react-server-dom-parcel 19.2.8 → 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.
@@ -57,7 +57,11 @@ function getIteratorFn(maybeIterable) {
57
57
  maybeIterable["@@iterator"];
58
58
  return "function" === typeof maybeIterable ? maybeIterable : null;
59
59
  }
60
- var ASYNC_ITERATOR = Symbol.asyncIterator;
60
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
61
+ supportsArrayBufferDetached = hasOwnProperty.call(
62
+ ArrayBuffer.prototype,
63
+ "detached"
64
+ );
61
65
  function handleErrorInNextTick(error) {
62
66
  setTimeout(function () {
63
67
  throw error;
@@ -75,28 +79,30 @@ var LocalPromise = Promise,
75
79
  currentView = null,
76
80
  writtenBytes = 0;
77
81
  function writeChunkAndReturn(destination, chunk) {
78
- if (0 !== chunk.byteLength)
79
- if (2048 < chunk.byteLength)
80
- 0 < writtenBytes &&
81
- (destination.enqueue(
82
- new Uint8Array(currentView.buffer, 0, writtenBytes)
83
- ),
84
- (currentView = new Uint8Array(2048)),
85
- (writtenBytes = 0)),
86
- destination.enqueue(chunk);
87
- else {
88
- var allowableBytes = currentView.length - writtenBytes;
89
- allowableBytes < chunk.byteLength &&
90
- (0 === allowableBytes
91
- ? destination.enqueue(currentView)
92
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
93
- destination.enqueue(currentView),
94
- (chunk = chunk.subarray(allowableBytes))),
95
- (currentView = new Uint8Array(2048)),
96
- (writtenBytes = 0));
97
- currentView.set(chunk, writtenBytes);
98
- writtenBytes += chunk.byteLength;
99
- }
82
+ if (0 === chunk.byteLength) {
83
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
84
+ throw Error(
85
+ "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()`."
86
+ );
87
+ } else if (2048 < chunk.byteLength)
88
+ 0 < writtenBytes &&
89
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
90
+ (currentView = new Uint8Array(2048)),
91
+ (writtenBytes = 0)),
92
+ destination.enqueue(chunk);
93
+ else {
94
+ var allowableBytes = currentView.length - writtenBytes;
95
+ allowableBytes < chunk.byteLength &&
96
+ (0 === allowableBytes
97
+ ? destination.enqueue(currentView)
98
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
99
+ destination.enqueue(currentView),
100
+ (chunk = chunk.subarray(allowableBytes))),
101
+ (currentView = new Uint8Array(2048)),
102
+ (writtenBytes = 0));
103
+ currentView.set(chunk, writtenBytes);
104
+ writtenBytes += chunk.byteLength;
105
+ }
100
106
  return !0;
101
107
  }
102
108
  var textEncoder = new TextEncoder();
@@ -1706,12 +1712,28 @@ function emitModelChunk(request, id, json) {
1706
1712
  }
1707
1713
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1708
1714
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1709
- debug = new Uint8Array(
1710
- typedArray.buffer,
1711
- typedArray.byteOffset,
1712
- typedArray.byteLength
1713
- );
1714
- typedArray = 2048 < typedArray.byteLength ? debug.slice() : debug;
1715
+ a: {
1716
+ debug = new Uint8Array(
1717
+ typedArray.buffer,
1718
+ typedArray.byteOffset,
1719
+ typedArray.byteLength
1720
+ );
1721
+ if (2048 < typedArray.byteLength) {
1722
+ if (
1723
+ 0 !== typedArray.byteOffset ||
1724
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1725
+ typedArray.buffer.resizable
1726
+ ) {
1727
+ typedArray = debug.slice();
1728
+ break a;
1729
+ }
1730
+ if (!supportsArrayBufferDetached) {
1731
+ typedArray = debug.slice();
1732
+ break a;
1733
+ }
1734
+ }
1735
+ typedArray = debug;
1736
+ }
1715
1737
  debug = typedArray.byteLength;
1716
1738
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1717
1739
  id = stringToChunk(id);
@@ -2035,13 +2057,37 @@ function abort(request, reason) {
2035
2057
  fatalError(request, error$26);
2036
2058
  }
2037
2059
  }
