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.
@@ -11,12 +11,17 @@
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
13
  React = require("react"),
14
+ hasOwnProperty = Object.prototype.hasOwnProperty,
14
15
  channel = new MessageChannel(),
15
16
  taskQueue = [];
16
17
  channel.port1.onmessage = function () {
17
18
  var task = taskQueue.shift();
18
19
  task && task();
19
20
  };
21
+ var supportsArrayBufferDetached = hasOwnProperty.call(
22
+ ArrayBuffer.prototype,
23
+ "detached"
24
+ );
20
25
  function scheduleWork(callback) {
21
26
  taskQueue.push(callback);
22
27
  channel.port2.postMessage(null);
@@ -38,28 +43,30 @@ var LocalPromise = Promise,
38
43
  currentView = null,
39
44
  writtenBytes = 0;
40
45
  function writeChunkAndReturn(destination, chunk) {
41
- if (0 !== chunk.byteLength)
42
- if (2048 < chunk.byteLength)
43
- 0 < writtenBytes &&
44
- (destination.enqueue(
45
- new Uint8Array(currentView.buffer, 0, writtenBytes)
46
- ),
47
- (currentView = new Uint8Array(2048)),
48
- (writtenBytes = 0)),
49
- destination.enqueue(chunk);
50
- else {
51
- var allowableBytes = currentView.length - writtenBytes;
52
- allowableBytes < chunk.byteLength &&
53
- (0 === allowableBytes
54
- ? destination.enqueue(currentView)
55
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
56
- destination.enqueue(currentView),
57
- (chunk = chunk.subarray(allowableBytes))),
58
- (currentView = new Uint8Array(2048)),
59
- (writtenBytes = 0));
60
- currentView.set(chunk, writtenBytes);
61
- writtenBytes += chunk.byteLength;
62
- }
46
+ if (0 === chunk.byteLength) {
47
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
48
+ throw Error(
49
+ "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()`."
50
+ );
51
+ } else if (2048 < chunk.byteLength)
52
+ 0 < writtenBytes &&
53
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
54
+ (currentView = new Uint8Array(2048)),
55
+ (writtenBytes = 0)),
56
+ destination.enqueue(chunk);
57
+ else {
58
+ var allowableBytes = currentView.length - writtenBytes;
59
+ allowableBytes < chunk.byteLength &&
60
+ (0 === allowableBytes
61
+ ? destination.enqueue(currentView)
62
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
63
+ destination.enqueue(currentView),
64
+ (chunk = chunk.subarray(allowableBytes))),
65
+ (currentView = new Uint8Array(2048)),
66
+ (writtenBytes = 0));
67
+ currentView.set(chunk, writtenBytes);
68
+ writtenBytes += chunk.byteLength;
69
+ }
63
70
  return !0;
64
71
  }
65
72
  var textEncoder = new TextEncoder();
@@ -1654,14 +1661,30 @@ function emitModelChunk(request, id, json) {
1654
1661
  }
1655
1662
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1656
1663
  request.pendingChunks++;
1657
- var buffer = new Uint8Array(
1658
- typedArray.buffer,
1659
- typedArray.byteOffset,
1660
- typedArray.byteLength
1661
- );
1662
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1663
- buffer = typedArray.byteLength;
1664
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1664
+ a: {
1665
+ var view = new Uint8Array(
1666
+ typedArray.buffer,
1667
+ typedArray.byteOffset,
1668
+ typedArray.byteLength
1669
+ );
1670
+ if (2048 < typedArray.byteLength) {
1671
+ if (
1672
+ 0 !== typedArray.byteOffset ||
1673
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1674
+ typedArray.buffer.resizable
1675
+ ) {
1676
+ typedArray = view.slice();
1677
+ break a;
1678
+ }
1679
+ if (!supportsArrayBufferDetached) {
1680
+ typedArray = view.slice();
1681
+ break a;
1682
+ }
1683
+ }
1684
+ typedArray = view;
1685
+ }
1686
+ view = typedArray.byteLength;
1687
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1665
1688
  id = stringToChunk(id);
1666
1689
  request.completedRegularChunks.push(id, typedArray);
1667
1690
  }
@@ -1913,7 +1936,6 @@ function abort(request, reason) {
1913
1936
  logRecoverableError(request, error$26, null), fatalError(request, error$26);
1914
1937
  }
