npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bnd-app-js

v1.0.4

Published

bnd-app-js

Readme

import { loginInDevelopment } from './libs/index.js'

const ua = window.navigator.userAgent
const ipad = ua.match(/(iPad).*OS\s([\d_]+)/)
const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/)
const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/)
const isAndroid = ua.match(/(Android);?[\s\/]+([\d.]+)?/)
const isIos=ipad||ipod||iphone
const isDesktop=!(isIos||isAndroid)
if (isDesktop) {
  localStorage.setItem('developmentInPC', 1)
}
const isInXqc = !isDesktop && localStorage.getItem('developmentInPC') === null
console.info(`develop in PC:${!isInXqc}`)
const webViewJavascriptBridgeReady = () => {
  function initWebViewJavascriptBridge(bridge) {
    bridge.init(function (responseCallback) {
      console.log('JS got a message')
      const data = {
        'Javascript Responds': 'Wee!'
      }
      console.log('JS responding with', data)
      responseCallback(data)
    })
  }
  return new Promise((resolve, reject) => {
    if (window.WebViewJavascriptBridge) {
      initWebViewJavascriptBridge(window.WebViewJavascriptBridge)
      resolve(window.WebViewJavascriptBridge)
    } else {
      document.addEventListener(
        'WebViewJavascriptBridgeReady',
        function () {
          initWebViewJavascriptBridge(window.WebViewJavascriptBridge)
          resolve(window.WebViewJavascriptBridge)
        },
        false
      )
    }
  })
}
/**
 * @param {Object} param 调用源生方法的参数,{name,data={}}
 * @description 调用源生方法
 */
const caller = async function ({
  name,
  param = {}
}) {
  try {
    const bridge = await webViewJavascriptBridgeReady()
    return new Promise((resolve, reject) => {
      bridge.callHandler(name, data, responseData => {
        if (isAndroid) {
          responseData = JSON.parse(responseData)
        }
        resolve(responseData)
      })
    })
  } catch (error) {
    throw error
  }
}

const app = {
  /**
   * @description get access token
   */
  async getAccessToken() {
    let result, accessToken, devAccessToken
    if (isInXqc) {
      accessToken = sessionStorage.getItem('accessToken')
      if (!accessToken) {
        result = await caller({
          name: 'userCarGetAccessToken'
        })
        accessToken = result.data
        sessionStorage.setItem('accessToken', accessToken)
      }
      return accessToken
    } else {
      //
      devAccessToken = sessionStorage.getItem('devAccessToken')
      if (!devAccessToken) {
        result = await loginInDevelopment()
        console.log(result)
        if(result.code===10200){
        devAccessToken = result.data['access_token']
        sessionStorage.setItem('devAccessToken', devAccessToken)
        }else{
          console.error('登录失败')
        }
      }
      return devAccessToken
    }
  },
  /**
   * @return Promise Object
   * @description Get current user information.
   */
  getUserInfo() {
    if (isInXqc) {
      return caller({
        name: 'userCarGetUserInfo'
      })
    } else {
      console.log('Open camera. Original function name:"userCarGetUserInfo"')
    }
  },
  /**
   * @return Promise Object
   * @description back to the previous page.
   */
  goBack() {
    if (isInXqc) {
      return caller({
        name: 'platformBack'
      })
    } else {
      console.log('Go back to the previous page. Original function name:"platformBack"')
    }
  },
  /**
   * @return Promise Object
   * @description Close current page.
   */
  exit() {
    if (isInXqc) {
      return caller({
        name: 'platformPop'
      })
    } else {
      console.log('Exit. Close current page. Original function name:"platformPop"')
    }
  },
  /**
   * @param {Object} param {maxImageNum,isUpload,waterMark}
   * @return Promise Object
   * @description Open camera.
   */
  openCamera(param = {}) {
    param = Object.assign({
      maxImageNum: 1,
      isUpload: 1,
      waterMark: '薪公务用车'
    }, param)
    if (isInXqc) {
      return caller({
        name: 'platformCamera',
        param
      })
    } else {
      console.log('Open camera. Original function name:"platformCamera"')
    }
  },
  /**
   * @param {String} viewKey the target view's key
   * @return Promise Object
   * @description Open an app view.
   */
  openAppView(viewKey) {
    if (isInXqc) {
      return caller({
        name: 'callbackApp',
        param: {
          viewKey
        }
      })
    } else {
      console.log('Open an app view. Original function name:"callbackApp"')
    }
  },
  /**
   * @param {Object} param share information {title,content,url}
   * @return Promise Object
   * @description Open an app view.
   */
  shareFile(param = {}) {
    param = Object.assign({
      title: '薪公务用车',
      url: document.location.href,
      content: document.title
    }, param)
    if (isInXqc) {
      return caller({
        name: 'shareFile',
        param
      })
    } else {
      console.log('Share. Original function name:"shareFile"')
    }
  },
    /**
   * @return Promise Object
   * @description Get location information.
   */
  location() {
    if (isInXqc) {
      return caller({
        name: 'location'
      })
    } else {
      console.log('Get location information. Close current page. Original function name:"location"')
    }
  },
    /**
   * @param {Object} param webview information {type:'1','linkUrl':'https://www.baidu.com'}
   * @return Promise Object
   * @description Open a new webview. more information in http://192.168.0.247:8002/pages/viewpage.action?pageId=27386693
   */
  openWebview(param = {}) {
    param = Object.assign({
      type: '1',
      linkUrl: 'https://www.baidu.com'
    }, param)
    if (isInXqc) {
      return caller({
        name: 'openNewWebView',
        param
      })
    } else {
      console.log('Open a new webview. Original function name:"openNewWebView"')
    }
  },
  install: function(Vue) {
    Vue.prototype.$app=app
  }
}
window.BndApp=app
export default app