@deepseek-ai/libreoffice-kit 0.1.4 → 0.2.0-alpha5

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 (79) hide show
  1. package/NOTICE +4 -0
  2. package/README.md +49 -9
  3. package/README.zh.md +50 -10
  4. package/lib/cli.js +155 -52
  5. package/lib/editor.js +2061 -0
  6. package/lib/index.js +155 -52
  7. package/lib/types/editor-protocol.d.ts +29 -0
  8. package/lib/types/editor-transport.d.ts +36 -0
  9. package/lib/types/editor-types.d.ts +119 -0
  10. package/lib/types/editor.d.ts +105 -0
  11. package/lib/types/engine.d.ts +4 -2
  12. package/lib/types/fonts.d.ts +4 -8
  13. package/lib/types/native-image-renderer.d.ts +0 -1
  14. package/lib/types/native-process.d.ts +1 -0
  15. package/lib/types/native.d.ts +31 -2
  16. package/lib/types/rendering.d.ts +2 -0
  17. package/lib/types/runtime.d.ts +2 -0
  18. package/lib/types/sheet-geometry.d.ts +1 -1
  19. package/lib/types/worker.d.ts +2 -2
  20. package/lib/worker.js +51 -32
  21. package/native-render/CMakeLists.txt +40 -0
  22. package/native-render/LICENSE +21 -0
  23. package/native-render/README.md +83 -0
  24. package/native-render/README.zh.md +83 -0
  25. package/native-render/include/dsh_render.h +101 -0
  26. package/native-render/include/dsh_render_engine.h +66 -0
  27. package/native-render/include/dsh_render_node.h +27 -0
  28. package/native-render/include/dsh_webgpu.h +52 -0
  29. package/native-render/index.d.ts +145 -0
  30. package/native-render/index.mjs +71 -0
  31. package/native-render/lib/browser/display.d.ts +46 -0
  32. package/native-render/lib/browser/display.js +128 -0
  33. package/native-render/lib/browser/index.d.ts +4 -0
  34. package/native-render/lib/browser/index.js +3 -0
  35. package/native-render/lib/browser/painters.d.ts +9 -0
  36. package/native-render/lib/browser/painters.js +180 -0
  37. package/native-render/lib/browser/types.d.ts +51 -0
  38. package/native-render/lib/browser/types.js +1 -0
  39. package/native-render/lib/electron/adapter.d.ts +9 -0
  40. package/native-render/lib/electron/adapter.js +118 -0
  41. package/native-render/lib/electron/index.d.ts +3 -0
  42. package/native-render/lib/electron/index.js +3 -0
  43. package/native-render/lib/electron/preload.d.ts +13 -0
  44. package/native-render/lib/electron/preload.js +47 -0
  45. package/native-render/lib/electron/transfer.d.ts +15 -0
  46. package/native-render/lib/electron/transfer.js +36 -0
  47. package/native-render/prebuilds/darwin-arm64/libdsh_render_sdk.a +0 -0
  48. package/native-render/prebuilds/darwin-arm64/manifest.json +34 -0
  49. package/native-render/prebuilds/darwin-arm64/render.node +0 -0
  50. package/native-render/prebuilds/darwin-x64/libdsh_render_sdk.a +0 -0
  51. package/native-render/prebuilds/darwin-x64/manifest.json +34 -0
  52. package/native-render/prebuilds/darwin-x64/render.node +0 -0
  53. package/native-render/prebuilds/win32-arm64/dsh_render_sdk.lib +0 -0
  54. package/native-render/prebuilds/win32-arm64/manifest.json +34 -0
  55. package/native-render/prebuilds/win32-arm64/render.node +0 -0
  56. package/native-render/prebuilds/win32-x64/dsh_render_sdk.lib +0 -0
  57. package/native-render/prebuilds/win32-x64/manifest.json +34 -0
  58. package/native-render/prebuilds/win32-x64/render.node +0 -0
  59. package/native-render/receipt.json +23 -0
  60. package/native-render/scripts/build-webgpu.mjs +197 -0
  61. package/native-render/scripts/build.mjs +43 -0
  62. package/native-render/scripts/metadata.mjs +47 -0
  63. package/native-render/scripts/source-identity.mjs +15 -0
  64. package/native-render/scripts/verify-prebuilds.mjs +14 -0
  65. package/native-render/sdk.json +45 -0
  66. package/native-render/src/node-producer.cc +595 -0
  67. package/native-render/src/producer-internal.h +8 -0
  68. package/native-render/src/producer.cc +306 -0
  69. package/native-render/src/receiver.cc +1050 -0
  70. package/native-render/src/relay-transport.inc +293 -0
  71. package/native-render/src/transport.cc +405 -0
  72. package/native-render/src/transport.h +80 -0
  73. package/native-render/src/webgpu.cc +214 -0
  74. package/native-render/src/win-delay-load.LICENSE +24 -0
  75. package/native-render/src/win-delay-load.cc +43 -0
  76. package/native-render/verify.d.mts +4 -0
  77. package/native-render/verify.mjs +101 -0
  78. package/native-render/webgpu-dependencies.json +51 -0
  79. package/package.json +97 -11
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,41 @@ 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({
341
+ nLength: "uint32",
342
+ lpSecurityDescriptor: "void *",
343
+ bInheritHandle: "int"
344
+ });
345
+ const createPipe = kernel.func("__stdcall", "CreatePipe", "int", [
346
+ koffi.out(koffi.pointer("void *")),
347
+ koffi.out(koffi.pointer("void *")),
348
+ koffi.pointer(attributes),
349
+ "uint32"
350
+ ]);
329
351
  const closeHandle = kernel.func("int __stdcall CloseHandle(void *handle)");
