@poe-platform/safe-bash 0.1.756 → 0.1.758

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 (161) hide show
  1. package/dist/image-ast/index.browser.js +76 -23
  2. package/dist/image-ast/index.js +76 -23
  3. package/dist/pdf-ast/ast.d.ts +3 -0
  4. package/dist/pdf-ast/index.js +88 -36
  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-F3J5ZLKF.js → chunk-522TDVLS.js} +1 -1
  8. package/dist/safe-bash/command-chunks/{chunk-VFS2MDAB.js → chunk-6YLD37NH.js} +2 -2
  9. package/dist/safe-bash/command-chunks/{chunk-YI3GKJ7Q.js → chunk-766IWMTB.js} +2 -2
  10. package/dist/safe-bash/command-chunks/{chunk-6AIOGLZO.js → chunk-CE6Z2ULX.js} +2 -2
  11. package/dist/safe-bash/command-chunks/{chunk-KSH2F6RG.js → chunk-CUFCNL6G.js} +1 -1
  12. package/dist/safe-bash/command-chunks/{chunk-5VSGEE6J.js → chunk-F4IQCXZG.js} +5 -5
  13. package/dist/safe-bash/command-chunks/{chunk-F5MORDSU.js → chunk-FDNCPZQS.js} +32 -1
  14. package/dist/safe-bash/command-chunks/{chunk-SG3ZDZCX.js → chunk-FLMLM7Y4.js} +2 -2
  15. package/dist/safe-bash/command-chunks/{chunk-DVZCHNB5.js → chunk-J2NPH7DO.js} +11 -7
  16. package/dist/safe-bash/command-chunks/{chunk-CT3FB722.js → chunk-J7UMKBRK.js} +1 -1
  17. package/dist/safe-bash/command-chunks/{chunk-QQOAK7JQ.js → chunk-KKJCKPTA.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-7KS6PX4U.js → chunk-KSIGF4AG.js} +3 -3
  19. package/dist/safe-bash/command-chunks/{chunk-KBBI4CSU.js → chunk-L2C5TIII.js} +2 -2
  20. package/dist/safe-bash/command-chunks/{chunk-4HQ7WYSI.js → chunk-MED2BOOW.js} +30 -5
  21. package/dist/safe-bash/command-chunks/{chunk-JRNLDPLI.js → chunk-OZSWW23M.js} +1 -1
  22. package/dist/safe-bash/command-chunks/{chunk-DKQ5REXF.js → chunk-QDPRSPHQ.js} +1 -1
  23. package/dist/safe-bash/command-chunks/{chunk-WOPU2VWF.js → chunk-RID3B5RE.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-H2FQA4OU.js → chunk-TCAGGM44.js} +72 -19
  25. package/dist/safe-bash/command-chunks/{chunk-REYTQLLB.js → chunk-TT2DMDBY.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-UGX6MXDD.js → chunk-UIIT4ULR.js} +3 -3
  27. package/dist/safe-bash/command-chunks/{chunk-A6NFLWZI.js → chunk-WKPOGTZY.js} +22 -6
  28. package/dist/safe-bash/command-chunks/{chunk-WI35236J.js → chunk-XYCWDGOG.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-3DOHQQJR.js → chunk-Y64PA6IA.js} +8 -8
  30. package/dist/safe-bash/command-chunks/{chunk-4F6PG2OT.js → chunk-YJWWRCIG.js} +8 -8
  31. package/dist/safe-bash/command-chunks/{chunk-6Z7OS3TZ.js → chunk-ZP5KDHB4.js} +7 -7
  32. package/dist/safe-bash/commands/pandoc/index.d.ts +1 -1
  33. package/dist/safe-bash/commands/pandoc/index.js +5 -3
  34. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  35. package/dist/safe-bash/commands/python/index.js +6 -0
  36. package/dist/safe-bash/commands/python/jspi.js +11 -2
  37. package/dist/safe-bash/core.browser.js +6 -4
  38. package/dist/safe-bash-command-column/column.js +3 -3
  39. package/dist/safe-bash-command-column/index.js +3 -3
  40. package/dist/safe-bash-command-column/layout.js +2 -2
  41. package/dist/safe-bash-command-csvkit/index.js +8 -8
  42. package/dist/safe-bash-command-factor/command.js +2 -2
  43. package/dist/safe-bash-command-factor/index.js +2 -2
  44. package/dist/safe-bash-command-ffmpeg/index.js +5923 -5893
  45. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  46. package/dist/safe-bash-command-pandoc/command.js +3 -3
  47. package/dist/safe-bash-command-pandoc/index.js +3 -3
  48. package/dist/safe-bash-command-pdfimages/index.js +72 -19
  49. package/dist/safe-bash-command-pdfinfo/index.js +88 -36
  50. package/dist/safe-bash-command-pdftk/index.js +72 -19
  51. package/dist/safe-bash-command-pdftoppm/index.js +88 -36
  52. package/dist/safe-bash-command-pdftotext/index.js +72 -19
  53. package/dist/safe-bash-command-qpdf/index.js +72 -19
  54. package/dist/safe-bash-command-sips/index.js +2 -2
  55. package/dist/safe-bash-command-soffice/index.js +17 -17
  56. package/dist/safe-bash-command-ssconvert/command-bindings.d.ts +18 -0
  57. package/dist/safe-bash-command-ssconvert/command.d.ts +5 -14
  58. package/dist/safe-bash-command-ssconvert/commands.d.ts +6 -0
  59. package/dist/safe-bash-command-ssconvert/commands.js +871 -0
  60. package/dist/safe-bash-command-ssconvert/core.js +8 -8
  61. package/dist/safe-bash-command-ssconvert/formats/csv.js +9 -9
  62. package/dist/safe-bash-command-ssconvert/formats/ods.js +8 -8
  63. package/dist/safe-bash-command-ssconvert/formats/spreadsheetml.js +1 -1
  64. package/dist/safe-bash-command-ssconvert/formats/xls.js +9 -8
  65. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +8 -8
  66. package/dist/safe-bash-command-ssconvert/index.js +376 -236
  67. package/dist/safe-bash-command-wkhtmltopdf/index.js +72 -19
  68. package/dist/safe-bash-command-yq/index.js +4 -4
  69. package/dist/safe-bash-compression-engine/files.js +2 -2
  70. package/dist/safe-bash-compression-engine/operand.js +4 -4
  71. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  72. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  73. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  74. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  75. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  76. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  77. package/dist/safe-bash-markdown-engine/index.js +7 -7
  78. package/dist/safe-bash-mcp/index.js +4 -4
  79. package/dist/safe-bash-query-engine/index.js +5 -5
  80. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  81. package/dist/safe-bash-query-engine/query-core.js +5 -5
  82. package/dist/spreadsheet-engine/formulas/ast.d.ts +13 -0
  83. package/dist/spreadsheet-engine/formulas/conventions.js +1 -1
  84. package/dist/spreadsheet-engine/formulas/dependencies.js +2 -2
  85. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -2
  86. package/dist/spreadsheet-engine/formulas/named-expressions.d.ts +2 -2
  87. package/dist/spreadsheet-engine/formulas/named-expressions.js +31 -5
  88. package/dist/spreadsheet-engine/formulas/parser.js +34 -0
  89. package/dist/spreadsheet-engine/formulas/rewriting.js +19 -1
  90. package/dist/spreadsheet-engine/formulas/serialization.js +6 -0
  91. package/dist/spreadsheet-format-xls/biff-write-formulas.js +2 -0
  92. package/dist/xlsx-ast/formula-semantics.js +2 -0
  93. package/package.json +6 -2
  94. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +16 -0
  95. package/dist/safe-bash/chunks/browser-ECQX6GMK.js +0 -6766
  96. package/dist/safe-bash/chunks/bz2-4OP3OWW3.js +0 -8
  97. package/dist/safe-bash/chunks/chunk-22XPAAOI.js +0 -173
  98. package/dist/safe-bash/chunks/chunk-44WUNUPV.js +0 -649
  99. package/dist/safe-bash/chunks/chunk-4E3SGG37.js +0 -876
  100. package/dist/safe-bash/chunks/chunk-4QTSSQKP.js +0 -898
  101. package/dist/safe-bash/chunks/chunk-5UVGPVXP.js +0 -410
  102. package/dist/safe-bash/chunks/chunk-64OE6Q6X.js +0 -3487
  103. package/dist/safe-bash/chunks/chunk-6IIFUPN2.js +0 -1526
  104. package/dist/safe-bash/chunks/chunk-BENDLTQD.js +0 -7065
  105. package/dist/safe-bash/chunks/chunk-BMO5LWEX.js +0 -534
  106. package/dist/safe-bash/chunks/chunk-BPMCPTNP.js +0 -1920
  107. package/dist/safe-bash/chunks/chunk-BRJTAWP5.js +0 -2955
  108. package/dist/safe-bash/chunks/chunk-C3GEIN7Q.js +0 -20054
  109. package/dist/safe-bash/chunks/chunk-CBVANNKK.js +0 -174814
  110. package/dist/safe-bash/chunks/chunk-CEWCRI6H.js +0 -2813
  111. package/dist/safe-bash/chunks/chunk-CGL53DQQ.js +0 -37
  112. package/dist/safe-bash/chunks/chunk-CTYJJD4O.js +0 -869
  113. package/dist/safe-bash/chunks/chunk-CWSS4MQA.js +0 -7
  114. package/dist/safe-bash/chunks/chunk-DLIGMTCP.js +0 -3266
  115. package/dist/safe-bash/chunks/chunk-EMAJ7WUW.js +0 -1031
  116. package/dist/safe-bash/chunks/chunk-FDKIZ2IJ.js +0 -1950
  117. package/dist/safe-bash/chunks/chunk-FZWJ2A7V.js +0 -3093
  118. package/dist/safe-bash/chunks/chunk-G2VCIF2J.js +0 -22
  119. package/dist/safe-bash/chunks/chunk-GVKBUQDX.js +0 -2649
  120. package/dist/safe-bash/chunks/chunk-IO2OGW3E.js +0 -28051
  121. package/dist/safe-bash/chunks/chunk-ISCZG7WA.js +0 -2648
  122. package/dist/safe-bash/chunks/chunk-JCN3FXLP.js +0 -38983
  123. package/dist/safe-bash/chunks/chunk-KJHDD4A2.js +0 -759
  124. package/dist/safe-bash/chunks/chunk-LB6HVRXS.js +0 -857
  125. package/dist/safe-bash/chunks/chunk-LLWAJOZH.js +0 -15
  126. package/dist/safe-bash/chunks/chunk-LMUKYZIJ.js +0 -708
  127. package/dist/safe-bash/chunks/chunk-M5SCNKIK.js +0 -2012
  128. package/dist/safe-bash/chunks/chunk-MJPFHANT.js +0 -3350
  129. package/dist/safe-bash/chunks/chunk-MZQW2DOL.js +0 -82
  130. package/dist/safe-bash/chunks/chunk-NB2V7EOY.js +0 -1348
  131. package/dist/safe-bash/chunks/chunk-NJVGOIYN.js +0 -17
  132. package/dist/safe-bash/chunks/chunk-OLNZHDIQ.js +0 -5141
  133. package/dist/safe-bash/chunks/chunk-OSUXMC43.js +0 -2317
  134. package/dist/safe-bash/chunks/chunk-OUUVROTM.js +0 -38
  135. package/dist/safe-bash/chunks/chunk-PA6GYKBQ.js +0 -151
  136. package/dist/safe-bash/chunks/chunk-PEFHZ226.js +0 -6957
  137. package/dist/safe-bash/chunks/chunk-QBB5P5KW.js +0 -4839
  138. package/dist/safe-bash/chunks/chunk-RSAWYAEH.js +0 -973
  139. package/dist/safe-bash/chunks/chunk-UWLYRWT4.js +0 -739
  140. package/dist/safe-bash/chunks/chunk-V463NBQH.js +0 -13
  141. package/dist/safe-bash/chunks/chunk-WPUALYUS.js +0 -843
  142. package/dist/safe-bash/chunks/chunk-XHKFSRGU.js +0 -5747
  143. package/dist/safe-bash/chunks/chunk-XHRCLZ3N.js +0 -13391
  144. package/dist/safe-bash/chunks/chunk-XPF5XHLY.js +0 -15
  145. package/dist/safe-bash/chunks/chunk-ZBFOWARG.js +0 -305
  146. package/dist/safe-bash/chunks/chunk-ZG7GWQ5P.js +0 -1859
  147. package/dist/safe-bash/chunks/model-store-EIY3ZQLZ.js +0 -10
  148. package/dist/safe-bash/chunks/pdf-renderer-CMF3CSVU.js +0 -22
  149. package/dist/safe-bash/chunks/pptx-ZL6L7KP2-O425BFIU.js +0 -30658
  150. package/dist/safe-bash/chunks/src-HHEPGR7U.js +0 -18969
  151. package/dist/safe-bash/chunks/src-MXIKQCIC.js +0 -187
  152. package/dist/safe-bash/chunks/usage-6TGVA2OM.js +0 -35
  153. package/dist/safe-bash/chunks/xz-EGQGQUEI.js +0 -8
  154. package/dist/safe-bash/chunks/xz-K2E2WLM6.js +0 -9
  155. package/dist/safe-bash/chunks/zstd-6JBLP5EF.js +0 -8
  156. package/dist/safe-bash/git_rust-C3QYOAZL.wasm +0 -0
  157. package/dist/safe-bash/command-chunks/{chunk-OQVIJMBY.js → chunk-7HINP7ZK.js} +4 -4
  158. package/dist/safe-bash/command-chunks/{chunk-XAYEDOV5.js → chunk-CG4JSOK2.js} +3 -3
  159. package/dist/safe-bash/command-chunks/{chunk-YIK4ZYQ4.js → chunk-DC52GWRK.js} +9 -9
  160. package/dist/safe-bash/command-chunks/{chunk-TOTZFBDT.js → chunk-TKACIO4X.js} +4 -4
  161. package/dist/safe-bash/command-chunks/{chunk-VTWKS4RM.js → chunk-WF2LSKMI.js} +3 -3
