react-server-dom-parcel 19.1.9 → 19.1.10

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.
@@ -43,6 +43,10 @@ channel.port1.onmessage = function () {
43
43
  var task = taskQueue.shift();
44
44
  task && task();
45
45
  };
46
+ var supportsArrayBufferDetached = hasOwnProperty.call(
47
+ ArrayBuffer.prototype,
48
+ "detached"
49
+ );
46
50
  function scheduleWork(callback) {
47
51
  taskQueue.push(callback);
48
52
  channel.port2.postMessage(null);
@@ -64,28 +68,30 @@ var LocalPromise = Promise,
64
68
  currentView = null,
65
69
  writtenBytes = 0;
66
70
  function writeChunkAndReturn(destination, chunk) {
67
- if (0 !== chunk.byteLength)
68
- if (2048 < chunk.byteLength)
69
- 0 < writtenBytes &&
70
- (destination.enqueue(
71
- new Uint8Array(currentView.buffer, 0, writtenBytes)
72
- ),
73
- (currentView = new Uint8Array(2048)),
74
- (writtenBytes = 0)),
75
- destination.enqueue(chunk);
76
- else {
77
- var allowableBytes = currentView.length - writtenBytes;
78
- allowableBytes < chunk.byteLength &&
79
- (0 === allowableBytes
80
- ? destination.enqueue(currentView)
81
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
82
- destination.enqueue(currentView),
83
- (chunk = chunk.subarray(allowableBytes))),
84
- (currentView = new Uint8Array(2048)),
85
- (writtenBytes = 0));
86
- currentView.set(chunk, writtenBytes);
87
- writtenBytes += chunk.byteLength;
88
- }
71
+ if (0 === chunk.byteLength) {
72
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
73
+ throw Error(
74
+ "Cannot transport a detached buffer. This usually happens when trying to transport multiple buffer-spanning views on the same underyling buffer. Either reuse the exact same view by identity or copy the underlying buffer manually via `view.slice()`."
75
+ );
76
+ } else if (2048 < chunk.byteLength)
77
+ 0 < writtenBytes &&
78
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
79
+ (currentView = new Uint8Array(2048)),
80
+ (writtenBytes = 0)),
81
+ destination.enqueue(chunk);
82
+ else {
83
+ var allowableBytes = currentView.length - writtenBytes;
84
+ allowableBytes < chunk.byteLength &&
85
+ (0 === allowableBytes
86
+ ? destination.enqueue(currentView)
87
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
88
+ destination.enqueue(currentView),
89
+ (chunk = chunk.subarray(allowableBytes))),
90
+ (currentView = new Uint8Array(2048)),
91
+ (writtenBytes = 0));
92
+ currentView.set(chunk, writtenBytes);
93
+ writtenBytes += chunk.byteLength;
94
+ }
89
95
  return !0;
90
96
  }
91
97
  var textEncoder = new TextEncoder();
@@ -1519,14 +1525,30 @@ function emitModelChunk(request, id, json) {
1519
1525
  }
1520
1526
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1521
1527
  request.pendingChunks++;
1522
- var buffer = new Uint8Array(
1523
- typedArray.buffer,
1524
- typedArray.byteOffset,
1525
- typedArray.byteLength
1526
- );
1527
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1528
- buffer = typedArray.byteLength;
1529
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1528
+ a: {
1529
+ var view = new Uint8Array(
1530
+ typedArray.buffer,
1531
+ typedArray.byteOffset,
1532
+ typedArray.byteLength
1533
+ );
1534
+ if (2048 < typedArray.byteLength) {
1535
+ if (
1536
+ 0 !== typedArray.byteOffset ||
1537
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1538
+ typedArray.buffer.resizable
1539
+ ) {
1540
+ typedArray = view.slice();
1541
+ break a;
1542
+ }
1543
+ if (!supportsArrayBufferDetached) {
1544
+ typedArray = view.slice();
1545
+ break a;
1546
+ }
1547
+ }
1548
+ typedArray = view;
1549
+ }
1550
+ view = typedArray.byteLength;
1551
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1530
1552
  id = stringToChunk(id);
1531
1553
  request.completedRegularChunks.push(id, typedArray);
1532
1554
  }
