@deepseek-ai/libreoffice-kit 0.0.2-rc9 → 0.0.3

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.
Files changed (86) hide show
  1. package/NOTICE +0 -240
  2. package/README.md +53 -43
  3. package/README.zh.md +58 -35
  4. package/lib/cli.js +725 -132
  5. package/lib/index.js +757 -133
  6. package/lib/types/engine.d.ts +5 -5
  7. package/lib/types/font-loader.d.ts +18 -16
  8. package/lib/types/fonts.d.ts +38 -21
  9. package/lib/types/image-operations.d.ts +1 -1
  10. package/lib/types/index.d.ts +13 -7
  11. package/lib/types/native-image-renderer.d.ts +19 -0
  12. package/lib/types/native.d.ts +1 -1
  13. package/lib/types/options.d.ts +3 -1
  14. package/lib/types/wasm.d.ts +4 -1
  15. package/lib/types/worker.d.ts +2 -0
  16. package/lib/worker.js +420 -942
  17. package/package.json +13 -55
  18. package/assets/font-subset.json +0 -70
  19. package/assets/font-subset.wasm +0 -0
  20. package/lib/browser/assets.json +0 -10
  21. package/lib/browser/index.js +0 -626
  22. package/lib/browser/types/connection.d.ts +0 -42
  23. package/lib/browser/types/engine-rendering.d.ts +0 -3
  24. package/lib/browser/types/engine-types.d.ts +0 -17
  25. package/lib/browser/types/font-channel.d.ts +0 -36
  26. package/lib/browser/types/index.d.ts +0 -14
  27. package/lib/browser/types/office-engine.d.ts +0 -56
  28. package/lib/browser/types/office-types.d.ts +0 -166
  29. package/lib/browser/types/office.d.ts +0 -19
  30. package/lib/browser/types/preparation.d.ts +0 -13
  31. package/lib/browser/types/protocol.d.ts +0 -137
  32. package/lib/browser/types/rendering.d.ts +0 -4
  33. package/lib/browser/types/types.d.ts +0 -115
  34. package/lib/browser/types/worker.d.ts +0 -2
  35. package/lib/browser/worker.js +0 -3796
  36. package/lib/browser-assets.js +0 -119
  37. package/lib/document.js +0 -178
  38. package/lib/engine-rendering.js +0 -120
  39. package/lib/font-config.js +0 -46
  40. package/lib/font-source.js +0 -395
  41. package/lib/font-worker.js +0 -1481
  42. package/lib/rendering.js +0 -99
  43. package/lib/sheet-geometry.js +0 -111
  44. package/lib/types/browser-assets.d.ts +0 -15
  45. package/lib/types/default-fonts.d.ts +0 -3
  46. package/lib/types/font-config.d.ts +0 -24
  47. package/lib/types/font-preferences-data.d.ts +0 -16
  48. package/lib/types/font-preferences.d.ts +0 -29
  49. package/lib/types/font-request.d.ts +0 -12
  50. package/lib/types/font-source-types.d.ts +0 -95
  51. package/lib/types/font-source.d.ts +0 -10
  52. package/lib/types/font-subsets.d.ts +0 -39
  53. package/lib/types/font-worker.d.ts +0 -2
  54. package/lib/types/harfbuzz-subset.d.ts +0 -11
  55. package/lib/types/unicode-scripts.d.ts +0 -18
  56. package/licenses/font-subset/harfbuzz-COPYING +0 -42
  57. package/licenses/font-subset/harfbuzzjs-LICENSE +0 -19
  58. package/licenses/javascript/fflate-LICENSE +0 -21
  59. package/licenses/javascript/saxes-LICENSE +0 -64
  60. package/licenses/javascript/xmlchars-LICENSE +0 -18
  61. package/sources/browser/packages/browser/package.json +0 -22
  62. package/sources/browser/packages/browser/src/connection.ts +0 -237
  63. package/sources/browser/packages/browser/src/engine-rendering.ts +0 -2
  64. package/sources/browser/packages/browser/src/engine-types.ts +0 -14
  65. package/sources/browser/packages/browser/src/font-channel.ts +0 -169
  66. package/sources/browser/packages/browser/src/index.ts +0 -40
  67. package/sources/browser/packages/browser/src/office-engine.ts +0 -397
  68. package/sources/browser/packages/browser/src/office-types.ts +0 -128
  69. package/sources/browser/packages/browser/src/office.ts +0 -128
  70. package/sources/browser/packages/browser/src/preparation.ts +0 -41
  71. package/sources/browser/packages/browser/src/protocol.ts +0 -55
  72. package/sources/browser/packages/browser/src/rendering.ts +0 -3
  73. package/sources/browser/packages/browser/src/types.ts +0 -118
  74. package/sources/browser/packages/browser/src/worker.ts +0 -260
  75. package/sources/browser/packages/browser/tsconfig.json +0 -5
  76. package/sources/browser/packages/browser/tsdown.config.ts +0 -7
  77. package/sources/browser/scripts/build-browser.mjs +0 -86
  78. package/sources/font-subset/engine/font-subset/README.md +0 -23
  79. package/sources/font-subset/engine/font-subset/README.zh.md +0 -23
  80. package/sources/font-subset/engine/font-subset/source.json +0 -16
  81. package/sources/font-subset/harfbuzzjs/config-override-subset.h +0 -7
  82. package/sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols +0 -34
  83. package/sources/font-subset/scripts/build-font-subset.mjs +0 -64
  84. package/sources/font-subset/scripts/pack-utils.mjs +0 -69
  85. package/sources/font-subset/scripts/platform-matrix.mjs +0 -100
  86. package/sources/font-subset/scripts/verify-artifacts.mjs +0 -260
