@poe-platform/safe-bash 0.1.756 → 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 (113) hide show
  1. package/dist/image-ast/index.browser.js +4 -4
  2. package/dist/image-ast/index.js +4 -4
  3. package/dist/safe-bash/chunks/{chunk-LESPJ3OG.js → chunk-WNWIBBJZ.js} +15 -2
  4. package/dist/safe-bash/command-chunks/{chunk-S4J6MSLY.js → chunk-444OTXM7.js} +3 -3
  5. package/dist/safe-bash/command-chunks/{chunk-6AIOGLZO.js → chunk-CE6Z2ULX.js} +2 -2
  6. package/dist/safe-bash/command-chunks/{chunk-5VSGEE6J.js → chunk-F4IQCXZG.js} +5 -5
  7. package/dist/safe-bash/command-chunks/{chunk-F5MORDSU.js → chunk-FDNCPZQS.js} +32 -1
  8. package/dist/safe-bash/command-chunks/{chunk-SG3ZDZCX.js → chunk-FLMLM7Y4.js} +2 -2
  9. package/dist/safe-bash/command-chunks/{chunk-CT3FB722.js → chunk-J7UMKBRK.js} +1 -1
  10. package/dist/safe-bash/command-chunks/{chunk-QQOAK7JQ.js → chunk-KKJCKPTA.js} +1 -1
  11. package/dist/safe-bash/command-chunks/{chunk-7KS6PX4U.js → chunk-KSIGF4AG.js} +3 -3
  12. package/dist/safe-bash/command-chunks/{chunk-4HQ7WYSI.js → chunk-MED2BOOW.js} +30 -5
  13. package/dist/safe-bash/command-chunks/{chunk-JRNLDPLI.js → chunk-OZSWW23M.js} +1 -1
  14. package/dist/safe-bash/command-chunks/{chunk-DKQ5REXF.js → chunk-QDPRSPHQ.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-WOPU2VWF.js → chunk-RID3B5RE.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-DVZCHNB5.js → chunk-S4MLIYSN.js} +7 -7
  17. package/dist/safe-bash/command-chunks/{chunk-REYTQLLB.js → chunk-TT2DMDBY.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-UGX6MXDD.js → chunk-UIIT4ULR.js} +3 -3
  19. package/dist/safe-bash/command-chunks/{chunk-A6NFLWZI.js → chunk-WKPOGTZY.js} +22 -6
  20. package/dist/safe-bash/command-chunks/{chunk-3DOHQQJR.js → chunk-Y64PA6IA.js} +8 -8
  21. package/dist/safe-bash/command-chunks/{chunk-6Z7OS3TZ.js → chunk-ZP5KDHB4.js} +7 -7
  22. package/dist/safe-bash/commands/pandoc/index.d.ts +1 -1
  23. package/dist/safe-bash/commands/pandoc/index.js +5 -3
  24. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  25. package/dist/safe-bash/commands/python/index.js +6 -0
  26. package/dist/safe-bash/commands/python/jspi.js +11 -2
  27. package/dist/safe-bash/core.browser.js +6 -4
  28. package/dist/safe-bash-command-csvkit/index.js +8 -8
  29. package/dist/safe-bash-command-soffice/index.js +16 -16
  30. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  31. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  32. package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
  33. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +1 -1
  34. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -8
  35. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
  36. package/dist/safe-bash-command-ssconvert/index.js +107 -27
  37. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  38. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  39. package/dist/safe-bash-mcp/index.js +4 -4
  40. package/dist/spreadsheet-engine/formulas/ast.d.ts +13 -0
  41. package/dist/spreadsheet-engine/formulas/conventions.js +1 -1
  42. package/dist/spreadsheet-engine/formulas/dependencies.js +2 -2
  43. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -2
  44. package/dist/spreadsheet-engine/formulas/named-expressions.d.ts +2 -2
  45. package/dist/spreadsheet-engine/formulas/named-expressions.js +31 -5
  46. package/dist/spreadsheet-engine/formulas/parser.js +34 -0
  47. package/dist/spreadsheet-engine/formulas/rewriting.js +19 -1
  48. package/dist/spreadsheet-engine/formulas/serialization.js +6 -0
  49. package/dist/spreadsheet-format-xls/biff-write-formulas.js +2 -0
  50. package/dist/xlsx-ast/formula-semantics.js +2 -0
  51. package/package.json +2 -2
  52. package/dist/safe-bash/chunks/browser-ECQX6GMK.js +0 -6766
  53. package/dist/safe-bash/chunks/bz2-4OP3OWW3.js +0 -8
  54. package/dist/safe-bash/chunks/chunk-22XPAAOI.js +0 -173
  55. package/dist/safe-bash/chunks/chunk-44WUNUPV.js +0 -649
  56. package/dist/safe-bash/chunks/chunk-4E3SGG37.js +0 -876
  57. package/dist/safe-bash/chunks/chunk-4QTSSQKP.js +0 -898
  58. package/dist/safe-bash/chunks/chunk-5UVGPVXP.js +0 -410
  59. package/dist/safe-bash/chunks/chunk-64OE6Q6X.js +0 -3487
  60. package/dist/safe-bash/chunks/chunk-6IIFUPN2.js +0 -1526
  61. package/dist/safe-bash/chunks/chunk-BENDLTQD.js +0 -7065
  62. package/dist/safe-bash/chunks/chunk-BMO5LWEX.js +0 -534
  63. package/dist/safe-bash/chunks/chunk-BPMCPTNP.js +0 -1920
  64. package/dist/safe-bash/chunks/chunk-BRJTAWP5.js +0 -2955
  65. package/dist/safe-bash/chunks/chunk-C3GEIN7Q.js +0 -20054
  66. package/dist/safe-bash/chunks/chunk-CBVANNKK.js +0 -174814
  67. package/dist/safe-bash/chunks/chunk-CEWCRI6H.js +0 -2813
  68. package/dist/safe-bash/chunks/chunk-CGL53DQQ.js +0 -37
  69. package/dist/safe-bash/chunks/chunk-CTYJJD4O.js +0 -869
  70. package/dist/safe-bash/chunks/chunk-CWSS4MQA.js +0 -7
  71. package/dist/safe-bash/chunks/chunk-DLIGMTCP.js +0 -3266
  72. package/dist/safe-bash/chunks/chunk-EMAJ7WUW.js +0 -1031
  73. package/dist/safe-bash/chunks/chunk-FDKIZ2IJ.js +0 -1950
  74. package/dist/safe-bash/chunks/chunk-FZWJ2A7V.js +0 -3093
  75. package/dist/safe-bash/chunks/chunk-G2VCIF2J.js +0 -22
  76. package/dist/safe-bash/chunks/chunk-GVKBUQDX.js +0 -2649
  77. package/dist/safe-bash/chunks/chunk-IO2OGW3E.js +0 -28051
  78. package/dist/safe-bash/chunks/chunk-ISCZG7WA.js +0 -2648
  79. package/dist/safe-bash/chunks/chunk-JCN3FXLP.js +0 -38983
  80. package/dist/safe-bash/chunks/chunk-KJHDD4A2.js +0 -759
  81. package/dist/safe-bash/chunks/chunk-LB6HVRXS.js +0 -857
  82. package/dist/safe-bash/chunks/chunk-LLWAJOZH.js +0 -15
  83. package/dist/safe-bash/chunks/chunk-LMUKYZIJ.js +0 -708
  84. package/dist/safe-bash/chunks/chunk-M5SCNKIK.js +0 -2012
  85. package/dist/safe-bash/chunks/chunk-MJPFHANT.js +0 -3350
  86. package/dist/safe-bash/chunks/chunk-MZQW2DOL.js +0 -82
  87. package/dist/safe-bash/chunks/chunk-NB2V7EOY.js +0 -1348
  88. package/dist/safe-bash/chunks/chunk-NJVGOIYN.js +0 -17
  89. package/dist/safe-bash/chunks/chunk-OLNZHDIQ.js +0 -5141
  90. package/dist/safe-bash/chunks/chunk-OSUXMC43.js +0 -2317
  91. package/dist/safe-bash/chunks/chunk-OUUVROTM.js +0 -38
  92. package/dist/safe-bash/chunks/chunk-PA6GYKBQ.js +0 -151
  93. package/dist/safe-bash/chunks/chunk-PEFHZ226.js +0 -6957
  94. package/dist/safe-bash/chunks/chunk-QBB5P5KW.js +0 -4839
  95. package/dist/safe-bash/chunks/chunk-RSAWYAEH.js +0 -973
  96. package/dist/safe-bash/chunks/chunk-UWLYRWT4.js +0 -739
  97. package/dist/safe-bash/chunks/chunk-V463NBQH.js +0 -13
  98. package/dist/safe-bash/chunks/chunk-WPUALYUS.js +0 -843
  99. package/dist/safe-bash/chunks/chunk-XHKFSRGU.js +0 -5747
  100. package/dist/safe-bash/chunks/chunk-XHRCLZ3N.js +0 -13391
  101. package/dist/safe-bash/chunks/chunk-XPF5XHLY.js +0 -15
  102. package/dist/safe-bash/chunks/chunk-ZBFOWARG.js +0 -305
  103. package/dist/safe-bash/chunks/chunk-ZG7GWQ5P.js +0 -1859
  104. package/dist/safe-bash/chunks/model-store-EIY3ZQLZ.js +0 -10
  105. package/dist/safe-bash/chunks/pdf-renderer-CMF3CSVU.js +0 -22
  106. package/dist/safe-bash/chunks/pptx-ZL6L7KP2-O425BFIU.js +0 -30658
  107. package/dist/safe-bash/chunks/src-HHEPGR7U.js +0 -18969
  108. package/dist/safe-bash/chunks/src-MXIKQCIC.js +0 -187
  109. package/dist/safe-bash/chunks/usage-6TGVA2OM.js +0 -35
  110. package/dist/safe-bash/chunks/xz-EGQGQUEI.js +0 -8
  111. package/dist/safe-bash/chunks/xz-K2E2WLM6.js +0 -9
  112. package/dist/safe-bash/chunks/zstd-6JBLP5EF.js +0 -8
  113. package/dist/safe-bash/git_rust-C3QYOAZL.wasm +0 -0