@@ -1778,6 +1800,38 @@ function abort(request, reason) {
1778
1800
  logRecoverableError(request, error$26, null), fatalError(request, error$26);
1779
1801
  }
1780
1802
  }
1803
+ function appendBackingEntry(backingStore, value, key) {
1804
+ var prefix = backingStore.prefix;
1805
+ if (key.startsWith(prefix)) {
1806
+ switch (key[prefix.length]) {
1807
+ case "_":
1808
+ prefix = backingStore.referencedEntries;
1809
+ null === prefix && (prefix = backingStore.referencedEntries = []);
1810
+ prefix.push([key, value]);
1811
+ return;
1812
+ case "S":
1813
+ "string" === typeof value &&
1814
+ ((prefix = backingStore.streamChunks),
1815
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
1816
+ (backingStore = prefix.get(key)),
1817
+ void 0 === backingStore
1818
+ ? prefix.set(key, [value])
1819
+ : backingStore.push(value));
1820
+ return;
1821
+ }
1822
+ "string" === typeof value
1823
+ ? ((prefix = backingStore.stringChunks),
1824
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
1825
+ prefix.set(key, value))
1826
+ : ((prefix = backingStore.blobs),
1827
+ null === prefix && (prefix = backingStore.blobs = new Map()),
1828
+ prefix.set(key, value));
1829
+ }
1830
+ }
1831
+ function getBackingBlob(backingStore, key) {
1832
+ backingStore = backingStore.blobs;
1833
+ return null === backingStore ? void 0 : backingStore.get(key);
1834
+ }
1781
1835
  var RESPONSE_SYMBOL = Symbol();
