@changfenhuang/dsh-genui 0.11.1 → 0.11.2-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/SKILL.md +4 -2
- package/lib/assets/standalone-runtime.js +1505 -0
- package/lib/client.js +163 -25
- package/lib/index.js +222 -18
- package/lib/types/client/artifact/ExportableGenuiBlock.d.ts +6 -0
- package/lib/types/client/artifact/create.d.ts +5 -0
- package/lib/types/client/artifact/download.d.ts +9 -0
- package/lib/types/client/artifact/html.d.ts +5 -0
- package/lib/types/client/artifact/index.d.ts +8 -0
- package/lib/types/client/artifact/json.d.ts +3 -0
- package/lib/types/client/artifact/parse.d.ts +3 -0
- package/lib/types/client/artifact/portability.d.ts +4 -0
- package/lib/types/client/artifact/standalone-theme.d.ts +2 -0
- package/lib/types/client/artifact/types.d.ts +33 -0
- package/lib/types/client/blocks/state.d.ts +2 -0
- package/lib/types/client/echarts-engine.d.ts +4 -0
- package/lib/types/client/echarts-lazy.d.ts +1 -3
- package/lib/types/client/embed.d.ts +2 -0
- package/lib/types/client/i18n/en.d.ts +6 -0
- package/lib/types/client/primitive-adapter.d.ts +4 -0
- package/lib/types/client/primitive-labels.d.ts +1 -1
- package/lib/types/client/standalone/asset-loader.d.ts +2 -0
- package/lib/types/client/standalone/bootstrap-types.d.ts +9 -0
- package/lib/types/client/standalone/katex-style.d.ts +1 -0
- package/lib/types/client/standalone/primitive-adapter.d.ts +54 -0
- package/lib/types/client/standalone/runtime.d.ts +2 -0
- package/lib/types/plugin/fence-feedback.d.ts +4 -1
- package/lib/types/plugin/index.d.ts +1 -1
- package/lib/types/plugin/inline-content-diagnostic.d.ts +8 -0
- package/package.json +3 -2
- package/src/client/EChartNode.tsx +4 -8
- package/src/client/GenuiBlock.tsx +17 -13
- package/src/client/action-context.ts +1 -1
- package/src/client/artifact/ArtifactExport.module.css +64 -0
- package/src/client/artifact/ExportableGenuiBlock.tsx +100 -0
- package/src/client/artifact/create.ts +69 -0
- package/src/client/artifact/download.ts +42 -0
- package/src/client/artifact/html.ts +157 -0
- package/src/client/artifact/index.ts +15 -0
- package/src/client/artifact/json.ts +6 -0
- package/src/client/artifact/parse.ts +32 -0
- package/src/client/artifact/portability.ts +47 -0
- package/src/client/artifact/standalone-theme.ts +94 -0
- package/src/client/artifact/types.ts +44 -0
- package/src/client/asset-loader.ts +8 -0
- package/src/client/blocks/advanced.tsx +9 -1
- package/src/client/blocks/charts.tsx +1 -1
- package/src/client/blocks/forms.tsx +8 -5
- package/src/client/blocks/render-node.tsx +1 -1
- package/src/client/blocks/state.ts +2 -0
- package/src/client/echarts-engine.ts +9 -0
- package/src/client/echarts-lazy.ts +1 -4
- package/src/client/embed.ts +10 -0
- package/src/client/fence-render.tsx +5 -13
- package/src/client/genui-runtime/normalize.ts +1 -1
- package/src/client/guard.ts +2 -1
- package/src/client/i18n/en.ts +8 -0
- package/src/client/i18n/zh.ts +8 -0
- package/src/client/inline.ts +26 -1
- package/src/client/panel.tsx +2 -2
- package/src/client/primitive-adapter.ts +13 -0
- package/src/client/primitive-labels.ts +1 -1
- package/src/client/standalone/asset-loader.ts +9 -0
- package/src/client/standalone/bootstrap-types.ts +11 -0
- package/src/client/standalone/katex-style.ts +1 -0
- package/src/client/standalone/primitive-adapter.tsx +94 -0
- package/src/client/standalone/runtime.tsx +27 -0
- package/src/client/toolview.tsx +2 -2
- package/src/plugin/fence-feedback.ts +25 -9
- package/src/plugin/index.ts +4 -3
- package/src/plugin/inline-content-diagnostic.ts +178 -0
- package/src/plugin/tool.ts +18 -3
- package/tsdown.config.ts +82 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.11.2-preview.1] - 2026-09-26
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
|
|
9
|
+
- 完成态 GenUI 支持导出 standalone HTML 与 `.genui.json`(#205、PR #212)。
|
|
10
|
+
- standalone 页面内嵌运行时、样式、主题、KaTeX 字体及按需选择的图形引擎,可独立打开;成果物保存安全的交互状态、语言和主题。
|
|
11
|
+
|
|
12
|
+
### 兼容性
|
|
13
|
+
|
|
14
|
+
- `preview-latest` 与 Release API、packed smoke 宿主检查统一更新为 DSH `0.1.7-rc.2`,并保留 `0.1.7-rc.1` API 标签检查能力。
|
|
15
|
+
- Session format v4 的 fence repair feedback 使用 producer-owned source kind,避免新版 DSH 拒绝反馈消息;同时识别原始插件来源和迁移后的 v4 来源(#218、PR #220)。
|
|
16
|
+
|
|
17
|
+
### 修复
|
|
18
|
+
|
|
19
|
+
- 去除 `validateGenuiSpec` 与 `processGenuiSpec` 中完全相同的重复校验错误,覆盖 chart、tabs 和 accordion 的嵌套数据(#222、PR #223)。
|
|
20
|
+
- `TextareaNode` 恢复时优先使用已持久化的用户值,避免重新挂载后被 spec 默认值覆盖(PR #213)。
|
|
21
|
+
- `QuizNode` 的 `id` 改变时重置已作答状态,避免原位换题后保留旧题状态(PR #214)。
|
|
22
|
+
- 允许 tab 缺少 `items` 及空 tab,修复相关校验失败(PR #216)。
|
|
23
|
+
- 改进行内 Markdown 内容校验与反引号解析,减少误报并保留代码围栏原文(PR #217)。
|
|
24
|
+
|
|
5
25
|
## [0.11.1] - 2026-09-24
|
|
6
26
|
|
|
7
27
|
### 兼容性
|
package/README.md
CHANGED
|
@@ -216,6 +216,10 @@ The model writes the interface description as JSON inside a `dsh-ui` fence; the
|
|
|
216
216
|
|
|
217
217
|
The core render package stays light (≈110 KB min / 28 KB gzip); the mermaid, three.js, and echarts engines are bundled separately as on-demand assets (loaded through the plugin's self-registered HTTP routes the first time they're used), so startup only downloads the rendering core.
|
|
218
218
|
|
|
219
|
+
## Export a GenUI artifact
|
|
220
|
+
|
|
221
|
+
Settled GenUI blocks expose **Export → HTML** and **GenUI JSON**. The `.html` file includes its renderer, styles, KaTeX WOFF2 fonts, and only the chart engines used by the spec. Local controls continue to work; model actions are disabled. Relative media URLs become absolute URLs based on the export page; media still requires network access when the file is opened offline. `.genui.json` preserves the original media URLs, normalized spec, durable interaction state, locale, and theme. Custom components disable HTML export, and export errors appear beside the menu. Hosts can use `createGenuiArtifact`, `parseGenuiArtifact`, `serializeGenuiArtifact`, and `buildStandaloneHtml` from `@changfenhuang/dsh-genui/embed`; `@changfenhuang/dsh-genui/assets/standalone` resolves to the built runtime script for copying or serving.
|
|
222
|
+
|
|
219
223
|
## ❓ FAQ
|
|
220
224
|
|
|
221
225
|
- **Rendering as a code block?** First check the browser console for `[genui] client active; fence-channel=registry|dom`. If absent, the client bundle was not activated even if its URL returns 200 — align the profile dependency, `package.json.name`, `cordis.patch.yml`, ModuleLoader id, and configured bundle name. If present, inspect the fence label/body; registry-less hosts automatically use the DOM channel.
|
package/README.zh-CN.md
CHANGED
|
@@ -242,6 +242,10 @@ dsh plugin --profile web add link:$PWD
|
|
|
242
242
|
|
|
243
243
|
调用 `setGenuiAssetBase` 设置本地引擎目录;从公开的 `@changfenhuang/dsh-genui/assets/mermaid`、`assets/three`、`assets/echarts-core`、`assets/echarts` 构建对应脚本。模型指引从 `@changfenhuang/dsh-genui/skill` 读取。宿主只补自己的交付通道和设计变量;渲染器仍使用本包与 `@deepseek-ai/dsh-client-ui-primitives` 的组件。构建时提供 React、CSS Modules、KaTeX 字体及所用引擎依赖。
|
|
244
244
|
|
|
245
|
+
### 导出 GenUI 成果文件
|
|
246
|
+
|
|
247
|
+
已完成的 GenUI 区块提供“导出 → HTML”和“GenUI JSON”。`.html` 文件内含渲染器、样式、KaTeX WOFF2 字体和规格实际需要的图形引擎,本地控件可以继续使用,模型动作按钮会禁用。相对媒体地址会按导出页面的地址转换为绝对地址;离线打开时,网络媒体仍需连接原站点。`.genui.json` 保留原媒体地址、规范化规格、可持久化交互状态、语言和主题。自定义组件会禁用 HTML 导出,导出错误会显示在菜单旁。宿主可从 `@changfenhuang/dsh-genui/embed` 使用 `createGenuiArtifact`、`parseGenuiArtifact`、`serializeGenuiArtifact` 和 `buildStandaloneHtml`;`@changfenhuang/dsh-genui/assets/standalone` 指向可供复制或提供下载的运行文件。
|
|
248
|
+
|
|
245
249
|
```sh
|
|
246
250
|
pnpm install
|
|
247
251
|
pnpm run check # 类型检查 + 全量测试 + 构建
|
package/SKILL.md
CHANGED
|
@@ -72,7 +72,7 @@ description: "Render structured interactive UI inline through the dsh-ui fence.
|
|
|
72
72
|
- submit: `{"type":"submit","label":"<user-language action>","action":"grade","groups":["q1","styles"],"resetAction":"redo"?}` — 聚合按钮:纯 radio 且题目带 `answer` 时仍本地立即判卷(得分 + 每题 ✓/✗ + 解析,零往返);其余聚合场景一次发送 `[genui-action]`,payload 为 `{answers:{q1:"<user-language option>",styles:["<user-language option>","<user-language option>"]},fields:{id:"<user-language value>"},total,answered}`。`groups` 中每个 radio 必须已选择、每个 checkbox 组必须至少勾选一项才可提交
|
|
73
73
|
- switch: `{"type":"switch","label":"...","checked":true?,"action":"toggle"?}`
|
|
74
74
|
- textarea: `{"type":"textarea","label":"...","placeholder":"...","rows":n?,"value":"...","action":"save"?,"id":"field-id"?}` — action 在失焦和 **Ctrl/Cmd+Enter** 时触发;blur 仅值有变化才发送;带 `id` 的值刷新后保留
|
|
75
|
-
- tabs: `{"type":"tabs","tabs":[{"label":"...","items":[...]}]}`
|
|
75
|
+
- tabs: `{"type":"tabs","tabs":[{"label":"...","items":[...]}]}` — 空 tab 可以省略 `items`,会按空数组处理
|
|
76
76
|
- accordion: `{"type":"accordion","items":[{"title":"...","items":[...]}]}`
|
|
77
77
|
- copy: `{"type":"copy","label":"<user-language action>","text":"<user-language text>"}`
|
|
78
78
|
|
|
@@ -136,6 +136,8 @@ description: "Render structured interactive UI inline through the dsh-ui fence.
|
|
|
136
136
|
|
|
137
137
|
不嵌套、不解析 HTML(每个标记生成 React 元素,不走 innerHTML;`<br>` 字面显示,换行用 `"\n"`);标记没闭合时原样显示。数值列 / badge / spark 单元格不解析(数字没什么可强调的)。
|
|
138
138
|
|
|
139
|
+
文字字段只支持行内富文本。`text.content`、`callout.content`、`list` 项、`keyvalue` 值、`table` 单元格等字段中不要嵌入 Markdown 表格或连续三个及以上反引号、波浪号组成的代码围栏;表格使用 `table`,代码使用 `code`,代码改动使用 `diff`,结构化 JSON 使用 `json`。误写入文字字段的代码围栏连同内部标记保持原文,未闭合时从围栏标记开始保持原文。`validate_dsh_ui` 返回 `warning=block_markdown` 时,按照 `replacement` 改写结构节点并重新验证。
|
|
140
|
+
|
|
139
141
|
## 回答级版式:默认无卡,焦点唯一
|
|
140
142
|
|
|
141
143
|
**规则来自设计规范,不是口味**(`design` skill 的 `references/design-reference.md`):
|
|
@@ -244,4 +246,4 @@ description: "Render structured interactive UI inline through the dsh-ui fence.
|
|
|
244
246
|
8. **规格要紧凑**:整棵组件树 ≤200 节点、≤8 层嵌套(超出部分会被渲染器裁掉),避免巨型 spec
|
|
245
247
|
9. **一个主题选一个主组件**:命中映射表后选**一种**组件承载,同一信息不要用两种组件重复表达(同一批数据又画 bars 又画 donut = 冗余)
|
|
246
248
|
10. **数量纪律**:一条回答 3–8 个组件为宜,宁缺毋滥。反例:该用 `table` 对比时写三段 `text`;一个 `stat` 能说清的事套 `card`+`grid`;与内容无关的 `scene3d` 炫技——3D 只在内容本身就是几何/空间时才用
|
|
247
|
-
11. **先验后发(复杂 UI)**:发出 ```dsh-ui 围栏前,若 spec ≥3 个组件或含 `table`(长表格最易括号错位),先调用 `validate_dsh_ui` 工具(参数 `spec` 传围栏内的 JSON 文本)验证;返回 `
|
|
249
|
+
11. **先验后发(复杂 UI)**:发出 ```dsh-ui 围栏前,若 spec ≥3 个组件或含 `table`(长表格最易括号错位),先调用 `validate_dsh_ui` 工具(参数 `spec` 传围栏内的 JSON 文本)验证;返回 `next=fix_and_revalidate` 就按诊断修正后重新验证;返回 `next=emit_fence` 再发出;返回 `next=emit_repaired_fence` 时直接照抄 `repaired_json` 发出,无需再次验证;简单 UI(≤2 个组件)不必验证,渲染器会自动修复大部分标点/括号错误
|