@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,87 @@
1
+ /** Runtime metadata shared by GenUI normalization and diagnostics. */
2
+ export type ComponentFieldKind = 'string' | 'string-or-null' | 'number' | 'boolean' | 'nodes' | 'array' | 'object' | 'unknown';
3
+ /** A conditional rule for fields whose presence depends on another field. */
4
+ export interface ComponentConditionalRule {
5
+ readonly kind: 'required-if';
6
+ readonly when: {
7
+ readonly field: string;
8
+ readonly equals: unknown;
9
+ };
10
+ readonly required: readonly string[];
11
+ readonly message?: string;
12
+ }
13
+ /** A field rule that requires at least one member of a field group. */
14
+ export interface ComponentOneOfRule {
15
+ readonly kind: 'one-of-required';
16
+ readonly fields: readonly string[];
17
+ readonly message?: string;
18
+ }
19
+ /** Runtime metadata naming a component-specific semantic validator. */
20
+ export interface ComponentValidatorMetadata {
21
+ readonly name: string;
22
+ readonly [key: string]: unknown;
23
+ }
24
+ /** Runtime schema for an object nested inside a native component field. */
25
+ export interface ComponentRecordSchema {
26
+ readonly required: readonly string[];
27
+ readonly fields: Readonly<Record<string, ComponentFieldKind>>;
28
+ readonly enums: Readonly<Record<string, readonly string[]>>;
29
+ readonly nested: Readonly<Record<string, ComponentRecordSchema>>;
30
+ /** Field-name aliases applied to each record before validation/repair. */
31
+ readonly aliases: Readonly<Record<string, string>>;
32
+ }
33
+ export interface ComponentSchema {
34
+ readonly required: readonly string[];
35
+ readonly fields: Readonly<Record<string, ComponentFieldKind>>;
36
+ readonly enums: Readonly<Record<string, readonly string[]>>;
37
+ /** Explicit optional field kinds; `fields` remains the complete field map. */
38
+ readonly optional: Readonly<Record<string, ComponentFieldKind>>;
39
+ readonly aliases: Readonly<Record<string, string>>;
40
+ /** Written enum values deterministically mapped to canonical ones (field → value → canonical). */
41
+ readonly valueAliases: Readonly<Record<string, Readonly<Record<string, string>>>>;
42
+ readonly oneOfRequired: readonly (readonly string[])[];
43
+ readonly conditionalRequired: readonly ComponentConditionalRule[];
44
+ readonly rules: readonly (ComponentOneOfRule | ComponentConditionalRule)[];
45
+ readonly nested: Readonly<Record<string, ComponentRecordSchema>>;
46
+ readonly validator?: ComponentValidatorMetadata;
47
+ }
48
+ /** Canonical enum domains shared by schema validation and repair. */
49
+ export declare const TEXT_SIZES: readonly ["h1", "h2", "h3", "body", "muted", "caption"];
50
+ export declare const BUTTON_TONES: readonly ["primary", "danger", "success", "ghost"];
51
+ export declare const BADGE_TONES: readonly ["success", "warn", "danger", "accent"];
52
+ export declare const INPUT_TYPES: readonly ["text", "email", "password", "color"];
53
+ export declare const CALLOUT_TONES: readonly ["info", "success", "warning", "error"];
54
+ export declare const CHART_KINDS: readonly ["bars", "line", "donut"];
55
+ export declare const PLOT_KINDS: readonly ["line", "area", "scatter"];
56
+ export declare const MEDIA_ASPECT_RATIOS: readonly ["16:9", "4:3", "1:1", "9:16"];
57
+ export declare const MESH_SHAPES: readonly ["box", "sphere", "cone", "cylinder", "torus"];
58
+ export declare const FILE_TYPES: readonly ["file", "dir"];
59
+ export declare const DIAGRAM_KINDS: readonly ["architecture", "it-state", "flowchart", "sequence", "state", "er", "timeline", "swimlane", "quadrant", "radar", "loop", "nested", "tree", "org-chart", "layers", "venn", "pyramid", "bar", "line", "gantt", "scatter", "high-level", "process", "medallion", "data-flow", "dp-integration", "dp-security-matrix"];
60
+ export declare const DIAGRAM_NODE_TYPES: readonly ["focal", "backend", "store", "external", "input", "optional", "security"];
61
+ export declare const DIAGRAM_VARIANTS: readonly ["light", "dark", "editorial"];
62
+ export declare const DIAGRAM_EDGE_KINDS: readonly ["solid", "dashed", "accent", "link"];
63
+ export declare const DIAGRAM_ROUTES: readonly ["auto", "orthogonal", "straight"];
64
+ export declare const ECHART_PRESETS: readonly ["bar", "line", "area", "pie", "scatter", "radar", "gauge", "funnel", "treemap", "sankey", "graph", "heatmap", "bigline", "wordCloud"];
65
+ /** Oversized single-number stat (one per fence as the visual anchor). */
66
+ export declare const STAT_SIZES: readonly ["hero"];
67
+ /** Progress shapes: a track (default) or a circular gauge. */
68
+ export declare const PROGRESS_VARIANTS: readonly ["bar", "ring"];
69
+ /** Semantic card surfaces. */
70
+ export declare const CARD_TONES: readonly ["info", "success", "warning", "danger"];
71
+ /** Hero cover tones. */
72
+ export declare const HERO_TONES: readonly ["accent", "success", "warning", "danger"];
73
+ /** Table cell renderers (`table.types`, one entry per column). */
74
+ export declare const TABLE_CELL_TYPES: readonly ["text", "num", "delta", "bar", "badge", "spark", "ring", "index", "group"];
75
+ /** Root GenUI specification metadata used by diagnostics. */
76
+ export declare const GENUI_SPEC_SCHEMA: ComponentSchema;
77
+ /** Backwards-friendly short alias for the root specification schema. */
78
+ export declare const SPEC_SCHEMA: ComponentSchema;
79
+ /**
80
+ * Native component field metadata.
81
+ *
82
+ * This is intentionally explicit rather than inferred from TypeScript
83
+ * interfaces: the registry is also consumed at runtime by normalization and
84
+ * diagnostics, where erased interfaces are unavailable.
85
+ */
86
+ export declare const COMPONENT_SCHEMAS: Readonly<Record<string, ComponentSchema>>;
87
+ export declare const GENUI_NATIVE_TYPES: ReadonlySet<string>;
@@ -0,0 +1,18 @@
1
+ /** Shared primitive sanitizers used by the GenUI guard. */
2
+ /** String field: truncate a string to `cap`, or undefined when not a string. */
3
+ export declare function str(value: unknown, cap: number): string | undefined;
4
+ export declare function color(value: unknown): string | undefined;
5
+ /** Keep only http(s) and mailto link targets. */
6
+ export declare function safeHref(value: unknown): string | undefined;
7
+ /** Keep browser-reachable http(s) or same-origin relative media paths. */
8
+ export declare function safeMediaSrc(value: unknown): string | undefined;
9
+ /** Finite-number field: clamp into [min, max], or undefined when not finite. */
10
+ export declare function num(value: unknown, min: number, max: number): number | undefined;
11
+ /** Integer field: clamp into [min, max], or undefined when not a finite number. */
12
+ export declare function int(value: unknown, min: number, max: number): number | undefined;
13
+ /** Optional enum field: the value when it matches, otherwise undefined. */
14
+ export declare function enu<T extends string>(value: unknown, values: readonly T[]): T | undefined;
15
+ /** Plain object (not array, not null). */
16
+ export declare function obj(value: unknown): Record<string, unknown> | undefined;
17
+ /** Preserve an optional field only when its value exists. */
18
+ export declare function opt<K extends string, V>(key: K, value: V | undefined): Partial<Record<K, V>>;
@@ -0,0 +1,144 @@
1
+ /**
2
+ * GenUI spec guard: resource limits, structural validation, and deterministic
3
+ * repair for ```dsh-ui fence specs.
4
+ *
5
+ * The renderer path runs every fence body through `repairGenuiSpec` before
6
+ * rendering, so a pathological or hostile spec — deep nesting, thousands of
7
+ * nodes, oversized strings, out-of-range numbers — degrades gracefully instead
8
+ * of stalling the UI. Repair is deterministic and prefix-stable: a component
9
+ * that survives repair of a partial stream keeps its position when later
10
+ * chunks arrive, so streaming re-renders stay consistent.
11
+ *
12
+ * Policy:
13
+ * - Unknown node `type`s pass through untouched (plugin-registered custom
14
+ * components via `registerGenuiComponent` are opaque to this package).
15
+ * - Known types: required fields must have the right type or the node is
16
+ * dropped; numbers are clamped into range; strings truncated; arrays
17
+ * sliced to their caps; containers recursed with a depth budget.
18
+ * - The whole spec carries a node budget; once exhausted, remaining siblings
19
+ * are elided.
20
+ */
21
+ import type { GenuiSpec } from './spec.ts';
22
+ import type { GenuiDiagnostic } from './genui-runtime/diagnostics.ts';
23
+ /** Result of `validateGenuiSpec`. */
24
+ export interface GenuiValidation {
25
+ ok: boolean;
26
+ /** Human-readable problems, empty when `ok`. */
27
+ errors: string[];
28
+ }
29
+ /**
30
+ * Deterministically repair a raw spec into a renderable GenuiSpec.
31
+ *
32
+ * Alias normalization is performed before the existing resource, type, and
33
+ * security repair rules. The result remains idempotent and keeps the legacy
34
+ * public API used by the fence renderer and client components.
35
+ *
36
+ * @param value - Raw GenUI spec or bare component.
37
+ * @returns Repaired canonical spec, or null for an invalid root.
38
+ */
39
+ export declare function repairGenuiSpec(value: unknown): GenuiSpec | null;
40
+ /**
41
+ * Count the nodes of a spec tree (every item, descending into tabs /
42
+ * accordion / file-tree / list containers — the same descent
43
+ * `validateGenuiSpec` walks). Shared by the panel fold (node-budget gate)
44
+ * and validation, so the panel never runs a second, divergent traversal.
45
+ * `cap` bounds the walk for hostile inputs; the panel passes
46
+ * `PANEL_LIMITS.maxNodes + 1` to detect overflow without counting the whole
47
+ * tree.
48
+ */
49
+ export declare function countGenuiNodes(value: unknown, cap?: number): number;
50
+ /** Every white-listed node `type`. Keep in sync with the repairNode switch —
51
+ * validate_dsh_ui uses it to tell declared GenUI nodes apart from unrelated
52
+ * `"type"` strings (e.g. file-tree's `{type:'file'}` children). */
53
+ export declare const GENUI_NODE_TYPES: ReadonlySet<string>;
54
+ /**
55
+ * Count white-listed nodes declared by a raw spec before repair drops invalid entries.
56
+ * @param value - raw GenUI spec.
57
+ * @param cap - traversal ceiling.
58
+ * @returns declared node count up to the ceiling.
59
+ */
60
+ export declare function countDeclaredGenuiNodes(value: unknown, cap?: number): number;
61
+ /** Count native nodes that survived repair, excluding opaque custom nodes. */
62
+ export declare function countRenderedNativeGenuiNodes(value: unknown, cap?: number): number;
63
+ /**
64
+ * Return field-level chart errors without changing other repairable component families.
65
+ * @param value - raw GenUI spec.
66
+ * @returns chart semantic errors in tree order.
67
+ */
68
+ export declare function validateGenuiChartSemantics(value: unknown): string[];
69
+ /**
70
+ * Validate a raw spec value against the white list and limits, collecting
71
+ * human-readable problems. Unlike repair this never mutates: it is a
72
+ * diagnostic for tests and tooling. Unknown `type`s are reported (a plugin
73
+ * custom type is valid only when a renderer is registered — the guard cannot
74
+ * know, so it flags them as warnings).
75
+ *
76
+ * @param value - 未经过别名转换的 GenUI 文档。
77
+ * @returns 完整结构与字段校验结果。
78
+ */
79
+ export declare function validateCanonicalGenuiSpec(value: unknown): GenuiValidation;
80
+ /**
81
+ * Validate a raw GenUI value after deterministic alias normalization.
82
+ *
83
+ * Validation therefore only sees canonical fields; repairable aliases do not
84
+ * produce false required-field errors. Structural and semantic defects remain
85
+ * errors, while native unknown fields are exposed by the warning diagnostics
86
+ * returned from `processGenuiSpec`.
87
+ *
88
+ * @param value - Raw GenUI spec or bare component.
89
+ * @returns Validation result with human-readable errors.
90
+ */
91
+ export declare function validateGenuiSpec(value: unknown): GenuiValidation;
92
+ export interface GenuiProcessResult {
93
+ /** Canonical alias-normalized input value. */
94
+ value: unknown;
95
+ /** Alias-normalized value, provided as an explicit descriptive alias. */
96
+ normalized: unknown;
97
+ /** Canonical repaired value consumed by the renderer. */
98
+ repaired: GenuiSpec | null;
99
+ /** Renderer-facing alias for `repaired`. */
100
+ spec: GenuiSpec | null;
101
+ /** Structural and semantic validation errors. */
102
+ errors: string[];
103
+ /** Alias and native unknown-field warnings. */
104
+ warnings: GenuiDiagnostic[];
105
+ /** Native nodes declared in the canonical input, before repair drops. */
106
+ declaredCount: number;
107
+ /** Nodes present in the repaired tree. */
108
+ renderedCount: number;
109
+ /** Native nodes declared before repair, excluding custom payloads. */
110
+ declaredNativeCount: number;
111
+ /** Native nodes present after repair, excluding custom and file-tree data. */
112
+ renderedNativeCount: number;
113
+ /** All rendered component nodes, including opaque custom nodes. */
114
+ renderedTotalCount: number;
115
+ }
116
+ /**
117
+ * Run the shared canonical GenUI pipeline.
118
+ *
119
+ * The pipeline normalizes aliases, applies the existing deterministic repair
120
+ * and security filters, validates the canonical input, and reports native
121
+ * declarations that disappeared during repair. Custom nodes stay opaque and
122
+ * do not participate in native unknown-field diagnostics.
123
+ *
124
+ * @param value - Raw GenUI spec or bare component.
125
+ * @returns Canonical input, repaired output, diagnostics, and node counts.
126
+ */
127
+ export declare function processGenuiSpec(value: unknown): GenuiProcessResult;
128
+ /** Return whether the only process errors describe an intentional budget tail cut. */
129
+ export declare function isIntentionalBudgetCut(processed: GenuiProcessResult): boolean;
130
+ /** Decide whether a repaired spec is safe to expose to any GenUI renderer. */
131
+ export declare function isRenderableProcess(processed: GenuiProcessResult): boolean;
132
+ /**
133
+ * Best-effort repair for a spec whose strict validation failed: drop the
134
+ * declared nodes the errors point at and re-run the whole pipeline once.
135
+ *
136
+ * The fence channels call this after the strict gate refuses, so ONE bad
137
+ * component no longer degrades the whole fence to a code block — the
138
+ * behaviour the capability map documents ("坏节点静默丢弃…不会拖垮界面") and
139
+ * that validate_dsh_ui keeps diagnosing for the model. Bounded to a single
140
+ * retry: a second failing pass is a genuinely pathological tree and keeps
141
+ * today's full-fence fallback. Chart semantics stay protected the same way —
142
+ * an undrawable chart is DROPPED here, never repaired into a blank canvas.
143
+ */
144
+ export declare function partialRepairGenuiSpec(processed: GenuiProcessResult): GenuiSpec | null;
@@ -0,0 +1,307 @@
1
+ /**
2
+ * English dictionary — the CANONICAL key set.
3
+ *
4
+ * `GenuiTextKey` derives from this object, so a key added here becomes a
5
+ * compile error in every other dictionary until it is translated. English is
6
+ * also the per-key fallback chain terminus (see runtime.ts).
7
+ *
8
+ * Keys are namespaced by surface: `panel.*`, `tpl.*`, `ach.*`, `label.*`,
9
+ * `block.*`, `err.*`.
10
+ */
11
+ export declare const EN: {
12
+ readonly 'artifact.export': "Export";
13
+ readonly 'artifact.exportHtml': "HTML";
14
+ readonly 'artifact.exportJson': "GenUI JSON";
15
+ readonly 'artifact.exportFailed': "Export failed. Try again.";
16
+ readonly 'artifact.unsupportedCustom': "Cannot export HTML because the standalone runtime cannot render custom components: {types}. Export GenUI JSON to preserve these nodes.";
17
+ readonly 'artifact.externalMediaNotice': "External media may not appear when this file is opened offline.";
18
+ readonly 'panel.badge': "Panel";
19
+ readonly 'panel.title.default': "GenUI panel";
20
+ readonly 'panel.title.explore': "GenUI explorer";
21
+ readonly 'panel.templates': "Templates";
22
+ readonly 'panel.templates.aria': "Template center";
23
+ readonly 'panel.templates.title': "Template center: preview and try GenUI examples";
24
+ readonly 'panel.achievements': "Trophies";
25
+ readonly 'panel.achievements.aria': "Exploration trophies";
26
+ readonly 'panel.achievements.title': "Exploration trophies: badges and progress";
27
+ readonly 'panel.close.aria': "Close panel";
28
+ readonly 'panel.resize.aria': "Resize panel height";
29
+ readonly 'panel.hint': "💡 This is the GenUI session panel — hit “Templates” above to browse runnable examples";
30
+ readonly 'panel.boundary': "panel";
31
+ readonly 'panel.flash.inserted': "Instruction inserted into the composer — send it to generate";
32
+ readonly 'panel.cmd.hint': "Open the GenUI panel; /panel <instruction> to customize; /panel clear to empty";
33
+ readonly 'panel.cmd.description': "Open the GenUI panel (/panel clear empties it; /panel <instruction> tailors the content)";
34
+ readonly 'panel.default.heading': "GenUI generative interface";
35
+ readonly 'panel.default.subtitle': "The panel updates in place: say “update the panel” in chat, or run /panel again to refresh.";
36
+ readonly 'panel.default.stat.components': "Components";
37
+ readonly 'panel.default.stat.single': "Primitives";
38
+ readonly 'panel.default.stat.composite': "Composites";
39
+ readonly 'panel.default.stat.advanced': "Advanced";
40
+ readonly 'panel.default.group.single': "Primitives ×12";
41
+ readonly 'panel.default.group.composite': "Composites ×8";
42
+ readonly 'panel.default.group.data': "Data ×7";
43
+ readonly 'panel.default.group.interactive': "Interactive ×5";
44
+ readonly 'panel.default.group.advanced': "Advanced ×5";
45
+ readonly 'panel.default.group.teaching': "Teaching ×1";
46
+ readonly 'panel.default.callout.title': "How to update";
47
+ readonly 'panel.default.callout.body': "Say “update the panel” in chat → the model emits a panel:true fence; /panel clear empties it.";
48
+ readonly 'tpl.category.all': "All";
49
+ readonly 'tpl.category.dashboard': "Dashboard";
50
+ readonly 'tpl.category.data': "Data";
51
+ readonly 'tpl.category.flow': "Flow";
52
+ readonly 'tpl.category.chart': "Charts";
53
+ readonly 'tpl.category.interactive': "Interactive";
54
+ readonly 'tpl.category.quiz': "Quiz";
55
+ readonly 'tpl.category.advanced': "Advanced";
56
+ readonly 'tpl.categories.aria': "Template categories";
57
+ readonly 'tpl.try': "Try it: insert into composer";
58
+ readonly 'tpl.copy': "Copy instruction";
59
+ readonly 'tpl.copied': "✓ Copied";
60
+ readonly 'tpl.boundary.preview': "template preview";
61
+ readonly 'tpl.boundary.achievements': "trophy page";
62
+ readonly 'tpl.dashboard.name': "Project dashboard";
63
+ readonly 'tpl.dashboard.desc': "Core metrics on one card: numbers, deltas and a progress bar — the decision at a glance.";
64
+ readonly 'tpl.dashboard.instruction': "Use dsh-ui to build a dashboard for this project: 4 key-metric stat cards (with deltas), an overall progress bar, and a list of today’s 3 todos. Title it “Project dashboard”.";
65
+ readonly 'tpl.dashboard.demo.title': "Project dashboard (example)";
66
+ readonly 'tpl.dashboard.demo.metrics': "This week’s key metrics";
67
+ readonly 'tpl.dashboard.demo.done': "Completed";
68
+ readonly 'tpl.dashboard.demo.blocked': "Blocked";
69
+ readonly 'tpl.dashboard.demo.duration': "Avg. cycle time";
70
+ readonly 'tpl.dashboard.demo.coverage': "Coverage";
71
+ readonly 'tpl.dashboard.demo.progress': "Overall progress";
72
+ readonly 'tpl.dashboard.demo.milestone': "v1.0 milestone";
73
+ readonly 'tpl.dashboard.demo.todo': "Today’s todos";
74
+ readonly 'tpl.dashboard.demo.todo1': "Review the M1 template-center PR";
75
+ readonly 'tpl.dashboard.demo.todo2': "Sync vendor to SSiD";
76
+ readonly 'tpl.dashboard.demo.todo3': "Wednesday standup deck";
77
+ readonly 'tpl.compare.name': "Option comparison";
78
+ readonly 'tpl.compare.desc': "Options scored dimension by dimension — the contested cells jump out.";
79
+ readonly 'tpl.compare.instruction': "Use dsh-ui to turn these options into a comparison table: options A/B/C × dimensions (cost / complexity / risk / payoff), marking the recommended column; add a callout at the top stating the conclusion.";
80
+ readonly 'tpl.compare.demo.title': "Option comparison (example)";
81
+ readonly 'tpl.compare.demo.conclusion': "Conclusion";
82
+ readonly 'tpl.compare.demo.body': "Option B wins overall: medium cost, low complexity, low risk.";
83
+ readonly 'tpl.compare.demo.dimension': "Dimension";
84
+ readonly 'tpl.compare.demo.optionA': "Option A";
85
+ readonly 'tpl.compare.demo.optionB': "Option B ★";
86
+ readonly 'tpl.compare.demo.optionC': "Option C";
87
+ readonly 'tpl.compare.demo.cost': "Cost";
88
+ readonly 'tpl.compare.demo.complexity': "Complexity";
89
+ readonly 'tpl.compare.demo.risk': "Risk";
90
+ readonly 'tpl.compare.demo.payoff': "Payoff";
91
+ readonly 'tpl.compare.demo.high': "High";
92
+ readonly 'tpl.compare.demo.medium': "Medium";
93
+ readonly 'tpl.compare.demo.low': "Low";
94
+ readonly 'tpl.compare.demo.large': "Large";
95
+ readonly 'tpl.compare.demo.small': "Small";
96
+ readonly 'tpl.steps.name': "Five-step walkthrough";
97
+ readonly 'tpl.steps.desc': "Key steps on a timeline, one line each — for tutorials, handovers and release runbooks.";
98
+ readonly 'tpl.steps.instruction': "Use dsh-ui to turn the procedure into a steps walkthrough: 5 steps following the real flow, each with a title and a line or two of detail, with a badge at the top showing the expected duration.";
99
+ readonly 'tpl.steps.demo.title': "Getting started (example)";
100
+ readonly 'tpl.steps.demo.badge': "About 5 minutes";
101
+ readonly 'tpl.steps.demo.s1': "Install the plugin";
102
+ readonly 'tpl.steps.demo.s1desc': "From the plugin center, or npm-install it into your profile";
103
+ readonly 'tpl.steps.demo.s2': "Send your first instruction";
104
+ readonly 'tpl.steps.demo.s2desc': "Ask the model to answer with a dsh-ui interface";
105
+ readonly 'tpl.steps.demo.s3': "Try the interaction";
106
+ readonly 'tpl.steps.demo.s3desc': "Click a button, grade a quiz, switch a tab — actions travel back to the model";
107
+ readonly 'tpl.steps.demo.s4': "Pin a panel";
108
+ readonly 'tpl.steps.demo.s4desc': "The model uses panel:true to pin results to the session panel";
109
+ readonly 'tpl.steps.demo.s5': "Advanced components";
110
+ readonly 'tpl.steps.demo.s5desc': "Charts, diagrams and 3D load lazily, on demand";
111
+ readonly 'tpl.quiz.name': "Pop quiz";
112
+ readonly 'tpl.quiz.desc': "Graded the moment you answer: right or wrong plus an explanation — good for training.";
113
+ readonly 'tpl.quiz.instruction': "Use dsh-ui to write 3 pop-quiz questions (quiz component: question + options, exactly one correct, each with an explanation), titled “Pop quiz”, graded as soon as an option is picked.";
114
+ readonly 'tpl.quiz.demo.title': "Pop quiz (example)";
115
+ readonly 'tpl.quiz.demo.hint': "Picking an option grades it instantly and reveals the explanation.";
116
+ readonly 'tpl.quiz.demo.q1': "What is the smallest unit of a DSH plugin?";
117
+ readonly 'tpl.quiz.demo.q1a': "A service";
118
+ readonly 'tpl.quiz.demo.q1b': "A plugin (a cordis plugin)";
119
+ readonly 'tpl.quiz.demo.q1bfx': "✓ Everything is a plugin: services, tools and UI all register through one.";
120
+ readonly 'tpl.quiz.demo.q1c': "A tool";
121
+ readonly 'tpl.quiz.demo.q1exp': "DSH is built on cordis: every capability, services and tools included, registers as a plugin.";
122
+ readonly 'tpl.quiz.demo.q2': "Who emits a dsh-ui fence?";
123
+ readonly 'tpl.quiz.demo.q2a': "The user";
124
+ readonly 'tpl.quiz.demo.q2b': "The model";
125
+ readonly 'tpl.quiz.demo.q2bfx': "✓ The model writes the dsh-ui fence into its reply.";
126
+ readonly 'tpl.quiz.demo.q2c': "The host";
127
+ readonly 'tpl.quiz.demo.q2exp': "The model emits the fence; the renderer paints it into real components.";
128
+ readonly 'tpl.quiz.demo.q3': "Where does a panel:true fence render?";
129
+ readonly 'tpl.quiz.demo.q3a': "The message flow";
130
+ readonly 'tpl.quiz.demo.q3b': "The session panel dock";
131
+ readonly 'tpl.quiz.demo.q3bfx': "✓ Panel updates never spam the transcript.";
132
+ readonly 'tpl.quiz.demo.q3c': "The settings page";
133
+ readonly 'tpl.stats.name': "Key figures + progress";
134
+ readonly 'tpl.stats.desc': "Numbers, progress and milestones in one delivery — the standard weekly report.";
135
+ readonly 'tpl.stats.instruction': "Use dsh-ui to summarize this week: a keyvalue block with 3 key figures, two progress bars (planned vs actual), and a timeline with 3 milestones. Title it “Weekly snapshot”.";
136
+ readonly 'tpl.stats.demo.title': "Weekly snapshot (example)";
137
+ readonly 'tpl.stats.demo.done': "Completed";
138
+ readonly 'tpl.stats.demo.late': "Late";
139
+ readonly 'tpl.stats.demo.risk': "Risks";
140
+ readonly 'tpl.stats.demo.riskValue': "2 (both mitigated)";
141
+ readonly 'tpl.stats.demo.planned': "Planned progress";
142
+ readonly 'tpl.stats.demo.actual': "Actual progress";
143
+ readonly 'tpl.stats.demo.mon': "Monday";
144
+ readonly 'tpl.stats.demo.monDesc': "M1 development complete";
145
+ readonly 'tpl.stats.demo.wed': "Wednesday";
146
+ readonly 'tpl.stats.demo.wedDesc': "End-to-end verification passed";
147
+ readonly 'tpl.stats.demo.fri': "Friday";
148
+ readonly 'tpl.stats.demo.friDesc': "Shipped 0.9.4";
149
+ readonly 'tpl.chart.name': "Trend chart";
150
+ readonly 'tpl.chart.desc': "Data drawn straight into a chart — multiple series, trend visible at a glance.";
151
+ readonly 'tpl.chart.instruction': "Use dsh-ui to plot this data as a chart (bars, multi-series): completed vs planned over the last 6 weeks, with a one-line trend conclusion above the chart.";
152
+ readonly 'tpl.chart.demo.title': "Trend comparison (example)";
153
+ readonly 'tpl.chart.demo.conclusion': "Conclusion: completions rose 3 weeks running and overtook plan for the first time this week.";
154
+ readonly 'tpl.tabs.name': "Tabbed sections";
155
+ readonly 'tpl.tabs.desc': "A big block split into tabs: clear anchors, an uncluttered panel, no transcript spam.";
156
+ readonly 'tpl.tabs.instruction': "Use dsh-ui to split the content into three tabs: Overview / Details / FAQ, at most 3 points per tab. Title it “Feature tour”.";
157
+ readonly 'tpl.tabs.demo.title': "Feature tour (example)";
158
+ readonly 'tpl.tabs.demo.overview': "Overview";
159
+ readonly 'tpl.tabs.demo.overviewBody': "Three capabilities: live rendering, action round-trips, and a persistent panel.";
160
+ readonly 'tpl.tabs.demo.details': "Details";
161
+ readonly 'tpl.tabs.demo.d1': "Rendering: incremental fence parsing, painted as it streams";
162
+ readonly 'tpl.tabs.demo.d2': "Interaction: actions travel back and the model updates in place";
163
+ readonly 'tpl.tabs.demo.d3': "Panel: a session-level dock you can collapse and resize";
164
+ readonly 'tpl.tabs.demo.faqBody': "Q: What if the model never replies? A: Components still grade and expand locally.";
165
+ readonly 'tpl.checklist.name': "Release checklist";
166
+ readonly 'tpl.checklist.desc': "Tick every box before you ship: the list is the process, and gaps are visible.";
167
+ readonly 'tpl.checklist.instruction': "Use dsh-ui to build a release checklist: 6 tickable checkbox items (tests / docs / release / rollback / monitoring / announcement), with a badge at the top reading “Tick everything before merging”.";
168
+ readonly 'tpl.checklist.demo.title': "Release checklist (example)";
169
+ readonly 'tpl.checklist.demo.badge': "Tick everything before merging";
170
+ readonly 'tpl.checklist.demo.c1': "Unit tests pass";
171
+ readonly 'tpl.checklist.demo.c2': "Docs updated";
172
+ readonly 'tpl.checklist.demo.c3': "Release bundle ready";
173
+ readonly 'tpl.checklist.demo.c4': "Rollback plan";
174
+ readonly 'tpl.accordion.name': "FAQ accordion";
175
+ readonly 'tpl.accordion.desc': "Questions and answers folded away: long documents get short and answers stop intimidating.";
176
+ readonly 'tpl.accordion.instruction': "Use dsh-ui to build an FAQ accordion: 5 common questions, the question as the header and the answer inside, with the first one expanded by default.";
177
+ readonly 'tpl.accordion.demo.title': "FAQ (example)";
178
+ readonly 'tpl.accordion.demo.q1': "Which chart types are supported?";
179
+ readonly 'tpl.accordion.demo.a1': "chart (bars/line/donut), plot for function graphs, and echart for the full chart library.";
180
+ readonly 'tpl.accordion.demo.q2': "Does the panel persist?";
181
+ readonly 'tpl.accordion.demo.a2': "The same content fingerprint restores its state across refresh and replay; new content resets.";
182
+ readonly 'tpl.accordion.demo.q3': "Do interactions disturb the model?";
183
+ readonly 'tpl.accordion.demo.a3': "Only components carrying an action send anything; pure display costs zero round-trips.";
184
+ readonly 'tpl.diagram.name': "System architecture";
185
+ readonly 'tpl.diagram.desc': "Architecture drawn as SVG: layered nodes, real edges, labelled zones — clearer than a screenshot.";
186
+ readonly 'tpl.diagram.instruction': "Use dsh-ui to draw an architecture diagram: 5 nodes of this system and their connections (kind: architecture or flowchart), including one security zone.";
187
+ readonly 'tpl.diagram.demo.title': "Architecture (example)";
188
+ readonly 'tpl.diagram.demo.caption': "DSH plugin path";
189
+ readonly 'tpl.diagram.demo.model': "Model";
190
+ readonly 'tpl.diagram.demo.plugin': "Plugin";
191
+ readonly 'tpl.diagram.demo.host': "Host";
192
+ readonly 'tpl.3d.name': "3D scene";
193
+ readonly 'tpl.3d.desc': "A rotatable 3D scene — for product demos and spatial explanations.";
194
+ readonly 'tpl.3d.instruction': "Use dsh-ui to render a 3D scene (scene3d): a cube and a sphere, titled “Example scene”, with a sentence on when to use it.";
195
+ readonly 'tpl.3d.demo.title': "3D scene (example)";
196
+ readonly 'tpl.3d.demo.note': "The first load downloads three.js (~700KB, lazily); afterwards it comes from cache.";
197
+ readonly 'tpl.3d.demo.scene': "Example scene";
198
+ readonly 'tpl.breadcrumb.name': "Path breadcrumb";
199
+ readonly 'tpl.breadcrumb.desc': "Long paths as breadcrumbs: file location and org hierarchy read instantly.";
200
+ readonly 'tpl.breadcrumb.instruction': "Use dsh-ui to show the current workspace layout: a breadcrumb for the file path (4 segments) and a file-tree of the project (3 directories, 2 children each).";
201
+ readonly 'tpl.breadcrumb.demo.title': "Directory layout (example)";
202
+ readonly 'tpl.breadcrumb.demo.workspace': "Workspace";
203
+ readonly 'ach.page.title': "GenUI exploration trophies";
204
+ readonly 'ach.stat.unlocked': "Unlocked";
205
+ readonly 'ach.stat.rendered': "Interfaces rendered";
206
+ readonly 'ach.stat.interactions': "Interactions";
207
+ readonly 'ach.progress': "Exploration progress";
208
+ readonly 'ach.rarity.common': "Common";
209
+ readonly 'ach.rarity.rare': "Rare";
210
+ readonly 'ach.rarity.legendary': "Legendary";
211
+ readonly 'ach.hidden.name': "?";
212
+ readonly 'ach.hidden.desc': "Keep exploring to reveal";
213
+ readonly 'ach.toast.unlocked': "Trophy unlocked: {name}";
214
+ readonly 'ach.first-fence.name': "First contact";
215
+ readonly 'ach.first-fence.desc': "Rendered your first GenUI interface.";
216
+ readonly 'ach.fence-5.name': "Getting the hang of it";
217
+ readonly 'ach.fence-5.desc': "Rendered 5 interfaces.";
218
+ readonly 'ach.fence-25.name': "Interface weaver";
219
+ readonly 'ach.fence-25.desc': "Rendered 25 interfaces.";
220
+ readonly 'ach.fence-50.name': "Soul of the blueprint";
221
+ readonly 'ach.fence-50.desc': "Rendered 50 interfaces — you and GenUI go way back.";
222
+ readonly 'ach.first-interaction.name': "The button works";
223
+ readonly 'ach.first-interaction.desc': "Triggered a component interaction for the first time.";
224
+ readonly 'ach.interaction-10.name': "Little puppeteer";
225
+ readonly 'ach.interaction-10.desc': "Triggered 10 component interactions.";
226
+ readonly 'ach.first-panel.name': "Pinned to the wall";
227
+ readonly 'ach.first-panel.desc': "Pinned content to the session panel for the first time.";
228
+ readonly 'ach.panel-5.name': "Panel keeper";
229
+ readonly 'ach.panel-5.desc': "Used the panel in 5 different sessions.";
230
+ readonly 'ach.first-chart.name': "Chart enthusiast";
231
+ readonly 'ach.first-chart.desc': "Rendered your first chart (chart/plot/echart).";
232
+ readonly 'ach.chart-10.name': "Data visualizer";
233
+ readonly 'ach.chart-10.desc': "Charts appeared in 10 interfaces.";
234
+ readonly 'ach.first-advanced.name': "Power user";
235
+ readonly 'ach.first-advanced.desc': "Used 3D, a chart engine, or an architecture diagram.";
236
+ readonly 'ach.template-1.name': "Template student";
237
+ readonly 'ach.template-1.desc': "Tried a template from the template center.";
238
+ readonly 'label.copy': "Copy";
239
+ /** CodeBlock's post-copy button label. */
240
+ readonly 'label.copied': "Copied";
241
+ /** Bare "done" state used by JsonTree and the table copy chips. */
242
+ readonly 'label.copiedDone': "Copied";
243
+ /** Inline chip with its check mark. */
244
+ readonly 'label.copiedShort': "✓ Copied";
245
+ readonly 'label.copiedToClipboard': "Copied to clipboard";
246
+ readonly 'label.copyFailed': "Copy failed";
247
+ readonly 'label.code': "Code";
248
+ readonly 'label.wrap': "Wrap lines";
249
+ readonly 'label.unwrap': "Unwrap lines";
250
+ readonly 'label.collapse': "Collapse";
251
+ readonly 'label.collapseDiff.aria': "Collapse diff";
252
+ readonly 'label.expandDiff.aria': "Show the remaining {hidden} diff lines";
253
+ readonly 'label.expandDiff': "… {hidden} more lines";
254
+ readonly 'label.diffFiles': "{count} files";
255
+ readonly 'label.copyValue': "Copy value";
256
+ readonly 'label.copyJson': "Copy JSON";
257
+ readonly 'label.copyPath': "Copy property path";
258
+ readonly 'label.copyPrettyJson': "Copy formatted JSON";
259
+ readonly 'label.copyCompactJson': "Copy compact JSON";
260
+ readonly 'label.collapseNode': "Collapse JSON node";
261
+ readonly 'label.expandNode': "Expand JSON node";
262
+ readonly 'label.copyButtonTitle': "{action}; right-click for copy options";
263
+ readonly 'block.copyMarkdown': "Copy Markdown";
264
+ readonly 'block.copyCsv': "Copy CSV";
265
+ readonly 'block.total': "Total";
266
+ readonly 'block.filteredRows': "{visible} / {total} rows after filtering";
267
+ readonly 'block.filterMatch': "{shown} / {total} matched";
268
+ readonly 'block.triggered': "✓ Sent";
269
+ readonly 'block.triggeredPlain': "Sent";
270
+ readonly 'block.audio': "Audio";
271
+ readonly 'block.audioError': "Audio cannot be played";
272
+ readonly 'block.video': "Video";
273
+ readonly 'block.videoError': "Video cannot be played";
274
+ readonly 'block.image': "Image";
275
+ readonly 'block.imageError': "Image failed to load";
276
+ readonly 'block.svgLabel': "SVG diagram";
277
+ readonly 'block.svgPreview': "Preview";
278
+ readonly 'block.svgSource': "Source";
279
+ readonly 'block.svgError': "SVG could not be displayed — showing the source instead";
280
+ readonly 'block.mermaidError': "Invalid diagram syntax — showing the source instead";
281
+ readonly 'block.mermaidLoading': "Rendering…";
282
+ readonly 'block.scene3dLoading': "Loading 3D scene…";
283
+ readonly 'block.scene3dError': "3D rendering failed";
284
+ readonly 'block.quizCorrect': "✓ Correct!";
285
+ readonly 'block.quizWrong': "✗ Try again";
286
+ readonly 'block.quizRetry': "Start over";
287
+ readonly 'block.selectPlaceholder': "Choose…";
288
+ readonly 'block.score': "Score";
289
+ readonly 'block.scoreUngraded': " ({count} unanswered, not scored)";
290
+ readonly 'block.yourAnswer': "Your answer:";
291
+ readonly 'block.correctAnswer': " Correct answer:";
292
+ readonly 'block.selectedCount': "{answered}/{total} answered";
293
+ readonly 'block.target': "Target {value}%";
294
+ readonly 'block.chart.barsAria': "Horizontal bar chart, {count} groups";
295
+ readonly 'block.chart.barsSummary': "Bar chart, {count} groups, max {max}";
296
+ readonly 'block.chart.lineSeries': "Line chart, {count} series, range {min} to {max}";
297
+ readonly 'block.chart.linePoints': "Line chart, {count} points, range {min} to {max}";
298
+ readonly 'block.chart.donutSummary': "Donut chart, {count} slices, total {total}";
299
+ readonly 'block.chart.node': "Point";
300
+ readonly 'err.boundary.generic': "this interface";
301
+ readonly 'err.boundary.fence': "this interface";
302
+ readonly 'err.boundary.body': "⚠️ {label} failed to render (isolated — the rest of the reply is unaffected)";
303
+ readonly 'err.fieldValidation': "GenUI field validation failed: {errors}";
304
+ readonly 'err.chartValidation': "chart field validation failed: {errors}";
305
+ readonly 'err.fenceKeptAsCode': "⚠️ dsh-ui {diagnostic} — the fence stays a code block; fix it and resend.";
306
+ readonly 'err.fenceParse': "⚠️ dsh-ui fence JSON failed to parse{diagnostic} — the fence stays a code block; ask the model to fix the JSON and resend.";
307
+ };
@@ -0,0 +1,44 @@
1
+ import { t, type LocaleId } from './runtime.ts';
2
+ export { detectLocale, dictOf, FALLBACK_LOCALE, getLocale, getLocaleRevision, LOCALE_IDS, normalizeLocale, setLocale, subscribeLocale, t, type GenuiTextKey, type LocaleDict, type LocaleId, } from './runtime.ts';
3
+ /**
4
+ * Subscribe a component to locale changes.
5
+ *
6
+ * Returns the translate function itself (stable identity — `t` reads the
7
+ * active locale at call time), so a component calls `const t = useT()` and
8
+ * re-renders whenever the language switches.
9
+ */
10
+ export declare function useT(): typeof t;
11
+ /**
12
+ * Subscribe to locale changes and return the current revision.
13
+ *
14
+ * `t` keeps a STABLE identity on purpose (so it can ride inject surfaces
15
+ * without breaking memoization), which means it cannot serve as a `useMemo`
16
+ * dependency. Use this revision instead when a memoized value embeds
17
+ * translated text.
18
+ */
19
+ export declare function useLocaleRevision(): number;
20
+ /** Namespace this package registers its dictionaries under on the host. */
21
+ export declare const GENUI_LOCALE_NS = "genui";
22
+ /**
23
+ * Bridge this package's locale to the DSH host language preference.
24
+ *
25
+ * Hosts that ship `@deepseek-ai/dsh-client-locale` own the user's language
26
+ * choice; GenUI must follow it rather than keep a second, divergent setting.
27
+ * The bridge:
28
+ * - publishes both dictionaries into the host registry (so host-side
29
+ * surfaces can read GenUI keys), and
30
+ * - mirrors the host's active locale into this runtime, now and on change.
31
+ *
32
+ * Hosts WITHOUT the locale service degrade silently to browser detection —
33
+ * the service is read optionally, never declared in `inject`, because a
34
+ * declared-but-absent service parks the fiber forever and would kill all
35
+ * GenUI rendering on pristine hosts.
36
+ *
37
+ * @param ctx - client cordis context (read optionally).
38
+ * @returns disposer removing the registrations and the subscription.
39
+ */
40
+ export declare function bridgeHostLocale(ctx: {
41
+ get?: (name: string) => unknown;
42
+ }): () => void;
43
+ /** Current locale id, for non-React call sites. */
44
+ export declare function currentLocale(): LocaleId;