@deepseek-ai/libreoffice-kit 0.1.4 → 0.1.5

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
@@ -41,7 +41,7 @@ Converters created through the compatibility `createConverter(options)` API tran
41
41
 
42
42
  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.
43
43
 
44
- `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`.
44
+ `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.
45
45
 
46
46
  ```sh
47
47
  npm exec -- dsoffice render --input report.docx --output-dir report-pages --pages 1
@@ -50,9 +50,13 @@ npm exec -- dsoffice convert --input report.docx --output report.pdf
50
50
  npm exec -- dsoffice recalculate --input budget.xlsx --output recalculated.xlsx
51
51
  ```
52
52
 
53
+ Right-to-left worksheets produce readable PNG text with column A on the right. A1 ranges and manifest rectangles retain logical column coordinates; each split tile is independently oriented for display.
54
+
53
55
  Conversion workers run the package's shipped JavaScript with an empty `execArgv`; consumer launch flags such as `--input-type=module` are not inherited.
54
56
 
55
- Windows native helpers use anonymous stdio pipes and inherit the caller's token and Job restrictions. Pipe polling does not occupy libuv worker threads while a helper waits for commands. Cancellation waits for process exit and pipe closure; this transport does not grant additional filesystem or network access.
57
+ Windows native helpers use anonymous stdio pipes and inherit the caller's token and Job restrictions. Pipe polling does not occupy libuv worker threads while a helper waits for commands. Cancellation and rejected worksheet selections wait for process exit and pipe closure, including when the protocol reader has paused stdout; this transport does not grant additional filesystem or network access.
58
+
59
+ Native conversion and image-rendering helpers disable printer enumeration and default-printer lookup with `SAL_DISABLE_PRINTERLIST=1` and `SAL_DISABLE_DEFAULTPRINTER=1`. Document previews and exports do not need a physical printer; these child-process settings prevent printer-driver dialogs and network-printer connection waits without changing the system's printer settings.
56
60
 
57
61
  On Windows, an engine executable or program path of 260 or more characters uses a temporary helper copy and a junction to the installed resources inside the private operation directory. Resources stay in their installation, and the junction remains until the helper closes. A renderer that exits before returning a protocol response rejects with its exit status and captured diagnostics.
58
62
 
package/README.zh.md CHANGED
@@ -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` 提供相同行为。
46
+ `convert()` 按输出后缀导出格式,`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
@@ -52,9 +52,13 @@ npm exec -- dsoffice convert --input report.docx --output report.pdf
52
52
  npm exec -- dsoffice recalculate --input budget.xlsx --output recalculated.xlsx
53
53
  ```
54
54
 
55
+ 从右向左排列的工作表会生成文字可正常阅读、A 列位于右侧的 PNG。A1 范围和 manifest 中的矩形仍使用逻辑列坐标;拆分后的每张 tile 均独立调整像素方向。
56
+
55
57
  转换 worker 以空的 `execArgv` 运行包内发布的 JavaScript;`--input-type=module` 之类的调用方启动参数不会被继承。
56
58
 
57
- Windows 原生 helper 使用匿名标准输入输出管道,继承调用方的令牌和 Job 限制。helper 等待命令时,管道轮询不会占用 libuv 工作线程。取消会等待进程退出和管道关闭;此传输方式不授予额外的文件系统或网络权限。
59
+ Windows 原生 helper 使用匿名标准输入输出管道,继承调用方的令牌和 Job 限制。helper 等待命令时,管道轮询不会占用 libuv 工作线程。取消及工作表选择失败均会等待进程退出和管道关闭,包括协议读取器已暂停 stdout 的情况;此传输方式不授予额外的文件系统或网络权限。
60
+
61
+ 原生转换和图片渲染 helper 设置 `SAL_DISABLE_PRINTERLIST=1` 与 `SAL_DISABLE_DEFAULTPRINTER=1`,禁用打印机枚举和默认打印机查询。文档预览和导出不需要实体打印机;这些子进程设置可避免打印机驱动弹窗及网络打印机连接等待,不会修改系统打印机设置。
58
62
 
59
63
  在 Linux 上,原生子进程会先在所选引擎的 program 目录中查找共享库,然后才查找系统路径。调用方提供的 `LD_LIBRARY_PATH` 和 `LD_PRELOAD` 不会被继承。
60
64
 
package/lib/cli.js CHANGED
@@ -140,7 +140,7 @@ function dimension(data, first, last, maximum, scale) {
140
140
  }
