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.
@@ -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];
@@ -1995,13 +2017,37 @@ function requireModule(metadata) {
1995
2017
  if (hasOwnProperty.call(moduleExports, metadata[2]))
1996
2018
  return moduleExports[metadata[2]];
1997
2019
  }
1998
- function appendBackingEntry(backingStore, key, value) {
1999
- backingStore.data.append(key, value);
2000
- value = backingStore.keys;
2001
- null === value
2002
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2003
- (backingStore.keyPointer = 0))
2004
- : value.push(key);
2020
+ function appendBackingEntry(backingStore, value, key) {
2021
+ var prefix = backingStore.prefix;
2022
+ if (key.startsWith(prefix)) {
2023
+ switch (key[prefix.length]) {
2024
+ case "_":
2025
+ prefix = backingStore.referencedEntries;
2026
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2027
+ prefix.push([key, value]);
2028
+ return;
2029
+ case "S":
2030
+ "string" === typeof value &&
2031
+ ((prefix = backingStore.streamChunks),
2032
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2033
+ (backingStore = prefix.get(key)),
2034
+ void 0 === backingStore
2035
+ ? prefix.set(key, [value])
2036
+ : backingStore.push(value));
2037
+ return;
2038
+ }
2039
+ "string" === typeof value
2040
+ ? ((prefix = backingStore.stringChunks),
2041
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2042
+ prefix.set(key, value))
2043
+ : ((prefix = backingStore.blobs),
2044
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2045
+ prefix.set(key, value));
2046
+ }
2047
+ }
2048
+ function getBackingBlob(backingStore, key) {
2049
+ backingStore = backingStore.blobs;
2050
+ return null === backingStore ? void 0 : backingStore.get(key);
2005
2051
  }
2006
2052
  var RESPONSE_SYMBOL = Symbol();
