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.
@@ -43,31 +43,39 @@
43
43
  });
44
44
  }
45
45
  function writeChunkAndReturn(destination, chunk) {
46
- if (0 !== chunk.byteLength)
47
- if (2048 < chunk.byteLength)
48
- 0 < writtenBytes &&
49
- (destination.enqueue(
50
- new Uint8Array(currentView.buffer, 0, writtenBytes)
46
+ if (0 === chunk.byteLength)
47
+ if (supportsArrayBufferDetached) {
48
+ if (chunk.buffer.detached)
49
+ throw Error(
50
+ "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()`."
51
+ );
52
+ } else
53
+ didWarnAboutMissingArrayBufferDetached ||
54
+ (console.error(
55
+ "React encountered an empty buffer when writing in an environment that does not support ArrayBuffer.prototype.detached. This could be a security issue if the buffer was not actually empty. Please use a modern browser that supports ArrayBuffer.prototype.detached."
51
56
  ),
52
- (currentView = new Uint8Array(2048)),
53
- (writtenBytes = 0)),
54
- destination.enqueue(chunk);
55
- else {
56
- var allowableBytes = currentView.length - writtenBytes;
57
- allowableBytes < chunk.byteLength &&
58
- (0 === allowableBytes
59
- ? destination.enqueue(currentView)
60
- : (currentView.set(
61
- chunk.subarray(0, allowableBytes),
62
- writtenBytes
63
- ),
64
- destination.enqueue(currentView),
65
- (chunk = chunk.subarray(allowableBytes))),
66
- (currentView = new Uint8Array(2048)),
67
- (writtenBytes = 0));
68
- currentView.set(chunk, writtenBytes);
69
- writtenBytes += chunk.byteLength;
70
- }
57
+ (didWarnAboutMissingArrayBufferDetached = !0));
58
+ else if (2048 < chunk.byteLength)
59
+ 0 < writtenBytes &&
60
+ (destination.enqueue(
61
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
62
+ ),
63
+ (currentView = new Uint8Array(2048)),
64
+ (writtenBytes = 0)),
65
+ destination.enqueue(chunk);
66
+ else {
67
+ var allowableBytes = currentView.length - writtenBytes;
68
+ allowableBytes < chunk.byteLength &&
69
+ (0 === allowableBytes
70
+ ? destination.enqueue(currentView)
71
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
72
+ destination.enqueue(currentView),
73
+ (chunk = chunk.subarray(allowableBytes))),
74
+ (currentView = new Uint8Array(2048)),
75
+ (writtenBytes = 0));
76
+ currentView.set(chunk, writtenBytes);
77
+ writtenBytes += chunk.byteLength;
78
+ }
71
79
  return !0;
72
80
  }
73
81
  function stringToChunk(content) {
@@ -2110,14 +2118,35 @@
2110
2118
  }
2111
2119
  function emitTypedArrayChunk(request, id, tag, typedArray) {
2112
2120
  request.pendingChunks++;
2113
- var buffer = new Uint8Array(
2114
- typedArray.buffer,
2115
- typedArray.byteOffset,
2116
- typedArray.byteLength
2117
- );
2118
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
2119
- buffer = typedArray.byteLength;
2120
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
2121
+ a: {
2122
+ var view = new Uint8Array(
2123
+ typedArray.buffer,
2124
+ typedArray.byteOffset,
2125
+ typedArray.byteLength
2126
+ );
2127
+ if (2048 < typedArray.byteLength) {
2128
+ if (
2129
+ 0 !== typedArray.byteOffset ||
2130
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
2131
+ typedArray.buffer.resizable
2132
+ ) {
2133
+ typedArray = view.slice();
2134
+ break a;
2135
+ }
2136
+ if (!supportsArrayBufferDetached) {
2137
+ didWarnAboutMissingArrayBufferDetached ||
2138
+ (console.error(
2139
+ "React copied a partial view into a fresh buffer as a safety precaution because the environment does not implement ArrayBuffer.prototype.detached. This negatively impacts performance. Please use a modern browser that supports ArrayBuffer.prototype.detached."
2140
+ ),
2141
+ (didWarnAboutMissingArrayBufferDetached = !0));
2142
+ typedArray = view.slice();
2143
+ break a;
2144
+ }
2145
+ }
2146
+ typedArray = view;
2147
+ }
2148
+ view = typedArray.byteLength;
2149
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
2121
2150
  id = stringToChunk(id);
2122
2151
  request.completedRegularChunks.push(id, typedArray);
2123
2152
  }
@@ -2752,6 +2781,39 @@
2752
2781
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2753
2782
  return moduleExports[metadata[2]];
2754
2783
  }
