react-server-dom-turbopack 19.2.7 → 19.2.9

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.
@@ -14,8 +14,9 @@ var stream = require("stream"),
14
14
  require("crypto");
15
15
  var async_hooks = require("async_hooks"),
16
16
  ReactDOM = require("react-dom"),
17
- React = require("react"),
18
- REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
17
+ React = require("react");
18
+ function noop() {}
19
+ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
19
20
  REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
20
21
  REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
21
22
  REACT_CONTEXT_TYPE = Symbol.for("react.context"),
@@ -35,6 +36,11 @@ function getIteratorFn(maybeIterable) {
35
36
  return "function" === typeof maybeIterable ? maybeIterable : null;
36
37
  }
37
38
  var ASYNC_ITERATOR = Symbol.asyncIterator,
39
+ hasOwnProperty = Object.prototype.hasOwnProperty,
40
+ supportsArrayBufferDetached = hasOwnProperty.call(
41
+ ArrayBuffer.prototype,
42
+ "detached"
43
+ ),
38
44
  scheduleMicrotask = queueMicrotask,
39
45
  currentView = null,
40
46
  writtenBytes = 0,
@@ -76,33 +82,37 @@ function writeChunkAndReturn(destination, chunk) {
76
82
  (currentView = new Uint8Array(2048)),
77
83
  (writtenBytes = 0));
78
84
  }
85
+ } else if (0 === chunk.byteLength) {
86
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
87
+ throw Error(
88
+ "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()`."
89
+ );
79
90
  } else
80
- 0 !== chunk.byteLength &&
81
- (2048 < chunk.byteLength
82
- ? (0 < writtenBytes &&
83
- (writeToDestination(
84
- destination,
85
- currentView.subarray(0, writtenBytes)
86
- ),
87
- (currentView = new Uint8Array(2048)),
88
- (writtenBytes = 0)),
89
- writeToDestination(destination, chunk))
90
- : ((target = currentView.length - writtenBytes),
91
- target < chunk.byteLength &&
92
- (0 === target
93
- ? writeToDestination(destination, currentView)
94
- : (currentView.set(chunk.subarray(0, target), writtenBytes),
95
- (writtenBytes += target),
96
- writeToDestination(destination, currentView),
97
- (chunk = chunk.subarray(target))),
98
- (currentView = new Uint8Array(2048)),
99
- (writtenBytes = 0)),
100
- currentView.set(chunk, writtenBytes),
101
- (writtenBytes += chunk.byteLength),
102
- 2048 === writtenBytes &&
103
- (writeToDestination(destination, currentView),
104
- (currentView = new Uint8Array(2048)),
105
- (writtenBytes = 0))));
91
+ 2048 < chunk.byteLength
92
+ ? (0 < writtenBytes &&
93
+ (writeToDestination(
94
+ destination,
95
+ currentView.subarray(0, writtenBytes)
96
+ ),
97
+ (currentView = new Uint8Array(2048)),
98
+ (writtenBytes = 0)),
99
+ writeToDestination(destination, chunk))
100
+ : ((target = currentView.length - writtenBytes),
101
+ target < chunk.byteLength &&
102
+ (0 === target
103
+ ? writeToDestination(destination, currentView)
104
+ : (currentView.set(chunk.subarray(0, target), writtenBytes),
105
+ (writtenBytes += target),
106
+ writeToDestination(destination, currentView),
107
+ (chunk = chunk.subarray(target))),
108
+ (currentView = new Uint8Array(2048)),
109
+ (writtenBytes = 0)),
110
+ currentView.set(chunk, writtenBytes),
111
+ (writtenBytes += chunk.byteLength),
112
+ 2048 === writtenBytes &&
113
+ (writeToDestination(destination, currentView),
114
+ (currentView = new Uint8Array(2048)),
115
+ (writtenBytes = 0)));
106
116
  return destinationHasCapacity;
107
117
  }
108
118
  var textEncoder = new util.TextEncoder();
