@deepseek-ai/libreoffice-kit 0.0.1-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/LICENSE +373 -0
- package/NOTICE +26 -0
- package/README.md +81 -0
- package/README.zh.md +81 -0
- package/lib/cli.js +1929 -0
- package/lib/index.js +1791 -0
- package/lib/types/cli.d.ts +3 -0
- package/lib/types/document.d.ts +15 -0
- package/lib/types/engine-rendering.d.ts +15 -0
- package/lib/types/engine.d.ts +67 -0
- package/lib/types/errors.d.ts +21 -0
- package/lib/types/font-full.d.ts +13 -0
- package/lib/types/font-loader.d.ts +38 -0
- package/lib/types/fonts.d.ts +142 -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 +94 -0
- package/lib/types/native-font-names.d.ts +3 -0
- package/lib/types/native-image-renderer.d.ts +19 -0
- package/lib/types/native.d.ts +36 -0
- package/lib/types/office-fonts.d.ts +6 -0
- package/lib/types/ooxml.d.ts +17 -0
- package/lib/types/operations.d.ts +41 -0
- package/lib/types/options.d.ts +30 -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/wasm.d.ts +103 -0
- package/lib/types/worker.d.ts +19 -0
- package/lib/worker.js +1724 -0
- package/package.json +51 -0
|
@@ -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,103 @@
|
|
|
1
|
+
import type { FontFace } from './fonts.ts';
|
|
2
|
+
import type { FontResolutionCacheEntry } from './font-loader.ts';
|
|
3
|
+
import type { DocumentFontMetadata } from './ooxml.ts';
|
|
4
|
+
import type { ResolvedOptions } from './options.ts';
|
|
5
|
+
import type { ConversionSpec } from './operations.ts';
|
|
6
|
+
import type { WasmEngine } from './engine.ts';
|
|
7
|
+
/** MEMFS operations the conversion uses inside the Emscripten module. */
|
|
8
|
+
interface EmscriptenFileSystem {
|
|
9
|
+
/**
|
|
10
|
+
* @param path - Absolute MEMFS path.
|
|
11
|
+
*/
|
|
12
|
+
mkdirTree(path: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* @param path - Absolute MEMFS path.
|
|
15
|
+
* @param data - Complete file contents.
|
|
16
|
+
*/
|
|
17
|
+
writeFile(path: string, data: Uint8Array): void;
|
|
18
|
+
/**
|
|
19
|
+
* @param path - Absolute MEMFS path.
|
|
20
|
+
* @returns whether the path exists.
|
|
21
|
+
*/
|
|
22
|
+
analyzePath(path: string): {
|
|
23
|
+
exists: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @param path - Absolute MEMFS path.
|
|
27
|
+
* @returns the stat record the conversion inspects.
|
|
28
|
+
*/
|
|
29
|
+
stat(path: string): {
|
|
30
|
+
mode: number;
|
|
31
|
+
size: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @param mode - Stat mode flags.
|
|
35
|
+
* @returns whether the mode flags describe a regular file.
|
|
36
|
+
*/
|
|
37
|
+
isFile(mode: number): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @param path - Absolute MEMFS path.
|
|
40
|
+
* @returns the complete file contents.
|
|
41
|
+
*/
|
|
42
|
+
readFile(path: string): Uint8Array;
|
|
43
|
+
}
|
|
44
|
+
/** The Emscripten module surface the conversion drives. */
|
|
45
|
+
export interface EmscriptenModule {
|
|
46
|
+
readonly HEAPU32: Uint32Array;
|
|
47
|
+
readonly FS: EmscriptenFileSystem;
|
|
48
|
+
readonly ENV: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* @param name - Exported C function name.
|
|
51
|
+
* @param returnType - Emscripten return type, or null for void.
|
|
52
|
+
* @param argTypes - Emscripten argument types.
|
|
53
|
+
* @param args - Call arguments.
|
|
54
|
+
* @returns the exported function's numeric result.
|
|
55
|
+
*/
|
|
56
|
+
ccall(name: string, returnType: string | null, argTypes: string[], args: unknown[]): number;
|
|
57
|
+
/**
|
|
58
|
+
* @param pointer - Pointer returned by the module.
|
|
59
|
+
* @returns the NUL-terminated UTF-8 string at the pointer.
|
|
60
|
+
*/
|
|
61
|
+
UTF8ToString(pointer: number): string;
|
|
62
|
+
readonly PThread: {
|
|
63
|
+
/** Stop every pthread the module started. */
|
|
64
|
+
terminateAllThreads(): void;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** One conversion request executed inside the Node worker. */
|
|
68
|
+
export interface WasmConversionRequest {
|
|
69
|
+
readonly engine: WasmEngine;
|
|
70
|
+
readonly bytes: Uint8Array;
|
|
71
|
+
readonly extension: string;
|
|
72
|
+
readonly operation?: Pick<ConversionSpec, 'format' | 'recalculate' | 'sheet'>;
|
|
73
|
+
readonly options: ResolvedOptions;
|
|
74
|
+
readonly document: DocumentFontMetadata;
|
|
75
|
+
readonly faces: readonly FontFace[];
|
|
76
|
+
readonly fontCache?: readonly FontResolutionCacheEntry[];
|
|
77
|
+
readonly onFontCache?: (entries: FontResolutionCacheEntry[]) => void;
|
|
78
|
+
}
|
|
79
|
+
/** Owned PDF bytes and declared families the installed catalog could not provide. */
|
|
80
|
+
export interface WasmConversionResult {
|
|
81
|
+
readonly output: Uint8Array;
|
|
82
|
+
readonly missingFonts: string[];
|
|
83
|
+
}
|
|
84
|
+
export declare function engineError(module: EmscriptenModule, office: number): Error;
|
|
85
|
+
/**
|
|
86
|
+
* Convert bounded source bytes; return owned PDF bytes only after engine teardown.
|
|
87
|
+
* @param request - Engine installation, source bytes, limits, and font metadata.
|
|
88
|
+
* @returns the generated PDF bytes and the declared families the catalog could not provide.
|
|
89
|
+
*/
|
|
90
|
+
export interface WasmSession {
|
|
91
|
+
readonly module: EmscriptenModule;
|
|
92
|
+
readonly office: number;
|
|
93
|
+
readonly document: number;
|
|
94
|
+
readonly pdf: boolean;
|
|
95
|
+
readonly missingFonts: string[];
|
|
96
|
+
idle(): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/** A single module loader and owned session lifecycle for export and direct raster operations. */
|
|
99
|
+
export declare function withWasmSession<T>(request: Omit<WasmConversionRequest, 'operation'>, use: (session: WasmSession) => Promise<T> | T): Promise<T>;
|
|
100
|
+
/** Convert bounded source bytes; return owned bytes only after engine teardown. */
|
|
101
|
+
export declare function convertWithWasm(request: WasmConversionRequest): Promise<WasmConversionResult>;
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FontResolutionCacheEntry } from './font-loader.ts';
|
|
2
|
+
import type { ImageRenderSpec } from './image-operations.ts';
|
|
3
|
+
import type { ConversionSpec } from './operations.ts';
|
|
4
|
+
import type { Engine } from './engine.ts';
|
|
5
|
+
import type { FontFace } from './fonts.ts';
|
|
6
|
+
import type { ResolvedOptions } from './options.ts';
|
|
7
|
+
/** Worker input: inspected paths, validated limits, the resolved engine, and cached faces. */
|
|
8
|
+
export interface WorkerRequest {
|
|
9
|
+
readonly inputPath: string;
|
|
10
|
+
readonly extension: string;
|
|
11
|
+
readonly operation: ConversionSpec | ImageRenderSpec;
|
|
12
|
+
readonly options: ResolvedOptions;
|
|
13
|
+
readonly engine: Engine;
|
|
14
|
+
readonly scratch: string;
|
|
15
|
+
/** Faces the previous conversion indexed; absent until the worker reports them. */
|
|
16
|
+
readonly fontFaces?: FontFace[] | undefined;
|
|
17
|
+
readonly fontCache?: FontResolutionCacheEntry[] | undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=worker.d.ts.map
|