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

@wevu/api

v0.1.1

Published

tsdown bundler template

Readme

@wevu/api

简介

@wevu/api 提供跨平台的小程序 API 封装,默认推荐 Promise 风格,同时兼容传统回调风格。

特性

  • 动态代理,覆盖微信小程序全量 API
  • 跨平台适配(微信/支付宝/百度/字节/QQ/快应用/京东/小红书/快手/淘宝等)
  • Promise 风格优先,回调风格可用
  • 支持显式注入平台适配器

类型对齐与平台支持

@wevu/api 的默认导出 wpi 会同时对齐:

  • 微信类型:miniprogram-api-typings
  • 支付宝类型:@mini-types/alipay
  • 抖音类型:@douyin-microapp/typings

平台类型对齐矩阵

| 平台 | 全局对象 | 类型来源 | 支持度 | | --- | --- | --- | --- | | 微信小程序 | wx | miniprogram-api-typings | ✅ 全量 | | 支付宝小程序 | my | @mini-types/alipay | ✅ 全量 | | 抖音小程序 | tt | @douyin-microapp/typings | ✅ 全量 | | 其他平台(swan/jd/xhs 等) | 运行时宿主对象 | 运行时透传 | ⚠️ 按宿主能力支持 |

API 支持覆盖率报告

| 平台 | 已支持 API 数 | API 总数 | 覆盖率 | | --- | --- | --- | --- | | 微信小程序 (wx) | 8 | 8 | 100.00% | | 支付宝小程序 (my) | 8 | 8 | 100.00% | | 抖音小程序 (tt) | 8 | 8 | 100.00% | | 三端完全对齐 (wx/my/tt) | 8 | 8 | 100.00% |

该报告由 WEAPI_METHOD_SUPPORT_MATRIX 与映射规则自动计算生成。

核心跨端映射矩阵

| API | 说明 | 微信策略 | 支付宝策略 | 抖音策略 | 支持度 | | --- | --- | --- | --- | --- | --- | | showToast | 显示消息提示框。 | 直连 wx.showToast | title/icon 映射到 content/type 后调用 my.showToast | icon=error 映射为 fail 后调用 tt.showToast | ✅ | | showLoading | 显示 loading 提示框。 | 直连 wx.showLoading | title 映射到 content 后调用 my.showLoading | 直连 tt.showLoading | ✅ | | showActionSheet | 显示操作菜单。 | 直连 wx.showActionSheet | itemListitemsindextapIndex 双向对齐 | 直连 tt.showActionSheet,并兼容 indextapIndex | ✅ | | showModal | 显示模态弹窗。 | 直连 wx.showModal | 调用 my.confirm 并对齐按钮字段与 cancel 结果 | 直连 tt.showModal | ✅ | | chooseImage | 选择图片。 | 直连 wx.chooseImage | 返回值 apFilePaths 映射到 tempFilePaths | tempFilePaths 字符串转数组,缺失时从 tempFiles.path 兜底 | ✅ | | saveFile | 保存文件。 | 直连 wx.saveFile | 请求参数 tempFilePathapFilePath、结果映射为 savedFilePath | 直连 tt.saveFile,并在缺失时用 filePath 兜底 savedFilePath | ✅ | | setClipboardData | 设置剪贴板内容。 | 直连 wx.setClipboardData | 转调 my.setClipboard 并映射 datatext | 直连 tt.setClipboardData | ✅ | | getClipboardData | 获取剪贴板内容。 | 直连 wx.getClipboardData | 转调 my.getClipboard 并映射 textdata | 直连 tt.getClipboardData | ✅ |

安装

pnpm add @wevu/api

使用

Promise 风格(推荐)

import { wpi } from '@wevu/api'

const res = await wpi.request({
  url: 'https://example.com',
  method: 'GET',
})

console.log(res)

回调风格(兼容)

import { wpi } from '@wevu/api'

wpi.request({
  url: 'https://example.com',
  method: 'GET',
  success(res) {
    console.log(res)
  },
  fail(err) {
    console.error(err)
  },
})

显式注入平台适配器

import { createWeapi } from '@wevu/api'

const api = createWeapi({
  adapter: wx,
  platform: 'wx',
})

await api.getSystemInfo()

行为说明

  • 只在不传回调时返回 Promise
  • 同步 API(*Sync)与事件 API(onXxx/offXxx)直接透传
  • 缺失 API 时:
    • 回调风格触发 fail/complete
    • Promise 风格返回 rejected Promise

相关链接

  • 仓库:https://github.com/weapp-vite/weapp-vite