@@ -4540,7 +4540,7 @@ function decryptCosDocument(doc, state) {
4540
4540
  doc.objects.set(num, { objectNumber: obj.objectNumber, generationNumber: obj.generationNumber, value: decrypted, span: obj.span });
4541
4541
  }
4542
4542
  }
4543
- function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false) {
4543
+ function parseNodeFromLexer(lexer, bytes, maxDepth, repair = false) {
4544
4544
  const stack = [];
4545
4545
  while (true) {
4546
4546
  const tok = lexer.nextToken();
@@ -4549,7 +4549,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
4549
4549
  if (!parent) return void 0;
4550
4550
  throw new PdfError("E_PARSE", parent.kind === "array" ? "Unterminated PDF array" : "Unterminated PDF dictionary");
4551
4551
  }
4552
- if (!parent && recoverEmptyObject && tok.kind === "keyword" && tok.value === "endobj") {
4552
+ if (!parent && repair && tok.kind === "keyword" && tok.value === "endobj") {
4553
4553
  return { kind: "null", span: tok.span };
4554
4554
  }
4555
4555
  let node;
@@ -4564,6 +4564,7 @@ function parseNodeFromLexer(lexer, bytes, maxDepth, recoverEmptyObject = false)
4564
4564
  parent.key = { kind: "name", rawBytes: tok.rawBytes, decoded: tok.decoded, span: tok.span };
4565
4565
  continue;
4566
4566
  } else {
4567
+ if (repair) continue;
4567
4568
  throw new PdfError("E_PARSE", `Expected dictionary key /Name, got ${tok.kind}`);
4568
4569
  }
4569
4570
  } else {
@@ -4730,7 +4731,7 @@ function parseHeaderVersion(bytes) {
4730
4731
  }
4731
4732
  return head.slice(idx + 5, idx + 8);
4732
4733
  }
4733
- function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObject = false) {
4734
+ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, repair = false) {
4734
4735
  const lexer = new CosByteLexer(bytes, offset);
4735
4736
  const objNumTok = lexer.nextToken();
4736
4737
  const genNumTok = lexer.nextToken();
@@ -4738,7 +4739,7 @@ function parseObjectAtOffset(bytes, offset, maxRecursionDepth, recoverEmptyObjec
4738
4739
  if (objNumTok?.kind !== "number" || genNumTok?.kind !== "number" || objKwTok?.kind !== "keyword" || objKwTok.value !== "obj") {
4739
4740
  throw new PdfError("E_PARSE", `Malformed indirect object header at byte offset ${offset}`);
4740
4741
  }
4741
- const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, recoverEmptyObject);
4742
+ const value = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, repair);
4742
4743
  if (!value) {
4743
4744
  throw new PdfError("E_PARSE", `Empty indirect object ${objNumTok.value} at offset ${offset}`);
4744
4745
  }
