react-server-dom-turbopack 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.
@@ -15,6 +15,11 @@ require("crypto");
15
15
  var async_hooks = require("async_hooks"),
16
16
  ReactDOM = require("react-dom"),
17
17
  React = require("react"),
18
+ hasOwnProperty = Object.prototype.hasOwnProperty,
19
+ supportsArrayBufferDetached = hasOwnProperty.call(
20
+ ArrayBuffer.prototype,
21
+ "detached"
22
+ ),
18
23
  scheduleMicrotask = queueMicrotask,
19
24
  currentView = null,
20
25
  writtenBytes = 0,
@@ -56,33 +61,37 @@ function writeChunkAndReturn(destination, chunk) {
56
61
  (currentView = new Uint8Array(2048)),
57
62
  (writtenBytes = 0));
58
63
  }
64
+ } else if (0 === chunk.byteLength) {
65
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
66
+ throw Error(
67
+ "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()`."
68
+ );
59
69
  } else
60
- 0 !== chunk.byteLength &&
61
- (2048 < chunk.byteLength
62
- ? (0 < writtenBytes &&
63
- (writeToDestination(
64
- destination,
65
- currentView.subarray(0, writtenBytes)
66
- ),
67
- (currentView = new Uint8Array(2048)),
68
- (writtenBytes = 0)),
69
- writeToDestination(destination, chunk))
70
- : ((target = currentView.length - writtenBytes),
71
- target < chunk.byteLength &&
72
- (0 === target
73
- ? writeToDestination(destination, currentView)
74
- : (currentView.set(chunk.subarray(0, target), writtenBytes),
75
- (writtenBytes += target),
76
- writeToDestination(destination, currentView),
77
- (chunk = chunk.subarray(target))),
78
- (currentView = new Uint8Array(2048)),
79
- (writtenBytes = 0)),
80
- currentView.set(chunk, writtenBytes),
81
- (writtenBytes += chunk.byteLength),
82
- 2048 === writtenBytes &&
83
- (writeToDestination(destination, currentView),
84
- (currentView = new Uint8Array(2048)),
85
- (writtenBytes = 0))));
70
+ 2048 < chunk.byteLength
71
+ ? (0 < writtenBytes &&
72
+ (writeToDestination(
73
+ destination,
74
+ currentView.subarray(0, writtenBytes)
75
+ ),
76
+ (currentView = new Uint8Array(2048)),
77
+ (writtenBytes = 0)),
78
+ writeToDestination(destination, chunk))
79
+ : ((target = currentView.length - writtenBytes),
80
+ target < chunk.byteLength &&
81
+ (0 === target
82
+ ? writeToDestination(destination, currentView)
83
+ : (currentView.set(chunk.subarray(0, target), writtenBytes),
84
+ (writtenBytes += target),
85
+ writeToDestination(destination, currentView),
86
+ (chunk = chunk.subarray(target))),
87
+ (currentView = new Uint8Array(2048)),
88
+ (writtenBytes = 0)),
89
+ currentView.set(chunk, writtenBytes),
90
+ (writtenBytes += chunk.byteLength),
91
+ 2048 === writtenBytes &&
92
+ (writeToDestination(destination, currentView),
93
+ (currentView = new Uint8Array(2048)),
94
+ (writtenBytes = 0)));
86
95
  return destinationHasCapacity;
87
96
  }
88
97
  var textEncoder = new util.TextEncoder();
@@ -946,7 +955,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
946
955
  erroredTask(request, streamTask, reason),
947
956
  enqueueFlush(request),
948
957
  "function" === typeof iterator.throw &&
949
- iterator.throw(reason).then(error, error));
958
+ iterator.throw(reason).then(noop, noop));
950
959
  }
951
960
  function abortIterable(reason) {
952
961
  aborted ||
@@ -955,7 +964,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
955
964
  erroredTask(request, streamTask, reason),
956
965
  enqueueFlush(request),
957
966
  "function" === typeof iterator.throw &&
958
- iterator.throw(reason).then(error, error));
967
+ iterator.throw(reason).then(noop, noop));
959
968
  }
960
969
  iterable = iterable === iterator;