2007
2053
  function ReactPromise(status, value, reason) {
@@ -2374,15 +2420,18 @@ function reportGlobalError(response, error) {
2374
2420
  function getChunk(response, id) {
2375
2421
  var chunks = response._chunks,
2376
2422
  chunk = chunks.get(id);
2377
- chunk ||
2378
- ((chunk = response._formData.data.get(response._prefix + id)),
2379
- (chunk =
2423
+ if (!chunk) {
2424
+ chunk = response._prefix;
2425
+ var stringChunks = response._formData.stringChunks;
2426
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2427
+ chunk =
2380
2428
  "string" === typeof chunk
2381
2429
  ? createResolvedModelChunk(response, chunk, id)
2382
2430
  : response._closed
2383
2431
  ? new ReactPromise("rejected", null, response._closedReason)
2384
- : new ReactPromise("pending", null, null)),
2385
- chunks.set(id, chunk));
2432
+ : new ReactPromise("pending", null, null);
2433
+ chunks.set(id, chunk);
2434
+ }
2386
2435
  return chunk;
2387
2436
  }
2388
2437
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2613,7 +2662,7 @@ function parseTypedArray(
2613
2662
  Error("Already initialized typed array.")
2614
2663
  )
2615
2664
  );
2616
- reference = response._formData.data.get(key).arrayBuffer();
2665
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2617
2666
  if (initializingHandler) {
2618
2667
  var handler = initializingHandler;
2619
2668
  handler.deps++;
@@ -2657,13 +2706,15 @@ function resolveStream(response, id, stream, controller) {
2657
2706
  var chunks = response._chunks;
2658
2707
  stream = new ReactPromise("fulfilled", stream, controller);
2659
2708
  chunks.set(id, stream);
2660
- response = response._formData.data.getAll(response._prefix + id);
2661
- for (id = 0; id < response.length; id++)
2662
- (chunks = response[id]),
2663
- "string" === typeof chunks &&
2664
- ("C" === chunks[0]
2709
+ chunks = response._prefix;
2710
+ response = response._formData.streamChunks;
2711
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2712
+ if (void 0 !== id)
2713
+ for (response = 0; response < id.length; response++)
2714
+ (chunks = id[response]),
2715
+ "C" === chunks[0]
2665
2716
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2666
- : controller.enqueueModel(chunks));
2717
+ : controller.enqueueModel(chunks);
2667
2718
  }
2668
2719
  function parseReadableStream(response, reference, type) {
2669
2720
  function enqueue(value) {
@@ -2829,7 +2880,14 @@ function parseAsyncIterable(response, reference, iterator) {
2829
2880
  });
2830
2881
  return iterator;
2831
2882
  }
2832
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
2883
+ function parseModelString(
2884
+ response,
2885
+ obj,
2886
+ key$jscomp$0,
2887
+ value,
2888
+ reference,
2889
+ arrayRoot
2890
+ ) {
2833
2891
  if ("$" === value[0]) {
2834
2892
  switch (value[1]) {
2835
2893
  case "$":
@@ -2847,7 +2905,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2847
2905
  response,
2848
2906
  arrayRoot,
2849
2907
  obj,
2850
- key,
2908
+ key$jscomp$0,
2851
2909
  null,
2852
2910
  loadServerReference$1
2853
2911
  )
@@ -2864,43 +2922,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2864
2922
  case "Q":
2865
2923
  return (
2866
2924
  (arrayRoot = value.slice(2)),
2867
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
2925
+ getOutlinedModel(
2926
+ response,
2927
+ arrayRoot,
2928
+ obj,
2929
+ key$jscomp$0,
2930
+ null,
2931
+ createMap
2932
+ )
2868
2933
  );
2869
2934
  case "W":
2870
2935
  return (
2871
2936
  (arrayRoot = value.slice(2)),
2872
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
2937
+ getOutlinedModel(
2938
+ response,
2939
+ arrayRoot,
2940
+ obj,
2941
+ key$jscomp$0,
2942
+ null,
2943
+ createSet
2944
+ )
2873
2945
  );
2874
2946
  case "K":
2875
- key = value.slice(2);
2876
- obj = response._prefix + "_";
2877
- key = obj + key + "_";
2878
- arrayRoot = new FormData();
2879
- for (response = response._formData; ; ) {
2880
- value = response.keys;
2881
- null === value &&
2882
- ((value = response.keys = Array.from(response.data.keys())),
2883
- (response.keyPointer = 0));
2884
- value = value[response.keyPointer];
2885
- if (void 0 === value) break;
2886
- if (value.startsWith(key)) {
2887
- reference = response.data.getAll(value);
2888
- for (
2889
- var referencedFormDataKey = value.slice(key.length), i = 0;
2890
- i < reference.length;
2891
- i++
2892
- )
2893
- arrayRoot.append(referencedFormDataKey, reference[i]);
2894
- response.data.delete(value);
2895
- response.keyPointer++;
2896
- } else if (value.startsWith(obj)) break;
2897
- else response.keyPointer++;
2947
+ obj = value.slice(2);
2948
+ obj = response._prefix + "_" + obj + "_";
2949
+ response = response._formData;
2950
+ key$jscomp$0 = new FormData();
2951
+ arrayRoot = response.referencedEntries;
2952
+ if (null !== arrayRoot) {
2953
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
2954
+ reference = arrayRoot[value];
2955
+ var key = reference[0];
2956
+ if (!key.startsWith(obj)) break;
2957
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
2958
+ value++;
2959
+ }
2960
+ response.keyPointer = value;
2898
2961
  }
2899
- return arrayRoot;
2962
+ return key$jscomp$0;
2900
2963
  case "i":
2901
2964
  return (
2902
2965
  (arrayRoot = value.slice(2)),
2903
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
2966
+ getOutlinedModel(
2967
+ response,
2968
+ arrayRoot,
2969
+ obj,
2970
+ key$jscomp$0,
2971
+ null,
2972
+ extractIterator
2973
+ )
2904
2974
  );
2905
2975
  case "I":
2906
2976
  return Infinity;
@@ -2929,7 +2999,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2929
2999
  ArrayBuffer,
2930
3000
  1,
2931
3001
  obj,
2932
- key,
3002
+ key$jscomp$0,
2933
3003
  arrayRoot
2934
3004
  );
2935
3005
  case "O":
@@ -2939,7 +3009,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2939
3009
  Int8Array,
2940
3010
  1,
2941
3011
  obj,
2942
- key,
3012
+ key$jscomp$0,
2943
3013
  arrayRoot
2944
3014
  );
2945
3015
  case "o":
@@ -2949,7 +3019,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2949
3019
  Uint8Array,
2950
3020
  1,
2951
3021
  obj,
2952
- key,
3022
+ key$jscomp$0,
2953
3023
  arrayRoot
2954
3024
  );
2955
3025
  case "U":
@@ -2959,7 +3029,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2959
3029
  Uint8ClampedArray,
2960
3030
  1,
2961
3031
  obj,
2962
- key,
3032
+ key$jscomp$0,
2963
3033
  arrayRoot
2964
3034
  );
2965
3035
  case "S":
@@ -2969,7 +3039,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2969
3039
  Int16Array,
2970
3040
  2,
2971
3041
  obj,
2972
- key,
3042
+ key$jscomp$0,
2973
3043
  arrayRoot
2974
3044
  );
2975
3045
  case "s":
@@ -2979,7 +3049,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2979
3049
  Uint16Array,
2980
3050
  2,
2981
3051
  obj,
2982
- key,
3052
+ key$jscomp$0,
2983
3053
  arrayRoot
2984
3054
  );
2985
3055
  case "L":
@@ -2989,7 +3059,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2989
3059
  Int32Array,
2990
3060
  4,
2991
3061
  obj,
2992
- key,
3062
+ key$jscomp$0,
2993
3063
  arrayRoot
2994
3064
  );
2995
3065
  case "l":
@@ -2999,7 +3069,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
2999
3069
  Uint32Array,
3000
3070
  4,
3001
3071
  obj,
3002
- key,
3072
+ key$jscomp$0,
3003
3073
  arrayRoot
