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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hd-front-end/jsbridge-sdk

v1.0.6

Published

HD JSBridge SDK - 统一的原生能力封装

Readme

JSBridge SDK

生产级 JSBridge SDK - 通过原生 log 能力实现监控和日志上报

✨ 核心特性

  • 🎯 职责单一 - 只封装原生 API,不包含适配层
  • 📱 双平台支持 - 兼容 Android 和 iOS
  • 📊 统一日志管理 - 监控和业务日志都通过原生 log 上报
  • 📝 提供 log API - 子应用可以上传业务日志
  • 🔍 Debug 模式 - 支持开启调试模式和调用追踪
  • 💪 类型安全 - 完整的 TypeScript 类型定义
  • 高性能 - 毫秒级初始化,内置竞态处理机制
  • 📦 体积小 - 20KB(gzip: 7KB)

🎯 两个目的

  1. 监控 SDK 稳定性 - SDK 自动记录性能和错误,通过原生 log 上报
  2. 提供子应用日志能力 - 子应用调用 JSBridge.log.* 上传业务日志

🚀 快速开始

安装

npm install @hd-front-end/jsbridge-sdk

基础使用

import { init, JSBridge } from '@hd-front-end/jsbridge-sdk'

// 初始化
await init({
  monitor: {
    enabled: true,
    autoReport: true,        // 通过 log 自动上报
    logTag: 'JSBridge-Monitor'
  }
})

// 使用 bridge API
// SDK 会自动处理初始化等待,无需手动 check
const result = await JSBridge.scan()

// 上传业务日志
await JSBridge.log.info('用户点击了购买按钮', 'UserBehavior')
await JSBridge.log.error('支付失败', 'Payment')

调试模式

SDK 不再内置 vConsole,以减少包体积和避免依赖冲突。如果需要 vConsole,请在业务项目中自行安装。

// 业务代码中
import VConsole from 'vconsole'

if (process.env.NODE_ENV === 'development') {
  new VConsole()
  
  // 开启 SDK 调试模式
  init({
    debug: {
      enabled: true, // 开启后会在控制台输出详细的调用日志
      logLevel: 'debug'
    }
  })
}

📚 文档

快速入口

详细文档

工作总结

🏗️ 架构设计

┌─────────────────────────────────────┐
│  子应用                              │
│  - 调用 JSBridge.log.info(...)      │
│  - 上传业务日志                      │
└─────────────────────────────────────┘
            ↓
┌─────────────────────────────────────┐
│  @hd-front-end/jsbridge-sdk                   │
│  ├── 核心通信(Android/iOS)         │
│  ├── API 层(device/media/log...)  │
│  ├── 监控层(通过 log 上报)         │
│  └── Debug 层(调用追踪)           │
└─────────────────────────────────────┘
            ↓
┌─────────────────────────────────────┐
│  原生 WebView                        │
│  ├── log handler                    │
│  ├── LogUtil 写入日志文件            │
│  └── 统一上传到服务器                │
└─────────────────────────────────────┘

💻 核心 API

Bridge API

// 扫码
const result = await JSBridge.scan()

// 拨打电话
await JSBridge.makePhoneCall({ phoneNumber: '10086' })

// 震动
await JSBridge.vibrate()

// 获取设备信息
const info = await JSBridge.getDeviceInfo()

Log API

// 记录日志
await JSBridge.log.info('操作成功', 'Business')
await JSBridge.log.error('接口异常', 'Network', { status: 500 })