@@ -575,7 +585,6 @@ function createTemporaryReference(temporaryReferences, id) {
575
585
  temporaryReferences.set(reference, id);
576
586
  return reference;
577
587
  }
578
- function noop() {}
579
588
  var SuspenseException = Error(
580
589
  "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`."
581
590
  );
@@ -840,8 +849,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
840
849
  "\n " + str + "\n " + objectOrArray)
841
850
  : "\n " + str;
842
851
  }
843
- var hasOwnProperty = Object.prototype.hasOwnProperty,
844
- ObjectPrototype$1 = Object.prototype,
852
+ var ObjectPrototype$1 = Object.prototype,
845
853
  stringify = JSON.stringify;
846
854
  function defaultErrorHandler(error) {
847
855
  console.error(error);
@@ -1074,7 +1082,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
1074
1082
  erroredTask(request, streamTask, reason),
1075
1083
  enqueueFlush(request),
1076
1084
  "function" === typeof iterator.throw &&
1077
- iterator.throw(reason).then(error, error));
1085
+ iterator.throw(reason).then(noop, noop));
1078
1086
  }
1079
1087
  function abortIterable() {
1080
1088
  if (0 === streamTask.status) {
@@ -1088,7 +1096,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
1088
1096
  : (erroredTask(request, streamTask, signal.reason),
1089
1097
  enqueueFlush(request));
1090
1098
  "function" === typeof iterator.throw &&
1091
- iterator.throw(reason).then(error, error);
1099
+ iterator.throw(reason).then(noop, noop);
1092
1100
  }
1093
1101
  }
1094
1102
  iterable = iterable === iterator;
@@ -1857,11 +1865,28 @@ function emitErrorChunk(request, id, digest) {
1857
1865
  }
1858
1866
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1859
1867
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1860
- typedArray = new Uint8Array(
1861
- typedArray.buffer,
1862
- typedArray.byteOffset,
1863
- typedArray.byteLength
1864
- );
1868
+ a: {
1869
+ debug = new Uint8Array(
1870
+ typedArray.buffer,
1871
+ typedArray.byteOffset,
1872
+ typedArray.byteLength
1873
+ );
1874
+ if (2048 < typedArray.byteLength) {
1875
+ if (
1876
+ 0 !== typedArray.byteOffset ||
1877
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1878
+ typedArray.buffer.resizable
1879
+ ) {
1880
+ typedArray = debug.slice();
1881
+ break a;
1882
+ }
1883
+ if (!supportsArrayBufferDetached) {
1884
+ typedArray = debug.slice();
1885
+ break a;
1886
+ }
1887
+ }
1888
+ typedArray = debug;
1889
+ }
1865
1890
  debug = typedArray.byteLength;
1866
1891
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1867
1892
  request.completedRegularChunks.push(id, typedArray);
@@ -2275,13 +2300,37 @@ function requireModule(metadata) {
2275
2300
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2276
2301
  return moduleExports[metadata[2]];
2277
2302
  }
2278
- function appendBackingEntry(backingStore, key, value) {
2279
- backingStore.data.append(key, value);
2280
- value = backingStore.keys;
2281
- null === value
2282
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2283
- (backingStore.keyPointer = 0))
2284
- : value.push(key);
2303
+ function appendBackingEntry(backingStore, value, key) {
2304
+ var prefix = backingStore.prefix;
2305
+ if (key.startsWith(prefix)) {
2306
+ switch (key[prefix.length]) {
2307
+ case "_":
2308
+ prefix = backingStore.referencedEntries;
2309
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2310
+ prefix.push([key, value]);
2311
+ return;
2312
+ case "S":
2313
+ "string" === typeof value &&
2314
+ ((prefix = backingStore.streamChunks),
2315
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2316
+ (backingStore = prefix.get(key)),
2317
+ void 0 === backingStore
2318
+ ? prefix.set(key, [value])
2319
+ : backingStore.push(value));
2320
+ return;
2321
+ }
2322
+ "string" === typeof value
2323
+ ? ((prefix = backingStore.stringChunks),
2324
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2325
+ prefix.set(key, value))
2326
+ : ((prefix = backingStore.blobs),
2327
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2328
+ prefix.set(key, value));
2329
+ }
2330
+ }
2331
+ function getBackingBlob(backingStore, key) {
2332
+ backingStore = backingStore.blobs;
2333
+ return null === backingStore ? void 0 : backingStore.get(key);
2285
2334
  }