2038
- function appendBackingEntry(backingStore, key, value) {
2039
- backingStore.data.append(key, value);
2040
- value = backingStore.keys;
2041
- null === value
2042
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2043
- (backingStore.keyPointer = 0))
2044
- : value.push(key);
2060
+ function appendBackingEntry(backingStore, value, key) {
2061
+ var prefix = backingStore.prefix;
2062
+ if (key.startsWith(prefix)) {
2063
+ switch (key[prefix.length]) {
2064
+ case "_":
2065
+ prefix = backingStore.referencedEntries;
2066
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2067
+ prefix.push([key, value]);
2068
+ return;
2069
+ case "S":
2070
+ "string" === typeof value &&
2071
+ ((prefix = backingStore.streamChunks),
2072
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2073
+ (backingStore = prefix.get(key)),
2074
+ void 0 === backingStore
2075
+ ? prefix.set(key, [value])
2076
+ : backingStore.push(value));
2077
+ return;
2078
+ }
2079
+ "string" === typeof value
2080
+ ? ((prefix = backingStore.stringChunks),
2081
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2082
+ prefix.set(key, value))
2083
+ : ((prefix = backingStore.blobs),
2084
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2085
+ prefix.set(key, value));
2086
+ }
2087
+ }
2088
+ function getBackingBlob(backingStore, key) {
2089
+ backingStore = backingStore.blobs;
2090
+ return null === backingStore ? void 0 : backingStore.get(key);
2045
2091
  }
2046
2092
  var RESPONSE_SYMBOL = Symbol();
2047
2093
  function ReactPromise(status, value, reason) {
@@ -2414,15 +2460,18 @@ function reportGlobalError(response, error) {
2414
2460
  function getChunk(response, id) {
2415
2461
  var chunks = response._chunks,
2416
2462
  chunk = chunks.get(id);
2417
- chunk ||
2418
- ((chunk = response._formData.data.get(response._prefix + id)),
2419
- (chunk =
2463
+ if (!chunk) {
2464
+ chunk = response._prefix;
2465
+ var stringChunks = response._formData.stringChunks;
2466
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2467
+ chunk =
2420
2468
  "string" === typeof chunk
2421
2469
  ? createResolvedModelChunk(response, chunk, id)
2422
2470
  : response._closed
2423
2471
  ? new ReactPromise("rejected", null, response._closedReason)
2424
- : new ReactPromise("pending", null, null)),
2425
- chunks.set(id, chunk));
2472
+ : new ReactPromise("pending", null, null);
2473
+ chunks.set(id, chunk);
2474
+ }
2426
2475
  return chunk;
2427
2476
  }
2428
2477
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2653,7 +2702,7 @@ function parseTypedArray(
2653
2702
  Error("Already initialized typed array.")
2654
2703
  )
2655
2704
  );
2656
- reference = response._formData.data.get(key).arrayBuffer();
2705
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2657
2706
  if (initializingHandler) {
2658
2707
  var handler = initializingHandler;
2659
2708
  handler.deps++;
@@ -2697,13 +2746,15 @@ function resolveStream(response, id, stream, controller) {
2697
2746
  var chunks = response._chunks;
2698
2747
  stream = new ReactPromise("fulfilled", stream, controller);
2699
2748
  chunks.set(id, stream);
2700
- response = response._formData.data.getAll(response._prefix + id);
2701
- for (id = 0; id < response.length; id++)
2702
- (chunks = response[id]),
2703
- "string" === typeof chunks &&
2704
- ("C" === chunks[0]
2749
+ chunks = response._prefix;
2750
+ response = response._formData.streamChunks;
2751
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2752
+ if (void 0 !== id)
2753
+ for (response = 0; response < id.length; response++)
2754
+ (chunks = id[response]),
2755
+ "C" === chunks[0]
2705
2756
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2706
- : controller.enqueueModel(chunks));
2757
+ : controller.enqueueModel(chunks);
2707
2758
  }
2708
2759
  function parseReadableStream(response, reference, type) {
2709
2760
  function enqueue(value) {
@@ -2869,7 +2920,14 @@ function parseAsyncIterable(response, reference, iterator) {
2869
2920
  });
2870
2921
  return iterator;
2871
2922
  }
2872
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2923
+ function parseModelString(
2924
+ response,
2925
+ obj,
2926
+ key$jscomp$0,
2927
+ value,
2928
+ reference,
2929
+ arrayRoot
2930
+ ) {
2873
2931
  if ("$" === value[0]) {
2874
2932
  switch (value[1]) {
2875
2933
  case "$":
@@ -2887,7 +2945,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2887
2945
  response,
2888
2946
  arrayRoot,
2889
2947
  obj,
2890
- key,
2948
+ key$jscomp$0,
2891
2949
  null,
2892
2950
  loadServerReference$1
2893
2951
  )
@@ -2904,43 +2962,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2904
2962
  case "Q":
2905
2963
  return (
2906
2964
  (arrayRoot = value.slice(2)),
2907
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2965
+ getOutlinedModel(
2966
+ response,
2967
+ arrayRoot,
2968
+ obj,
2969
+ key$jscomp$0,
2970
+ null,
2971
+ createMap
2972
+ )
2908
2973
  );
2909
2974
  case "W":
2910
2975
  return (
2911
2976
  (arrayRoot = value.slice(2)),
2912
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2977
+ getOutlinedModel(
2978
+ response,
2979
+ arrayRoot,
2980
+ obj,
2981
+ key$jscomp$0,
2982
+ null,
2983
+ createSet
2984
+ )
2913
2985
  );
2914
2986
  case "K":
2915
- key = value.slice(2);
2916
- obj = response._prefix + "_";
2917
- key = obj + key + "_";
2918
- arrayRoot = new FormData();
2919
- for (response = response._formData; ; ) {
2920
- value = response.keys;
2921
- null === value &&
2922
- ((value = response.keys = Array.from(response.data.keys())),
2923
- (response.keyPointer = 0));
2924
- value = value[response.keyPointer];
2925
- if (void 0 === value) break;
2926
- if (value.startsWith(key)) {
2927
- reference = response.data.getAll(value);
2928
- for (
2929
- var referencedFormDataKey = value.slice(key.length), i = 0;
2930
- i < reference.length;
2931
- i++
2932
- )
2933
- arrayRoot.append(referencedFormDataKey, reference[i]);
2934
- response.data.delete(value);
2935
- response.keyPointer++;
2936
- } else if (value.startsWith(obj)) break;
2937
- else response.keyPointer++;
2987
+ obj = value.slice(2);
2988
+ obj = response._prefix + "_" + obj + "_";
2989
+ response = response._formData;
2990
+ key$jscomp$0 = new FormData();
2991
+ arrayRoot = response.referencedEntries;
2992
+ if (null !== arrayRoot) {
2993
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2994
+ reference = arrayRoot[value];
2995
+ var key = reference[0];
2996
+ if (!key.startsWith(obj)) break;
2997
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2998
+ value++;
2999
+ }
3000
+ response.keyPointer = value;
2938
3001
  }
2939
- return arrayRoot;
3002
+ return key$jscomp$0;
2940
3003
  case "i":
2941
3004
  return (
2942
3005
  (arrayRoot = value.slice(2)),
2943
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3006
+ getOutlinedModel(
3007
+ response,
3008
+ arrayRoot,
3009
+ obj,
3010
+ key$jscomp$0,
3011
+ null,
3012
+ extractIterator
3013
+ )
2944
3014
  );
2945
3015
  case "I":
2946
3016
  return Infinity;
@@ -2969,7 +3039,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2969
3039
  ArrayBuffer,
2970
3040
  1,
2971
3041
  obj,
2972
- key,
3042
+ key$jscomp$0,
2973
3043
  arrayRoot
2974
3044
  );
2975
3045
  case "O":
@@ -2979,7 +3049,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2979
3049
  Int8Array,
2980
3050
  1,
2981
3051
  obj,
2982
- key,
3052
+ key$jscomp$0,
2983
3053
  arrayRoot
2984
3054
  );
2985
3055
  case "o":
@@ -2989,7 +3059,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2989
3059
  Uint8Array,
2990
3060
  1,
2991
3061
  obj,
2992
- key,
3062
+ key$jscomp$0,
2993
3063
  arrayRoot
2994
3064
  );
2995
3065
  case "U":
@@ -2999,7 +3069,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2999
3069
  Uint8ClampedArray,
3000
3070
  1,
3001
3071
  obj,
3002
- key,
3072
+ key$jscomp$0,
3003
3073
  arrayRoot
3004
3074
  );
