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

djapp-bridge

v1.0.4

Published

djapp-bridge是东家app工具类集合,包括: * 平台判断工具类:detector * jsbridge类:jsbridge * launch唤起类:launch,如果你想了解一些唤端的原理知识[H5 唤起 APP 指南](https://suanmei.github.io/2018/08/23/h5_call_app/) * 头部引流组件:imk

Readme

djapp-bridge

djapp-bridge是东家app工具类集合,包括:

  • 平台判断工具类:detector
  • jsbridge类:jsbridge
  • launch唤起类:launch,如果你想了解一些唤端的原理知识H5 唤起 APP 指南
  • 头部引流组件:imk

Install

Install with npm:

npm install --save djapp-bridge

Usage

const DjappBridge = require('djapp-bridge');

or

import DjappBridge from 'djapp-bridge';

djapp-bridge 同样支持 script 加载,你可以使用下面的 cdn 文件(地址在下面的示例中),也可以下载 dist/djapp-bridge.js 到你的项目中,djapp-bridge.js 会暴露一个全局变量 DjappBridge ,这个全局变量和上面 commonjs 导入的 DjappBridge 内容是一致的,使用方法也是一致的。

<!-- 及时下载压缩的最新版本 Js -->
<script src="//storage.360buyimg.com/dj-assets/js/bridge/djapp-bridge.1.0.1.min.js
"></script>

使用方法

  1. detector类,环境判断类,返回os对象和browser对象,其中os对象代表系统,browser代表浏览器环境
{
  os: {
    fullVersion: "13.2.3"
    ios: 13.2
    name: "ios"
    version: 13.2
  },
  browser: {
    fullMode: "13.0.3"
    fullVersion: "13.0.3"
    mode: 13
    name: "safari"
    safari: 13
    version: 13
  }
}
  1. jsbridge类,h5与东家app交互类
// h5调原生app方法
function callHandler(method, param, callback, delay) {

}
// 或者
function callHandler(method, param, delay) {

}

// h5给原生app发送数据
function send(data, callback, delay) {

}
// 或者
function send(data, delay) {

}

// 原生app调用h5的方法
function registerHandler(method, callback, delay) {

}
  • 1.0.3升级内容
    1. jsbirdge各个方法增加防抖,支持delay参数,boolean类型,是否开启防抖,开启后300ms内函数只能执行一次,默认关闭状态。 此处注意:函数防抖维度为jsbirdge的各个方法,比如300ms内多次调用jsbirdge.callHandler,只会执行一次。所以在页面加载时调用jsbirdge的方法时慎用delay参数,只有在确定此处只需调用一次jsbirdge,并且需要防抖时才用,比如点击事件的回调中。

    2. jsbridge callback返回参数统一封装成对象,因为安卓端和ios在执行callback时返回参数不一致,ios端直接返回对象,安卓端返回 JSON.String,库这边统一处理,如果返回数据能够JSON.parse,咱返回JSON.parse后结果,如果不能,则原样返回

  1. Launch类,唤起东家app调用类
// 具体参数查看源码 defaultOptions,一般不用改动
const launch = new DjappBridge.Launch();

// 唤起方法,支持 errorHandle 参数,会阻止默认唤起失败逻辑
launch.open({
  path: 'openWebView',
  param: {
    url: 'https://www.jd.com'
  }
});

// 自动唤起方法,参数与open方法一致,只是在ios使用scheme方式唤起(兼容性不好)
launch.autoOpen({
  path: 'openWebView',
  param: {
    url: 'https://www.jd.com'
  }
});
  1. Imk类,头部引流横幅
// 参数 config, options
// config暂时只有wrap参数,传入容器id或class供querySelector查找
// options为launch的参数
// 现在点击只唤起app,不支持指定唤起
new DjappBridge.Imk();
  1. os类,环境判断的快捷类,其实是根据 detector来判断的,比如判断是否是ios:detector.os.name === 'ios', jr代表是否是金融app环境,dj代表是否为东家app环境
appVersion: "13.0.3"
device: {jr: false, dj: false, wx: false}
isAndroid: false
isIOS: true
osVersion: "13.2.3"

碰到任何问题请及时联系,代码库需要大家共同维护