2784
+ function appendBackingEntry(backingStore, value, key) {
2785
+ var prefix = backingStore.prefix;
2786
+ if (key.startsWith(prefix)) {
2787
+ switch (key[prefix.length]) {
2788
+ case "_":
2789
+ prefix = backingStore.referencedEntries;
2790
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2791
+ prefix.push([key, value]);
2792
+ return;
2793
+ case "S":
2794
+ "string" === typeof value &&
2795
+ ((prefix = backingStore.streamChunks),
2796
+ null === prefix &&
2797
+ (prefix = backingStore.streamChunks = new Map()),
2798
+ (backingStore = prefix.get(key)),
2799
+ void 0 === backingStore
2800
+ ? prefix.set(key, [value])
2801
+ : backingStore.push(value));
2802
+ return;
2803
+ }
2804
+ "string" === typeof value
2805
+ ? ((prefix = backingStore.stringChunks),
2806
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2807
+ prefix.set(key, value))
2808
+ : ((prefix = backingStore.blobs),
2809
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2810
+ prefix.set(key, value));
2811
+ }
2812
+ }
2813
+ function getBackingBlob(backingStore, key) {
2814
+ backingStore = backingStore.blobs;
2815
+ return null === backingStore ? void 0 : backingStore.get(key);
2816
+ }
2755
2817
  function ReactPromise(status, value, reason) {
2756
2818
  this.status = status;
2757
2819
  this.value = value;
@@ -3063,9 +3125,11 @@
3063
3125
  function getChunk(response, id) {
3064
3126
  var chunks = response._chunks,
3065
3127
  chunk = chunks.get(id);
3066
- chunk ||
3067
- ((chunk = response._formData.data.get(response._prefix + id)),
3068
- (chunk =
3128
+ if (!chunk) {
3129
+ chunk = response._prefix;
3130
+ var stringChunks = response._formData.stringChunks;
3131
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
3132
+ chunk =
3069
3133
  "string" === typeof chunk
3070
3134
  ? new ReactPromise(
3071
3135
  "resolved_model",
@@ -3074,8 +3138,9 @@
3074
3138
  )
3075
3139
  : response._closed
3076
3140
  ? new ReactPromise("rejected", null, response._closedReason)
3077
- : new ReactPromise("pending", null, null)),
3078
- chunks.set(id, chunk));
3141
+ : new ReactPromise("pending", null, null);
3142
+ chunks.set(id, chunk);
3143
+ }
3079
3144
  return chunk;
3080
3145
  }
3081
3146
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3322,7 +3387,7 @@
3322
3387
  Error("Already initialized typed array.")
3323
3388
  )
3324
3389
  );
3325
- reference = response._formData.data.get(key).arrayBuffer();
3390
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3326
3391
  if (initializingHandler) {
3327
3392
  var handler = initializingHandler;
3328
3393
  handler.deps++;
@@ -3366,15 +3431,17 @@
3366
3431
  var chunks = response._chunks;
3367
3432
  stream = new ReactPromise("fulfilled", stream, controller);
3368
3433
  chunks.set(id, stream);
3369
- response = response._formData.data.getAll(response._prefix + id);
3370
- for (id = 0; id < response.length; id++)
3371
- (chunks = response[id]),
3372
- "string" === typeof chunks &&
3373
- ("C" === chunks[0]
3434
+ chunks = response._prefix;
3435
+ response = response._formData.streamChunks;
3436
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3437
+ if (void 0 !== id)
3438
+ for (response = 0; response < id.length; response++)
3439
+ (chunks = id[response]),
3440
+ "C" === chunks[0]
3374
3441
  ? controller.close(
3375
3442
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
3376
3443
  )
3377
- : controller.enqueueModel(chunks));
3444
+ : controller.enqueueModel(chunks);
3378
3445
  }
3379
3446
  function parseReadableStream(response, reference, type) {
3380
3447
  function enqueue(value) {
@@ -3538,7 +3605,14 @@
3538
3605
  });
3539
3606
  return iterator;
3540
3607
  }
