@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,649 +0,0 @@
1
- import {
2
- init_platform
3
- } from "./chunk-ZG7GWQ5P.js";
4
-
5
- // packages/safe-bash-query-engine/src/encoding.ts
6
- init_platform();
7
- var encoder = new TextEncoder();
8
- var decoder = new TextDecoder("utf-8", { ignoreBOM: true });
9
- function utf8ByteLength(text) {
10
- let bytes = 0;
11
- for (let index = 0; index < text.length; index++) {
12
- const code = text.charCodeAt(index);
13
- if (code < 128) bytes++;
14
- else if (code < 2048) bytes += 2;
15
- else if (code >= 55296 && code <= 56319 && index + 1 < text.length && text.charCodeAt(index + 1) >= 56320 && text.charCodeAt(index + 1) <= 57343) {
16
- bytes += 4;
17
- index++;
18
- } else bytes += 3;
19
- }
20
- return bytes;
21
- }
22
- function byteString(bytes) {
23
- let text = "";
24
- for (let offset = 0; offset < bytes.length; offset += 1024) text += String.fromCharCode(...bytes.subarray(offset, offset + 1024));
25
- return text;
26
- }
27
- function latin1Bytes(text) {
28
- const bytes = new Uint8Array(text.length);
29
- for (let index = 0; index < text.length; index++) bytes[index] = text.charCodeAt(index);
30
- return bytes;
31
- }
32
-
33
- // packages/safe-bash-query-engine/src/bytes.ts
34
- init_platform();
35
- function encodeBase64(bytes) {
36
- return btoa(byteString(bytes));
37
- }
38
- function decodeBase64(text) {
39
- return latin1Bytes(atob(text));
40
- }
41
- function compareBytes(left, right) {
42
- for (let index = 0; index < Math.min(left.length, right.length); index++) {
43
- if (left[index] !== right[index]) return left[index] - right[index];
44
- }
45
- return left.length - right.length;
46
- }
47
-
48
- // packages/safe-bash-query-engine/src/numbers.ts
49
- init_platform();
50
- var Decimal = class {
51
- constructor(digits, exponent, negative, text, double) {
52
- this.digits = digits;
53
- this.exponent = exponent;
54
- this.negative = negative;
55
- this.text = text;
56
- this.double = double;
57
- this.isFinite = Number.isFinite(double);
58
- Object.freeze(this);
59
- }
60
- digits;
61
- exponent;
62
- negative;
63
- text;
64
- double;
65
- isFinite;
66
- };
67
- var SMALL_DECIMALS = Array.from({ length: 1025 }, (_, i) => {
68
- const s = String(i);
69
- return new Decimal(s, 0, false, s, i);
70
- });
71
- function isNumber(value) {
72
- return typeof value === "number" || value instanceof Decimal;
73
- }
74
- function numberValue(value) {
75
- return typeof value === "number" ? value : value.double;
76
- }
77
- function numericToken(token, budget) {
78
- const len = token.length;
79
- if (len >= 1 && len <= 15) {
80
- const first = token.charCodeAt(0);
81
- if (first === 48 && len === 1) {
82
- budget.step(2);
83
- budget.text(token);
84
- return SMALL_DECIMALS[0];
85
- }
86
- if (first >= 49 && first <= 57) {
87
- let val = first - 48;
88
- let allDigits = true;
89
- for (let i = 1; i < len; i++) {
90
- const c = token.charCodeAt(i);
91
- if (c < 48 || c > 57) {
92
- allDigits = false;
93
- break;
94
- }
95
- val = val * 10 + (c - 48);
96
- }
97
- if (allDigits) {
98
- budget.step(2);
99
- budget.text(token);
100
- if (val <= 1024) return SMALL_DECIMALS[val];
101
- return new Decimal(token, 0, false, token, val);
102
- }
103
- }
104
- }
105
- budget.step(Math.ceil(token.length / 32));
106
- const end = token.indexOf("\0");
107
- const text = end < 0 ? token : token.slice(0, end);
108
- if (/^[+-]?s?nan[0-9]*$/iu.test(text)) return new Decimal("0", NaN, false, "null", NaN);
109
- if (/^[+-]?inf(?:inity)?$/iu.test(text)) {
110
- const negative = text[0] === "-";
111
- const value = negative ? -Infinity : Infinity;
112
- return new Decimal("1", Infinity, negative, numberText(value), value);
113
- }
114
- if (!/^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/u.test(text)) return void 0;
115
- return decimalNumber(text[0] === "+" ? text.slice(1) : text, budget);
116
- }
117
- function increment(digits) {
118
- let position = digits.length - 1;
119
- while (position >= 0 && digits[position] === "9") position--;
120
- return position < 0 ? `1${"0".repeat(digits.length)}` : `${digits.slice(0, position)}${Number(digits[position]) + 1}${"0".repeat(digits.length - position - 1)}`;
121
- }
122
- function decimalDouble(digits, exponent, negative) {
123
- let rounded = digits;
124
- if (digits.length > 17) {
125
- rounded = digits.slice(0, 17);
126
- const next = digits[17];
127
- if (next > "5" || next === "5" && (/[1-9]/u.test(digits.slice(18)) || Number(rounded[16]) % 2 !== 0)) rounded = increment(rounded);
128
- exponent += digits.length - 17;
129
- }
130
- return Number(`${negative ? "-" : ""}${rounded}e${exponent}`);
131
- }
132
- function decimalText(digits, exponent, negative) {
133
- const sign = negative ? "-" : "";
134
- const adjusted = exponent + digits.length - 1;
135
- if (exponent > 0 || adjusted < -6) return `${sign}${digits[0]}${digits.length > 1 ? `.${digits.slice(1)}` : ""}E${adjusted >= 0 ? "+" : ""}${adjusted}`;
136
- const point = digits.length + exponent;
137
- if (point <= 0) return `${sign}0.${"0".repeat(-point)}${digits}`;
138
- return `${sign}${digits.slice(0, point)}${point < digits.length ? `.${digits.slice(point)}` : ""}`;
139
- }
140
- function decimalNumber(token, budget) {
141
- budget.text(token);
142
- budget.step(Math.ceil(token.length / 32));
143
- const negative = token[0] === "-";
144
- const unsigned = negative ? token.slice(1) : token;
145
- const marker = unsigned.search(/[eE]/u);
146
- const coefficient = marker < 0 ? unsigned : unsigned.slice(0, marker);
147
- const point = coefficient.indexOf(".");
148
- let exponent = (marker < 0 ? 0 : Number(unsigned.slice(marker + 1))) - (point < 0 ? 0 : coefficient.length - point - 1);
149
- let digits = coefficient.replace(".", "").replace(/^0+/u, "") || "0";
150
- const minimumExponent = -1147483646;
151
- const maximumExponent = 999999999;
152
- if (digits === "0") exponent = Math.max(minimumExponent, Math.min(maximumExponent, exponent));
153
- else if (exponent + digits.length - 1 > maximumExponent) {
154
- const infinity = negative ? -Infinity : Infinity;
155
- return new Decimal("1", Infinity, negative, numberText(infinity), infinity);
156
- } else if (exponent < minimumExponent) {
157
- const retained = digits.length - (minimumExponent - exponent);
158
- const roundUp = retained >= 0 && digits[retained] >= "5";
159
- digits = retained > 0 ? digits.slice(0, retained) : "0";
160
- if (roundUp) digits = increment(digits);
161
- exponent = minimumExponent;
162
- }
163
- const text = decimalText(digits, exponent, negative);
164
- budget.text(text);
165
- return new Decimal(digits, exponent, negative, text, decimalDouble(digits, exponent, negative));
166
- }
167
- function compareNumbers(left, right, budget) {
168
- if (left instanceof Decimal && right instanceof Decimal && left.isFinite && right.isFinite && left.exponent === 0 && right.exponent === 0 && left.digits.length <= 15 && right.digits.length <= 15) {
169
- budget.step(2);
170
- return left.double < right.double ? -1 : left.double === right.double ? 0 : 1;
171
- }
172
- if (Number.isNaN(numberValue(left))) return -1;
173
- if (Number.isNaN(numberValue(right))) return 1;
174
- if (!(left instanceof Decimal) || !(right instanceof Decimal)) {
175
- const first = numberValue(left);
176
- const second = numberValue(right);
177
- return first < second ? -1 : first === second ? 0 : 1;
178
- }
179
- if (left.digits === "0" && right.digits === "0") return 0;
180
- const sign = left.negative ? -1 : 1;
181
- if (left.negative !== right.negative) return sign;
182
- if (left.digits === "0") return -sign;
183
- if (right.digits === "0") return sign;
184
- if (left.exponent === Infinity || right.exponent === Infinity) return left.exponent === right.exponent ? 0 : left.exponent === Infinity ? sign : -sign;
185
- const magnitude = left.exponent + left.digits.length - right.exponent - right.digits.length;
186
- if (magnitude) return Math.sign(magnitude) * sign;
187
- const length = Math.max(left.digits.length, right.digits.length);
188
- budget.step(Math.ceil(length / 32));
189
- for (let index = 0; index < length; index++) {
190
- if (index % 1024 === 0) budget.step();
191
- const first = left.digits[index] ?? "0";
192
- const second = right.digits[index] ?? "0";
193
- if (first !== second) return (first < second ? -1 : 1) * sign;
194
- }
195
- return 0;
196
- }
197
- function numberText(value) {
198
- if (value instanceof Decimal) return value.text;
199
- if (Number.isNaN(value)) return "null";
200
- const bounded = Math.max(-Number.MAX_VALUE, Math.min(Number.MAX_VALUE, value));
201
- const sign = bounded < 0 || Object.is(bounded, -0) ? "-" : "";
202
- const [mantissa, power] = Math.abs(bounded).toExponential().split("e");
203
- const digits = mantissa.replace(".", "");
204
- const exponent = Number(power);
205
- const point = exponent + 1;
206
- if (point <= -4 || point > digits.length + 15) return `${sign}${mantissa}e${exponent < 0 ? "-" : "+"}${String(Math.abs(exponent)).padStart(2, "0")}`;
207
- if (point <= 0) return `${sign}0.${"0".repeat(-point)}${digits}`;
208
- return `${sign}${point >= digits.length ? digits.padEnd(point, "0") : `${digits.slice(0, point)}.${digits.slice(point)}`}`;
209
- }
210
-
211
- // packages/safe-bash-query-engine/src/limits.ts
212
- init_platform();
213
- import { hasYieldCheckpoint, monotonicNow, runYieldCheckpoint, yieldTurn } from "../../safe-bash-contracts/yield.js";
214
- var ONCE_ABORT_OPTIONS = Object.freeze({ once: true });
215
- var defaultPerfNow = performance.now;
216
- var defaultJqLimits = Object.freeze({
217
- maxInputBytes: Infinity,
218
- maxValueBytes: Infinity,
219
- maxOutputBytes: Infinity,
220
- maxSourceBytes: Infinity,
221
- maxDepth: Infinity,
222
- maxAstDepth: Infinity,
223
- maxSteps: Infinity,
224
- maxResults: Infinity,
225
- maxCollectionSize: Infinity
226
- });
227
- var JqHalt = class extends Error {
228
- constructor(exitCode, stderr) {
229
- super("jq halted");
230
- this.exitCode = exitCode;
231
- this.stderr = stderr;
232
- }
233
- exitCode;
234
- stderr;
235
- };
236
- var JqError = class extends Error {
237
- constructor(message, exitCode = 5) {
238
- super(message);
239
- this.exitCode = exitCode;
240
- }
241
- exitCode;
242
- };
243
- var JqLimitError = class extends JqError {
244
- constructor(name) {
245
- super(`${name} limit exceeded`);
246
- }
247
- };
248
- function resolveJqLimits(options = {}) {
249
- const limits = { ...defaultJqLimits, ...options };
250
- for (const [name, value] of Object.entries(limits)) {
251
- if (value !== Infinity && !Number.isSafeInteger(value) || value < 1) throw new RangeError(`${name} must be a positive safe integer`);
252
- }
253
- return Object.freeze(limits);
254
- }
255
- var Budget = class {
256
- constructor(limits, signal) {
257
- this.limits = limits;
258
- this.signal = signal;
259
- this.unlimitedSteps = limits.maxSteps === Infinity;
260
- this.maxStepsSmi = !this.unlimitedSteps && limits.maxSteps <= 1073741823 ? limits.maxSteps | 0 : 1073741823;
261
- this.maxInputBytesSmi = limits.maxInputBytes <= 1073741823 ? limits.maxInputBytes | 0 : 1073741823;
262
- this.maxValueBytesSmi = limits.maxValueBytes <= 1073741823 ? limits.maxValueBytes | 0 : 1073741823;
263
- this.maxOutputBytesSmi = limits.maxOutputBytes <= 1073741823 ? limits.maxOutputBytes | 0 : 1073741823;
264
- this.maxDepthSmi = limits.maxDepth <= 1073741823 ? limits.maxDepth | 0 : 1073741823;
265
- this.maxAstDepthSmi = limits.maxAstDepth <= 1073741823 ? limits.maxAstDepth | 0 : 1073741823;
266
- this.maxResultsSmi = limits.maxResults <= 1073741823 ? limits.maxResults | 0 : 1073741823;
267
- this.maxCollectionSizeSmi = limits.maxCollectionSize <= 1073741823 ? limits.maxCollectionSize | 0 : 1073741823;
268
- this.unlimitedValueCheck = limits.maxValueBytes === Infinity && limits.maxDepth === Infinity && limits.maxCollectionSize === Infinity;
269
- this.bindSignal(signal);
270
- }
271
- limits;
272
- signal;
273
- steps = 0;
274
- yieldTimes = new Float64Array([monotonicNow()]);
275
- lastYieldSteps = 0;
276
- unlimitedSteps;
277
- maxStepsSmi;
278
- aborted = false;
279
- pollSignal = false;
280
- maxInputBytesSmi;
281
- maxValueBytesSmi;
282
- maxOutputBytesSmi;
283
- maxDepthSmi;
284
- maxAstDepthSmi;
285
- maxResultsSmi;
286
- maxCollectionSizeSmi;
287
- unlimitedValueCheck;
288
- inputBytes = 0;
289
- outputBytes = 0;
290
- results = 0;
291
- inputLocation = { name: "<unknown>", line: 0, complete: true };
292
- onAbortBound = () => {
293
- this.aborted = true;
294
- };
295
- bindSignal(signal) {
296
- this.aborted = Boolean(signal?.aborted);
297
- this.pollSignal = true;
298
- }
299
- resetForRun(signal) {
300
- this.signal = signal;
301
- this.bindSignal(signal);
302
- this.steps = 0;
303
- this.lastYieldSteps = 0;
304
- this.yieldTimes[0] = monotonicNow();
305
- this.inputBytes = 0;
306
- this.outputBytes = 0;
307
- this.results = 0;
308
- this.inputLocation.name = "<unknown>";
309
- this.inputLocation.line = 0;
310
- this.inputLocation.complete = true;
311
- }
312
- resetForSyncFastRun(signal) {
313
- this.signal = signal;
314
- this.bindSignal(signal);
315
- this.steps = 0;
316
- this.lastYieldSteps = 0;
317
- this.yieldTimes[0] = performance.now !== defaultPerfNow || hasYieldCheckpoint(signal) ? monotonicNow() : -1;
318
- this.inputBytes = 0;
319
- this.outputBytes = 0;
320
- this.results = 0;
321
- this.inputLocation.name = "<unknown>";
322
- this.inputLocation.line = 0;
323
- this.inputLocation.complete = true;
324
- }
325
- step(count = 1) {
326
- if (this.aborted || this.pollSignal && this.signal.aborted) {
327
- this.aborted = true;
328
- this.signal.throwIfAborted();
329
- }
330
- const next = this.steps + count;
331
- this.steps = next;
332
- if (!this.unlimitedSteps && next > this.maxStepsSmi && next > this.limits.maxSteps) throw new JqLimitError("maxSteps");
333
- }
334
- get currentSteps() {
335
- return this.steps;
336
- }
337
- restoreSteps(steps) {
338
- this.steps = steps;
339
- }
340
- needsYield(checkTime = false) {
341
- const checkpoint = hasYieldCheckpoint(this.signal);
342
- if (checkTime || checkpoint) {
343
- const now = monotonicNow();
344
- if (this.yieldTimes[0] < 0) this.yieldTimes[0] = now;
345
- if (now - this.yieldTimes[0] >= 25) return true;
346
- if (checkpoint) return this.steps - this.lastYieldSteps >= 1024;
347
- }
348
- if (this.steps - this.lastYieldSteps >= 65536) {
349
- if (!checkTime && this.yieldTimes[0] >= 0 && this.steps < 524288 && monotonicNow() - this.yieldTimes[0] < 20) {
350
- this.lastYieldSteps = this.steps;
351
- return false;
352
- }
353
- return true;
354
- }
355
- return false;
356
- }
357
- ensureFreshWindow() {
358
- const now = monotonicNow();
359
- if (this.yieldTimes[0] < 0) this.yieldTimes[0] = now;
360
- if (now - this.yieldTimes[0] < 15) {
361
- runYieldCheckpoint(this.signal);
362
- return void 0;
363
- }
364
- return this.yieldTickSync();
365
- }
366
- tickSync(count = 1) {
367
- this.step(count);
368
- if (this.steps - this.lastYieldSteps >= 65536 || this.needsYield(count === 0)) return this.yieldTickSync();
369
- return void 0;
370
- }
371
- yieldTickSync() {
372
- return yieldTurn(this.signal).then(() => {
373
- this.signal.throwIfAborted();
374
- this.yieldTimes[0] = monotonicNow();
375
- this.lastYieldSteps = this.steps;
376
- });
377
- }
378
- async tick(count = 1) {
379
- this.step(count);
380
- if (this.needsYield(true)) await this.yieldTickSync();
381
- }
382
- collection(size) {
383
- if (size > this.maxCollectionSizeSmi && size > this.limits.maxCollectionSize) throw new JqLimitError("maxCollectionSize");
384
- }
385
- text(text) {
386
- if (text.length > this.maxValueBytesSmi || text.length * 3 > this.maxValueBytesSmi && utf8ByteLength(text) > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
387
- }
388
- checkValue(value) {
389
- if (this.unlimitedValueCheck) {
390
- this.step();
391
- return;
392
- }
393
- this.visitValue(value, 0, 0);
394
- }
395
- value(value) {
396
- if (this.unlimitedValueCheck && this.unlimitedSteps) {
397
- this.step();
398
- return 0;
399
- }
400
- return this.visitValue(value, 0, 0);
401
- }
402
- visitValue(current, depth, bytes) {
403
- this.step();
404
- if (depth > this.limits.maxDepth) throw new JqLimitError("maxDepth");
405
- if (current !== null && typeof current === "object" && !(current instanceof Decimal)) {
406
- const cached = cachedValueMetrics.get(current);
407
- if (cached !== void 0) {
408
- if (depth + cached.maxRelDepth > this.limits.maxDepth) throw new JqLimitError("maxDepth");
409
- this.collection(cached.maxCol);
410
- const total = bytes + cached.bytes;
411
- if (total > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
412
- return total;
413
- }
414
- if (depth + 1 > this.limits.maxDepth) throw new JqLimitError("maxDepth");
415
- const startBytes = bytes;
416
- let maxRelDepth = 1;
417
- let maxCol = 0;
418
- if (Array.isArray(current)) {
419
- maxCol = current.length;
420
- this.collection(maxCol);
421
- bytes += 2 + Math.max(0, current.length - 1);
422
- for (let index = 0; index < current.length; index++) {
423
- if (bytes > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
424
- const child = current[index];
425
- bytes = this.visitValue(child, depth + 1, bytes);
426
- if (child !== null && typeof child === "object" && !(child instanceof Decimal)) {
427
- const cm = cachedValueMetrics.get(child);
428
- if (cm) {
429
- if (cm.maxRelDepth + 1 > maxRelDepth) maxRelDepth = cm.maxRelDepth + 1;
430
- if (cm.maxCol > maxCol) maxCol = cm.maxCol;
431
- }
432
- }
433
- }
434
- } else {
435
- const keys = keyOrders.get(current);
436
- if (keys !== void 0) {
437
- maxCol = keys.length;
438
- this.collection(maxCol);
439
- bytes += 2 + Math.max(0, keys.length - 1);
440
- for (let index = 0; index < keys.length; index++) {
441
- const key = keys[index];
442
- this.text(key);
443
- bytes += scalarJsonByteLength(key, this) + 1;
444
- if (bytes > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
445
- const child = current[key];
446
- bytes = this.visitValue(child, depth + 1, bytes);
447
- if (child !== null && typeof child === "object" && !(child instanceof Decimal)) {
448
- const cm = cachedValueMetrics.get(child);
449
- if (cm) {
450
- if (cm.maxRelDepth + 1 > maxRelDepth) maxRelDepth = cm.maxRelDepth + 1;
451
- if (cm.maxCol > maxCol) maxCol = cm.maxCol;
452
- }
453
- }
454
- }
455
- } else {
456
- let count = 0;
457
- for (const key in current) {
458
- if (!Object.hasOwn(current, key)) continue;
459
- this.collection(++count);
460
- this.text(key);
461
- bytes += scalarJsonByteLength(key, this) + 1 + (count > 1 ? 1 : 0);
462
- if (bytes > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
463
- const child = current[key];
464
- bytes = this.visitValue(child, depth + 1, bytes);
465
- if (child !== null && typeof child === "object" && !(child instanceof Decimal)) {
466
- const cm = cachedValueMetrics.get(child);
467
- if (cm) {
468
- if (cm.maxRelDepth + 1 > maxRelDepth) maxRelDepth = cm.maxRelDepth + 1;
469
- if (cm.maxCol > maxCol) maxCol = cm.maxCol;
470
- }
471
- }
472
- }
473
- if (count > maxCol) maxCol = count;
474
- bytes += 2;
475
- }
476
- }
477
- cachedValueMetrics.set(current, { bytes: bytes - startBytes, maxRelDepth, maxCol });
478
- } else {
479
- if (typeof current === "string") {
480
- this.step(current.length);
481
- this.text(current);
482
- }
483
- bytes += scalarJsonByteLength(current, this);
484
- }
485
- if (bytes > this.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
486
- return bytes;
487
- }
488
- };
489
- var keyOrders = /* @__PURE__ */ new WeakMap();
490
- var cachedValueMetrics = /* @__PURE__ */ new WeakMap();
491
- function invalidateCachedValueMetrics(target) {
492
- cachedValueMetrics.delete(target);
493
- }
494
- function hasCustomKeyOrder(value) {
495
- return keyOrders.has(value);
496
- }
497
- function object() {
498
- return {};
499
- }
500
- function objectKeys(value) {
501
- return keyOrders.get(value)?.slice() ?? Object.keys(value);
502
- }
503
- function* objectKeyIterator(value) {
504
- const keys = keyOrders.get(value);
505
- if (keys) yield* keys;
506
- else for (const key in value) if (Object.hasOwn(value, key)) yield key;
507
- }
508
- function objectSize(value) {
509
- return keyOrders.get(value)?.length ?? Object.keys(value).length;
510
- }
511
- function put(value, key, item) {
512
- const existing = Object.hasOwn(value, key);
513
- let keys = keyOrders.get(value);
514
- if (keys !== void 0) {
515
- if (!existing) keys.push(key);
516
- } else if (!existing && key.length > 0) {
517
- const first = key.charCodeAt(0);
518
- if (first >= 48 && first <= 57) {
519
- keys = Object.keys(value);
520
- keys.push(key);
521
- keyOrders.set(value, keys);
522
- }
523
- }
524
- if (key === "__proto__") {
525
- Object.defineProperty(value, "__proto__", { value: item, writable: true, enumerable: true, configurable: true });
526
- } else {
527
- value[key] = item;
528
- }
529
- }
530
- function remove(value, key) {
531
- if (!Object.hasOwn(value, key)) return;
532
- let keys = keyOrders.get(value);
533
- if (!keys) {
534
- keys = Object.keys(value);
535
- keyOrders.set(value, keys);
536
- }
537
- delete value[key];
538
- const index = keys.indexOf(key);
539
- if (index >= 0) keys.splice(index, 1);
540
- }
541
- function copyObject(...sources) {
542
- const result = object();
543
- for (const source of sources) if (source) for (const key of objectKeys(source)) put(result, key, source[key]);
544
- return result;
545
- }
546
- function wellFormed(text) {
547
- for (let index = 0; index < text.length; index++) {
548
- const code = text.charCodeAt(index);
549
- if (code >= 55296 && code <= 56319) {
550
- const next = text.charCodeAt(++index);
551
- if (!(next >= 56320 && next <= 57343)) return false;
552
- } else if (code >= 56320 && code <= 57343) return false;
553
- }
554
- return true;
555
- }
556
- function isObject(value) {
557
- return value !== null && typeof value === "object" && !Array.isArray(value) && !(value instanceof Decimal);
558
- }
559
- function truth(value) {
560
- return value !== null && value !== false;
561
- }
562
- function scalarJson(value, budget) {
563
- if (value instanceof Decimal) budget.step(Math.ceil(value.text.length / 32));
564
- return isNumber(value) ? numberText(value) : JSON.stringify(value);
565
- }
566
- function scalarJsonByteLength(value, budget) {
567
- if (value === null || value === true) return 4;
568
- if (value === false) return 5;
569
- if (typeof value === "number") {
570
- return Number.isFinite(value) ? Object.is(value, -0) ? 2 : String(value).length : utf8ByteLength(scalarJson(value, budget));
571
- }
572
- if (value instanceof Decimal) {
573
- budget.step(Math.ceil(value.text.length / 32));
574
- return utf8ByteLength(numberText(value));
575
- }
576
- let extra = 2;
577
- for (let index = 0; index < value.length; index++) {
578
- const code = value.charCodeAt(index);
579
- if (code >= 128) return utf8ByteLength(JSON.stringify(value));
580
- if (code === 34 || code === 92 || code === 8 || code === 9 || code === 10 || code === 12 || code === 13) extra++;
581
- else if (code < 32) extra += 5;
582
- }
583
- return value.length + extra;
584
- }
585
- async function interruptible(operation, signal) {
586
- signal.throwIfAborted();
587
- return new Promise((resolve, reject) => {
588
- const aborted = () => {
589
- signal.removeEventListener("abort", aborted);
590
- reject(signal.reason);
591
- };
592
- signal.addEventListener("abort", aborted, { once: true });
593
- try {
594
- Promise.resolve(operation()).then(
595
- (result) => {
596
- signal.removeEventListener("abort", aborted);
597
- resolve(result);
598
- },
599
- (error) => {
600
- signal.removeEventListener("abort", aborted);
601
- reject(error);
602
- }
603
- );
604
- } catch (error) {
605
- signal.removeEventListener("abort", aborted);
606
- reject(error);
607
- }
608
- });
609
- }
610
-
611
- export {
612
- encoder,
613
- decoder,
614
- utf8ByteLength,
615
- byteString,
616
- latin1Bytes,
617
- encodeBase64,
618
- decodeBase64,
619
- compareBytes,
620
- Decimal,
621
- SMALL_DECIMALS,
622
- isNumber,
623
- numberValue,
624
- numericToken,
625
- decimalNumber,
626
- compareNumbers,
627
- numberText,
628
- defaultJqLimits,
629
- JqHalt,
630
- JqError,
631
- JqLimitError,
632
- resolveJqLimits,
633
- Budget,
634
- invalidateCachedValueMetrics,
635
- hasCustomKeyOrder,
636
- object,
637
- objectKeys,
638
- objectKeyIterator,
639
- objectSize,
640
- put,
641
- remove,
642
- copyObject,
643
- wellFormed,
644
- isObject,
645
- truth,
646
- scalarJson,
647
- interruptible
648
- };
649
- //# sourceMappingURL=chunk-44WUNUPV.js.map