3004
3074
  );
3005
3075
  case "G":
@@ -3009,7 +3079,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3009
3079
  Float32Array,
3010
3080
  4,
3011
3081
  obj,
3012
- key,
3082
+ key$jscomp$0,
3013
3083
  arrayRoot
3014
3084
  );
3015
3085
  case "g":
@@ -3019,7 +3089,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3019
3089
  Float64Array,
3020
3090
  8,
3021
3091
  obj,
3022
- key,
3092
+ key$jscomp$0,
3023
3093
  arrayRoot
3024
3094
  );
3025
3095
  case "M":
@@ -3029,7 +3099,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3029
3099
  BigInt64Array,
3030
3100
  8,
3031
3101
  obj,
3032
- key,
3102
+ key$jscomp$0,
3033
3103
  arrayRoot
3034
3104
  );
3035
3105
  case "m":
@@ -3039,7 +3109,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3039
3109
  BigUint64Array,
3040
3110
  8,
3041
3111
  obj,
3042
- key,
3112
+ key$jscomp$0,
3043
3113
  arrayRoot
3044
3114
  );
3045
3115
  case "V":
@@ -3049,13 +3119,13 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3049
3119
  DataView,
3050
3120
  1,
3051
3121
  obj,
3052
- key,
3122
+ key$jscomp$0,
3053
3123
  arrayRoot
3054
3124
  );
3055
3125
  case "B":
3056
3126
  return (
3057
3127
  (obj = parseInt(value.slice(2), 16)),
3058
- response._formData.data.get(response._prefix + obj)
3128
+ getBackingBlob(response._formData, response._prefix + obj)
3059
3129
  );
3060
3130
  case "R":
3061
3131
  return parseReadableStream(response, value, void 0);
@@ -3067,7 +3137,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3067
3137
  return parseAsyncIterable(response, value, !0);
3068
3138
  }
3069
3139
  value = value.slice(1);
3070
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3140
+ return getOutlinedModel(
3141
+ response,
3142
+ value,
3143
+ obj,
3144
+ key$jscomp$0,
3145
+ arrayRoot,
3146
+ createModel
3147
+ );
3071
3148
  }
3072
3149
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3073
3150
  return value;
@@ -3079,11 +3156,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3079
3156
  : new FormData(),
3080
3157
  arraySizeLimit =
3081
3158
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3082
- chunks = new Map();
3159
+ chunks = new Map(),
3160
+ backingStore = {
3161
+ prefix: formFieldPrefix,
3162
+ referencedEntries: null,
3163
+ keyPointer: 0,
3164
+ stringChunks: null,
3165
+ streamChunks: null,
3166
+ blobs: null
3167
+ };
3168
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3083
3169
  return {
3084
3170
  _bundlerConfig: bundlerConfig,
3085
3171
  _prefix: formFieldPrefix,
3086
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3172
+ _formData: backingStore,
3087
3173
  _chunks: chunks,
3088
3174
  _closed: !1,
3089
3175
  _closedReason: null,
@@ -3213,19 +3299,34 @@ exports.decodeReplyFromAsyncIterable = function (
3213
3299
  function progress(entry) {
3214
3300
  if (entry.done) close(response);
3215
3301
  else {
3216
- entry = entry.value;
3217
- var name = entry[0];
3218
- entry = entry[1];
3219
- if ("string" === typeof entry) {
3220
- appendBackingEntry(response._formData, name, entry);
3221
- var prefix = response._prefix;
3222
- if (name.startsWith(prefix)) {
3223
- var chunks = response._chunks;
3224
- name = +name.slice(prefix.length);
3225
- (chunks = chunks.get(name)) &&
3226
- resolveModelChunk(response, chunks, entry, name);
3302
+ var _entry$value = entry.value;
3303
+ entry = _entry$value[0];
3304
+ _entry$value = _entry$value[1];
3305
+ if ("string" === typeof _entry$value)
3306
+ a: {
3307
+ var prefix = response._prefix;
3308
+ if (entry.startsWith(prefix)) {
3309
+ var chunks = response._chunks;
3310
+ if ("S" === entry[prefix.length]) {
3311
+ if (
3312
+ entry.length > prefix.length + 1 &&
3313
+ ((prefix = +entry.slice(prefix.length + 1)),
3314
+ (chunks = chunks.get(prefix)))
3315
+ ) {
3316
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3317
+ break a;
3318
+ }
3319
+ } else if (
3320
+ ((prefix = +entry.slice(prefix.length)),
3321
+ (chunks = chunks.get(prefix)))
3322
+ ) {
3323
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3324
+ break a;
3325
+ }
3326
+ }
3327
+ appendBackingEntry(response._formData, _entry$value, entry);
3227
3328
  }
3228
- } else appendBackingEntry(response._formData, name, entry);
3329
+ else appendBackingEntry(response._formData, _entry$value, entry);
3229
3330
  iterator.next().then(progress, error);
3230
3331
  }
3231
3332
  }