1915
1938
  }
1916
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1917
1939
  function resolveServerReference(bundlerConfig, id) {
1918
1940
  var name = "",
1919
1941
  resolvedModuleData = bundlerConfig[id];
@@ -1996,6 +2018,38 @@ __webpack_require__.u = function (chunkId) {
1996
2018
  ? flightChunk
1997
2019
  : webpackGetChunkFilename(chunkId);
1998
2020
  };
2021
+ function appendBackingEntry(backingStore, value, key) {
2022
+ var prefix = backingStore.prefix;
2023
+ if (key.startsWith(prefix)) {
2024
+ switch (key[prefix.length]) {
2025
+ case "_":
2026
+ prefix = backingStore.referencedEntries;
2027
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2028
+ prefix.push([key, value]);
2029
+ return;
2030
+ case "S":
2031
+ "string" === typeof value &&
2032
+ ((prefix = backingStore.streamChunks),
2033
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2034
+ (backingStore = prefix.get(key)),
2035
+ void 0 === backingStore
2036
+ ? prefix.set(key, [value])
2037
+ : backingStore.push(value));
2038
+ return;
2039
+ }
2040
+ "string" === typeof value
2041
+ ? ((prefix = backingStore.stringChunks),
2042
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2043
+ prefix.set(key, value))
2044
+ : ((prefix = backingStore.blobs),
2045
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2046
+ prefix.set(key, value));
2047
+ }
2048
+ }
2049
+ function getBackingBlob(backingStore, key) {
2050
+ backingStore = backingStore.blobs;
2051
+ return null === backingStore ? void 0 : backingStore.get(key);
2052
+ }
1999
2053
  var RESPONSE_SYMBOL = Symbol();
2000
2054
  function ReactPromise(status, value, reason) {
2001
2055
  this.status = status;
@@ -2367,15 +2421,18 @@ function reportGlobalError(response, error) {
2367
2421
  function getChunk(response, id) {
2368
2422
  var chunks = response._chunks,
2369
2423
  chunk = chunks.get(id);
2370
- chunk ||
2371
- ((chunk = response._formData.data.get(response._prefix + id)),
2372
- (chunk =
2424
+ if (!chunk) {
2425
+ chunk = response._prefix;
2426
+ var stringChunks = response._formData.stringChunks;
2427
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2428
+ chunk =
2373
2429
  "string" === typeof chunk
2374
2430
  ? createResolvedModelChunk(response, chunk, id)
2375
2431
  : response._closed
2376
2432
  ? new ReactPromise("rejected", null, response._closedReason)
2377
- : new ReactPromise("pending", null, null)),
2378
- chunks.set(id, chunk));
2433
+ : new ReactPromise("pending", null, null);
2434
+ chunks.set(id, chunk);
2435
+ }
2379
2436
  return chunk;
2380
2437
  }
2381
2438
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2606,7 +2663,7 @@ function parseTypedArray(
2606
2663
  Error("Already initialized typed array.")
2607
2664
  )
2608
2665
  );
2609
- reference = response._formData.data.get(key).arrayBuffer();
2666
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2610
2667
  if (initializingHandler) {
2611
2668
  var handler = initializingHandler;
2612
2669
  handler.deps++;
@@ -2650,13 +2707,15 @@ function resolveStream(response, id, stream, controller) {
2650
2707
  var chunks = response._chunks;
2651
2708
  stream = new ReactPromise("fulfilled", stream, controller);
2652
2709
  chunks.set(id, stream);
2653
- response = response._formData.data.getAll(response._prefix + id);
2654
- for (id = 0; id < response.length; id++)
2655
- (chunks = response[id]),
2656
- "string" === typeof chunks &&
2657
- ("C" === chunks[0]
2710
+ chunks = response._prefix;
2711
+ response = response._formData.streamChunks;
2712
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2713
+ if (void 0 !== id)
2714
+ for (response = 0; response < id.length; response++)
2715
+ (chunks = id[response]),
2716
+ "C" === chunks[0]
2658
2717
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2659
- : controller.enqueueModel(chunks));
2718
+ : controller.enqueueModel(chunks);
2660
2719
  }
2661
2720
  function parseReadableStream(response, reference, type) {
2662
2721
  function enqueue(value) {
@@ -2822,7 +2881,14 @@ function parseAsyncIterable(response, reference, iterator) {
2822
2881
  });
2823
2882
  return iterator;
2824
2883
  }
2825
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2884
+ function parseModelString(
2885
+ response,
2886
+ obj,
2887
+ key$jscomp$0,
2888
+ value,
2889
+ reference,
2890
+ arrayRoot
2891
+ ) {
2826
2892
  if ("$" === value[0]) {
2827
2893
  switch (value[1]) {
2828
2894
  case "$":
@@ -2840,7 +2906,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2840
2906
  response,
2841
2907
  arrayRoot,
2842
2908
  obj,
2843
- key,
2909
+ key$jscomp$0,
2844
2910
  null,
2845
2911
  loadServerReference$1
2846
2912
  )
@@ -2857,43 +2923,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2857
2923
  case "Q":
2858
2924
  return (
2859
2925
  (arrayRoot = value.slice(2)),
2860
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2926
+ getOutlinedModel(
2927
+ response,
2928
+ arrayRoot,
2929
+ obj,
2930
+ key$jscomp$0,
2931
+ null,
2932
+ createMap
2933
+ )
2861
2934
  );
2862
2935
  case "W":
2863
2936
  return (
2864
2937
  (arrayRoot = value.slice(2)),
2865
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2938
+ getOutlinedModel(
2939
+ response,
2940
+ arrayRoot,
2941
+ obj,
2942
+ key$jscomp$0,
2943
+ null,
2944
+ createSet
2945
+ )
2866
2946
  );
2867
2947
  case "K":
2868
- key = value.slice(2);
2869
- obj = response._prefix + "_";
2870
- key = obj + key + "_";
2871
- arrayRoot = new FormData();
2872
- for (response = response._formData; ; ) {
2873
- value = response.keys;
2874
- null === value &&
2875
- ((value = response.keys = Array.from(response.data.keys())),
2876
- (response.keyPointer = 0));
2877
- value = value[response.keyPointer];
2878
- if (void 0 === value) break;
2879
- if (value.startsWith(key)) {
2880
- reference = response.data.getAll(value);
2881
- for (
2882
- var referencedFormDataKey = value.slice(key.length), i = 0;
2883
- i < reference.length;
2884
- i++
2885
- )
2886
- arrayRoot.append(referencedFormDataKey, reference[i]);
2887
- response.data.delete(value);
2888
- response.keyPointer++;
2889
- } else if (value.startsWith(obj)) break;
2890
- else response.keyPointer++;
2948
+ obj = value.slice(2);
2949
+ obj = response._prefix + "_" + obj + "_";
2950
+ response = response._formData;
2951
+ key$jscomp$0 = new FormData();
2952
+ arrayRoot = response.referencedEntries;
2953
+ if (null !== arrayRoot) {
2954
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2955
+ reference = arrayRoot[value];
2956
+ var key = reference[0];
2957
+ if (!key.startsWith(obj)) break;
2958
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2959
+ value++;
2960
+ }
2961
+ response.keyPointer = value;
2891
2962
  }
2892
- return arrayRoot;
2963
+ return key$jscomp$0;
2893
2964
  case "i":
2894
2965
  return (
2895
2966
  (arrayRoot = value.slice(2)),
2896
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2967
+ getOutlinedModel(
2968
+ response,
2969
+ arrayRoot,
2970
+ obj,
2971
+ key$jscomp$0,
2972
+ null,
2973
+ extractIterator
2974
+ )
2897
2975
  );
2898
2976
  case "I":
2899
2977
  return Infinity;
@@ -2922,7 +3000,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2922
3000
  ArrayBuffer,
2923
3001
  1,
2924
3002
  obj,
2925
- key,
3003
+ key$jscomp$0,
2926
3004
  arrayRoot
2927
3005
  );
2928
3006
  case "O":
@@ -2932,7 +3010,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2932
3010
  Int8Array,
2933
3011
  1,
2934
3012
  obj,
2935
- key,
3013
+ key$jscomp$0,
2936
3014
  arrayRoot
2937
3015
  );
2938
3016
  case "o":
@@ -2942,7 +3020,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2942
3020
  Uint8Array,
2943
3021
  1,
2944
3022
  obj,
2945
- key,
3023
+ key$jscomp$0,
2946
3024
  arrayRoot
2947
3025
  );
2948
3026
  case "U":
@@ -2952,7 +3030,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2952
3030
  Uint8ClampedArray,
2953
3031
  1,
2954
3032
  obj,
2955
- key,
3033
+ key$jscomp$0,
2956
3034
  arrayRoot
2957
3035
  );
2958
3036
  case "S":
@@ -2962,7 +3040,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2962
3040
  Int16Array,
2963
3041
  2,
2964
3042
  obj,
2965
- key,
3043
+ key$jscomp$0,
2966
3044
  arrayRoot
2967
3045
  );
