@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
@@ -1,898 +0,0 @@
1
- import {
2
- Decimal,
3
- numberText,
4
- object,
5
- objectKeyIterator,
6
- objectKeys,
7
- objectSize,
8
- put,
9
- utf8ByteLength
10
- } from "./chunk-44WUNUPV.js";
11
- import {
12
- init_platform
13
- } from "./chunk-ZG7GWQ5P.js";
14
-
15
- // packages/safe-bash-command-yq/src/accounting.ts
16
- init_platform();
17
-
18
- // packages/safe-bash-command-yq/src/errors.ts
19
- init_platform();
20
- var YqError = class extends Error {
21
- constructor(category, code, status, source, line, column) {
22
- super(`${category}: ${code}`);
23
- this.category = category;
24
- this.code = code;
25
- this.status = status;
26
- this.source = source;
27
- this.line = line;
28
- this.column = column;
29
- }
30
- category;
31
- code;
32
- status;
33
- source;
34
- line;
35
- column;
36
- };
37
- var budgetLimits = Object.freeze({
38
- maxInputBytes: "LIMIT_MAX_INPUT_BYTES",
39
- maxValueBytes: "LIMIT_MAX_VALUE_BYTES",
40
- maxOutputBytes: "LIMIT_MAX_OUTPUT_BYTES",
41
- maxSourceBytes: "LIMIT_MAX_QUERY_SOURCE_BYTES",
42
- maxDepth: "LIMIT_MAX_DEPTH",
43
- maxAstDepth: "LIMIT_MAX_AST_DEPTH",
44
- maxSteps: "LIMIT_MAX_STEPS",
45
- maxResults: "LIMIT_MAX_RESULTS",
46
- maxCollectionSize: "LIMIT_MAX_COLLECTION_SIZE"
47
- });
48
- function fromJqLimit(error) {
49
- const prefix = error.message.slice(0, error.message.indexOf(" "));
50
- return new YqError("limit", budgetLimits[prefix] ?? "LIMIT_MAX_STEPS", 5);
51
- }
52
- function limit(code, source, line, column) {
53
- return new YqError("limit", code, 5, source, line, column);
54
- }
55
-
56
- // packages/safe-bash-command-yq/src/accounting.ts
57
- var yqCaps = Object.freeze({
58
- maxArgvEntries: Infinity,
59
- maxArgvUtf8Bytes: Infinity,
60
- maxVfsOperandPathBytes: Infinity,
61
- maxInputBytes: Infinity,
62
- maxDocumentBytes: Infinity,
63
- maxValueBytes: Infinity,
64
- maxScalarBytes: Infinity,
65
- maxQuerySourceBytes: Infinity,
66
- maxDepth: Infinity,
67
- maxAstDepth: Infinity,
68
- maxSteps: Infinity,
69
- maxResults: Infinity,
70
- maxCollectionSize: Infinity,
71
- maxDocuments: Infinity,
72
- maxAnchorsPerDocument: Infinity,
73
- maxAliasReferences: Infinity,
74
- maxSourceLines: Infinity,
75
- maxDocumentNodes: Infinity,
76
- maxOutputBytes: Infinity,
77
- diagnosticReserveBytes: Infinity,
78
- stdoutCapBytes: Infinity,
79
- maxDisplayedFilenameBytes: Infinity
80
- });
81
- function resolveYqLimits(overrides = {}) {
82
- if (typeof overrides !== "object" || overrides === null) throw new TypeError("limits must be an object");
83
- const limits = {
84
- maxAliasReferences: yqCaps.maxAliasReferences,
85
- maxSourceLines: yqCaps.maxSourceLines,
86
- maxDocumentNodes: yqCaps.maxDocumentNodes,
87
- maxValueBytes: yqCaps.maxValueBytes,
88
- maxSteps: yqCaps.maxSteps
89
- };
90
- for (const [key, value] of Object.entries(overrides)) {
91
- if (!Object.hasOwn(limits, key) || value !== Infinity && (!Number.isSafeInteger(value) || value < 0)) {
92
- throw new TypeError("yq limits must be nonnegative safe integers or Infinity with supported names");
93
- }
94
- Object.assign(limits, { [key]: value });
95
- }
96
- return Object.freeze(limits);
97
- }
98
- function checked(current, incoming, limitValue, code) {
99
- if (!Number.isSafeInteger(incoming) || incoming < 0) throw new RangeError("invalid yq accounting projection");
100
- if (incoming > limitValue - current) throw limit(code);
101
- return current + incoming;
102
- }
103
- var YqLedger = class {
104
- constructor(limits = resolveYqLimits()) {
105
- this.limits = limits;
106
- }
107
- limits;
108
- documents = 0;
109
- aliases = 0;
110
- documentNodes = 0;
111
- documentValueBytes = 0;
112
- anchors = 0;
113
- stdoutBytes = 0;
114
- combinedOutputBytes = 0;
115
- admitDocumentBytes(rawBytes) {
116
- if (!Number.isSafeInteger(rawBytes) || rawBytes < 0) throw new RangeError("invalid raw document byte count");
117
- if (rawBytes > yqCaps.maxDocumentBytes) throw limit("LIMIT_MAX_DOCUMENT_BYTES");
118
- }
119
- beginDocument(rawBytes) {
120
- this.admitDocumentBytes(rawBytes);
121
- this.documents = checked(this.documents, 1, yqCaps.maxDocuments, "LIMIT_MAX_DOCUMENTS");
122
- this.documentNodes = 0;
123
- this.documentValueBytes = 0;
124
- this.anchors = 0;
125
- }
126
- admitNode() {
127
- this.documentNodes = checked(this.documentNodes, 1, this.limits.maxDocumentNodes, "LIMIT_MAX_DOCUMENT_NODES");
128
- }
129
- admitAnchor() {
130
- this.anchors = checked(this.anchors, 1, yqCaps.maxAnchorsPerDocument, "LIMIT_MAX_ANCHORS_PER_DOCUMENT");
131
- }
132
- admitScalar(bytes) {
133
- if (bytes > yqCaps.maxScalarBytes) throw limit("LIMIT_MAX_SCALAR_BYTES");
134
- }
135
- admitValueBytes(bytes) {
136
- this.documentValueBytes = checked(this.documentValueBytes, bytes, this.limits.maxValueBytes, "LIMIT_MAX_VALUE_BYTES");
137
- }
138
- preflightAlias(descriptor) {
139
- const aliases = checked(this.aliases, 1, this.limits.maxAliasReferences, "LIMIT_MAX_ALIAS_REFERENCES");
140
- const nodes = checked(this.documentNodes, descriptor.nodes, this.limits.maxDocumentNodes, "LIMIT_MAX_DOCUMENT_NODES");
141
- const valueBytes = checked(this.documentValueBytes, descriptor.compactBytes, this.limits.maxValueBytes, "LIMIT_MAX_VALUE_BYTES");
142
- if (descriptor.maxDepth > yqCaps.maxDepth) throw limit("LIMIT_MAX_DEPTH");
143
- return { aliases, nodes, valueBytes };
144
- }
145
- commitAlias(projection) {
146
- this.aliases = projection.aliases;
147
- this.documentNodes = projection.nodes;
148
- this.documentValueBytes = projection.valueBytes;
149
- }
150
- admitStdout(bytes) {
151
- this.stdoutBytes = checked(this.stdoutBytes, bytes, yqCaps.stdoutCapBytes, "LIMIT_MAX_OUTPUT_BYTES");
152
- this.combinedOutputBytes = checked(this.combinedOutputBytes, bytes, yqCaps.maxOutputBytes, "LIMIT_MAX_OUTPUT_BYTES");
153
- }
154
- canAdmitDiagnostic(bytes) {
155
- return Number.isSafeInteger(bytes) && bytes >= 0 && bytes <= yqCaps.diagnosticReserveBytes && bytes <= yqCaps.maxOutputBytes - this.combinedOutputBytes;
156
- }
157
- admitDiagnostic(bytes) {
158
- if (!this.canAdmitDiagnostic(bytes)) throw limit("LIMIT_MAX_OUTPUT_BYTES");
159
- this.combinedOutputBytes += bytes;
160
- }
161
- };
162
- function addProjection(current, incoming) {
163
- if (!Number.isSafeInteger(incoming) || incoming < 0 || incoming > Number.MAX_SAFE_INTEGER - current) {
164
- throw new RangeError("alias projection overflow");
165
- }
166
- return current + incoming;
167
- }
168
- async function payload(work, text) {
169
- let codePoints = 0;
170
- let bytes = 0;
171
- for (const character of text) {
172
- codePoints++;
173
- bytes += utf8ByteLength(character);
174
- if (codePoints === 256) {
175
- await work.charge(codePoints);
176
- work.assertOpen();
177
- codePoints = 0;
178
- }
179
- }
180
- if (codePoints > 0) {
181
- await work.charge(codePoints);
182
- work.assertOpen();
183
- }
184
- const units = bytes === 0 ? 0 : Math.ceil(bytes / 1024);
185
- if (units > 0) {
186
- await work.charge(units);
187
- work.assertOpen();
188
- }
189
- return units;
190
- }
191
- function jsonStringBytes(text) {
192
- let bytes = 2;
193
- for (const character of text) {
194
- const point = character.codePointAt(0);
195
- if (point === 34 || point === 92 || point === 8 || point === 12 || point === 10 || point === 13 || point === 9) bytes += 2;
196
- else if (point < 32) bytes += 6;
197
- else bytes += utf8ByteLength(character);
198
- }
199
- return bytes;
200
- }
201
- async function estimateAlias(value, work, limits = resolveYqLimits()) {
202
- let nodes = 0;
203
- let compactBytes = 0;
204
- let maxDepth = 0;
205
- let ordinaryUnits = 0;
206
- const stack = [{ value, depth: 0 }];
207
- while (stack.length > 0) {
208
- const item = stack.pop();
209
- await work.charge(1);
210
- work.assertOpen();
211
- nodes = checked(nodes, 1, limits.maxDocumentNodes, "LIMIT_MAX_DOCUMENT_NODES");
212
- ordinaryUnits = addProjection(ordinaryUnits, 1);
213
- maxDepth = Math.max(maxDepth, item.depth);
214
- if (maxDepth > yqCaps.maxDepth) throw limit("LIMIT_MAX_DEPTH");
215
- const current = item.value;
216
- if (current === null || typeof current === "boolean") {
217
- compactBytes = addProjection(compactBytes, utf8ByteLength(JSON.stringify(current)));
218
- } else if (typeof current === "number" || current instanceof Decimal) {
219
- const text = numberText(current);
220
- const units = await payload(work, text);
221
- work.assertOpen();
222
- ordinaryUnits = addProjection(ordinaryUnits, units);
223
- compactBytes = addProjection(compactBytes, utf8ByteLength(text));
224
- } else if (typeof current === "string") {
225
- const units = await payload(work, current);
226
- work.assertOpen();
227
- ordinaryUnits = addProjection(ordinaryUnits, units);
228
- compactBytes = addProjection(compactBytes, jsonStringBytes(current));
229
- } else {
230
- const keys = Array.isArray(current) ? Object.keys(current) : objectKeys(current);
231
- if (keys.length > yqCaps.maxCollectionSize) throw limit("LIMIT_MAX_COLLECTION_SIZE");
232
- compactBytes = addProjection(compactBytes, 2 + Math.max(0, keys.length - 1));
233
- for (let index = keys.length - 1; index >= 0; index--) {
234
- const key = keys[index];
235
- if (!Array.isArray(current)) {
236
- const units = await payload(work, key);
237
- work.assertOpen();
238
- ordinaryUnits = addProjection(ordinaryUnits, units);
239
- compactBytes = addProjection(compactBytes, jsonStringBytes(key) + 1);
240
- }
241
- stack.push({ value: current[key], depth: item.depth + 1 });
242
- }
243
- }
244
- if (compactBytes > limits.maxValueBytes) throw limit("LIMIT_MAX_VALUE_BYTES");
245
- }
246
- return Object.freeze({ nodes, compactBytes, maxDepth, ordinaryUnits });
247
- }
248
- async function consumePayload(work, reservation, text) {
249
- const bytes = utf8ByteLength(text);
250
- const units = bytes === 0 ? 0 : Math.ceil(bytes / 1024);
251
- for (let unit = 0; unit < units; unit++) {
252
- await reservation.beforeUnit();
253
- work.assertOpen();
254
- }
255
- }
256
- async function copyAlias(value, ledger, work) {
257
- const descriptor = await estimateAlias(value, work, ledger.limits);
258
- work.assertOpen();
259
- const projection = ledger.preflightAlias(descriptor);
260
- const reservation = work.reserve(descriptor.ordinaryUnits);
261
- ledger.commitAlias(projection);
262
- let completed = false;
263
- const copy = async (current) => {
264
- await reservation.beforeUnit();
265
- work.assertOpen();
266
- if (current === null || typeof current === "boolean") return current;
267
- if (typeof current === "number" || current instanceof Decimal) {
268
- await consumePayload(work, reservation, numberText(current));
269
- work.assertOpen();
270
- return current;
271
- }
272
- if (typeof current === "string") {
273
- await consumePayload(work, reservation, current);
274
- work.assertOpen();
275
- return current;
276
- }
277
- if (Array.isArray(current)) {
278
- const result2 = [];
279
- for (const child of current) {
280
- const copied = await copy(child);
281
- work.assertOpen();
282
- result2.push(copied);
283
- }
284
- return result2;
285
- }
286
- const result = object();
287
- for (const key of objectKeys(current)) {
288
- await consumePayload(work, reservation, key);
289
- work.assertOpen();
290
- const copied = await copy(current[key]);
291
- work.assertOpen();
292
- put(result, key, copied);
293
- }
294
- return result;
295
- };
296
- try {
297
- const result = await copy(value);
298
- work.assertOpen();
299
- reservation.finish();
300
- work.assertOpen();
301
- completed = true;
302
- return result;
303
- } finally {
304
- if (!completed) reservation.abandon();
305
- }
306
- }
307
- function aliasFailure(code) {
308
- return new YqError("alias", code, 5);
309
- }
310
-
311
- // packages/safe-bash-command-yq/src/toml.ts
312
- init_platform();
313
- var TomlParser = class {
314
- constructor(source, work, ledger) {
315
- this.source = source;
316
- this.work = work;
317
- this.ledger = ledger;
318
- }
319
- source;
320
- work;
321
- ledger;
322
- #offset = 0;
323
- #line = 1;
324
- #column = 1;
325
- #pending = 0;
326
- #tables = /* @__PURE__ */ new WeakMap();
327
- #arraysOfTables = /* @__PURE__ */ new WeakSet();
328
- #syntax() {
329
- throw new YqError("input", "INPUT_TOML_SYNTAX", 5, void 0, this.#line, this.#column);
330
- }
331
- #conflict() {
332
- throw new YqError("schema", "SCHEMA_DUPLICATE_KEY", 5, void 0, this.#line, this.#column);
333
- }
334
- #schema(code) {
335
- throw new YqError("schema", code, 5, void 0, this.#line, this.#column);
336
- }
337
- #peek(distance = 0) {
338
- return this.source[this.#offset + distance] ?? "";
339
- }
340
- #take() {
341
- if (this.#offset >= this.source.length) this.#syntax();
342
- const point = this.source.codePointAt(this.#offset);
343
- if (point >= 55296 && point <= 57343 || point < 32 && point !== 9 && point !== 10 && point !== 13 || point === 127) this.#syntax();
344
- let value = String.fromCodePoint(point);
345
- this.#offset += value.length;
346
- this.#pending++;
347
- if (point === 13) {
348
- if (this.#peek() !== "\n") this.#syntax();
349
- this.#offset++;
350
- value = "\n";
351
- }
352
- if (value === "\n") {
353
- this.#line++;
354
- this.#column = 1;
355
- } else this.#column++;
356
- return value;
357
- }
358
- async #flush() {
359
- if (this.#pending) {
360
- const units = this.#pending;
361
- this.#pending = 0;
362
- await this.work.charge(units);
363
- }
364
- this.work.assertOpen();
365
- }
366
- async #space(newlines) {
367
- while (true) {
368
- const character = this.#peek();
369
- if (character === " " || character === " " || newlines && (character === "\n" || character === "\r")) this.#take();
370
- else if (newlines && character === "#") {
371
- while (this.#peek() && this.#peek() !== "\n" && this.#peek() !== "\r") {
372
- this.#take();
373
- if (this.#pending >= 256) await this.#flush();
374
- }
375
- } else break;
376
- if (this.#pending >= 256) await this.#flush();
377
- }
378
- }
379
- async #lineEnd() {
380
- await this.#space(false);
381
- if (this.#peek() === "#") {
382
- while (this.#peek() && this.#peek() !== "\n" && this.#peek() !== "\r") {
383
- this.#take();
384
- if (this.#pending >= 256) await this.#flush();
385
- }
386
- }
387
- if (this.#peek() === "\n" || this.#peek() === "\r") this.#take();
388
- else if (this.#peek()) this.#syntax();
389
- }
390
- #depth(depth) {
391
- if (depth > yqCaps.maxDepth) throw limit("LIMIT_MAX_DEPTH");
392
- }
393
- async #node() {
394
- await this.#flush();
395
- await this.work.charge(1);
396
- this.work.assertOpen();
397
- this.ledger.admitNode();
398
- }
399
- async #table(kind, depth) {
400
- this.#depth(depth);
401
- await this.#node();
402
- this.ledger.admitValueBytes(2);
403
- const value = object();
404
- this.#tables.set(value, { kind, depth, sealed: false });
405
- return value;
406
- }
407
- async #array(depth) {
408
- this.#depth(depth);
409
- await this.#node();
410
- this.ledger.admitValueBytes(2);
411
- return [];
412
- }
413
- async #scalar(value) {
414
- await this.#node();
415
- if (typeof value !== "string") {
416
- const text = typeof value === "boolean" ? String(value) : numberText(value);
417
- this.ledger.admitScalar(text.length);
418
- this.ledger.admitValueBytes(text.length);
419
- return;
420
- }
421
- let rawBytes = 0;
422
- let compactBytes = 2;
423
- let work = 0;
424
- for (const character of value) {
425
- const point = character.codePointAt(0);
426
- const bytes = point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
427
- rawBytes += bytes;
428
- compactBytes += point === 34 || point === 92 || [8, 9, 10, 12, 13].includes(point) ? 2 : point < 32 ? 6 : bytes;
429
- this.ledger.admitScalar(rawBytes);
430
- if (++work === 256) {
431
- await this.work.charge(work);
432
- this.work.assertOpen();
433
- work = 0;
434
- }
435
- }
436
- if (work) await this.work.charge(work);
437
- this.work.assertOpen();
438
- this.ledger.admitValueBytes(compactBytes);
439
- }
440
- async #member(table, key, value) {
441
- if (Object.hasOwn(table, key)) this.#conflict();
442
- const size = objectSize(table);
443
- if (size >= yqCaps.maxCollectionSize) throw limit("LIMIT_MAX_COLLECTION_SIZE");
444
- await this.#scalar(key);
445
- this.ledger.admitValueBytes(size ? 2 : 1);
446
- this.work.assertOpen();
447
- put(table, key, value);
448
- }
449
- #append(array, value) {
450
- if (array.length >= yqCaps.maxCollectionSize) throw limit("LIMIT_MAX_COLLECTION_SIZE");
451
- if (array.length) this.ledger.admitValueBytes(1);
452
- this.work.assertOpen();
453
- array.push(value);
454
- }
455
- async #string(key = false) {
456
- const quote = this.#take();
457
- let multiline = false;
458
- if (!key && this.#peek() === quote && this.#peek(1) === quote) {
459
- this.#take();
460
- this.#take();
461
- multiline = true;
462
- if (this.#peek() === "\n" || this.#peek() === "\r") this.#take();
463
- }
464
- const parts = [];
465
- let part = "";
466
- let bytes = 0;
467
- const append = (value) => {
468
- bytes += utf8ByteLength(value);
469
- this.ledger.admitScalar(bytes);
470
- part += value;
471
- if (part.length >= 256) {
472
- parts.push(part);
473
- part = "";
474
- }
475
- };
476
- while (this.#peek()) {
477
- const character = this.#take();
478
- if (character === quote) {
479
- if (!multiline) {
480
- parts.push(part);
481
- return parts.join("");
482
- }
483
- let count = 1;
484
- while (count < 5 && this.#peek() === quote) {
485
- this.#take();
486
- count++;
487
- }
488
- if (count >= 3) {
489
- append(quote.repeat(count - 3));
490
- parts.push(part);
491
- return parts.join("");
492
- }
493
- append(quote.repeat(count));
494
- } else if (character === "\n") {
495
- if (!multiline) this.#syntax();
496
- append(character);
497
- } else if (quote === '"' && character === "\\") {
498
- if (multiline && [" ", " ", "\n", "\r"].includes(this.#peek())) {
499
- await this.#space(false);
500
- if (this.#peek() !== "\n" && this.#peek() !== "\r") this.#syntax();
501
- this.#take();
502
- while ([" ", " ", "\n", "\r"].includes(this.#peek())) {
503
- this.#take();
504
- if (this.#pending >= 256) await this.#flush();
505
- }
506
- } else {
507
- const escape = this.#take();
508
- const simple = { b: "\b", t: " ", n: "\n", f: "\f", r: "\r", '"': '"', "\\": "\\" };
509
- if (Object.hasOwn(simple, escape)) append(simple[escape]);
510
- else if (escape === "u" || escape === "U") {
511
- let point = 0;
512
- for (let index = 0; index < (escape === "u" ? 4 : 8); index++) {
513
- const digit = this.#digit(this.#take(), 16);
514
- if (digit < 0) this.#syntax();
515
- point = point * 16 + digit;
516
- }
517
- if (point > 1114111 || point >= 55296 && point <= 57343) this.#syntax();
518
- append(String.fromCodePoint(point));
519
- } else this.#syntax();
520
- }
521
- } else append(character);
522
- if (this.#pending >= 256) await this.#flush();
523
- }
524
- return this.#syntax();
525
- }
526
- #digit(character, base) {
527
- const code = character.charCodeAt(0);
528
- const digit = code >= 48 && code <= 57 ? code - 48 : code >= 65 && code <= 70 ? code - 55 : code >= 97 && code <= 102 ? code - 87 : -1;
529
- return digit >= 0 && digit < base ? digit : -1;
530
- }
531
- async #keyPath() {
532
- const path = [];
533
- while (true) {
534
- await this.#space(false);
535
- let key;
536
- if (this.#peek() === '"' || this.#peek() === "'") key = await this.#string(true);
537
- else {
538
- const start = this.#offset;
539
- while (this.#peek()) {
540
- const code = this.#peek().charCodeAt(0);
541
- if (!(code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 95 || code === 45)) break;
542
- this.#take();
543
- if (this.#offset - start > yqCaps.maxScalarBytes) throw limit("LIMIT_MAX_SCALAR_BYTES");
544
- if (this.#pending >= 256) await this.#flush();
545
- }
546
- if (this.#offset === start) this.#syntax();
547
- key = this.source.slice(start, this.#offset);
548
- }
549
- if (path.length >= yqCaps.maxDepth) throw limit("LIMIT_MAX_DEPTH");
550
- path.push(key);
551
- await this.#space(false);
552
- if (this.#peek() !== ".") return path;
553
- this.#take();
554
- }
555
- }
556
- #state(table) {
557
- const state = this.#tables.get(table);
558
- if (!state) this.#conflict();
559
- return state;
560
- }
561
- async #parents(start, path, kind, allowAoT) {
562
- let current = start;
563
- for (const key of path) {
564
- await this.work.charge(1);
565
- this.work.assertOpen();
566
- const parent = this.#state(current);
567
- if (parent.sealed) this.#conflict();
568
- let value = current[key];
569
- if (!Object.hasOwn(current, key)) {
570
- value = await this.#table(kind, parent.depth + 1);
571
- await this.#member(current, key, value);
572
- } else if (Array.isArray(value) && allowAoT && this.#arraysOfTables.has(value)) value = value.at(-1);
573
- if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Decimal) this.#conflict();
574
- const state = this.#state(value);
575
- if (state.sealed) this.#conflict();
576
- if (kind === "dotted" && state.kind === "header") this.#conflict();
577
- if (kind === "dotted" && state.kind === "implicit") state.kind = "dotted";
578
- current = value;
579
- }
580
- return current;
581
- }
582
- async #assignment(current) {
583
- const path = await this.#keyPath();
584
- if (this.#take() !== "=") this.#syntax();
585
- await this.#space(false);
586
- const parent = await this.#parents(current, path.slice(0, -1), "dotted", false);
587
- if (this.#state(parent).sealed || Object.hasOwn(parent, path.at(-1))) this.#conflict();
588
- if (objectSize(parent) >= yqCaps.maxCollectionSize) throw limit("LIMIT_MAX_COLLECTION_SIZE");
589
- const value = await this.#value(this.#state(parent).depth + 1);
590
- await this.#member(parent, path.at(-1), value);
591
- }
592
- async #header(root) {
593
- this.#take();
594
- const array = this.#peek() === "[";
595
- if (array) this.#take();
596
- const path = await this.#keyPath();
597
- if (this.#take() !== "]" || array && this.#take() !== "]") this.#syntax();
598
- await this.#lineEnd();
599
- const parent = await this.#parents(root, path.slice(0, -1), "implicit", true);
600
- const key = path.at(-1);
601
- const parentState = this.#state(parent);
602
- if (parentState.sealed) this.#conflict();
603
- const exists = Object.hasOwn(parent, key);
604
- const existing = parent[key];
605
- if (array) {
606
- let values;
607
- if (exists) {
608
- if (!Array.isArray(existing) || !this.#arraysOfTables.has(existing)) this.#conflict();
609
- values = existing;
610
- } else {
611
- values = await this.#array(parentState.depth + 1);
612
- this.#arraysOfTables.add(values);
613
- await this.#member(parent, key, values);
614
- }
615
- if (values.length >= yqCaps.maxCollectionSize) throw limit("LIMIT_MAX_COLLECTION_SIZE");
616
- const table2 = await this.#table("header", parentState.depth + 2);
617
- this.#append(values, table2);
618
- return table2;
619
- }
620
- if (exists) {
621
- if (typeof existing !== "object" || existing === null || Array.isArray(existing) || existing instanceof Decimal) this.#conflict();
622
- const state = this.#state(existing);
623
- if (state.kind !== "implicit" || state.sealed) this.#conflict();
624
- state.kind = "header";
625
- return existing;
626
- }
627
- const table = await this.#table("header", parentState.depth + 1);
628
- await this.#member(parent, key, table);
629
- return table;
630
- }
631
- async #seal(table) {
632
- const pending = [table];
633
- while (pending.length) {
634
- const current = pending.pop();
635
- await this.work.charge(1);
636
- this.work.assertOpen();
637
- this.#state(current).sealed = true;
638
- for (const key of objectKeyIterator(current)) {
639
- await this.work.charge(1);
640
- this.work.assertOpen();
641
- const value = current[key];
642
- if (typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Decimal)) pending.push(value);
643
- }
644
- }
645
- }
646
- async #value(depth) {
647
- this.#depth(depth);
648
- const character = this.#peek();
649
- if (character === '"' || character === "'") {
650
- const value2 = await this.#string();
651
- await this.#scalar(value2);
652
- return value2;
653
- }
654
- if (character === "[") {
655
- this.#take();
656
- const result = await this.#array(depth);
657
- await this.#space(true);
658
- while (this.#peek() !== "]") {
659
- if (!this.#peek()) this.#syntax();
660
- if (result.length >= yqCaps.maxCollectionSize) throw limit("LIMIT_MAX_COLLECTION_SIZE");
661
- const value2 = await this.#value(depth + 1);
662
- this.#append(result, value2);
663
- await this.#space(true);
664
- if (this.#peek() !== ",") break;
665
- this.#take();
666
- await this.#space(true);
667
- }
668
- if (this.#take() !== "]") this.#syntax();
669
- return result;
670
- }
671
- if (character === "{") {
672
- this.#take();
673
- const result = await this.#table("inline", depth);
674
- await this.#space(false);
675
- if (this.#peek() !== "}") {
676
- while (true) {
677
- await this.#assignment(result);
678
- await this.#space(false);
679
- if (this.#peek() !== ",") break;
680
- this.#take();
681
- await this.#space(false);
682
- if (this.#peek() === "}") this.#syntax();
683
- }
684
- }
685
- if (this.#take() !== "}") this.#syntax();
686
- await this.#seal(result);
687
- return result;
688
- }
689
- const start = this.#offset;
690
- while (this.#peek()) {
691
- const next = this.#peek();
692
- if (" \r\n#,]}".includes(next)) {
693
- if (next === " " && this.#offset - start === 10 && this.source[start + 4] === "-" && this.source[start + 7] === "-" && this.#digit(this.#peek(1), 10) >= 0) this.#take();
694
- else break;
695
- } else this.#take();
696
- if (this.#offset - start > yqCaps.maxScalarBytes) throw limit("LIMIT_MAX_SCALAR_BYTES");
697
- if (this.#pending >= 256) await this.#flush();
698
- }
699
- if (this.#offset === start) this.#syntax();
700
- const raw = this.source.slice(start, this.#offset);
701
- await this.#flush();
702
- let value;
703
- if (raw === "true" || raw === "false") value = raw === "true";
704
- else if (raw.length >= 8 && (raw[2] === ":" || raw[4] === "-" && raw[7] === "-")) {
705
- await this.#date(raw);
706
- value = raw;
707
- } else value = await this.#number(raw);
708
- await this.#scalar(value);
709
- return value;
710
- }
711
- async #number(raw) {
712
- let start = 0;
713
- const negative = raw[0] === "-";
714
- if (negative || raw[0] === "+") start++;
715
- const unsigned = raw.slice(start);
716
- if (unsigned === "inf" || unsigned === "nan") this.#schema("SCHEMA_NONFINITE_NUMBER");
717
- let base = 10;
718
- if (unsigned.startsWith("0x")) base = 16;
719
- else if (unsigned.startsWith("0o")) base = 8;
720
- else if (unsigned.startsWith("0b")) base = 2;
721
- if (base !== 10) {
722
- if (start) this.#syntax();
723
- let value2 = 0;
724
- let previousDigit2 = false;
725
- if (raw.length <= 2) this.#syntax();
726
- for (let index = 2; index < raw.length; index++) {
727
- const character = raw[index];
728
- if (character === "_") {
729
- if (!previousDigit2 || this.#digit(raw[index + 1] ?? "", base) < 0) this.#syntax();
730
- previousDigit2 = false;
731
- } else {
732
- const digit = this.#digit(character, base);
733
- if (digit < 0) this.#syntax();
734
- if (value2 > Math.floor((Number.MAX_SAFE_INTEGER - digit) / base)) this.#schema("SCHEMA_UNSAFE_INTEGER");
735
- value2 = value2 * base + digit;
736
- previousDigit2 = true;
737
- }
738
- if (index % 256 === 0) {
739
- await this.work.charge(256);
740
- this.work.assertOpen();
741
- }
742
- }
743
- return value2;
744
- }
745
- let clean = "";
746
- let integerDigits = 0;
747
- let fractionDigits = 0;
748
- let exponentDigits = 0;
749
- let exponentValue = 0;
750
- let exponentNegative = false;
751
- let state = "integer";
752
- let previousDigit = false;
753
- let coefficient = "";
754
- for (let index = start; index < raw.length; index++) {
755
- const character = raw[index];
756
- const digit = this.#digit(character, 10);
757
- if (digit >= 0) {
758
- clean += character;
759
- previousDigit = true;
760
- if (state === "integer") {
761
- integerDigits++;
762
- coefficient += character;
763
- } else if (state === "fraction") {
764
- fractionDigits++;
765
- coefficient += character;
766
- } else {
767
- exponentDigits++;
768
- if (exponentValue > 1147483646) this.#schema("SCHEMA_DECIMAL_RANGE");
769
- exponentValue = exponentValue * 10 + digit;
770
- }
771
- } else if (character === "_") {
772
- if (!previousDigit || this.#digit(raw[index + 1] ?? "", 10) < 0) this.#syntax();
773
- previousDigit = false;
774
- } else if (character === "." && state === "integer" && previousDigit) {
775
- state = "fraction";
776
- previousDigit = false;
777
- clean += character;
778
- } else if ((character === "e" || character === "E") && state !== "exponent" && previousDigit) {
779
- state = "exponent";
780
- previousDigit = false;
781
- clean += "e";
782
- if (raw[index + 1] === "+" || raw[index + 1] === "-") {
783
- exponentNegative = raw[index + 1] === "-";
784
- clean += raw[++index];
785
- }
786
- } else this.#syntax();
787
- if ((index - start + 1) % 256 === 0) {
788
- await this.work.charge(256);
789
- this.work.assertOpen();
790
- }
791
- }
792
- if (!previousDigit || !integerDigits || integerDigits > 1 && unsigned[0] === "0" || state === "fraction" && !fractionDigits || state === "exponent" && !exponentDigits) this.#syntax();
793
- const signed = (negative ? "-" : "") + clean;
794
- const value = Number(signed);
795
- if (!Number.isFinite(value)) this.#schema("SCHEMA_NONFINITE_NUMBER");
796
- if (Number.isInteger(value) && !Number.isSafeInteger(value)) this.#schema("SCHEMA_UNSAFE_INTEGER");
797
- if (state === "integer") return value;
798
- let exponent = (exponentNegative ? -exponentValue : exponentValue) - fractionDigits;
799
- if (exponent < -1147483646 || exponent > 999999999) this.#schema("SCHEMA_DECIMAL_RANGE");
800
- let first = 0;
801
- while (first < coefficient.length - 1 && coefficient[first] === "0") {
802
- first++;
803
- if (first % 256 === 0) {
804
- await this.work.charge(256);
805
- this.work.assertOpen();
806
- }
807
- }
808
- let last = coefficient.length;
809
- while (last > first + 1 && coefficient[last - 1] === "0") {
810
- last--;
811
- exponent++;
812
- if ((coefficient.length - last) % 256 === 0) {
813
- await this.work.charge(256);
814
- this.work.assertOpen();
815
- }
816
- }
817
- const digits = coefficient.slice(first, last);
818
- if (digits !== "0" && exponent >= 0 && (digits.length + exponent > 16 || !Number.isSafeInteger(Number(`${digits}e${exponent}`)))) this.#schema("SCHEMA_UNSAFE_INTEGER");
819
- return new Decimal(digits, exponent, negative, signed, value);
820
- }
821
- async #date(raw) {
822
- const digits = (offset2, length) => {
823
- let value = 0;
824
- for (let index = offset2; index < offset2 + length; index++) {
825
- const digit = this.#digit(raw[index] ?? "", 10);
826
- if (digit < 0) this.#syntax();
827
- value = value * 10 + digit;
828
- }
829
- return value;
830
- };
831
- let offset = 0;
832
- const date = raw[4] === "-" && raw[7] === "-";
833
- if (date) {
834
- const year = digits(0, 4), month = digits(5, 2), day = digits(8, 2);
835
- const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
836
- const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
837
- if (year < 1 || month < 1 || month > 12 || day < 1 || day > days[month - 1]) this.#syntax();
838
- if (raw.length === 10) return;
839
- if (!["T", "t", " "].includes(raw[10])) this.#syntax();
840
- offset = 11;
841
- }
842
- if (raw[offset + 2] !== ":" || raw[offset + 5] !== ":" || digits(offset, 2) > 23 || digits(offset + 3, 2) > 59 || digits(offset + 6, 2) > 59) this.#syntax();
843
- offset += 8;
844
- if (raw[offset] === ".") {
845
- const start = ++offset;
846
- while (this.#digit(raw[offset] ?? "", 10) >= 0) {
847
- offset++;
848
- if ((offset - start) % 256 === 0) {
849
- await this.work.charge(256);
850
- this.work.assertOpen();
851
- }
852
- }
853
- if (offset === start) this.#syntax();
854
- }
855
- if (offset === raw.length) return;
856
- if (!date) this.#syntax();
857
- if (raw[offset] === "Z" || raw[offset] === "z") offset++;
858
- else if (raw[offset] === "+" || raw[offset] === "-") {
859
- if (raw[offset + 3] !== ":" || digits(offset + 1, 2) > 23 || digits(offset + 4, 2) > 59) this.#syntax();
860
- offset += 6;
861
- } else this.#syntax();
862
- if (offset !== raw.length) this.#syntax();
863
- }
864
- async parse() {
865
- if (this.source.charCodeAt(0) === 65279) this.#syntax();
866
- const root = await this.#table("root", 1);
867
- let current = root;
868
- while (true) {
869
- await this.#space(true);
870
- if (!this.#peek()) break;
871
- if (this.#peek() === "[") current = await this.#header(root);
872
- else {
873
- await this.#assignment(current);
874
- await this.#lineEnd();
875
- }
876
- }
877
- await this.#flush();
878
- return root;
879
- }
880
- };
881
- async function parseTomlDocument(text, work, ledger, rawBytes) {
882
- work.assertOpen();
883
- ledger.beginDocument(rawBytes);
884
- return new TomlParser(text, work, ledger).parse();
885
- }
886
-
887
- export {
888
- YqError,
889
- fromJqLimit,
890
- limit,
891
- yqCaps,
892
- resolveYqLimits,
893
- YqLedger,
894
- copyAlias,
895
- aliasFailure,
896
- parseTomlDocument
897
- };
898
- //# sourceMappingURL=chunk-4QTSSQKP.js.map