@sparkelf/dsh-genui 0.11.4-patch.2 → 0.13.0-sparkelf.3
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 +76 -0
- package/ICON-NAMES.md +30 -0
- package/README.md +26 -28
- package/README.zh-CN.md +26 -28
- package/SKILL.md +128 -19
- package/THIRD_PARTY_NOTICES.md +42 -0
- package/assets/genui-icon.svg +20 -0
- package/assets/genui-logo.svg +18 -0
- package/lib/assets/icons.js +1 -0
- package/lib/assets/mermaid.js +325 -325
- package/lib/assets/standalone-runtime.js +10 -9
- package/lib/client.js +32 -31
- package/lib/index.js +523 -80
- package/lib/types/client/action-context.d.ts +1 -1
- package/lib/types/client/artifact/types.d.ts +1 -1
- package/lib/types/client/asset-loader.d.ts +2 -2
- package/lib/types/client/blocks/blocks.d.ts +12 -0
- package/lib/types/client/blocks/icon.d.ts +4 -0
- package/lib/types/client/dom-fence.d.ts +2 -1
- package/lib/types/client/fence-render.d.ts +5 -21
- package/lib/types/client/file-address.d.ts +4 -0
- package/lib/types/client/file-link-context.d.ts +49 -0
- package/lib/types/client/file-link.d.ts +17 -0
- package/lib/types/client/gallery.d.ts +8 -2
- package/lib/types/client/genui-runtime/diagnostics.d.ts +1 -1
- package/lib/types/client/genui-runtime/limits.d.ts +4 -0
- package/lib/types/client/genui-runtime/schema.d.ts +14 -1
- package/lib/types/client/guard.d.ts +4 -1
- package/lib/types/client/i18n/en.d.ts +5 -1
- package/lib/types/client/i18n/index.d.ts +1 -1
- package/lib/types/client/icons/asset-icons.d.ts +1 -0
- package/lib/types/client/icons/icon-data-full.d.ts +23 -0
- package/lib/types/client/icons/icon-data.d.ts +24 -0
- package/lib/types/client/icons/icon-lazy.d.ts +18 -0
- package/lib/types/client/icons/icon-names-full.d.ts +12 -0
- package/lib/types/client/index.d.ts +5 -15
- package/lib/types/client/inline.d.ts +1 -1
- package/lib/types/client/mermaid-colors.d.ts +2 -0
- package/lib/types/client/mermaid-core.d.ts +2 -1
- package/lib/types/client/mermaid-lazy.d.ts +5 -1
- package/lib/types/client/panel-command.d.ts +21 -1
- package/lib/types/client/panel.d.ts +6 -1
- package/lib/types/client/primitive-adapter.d.ts +0 -2
- package/lib/types/client/session-resolver.d.ts +13 -2
- package/lib/types/client/source-fence.d.ts +1 -1
- package/lib/types/client/spec.d.ts +127 -3
- package/lib/types/client/standalone/asset-loader.d.ts +1 -1
- package/lib/types/client/standalone/primitive-adapter.d.ts +0 -4
- package/lib/types/plugin/fence-feedback.d.ts +11 -7
- package/lib/types/plugin/index.d.ts +6 -2
- package/lib/types/shared/fence-language.d.ts +14 -0
- package/lib/types/shared/fence-repair.d.ts +2 -1
- package/lib/types/shared/fence-resolve.d.ts +1 -1
- package/package.json +92 -83
- package/src/client/EChartNode.tsx +17 -3
- package/src/client/GenuiBlock.module.css +411 -76
- package/src/client/action-context.ts +5 -15
- package/src/client/artifact/ArtifactExport.module.css +34 -3
- package/src/client/artifact/ExportableGenuiBlock.tsx +23 -2
- package/src/client/artifact/portability.ts +6 -1
- package/src/client/artifact/types.ts +1 -1
- package/src/client/asset-loader.ts +3 -3
- package/src/client/blocks/advanced.tsx +101 -14
- package/src/client/blocks/blocks.tsx +143 -0
- package/src/client/blocks/charts.tsx +22 -6
- package/src/client/blocks/icon.tsx +93 -0
- package/src/client/blocks/image.tsx +1 -0
- package/src/client/blocks/render-node.tsx +84 -52
- package/src/client/dom-fence.tsx +546 -72
- package/src/client/fence-render.tsx +5 -21
- package/src/client/file-address.ts +37 -0
- package/src/client/file-link-context.tsx +116 -0
- package/src/client/file-link.ts +46 -0
- package/src/client/gallery.ts +161 -133
- package/src/client/genui-runtime/diagnostics.ts +1 -1
- package/src/client/genui-runtime/limits.ts +4 -0
- package/src/client/genui-runtime/normalize.ts +42 -6
- package/src/client/genui-runtime/schema.ts +39 -7
- package/src/client/guard.ts +170 -15
- package/src/client/i18n/en.ts +5 -1
- package/src/client/i18n/index.ts +1 -1
- package/src/client/i18n/zh.ts +5 -1
- package/src/client/icons/asset-icons.ts +16 -0
- package/src/client/icons/icon-data-full.ts +5715 -0
- package/src/client/icons/icon-data.ts +507 -0
- package/src/client/icons/icon-lazy.ts +80 -0
- package/src/client/icons/icon-names-full.ts +12 -0
- package/src/client/index.tsx +27 -51
- package/src/client/inline.ts +17 -6
- package/src/client/mermaid-colors.ts +40 -0
- package/src/client/mermaid-core.ts +69 -61
- package/src/client/mermaid-lazy.ts +99 -4
- package/src/client/panel-command.ts +16 -2
- package/src/client/panel.tsx +18 -5
- package/src/client/parse-partial.ts +6 -1
- package/src/client/primitive-adapter.ts +0 -11
- package/src/client/session-resolver.ts +12 -21
- package/src/client/source-fence.ts +4 -2
- package/src/client/spec.ts +149 -2
- package/src/client/standalone/asset-loader.ts +1 -1
- package/src/client/standalone/primitive-adapter.tsx +1 -9
- package/src/client/table-details.ts +4 -3
- package/src/plugin/fence-feedback.ts +60 -14
- package/src/plugin/index.ts +45 -20
- package/src/plugin/tool.ts +11 -2
- package/src/shared/fence-language.ts +30 -0
- package/src/shared/fence-repair.ts +37 -1
- package/src/shared/fence-resolve.ts +1 -1
- package/tsdown.config.ts +7 -8
- package/lib/invariant.js +0 -19
- package/lib/types/plugin/invariant.d.ts +0 -15
- package/src/plugin/invariant.ts +0 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from 'react';
|
|
2
2
|
/** v2 action handler: component action + its collected data. */
|
|
3
3
|
export type GenuiActionHandler = (action: string, payload: Record<string, unknown>) => void;
|
|
4
|
-
/**
|
|
4
|
+
/** Shared action context owned by this plugin. */
|
|
5
5
|
export declare const GenuiActionContext: Context<GenuiActionHandler | undefined>;
|
|
6
6
|
/** Read the installed action handler, if any. */
|
|
7
7
|
export declare function useGenuiAction(): GenuiActionHandler | undefined;
|
|
@@ -4,7 +4,7 @@ import type { BlockInteractionState } from '../interaction-store.ts';
|
|
|
4
4
|
export declare const GENUI_ARTIFACT_FORMAT = "dsh-genui";
|
|
5
5
|
export declare const GENUI_ARTIFACT_VERSION: 1;
|
|
6
6
|
export type GenuiArtifactTheme = 'light' | 'dark';
|
|
7
|
-
export type GenuiStandaloneAsset = 'mermaid' | 'three' | 'echarts-core' | 'echarts-full';
|
|
7
|
+
export type GenuiStandaloneAsset = 'mermaid' | 'three' | 'echarts-core' | 'echarts-full' | 'icons';
|
|
8
8
|
export interface GenuiArtifactV1 {
|
|
9
9
|
format: typeof GENUI_ARTIFACT_FORMAT;
|
|
10
10
|
version: typeof GENUI_ARTIFACT_VERSION;
|
|
@@ -27,7 +27,7 @@ export declare function assetUrl(file: string): string;
|
|
|
27
27
|
* file: repeated requests (several mermaid nodes, re-renders) share one
|
|
28
28
|
* script load; a failed load stays failed for the page (the component shows
|
|
29
29
|
* its fallback).
|
|
30
|
-
* @param name - 'mermaid', 'three', 'echarts-core',
|
|
30
|
+
* @param name - 'mermaid', 'three', 'echarts-core', 'echarts-full', or 'icons'.
|
|
31
31
|
* @returns the registered engine surface.
|
|
32
32
|
*/
|
|
33
|
-
export declare function loadGenuiAsset<T>(name: 'mermaid' | 'three' | 'echarts-core' | 'echarts-full'): Promise<T>;
|
|
33
|
+
export declare function loadGenuiAsset<T>(name: 'mermaid' | 'three' | 'echarts-core' | 'echarts-full' | 'icons'): Promise<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GenuiBlocks } from '../spec.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Contrast-aware ink for opaque literal fills; theme ink for contextual fills.
|
|
4
|
+
*
|
|
5
|
+
* Uses WCAG relative luminance, not a naive RGB average: the average reads
|
|
6
|
+
* mid-tone blues (#339cff) as "dark" and prints white on a surface that
|
|
7
|
+
* actually needs ink on it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readableOn(color: string | undefined): string;
|
|
10
|
+
export declare const BlocksNode: import("react").NamedExoticComponent<{
|
|
11
|
+
node: GenuiBlocks;
|
|
12
|
+
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Root } from 'react-dom/client';
|
|
2
2
|
import type { Context } from '@deepseek-ai/cordis';
|
|
3
3
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
4
|
+
import { type FileLinkAvailability } from './file-link-context.tsx';
|
|
4
5
|
/** Override the React root factory (tests / tuning). */
|
|
5
6
|
export declare function setDomRootFactory(factory: (container: HTMLElement) => Root): void;
|
|
6
7
|
/**
|
|
@@ -27,4 +28,4 @@ export declare function hostFenceIndexOf(row: Element, block: Element): number;
|
|
|
27
28
|
* @param sendAction - plugin-owned relay: (sessionId, action, payload) → the
|
|
28
29
|
* scoped conversation send carrying the `[genui-action]` prompt.
|
|
29
30
|
*/
|
|
30
|
-
export declare function installDomFenceRenderer(ctx: Context, sendAction: (sessionId: SessionId, action: string, payload: Record<string, unknown>) => void): () => void;
|
|
31
|
+
export declare function installDomFenceRenderer(ctx: Context, sendAction: (sessionId: SessionId, action: string, payload: Record<string, unknown>) => void, fileLinkAvailability?: FileLinkAvailability): () => void;
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The dsh-ui fence render pipeline
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* ```dsh-ui fences through the fence-registry extension point and calls
|
|
6
|
-
* {@link renderGenuiFence} with a session-scoped context (sessionId + the
|
|
7
|
-
* settled source identity). An unrepairable body renders {@link FenceFallback}.
|
|
8
|
-
* - **DOM channel** (pristine hosts, no extension point): the DOM observer
|
|
9
|
-
* (`dom-fence.ts`) finds stock code blocks labelled `dsh-ui` and mounts
|
|
10
|
-
* {@link renderResolvedFenceNode} into its own React root, wrapped in the
|
|
11
|
-
* plugin-owned action context. An unrepairable body returns `null` so the
|
|
12
|
-
* stock code block stays visible, with {@link FenceDiagnostic} mounted above
|
|
13
|
-
* it so the defect is never silent (issue #158).
|
|
14
|
-
*
|
|
15
|
-
* Structural types are declared locally on purpose: the context contract is
|
|
16
|
-
* a data shape, and pristine hosts do not export the host-side type names.
|
|
2
|
+
* The dsh-ui fence render pipeline used by the DOM observer and renderer tests.
|
|
3
|
+
* An unrepairable body returns `null` so the stock code block stays visible,
|
|
4
|
+
* with {@link FenceDiagnostic} mounted above it (issue #158).
|
|
17
5
|
*/
|
|
18
6
|
import { type Key, type ReactNode } from 'react';
|
|
19
7
|
import type { GenuiSpec } from './spec.ts';
|
|
@@ -63,8 +51,7 @@ export declare function describeFenceFailure(raw: string, options?: {
|
|
|
63
51
|
/**
|
|
64
52
|
* The visible diagnostic for a settled, unrenderable ```dsh-ui body.
|
|
65
53
|
*
|
|
66
|
-
*
|
|
67
|
-
* fallback code block, the DOM channel above the host's stock code block. A
|
|
54
|
+
* The DOM channel renders this above the host's stock code block. A
|
|
68
55
|
* fence that keeps degrading to raw JSON must say why it degraded — the
|
|
69
56
|
* console-only path left the defect invisible (issues #158/#172).
|
|
70
57
|
*
|
|
@@ -98,9 +85,6 @@ export declare function resolveGenuiSpec(raw: string, context?: GenuiFenceContex
|
|
|
98
85
|
*/
|
|
99
86
|
export declare function renderResolvedFenceNode(raw: string, key: Key, context?: GenuiFenceContext): ReactNode | null;
|
|
100
87
|
/**
|
|
101
|
-
*
|
|
102
|
-
* but an unrepairable body renders the fallback code block + settled
|
|
103
|
-
* diagnostic — the host replaced its own block with our output — and an
|
|
104
|
-
* unpublishable `panel:true` fence renders `null` (nothing in the flow).
|
|
88
|
+
* Render a complete fence body for renderer-level tests.
|
|
105
89
|
*/
|
|
106
90
|
export declare function renderGenuiFence(raw: string, key: Key, context?: GenuiFenceContext): ReactNode;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Build a session resource address while preserving encoded path segments. */
|
|
2
|
+
export declare function sessionFileAddress(sessionId: string, path: string): string;
|
|
3
|
+
/** Resolve workspace absolute paths to session-relative resource addresses. */
|
|
4
|
+
export declare function fileAddressFor(sessionId: string, cwd: string | undefined, path: string): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
3
|
+
interface SidebarRightService {
|
|
4
|
+
openResource(address: string, options?: {
|
|
5
|
+
params: {
|
|
6
|
+
line: number;
|
|
7
|
+
};
|
|
8
|
+
}): void;
|
|
9
|
+
}
|
|
10
|
+
interface FileLinkHostContext {
|
|
11
|
+
get(name: 'sidebarRight', strict?: false): SidebarRightService | undefined;
|
|
12
|
+
sessions: {
|
|
13
|
+
list: {
|
|
14
|
+
getSnapshot(): unknown;
|
|
15
|
+
};
|
|
16
|
+
retainInfo(sessionId: SessionId): {
|
|
17
|
+
getSnapshot(): {
|
|
18
|
+
retainedBy: {
|
|
19
|
+
mainView?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface FileLinkScope {
|
|
26
|
+
get(name: 'sidebarRight'): SidebarRightService | undefined;
|
|
27
|
+
effect(callback: () => void | (() => void), name?: string): unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface FileLinkCordisContext extends FileLinkHostContext {
|
|
30
|
+
inject(services: ['sidebarRight'], callback: (scope: FileLinkScope) => void): unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface FileLinkAvailability {
|
|
33
|
+
subscribe(listener: () => void): () => void;
|
|
34
|
+
getSnapshot(): boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Track an optional host service through arrival, removal, and plugin unload. */
|
|
37
|
+
export declare function createFileLinkAvailability(ctx: FileLinkCordisContext): FileLinkAvailability;
|
|
38
|
+
/** Render a file link as an accessible host navigation button when available. */
|
|
39
|
+
export declare function FileLink({ path, line, label, children }: {
|
|
40
|
+
path: string;
|
|
41
|
+
line?: number;
|
|
42
|
+
label: string;
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
}): import("react").DetailedReactHTMLElement<{
|
|
45
|
+
title: string;
|
|
46
|
+
}, HTMLElement>;
|
|
47
|
+
/** Add session-scoped file navigation to one fence render tree. */
|
|
48
|
+
export declare function withFileLinkContext(ctx: FileLinkHostContext, availability: FileLinkAvailability, sessionId: string | undefined, streaming: boolean, children: ReactNode): ReactNode;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ParsedFileLink {
|
|
2
|
+
path: string;
|
|
3
|
+
line?: number;
|
|
4
|
+
}
|
|
5
|
+
export type LinkTarget = {
|
|
6
|
+
type: 'external';
|
|
7
|
+
href: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'file';
|
|
10
|
+
file: ParsedFileLink;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'invalid';
|
|
13
|
+
};
|
|
14
|
+
/** Decode a local file destination and its optional first line fragment. */
|
|
15
|
+
export declare function parseFileLink(value: string): ParsedFileLink | undefined;
|
|
16
|
+
/** Classify a link destination while preserving the existing external URL policy. */
|
|
17
|
+
export declare function classifyLinkTarget(value: unknown): LinkTarget;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GenUI gallery: canonical
|
|
3
|
-
*
|
|
2
|
+
* GenUI gallery: the canonical component anthology (选集). Chapters demo the
|
|
3
|
+
* composition patterns (hero → 摘要 → 数据 → 图表册 → 叙事与代码 → 交互), and
|
|
4
|
+
* the appendix lays out the full vocabulary flat. Docs, demos, and renderer
|
|
5
|
+
* tests reuse it as the canonical fence — one spec, four consumers (tests,
|
|
6
|
+
* e2e-visual, README screenshots, the Pages anthology page).
|
|
7
|
+
*
|
|
8
|
+
* Every B-programme field is exercised here: divider.label chapters,
|
|
9
|
+
* card.eyebrow overlines, text display/align, image.caption.
|
|
4
10
|
*/
|
|
5
11
|
import type { GenuiSpec } from './spec.ts';
|
|
6
12
|
/** Canonical gallery spec for the built-in GenUI component vocabulary. */
|
|
@@ -39,6 +39,10 @@ export declare const GENUI_LIMITS: {
|
|
|
39
39
|
readonly maxKeyValuePairs: 24;
|
|
40
40
|
/** Maximum `file-tree` nesting. */
|
|
41
41
|
readonly maxTreeDepth: 6;
|
|
42
|
+
/** Maximum `blocks` figure rows / cells per row. Cells are data, not nodes,
|
|
43
|
+
* so a wide figure still costs one node against `maxNodes`. */
|
|
44
|
+
readonly maxBlocksRows: 14;
|
|
45
|
+
readonly maxBlocksCells: 16;
|
|
42
46
|
/** Maximum `diagram` nodes / edges / zones / focal accents. */
|
|
43
47
|
readonly maxDiagramNodes: 9;
|
|
44
48
|
readonly maxDiagramEdges: 12;
|
|
@@ -46,7 +46,8 @@ export interface ComponentSchema {
|
|
|
46
46
|
readonly validator?: ComponentValidatorMetadata;
|
|
47
47
|
}
|
|
48
48
|
/** Canonical enum domains shared by schema validation and repair. */
|
|
49
|
-
export declare const TEXT_SIZES: readonly ["h1", "h2", "h3", "body", "muted", "caption"];
|
|
49
|
+
export declare const TEXT_SIZES: readonly ["display", "h1", "h2", "h3", "body", "muted", "caption"];
|
|
50
|
+
export declare const TEXT_ALIGNS: readonly ["left", "center", "right"];
|
|
50
51
|
export declare const BUTTON_TONES: readonly ["primary", "danger", "success", "ghost"];
|
|
51
52
|
export declare const BADGE_TONES: readonly ["success", "warn", "danger", "accent"];
|
|
52
53
|
export declare const INPUT_TYPES: readonly ["text", "email", "password", "color"];
|
|
@@ -68,6 +69,18 @@ export declare const STAT_SIZES: readonly ["hero"];
|
|
|
68
69
|
export declare const PROGRESS_VARIANTS: readonly ["bar", "ring"];
|
|
69
70
|
/** Semantic card surfaces. */
|
|
70
71
|
export declare const CARD_TONES: readonly ["info", "success", "warning", "danger"];
|
|
72
|
+
/** Text run tones (semantic colour without a badge). */
|
|
73
|
+
export declare const TEXT_TONES: readonly ["danger", "success", "warning", "info", "muted"];
|
|
74
|
+
/** Arrow directions. */
|
|
75
|
+
export declare const ARROW_DIRS: readonly ["down", "right"];
|
|
76
|
+
/** Row main-axis alignment values. */
|
|
77
|
+
export declare const ROW_JUSTIFY: readonly ["start", "center", "end", "between"];
|
|
78
|
+
/** Block-row paint modes: filled cells, or outlined cells for bit grids. */
|
|
79
|
+
export declare const BLOCKS_VARIANTS: readonly ["fill", "outline", "plain"];
|
|
80
|
+
/** 单格强调的语义档位。 */
|
|
81
|
+
export declare const BLOCK_CELL_TONES: readonly ["accent", "success", "warning", "danger", "muted"];
|
|
82
|
+
/** Icon tones: the four semantic roles plus neutral/muted text colours. */
|
|
83
|
+
export declare const ICON_TONES: readonly ["default", "muted", "info", "success", "warning", "danger"];
|
|
71
84
|
/** Hero cover tones. */
|
|
72
85
|
export declare const HERO_TONES: readonly ["accent", "success", "warning", "danger"];
|
|
73
86
|
/** Table cell renderers (`table.types`, one entry per column). */
|
|
@@ -55,9 +55,12 @@ export declare const GENUI_NODE_TYPES: ReadonlySet<string>;
|
|
|
55
55
|
* Count white-listed nodes declared by a raw spec before repair drops invalid entries.
|
|
56
56
|
* @param value - raw GenUI spec.
|
|
57
57
|
* @param cap - traversal ceiling.
|
|
58
|
+
* @param options - `familyCaps: false` counts beyond per-family policy caps too.
|
|
58
59
|
* @returns declared node count up to the ceiling.
|
|
59
60
|
*/
|
|
60
|
-
export declare function countDeclaredGenuiNodes(value: unknown, cap?: number
|
|
61
|
+
export declare function countDeclaredGenuiNodes(value: unknown, cap?: number, options?: {
|
|
62
|
+
familyCaps?: boolean;
|
|
63
|
+
}): number;
|
|
61
64
|
/** Count native nodes that survived repair, excluding opaque custom nodes. */
|
|
62
65
|
export declare function countRenderedNativeGenuiNodes(value: unknown, cap?: number): number;
|
|
63
66
|
/**
|
|
@@ -262,6 +262,10 @@ export declare const EN: {
|
|
|
262
262
|
readonly 'label.copyButtonTitle': "{action}; right-click for copy options";
|
|
263
263
|
readonly 'block.copyMarkdown': "Copy Markdown";
|
|
264
264
|
readonly 'block.copyCsv': "Copy CSV";
|
|
265
|
+
readonly 'block.table.expandDetails': "Expand details for {label}";
|
|
266
|
+
readonly 'block.table.collapseDetails': "Collapse details for {label}";
|
|
267
|
+
readonly 'block.table.expandGroup': "Expand group {label}";
|
|
268
|
+
readonly 'block.table.collapseGroup': "Collapse group {label}";
|
|
265
269
|
readonly 'block.total': "Total";
|
|
266
270
|
readonly 'block.filteredRows': "{visible} / {total} rows after filtering";
|
|
267
271
|
readonly 'block.filterMatch': "{shown} / {total} matched";
|
|
@@ -277,7 +281,7 @@ export declare const EN: {
|
|
|
277
281
|
readonly 'block.svgPreview': "Preview";
|
|
278
282
|
readonly 'block.svgSource': "Source";
|
|
279
283
|
readonly 'block.svgError': "SVG could not be displayed — showing the source instead";
|
|
280
|
-
readonly 'block.mermaidError': "
|
|
284
|
+
readonly 'block.mermaidError': "Diagram rendering failed — showing the source instead";
|
|
281
285
|
readonly 'block.mermaidLoading': "Rendering…";
|
|
282
286
|
readonly 'block.scene3dLoading': "Loading 3D scene…";
|
|
283
287
|
readonly 'block.scene3dError': "3D rendering failed";
|
|
@@ -32,7 +32,7 @@ export declare const GENUI_LOCALE_NS = "genui";
|
|
|
32
32
|
* Hosts WITHOUT the locale service degrade silently to browser detection —
|
|
33
33
|
* the service is read optionally, never declared in `inject`, because a
|
|
34
34
|
* declared-but-absent service parks the fiber forever and would kill all
|
|
35
|
-
* GenUI rendering
|
|
35
|
+
* GenUI rendering when the host has no locale service.
|
|
36
36
|
*
|
|
37
37
|
* @param ctx - client cordis context (read optionally).
|
|
38
38
|
* @returns disposer removing the registrations and the subscription.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Apps SDK UI icons — https://github.com/openai/apps-sdk-ui
|
|
3
|
+
* Pinned commit 0f00143c7a639906f1621fe58e1b6be7b5bea46d · MIT · Copyright 2025 OpenAI.
|
|
4
|
+
* See THIRD_PARTY_NOTICES.md.
|
|
5
|
+
*
|
|
6
|
+
* Generated by scripts/generate-icon-data.mjs — do not hand-edit.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 全量字形(749 个)。只有懒加载资产入口引用它,不进入客户端包。
|
|
10
|
+
*/
|
|
11
|
+
import type { SVGProps } from 'react';
|
|
12
|
+
export interface BundledIcon {
|
|
13
|
+
viewBox: string;
|
|
14
|
+
/** Root attributes preserve SVG paint inheritance. */
|
|
15
|
+
attrs: IconAttributes;
|
|
16
|
+
shapes: IconShape[];
|
|
17
|
+
}
|
|
18
|
+
export type IconAttributes = Pick<SVGProps<SVGSVGElement>, 'fill' | 'fillRule' | 'clipRule' | 'stroke' | 'strokeWidth' | 'strokeLinecap' | 'strokeLinejoin' | 'opacity' | 'd' | 'x' | 'y' | 'width' | 'height' | 'rx' | 'ry' | 'cx' | 'cy' | 'r' | 'x1' | 'y1' | 'x2' | 'y2' | 'points' | 'transform'>;
|
|
19
|
+
export interface IconShape {
|
|
20
|
+
tag: 'path' | 'rect' | 'circle' | 'ellipse' | 'line' | 'polyline' | 'polygon';
|
|
21
|
+
attrs: IconAttributes;
|
|
22
|
+
}
|
|
23
|
+
export declare const ICONS_FULL: Readonly<Record<string, BundledIcon>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Apps SDK UI icons — https://github.com/openai/apps-sdk-ui
|
|
3
|
+
* Pinned commit 0f00143c7a639906f1621fe58e1b6be7b5bea46d · MIT · Copyright 2025 OpenAI.
|
|
4
|
+
* See THIRD_PARTY_NOTICES.md.
|
|
5
|
+
*
|
|
6
|
+
* Generated by scripts/generate-icon-data.mjs — do not hand-edit.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 内联集合(64 个):随客户端包发布,常见构图无需下载即可渲染。
|
|
10
|
+
* 其余字形见 icon-data-full.ts,经 lib/assets/icons.js 按需载入。
|
|
11
|
+
*/
|
|
12
|
+
import type { SVGProps } from 'react';
|
|
13
|
+
export interface BundledIcon {
|
|
14
|
+
viewBox: string;
|
|
15
|
+
/** Root attributes preserve SVG paint inheritance. */
|
|
16
|
+
attrs: IconAttributes;
|
|
17
|
+
shapes: IconShape[];
|
|
18
|
+
}
|
|
19
|
+
export type IconAttributes = Pick<SVGProps<SVGSVGElement>, 'fill' | 'fillRule' | 'clipRule' | 'stroke' | 'strokeWidth' | 'strokeLinecap' | 'strokeLinejoin' | 'opacity' | 'd' | 'x' | 'y' | 'width' | 'height' | 'rx' | 'ry' | 'cx' | 'cy' | 'r' | 'x1' | 'y1' | 'x2' | 'y2' | 'points' | 'transform'>;
|
|
20
|
+
export interface IconShape {
|
|
21
|
+
tag: 'path' | 'rect' | 'circle' | 'ellipse' | 'line' | 'polyline' | 'polygon';
|
|
22
|
+
attrs: IconAttributes;
|
|
23
|
+
}
|
|
24
|
+
export declare const ICONS: Readonly<Record<string, BundledIcon>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BundledIcon } from './icon-data.ts';
|
|
2
|
+
/** Is `name` a real catalogue entry (even if its shapes are not downloaded)? */
|
|
3
|
+
export declare function isKnownIcon(name: string): boolean;
|
|
4
|
+
/** Resolve a glyph if its shapes are already available, synchronously. */
|
|
5
|
+
export declare function resolveIcon(name: string): BundledIcon | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Subscribe to the one-shot full-catalogue load. Used by mounted `icon` nodes
|
|
8
|
+
* to swap their fallback dot for the real glyph.
|
|
9
|
+
* @returns unsubscribe.
|
|
10
|
+
*/
|
|
11
|
+
export declare function onIconsLoaded(listener: () => void): () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Fetch the full catalogue once. A failed load stays failed for the page (the
|
|
14
|
+
* glyphs keep their fallback), matching the asset loader's memoized-rejection
|
|
15
|
+
* contract — retrying on every render would turn a missing route into a
|
|
16
|
+
* request storm.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ensureIcons(): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Apps SDK UI icons — https://github.com/openai/apps-sdk-ui
|
|
3
|
+
* Pinned commit 0f00143c7a639906f1621fe58e1b6be7b5bea46d · MIT · Copyright 2025 OpenAI.
|
|
4
|
+
* See THIRD_PARTY_NOTICES.md.
|
|
5
|
+
*
|
|
6
|
+
* Generated by scripts/generate-icon-data.mjs — do not hand-edit.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 全部规范名(749)。只内联名字,好让渲染器区分「拼错」和「还没下载」:
|
|
10
|
+
* 不在这里的名字立刻走中性圆点兜底,不会触发全量字形包下载。
|
|
11
|
+
*/
|
|
12
|
+
export declare const ICON_NAMES_FULL: readonly string[];
|
|
@@ -2,17 +2,10 @@
|
|
|
2
2
|
* dsh-genui browser half: the ```dsh-ui fence renderer, the keyed toolview
|
|
3
3
|
* for the `render_ui` tool, and the session panel dock.
|
|
4
4
|
*
|
|
5
|
-
* Fence rendering
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* GenuiActionContext.
|
|
10
|
-
* - **DOM channel** (pristine hosts): no extension point exists, so
|
|
11
|
-
* `dom-fence.ts` observes the conversation DOM, finds settled stock code
|
|
12
|
-
* blocks labelled `dsh-ui`, and mounts the same render pipeline in its own
|
|
13
|
-
* React roots — wrapped in the plugin-owned GenuiActionContext that relays
|
|
14
|
-
* `[genui-action]` through the scoped conversation send. Either way the
|
|
15
|
-
* deployment is the STOCK DSH snapshot plus this plugin.
|
|
5
|
+
* Fence rendering uses the stock DSH DOM. `dom-fence.ts` observes the
|
|
6
|
+
* conversation DOM, identifies `dsh-ui` blocks and mounts the renderer in
|
|
7
|
+
* plugin-owned React roots. The plugin-owned GenuiActionContext relays
|
|
8
|
+
* `[genui-action]` through the scoped conversation send.
|
|
16
9
|
*
|
|
17
10
|
* The renderer parses the fence body with the partial parser: while the reply
|
|
18
11
|
* streams, every FINISHED component appears the moment its JSON object
|
|
@@ -21,16 +14,13 @@
|
|
|
21
14
|
* @module @changfenhuang/dsh-genui/client
|
|
22
15
|
*/
|
|
23
16
|
import type { Context } from '@deepseek-ai/cordis';
|
|
24
|
-
import { renderGenuiFence } from './fence-render.tsx';
|
|
25
17
|
/** Add low-priority prefetch links for the lazy engine assets (mermaid/three).
|
|
26
18
|
* Browser-dependent: some engines ignore `<link rel=prefetch>`; harmless
|
|
27
19
|
* either way — the on-demand loader still covers a cache miss. Exported for
|
|
28
20
|
* tests. */
|
|
29
21
|
export declare function prefetchGenuiAssets(): void;
|
|
30
|
-
/** Cordis client entry:
|
|
22
|
+
/** Cordis client entry: install the fence renderer on boot, the keyed
|
|
31
23
|
* toolview for the render_ui tool, and the session panel dock; returning the
|
|
32
24
|
* disposers lets cordis tear all registrations down on plugin unload. */
|
|
33
25
|
export declare function apply(ctx: Context): () => void;
|
|
34
26
|
export declare const inject: string[];
|
|
35
|
-
export { renderGenuiFence };
|
|
36
|
-
export type { GenuiFenceContext } from './fence-render.tsx';
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
export declare function hasInlineMarkup(text: string): boolean;
|
|
4
4
|
/** Render safe phrasing content, usable in headings, buttons and labels too. */
|
|
5
|
-
export declare function renderInline(text: string, allowLinks?: boolean, depth?: number): ReactNode;
|
|
5
|
+
export declare function renderInline(text: string, allowLinks?: boolean | 'file', depth?: number): ReactNode;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Render mermaid source to an SVG string.
|
|
3
3
|
* @param code - the mermaid diagram source.
|
|
4
|
+
* @param target - final diagram element whose inherited font is used for layout.
|
|
4
5
|
* @returns the rendered SVG markup (verified free of script/event handlers).
|
|
5
6
|
* @throws when the kind is not whitelisted, rendering fails, or the output
|
|
6
7
|
* fails the sanitization check.
|
|
7
8
|
*/
|
|
8
|
-
export declare function renderMermaid(code: string): Promise<string>;
|
|
9
|
+
export declare function renderMermaid(code: string, target?: HTMLElement): Promise<string>;
|
|
@@ -2,8 +2,12 @@ export { assertSafeSvg, ensureFlowchartKind, repairMermaidSource } from './merma
|
|
|
2
2
|
/**
|
|
3
3
|
* Render mermaid source to an SVG string (engine loaded on demand).
|
|
4
4
|
* @param code - the mermaid diagram source.
|
|
5
|
+
* @param options - abort signal for queued or superseded work.
|
|
5
6
|
* @returns the rendered SVG markup (verified free of script/event handlers).
|
|
6
7
|
* @throws when the asset cannot load, the kind is not whitelisted, rendering
|
|
7
8
|
* fails, or the output fails the sanitization check.
|
|
8
9
|
*/
|
|
9
|
-
export declare function renderMermaid(code: string
|
|
10
|
+
export declare function renderMermaid(code: string, options?: {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
target?: HTMLElement;
|
|
13
|
+
}): Promise<string>;
|
|
@@ -15,8 +15,12 @@
|
|
|
15
15
|
* panel", or re-run render_ui) or through another /panel.
|
|
16
16
|
*/
|
|
17
17
|
import type { InputTriggerSource } from '@deepseek-ai/dsh-client-ui-input-trigger/client';
|
|
18
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
18
19
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
19
20
|
import type { GenuiSpec } from './spec.ts';
|
|
21
|
+
type PanelInputTriggerSource = InputTriggerSource & {
|
|
22
|
+
matchClaim: (session: Parameters<InputTriggerSource['onPick']>[0]['session'], token: string, signal: AbortSignal) => Promise<ReturnType<typeof panelClaim> | undefined>;
|
|
23
|
+
};
|
|
20
24
|
/**
|
|
21
25
|
* Default panel content published by `/panel`: the component overview.
|
|
22
26
|
*
|
|
@@ -24,6 +28,21 @@ import type { GenuiSpec } from './spec.ts';
|
|
|
24
28
|
* rather than the one that happened to be active at module load.
|
|
25
29
|
*/
|
|
26
30
|
export declare function defaultPanelSpec(): GenuiSpec;
|
|
31
|
+
/**
|
|
32
|
+
* Build the command claim for one session (span CAS is handled by the input).
|
|
33
|
+
* `sendInstruction` relays a /panel instruction to the model when the user
|
|
34
|
+
* typed more than a bare command — otherwise the instruction would be
|
|
35
|
+
* swallowed (the draft is cleared on submit) and the panel would never leave
|
|
36
|
+
* its default content.
|
|
37
|
+
*/
|
|
38
|
+
declare function panelClaim(sessionId: SessionId, sendInstruction: (sessionId: SessionId, instruction: string) => void): {
|
|
39
|
+
name: string;
|
|
40
|
+
token: string;
|
|
41
|
+
hint: string;
|
|
42
|
+
submit: (args: string, _actx: ClientContext) => Promise<{
|
|
43
|
+
kind: "success";
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
27
46
|
/**
|
|
28
47
|
* The /panel source. Menu group `genui` under the '/' trigger; the panel
|
|
29
48
|
* candidate claims the line so both the menu pick and a bare `/panel` enter
|
|
@@ -31,4 +50,5 @@ export declare function defaultPanelSpec(): GenuiSpec;
|
|
|
31
50
|
* works without opening the menu (leading-token adjudication), and it also
|
|
32
51
|
* catches `/panel clear` style args.
|
|
33
52
|
*/
|
|
34
|
-
export declare function createPanelSlashSource(sendInstruction: (sessionId: SessionId, instruction: string) => void):
|
|
53
|
+
export declare function createPanelSlashSource(sendInstruction: (sessionId: SessionId, instruction: string) => void): PanelInputTriggerSource;
|
|
54
|
+
export {};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { type GenuiActionHandler } from './action-context.ts';
|
|
2
|
+
import { type FileLinkAvailability, type FileLinkCordisContext } from './file-link-context.tsx';
|
|
2
3
|
import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
4
|
/** Injection face built per session in apply (scoped conversation send). */
|
|
4
5
|
export interface GenuiPanelInjected {
|
|
5
6
|
sessionId: string;
|
|
6
7
|
sendGenuiAction: GenuiActionHandler;
|
|
8
|
+
fileLinkContext?: {
|
|
9
|
+
ctx: FileLinkCordisContext;
|
|
10
|
+
availability: FileLinkAvailability;
|
|
11
|
+
};
|
|
7
12
|
/** Template center "try it": insert the template instruction into the
|
|
8
13
|
* current composer draft (standard conversation.input.for channel). */
|
|
9
14
|
insertTemplate: (text: string) => void;
|
|
@@ -15,4 +20,4 @@ export type GenuiPanelProps = PropsRuntime<'conversation.input.dock'> & GenuiPan
|
|
|
15
20
|
* default so the dock never steals the message flow's scroll room; the
|
|
16
21
|
* header always shows the current panel title.
|
|
17
22
|
*/
|
|
18
|
-
export declare function GenuiPanel({ sessionId, sendGenuiAction, insertTemplate }: GenuiPanelProps): import("react").JSX.Element | null;
|
|
23
|
+
export declare function GenuiPanel({ sessionId, sendGenuiAction, insertTemplate, fileLinkContext }: GenuiPanelProps): import("react").JSX.Element | null;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export { CodeBlock, DiffBlock, JsonTree, writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
2
2
|
export type { DiffBlockLabels, JsonTreeLabels } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
3
|
-
export declare const getGenuiComponent: ((type: string) => unknown) | undefined;
|
|
4
|
-
export declare const GenuiActionContext: unknown;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
2
|
+
import type { SessionListState } from '@deepseek-ai/dsh-api-session-controller/client';
|
|
3
|
+
interface SessionRetainSnapshot {
|
|
4
|
+
retainedBy: {
|
|
5
|
+
mainView?: number;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
interface SessionRetainInfo {
|
|
9
|
+
getSnapshot(): SessionRetainSnapshot;
|
|
10
|
+
}
|
|
2
11
|
/**
|
|
3
12
|
* 从宿主会话列表快照中解析当前主视图会话。
|
|
4
13
|
*
|
|
5
14
|
* @param list - 宿主提供的会话列表快照
|
|
6
|
-
* @
|
|
15
|
+
* @param retainInfo - 按会话标识读取的引用来源快照
|
|
16
|
+
* @returns 当前主视图会话标识;没有主视图引用时返回 undefined
|
|
7
17
|
*/
|
|
8
|
-
export declare function resolveViewedSessionId(list:
|
|
18
|
+
export declare function resolveViewedSessionId(list: Pick<SessionListState, 'ids'>, retainInfo: (sessionId: SessionId) => SessionRetainInfo): SessionId | undefined;
|
|
19
|
+
export {};
|
|
@@ -24,6 +24,6 @@ export declare function sourceFencesOfAssistant(blocks: readonly AssistantBlock[
|
|
|
24
24
|
* @param chat - 当前会话的 ChatSnapshot
|
|
25
25
|
* @param nodeKey - DOM assistant row 对应的 Chat node key
|
|
26
26
|
* @param index - assistant row 内从零开始的宿主代码块序号
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns 规范化后的 language;null 表示围栏没有 language,undefined 表示 source 不可用
|
|
28
28
|
*/
|
|
29
29
|
export declare function sourceLanguageAt(chat: ChatSnapshot | undefined, nodeKey: string, index: number): string | null | undefined;
|