@sparkelf/dsh-genui 0.0.0-stage → 0.11.4-patch.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +597 -0
- package/LICENSE +21 -0
- package/README.md +292 -2
- package/README.zh-CN.md +307 -0
- package/SKILL.md +261 -0
- package/cordis.patch.yml +9 -0
- package/demo-prompts.md +118 -0
- package/lib/assets/echarts-core.js +43 -0
- package/lib/assets/echarts-full.js +72 -0
- package/lib/assets/mermaid.js +3591 -0
- package/lib/assets/standalone-runtime.js +1506 -0
- package/lib/assets/three.js +3844 -0
- package/lib/client.js +405 -0
- package/lib/index.js +5187 -0
- package/lib/invariant.js +19 -0
- package/lib/types/client/EChartNode.d.ts +13 -0
- package/lib/types/client/ErrorBoundary.d.ts +30 -0
- package/lib/types/client/GenuiBlock.d.ts +9 -0
- package/lib/types/client/PlotBlock.d.ts +44 -0
- package/lib/types/client/TemplateDrawer.d.ts +7 -0
- package/lib/types/client/achievement-store.d.ts +35 -0
- package/lib/types/client/achievement-toast.d.ts +2 -0
- package/lib/types/client/achievements.d.ts +63 -0
- package/lib/types/client/action-context.d.ts +7 -0
- package/lib/types/client/artifact/ExportableGenuiBlock.d.ts +6 -0
- package/lib/types/client/artifact/create.d.ts +5 -0
- package/lib/types/client/artifact/download.d.ts +9 -0
- package/lib/types/client/artifact/html.d.ts +5 -0
- package/lib/types/client/artifact/index.d.ts +8 -0
- package/lib/types/client/artifact/json.d.ts +3 -0
- package/lib/types/client/artifact/parse.d.ts +3 -0
- package/lib/types/client/artifact/portability.d.ts +4 -0
- package/lib/types/client/artifact/standalone-theme.d.ts +2 -0
- package/lib/types/client/artifact/types.d.ts +33 -0
- package/lib/types/client/asset-echarts-core.d.ts +1 -0
- package/lib/types/client/asset-echarts.d.ts +17 -0
- package/lib/types/client/asset-loader.d.ts +33 -0
- package/lib/types/client/asset-mermaid.d.ts +1 -0
- package/lib/types/client/asset-three.d.ts +1 -0
- package/lib/types/client/blocks/advanced.d.ts +101 -0
- package/lib/types/client/blocks/basic.d.ts +22 -0
- package/lib/types/client/blocks/charts.d.ts +53 -0
- package/lib/types/client/blocks/checkbox.d.ts +17 -0
- package/lib/types/client/blocks/diagram/geometry.d.ts +73 -0
- package/lib/types/client/blocks/diagram/index.d.ts +5 -0
- package/lib/types/client/blocks/diagram/layout.d.ts +41 -0
- package/lib/types/client/blocks/diagram/theme.d.ts +37 -0
- package/lib/types/client/blocks/forms.d.ts +77 -0
- package/lib/types/client/blocks/image.d.ts +6 -0
- package/lib/types/client/blocks/render-node.d.ts +10 -0
- package/lib/types/client/blocks/state.d.ts +63 -0
- package/lib/types/client/blocks/svg.d.ts +4 -0
- package/lib/types/client/dom-fence.d.ts +30 -0
- package/lib/types/client/echarts-engine.d.ts +4 -0
- package/lib/types/client/echarts-lazy.d.ts +18 -0
- package/lib/types/client/embed.d.ts +10 -0
- package/lib/types/client/fence-render.d.ts +106 -0
- package/lib/types/client/gallery.d.ts +7 -0
- package/lib/types/client/genui-runtime/diagnostics.d.ts +18 -0
- package/lib/types/client/genui-runtime/index.d.ts +1 -0
- package/lib/types/client/genui-runtime/limits.d.ts +54 -0
- package/lib/types/client/genui-runtime/normalize.d.ts +15 -0
- package/lib/types/client/genui-runtime/schema.d.ts +87 -0
- package/lib/types/client/genui-runtime/value-utils.d.ts +18 -0
- package/lib/types/client/guard.d.ts +144 -0
- package/lib/types/client/i18n/en.d.ts +307 -0
- package/lib/types/client/i18n/index.d.ts +44 -0
- package/lib/types/client/i18n/runtime.d.ts +64 -0
- package/lib/types/client/i18n/zh.d.ts +8 -0
- package/lib/types/client/index.d.ts +36 -0
- package/lib/types/client/inline.d.ts +5 -0
- package/lib/types/client/interaction-store.d.ts +48 -0
- package/lib/types/client/mermaid-core.d.ts +8 -0
- package/lib/types/client/mermaid-lazy.d.ts +9 -0
- package/lib/types/client/mermaid-safe.d.ts +52 -0
- package/lib/types/client/panel-command.d.ts +34 -0
- package/lib/types/client/panel-store.d.ts +94 -0
- package/lib/types/client/panel.d.ts +18 -0
- package/lib/types/client/parse-partial.d.ts +63 -0
- package/lib/types/client/primitive-adapter.d.ts +4 -0
- package/lib/types/client/primitive-labels.d.ts +18 -0
- package/lib/types/client/safe-math.d.ts +43 -0
- package/lib/types/client/scene3d-core.d.ts +21 -0
- package/lib/types/client/scene3d-lazy.d.ts +8 -0
- package/lib/types/client/session-resolver.d.ts +8 -0
- package/lib/types/client/source-fence.d.ts +29 -0
- package/lib/types/client/spec.d.ts +709 -0
- package/lib/types/client/standalone/asset-loader.d.ts +2 -0
- package/lib/types/client/standalone/bootstrap-types.d.ts +9 -0
- package/lib/types/client/standalone/katex-style.d.ts +1 -0
- package/lib/types/client/standalone/primitive-adapter.d.ts +54 -0
- package/lib/types/client/standalone/runtime.d.ts +2 -0
- package/lib/types/client/submission-registry.d.ts +51 -0
- package/lib/types/client/svg-fence.d.ts +2 -0
- package/lib/types/client/table-details.d.ts +20 -0
- package/lib/types/client/templates.d.ts +41 -0
- package/lib/types/client/toolview.d.ts +7 -0
- package/lib/types/client/walk-spec.d.ts +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/plugin/chart-contract.d.ts +9 -0
- package/lib/types/plugin/fence-feedback.d.ts +151 -0
- package/lib/types/plugin/genui-diagnostic.d.ts +13 -0
- package/lib/types/plugin/index.d.ts +35 -0
- package/lib/types/plugin/inline-content-diagnostic.d.ts +8 -0
- package/lib/types/plugin/invariant.d.ts +15 -0
- package/lib/types/plugin/tool.d.ts +27 -0
- package/lib/types/shared/fence-repair.d.ts +78 -0
- package/lib/types/shared/fence-resolve.d.ts +39 -0
- package/package.json +249 -4
- package/src/client/EChartNode.tsx +466 -0
- package/src/client/ErrorBoundary.tsx +67 -0
- package/src/client/GenuiBlock.module.css +2221 -0
- package/src/client/GenuiBlock.tsx +235 -0
- package/src/client/PlotBlock.module.css +171 -0
- package/src/client/PlotBlock.tsx +492 -0
- package/src/client/TemplateDrawer.module.css +152 -0
- package/src/client/TemplateDrawer.tsx +147 -0
- package/src/client/achievement-store.ts +151 -0
- package/src/client/achievement-toast.tsx +71 -0
- package/src/client/achievements.ts +160 -0
- package/src/client/action-context.ts +32 -0
- package/src/client/artifact/ArtifactExport.module.css +64 -0
- package/src/client/artifact/ExportableGenuiBlock.tsx +100 -0
- package/src/client/artifact/create.ts +69 -0
- package/src/client/artifact/download.ts +42 -0
- package/src/client/artifact/html.ts +157 -0
- package/src/client/artifact/index.ts +15 -0
- package/src/client/artifact/json.ts +6 -0
- package/src/client/artifact/parse.ts +32 -0
- package/src/client/artifact/portability.ts +47 -0
- package/src/client/artifact/standalone-theme.ts +94 -0
- package/src/client/artifact/types.ts +44 -0
- package/src/client/asset-echarts-core.ts +39 -0
- package/src/client/asset-echarts.ts +27 -0
- package/src/client/asset-loader.ts +96 -0
- package/src/client/asset-mermaid.ts +13 -0
- package/src/client/asset-three.ts +12 -0
- package/src/client/blocks/advanced.tsx +537 -0
- package/src/client/blocks/basic.tsx +121 -0
- package/src/client/blocks/charts.tsx +999 -0
- package/src/client/blocks/checkbox.tsx +61 -0
- package/src/client/blocks/diagram/geometry.ts +151 -0
- package/src/client/blocks/diagram/index.tsx +293 -0
- package/src/client/blocks/diagram/layout.ts +202 -0
- package/src/client/blocks/diagram/theme.ts +127 -0
- package/src/client/blocks/forms.tsx +531 -0
- package/src/client/blocks/image.tsx +28 -0
- package/src/client/blocks/render-node.tsx +494 -0
- package/src/client/blocks/state.ts +65 -0
- package/src/client/blocks/svg.tsx +66 -0
- package/src/client/dom-fence.tsx +1123 -0
- package/src/client/echarts-engine.ts +9 -0
- package/src/client/echarts-lazy.ts +41 -0
- package/src/client/embed.ts +19 -0
- package/src/client/fence-render.tsx +266 -0
- package/src/client/gallery.ts +215 -0
- package/src/client/genui-runtime/diagnostics.ts +165 -0
- package/src/client/genui-runtime/index.ts +1 -0
- package/src/client/genui-runtime/limits.ts +54 -0
- package/src/client/genui-runtime/normalize.ts +329 -0
- package/src/client/genui-runtime/schema.ts +352 -0
- package/src/client/genui-runtime/value-utils.ts +67 -0
- package/src/client/guard.ts +1965 -0
- package/src/client/i18n/en.ts +335 -0
- package/src/client/i18n/index.ts +125 -0
- package/src/client/i18n/runtime.ts +130 -0
- package/src/client/i18n/zh.ts +330 -0
- package/src/client/index.tsx +228 -0
- package/src/client/inline.ts +106 -0
- package/src/client/interaction-store.ts +127 -0
- package/src/client/mermaid-core.ts +158 -0
- package/src/client/mermaid-lazy.ts +31 -0
- package/src/client/mermaid-safe.ts +122 -0
- package/src/client/panel-command.ts +138 -0
- package/src/client/panel-store.ts +471 -0
- package/src/client/panel.tsx +287 -0
- package/src/client/parse-partial.ts +170 -0
- package/src/client/primitive-adapter.ts +13 -0
- package/src/client/primitive-labels.ts +55 -0
- package/src/client/safe-math.ts +298 -0
- package/src/client/scene3d-core.ts +195 -0
- package/src/client/scene3d-lazy.ts +26 -0
- package/src/client/session-resolver.ts +33 -0
- package/src/client/source-fence.ts +70 -0
- package/src/client/spec.ts +896 -0
- package/src/client/standalone/asset-loader.ts +9 -0
- package/src/client/standalone/bootstrap-types.ts +11 -0
- package/src/client/standalone/katex-style.ts +1 -0
- package/src/client/standalone/primitive-adapter.tsx +94 -0
- package/src/client/standalone/runtime.tsx +27 -0
- package/src/client/submission-registry.ts +150 -0
- package/src/client/svg-fence.tsx +39 -0
- package/src/client/table-details.ts +151 -0
- package/src/client/templates.ts +322 -0
- package/src/client/toolview.tsx +67 -0
- package/src/client/walk-spec.ts +43 -0
- package/src/css-modules.d.ts +5 -0
- package/src/index.ts +9 -0
- package/src/plugin/chart-contract.ts +13 -0
- package/src/plugin/fence-feedback.ts +655 -0
- package/src/plugin/genui-diagnostic.ts +112 -0
- package/src/plugin/index.ts +224 -0
- package/src/plugin/inline-content-diagnostic.ts +178 -0
- package/src/plugin/invariant.ts +30 -0
- package/src/plugin/node-shims.d.ts +31 -0
- package/src/plugin/tool.ts +424 -0
- package/src/shared/fence-repair.ts +536 -0
- package/src/shared/fence-resolve.ts +80 -0
- package/tsconfig.json +35 -0
- package/tsdown.config.ts +275 -0
|
@@ -0,0 +1,27 @@
|
|
|
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 { init as echartsInit, type EChartsType, type EChartsCoreOption } from 'echarts'
|
|
10
|
+
import 'echarts-wordcloud'
|
|
11
|
+
|
|
12
|
+
/** The engine surface registered by the echarts asset bundle. */
|
|
13
|
+
export interface EChartsAssetApi {
|
|
14
|
+
/** Create an ECharts instance on `el`, apply `option`, return the instance. */
|
|
15
|
+
createChart: (el: HTMLElement, option: EChartsCoreOption, opts?: { height?: number }) => EChartsType
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function createChart(el: HTMLElement, option: EChartsCoreOption, opts?: { height?: number }): EChartsType {
|
|
19
|
+
const initOpts = opts !== undefined && opts.height !== undefined ? { height: opts.height } : undefined
|
|
20
|
+
const instance = echartsInit(el, undefined, initOpts)
|
|
21
|
+
instance.setOption(option)
|
|
22
|
+
return instance
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const win = globalThis as unknown as { __GenuiAssets__?: Record<string, unknown> }
|
|
26
|
+
const assets = win.__GenuiAssets__ ?? (win.__GenuiAssets__ = {})
|
|
27
|
+
assets.echartsFull = { createChart }
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
|
|
21
|
+
/** The plugin's entry id — mirrors the loader entry name (package name). */
|
|
22
|
+
const PLUGIN_ID = '@changfenhuang/dsh-genui'
|
|
23
|
+
|
|
24
|
+
/** Assets directory served by the node-half route. */
|
|
25
|
+
const ASSET_DIR = `/plugins/${PLUGIN_ID}/assets`
|
|
26
|
+
let embeddedAssetBase: string | undefined
|
|
27
|
+
|
|
28
|
+
/** Set once before rendering when the host bundles engines locally. */
|
|
29
|
+
export function setGenuiAssetBase(baseURL: string): void {
|
|
30
|
+
embeddedAssetBase = new URL(baseURL, document.baseURI).href.replace(/\/?$/, '/')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Boot graph shape read from `window.__DSH_BOOT__` (subset, defensive). */
|
|
34
|
+
interface BootGraphLike {
|
|
35
|
+
entries?: Array<{ id?: string; rev?: string }>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The global the asset bundles register their engines on. */
|
|
39
|
+
interface AssetGlobal {
|
|
40
|
+
__GenuiAssets__?: Record<string, unknown>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Resolve an engine API registered by an inline standalone bundle. */
|
|
44
|
+
function preloadedAsset(name: string): unknown {
|
|
45
|
+
const key = name.replace(/-(\w)/g, (_match, char: string) => char.toUpperCase())
|
|
46
|
+
return (window as unknown as AssetGlobal).__GenuiAssets__?.[key]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Resolve an asset URL, appending the bundle rev for cache busting when the
|
|
50
|
+
* boot graph exposes it. */
|
|
51
|
+
export function assetUrl(file: string): string {
|
|
52
|
+
if (embeddedAssetBase !== undefined) return new URL(file, embeddedAssetBase).href
|
|
53
|
+
const graph = (window as unknown as { __DSH_BOOT__?: BootGraphLike }).__DSH_BOOT__
|
|
54
|
+
const rev = graph?.entries?.find(entry => entry.id === PLUGIN_ID)?.rev
|
|
55
|
+
return `${ASSET_DIR}/${file}${rev === undefined ? '' : `?rev=${rev}`}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const pending = new Map<string, Promise<Record<string, unknown>>>()
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Load one asset bundle and return the engines it registered. Memoized per
|
|
62
|
+
* file: repeated requests (several mermaid nodes, re-renders) share one
|
|
63
|
+
* script load; a failed load stays failed for the page (the component shows
|
|
64
|
+
* its fallback).
|
|
65
|
+
* @param name - 'mermaid', 'three', 'echarts-core', or 'echarts-full'.
|
|
66
|
+
* @returns the registered engine surface.
|
|
67
|
+
*/
|
|
68
|
+
export function loadGenuiAsset<T>(name: 'mermaid' | 'three' | 'echarts-core' | 'echarts-full'): Promise<T> {
|
|
69
|
+
const preloaded = preloadedAsset(name)
|
|
70
|
+
if (preloaded !== undefined) return Promise.resolve(preloaded as T)
|
|
71
|
+
const file = `${name}.js`
|
|
72
|
+
const existing = pending.get(file)
|
|
73
|
+
if (existing !== undefined) return existing as Promise<T>
|
|
74
|
+
const task = new Promise<T>((resolve, reject) => {
|
|
75
|
+
const script = document.createElement('script')
|
|
76
|
+
script.src = assetUrl(file)
|
|
77
|
+
script.async = true
|
|
78
|
+
script.onload = () => {
|
|
79
|
+
const global = (window as unknown as AssetGlobal).__GenuiAssets__ ?? {}
|
|
80
|
+
// Asset files are kebab-case; the keys they register are camelCase.
|
|
81
|
+
const key = name.replace(/-(\w)/g, (_m, ch: string) => ch.toUpperCase())
|
|
82
|
+
const api = global[key]
|
|
83
|
+
if (api === undefined) {
|
|
84
|
+
reject(new Error(`genui asset '${file}' loaded but registered no '${name}' engine`))
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
resolve(api as T)
|
|
88
|
+
}
|
|
89
|
+
script.onerror = () => {
|
|
90
|
+
reject(new Error(`genui asset '${file}' failed to load (host asset route missing?)`))
|
|
91
|
+
}
|
|
92
|
+
document.head.appendChild(script)
|
|
93
|
+
})
|
|
94
|
+
pending.set(file, task as unknown as Promise<Record<string, unknown>>)
|
|
95
|
+
return task
|
|
96
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid asset-bundle entry: registers the mermaid engine on
|
|
3
|
+
* `window.__GenuiAssets__.mermaid`. Built as a standalone IIFE into
|
|
4
|
+
* `lib/assets/mermaid.js` and served by the plugin's node-half route; loaded
|
|
5
|
+
* on demand by mermaid-lazy.
|
|
6
|
+
* @module @changfenhuang/dsh-genui/client/asset-mermaid
|
|
7
|
+
*/
|
|
8
|
+
import { renderMermaid } from './mermaid-core.ts'
|
|
9
|
+
import { assertSafeSvg, repairMermaidSource } from './mermaid-safe.ts'
|
|
10
|
+
|
|
11
|
+
const win = globalThis as unknown as { __GenuiAssets__?: Record<string, unknown> }
|
|
12
|
+
const assets = win.__GenuiAssets__ ?? (win.__GenuiAssets__ = {})
|
|
13
|
+
assets.mermaid = { assertSafeSvg, repairMermaidSource, renderMermaid }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* three.js asset-bundle entry: registers the scene renderer on
|
|
3
|
+
* `window.__GenuiAssets__.three`. Built as a standalone IIFE into
|
|
4
|
+
* `lib/assets/three.js` and served by the plugin's node-half route; loaded on
|
|
5
|
+
* demand by scene3d-lazy.
|
|
6
|
+
* @module @changfenhuang/dsh-genui/client/asset-three
|
|
7
|
+
*/
|
|
8
|
+
import { mountScene } from './scene3d-core.ts'
|
|
9
|
+
|
|
10
|
+
const win = globalThis as unknown as { __GenuiAssets__?: Record<string, unknown> }
|
|
11
|
+
const assets = win.__GenuiAssets__ ?? (win.__GenuiAssets__ = {})
|
|
12
|
+
assets.three = { mountScene }
|