1782
1836
  function ReactPromise(status, value, reason) {
1783
1837
  this.status = status;
@@ -2149,15 +2203,18 @@ function reportGlobalError(response, error) {
2149
2203
  function getChunk(response, id) {
2150
2204
  var chunks = response._chunks,
2151
2205
  chunk = chunks.get(id);
2152
- chunk ||
2153
- ((chunk = response._formData.data.get(response._prefix + id)),
2154
- (chunk =
2206
+ if (!chunk) {
2207
+ chunk = response._prefix;
2208
+ var stringChunks = response._formData.stringChunks;
2209
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2210
+ chunk =
2155
2211
  "string" === typeof chunk
2156
2212
  ? createResolvedModelChunk(response, chunk, id)
2157
2213
  : response._closed
2158
2214
  ? new ReactPromise("rejected", null, response._closedReason)
2159
- : new ReactPromise("pending", null, null)),
2160
- chunks.set(id, chunk));
2215
+ : new ReactPromise("pending", null, null);
2216
+ chunks.set(id, chunk);
2217
+ }
2161
2218
  return chunk;
2162
2219
  }
2163
2220
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2388,7 +2445,7 @@ function parseTypedArray(
2388
2445
  Error("Already initialized typed array.")
2389
2446
  )
2390
2447
  );
2391
- reference = response._formData.data.get(key).arrayBuffer();
2448
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2392
2449
  if (initializingHandler) {
2393
2450
  var handler = initializingHandler;
2394
2451
  handler.deps++;
@@ -2432,13 +2489,15 @@ function resolveStream(response, id, stream, controller) {
2432
2489
  var chunks = response._chunks;
2433
2490
  stream = new ReactPromise("fulfilled", stream, controller);
2434
2491
  chunks.set(id, stream);
2435
- response = response._formData.data.getAll(response._prefix + id);
2436
- for (id = 0; id < response.length; id++)
2437
- (chunks = response[id]),
2438
- "string" === typeof chunks &&
2439
- ("C" === chunks[0]
2492
+ chunks = response._prefix;
2493
+ response = response._formData.streamChunks;
2494
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2495
+ if (void 0 !== id)
2496
+ for (response = 0; response < id.length; response++)
2497
+ (chunks = id[response]),
2498
+ "C" === chunks[0]
2440
2499
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2441
- : controller.enqueueModel(chunks));
2500
+ : controller.enqueueModel(chunks);
2442
2501
  }
2443
2502
  function parseReadableStream(response, reference, type) {
2444
2503
  function enqueue(value) {
@@ -2604,7 +2663,14 @@ function parseAsyncIterable(response, reference, iterator) {
2604
2663
  });
2605
2664
  return iterator;
2606
2665
  }
2607
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2666
+ function parseModelString(
2667
+ response,
2668
+ obj,
2669
+ key$jscomp$0,
2670
+ value,
2671
+ reference,
2672
+ arrayRoot
2673
+ ) {
2608
2674
  if ("$" === value[0]) {
2609
2675
  switch (value[1]) {
2610
2676
  case "$":
@@ -2622,7 +2688,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2622
2688
  response,
2623
2689
  arrayRoot,
2624
2690
  obj,
2625
- key,
2691
+ key$jscomp$0,
2626
2692
  null,
2627
2693
  loadServerReference$1
2628
2694
  )
@@ -2639,43 +2705,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2639
2705
  case "Q":
2640
2706
  return (
2641
2707
  (arrayRoot = value.slice(2)),
2642
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2708
+ getOutlinedModel(
2709
+ response,
2710
+ arrayRoot,
2711
+ obj,
2712
+ key$jscomp$0,
2713
+ null,
2714
+ createMap
2715
+ )
2643
2716
  );
2644
2717
  case "W":
2645
2718
  return (
2646
2719
  (arrayRoot = value.slice(2)),
2647
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2720
+ getOutlinedModel(
2721
+ response,
2722
+ arrayRoot,
2723
+ obj,
2724
+ key$jscomp$0,
2725
+ null,
2726
+ createSet
2727
+ )
2648
2728
  );
2649
2729
  case "K":
2650
- key = value.slice(2);
2651
- obj = response._prefix + "_";
2652
- key = obj + key + "_";
2653
- arrayRoot = new FormData();
2654
- for (response = response._formData; ; ) {
2655
- value = response.keys;
2656
- null === value &&
2657
- ((value = response.keys = Array.from(response.data.keys())),
2658
- (response.keyPointer = 0));
2659
- value = value[response.keyPointer];
2660
- if (void 0 === value) break;
2661
- if (value.startsWith(key)) {
2662
- reference = response.data.getAll(value);
2663
- for (
2664
- var referencedFormDataKey = value.slice(key.length), i = 0;
2665
- i < reference.length;
2666
- i++
2667
- )
2668
- arrayRoot.append(referencedFormDataKey, reference[i]);
2669
- response.data.delete(value);
2670
- response.keyPointer++;
2671
- } else if (value.startsWith(obj)) break;
2672
- else response.keyPointer++;
2730
+ obj = value.slice(2);
2731
+ obj = response._prefix + "_" + obj + "_";
2732
+ response = response._formData;
2733
+ key$jscomp$0 = new FormData();
2734
+ arrayRoot = response.referencedEntries;
2735
+ if (null !== arrayRoot) {
2736
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2737
+ reference = arrayRoot[value];
2738
+ var key = reference[0];
2739
+ if (!key.startsWith(obj)) break;
2740
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2741
+ value++;
2742
+ }
2743
+ response.keyPointer = value;
2673
2744
  }
2674
- return arrayRoot;
2745
+ return key$jscomp$0;
2675
2746
  case "i":
2676
2747
  return (
2677
2748
  (arrayRoot = value.slice(2)),
2678
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2749
+ getOutlinedModel(
2750
+ response,
2751
+ arrayRoot,
2752
+ obj,
2753
+ key$jscomp$0,
2754
+ null,
2755
+ extractIterator
2756
+ )
2679
2757
  );
2680
2758
  case "I":
2681
2759
  return Infinity;
@@ -2704,7 +2782,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2704
2782
  ArrayBuffer,
2705
2783
  1,
2706
2784
  obj,
2707
- key,
2785
+ key$jscomp$0,
2708
2786
  arrayRoot
2709
2787
  );
2710
2788
  case "O":
@@ -2714,7 +2792,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2714
2792
  Int8Array,
2715
2793
  1,
2716
2794
  obj,
2717
- key,
2795
+ key$jscomp$0,
2718
2796
  arrayRoot
2719
2797
  );
2720
2798
  case "o":
@@ -2724,7 +2802,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2724
2802
  Uint8Array,
2725
2803
  1,
2726
2804
  obj,
2727
- key,
2805
+ key$jscomp$0,
2728
2806
  arrayRoot
2729
2807
  );
2730
2808
  case "U":
@@ -2734,7 +2812,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2734
2812
  Uint8ClampedArray,
2735
2813
  1,
2736
2814
  obj,
2737
- key,
2815
+ key$jscomp$0,
2738
2816
  arrayRoot
2739
2817
  );
