@sparkelf/dsh-genui 0.0.0-stage → 0.11.4-patch.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.
Files changed (210) hide show
  1. package/CHANGELOG.md +597 -0
  2. package/LICENSE +21 -0
  3. package/README.md +292 -2
  4. package/README.zh-CN.md +307 -0
  5. package/SKILL.md +261 -0
  6. package/cordis.patch.yml +9 -0
  7. package/demo-prompts.md +118 -0
  8. package/lib/assets/echarts-core.js +43 -0
  9. package/lib/assets/echarts-full.js +72 -0
  10. package/lib/assets/mermaid.js +3591 -0
  11. package/lib/assets/standalone-runtime.js +1506 -0
  12. package/lib/assets/three.js +3844 -0
  13. package/lib/client.js +405 -0
  14. package/lib/index.js +5187 -0
  15. package/lib/invariant.js +19 -0
  16. package/lib/types/client/EChartNode.d.ts +13 -0
  17. package/lib/types/client/ErrorBoundary.d.ts +30 -0
  18. package/lib/types/client/GenuiBlock.d.ts +9 -0
  19. package/lib/types/client/PlotBlock.d.ts +44 -0
  20. package/lib/types/client/TemplateDrawer.d.ts +7 -0
  21. package/lib/types/client/achievement-store.d.ts +35 -0
  22. package/lib/types/client/achievement-toast.d.ts +2 -0
  23. package/lib/types/client/achievements.d.ts +63 -0
  24. package/lib/types/client/action-context.d.ts +7 -0
  25. package/lib/types/client/artifact/ExportableGenuiBlock.d.ts +6 -0
  26. package/lib/types/client/artifact/create.d.ts +5 -0
  27. package/lib/types/client/artifact/download.d.ts +9 -0
  28. package/lib/types/client/artifact/html.d.ts +5 -0
  29. package/lib/types/client/artifact/index.d.ts +8 -0
  30. package/lib/types/client/artifact/json.d.ts +3 -0
  31. package/lib/types/client/artifact/parse.d.ts +3 -0
  32. package/lib/types/client/artifact/portability.d.ts +4 -0
  33. package/lib/types/client/artifact/standalone-theme.d.ts +2 -0
  34. package/lib/types/client/artifact/types.d.ts +33 -0
  35. package/lib/types/client/asset-echarts-core.d.ts +1 -0
  36. package/lib/types/client/asset-echarts.d.ts +17 -0
  37. package/lib/types/client/asset-loader.d.ts +33 -0
  38. package/lib/types/client/asset-mermaid.d.ts +1 -0
  39. package/lib/types/client/asset-three.d.ts +1 -0
  40. package/lib/types/client/blocks/advanced.d.ts +101 -0
  41. package/lib/types/client/blocks/basic.d.ts +22 -0
  42. package/lib/types/client/blocks/charts.d.ts +53 -0
  43. package/lib/types/client/blocks/checkbox.d.ts +17 -0
  44. package/lib/types/client/blocks/diagram/geometry.d.ts +73 -0
  45. package/lib/types/client/blocks/diagram/index.d.ts +5 -0
  46. package/lib/types/client/blocks/diagram/layout.d.ts +41 -0
  47. package/lib/types/client/blocks/diagram/theme.d.ts +37 -0
  48. package/lib/types/client/blocks/forms.d.ts +77 -0
  49. package/lib/types/client/blocks/image.d.ts +6 -0
  50. package/lib/types/client/blocks/render-node.d.ts +10 -0
  51. package/lib/types/client/blocks/state.d.ts +63 -0
  52. package/lib/types/client/blocks/svg.d.ts +4 -0
  53. package/lib/types/client/dom-fence.d.ts +30 -0
  54. package/lib/types/client/echarts-engine.d.ts +4 -0
  55. package/lib/types/client/echarts-lazy.d.ts +18 -0
  56. package/lib/types/client/embed.d.ts +10 -0
  57. package/lib/types/client/fence-render.d.ts +106 -0
  58. package/lib/types/client/gallery.d.ts +7 -0
  59. package/lib/types/client/genui-runtime/diagnostics.d.ts +18 -0
  60. package/lib/types/client/genui-runtime/index.d.ts +1 -0
  61. package/lib/types/client/genui-runtime/limits.d.ts +54 -0
  62. package/lib/types/client/genui-runtime/normalize.d.ts +15 -0
  63. package/lib/types/client/genui-runtime/schema.d.ts +87 -0
  64. package/lib/types/client/genui-runtime/value-utils.d.ts +18 -0
  65. package/lib/types/client/guard.d.ts +144 -0
  66. package/lib/types/client/i18n/en.d.ts +307 -0
  67. package/lib/types/client/i18n/index.d.ts +44 -0
  68. package/lib/types/client/i18n/runtime.d.ts +64 -0
  69. package/lib/types/client/i18n/zh.d.ts +8 -0
  70. package/lib/types/client/index.d.ts +36 -0
  71. package/lib/types/client/inline.d.ts +5 -0
  72. package/lib/types/client/interaction-store.d.ts +48 -0
  73. package/lib/types/client/mermaid-core.d.ts +8 -0
  74. package/lib/types/client/mermaid-lazy.d.ts +9 -0
  75. package/lib/types/client/mermaid-safe.d.ts +52 -0
  76. package/lib/types/client/panel-command.d.ts +34 -0
  77. package/lib/types/client/panel-store.d.ts +94 -0
  78. package/lib/types/client/panel.d.ts +18 -0
  79. package/lib/types/client/parse-partial.d.ts +63 -0
  80. package/lib/types/client/primitive-adapter.d.ts +4 -0
  81. package/lib/types/client/primitive-labels.d.ts +18 -0
  82. package/lib/types/client/safe-math.d.ts +43 -0
  83. package/lib/types/client/scene3d-core.d.ts +21 -0
  84. package/lib/types/client/scene3d-lazy.d.ts +8 -0
  85. package/lib/types/client/session-resolver.d.ts +8 -0
  86. package/lib/types/client/source-fence.d.ts +29 -0
  87. package/lib/types/client/spec.d.ts +709 -0
  88. package/lib/types/client/standalone/asset-loader.d.ts +2 -0
  89. package/lib/types/client/standalone/bootstrap-types.d.ts +9 -0
  90. package/lib/types/client/standalone/katex-style.d.ts +1 -0
  91. package/lib/types/client/standalone/primitive-adapter.d.ts +54 -0
  92. package/lib/types/client/standalone/runtime.d.ts +2 -0
  93. package/lib/types/client/submission-registry.d.ts +51 -0
  94. package/lib/types/client/svg-fence.d.ts +2 -0
  95. package/lib/types/client/table-details.d.ts +20 -0
  96. package/lib/types/client/templates.d.ts +41 -0
  97. package/lib/types/client/toolview.d.ts +7 -0
  98. package/lib/types/client/walk-spec.d.ts +3 -0
  99. package/lib/types/index.d.ts +1 -0
  100. package/lib/types/plugin/chart-contract.d.ts +9 -0
  101. package/lib/types/plugin/fence-feedback.d.ts +151 -0
  102. package/lib/types/plugin/genui-diagnostic.d.ts +13 -0
  103. package/lib/types/plugin/index.d.ts +35 -0
  104. package/lib/types/plugin/inline-content-diagnostic.d.ts +8 -0
  105. package/lib/types/plugin/invariant.d.ts +15 -0
  106. package/lib/types/plugin/tool.d.ts +27 -0
  107. package/lib/types/shared/fence-repair.d.ts +78 -0
  108. package/lib/types/shared/fence-resolve.d.ts +39 -0
  109. package/package.json +249 -4
  110. package/src/client/EChartNode.tsx +466 -0
  111. package/src/client/ErrorBoundary.tsx +67 -0
  112. package/src/client/GenuiBlock.module.css +2221 -0
  113. package/src/client/GenuiBlock.tsx +235 -0
  114. package/src/client/PlotBlock.module.css +171 -0
  115. package/src/client/PlotBlock.tsx +492 -0
  116. package/src/client/TemplateDrawer.module.css +152 -0
  117. package/src/client/TemplateDrawer.tsx +147 -0
  118. package/src/client/achievement-store.ts +151 -0
  119. package/src/client/achievement-toast.tsx +71 -0
  120. package/src/client/achievements.ts +160 -0
  121. package/src/client/action-context.ts +32 -0
  122. package/src/client/artifact/ArtifactExport.module.css +64 -0
  123. package/src/client/artifact/ExportableGenuiBlock.tsx +100 -0
  124. package/src/client/artifact/create.ts +69 -0
  125. package/src/client/artifact/download.ts +42 -0
  126. package/src/client/artifact/html.ts +157 -0
  127. package/src/client/artifact/index.ts +15 -0
  128. package/src/client/artifact/json.ts +6 -0
  129. package/src/client/artifact/parse.ts +32 -0
  130. package/src/client/artifact/portability.ts +47 -0
  131. package/src/client/artifact/standalone-theme.ts +94 -0
  132. package/src/client/artifact/types.ts +44 -0
  133. package/src/client/asset-echarts-core.ts +39 -0
  134. package/src/client/asset-echarts.ts +27 -0
  135. package/src/client/asset-loader.ts +96 -0
  136. package/src/client/asset-mermaid.ts +13 -0
  137. package/src/client/asset-three.ts +12 -0
  138. package/src/client/blocks/advanced.tsx +537 -0
  139. package/src/client/blocks/basic.tsx +121 -0
  140. package/src/client/blocks/charts.tsx +999 -0
  141. package/src/client/blocks/checkbox.tsx +61 -0
  142. package/src/client/blocks/diagram/geometry.ts +151 -0
  143. package/src/client/blocks/diagram/index.tsx +293 -0
  144. package/src/client/blocks/diagram/layout.ts +202 -0
  145. package/src/client/blocks/diagram/theme.ts +127 -0
  146. package/src/client/blocks/forms.tsx +531 -0
  147. package/src/client/blocks/image.tsx +28 -0
  148. package/src/client/blocks/render-node.tsx +494 -0
  149. package/src/client/blocks/state.ts +65 -0
  150. package/src/client/blocks/svg.tsx +66 -0
  151. package/src/client/dom-fence.tsx +1123 -0
  152. package/src/client/echarts-engine.ts +9 -0
  153. package/src/client/echarts-lazy.ts +41 -0
  154. package/src/client/embed.ts +19 -0
  155. package/src/client/fence-render.tsx +266 -0
  156. package/src/client/gallery.ts +215 -0
  157. package/src/client/genui-runtime/diagnostics.ts +165 -0
  158. package/src/client/genui-runtime/index.ts +1 -0
  159. package/src/client/genui-runtime/limits.ts +54 -0
  160. package/src/client/genui-runtime/normalize.ts +329 -0
  161. package/src/client/genui-runtime/schema.ts +352 -0
  162. package/src/client/genui-runtime/value-utils.ts +67 -0
  163. package/src/client/guard.ts +1965 -0
  164. package/src/client/i18n/en.ts +335 -0
  165. package/src/client/i18n/index.ts +125 -0
  166. package/src/client/i18n/runtime.ts +130 -0
  167. package/src/client/i18n/zh.ts +330 -0
  168. package/src/client/index.tsx +228 -0
  169. package/src/client/inline.ts +106 -0
  170. package/src/client/interaction-store.ts +127 -0
  171. package/src/client/mermaid-core.ts +158 -0
  172. package/src/client/mermaid-lazy.ts +31 -0
  173. package/src/client/mermaid-safe.ts +122 -0
  174. package/src/client/panel-command.ts +138 -0
  175. package/src/client/panel-store.ts +471 -0
  176. package/src/client/panel.tsx +287 -0
  177. package/src/client/parse-partial.ts +170 -0
  178. package/src/client/primitive-adapter.ts +13 -0
  179. package/src/client/primitive-labels.ts +55 -0
  180. package/src/client/safe-math.ts +298 -0
  181. package/src/client/scene3d-core.ts +195 -0
  182. package/src/client/scene3d-lazy.ts +26 -0
  183. package/src/client/session-resolver.ts +33 -0
  184. package/src/client/source-fence.ts +70 -0
  185. package/src/client/spec.ts +896 -0
  186. package/src/client/standalone/asset-loader.ts +9 -0
  187. package/src/client/standalone/bootstrap-types.ts +11 -0
  188. package/src/client/standalone/katex-style.ts +1 -0
  189. package/src/client/standalone/primitive-adapter.tsx +94 -0
  190. package/src/client/standalone/runtime.tsx +27 -0
  191. package/src/client/submission-registry.ts +150 -0
  192. package/src/client/svg-fence.tsx +39 -0
  193. package/src/client/table-details.ts +151 -0
  194. package/src/client/templates.ts +322 -0
  195. package/src/client/toolview.tsx +67 -0
  196. package/src/client/walk-spec.ts +43 -0
  197. package/src/css-modules.d.ts +5 -0
  198. package/src/index.ts +9 -0
  199. package/src/plugin/chart-contract.ts +13 -0
  200. package/src/plugin/fence-feedback.ts +655 -0
  201. package/src/plugin/genui-diagnostic.ts +112 -0
  202. package/src/plugin/index.ts +224 -0
  203. package/src/plugin/inline-content-diagnostic.ts +178 -0
  204. package/src/plugin/invariant.ts +30 -0
  205. package/src/plugin/node-shims.d.ts +31 -0
  206. package/src/plugin/tool.ts +424 -0
  207. package/src/shared/fence-repair.ts +536 -0
  208. package/src/shared/fence-resolve.ts +80 -0
  209. package/tsconfig.json +35 -0
  210. package/tsdown.config.ts +275 -0
