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

@xiao-ying/miniapp-sdk

v1.3.0

Published

小应移动端官方 Hybrid JS-SDK。Web 页面在 WebView 内直连原生能力;浏览器运行时由 `@xiao-ying/miniapp-sdk-browser` 提供。

Readme

@xiao-ying/miniapp-sdk

小应移动端官方 Hybrid JS-SDK。Web 页面在 WebView 内直连原生能力;浏览器运行时由 @xiao-ying/miniapp-sdk-browser 提供。

特性

  • 桥接核心:App WebView 内直连原生能力
  • 浏览器实现拆包:浏览器运行时由独立包提供
  • TypeScript 类型完整:全量类型导出,默认挂载全局 xy
  • 常用能力覆盖:网络、文件、媒体、剪贴板、UI、路由、存储、分享与鉴权

安装

App WebView 环境:

pnpm add @xiao-ying/miniapp-sdk

浏览器环境(需要额外安装浏览器包):

pnpm add @xiao-ying/miniapp-sdk @xiao-ying/miniapp-sdk-browser

快速开始

在入口处引入一次,SDK 会自动挂载全局 xy

import '@xiao-ying/miniapp-sdk'

浏览器运行时需要额外引入浏览器包:

import '@xiao-ying/miniapp-sdk'
import '@xiao-ying/miniapp-sdk-browser'

const res = await xy.request({
  url: '/api/user/info',
  method: 'GET'
})

const unsubscribe = xy.onStorageChange(({ key, newValue }) => {
  console.log('storage changed', key, newValue)
})

const unsubscribeError = xy.onError((info) => {
  console.warn('sdk error', info.method, info.code, info.message)
})

unsubscribe()
unsubscribeError()

运行时配置(可选)

宿主可在页面注入 window.__XY_CONFIG__,用于标识运行模式与宿主信息。以下为常见字段示例(字段类型以 XYNativeConfig 为准):

<script>
  window.__XY_CONFIG__ = {
    appVersion: '26.3.0',
    engineVersion: '1.9.0',
    platform: 'android',      // ios | android | macos | windows | linux | web
    runtime: 'app',           // app: WebView
    sessionId: '...',
    viewMode: 'fullScreen',   // fullScreen | sheet
    env: {
      school: 'demo-school',
      campus: 'main',
      devMode: true
    },
    mediaQuery: {
      statusBarHeight: 24,
      safeAreaInsets: { top: 24, bottom: 0, left: 0, right: 0 },
      size: { width: 390, height: 844 },
      devicePixelRatio: 3
    },
    brightness: 'light',      // light | dark
    intent: {},
    path: '/',
    isForeground: true,
    manifest: {
      id: 'example',
      name: '小应小程序示例',
      description: '小应官方示例小应小程序',
      iconUrl: 'https://example.com/icon.png',
      channel: 'dev',
      initialPath: '/',
      entryPrefix: '/app/#',
      host: 'example.com',
      protocol: 'https',
      minEngineVersion: '1.9.0',
      permissions: ['network', 'storage'],
      config: {
        showBackButton: true,
        showTitle: true,
        showMenuButton: true,
        useHostSafeArea: false
      }
    }
  }
</script>

运行模式与兼容

  • runtime = 'app' 且原生桥接可用时走原生能力。
  • 浏览器运行时需引入 @xiao-ying/miniapp-sdk-browser,是否启用由入口导入方式决定。
  • 调用前可通过 xy.supports('>=1.9.0') 判断宿主 engine 版本是否满足要求。

API 总览

  • 环境与会话:appVersionengineVersionsdkVersionplatformenvsessionIdmanifestruntimeviewModemediaQuerybrightnessintentparentMiniAppisForeground
  • 能力检测:supports
  • 网络:requestuploadFiledownloadFile
  • WebSocket:ws
  • 媒体与工具:pickImagecompressImagecropImagepickFilepickDatepickTimescanCode
  • 剪贴板:hasClipboardDatagetClipboardDatasetClipboardData
  • UI:showToastshowModalopenMenuvibrate
  • 路由:openUrlopenFileopenMiniAppexit
  • 生命周期:onForegroundonBackgroundonStorageChangeonBrightnessChange
  • 存储:setStoragegetStorageremoveStorageclearStorage
  • 分享与聊天:setShareHandlersharechat
  • Cookie:getCookiessetCookieremoveCookieclearCookies
  • 鉴权:getAuthStateonAuthStateChangesignIn
  • 错误订阅:onError(统一监听参数校验/运行时错误)

相关包

  • @xiao-ying/miniapp-request:axios 风格请求封装(request/upload/download 统一管理)
  • @xiao-ying/miniapp-hooks:React hooks 封装(brightness/storage 等响应式)
  • @xiao-ying/miniapp-cloud-kit:Cloud KV / Snapshot 核心 API
  • @xiao-ying/miniapp-cloud-hooks:Cloud KV / Snapshot 的 SWR hooks
  • @xiao-ying/miniapp-proxy:开发态跨域代理(配合浏览器运行时)
  • @xiao-ying/miniapp-sdk-browser:浏览器运行时实现

文档

  • 入门与示例:docs/guide/getting-started.md
  • API 能力:docs/guide/api.md
  • 文档总览:docs/index.md