react-server-dom-parcel 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.
@@ -43,6 +43,10 @@ channel.port1.onmessage = function () {
43
43
  var task = taskQueue.shift();
44
44
  task && task();
45
45
  };
46
+ var supportsArrayBufferDetached = hasOwnProperty.call(
47
+ ArrayBuffer.prototype,
48
+ "detached"
49
+ );
46
50
  function scheduleWork(callback) {
47
51
  taskQueue.push(callback);
48
52
  channel.port2.postMessage(null);
@@ -64,28 +68,30 @@ var LocalPromise = Promise,
64
68
  currentView = null,
65
69
  writtenBytes = 0;
66
70
  function writeChunkAndReturn(destination, chunk) {
67
- if (0 !== chunk.byteLength)
68
- if (2048 < chunk.byteLength)
69
- 0 < writtenBytes &&
70
- (destination.enqueue(
71
- new Uint8Array(currentView.buffer, 0, writtenBytes)
72
- ),
73
- (currentView = new Uint8Array(2048)),
74
- (writtenBytes = 0)),
75
- destination.enqueue(chunk);
76
- else {
77
- var allowableBytes = currentView.length - writtenBytes;
78
- allowableBytes < chunk.byteLength &&
79
- (0 === allowableBytes
80
- ? destination.enqueue(currentView)
81
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
82
- destination.enqueue(currentView),
83
- (chunk = chunk.subarray(allowableBytes))),
84
- (currentView = new Uint8Array(2048)),
85
- (writtenBytes = 0));
86
- currentView.set(chunk, writtenBytes);
87
- writtenBytes += chunk.byteLength;
88
- }
71
+ if (0 === chunk.byteLength) {
72
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
73
+ throw Error(
74
+ "Cannot transport a detached buffer. This usually happens when trying to transport multiple buffer-spanning views on the same underyling buffer. Either reuse the exact same view by identity or copy the underlying buffer manually via `view.slice()`."
75
+ );
76
+ } else if (2048 < chunk.byteLength)
77
+ 0 < writtenBytes &&
78
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
79
+ (currentView = new Uint8Array(2048)),
80
+ (writtenBytes = 0)),
81
+ destination.enqueue(chunk);
82
+ else {
83
+ var allowableBytes = currentView.length - writtenBytes;
84
+ allowableBytes < chunk.byteLength &&
85
+ (0 === allowableBytes
86
+ ? destination.enqueue(currentView)
87
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
88
+ destination.enqueue(currentView),
89
+ (chunk = chunk.subarray(allowableBytes))),
90
+ (currentView = new Uint8Array(2048)),
91
+ (writtenBytes = 0));
92
+ currentView.set(chunk, writtenBytes);
93
+ writtenBytes += chunk.byteLength;
94
+ }
89
95
  return !0;
90
96
  }
91
97
  var textEncoder = new TextEncoder();
@@ -929,7 +935,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
929
935
  erroredTask(request, streamTask, reason),
930
936
  enqueueFlush(request),
931
937
  "function" === typeof iterator.throw &&
932
- iterator.throw(reason).then(error, error));
938
+ iterator.throw(reason).then(noop, noop));
933
939
  }
934
940
  function abortIterable() {
935
941
  if (0 === streamTask.status) {
@@ -943,7 +949,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
943
949
  : (erroredTask(request, streamTask, signal.reason),
944
950
  enqueueFlush(request));
945
951
  "function" === typeof iterator.throw &&
946
- iterator.throw(reason).then(error, error);
952
+ iterator.throw(reason).then(noop, noop);
947
953
  }
948
954
  }
949
955
  iterable = iterable === iterator;
@@ -1705,12 +1711,28 @@ function emitModelChunk(request, id, json) {
1705
1711
  }
