@sentropic/h2a 0.97.11 → 0.97.12

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 (108) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/dist/cli-command-map.d.ts.map +1 -1
  4. package/dist/cli-command-map.js +2 -1
  5. package/dist/cli-command-map.js.map +1 -1
  6. package/dist/index.d.ts +2 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/runtime/identity/readers.d.ts.map +1 -1
  11. package/dist/runtime/identity/readers.js +25 -2
  12. package/dist/runtime/identity/readers.js.map +1 -1
  13. package/dist/runtime/local-files/succession-lock.d.ts +105 -17
  14. package/dist/runtime/local-files/succession-lock.d.ts.map +1 -1
  15. package/dist/runtime/local-files/succession-lock.js +320 -108
  16. package/dist/runtime/local-files/succession-lock.js.map +1 -1
  17. package/dist/runtime/mcp/agent-launch.d.ts +6 -3
  18. package/dist/runtime/mcp/agent-launch.d.ts.map +1 -1
  19. package/dist/runtime/mcp/agent-launch.js +146 -4
  20. package/dist/runtime/mcp/agent-launch.js.map +1 -1
  21. package/dist/runtime/mcp/server.d.ts +1 -1
  22. package/dist/runtime/mcp/server.d.ts.map +1 -1
  23. package/dist/runtime/mcp/server.js +3 -3
  24. package/dist/runtime/mcp/server.js.map +1 -1
  25. package/dist/runtime/mcp/stdio.d.ts.map +1 -1
  26. package/dist/runtime/mcp/stdio.js +16 -9
  27. package/dist/runtime/mcp/stdio.js.map +1 -1
  28. package/dist/runtime/mcp/tools.js +1 -1
  29. package/dist/runtime/mcp/tools.js.map +1 -1
  30. package/dist/runtime/mcp-central.js +2 -2
  31. package/dist/runtime/mcp-central.js.map +1 -1
  32. package/dist/runtime/upgrade/index.d.ts +5 -5
  33. package/dist/runtime/upgrade/index.d.ts.map +1 -1
  34. package/dist/runtime/upgrade/index.js +16 -13
  35. package/dist/runtime/upgrade/index.js.map +1 -1
  36. package/focus-app/client/_app/immutable/chunks/dIB57M75.js +2 -0
  37. package/focus-app/client/_app/immutable/chunks/dIB57M75.js.br +0 -0
  38. package/focus-app/client/_app/immutable/chunks/dIB57M75.js.gz +0 -0
  39. package/focus-app/client/_app/immutable/entry/{app.D_yfk55R.js → app.TWAh2blR.js} +2 -2
  40. package/focus-app/client/_app/immutable/entry/app.TWAh2blR.js.br +0 -0
  41. package/focus-app/client/_app/immutable/entry/app.TWAh2blR.js.gz +0 -0
  42. package/focus-app/client/_app/immutable/entry/start.CIDL5k-O.js +1 -0
  43. package/focus-app/client/_app/immutable/entry/start.CIDL5k-O.js.br +2 -0
  44. package/focus-app/client/_app/immutable/entry/start.CIDL5k-O.js.gz +0 -0
  45. package/focus-app/client/_app/immutable/nodes/{1.Jo1uWTw0.js → 1.B_iSEKRr.js} +1 -1
  46. package/focus-app/client/_app/immutable/nodes/1.B_iSEKRr.js.br +1 -0
  47. package/focus-app/client/_app/immutable/nodes/1.B_iSEKRr.js.gz +0 -0
  48. package/focus-app/client/_app/version.json +1 -1
  49. package/focus-app/client/_app/version.json.br +0 -0
  50. package/focus-app/client/_app/version.json.gz +0 -0
  51. package/focus-app/h2a-focus.json +61 -61
  52. package/focus-app/handler.js +8 -8
  53. package/focus-app/index.js +8 -8
  54. package/focus-app/server/chunks/chunks/{AppShell.js-BoWxjmfr.js → AppShell.js-DT15_EBV.js} +2 -2
  55. package/focus-app/server/chunks/chunks/{AppShell.js-BoWxjmfr.js.map → AppShell.js-DT15_EBV.js.map} +1 -1
  56. package/focus-app/server/chunks/chunks/{exports.js-D45A8dcc.js → exports.js-BrfiJlPR.js} +3 -3
  57. package/focus-app/server/chunks/chunks/{exports.js-D45A8dcc.js.map → exports.js-BrfiJlPR.js.map} +1 -1
  58. package/focus-app/server/chunks/chunks/{index.js-e3L5MwfB.js → index.js-BY6_68Zf.js} +2 -2
  59. package/focus-app/server/chunks/chunks/{index.js-e3L5MwfB.js.map → index.js-BY6_68Zf.js.map} +1 -1
  60. package/focus-app/server/chunks/chunks/{internal.js-DAV-A6NO.js → internal.js-_1TPywBu.js} +3 -3
  61. package/focus-app/server/chunks/chunks/{internal.js-DAV-A6NO.js.map → internal.js-_1TPywBu.js.map} +1 -1
  62. package/focus-app/server/chunks/chunks/{root.js-CEypm32A.js → root.js-CZyc7gzj.js} +2 -2
  63. package/focus-app/server/chunks/chunks/{root.js-CEypm32A.js.map → root.js-CZyc7gzj.js.map} +1 -1
  64. package/focus-app/server/chunks/chunks/{utils.js-Bzpr6vQU.js → utils.js-DBwpgn00.js} +178 -51
  65. package/focus-app/server/chunks/chunks/utils.js-DBwpgn00.js.map +1 -0
  66. package/focus-app/server/chunks/entries/endpoints/api/actions/launch/{_server.ts.js-Cah_Ivgw.js → _server.ts.js-H2iyKDJx.js} +2 -2
  67. package/focus-app/server/chunks/entries/endpoints/api/actions/launch/{_server.ts.js-Cah_Ivgw.js.map → _server.ts.js-H2iyKDJx.js.map} +1 -1
  68. package/focus-app/server/chunks/entries/endpoints/api/decisions/inject/{_server.ts.js-DW5wvcgH.js → _server.ts.js-BuR515Qd.js} +2 -2
  69. package/focus-app/server/chunks/entries/endpoints/api/decisions/inject/{_server.ts.js-DW5wvcgH.js.map → _server.ts.js-BuR515Qd.js.map} +1 -1
  70. package/focus-app/server/chunks/entries/endpoints/api/dossiers/agent-memory/include/{_server.ts.js-C2jIx8Jr.js → _server.ts.js-Cs32vOYa.js} +2 -2
  71. package/focus-app/server/chunks/entries/endpoints/api/dossiers/agent-memory/include/{_server.ts.js-C2jIx8Jr.js.map → _server.ts.js-Cs32vOYa.js.map} +1 -1
  72. package/focus-app/server/chunks/entries/endpoints/api/h2a/targets/{_server.ts.js-BkAMLcHu.js → _server.ts.js-DbEqL92p.js} +2 -2
  73. package/focus-app/server/chunks/entries/endpoints/api/h2a/targets/{_server.ts.js-BkAMLcHu.js.map → _server.ts.js-DbEqL92p.js.map} +1 -1
  74. package/focus-app/server/chunks/entries/fallbacks/{error.svelte.js-BWuS92Wk.js → error.svelte.js-BzO57FOz.js} +5 -5
  75. package/focus-app/server/chunks/entries/fallbacks/{error.svelte.js-BWuS92Wk.js.map → error.svelte.js-BzO57FOz.js.map} +1 -1
  76. package/focus-app/server/chunks/entries/pages/{_layout.svelte.js-CKspI0Bw.js → _layout.svelte.js-BHXu1zZ0.js} +3 -3
  77. package/focus-app/server/chunks/entries/pages/{_layout.svelte.js-CKspI0Bw.js.map → _layout.svelte.js-BHXu1zZ0.js.map} +1 -1
  78. package/focus-app/server/chunks/entries/pages/{_page.svelte.js-B8EWZmZj.js → _page.svelte.js-DgcoCR_G.js} +4 -4
  79. package/focus-app/server/chunks/entries/pages/{_page.svelte.js-B8EWZmZj.js.map → _page.svelte.js-DgcoCR_G.js.map} +1 -1
  80. package/focus-app/server/chunks/entries/pages/dossier/agent-memory/{_page.svelte.js-BZvcKeya.js → _page.svelte.js-D8qUTYi2.js} +4 -4
  81. package/focus-app/server/chunks/entries/pages/dossier/agent-memory/{_page.svelte.js-BZvcKeya.js.map → _page.svelte.js-D8qUTYi2.js.map} +1 -1
  82. package/focus-app/server/chunks/{handler-BCBpURX0.js → handler-CdaCXhHn.js} +4 -4
  83. package/focus-app/server/chunks/{handler-BCBpURX0.js.map → handler-CdaCXhHn.js.map} +1 -1
  84. package/focus-app/server/chunks/{index.js-CZWB6FqQ.js → index.js-XG_2L2nP.js} +5 -5
  85. package/focus-app/server/chunks/{index.js-CZWB6FqQ.js.map → index.js-XG_2L2nP.js.map} +1 -1
  86. package/focus-app/server/chunks/{manifest.js-C2CyTiUe.js → manifest.js-SPNxHAN5.js} +10 -10
  87. package/focus-app/server/chunks/{manifest.js-C2CyTiUe.js.map → manifest.js-SPNxHAN5.js.map} +1 -1
  88. package/focus-app/server/chunks/nodes/{0.js-Cp9RMJ1x.js → 0.js-DyONiS9Y.js} +2 -2
  89. package/focus-app/server/chunks/nodes/{0.js-Cp9RMJ1x.js.map → 0.js-DyONiS9Y.js.map} +1 -1
  90. package/focus-app/server/chunks/nodes/1.js-DgrMPNBg.js +9 -0
  91. package/focus-app/server/chunks/nodes/{1.js-DMWmTj0d.js.map → 1.js-DgrMPNBg.js.map} +1 -1
  92. package/focus-app/server/chunks/nodes/{2.js-Dv8Q6LQc.js → 2.js-C16ONuI7.js} +2 -2
  93. package/focus-app/server/chunks/nodes/{2.js-Dv8Q6LQc.js.map → 2.js-C16ONuI7.js.map} +1 -1
  94. package/focus-app/server/chunks/nodes/{3.js-DJH-zOae.js → 3.js-DIZzznQP.js} +2 -2
  95. package/focus-app/server/chunks/nodes/{3.js-DJH-zOae.js.map → 3.js-DIZzznQP.js.map} +1 -1
  96. package/package.json +3 -3
  97. package/focus-app/client/_app/immutable/chunks/BgBtu3IQ.js +0 -2
  98. package/focus-app/client/_app/immutable/chunks/BgBtu3IQ.js.br +0 -0
  99. package/focus-app/client/_app/immutable/chunks/BgBtu3IQ.js.gz +0 -0
  100. package/focus-app/client/_app/immutable/entry/app.D_yfk55R.js.br +0 -0
  101. package/focus-app/client/_app/immutable/entry/app.D_yfk55R.js.gz +0 -0
  102. package/focus-app/client/_app/immutable/entry/start.CoQWYNTs.js +0 -1
  103. package/focus-app/client/_app/immutable/entry/start.CoQWYNTs.js.br +0 -2
  104. package/focus-app/client/_app/immutable/entry/start.CoQWYNTs.js.gz +0 -0
  105. package/focus-app/client/_app/immutable/nodes/1.Jo1uWTw0.js.br +0 -4
  106. package/focus-app/client/_app/immutable/nodes/1.Jo1uWTw0.js.gz +0 -0
  107. package/focus-app/server/chunks/chunks/utils.js-Bzpr6vQU.js.map +0 -1
  108. package/focus-app/server/chunks/nodes/1.js-DMWmTj0d.js +0 -9
