@devframes/plugin-data-inspector

中文文档
1.3.3发布于 2026/11/10MITTypeScriptES Module构建来源已验证近 30 天下载 12.1万

Devframe plugin for inspecting live server objects interactively with jora queries.

原始使用文档
文档目录6 节
  1. Register a data source
  2. Writable sources
  3. Mount
  4. Standalone CLI
  5. Attach to another Node process
  6. Saved queries

@devframes/plugin-data-inspector

Inspect live server-side objects interactively. Other devframes and host frameworks register data sources; the workbench composes jora queries against them (executed in the process that owns the objects) and renders normalized results in a discovery.js struct view with type badges, a shape panel, saved queries, and shareable URL state. Deep graphs expand a level at a time (load deeper fetches each subtree on demand), an optional poller re-runs the query every N seconds, and a toolbar offers expand/collapse-all and copy.

Register a data source

The registry is process-global: register from anywhere, before or after the devframe mounts:

import { registerDataSource } from '@devframes/plugin-data-inspector/registry'

registerDataSource({
  id: 'my-plugin:state',
  title: 'My plugin state',
  description: 'The live state store',
  data: () => store, // value or (async) factory; `static: true` memoizes
  queries: [
    { title: 'Active entries', query: 'entries.mapEntries()' }
  ],
})

Devframes that prefer zero package dependency consume the same store through the typed context service:

ctx.services.whenAvailable('devframes:plugin:data-inspector:sources', (sources) => {
  sources.register({
    id: 'my-plugin:state',
    title: 'My state',
    data: () => store
  })
})

Writable sources

Sources opt into live edits with writable: true: on the root view ($), every value grows an edit affordance that opens a side panel where you set a value (string / number / boolean / null / undefined / JSON), add or delete entries, or rename keys; the mutation is applied in place to the live object through the write RPC. Read-only stays the default; static: true sources are memoized snapshots and always stay read-only (declaring both reports DP_DATA_INSPECTOR_0004).

registerDataSource returns a handle; call notifyChanged() whenever the data changes outside the inspector so connected views re-run, or hand the devframe a bridge to the source's own change signal via subscribe:

const handle = registerDataSource({
  id: 'my-plugin:state',
  title: 'My plugin state',
  data: () => store,
  writable: true, // opt-in: the inspector may mutate the live object
  subscribe: (notify) => { // optional: push the source's own change signal
    store.on('change', notify)
    return () => store.off('change', notify)
  },
})

handle.notifyChanged() // or notify imperatively

Mount

// the default export is the factory; call it for an instance:
import createDataInspectorDevframe from '@devframes/plugin-data-inspector'
// Vite
import { devframeVite } from '@devframes/vite/single'

devframeVite(createDataInspectorDevframe())

Standalone CLI

pnpx @devframes/plugin-data-inspector stats.json trace.jsonl # inspect local data files
pnpx @devframes/plugin-data-inspector build stats.json       # self-contained static export
pnpx @devframes/plugin-data-inspector attach                 # attach to a process running the inject entry

Static exports embed the dataset and run the same query engine client-side, so saved recipes stay portable.

Attach to another Node process

import { exposeDataInspector } from '@devframes/plugin-data-inspector/inject'

// pass sources inline, or register them separately beforehand
await exposeDataInspector({
  sources: [
    {
      id: 'app:store',
      title: 'App store',
      data: () => store
    }
  ],
})

or with zero code changes:

DEVFRAME_DATA_INSPECTOR=1 node --import @devframes/plugin-data-inspector/inject server.js

On the zero-code path there's nowhere to call registerDataSource, so the inject entry auto-registers a globalThis source: assign what you want to inspect onto the global object (globalThis.store = store) and query it live. Opt out with DEVFRAME_DATA_INSPECTOR_GLOBAL=0.

The inject entry binds 127.0.0.1, requires devframe's trust handshake with a per-run token by default, and advertises its endpoint in node_modules/.data-inspector/discovery.json, which pnpx @devframes/plugin-data-inspector attach picks up automatically.

[!WARNING] A connected inspector runs eval-grade jora queries against live objects: queries can invoke functions reachable as own properties and fire getters. Treat the inject endpoint like a debugger port: keep it on loopback and keep auth on.

Saved queries

Recipes ({ query, title?, description?, ...filters }) persist id-keyed in two scopes: workspace (committable, getStorageDir('workspace')/data-inspector/queries.json, shared with the team) and project (per-checkout, under node_modules).

版本与发布记录

@devframes/plugin-data-inspector 共发布 58 个版本,首次发布于 2026/07/17;过去 12 个月发布了 58 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.3.3latest2026/11/101 天前
1.3.22026/11/029 天前
1.3.12026/11/0110 天前
1.3.02026/10/3112 天前
1.2.62026/10/1924 天前
1.2.52026/10/1428 天前

关于 @devframes/plugin-data-inspector 的常见问题

@devframes/plugin-data-inspector 是什么?

Devframe plugin for inspecting live server objects interactively with jora queries.

如何安装 @devframes/plugin-data-inspector?

在项目目录运行 npm install @devframes/plugin-data-inspector,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:devframe(1.3.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 devframe-data-inspector,可以用 npx devframe-data-inspector 直接运行。

@devframes/plugin-data-inspector 支持 TypeScript 吗?

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

@devframes/plugin-data-inspector 支持 ESM 还是 CommonJS?

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

@devframes/plugin-data-inspector 可以商用吗?

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

@devframes/plugin-data-inspector 的下载量有多少?

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

@devframes/plugin-data-inspector 还在维护吗?

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