@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
package/lib/index.js
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
//#region lib/types/config.js
|
|
3
|
+
/** Cache limits shared by the Host configuration and browser document previews. */
|
|
4
|
+
/** Deployment limits applied before Office preview registration. */
|
|
5
|
+
const Config = z.object({
|
|
6
|
+
office: z.object({
|
|
7
|
+
maxCachedEntries: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(8),
|
|
8
|
+
maxCachedBytes: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(64 * 1024 * 1024),
|
|
9
|
+
maxPending: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(8),
|
|
10
|
+
maxReaders: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(32)
|
|
11
|
+
}),
|
|
12
|
+
excel: z.object({
|
|
13
|
+
maxBytes: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(16 * 1024 * 1024),
|
|
14
|
+
maxCells: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(25e4),
|
|
15
|
+
timeoutMs: z.natural().min(1).max(2147483647).default(15e3)
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
1
19
|
//#region lib/types/index.js
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Embed validated preview settings in browser pages.
|
|
22
|
+
* @param ctx - Host context serving browser pages.
|
|
23
|
+
* @param config - Cache limits adopted when the page loads.
|
|
24
|
+
*/
|
|
25
|
+
function apply(ctx, config) {
|
|
26
|
+
ctx.on("webserver/index-inject", (table) => {
|
|
27
|
+
table.push({
|
|
28
|
+
kind: "global",
|
|
29
|
+
name: "__DSH_DOCUMENT_PREVIEW_CONFIG__",
|
|
30
|
+
value: config
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
5
34
|
//#endregion
|
|
6
|
-
export { apply };
|
|
35
|
+
export { Config, apply };
|
|
@@ -13,11 +13,11 @@ export interface TextPreviewInjected extends TextInjected {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
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'>;
|
|
16
|
+
export type TextPreviewProps = PropsRuntime<'sidebar.right.pane.tab'> & PropsRenderSlots<'sidebar.right.tab.document' | 'sidebar.right.tab.document.action' | 'sidebar.right.tab.document.actions' | 'sidebar.right.tab.document.unpreviewable'> & PropsStore<TextStore> & InjectFace<TextPreviewInjected> & PropsLocale<'sidebarDocumentPreview'>;
|
|
17
17
|
/**
|
|
18
18
|
* The text type's body, registered under `sidebar.right.pane.tab` as `text`.
|
|
19
19
|
* @param props - composed slot props.
|
|
20
20
|
* @returns the content read so far with its controls, or a progress line.
|
|
21
21
|
*/
|
|
22
|
-
export declare function TextPreview({ useTabInfo, useResource, useStore, actions, loadPage, reloadPages, loadAll, reloadAll, useDocumentPreviews, renderSlot, t, }: TextPreviewProps): ReactNode;
|
|
22
|
+
export declare function TextPreview({ useTabInfo, useResource, useStore, actions, loadPage, reloadPages, loadAll, reloadAll, prepareRenderer, useDocumentPreviews, renderSlot, t, addResource, setResources, }: TextPreviewProps): ReactNode;
|
|
23
23
|
//# sourceMappingURL=TextPreview.d.ts.map
|
|
@@ -9,7 +9,7 @@ export interface DocumentTextPage {
|
|
|
9
9
|
readonly lines: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Ordinary file contents, or a request for the selected renderer to load its content.
|
|
13
13
|
* Byte arrays are transient UI input, never persisted layout or Session data.
|
|
14
14
|
*/
|
|
15
15
|
export type DocumentContent = {
|
|
@@ -20,22 +20,76 @@ export type DocumentContent = {
|
|
|
20
20
|
} | {
|
|
21
21
|
readonly kind: 'bytes';
|
|
22
22
|
readonly data: Uint8Array<ArrayBuffer>;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'renderer';
|
|
25
|
+
/** Changes on reload or implementation replacement; retained contents belong to one revision. */
|
|
26
|
+
readonly revision: number;
|
|
27
|
+
/** Report the displayed source version; stale revisions cannot update the owner. @param version - loaded source version. */
|
|
28
|
+
readonly loaded: (version: string) => void;
|
|
29
|
+
/** End a failed load; a later file change can start another revision. */
|
|
30
|
+
readonly failed: () => void;
|
|
31
|
+
/** Cancel the current load and start a new revision. */
|
|
32
|
+
readonly reload: () => void;
|
|
23
33
|
};
|
|
34
|
+
/** Content and viewing inputs shared by document bodies and nested PDF presentation. */
|
|
35
|
+
export interface DocumentBodyOwner {
|
|
36
|
+
/** Observe a file read by this renderer. @param address - complete file resource address. */
|
|
37
|
+
readonly addResource: (address: string) => void;
|
|
38
|
+
/** Replace this renderer's dependencies. @param addresses - complete file resource addresses. */
|
|
39
|
+
readonly setResources: (addresses: readonly string[]) => void;
|
|
40
|
+
/** Original file address, also readable through the standard useResource hook. */
|
|
41
|
+
readonly resourceAddress: string;
|
|
42
|
+
/** Ordinary file content or a renderer-owned loading request; text accumulates until eof. */
|
|
43
|
+
readonly content: DocumentContent;
|
|
44
|
+
/** The document toolbar's current wrapping preference. */
|
|
45
|
+
readonly wrap: boolean;
|
|
46
|
+
/** Report a renderer-owned scrollport; passing `null` restores the shared body as the owner. */
|
|
47
|
+
readonly scrollportRef: RefCallback<HTMLElement>;
|
|
48
|
+
}
|
|
24
49
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
25
50
|
interface SlotMap {
|
|
26
51
|
/** Document body selected by a registered implementation id. */
|
|
27
52
|
'sidebar.right.tab.document': {
|
|
53
|
+
kind: 'keyed';
|
|
54
|
+
scope: 'session';
|
|
55
|
+
owner: DocumentBodyOwner;
|
|
56
|
+
hookContext: UseSidebarRightTabInfo;
|
|
57
|
+
inject: {
|
|
58
|
+
hooks: {
|
|
59
|
+
tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Header toolbar contributions acting on the previewed file, rendered
|
|
65
|
+
* after the preview's own controls once the file's Host path is known.
|
|
66
|
+
*/
|
|
67
|
+
'sidebar.right.tab.document.actions': {
|
|
68
|
+
kind: 'list';
|
|
69
|
+
scope: 'session';
|
|
70
|
+
owner: {
|
|
71
|
+
/** Absolute path in the file's execution environment; native actions must verify a Host mapping. */
|
|
72
|
+
readonly absolutePath: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Empty-state contributions for a file this preview cannot render,
|
|
77
|
+
* offered where Retry would stand once the file's Host path is known.
|
|
78
|
+
*/
|
|
79
|
+
'sidebar.right.tab.document.unpreviewable': {
|
|
80
|
+
kind: 'list';
|
|
81
|
+
scope: 'session';
|
|
82
|
+
owner: {
|
|
83
|
+
/** Absolute path in the file's execution environment; native actions must verify a Host mapping. */
|
|
84
|
+
readonly absolutePath: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/** Renderer-specific controls before the document toolbar's reload button. */
|
|
88
|
+
'sidebar.right.tab.document.action': {
|
|
28
89
|
kind: 'keyed';
|
|
29
90
|
scope: 'session';
|
|
30
91
|
owner: {
|
|
31
|
-
/** Original file address, also readable through the standard useResource hook. */
|
|
32
|
-
readonly resourceAddress: string;
|
|
33
|
-
/** Loaded content; text is an accumulated prefix until eof. */
|
|
34
92
|
readonly content: DocumentContent;
|
|
35
|
-
/** The document toolbar's current wrapping preference. */
|
|
36
|
-
readonly wrap: boolean;
|
|
37
|
-
/** Report a renderer-owned scrollport; passing `null` restores the shared body as the owner. */
|
|
38
|
-
readonly scrollportRef: RefCallback<HTMLElement>;
|
|
39
93
|
};
|
|
40
94
|
hookContext: UseSidebarRightTabInfo;
|
|
41
95
|
inject: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export type DocumentLoadMode = 'text-pages' | 'bytes-complete';
|
|
1
|
+
/** Shared text or byte reads, or content loading owned by the renderer. */
|
|
2
|
+
export type DocumentLoadMode = 'text-pages' | 'bytes-complete' | 'renderer';
|
|
3
3
|
/** One renderer implementation, independent of its component registration. */
|
|
4
4
|
export interface DocumentPreviewDefinition {
|
|
5
5
|
/** Unique implementation name, also used as the document slot key. */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** File-resource membership and invalidation for one document preview. */
|
|
2
|
+
import type { Resources } from '@deepseek-ai/dsh-client-resources/client';
|
|
3
|
+
/** Forwards member metadata changes to one document preview. */
|
|
4
|
+
export declare class ResourceGroup {
|
|
5
|
+
private readonly resources;
|
|
6
|
+
private readonly changed;
|
|
7
|
+
private readonly members;
|
|
8
|
+
/** @param resources - shared file sources. @param changed - marks the owning preview stale. */
|
|
9
|
+
constructor(resources: Resources, changed: () => void);
|
|
10
|
+
/**
|
|
11
|
+
* Subscribe once; initial metadata establishes the baseline for later changes.
|
|
12
|
+
* @param address - complete resource address.
|
|
13
|
+
*/
|
|
14
|
+
add(address: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Release dependencies absent from the current document.
|
|
17
|
+
* @param addresses - complete membership of the latest document load.
|
|
18
|
+
*/
|
|
19
|
+
set(addresses: readonly string[]): void;
|
|
20
|
+
/** Release every member when the preview tab ends. */
|
|
21
|
+
close(): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=resource-group.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Document view state belongs to tab records, including while their bodies are hidden. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
4
|
+
/**
|
|
5
|
+
* Release retained view state on tab closure or plugin disposal.
|
|
6
|
+
* @param ctx - owning preview plugin context.
|
|
7
|
+
* @returns a callback accepting the tab, its lifetime signal, and its store's forget action; repeated holds share one listener.
|
|
8
|
+
*/
|
|
9
|
+
export declare function retainDocumentTabs(ctx: Context): (tabId: TabId, signal: AbortSignal, forget: (tabId: TabId) => void) => void;
|
|
10
|
+
//# sourceMappingURL=tab-lifetime.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Load the spreadsheet renderer only when a supported workbook is opened. */
|
|
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
|
+
import { type ExcelFormat } from './format.ts';
|
|
6
|
+
import type { ExcelLimits } from './model.ts';
|
|
7
|
+
/** Document input plus parser limits and localized copy. */
|
|
8
|
+
export type ExcelBodyProps = DocumentPreviewProps & PropsLocale<'sidebarExcel'> & {
|
|
9
|
+
readonly limits: ExcelLimits;
|
|
10
|
+
};
|
|
11
|
+
/** Lazily loaded renderer input with the filename-derived parser choice. */
|
|
12
|
+
export type LoadedExcelBodyProps = ExcelBodyProps & {
|
|
13
|
+
readonly format: ExcelFormat;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Load the browser spreadsheet renderer for every registered format.
|
|
17
|
+
* @param props - Complete file bytes and standard document seats.
|
|
18
|
+
* @returns Localized loading state or Excel preview.
|
|
19
|
+
*/
|
|
20
|
+
export declare function LazyExcelBody(props: ExcelBodyProps): ReactNode;
|
|
21
|
+
//# sourceMappingURL=LazyExcelBody.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Format-specific parsing into one read-only FortuneSheet representation. */
|
|
2
|
+
import type { ExcelFormat } from './format.ts';
|
|
3
|
+
import type { ExcelLimits, ExcelPreview } from './model.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Decode spreadsheet bytes without recalculating saved formulas.
|
|
6
|
+
* @param bytes - Borrowed complete file bytes.
|
|
7
|
+
* @param format - Format selected by the registered filename suffix.
|
|
8
|
+
* @param limits - File and matrix allocation limits.
|
|
9
|
+
* @returns Display sheets and missing formula-cache count.
|
|
10
|
+
*/
|
|
11
|
+
export declare function convertExcel(bytes: Uint8Array<ArrayBuffer>, format: ExcelFormat, limits: ExcelLimits): Promise<ExcelPreview>;
|
|
12
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ExcelLimits, type ExcelPreview } from './model.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Parse delimited UTF-8 or BOM-marked UTF-16 without type inference.
|
|
4
|
+
* @param bytes - Borrowed complete file bytes.
|
|
5
|
+
* @param format - Comma or tab-separated input.
|
|
6
|
+
* @param limits - Maximum worksheet area.
|
|
7
|
+
* @returns A single sheet with literal field values.
|
|
8
|
+
*/
|
|
9
|
+
export declare function convertDelimited(bytes: Uint8Array<ArrayBuffer>, format: 'csv' | 'tsv', limits: ExcelLimits): ExcelPreview;
|
|
10
|
+
//# sourceMappingURL=delimited.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Locale-independent spreadsheet parser failure categories. */
|
|
2
|
+
export declare class ExcelPreviewError extends Error {
|
|
3
|
+
readonly code: 'invalid' | 'tooLarge' | 'timeout' | 'encoding';
|
|
4
|
+
/** @param code - User-actionable parser failure. */
|
|
5
|
+
constructor(code: 'invalid' | 'tooLarge' | 'timeout' | 'encoding', options?: ErrorOptions);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Read-only spreadsheet surface backed by browser-parsed workbook data. */
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import type { LoadedExcelBodyProps } from './LazyExcelBody.tsx';
|
|
4
|
+
/**
|
|
5
|
+
* Display stored spreadsheet values and formats without editing or recalculation.
|
|
6
|
+
* @param props - Complete workbook bytes, limits, and locale.
|
|
7
|
+
* @returns An isolated spreadsheet surface with cancellable loading.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ExcelBody({ content, format, limits, t }: LoadedExcelBodyProps): ReactNode;
|
|
10
|
+
//# sourceMappingURL=excel.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** File formats admitted by the spreadsheet preview. */
|
|
2
|
+
export type ExcelFormat = 'xlsx' | 'xls' | 'csv' | 'tsv';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a registered filename to its parser.
|
|
5
|
+
* @param path - Decoded file path.
|
|
6
|
+
* @returns The supported suffix; rejects unsupported filenames.
|
|
7
|
+
*/
|
|
8
|
+
export declare function excelFormat(path: string): ExcelFormat;
|
|
9
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Excel previews use ordinary authorized file bytes without Office conversion. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Config } from '../../config.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Register the browser Excel viewer and its lifecycle-owned slot.
|
|
6
|
+
* @param ctx - Preview and locale registries.
|
|
7
|
+
* @param limits - Resolved parser limits.
|
|
8
|
+
*/
|
|
9
|
+
export declare function apply(ctx: Context, limits: Config['excel']): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Locale-owned Excel preview controls and parser feedback. */
|
|
2
|
+
export declare const zh: {
|
|
3
|
+
title: string;
|
|
4
|
+
language: string;
|
|
5
|
+
loading: string;
|
|
6
|
+
invalid: string;
|
|
7
|
+
tooLarge: string;
|
|
8
|
+
timeout: string;
|
|
9
|
+
encoding: string;
|
|
10
|
+
formulaWarning: string;
|
|
11
|
+
unsupportedNotice: string;
|
|
12
|
+
charts: string;
|
|
13
|
+
images: string;
|
|
14
|
+
shapes: string;
|
|
15
|
+
conditionalFormatting: string;
|
|
16
|
+
featureSeparator: string;
|
|
17
|
+
retry: string;
|
|
18
|
+
};
|
|
19
|
+
/** Excel preview dictionary keys. */
|
|
20
|
+
export type ExcelPreviewKey = keyof typeof zh;
|
|
21
|
+
/** English Excel preview copy. */
|
|
22
|
+
export declare const en: {
|
|
23
|
+
title: string;
|
|
24
|
+
language: string;
|
|
25
|
+
loading: string;
|
|
26
|
+
invalid: string;
|
|
27
|
+
tooLarge: string;
|
|
28
|
+
timeout: string;
|
|
29
|
+
encoding: string;
|
|
30
|
+
formulaWarning: string;
|
|
31
|
+
unsupportedNotice: string;
|
|
32
|
+
charts: string;
|
|
33
|
+
images: string;
|
|
34
|
+
shapes: string;
|
|
35
|
+
conditionalFormatting: string;
|
|
36
|
+
featureSeparator: string;
|
|
37
|
+
retry: string;
|
|
38
|
+
};
|
|
39
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
40
|
+
interface LocaleNamespaceMap {
|
|
41
|
+
/** Excel preview status and third-party locale selection. */
|
|
42
|
+
sidebarExcel: ExcelPreviewKey;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Shared display cells, resource limits, and parser failure categories. */
|
|
2
|
+
import { type Cell, type Sheet, type SheetConfig } from '@fortune-sheet/core';
|
|
3
|
+
/** Resource limits applied before allocating FortuneSheet's dense cell matrices. */
|
|
4
|
+
export interface ExcelLimits {
|
|
5
|
+
/** Maximum source file bytes. */
|
|
6
|
+
maxBytes: number;
|
|
7
|
+
/** Maximum combined rectangular cell area across worksheets. */
|
|
8
|
+
maxCells: number;
|
|
9
|
+
/** Maximum time allowed for one parser Worker. */
|
|
10
|
+
timeoutMs: number;
|
|
11
|
+
}
|
|
12
|
+
/** Content categories reported in stable order when XLSX preview omits them. */
|
|
13
|
+
export declare const EXCEL_UNSUPPORTED_FEATURES: readonly ["charts", "images", "shapes", "conditionalFormatting"];
|
|
14
|
+
/** A detected workbook feature that the spreadsheet preview does not display. */
|
|
15
|
+
export type ExcelUnsupportedFeature = typeof EXCEL_UNSUPPORTED_FEATURES[number];
|
|
16
|
+
/** Preview data, missing formula results, and detected content that is not displayed. */
|
|
17
|
+
export interface ExcelPreview {
|
|
18
|
+
sheets: Sheet[];
|
|
19
|
+
missingResults: number;
|
|
20
|
+
unsupportedFeatures: ExcelUnsupportedFeature[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Retain an addressable A1 selection, including an A1 merge.
|
|
24
|
+
* @param config - Worksheet layout.
|
|
25
|
+
* @returns The initial selection used when activating a worksheet.
|
|
26
|
+
*/
|
|
27
|
+
export declare function initialSelection(config: SheetConfig): NonNullable<Sheet['luckysheet_select_save']>;
|
|
28
|
+
/**
|
|
29
|
+
* Apply number formatting and default alignment without evaluating formulas.
|
|
30
|
+
* @param cell - Owned display cell to complete.
|
|
31
|
+
* @param numberFormat - Excel number format code.
|
|
32
|
+
* @returns The same cell with its display text and value type.
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatCell(cell: Cell, numberFormat: string): Cell;
|
|
35
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExcelFormat } from './format.ts';
|
|
2
|
+
import { type ExcelLimits, type ExcelPreview } from './model.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Parse workbook bytes in a disposable Worker, copying the retained preview buffer.
|
|
5
|
+
* @param bytes - Borrowed complete file bytes.
|
|
6
|
+
* @param format - Format selected by the registered filename suffix.
|
|
7
|
+
* @param limits - File, matrix, and elapsed-time limits.
|
|
8
|
+
* @param signal - Document body's lifetime.
|
|
9
|
+
* @returns Parsed sheets; rejects with a locale key on parser failures.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseExcel(bytes: Uint8Array<ArrayBuffer>, format: ExcelFormat, limits: ExcelLimits, signal: AbortSignal): Promise<ExcelPreview>;
|
|
12
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Legacy BIFF workbooks mapped to saved values and basic spreadsheet layout. */
|
|
2
|
+
import { type WorkBook } from 'xlsx';
|
|
3
|
+
import { type ExcelLimits, type ExcelPreview } from './model.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Decode a binary XLS workbook without accepting renamed text or HTML files.
|
|
6
|
+
* @param bytes - Borrowed complete workbook bytes.
|
|
7
|
+
* @param limits - Maximum combined worksheet area.
|
|
8
|
+
* @returns Saved values, formulas, and supported workbook layout.
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertXls(bytes: Uint8Array<ArrayBuffer>, limits: ExcelLimits): ExcelPreview;
|
|
11
|
+
/**
|
|
12
|
+
* Map SheetJS values and optional BIFF layout metadata without retaining the workbook.
|
|
13
|
+
* @param workbook - Parsed legacy workbook.
|
|
14
|
+
* @param limits - Maximum combined worksheet area.
|
|
15
|
+
* @returns FortuneSheet display data.
|
|
16
|
+
*/
|
|
17
|
+
export declare function mapXlsWorkbook(workbook: WorkBook, limits: ExcelLimits): ExcelPreview;
|
|
18
|
+
//# sourceMappingURL=xls.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Owns the unpacked preview copy and its detected unsupported content. */
|
|
2
|
+
export declare class XlsxPreviewArchive {
|
|
3
|
+
private readonly bytes;
|
|
4
|
+
/** Detected workbook content that the preview does not display. */
|
|
5
|
+
readonly unsupportedFeatures: Set<"charts" | "images" | "shapes" | "conditionalFormatting">;
|
|
6
|
+
private readonly files;
|
|
7
|
+
/**
|
|
8
|
+
* Read an archive without modifying the borrowed source buffer.
|
|
9
|
+
* @param bytes - Complete XLSX source bytes.
|
|
10
|
+
*/
|
|
11
|
+
constructor(bytes: Uint8Array<ArrayBuffer>);
|
|
12
|
+
/**
|
|
13
|
+
* Omit DrawingML parts before ExcelJS parses them; callers must also ignore worksheet drawing references.
|
|
14
|
+
* @returns Source bytes when no parts were omitted, otherwise an uncompressed temporary ZIP.
|
|
15
|
+
*/
|
|
16
|
+
withoutDrawings(): Uint8Array<ArrayBuffer>;
|
|
17
|
+
private inspectContent;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=xlsx-archive.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ExcelLimits, type ExcelPreview } from './model.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Decode an XLSX into display cells, omitting drawings and retaining formulas without recalculation.
|
|
4
|
+
* @param bytes - Complete borrowed workbook bytes.
|
|
5
|
+
* @param limits - File and matrix allocation limits.
|
|
6
|
+
* @returns Sheets ready for a read-only FortuneSheet workbook.
|
|
7
|
+
*/
|
|
8
|
+
export declare function convertXlsx(bytes: Uint8Array<ArrayBuffer>, limits: ExcelLimits): Promise<ExcelPreview>;
|
|
9
|
+
//# sourceMappingURL=xlsx.d.ts.map
|
|
@@ -21,8 +21,13 @@ import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit';
|
|
|
21
21
|
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
22
22
|
import type { ReadDocumentBytes, ReadWorkspaceFilePage, SessionFile } from './rpc.ts';
|
|
23
23
|
import type { TextStore } from './store.ts';
|
|
24
|
+
import type { Resources } from '@deepseek-ai/dsh-client-resources/client';
|
|
24
25
|
/** The preview's injected business face, as the body receives it. */
|
|
25
26
|
export interface TextInjected {
|
|
27
|
+
/** Observe one renderer dependency. @param tabId - owning tab. @param address - resource address. @param signal - tab lifetime. */
|
|
28
|
+
readonly addResource: (tabId: TabId, address: string, signal: AbortSignal) => void;
|
|
29
|
+
/** Replace dependency membership. @param tabId - owning tab. @param addresses - resource addresses. @param signal - tab lifetime. */
|
|
30
|
+
readonly setResources: (tabId: TabId, addresses: readonly string[], signal: AbortSignal) => void;
|
|
26
31
|
/**
|
|
27
32
|
* Read one page into the store. A page of a newer file version than the pages
|
|
28
33
|
* held, arriving past the first line, is not kept: the tab's pages are dropped
|
|
@@ -61,12 +66,22 @@ export interface TextInjected {
|
|
|
61
66
|
* @param observedVersion - metadata version observed at read start.
|
|
62
67
|
*/
|
|
63
68
|
readonly reloadAll: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Begin a renderer-owned load without reading source bytes.
|
|
71
|
+
* @param tabId - owning tab.
|
|
72
|
+
* @param signal - tab lifetime.
|
|
73
|
+
* @param rendererId - selected implementation.
|
|
74
|
+
* @param observedVersion - metadata version observed at request start.
|
|
75
|
+
* @param reload - discard the previous content revision.
|
|
76
|
+
*/
|
|
77
|
+
readonly prepareRenderer: (tabId: TabId, signal: AbortSignal, rendererId: string, observedVersion?: string, reload?: boolean) => void;
|
|
64
78
|
}
|
|
65
79
|
/**
|
|
66
80
|
* Bind the preview's face to one paged read and one complete-byte read.
|
|
67
81
|
* @param read - the bound `workspaceFiles.read` call.
|
|
68
|
-
* @param readAll -
|
|
82
|
+
* @param readAll - complete-byte workspace Remote read.
|
|
83
|
+
* @param resources - shared metadata sources for the document and its dependencies.
|
|
69
84
|
* @returns the Slot `inject` factory: bound actions in, face out. The slot's session id is unused because the address carries its own.
|
|
70
85
|
*/
|
|
71
|
-
export declare function textFace(read: ReadWorkspaceFilePage, readAll: ReadDocumentBytes): (sessionId: SessionId, actions: BoundActions<TextStore>) => TextInjected;
|
|
86
|
+
export declare function textFace(read: ReadWorkspaceFilePage, readAll: ReadDocumentBytes, resources: Resources): (sessionId: SessionId, actions: BoundActions<TextStore>) => TextInjected;
|
|
72
87
|
//# sourceMappingURL=face.d.ts.map
|
|
@@ -14,4 +14,14 @@ import type { TranslateNS } from '@deepseek-ai/dsh-client-locale/client';
|
|
|
14
14
|
* @returns the line to show in place of the file.
|
|
15
15
|
*/
|
|
16
16
|
export declare function failureLine(t: TranslateNS<'sidebarDocumentPreview'>, failure: RemoteFailure): string;
|
|
17
|
+
/** The action an empty preview offers beside its failure line. */
|
|
18
|
+
export type EmptyFailureRecourse = 'open' | 'retry' | 'none';
|
|
19
|
+
/**
|
|
20
|
+
* Choose the empty state's action for one settled read failure.
|
|
21
|
+
* @param failure - the settled Remote failure.
|
|
22
|
+
* @returns `open` for a readable file this preview cannot render, `none` for a
|
|
23
|
+
* path with nothing to show or open, `retry` for the rest: carrier and
|
|
24
|
+
* unclassified failures a second read may resolve.
|
|
25
|
+
*/
|
|
26
|
+
export declare function emptyFailureRecourse(failure: RemoteFailure): EmptyFailureRecourse;
|
|
17
27
|
//# sourceMappingURL=failure-line.d.ts.map
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
2
|
+
import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
|
|
3
4
|
import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
4
5
|
import type { ReadHtmlRelated } from './read-relative.ts';
|
|
5
6
|
/** Standard document inputs plus this renderer's dictionary. */
|
|
6
|
-
export type HtmlBodyProps = DocumentPreviewProps & PropsLocale<'documentHtml'> &
|
|
7
|
+
export type HtmlBodyProps = DocumentPreviewProps & PropsLocale<'documentHtml'> & InjectFace<HtmlBodyInjected>;
|
|
8
|
+
/** Related-file reader and accepted preview mode supplied by the plugin. */
|
|
9
|
+
export interface HtmlBodyInjected {
|
|
10
|
+
hooks: {
|
|
11
|
+
interactivePreview: ObservableSnapshot<boolean>;
|
|
12
|
+
};
|
|
7
13
|
/** Ordinary Remote callback bound by this renderer's Slot inject. */
|
|
8
14
|
readonly readRelated: ReadHtmlRelated;
|
|
9
|
-
}
|
|
15
|
+
}
|
|
10
16
|
/**
|
|
11
17
|
* Render complete HTML with the standard file and tab hooks.
|
|
12
18
|
* @param props - document bytes, hooks, related-file reader and locale.
|
|
13
19
|
* @returns an isolated HTML document, or nothing for text delivery.
|
|
14
20
|
*/
|
|
15
|
-
export declare function HtmlBody({ content, resourceAddress, readRelated, useTabInfo, t }: HtmlBodyProps): ReactNode;
|
|
21
|
+
export declare function HtmlBody({ content, resourceAddress, readRelated, useTabInfo, useInteractivePreview, addResource, setResources, t, }: HtmlBodyProps): ReactNode;
|
|
16
22
|
//# sourceMappingURL=HtmlBody.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepare static content before the browser can load any document resources.
|
|
3
|
+
* @param data - complete UTF-8 HTML bytes.
|
|
4
|
+
* @returns document with the restrictive CSP first in its head.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createBasicHtmlDocument(data: Uint8Array<ArrayBuffer>): string;
|
|
7
|
+
//# sourceMappingURL=basic-document.d.ts.map
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
/** Adapt a
|
|
1
|
+
/** Adapt a relative workspace read without changing its Session or Host path authority. */
|
|
2
2
|
import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DocumentFileBytes } from '../rpc.ts';
|
|
4
4
|
import type { ReadHtmlRelative } from './pack.ts';
|
|
5
5
|
/**
|
|
6
6
|
* Read one dependency relative to the addressed HTML file through the Host.
|
|
7
7
|
* @param address - root HTML file address.
|
|
8
8
|
* @param relativePath - decoded dependency path, resolved only by the Host.
|
|
9
9
|
* @param signal - cancellation shared by the tab and packing operation.
|
|
10
|
-
* @returns the
|
|
10
|
+
* @returns the complete-byte result, including declared failures.
|
|
11
11
|
*/
|
|
12
|
-
export type ReadHtmlRelated = (address: string, relativePath: string, signal: AbortSignal) => Promise<RemoteResult<
|
|
12
|
+
export type ReadHtmlRelated = (address: string, relativePath: string, signal: AbortSignal) => Promise<RemoteResult<DocumentFileBytes>>;
|
|
13
13
|
/**
|
|
14
14
|
* Bind a package reader to the original HTML file's address.
|
|
15
|
-
* @param readRelated -
|
|
15
|
+
* @param readRelated - workspace reader using the Session in the root HTML address.
|
|
16
16
|
* @param address - root HTML file address.
|
|
17
17
|
* @param lifetime - tab lifetime.
|
|
18
|
+
* @param addResource - subscribes to the dependency path reported by the Host.
|
|
18
19
|
* @returns a reader that strips URL query/fragment, decodes one path, and preserves Host failures.
|
|
19
20
|
*/
|
|
20
|
-
export declare function createReadHtmlRelative(readRelated: ReadHtmlRelated, address: string, lifetime: AbortSignal): ReadHtmlRelative;
|
|
21
|
+
export declare function createReadHtmlRelative(readRelated: ReadHtmlRelated, address: string, lifetime: AbortSignal, addResource: (address: string) => void): ReadHtmlRelative;
|
|
21
22
|
//# sourceMappingURL=read-relative.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/** Complete image bytes rendered
|
|
1
|
+
/** Complete image bytes rendered in a shared zoom viewport. */
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
|
+
import type { PropsLocale, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
|
|
4
4
|
import type { DocumentPreviewProps } from '../document/contract.ts';
|
|
5
|
+
import { type ZoomInjected, type ZoomStore } from '../zoom/store.ts';
|
|
5
6
|
declare const IMAGE_MEDIA_TYPES: {
|
|
6
7
|
readonly png: "image/png";
|
|
7
8
|
readonly jpg: "image/jpeg";
|
|
@@ -14,7 +15,7 @@ declare const IMAGE_MEDIA_TYPES: {
|
|
|
14
15
|
};
|
|
15
16
|
type ImageMediaType = typeof IMAGE_MEDIA_TYPES[keyof typeof IMAGE_MEDIA_TYPES];
|
|
16
17
|
/** Standard document props plus the image renderer's dictionary. */
|
|
17
|
-
export type ImageBodyProps = DocumentPreviewProps & PropsLocale<'sidebarImage'
|
|
18
|
+
export type ImageBodyProps = DocumentPreviewProps & PropsLocale<'sidebarImage'> & PropsStore<ZoomStore> & ZoomInjected;
|
|
18
19
|
/**
|
|
19
20
|
* Resolve a supported filename to the media type assigned to its Blob.
|
|
20
21
|
* @param path - decoded workspace file path.
|
|
@@ -22,12 +23,10 @@ export type ImageBodyProps = DocumentPreviewProps & PropsLocale<'sidebarImage'>;
|
|
|
22
23
|
*/
|
|
23
24
|
export declare function imageMediaType(path: string): ImageMediaType | undefined;
|
|
24
25
|
/**
|
|
25
|
-
* Present complete image bytes
|
|
26
|
+
* Present complete image bytes with fit-width and fixed-scale viewing.
|
|
26
27
|
* @param props - document bytes, resource identity, and locale.
|
|
27
|
-
* @returns a rounded image
|
|
28
|
-
* ratio — a smaller image centres at its intrinsic size — whose containing
|
|
29
|
-
* document body provides vertical scrolling.
|
|
28
|
+
* @returns a rounded image fitted or scaled at its intrinsic aspect ratio.
|
|
30
29
|
*/
|
|
31
|
-
export declare function ImageBody(
|
|
30
|
+
export declare function ImageBody(props: ImageBodyProps): ReactNode;
|
|
32
31
|
export {};
|
|
33
32
|
//# sourceMappingURL=ImageBody.d.ts.map
|
|
@@ -5,6 +5,12 @@ export declare const zh: {
|
|
|
5
5
|
loading: string;
|
|
6
6
|
failed: string;
|
|
7
7
|
unsupported: string;
|
|
8
|
+
zoomControls: "缩放控件";
|
|
9
|
+
zoomMenu: "选择缩放比例";
|
|
10
|
+
zoomOut: "缩小";
|
|
11
|
+
zoomIn: "放大";
|
|
12
|
+
zoomFitWidth: "适应宽度";
|
|
13
|
+
zoomValue: "{percent}%";
|
|
8
14
|
};
|
|
9
15
|
/** Image renderer dictionary keys. */
|
|
10
16
|
export type ImagePreviewKey = keyof typeof zh;
|
|
@@ -15,6 +21,12 @@ export declare const en: {
|
|
|
15
21
|
loading: string;
|
|
16
22
|
failed: string;
|
|
17
23
|
unsupported: string;
|
|
24
|
+
zoomControls: string;
|
|
25
|
+
zoomMenu: string;
|
|
26
|
+
zoomOut: string;
|
|
27
|
+
zoomIn: string;
|
|
28
|
+
zoomFitWidth: string;
|
|
29
|
+
zoomValue: string;
|
|
18
30
|
};
|
|
19
31
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
20
32
|
interface LocaleNamespaceMap {
|