react-server-dom-webpack 19.1.9 → 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.
@@ -30,7 +30,12 @@ function getIteratorFn(maybeIterable) {
30
30
  maybeIterable["@@iterator"];
31
31
  return "function" === typeof maybeIterable ? maybeIterable : null;
32
32
  }
33
- var ASYNC_ITERATOR = Symbol.asyncIterator;
33
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
34
+ hasOwnProperty = Object.prototype.hasOwnProperty,
35
+ supportsArrayBufferDetached = hasOwnProperty.call(
36
+ ArrayBuffer.prototype,
37
+ "detached"
38
+ );
34
39
  function handleErrorInNextTick(error) {
35
40
  setTimeout(function () {
36
41
  throw error;
@@ -48,28 +53,30 @@ var LocalPromise = Promise,
48
53
  currentView = null,
49
54
  writtenBytes = 0;
50
55
  function writeChunkAndReturn(destination, chunk) {
51
- if (0 !== chunk.byteLength)
52
- if (2048 < chunk.byteLength)
53
- 0 < writtenBytes &&
54
- (destination.enqueue(
55
- new Uint8Array(currentView.buffer, 0, writtenBytes)
56
- ),
57
- (currentView = new Uint8Array(2048)),
58
- (writtenBytes = 0)),
59
- destination.enqueue(chunk);
60
- else {
61
- var allowableBytes = currentView.length - writtenBytes;
62
- allowableBytes < chunk.byteLength &&
63
- (0 === allowableBytes
64
- ? destination.enqueue(currentView)
65
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
66
- destination.enqueue(currentView),
67
- (chunk = chunk.subarray(allowableBytes))),
68
- (currentView = new Uint8Array(2048)),
69
- (writtenBytes = 0));
70
- currentView.set(chunk, writtenBytes);
71
- writtenBytes += chunk.byteLength;
72
- }
56
+ if (0 === chunk.byteLength) {
57
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
58
+ throw Error(
59
+ "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()`."
60
+ );
61
+ } else if (2048 < chunk.byteLength)
62
+ 0 < writtenBytes &&
63
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
64
+ (currentView = new Uint8Array(2048)),
65
+ (writtenBytes = 0)),
66
+ destination.enqueue(chunk);
67
+ else {
68
+ var allowableBytes = currentView.length - writtenBytes;
69
+ allowableBytes < chunk.byteLength &&
70
+ (0 === allowableBytes
71
+ ? destination.enqueue(currentView)
72
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
73
+ destination.enqueue(currentView),
74
+ (chunk = chunk.subarray(allowableBytes))),
75
+ (currentView = new Uint8Array(2048)),
76
+ (writtenBytes = 0));
77
+ currentView.set(chunk, writtenBytes);
78
+ writtenBytes += chunk.byteLength;
79
+ }
73
80
  return !0;
74
81
  }
75
82
  var textEncoder = new TextEncoder();
@@ -1661,14 +1668,30 @@ function emitModelChunk(request, id, json) {
1661
1668
  }
1662
1669
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1663
1670
  request.pendingChunks++;
1664
- var buffer = new Uint8Array(
1665
- typedArray.buffer,
1666
- typedArray.byteOffset,
1667
- typedArray.byteLength
1668
- );
1669
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1670
- buffer = typedArray.byteLength;
1671
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1671
+ a: {
1672
+ var view = new Uint8Array(
1673
+ typedArray.buffer,
1674
+ typedArray.byteOffset,
1675
+ typedArray.byteLength
1676
+ );
1677
+ if (2048 < typedArray.byteLength) {
1678
+ if (
1679
+ 0 !== typedArray.byteOffset ||
1680
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1681
+ typedArray.buffer.resizable
1682
+ ) {
1683
+ typedArray = view.slice();
1684
+ break a;
1685
+ }
1686
+ if (!supportsArrayBufferDetached) {
1687
+ typedArray = view.slice();
1688
+ break a;
1689
+ }
1690
+ }
1691
+ typedArray = view;
1692
+ }
1693
+ view = typedArray.byteLength;
1694
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1672
1695
  id = stringToChunk(id);
