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

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 (40) hide show
  1. package/README.md +2 -2
  2. package/README.zh.md +1 -1
  3. package/assets/font-subset.json +2 -2
  4. package/lib/browser/assets.json +2 -2
  5. package/lib/browser/index.js +333 -162
  6. package/lib/browser/types/connection.d.ts +28 -6
  7. package/lib/browser/types/font-channel.d.ts +16 -1
  8. package/lib/browser/types/index.d.ts +3 -2
  9. package/lib/browser/types/office-engine.d.ts +10 -2
  10. package/lib/browser/types/office-types.d.ts +60 -1
  11. package/lib/browser/types/office.d.ts +18 -3
  12. package/lib/browser/types/preparation.d.ts +13 -0
  13. package/lib/browser/types/protocol.d.ts +33 -10
  14. package/lib/browser/types/types.d.ts +31 -8
  15. package/lib/browser/worker.js +360 -106
  16. package/lib/browser-assets.js +1 -1
  17. package/lib/cli.js +2 -2
  18. package/lib/font-source.js +19 -1
  19. package/lib/font-worker.js +126 -29
  20. package/lib/index.js +2 -2
  21. package/lib/types/engine.d.ts +1 -1
  22. package/lib/types/font-source-types.d.ts +11 -0
  23. package/lib/types/font-subsets.d.ts +5 -1
  24. package/lib/types/fonts.d.ts +1 -0
  25. package/lib/types/office-fonts.d.ts +6 -0
  26. package/lib/worker.js +6 -5
  27. package/package.json +2 -2
  28. package/sources/browser/packages/browser/package.json +1 -1
  29. package/sources/browser/packages/browser/src/connection.ts +105 -34
  30. package/sources/browser/packages/browser/src/font-channel.ts +69 -9
  31. package/sources/browser/packages/browser/src/index.ts +3 -2
  32. package/sources/browser/packages/browser/src/office-engine.ts +80 -6
  33. package/sources/browser/packages/browser/src/office-types.ts +52 -1
  34. package/sources/browser/packages/browser/src/office.ts +118 -52
  35. package/sources/browser/packages/browser/src/preparation.ts +41 -0
  36. package/sources/browser/packages/browser/src/protocol.ts +19 -5
  37. package/sources/browser/packages/browser/src/types.ts +26 -2
  38. package/sources/browser/packages/browser/src/worker.ts +138 -53
  39. package/sources/browser/scripts/build-browser.mjs +6 -2
  40. package/sources/font-subset/scripts/verify-artifacts.mjs +1 -1
@@ -1,20 +1,42 @@
1
- import type { OwnerRequest, WorkerMessage } from './protocol.ts';
2
- import type { BrowserDocumentOptions } from './types.ts';
3
- import type { OfficeDocumentEvent, OfficeDocumentOptions } from './office-types.ts';
1
+ import type { OwnerRequest, WorkerDocumentOptions, WorkerMessage } from './protocol.ts';
2
+ import type { BrowserDocumentOptions, BrowserRuntimeOptions } from './types.ts';
3
+ import type { OfficeDocumentEvent } from './office-types.ts';
4
+ /** One engine Worker that owns a LibreOffice instance and opens one document at a time. */
5
+ export interface BrowserWorker {
6
+ /** Load a document, replacing any document this Worker still holds. */
7
+ openDocument(options: WorkerDocumentOptions & Pick<BrowserDocumentOptions, 'resolveFonts' | 'onMissingFonts'>, signal?: AbortSignal): Promise<Extract<WorkerMessage, {
8
+ type: 'opened';
9
+ }>>;
10
+ /** Release the open document; the engine and its pthreads stay initialized. */
11
+ closeDocument(): Promise<void>;
12
+ /** Send one typed request owned by the open document. */
13
+ request(message: OwnerRequest, operation?: AbortSignal, transfer?: Transferable[]): Promise<WorkerMessage>;
14
+ /** Close the document and terminate the Worker. */
15
+ dispose(): Promise<void>;
16
+ }
4
17
  /**
5
- * Load original Office bytes in a dedicated Worker with no intermediate PDF.
18
+ * Start one LibreOffice Worker without loading a document.
19
+ * @param options - Engine resources, limits and asynchronous Host font provider.
20
+ * @param signal - Engine lifetime; abort closes its Worker and all pending work.
21
+ * @param onEvent - Reading notifications, including fatal Worker failures.
22
+ * @returns Document loading, Worker requests and joined disposal.
23
+ */
24
+ export declare function openBrowserWorker(options: BrowserRuntimeOptions, signal?: AbortSignal, onEvent?: (event: OfficeDocumentEvent) => void): Promise<BrowserWorker>;
25
+ /**
26
+ * Load original PDF bytes in a dedicated Worker without Draw import.
6
27
  * @param options - Resources, limits, source bytes and asynchronous Host font provider.
7
28
  * @param signal - Document lifetime; abort closes its Worker and all pending work.
29
+ * @param onEvent - Reading notifications, including fatal Worker failures.
8
30
  * @returns Initial geometry, ordered Worker requests and joined disposal.
9
31
  */