961
970
  var streamTask = createTask(
@@ -1670,13 +1679,30 @@ function emitModelChunk(request, id, json) {
1670
1679
  }
1671
1680
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1672
1681
  request.pendingChunks++;
1673
- typedArray = new Uint8Array(
1674
- typedArray.buffer,
1675
- typedArray.byteOffset,
1676
- typedArray.byteLength
1677
- );
1678
- var binaryLength = typedArray.byteLength;
1679
- id = id.toString(16) + ":" + tag + binaryLength.toString(16) + ",";
1682
+ a: {
1683
+ var view = new Uint8Array(
1684
+ typedArray.buffer,
1685
+ typedArray.byteOffset,
1686
+ typedArray.byteLength
1687
+ );
1688
+ if (2048 < typedArray.byteLength) {
1689
+ if (
1690
+ 0 !== typedArray.byteOffset ||
1691
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1692
+ typedArray.buffer.resizable
1693
+ ) {
1694
+ typedArray = view.slice();
1695
+ break a;
1696
+ }
1697
+ if (!supportsArrayBufferDetached) {
1698
+ typedArray = view.slice();
1699
+ break a;
1700
+ }
1701
+ }
1702
+ typedArray = view;
1703
+ }
1704
+ view = typedArray.byteLength;
1705
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1680
1706
  request.completedRegularChunks.push(id, typedArray);
1681
1707
  }
1682
1708
  function emitTextChunk(request, id, text) {
@@ -1949,7 +1975,6 @@ function abort(request, reason) {
1949
1975
  logRecoverableError(request, error$26, null), fatalError(request, error$26);
1950
1976
  }
1951
1977
  }
