react-server-dom-webpack 19.0.7 → 19.0.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,6 +14,11 @@ require("crypto");
14
14
  var async_hooks = require("async_hooks"),
15
15
  ReactDOM = require("react-dom"),
16
16
  React = require("react"),
17
+ hasOwnProperty = Object.prototype.hasOwnProperty,
18
+ supportsArrayBufferDetached = hasOwnProperty.call(
19
+ ArrayBuffer.prototype,
20
+ "detached"
21
+ ),
17
22
  scheduleMicrotask = queueMicrotask,
18
23
  currentView = null,
19
24
  writtenBytes = 0,
@@ -55,33 +60,37 @@ function writeChunkAndReturn(destination, chunk) {
55
60
  (currentView = new Uint8Array(2048)),
56
61
  (writtenBytes = 0));
57
62
  }
63
+ } else if (0 === chunk.byteLength) {
64
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
65
+ throw Error(
66
+ "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()`."
67
+ );
58
68
  } else
59
- 0 !== chunk.byteLength &&
60
- (2048 < chunk.byteLength
61
- ? (0 < writtenBytes &&
62
- (writeToDestination(
63
- destination,
64
- currentView.subarray(0, writtenBytes)
65
- ),
66
- (currentView = new Uint8Array(2048)),
67
- (writtenBytes = 0)),
68
- writeToDestination(destination, chunk))
69
- : ((target = currentView.length - writtenBytes),
70
- target < chunk.byteLength &&
71
- (0 === target
72
- ? writeToDestination(destination, currentView)
73
- : (currentView.set(chunk.subarray(0, target), writtenBytes),
74
- (writtenBytes += target),
75
- writeToDestination(destination, currentView),
76
- (chunk = chunk.subarray(target))),
77
- (currentView = new Uint8Array(2048)),
78
- (writtenBytes = 0)),
79
- currentView.set(chunk, writtenBytes),
80
- (writtenBytes += chunk.byteLength),
81
- 2048 === writtenBytes &&
82
- (writeToDestination(destination, currentView),
83
- (currentView = new Uint8Array(2048)),
84
- (writtenBytes = 0))));
69
+ 2048 < chunk.byteLength
70
+ ? (0 < writtenBytes &&
71
+ (writeToDestination(
72
+ destination,
73
+ currentView.subarray(0, writtenBytes)
74
+ ),
75
+ (currentView = new Uint8Array(2048)),
76
+ (writtenBytes = 0)),
77
+ writeToDestination(destination, chunk))
78
+ : ((target = currentView.length - writtenBytes),
79
+ target < chunk.byteLength &&
80
+ (0 === target
81
+ ? writeToDestination(destination, currentView)
82
+ : (currentView.set(chunk.subarray(0, target), writtenBytes),
83
+ (writtenBytes += target),
84
+ writeToDestination(destination, currentView),
85
+ (chunk = chunk.subarray(target))),
86
+ (currentView = new Uint8Array(2048)),
87
+ (writtenBytes = 0)),
88
+ currentView.set(chunk, writtenBytes),
89
+ (writtenBytes += chunk.byteLength),
90
+ 2048 === writtenBytes &&
91
+ (writeToDestination(destination, currentView),
92
+ (currentView = new Uint8Array(2048)),
93
+ (writtenBytes = 0)));
85
94
  return destinationHasCapacity;
86
95
  }
87
96
  var textEncoder = new util.TextEncoder();
@@ -956,7 +965,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
956
965
  emitErrorChunk(request, streamTask.id, digest);
957
966
  enqueueFlush(request);
958
967
  "function" === typeof iterator.throw &&
959
- iterator.throw(reason).then(error, error);
968
+ iterator.throw(reason).then(noop, noop);
960
969
  }
961
970
  }
962
971
  function abortIterable(reason) {
@@ -967,7 +976,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
967
976
  emitErrorChunk(request, streamTask.id, digest);
968
977
  enqueueFlush(request);
969
978
  "function" === typeof iterator.throw &&
970
- iterator.throw(reason).then(error, error);
979
+ iterator.throw(reason).then(noop, noop);
971
980
  }
972
981
  }
973
982
  iterable = iterable === iterator;
@@ -1696,13 +1705,30 @@ function emitModelChunk(request, id, json) {
1696
1705
  }
1697
1706
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1698
1707
  request.pendingChunks++;
