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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dz-bridge-sdk-core

v1.3.0

Published

> 该SDK主要包含与原生 APP/ PC / Web(iframe) 的Webview JS Bridge的通讯协议的封装

Downloads

9

Readme

Webview JS Bridge SDK 核心库

该SDK主要包含与原生 APP/ PC / Web(iframe) 的Webview JS Bridge的通讯协议的封装

用法

ES6

# 安装核心库
yarn add dz-bridge-sdk-core 
import dz from 'dz-bridge-sdk-core'

dz.onReady.then(function () {
  // 调用APP打开新的一个网页,并获得APP的回调数据 response
  dz.call.url('http://www.baidu.com').then(response => {
    console.log(response);
  });

  // async 写法
  const response = await dz.call.url('http://www.baidu.com');
  console.log(response);

  // 调起APP的登录
  dz.call.view('login');
});

ES5

<!-- 引入sdk -->
<script src="dz.sdk.core.app.min.js"></script>

<script>
  // 调用APP打开新的一个网页,并获得APP的回调数据 response
  dz.call.url('http://www.baidu.com').then(function(response) {
  console.log(response);
});

  // 调起APP的登录
  dz.call.view('login');

  // 向APP注册一个test函数,接收参数params,并且可以通过callBack函数回调APP,给APP传递结果
  dz.register('test', function (params, callBack) {
  console.log('call test', p);
  callBack('test back!')
});
</script>

API

call

调用 APP / PC / Web(iframe) 的函数,支持的方法包括:

  • call.url 在新的页面中打开一个网站;
  • call.view 在新的页面中打开原生视图,如:登录、注册等;
  • call.file 在新的页面中打开一个本地文件;
  • call.app 打开本地其他应用,如:QQ、微信等;
  • call.msg JS向Native App传递一个消息。
dz.call.url(cmd, params).then(response =>
...)

参数|必填|类型|说明|示例 |---|---|---|---|---| cmd|是|String|对应 移动端JS与原生交互接口规范command字段内容|call.view('login') params|否|String / Object|对应 移动端JS与原生交互接口规范params字段内容|call.view('login',{name:'kiny',age:44}) response|否|String / Object| APP返回的数据|call.view('login',{name:'kiny'}).then(response => ...)

register

向 APP / PC / Web(iframe) 注册JS函数

参数|必填|类型|说明 |---|---|---|---| functionName |是|String|需要注册的函数名 params|否|String / Object|APP调用该JS函数时,可传入的参数 callback |否|Function|JS函数执行完成时,回调APP

dz.register(functionName, function (params, callback) {
...
  callback(...)
})

示例:

dz.register('test', function (p, callBack) {
  console.log('params from app ', p);
  callBack('hello,app!' + JSON.stringify(p))
});