@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.
Files changed (155) hide show
  1. package/dist/image-ast/index.js +39 -18
  2. package/dist/pdf-ast/image.js +1 -1
  3. package/dist/pdf-ast/index.js +1 -1
  4. package/dist/pdf-ast/vendor/pdfjs-fonts.mjs +9 -3
  5. package/dist/safe-bash/chunks/{chunk-AGHV53VF.js → chunk-M6XFU6LQ.js} +3 -1
  6. package/dist/safe-bash/chunks/{chunk-363QOIDR.js → chunk-T6FHWSHM.js} +3 -1
  7. package/dist/safe-bash/command-chunks/{chunk-ZPBL7TYJ.js → chunk-2JRHCVMQ.js} +1 -1
  8. package/dist/safe-bash/command-chunks/{chunk-FMGNXOMV.js → chunk-2L3NMRLG.js} +7 -3
  9. package/dist/safe-bash/command-chunks/{chunk-DAQO64WC.js → chunk-2YKOJPIW.js} +1 -1
  10. package/dist/safe-bash/command-chunks/{chunk-EPYJSPOY.js → chunk-3QCW4VQF.js} +12 -8
  11. package/dist/safe-bash/command-chunks/{chunk-YRBFNT5B.js → chunk-3YL2TMLA.js} +10 -1
  12. package/dist/safe-bash/command-chunks/{chunk-5H7ZHP7F.js → chunk-43NDRBKY.js} +1 -1
  13. package/dist/safe-bash/command-chunks/{chunk-BBOYR6LV.js → chunk-46GA576V.js} +3 -3
  14. package/dist/safe-bash/command-chunks/{chunk-WPT2FCHH.js → chunk-4SLPM2WM.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-7ZQVMPSB.js → chunk-5CAXR62E.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-3DTHX5UU.js → chunk-66653AEZ.js} +40 -14
  17. package/dist/safe-bash/command-chunks/{chunk-ETFJ4L7F.js → chunk-6OLE6CLV.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-ZIDESNHW.js → chunk-7M3M6FKC.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-2KMNVJB7.js → chunk-A7PKUIJT.js} +1 -1
  20. package/dist/safe-bash/command-chunks/{chunk-AVSINNZ6.js → chunk-DEQ47SBQ.js} +5 -5
  21. package/dist/safe-bash/command-chunks/{chunk-EV7A5FNN.js → chunk-FFFRLPXU.js} +2 -2
  22. package/dist/safe-bash/command-chunks/{chunk-4MVQE6CT.js → chunk-FYTBEGSY.js} +1 -1
  23. package/dist/safe-bash/command-chunks/{chunk-LFTGMUAV.js → chunk-HQIZR6EU.js} +192 -489
  24. package/dist/safe-bash/command-chunks/chunk-HS2L7I4N.js +219 -0
  25. package/dist/safe-bash/command-chunks/{chunk-WKS2PAZL.js → chunk-HUGKO4ZE.js} +10 -1
  26. package/dist/safe-bash/command-chunks/chunk-IGXH5W5Z.js +111 -0
  27. package/dist/safe-bash/command-chunks/{chunk-CMJBRGU2.js → chunk-IHQZKUBS.js} +1 -1
  28. package/dist/safe-bash/command-chunks/chunk-JADJ4BMN.js +1519 -0
  29. package/dist/safe-bash/command-chunks/{chunk-5AQAWIYK.js → chunk-JEZC5V3B.js} +4 -0
  30. package/dist/safe-bash/command-chunks/{chunk-YB5TNDY6.js → chunk-K5VJ4NNL.js} +39 -5
  31. package/dist/safe-bash/command-chunks/{chunk-7RQGRFHJ.js → chunk-KHWDEAE4.js} +2 -2
  32. package/dist/safe-bash/command-chunks/chunk-L54KVUSY.js +604 -0
  33. package/dist/safe-bash/command-chunks/{chunk-3NJETNC2.js → chunk-MBXNG6C3.js} +2 -2
  34. package/dist/safe-bash/command-chunks/{chunk-HCPEYQKT.js → chunk-N4SH6QY5.js} +285 -302
  35. package/dist/safe-bash/command-chunks/{chunk-3DID6MQY.js → chunk-OWTQYLID.js} +2 -2
  36. package/dist/safe-bash/command-chunks/{chunk-4EA7WI3L.js → chunk-QOOQD6BD.js} +42 -33
  37. package/dist/safe-bash/command-chunks/{chunk-RQTFK7AV.js → chunk-QZYEI4N6.js} +1 -1
  38. package/dist/safe-bash/command-chunks/{chunk-R3SLT3ZX.js → chunk-R6GON4H3.js} +11 -1
  39. package/dist/safe-bash/command-chunks/{chunk-2GILUQJY.js → chunk-R7ZGDHME.js} +3 -3
  40. package/dist/safe-bash/command-chunks/{chunk-HNEWGADJ.js → chunk-RUXOFW5G.js} +7 -6
  41. package/dist/safe-bash/command-chunks/{chunk-LKAFLJ5L.js → chunk-RWQKX44L.js} +1 -1
  42. package/dist/safe-bash/command-chunks/{chunk-PKH57OIC.js → chunk-SG2KOOD4.js} +2 -2
  43. package/dist/safe-bash/command-chunks/chunk-T4TGJYFV.js +60 -0
  44. package/dist/safe-bash/command-chunks/chunk-TGSNVLFZ.js +105 -0
  45. package/dist/safe-bash/command-chunks/{chunk-NXCJNPL3.js → chunk-UCE77LYV.js} +2 -1
  46. package/dist/safe-bash/command-chunks/{chunk-EWECMOQ5.js → chunk-UIHPHIKI.js} +1 -1
  47. package/dist/safe-bash/command-chunks/{chunk-XSZNL3GV.js → chunk-UJPWPRVB.js} +191 -146
  48. package/dist/safe-bash/command-chunks/{chunk-E5CDHXFA.js → chunk-VOR6YDZC.js} +26 -1
  49. package/dist/safe-bash/command-chunks/chunk-VSNVYOK2.js +30 -0
  50. package/dist/safe-bash/command-chunks/{chunk-4XYGJB24.js → chunk-VTH4AORO.js} +3 -3
  51. package/dist/safe-bash/command-chunks/{chunk-W5LH7D23.js → chunk-WKKJJBJQ.js} +8 -8
  52. package/dist/safe-bash/command-chunks/{chunk-OLXMWQJ5.js → chunk-WRO3PB2M.js} +1 -1
  53. package/dist/safe-bash/command-chunks/{chunk-RUAGHZNF.js → chunk-X5ODTF3E.js} +7 -5
  54. package/dist/safe-bash/command-chunks/{chunk-LH4VBNF6.js → chunk-XGTSP2CP.js} +84 -16
  55. package/dist/safe-bash/command-chunks/{chunk-K576GZED.js → chunk-XTHKXCF2.js} +2 -2
  56. package/dist/safe-bash/command-chunks/{chunk-J3VS55K4.js → chunk-YHRESVJ7.js} +9 -3
  57. package/dist/safe-bash/command-chunks/{chunk-UWIDPTOB.js → chunk-YSCKOUQP.js} +1 -1
  58. package/dist/safe-bash/command-chunks/{chunk-UYNJF5QN.js → chunk-ZALAWNOE.js} +76 -122
  59. package/dist/safe-bash/command-chunks/{chunk-OT75C5YS.js → chunk-ZYXKW2K7.js} +1 -1
  60. package/dist/safe-bash/command-chunks/{pdf-renderer-346WYKSZ.js → pdf-renderer-5QWOVFA4.js} +1 -1
  61. package/dist/safe-bash/command-chunks/{prompt-tool-debug-3POFNRYP.js → prompt-tool-debug-G7ATE7D5.js} +6 -4
  62. package/dist/safe-bash/commands/llm/index.browser.js +5 -1
  63. package/dist/safe-bash/commands/llm/index.js +1 -1
  64. package/dist/safe-bash/commands/python/executor.browser.js +3 -1
  65. package/dist/safe-bash/commands/python/executor.js +1 -1
  66. package/dist/safe-bash/commands/python/index.browser.js +5 -1
  67. package/dist/safe-bash/commands/python/index.js +1 -1
  68. package/dist/safe-bash/core.browser.js +2 -2
  69. package/dist/safe-bash/full-core.browser.js +10 -2
  70. package/dist/safe-bash-command-awk/awk-runtime.js +2 -2
  71. package/dist/safe-bash-command-awk/awk-syntax.js +1 -1
  72. package/dist/safe-bash-command-awk/awk.js +3 -3
  73. package/dist/safe-bash-command-awk/index.js +3 -3
  74. package/dist/safe-bash-command-gpg/index.js +11 -3
  75. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  76. package/dist/safe-bash-command-llm/collections.js +6 -4
  77. package/dist/safe-bash-command-llm/command.js +4 -4
  78. package/dist/safe-bash-command-llm/import-json-document.d.ts +9 -2
  79. package/dist/safe-bash-command-llm/index.d.ts +2 -1
  80. package/dist/safe-bash-command-llm/index.js +10 -4
  81. package/dist/safe-bash-command-llm/loader-provider.d.ts +5 -0
  82. package/dist/safe-bash-command-mcp/index.js +10 -13
  83. package/dist/safe-bash-command-pdftoppm/index.js +2 -2
  84. package/dist/safe-bash-command-playwright-cli/index.js +2 -2
  85. package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.d.ts +1 -0
  86. package/dist/safe-bash-command-playwright-cli/playwright/ability-execution.js +1 -1
  87. package/dist/safe-bash-command-playwright-cli/playwright/controller.d.ts +2 -0
  88. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +2 -2
  89. package/dist/safe-bash-command-playwright-cli/playwright/index.js +2 -2
  90. package/dist/safe-bash-command-python/build-backend.d.ts +2 -0
  91. package/dist/safe-bash-command-python/cache.d.ts +1 -1
  92. package/dist/safe-bash-command-python/executor.d.ts +5 -2
  93. package/dist/safe-bash-command-python/executor.js +11 -6
  94. package/dist/safe-bash-command-python/host-capabilities.js +1 -1
  95. package/dist/safe-bash-command-python/index.js +11 -6
  96. package/dist/safe-bash-command-python/jspi.js +5 -3
  97. package/dist/safe-bash-command-python/manifest-file.d.ts +44 -0
  98. package/dist/safe-bash-command-python/manifest.d.ts +45 -0
  99. package/dist/safe-bash-command-python/provisioning.d.ts +20 -1
  100. package/dist/safe-bash-command-python/provisioning.js +3 -2
  101. package/dist/safe-bash-command-python/reply.js +7 -11
  102. package/dist/safe-bash-command-python/source-archive.js +2 -2
  103. package/dist/safe-bash-command-python/source-zip.js +2 -2
  104. package/dist/safe-bash-command-python/worker.js +34 -21
  105. package/dist/safe-bash-command-sqlite3/engine.d.ts +4 -0
  106. package/dist/safe-bash-command-sqlite3/index.js +174 -18
  107. package/dist/safe-bash-command-svgo/index.js +1 -1
  108. package/dist/safe-bash-command-tar/create.js +3 -3
  109. package/dist/safe-bash-command-tar/extract.js +3 -3
  110. package/dist/safe-bash-command-tar/index.js +5 -5
  111. package/dist/safe-bash-command-tar/modes.js +5 -5
  112. package/dist/safe-bash-command-tar/options.d.ts +1 -1
  113. package/dist/safe-bash-command-tar/options.js +1 -1
  114. package/dist/safe-bash-command-tar/stream.js +1 -1
  115. package/dist/safe-bash-command-wkhtmltopdf/index.js +1 -1
  116. package/dist/safe-bash-command-xan/argv.js +1 -1
  117. package/dist/safe-bash-command-xan/commands.js +3 -3
  118. package/dist/safe-bash-command-xan/index.js +3 -3
  119. package/dist/safe-bash-command-xan/io.js +2 -2
  120. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  121. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  122. package/dist/safe-bash-compression-engine/files.js +6 -6
  123. package/dist/safe-bash-compression-engine/index.js +5 -5
  124. package/dist/safe-bash-compression-engine/operand.js +6 -6
  125. package/dist/safe-bash-compression-engine/options.js +1 -1
  126. package/dist/safe-bash-compression-engine/stream.js +5 -5
  127. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  128. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  129. package/dist/safe-bash-contracts/filesystem-output.js +1 -1
  130. package/dist/safe-bash-csv-engine/index.js +6 -6
  131. package/dist/safe-bash-csv-engine/python-codec-aliases.js +1 -1
  132. package/dist/safe-bash-csv-engine/python-codepages.js +3 -3
  133. package/dist/safe-bash-csv-engine/python-file-codepages.js +2 -2
  134. package/dist/safe-bash-csv-engine/python-utf16.js +4 -4
  135. package/dist/safe-bash-csv-engine/text-decoder.js +6 -6
  136. package/dist/safe-bash-graphviz-engine/index.js +1 -1
  137. package/dist/safe-bash-pager-engine/index.js +2 -2
  138. package/dist/safe-bash-query-engine/capture.js +3 -3
  139. package/dist/safe-bash-query-engine/delpaths.js +3 -3
  140. package/dist/safe-bash-query-engine/formats.js +2 -2
  141. package/dist/safe-bash-query-engine/index.js +10 -10
  142. package/dist/safe-bash-query-engine/indices.js +3 -3
  143. package/dist/safe-bash-query-engine/input.d.ts +3 -3
  144. package/dist/safe-bash-query-engine/input.js +1 -1
  145. package/dist/safe-bash-query-engine/interpreter.js +9 -9
  146. package/dist/safe-bash-query-engine/query-core.js +10 -10
  147. package/dist/safe-bash-query-engine/regex.js +4 -4
  148. package/dist/safe-bash-query-engine/splits.js +5 -5
  149. package/dist/safe-bash-query-engine/values.js +2 -2
  150. package/package.json +2 -2
  151. package/dist/safe-bash/command-chunks/chunk-OOYVZAWL.js +0 -90
  152. package/dist/safe-bash/command-chunks/chunk-RZOHZGEZ.js +0 -772
  153. package/dist/safe-bash/command-chunks/chunk-WIUEM7HP.js +0 -58
  154. package/dist/safe-bash/command-chunks/chunk-WY6THI6J.js +0 -673
  155. 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
