@poe-platform/safe-bash 0.1.755 → 0.1.757

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 (131) hide show
  1. package/dist/image-ast/index.browser.js +30 -6
  2. package/dist/image-ast/index.js +30 -6
  3. package/dist/pdf-ast/canvas.d.ts +1 -0
  4. package/dist/pdf-ast/index.js +26 -2
  5. package/dist/safe-bash/chunks/{chunk-LESPJ3OG.js → chunk-WNWIBBJZ.js} +15 -2
  6. package/dist/safe-bash/command-chunks/{chunk-S4J6MSLY.js → chunk-444OTXM7.js} +3 -3
  7. package/dist/safe-bash/command-chunks/{chunk-6AIOGLZO.js → chunk-CE6Z2ULX.js} +2 -2
  8. package/dist/safe-bash/command-chunks/{chunk-5VSGEE6J.js → chunk-F4IQCXZG.js} +5 -5
  9. package/dist/safe-bash/command-chunks/{chunk-F5MORDSU.js → chunk-FDNCPZQS.js} +32 -1
  10. package/dist/safe-bash/command-chunks/{chunk-SG3ZDZCX.js → chunk-FLMLM7Y4.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-XRVNFK7Z.js → chunk-H2FQA4OU.js} +26 -2
  12. package/dist/safe-bash/command-chunks/{chunk-CT3FB722.js → chunk-J7UMKBRK.js} +1 -1
  13. package/dist/safe-bash/command-chunks/{chunk-KB2LQ4HG.js → chunk-KBBI4CSU.js} +2 -2
  14. package/dist/safe-bash/command-chunks/{chunk-QQOAK7JQ.js → chunk-KKJCKPTA.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-7KS6PX4U.js → chunk-KSIGF4AG.js} +3 -3
  16. package/dist/safe-bash/command-chunks/{chunk-4HQ7WYSI.js → chunk-MED2BOOW.js} +30 -5
  17. package/dist/safe-bash/command-chunks/{chunk-JRNLDPLI.js → chunk-OZSWW23M.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-DKQ5REXF.js → chunk-QDPRSPHQ.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-WOPU2VWF.js → chunk-RID3B5RE.js} +1 -1
  20. package/dist/safe-bash/command-chunks/{chunk-DVZCHNB5.js → chunk-S4MLIYSN.js} +7 -7
  21. package/dist/safe-bash/command-chunks/{chunk-REYTQLLB.js → chunk-TT2DMDBY.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-UGX6MXDD.js → chunk-UIIT4ULR.js} +3 -3
  23. package/dist/safe-bash/command-chunks/{chunk-MENC7RPR.js → chunk-WI35236J.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-A6NFLWZI.js → chunk-WKPOGTZY.js} +22 -6
  25. package/dist/safe-bash/command-chunks/{chunk-3DOHQQJR.js → chunk-Y64PA6IA.js} +8 -8
  26. package/dist/safe-bash/command-chunks/{chunk-6Z7OS3TZ.js → chunk-ZP5KDHB4.js} +7 -7
  27. package/dist/safe-bash/commands/pandoc/index.d.ts +1 -1
  28. package/dist/safe-bash/commands/pandoc/index.js +5 -3
  29. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  30. package/dist/safe-bash/commands/python/index.js +6 -0
  31. package/dist/safe-bash/commands/python/jspi.js +11 -2
  32. package/dist/safe-bash/core.browser.js +6 -4
  33. package/dist/safe-bash-command-csvkit/index.js +8 -8
  34. package/dist/safe-bash-command-ffmpeg/index.js +20 -2
  35. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  36. package/dist/safe-bash-command-pandoc/command.js +3 -3
  37. package/dist/safe-bash-command-pandoc/index.js +3 -3
  38. package/dist/safe-bash-command-pdfimages/index.js +26 -2
  39. package/dist/safe-bash-command-pdfinfo/index.js +26 -2
  40. package/dist/safe-bash-command-pdftk/index.js +26 -2
  41. package/dist/safe-bash-command-pdftoppm/index.js +26 -2
  42. package/dist/safe-bash-command-pdftotext/index.js +26 -2
  43. package/dist/safe-bash-command-qpdf/index.js +26 -2
  44. package/dist/safe-bash-command-sips/index.js +2 -2
  45. package/dist/safe-bash-command-soffice/index.js +17 -17
  46. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  47. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  48. package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
  49. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +1 -1
  50. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -8
  51. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
  52. package/dist/safe-bash-command-ssconvert/index.js +133 -29
  53. package/dist/safe-bash-command-wkhtmltopdf/index.js +26 -2
  54. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  55. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  56. package/dist/safe-bash-mcp/index.js +4 -4
  57. package/dist/spreadsheet-engine/formulas/ast.d.ts +13 -0
  58. package/dist/spreadsheet-engine/formulas/conventions.js +1 -1
  59. package/dist/spreadsheet-engine/formulas/dependencies.js +2 -2
  60. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -2
  61. package/dist/spreadsheet-engine/formulas/named-expressions.d.ts +2 -2
  62. package/dist/spreadsheet-engine/formulas/named-expressions.js +31 -5
  63. package/dist/spreadsheet-engine/formulas/parser.js +34 -0
  64. package/dist/spreadsheet-engine/formulas/rewriting.js +19 -1
  65. package/dist/spreadsheet-engine/formulas/serialization.js +6 -0
  66. package/dist/spreadsheet-format-xls/biff-write-formulas.js +2 -0
  67. package/dist/xlsx-ast/formula-semantics.js +2 -0
  68. package/package.json +2 -2
  69. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +1 -1
  70. package/dist/safe-bash/chunks/browser-ECQX6GMK.js +0 -6766
  71. package/dist/safe-bash/chunks/bz2-4OP3OWW3.js +0 -8
  72. package/dist/safe-bash/chunks/chunk-22XPAAOI.js +0 -173
  73. package/dist/safe-bash/chunks/chunk-44WUNUPV.js +0 -649
  74. package/dist/safe-bash/chunks/chunk-4E3SGG37.js +0 -876
  75. package/dist/safe-bash/chunks/chunk-4QTSSQKP.js +0 -898
  76. package/dist/safe-bash/chunks/chunk-5UVGPVXP.js +0 -410
  77. package/dist/safe-bash/chunks/chunk-64OE6Q6X.js +0 -3487
  78. package/dist/safe-bash/chunks/chunk-6IIFUPN2.js +0 -1526
  79. package/dist/safe-bash/chunks/chunk-6XDKK63A.js +0 -38959
  80. package/dist/safe-bash/chunks/chunk-BENDLTQD.js +0 -7065
  81. package/dist/safe-bash/chunks/chunk-BMO5LWEX.js +0 -534
  82. package/dist/safe-bash/chunks/chunk-BPMCPTNP.js +0 -1920
  83. package/dist/safe-bash/chunks/chunk-BRJTAWP5.js +0 -2955
  84. package/dist/safe-bash/chunks/chunk-C3GEIN7Q.js +0 -20054
  85. package/dist/safe-bash/chunks/chunk-CEWCRI6H.js +0 -2813
  86. package/dist/safe-bash/chunks/chunk-CGL53DQQ.js +0 -37
  87. package/dist/safe-bash/chunks/chunk-CTYJJD4O.js +0 -869
  88. package/dist/safe-bash/chunks/chunk-CWSS4MQA.js +0 -7
  89. package/dist/safe-bash/chunks/chunk-DLIGMTCP.js +0 -3266
  90. package/dist/safe-bash/chunks/chunk-EMAJ7WUW.js +0 -1031
  91. package/dist/safe-bash/chunks/chunk-FDKIZ2IJ.js +0 -1950
  92. package/dist/safe-bash/chunks/chunk-FZWJ2A7V.js +0 -3093
  93. package/dist/safe-bash/chunks/chunk-G2VCIF2J.js +0 -22
  94. package/dist/safe-bash/chunks/chunk-GVKBUQDX.js +0 -2649
  95. package/dist/safe-bash/chunks/chunk-IO2OGW3E.js +0 -28051
  96. package/dist/safe-bash/chunks/chunk-ISCZG7WA.js +0 -2648
  97. package/dist/safe-bash/chunks/chunk-JEFBTRY7.js +0 -174814
  98. package/dist/safe-bash/chunks/chunk-KJHDD4A2.js +0 -759
  99. package/dist/safe-bash/chunks/chunk-LB6HVRXS.js +0 -857
  100. package/dist/safe-bash/chunks/chunk-LLWAJOZH.js +0 -15
  101. package/dist/safe-bash/chunks/chunk-LMUKYZIJ.js +0 -708
  102. package/dist/safe-bash/chunks/chunk-M5SCNKIK.js +0 -2012
  103. package/dist/safe-bash/chunks/chunk-MJPFHANT.js +0 -3350
  104. package/dist/safe-bash/chunks/chunk-MZQW2DOL.js +0 -82
  105. package/dist/safe-bash/chunks/chunk-NB2V7EOY.js +0 -1348
  106. package/dist/safe-bash/chunks/chunk-NJVGOIYN.js +0 -17
  107. package/dist/safe-bash/chunks/chunk-OLNZHDIQ.js +0 -5141
  108. package/dist/safe-bash/chunks/chunk-OUUVROTM.js +0 -38
  109. package/dist/safe-bash/chunks/chunk-PA6GYKBQ.js +0 -151
  110. package/dist/safe-bash/chunks/chunk-PEFHZ226.js +0 -6957
  111. package/dist/safe-bash/chunks/chunk-QBB5P5KW.js +0 -4839
  112. package/dist/safe-bash/chunks/chunk-QHB7HBLA.js +0 -2317
  113. package/dist/safe-bash/chunks/chunk-RSAWYAEH.js +0 -973
  114. package/dist/safe-bash/chunks/chunk-UWLYRWT4.js +0 -739
  115. package/dist/safe-bash/chunks/chunk-V463NBQH.js +0 -13
  116. package/dist/safe-bash/chunks/chunk-WPUALYUS.js +0 -843
  117. package/dist/safe-bash/chunks/chunk-XHKFSRGU.js +0 -5747
  118. package/dist/safe-bash/chunks/chunk-XHRCLZ3N.js +0 -13391
  119. package/dist/safe-bash/chunks/chunk-XPF5XHLY.js +0 -15
  120. package/dist/safe-bash/chunks/chunk-ZBFOWARG.js +0 -305
  121. package/dist/safe-bash/chunks/chunk-ZG7GWQ5P.js +0 -1859
  122. package/dist/safe-bash/chunks/model-store-EIY3ZQLZ.js +0 -10
  123. package/dist/safe-bash/chunks/pdf-renderer-XIFUTX34.js +0 -22
  124. package/dist/safe-bash/chunks/pptx-ZL6L7KP2-O425BFIU.js +0 -30658
  125. package/dist/safe-bash/chunks/src-HHEPGR7U.js +0 -18969
  126. package/dist/safe-bash/chunks/src-V4VCM5OX.js +0 -187
  127. package/dist/safe-bash/chunks/usage-6TGVA2OM.js +0 -35
  128. package/dist/safe-bash/chunks/xz-EGQGQUEI.js +0 -8
  129. package/dist/safe-bash/chunks/xz-K2E2WLM6.js +0 -9
  130. package/dist/safe-bash/chunks/zstd-6JBLP5EF.js +0 -8
  131. package/dist/safe-bash/git_rust-C3QYOAZL.wasm +0 -0