3005
3075
  case "S":
@@ -3009,7 +3079,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3009
3079
  Int16Array,
3010
3080
  2,
3011
3081
  obj,
3012
- key,
3082
+ key$jscomp$0,
3013
3083
  arrayRoot
3014
3084
  );
3015
3085
  case "s":
@@ -3019,7 +3089,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3019
3089
  Uint16Array,
3020
3090
  2,
3021
3091
  obj,
3022
- key,
3092
+ key$jscomp$0,
3023
3093
  arrayRoot
3024
3094
  );
3025
3095
  case "L":
@@ -3029,7 +3099,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3029
3099
  Int32Array,
3030
3100
  4,
3031
3101
  obj,
3032
- key,
3102
+ key$jscomp$0,
3033
3103
  arrayRoot
3034
3104
  );
3035
3105
  case "l":
@@ -3039,7 +3109,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3039
3109
  Uint32Array,
3040
3110
  4,
3041
3111
  obj,
3042
- key,
3112
+ key$jscomp$0,
3043
3113
  arrayRoot
3044
3114
  );
3045
3115
  case "G":
@@ -3049,7 +3119,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3049
3119
  Float32Array,
3050
3120
  4,
3051
3121
  obj,
3052
- key,
3122
+ key$jscomp$0,
3053
3123
  arrayRoot