@@ -53213,7 +53213,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
53213
53213
  write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
53214
53214
  truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
53215
53215
  sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
53216
- close: (retained) => operation("close", {}, () => retained.close())
53216
+ close: (retained, options) => operation("close", {}, () => retained.close(options))
53217
53217
  };
53218
53218
  }
53219
53219
  function integer(value, syscall, path) {
@@ -53381,10 +53381,10 @@ var ManagedFileDescriptor = class {
53381
53381
  await backend.sync(backend.resource, dataOnly, forwarded);
53382
53382
  });
53383
53383
  }
53384
- close() {
53384
+ close(options = {}) {
53385
53385
  this.#closing ??= this.#pending.then(async () => {
53386
53386
  try {
53387
- await this.#backend.close(this.#backend.resource);
53387
+ await this.#backend.close(this.#backend.resource, options);
53388
53388
  } finally {
53389
53389
  this.#backend = void 0;
53390
53390
  this.#getPosition = void 0;
@@ -53442,7 +53442,7 @@ async function openFileDescriptor(path, options, capabilities, acquire) {
53442
53442
  signal?.throwIfAborted();
53443
53443
  return descriptor;
53444
53444
  } catch (error) {
53445
- await finishCleanup(() => backend.close(backend.resource), true);
53445
+ await finishCleanup(() => backend.close(backend.resource, {}), true);
53446
53446
  signal?.throwIfAborted();
53447
53447
  throw error;
53448
53448
  }
@@ -53213,7 +53213,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
53213
53213
  write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
53214
53214
  truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
53215
53215
  sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
53216
- close: (retained) => operation("close", {}, () => retained.close())
53216
+ close: (retained, options) => operation("close", {}, () => retained.close(options))
53217
53217
  };
53218
53218
  }
53219
53219
  function integer(value, syscall, path) {
@@ -53381,10 +53381,10 @@ var ManagedFileDescriptor = class {
53381
53381
  await backend.sync(backend.resource, dataOnly, forwarded);
53382
53382
  });
53383
53383
  }
