react-server-dom-parcel 19.1.8 → 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.
@@ -56,7 +56,11 @@ function getIteratorFn(maybeIterable) {
56
56
  maybeIterable["@@iterator"];
57
57
  return "function" === typeof maybeIterable ? maybeIterable : null;
58
58
  }
59
- var ASYNC_ITERATOR = Symbol.asyncIterator;
59
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
60
+ supportsArrayBufferDetached = hasOwnProperty.call(
61
+ ArrayBuffer.prototype,
62
+ "detached"
63
+ );
60
64
  function handleErrorInNextTick(error) {
61
65
  setTimeout(function () {
62
66
  throw error;
@@ -74,28 +78,30 @@ var LocalPromise = Promise,
74
78
  currentView = null,
75
79
  writtenBytes = 0;
76
80
  function writeChunkAndReturn(destination, chunk) {
77
- if (0 !== chunk.byteLength)
78
- if (2048 < chunk.byteLength)
79
- 0 < writtenBytes &&
80
- (destination.enqueue(
81
- new Uint8Array(currentView.buffer, 0, writtenBytes)
82
- ),
83
- (currentView = new Uint8Array(2048)),
84
- (writtenBytes = 0)),
85
- destination.enqueue(chunk);
86
- else {
87
- var allowableBytes = currentView.length - writtenBytes;
88
- allowableBytes < chunk.byteLength &&
89
- (0 === allowableBytes
90
- ? destination.enqueue(currentView)
91
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
92
- destination.enqueue(currentView),
93
- (chunk = chunk.subarray(allowableBytes))),
94
- (currentView = new Uint8Array(2048)),
95
- (writtenBytes = 0));
96
- currentView.set(chunk, writtenBytes);
97
- writtenBytes += chunk.byteLength;
98
- }
81
+ if (0 === chunk.byteLength) {
82
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
83
+ throw Error(
84
+ "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()`."
85
+ );
86
+ } else if (2048 < chunk.byteLength)
87
+ 0 < writtenBytes &&
88
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
89
+ (currentView = new Uint8Array(2048)),
90
+ (writtenBytes = 0)),
91
+ destination.enqueue(chunk);
92
+ else {
93
+ var allowableBytes = currentView.length - writtenBytes;
94
+ allowableBytes < chunk.byteLength &&
95
+ (0 === allowableBytes
96
+ ? destination.enqueue(currentView)
97
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
98
+ destination.enqueue(currentView),
99
+ (chunk = chunk.subarray(allowableBytes))),
100
+ (currentView = new Uint8Array(2048)),
101
+ (writtenBytes = 0));
102
+ currentView.set(chunk, writtenBytes);
103
+ writtenBytes += chunk.byteLength;
104
+ }
99
105
  return !0;
100
106
  }
101
107
  var textEncoder = new TextEncoder();
