@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
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PdfDocument,
3
3
  renderPdfPageToPng
4
- } from "./chunk-XRVNFK7Z.js";
4
+ } from "./chunk-H2FQA4OU.js";
5
5
  import {
6
6
  init_buffer
7
7
  } 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;
@@ -1,8 +1,8 @@
1
1
  import { builtInDirectContextExecutors, syncCommandEvaluators } from "../internal.js";
2
2
  import { createPandocCommand as createRawPandocCommand, createPandocCommands as createRawPandocCommands, inspectFormats, parseConversionArgs, convertSync, } from "../../../safe-bash-command-pandoc/index.js";
3
3
  export * from "../../../safe-bash-command-pandoc/index.js";
4
- export function createPandocCommand(options = {}) {
5
- const def = createRawPandocCommand(options);
4
+ export function createPandocCommand(options = {}, hasCommand) {
5
+ const def = createRawPandocCommand(options, hasCommand);
6
6
  if (options.limits === undefined && options.filters === undefined && options.jsonFilterCommand === undefined && options.citeproc === undefined) {
7
7
  builtInDirectContextExecutors.add(def.execute);
8
8
  }
@@ -17,10 +17,12 @@ export function createPandocCommands(options = {}) {
17
17
  return defs;
18
18
  }
19
19
  export function pandocCommands(options = {}) {
20
- const command = createPandocCommand(options);
20
+ let hasCommand;
21
+ const command = createPandocCommand(options, name => hasCommand?.(name) ?? false);
21
22
  return {
22
23
  name: "pandoc",
23
24
  setup(host) {
25
+ hasCommand = name => host.commands.has(name);
24
26
  host.commands.register(command, { replace: options.replace ?? false });
25
27
  },
26
28
  };
@@ -16,7 +16,7 @@ import {
16
16
  pythonCommands,
17
17
  pythonDocumentPackages,
18
18
  pythonHostFailureCode
19
- } from "../../chunks/chunk-LESPJ3OG.js";
19
+ } from "../../chunks/chunk-WNWIBBJZ.js";
20
20
  import {
21
21
  PythonFailure,
22
22
  inspectPythonCapabilities
@@ -112,6 +112,12 @@ export function createPythonCommands(options) {
112
112
  fragment = undefined;
113
113
  if (packages)
114
114
  environment.finish(packages);
115
+ // Operation failures remain reportable after all work drains. Only an
116
+ // unconfirmed interpreter termination must keep its capacity occupied.
117
+ if (results[1]?.status === 'fulfilled' && admitted) {
118
+ activeWorkers--;
119
+ admitted = false;
120
+ }
115
121
  for (const result of results)
116
122
  if (result.status === 'rejected')
117
123
  throw result.reason;
@@ -21,6 +21,8 @@ export function createPythonJspiExecutor(options) {
21
21
  let running;
22
22
  let retirement;
23
23
  let schedulerCleanup;
24
+ let interpreterFinalized = false;
25
+ let finalizationFailure;
24
26
  let cleanup;
25
27
  let runtime;
26
28
  let native;
@@ -284,7 +286,9 @@ await _safe_quiesce_tasks()
284
286
  }
285
287
  finally {
286
288
  active.value = native ? 2 : 0;
287
- finalized = Number(await engine.promising(runtime._module._Py_FinalizeEx)());
289
+ finalized = Number(await Promise.resolve().then(() => engine.promising(runtime._module._Py_FinalizeEx)())
290
+ .catch(reason => { finalizationFailure = { reason }; throw reason; }));
291
+ interpreterFinalized = true;
288
292
  }
289
293
  }
290
294
  }
@@ -330,7 +334,12 @@ await _safe_quiesce_tasks()
330
334
  controller.abort();
331
335
  await running?.catch(() => { });
332
336
  await cleanup?.catch(() => { });
333
- await schedulerCleanup;
337
+ // Callback failures remain visible on run. Once callbacks have drained and
338
+ // CPython finalized, they cannot leave an interpreter occupying capacity.
339
+ await schedulerCleanup?.catch(error => { if (!interpreterFinalized)
340
+ throw error; });
341
+ if (finalizationFailure)
342
+ throw finalizationFailure.reason;
334
343
  })();
335
344
  return retirement;
336
345
  },