1673
1696
  request.completedRegularChunks.push(id, typedArray);
1674
1697
  }
@@ -1924,7 +1947,6 @@ function abort(request, reason) {
1924
1947
  logRecoverableError(request, error$26, null), fatalError(request, error$26);
1925
1948
  }
1926
1949
  }
1927
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1928
1950
  function resolveServerReference(bundlerConfig, id) {
1929
1951
  var name = "",
1930
1952
  resolvedModuleData = bundlerConfig[id];
@@ -1998,13 +2020,37 @@ function requireModule(metadata) {
1998
2020
  if (hasOwnProperty.call(moduleExports, metadata[2]))
1999
2021
  return moduleExports[metadata[2]];
2000
2022
  }
2001
- function appendBackingEntry(backingStore, key, value) {
2002
- backingStore.data.append(key, value);
2003
- value = backingStore.keys;
2004
- null === value
2005
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2006
- (backingStore.keyPointer = 0))
2007
- : value.push(key);
2023
+ function appendBackingEntry(backingStore, value, key) {
2024
+ var prefix = backingStore.prefix;
2025
+ if (key.startsWith(prefix)) {
2026
+ switch (key[prefix.length]) {
2027
+ case "_":
2028
+ prefix = backingStore.referencedEntries;
2029
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2030
+ prefix.push([key, value]);
2031
+ return;
2032
+ case "S":
2033
+ "string" === typeof value &&
2034
+ ((prefix = backingStore.streamChunks),
2035
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2036
+ (backingStore = prefix.get(key)),
2037
+ void 0 === backingStore
2038
+ ? prefix.set(key, [value])
2039
+ : backingStore.push(value));
2040
+ return;
2041
+ }
2042
+ "string" === typeof value
2043
+ ? ((prefix = backingStore.stringChunks),
2044
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2045
+ prefix.set(key, value))
2046
+ : ((prefix = backingStore.blobs),
2047
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2048
+ prefix.set(key, value));
2049
+ }
2050
+ }
2051
+ function getBackingBlob(backingStore, key) {
2052
+ backingStore = backingStore.blobs;
2053
+ return null === backingStore ? void 0 : backingStore.get(key);
2008
2054
  }
2009
2055
  var RESPONSE_SYMBOL = Symbol();
2010
2056
  function ReactPromise(status, value, reason) {
@@ -2377,15 +2423,18 @@ function reportGlobalError(response, error) {
2377
2423
  function getChunk(response, id) {
2378
2424
  var chunks = response._chunks,
2379
2425
  chunk = chunks.get(id);
2380
- chunk ||
2381
- ((chunk = response._formData.data.get(response._prefix + id)),
2382
- (chunk =
2426
+ if (!chunk) {
2427
+ chunk = response._prefix;
2428
+ var stringChunks = response._formData.stringChunks;
2429
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2430
+ chunk =
2383
2431
  "string" === typeof chunk
2384
2432
  ? createResolvedModelChunk(response, chunk, id)
2385
2433
  : response._closed
2386
2434
  ? new ReactPromise("rejected", null, response._closedReason)
2387
- : new ReactPromise("pending", null, null)),
2388
- chunks.set(id, chunk));
2435
+ : new ReactPromise("pending", null, null);
2436
+ chunks.set(id, chunk);
2437
+ }
2389
2438
  return chunk;
2390
2439
  }
2391
2440
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2616,7 +2665,7 @@ function parseTypedArray(
2616
2665
  Error("Already initialized typed array.")
2617
2666
  )
2618
2667
  );
2619
- reference = response._formData.data.get(key).arrayBuffer();
2668
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2620
2669
  if (initializingHandler) {
2621
2670
  var handler = initializingHandler;
2622
2671
  handler.deps++;
@@ -2660,13 +2709,15 @@ function resolveStream(response, id, stream, controller) {
2660
2709
  var chunks = response._chunks;
2661
2710
  stream = new ReactPromise("fulfilled", stream, controller);
2662
2711
  chunks.set(id, stream);
2663
- response = response._formData.data.getAll(response._prefix + id);
2664
- for (id = 0; id < response.length; id++)
2665
- (chunks = response[id]),
2666
- "string" === typeof chunks &&
2667
- ("C" === chunks[0]
2712
+ chunks = response._prefix;
2713
+ response = response._formData.streamChunks;
2714
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2715
+ if (void 0 !== id)
2716
+ for (response = 0; response < id.length; response++)
2717
+ (chunks = id[response]),
2718
+ "C" === chunks[0]
2668
2719
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2669
- : controller.enqueueModel(chunks));
2720
+ : controller.enqueueModel(chunks);
2670
2721
  }
2671
2722
  function parseReadableStream(response, reference, type) {
2672
2723
  function enqueue(value) {
@@ -2832,7 +2883,14 @@ function parseAsyncIterable(response, reference, iterator) {
2832
2883
  });
2833
2884
  return iterator;
2834
2885
  }
2835
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2886
+ function parseModelString(
2887
+ response,
2888
+ obj,
2889
+ key$jscomp$0,
2890
+ value,
2891
+ reference,
2892
+ arrayRoot
2893
+ ) {
2836
2894
  if ("$" === value[0]) {
2837
2895
  switch (value[1]) {
2838
2896
  case "$":
@@ -2850,7 +2908,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2850
2908
  response,
2851
2909
  arrayRoot,
2852
2910
  obj,
2853
- key,
2911
+ key$jscomp$0,
2854
2912
  null,
2855
2913
  loadServerReference$1
2856
2914
  )
@@ -2867,43 +2925,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2867
2925
  case "Q":
2868
2926
  return (
2869
2927
  (arrayRoot = value.slice(2)),
2870
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2928
+ getOutlinedModel(
2929
+ response,
2930
+ arrayRoot,
2931
+ obj,
2932
+ key$jscomp$0,
2933
+ null,
2934
+ createMap
2935
+ )
2871
2936
  );
2872
2937
  case "W":
2873
2938
  return (
2874
2939
  (arrayRoot = value.slice(2)),
2875
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2940
+ getOutlinedModel(
2941
+ response,
2942
+ arrayRoot,
2943
+ obj,
2944
+ key$jscomp$0,
2945
+ null,
2946
+ createSet
2947
+ )
2876
2948
  );
2877
2949
  case "K":
2878
- key = value.slice(2);
2879
- obj = response._prefix + "_";
2880
- key = obj + key + "_";
2881
- arrayRoot = new FormData();
2882
- for (response = response._formData; ; ) {
2883
- value = response.keys;
2884
- null === value &&
2885
- ((value = response.keys = Array.from(response.data.keys())),
2886
- (response.keyPointer = 0));
2887
- value = value[response.keyPointer];
2888
- if (void 0 === value) break;
2889
- if (value.startsWith(key)) {
2890
- reference = response.data.getAll(value);
2891
- for (
2892
- var referencedFormDataKey = value.slice(key.length), i = 0;
2893
- i < reference.length;
2894
- i++
2895
- )
2896
- arrayRoot.append(referencedFormDataKey, reference[i]);
2897
- response.data.delete(value);
2898
- response.keyPointer++;
2899
- } else if (value.startsWith(obj)) break;
2900
- else response.keyPointer++;
2950
+ obj = value.slice(2);
2951
+ obj = response._prefix + "_" + obj + "_";
2952
+ response = response._formData;
2953
+ key$jscomp$0 = new FormData();
2954
+ arrayRoot = response.referencedEntries;
2955
+ if (null !== arrayRoot) {
2956
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2957
+ reference = arrayRoot[value];
2958
+ var key = reference[0];
2959
+ if (!key.startsWith(obj)) break;
2960
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2961
+ value++;
2962
+ }
2963
+ response.keyPointer = value;
2901
2964
  }
2902
- return arrayRoot;
2965
+ return key$jscomp$0;
2903
2966
  case "i":
2904
2967
  return (
2905
2968
  (arrayRoot = value.slice(2)),
2906
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2969
+ getOutlinedModel(
2970
+ response,
2971
+ arrayRoot,
2972
+ obj,
2973
+ key$jscomp$0,
2974
+ null,
2975
+ extractIterator
2976
+ )
2907
2977
  );
2908
2978
  case "I":
2909
2979
  return Infinity;
@@ -2932,7 +3002,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2932
3002
  ArrayBuffer,
2933
3003
  1,
2934
3004
  obj,
2935
- key,
3005
+ key$jscomp$0,
2936
3006
  arrayRoot
2937
3007
  );
2938
3008
  case "O":
@@ -2942,7 +3012,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2942
3012
  Int8Array,
2943
3013
  1,
2944
3014
  obj,
2945
- key,
3015
+ key$jscomp$0,
2946
3016
  arrayRoot
2947
3017
  );
2948
3018
  case "o":
@@ -2952,7 +3022,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2952
3022
  Uint8Array,
2953
3023
  1,
2954
3024
  obj,
2955
- key,
3025
+ key$jscomp$0,
2956
3026
  arrayRoot
2957
3027
  );
2958
3028
  case "U":
@@ -2962,7 +3032,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2962
3032
  Uint8ClampedArray,
2963
3033
  1,
2964
3034
  obj,
2965
- key,
3035
+ key$jscomp$0,
2966
3036
  arrayRoot
2967
3037
  );
2968
3038
  case "S":
@@ -2972,7 +3042,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2972
3042
  Int16Array,
2973
3043
  2,
2974
3044
  obj,
2975
- key,
3045
+ key$jscomp$0,
2976
3046
  arrayRoot
2977
3047
  );