1706
1712
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1707
1713
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1708
- debug = new Uint8Array(
1709
- typedArray.buffer,
1710
- typedArray.byteOffset,
1711
- typedArray.byteLength
1712
- );
1713
- typedArray = 2048 < typedArray.byteLength ? debug.slice() : debug;
1714
+ a: {
1715
+ debug = new Uint8Array(
1716
+ typedArray.buffer,
1717
+ typedArray.byteOffset,
1718
+ typedArray.byteLength
1719
+ );
1720
+ if (2048 < typedArray.byteLength) {
1721
+ if (
1722
+ 0 !== typedArray.byteOffset ||
1723
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1724
+ typedArray.buffer.resizable
1725
+ ) {
1726
+ typedArray = debug.slice();
1727
+ break a;
1728
+ }
1729
+ if (!supportsArrayBufferDetached) {
1730
+ typedArray = debug.slice();
1731
+ break a;
1732
+ }
1733
+ }
1734
+ typedArray = debug;
1735
+ }
1714
1736
  debug = typedArray.byteLength;
1715
1737
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1716
1738
  id = stringToChunk(id);
@@ -2030,6 +2052,38 @@ function abort(request, reason) {
2030
2052
  fatalError(request, error$26);
2031
2053
  }
2032
2054
  }
2055
+ function appendBackingEntry(backingStore, value, key) {
2056
+ var prefix = backingStore.prefix;
2057
+ if (key.startsWith(prefix)) {
2058
+ switch (key[prefix.length]) {
2059
+ case "_":
2060
+ prefix = backingStore.referencedEntries;
2061
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2062
+ prefix.push([key, value]);
2063
+ return;
2064
+ case "S":
2065
+ "string" === typeof value &&
2066
+ ((prefix = backingStore.streamChunks),
2067
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2068
+ (backingStore = prefix.get(key)),
2069
+ void 0 === backingStore
2070
+ ? prefix.set(key, [value])
2071
+ : backingStore.push(value));
2072
+ return;
2073
+ }
2074
+ "string" === typeof value
2075
+ ? ((prefix = backingStore.stringChunks),
2076
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2077
+ prefix.set(key, value))
2078
+ : ((prefix = backingStore.blobs),
2079
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2080
+ prefix.set(key, value));
2081
+ }
2082
+ }
2083
+ function getBackingBlob(backingStore, key) {
2084
+ backingStore = backingStore.blobs;
2085
+ return null === backingStore ? void 0 : backingStore.get(key);
2086
+ }
2033
2087
  var RESPONSE_SYMBOL = Symbol();
