@deepseek-ai/libreoffice-kit 0.2.0-alpha7 → 0.2.0

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/README.md CHANGED
@@ -8,14 +8,14 @@ The conversion and native preview entry points can run together in one process,
8
8
 
9
9
  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.
10
10
 
11
- The Node API version is independent of its platform engine versions. The 0.2.0-alpha7 adapter uses alpha7 macOS and Windows x64 engines, retains the Windows ARM64 0.1.5 engine, and uses a portable alpha5 WASM package containing the 0.1.5 engine files. `ENGINE_VERSION` and `discoverRuntime().version` identify the Node API; `ENGINE_VERSIONS` lists the exact compatible engine versions. `discoverRuntime().nativePreview` distinguishes native preview support from PDF conversion. Missing native packages select WASM; malformed installed packages reject.
11
+ The Node API version is independent of its platform engine versions. The 0.2.0 candidate selects 0.2.0 macOS and Windows ARM64/x64 engines and a rebuilt portable 0.2.0 WASM engine. `ENGINE_VERSION` and `discoverRuntime().version` identify the Node API; `ENGINE_VERSIONS` lists the exact compatible engine versions. `discoverRuntime().nativePreview` distinguishes native preview support from PDF conversion. Missing native packages select WASM; malformed installed packages reject.
12
12
 
13
13
  ## Installation and usage
14
14
 
15
- Use Node.js 22.19.0 or newer. This command applies after alpha7 is published; unpublished candidates must be built and qualified from source first:
15
+ Use Node.js 22.19.0 or newer. This command applies after 0.2.0 is published; unpublished candidates must be built and qualified from source first:
16
16
 
17
17
  ```sh
18
- npm install @deepseek-ai/libreoffice-kit@0.2.0-alpha7
18
+ npm install @deepseek-ai/libreoffice-kit@0.2.0
19
19
  ```
20
20
 
21
21
  npm installs the shared WASM engine and any matching native engine. The adapter prefers a compatible installed native engine, then selects WASM when no native package supports the host or the optional native package is absent. A corrupt installed package rejects with `unavailable`. Conversion failures never switch engines.
@@ -29,7 +29,7 @@ try {
29
29
  inputPath: '/private/work/document.docx',
30
30
  outputPath: '/private/work/document.pdf',
31
31
  });
32
- console.log(result.backend, result.missingFonts);
32
+ console.log(result.backend, result.missingFonts, result.pageCount);
33
33
  } finally {
34
34
  await converter.dispose();
35
35
  }
@@ -43,7 +43,7 @@ Converters created through the compatibility `createConverter(options)` API tran
43
43
 
44
44
  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.
45
45
 
46
- `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 `dsoffice capabilities|convert|recalculate|render`. Worksheet names are exact: a missing image-render selection rejects with `invalid-document`, and a missing CSV selection rejects with `failed`; neither leaves output behind. Recalculation applies to the entire workbook and rejects `--sheet`. A rejected selection leaves the converter available for subsequent operations.
46
+ `convert()` exports the format named by the output suffix. PDF results from `render()` and `convert()` include `pageCount`, read from the written PDF's page tree; an output whose trailer, catalog, or page tree is unreadable rejects with `invalid-output` and is removed. `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 `dsoffice capabilities|convert|recalculate|render`. Worksheet names are exact: a missing image-render selection rejects with `invalid-document`, and a missing CSV selection rejects with `failed`; neither leaves output behind. Recalculation applies to the entire workbook and rejects `--sheet`. A rejected selection leaves the converter available for subsequent operations.
47
47
 
48
48
  ```sh
49
49
  npm exec -- dsoffice render --input report.docx --output-dir report-pages --pages 1
package/README.zh.md CHANGED
@@ -8,14 +8,14 @@
8
8
 
9
9
  二进制 `.doc`、`.xls`、`.ppt` 输入必须是 OLE 复合文档,例如 Office 97–2003 文件。不支持改后缀的 RTF/HTML 和 `.wps`。二进制输入的 `missingFonts` 为空,因为其字体表由 LibreOffice 读取,而不是由 OOXML 检查器读取。
10
10
 
11
- Node API 与各平台引擎独立指定版本。0.2.0-alpha7 转换器使用 alpha7 的 macOS 与 Windows x64 引擎,保留 Windows ARM64 的 0.1.5 引擎,并使用包含 0.1.5 引擎文件的通用 alpha5 WASM 包。`ENGINE_VERSION` 和 `discoverRuntime().version` 表示 Node API 版本;`ENGINE_VERSIONS` 列出各平台兼容的精确引擎版本。`discoverRuntime().nativePreview` 区分原生预览与 PDF 转换能力。缺少原生包时选择 WASM;已安装的包损坏时拒绝。
11
+ Node API 与各平台引擎独立指定版本。0.2.0 candidate 指定 0.2.0 的 macOS 与 Windows ARM64/x64 引擎,并使用重新编译的通用 0.2.0 WASM 引擎。`ENGINE_VERSION` 和 `discoverRuntime().version` 表示 Node API 版本;`ENGINE_VERSIONS` 列出各平台兼容的精确引擎版本。`discoverRuntime().nativePreview` 区分原生预览与 PDF 转换能力。缺少原生包时选择 WASM;已安装的包损坏时拒绝。
12
12
 
13
13
  ## 安装与使用
14
14
 
15
- 使用 Node.js 22.19.0 或更新版本。alpha7 发布后可使用以下命令安装;未发布的候选包需先从源码构建并验证:
15
+ 使用 Node.js 22.19.0 或更新版本。0.2.0 发布后可使用以下命令安装;未发布的候选包需先从源码构建并验证:
16
16
 
17
17
  ```sh