2978
3048
  case "s":
@@ -2982,7 +3052,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2982
3052
  Uint16Array,
2983
3053
  2,
2984
3054
  obj,
2985
- key,
3055
+ key$jscomp$0,
2986
3056
  arrayRoot
2987
3057
  );
2988
3058
  case "L":
@@ -2992,7 +3062,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2992
3062
  Int32Array,
2993
3063
  4,
2994
3064
  obj,
2995
- key,
3065
+ key$jscomp$0,
2996
3066
  arrayRoot
2997
3067
  );
2998
3068
  case "l":
@@ -3002,7 +3072,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3002
3072
  Uint32Array,
3003
3073
  4,
3004
3074
  obj,
3005
- key,
3075
+ key$jscomp$0,
3006
3076
  arrayRoot
3007
3077
  );
3008
3078
  case "G":
@@ -3012,7 +3082,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3012
3082
  Float32Array,
3013
3083
  4,
3014
3084
  obj,
3015
- key,
3085
+ key$jscomp$0,
3016
3086
  arrayRoot
3017
3087
  );
3018
3088
  case "g":
@@ -3022,7 +3092,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3022
3092
  Float64Array,
3023
3093
  8,
3024
3094
  obj,
3025
- key,
3095
+ key$jscomp$0,
3026
3096
  arrayRoot
