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

zzcBridge

v2.1.2

Published

js与native相互通讯桥梁,通过单一入口调用接口,并在控制台打印日志,localStorage持久化保存日志

Downloads

2

Readme

zzcBridge

js与native相互通讯桥梁,封装单一调用入口,并在控制台打印日志,localStorage持久化保存日志

Build Status

文档

测试页面(用APP访问)

fuck

  • 除了功能接口,还有各项目的具体业务需求接口
  • cordova不能准确触发ready状态
  • Android或iOS特有接口
  • 将log永久保存起来,同时也打印到控制台。

用例:

npm install --save zzcBridge

拷贝 ./dist 目录版本,通过<script/>引入。

下面用例的接口都是假的

调用cordova接口,example:

import * as zzcBridge from 'zzcBridge';
const {
  init,
  exec
} = zzcBridge;

// 初始化,定义需要用到的接口
init([
  'setTitle',
  'alert',
  'setTabbarColor'
]);

// 警告
document.onclick = function () {
  exec('alert', {content: '警告'});
}

exec('setTitle', {
  content: '标题',
  success: function (res) {
    console.log(res);
  },
  error: function (err) {
    console.log(err);
  }
});


exec('setTabbarColor', {color: 'light'})
// 等同于success()和error()
.then(function (res) {
  console.log(res);
}, function (err) {
  // 如果接口不存在 err.code === 404
  console.log(err);
});

直接调用cordova接口不用init()

import {
  exist,
  execUnsafe
} from 'zzcBridge';

if (exist('alert')) {
  execUnsafe('alert', {content: '经过'});
} else {
  alert('经过');
}

注册接口给native,example:

import {register} from 'zzcBridge';

// 断网的时候调用
register('offline', function () {
  console.log('断网啦');
});

// 联网的时候调用
register('online', function () {
  console.log('联网啦');
});

依赖

  • events
  • 低版本浏览器需要promise polyfill

自动化npm脚本

  • test 单元测试(包含:lint)
  • build:dev 构建源码(development模式)
  • build:pro 构建源码(production模式)
  • compile 编译源码
  • lint 检测代码语法和风格
  • lint:watch 增强版的lint
  • install-git-hooks 安装git hooks
  • doc 生成文档
  • build 构建项目(包含:test, build:dev, build:pro, compile, doc)
  • prepublish 发布前的测试
  • postpublish 发布后同步到github
  • demos 生成demos页面

APIS

  • init(apis) 初始化API,只能调用一次
  • exec(api, params) 调用cordova API,会等待ready之后才调用
  • register(api, callback) 注册js API给native调用
  • exist(api) 判断api是否存在
    • exist() 判断cordova对象是否存在
  • ready(success, error) 当cordova API准备好后调用success函数,超时则调用error函数
  • ready() cordova API是否准备好
  • execUnsafe(api, params) 调用cordova API,不会等待ready
  • events register是events.on的别名,所以...