@ai-matrx/content-ir-react

中文文档
0.25.93发布于 2026/10/15MITTypeScriptESM + CJS近 30 天下载 4.7万

The shared AI Matrx Content IR RENDER layer: kind routing, the component resolver, provisional (streaming) rendering, the runtime-wrapper chrome, and the generic structured floor — as portable React.

原始使用文档
文档目录4 节
  1. Wire your host once
  2. What you get
  3. The rule this package exists to enforce
  4. Docs

@ai-matrx/content-ir-react

The shared render layer for AI Matrx Content IR.

@ai-matrx/content-ir is the pure kernel — it parses a kind, validates it, reads a streaming partial, and reads a runtime wrapper. This package is the layer above it: the one that decides which component a kind renders through, and draws the chrome around that decision.

It is framework-portable React. No Next.js, no Redux, no Supabase, no router, no host error capture. Every host-specific capability enters through an explicit seam.

npm install @ai-matrx/content-ir-react @ai-matrx/content-ir react

Wire your host once

import {
  ComponentResolver,
  ContentIrRenderProvider,
  applyIrKindRoute,
  type ContentIrHost,
} from "@ai-matrx/content-ir-react";

const components = new ComponentResolver({
  loadAll: () => fetchKindComponentRows(),
  loadForKind: (kind, platform) => fetchKindComponentRows({ kind, platform }),
  reportError: (report) => myErrorLog(report),
});

const host: ContentIrHost = {
  platform: "web",
  kinds: myKindDefinitionSource,
  components,
  reportError: (report) => myErrorLog(report),
  // The host's dispatch table — the ONE place a component key becomes a
  // component. Run the route here.
  renderBlock: (block) => <MyBlockRenderer block={applyIrKindRoute(block, env)} />,
  // The FLOOR: any JSON value as a human document.
  renderValue: ({ value, kind, note }) => (
    <MyStructuredValueView value={value} kind={kind} note={note} />
  ),
};

<ContentIrRenderProvider host={host}>
  <App />
</ContentIrRenderProvider>;

What you get

ExportWhat it is
applyIrKindRouteTHE kind route: envelope → registered kind → the right component key. Pure; callable from a reducer or a stream accumulator.
resolveProvisionalKindRender / resolveAnnouncedKindLoadingThe streaming partial-kinds route — a provisional value renders through the SAME component the final value will.
ComponentResolver(kind, platform, role) → component, compiled floor + DB override, granular repaint counters, cold-fetch dedupe.
KindInstanceRenderRender one canonical kind instance through the real production path, with the "no component yet" floor beneath it.
GenericStructuredViewThe R6 disposition for a known shape nothing render-trusted claims — readable, honest, never an error.
NodeOutcomeView / RunResultViewThe runtime-wrapper chrome. Transparent routers: they delegate, they never render a payload.
ProvisionalKindBoundary / ProvisionalKindFrameThe mid-stream safety net and the "still arriving" affordance.
useContentIrKindVersionGranular late-arrival repaint for one kind.

The rule this package exists to enforce

A shape has exactly one component, everywhere. A second implementation of the routing decisions — in a dashboard, an extension, a desktop webview, a customer's app — is a guaranteed divergence, and it is banned. If this package cannot express what your host needs, add a seam; never fork the route.

Docs

  • Package internals and boundary: FEATURE.md beside this file.
  • Cross-repo system-of-record: common-docs/systems/architecture/content-ir/FEATURE.md.
  • Shape System semantics: matrx-frontend/features/content-ir/docs/SHAPE_SYSTEM.md.

版本与发布记录

@ai-matrx/content-ir-react 共发布 171 个版本,首次发布于 2026/08/24;过去 12 个月发布了 171 个版本。

版本发布日期距今
0.25.93latest2026/10/1523 天前
0.25.922026/10/1523 天前
0.25.912026/10/1424 天前
0.25.902026/10/1424 天前
0.25.892026/10/1424 天前
0.25.882026/10/1424 天前

关于 @ai-matrx/content-ir-react 的常见问题

@ai-matrx/content-ir-react 是什么?

The shared AI Matrx Content IR RENDER layer: kind routing, the component resolver, provisional (streaming) rendering, the runtime-wrapper chrome, and the generic structured floor — as portable React.

如何安装 @ai-matrx/content-ir-react?

在项目目录运行 npm install @ai-matrx/content-ir-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ai-matrx/content-ir-react 支持 TypeScript 吗?

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

@ai-matrx/content-ir-react 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ai-matrx/content-ir-react 需要什么版本的 Node.js?

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

@ai-matrx/content-ir-react 可以商用吗?

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

@ai-matrx/content-ir-react 的下载量有多少?

根据 npm 官方下载统计,@ai-matrx/content-ir-react 在 2026/10/05 – 2026/11/03 这 30 天内被下载 46,595 次,日均约 1,553 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ai-matrx/content-ir-react 还在维护吗?

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