18
- npm install @deepseek-ai/libreoffice-kit@0.2.0-alpha7
18
+ npm install @deepseek-ai/libreoffice-kit@0.2.0
19
19
  ```
20
20
 
21
21
  npm 安装共享 WASM 引擎和匹配平台的原生引擎。转换器优先使用已安装且兼容的原生引擎;平台没有原生包或可选原生包未安装时选择 WASM。已安装的包损坏时以 `unavailable` 拒绝。转换失败不会切换引擎。
@@ -29,7 +29,7 @@ try {
29
29
  inputPath: '/private/work/document.docx',
30
30
  outputPath: '/private/work/document.pdf',
31
31
  });
32
- console.log(result.backend, result.missingFonts);
32
+ console.log(result.backend, result.missingFonts, result.pageCount);
33
33
  } finally {
34
34
  await converter.dispose();
35
35
  }
@@ -43,7 +43,7 @@ try {
43
43
 
44
44
  长驻服务如果需要为多个并发转换槽提供一个显式生命周期所有者,可创建 `createConverterFactory(options)`,再通过 `factory.create()` 建立转换器。这些转换器使用 factory 私有缓存,同时仍分别拥有 Worker、原生 helper、配置目录和输出。释放 factory 会停止并等待它创建的全部转换器。
45
45
 
46
- `convert()` 按输出后缀导出格式,`recalculate()` 在保存前刷新电子表格公式结果,`renderImages()` 在全新目录中写入 PNG tile 和 `manifest.json`。Office 图像直接从一次加载的模型绘制,PDF 使用 PDFium。CLI 通过 `dsoffice capabilities|convert|recalculate|render` 提供相同行为。工作表名称按精确名称匹配:图像渲染指定不存在的工作表时返回 `invalid-document`,CSV 导出返回 `failed`,两者均不保留输出。重算作用于整个工作簿并拒绝 `--sheet`。选择失败后仍可复用转换器。
46
+ `convert()` 按输出后缀导出格式。`render()` 和 `convert()` 的 PDF 结果包含从输出 PDF 页面树读取的 `pageCount`;尾部、目录或页面树无法读取的输出返回 `invalid-output` 并被删除。`recalculate()` 在保存前刷新电子表格公式结果,`renderImages()` 在全新目录中写入 PNG tile 和 `manifest.json`。Office 图像直接从一次加载的模型绘制,PDF 使用 PDFium。CLI 通过 `dsoffice capabilities|convert|recalculate|render` 提供相同行为。工作表名称按精确名称匹配:图像渲染指定不存在的工作表时返回 `invalid-document`,CSV 导出返回 `failed`,两者均不保留输出。重算作用于整个工作簿并拒绝 `--sheet`。选择失败后仍可复用转换器。
47
47
 
48
48
  ```sh
49
49
  npm exec -- dsoffice render --input report.docx --output-dir report-pages --pages 1
@@ -15,20 +15,20 @@
15
15
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
16
16
  "src/webgpu.cc": "b5d85f74d3d361ea9dc6ec9a58e66e0472e2266ade3e69f985239dc790b5b577",
17
17
  "CMakeLists.txt": "49dd087df46ca363e36aa6fb2460fb4f44a285dec0ba134d31f085b33631f646",
18
- "sdk.json": "895c95635cb80ebdfb062e585f07b479bd15db126a696a0cf7a4b4c9ea7e928e",
19
- "scripts/build.mjs": "a51bf0a1f132125c4ec9a670fc49b15333763982ad3a3667a865bff01a058240",
18
+ "sdk.json": "f3132544d8d2a6a7cf1ff6507fe6379951a31fe05d3e64d437ab8c4844e7741e",
19
+ "scripts/build.mjs": "7c88ef10d7a1da3d5a98fbd2b181ebf667a259179644f26211c45c7091884094",
20
20
  "scripts/metadata.mjs": "109412567d73de396c6ad01ce1fcf7191b515551461b70d8900fa0774ff45a30",
21
21
  "scripts/source-identity.mjs": "021b2e62a9f986b7557e1eb0d7cdacaab87eeafd9fe84e939be33e82ade9281f",
22
22
  "scripts/build-webgpu.mjs": "7e84378707dc2dc5ef2a5e79c832df1fd38bda641f1ee779baa247553e8b7535",
23
23
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
24
24
  },
25
- "sourceCommit": "3f315f04d021fc3af7c3efc2265d922fa00ab1bc",
25
+ "sourceCommit": "006996e72b1d6d134d1e284662a7ca28a8a6691b",
26
26
  "sourceDirty": false,
27
- "version": "0.2.0-alpha7",
27
+ "version": "0.2.0",
28
28
  "protocolVersion": 1,
29
29
  "platform": "darwin-arm64",
30
30
  "files": {
31
- "frame-forwarding.node": "e4f0327255488c1751230ff6b11470d759394c138aaf81337d0b6c372ad702c1",
32
- "libdsh_frame_forwarding_sdk.a": "4a82da0a76f8fc113a3fa0aee6617b5824a8a6ef635e26ffd11098353c180b9d"
31
+ "frame-forwarding.node": "21504100c274c4ce3b7c677da7c6eca4ceec8e49794e12d291fabeb3768ac572",
32
+ "libdsh_frame_forwarding_sdk.a": "9b0f80513f257d9a663d95e7ce74177de9c02b310080ad6c743bc0ad7c77a58d"
33
33
  }