3541
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3608
+ function parseModelString(
3609
+ response,
3610
+ obj,
3611
+ key$jscomp$0,
3612
+ value,
3613
+ reference,
3614
+ arrayRoot
3615
+ ) {
3542
3616
  if ("$" === value[0]) {
3543
3617
  switch (value[1]) {
3544
3618
  case "$":
@@ -3558,7 +3632,7 @@
3558
3632
  response,
3559
3633
  arrayRoot,
3560
3634
  obj,
3561
- key,
3635
+ key$jscomp$0,
3562
3636
  null,
3563
3637
  loadServerReference$1
3564
3638
  )
@@ -3578,41 +3652,44 @@
3578
3652
  case "Q":
3579
3653
  return (
3580
3654
  (arrayRoot = value.slice(2)),
3581
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3655
+ getOutlinedModel(
3656
+ response,
3657
+ arrayRoot,
3658
+ obj,
3659
+ key$jscomp$0,
3660
+ null,
3661
+ createMap
3662
+ )
3582
3663
  );
3583
3664
  case "W":
3584
3665
  return (
3585
3666
  (arrayRoot = value.slice(2)),
3586
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3667
+ getOutlinedModel(
3668
+ response,
3669
+ arrayRoot,
3670
+ obj,
3671
+ key$jscomp$0,
3672
+ null,
3673
+ createSet
3674
+ )
3587
3675
  );
3588
3676
  case "K":
3589
- key = value.slice(2);
3590
- obj = response._prefix + "_";
3591
- key = obj + key + "_";
3592
- arrayRoot = new FormData();
3593
- for (response = response._formData; ; ) {
3594
- value = response;
3595
- reference = value.keys;
3596
- null === reference &&
3597
- ((reference = value.keys = Array.from(value.data.keys())),
3598
- (value.keyPointer = 0));
3599
- value = reference[value.keyPointer];
3600
- if (void 0 === value) break;
3601
- if (value.startsWith(key)) {
3602
- reference = response.data.getAll(value);
3603
- for (
3604
- var referencedFormDataKey = value.slice(key.length), i = 0;
3605
- i < reference.length;
3606
- i++
3607
- )
3608
- arrayRoot.append(referencedFormDataKey, reference[i]);
3609
- reference = response;
3610
- reference.data.delete(value);
3611
- reference.keyPointer++;
3612
- } else if (value.startsWith(obj)) break;
3613
- else response.keyPointer++;
3677
+ key$jscomp$0 = value.slice(2);
3678
+ obj = response._formData;
3679
+ response = response._prefix + "_" + key$jscomp$0 + "_";
3680
+ key$jscomp$0 = new FormData();
3681
+ arrayRoot = obj.referencedEntries;
3682
+ if (null !== arrayRoot) {
3683
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
3684
+ reference = arrayRoot[value];
3685
+ var key = reference[0];
3686
+ if (!key.startsWith(response)) break;
3687
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
3688
+ value++;
3689
+ }
3690
+ obj.keyPointer = value;
3614
3691
  }
3615
- return arrayRoot;
3692
+ return key$jscomp$0;
3616
3693
  case "i":
3617
3694
  return (
3618
3695
  (arrayRoot = value.slice(2)),
@@ -3620,7 +3697,7 @@
3620
3697
  response,
3621
3698
  arrayRoot,
3622
3699
  obj,
3623
- key,
3700
+ key$jscomp$0,
3624
3701
  null,
3625
3702
  extractIterator
3626
3703
  )
@@ -3655,7 +3732,7 @@
3655
3732
  ArrayBuffer,
3656
3733
  1,
3657
3734
  obj,
3658
- key,
3735
+ key$jscomp$0,
3659
3736
  arrayRoot
3660
3737
  );
3661
3738
  case "O":
@@ -3665,7 +3742,7 @@
3665
3742
  Int8Array,
3666
3743
  1,
3667
3744
  obj,
3668
- key,
3745
+ key$jscomp$0,
3669
3746
  arrayRoot
3670
3747
  );
3671
3748
  case "o":
@@ -3675,7 +3752,7 @@
3675
3752
  Uint8Array,
3676
3753
  1,
3677
3754
  obj,
3678
- key,
3755
+ key$jscomp$0,
3679
3756
  arrayRoot
3680
3757
  );
3681
3758
  case "U":
@@ -3685,7 +3762,7 @@
3685
3762
  Uint8ClampedArray,
3686
3763
  1,
3687
3764
  obj,
3688
- key,
3765
+ key$jscomp$0,
3689
3766
  arrayRoot
3690
3767
  );
3691
3768
  case "S":
@@ -3695,7 +3772,7 @@
3695
3772
  Int16Array,
3696
3773
  2,
3697
3774
  obj,
3698
- key,
3775
+ key$jscomp$0,
3699
3776
  arrayRoot
3700
3777
  );
3701
3778
  case "s":
@@ -3705,7 +3782,7 @@
3705
3782
  Uint16Array,
3706
3783
  2,
3707
3784
  obj,
3708
- key,
3785
+ key$jscomp$0,
3709
3786
  arrayRoot
3710
3787
  );
3711
3788
  case "L":
@@ -3715,7 +3792,7 @@
3715
3792
  Int32Array,
3716
3793
  4,
