@aqian0/dsh-renderer 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +122 -2
- package/cordis.patch.yml +4 -0
- package/icon.svg +5 -0
- package/lib/client.js +789 -0
- package/lib/config.js +96 -0
- package/lib/host/artifact-skill.js +55 -0
- package/lib/host/artifact-tool.js +177 -0
- package/lib/host/media-bridge.js +102 -0
- package/lib/index.js +120 -0
- package/lib/shared/artifact-stream.js +293 -0
- package/lib/shared/config-defaults.js +92 -0
- package/lib/shared/content-complexity.js +812 -0
- package/lib/shared/media-extractor.js +154 -0
- package/lib/shared/sandbox-core.js +286 -0
- package/lib/shared/sanitize.js +539 -0
- package/lib/types/client/artifact-node.d.ts +62 -0
- package/lib/types/client/artifact-resource.d.ts +30 -0
- package/lib/types/client/artifact-toolview.d.ts +17 -0
- package/lib/types/client/code-view.d.ts +22 -0
- package/lib/types/client/document-card.d.ts +33 -0
- package/lib/types/client/fence-layer.d.ts +26 -0
- package/lib/types/client/highlight.d.ts +24 -0
- package/lib/types/client/icons.d.ts +10 -0
- package/lib/types/client/locales.d.ts +57 -0
- package/lib/types/client/sandbox.d.ts +23 -0
- package/lib/types/client/styles.d.ts +20 -0
- package/lib/types/client/svg-view.d.ts +19 -0
- package/lib/types/client/theme.d.ts +20 -0
- package/lib/types/client/turn-media.d.ts +10 -0
- package/lib/types/client/types.d.ts +293 -0
- package/lib/types/client/workbench.d.ts +24 -0
- package/lib/types/client.d.ts +10 -0
- package/lib/types/config.d.ts +50 -0
- package/lib/types/host/artifact-skill.d.ts +39 -0
- package/lib/types/host/artifact-tool.d.ts +82 -0
- package/lib/types/host/media-bridge.d.ts +47 -0
- package/lib/types/index.d.ts +29 -0
- package/lib/types/shared/artifact-stream.d.ts +52 -0
- package/lib/types/shared/config-defaults.d.ts +56 -0
- package/lib/types/shared/content-complexity.d.ts +94 -0
- package/lib/types/shared/media-extractor.d.ts +42 -0
- package/lib/types/shared/sandbox-core.d.ts +128 -0
- package/lib/types/shared/sanitize.d.ts +97 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +95 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared DSH-native Document Expand Card rendered in the Chat stream for both:
|
|
3
|
+
* - `render_artifact` tool calls (`tool.call.toolview`) across preparing/start/result
|
|
4
|
+
* - Complex Markdown fences (`conversation.chat.markdown.fence`) during streaming and settled states
|
|
5
|
+
*
|
|
6
|
+
* Uses a single native `<button>` when ready (consistent `cursor: pointer` across the
|
|
7
|
+
* whole surface) and a matching non-interactive card container with a subtle spinner
|
|
8
|
+
* while streaming so layout height stays completely stable (zero jump on completion).
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-renderer/client/document-card
|
|
11
|
+
*/
|
|
12
|
+
import { type ContentCategory } from '../shared/content-complexity.ts';
|
|
13
|
+
import { type IconName } from './icons.ts';
|
|
14
|
+
import type { ClientEnv } from './types.ts';
|
|
15
|
+
/** Choose the localized document-type label shown in the card metadata row. */
|
|
16
|
+
export declare function documentTypeLabel(env: ClientEnv, category: ContentCategory, lang: string): string;
|
|
17
|
+
/** Choose the fallback title when neither metadata nor source content provides one. */
|
|
18
|
+
export declare function fallbackDocumentTitle(env: ClientEnv, category: ContentCategory, lang: string): string;
|
|
19
|
+
/** Choose the 20x20 document sheet icon for a Document Expand Card category. */
|
|
20
|
+
export declare function iconForCategory(category: ContentCategory): IconName;
|
|
21
|
+
/** Props for rendering one DSH-native Document Expand Card. */
|
|
22
|
+
export interface DocumentCardRenderOptions {
|
|
23
|
+
readonly state: 'streaming' | 'ready' | 'error';
|
|
24
|
+
readonly category: ContentCategory;
|
|
25
|
+
readonly lang: string;
|
|
26
|
+
readonly title: string;
|
|
27
|
+
readonly lines?: number | undefined;
|
|
28
|
+
readonly bytes?: number | undefined;
|
|
29
|
+
readonly errorMessage?: string | undefined;
|
|
30
|
+
readonly onOpen?: (() => void) | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Render one DSH-native Document Expand Card (streaming, ready, or error). */
|
|
33
|
+
export declare function renderDocumentCard(env: ClientEnv, options: DocumentCardRenderOptions): unknown;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `conversation.chat.markdown.fence` HOC layers:
|
|
3
|
+
*
|
|
4
|
+
* 1. `createFenceLayerComponent` (keyed `html` / `svg`):
|
|
5
|
+
* - While `streaming === true`, collapses early into a live "Generating…" Document Card
|
|
6
|
+
* as soon as full-document / large-canvas / explicit-sidebar / complexity signals appear;
|
|
7
|
+
* lightweight snippets stream inline verbatim without flicker.
|
|
8
|
+
* - Once settled, complex HTML/SVG renders as a clickable DSH Document Card opening in
|
|
9
|
+
* the right Sidebar; simple HTML/SVG renders inline inside a single-header DSH card.
|
|
10
|
+
*
|
|
11
|
+
* 2. `createComplexOverflowLayerComponent` (wildcard layer for all other languages):
|
|
12
|
+
* - Passes handled visual languages and ordinary/short code blocks through untouched.
|
|
13
|
+
* - Collapses overly complex or long code, Markdown, structured-data, and diff fences
|
|
14
|
+
* (including mid-stream early collapse) into the same DSH Document Card.
|
|
15
|
+
*
|
|
16
|
+
* @module dsh-renderer/client/fence-layer
|
|
17
|
+
*/
|
|
18
|
+
import type { ClientEnv, FenceSlotProps } from './types.ts';
|
|
19
|
+
/** Create the HOC component registered into `conversation.chat.markdown.fence` for `html` and `svg`. */
|
|
20
|
+
export declare function createFenceLayerComponent(env: ClientEnv): (props: FenceSlotProps) => unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Create the wildcard HOC component registered into `conversation.chat.markdown.fence`
|
|
23
|
+
* to offload overly complex non-visual fences (code, Markdown, JSON/YAML, large diffs)
|
|
24
|
+
* into a DSH-styled Document Expand Card that opens in the right Sidebar.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createComplexOverflowLayerComponent(env: ClientEnv, handledVisualLangs: ReadonlySet<string>): (props: FenceSlotProps) => unknown;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shiki-backed synchronous syntax highlighter for the browser Client bundle.
|
|
3
|
+
*
|
|
4
|
+
* Uses `@shikijs/core` + `@shikijs/engine-javascript` (no WASM) with the exact
|
|
5
|
+
* same `css-variables` (`--shiki-*`) theme contract that DSH's own
|
|
6
|
+
* `dsh-client-ui-theme/src/styles/shiki.css` provides, initialized lazily on
|
|
7
|
+
* first Code view render so page boot stays zero-cost.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-renderer/client/highlight
|
|
10
|
+
*/
|
|
11
|
+
/** One rendered token span with inline CSS style mapped to `--shiki-*` variables. */
|
|
12
|
+
export interface ShikiTokenSpan {
|
|
13
|
+
readonly text: string;
|
|
14
|
+
readonly style?: Readonly<Record<string, string>> | undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Resolve an arbitrary Markdown fence language tag to a bundled Shiki grammar name, if supported. */
|
|
17
|
+
export declare function resolveShikiLanguage(lang: string): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Tokenize source text into per-line Shiki spans using DSH's `--shiki-*` variables.
|
|
20
|
+
*
|
|
21
|
+
* Falls back cleanly to plain monospace lines when a language has no bundled grammar
|
|
22
|
+
* or when content exceeds the synchronous highlight length cap.
|
|
23
|
+
*/
|
|
24
|
+
export declare function highlightCode(source: string, lang: string): readonly (readonly ShikiTokenSpan[])[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal stroke-based 14px SVG icons matching DSH's compact action buttons.
|
|
3
|
+
*
|
|
4
|
+
* @module dsh-renderer/client/icons
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactRuntime } from './types.ts';
|
|
7
|
+
/** Supported icon names rendered inside toolbar, document cards, and floating controls. */
|
|
8
|
+
export type IconName = 'sidebar' | 'expand' | 'download' | 'close' | 'zoomIn' | 'zoomOut' | 'grid' | 'copy' | 'check' | 'wrap' | 'htmlDoc' | 'svgDoc' | 'codeDoc' | 'textDoc' | 'chevronRight';
|
|
9
|
+
/** Render a crisp 14x14 outline icon inheriting `currentColor`. */
|
|
10
|
+
export declare function renderIcon(React: ReactRuntime, name: IconName, size?: number): unknown;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side localization dictionaries (`dshRenderer` namespace).
|
|
3
|
+
*
|
|
4
|
+
* Both `zh` and `en` MUST carry the exact same set of keys (`test/build.test.ts` enforces this).
|
|
5
|
+
*
|
|
6
|
+
* @module dsh-renderer/client/locales
|
|
7
|
+
*/
|
|
8
|
+
/** Client locale namespace registered with `ctx.locale`. */
|
|
9
|
+
export declare const LOCALE_NAMESPACE = "dshRenderer";
|
|
10
|
+
/** Complete English baseline dictionary. */
|
|
11
|
+
export declare const EN_DICT: {
|
|
12
|
+
readonly title: 'Custom renderer';
|
|
13
|
+
readonly preview: 'Preview';
|
|
14
|
+
readonly code: 'Code';
|
|
15
|
+
readonly copy: 'Copy code';
|
|
16
|
+
readonly copied: 'Copied';
|
|
17
|
+
readonly wrap: 'Toggle word wrap';
|
|
18
|
+
readonly openWorkbench: 'Workbench';
|
|
19
|
+
readonly fullscreen: 'Fullscreen';
|
|
20
|
+
readonly close: 'Close';
|
|
21
|
+
readonly download: 'Download';
|
|
22
|
+
readonly zoomIn: 'Zoom in';
|
|
23
|
+
readonly zoomOut: 'Zoom out';
|
|
24
|
+
readonly zoomFit: 'Fit';
|
|
25
|
+
readonly checkerboard: 'Grid background';
|
|
26
|
+
readonly sleepingNotice: 'HTML sandbox paused to save memory.';
|
|
27
|
+
readonly wakeUp: 'Resume preview';
|
|
28
|
+
readonly oversizeNotice: 'Preview skipped: content exceeds the configured byte limit.';
|
|
29
|
+
readonly invalidSvg: 'Unable to render SVG markup; showing source code.';
|
|
30
|
+
readonly runtimeError: 'Sandbox script error';
|
|
31
|
+
readonly sandboxFrameTitle: 'Sandboxed HTML preview';
|
|
32
|
+
readonly svgPreviewAlt: 'Rendered SVG preview';
|
|
33
|
+
readonly artifactMissing: 'This preview artifact is no longer available in memory.';
|
|
34
|
+
readonly artifactLoading: 'Loading artifact…';
|
|
35
|
+
readonly artifactNotFound: 'This artifact could not be found in the session history.';
|
|
36
|
+
readonly artifactReceiptOpen: 'Open';
|
|
37
|
+
readonly artifactTabTitle: 'Preview';
|
|
38
|
+
readonly htmlDocument: 'HTML Document';
|
|
39
|
+
readonly svgDocument: 'SVG Graphic';
|
|
40
|
+
readonly markdownDocument: 'Markdown Document';
|
|
41
|
+
readonly codeDocument: '{lang} Document';
|
|
42
|
+
readonly generatingDocument: 'Generating document…';
|
|
43
|
+
readonly openDocumentNamed: 'Open document in sidebar: {title}';
|
|
44
|
+
readonly docMeta: '{type} · {lines} lines · {size}';
|
|
45
|
+
readonly docStreamingMeta: '{type} · Generating… · {lines} lines · {size}';
|
|
46
|
+
readonly docStreamingSizeMeta: '{type} · Generating… · {size}';
|
|
47
|
+
readonly docStreamingBareMeta: '{type} · Generating…';
|
|
48
|
+
readonly artifactError: 'Failed to render document';
|
|
49
|
+
readonly turnMediaHeading: 'Inline visual media';
|
|
50
|
+
readonly openImage: 'Inspect image';
|
|
51
|
+
};
|
|
52
|
+
/** Exact locale key union derived from {@link EN_DICT}. */
|
|
53
|
+
export type LocaleKey = keyof typeof EN_DICT;
|
|
54
|
+
/** Complete Chinese dictionary with identical keys to {@link EN_DICT}. */
|
|
55
|
+
export declare const ZH_DICT: Record<LocaleKey, string>;
|
|
56
|
+
/** Registered dictionary bundle handed to `ctx.locale.register`. */
|
|
57
|
+
export declare const DICTIONARIES: Record<'zh' | 'en', Record<LocaleKey, string>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive HTML sandbox iframe component (`Blob URL` + `sandbox="allow-scripts"`).
|
|
3
|
+
*
|
|
4
|
+
* Runs HTML previews directly in an opaque-origin iframe (never `allow-same-origin`),
|
|
5
|
+
* managed by {@link SandboxLruPool}, with token-verified `postMessage` auto-height,
|
|
6
|
+
* runtime error reporting, and live host theme synchronization.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-renderer/client/sandbox
|
|
9
|
+
*/
|
|
10
|
+
import type { ClientEnv } from './types.ts';
|
|
11
|
+
/** Props accepted by the HTML sandbox component. */
|
|
12
|
+
export interface HtmlSandboxProps {
|
|
13
|
+
readonly sandboxId: string;
|
|
14
|
+
readonly code: string;
|
|
15
|
+
readonly maxHeight: number;
|
|
16
|
+
readonly fillHeight?: boolean | undefined;
|
|
17
|
+
readonly visible?: boolean | undefined;
|
|
18
|
+
readonly onRuntimeError?: ((message: string | null) => void) | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Trigger a client-side file download for one HTML or SVG artifact. */
|
|
21
|
+
export declare function downloadTextFile(filename: string, content: string, mimeType: string): void;
|
|
22
|
+
/** Create the React component rendering interactive sandboxed HTML. */
|
|
23
|
+
export declare function createHtmlSandboxComponent(env: ClientEnv): (props: HtmlSandboxProps) => unknown;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scoped stylesheet aligned with DSH's native design system (`--dsw-alias-*`,
|
|
3
|
+
* `--dsw-radius-*`, `--dsw-font-family`, `--ds-font-family-code`).
|
|
4
|
+
*
|
|
5
|
+
* Visual rules matched to DSH's native `.md-code-block` and document preview:
|
|
6
|
+
* - Outer card uses `--dsw-radius-lg` (16px), `--dsw-alias-markdown-code-block`,
|
|
7
|
+
* and crisp `0.5px` `--dsw-alias-border-l2` hairlines.
|
|
8
|
+
* - Header matches native code-block banner height, typography, and padding.
|
|
9
|
+
* - Segmented Preview/Code toggle uses DSH's dedicated
|
|
10
|
+
* `--dsw-alias-markdown-code-segment-*` tokens.
|
|
11
|
+
* - Toolbar actions are borderless ghost icon buttons + soft blue tinted pill
|
|
12
|
+
* for interactive mode (no heavy black borders or box-inside-box clutter).
|
|
13
|
+
* - SVG zoom controls float cleanly in a compact pill matching `ImageBody`.
|
|
14
|
+
* - Fence root sets `margin: 0` so Chat's block container owns spacing.
|
|
15
|
+
*
|
|
16
|
+
* @module dsh-renderer/client/styles
|
|
17
|
+
*/
|
|
18
|
+
export declare const RENDERER_STYLES = "\n.dshr-card {\n margin: 0;\n border-radius: var(--dsw-radius-lg, 16px);\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-markdown-code-block, #f9fafb);\n color: var(--dsw-alias-label-primary, inherit);\n font-family: var(--dsw-font-family, system-ui, -apple-system, sans-serif);\n font-size: 13px;\n line-height: 1.5;\n overflow: hidden;\n}\n\n.dshr-toolbar {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n height: 40px;\n padding: 0 10px 0 16px;\n background: var(--dsw-alias-markdown-code-block-banner, var(--dsw-alias-markdown-code-block, #f9fafb));\n border-bottom: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.04));\n flex-wrap: nowrap;\n}\n\n.dshr-toolbar-group {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n\n.dshr-actions {\n display: inline-flex;\n align-items: center;\n gap: 2px;\n flex: none;\n}\n\n.dshr-lang {\n font-family: var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, monospace);\n font-size: 12px;\n line-height: 18px;\n font-weight: 500;\n color: var(--dsw-alias-label-tertiary, #81858c);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 240px;\n}\n\n.dshr-seg {\n display: inline-flex;\n align-items: center;\n gap: 2px;\n padding: 2px;\n border-radius: var(--dsw-radius-sm, 8px);\n background: var(--dsw-alias-markdown-code-segment-unselected, rgba(38, 49, 72, 0.06));\n}\n\n.dshr-seg-btn {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n padding: 2px 9px;\n border-radius: 6px;\n font-family: inherit;\n font-size: 12px;\n line-height: 18px;\n font-weight: 500;\n cursor: pointer;\n transition: background-color 0.14s ease, color 0.14s ease;\n}\n\n.dshr-seg-btn:hover:not([data-active=\"true\"]) {\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshr-seg-btn[data-active=\"true\"] {\n background: var(--dsw-alias-markdown-code-segment-selected, #ffffff);\n color: var(--dsw-alias-label-primary, inherit);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);\n}\n\n.dshr-icon-btn {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n border-radius: var(--dsw-radius-sm, 8px);\n cursor: pointer;\n transition: background-color 0.14s ease, color 0.14s ease;\n}\n\n.dshr-icon-btn:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06));\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshr-icon-btn[aria-pressed=\"true\"] {\n background: var(--dsw-alias-interactive-bg-active, rgba(38, 49, 72, 0.1));\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshr-btn {\n appearance: none;\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-button-floating-fill, var(--dsw-alias-bg-base, #ffffff));\n color: var(--dsw-alias-label-primary, inherit);\n padding: 5px 12px;\n border-radius: var(--dsw-radius-sm, 8px);\n font-family: inherit;\n font-size: 12px;\n line-height: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: background-color 0.14s ease;\n}\n\n.dshr-btn:hover {\n background: var(--dsw-alias-button-floating-hover, var(--dsw-alias-interactive-bg-hover));\n}\n\n.dshr-btn-accent {\n border-color: transparent;\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n color: var(--dsw-alias-state-business-primary, #4176e6);\n}\n\n.dshr-btn-accent:hover {\n background: var(--dsw-alias-state-business-tertiary, #e4edfd);\n opacity: 0.88;\n}\n\n.dshr-body {\n position: relative;\n background: var(--dsw-alias-bg-base, #ffffff);\n}\n\n.dshr-code-wrap {\n background: var(--dsw-alias-markdown-code-block, #f9fafb);\n}\n\n.dshr-code-wrap > * {\n margin: 0 !important;\n border: none !important;\n border-radius: 0 !important;\n box-shadow: none !important;\n}\n\n.dshr-code-scroll {\n overflow: auto;\n background: var(--shiki-background, var(--dsw-alias-markdown-code-block, #f9fafb));\n}\n\n.dshr-code-pre {\n margin: 0 !important;\n padding: 14px 16px;\n font-family: var(--ds-font-family-code, ui-monospace, SFMono-Regular, Menlo, monospace);\n font-size: 12.5px;\n line-height: 1.6;\n color: var(--shiki-foreground, var(--dsw-alias-label-primary, inherit));\n background: transparent;\n overflow: visible;\n white-space: pre;\n word-break: normal;\n overflow-wrap: normal;\n tab-size: 2;\n}\n\n.dshr-code-scroll[data-wrap=\"true\"] .dshr-code-pre {\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.dshr-code-inner {\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n background: transparent !important;\n border: none !important;\n padding: 0 !important;\n}\n\n.dshr-frame-host {\n position: relative;\n width: 100%;\n background: var(--dsw-alias-bg-base, #ffffff);\n overflow: hidden;\n contain: layout style;\n}\n\n.dshr-iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n background: var(--dsw-alias-bg-base, #ffffff);\n}\n\n.dshr-notice {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 8px 14px;\n font-size: 12px;\n color: var(--dsw-alias-label-secondary, #61666b);\n background: var(--dsw-alias-markdown-code-block, #f9fafb);\n border-bottom: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.04));\n}\n\n.dshr-error {\n padding: 8px 14px;\n font-size: 12px;\n color: var(--dsw-alias-state-error-primary, #ec1313);\n background: var(--dsw-alias-interactive-bg-hover-danger, rgba(236, 19, 19, 0.05));\n border-top: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));\n overflow-wrap: anywhere;\n}\n\n.dshr-sleeping {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 10px;\n padding: 28px 16px;\n color: var(--dsw-alias-label-secondary, #61666b);\n text-align: center;\n}\n\n.dshr-svg-wrap {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 0;\n background: var(--dsw-alias-bg-base, #ffffff);\n}\n\n.dshr-svg-stage {\n overflow: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 20px 16px 42px;\n min-height: 120px;\n}\n\n.dshr-svg-stage[data-checker=\"true\"] {\n background-image:\n linear-gradient(45deg, var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05)) 25%, transparent 25%),\n linear-gradient(-45deg, var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05)) 25%, transparent 25%),\n linear-gradient(45deg, transparent 75%, var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05)) 75%),\n linear-gradient(-45deg, transparent 75%, var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.05)) 75%);\n background-size: 16px 16px;\n background-position: 0 0, 0 8px, 8px -8px, -8px 0;\n}\n\n.dshr-svg-img {\n display: block;\n max-width: 100%;\n height: auto;\n border-radius: var(--dsw-radius-xs, 4px);\n user-select: none;\n}\n\n.dshr-svg-floating {\n position: absolute;\n right: 10px;\n bottom: 10px;\n display: inline-flex;\n align-items: center;\n gap: 2px;\n padding: 3px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-button-floating-fill, var(--dsw-alias-bg-base, #ffffff));\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);\n}\n\n.dshr-svg-divider {\n width: 1px;\n height: 14px;\n margin: 0 2px;\n background: var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n}\n\n.dshr-zoom-readout {\n appearance: none;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary, #61666b);\n min-width: 42px;\n height: 24px;\n padding: 0 6px;\n border-radius: 6px;\n font-family: inherit;\n font-size: 11px;\n line-height: 24px;\n text-align: center;\n cursor: pointer;\n transition: background-color 0.14s ease, color 0.14s ease;\n}\n\n.dshr-zoom-readout:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06));\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshr-svg-floating .dshr-icon-btn {\n width: 24px;\n height: 24px;\n border-radius: 6px;\n}\n\n.dshr-workbench {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--dsw-alias-bg-base, #ffffff);\n color: var(--dsw-alias-label-primary, inherit);\n font-family: var(--dsw-font-family, system-ui, -apple-system, sans-serif);\n}\n\n.dshr-workbench-title {\n font-family: inherit;\n font-size: 13px;\n line-height: 20px;\n font-weight: 500;\n color: var(--dsw-alias-label-primary, inherit);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 280px;\n}\n\n.dshr-tab-title-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n color: var(--dsw-alias-state-business-primary, #4176e6);\n}\n\n.dshr-doc-card {\n appearance: none;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 10px;\n min-width: 0;\n width: 100%;\n min-height: 60px;\n padding: 8px 12px 8px 10px;\n margin: 0;\n overflow: hidden;\n border: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));\n border-radius: var(--dsw-radius-lg, 16px);\n background: var(--dsw-alias-card-fill, var(--dsw-alias-markdown-code-block, #f9fafb));\n color: var(--dsw-alias-label-primary, inherit);\n font-family: var(--dsw-font-family, system-ui, -apple-system, sans-serif);\n text-align: left;\n cursor: pointer;\n transition: background-color 120ms ease, border-color 120ms ease;\n}\n\n@media (hover: hover) {\n .dshr-doc-card[data-dshr-state=\"ready\"]:hover {\n background: var(--dsw-alias-card-fill-hover, var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.06)));\n border-color: var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n }\n\n .dshr-doc-card[data-dshr-state=\"ready\"]:hover .dshr-doc-chevron {\n color: var(--dsw-alias-label-primary, inherit);\n transform: translateX(2px);\n }\n}\n\n.dshr-doc-card:focus-visible {\n outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary, #4176e6));\n outline-offset: 2px;\n}\n\n.dshr-doc-icon {\n box-sizing: border-box;\n flex: none;\n display: grid;\n place-items: center;\n width: 40px;\n height: 40px;\n border: 0.5px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, 0.06));\n border-radius: 10px;\n background: var(--dsw-alias-card-tile-fill, var(--dsw-alias-bg-base, #ffffff));\n color: var(--dsw-alias-state-business-primary, #4176e6);\n}\n\n.dshr-doc-details {\n display: flex;\n flex: 1;\n flex-direction: column;\n justify-content: center;\n gap: 2px;\n min-width: 0;\n}\n\n.dshr-doc-title {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n color: var(--dsw-alias-label-primary, inherit);\n}\n\n.dshr-doc-meta {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 11px;\n font-weight: 400;\n line-height: 16px;\n color: var(--dsw-alias-label-tertiary, #81858c);\n}\n\n.dshr-doc-card[data-dshr-state=\"streaming\"],\n.dshr-doc-card[data-dshr-state=\"error\"] {\n cursor: default;\n}\n\n.dshr-doc-card[data-dshr-state=\"error\"] {\n border-color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dshr-doc-card[data-dshr-state=\"error\"] .dshr-doc-icon,\n.dshr-doc-card[data-dshr-state=\"error\"] .dshr-doc-meta {\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n.dshr-tool-receipt {\n appearance: none;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: 100%;\n padding: 2px 6px;\n margin: 0;\n border: none;\n border-radius: 6px;\n background: transparent;\n color: var(--dsw-alias-label-tertiary, #81858c);\n font-family: var(--dsw-font-family, system-ui, -apple-system, sans-serif);\n font-size: 12px;\n line-height: 18px;\n text-align: left;\n cursor: pointer;\n transition: color 120ms ease, background-color 120ms ease;\n}\n\n.dshr-tool-receipt[data-dshr-state=\"streaming\"],\n.dshr-tool-receipt[data-dshr-state=\"error\"] {\n cursor: default;\n}\n\n.dshr-tool-receipt[data-dshr-state=\"error\"] {\n color: var(--dsw-alias-state-error-primary, #ec1313);\n}\n\n@media (hover: hover) {\n .dshr-tool-receipt[data-dshr-state=\"ready\"]:hover {\n color: var(--dsw-alias-label-primary, inherit);\n background: var(--dsw-alias-interactive-bg-hover, rgba(38, 49, 72, 0.05));\n }\n}\n\n.dshr-tool-receipt-title {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n}\n\n.dshr-tool-receipt-action {\n flex: none;\n font-size: 11px;\n color: var(--dsw-alias-state-business-primary, #4176e6);\n}\n\n@keyframes dshr-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.dshr-spinner {\n box-sizing: border-box;\n width: 15px;\n height: 15px;\n flex: none;\n border-radius: 50%;\n border: 1.75px solid var(--dsw-alias-border-l3, rgba(0, 0, 0, 0.14));\n border-top-color: var(--dsw-alias-state-business-primary, #4176e6);\n animation: dshr-spin 0.8s linear infinite;\n}\n\n.dshr-doc-chevron {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex: none;\n color: var(--dsw-alias-label-tertiary, #81858c);\n transition: color 120ms ease, transform 120ms ease;\n}\n\n.dshr-workbench-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n display: flex;\n flex-direction: column;\n background: var(--dsw-alias-bg-base, #ffffff);\n}\n\n.dshr-modal-backdrop {\n position: fixed;\n inset: 0;\n z-index: 1200;\n pointer-events: auto;\n background: var(--dsw-alias-bg-mask-1, rgba(0, 0, 0, 0.28));\n backdrop-filter: blur(4px);\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 24px;\n}\n\n.dshr-modal-panel {\n width: min(1120px, 94vw);\n height: min(820px, 90vh);\n border-radius: var(--dsw-radius-lg, 16px);\n overflow: hidden;\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.12));\n background: var(--dsw-alias-bg-base, #ffffff);\n box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);\n display: flex;\n flex-direction: column;\n}\n\n.dshr-turn-media {\n margin: 8px 0 0;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-md, 12px);\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-markdown-code-block, #f9fafb);\n font-family: var(--dsw-font-family, system-ui, -apple-system, sans-serif);\n}\n\n.dshr-turn-media-header {\n font-size: 11px;\n line-height: 16px;\n font-weight: 500;\n color: var(--dsw-alias-label-tertiary, #81858c);\n margin-bottom: 8px;\n}\n\n.dshr-turn-media-grid {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.dshr-turn-media-thumb {\n appearance: none;\n padding: 6px;\n border-radius: var(--dsw-radius-sm, 8px);\n border: 0.5px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.1));\n background: var(--dsw-alias-bg-base, #ffffff);\n cursor: pointer;\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n gap: 5px;\n max-width: 220px;\n transition: border-color 0.14s ease, box-shadow 0.14s ease;\n}\n\n.dshr-turn-media-thumb:hover {\n border-color: var(--dsw-alias-state-business-primary, #4176e6);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);\n}\n\n.dshr-turn-media-img {\n display: block;\n max-width: 208px;\n max-height: 150px;\n object-fit: contain;\n border-radius: var(--dsw-radius-xs, 4px);\n}\n\n.dshr-turn-media-caption {\n font-size: 11px;\n color: var(--dsw-alias-label-secondary, #61666b);\n max-width: 204px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.dshr-lightbox-img {\n display: block;\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n object-fit: contain;\n border-radius: var(--dsw-radius-sm, 8px);\n}\n";
|
|
19
|
+
/** Insert the plugin stylesheet into `document.head` and return a cleanup callback. */
|
|
20
|
+
export declare function injectRendererStyles(): () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe static SVG viewer rendered through an `<img>` Blob URL.
|
|
3
|
+
*
|
|
4
|
+
* Browsers strictly prohibit script execution and sub-resource fetches inside
|
|
5
|
+
* `<img src="blob:...">` SVG documents, matching DSH's `ImageBody` security model
|
|
6
|
+
* while preserving crisp vector scaling and floating zoom controls.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-renderer/client/svg-view
|
|
9
|
+
*/
|
|
10
|
+
import type { ClientEnv } from './types.ts';
|
|
11
|
+
/** Props accepted by the SVG viewer component. */
|
|
12
|
+
export interface SvgViewerProps {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
readonly maxHeight: number;
|
|
15
|
+
readonly fillHeight?: boolean | undefined;
|
|
16
|
+
readonly onInvalid?: (() => void) | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** Create the React component rendering sanitized SVG inside an `<img>` Blob URL. */
|
|
19
|
+
export declare function createSvgViewerComponent(env: ClientEnv): (props: SvgViewerProps) => unknown;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host theme token reader and `theme/change` subscription bridge for sandbox iframes.
|
|
3
|
+
*
|
|
4
|
+
* DSH defines `--dsw-alias-*` tokens on `body` and toggles dark mode through
|
|
5
|
+
* `body[data-ds-dark-theme]`. We sample `document.body` (falling back to
|
|
6
|
+
* `document.documentElement`) and watch both `theme/change` and body attributes
|
|
7
|
+
* so sandboxed iframes always stay synchronized with DSH's exact palette.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-renderer/client/theme
|
|
10
|
+
*/
|
|
11
|
+
import type { ClientContext, ClientThemeBridge } from './types.ts';
|
|
12
|
+
/**
|
|
13
|
+
* Create a live {@link ClientThemeBridge} tied to the plugin's Cordis lifecycle.
|
|
14
|
+
*
|
|
15
|
+
* Returns both the bridge and a `dispose` callback to register inside `ctx.effect`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createThemeBridge(ctx: ClientContext): {
|
|
18
|
+
readonly bridge: ClientThemeBridge;
|
|
19
|
+
readonly dispose: () => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-destructive `conversation.chat.turnTail` fallback rendering inline
|
|
3
|
+
* `data:image/*` URIs, raw `<img>` tags, and raw `<svg>` fragments emitted in
|
|
4
|
+
* Assistant prose outside code fences.
|
|
5
|
+
*
|
|
6
|
+
* @module dsh-renderer/client/turn-media
|
|
7
|
+
*/
|
|
8
|
+
import type { ClientEnv, TurnTailSlotProps } from './types.ts';
|
|
9
|
+
/** Create the React component registered into `conversation.chat.turnTail`. */
|
|
10
|
+
export declare function createTurnMediaComponent(env: ClientEnv): (props: TurnTailSlotProps) => unknown;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural browser runtime types for `@aqian0/dsh-renderer/client`.
|
|
3
|
+
*
|
|
4
|
+
* Keeps the client bundle free of `@types/react` and internal DSH UI package
|
|
5
|
+
* imports while maintaining strict TypeScript checking.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-renderer/client/types
|
|
8
|
+
*/
|
|
9
|
+
import type { RendererPluginConfig } from '../shared/config-defaults.ts';
|
|
10
|
+
import type { ArtifactKind, ArtifactRecord, ArtifactSessionAddress, ArtifactStore, SandboxLruPool } from '../shared/sandbox-core.ts';
|
|
11
|
+
import type { SandboxThemeTokens } from '../shared/sanitize.ts';
|
|
12
|
+
import type { LocaleKey } from './locales.ts';
|
|
13
|
+
/** Minimal structural subset of React 18 provided by DSH's browser module table. */
|
|
14
|
+
export interface ReactRuntime {
|
|
15
|
+
readonly Fragment: unknown;
|
|
16
|
+
createElement(type: unknown, props?: Record<string, unknown> | null, ...children: unknown[]): unknown;
|
|
17
|
+
useState<T>(initial: T | (() => T)): [T, (next: T | ((prev: T) => T)) => void];
|
|
18
|
+
useEffect(effect: () => void | (() => void), deps?: readonly unknown[]): void;
|
|
19
|
+
useMemo<T>(factory: () => T, deps: readonly unknown[]): T;
|
|
20
|
+
useCallback<T extends (...args: never[]) => unknown>(fn: T, deps: readonly unknown[]): T;
|
|
21
|
+
useRef<T>(initial: T): {
|
|
22
|
+
current: T;
|
|
23
|
+
};
|
|
24
|
+
useSyncExternalStore?<T>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => T): T;
|
|
25
|
+
}
|
|
26
|
+
/** Structural subset of the browser Cordis `slots` service. */
|
|
27
|
+
export interface ClientSlotsService {
|
|
28
|
+
inject(name: string, callback: () => unknown): () => void;
|
|
29
|
+
register(definition: Record<string, unknown>, component: unknown): () => void;
|
|
30
|
+
}
|
|
31
|
+
/** Structural subset of the browser Cordis `locale` service. */
|
|
32
|
+
export interface ClientLocaleService {
|
|
33
|
+
register(namespace: string, dictionaries: Record<string, Record<string, string>>): () => void;
|
|
34
|
+
bind(namespace: string): (key: string, params?: Record<string, unknown>) => string;
|
|
35
|
+
}
|
|
36
|
+
/** Structural subset of the browser Cordis `theme` service. */
|
|
37
|
+
export interface ClientThemeService {
|
|
38
|
+
getTheme?(): {
|
|
39
|
+
readonly resolved?: string;
|
|
40
|
+
readonly mode?: string;
|
|
41
|
+
readonly id?: string;
|
|
42
|
+
} | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Minimal observable snapshot interface shared across DSH client services. */
|
|
45
|
+
export interface ClientObservable<T> {
|
|
46
|
+
getSnapshot(): T;
|
|
47
|
+
subscribe(listener: () => void): () => void;
|
|
48
|
+
}
|
|
49
|
+
/** Structural subset of the optional right-Sidebar navigation service (`ctx.get('sidebarRight')`). */
|
|
50
|
+
export interface ClientSidebarRightService {
|
|
51
|
+
openResource(address: string, options?: Record<string, unknown>): void;
|
|
52
|
+
readonly mounted?: ClientObservable<string | undefined>;
|
|
53
|
+
}
|
|
54
|
+
/** Structural subset of the optional right-Sidebar tab registry (`ctx.get('sidebarRightTabs')`). */
|
|
55
|
+
export interface ClientSidebarRightTabsService {
|
|
56
|
+
register(definition: {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly kind: string;
|
|
59
|
+
readonly patterns?: readonly string[];
|
|
60
|
+
readonly priority?: 'extension' | 'builtin' | 'fallback';
|
|
61
|
+
readonly canOpen?: (address: string) => boolean;
|
|
62
|
+
readonly title: (address: string) => string;
|
|
63
|
+
readonly keepMounted?: boolean;
|
|
64
|
+
}): () => void;
|
|
65
|
+
}
|
|
66
|
+
/** Structural subset of DSH's `ctx.uiConversation` service (`@deepseek-ai/dsh-client-ui-conversation`). */
|
|
67
|
+
export interface ClientUiConversationService {
|
|
68
|
+
readonly events?: {
|
|
69
|
+
register(definition: Record<string, unknown>): () => void;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Structural subset of DSH's `ctx.sessions` service (`@deepseek-ai/dsh-client-ui-session`). */
|
|
73
|
+
export interface ClientSessionsService {
|
|
74
|
+
subagentAddress?(sessionId: string): {
|
|
75
|
+
readonly parentSessionId: string;
|
|
76
|
+
readonly childSessionId: string;
|
|
77
|
+
readonly mode: 'one-shot' | 'continuable' | 'unknown';
|
|
78
|
+
} | undefined;
|
|
79
|
+
}
|
|
80
|
+
/** Structural subset of DSH's `ctx.remote.session` read API for durable history recovery. */
|
|
81
|
+
export interface ClientSessionHistoryRemote {
|
|
82
|
+
events(input: {
|
|
83
|
+
readonly address: ArtifactSessionAddress;
|
|
84
|
+
}, signal?: AbortSignal): Promise<{
|
|
85
|
+
readonly ok: true;
|
|
86
|
+
readonly value: {
|
|
87
|
+
readonly cursor: number;
|
|
88
|
+
readonly hasMore: boolean;
|
|
89
|
+
readonly records: readonly {
|
|
90
|
+
readonly event: {
|
|
91
|
+
readonly type: string;
|
|
92
|
+
readonly seq: number;
|
|
93
|
+
readonly data: unknown;
|
|
94
|
+
};
|
|
95
|
+
}[];
|
|
96
|
+
};
|
|
97
|
+
} | {
|
|
98
|
+
readonly ok: false;
|
|
99
|
+
readonly error: {
|
|
100
|
+
readonly code?: string;
|
|
101
|
+
readonly message?: string;
|
|
102
|
+
};
|
|
103
|
+
}>;
|
|
104
|
+
page(input: {
|
|
105
|
+
readonly address: ArtifactSessionAddress;
|
|
106
|
+
readonly throughSeq: number;
|
|
107
|
+
readonly beforeSeq: number;
|
|
108
|
+
}, signal?: AbortSignal): Promise<{
|
|
109
|
+
readonly ok: true;
|
|
110
|
+
readonly value: {
|
|
111
|
+
readonly hasMore: boolean;
|
|
112
|
+
readonly records: readonly {
|
|
113
|
+
readonly event: {
|
|
114
|
+
readonly type: string;
|
|
115
|
+
readonly seq: number;
|
|
116
|
+
readonly data: unknown;
|
|
117
|
+
};
|
|
118
|
+
}[];
|
|
119
|
+
};
|
|
120
|
+
} | {
|
|
121
|
+
readonly ok: false;
|
|
122
|
+
readonly error: {
|
|
123
|
+
readonly code?: string;
|
|
124
|
+
readonly message?: string;
|
|
125
|
+
};
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
/** Structural subset of DSH's `ctx.remote` namespace container. */
|
|
129
|
+
export interface ClientRemoteService {
|
|
130
|
+
readonly session?: ClientSessionHistoryRemote;
|
|
131
|
+
}
|
|
132
|
+
/** Frame yielded by a `ctx.resources` provider stream. */
|
|
133
|
+
export type ClientResourceFrame<T = unknown> = {
|
|
134
|
+
readonly ok: true;
|
|
135
|
+
readonly value: T;
|
|
136
|
+
} | {
|
|
137
|
+
readonly ok: false;
|
|
138
|
+
readonly error: {
|
|
139
|
+
readonly code: string;
|
|
140
|
+
readonly message: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/** Structural subset of DSH's `ctx.resources` service (`@deepseek-ai/dsh-client-resources`). */
|
|
144
|
+
export interface ClientResourcesService {
|
|
145
|
+
register(provider: {
|
|
146
|
+
readonly protocol: string;
|
|
147
|
+
open(address: string, context: {
|
|
148
|
+
readonly signal: AbortSignal;
|
|
149
|
+
}): AsyncIterable<ClientResourceFrame<ArtifactRecord>>;
|
|
150
|
+
}): () => void;
|
|
151
|
+
}
|
|
152
|
+
/** Snapshot returned by DSH's root-injected `useResource(address)` hook. */
|
|
153
|
+
export interface ClientResourceSnapshot<T = unknown> {
|
|
154
|
+
readonly status: 'none' | 'loading' | 'live' | 'failed';
|
|
155
|
+
readonly value?: T | undefined;
|
|
156
|
+
readonly failure?: {
|
|
157
|
+
readonly code?: string;
|
|
158
|
+
readonly message?: string;
|
|
159
|
+
} | undefined;
|
|
160
|
+
}
|
|
161
|
+
/** Structural view of the browser Cordis plugin context. */
|
|
162
|
+
export interface ClientContext {
|
|
163
|
+
readonly slots?: ClientSlotsService;
|
|
164
|
+
readonly locale?: ClientLocaleService;
|
|
165
|
+
get?(name: string): unknown;
|
|
166
|
+
inject?(deps: readonly string[], callback: (ctx: ClientContext) => void): unknown;
|
|
167
|
+
on?(event: string, listener: (...args: unknown[]) => void): () => void;
|
|
168
|
+
effect?(body: () => unknown, label?: string): () => void;
|
|
169
|
+
}
|
|
170
|
+
/** Owner + standard props passed to `conversation.chat.markdown.fence` HOC layers. */
|
|
171
|
+
export interface FenceSlotProps {
|
|
172
|
+
readonly lang: string;
|
|
173
|
+
readonly code: string;
|
|
174
|
+
readonly streaming: boolean;
|
|
175
|
+
readonly meta?: string | undefined;
|
|
176
|
+
readonly children?: unknown;
|
|
177
|
+
readonly sessionId?: string | undefined;
|
|
178
|
+
}
|
|
179
|
+
/** Owner + standard props passed to `conversation.chat.turnTail` list entries. */
|
|
180
|
+
export interface TurnTailSlotProps {
|
|
181
|
+
readonly turn?: {
|
|
182
|
+
readonly turn?: number;
|
|
183
|
+
readonly status?: string;
|
|
184
|
+
};
|
|
185
|
+
readonly seq?: number;
|
|
186
|
+
readonly sessionId?: string | undefined;
|
|
187
|
+
readonly useChat?: <T>(selector: (snapshot: ChatSnapshotLike) => T) => T;
|
|
188
|
+
}
|
|
189
|
+
/** Minimal Chat snapshot slice read by the `turnTail` media fallback. */
|
|
190
|
+
export interface ChatSnapshotLike {
|
|
191
|
+
readonly locations?: {
|
|
192
|
+
getTurn?(turn: number): readonly string[];
|
|
193
|
+
};
|
|
194
|
+
readonly nodes?: {
|
|
195
|
+
get?(key: string): ChatNodeLike | undefined;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** Minimal Chat node shape inspected for settled Assistant text blocks. */
|
|
199
|
+
export interface ChatNodeLike {
|
|
200
|
+
readonly kind?: string;
|
|
201
|
+
readonly data?: {
|
|
202
|
+
readonly status?: string;
|
|
203
|
+
readonly blocks?: readonly {
|
|
204
|
+
readonly kind?: string;
|
|
205
|
+
readonly text?: string;
|
|
206
|
+
}[];
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/** Structural subset of DSH's `PartialArguments` lazy reader shared across tool phases. */
|
|
210
|
+
export interface PartialArgumentsLike {
|
|
211
|
+
has?(key: string): boolean;
|
|
212
|
+
complete?(key: string): boolean;
|
|
213
|
+
text?(key: string): string | undefined;
|
|
214
|
+
stringLength?(key: string, options?: {
|
|
215
|
+
readonly step?: number;
|
|
216
|
+
readonly offset?: number;
|
|
217
|
+
}): number | undefined;
|
|
218
|
+
}
|
|
219
|
+
/** Structural subset of `tool.call.toolview` owner + standard props across preparing/start/result. */
|
|
220
|
+
export interface ToolCallSlotProps {
|
|
221
|
+
readonly phase: 'preparing' | 'start' | 'result';
|
|
222
|
+
readonly callId: string;
|
|
223
|
+
readonly toolName: string;
|
|
224
|
+
readonly sessionId?: string | undefined;
|
|
225
|
+
readonly block: {
|
|
226
|
+
readonly callId?: string;
|
|
227
|
+
readonly kind?: string;
|
|
228
|
+
readonly name?: string;
|
|
229
|
+
readonly args?: PartialArgumentsLike;
|
|
230
|
+
readonly argsRaw?: string;
|
|
231
|
+
readonly call?: {
|
|
232
|
+
readonly name?: string;
|
|
233
|
+
readonly argsRaw?: string;
|
|
234
|
+
} | null;
|
|
235
|
+
readonly content?: readonly {
|
|
236
|
+
readonly type?: string;
|
|
237
|
+
readonly text?: string;
|
|
238
|
+
}[];
|
|
239
|
+
readonly isError?: boolean;
|
|
240
|
+
readonly error?: {
|
|
241
|
+
readonly name?: string;
|
|
242
|
+
readonly code?: string;
|
|
243
|
+
readonly reason?: string;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/** Props passed to `sidebar.right.pane.tab` and `sidebar.right.pane.tab.title` keyed entries. */
|
|
248
|
+
export interface SidebarRightTabProps {
|
|
249
|
+
readonly useTabInfo?: () => {
|
|
250
|
+
readonly tab?: {
|
|
251
|
+
readonly id?: string;
|
|
252
|
+
readonly title?: string;
|
|
253
|
+
readonly contentId?: string;
|
|
254
|
+
readonly visible?: boolean;
|
|
255
|
+
readonly navigation?: {
|
|
256
|
+
readonly address?: string;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
readonly useResource?: <T = ArtifactRecord>(address: string) => ClientResourceSnapshot<T>;
|
|
261
|
+
}
|
|
262
|
+
/** Theme observer facade shared across all Client components. */
|
|
263
|
+
export interface ClientThemeBridge {
|
|
264
|
+
getSnapshot(): SandboxThemeTokens;
|
|
265
|
+
subscribe(listener: () => void): () => void;
|
|
266
|
+
}
|
|
267
|
+
/** Shared client runtime environment passed into component factories. */
|
|
268
|
+
export interface ClientEnv {
|
|
269
|
+
readonly React: ReactRuntime;
|
|
270
|
+
readonly config: RendererPluginConfig;
|
|
271
|
+
readonly t: (key: LocaleKey, params?: Record<string, string | number>) => string;
|
|
272
|
+
readonly theme: ClientThemeBridge;
|
|
273
|
+
readonly sandboxPool: SandboxLruPool;
|
|
274
|
+
readonly artifacts: ArtifactStore;
|
|
275
|
+
readonly openArtifact: (input: {
|
|
276
|
+
readonly id?: string | undefined;
|
|
277
|
+
readonly address?: string | undefined;
|
|
278
|
+
readonly kind: ArtifactKind;
|
|
279
|
+
readonly lang?: string | undefined;
|
|
280
|
+
readonly title: string;
|
|
281
|
+
readonly code: string;
|
|
282
|
+
readonly sessionId?: string | undefined;
|
|
283
|
+
readonly destination?: 'sidebar' | 'float' | 'modal';
|
|
284
|
+
}) => void;
|
|
285
|
+
/** Build a durable `dsh-resource://dsh-renderer/call/...` address for one `render_artifact` invocation. */
|
|
286
|
+
readonly resolveCallAddress?: (sessionId: string | undefined, callId: string) => string | undefined;
|
|
287
|
+
/** Return whether `sessionId` currently owns the on-screen right Sidebar. */
|
|
288
|
+
readonly isSessionOnScreen?: (sessionId: string | undefined) => boolean;
|
|
289
|
+
/** Subscribe to on-screen Session changes (drives deferred live auto-open). */
|
|
290
|
+
readonly subscribeSessionOnScreen?: (listener: () => void) => () => void;
|
|
291
|
+
/** Return whether the standalone `dsh-renderer:artifact` Chat node definition is active. */
|
|
292
|
+
readonly isArtifactNodePromoted?: () => boolean;
|
|
293
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact workbench rendered either in DSH's right Sidebar (`sidebar.right.pane.tab`)
|
|
3
|
+
* or inside a fullscreen overlay modal (`shell.overlay`) when the Sidebar service
|
|
4
|
+
* is unavailable or the user explicitly requests Fullscreen.
|
|
5
|
+
*
|
|
6
|
+
* Supports interactive HTML previews, zoomable SVG previews, and full-height
|
|
7
|
+
* Shiki-highlighted code/document artifacts.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-renderer/client/workbench
|
|
10
|
+
*/
|
|
11
|
+
import { type ArtifactRecord } from '../shared/sandbox-core.ts';
|
|
12
|
+
import { type IconName } from './icons.ts';
|
|
13
|
+
import type { ClientContext, ClientEnv } from './types.ts';
|
|
14
|
+
/** Stable tab implementation id registered in `sidebarRightTabs` and `sidebar.right.pane.tab`. */
|
|
15
|
+
export declare const WORKBENCH_TAB_ID = "@aqian0/dsh-renderer/workbench";
|
|
16
|
+
/** Tab kind claimed by `@aqian0/dsh-renderer` for `dsh-resource://dsh-renderer/artifact/**`. */
|
|
17
|
+
export declare const WORKBENCH_TAB_KIND = "dsh-renderer:artifact";
|
|
18
|
+
/** Choose the tab/document icon matching an artifact's kind and language. */
|
|
19
|
+
export declare function iconForArtifact(record: ArtifactRecord | undefined): IconName;
|
|
20
|
+
/**
|
|
21
|
+
* Register the right-Sidebar workbench tab (when `sidebarRightTabs` is available)
|
|
22
|
+
* and the `shell.overlay` fullscreen modal fallback.
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerWorkbench(ctx: ClientContext, env: ClientEnv): () => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-renderer — browser half entry (bundled into a classic IIFE script).
|
|
3
|
+
*
|
|
4
|
+
* DSH serves third-party client plugins as classic scripts that register a lazy
|
|
5
|
+
* CommonJS factory through `window.__ModuleLoader__.load({ id, factory })`. The id
|
|
6
|
+
* must match this package's manifest name (`@aqian0/dsh-renderer`).
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-renderer/client
|
|
9
|
+
*/
|
|
10
|
+
export {};
|