@poe-platform/safe-bash 0.1.825 → 0.1.827
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.
- package/dist/image-ast/index.js +39 -18
- package/dist/pdf-ast/image.js +1 -1
- package/dist/pdf-ast/index.js +1 -1
- package/dist/pdf-ast/vendor/pdfjs-fonts.mjs +9 -3
- package/dist/safe-bash/chunks/{chunk-AGHV53VF.js → chunk-M6XFU6LQ.js} +3 -1
- package/dist/safe-bash/chunks/{chunk-363QOIDR.js → chunk-T6FHWSHM.js} +3 -1
- package/dist/safe-bash/command-chunks/{chunk-ZPBL7TYJ.js → chunk-2JRHCVMQ.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-FMGNXOMV.js → chunk-2L3NMRLG.js} +7 -3
- package/dist/safe-bash/command-chunks/{chunk-DAQO64WC.js → chunk-2YKOJPIW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-EPYJSPOY.js → chunk-3QCW4VQF.js} +12 -8
- package/dist/safe-bash/command-chunks/{chunk-YRBFNT5B.js → chunk-3YL2TMLA.js} +10 -1
- package/dist/safe-bash/command-chunks/{chunk-5H7ZHP7F.js → chunk-43NDRBKY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-BBOYR6LV.js → chunk-46GA576V.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-WPT2FCHH.js → chunk-4SLPM2WM.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-7ZQVMPSB.js → chunk-5CAXR62E.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-3DTHX5UU.js → chunk-66653AEZ.js} +40 -14
- package/dist/safe-bash/command-chunks/{chunk-ETFJ4L7F.js → chunk-6OLE6CLV.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-ZIDESNHW.js → chunk-7M3M6FKC.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-2KMNVJB7.js → chunk-A7PKUIJT.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-AVSINNZ6.js → chunk-DEQ47SBQ.js} +5 -5
- package/dist/safe-bash/command-chunks/{chunk-EV7A5FNN.js → chunk-FFFRLPXU.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4MVQE6CT.js → chunk-FYTBEGSY.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-LFTGMUAV.js → chunk-HQIZR6EU.js} +192 -489
- package/dist/safe-bash/command-chunks/chunk-HS2L7I4N.js +219 -0
- package/dist/safe-bash/command-chunks/{chunk-WKS2PAZL.js → chunk-HUGKO4ZE.js} +10 -1
- package/dist/safe-bash/command-chunks/chunk-IGXH5W5Z.js +111 -0
- package/dist/safe-bash/command-chunks/{chunk-CMJBRGU2.js → chunk-IHQZKUBS.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-JADJ4BMN.js +1519 -0
- package/dist/safe-bash/command-chunks/{chunk-5AQAWIYK.js → chunk-JEZC5V3B.js} +4 -0
- package/dist/safe-bash/command-chunks/{chunk-YB5TNDY6.js → chunk-K5VJ4NNL.js} +39 -5
- package/dist/safe-bash/command-chunks/{chunk-7RQGRFHJ.js → chunk-KHWDEAE4.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-L54KVUSY.js +604 -0
- package/dist/safe-bash/command-chunks/{chunk-3NJETNC2.js → chunk-MBXNG6C3.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-HCPEYQKT.js → chunk-N4SH6QY5.js} +285 -302
- package/dist/safe-bash/command-chunks/{chunk-3DID6MQY.js → chunk-OWTQYLID.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-4EA7WI3L.js → chunk-QOOQD6BD.js} +42 -33
- package/dist/safe-bash/command-chunks/{chunk-RQTFK7AV.js → chunk-QZYEI4N6.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-R3SLT3ZX.js → chunk-R6GON4H3.js} +11 -1
- package/dist/safe-bash/command-chunks/{chunk-2GILUQJY.js → chunk-R7ZGDHME.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-HNEWGADJ.js → chunk-RUXOFW5G.js} +7 -6
- package/dist/safe-bash/command-chunks/{chunk-LKAFLJ5L.js → chunk-RWQKX44L.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-PKH57OIC.js → chunk-SG2KOOD4.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-T4TGJYFV.js +60 -0
- package/dist/safe-bash/command-chunks/chunk-TGSNVLFZ.js +105 -0
- package/dist/safe-bash/command-chunks/{chunk-NXCJNPL3.js → chunk-UCE77LYV.js} +2 -1
- package/dist/safe-bash/command-chunks/{chunk-EWECMOQ5.js → chunk-UIHPHIKI.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-XSZNL3GV.js → chunk-UJPWPRVB.js} +191 -146
- package/dist/safe-bash/command-chunks/{chunk-E5CDHXFA.js → chunk-VOR6YDZC.js} +26 -1
- package/dist/safe-bash/command-chunks/chunk-VSNVYOK2.js +30 -0
- package/dist/safe-bash/command-chunks/{chunk-4XYGJB24.js → chunk-VTH4AORO.js} +3 -3
- package/dist/safe-bash/command-chunks/{chunk-W5LH7D23.js → chunk-WKKJJBJQ.js} +8 -8
- package/dist/safe-bash/command-chunks/{chunk-OLXMWQJ5.js → chunk-WRO3PB2M.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-RUAGHZNF.js → chunk-X5ODTF3E.js} +7 -5
- package/dist/safe-bash/command-chunks/{chunk-LH4VBNF6.js → chunk-XGTSP2CP.js} +84 -16
- package/dist/safe-bash/command-chunks/{chunk-K576GZED.js → chunk-XTHKXCF2.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-J3VS55K4.js → chunk-YHRESVJ7.js} +9 -3
- package/dist/safe-bash/command-chunks/{chunk-UWIDPTOB.js → chunk-YSCKOUQP.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-UYNJF5QN.js → chunk-ZALAWNOE.js} +76 -122
- package/dist/safe-bash/command-chunks/{chunk-OT75C5YS.js → chunk-ZYXKW2K7.js} +1 -1
- package/dist/safe-bash/command-chunks/{pdf-renderer-346WYKSZ.js → pdf-renderer-5QWOVFA4.js} +1 -1
- package/dist/safe-bash/command-chunks/{prompt-tool-debug-3POFNRYP.js → prompt-tool-debug-G7ATE7D5.js} +6 -4
- package/dist/safe-bash/commands/llm/index.browser.js +5 -1
- package/dist/safe-bash/commands/llm/index.js +1 -1
- package/dist/safe-bash/commands/python/executor.browser.js +3 -1
- package/dist/safe-bash/commands/python/executor.js +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +5 -1
- package/dist/safe-bash/commands/python/index.js +1 -1
- package/dist/safe-bash/core.browser.js +2 -2
- package/dist/safe-bash/full-core.browser.js +10 -2
- package/dist/safe-bash-command-awk/awk-runtime.js +2 -2
- package/dist/safe-bash-command-awk/awk-syntax.js +1 -1
- package/dist/safe-bash-command-awk/awk.js +3 -3
- package/dist/safe-bash-command-awk/index.js +3 -3
- package/dist/safe-bash-command-gpg/index.js +11 -3
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-llm/collections.js +6 -4
- package/dist/safe-bash-command-llm/command.js +4 -4
- package/dist/safe-bash-command-llm/import-json-document.d.ts +9 -2
- package/dist/safe-bash-command-llm/index.d.ts +2 -1
- package/dist/safe-bash-command-llm/index.js +10 -4
- package/dist/safe-bash-command-llm/loader-provider.d.ts +5 -0
- package/dist/safe-bash-command-mcp/index.js +10 -13
- package/dist/safe-bash-command-pdftoppm/index.js +2 -2
- package/dist/safe-bash-command-playwright-cli/index.js +2 -2
- package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.d.ts +1 -0
- package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.js +1 -1
- package/dist/safe-bash-command-playwright-cli/playwright/controller.d.ts +2 -0
- package/dist/safe-bash-command-playwright-cli/playwright/controller.js +2 -2
- package/dist/safe-bash-command-playwright-cli/playwright/index.js +2 -2
- package/dist/safe-bash-command-python/build-backend.d.ts +2 -0
- package/dist/safe-bash-command-python/cache.d.ts +1 -1
- package/dist/safe-bash-command-python/executor.d.ts +5 -2
- package/dist/safe-bash-command-python/executor.js +11 -6
- package/dist/safe-bash-command-python/host-capabilities.js +1 -1
- package/dist/safe-bash-command-python/index.js +11 -6
- package/dist/safe-bash-command-python/jspi.js +5 -3
- package/dist/safe-bash-command-python/manifest-file.d.ts +44 -0
- package/dist/safe-bash-command-python/manifest.d.ts +45 -0
- package/dist/safe-bash-command-python/provisioning.d.ts +20 -1
- package/dist/safe-bash-command-python/provisioning.js +3 -2
- package/dist/safe-bash-command-python/reply.js +7 -11
- package/dist/safe-bash-command-python/source-archive.js +2 -2
- package/dist/safe-bash-command-python/source-zip.js +2 -2
- package/dist/safe-bash-command-python/worker.js +34 -21
- package/dist/safe-bash-command-sqlite3/engine.d.ts +4 -0
- package/dist/safe-bash-command-sqlite3/index.js +174 -18
- package/dist/safe-bash-command-svgo/index.js +1 -1
- package/dist/safe-bash-command-tar/create.js +3 -3
- package/dist/safe-bash-command-tar/extract.js +3 -3
- package/dist/safe-bash-command-tar/index.js +5 -5
- package/dist/safe-bash-command-tar/modes.js +5 -5
- package/dist/safe-bash-command-tar/options.d.ts +1 -1
- package/dist/safe-bash-command-tar/options.js +1 -1
- package/dist/safe-bash-command-tar/stream.js +1 -1
- package/dist/safe-bash-command-wkhtmltopdf/index.js +1 -1
- package/dist/safe-bash-command-xan/argv.js +1 -1
- package/dist/safe-bash-command-xan/commands.js +3 -3
- package/dist/safe-bash-command-xan/index.js +3 -3
- package/dist/safe-bash-command-xan/io.js +2 -2
- package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
- package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
- package/dist/safe-bash-compression-engine/files.js +6 -6
- package/dist/safe-bash-compression-engine/index.js +5 -5
- package/dist/safe-bash-compression-engine/operand.js +6 -6
- package/dist/safe-bash-compression-engine/options.js +1 -1
- package/dist/safe-bash-compression-engine/stream.js +5 -5
- package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
- package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
- package/dist/safe-bash-contracts/filesystem-output.js +1 -1
- package/dist/safe-bash-csv-engine/index.js +6 -6
- package/dist/safe-bash-csv-engine/python-codec-aliases.js +1 -1
- package/dist/safe-bash-csv-engine/python-codepages.js +3 -3
- package/dist/safe-bash-csv-engine/python-file-codepages.js +2 -2
- package/dist/safe-bash-csv-engine/python-utf16.js +4 -4
- package/dist/safe-bash-csv-engine/text-decoder.js +6 -6
- package/dist/safe-bash-graphviz-engine/index.js +1 -1
- package/dist/safe-bash-pager-engine/index.js +2 -2
- package/dist/safe-bash-query-engine/capture.js +3 -3
- package/dist/safe-bash-query-engine/delpaths.js +3 -3
- package/dist/safe-bash-query-engine/formats.js +2 -2
- package/dist/safe-bash-query-engine/index.js +10 -10
- package/dist/safe-bash-query-engine/indices.js +3 -3
- package/dist/safe-bash-query-engine/input.d.ts +3 -3
- package/dist/safe-bash-query-engine/input.js +1 -1
- package/dist/safe-bash-query-engine/interpreter.js +9 -9
- package/dist/safe-bash-query-engine/query-core.js +10 -10
- package/dist/safe-bash-query-engine/regex.js +4 -4
- package/dist/safe-bash-query-engine/splits.js +5 -5
- package/dist/safe-bash-query-engine/values.js +2 -2
- package/package.json +2 -2
- package/dist/safe-bash/command-chunks/chunk-OOYVZAWL.js +0 -90
- package/dist/safe-bash/command-chunks/chunk-RZOHZGEZ.js +0 -772
- package/dist/safe-bash/command-chunks/chunk-WIUEM7HP.js +0 -58
- package/dist/safe-bash/command-chunks/chunk-WY6THI6J.js +0 -673
- package/dist/safe-bash/command-chunks/chunk-ZERCTWUI.js +0 -467
|
@@ -164,7 +164,7 @@ var JqParseError = class extends JqError {
|
|
|
164
164
|
};
|
|
165
165
|
function decodeUtf8(bytes, budget, fatal = false, points) {
|
|
166
166
|
budget.step(Math.ceil(bytes.length / 1024));
|
|
167
|
-
if (fatal === true && !points) return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(latin1Bytes(bytes));
|
|
167
|
+
if ((fatal === true || fatal === "javascript") && !points) return new TextDecoder("utf-8", { fatal: fatal === true, ignoreBOM: true }).decode(latin1Bytes(bytes));
|
|
168
168
|
let ascii = true;
|
|
169
169
|
for (let index = 0; index < bytes.length; index++) {
|
|
170
170
|
if ((index & 1023) === 0) budget.signal.throwIfAborted();
|
|
@@ -235,100 +235,82 @@ function shortSliceString(bytes, start, end) {
|
|
|
235
235
|
}
|
|
236
236
|
return byteString(bytes.subarray(start, start + len));
|
|
237
237
|
}
|
|
238
|
-
function pythonJsonNumber(text) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
};
|
|
245
|
-
if (text[index] === "0") index++;
|
|
246
|
-
else {
|
|
247
|
-
if (!digit(index) || text[index] === "0") return false;
|
|
248
|
-
while (digit(index)) index++;
|
|
249
|
-
}
|
|
250
|
-
if (text[index] === ".") {
|
|
251
|
-
index++;
|
|
252
|
-
if (!digit(index)) return false;
|
|
253
|
-
while (digit(index)) index++;
|
|
254
|
-
}
|
|
255
|
-
if (text[index] === "e" || text[index] === "E") {
|
|
256
|
-
index++;
|
|
257
|
-
if (text[index] === "+" || text[index] === "-") index++;
|
|
258
|
-
if (!digit(index)) return false;
|
|
259
|
-
while (digit(index)) index++;
|
|
260
|
-
}
|
|
261
|
-
return index === text.length;
|
|
238
|
+
function pythonJsonNumber(text, constants) {
|
|
239
|
+
try {
|
|
240
|
+
return constants && ["NaN", "Infinity", "-Infinity"].includes(text) || typeof JSON.parse(text) === "number";
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
262
244
|
}
|
|
263
245
|
var JsonParser = class {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
quoted = false;
|
|
281
|
-
chunkedString = false;
|
|
282
|
-
chunkedLeaf = false;
|
|
283
|
-
stringPoints;
|
|
284
|
-
keyPoints = /* @__PURE__ */ new Map();
|
|
285
|
-
completedValues = 0;
|
|
286
|
-
escaped = false;
|
|
287
|
-
bom = 0;
|
|
288
|
-
bytes = 0;
|
|
289
|
-
depth = 0;
|
|
290
|
-
offset = 0;
|
|
291
|
-
line = 1;
|
|
292
|
-
column = 0;
|
|
246
|
+
#stack = [];
|
|
247
|
+
#next;
|
|
248
|
+
#token = "";
|
|
249
|
+
#quoted = false;
|
|
250
|
+
#chunkedString = false;
|
|
251
|
+
#chunkedLeaf = false;
|
|
252
|
+
#stringPoints;
|
|
253
|
+
#keyPoints = /* @__PURE__ */ new Map();
|
|
254
|
+
#completedValues = 0;
|
|
255
|
+
#escaped = false;
|
|
256
|
+
#bom = 0;
|
|
257
|
+
#bytes = 0;
|
|
258
|
+
#depth = 0;
|
|
259
|
+
#offset = 0;
|
|
260
|
+
#line = 1;
|
|
261
|
+
#column = 0;
|
|
293
262
|
events = [];
|
|
294
|
-
_counts;
|
|
295
|
-
_closed;
|
|
296
|
-
_lastKey;
|
|
297
|
-
get counts() {
|
|
298
|
-
return this
|
|
299
|
-
}
|
|
300
|
-
get closed() {
|
|
301
|
-
return this
|
|
302
|
-
}
|
|
303
|
-
get lastKey() {
|
|
304
|
-
return this
|
|
305
|
-
}
|
|
306
|
-
reusableObj = object();
|
|
307
|
-
reusableKeys = [];
|
|
308
|
-
reusableArr = [];
|
|
309
|
-
reusableInUse = false;
|
|
263
|
+
#_counts;
|
|
264
|
+
#_closed;
|
|
265
|
+
#_lastKey;
|
|
266
|
+
get #counts() {
|
|
267
|
+
return this.#_counts ??= /* @__PURE__ */ new WeakMap();
|
|
268
|
+
}
|
|
269
|
+
get #closed() {
|
|
270
|
+
return this.#_closed ??= /* @__PURE__ */ new WeakSet();
|
|
271
|
+
}
|
|
272
|
+
get #lastKey() {
|
|
273
|
+
return this.#_lastKey ??= /* @__PURE__ */ new WeakMap();
|
|
274
|
+
}
|
|
275
|
+
#reusableObj = object();
|
|
276
|
+
#reusableKeys = [];
|
|
277
|
+
#reusableArr = [];
|
|
278
|
+
#reusableInUse = false;
|
|
279
|
+
#budget;
|
|
280
|
+
#stream;
|
|
281
|
+
#stringChunks;
|
|
282
|
+
#profile;
|
|
283
|
+
constructor(budget, stream = false, line = 1, column = 0, stringChunks, profile) {
|
|
284
|
+
this.#budget = budget;
|
|
285
|
+
this.#stream = stream;
|
|
286
|
+
this.#stringChunks = stringChunks;
|
|
287
|
+
this.#profile = profile;
|
|
288
|
+
this.#line = line;
|
|
289
|
+
this.#column = column;
|
|
290
|
+
if (profile === "python39") this.#bom = 3;
|
|
291
|
+
}
|
|
310
292
|
releaseReusable() {
|
|
311
|
-
invalidateCachedValueMetrics(this
|
|
312
|
-
invalidateCachedValueMetrics(this
|
|
313
|
-
this
|
|
293
|
+
invalidateCachedValueMetrics(this.#reusableObj);
|
|
294
|
+
invalidateCachedValueMetrics(this.#reusableArr);
|
|
295
|
+
this.#reusableInUse = false;
|
|
314
296
|
}
|
|
315
297
|
isQuotedUnescaped() {
|
|
316
|
-
return this
|
|
298
|
+
return this.#quoted && !this.#escaped && this.#bom >= 3;
|
|
317
299
|
}
|
|
318
300
|
isUnquotedReady() {
|
|
319
|
-
return !this
|
|
301
|
+
return !this.#quoted && this.#bom >= 3;
|
|
320
302
|
}
|
|
321
303
|
isTopLevelIdle() {
|
|
322
|
-
return !this
|
|
304
|
+
return !this.#quoted && !this.#escaped && this.#stack.length === 0 && this.#token === "" && this.#next === void 0 && !this.#stream;
|
|
323
305
|
}
|
|
324
306
|
tryParseFlatLine(bytes, start, end) {
|
|
325
307
|
const byteLen = end - start;
|
|
326
|
-
if (byteLen < 2 || byteLen > this
|
|
308
|
+
if (byteLen < 2 || byteLen > this.#budget.maxValueBytesSmi && byteLen > this.#budget.limits.maxValueBytes) return void 0;
|
|
327
309
|
if (bytes[start] !== 123 || bytes[end - 1] !== 125) return void 0;
|
|
328
|
-
if (this
|
|
329
|
-
const canReuse = !this
|
|
330
|
-
let obj = canReuse ? this
|
|
331
|
-
const rKeys = this
|
|
310
|
+
if (this.#budget.maxDepthSmi < 1) return void 0;
|
|
311
|
+
const canReuse = !this.#reusableInUse;
|
|
312
|
+
let obj = canReuse ? this.#reusableObj : object();
|
|
313
|
+
const rKeys = this.#reusableKeys;
|
|
332
314
|
let shapeMatch = canReuse && rKeys.length > 0;
|
|
333
315
|
let usedArr = false;
|
|
334
316
|
let pos = start + 1;
|
|
@@ -363,7 +345,7 @@ var JsonParser = class {
|
|
|
363
345
|
}
|
|
364
346
|
obj = fresh;
|
|
365
347
|
if (canReuse) {
|
|
366
|
-
this
|
|
348
|
+
this.#reusableObj = obj;
|
|
367
349
|
rKeys.length = count;
|
|
368
350
|
}
|
|
369
351
|
}
|
|
@@ -386,7 +368,7 @@ var JsonParser = class {
|
|
|
386
368
|
}
|
|
387
369
|
obj = fresh;
|
|
388
370
|
if (canReuse) {
|
|
389
|
-
this
|
|
371
|
+
this.#reusableObj = obj;
|
|
390
372
|
rKeys.length = count;
|
|
391
373
|
}
|
|
392
374
|
}
|
|
@@ -454,7 +436,7 @@ var JsonParser = class {
|
|
|
454
436
|
let arr;
|
|
455
437
|
if (canReuse && !usedArr) {
|
|
456
438
|
usedArr = true;
|
|
457
|
-
arr = this
|
|
439
|
+
arr = this.#reusableArr;
|
|
458
440
|
} else {
|
|
459
441
|
arr = [];
|
|
460
442
|
}
|
|
@@ -501,7 +483,7 @@ var JsonParser = class {
|
|
|
501
483
|
return void 0;
|
|
502
484
|
}
|
|
503
485
|
arr[aIdx++] = elem;
|
|
504
|
-
if (aIdx > this
|
|
486
|
+
if (aIdx > this.#budget.maxCollectionSizeSmi && aIdx > this.#budget.limits.maxCollectionSize) return void 0;
|
|
505
487
|
const aSep = bytes[pos];
|
|
506
488
|
if (aSep === 44) {
|
|
507
489
|
pos++;
|
|
@@ -520,7 +502,7 @@ var JsonParser = class {
|
|
|
520
502
|
return void 0;
|
|
521
503
|
}
|
|
522
504
|
count++;
|
|
523
|
-
if (count > this
|
|
505
|
+
if (count > this.#budget.maxCollectionSizeSmi && count > this.#budget.limits.maxCollectionSize) return void 0;
|
|
524
506
|
const kFirst = key.charCodeAt(0);
|
|
525
507
|
if (kFirst >= 48 && kFirst <= 57 || key === "__proto__" || hasCustomKeyOrder(obj)) {
|
|
526
508
|
if (shapeMatch) {
|
|
@@ -532,7 +514,7 @@ var JsonParser = class {
|
|
|
532
514
|
}
|
|
533
515
|
obj = fresh;
|
|
534
516
|
if (canReuse) {
|
|
535
|
-
this
|
|
517
|
+
this.#reusableObj = obj;
|
|
536
518
|
rKeys.length = count - 1;
|
|
537
519
|
rKeys.push(key);
|
|
538
520
|
}
|
|
@@ -556,257 +538,257 @@ var JsonParser = class {
|
|
|
556
538
|
}
|
|
557
539
|
obj = fresh;
|
|
558
540
|
if (canReuse) {
|
|
559
|
-
this
|
|
541
|
+
this.#reusableObj = obj;
|
|
560
542
|
rKeys.length = count;
|
|
561
543
|
}
|
|
562
544
|
}
|
|
563
|
-
if (canReuse) this
|
|
564
|
-
this
|
|
565
|
-
this
|
|
566
|
-
this
|
|
567
|
-
this
|
|
568
|
-
this
|
|
569
|
-
this
|
|
545
|
+
if (canReuse) this.#reusableInUse = true;
|
|
546
|
+
this.#bom = 3;
|
|
547
|
+
this.#offset += byteLen + 1;
|
|
548
|
+
this.#line++;
|
|
549
|
+
this.#column = 0;
|
|
550
|
+
this.#bytes = 0;
|
|
551
|
+
this.#budget.step(count * 3 + 2);
|
|
570
552
|
return obj;
|
|
571
553
|
}
|
|
572
554
|
appendQuotedSpan(span) {
|
|
573
555
|
const len = span.length;
|
|
574
|
-
this
|
|
575
|
-
this
|
|
576
|
-
this
|
|
577
|
-
if (this
|
|
578
|
-
this
|
|
579
|
-
this
|
|
556
|
+
this.#offset += len;
|
|
557
|
+
this.#column += len;
|
|
558
|
+
this.#bytes += len;
|
|
559
|
+
if (this.#bytes > this.#budget.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
|
|
560
|
+
this.#token += span;
|
|
561
|
+
this.#flushStringChunks();
|
|
580
562
|
}
|
|
581
563
|
appendTokenSpan(span) {
|
|
582
|
-
if (this
|
|
564
|
+
if (this.#profile && this.#completedValues) this.#fail("Extra data");
|
|
583
565
|
const len = span.length;
|
|
584
|
-
this
|
|
585
|
-
this
|
|
586
|
-
this
|
|
587
|
-
if (this
|
|
588
|
-
this
|
|
589
|
-
this
|
|
590
|
-
}
|
|
591
|
-
controlToken() {
|
|
592
|
-
if (this
|
|
566
|
+
this.#offset += len;
|
|
567
|
+
this.#column += len;
|
|
568
|
+
this.#bytes += len;
|
|
569
|
+
if (this.#bytes > this.#budget.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
|
|
570
|
+
this.#token += span;
|
|
571
|
+
this.#controlToken();
|
|
572
|
+
}
|
|
573
|
+
#controlToken() {
|
|
574
|
+
if (this.#stringChunks && !this.#chunkedString && this.#token.length > this.#stringChunks.maxControlBytes) {
|
|
593
575
|
throw new RangeError("JSON control token exceeds maxControlBytes");
|
|
594
576
|
}
|
|
595
577
|
}
|
|
596
|
-
flushStringChunks(final = false) {
|
|
597
|
-
if (!this
|
|
598
|
-
this
|
|
578
|
+
#flushStringChunks(final = false) {
|
|
579
|
+
if (!this.#chunkedString) {
|
|
580
|
+
this.#controlToken();
|
|
599
581
|
return;
|
|
600
582
|
}
|
|
601
|
-
if (!final && this
|
|
602
|
-
let end = final ? this
|
|
583
|
+
if (!final && this.#token.length < 4096) return;
|
|
584
|
+
let end = final ? this.#token.length : 0;
|
|
603
585
|
if (!final) {
|
|
604
|
-
for (let offset = 0; offset < this
|
|
605
|
-
const code = this
|
|
586
|
+
for (let offset = 0; offset < this.#token.length; ) {
|
|
587
|
+
const code = this.#token.charCodeAt(offset);
|
|
606
588
|
let count = 1;
|
|
607
589
|
if (code === 92) {
|
|
608
|
-
if (offset + 1 >= this
|
|
609
|
-
count = this
|
|
610
|
-
if (offset + count > this
|
|
590
|
+
if (offset + 1 >= this.#token.length) break;
|
|
591
|
+
count = this.#token[offset + 1] === "u" ? 6 : 2;
|
|
592
|
+
if (offset + count > this.#token.length) break;
|
|
611
593
|
if (count === 6) {
|
|
612
|
-
const point = Number.parseInt(this
|
|
594
|
+
const point = Number.parseInt(this.#token.slice(offset + 2, offset + 6), 16);
|
|
613
595
|
if (point >= 55296 && point <= 56319) count = 12;
|
|
614
596
|
}
|
|
615
597
|
} else if (code >= 194 && code <= 223) count = 2;
|
|
616
598
|
else if (code >= 224 && code <= 239) count = 3;
|
|
617
599
|
else if (code >= 240 && code <= 244) count = 4;
|
|
618
|
-
if (offset + count > this
|
|
600
|
+
if (offset + count > this.#token.length) break;
|
|
619
601
|
offset += count;
|
|
620
602
|
end = offset;
|
|
621
603
|
}
|
|
622
604
|
}
|
|
623
605
|
if (!end && !final) return;
|
|
624
|
-
const tail = this
|
|
625
|
-
this
|
|
626
|
-
const decoded = this
|
|
627
|
-
this
|
|
628
|
-
this
|
|
606
|
+
const tail = this.#token.slice(end);
|
|
607
|
+
this.#token = this.#token.slice(0, end);
|
|
608
|
+
const decoded = this.#string();
|
|
609
|
+
this.#event([this.path(), decoded, final], this.#stringPoints);
|
|
610
|
+
this.#token = tail;
|
|
629
611
|
}
|
|
630
612
|
path() {
|
|
631
613
|
const path = [];
|
|
632
|
-
for (const frame of this
|
|
633
|
-
if (Array.isArray(frame)) path.push(this
|
|
614
|
+
for (const frame of this.#stack) {
|
|
615
|
+
if (Array.isArray(frame)) path.push(this.#counts.get(frame) ?? frame.length);
|
|
634
616
|
else if (typeof frame === "string") path.push(frame);
|
|
635
617
|
}
|
|
636
618
|
return path;
|
|
637
619
|
}
|
|
638
|
-
event(value, points) {
|
|
639
|
-
if (this
|
|
620
|
+
#event(value, points) {
|
|
621
|
+
if (this.#stringChunks?.codePoints && Array.isArray(value)) {
|
|
640
622
|
if (value.length === 1) value.push(null, "end");
|
|
641
623
|
else if (value.length === 2) value.push(null);
|
|
642
|
-
value.push({ key: this
|
|
624
|
+
value.push({ key: this.#keyPoints.get(this.#stack.length - 1) ?? null, points: points ?? null });
|
|
643
625
|
}
|
|
644
|
-
this
|
|
626
|
+
this.#budget.value(value);
|
|
645
627
|
this.events.push(value);
|
|
646
628
|
}
|
|
647
|
-
leaf(value) {
|
|
648
|
-
if (value !== null && typeof value === "object" && this
|
|
649
|
-
this
|
|
629
|
+
#leaf(value) {
|
|
630
|
+
if (value !== null && typeof value === "object" && this.#closed.has(value)) return;
|
|
631
|
+
this.#event([this.path(), value]);
|
|
650
632
|
}
|
|
651
|
-
fail(detail, located = true) {
|
|
652
|
-
throw new JqParseError(detail, this
|
|
633
|
+
#fail(detail, located = true) {
|
|
634
|
+
throw new JqParseError(detail, this.#offset, this.#line, this.#column, located);
|
|
653
635
|
}
|
|
654
|
-
accept(value) {
|
|
655
|
-
this
|
|
656
|
-
if (this
|
|
657
|
-
this
|
|
636
|
+
#accept(value) {
|
|
637
|
+
this.#budget.step();
|
|
638
|
+
if (this.#next !== void 0) this.#fail("Expected separator between values");
|
|
639
|
+
this.#next = value;
|
|
658
640
|
}
|
|
659
|
-
literal(eof = false) {
|
|
660
|
-
if (!this
|
|
661
|
-
const text = this
|
|
641
|
+
#literal(eof = false) {
|
|
642
|
+
if (!this.#token) return;
|
|
643
|
+
const text = this.#token;
|
|
662
644
|
const pattern = text[0] === "t" ? "true" : text[0] === "f" ? "false" : text.startsWith("nu") ? "null" : void 0;
|
|
663
645
|
let value;
|
|
664
646
|
if (pattern) {
|
|
665
|
-
if (text !== pattern) this
|
|
647
|
+
if (text !== pattern) this.#fail("Invalid literal" + (eof ? " at EOF" : ""));
|
|
666
648
|
value = pattern === "true" ? true : pattern === "false" ? false : null;
|
|
667
649
|
} else {
|
|
668
|
-
if (this
|
|
669
|
-
value = numericToken(text, this
|
|
670
|
-
if (this
|
|
671
|
-
if (value === void 0) this
|
|
650
|
+
if (this.#profile && !pythonJsonNumber(text, this.#profile === "python39")) this.#fail("Invalid numeric literal" + (eof ? " at EOF" : ""));
|
|
651
|
+
value = this.#profile === "javascript" ? Number(text) : numericToken(text, this.#budget);
|
|
652
|
+
if (this.#profile && value instanceof Decimal) value = new Decimal(value.digits, value.exponent, value.negative, text, value.double);
|
|
653
|
+
if (value === void 0) this.#fail("Invalid numeric literal" + (eof ? " at EOF" : ""));
|
|
672
654
|
}
|
|
673
|
-
this
|
|
674
|
-
this
|
|
655
|
+
this.#accept(value);
|
|
656
|
+
this.#token = "";
|
|
675
657
|
}
|
|
676
|
-
string() {
|
|
677
|
-
const points = this
|
|
678
|
-
this
|
|
679
|
-
const decoding = this
|
|
658
|
+
#string() {
|
|
659
|
+
const points = this.#stringChunks?.codePoints ? [] : void 0;
|
|
660
|
+
this.#stringPoints = points;
|
|
661
|
+
const decoding = this.#profile === "python39" ? points ? "surrogatepass" : true : this.#profile ?? false;
|
|
680
662
|
let fastAscii = true;
|
|
681
|
-
for (let index = 0; index < this
|
|
682
|
-
const code = this
|
|
663
|
+
for (let index = 0; index < this.#token.length; index++) {
|
|
664
|
+
const code = this.#token.charCodeAt(index);
|
|
683
665
|
if (code === 92 || code < 32 || code >= 128) {
|
|
684
666
|
fastAscii = false;
|
|
685
667
|
break;
|
|
686
668
|
}
|
|
687
669
|
}
|
|
688
670
|
if (fastAscii) {
|
|
689
|
-
const steps = Math.ceil(this
|
|
690
|
-
if (steps > 0) this
|
|
691
|
-
else this
|
|
692
|
-
this
|
|
693
|
-
if (points) for (let i = 0; i < this
|
|
694
|
-
return this
|
|
671
|
+
const steps = Math.ceil(this.#token.length / 1024);
|
|
672
|
+
if (steps > 0) this.#budget.step(steps * 2);
|
|
673
|
+
else this.#budget.signal.throwIfAborted();
|
|
674
|
+
this.#budget.text(this.#token);
|
|
675
|
+
if (points) for (let i = 0; i < this.#token.length; i++) points.push(this.#token.charCodeAt(i));
|
|
676
|
+
return this.#token;
|
|
695
677
|
}
|
|
696
678
|
let result = "";
|
|
697
679
|
let start = 0;
|
|
698
|
-
for (let index = 0; index < this
|
|
699
|
-
if (index % 1024 === 0) this
|
|
700
|
-
const character = this
|
|
680
|
+
for (let index = 0; index < this.#token.length; index++) {
|
|
681
|
+
if (index % 1024 === 0) this.#budget.step();
|
|
682
|
+
const character = this.#token[index];
|
|
701
683
|
if (character === "\\") {
|
|
702
|
-
result += decodeUtf8(this
|
|
703
|
-
const escaped = this
|
|
684
|
+
result += decodeUtf8(this.#token.slice(start, index), this.#budget, decoding, points);
|
|
685
|
+
const escaped = this.#token[++index];
|
|
704
686
|
if (escaped === "u") {
|
|
705
|
-
const digits = this
|
|
706
|
-
if (digits.length < 4) this
|
|
707
|
-
if (!/^[0-9a-f]{4}$/iu.test(digits)) this
|
|
687
|
+
const digits = this.#token.slice(index + 1, index + 5);
|
|
688
|
+
if (digits.length < 4) this.#fail("Invalid \\uXXXX escape");
|
|
689
|
+
if (!/^[0-9a-f]{4}$/iu.test(digits)) this.#fail("Invalid characters in \\uXXXX escape");
|
|
708
690
|
let point = parseInt(digits, 16);
|
|
709
691
|
index += 4;
|
|
710
692
|
if (point >= 55296 && point <= 56319) {
|
|
711
|
-
const tail = this
|
|
693
|
+
const tail = this.#token.slice(index + 1, index + 7);
|
|
712
694
|
const low = /^\\u[0-9a-f]{4}$/iu.test(tail) ? parseInt(tail.slice(2), 16) : 0;
|
|
713
695
|
if (low < 56320 || low > 57343) {
|
|
714
|
-
if (!this
|
|
696
|
+
if (!this.#profile) this.#fail("Invalid \\uXXXX\\uXXXX surrogate pair escape");
|
|
715
697
|
} else {
|
|
716
698
|
point = 65536 + (point - 55296 << 10) + low - 56320;
|
|
717
699
|
index += 6;
|
|
718
700
|
}
|
|
719
701
|
}
|
|
720
702
|
points?.push(point);
|
|
721
|
-
result += String.fromCodePoint(!this
|
|
703
|
+
result += String.fromCodePoint(!this.#profile && point >= 56320 && point <= 57343 ? 65533 : point);
|
|
722
704
|
} else {
|
|
723
705
|
const escapes = { '"': '"', "\\": "\\", "/": "/", b: "\b", f: "\f", n: "\n", r: "\r", t: " " };
|
|
724
|
-
if (escaped === void 0 || !Object.hasOwn(escapes, escaped)) this
|
|
706
|
+
if (escaped === void 0 || !Object.hasOwn(escapes, escaped)) this.#fail("Invalid escape");
|
|
725
707
|
result += escapes[escaped];
|
|
726
708
|
points?.push(escapes[escaped].charCodeAt(0));
|
|
727
709
|
}
|
|
728
710
|
start = index + 1;
|
|
729
|
-
} else if (character.charCodeAt(0) < 32) this
|
|
711
|
+
} else if (character.charCodeAt(0) < 32) this.#fail("Invalid string: control characters from U+0000 through U+001F must be escaped");
|
|
730
712
|
}
|
|
731
|
-
result += decodeUtf8(this
|
|
732
|
-
this
|
|
713
|
+
result += decodeUtf8(this.#token.slice(start), this.#budget, decoding, points);
|
|
714
|
+
this.#budget.text(result);
|
|
733
715
|
return result;
|
|
734
716
|
}
|
|
735
|
-
done() {
|
|
736
|
-
if (this
|
|
737
|
-
if (this
|
|
738
|
-
const value = this
|
|
739
|
-
this
|
|
740
|
-
this
|
|
741
|
-
if (this
|
|
742
|
-
this
|
|
743
|
-
this
|
|
717
|
+
#done() {
|
|
718
|
+
if (this.#stack.length || this.#next === void 0) return void 0;
|
|
719
|
+
if (this.#profile && this.#completedValues++) this.#fail("Extra data");
|
|
720
|
+
const value = this.#next;
|
|
721
|
+
this.#next = void 0;
|
|
722
|
+
this.#budget.value(value);
|
|
723
|
+
if (this.#stream && !this.#chunkedLeaf) this.#leaf(value);
|
|
724
|
+
this.#chunkedLeaf = false;
|
|
725
|
+
this.#bytes = 0;
|
|
744
726
|
return value;
|
|
745
727
|
}
|
|
746
|
-
append() {
|
|
747
|
-
const parent = this
|
|
748
|
-
if (this
|
|
749
|
-
if (!this
|
|
750
|
-
this
|
|
751
|
-
const container = typeof parent === "string" ? this
|
|
752
|
-
const count = (this
|
|
753
|
-
this
|
|
754
|
-
this
|
|
728
|
+
#append() {
|
|
729
|
+
const parent = this.#stack.at(-1);
|
|
730
|
+
if (this.#stream) {
|
|
731
|
+
if (!this.#chunkedLeaf) this.#leaf(this.#next);
|
|
732
|
+
this.#chunkedLeaf = false;
|
|
733
|
+
const container = typeof parent === "string" ? this.#stack.at(-2) : parent;
|
|
734
|
+
const count = (this.#counts.get(container) ?? 0) + 1;
|
|
735
|
+
this.#budget.collection(count);
|
|
736
|
+
this.#counts.set(container, count);
|
|
755
737
|
if (typeof parent === "string") {
|
|
756
|
-
this
|
|
757
|
-
this
|
|
758
|
-
} else if (!Array.isArray(parent)) this
|
|
759
|
-
this
|
|
738
|
+
this.#keyPoints.delete(this.#stack.length - 1);
|
|
739
|
+
this.#stack.pop();
|
|
740
|
+
} else if (!Array.isArray(parent)) this.#fail("Objects must consist of key:value pairs");
|
|
741
|
+
this.#next = void 0;
|
|
760
742
|
return;
|
|
761
743
|
}
|
|
762
744
|
if (Array.isArray(parent)) {
|
|
763
|
-
if (this
|
|
764
|
-
parent.push(this
|
|
745
|
+
if (this.#budget.limits.maxCollectionSize !== Infinity) this.#budget.collection(parent.length + 1);
|
|
746
|
+
parent.push(this.#next);
|
|
765
747
|
} else if (typeof parent === "string") {
|
|
766
|
-
const container = this
|
|
767
|
-
if (this
|
|
768
|
-
this
|
|
748
|
+
const container = this.#stack.at(-2);
|
|
749
|
+
if (this.#budget.limits.maxCollectionSize !== Infinity && !Object.hasOwn(container, parent)) {
|
|
750
|
+
this.#budget.collection(objectSize(container) + 1);
|
|
769
751
|
}
|
|
770
|
-
put(container, parent, this
|
|
771
|
-
this
|
|
772
|
-
} else this
|
|
773
|
-
this
|
|
774
|
-
}
|
|
775
|
-
structure(character) {
|
|
776
|
-
const parent = this
|
|
777
|
-
const closingPath = this
|
|
778
|
-
const closingContainer = typeof parent === "string" ? this
|
|
779
|
-
const closingCount = closingContainer && typeof closingContainer === "object" ? this
|
|
752
|
+
put(container, parent, this.#next);
|
|
753
|
+
this.#stack.pop();
|
|
754
|
+
} else this.#fail("Objects must consist of key:value pairs");
|
|
755
|
+
this.#next = void 0;
|
|
756
|
+
}
|
|
757
|
+
#structure(character) {
|
|
758
|
+
const parent = this.#stack.at(-1);
|
|
759
|
+
const closingPath = this.#stream && (character === "]" || character === "}") ? this.path() : void 0;
|
|
760
|
+
const closingContainer = typeof parent === "string" ? this.#stack.at(-2) : parent;
|
|
761
|
+
const closingCount = closingContainer && typeof closingContainer === "object" ? this.#counts.get(closingContainer) ?? 0 : 0;
|
|
780
762
|
if (character === "[" || character === "{") {
|
|
781
|
-
if (this
|
|
782
|
-
if (++this
|
|
783
|
-
if (this
|
|
784
|
-
this
|
|
763
|
+
if (this.#next !== void 0) this.#fail("Expected separator between values");
|
|
764
|
+
if (++this.#depth > this.#budget.limits.maxDepth) throw new JqLimitError("maxDepth");
|
|
765
|
+
if (this.#stringChunks?.containers) this.#event([this.path(), character, "open"]);
|
|
766
|
+
this.#stack.push(character === "[" ? [] : object());
|
|
785
767
|
} else if (character === ":") {
|
|
786
|
-
if (this
|
|
787
|
-
if (!parent || Array.isArray(parent) || typeof parent === "string") this
|
|
788
|
-
if (typeof this
|
|
789
|
-
if (this
|
|
790
|
-
if (this
|
|
791
|
-
this
|
|
792
|
-
this
|
|
768
|
+
if (this.#next === void 0) this.#fail("Expected string key before ':'");
|
|
769
|
+
if (!parent || Array.isArray(parent) || typeof parent === "string") this.#fail("':' not as part of an object");
|
|
770
|
+
if (typeof this.#next !== "string") this.#fail("Object keys must be strings");
|
|
771
|
+
if (this.#stream) this.#lastKey.set(parent, this.#next);
|
|
772
|
+
if (this.#stringPoints) this.#keyPoints.set(this.#stack.length, this.#stringPoints);
|
|
773
|
+
this.#stack.push(this.#next);
|
|
774
|
+
this.#next = void 0;
|
|
793
775
|
} else if (character === ",") {
|
|
794
|
-
if (this
|
|
795
|
-
if (!this
|
|
796
|
-
this
|
|
776
|
+
if (this.#next === void 0) this.#fail("Expected value before ','");
|
|
777
|
+
if (!this.#stack.length) this.#fail("',' not as part of an object or array");
|
|
778
|
+
this.#append();
|
|
797
779
|
} else if (character === "]") {
|
|
798
|
-
if (!Array.isArray(parent)) this
|
|
799
|
-
if (this
|
|
800
|
-
else if (parent.length || closingCount) this
|
|
801
|
-
this
|
|
802
|
-
this
|
|
780
|
+
if (!Array.isArray(parent)) this.#fail("Unmatched ']'");
|
|
781
|
+
if (this.#next !== void 0) this.#append();
|
|
782
|
+
else if (parent.length || closingCount) this.#fail("Expected another array element");
|
|
783
|
+
this.#next = this.#stack.pop();
|
|
784
|
+
this.#depth--;
|
|
803
785
|
} else if (character === "}") {
|
|
804
|
-
if (!this
|
|
805
|
-
if (this
|
|
806
|
-
if (typeof parent !== "string") this
|
|
807
|
-
this
|
|
786
|
+
if (!this.#stack.length) this.#fail("Unmatched '}'");
|
|
787
|
+
if (this.#next !== void 0) {
|
|
788
|
+
if (typeof parent !== "string") this.#fail("Objects must consist of key:value pairs");
|
|
789
|
+
this.#append();
|
|
808
790
|
} else {
|
|
809
|
-
if (typeof parent === "string" || Array.isArray(parent)) this
|
|
791
|
+
if (typeof parent === "string" || Array.isArray(parent)) this.#fail("Unmatched '}'");
|
|
810
792
|
let hasKey = closingCount > 0;
|
|
811
793
|
if (!hasKey) {
|
|
812
794
|
for (const k in parent) {
|
|
@@ -816,90 +798,90 @@ var JsonParser = class {
|
|
|
816
798
|
}
|
|
817
799
|
}
|
|
818
800
|
}
|
|
819
|
-
if (hasKey) this
|
|
801
|
+
if (hasKey) this.#fail("Expected another key-value pair");
|
|
820
802
|
}
|
|
821
|
-
this
|
|
822
|
-
this
|
|
803
|
+
this.#next = this.#stack.pop();
|
|
804
|
+
this.#depth--;
|
|
823
805
|
}
|
|
824
|
-
if (this
|
|
825
|
-
if (closingPath && this
|
|
826
|
-
if (closingCount || closingContainer && typeof closingContainer === "object" && (this
|
|
827
|
-
if (Array.isArray(closingContainer)) closingPath[closingPath.length - 1] = (this
|
|
828
|
-
else if (typeof parent !== "string") closingPath.push(this
|
|
829
|
-
this
|
|
806
|
+
if (this.#stringChunks?.containers && (character === "]" || character === "}")) this.#event([this.path(), character, "close"]);
|
|
807
|
+
if (closingPath && this.#next !== null && typeof this.#next === "object") {
|
|
808
|
+
if (closingCount || closingContainer && typeof closingContainer === "object" && (this.#counts.get(closingContainer) ?? 0)) {
|
|
809
|
+
if (Array.isArray(closingContainer)) closingPath[closingPath.length - 1] = (this.#counts.get(closingContainer) ?? 1) - 1;
|
|
810
|
+
else if (typeof parent !== "string") closingPath.push(this.#lastKey.get(closingContainer));
|
|
811
|
+
this.#event([closingPath]);
|
|
830
812
|
} else {
|
|
831
813
|
if (Array.isArray(closingContainer)) closingPath.pop();
|
|
832
|
-
this
|
|
814
|
+
this.#event([closingPath, this.#next]);
|
|
833
815
|
}
|
|
834
|
-
this
|
|
816
|
+
this.#closed.add(this.#next);
|
|
835
817
|
}
|
|
836
818
|
}
|
|
837
819
|
feed(character) {
|
|
838
|
-
this
|
|
839
|
-
if (this
|
|
840
|
-
if (character.charCodeAt(0) === [239, 187, 191][this
|
|
841
|
-
this
|
|
820
|
+
this.#offset++;
|
|
821
|
+
if (this.#bom < 3) {
|
|
822
|
+
if (character.charCodeAt(0) === [239, 187, 191][this.#bom]) {
|
|
823
|
+
this.#bom++;
|
|
842
824
|
return void 0;
|
|
843
825
|
}
|
|
844
|
-
if (this
|
|
845
|
-
this
|
|
826
|
+
if (this.#bom) this.#fail("Malformed BOM", false);
|
|
827
|
+
this.#bom = 3;
|
|
846
828
|
}
|
|
847
829
|
if (character === "\n") {
|
|
848
|
-
this
|
|
849
|
-
this
|
|
850
|
-
} else this
|
|
830
|
+
this.#line++;
|
|
831
|
+
this.#column = 0;
|
|
832
|
+
} else this.#column++;
|
|
851
833
|
const space = character === " " || character === " " || character === "\r" || character === "\n";
|
|
852
|
-
if (this
|
|
834
|
+
if (this.#profile && this.#completedValues && !space) this.#fail("Extra data");
|
|
853
835
|
const structure = character === "[" || character === "]" || character === "{" || character === "}" || character === ":" || character === ",";
|
|
854
|
-
const endsScalar = !this
|
|
855
|
-
if (!endsScalar && (this
|
|
856
|
-
if (++this
|
|
836
|
+
const endsScalar = !this.#quoted && !this.#stack.length && this.#token !== "" && (space || structure || character === '"');
|
|
837
|
+
if (!endsScalar && (this.#bytes || !space)) {
|
|
838
|
+
if (++this.#bytes > this.#budget.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
|
|
857
839
|
}
|
|
858
|
-
if (this
|
|
859
|
-
if (character === '"' && !this
|
|
860
|
-
if (this
|
|
861
|
-
this
|
|
862
|
-
this
|
|
863
|
-
this
|
|
864
|
-
this
|
|
865
|
-
} else this
|
|
866
|
-
this
|
|
867
|
-
this
|
|
868
|
-
return this
|
|
840
|
+
if (this.#quoted) {
|
|
841
|
+
if (character === '"' && !this.#escaped) {
|
|
842
|
+
if (this.#chunkedString) {
|
|
843
|
+
this.#flushStringChunks(true);
|
|
844
|
+
this.#accept("");
|
|
845
|
+
this.#chunkedLeaf = true;
|
|
846
|
+
this.#chunkedString = false;
|
|
847
|
+
} else this.#accept(this.#string());
|
|
848
|
+
this.#token = "";
|
|
849
|
+
this.#quoted = false;
|
|
850
|
+
return this.#done();
|
|
869
851
|
}
|
|
870
|
-
this
|
|
871
|
-
this
|
|
872
|
-
this
|
|
852
|
+
this.#token += character;
|
|
853
|
+
this.#escaped = character === "\\" && !this.#escaped;
|
|
854
|
+
this.#flushStringChunks();
|
|
873
855
|
return void 0;
|
|
874
856
|
}
|
|
875
857
|
if (!space && !structure && character !== '"') {
|
|
876
|
-
this
|
|
877
|
-
this
|
|
858
|
+
this.#token += character;
|
|
859
|
+
this.#controlToken();
|
|
878
860
|
return void 0;
|
|
879
861
|
}
|
|
880
|
-
this
|
|
881
|
-
const output = this
|
|
862
|
+
this.#literal();
|
|
863
|
+
const output = this.#done();
|
|
882
864
|
if (character === '"') {
|
|
883
|
-
this
|
|
884
|
-
const parent = this
|
|
885
|
-
this
|
|
886
|
-
} else if (structure) this
|
|
887
|
-
if (output !== void 0 && (this
|
|
888
|
-
return this
|
|
865
|
+
this.#quoted = true;
|
|
866
|
+
const parent = this.#stack.at(-1);
|
|
867
|
+
this.#chunkedString = !!this.#stringChunks && (parent === void 0 || Array.isArray(parent) || typeof parent === "string");
|
|
868
|
+
} else if (structure) this.#structure(character);
|
|
869
|
+
if (output !== void 0 && (this.#quoted || this.#stack.length)) this.#bytes = 1;
|
|
870
|
+
return this.#done() ?? output;
|
|
889
871
|
}
|
|
890
872
|
finish(boundary) {
|
|
891
|
-
if (boundary && !this
|
|
892
|
-
throw new JqParseError(`Potentially truncated top-level numeric value${boundary.eof ? " at EOF" : ""}`, this
|
|
873
|
+
if (boundary && !this.#quoted && !this.#stack.length && this.#token && numericToken(this.#token, this.#budget) !== void 0) {
|
|
874
|
+
throw new JqParseError(`Potentially truncated top-level numeric value${boundary.eof ? " at EOF" : ""}`, this.#offset, boundary.line, boundary.column);
|
|
893
875
|
}
|
|
894
|
-
if (boundary && !boundary.eof && this
|
|
895
|
-
if (boundary && !boundary.eof && (this
|
|
896
|
-
throw new JqParseError("Truncated value", this
|
|
876
|
+
if (boundary && !boundary.eof && this.#stack.length && !this.#quoted && !this.#token) return void 0;
|
|
877
|
+
if (boundary && !boundary.eof && (this.#quoted || this.#token && this.#stack.length)) {
|
|
878
|
+
throw new JqParseError("Truncated value", this.#offset, boundary.line, boundary.column);
|
|
897
879
|
}
|
|
898
|
-
if (this
|
|
899
|
-
this
|
|
900
|
-
if (this
|
|
901
|
-
const result = this
|
|
902
|
-
if (this
|
|
880
|
+
if (this.#quoted) this.#fail("Unfinished string at EOF");
|
|
881
|
+
this.#literal(true);
|
|
882
|
+
if (this.#stack.length) this.#fail("Unfinished JSON term at EOF");
|
|
883
|
+
const result = this.#done();
|
|
884
|
+
if (this.#profile && !this.#completedValues) this.#fail("Expecting value");
|
|
903
885
|
return result;
|
|
904
886
|
}
|
|
905
887
|
};
|
|
@@ -1198,10 +1180,11 @@ function tryProcessFlatJsonChunkSync(rawChunk, budget, onValue, onChunkEnd, hasP
|
|
|
1198
1180
|
}
|
|
1199
1181
|
}
|
|
1200
1182
|
async function* jsonValues(source, budget, options = {}) {
|
|
1183
|
+
const python = options.profile === "python39";
|
|
1201
1184
|
if (options.stringChunks && (!options.stream || !Number.isSafeInteger(options.stringChunks.maxControlBytes) || options.stringChunks.maxControlBytes < 1)) {
|
|
1202
1185
|
throw new RangeError("stringChunks requires stream and a positive maxControlBytes");
|
|
1203
1186
|
}
|
|
1204
|
-
if (options.stringChunks?.codePoints &&
|
|
1187
|
+
if (options.stringChunks?.codePoints && !python) throw new RangeError("codePoints requires python39");
|
|
1205
1188
|
let parser = new JsonParser(budget, options.stream, 1, 0, options.stringChunks, options.profile);
|
|
1206
1189
|
let active = !options.sequence;
|
|
1207
1190
|
let failed = false;
|
|
@@ -1220,7 +1203,7 @@ async function* jsonValues(source, budget, options = {}) {
|
|
|
1220
1203
|
let line = 1;
|
|
1221
1204
|
let column = 0;
|
|
1222
1205
|
let nulTail;
|
|
1223
|
-
const input =
|
|
1206
|
+
const input = python ? pythonJsonBytes(source, budget, options.stringChunks?.codePoints) : source;
|
|
1224
1207
|
const iter = typeof input.tryNextSync === "function" ? input : readBytes2(input, budget.signal)[Symbol.asyncIterator]();
|
|
1225
1208
|
let done = false;
|
|
1226
1209
|
try {
|
|
@@ -1238,7 +1221,7 @@ async function* jsonValues(source, budget, options = {}) {
|
|
|
1238
1221
|
}
|
|
1239
1222
|
const pt = budget.tickSync();
|
|
1240
1223
|
if (pt) await pt;
|
|
1241
|
-
if (!
|
|
1224
|
+
if (!python) budget.inputBytes += rawChunk.byteLength;
|
|
1242
1225
|
if (budget.inputBytes > budget.maxInputBytesSmi && budget.inputBytes > budget.limits.maxInputBytes) throw new JqLimitError("maxInputBytes");
|
|
1243
1226
|
let fullText;
|
|
1244
1227
|
let chunkOffset = 0;
|