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

stbridge-api

v0.0.2

Published

- 执行命令:`npm i stbridge-api`

Downloads

2

Readme

安装说明

  • 执行命令:npm i stbridge-api

  • main.js文件中全局注入

require('stbridge-api')

使用说明

- js调用native api

window.stBridge.common.getUserInfo(response => {
    console.log(response)
})

- 注册js api供native调用

window.stBridge.custom.registerAsyn('namespace.api', (params, responseCallback) => {
    console.log(JSON.stringify(params));
    responseCallback(response);
})

- 添加自定义api(需android端api支持)

1.新建一个Java类,实现API
      public class JsApi{
          //同步API
          @JavascriptInterface
          public String testSyn(Object msg)  {
              return msg + "[syn call]";
          }

          //异步API
          @JavascriptInterface
          public void testAsyn(Object msg, CompletionHandler<String> handler) {
              handler.complete(msg+" [ asyn call]");
          }
      }
2. 添加API类实例到 DWebView .
        import wendu.dsbridge.DWebView
        ...
        DWebView dwebView= (DWebView) findViewById(R.id.dwebview);
        dwebView.addJavascriptObject(new JsApi(), 'custom');
3. 在Javascript中调用原生 (Java/Object-c/swift) API ,并注册一个 javascript API供原生调用.
  • 调用原生API ,并注册一个 javascript API供原生调用.

            window.stBridge.custom.call('custom.testSyn', params)

            //注册 javascript API 
            window.stBridge.custom.registerAsyn('custom.testJava', (l, r) => {
                return l + r;
            })
4. 在Java中调用 Javascript API
        dwebView.callHandler("custom.testJava",new Object[]{3,4},new OnReturnValue<Integer>(){
                @Override
                public void onValue(Integer retValue) {
                Log.d("jsbridge","call succeed,return value is "+retValue);
                }
        });

API列表

common

| API | Type | Description | | ---| :---: | --- | | getUserInfo | js | 获取用户信息、token | | senseHttp | js | ajax调用 | | setColor | js | 设置标题栏颜色 | | setTitle | js | 设置标题 | | statusbarBack | native | 返回按钮触发事件 | | closeWindow | js | 关闭页面 | | openWindow | js | 打开新的页面 |

share

| API | Type | Description | | --- | :---: | --- | | share | js | 调用分享面板 | | isWXAppInstalled | js | 微信app是否安装 | | shareToWXSession | js | 分享给微信好友 | | shareToWXTimeline | js | 分享微信朋友圈 | | shareToWXFavorite | js | 添加到微信收藏 |

custom

| API | Type | Description | | --- | :---: | --- | | call | js | 同步调用 | | callAsyn | js | 异步调用 | | callProgress | js | 进度回调:一次调用,多次返回 | | register | native | 注册同步api供java端调用 | | registerAsyn | native | 注册异步api供java端调用 | | registerWidthNamspace | native | 命名空间 |