34
34
  }
@@ -15,20 +15,20 @@
15
15
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
16
16
  "src/webgpu.cc": "b5d85f74d3d361ea9dc6ec9a58e66e0472e2266ade3e69f985239dc790b5b577",
17
17
  "CMakeLists.txt": "49dd087df46ca363e36aa6fb2460fb4f44a285dec0ba134d31f085b33631f646",
18
- "sdk.json": "895c95635cb80ebdfb062e585f07b479bd15db126a696a0cf7a4b4c9ea7e928e",
19
- "scripts/build.mjs": "a51bf0a1f132125c4ec9a670fc49b15333763982ad3a3667a865bff01a058240",
18
+ "sdk.json": "f3132544d8d2a6a7cf1ff6507fe6379951a31fe05d3e64d437ab8c4844e7741e",
19
+ "scripts/build.mjs": "7c88ef10d7a1da3d5a98fbd2b181ebf667a259179644f26211c45c7091884094",
20
20
  "scripts/metadata.mjs": "109412567d73de396c6ad01ce1fcf7191b515551461b70d8900fa0774ff45a30",
21
21
  "scripts/source-identity.mjs": "021b2e62a9f986b7557e1eb0d7cdacaab87eeafd9fe84e939be33e82ade9281f",
22
22
  "scripts/build-webgpu.mjs": "7e84378707dc2dc5ef2a5e79c832df1fd38bda641f1ee779baa247553e8b7535",
23
23
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
24
24
  },
25
- "sourceCommit": "3f315f04d021fc3af7c3efc2265d922fa00ab1bc",
25
+ "sourceCommit": "006996e72b1d6d134d1e284662a7ca28a8a6691b",
26
26
  "sourceDirty": false,
27
- "version": "0.2.0-alpha7",
27
+ "version": "0.2.0",
28
28
  "protocolVersion": 1,
29
29
  "platform": "darwin-x64",
30
30
  "files": {
31
- "frame-forwarding.node": "44a87ee9e7460df1f8eed0b5e9ff2b32632cb62cb685541fd693738cdc641394",
32
- "libdsh_frame_forwarding_sdk.a": "f0db667851e6c3136c2834d81295c44456ef60c48e2e50d02d35af4fb35f6254"
31
+ "frame-forwarding.node": "6b787f80193e37ad366ae7184234ad9b0791d12f4680baaf17efe5e700065351",
32
+ "libdsh_frame_forwarding_sdk.a": "38e3a5309b0906ea97bd1a63d01b859c90ae605f45387f20b127db14e9edf777"
33
33
  }
34
34
  }
@@ -15,20 +15,20 @@
15
15
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
16
16
  "src/webgpu.cc": "b5d85f74d3d361ea9dc6ec9a58e66e0472e2266ade3e69f985239dc790b5b577",
17
17
  "CMakeLists.txt": "49dd087df46ca363e36aa6fb2460fb4f44a285dec0ba134d31f085b33631f646",
18
- "sdk.json": "895c95635cb80ebdfb062e585f07b479bd15db126a696a0cf7a4b4c9ea7e928e",
19
- "scripts/build.mjs": "a51bf0a1f132125c4ec9a670fc49b15333763982ad3a3667a865bff01a058240",
18
+ "sdk.json": "f3132544d8d2a6a7cf1ff6507fe6379951a31fe05d3e64d437ab8c4844e7741e",
19
+ "scripts/build.mjs": "7c88ef10d7a1da3d5a98fbd2b181ebf667a259179644f26211c45c7091884094",
20
20
  "scripts/metadata.mjs": "109412567d73de396c6ad01ce1fcf7191b515551461b70d8900fa0774ff45a30",
21
21
  "scripts/source-identity.mjs": "021b2e62a9f986b7557e1eb0d7cdacaab87eeafd9fe84e939be33e82ade9281f",
22
22
  "scripts/build-webgpu.mjs": "7e84378707dc2dc5ef2a5e79c832df1fd38bda641f1ee779baa247553e8b7535",
23
23
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
24
24
  },
25
- "sourceCommit": "3f315f04d021fc3af7c3efc2265d922fa00ab1bc",
25
+ "sourceCommit": "006996e72b1d6d134d1e284662a7ca28a8a6691b",
26
26
  "sourceDirty": false,
27
- "version": "0.2.0-alpha7",
27
+ "version": "0.2.0",
28
28
  "protocolVersion": 1,
29
29
  "platform": "win32-arm64",
30
30
  "files": {
31
- "frame-forwarding.node": "6c6c300856701bde88a6ad5beeb5d8ef3dc068f6b460863a81e066ef657c42b7",
32
- "dsh_frame_forwarding_sdk.lib": "e076b57cf0cd0610346d9126b0549ca763a5c8d5e706b8a8fbf6ce4c77c99e47"
31
+ "frame-forwarding.node": "de00e1254bb3127e13adbf6d254eebd758faec1a58bf23822660c86d5ec221ff",
32
+ "dsh_frame_forwarding_sdk.lib": "d083b8b167afe017de4e6f3a8b67dd81de8d03b89dc2e47ddd487af7e4077588"
33
33
  }
34
34
  }
@@ -15,20 +15,20 @@
15
15
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
16
16
  "src/webgpu.cc": "b5d85f74d3d361ea9dc6ec9a58e66e0472e2266ade3e69f985239dc790b5b577",
17
17
  "CMakeLists.txt": "49dd087df46ca363e36aa6fb2460fb4f44a285dec0ba134d31f085b33631f646",
