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

nejsbridge

v1.8.14

Published

文学漫画h5和native通信库

Downloads

269

Readme

文学漫画h5和native通信库

该项目包含h5和native通信库(schema和bridge实现)、文学漫画各个产品的通信协议文档和具体实现,并对老版本schema方式的通信做兼容,在 http://doc.hz.netease.com/pages/viewpage.action?pageId=80308439 了解jsbridge的细节

文档

文档使用apidoc生成。

# 全部
apidoc -i src/ -o out/all/

# 公用部分
apidoc -i src/lib/ -o out/lib/

# 蜗牛部分,在线地址 http://doc.hz.netease.com/pages/viewpage.action?pageId=85264142
apidoc -i src/snail -i src/lib/ -o out/snail/

# 漫画部分,在线地址 http://doc.hz.netease.com/pages/viewpage.action?pageId=85264165
apidoc -i src/comic -i src/lib/ -o out/comic/

# 阅读部分,在线地址 http://doc.hz.netease.com/pages/viewpage.action?pageId=105039339
apidoc -i src/read -o out/read/

# Lofter部分,在线地址 http://doc.hz.netease.com/pages/viewpage.action?pageId=179606608
apidoc -i src/lofter -o out/lofter/

使用

每个产品都有单独的入口文件

  1. 漫画在src/comic/comic.js
  2. 蜗牛在src/snail/snail.js
  3. Lofter在src/lofter/lofter.js

使用rollup构建

# 安装依赖
npm install

# 构建
npm run build

# 发布
npm version patch
npm publish

生成的文件在dist下,以漫画为例,bridge.comic.js是umd格式,如果通过script引入,命名空间为Bridge.comic,bridge.comic.es.js是module格式

// umd

Bridge.comic.callHandler;
Bridge.comic.registerHandler;

// es
import {callHanlder, registerHandler} from 'nejsbridge/dist/bridge.comic.es.js';

API选项

callHandler h5主动跟客户端通信

Bridge.comic.callHandler(actionName, data, callback);
  • actionName – type: string. 接口名
  • data – type: object. 数据
  • callback – type: funtion. 回调函数,可选

registerHandler h5注册协议,客户端发起通信

Bridge.comic.callHandler(actionName, callback);
  • actionName – type: string. 接口名
  • callback – type: funtion. 回调函数

support 判断当前客户端是否支持该协议

Bridge.comic.support(actionName);
  • actionName – type: string. 接口名

返回值为Booleantrue表示支持,false表示不支持

新产品接入

准备工作

  1. 熟悉apidoc的文档 http://apidocjs.com/
  2. 了解rollup的基本使用和配置文件的构成
  3. 参考蜗牛已有的实现 src/snail/snail.js

需要基于APIAbstract实现API接口说明

  1. schemaName_是产品的schema头
  2. isInApp判断是否在app里
  3. getLegacyProtocolConfig实现具体兼容老版本的协议

开始

  1. 定义产品所需的协议和文档
  2. 实现接口
  3. 处理好打包相关的内容
  4. 记得更新本readme哦

备注

  1. LOFTER客户端6.19.0客户端JSBridge SDK有更新,多次注册同一registerHandler协议将不再互相覆盖,而是会以数组形式储存,然后按照注册顺序一次触发。