1952
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1953
1978
  function resolveServerReference(bundlerConfig, id) {
1954
1979
  var name = "",
1955
1980
  resolvedModuleData = bundlerConfig[id];
@@ -2020,6 +2045,38 @@ function requireModule(metadata) {
2020
2045
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2021
2046
  return moduleExports[metadata[2]];
2022
2047
  }
2048
+ function appendBackingEntry(backingStore, value, key) {
2049
+ var prefix = backingStore.prefix;
2050
+ if (key.startsWith(prefix)) {
2051
+ switch (key[prefix.length]) {
2052
+ case "_":
2053
+ prefix = backingStore.referencedEntries;
2054
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2055
+ prefix.push([key, value]);
2056
+ return;
2057
+ case "S":
2058
+ "string" === typeof value &&
2059
+ ((prefix = backingStore.streamChunks),
2060
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2061
+ (backingStore = prefix.get(key)),
2062
+ void 0 === backingStore
2063
+ ? prefix.set(key, [value])
2064
+ : backingStore.push(value));
2065
+ return;
2066
+ }
2067
+ "string" === typeof value
2068
+ ? ((prefix = backingStore.stringChunks),
2069
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2070
+ prefix.set(key, value))
2071
+ : ((prefix = backingStore.blobs),
2072
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2073
+ prefix.set(key, value));
2074
+ }
2075
+ }
2076
+ function getBackingBlob(backingStore, key) {
2077
+ backingStore = backingStore.blobs;
2078
+ return null === backingStore ? void 0 : backingStore.get(key);
2079
+ }
2023
2080
  var RESPONSE_SYMBOL = Symbol();
2024
2081
  function ReactPromise(status, value, reason) {
2025
2082
  this.status = status;
@@ -2391,15 +2448,18 @@ function reportGlobalError(response, error) {
2391
2448
  function getChunk(response, id) {
2392
2449
  var chunks = response._chunks,
2393
2450
  chunk = chunks.get(id);
2394
- chunk ||
2395
- ((chunk = response._formData.data.get(response._prefix + id)),
2396
- (chunk =
2451
+ if (!chunk) {
2452
+ chunk = response._prefix;
2453
+ var stringChunks = response._formData.stringChunks;
2454
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2455
+ chunk =
2397
2456
  "string" === typeof chunk
2398
2457
  ? createResolvedModelChunk(response, chunk, id)
2399
2458
  : response._closed
2400
2459
  ? new ReactPromise("rejected", null, response._closedReason)
2401
- : new ReactPromise("pending", null, null)),
2402
- chunks.set(id, chunk));
2460
+ : new ReactPromise("pending", null, null);
2461
+ chunks.set(id, chunk);
2462
+ }
2403
2463
  return chunk;
2404
2464
  }
2405
2465
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2630,7 +2690,7 @@ function parseTypedArray(
2630
2690
  Error("Already initialized typed array.")
2631
2691
  )
2632
2692
  );
2633
- reference = response._formData.data.get(key).arrayBuffer();
2693
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2634
2694
  if (initializingHandler) {
2635
2695
  var handler = initializingHandler;
2636
2696
  handler.deps++;
@@ -2674,13 +2734,15 @@ function resolveStream(response, id, stream, controller) {
2674
2734
  var chunks = response._chunks;
2675
2735
  stream = new ReactPromise("fulfilled", stream, controller);
2676
2736
  chunks.set(id, stream);
2677
- response = response._formData.data.getAll(response._prefix + id);
2678
- for (id = 0; id < response.length; id++)
2679
- (chunks = response[id]),
2680
- "string" === typeof chunks &&
2681
- ("C" === chunks[0]
2737
+ chunks = response._prefix;
2738
+ response = response._formData.streamChunks;
2739
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2740
+ if (void 0 !== id)
2741
+ for (response = 0; response < id.length; response++)
2742
+ (chunks = id[response]),
2743
+ "C" === chunks[0]
2682
2744
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2683
- : controller.enqueueModel(chunks));
2745
+ : controller.enqueueModel(chunks);
2684
2746
  }
2685
2747
  function parseReadableStream(response, reference, type) {
2686
2748
  function enqueue(value) {
@@ -2846,7 +2908,14 @@ function parseAsyncIterable(response, reference, iterator) {
2846
2908
  });
2847
2909
  return iterator;
2848
2910
  }
2849
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2911
+ function parseModelString(
2912
+ response,
2913
+ obj,
2914
+ key$jscomp$0,
2915
+ value,
2916
+ reference,
2917
+ arrayRoot
2918
+ ) {
2850
2919
  if ("$" === value[0]) {
2851
2920
  switch (value[1]) {
2852
2921
  case "$":
@@ -2864,7 +2933,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2864
2933
  response,
2865
2934
  arrayRoot,
2866
2935
  obj,
2867
- key,
2936
+ key$jscomp$0,
2868
2937
  null,
2869
2938
  loadServerReference$1
2870
2939
  )
@@ -2881,43 +2950,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2881
2950
  case "Q":
2882
2951
  return (
2883
2952
  (arrayRoot = value.slice(2)),
2884
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2953
+ getOutlinedModel(
2954
+ response,
2955
+ arrayRoot,
2956
+ obj,
2957
+ key$jscomp$0,
2958
+ null,
2959
+ createMap
2960
+ )
2885
2961
  );
2886
2962
  case "W":
2887
2963
  return (
2888
2964
  (arrayRoot = value.slice(2)),
2889
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2965
+ getOutlinedModel(
2966
+ response,
2967
+ arrayRoot,
2968
+ obj,
2969
+ key$jscomp$0,
2970
+ null,
2971
+ createSet
2972
+ )
2890
2973
  );
2891
2974
  case "K":
2892
- key = value.slice(2);
2893
- obj = response._prefix + "_";
2894
- key = obj + key + "_";
2895
- arrayRoot = new FormData();
2896
- for (response = response._formData; ; ) {
2897
- value = response.keys;
2898
- null === value &&
2899
- ((value = response.keys = Array.from(response.data.keys())),
2900
- (response.keyPointer = 0));
2901
- value = value[response.keyPointer];
2902
- if (void 0 === value) break;
2903
- if (value.startsWith(key)) {
2904
- reference = response.data.getAll(value);
2905
- for (
2906
- var referencedFormDataKey = value.slice(key.length), i = 0;
2907
- i < reference.length;
2908
- i++
2909
- )
2910
- arrayRoot.append(referencedFormDataKey, reference[i]);
2911
- response.data.delete(value);
2912
- response.keyPointer++;
2913
- } else if (value.startsWith(obj)) break;
2914
- else response.keyPointer++;
2975
+ obj = value.slice(2);
2976
+ obj = response._prefix + "_" + obj + "_";
2977
+ response = response._formData;
2978
+ key$jscomp$0 = new FormData();
2979
+ arrayRoot = response.referencedEntries;
2980
+ if (null !== arrayRoot) {
2981
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2982
+ reference = arrayRoot[value];
2983
+ var key = reference[0];
2984
+ if (!key.startsWith(obj)) break;
2985
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2986
+ value++;
2987
+ }
2988
+ response.keyPointer = value;
2915
2989
  }
2916
- return arrayRoot;
2990
+ return key$jscomp$0;
2917
2991
  case "i":
2918
2992
  return (
2919
2993
  (arrayRoot = value.slice(2)),
2920
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2994
+ getOutlinedModel(
2995
+ response,
2996
+ arrayRoot,
2997
+ obj,
2998
+ key$jscomp$0,
2999
+ null,
3000
+ extractIterator
3001
+ )
2921
3002
  );
2922
3003
  case "I":
2923
3004
  return Infinity;
@@ -2946,7 +3027,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2946
3027
  ArrayBuffer,
2947
3028
  1,
2948
3029
  obj,
2949
- key,
3030
+ key$jscomp$0,
2950
3031
  arrayRoot
2951
3032
  );
2952
3033
  case "O":
@@ -2956,7 +3037,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2956
3037
  Int8Array,
2957
3038
  1,
2958
3039
  obj,
2959
- key,
3040
+ key$jscomp$0,
2960
3041
  arrayRoot
2961
3042
  );
2962
3043
  case "o":
@@ -2966,7 +3047,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2966
3047
  Uint8Array,
2967
3048
  1,
2968
3049
  obj,
2969
- key,
3050
+ key$jscomp$0,
2970
3051
  arrayRoot
2971
3052
  );
2972
3053
  case "U":
@@ -2976,7 +3057,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2976
3057
  Uint8ClampedArray,
2977
3058
  1,
2978
3059
  obj,
2979
- key,
3060
+ key$jscomp$0,
2980
3061
  arrayRoot
2981
3062
  );
2982
3063
  case "S":
@@ -2986,7 +3067,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2986
3067
  Int16Array,
2987
3068
  2,
2988
3069
  obj,
2989
- key,
3070
+ key$jscomp$0,
2990
3071
  arrayRoot
2991
3072
  );