18
- "sdk.json": "895c95635cb80ebdfb062e585f07b479bd15db126a696a0cf7a4b4c9ea7e928e",
19
- "scripts/build.mjs": "a51bf0a1f132125c4ec9a670fc49b15333763982ad3a3667a865bff01a058240",
18
+ "sdk.json": "f3132544d8d2a6a7cf1ff6507fe6379951a31fe05d3e64d437ab8c4844e7741e",
19
+ "scripts/build.mjs": "7c88ef10d7a1da3d5a98fbd2b181ebf667a259179644f26211c45c7091884094",
20
20
  "scripts/metadata.mjs": "109412567d73de396c6ad01ce1fcf7191b515551461b70d8900fa0774ff45a30",
21
21
  "scripts/source-identity.mjs": "021b2e62a9f986b7557e1eb0d7cdacaab87eeafd9fe84e939be33e82ade9281f",
22
22
  "scripts/build-webgpu.mjs": "7e84378707dc2dc5ef2a5e79c832df1fd38bda641f1ee779baa247553e8b7535",
23
23
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
24
24
  },
25
- "sourceCommit": "3f315f04d021fc3af7c3efc2265d922fa00ab1bc",
25
+ "sourceCommit": "006996e72b1d6d134d1e284662a7ca28a8a6691b",
26
26
  "sourceDirty": false,
27
- "version": "0.2.0-alpha7",
27
+ "version": "0.2.0",
28
28
  "protocolVersion": 1,
29
29
  "platform": "win32-x64",
30
30
  "files": {
31
- "frame-forwarding.node": "84b16c8e1dcc4adc8b1774a0d7c00ee82af2918aea5125c861a1e23951bb4e51",
32
- "dsh_frame_forwarding_sdk.lib": "bae6ebb2f7be0ffe0a7853d85dafb993d143262edcc3c44f9e513df75e4a8edb"
31
+ "frame-forwarding.node": "0095352456c73221531d2304c31cbe4e12a110a2c27a8a01576d0b8d97770f54",
32
+ "dsh_frame_forwarding_sdk.lib": "a9120a095c66367ad3dbdc8399005ccc02407434dff9d6e0d897254ef9c3e12a"
33
33
  }
34
34
  }
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "package": "@deepseek-ai/libreoffice-kit",
3
- "version": "0.2.0-alpha7",
3
+ "version": "0.2.0",
4
4
  "protocolVersion": 1,