- if (text === "NaN" || text === "Infinity" || text === "-Infinity") return true;
240
- let index = text[0] === "-" ? 1 : 0;
241
- const digit = (offset) => {
242
- const code = text.charCodeAt(offset);
243
- return code >= 48 && code <= 57;
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
- constructor(budget, stream = false, line = 1, column = 0, stringChunks, profile) {
265
- this.budget = budget;
266
- this.stream = stream;
267
- this.stringChunks = stringChunks;
268
- this.profile = profile;
269
- this.line = line;
270
- this.column = column;
271
- if (profile) this.bom = 3;
272
- }
273
- budget;
274
- stream;
275
- stringChunks;
276
- profile;
277
- stack = [];
278
- next;
279
- token = "";
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._counts ??= /* @__PURE__ */ new WeakMap();
299
- }
300
- get closed() {
301
- return this._closed ??= /* @__PURE__ */ new WeakSet();
302
- }
303
- get lastKey() {
304
- return this._lastKey ??= /* @__PURE__ */ new WeakMap();
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.reusableObj);
312
- invalidateCachedValueMetrics(this.reusableArr);
313
- this.reusableInUse = false;
293
+ invalidateCachedValueMetrics(this.#reusableObj);
294
+ invalidateCachedValueMetrics(this.#reusableArr);
295
+ this.#reusableInUse = false;
314
296
  }
315
297
  isQuotedUnescaped() {
316
- return this.quoted && !this.escaped && this.bom >= 3;
298
+ return this.#quoted && !this.#escaped && this.#bom >= 3;
317
299
  }
318
300
  isUnquotedReady() {
319
- return !this.quoted && this.bom >= 3;
301
+ return !this.#quoted && this.#bom >= 3;
320
302
  }
321
303
  isTopLevelIdle() {
322
- return !this.quoted && !this.escaped && this.stack.length === 0 && this.token === "" && this.next === void 0 && !this.stream;
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.budget.maxValueBytesSmi && byteLen > this.budget.limits.maxValueBytes) return void 0;
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.budget.maxDepthSmi < 1) return void 0;
329
- const canReuse = !this.reusableInUse;
330
- let obj = canReuse ? this.reusableObj : object();
331
- const rKeys = this.reusableKeys;
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.reusableObj = obj;
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.reusableObj = obj;
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.reusableArr;
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.budget.maxCollectionSizeSmi && aIdx > this.budget.limits.maxCollectionSize) return void 0;
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.budget.maxCollectionSizeSmi && count > this.budget.limits.maxCollectionSize) return void 0;
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.reusableObj = obj;
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.reusableObj = obj;
541
+ this.#reusableObj = obj;
560
542
  rKeys.length = count;