@@ -46136,7 +46136,7 @@ var PdfPage = class {
46136
46136
  this.cachedContentAst = parseContentStream(bytes);
46137
46137
  this.isolatedInitialStream = false;
46138
46138
  const stm = cosStream(bytes, { compress });
46139
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
46139
+ this.replaceContentStream(stm);
46140
46140
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46141
46141
  }
46142
46142
  getIsolatedContentAst() {
@@ -46153,9 +46153,33 @@ var PdfPage = class {
46153
46153
  this.cachedContentAst = [...nodes];
46154
46154
  const bytes = serializeContentAst(this.cachedContentAst);
46155
46155
  const streamObj = cosStream(bytes, { compress });
46156
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
46156
+ this.replaceContentStream(streamObj);
46157
46157
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46158
46158
  }
46159
+ replaceContentStream(stream) {
46160
+ const contents = dictGet(this.pageDict, "Contents");
46161
+ if (contents?.kind === "ref") {
46162
+ let references = 0;
46163
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
46164
+ const visited = /* @__PURE__ */ new Set();
46165
+ while (pending.length > 0 && references < 2) {
46166
+ const node = pending.pop();
46167
+ if (node.kind === "ref") {
46168
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
46169
+ } else if (!visited.has(node)) {
46170
+ visited.add(node);
46171
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
46172
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
46173
+ else if (node.kind === "stream") pending.push(node.dict);
46174
+ }
46175
+ }
46176
+ if (references === 1) {
46177
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
46178
+ return;
46179
+ }
46180
+ }
46181
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
46182
+ }
46159
46183
  drawText(text, options) {
46160
46184
  const size = options.size ?? options.fontSize ?? 12;
46161
46185
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -53189,7 +53213,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
53189
53213
  write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
53190
53214
  truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
53191
53215
  sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
53192
- close: (retained) => operation("close", {}, () => retained.close())
53216
+ close: (retained, options) => operation("close", {}, () => retained.close(options))
53193
53217
  };
53194
53218
  }