@@ -333,12 +339,12 @@ function createTemporaryReference(temporaryReferences, id) {
333
339
  var SuspenseException = Error(
334
340
  "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
335
341
  );
336
- function noop$1() {}
342
+ function noop$2() {}
337
343
  function trackUsedThenable(thenableState, thenable, index) {
338
344
  index = thenableState[index];
339
345
  void 0 === index
340
346
  ? thenableState.push(thenable)
341
- : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
347
+ : index !== thenable && (thenable.then(noop$2, noop$2), (thenable = index));
342
348
  switch (thenable.status) {
343
349
  case "fulfilled":
344
350
  return thenable.value;
@@ -346,7 +352,7 @@ function trackUsedThenable(thenableState, thenable, index) {
346
352
  throw thenable.reason;
347
353
  default:
348
354
  "string" === typeof thenable.status
349
- ? thenable.then(noop$1, noop$1)
355
+ ? thenable.then(noop$2, noop$2)
350
356
  : ((thenableState = thenable),
351
357
  (thenableState.status = "pending"),
352
358
  thenableState.then(
@@ -651,7 +657,7 @@ function RequestInstance(
651
657
  type = createTask(this, model, null, !1, filterStackFrame);
652
658
  environmentName.push(type);
653
659
  }
654
- function noop() {}
660
+ function noop$1() {}
655
661
  var currentRequest = null;
656
662
  function resolveRequest() {
657
663
  if (currentRequest) return currentRequest;
@@ -811,7 +817,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
811
817
  erroredTask(request, streamTask, reason),
812
818
  enqueueFlush(request),
813
819
  "function" === typeof iterator.throw &&
814
- iterator.throw(reason).then(error, error));
820
+ iterator.throw(reason).then(noop$1, noop$1));
815
821
  }
816
822
  function abortIterable(reason) {
817
823
  aborted ||
@@ -820,7 +826,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
820
826
  erroredTask(request, streamTask, reason),
821
827
  enqueueFlush(request),
822
828
  "function" === typeof iterator.throw &&
823
- iterator.throw(reason).then(error, error));
829
+ iterator.throw(reason).then(noop$1, noop$1));
824
830
  }
825
831
  iterable = iterable === iterator;
826
832
  var streamTask = createTask(
@@ -1526,14 +1532,30 @@ function emitModelChunk(request, id, json) {
1526
1532
  }
1527
1533
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1528
1534
  request.pendingChunks++;
1529
- var buffer = new Uint8Array(
1530
- typedArray.buffer,
1531
- typedArray.byteOffset,
1532
- typedArray.byteLength
1533
- );
1534
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1535
- buffer = typedArray.byteLength;
1536
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1535
+ a: {
1536
+ var view = new Uint8Array(
1537
+ typedArray.buffer,
1538
+ typedArray.byteOffset,
1539
+ typedArray.byteLength
1540
+ );
1541
+ if (2048 < typedArray.byteLength) {
1542
+ if (
1543
+ 0 !== typedArray.byteOffset ||
1544
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1545
+ typedArray.buffer.resizable
1546
+ ) {
1547
+ typedArray = view.slice();
1548
+ break a;
1549
+ }
1550
+ if (!supportsArrayBufferDetached) {
1551
+ typedArray = view.slice();
1552
+ break a;
1553
+ }
1554
+ }
1555
+ typedArray = view;
1556
+ }
1557
+ view = typedArray.byteLength;
1558
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1537
1559
  id = stringToChunk(id);
1538
1560
  request.completedRegularChunks.push(id, typedArray);
1539
1561
  }
@@ -1789,13 +1811,37 @@ function abort(request, reason) {
1789
1811
  logRecoverableError(request, error$26, null), fatalError(request, error$26);
1790
1812
  }
1791
1813
  }
1792
- function appendBackingEntry(backingStore, key, value) {
1793
- backingStore.data.append(key, value);
1794
- value = backingStore.keys;
1795
- null === value
1796
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
1797
- (backingStore.keyPointer = 0))
1798
- : value.push(key);
1814
+ function appendBackingEntry(backingStore, value, key) {
1815
+ var prefix = backingStore.prefix;
1816
+ if (key.startsWith(prefix)) {
1817
+ switch (key[prefix.length]) {
1818
+ case "_":
1819
+ prefix = backingStore.referencedEntries;
1820
+ null === prefix && (prefix = backingStore.referencedEntries = []);
1821
+ prefix.push([key, value]);
1822
+ return;
1823
+ case "S":
1824
+ "string" === typeof value &&
1825
+ ((prefix = backingStore.streamChunks),
1826
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
1827
+ (backingStore = prefix.get(key)),
1828
+ void 0 === backingStore
1829
+ ? prefix.set(key, [value])
1830
+ : backingStore.push(value));
1831
+ return;
1832
+ }
1833
+ "string" === typeof value
1834
+ ? ((prefix = backingStore.stringChunks),
1835
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
1836
+ prefix.set(key, value))
1837
+ : ((prefix = backingStore.blobs),
1838
+ null === prefix && (prefix = backingStore.blobs = new Map()),
1839
+ prefix.set(key, value));
1840
+ }
1841
+ }
1842
+ function getBackingBlob(backingStore, key) {
1843
+ backingStore = backingStore.blobs;
1844
+ return null === backingStore ? void 0 : backingStore.get(key);
1799
1845
  }
1800
1846
  var RESPONSE_SYMBOL = Symbol();
1801
1847
  function ReactPromise(status, value, reason) {
@@ -2168,15 +2214,18 @@ function reportGlobalError(response, error) {
2168
2214
  function getChunk(response, id) {
2169
2215
  var chunks = response._chunks,
2170
2216
  chunk = chunks.get(id);
2171
- chunk ||
2172
- ((chunk = response._formData.data.get(response._prefix + id)),
2173
- (chunk =
2217
+ if (!chunk) {
2218
+ chunk = response._prefix;
2219
+ var stringChunks = response._formData.stringChunks;
2220
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2221
+ chunk =
2174
2222
  "string" === typeof chunk
2175
2223
  ? createResolvedModelChunk(response, chunk, id)
2176
2224
  : response._closed
2177
2225
  ? new ReactPromise("rejected", null, response._closedReason)
2178
- : new ReactPromise("pending", null, null)),
2179
- chunks.set(id, chunk));
2226
+ : new ReactPromise("pending", null, null);
2227
+ chunks.set(id, chunk);
2228
+ }
2180
2229
  return chunk;
2181
2230
  }
2182
2231
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2407,7 +2456,7 @@ function parseTypedArray(
2407
2456
  Error("Already initialized typed array.")
2408
2457
  )
2409
2458
  );
2410
- reference = response._formData.data.get(key).arrayBuffer();
2459
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2411
2460
  if (initializingHandler) {
2412
2461
  var handler = initializingHandler;
2413
2462
  handler.deps++;
@@ -2451,13 +2500,15 @@ function resolveStream(response, id, stream, controller) {
2451
2500
  var chunks = response._chunks;
2452
2501
  stream = new ReactPromise("fulfilled", stream, controller);
2453
2502
  chunks.set(id, stream);
2454
- response = response._formData.data.getAll(response._prefix + id);
2455
- for (id = 0; id < response.length; id++)
2456
- (chunks = response[id]),
2457
- "string" === typeof chunks &&
2458
- ("C" === chunks[0]
2503
+ chunks = response._prefix;
2504
+ response = response._formData.streamChunks;
2505
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2506
+ if (void 0 !== id)
2507
+ for (response = 0; response < id.length; response++)
2508
+ (chunks = id[response]),
2509
+ "C" === chunks[0]
2459
2510
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2460
- : controller.enqueueModel(chunks));
2511
+ : controller.enqueueModel(chunks);
2461
2512
  }
2462
2513
  function parseReadableStream(response, reference, type) {
2463
2514
  function enqueue(value) {
@@ -2623,7 +2674,14 @@ function parseAsyncIterable(response, reference, iterator) {
2623
2674
  });
2624
2675
  return iterator;
2625
2676
  }
2626
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2677
+ function parseModelString(
2678
+ response,
2679
+ obj,
2680
+ key$jscomp$0,
2681
+ value,
2682
+ reference,
2683
+ arrayRoot
2684
+ ) {
2627
2685
  if ("$" === value[0]) {
2628
2686
  switch (value[1]) {
2629
2687
  case "$":
@@ -2641,7 +2699,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2641
2699
  response,
2642
2700
  arrayRoot,
2643
2701
  obj,
2644
- key,
2702
+ key$jscomp$0,
2645
2703
  null,
2646
2704
  loadServerReference$1
2647
2705
  )
@@ -2658,43 +2716,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2658
2716
  case "Q":
2659
2717
  return (
2660
2718
  (arrayRoot = value.slice(2)),
2661
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2719
+ getOutlinedModel(
2720
+ response,
2721
+ arrayRoot,
2722
+ obj,
2723
+ key$jscomp$0,
2724
+ null,
2725
+ createMap
2726
+ )
2662
2727
  );
2663
2728
  case "W":
2664
2729
  return (
2665
2730
  (arrayRoot = value.slice(2)),
2666
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2731
+ getOutlinedModel(
2732
+ response,
2733
+ arrayRoot,
2734
+ obj,
2735
+ key$jscomp$0,
2736
+ null,
2737
+ createSet
2738
+ )
2667
2739
  );
2668
2740
  case "K":
2669
- key = value.slice(2);
2670
- obj = response._prefix + "_";
2671
- key = obj + key + "_";
2672
- arrayRoot = new FormData();
2673
- for (response = response._formData; ; ) {
2674
- value = response.keys;
2675
- null === value &&
2676
- ((value = response.keys = Array.from(response.data.keys())),
2677
- (response.keyPointer = 0));
2678
- value = value[response.keyPointer];
2679
- if (void 0 === value) break;
2680
- if (value.startsWith(key)) {
2681
- reference = response.data.getAll(value);
2682
- for (
2683
- var referencedFormDataKey = value.slice(key.length), i = 0;
2684
- i < reference.length;
2685
- i++
2686
- )
2687
- arrayRoot.append(referencedFormDataKey, reference[i]);
2688
- response.data.delete(value);
2689
- response.keyPointer++;
2690
- } else if (value.startsWith(obj)) break;
2691
- else response.keyPointer++;
2741
+ obj = value.slice(2);
2742
+ obj = response._prefix + "_" + obj + "_";
2743
+ response = response._formData;
2744
+ key$jscomp$0 = new FormData();
2745
+ arrayRoot = response.referencedEntries;
2746
+ if (null !== arrayRoot) {
2747
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2748
+ reference = arrayRoot[value];
2749
+ var key = reference[0];
2750
+ if (!key.startsWith(obj)) break;
2751
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2752
+ value++;
2753
+ }
2754
+ response.keyPointer = value;
2692
2755
  }
2693
- return arrayRoot;
2756
+ return key$jscomp$0;
2694
2757
  case "i":
2695
2758
  return (
2696
2759
  (arrayRoot = value.slice(2)),
2697
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2760
+ getOutlinedModel(
2761
+ response,
2762
+ arrayRoot,
2763
+ obj,
2764
+ key$jscomp$0,
2765
+ null,
2766
+ extractIterator
2767
+ )
2698
2768
  );
2699
2769
  case "I":
2700
2770
  return Infinity;
@@ -2723,7 +2793,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2723
2793
  ArrayBuffer,
2724
2794
  1,
2725
2795
  obj,
2726
- key,
2796
+ key$jscomp$0,
2727
2797
  arrayRoot
2728
2798
  );
2729
2799
  case "O":
@@ -2733,7 +2803,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2733
2803
  Int8Array,
2734
2804
  1,
2735
2805
  obj,
2736
- key,
2806
+ key$jscomp$0,
2737
2807
  arrayRoot
2738
2808
  );
2739
2809
  case "o":
@@ -2743,7 +2813,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2743
2813
  Uint8Array,
2744
2814
  1,
2745
2815
  obj,
2746
- key,
2816
+ key$jscomp$0,
2747
2817
  arrayRoot
2748
2818
  );
2749
2819
  case "U":
@@ -2753,7 +2823,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2753
2823
  Uint8ClampedArray,
2754
2824
  1,
2755
2825
  obj,
2756
- key,
2826
+ key$jscomp$0,
2757
2827
  arrayRoot
2758
2828
  );
2759
2829
  case "S":
@@ -2763,7 +2833,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2763
2833
  Int16Array,
2764
2834
  2,
2765
2835
  obj,
2766
- key,
2836
+ key$jscomp$0,
2767
2837
  arrayRoot
2768
2838
  );