10
- export declare function openBrowserConnection(options: BrowserDocumentOptions | OfficeDocumentOptions, signal?: AbortSignal, office?: boolean, onEvent?: (event: OfficeDocumentEvent) => void): Promise<{
32
+ export declare function openBrowserConnection(options: BrowserDocumentOptions, signal?: AbortSignal, onEvent?: (event: OfficeDocumentEvent) => void): Promise<{
11
33
  opened: {
12
34
  readonly type: "opened";
13
35
  readonly id: number;
14
36
  readonly pages: readonly import("./types.ts").BrowserPage[];
15
37
  readonly office?: import("./office-types.ts").OfficeDocumentState;
16
38
  };
17
- request(message: OwnerRequest, operation?: AbortSignal): Promise<WorkerMessage>;
39
+ request: (message: OwnerRequest, operation?: AbortSignal, transfer?: Transferable[]) => Promise<WorkerMessage>;
18
40
  dispose: () => Promise<void>;
19
41
  }>;
20
42
  //# sourceMappingURL=connection.d.ts.map
@@ -16,6 +16,21 @@ export interface EngineFontFace {
16
16
  readonly path: string;
17
17
  readonly family: string;
18
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;
19
34
  /** The synchronous reader installs immutable font assets before returning their MEMFS paths and aliases. */
20
- 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): (request: BrowserFontRequest) => EngineFontFace[];
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[];
21
36
  //# sourceMappingURL=font-channel.d.ts.map
@@ -1,8 +1,9 @@
1
1
  import type { BrowserDocument, BrowserDocumentOptions } from './types.ts';
2
2
  export { BrowserRenderError } from './types.ts';
3
- export { openOfficeDocument } from './office.ts';
3
+ export { openOfficeDocument, openOfficeRuntime } from './office.ts';
4
+ export { prepareOfficeBrowser } from './preparation.ts';
4
5
  export type * from './office-types.ts';
5
- export type { BrowserDocument, BrowserDocumentOptions, BrowserEngineAssets, BrowserFontRequest, BrowserFontResult, BrowserPage, BrowserRenderErrorCode, BrowserTile, BrowserTileRequest } from './types.ts';
6
+ export type { BrowserDocument, BrowserDocumentOptions, BrowserEngineAssets, BrowserFontIdentity, BrowserFontRequest, BrowserFontResult, BrowserPage, BrowserRenderErrorCode, BrowserResolvedFont, BrowserRuntimeOptions, BrowserTile, BrowserTileRequest, PreparedBrowserEngine } from './types.ts';
6
7
  /**
7
8
  * Open a read-only document; each call owns an independent Worker.
8
9
  * @param options - Source bytes, version-matched resources and Host fonts.
@@ -1,7 +1,7 @@
1
1
  import type { BrowserTile } from './types.ts';
2
2
  import type { EmscriptenModule } from './engine-types.ts';
3
3
  import type { OfficeOperation } from './protocol.ts';
4
- import type { OfficeDocumentEvent, OfficeDocumentFormat, OfficeDocumentState, OfficeDocumentTileRequest, OfficeDocumentLayoutResult } from './office-types.ts';
4
+ import type { OfficeDocumentEvent, OfficeDocumentFormat, OfficeDocumentState, OfficeDocumentTileRequest, OfficeDocumentLayoutResult, OfficeReadingState } from './office-types.ts';
5
5
  /** One read-only document, driven exclusively by its Worker's messages and timer. */
6
6
  export declare class OfficeEngine {
7
7
  private readonly module;
@@ -14,7 +14,8 @@ export declare class OfficeEngine {
14
14
  private geometryDirty;
15
15
  private stopped;
16
16
  private layoutWidth;
17
- private viewport;
17
+ private viewportKey;
18
+ private viewportState;
18
19
  private captureView;
19
20
  private readingView;
20
21
  private commandResult;
@@ -42,6 +43,13 @@ export declare class OfficeEngine {
42
43
  private configure;
43
44
  /** Internal whitelist commands only; no arbitrary command crosses the public API. */
44
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>;
45
53
  /** Direct tiles preserve the active view, navigation state and selection. */
46
54
  render(request: OfficeDocumentTileRequest): BrowserTile;
47
55
  }
@@ -72,6 +72,53 @@ export interface OfficeDocumentTileRequest extends OfficeDocumentRectangle {
72
72
  readonly part: number;
73
73
  readonly scale: number;
74
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
+ }
75
122
  /** A null rectangle invalidates an entire part; negative part means every part. */
76
123
  export type OfficeDocumentEvent = {
77
124
  readonly type: 'state';
@@ -86,7 +133,7 @@ export type OfficeDocumentEvent = {
86
133
  readonly code: BrowserRenderErrorCode;
87
134
  readonly message: string;
88
135
  };
89
- /** Retain this session while hidden; dispose only when the document is closed. */
136
+ /** One open document of a runtime; closing it frees the parsed model without destroying the engine. */
90
137
  export interface OfficeDocument {
91
138
  readonly state: OfficeDocumentState;
92
139
  subscribe(listener: (event: OfficeDocumentEvent) => void): () => void;
@@ -102,6 +149,18 @@ export interface OfficeDocument {
102
149
  setLayout(request: OfficeDocumentLayoutRequest): Promise<OfficeDocumentLayoutResult>;
103
150
  /** Only the current part can be painted; queued requests for a former part reject with stale-part without changing selection. */
104
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. */
105
164
  dispose(): Promise<void>;
106
165
  }
107
166
  //# sourceMappingURL=office-types.d.ts.map
@@ -1,4 +1,19 @@
1
- import type { OfficeDocument, OfficeDocumentOptions } from './office-types.ts';
2
- /** Open one read-only Office model; source bytes remain owned by the caller. */
3
- export declare function openOfficeDocument(options: OfficeDocumentOptions, signal?: AbortSignal): Promise<OfficeDocument>;
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>;
4
19
  //# sourceMappingURL=office.d.ts.map
@@ -0,0 +1,13 @@
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,6 +1,6 @@
1
1
  /** Private messages exchanged by the document owner and its single engine Worker. */
2
- import type { BrowserDocumentOptions, BrowserFontRequest, BrowserPage, BrowserRenderErrorCode, BrowserTile, BrowserTileRequest } from './types.ts';
3
- import type { OfficeDocumentEvent, OfficeDocumentNavigation, OfficeDocumentOptions, OfficeDocumentState, OfficeDocumentPointer, OfficeDocumentLayoutRequest, OfficeDocumentLayoutResult, OfficeDocumentTileRequest, OfficeDocumentRectangle } from './office-types.ts';
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
4
  export declare const FONT_CHUNK_BYTES: number;
5
5
  export declare const FONT_HEADER_BYTES = 8;
6
6
  export declare const enum FontState {
@@ -11,7 +11,15 @@ export declare const enum FontState {
11
11
  Error = 4,
12
12
  Cancelled = 5
13
13
  }
14
- export type WorkerOptions = Omit<BrowserDocumentOptions | OfficeDocumentOptions, 'resolveFonts' | 'onMissingFonts'>;
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
+ }
15
23
  export type OfficeOperation = {
16
24
  readonly type: 'pointer';
17
25
  readonly event: OfficeDocumentPointer;
@@ -37,11 +45,20 @@ export type OfficeOperation = {
37
45
  readonly request: OfficeDocumentLayoutRequest;
38
46
  };
39
47
  export type OwnerMessage = {
40
- readonly type: 'open';
48
+ readonly type: 'start';
41
49
  readonly id: number;
42
50
  readonly options: WorkerOptions;
43
51
  readonly channel: SharedArrayBuffer;
44
- readonly office?: boolean;
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;
45
62
  } | {
46
63
  readonly type: 'tile';
47
64
  readonly id: number;
@@ -61,10 +78,20 @@ export type OwnerMessage = {
61
78
  type WithoutId<T> = T extends unknown ? Omit<T, 'id'> : never;
62
79
  export type OwnerRequest = WithoutId<OwnerMessage>;
63
80
  export type WorkerMessage = {
81
+ readonly type: 'started';
82
+ readonly id: number;
83
+ } | {
64
84
  readonly type: 'opened';
65
85
  readonly id: number;
66
86
  readonly pages: readonly BrowserPage[];
67
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;
68
95
  } | {
69
96
  readonly type: 'tile';
70
97
  readonly id: number;
@@ -97,11 +124,7 @@ export type WorkerMessage = {
97
124
  readonly families: readonly string[];
98
125
  };
99
126
  /** Immutable bytes already installed in this document's MEMFS. */
100
- export interface FontIdentity {
101
- readonly id: string;
102
- readonly bytes: number;
103
- readonly format?: 'ttf' | 'otf' | 'ttc';
104
- }
127
+ export type FontIdentity = BrowserFontIdentity;
105
128
  export interface FontHeader {
106
129
  readonly fonts: readonly (FontIdentity & {
107
130
  readonly family: string;
@@ -8,6 +8,11 @@ export interface BrowserEngineAssets {
8
8
  readonly metadataUrl: string;
9
9
  readonly programDirectory: string;
10
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
+ }
11
16
  /** VCL attributes passed unchanged to the Host's font matcher. */
12
17
  export interface BrowserFontRequest {
13
18
  readonly mode?: 'full';
@@ -20,15 +25,28 @@ export interface BrowserFontRequest {
20
25
  readonly language: string;
21
26
  readonly codePoints: readonly number[];
22
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
+ });
23
47
  /** Immutable per-face font subsets; equal ids and aliases must identify equal bytes. */
24
48
  export interface BrowserFontResult {
25
- readonly fonts: readonly {
26
- readonly id: string;
27
- readonly data: Uint8Array;
28
- readonly family: string;
29
- readonly alias: string;
30
- readonly format?: 'ttf' | 'otf' | 'ttc';
31
- }[];
49
+ readonly fonts: readonly BrowserResolvedFont[];
32
50
  readonly missingFamily?: string;
33
51
  /** Missing scalars reported by the Host, independently of a substituted family. */
34
52
  readonly unresolvedCodePoints?: readonly number[];
@@ -58,6 +76,8 @@ export interface BrowserDocumentOptions {
58
76
  readonly data: Uint8Array;
59
77
  readonly extension: 'pdf';
60
78
  readonly assets: BrowserEngineAssets;
79
+ /** Optional compiled WASM code created by prepareOfficeBrowser for these assets. */
80
+ readonly preparedEngine?: PreparedBrowserEngine;
61
81
  /** Maximum time for each load, render, font request, or teardown operation. */
62
82
  readonly timeoutMs: number;
63
83
  /** Maximum ZIP entries inspected before LibreOffice loads OOXML. */
@@ -69,10 +89,12 @@ export interface BrowserDocumentOptions {
69
89
  /** The same ordered substitution groups used by the Host font matcher. */
70
90
  readonly fontFallbacks: readonly (readonly string[])[];
71
91
  /** Match fonts without blocking the browser's main thread. */
72
- readonly resolveFonts: (request: BrowserFontRequest, signal: AbortSignal) => Promise<BrowserFontResult>;
92
+ readonly resolveFonts: (request: BrowserFontRequest, known: readonly BrowserFontIdentity[], signal: AbortSignal) => Promise<BrowserFontResult>;
73
93
  /** Called with unavailable declared OOXML families; binary DOC/PPT have no font diagnostics. */
74
94
  readonly onMissingFonts?: (families: readonly string[]) => void;
75
95
  }
96
+ /** Engine resources and limits one Worker holds for every document it opens. */
97
+ export type BrowserRuntimeOptions = Omit<BrowserDocumentOptions, 'data' | 'extension' | 'resolveFonts' | 'onMissingFonts'>;
76
98
  /** One Worker-owned, read-only Office document. */
77
99
  export interface BrowserDocument {
78
100
  /** Visible pages; Writer omits zero-area automatic section parity placeholders. */
@@ -89,4 +111,5 @@ export declare class BrowserRenderError extends Error {
89
111
  readonly code: BrowserRenderErrorCode;
90
112
  constructor(code: BrowserRenderErrorCode, message: string);
91
113
  }
114
+ export {};
92
115
  //# sourceMappingURL=types.d.ts.map