1699
- typedArray = new Uint8Array(
1700
- typedArray.buffer,
1701
- typedArray.byteOffset,
1702
- typedArray.byteLength
1703
- );
1704
- var binaryLength = typedArray.byteLength;
1705
- id = id.toString(16) + ":" + tag + binaryLength.toString(16) + ",";
1708
+ a: {
1709
+ var view = new Uint8Array(
1710
+ typedArray.buffer,
1711
+ typedArray.byteOffset,
1712
+ typedArray.byteLength
1713
+ );
1714
+ if (2048 < typedArray.byteLength) {
1715
+ if (
1716
+ 0 !== typedArray.byteOffset ||
1717
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1718
+ typedArray.buffer.resizable
1719
+ ) {
1720
+ typedArray = view.slice();
1721
+ break a;
1722
+ }
1723
+ if (!supportsArrayBufferDetached) {
1724
+ typedArray = view.slice();
1725
+ break a;
1726
+ }
1727
+ }
1728
+ typedArray = view;
1729
+ }
1730
+ view = typedArray.byteLength;
1731
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1706
1732
  request.completedRegularChunks.push(id, typedArray);
1707
1733
  }
1708
1734
  function emitTextChunk(request, id, text) {
@@ -1974,7 +2000,6 @@ function abort(request, reason) {
1974
2000
  logRecoverableError(request, error$27, null), fatalError(request, error$27);
1975
2001
  }
1976
2002
  }