3717
3794
  obj,
3718
- key,
3795
+ key$jscomp$0,
3719
3796
  arrayRoot
3720
3797
  );
3721
3798
  case "l":
@@ -3725,7 +3802,7 @@
3725
3802
  Uint32Array,
3726
3803
  4,
3727
3804
  obj,
3728
- key,
3805
+ key$jscomp$0,
3729
3806
  arrayRoot
3730
3807
  );
3731
3808
  case "G":
@@ -3735,7 +3812,7 @@
3735
3812
  Float32Array,
3736
3813
  4,
3737
3814
  obj,
3738
- key,
3815
+ key$jscomp$0,
3739
3816
  arrayRoot
3740
3817
  );
3741
3818
  case "g":
@@ -3745,7 +3822,7 @@
3745
3822
  Float64Array,
3746
3823
  8,
3747
3824
  obj,
3748
- key,
3825
+ key$jscomp$0,
3749
3826
  arrayRoot
3750
3827
  );
3751
3828
  case "M":
@@ -3755,7 +3832,7 @@
3755
3832
  BigInt64Array,
3756
3833
  8,
3757
3834
  obj,
3758
- key,
3835
+ key$jscomp$0,
3759
3836
  arrayRoot
3760
3837
  );
3761
3838
  case "m":
@@ -3765,7 +3842,7 @@
3765
3842
  BigUint64Array,
3766
3843
  8,
3767
3844
  obj,
3768
- key,
3845
+ key$jscomp$0,
3769
3846
  arrayRoot
3770
3847
  );
3771
3848
  case "V":
@@ -3775,13 +3852,13 @@
3775
3852
  DataView,
3776
3853
  1,
3777
3854
  obj,
3778
- key,
3855
+ key$jscomp$0,
3779
3856
  arrayRoot
3780
3857
  );
3781
3858
  case "B":
3782
3859
  return (
3783
3860
  (obj = parseInt(value.slice(2), 16)),
3784
- response._formData.data.get(response._prefix + obj)
3861
+ getBackingBlob(response._formData, response._prefix + obj)
3785
3862
  );
3786
3863
  case "R":
3787
3864
  return parseReadableStream(response, value, void 0);
@@ -3797,7 +3874,7 @@
3797
3874
  response,
3798
3875
  value,
3799
3876
  obj,
3800
- key,
3877
+ key$jscomp$0,
3801
3878
  arrayRoot,
3802
3879
  createModel
3803
3880
  );
@@ -3816,11 +3893,20 @@
3816
3893
  : new FormData(),
3817
3894
  arraySizeLimit =
3818
3895
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3819
- chunks = new Map();
3896
+ chunks = new Map(),
3897
+ backingStore = {
3898
+ prefix: formFieldPrefix,
3899
+ referencedEntries: null,
3900
+ keyPointer: 0,
3901
+ stringChunks: null,
3902
+ streamChunks: null,
3903
+ blobs: null
3904
+ };
3905
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3820
3906
  return {
3821
3907
  _bundlerConfig: bundlerConfig,
3822
3908
  _prefix: formFieldPrefix,
3823
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3909
+ _formData: backingStore,
3824
3910
  _chunks: chunks,
3825
3911
  _closed: !1,
3826
3912
  _closedReason: null,
@@ -3879,13 +3965,19 @@
3879
3965
  }
3880
3966
  var ReactDOM = require("react-dom"),
3881
3967
  React = require("react"),
3968
+ hasOwnProperty = Object.prototype.hasOwnProperty,
3882
3969
  channel = new MessageChannel(),
3883
3970
  taskQueue = [];
3884
3971
  channel.port1.onmessage = function () {
3885
3972
  var task = taskQueue.shift();
3886
3973
  task && task();
3887
3974
  };
3888
- var LocalPromise = Promise,
3975
+ var supportsArrayBufferDetached = hasOwnProperty.call(
3976
+ ArrayBuffer.prototype,
3977
+ "detached"
3978
+ ),
3979
+ didWarnAboutMissingArrayBufferDetached = !1,
3980
+ LocalPromise = Promise,
3889
3981
  scheduleMicrotask =
3890
3982
  "function" === typeof queueMicrotask
3891
3983
  ? queueMicrotask
@@ -4333,7 +4425,6 @@
4333
4425
  debugID = null,
4334
4426
  modelRoot = !1,
4335
4427
  emptyRoot = {},
4336
- hasOwnProperty = Object.prototype.hasOwnProperty,
4337
4428
  chunkCache = new Map(),
4338
4429
  RESPONSE_SYMBOL = Symbol();
4339
4430
  ReactPromise.prototype = Object.create(Promise.prototype);