2740
2818
  case "S":
@@ -2744,7 +2822,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2744
2822
  Int16Array,
2745
2823
  2,
2746
2824
  obj,
2747
- key,
2825
+ key$jscomp$0,
2748
2826
  arrayRoot
2749
2827
  );
2750
2828
  case "s":
@@ -2754,7 +2832,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2754
2832
  Uint16Array,
2755
2833
  2,
2756
2834
  obj,
2757
- key,
2835
+ key$jscomp$0,
2758
2836
  arrayRoot
2759
2837
  );
2760
2838
  case "L":
@@ -2764,7 +2842,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2764
2842
  Int32Array,
2765
2843
  4,
2766
2844
  obj,
2767
- key,
2845
+ key$jscomp$0,
2768
2846
  arrayRoot
2769
2847
  );
2770
2848
  case "l":
@@ -2774,7 +2852,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2774
2852
  Uint32Array,
2775
2853
  4,
2776
2854
  obj,
2777
- key,
2855
+ key$jscomp$0,
2778
2856
  arrayRoot
2779
2857
  );
2780
2858
  case "G":
@@ -2784,7 +2862,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2784
2862
  Float32Array,
2785
2863
  4,
2786
2864
  obj,
2787
- key,
2865
+ key$jscomp$0,
2788
2866
  arrayRoot
2789
2867
  );
2790
2868
  case "g":
@@ -2794,7 +2872,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2794
2872
  Float64Array,
2795
2873
  8,
2796
2874
  obj,
2797
- key,
2875
+ key$jscomp$0,
2798
2876
  arrayRoot
2799
2877
  );
2800
2878
  case "M":
@@ -2804,7 +2882,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2804
2882
  BigInt64Array,
2805
2883
  8,
2806
2884
  obj,
2807
- key,
2885
+ key$jscomp$0,
2808
2886
  arrayRoot
2809
2887
  );
2810
2888
  case "m":
@@ -2814,7 +2892,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2814
2892
  BigUint64Array,
2815
2893
  8,
2816
2894
  obj,
2817
- key,
2895
+ key$jscomp$0,
2818
2896
  arrayRoot
2819
2897
  );
2820
2898
  case "V":
@@ -2824,13 +2902,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2824
2902
  DataView,
2825
2903
  1,
2826
2904
  obj,
2827
- key,
2905
+ key$jscomp$0,
2828
2906
  arrayRoot
2829
2907
  );
2830
2908
  case "B":
2831
2909
  return (
2832
2910
  (obj = parseInt(value.slice(2), 16)),
2833
- response._formData.data.get(response._prefix + obj)
2911
+ getBackingBlob(response._formData, response._prefix + obj)
2834
2912
  );
2835
2913
  case "R":
2836
2914
  return parseReadableStream(response, value, void 0);
@@ -2842,7 +2920,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2842
2920
  return parseAsyncIterable(response, value, !0);
2843
2921
  }
2844
2922
  value = value.slice(1);
2845
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
2923
+ return getOutlinedModel(
2924
+ response,
2925
+ value,
2926
+ obj,
2927
+ key$jscomp$0,
2928
+ arrayRoot,
2929
+ createModel
2930
+ );
2846
2931
  }
2847
2932
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
2848
2933
  return value;
@@ -2854,11 +2939,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
2854
2939
  : new FormData(),
2855
2940
  arraySizeLimit =
2856
2941
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
2857
- chunks = new Map();
2942
+ chunks = new Map(),
2943
+ backingStore = {
2944
+ prefix: formFieldPrefix,
2945
+ referencedEntries: null,
2946
+ keyPointer: 0,
2947
+ stringChunks: null,
2948
+ streamChunks: null,
2949
+ blobs: null
2950
+ };
2951
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
2858
2952
  return {
2859
2953
  _bundlerConfig: bundlerConfig,
2860
2954
  _prefix: formFieldPrefix,
2861
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
2955
+ _formData: backingStore,
2862
2956
  _chunks: chunks,
2863
2957
  _closed: !1,
2864
2958
  _closedReason: null,