@deepseek-ai/libreoffice-kit 0.0.1 → 0.0.2-rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +2 -0
- package/README.md +43 -47
- package/README.zh.md +35 -50
- package/assets/font-subset.json +70 -0
- package/assets/font-subset.wasm +0 -0
- package/lib/browser/assets.json +10 -0
- package/lib/browser/index.js +435 -0
- package/lib/browser/types/connection.d.ts +20 -0
- package/lib/browser/types/editor-engine.d.ts +50 -0
- package/lib/browser/types/editor-types.d.ts +141 -0
- package/lib/browser/types/editor.d.ts +9 -0
- package/lib/browser/types/engine-rendering.d.ts +3 -0
- package/lib/browser/types/engine-types.d.ts +17 -0
- package/lib/browser/types/font-channel.d.ts +20 -0
- package/lib/browser/types/index.d.ts +13 -0
- package/lib/browser/types/protocol.d.ts +117 -0
- package/lib/browser/types/rendering.d.ts +4 -0
- package/lib/browser/types/types.d.ts +90 -0
- package/lib/browser/types/worker.d.ts +2 -0
- package/lib/browser/worker.js +3711 -0
- package/lib/browser-assets.js +119 -0
- package/lib/cli.js +1303 -0
- package/lib/document.js +178 -0
- package/lib/engine-rendering.js +120 -0
- package/lib/font-config.js +46 -0
- package/lib/font-source.js +344 -0
- package/lib/font-worker.js +712 -0
- package/lib/index.js +319 -109
- package/lib/rendering.js +99 -0
- package/lib/sheet-geometry.js +111 -0
- package/lib/types/browser-assets.d.ts +15 -0
- package/lib/types/cli.d.ts +3 -0
- package/lib/types/document.d.ts +1 -1
- package/lib/types/engine-rendering.d.ts +15 -0
- package/lib/types/engine.d.ts +5 -5
- package/lib/types/font-config.d.ts +24 -0
- package/lib/types/font-full.d.ts +13 -0
- package/lib/types/font-loader.d.ts +1 -7
- package/lib/types/font-request.d.ts +12 -0
- package/lib/types/font-source-types.d.ts +82 -0
- package/lib/types/font-source.d.ts +10 -0
- package/lib/types/font-subsets.d.ts +35 -0
- package/lib/types/font-worker.d.ts +2 -0
- package/lib/types/fonts.d.ts +9 -29
- package/lib/types/harfbuzz-subset.d.ts +11 -0
- package/lib/types/image-operations.d.ts +58 -0
- package/lib/types/image-renderer.d.ts +6 -0
- package/lib/types/index.d.ts +25 -2
- package/lib/types/native.d.ts +4 -2
- package/lib/types/operations.d.ts +41 -0
- package/lib/types/png.d.ts +2 -0
- package/lib/types/profile.d.ts +8 -0
- package/lib/types/rendering.d.ts +41 -0
- package/lib/types/runtime.d.ts +14 -0
- package/lib/types/sheet-geometry.d.ts +38 -0
- package/lib/types/unicode-scripts.d.ts +18 -0
- package/lib/types/wasm.d.ts +76 -1
- package/lib/types/worker.d.ts +3 -0
- package/lib/worker.js +1012 -237
- package/licenses/font-subset/harfbuzz-COPYING +42 -0
- package/licenses/font-subset/harfbuzzjs-LICENSE +19 -0
- package/licenses/javascript/fflate-LICENSE +21 -0
- package/licenses/javascript/saxes-LICENSE +64 -0
- package/licenses/javascript/xmlchars-LICENSE +18 -0
- package/package.json +59 -12
- package/sources/browser/packages/browser/package.json +22 -0
- package/sources/browser/packages/browser/src/connection.ts +168 -0
- package/sources/browser/packages/browser/src/editor-engine.ts +382 -0
- package/sources/browser/packages/browser/src/editor-types.ts +106 -0
- package/sources/browser/packages/browser/src/editor.ts +55 -0
- package/sources/browser/packages/browser/src/engine-rendering.ts +2 -0
- package/sources/browser/packages/browser/src/engine-types.ts +14 -0
- package/sources/browser/packages/browser/src/font-channel.ts +99 -0
- package/sources/browser/packages/browser/src/index.ts +39 -0
- package/sources/browser/packages/browser/src/protocol.ts +40 -0
- package/sources/browser/packages/browser/src/rendering.ts +3 -0
- package/sources/browser/packages/browser/src/types.ts +92 -0
- package/sources/browser/packages/browser/src/worker.ts +171 -0
- package/sources/browser/packages/browser/tsconfig.json +5 -0
- package/sources/browser/packages/browser/tsdown.config.ts +7 -0
- package/sources/browser/scripts/build-browser.mjs +74 -0
- package/sources/font-subset/engine/font-subset/README.md +23 -0
- package/sources/font-subset/engine/font-subset/README.zh.md +23 -0
- package/sources/font-subset/engine/font-subset/source.json +16 -0
- package/sources/font-subset/harfbuzzjs/config-override-subset.h +7 -0
- package/sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols +34 -0
- package/sources/font-subset/scripts/build-font-subset.mjs +64 -0
- package/sources/font-subset/scripts/pack-utils.mjs +69 -0
- package/sources/font-subset/scripts/platform-matrix.mjs +100 -0
- package/sources/font-subset/scripts/verify-artifacts.mjs +260 -0
package/NOTICE
CHANGED
|
@@ -24,3 +24,5 @@ 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/.
|
package/README.md
CHANGED
|
@@ -1,73 +1,69 @@
|
|
|
1
1
|
# @deepseek-ai/libreoffice-kit
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```ts
|
|
6
|
+
import { createConverter, discoverRuntime } from '@deepseek-ai/libreoffice-kit'
|
|
6
7
|
|
|
7
|
-
|
|
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.1
|
|
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 });
|
|
8
|
+
const converter = await createConverter({ timeoutMs: 120_000 })
|
|
23
9
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
|
|
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' })
|
|
29
16
|
} finally {
|
|
30
|
-
await converter.dispose()
|
|
17
|
+
await converter.dispose()
|
|
31
18
|
}
|
|
19
|
+
const runtime = await discoverRuntime() // installed CLI and API paths; no engine start
|
|
32
20
|
```
|
|
33
21
|
|
|
34
|
-
|
|
22
|
+
## Direct image rendering
|
|
35
23
|
|
|
36
|
-
|
|
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.
|
|
37
25
|
|
|
38
|
-
|
|
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`.
|
|
39
32
|
|
|
40
|
-
|
|
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.
|
|
41
34
|
|
|
42
|
-
|
|
35
|
+
## CLI and conversions
|
|
43
36
|
|
|
44
|
-
|
|
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
|
+
```
|
|
45
46
|
|
|
46
|
-
|
|
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`.
|
|
47
48
|
|
|
48
|
-
|
|
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.
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
## Fonts and PDF scope
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
Node operations use bounded system-font discovery. Exact installed families precede configured fallbacks; full original font files retain shaping and encoding. Recreate the converter after changing installed fonts. `missingFonts` covers named families in readable OOXML metadata, not all missing glyphs or PDF font diagnostics.
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
`createFontSource` from `@deepseek-ai/libreoffice-kit/fonts` provides an independent lazy Worker service. `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.
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
PDFium is an experimental direct raster path, separate from PDF.js and editable Office models. 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.
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
## Browser and font entries
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
`@deepseek-ai/libreoffice-kit/browser` provides persistent Office editing, read-only legacy Office models, PDFium viewing and consistent image capture. `@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.
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
`./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.
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
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.
|
|
65
66
|
|
|
66
|
-
##
|
|
67
|
+
## Source and license
|
|
67
68
|
|
|
68
|
-
-
|
|
69
|
-
- Only DOCX, XLSX, and PPTX input is supported. Conversion does not discover system LibreOffice or download engines and fonts.
|
|
70
|
-
- Font import and output limits do not bound all native memory or temporary disk use. Native platform engines may resolve fonts differently from WASM.
|
|
71
|
-
- Installations from npm use platform-specific optional packages. Applications that bundle engines must retain the complete selected package, including its resources and notices.
|
|
72
|
-
- 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.
|
|
73
|
-
- Version `0.0.1` ships macOS and Windows native engines for ARM64 and x64 and a shared Node WASM engine. Other native platforms are development recipes.
|
|
69
|
+
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.
|
package/README.zh.md
CHANGED
|
@@ -1,73 +1,58 @@
|
|
|
1
1
|
# @deepseek-ai/libreoffice-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node API、CLI、浏览器适配器和字体服务复用本包;精确版本依赖 `@deepseek-ai/libreoffice-kit-wasm` 提供跨平台预编译引擎。不在安装或文档操作期间编译、下载引擎或发现系统 LibreOffice。需要 Node.js 22.19 以上。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 直接输出图片
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
使用 Node.js 22.19.0 或更新版本安装:
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
npm install @deepseek-ai/libreoffice-kit@0.0.1
|
|
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 });
|
|
7
|
+
```ts
|
|
8
|
+
import { createConverter } from '@deepseek-ai/libreoffice-kit'
|
|
9
|
+
const converter = await createConverter({ timeoutMs: 120_000 })
|
|
23
10
|
try {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
console.log(result.backend, result.missingFonts);
|
|
29
|
-
} finally {
|
|
30
|
-
await converter.dispose();
|
|
31
|
-
}
|
|
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() }
|
|
32
14
|
```
|
|
33
15
|
|
|
34
|
-
|
|
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 的兼容语义。
|
|
35
17
|
|
|
36
|
-
|
|
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`。
|
|
37
24
|
|
|
38
|
-
|
|
25
|
+
调用方负责授权绝对路径并保护私有目录免受并发路径替换。输入必须是非空普通文件,输出目录必须不存在。失败、取消、超时或 dispose 会等待 Worker 退出并清理整个新批次,不删除已有目录。转换器串行执行调用;每次操作使用新 Worker,浏览器编辑复用另行保留的会话。
|
|
39
26
|
|
|
40
|
-
|
|
27
|
+
## CLI 与转换
|
|
41
28
|
|
|
42
|
-
|
|
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
|
+
```
|
|
43
37
|
|
|
44
|
-
`
|
|
38
|
+
CLI 相对路径按工作目录解析,成功在 stdout 输出一个 JSON,失败在 stderr 输出 `{code,error}` 并退出 1。SIGINT/SIGTERM 取消后等待清理。`render` 支持 `--max-pages`、`--max-pixels`、`--max-dimension`,以及通用输入/输出/归档/字体限制、`--timeout-ms`、可重复字体目录和初始 family,以及 JSON `--font-fallbacks`。
|
|
45
39
|
|
|
46
|
-
|
|
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 的公式和缓存结果,不验证业务逻辑。输出必须是新文件,宏和外部链接更新保持禁用。
|
|
47
41
|
|
|
48
|
-
|
|
42
|
+
## 字体与 PDF 范围
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
Node 端在限制范围内发现系统字体,精确 family 优先于回退配置,导入完整原始字体。安装字体改变后重新创建转换器。`missingFonts` 只报告可读 OOXML 的声明 family,不代表全部缺字或 PDF 字体诊断。
|
|
51
45
|
|
|
52
|
-
|
|
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 会拒绝读取。
|
|
53
47
|
|
|
54
|
-
|
|
48
|
+
PDFium 直接图片渲染仍为实验能力,与 PDF.js 和 Office 编辑模型分开。嵌入字体由 PDFium 管理;在首次字体枚举前,按初始 family 和回退组预载有字节上限的完整常规字体。该方案不自动推断所有 PDF 字体,也不修复任意自定义编码。加密 PDF 暂拒绝;上游包装层绘制表单,普通注释和高级 PDF 特性仍需专项验收。
|
|
55
49
|
|
|
56
|
-
|
|
50
|
+
## 浏览器与字体入口
|
|
57
51
|
|
|
58
|
-
Node
|
|
52
|
+
`@deepseek-ai/libreoffice-kit/browser` 提供常驻 Office 编辑、旧格式只读模型、PDFium 查看和一致性截图。Node 端 `./browser-assets` 校验并解析主包中的 Worker,以及精确版本 WASM 依赖中的资源。Host 将其映射成资源 URL;主包不复制 LibreOffice 大文件。
|
|
59
53
|
|
|
60
|
-
|
|
54
|
+
`./fonts` 提供上文的字体服务。`./font-config` 与 `./document-inspection` 为浏览器和 Node 共用的纯逻辑;`./internal/*` 仅用于内部实现。字体子集采用 Unicode 17 数据和 HarfBuzz 布局闭包,内存缓存淘汰后从未变化的原字体重新生成。
|
|
61
55
|
|
|
62
56
|
## 源码与许可
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## 使用限制
|
|
67
|
-
|
|
68
|
-
- 保真度取决于源格式、已安装字体和所选引擎。缺失字体名称不能报告所有缺字。
|
|
69
|
-
- 只支持 DOCX、XLSX 和 PPTX 输入。转换不发现系统 LibreOffice,也不下载引擎和字体。
|
|
70
|
-
- 字体导入和输出限制不能约束全部原生内存或临时磁盘使用。原生平台引擎的字体解析可能与 WASM 不同。
|
|
71
|
-
- npm 安装使用按平台选择的可选包。自行打包引擎的应用需要保留所选包的完整内容,包括资源和许可声明。
|
|
72
|
-
- Windows 需要系统安装与 Node.js 架构一致的 Microsoft Visual C++ v14 Redistributable(x64 或 ARM64);包中不捆绑该运行库。Windows ARM64 引擎需要使用 ARM64 Node.js。
|
|
73
|
-
- `0.0.1` 提供 macOS 和 Windows 的 ARM64、x64 原生引擎和共享 Node WASM 引擎;其他原生平台仅保留开发构建配方。
|
|
58
|
+
使用 [MPL-2.0](LICENSE)。引擎包含 `prebuilds.json` 完整性清单、`sources/` 中的固定源码与补丁配方、`licenses/` 第三方声明;字体子集器也包含自己的配方和声明。打包应用需保留这些资源。声明目标和源码测试不能代替可安装产物的真实文档验收。
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"source": {
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"algorithm": "harfbuzzjs-1.6.1-hb-36cb489-growth-v1",
|
|
6
|
+
"harfbuzzjs": {
|
|
7
|
+
"repository": "https://github.com/harfbuzz/harfbuzzjs.git",
|
|
8
|
+
"commit": "8aa047b90387790b255b118cf45ad11691a38910"
|
|
9
|
+
},
|
|
10
|
+
"harfbuzz": {
|
|
11
|
+
"repository": "https://github.com/harfbuzz/harfbuzz.git",
|
|
12
|
+
"commit": "36cb489cb02ce4b92099669ba9f9bea348eff93f"
|
|
13
|
+
},
|
|
14
|
+
"emsdk": {
|
|
15
|
+
"commit": "5eb0bde7585670252e8ba05e9d361627bffd08b5",
|
|
16
|
+
"version": "4.0.10"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"recipe": "3dbe51aba06e309bc9a8573462af1a8c93628cf325e88db7d32320fc2a9d54e8",
|
|
20
|
+
"files": {
|
|
21
|
+
"assets/font-subset.wasm": {
|
|
22
|
+
"bytes": 623142,
|
|
23
|
+
"sha256": "9714355321714323b3b15b4a8fa186269cd52a3852282251e985daf76cfe0869"
|
|
24
|
+
},
|
|
25
|
+
"sources/font-subset/engine/font-subset/source.json": {
|
|
26
|
+
"bytes": 465,
|
|
27
|
+
"sha256": "b4fb57078136a796a950c6fcf654ca1b20e3d3ee0cc342b452324b3049e69fdc"
|
|
28
|
+
},
|
|
29
|
+
"sources/font-subset/scripts/build-font-subset.mjs": {
|
|
30
|
+
"bytes": 5401,
|
|
31
|
+
"sha256": "3dbe51aba06e309bc9a8573462af1a8c93628cf325e88db7d32320fc2a9d54e8"
|
|
32
|
+
},
|
|
33
|
+
"sources/font-subset/scripts/platform-matrix.mjs": {
|
|
34
|
+
"bytes": 4810,
|
|
35
|
+
"sha256": "fb5656feafafa89e02d1217bea5e36e3fea7583f113dbda8ff50ba5c966c411b"
|
|
36
|
+
},
|
|
37
|
+
"sources/font-subset/scripts/pack-utils.mjs": {
|
|
38
|
+
"bytes": 3327,
|
|
39
|
+
"sha256": "aa5368e0dd38d90459f0ef14e1d4b27740aef2f4e46617aca6d6fafed0577a44"
|
|
40
|
+
},
|
|
41
|
+
"sources/font-subset/scripts/verify-artifacts.mjs": {
|
|
42
|
+
"bytes": 15997,
|
|
43
|
+
"sha256": "6e89c766a49aa5cb3859e25ae16cdf48e0355df53a5210061b475357709f0cec"
|
|
44
|
+
},
|
|
45
|
+
"sources/font-subset/engine/font-subset/README.md": {
|
|
46
|
+
"bytes": 2130,
|
|
47
|
+
"sha256": "9d0291dec056a36ada10fb38579b0b4bd661e44e941e0fa6bf50e35266435a46"
|
|
48
|
+
},
|
|
49
|
+
"sources/font-subset/engine/font-subset/README.zh.md": {
|
|
50
|
+
"bytes": 1972,
|
|
51
|
+
"sha256": "de8a1f7508e6f9da99162de35ba285bbb75525f522f816a074261d9e004a73eb"
|
|
52
|
+
},
|
|
53
|
+
"sources/font-subset/harfbuzzjs/config-override-subset.h": {
|
|
54
|
+
"bytes": 150,
|
|
55
|
+
"sha256": "05175e798a0f3950814af7b7915be4a6dc8a99d00f59005c702813d8d3a187e6"
|
|
56
|
+
},
|
|
57
|
+
"sources/font-subset/harfbuzzjs/harfbuzz-subset.symbols": {
|
|
58
|
+
"bytes": 755,
|
|
59
|
+
"sha256": "a17abb59f87725011902150347be9ba48f9ae6bfc5df29a906dfdef50d68387a"
|
|
60
|
+
},
|
|
61
|
+
"licenses/font-subset/harfbuzzjs-LICENSE": {
|
|
62
|
+
"bytes": 1079,
|
|
63
|
+
"sha256": "5d09767b2cc476f08028b56d9384dc45061c5a3e90f9ad966e44addc8d26c8b1"
|
|
64
|
+
},
|
|
65
|
+
"licenses/font-subset/harfbuzz-COPYING": {
|
|
66
|
+
"bytes": 1971,
|
|
67
|
+
"sha256": "ba8f810f2455c2f08e2d56bb49b72f37fcf68f1f4fade38977cfd7372050ad64"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
Binary file
|