1977
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1978
2003
  function resolveServerReference(bundlerConfig, id) {
1979
2004
  var name = "",
1980
2005
  resolvedModuleData = bundlerConfig[id];
@@ -2048,6 +2073,38 @@ function requireModule(metadata) {
2048
2073
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2049
2074
  return moduleExports[metadata[2]];
2050
2075
  }
2076
+ function appendBackingEntry(backingStore, value, key) {
2077
+ var prefix = backingStore.prefix;
2078
+ if (key.startsWith(prefix)) {
2079
+ switch (key[prefix.length]) {
2080
+ case "_":
2081
+ prefix = backingStore.referencedEntries;
2082
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2083
+ prefix.push([key, value]);
2084
+ return;
2085
+ case "S":
2086
+ "string" === typeof value &&
2087
+ ((prefix = backingStore.streamChunks),
2088
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2089
+ (backingStore = prefix.get(key)),
2090
+ void 0 === backingStore
2091
+ ? prefix.set(key, [value])
2092
+ : backingStore.push(value));
2093
+ return;
2094
+ }
2095
+ "string" === typeof value
2096
+ ? ((prefix = backingStore.stringChunks),
2097
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2098
+ prefix.set(key, value))
2099
+ : ((prefix = backingStore.blobs),
2100
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2101
+ prefix.set(key, value));
2102
+ }
2103
+ }
2104
+ function getBackingBlob(backingStore, key) {
2105
+ backingStore = backingStore.blobs;
2106
+ return null === backingStore ? void 0 : backingStore.get(key);
2107
+ }
2051
2108
  var RESPONSE_SYMBOL = Symbol();
2052
2109
  function ReactPromise(status, value, reason) {
2053
2110
  this.status = status;
@@ -2417,13 +2474,16 @@ function reportGlobalError(response, error) {
2417
2474
  function getChunk(response, id) {
2418
2475
  var chunks = response._chunks,
2419
2476
  chunk = chunks.get(id);
2420
- chunk ||
2421
- ((chunk = response._formData.data.get(response._prefix + id)),
2422
- (chunk =
2477
+ if (!chunk) {
2478
+ chunk = response._prefix;
2479
+ var stringChunks = response._formData.stringChunks;
2480
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2481
+ chunk =
2423
2482
  "string" === typeof chunk
2424
2483
  ? createResolvedModelChunk(response, chunk, id)
2425
- : new ReactPromise("pending", null, null)),
2426
- chunks.set(id, chunk));
2484
+ : new ReactPromise("pending", null, null);
2485
+ chunks.set(id, chunk);
2486
+ }
2427
2487
  return chunk;
2428
2488
  }
2429
2489
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2654,7 +2714,7 @@ function parseTypedArray(
2654
2714
  Error("Already initialized typed array.")
2655
2715
  )
2656
2716
  );
2657
- reference = response._formData.data.get(key).arrayBuffer();
2717
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2658
2718
  if (initializingHandler) {
2659
2719
  var handler = initializingHandler;
2660
2720
  handler.deps++;
@@ -2698,13 +2758,15 @@ function resolveStream(response, id, stream, controller) {
2698
2758
  var chunks = response._chunks;
2699
2759
  stream = new ReactPromise("fulfilled", stream, controller);
2700
2760
  chunks.set(id, stream);
2701
- response = response._formData.data.getAll(response._prefix + id);
2702
- for (id = 0; id < response.length; id++)
2703
- (chunks = response[id]),
2704
- "string" === typeof chunks &&
2705
- ("C" === chunks[0]
2761
+ chunks = response._prefix;
2762
+ response = response._formData.streamChunks;
2763
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2764
+ if (void 0 !== id)
2765
+ for (response = 0; response < id.length; response++)
2766
+ (chunks = id[response]),
2767
+ "C" === chunks[0]
2706
2768
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2707
- : controller.enqueueModel(chunks));
2769
+ : controller.enqueueModel(chunks);
2708
2770
  }
2709
2771
  function parseReadableStream(response, reference, type) {
2710
2772
  function enqueue(value) {
@@ -2870,7 +2932,14 @@ function parseAsyncIterable(response, reference, iterator) {
2870
2932
  });
2871
2933
  return iterator;
2872
2934
  }
2873
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2935
+ function parseModelString(
2936
+ response,
2937
+ obj,
2938
+ key$jscomp$0,
2939
+ value,
2940
+ reference,
2941
+ arrayRoot
2942
+ ) {
2874
2943
  if ("$" === value[0]) {
2875
2944
  switch (value[1]) {
2876
2945
  case "$":
@@ -2888,7 +2957,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2888
2957
  response,
2889
2958
  arrayRoot,
2890
2959
  obj,
2891
- key,
2960
+ key$jscomp$0,
2892
2961
  null,
2893
2962
  loadServerReference$1
2894
2963
  )
@@ -2905,43 +2974,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2905
2974
  case "Q":
2906
2975
  return (
2907
2976
  (arrayRoot = value.slice(2)),
2908
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2977
+ getOutlinedModel(
2978
+ response,
2979
+ arrayRoot,
2980
+ obj,
2981
+ key$jscomp$0,
2982
+ null,
2983
+ createMap
2984
+ )
2909
2985
  );
2910
2986
  case "W":
2911
2987
  return (
2912
2988
  (arrayRoot = value.slice(2)),
2913
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2989
+ getOutlinedModel(
2990
+ response,
2991
+ arrayRoot,
2992
+ obj,
2993
+ key$jscomp$0,
2994
+ null,
2995
+ createSet
2996
+ )
2914
2997
  );
2915
2998
  case "K":
2916
- key = value.slice(2);
2917
- obj = response._prefix + "_";
2918
- key = obj + key + "_";
2919
- arrayRoot = new FormData();
2920
- for (response = response._formData; ; ) {
2921
- value = response.keys;
2922
- null === value &&
2923
- ((value = response.keys = Array.from(response.data.keys())),
2924
- (response.keyPointer = 0));
2925
- value = value[response.keyPointer];
2926
- if (void 0 === value) break;
2927
- if (value.startsWith(key)) {
2928
- reference = response.data.getAll(value);
2929
- for (
2930
- var referencedFormDataKey = value.slice(key.length), i = 0;
2931
- i < reference.length;
2932
- i++
2933
- )
2934
- arrayRoot.append(referencedFormDataKey, reference[i]);
2935
- response.data.delete(value);
2936
- response.keyPointer++;
2937
- } else if (value.startsWith(obj)) break;
2938
- else response.keyPointer++;
2999
+ obj = value.slice(2);
3000
+ obj = response._prefix + "_" + obj + "_";
3001
+ response = response._formData;
3002
+ key$jscomp$0 = new FormData();
3003
+ arrayRoot = response.referencedEntries;
3004
+ if (null !== arrayRoot) {
3005
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3006
+ reference = arrayRoot[value];
3007
+ var key = reference[0];
3008
+ if (!key.startsWith(obj)) break;
3009
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3010
+ value++;
3011
+ }
3012
+ response.keyPointer = value;
2939
3013
  }
2940
- return arrayRoot;
3014
+ return key$jscomp$0;
2941
3015
  case "i":
2942
3016
  return (
2943
3017
  (arrayRoot = value.slice(2)),
2944
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3018
+ getOutlinedModel(
3019
+ response,
3020
+ arrayRoot,
3021
+ obj,
3022
+ key$jscomp$0,
3023
+ null,
3024
+ extractIterator
3025
+ )
2945
3026
  );
2946
3027
  case "I":
2947
3028
  return Infinity;
@@ -2972,7 +3053,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2972
3053
  ArrayBuffer,
2973
3054
  1,
2974
3055
  obj,
2975
- key,
3056
+ key$jscomp$0,
2976
3057
  arrayRoot
2977
3058
  );
2978
3059
  case "O":
@@ -2982,7 +3063,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2982
3063
  Int8Array,
2983
3064
  1,
2984
3065
  obj,
2985
- key,
3066
+ key$jscomp$0,
2986
3067
  arrayRoot
2987
3068
  );
2988
3069
  case "o":
@@ -2992,7 +3073,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2992
3073
  Uint8Array,
2993
3074
  1,
2994
3075
  obj,
2995
- key,
3076
+ key$jscomp$0,
2996
3077
  arrayRoot
2997
3078
  );
2998
3079
  case "U":
@@ -3002,7 +3083,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3002
3083
  Uint8ClampedArray,
3003
3084
  1,
3004
3085
  obj,
3005
- key,
3086
+ key$jscomp$0,
3006
3087
  arrayRoot
3007
3088
  );
3008
3089
  case "S":
@@ -3012,7 +3093,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3012
3093
  Int16Array,
3013
3094
  2,
3014
3095
  obj,
3015
- key,
3096
+ key$jscomp$0,
3016
3097
  arrayRoot
3017
3098
  );