53384
- close() {
53384
+ close(options = {}) {
53385
53385
  this.#closing ??= this.#pending.then(async () => {
53386
53386
  try {
53387
- await this.#backend.close(this.#backend.resource);
53387
+ await this.#backend.close(this.#backend.resource, options);
53388
53388
  } finally {
53389
53389
  this.#backend = void 0;
53390
53390
  this.#getPosition = void 0;
@@ -53442,7 +53442,7 @@ async function openFileDescriptor(path, options, capabilities, acquire) {
53442
53442
  signal?.throwIfAborted();
53443
53443
  return descriptor;
53444
53444
  } catch (error) {
53445
- await finishCleanup(() => backend.close(backend.resource), true);
53445
+ await finishCleanup(() => backend.close(backend.resource, {}), true);
53446
53446
  signal?.throwIfAborted();
53447
53447
  throw error;
53448
53448
  }
@@ -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";
@@ -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";
@@ -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";
@@ -2,7 +2,7 @@ import {
2
2
  cellValueFormat,
3
3
  functionDescriptors,
4
4
  parseNamedExpression
5
- } from "./chunk-4HQ7WYSI.js";
5
+ } from "./chunk-MED2BOOW.js";
6
6
  import {
7
7
  DEFAULT_SHEET_SIZE,
8
8
  MAX_SHEET_SIZE,
@@ -27,7 +27,7 @@ import {
27
27
  statisticsFunctionDescriptors,
28
28
  sylkGrammar,
29
29
  validSheetSize
30
- } from "./chunk-F5MORDSU.js";
30
+ } from "./chunk-FDNCPZQS.js";
31
31
  import {
32
32
  init_buffer
33
33
  } from "./chunk-HX3SHTCE.js";
@@ -225,6 +225,22 @@ function rewriteReferences(document, edit) {
225
225
  const position = { ...target, sheet: document.sheetNames?.[target.sheet] ?? target.sheet };
226
226
  changes.push({ start: node.start, end: node.end, text: label ? serializeLabelReference({ ...node, first, ...last ? { last } : {}, label }, document.grammar, position) : serializeReference(first, last, document.grammar, position) });
227
227
  }
228
+ } else if (node.kind === "name" && node.relocation && edit.translation === "copy") {
229
+ const relocation = { ...node.relocation };
230
+ if (relocation.relative) {
231
+ relocation.row += target.row - document.position.row;
232
+ relocation.column += target.column - document.position.column;
233
+ }
234
+ if (relocation.sheetRelative !== false && target.sheet !== document.position.sheet) {
235
+ const origin = document.sheetOrder?.indexOf(document.position.sheet) ?? -1;
236
+ const destination = document.sheetOrder?.indexOf(target.sheet) ?? -1;
237
+ if (origin < 0 || destination < 0) throw new SsconvertError("invalid-request", "Cross-sheet formula copy requires workbook tab order");
238
+ relocation.sheet += destination - origin;
239
+ }
240
+ if (![relocation.row, relocation.column, relocation.sheet].every(Number.isSafeInteger))
241
+ throw new SsconvertError("invalid-request", "Invalid live name displacement");
242
+ const text = serializeExpression({ ...document, root: { ...node, relocation } }, document.grammar, false).slice(document.grammar.prefixes[0]?.length ?? 0);
243
+ changes.push({ start: node.start, end: node.end, text });
228
244
  } else if (node.kind === "name" && (node.workbook === void 0 || node.workbook === "") && node.sheet && renamedSheet(node.sheet) !== void 0) {
229
245
  const text = quoteFormulaString(renamedSheet(node.sheet), "'", document.grammar) + document.grammar.sheetSeparator + node.name;
230
246
  changes.push({ start: node.start, end: node.end, text: document.grammar.bracketReferences ? "[" + text + "]" : text });
@@ -2381,7 +2397,7 @@ function buildDependencyGraph(book, roots, resolve, parse2, tick, onRange, maxim
2381
2397
  if (node.kind === "name") {
2382
2398
  const name = named(node, position);
2383
2399
  if (!name || names.has(name)) return [];
2384
- return staticRanges(parseNamedExpression(name, book, parse2, tick, maximumDepth), position, /* @__PURE__ */ new Set([...names, name]), depth + 1);
2400
+ return staticRanges(parseNamedExpression(name, book, parse2, tick, maximumDepth, node.relocation), position, /* @__PURE__ */ new Set([...names, name]), depth + 1);
2385
2401
  }
2386
2402
  if (node.kind === "call" && (node.name === "IF" || node.name === "CHOOSE")) {
2387
2403
  const ranges2 = [];
@@ -2473,7 +2489,7 @@ function buildDependencyGraph(book, roots, resolve, parse2, tick, onRange, maxim
2473
2489
  if (node.kind === "name" && (node.workbook === void 0 || node.workbook === "")) {
2474
2490
  const name = named(node, position2);
2475
2491
  if (name && !names2.has(name)) {
2476
- pending.push({ node: parseNamedExpression(name, book, parse2, tick, maximumDepth), position: position2, names: /* @__PURE__ */ new Set([...names2, name]), depth: depth + 1 });
2492
+ pending.push({ node: parseNamedExpression(name, book, parse2, tick, maximumDepth, node.relocation), position: position2, names: /* @__PURE__ */ new Set([...names2, name]), depth: depth + 1 });
2477
2493
  }
2478
2494
  }
2479
2495
  const children = node.kind === "unary" || node.kind === "parentheses" ? [node.child] : node.kind === "binary" ? [node.left, node.right] : node.kind === "call" ? node.args : node.kind === "array" ? node.rows.flat() : [];
@@ -22506,7 +22522,7 @@ function* recalculateWorkbookSteps(input, context, options = false, onDiagnostic
22506
22522
  const matches = (entry2) => entry2.name === node.name;
22507
22523
  const name = book.names?.find((entry2) => entry2.sheet === sheet && matches(entry2)) ?? book.names?.find((entry2) => entry2.sheet === void 0 && matches(entry2));
22508
22524
  if (!name || names.has(name)) return error("#REF!");
22509
- return indirectRange(parseNamedExpression(name, book, parse2, tick, context.limits.formulaDependencyDepth ?? Infinity), position, /* @__PURE__ */ new Set([...names, name]), depth2 + 1);
22525
+ return indirectRange(parseNamedExpression(name, book, parse2, tick, context.limits.formulaDependencyDepth ?? Infinity, node.relocation), position, /* @__PURE__ */ new Set([...names, name]), depth2 + 1);
22510
22526
  }
22511
22527
  function scalar(value, position) {
22512
22528
  const label = scalarLabels.get(value);
@@ -22580,7 +22596,7 @@ function* recalculateWorkbookSteps(input, context, options = false, onDiagnostic
22580
22596
  const matches = (entry2) => entry2.name === node.name;
22581
22597
  const name = book.names?.find((entry2) => entry2.sheet === sheet && matches(entry2)) ?? book.names?.find((entry2) => entry2.sheet === void 0 && matches(entry2));
22582
22598
  if (!name || names.has(name)) return error("#NAME?");
22583
- return evaluate(parseNamedExpression(name, book, parse2, tick, context.limits.formulaDependencyDepth ?? Infinity), position, array, /* @__PURE__ */ new Set([...names, name]), wantReference);
22599
+ return evaluate(parseNamedExpression(name, book, parse2, tick, context.limits.formulaDependencyDepth ?? Infinity, node.relocation), position, array, /* @__PURE__ */ new Set([...names, name]), wantReference);
22584
22600
  }
22585
22601
  if (node.kind === "unary") {
22586
22602
  const apply = (value) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  encodeText,
3
3
  nativeTextCharsets
4
- } from "./chunk-UGX6MXDD.js";
4
+ } from "./chunk-UIIT4ULR.js";
5
5
  import {
6
6
  encodingName
7
7
  } from "./chunk-IDR3WWKI.js";
@@ -9,17 +9,17 @@ import {
9
9
  exportRangeForSheet,
10
10
  inferText,
11
11
  parseFormula
12
- } from "./chunk-6AIOGLZO.js";
12
+ } from "./chunk-CE6Z2ULX.js";
13
13
  import {
14
14
  CodecWriteFailure,
15
15
  TextConverterUnavailable
16
- } from "./chunk-JRNLDPLI.js";
16
+ } from "./chunk-OZSWW23M.js";
17
17
  import {
18
18
  renderCellText
19
- } from "./chunk-S4J6MSLY.js";
19
+ } from "./chunk-444OTXM7.js";
20
20
  import {
21
21
  exportOptionPairs
22
- } from "./chunk-REYTQLLB.js";
22
+ } from "./chunk-TT2DMDBY.js";
23
23
  import {
24
24
  singleByteTables
25
25
  } from "./chunk-KOM3FNCE.js";
@@ -27,17 +27,17 @@ import {
27
27
  formattingLocale,
28
28
  readByteTextCharacter,
29
29
  recalculateWorkbook
30
- } from "./chunk-A6NFLWZI.js";
30
+ } from "./chunk-WKPOGTZY.js";
31
31
  import {
32
32
  exportLocale
33
- } from "./chunk-4HQ7WYSI.js";
33
+ } from "./chunk-MED2BOOW.js";
34
34
  import {
35
35
  DEFAULT_SHEET_SIZE,
36
36
  MAX_SHEET_SIZE,
37
37
  SsconvertError,
38
38
  decodeByteString,
39
39
  foldSheetName
40
- } from "./chunk-F5MORDSU.js";
40
+ } from "./chunk-FDNCPZQS.js";
41
41
  import {
42
42
  init_buffer
43
43
  } from "./chunk-HX3SHTCE.js";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  renderCellText
