@deepseek-ai/libreoffice-kit 0.0.1 → 0.0.2-rc4
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/NOTICE +2 -0
- package/README.md +43 -47
- package/README.zh.md +35 -50
- package/assets/font-subset.json +70 -0
- package/assets/font-subset.wasm +0 -0
- package/lib/browser/assets.json +10 -0
- package/lib/browser/index.js +435 -0
- package/lib/browser/types/connection.d.ts +20 -0
- package/lib/browser/types/editor-engine.d.ts +50 -0
- package/lib/browser/types/editor-types.d.ts +141 -0
- package/lib/browser/types/editor.d.ts +9 -0
- package/lib/browser/types/engine-rendering.d.ts +3 -0
- package/lib/browser/types/engine-types.d.ts +17 -0
- package/lib/browser/types/font-channel.d.ts +20 -0
- package/lib/browser/types/index.d.ts +13 -0
- package/lib/browser/types/protocol.d.ts +117 -0
- package/lib/browser/types/rendering.d.ts +4 -0
- package/lib/browser/types/types.d.ts +90 -0
- package/lib/browser/types/worker.d.ts +2 -0
- package/lib/browser/worker.js +3711 -0
- package/lib/browser-assets.js +119 -0
- package/lib/cli.js +1303 -0
- package/lib/document.js +178 -0
- package/lib/engine-rendering.js +120 -0
- package/lib/font-config.js +46 -0
- package/lib/font-source.js +344 -0
- package/lib/font-worker.js +712 -0
- package/lib/index.js +319 -109
- package/lib/rendering.js +99 -0
- package/lib/sheet-geometry.js +111 -0
- package/lib/types/browser-assets.d.ts +15 -0
- package/lib/types/cli.d.ts +3 -0
- package/lib/types/document.d.ts +1 -1
- package/lib/types/engine-rendering.d.ts +15 -0
- package/lib/types/engine.d.ts +5 -5
- package/lib/types/font-config.d.ts +24 -0
- package/lib/types/font-full.d.ts +13 -0
- package/lib/types/font-loader.d.ts +1 -7
- package/lib/types/font-request.d.ts +12 -0
- package/lib/types/font-source-types.d.ts +82 -0
- package/lib/types/font-source.d.ts +10 -0
- package/lib/types/font-subsets.d.ts +35 -0
- package/lib/types/font-worker.d.ts +2 -0
- package/lib/types/fonts.d.ts +9 -29
- package/lib/types/harfbuzz-subset.d.ts +11 -0
- package/lib/types/image-operations.d.ts +58 -0
- package/lib/types/image-renderer.d.ts +6 -0
- package/lib/types/index.d.ts +25 -2
- package/lib/types/native.d.ts +4 -2
- package/lib/types/operations.d.ts +41 -0
- package/lib/types/png.d.ts +2 -0
- package/lib/types/profile.d.ts +8 -0
- package/lib/types/rendering.d.ts +41 -0
- package/lib/types/runtime.d.ts +14 -0
- package/lib/types/sheet-geometry.d.ts +38 -0
- package/lib/types/unicode-scripts.d.ts +18 -0
- package/lib/types/wasm.d.ts +76 -1
- package/lib/types/worker.d.ts +3 -0
- package/lib/worker.js +1012 -237
- package/licenses/font-subset/harfbuzz-COPYING +42 -0
- package/licenses/font-subset/harfbuzzjs-LICENSE +19 -0
- package/licenses/javascript/fflate-LICENSE +21 -0
- package/licenses/javascript/saxes-LICENSE +64 -0
- package/licenses/javascript/xmlchars-LICENSE +18 -0
- package/package.json +59 -12
- package/sources/browser/packages/browser/package.json +22 -0
- package/sources/browser/packages/browser/src/connection.ts +168 -0
- package/sources/browser/packages/browser/src/editor-engine.ts +382 -0
- package/sources/browser/packages/browser/src/editor-types.ts +106 -0
- package/sources/browser/packages/browser/src/editor.ts +55 -0
- package/sources/browser/packages/browser/src/engine-rendering.ts +2 -0
- package/sources/browser/packages/browser/src/engine-types.ts +14 -0
- package/sources/browser/packages/browser/src/font-channel.ts +99 -0
- package/sources/browser/packages/browser/src/index.ts +39 -0
- package/sources/browser/packages/browser/src/protocol.ts +40 -0
- package/sources/browser/packages/browser/src/rendering.ts +3 -0
- package/sources/browser/packages/browser/src/types.ts +92 -0
- package/sources/browser/packages/browser/src/worker.ts +171 -0
- package/sources/browser/packages/browser/tsconfig.json +5 -0
- package/sources/browser/packages/browser/tsdown.config.ts +7 -0
- package/sources/browser/scripts/build-browser.mjs +74 -0
- package/sources/font-subset/engine/font-subset/README.md +23 -0
- package/sources/font-subset/engine/font-subset/README.zh.md +23 -0
- package/sources/font-subset/engine/font-subset/source.json +16 -0
- package/sources/font-subset/harfbuzzjs/config-override-subset.h +7 -0
- package/sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols +34 -0
- package/sources/font-subset/scripts/build-font-subset.mjs +64 -0
- package/sources/font-subset/scripts/pack-utils.mjs +69 -0
- package/sources/font-subset/scripts/platform-matrix.mjs +100 -0
- package/sources/font-subset/scripts/verify-artifacts.mjs +260 -0
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import type { RenderImagesRequest, RenderImagesResult } from './image-operations.ts';
|
|
2
|
+
export { IMAGE_FORMATS } from './image-operations.ts';
|
|
3
|
+
export type { RenderImagesRequest, RenderImagesResult, RenderedImage } from './image-operations.ts';
|
|
4
|
+
import type { ConversionRequest } from './operations.ts';
|
|
5
|
+
export { CONVERSION_FORMATS } from './operations.ts';
|
|
6
|
+
export type { ConversionRequest } from './operations.ts';
|
|
7
|
+
export { discoverRuntime } from './runtime.ts';
|
|
8
|
+
export type { RuntimeInfo } from './runtime.ts';
|
|
1
9
|
export { ConversionError } from './errors.ts';
|
|
2
10
|
export type { ConversionErrorCode } from './errors.ts';
|
|
3
11
|
export { ENGINE_VERSION } from './engine.ts';
|
|
@@ -7,7 +15,7 @@ export interface ConverterOptions {
|
|
|
7
15
|
timeoutMs?: number;
|
|
8
16
|
/** Maximum source bytes. Default: 64 MiB. */
|
|
9
17
|
maxInputBytes?: number;
|
|
10
|
-
/** Maximum generated
|
|
18
|
+
/** Maximum generated output bytes. Default: 128 MiB. */
|
|
11
19
|
maxOutputBytes?: number;
|
|
12
20
|
/** PDF export image resolution in DPI. Default: 144. */
|
|
13
21
|
maxImageResolution?: number;
|
|
@@ -43,7 +51,7 @@ export interface Converter {
|
|
|
43
51
|
* Convert a private, caller-authorized regular Office file to a fresh exclusive PDF path.
|
|
44
52
|
* The caller owns both directories and must prevent concurrent path changes.
|
|
45
53
|
* Rejects existing output paths; removes a newly created output on failure or cancellation.
|
|
46
|
-
* @param request - Absolute paths. Input
|
|
54
|
+
* @param request - Absolute paths. Input suffixes are listed in CONVERSION_FORMATS.
|
|
47
55
|
* @param signal - Optional cancellation, including while queued.
|
|
48
56
|
* @returns Engine choice and missing declared font families.
|
|
49
57
|
*/
|
|
@@ -51,6 +59,21 @@ export interface Converter {
|
|
|
51
59
|
inputPath: string;
|
|
52
60
|
outputPath: string;
|
|
53
61
|
}, signal?: AbortSignal): Promise<RenderResult>;
|
|
62
|
+
/** Render Office directly to PNG, or PDF through PDFium, in one fresh output directory.
|
|
63
|
+
* Worksheets use sheet/A1 coordinates; page selections are one-based for documents and slides.
|
|
64
|
+
* Failure/cancellation removes the complete batch. The manifest describes one saved input snapshot.
|
|
65
|
+
*/
|
|
66
|
+
renderImages(request: RenderImagesRequest, signal?: AbortSignal): Promise<RenderImagesResult>;
|
|
67
|
+
/** Convert to the output extension; CSV requires a sheet for multi-sheet inputs. */
|
|
68
|
+
convert(request: ConversionRequest, signal?: AbortSignal): Promise<RenderResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Recalculate the entire workbook synchronously and save formulas with refreshed cached results.
|
|
71
|
+
* This does not validate formulas or business data.
|
|
72
|
+
* @param request - XLS, XLSX, or ODS input and a distinct fresh XLSX or ODS output.
|
|
73
|
+
* @param signal - Cancellation, including while queued.
|
|
74
|
+
* @returns Engine choice and missing declared font families.
|
|
75
|
+
*/
|
|
76
|
+
recalculate(request: Omit<ConversionRequest, 'sheet'>, signal?: AbortSignal): Promise<RenderResult>;
|
|
54
77
|
/** Abort queued and active work, await exit and cleanup, and permanently reject further renders. */
|
|
55
78
|
dispose(): Promise<void>;
|
|
56
79
|
}
|
package/lib/types/native.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FontSubstitution } from './font-loader.ts';
|
|
2
|
+
import type { ConversionSpec } from './operations.ts';
|
|
2
3
|
import type { NativeEngine } from './engine.ts';
|
|
3
4
|
import type { ResolvedOptions } from './options.ts';
|
|
4
5
|
/**
|
|
@@ -6,7 +7,7 @@ import type { ResolvedOptions } from './options.ts';
|
|
|
6
7
|
* Installed originals and metric-compatible fonts are resolved before this table by LibreOffice.
|
|
7
8
|
* @param profile - Existing, conversion-owned profile directory.
|
|
8
9
|
* @param substitutions - Missing document families and the selected installed family.
|
|
9
|
-
* @returns Resolves after the exclusive profile file is written; empty choices
|
|
10
|
+
* @returns Resolves after the exclusive profile file is written; empty choices still disable the interactive CSV warning.
|
|
10
11
|
*/
|
|
11
12
|
export declare function prepareNativeFontProfile(profile: string, substitutions: readonly FontSubstitution[]): Promise<void>;
|
|
12
13
|
/**
|
|
@@ -28,7 +29,8 @@ export declare function nativeEnvironment(profile: string, programDirectory: str
|
|
|
28
29
|
* @param fonts - Installed font files the helper may load.
|
|
29
30
|
* @param substitutions - Missing families and their selected installed substitutes.
|
|
30
31
|
* @param signal - Cancellation; it kills the helper and awaits its exit.
|
|
32
|
+
* @param operation - Validated output format, recalculation, and worksheet selection.
|
|
31
33
|
* @throws ConversionError for a reported conversion failure, and the abort reason for cancellation.
|
|
32
34
|
*/
|
|
33
|
-
export declare function runNative(engine: NativeEngine, options: ResolvedOptions, input: string, output: string, profile: string, fonts: readonly string[], substitutions: readonly FontSubstitution[], signal: AbortSignal): Promise<void>;
|
|
35
|
+
export declare function runNative(engine: NativeEngine, options: ResolvedOptions, input: string, output: string, profile: string, fonts: readonly string[], substitutions: readonly FontSubstitution[], signal: AbortSignal, operation: Pick<ConversionSpec, 'format' | 'recalculate' | 'sheet'>): Promise<void>;
|
|
34
36
|
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Conversions supported by the bundled Writer, Calc, and Impress components. */
|
|
2
|
+
export declare const CONVERSION_FORMATS: readonly [{
|
|
3
|
+
readonly inputs: readonly ["doc", "docx", "odt"];
|
|
4
|
+
readonly outputs: readonly ["pdf", "docx", "odt", "txt"];
|
|
5
|
+
}, {
|
|
6
|
+
readonly inputs: readonly ["xls", "xlsx", "ods"];
|
|
7
|
+
readonly outputs: readonly ["pdf", "xlsx", "ods", "csv"];
|
|
8
|
+
}, {
|
|
9
|
+
readonly inputs: readonly ["ppt", "pptx", "odp"];
|
|
10
|
+
readonly outputs: readonly ["pdf", "pptx", "odp"];
|
|
11
|
+
}];
|
|
12
|
+
/** Absolute input and fresh output paths, with an exact worksheet name for CSV export. */
|
|
13
|
+
export interface ConversionRequest {
|
|
14
|
+
readonly inputPath: string;
|
|
15
|
+
readonly outputPath: string;
|
|
16
|
+
/** CSV only; required for a workbook containing multiple sheets. */
|
|
17
|
+
readonly sheet?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Engine operation after extension and parameter validation. */
|
|
20
|
+
export interface ConversionSpec {
|
|
21
|
+
readonly inputPath: string;
|
|
22
|
+
readonly outputPath: string;
|
|
23
|
+
readonly extension: string;
|
|
24
|
+
readonly format: string;
|
|
25
|
+
readonly recalculate: boolean;
|
|
26
|
+
readonly sheet?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate paths and the format matrix before file access or queue admission.
|
|
30
|
+
* @param request - Public conversion parameters.
|
|
31
|
+
* @param operation - PDF compatibility entry, general conversion, or workbook recalculation.
|
|
32
|
+
* @returns The explicit engine operation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveConversion(request: ConversionRequest, operation: 'render' | 'convert' | 'recalculate'): ConversionSpec;
|
|
35
|
+
/**
|
|
36
|
+
* Reject an engine output with an incorrect container signature.
|
|
37
|
+
* @param bytes - Complete bounded output.
|
|
38
|
+
* @param format - Requested output suffix.
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateOutput(bytes: Uint8Array, format: string): void;
|
|
41
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Private headless profile used by both native and WASM conversions. */
|
|
2
|
+
/**
|
|
3
|
+
* CSV selection is checked by the engine wrapper before saving; suppress the interactive warning.
|
|
4
|
+
* @param fontNodes - Escaped VCL font-substitution nodes, or an empty string for WASM.
|
|
5
|
+
* @returns The per-operation registry XML; macro execution is independently disabled at load.
|
|
6
|
+
*/
|
|
7
|
+
export declare function profileXml(fontNodes?: string): string;
|
|
8
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Platform-independent document geometry and raster pixel conversion. */
|
|
2
|
+
import type { Rectangle } from './sheet-geometry.ts';
|
|
3
|
+
export declare const TWIPS_PER_CSS_PIXEL = 15;
|
|
4
|
+
export declare const MAX_TILE_PIXELS: number;
|
|
5
|
+
export interface EnginePage {
|
|
6
|
+
readonly width: number;
|
|
7
|
+
readonly height: number;
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
10
|
+
readonly part: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TileRequest {
|
|
13
|
+
readonly pageIndex: number;
|
|
14
|
+
readonly x: number;
|
|
15
|
+
readonly y: number;
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
readonly scale: number;
|
|
19
|
+
}
|
|
20
|
+
export interface RasterTile {
|
|
21
|
+
readonly width: number;
|
|
22
|
+
readonly height: number;
|
|
23
|
+
readonly rgba: Uint8ClampedArray;
|
|
24
|
+
}
|
|
25
|
+
/** Split a region on its output-pixel grid, bounding the plan before allocating it. */
|
|
26
|
+
export declare function splitRasterRectangle(rectangle: Rectangle, scale: number, limits: {
|
|
27
|
+
readonly maxPixels: number;
|
|
28
|
+
readonly maxDimension: number;
|
|
29
|
+
readonly maxTiles: number;
|
|
30
|
+
}): Rectangle[];
|
|
31
|
+
/** Writer's zero-area parity placeholders have no visible page. Offsets stay in twips. */
|
|
32
|
+
export declare function writerPages(rectangles: string): EnginePage[];
|
|
33
|
+
/** Validate coordinates before allocation or wasm32 integer conversion. */
|
|
34
|
+
export declare function tileDimensions(request: TileRequest, pages: readonly EnginePage[]): {
|
|
35
|
+
page: EnginePage;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
/** Cairo/LO channels are premultiplied; PNG and ImageData require straight RGBA. */
|
|
40
|
+
export declare function rgbaPixels(source: Uint8Array, tileMode: number): Uint8ClampedArray;
|
|
41
|
+
//# sourceMappingURL=rendering.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Paths use the same installed Node API and precompiled engine as createConverter. */
|
|
2
|
+
export interface RuntimeInfo {
|
|
3
|
+
readonly version: string;
|
|
4
|
+
readonly backend: 'native' | 'wasm';
|
|
5
|
+
readonly cliPath: string;
|
|
6
|
+
readonly nodeApiPath: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Inspect installed engine metadata without starting, downloading, or building an engine.
|
|
10
|
+
* @returns Public entry paths, engine version, and selected backend.
|
|
11
|
+
* @throws ConversionError when the installed engine is unavailable or invalid.
|
|
12
|
+
*/
|
|
13
|
+
export declare function discoverRuntime(): Promise<RuntimeInfo>;
|
|
14
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Calc data-area and A1 coordinates shared by saved-file and retained-session capture. */
|
|
2
|
+
export interface CellRange {
|
|
3
|
+
readonly firstColumn: number;
|
|
4
|
+
readonly firstRow: number;
|
|
5
|
+
readonly lastColumn: number;
|
|
6
|
+
readonly lastRow: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Rectangle {
|
|
9
|
+
readonly x: number;
|
|
10
|
+
readonly y: number;
|
|
11
|
+
readonly width: number;
|
|
12
|
+
readonly height: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SheetPartInfo {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly visible: number;
|
|
17
|
+
readonly rtllayout: number;
|
|
18
|
+
readonly lastcolumn: number;
|
|
19
|
+
readonly lastrow: number;
|
|
20
|
+
}
|
|
21
|
+
interface DimensionData {
|
|
22
|
+
readonly sizes: string;
|
|
23
|
+
readonly hidden: string;
|
|
24
|
+
readonly filtered: string;
|
|
25
|
+
}
|
|
26
|
+
export interface SheetGeometry {
|
|
27
|
+
readonly columns: DimensionData;
|
|
28
|
+
readonly rows: DimensionData;
|
|
29
|
+
}
|
|
30
|
+
export declare function rangeName(range: CellRange): string;
|
|
31
|
+
export declare function parseCellRange(value: string): CellRange;
|
|
32
|
+
export declare function sheetPartInfo(value: string): SheetPartInfo;
|
|
33
|
+
/** Formatting-only cells and standalone drawings do not enlarge LibreOffice's data area. */
|
|
34
|
+
export declare function dataArea(info: SheetPartInfo): CellRange;
|
|
35
|
+
/** Logical columns advance from A; LOK itself mirrors RTL sheet painting. No manual x inversion. */
|
|
36
|
+
export declare function sheetRangeRectangle(geometry: SheetGeometry, range: CellRange, scale: number): Rectangle;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=sheet-geometry.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Unicode data and partition generation participate in every subset request identity. */
|
|
2
|
+
export declare const FONT_PARTITION_VERSION = "unicode-17.0.0-data-2.0.7-script-v1";
|
|
3
|
+
/** A shared metadata/punctuation subset used before layout requests any script. */
|
|
4
|
+
export declare const FONT_BASE_SCRIPT = "Common";
|
|
5
|
+
/**
|
|
6
|
+
* Select stable whole-script partitions for a request; shared characters use the base partition.
|
|
7
|
+
* @param points - Unicode scalars requested by layout.
|
|
8
|
+
* @returns deterministic Unicode script names, including Unknown for private-use or unassigned characters.
|
|
9
|
+
*/
|
|
10
|
+
export declare function requestedFontScripts(points: readonly number[]): Promise<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Retain source characters in a script's Script_Extensions, plus Common/Inherited and variation selectors.
|
|
13
|
+
* @param points - Character repertoire of one physical font face.
|
|
14
|
+
* @param script - Name returned by requestedFontScripts.
|
|
15
|
+
* @returns Unicode set for HarfBuzz's layout and composite-glyph closure.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fontScriptCodePoints(points: readonly number[], script: string): Promise<number[]>;
|
|
18
|
+
//# sourceMappingURL=unicode-scripts.d.ts.map
|
package/lib/types/wasm.d.ts
CHANGED
|
@@ -1,25 +1,100 @@
|
|
|
1
1
|
import type { FontFace } from './fonts.ts';
|
|
2
2
|
import type { DocumentFontMetadata } from './ooxml.ts';
|
|
3
3
|
import type { ResolvedOptions } from './options.ts';
|
|
4
|
+
import type { ConversionSpec } from './operations.ts';
|
|
4
5
|
import type { WasmEngine } from './engine.ts';
|
|
6
|
+
/** MEMFS operations the conversion uses inside the Emscripten module. */
|
|
7
|
+
interface EmscriptenFileSystem {
|
|
8
|
+
/**
|
|
9
|
+
* @param path - Absolute MEMFS path.
|
|
10
|
+
*/
|
|
11
|
+
mkdirTree(path: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* @param path - Absolute MEMFS path.
|
|
14
|
+
* @param data - Complete file contents.
|
|
15
|
+
*/
|
|
16
|
+
writeFile(path: string, data: Uint8Array): void;
|
|
17
|
+
/**
|
|
18
|
+
* @param path - Absolute MEMFS path.
|
|
19
|
+
* @returns whether the path exists.
|
|
20
|
+
*/
|
|
21
|
+
analyzePath(path: string): {
|
|
22
|
+
exists: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @param path - Absolute MEMFS path.
|
|
26
|
+
* @returns the stat record the conversion inspects.
|
|
27
|
+
*/
|
|
28
|
+
stat(path: string): {
|
|
29
|
+
mode: number;
|
|
30
|
+
size: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @param mode - Stat mode flags.
|
|
34
|
+
* @returns whether the mode flags describe a regular file.
|
|
35
|
+
*/
|
|
36
|
+
isFile(mode: number): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @param path - Absolute MEMFS path.
|
|
39
|
+
* @returns the complete file contents.
|
|
40
|
+
*/
|
|
41
|
+
readFile(path: string): Uint8Array;
|
|
42
|
+
}
|
|
43
|
+
/** The Emscripten module surface the conversion drives. */
|
|
44
|
+
export interface EmscriptenModule {
|
|
45
|
+
readonly HEAPU32: Uint32Array;
|
|
46
|
+
readonly FS: EmscriptenFileSystem;
|
|
47
|
+
readonly ENV: Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* @param name - Exported C function name.
|
|
50
|
+
* @param returnType - Emscripten return type, or null for void.
|
|
51
|
+
* @param argTypes - Emscripten argument types.
|
|
52
|
+
* @param args - Call arguments.
|
|
53
|
+
* @returns the exported function's numeric result.
|
|
54
|
+
*/
|
|
55
|
+
ccall(name: string, returnType: string | null, argTypes: string[], args: unknown[]): number;
|
|
56
|
+
/**
|
|
57
|
+
* @param pointer - Pointer returned by the module.
|
|
58
|
+
* @returns the NUL-terminated UTF-8 string at the pointer.
|
|
59
|
+
*/
|
|
60
|
+
UTF8ToString(pointer: number): string;
|
|
61
|
+
readonly PThread: {
|
|
62
|
+
/** Stop every pthread the module started. */
|
|
63
|
+
terminateAllThreads(): void;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
5
66
|
/** One conversion request executed inside the Node worker. */
|
|
6
67
|
export interface WasmConversionRequest {
|
|
7
68
|
readonly engine: WasmEngine;
|
|
8
69
|
readonly bytes: Uint8Array;
|
|
9
70
|
readonly extension: string;
|
|
71
|
+
readonly operation: Pick<ConversionSpec, 'format' | 'recalculate' | 'sheet'>;
|
|
10
72
|
readonly options: ResolvedOptions;
|
|
11
73
|
readonly document: DocumentFontMetadata;
|
|
12
74
|
readonly faces: readonly FontFace[];
|
|
13
75
|
}
|
|
14
76
|
/** Owned PDF bytes and declared families the installed catalog could not provide. */
|
|
15
77
|
export interface WasmConversionResult {
|
|
16
|
-
readonly
|
|
78
|
+
readonly output: Uint8Array;
|
|
17
79
|
readonly missingFonts: string[];
|
|
18
80
|
}
|
|
81
|
+
export declare function engineError(module: EmscriptenModule, office: number): Error;
|
|
19
82
|
/**
|
|
20
83
|
* Convert bounded source bytes; return owned PDF bytes only after engine teardown.
|
|
21
84
|
* @param request - Engine installation, source bytes, limits, and font metadata.
|
|
22
85
|
* @returns the generated PDF bytes and the declared families the catalog could not provide.
|
|
23
86
|
*/
|
|
87
|
+
export interface WasmSession {
|
|
88
|
+
readonly module: EmscriptenModule;
|
|
89
|
+
readonly office: number;
|
|
90
|
+
readonly document: number;
|
|
91
|
+
readonly pdf: boolean;
|
|
92
|
+
readonly missingFonts: string[];
|
|
93
|
+
idle(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/** A single module loader and owned session lifecycle for export and direct raster operations. */
|
|
96
|
+
export declare function withWasmSession<T>(request: Omit<WasmConversionRequest, 'operation'>, use: (session: WasmSession) => Promise<T> | T): Promise<T>;
|
|
97
|
+
/** Convert bounded source bytes; return owned bytes only after engine teardown. */
|
|
24
98
|
export declare function convertWithWasm(request: WasmConversionRequest): Promise<WasmConversionResult>;
|
|
99
|
+
export {};
|
|
25
100
|
//# sourceMappingURL=wasm.d.ts.map
|
package/lib/types/worker.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ImageRenderSpec } from './image-operations.ts';
|
|
2
|
+
import type { ConversionSpec } from './operations.ts';
|
|
1
3
|
import type { Engine } from './engine.ts';
|
|
2
4
|
import type { FontFace } from './fonts.ts';
|
|
3
5
|
import type { ResolvedOptions } from './options.ts';
|
|
@@ -5,6 +7,7 @@ import type { ResolvedOptions } from './options.ts';
|
|
|
5
7
|
export interface WorkerRequest {
|
|
6
8
|
readonly inputPath: string;
|
|
7
9
|
readonly extension: string;
|
|
10
|
+
readonly operation: ConversionSpec | ImageRenderSpec;
|
|
8
11
|
readonly options: ResolvedOptions;
|
|
9
12
|
readonly engine: Engine;
|
|
10
13
|
readonly scratch: string;
|