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

@microbt/js-bridge

v0.0.0

Published

a brige for microbt client

Downloads

3

Readme

JSBrige 使用说明书

将构建产物 dist/umd/js-bridge.min.js 内置到客户端内,由 Webview 启动时加载并运行 JSBridge

基础约定

// 调用示例
SuperACME.call('module', parameter, fulfilled, rejected);
  • 基础约定必须保持跨平台一致
  • SuperACME为客户端注入 Webview 的全局对象,访问SuperACME.version可获得当前 bridge 版本
  • 客户端在注入全局对象成功后,须通知运行时。Bridge 相关的所有调用发生在该通知之后。(通知方案待讨论 TODO)
  • module为客户端实现的具体方法名称
  • parameter为运行时传入的参数对象。参数的具体规范,应与具体module保持一一对应
  • 所有的 bridge 调用均为异步调用,fulfilled为成功调用的回调函数,rejected为失败调用的回调函数,没有其他回调情况
  • fulfilled的定义: (result) => void,其中result为模块调用返回的数据
  • rejected的定义: (error: {code: number; message: string; cause?: unknown}) => void,其中error为模块调用返回的错误对象。error.code为错误码,error.message为错误描述,error.detail为错误详情(可选)

注入脚本涉及到 IO 异步操作,客户端注入成功后,WebView 运行时才能访问SuperACME全局对象。

错误码约定

  • 0: 调用成功
  • 1000:本地系统异常(1001-1999)约定具体的本地系统错误码(尽可能的保持跨平台的一致性)TODO
  • 2000:本地业务异常(2001-2999)约定具体的业务错误码(保持跨平台的一致性)TODO
  • 3000:远程调用异常(3001-3999)约定具体的远程调用错误码(保持跨平台的一致性)TODO
  • 9999:未知的错误

页面的生命周期

SuperACME.call('onShow', {}, fulfilled);
  • 页面生命周期至少包含:onShow(页面转换到前台时的回调)、onHide(页面转换到后台时的回调)
  • 可选包含:onCreate(页面创建时的回调)、onDestroy(页面销毁时的回调)
  • fulfilled的返回值待讨论 TODO
  • 该调用没有失败

判断模块/接口是否存在

SuperACME.call('canIUse', 'module', fulfilled);
  • module为模块名
  • fulfilled的返回值为true or false
  • 该方法不会调用失败

Model 定义

明确定义各个模块的入参与出参的数据结构。TODO

  • 客户端版本
  • 远程请求
  • 打开新的窗口
  • 支付
  • 用户信息