@arkitektio/bsx

中文文档
2.2.1发布于 2026/10/31MITTypeScriptES Module零依赖构建来源已验证

The BSX language, the blok spec, runtime and React renderer: one copy for every Arkitekt frontend.

原始使用文档
文档目录3 节
  1. Catalogs
  2. In an app
  3. The spec JSON

@arkitektio/bsx

The BSX language, the blok catalogs, the blok runtime and the React renderer: one copy for every Arkitekt frontend (the Orkestrator, newswitch, pokket).

importwhatneeds
@arkitektio/bsxthe language (parseBsx, printBsx, analyzeBsx, completeBsx, …), the vocabulary and the spec JSONnothing
@arkitektio/bsx/catalogsthe global catalog contracts (uiCatalog, htmlCatalog, logoCatalog, sceneCatalog, structureCatalog, shadcnCatalog) and the prop-schema vocabularyzod
@arkitektio/bsx/runtimethe runtime, defineBlokCatalog / implementBlokCatalog / ownBlokCatalog / declareBlokUi, declarations, persistence, configureBlokPlatformreact, zod, zustand, graphql
@arkitektio/bsx/webBlokRenderer, BlokComponentHost, BlokCatalogProvider, addBlokComponentsreact-dom
@arkitektio/bsx/shadcnopt-in: ui@1, html@1, logo@1 and shadcn@1 drawn with shadcn/ui (shadcnUi, shadcnHtml, shadcnLogo, shadcnExtras)radix-ui, tailwindcss, …
@arkitektio/bsx/sceneopt-in: scene@1 drawn with three (threeScene), and the scene hoststhree, @react-three/fiber, @react-three/drei
@arkitektio/bsx/editorthe Monaco BSX editor@monaco-editor/react
@arkitektio/bsx/tailwindTailwind for the classes bloks bring at run timetailwindcss, a Vite host (?raw)

Every module is reachable by its path too (@arkitektio/bsx/renderer/runtime/task).

Catalogs

A catalog is a contract: which components it holds and what each takes (a zod schema per component, placement, text prop, callback events). It draws nothing. The UI defines catalogs, in TypeScript; the spec JSON is written from them.

  • Global catalogs are versioned (ui@1) and defined here. A UI that implements one whole claims it, so a blok that uses only global catalogs renders in every UI that claims them.
  • A UI's own catalog is defined and registered by that UI: newswitch's newswitch@2, orkestrator's module bloks. A blok that uses one renders only there.

An implementation is the app's: a render per component, a map the compiler checks against the contract (a missing or unknown render fails tsc).

import {uiCatalog} from '@arkitektio/bsx/catalogs';
import {configureBlokPlatform, declareBlokUi, implementBlokCatalog, type BlokRender} from '@arkitektio/bsx/runtime';
import {shadcnExtras, shadcnHtml, shadcnLogo, shadcnUiRenders} from '@arkitektio/bsx/shadcn';
import {threeScene} from '@arkitektio/bsx/scene';

// Draw over one part of the reference implementation:
const MyButton: BlokRender<typeof uiCatalog.components.Button> = ({component, schema}) => { /* … */ };
const ui = implementBlokCatalog(uiCatalog, {...shadcnUiRenders, Button: MyButton});

export const app = declareBlokUi({
  name: 'myapp',
  implements: [ui, shadcnHtml, shadcnLogo, shadcnExtras, threeScene, myOwnCatalog],
});
// app.catalog: what the renderers draw. app.claims: the global catalogs it implements whole.

// Once, before the first render: what the bloks get from the app.
configureBlokPlatform({toast, describeError, useKeepLive, useColorScheme, tailwindTheme: appThemeCss, catalog: app.catalog});

A UI's own components join the language's default view (parser, checks, editor) with registerBlokModules([parseSpecCatalog(blokModuleSpec(name, description, app.catalog), name)]).

In an app

  • Tailwind. A blok's own classes are compiled at run time (./tailwind). The opt-in implementations' own classes are not: overlays portal outside the blok, and tw-animate-css is build-only. An app that uses ./shadcn adds @source "<path to>/node_modules/@arkitektio/bsx/dist";. One that brings its own components does not need it.
  • Under vitest, inline the package (test.server.deps.inline: ['@arkitektio/bsx']): ./tailwind reads stylesheets with ?raw.
  • three must be a single copy in the app (it is a peer).
  • radix-ui 1.4.x is what the shadcn implementation is tested against (its tabs fire onValueChange twice in 1.8).

The spec JSON

src/spec/catalogs/<name>@<version>.json for the global catalogs is written from the contracts: pnpm build && pnpm spec:export (a test fails while they disagree). arkitekt-spec's scripts/sync_standard_catalog.py copies them in, and writes the language it owns into this checkout: vocabulary.json, catalogs/[email protected] and the parity corpus bsx_v2.json. Never edit those three here.

版本与发布记录

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

版本发布日期距今
2.2.1latest2026/10/313 天前
2.2.02026/10/304 天前
2.1.02026/10/304 天前
2.0.02026/10/295 天前
1.0.12026/10/286 天前
0.0.02026/10/286 天前

关于 @arkitektio/bsx 的常见问题

@arkitektio/bsx 是什么?

BSX语言、块规范、运行时和React渲染器:每个Arkitekt前端都有一份副本。

如何安装 @arkitektio/bsx?

在项目目录运行 npm install @arkitektio/bsx,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:zod(^4.0.0)、react(^19.2.0)、graphql(^16.8.0)、zustand(^5.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@arkitektio/bsx 支持 TypeScript 吗?

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

@arkitektio/bsx 支持 ESM 还是 CommonJS?

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

@arkitektio/bsx 可以商用吗?

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

@arkitektio/bsx 还在维护吗?

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