3018
3099
  case "s":
@@ -3022,7 +3103,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3022
3103
  Uint16Array,
3023
3104
  2,
3024
3105
  obj,
3025
- key,
3106
+ key$jscomp$0,
3026
3107
  arrayRoot
3027
3108
  );
3028
3109
  case "L":
@@ -3032,7 +3113,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3032
3113
  Int32Array,
3033
3114
  4,
3034
3115
  obj,
3035
- key,
3116
+ key$jscomp$0,
3036
3117
  arrayRoot
3037
3118
  );
3038
3119
  case "l":
@@ -3042,7 +3123,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3042
3123
  Uint32Array,
3043
3124
  4,
3044
3125
  obj,
3045
- key,
3126
+ key$jscomp$0,
3046
3127
  arrayRoot
3047
3128
  );
3048
3129
  case "G":
@@ -3052,7 +3133,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3052
3133
  Float32Array,
3053
3134
  4,
3054
3135
  obj,
3055
- key,
3136
+ key$jscomp$0,
3056
3137
  arrayRoot
3057
3138
  );
3058
3139
  case "g":
@@ -3062,7 +3143,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3062
3143
  Float64Array,
3063
3144
  8,
3064
3145
  obj,
3065
- key,
3146
+ key$jscomp$0,
3066
3147
  arrayRoot
3067
3148
  );
3068
3149
  case "M":
@@ -3072,7 +3153,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3072
3153
  BigInt64Array,
3073
3154
  8,
3074
3155
  obj,
3075
- key,
3156
+ key$jscomp$0,
3076
3157
  arrayRoot
3077
3158
  );
3078
3159
  case "m":
@@ -3082,7 +3163,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3082
3163
  BigUint64Array,
3083
3164
  8,
3084
3165
  obj,
3085
- key,
3166
+ key$jscomp$0,
3086
3167
  arrayRoot
3087
3168
  );
3088
3169
  case "V":
@@ -3092,13 +3173,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3092
3173
  DataView,
3093
3174
  1,
3094
3175
  obj,
3095
- key,
3176
+ key$jscomp$0,
3096
3177
  arrayRoot
3097
3178
  );
3098
3179
  case "B":
3099
3180
  return (
3100
3181
  (obj = parseInt(value.slice(2), 16)),
3101
- response._formData.data.get(response._prefix + obj)
3182
+ getBackingBlob(response._formData, response._prefix + obj)
3102
3183
  );
3103
3184
  }
3104
3185
  switch (value[1]) {
@@ -3112,7 +3193,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3112
3193
  return parseAsyncIterable(response, value, !0);
3113
3194
  }
