dsh-coding-sidebar 1.0.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 +524 -0
- package/cordis.patch.yml +49 -0
- package/lib/client-editor.js +48229 -0
- package/lib/client-mermaid.js +200745 -0
- package/lib/client-registry.js +21867 -0
- package/lib/client-terminal.js +9361 -0
- package/lib/client.js +21867 -0
- package/lib/index.js +4556 -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/client/BrowserView.d.ts +39 -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/FileTree.d.ts +38 -0
- package/lib/types/client/FreeWindow.d.ts +29 -0
- package/lib/types/client/GitView.d.ts +10 -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/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/SideChatView.d.ts +16 -0
- package/lib/types/client/Sidebar.d.ts +6 -0
- package/lib/types/client/SubagentView.d.ts +16 -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 +24 -0
- package/lib/types/client/UploadOverlay.d.ts +20 -0
- package/lib/types/client/add-plugin-modal.d.ts +15 -0
- package/lib/types/client/api.d.ts +275 -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/chunk-loader.d.ts +131 -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 +59 -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 +25 -0
- package/lib/types/client/intercept.d.ts +46 -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 +452 -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 +38 -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 +85 -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 +439 -0
- package/lib/types/client/settings-nav-icon.d.ts +19 -0
- package/lib/types/client/shell-presets.d.ts +48 -0
- package/lib/types/client/sidechat-transcript.d.ts +103 -0
- package/lib/types/client/split-pane.d.ts +36 -0
- package/lib/types/client/state.d.ts +432 -0
- package/lib/types/client/subagent-detect.d.ts +54 -0
- package/lib/types/client/subagent-jobs.d.ts +63 -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/upload.d.ts +69 -0
- package/lib/types/client/wco.d.ts +47 -0
- package/lib/types/config.d.ts +64 -0
- package/lib/types/context-types.d.ts +605 -0
- package/lib/types/fs-operations.d.ts +28 -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/jobs-routes.d.ts +45 -0
- package/lib/types/open-external.d.ts +24 -0
- package/lib/types/path-security.d.ts +20 -0
- package/lib/types/prefs-shared.d.ts +236 -0
- package/lib/types/pty-deps.d.ts +78 -0
- package/lib/types/pty-manager.d.ts +168 -0
- package/lib/types/sidechat-core.d.ts +172 -0
- package/lib/types/sidechat-routes.d.ts +30 -0
- package/lib/types/subagent-activity.d.ts +44 -0
- package/lib/types/subagent-live-route.d.ts +44 -0
- package/lib/types/tools.d.ts +34 -0
- package/lib/types/trust-fence.d.ts +24 -0
- package/lib/types/wire.d.ts +38 -0
- package/package.json +172 -0
- package/scripts/install.ps1 +306 -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/client/BrowserView.tsx +289 -0
- package/src/client/DiffTab.tsx +114 -0
- package/src/client/DiffView.tsx +305 -0
- package/src/client/EditorHost.tsx +558 -0
- package/src/client/FileTree.tsx +669 -0
- package/src/client/FreeWindow.tsx +337 -0
- package/src/client/GitView.tsx +717 -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/RenderBoundary.tsx +49 -0
- package/src/client/SandboxStatusBar.tsx +60 -0
- package/src/client/SideCardSection.module.css +960 -0
- package/src/client/SideCardSection.tsx +1163 -0
- package/src/client/SideChatView.module.css +437 -0
- package/src/client/SideChatView.tsx +645 -0
- package/src/client/Sidebar.tsx +1370 -0
- package/src/client/SubagentView.module.css +547 -0
- package/src/client/SubagentView.tsx +883 -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 +275 -0
- package/src/client/UploadOverlay.tsx +62 -0
- package/src/client/add-plugin-modal.tsx +199 -0
- package/src/client/api.ts +357 -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 +340 -0
- package/src/client/builtins/viewers.tsx +125 -0
- package/src/client/chunk-loader.ts +358 -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 +152 -0
- package/src/client/image-types.ts +8 -0
- package/src/client/ime-guard.ts +47 -0
- package/src/client/index.tsx +427 -0
- package/src/client/intercept.tsx +188 -0
- package/src/client/lang.ts +225 -0
- package/src/client/layout-push.ts +24 -0
- package/src/client/layout.css +90 -0
- package/src/client/lazy-chunk.tsx +89 -0
- package/src/client/link-intercept.ts +73 -0
- package/src/client/locales-ar.ts +368 -0
- package/src/client/locales-de.ts +353 -0
- package/src/client/locales-fr.ts +360 -0
- package/src/client/locales-hi.ts +367 -0
- package/src/client/locales-id.ts +365 -0
- package/src/client/locales-it.ts +358 -0
- package/src/client/locales-ja.ts +367 -0
- package/src/client/locales-ko.ts +359 -0
- package/src/client/locales-nl.ts +365 -0
- package/src/client/locales-pl.ts +369 -0
- package/src/client/locales-pt.ts +350 -0
- package/src/client/locales-ru.ts +365 -0
- package/src/client/locales-sv.ts +350 -0
- package/src/client/locales-th.ts +367 -0
- package/src/client/locales-tr.ts +367 -0
- package/src/client/locales-vi.ts +367 -0
- package/src/client/locales-zh-HK.ts +382 -0
- package/src/client/locales-zh-MO.ts +382 -0
- package/src/client/locales-zh-TW.ts +382 -0
- package/src/client/locales.ts +894 -0
- package/src/client/markdown-html.ts +331 -0
- package/src/client/markdown-images.ts +137 -0
- package/src/client/markdown-labels.tsx +52 -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 +143 -0
- package/src/client/paths.ts +63 -0
- package/src/client/pdf-types.ts +4 -0
- package/src/client/pinned.ts +183 -0
- package/src/client/plugin-settings.ts +43 -0
- package/src/client/plugins-shared.ts +29 -0
- package/src/client/plugins-tabs.ts +96 -0
- package/src/client/plugins-viewers.ts +30 -0
- package/src/client/prefs.ts +210 -0
- package/src/client/produced-files.ts +120 -0
- package/src/client/selection-payload.ts +86 -0
- package/src/client/service.ts +859 -0
- package/src/client/settings-nav-icon.ts +45 -0
- package/src/client/shell-presets.ts +83 -0
- package/src/client/sidebar.module.css +2788 -0
- package/src/client/sidechat-transcript.ts +321 -0
- package/src/client/split-pane.tsx +331 -0
- package/src/client/state.ts +1497 -0
- package/src/client/subagent-detect.ts +137 -0
- package/src/client/subagent-jobs.ts +161 -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/upload.ts +187 -0
- package/src/client/wco.ts +120 -0
- package/src/config.ts +154 -0
- package/src/context-types.ts +611 -0
- package/src/fs-operations.ts +95 -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 +1291 -0
- package/src/invariant.ts +32 -0
- package/src/jobs-routes.ts +257 -0
- package/src/open-external.ts +90 -0
- package/src/path-security.ts +75 -0
- package/src/prefs-shared.ts +280 -0
- package/src/pty-deps.ts +240 -0
- package/src/pty-manager.ts +376 -0
- package/src/sidechat-core.ts +468 -0
- package/src/sidechat-routes.ts +344 -0
- package/src/subagent-activity.ts +91 -0
- package/src/subagent-live-route.ts +93 -0
- package/src/tools.ts +482 -0
- package/src/trust-fence.ts +84 -0
- package/src/wire.ts +100 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal zh/en/ja copy for the sidebar. The copy follows the DSH i18n system:
|
|
3
|
+
* the client apply attaches the locale service (`ctx.locale`, provided by
|
|
4
|
+
* `@deepseek-ai/dsh-client-locale`) through {@link attachLocale}, and
|
|
5
|
+
* `t()`/`isZh()` resolve the active locale from it — the Host-backed
|
|
6
|
+
* `locale.preference` wins over the raw browser language and switches live.
|
|
7
|
+
* Without an attached service (standalone/test compositions) the browser
|
|
8
|
+
* language is used, matching the previous behavior. The dictionaries are
|
|
9
|
+
* also registered into the DSH locale registry under {@link LOCALE_NS}.
|
|
10
|
+
*
|
|
11
|
+
* ja (Japanese) is opt-in through `@huanlin/dsh-plugin-better-locale`: when
|
|
12
|
+
* that plugin is installed, the client apply also calls
|
|
13
|
+
* {@link attachBetterLocale} with the override store. `t()` then consults
|
|
14
|
+
* the store's active override id first; if it is `'ja'` (or any id whose
|
|
15
|
+
* dict has the requested key) the ja text wins, otherwise the existing
|
|
16
|
+
* zh/en chain runs unchanged. better-locale itself patches
|
|
17
|
+
* `LocaleRuntime.prototype.lookup` so DSH's own translate chain also
|
|
18
|
+
* returns ja where the `betterSidebar` namespace has a ja entry — that
|
|
19
|
+
* path covers external callers of `ctx.locale.bind('betterSidebar')`,
|
|
20
|
+
* while the override-aware `t()` here covers dsh-coding-sidebar's own
|
|
21
|
+
* components (which bypass `ctx.locale` and call `t()` directly).
|
|
22
|
+
*/
|
|
23
|
+
/** The zh dictionary (also registered into the DSH locale registry under {@link LOCALE_NS}). */
|
|
24
|
+
export declare const zh: {
|
|
25
|
+
files: string;
|
|
26
|
+
explorer: string;
|
|
27
|
+
git: string;
|
|
28
|
+
terminal: string;
|
|
29
|
+
editor: string;
|
|
30
|
+
editorExplorer: string;
|
|
31
|
+
editorExplorerDesc: string;
|
|
32
|
+
editorExplorerMerged: string;
|
|
33
|
+
editorExplorerMergedDesc: string;
|
|
34
|
+
editorExplorerSplit: string;
|
|
35
|
+
editorExplorerSplitDesc: string;
|
|
36
|
+
editorTreeToggle: string;
|
|
37
|
+
editorPathPlaceholder: string;
|
|
38
|
+
editorSearchPlaceholder: string;
|
|
39
|
+
editorSearchNoResults: string;
|
|
40
|
+
editorSearchTruncated: string;
|
|
41
|
+
editorEmptyHint: string;
|
|
42
|
+
openFileNewTab: string;
|
|
43
|
+
openFileSide: string;
|
|
44
|
+
openWithMenu: string;
|
|
45
|
+
openWithSshSuffix: string;
|
|
46
|
+
pinOpenWith: string;
|
|
47
|
+
unpinOpenWith: string;
|
|
48
|
+
openWithExplorer: string;
|
|
49
|
+
openWithVscode: string;
|
|
50
|
+
openWithCursor: string;
|
|
51
|
+
openWithZed: string;
|
|
52
|
+
openWithSettingsSshTitle: string;
|
|
53
|
+
openWithSettingsSshDesc: string;
|
|
54
|
+
openWithSettingsSshPlaceholder: string;
|
|
55
|
+
openWithSettingsCustomTitle: string;
|
|
56
|
+
openWithSettingsCustomDesc: string;
|
|
57
|
+
openWithSettingsAdd: string;
|
|
58
|
+
openWithSettingsName: string;
|
|
59
|
+
openWithSettingsTemplate: string;
|
|
60
|
+
openWithSettingsFamily: string;
|
|
61
|
+
openWithSettingsFamilyDesc: string;
|
|
62
|
+
openWithSettingsRemove: string;
|
|
63
|
+
openWithSettingsInvalidHint: string;
|
|
64
|
+
newTab: string;
|
|
65
|
+
openExplorer: string;
|
|
66
|
+
brokenSymlink: string;
|
|
67
|
+
openGit: string;
|
|
68
|
+
newTerminal: string;
|
|
69
|
+
terminalLimit: string;
|
|
70
|
+
close: string;
|
|
71
|
+
closeOtherTabs: string;
|
|
72
|
+
closeLeftTabs: string;
|
|
73
|
+
closeRightTabs: string;
|
|
74
|
+
moveToFreeWindow: string;
|
|
75
|
+
floatDropHint: string;
|
|
76
|
+
dockToSidebar: string;
|
|
77
|
+
pinTerminal: string;
|
|
78
|
+
pinAgentTerminal: string;
|
|
79
|
+
pinToWorkspace: string;
|
|
80
|
+
pinToGlobal: string;
|
|
81
|
+
unpinTerminal: string;
|
|
82
|
+
pinnedTerminalTooltip: string;
|
|
83
|
+
pinnedTerminalKindUi: string;
|
|
84
|
+
pinnedTerminalKindAgent: string;
|
|
85
|
+
pinnedTerminalScopeWorkspace: string;
|
|
86
|
+
pinnedTerminalScopeGlobal: string;
|
|
87
|
+
pinnedRailLabel: string;
|
|
88
|
+
closePinnedTerminal: string;
|
|
89
|
+
collapse: string;
|
|
90
|
+
expand: string;
|
|
91
|
+
terminalError: string;
|
|
92
|
+
terminalConnectFailed: string;
|
|
93
|
+
terminalRetry: string;
|
|
94
|
+
terminalDepsFailed: string;
|
|
95
|
+
terminalDepsHint: string;
|
|
96
|
+
terminalDepsProfile: string;
|
|
97
|
+
preview: string;
|
|
98
|
+
toc: string;
|
|
99
|
+
edit: string;
|
|
100
|
+
mermaidError: string;
|
|
101
|
+
mermaidZoomIn: string;
|
|
102
|
+
mermaidZoomOut: string;
|
|
103
|
+
mermaidZoomReset: string;
|
|
104
|
+
mermaidZoomHint: string;
|
|
105
|
+
refresh: string;
|
|
106
|
+
refreshUnsavedConfirm: string;
|
|
107
|
+
save: string;
|
|
108
|
+
saved: string;
|
|
109
|
+
unsaved: string;
|
|
110
|
+
saveFailed: string;
|
|
111
|
+
truncation: string;
|
|
112
|
+
binary: string;
|
|
113
|
+
loading: string;
|
|
114
|
+
error: string;
|
|
115
|
+
retry: string;
|
|
116
|
+
splitLeft: string;
|
|
117
|
+
splitRight: string;
|
|
118
|
+
splitUp: string;
|
|
119
|
+
splitDown: string;
|
|
120
|
+
notRepo: string;
|
|
121
|
+
noChanges: string;
|
|
122
|
+
statusTruncated: string;
|
|
123
|
+
stage: string;
|
|
124
|
+
unstage: string;
|
|
125
|
+
stageAll: string;
|
|
126
|
+
unstageAll: string;
|
|
127
|
+
commitPlaceholder: string;
|
|
128
|
+
commit: string;
|
|
129
|
+
commitError: string;
|
|
130
|
+
branch: string;
|
|
131
|
+
worktree: string;
|
|
132
|
+
checkoutError: string;
|
|
133
|
+
history: string;
|
|
134
|
+
changes: string;
|
|
135
|
+
staged: string;
|
|
136
|
+
unstaged: string;
|
|
137
|
+
cancel: string;
|
|
138
|
+
diffEmpty: string;
|
|
139
|
+
diffLoadError: string;
|
|
140
|
+
diffBinary: string;
|
|
141
|
+
diffAdded: string;
|
|
142
|
+
diffDeleted: string;
|
|
143
|
+
diffRenamed: string;
|
|
144
|
+
diffExpand: string;
|
|
145
|
+
diffCollapse: string;
|
|
146
|
+
discard: string;
|
|
147
|
+
discardTitle: string;
|
|
148
|
+
discardDesc: string;
|
|
149
|
+
viewCommitDiff: string;
|
|
150
|
+
copyShortHash: string;
|
|
151
|
+
copyFullHash: string;
|
|
152
|
+
copySubject: string;
|
|
153
|
+
revertCommit: string;
|
|
154
|
+
revertTitle: string;
|
|
155
|
+
revertDesc: string;
|
|
156
|
+
cherryPickCommit: string;
|
|
157
|
+
cherryPickTitle: string;
|
|
158
|
+
cherryPickDesc: string;
|
|
159
|
+
timeJustNow: string;
|
|
160
|
+
timeMinutesAgo: string;
|
|
161
|
+
timeHoursAgo: string;
|
|
162
|
+
timeYesterday: string;
|
|
163
|
+
loadMore: string;
|
|
164
|
+
historyLoadError: string;
|
|
165
|
+
produced: string;
|
|
166
|
+
producedOpen: string;
|
|
167
|
+
showInFolder: string;
|
|
168
|
+
disconnected: string;
|
|
169
|
+
exited: string;
|
|
170
|
+
noSession: string;
|
|
171
|
+
pluginNotLoaded: string;
|
|
172
|
+
hiddenFiles: string;
|
|
173
|
+
parent: string;
|
|
174
|
+
copied: string;
|
|
175
|
+
copy: string;
|
|
176
|
+
newFile: string;
|
|
177
|
+
openEditor: string;
|
|
178
|
+
gitDetail: string;
|
|
179
|
+
referenceFile: string;
|
|
180
|
+
addToConversation: string;
|
|
181
|
+
copyRelative: string;
|
|
182
|
+
copyAbsolute: string;
|
|
183
|
+
download: string;
|
|
184
|
+
uploadFiles: string;
|
|
185
|
+
uploadFolder: string;
|
|
186
|
+
uploadHere: string;
|
|
187
|
+
uploadDropHint: string;
|
|
188
|
+
uploadDropChat: string;
|
|
189
|
+
uploadTo: string;
|
|
190
|
+
uploadingTo: string;
|
|
191
|
+
uploadProgress: string;
|
|
192
|
+
uploadDone: string;
|
|
193
|
+
uploadFailed: string;
|
|
194
|
+
uploadFailedUnknown: string;
|
|
195
|
+
uploadTooLarge: string;
|
|
196
|
+
uploadCancelled: string;
|
|
197
|
+
settingsNav: string;
|
|
198
|
+
settingsIntro: string;
|
|
199
|
+
settingsPopupDesc: string;
|
|
200
|
+
settingsDone: string;
|
|
201
|
+
settingsOpenTitle: string;
|
|
202
|
+
settingsOpenDesc: string;
|
|
203
|
+
settingsWidthTitle: string;
|
|
204
|
+
settingsWidthDesc: string;
|
|
205
|
+
settingsWidthSuffix: string;
|
|
206
|
+
settingsOpenPathTitle: string;
|
|
207
|
+
settingsOpenPathDesc: string;
|
|
208
|
+
settingsOpenToolsTitle: string;
|
|
209
|
+
settingsOpenToolsDesc: string;
|
|
210
|
+
settingsTitleBarTitle: string;
|
|
211
|
+
settingsTitleBarDesc: string;
|
|
212
|
+
settingsTitleBarStripTitle: string;
|
|
213
|
+
settingsTitleBarStripDesc: string;
|
|
214
|
+
settingsSchemeAutoTitle: string;
|
|
215
|
+
settingsSchemeAutoDesc: string;
|
|
216
|
+
settingsSchemeWebTitle: string;
|
|
217
|
+
settingsSchemeWebDesc: string;
|
|
218
|
+
settingsSchemeCustomTitle: string;
|
|
219
|
+
settingsSchemeCustomDesc: string;
|
|
220
|
+
settingsSchemeDetectedSuffix: string;
|
|
221
|
+
settingsCustomCssTitle: string;
|
|
222
|
+
settingsCustomCssDesc: string;
|
|
223
|
+
settingsCustomCssPlaceholder: string;
|
|
224
|
+
settingsSaveFailed: string;
|
|
225
|
+
settingsConflict: string;
|
|
226
|
+
binaryNoPreview: string;
|
|
227
|
+
downloadToView: string;
|
|
228
|
+
settingsSubagentTitle: string;
|
|
229
|
+
settingsSubagentDesc: string;
|
|
230
|
+
settingsJobsTitle: string;
|
|
231
|
+
settingsJobsDesc: string;
|
|
232
|
+
settingsToolsTitle: string;
|
|
233
|
+
settingsToolsDesc: string;
|
|
234
|
+
settingsFontFamilyTitle: string;
|
|
235
|
+
settingsFontFamilyDesc: string;
|
|
236
|
+
settingsFontFamilyPlaceholder: string;
|
|
237
|
+
settingsFontSizeTitle: string;
|
|
238
|
+
settingsFontSizeDesc: string;
|
|
239
|
+
settingsFontSizeSuffix: string;
|
|
240
|
+
settingsShellTitle: string;
|
|
241
|
+
settingsShellDesc: string;
|
|
242
|
+
settingsShellPlaceholder: string;
|
|
243
|
+
settingsShellArgsTitle: string;
|
|
244
|
+
settingsShellArgsDesc: string;
|
|
245
|
+
settingsShellArgsPlaceholder: string;
|
|
246
|
+
settingsTabsTitle: string;
|
|
247
|
+
settingsViewersTitle: string;
|
|
248
|
+
settingsGeneralTitle: string;
|
|
249
|
+
settingsPopup: string;
|
|
250
|
+
settingsViewerCatchAll: string;
|
|
251
|
+
viewerImage: string;
|
|
252
|
+
viewerPdf: string;
|
|
253
|
+
viewerMarkdown: string;
|
|
254
|
+
viewerCode: string;
|
|
255
|
+
viewerBinary: string;
|
|
256
|
+
viewerHtml: string;
|
|
257
|
+
browser: string;
|
|
258
|
+
browserPlaceholder: string;
|
|
259
|
+
browserGo: string;
|
|
260
|
+
browserBack: string;
|
|
261
|
+
browserForward: string;
|
|
262
|
+
browserStart: string;
|
|
263
|
+
browserBlockedScheme: string;
|
|
264
|
+
browserBlockedLoopback: string;
|
|
265
|
+
browserInvalid: string;
|
|
266
|
+
browserNoSandboxWarning: string;
|
|
267
|
+
htmlNoSandboxWarning: string;
|
|
268
|
+
sandboxStatusOn: string;
|
|
269
|
+
sandboxUnlock: string;
|
|
270
|
+
sandboxRestore: string;
|
|
271
|
+
settingsHtmlDefaultUnsafeTitle: string;
|
|
272
|
+
settingsHtmlDefaultUnsafeDesc: string;
|
|
273
|
+
settingsHtmlSandboxTitle: string;
|
|
274
|
+
settingsHtmlSandboxDesc: string;
|
|
275
|
+
settingsBrowserSandboxTitle: string;
|
|
276
|
+
settingsBrowserSandboxDesc: string;
|
|
277
|
+
settingsBrowserLinksTitle: string;
|
|
278
|
+
settingsBrowserLinksDesc: string;
|
|
279
|
+
settingsBrowserHttpTitle: string;
|
|
280
|
+
settingsBrowserHttpDesc: string;
|
|
281
|
+
settingsBrowserHttpsTitle: string;
|
|
282
|
+
settingsBrowserHttpsDesc: string;
|
|
283
|
+
settingsBrowserLoopbackTitle: string;
|
|
284
|
+
settingsBrowserLoopbackDesc: string;
|
|
285
|
+
settingsBrowserLoopbackPlaceholder: string;
|
|
286
|
+
browserOpenExternal: string;
|
|
287
|
+
browserEmbedBlocked: string;
|
|
288
|
+
browserEmbedBlockedDesc: string;
|
|
289
|
+
browserEmbedAnyway: string;
|
|
290
|
+
subagent: string;
|
|
291
|
+
openSubagent: string;
|
|
292
|
+
subagentMainAgent: string;
|
|
293
|
+
subagentEmpty: string;
|
|
294
|
+
subagentEmptyDesc: string;
|
|
295
|
+
subagentRunning: string;
|
|
296
|
+
subagentInactive: string;
|
|
297
|
+
subagentModeOneShot: string;
|
|
298
|
+
subagentModeContinuable: string;
|
|
299
|
+
subagentCount: string;
|
|
300
|
+
subagentCountRunning: string;
|
|
301
|
+
subagentDiagCorrupt: string;
|
|
302
|
+
subagentDiagUnsupported: string;
|
|
303
|
+
subagentDiagUnavailable: string;
|
|
304
|
+
subagentThinking: string;
|
|
305
|
+
sideChat: string;
|
|
306
|
+
sideChatNew: string;
|
|
307
|
+
sideChatUntitled: string;
|
|
308
|
+
sideChatEmpty: string;
|
|
309
|
+
sideChatEmptyDesc: string;
|
|
310
|
+
sideChatCreating: string;
|
|
311
|
+
sideChatRetry: string;
|
|
312
|
+
sideChatThreads: string;
|
|
313
|
+
sideChatSave: string;
|
|
314
|
+
sideChatSaveTitle: string;
|
|
315
|
+
sideChatSaved: string;
|
|
316
|
+
sideChatNoTurn: string;
|
|
317
|
+
sideChatPendingDrop: string;
|
|
318
|
+
sideChatFirstPlaceholder: string;
|
|
319
|
+
sideChatComposerPlaceholder: string;
|
|
320
|
+
sideChatThinking: string;
|
|
321
|
+
sideChatThink: string;
|
|
322
|
+
sideChatInjection: string;
|
|
323
|
+
sideChatSend: string;
|
|
324
|
+
sideChatCancel: string;
|
|
325
|
+
sideChatCancelTitle: string;
|
|
326
|
+
sideChatClose: string;
|
|
327
|
+
sideChatCloseTitle: string;
|
|
328
|
+
sideChatError: string;
|
|
329
|
+
jobs: string;
|
|
330
|
+
jobsCount: string;
|
|
331
|
+
jobsCountRunning: string;
|
|
332
|
+
jobStatusRunning: string;
|
|
333
|
+
jobStatusStopping: string;
|
|
334
|
+
jobStatusCompleted: string;
|
|
335
|
+
jobStatusKilled: string;
|
|
336
|
+
jobStatusFailed: string;
|
|
337
|
+
jobDurationSeconds: string;
|
|
338
|
+
jobDurationMinutes: string;
|
|
339
|
+
jobDurationHours: string;
|
|
340
|
+
jobViewOutput: string;
|
|
341
|
+
jobHideOutput: string;
|
|
342
|
+
jobNoOutput: string;
|
|
343
|
+
jobNotReadYet: string;
|
|
344
|
+
jobOutputTruncated: string;
|
|
345
|
+
jobOutputError: string;
|
|
346
|
+
jobKill: string;
|
|
347
|
+
jobKillConfirm: string;
|
|
348
|
+
jobKillError: string;
|
|
349
|
+
addPluginsTabCard: string;
|
|
350
|
+
addPluginsTabCardDesc: string;
|
|
351
|
+
addPluginsViewerCard: string;
|
|
352
|
+
addPluginsViewerCardDesc: string;
|
|
353
|
+
addPluginsTabDesc: string;
|
|
354
|
+
addPluginsViewerDesc: string;
|
|
355
|
+
addPluginsBrowseMore: string;
|
|
356
|
+
addPluginsSearch: string;
|
|
357
|
+
addPluginsNoMatch: string;
|
|
358
|
+
addPluginsRecommended: string;
|
|
359
|
+
addPluginsEmpty: string;
|
|
360
|
+
openPlugin: string;
|
|
361
|
+
copyInstall: string;
|
|
362
|
+
pluginOfficeDesc: string;
|
|
363
|
+
pluginFlowglassDesc: string;
|
|
364
|
+
pluginGitForgeDesc: string;
|
|
365
|
+
pluginGitRemotesDesc: string;
|
|
366
|
+
pluginSentinelDesc: string;
|
|
367
|
+
pluginSidebarQaDesc: string;
|
|
368
|
+
pluginSshTunnelDesc: string;
|
|
369
|
+
pluginTurnReviewDesc: string;
|
|
370
|
+
pluginVideoPreviewDesc: string;
|
|
371
|
+
pluginDocsPanelDesc: string;
|
|
372
|
+
pluginEgoBrowserDesc: string;
|
|
373
|
+
};
|
|
374
|
+
/** The en dictionary (key-set-equal to zh, enforced by the type annotation). */
|
|
375
|
+
export declare const en: Record<keyof typeof zh, string>;
|
|
376
|
+
/**
|
|
377
|
+
* The dictionary namespace this plugin owns in the DSH locale registry
|
|
378
|
+
* (`'sidebar'` is taken by DSH's own ui-sidebar, hence this distinct name).
|
|
379
|
+
*/
|
|
380
|
+
export declare const LOCALE_NS = "betterSidebar";
|
|
381
|
+
/** The ja dictionary (key-set-equal to zh, enforced by the type annotation). */
|
|
382
|
+
export declare const ja: Record<keyof typeof zh, string>;
|
|
383
|
+
export declare const de: Record<keyof typeof zh, string>;
|
|
384
|
+
export declare const fr: Record<keyof typeof zh, string>;
|
|
385
|
+
export declare const pt: Record<keyof typeof zh, string>;
|
|
386
|
+
export declare const ko: Record<keyof typeof zh, string>;
|
|
387
|
+
export declare const ar: Record<keyof typeof zh, string>;
|
|
388
|
+
export declare const hi: Record<keyof typeof zh, string>;
|
|
389
|
+
export declare const id: Record<keyof typeof zh, string>;
|
|
390
|
+
export declare const tr: Record<keyof typeof zh, string>;
|
|
391
|
+
export declare const vi: Record<keyof typeof zh, string>;
|
|
392
|
+
export declare const th: Record<keyof typeof zh, string>;
|
|
393
|
+
export declare const ru: Record<keyof typeof zh, string>;
|
|
394
|
+
export declare const it: Record<keyof typeof zh, string>;
|
|
395
|
+
export declare const nl: Record<keyof typeof zh, string>;
|
|
396
|
+
export declare const sv: Record<keyof typeof zh, string>;
|
|
397
|
+
export declare const pl: Record<keyof typeof zh, string>;
|
|
398
|
+
export declare const zhHK: Record<keyof typeof zh, string>;
|
|
399
|
+
export declare const zhTW: Record<keyof typeof zh, string>;
|
|
400
|
+
export declare const zhMO: Record<keyof typeof zh, string>;
|
|
401
|
+
/**
|
|
402
|
+
* The better-locale override store attached by the client apply
|
|
403
|
+
* (absent → no override; the zh/en chain runs). The store's `active`
|
|
404
|
+
* field holds the user's chosen override id (e.g. `'ja'`); `undefined`
|
|
405
|
+
* means "no override, use DSH native zh/en".
|
|
406
|
+
*
|
|
407
|
+
* The override only takes effect when DSH's active locale is `'en'`
|
|
408
|
+
* (it borrows DSH's English slot to render a third language). While
|
|
409
|
+
* DSH is on `'zh'` the override is inert — `getOverride` returns
|
|
410
|
+
* `undefined` and `isOverrideActive` returns `false` — so `t()` and
|
|
411
|
+
* `isZh()` fall through to the native zh/en chain unchanged.
|
|
412
|
+
*/
|
|
413
|
+
declare let betterLocaleStore: {
|
|
414
|
+
readonly active: string | undefined;
|
|
415
|
+
getOverride(dshActive: string, ns: string, key: string): string | undefined;
|
|
416
|
+
isOverrideActive(dshActive: string): boolean;
|
|
417
|
+
} | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* Attach (or detach, with undefined) the DSH locale service. The sidebar
|
|
420
|
+
* mounts its own React root outside the slot system's locale seat, so the
|
|
421
|
+
* service rides this module-level holder: components keep calling the plain
|
|
422
|
+
* `t()` function, and the Sidebar root's locale subscription re-renders the
|
|
423
|
+
* whole tree on switches.
|
|
424
|
+
*/
|
|
425
|
+
export declare function attachLocale(service: {
|
|
426
|
+
getSnapshot(): {
|
|
427
|
+
active: string;
|
|
428
|
+
};
|
|
429
|
+
} | undefined): void;
|
|
430
|
+
/**
|
|
431
|
+
* Attach (or detach, with undefined) the better-locale override store.
|
|
432
|
+
* When attached with an active override, `t()` consults the store's
|
|
433
|
+
* `getOverride(active, LOCALE_NS, key)` first; if it returns a string,
|
|
434
|
+
* that text wins over the zh/en chain. Detaching (or the store's active
|
|
435
|
+
* being `undefined`) restores the zh/en chain unchanged.
|
|
436
|
+
*
|
|
437
|
+
* The Sidebar root subscribes to the store separately (see Sidebar.tsx)
|
|
438
|
+
* so an override change re-renders the whole tree — the locale service's
|
|
439
|
+
* own revision bump (which better-locale triggers via `publish(active, true)`)
|
|
440
|
+
* does NOT fire the existing `localeRevision` uSES because that snapshot
|
|
441
|
+
* reads `getSnapshot().active` (unchanged) rather than `revision`.
|
|
442
|
+
*/
|
|
443
|
+
export declare function attachBetterLocale(store: typeof betterLocaleStore): void;
|
|
444
|
+
/** Translate a copy key in the active locale (zh → zh, else en). */
|
|
445
|
+
export type CopyKey = keyof typeof zh;
|
|
446
|
+
/** Translate a copy key; `{name}` placeholders interpolate from `params`. */
|
|
447
|
+
export declare function t(key: CopyKey, params?: Record<string, string | number>): string;
|
|
448
|
+
/** Whether the active locale is Chinese (used for selectors). */
|
|
449
|
+
export declare function isZh(): boolean;
|
|
450
|
+
/** Format an ISO 8601 author date relative to now (刚刚 / N 分钟前 / N 小时前 / 昨天 / date). */
|
|
451
|
+
export declare function relativeTime(iso: string): string;
|
|
452
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw-HTML block detection for the markdown preview. The shared `MarkdownText`
|
|
3
|
+
* renders raw HTML as literal text (a chat-security stance), so a GitHub-style
|
|
4
|
+
* README (`<div align="center">` badge walls, `<details>` collapsibles with
|
|
5
|
+
* markdown inside, table cells full of inline tags) previews as source soup.
|
|
6
|
+
* This module's pure splitter lifts those HTML runs OUT of the markdown stream
|
|
7
|
+
* before rendering: markdown runs keep flowing through `MarkdownText` (shiki /
|
|
8
|
+
* KaTeX / GFM intact, mermaid chunk path unchanged) while HTML runs render as
|
|
9
|
+
* sanitized DOM (see markdown-html.tsx).
|
|
10
|
+
*
|
|
11
|
+
* Splitting follows CommonMark's shape closely enough for real-world READMEs:
|
|
12
|
+
* a line outside code fences that starts with a block-level tag (type-6 list
|
|
13
|
+
* below) or `<!--` opens an HTML run that extends to the next blank line
|
|
14
|
+
* (comments end at the line containing `-->`). Inline-only tags (`<b>`, `<br>`,
|
|
15
|
+
* `<a>`…) never open a run — they stay in the markdown stream and are handled
|
|
16
|
+
* by the inline pass instead. Unclosed block tags (`<details>` … markdown …
|
|
17
|
+
* `</details>`) are surfaced by {@link analyzeHtmlSegment} as ordered parts so
|
|
18
|
+
* the renderer can nest the in-between markdown inside the open element, the
|
|
19
|
+
* way GitHub's linear HTML output nests.
|
|
20
|
+
*/
|
|
21
|
+
/** A run of raw HTML lines lifted out of the markdown stream. */
|
|
22
|
+
export interface HtmlSegment {
|
|
23
|
+
kind: 'html';
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
/** A run of markdown source (may contain non-mermaid fences, inline HTML…). */
|
|
27
|
+
export interface MarkdownHtmlSegment {
|
|
28
|
+
kind: 'markdown';
|
|
29
|
+
text: string;
|
|
30
|
+
}
|
|
31
|
+
export type MdHtmlSegment = MarkdownHtmlSegment | HtmlSegment;
|
|
32
|
+
/** The doc-wide analysis the preview consumes (all pure, unit-tested here). */
|
|
33
|
+
export interface AnalyzedMarkdownHtml {
|
|
34
|
+
/** The document split into markdown / html runs (empty input → []). */
|
|
35
|
+
segments: MdHtmlSegment[];
|
|
36
|
+
/** True when at least one html run was lifted out. */
|
|
37
|
+
hasBlockHtml: boolean;
|
|
38
|
+
/** True when the source contains any tag-like text (block OR inline). */
|
|
39
|
+
hasInlineHtml: boolean;
|
|
40
|
+
/** Every reference definition found in the markdown runs (`[label]: dest`
|
|
41
|
+
* lines), joined — appended to each markdown run so `[text][id]` keeps
|
|
42
|
+
* resolving across the lifted HTML runs (first-match wins makes the
|
|
43
|
+
* appended copy inert inside runs that already define it). */
|
|
44
|
+
referenceDefinitions: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* CommonMark HTML-block type-6 tag names (block-level elements), lowercased.
|
|
48
|
+
* A line starting with one of these (open or close) outside a fence begins an
|
|
49
|
+
* HTML run. `<summary>` is CommonMark-inline but intentionally included: it is
|
|
50
|
+
* the idiomatic first child of a `<details>` run in GitHub-flavored READMEs.
|
|
51
|
+
*/
|
|
52
|
+
export declare const HTML_BLOCK_TAGS: ReadonlySet<string>;
|
|
53
|
+
/** One structural piece of a lifted HTML run, in document order. */
|
|
54
|
+
export type HtmlPart = {
|
|
55
|
+
kind: 'html';
|
|
56
|
+
html: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'open';
|
|
59
|
+
tag: string;
|
|
60
|
+
attrs: string;
|
|
61
|
+
} | {
|
|
62
|
+
kind: 'close';
|
|
63
|
+
tag: string;
|
|
64
|
+
};
|
|
65
|
+
/** The run's structure relative to the surrounding document nesting. */
|
|
66
|
+
export interface HtmlSegmentShape {
|
|
67
|
+
parts: HtmlPart[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Reduce a lifted HTML run to ordered parts: balanced spans become `html`
|
|
71
|
+
* leaves, unclosed open tags become `open` (a wrapper the renderer lowers
|
|
72
|
+
* following markdown runs into), unmatched closes become `close` (pops one
|
|
73
|
+
* wrapper level). A mismatched close pops through the matching open — the
|
|
74
|
+
* HTML parser's implicit-close behavior. Runs with no structural tags reduce
|
|
75
|
+
* to a single `html` part.
|
|
76
|
+
*/
|
|
77
|
+
export declare function analyzeHtmlSegment(source: string): HtmlSegmentShape;
|
|
78
|
+
/**
|
|
79
|
+
* Split markdown source into markdown / html runs (fence-aware: an HTML-looking
|
|
80
|
+
* line inside any fenced code block is content, not a run start). Blank lines
|
|
81
|
+
* terminate HTML runs and are dropped between segments (they carry no markdown
|
|
82
|
+
* semantics the preview needs); everything else stays byte-identical.
|
|
83
|
+
*/
|
|
84
|
+
export declare function splitHtmlBlocks(text: string): MdHtmlSegment[];
|
|
85
|
+
/**
|
|
86
|
+
* Collect the reference definitions of every markdown run (HTML runs cannot
|
|
87
|
+
* define them), in document order, newline-joined for appending.
|
|
88
|
+
*/
|
|
89
|
+
export declare function collectReferenceDefinitions(segments: readonly MdHtmlSegment[]): string;
|
|
90
|
+
/**
|
|
91
|
+
* The whole-document gate + split the preview consumes. `hasInlineHtml` is a
|
|
92
|
+
* cheap source-level regex (code-fence content may false-positive; the inline
|
|
93
|
+
* pass skips rendered code blocks anyway, so a false positive only costs the
|
|
94
|
+
* enhanced render path, never a behavior change).
|
|
95
|
+
*/
|
|
96
|
+
export declare function analyzeMarkdownHtml(text: string): AnalyzedMarkdownHtml;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown-preview local-image resolution. The shared `MarkdownText` (from
|
|
3
|
+
* @deepseek-ai/dsh-client-ui-primitives) only renders absolute http(s) image
|
|
4
|
+
* URLs — relative links are disabled for chat security — so a local image in
|
|
5
|
+
* a previewed `.md` (``, an absolute `/cwd/img.png`, or a
|
|
6
|
+
* reference definition) would otherwise fall back to its alt text. This
|
|
7
|
+
* dependency-free helper rewrites those destinations into absolute
|
|
8
|
+
* `/sidebar/file` media URLs (prefixed with the GUI's own origin) so
|
|
9
|
+
* `MarkdownText` accepts them; the host media route then serves the bytes,
|
|
10
|
+
* still restricted to files under the session cwd.
|
|
11
|
+
*/
|
|
12
|
+
import type { SessionScope } from './api.ts';
|
|
13
|
+
/**
|
|
14
|
+
* Rewrite markdown image destinations that point at local files into
|
|
15
|
+
* absolute `/sidebar/file` media URLs. Relative destinations resolve against
|
|
16
|
+
* the opened file's directory (normalizing `.`/`..` segments); absolute
|
|
17
|
+
* local paths pass through. Remote (http/https/data/mailto) and `#`-anchor
|
|
18
|
+
* destinations are left untouched for `MarkdownText`. Reference-style images
|
|
19
|
+
* (`![x][id]` + `[id]: url`) are covered by rewriting their definition lines.
|
|
20
|
+
*
|
|
21
|
+
* Code spans (`` `...` ``) and fenced code blocks (``` ```...``` ```) are
|
|
22
|
+
* masked before rewriting so documentation that demonstrates ``
|
|
23
|
+
* is not mutated into a `/sidebar/file` URL. Reference definitions are only
|
|
24
|
+
* rewritten when their label is actually referenced by an image (collapsed
|
|
25
|
+
* `[![][id]]`, full `![alt][id]`, or shortcut `![]` referencing the next
|
|
26
|
+
* definition) — a plain link `[text][id]` must not have its destination
|
|
27
|
+
* redirected to the media route.
|
|
28
|
+
* @param text - The raw markdown source (inline + reference images).
|
|
29
|
+
* @param scope - The session scope (sessionId + cwd) for the media route.
|
|
30
|
+
* @param filePath - The absolute path of the opened `.md` file.
|
|
31
|
+
* @param origin - The GUI's own origin (`window.location.origin`); injected
|
|
32
|
+
* so the core rewrite stays pure and unit-testable.
|
|
33
|
+
* @returns The markdown with local image destinations rewritten in place.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Resolve one media destination against the session's media route: local
|
|
37
|
+
* (relative or absolute) paths become absolute `/sidebar/file` URLs (prefixed
|
|
38
|
+
* with the GUI's own origin so the shared MarkdownText http(s) allowlist
|
|
39
|
+
* accepts them), while remote URLs, `#`-anchors and empty destinations are
|
|
40
|
+
* returned untouched. Shared by the markdown image rewriter below and by the
|
|
41
|
+
* preview's raw-HTML sanitizer (`markdown-html.tsx`, which meets the same
|
|
42
|
+
* allowlist when rendering `<img src="./x.png">` inside HTML blocks).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveLocalMediaDest(dest: string, scope: SessionScope, filePath: string, origin: string): string;
|
|
45
|
+
export declare function rewriteLocalImageUrls(text: string, scope: SessionScope, filePath: string, origin: string): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy-button / chrome labels for DSH's shared `MarkdownText`, shaped for
|
|
3
|
+
* BOTH prop generations the plugin supports:
|
|
4
|
+
*
|
|
5
|
+
* - 0.1.1-rc.x: optional flat prop `codeLabels` — the renderer reads
|
|
6
|
+
* `labels.copyLabel` / `labels.copiedLabel` directly.
|
|
7
|
+
* - 0.1.2-alpha.1+: renamed to a REQUIRED `labels` prop with a nested shape
|
|
8
|
+
* (`labels.code.copyLabel` + a screen-reader-only `labels.footnotes`
|
|
9
|
+
* heading). Passing only the old prop crashes the fence render with
|
|
10
|
+
* "Cannot read properties of undefined (reading 'code')" — the exact
|
|
11
|
+
* regression the mount lane caught on a real 0.1.2-alpha.1 host.
|
|
12
|
+
*
|
|
13
|
+
* The union object satisfies both readers, and {@link markdownTextProps}
|
|
14
|
+
* passes it under BOTH prop names — each host ignores the one it does not
|
|
15
|
+
* know. `footnotes` is left empty (the heading is sr-only; give it a real
|
|
16
|
+
* string only if a locale key ever earns its place in all 19 dictionaries).
|
|
17
|
+
*/
|
|
18
|
+
import type { ComponentProps } from 'react';
|
|
19
|
+
import { MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
20
|
+
/** The flat copy-button pair the plugin threads through its own props
|
|
21
|
+
* (e.g. MermaidMarkdownProps.codeLabels — the chunk contract stays put). */
|
|
22
|
+
export interface MarkdownCopyLabels {
|
|
23
|
+
copyLabel: string;
|
|
24
|
+
copiedLabel: string;
|
|
25
|
+
}
|
|
26
|
+
/** The dual-generation chrome labels object (see module doc). */
|
|
27
|
+
export interface MarkdownChromeLabels extends MarkdownCopyLabels {
|
|
28
|
+
/** 0.1.2-alpha.1+ nested reads. */
|
|
29
|
+
code: MarkdownCopyLabels;
|
|
30
|
+
/** 0.1.2-alpha.1+ sr-only footnotes heading. */
|
|
31
|
+
footnotes: string;
|
|
32
|
+
}
|
|
33
|
+
/** Build the dual-shape chrome labels from a flat copy-button pair. */
|
|
34
|
+
export declare function markdownChromeLabels(labels: MarkdownCopyLabels): MarkdownChromeLabels;
|
|
35
|
+
/** MarkdownText props carrying the labels under BOTH prop names. The cast is
|
|
36
|
+
* load-bearing: the plugin builds against the 0.1.1-rc.x declaration, where
|
|
37
|
+
* `labels` does not exist yet (and vice versa on a 0.1.2-alpha.1+ host). */
|
|
38
|
+
export declare function markdownTextProps(text: string, labels: MarkdownCopyLabels): ComponentProps<typeof MarkdownText>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown/mermaid fence detection for the markdown preview. The preview
|
|
3
|
+
* renders the WHOLE document through one DSH `MarkdownText` pass (so
|
|
4
|
+
* cross-fence semantics — reference-style links, footnotes, list
|
|
5
|
+
* continuity — stay intact) and the mermaid lazy chunk then swaps the
|
|
6
|
+
* rendered `language-mermaid` code blocks for diagrams. This module's pure
|
|
7
|
+
* splitter exists to detect whether the source contains a mermaid fence at
|
|
8
|
+
* all, so the mermaid chunk is only fetched when needed (unit-tested in
|
|
9
|
+
* tests/mermaid-blocks.spec.ts).
|
|
10
|
+
*/
|
|
11
|
+
/** One fenced mermaid diagram lifted out of the markdown source. */
|
|
12
|
+
export interface MermaidBlock {
|
|
13
|
+
kind: 'mermaid';
|
|
14
|
+
/** The raw diagram source between the fences (info string stripped). */
|
|
15
|
+
code: string;
|
|
16
|
+
}
|
|
17
|
+
/** A span of plain markdown source (may itself contain non-mermaid fences). */
|
|
18
|
+
export interface MarkdownBlock {
|
|
19
|
+
kind: 'markdown';
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
export type MdBlock = MarkdownBlock | MermaidBlock;
|
|
23
|
+
/** Props of the chunk-resident `MermaidMarkdown` component (shared contract). */
|
|
24
|
+
export interface MermaidMarkdownProps {
|
|
25
|
+
/** The full markdown source (rendered in a single MarkdownText pass). */
|
|
26
|
+
text: string;
|
|
27
|
+
codeLabels: {
|
|
28
|
+
copyLabel: string;
|
|
29
|
+
copiedLabel: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** CommonMark opening fence: 0-3 spaces indent + a run of 3+ backticks or tildes. */
|
|
33
|
+
export declare const OPEN_FENCE_RE: RegExp;
|
|
34
|
+
/** A closing-fence line: 0-3 spaces indent + 3+ backticks/tildes + trailing spaces only. */
|
|
35
|
+
export declare const CLOSE_FENCE_RE: RegExp;
|
|
36
|
+
/** Parse the info string from the line tail after the fence run; null when invalid. */
|
|
37
|
+
export declare function fenceInfo(rest: string, fence: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Split markdown source into md/mermaid blocks for detection: only fences
|
|
40
|
+
* whose info string names mermaid are lifted; every other line stays in the
|
|
41
|
+
* markdown stream untouched. CommonMark fence rules are honored — opening
|
|
42
|
+
* fences of 3+ backticks OR tildes, and a closing fence must use the same
|
|
43
|
+
* character with at least as many characters as the opening fence. An
|
|
44
|
+
* unterminated mermaid fence swallows the rest of the file (the same
|
|
45
|
+
* recovery CommonMark applies to open fences).
|
|
46
|
+
*/
|
|
47
|
+
export declare function splitMermaidBlocks(text: string): MdBlock[];
|