@deepseek-ai/dsh-client-ui-sidebar-documentpreview 0.1.6-alpha.2 → 0.1.7-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/README.i18n.yaml +2 -2
- package/README.md +48 -20
- package/README.zh.md +48 -20
- package/lib/client.excel.js +133796 -0
- package/lib/client.js +3785 -791
- package/lib/client.pdf.js +37 -15
- package/lib/index.js +13 -6
- package/lib/types/client/TextPreview.d.ts +2 -2
- package/lib/types/client/document/contract.d.ts +44 -0
- package/lib/types/client/document/resource-group.d.ts +23 -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 +11 -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 +21 -0
- package/lib/types/client/excel/xlsx.d.ts +9 -0
- package/lib/types/client/face.d.ts +8 -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 +2 -2
- 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 +5 -7
- package/lib/types/client/office/OfficeBody.d.ts +4 -10
- package/lib/types/client/office/OfficeFontAction.d.ts +13 -0
- package/lib/types/client/office/face.d.ts +31 -0
- package/lib/types/client/office/locales.d.ts +2 -6
- package/lib/types/client/pdf/locales.d.ts +12 -0
- package/lib/types/client/pdf/pdf.d.ts +6 -1
- package/lib/types/client/pdf/store.d.ts +5 -2
- package/lib/types/client/rpc.d.ts +3 -11
- package/lib/types/client/store.d.ts +5 -0
- 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 +10 -0
- package/package.json +36 -24
- package/lib/types/client/code/languages.d.ts +0 -9
- package/lib/types/client/icons.d.ts +0 -14
package/lib/client.pdf.js
CHANGED
|
@@ -32376,7 +32376,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32376
32376
|
}
|
|
32377
32377
|
//#endregion
|
|
32378
32378
|
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-sidebar-documentpreview/src/client/pdf/PdfBody.module.css.mjs
|
|
32379
|
-
const css = ".E0GbtG_body{box-sizing:border-box;background:var(--dsw-alias-bg-document-preview);width:100%;min-height:0;font-family:var(--dsw-font,sans-serif);white-space:normal;flex-direction:column;display:flex;overflow
|
|
32379
|
+
const css = ".E0GbtG_body{box-sizing:border-box;background:var(--dsw-alias-bg-document-preview);width:100%;min-width:100%;min-height:0;font-family:var(--dsw-font,sans-serif);white-space:normal;flex-direction:column;display:flex;overflow:visible}.E0GbtG_page{box-sizing:border-box;width:100%;min-width:0;overflow-x:visible}.E0GbtG_placeholder{aspect-ratio:3/4;background:var(--dsw-alias-bg-skeleton);width:100%}.E0GbtG_canvas{width:100%;max-width:none;height:auto;margin-inline:auto;display:block}.E0GbtG_surface{max-width:none;box-shadow:var(--dsw-elevation-prominent);margin-inline:auto;position:relative}.E0GbtG_surface[hidden]{display:none}.E0GbtG_text{position:absolute;inset:0;overflow:clip}.E0GbtG_text .textLayer{text-align:initial;letter-spacing:normal;word-spacing:normal;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;caret-color:canvastext;z-index:0;--text-scale-factor:calc(var(--total-scale-factor) * var(--min-font-size));--min-font-size-inv:calc(1 / var(--min-font-size));line-height:1;position:absolute;inset:0;overflow:clip}.E0GbtG_text .textLayer[data-main-rotation=\"90\"]{transform:rotate(90deg)translateY(-100%)}.E0GbtG_text .textLayer[data-main-rotation=\"180\"]{transform:rotate(180deg)translate(-100%,-100%)}.E0GbtG_text .textLayer[data-main-rotation=\"270\"]{transform:rotate(270deg)translate(-100%)}.E0GbtG_text :is(span,br){color:#0000;white-space:pre;cursor:text;transform-origin:0 0;user-select:text;position:absolute}.E0GbtG_text .textLayer>:not(.markedContent),.E0GbtG_text .markedContent span:not(.markedContent){z-index:1;--font-height:0;--scale-x:1;--rotate:0deg;font-size:calc(var(--text-scale-factor) * var(--font-height));transform:rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv))}.E0GbtG_text .markedContent{display:contents}.E0GbtG_text ::selection{background:var(--dsw-alias-interactive-bg-hover-accent);color:#0000}.E0GbtG_text br::selection{background:0 0}.E0GbtG_text .textLayer .endOfContent{z-index:0;cursor:default;user-select:none;display:block;position:absolute;inset:100% 0 0}.E0GbtG_text .selecting .endOfContent{top:0}.E0GbtG_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;padding:10px;font-size:13px;line-height:1.5;display:flex}.E0GbtG_body .E0GbtG_status{color:var(--dsw-alias-label-document-preview)}.E0GbtG_opening{box-sizing:border-box;justify-content:center;width:100%;min-height:100%}";
|
|
32380
32380
|
const tagId = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview/PdfBody.module.css";
|
|
32381
32381
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
32382
32382
|
const tag = document.createElement("style");
|
|
@@ -32388,19 +32388,18 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32388
32388
|
var PdfBody_module_css_default = {
|
|
32389
32389
|
"body": "E0GbtG_body",
|
|
32390
32390
|
"canvas": "E0GbtG_canvas",
|
|
32391
|
-
"loadingIcon": "E0GbtG_loadingIcon",
|
|
32392
32391
|
"opening": "E0GbtG_opening",
|
|
32393
32392
|
"page": "E0GbtG_page",
|
|
32394
32393
|
"placeholder": "E0GbtG_placeholder",
|
|
32395
32394
|
"status": "E0GbtG_status",
|
|
32396
32395
|
"surface": "E0GbtG_surface",
|
|
32397
|
-
"text": "E0GbtG_text"
|
|
32398
|
-
"turn": "E0GbtG_turn"
|
|
32396
|
+
"text": "E0GbtG_text"
|
|
32399
32397
|
};
|
|
32400
32398
|
//#endregion
|
|
32401
32399
|
//#region lib/types/client/pdf/pdf.js
|
|
32402
32400
|
/** PDF page presentation; binary content and tab information come from the document owner. */
|
|
32403
32401
|
const DEFAULT_PDF_VIEW = { page: 1 };
|
|
32402
|
+
const FIT_WIDTH = { kind: "fit-width" };
|
|
32404
32403
|
/**
|
|
32405
32404
|
* Present a PDF with tab-local viewing preferences and component-owned rendering resources.
|
|
32406
32405
|
* @param props - complete bytes and framework-owned tab/store/locale seats.
|
|
@@ -32412,10 +32411,23 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32412
32411
|
const data = props.content.kind === "bytes" ? props.content.data : void 0;
|
|
32413
32412
|
const [load, setLoad] = (0, react.useState)();
|
|
32414
32413
|
const [attempt, setAttempt] = (0, react.useState)(0);
|
|
32415
|
-
const
|
|
32414
|
+
const [pageWidth, setPageWidth] = (0, react.useState)();
|
|
32415
|
+
const { retainTab, actions, t, ZoomViewport, zoomSurfaceClass } = props;
|
|
32416
|
+
const preference = view.zoom ?? FIT_WIDTH;
|
|
32417
|
+
const labels = {
|
|
32418
|
+
controls: t("zoomControls"),
|
|
32419
|
+
menu: t("zoomMenu"),
|
|
32420
|
+
out: t("zoomOut"),
|
|
32421
|
+
into: t("zoomIn"),
|
|
32422
|
+
fitWidth: t("zoomFitWidth"),
|
|
32423
|
+
value: (percent) => t("zoomValue", { percent })
|
|
32424
|
+
};
|
|
32416
32425
|
const pageVisible = (0, react.useCallback)((page) => {
|
|
32417
32426
|
actions.page(tab.id, page);
|
|
32418
32427
|
}, [actions, tab.id]);
|
|
32428
|
+
const setPreference = (0, react.useCallback)((value) => {
|
|
32429
|
+
actions.zoom(tab.id, value);
|
|
32430
|
+
}, [actions, tab.id]);
|
|
32419
32431
|
(0, react.useEffect)(() => {
|
|
32420
32432
|
retainTab(tab.id, tab.signal);
|
|
32421
32433
|
}, [
|
|
@@ -32467,11 +32479,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32467
32479
|
role: "status",
|
|
32468
32480
|
"aria-label": t("loading"),
|
|
32469
32481
|
"data-document-loading": true,
|
|
32470
|
-
children: (0, react_jsx_runtime.jsx)("
|
|
32471
|
-
className: PdfBody_module_css_default.loadingIcon,
|
|
32472
|
-
"aria-hidden": "true",
|
|
32473
|
-
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconLoadingOutline16, {})
|
|
32474
|
-
})
|
|
32482
|
+
children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "ongoing" })
|
|
32475
32483
|
});
|
|
32476
32484
|
if (load.kind === "failed") return (0, react_jsx_runtime.jsxs)("div", {
|
|
32477
32485
|
className: PdfBody_module_css_default.status,
|
|
@@ -32484,7 +32492,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32484
32492
|
children: t("retry")
|
|
32485
32493
|
})]
|
|
32486
32494
|
});
|
|
32487
|
-
|
|
32495
|
+
const pages = (0, react_jsx_runtime.jsx)("section", {
|
|
32488
32496
|
className: PdfBody_module_css_default.body,
|
|
32489
32497
|
"data-pdf-preview": true,
|
|
32490
32498
|
children: Array.from({ length: load.document.numPages }, (_, index) => (0, react_jsx_runtime.jsx)(PdfPage, {
|
|
@@ -32493,11 +32501,22 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32493
32501
|
requested: index === 0 || view.page === index + 1,
|
|
32494
32502
|
onVisible: pageVisible,
|
|
32495
32503
|
signal: tab.signal,
|
|
32504
|
+
onWidth: index === 0 ? setPageWidth : void 0,
|
|
32505
|
+
zoomSurfaceClass,
|
|
32496
32506
|
t
|
|
32497
32507
|
}, index))
|
|
32498
32508
|
});
|
|
32509
|
+
return (0, react_jsx_runtime.jsx)(ZoomViewport, {
|
|
32510
|
+
preference,
|
|
32511
|
+
intrinsicWidth: pageWidth,
|
|
32512
|
+
labels,
|
|
32513
|
+
signal: tab.signal,
|
|
32514
|
+
scrollportRef: props.scrollportRef,
|
|
32515
|
+
onPreference: setPreference,
|
|
32516
|
+
children: pages
|
|
32517
|
+
});
|
|
32499
32518
|
}
|
|
32500
|
-
function PdfPage({ document, page, requested: initiallyRequested, onVisible, signal, t }) {
|
|
32519
|
+
function PdfPage({ document, page, requested: initiallyRequested, onVisible, signal, onWidth, zoomSurfaceClass, t }) {
|
|
32501
32520
|
const host = (0, react.useRef)(null);
|
|
32502
32521
|
const canvas = (0, react.useRef)(null);
|
|
32503
32522
|
const text = (0, react.useRef)(null);
|
|
@@ -32540,6 +32559,7 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32540
32559
|
}).then((size) => {
|
|
32541
32560
|
if (!renderSignal.aborted) {
|
|
32542
32561
|
setWidth(size.width);
|
|
32562
|
+
onWidth?.(size.width);
|
|
32543
32563
|
setState("ready");
|
|
32544
32564
|
}
|
|
32545
32565
|
}, (error) => {
|
|
@@ -32554,7 +32574,8 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32554
32574
|
page,
|
|
32555
32575
|
requested,
|
|
32556
32576
|
signal,
|
|
32557
|
-
attempt
|
|
32577
|
+
attempt,
|
|
32578
|
+
onWidth
|
|
32558
32579
|
]);
|
|
32559
32580
|
return (0, react_jsx_runtime.jsxs)("div", {
|
|
32560
32581
|
ref: host,
|
|
@@ -32578,8 +32599,9 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
|
32578
32599
|
})]
|
|
32579
32600
|
}),
|
|
32580
32601
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
32581
|
-
className: PdfBody_module_css_default.surface
|
|
32582
|
-
|
|
32602
|
+
className: `${PdfBody_module_css_default.surface} ${zoomSurfaceClass}`,
|
|
32603
|
+
"data-document-zoom-surface": true,
|
|
32604
|
+
style: { "--document-zoom-width": `${width ?? 0}px` },
|
|
32583
32605
|
hidden: state !== "ready" || failure !== void 0,
|
|
32584
32606
|
children: [(0, react_jsx_runtime.jsx)("canvas", {
|
|
32585
32607
|
ref: canvas,
|
package/lib/index.js
CHANGED
|
@@ -2,12 +2,19 @@ import z from "@deepseek-ai/schemastery";
|
|
|
2
2
|
//#region lib/types/config.js
|
|
3
3
|
/** Cache limits shared by the Host configuration and browser document previews. */
|
|
4
4
|
/** Deployment limits applied before Office preview registration. */
|
|
5
|
-
const Config = z.object({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
});
|
|
11
18
|
//#endregion
|
|
12
19
|
//#region lib/types/index.js
|
|
13
20
|
/**
|
|
@@ -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, prepareRenderer, 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
|
|
@@ -26,11 +26,17 @@ export type DocumentContent = {
|
|
|
26
26
|
readonly revision: number;
|
|
27
27
|
/** Report the displayed source version; stale revisions cannot update the owner. @param version - loaded source version. */
|
|
28
28
|
readonly loaded: (version: string) => void;
|
|
29
|
+
/** End a failed load; a later file change can start another revision. */
|
|
30
|
+
readonly failed: () => void;
|
|
29
31
|
/** Cancel the current load and start a new revision. */
|
|
30
32
|
readonly reload: () => void;
|
|
31
33
|
};
|
|
32
34
|
/** Content and viewing inputs shared by document bodies and nested PDF presentation. */
|
|
33
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;
|
|
34
40
|
/** Original file address, also readable through the standard useResource hook. */
|
|
35
41
|
readonly resourceAddress: string;
|
|
36
42
|
/** Ordinary file content or a renderer-owned loading request; text accumulates until eof. */
|
|
@@ -54,6 +60,44 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
54
60
|
};
|
|
55
61
|
};
|
|
56
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': {
|
|
89
|
+
kind: 'keyed';
|
|
90
|
+
scope: 'session';
|
|
91
|
+
owner: {
|
|
92
|
+
readonly content: DocumentContent;
|
|
93
|
+
};
|
|
94
|
+
hookContext: UseSidebarRightTabInfo;
|
|
95
|
+
inject: {
|
|
96
|
+
hooks: {
|
|
97
|
+
tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
57
101
|
}
|
|
58
102
|
}
|
|
59
103
|
/** Standard input for every document body; entry-local stores and locale props can be intersected with it. */
|
|
@@ -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,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,11 @@
|
|
|
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
|
+
* Keep the mounted workbook sized to its preview pane.
|
|
7
|
+
* @param props - Complete workbook bytes, limits, and locale.
|
|
8
|
+
* @returns An isolated spreadsheet surface with cancellable loading.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ExcelBody({ content, format, limits, t }: LoadedExcelBodyProps): ReactNode;
|
|
11
|
+
//# 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,21 @@
|
|
|
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
|
+
private readonly parts;
|
|
8
|
+
/**
|
|
9
|
+
* Read an archive without modifying the borrowed source buffer.
|
|
10
|
+
* @param bytes - Complete XLSX source bytes.
|
|
11
|
+
* @throws When ZIP entries have ASCII case-equivalent names.
|
|
12
|
+
*/
|
|
13
|
+
constructor(bytes: Uint8Array<ArrayBuffer>);
|
|
14
|
+
/**
|
|
15
|
+
* Omit DrawingML parts before ExcelJS parses them; callers must also ignore worksheet drawing references.
|
|
16
|
+
* @returns Source bytes when no parts were omitted, otherwise an uncompressed temporary ZIP.
|
|
17
|
+
*/
|
|
18
|
+
withoutDrawings(): Uint8Array<ArrayBuffer>;
|
|
19
|
+
private inspectContent;
|
|
20
|
+
}
|
|
21
|
+
//# 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
|
|
@@ -74,8 +79,9 @@ export interface TextInjected {
|
|
|
74
79
|
/**
|
|
75
80
|
* Bind the preview's face to one paged read and one complete-byte read.
|
|
76
81
|
* @param read - the bound `workspaceFiles.read` call.
|
|
77
|
-
* @param readAll -
|
|
82
|
+
* @param readAll - complete-byte workspace Remote read.
|
|
83
|
+
* @param resources - shared metadata sources for the document and its dependencies.
|
|
78
84
|
* @returns the Slot `inject` factory: bound actions in, face out. The slot's session id is unused because the address carries its own.
|
|
79
85
|
*/
|
|
80
|
-
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;
|
|
81
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
|