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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/NOTICE +0 -240
  2. package/README.md +53 -43
  3. package/README.zh.md +58 -35
  4. package/lib/cli.js +725 -132
  5. package/lib/index.js +757 -133
  6. package/lib/types/engine.d.ts +5 -5
  7. package/lib/types/font-loader.d.ts +18 -16
  8. package/lib/types/fonts.d.ts +38 -21
  9. package/lib/types/image-operations.d.ts +1 -1
  10. package/lib/types/index.d.ts +13 -7
  11. package/lib/types/native-image-renderer.d.ts +19 -0
  12. package/lib/types/native.d.ts +1 -1
  13. package/lib/types/options.d.ts +3 -1
  14. package/lib/types/wasm.d.ts +4 -1
  15. package/lib/types/worker.d.ts +2 -0
  16. package/lib/worker.js +420 -942
  17. package/package.json +13 -55
  18. package/assets/font-subset.json +0 -70
  19. package/assets/font-subset.wasm +0 -0
  20. package/lib/browser/assets.json +0 -10
  21. package/lib/browser/index.js +0 -491
  22. package/lib/browser/types/connection.d.ts +0 -20
  23. package/lib/browser/types/engine-rendering.d.ts +0 -3
  24. package/lib/browser/types/engine-types.d.ts +0 -17
  25. package/lib/browser/types/font-channel.d.ts +0 -21
  26. package/lib/browser/types/index.d.ts +0 -14
  27. package/lib/browser/types/office-engine.d.ts +0 -48
  28. package/lib/browser/types/office-types.d.ts +0 -107
  29. package/lib/browser/types/office.d.ts +0 -4
  30. package/lib/browser/types/preparation.d.ts +0 -13
  31. package/lib/browser/types/protocol.d.ts +0 -110
  32. package/lib/browser/types/rendering.d.ts +0 -4
  33. package/lib/browser/types/types.d.ts +0 -113
  34. package/lib/browser/types/worker.d.ts +0 -2
  35. package/lib/browser/worker.js +0 -3615
  36. package/lib/browser-assets.js +0 -119
  37. package/lib/document.js +0 -178
  38. package/lib/engine-rendering.js +0 -120
  39. package/lib/font-config.js +0 -46
  40. package/lib/font-source.js +0 -395
  41. package/lib/font-worker.js +0 -1481
  42. package/lib/rendering.js +0 -99
  43. package/lib/sheet-geometry.js +0 -111
  44. package/lib/types/browser-assets.d.ts +0 -15
  45. package/lib/types/default-fonts.d.ts +0 -3
  46. package/lib/types/font-config.d.ts +0 -24
  47. package/lib/types/font-preferences-data.d.ts +0 -16
  48. package/lib/types/font-preferences.d.ts +0 -29
  49. package/lib/types/font-request.d.ts +0 -12
  50. package/lib/types/font-source-types.d.ts +0 -95
  51. package/lib/types/font-source.d.ts +0 -10
  52. package/lib/types/font-subsets.d.ts +0 -39
  53. package/lib/types/font-worker.d.ts +0 -2
  54. package/lib/types/harfbuzz-subset.d.ts +0 -11
  55. package/lib/types/unicode-scripts.d.ts +0 -18
  56. package/licenses/font-subset/harfbuzz-COPYING +0 -42
  57. package/licenses/font-subset/harfbuzzjs-LICENSE +0 -19
  58. package/licenses/javascript/fflate-LICENSE +0 -21
  59. package/licenses/javascript/saxes-LICENSE +0 -64
  60. package/licenses/javascript/xmlchars-LICENSE +0 -18
  61. package/sources/browser/packages/browser/package.json +0 -22
  62. package/sources/browser/packages/browser/src/connection.ts +0 -171
  63. package/sources/browser/packages/browser/src/engine-rendering.ts +0 -2
  64. package/sources/browser/packages/browser/src/engine-types.ts +0 -14
  65. package/sources/browser/packages/browser/src/font-channel.ts +0 -160
  66. package/sources/browser/packages/browser/src/index.ts +0 -40
  67. package/sources/browser/packages/browser/src/office-engine.ts +0 -323
  68. package/sources/browser/packages/browser/src/office-types.ts +0 -77
  69. package/sources/browser/packages/browser/src/office.ts +0 -62
  70. package/sources/browser/packages/browser/src/preparation.ts +0 -41
  71. package/sources/browser/packages/browser/src/protocol.ts +0 -41
  72. package/sources/browser/packages/browser/src/rendering.ts +0 -3
  73. package/sources/browser/packages/browser/src/types.ts +0 -115
  74. package/sources/browser/packages/browser/src/worker.ts +0 -181
  75. package/sources/browser/packages/browser/tsconfig.json +0 -5
  76. package/sources/browser/packages/browser/tsdown.config.ts +0 -7
  77. package/sources/browser/scripts/build-browser.mjs +0 -82
  78. package/sources/font-subset/engine/font-subset/README.md +0 -23
  79. package/sources/font-subset/engine/font-subset/README.zh.md +0 -23
  80. package/sources/font-subset/engine/font-subset/source.json +0 -16
  81. package/sources/font-subset/harfbuzzjs/config-override-subset.h +0 -7
  82. package/sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols +0 -34
  83. package/sources/font-subset/scripts/build-font-subset.mjs +0 -64
  84. package/sources/font-subset/scripts/pack-utils.mjs +0 -69
  85. package/sources/font-subset/scripts/platform-matrix.mjs +0 -100
  86. package/sources/font-subset/scripts/verify-artifacts.mjs +0 -260
