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

sf-bridge

v1.2.0-beta.1

Published

bridge

Downloads

19

Readme

Bridge

介绍

提供了一套方便使用端能力的api,并且所有api在非APP环境中使用均做了降级替换;提供检查是否在APP内部,如果在APP内部使用NA能力完成,若在纯浏览器环境,则自动切换成Substitute功能,使hybrid H5与浏览器无缝使用同一套代码;

一期实现

  1. NA代发请求,用于离线、跨域情形;

  2. 拍照;

  3. 扫条形码;

  4. 环境检查;

持续更新ing

使用指南

// 安装
npm install --save sf-bridge
// 环境检查
import bridge from 'sf-bridge';
// return bool;
const isInApp = bridge.utils.isInApp(); 
// NA代发请求
import bridge from 'sf-bridge';

const { get, post, setHost, sendRequest } = bridge.network;

// 设置host 仅需设置一次,且必须设置,若需要跨多个域取数据则设置为'', 而后请求使用完整路径;
setHost('http://gz-loc-development00.gz.sftcwl.com:9949');

// 发送请求 Promise,url为/appname/getsth
get(url, params, headers).then(response => {
  // do sth
});

post(url, params, headers).then(response => {
  // do sth
});

// 直接使用未封装方法与NA交互可配置数据如下
// data = {
//   url: Fullurl,
//   contentType: 'application/x-www-form-urlencoded',
//   httpBody: query.join('&'),
//   headers: {...}
// }
sendRequest(data).then(response => {
  // do sth
});
// 拍照、扫码
import bridge from 'sf-bridge';
const { scanCode, takePhoto } = bridge.device;

scanCode().then((data) => {
  console.log(data); // {status: "1", result: {code: "6901236341292"}}
});

注意事项

  1. 需要端上提前注入static/base.js;
  2. 代发请求需要先行调用network.setHost()设置请求host;