@domscribe/runtime

中文文档
0.7.0发布于 2026/10/28TypeScriptES Module构建来源已验证近 30 天下载 14.1万

Browser-side runtime context capture for Domscribe

原始使用文档
文档目录9 节
  1. Install
  2. Framework Support
  3. RuntimeManager
  4. Options
  5. Serialization Constraints
  6. FrameworkAdapter Interface
  7. Serialization Hints
  8. Links
  9. License

@domscribe/runtime

Browser-side context capture engine for Domscribe.

@domscribe/runtime runs in the browser during development and captures component props, state, and DOM context when a developer clicks an element. It is framework-agnostic at its core — framework-specific behavior is provided by adapters.

Install

npm install @domscribe/runtime

Framework Support

FrameworkAdapterCapture Strategy
React 18-19@domscribe/reactFiber walking, DevTools hook, BestEffort
Vue 3@domscribe/vueVNode inspection, Composition + Options API
Next.js 15-16@domscribe/nextReact adapter + withDomscribe() config wrapper
Nuxt 3+@domscribe/nuxtVue adapter + auto-configured Nuxt module

For most projects you will install a framework adapter rather than @domscribe/runtime directly. The adapter declares @domscribe/runtime as a peer dependency and handles initialization.

RuntimeManager

RuntimeManager is a singleton that manages the active adapter and provides the capture API to the overlay and other internal consumers.

import { RuntimeManager } from '@domscribe/runtime';

const runtime = RuntimeManager.getInstance();
await runtime.initialize({
  adapter: myAdapter,
  phase: 1,
  debug: false,
  redactPII: true,
  blockSelectors: [],
});

Options

OptionTypeDefaultDescription
adapterFrameworkAdapterNoopAdapterFramework adapter for context capture
phase1 | 21Feature phase gate. Phase 1: props and state capture. Phase 2: event flow and performance metrics (future).
debugbooleanfalseEnable debug logging
redactPIIbooleantrueRedact sensitive values (emails, tokens) in captured data
blockSelectorsstring[][]CSS selectors for elements to skip during capture
serializationSerializationConstraintsundefinedSerialization constraints for captured props and state (see below)

initialize() is safe to call multiple times — subsequent calls with the same configuration are no-ops.

Serialization Constraints

The runtime serializes component props and state with bounded constraints to prevent excessive payload sizes. All fields are optional — defaults are applied by the serializer.

OptionDefaultDescription
maxDepth6 (props), 4 (state)Maximum object traversal depth
maxArrayLength20Maximum array elements before truncation
maxStringLength2048Maximum string length before truncation
maxProperties50Maximum properties per object
maxTotalBytes262144 (256 KB)Approximate byte budget for the entire serialized output

When a limit is exceeded, the serializer inserts human-readable sentinels ([Max Depth Exceeded], [Truncated: size limit]) and truncation metadata ({ __truncated: true, originalLength: N }) so agents can see what was omitted.

These constraints are configurable per-project via the serialization option on RuntimeOptions, which all framework adapter plugins expose through their runtime namespace.

FrameworkAdapter Interface

Adapters implement the FrameworkAdapter interface to bridge the runtime to a specific framework's internal component model.

interface FrameworkAdapter {
  readonly name: string;
  readonly version?: string;
  getComponentInstance(element: HTMLElement): Nullable<unknown>;
  captureProps(component: unknown): Nullable<Record<string, unknown>>;
  captureState(component: unknown): Nullable<Record<string, unknown>>;
  getComponentName?(component: unknown): Nullable<string>;
  getComponentTree?(component: unknown): Nullable<ComponentTreeNode>;
  getSerializationHints?(): SerializationHints;
}

Serialization Hints

Adapters can implement getSerializationHints() to declare which object keys are framework internals that should be skipped during serialization. This prevents framework plumbing (e.g., React Fiber trees, Vue reactivity markers) from consuming the byte budget.

interface SerializationHints {
  skipKeys?: Set<string>; // Exact keys to omit (e.g., '_owner')
  skipKeyPrefixes?: string[]; // Prefixes to omit (e.g., '__react' catches '__reactFiber$xyz')
}

The React adapter skips _owner, _store, and all __react* keys. The Vue adapter skips __v_* reactivity internals. The NoopAdapter returns no hints — all keys are serialized.

See the Custom Adapters Guide for the full interface, a worked example, and integration instructions.

Part of Domscribe.

License

MIT

版本与发布记录

@domscribe/runtime 共发布 16 个版本,首次发布于 2026/03/18;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/10/2816 天前
0.6.12026/10/2519 天前
0.5.22026/04/017 个月前
0.5.12026/04/017 个月前
0.5.02026/03/277 个月前
0.4.02026/03/277 个月前

关于 @domscribe/runtime 的常见问题

@domscribe/runtime 是什么?

Browser-side runtime context capture for Domscribe

如何安装 @domscribe/runtime?

在项目目录运行 npm install @domscribe/runtime,或使用 pnpm add / yarn add / bun add。

@domscribe/runtime 支持 TypeScript 吗?

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

@domscribe/runtime 支持 ESM 还是 CommonJS?

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

@domscribe/runtime 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@domscribe/runtime 可以商用吗?

@domscribe/runtime 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@domscribe/runtime 的下载量有多少?

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

@domscribe/runtime 还在维护吗?

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