5
5
  "files": {
6
6
  "LICENSE": "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
7
7
  "CMakeLists.txt": "49dd087df46ca363e36aa6fb2460fb4f44a285dec0ba134d31f085b33631f646",
8
- "sdk.json": "895c95635cb80ebdfb062e585f07b479bd15db126a696a0cf7a4b4c9ea7e928e",
8
+ "sdk.json": "f3132544d8d2a6a7cf1ff6507fe6379951a31fe05d3e64d437ab8c4844e7741e",
9
9
  "scripts/metadata.mjs": "109412567d73de396c6ad01ce1fcf7191b515551461b70d8900fa0774ff45a30",
10
10
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2",
11
11
  "scripts/build-webgpu.mjs": "7e84378707dc2dc5ef2a5e79c832df1fd38bda641f1ee779baa247553e8b7535",
@@ -26,7 +26,8 @@ const run = (command, args) => {
26
26
  if (process.platform === 'darwin') {
27
27
  const common = ['-arch', arch === 'x64' ? 'x86_64' : 'arm64', '-mmacosx-version-min=11.0', '-std=c++17', '-O2', '-fPIC', '-Iinclude', '-Isrc', '-Wall', '-Wextra'];
28
28
  const libs = ['-framework', 'IOSurface', '-framework', 'CoreFoundation', '-lbsm'];
29
- run('clang++', [...common, '-I' + nodeInclude, '-DNAPI_VERSION=8', '-DNODE_GYP_MODULE_NAME=dsh_frame_forwarding', '-shared', '-undefined', 'dynamic_lookup', 'src/receiver.cc', 'src/node-producer.cc', 'src/producer.cc', 'src/transport.cc', ...libs, '-o', resolve(output, 'frame-forwarding.node')]);
29
+ run('clang++', [...common, '-I' + nodeInclude, '-DNAPI_VERSION=8', '-DNODE_GYP_MODULE_NAME=dsh_frame_forwarding', '-shared', '-undefined', 'dynamic_lookup', '-Wl,-install_name,@rpath/frame-forwarding.node', 'src/receiver.cc', 'src/node-producer.cc', 'src/producer.cc', 'src/transport.cc', ...libs, '-o', resolve(output, 'frame-forwarding.node')]);
30
+ run('codesign', ['--force', '--sign', '-', resolve(output, 'frame-forwarding.node')]);
30
31
  for (const source of ['producer', 'transport']) run('clang++', [...common, '-c', `src/${source}.cc`, '-o', resolve(output, `${source}.o`)]);
31
32
  run('ar', ['rcs', resolve(output, 'libdsh_frame_forwarding_sdk.a'), resolve(output, 'producer.o'), resolve(output, 'transport.o')]);
32
33
  } else if (process.platform === 'win32') {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.0-alpha7",
2
+ "version": "0.2.0",
3
3
  "protocolVersion": 1,
4
4
  "header": "include/dsh_frame_forwarding.h",
5
5
  "sources": [
package/lib/cli.js CHANGED
@@ -779,7 +779,7 @@ async function prepareNativeEngine(engine, profile) {
779
779
  const root = join(profile, "engine");
780
780
  await symlink(engine.root, root, "junction");
781
781
  try {
782
- const executable = join(profile, "libreoffice-kit.exe");
782
+ const executable = join(profile, "dsoffice.exe");
783
783
  await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
784
784
  return {
785
785
  engine: {
@@ -1537,16 +1537,16 @@ function resolveOptions(input = {}) {
1537
1537
  /** Resolve installed, version-matched engine packages without downloads or compilation. */
1538
1538
  const require = createRequire(import.meta.url);
1539
1539
  /** Node API release version returned by runtime discovery. */
1540
- const ENGINE_VERSION = "0.2.0-alpha7";
1540
+ const ENGINE_VERSION = "0.2.0";
1541
1541
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
1542
1542
  const ENGINE_VERSIONS = Object.freeze({
1543
- "darwin-arm64": "0.2.0-alpha7",
1544
- "darwin-x64": "0.2.0-alpha7",
1543
+ "darwin-arm64": "0.2.0",
1544
+ "darwin-x64": "0.2.0",
1545
1545
  "linux-arm64-glibc": "0.1.1",
1546
1546
  "linux-x64-glibc": "0.1.1",
1547
- "win32-arm64": "0.1.5",
1548
- "win32-x64": "0.2.0-alpha7",
1549
- wasm: "0.2.0-alpha5"
1547
+ "win32-arm64": "0.2.0",
1548
+ "win32-x64": "0.2.0",
1549
+ wasm: "0.2.0"
1550
1550
  });
1551
1551
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
1552
1552
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
@@ -1739,6 +1739,75 @@ function validateOutput(bytes, format) {
1739
1739
  ].includes(format) && (bytes[0] !== 80 || bytes[1] !== 75 || bytes[2] !== 3 || bytes[3] !== 4)) throw new ConversionError("invalid-output", `LibreOffice did not produce a ${format} archive.`);
1740
1740
  }
1741
1741
  //#endregion
1742
+ //#region lib/types/pdf.js
1743
+ /** Page count of exported PDFs, read from the cross-reference table and page tree that LibreOffice writes. */
1744
+ /** LibreOffice ends each export with `startxref`, its byte offset, and `%%EOF`. */
1745
+ const TRAILER_WINDOW_BYTES = 1024;
1746
+ function unreadable(reason) {
1747
+ return new ConversionError("invalid-output", `LibreOffice produced a PDF without a readable page tree: ${reason}.`);
1748
+ }
1749
+ function crossReferences(pdf, offset, end) {
1750
+ const tokens = pdf.toString("latin1", offset, end).trim().split(/\s+/u);
1751
+ if (tokens[0] !== "xref") throw unreadable("startxref does not point to a cross-reference table");
1752
+ const offsets = /* @__PURE__ */ new Map();
1753
+ for (let index = 1; index < tokens.length;) {
1754
+ const first = Number(tokens[index]);
1755
+ const count = Number(tokens[index + 1]);
1756
+ index += 2;
1757
+ if (!Number.isSafeInteger(first) || !Number.isSafeInteger(count) || count < 0 || index + count * 3 > tokens.length) throw unreadable("a cross-reference subsection is malformed");
1758
+ for (let entry = 0; entry < count; entry++, index += 3) {
1759
+ const [position, generation, kind] = [
1760
+ tokens[index],
1761
+ tokens[index + 1],
1762
+ tokens[index + 2]
1763
+ ];
1764
+ if (!/^\d{10}$/u.test(position) || !/^\d{5}$/u.test(generation) || kind !== "n" && kind !== "f") throw unreadable("a cross-reference entry is malformed");
1765
+ if (kind === "n") offsets.set(`${first + entry} ${Number(generation)}`, Number(position));
1766
+ }
1767
+ }
1768
+ return offsets;
1769
+ }
1770
+ function reference(dictionary, key) {
1771
+ const match = new RegExp(`/${key}\\s+(\\d+)\\s+(\\d+)\\s+R\\b`, "u").exec(dictionary);
1772
+ return match === null ? void 0 : `${Number(match[1])} ${Number(match[2])}`;
1773
+ }
1774
+ function indirectObject(pdf, offsets, target) {
1775
+ const offset = offsets.get(target);
1776
+ const end = offset === void 0 ? -1 : pdf.indexOf("endobj", offset, "latin1");
1777
+ const header = end < 0 ? null : /^(\d+)\s+(\d+)\s+obj\b/u.exec(pdf.toString("latin1", offset, end));
1778
+ if (header === null || `${Number(header[1])} ${Number(header[2])}` !== target) throw unreadable(`object ${target} is not at a cross-reference offset`);
1779
+ return header.input;
1780
+ }
1781
+ /**
1782
+ * Read the page count of one complete PDF written by LibreOffice export.
1783
+ * Accepts the classic cross-reference table and uncompressed catalog and page-tree objects LibreOffice writes; rejects
1784
+ * truncated files, cross-reference streams, and references the table does not resolve.
1785
+ * @param bytes - Complete PDF output.
1786
+ * @returns The direct `/Count` of the catalog's root page tree.
1787
+ * @throws ConversionError `invalid-output` when the trailer, catalog, or page tree cannot be read.
1788
+ */
1789
+ function pdfPageCount(bytes) {
1790
+ const pdf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1791
+ const windowStart = Math.max(0, pdf.length - TRAILER_WINDOW_BYTES);
1792
+ const tail = /startxref\s+(\d+)\s+%%EOF\s*$/u.exec(pdf.toString("latin1", windowStart));
1793
+ if (tail === null) throw unreadable("the file does not end with startxref and %%EOF");
1794
+ const startxref = windowStart + tail.index;
1795
+ const table = Number(tail[1]);
1796
+ const trailer = pdf.subarray(0, startxref).indexOf("trailer", table, "latin1");
1797
+ if (trailer < 0) throw unreadable("startxref does not precede a trailer");
1798
+ const offsets = crossReferences(pdf, table, trailer);
1799
+ const root = reference(pdf.toString("latin1", trailer, startxref), "Root");
1800
+ if (root === void 0) throw unreadable("the trailer has no /Root reference");
1801
+ const catalog = indirectObject(pdf, offsets, root);
1802
+ const pagesReference = /\/Type\s*\/Catalog\b/u.test(catalog) ? reference(catalog, "Pages") : void 0;
1803
+ if (pagesReference === void 0) throw unreadable("/Root is not a catalog with a /Pages reference");
1804
+ const pages = indirectObject(pdf, offsets, pagesReference);
1805
+ const count = /\/Type\s*\/Pages\b/u.test(pages) ? /\/Count\s+(\d+)\b(?!\s+\d+\s+R\b)/u.exec(pages) : null;
1806
+ const value = count === null ? NaN : Number(count[1]);
1807
+ if (!Number.isSafeInteger(value)) throw unreadable("the root page tree has no direct /Count");
1808
+ return value;
1809
+ }
1810
+ //#endregion
1742
1811
  //#region lib/types/runtime.js
1743
1812
  /** Offline discovery of the installed engine and public entry points. */
1744
1813
  /**
@@ -2067,6 +2136,7 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
2067
2136
  bytes = await readBounded(path, resolvedOptions.maxOutputBytes, stopped, "output");
2068
2137
  }
2069
2138
  validateOutput(bytes, format);
2139
+ const pageCount = format === "pdf" ? pdfPageCount(bytes) : void 0;
2070
2140
  await validateFontSnapshot(fonts);
2071
2141
  stopped.throwIfAborted();
2072
2142
  await output.writeFile(bytes);
@@ -2074,7 +2144,8 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
2074
2144
  succeeded = true;
2075
2145
  return {
2076
2146
  backend: engine.backend,
2077
- missingFonts: result.missingFonts
2147
+ missingFonts: result.missingFonts,
2148
+ ...pageCount === void 0 ? {} : { pageCount }
2078
2149
  };
2079
2150
  } catch (error) {
2080
2151
  failure = error;
package/lib/editor.js CHANGED
@@ -474,13 +474,13 @@ function resolveOptions(input = {}) {
474
474
  const require = createRequire(import.meta.url);
475
475
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
476
476
  const ENGINE_VERSIONS = Object.freeze({
477
- "darwin-arm64": "0.2.0-alpha7",
478
- "darwin-x64": "0.2.0-alpha7",
477
+ "darwin-arm64": "0.2.0",
478
+ "darwin-x64": "0.2.0",
479
479
  "linux-arm64-glibc": "0.1.1",
480
480
  "linux-x64-glibc": "0.1.1",
481
- "win32-arm64": "0.1.5",
482
- "win32-x64": "0.2.0-alpha7",
483
- wasm: "0.2.0-alpha5"
481
+ "win32-arm64": "0.2.0",
482
+ "win32-x64": "0.2.0",
483
+ wasm: "0.2.0"
484
484
  });
485
485
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
486
486
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
@@ -1424,7 +1424,7 @@ async function prepareNativeEngine(engine, profile) {
1424
1424
  const root = join(profile, "engine");
1425
1425
  await symlink(engine.root, root, "junction");
1426
1426
  try {
1427
- const executable = join(profile, "libreoffice-kit.exe");
1427
+ const executable = join(profile, "dsoffice.exe");
1428
1428
  await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
1429
1429
  return {
1430
1430
  engine: {
package/lib/index.js CHANGED
@@ -777,7 +777,7 @@ async function prepareNativeEngine(engine, profile) {
777
777
  const root = join(profile, "engine");
778
778
  await symlink(engine.root, root, "junction");
779
779
  try {
780
- const executable = join(profile, "libreoffice-kit.exe");
780
+ const executable = join(profile, "dsoffice.exe");
781
781
  await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
782
782
  return {
783
783
  engine: {
@@ -1535,16 +1535,16 @@ function resolveOptions(input = {}) {
1535
1535
  /** Resolve installed, version-matched engine packages without downloads or compilation. */
1536
1536
  const require = createRequire(import.meta.url);
1537
1537
  /** Node API release version returned by runtime discovery. */
1538
- const ENGINE_VERSION = "0.2.0-alpha7";
1538
+ const ENGINE_VERSION = "0.2.0";
1539
1539
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
1540
1540
  const ENGINE_VERSIONS = Object.freeze({
1541
- "darwin-arm64": "0.2.0-alpha7",
1542
- "darwin-x64": "0.2.0-alpha7",
1541
+ "darwin-arm64": "0.2.0",
1542
+ "darwin-x64": "0.2.0",
1543
1543
  "linux-arm64-glibc": "0.1.1",
1544
1544
  "linux-x64-glibc": "0.1.1",
1545
- "win32-arm64": "0.1.5",
1546
- "win32-x64": "0.2.0-alpha7",
1547
- wasm: "0.2.0-alpha5"
1545
+ "win32-arm64": "0.2.0",
1546
+ "win32-x64": "0.2.0",
1547
+ wasm: "0.2.0"
1548
1548
  });
1549
1549
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
1550
1550
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
@@ -1737,6 +1737,75 @@ function validateOutput(bytes, format) {
1737
1737
  ].includes(format) && (bytes[0] !== 80 || bytes[1] !== 75 || bytes[2] !== 3 || bytes[3] !== 4)) throw new ConversionError("invalid-output", `LibreOffice did not produce a ${format} archive.`);
1738
1738
  }
1739
1739
  //#endregion
1740
+ //#region lib/types/pdf.js
1741
+ /** Page count of exported PDFs, read from the cross-reference table and page tree that LibreOffice writes. */
1742
+ /** LibreOffice ends each export with `startxref`, its byte offset, and `%%EOF`. */
1743
+ const TRAILER_WINDOW_BYTES = 1024;
1744
+ function unreadable(reason) {
1745
+ return new ConversionError("invalid-output", `LibreOffice produced a PDF without a readable page tree: ${reason}.`);
1746
+ }
1747
+ function crossReferences(pdf, offset, end) {
1748
+ const tokens = pdf.toString("latin1", offset, end).trim().split(/\s+/u);
1749
+ if (tokens[0] !== "xref") throw unreadable("startxref does not point to a cross-reference table");
1750
+ const offsets = /* @__PURE__ */ new Map();
1751
+ for (let index = 1; index < tokens.length;) {
1752
+ const first = Number(tokens[index]);
1753
+ const count = Number(tokens[index + 1]);
1754
+ index += 2;
1755
+ if (!Number.isSafeInteger(first) || !Number.isSafeInteger(count) || count < 0 || index + count * 3 > tokens.length) throw unreadable("a cross-reference subsection is malformed");
1756
+ for (let entry = 0; entry < count; entry++, index += 3) {
1757
+ const [position, generation, kind] = [
1758
+ tokens[index],
1759
+ tokens[index + 1],
1760
+ tokens[index + 2]
1761
+ ];
1762
+ if (!/^\d{10}$/u.test(position) || !/^\d{5}$/u.test(generation) || kind !== "n" && kind !== "f") throw unreadable("a cross-reference entry is malformed");
1763
+ if (kind === "n") offsets.set(`${first + entry} ${Number(generation)}`, Number(position));
1764
+ }
1765
+ }
1766
+ return offsets;
1767
+ }
1768
+ function reference(dictionary, key) {
1769
+ const match = new RegExp(`/${key}\\s+(\\d+)\\s+(\\d+)\\s+R\\b`, "u").exec(dictionary);
1770
+ return match === null ? void 0 : `${Number(match[1])} ${Number(match[2])}`;
1771
+ }
1772
+ function indirectObject(pdf, offsets, target) {
1773
+ const offset = offsets.get(target);
1774
+ const end = offset === void 0 ? -1 : pdf.indexOf("endobj", offset, "latin1");
1775
+ const header = end < 0 ? null : /^(\d+)\s+(\d+)\s+obj\b/u.exec(pdf.toString("latin1", offset, end));
1776
+ if (header === null || `${Number(header[1])} ${Number(header[2])}` !== target) throw unreadable(`object ${target} is not at a cross-reference offset`);
1777
+ return header.input;
1778
+ }
1779
+ /**
1780
+ * Read the page count of one complete PDF written by LibreOffice export.
1781
+ * Accepts the classic cross-reference table and uncompressed catalog and page-tree objects LibreOffice writes; rejects
1782
+ * truncated files, cross-reference streams, and references the table does not resolve.
1783
+ * @param bytes - Complete PDF output.
1784
+ * @returns The direct `/Count` of the catalog's root page tree.
1785
+ * @throws ConversionError `invalid-output` when the trailer, catalog, or page tree cannot be read.
1786
+ */
1787
+ function pdfPageCount(bytes) {
1788
+ const pdf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
1789
+ const windowStart = Math.max(0, pdf.length - TRAILER_WINDOW_BYTES);
1790
+ const tail = /startxref\s+(\d+)\s+%%EOF\s*$/u.exec(pdf.toString("latin1", windowStart));
1791
+ if (tail === null) throw unreadable("the file does not end with startxref and %%EOF");
1792
+ const startxref = windowStart + tail.index;
1793
+ const table = Number(tail[1]);
1794
+ const trailer = pdf.subarray(0, startxref).indexOf("trailer", table, "latin1");
1795
+ if (trailer < 0) throw unreadable("startxref does not precede a trailer");
1796
+ const offsets = crossReferences(pdf, table, trailer);
1797
+ const root = reference(pdf.toString("latin1", trailer, startxref), "Root");
1798
+ if (root === void 0) throw unreadable("the trailer has no /Root reference");
1799
+ const catalog = indirectObject(pdf, offsets, root);
1800
+ const pagesReference = /\/Type\s*\/Catalog\b/u.test(catalog) ? reference(catalog, "Pages") : void 0;
1801
+ if (pagesReference === void 0) throw unreadable("/Root is not a catalog with a /Pages reference");
1802
+ const pages = indirectObject(pdf, offsets, pagesReference);
1803
+ const count = /\/Type\s*\/Pages\b/u.test(pages) ? /\/Count\s+(\d+)\b(?!\s+\d+\s+R\b)/u.exec(pages) : null;
1804
+ const value = count === null ? NaN : Number(count[1]);
1805
+ if (!Number.isSafeInteger(value)) throw unreadable("the root page tree has no direct /Count");
1806
+ return value;
1807
+ }
1808
+ //#endregion
1740
1809
  //#region lib/types/runtime.js
1741
1810
  /** Offline discovery of the installed engine and public entry points. */
1742
1811
  /**
@@ -2065,6 +2134,7 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
2065
2134
  bytes = await readBounded(path, resolvedOptions.maxOutputBytes, stopped, "output");
2066
2135
  }
2067
2136
  validateOutput(bytes, format);
2137
+ const pageCount = format === "pdf" ? pdfPageCount(bytes) : void 0;
2068
2138
  await validateFontSnapshot(fonts);
2069
2139
  stopped.throwIfAborted();
2070
2140
  await output.writeFile(bytes);
@@ -2072,7 +2142,8 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
2072
2142
  succeeded = true;
2073
2143
  return {
2074
2144
  backend: engine.backend,
2075
- missingFonts: result.missingFonts
2145
+ missingFonts: result.missingFonts,
2146
+ ...pageCount === void 0 ? {} : { pageCount }
2076
2147
  };
2077
2148
  } catch (error) {
2078
2149
  failure = error;
@@ -1,5 +1,5 @@
1
1
  /** Node API release version returned by runtime discovery. */
2
- export declare const ENGINE_VERSION = "0.2.0-alpha7";
2
+ export declare const ENGINE_VERSION = "0.2.0";
3
3
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
4
4
  export declare const ENGINE_VERSIONS: Readonly<Record<string, string>>;
5
5
  /** Host diagnostic fields used to identify the runtime glibc version. */
@@ -49,6 +49,8 @@ export interface RenderResult {
49
49
  readonly backend: 'native' | 'wasm';
50
50
  /** Declared OOXML families no installed font provides; binary formats return an empty list. */
51
51
  readonly missingFonts: string[];
52
+ /** Pages in the written PDF's page tree; present exactly when the output is PDF. */
53
+ readonly pageCount?: number;
52
54
  }
53
55
  /** A converter serializes document operations; cancellation and disposal await process/worker exit. */
54
56
  export interface Converter {
@@ -59,7 +61,7 @@ export interface Converter {
59
61
  * Rejects existing output paths; removes a newly created output on failure or cancellation.
60
62
  * @param request - Absolute paths. Input suffixes are listed in CONVERSION_FORMATS.
61
63
  * @param signal - Optional cancellation, including while queued.
62
- * @returns Engine choice and missing declared font families.
64
+ * @returns Engine choice, missing declared font families, and the PDF page count.
63
65
  */
64
66
  render(request: {
65
67
  inputPath: string;
@@ -70,7 +72,7 @@ export interface Converter {
70
72
  * Failure/cancellation removes the complete batch. The manifest describes one saved input snapshot.
71
73
  */
72
74
  renderImages(request: RenderImagesRequest, signal?: AbortSignal): Promise<RenderImagesResult>;
73
- /** Convert to the output extension; CSV requires a sheet for multi-sheet inputs. */
75
+ /** Convert to the output extension; CSV requires a sheet for multi-sheet inputs. PDF results include `pageCount`. */
74
76
  convert(request: ConversionRequest, signal?: AbortSignal): Promise<RenderResult>;
75
77
  /**
76
78
  * Recalculate the entire workbook synchronously and save formulas with refreshed cached results.
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Read the page count of one complete PDF written by LibreOffice export.
3
+ * Accepts the classic cross-reference table and uncompressed catalog and page-tree objects LibreOffice writes; rejects
4
+ * truncated files, cross-reference streams, and references the table does not resolve.
5
+ * @param bytes - Complete PDF output.
6
+ * @returns The direct `/Count` of the catalog's root page tree.
7
+ * @throws ConversionError `invalid-output` when the trailer, catalog, or page tree cannot be read.
8
+ */
9
+ export declare function pdfPageCount(bytes: Uint8Array): number;
10
+ //# sourceMappingURL=pdf.d.ts.map
package/lib/worker.js CHANGED
@@ -675,7 +675,7 @@ async function withWasmSession(request, use) {
675
675
  mainScriptUrlOrBlob: engine.loader,
676
676
  locateFile(name) {
677
677
  const file = basename(name);
678
- if (file === "soffice.wasm") return engine.wasm;
678
+ if (file === "dsoffice.wasm") return engine.wasm;
679
679
  for (const asset of [
680
680
  engine.loader,
681
681
  engine.data,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/libreoffice-kit",
3
3
  "description": "Convert, recalculate, and render Office documents with prebuilt LibreOffice",
4
- "version": "0.2.0-alpha7",
4
+ "version": "0.2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -126,11 +126,11 @@
126
126
  },
127
127
  "optionalDependencies": {
128
128
  "koffi": "3.1.1",
129
- "@deepseek-ai/libreoffice-kit-darwin-arm64": "0.2.0-alpha7",
130
- "@deepseek-ai/libreoffice-kit-darwin-x64": "0.2.0-alpha7",
131
- "@deepseek-ai/libreoffice-kit-wasm": "0.2.0-alpha5",
132
- "@deepseek-ai/libreoffice-kit-win32-arm64": "0.1.5",
133
- "@deepseek-ai/libreoffice-kit-win32-x64": "0.2.0-alpha7"
129
+ "@deepseek-ai/libreoffice-kit-darwin-x64": "0.2.0",
130
+ "@deepseek-ai/libreoffice-kit-darwin-arm64": "0.2.0",
131
+ "@deepseek-ai/libreoffice-kit-wasm": "0.2.0",
132
+ "@deepseek-ai/libreoffice-kit-win32-x64": "0.2.0",
133
+ "@deepseek-ai/libreoffice-kit-win32-arm64": "0.2.0"
134
134
  },
135
135
  "bin": {
136
136
  "dsoffice": "./lib/cli.js"