react-server-dom-turbopack 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];
@@ -1984,6 +2006,38 @@ function requireModule(metadata) {
1984
2006
  if (hasOwnProperty.call(moduleExports, metadata[2]))
1985
2007
  return moduleExports[metadata[2]];
1986
2008
  }
2009
+ function appendBackingEntry(backingStore, value, key) {
2010
+ var prefix = backingStore.prefix;
2011
+ if (key.startsWith(prefix)) {
2012
+ switch (key[prefix.length]) {
2013
+ case "_":
2014
+ prefix = backingStore.referencedEntries;
2015
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2016
+ prefix.push([key, value]);
2017
+ return;
2018
+ case "S":
2019
+ "string" === typeof value &&
2020
+ ((prefix = backingStore.streamChunks),
2021
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2022
+ (backingStore = prefix.get(key)),
2023
+ void 0 === backingStore
2024
+ ? prefix.set(key, [value])
2025
+ : backingStore.push(value));
2026
+ return;
2027
+ }
2028
+ "string" === typeof value
2029
+ ? ((prefix = backingStore.stringChunks),
2030
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2031
+ prefix.set(key, value))
2032
+ : ((prefix = backingStore.blobs),
2033
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2034
+ prefix.set(key, value));
2035
+ }
2036
+ }
2037
+ function getBackingBlob(backingStore, key) {
2038
+ backingStore = backingStore.blobs;
2039
+ return null === backingStore ? void 0 : backingStore.get(key);
2040
+ }
1987
2041
  var RESPONSE_SYMBOL = Symbol();