3027
3097
  );
3028
3098
  case "M":
@@ -3032,7 +3102,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3032
3102
  BigInt64Array,
3033
3103
  8,
3034
3104
  obj,
3035
- key,
3105
+ key$jscomp$0,
3036
3106
  arrayRoot
3037
3107
  );
3038
3108
  case "m":
@@ -3042,7 +3112,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3042
3112
  BigUint64Array,
3043
3113
  8,
3044
3114
  obj,
3045
- key,
3115
+ key$jscomp$0,
3046
3116
  arrayRoot
3047
3117
  );
3048
3118
  case "V":
@@ -3052,13 +3122,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3052
3122
  DataView,
3053
3123
  1,
3054
3124
  obj,
3055
- key,
3125
+ key$jscomp$0,
3056
3126
  arrayRoot
3057
3127
  );
3058
3128
  case "B":
3059
3129
  return (
3060
3130
  (obj = parseInt(value.slice(2), 16)),
3061
- response._formData.data.get(response._prefix + obj)
3131
+ getBackingBlob(response._formData, response._prefix + obj)
3062
3132
  );
3063
3133
  case "R":
3064
3134
  return parseReadableStream(response, value, void 0);
@@ -3070,7 +3140,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3070
3140
  return parseAsyncIterable(response, value, !0);