53195
53219
  function integer(value, syscall, path) {
@@ -53357,10 +53381,10 @@ var ManagedFileDescriptor = class {
53357
53381
  await backend.sync(backend.resource, dataOnly, forwarded);
53358
53382
  });
53359
53383
  }
53360
- close() {
53384
+ close(options = {}) {
53361
53385
  this.#closing ??= this.#pending.then(async () => {
53362
53386
  try {
53363
- await this.#backend.close(this.#backend.resource);
53387
+ await this.#backend.close(this.#backend.resource, options);
53364
53388
  } finally {
53365
53389
  this.#backend = void 0;
53366
53390
  this.#getPosition = void 0;
@@ -53418,7 +53442,7 @@ async function openFileDescriptor(path, options, capabilities, acquire) {
53418
53442
  signal?.throwIfAborted();
53419
53443
  return descriptor;
53420
53444
  } catch (error) {
53421
- await finishCleanup(() => backend.close(backend.resource), true);
53445
+ await finishCleanup(() => backend.close(backend.resource, {}), true);
53422
53446
  signal?.throwIfAborted();
53423
53447
  throw error;
53424
53448
  }
@@ -46136,7 +46136,7 @@ var PdfPage = class {
46136
46136
  this.cachedContentAst = parseContentStream(bytes);
46137
46137
  this.isolatedInitialStream = false;
46138
46138
  const stm = cosStream(bytes, { compress });
46139
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
46139
+ this.replaceContentStream(stm);
46140
46140
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46141
46141
  }
46142
46142
  getIsolatedContentAst() {
@@ -46153,9 +46153,33 @@ var PdfPage = class {
46153
46153
  this.cachedContentAst = [...nodes];
46154
46154
  const bytes = serializeContentAst(this.cachedContentAst);
46155
46155
  const streamObj = cosStream(bytes, { compress });
46156
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
46156
+ this.replaceContentStream(streamObj);
46157
46157
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
46158
46158
  }
46159
+ replaceContentStream(stream) {
46160
+ const contents = dictGet(this.pageDict, "Contents");
46161
+ if (contents?.kind === "ref") {
46162
+ let references = 0;
46163
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
46164
+ const visited = /* @__PURE__ */ new Set();
46165
+ while (pending.length > 0 && references < 2) {
46166
+ const node = pending.pop();
46167
+ if (node.kind === "ref") {
46168
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
46169
+ } else if (!visited.has(node)) {
46170
+ visited.add(node);
46171
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
46172
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
46173
+ else if (node.kind === "stream") pending.push(node.dict);
46174
+ }
46175
+ }
46176
+ if (references === 1) {
46177
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
46178
+ return;
46179
+ }
46180
+ }
46181
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
46182
+ }
46159
46183
  drawText(text, options) {
46160
46184
  const size = options.size ?? options.fontSize ?? 12;
46161
46185
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -53189,7 +53213,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
53189
53213
  write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
53190
53214
  truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
53191
53215
  sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
53192
- close: (retained) => operation("close", {}, () => retained.close())
53216
+ close: (retained, options) => operation("close", {}, () => retained.close(options))
53193
53217
  };
53194
53218
  }
53195
53219
  function integer(value, syscall, path) {
@@ -53357,10 +53381,10 @@ var ManagedFileDescriptor = class {
53357
53381
  await backend.sync(backend.resource, dataOnly, forwarded);
53358
53382
  });
53359
53383
  }
53360
- close() {
53384
+ close(options = {}) {
53361
53385
  this.#closing ??= this.#pending.then(async () => {
53362
53386
  try {
53363
- await this.#backend.close(this.#backend.resource);
53387
+ await this.#backend.close(this.#backend.resource, options);
53364
53388
  } finally {
53365
53389
  this.#backend = void 0;
53366
53390
  this.#getPosition = void 0;
@@ -53418,7 +53442,7 @@ async function openFileDescriptor(path, options, capabilities, acquire) {
53418
53442
  signal?.throwIfAborted();
53419
53443
  return descriptor;
53420
53444
  } catch (error) {
53421
- await finishCleanup(() => backend.close(backend.resource), true);
53445
+ await finishCleanup(() => backend.close(backend.resource, {}), true);
53422
53446
  signal?.throwIfAborted();
53423
53447
  throw error;
53424
53448
  }
@@ -103,6 +103,7 @@ export declare class PdfPage {
103
103
  setRawContentStream(bytesOrText: Uint8Array | string, compress?: boolean): void;
104
104
  private getIsolatedContentAst;
105
105
  setContentAst(nodes: PdfContentNode[], compress?: boolean): void;
106
+ private replaceContentStream;
106
107
  drawText(text: string, options: DrawTextOptions): void;
107
108
  drawRect(options: DrawRectOptions): void;
108
109
  drawLine(options: DrawLineOptions): void;
@@ -39539,7 +39539,7 @@ var PdfPage = class {
39539
39539
  this.cachedContentAst = parseContentStream(bytes);
39540
39540
  this.isolatedInitialStream = false;
39541
39541
  const stm = cosStream(bytes, { compress });
39542
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
39542
+ this.replaceContentStream(stm);
39543
39543
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
39544
39544
  }
39545
39545
  getIsolatedContentAst() {
@@ -39556,9 +39556,33 @@ var PdfPage = class {
39556
39556
  this.cachedContentAst = [...nodes];
39557
39557
  const bytes = serializeContentAst(this.cachedContentAst);
39558
39558
  const streamObj = cosStream(bytes, { compress });
39559
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
39559
+ this.replaceContentStream(streamObj);
39560
39560
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
39561
39561
  }
39562
+ replaceContentStream(stream) {
39563
+ const contents = dictGet(this.pageDict, "Contents");
39564
+ if (contents?.kind === "ref") {
39565
+ let references = 0;
39566
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
39567
+ const visited = /* @__PURE__ */ new Set();
39568
+ while (pending.length > 0 && references < 2) {
39569
+ const node = pending.pop();
39570
+ if (node.kind === "ref") {
39571
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
39572
+ } else if (!visited.has(node)) {
39573
+ visited.add(node);
39574
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
39575
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
39576
+ else if (node.kind === "stream") pending.push(node.dict);
39577
+ }
39578
+ }
39579
+ if (references === 1) {
39580
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
39581
+ return;
39582
+ }
39583
+ }
39584
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
39585
+ }
39562
39586
  drawText(text, options) {
39563
39587
  const size = options.size ?? options.fontSize ?? 12;
39564
39588
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -3245,6 +3245,8 @@ function createPythonJspiExecutor(options) {
3245
3245
  let running;
3246
3246
  let retirement;
3247
3247
  let schedulerCleanup;
3248
+ let interpreterFinalized = false;
3249
+ let finalizationFailure;
3248
3250
  let cleanup;
3249
3251
  let runtime;
3250
3252
  let native;
@@ -3500,7 +3502,11 @@ await _safe_quiesce_tasks()
3500
3502
  await scheduler.close();
3501
3503
  } finally {
3502
3504
  active.value = native ? 2 : 0;
3503
- finalized = Number(await engine.promising(runtime._module._Py_FinalizeEx)());
3505
+ finalized = Number(await Promise.resolve().then(() => engine.promising(runtime._module._Py_FinalizeEx)()).catch((reason) => {
3506
+ finalizationFailure = { reason };
3507
+ throw reason;
3508
+ }));
3509
+ interpreterFinalized = true;
3504
3510
  }
3505
3511
  }
3506
3512
  }
@@ -3540,7 +3546,10 @@ await _safe_quiesce_tasks()
3540
3546
  });
3541
3547
  await cleanup?.catch(() => {
3542
3548
  });
3543
- await schedulerCleanup;
3549
+ await schedulerCleanup?.catch((error) => {
3550
+ if (!interpreterFinalized) throw error;
3551
+ });
3552
+ if (finalizationFailure) throw finalizationFailure.reason;
3544
3553
  })();
3545
3554
  return retirement;
3546
3555
  }
@@ -3690,6 +3699,10 @@ function createPythonCommands(options) {
3690
3699
  await input.return?.(void 0);
3691
3700
  fragment = void 0;
3692
3701
  if (packages) environment.finish(packages);
3702
+ if (results[1]?.status === "fulfilled" && admitted) {
3703
+ activeWorkers--;
3704
+ admitted = false;
3705
+ }
3693
3706
  for (const result2 of results) if (result2.status === "rejected") throw result2.reason;
3694
3707
  })().then(() => {
3695
3708
  if (admitted) {
@@ -5,13 +5,13 @@ import {
5
5
  parseFormatSections,
6
6
  scanFormat,
7
7
  selectFormatSection
8
- } from "./chunk-A6NFLWZI.js";
8
+ } from "./chunk-WKPOGTZY.js";
9
9
  import {
10
10
  cellValueFormat
11
- } from "./chunk-4HQ7WYSI.js";
11
+ } from "./chunk-MED2BOOW.js";
12
12
  import {
13
13
  SsconvertError
14
- } from "./chunk-F5MORDSU.js";
14
+ } from "./chunk-FDNCPZQS.js";
15
15
  import {
16
16
  init_buffer
17
17
  } from "./chunk-HX3SHTCE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  rewriteReferences