2286
2335
  var RESPONSE_SYMBOL = Symbol();
2287
2336
  function ReactPromise(status, value, reason) {
@@ -2654,15 +2703,18 @@ function reportGlobalError(response, error) {
2654
2703
  function getChunk(response, id) {
2655
2704
  var chunks = response._chunks,
2656
2705
  chunk = chunks.get(id);
2657
- chunk ||
2658
- ((chunk = response._formData.data.get(response._prefix + id)),
2659
- (chunk =
2706
+ if (!chunk) {
2707
+ chunk = response._prefix;
2708
+ var stringChunks = response._formData.stringChunks;
2709
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2710
+ chunk =
2660
2711
  "string" === typeof chunk
2661
2712
  ? createResolvedModelChunk(response, chunk, id)
2662
2713
  : response._closed
2663
2714
  ? new ReactPromise("rejected", null, response._closedReason)
2664
- : new ReactPromise("pending", null, null)),
2665
- chunks.set(id, chunk));
2715
+ : new ReactPromise("pending", null, null);
2716
+ chunks.set(id, chunk);
2717
+ }
2666
2718
  return chunk;
2667
2719
  }
2668
2720
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2893,7 +2945,7 @@ function parseTypedArray(
2893
2945
  Error("Already initialized typed array.")
2894
2946
  )
2895
2947
  );
2896
- reference = response._formData.data.get(key).arrayBuffer();
2948
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2897
2949
  if (initializingHandler) {
2898
2950
  var handler = initializingHandler;
2899
2951
  handler.deps++;
@@ -2937,13 +2989,15 @@ function resolveStream(response, id, stream, controller) {
2937
2989
  var chunks = response._chunks;
2938
2990
  stream = new ReactPromise("fulfilled", stream, controller);
2939
2991
  chunks.set(id, stream);
2940
- response = response._formData.data.getAll(response._prefix + id);
2941
- for (id = 0; id < response.length; id++)
2942
- (chunks = response[id]),
2943
- "string" === typeof chunks &&
2944
- ("C" === chunks[0]
2992
+ chunks = response._prefix;
2993
+ response = response._formData.streamChunks;
2994
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2995
+ if (void 0 !== id)
2996
+ for (response = 0; response < id.length; response++)
2997
+ (chunks = id[response]),
2998
+ "C" === chunks[0]
2945
2999
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2946
- : controller.enqueueModel(chunks));
3000
+ : controller.enqueueModel(chunks);
2947
3001
  }
2948
3002
  function parseReadableStream(response, reference, type) {
2949
3003
  function enqueue(value) {
@@ -3109,7 +3163,14 @@ function parseAsyncIterable(response, reference, iterator) {
3109
3163
  });
3110
3164
  return iterator;
3111
3165
  }
3112
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3166
+ function parseModelString(
3167
+ response,
3168
+ obj,
3169
+ key$jscomp$0,
3170
+ value,
3171
+ reference,
3172
+ arrayRoot
3173
+ ) {
3113
3174
  if ("$" === value[0]) {
3114
3175
  switch (value[1]) {
3115
3176
  case "$":
@@ -3127,7 +3188,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3127
3188
  response,
3128
3189
  arrayRoot,
3129
3190
  obj,
3130
- key,
3191
+ key$jscomp$0,
3131
3192
  null,
3132
3193
  loadServerReference$1
3133
3194
  )
@@ -3144,43 +3205,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3144
3205
  case "Q":
3145
3206
  return (
3146
3207
  (arrayRoot = value.slice(2)),
3147
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3208
+ getOutlinedModel(
3209
+ response,
3210
+ arrayRoot,
3211
+ obj,
3212
+ key$jscomp$0,
3213
+ null,
3214
+ createMap
3215
+ )
3148
3216
  );
3149
3217
  case "W":
3150
3218
  return (
3151
3219
  (arrayRoot = value.slice(2)),
3152
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3220
+ getOutlinedModel(
3221
+ response,
3222
+ arrayRoot,
3223
+ obj,
3224
+ key$jscomp$0,
3225
+ null,
3226
+ createSet
3227
+ )
3153
3228
  );
3154
3229
  case "K":
3155
- key = value.slice(2);
3156
- obj = response._prefix + "_";
3157
- key = obj + key + "_";
3158
- arrayRoot = new FormData();
3159
- for (response = response._formData; ; ) {
3160
- value = response.keys;
3161
- null === value &&
3162
- ((value = response.keys = Array.from(response.data.keys())),
3163
- (response.keyPointer = 0));
3164
- value = value[response.keyPointer];
3165
- if (void 0 === value) break;
3166
- if (value.startsWith(key)) {
3167
- reference = response.data.getAll(value);
3168
- for (
3169
- var referencedFormDataKey = value.slice(key.length), i = 0;
3170
- i < reference.length;
3171
- i++
3172
- )
3173
- arrayRoot.append(referencedFormDataKey, reference[i]);
3174
- response.data.delete(value);
3175
- response.keyPointer++;
3176
- } else if (value.startsWith(obj)) break;
3177
- else response.keyPointer++;
3230
+ obj = value.slice(2);
3231
+ obj = response._prefix + "_" + obj + "_";
3232
+ response = response._formData;
3233
+ key$jscomp$0 = new FormData();
3234
+ arrayRoot = response.referencedEntries;
3235
+ if (null !== arrayRoot) {
3236
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3237
+ reference = arrayRoot[value];
3238
+ var key = reference[0];
3239
+ if (!key.startsWith(obj)) break;
3240
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3241
+ value++;
3242
+ }
3243
+ response.keyPointer = value;
3178
3244
  }
3179
- return arrayRoot;
3245
+ return key$jscomp$0;
3180
3246
  case "i":
3181
3247
  return (
3182
3248
  (arrayRoot = value.slice(2)),
3183
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3249
+ getOutlinedModel(
3250
+ response,
3251
+ arrayRoot,
3252
+ obj,
3253
+ key$jscomp$0,
3254
+ null,
3255
+ extractIterator
3256
+ )
3184
3257
  );
3185
3258
  case "I":
3186
3259
  return Infinity;
@@ -3209,7 +3282,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3209
3282
  ArrayBuffer,
3210
3283
  1,
3211
3284
  obj,
3212
- key,
3285
+ key$jscomp$0,
3213
3286
  arrayRoot
3214
3287
  );
3215
3288
  case "O":
@@ -3219,7 +3292,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3219
3292
  Int8Array,
3220
3293
  1,
3221
3294
  obj,
3222
- key,
3295
+ key$jscomp$0,
3223
3296
  arrayRoot
3224
3297
  );
3225
3298
  case "o":
@@ -3229,7 +3302,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3229
3302
  Uint8Array,
3230
3303
  1,
3231
3304
  obj,
3232
- key,
3305
+ key$jscomp$0,
3233
3306
  arrayRoot
3234
3307
  );
3235
3308
  case "U":
@@ -3239,7 +3312,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3239
3312
  Uint8ClampedArray,
3240
3313
  1,
3241
3314
  obj,
3242
- key,
3315
+ key$jscomp$0,
3243
3316
  arrayRoot
3244
3317
  );
