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/runtime

v0.2.1

Published

Readme

@arkmp/runtime

ArkMP 产物侧运行时:在编译产物小程序工程中提供 state → data 桥接、生命周期分发、事件参数规范化与内置基础样式(对应设计文档 05/06 篇)。

所属层

L5 runtime(独立子树,不进入编译器依赖链)。

依赖

无外部依赖(package.json 仅含构建/测试用 devDependencies)。运行时无运行期第三方依赖,构建为单文件产物,直接拷贝进小程序工程。

导出 API

createPage(options: PageOptions): void

页面构造器封装。将 ArkUI 页面(@Entry + @Component)的状态、派生字段、@Watch、方法映射为原生 Page(config)state 桥接为 data + 批量 setDataaboutToAppear/onPageShow/onDidBuild/onPageHide/aboutToDisappear/onPullRefresh 映射为对应 Page 生命周期钩子(onLoad 中安装状态桥接)。返回 void

createComponent(options: ComponentOptions): void

组件构造器封装。将 ArkUI 自定义组件(@Component)的 propertiesstatederivedwatchmethods 映射为原生 Component(config):生命周期方法映射为 lifetimes.attached/ready/detached@Watch 桥接为 observers,保留用户自定义 observers/lifetimes。返回 void

normalizeEvent(e: Record<string, any>): NormalizedEvent

事件参数规范化。抹平 tap/touch/表单事件的结构差异,统一返回 NormalizedEventtypedetailiddatasetxytimeStamp)。

BASE_WXSS: string

编译器写入产物 wxss 的内置基础类定义(.arkmp-page/.arkmp-col/.arkmp-row/.arkmp-text/.arkmp-btn),字符串常量。

类型

  • PageOptionscreatePage 入参,含 state?derived?watch?methods? 及其余原生 Page 配置透传。
  • ComponentOptionscreateComponent 入参,含 state?properties?derived?watch?methods? 及其余原生 Component 配置透传。
  • StateDefRecord<string, unknown>,状态字段定义。
  • WatchHandlerstring | Fn@Watch 回调(方法名字符串或函数,签名 (value, key))。
  • WatchDefRecord<string, WatchHandler>
  • DerivedFn(this, data) => unknown,派生字段计算函数。
  • DerivedSpec[...依赖字段, 计算函数]
  • DerivedDefRecord<string, DerivedSpec>
  • NormalizedEventnormalizeEvent 返回值结构。

用法示例

import { createPage, BASE_WXSS } from '@arkmp/runtime';

createPage({
  state: { count: 0, items: [] as number[] },
  derived: {
    double: ['count', (data) => data.count * 2],
  },
  watch: { count: 'onCountChange' },
  methods: {
    aboutToAppear() {
      // → onLoad
    },
    onCountChange(value: number) {
      // @Watch 回调
    },
    onTap() {
      this.count++; // 自动桥接为批量 setData
    },
  },
});

组件示例:

import { createComponent } from '@arkmp/runtime';

createComponent({
  properties: { label: String },
  state: { open: false },
  watch: { label: 'onLabelChange' },
  methods: {
    aboutToAppear() {
      // → lifetimes.attached
    },
    toggle() {
      this.open = !this.open;
    },
  },
});

测试

pnpm --filter @arkmp/runtime test