3
- } from "./chunk-A6NFLWZI.js";
3
+ } from "./chunk-WKPOGTZY.js";
4
4
  import {
5
5
  DEFAULT_SHEET_SIZE,
6
6
  SsconvertError,
@@ -9,7 +9,7 @@ import {
9
9
  isUnicodeAlphanumeric,
10
10
  isUnicodeDigit,
11
11
  parseExpression
12
- } from "./chunk-F5MORDSU.js";
12
+ } from "./chunk-FDNCPZQS.js";
13
13
  import {
14
14
  init_buffer
15
15
  } from "./chunk-HX3SHTCE.js";
@@ -6,20 +6,20 @@ import {
6
6
  expandIndexSheetAreas,
7
7
  metadataNode,
8
8
  writeRichString
9
- } from "./chunk-SG3ZDZCX.js";
9
+ } from "./chunk-FLMLM7Y4.js";
10
10
  import {
11
11
  readGnumericRichText,
12
12
  writeGnumericRichText
13
- } from "./chunk-CT3FB722.js";
13
+ } from "./chunk-J7UMKBRK.js";
14
14
  import {
15
15
  recalculateWorkbook,
16
16
  rewriteReferences,
17
17
  visitFormula
18
- } from "./chunk-A6NFLWZI.js";
18
+ } from "./chunk-WKPOGTZY.js";
19
19
  import {
20
20
  cellValueFormat,
21
21
  converterLocale
22
- } from "./chunk-4HQ7WYSI.js";
22
+ } from "./chunk-MED2BOOW.js";
23
23
  import {
24
24
  SsconvertError,
25
25
  excelGrammar,
@@ -29,7 +29,7 @@ import {
29
29
  parseExpression,
30
30
  serializeExpression,
31
31
  snapshotWorkbook
32
- } from "./chunk-F5MORDSU.js";
32
+ } from "./chunk-FDNCPZQS.js";
33
33
  import {
34
34
  createZipCodec
35
35
  } from "./chunk-MKQVQMXO.js";
