@deepseek-ai/dsh-client-ui-sidebar-documentpreview 0.1.6-alpha.1 → 0.1.7-alpha.1
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/README.i18n.yaml +2 -2
- package/README.md +74 -15
- package/README.zh.md +74 -15
- package/lib/client.excel.js +133782 -0
- package/lib/client.js +5306 -25638
- package/lib/client.pdf.js +32631 -0
- package/lib/index.js +33 -4
- package/lib/types/client/TextPreview.d.ts +2 -2
- package/lib/types/client/document/contract.d.ts +62 -8
- package/lib/types/client/document/registry.d.ts +2 -2
- package/lib/types/client/document/resource-group.d.ts +23 -0
- package/lib/types/client/document/tab-lifetime.d.ts +10 -0
- package/lib/types/client/excel/LazyExcelBody.d.ts +21 -0
- package/lib/types/client/excel/convert.d.ts +12 -0
- package/lib/types/client/excel/delimited.d.ts +10 -0
- package/lib/types/client/excel/error.d.ts +7 -0
- package/lib/types/client/excel/excel.d.ts +10 -0
- package/lib/types/client/excel/format.d.ts +9 -0
- package/lib/types/client/excel/index.d.ts +10 -0
- package/lib/types/client/excel/locales.d.ts +45 -0
- package/lib/types/client/excel/model.d.ts +35 -0
- package/lib/types/client/excel/parse.d.ts +12 -0
- package/lib/types/client/excel/worker.d.ts +2 -0
- package/lib/types/client/excel/xls.d.ts +18 -0
- package/lib/types/client/excel/xlsx-archive.d.ts +19 -0
- package/lib/types/client/excel/xlsx.d.ts +9 -0
- package/lib/types/client/face.d.ts +17 -2
- package/lib/types/client/failure-line.d.ts +10 -0
- package/lib/types/client/html/HtmlBody.d.ts +10 -4
- package/lib/types/client/html/basic-document.d.ts +7 -0
- package/lib/types/client/html/read-relative.d.ts +7 -6
- package/lib/types/client/image/ImageBody.d.ts +7 -8
- package/lib/types/client/image/locales.d.ts +12 -0
- package/lib/types/client/index.d.ts +3 -3
- package/lib/types/client/locales.d.ts +6 -0
- package/lib/types/client/markdown/MarkdownBody.d.ts +1 -1
- package/lib/types/client/markdown/path-images.d.ts +9 -0
- package/lib/types/client/office/FontNotice.d.ts +14 -0
- package/lib/types/client/office/OfficeBody.d.ts +38 -0
- package/lib/types/client/office/OfficeFontAction.d.ts +13 -0
- package/lib/types/client/office/cache.d.ts +70 -0
- package/lib/types/client/office/face.d.ts +31 -0
- package/lib/types/client/office/index.d.ts +16 -0
- package/lib/types/client/office/locales.d.ts +39 -0
- package/lib/types/client/office/store.d.ts +32 -0
- package/lib/types/client/pdf/LazyPdfBody.d.ts +10 -0
- package/lib/types/client/pdf/document.d.ts +8 -2
- package/lib/types/client/pdf/index.d.ts +13 -0
- package/lib/types/client/pdf/locales.d.ts +12 -0
- package/lib/types/client/pdf/{PdfBody.d.ts → pdf.d.ts} +8 -3
- package/lib/types/client/pdf/store.d.ts +5 -4
- package/lib/types/client/pdf/text.d.ts +10 -0
- package/lib/types/client/rpc.d.ts +4 -12
- package/lib/types/client/store.d.ts +11 -1
- package/lib/types/client/zoom/ZoomControls.d.ts +21 -0
- package/lib/types/client/zoom/ZoomViewport.d.ts +25 -0
- package/lib/types/client/zoom/locales.d.ts +21 -0
- package/lib/types/client/zoom/store.d.ts +28 -0
- package/lib/types/client/zoom/types.d.ts +27 -0
- package/lib/types/config.d.ts +31 -0
- package/lib/types/index.d.ts +10 -3
- package/package.json +40 -20
- package/lib/types/client/code/languages.d.ts +0 -9
- package/lib/types/client/icons.d.ts +0 -14
|
@@ -16,7 +16,7 @@ import { DocumentPreviewRegistry } from './document/registry.ts';
|
|
|
16
16
|
export type { SidebarDocumentPreviewKey } from './locales.ts';
|
|
17
17
|
export type { TextPreviewProps } from './TextPreview.tsx';
|
|
18
18
|
export type { TextInjected } from './face.ts';
|
|
19
|
-
export type { ReadWorkspaceFilePage, SessionFile, WorkspaceFilesReadRemote } from './rpc.ts';
|
|
19
|
+
export type { ReadDocumentBytes, DocumentFileBytes, ReadWorkspaceFilePage, SessionFile, WorkspaceFilesReadRemote } from './rpc.ts';
|
|
20
20
|
export type { TextPage, TextState, TextStore, TextTabState } from './store.ts';
|
|
21
21
|
export type { DocumentContent, DocumentPreviewProps, DocumentTextPage } from './document/contract.ts';
|
|
22
22
|
export type { DocumentLoadMode, DocumentPreviewDefinition } from './document/registry.ts';
|
|
@@ -40,12 +40,12 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Required browser services: the tab registry, the slot registry, copy, and the
|
|
43
|
-
* Remote
|
|
43
|
+
* workspace Remote for bytes and paged text reads.
|
|
44
44
|
*/
|
|
45
45
|
export declare const inject: string[];
|
|
46
46
|
/**
|
|
47
47
|
* Client plugin body: register the type, its dictionaries, its body, and its chip title.
|
|
48
|
-
* @param ctx - client root context carrying the registry,
|
|
48
|
+
* @param ctx - client root context carrying the registry, slots, copy, and file readers.
|
|
49
49
|
*/
|
|
50
50
|
export declare function apply(ctx: ClientContext): void;
|
|
51
51
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -12,6 +12,9 @@ export declare const zh: {
|
|
|
12
12
|
changed: string;
|
|
13
13
|
reloadNow: string;
|
|
14
14
|
reload: string;
|
|
15
|
+
autoRefresh: string;
|
|
16
|
+
'autoRefresh.enable': string;
|
|
17
|
+
'autoRefresh.disable': string;
|
|
15
18
|
'wrap.enable': string;
|
|
16
19
|
'wrap.disable': string;
|
|
17
20
|
'wrap.aria': string;
|
|
@@ -36,6 +39,9 @@ export declare const en: {
|
|
|
36
39
|
changed: string;
|
|
37
40
|
reloadNow: string;
|
|
38
41
|
reload: string;
|
|
42
|
+
autoRefresh: string;
|
|
43
|
+
'autoRefresh.enable': string;
|
|
44
|
+
'autoRefresh.disable': string;
|
|
39
45
|
'wrap.enable': string;
|
|
40
46
|
'wrap.disable': string;
|
|
41
47
|
'wrap.aria': string;
|
|
@@ -8,5 +8,5 @@ export type MarkdownBodyProps = DocumentPreviewProps & PropsLocale<'documentMark
|
|
|
8
8
|
* @param props - owner-loaded contents and localized primitive labels.
|
|
9
9
|
* @returns Markdown content, or nothing for a non-text delivery.
|
|
10
10
|
*/
|
|
11
|
-
export declare function MarkdownBody({ content, t }: MarkdownBodyProps): ReactNode;
|
|
11
|
+
export declare function MarkdownBody({ content, resourceAddress, useResource, t }: MarkdownBodyProps): ReactNode;
|
|
12
12
|
//# sourceMappingURL=MarkdownBody.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a file URL, resolving relative destinations beside the previewed file.
|
|
3
|
+
* @param base - document base URI, including any deployment prefix.
|
|
4
|
+
* @param documentPath - absolute source path reported by the Host, when available.
|
|
5
|
+
* @param destination - authored Markdown image URL; query and fragment are not filename components.
|
|
6
|
+
* @returns an HTTP(S) file URL, or undefined for unsupported or malformed destinations.
|
|
7
|
+
*/
|
|
8
|
+
export declare function markdownImageUrl(base: string, documentPath: string | undefined, destination: string): string | undefined;
|
|
9
|
+
//# sourceMappingURL=path-images.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Toolbar warning and non-modal details for the current preview’s missing fonts. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
/** Notice inputs supplied by the document owner and Office locale registration. */
|
|
5
|
+
export type FontNoticeProps = PropsLocale<'sidebarOffice'> & {
|
|
6
|
+
readonly fonts: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Show a warning while fonts are unavailable for the current preview.
|
|
10
|
+
* @param props - missing font families and localized copy.
|
|
11
|
+
* @returns a warning button and its anchored details, or nothing when fonts are available.
|
|
12
|
+
*/
|
|
13
|
+
export declare function FontNotice({ fonts, t }: FontNoticeProps): ReactNode;
|
|
14
|
+
//# sourceMappingURL=FontNotice.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Office presents retained conversion results and font notices around the shared PDF view. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { PropsLocale, PropsRenderSlots, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
5
|
+
import type { UseSidebarRightTabInfo } from '@deepseek-ai/dsh-client-ui-sidebar-right/client';
|
|
6
|
+
import type { DocumentBodyOwner, DocumentPreviewProps } from '../document/contract.ts';
|
|
7
|
+
import type { OfficeLoadInjected } from './face.ts';
|
|
8
|
+
import type { OfficeStore } from './store.ts';
|
|
9
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
10
|
+
interface SlotMap {
|
|
11
|
+
/** PDF presentation supplied with Office-owned converted bytes. */
|
|
12
|
+
'sidebar.right.tab.document.office.pdf': {
|
|
13
|
+
kind: 'keyed';
|
|
14
|
+
scope: 'session';
|
|
15
|
+
owner: DocumentBodyOwner;
|
|
16
|
+
hookContext: UseSidebarRightTabInfo;
|
|
17
|
+
inject: {
|
|
18
|
+
hooks: {
|
|
19
|
+
tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Office loading callbacks supplied by the registration's services. */
|
|
26
|
+
export interface OfficeBodyInjected extends OfficeLoadInjected {
|
|
27
|
+
/** @param tab - owning tab. @param signal - tab lifetime, including hidden bodies. */
|
|
28
|
+
readonly retainTab: (tab: TabId, signal: AbortSignal) => void;
|
|
29
|
+
}
|
|
30
|
+
/** Office body inputs and its private PDF child. */
|
|
31
|
+
export type OfficeBodyProps = DocumentPreviewProps & PropsStore<OfficeStore> & OfficeBodyInjected & PropsLocale<'sidebarOffice'> & PropsRenderSlots<'sidebar.right.tab.document.office.pdf'>;
|
|
32
|
+
/**
|
|
33
|
+
* Load one Office revision and preserve its result while its tab remains open.
|
|
34
|
+
* @param props - renderer loading request, tab state, conversion callbacks, and PDF slot.
|
|
35
|
+
* @returns conversion status or the PDF scrollport.
|
|
36
|
+
*/
|
|
37
|
+
export declare function OfficeBody(props: OfficeBodyProps): ReactNode;
|
|
38
|
+
//# sourceMappingURL=OfficeBody.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Font warning for the Office revision displayed by the document toolbar. */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { PropsLocale, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
|
+
import type { OfficeStore } from './store.ts';
|
|
5
|
+
/** Office toolbar inputs share the body’s conversion result. */
|
|
6
|
+
export type OfficeFontActionProps = PropsRuntime<'sidebar.right.tab.document.action'> & PropsStore<OfficeStore> & PropsLocale<'sidebarOffice'>;
|
|
7
|
+
/**
|
|
8
|
+
* Expose font details only for the currently loaded Office revision.
|
|
9
|
+
* @param props - toolbar revision, tab reader, Office store, and localized copy.
|
|
10
|
+
* @returns the font warning, or nothing before conversion completes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function OfficeFontAction({ content, useTabInfo, useStore, t }: OfficeFontActionProps): ReactNode;
|
|
13
|
+
//# sourceMappingURL=OfficeFontAction.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Session-authorized, version-checked Office bytes shared by concurrent preview reads. */
|
|
2
|
+
import type { OfficeToPdfPriority, OfficeToPdfGeneration } from '@deepseek-ai/dsh-office-to-pdf/types';
|
|
3
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client';
|
|
4
|
+
import type { WorkspaceFileStat } from '@deepseek-ai/dsh-api-workspace-files/types';
|
|
5
|
+
import type { DocumentFileBytes, SessionFile } from '../rpc.ts';
|
|
6
|
+
/** PDF bytes and conversion metadata owned by Office preview. */
|
|
7
|
+
export type OfficeFileBytes = DocumentFileBytes & {
|
|
8
|
+
readonly missingFonts: readonly string[];
|
|
9
|
+
readonly generation: OfficeToPdfGeneration;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Load authorized PDF contents for one Office source.
|
|
13
|
+
* @param file - Session and source path.
|
|
14
|
+
* @param signal - this reader's lifetime.
|
|
15
|
+
* @returns converted PDF bytes or a declared source-access failure.
|
|
16
|
+
*/
|
|
17
|
+
export type ReadOfficeDocument = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<OfficeFileBytes>>;
|
|
18
|
+
/** Authorized cached reads carry explicit scheduling intent to the Host. */
|
|
19
|
+
export type ReadOfficeBytes = (file: SessionFile, signal: AbortSignal, priority: OfficeToPdfPriority) => ReturnType<ReadOfficeDocument>;
|
|
20
|
+
type Result = Awaited<ReturnType<ReadOfficeDocument>>;
|
|
21
|
+
type Stat = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<WorkspaceFileStat>>;
|
|
22
|
+
/** Bounded successful results; each caller reauthorizes and checks source freshness before reuse. */
|
|
23
|
+
export declare class OfficePreviewCache {
|
|
24
|
+
private readonly stat;
|
|
25
|
+
private readonly convert;
|
|
26
|
+
private readonly maxEntries;
|
|
27
|
+
private readonly maxBytes;
|
|
28
|
+
private readonly maxPending;
|
|
29
|
+
private readonly maxReaders;
|
|
30
|
+
private readonly currentGeneration;
|
|
31
|
+
private readonly busy;
|
|
32
|
+
private readonly ready;
|
|
33
|
+
private readonly pending;
|
|
34
|
+
private bytes;
|
|
35
|
+
private readers;
|
|
36
|
+
private generation;
|
|
37
|
+
private generationQuery;
|
|
38
|
+
private acceptedQuery;
|
|
39
|
+
private readonly superseded;
|
|
40
|
+
private readonly lifetime;
|
|
41
|
+
private readonly tasks;
|
|
42
|
+
private readonly reads;
|
|
43
|
+
/**
|
|
44
|
+
* @param stat - authorized source metadata lookup.
|
|
45
|
+
* @param convert - Host render Remote returning binary PDF bytes borrowed read-only by callers.
|
|
46
|
+
* @param maxEntries - maximum completed results retained.
|
|
47
|
+
* @param maxBytes - maximum retained PDF byteLength.
|
|
48
|
+
* @param maxPending - maximum unsettled Host conversion requests, including cancellation teardown.
|
|
49
|
+
* @param maxReaders - maximum readers, including metadata lookups.
|
|
50
|
+
* @param generation - current Host renderer generation, checked before cached reuse.
|
|
51
|
+
* @param busy - localized capacity failure.
|
|
52
|
+
*/
|
|
53
|
+
constructor(stat: Stat, convert: ReadOfficeBytes, maxEntries: number, maxBytes: number, maxPending: number, maxReaders: number, currentGeneration: (signal: AbortSignal) => Promise<RemoteResult<OfficeToPdfGeneration>>, busy: () => Error);
|
|
54
|
+
/**
|
|
55
|
+
* Share a conversion without letting one caller cancel another caller's work.
|
|
56
|
+
* Renderer replacement retries authorization once; repeated replacement reports localized capacity failure.
|
|
57
|
+
* @param file - Session authorization scope and source path.
|
|
58
|
+
* @param signal - this caller's lifetime.
|
|
59
|
+
* @param priority - foreground preview or speculative read.
|
|
60
|
+
* @returns current PDF bytes borrowed read-only, or a declared source-read failure; cancellation rejects.
|
|
61
|
+
*/
|
|
62
|
+
read(file: SessionFile, signal: AbortSignal, priority?: OfficeToPdfPriority): Promise<Result>;
|
|
63
|
+
private lookup;
|
|
64
|
+
private lookupGeneration;
|
|
65
|
+
/** Clear retained bytes, cancel outstanding conversions, and await their completion. */
|
|
66
|
+
dispose(): Promise<void>;
|
|
67
|
+
private retain;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Office conversion reads and settlements bound to the renderer's declared store. */
|
|
2
|
+
import type { BoundActions } from '@deepseek-ai/dsh-client-store';
|
|
3
|
+
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
4
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
5
|
+
import type { RemoteFailure } from '@deepseek-ai/dsh-api-remotes/client';
|
|
6
|
+
import type { SessionFile } from '../rpc.ts';
|
|
7
|
+
import type { ReadOfficeDocument } from './cache.ts';
|
|
8
|
+
import type { OfficeStore } from './store.ts';
|
|
9
|
+
/** Conversion loading callback supplied to the Office body through Slot injection. */
|
|
10
|
+
export interface OfficeLoadInjected {
|
|
11
|
+
/**
|
|
12
|
+
* Read one conversion revision; cancellation suppresses its store writes and version report.
|
|
13
|
+
* @param tabId - owning tab.
|
|
14
|
+
* @param revision - requested content revision.
|
|
15
|
+
* @param file - addressed Session and source path.
|
|
16
|
+
* @param signal - request lifetime, cancelled on replacement, unmount, or tab closure.
|
|
17
|
+
* @param loaded - report the displayed source version to the document owner.
|
|
18
|
+
* @param failed - report a failed load to the document owner.
|
|
19
|
+
*/
|
|
20
|
+
readonly load: (tabId: TabId, revision: number, file: SessionFile, signal: AbortSignal, loaded: (version: string) => void, failed: () => void) => void;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Bind Office reads to store actions without exposing Remote work to the component.
|
|
24
|
+
* @param read - authorized conversion reader, including Client cache reuse.
|
|
25
|
+
* @param describeFailure - localized conversion or source-access failure text.
|
|
26
|
+
* @returns Slot inject factory; the file address supplies the read's Session authority.
|
|
27
|
+
*/
|
|
28
|
+
export declare function officeFace(read: ReadOfficeDocument, describeFailure: (failure: RemoteFailure | {
|
|
29
|
+
readonly message: string;
|
|
30
|
+
}) => string): (sessionId: SessionId, actions: BoundActions<OfficeStore>) => OfficeLoadInjected;
|
|
31
|
+
//# sourceMappingURL=face.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Office preview registration backed by authorized Host rendering and the existing PDF body. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import { type OfficePreviewKey } from './locales.ts';
|
|
4
|
+
import type { Config } from '../../config.ts';
|
|
5
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
6
|
+
interface LocaleNamespaceMap {
|
|
7
|
+
sidebarOffice: OfficePreviewKey;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Register Office previews with versioned PDF reuse and missing-font notices.
|
|
12
|
+
* @param ctx - Client renderer registry, localized copy, and optional Host Remotes.
|
|
13
|
+
* @param config - Resolved Office preview cache limits.
|
|
14
|
+
*/
|
|
15
|
+
export declare function apply(ctx: Context, config: Config['office']): void;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Office preview copy and Host render configuration guidance. */
|
|
2
|
+
export declare const zh: {
|
|
3
|
+
title: string;
|
|
4
|
+
loading: string;
|
|
5
|
+
retry: string;
|
|
6
|
+
viewMissingFonts: string;
|
|
7
|
+
missingFontsTitle: string;
|
|
8
|
+
missingFontsDescription: string;
|
|
9
|
+
missingFontsCount: string;
|
|
10
|
+
closeDetails: string;
|
|
11
|
+
unavailable: string;
|
|
12
|
+
invalid: string;
|
|
13
|
+
tooLarge: string;
|
|
14
|
+
failed: string;
|
|
15
|
+
timeout: string;
|
|
16
|
+
busy: string;
|
|
17
|
+
changed: string;
|
|
18
|
+
};
|
|
19
|
+
/** Office preview locale keys. */
|
|
20
|
+
export type OfficePreviewKey = keyof typeof zh;
|
|
21
|
+
/** English translations checked against the Chinese key set. */
|
|
22
|
+
export declare const en: {
|
|
23
|
+
title: string;
|
|
24
|
+
loading: string;
|
|
25
|
+
retry: string;
|
|
26
|
+
viewMissingFonts: string;
|
|
27
|
+
missingFontsTitle: string;
|
|
28
|
+
missingFontsDescription: string;
|
|
29
|
+
missingFontsCount: string;
|
|
30
|
+
closeDetails: string;
|
|
31
|
+
unavailable: string;
|
|
32
|
+
invalid: string;
|
|
33
|
+
tooLarge: string;
|
|
34
|
+
failed: string;
|
|
35
|
+
timeout: string;
|
|
36
|
+
busy: string;
|
|
37
|
+
changed: string;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Loaded Office previews survive body remounts until reload or tab closure. */
|
|
2
|
+
import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-store';
|
|
3
|
+
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
4
|
+
import type { OfficeFileBytes } from './cache.ts';
|
|
5
|
+
/** One requested source revision and its settled preview. */
|
|
6
|
+
export interface OfficeView {
|
|
7
|
+
readonly revision: number;
|
|
8
|
+
readonly file?: OfficeFileBytes;
|
|
9
|
+
readonly failure?: {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** Office-owned content, isolated by tab identity. */
|
|
15
|
+
export interface OfficeState {
|
|
16
|
+
byTab: Record<TabId, OfficeView>;
|
|
17
|
+
}
|
|
18
|
+
type OfficeActions = {
|
|
19
|
+
loading: (state: OfficeState, tab: TabId, revision: number) => void;
|
|
20
|
+
complete: (state: OfficeState, tab: TabId, revision: number, file: OfficeFileBytes) => void;
|
|
21
|
+
failed: (state: OfficeState, tab: TabId, revision: number, failure: NonNullable<OfficeView['failure']>) => void;
|
|
22
|
+
forget: (state: OfficeState, tab: TabId) => void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Retain Office contents across body remounts within a Session.
|
|
26
|
+
* @returns the tab-content store declaration.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createOfficeStore(): EngineStoreHandle<OfficeState, OfficeActions>;
|
|
29
|
+
/** Store declaration used by the Office body. */
|
|
30
|
+
export type OfficeStore = ReturnType<typeof createOfficeStore>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Load the PDF renderer only after a PDF body is mounted. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { PdfBodyProps } from './pdf.tsx';
|
|
4
|
+
/**
|
|
5
|
+
* Suspend while the package-local PDF chunk arrives.
|
|
6
|
+
* @param props - PDF body props supplied by the document slot.
|
|
7
|
+
* @returns the deferred PDF renderer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function LazyPdfBody(props: PdfBodyProps): ReactNode;
|
|
10
|
+
//# sourceMappingURL=LazyPdfBody.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Canvas rendering with cancellation and page cleanup, shared by the PDF body and real-library smoke. */
|
|
2
|
-
import type { PDFDocumentProxy } from 'pdfjs-dist';
|
|
2
|
+
import type { PDFDocumentProxy, PDFPageProxy, PageViewport } from 'pdfjs-dist';
|
|
3
3
|
/** The document operations used by one mounted PDF body. */
|
|
4
4
|
export type PdfDocument = Pick<PDFDocumentProxy, 'numPages' | 'getPage'>;
|
|
5
5
|
/** One in-flight PDF load and its complete cleanup operation. */
|
|
@@ -17,6 +17,11 @@ export interface PdfPageSize {
|
|
|
17
17
|
readonly width: number;
|
|
18
18
|
readonly height: number;
|
|
19
19
|
}
|
|
20
|
+
/** Optional DOM text rendering that shares the canvas page's cleanup barrier. */
|
|
21
|
+
export type RenderPdfText = (page: PDFPageProxy, viewport: PageViewport) => {
|
|
22
|
+
readonly promise: Promise<void>;
|
|
23
|
+
cancel(): void;
|
|
24
|
+
};
|
|
20
25
|
/**
|
|
21
26
|
* Render one page into an exclusively owned canvas. Cancellation cannot write
|
|
22
27
|
* dimensions after a delayed getPage; active render tasks are cancelled and
|
|
@@ -26,7 +31,8 @@ export interface PdfPageSize {
|
|
|
26
31
|
* @param canvas - canvas owned by this render only.
|
|
27
32
|
* @param signal - render lifetime.
|
|
28
33
|
* @param pixelRatio - display pixel ratio.
|
|
34
|
+
* @param renderText - optional selectable text layer sharing this page and viewport.
|
|
29
35
|
* @returns the page's CSS dimensions after rendering completes.
|
|
30
36
|
*/
|
|
31
|
-
export declare function renderPdfPage(document: PdfDocument, pageNumber: number, canvas: HTMLCanvasElement, signal: AbortSignal, pixelRatio: number): Promise<PdfPageSize>;
|
|
37
|
+
export declare function renderPdfPage(document: PdfDocument, pageNumber: number, canvas: HTMLCanvasElement, signal: AbortSignal, pixelRatio: number, renderText?: RenderPdfText): Promise<PdfPageSize>;
|
|
32
38
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** Builtin PDF registration through document metadata and the keyed body slot. */
|
|
2
2
|
import type { Context } from '@deepseek-ai/cordis';
|
|
3
3
|
import type { DocumentPreviewDefinition } from '../document/registry.ts';
|
|
4
|
+
import type { PdfBodyInjected } from './pdf.tsx';
|
|
5
|
+
import type { BoundActions } from '@deepseek-ai/dsh-client-store';
|
|
6
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
7
|
+
import { type PdfStore } from './store.ts';
|
|
4
8
|
/** PDF metadata and keyed body share this package-local implementation identity. */
|
|
5
9
|
export declare const PDF_BODY_ID = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview/pdf";
|
|
6
10
|
/**
|
|
@@ -11,4 +15,13 @@ export declare const PDF_BODY_ID = "@deepseek-ai/dsh-client-ui-sidebar-documentp
|
|
|
11
15
|
export declare function pdfBodyDefinition(title: () => string): DocumentPreviewDefinition;
|
|
12
16
|
/** @param ctx - context carrying the locale, document registry, and slot registry. */
|
|
13
17
|
export declare function apply(ctx: Context): void;
|
|
18
|
+
/**
|
|
19
|
+
* Retain PDF viewing state for a document entry's tab lifetime.
|
|
20
|
+
* @param ctx - owning registration context.
|
|
21
|
+
* @returns the store and injection shared by ordinary and Office PDF registrations.
|
|
22
|
+
*/
|
|
23
|
+
export declare function pdfBodyRegistration(ctx: Context): {
|
|
24
|
+
store: PdfStore;
|
|
25
|
+
inject: (sessionId: SessionId, actions: BoundActions<PdfStore>) => PdfBodyInjected;
|
|
26
|
+
};
|
|
14
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -9,6 +9,12 @@ export declare const zh: {
|
|
|
9
9
|
workerFailed: string;
|
|
10
10
|
unsupported: string;
|
|
11
11
|
retry: string;
|
|
12
|
+
zoomControls: "缩放控件";
|
|
13
|
+
zoomMenu: "选择缩放比例";
|
|
14
|
+
zoomOut: "缩小";
|
|
15
|
+
zoomIn: "放大";
|
|
16
|
+
zoomFitWidth: "适应宽度";
|
|
17
|
+
zoomValue: "{percent}%";
|
|
12
18
|
};
|
|
13
19
|
/** PDF translation keys shared by both dictionaries. */
|
|
14
20
|
export type PdfLocaleKey = keyof typeof zh;
|
|
@@ -23,6 +29,12 @@ export declare const en: {
|
|
|
23
29
|
workerFailed: string;
|
|
24
30
|
unsupported: string;
|
|
25
31
|
retry: string;
|
|
32
|
+
zoomControls: string;
|
|
33
|
+
zoomMenu: string;
|
|
34
|
+
zoomOut: string;
|
|
35
|
+
zoomIn: string;
|
|
36
|
+
zoomFitWidth: string;
|
|
37
|
+
zoomValue: string;
|
|
26
38
|
};
|
|
27
39
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
28
40
|
interface LocaleNamespaceMap {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/** PDF page presentation; binary content and tab information come from the document owner. */
|
|
2
|
-
import { type ReactNode } from 'react';
|
|
2
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
3
3
|
import type { PropsLocale, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
4
|
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
5
5
|
import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
6
|
-
import {
|
|
6
|
+
import type { PdfStore } from './store.ts';
|
|
7
|
+
import type { ZoomViewportProps } from '../zoom/ZoomViewport.tsx';
|
|
7
8
|
/** A record's viewing preferences survive body unmounts and leave with the tab. */
|
|
8
9
|
export interface PdfBodyInjected {
|
|
9
10
|
/**
|
|
@@ -12,6 +13,10 @@ export interface PdfBodyInjected {
|
|
|
12
13
|
* @param signal - tab-record lifetime, not body visibility.
|
|
13
14
|
*/
|
|
14
15
|
readonly retainTab: (tabId: TabId, signal: AbortSignal) => void;
|
|
16
|
+
/** Main-bundle viewport reused by the lazy PDF body. */
|
|
17
|
+
readonly ZoomViewport: ComponentType<ZoomViewportProps>;
|
|
18
|
+
/** Main-bundle class implementing fit-width and fixed-size surfaces. */
|
|
19
|
+
readonly zoomSurfaceClass: string;
|
|
15
20
|
}
|
|
16
21
|
/** Standard document props plus the PDF entry's locale, viewing store, and lifetime callback. */
|
|
17
22
|
export type PdfBodyProps = DocumentPreviewProps & PropsLocale<'sidebarPdf'> & PropsStore<PdfStore> & PdfBodyInjected;
|
|
@@ -21,4 +26,4 @@ export type PdfBodyProps = DocumentPreviewProps & PropsLocale<'sidebarPdf'> & Pr
|
|
|
21
26
|
* @returns the PDF reader.
|
|
22
27
|
*/
|
|
23
28
|
export declare function PdfBody(props: PdfBodyProps): ReactNode;
|
|
24
|
-
//# sourceMappingURL=
|
|
29
|
+
//# sourceMappingURL=pdf.d.ts.map
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
/** Restorable PDF viewing preferences; document objects and canvases remain component-local. */
|
|
2
2
|
import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-store';
|
|
3
3
|
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
4
|
-
|
|
4
|
+
import type { ZoomPreference } from '../zoom/types.ts';
|
|
5
|
+
/** One tab's last visible page and optional PDF zoom preference. */
|
|
5
6
|
export interface PdfView {
|
|
6
7
|
readonly page: number;
|
|
8
|
+
readonly zoom?: ZoomPreference;
|
|
7
9
|
}
|
|
8
|
-
/** Initial viewing position before a tab reaches another page. */
|
|
9
|
-
export declare const DEFAULT_PDF_VIEW: PdfView;
|
|
10
10
|
/** Page state isolated by the owning tab record. */
|
|
11
11
|
export interface PdfState {
|
|
12
12
|
byTab: Record<TabId, PdfView>;
|
|
13
13
|
}
|
|
14
14
|
type PdfActions = {
|
|
15
15
|
page: (draft: PdfState, tabId: TabId, page: number) => void;
|
|
16
|
+
zoom: (draft: PdfState, tabId: TabId, zoom: ZoomPreference) => void;
|
|
16
17
|
forget: (draft: PdfState, tabId: TabId) => void;
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
|
-
* Declare the last visible page isolated by tab identity.
|
|
20
|
+
* Declare the last visible page and zoom preference isolated by tab identity.
|
|
20
21
|
* @returns a store declaration instantiated by the document slot for each Session.
|
|
21
22
|
*/
|
|
22
23
|
export declare function createPdfStore(): EngineStoreHandle<PdfState, PdfActions>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** PDF.js's viewer owns selection boundaries and copy normalization; the overlay follows its canvas. */
|
|
2
|
+
import 'pdfjs-dist';
|
|
3
|
+
import type { RenderPdfText } from './document.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Create a selectable overlay in a component-owned host.
|
|
6
|
+
* @param host - absolute overlay matching the displayed canvas dimensions.
|
|
7
|
+
* @returns renderer whose cancellation also releases its resize observer and DOM.
|
|
8
|
+
*/
|
|
9
|
+
export declare function pdfTextRenderer(host: HTMLDivElement): RenderPdfText;
|
|
10
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -57,21 +57,13 @@ export declare function hostFileOf(address: string): SessionFile;
|
|
|
57
57
|
* @returns the read the face performs.
|
|
58
58
|
*/
|
|
59
59
|
export declare function createReadPage(remote: WorkspaceFilesReadRemote): ReadWorkspaceFilePage;
|
|
60
|
-
/**
|
|
61
|
-
export type DocumentFileBytes =
|
|
62
|
-
readonly data: Uint8Array<ArrayBuffer>;
|
|
63
|
-
};
|
|
60
|
+
/** Document bytes borrowed read-only by renderers; copy before transferring to a Worker. */
|
|
61
|
+
export type DocumentFileBytes = WorkspaceFileBytes<Uint8Array<ArrayBuffer>>;
|
|
64
62
|
/**
|
|
65
63
|
* Read a complete file through the Host endpoint.
|
|
66
64
|
* @param file - Session and path decoded from the tab address.
|
|
67
65
|
* @param signal - owning tab lifetime.
|
|
68
|
-
* @returns complete
|
|
66
|
+
* @returns complete native bytes, including declared failures.
|
|
69
67
|
*/
|
|
70
|
-
export type ReadDocumentBytes = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<
|
|
71
|
-
/**
|
|
72
|
-
* Decode one successful Remote byte result for document renderers.
|
|
73
|
-
* @param file - Host byte result with base64 data.
|
|
74
|
-
* @returns the same metadata with native bytes; malformed base64 throws.
|
|
75
|
-
*/
|
|
76
|
-
export declare function documentFileBytes(file: WorkspaceFileBytes): DocumentFileBytes;
|
|
68
|
+
export type ReadDocumentBytes = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<DocumentFileBytes>>;
|
|
77
69
|
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -29,10 +29,16 @@ export interface TextPage {
|
|
|
29
29
|
}
|
|
30
30
|
/** One tab's pages and view. */
|
|
31
31
|
export interface TextTabState {
|
|
32
|
+
autoRefresh: boolean;
|
|
33
|
+
resourcesDirty: boolean;
|
|
32
34
|
/** Explicit viewer choice for this tab; absence follows automatic matching. */
|
|
33
35
|
rendererId?: string;
|
|
34
36
|
/** Current display-loading mode; absent before the first read. */
|
|
35
37
|
mode?: DocumentLoadMode;
|
|
38
|
+
/** Implementation owning source loading; absent for ordinary file reads. */
|
|
39
|
+
contentRendererId?: string;
|
|
40
|
+
/** Current content revision, incremented whenever loaded content is discarded. */
|
|
41
|
+
loadRevision: number;
|
|
36
42
|
/** Full byte result used by complete-file renderers. */
|
|
37
43
|
complete?: DocumentFileBytes;
|
|
38
44
|
/** The file version the loaded pages belong to; absent before the first page. */
|
|
@@ -65,8 +71,12 @@ export interface TextState {
|
|
|
65
71
|
export declare function fresh(): TextTabState;
|
|
66
72
|
/** The preview store's write set; every action names the tab it writes. */
|
|
67
73
|
type TextActions = {
|
|
74
|
+
toggledAutoRefresh: (draft: TextState, tabId: TabId) => void;
|
|
75
|
+
resourceChanged: (draft: TextState, tabId: TabId) => void;
|
|
68
76
|
selected: (draft: TextState, tabId: TabId, rendererId: string | undefined) => void;
|
|
69
|
-
loading: (draft: TextState, tabId: TabId, mode?: DocumentLoadMode, observedVersion?: string) => void;
|
|
77
|
+
loading: (draft: TextState, tabId: TabId, mode?: DocumentLoadMode, observedVersion?: string, contentRendererId?: string) => void;
|
|
78
|
+
rendered: (draft: TextState, tabId: TabId, revision: number, version: string) => void;
|
|
79
|
+
rendererFailed: (draft: TextState, tabId: TabId, revision: number) => void;
|
|
70
80
|
complete: (draft: TextState, tabId: TabId, file: DocumentFileBytes) => void;
|
|
71
81
|
page: (draft: TextState, tabId: TabId, page: WorkspaceFileText) => void;
|
|
72
82
|
failed: (draft: TextState, tabId: TabId, failure: RemoteFailure) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ZoomLabels } from './types.ts';
|
|
2
|
+
/** Live percentage display updated independently from the document tree. */
|
|
3
|
+
export interface ZoomControlsHandle {
|
|
4
|
+
/** @param zoom - current gesture scale multiplier. */
|
|
5
|
+
showZoom: (zoom: number) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Present fit-width, fixed presets, and incremental controls.
|
|
9
|
+
* @param props - current resolved zoom, preference mode, labels, and callbacks.
|
|
10
|
+
* @returns a localized zoom toolbar.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ZoomControls: import("react").ForwardRefExoticComponent<{
|
|
13
|
+
readonly zoom: number;
|
|
14
|
+
readonly fitWidth: boolean;
|
|
15
|
+
readonly labels: ZoomLabels;
|
|
16
|
+
readonly visible: boolean;
|
|
17
|
+
readonly onZoom: (zoom: number) => void;
|
|
18
|
+
readonly onFitWidth: () => void;
|
|
19
|
+
readonly onActiveChange: (active: boolean) => void;
|
|
20
|
+
} & import("react").RefAttributes<ZoomControlsHandle>>;
|
|
21
|
+
//# sourceMappingURL=ZoomControls.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Shared zoom viewport, gesture handling, anchoring, and fit-width measurement. */
|
|
2
|
+
import { type ReactNode, type RefCallback } from 'react';
|
|
3
|
+
import { type ZoomLabels, type ZoomPreference } from './types.ts';
|
|
4
|
+
/** @returns an actual-size scale that only shrinks content wider than the viewport. */
|
|
5
|
+
export declare function fitWidthZoom(viewportWidth: number, intrinsicWidth: number | undefined, horizontalInset?: number): number;
|
|
6
|
+
/** Shared viewport inputs for renderer-owned content and tab state. */
|
|
7
|
+
export interface ZoomViewportProps {
|
|
8
|
+
readonly preference: ZoomPreference;
|
|
9
|
+
readonly intrinsicWidth: number | undefined;
|
|
10
|
+
readonly horizontalInset?: number;
|
|
11
|
+
readonly labels: ZoomLabels;
|
|
12
|
+
readonly signal: AbortSignal;
|
|
13
|
+
readonly scrollportRef: RefCallback<HTMLElement>;
|
|
14
|
+
readonly onPreference: (preference: ZoomPreference) => void;
|
|
15
|
+
readonly children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Keep zoom controls and trackpad gestures independent from document rendering.
|
|
19
|
+
* @param props - renderer content, intrinsic width, tab preference, and localized labels.
|
|
20
|
+
* @returns the owned scrollport and floating zoom controls.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ZoomViewport(props: ZoomViewportProps): ReactNode;
|
|
23
|
+
/** Shared surface class for actual-size and fit-width layout. */
|
|
24
|
+
export declare const zoomSurfaceClass: string;
|
|
25
|
+
//# sourceMappingURL=ZoomViewport.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Shared zoom copy embedded into renderer-owned dictionaries. */
|
|
2
|
+
export declare const zoomZh: {
|
|
3
|
+
readonly zoomControls: "缩放控件";
|
|
4
|
+
readonly zoomMenu: "选择缩放比例";
|
|
5
|
+
readonly zoomOut: "缩小";
|
|
6
|
+
readonly zoomIn: "放大";
|
|
7
|
+
readonly zoomFitWidth: "适应宽度";
|
|
8
|
+
readonly zoomValue: "{percent}%";
|
|
9
|
+
};
|
|
10
|
+
/** Shared English zoom copy. */
|
|
11
|
+
export declare const zoomEn: {
|
|
12
|
+
zoomControls: string;
|
|
13
|
+
zoomMenu: string;
|
|
14
|
+
zoomOut: string;
|
|
15
|
+
zoomIn: string;
|
|
16
|
+
zoomFitWidth: string;
|
|
17
|
+
zoomValue: string;
|
|
18
|
+
};
|
|
19
|
+
/** Shared zoom dictionary keys. */
|
|
20
|
+
export type ZoomLocaleKey = keyof typeof zoomZh;
|
|
21
|
+
//# sourceMappingURL=locales.d.ts.map
|