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

@arkmp/api

v0.2.1

Published

Readme

@arkmp/api

对外发布包

ArkMP 源码侧 API 命名空间(仿鸿蒙 kit 风格)+ wx.* 映射表。命名空间对象仅供 .ets 源码获得类型提示,所有方法在编译期被改写为 wx.* 调用(映射关系见 mapping.ts,对应设计文档 06 篇),直接运行会抛出明确错误。

所属层

L6 source-side(独立子树)。

依赖

无外部依赖(package.json 仅含构建/测试用 devDependencies)。本包不含 workspace 依赖,映射表为纯数据,命名空间为编译期占位实现。

导出 API

映射表与查询函数

getApiMapping(source: string): ApiMapping | undefined

按源码侧 API 路径查询映射,如 getApiMapping('http.request'),返回对应 ApiMappingundefined

listApiMappings(category?: ApiCategory): readonly ApiMapping[]

列出映射条目;可按类别过滤('router' / 'system'),缺省返回全部。

apiMappings: readonly ApiMapping[]

全量映射表(路由 + 系统 + 不支持能力)。

routerMappings: readonly ApiMapping[]

路由适配映射(06 篇"路由适配"表,6 条)。

systemMappings: readonly ApiMapping[]

系统 API 映射(06 篇"系统 API 映射"表,14 条)。

unsupportedMappings: readonly ApiMapping[]

平台能力缺失条目(06 篇),targetnullfallback 字段为 E3xxx 诊断文案来源。

ApiMapping(类型)

单条映射结构,字段:source(源码侧 API 路径)、signature(签名描述)、target(产物 wx.* API 名,不支持时为 null)、adapter(参数适配方式 direct/wrap/unsupported)、runtimeBridge(是否依赖 @arkmp/runtime 桥接)、note(适配说明)、fallback?(降级诊断与替代建议)、category'router' | 'system')。

ApiCategory(类型)

'router' | 'system'

ParamAdapter(类型)

'direct' | 'wrap' | 'unsupported'

源码侧命名空间

以下命名空间对象均为编译期占位实现(直接调用抛错),提供 Promise 风格的类型签名:

  • http: HttpNamespacerequest(url, options?): Promise<HttpResponse>(→ wx.request)。
  • storage: StorageNamespaceset(key, value) / get<T>(key) / remove(key)(→ wx.setStorageSync 等,值自动 JSON 序列化)。
  • prompt: PromptNamespaceshowToast / showDialog / showActionMenu(→ wx.showToast/wx.showModal/wx.showActionSheet)。
  • media: MediaNamespacepickImage(options?) / previewImage(urls, current?)(→ wx.chooseMedia/wx.previewImage)。
  • location: LocationNamespacegetCurrent(): Promise<GeoLocation>(→ wx.getLocation)。
  • share: ShareNamespaceshare(options)(编译为 onShareAppMessage 配置)。
  • auth: AuthNamespacelogin(): Promise<LoginResult>(→ wx.login)。
  • device: DeviceNamespacegetNetworkType(): Promise<NetworkType>(→ wx.getNetworkType)。
  • pay: PayNamespacerequest(params): Promise<void>(→ wx.requestPayment)。

各命名空间的选项/返回类型(HttpRequestOptionsHttpResponseHttpMethodShowToastOptionsDialogButtonShowDialogOptionsShowActionMenuOptionsPickImageOptionsGeoLocationShareOptionsLoginResultNetworkTypePayRequestParams 等)均从本包导出。

用法示例

import { http, storage, prompt, getApiMapping } from '@arkmp/api';

// 源码侧调用(编译期被改写为 wx.*,类型提示由本包提供)
async function onLoad() {
  const res = await http.request('https://example.com', { method: 'GET' });
  await storage.set('lastStatus', res.statusCode);
  await prompt.showToast({ message: 'done' });
}

// 编译器侧查询映射
const mapping = getApiMapping('http.request');
// mapping.target === 'wx.request',mapping.runtimeBridge === true

测试

pnpm --filter @arkmp/api test