3
- } from "./chunk-S4J6MSLY.js";
3
+ } from "./chunk-444OTXM7.js";
4
4
  import {
5
5
  exportOptionPairs
6
- } from "./chunk-REYTQLLB.js";
6
+ } from "./chunk-TT2DMDBY.js";
7
7
  import {
8
8
  readGnumericRichText,
9
9
  writeGnumericRichText
10
- } from "./chunk-CT3FB722.js";
10
+ } from "./chunk-J7UMKBRK.js";
11
11
  import {
12
12
  richTextSegments
13
- } from "./chunk-WOPU2VWF.js";
13
+ } from "./chunk-RID3B5RE.js";
14
14
  import {
15
15
  createOdfXml,
16
16
  dateSerial,
@@ -27,10 +27,10 @@ import {
27
27
  translateOdfHyperlink,
28
28
  upgradeOdfAnnotation,
29
29
  visitFormula
30
- } from "./chunk-A6NFLWZI.js";
30
+ } from "./chunk-WKPOGTZY.js";
31
31
  import {
32
32
  converterLocale
33
- } from "./chunk-4HQ7WYSI.js";
33
+ } from "./chunk-MED2BOOW.js";
34
34
  import {
35
35
  DEFAULT_SHEET_SIZE,
36
36
  MAX_SHEET_SIZE,
@@ -46,7 +46,7 @@ import {
46
46
  quoteNativeSheet,
47
47
  quotedLabelText,
48
48
  serializeExpression
49
- } from "./chunk-F5MORDSU.js";
49
+ } from "./chunk-FDNCPZQS.js";
50
50
  import {
51
51
  createZipCodec
52
52
  } from "./chunk-MKQVQMXO.js";
@@ -1,7 +1,7 @@
1
1
  import type { CommandDefinition, VirtualShellPlugin } from "../../contracts/index.js";
2
2
  import { type PandocCommandsOptions } from "../../../safe-bash-command-pandoc/index.js";
3
3
  export * from "../../../safe-bash-command-pandoc/index.js";
4
- export declare function createPandocCommand(options?: PandocCommandsOptions): CommandDefinition;
4
+ export declare function createPandocCommand(options?: PandocCommandsOptions, hasCommand?: (name: string) => boolean): CommandDefinition;
5
5
  export declare function createPandocCommands(options?: PandocCommandsOptions): readonly CommandDefinition[];
6
6
  export declare function pandocCommands(options?: PandocCommandsOptions): VirtualShellPlugin;
7
7
  export declare function evalSyncPandoc(inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (filePath: string) => Uint8Array | undefined, writeFileSync?: (filePath: string, bytes: Uint8Array) => boolean): string | undefined;