1988
2042
  function ReactPromise(status, value, reason) {
1989
2043
  this.status = status;
@@ -2355,15 +2409,18 @@ function reportGlobalError(response, error) {
2355
2409
  function getChunk(response, id) {
2356
2410
  var chunks = response._chunks,
2357
2411
  chunk = chunks.get(id);
2358
- chunk ||
2359
- ((chunk = response._formData.data.get(response._prefix + id)),
2360
- (chunk =
2412
+ if (!chunk) {
2413
+ chunk = response._prefix;
2414
+ var stringChunks = response._formData.stringChunks;
2415
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2416
+ chunk =
2361
2417
  "string" === typeof chunk
2362
2418
  ? createResolvedModelChunk(response, chunk, id)
2363
2419
  : response._closed
2364
2420
  ? new ReactPromise("rejected", null, response._closedReason)
2365
- : new ReactPromise("pending", null, null)),
2366
- chunks.set(id, chunk));
2421
+ : new ReactPromise("pending", null, null);
2422
+ chunks.set(id, chunk);
2423
+ }
2367
2424
  return chunk;
2368
2425
  }
2369
2426
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2594,7 +2651,7 @@ function parseTypedArray(
2594
2651
  Error("Already initialized typed array.")
2595
2652
  )
2596
2653
  );
2597
- reference = response._formData.data.get(key).arrayBuffer();
2654
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2598
2655
  if (initializingHandler) {
2599
2656
  var handler = initializingHandler;
2600
2657
  handler.deps++;
@@ -2638,13 +2695,15 @@ function resolveStream(response, id, stream, controller) {
2638
2695
  var chunks = response._chunks;
2639
2696
  stream = new ReactPromise("fulfilled", stream, controller);
2640
2697
  chunks.set(id, stream);
2641
- response = response._formData.data.getAll(response._prefix + id);
2642
- for (id = 0; id < response.length; id++)
2643
- (chunks = response[id]),
2644
- "string" === typeof chunks &&
2645
- ("C" === chunks[0]
2698
+ chunks = response._prefix;
2699
+ response = response._formData.streamChunks;
2700
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2701
+ if (void 0 !== id)
2702
+ for (response = 0; response < id.length; response++)
2703
+ (chunks = id[response]),
2704
+ "C" === chunks[0]
2646
2705
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2647
- : controller.enqueueModel(chunks));
2706
+ : controller.enqueueModel(chunks);
2648
2707
  }
2649
2708
  function parseReadableStream(response, reference, type) {
2650
2709
  function enqueue(value) {
@@ -2810,7 +2869,14 @@ function parseAsyncIterable(response, reference, iterator) {
2810
2869
  });
2811
2870
  return iterator;
2812
2871
  }
2813
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2872
+ function parseModelString(
2873
+ response,
2874
+ obj,
2875
+ key$jscomp$0,
2876
+ value,
2877
+ reference,
2878
+ arrayRoot
2879
+ ) {
2814
2880
  if ("$" === value[0]) {
2815
2881
  switch (value[1]) {
2816
2882
  case "$":
@@ -2828,7 +2894,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2828
2894
  response,
2829
2895
  arrayRoot,
2830
2896
  obj,
2831
- key,
2897
+ key$jscomp$0,
2832
2898
  null,
2833
2899
  loadServerReference$1
2834
2900
  )
@@ -2845,43 +2911,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2845
2911
  case "Q":
2846
2912
  return (
2847
2913
  (arrayRoot = value.slice(2)),
2848
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2914
+ getOutlinedModel(
2915
+ response,
2916
+ arrayRoot,
2917
+ obj,
2918
+ key$jscomp$0,
2919
+ null,
2920
+ createMap
2921
+ )
2849
2922
  );
2850
2923
  case "W":
2851
2924
  return (
2852
2925
  (arrayRoot = value.slice(2)),
2853
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2926
+ getOutlinedModel(
2927
+ response,
2928
+ arrayRoot,
2929
+ obj,
2930
+ key$jscomp$0,
2931
+ null,
2932
+ createSet
2933
+ )
2854
2934
  );
2855
2935
  case "K":
2856
- key = value.slice(2);
2857
- obj = response._prefix + "_";
2858
- key = obj + key + "_";
2859
- arrayRoot = new FormData();
2860
- for (response = response._formData; ; ) {
2861
- value = response.keys;
2862
- null === value &&
2863
- ((value = response.keys = Array.from(response.data.keys())),
2864
- (response.keyPointer = 0));
2865
- value = value[response.keyPointer];
2866
- if (void 0 === value) break;
2867
- if (value.startsWith(key)) {
2868
- reference = response.data.getAll(value);
2869
- for (
2870
- var referencedFormDataKey = value.slice(key.length), i = 0;
2871
- i < reference.length;
2872
- i++
2873
- )
2874
- arrayRoot.append(referencedFormDataKey, reference[i]);
2875
- response.data.delete(value);
2876
- response.keyPointer++;
2877
- } else if (value.startsWith(obj)) break;
2878
- else response.keyPointer++;
2936
+ obj = value.slice(2);
2937
+ obj = response._prefix + "_" + obj + "_";
2938
+ response = response._formData;
2939
+ key$jscomp$0 = new FormData();
2940
+ arrayRoot = response.referencedEntries;
2941
+ if (null !== arrayRoot) {
2942
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2943
+ reference = arrayRoot[value];
2944
+ var key = reference[0];
2945
+ if (!key.startsWith(obj)) break;
2946
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2947
+ value++;
2948
+ }
2949
+ response.keyPointer = value;
2879
2950
  }
2880
- return arrayRoot;
2951
+ return key$jscomp$0;
2881
2952
  case "i":
2882
2953
  return (
2883
2954
  (arrayRoot = value.slice(2)),
2884
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2955
+ getOutlinedModel(
2956
+ response,
2957
+ arrayRoot,
2958
+ obj,
2959
+ key$jscomp$0,
2960
+ null,
2961
+ extractIterator
2962
+ )
2885
2963
  );
2886
2964
  case "I":
2887
2965
  return Infinity;
@@ -2910,7 +2988,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2910
2988
  ArrayBuffer,
2911
2989
  1,
2912
2990
  obj,
2913
- key,
2991
+ key$jscomp$0,
2914
2992
  arrayRoot
2915
2993
  );
2916
2994
  case "O":
@@ -2920,7 +2998,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2920
2998
  Int8Array,
2921
2999
  1,
2922
3000
  obj,
2923
- key,
3001
+ key$jscomp$0,
2924
3002
  arrayRoot
2925
3003
  );
2926
3004
  case "o":
@@ -2930,7 +3008,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2930
3008
  Uint8Array,
2931
3009
  1,
2932
3010
  obj,
2933
- key,
3011
+ key$jscomp$0,
2934
3012
  arrayRoot
2935
3013
  );
2936
3014
  case "U":
@@ -2940,7 +3018,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2940
3018
  Uint8ClampedArray,
2941
3019
  1,
2942
3020
  obj,
2943
- key,
3021
+ key$jscomp$0,
2944
3022
  arrayRoot
2945
3023
  );