2992
3073
  case "s":
@@ -2996,7 +3077,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2996
3077
  Uint16Array,
2997
3078
  2,
2998
3079
  obj,
2999
- key,
3080
+ key$jscomp$0,
3000
3081
  arrayRoot
3001
3082
  );
3002
3083
  case "L":
@@ -3006,7 +3087,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3006
3087
  Int32Array,
3007
3088
  4,
3008
3089
  obj,
3009
- key,
3090
+ key$jscomp$0,
3010
3091
  arrayRoot
3011
3092
  );
3012
3093
  case "l":
@@ -3016,7 +3097,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3016
3097
  Uint32Array,
3017
3098
  4,
3018
3099
  obj,
3019
- key,
3100
+ key$jscomp$0,
3020
3101
  arrayRoot
3021
3102
  );
3022
3103
  case "G":
@@ -3026,7 +3107,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3026
3107
  Float32Array,
3027
3108
  4,
3028
3109
  obj,
3029
- key,
3110
+ key$jscomp$0,
3030
3111
  arrayRoot
3031
3112
  );
3032
3113
  case "g":
@@ -3036,7 +3117,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3036
3117
  Float64Array,
3037
3118
  8,
3038
3119
  obj,
3039
- key,
3120
+ key$jscomp$0,
3040
3121
  arrayRoot
3041
3122
  );
3042
3123
  case "M":
@@ -3046,7 +3127,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3046
3127
  BigInt64Array,
3047
3128
  8,
3048
3129
  obj,
3049
- key,
3130
+ key$jscomp$0,
3050
3131
  arrayRoot
3051
3132
  );
3052
3133
  case "m":
@@ -3056,7 +3137,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3056
3137
  BigUint64Array,
3057
3138
  8,
3058
3139
  obj,
3059
- key,
3140
+ key$jscomp$0,
3060
3141
  arrayRoot
3061
3142
  );
3062
3143
  case "V":
@@ -3066,13 +3147,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3066
3147
  DataView,
3067
3148
  1,
3068
3149
  obj,
3069
- key,
3150
+ key$jscomp$0,
3070
3151
  arrayRoot
3071
3152
  );
3072
3153
  case "B":
3073
3154
  return (
3074
3155
  (obj = parseInt(value.slice(2), 16)),
3075
- response._formData.data.get(response._prefix + obj)
3156
+ getBackingBlob(response._formData, response._prefix + obj)
3076
3157
  );
3077
3158
  case "R":
3078
3159
  return parseReadableStream(response, value, void 0);