@@ -3133,7 +3133,7 @@ var odfGrammar = Object.freeze({
3133
3133
  prefixes: Object.freeze(["of:=", "oooc:=", "="]),
3134
3134
  functionPrefixes: Object.freeze(["ORG.GNUMERIC.", "COM.MICROSOFT."])
3135
3135
  });
3136
- var internalOdfGrammar = Object.freeze({ ...odfGrammar, internalLabels: true });
3136
+ var internalOdfGrammar = Object.freeze({ ...odfGrammar, internalLabels: true, internalNames: true });
3137
3137
  var sylkGrammar = Object.freeze({ ...gnumericGrammar, id: "sylk", address: "r1c1" });
3138
3138
  var sylkWriterGrammar = Object.freeze({ ...sylkGrammar, id: "sylk-writer", stringEscape: "raw" });
3139
3139
  var legacyOpenOfficeGrammar = Object.freeze({
@@ -4521,6 +4521,31 @@ function parseExpression(source, options) {
4521
4521
  if (depth > (options.maximumNodes ?? Infinity)) throw new SsconvertError("resource-limit", "ssconvert formula node limit exceeded");
4522
4522
  try {
4523
4523
  const c = source[offset];
4524
+ if (source.startsWith("@name.", offset)) {
4525
+ if (grammar.id !== "gnumeric" && !grammar.internalNames) fail("Internal live name in native formula");
4526
+ offset += 6;
4527
+ const relative = source.startsWith("relative", offset);
4528
+ if (!relative && !source.startsWith("absolute", offset)) fail("Invalid live name mode");
4529
+ offset += 8;
4530
+ const fixedSheet = source.startsWith(".fixed-sheet", offset);
4531
+ if (fixedSheet) offset += 12;
4532
+ if (source[offset++] !== "[") fail("Invalid live name mode");
4533
+ const displacement = (separator) => {
4534
+ const start2 = offset;
4535
+ if (source[offset] === "-") offset++;
4536
+ const begin = offset;
4537
+ while (digit(source[offset])) offset++;
4538
+ const value = Number(source.slice(start2, offset));
4539
+ if (offset === begin || !Number.isSafeInteger(value) || source[offset++] !== separator) fail("Invalid live name displacement");
4540
+ return value;
4541
+ };
4542
+ const row = displacement(","), column = displacement(","), sheet = displacement("]");
4543
+ if (!relative && (row !== 0 || column !== 0) || source[offset++] !== ":" || source[offset] !== '"') fail("Invalid live name");
4544
+ const name = quoted('"', grammar.stringEscape);
4545
+ if (!name) fail("Empty live name");
4546
+ options.onName?.(name);
4547
+ return node({ kind: "name", name, workbook: "", relocation: { relative, row, column, sheet, ...fixedSheet ? { sheetRelative: false } : {} }, start, end: offset });
4548
+ }
4524
4549
  if (c === "@" && !internalLabels) fail("Internal label reference in native formula");
4525
4550
  if (c === "@" && internalLabels) {
4526
4551
  offset++;
@@ -7702,6 +7727,12 @@ function serializeExpression(document, grammar = document.grammar, preserveSourc
7702
7727
  position
7703
7728
  );
7704
7729
  case "name": {
7730
+ if (value.relocation) {
7731
+ if (grammar.id !== "gnumeric" && !grammar.internalNames)
7732
+ throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: live name relocation in target grammar");
7733
+ const { relative, row, column, sheet } = value.relocation;
7734
+ return `@name.${relative ? "relative" : "absolute"}${value.relocation.sheetRelative === false ? ".fixed-sheet" : ""}[${row},${column},${sheet}]:` + quoteFormulaString(value.name, '"', grammar);
7735
+ }
7705
7736
  if (grammar.qualifiedNames === false && (value.sheet !== void 0 || value.workbook !== void 0))
7706
7737
  throw new SsconvertError("unsupported-feature", "Unsupported ssconvert feature: qualified formula name in target grammar");
7707
7738
  if (value.workbook === "" && grammar.bracketReferences && value.sheet === void 0)
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  richTextSegments
3
- } from "./chunk-WOPU2VWF.js";
3
+ } from "./chunk-RID3B5RE.js";
4
4
  import {
5
5
  SsconvertError,
6
6
  foldSheetName
7
- } from "./chunk-F5MORDSU.js";
7
+ } from "./chunk-FDNCPZQS.js";
8
8
  import {
9
9
  init_buffer
10
10
  } from "./chunk-HX3SHTCE.js";
@@ -35390,7 +35390,7 @@ var PdfPage = class {
35390
35390
  this.cachedContentAst = parseContentStream(bytes);
35391
35391
  this.isolatedInitialStream = false;
35392
35392
  const stm = cosStream(bytes, { compress });
35393
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
35393
+ this.replaceContentStream(stm);
35394
35394
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
35395
35395
  }
35396
35396
  getIsolatedContentAst() {
@@ -35407,9 +35407,33 @@ var PdfPage = class {
35407
35407
  this.cachedContentAst = [...nodes];
35408
35408
  const bytes = serializeContentAst(this.cachedContentAst);
35409
35409
  const streamObj = cosStream(bytes, { compress });
35410
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
35410
+ this.replaceContentStream(streamObj);
35411
35411
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
35412
35412
  }
35413
+ replaceContentStream(stream) {
35414
+ const contents = dictGet(this.pageDict, "Contents");
35415
+ if (contents?.kind === "ref") {
35416
+ let references = 0;
35417
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
35418
+ const visited = /* @__PURE__ */ new Set();
35419
+ while (pending.length > 0 && references < 2) {
35420
+ const node = pending.pop();
35421
+ if (node.kind === "ref") {
35422
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
35423
+ } else if (!visited.has(node)) {
35424
+ visited.add(node);
35425
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
35426
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
35427
+ else if (node.kind === "stream") pending.push(node.dict);
35428
+ }
35429
+ }
35430
+ if (references === 1) {
35431
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
35432
+ return;
35433
+ }
35434
+ }
35435
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
35436
+ }
35413
35437
  drawText(text, options) {
35414
35438
  const size = options.size ?? options.fontSize ?? 12;
35415
35439
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SsconvertError
3
- } from "./chunk-F5MORDSU.js";
3
+ } from "./chunk-FDNCPZQS.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";
@@ -48,11 +48,11 @@ import {
48
48
  trimImage,
49
49
  unflattenImage,
50
50
  unpremultiplyRgbaImage
51
- } from "./chunk-MENC7RPR.js";
51
+ } from "./chunk-WI35236J.js";
52
52
  import {
53
53
  PdfDocument,
54
54
  encodePng
55
- } from "./chunk-XRVNFK7Z.js";
55
+ } from "./chunk-H2FQA4OU.js";
56
56
  import {
57
57
  createLuaFilterCapability
58
58
  } from "./chunk-Y2KHC6TZ.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-KOM3FNCE.js";
4
4
  import {
5
5
  SsconvertError
6
- } from "./chunk-F5MORDSU.js";
6
+ } from "./chunk-FDNCPZQS.js";
7
7
  import {
8
8
  init_buffer
9
9
  } from "./chunk-HX3SHTCE.js";