561
543
  }
562
544
  }
563
- if (canReuse) this.reusableInUse = true;
564
- this.bom = 3;
565
- this.offset += byteLen + 1;
566
- this.line++;
567
- this.column = 0;
568
- this.bytes = 0;
569
- this.budget.step(count * 3 + 2);
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.offset += len;
575
- this.column += len;
576
- this.bytes += len;
577
- if (this.bytes > this.budget.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
578
- this.token += span;
579
- this.flushStringChunks();
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.profile && this.completedValues) this.fail("Extra data");
564
+ if (this.#profile && this.#completedValues) this.#fail("Extra data");
583
565
  const len = span.length;
584
- this.offset += len;
585
- this.column += len;
586
- this.bytes += len;
587
- if (this.bytes > this.budget.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
588
- this.token += span;
589
- this.controlToken();
590
- }
591
- controlToken() {
592
- if (this.stringChunks && !this.chunkedString && this.token.length > this.stringChunks.maxControlBytes) {
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.chunkedString) {
598
- this.controlToken();
578
+ #flushStringChunks(final = false) {
579
+ if (!this.#chunkedString) {
580
+ this.#controlToken();
599
581
  return;
600
582
  }
601
- if (!final && this.token.length < 4096) return;
602
- let end = final ? this.token.length : 0;
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.token.length; ) {
605
- const code = this.token.charCodeAt(offset);
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.token.length) break;
609
- count = this.token[offset + 1] === "u" ? 6 : 2;
610
- if (offset + count > this.token.length) break;
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.token.slice(offset + 2, offset + 6), 16);
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.token.length) break;
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.token.slice(end);
625
- this.token = this.token.slice(0, end);
626
- const decoded = this.string();
627
- this.event([this.path(), decoded, final], this.stringPoints);
628
- this.token = tail;
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.stack) {
633
- if (Array.isArray(frame)) path.push(this.counts.get(frame) ?? frame.length);
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.stringChunks?.codePoints && Array.isArray(value)) {
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.keyPoints.get(this.stack.length - 1) ?? null, points: points ?? null });
624
+ value.push({ key: this.#keyPoints.get(this.#stack.length - 1) ?? null, points: points ?? null });
643
625
  }
644
- this.budget.value(value);
626
+ this.#budget.value(value);
645
627
  this.events.push(value);
646
628
  }