3054
3124
  );
3055
3125
  case "g":
@@ -3059,7 +3129,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3059
3129
  Float64Array,
3060
3130
  8,
3061
3131
  obj,
3062
- key,
3132
+ key$jscomp$0,
3063
3133
  arrayRoot
3064
3134
  );
3065
3135
  case "M":
@@ -3069,7 +3139,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3069
3139
  BigInt64Array,
3070
3140
  8,
3071
3141
  obj,
3072
- key,
3142
+ key$jscomp$0,
3073
3143
  arrayRoot
3074
3144
  );
3075
3145
  case "m":
@@ -3079,7 +3149,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3079
3149
  BigUint64Array,
3080
3150
  8,
3081
3151
  obj,
3082
- key,
3152
+ key$jscomp$0,
3083
3153
  arrayRoot
3084
3154
  );
3085
3155
  case "V":
@@ -3089,13 +3159,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3089
3159
  DataView,
3090
3160
  1,
3091
3161
  obj,
3092
- key,
3162
+ key$jscomp$0,
3093
3163
  arrayRoot
3094
3164
  );
3095
3165
  case "B":
3096
3166
  return (
3097
3167
  (obj = parseInt(value.slice(2), 16)),
3098
- response._formData.data.get(response._prefix + obj)
3168
+ getBackingBlob(response._formData, response._prefix + obj)
3099
3169
  );
3100
3170
  case "R":
3101
3171
  return parseReadableStream(response, value, void 0);
@@ -3107,7 +3177,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3107
3177
  return parseAsyncIterable(response, value, !0);
3108
3178
  }
3109
3179
  value = value.slice(1);
3110
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3180
+ return getOutlinedModel(
3181
+ response,
3182
+ value,
3183
+ obj,
3184
+ key$jscomp$0,
3185
+ arrayRoot,
3186
+ createModel
3187
+ );
3111
3188
  }
3112
3189
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3113
3190
  return value;
@@ -3119,11 +3196,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3119
3196
  : new FormData(),
3120
3197
  arraySizeLimit =
3121
3198
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3122
- chunks = new Map();
3199
+ chunks = new Map(),
3200
+ backingStore = {
3201
+ prefix: formFieldPrefix,
3202
+ referencedEntries: null,
3203
+ keyPointer: 0,
3204
+ stringChunks: null,
3205
+ streamChunks: null,
3206
+ blobs: null
3207
+ };
3208
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3123
3209
  return {
3124
3210
  _bundlerConfig: bundlerConfig,
3125
3211
  _prefix: formFieldPrefix,
3126
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3212
+ _formData: backingStore,
3127
3213
  _chunks: chunks,
3128
3214
  _closed: !1,
3129
3215
  _closedReason: null,
@@ -3260,19 +3346,34 @@ exports.decodeReplyFromAsyncIterable = function (iterable, options) {
3260
3346
  function progress(entry) {
3261
3347
  if (entry.done) close(response);
3262
3348
  else {
3263
- entry = entry.value;
3264
- var name = entry[0];
3265
- entry = entry[1];
3266
- if ("string" === typeof entry) {
3267
- appendBackingEntry(response._formData, name, entry);
3268
- var prefix = response._prefix;
3269
- if (name.startsWith(prefix)) {
3270
- var chunks = response._chunks;
3271
- name = +name.slice(prefix.length);
3272
- (chunks = chunks.get(name)) &&
3273
- resolveModelChunk(response, chunks, entry, name);
3349
+ var _entry$value = entry.value;
3350
+ entry = _entry$value[0];
3351
+ _entry$value = _entry$value[1];
3352
+ if ("string" === typeof _entry$value)
3353
+ a: {
3354
+ var prefix = response._prefix;
3355
+ if (entry.startsWith(prefix)) {
3356
+ var chunks = response._chunks;
3357
+ if ("S" === entry[prefix.length]) {
3358
+ if (
3359
+ entry.length > prefix.length + 1 &&
3360
+ ((prefix = +entry.slice(prefix.length + 1)),
3361
+ (chunks = chunks.get(prefix)))
3362
+ ) {
3363
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3364
+ break a;
3365
+ }
3366
+ } else if (
3367
+ ((prefix = +entry.slice(prefix.length)),
3368
+ (chunks = chunks.get(prefix)))
3369
+ ) {
3370
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3371
+ break a;
3372
+ }
3373
+ }
3374
+ appendBackingEntry(response._formData, _entry$value, entry);
3274
3375
  }
3275
- } else appendBackingEntry(response._formData, name, entry);
3376
+ else appendBackingEntry(response._formData, _entry$value, entry);
3276
3377
  iterator.next().then(progress, error);
3277
3378
  }
3278
3379
  }