package/NOTICE CHANGED
@@ -24,243 +24,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
-
28
- The Host font subset runtime uses HarfBuzz and the harfbuzzjs subset configuration. Exact commits and compiler settings are recorded in assets/font-subset.json and sources/font-subset/. Their MIT and Old MIT notices are retained in licenses/font-subset/.
29
-
30
- Font preference data
31
-
32
- https://raw.githubusercontent.com/chromium/chromium/ffaf825e8c2e27fccc089b425f9f114d275804ae/third_party/blink/renderer/platform/fonts/win/font_fallback_win.cc
33
- /*
34
- * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights
35
- * reserved.
36
- *
37
- * Redistribution and use in source and binary forms, with or without
38
- * modification, are permitted provided that the following conditions are
39
- * met:
40
- *
41
- * * Redistributions of source code must retain the above copyright
42
- * notice, this list of conditions and the following disclaimer.
43
- * * Redistributions in binary form must reproduce the above
44
- * copyright notice, this list of conditions and the following disclaimer
45
- * in the documentation and/or other materials provided with the
46
- * distribution.
47
- * * Neither the name of Google Inc. nor the names of its
48
- * contributors may be used to endorse or promote products derived from
49
- * this software without specific prior written permission.
50
- *
51
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
- */
63
-
64
- https://raw.githubusercontent.com/fontconfig/fontconfig/84ae86bc21c94d4aedbc02e32c9dc18b8750193c/COPYING
65
- fontconfig/COPYING
66
-
67
- Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard
68
- Copyright © 2005 Patrick Lam
69
- Copyright © 2007 Dwayne Bailey and Translate.org.za
70
- Copyright © 2009 Roozbeh Pournader
71
- Copyright © 2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 Red Hat, Inc.
72
- Copyright © 2008 Danilo Šegan
73
- Copyright © 2012 Google, Inc.
74
-
75
-
76
- Permission to use, copy, modify, distribute, and sell this software and its
77
- documentation for any purpose is hereby granted without fee, provided that
78
- the above copyright notice appear in all copies and that both that
79
- copyright notice and this permission notice appear in supporting
80
- documentation, and that the name of the author(s) not be used in
81
- advertising or publicity pertaining to distribution of the software without
82
- specific, written prior permission. The authors make no
83
- representations about the suitability of this software for any purpose. It
84
- is provided "as is" without express or implied warranty.
85
-
86
- THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
87
- INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
88
- EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
89
- CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
90
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
91
- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
92
- PERFORMANCE OF THIS SOFTWARE.
93
-
94
-
95
- --------------------------------------------------------------------------------
96
- fontconfig/fc-case/CaseFolding.txt
97
-
98
- © 2019 Unicode®, Inc.
99
- Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
100
- For terms of use, see http://www.unicode.org/terms_of_use.html
101
-
102
-
103
- --------------------------------------------------------------------------------
104
- fontconfig/src/fcatomic.h
105
-
106
- /*
107
- * Mutex operations. Originally copied from HarfBuzz.
108
- *
109
- * Copyright © 2007 Chris Wilson
110
- * Copyright © 2009,2010 Red Hat, Inc.
111
- * Copyright © 2011,2012,2013 Google, Inc.
112
- *
113
- * Permission is hereby granted, without written agreement and without
114
- * license or royalty fees, to use, copy, modify, and distribute this
115
- * software and its documentation for any purpose, provided that the
116
- * above copyright notice and the following two paragraphs appear in
117
- * all copies of this software.
118
- *
119
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
120
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
121
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
122
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
123
- * DAMAGE.
124
- *
125
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
126
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
127
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
128
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
129
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
130
- *
131
- * Contributor(s):
132
- * Chris Wilson <chris@chris-wilson.co.uk>
133
- * Red Hat Author(s): Behdad Esfahbod
134
- * Google Author(s): Behdad Esfahbod
135
- */
136
-
137
-
138
- --------------------------------------------------------------------------------
139
- fontconfig/src/fcfoundry.h
140
-
141
- /*
142
- Copyright © 2002-2003 by Juliusz Chroboczek
143
-
144
- Permission is hereby granted, free of charge, to any person obtaining a copy
145
- of this software and associated documentation files (the "Software"), to deal
146
- in the Software without restriction, including without limitation the rights
147
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
148
- copies of the Software, and to permit persons to whom the Software is
149
- furnished to do so, subject to the following conditions:
150
-
151
- The above copyright notice and this permission notice shall be included in
152
- all copies or substantial portions of the Software.
153
-
154
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
156
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
157
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
158
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
159
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
160
- THE SOFTWARE.
161
- */
162
-
163
-
164
- --------------------------------------------------------------------------------
165
- fontconfig/src/fcmd5.h
166
-
167
- /*
168
- * This code implements the MD5 message-digest algorithm.
169
- * The algorithm is due to Ron Rivest. This code was
170
- * written by Colin Plumb in 1993, no copyright is claimed.
171
- * This code is in the public domain; do with it what you wish.
172
- *
173
- * Equivalent code is available from RSA Data Security, Inc.
174
- * This code has been tested against that, and is equivalent,
175
- * except that you don't need to include two pages of legalese
176
- * with every copy.
177
- *
178
- * To compute the message digest of a chunk of bytes, declare an
179
- * MD5Context structure, pass it to MD5Init, call MD5Update as
180
- * needed on buffers full of bytes, and then call MD5Final, which
181
- * will fill a supplied 16-byte array with the digest.
182
- */
183
-
184
-
185
- --------------------------------------------------------------------------------
186
- fontconfig/src/fcmutex.h
187
-
188
- /*
189
- * Atomic int and pointer operations. Originally copied from HarfBuzz.
190
- *
191
- * Copyright © 2007 Chris Wilson
192
- * Copyright © 2009,2010 Red Hat, Inc.
193
- * Copyright © 2011,2012,2013 Google, Inc.
194
- *
195
- * Permission is hereby granted, without written agreement and without
196
- * license or royalty fees, to use, copy, modify, and distribute this
197
- * software and its documentation for any purpose, provided that the
198
- * above copyright notice and the following two paragraphs appear in
199
- * all copies of this software.
200
- *
201
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
202
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
203
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
204
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
205
- * DAMAGE.
206
- *
207
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
208
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
209
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
210
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
211
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
212
- *
213
- * Contributor(s):
214
- * Chris Wilson <chris@chris-wilson.co.uk>
215
- * Red Hat Author(s): Behdad Esfahbod
216
- * Google Author(s): Behdad Esfahbod
217
- */
218
-
219
-
220
- --------------------------------------------------------------------------------
221
- fontconfig/src/ftglue.[ch]
222
-
223
- /* ftglue.c: Glue code for compiling the OpenType code from
224
- * FreeType 1 using only the public API of FreeType 2
225
- *
226
- * By David Turner, The FreeType Project (www.freetype.org)
227
- *
228
- * This code is explicitely put in the public domain
229
- *
230
- * ==========================================================================
231
- *
232
- * the OpenType parser codes was originally written as an extension to
233
- * FreeType 1.x. As such, its source code was embedded within the library,
234
- * and used many internal FreeType functions to deal with memory and
235
- * stream i/o.
236
- *
237
- * When it was 'salvaged' for Pango and Qt, the code was "ported" to FreeType 2,
238
- * which basically means that some macro tricks were performed in order to
239
- * directly access FT2 _internal_ functions.
240
- *
241
- * these functions were never part of FT2 public API, and _did_ change between
242
- * various releases. This created chaos for many users: when they upgraded the
243
- * FreeType library on their system, they couldn't run Gnome anymore since
244
- * Pango refused to link.
245
- *
246
- * Very fortunately, it's possible to completely avoid this problem because
247
- * the FT_StreamRec and FT_MemoryRec structure types, which describe how
248
- * memory and stream implementations interface with the rest of the font
249
- * library, have always been part of the public API, and never changed.
250
- *
251
- * What we do thus is re-implement, within the OpenType parser, the few
252
- * functions that depend on them. This only adds one or two kilobytes of
253
- * code, and ensures that the parser can work with _any_ version
254
- * of FreeType installed on your system. How sweet... !
255
- *
256
- * Note that we assume that Pango doesn't use any other internal functions
257
- * from FreeType. It used to in old versions, but this should no longer
258
- * be the case. (crossing my fingers).
259
- *
260
- * - David Turner
261
- * - The FreeType Project (www.freetype.org)
262
- *
263
- * PS: This "glue" code is explicitely put in the public domain
264
- */
265
-
266
- Unicode data is supplied by @unicode/unicode-17.0.0 under its included MIT license.
package/README.md CHANGED
@@ -1,71 +1,81 @@
1
1
  # @deepseek-ai/libreoffice-kit