647
- leaf(value) {
648
- if (value !== null && typeof value === "object" && this.closed.has(value)) return;
649
- this.event([this.path(), value]);
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.offset, this.line, this.column, located);
633
+ #fail(detail, located = true) {
634
+ throw new JqParseError(detail, this.#offset, this.#line, this.#column, located);
653
635
  }
654
- accept(value) {
655
- this.budget.step();
656
- if (this.next !== void 0) this.fail("Expected separator between values");
657
- this.next = value;
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.token) return;
661
- const text = this.token;
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.fail("Invalid literal" + (eof ? " at EOF" : ""));
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.profile && !pythonJsonNumber(text)) this.fail("Invalid numeric literal" + (eof ? " at EOF" : ""));
669
- value = numericToken(text, this.budget);
670
- if (this.profile && value instanceof Decimal) value = new Decimal(value.digits, value.exponent, value.negative, text, value.double);
671
- if (value === void 0) this.fail("Invalid numeric literal" + (eof ? " at EOF" : ""));
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.accept(value);
674
- this.token = "";
655
+ this.#accept(value);
656
+ this.#token = "";
675
657
  }
676
- string() {
677
- const points = this.stringChunks?.codePoints ? [] : void 0;
678
- this.stringPoints = points;
679
- const decoding = this.profile === "python39" ? points ? "surrogatepass" : true : false;
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.token.length; index++) {
682
- const code = this.token.charCodeAt(index);
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.token.length / 1024);
690
- if (steps > 0) this.budget.step(steps * 2);
691
- else this.budget.signal.throwIfAborted();
692
- this.budget.text(this.token);
693
- if (points) for (let i = 0; i < this.token.length; i++) points.push(this.token.charCodeAt(i));
694
- return this.token;
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.token.length; index++) {
699
- if (index % 1024 === 0) this.budget.step();
700
- const character = this.token[index];
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.token.slice(start, index), this.budget, decoding, points);
703
- const escaped = this.token[++index];
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.token.slice(index + 1, index + 5);
706
- if (digits.length < 4) this.fail("Invalid \\uXXXX escape");
707
- if (!/^[0-9a-f]{4}$/iu.test(digits)) this.fail("Invalid characters in \\uXXXX escape");
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.token.slice(index + 1, index + 7);
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.profile) this.fail("Invalid \\uXXXX\\uXXXX surrogate pair escape");
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.profile && point >= 56320 && point <= 57343 ? 65533 : point);
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.fail("Invalid escape");
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.fail("Invalid string: control characters from U+0000 through U+001F must be escaped");
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.token.slice(start), this.budget, decoding, points);
732
- this.budget.text(result);
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.stack.length || this.next === void 0) return void 0;
737
- if (this.profile && this.completedValues++) this.fail("Extra data");
738
- const value = this.next;
739
- this.next = void 0;
740
- this.budget.value(value);
741
- if (this.stream && !this.chunkedLeaf) this.leaf(value);
742
- this.chunkedLeaf = false;
743
- this.bytes = 0;
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.stack.at(-1);
748
- if (this.stream) {
749
- if (!this.chunkedLeaf) this.leaf(this.next);
750
- this.chunkedLeaf = false;
751
- const container = typeof parent === "string" ? this.stack.at(-2) : parent;
752
- const count = (this.counts.get(container) ?? 0) + 1;
753
- this.budget.collection(count);
754
- this.counts.set(container, count);
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.keyPoints.delete(this.stack.length - 1);
757
- this.stack.pop();
758
- } else if (!Array.isArray(parent)) this.fail("Objects must consist of key:value pairs");
759
- this.next = void 0;
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.budget.limits.maxCollectionSize !== Infinity) this.budget.collection(parent.length + 1);
764
- parent.push(this.next);
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.stack.at(-2);
767
- if (this.budget.limits.maxCollectionSize !== Infinity && !Object.hasOwn(container, parent)) {
768
- this.budget.collection(objectSize(container) + 1);
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.next);
771
- this.stack.pop();
772
- } else this.fail("Objects must consist of key:value pairs");
773
- this.next = void 0;
774
- }
775
- structure(character) {
776
- const parent = this.stack.at(-1);
777
- const closingPath = this.stream && (character === "]" || character === "}") ? this.path() : void 0;
778
- const closingContainer = typeof parent === "string" ? this.stack.at(-2) : parent;
779
- const closingCount = closingContainer && typeof closingContainer === "object" ? this.counts.get(closingContainer) ?? 0 : 0;
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.next !== void 0) this.fail("Expected separator between values");
782
- if (++this.depth > this.budget.limits.maxDepth) throw new JqLimitError("maxDepth");
783
- if (this.stringChunks?.containers) this.event([this.path(), character, "open"]);
784
- this.stack.push(character === "[" ? [] : object());
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.next === void 0) this.fail("Expected string key before ':'");
787
- if (!parent || Array.isArray(parent) || typeof parent === "string") this.fail("':' not as part of an object");
788
- if (typeof this.next !== "string") this.fail("Object keys must be strings");
789
- if (this.stream) this.lastKey.set(parent, this.next);
790
- if (this.stringPoints) this.keyPoints.set(this.stack.length, this.stringPoints);
791
- this.stack.push(this.next);
792
- this.next = void 0;
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.next === void 0) this.fail("Expected value before ','");
795
- if (!this.stack.length) this.fail("',' not as part of an object or array");
796
- this.append();
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.fail("Unmatched ']'");
799
- if (this.next !== void 0) this.append();
800
- else if (parent.length || closingCount) this.fail("Expected another array element");
801
- this.next = this.stack.pop();
802
- this.depth--;
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.stack.length) this.fail("Unmatched '}'");
805
- if (this.next !== void 0) {
806
- if (typeof parent !== "string") this.fail("Objects must consist of key:value pairs");
807
- this.append();
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.fail("Unmatched '}'");
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.fail("Expected another key-value pair");
801
+ if (hasKey) this.#fail("Expected another key-value pair");
820
802
  }