2769
2839
  case "s":
@@ -2773,7 +2843,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2773
2843
  Uint16Array,
2774
2844
  2,
2775
2845
  obj,
2776
- key,
2846
+ key$jscomp$0,
2777
2847
  arrayRoot
2778
2848
  );
2779
2849
  case "L":
@@ -2783,7 +2853,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2783
2853
  Int32Array,
2784
2854
  4,
2785
2855
  obj,
2786
- key,
2856
+ key$jscomp$0,
2787
2857
  arrayRoot
2788
2858
  );
2789
2859
  case "l":
@@ -2793,7 +2863,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2793
2863
  Uint32Array,
2794
2864
  4,
2795
2865
  obj,
2796
- key,
2866
+ key$jscomp$0,
2797
2867
  arrayRoot
2798
2868
  );
2799
2869
  case "G":
@@ -2803,7 +2873,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2803
2873
  Float32Array,
2804
2874
  4,
2805
2875
  obj,
2806
- key,
2876
+ key$jscomp$0,
2807
2877
  arrayRoot
2808
2878
  );
2809
2879
  case "g":
@@ -2813,7 +2883,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2813
2883
  Float64Array,
2814
2884
  8,
2815
2885
  obj,
2816
- key,
2886
+ key$jscomp$0,
2817
2887
  arrayRoot