2968
3046
  case "s":
@@ -2972,7 +3050,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2972
3050
  Uint16Array,
2973
3051
  2,
2974
3052
  obj,
2975
- key,
3053
+ key$jscomp$0,
2976
3054
  arrayRoot
2977
3055
  );
2978
3056
  case "L":
@@ -2982,7 +3060,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2982
3060
  Int32Array,
2983
3061
  4,
2984
3062
  obj,
2985
- key,
3063
+ key$jscomp$0,
2986
3064
  arrayRoot
2987
3065
  );
2988
3066
  case "l":
@@ -2992,7 +3070,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2992
3070
  Uint32Array,
2993
3071
  4,
2994
3072
  obj,
2995
- key,
3073
+ key$jscomp$0,
2996
3074
  arrayRoot
2997
3075
  );
2998
3076
  case "G":
@@ -3002,7 +3080,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3002
3080
  Float32Array,
3003
3081
  4,
3004
3082
  obj,
3005
- key,
3083
+ key$jscomp$0,
3006
3084
  arrayRoot
3007
3085
  );
3008
3086
  case "g":
@@ -3012,7 +3090,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3012
3090
  Float64Array,
3013
3091
  8,
3014
3092
  obj,
3015
- key,
3093
+ key$jscomp$0,
3016
3094
  arrayRoot
