@deepseek-ai/libreoffice-kit 0.0.1 → 0.0.2-rc5

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 (94) hide show
  1. package/NOTICE +240 -0
  2. package/README.md +43 -47
  3. package/README.zh.md +35 -50
  4. package/assets/font-subset.json +70 -0
  5. package/assets/font-subset.wasm +0 -0
  6. package/lib/browser/assets.json +10 -0
  7. package/lib/browser/index.js +442 -0
  8. package/lib/browser/types/connection.d.ts +20 -0
  9. package/lib/browser/types/engine-rendering.d.ts +3 -0
  10. package/lib/browser/types/engine-types.d.ts +17 -0
  11. package/lib/browser/types/font-channel.d.ts +20 -0
  12. package/lib/browser/types/index.d.ts +13 -0
  13. package/lib/browser/types/office-engine.d.ts +46 -0
  14. package/lib/browser/types/office-types.d.ts +107 -0
  15. package/lib/browser/types/office.d.ts +4 -0
  16. package/lib/browser/types/protocol.d.ts +109 -0
  17. package/lib/browser/types/rendering.d.ts +4 -0
  18. package/lib/browser/types/types.d.ts +92 -0
  19. package/lib/browser/types/worker.d.ts +2 -0
  20. package/lib/browser/worker.js +3498 -0
  21. package/lib/browser-assets.js +119 -0
  22. package/lib/cli.js +1336 -0
  23. package/lib/document.js +178 -0
  24. package/lib/engine-rendering.js +120 -0
  25. package/lib/font-config.js +46 -0
  26. package/lib/font-source.js +377 -0
  27. package/lib/font-worker.js +1383 -0
  28. package/lib/index.js +408 -165
  29. package/lib/rendering.js +99 -0
  30. package/lib/sheet-geometry.js +111 -0
  31. package/lib/types/browser-assets.d.ts +15 -0
  32. package/lib/types/cli.d.ts +3 -0
  33. package/lib/types/default-fonts.d.ts +3 -0
  34. package/lib/types/document.d.ts +1 -1
  35. package/lib/types/engine-rendering.d.ts +15 -0
  36. package/lib/types/engine.d.ts +5 -5
  37. package/lib/types/font-config.d.ts +24 -0
  38. package/lib/types/font-full.d.ts +13 -0
  39. package/lib/types/font-loader.d.ts +1 -7
  40. package/lib/types/font-preferences-data.d.ts +16 -0
  41. package/lib/types/font-preferences.d.ts +29 -0
  42. package/lib/types/font-request.d.ts +12 -0
  43. package/lib/types/font-source-types.d.ts +84 -0
  44. package/lib/types/font-source.d.ts +10 -0
  45. package/lib/types/font-subsets.d.ts +35 -0
  46. package/lib/types/font-worker.d.ts +2 -0
  47. package/lib/types/fonts.d.ts +20 -37
  48. package/lib/types/harfbuzz-subset.d.ts +11 -0
  49. package/lib/types/image-operations.d.ts +58 -0
  50. package/lib/types/image-renderer.d.ts +6 -0
  51. package/lib/types/index.d.ts +25 -2
  52. package/lib/types/native.d.ts +4 -2
  53. package/lib/types/operations.d.ts +41 -0
  54. package/lib/types/options.d.ts +1 -1
  55. package/lib/types/png.d.ts +2 -0
  56. package/lib/types/profile.d.ts +8 -0
  57. package/lib/types/rendering.d.ts +41 -0
  58. package/lib/types/runtime.d.ts +14 -0
  59. package/lib/types/sheet-geometry.d.ts +38 -0
  60. package/lib/types/unicode-scripts.d.ts +18 -0
  61. package/lib/types/wasm.d.ts +76 -1
  62. package/lib/types/worker.d.ts +3 -0
  63. package/lib/worker.js +1716 -271
  64. package/licenses/font-subset/harfbuzz-COPYING +42 -0
  65. package/licenses/font-subset/harfbuzzjs-LICENSE +19 -0
  66. package/licenses/javascript/fflate-LICENSE +21 -0
  67. package/licenses/javascript/saxes-LICENSE +64 -0
  68. package/licenses/javascript/xmlchars-LICENSE +18 -0
  69. package/package.json +59 -12
  70. package/sources/browser/packages/browser/package.json +22 -0
  71. package/sources/browser/packages/browser/src/connection.ts +166 -0
  72. package/sources/browser/packages/browser/src/engine-rendering.ts +2 -0
  73. package/sources/browser/packages/browser/src/engine-types.ts +14 -0
  74. package/sources/browser/packages/browser/src/font-channel.ts +99 -0
  75. package/sources/browser/packages/browser/src/index.ts +39 -0
  76. package/sources/browser/packages/browser/src/office-engine.ts +299 -0
  77. package/sources/browser/packages/browser/src/office-types.ts +77 -0
  78. package/sources/browser/packages/browser/src/office.ts +62 -0
  79. package/sources/browser/packages/browser/src/protocol.ts +39 -0
  80. package/sources/browser/packages/browser/src/rendering.ts +3 -0
  81. package/sources/browser/packages/browser/src/types.ts +94 -0
  82. package/sources/browser/packages/browser/src/worker.ts +166 -0
  83. package/sources/browser/packages/browser/tsconfig.json +5 -0
  84. package/sources/browser/packages/browser/tsdown.config.ts +7 -0
  85. package/sources/browser/scripts/build-browser.mjs +82 -0
  86. package/sources/font-subset/engine/font-subset/README.md +23 -0
  87. package/sources/font-subset/engine/font-subset/README.zh.md +23 -0
  88. package/sources/font-subset/engine/font-subset/source.json +16 -0
  89. package/sources/font-subset/harfbuzzjs/config-override-subset.h +7 -0
  90. package/sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols +34 -0
  91. package/sources/font-subset/scripts/build-font-subset.mjs +64 -0
  92. package/sources/font-subset/scripts/pack-utils.mjs +69 -0
  93. package/sources/font-subset/scripts/platform-matrix.mjs +100 -0
  94. package/sources/font-subset/scripts/verify-artifacts.mjs +260 -0