821
- this.next = this.stack.pop();
822
- this.depth--;
803
+ this.#next = this.#stack.pop();
804
+ this.#depth--;
823
805
  }
824
- if (this.stringChunks?.containers && (character === "]" || character === "}")) this.event([this.path(), character, "close"]);
825
- if (closingPath && this.next !== null && typeof this.next === "object") {
826
- if (closingCount || closingContainer && typeof closingContainer === "object" && (this.counts.get(closingContainer) ?? 0)) {
827
- if (Array.isArray(closingContainer)) closingPath[closingPath.length - 1] = (this.counts.get(closingContainer) ?? 1) - 1;
828
- else if (typeof parent !== "string") closingPath.push(this.lastKey.get(closingContainer));
829
- this.event([closingPath]);
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.event([closingPath, this.next]);
814
+ this.#event([closingPath, this.#next]);
833
815
  }
834
- this.closed.add(this.next);
816
+ this.#closed.add(this.#next);
835
817
  }
836
818
  }
837
819
  feed(character) {
838
- this.offset++;
839
- if (this.bom < 3) {
840
- if (character.charCodeAt(0) === [239, 187, 191][this.bom]) {
841
- this.bom++;
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.bom) this.fail("Malformed BOM", false);
845
- this.bom = 3;
826
+ if (this.#bom) this.#fail("Malformed BOM", false);
827
+ this.#bom = 3;
846
828
  }
847
829
  if (character === "\n") {
848
- this.line++;
849
- this.column = 0;
850
- } else this.column++;
830
+ this.#line++;
831
+ this.#column = 0;
832
+ } else this.#column++;
851
833
  const space = character === " " || character === " " || character === "\r" || character === "\n";
852
- if (this.profile && this.completedValues && !space) this.fail("Extra data");
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.quoted && !this.stack.length && this.token !== "" && (space || structure || character === '"');
855
- if (!endsScalar && (this.bytes || !space)) {
856
- if (++this.bytes > this.budget.limits.maxValueBytes) throw new JqLimitError("maxValueBytes");
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.quoted) {
859
- if (character === '"' && !this.escaped) {
860
- if (this.chunkedString) {
861
- this.flushStringChunks(true);
862
- this.accept("");
863
- this.chunkedLeaf = true;
864
- this.chunkedString = false;
865
- } else this.accept(this.string());
866
- this.token = "";
867
- this.quoted = false;
868
- return this.done();
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.token += character;
871
- this.escaped = character === "\\" && !this.escaped;
872
- this.flushStringChunks();
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.token += character;
877
- this.controlToken();
858
+ this.#token += character;
859
+ this.#controlToken();
878
860
  return void 0;
879
861
  }
880
- this.literal();
881
- const output = this.done();
862
+ this.#literal();
863
+ const output = this.#done();
882
864
  if (character === '"') {
883
- this.quoted = true;
884
- const parent = this.stack.at(-1);
885
- this.chunkedString = !!this.stringChunks && (parent === void 0 || Array.isArray(parent) || typeof parent === "string");
886
- } else if (structure) this.structure(character);
887
- if (output !== void 0 && (this.quoted || this.stack.length)) this.bytes = 1;
888
- return this.done() ?? output;
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.quoted && !this.stack.length && this.token && numericToken(this.token, this.budget) !== void 0) {
892
- throw new JqParseError(`Potentially truncated top-level numeric value${boundary.eof ? " at EOF" : ""}`, this.offset, boundary.line, boundary.column);
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.stack.length && !this.quoted && !this.token) return void 0;
895
- if (boundary && !boundary.eof && (this.quoted || this.token && this.stack.length)) {
896
- throw new JqParseError("Truncated value", this.offset, boundary.line, boundary.column);
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.quoted) this.fail("Unfinished string at EOF");
899
- this.literal(true);
900
- if (this.stack.length) this.fail("Unfinished JSON term at EOF");
901
- const result = this.done();
902
- if (this.profile && !this.completedValues) this.fail("Expecting value");
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 && options.profile !== "python39") throw new RangeError("codePoints requires python39");
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 = options.profile ? pythonJsonBytes(source, budget, options.stringChunks?.codePoints) : source;
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 (!options.profile) budget.inputBytes += rawChunk.byteLength;
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;