@fungi.computer/nacre

中文文档
0.6.6发布于 2026/11/15MITTypeScriptES Module近 30 天下载 1.1万

The shell client for hosting Apps: workbench, command host, keys, commands, window manager and App directory rows

原始使用文档
文档目录7 节
  1. Install or set up
  2. Quick start
  3. Core concepts
  4. API reference
  5. Examples and checks
  6. Limits and errors
  7. Contribute and license

Nacre (@fungi.computer/nacre)

Nacre is mother-of-pearl, the lining an oyster grows on the inside of its shell. This package is that lining for App hosts: the shell client that windows, commands, keys and the App directory are built from. Oyster's page uses it, and any shell can import it without the Oyster server.

Install or set up

pnpm add @fungi.computer/nacre

The package is ESM-only. It depends on @fungi.computer/agar, @fungi.computer/ear-tag, @fungi.computer/gills, @fungi.computer/puffball, @fungi.computer/whistle, effect and zod.

Quick start

import { createWindowManager } from "@fungi.computer/nacre";

const windows = createWindowManager({
  createContainer: () => ({}),
  mount: () => ({
    setVisibility: () => undefined,
    reconfigure: () => undefined,
    dispose: () => undefined,
  }),
});
await windows.open({ windowId: "notes" });

Core concepts

@fungi.computer/nacre supplies the client side of hosting Apps. It can be imported independently of the Workers server and Node packing helpers. The same exports are available through focused entries:

EntryContract
./workbenchWorkbench host contract, shared child-window host, Gill layout and arranger shapes.
./command-hostA Whistle graph that admits mounted commands against verified Release declarations.
./keysDOM key dispatch and shared chord matching.
./commandsWindow, App picker and command palette declarations over host callbacks.
./window-managerWindow generations, visibility, navigation, cancellation and disposal.
./app-directoryApp addresses, reusable directory rows and catalog metadata.

./shell-module is the contract between a host and the shell it runs, and is imported on its own rather than through the root entry. A shell Release exports mountShell(root, input) (MountShell); input (ShellMountInput) carries the workbench handle, the shell installation's AppStorage and methods.call(method, input) for its declared backend methods, which takes the input as JSON text and resolves with the decoded JSON result. importShellModule(moduleUrl, hostOrigin) imports the picked shell's module from the host's own origin, checks that it exports mountShell, and rejects with ShellModuleError otherwise. The host never bundles a shell.

Supply your own mount adapter to createWindowManager. It receives the container, launch descriptor, cancellation signal and navigation callbacks; its returned handle owns visibility, reconfiguration and disposal. The manager disposes stale mounts and serializes changes to each window. It neither picks Apps nor grants capabilities.

createAppSurfaceCommandHost owns command contribution and focus. Give mount(id, declarations) the verified Release's declarations and pass the returned handlers to Agar's connectAppHost. A mounted App cannot introduce an undeclared command or claim the reserved shell chord. Dispose its command mount when its iframe closes, and dispose the command host with the shell. installShellKeys attaches DOM listeners only when called; its return value removes them. Terminal shells can use the command and window owners without a DOM.

Directory metadata is not launch authority. A host extends the public row schema with its own permission model and admits each mount itself. Fungi's Team directory, Team settings capability and signed Hub/host protocol live in its private consumers; the public shell imports none of them.

API reference

The generated reference is in docs/api.

Examples and checks

  • pnpm --filter @fungi.computer/nacre test runs the window manager, command host, shell module and App catalog tests.
  • pnpm --filter @fungi.computer/nacre stranger packs the package and typechecks and runs a consumer against the tarball.

Limits and errors

Directory metadata is not launch authority, and a mounted App cannot introduce an undeclared command. importShellModule rejects a module that does not export mountShell with ShellModuleError.

Contribute and license

Changes land through the Botanical repository. MIT licensed; see LICENSE.

版本与发布记录

@fungi.computer/nacre 共发布 34 个版本,首次发布于 2026/10/23;过去 12 个月发布了 34 个版本。

版本发布日期距今
0.6.6latest2026/11/15今天
0.6.52026/11/15今天
0.6.42026/11/141 天前
0.6.32026/11/141 天前
0.6.22026/11/141 天前
0.6.12026/11/141 天前

关于 @fungi.computer/nacre 的常见问题

@fungi.computer/nacre 是什么?

The shell client for hosting Apps: workbench, command host, keys, commands, window manager and App directory rows

如何安装 @fungi.computer/nacre?

在项目目录运行 npm install @fungi.computer/nacre,或使用 pnpm add / yarn add / bun add。

@fungi.computer/nacre 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fungi.computer/nacre 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fungi.computer/nacre 可以商用吗?

@fungi.computer/nacre 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fungi.computer/nacre 的下载量有多少?

根据 npm 官方下载统计,@fungi.computer/nacre 在 2026/10/16 – 2026/11/14 这 30 天内被下载 10,650 次,日均约 355 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fungi.computer/nacre 还在维护吗?

最新版本 0.6.6 发布于 2026/11/15(今天);至今共发布 34 个版本,其中过去 12 个月发布了 34 个;首次发布于 2026/10/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。