3017
3095
  );
3018
3096
  case "M":
@@ -3022,7 +3100,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3022
3100
  BigInt64Array,
3023
3101
  8,
3024
3102
  obj,
3025
- key,
3103
+ key$jscomp$0,
3026
3104
  arrayRoot
3027
3105
  );
3028
3106
  case "m":
@@ -3032,7 +3110,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3032
3110
  BigUint64Array,
3033
3111
  8,
3034
3112
  obj,
3035
- key,
3113
+ key$jscomp$0,
3036
3114
  arrayRoot
3037
3115
  );
3038
3116
  case "V":
@@ -3042,13 +3120,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3042
3120
  DataView,
3043
3121
  1,
3044
3122
  obj,
3045
- key,
3123
+ key$jscomp$0,
3046
3124
  arrayRoot
3047
3125
  );
3048
3126
  case "B":
3049
3127
  return (
3050
3128
  (obj = parseInt(value.slice(2), 16)),
3051
- response._formData.data.get(response._prefix + obj)
3129
+ getBackingBlob(response._formData, response._prefix + obj)
3052
3130
  );
3053
3131
  case "R":
3054
3132
  return parseReadableStream(response, value, void 0);
@@ -3060,7 +3138,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3060
3138
  return parseAsyncIterable(response, value, !0);
3061
3139
  }
3062
3140
  value = value.slice(1);
3063
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3141
+ return getOutlinedModel(
3142
+ response,
3143
+ value,
3144
+ obj,
3145
+ key$jscomp$0,
3146
+ arrayRoot,
3147
+ createModel
3148
+ );
3064
3149
  }
3065
3150
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3066
3151
  return value;
@@ -3072,11 +3157,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3072
3157
  : new FormData(),
3073
3158
  arraySizeLimit =
3074
3159
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3075
- chunks = new Map();
3160
+ chunks = new Map(),
3161
+ backingStore = {
3162
+ prefix: formFieldPrefix,
3163
+ referencedEntries: null,
3164
+ keyPointer: 0,
3165
+ stringChunks: null,
3166
+ streamChunks: null,
3167
+ blobs: null
3168
+ };
3169
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3076
3170
  return {
3077
3171
  _bundlerConfig: bundlerConfig,
3078
3172
  _prefix: formFieldPrefix,
3079
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3173
+ _formData: backingStore,
3080
3174
  _chunks: chunks,
3081
3175
  _closed: !1,
3082
3176
  _closedReason: null,