352
+ const localFree = kernel.func("void * __stdcall LocalFree(void *memory)");
330
353
  const peek = kernel.func("int __stdcall PeekNamedPipe(void *pipe, void *buffer, uint32 size, void *read, _Out_ uint32 *available, void *remaining)");
331
354
  const lastError = kernel.func("uint32 __stdcall GetLastError()");
355
+ const convertSecurityDescriptor = advapi.func("int __stdcall ConvertStringSecurityDescriptorToSecurityDescriptorW(void *sddl, uint32 revision, _Out_ void **descriptor, void *size)");
332
356
  const openFd = node.func("int uv_open_osfhandle(void *handle)");
333
357
  function pipe() {
334
358
  const reads = [null], writes = [null];
335
- if (!createPipe(reads, writes, null, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
359
+ const descriptor = [null];
360
+ if (!convertSecurityDescriptor(Buffer.from("D:(A;;GRGW;;;WD)\0", "utf16le"), 1, descriptor, null)) throw new Error(`Pipe security descriptor failed: ${lastError()}`);
361
+ try {
362
+ if (!createPipe(reads, writes, {
363
+ nLength: attributes.size,
364
+ lpSecurityDescriptor: descriptor[0],
365
+ bInheritHandle: 0
366
+ }, 0)) throw new Error(`CreatePipe failed: ${lastError()}`);
367
+ } finally {
368
+ localFree(descriptor[0]);
369
+ }
336
370
  const read = openFd(reads[0]);
337
371
  if (read < 0) {
338
372
  closeHandle(reads[0]);
@@ -442,6 +476,9 @@ function spawnNative(executable, args, env) {
442
476
  stdin = stdin;
443
477
  stdout = output.readable;
444
478
  stderr = error.readable;
479
+ get pid() {
480
+ return child.pid;
481
+ }
445
482
  get exitCode() {
446
483
  return child.exitCode;
447
484
  }
@@ -470,6 +507,8 @@ function spawnNative(executable, args, env) {
470
507
  });
471
508
  child.once("close", (code, signal) => {
472
509
  stdin.destroy();
510
+ output.readable.resume();
511
+ error.readable.resume();
473
512
  drained.then(() => {
474
513
  if (failure !== void 0) helper.emit("error", failure);
475
514
  helper.emit("close", code, signal);
@@ -673,7 +712,9 @@ const NATIVE_ENVIRONMENT_KEYS = [
673
712
  "PATHEXT",
674
713
  "LANG",
675
714
  "LC_ALL",
676
- "TZ"
715
+ "TZ",
716
+ "OFFICE_GRAPHITE_DIAGNOSTICS",
717
+ "OFFICE_LOAD_DIAGNOSTICS"
677
718
  ];
678
719
  function fontSearchName(value) {
679
720
  const name = value.replaceAll(/[\uff00-\uff5e]/g, (character) => String.fromCharCode(character.charCodeAt(0) - 65248)).replaceAll(/[A-Z]/g, (character) => character.toLowerCase()).replaceAll(/[^a-z0-9;()\u0080-\uffff]/g, "");
@@ -699,6 +740,7 @@ async function prepareNativeFontProfile(profile, substitutions) {
699
740
  });
700
741
  }
701
742
  /**
743
+ * Native conversion and rendering disable printer discovery to avoid driver UI and network waits.
702
744
  * Linux searches the verified program directory; ambient loader overrides and credentials are excluded.
703
745
  * @param profile - Conversion-owned profile directory the helper treats as home.
704
746
  * @param programDirectory - Verified engine program directory.
@@ -718,38 +760,90 @@ function nativeEnvironment(profile, programDirectory, source = process.env, plat
718
760
  USERPROFILE: profile,
719
761
  TMPDIR: profile,
720
762
  TMP: profile,
721
- TEMP: profile
763
+ TEMP: profile,
764
+ SAL_DISABLE_PRINTERLIST: "1",
765
+ SAL_DISABLE_DEFAULTPRINTER: "1"
722
766
  });
723
767
  }
724
768
  /**
725
- * Keep Windows engine resources reachable through a short profile-owned path until the helper exits.
769
+ * Prepare short Windows engine paths owned by the caller's private profile.
726
770
  * @param engine - Verified engine installation; its resources remain in place.
727
771
  * @param profile - Private operation directory that owns the temporary executable and junction.
728
- * @param run - Operation that settles only after its helper closes.
729
- * @returns The operation result after removing the resource junction.
772
+ * @returns Engine paths and a release function to call once, after the helper closes and before removing the profile.
730
773
  */
731
- async function withNativeEngine(engine, profile, run) {
732
- if (process.platform !== "win32" || engine.executable.length < 260 && engine.programDirectory.length < 260) return run(engine);
774
+ async function prepareNativeEngine(engine, profile) {
775
+ if (process.platform !== "win32" || engine.executable.length < 260 && engine.programDirectory.length < 260) return {
776
+ engine,
777
+ release: async () => {}
778
+ };
733
779
  const root = join(profile, "engine");
734
780
  await symlink(engine.root, root, "junction");
735
781
  try {
736
782
  const executable = join(profile, "libreoffice-kit.exe");
737
783
  await copyFile(engine.executable, executable, constants.COPYFILE_EXCL);
738
- return await run({
739
- ...engine,
740
- root,
741
- executable,
742
- programDirectory: join(root, relative(engine.root, engine.programDirectory))
743
- });
744
- } finally {
784
+ return {
785
+ engine: {
786
+ ...engine,
787
+ root,
788
+ executable,
789
+ programDirectory: join(root, relative(engine.root, engine.programDirectory))
790
+ },
791
+ release: () => unlink(root)
792
+ };
793
+ } catch (error) {
745
794
  await unlink(root);
795
+ throw error;
746
796
  }
747
797
  }
748
798
  /**
799
+ * Keep Windows engine resources reachable through a short profile-owned path until the helper exits.
800
+ * @param engine - Verified engine installation; its resources remain in place.
801
+ * @param profile - Private operation directory that owns the temporary executable and junction.
802
+ * @param run - Operation that settles only after its helper closes.
803
+ * @returns The operation result after removing the resource junction.
804
+ */
805
+ async function withNativeEngine(engine, profile, run) {
806
+ const prepared = await prepareNativeEngine(engine, profile);
807
+ try {
808
+ return await run(prepared.engine);
809
+ } finally {
810
+ await prepared.release();
811
+ }
812
+ }
813
+ /**
814
+ * Prepare the document transport accepted by the pinned helper.
815
+ * @param engine - Resolved helper and input protocol.
816
+ * @param input - Owned document bytes and validated format.
817
+ * @param profile - Private directory retained until the helper exits and removed by the operation owner.
818
+ * @param signal - Cancellation of input preparation.
819
+ * @returns Helper arguments and an optional binary stdin prefix.
820
+ */
821
+ async function prepareNativeInput(engine, input, profile, signal) {
822
+ signal.throwIfAborted();
823
+ if (engine.legacyInputPath) {
824
+ const path = join(profile, `source.${input.format}`);
825
+ await writeFile(path, input.bytes, {
826
+ flag: "wx",
827
+ mode: 384,
828
+ signal
829
+ });
830
+ return { args: ["--input-path", path] };
831
+ }
832
+ return {
833
+ args: [
834
+ "--input-bytes",
835
+ String(input.bytes.byteLength),
836
+ "--input-format",
837
+ input.format
838
+ ],
839
+ bytes: input.bytes
840
+ };
841
+ }
842
+ /**
749
843
  * Run one native conversion and await bounded result transport.
750
844
  * @param engine - Resolved native engine installation.
751
845
  * @param options - Validated conversion limits.
752
- * @param input - Private source path inside the conversion scratch directory.
846
+ * @param input - Owned source bytes and format; older pinned helpers receive a private input file.
753
847
  * @param output - Private PDF path inside the conversion scratch directory.
754
848
  * @param profile - Conversion-owned profile directory.
755
849
  * @param fonts - Installed font files the helper may load.
@@ -768,11 +862,12 @@ async function runNative(engine, options, input, output, profile, fonts, substit
768
862
  return withNativeEngine(engine, profile, async (engine) => {
769
863
  signal.throwIfAborted();
770
864
  const env = nativeEnvironment(profile, engine.programDirectory);
865
+ const transport = await prepareNativeInput(engine, input, profile, signal);
866
+ signal.throwIfAborted();
771
867
  const child = spawnNative(engine.executable, [
772
868
  "--program-directory",
773
869
  engine.programDirectory,
774
- "--input-path",
775
- input,
870
+ ...transport.args,
776
871
  "--output-path",
777
872
  output,
778
873
  "--profile-directory",
@@ -788,7 +883,6 @@ async function runNative(engine, options, input, output, profile, fonts, substit
788
883
  ...operation.sheet === void 0 ? [] : ["--sheet", operation.sheet],
789
884
  ...fonts.flatMap((path) => ["--font-file", path])
790
885
  ], env);
791
- child.stdin.end();
792
886
  let stdout = "";
793
887
  let stderr = "";
794
888
  let failure;
@@ -809,6 +903,11 @@ async function runNative(engine, options, input, output, profile, fonts, substit
809
903
  child.stderr.on("data", (chunk) => {
810
904
  stderr = (stderr + chunk).slice(-65536);
811
905
  });
906
+ child.stdin.on("error", (error) => {
907
+ failure ??= error;
908
+ child.kill("SIGKILL");
909
+ });
910
+ child.stdin.end(transport.bytes);
812
911
  try {
813
912
  const code = await new Promise((resolve, reject) => {
814
913
  child.once("error", (error) => {
@@ -964,19 +1063,22 @@ function plan(ready, request) {
964
1063
  }
965
1064
  /** Run one native image batch and write final PNGs only after each bounded paint succeeds. */
966
1065
  async function renderImagesWithNative(request) {
967
- const { engine, options, inputPath, source, scratch, profile, fonts, substitutions, missingFonts, operation, signal } = request;
1066
+ const { engine, options, source, scratch, profile, fonts, substitutions, missingFonts, operation, signal } = request;
968
1067
  signal.throwIfAborted();
969
1068
  await mkdir(profile, { mode: 448 });
970
1069
  await prepareNativeFontProfile(profile, substitutions);
971
1070
  return withNativeEngine(engine, profile, async (engine) => {
1071
+ const transport = await prepareNativeInput(engine, {
1072
+ bytes: source,
1073
+ format: operation.extension
1074
+ }, profile, signal);
972
1075
  signal.throwIfAborted();
973
1076
  const child = spawnNative(engine.executable, [
974
1077
  "--operation",
975
1078
  "render-images",
976
1079
  "--program-directory",
977
1080
  engine.programDirectory,
978
- "--input-path",
979
- inputPath,
1081
+ ...transport.args,
980
1082
  "--scratch-directory",
981
1083
  scratch,
982
1084
  "--profile-directory",
@@ -1016,6 +1118,11 @@ async function renderImagesWithNative(request) {
1016
1118
  child.kill("SIGKILL");
1017
1119
  };
1018
1120
  signal.addEventListener("abort", abort, { once: true });
1121
+ child.stdin.on("error", (error) => {
1122
+ stopped ??= error;
1123
+ child.kill("SIGKILL");
1124
+ });
1125
+ if (transport.bytes) child.stdin.write(transport.bytes);
1019
1126
  const next = async () => {
1020
1127
  signal.throwIfAborted();
1021
1128
  if (lines.length > 0) return lines.shift();
@@ -1102,7 +1209,13 @@ async function renderImagesWithNative(request) {
1102
1209
  if (resolve(painted.path) !== resolve(scratch, `tile-${index}.rgba`)) throw new Error("LibreOffice native renderer returned a tile outside its scratch directory.");
1103
1210
  const raw = await readFile(painted.path);
1104
1211
  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));
1212
+ const rgba = ready.documentType === "pdf" ? new Uint8ClampedArray(raw) : rgbaPixels(raw, ready.tileMode);
1213
+ if (region.rtl) unmirrorRtlTile({
1214
+ width,
1215
+ height,
1216
+ rgba
1217
+ });
1218
+ const png = encodePng(width, height, rgba);
1106
1219
  total += png.byteLength;
1107
1220
  if (total > options.maxOutputBytes) throw new ConversionError("output-too-large", "PNG batch exceeds maxOutputBytes.");
1108
1221
  const path = join(operation.outputDir, `page-${String(index).padStart(4, "0")}.png`);
@@ -1424,16 +1537,16 @@ function resolveOptions(input = {}) {
1424
1537
  /** Resolve installed, version-matched engine packages without downloads or compilation. */
1425
1538
  const require = createRequire(import.meta.url);
1426
1539
  /** Node API release version returned by runtime discovery. */
1427
- const ENGINE_VERSION = "0.1.4";
1540
+ const ENGINE_VERSION = "0.2.0-alpha5";
1428
1541
  /** Exact compatible engine versions; unchanged platforms retain their published packages. */
1429
1542
  const ENGINE_VERSIONS = Object.freeze({
1430
- "darwin-arm64": "0.1.4",
1431
- "darwin-x64": "0.1.4",
1543
+ "darwin-arm64": "0.2.0-alpha5",
1544
+ "darwin-x64": "0.2.0-alpha5",
1432
1545
  "linux-arm64-glibc": "0.1.1",
1433
1546
  "linux-x64-glibc": "0.1.1",
1434
- "win32-arm64": "0.1.4",
1435
- "win32-x64": "0.1.4",
1436
- wasm: "0.1.4"
1547
+ "win32-arm64": "0.1.5",
1548
+ "win32-x64": "0.2.0-alpha5",
1549
+ wasm: "0.2.0-alpha5"
1437
1550
  });
1438
1551
  /** npm scope and name prefix shared by the engine packages this adapter installs. */
1439
1552
  const ENGINE_PREFIX = "@deepseek-ai/libreoffice-kit";
@@ -1472,7 +1585,7 @@ function glibcVersion(value) {
1472
1585
  return typeof value === "string" && /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/.test(value) && value.split(".").every((part) => Number.isSafeInteger(Number(part))) ? value.split(".").map(Number) : void 0;
1473
1586
  }
1474
1587
  /**
1475
- * macOS and Windows require their native engine. Linux uses WASM when no compatible development native engine is installed.
1588
+ * Prefer the installed compatible native engine; hosts without one use the shared WASM package.
1476
1589
  * @param resolvePackage - Package manifest resolver; injectable for selection tests.
1477
1590
  * @param packageExists - Installed-package probe; injectable for selection tests.
1478
1591
  * @param host - Process identification and diagnostic report.
@@ -1490,7 +1603,6 @@ async function resolveEngine(resolvePackage = (name) => require.resolve(`${name}
1490
1603
  const failure = error;
1491
1604
  if (!(failure?.code === "MODULE_NOT_FOUND" && typeof failure.message === "string" && failure.message.includes(`${name}/package.json`))) throw error;
1492
1605
  if (packageExists(name)) throw new Error(`Installed LibreOfficeKit package is incomplete: ${name}`, { cause: error });
1493
- if (platform !== "linux") throw new Error(`Required LibreOfficeKit native package is missing: ${name}`, { cause: error });
1494
1606
  }
1495
1607
  if (packageFile !== void 0) {
1496
1608
  const engine = await readEngine(packageFile, "native", target);
@@ -1499,7 +1611,6 @@ async function resolveEngine(resolvePackage = (name) => require.resolve(`${name}
1499
1611
  if (!(minimum && host && minimum.some((part, index) => part > (host[index] ?? 0) && minimum.slice(0, index).every((prior, priorIndex) => prior === host[priorIndex])))) return engine;
1500
1612
  }
1501
1613
  }
1502
- if (platform !== "linux") throw new Error(`Unsupported LibreOfficeKit host: ${platform}-${arch}`);
1503
1614
  return readEngine(resolvePackage(`${ENGINE_PREFIX}-wasm`), "wasm", "wasm");
1504
1615
  }
1505
1616
  async function engineAsset(root, value, name, kind) {
@@ -1524,6 +1635,7 @@ async function readEngine(packageFile, backend, target) {
1524
1635
  root,
1525
1636
  programDirectory: await engineAsset(root, engine.programDirectory, "programDirectory", "directory"),
1526
1637
  executable,
1638
+ ...["0.1.1", "0.1.5"].includes(String(pkg.version)) ? { legacyInputPath: true } : {},
1527
1639
  ...glibcFloor
1528
1640
  };
1529
1641
  }
@@ -1640,6 +1752,7 @@ async function discoverRuntime() {
1640
1752
  return {
1641
1753
  version: ENGINE_VERSION,
1642
1754
  backend: engine.backend,
1755
+ nativePreview: engine.backend === "native" && !engine.legacyInputPath,
1643
1756
  cliPath: fileURLToPath(new URL("./cli.js", import.meta.url)),
1644
1757
  nodeApiPath: fileURLToPath(new URL("./index.js", import.meta.url))
1645
1758
  };
@@ -1928,16 +2041,9 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
1928
2041
  output = await open(request.outputPath, "wx", 384);
1929
2042
  const sourceBytes = await readBounded(request.inputPath, resolvedOptions.maxInputBytes, stopped, "input");
1930
2043
  scratch = await mkdtemp(join(tmpdir(), "libreoffice-kit-"));
1931
- const inputPath = join(scratch, `document.${extension}`);
1932
- const input = await open(inputPath, "wx", 384);
1933
- try {
1934
- await input.writeFile(sourceBytes);
1935
- } finally {
1936
- await input.close();
1937
- }
1938
2044
  const fonts = await snapshot(stopped);
1939
2045
  const result = await runWorker({
1940
- inputPath,
2046
+ bytes: sourceBytes,
1941
2047
  extension,
1942
2048
  operation: request,
1943
2049
  options: resolvedOptions,
@@ -1954,7 +2060,10 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
1954
2060
  const profile = join(scratch, "profile");
1955
2061
  await mkdir(profile, { mode: 448 });
1956
2062
  const path = join(scratch, `output.${format}`);
1957
- await runNative(native, resolvedOptions, inputPath, path, profile, result.fonts, result.substitutions, stopped, request);
2063
+ await runNative(native, resolvedOptions, {
2064
+ bytes: sourceBytes,
2065
+ format: extension
2066
+ }, path, profile, result.fonts, result.substitutions, stopped, request);
1958
2067
  bytes = await readBounded(path, resolvedOptions.maxOutputBytes, stopped, "output");
1959
2068
  }
1960
2069
  validateOutput(bytes, format);
@@ -2005,14 +2114,9 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
2005
2114
  owned = true;
2006
2115
  const source = await readBounded(request.inputPath, resolvedOptions.maxInputBytes, stopped, "input");
2007
2116
  scratch = await mkdtemp(join(tmpdir(), "libreoffice-kit-images-"));
2008
- const inputPath = join(scratch, `document.${request.extension}`);
2009
- await writeFile(inputPath, source, {
2010
- flag: "wx",
2011
- mode: 384
2012
- });
2013
2117
  const fonts = await snapshot(stopped);
2014
2118
  const result = await runWorker({
2015
- inputPath,
2119
+ bytes: source,
2016
2120
  extension: request.extension,
2017
2121
  operation: request,
2018
2122
  options: resolvedOptions,
@@ -2028,7 +2132,6 @@ function createConverterWith(resolvedOptions, engine, shared, onDispose) {
2028
2132
  images = await renderImagesWithNative({
2029
2133
  engine,
2030
2134
  options: resolvedOptions,
2031
- inputPath,
2032
2135
  source,
2033
2136
  scratch,
2034
2137
  profile,