2034
2088
  function ReactPromise(status, value, reason) {
2035
2089
  this.status = status;
@@ -2401,15 +2455,18 @@ function reportGlobalError(response, error) {
2401
2455
  function getChunk(response, id) {
2402
2456
  var chunks = response._chunks,
2403
2457
  chunk = chunks.get(id);
2404
- chunk ||
2405
- ((chunk = response._formData.data.get(response._prefix + id)),
2406
- (chunk =
2458
+ if (!chunk) {
2459
+ chunk = response._prefix;
2460
+ var stringChunks = response._formData.stringChunks;
2461
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2462
+ chunk =
2407
2463
  "string" === typeof chunk
2408
2464
  ? createResolvedModelChunk(response, chunk, id)
2409
2465
  : response._closed
2410
2466
  ? new ReactPromise("rejected", null, response._closedReason)
2411
- : new ReactPromise("pending", null, null)),
2412
- chunks.set(id, chunk));
2467
+ : new ReactPromise("pending", null, null);
2468
+ chunks.set(id, chunk);
2469
+ }
2413
2470
  return chunk;
2414
2471
  }
2415
2472
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2640,7 +2697,7 @@ function parseTypedArray(
2640
2697
  Error("Already initialized typed array.")
2641
2698
  )
2642
2699
  );
2643
- reference = response._formData.data.get(key).arrayBuffer();
2700
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2644
2701
  if (initializingHandler) {
2645
2702
  var handler = initializingHandler;
2646
2703
  handler.deps++;
@@ -2684,13 +2741,15 @@ function resolveStream(response, id, stream, controller) {
2684
2741
  var chunks = response._chunks;
2685
2742
  stream = new ReactPromise("fulfilled", stream, controller);
2686
2743
  chunks.set(id, stream);
2687
- response = response._formData.data.getAll(response._prefix + id);
2688
- for (id = 0; id < response.length; id++)
2689
- (chunks = response[id]),
2690
- "string" === typeof chunks &&
2691
- ("C" === chunks[0]
2744
+ chunks = response._prefix;
2745
+ response = response._formData.streamChunks;
2746
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2747
+ if (void 0 !== id)
2748
+ for (response = 0; response < id.length; response++)
2749
+ (chunks = id[response]),
2750
+ "C" === chunks[0]
2692
2751
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2693
- : controller.enqueueModel(chunks));
2752
+ : controller.enqueueModel(chunks);
2694
2753
  }
2695
2754
  function parseReadableStream(response, reference, type) {
2696
2755
  function enqueue(value) {
@@ -2856,7 +2915,14 @@ function parseAsyncIterable(response, reference, iterator) {
2856
2915
  });
2857
2916
  return iterator;
2858
2917
  }
2859
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2918
+ function parseModelString(
2919
+ response,
2920
+ obj,
2921
+ key$jscomp$0,
2922
+ value,
2923
+ reference,
2924
+ arrayRoot
2925
+ ) {
2860
2926
  if ("$" === value[0]) {
2861
2927
  switch (value[1]) {
2862
2928
  case "$":
@@ -2874,7 +2940,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2874
2940
  response,
2875
2941
  arrayRoot,
2876
2942
  obj,
2877
- key,
2943
+ key$jscomp$0,
2878
2944
  null,
2879
2945
  loadServerReference$1
2880
2946
  )
@@ -2891,43 +2957,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2891
2957
  case "Q":
2892
2958
  return (
2893
2959
  (arrayRoot = value.slice(2)),
2894
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2960
+ getOutlinedModel(
2961
+ response,
2962
+ arrayRoot,
2963
+ obj,
2964
+ key$jscomp$0,
2965
+ null,
2966
+ createMap
2967
+ )
2895
2968
  );
2896
2969
  case "W":
2897
2970
  return (
2898
2971
  (arrayRoot = value.slice(2)),
2899
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2972
+ getOutlinedModel(
2973
+ response,
2974
+ arrayRoot,
2975
+ obj,
2976
+ key$jscomp$0,
2977
+ null,
2978
+ createSet
2979
+ )
2900
2980
  );
2901
2981
  case "K":
2902
- key = value.slice(2);
2903
- obj = response._prefix + "_";
2904
- key = obj + key + "_";
2905
- arrayRoot = new FormData();
2906
- for (response = response._formData; ; ) {
2907
- value = response.keys;
2908
- null === value &&
2909
- ((value = response.keys = Array.from(response.data.keys())),
2910
- (response.keyPointer = 0));
2911
- value = value[response.keyPointer];
2912
- if (void 0 === value) break;
2913
- if (value.startsWith(key)) {
2914
- reference = response.data.getAll(value);
2915
- for (
2916
- var referencedFormDataKey = value.slice(key.length), i = 0;
2917
- i < reference.length;
2918
- i++
2919
- )
2920
- arrayRoot.append(referencedFormDataKey, reference[i]);
2921
- response.data.delete(value);
2922
- response.keyPointer++;
2923
- } else if (value.startsWith(obj)) break;
2924
- else response.keyPointer++;
2982
+ obj = value.slice(2);
2983
+ obj = response._prefix + "_" + obj + "_";
2984
+ response = response._formData;
2985
+ key$jscomp$0 = new FormData();
2986
+ arrayRoot = response.referencedEntries;
2987
+ if (null !== arrayRoot) {
2988
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2989
+ reference = arrayRoot[value];
2990
+ var key = reference[0];
2991
+ if (!key.startsWith(obj)) break;
2992
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2993
+ value++;
2994
+ }
2995
+ response.keyPointer = value;
2925
2996
  }
2926
- return arrayRoot;
2997
+ return key$jscomp$0;
2927
2998
  case "i":
2928
2999
  return (
2929
3000
  (arrayRoot = value.slice(2)),
2930
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3001
+ getOutlinedModel(
3002
+ response,
3003
+ arrayRoot,
3004
+ obj,
3005
+ key$jscomp$0,
3006
+ null,
3007
+ extractIterator
3008
+ )
2931
3009
  );
2932
3010
  case "I":
2933
3011
  return Infinity;
@@ -2956,7 +3034,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2956
3034
  ArrayBuffer,
2957
3035
  1,
2958
3036
  obj,
2959
- key,
3037
+ key$jscomp$0,
2960
3038
  arrayRoot
2961
3039
  );
2962
3040
  case "O":
@@ -2966,7 +3044,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2966
3044
  Int8Array,
2967
3045
  1,
2968
3046
  obj,
2969
- key,
3047
+ key$jscomp$0,
2970
3048
  arrayRoot
2971
3049
  );
2972
3050
  case "o":
@@ -2976,7 +3054,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2976
3054
  Uint8Array,
2977
3055
  1,
2978
3056
  obj,
2979
- key,
3057
+ key$jscomp$0,
2980
3058
  arrayRoot
2981
3059
  );
2982
3060
  case "U":
@@ -2986,7 +3064,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2986
3064
  Uint8ClampedArray,
2987
3065
  1,
2988
3066
  obj,
2989
- key,
3067
+ key$jscomp$0,
2990
3068
  arrayRoot
2991
3069
  );