@@ -1,3 +1,6 @@
1
+ import type { FontMatchRequest } from './font-request.ts';
2
+ export type { FontMatchRequest } from './font-request.ts';
3
+ export { fontFamilyPriority, normalize } from './font-config.ts';
1
4
  import type { Font, FontCollection } from 'fontkit';
2
5
  /** One inclusive Unicode range a physical face renders. */
3
6
  export type GlyphRange = [number, number];
@@ -17,30 +20,27 @@ export interface FontFace {
17
20
  readonly width: number;
18
21
  readonly italic: boolean;
19
22
  readonly fixed: boolean;
23
+ /** OS/2 identifies a script or ornamental face; deprioritized only after named preferences. */
24
+ readonly decorative: boolean;
20
25
  readonly postscriptName: string | null;
21
26
  /** Decoded glyph ranges; absent until a match reads this face's coverage. */
22
27
  coverage?: GlyphRange[];
23
28
  }
24
- /** VCL attributes LibreOffice requests one family for. */
25
- export interface FontMatchRequest {
26
- readonly family: string;
27
- readonly style: string;
28
- readonly weight: number;
29
- readonly italic: number;
30
- readonly width: number;
31
- readonly pitch: number;
32
- readonly language: string;
33
- readonly codePoints: readonly number[];
34
- }
35
29
  /** Selected physical files and the requested family the catalog could not find. */
36
30
  export interface FontMatchResult {
37
31
  readonly fonts: FontFace[];
38
32
  readonly missingFamily?: string;
33
+ /** Requested scalars no installed face covers. */
34
+ readonly unresolvedCodePoints?: readonly number[];
39
35
  }
40
36
  /** One host font snapshot and the ordered fallback groups a conversion supplies. */
41
37
  export interface SystemFontCatalogOptions {
42
38
  readonly faces: readonly FontFace[];
43
39
  readonly fallbackFamilies: readonly (readonly string[])[];
40
+ /** Whole-file consumers deduplicate collections; subset consumers retain each selected face. */
41
+ readonly deduplicateBy?: 'file' | 'face';
42
+ /** Platform owning the indexed font snapshot; defaults to the current Host. */
43
+ readonly platform?: string;
44
44
  }
45
45
  /** Host font roots and physical file limits. */