141
141
  return [start / scale, (position - start) / scale];
142
142
  }
143
- /** Logical columns advance from A; LOK itself mirrors RTL sheet painting. No manual x inversion. */
143
+ /** Logical columns advance from A; RTL uses the same coordinates and mirrored transport pixels. */
144
144
  function sheetRangeRectangle(geometry, range, scale) {
145
145
  if (!Number.isFinite(scale) || scale <= 0 || scale > 16) throw new TypeError("Invalid worksheet raster scale.");
146
146
  const [x, width] = dimension(geometry.columns, range.firstColumn, range.lastColumn, MAX_COLUMN, scale);
@@ -161,6 +161,17 @@ function sheetRangeRectangle(geometry, range, scale) {
161
161
  height
162
162
  };
163
163
  }
164
+ /** Undo Calc's RTL transport mirroring so saved pixels contain readable text and right-to-left columns. */
165
+ function unmirrorRtlTile({ width, height, rgba }) {
166
+ for (let y = 0; y < height; y++) for (let x = 0; x < Math.floor(width / 2); x++) {
167
+ const left = (y * width + x) * 4, right = (y * width + width - 1 - x) * 4;
168
+ for (let channel = 0; channel < 4; channel++) {
169
+ const value = rgba[left + channel];
170
+ rgba[left + channel] = rgba[right + channel];
171
+ rgba[right + channel] = value;
172
+ }
173
+ }
174
+ }
164
175
  /** Split a region on its output-pixel grid, bounding the plan before allocating it. */