2
2
 
3
- The Node API, CLI, browser adapters and font service share this package. Its exact-version dependency, `@deepseek-ai/libreoffice-kit-wasm`, carries the prebuilt engine for all supported hosts. Installation and document operations never compile, download, or discover a system LibreOffice. Node.js 22.19 or newer is required.
3
+ English | [中文](README.zh.md)
4
4
 
5
- ```ts
6
- import { createConverter, discoverRuntime } from '@deepseek-ai/libreoffice-kit'
5
+ Convert, recalculate, and directly render local Office documents with prebuilt LibreOffice engines. Use the same API in a server, desktop application, or document-processing job, with configurable fonts, cancellation, and resource limits.
7
6
 
8
- const converter = await createConverter({ timeoutMs: 120_000 })
7
+ Binary `.doc`, `.xls`, and `.ppt` inputs must be OLE compound documents, such as Office 97–2003 files. Renamed RTF/HTML and `.wps` inputs are unsupported. `missingFonts` is empty for binary inputs because their font tables are interpreted by LibreOffice rather than the OOXML inspector.
8
+
9
+ ## Installation and usage
10
+
11
+ Install with Node.js 22.19.0 or newer:
12
+
13
+ ```sh
14
+ npm install @deepseek-ai/libreoffice-kit@0.0.3
15
+ ```
16
+
17
+ npm installs the matching native engine on macOS/Windows ARM64 or x64, and the shared WASM engine on Linux. macOS and Windows require their native package; a missing or invalid package rejects `createConverter` with `unavailable`, without switching to WASM. Linux uses WASM unless a compatible development native package was installed explicitly. Conversion failures never switch engines.
18
+
19
+ ```js
20
+ import { createConverter } from '@deepseek-ai/libreoffice-kit';
21
+
22
+ const converter = await createConverter({ timeoutMs: 120_000 });
9
23
  try {
10
- // Office paints directly from its model; PDF inputs use PDFium.
11
- const images = await converter.renderImages({
12
- inputPath: '/private/report.docx', outputDir: '/private/new-images', pages: [1, 3], dpi: 144,
13
- })
14
- await converter.convert({ inputPath: '/private/report.doc', outputPath: '/private/new-report.docx' })
15
- await converter.recalculate({ inputPath: '/private/book.xlsx', outputPath: '/private/recalculated.xlsx' })
24
+ const result = await converter.render({
25
+ inputPath: '/private/work/document.docx',
26
+ outputPath: '/private/work/document.pdf',
27
+ });
28
+ console.log(result.backend, result.missingFonts);
16
29
  } finally {
17
- await converter.dispose()
30
+ await converter.dispose();
18
31
  }
