@deepseek-ai/dsh-client-ui-sidebar-documentpreview 0.1.5-alpha.2
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.i18n.yaml +6 -0
- package/README.md +92 -0
- package/README.zh.md +92 -0
- package/lib/client.js +26957 -0
- package/lib/index.js +6 -0
- package/lib/types/client/LoadingIndicator.d.ts +8 -0
- package/lib/types/client/TextPreview.d.ts +23 -0
- package/lib/types/client/TextTitle.d.ts +14 -0
- package/lib/types/client/code/CodeBody.d.ts +9 -0
- package/lib/types/client/code/index.d.ts +5 -0
- package/lib/types/client/code/languages.d.ts +9 -0
- package/lib/types/client/code/locales.d.ts +19 -0
- package/lib/types/client/definition.d.ts +32 -0
- package/lib/types/client/document/contract.d.ts +55 -0
- package/lib/types/client/document/registry.d.ts +55 -0
- package/lib/types/client/face.d.ts +72 -0
- package/lib/types/client/failure-line.d.ts +17 -0
- package/lib/types/client/html/HtmlBody.d.ts +16 -0
- package/lib/types/client/html/bootstrap.d.ts +20 -0
- package/lib/types/client/html/bytes.d.ts +14 -0
- package/lib/types/client/html/index.d.ts +17 -0
- package/lib/types/client/html/locales.d.ts +23 -0
- package/lib/types/client/html/pack.d.ts +21 -0
- package/lib/types/client/html/read-relative.d.ts +21 -0
- package/lib/types/client/icons.d.ts +14 -0
- package/lib/types/client/image/ImageBody.d.ts +31 -0
- package/lib/types/client/image/index.d.ts +19 -0
- package/lib/types/client/image/locales.d.ts +25 -0
- package/lib/types/client/index.d.ts +51 -0
- package/lib/types/client/locales.d.ts +52 -0
- package/lib/types/client/markdown/MarkdownBody.d.ts +12 -0
- package/lib/types/client/markdown/index.d.ts +17 -0
- package/lib/types/client/markdown/locales.d.ts +23 -0
- package/lib/types/client/pdf/PdfBody.d.ts +24 -0
- package/lib/types/client/pdf/assets.d.ts +26 -0
- package/lib/types/client/pdf/document.d.ts +32 -0
- package/lib/types/client/pdf/errors.d.ts +8 -0
- package/lib/types/client/pdf/index.d.ts +14 -0
- package/lib/types/client/pdf/locales.d.ts +33 -0
- package/lib/types/client/pdf/runtime.d.ts +14 -0
- package/lib/types/client/pdf/store.d.ts +26 -0
- package/lib/types/client/rpc.d.ts +77 -0
- package/lib/types/client/store.d.ts +90 -0
- package/lib/types/client/text/TextBody.d.ts +6 -0
- package/lib/types/client/text/index.d.ts +14 -0
- package/lib/types/client/text/lines.d.ts +31 -0
- package/lib/types/index.d.ts +4 -0
- package/package.json +78 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Shared indeterminate loading feedback for document reads and rendering. */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/** @param props - localized status label and optional placement style. @returns an animated, accessible loading status. */
|
|
4
|
+
export declare function LoadingIndicator({ label, className }: {
|
|
5
|
+
label: string;
|
|
6
|
+
className?: string | undefined;
|
|
7
|
+
}): ReactNode;
|
|
8
|
+
//# sourceMappingURL=LoadingIndicator.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
|
|
3
|
+
import type { InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { TextInjected } from './face.ts';
|
|
5
|
+
import type { TextStore } from './store.ts';
|
|
6
|
+
import type { DocumentPreviewDefinition } from './document/registry.ts';
|
|
7
|
+
export { linesOf, loadedPages, lastLineLoaded, scrollToLine } from './text/lines.ts';
|
|
8
|
+
export type { LoadedPage } from './text/lines.ts';
|
|
9
|
+
/** Private registration inputs; the framework binds the registry source to useDocumentPreviews. */
|
|
10
|
+
export interface TextPreviewInjected extends TextInjected {
|
|
11
|
+
readonly hooks: {
|
|
12
|
+
readonly documentPreviews: ObservableSnapshot<readonly DocumentPreviewDefinition[]>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The body's composed props: the tab, its navigation, the shared store and face, and copy. */
|
|
16
|
+
export type TextPreviewProps = PropsRuntime<'sidebar.right.pane.tab'> & PropsRenderSlots<'sidebar.right.tab.document'> & PropsStore<TextStore> & InjectFace<TextPreviewInjected> & PropsLocale<'sidebarDocumentPreview'>;
|
|
17
|
+
/**
|
|
18
|
+
* The text type's body, registered under `sidebar.right.pane.tab` as `text`.
|
|
19
|
+
* @param props - composed slot props.
|
|
20
|
+
* @returns the content read so far with its controls, or a progress line.
|
|
21
|
+
*/
|
|
22
|
+
export declare function TextPreview({ useTabInfo, useResource, useStore, actions, loadPage, reloadPages, loadAll, reloadAll, useDocumentPreviews, renderSlot, t, }: TextPreviewProps): ReactNode;
|
|
23
|
+
//# sourceMappingURL=TextPreview.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text type's chip title: the file type's coloured sheet before the name
|
|
3
|
+
* the registry captured at open time. Registered under
|
|
4
|
+
* `sidebar.right.pane.tab.title`; without it the chip would show the bare name.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
8
|
+
/**
|
|
9
|
+
* The title as the chip and a floating panel's header show it.
|
|
10
|
+
* @param props - the tab information hook.
|
|
11
|
+
* @returns the type's 16px sheet followed by the tab's title text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function TextTitle({ useTabInfo }: PropsRuntime<'sidebar.right.pane.tab.title'>): ReactNode;
|
|
14
|
+
//# sourceMappingURL=TextTitle.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Incrementally highlighted source; the document owner supplies the accumulated text and wrap preference. */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
5
|
+
/** Document owner props and this renderer's localized controls. */
|
|
6
|
+
export type CodeBodyProps = DocumentPreviewProps & PropsLocale<'sidebarCodePreview'>;
|
|
7
|
+
/** @param props - accumulated document contents and framework props. @returns one stable CodeBlock, or no body for byte contents. */
|
|
8
|
+
export declare function CodeBody({ resourceAddress, content, wrap, t }: CodeBodyProps): ReactNode;
|
|
9
|
+
//# sourceMappingURL=CodeBody.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Code preview metadata and body registered through the public document extension points. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
/** @param ctx - owning plugin context. Register localized metadata and the matching keyed document body. */
|
|
4
|
+
export declare function apply(ctx: Context): void;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Recognized suffixes shared by renderer selection and language hints. */
|
|
2
|
+
export declare const CODE_EXTENSIONS: readonly string[];
|
|
3
|
+
/**
|
|
4
|
+
* Select the shared highlighter's grammar for a filename.
|
|
5
|
+
* @param path - decoded source filename or path.
|
|
6
|
+
* @returns a supported grammar hint, or undefined for other suffixes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function languageForPath(path: string): string | undefined;
|
|
9
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
2
|
+
interface LocaleNamespaceMap {
|
|
3
|
+
/** Code document implementation name and copy controls. */
|
|
4
|
+
sidebarCodePreview: keyof typeof zh;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** Simplified Chinese dictionary and key source. */
|
|
8
|
+
export declare const zh: {
|
|
9
|
+
title: string;
|
|
10
|
+
copy: string;
|
|
11
|
+
copied: string;
|
|
12
|
+
};
|
|
13
|
+
/** English dictionary with the same keys. */
|
|
14
|
+
export declare const en: {
|
|
15
|
+
title: string;
|
|
16
|
+
copy: string;
|
|
17
|
+
copied: string;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage one of this package's registration: what the `text` tab type IS.
|
|
3
|
+
*
|
|
4
|
+
* The type claims every `dsh-resource://file/session/<sessionId>/<path>`
|
|
5
|
+
* address at the `fallback` band: it
|
|
6
|
+
* is the plain viewer that any more specific type for the same address should
|
|
7
|
+
* beat, the position VS Code's text editor holds among its editors. `canOpen`
|
|
8
|
+
* refuses an address `parseFileAddress` rejects or that has no Session at claim time, where an
|
|
9
|
+
* unclaimed address is the documented wiring error.
|
|
10
|
+
*/
|
|
11
|
+
import type { SidebarRightTabDefinition } from '@deepseek-ai/dsh-client-ui-sidebar-right/client';
|
|
12
|
+
/** The tab kind this package owns. */
|
|
13
|
+
export declare const TEXTPREVIEW_KIND = "text";
|
|
14
|
+
/** This implementation's identity in the tab system: the key its body registers under. */
|
|
15
|
+
export declare const TEXTPREVIEW_ID = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview";
|
|
16
|
+
/**
|
|
17
|
+
* The tab title for one `file:` address: its decoded basename.
|
|
18
|
+
*
|
|
19
|
+
* The whole address stays the content identity, so two files with one name in
|
|
20
|
+
* different directories are two tabs; only the chip text is shortened. Decoding
|
|
21
|
+
* is per segment, matching how the address was built, so a name carrying `#`,
|
|
22
|
+
* `?`, or a space reads as itself.
|
|
23
|
+
* @param address - a `file:`-shaped address.
|
|
24
|
+
* @returns the decoded last path segment, or the address itself when it has none.
|
|
25
|
+
*/
|
|
26
|
+
export declare function basenameOf(address: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* The text type's registry definition.
|
|
29
|
+
* @returns the definition to register.
|
|
30
|
+
*/
|
|
31
|
+
export declare function textDefinition(): SidebarRightTabDefinition;
|
|
32
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Document renderer slot: the owner supplies shared file state, renderers own their presentation. */
|
|
2
|
+
import type { PropsRuntime, SlotHookFactory } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { UseSidebarRightTabInfo } from '@deepseek-ai/dsh-client-ui-sidebar-right/client';
|
|
4
|
+
/** One loaded text window, retaining source line positions. */
|
|
5
|
+
export interface DocumentTextPage {
|
|
6
|
+
readonly offset: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly lines: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Contents prepared by the preview owner using ordinary file reads.
|
|
12
|
+
* Byte arrays are transient UI input, never persisted layout or Session data.
|
|
13
|
+
*/
|
|
14
|
+
export type DocumentContent = {
|
|
15
|
+
readonly kind: 'text';
|
|
16
|
+
readonly text: string;
|
|
17
|
+
readonly pages: readonly DocumentTextPage[];
|
|
18
|
+
readonly eof: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'bytes';
|
|
21
|
+
readonly data: Uint8Array<ArrayBuffer>;
|
|
22
|
+
};
|
|
23
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
24
|
+
interface SlotMap {
|
|
25
|
+
/** Document body selected by a registered implementation id. */
|
|
26
|
+
'sidebar.right.tab.document': {
|
|
27
|
+
kind: 'keyed';
|
|
28
|
+
scope: 'session';
|
|
29
|
+
owner: {
|
|
30
|
+
/** Original file address, also readable through the standard useResource hook. */
|
|
31
|
+
readonly resourceAddress: string;
|
|
32
|
+
/** Loaded content; text is an accumulated prefix until eof. */
|
|
33
|
+
readonly content: DocumentContent;
|
|
34
|
+
/** The document toolbar's current wrapping preference. */
|
|
35
|
+
readonly wrap: boolean;
|
|
36
|
+
};
|
|
37
|
+
hookContext: UseSidebarRightTabInfo;
|
|
38
|
+
inject: {
|
|
39
|
+
hooks: {
|
|
40
|
+
tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Standard input for every document body; entry-local stores and locale props can be intersected with it. */
|
|
47
|
+
export type DocumentPreviewProps = PropsRuntime<'sidebar.right.tab.document'>;
|
|
48
|
+
/**
|
|
49
|
+
* Forward the framework's tab reader to the selected document body.
|
|
50
|
+
* @param _standard - framework standard props.
|
|
51
|
+
* @param useTabInfo - enclosing tab's bound reader.
|
|
52
|
+
* @returns the same reader, without another subscription adapter.
|
|
53
|
+
*/
|
|
54
|
+
export declare const documentTabInfoFactory: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
|
|
55
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** How the document owner delivers file contents to a renderer. */
|
|
2
|
+
export type DocumentLoadMode = 'text-pages' | 'bytes-complete';
|
|
3
|
+
/** One renderer implementation, independent of its component registration. */
|
|
4
|
+
export interface DocumentPreviewDefinition {
|
|
5
|
+
/** Unique implementation name, also used as the document slot key. */
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** File suffixes without a leading dot; compound suffixes such as tar.gz are accepted. */
|
|
8
|
+
readonly extensions: readonly string[];
|
|
9
|
+
/** External implementations win over product implementations; defaults to extension. */
|
|
10
|
+
readonly priority?: 'builtin' | 'extension';
|
|
11
|
+
/** Localized implementation label, evaluated when the toolbar renders. @returns the visible name. */
|
|
12
|
+
readonly title: () => string;
|
|
13
|
+
/** Content delivery mode supplied by the document owner. */
|
|
14
|
+
readonly loading: DocumentLoadMode;
|
|
15
|
+
/** Whether the implementation consumes the document's wrap preference. */
|
|
16
|
+
readonly wrap?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Rank an observed definition snapshot without consulting mutable service state.
|
|
20
|
+
* @param definitions - registered implementations in registration order.
|
|
21
|
+
* @param path - decoded filename or file path.
|
|
22
|
+
* @returns matching implementations, external band first, then longest suffix.
|
|
23
|
+
*/
|
|
24
|
+
export declare function matchingDocumentPreviews(definitions: readonly DocumentPreviewDefinition[], path: string): readonly DocumentPreviewDefinition[];
|
|
25
|
+
/** Observable registry of all live implementations, including lower-priority alternatives. */
|
|
26
|
+
export declare class DocumentPreviewRegistry {
|
|
27
|
+
private readonly registered;
|
|
28
|
+
private readonly listeners;
|
|
29
|
+
private snapshot;
|
|
30
|
+
/**
|
|
31
|
+
* Read the current registrations.
|
|
32
|
+
* @returns the same snapshot until a registration changes.
|
|
33
|
+
*/
|
|
34
|
+
readonly getSnapshot: () => readonly DocumentPreviewDefinition[];
|
|
35
|
+
/**
|
|
36
|
+
* Observe registration changes.
|
|
37
|
+
* @param listener - registration-change observer.
|
|
38
|
+
* @returns its disposer.
|
|
39
|
+
*/
|
|
40
|
+
readonly subscribe: (listener: () => void) => (() => void);
|
|
41
|
+
/**
|
|
42
|
+
* Register metadata separately from the matching keyed slot component.
|
|
43
|
+
* @param definition - unique implementation and recognized suffixes.
|
|
44
|
+
* @returns an idempotent disposer; duplicate live implementation names throw.
|
|
45
|
+
*/
|
|
46
|
+
register(definition: DocumentPreviewDefinition): () => void;
|
|
47
|
+
/**
|
|
48
|
+
* List every matching implementation in automatic-selection order.
|
|
49
|
+
* @param path - decoded file path; matching never resolves filesystem access.
|
|
50
|
+
* @returns extension band first, then longest suffix, then registration order.
|
|
51
|
+
*/
|
|
52
|
+
candidates(path: string): readonly DocumentPreviewDefinition[];
|
|
53
|
+
private publish;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview's asynchronous half: reading pages into the store.
|
|
3
|
+
*
|
|
4
|
+
* The component never awaits anything. It asks for a page and this face performs
|
|
5
|
+
* the read and writes the outcome through the store's own actions — the
|
|
6
|
+
* Slot-standard `inject` form, so the write set stays the store's. The session
|
|
7
|
+
* the read runs under comes from the file's address, not from the slot's
|
|
8
|
+
* session: the address is the read's whole authority.
|
|
9
|
+
*
|
|
10
|
+
* A tab's pages are one file version walked from the first line. Dropping them
|
|
11
|
+
* — a reload, or a page of a newer version arriving past the first line, which
|
|
12
|
+
* restarts the walk — retires every read still in flight for the tab: a
|
|
13
|
+
* settlement from before the drop writes nothing. Cleanup rides the owner's
|
|
14
|
+
* `signal`, armed once per tab by its first read: the abort forgets the tab's
|
|
15
|
+
* bucket and this bookkeeping, a request is not made for a record that already
|
|
16
|
+
* ended, and a settlement arriving after the record is gone has nothing left to
|
|
17
|
+
* write to. A tab that never read has no bucket to forget.
|
|
18
|
+
*/
|
|
19
|
+
import type { BoundActions } from '@deepseek-ai/dsh-client-store';
|
|
20
|
+
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
21
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
22
|
+
import type { ReadDocumentBytes, ReadWorkspaceFilePage, SessionFile } from './rpc.ts';
|
|
23
|
+
import type { TextStore } from './store.ts';
|
|
24
|
+
/** The preview's injected business face, as the body receives it. */
|
|
25
|
+
export interface TextInjected {
|
|
26
|
+
/**
|
|
27
|
+
* Read one page into the store. A page of a newer file version than the pages
|
|
28
|
+
* held, arriving past the first line, is not kept: the tab's pages are dropped
|
|
29
|
+
* and the first page read again. The tab's first read arms the abort listener
|
|
30
|
+
* that forgets its bucket when the record ends.
|
|
31
|
+
* @param tabId - the tab being drawn.
|
|
32
|
+
* @param file - the session and workspace path the tab's address names.
|
|
33
|
+
* @param offset - 1-based line the page starts at.
|
|
34
|
+
* @param signal - the tab record's lifetime.
|
|
35
|
+
* @param observedVersion - metadata version observed at read start.
|
|
36
|
+
*/
|
|
37
|
+
readonly loadPage: (tabId: TabId, file: SessionFile, offset: number, signal: AbortSignal, observedVersion?: string) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Drop every page and read the first one again, for a file the Host reports
|
|
40
|
+
* changed. The view is kept, so the reader stays where they were; a page read
|
|
41
|
+
* still in flight writes nothing when it settles.
|
|
42
|
+
* @param tabId - the tab being drawn.
|
|
43
|
+
* @param file - the session and workspace path the tab's address names.
|
|
44
|
+
* @param signal - the tab record's lifetime.
|
|
45
|
+
* @param observedVersion - metadata version observed at read start.
|
|
46
|
+
*/
|
|
47
|
+
readonly reloadPages: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Read the complete file for a whole-file renderer.
|
|
50
|
+
* @param tabId - owning tab.
|
|
51
|
+
* @param file - the session and workspace path the tab's address names.
|
|
52
|
+
* @param signal - tab lifetime.
|
|
53
|
+
* @param observedVersion - metadata version observed at read start.
|
|
54
|
+
*/
|
|
55
|
+
readonly loadAll: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Discard the old complete result and read again.
|
|
58
|
+
* @param tabId - owning tab.
|
|
59
|
+
* @param file - the session and workspace path the tab's address names.
|
|
60
|
+
* @param signal - tab lifetime.
|
|
61
|
+
* @param observedVersion - metadata version observed at read start.
|
|
62
|
+
*/
|
|
63
|
+
readonly reloadAll: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Bind the preview's face to one paged read and one complete-byte read.
|
|
67
|
+
* @param read - the bound `workspaceFiles.read` call.
|
|
68
|
+
* @param readAll - ordinary complete-byte Remote read.
|
|
69
|
+
* @returns the Slot `inject` factory: bound actions in, face out. The slot's session id is unused because the address carries its own.
|
|
70
|
+
*/
|
|
71
|
+
export declare function textFace(read: ReadWorkspaceFilePage, readAll: ReadDocumentBytes): (sessionId: SessionId, actions: BoundActions<TextStore>) => TextInjected;
|
|
72
|
+
//# sourceMappingURL=face.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The failure line one Remote code deserves.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from the component so the mapping is testable on its own. Codes
|
|
5
|
+
* this reader does not name fall to the generic line carrying the carrier's
|
|
6
|
+
* message.
|
|
7
|
+
*/
|
|
8
|
+
import type { RemoteFailure } from '@deepseek-ai/dsh-api-remotes/client';
|
|
9
|
+
import type { TranslateNS } from '@deepseek-ai/dsh-client-locale/client';
|
|
10
|
+
/**
|
|
11
|
+
* Say what went wrong, in terms of the file rather than of the transport.
|
|
12
|
+
* @param t - namespace-bound translate.
|
|
13
|
+
* @param failure - the settled Remote failure.
|
|
14
|
+
* @returns the line to show in place of the file.
|
|
15
|
+
*/
|
|
16
|
+
export declare function failureLine(t: TranslateNS<'sidebarDocumentPreview'>, failure: RemoteFailure): string;
|
|
17
|
+
//# sourceMappingURL=failure-line.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
4
|
+
import type { ReadHtmlRelated } from './read-relative.ts';
|
|
5
|
+
/** Standard document inputs plus this renderer's dictionary. */
|
|
6
|
+
export type HtmlBodyProps = DocumentPreviewProps & PropsLocale<'documentHtml'> & {
|
|
7
|
+
/** Ordinary Remote callback bound by this renderer's Slot inject. */
|
|
8
|
+
readonly readRelated: ReadHtmlRelated;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Render complete HTML with the standard file and tab hooks.
|
|
12
|
+
* @param props - document bytes, hooks, related-file reader and locale.
|
|
13
|
+
* @returns an isolated HTML document, or nothing for text delivery.
|
|
14
|
+
*/
|
|
15
|
+
export declare function HtmlBody({ content, resourceAddress, readRelated, useTabInfo, t }: HtmlBodyProps): ReactNode;
|
|
16
|
+
//# sourceMappingURL=HtmlBody.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** One statically declared local script or stylesheet, already read under the source file's authority. */
|
|
2
|
+
export interface HtmlAsset {
|
|
3
|
+
readonly kind: 'script' | 'stylesheet';
|
|
4
|
+
/** Original HTML attribute, not a Host absolute path. */
|
|
5
|
+
readonly reference: string;
|
|
6
|
+
readonly data: Uint8Array<ArrayBuffer>;
|
|
7
|
+
}
|
|
8
|
+
/** Complete bytes for one document; dependencies are finite and never requested by iframe messages. */
|
|
9
|
+
export interface HtmlBundle {
|
|
10
|
+
readonly data: Uint8Array<ArrayBuffer>;
|
|
11
|
+
readonly assets: readonly HtmlAsset[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build the outer iframe document. Its resource URLs are created inside the sandbox,
|
|
15
|
+
* because that opaque origin cannot load resource URLs created by the parent.
|
|
16
|
+
* @param bundle - complete HTML bytes and optional static dependencies.
|
|
17
|
+
* @returns bootstrap HTML; invalid UTF-8 throws before navigation.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createHtmlDocument(bundle: HtmlBundle): string;
|
|
20
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** UTF-8 decoding for file bytes and encoding only for the iframe's script payload. */
|
|
2
|
+
/**
|
|
3
|
+
* Decode complete UTF-8 text, rejecting invalid byte sequences.
|
|
4
|
+
* @param data - complete UTF-8 bytes.
|
|
5
|
+
* @returns decoded text; invalid UTF-8 throws.
|
|
6
|
+
*/
|
|
7
|
+
export declare function decodeText(data: Uint8Array<ArrayBuffer>): string;
|
|
8
|
+
/**
|
|
9
|
+
* Encode Unicode text for the iframe's base64 payload.
|
|
10
|
+
* @param text - Unicode text.
|
|
11
|
+
* @returns base64 of its UTF-8 bytes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function encodeText(text: string): string;
|
|
14
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Builtin HTML metadata and keyed body registration; assembly belongs to the package entry. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { DocumentPreviewDefinition } from '../document/registry.ts';
|
|
4
|
+
/** HTML implementation identity, shared by metadata and the keyed slot. */
|
|
5
|
+
export declare const HTML_BODY_ID = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview/html";
|
|
6
|
+
/**
|
|
7
|
+
* Describe the builtin HTML renderer's file types and loading mode.
|
|
8
|
+
* @param title - locale-owned implementation name.
|
|
9
|
+
* @returns metadata for complete HTML documents.
|
|
10
|
+
*/
|
|
11
|
+
export declare function htmlBodyDefinition(title: () => string): DocumentPreviewDefinition;
|
|
12
|
+
/**
|
|
13
|
+
* Register the HTML dictionary, metadata and body with reversible effects.
|
|
14
|
+
* @param ctx - owning plugin context.
|
|
15
|
+
*/
|
|
16
|
+
export declare function apply(ctx: Context): void;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Locale-owned HTML implementation name and iframe status text. */
|
|
2
|
+
export declare const zh: {
|
|
3
|
+
title: string;
|
|
4
|
+
frame: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
failed: string;
|
|
7
|
+
};
|
|
8
|
+
/** HTML renderer dictionary keys. */
|
|
9
|
+
export type HtmlPreviewKey = keyof typeof zh;
|
|
10
|
+
/** English dictionary with the same keys as the Chinese dictionary. */
|
|
11
|
+
export declare const en: {
|
|
12
|
+
title: string;
|
|
13
|
+
frame: string;
|
|
14
|
+
loading: string;
|
|
15
|
+
failed: string;
|
|
16
|
+
};
|
|
17
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
18
|
+
interface LocaleNamespaceMap {
|
|
19
|
+
/** HTML preview selection and status text. */
|
|
20
|
+
documentHtml: HtmlPreviewKey;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Finite HTML-declared classic scripts and stylesheets; no module, CSS dependency or runtime fetch traversal. */
|
|
2
|
+
import type { HtmlBundle } from './bootstrap.ts';
|
|
3
|
+
import type { DocumentFileBytes } from '../rpc.ts';
|
|
4
|
+
/**
|
|
5
|
+
* A read bound to the original document's session and directory, using ordinary file operations.
|
|
6
|
+
* @param reference - HTML-decoded relative URL, including any query or fragment; the reader resolves its file path.
|
|
7
|
+
* @param signal - cancellation of this packing operation.
|
|
8
|
+
* @returns complete file bytes; permission and read failures reject.
|
|
9
|
+
*/
|
|
10
|
+
export type ReadHtmlRelative = (reference: string, signal: AbortSignal) => Promise<DocumentFileBytes>;
|
|
11
|
+
/**
|
|
12
|
+
* Collect static dependencies without executing or mounting document elements in the parent page.
|
|
13
|
+
* A base element leaves URL resolution to the browser. Only direct .js classic scripts and .css
|
|
14
|
+
* links are packed; local CSS url/import, modules and dynamically constructed URLs are unsupported.
|
|
15
|
+
* @param data - complete UTF-8 HTML bytes.
|
|
16
|
+
* @param readRelative - original-document-scoped read, never exposed to the iframe.
|
|
17
|
+
* @param signal - stops reads and prevents publication after cancellation.
|
|
18
|
+
* @returns complete HTML and its finite static asset set; decoding, limits and read failures reject.
|
|
19
|
+
*/
|
|
20
|
+
export declare function packHtml(data: Uint8Array<ArrayBuffer>, readRelative: ReadHtmlRelative, signal: AbortSignal): Promise<HtmlBundle>;
|
|
21
|
+
//# sourceMappingURL=pack.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Adapt a Remote relative read without changing its Session or Host path authority. */
|
|
2
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client';
|
|
3
|
+
import type { WorkspaceFileBytes } from '@deepseek-ai/dsh-api-workspace-files/types';
|
|
4
|
+
import type { ReadHtmlRelative } from './pack.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Read one dependency relative to the addressed HTML file through the Host.
|
|
7
|
+
* @param address - root HTML file address.
|
|
8
|
+
* @param relativePath - decoded dependency path, resolved only by the Host.
|
|
9
|
+
* @param signal - cancellation shared by the tab and packing operation.
|
|
10
|
+
* @returns the Remote complete-byte result, including declared failures.
|
|
11
|
+
*/
|
|
12
|
+
export type ReadHtmlRelated = (address: string, relativePath: string, signal: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>;
|
|
13
|
+
/**
|
|
14
|
+
* Bind a package reader to the original HTML file's address.
|
|
15
|
+
* @param readRelated - Remote reader using the Session in the root HTML address.
|
|
16
|
+
* @param address - root HTML file address.
|
|
17
|
+
* @param lifetime - tab lifetime.
|
|
18
|
+
* @returns a reader that strips URL query/fragment, decodes one path, and preserves Host failures.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createReadHtmlRelative(readRelated: ReadHtmlRelated, address: string, lifetime: AbortSignal): ReadHtmlRelative;
|
|
21
|
+
//# sourceMappingURL=read-relative.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glyphs this package draws that the shared icon set does not carry yet.
|
|
3
|
+
* Same props contract as `@deepseek-ai/dsh-client-ui-primitives` icons, so a
|
|
4
|
+
* shared replacement is a one-line import change.
|
|
5
|
+
*
|
|
6
|
+
* The wrap control swaps between the two glyphs below to preview the mode a
|
|
7
|
+
* click switches to, so neither needs a pressed style.
|
|
8
|
+
*/
|
|
9
|
+
import type { IconProps } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
10
|
+
/** Two margin bars, a straight arrow running to the right one: lines run past the edge. */
|
|
11
|
+
export declare const IconNowrapFill16: ({ size, className }: IconProps) => import("react").JSX.Element;
|
|
12
|
+
/** Two margin bars, an arrow sweeping around and back left: lines turn under themselves. */
|
|
13
|
+
export declare const IconWrapFill16: ({ size, className }: IconProps) => import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Complete image bytes rendered at their intrinsic CSS-pixel dimensions. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
5
|
+
declare const IMAGE_MEDIA_TYPES: {
|
|
6
|
+
readonly png: "image/png";
|
|
7
|
+
readonly jpg: "image/jpeg";
|
|
8
|
+
readonly jpeg: "image/jpeg";
|
|
9
|
+
readonly gif: "image/gif";
|
|
10
|
+
readonly webp: "image/webp";
|
|
11
|
+
readonly bmp: "image/bmp";
|
|
12
|
+
readonly ico: "image/x-icon";
|
|
13
|
+
readonly svg: "image/svg+xml";
|
|
14
|
+
};
|
|
15
|
+
type ImageMediaType = typeof IMAGE_MEDIA_TYPES[keyof typeof IMAGE_MEDIA_TYPES];
|
|
16
|
+
/** Standard document props plus the image renderer's dictionary. */
|
|
17
|
+
export type ImageBodyProps = DocumentPreviewProps & PropsLocale<'sidebarImage'>;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a supported filename to the media type assigned to its Blob.
|
|
20
|
+
* @param path - decoded workspace file path.
|
|
21
|
+
* @returns the image media type, or undefined for an unregistered suffix.
|
|
22
|
+
*/
|
|
23
|
+
export declare function imageMediaType(path: string): ImageMediaType | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Present complete image bytes without fitting or scaling them to the pane.
|
|
26
|
+
* @param props - document bytes, resource identity, and locale.
|
|
27
|
+
* @returns an intrinsic-size image whose containing document body provides scrolling.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ImageBody({ content, resourceAddress, t }: ImageBodyProps): ReactNode;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=ImageBody.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Builtin image metadata and keyed document-body registration. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { DocumentPreviewDefinition } from '../document/registry.ts';
|
|
4
|
+
/** Image implementation identity, shared by metadata and the keyed slot. */
|
|
5
|
+
export declare const IMAGE_BODY_ID = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview/image";
|
|
6
|
+
/** File suffixes rendered by the builtin image body. */
|
|
7
|
+
export declare const IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg"];
|
|
8
|
+
/**
|
|
9
|
+
* Describe the builtin image renderer independently from its keyed body slot.
|
|
10
|
+
* @param title - locale-owned implementation name.
|
|
11
|
+
* @returns metadata for complete image files.
|
|
12
|
+
*/
|
|
13
|
+
export declare function imageBodyDefinition(title: () => string): DocumentPreviewDefinition;
|
|
14
|
+
/**
|
|
15
|
+
* Register the image dictionary, metadata, and body with reversible effects.
|
|
16
|
+
* @param ctx - owning plugin context.
|
|
17
|
+
*/
|
|
18
|
+
export declare function apply(ctx: Context): void;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Locale-owned image renderer labels and status text. */
|
|
2
|
+
export declare const zh: {
|
|
3
|
+
title: string;
|
|
4
|
+
preview: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
failed: string;
|
|
7
|
+
unsupported: string;
|
|
8
|
+
};
|
|
9
|
+
/** Image renderer dictionary keys. */
|
|
10
|
+
export type ImagePreviewKey = keyof typeof zh;
|
|
11
|
+
/** English dictionary with the same keys as the Chinese dictionary. */
|
|
12
|
+
export declare const en: {
|
|
13
|
+
title: string;
|
|
14
|
+
preview: string;
|
|
15
|
+
loading: string;
|
|
16
|
+
failed: string;
|
|
17
|
+
unsupported: string;
|
|
18
|
+
};
|
|
19
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
20
|
+
interface LocaleNamespaceMap {
|
|
21
|
+
/** Image preview selection, accessible name, and status text. */
|
|
22
|
+
sidebarImage: ImagePreviewKey;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser half: register `text` as a right-Sidebar tab type.
|
|
3
|
+
*
|
|
4
|
+
* The type reaches the Sidebar through its public path only: the definition into
|
|
5
|
+
* `ctx.sidebarRightTabs`, the body into the keyed `sidebar.right.pane.tab`
|
|
6
|
+
* seat, and the chip title into `sidebar.right.pane.tab.title`, both under the
|
|
7
|
+
* definition's `id`. Nothing here reaches into the Sidebar's store, its
|
|
8
|
+
* panes, or its sequence. The file's metadata comes from the standard
|
|
9
|
+
* `useResource`, served by the `file` provider; the content is this type's own
|
|
10
|
+
* business, read through its face. Every import from another
|
|
11
|
+
* client plugin is a type.
|
|
12
|
+
*/
|
|
13
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
14
|
+
import type { WorkspaceFileParams } from '@deepseek-ai/dsh-api-workspace-files/client';
|
|
15
|
+
import { DocumentPreviewRegistry } from './document/registry.ts';
|
|
16
|
+
export type { SidebarDocumentPreviewKey } from './locales.ts';
|
|
17
|
+
export type { TextPreviewProps } from './TextPreview.tsx';
|
|
18
|
+
export type { TextInjected } from './face.ts';
|
|
19
|
+
export type { ReadWorkspaceFilePage, SessionFile, WorkspaceFilesReadRemote } from './rpc.ts';
|
|
20
|
+
export type { TextPage, TextState, TextStore, TextTabState } from './store.ts';
|
|
21
|
+
export type { DocumentContent, DocumentPreviewProps, DocumentTextPage } from './document/contract.ts';
|
|
22
|
+
export type { DocumentLoadMode, DocumentPreviewDefinition } from './document/registry.ts';
|
|
23
|
+
declare module '@deepseek-ai/cordis' {
|
|
24
|
+
interface Context {
|
|
25
|
+
/** File-extension renderer registrations, independent from their keyed document bodies. */
|
|
26
|
+
documentPreviews: DocumentPreviewRegistry;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
declare module '@deepseek-ai/dsh-client-ui-sidebar-right/client' {
|
|
30
|
+
interface SidebarRightResourceParamsMap {
|
|
31
|
+
/** File line navigation supported by the text preview. */
|
|
32
|
+
file: WorkspaceFileParams;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
36
|
+
interface LocaleNamespaceMap {
|
|
37
|
+
/** Text-preview progress, paging, change, control, and failure lines. */
|
|
38
|
+
sidebarDocumentPreview: import('./locales.ts').SidebarDocumentPreviewKey;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Required browser services: the tab registry, the slot registry, copy, and the
|
|
43
|
+
* Remote carrier with its `workspaceFiles` namespace.
|
|
44
|
+
*/
|
|
45
|
+
export declare const inject: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Client plugin body: register the type, its dictionaries, its body, and its chip title.
|
|
48
|
+
* @param ctx - client root context carrying the registry, the slots, copy, and the Remote face.
|
|
49
|
+
*/
|
|
50
|
+
export declare function apply(ctx: ClientContext): void;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|