3071
3141
  }
3072
3142
  value = value.slice(1);
3073
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3143
+ return getOutlinedModel(
3144
+ response,
3145
+ value,
3146
+ obj,
3147
+ key$jscomp$0,
3148
+ arrayRoot,
3149
+ createModel
3150
+ );
3074
3151
  }
3075
3152
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3076
3153
  return value;
@@ -3082,11 +3159,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3082
3159
  : new FormData(),
3083
3160
  arraySizeLimit =
3084
3161
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3085
- chunks = new Map();
3162
+ chunks = new Map(),
3163
+ backingStore = {
3164
+ prefix: formFieldPrefix,
3165
+ referencedEntries: null,
3166
+ keyPointer: 0,
3167
+ stringChunks: null,
3168
+ streamChunks: null,
3169
+ blobs: null
3170
+ };
3171
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3086
3172
  return {
3087
3173
  _bundlerConfig: bundlerConfig,
3088
3174
  _prefix: formFieldPrefix,
3089
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3175
+ _formData: backingStore,
3090
3176
  _chunks: chunks,
3091
3177
  _closed: !1,
3092
3178
  _closedReason: null,
@@ -3216,19 +3302,34 @@ exports.decodeReplyFromAsyncIterable = function (
3216
3302
  function progress(entry) {
3217
3303
  if (entry.done) close(response);
3218
3304
  else {
3219
- entry = entry.value;
3220
- var name = entry[0];
3221
- entry = entry[1];
3222
- if ("string" === typeof entry) {
3223
- appendBackingEntry(response._formData, name, entry);
3224
- var prefix = response._prefix;
3225
- if (name.startsWith(prefix)) {
3226
- var chunks = response._chunks;
3227
- name = +name.slice(prefix.length);
3228
- (chunks = chunks.get(name)) &&
3229
- resolveModelChunk(response, chunks, entry, name);
3305
+ var _entry$value = entry.value;
3306
+ entry = _entry$value[0];
3307
+ _entry$value = _entry$value[1];
3308
+ if ("string" === typeof _entry$value)
3309
+ a: {
3310
+ var prefix = response._prefix;
3311
+ if (entry.startsWith(prefix)) {
3312
+ var chunks = response._chunks;
3313
+ if ("S" === entry[prefix.length]) {
3314
+ if (
3315
+ entry.length > prefix.length + 1 &&
3316
+ ((prefix = +entry.slice(prefix.length + 1)),
3317
+ (chunks = chunks.get(prefix)))
3318
+ ) {
3319
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3320
+ break a;
3321
+ }
3322
+ } else if (
3323
+ ((prefix = +entry.slice(prefix.length)),
3324
+ (chunks = chunks.get(prefix)))
3325
+ ) {
3326
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3327
+ break a;
3328
+ }
3329
+ }
3330
+ appendBackingEntry(response._formData, _entry$value, entry);
3230
3331
  }
3231
- } else appendBackingEntry(response._formData, name, entry);
3332
+ else appendBackingEntry(response._formData, _entry$value, entry);
3232
3333
  iterator.next().then(progress, error);
3233
3334
  }
3234
3335
  }