46
46
  export interface FontIndexOptions {
@@ -53,21 +53,6 @@ export interface FontIndexOptions {
53
53
  * @returns whether it means the path is not a usable font source.
54
54
  */
55
55
  export declare function absent(error: unknown): boolean;
56
- /**
57
- * Case- and separator-insensitive family key used to compare names across sources.
58
- * @param value - Family, style, or postscript name as recorded by a document or font.
59
- * @returns The normalized key.
60
- */
61
- export declare function normalize(value: string): string;
62
- /**
63
- * Order named substitutions and their generic text family without excluding unlisted fonts.
64
- * @param requested - Original family names, in document order.
65
- * @param groups - Ordered family groups shared with Fontconfig aliases.
66
- * @param pitch - VCL pitch; one requests a monospaced fallback.
67
- * @param symbols - Whether symbol alternatives precede the generic fallback.
68
- * @returns distinct family names, with original requests first.
69
- */
70
- export declare function fontFamilyPriority(requested: readonly string[], groups: readonly (readonly string[])[], pitch?: number, symbols?: boolean): string[];
71
56
  /**
72
57
  * Discover system and per-user font roots using the selected platform's path separators.
73
58
  * @param platform - Host operating system.
@@ -97,21 +82,18 @@ export declare function faceCoverage(font: Font): GlyphRange[];
97
82
  */
98
83
  export declare function indexedFace(parsed: Font | FontCollection, face: Pick<FontFace, 'faceIndex' | 'postscriptName'>): Font;
99
84
  /**
100
- * VCL weight, width, and fixed-pitch values for one parsed face.
85
+ * VCL metrics and OS/2 design classification for one parsed face.
101
86
  * @param font - The parsed physical face, whose `OS/2` and `post` tables may be absent.
102
87
  * @returns the recorded classes, or the regular defaults for an absent table.
103
88
  */
104
- export declare function faceMetrics(font: Pick<Font, 'OS/2' | 'post'>): {
105
- weight: number;
106
- width: number;
107
- fixed: boolean;
108
- };
89
+ export declare function faceMetrics(font: Pick<Font, 'OS/2' | 'post'>): Pick<FontFace, 'weight' | 'width' | 'fixed' | 'decorative'>;
109
90
  /**
110
91
  * Snapshot eligible local font metadata without retaining font bytes or decoding glyph coverage.
111
92
  * @param options - Host font roots and physical file limits.
112
- * @returns metadata reused for the converter lifetime; recreate it after changing installed fonts.
93
+ * @param previous - Optional prior snapshot whose unchanged physical files can reuse parsed metadata.
94
+ * @returns current metadata; changed and newly installed files are decoded again.
113
95
  */
114
- export declare function indexSystemFonts(options: FontIndexOptions): FontFace[];
96
+ export declare function indexSystemFonts(options: FontIndexOptions, previous?: readonly FontFace[]): FontFace[];
115
97
  /** Conversion-local glyph coverage over the converter's first metadata snapshot. */
116
98
  export declare class SystemFontCatalog {
117
99
  private readonly options;
@@ -122,11 +104,12 @@ export declare class SystemFontCatalog {
122
104
  constructor(options: SystemFontCatalogOptions);
123
105
  /**
124
106
  * Find installed faces covering the requested family or missing characters.
125
- * Exact families precede configured alternatives, symbol families for missing symbols,
126
- * generic families, then other glyph-covering faces.
107
+ * Exact families and configured aliases precede script/region body preferences,
108
+ * then other glyph-covering faces. Unlisted decorative Latin/CJK faces follow
109
+ * body faces; normal cursive writing systems retain their typographic traditions.
127
110
  * @param request - VCL family/style attributes and Unicode scalars missing from its current font.
128
111
  * @param signal - cancellation checked between synchronous font reads.
129
- * @returns selected physical files, deduplicated across collection faces; absent glyphs remain unresolved.
112
+ * @returns selected files or physical faces according to deduplicateBy; absent glyphs remain unresolved.
130
113
  * @throws if an indexed font changes or cannot be read during glyph matching.
131
114
  */
132
115
  match(request: FontMatchRequest, signal: AbortSignal): FontMatchResult;
@@ -0,0 +1,11 @@
1
+ /** Exact upstream subset source and heap-growth recipe, included in generated subset identities. */
2
+ export declare const FONT_SUBSET_VERSION = "harfbuzzjs-1.6.1-hb-36cb489-growth-v1";
3
+ /**
4
+ * Extract and subset one physical face without renaming it or instancing variable axes.
5
+ * @param original - TTF, OTF, or collection bytes.
6
+ * @param faceIndex - Collection face index; zero for a standalone face.
7
+ * @param points - Unicode scalars, including any required variation selectors.
8
+ * @returns caller-owned sfnt bytes; all layout scripts/features and glyph closure remain enabled.
9
+ */
10
+ export declare function subsetFont(original: Uint8Array, faceIndex: number, points: readonly number[]): Promise<Uint8Array>;
11
+ //# sourceMappingURL=harfbuzz-subset.d.ts.map
@@ -0,0 +1,58 @@
1
+ import { type Rectangle } from './sheet-geometry.ts';
2
+ export declare const IMAGE_FORMATS: readonly ["doc", "docx", "odt", "xls", "xlsx", "ods", "ppt", "pptx", "odp", "pdf"];
3
+ export interface RenderImagesRequest {
4
+ readonly inputPath: string;
5
+ /** Must not exist. A failed or cancelled batch removes this entire new directory. */
6
+ readonly outputDir: string;
7
+ /** One-based physical pages/slides; forbidden for worksheets. Default: all. */
8
+ readonly pages?: 'all' | readonly number[];
9
+ /** Calc only. Exact worksheet name. Without it, render each visible worksheet's data area. */
10
+ readonly sheet?: string;
11
+ /** Calc only. A1 rectangle, requiring an exact sheet. Default: A1 through the last data cell. */
12
+ readonly range?: string;
13
+ /** Raster DPI. Default 144, range 24–600. */
14
+ readonly dpi?: number;
15
+ /** Total output image limit, including worksheet fragments. Never truncates. Default: 100. */
16
+ readonly maxPages?: number;
17
+ /** Per-image pixel limit. Default and maximum: 16777216. */
18
+ readonly maxPixels?: number;
19
+ /** Per-image width/height limit in output pixels. Default: 8192. */
20
+ readonly maxDimension?: number;
21
+ }
22
+ export interface RenderedImage {
23
+ readonly index: number;
24
+ readonly page?: number;
25
+ readonly sheet?: string;
26
+ readonly range?: string;
27
+ readonly rtl?: boolean;
28
+ readonly path: string;
29
+ readonly width: number;
30
+ readonly height: number;
31
+ /** Source rectangle in CSS pixels at 96 DPI, before raster scale. */
32
+ readonly rectangle: Rectangle;
33
+ readonly byteLength: number;
34
+ }
35
+ export interface RenderImagesResult {
36
+ readonly schemaVersion: 1;
37
+ readonly backend: 'wasm';
38
+ readonly rasterEngine: 'libreoffice' | 'pdfium';
39
+ readonly source: 'saved';
40
+ readonly inputPath: string;
41
+ readonly sourceSha256: string;
42
+ readonly dpi: number;
43
+ /** Total physical pages/slides, or visible worksheets; images contains the selected subset. */
44
+ readonly pageCount: number;
45
+ readonly images: readonly RenderedImage[];
46
+ readonly missingFonts: string[];
47
+ }
48
+ export interface ImageRenderSpec extends RenderImagesRequest {
49
+ readonly kind: 'images';
50
+ readonly extension: string;
51
+ readonly dpi: number;
52
+ readonly maxPages: number;
53
+ readonly maxPixels: number;
54
+ readonly maxDimension: number;
55
+ }
56
+ export declare function resolveImageRender(request: RenderImagesRequest): ImageRenderSpec;
57
+ export declare function selectedPages(pages: 'all' | readonly number[] | undefined, count: number, limit: number): number[];
58
+ //# sourceMappingURL=image-operations.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { type WasmConversionRequest } from './wasm.ts';
2
+ import { type ImageRenderSpec, type RenderImagesResult } from './image-operations.ts';
3
+ export declare function renderImagesWithWasm(request: Omit<WasmConversionRequest, 'operation'> & {
4
+ operation: ImageRenderSpec;
5
+ }): Promise<RenderImagesResult>;
6
+ //# sourceMappingURL=image-renderer.d.ts.map
@@ -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 PDF bytes. Default: 128 MiB. */
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 suffix: doc, docx, xls, xlsx, ppt, or pptx.
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
  }
@@ -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 create no file.
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
@@ -1,6 +1,6 @@
1
1
  /** Validated deployment limits shared by native and Node WASM conversions. */
2
2
  import type { ConverterOptions } from './index.ts';
3
- /** Ordered family groups used when the caller supplies none. */
3
+ /** Default named aliases and generic families. */
4
4
  export declare const FONT_FALLBACKS: readonly (readonly string[])[];
5
5
  /** Resolved limits and font settings used by every conversion of one converter. */
6
6
  export interface ResolvedOptions {
@@ -0,0 +1,2 @@
1
+ export declare function encodePng(width: number, height: number, rgba: Uint8Array | Uint8ClampedArray): Uint8Array;
2
+ //# sourceMappingURL=png.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
@@ -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 pdf: Uint8Array;
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
@@ -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;