165
176
  function splitRasterRectangle(rectangle, scale, limits) {
166
177
  const { x, y, width, height } = rectangle;
@@ -321,18 +332,36 @@ function selectedPages(pages, count, limit) {
321
332
  }
322
333
  //#endregion
323
334
  //#region lib/types/native-process.js
324
- /** Native helper stdio; Windows anonymous pipes retain the caller's restricted-token permissions. */
335
+ /** Native helper stdio; Windows pipe handles permit read/write access under restricted tokens. */
336
+ let pipeAttributes;
325
337
  function windowsPipes() {
326
338
  const koffi = createRequire(import.meta.url)("koffi");
327
- const kernel = koffi.load("kernel32.dll"), node = koffi.load(null);
328
- const createPipe = kernel.func("int __stdcall CreatePipe(_Out_ void **read, _Out_ void **write, void *attributes, uint32 size)");
339
+ const kernel = koffi.load("kernel32.dll"), advapi = koffi.load("advapi32.dll"), node = koffi.load(null);
340
+ const attributes = pipeAttributes ??= koffi.struct("KIT_SECURITY_ATTRIBUTES", {
341
+ nLength: "uint32",
342
+ lpSecurityDescriptor: "void *",
343
+ bInheritHandle: "int"
344
+ });
345
+ const createPipe = kernel.func("int __stdcall CreatePipe(_Out_ void **read, _Out_ void **write, KIT_SECURITY_ATTRIBUTES *attributes, uint32 size)");
329
346
  const closeHandle = kernel.func("int __stdcall CloseHandle(void *handle)");
347
+ const localFree = kernel.func("void * __stdcall LocalFree(void *memory)");
330
348
  const peek = kernel.func("int __stdcall PeekNamedPipe(void *pipe, void *buffer, uint32 size, void *read, _Out_ uint32 *available, void *remaining)");
331
349
  const lastError = kernel.func("uint32 __stdcall GetLastError()");
350
+ const convertSecurityDescriptor = advapi.func("int __stdcall ConvertStringSecurityDescriptorToSecurityDescriptorW(void *sddl, uint32 revision, _Out_ void **descriptor, void *size)");
332
351
  const openFd = node.func("int uv_open_osfhandle(void *handle)");
333
352
  function pipe() {
334
353
  const reads = [null], writes = [null];
335
- if (!createPipe(reads, writes, null, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
354
+ const descriptor = [null];
355
+ if (!convertSecurityDescriptor(Buffer.from("D:(A;;GRGW;;;WD)\0", "utf16le"), 1, descriptor, null)) throw new Error(`Pipe security descriptor failed: ${lastError()}`);
356
+ try {
357
+ if (!createPipe(reads, writes, {
358
+ nLength: attributes.size,
359
+ lpSecurityDescriptor: descriptor[0],
360
+ bInheritHandle: 0
361
+ }, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
362
+ } finally {
363
+ localFree(descriptor[0]);
364
+ }
336
365
  const read = openFd(reads[0]);
337
366
  if (read < 0) {
338
367
  closeHandle(reads[0]);
@@ -470,6 +499,8 @@ function spawnNative(executable, args, env) {
470
499
  });
471
500
  child.once("close", (code, signal) => {
472
501
  stdin.destroy();
502
+ output.readable.resume();
503
+ error.readable.resume();
473
504
  drained.then(() => {
474
505
  if (failure !== void 0) helper.emit("error", failure);
475
506
  helper.emit("close", code, signal);
@@ -699,6 +730,7 @@ async function prepareNativeFontProfile(profile, substitutions) {
699
730
  });
700
731
  }
701
732
  /**
733
+ * Native conversion and rendering disable printer discovery to avoid driver UI and network waits.
702
734
  * Linux searches the verified program directory; ambient loader overrides and credentials are excluded.
703
735
  * @param profile - Conversion-owned profile directory the helper treats as home.
704
736
  * @param programDirectory - Verified engine program directory.
@@ -718,7 +750,9 @@ function nativeEnvironment(profile, programDirectory, source = process.env, plat
718
750
  USERPROFILE: profile,
719
751
  TMPDIR: profile,
720
752
  TMP: profile,
721
- TEMP: profile
753
+ TEMP: profile,
754
+ SAL_DISABLE_PRINTERLIST: "1",
755
+ SAL_DISABLE_DEFAULTPRINTER: "1"
722
756
  });
723
757
  }
724
758
  /**
@@ -1102,7 +1136,13 @@ async function renderImagesWithNative(request) {
1102
1136
  if (resolve(painted.path) !== resolve(scratch, `tile-${index}.rgba`)) throw new Error("LibreOffice native renderer returned a tile outside its scratch directory.");
1103
1137
  const raw = await readFile(painted.path);
1104
1138
  if (raw.byteLength !== width * height * 4) throw new Error("LibreOffice native renderer returned incomplete pixels.");
1105
- const png = encodePng(width, height, ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode));
1139
+ const rgba = ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode);
1140
+ if (region.rtl) unmirrorRtlTile({
1141
+ width,
1142
+ height,
1143
+ rgba
1144
+ });
1145
+ const png = encodePng(width, height, rgba);
1106
1146
  total += png.byteLength;
1107
1147
  if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
1108
1148
  const path = join(operation.outputDir, `page-${String(index).padStart(4, "0")}.png`);
@@ -1424,16 +1464,16 @@ function resolveOptions(input = {}) {
1424
1464
  /** Resolve installed, version-matched engine packages without downloads or compilation. */
1425
1465
  const require = createRequire(import.meta.url);
1426
1466
  /** Node API release version returned by runtime discovery. */
1427
- const ENGINE_VERSION = "0.1.4";
1467
+ const ENGINE_VERSION = "0.1.5";
1428
1468
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
1429
1469
  const ENGINE_VERSIONS = Object.freeze({
1430
- "darwin-arm64": "0.1.4",
1431
- "darwin-x64": "0.1.4",
1470
+ "darwin-arm64": "0.1.5",
1471
+ "darwin-x64": "0.1.5",
1432
1472
  "linux-arm64-glibc": "0.1.1",
1433
1473
  "linux-x64-glibc": "0.1.1",
1434
- "win32-arm64": "0.1.4",
1435
- "win32-x64": "0.1.4",
1436
- wasm: "0.1.4"
1474
+ "win32-arm64": "0.1.5",
1475
+ "win32-x64": "0.1.5",
1476
+ wasm: "0.1.5"
1437
1477
  });
1438
1478
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
1439
1479
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
package/lib/index.js CHANGED
@@ -138,7 +138,7 @@ function dimension(data, first, last, maximum, scale) {
138
138
  }
139
139
  return [start / scale, (position - start) / scale];
140
140
  }
141
- /** Logical columns advance from A; LOK itself mirrors RTL sheet painting. No manual x inversion. */
141
+ /** Logical columns advance from A; RTL uses the same coordinates and mirrored transport pixels. */
142
142
  function sheetRangeRectangle(geometry, range, scale) {
143
143
  if (!Number.isFinite(scale) || scale <= 0 || scale > 16) throw new TypeError("Invalid worksheet raster scale.");
144
144
  const [x, width] = dimension(geometry.columns, range.firstColumn, range.lastColumn, MAX_COLUMN, scale);
@@ -159,6 +159,17 @@ function sheetRangeRectangle(geometry, range, scale) {
159
159
  height
160
160
  };
161
161
  }
162
+ /** Undo Calc's RTL transport mirroring so saved pixels contain readable text and right-to-left columns. */
163
+ function unmirrorRtlTile({ width, height, rgba }) {
164
+ for (let y = 0; y < height; y++) for (let x = 0; x < Math.floor(width / 2); x++) {
165
+ const left = (y * width + x) * 4, right = (y * width + width - 1 - x) * 4;
166
+ for (let channel = 0; channel < 4; channel++) {
167
+ const value = rgba[left + channel];
168
+ rgba[left + channel] = rgba[right + channel];
169
+ rgba[right + channel] = value;
170
+ }
171
+ }
172
+ }
162
173
  /** Split a region on its output-pixel grid, bounding the plan before allocating it. */
163
174
  function splitRasterRectangle(rectangle, scale, limits) {
164
175
  const { x, y, width, height } = rectangle;
@@ -319,18 +330,36 @@ function selectedPages(pages, count, limit) {
319
330
  }
320
331
  //#endregion
321
332
  //#region lib/types/native-process.js
322
- /** Native helper stdio; Windows anonymous pipes retain the caller's restricted-token permissions. */
333
+ /** Native helper stdio; Windows pipe handles permit read/write access under restricted tokens. */
334
+ let pipeAttributes;
323
335
  function windowsPipes() {
324
336
  const koffi = createRequire(import.meta.url)("koffi");
325
- const kernel = koffi.load("kernel32.dll"), node = koffi.load(null);
326
- const createPipe = kernel.func("int __stdcall CreatePipe(_Out_ void **read, _Out_ void **write, void *attributes, uint32 size)");
337
+ const kernel = koffi.load("kernel32.dll"), advapi = koffi.load("advapi32.dll"), node = koffi.load(null);
338
+ const attributes = pipeAttributes ??= koffi.struct("KIT_SECURITY_ATTRIBUTES", {
339
+ nLength: "uint32",
340
+ lpSecurityDescriptor: "void *",
341
+ bInheritHandle: "int"
342
+ });
343
+ const createPipe = kernel.func("int __stdcall CreatePipe(_Out_ void **read, _Out_ void **write, KIT_SECURITY_ATTRIBUTES *attributes, uint32 size)");
327
344
  const closeHandle = kernel.func("int __stdcall CloseHandle(void *handle)");
345
+ const localFree = kernel.func("void * __stdcall LocalFree(void *memory)");
328
346
  const peek = kernel.func("int __stdcall PeekNamedPipe(void *pipe, void *buffer, uint32 size, void *read, _Out_ uint32 *available, void *remaining)");
329
347
  const lastError = kernel.func("uint32 __stdcall GetLastError()");
348
+ const convertSecurityDescriptor = advapi.func("int __stdcall ConvertStringSecurityDescriptorToSecurityDescriptorW(void *sddl, uint32 revision, _Out_ void **descriptor, void *size)");
330
349
  const openFd = node.func("int uv_open_osfhandle(void *handle)");
331
350
  function pipe() {
332
351
  const reads = [null], writes = [null];
333
- if (!createPipe(reads, writes, null, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
352
+ const descriptor = [null];
353
+ if (!convertSecurityDescriptor(Buffer.from("D:(A;;GRGW;;;WD)\0", "utf16le"), 1, descriptor, null)) throw new Error(`Pipe security descriptor failed: ${lastError()}`);
354
+ try {
355
+ if (!createPipe(reads, writes, {
356
+ nLength: attributes.size,
357
+ lpSecurityDescriptor: descriptor[0],
358
+ bInheritHandle: 0
359
+ }, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
360
+ } finally {
361
+ localFree(descriptor[0]);
362
+ }
334
363
  const read = openFd(reads[0]);
335
364
  if (read < 0) {
336
365
  closeHandle(reads[0]);
@@ -468,6 +497,8 @@ function spawnNative(executable, args, env) {
468
497
  });
469
498
  child.once("close", (code, signal) => {
470
499
  stdin.destroy();
500
+ output.readable.resume();
501
+ error.readable.resume();
471
502
  drained.then(() => {
472
503
  if (failure !== void 0) helper.emit("error", failure);
473
504
  helper.emit("close", code, signal);
@@ -697,6 +728,7 @@ async function prepareNativeFontProfile(profile, substitutions) {
697
728
  });
698
729
  }
699
730
  /**
731
+ * Native conversion and rendering disable printer discovery to avoid driver UI and network waits.
700
732
  * Linux searches the verified program directory; ambient loader overrides and credentials are excluded.
701
733
  * @param profile - Conversion-owned profile directory the helper treats as home.
702
734
  * @param programDirectory - Verified engine program directory.
@@ -716,7 +748,9 @@ function nativeEnvironment(profile, programDirectory, source = process.env, plat
716
748
  USERPROFILE: profile,
717
749
  TMPDIR: profile,
718
750
  TMP: profile,
719
- TEMP: profile
751
+ TEMP: profile,
752
+ SAL_DISABLE_PRINTERLIST: "1",
753
+ SAL_DISABLE_DEFAULTPRINTER: "1"
720
754
  });
721
755
  }
722
756
  /**
@@ -1100,7 +1134,13 @@ async function renderImagesWithNative(request) {
1100
1134
  if (resolve(painted.path) !== resolve(scratch, `tile-${index}.rgba`)) throw new Error("LibreOffice native renderer returned a tile outside its scratch directory.");
1101
1135
  const raw = await readFile(painted.path);
1102
1136
  if (raw.byteLength !== width * height * 4) throw new Error("LibreOffice native renderer returned incomplete pixels.");
1103
- const png = encodePng(width, height, ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode));
1137
+ const rgba = ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode);
1138
+ if (region.rtl) unmirrorRtlTile({
1139
+ width,
1140
+ height,
1141
+ rgba
1142
+ });
1143
+ const png = encodePng(width, height, rgba);
1104
1144
  total += png.byteLength;
1105
1145
  if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
1106
1146
  const path = join(operation.outputDir, `page-${String(index).padStart(4, "0")}.png`);
@@ -1422,16 +1462,16 @@ function resolveOptions(input = {}) {
1422
1462
  /** Resolve installed, version-matched engine packages without downloads or compilation. */
1423
1463
  const require = createRequire(import.meta.url);
1424
1464
  /** Node API release version returned by runtime discovery. */
1425
- const ENGINE_VERSION = "0.1.4";
1465
+ const ENGINE_VERSION = "0.1.5";
1426
1466
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
1427
1467
  const ENGINE_VERSIONS = Object.freeze({
1428
- "darwin-arm64": "0.1.4",
1429
- "darwin-x64": "0.1.4",
1468
+ "darwin-arm64": "0.1.5",
1469
+ "darwin-x64": "0.1.5",
1430
1470
  "linux-arm64-glibc": "0.1.1",
1431
1471
  "linux-x64-glibc": "0.1.1",
1432
- "win32-arm64": "0.1.4",
1433
- "win32-x64": "0.1.4",
1434
- wasm: "0.1.4"
1472
+ "win32-arm64": "0.1.5",
1473
+ "win32-x64": "0.1.5",
1474
+ wasm: "0.1.5"
1435
1475
  });
1436
1476
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
1437
1477
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
@@ -1,5 +1,5 @@
1
1
  /** Node API release version returned by runtime discovery. */
2
- export declare const ENGINE_VERSION = "0.1.4";
2
+ export declare const ENGINE_VERSION = "0.1.5";
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. */
@@ -11,6 +11,7 @@ import type { ResolvedOptions } from './options.ts';
11
11
  */
12
12
  export declare function prepareNativeFontProfile(profile: string, substitutions: readonly FontSubstitution[]): Promise<void>;
13
13
  /**
14
+ * Native conversion and rendering disable printer discovery to avoid driver UI and network waits.
14
15
  * Linux searches the verified program directory; ambient loader overrides and credentials are excluded.
15
16
  * @param profile - Conversion-owned profile directory the helper treats as home.
16
17
  * @param programDirectory - Verified engine program directory.
@@ -22,6 +22,8 @@ export interface RasterTile {
22
22
  readonly height: number;
23
23
  readonly rgba: Uint8ClampedArray;
24
24
  }
25
+ /** Undo Calc's RTL transport mirroring so saved pixels contain readable text and right-to-left columns. */
26
+ export declare function unmirrorRtlTile({ width, height, rgba }: RasterTile): void;
25
27
  /** Split a region on its output-pixel grid, bounding the plan before allocating it. */
26
28
  export declare function splitRasterRectangle(rectangle: Rectangle, scale: number, limits: {
27
29
  readonly maxPixels: number;
@@ -32,7 +32,7 @@ export declare function parseCellRange(value: string): CellRange;
32
32
  export declare function sheetPartInfo(value: string): SheetPartInfo;
33
33
  /** Formatting-only cells and standalone drawings do not enlarge LibreOffice's data area. */
34
34
  export declare function dataArea(info: SheetPartInfo): CellRange;
35
- /** Logical columns advance from A; LOK itself mirrors RTL sheet painting. No manual x inversion. */
35
+ /** Logical columns advance from A; RTL uses the same coordinates and mirrored transport pixels. */
36
36
  export declare function sheetRangeRectangle(geometry: SheetGeometry, range: CellRange, scale: number): Rectangle;
37
37
  export {};
38
38
  //# sourceMappingURL=sheet-geometry.d.ts.map
package/lib/worker.js CHANGED
@@ -860,6 +860,17 @@ async function convertWithWasm(request) {
860
860
  };
861
861
  });
862
862
  }
863
+ /** Undo Calc's RTL transport mirroring so saved pixels contain readable text and right-to-left columns. */
864
+ function unmirrorRtlTile({ width, height, rgba }) {
865
+ for (let y = 0; y < height; y++) for (let x = 0; x < Math.floor(width / 2); x++) {
866
+ const left = (y * width + x) * 4, right = (y * width + width - 1 - x) * 4;
867
+ for (let channel = 0; channel < 4; channel++) {
868
+ const value = rgba[left + channel];
869
+ rgba[left + channel] = rgba[right + channel];
870
+ rgba[right + channel] = value;
871
+ }
872
+ }
873
+ }
863
874
  /** Split a region on its output-pixel grid, bounding the plan before allocating it. */
864
875
  function splitRasterRectangle(rectangle, scale, limits) {
865
876
  const { x, y, width, height } = rectangle;
@@ -1121,7 +1132,7 @@ function dimension(data, first, last, maximum, scale) {
1121
1132
  }
1122
1133
  return [start / scale, (position - start) / scale];
1123
1134
  }
1124
- /** Logical columns advance from A; LOK itself mirrors RTL sheet painting. No manual x inversion. */
1135
+ /** Logical columns advance from A; RTL uses the same coordinates and mirrored transport pixels. */
1125
1136
  function sheetRangeRectangle(geometry, range, scale) {
1126
1137
  if (!Number.isFinite(scale) || scale <= 0 || scale > 16) throw new TypeError("Invalid worksheet raster scale.");
1127
1138
  const [x, width] = dimension(geometry.columns, range.firstColumn, range.lastColumn, MAX_COLUMN, scale);
@@ -1357,6 +1368,7 @@ async function renderImagesWithWasm(request) {
1357
1368
  ...region.rectangle,
1358
1369
  scale
1359
1370
  }, [region.page], () => engineError(session.module, session.office), session.pdf);
1371
+ if (region.rtl) unmirrorRtlTile(tile);
1360
1372
  const png = encodePng(tile.width, tile.height, tile.rgba);
1361
1373
  total += png.length;
1362
1374
  if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
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.1.4",
4
+ "version": "0.1.5",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -14,9 +14,10 @@
14
14
  "license": "MPL-2.0",
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/deepseek-harness/libreoffice-kit.git",
17
+ "url": "https://github.com/deepseek-ai/dsh-libreoffice-kit",
18
18
  "directory": "packages/entry"
19
19
  },
20
+ "homepage": "https://github.com/deepseek-ai/dsh-libreoffice-kit",
20
21
  "exports": {
21
22
  ".": {
22
23
  "types": "./lib/types/index.d.ts",
@@ -41,11 +42,11 @@
41
42
  "saxes": "6.0.0"
42
43
  },
43
44
  "optionalDependencies": {
44
- "@deepseek-ai/libreoffice-kit-darwin-arm64": "0.1.4",
45
- "@deepseek-ai/libreoffice-kit-wasm": "0.1.4",
46
- "@deepseek-ai/libreoffice-kit-win32-x64": "0.1.4",
47
- "@deepseek-ai/libreoffice-kit-darwin-x64": "0.1.4",
48
- "@deepseek-ai/libreoffice-kit-win32-arm64": "0.1.4"
45
+ "@deepseek-ai/libreoffice-kit-darwin-arm64": "0.1.5",
46
+ "@deepseek-ai/libreoffice-kit-win32-x64": "0.1.5",
47
+ "@deepseek-ai/libreoffice-kit-darwin-x64": "0.1.5",
48
+ "@deepseek-ai/libreoffice-kit-wasm": "0.1.5",
49
+ "@deepseek-ai/libreoffice-kit-win32-arm64": "0.1.5"
49
50
  },
50
51
  "bin": {
51
52
  "dsoffice": "./lib/cli.js"