@@ -158,7 +158,7 @@ import {
158
158
  sha256,
159
159
  sha384,
160
160
  sha512
161
- } from "./chunks/chunk-LESPJ3OG.js";
161
+ } from "./chunks/chunk-WNWIBBJZ.js";
162
162
  import {
163
163
  PythonFailure,
164
164
  inspectPythonCapabilities
@@ -95420,8 +95420,8 @@ import {
95420
95420
  convertSync
95421
95421
  } from "../safe-bash-command-pandoc/index.js";
95422
95422
  import * as safe_bash_command_pandoc_star from "../safe-bash-command-pandoc/index.js";
95423
- function createPandocCommand(options8 = {}) {
95424
- const def = createRawPandocCommand(options8);
95423
+ function createPandocCommand(options8 = {}, hasCommand) {
95424
+ const def = createRawPandocCommand(options8, hasCommand);
95425
95425
  if (options8.limits === void 0 && options8.filters === void 0 && options8.jsonFilterCommand === void 0 && options8.citeproc === void 0) {
95426
95426
  internal_exports.builtInDirectContextExecutors.add(def.execute);
95427
95427
  }
@@ -95435,10 +95435,12 @@ function createPandocCommands(options8 = {}) {
95435
95435
  return defs;
95436
95436
  }
95437
95437
  function pandocCommands(options8 = {}) {
95438
- const command4 = createPandocCommand(options8);
95438
+ let hasCommand;
95439
+ const command4 = createPandocCommand(options8, (name2) => hasCommand?.(name2) ?? false);
95439
95440
  return {
95440
95441
  name: "pandoc",
95441
95442
  setup(host2) {
95443
+ hasCommand = (name2) => host2.commands.has(name2);
95442
95444
  host2.commands.register(command4, { replace: options8.replace ?? false });
95443
95445
  }
95444
95446
  };
@@ -5,20 +5,20 @@ import {
5
5
  isCfb,
6
6
  readBiffRecords,
7
7
  readCfb
8
- } from "../safe-bash/command-chunks/chunk-QQOAK7JQ.js";
9
- import "../safe-bash/command-chunks/chunk-5VSGEE6J.js";
10
- import "../safe-bash/command-chunks/chunk-SG3ZDZCX.js";
8
+ } from "../safe-bash/command-chunks/chunk-KKJCKPTA.js";
9
+ import "../safe-bash/command-chunks/chunk-F4IQCXZG.js";
10
+ import "../safe-bash/command-chunks/chunk-FLMLM7Y4.js";
11
11
  import "../safe-bash/command-chunks/chunk-KOM3FNCE.js";
12
- import "../safe-bash/command-chunks/chunk-CT3FB722.js";
12
+ import "../safe-bash/command-chunks/chunk-J7UMKBRK.js";
13
13
  import "../safe-bash/command-chunks/chunk-6X2OX6IJ.js";
14
- import "../safe-bash/command-chunks/chunk-WOPU2VWF.js";
15
- import "../safe-bash/command-chunks/chunk-A6NFLWZI.js";
16
- import "../safe-bash/command-chunks/chunk-4HQ7WYSI.js";
14
+ import "../safe-bash/command-chunks/chunk-RID3B5RE.js";
15
+ import "../safe-bash/command-chunks/chunk-WKPOGTZY.js";
16
+ import "../safe-bash/command-chunks/chunk-MED2BOOW.js";
17
17
  import {
18
18
  SsconvertError,
19
19
  formatA1,
20
20
  parseA1
21
- } from "../safe-bash/command-chunks/chunk-F5MORDSU.js";
21
+ } from "../safe-bash/command-chunks/chunk-FDNCPZQS.js";
22
22
  import {
23
23
  normalizeEncoding,
24
24
  pythonCodecAliases,
@@ -14675,7 +14675,7 @@ var is = class {
14675
14675
  let n = typeof e == "string" ? new TextEncoder().encode(e) : e;
14676
14676
  this.cachedContentAst = Ba(n), this.isolatedInitialStream = false;
14677
14677
  let a = Mt(n, { compress: t });
14678
- ke(this.pageDict, "Contents", this.cosDoc.allocateObject(a)), this.cachedContentsNode = K(this.pageDict, "Contents");
14678
+ this.replaceContentStream(a), this.cachedContentsNode = K(this.pageDict, "Contents");
14679
14679
  }
14680
14680
  getIsolatedContentAst() {
14681
14681
  let e = this.getContentAst();
@@ -14684,7 +14684,25 @@ var is = class {
14684
14684
  setContentAst(e, t = true) {
14685
14685
  this.cachedContentAst = [...e];
14686
14686
  let n = qd(this.cachedContentAst), a = Mt(n, { compress: t });
14687
- ke(this.pageDict, "Contents", this.cosDoc.allocateObject(a)), this.cachedContentsNode = K(this.pageDict, "Contents");
14687
+ this.replaceContentStream(a), this.cachedContentsNode = K(this.pageDict, "Contents");
14688
+ }
14689
+ replaceContentStream(e) {
14690
+ let t = K(this.pageDict, "Contents");
14691
+ if (t?.kind === "ref") {
14692
+ let n = 0, a = [...this.cosDoc.objects.values()].map((r) => r.value), i = /* @__PURE__ */ new Set();
14693
+ for (; a.length > 0 && n < 2; ) {
14694
+ let r = a.pop();
14695
+ if (r.kind === "ref") r.objectNumber === t.objectNumber && r.generationNumber === t.generationNumber && n++;
14696
+ else if (!i.has(r)) if (i.add(r), r.kind === "array") for (let o of r.items) a.push(o);
14697
+ else if (r.kind === "dict") for (let o of r.entries) a.push(o.value);
14698
+ else r.kind === "stream" && a.push(r.dict);
14699
+ }
14700
+ if (n === 1) {
14701
+ this.cosDoc.setObject(t.objectNumber, e, t.generationNumber);
14702
+ return;
14703
+ }
14704
+ }
14705
+ ke(this.pageDict, "Contents", this.cosDoc.allocateObject(e));
14688
14706
  }
14689
14707
  drawText(e, t) {
14690
14708
  let n = t.size ?? t.fontSize ?? 12, a = t.color ?? { r: 0, g: 0, b: 0 }, i = this.getIsolatedContentAst(), r, o;
@@ -28,8 +28,8 @@ import {
28
28
  thresholdImage,
29
29
  tintImage,
30
30
  trimImage
31
- } from "../safe-bash/command-chunks/chunk-MENC7RPR.js";
32
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
31
+ } from "../safe-bash/command-chunks/chunk-WI35236J.js";
32
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
33
33
  import {
34
34
  init_buffer
35
35
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -2,11 +2,11 @@ import {
2
2
  createPandocCommand,
3
3
  createPandocCommands,
4
4
  pandocCommands
5
- } from "../safe-bash/command-chunks/chunk-KB2LQ4HG.js";
5
+ } from "../safe-bash/command-chunks/chunk-KBBI4CSU.js";
6
6
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
7
7
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
8
- import "../safe-bash/command-chunks/chunk-MENC7RPR.js";
9
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
8
+ import "../safe-bash/command-chunks/chunk-WI35236J.js";
9
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
10
10
  import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
11
11
  import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
12
12
  import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
@@ -21,11 +21,11 @@ import {
21
21
  readDocument,
22
22
  resolveConversionArgs,
23
23
  writeDocument
24
- } from "../safe-bash/command-chunks/chunk-KB2LQ4HG.js";
24
+ } from "../safe-bash/command-chunks/chunk-KBBI4CSU.js";
25
25
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
26
26
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
27
- import "../safe-bash/command-chunks/chunk-MENC7RPR.js";
28
- import "../safe-bash/command-chunks/chunk-XRVNFK7Z.js";
27
+ import "../safe-bash/command-chunks/chunk-WI35236J.js";
28
+ import "../safe-bash/command-chunks/chunk-H2FQA4OU.js";
29
29
  import {
30
30
  createLuaFilterCapability
31
31
  } from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
@@ -38482,7 +38482,7 @@ var PdfPage = class {
38482
38482
  this.cachedContentAst = parseContentStream(bytes);
38483
38483
  this.isolatedInitialStream = false;
38484
38484
  const stm = cosStream(bytes, { compress });
38485
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38485
+ this.replaceContentStream(stm);
38486
38486
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38487
38487
  }
38488
38488
  getIsolatedContentAst() {
@@ -38499,9 +38499,33 @@ var PdfPage = class {
38499
38499
  this.cachedContentAst = [...nodes];
38500
38500
  const bytes = serializeContentAst(this.cachedContentAst);
38501
38501
  const streamObj = cosStream(bytes, { compress });
38502
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38502
+ this.replaceContentStream(streamObj);
38503
38503
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38504
38504
  }
38505
+ replaceContentStream(stream) {
38506
+ const contents = dictGet(this.pageDict, "Contents");
38507
+ if (contents?.kind === "ref") {
38508
+ let references = 0;
38509
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38510
+ const visited = /* @__PURE__ */ new Set();
38511
+ while (pending.length > 0 && references < 2) {
38512
+ const node = pending.pop();
38513
+ if (node.kind === "ref") {
38514
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38515
+ } else if (!visited.has(node)) {
38516
+ visited.add(node);
38517
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38518
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38519
+ else if (node.kind === "stream") pending.push(node.dict);
38520
+ }
38521
+ }
38522
+ if (references === 1) {
38523
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38524
+ return;
38525
+ }
38526
+ }
38527
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38528
+ }
38505
38529
  drawText(text, options) {
38506
38530
  const size = options.size ?? options.fontSize ?? 12;
38507
38531
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38676,7 +38676,7 @@ var PdfPage = class {
38676
38676
  this.cachedContentAst = parseContentStream(bytes);
38677
38677
  this.isolatedInitialStream = false;
38678
38678
  const stm = cosStream(bytes, { compress });
38679
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38679
+ this.replaceContentStream(stm);
38680
38680
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38681
38681
  }
38682
38682
  getIsolatedContentAst() {
@@ -38693,9 +38693,33 @@ var PdfPage = class {
38693
38693
  this.cachedContentAst = [...nodes];
38694
38694
  const bytes = serializeContentAst(this.cachedContentAst);
38695
38695
  const streamObj = cosStream(bytes, { compress });
38696
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38696
+ this.replaceContentStream(streamObj);
38697
38697
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38698
38698
  }
38699
+ replaceContentStream(stream) {
38700
+ const contents = dictGet(this.pageDict, "Contents");
38701
+ if (contents?.kind === "ref") {
38702
+ let references = 0;
38703
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38704
+ const visited = /* @__PURE__ */ new Set();
38705
+ while (pending.length > 0 && references < 2) {
38706
+ const node = pending.pop();
38707
+ if (node.kind === "ref") {
38708
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38709
+ } else if (!visited.has(node)) {
38710
+ visited.add(node);
38711
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38712
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38713
+ else if (node.kind === "stream") pending.push(node.dict);
38714
+ }
38715
+ }
38716
+ if (references === 1) {
38717
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38718
+ return;
38719
+ }
38720
+ }
38721
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38722
+ }
38699
38723
  drawText(text, options) {
38700
38724
  const size = options.size ?? options.fontSize ?? 12;
38701
38725
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38701,7 +38701,7 @@ var PdfPage = class {
38701
38701
  this.cachedContentAst = parseContentStream(bytes);
38702
38702
  this.isolatedInitialStream = false;
38703
38703
  const stm = cosStream(bytes, { compress });
38704
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38704
+ this.replaceContentStream(stm);
38705
38705
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38706
38706
  }
38707
38707
  getIsolatedContentAst() {
@@ -38718,9 +38718,33 @@ var PdfPage = class {
38718
38718
  this.cachedContentAst = [...nodes];
38719
38719
  const bytes = serializeContentAst(this.cachedContentAst);
38720
38720
  const streamObj = cosStream(bytes, { compress });
38721
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38721
+ this.replaceContentStream(streamObj);
38722
38722
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38723
38723
  }
38724
+ replaceContentStream(stream) {
38725
+ const contents = dictGet(this.pageDict, "Contents");
38726
+ if (contents?.kind === "ref") {
38727
+ let references = 0;
38728
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38729
+ const visited = /* @__PURE__ */ new Set();
38730
+ while (pending.length > 0 && references < 2) {
38731
+ const node = pending.pop();
38732
+ if (node.kind === "ref") {
38733
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38734
+ } else if (!visited.has(node)) {
38735
+ visited.add(node);
38736
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38737
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38738
+ else if (node.kind === "stream") pending.push(node.dict);
38739
+ }
38740
+ }
38741
+ if (references === 1) {
38742
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38743
+ return;
38744
+ }
38745
+ }
38746
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38747
+ }
38724
38748
  drawText(text, options) {
38725
38749
  const size = options.size ?? options.fontSize ?? 12;
38726
38750
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38331,7 +38331,7 @@ var PdfPage = class {
38331
38331
  this.cachedContentAst = parseContentStream(bytes);
38332
38332
  this.isolatedInitialStream = false;
38333
38333
  const stm = cosStream(bytes, { compress });
38334
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38334
+ this.replaceContentStream(stm);
38335
38335
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38336
38336
  }
38337
38337
  getIsolatedContentAst() {
@@ -38348,9 +38348,33 @@ var PdfPage = class {
38348
38348
  this.cachedContentAst = [...nodes];
38349
38349
  const bytes = serializeContentAst(this.cachedContentAst);
38350
38350
  const streamObj = cosStream(bytes, { compress });
38351
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38351
+ this.replaceContentStream(streamObj);
38352
38352
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38353
38353
  }
38354
+ replaceContentStream(stream) {
38355
+ const contents = dictGet(this.pageDict, "Contents");
38356
+ if (contents?.kind === "ref") {
38357
+ let references = 0;
38358
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38359
+ const visited = /* @__PURE__ */ new Set();
38360
+ while (pending.length > 0 && references < 2) {
38361
+ const node = pending.pop();
38362
+ if (node.kind === "ref") {
38363
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38364
+ } else if (!visited.has(node)) {
38365
+ visited.add(node);
38366
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38367
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38368
+ else if (node.kind === "stream") pending.push(node.dict);
38369
+ }
38370
+ }
38371
+ if (references === 1) {
38372
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38373
+ return;
38374
+ }
38375
+ }
38376
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38377
+ }
38354
38378
  drawText(text, options) {
38355
38379
  const size = options.size ?? options.fontSize ?? 12;
38356
38380
  const color = options.color ?? { r: 0, g: 0, b: 0 };
@@ -38482,7 +38482,7 @@ var PdfPage = class {
38482
38482
  this.cachedContentAst = parseContentStream(bytes);
38483
38483
  this.isolatedInitialStream = false;
38484
38484
  const stm = cosStream(bytes, { compress });
38485
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stm));
38485
+ this.replaceContentStream(stm);
38486
38486
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38487
38487
  }
38488
38488
  getIsolatedContentAst() {
@@ -38499,9 +38499,33 @@ var PdfPage = class {
38499
38499
  this.cachedContentAst = [...nodes];
38500
38500
  const bytes = serializeContentAst(this.cachedContentAst);
38501
38501
  const streamObj = cosStream(bytes, { compress });
38502
- dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(streamObj));
38502
+ this.replaceContentStream(streamObj);
38503
38503
  this.cachedContentsNode = dictGet(this.pageDict, "Contents");
38504
38504
  }
38505
+ replaceContentStream(stream) {
38506
+ const contents = dictGet(this.pageDict, "Contents");
38507
+ if (contents?.kind === "ref") {
38508
+ let references = 0;
38509
+ const pending = [...this.cosDoc.objects.values()].map((object) => object.value);
38510
+ const visited = /* @__PURE__ */ new Set();
38511
+ while (pending.length > 0 && references < 2) {
38512
+ const node = pending.pop();
38513
+ if (node.kind === "ref") {
38514
+ if (node.objectNumber === contents.objectNumber && node.generationNumber === contents.generationNumber) references++;
38515
+ } else if (!visited.has(node)) {
38516
+ visited.add(node);
38517
+ if (node.kind === "array") for (const item of node.items) pending.push(item);
38518
+ else if (node.kind === "dict") for (const entry of node.entries) pending.push(entry.value);
38519
+ else if (node.kind === "stream") pending.push(node.dict);
38520
+ }
38521
+ }
38522
+ if (references === 1) {
38523
+ this.cosDoc.setObject(contents.objectNumber, stream, contents.generationNumber);
38524
+ return;
38525
+ }
38526
+ }
38527
+ dictSet(this.pageDict, "Contents", this.cosDoc.allocateObject(stream));
38528
+ }
38505
38529
  drawText(text, options) {
38506
38530
  const size = options.size ?? options.fontSize ?? 12;
38507
38531
  const color = options.color ?? { r: 0, g: 0, b: 0 };