@@ -3084,7 +3165,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3084
3165
  return parseAsyncIterable(response, value, !0);
3085
3166
  }
3086
3167
  value = value.slice(1);
3087
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3168
+ return getOutlinedModel(
3169
+ response,
3170
+ value,
3171
+ obj,
3172
+ key$jscomp$0,
3173
+ arrayRoot,
3174
+ createModel
3175
+ );
3088
3176
  }
3089
3177
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3090
3178
  return value;
@@ -3096,11 +3184,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3096
3184
  : new FormData(),
3097
3185
  arraySizeLimit =
3098
3186
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3099
- chunks = new Map();
3187
+ chunks = new Map(),
3188
+ backingStore = {
3189
+ prefix: formFieldPrefix,
3190
+ referencedEntries: null,
3191
+ keyPointer: 0,
3192
+ stringChunks: null,
3193
+ streamChunks: null,
3194
+ blobs: null
3195
+ };
3196
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3100
3197
  return {
3101
3198
  _bundlerConfig: bundlerConfig,
3102
3199
  _prefix: formFieldPrefix,
3103
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3200
+ _formData: backingStore,
3104
3201
  _chunks: chunks,
3105
3202
  _closed: !1,
3106
3203
  _closedReason: null,
@@ -3110,19 +3207,26 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3110
3207
  };
3111
3208
  }
3112
3209
  function resolveField(response, key, value) {
3113
- var backingStore = response._formData;
3114
- backingStore.data.append(key, value);
3115
- var keys = backingStore.keys;
3116
- null === keys
3117
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
3118
- (backingStore.keyPointer = 0))
3119
- : keys.push(key);
3120
- keys = response._prefix;
3121
- key.startsWith(keys) &&
3122
- ((backingStore = response._chunks),
3123
- (key = +key.slice(keys.length)),
3124
- (backingStore = backingStore.get(key)) &&
3125
- resolveModelChunk(response, backingStore, value, key));
3210
+ var prefix = response._prefix;
3211
+ if (key.startsWith(prefix)) {
3212
+ var chunks = response._chunks;
3213
+ if ("S" === key[prefix.length]) {
3214
+ if (
3215
+ key.length > prefix.length + 1 &&
3216
+ ((prefix = +key.slice(prefix.length + 1)),
3217
+ (chunks = chunks.get(prefix)))
3218
+ ) {
3219
+ resolveModelChunk(response, chunks, value, prefix);
3220
+ return;
3221
+ }
3222
+ } else if (
3223
+ ((prefix = +key.slice(prefix.length)), (chunks = chunks.get(prefix)))
3224
+ ) {
3225
+ resolveModelChunk(response, chunks, value, prefix);
3226
+ return;
3227
+ }
3228
+ }
3229
+ appendBackingEntry(response._formData, value, key);
3126
3230
  }