2818
2888
  );
2819
2889
  case "M":
@@ -2823,7 +2893,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2823
2893
  BigInt64Array,
2824
2894
  8,
2825
2895
  obj,
2826
- key,
2896
+ key$jscomp$0,
2827
2897
  arrayRoot
2828
2898
  );
2829
2899
  case "m":
@@ -2833,7 +2903,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2833
2903
  BigUint64Array,
2834
2904
  8,
2835
2905
  obj,
2836
- key,
2906
+ key$jscomp$0,
2837
2907
  arrayRoot
2838
2908
  );
2839
2909
  case "V":
@@ -2843,13 +2913,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2843
2913
  DataView,
2844
2914
  1,
2845
2915
  obj,
2846
- key,
2916
+ key$jscomp$0,
2847
2917
  arrayRoot
2848
2918
  );
2849
2919
  case "B":
2850
2920
  return (
2851
2921
  (obj = parseInt(value.slice(2), 16)),
2852
- response._formData.data.get(response._prefix + obj)
2922
+ getBackingBlob(response._formData, response._prefix + obj)
2853
2923
  );
2854
2924
  case "R":
2855
2925
  return parseReadableStream(response, value, void 0);
@@ -2861,7 +2931,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2861
2931
  return parseAsyncIterable(response, value, !0);