2992
3070
  case "S":
@@ -2996,7 +3074,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2996
3074
  Int16Array,
2997
3075
  2,
2998
3076
  obj,
2999
- key,
3077
+ key$jscomp$0,
3000
3078
  arrayRoot
3001
3079
  );
3002
3080
  case "s":
@@ -3006,7 +3084,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3006
3084
  Uint16Array,
3007
3085
  2,
3008
3086
  obj,
3009
- key,
3087
+ key$jscomp$0,
3010
3088
  arrayRoot
3011
3089
  );
3012
3090
  case "L":
@@ -3016,7 +3094,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3016
3094
  Int32Array,
3017
3095
  4,
3018
3096
  obj,
3019
- key,
3097
+ key$jscomp$0,
3020
3098
  arrayRoot
3021
3099
  );
3022
3100
  case "l":
@@ -3026,7 +3104,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3026
3104
  Uint32Array,
3027
3105
  4,
3028
3106
  obj,
3029
- key,
3107
+ key$jscomp$0,
3030
3108
  arrayRoot
3031
3109
  );
3032
3110
  case "G":
@@ -3036,7 +3114,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3036
3114
  Float32Array,
3037
3115
  4,
3038
3116
  obj,
3039
- key,
3117
+ key$jscomp$0,
3040
3118
  arrayRoot
3041
3119
  );
3042
3120
  case "g":
@@ -3046,7 +3124,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3046
3124
  Float64Array,
3047
3125
  8,
3048
3126
  obj,
3049
- key,
3127
+ key$jscomp$0,
3050
3128
  arrayRoot
3051
3129
  );
3052
3130
  case "M":
@@ -3056,7 +3134,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3056
3134
  BigInt64Array,
3057
3135
  8,
3058
3136
  obj,
3059
- key,
3137
+ key$jscomp$0,
3060
3138
  arrayRoot
3061
3139
  );
3062
3140
  case "m":
@@ -3066,7 +3144,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3066
3144
  BigUint64Array,
3067
3145
  8,
3068
3146
  obj,
3069
- key,
3147
+ key$jscomp$0,
3070
3148
  arrayRoot
3071
3149
  );
3072
3150
  case "V":
@@ -3076,13 +3154,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3076
3154
  DataView,
3077
3155
  1,
3078
3156
  obj,
3079
- key,
3157
+ key$jscomp$0,
3080
3158
  arrayRoot
3081
3159
  );
3082
3160
  case "B":
3083
3161
  return (
3084
3162
  (obj = parseInt(value.slice(2), 16)),
3085
- response._formData.data.get(response._prefix + obj)
3163
+ getBackingBlob(response._formData, response._prefix + obj)
3086
3164
  );
3087
3165
  case "R":
3088
3166
  return parseReadableStream(response, value, void 0);
@@ -3094,7 +3172,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3094
3172
  return parseAsyncIterable(response, value, !0);
3095
3173
  }
3096
3174
  value = value.slice(1);
3097
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3175
+ return getOutlinedModel(
3176
+ response,
3177
+ value,
3178
+ obj,
3179
+ key$jscomp$0,
3180
+ arrayRoot,
3181
+ createModel
3182
+ );
3098
3183
  }
3099
3184
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3100
3185
  return value;
@@ -3106,11 +3191,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3106
3191
  : new FormData(),
3107
3192
  arraySizeLimit =