3127
3231
  function close(response) {
3128
3232
  reportGlobalError(response, Error("Connection closed."));
@@ -3203,44 +3307,41 @@ exports.createTemporaryReferenceSet = function () {
3203
3307
  };
3204
3308
  exports.decodeAction = function (body, serverManifest) {
3205
3309
  var formData = new FormData(),
3206
- action = null,
3207
- seenActions = new Set();
3310
+ maybeActionKey = null;
3208
3311
  body.forEach(function (value, key) {
3209
3312
  key.startsWith("$ACTION_")
3210
3313
  ? key.startsWith("$ACTION_REF_")
3211
- ? seenActions.has(key) ||
3212
- (seenActions.add(key),
3213
- (value = "$ACTION_" + key.slice(12) + ":"),
3214
- (value = decodeBoundActionMetaData(body, serverManifest, value)),
3215
- (action = loadServerReference(serverManifest, value)))
3216
- : key.startsWith("$ACTION_ID_") &&
3217
- !seenActions.has(key) &&
3218
- (seenActions.add(key),
3219
- (value = key.slice(11)),
3220
- (action = loadServerReference(serverManifest, {
3221
- id: value,
3222
- bound: null
3223
- })))
3314
+ ? (maybeActionKey = key)
3315
+ : key.startsWith("$ACTION_ID_") && (maybeActionKey = key)
3224
3316
  : formData.append(key, value);
3225
3317
  });
3226
- return null === action
3227
- ? null
3228
- : action.then(function (fn) {
3229
- return fn.bind(null, formData);
3230
- });
3318
+ if (null === maybeActionKey) return null;
3319
+ var actionKey = maybeActionKey,
3320
+ action = null;
3321
+ if (actionKey.startsWith("$ACTION_REF_"))
3322
+ (actionKey = "$ACTION_" + actionKey.slice(12) + ":"),
3323
+ (body = decodeBoundActionMetaData(body, serverManifest, actionKey)),
3324
+ (action = loadServerReference(serverManifest, body));
3325
+ else if (actionKey.startsWith("$ACTION_ID_"))
3326
+ (body = actionKey.slice(11)),
3327
+ (action = loadServerReference(serverManifest, { id: body, bound: null }));
3328
+ else throw Error("Cannot handle action key. This is a bug in React.");
3329
+ return action.then(function (fn) {
3330
+ return fn.bind(null, formData);
3331
+ });
3231
3332
  };
3232
3333
  exports.decodeFormState = function (actionResult, body, serverManifest) {
3233
3334
  var keyPath = body.get("$ACTION_KEY");
3234
3335
  if ("string" !== typeof keyPath) return Promise.resolve(null);
3235
- var metaData = null;
3336
+ var actionKey = null;
3236
3337
  body.forEach(function (value, key) {
3237
- key.startsWith("$ACTION_REF_") &&
3238
- ((value = "$ACTION_" + key.slice(12) + ":"),
3239
- (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
3338
+ key.startsWith("$ACTION_REF_") && (actionKey = key);
3240
3339
  });
3241
- if (null === metaData) return Promise.resolve(null);
3242
- var referenceId = metaData.id;
3243
- return Promise.resolve(metaData.bound).then(function (bound) {
3340
+ if (null === actionKey) return Promise.resolve(null);
3341
+ var formFieldPrefix = "$ACTION_" + actionKey.slice(12) + ":";
3342
+ body = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
3343
+ var referenceId = body.id;
3344
+ return Promise.resolve(body.bound).then(function (bound) {
3244
3345
  return null === bound
3245
3346
  ? null
3246
3347
  : [actionResult, keyPath, referenceId, bound.length - 1];
@@ -3270,28 +3371,32 @@ exports.decodeReplyFromBusboy = function (busboyStream, turbopackMap, options) {
3270
3371
  if (!current.complete) return;
3271
3372
  try {
3272
3373
  var key = current.name,
3273
- handle = current.file,
3274
- blob = new Blob(handle.chunks, { type: handle.mime }),
3275
- backingStore = response._formData,
3276
- key$jscomp$0 = key;
3277
- backingStore.data.append(key$jscomp$0, blob, handle.filename);
3278
- var keys = backingStore.keys;
3279
- null === keys
3280
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
3281
- (backingStore.keyPointer = 0))
3282
- : keys.push(key$jscomp$0);
3374
+ JSCompiler_temp_const = response._formData;
3375
+ var handle = current.file;
3376
+ if ("function" === typeof File)
3377
+ var JSCompiler_inline_result = new File(
3378
+ handle.chunks,
3379
+ handle.filename,
3380
+ { type: handle.mime }
3381
+ );
3382
+ else {
3383
+ var scratch = new FormData();
3384
+ scratch.append(
3385
+ "file",
3386
+ new Blob(handle.chunks, { type: handle.mime }),
3387
+ handle.filename
3388
+ );
3389
+ JSCompiler_inline_result = scratch.get("file");
3390
+ }
3391
+ appendBackingEntry(
3392
+ JSCompiler_temp_const,
3393
+ JSCompiler_inline_result,
3394
+ key
3395
+ );
3283
3396
  var queuedFields = current.queuedFields;
3284
3397
  if (null !== queuedFields)
3285
- for (
3286
- key$jscomp$0 = 0;
3287
- key$jscomp$0 < queuedFields.length;
3288
- key$jscomp$0 += 2
3289
- )
3290
- resolveField(
3291
- response,
3292
- queuedFields[key$jscomp$0],
3293
- queuedFields[key$jscomp$0 + 1]
3294
- );
3398
+ for (var i = 0; i < queuedFields.length; i += 2)
3399
+ resolveField(response, queuedFields[i], queuedFields[i + 1]);
3295
3400
  } catch (error) {
3296
3401
  busboyStream.destroy(error);
3297
3402
  return;