3114
3195
  value = value.slice(1);
3115
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3196
+ return getOutlinedModel(
3197
+ response,
3198
+ value,
3199
+ obj,
3200
+ key$jscomp$0,
3201
+ arrayRoot,
3202
+ createModel
3203
+ );
3116
3204
  }
3117
3205
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3118
3206
  return value;
@@ -3124,11 +3212,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3124
3212
  : new FormData(),
3125
3213
  arraySizeLimit =
3126
3214
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3127
- chunks = new Map();
3215
+ chunks = new Map(),
3216
+ backingStore = {
3217
+ prefix: formFieldPrefix,
3218
+ referencedEntries: null,
3219
+ keyPointer: 0,
3220
+ stringChunks: null,
3221
+ streamChunks: null,
3222
+ blobs: null
3223
+ };
3224
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3128
3225
  return {
3129
3226
  _bundlerConfig: bundlerConfig,
3130
3227
  _prefix: formFieldPrefix,
3131
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3228
+ _formData: backingStore,
3132
3229
  _chunks: chunks,
3133
3230
  _temporaryReferences: temporaryReferences,
3134
3231
  _rootArrayContexts: new WeakMap(),
@@ -3136,19 +3233,26 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3136
3233
  };
3137
3234
  }
3138
3235
  function resolveField(response, key, value) {
3139
- var backingStore = response._formData;
3140
- backingStore.data.append(key, value);
3141
- var keys = backingStore.keys;
3142
- null === keys
3143
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
3144
- (backingStore.keyPointer = 0))
3145
- : keys.push(key);
3146
- keys = response._prefix;
3147
- key.startsWith(keys) &&
3148
- ((backingStore = response._chunks),
3149
- (key = +key.slice(keys.length)),
3150
- (backingStore = backingStore.get(key)) &&
3151
- resolveModelChunk(response, backingStore, value, key));
3236
+ var prefix = response._prefix;
3237
+ if (key.startsWith(prefix)) {
3238
+ var chunks = response._chunks;
3239
+ if ("S" === key[prefix.length]) {
3240
+ if (
3241
+ key.length > prefix.length + 1 &&
3242
+ ((prefix = +key.slice(prefix.length + 1)),
3243
+ (chunks = chunks.get(prefix)))
3244
+ ) {
3245
+ resolveModelChunk(response, chunks, value, prefix);
3246
+ return;
3247
+ }
3248
+ } else if (
3249
+ ((prefix = +key.slice(prefix.length)), (chunks = chunks.get(prefix)))
3250
+ ) {
3251
+ resolveModelChunk(response, chunks, value, prefix);
3252
+ return;
3253
+ }
3254
+ }
3255
+ appendBackingEntry(response._formData, value, key);
3152
3256
  }
