@lijian-ui/dsh-file-manager 0.1.20
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 +38 -0
- package/README.i18n.yaml +6 -0
- package/README.md +66 -0
- package/README.zh.md +66 -0
- package/cordis.patch.yml +13 -0
- package/lib/assets/mermaid.min.js +3587 -0
- package/lib/client.js +7621 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +3207 -0
- package/lib/tsconfig.client.tsbuildinfo +1 -0
- package/lib/tsconfig.host.tsbuildinfo +1 -0
- package/lib/types/client/FileManagerSettingsCard.d.ts +56 -0
- package/lib/types/client/FileManagerSettingsCard.d.ts.map +1 -0
- package/lib/types/client/PluginSettingsCard.d.ts +104 -0
- package/lib/types/client/PluginSettingsCard.d.ts.map +1 -0
- package/lib/types/client/api.d.ts +75 -0
- package/lib/types/client/api.d.ts.map +1 -0
- package/lib/types/client/chat/AttachedFilesDock.d.ts +51 -0
- package/lib/types/client/chat/AttachedFilesDock.d.ts.map +1 -0
- package/lib/types/client/chat/file-ref.d.ts +35 -0
- package/lib/types/client/chat/file-ref.d.ts.map +1 -0
- package/lib/types/client/chat/mermaid-chat.d.ts +30 -0
- package/lib/types/client/chat/mermaid-chat.d.ts.map +1 -0
- package/lib/types/client/chat/placeholder-hint.d.ts +16 -0
- package/lib/types/client/chat/placeholder-hint.d.ts.map +1 -0
- package/lib/types/client/components/ExplorerPanel.d.ts +26 -0
- package/lib/types/client/components/ExplorerPanel.d.ts.map +1 -0
- package/lib/types/client/components/FileIcon.d.ts +15 -0
- package/lib/types/client/components/FileIcon.d.ts.map +1 -0
- package/lib/types/client/components/ScmPanel.d.ts +23 -0
- package/lib/types/client/components/ScmPanel.d.ts.map +1 -0
- package/lib/types/client/components/a11y.d.ts +12 -0
- package/lib/types/client/components/a11y.d.ts.map +1 -0
- package/lib/types/client/components/icons.d.ts +41 -0
- package/lib/types/client/components/icons.d.ts.map +1 -0
- package/lib/types/client/components/overlay.d.ts +45 -0
- package/lib/types/client/components/overlay.d.ts.map +1 -0
- package/lib/types/client/drag/DragFileInlay.d.ts +31 -0
- package/lib/types/client/drag/DragFileInlay.d.ts.map +1 -0
- package/lib/types/client/drag/file-drag.d.ts +47 -0
- package/lib/types/client/drag/file-drag.d.ts.map +1 -0
- package/lib/types/client/drag.d.ts +31 -0
- package/lib/types/client/drag.d.ts.map +1 -0
- package/lib/types/client/file-source.d.ts +29 -0
- package/lib/types/client/file-source.d.ts.map +1 -0
- package/lib/types/client/fileType.d.ts +31 -0
- package/lib/types/client/fileType.d.ts.map +1 -0
- package/lib/types/client/floating.d.ts +27 -0
- package/lib/types/client/floating.d.ts.map +1 -0
- package/lib/types/client/hooks/useResizableSplit.d.ts +37 -0
- package/lib/types/client/hooks/useResizableSplit.d.ts.map +1 -0
- package/lib/types/client/hooks/useStore.d.ts +10 -0
- package/lib/types/client/hooks/useStore.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +57 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/layout.d.ts +104 -0
- package/lib/types/client/layout.d.ts.map +1 -0
- package/lib/types/client/locales.d.ts +125 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/maximize.d.ts +24 -0
- package/lib/types/client/maximize.d.ts.map +1 -0
- package/lib/types/client/mention.d.ts +44 -0
- package/lib/types/client/mention.d.ts.map +1 -0
- package/lib/types/client/mount.d.ts +22 -0
- package/lib/types/client/mount.d.ts.map +1 -0
- package/lib/types/client/persist.d.ts +55 -0
- package/lib/types/client/persist.d.ts.map +1 -0
- package/lib/types/client/picker/FilePickerModal.d.ts +47 -0
- package/lib/types/client/picker/FilePickerModal.d.ts.map +1 -0
- package/lib/types/client/picker/file-picker.d.ts +62 -0
- package/lib/types/client/picker/file-picker.d.ts.map +1 -0
- package/lib/types/client/preview/PreviewPanel.d.ts +17 -0
- package/lib/types/client/preview/PreviewPanel.d.ts.map +1 -0
- package/lib/types/client/preview/PreviewTabs.d.ts +30 -0
- package/lib/types/client/preview/PreviewTabs.d.ts.map +1 -0
- package/lib/types/client/preview/PreviewToolbar.d.ts +37 -0
- package/lib/types/client/preview/PreviewToolbar.d.ts.map +1 -0
- package/lib/types/client/preview/content.d.ts +43 -0
- package/lib/types/client/preview/content.d.ts.map +1 -0
- package/lib/types/client/preview/markdown.d.ts +60 -0
- package/lib/types/client/preview/markdown.d.ts.map +1 -0
- package/lib/types/client/preview/mermaid.d.ts +78 -0
- package/lib/types/client/preview/mermaid.d.ts.map +1 -0
- package/lib/types/client/preview/selection.d.ts +26 -0
- package/lib/types/client/preview/selection.d.ts.map +1 -0
- package/lib/types/client/reference.d.ts +75 -0
- package/lib/types/client/reference.d.ts.map +1 -0
- package/lib/types/client/settings-form.d.ts +206 -0
- package/lib/types/client/settings-form.d.ts.map +1 -0
- package/lib/types/client/store.d.ts +279 -0
- package/lib/types/client/store.d.ts.map +1 -0
- package/lib/types/core/types.d.ts +132 -0
- package/lib/types/core/types.d.ts.map +1 -0
- package/lib/types/host/fs-service.d.ts +96 -0
- package/lib/types/host/fs-service.d.ts.map +1 -0
- package/lib/types/host/gate.d.ts +45 -0
- package/lib/types/host/gate.d.ts.map +1 -0
- package/lib/types/host/git-runner.d.ts +80 -0
- package/lib/types/host/git-runner.d.ts.map +1 -0
- package/lib/types/host/git-service.d.ts +130 -0
- package/lib/types/host/git-service.d.ts.map +1 -0
- package/lib/types/host/loopback.d.ts +25 -0
- package/lib/types/host/loopback.d.ts.map +1 -0
- package/lib/types/host/poll-guard.d.ts +55 -0
- package/lib/types/host/poll-guard.d.ts.map +1 -0
- package/lib/types/host/routes.d.ts +54 -0
- package/lib/types/host/routes.d.ts.map +1 -0
- package/lib/types/index.d.ts +35 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/mount-once.d.ts +25 -0
- package/lib/types/mount-once.d.ts.map +1 -0
- package/package.json +85 -0
- package/src/client/FileManagerSettingsCard.tsx +117 -0
- package/src/client/PluginSettingsCard.tsx +337 -0
- package/src/client/api.ts +141 -0
- package/src/client/chat/file-ref.ts +144 -0
- package/src/client/chat/mermaid-chat.tsx +102 -0
- package/src/client/chat/placeholder-hint.tsx +46 -0
- package/src/client/components/ExplorerPanel.tsx +534 -0
- package/src/client/components/FileIcon.tsx +46 -0
- package/src/client/components/ScmPanel.tsx +480 -0
- package/src/client/components/a11y.ts +20 -0
- package/src/client/components/icons.tsx +274 -0
- package/src/client/components/overlay.tsx +225 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/drag/DragFileInlay.tsx +89 -0
- package/src/client/drag/file-drag.ts +67 -0
- package/src/client/drag.ts +154 -0
- package/src/client/file-source.ts +58 -0
- package/src/client/fileType.ts +129 -0
- package/src/client/floating.ts +63 -0
- package/src/client/hooks/useResizableSplit.ts +91 -0
- package/src/client/hooks/useStore.ts +15 -0
- package/src/client/index.ts +389 -0
- package/src/client/layout.ts +546 -0
- package/src/client/locales.ts +247 -0
- package/src/client/maximize.ts +34 -0
- package/src/client/mount.tsx +74 -0
- package/src/client/persist.ts +194 -0
- package/src/client/picker/FilePickerModal.tsx +506 -0
- package/src/client/picker/file-picker.ts +86 -0
- package/src/client/preview/PreviewPanel.tsx +233 -0
- package/src/client/preview/PreviewTabs.tsx +159 -0
- package/src/client/preview/PreviewToolbar.tsx +160 -0
- package/src/client/preview/content.tsx +617 -0
- package/src/client/preview/markdown.ts +351 -0
- package/src/client/preview/mermaid.ts +274 -0
- package/src/client/preview/selection.ts +82 -0
- package/src/client/reference.ts +161 -0
- package/src/client/settings-card.module.css +316 -0
- package/src/client/settings-form.ts +451 -0
- package/src/client/store.ts +1290 -0
- package/src/client/styles/chip.module.css +38 -0
- package/src/client/styles/drag.module.css +30 -0
- package/src/client/styles/explorer.module.css +371 -0
- package/src/client/styles/picker.module.css +344 -0
- package/src/client/styles/preview.module.css +904 -0
- package/src/client/styles/scm.module.css +380 -0
- package/src/client/styles/tokens.module.css +480 -0
- package/src/core/types.ts +162 -0
- package/src/host/fs-service.ts +513 -0
- package/src/host/gate.ts +74 -0
- package/src/host/git-runner.ts +116 -0
- package/src/host/git-service.ts +395 -0
- package/src/host/loopback.ts +63 -0
- package/src/host/poll-guard.ts +109 -0
- package/src/host/routes.ts +695 -0
- package/src/index.ts +97 -0
- package/src/mount-once.ts +48 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence helpers for panel preferences: range-validated reads (invalid
|
|
3
|
+
* stored values fall back to defaults — a broken or hand-edited value must
|
|
4
|
+
* never produce a 0px or NaN panel), debounced writes, and the LRU registry
|
|
5
|
+
* for preview scopes (at most 12 scopes; the oldest savedAt evicts).
|
|
6
|
+
*
|
|
7
|
+
* Keys follow the FileManager contract verbatim:
|
|
8
|
+
* chat-workspace-width-px, chat-preview-width-px, preview-panel-split-ratio,
|
|
9
|
+
* project-panel-collapse:<root>, explorer-ui:<root>, scm-ui:<root>,
|
|
10
|
+
* preview-ui:<root>.
|
|
11
|
+
* @module dsh-filemgr/client/persist
|
|
12
|
+
*/
|
|
13
|
+
/** Read a stored number, validating it against [min, max]; fallback otherwise. */
|
|
14
|
+
export declare function readStoredNumber(key: string, min: number, max: number, fallback: number): number;
|
|
15
|
+
/** Write a number if it differs from the stored value (avoids churn). */
|
|
16
|
+
export declare function writeStoredNumber(key: string, value: number): void;
|
|
17
|
+
/**
|
|
18
|
+
* A single debounce pipeline used by the stores for its search and persist
|
|
19
|
+
* timers: coalesces rapid schedules into one trailing run (the latest fn wins).
|
|
20
|
+
* `flush` runs the pending fn immediately (pagehide/beforeunload), `dispose`
|
|
21
|
+
* cancels a pending schedule. Behavior is equivalent to the stores' previous
|
|
22
|
+
* hand-rolled setTimeout + clearTimeout pairs, just centralized.
|
|
23
|
+
*/
|
|
24
|
+
export interface Debounced {
|
|
25
|
+
/** Queue a fn; repeated calls before the delay replaces the pending fn. */
|
|
26
|
+
schedule: (fn: () => void) => void;
|
|
27
|
+
/** Run the pending fn now and clear the timer. */
|
|
28
|
+
flush: () => void;
|
|
29
|
+
/** Cancel the pending fn and timer. */
|
|
30
|
+
dispose: () => void;
|
|
31
|
+
}
|
|
32
|
+
/** Create one debounced scheduler (default 150ms). */
|
|
33
|
+
export declare function createDebounced(delayMs?: number): Debounced;
|
|
34
|
+
/** The preview-ui scope registry: keys, savedAt values, eviction. */
|
|
35
|
+
export declare const PREVIEW_SCOPE_PREFIX = "preview-ui:";
|
|
36
|
+
/** LRU cap on distinct preview scopes. */
|
|
37
|
+
export declare const PREVIEW_SCOPE_CAP = 12;
|
|
38
|
+
/**
|
|
39
|
+
* Precisely delete every stored key under a prefix. Only this package's own
|
|
40
|
+
* prefixed keys are removed — foreign-application keys are never touched,
|
|
41
|
+
* replacing the former all-at-once `localStorage.clear()` sweep.
|
|
42
|
+
*/
|
|
43
|
+
export declare function removeStoredByPrefix(prefix: string): number;
|
|
44
|
+
/** All stored preview scopes with their savedAt timestamps, oldest first. */
|
|
45
|
+
export declare function listPreviewScopes(): Array<{
|
|
46
|
+
root: string;
|
|
47
|
+
savedAt: number;
|
|
48
|
+
}>;
|
|
49
|
+
/** Evict the oldest scopes beyond the cap. */
|
|
50
|
+
export declare function evictPreviewScopes(keep: string): void;
|
|
51
|
+
/** Serialize a JSON value with a size guard (quota failures degrade silently). */
|
|
52
|
+
export declare function writeJson(key: string, value: unknown): boolean;
|
|
53
|
+
/** Parse a stored JSON value; fallback on any failure. */
|
|
54
|
+
export declare function readJson<T>(key: string, fallback: T): T;
|
|
55
|
+
//# sourceMappingURL=persist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../../src/client/persist.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWhG;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQlE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;IAClC,kDAAkD;IAClD,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,uCAAuC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,sDAAsD;AACtD,wBAAgB,eAAe,CAAC,OAAO,SAAM,GAAG,SAAS,CAyBxD;AAED,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,gBAAgB,CAAA;AACjD,0CAA0C;AAC1C,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAqBnC;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAY3D;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAkB5E;AAED,8CAA8C;AAC9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgBrD;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAY9D;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAYvD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-picker modal: a pi-desktop-style multi-select tree browser for '@'
|
|
3
|
+
* file/folder references.
|
|
4
|
+
*
|
|
5
|
+
* Trigger: typing `@` (with nothing after it) in the composer opens this
|
|
6
|
+
* modal directly — no inline trigger menu (the shell's trigger menu is a
|
|
7
|
+
* flat candidate list that cannot host a tree). The modal owns a recursive
|
|
8
|
+
* tree with lazy expansion, a workspace filename search, per-row checkboxes
|
|
9
|
+
* for multi-selection, and a chip row of the picked paths.
|
|
10
|
+
*
|
|
11
|
+
* Insertion replaces the `@` token the picker was opened from with the
|
|
12
|
+
* picked references joined by spaces (`@a.ts @src/ @b.md`); cancel drops
|
|
13
|
+
* the stray `@`.
|
|
14
|
+
* @module dsh-filemgr/client/picker/FilePickerModal
|
|
15
|
+
*/
|
|
16
|
+
import type { JSX } from 'react';
|
|
17
|
+
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
|
|
18
|
+
import type { PanelApi } from '../api.ts';
|
|
19
|
+
import { type PickState } from './file-picker.ts';
|
|
20
|
+
/** One picked path with its kind (drives the trailing slash on insert). */
|
|
21
|
+
export interface PickedPath {
|
|
22
|
+
path: string;
|
|
23
|
+
isDir: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** The modal surface (portal target; renders only while open). */
|
|
26
|
+
export declare function FilePickerModal({ state, api, onInsert, onClose, }: {
|
|
27
|
+
state: PickState;
|
|
28
|
+
api: PanelApi;
|
|
29
|
+
onInsert: (paths: PickedPath[]) => void;
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
}): JSX.Element | null;
|
|
32
|
+
/** Active `@` mention candidate in the draft (mimics pi-desktop's getActiveMention). */
|
|
33
|
+
export declare function findAtMention(value: string, caret: number): {
|
|
34
|
+
start: number;
|
|
35
|
+
query: string;
|
|
36
|
+
} | null;
|
|
37
|
+
/**
|
|
38
|
+
* The picker host: watches the composer textarea for a bare `@` (opening the
|
|
39
|
+
* modal directly, pi-desktop style — no inline trigger menu), subscribes to
|
|
40
|
+
* the bridge, and renders the modal. Insertion replaces the `@` token span
|
|
41
|
+
* with the picked references joined by spaces; cancel drops the stray `@`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function FilePickerHost({ ctx, api }: {
|
|
44
|
+
ctx: ClientContext;
|
|
45
|
+
api: PanelApi;
|
|
46
|
+
}): JSX.Element;
|
|
47
|
+
//# sourceMappingURL=FilePickerModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilePickerModal.d.ts","sourceRoot":"","sources":["../../../../src/client/picker/FilePickerModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAE3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAoB7D,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,OAAO,CAAA;CACf;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,GAAG,EACH,QAAQ,EACR,OAAO,GACR,EAAE;IACD,KAAK,EAAE,SAAS,CAAA;IAChB,GAAG,EAAE,QAAQ,CAAA;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,IAAI,CAAA;IACvC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAuQrB;AAoBD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOnG;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,GAAG,EAAE,QAAQ,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAmJ/F"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-picker bridge: the single channel between the '@' trigger source
|
|
3
|
+
* (which asks for a directory) and the tree-browser modal (which renders it).
|
|
4
|
+
*
|
|
5
|
+
* Why a modal and not the inline trigger menu: the shell's trigger menu is a
|
|
6
|
+
* flat candidate list with no tree affordance — picking a directory cannot
|
|
7
|
+
* expand it (the menu closes on pick, and the shell only re-runs trigger
|
|
8
|
+
* detection on keyboard input, not on programmatic draft writes). The modal
|
|
9
|
+
* is the pi-desktop-style answer: a real directory tree with lazy expansion,
|
|
10
|
+
* a search box, and one-click insertion.
|
|
11
|
+
*
|
|
12
|
+
* The bridge is framework-free (subscribe/getSnapshot/open/close) so the
|
|
13
|
+
* trigger source can open the picker without touching React; the modal host
|
|
14
|
+
* component subscribes and renders. Insertion happens through the
|
|
15
|
+
* conversation input shell, replacing the exact `@` token span the picker
|
|
16
|
+
* was opened from.
|
|
17
|
+
* @module dsh-filemgr/client/picker/file-picker
|
|
18
|
+
*/
|
|
19
|
+
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client';
|
|
20
|
+
/** The `@` token span captured when the picker opened (replace-on-insert). */
|
|
21
|
+
export interface PickSpan {
|
|
22
|
+
/** Start offset of the `@` token in the draft. */
|
|
23
|
+
start: number;
|
|
24
|
+
/** End offset (the caret). */
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
/** What the picker is currently anchored to. */
|
|
28
|
+
export interface PickRequest {
|
|
29
|
+
/** Session whose draft the picker will edit. */
|
|
30
|
+
sessionId: SessionId;
|
|
31
|
+
/** Project root (canonical cwd) everything is relative to. */
|
|
32
|
+
root: string;
|
|
33
|
+
/** Directory to start browsing at ('' = root). */
|
|
34
|
+
initialDir: string;
|
|
35
|
+
/** The `@` token span to replace on insert. */
|
|
36
|
+
span: PickSpan;
|
|
37
|
+
}
|
|
38
|
+
/** The bridge's public snapshot. */
|
|
39
|
+
export interface PickState {
|
|
40
|
+
open: boolean;
|
|
41
|
+
req: PickRequest | null;
|
|
42
|
+
}
|
|
43
|
+
/** Minimal listener shape. */
|
|
44
|
+
type Listener = (state: PickState) => void;
|
|
45
|
+
/** Framework-free singleton store backing the modal. */
|
|
46
|
+
declare class FilePickerBridge {
|
|
47
|
+
private state;
|
|
48
|
+
private readonly listeners;
|
|
49
|
+
/** Current snapshot (stable reference until the next open/close). */
|
|
50
|
+
getSnapshot(): PickState;
|
|
51
|
+
/** Subscribe to open/close transitions. */
|
|
52
|
+
subscribe(listener: Listener): () => void;
|
|
53
|
+
/** Open the picker anchored to one `@` token. */
|
|
54
|
+
open(req: PickRequest): void;
|
|
55
|
+
/** Close the picker without inserting anything. */
|
|
56
|
+
close(): void;
|
|
57
|
+
private emit;
|
|
58
|
+
}
|
|
59
|
+
/** The shared singleton instance. */
|
|
60
|
+
export declare const filePicker: FilePickerBridge;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=file-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-picker.d.ts","sourceRoot":"","sources":["../../../../src/client/picker/file-picker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAEvE,8EAA8E;AAC9E,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,SAAS,EAAE,SAAS,CAAA;IACpB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,+CAA+C;IAC/C,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,oCAAoC;AACpC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,WAAW,GAAG,IAAI,CAAA;CACxB;AAED,8BAA8B;AAC9B,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAA;AAE1C,wDAAwD;AACxD,cAAM,gBAAgB;IACpB,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;IAEhD,qEAAqE;IACrE,WAAW,IAAI,SAAS;IAIxB,2CAA2C;IAC3C,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAKzC,iDAAiD;IACjD,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAK5B,mDAAmD;IACnD,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,IAAI;CAGb;AAED,qCAAqC;AACrC,eAAO,MAAM,UAAU,kBAAyB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview panel root: tab strip + toolbar + content router, the tab
|
|
3
|
+
* context menu (close left/right/others/all), the dirty-close confirmation
|
|
4
|
+
* (the single entry for every batch close — middle-click included), and the
|
|
5
|
+
* panel collapse button. View mode and split live here so the toolbar and the
|
|
6
|
+
* content share one source; both reset when the displayed file changes.
|
|
7
|
+
* @module dsh-filemgr/client/preview/PreviewPanel
|
|
8
|
+
*/
|
|
9
|
+
import type { JSX } from 'react';
|
|
10
|
+
import type { PanelStores } from '../store.ts';
|
|
11
|
+
import { type FileReferenceSelection } from './selection.ts';
|
|
12
|
+
/** The preview panel (mounted in the preview grid column). */
|
|
13
|
+
export declare function PreviewPanel({ stores, onAddFileReference }: {
|
|
14
|
+
stores: PanelStores;
|
|
15
|
+
onAddFileReference: (selection: FileReferenceSelection) => boolean;
|
|
16
|
+
}): JSX.Element;
|
|
17
|
+
//# sourceMappingURL=PreviewPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewPanel.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/PreviewPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAIhC,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAA;AAK/D,OAAO,EAA8B,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAUxF,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,kBAAkB,EAAE,CAAC,SAAS,EAAE,sBAAsB,KAAK,OAAO,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CA0MrK"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview tab strip: 36px bar, tabs capped at 180px (padding 0 10, gap 6,
|
|
3
|
+
* 12px title), dirty dot (6px, primary), close glyph (16px box, 12px icon),
|
|
4
|
+
* middle-click close, right-click menu (close left/right/others/all), the
|
|
5
|
+
* 32px left/right overflow fade indicators (ResizeObserver + scroll), the
|
|
6
|
+
* new-URL-tab plus, and the panel collapse button.
|
|
7
|
+
* @module dsh-filemgr/client/preview/PreviewTabs
|
|
8
|
+
*/
|
|
9
|
+
import type { JSX } from 'react';
|
|
10
|
+
import type { PreviewTabState } from '../store.ts';
|
|
11
|
+
/** Tab width cap (FileManager measured). */
|
|
12
|
+
export declare const MAX_TAB_WIDTH_PX = 180;
|
|
13
|
+
/** Left/right overflow state. */
|
|
14
|
+
export interface TabFadeState {
|
|
15
|
+
left: boolean;
|
|
16
|
+
right: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The tab strip. */
|
|
19
|
+
export declare function PreviewTabs({ tabs, activeTabId, onSwitch, onClose, onContextMenu, onNewUrlTab, onClosePanel, maximized, onMaximize, }: {
|
|
20
|
+
tabs: PreviewTabState[];
|
|
21
|
+
activeTabId: string | null;
|
|
22
|
+
onSwitch: (id: string) => void;
|
|
23
|
+
onClose: (id: string) => void;
|
|
24
|
+
onContextMenu: (event: React.MouseEvent, tab: PreviewTabState) => void;
|
|
25
|
+
onNewUrlTab: () => void;
|
|
26
|
+
onClosePanel: () => void;
|
|
27
|
+
maximized: boolean;
|
|
28
|
+
onMaximize: () => void;
|
|
29
|
+
}): JSX.Element;
|
|
30
|
+
//# sourceMappingURL=PreviewTabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewTabs.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/PreviewTabs.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAMlD,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAInC,iCAAiC;AACjC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;CACf;AAED,qBAAqB;AACrB,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,OAAO,EACP,aAAa,EACb,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,GACX,EAAE;IACD,IAAI,EAAE,eAAe,EAAE,CAAA;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,GAAG,EAAE,eAAe,KAAK,IAAI,CAAA;IACtE,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB,GAAG,GAAG,CAAC,OAAO,CA6Gd"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview toolbar: 32px bar (padding 0 10). Left: source/preview toggle
|
|
3
|
+
* (markdown/html), split-screen toggle (editable types), download. Right: the
|
|
4
|
+
* refresh button (4-state: hidden/disabled/idle/updated — never a dead
|
|
5
|
+
* button) and save (editable + dirty, Cmd/Ctrl+S too).
|
|
6
|
+
* @module dsh-filemgr/client/preview/PreviewToolbar
|
|
7
|
+
*/
|
|
8
|
+
import type { JSX } from 'react';
|
|
9
|
+
import type { PreviewContentType } from '../../core/types.ts';
|
|
10
|
+
/** Refresh button states (FileManager's 4-state machine). */
|
|
11
|
+
export type RefreshState = 'hidden' | 'disabled' | 'idle' | 'updated';
|
|
12
|
+
/** Derive the refresh state for one tab. */
|
|
13
|
+
export declare function refreshStateFor(contentType: PreviewContentType, hasContent: boolean, loading: boolean, updated: boolean): RefreshState;
|
|
14
|
+
/** Download the current tab's content as a file. */
|
|
15
|
+
export declare function downloadTab(tab: {
|
|
16
|
+
title: string;
|
|
17
|
+
content: string | null;
|
|
18
|
+
contentType: PreviewContentType;
|
|
19
|
+
}): void;
|
|
20
|
+
/** The toolbar. */
|
|
21
|
+
export declare function PreviewToolbar({ contentType, hasContent, loading, dirty, updated, viewMode, canToggleView, split, canSplit, onViewModeChange, onSplitChange, onRefresh, onSave, onDownload, }: {
|
|
22
|
+
contentType: PreviewContentType;
|
|
23
|
+
hasContent: boolean;
|
|
24
|
+
loading: boolean;
|
|
25
|
+
dirty: boolean;
|
|
26
|
+
updated: boolean;
|
|
27
|
+
viewMode: 'source' | 'preview';
|
|
28
|
+
canToggleView: boolean;
|
|
29
|
+
split: boolean;
|
|
30
|
+
canSplit: boolean;
|
|
31
|
+
onViewModeChange: (mode: 'source' | 'preview') => void;
|
|
32
|
+
onSplitChange: (split: boolean) => void;
|
|
33
|
+
onRefresh: () => void;
|
|
34
|
+
onSave: () => void;
|
|
35
|
+
onDownload: () => void;
|
|
36
|
+
}): JSX.Element;
|
|
37
|
+
//# sourceMappingURL=PreviewToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewToolbar.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/PreviewToolbar.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAM7D,6DAA6D;AAC7D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAA;AAErE,4CAA4C;AAC5C,wBAAgB,eAAe,CAC7B,WAAW,EAAE,kBAAkB,EAC/B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACf,YAAY,CAUd;AAED,oDAAoD;AACpD,wBAAgB,WAAW,CAAC,GAAG,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,kBAAkB,CAAA;CAAE,GAAG,IAAI,CAiBjH;AAED,mBAAmB;AACnB,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,UAAU,EACV,OAAO,EACP,KAAK,EACL,OAAO,EACP,QAAQ,EACR,aAAa,EACb,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,MAAM,EACN,UAAU,GACX,EAAE;IACD,WAAW,EAAE,kBAAkB,CAAA;IAC/B,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC9B,aAAa,EAAE,OAAO,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,gBAAgB,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,CAAA;IACtD,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACvC,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB,GAAG,GAAG,CAAC,OAAO,CAwEd"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview content routing: the renderers for every content type plus the
|
|
3
|
+
* split-screen editor|preview layout. View mode (source/preview) resets to
|
|
4
|
+
* preview when the displayed FILE changes (keyed on path+type, not tab id —
|
|
5
|
+
* FileManager contract), and the split ratio is persisted under
|
|
6
|
+
* preview-panel-split-ratio with a 20..80 clamp.
|
|
7
|
+
* @module dsh-filemgr/client/preview/content
|
|
8
|
+
*/
|
|
9
|
+
import type { JSX } from 'react';
|
|
10
|
+
import type { PreviewTabState } from '../store.ts';
|
|
11
|
+
/** Split-ratio persistence key (FileManager contract). */
|
|
12
|
+
export declare const KEY_SPLIT_RATIO = "preview-panel-split-ratio";
|
|
13
|
+
/** The rendered content of one tab (viewMode/split are controlled by the panel). */
|
|
14
|
+
export declare function TabContent({ tab, viewMode, split, onContentChange, onSave, }: {
|
|
15
|
+
tab: PreviewTabState;
|
|
16
|
+
viewMode: 'source' | 'preview';
|
|
17
|
+
split: boolean;
|
|
18
|
+
onContentChange: (content: string) => void;
|
|
19
|
+
onSave: () => void;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Syntax-highlighted code/text viewer (official shiki core via CodeBlock),
|
|
23
|
+
* wrapped in a line-number gutter.
|
|
24
|
+
*
|
|
25
|
+
* Alignment strategy: instead of trusting CSS to mirror the code block's
|
|
26
|
+
* internal metrics (its language banner, `pre` padding and line-height are
|
|
27
|
+
* owned by the primitives package), the gutter is measured against the live
|
|
28
|
+
* `pre` — its top offset inside the shell (the banner's height) and its
|
|
29
|
+
* computed line-height are read after render and applied as inline styles.
|
|
30
|
+
* This keeps the numbers exactly on their lines regardless of the primitives'
|
|
31
|
+
* internal layout. The trailing newline is not counted (CodeBlock trims it).
|
|
32
|
+
*/
|
|
33
|
+
export declare function CodeViewer({ content, language }: {
|
|
34
|
+
content: string;
|
|
35
|
+
language: string;
|
|
36
|
+
}): JSX.Element;
|
|
37
|
+
/** Parse CSV lines (quoted cells with escaped quotes). */
|
|
38
|
+
export declare function parseCsv(text: string): string[][];
|
|
39
|
+
/** Convert a data URL to a Blob (null on failure). */
|
|
40
|
+
export declare function dataUrlToBlob(dataUrl: string): Blob | null;
|
|
41
|
+
/** Bare domains get https://; whitespace queries go to a search engine. */
|
|
42
|
+
export declare function normalizeUrl(input: string): string;
|
|
43
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/content.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAclD,0DAA0D;AAC1D,eAAO,MAAM,eAAe,8BAA8B,CAAA;AAE1D,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,QAAQ,EACR,KAAK,EACL,eAAe,EACf,MAAM,GACP,EAAE;IACD,GAAG,EAAE,eAAe,CAAA;IACpB,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC9B,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,GAAG,GAAG,CAAC,OAAO,CAiEd;AA8JD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,GAAG,CAAC,OAAO,CAmEpG;AAmDD,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAyCjD;AAgED,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAa1D;AAuED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBlD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A compact markdown renderer for the preview panel: headings, paragraphs,
|
|
3
|
+
* fenced + inline code, bold/italic, links/images, lists, blockquotes, hr,
|
|
4
|
+
* and tables. All HTML is escaped before transformation — the output only
|
|
5
|
+
* ever contains the renderer's own tags. Pure and exported for tests.
|
|
6
|
+
* @module dsh-filemgr/client/preview/markdown
|
|
7
|
+
*/
|
|
8
|
+
/** Escape HTML special characters. */
|
|
9
|
+
export declare function escapeHtml(text: string): string;
|
|
10
|
+
/** How one image src resolves against the markdown file's location. */
|
|
11
|
+
export type MarkdownImageResolution =
|
|
12
|
+
/** Scheme URL or fragment: the browser resolves it as-is. */
|
|
13
|
+
{
|
|
14
|
+
kind: 'absolute';
|
|
15
|
+
}
|
|
16
|
+
/** Workspace-relative target: resolved path plus any ?query#fragment suffix. */
|
|
17
|
+
| {
|
|
18
|
+
kind: 'relative';
|
|
19
|
+
path: string;
|
|
20
|
+
suffix: string;
|
|
21
|
+
}
|
|
22
|
+
/** `..` escaped the project root: the image must be dropped. */
|
|
23
|
+
| {
|
|
24
|
+
kind: 'escape';
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Resolve one markdown image src against the markdown file's location:
|
|
28
|
+
* - Absolute URLs (http/https/data:/...) and fragment-only srcs are left to
|
|
29
|
+
* the browser ('absolute').
|
|
30
|
+
* - Root-relative srcs (/img.png) resolve from the project root; other
|
|
31
|
+
* relative srcs resolve against the file's directory. `..` escaping the
|
|
32
|
+
* project root is rejected ('escape').
|
|
33
|
+
* - The path portion is percent-decoded (markdown authors encode spaces in
|
|
34
|
+
* filenames) and any ?query#fragment suffix is preserved verbatim, so
|
|
35
|
+
* cache-busting srcs like ./img.png?v=2 still fetch img.png.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveMarkdownImage(filePath: string, src: string): MarkdownImageResolution;
|
|
38
|
+
/** Options controlling markdown rendering. */
|
|
39
|
+
export interface MarkdownRenderOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Rewrite image srcs before they are emitted. Return the URL to use, or
|
|
42
|
+
* null to drop the image (alt text only). Relative workspace paths are
|
|
43
|
+
* typically resolved to absolute URLs here.
|
|
44
|
+
*/
|
|
45
|
+
resolveImageSrc?: (src: string) => string | null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Guard a raw link/image target against dangerous protocols. Returns the
|
|
49
|
+
* (trimmed) raw string when safe, else null. Only these schemes are allowed:
|
|
50
|
+
* http:, https:, mailto: and fragment anchors (#...). Scheme-less relative
|
|
51
|
+
* paths (./ ../ / and plain filenames) pass through unchanged. Anything with
|
|
52
|
+
* a scheme outside the allow-list — javascript:, data:, vbscript:, etc. —
|
|
53
|
+
* is rejected so the value never reaches dangerouslySetInnerHTML.
|
|
54
|
+
*/
|
|
55
|
+
export declare function safeUrl(raw: string): string | null;
|
|
56
|
+
/** Inline pass: code spans, bold, italic, images, links. */
|
|
57
|
+
export declare function renderInline(text: string, options?: MarkdownRenderOptions): string;
|
|
58
|
+
/** Render a markdown document to HTML (block pass). */
|
|
59
|
+
export declare function renderMarkdown(source: string, options?: MarkdownRenderOptions): string;
|
|
60
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,sCAAsC;AACtC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,uEAAuE;AACvE,MAAM,MAAM,uBAAuB;AACjC,6DAA6D;AAC3D;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE;AACtB,gFAAgF;GAC9E;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACpD,gEAAgE;GAC9D;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAgCtB;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAiB3F;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAA;CACjD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQlD;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAgGlF;AAED,uDAAuD;AACvD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CA+HtF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mermaid diagram enhancement for markdown surfaces: lazily loads the
|
|
3
|
+
* mermaid runtime from the host vendor route (same origin, no CDN), renders
|
|
4
|
+
* every fenced ```mermaid code block in place, and re-renders on theme
|
|
5
|
+
* flips. Framework-free so both the preview panel (React effect) and the
|
|
6
|
+
* chat transcript observer can drive it over disjoint DOM scopes.
|
|
7
|
+
*
|
|
8
|
+
* Failure policy: any load/render failure leaves the original code block
|
|
9
|
+
* untouched (or restores it verbatim); nothing here throws to the caller.
|
|
10
|
+
* @module dsh-filemgr/client/preview/mermaid
|
|
11
|
+
*/
|
|
12
|
+
/** Minimal structural type of the mermaid runtime this module consumes. */
|
|
13
|
+
interface MermaidRuntime {
|
|
14
|
+
initialize: (config: Record<string, unknown>) => void;
|
|
15
|
+
render: (id: string, text: string, container?: HTMLElement) => Promise<{
|
|
16
|
+
svg: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/** Host-served mermaid IIFE bundle (lib/assets/mermaid.min.js behind the route). */
|
|
20
|
+
export declare const MERMAID_VENDOR_URL = "/filemgr/vendor/mermaid.js";
|
|
21
|
+
/** Marker the preview viewer stamps on its own subtree (chat enhancement skips it). */
|
|
22
|
+
export declare const DATA_MD_SCOPE = "data-filemgr-md-scope";
|
|
23
|
+
/**
|
|
24
|
+
* Load the mermaid runtime once per page: injects a <script> for the host
|
|
25
|
+
* vendor route and resolves with the runtime. Concurrent callers share one
|
|
26
|
+
* injection; a failure clears the cache so a later surface can retry.
|
|
27
|
+
*/
|
|
28
|
+
export declare function loadMermaidLibrary(): Promise<MermaidRuntime>;
|
|
29
|
+
/** Mermaid theme name for the shell theme marker (`default` or `dark`). */
|
|
30
|
+
export declare function mermaidTheme(isDark: boolean): 'default' | 'dark';
|
|
31
|
+
/** Whether the shell currently carries the dark marker attribute. */
|
|
32
|
+
export declare function shellIsDark(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Application-level defense-in-depth on top of mermaid's own strict-mode
|
|
35
|
+
* escaping: parse the rendered SVG in a detached container, remove disallowed
|
|
36
|
+
* elements and dangerous attributes, and return the serialized cleaned markup.
|
|
37
|
+
* Throws when the input cannot be parsed as markup or still carries dangerous
|
|
38
|
+
* raw tokens, so callers fall back to their failure path.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sanitizeSvg(svg: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Collect the still-unclaimed fenced mermaid code blocks under one scope.
|
|
43
|
+
* Both shapes are found: the panel renderer's `pre.language-mermaid` and
|
|
44
|
+
* the chat renderer's `pre > code.language-mermaid` (the claim always
|
|
45
|
+
* targets the <pre>). Empty blocks and blocks another driver already
|
|
46
|
+
* claimed are skipped. Pure (DOM-read only) so tests can drive it in jsdom.
|
|
47
|
+
*/
|
|
48
|
+
export declare function findMermaidCodeBlocks(scope: ParentNode): HTMLPreElement[];
|
|
49
|
+
/** Options for {@link enhanceMermaidBlocks}. */
|
|
50
|
+
export interface EnhanceOptions {
|
|
51
|
+
/** Class for the diagram container (a CSS module export). */
|
|
52
|
+
className: string;
|
|
53
|
+
/** Resolved mermaid theme name. */
|
|
54
|
+
theme: string;
|
|
55
|
+
/** Optional extra exclusion for scopes another driver owns. */
|
|
56
|
+
skip?: (pre: HTMLPreElement) => boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Render every unclaimed ```mermaid block under `scope` into an inline SVG
|
|
60
|
+
* diagram. Idempotent per block across drivers (claimed blocks are skipped);
|
|
61
|
+
* failures restore the original code block. Never rejects.
|
|
62
|
+
*/
|
|
63
|
+
export declare function enhanceMermaidBlocks(scope: ParentNode, options: EnhanceOptions): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Re-render every completed diagram container under `scope` after a theme
|
|
66
|
+
* flip (stored sources re-render with the new theme). Containers not in the
|
|
67
|
+
* `done` state are skipped; a failure keeps the previous render.
|
|
68
|
+
*/
|
|
69
|
+
export declare function rethemeMermaidBlocks(scope: ParentNode, options: {
|
|
70
|
+
theme: string;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* One dark-marker watcher per surface: fires on body attribute flips so the
|
|
74
|
+
* caller can retheme. Returns the disposer.
|
|
75
|
+
*/
|
|
76
|
+
export declare function watchShellTheme(onChange: (isDark: boolean) => void): () => void;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/mermaid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2EAA2E;AAC3E,UAAU,cAAc;IACtB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACrD,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACxF;AAED,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,+BAA+B,CAAA;AAW9D,uFAAuF;AACvF,eAAO,MAAM,aAAa,0BAA0B,CAAA;AAgBpD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,cAAc,CAAC,CAwB5D;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAEhE;AAED,qEAAqE;AACrE,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAsCD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA6B/C;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,cAAc,EAAE,CAazE;AAiBD,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAA;IACjB,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,+DAA+D;IAC/D,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAA;CACxC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BpG;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAcvG;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAI/E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate a text selection inside the preview into a file reference (path
|
|
3
|
+
* plus start/end line). The selection must live inside a `<pre>` of a file-
|
|
4
|
+
* backed preview (code / text / markdown source / diff); returns null for
|
|
5
|
+
* anything else so the caller can hide the floating action.
|
|
6
|
+
*
|
|
7
|
+
* The reference carries only what the agent needs: the workspace-relative
|
|
8
|
+
* path of the file and the 1-based line range. The selected text itself is
|
|
9
|
+
* not copied into the composer — the agent re-reads the file at the line
|
|
10
|
+
* range when the message is sent.
|
|
11
|
+
* @module dsh-filemgr/client/preview/selection
|
|
12
|
+
*/
|
|
13
|
+
import type { PreviewTabState } from '../store.ts';
|
|
14
|
+
/** The file-backed reference we surface from a preview selection. */
|
|
15
|
+
export interface FileReferenceSelection {
|
|
16
|
+
path: string;
|
|
17
|
+
startLine: number;
|
|
18
|
+
endLine: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a FileReferenceSelection from a browser selection if it points to a
|
|
22
|
+
* supported preview's `<pre>`. Returns null otherwise (image / pdf / url /
|
|
23
|
+
* non-line content, or a selection that lives outside any code block).
|
|
24
|
+
*/
|
|
25
|
+
export declare function findFileReferenceSelection(anchorElement: Element | null, selection: Selection, tab: PreviewTabState | null): FileReferenceSelection | null;
|
|
26
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../src/client/preview/selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,qEAAqE;AACrE,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAkCD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,OAAO,GAAG,IAAI,EAC7B,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,eAAe,GAAG,IAAI,GAC1B,sBAAsB,GAAG,IAAI,CAkB/B"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ClientContext, SessionId } from '@deepseek-ai/dsh-client-runtime/client';
|
|
2
|
+
/**
|
|
3
|
+
* Composer draft helpers for file references.
|
|
4
|
+
*
|
|
5
|
+
* References ride the shell's native U+FFFC chip pipeline
|
|
6
|
+
* (`slash/input-insert-reference` bail): the composer shows one chip pill in
|
|
7
|
+
* place of the hidden `@path:lines` token, and the model text is serialized
|
|
8
|
+
* on submit through the `file` reference source's codec (registered in
|
|
9
|
+
* file-source.ts). Without that codec the submit attempt fails with
|
|
10
|
+
* `slash: no serializer for reference source "file"` — the codec MUST stay
|
|
11
|
+
* registered while any chip is in a draft.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Minimal structural view of the conversation input service. Declared locally
|
|
15
|
+
* so this helper has no value import from the conversation package (keeps the
|
|
16
|
+
* client bundle purity gate happy).
|
|
17
|
+
*/
|
|
18
|
+
interface DraftInput {
|
|
19
|
+
state: {
|
|
20
|
+
getSnapshot(): {
|
|
21
|
+
draft: string;
|
|
22
|
+
draftRev: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
setDraft(draft: string): void;
|
|
26
|
+
}
|
|
27
|
+
export interface ConversationService {
|
|
28
|
+
input: {
|
|
29
|
+
for(actx: ClientContext): DraftInput;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** The file-backed reference a composer chip stands for. */
|
|
33
|
+
export interface FileReference {
|
|
34
|
+
/** Workspace-relative path (what the agent will read). */
|
|
35
|
+
path: string;
|
|
36
|
+
/** First line of the referenced range (1-based, inclusive). */
|
|
37
|
+
startLine: number;
|
|
38
|
+
/** Last line of the referenced range (1-based, inclusive). */
|
|
39
|
+
endLine: number;
|
|
40
|
+
}
|
|
41
|
+
/** The `@path:lines` model form (what the codec serializes to on submit). */
|
|
42
|
+
export declare function formatFileRefToken(ref: {
|
|
43
|
+
path: string;
|
|
44
|
+
startLine: number;
|
|
45
|
+
endLine: number;
|
|
46
|
+
}): string;
|
|
47
|
+
/** The DRAFT-REV+CAS span the conversation machine expects for chip inserts. */
|
|
48
|
+
export interface RefSpan {
|
|
49
|
+
start: number;
|
|
50
|
+
end: number;
|
|
51
|
+
draftRev: number;
|
|
52
|
+
}
|
|
53
|
+
/** Append `text` to the session's composer draft (plain text — no chip). */
|
|
54
|
+
export declare function appendToDraft(ctx: ClientContext, sessionId: SessionId | undefined, text: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Insert a file-reference chip into the composer draft at `span`, replacing
|
|
57
|
+
* its range with an occurrence the machine renders as a `</> name N-M`
|
|
58
|
+
* pill. The model text (`@path:lines`) is serialized on submit by the `file`
|
|
59
|
+
* source's codec (file-source.ts) — never the clipboard text.
|
|
60
|
+
*
|
|
61
|
+
* @returns true when the bail was accepted (CAS will still reject on
|
|
62
|
+
* stale draftRev — caller can re-read draft after).
|
|
63
|
+
*/
|
|
64
|
+
export declare function insertFileReference(ctx: ClientContext, sessionId: SessionId | undefined, ref: FileReference, span: RefSpan): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Append a file-reference chip at the end of the current draft (the explorer
|
|
67
|
+
* `@` button and the preview "添加到对话" action path). Reads the latest
|
|
68
|
+
* draft + draftRev from the conversation shell and inserts a zero-length chip
|
|
69
|
+
* there, so the chip lands after whatever the user has already typed.
|
|
70
|
+
*
|
|
71
|
+
* @returns true on success.
|
|
72
|
+
*/
|
|
73
|
+
export declare function appendFileReferenceChip(ctx: ClientContext, sessionId: SessionId | undefined, ref: FileReference): boolean;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/client/reference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAEtF;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,UAAU,UAAU;IAClB,KAAK,EAAE;QAAE,WAAW,IAAI;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;IAC7D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AACD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE;QAAE,GAAG,CAAC,IAAI,EAAE,aAAa,GAAG,UAAU,CAAA;KAAE,CAAA;CAChD;AAED,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,SAAS,EAAE,MAAM,CAAA;IACjB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAA;CAChB;AA0BD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAGpG;AAUD,gFAAgF;AAChF,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAezG;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,OAAO,GACZ,OAAO,CAkBT;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,GAAG,EAAE,aAAa,GACjB,OAAO,CAcT"}
|