@@ -1,36 +0,0 @@
1
- import { FontState } from './protocol.ts';
2
- import type { FontIdentity } from './protocol.ts';
3
- import type { BrowserFontRequest, BrowserFontResult } from './types.ts';
4
- /** Views shared by the owner and engine; only the engine uses Atomics.wait. */
5
- export declare function fontViews(channel: SharedArrayBuffer): {
6
- control: Int32Array;
7
- bytes: Uint8Array;
8
- };
9
- /** Only uninstalled content crosses the channel; each family retains its own alias. */
10
- export declare function fontFrames(result: BrowserFontResult, known?: readonly FontIdentity[]): Generator<{
11
- state: FontState;
12
- bytes: Uint8Array;
13
- }>;
14
- /** One MEMFS font face registered under a document-local family alias. */
15
- export interface EngineFontFace {
16
- readonly path: string;
17
- readonly family: string;
18
- }
19
- /** Fonts and internal aliases retained for the lifetime of one engine Worker. */
20
- export interface EngineFontCache {
21
- readonly installed: Map<string, {
22
- face: EngineFontFace;
23
- bytes: number;
24
- format: FontIdentity['format'];
25
- }>;
26
- readonly aliases: Map<string, {
27
- id: string;
28
- family: string;
29
- }>;
30
- loadedBytes: number;
31
- }
32
- /** @returns Empty runtime-owned font state shared by successive documents. */
33
- export declare function createEngineFontCache(): EngineFontCache;
34
- /** The synchronous reader installs immutable font assets before returning their MEMFS paths and aliases. */
35
- export declare function createFontReader(channel: SharedArrayBuffer, timeoutMs: number, maxLoadedFontBytes: number, declaredFamilies: ReadonlyMap<string, string>, request: (request: BrowserFontRequest, known: readonly FontIdentity[]) => void, next: () => void, install: (path: string, bytes: Uint8Array) => void, missing: (families: readonly string[]) => void, documentCodePoints?: readonly number[], cache?: EngineFontCache): (request: BrowserFontRequest) => EngineFontFace[];
36
- //# sourceMappingURL=font-channel.d.ts.map
@@ -1,14 +0,0 @@
1
- import type { BrowserDocument, BrowserDocumentOptions } from './types.ts';
2
- export { BrowserRenderError } from './types.ts';
3
- export { openOfficeDocument, openOfficeRuntime } from './office.ts';
4
- export { prepareOfficeBrowser } from './preparation.ts';
5
- export type * from './office-types.ts';
6
- export type { BrowserDocument, BrowserDocumentOptions, BrowserEngineAssets, BrowserFontIdentity, BrowserFontRequest, BrowserFontResult, BrowserPage, BrowserRenderErrorCode, BrowserResolvedFont, BrowserRuntimeOptions, BrowserTile, BrowserTileRequest, PreparedBrowserEngine } from './types.ts';
7
- /**
8
- * Open a read-only document; each call owns an independent Worker.
9
- * @param options - Source bytes, version-matched resources and Host fonts.
10
- * @param signal - Document lifetime; abort awaits engine teardown.
11
- * @returns Immutable geometry, serialized tile rendering and disposal.
12
- */
13
- export declare function openDocument(options: BrowserDocumentOptions, signal?: AbortSignal): Promise<BrowserDocument>;
14
- //# sourceMappingURL=index.d.ts.map
@@ -1,56 +0,0 @@
1
- import type { BrowserTile } from './types.ts';
2
- import type { EmscriptenModule } from './engine-types.ts';
3
- import type { OfficeOperation } from './protocol.ts';
4
- import type { OfficeDocumentEvent, OfficeDocumentFormat, OfficeDocumentState, OfficeDocumentTileRequest, OfficeDocumentLayoutResult, OfficeReadingState } from './office-types.ts';
5
- /** One read-only document, driven exclusively by its Worker's messages and timer. */
6
- export declare class OfficeEngine {
7
- private readonly module;
8
- private readonly document;
9
- private readonly emit;
10
- private readonly failure;
11
- state: OfficeDocumentState;
12
- private timer;
13
- private readonly callbacks;
14
- private geometryDirty;
15
- private stopped;
16
- private layoutWidth;
17
- private viewportKey;
18
- private viewportState;
19
- private captureView;
20
- private readingView;
21
- private commandResult;
22
- constructor(module: EmscriptenModule, document: number, format: OfficeDocumentFormat, emit: (event: OfficeDocumentEvent) => void, failure: (error: unknown) => void);
23
- private call;
24
- private text;
25
- private invoke;
26
- private requireOpen;
27
- /** Collect callbacks without reentering LibreOffice inside its callback. */
28
- callback(type: number, payload: string): void;
29
- /** Enforce the native read-only view before accepting any input. */
30
- start(): Promise<void>;
31
- private schedule;
32
- /** Stop event processing before destroying the document. */
33
- stop(): void;
34
- /** Return the part whose cached coordinates changed, or -1 when part identities changed. */
35
- private refreshGeometry;
36
- private pump;
37
- private flush;
38
- /** The Worker permits only these typed reading operations, including at runtime. */
39
- operation(operation: OfficeOperation): Promise<{
40
- text?: string;
41
- layout?: OfficeDocumentLayoutResult;
42
- }>;
43
- private configure;
44
- /** Internal whitelist commands only; no arbitrary command crosses the public API. */
45
- private command;
46
- /** Read the part and selection the next open of these bytes must restore. */
47
- capture(): OfficeReadingState;
48
- /**
49
- * Apply a reading position captured from the same bytes.
50
- * @param state - Part and selection captured before this document closed.
51
- */
52
- restore(state: OfficeReadingState): Promise<void>;
53
- /** Direct tiles preserve the active view, navigation state and selection. */
54
- render(request: OfficeDocumentTileRequest): BrowserTile;
55
- }
56
- //# sourceMappingURL=office-engine.d.ts.map
@@ -1,166 +0,0 @@
1
- /** Retained Office reading sessions; this API never exposes document mutation. */
2
- import type { BrowserDocumentOptions, BrowserPage, BrowserRenderErrorCode, BrowserTile } from './types.ts';
3
- /** Office containers supported by the reading engine. */
4
- export type OfficeDocumentFormat = 'doc' | 'docx' | 'xls' | 'xlsx' | 'ppt' | 'pptx';
5
- /** Source bytes, engine resources and Host fonts; all sessions are read-only. */
6
- export type OfficeDocumentOptions = Omit<BrowserDocumentOptions, 'extension'> & {
7
- readonly extension: OfficeDocumentFormat;
8
- };
9
- /** Document coordinates in CSS pixels at 96 DPI, independent of zoom. */
10
- export interface OfficeDocumentRectangle extends BrowserPage {
11
- readonly x: number;
12
- readonly y: number;
13
- }
14
- /** One Writer document, Calc worksheet or Impress slide. */
15
- export interface OfficeDocumentPart extends BrowserPage {
16
- readonly name: string;
17
- }
18
- /** Writer layout; other document types always remain paginated. */
19
- export type OfficeDocumentLayout = 'paginated' | 'continuous';
20
- /** A point in the previous layout, normally the upper visible line of body text. */
21
- export interface OfficeDocumentAnchor {
22
- readonly x: number;
23
- readonly y: number;
24
- }
25
- /** Continuous width is the available content width in document CSS pixels. */
26
- export type OfficeDocumentLayoutRequest = {
27
- readonly mode: 'paginated';
28
- readonly anchor?: OfficeDocumentAnchor;
29
- } | {
30
- readonly mode: 'continuous';
31
- readonly width: number;
32
- readonly anchor?: OfficeDocumentAnchor;
33
- };
34
- /** An optional body-text rectangle in the new layout for restoring reading position. */
35
- export interface OfficeDocumentLayoutResult {
36
- readonly changed: boolean;
37
- readonly anchor?: OfficeDocumentRectangle;
38
- }
39
- /** Geometry and selection; cursor is a navigation/cell rectangle, never an editing caret. */
40
- export interface OfficeDocumentState {
41
- readonly documentType: 'text' | 'spreadsheet' | 'presentation';
42
- readonly renderGeneration: number;
43
- readonly layoutGeneration: number;
44
- readonly layout: OfficeDocumentLayout;
45
- readonly part: number;
46
- readonly parts: readonly OfficeDocumentPart[];
47
- /** Writer page rectangles in paginated mode; one continuous rectangle otherwise. */
48
- readonly pages: readonly OfficeDocumentRectangle[];
49
- readonly cursor: OfficeDocumentRectangle | null;
50
- readonly selection: readonly OfficeDocumentRectangle[];
51
- readonly graphicSelection: OfficeDocumentRectangle | null;
52
- readonly cellAddress: string;
53
- readonly cellFormula: string;
54
- }
55
- /** Primary-button selection; modifiers use LOK Shift (0x1000) / Control (0x2000). */
56
- export interface OfficeDocumentPointer {
57
- readonly action: 'down' | 'up' | 'move';
58
- readonly x: number;
59
- readonly y: number;
60
- readonly buttons: number;
61
- readonly modifiers: number;
62
- readonly clicks: number;
63
- }
64
- /** Only navigation keys are accepted; no arbitrary character or key injection. */
65
- export interface OfficeDocumentNavigation {
66
- readonly key: 'left' | 'right' | 'up' | 'down' | 'home' | 'end' | 'pageUp' | 'pageDown';
67
- readonly extend?: boolean;
68
- readonly word?: boolean;
69
- }
70
- /** One region of the current part. Pixel density does not change document layout. */
71
- export interface OfficeDocumentTileRequest extends OfficeDocumentRectangle {
72
- readonly part: number;
73
- readonly scale: number;
74
- }
75
- /** Writer selection as document-model positions; one file always resolves to the same nodes. */
76
- export interface OfficeTextSelection {
77
- /** Document node holding the selection point. */
78
- readonly pointNode: number;
79
- /** Character offset inside the point node's text. */
80
- readonly pointOffset: number;
81
- /** Document node holding the selection mark. */
82
- readonly markNode: number;
83
- /** Character offset inside the mark node's text. */
84
- readonly markOffset: number;
85
- }
86
- /** Reading position of one document; capturable before it closes and restorable when its bytes reopen. */
87
- export interface OfficeReadingState {
88
- readonly version: 1;
89
- readonly documentType: OfficeDocumentState['documentType'];
90
- /** Writer page, Calc worksheet, or Impress slide. */
91
- readonly part: number;
92
- /** Writer layout parameters; non-Writer documents remain paginated. */
93
- readonly layout: {
94
- readonly mode: 'paginated';
95
- } | {
96
- readonly mode: 'continuous';
97
- readonly width: number;
98
- };
99
- /** Last document-coordinate viewport and raster scale, when one was configured. */
100
- readonly viewport: {
101
- readonly rectangle: OfficeDocumentRectangle;
102
- readonly scale: number;
103
- } | null;
104
- /** Writer text selection; null when the reader holds no text selection. */
105
- readonly text: OfficeTextSelection | null;
106
- /** Calc selected range in A1 notation; null when the reader holds no cell range. */
107
- readonly cell: string | null;
108
- /** Selected drawing objects as ordinal paths inside the current slide. */
109
- readonly object: readonly (readonly number[])[] | null;
110
- }
111
- /** Source bytes and reading position for one document of a shared runtime. */
112
- export interface OfficeDocumentOpenOptions {
113
- readonly data: Uint8Array;
114
- readonly extension: OfficeDocumentFormat;
115
- /** Match fonts for this document without blocking the browser's main thread. */
116
- readonly resolveFonts: BrowserDocumentOptions['resolveFonts'];
117
- /** Called with unavailable declared families for this document. */
118
- readonly onMissingFonts?: BrowserDocumentOptions['onMissingFonts'];
119
- /** Reading position captured from an earlier open of the same bytes. */
120
- readonly restore?: OfficeReadingState;
121
- }
122
- /** A null rectangle invalidates an entire part; negative part means every part. */
123
- export type OfficeDocumentEvent = {
124
- readonly type: 'state';
125
- readonly state: OfficeDocumentState;
126
- } | {
127
- readonly type: 'invalidate';
128
- readonly part: number;
129
- readonly rectangle: OfficeDocumentRectangle | null;
130
- readonly generation: number;
131
- } | {
132
- readonly type: 'error';
133
- readonly code: BrowserRenderErrorCode;
134
- readonly message: string;
135
- };
136
- /** One open document of a runtime; closing it frees the parsed model without destroying the engine. */
137
- export interface OfficeDocument {
138
- readonly state: OfficeDocumentState;
139
- subscribe(listener: (event: OfficeDocumentEvent) => void): () => void;
140
- pointer(event: OfficeDocumentPointer): Promise<void>;
141
- navigate(event: OfficeDocumentNavigation): Promise<void>;
142
- selectAll(): Promise<void>;
143
- copy(): Promise<string>;
144
- /** Select a bounded A1 cell or range on the current worksheet. */
145
- goToCell(address: string): Promise<void>;
146
- setPart(part: number): Promise<void>;
147
- setViewport(rectangle: OfficeDocumentRectangle, scale: number): Promise<void>;
148
- /** Coalesces pending widths; superseded callers observe the newest applied layout. */
149
- setLayout(request: OfficeDocumentLayoutRequest): Promise<OfficeDocumentLayoutResult>;
150
- /** Only the current part can be painted; queued requests for a former part reject with stale-part without changing selection. */
151
- renderTile(request: OfficeDocumentTileRequest, signal?: AbortSignal): Promise<BrowserTile>;
152
- /** Read the position the next open of the same bytes must restore. */
153
- captureReadingState(): Promise<OfficeReadingState>;
154
- /** Close this document and release its model; the owning runtime keeps its engine. */
155
- close(): Promise<void>;
156
- /** Close this document and destroy the owning runtime. */
157
- dispose(): Promise<void>;
158
- }
159
- /** One engine Worker that opens documents one at a time without reinitializing LibreOffice. */
160
- export interface OfficeRuntime {
161
- /** Open a document, closing the document this runtime currently holds. */
162
- open(options: OfficeDocumentOpenOptions, signal?: AbortSignal): Promise<OfficeDocument>;
163
- /** Close the open document and release the Worker, its WASM instance and its pthreads. */
164
- dispose(): Promise<void>;
165
- }
166
- //# sourceMappingURL=office-types.d.ts.map
@@ -1,19 +0,0 @@
1
- import type { BrowserRuntimeOptions } from './types.ts';
2
- import type { OfficeDocument, OfficeDocumentOpenOptions, OfficeRuntime } from './office-types.ts';
3
- /**
4
- * Start one read-only Office engine that opens documents one at a time.
5
- * @param options - Engine resources and limits shared by every document.
6
- * @param signal - Runtime lifetime; abort closes the Worker and its pthreads.
7
- * @returns Sequential document loading and joined disposal.
8
- */
9
- export declare function openOfficeRuntime(options: BrowserRuntimeOptions, signal?: AbortSignal): Promise<OfficeRuntime>;
10
- /**
11
- * Open one read-only Office document in its own engine; the runtime ends with the document.
12
- * @param options - Source bytes, engine resources and Host fonts.
13
- * @param signal - Document lifetime; abort closes its Worker and pthreads.
14
- * @returns Immutable reading state and disposal.
15
- */
16
- export declare function openOfficeDocument(options: BrowserRuntimeOptions & {
17
- readonly data: Uint8Array;
18
- } & Pick<OfficeDocumentOpenOptions, 'extension' | 'resolveFonts' | 'onMissingFonts'>, signal?: AbortSignal): Promise<OfficeDocument>;
19
- //# sourceMappingURL=office.d.ts.map
@@ -1,13 +0,0 @@
1
- import type { BrowserEngineAssets, PreparedBrowserEngine } from './types.ts';
2
- /**
3
- * Compile the version-matched LibreOffice WASM module for later document Workers.
4
- * @param assets - Browser resources whose WASM URL identifies the compiled module.
5
- * @param signal - Cancels the resource request; compilation may finish before cancellation is observed.
6
- * @returns an opaque, structured-cloneable engine handle that allocates no WASM memory.
7
- */
8
- export declare function prepareOfficeBrowser(assets: BrowserEngineAssets, signal?: AbortSignal): Promise<PreparedBrowserEngine>;
9
- /** Return the compiled module after validating the Worker-bound asset identity. */
10
- export declare function preparedBrowserModule(prepared: PreparedBrowserEngine, assets: BrowserEngineAssets): WebAssembly.Module;
11
- /** Instantiate precompiled code through Emscripten's synchronous override. */
12
- export declare function instantiatePreparedModule(module: WebAssembly.Module, imports: WebAssembly.Imports, receive: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void): WebAssembly.Exports;
13
- //# sourceMappingURL=preparation.d.ts.map
@@ -1,137 +0,0 @@
1
- /** Private messages exchanged by the document owner and its single engine Worker. */
2
- import type { BrowserDocumentOptions, BrowserFontIdentity, BrowserFontRequest, BrowserPage, BrowserRenderErrorCode, BrowserRuntimeOptions, BrowserTile, BrowserTileRequest } from './types.ts';
3
- import type { OfficeDocumentEvent, OfficeDocumentNavigation, OfficeDocumentOptions, OfficeDocumentState, OfficeDocumentPointer, OfficeDocumentLayoutRequest, OfficeDocumentLayoutResult, OfficeDocumentTileRequest, OfficeDocumentRectangle, OfficeReadingState } from './office-types.ts';
4
- export declare const FONT_CHUNK_BYTES: number;
5
- export declare const FONT_HEADER_BYTES = 8;
6
- export declare const enum FontState {
7
- Waiting = 0,
8
- Header = 1,
9
- Bytes = 2,
10
- Done = 3,
11
- Error = 4,
12
- Cancelled = 5
13
- }
14
- /** Engine resources a Worker holds for the lifetime of every document it opens. */
15
- export type WorkerOptions = Omit<BrowserRuntimeOptions, 'resolveFonts' | 'onMissingFonts'>;
16
- /** Source bytes and reading position of one document opened inside a started Worker. */
17
- export interface WorkerDocumentOptions {
18
- readonly data: Uint8Array;
19
- readonly extension: BrowserDocumentOptions['extension'] | OfficeDocumentOptions['extension'];
20
- /** Reading position captured from an earlier open of the same bytes. */
21
- readonly restore?: OfficeReadingState;
22
- }
23
- export type OfficeOperation = {
24
- readonly type: 'pointer';
25
- readonly event: OfficeDocumentPointer;
26
- } | {
27
- readonly type: 'navigate';
28
- readonly event: OfficeDocumentNavigation;
29
- } | {
30
- readonly type: 'select-all';
31
- } | {
32
- readonly type: 'cell';
33
- readonly address: string;
34
- } | {
35
- readonly type: 'copy';
36
- } | {
37
- readonly type: 'part';
38
- readonly part: number;
39
- } | {
40
- readonly type: 'viewport';
41
- readonly rectangle: OfficeDocumentRectangle;
42
- readonly scale: number;
43
- } | {
44
- readonly type: 'layout';
45
- readonly request: OfficeDocumentLayoutRequest;
46
- };
47
- export type OwnerMessage = {
48
- readonly type: 'start';
49
- readonly id: number;
50
- readonly options: WorkerOptions;
51
- readonly channel: SharedArrayBuffer;
52
- } | {
53
- readonly type: 'open';
54
- readonly id: number;
55
- readonly options: WorkerDocumentOptions;
56
- } | {
57
- readonly type: 'close-document';
58
- readonly id: number;
59
- } | {
60
- readonly type: 'reading-state';
61
- readonly id: number;
62
- } | {
63
- readonly type: 'tile';
64
- readonly id: number;
65
- readonly request: BrowserTileRequest;
66
- } | {
67
- readonly type: 'office-tile';
68
- readonly id: number;
69
- readonly request: OfficeDocumentTileRequest;
70
- } | {
71
- readonly type: 'office-operation';
72
- readonly id: number;
73
- readonly operation: OfficeOperation;
74
- } | {
75
- readonly type: 'dispose';
76
- readonly id: number;
77
- };
78
- type WithoutId<T> = T extends unknown ? Omit<T, 'id'> : never;
79
- export type OwnerRequest = WithoutId<OwnerMessage>;
80
- export type WorkerMessage = {
81
- readonly type: 'started';
82
- readonly id: number;
83
- } | {
84
- readonly type: 'opened';
85
- readonly id: number;
86
- readonly pages: readonly BrowserPage[];
87
- readonly office?: OfficeDocumentState;
88
- } | {
89
- readonly type: 'closed-document';
90
- readonly id: number;
91
- } | {
92
- readonly type: 'reading-state';
93
- readonly id: number;
94
- readonly state: OfficeReadingState;
95
- } | {
96
- readonly type: 'tile';
97
- readonly id: number;
98
- readonly tile: BrowserTile;
99
- } | {
100
- readonly type: 'office-result';
101
- readonly id: number;
102
- readonly text?: string;
103
- readonly layout?: OfficeDocumentLayoutResult;
104
- } | {
105
- readonly type: 'office-event';
106
- readonly event: OfficeDocumentEvent;
107
- } | {
108
- readonly type: 'disposed';
109
- readonly id: number;
110
- } | {
111
- readonly type: 'error';
112
- readonly id: number;
113
- readonly code: BrowserRenderErrorCode;
114
- readonly message: string;
115
- readonly fatal: boolean;
116
- } | {
117
- readonly type: 'font';
118
- readonly request: BrowserFontRequest;
119
- readonly known: readonly FontIdentity[];
120
- } | {
121
- readonly type: 'font-next';
122
- } | {
123
- readonly type: 'missing-fonts';
124
- readonly families: readonly string[];
125
- };
126
- /** Immutable bytes already installed in this document's MEMFS. */
127
- export type FontIdentity = BrowserFontIdentity;
128
- export interface FontHeader {
129
- readonly fonts: readonly (FontIdentity & {
130
- readonly family: string;
131
- readonly alias: string;
132
- readonly reference?: true;
133
- })[];
134
- readonly missingFamily?: string;
135
- }
136
- export {};
137
- //# sourceMappingURL=protocol.d.ts.map
@@ -1,4 +0,0 @@
1
- /** Geometry and RGBA conversion shared by every WASM consumer. */
2
- export { writerPages, tileDimensions, rgbaPixels, TWIPS_PER_CSS_PIXEL } from '@deepseek-ai/libreoffice-kit/internal/rendering';
3
- export type { EnginePage } from '@deepseek-ai/libreoffice-kit/internal/rendering';
4
- //# sourceMappingURL=rendering.d.ts.map
@@ -1,115 +0,0 @@
1
- /** Browser-facing document rendering and host font interfaces. */
2
- /** Independently served, version-matched engine resources. */
3
- export interface BrowserEngineAssets {
4
- readonly workerUrl: string;
5
- readonly loaderUrl: string;
6
- readonly wasmUrl: string;
7
- readonly dataUrl: string;
8
- readonly metadataUrl: string;
9
- readonly programDirectory: string;
10
- }
11
- declare const preparedBrowserEngine: unique symbol;
12
- /** Compiled engine code bound to one WASM resource identity. */
13
- export interface PreparedBrowserEngine {
14
- readonly [preparedBrowserEngine]: true;
15
- }
16
- /** VCL attributes passed unchanged to the Host's font matcher. */
17
- export interface BrowserFontRequest {
18
- readonly mode?: 'full';
19
- readonly family: string;
20
- readonly style: string;
21
- readonly weight: number;
22
- readonly italic: number;
23
- readonly width: number;
24
- readonly pitch: number;
25
- readonly language: string;
26
- readonly codePoints: readonly number[];
27
- }
28
- /** Immutable font content already installed in one document Worker. */
29
- export interface BrowserFontIdentity {
30
- readonly id: string;
31
- readonly bytes: number;
32
- readonly format?: 'ttf' | 'otf' | 'ttc';
33
- }
34
- /** One new font body or a metadata-only reference to content already installed in the Worker. */
35
- export type BrowserResolvedFont = {
36
- readonly id: string;
37
- readonly family: string;
38
- readonly alias: string;
39
- readonly format?: 'ttf' | 'otf' | 'ttc';
40
- } & ({
41
- readonly data: Uint8Array;
42
- readonly bytes?: never;
43
- } | {
44
- readonly data?: never;
45
- readonly bytes: number;
46
- });
47
- /** Immutable per-face font subsets; equal ids and aliases must identify equal bytes. */
48
- export interface BrowserFontResult {
49
- readonly fonts: readonly BrowserResolvedFont[];
50
- readonly missingFamily?: string;
51
- /** Missing scalars reported by the Host, independently of a substituted family. */
52
- readonly unresolvedCodePoints?: readonly number[];
53
- }
54
- /** All sizes are CSS pixels at 96 pixels per inch. */
55
- export interface BrowserPage {
56
- readonly width: number;
57
- readonly height: number;
58
- }
59
- /** Page-relative rectangle, rasterized at the requested pixel scale. */
60
- export interface BrowserTileRequest {
61
- readonly pageIndex: number;
62
- readonly x: number;
63
- readonly y: number;
64
- readonly width: number;
65
- readonly height: number;
66
- readonly scale: number;
67
- }
68
- /** Owned, non-premultiplied RGBA pixels accepted by ImageData. */
69
- export interface BrowserTile {
70
- readonly width: number;
71
- readonly height: number;
72
- readonly rgba: Uint8ClampedArray;
73
- }
74
- /** Caller-owned source bytes are copied before Worker transfer. */
75
- export interface BrowserDocumentOptions {
76
- readonly data: Uint8Array;
77
- readonly extension: 'pdf';
78
- readonly assets: BrowserEngineAssets;
79
- /** Optional compiled WASM code created by prepareOfficeBrowser for these assets. */
80
- readonly preparedEngine?: PreparedBrowserEngine;
81
- /** Maximum time for each load, render, font request, or teardown operation. */
82
- readonly timeoutMs: number;
83
- /** Maximum ZIP entries inspected before LibreOffice loads OOXML. */
84
- readonly maxArchiveEntries: number;
85
- /** Maximum total declared uncompressed OOXML bytes. */
86
- readonly maxUncompressedBytes: number;
87
- /** Total distinct font bytes retained in this document's MEMFS. */
88
- readonly maxLoadedFontBytes: number;
89
- /** The same ordered substitution groups used by the Host font matcher. */
90
- readonly fontFallbacks: readonly (readonly string[])[];
91
- /** Match fonts without blocking the browser's main thread. */
92
- readonly resolveFonts: (request: BrowserFontRequest, known: readonly BrowserFontIdentity[], signal: AbortSignal) => Promise<BrowserFontResult>;
93
- /** Called with unavailable declared OOXML families; binary DOC/PPT have no font diagnostics. */
94
- readonly onMissingFonts?: (families: readonly string[]) => void;
95
- }
96
- /** Engine resources and limits one Worker holds for every document it opens. */
97
- export type BrowserRuntimeOptions = Omit<BrowserDocumentOptions, 'data' | 'extension' | 'resolveFonts' | 'onMissingFonts'>;
98
- /** One Worker-owned, read-only Office document. */
99
- export interface BrowserDocument {
100
- /** Visible pages; Writer omits zero-area automatic section parity placeholders. */
101
- readonly pages: readonly BrowserPage[];
102
- /** Render a page region; cancellation discards that region without closing the document. */
103
- renderTile(request: BrowserTileRequest, signal?: AbortSignal): Promise<BrowserTile>;
104
- /** Await document, office and pthread disposal; repeated calls share completion. */
105
- dispose(): Promise<void>;
106
- }
107
- /** Stable failures callers may map to their own localized product copy. */
108
- export type BrowserRenderErrorCode = 'unavailable' | 'invalid-document' | 'timeout' | 'font-limit' | 'font-unavailable' | 'disposed' | 'render-failed' | 'stale-part';
109
- /** A rendering failure with a stable machine-readable category. */
110
- export declare class BrowserRenderError extends Error {
111
- readonly code: BrowserRenderErrorCode;
112
- constructor(code: BrowserRenderErrorCode, message: string);
113
- }
114
- export {};
115
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=worker.d.ts.map