3153
3257
  function close(response) {
3154
3258
  reportGlobalError(response, Error("Connection closed."));
@@ -3216,44 +3320,41 @@ exports.createTemporaryReferenceSet = function () {
3216
3320
  };
3217
3321
  exports.decodeAction = function (body, serverManifest) {
3218
3322
  var formData = new FormData(),
3219
- action = null,
3220
- seenActions = new Set();
3323
+ maybeActionKey = null;
3221
3324
  body.forEach(function (value, key) {
3222
3325
  key.startsWith("$ACTION_")
3223
3326
  ? key.startsWith("$ACTION_REF_")
3224
- ? seenActions.has(key) ||
3225
- (seenActions.add(key),
3226
- (value = "$ACTION_" + key.slice(12) + ":"),
3227
- (value = decodeBoundActionMetaData(body, serverManifest, value)),
3228
- (action = loadServerReference(serverManifest, value)))
3229
- : key.startsWith("$ACTION_ID_") &&
3230
- !seenActions.has(key) &&
3231
- (seenActions.add(key),
3232
- (value = key.slice(11)),
3233
- (action = loadServerReference(serverManifest, {
3234
- id: value,
3235
- bound: null
3236
- })))
3327
+ ? (maybeActionKey = key)
3328
+ : key.startsWith("$ACTION_ID_") && (maybeActionKey = key)
3237
3329
  : formData.append(key, value);
3238
3330
  });
3239
- return null === action
3240
- ? null
3241
- : action.then(function (fn) {
3242
- return fn.bind(null, formData);
3243
- });
3331
+ if (null === maybeActionKey) return null;
3332
+ var actionKey = maybeActionKey,
3333
+ action = null;
3334
+ if (actionKey.startsWith("$ACTION_REF_"))
3335
+ (actionKey = "$ACTION_" + actionKey.slice(12) + ":"),
3336
+ (body = decodeBoundActionMetaData(body, serverManifest, actionKey)),
3337
+ (action = loadServerReference(serverManifest, body));
3338
+ else if (actionKey.startsWith("$ACTION_ID_"))
3339
+ (body = actionKey.slice(11)),
3340
+ (action = loadServerReference(serverManifest, { id: body, bound: null }));
3341
+ else throw Error("Cannot handle action key. This is a bug in React.");
3342
+ return action.then(function (fn) {
3343
+ return fn.bind(null, formData);
3344
+ });
3244
3345
  };
3245
3346
  exports.decodeFormState = function (actionResult, body, serverManifest) {
3246
3347
  var keyPath = body.get("$ACTION_KEY");
3247
3348
  if ("string" !== typeof keyPath) return Promise.resolve(null);
3248
- var metaData = null;
3349
+ var actionKey = null;
3249
3350
  body.forEach(function (value, key) {
3250
- key.startsWith("$ACTION_REF_") &&
3251
- ((value = "$ACTION_" + key.slice(12) + ":"),
3252
- (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
3351
+ key.startsWith("$ACTION_REF_") && (actionKey = key);
3253
3352
  });
3254
- if (null === metaData) return Promise.resolve(null);
3255
- var referenceId = metaData.id;
3256
- return Promise.resolve(metaData.bound).then(function (bound) {
3353
+ if (null === actionKey) return Promise.resolve(null);
3354
+ var formFieldPrefix = "$ACTION_" + actionKey.slice(12) + ":";
3355
+ body = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
3356
+ var referenceId = body.id;
3357
+ return Promise.resolve(body.bound).then(function (bound) {
3257
3358
  return null === bound
3258
3359
  ? null
3259
3360
  : [actionResult, keyPath, referenceId, bound.length - 1];
@@ -3283,28 +3384,32 @@ exports.decodeReplyFromBusboy = function (busboyStream, webpackMap, options) {
3283
3384
  if (!current.complete) return;
3284
3385
  try {
3285
3386
  var key = current.name,
3286
- handle = current.file,
3287
- blob = new Blob(handle.chunks, { type: handle.mime }),
3288
- backingStore = response._formData,
3289
- key$jscomp$0 = key;
3290
- backingStore.data.append(key$jscomp$0, blob, handle.filename);
3291
- var keys = backingStore.keys;
3292
- null === keys
3293
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
3294
- (backingStore.keyPointer = 0))
3295
- : keys.push(key$jscomp$0);
3387
+ JSCompiler_temp_const = response._formData;
3388
+ var handle = current.file;
3389
+ if ("function" === typeof File)
3390
+ var JSCompiler_inline_result = new File(
3391
+ handle.chunks,
3392
+ handle.filename,
3393
+ { type: handle.mime }
3394
+ );
3395
+ else {
3396
+ var scratch = new FormData();
3397
+ scratch.append(
3398
+ "file",
3399
+ new Blob(handle.chunks, { type: handle.mime }),
3400
+ handle.filename
3401
+ );
3402
+ JSCompiler_inline_result = scratch.get("file");
3403
+ }
3404
+ appendBackingEntry(
3405
+ JSCompiler_temp_const,
3406
+ JSCompiler_inline_result,
3407
+ key
3408
+ );
3296
3409
  var queuedFields = current.queuedFields;
3297
3410
  if (null !== queuedFields)
3298
- for (
3299
- key$jscomp$0 = 0;
3300
- key$jscomp$0 < queuedFields.length;
3301
- key$jscomp$0 += 2
3302
- )
3303
- resolveField(
3304
- response,
3305
- queuedFields[key$jscomp$0],
3306
- queuedFields[key$jscomp$0 + 1]
3307
- );
3411
+ for (var i = 0; i < queuedFields.length; i += 2)
3412
+ resolveField(response, queuedFields[i], queuedFields[i + 1]);
3308
3413
  } catch (error) {
3309
3414
  busboyStream.destroy(error);
3310
3415
  return;