@@ -4927,7 +4928,7 @@ function repairScanCosDocument(bytes, maxObjects, maxRecursionDepth) {
4927
4928
  try {
4928
4929
  const token = lexer.nextToken();
4929
4930
  if (token?.kind === "keyword" && token.value === "trailer") {
4930
- const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth);
4931
+ const trailer = parseNodeFromLexer(lexer, bytes, maxRecursionDepth, true);
4931
4932
  if (trailer?.kind === "dict") trailers.push(trailer);
4932
4933
  pos = lexer.offset;
4933
4934
  continue;
@@ -4983,7 +4984,7 @@ function unpackRecoveredObjects(objects, maxObjects, maxDecompressedBytes, maxRe
4983
4984
  const t = dictGet(obj.value.dict, "Type");
4984
4985
  if (t?.kind === "name" && t.decoded === "ObjStm") {
4985
4986
  try {
4986
- for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth).entries()) {
4987
+ for (const [unpackedNum, unpackedVal] of unpackObjectStream(obj.value, maxDecompressedBytes, maxRecursionDepth, true).entries()) {
4987
4988
  if (!objects.has(unpackedNum)) {
4988
4989
  objects.set(unpackedNum, {
4989
4990
  objectNumber: unpackedNum,
@@ -5019,7 +5020,7 @@ function recoveredReferences(objects) {
5019
5020
  }
5020
5021
  return { ...rootRef ? { rootRef } : {}, ...infoRef ? { infoRef } : {} };
5021
5022
  }
5022
- function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth) {
5023
+ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth, repair = false) {
5023
5024
  const nNode = dictGet(streamObj.dict, "N");
5024
5025
  const firstNode = dictGet(streamObj.dict, "First");
5025
5026
  if (nNode?.kind !== "number" || firstNode?.kind !== "number") {
@@ -5039,7 +5040,7 @@ function unpackObjectStream(streamObj, maxDecompressedBytes, maxRecursionDepth)
5039
5040
  for (const pair of pairs) {
5040
5041
  try {
5041
5042
  const valLexer = new CosByteLexer(decoded, firstNode.value + pair.relativeOffset);
5042
- const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth);
5043
+ const node = parseNodeFromLexer(valLexer, decoded, maxRecursionDepth, repair);
5043
5044
  if (node) {
5044
5045
  result.set(pair.objectNumber, node);
5045
5046
  }
@@ -5222,7 +5223,7 @@ function parseCosDocument(bytes, options = {}) {
5222
5223
  if (!unpacked) {
5223
5224
  const stmObj = objects.get(entry.objectStreamNumber)?.value;
5224
5225
  if (stmObj?.kind === "stream") {
5225
- unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth);
5226
+ unpacked = unpackObjectStream(stmObj, maxDecompressedBytes, maxRecursionDepth, recovery === "repair");
5226
5227
  objStmCache.set(entry.objectStreamNumber, unpacked);
5227
5228
  }
5228
5229
  }
@@ -10469,7 +10470,11 @@ function resolvePageFonts(doc, resourcesDict) {
10469
10470
  let cmap;
10470
10471
  const toUniNode = doc.resolve(dictGet(fObj, "ToUnicode"));
10471
10472
  if (toUniNode?.kind === "stream") {
10472
- cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
10473
+ try {
10474
+ cmap = parseToUnicodeCMap(doc.decodeStream(toUniNode));
10475
+ } catch (error) {
10476
+ if (error instanceof PdfError && error.code === "E_LIMIT") throw error;
10477
+ }
10473
10478
  }
10474
10479
  const encNode = doc.resolve(dictGet(fObj, "Encoding"));
10475
10480
  if (encNode?.kind === "dict") {
@@ -11593,8 +11598,12 @@ function evaluateContentStreamToDisplayList(params) {
11593
11598
  const images = [];
11594
11599
  const operations = [];
11595
11600
  const emit = (operation) => {
11596
- const clipPaths = curState().clipPaths;
11597
- if (clipPaths) operation = { ...operation, value: { ...operation.value, clipPaths } };
11601
+ const { clipPaths, clipImages } = curState();
11602
+ if (clipPaths || clipImages) operation = { ...operation, value: {
11603
+ ...operation.value,
11604
+ ...clipPaths ? { clipPaths } : {},
11605
+ ...clipImages ? { clipImages } : {}
11606
+ } };
11598
11607
  operations.push(operation);
11599
11608
  switch (operation.kind) {
11600
11609
  case "path":
@@ -11858,6 +11867,18 @@ function evaluateContentStreamToDisplayList(params) {
11858
11867
  let hasTextClip = false;
11859
11868
  let activeTm = [1, 0, 0, 1, 0, 0];
11860
11869
  let activeTlm = [1, 0, 0, 1, 0, 0];
11870
+ const paintImage = (image, patternMask, resources, activeFonts, depth) => {
11871
+ if (!patternMask) {
11872
+ emit({ kind: "image", value: image });
11873
+ return;
11874
+ }
11875
+ const st = curState();
11876
+ stateStack.push({ ...st, clipImages: [...st.clipImages ?? [], image] });
11877
+ walkNodes([{ kind: "path-op", paint: "f", segments: [
11878
+ { kind: "rect", x: 0, y: 0, width: 1, height: 1 }
11879
+ ] }], void 0, void 0, resources, activeFonts, depth);
11880
+ stateStack.pop();
11881
+ };
11861
11882
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
11862
11883
  for (const node of nodes) {
11863
11884
  switch (node.kind) {
@@ -12041,7 +12062,8 @@ function evaluateContentStreamToDisplayList(params) {
12041
12062
  st.fillAlpha,
12042
12063
  "PatternShading_" + st.fillPatternName,
12043
12064
  patClip,
12044
- shading?.kind === "stream" ? shading : void 0
12065
+ shading?.kind === "stream" ? shading : void 0,
12066
+ st.blendMode
12045
12067
  );
12046
12068
  if (shImg) {
12047
12069
  emit({ kind: "image", value: shImg });
@@ -12150,18 +12172,20 @@ function evaluateContentStreamToDisplayList(params) {
12150
12172
  const subNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "Subtype"));
12151
12173
  const sub = subNode?.kind === "name" ? subNode.decoded : "";
12152
12174
  if (sub === "Image") {
12175
+ const maskNode = params.cosDoc.resolve(dictGet(xobjNode.dict, "ImageMask"));
12176
+ const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
12153
12177
  const decoded = decodeXObjectImageToRgba(
12154
12178
  params.cosDoc,
12155
12179
  xobjNode,
12156
12180
  activeResources,
12157
- {
12181
+ patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
12158
12182
  r: st.fillColor.r,
12159
12183
  g: st.fillColor.g,
12160
12184
  b: st.fillColor.b,
12161
12185
  alpha: st.fillAlpha
12162
12186
  }
12163
12187
  );
12164
- emit({ kind: "image", value: {
12188
+ paintImage({
12165
12189
  name: node.name,
12166
12190
  matrix: [...st.ctm],
12167
12191
  width: decoded.width,
@@ -12171,7 +12195,7 @@ function evaluateContentStreamToDisplayList(params) {
12171
12195
  decodedRgba: decoded.rgba,
12172
12196
  ...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
12173
12197
  ...st.clipRect ? { clipRect: [...st.clipRect] } : {}
12174
- } });
12198
+ }, patternMask, activeResources, activeFonts, depth);
12175
12199
  } else if (sub === "Form" && depth < 8) {
12176
12200
  const formStreamBytes = params.cosDoc.decodeStream(xobjNode);
12177
12201
  const formNodes = parseContentStream(formStreamBytes);
@@ -12227,19 +12251,22 @@ function evaluateContentStreamToDisplayList(params) {
12227
12251
  }
12228
12252
  case "inline-image": {
12229
12253
  const st = curState();
12254
+ const maskEntry = dictGet(node.dict, "ImageMask") ?? dictGet(node.dict, "IM");
12255
+ const maskNode = params.cosDoc ? params.cosDoc.resolve(maskEntry) : maskEntry;
12256
+ const patternMask = !!st.fillPatternName && maskNode?.kind === "boolean" && maskNode.value;
12230
12257
  const decoded = decodeInlineImageNodeToRgba(
12231
12258
  params.cosDoc,
12232
12259
  node.dict,
12233
12260
  node.data,
12234
12261
  activeResources,
12235
- {
12262
+ patternMask ? { r: 1, g: 1, b: 1, alpha: 1 } : {
12236
12263
  r: st.fillColor.r,
12237
12264
  g: st.fillColor.g,
12238
12265
  b: st.fillColor.b,
12239
12266
  alpha: st.fillAlpha
12240
12267
  }
12241
12268
  );
12242
- emit({ kind: "image", value: {
12269
+ paintImage({
12243
12270
  name: "InlineImage",
12244
12271
  matrix: [...st.ctm],
12245
12272
  width: decoded.width,
@@ -12249,7 +12276,7 @@ function evaluateContentStreamToDisplayList(params) {
12249
12276
  decodedRgba: decoded.rgba,
12250
12277
  ...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
12251
12278
  ...st.clipRect ? { clipRect: [...st.clipRect] } : {}
12252
- } });
12279
+ }, patternMask, activeResources, activeFonts, depth);
12253
12280
  break;
12254
12281
  }
12255
12282
  case "text-object": {
@@ -14502,6 +14529,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
14502
14529
  const aaVec = options.antialiasVector !== false;
14503
14530
  const aaTxt = options.antialiasText !== false;
14504
14531
  const clipMasks = /* @__PURE__ */ new Map();
14532
+ const imageClipMasks = /* @__PURE__ */ new Map();
14505
14533
  for (const original of paintOperations(displayList)) {
14506
14534
  if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
14507
14535
  const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
@@ -14516,6 +14544,31 @@ function renderDisplayListToBitmap(displayList, options = {}) {
14516
14544
  }
14517
14545
  clipMasks.set(clips, clipMask);
14518
14546
  }
14547
+ const imageClips = original.value.clipImages;
14548
+ if (imageClips) {
14549
+ let imageMask = imageClipMasks.get(imageClips);
14550
+ if (!imageMask) {
14551
+ imageMask = new Uint8Array(width * height * 4).fill(255);
14552
+ for (const image of imageClips) {
14553
+ const layer = renderDisplayListToBitmap({
14554
+ ...displayList,
14555
+ rotation: 0,
14556
+ paths: [],
14557
+ glyphs: [],
14558
+ images: [image],
14559
+ operations: [{ kind: "image", value: image }]
14560
+ }, { scale, transparent: true }).data;
14561
+ for (let i = 3; i < layer.length; i += 4) imageMask[i] = Math.round(imageMask[i] * layer[i] / 255);
14562
+ }
14563
+ imageClipMasks.set(imageClips, imageMask);
14564
+ }
14565
+ if (clipMask) {
14566
+ clipMask = clipMask.slice();
14567
+ for (let i = 3; i < clipMask.length; i += 4) clipMask[i] = Math.round(clipMask[i] * imageMask[i] / 255);
14568
+ } else {
14569
+ clipMask = imageMask;
14570
+ }
14571
+ }
14519
14572
  if (operation.kind === "path") {
14520
14573
  const path = operation.value;
14521
14574
  if (path.fillColor) {
@@ -9,15 +9,15 @@ import {
9
9
  resolveYqLimits,
10
10
  yqCaps
11
11
  } from "../safe-bash/command-chunks/chunk-LOAD233I.js";
12
+ import {
13
+ YqError,
14
+ fromJqLimit
15
+ } from "../safe-bash/command-chunks/chunk-HACCCNFF.js";
12
16
  import {
13
17
  encodeJson,
14
18
  encodeRaw,
15
19
  encodeYaml
16
20
  } from "../safe-bash/command-chunks/chunk-7DEZJSBF.js";
17
- import {
18
- YqError,
19
- fromJqLimit
20
- } from "../safe-bash/command-chunks/chunk-HACCCNFF.js";
21
21
  import {
22
22
  init_buffer
23
23
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -4,7 +4,8 @@ import {
4
4
  unchangedSource,
5
5
  verifyOperandDestinations,
6
6
  writeFileOperand
7
- } from "../safe-bash/command-chunks/chunk-XAYEDOV5.js";
7
+ } from "../safe-bash/command-chunks/chunk-CG4JSOK2.js";
8
+ import "../safe-bash/command-chunks/chunk-LVEHHFOV.js";
8
9
  import "../safe-bash/command-chunks/chunk-E5TEVROY.js";
9
10
  import "../safe-bash/command-chunks/chunk-3ZK5F23O.js";
10
11
  import "../safe-bash/command-chunks/chunk-6NTY42E5.js";
@@ -14,7 +15,6 @@ import "../safe-bash/command-chunks/chunk-KHGQDFQ7.js";
14
15
  import "../safe-bash/command-chunks/chunk-A7L65T2H.js";
15
16
  import "../safe-bash/command-chunks/chunk-2MFNTNK7.js";
16
17
  import "../safe-bash/command-chunks/chunk-Z6SFT6OC.js";
17
- import "../safe-bash/command-chunks/chunk-LVEHHFOV.js";
18
18
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
19
19
  import "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
20
20
  export {
@@ -2,7 +2,10 @@ import {
2
2
  sourceBytes,
3
3
  unchangedSource,
4
4
  writeFileOperand
5
- } from "../safe-bash/command-chunks/chunk-XAYEDOV5.js";
5
+ } from "../safe-bash/command-chunks/chunk-CG4JSOK2.js";
6
+ import {
7
+ FileOperation
8
+ } from "../safe-bash/command-chunks/chunk-LVEHHFOV.js";
6
9
  import {
7
10
  transform
8
11
  } from "../safe-bash/command-chunks/chunk-E5TEVROY.js";
@@ -14,9 +17,6 @@ import "../safe-bash/command-chunks/chunk-KHGQDFQ7.js";
14
17
  import "../safe-bash/command-chunks/chunk-A7L65T2H.js";
15
18
  import "../safe-bash/command-chunks/chunk-2MFNTNK7.js";
16
19
  import "../safe-bash/command-chunks/chunk-Z6SFT6OC.js";
17
- import {
18
- FileOperation
19
- } from "../safe-bash/command-chunks/chunk-LVEHHFOV.js";
20
20
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
21
21
  import {
22
22
  init_buffer
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  openCommandFile
3
- } from "../safe-bash/command-chunks/chunk-7KS6PX4U.js";
3
+ } from "../safe-bash/command-chunks/chunk-KSIGF4AG.js";
4
4
  import "../safe-bash/command-chunks/chunk-PTLDMI4O.js";
5
5
  import "../safe-bash/command-chunks/chunk-U6CJOXRY.js";
6
6
  import "../safe-bash/command-chunks/chunk-WYJTWJZ5.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  openCommandFile
3
- } from "../safe-bash/command-chunks/chunk-7KS6PX4U.js";
3
+ } from "../safe-bash/command-chunks/chunk-KSIGF4AG.js";
4
4
  import {
5
5
  assertCountedFileOutput,
6
6
  bindFileOutputBudget,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parseCommonMarkBlocks
3
- } from "../safe-bash/command-chunks/chunk-VFS2MDAB.js";
4
- import "../safe-bash/command-chunks/chunk-F3J5ZLKF.js";
5
- import "../safe-bash/command-chunks/chunk-VTWKS4RM.js";
3
+ } from "../safe-bash/command-chunks/chunk-6YLD37NH.js";
4
+ import "../safe-bash/command-chunks/chunk-522TDVLS.js";
5
+ import "../safe-bash/command-chunks/chunk-WF2LSKMI.js";
6
+ import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
6
7
  import "../safe-bash/command-chunks/chunk-OEE6EKOT.js";
7
8
  import "../safe-bash/command-chunks/chunk-UI6H6YG4.js";
8
- import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
9
9
  import "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
10
10
  export {
11
11
  parseCommonMarkBlocks
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parseCommonMarkInlines
3
- } from "../safe-bash/command-chunks/chunk-YI3GKJ7Q.js";
4
- import "../safe-bash/command-chunks/chunk-F3J5ZLKF.js";
5
- import "../safe-bash/command-chunks/chunk-VTWKS4RM.js";
3
+ } from "../safe-bash/command-chunks/chunk-766IWMTB.js";
4
+ import "../safe-bash/command-chunks/chunk-522TDVLS.js";
5
+ import "../safe-bash/command-chunks/chunk-WF2LSKMI.js";
6
+ import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
6
7
  import "../safe-bash/command-chunks/chunk-OEE6EKOT.js";
7
8
  import "../safe-bash/command-chunks/chunk-UI6H6YG4.js";
8
- import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
9
9
  import "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
10
10
  export {
11
11
  parseCommonMarkInlines
@@ -10,9 +10,9 @@ import {
10
10
  readLabel,
11
11
  readTitle,
12
12
  whitespace
13
- } from "../safe-bash/command-chunks/chunk-VTWKS4RM.js";
14
- import "../safe-bash/command-chunks/chunk-OEE6EKOT.js";
13
+ } from "../safe-bash/command-chunks/chunk-WF2LSKMI.js";
15
14
  import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
15
+ import "../safe-bash/command-chunks/chunk-OEE6EKOT.js";
16
16
  import "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
17
17
  export {
18
18
  asciiPunctuation,
@@ -2,11 +2,11 @@ import {
2
2
  bareAutolink,
3
3
  filterGfmHtml,
4
4
  pipeRow
5
- } from "../safe-bash/command-chunks/chunk-F3J5ZLKF.js";
6
- import "../safe-bash/command-chunks/chunk-VTWKS4RM.js";
5
+ } from "../safe-bash/command-chunks/chunk-522TDVLS.js";
6
+ import "../safe-bash/command-chunks/chunk-WF2LSKMI.js";
7
+ import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
7
8
  import "../safe-bash/command-chunks/chunk-OEE6EKOT.js";
8
9
  import "../safe-bash/command-chunks/chunk-UI6H6YG4.js";
9
- import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
10
10
  import "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
11
11
  export {
12
12
  bareAutolink,
@@ -1,14 +1,14 @@
1
- import {
2
- parseCommonMarkInlines
3
- } from "../safe-bash/command-chunks/chunk-YI3GKJ7Q.js";
4
1
  import {
5
2
  parseCommonMarkBlocks
6
- } from "../safe-bash/command-chunks/chunk-VFS2MDAB.js";
7
- import "../safe-bash/command-chunks/chunk-F3J5ZLKF.js";
8
- import "../safe-bash/command-chunks/chunk-VTWKS4RM.js";
3
+ } from "../safe-bash/command-chunks/chunk-6YLD37NH.js";
4
+ import {
5
+ parseCommonMarkInlines
6
+ } from "../safe-bash/command-chunks/chunk-766IWMTB.js";
7
+ import "../safe-bash/command-chunks/chunk-522TDVLS.js";
8
+ import "../safe-bash/command-chunks/chunk-WF2LSKMI.js";
9
+ import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
9
10
  import "../safe-bash/command-chunks/chunk-OEE6EKOT.js";
10
11
  import "../safe-bash/command-chunks/chunk-UI6H6YG4.js";
11
- import "../safe-bash/command-chunks/chunk-XC57GYGL.js";
12
12
  import {
13
13
  init_buffer
14
14
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -14397,7 +14397,7 @@ function forwardFileDescriptor(descriptor, operation, capabilities, snapshot = (
14397
14397
  write: (retained, buffer, position, options) => operation("write", options, () => retained.write(buffer, position, options)),
14398
14398
  truncate: (retained, length, options) => operation("ftruncate", options, () => retained.truncate(length, options)),
14399
14399
  sync: (retained, dataOnly, options) => operation(dataOnly ? "fdatasync" : "fsync", options, () => retained.sync(dataOnly, options)),
14400
- close: (retained) => operation("close", {}, () => retained.close())
14400
+ close: (retained, options) => operation("close", {}, () => retained.close(options))
14401
14401
  };
14402
14402
  }
14403
14403
  function integer(value, syscall, path6) {
@@ -14565,10 +14565,10 @@ var ManagedFileDescriptor = class {
14565
14565
  await backend.sync(backend.resource, dataOnly, forwarded);
14566
14566
  });
14567
14567
  }
14568
- close() {
14568
+ close(options = {}) {
14569
14569
  this.#closing ??= this.#pending.then(async () => {
14570
14570
  try {
14571
- await this.#backend.close(this.#backend.resource);
14571
+ await this.#backend.close(this.#backend.resource, options);
14572
14572
  } finally {
14573
14573
  this.#backend = void 0;
14574
14574
  this.#getPosition = void 0;
@@ -14626,7 +14626,7 @@ async function openFileDescriptor(path6, options, capabilities, acquire) {
14626
14626
  signal?.throwIfAborted();
14627
14627
  return descriptor;
14628
14628
  } catch (error) {
14629
- await finishCleanup(() => backend.close(backend.resource), true);
14629
+ await finishCleanup(() => backend.close(backend.resource, {}), true);
14630
14630
  signal?.throwIfAborted();
14631
14631
  throw error;
14632
14632
  }
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  YqValueFailure,
3
3
  createYqQuerySession
4
- } from "../safe-bash/command-chunks/chunk-KSH2F6RG.js";
5
- import "../safe-bash/command-chunks/chunk-YIK4ZYQ4.js";
4
+ } from "../safe-bash/command-chunks/chunk-CUFCNL6G.js";
5
+ import "../safe-bash/command-chunks/chunk-DC52GWRK.js";
6
6
  import "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
7
+ import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
8
+ import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
7
9
  import "../safe-bash/command-chunks/chunk-ACRMXIQC.js";
8
10
  import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
9
- import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
10
11
  import "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
11
12
  import "../safe-bash/command-chunks/chunk-SNXWY3KV.js";
12
13
  import "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
13
- import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
14
- import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
15
14
  import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
16
15
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
16
+ import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
17
17
  import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
18
18
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
19
19
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  Interpreter
3
- } from "../safe-bash/command-chunks/chunk-YIK4ZYQ4.js";
3
+ } from "../safe-bash/command-chunks/chunk-DC52GWRK.js";
4
4
  import "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
5
- import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
6
5
  import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
6
+ import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
7
+ import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
7
8
  import "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
8
9
  import "../safe-bash/command-chunks/chunk-SNXWY3KV.js";
9
10
  import "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
10
- import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
11
- import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
12
11
  import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
13
12
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
13
+ import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
14
14
  import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
15
15
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
16
16
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  YqValueFailure,
3
3
  createYqQuerySession
4
- } from "../safe-bash/command-chunks/chunk-KSH2F6RG.js";
5
- import "../safe-bash/command-chunks/chunk-YIK4ZYQ4.js";
4
+ } from "../safe-bash/command-chunks/chunk-CUFCNL6G.js";
5
+ import "../safe-bash/command-chunks/chunk-DC52GWRK.js";
6
6
  import "../safe-bash/command-chunks/chunk-NSEUBSOD.js";
7
+ import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
8
+ import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
7
9
  import "../safe-bash/command-chunks/chunk-ACRMXIQC.js";
8
10
  import "../safe-bash/command-chunks/chunk-5PM5TEPM.js";
9
- import "../safe-bash/command-chunks/chunk-WVWWRMFD.js";
10
11
  import "../safe-bash/command-chunks/chunk-GZOUGVVV.js";
11
12
  import "../safe-bash/command-chunks/chunk-SNXWY3KV.js";
12
13
  import "../safe-bash/command-chunks/chunk-TFZEYNMX.js";
13
- import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
14
- import "../safe-bash/command-chunks/chunk-Z47EO74H.js";
15
14
  import "../safe-bash/command-chunks/chunk-IFUNAM4D.js";
16
15
  import "../safe-bash/command-chunks/chunk-NYUMOVF2.js";
16
+ import "../safe-bash/command-chunks/chunk-3JS4FOLB.js";
17
17
  import "../safe-bash/command-chunks/chunk-BIXN77VL.js";
18
18
  import "../safe-bash/command-chunks/chunk-UPOI7O7Y.js";
19
19
  import "../safe-bash/command-chunks/chunk-744EDSWN.js";
@@ -13,6 +13,17 @@ export interface Axis {
13
13
  readonly value: number;
14
14
  readonly relative: boolean;
15
15
  }
16
+ /** A binary-format name use retains identity while copies displace its definition.
17
+ * Offsets apply to references resolved at the current definition's declaration
18
+ * anchor. Copy adds row/column deltas only in relative mode and always adds tab
19
+ * displacement unless sheetRelative is false; moving leaves offsets intact. */
20
+ export interface NameRelocation {
21
+ readonly relative: boolean;
22
+ readonly row: number;
23
+ readonly column: number;
24
+ readonly sheet: number;
25
+ readonly sheetRelative?: boolean;
26
+ }
16
27
  export interface ReferenceEndpoint {
17
28
  readonly row?: Axis;
18
29
  readonly column?: Axis;
@@ -62,6 +73,7 @@ export type FormulaNode = Span & ({
62
73
  readonly kind: "name";
63
74
  readonly name: string;
64
75
  readonly sheet?: string;
76
+ readonly relocation?: NameRelocation;
65
77
  /** Empty means the current workbook; without a sheet it selects only global names. */
66
78
  readonly workbook?: string;
67
79
  } | {
@@ -117,6 +129,7 @@ export interface FormulaGrammar {
117
129
  readonly quotedLabels?: "openformula" | "calc";
118
130
  /** Permit ssconvert's live label anchors in internal workbook expressions. */
119
131
  readonly internalLabels?: boolean;
132
+ readonly internalNames?: boolean;
120
133
  readonly quotedErrors?: boolean;
121
134
  readonly rangeSeparator?: string;
122
135
  readonly sheetSpans?: boolean;
@@ -25,7 +25,7 @@ export const odfGrammar = Object.freeze({ ...gnumericGrammar,
25
25
  prefixes: Object.freeze(["of:=", "oooc:=", "="]), functionPrefixes: Object.freeze(["ORG.GNUMERIC.", "COM.MICROSOFT."])
26
26
  });
27
27
  /** Internal OpenFormula preserves relative sheets alongside live label anchors. */
28
- export const internalOdfGrammar = Object.freeze({ ...odfGrammar, internalLabels: true });
28
+ export const internalOdfGrammar = Object.freeze({ ...odfGrammar, internalLabels: true, internalNames: true });
29
29
  export const sylkGrammar = Object.freeze({ ...gnumericGrammar, id: "sylk", address: "r1c1" });
30
30
  /** Native SYLK output quotes strings without escaping; its reader does not invert that operation. */
31
31
  export const sylkWriterGrammar = Object.freeze({ ...sylkGrammar, id: "sylk-writer", stringEscape: "raw" });
@@ -80,7 +80,7 @@ export function buildDependencyGraph(book, roots, resolve, parse, tick, onRange,
80
80
  const name = named(node, position);
81
81
  if (!name || names.has(name))
82
82
  return [];
83
- return staticRanges(parseNamedExpression(name, book, parse, tick, maximumDepth), position, new Set([...names, name]), depth + 1);
83
+ return staticRanges(parseNamedExpression(name, book, parse, tick, maximumDepth, node.relocation), position, new Set([...names, name]), depth + 1);
84
84
  }
85
85
  if (node.kind === "call" && (node.name === "IF" || node.name === "CHOOSE")) {
86
86
  const ranges = [];
@@ -188,7 +188,7 @@ export function buildDependencyGraph(book, roots, resolve, parse, tick, onRange,
188
188
  if (node.kind === "name" && (node.workbook === undefined || node.workbook === "")) {
189
189
  const name = named(node, position);
190
190
  if (name && !names.has(name)) {
191
- pending.push({ node: parseNamedExpression(name, book, parse, tick, maximumDepth), position, names: new Set([...names, name]), depth: depth + 1 });
191
+ pending.push({ node: parseNamedExpression(name, book, parse, tick, maximumDepth, node.relocation), position, names: new Set([...names, name]), depth: depth + 1 });
192
192
  }
193
193
  }
194
194
  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() : [];
@@ -175,7 +175,7 @@ export function* recalculateWorkbookSteps(input, context, options = false, onDia
175
175
  const name = book.names?.find(entry => entry.sheet === sheet && matches(entry)) ?? book.names?.find(entry => entry.sheet === undefined && matches(entry));
176
176
  if (!name || names.has(name))
177
177
  return error("#REF!");
178
- return indirectRange(parseNamedExpression(name, book, parse, tick, context.limits.formulaDependencyDepth ?? Infinity), position, new Set([...names, name]), depth + 1);
178
+ return indirectRange(parseNamedExpression(name, book, parse, tick, context.limits.formulaDependencyDepth ?? Infinity, node.relocation), position, new Set([...names, name]), depth + 1);
179
179
  }
180
180
  function scalar(value, position) {
181
181
  // OpenFormula §5.10.4 selects at the formula position when the consumer
@@ -264,7 +264,7 @@ export function* recalculateWorkbookSteps(input, context, options = false, onDia
264
264
  const name = book.names?.find(entry => entry.sheet === sheet && matches(entry)) ?? book.names?.find(entry => entry.sheet === undefined && matches(entry));
265
265
  if (!name || names.has(name))
266
266
  return error("#NAME?");
267
- return evaluate(parseNamedExpression(name, book, parse, tick, context.limits.formulaDependencyDepth ?? Infinity), position, array, new Set([...names, name]), wantReference);
267
+ return evaluate(parseNamedExpression(name, book, parse, tick, context.limits.formulaDependencyDepth ?? Infinity, node.relocation), position, array, new Set([...names, name]), wantReference);
268
268
  }
269
269
  if (node.kind === "unary") {
270
270
  const apply = (value) => {
@@ -1,6 +1,6 @@
1
1
  import { type NamedExpression, type Workbook } from "../../spreadsheet-ast/index.js";
2
- import type { FormulaNode, ParsePosition } from "./ast.js";
2
+ import type { FormulaNode, NameRelocation, ParsePosition } from "./ast.js";
3
3
  /** Parse relative offsets at the declaration anchor and bind nested names there.
4
4
  * References and functions in the resulting expression still use the caller's
5
5
  * evaluation position, as in native expr_name_eval. */
6
- export declare function parseNamedExpression(name: NamedExpression, book: Workbook, parse: (source: string, position: ParsePosition, arrayStringLiterals?: boolean) => FormulaNode, tick: () => void, maximumDepth?: number): FormulaNode;
6
+ export declare function parseNamedExpression(name: NamedExpression, book: Workbook, parse: (source: string, position: ParsePosition, arrayStringLiterals?: boolean) => FormulaNode, tick: () => void, maximumDepth?: number, relocation?: NameRelocation): FormulaNode;