3245
3318
  case "S":
@@ -3249,7 +3322,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3249
3322
  Int16Array,
3250
3323
  2,
3251
3324
  obj,
3252
- key,
3325
+ key$jscomp$0,
3253
3326
  arrayRoot
3254
3327
  );
3255
3328
  case "s":
@@ -3259,7 +3332,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3259
3332
  Uint16Array,
3260
3333
  2,
3261
3334
  obj,
3262
- key,
3335
+ key$jscomp$0,
3263
3336
  arrayRoot
3264
3337
  );
3265
3338
  case "L":
@@ -3269,7 +3342,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3269
3342
  Int32Array,
3270
3343
  4,
3271
3344
  obj,
3272
- key,
3345
+ key$jscomp$0,
3273
3346
  arrayRoot
3274
3347
  );
3275
3348
  case "l":
@@ -3279,7 +3352,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3279
3352
  Uint32Array,
3280
3353
  4,
3281
3354
  obj,
3282
- key,
3355
+ key$jscomp$0,
3283
3356
  arrayRoot
3284
3357
  );
3285
3358
  case "G":
@@ -3289,7 +3362,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3289
3362
  Float32Array,
3290
3363
  4,
3291
3364
  obj,
3292
- key,
3365
+ key$jscomp$0,
3293
3366
  arrayRoot