2946
3024
  case "S":
@@ -2950,7 +3028,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2950
3028
  Int16Array,
2951
3029
  2,
2952
3030
  obj,
2953
- key,
3031
+ key$jscomp$0,
2954
3032
  arrayRoot
2955
3033
  );
2956
3034
  case "s":
@@ -2960,7 +3038,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2960
3038
  Uint16Array,
2961
3039
  2,
2962
3040
  obj,
2963
- key,
3041
+ key$jscomp$0,
2964
3042
  arrayRoot
2965
3043
  );
2966
3044
  case "L":
@@ -2970,7 +3048,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2970
3048
  Int32Array,
2971
3049
  4,
2972
3050
  obj,
2973
- key,
3051
+ key$jscomp$0,
2974
3052
  arrayRoot
2975
3053
  );
2976
3054
  case "l":
@@ -2980,7 +3058,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2980
3058
  Uint32Array,
2981
3059
  4,
2982
3060
  obj,
2983
- key,
3061
+ key$jscomp$0,
2984
3062
  arrayRoot
2985
3063
  );
2986
3064
  case "G":
@@ -2990,7 +3068,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2990
3068
  Float32Array,
2991
3069
  4,
2992
3070
  obj,
2993
- key,
3071
+ key$jscomp$0,
2994
3072
  arrayRoot
2995
3073
  );
2996
3074
  case "g":
@@ -3000,7 +3078,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3000
3078
  Float64Array,
3001
3079
  8,
3002
3080
  obj,
3003
- key,
3081
+ key$jscomp$0,
3004
3082
  arrayRoot
3005
3083
  );
3006
3084
  case "M":
@@ -3010,7 +3088,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3010
3088
  BigInt64Array,
3011
3089
  8,
3012
3090
  obj,
3013
- key,
3091
+ key$jscomp$0,
3014
3092
  arrayRoot
3015
3093
  );
3016
3094
  case "m":
@@ -3020,7 +3098,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3020
3098
  BigUint64Array,
3021
3099
  8,
3022
3100
  obj,
3023
- key,
3101
+ key$jscomp$0,
3024
3102
  arrayRoot
3025
3103
  );
3026
3104
  case "V":
@@ -3030,13 +3108,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3030
3108
  DataView,
3031
3109
  1,
3032
3110
  obj,
3033
- key,
3111
+ key$jscomp$0,
3034
3112
  arrayRoot
3035
3113
  );
3036
3114
  case "B":
3037
3115
  return (
3038
3116
  (obj = parseInt(value.slice(2), 16)),
3039
- response._formData.data.get(response._prefix + obj)
3117
+ getBackingBlob(response._formData, response._prefix + obj)
3040
3118
  );
3041
3119
  case "R":
3042
3120
  return parseReadableStream(response, value, void 0);
@@ -3048,7 +3126,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3048
3126
  return parseAsyncIterable(response, value, !0);
3049
3127
  }
3050
3128
  value = value.slice(1);
3051
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3129
+ return getOutlinedModel(
3130
+ response,
3131
+ value,
3132
+ obj,
3133
+ key$jscomp$0,
3134
+ arrayRoot,
3135
+ createModel
3136
+ );
3052
3137
  }
3053
3138
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3054
3139
  return value;
@@ -3060,11 +3145,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3060
3145
  : new FormData(),
3061
3146
  arraySizeLimit =
3062
3147
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3063
- chunks = new Map();
3148
+ chunks = new Map(),
3149
+ backingStore = {
3150
+ prefix: formFieldPrefix,
3151
+ referencedEntries: null,
3152
+ keyPointer: 0,
3153
+ stringChunks: null,
3154
+ streamChunks: null,
3155
+ blobs: null
3156
+ };
3157
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3064
3158
  return {
3065
3159
  _bundlerConfig: bundlerConfig,
3066
3160
  _prefix: formFieldPrefix,
3067
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3161
+ _formData: backingStore,
3068
3162
  _chunks: chunks,
3069
3163
  _closed: !1,
3070
3164
  _closedReason: null,