19
- const runtime = await discoverRuntime() // installed CLI and API paths; no engine start
20
32
  ```
21
33
 
22
- ## Direct image rendering
34
+ Native and WASM engines are platform-filtered optional dependencies. Application builders must verify the required engine is installed: native on macOS/Windows, WASM on Linux. A missing required engine rejects `createConverter()` with `unavailable`.
23
35
 
24
- `renderImages(request, signal?)` loads one saved input snapshot and produces `page-0001.png`, subsequent images, and `manifest.json` in a **new** directory. It supports DOC/DOCX/ODT, XLS/XLSX/ODS, PPT/PPTX/ODP, and PDF. Office rasterization never exports an intermediate PDF. The existing `render({inputPath,outputPath})` method still exports PDF for compatibility.
36
+ Each converter serializes renders. A render creates a separate native process or Node worker and private profile, so fonts, document state, and failures do not leak into later renders. The deadline begins after acquiring its conversion slot. An `AbortSignal` cancels queued or active work; cancellation and `dispose()` await process or worker exit and scratch cleanup. Disposed converters reject further work.
25
37
 
26
- - Writer, Impress and PDF use distinct, one-based `pages`, preserving the requested order. Omit it or specify `'all'` for all physical pages/slides.
27
- - Calc uses an exact `sheet` name and optional `range: 'A1:D20'`; a range requires a sheet. Without selectors, every visible sheet's data area is captured. `pages` is rejected for worksheets. Hidden/filtered rows and columns retain their display behavior. The default data area excludes formatting-only cells and standalone drawings; select an explicit range to include additional content. An empty sheet renders A1.
28
- - `dpi` defaults to 144 and accepts 24–600. Each image is bounded by `maxPixels` (default and maximum 16,777,216) and `maxDimension` (default 8192 pixels per side). Large worksheet regions split on the output-pixel grid in row order. Each fragment retains the requested `sheet`/`range`; its `rectangle` identifies the exact source portion. Writer, Impress and PDF keep whole pages and reject an oversized page.
29
- - `maxPages` defaults to 100 and limits the total output image count, including worksheet fragments across all selected sheets. The complete batch is checked before painting; limits reject the request instead of truncating it.
30
- - `maxInputBytes`, aggregate PNG `maxOutputBytes`, font limits, and `timeoutMs` come from `ConverterOptions`. Defaults and all options are in the shipped TypeScript declarations.
31
- - The manifest identifies `source: 'saved'`, the original `inputPath`, `sourceSha256`, `backend: 'wasm'`, `rasterEngine: 'libreoffice' | 'pdfium'`, total `pageCount`, selected images, dimensions, source rectangles at 96 DPI, and OOXML missing-font diagnostics. For Calc, `pageCount` is the visible sheet count and each image has `sheet`/`range` instead of `page`.
38
+ Converters created through the compatibility `createConverter(options)` API transparently share bounded font metadata and match results with other process-local converters using the same engine and font configuration. Disposing a converter still joins only its own work; the metadata cache remains available to later compatible converters and is bounded both by configuration count and by `maxFontResolutionEntries`, which defaults to 4096. Restart the process after changing font files.
32
39
 
33
- Absolute paths must be caller-authorized, private, and protected against concurrent path replacement. Input must be a nonempty regular file. The output directory must not exist. Cancellation, timeout, disposal or any failure waits for Worker exit and removes the whole newly owned output batch; it never removes a pre-existing output directory. Calls on one converter are serialized. Every operation starts a fresh Worker/model; retained browser editor sessions use the browser adapter.
40
+ For a long-lived service that wants one explicit lifecycle owner for concurrent conversion slots, create one `createConverterFactory(options)` and obtain converters through `factory.create()`. Those converters use a factory-private cache while retaining separate Workers, native helpers, profiles, and output ownership. Dispose the factory to stop and join every converter it created.
34
41
 
35
- ## CLI and conversions
42
+ `convert()` exports the format named by the output suffix, `recalculate()` refreshes spreadsheet formula results before saving, and `renderImages()` writes a fresh directory containing PNG tiles plus `manifest.json`. Office images are painted directly from one loaded model; PDF images use PDFium. The CLI exposes the same operations through `libreoffice-kit capabilities|convert|recalculate|render`.
36
43
 
37
- ```sh
38
- libreoffice-kit capabilities --json
39
- libreoffice-kit render --input report.docx --output-dir new-images --pages 1,3 --dpi 144
40
- libreoffice-kit render --input book.xlsx --output-dir new-sheet --sheet 'Summary' --range A1:D20
41
- libreoffice-kit render --input document.pdf --output-dir new-pdf-images
42
- libreoffice-kit convert --input report.docx --output report.pdf
43
- libreoffice-kit convert --input book.xlsx --output table.csv --sheet 'Summary'
44
- libreoffice-kit recalculate --input book.xlsx --output checked.xlsx
45
- ```
44
+ Conversion workers run the package's shipped JavaScript with an empty `execArgv`; consumer launch flags such as `--input-type=module` are not inherited.
46
45
 
47
- CLI paths resolve against its working directory. Success writes one JSON object to stdout; failure writes `{code,error}` to stderr and exits with status 1. SIGINT/SIGTERM cancel and await cleanup. `render` accepts `--max-pages`, `--max-pixels`, `--max-dimension`, and the common `--timeout-ms`, `--max-input-bytes`, `--max-output-bytes`, archive/font limits, repeated `--font-directory`/`--initial-font-family`, and JSON `--font-fallbacks`.
46
+ On Linux, the native child searches the selected engine's program directory before system paths for shared libraries. Caller-provided `LD_LIBRARY_PATH` and `LD_PRELOAD` are not inherited.
48
47
 
49
- `convert` supports Writer → PDF/DOCX/ODT/TXT, Calc → PDF/XLSX/ODS/CSV, Impress → PDF/PPTX/ODP. CSV requires an exact sheet for multi-sheet inputs and emits UTF-8 with a comma delimiter. `recalculate` synchronously recalculates XLS/XLSX/ODS and saves XLSX/ODS with formulas and refreshed cached results; it does not validate business logic. Conversion outputs must be fresh exclusive files. Macros and external-link updates remain disabled.
48
+ The caller authorizes input access and owns private input/output directories; paths must be absolute and remain unchanged during conversion. Input files must be regular Office files within the configured byte limits. ZIP entry and uncompressed-size limits apply to OOXML; binary DOC/XLS/PPT files use OLE compound containers validated by the LibreOffice importer. Binary formats retain the same conversion deadline and input/output limits. Output creation uses exclusive mode and permissions `0600`; an existing output is never overwritten. Failed or cancelled renders remove newly created outputs. `maxOutputBytes` limits the returned PDF and its read buffer; native temporary disk files can grow until export completes, then oversized PDFs are rejected and deleted before Node reads them. The caller owns successful PDFs and may send their bytes to a browser PDF viewer.
50
49
 
51
- ## Fonts and PDF scope
50
+ `ConversionError.code` distinguishes `invalid-document`, `unsupported-format`, `input-too-large`, `output-too-large`, `invalid-output`, `timeout`, `unavailable`, and `failed`. These codes survive the worker/native transports. Invalid installation assets reject creation as `unavailable`; they never enable fallback. Filesystem errors such as `EEXIST`, invalid configuration errors, and caller cancellation reasons remain unchanged.
52
51
 
53
- Node operations and the Host font service use bounded system-font discovery. Exact installed families and explicit aliases precede Unicode-script and regional body-text preferences, then other glyph-covering fonts. Windows preferences derive from pinned Chromium data; macOS/Linux use Fontconfig categories, with the other source supplying additional candidates. Unicode 17 Script/Script_Extensions data keeps mixed text independent of incorrectly declared document languages. Only unlisted Latin/CJK decorative faces are demoted; cursive writing traditions such as Urdu Nastaliq remain normal body fonts. No fonts are downloaded or bundled by these rules. Full original files retain shaping and encoding. Recreate the converter after changing installed fonts. `missingFonts` reports unavailable declared OOXML families; font-service `unresolvedCodePoints` separately reports scalars no installed face covers. The rule data and licenses are regenerated with `node scripts/generate-font-preferences.mjs` and retained in `NOTICE`.
52
+ ## Engines, fonts, and runtime behavior
54
53
 
55
- `createFontSource` from `@deepseek-ai/libreoffice-kit/fonts` provides an independent Worker service. `prepare()` builds its lifetime font snapshot before the first document request. Default discovery supplements normal system roots with a small compatibility set from an installed Microsoft Office on macOS or Windows; explicit `fontDirectories` replace all defaults. No font bytes or Host paths enter the package. `resolve(attributes)` retains the Unicode-script subset behavior for interactive Office. `resolve({...attributes, mode:'full'})` returns opaque `full_…` identities, original family names and `format` (`ttf`, `otf`, `ttc`); `read(id)` returns complete original font bytes. Apple dfont resources are extracted as complete sfnt faces. Reads reject unknown or changed sources and do not expose host paths.
54
+ The Node API and engine packages share the kit release version. `ENGINE_VERSION` pins both WASM and native optional dependencies to the exact engine version. npm installs prepared engines; installation and conversion never compile LibreOffice or download additional engine payloads. Each engine includes its matching source recipes, patches, build information, and third-party license notices under `sources/` and `licenses/`.
56
55
 
57
- Full-mode selections from the same unchanged TTC share one file read and retained byte entry while keeping each selected family's name and alias. The existing cache budget counts unique full assets once; eviction may require a later read to regenerate them. Subsets and dfont resources remain specific to each physical face.
56
+ Defaults and all options are documented in the shipped TypeScript declarations in `lib/types/index.d.ts`. Font directories use conventional system/user paths for the selected OS. Indexing skips missing or protected sources and propagates other filesystem errors. `fontkit` indexes original font files and selects installed faces and glyph coverage; it does not rewrite fonts. The converter reuses its first font metadata snapshot; recreate the converter after changing installed fonts. Original font bytes and decoded glyph coverage remain conversion-local. `missingFonts` contains absent families declared in readable document XML, excluding unrelated engine defaults. Missing glyphs without a named missing family are not a complete document accessibility report.
58
57
 
59
- PDFium is an experimental direct raster path, separate from PDF.js and Office reading sessions. Embedded PDF fonts remain PDFium-owned. A fixed, bounded set of regular faces selected from `initialFontFamilies` and fallback groups is mounted before PDFium's first font enumeration. This does not infer every arbitrary PDF font or repair custom encodings. Password-protected PDFs are rejected; forms are rasterized by the upstream PDFium wrapper, while ordinary annotations and advanced PDF features require further qualification.
58
+ When `fontDirectories` is omitted on macOS or Windows, default discovery also checks Microsoft Office's bundled/private font directory and the user's Office font cache. Only curated Office-compatible families absent from normal system roots are added, including SimSun and Microsoft YaHei. Explicit `fontDirectories` disables this supplemental discovery.
60
59
 
61
- ## Browser and font entries
60
+ Exact installed families take priority in font matching, including explicitly requested handwriting or decorative fonts. Default `fontFallbacks` prefer common serif, sans-serif, and monospaced text families and corresponding Simplified Chinese faces, with Carlito for Calibri and Calibri Light, and Caladea for Cambria. Catalog matching retains the weight and italic style supplied by WASM font requests when matching faces are installed. The complete indexed catalog remains available for glyphs absent from the preferred families. Caller-provided groups replace the defaults; `[]` removes these preferences without disabling catalog discovery. WASM uses the same ordered aliases for imported fonts. The shipped option types describe `fontFallbacks`.
62
61
 
63
- `@deepseek-ai/libreoffice-kit/browser` provides retained read-only Office sessions through `openOfficeDocument`, Writer paginated/continuous layouts, selection/copy, and standalone PDFium viewing. The rc5 browser API has no editing, snapshot-save or capture operations; Node/CLI conversion and recalculation retain their explicit output APIs. `@deepseek-ai/libreoffice-kit/browser-assets` resolves the local browser Worker and validates the assets in the exact-version WASM dependency. Host asset servers expose these resources as opaque URLs; the main package does not duplicate the LibreOffice payload.
62
+ Native conversion writes missing-family choices into its private LibreOffice profile. LibreOffice resolves installed originals and its metric-compatible fonts before consulting these choices, so custom groups can produce different substitutions across engines. Native weight and italic selection depend on the engine and the fonts it can discover; native font preloading requests regular faces.
64
63
 
65
- `./fonts` provides the Host font service described above. Browser-safe `./font-config` and `./document-inspection` share font configuration and input validation with the Node API. `./internal/*` exports are implementation details used by the bundled browser Worker.
64
+ `maxFontFiles` and `maxFontFileBytes` bound font indexing; `maxLoadedFontBytes` bounds original files explicitly imported by this kit per conversion. WASM uses only imported originals and rejects with `unavailable` when no usable fonts are found; install fonts or configure `fontDirectories` before converting in a minimal container. Native macOS and Windows engines can also use OS-managed fonts, so the import limit is not a cap on native total font memory. Font matching and XML work run inside the cancellable worker; no browser font RPC or DOM is involved.
66
65
 
67
- Subsets use Unicode 17 script data and HarfBuzz layout/composite closure. Their bounded in-memory cache can regenerate evicted entries from unchanged originals. [The subset build recipe](../../engine/font-subset/README.md) pins source and redistribution notices.
66
+ Node WASM image downscaling uses LibreOffice's CPU image filter. Text layout, font matching, and PDF serialization are CPU work as well.
67
+
68
+ For reproducible comparisons, use identical documents, fonts, DPI, and limits; WASM installations run on Linux. Report engine startup together with conversion time; every render starts a fresh engine. The WASM assets and platform payloads carry their source, license, and integrity manifests.
68
69
 
69
70
  ## Source and license
70
71
 
71
- This package is licensed under [MPL-2.0](LICENSE). Engine `prebuilds.json` inventories, corresponding pinned source recipes and patches in `sources/`, and third-party notices in `licenses/` accompany the engine payload. The font subsetter carries its own pinned recipe and redistribution notices. Applications bundling the engine must retain these resources and notices. Declared targets and source-level tests do not substitute for testing the installed engine on representative files.
72
+ This package is licensed under [MPL-2.0](LICENSE). The engine packages include `prebuilds.json` integrity inventories, corresponding source recipes and patches in `sources/`, and third-party redistribution notices in `licenses/`.
73
+
74
+ ## Limitations
75
+
76
+ - Fidelity depends on source formatting, installed fonts, and the selected engine. Missing-font names do not report every missing glyph.
77
+ - DOC/DOCX/ODT, XLS/XLSX/ODS, and PPT/PPTX/ODP conversion is supported; direct image rendering additionally accepts PDF. Conversion does not discover system LibreOffice or download engines and fonts.
78
+ - Font import and output limits do not bound all native memory or temporary disk use. Native platform engines may resolve fonts differently from WASM.
79
+ - Installations from npm use platform-specific optional packages. Applications that bundle engines must retain the complete selected package, including its resources and notices.
80
+ - Windows requires the Microsoft Visual C++ v14 Redistributable matching the Node.js architecture (x64 or ARM64); it is not bundled. Use ARM64 Node.js for the Windows ARM64 engine.
81
+ - Version `0.0.3` ships macOS and Windows native engines for ARM64 and x64 and a shared Node WASM engine for Linux. Other native platforms are development recipes.
package/README.zh.md CHANGED
@@ -1,58 +1,81 @@
1
1
  # @deepseek-ai/libreoffice-kit
2
2
 
3
- Node API、CLI、浏览器适配器和字体服务复用本包;精确版本依赖 `@deepseek-ai/libreoffice-kit-wasm` 提供跨平台预编译引擎。不在安装或文档操作期间编译、下载引擎或发现系统 LibreOffice。需要 Node.js 22.19 以上。
3
+ [English](README.md) | 中文
4
4
 
5
- ## 直接输出图片
5
+ 使用预编译 LibreOffice 引擎,在 Node.js 中转换、重算并直接渲染本地 Office 文档。通过同一套 API,为服务端、桌面应用和文档处理任务提供可配置字体、取消和资源限制。
6
6
 
7
- ```ts
8
- import { createConverter } from '@deepseek-ai/libreoffice-kit'
9
- const converter = await createConverter({ timeoutMs: 120_000 })
7
+ 二进制 `.doc`、`.xls`、`.ppt` 输入必须是 OLE 复合文档,例如 Office 97–2003 文件。不支持改后缀的 RTF/HTML 和 `.wps`。二进制输入的 `missingFonts` 为空,因为其字体表由 LibreOffice 读取,而不是由 OOXML 检查器读取。
8
+
9
+ ## 安装与使用
10
+
11
+ 使用 Node.js 22.19.0 或更新版本安装:
12
+
13
+ ```sh
14
+ npm install @deepseek-ai/libreoffice-kit@0.0.3
15
+ ```
16
+
17
+ npm 在 macOS/Windows ARM64 或 x64 上安装匹配的原生引擎,在 Linux 上安装共享 WASM 引擎。macOS 和 Windows 必须具有对应原生包;包缺失或无效时,`createConverter` 以 `unavailable` 拒绝,不会切换到 WASM。Linux 使用 WASM,除非显式安装了兼容的原生开发包。转换失败不会切换引擎。
18
+
19
+ ```js
20
+ import { createConverter } from '@deepseek-ai/libreoffice-kit';
21
+
22
+ const converter = await createConverter({ timeoutMs: 120_000 });
10
23
  try {
11
- await converter.renderImages({ inputPath: '/private/report.docx', outputDir: '/private/new-images', pages: [1, 3], dpi: 144 })
12
- await converter.renderImages({ inputPath: '/private/book.xlsx', outputDir: '/private/new-sheet', sheet: '汇总', range: 'A1:D20' })
13
- } finally { await converter.dispose() }
24
+ const result = await converter.render({
25
+ inputPath: '/private/work/document.docx',
26
+ outputPath: '/private/work/document.pdf',
27
+ });
28
+ console.log(result.backend, result.missingFonts);
29
+ } finally {
30
+ await converter.dispose();
31
+ }
14
32
  ```
15
33
 
16
- `renderImages` 从一次已保存文件快照加载模型,在新目录中输出 `page-0001.png` 等图片和 `manifest.json`。支持 DOC/DOCX/ODT、XLS/XLSX/ODS、PPT/PPTX/ODP 以及 PDF。Office 从内存模型直接绘图,不经过 PDF;PDF 使用独立 PDFium 路径。原 `render({inputPath,outputPath})` 仍保持导出 PDF 的兼容语义。
34
+ 原生与 WASM 引擎是按平台筛选的可选依赖。应用构建方必须验证所需引擎已安装:macOS/Windows 使用原生引擎,Linux 使用 WASM。必需引擎缺失时,`createConverter()` 以 `unavailable` 拒绝。
17
35
 
18
- - Word、PPT 和 PDF 的 `pages` 是从 1 开始的实体页/幻灯片序号;默认全部,数组保留请求顺序。
19
- - Excel 使用精确 `sheet` 名称与可选 A1 `range`,范围必须指定工作表。不传选择器时渲染全部可见表的数据区,拒绝打印页码。隐藏/筛选行列保留显示行为。默认数据区不包含仅有格式的单元格或独立绘图对象,可显式指定更大范围;空表渲染 A1。
20
- - `dpi` 默认 144,范围 24–600;每图 `maxPixels` 默认且最多 16,777,216,`maxDimension` 默认每边 8192 像素。大表区域按输出像素网格、从上到下逐行拆图;每片保留原请求 `sheet`/`range`,`rectangle` 标明该片的准确源区域。Word、PPT、PDF 保持完整页面,单页超限时报错。
21
- - `maxPages` 默认 100,限制全部工作表拆片后的输出图片总数。绘图前检查完整批次,超限明确报错,不截断批次。
22
- - 输入、全部 PNG 字节总量、字体和超时受 `ConverterOptions` 限制。完整选项与默认值见随包 TypeScript 声明。
23
- - 清单包含 `source:'saved'`、原输入路径与 SHA256、`backend:'wasm'`、实际 `rasterEngine`、总页数、已选图片及尺寸、96 DPI 下源矩形。Excel 总页数表示可见工作表数,图片使用 `sheet`/`range` 而非 `page`。
36
+ 每个转换器串行执行渲染。一次渲染会创建独立的原生进程或 Node worker 以及私有配置目录,因此字体、文档状态和失败不会泄漏到后续渲染。截止时间在获得转换槽位之后开始计算。`AbortSignal` 可以取消排队中或进行中的工作;取消和 `dispose()` 都会等待进程或 worker 退出并完成临时文件清理。已释放的转换器会拒绝后续工作。
24
37
 
25
- 调用方负责授权绝对路径并保护私有目录免受并发路径替换。输入必须是非空普通文件,输出目录必须不存在。失败、取消、超时或 dispose 会等待 Worker 退出并清理整个新批次,不删除已有目录。转换器串行执行调用;每次操作使用新 Worker,浏览器编辑复用另行保留的会话。
38
+ 通过兼容 API `createConverter(options)` 创建的转换器,会自动与进程内使用相同引擎及字体配置的其他转换器共享有界字体元数据和匹配结果。释放 converter 仍只等待它自己的工作;元数据缓存会留给后续兼容 converter,并同时受配置数量和默认值为 4096 的 `maxFontResolutionEntries` 限制。字体文件发生变化后需要重启进程。
26
39
 
27
- ## CLI 与转换
40
+ 长驻服务如果需要为多个并发转换槽提供一个显式生命周期所有者,可创建 `createConverterFactory(options)`,再通过 `factory.create()` 建立转换器。这些转换器使用 factory 私有缓存,同时仍分别拥有 Worker、原生 helper、配置目录和输出。释放 factory 会停止并等待它创建的全部转换器。
28
41
 
29
- ```sh
30
- libreoffice-kit capabilities --json
31
- libreoffice-kit render --input report.docx --output-dir new-images --pages 1,3 --dpi 144
32
- libreoffice-kit render --input book.xlsx --output-dir new-sheet --sheet '汇总' --range A1:D20
33
- libreoffice-kit render --input document.pdf --output-dir new-pdf-images
34
- libreoffice-kit convert --input book.xlsx --output table.csv --sheet '汇总'
35
- libreoffice-kit recalculate --input book.xlsx --output checked.xlsx
36
- ```
42
+ `convert()` 按输出后缀导出格式,`recalculate()` 在保存前刷新电子表格公式结果,`renderImages()` 在全新目录中写入 PNG tile 和 `manifest.json`。Office 图像直接从一次加载的模型绘制,PDF 使用 PDFium。CLI 通过 `libreoffice-kit capabilities|convert|recalculate|render` 提供相同行为。
43
+
44
+ 转换 worker 以空的 `execArgv` 运行包内发布的 JavaScript;`--input-type=module` 之类的调用方启动参数不会被继承。
45
+
46
+ 在 Linux 上,原生子进程会先在所选引擎的 program 目录中查找共享库,然后才查找系统路径。调用方提供的 `LD_LIBRARY_PATH` 和 `LD_PRELOAD` 不会被继承。
37
47
 
38
- CLI 相对路径按工作目录解析,成功在 stdout 输出一个 JSON,失败在 stderr 输出 `{code,error}` 并退出 1。SIGINT/SIGTERM 取消后等待清理。`render` 支持 `--max-pages`、`--max-pixels`、`--max-dimension`,以及通用输入/输出/归档/字体限制、`--timeout-ms`、可重复字体目录和初始 family,以及 JSON `--font-fallbacks`。
48
+ 调用方负责授权输入访问并拥有私有输入/输出目录;路径必须是绝对路径,并在转换期间保持不变。输入文件必须是常规 Office 文件,且在配置的字节限制之内。ZIP 条目数和解压大小限制适用于 OOXML;二进制 DOC/XLS/PPT 使用 OLE 复合容器,内部结构由 LibreOffice 导入器验证。二进制格式仍遵守相同的转换超时和输入/输出限制。输出创建使用独占模式和 `0600` 权限;已存在的输出绝不会被覆盖。失败或取消的渲染会删除新建的输出。`maxOutputBytes` 限制返回的 PDF 及其读取缓冲区;原生临时磁盘文件在导出完成前可能继续增长,随后过大的 PDF 会在 Node 读取之前被拒绝并删除。成功的 PDF 归调用方所有,调用方可以将其字节发送给浏览器 PDF 阅读器。
39
49
 
40
- `convert` 保留 Writer → PDF/DOCX/ODT/TXT、Calc → PDF/XLSX/ODS/CSV、Impress → PDF/PPTX/ODP。多表 CSV 必须指定精确表名,输出 UTF-8 逗号分隔文件。`recalculate` 对 XLS/XLSX/ODS 同步重算并保存 XLSX/ODS 的公式和缓存结果,不验证业务逻辑。输出必须是新文件,宏和外部链接更新保持禁用。
50
+ `ConversionError.code` 区分 `invalid-document`、`unsupported-format`、`input-too-large`、`output-too-large`、`invalid-output`、`timeout`、`unavailable` 和 `failed`。这些 code 会原样穿过 worker 和原生传输层。无效的安装资源会让创建以 `unavailable` 拒绝;它们绝不会启用回退。`EEXIST` 等文件系统错误、无效配置错误和调用方取消原因保持原样。
41
51
 
42
- ## 字体与 PDF 范围
52
+ ## 引擎、字体与运行行为
43
53
 
44
- Node 和 Host 字体服务共用有界系统字体发现与匹配:原字体和显式配置的替代字体优先,其次是对应 Unicode 文字系统、地区及正文类别的候选,最后选择其他覆盖所需字符的字体。Windows 顺序来自固定版本 Chromium,macOS/Linux 使用 Fontconfig 类别顺序,并补充另一来源的候选。Unicode 17 Script/Script_Extensions 数据识别混合文字,不让错误文档语言影响韩文等文字的选择。仅对未明确指定的 Latin/CJK 装饰字体降权,乌尔都文 Nastaliq 等正文传统不受影响。规则不下载或打包字体,仍导入原始字体以保留塑形和编码;安装字体改变后需重新创建转换器。`missingFonts` 报告缺失的声明字体,字体服务的 `unresolvedCodePoints` 单独报告没有任何已安装字体覆盖的字符。使用 `node scripts/generate-font-preferences.mjs` 更新固定来源数据,许可证保留在 `NOTICE`。
54
+ Node API 与引擎包使用相同的 kit 发布版本。`ENGINE_VERSION` 将 WASM 和原生可选依赖固定到精确的引擎版本。npm 安装预编译引擎;安装和转换阶段均不会编译 LibreOffice 或额外下载引擎资源。每个引擎包的 `sources/` 和 `licenses/` 保留匹配的源码配方、补丁、构建信息和第三方许可声明。
45
55
 
46
- `@deepseek-ai/libreoffice-kit/fonts` 的 `createFontSource` 是独立懒加载字体 Worker。默认 `resolve(attributes)` 保留 Office 的 Unicode-script 子集;新增 `resolve({...attributes,mode:'full'})` 返回不暴露主机路径的 `full_…` ID、原 family 和 ttf/otf/ttc 格式。`read(id)` 返回完整原字节,dfont 提取完整单字体 sfnt。来源变化或未知 ID 会拒绝读取。
56
+ 默认值和所有选项记录在随包发布的 `lib/types/index.d.ts` 类型声明中。字体目录使用所选操作系统的常规系统/用户路径。索引会跳过缺失或受保护的来源,并传播其他文件系统错误。`fontkit` 索引原始字体文件并选择已安装的字面和字形覆盖;它不重写字体。转换器复用其第一次字体元数据快照;更改已安装字体后需重新创建转换器。原始字体字节和解码后的字形覆盖都只在本次转换内有效。精确的 family 匹配优先于 `fontFallbacks`。`missingFonts` 包含可读文档 XML 中声明但缺失的 family,不包含无关的引擎默认值。未命名缺失 family 的缺字并不构成完整的文档可访问性报告。
47
57
 
48
- PDFium 直接图片渲染仍为实验能力,与 PDF.js 和 Office 阅读会话分开。嵌入字体由 PDFium 管理;在首次字体枚举前,按初始 family 和回退组预载有字节上限的完整常规字体。该方案不自动推断所有 PDF 字体,也不修复任意自定义编码。加密 PDF 暂拒绝;上游包装层绘制表单,普通注释和高级 PDF 特性仍需专项验收。
58
+ macOS 或 Windows 上省略 `fontDirectories` 时,默认发现还会检查 Microsoft Office 的捆绑/私有字体目录和用户 Office 字体缓存。只补充常规系统目录中不存在的精选 Office 兼容字体族,包括宋体和微软雅黑。显式 `fontDirectories` 会关闭这项补充发现。
49
59
 
50
- ## 浏览器与字体入口
60
+ 精确匹配的已安装 family 优先,包括调用方显式要求的书法或装饰字体。默认 `fontFallbacks` 优先选择常见的衬线、无衬线、等宽文本字体族以及对应的简体中文字面,为 Calibri 和 Calibri Light 使用 Carlito,为 Cambria 使用 Caladea。当匹配的字面已安装时,目录匹配保留 WASM 字体请求给出的字重和斜体。完整索引目录对首选字体族缺失的字形仍然可用。调用方提供的分组会替换默认值;`[]` 会移除这些偏好但不关闭目录发现。WASM 对导入的字体使用相同的顺序别名。随包发布的选项类型包含 `fontFallbacks` 的定义。
51
61
 
52
- `@deepseek-ai/libreoffice-kit/browser` 通过 `openOfficeDocument` 提供常驻 Office 阅读会话、Writer 分页/连续重排、选择复制和独立 PDFium 查看。rc5 浏览器 API 不提供编辑、OOXML 保存快照或 capture;Node/CLI 的转换和重算仍保留显式输出能力。Node 端 `./browser-assets` 校验并解析主包中的 Worker,以及精确版本 WASM 依赖中的资源。Host 将其映射成资源 URL;主包不复制 LibreOffice 大文件。
62
+ 原生转换会把缺失 family 的选择写入其私有 LibreOffice 配置。LibreOffice 会先解析已安装的原始字体及其度量兼容字体,然后才参考这些选择,因此自定义分组在不同引擎上可能产生不同的替换结果。原生的字重和斜体选择取决于引擎及其能发现的字体;原生字体预加载只请求常规字面。
53
63
 
54
- `./fonts` 提供上文的字体服务。`./font-config` 与 `./document-inspection` 为浏览器和 Node 共用的纯逻辑;`./internal/*` 仅用于内部实现。字体子集采用 Unicode 17 数据和 HarfBuzz 布局闭包,内存缓存淘汰后从未变化的原字体重新生成。
64
+ `maxFontFiles` 和 `maxFontFileBytes` 限制字体索引;`maxLoadedFontBytes` 限制本次转换中由本 kit 显式导入的原始文件。WASM 只使用导入的原始文件,找不到可用字体时以 `unavailable` 拒绝;在最小化容器中转换前请安装字体或配置 `fontDirectories`。原生 macOS 和 Windows 引擎还可以使用操作系统管理的字体,因此该导入限制不是原生字体总内存的上限。字体匹配和 XML 处理在可取消的 worker 内运行;不涉及浏览器字体 RPC 或 DOM。
65
+
66
+ Node WASM 的图像降采样使用 LibreOffice 的 CPU 图像过滤器。文本排版、字体匹配和 PDF 序列化同样由 CPU 完成。
67
+
68
+ 为获得可复现的比较结果,请使用相同的文档、字体、DPI 和限制;WASM 安装在 Linux 上运行。报告时应把引擎启动时间和转换时间一起给出;每次渲染都会启动一个全新的引擎。WASM 资源和平台载荷都带有各自的源码、许可证和完整性清单。
55
69
 
56
70
  ## 源码与许可
57
71
 
58
- 使用 [MPL-2.0](LICENSE)。引擎包含 `prebuilds.json` 完整性清单、`sources/` 中的固定源码与补丁配方、`licenses/` 第三方声明;字体子集器也包含自己的配方和声明。打包应用需保留这些资源。声明目标和源码测试不能代替可安装产物的真实文档验收。
72
+ 本包使用 [MPL-2.0](LICENSE) 许可。引擎包包含 `prebuilds.json` 完整性清单、`sources/` 对应源码配方和补丁,以及 `licenses/` 第三方再分发声明。
73
+
74
+ ## 使用限制
75
+
76
+ - 保真度取决于源格式、已安装字体和所选引擎。缺失字体名称不能报告所有缺字。
77
+ - 支持 DOC/DOCX/ODT、XLS/XLSX/ODS 和 PPT/PPTX/ODP 转换;直接图像渲染还接受 PDF。转换不发现系统 LibreOffice,也不下载引擎和字体。
78
+ - 字体导入和输出限制不能约束全部原生内存或临时磁盘使用。原生平台引擎的字体解析可能与 WASM 不同。
79
+ - npm 安装使用按平台选择的可选包。自行打包引擎的应用需要保留所选包的完整内容,包括资源和许可声明。
80
+ - Windows 需要系统安装与 Node.js 架构一致的 Microsoft Visual C++ v14 Redistributable(x64 或 ARM64);包中不捆绑该运行库。Windows ARM64 引擎需要使用 ARM64 Node.js。
81
+ - `0.0.3` 提供 macOS 和 Windows 的 ARM64、x64 原生引擎,以及供 Linux 使用的共享 Node WASM 引擎;其他原生平台仅保留开发构建配方。