3294
3367
  );
3295
3368
  case "g":
@@ -3299,7 +3372,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3299
3372
  Float64Array,
3300
3373
  8,
3301
3374
  obj,
3302
- key,
3375
+ key$jscomp$0,
3303
3376
  arrayRoot
3304
3377
  );
3305
3378
  case "M":
@@ -3309,7 +3382,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3309
3382
  BigInt64Array,
3310
3383
  8,
3311
3384
  obj,
3312
- key,
3385
+ key$jscomp$0,
3313
3386
  arrayRoot
3314
3387
  );
3315
3388
  case "m":
@@ -3319,7 +3392,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3319
3392
  BigUint64Array,
3320
3393
  8,
3321
3394
  obj,
3322
- key,
3395
+ key$jscomp$0,
3323
3396
  arrayRoot
3324
3397
  );
3325
3398
  case "V":
@@ -3329,13 +3402,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3329
3402
  DataView,
3330
3403
  1,
3331
3404
  obj,
3332
- key,
3405
+ key$jscomp$0,
3333
3406
  arrayRoot
3334
3407
  );
3335
3408
  case "B":
3336
3409
  return (
3337
3410
  (obj = parseInt(value.slice(2), 16)),
3338
- response._formData.data.get(response._prefix + obj)
3411
+ getBackingBlob(response._formData, response._prefix + obj)
3339
3412
  );
3340
3413
  case "R":
3341
3414
  return parseReadableStream(response, value, void 0);
@@ -3347,7 +3420,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3347
3420
  return parseAsyncIterable(response, value, !0);
3348
3421
  }
3349
3422
  value = value.slice(1);
3350
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3423
+ return getOutlinedModel(
3424
+ response,
3425
+ value,
3426
+ obj,
3427
+ key$jscomp$0,
3428
+ arrayRoot,
3429
+ createModel
3430
+ );
3351
3431
  }
3352
3432
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3353
3433
  return value;
@@ -3359,11 +3439,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3359
3439
  : new FormData(),
3360
3440
  arraySizeLimit =
3361
3441
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3362
- chunks = new Map();
3442
+ chunks = new Map(),
3443
+ backingStore = {
3444
+ prefix: formFieldPrefix,
3445
+ referencedEntries: null,
3446
+ keyPointer: 0,
3447
+ stringChunks: null,
3448
+ streamChunks: null,
3449
+ blobs: null
3450
+ };
3451
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3363
3452
  return {
3364
3453
  _bundlerConfig: bundlerConfig,
3365
3454
  _prefix: formFieldPrefix,
3366
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3455
+ _formData: backingStore,
3367
3456
  _chunks: chunks,
3368
3457
  _closed: !1,
3369
3458
  _closedReason: null,
@@ -3373,14 +3462,26 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3373
3462
  };
3374
3463
  }