@@ -59,7 +59,7 @@ async function openCommandFile(context, path, options) {
59
59
  acquisitionSettled?.();
60
60
  };
61
61
  let scope;
62
- const close = () => {
62
+ const close = (options2 = {}) => {
63
63
  accepting = false;
64
64
  closing ??= (async () => {
65
65
  if (acquiring) {
@@ -72,7 +72,7 @@ async function openCommandFile(context, path, options) {
72
72
  const retained = descriptor;
73
73
  descriptor = void 0;
74
74
  try {
75
- await retained?.close();
75
+ await retained?.close(options2);
76
76
  } catch (reason) {
77
77
  closeFailure = { reason, acknowledged: false, drained: false };
78
78
  throw reason;
@@ -90,7 +90,7 @@ async function openCommandFile(context, path, options) {
90
90
  return closing;
91
91
  };
92
92
  const aborted = () => {
93
- void close().catch(() => {
93
+ void close({ signal: scope ?? context.signal }).catch(() => {
94
94
  });
95
95
  };
96
96
  const check = (signal) => {
@@ -5,7 +5,7 @@ import {
5
5
  numericFunctionDescriptors,
6
6
  resolveName,
7
7
  statisticsFunctionDescriptors
8
- } from "./chunk-F5MORDSU.js";
8
+ } from "./chunk-FDNCPZQS.js";
9
9
  import {
10
10
  init_buffer
11
11
  } from "./chunk-HX3SHTCE.js";
@@ -637,21 +637,46 @@ var functionDescriptors = {
637
637
 
638
638
  // packages/spreadsheet-engine/src/formulas/named-expressions.ts
639
639
  init_buffer();
640
- function parseNamedExpression(name, book, parse, tick, maximumDepth = Infinity) {
640
+ function parseNamedExpression(name, book, parse, tick, maximumDepth = Infinity, relocation) {
641
641
  if (name.expression === "" || name.expression === "=") {
642
642
  tick();
643
643
  return { kind: "literal", value: { kind: "blank" }, start: 0, end: 0 };
644
644
  }
645
645
  const position = name.position ?? { sheet: name.sheet ?? book.sheets[0]?.id ?? "", row: 0, column: 0 };
646
+ function displace(ref, fallback) {
647
+ if (!relocation || ref.workbook !== void 0) return ref;
648
+ const origin = book.sheets.findIndex((sheet) => sheet.id === position.sheet);
649
+ const index = ref.sheetRelative ? origin + (ref.sheetOffset ?? 0) : ref.sheet !== void 0 || fallback !== void 0 ? book.sheets.findIndex((sheet) => foldSheetName(sheet.name) === foldSheetName(ref.sheet ?? fallback)) : origin;
650
+ const target = index >= 0 ? book.sheets[index + relocation.sheet] : void 0;
651
+ if (!target) return void 0;
652
+ const axis = (value, key) => ({ value: value.value + (value.relative ? position[key] : 0) + relocation[key], relative: false });
653
+ return { ...ref, sheet: target.name, sheetRelative: false, ...ref.row ? { row: axis(ref.row, "row") } : {}, ...ref.column ? { column: axis(ref.column, "column") } : {} };
654
+ }
646
655
  function bind(node, depth = 0) {
647
656
  tick();
648
657
  if (depth > maximumDepth) throw new SsconvertError("resource-limit", "ssconvert formula dependency depth limit exceeded");
649
- if (node.kind === "name" && (node.workbook === void 0 || node.workbook === "" && node.sheet !== void 0)) {
658
+ if (node.kind === "reference" && relocation) {
659
+ const first = displace(node.first), last = node.last ? displace(node.last, node.first.sheet) : void 0;
660
+ if (!first || node.last && !last) return { kind: "literal", value: { kind: "error", value: "#REF!" }, start: node.start, end: node.end };
661
+ return { ...node, first, ...last ? { last } : {} };
662
+ }
663
+ if (node.kind === "name" && (node.workbook === void 0 || node.workbook === "")) {
664
+ const inherited = relocation ? {
665
+ ...relocation,
666
+ row: relocation.row + (node.relocation?.row ?? 0),
667
+ column: relocation.column + (node.relocation?.column ?? 0),
668
+ sheet: relocation.sheet + (node.relocation?.sheet ?? 0)
669
+ } : node.relocation;
670
+ const bound = inherited ? { ...node, relocation: inherited } : node;
671
+ if (node.workbook === "" && node.sheet === void 0) return bound;
650
672
  const scope = node.sheet === void 0 ? name.sheet : book.sheets.find((sheet2) => foldSheetName(sheet2.name) === foldSheetName(node.sheet))?.id;
651
673
  const target = resolveName(book, node.name, scope);
652
- if (target?.sheet === void 0) return { kind: "name", name: node.name, workbook: "", start: node.start, end: node.end };
674
+ if (target?.sheet === void 0) {
675
+ const { sheet: ignoredSheet, ...global } = bound;
676
+ return { ...global, workbook: "" };
677
+ }
653
678
  const sheet = book.sheets.find((sheet2) => sheet2.id === target.sheet);
654
- return sheet ? { ...node, sheet: sheet.name } : node;
679
+ return sheet ? { ...bound, sheet: sheet.name } : bound;
655
680
  }
656
681
  if (node.kind === "parentheses" || node.kind === "unary") return { ...node, child: bind(node.child, depth + 1) };
657
682
  if (node.kind === "binary") return { ...node, left: bind(node.left, depth + 1), right: bind(node.right, depth + 1) };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SsconvertError
3
- } from "./chunk-F5MORDSU.js";
3
+ } from "./chunk-FDNCPZQS.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";
@@ -2,7 +2,7 @@ import {
2
2
  createXlsxWriter,
3
3
  probeXlsx,
4
4
  readXlsx
5
- } from "./chunk-5VSGEE6J.js";
5
+ } from "./chunk-F4IQCXZG.js";
6
6
  import {
7
7
  init_buffer
8
8
  } from "./chunk-HX3SHTCE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SsconvertError
3
- } from "./chunk-F5MORDSU.js";
3
+ } from "./chunk-FDNCPZQS.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";
@@ -6,16 +6,16 @@ import {
6
6
  parseRangePrefix,
7
7
  relocateFormula,
8
8
  resourceUri
9
- } from "./chunk-6AIOGLZO.js";
9
+ } from "./chunk-CE6Z2ULX.js";
10
10
  import {
11
11
  CodecWriteFailure
12
- } from "./chunk-JRNLDPLI.js";
12
+ } from "./chunk-OZSWW23M.js";
13
13
  import {
14
14
  createFormattingCapability
15
- } from "./chunk-S4J6MSLY.js";
15
+ } from "./chunk-444OTXM7.js";
16
16
  import {
17
17
  exportOptionPairs
18
- } from "./chunk-REYTQLLB.js";
18
+ } from "./chunk-TT2DMDBY.js";
19
19
  import {
20
20
  FinancialGoalSeek,
21
21
  WORK_QUANTUM,
@@ -38,11 +38,11 @@ import {
38
38
  serialDate,
39
39
  shiftMonths,
40
40
  snapshotRuntimeFunctions
41
- } from "./chunk-A6NFLWZI.js";
41
+ } from "./chunk-WKPOGTZY.js";
42
42
  import {
43
43
  converterLocale,
44
44
  runtimeEnvironment
45
- } from "./chunk-4HQ7WYSI.js";
45
+ } from "./chunk-MED2BOOW.js";
46
46
  import {
47
47
  DEFAULT_SHEET_SIZE,
48
48
  SsconvertError,
@@ -55,7 +55,7 @@ import {
55
55
  snapshotWorkbook,
56
56
  updateWorkbook,
57
57
  validSheetSize
58
- } from "./chunk-F5MORDSU.js";
58
+ } from "./chunk-FDNCPZQS.js";
59
59
  import {
60
60
  init_buffer
61
61
  } from "./chunk-HX3SHTCE.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SsconvertError,
3
3
  isUnicodeAlphanumeric
4
- } from "./chunk-F5MORDSU.js";
4
+ } from "./chunk-FDNCPZQS.js";
5
5
  import {
6
6
  init_buffer
7
7
  } from "./chunk-HX3SHTCE.js";
@@ -3,16 +3,16 @@ import {
3
3
  } from "./chunk-IDR3WWKI.js";
4
4
  import {
5
5
  TextConverterUnavailable
6
- } from "./chunk-JRNLDPLI.js";
6
+ } from "./chunk-OZSWW23M.js";
7
7
  import {
8
8
  singleByteTables
9
9
  } from "./chunk-KOM3FNCE.js";
10
10
  import {
11
11
  converterLocale
12
- } from "./chunk-4HQ7WYSI.js";
12
+ } from "./chunk-MED2BOOW.js";
13
13
  import {
14
14
  SsconvertError
15
- } from "./chunk-F5MORDSU.js";
15
+ } from "./chunk-FDNCPZQS.js";
16
16
  import {
17
17
  init_buffer
18
18
  } from "./chunk-HX3SHTCE.js";