@@ -403,6 +403,11 @@ function get_type(thing) {
403
403
  return Object.prototype.toString.call(thing).slice(8, -1);
404
404
  }
405
405
 
406
+ /** @param {any} thing */
407
+ function is_buffer(thing) {
408
+ return typeof Buffer !== 'undefined' && Buffer.isBuffer(thing);
409
+ }
410
+
406
411
  /** @param {string} char */
407
412
  function get_escaped_char(char) {
408
413
  switch (char) {
@@ -516,6 +521,10 @@ function valid_array_indices(array) {
516
521
  }
517
522
 
518
523
  const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
524
+ // Short strings have bounded escaping/output costs per reference, so they cannot
525
+ // cause quadratic expansion. Keep them on the original fast path rather than
526
+ // paying for deduplication on common values such as names, IDs and status fields.
527
+ const MIN_STRING_LENGTH = 128;
519
528
  const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
520
529
  const reserved =
521
530
  /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
@@ -533,6 +542,28 @@ function uneval(value, replacer) {
533
542
 
534
543
  const custom = new Map();
535
544
 
545
+ // Only allocate a literal cache when we need to reuse an expensive primitive,
546
+ // including long Map keys rendered in error paths during the walk.
547
+ /** @type {Map<string | bigint, string> | undefined} */
548
+ let primitives;
549
+
550
+ /** @param {any} thing */
551
+ function stringify_cached_primitive(thing) {
552
+ if (
553
+ (typeof thing === 'string' && thing.length >= MIN_STRING_LENGTH) ||
554
+ typeof thing === 'bigint'
555
+ ) {
556
+ primitives ??= new Map();
557
+ let literal = primitives.get(thing);
558
+ if (literal === undefined) {
559
+ literal = stringify_primitive$1(thing);
560
+ primitives.set(thing, literal);
561
+ }
562
+ return literal;
563
+ }
564
+ return stringify_primitive$1(thing);
565
+ }
566
+
536
567
  /** @param {any} thing */
537
568
  function walk(thing) {
538
569
  if (!is_primitive(thing)) {
@@ -559,9 +590,12 @@ function uneval(value, replacer) {
559
590
  const type = get_type(thing);
560
591
 
561
592
  switch (type) {
562
- case 'Number':
563
593
  case 'BigInt':
564
594
  case 'String':
595
+ walk(thing.valueOf());
596
+ return;
597
+
598
+ case 'Number':
565
599
  case 'Boolean':
566
600
  case 'Date':
567
601
  case 'RegExp':
@@ -570,11 +604,14 @@ function uneval(value, replacer) {
570
604
  return;
571
605
 
572
606
  case 'Array':
573
- /** @type {any[]} */ (thing).forEach((value, i) => {
607
+ // forEach scans the logical length of dictionary-backed sparse
608
+ // arrays. Visit own enumerable indices without doing work for
609
+ // every hole.
610
+ for (const i of valid_array_indices(thing)) {
574
611
  keys.push(`[${i}]`);
575
- walk(value);
612
+ walk(thing[i]);
576
613
  keys.pop();
577
- });
614
+ }
578
615
  break;
579
616
 
580
617
  case 'Set':
@@ -583,7 +620,7 @@ function uneval(value, replacer) {
583
620
 
584
621
  case 'Map':
585
622
  for (const [key, value] of thing) {
586
- keys.push(`.get(${is_primitive(key) ? stringify_primitive$1(key) : '...'})`);
623
+ keys.push(`.get(${is_primitive(key) ? stringify_cached_primitive(key) : '...'})`);
587
624
  walk(key);
588
625
  walk(value);
589
626
  keys.pop();
@@ -603,7 +640,9 @@ function uneval(value, replacer) {
603
640
  case 'BigInt64Array':
604
641
  case 'BigUint64Array':
605
642
  case 'DataView':
606
- walk(thing.buffer);
643
+ // A Node Buffer's backing store may be a shared pool. It must
644
+ // never be visited or hoisted just because a Buffer uses it.
645
+ if (!is_buffer(thing)) walk(thing.buffer);
607
646
  return;
608
647
 
609
648
  case 'ArrayBuffer':
@@ -645,6 +684,11 @@ function uneval(value, replacer) {
645
684
  }
646
685
  } else if (typeof thing === 'symbol') {
647
686
  throw new DevalueError(`Cannot stringify a Symbol primitive`, keys, thing, value);
687
+ } else if (
688
+ (typeof thing === 'string' && thing.length >= MIN_STRING_LENGTH) ||
689
+ typeof thing === 'bigint'
690
+ ) {
691
+ counts.set(thing, (counts.get(thing) || 0) + 1);
648
692
  }
649
693
  }
650
694
 
@@ -652,11 +696,27 @@ function uneval(value, replacer) {
652
696
 
653
697
  const names = new Map();
654
698
 
655
- Array.from(counts)
656
- .filter((entry) => entry[1] > 1)
699
+ /** @type {Array<[any, number]>} */
700
+ const repeated = [];
701
+ // Avoid allocating entries for all the values that will never be hoisted.
702
+ counts.forEach((count, thing) => {
703
+ if (count > 1) repeated.push([thing, count]);
704
+ });
705
+
706
+ repeated
657
707
  .sort((a, b) => b[1] - a[1])
658
- .forEach((entry, i) => {
659
- names.set(entry[0], get_name(i));
708
+ .forEach(([thing, count]) => {
709
+ const name = get_name(names.size);
710
+
711
+ if (is_primitive(thing)) {
712
+ const length = stringify_cached_primitive(thing).length;
713
+ // Hoisting costs one literal, a parameter and a reference per occurrence.
714
+ // Allow for the IIFE wrapper and separators even if one already exists,
715
+ // so inexpensive repetitions stay inline.
716
+ if (length * count <= length + (count + 1) * name.length + 25) return;
717
+ }
718
+
719
+ names.set(thing, name);
660
720
  });
661
721
 
662
722
  /**
@@ -702,10 +762,10 @@ function uneval(value, replacer) {
702
762
 
703
763
  case 'Array': {
704
764
  // For dense arrays (no holes), we iterate normally.
705
- // When we encounter the first hole, we call Object.keys
765
+ // When we encounter the first hole, we collect own indices
706
766
  // to determine the sparseness, then decide between:
707
767
  // - Array literal with holes: [,"a",,] (default)
708
- // - Object.assign: Object.assign(Array(n),{...}) (for very sparse arrays)
768
+ // - Object.assign with a sparse-safe allocator (for very sparse arrays)
709
769
  // Only the Object.assign path avoids iterating every slot, which
710
770
  // is what protects against the DoS of e.g. `arr[1000000] = 1`.
711
771
  let has_holes = false;
@@ -726,10 +786,11 @@ function uneval(value, replacer) {
726
786
  //
727
787
  // Object.assign: populated indices are listed explicitly.
728
788
  // For example, [, "a", ,] would be written as
729
- // Object.assign(Array(3),{1:"a"}). This avoids paying
730
- // per-hole, but has a large fixed overhead for the
731
- // "Object.assign(Array(n),{...})" wrapper, and each
732
- // element costs extra chars for its index and colon.
789
+ // Object.assign(sparse(3),{1:"a"}), where sparse(n) stands
790
+ // for the expression emitted by stringify_sparse_array(n).
791
+ // This avoids paying per-hole, but has a large fixed
792
+ // overhead for the allocator and Object.assign wrapper,
793
+ // and each element costs extra chars for its index and colon.
733
794
  //
734
795
  // The serialized values are the same size either way, so
735
796
  // the choice comes down to the structural overhead:
@@ -740,30 +801,32 @@ function uneval(value, replacer) {
740
801
  // = L + 2
741
802
  //
742
803
  // Object.assign overhead:
743
- // "Object.assign(Array(" — 20 chars
744
- // + length — d chars
745
- // + "),{" — 3 chars
804
+ // "Object.assign(" — 14 chars
805
+ // + allocator expression — A chars
806
+ // + ",{" — 2 chars
746
807
  // + for each populated element:
747
- // index + ":" + "," — (d + 2) chars
748
- // + "})" — 2 chars
749
- // = (25 + d) + P * (d + 2)
808
+ // index + ":" + "," — (d + 2) chars
809
+ // + "})" — 2 chars
810
+ // = (18 + A) + P * (d + 2)
750
811
  //
751
812
  // where L is the array length, P is the number of
752
- // populated elements, and d is the number of digits
753
- // in L (an upper bound on the digits in any index).
813
+ // populated elements, A is the allocator expression's
814
+ // length, and d is the number of digits in L (an upper
815
+ // bound on the digits in any index).
754
816
  //
755
817
  // Object.assign is cheaper when:
756
- // (25 + d) + P * (d + 2) < L + 2
757
- const populated_keys = valid_array_indices(/** @type {any[]} */ (thing));
818
+ // (18 + A) + P * (d + 2) < L + 2
819
+ const populated_keys = valid_array_indices(thing);
758
820
  const population = populated_keys.length;
759
821
  const d = String(thing.length).length;
822
+ const array = stringify_sparse_array(thing.length);
760
823
 
761
824
  const hole_cost = thing.length + 2;
762
- const sparse_cost = 25 + d + population * (d + 2);
825
+ const sparse_cost = array.length + 18 + population * (d + 2);
763
826
 
764
827
  if (hole_cost > sparse_cost) {
765
828
  const entries = populated_keys.map((k) => `${k}:${stringify(thing[k])}`).join(',');
766
- return `Object.assign(Array(${thing.length}),{${entries}})`;
829
+ return `Object.assign(${array},{${entries}})`;
767
830
  }
768
831
 
769
832
  has_holes = true;
@@ -772,7 +835,7 @@ function uneval(value, replacer) {
772
835
  // (the comma separator is all we need — no content for this position)
773
836
  }
774
837
 
775
- const tail = thing.length === 0 || thing.length - 1 in thing ? '' : ',';
838
+ const tail = thing.length === 0 || Object.hasOwn(thing, thing.length - 1) ? '' : ',';
776
839
  return result + tail + ']';
777
840
  }
778
841
 
@@ -792,6 +855,8 @@ function uneval(value, replacer) {
792
855
  case 'Float64Array':
793
856
  case 'BigInt64Array':
794
857
  case 'BigUint64Array': {
858
+ if (is_buffer(thing)) thing = new Uint8Array(thing);
859
+
795
860
  let str = `new ${type}`;
796
861
 
797
862
  if (!names.has(thing.buffer)) {
@@ -882,7 +947,7 @@ function uneval(value, replacer) {
882
947
  }
883
948
 
884
949
  if (is_primitive(thing)) {
885
- values.push(stringify_primitive$1(thing));
950
+ values.push(stringify_cached_primitive(thing));
886
951
  return;
887
952
  }
888
953
 
@@ -892,9 +957,18 @@ function uneval(value, replacer) {
892
957
  case 'Number':
893
958
  case 'String':
894
959
  case 'Boolean':
895
- case 'BigInt':
896
- values.push(`Object(${stringify(thing.valueOf())})`);
960
+ case 'BigInt': {
961
+ const primitive = thing.valueOf();
962
+ if (names.has(primitive)) {
963
+ // A hoisted primitive is only in scope inside the IIFE, not in
964
+ // its arguments. Reconstruct the box before assigning references.
965
+ values.push('{}');
966
+ reconstructions.push(`${name}=Object(${stringify(primitive)})`);
967
+ } else {
968
+ values.push(`Object(${stringify(primitive)})`);
969
+ }
897
970
  break;
971
+ }
898
972
 
899
973
  case 'RegExp':
900
974
  const { source, flags } = thing;
@@ -916,12 +990,20 @@ function uneval(value, replacer) {
916
990
  values.push(`new URLSearchParams(${stringify_string(thing.toString())})`);
917
991
  break;
918
992
 
919
- case 'Array':
920
- values.push(`Array(${thing.length})`);
921
- /** @type {any[]} */ (thing).forEach((v, i) => {
922
- statements.push(`${name}[${i}]=${stringify(v)}`);
923
- });
993
+ case 'Array': {
994
+ const populated_keys = valid_array_indices(thing);
995
+ // Only preallocate when the length is bounded by the number
996
+ // of populated elements, plus a small constant for short arrays.
997
+ values.push(
998
+ thing.length > 32 + 2 * populated_keys.length
999
+ ? stringify_sparse_array(thing.length)
1000
+ : `Array(${thing.length})`
1001
+ );
1002
+ for (const i of populated_keys) {
1003
+ statements.push(`${name}[${i}]=${stringify(thing[i])}`);
1004
+ }
924
1005
  break;
1006
+ }
925
1007
 
926
1008
  case 'Set': {
927
1009
  values.push(`new Set`);
@@ -953,6 +1035,8 @@ function uneval(value, replacer) {
953
1035
  case 'Float64Array':
954
1036
  case 'BigInt64Array':
955
1037
  case 'BigUint64Array': {
1038
+ if (is_buffer(thing)) thing = new Uint8Array(thing);
1039
+
956
1040
  let str = `new ${type}`;
957
1041
 
958
1042
  if (!names.has(thing.buffer)) {
@@ -1034,6 +1118,17 @@ function uneval(value, replacer) {
1034
1118
  }
1035
1119
  }
1036
1120
 
1121
+ /**
1122
+ * Emit an array whose storage is not proportional to its declared length.
1123
+ * As in the default parse operations, touching and deleting the largest valid
1124
+ * index forces V8 into dictionary-elements mode before setting the length.
1125
+ * Merely starting with [] and assigning .length still eagerly allocates.
1126
+ * @param {number} length
1127
+ */
1128
+ function stringify_sparse_array(length) {
1129
+ return `(function(a){a[${MAX_ARRAY_INDEX}]=0;delete a[${MAX_ARRAY_INDEX}];a.length=${length};return a}([]))`;
1130
+ }
1131
+
1037
1132
  /**
1038
1133
  * Serialize the elements of `buffer`, read as `type`, as a comma-separated list.
1039
1134
  * The view is created from `type` rather than from the serialized value's own
@@ -1187,10 +1282,10 @@ function merge_operations(defaults, overrides) {
1187
1282
  }
1188
1283
 
1189
1284
  /** @type {{ kind: 'not-plain' }} */
1190
- const NOT_PLAIN = Object.freeze({ kind: 'not-plain' });
1285
+ const NOT_PLAIN = /* @__PURE__ */ Object.freeze({ kind: 'not-plain' });
1191
1286
 
1192
1287
  /** @type {{ kind: 'symbol-keys' }} */
1193
- const SYMBOL_KEYS = Object.freeze({ kind: 'symbol-keys' });
1288
+ const SYMBOL_KEYS = /* @__PURE__ */ Object.freeze({ kind: 'symbol-keys' });
1194
1289
 
1195
1290
  /**
1196
1291
  * The default implementations of every introspection/extraction operation
@@ -1233,13 +1328,19 @@ const stringify_operations = {
1233
1328
 
1234
1329
  entriesOf: (map) => map,
1235
1330
 
1236
- viewInfo: (view) => ({
1237
- buffer: view.buffer,
1238
- byteOffset: view.byteOffset,
1239
- byteLength: view.byteLength,
1240
- length: view.length,
1241
- bufferByteLength: view.buffer.byteLength
1242
- }),
1331
+ viewInfo: (view) => {
1332
+ // Node Buffers may share a pool containing unrelated, sensitive data.
1333
+ // Copy only the visible bytes, without using Buffer's pooling or slice.
1334
+ if (is_buffer(view)) view = new Uint8Array(view);
1335
+
1336
+ return {
1337
+ buffer: view.buffer,
1338
+ byteOffset: view.byteOffset,
1339
+ byteLength: view.byteLength,
1340
+ length: view.length,
1341
+ bufferByteLength: view.buffer.byteLength
1342
+ };
1343
+ },
1243
1344
 
1244
1345
  toArrayBuffer: (buffer) => buffer,
1245
1346
 
@@ -1262,7 +1363,17 @@ const stringify_operations = {
1262
1363
  get: (value, key) => value[key]
1263
1364
  };
1264
1365
 
1265
- const default_stringify_operations = Object.freeze(stringify_operations);
1366
+ const default_stringify_operations = /* @__PURE__ */ Object.freeze(stringify_operations);
1367
+
1368
+ const array_buffer_byte_length = Object.getOwnPropertyDescriptor(
1369
+ ArrayBuffer.prototype,
1370
+ 'byteLength'
1371
+ ).get;
1372
+
1373
+ const shared_array_buffer_byte_length =
1374
+ typeof SharedArrayBuffer === 'undefined'
1375
+ ? undefined
1376
+ : Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, 'byteLength').get;
1266
1377
 
1267
1378
  /**
1268
1379
  * The default implementations of every construction operation `parse` and
@@ -1298,6 +1409,17 @@ const parse_operations = {
1298
1409
  fromRegExpInfo: (source, flags) => new RegExp(source, flags),
1299
1410
 
1300
1411
  fromViewInfo: (tag, buffer, byteOffset, length) => {
1412
+ // A reviver can replace an ArrayBuffer with a length or array-like value,
1413
+ // which a typed array constructor would use to allocate a new buffer.
1414
+ // The native getters check internal slots, so they work across realms
1415
+ // and cannot be fooled by a forged prototype or Symbol.toStringTag.
1416
+ try {
1417
+ array_buffer_byte_length.call(buffer);
1418
+ } catch (error) {
1419
+ if (!shared_array_buffer_byte_length) throw error;
1420
+ shared_array_buffer_byte_length.call(buffer);
1421
+ }
1422
+
1301
1423
  const Constructor = /** @type {any} */ (globalThis)[tag];
1302
1424
  return byteOffset !== undefined
1303
1425
  ? new Constructor(buffer, byteOffset, length)
@@ -1347,7 +1469,7 @@ const parse_operations = {
1347
1469
  }
1348
1470
  };
1349
1471
 
1350
- const default_parse_operations = Object.freeze(parse_operations);
1472
+ const default_parse_operations = /* @__PURE__ */ Object.freeze(parse_operations);
1351
1473
 
1352
1474
  /**
1353
1475
  * Revive a value serialized with `devalue.stringify`
@@ -1496,11 +1618,16 @@ function unflatten(parsed, revivers, options) {
1496
1618
  const obj = ops.createNullPrototypeObject();
1497
1619
  hydrated[index] = obj;
1498
1620
  for (let i = 1; i < value.length; i += 2) {
1499
- if (value[i] === '__proto__') {
1621
+ const key = value[i];
1622
+ if (typeof key !== 'string') {
1623
+ throw new Error('Cannot parse an object with a non-string key');
1624
+ }
1625
+
1626
+ if (key === '__proto__') {
1500
1627
  throw new Error('Cannot parse an object with a `__proto__` property');
1501
1628
  }
1502
1629
 
1503
- ops.set(obj, value[i], hydrate(value[i + 1]));
1630
+ ops.set(obj, key, hydrate(value[i + 1]));
1504
1631
  }
1505
1632
  break;
1506
1633
 
@@ -2807,4 +2934,4 @@ function create_replacer(transport) {
2807
2934
  }
2808
2935
 
2809
2936
  export { escape_html as A, create_remote_key as B, error as C, parse_remote_arg as D, ENDPOINT_METHODS as E, deserialize_binary_form as F, stringify as G, HttpError as H, INVALIDATED_PARAM as I, stringify$1 as J, ActionFailure as K, split_remote_key as L, SVELTE_KIT_ASSETS as M, splitCookiesString as N, PAGE_METHODS as P, Redirect as R, SvelteKitError as S, TRAILING_SLASH_PARAM as T, handle_fatal_error as a, negotiate as b, method_not_allowed as c, handle_error_and_jsonify as d, get_status as e, format_server_error as f, get_set_cookies as g, has_prerendered_path as h, is_form_content_type as i, json as j, get_global_name as k, create_replacer as l, merge_tracing as m, noop as n, serialize_uses as o, parseString as p, clarify_devalue_error as q, redirect_response as r, static_error_page as s, text as t, uneval as u, once as v, with_request_store as w, normalize_error as x, get_node_type as y, isRedirect as z };
2810
- //# sourceMappingURL=utils.js-Bzpr6vQU.js.map
2937
+ //# sourceMappingURL=utils.js-DBwpgn00.js.map