2862
2932
  }
2863
2933
  value = value.slice(1);
2864
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
2934
+ return getOutlinedModel(
2935
+ response,
2936
+ value,
2937
+ obj,
2938
+ key$jscomp$0,
2939
+ arrayRoot,
2940
+ createModel
2941
+ );
2865
2942
  }
2866
2943
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
2867
2944
  return value;
@@ -2873,11 +2950,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
2873
2950
  : new FormData(),
2874
2951
  arraySizeLimit =
2875
2952
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
2876
- chunks = new Map();
2953
+ chunks = new Map(),
2954
+ backingStore = {
2955
+ prefix: formFieldPrefix,
2956
+ referencedEntries: null,
2957
+ keyPointer: 0,
2958
+ stringChunks: null,
2959
+ streamChunks: null,
2960
+ blobs: null
2961
+ };
2962
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
2877
2963
  return {
2878
2964
  _bundlerConfig: bundlerConfig,
2879
2965
  _prefix: formFieldPrefix,
2880
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
2966
+ _formData: backingStore,
2881
2967
  _chunks: chunks,
2882
2968
  _closed: !1,
2883
2969
  _closedReason: null,
@@ -2934,49 +3020,47 @@ function decodeBoundActionMetaData(
2934
3020
  }
2935
3021
  function decodeAction$1(body, serverManifest) {
2936
3022
  var formData = new FormData(),
2937
- action = null,
2938
- seenActions = new Set();
3023
+ maybeActionKey = null;
2939
3024
  body.forEach(function (value, key) {
2940
3025
  key.startsWith("$ACTION_")
2941
3026
  ? key.startsWith("$ACTION_REF_")
2942
- ? seenActions.has(key) ||
2943
- (seenActions.add(key),
2944
- (value = "$ACTION_" + key.slice(12) + ":"),
2945
- (value = decodeBoundActionMetaData(body, serverManifest, value)),
2946
- (action = loadServerReference(serverManifest, value)))
2947
- : key.startsWith("$ACTION_ID_") &&
2948
- !seenActions.has(key) &&
2949
- (seenActions.add(key),
2950
- (value = key.slice(11)),
2951
- (action = loadServerReference(serverManifest, {
2952
- id: value,
2953
- bound: null
2954
- })))
3027
+ ? (maybeActionKey = key)
3028
+ : key.startsWith("$ACTION_ID_") && (maybeActionKey = key)
2955
3029
  : formData.append(key, value);
2956
3030
  });
2957
- return null === action
2958
- ? null
2959
- : action.then(function (fn) {
2960
- return fn.bind(null, formData);
2961
- });
3031
+ if (null === maybeActionKey) return null;
3032
+ var actionKey = maybeActionKey,
3033
+ action = null;
3034
+ if (actionKey.startsWith("$ACTION_REF_"))
3035
+ (actionKey = "$ACTION_" + actionKey.slice(12) + ":"),
3036
+ (body = decodeBoundActionMetaData(body, serverManifest, actionKey)),
3037
+ (action = loadServerReference(serverManifest, body));
3038
+ else if (actionKey.startsWith("$ACTION_ID_"))
3039
+ (body = actionKey.slice(11)),
3040
+ (action = loadServerReference(serverManifest, { id: body, bound: null }));
3041
+ else throw Error("Cannot handle action key. This is a bug in React.");
3042
+ return action.then(function (fn) {
3043
+ return fn.bind(null, formData);
3044
+ });
2962
3045
  }
2963
3046
  function decodeFormState$1(actionResult, body, serverManifest) {
2964
3047
  var keyPath = body.get("$ACTION_KEY");
2965
3048
  if ("string" !== typeof keyPath) return Promise.resolve(null);
2966
- var metaData = null;
3049
+ var actionKey = null;
2967
3050
  body.forEach(function (value, key) {
2968
- key.startsWith("$ACTION_REF_") &&
2969
- ((value = "$ACTION_" + key.slice(12) + ":"),
2970
- (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
3051
+ key.startsWith("$ACTION_REF_") && (actionKey = key);
2971
3052
  });
2972
- if (null === metaData) return Promise.resolve(null);
2973
- var referenceId = metaData.id;
2974
- return Promise.resolve(metaData.bound).then(function (bound) {
3053
+ if (null === actionKey) return Promise.resolve(null);
3054
+ var formFieldPrefix = "$ACTION_" + actionKey.slice(12) + ":";
3055
+ body = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
3056
+ var referenceId = body.id;
3057
+ return Promise.resolve(body.bound).then(function (bound) {
2975
3058
  return null === bound
2976
3059
  ? null
2977
3060
  : [actionResult, keyPath, referenceId, bound.length - 1];
2978
3061
  });
2979
3062
  }
3063
+ function noop() {}
2980
3064
  var serverManifest = {};
2981
3065
  exports.createClientReference = function (id, exportName, bundles, importMap) {
2982
3066
  return {
@@ -3017,26 +3101,41 @@ exports.decodeReplyFromAsyncIterable = function (iterable, options) {
3017
3101
  function progress(entry) {
3018
3102
  if (entry.done) close(response);
3019
3103
  else {
3020
- entry = entry.value;
3021
- var name = entry[0];
3022
- entry = entry[1];
3023
- if ("string" === typeof entry) {
3024
- appendBackingEntry(response._formData, name, entry);
3025
- var prefix = response._prefix;
3026
- if (name.startsWith(prefix)) {
3027
- var chunks = response._chunks;
3028
- name = +name.slice(prefix.length);
3029
- (chunks = chunks.get(name)) &&
3030
- resolveModelChunk(response, chunks, entry, name);
3104
+ var _entry$value = entry.value;
3105
+ entry = _entry$value[0];
3106
+ _entry$value = _entry$value[1];
3107
+ if ("string" === typeof _entry$value)
3108
+ a: {
3109
+ var prefix = response._prefix;
3110
+ if (entry.startsWith(prefix)) {
3111
+ var chunks = response._chunks;
3112
+ if ("S" === entry[prefix.length]) {
3113
+ if (
3114
+ entry.length > prefix.length + 1 &&
3115
+ ((prefix = +entry.slice(prefix.length + 1)),
3116
+ (chunks = chunks.get(prefix)))
3117
+ ) {
3118
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3119
+ break a;
3120
+ }
3121
+ } else if (
3122
+ ((prefix = +entry.slice(prefix.length)),
3123
+ (chunks = chunks.get(prefix)))
3124
+ ) {
3125
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3126
+ break a;
3127
+ }
3128
+ }
3129
+ appendBackingEntry(response._formData, _entry$value, entry);
3031
3130
  }
3032
- } else appendBackingEntry(response._formData, name, entry);
3131
+ else appendBackingEntry(response._formData, _entry$value, entry);
3033
3132
  iterator.next().then(progress, error);
3034
3133
  }
3035
3134
  }
3036
3135
  function error(reason) {
3037
3136
  reportGlobalError(response, reason);
3038
3137
  "function" === typeof iterator.throw &&
3039
- iterator.throw(reason).then(error, error);
3138
+ iterator.throw(reason).then(noop, noop);
3040
3139
  }
3041
3140
  var iterator = iterable[ASYNC_ITERATOR](),
3042
3141
  response = createResponse(
@@ -3083,8 +3182,8 @@ exports.renderToReadableStream = function (model, options) {
3083
3182
  options ? options.temporaryReferences : void 0,
3084
3183
  void 0,
3085
3184
  void 0,
3086
- noop,
3087
- noop
3185
+ noop$1,
3186
+ noop$1
3088
3187
  );
3089
3188
  if (options && options.signal) {
3090
3189
  var signal = options.signal;