3108
3193
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3109
- chunks = new Map();
3194
+ chunks = new Map(),
3195
+ backingStore = {
3196
+ prefix: formFieldPrefix,
3197
+ referencedEntries: null,
3198
+ keyPointer: 0,
3199
+ stringChunks: null,
3200
+ streamChunks: null,
3201
+ blobs: null
3202
+ };
3203
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3110
3204
  return {
3111
3205
  _bundlerConfig: bundlerConfig,
3112
3206
  _prefix: formFieldPrefix,
3113
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3207
+ _formData: backingStore,
3114
3208
  _chunks: chunks,
3115
3209
  _closed: !1,
3116
3210
  _closedReason: null,
@@ -3167,44 +3261,41 @@ function decodeBoundActionMetaData(
3167
3261
  }
3168
3262
  function decodeAction$1(body, serverManifest) {
3169
3263
  var formData = new FormData(),
3170
- action = null,
3171
- seenActions = new Set();
3264
+ maybeActionKey = null;
3172
3265
  body.forEach(function (value, key) {
3173
3266
  key.startsWith("$ACTION_")
3174
3267
  ? key.startsWith("$ACTION_REF_")
3175
- ? seenActions.has(key) ||
3176
- (seenActions.add(key),
3177
- (value = "$ACTION_" + key.slice(12) + ":"),
3178
- (value = decodeBoundActionMetaData(body, serverManifest, value)),
3179
- (action = loadServerReference(serverManifest, value)))
3180
- : key.startsWith("$ACTION_ID_") &&
3181
- !seenActions.has(key) &&
3182
- (seenActions.add(key),
3183
- (value = key.slice(11)),
3184
- (action = loadServerReference(serverManifest, {
3185
- id: value,
3186
- bound: null
3187
- })))
3268
+ ? (maybeActionKey = key)
3269
+ : key.startsWith("$ACTION_ID_") && (maybeActionKey = key)
3188
3270
  : formData.append(key, value);
3189
3271
  });
3190
- return null === action
3191
- ? null
3192
- : action.then(function (fn) {
3193
- return fn.bind(null, formData);
3194
- });
3272
+ if (null === maybeActionKey) return null;
3273
+ var actionKey = maybeActionKey,
3274
+ action = null;
3275
+ if (actionKey.startsWith("$ACTION_REF_"))
3276
+ (actionKey = "$ACTION_" + actionKey.slice(12) + ":"),
3277
+ (body = decodeBoundActionMetaData(body, serverManifest, actionKey)),
3278
+ (action = loadServerReference(serverManifest, body));
3279
+ else if (actionKey.startsWith("$ACTION_ID_"))
3280
+ (body = actionKey.slice(11)),
3281
+ (action = loadServerReference(serverManifest, { id: body, bound: null }));
3282
+ else throw Error("Cannot handle action key. This is a bug in React.");
3283
+ return action.then(function (fn) {
3284
+ return fn.bind(null, formData);
3285
+ });
3195
3286
  }
3196
3287
  function decodeFormState$1(actionResult, body, serverManifest) {
3197
3288
  var keyPath = body.get("$ACTION_KEY");
3198
3289
  if ("string" !== typeof keyPath) return Promise.resolve(null);
3199
- var metaData = null;
3290
+ var actionKey = null;
3200
3291
  body.forEach(function (value, key) {
3201
- key.startsWith("$ACTION_REF_") &&
3202
- ((value = "$ACTION_" + key.slice(12) + ":"),
3203
- (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
3292
+ key.startsWith("$ACTION_REF_") && (actionKey = key);
3204
3293
  });
3205
- if (null === metaData) return Promise.resolve(null);
3206
- var referenceId = metaData.id;
3207
- return Promise.resolve(metaData.bound).then(function (bound) {
3294
+ if (null === actionKey) return Promise.resolve(null);
3295
+ var formFieldPrefix = "$ACTION_" + actionKey.slice(12) + ":";
3296
+ body = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
3297
+ var referenceId = body.id;
3298
+ return Promise.resolve(body.bound).then(function (bound) {
3208
3299
  return null === bound
3209
3300
  ? null
3210
3301
  : [actionResult, keyPath, referenceId, bound.length - 1];