3375
3464
  function resolveField(response, key, value) {
3376
- appendBackingEntry(response._formData, key, value);
3377
3465
  var prefix = response._prefix;
3378
3466
  if (key.startsWith(prefix)) {
3379
3467
  var chunks = response._chunks;
3380
- key = +key.slice(prefix.length);
3381
- (chunks = chunks.get(key)) &&
3382
- resolveModelChunk(response, chunks, value, key);
3468
+ if ("S" === key[prefix.length]) {
3469
+ if (
3470
+ key.length > prefix.length + 1 &&
3471
+ ((prefix = +key.slice(prefix.length + 1)),
3472
+ (chunks = chunks.get(prefix)))
3473
+ ) {
3474
+ resolveModelChunk(response, chunks, value, prefix);
3475
+ return;
3476
+ }
3477
+ } else if (
3478
+ ((prefix = +key.slice(prefix.length)), (chunks = chunks.get(prefix)))
3479
+ ) {
3480
+ resolveModelChunk(response, chunks, value, prefix);
3481
+ return;
3482
+ }
3383
3483
  }
3484
+ appendBackingEntry(response._formData, value, key);
3384
3485
  }
3385
3486
  function close(response) {
3386
3487
  reportGlobalError(response, Error("Connection closed."));
@@ -3478,44 +3579,41 @@ exports.createTemporaryReferenceSet = function () {
3478
3579
  };
3479
3580
  exports.decodeAction = function (body, serverManifest) {
3480
3581
  var formData = new FormData(),
3481
- action = null,
3482
- seenActions = new Set();
3582
+ maybeActionKey = null;
3483
3583
  body.forEach(function (value, key) {
3484
3584
  key.startsWith("$ACTION_")
3485
3585
  ? key.startsWith("$ACTION_REF_")
3486
- ? seenActions.has(key) ||
3487
- (seenActions.add(key),
3488
- (value = "$ACTION_" + key.slice(12) + ":"),
3489
- (value = decodeBoundActionMetaData(body, serverManifest, value)),
3490
- (action = loadServerReference(serverManifest, value)))
3491
- : key.startsWith("$ACTION_ID_") &&
3492
- !seenActions.has(key) &&
3493
- (seenActions.add(key),
3494
- (value = key.slice(11)),
3495
- (action = loadServerReference(serverManifest, {
3496
- id: value,
3497
- bound: null
3498
- })))
3586
+ ? (maybeActionKey = key)
3587
+ : key.startsWith("$ACTION_ID_") && (maybeActionKey = key)
3499
3588
  : formData.append(key, value);
3500
3589
  });
3501
- return null === action
3502
- ? null
3503
- : action.then(function (fn) {
3504
- return fn.bind(null, formData);
3505
- });
3590
+ if (null === maybeActionKey) return null;
3591
+ var actionKey = maybeActionKey,
3592
+ action = null;
3593
+ if (actionKey.startsWith("$ACTION_REF_"))
3594
+ (actionKey = "$ACTION_" + actionKey.slice(12) + ":"),
3595
+ (body = decodeBoundActionMetaData(body, serverManifest, actionKey)),
3596
+ (action = loadServerReference(serverManifest, body));
3597
+ else if (actionKey.startsWith("$ACTION_ID_"))
3598
+ (body = actionKey.slice(11)),
3599
+ (action = loadServerReference(serverManifest, { id: body, bound: null }));
3600
+ else throw Error("Cannot handle action key. This is a bug in React.");
3601
+ return action.then(function (fn) {
3602
+ return fn.bind(null, formData);
3603
+ });
3506
3604
  };
3507
3605
  exports.decodeFormState = function (actionResult, body, serverManifest) {
3508
3606
  var keyPath = body.get("$ACTION_KEY");
3509
3607
  if ("string" !== typeof keyPath) return Promise.resolve(null);
3510
- var metaData = null;
3608
+ var actionKey = null;
3511
3609
  body.forEach(function (value, key) {
3512
- key.startsWith("$ACTION_REF_") &&
3513
- ((value = "$ACTION_" + key.slice(12) + ":"),
3514
- (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
3610
+ key.startsWith("$ACTION_REF_") && (actionKey = key);
3515
3611
  });
3516
- if (null === metaData) return Promise.resolve(null);
3517
- var referenceId = metaData.id;
3518
- return Promise.resolve(metaData.bound).then(function (bound) {
3612
+ if (null === actionKey) return Promise.resolve(null);
3613
+ var formFieldPrefix = "$ACTION_" + actionKey.slice(12) + ":";
3614
+ body = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
3615
+ var referenceId = body.id;
3616
+ return Promise.resolve(body.bound).then(function (bound) {
3519
3617
  return null === bound
3520
3618
  ? null
3521
3619
  : [actionResult, keyPath, referenceId, bound.length - 1];
@@ -3551,14 +3649,14 @@ exports.decodeReplyFromAsyncIterable = function (
3551
3649
  _entry$value = _entry$value[1];
3552
3650
  "string" === typeof _entry$value
3553
3651
  ? resolveField(response, entry, _entry$value)
3554
- : appendBackingEntry(response._formData, entry, _entry$value);
3652
+ : appendBackingEntry(response._formData, _entry$value, entry);
3555
3653
  iterator.next().then(progress, error);
3556
3654
  }
3557
3655
  }
3558
3656
  function error(reason) {
3559
3657
  reportGlobalError(response, reason);
3560
3658
  "function" === typeof iterator.throw &&
3561
- iterator.throw(reason).then(error, error);
3659
+ iterator.throw(reason).then(noop, noop);
3562
3660
  }
3563
3661
  var iterator = iterable[ASYNC_ITERATOR](),
3564
3662
  response = createResponse(
@@ -3578,28 +3676,32 @@ exports.decodeReplyFromBusboy = function (busboyStream, turbopackMap, options) {
3578
3676
  if (!current.complete) return;
3579
3677
  try {
3580
3678
  var key = current.name,
3581
- handle = current.file,
3582
- blob = new Blob(handle.chunks, { type: handle.mime }),
3583
- backingStore = response._formData,
3584
- key$jscomp$0 = key;
3585
- backingStore.data.append(key$jscomp$0, blob, handle.filename);
3586
- var keys = backingStore.keys;
3587
- null === keys
3588
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
3589
- (backingStore.keyPointer = 0))
3590
- : keys.push(key$jscomp$0);
3679
+ JSCompiler_temp_const = response._formData;
3680
+ var handle = current.file;
3681
+ if ("function" === typeof File)
3682
+ var JSCompiler_inline_result = new File(
3683
+ handle.chunks,
3684
+ handle.filename,
3685
+ { type: handle.mime }
3686
+ );
3687
+ else {
3688
+ var scratch = new FormData();
3689
+ scratch.append(
3690
+ "file",
3691
+ new Blob(handle.chunks, { type: handle.mime }),
3692
+ handle.filename
3693
+ );
3694
+ JSCompiler_inline_result = scratch.get("file");
3695
+ }
3696
+ appendBackingEntry(
3697
+ JSCompiler_temp_const,
3698
+ JSCompiler_inline_result,
3699
+ key
3700
+ );
3591
3701
  var queuedFields = current.queuedFields;
3592
3702
  if (null !== queuedFields)
3593
- for (
3594
- key$jscomp$0 = 0;
3595
- key$jscomp$0 < queuedFields.length;
3596
- key$jscomp$0 += 2
3597
- )
3598
- resolveField(
3599
- response,
3600
- queuedFields[key$jscomp$0],
3601
- queuedFields[key$jscomp$0 + 1]
3602
- );
3703
+ for (var i = 0; i < queuedFields.length; i += 2)
3704
+ resolveField(response, queuedFields[i], queuedFields[i + 1]);
3603
3705
  } catch (error) {
3604
3706
  busboyStream.destroy(error);
3605
3707
  return;