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

moobile-host

v0.2.0

Published

React Native / Expo host for moobile (MoonBit UI): implements the MOBILE_HOST contract and generates the capability registry.

Downloads

143

Readme

moobile-host

moobile(用 MoonBit 写 UI、交给 React Native 渲染)在 React Native / Expo 上的宿主。

它只做三件事:

  1. globalThis.MOBILE_HOST(React、5 个基础组件、两个调度钩子、后端地址);
  2. 契约版本比对 —— 库与宿主各自声明自己实现的契约版本,不等就当场报错并说出两个版本号;
  3. 能力注册表(本地数据库等),并核对每一项真的装上了。

用法

// App.js —— 整个宿主侧就这几行
import { mountApp } from 'moobile-host';
import { app } from './moobile.js';            // MoonBit 侧编译产物
import { registry } from './registry.generated.js';

export default mountApp(app, { registry });

MoonBit 侧只需要一个导出:

pub fn app() -> @moobile.JsValue {
  @moobile.handlers_with_init(init=init_app, update~, view~)   // 或 handlers(...)
}

能力注册表(registry.generated.js

不要手写它,从依赖生成

npx moobile-host regen          # 读 package.json,写 registry.generated.js
npx moobile-host regen --check  # CI 用:不一致就非零退出

加能力 = npm install 那个包 + 重跑 regen。生成物是静态 import(Metro 不能靠运行时 拼字符串 import),并在注释里列出"识别了什么、哪些没装"。

运行时还会再核对一遍:注册表里声明了 db,但 MOBILE_HOST.db 装完是空的 → 报错会点名 db 与提供它的 expo-sqlite,而不是让你对着 Cannot read properties of undefined 猜。

后端地址

RN 里没有"同源"这回事,fetch('/todos') 没有意义:地址由宿主给(MOBILE_HOST.apiBase), 默认 Android 走 http://10.0.2.2:8787、其余走 http://127.0.0.1:8787。 真机可以改用 adb reverse tcp:8787 tcp:8787

兼容性

| moobile(MoonBit 包) | moobile-host | MOBILE_HOST 契约 | |---|---|---| | 0.2.x | 0.2.x | 1 |

契约版本写在两边:app.mbthost_contract_versionindex.jsCONTRACT改契约形状必须同时 +1。

发布(维护者)

本机默认 registry 是淘宝镜像(只读),发布必须显式指向官方

npm publish --registry=https://registry.npmjs.org/     # package.json 里也写了 publishConfig