@chatcode/cco-better-sidebar 0.18.0-alpha.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 +554 -0
- package/README_EN.md +563 -0
- package/assets/logo.svg +1 -0
- package/cordis.patch.yml +79 -0
- package/lib/client-editor.js +55744 -0
- package/lib/client-mermaid.js +208256 -0
- package/lib/client-registry.js +30378 -0
- package/lib/client-terminal.js +16894 -0
- package/lib/client.js +30378 -0
- package/lib/index.js +6897 -0
- package/lib/invariant.js +22 -0
- package/lib/types/agent-opens.d.ts +65 -0
- package/lib/types/agent-pty.d.ts +226 -0
- package/lib/types/browser-probe.d.ts +15 -0
- package/lib/types/bundle-route.d.ts +12 -0
- package/lib/types/chatcode-update.d.ts +47 -0
- package/lib/types/client/AccountMenu.d.ts +1 -0
- package/lib/types/client/AiRatioSection.d.ts +3 -0
- package/lib/types/client/BrowserView.d.ts +39 -0
- package/lib/types/client/ChatcodeGate.d.ts +6 -0
- package/lib/types/client/CodingPlanModelsSettings.d.ts +9 -0
- package/lib/types/client/DiffTab.d.ts +6 -0
- package/lib/types/client/DiffView.d.ts +51 -0
- package/lib/types/client/EditorHost.d.ts +13 -0
- package/lib/types/client/FenceErrorNotice.d.ts +5 -0
- package/lib/types/client/FileTree.d.ts +41 -0
- package/lib/types/client/FreeWindow.d.ts +29 -0
- package/lib/types/client/GitView.d.ts +12 -0
- package/lib/types/client/MarkdownHtml.d.ts +32 -0
- package/lib/types/client/OrphanedTab.d.ts +11 -0
- package/lib/types/client/PdfView.d.ts +6 -0
- package/lib/types/client/ReleaseNotesDialog.d.ts +11 -0
- package/lib/types/client/RenderBoundary.d.ts +32 -0
- package/lib/types/client/SandboxStatusBar.d.ts +10 -0
- package/lib/types/client/SideCardSection.d.ts +74 -0
- package/lib/types/client/Sidebar.d.ts +8 -0
- package/lib/types/client/TabBar.d.ts +54 -0
- package/lib/types/client/TerminalView.d.ts +24 -0
- package/lib/types/client/TextEditor.d.ts +10 -0
- package/lib/types/client/TreePanel.d.ts +27 -0
- package/lib/types/client/UpdateDialog.d.ts +10 -0
- package/lib/types/client/UpdateSettingsPanel.d.ts +1 -0
- package/lib/types/client/UpdateSettingsSection.d.ts +10 -0
- package/lib/types/client/UploadOverlay.d.ts +20 -0
- package/lib/types/client/UsageHeatmapSection.d.ts +4 -0
- package/lib/types/client/add-plugin-modal.d.ts +15 -0
- package/lib/types/client/api.d.ts +345 -0
- package/lib/types/client/binary-download.d.ts +12 -0
- package/lib/types/client/breakpoints.d.ts +17 -0
- package/lib/types/client/browser.d.ts +60 -0
- package/lib/types/client/builtins/index.d.ts +18 -0
- package/lib/types/client/builtins/tabs.d.ts +11 -0
- package/lib/types/client/builtins/viewers.d.ts +3 -0
- package/lib/types/client/chat-presentation.d.ts +13 -0
- package/lib/types/client/chunk-loader.d.ts +124 -0
- package/lib/types/client/chunks/editor.d.ts +9 -0
- package/lib/types/client/chunks/mermaid.d.ts +10 -0
- package/lib/types/client/chunks/terminal.d.ts +9 -0
- package/lib/types/client/cm-themes.d.ts +24 -0
- package/lib/types/client/conversation-draft.d.ts +14 -0
- package/lib/types/client/desktop-env.d.ts +35 -0
- package/lib/types/client/editor-load.d.ts +66 -0
- package/lib/types/client/frame-batcher.d.ts +24 -0
- package/lib/types/client/icons.d.ts +66 -0
- package/lib/types/client/image-types.d.ts +3 -0
- package/lib/types/client/ime-guard.d.ts +36 -0
- package/lib/types/client/index.d.ts +19 -0
- package/lib/types/client/intercept.d.ts +44 -0
- package/lib/types/client/lang.d.ts +14 -0
- package/lib/types/client/layout-push.d.ts +15 -0
- package/lib/types/client/lazy-chunk.d.ts +25 -0
- package/lib/types/client/link-intercept.d.ts +42 -0
- package/lib/types/client/locales-ar.d.ts +18 -0
- package/lib/types/client/locales-de.d.ts +4 -0
- package/lib/types/client/locales-fr.d.ts +10 -0
- package/lib/types/client/locales-hi.d.ts +17 -0
- package/lib/types/client/locales-id.d.ts +15 -0
- package/lib/types/client/locales-it.d.ts +8 -0
- package/lib/types/client/locales-ja.d.ts +17 -0
- package/lib/types/client/locales-ko.d.ts +9 -0
- package/lib/types/client/locales-nl.d.ts +16 -0
- package/lib/types/client/locales-pl.d.ts +19 -0
- package/lib/types/client/locales-pt.d.ts +1 -0
- package/lib/types/client/locales-ru.d.ts +13 -0
- package/lib/types/client/locales-sv.d.ts +1 -0
- package/lib/types/client/locales-th.d.ts +17 -0
- package/lib/types/client/locales-tr.d.ts +17 -0
- package/lib/types/client/locales-vi.d.ts +17 -0
- package/lib/types/client/locales-zh-HK.d.ts +32 -0
- package/lib/types/client/locales-zh-MO.d.ts +32 -0
- package/lib/types/client/locales-zh-TW.d.ts +32 -0
- package/lib/types/client/locales.d.ts +571 -0
- package/lib/types/client/markdown-html.d.ts +96 -0
- package/lib/types/client/markdown-images.d.ts +45 -0
- package/lib/types/client/markdown-labels.d.ts +21 -0
- package/lib/types/client/md-toc.d.ts +4 -0
- package/lib/types/client/mermaid-blocks.d.ts +47 -0
- package/lib/types/client/mermaid-sanitize.d.ts +2 -0
- package/lib/types/client/mermaid.d.ts +12 -0
- package/lib/types/client/open-when-sized.d.ts +20 -0
- package/lib/types/client/open-with-settings.d.ts +4 -0
- package/lib/types/client/open-with.d.ts +87 -0
- package/lib/types/client/openpath-intercept.d.ts +52 -0
- package/lib/types/client/paths.d.ts +43 -0
- package/lib/types/client/pdf-types.d.ts +2 -0
- package/lib/types/client/pinned.d.ts +86 -0
- package/lib/types/client/plugin-settings.d.ts +8 -0
- package/lib/types/client/plugins-shared.d.ts +27 -0
- package/lib/types/client/plugins-tabs.d.ts +3 -0
- package/lib/types/client/plugins-viewers.d.ts +3 -0
- package/lib/types/client/prefs.d.ts +41 -0
- package/lib/types/client/produced-files.d.ts +29 -0
- package/lib/types/client/selection-payload.d.ts +27 -0
- package/lib/types/client/service.d.ts +445 -0
- package/lib/types/client/session-pins.d.ts +14 -0
- package/lib/types/client/settings-nav-icon.d.ts +27 -0
- package/lib/types/client/shell-presets.d.ts +48 -0
- package/lib/types/client/split-pane.d.ts +38 -0
- package/lib/types/client/state.d.ts +480 -0
- package/lib/types/client/tab-content-memo.d.ts +40 -0
- package/lib/types/client/terminal-font.d.ts +78 -0
- package/lib/types/client/terminal-links.d.ts +119 -0
- package/lib/types/client/theme.d.ts +45 -0
- package/lib/types/client/titlebar-strip.d.ts +23 -0
- package/lib/types/client/ui-tweaks/appicons.d.ts +16 -0
- package/lib/types/client/ui-tweaks/archive.d.ts +42 -0
- package/lib/types/client/ui-tweaks/branding.d.ts +45 -0
- package/lib/types/client/ui-tweaks/cachehit.d.ts +41 -0
- package/lib/types/client/ui-tweaks/gitbar.d.ts +103 -0
- package/lib/types/client/ui-tweaks/index.d.ts +279 -0
- package/lib/types/client/ui-tweaks/mcp.d.ts +28 -0
- package/lib/types/client/ui-tweaks/notifier.d.ts +125 -0
- package/lib/types/client/ui-tweaks/whale.d.ts +55 -0
- package/lib/types/client/upload.d.ts +69 -0
- package/lib/types/client/useChatcodeAccount.d.ts +10 -0
- package/lib/types/client/wco.d.ts +47 -0
- package/lib/types/codingplan.d.ts +37 -0
- package/lib/types/config.d.ts +95 -0
- package/lib/types/context-types.d.ts +540 -0
- package/lib/types/fs-operations.d.ts +30 -0
- package/lib/types/fs-search.d.ts +24 -0
- package/lib/types/fs-tree.d.ts +51 -0
- package/lib/types/git.d.ts +124 -0
- package/lib/types/html-route.d.ts +59 -0
- package/lib/types/index.d.ts +47 -0
- package/lib/types/invariant.d.ts +15 -0
- package/lib/types/login-route.d.ts +2 -0
- package/lib/types/open-external.d.ts +24 -0
- package/lib/types/path-security.d.ts +26 -0
- package/lib/types/prefs-shared.d.ts +257 -0
- package/lib/types/pty-deps.d.ts +79 -0
- package/lib/types/pty-manager.d.ts +168 -0
- package/lib/types/tools.d.ts +34 -0
- package/lib/types/trust-fence.d.ts +24 -0
- package/lib/types/ui-tweaks/archive.d.ts +71 -0
- package/lib/types/ui-tweaks/config.d.ts +186 -0
- package/lib/types/ui-tweaks/git-web.d.ts +43 -0
- package/lib/types/ui-tweaks/git.d.ts +311 -0
- package/lib/types/ui-tweaks/index.d.ts +17 -0
- package/lib/types/ui-tweaks/mcp.d.ts +103 -0
- package/lib/types/ui-tweaks/turn-outcome.d.ts +57 -0
- package/lib/types/ui-tweaks/web.d.ts +55 -0
- package/lib/types/wire.d.ts +38 -0
- package/package.json +213 -0
- package/scripts/install.ps1 +310 -0
- package/scripts/install.sh +287 -0
- package/src/agent-opens.ts +265 -0
- package/src/agent-pty.ts +527 -0
- package/src/browser-probe.ts +26 -0
- package/src/bundle-route.ts +129 -0
- package/src/chatcode-update.ts +193 -0
- package/src/client/AccountMenu.tsx +177 -0
- package/src/client/AiRatioSection.module.css +329 -0
- package/src/client/AiRatioSection.tsx +292 -0
- package/src/client/BrowserView.tsx +289 -0
- package/src/client/ChatcodeGate.tsx +35 -0
- package/src/client/CodingPlanModelsSettings.module.css +118 -0
- package/src/client/CodingPlanModelsSettings.tsx +101 -0
- package/src/client/DiffTab.tsx +114 -0
- package/src/client/DiffView.tsx +305 -0
- package/src/client/EditorHost.tsx +563 -0
- package/src/client/FenceErrorNotice.tsx +40 -0
- package/src/client/FileTree.tsx +701 -0
- package/src/client/FreeWindow.tsx +337 -0
- package/src/client/GitView.tsx +722 -0
- package/src/client/MarkdownHtml.tsx +296 -0
- package/src/client/OrphanedTab.tsx +27 -0
- package/src/client/PdfView.tsx +110 -0
- package/src/client/ReleaseNotesDialog.tsx +91 -0
- package/src/client/RenderBoundary.tsx +49 -0
- package/src/client/SandboxStatusBar.tsx +60 -0
- package/src/client/SideCardSection.module.css +932 -0
- package/src/client/SideCardSection.tsx +1169 -0
- package/src/client/Sidebar.tsx +1857 -0
- package/src/client/TabBar.tsx +365 -0
- package/src/client/TerminalView.tsx +424 -0
- package/src/client/TextEditor.tsx +468 -0
- package/src/client/TreePanel.tsx +279 -0
- package/src/client/UpdateDialog.tsx +186 -0
- package/src/client/UpdateSettingsPanel.tsx +29 -0
- package/src/client/UpdateSettingsSection.tsx +22 -0
- package/src/client/UploadOverlay.tsx +62 -0
- package/src/client/UsageHeatmapSection.module.css +440 -0
- package/src/client/UsageHeatmapSection.tsx +301 -0
- package/src/client/add-plugin-modal.tsx +199 -0
- package/src/client/api.ts +433 -0
- package/src/client/binary-download.tsx +23 -0
- package/src/client/breakpoints.ts +61 -0
- package/src/client/browser.ts +167 -0
- package/src/client/builtins/index.ts +37 -0
- package/src/client/builtins/tabs.tsx +275 -0
- package/src/client/builtins/viewers.tsx +125 -0
- package/src/client/chat-presentation.ts +95 -0
- package/src/client/chunk-loader.ts +350 -0
- package/src/client/chunks/editor.tsx +9 -0
- package/src/client/chunks/mermaid.tsx +10 -0
- package/src/client/chunks/terminal.tsx +9 -0
- package/src/client/cm-themes.ts +129 -0
- package/src/client/conversation-draft.ts +29 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/desktop-env.ts +72 -0
- package/src/client/editor-load.ts +92 -0
- package/src/client/frame-batcher.ts +56 -0
- package/src/client/icons.tsx +170 -0
- package/src/client/image-types.ts +8 -0
- package/src/client/ime-guard.ts +47 -0
- package/src/client/index.tsx +501 -0
- package/src/client/intercept.tsx +172 -0
- package/src/client/lang.ts +225 -0
- package/src/client/layout-push.ts +37 -0
- package/src/client/layout.css +156 -0
- package/src/client/lazy-chunk.tsx +89 -0
- package/src/client/link-intercept.ts +73 -0
- package/src/client/locales-ar.ts +387 -0
- package/src/client/locales-de.ts +372 -0
- package/src/client/locales-fr.ts +379 -0
- package/src/client/locales-hi.ts +386 -0
- package/src/client/locales-id.ts +384 -0
- package/src/client/locales-it.ts +377 -0
- package/src/client/locales-ja.ts +486 -0
- package/src/client/locales-ko.ts +378 -0
- package/src/client/locales-nl.ts +384 -0
- package/src/client/locales-pl.ts +388 -0
- package/src/client/locales-pt.ts +369 -0
- package/src/client/locales-ru.ts +384 -0
- package/src/client/locales-sv.ts +369 -0
- package/src/client/locales-th.ts +386 -0
- package/src/client/locales-tr.ts +386 -0
- package/src/client/locales-vi.ts +386 -0
- package/src/client/locales-zh-HK.ts +401 -0
- package/src/client/locales-zh-MO.ts +401 -0
- package/src/client/locales-zh-TW.ts +401 -0
- package/src/client/locales.ts +1229 -0
- package/src/client/markdown-html.ts +331 -0
- package/src/client/markdown-images.ts +137 -0
- package/src/client/markdown-labels.tsx +31 -0
- package/src/client/md-toc.tsx +127 -0
- package/src/client/mermaid-blocks.ts +110 -0
- package/src/client/mermaid-sanitize.ts +93 -0
- package/src/client/mermaid.tsx +406 -0
- package/src/client/open-when-sized.ts +43 -0
- package/src/client/open-with-settings.tsx +135 -0
- package/src/client/open-with.ts +221 -0
- package/src/client/openpath-intercept.ts +79 -0
- package/src/client/paths.ts +63 -0
- package/src/client/pdf-types.ts +4 -0
- package/src/client/pinned.ts +184 -0
- package/src/client/plugin-settings.ts +43 -0
- package/src/client/plugins-shared.ts +29 -0
- package/src/client/plugins-tabs.ts +153 -0
- package/src/client/plugins-viewers.ts +44 -0
- package/src/client/prefs.ts +216 -0
- package/src/client/produced-files.ts +120 -0
- package/src/client/selection-payload.ts +86 -0
- package/src/client/service.ts +873 -0
- package/src/client/session-pins.tsx +334 -0
- package/src/client/settings-nav-icon.ts +55 -0
- package/src/client/shell-presets.ts +83 -0
- package/src/client/sidebar.module.css +3607 -0
- package/src/client/split-pane.tsx +333 -0
- package/src/client/state.ts +1646 -0
- package/src/client/tab-content-memo.ts +55 -0
- package/src/client/terminal-font.ts +224 -0
- package/src/client/terminal-links.ts +194 -0
- package/src/client/theme.ts +110 -0
- package/src/client/titlebar-strip.ts +37 -0
- package/src/client/ui-tweaks/appicons.ts +24 -0
- package/src/client/ui-tweaks/archive.tsx +281 -0
- package/src/client/ui-tweaks/branding.tsx +232 -0
- package/src/client/ui-tweaks/cachehit.tsx +122 -0
- package/src/client/ui-tweaks/gitbar.tsx +2559 -0
- package/src/client/ui-tweaks/index.tsx +1696 -0
- package/src/client/ui-tweaks/mcp.tsx +582 -0
- package/src/client/ui-tweaks/notifier.ts +514 -0
- package/src/client/ui-tweaks/whale.tsx +171 -0
- package/src/client/upload.ts +187 -0
- package/src/client/useChatcodeAccount.ts +103 -0
- package/src/client/wco.ts +120 -0
- package/src/codingplan.ts +146 -0
- package/src/config.ts +207 -0
- package/src/context-types.ts +559 -0
- package/src/fs-operations.ts +97 -0
- package/src/fs-search.ts +113 -0
- package/src/fs-tree.ts +158 -0
- package/src/git.ts +446 -0
- package/src/html-route.ts +106 -0
- package/src/index.ts +1524 -0
- package/src/invariant.ts +32 -0
- package/src/login-route.ts +26 -0
- package/src/open-external.ts +90 -0
- package/src/path-security.ts +81 -0
- package/src/prefs-shared.ts +303 -0
- package/src/pty-deps.ts +241 -0
- package/src/pty-manager.ts +376 -0
- package/src/tools.ts +482 -0
- package/src/trust-fence.ts +84 -0
- package/src/ui-tweaks/archive.ts +293 -0
- package/src/ui-tweaks/config.ts +257 -0
- package/src/ui-tweaks/git-web.ts +421 -0
- package/src/ui-tweaks/git.ts +1524 -0
- package/src/ui-tweaks/index.ts +61 -0
- package/src/ui-tweaks/mcp.ts +535 -0
- package/src/ui-tweaks/turn-outcome.ts +105 -0
- package/src/ui-tweaks/web.ts +225 -0
- package/src/wire.ts +110 -0
- package/vendor/addon-fit.js +2 -0
- package/vendor/xterm.css +218 -0
- package/vendor/xterm.js +5 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import type { BrowserProbeResult } from './browser.ts';
|
|
2
|
+
/** One wire failure. */
|
|
3
|
+
export declare class SidebarApiError extends Error {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
constructor(code: string, message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether a wire failure is the workspace fence refusing a path outside the
|
|
9
|
+
* session workspace (the host message reads `path "..." is outside
|
|
10
|
+
* workspace`). The request-trust fence answers code `forbidden` with the
|
|
11
|
+
* bare message 'forbidden', so the message fragment — not the code alone —
|
|
12
|
+
* identifies this case.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isOutsideWorkspaceError(error: unknown): boolean;
|
|
15
|
+
/** Message-level variant for surfaces that stored the raw text (file-tree level errors). */
|
|
16
|
+
export declare function isOutsideWorkspaceMessage(message: string): boolean;
|
|
17
|
+
/** Explorer row (host fs-tree shape). */
|
|
18
|
+
export interface FsEntry {
|
|
19
|
+
name: string;
|
|
20
|
+
path: string;
|
|
21
|
+
isDir: boolean;
|
|
22
|
+
hidden: boolean;
|
|
23
|
+
/** Whether the row is a symlink; `isDir` then describes the link's target. */
|
|
24
|
+
isSymlink: boolean;
|
|
25
|
+
/** For symlinks: the target is missing or unreadable (stat failed). */
|
|
26
|
+
broken: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Git status entry (host git shape). */
|
|
29
|
+
export interface GitStatusEntry {
|
|
30
|
+
path: string;
|
|
31
|
+
xy: string;
|
|
32
|
+
}
|
|
33
|
+
/** Git status snapshot. */
|
|
34
|
+
export interface GitStatusResult {
|
|
35
|
+
isRepo: boolean;
|
|
36
|
+
branch?: string;
|
|
37
|
+
entries: GitStatusEntry[];
|
|
38
|
+
/** True when the host capped `entries` (huge untracked set); the panel
|
|
39
|
+
* shows a truncation notice instead of freezing (#369). */
|
|
40
|
+
truncated?: boolean;
|
|
41
|
+
root?: string;
|
|
42
|
+
repositories?: string[];
|
|
43
|
+
}
|
|
44
|
+
/** One linked Git checkout. */
|
|
45
|
+
export interface GitWorktree {
|
|
46
|
+
path: string;
|
|
47
|
+
branch: string;
|
|
48
|
+
current: boolean;
|
|
49
|
+
changes: number;
|
|
50
|
+
}
|
|
51
|
+
/** One git log row. */
|
|
52
|
+
export interface GitLogEntry {
|
|
53
|
+
/** Short hash (7+ chars, display). */
|
|
54
|
+
hash: string;
|
|
55
|
+
/** Full 40-char hash (advanced operations). */
|
|
56
|
+
hashFull: string;
|
|
57
|
+
subject: string;
|
|
58
|
+
author: string;
|
|
59
|
+
/** ISO 8601 author date (`%ai`). */
|
|
60
|
+
date: string;
|
|
61
|
+
/** Ref decorations (--decorate=short), e.g. `HEAD -> main, origin/main`; '' when none. */
|
|
62
|
+
refs: string;
|
|
63
|
+
}
|
|
64
|
+
/** Text read result. */
|
|
65
|
+
export interface FsTextResult {
|
|
66
|
+
kind: 'text';
|
|
67
|
+
content: string;
|
|
68
|
+
truncated: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** Binary read result (no content; images load through the media route).
|
|
71
|
+
* `head` carries the first bytes (base64) for viewer detect sniffing. */
|
|
72
|
+
export interface FsBinaryResult {
|
|
73
|
+
kind: 'binary';
|
|
74
|
+
size: number;
|
|
75
|
+
truncated: boolean;
|
|
76
|
+
head: string;
|
|
77
|
+
}
|
|
78
|
+
/** Terminal dependency status (mirror of the host's depsStatus; issue #140). */
|
|
79
|
+
export type TerminalDepsStatus = {
|
|
80
|
+
ok: true;
|
|
81
|
+
} | {
|
|
82
|
+
ok: false;
|
|
83
|
+
/** The require-time error message (module missing, native binding broken…). */
|
|
84
|
+
cause: string;
|
|
85
|
+
/** The pasteable repair command (terminal/cmd). */
|
|
86
|
+
command: string;
|
|
87
|
+
/** The detected profile name (null when undetected → the command defaults to web). */
|
|
88
|
+
profile: string | null;
|
|
89
|
+
/** Optional supplementary hint (fallback command only). */
|
|
90
|
+
note?: string;
|
|
91
|
+
};
|
|
92
|
+
/** Display-only CodingPlan model returned by the sidebar host. Provider
|
|
93
|
+
* endpoints, protocol details, and API keys intentionally do not exist in
|
|
94
|
+
* this browser-facing type. */
|
|
95
|
+
export interface CodingPlanModel {
|
|
96
|
+
logicalModelId: string;
|
|
97
|
+
displayName: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
accessType?: string;
|
|
100
|
+
maxToken?: number;
|
|
101
|
+
contextWindow?: number;
|
|
102
|
+
}
|
|
103
|
+
/** Cached CodingPlan catalogue state. */
|
|
104
|
+
export interface CodingPlanCatalogue {
|
|
105
|
+
status: 'loading' | 'ready' | 'unavailable';
|
|
106
|
+
models: CodingPlanModel[];
|
|
107
|
+
fetchedAt?: string;
|
|
108
|
+
}
|
|
109
|
+
/** Browser-safe ChatCode account state returned by the optional host plugin. */
|
|
110
|
+
export interface ChatCodeAuthState {
|
|
111
|
+
required?: boolean;
|
|
112
|
+
validation?: 'valid' | 'invalid' | 'unavailable' | 'none';
|
|
113
|
+
login?: {
|
|
114
|
+
sessionId: string;
|
|
115
|
+
state: 'pending' | 'succeeded' | 'failed' | 'timed-out' | 'cancelled';
|
|
116
|
+
expiresAtMs: number;
|
|
117
|
+
};
|
|
118
|
+
available: boolean;
|
|
119
|
+
configured?: boolean;
|
|
120
|
+
expired?: boolean;
|
|
121
|
+
userName?: string;
|
|
122
|
+
emailAddress?: string;
|
|
123
|
+
}
|
|
124
|
+
/** One day of personal token usage (the platform userTokenTrend row). */
|
|
125
|
+
export interface ChatCodeTokenDay {
|
|
126
|
+
statDate: string;
|
|
127
|
+
tokensIn: number;
|
|
128
|
+
tokensOut: number;
|
|
129
|
+
totalTokens: number;
|
|
130
|
+
}
|
|
131
|
+
/** One personal commit record (the platform gitCommitRecord row; numeric
|
|
132
|
+
* fields are coerced defensively at render time). */
|
|
133
|
+
export interface ChatCodeCommitRecord {
|
|
134
|
+
projectName: string;
|
|
135
|
+
name: string;
|
|
136
|
+
email: string;
|
|
137
|
+
authorEmail: string;
|
|
138
|
+
additions: number;
|
|
139
|
+
deletions: number;
|
|
140
|
+
total: number;
|
|
141
|
+
aiTotal: number;
|
|
142
|
+
orgname: string;
|
|
143
|
+
deptname: string;
|
|
144
|
+
title: string;
|
|
145
|
+
shortId: string;
|
|
146
|
+
authoredDate: string;
|
|
147
|
+
}
|
|
148
|
+
/** Exact release note for the running package version. */
|
|
149
|
+
export interface ReleaseNoteResult {
|
|
150
|
+
registered: boolean;
|
|
151
|
+
release: null | {
|
|
152
|
+
id: number;
|
|
153
|
+
packageName: string;
|
|
154
|
+
versionNum: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
contentMd: string;
|
|
157
|
+
updatedAt?: string;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** The package the "update" section's action upgrades. */
|
|
161
|
+
export declare const CHATCODE_CLI_PKG = "@chatcode/chatcode-cli";
|
|
162
|
+
/** One package's version-check result (mirror of the host chatcode-update). */
|
|
163
|
+
export interface ChatCodeUpdateCheck {
|
|
164
|
+
packageName: string;
|
|
165
|
+
current: string | null;
|
|
166
|
+
latest: string | null;
|
|
167
|
+
needsUpdate: boolean;
|
|
168
|
+
}
|
|
169
|
+
/** One package's perform-update result (mirror of the host chatcode-update). */
|
|
170
|
+
export interface ChatCodeUpdateResult {
|
|
171
|
+
packageName: string;
|
|
172
|
+
from: string | null;
|
|
173
|
+
to: string | null;
|
|
174
|
+
ok: boolean;
|
|
175
|
+
message: string;
|
|
176
|
+
}
|
|
177
|
+
/** One request's session scope: the conversation id plus its cwd when known. */
|
|
178
|
+
export interface SessionScope {
|
|
179
|
+
sessionId: string;
|
|
180
|
+
/** The session's working directory from the client list summary (optional). */
|
|
181
|
+
cwd?: string;
|
|
182
|
+
/** Selected Git repository when cwd is a workspace container. */
|
|
183
|
+
repoRoot?: string;
|
|
184
|
+
}
|
|
185
|
+
/** The sidebar API surface (session scope threaded through every call). */
|
|
186
|
+
export declare const api: {
|
|
187
|
+
chatcodeStatus: (signal?: AbortSignal) => Promise<ChatCodeAuthState>;
|
|
188
|
+
chatcodeStart: () => Promise<{
|
|
189
|
+
sessionId: string;
|
|
190
|
+
url: string;
|
|
191
|
+
}>;
|
|
192
|
+
chatcodeCancel: (sessionId: string) => Promise<{
|
|
193
|
+
ok: true;
|
|
194
|
+
}>;
|
|
195
|
+
chatcodeLogout: () => Promise<{
|
|
196
|
+
ok: true;
|
|
197
|
+
}>;
|
|
198
|
+
/** Check both ChatCode packages (web + CLI) against the npm registry. */
|
|
199
|
+
chatcodeUpdateCheck: (signal?: AbortSignal) => Promise<{
|
|
200
|
+
packages: ChatCodeUpdateCheck[];
|
|
201
|
+
}>;
|
|
202
|
+
/** Upgrade both ChatCode packages to their npm-latest versions. */
|
|
203
|
+
chatcodeUpdatePerform: (signal?: AbortSignal) => Promise<{
|
|
204
|
+
results: ChatCodeUpdateResult[];
|
|
205
|
+
}>;
|
|
206
|
+
releaseNoteCurrent: (packageName: string, versionNum: string, signal?: AbortSignal) => Promise<ReleaseNoteResult>;
|
|
207
|
+
/** Per-day token usage of one day range (`YYYY-MM-DD`). */
|
|
208
|
+
chatcodeTokenTrend: (begin: string, end: string, signal?: AbortSignal) => Promise<ChatCodeTokenDay[]>;
|
|
209
|
+
/** Personal commit records of one day range (AI-ratio view). */
|
|
210
|
+
chatcodeGitCommitStats: (begin: string, end: string, signal?: AbortSignal) => Promise<ChatCodeCommitRecord[]>;
|
|
211
|
+
sessionCwd: (scope: SessionScope, signal?: AbortSignal) => Promise<{
|
|
212
|
+
sessionId: string;
|
|
213
|
+
cwd: string;
|
|
214
|
+
root: string;
|
|
215
|
+
parent: string | null;
|
|
216
|
+
}>;
|
|
217
|
+
fsTree: (scope: SessionScope, path: string, signal?: AbortSignal) => Promise<{
|
|
218
|
+
path: string;
|
|
219
|
+
entries: FsEntry[];
|
|
220
|
+
truncated: boolean;
|
|
221
|
+
}>;
|
|
222
|
+
/** Global recursive file-name search rooted at the session cwd (the editor
|
|
223
|
+
* side panel's search box); matches are cwd-relative '/'-separated paths. */
|
|
224
|
+
fsSearch: (scope: SessionScope, query: string, signal?: AbortSignal) => Promise<{
|
|
225
|
+
matches: string[];
|
|
226
|
+
truncated: boolean;
|
|
227
|
+
}>;
|
|
228
|
+
fsRead: (scope: SessionScope, path: string, signal?: AbortSignal) => Promise<FsTextResult | FsBinaryResult>;
|
|
229
|
+
fsWrite: (scope: SessionScope, path: string, content: string) => Promise<{
|
|
230
|
+
ok: true;
|
|
231
|
+
}>;
|
|
232
|
+
/** Upload one file's raw bytes into `dir` (keeps the folder tree via
|
|
233
|
+
* `relativePath`); the host streams it under the session workspace. */
|
|
234
|
+
uploadFile: (scope: SessionScope, dir: string, relativePath: string, body: Blob, signal?: AbortSignal) => Promise<{
|
|
235
|
+
path: string;
|
|
236
|
+
size: number;
|
|
237
|
+
}>;
|
|
238
|
+
gitWorktrees: (scope: SessionScope, signal?: AbortSignal) => Promise<GitWorktree[]>;
|
|
239
|
+
gitStatus: (scope: SessionScope, worktree?: string, signal?: AbortSignal) => Promise<GitStatusResult>;
|
|
240
|
+
gitDiff: (scope: SessionScope, path: string | undefined, staged: boolean, worktree?: string, signal?: AbortSignal) => Promise<{
|
|
241
|
+
diff: string;
|
|
242
|
+
}>;
|
|
243
|
+
gitStage: (scope: SessionScope, path?: string, worktree?: string) => Promise<{
|
|
244
|
+
ok: true;
|
|
245
|
+
}>;
|
|
246
|
+
gitUnstage: (scope: SessionScope, path?: string, worktree?: string) => Promise<{
|
|
247
|
+
ok: true;
|
|
248
|
+
}>;
|
|
249
|
+
gitCommit: (scope: SessionScope, message: string, worktree?: string) => Promise<{
|
|
250
|
+
ok: true;
|
|
251
|
+
}>;
|
|
252
|
+
gitBranch: (scope: SessionScope, worktree?: string, signal?: AbortSignal) => Promise<{
|
|
253
|
+
current: string;
|
|
254
|
+
names: string[];
|
|
255
|
+
}>;
|
|
256
|
+
gitCheckout: (scope: SessionScope, branch: string, worktree?: string) => Promise<{
|
|
257
|
+
ok: true;
|
|
258
|
+
}>;
|
|
259
|
+
/** Recent commit history, lazily pageable (skip/count; defaults 0/30). */
|
|
260
|
+
gitLog: (scope: SessionScope, count?: number, skip?: number, worktree?: string, signal?: AbortSignal) => Promise<GitLogEntry[]>;
|
|
261
|
+
/** Full patch text of one commit (diff display for the history rows). */
|
|
262
|
+
gitCommitDiff: (scope: SessionScope, hash: string, worktree?: string, signal?: AbortSignal) => Promise<{
|
|
263
|
+
diff: string;
|
|
264
|
+
}>;
|
|
265
|
+
/** Discard the worktree changes of one file (the index is untouched). */
|
|
266
|
+
gitDiscard: (scope: SessionScope, path: string, worktree?: string) => Promise<{
|
|
267
|
+
ok: true;
|
|
268
|
+
}>;
|
|
269
|
+
/** Revert one commit onto the current branch. */
|
|
270
|
+
gitRevert: (scope: SessionScope, hash: string, worktree?: string) => Promise<{
|
|
271
|
+
ok: true;
|
|
272
|
+
}>;
|
|
273
|
+
/** Cherry-pick one commit onto the current branch. */
|
|
274
|
+
gitCherryPick: (scope: SessionScope, hash: string, worktree?: string) => Promise<{
|
|
275
|
+
ok: true;
|
|
276
|
+
}>;
|
|
277
|
+
/** Release a terminal's process immediately (tab closed; the WS close frame
|
|
278
|
+
* may be unreachable while the socket is down, so the host also accepts
|
|
279
|
+
* this explicit route). */
|
|
280
|
+
ptyClose: (scope: SessionScope, tab: string) => Promise<{
|
|
281
|
+
ok: true;
|
|
282
|
+
}>;
|
|
283
|
+
/** Release an agent terminal by uuid (tab closed while WS was down). */
|
|
284
|
+
agentPtyClose: (uuid: string) => Promise<{
|
|
285
|
+
ok: true;
|
|
286
|
+
}>;
|
|
287
|
+
/** Terminal dependency status (issue #140): after a WS close 1011 with
|
|
288
|
+
* reason `pty-deps-missing` the view fetches the full repair details here
|
|
289
|
+
* (the close reason itself is capped at 123 bytes). */
|
|
290
|
+
terminalDeps: () => Promise<TerminalDepsStatus>;
|
|
291
|
+
/** The effective terminal shell and its display name (plugin-global). */
|
|
292
|
+
shellGet: () => Promise<{
|
|
293
|
+
shell: string;
|
|
294
|
+
name: string;
|
|
295
|
+
}>;
|
|
296
|
+
/** The local display name used by the bottom-left account menu. */
|
|
297
|
+
accountGet: () => Promise<{
|
|
298
|
+
userName: string;
|
|
299
|
+
}>;
|
|
300
|
+
/** Read the host-cached CodingPlan model catalogue. */
|
|
301
|
+
codingPlanModels: () => Promise<CodingPlanCatalogue>;
|
|
302
|
+
/** Refresh the host-cached CodingPlan catalogue. */
|
|
303
|
+
codingPlanRefresh: () => Promise<CodingPlanCatalogue>;
|
|
304
|
+
/** Read the side card preferences (plugin-global, no session scope). */
|
|
305
|
+
settingsGet: () => Promise<{
|
|
306
|
+
value?: unknown;
|
|
307
|
+
revision?: number;
|
|
308
|
+
externalDisable?: boolean;
|
|
309
|
+
}>;
|
|
310
|
+
/** Merge a patch into the side card preferences (revision-guarded). */
|
|
311
|
+
settingsUpdate: (patch: Record<string, unknown>, expectedRevision?: number) => Promise<{
|
|
312
|
+
value?: unknown;
|
|
313
|
+
revision?: number;
|
|
314
|
+
}>;
|
|
315
|
+
/** Probe a URL's response headers (the sidebar browser's embeddability
|
|
316
|
+
* check; see the host's browser.probe route). */
|
|
317
|
+
browserProbe: (url: string, signal?: AbortSignal) => Promise<BrowserProbeResult>;
|
|
318
|
+
/** External open for the file tree's "open with" menu: reveal a path in
|
|
319
|
+
* the OS file manager, or hand a custom-scheme URL (vscode://, cursor://,
|
|
320
|
+
* zed://, custom editors) to its registered handler. The host launches
|
|
321
|
+
* the platform opener (argv, no shell). */
|
|
322
|
+
openExternal: (payload: {
|
|
323
|
+
action: "reveal";
|
|
324
|
+
path: string;
|
|
325
|
+
} | {
|
|
326
|
+
action: "url";
|
|
327
|
+
url: string;
|
|
328
|
+
}) => Promise<{
|
|
329
|
+
started: boolean;
|
|
330
|
+
}>;
|
|
331
|
+
};
|
|
332
|
+
/** Absolute URL of the media route for one path (images only). */
|
|
333
|
+
export declare function mediaUrl(scope: SessionScope, path: string): string;
|
|
334
|
+
/** Absolute URL of the download route: serves raw bytes (binary-safe) with
|
|
335
|
+
* `Content-Disposition: attachment`, so the browser saves the file. */
|
|
336
|
+
export declare function downloadUrl(scope: SessionScope, path: string): string;
|
|
337
|
+
/**
|
|
338
|
+
* Absolute URL of the HTML preview route (see html-route.ts): the path is
|
|
339
|
+
* fully encoded so the previewed page's relative assets resolve back into
|
|
340
|
+
* the same route with the session scope intact. The UNC marker is
|
|
341
|
+
* platform-neutral — the host's requireAbsolute resolves the decoded
|
|
342
|
+
* forward-slash `//server/share/...` form on both win32 and POSIX — so no
|
|
343
|
+
* client-side platform signal is needed.
|
|
344
|
+
*/
|
|
345
|
+
export declare function htmlUrl(scope: SessionScope, path: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "no preview — download instead" pane: shown by the editor host when no
|
|
3
|
+
* viewer can render a file (binary without a registered renderer, or the
|
|
4
|
+
* `binary-download` strategy) and registered as the `binary-download` viewer
|
|
5
|
+
* component so the declarative route and the host fallback share one UI.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
import type { SessionScope } from './api.ts';
|
|
9
|
+
export declare function BinaryDownload(props: {
|
|
10
|
+
scope: SessionScope;
|
|
11
|
+
path: string;
|
|
12
|
+
}): ReactNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Viewport widths strictly below this are "mobile" (paired CSS: max-width: 767px). */
|
|
2
|
+
export declare const NARROW_MAX_WIDTH = 768;
|
|
3
|
+
/** Whether a viewport width is narrow (mobile). */
|
|
4
|
+
export declare function isNarrowWidth(width: number): boolean;
|
|
5
|
+
export interface ViewportSize {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Live narrow-viewport flag for components. Reads `window.innerWidth` and
|
|
11
|
+
* re-measures on resize (rAF-throttled, the repo's existing drag pattern).
|
|
12
|
+
* Deliberately avoids `matchMedia` (jsdom does not implement it) — the
|
|
13
|
+
* resize listener is equally exact for a breakpoint that never changes
|
|
14
|
+
* while the page is open.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useViewportSize(): ViewportSize;
|
|
17
|
+
export declare function useNarrowViewport(): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure URL policy for the built-in browser tab: normalize user input into
|
|
3
|
+
* an http(s) URL, and refuse destinations that would be dangerous to embed
|
|
4
|
+
* in the sidebar iframe. Kept dependency-free so it is unit-testable.
|
|
5
|
+
*
|
|
6
|
+
* The iframe sandbox (opaque origin, no allow-same-origin / top-navigation)
|
|
7
|
+
* is the primary security boundary; this module is the address-bar gate on
|
|
8
|
+
* top of it: only http/https may be navigated, and loopback addresses are
|
|
9
|
+
* refused so a browsed page cannot probe local services by user action.
|
|
10
|
+
* The GUI's OWN origin is explicitly ALLOWED — the user may open the GUI
|
|
11
|
+
* itself in the sidebar (debugging, mirroring); the sandbox still renders
|
|
12
|
+
* it in an opaque origin with no same-origin privileges, exactly like any
|
|
13
|
+
* other site.
|
|
14
|
+
*/
|
|
15
|
+
/** Why a navigation attempt was refused. */
|
|
16
|
+
export type BrowserBlockReason = 'scheme' | 'loopback';
|
|
17
|
+
/** Result of normalizing one address-bar input. */
|
|
18
|
+
export type BrowserNavigateResult = {
|
|
19
|
+
kind: 'ok';
|
|
20
|
+
url: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'blocked';
|
|
23
|
+
reason: BrowserBlockReason;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'invalid';
|
|
26
|
+
};
|
|
27
|
+
/** One browser.probe wire result (host fetch of the target's headers). */
|
|
28
|
+
export interface BrowserProbeResult {
|
|
29
|
+
reachable: boolean;
|
|
30
|
+
/** The final (post-redirect) URL; present when reachable. */
|
|
31
|
+
url?: string;
|
|
32
|
+
status?: number;
|
|
33
|
+
xFrameOptions?: string;
|
|
34
|
+
/** The CSP frame-ancestors source list; present when the directive exists. */
|
|
35
|
+
frameAncestors?: string[];
|
|
36
|
+
}
|
|
37
|
+
/** Embeddability verdict of one probe. */
|
|
38
|
+
export type Embeddability = 'embeddable' | 'blocked' | 'unknown';
|
|
39
|
+
/**
|
|
40
|
+
* Decide whether a site can render inside the sidebar iframe. The signals
|
|
41
|
+
* are exactly the ones the BROWSER enforces when it refuses an iframe load:
|
|
42
|
+
* X-Frame-Options DENY/SAMEORIGIN, or a frame-ancestors directive that does
|
|
43
|
+
* not allow `*` ('self' here means the SITE's own origin — never ours, so
|
|
44
|
+
* it also blocks the sidebar). A site we could not reach yields 'unknown'
|
|
45
|
+
* and the plain iframe stays.
|
|
46
|
+
*/
|
|
47
|
+
export declare function embeddabilityOf(probe: BrowserProbeResult): Embeddability;
|
|
48
|
+
/** A loopback hostname (localhost, IPv6 ::1, 127.0.0.0/8, 0.0.0.0). */
|
|
49
|
+
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
50
|
+
/** Parse the loopback allowlist into a matcher predicate over host:port. */
|
|
51
|
+
export declare function parseLoopbackAllowlist(allowlist: string): (host: string, port: string) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a loopback URL is explicitly allowlisted by the side card prefs
|
|
54
|
+
* (`browserAllowedLoopback`). Only allowlisted local addresses may run with
|
|
55
|
+
* `allow-same-origin` in the sidebar iframe — needed for local dev servers
|
|
56
|
+
* (Vite etc.) whose module/HMR/fetch pipeline requires a real origin, while
|
|
57
|
+
* the page stays cross-origin to the GUI and to every other site.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isAllowedLoopbackUrl(url: string, allowlist: string): boolean;
|
|
60
|
+
export declare function normalizeBrowserUrl(input: string, selfOrigin: string, allowedLoopback?: string): BrowserNavigateResult;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in registration: the plugin registers its own tab pages and file
|
|
3
|
+
* previewers through the same {@link BetterSidebarService} external plugins
|
|
4
|
+
* use — eating its own dogfood. The descriptors live next to their feature
|
|
5
|
+
* modules (tabs.tsx / viewers.tsx); this module only aggregates them and
|
|
6
|
+
* owns the disposer lifecycle (cordis auto-invokes it on fiber disposal,
|
|
7
|
+
* HMR-safe).
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '../../context-types.ts';
|
|
10
|
+
import type { BetterSidebarService } from '../service.ts';
|
|
11
|
+
import { type BuiltinTabOptions } from './tabs.tsx';
|
|
12
|
+
/**
|
|
13
|
+
* Register all built-in tabs and viewers with the service. Returns a
|
|
14
|
+
* disposer that unregisters everything (cordis auto-invokes it on fiber
|
|
15
|
+
* disposal). The `ctx` is threaded into tab descriptors that need it
|
|
16
|
+
* (EditorHost reads `ctx.betterSidebar` for file-viewer matching).
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerBuiltins(ctx: Context, service: BetterSidebarService, options?: BuiltinTabOptions): () => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '../../context-types.ts';
|
|
2
|
+
import type { TabDescriptor } from '../service.ts';
|
|
3
|
+
/** How many UI-owned terminals may be open at once (agent-owned ones are uncapped). */
|
|
4
|
+
export declare const TERMINAL_LIMIT = 3;
|
|
5
|
+
/** Optional per-registration builtin behavior (currently terminal title). */
|
|
6
|
+
export interface BuiltinTabOptions {
|
|
7
|
+
/** Returns the display title for newly opened terminal tabs. */
|
|
8
|
+
terminalTitle?: () => string;
|
|
9
|
+
}
|
|
10
|
+
/** The 5 built-in tab descriptors. */
|
|
11
|
+
export declare function builtinTabs(ctx: Context, options?: BuiltinTabOptions): readonly TabDescriptor[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrow compatibility polish for the host Chat surface.
|
|
3
|
+
*
|
|
4
|
+
* DSH does not currently expose extension seats for the running-status copy
|
|
5
|
+
* or for suppressing one producer's context row. Keep the adaptation at the
|
|
6
|
+
* rendered DOM boundary, keyed by stable semantics (`role=status` and the
|
|
7
|
+
* context producer marker), and make every mutation reversible on unload.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Apply the Chat presentation compatibility layer and observe late React
|
|
11
|
+
* mounts/updates. The disposer restores every row hidden by this activation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerChatPresentationCompatibility(): () => void;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy chunk loader for the client bundle. The heavy preview/terminal
|
|
3
|
+
* libraries (CodeMirror, xterm — the editor/terminal stacks, several MB)
|
|
4
|
+
* live in separate build-time bundles (`lib/client-<name>.js`) fetched only
|
|
5
|
+
* on first use of the feature that needs them, so startup downloads/parses
|
|
6
|
+
* only the ~1MB core bundle. (The office stack — Univer / docx-preview /
|
|
7
|
+
* pptx-renderer — is no longer bundled here: Office previews moved to the
|
|
8
|
+
* recommended office plugin, see plugins-viewers.ts.)
|
|
9
|
+
*
|
|
10
|
+
* How a chunk script works (see tsdown.config.ts chunkBundle):
|
|
11
|
+
*
|
|
12
|
+
* globalThis.__dshChunks__ = globalThis.__dshChunks__ || {};
|
|
13
|
+
* globalThis.__dshChunks__["terminal"] = (require) => { ...exports };
|
|
14
|
+
*
|
|
15
|
+
* The script registers its factory on a plugin-owned global registry (NOT
|
|
16
|
+
* through window.__ModuleLoader__.load — the module loader's import() only
|
|
17
|
+
* resolves seed words, shell-own modules, registered factories, and boot
|
|
18
|
+
* graph rows; a chunk id is none of those, so resolution would be version-
|
|
19
|
+
* dependent). Materialization is plugin-owned:
|
|
20
|
+
*
|
|
21
|
+
* 1. inject <script src="/sidebar/bundle/<name>.js"> (classic same-origin
|
|
22
|
+
* script; the official /plugins/<id>/client.js route cannot serve
|
|
23
|
+
* arbitrary file names, so the plugin's own host route serves the chunks),
|
|
24
|
+
* 2. read the factory from the global registry,
|
|
25
|
+
* 3. call it with a require that resolves the platform externals through
|
|
26
|
+
* `__DSH_MODULES__.import(spec)` — the seed-word branch, the one part of
|
|
27
|
+
* the module system that is stable across versions.
|
|
28
|
+
*
|
|
29
|
+
* Caching contract (three layers, each with a failure path):
|
|
30
|
+
* - In-memory: one in-flight promise per chunk, memoized until
|
|
31
|
+
* {@link resetChunks}; a failed load removes its entry so the next call
|
|
32
|
+
* retries from scratch. HMR re-activation keeps the resolved exports of
|
|
33
|
+
* unchanged chunks (ETag revalidation via
|
|
34
|
+
* {@link revalidateChunksOnReactivate}) — the next lazy open skips the
|
|
35
|
+
* re-inject / re-execute.
|
|
36
|
+
* - Script execution: each re-execution overwrites the global registry slot
|
|
37
|
+
* (assignment, never registration) — no "duplicate factory registration"
|
|
38
|
+
* class of errors; a failed materialization clears the cache so the retry
|
|
39
|
+
* re-injects and re-executes.
|
|
40
|
+
* - HTTP: the bundle route revalidates every request (`cache-control:
|
|
41
|
+
* no-cache` + ETag, 304 when unchanged), so page refreshes and HMR
|
|
42
|
+
* re-activations never re-download a multi-MB chunk that did not change.
|
|
43
|
+
*
|
|
44
|
+
* HMR: each plugin activation calls {@link revalidateChunksOnReactivate},
|
|
45
|
+
* which HEADs every loaded chunk against the bundle route and keeps the
|
|
46
|
+
* in-memory cache for the ones whose ETag is unchanged (a hot-reloaded core
|
|
47
|
+
* bundle therefore does not re-execute multi-MB chunk scripts). Chunk-only
|
|
48
|
+
* source edits still need a manual page refresh (the HMR poll watches only
|
|
49
|
+
* client.js); an edit that does land while a core HMR happens is caught by
|
|
50
|
+
* the ETag comparison on the next activation.
|
|
51
|
+
*/
|
|
52
|
+
export type ChunkName = 'terminal' | 'editor' | 'mermaid';
|
|
53
|
+
/** The module exports a chunk factory provides (namespace-ish record). */
|
|
54
|
+
export type ChunkExports = Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* The platform externals a chunk bundle may require (mirror of
|
|
57
|
+
* CLIENT_EXTERNALS in tsdown.config.ts — the chunk builds keep these
|
|
58
|
+
* external and the loader resolves them here). A superset is safe: the
|
|
59
|
+
* require only answers what the chunk actually asks for. The shell's static
|
|
60
|
+
* module table seeds React, Cordis, and the UI libraries (primitives/slots).
|
|
61
|
+
* `@deepseek-ai/dsh-client-runtime` was removed upstream in DSH 0.1.2-alpha
|
|
62
|
+
* (its seed row became bare-name `@deepseek-ai/dsh-client-store`) and no
|
|
63
|
+
* chunk ever required it, so its row is gone; so are dsh-client-web-react /
|
|
64
|
+
* dsh-client-schema-form, dropped back in DSH 0.1.0-rc.8.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CHUNK_EXTERNALS: readonly string[];
|
|
67
|
+
/**
|
|
68
|
+
* The client module system surface this loader needs to resolve externals.
|
|
69
|
+
* DSH 0.1.0-rc.8 provides it as the `ctx.modules` service (no page global
|
|
70
|
+
* anymore); the plugin injects it at activation via
|
|
71
|
+
* {@link setChunkModuleSystem}. The rc.7-era `window.__DSH_MODULES__` global
|
|
72
|
+
* remains as a fallback so older hosts and the test harness keep working.
|
|
73
|
+
*/
|
|
74
|
+
export interface ChunkModuleSystem {
|
|
75
|
+
import(specifier: string): Promise<unknown>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Inject the client module system the chunk externals resolve through.
|
|
79
|
+
* Called by the client half's apply() with `ctx.modules` (rc.8+); pass
|
|
80
|
+
* undefined to clear (tests). Survives {@link resetChunks} — the module
|
|
81
|
+
* system is shell state, not chunk state, and stays live across HMR.
|
|
82
|
+
*/
|
|
83
|
+
export declare function setChunkModuleSystem(system: ChunkModuleSystem | undefined): void;
|
|
84
|
+
/** Script-load hook; tests replace it with a stub (the default needs a real DOM + network). */
|
|
85
|
+
export type ChunkScriptLoader = (src: string) => Promise<void>;
|
|
86
|
+
/** Test hook: replace the chunk-script loader (pass null to restore the default). */
|
|
87
|
+
export declare function setChunkScriptLoaderForTests(loader: ChunkScriptLoader | null): void;
|
|
88
|
+
export declare function registerChunkForTests(name: ChunkName, loader: () => Promise<ChunkExports>): void;
|
|
89
|
+
/**
|
|
90
|
+
* Load (once) and materialize a lazy chunk, returning its module exports.
|
|
91
|
+
* Concurrent callers share one in-flight load; a failure clears the cache
|
|
92
|
+
* entry so the next call retries (the script re-executes and overwrites its
|
|
93
|
+
* global registry slot — assignments are idempotent).
|
|
94
|
+
* @param name - the chunk to load.
|
|
95
|
+
*/
|
|
96
|
+
export declare function loadChunk(name: ChunkName): Promise<ChunkExports>;
|
|
97
|
+
/**
|
|
98
|
+
* Drop all chunk state for a fresh plugin activation (HMR-safe): clear the
|
|
99
|
+
* in-memory cache and any test-registry entries, so the next lazy open
|
|
100
|
+
* re-fetches and re-executes the current chunk scripts (the registry slots
|
|
101
|
+
* are overwritten by the re-execution — no cleanup needed). A pending
|
|
102
|
+
* revalidation barrier is cleared too: it was only guarding the cache reads
|
|
103
|
+
* of the state being dropped, so the next load must not wait on it (the
|
|
104
|
+
* orphaned task still settles and its identity-guarded `finally` no-ops).
|
|
105
|
+
*/
|
|
106
|
+
export declare function resetChunks(): void;
|
|
107
|
+
/**
|
|
108
|
+
* HMR-safe re-activation hook (index.tsx calls this instead of a full
|
|
109
|
+
* reset): keep the resolved exports of every loaded chunk and drop only the
|
|
110
|
+
* ones whose script changed on disk — the bundle route revalidates every
|
|
111
|
+
* request (cache-control: no-cache + ETag), so an unchanged chunk keeps its
|
|
112
|
+
* memory cache and the next lazy open skips the re-inject / re-execute.
|
|
113
|
+
* Fail-open: an unreachable, ETag-less, or timed-out chunk is dropped
|
|
114
|
+
* (re-fetch on next open). Test-registry entries are always cleared
|
|
115
|
+
* (per-test fixtures).
|
|
116
|
+
* A page refresh remains the authoritative reset (the HMR poll watches only
|
|
117
|
+
* client.js; chunk-only edits surface here on the next core re-activation).
|
|
118
|
+
*
|
|
119
|
+
* The returned promise is also a BARRIER for {@link loadChunk}: while a
|
|
120
|
+
* revalidation is pending, every chunk load awaits it before serving cache,
|
|
121
|
+
* so a lazy tab opening mid-revalidation can never render stale exports
|
|
122
|
+
* that the sweep is about to invalidate (CR #232 P1).
|
|
123
|
+
*/
|
|
124
|
+
export declare function revalidateChunksOnReactivate(): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy chunk entry: the code/markdown/html text editor (CodeMirror 6 + the
|
|
3
|
+
* language packages). Built as `lib/client-editor.js` and registered under
|
|
4
|
+
* `dsh-better-sidebar/editor` — fetched only when a text file is first
|
|
5
|
+
* opened (see chunk-loader.ts and docs/plans/2026-08-12-lazy-chunks-design.md).
|
|
6
|
+
* Never import this module from the core bundle: it pulls CodeMirror into
|
|
7
|
+
* the startup path.
|
|
8
|
+
*/
|
|
9
|
+
export { TextEditor } from '../TextEditor.tsx';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy chunk entry: the mermaid diagram renderer for the markdown preview
|
|
3
|
+
* (mermaid + its d3/dagre/cytoscape graph deps). Built as
|
|
4
|
+
* lib/client-mermaid.js and registered under the `mermaid` global chunk
|
|
5
|
+
* slot — fetched only when a previewed markdown file contains a mermaid
|
|
6
|
+
* fence (see chunk-loader.ts and the mermaid markdown preview design doc).
|
|
7
|
+
* Never import this module from the core bundle: it pulls mermaid into the
|
|
8
|
+
* startup path.
|
|
9
|
+
*/
|
|
10
|
+
export { MermaidMarkdown } from '../mermaid.tsx';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazy chunk entry: the interactive terminal (xterm + fit addon). Built as
|
|
3
|
+
* `lib/client-terminal.js` and registered under
|
|
4
|
+
* `dsh-better-sidebar/terminal` — fetched only when a terminal tab is first
|
|
5
|
+
* opened (see chunk-loader.ts and docs/plans/2026-08-12-lazy-chunks-design.md).
|
|
6
|
+
* Never import this module from the core bundle: it pulls xterm (and its
|
|
7
|
+
* stylesheet) into the startup path.
|
|
8
|
+
*/
|
|
9
|
+
export { TerminalView } from '../TerminalView.tsx';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodeMirror 6 theme pieces for the sidebar editor. The editor surface
|
|
3
|
+
* (background, caret, gutter) rides the DSH theme tokens so it blends with
|
|
4
|
+
* the panel in both schemes; only the syntax token colors need concrete
|
|
5
|
+
* values, and those come from the same designed palettes the app's code
|
|
6
|
+
* surfaces use — the one-dark family for dark, the one-light family for
|
|
7
|
+
* light. The scheme flip reconfigures these via a compartment (see
|
|
8
|
+
* TextEditor), so the document, undo history and scroll survive re-theming.
|
|
9
|
+
*/
|
|
10
|
+
import { Compartment } from '@codemirror/state';
|
|
11
|
+
/** Token-driven surface shared by both schemes (pure CSS values). */
|
|
12
|
+
export declare const cmSurfaceTheme: import("@codemirror/state").Extension;
|
|
13
|
+
/**
|
|
14
|
+
* A Compartment holding the two scheme-dependent extensions. Created once
|
|
15
|
+
* per editor view; a scheme flip dispatches `reconfigure(dark)` on it, so
|
|
16
|
+
* the document, undo history, scroll and keymaps survive re-theming.
|
|
17
|
+
*/
|
|
18
|
+
export declare class CmThemeCompartment {
|
|
19
|
+
private readonly compartment;
|
|
20
|
+
/** `of(...)` payload for EditorState.create. */
|
|
21
|
+
of(dark: boolean): ReturnType<Compartment['of']>;
|
|
22
|
+
/** Reconfigure for a new scheme. */
|
|
23
|
+
reconfigure(dark: boolean): ReturnType<Compartment['reconfigure']>;
|
|
24
|
+
}
|