@@ -0,0 +1,19 @@
1
+ //#region src/plugin/invariant.ts
2
+ const PACKAGE_NAME = "@changfenhuang/dsh-genui";
3
+ /** Cordis companion plugin name. */
4
+ const name = "genui-invariant";
5
+ /** Service required before the companion can reserve package ownership. */
6
+ const inject = ["invariants"];
7
+ /**
8
+ * No runtime invariant: this host plugin only registers a static prompt
9
+ * section; the section text is pinned by its own tests.
10
+ */
11
+ const install = () => {};
12
+ /**
13
+ * Register this package's invariant companion.
14
+ * @param ctx - Cordis context carrying the invariant service.
15
+ * @returns the installed registration's disposer after setup succeeds.
16
+ */
17
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
18
+ //#endregion
19
+ export { apply, inject, name };
@@ -0,0 +1,13 @@
1
+ import type { GenuiEChart } from './spec.ts';
2
+ /**
3
+ * Categorical fallback palette. The host defines its `--dsw-static-*` tokens on
4
+ * `body`, not on `:root`, and ECharts renders to CANVAS (so a `var(--x)` string
5
+ * is meaningless to it — every colour must be resolved to a literal first).
6
+ * Reading only `document.documentElement` therefore returned '' for every
7
+ * series colour and collapsed multi-series charts to one accent hue; these
8
+ * fixed hues keep series distinguishable on any host.
9
+ */
10
+ export declare const SERIES_FALLBACK: readonly ["#679efe", "#4ed17e", "#f5b83d", "#f2707a", "#8b7ff0", "#3fc7d4", "#b7c8fe", "#9aa3b2"];
11
+ export declare function EChartNode({ node }: {
12
+ node: GenuiEChart;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Rendering error boundary: a component render failure inside one GenUI
3
+ * block must never take down the whole chat surface (pre-2026-08-09 builds
4
+ * crashed the entire conversation tree on a missing API). Every fence,
5
+ * toolview card and panel body renders under this boundary; on error the
6
+ * block degrades to a compact inline alert instead of unmounting the tree.
7
+ * @module @changfenhuang/dsh-genui/client
8
+ */
9
+ import { Component, type ErrorInfo, type ReactNode } from 'react';
10
+ interface ErrorBoundaryProps {
11
+ /** What the block is, shown in the fallback alert (fence / tool / panel). */
12
+ label?: string;
13
+ children: ReactNode;
14
+ }
15
+ interface ErrorBoundaryState {
16
+ error: Error | null;
17
+ }
18
+ /**
19
+ * Class boundary because function components cannot catch their own subtree
20
+ * errors. `getDerivedStateFromError` flips to the fallback render; the error
21
+ * itself is logged (and its message surfaced in the alert) so the user sees
22
+ * a hint instead of a silent white region.
23
+ */
24
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
25
+ state: ErrorBoundaryState;
26
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
27
+ componentDidCatch(error: Error, info: ErrorInfo): void;
28
+ render(): ReactNode;
29
+ }
30
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { GenuiBlockProps } from './blocks/state.ts';
2
+ export declare const GENUI_ACTION_DEBOUNCE_MS = 300;
3
+ /**
4
+ * Render a GenUI spec as an inline block. `stateKey` is also the durable
5
+ * component identity. A streaming instance adopts its first durable key so
6
+ * inputs and pending actions survive settling. Leaving an existing durable
7
+ * key remounts, keeping different blocks' interaction state isolated.
8
+ */
9
+ export declare const GenuiBlock: import("react").NamedExoticComponent<GenuiBlockProps>;
@@ -0,0 +1,44 @@
1
+ export interface PlotSeriesParam {
2
+ name: string;
3
+ value: number;
4
+ min?: number | undefined;
5
+ max?: number | undefined;
6
+ step?: number | undefined;
7
+ /** v1.5: animate this parameter from its initial value to this target. */
8
+ animateTo?: number | undefined;
9
+ /** Animation duration in ms (default 4000). */
10
+ durationMs?: number | undefined;
11
+ /** Loop the animation (default false). */
12
+ loop?: boolean | undefined;
13
+ }
14
+ export interface PlotSeries {
15
+ /** Math expression in x. */
16
+ expr: string;
17
+ /** Optional label shown in a legend row. */
18
+ label?: string | undefined;
19
+ /** Stroke color; defaults to the accent token (multi-series auto-assign). */
20
+ color?: string | undefined;
21
+ /** v2.9 draw shape: line (default), area (fill to baseline), scatter. */
22
+ kind?: 'line' | 'area' | 'scatter' | undefined;
23
+ /** v2: adjustable parameters, one slider each, live re-render. */
24
+ params?: PlotSeriesParam[] | undefined;
25
+ }
26
+ /** Categorical palette for multi-series plots: host static tokens only
27
+ * (design system v2 — same families as the chart/avatar palettes in
28
+ * GenuiBlock, no off-theme hexes). CSS custom properties resolve inside
29
+ * inline `style` on SVG strokes and legend swatches. */
30
+ export declare const PLOT_COLORS: string[];
31
+ export interface PlotBlockProps {
32
+ /** Functions to draw, in draw order. */
33
+ series: PlotSeries[];
34
+ /** Horizontal range, inclusive. */
35
+ xMin?: number | undefined;
36
+ xMax?: number | undefined;
37
+ /** Vertical bounds; omitted = auto-fit to the sampled data. */
38
+ yMin?: number | undefined;
39
+ yMax?: number | undefined;
40
+ /** Chart title. */
41
+ title?: string | undefined;
42
+ }
43
+ /** Render one plot: grid, axes, one polyline per series, legend, sliders. */
44
+ export declare const PlotBlock: import("react").NamedExoticComponent<PlotBlockProps>;
@@ -0,0 +1,7 @@
1
+ export interface TemplateDrawerProps {
2
+ /** Try it: insert the template instruction into the composer draft. */
3
+ onUse: (instruction: string) => void;
4
+ /** Which drawer is open (template center / trophies), driven by the header. */
5
+ tab: 'templates' | 'achievements';
6
+ }
7
+ export declare function TemplateDrawer({ onUse, tab }: TemplateDrawerProps): import("react").JSX.Element;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * achievement-store.ts — 成就状态存储与埋点入口(模块级单例)。
3
+ *
4
+ * 只存计数与解锁时间戳;绝不含消息/内容。localStorage 持久化,
5
+ * 订阅接口供 toast 与成就页消费。埋点入口:
6
+ * - recordFence(spec):一次「内容不重复」的界面渲染(按 spec 指纹去重,
7
+ * LRU 指纹表跨刷新防重放重复计数)
8
+ * - recordPanel():面板 dock 出现
9
+ * - recordInteraction():组件动作回传(去抖后)
10
+ * - recordTemplateUse():模板中心试用
11
+ */
12
+ import type { GenuiSpec } from './spec.ts';
13
+ import { type AchieveState, type AchievementDef } from './achievements.ts';
14
+ /** 记录一次「内容不重复」的 fence 渲染。 */
15
+ export declare function recordFence(spec: GenuiSpec): void;
16
+ /** 记录一次面板 dock 出现(仅会话从无到有时)。 */
17
+ export declare function recordPanel(): void;
18
+ /** 记录一次组件交互动作回传。 */
19
+ export declare function recordInteraction(): void;
20
+ /** 记录一次模板试用。 */
21
+ export declare function recordTemplateUse(): void;
22
+ /** 当前状态快照(订阅者读取)。 */
23
+ export declare function getAchievementSnapshot(): {
24
+ state: AchieveState;
25
+ unlocked: Record<string, number>;
26
+ };
27
+ /** 取走新解锁(toast 消费;一次性)。 */
28
+ export declare function consumeUnlocks(): AchievementDef[];
29
+ /** 订阅状态变化(toast 与成就页)。 */
30
+ export declare function subscribeAchievements(listener: () => void): () => void;
31
+ /** 成就页 spec 数据源(面板内渲染用)。 */
32
+ export declare function achievementCount(): {
33
+ total: number;
34
+ unlocked: number;
35
+ };
@@ -0,0 +1,2 @@
1
+ /** Mount the toast stack (called from apply; returns the unmount disposer). */
2
+ export declare function mountAchievementToasts(): () => void;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * achievements.ts — GenUI exploration trophies.
3
+ *
4
+ * Lightweight local trophies: they count USAGE EVENTS only (fences rendered,
5
+ * panels shown, actions sent back, templates tried) and never read message
6
+ * or interface content. State lives in localStorage and survives across
7
+ * sessions. An unlock enters the toast queue (consumed by achievement-toast),
8
+ * and the panel's trophy tab renders its own page through dsh-ui (dogfooding).
9
+ *
10
+ * The design mirrors dsh-achievements' layered snapshot, with zero host
11
+ * changes: every counter sits on this package's own render/interaction paths
12
+ * (GenuiBlock / TemplateDrawer / GenuiPanel).
13
+ *
14
+ * Trophy NAMES and DESCRIPTIONS resolve from the i18n dictionaries at read
15
+ * time (`ach.<id>.name` / `.desc`); only the ids are persisted, so a language
16
+ * switch never orphans an unlocked trophy.
17
+ */
18
+ import type { GenuiSpec } from './spec.ts';
19
+ /** Cumulative usage counters (the trophy inputs). */
20
+ export interface AchieveState {
21
+ /** Distinct fences rendered. */
22
+ fences: number;
23
+ /** Sessions in which the panel dock appeared. */
24
+ panels: number;
25
+ /** Component action round-trips (after debounce). */
26
+ interactions: number;
27
+ /** Templates tried. */
28
+ templates: number;
29
+ /** Fences containing a chart node (chart/plot/echart). */
30
+ charts: number;
31
+ /** Fences containing an advanced node (scene3d/mermaid/diagram). */
32
+ advanced: number;
33
+ }
34
+ export declare function emptyState(): AchieveState;
35
+ export interface AchievementDef {
36
+ id: string;
37
+ /** Display name in the active locale (read through {@link achievementName}). */
38
+ readonly name: string;
39
+ /** Description in the active locale (read through {@link achievementDesc}). */
40
+ readonly description: string;
41
+ /** Hide name/description until unlocked (easter egg). */
42
+ hidden?: boolean;
43
+ /** Rarity tier. */
44
+ rarity: 'common' | 'rare' | 'legendary';
45
+ check: (s: AchieveState) => boolean;
46
+ }
47
+ /** Localized display name of a trophy. */
48
+ export declare function achievementName(id: string): string;
49
+ /** Localized description of a trophy. */
50
+ export declare function achievementDesc(id: string): string;
51
+ /** Localized rarity badge label. */
52
+ export declare function rarityLabel(rarity: AchievementDef['rarity']): string;
53
+ export declare const ACHIEVEMENTS: readonly AchievementDef[];
54
+ /** Count the relevant node families in a spec (same walk as the guard). */
55
+ export declare function countSpecKinds(spec: GenuiSpec): {
56
+ charts: number;
57
+ advanced: number;
58
+ };
59
+ /** Build the trophy page spec (rendered by dsh-ui): progress stats, the
60
+ * unlock list, and rarity badges — all in the active locale. */
61
+ export declare function buildAchievementsSpec(state: AchieveState, unlocked: Record<string, number>): GenuiSpec;
62
+ /** New unlocks for a state (hidden trophies included — rules are thresholds). */
63
+ export declare function checkAchievements(state: AchieveState, unlocked: Record<string, number>): AchievementDef[];
@@ -0,0 +1,7 @@
1
+ import type { Context } from 'react';
2
+ /** v2 action handler: component action + its collected data. */
3
+ export type GenuiActionHandler = (action: string, payload: Record<string, unknown>) => void;
4
+ /** Host-provided context when the deployment ships it, else the local one. */
5
+ export declare const GenuiActionContext: Context<GenuiActionHandler | undefined>;
6
+ /** Read the installed action handler, if any. */
7
+ export declare function useGenuiAction(): GenuiActionHandler | undefined;
@@ -0,0 +1,6 @@
1
+ import type { GenuiBlockProps } from '../blocks/state.ts';
2
+ export interface ExportableGenuiBlockProps extends GenuiBlockProps {
3
+ exportEnabled?: boolean;
4
+ }
5
+ /** 在完成态 GenUI 外层显示 artifact 导出菜单。 */
6
+ export declare function ExportableGenuiBlock(props: ExportableGenuiBlockProps): import("react").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import type { BlockInteractionState } from '../interaction-store.ts';
2
+ import type { GenuiSpec } from '../spec.ts';
3
+ import { type CreateGenuiArtifactOptions, type GenuiArtifactV1 } from './types.ts';
4
+ /** 创建规范化 artifact,并清除密码默认值及对应的持久化字段。 */
5
+ export declare function createGenuiArtifact(spec: GenuiSpec, state?: BlockInteractionState, options?: CreateGenuiArtifactOptions): GenuiArtifactV1;
@@ -0,0 +1,9 @@
1
+ import { type GenuiArtifactV1 } from './types.ts';
2
+ /** 过滤文件名中的路径符号、控制字符和危险标点。 */
3
+ export declare function sanitizeArtifactFilename(title: string | undefined, extension: '.html' | '.genui.json'): string;
4
+ /** 触发浏览器下载并释放临时地址。 */
5
+ export declare function downloadBlob(blob: Blob, filename: string): void;
6
+ /** 下载规范化 GenUI JSON artifact。 */
7
+ export declare function downloadGenuiArtifactJson(artifact: GenuiArtifactV1): void;
8
+ /** 生成并下载独立 HTML。 */
9
+ export declare function downloadGenuiArtifactHtml(artifact: GenuiArtifactV1): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { type GenuiArtifactV1 } from './types.ts';
2
+ /** 使用已下载的运行文件生成完整的独立 HTML 文档。 */
3
+ export declare function createStandaloneHtmlDocument(artifact: GenuiArtifactV1, bundles: ReadonlyMap<string, Uint8Array>, baseURI?: string): string;
4
+ /** 获取独立运行文件及规格实际使用的图形引擎,生成单文件 HTML。 */
5
+ export declare function buildStandaloneHtml(rawArtifact: GenuiArtifactV1): Promise<string>;
@@ -0,0 +1,8 @@
1
+ export { createGenuiArtifact } from './create.ts';
2
+ export { buildStandaloneHtml } from './html.ts';
3
+ export { downloadGenuiArtifactHtml, downloadGenuiArtifactJson } from './download.ts';
4
+ export { parseGenuiArtifact } from './parse.ts';
5
+ export { analyzeGenuiPortability } from './portability.ts';
6
+ export { serializeGenuiArtifact } from './json.ts';
7
+ export { GenuiExportError } from './types.ts';
8
+ export type { CreateGenuiArtifactOptions, GenuiArtifactTheme, GenuiArtifactV1, GenuiExportErrorCode, GenuiPortabilityReport, GenuiStandaloneAsset, } from './types.ts';
@@ -0,0 +1,3 @@
1
+ import type { GenuiArtifactV1 } from './types.ts';
2
+ /** 以稳定缩进序列化 GenUI artifact。 */
3
+ export declare function serializeGenuiArtifact(artifact: GenuiArtifactV1): string;
@@ -0,0 +1,3 @@
1
+ import { type GenuiArtifactV1 } from './types.ts';
2
+ /** 校验 artifact 格式并重新执行当前 GenUI 规范化流程。 */
3
+ export declare function parseGenuiArtifact(value: unknown): GenuiArtifactV1 | null;
@@ -0,0 +1,4 @@
1
+ import type { GenuiSpec } from '../spec.ts';
2
+ import type { GenuiPortabilityReport } from './types.ts';
3
+ /** 扫描嵌套 GenUI 节点,选择运行资源并列出独立页面限制。 */
4
+ export declare function analyzeGenuiPortability(spec: GenuiSpec): GenuiPortabilityReport;
@@ -0,0 +1,2 @@
1
+ /** standalone 页面使用的基础颜色和版面样式。 */
2
+ export declare const STANDALONE_THEME_CSS = "\n:root {\n color-scheme: light;\n --dsw-static-neutral-bluish-00: rgb(255, 255, 255);\n --dsw-static-neutral-bluish-50: rgb(249, 250, 251);\n --dsw-static-neutral-bluish-300: rgb(207, 211, 214);\n --dsw-static-neutral-bluish-400: rgb(173, 178, 184);\n --dsw-static-neutral-bluish-600: rgb(129, 133, 140);\n --dsw-static-neutral-bluish-700: rgb(97, 102, 107);\n --dsw-static-neutral-bluish-800: rgb(53, 54, 56);\n --dsw-static-neutral-bluish-850: rgb(44, 44, 46);\n --dsw-static-neutral-bluish-875: rgb(35, 35, 36);\n --dsw-static-neutral-bluish-900: rgb(27, 27, 28);\n --dsw-static-neutral-bluish-950: rgb(21, 21, 23);\n --dsw-static-neutral-bluish-1000: rgb(15, 17, 21);\n --dsw-alias-bg-base: var(--dsw-static-neutral-bluish-00);\n --dsw-alias-bg-layer-1: var(--dsw-static-neutral-bluish-00);\n --dsw-alias-bg-layer-2: var(--dsw-static-neutral-bluish-00);\n --dsw-alias-bg-layer-3: var(--dsw-static-neutral-bluish-00);\n --dsw-alias-border-l1: rgba(0, 0, 0, 0.04);\n --dsw-alias-border-l2: rgba(0, 0, 0, 0.1);\n --dsw-alias-fill-hover: #eef2f7;\n --dsw-alias-label-primary: var(--dsw-static-neutral-bluish-1000);\n --dsw-alias-label-secondary: var(--dsw-static-neutral-bluish-700);\n --dsw-alias-label-tertiary: var(--dsw-static-neutral-bluish-600);\n --dsw-alias-label-caption: var(--dsw-static-neutral-bluish-400);\n --dsw-alias-markdown-code-block: var(--dsw-static-neutral-bluish-50);\n --dsw-alias-markdown-hr: #cbd5e1;\n /* DSH \u9759\u6001\u8C03\u8272\u677F\u4F9B\u8BED\u4E49\u72B6\u6001\u522B\u540D\u4F7F\u7528\u3002 */\n --dsw-static-deepseek-100: rgb(228, 237, 253);\n --dsw-static-deepseek-400: rgb(122, 170, 255);\n --dsw-static-deepseek-500: rgb(65, 118, 230);\n --dsw-static-deepseek-800: rgb(52, 65, 91);\n --dsw-static-green-100: rgb(230, 250, 237);\n --dsw-static-green-400: rgb(78, 209, 126);\n --dsw-static-green-500: rgb(34, 197, 94);\n --dsw-static-green-900: rgb(35, 60, 44);\n --dsw-static-amber-100: rgb(254, 245, 231);\n --dsw-static-amber-400: rgb(247, 173, 49);\n --dsw-static-amber-500: rgb(245, 158, 11);\n --dsw-static-amber-600: rgb(221, 134, 41);\n --dsw-static-amber-900: rgb(39, 36, 31);\n --dsw-static-red-400: rgb(242, 90, 90);\n --dsw-static-red-600: rgb(236, 19, 19);\n\n /* DSH \u6D45\u8272\u4E3B\u9898\u8BED\u4E49\u72B6\u6001\u522B\u540D\u3002 */\n --dsw-alias-state-business-primary: var(--dsw-static-deepseek-500);\n --dsw-alias-state-business-tertiary: var(--dsw-static-deepseek-100);\n --dsw-alias-state-success-primary: var(--dsw-static-green-500);\n --dsw-alias-state-success-secondary: var(--dsw-static-green-400);\n --dsw-alias-state-success-tertiary: var(--dsw-static-green-100);\n --dsw-alias-state-warn-label: var(--dsw-static-amber-600);\n --dsw-alias-state-warn-primary: var(--dsw-static-amber-500);\n --dsw-alias-state-warn-secondary: var(--dsw-static-amber-400);\n --dsw-alias-state-warn-tertiary: var(--dsw-static-amber-100);\n --dsw-alias-state-error-primary: var(--dsw-static-red-600);\n --dsw-alias-state-error-secondary: var(--dsw-static-red-400);\n --dsw-static-deepseek-300: rgb(183, 200, 254);\n --dsw-static-deepseek-450: rgb(86, 134, 254);\n --dsw-static-blue-450: rgb(77, 147, 248);\n}\nbody[data-ds-dark-theme] {\n color-scheme: dark;\n --dsw-alias-bg-base: var(--dsw-static-neutral-bluish-950);\n --dsw-alias-bg-layer-1: var(--dsw-static-neutral-bluish-875);\n --dsw-alias-bg-layer-2: var(--dsw-static-neutral-bluish-850);\n --dsw-alias-bg-layer-3: var(--dsw-static-neutral-bluish-800);\n --dsw-alias-border-l1: rgba(255, 255, 255, 0.06);\n --dsw-alias-border-l2: rgba(255, 255, 255, 0.12);\n --dsw-alias-fill-hover: #2b3542;\n --dsw-alias-label-primary: var(--dsw-static-neutral-bluish-50);\n --dsw-alias-label-secondary: var(--dsw-static-neutral-bluish-300);\n --dsw-alias-label-tertiary: var(--dsw-static-neutral-bluish-400);\n --dsw-alias-label-caption: var(--dsw-static-neutral-bluish-600);\n --dsw-alias-markdown-code-block: var(--dsw-static-neutral-bluish-900);\n --dsw-alias-markdown-hr: #465365;\n /* DSH \u6DF1\u8272\u4E3B\u9898\u8BED\u4E49\u72B6\u6001\u522B\u540D\u3002 */\n --dsw-alias-state-business-primary: var(--dsw-static-deepseek-400);\n --dsw-alias-state-business-tertiary: var(--dsw-static-deepseek-800);\n --dsw-alias-state-success-primary: var(--dsw-static-green-500);\n --dsw-alias-state-success-secondary: var(--dsw-static-green-400);\n --dsw-alias-state-success-tertiary: var(--dsw-static-green-900);\n --dsw-alias-state-warn-label: var(--dsw-static-amber-600);\n --dsw-alias-state-warn-primary: var(--dsw-static-amber-500);\n --dsw-alias-state-warn-secondary: var(--dsw-static-amber-400);\n --dsw-alias-state-warn-tertiary: var(--dsw-static-amber-900);\n --dsw-alias-state-error-primary: var(--dsw-static-red-400);\n --dsw-alias-state-error-secondary: var(--dsw-static-red-400);\n}\nhtml { min-height: 100%; }\nbody { margin: 0; min-height: 100vh; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font-family: system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif; }\n#genui-root { width: min(1200px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 56px; }\n";
@@ -0,0 +1,33 @@
1
+ import type { LocaleId } from '../i18n/runtime.ts';
2
+ import type { GenuiSpec } from '../spec.ts';
3
+ import type { BlockInteractionState } from '../interaction-store.ts';
4
+ export declare const GENUI_ARTIFACT_FORMAT = "dsh-genui";
5
+ export declare const GENUI_ARTIFACT_VERSION: 1;
6
+ export type GenuiArtifactTheme = 'light' | 'dark';
7
+ export type GenuiStandaloneAsset = 'mermaid' | 'three' | 'echarts-core' | 'echarts-full';
8
+ export interface GenuiArtifactV1 {
9
+ format: typeof GENUI_ARTIFACT_FORMAT;
10
+ version: typeof GENUI_ARTIFACT_VERSION;
11
+ spec: GenuiSpec;
12
+ state?: BlockInteractionState;
13
+ presentation: {
14
+ locale: LocaleId;
15
+ theme: GenuiArtifactTheme;
16
+ };
17
+ }
18
+ export interface GenuiPortabilityReport {
19
+ requiredAssets: GenuiStandaloneAsset[];
20
+ customTypes: string[];
21
+ externalMedia: string[];
22
+ hasModelActions: boolean;
23
+ }
24
+ export type GenuiExportErrorCode = 'unsupported-custom-component' | 'runtime-fetch-failed' | 'asset-fetch-failed' | 'artifact-invalid' | 'download-failed';
25
+ /** 导出流程遇到可供界面识别的错误时使用。 */
26
+ export declare class GenuiExportError extends Error {
27
+ readonly code: GenuiExportErrorCode;
28
+ constructor(code: GenuiExportErrorCode, message: string);
29
+ }
30
+ export interface CreateGenuiArtifactOptions {
31
+ locale?: LocaleId;
32
+ theme?: GenuiArtifactTheme;
33
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ECharts FULL asset-bundle entry: the complete engine, fetched only when a
3
+ * spec needs a chart type outside the core set or ships a raw `option`.
4
+ * Registers on `window.__GenuiAssets__.echartsFull`. Built as a standalone IIFE into
5
+ * `lib/assets/echarts.js` and served by the plugin's node-half route; loaded
6
+ * on demand by echarts-lazy when a spec contains an `echart` node.
7
+ * @module @changfenhuang/dsh-genui/client/asset-echarts
8
+ */
9
+ import { type EChartsType, type EChartsCoreOption } from 'echarts';
10
+ import 'echarts-wordcloud';
11
+ /** The engine surface registered by the echarts asset bundle. */
12
+ export interface EChartsAssetApi {
13
+ /** Create an ECharts instance on `el`, apply `option`, return the instance. */
14
+ createChart: (el: HTMLElement, option: EChartsCoreOption, opts?: {
15
+ height?: number;
16
+ }) => EChartsType;
17
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Asset-bundle loader: fetches one of the plugin's lazy engine bundles
3
+ * (`lib/assets/mermaid.js` / `lib/assets/three.js`) by script injection and
4
+ * hands back the engine surface the bundle registered on
5
+ * `window.__GenuiAssets__`.
6
+ *
7
+ * The bundles are served by the plugin's OWN node-half HTTP route
8
+ * (`/plugins/@changfenhuang/dsh-genui/assets/*`), registered through the host
9
+ * webserver service — no host source change needed, and the longest-prefix
10
+ * rule lets this route win over the generic `/plugins` bundle route. Each
11
+ * file is loaded at most once per page (promise memoized); a rejection is
12
+ * final for the page (the node's fallback UI takes over).
13
+ *
14
+ * The rev query rides the boot graph: the plugin's own row in
15
+ * `window.__DSH_BOOT__` carries the client bundle rev, so a plugin rebuild
16
+ * busts the asset cache together with the main bundle. Absent graph = no
17
+ * query; the route serves no-cache anyway.
18
+ * @module @changfenhuang/dsh-genui/client/asset-loader
19
+ */
20
+ /** Set once before rendering when the host bundles engines locally. */
21
+ export declare function setGenuiAssetBase(baseURL: string): void;
22
+ /** Resolve an asset URL, appending the bundle rev for cache busting when the
23
+ * boot graph exposes it. */
24
+ export declare function assetUrl(file: string): string;
25
+ /**
26
+ * Load one asset bundle and return the engines it registered. Memoized per
27
+ * file: repeated requests (several mermaid nodes, re-renders) share one
28
+ * script load; a failed load stays failed for the page (the component shows
29
+ * its fallback).
30
+ * @param name - 'mermaid', 'three', 'echarts-core', or 'echarts-full'.
31
+ * @returns the registered engine surface.
32
+ */
33
+ export declare function loadGenuiAsset<T>(name: 'mermaid' | 'three' | 'echarts-core' | 'echarts-full'): Promise<T>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ import type { AnswersState, GenuiBlockProps } from './state.ts';
2
+ import type { GenuiAccordion, GenuiBreadcrumb, GenuiCallout, GenuiCode, GenuiCopy, GenuiDiff, GenuiFileTree, GenuiJson, GenuiKeyValue, GenuiMermaid, GenuiPlot, GenuiQuiz, GenuiScene3D, GenuiSteps, GenuiTabs, GenuiTimeline } from '../spec.ts';
3
+ /** Callout: a tinted notice box with an optional heading. */
4
+ export declare const CalloutNode: import("react").NamedExoticComponent<{
5
+ node: GenuiCallout;
6
+ }>;
7
+ /** Steps: a vertical progress checklist with an optional current index. */
8
+ export declare const StepsNode: import("react").NamedExoticComponent<{
9
+ steps: GenuiSteps;
10
+ }>;
11
+ /** KeyValue: a definition list for configs and metadata. */
12
+ export declare const KeyValueNode: import("react").NamedExoticComponent<{
13
+ node: GenuiKeyValue;
14
+ }>;
15
+ /** Plot: SVG function plot over the SafeMath evaluator. The series mapping
16
+ * is memoized on the stable spec node so the memo boundary actually skips
17
+ * sibling-state re-renders (a fresh mapped array would defeat it). */
18
+ export declare const PlotNode: import("react").NamedExoticComponent<{
19
+ plot: GenuiPlot;
20
+ }>;
21
+ /** Diff: 收编 dsh DiffBlock (same path/oldText/newText shape as DiffHunk). */
22
+ export declare const DiffNode: import("react").NamedExoticComponent<{
23
+ node: GenuiDiff;
24
+ }>;
25
+ /** Json: 收编 dsh JsonTree. */
26
+ export declare const JsonNode: import("react").NamedExoticComponent<{
27
+ node: GenuiJson;
28
+ }>;
29
+ /** Code: 收编 dsh CodeBlock with explicit language. */
30
+ export declare const CodeNode: import("react").NamedExoticComponent<{
31
+ node: GenuiCode;
32
+ }>;
33
+ /**
34
+ * Table: LOCAL sorting (v2.9) — click a header to sort ascending, click
35
+ * again for descending, a third click restores the spec order. Zero model
36
+ * round trip. Numeric cells (numbers or numeric strings) compare numerically;
37
+ * everything else compares as text.
38
+ */
39
+ export declare function TabsNode({ tabs, onAction, depth, answers }: {
40
+ tabs: GenuiTabs;
41
+ onAction?: GenuiBlockProps['onAction'];
42
+ depth?: number;
43
+ answers?: AnswersState | undefined;
44
+ }): import("react").JSX.Element;
45
+ /** Radio: one option from a group; local selection state. The group name is
46
+ * useId-based so sibling groups never collide (deterministic per mount).
47
+ *
48
+ * v2.5 aggregation: when `group` is set, the selection is recorded into the
49
+ * block-wide answers registry instead of firing a per-click action — a
50
+ * sibling `submit` node then grades the paper IN PLACE (v2.6, questions
51
+ * carry `answer` data) or collects all groups in ONE action. Without
52
+ * `group`, the legacy per-click action fires. After a local grading the
53
+ * group locks until 重新作答 resets it. */
54
+ export declare function AccordionNode({ node, onAction, depth, answers }: {
55
+ node: GenuiAccordion;
56
+ onAction?: GenuiBlockProps['onAction'];
57
+ depth?: number;
58
+ answers?: AnswersState | undefined;
59
+ }): import("react").JSX.Element;
60
+ /** Copy: a one-click copy chip. The live region is a visually-hidden SIBLING
61
+ * (not inside the button) — button content is atomic to screen readers, so a
62
+ * live region inside it would never announce. */
63
+ export declare const CopyNode: import("react").NamedExoticComponent<{
64
+ node: GenuiCopy;
65
+ }>;
66
+ /** Mermaid: lazily loaded diagram renderer. */
67
+ export declare const MermaidNode: import("react").NamedExoticComponent<{
68
+ node: GenuiMermaid;
69
+ }>;
70
+ /** Scene3D: three.js WebGL canvas, lazily imported. */
71
+ export declare const Scene3DNode: import("react").NamedExoticComponent<{
72
+ node: GenuiScene3D;
73
+ }>;
74
+ /** Timeline: vertical event list with time markers. */
75
+ export declare const TimelineNode: import("react").NamedExoticComponent<{
76
+ node: GenuiTimeline;
77
+ }>;
78
+ export declare const FileTreeNode: import("react").NamedExoticComponent<{
79
+ node: GenuiFileTree;
80
+ }>;
81
+ /** Quiz: a self-contained teaching question. Selecting an option marks it
82
+ * correct/incorrect in place and reveals feedback + explanation. With
83
+ * `action`, the chosen answer is ALSO sent back to the model
84
+ * (`{type:'quiz', question, answer, correct}`) so the model can collect or
85
+ * grade it — the in-place judging stays local (no round trip needed). */
86
+ export declare const QuizNode: import("react").NamedExoticComponent<{
87
+ node: GenuiQuiz;
88
+ onAction?: GenuiBlockProps["onAction"];
89
+ }>;
90
+ /** Breadcrumb: path-style navigation trail. */
91
+ export declare const BreadcrumbNode: import("react").NamedExoticComponent<{
92
+ node: GenuiBreadcrumb;
93
+ }>;
94
+ /**
95
+ * Trailing debounce window (ms) for one `[genui-action]` name: rapid
96
+ * repeated interactions on one control (button mashing, switch flipping)
97
+ * collapse into a single action with the LAST payload. Different action
98
+ * names stay independent. The model round-trip takes seconds, so a few
99
+ * hundred ms of trailing delay is imperceptible — and it stops bursts of
100
+ * queued user turns.
101
+ */
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { GenuiAudio, GenuiVideo } from '../spec.ts';
3
+ export declare function avatarColor(name: string): string;
4
+ /** Button with LOCAL click feedback: clicking an actionable button shows a
5
+ * brief "✓ 已触发" chip so the user sees the click registered even while the
6
+ * model round trip is in flight — no more "点了没反应" perception. The chip
7
+ * is purely cosmetic; the action fires through `onClick` as before. */
8
+ export declare function ClickFeedbackButton({ className, disabled, onClick, children }: {
9
+ className: string;
10
+ disabled?: boolean;
11
+ onClick?: (() => void) | undefined;
12
+ children: ReactNode;
13
+ }): import("react").JSX.Element;
14
+ /** Native controls intentionally own play/pause/seek/volume. Model-authored
15
+ * autoplay and controls hints are ignored: media starts only after the user
16
+ * asks for it. */
17
+ export declare const AudioNode: import("react").NamedExoticComponent<{
18
+ node: GenuiAudio;
19
+ }>;
20
+ export declare const VideoNode: import("react").NamedExoticComponent<{
21
+ node: GenuiVideo;
22
+ }>;
@@ -0,0 +1,53 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { GenuiChart, GenuiTable } from '../spec.ts';
3
+ export declare const CHART_COLORS: string[];
4
+ /**
5
+ * Sortable numeric value of a cell. Human-written table cells are rarely
6
+ * plain numbers, so the sort accepts the usual decorations:
7
+ * `1,234` / `1,234`(千分位)、`1.2k`/`3M`/`5b`、`3.5万`/`2亿`、`0.3%`、
8
+ * `¥99`/`$12`。A cell that cannot be read as a number returns NaN and the
9
+ * row falls back to the text comparison — mixed columns sort deterministically
10
+ * (numbers first, then text).
11
+ */
12
+ export declare function parseSortableNumber(v: unknown): number;
13
+ /** Markdown table text for the 复制 Markdown chip (pipes escaped). */
14
+ export declare function tableToMarkdown(columns: string[], rows: Array<Array<string | number>>): string;
15
+ /** RFC 4180 CSV text for the 复制 CSV chip. */
16
+ export declare function tableToCsv(rows: Array<Array<string | number>>): string;
17
+ export declare const TableNode: import("react").NamedExoticComponent<{
18
+ node: GenuiTable;
19
+ /** Live value of `node.filter`: substring-match rows locally. */
20
+ filterValue?: string | undefined;
21
+ /** Live value of `node.sortField`: a column header to sort by. */
22
+ sortValue?: string | undefined;
23
+ /** Renders a row's detail nodes. Supplied by render-node so the table never
24
+ * has to import the renderer back (import cycle). */
25
+ renderDetail?: ((items: NonNullable<GenuiTable["details"]>[number] & object[]) => ReactNode) | undefined;
26
+ }>;
27
+ /** 计算数字用普通或指数形式表示时所需的小数位数。 */
28
+ export declare function fractionDigits(value: number): number;
29
+ /** 按参与计算的原始数值精度格式化图表合计。 */
30
+ export declare function formatChartValue(value: number, maxFractionDigits: number): string;
31
+ /** Chart: bars (default), line (trend), or donut (share); multi-series bars via `series`. */
32
+ export declare const ChartNode: import("react").NamedExoticComponent<{
33
+ chart: GenuiChart;
34
+ /** Live value of the control bound via `chart.filter`; keeps matching
35
+ * categories only (label substring), so a chart is explorable locally. */
36
+ filterValue?: string | undefined;
37
+ }>;
38
+ /** Bars: one column per datum (grouped bars when `series` is present).
39
+ * Single-series bars render against a true zero line, so negative values
40
+ * draw downward instead of clamping to zero height. */
41
+ export declare const BarsNode: import("react").NamedExoticComponent<{
42
+ chart: GenuiChart;
43
+ }>;
44
+ /** Line: responsive polyline with an area wash, nice y ticks and sampled x
45
+ * labels drawn in SVG at their real size. */
46
+ export declare const LineChartNode: import("react").NamedExoticComponent<{
47
+ chart: GenuiChart;
48
+ }>;
49
+ /** Donut: share of total with a center total and a legend that shows each
50
+ * slice's value AND percentage (the old legend was unstyled text). */
51
+ export declare const DonutNode: import("react").NamedExoticComponent<{
52
+ chart: GenuiChart;
53
+ }>;
@@ -0,0 +1,17 @@
1
+ import type { GenuiCheckbox } from '../spec.ts';
2
+ import type { AnswersState, GenuiBlockProps } from './state.ts';
3
+ /**
4
+ * Checkbox with two backwards-compatible modes:
5
+ *
6
+ * - no `group`: legacy local toggle + optional per-click action;
7
+ * - with `group`: local-only multi-select state collected by a sibling submit.
8
+ *
9
+ * A persisted group key wins over `checked`, including an explicit empty
10
+ * array. This lets a user clear every default-checked option without those
11
+ * defaults reappearing after refresh.
12
+ */
13
+ export declare function CheckboxNode({ node, onAction, answers }: {
14
+ node: GenuiCheckbox;
15
+ onAction?: GenuiBlockProps['onAction'];
16
+ answers?: AnswersState | undefined;
17
+ }): import("react").JSX.Element;