react-server-dom-parcel 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.
@@ -70,31 +70,39 @@
70
70
  });
71
71
  }
72
72
  function writeChunkAndReturn(destination, chunk) {
73
- if (0 !== chunk.byteLength)
74
- if (2048 < chunk.byteLength)
75
- 0 < writtenBytes &&
76
- (destination.enqueue(
77
- new Uint8Array(currentView.buffer, 0, writtenBytes)
73
+ if (0 === chunk.byteLength)
74
+ if (supportsArrayBufferDetached) {
75
+ if (chunk.buffer.detached)
76
+ throw Error(
77
+ "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()`."
78
+ );
79
+ } else
80
+ didWarnAboutMissingArrayBufferDetached ||
81
+ (console.error(
82
+ "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 Edge runtime that supports ArrayBuffer.prototype.detached."
78
83
  ),
79
- (currentView = new Uint8Array(2048)),
80
- (writtenBytes = 0)),
81
- destination.enqueue(chunk);
82
- else {
83
- var allowableBytes = currentView.length - writtenBytes;
84
- allowableBytes < chunk.byteLength &&
85
- (0 === allowableBytes
86
- ? destination.enqueue(currentView)
87
- : (currentView.set(
88
- chunk.subarray(0, allowableBytes),
89
- writtenBytes
90
- ),
91
- destination.enqueue(currentView),
92
- (chunk = chunk.subarray(allowableBytes))),
93
- (currentView = new Uint8Array(2048)),
94
- (writtenBytes = 0));
95
- currentView.set(chunk, writtenBytes);
96
- writtenBytes += chunk.byteLength;
97
- }
84
+ (didWarnAboutMissingArrayBufferDetached = !0));
85
+ else if (2048 < chunk.byteLength)
86
+ 0 < writtenBytes &&
87
+ (destination.enqueue(
88
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
89
+ ),
90
+ (currentView = new Uint8Array(2048)),
91
+ (writtenBytes = 0)),
92
+ destination.enqueue(chunk);
93
+ else {
94
+ var allowableBytes = currentView.length - writtenBytes;
95
+ allowableBytes < chunk.byteLength &&
96
+ (0 === allowableBytes
97
+ ? destination.enqueue(currentView)
98
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
99
+ destination.enqueue(currentView),
100
+ (chunk = chunk.subarray(allowableBytes))),
101
+ (currentView = new Uint8Array(2048)),
102
+ (writtenBytes = 0));
103
+ currentView.set(chunk, writtenBytes);
104
+ writtenBytes += chunk.byteLength;
105
+ }
98
106
  return !0;
99
107
  }
100
108
  function stringToChunk(content) {
@@ -2109,14 +2117,35 @@
2109
2117
  }
2110
2118
  function emitTypedArrayChunk(request, id, tag, typedArray) {
2111
2119
  request.pendingChunks++;
2112
- var buffer = new Uint8Array(
2113
- typedArray.buffer,
2114
- typedArray.byteOffset,
2115
- typedArray.byteLength
2116
- );
2117
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
2118
- buffer = typedArray.byteLength;
2119
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
2120
+ a: {
2121
+ var view = new Uint8Array(
2122
+ typedArray.buffer,
2123
+ typedArray.byteOffset,
2124
+ typedArray.byteLength
2125
+ );
2126
+ if (2048 < typedArray.byteLength) {
2127
+ if (
2128
+ 0 !== typedArray.byteOffset ||
2129
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
2130
+ typedArray.buffer.resizable
2131
+ ) {
2132
+ typedArray = view.slice();
2133
+ break a;
2134
+ }
2135
+ if (!supportsArrayBufferDetached) {
2136
+ didWarnAboutMissingArrayBufferDetached ||
2137
+ (console.error(
2138
+ "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 upgrade to a modern Edge runtime."
2139
+ ),
2140
+ (didWarnAboutMissingArrayBufferDetached = !0));
2141
+ typedArray = view.slice();
2142
+ break a;
2143
+ }
2144
+ }
2145
+ typedArray = view;
2146
+ }
2147
+ view = typedArray.byteLength;
2148
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
2120
2149
  id = stringToChunk(id);
2121
2150
  request.completedRegularChunks.push(id, typedArray);
2122
2151
  }
@@ -2682,13 +2711,38 @@
2682
2711
  fatalError(request, error$2);
2683
2712
  }
2684
2713
  }
2685
- function appendBackingEntry(backingStore, key, value) {
2686
- backingStore.data.append(key, value);
2687
- value = backingStore.keys;
2688
- null === value
2689
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2690
- (backingStore.keyPointer = 0))
2691
- : value.push(key);
2714
+ function appendBackingEntry(backingStore, value, key) {
2715
+ var prefix = backingStore.prefix;
2716
+ if (key.startsWith(prefix)) {
2717
+ switch (key[prefix.length]) {
2718
+ case "_":
2719
+ prefix = backingStore.referencedEntries;
2720
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2721
+ prefix.push([key, value]);
2722
+ return;
2723
+ case "S":
2724
+ "string" === typeof value &&
2725
+ ((prefix = backingStore.streamChunks),
2726
+ null === prefix &&
2727
+ (prefix = backingStore.streamChunks = new Map()),
2728
+ (backingStore = prefix.get(key)),
2729
+ void 0 === backingStore
2730
+ ? prefix.set(key, [value])
2731
+ : backingStore.push(value));
2732
+ return;
2733
+ }
2734
+ "string" === typeof value
2735
+ ? ((prefix = backingStore.stringChunks),
2736
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2737
+ prefix.set(key, value))
2738
+ : ((prefix = backingStore.blobs),
2739
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2740
+ prefix.set(key, value));
2741
+ }
2742
+ }
2743
+ function getBackingBlob(backingStore, key) {
2744
+ backingStore = backingStore.blobs;
2745
+ return null === backingStore ? void 0 : backingStore.get(key);
2692
2746
  }
2693
2747
  function ReactPromise(status, value, reason) {
2694
2748
  this.status = status;
@@ -3001,9 +3055,11 @@
3001
3055
  function getChunk(response, id) {
3002
3056
  var chunks = response._chunks,
3003
3057
  chunk = chunks.get(id);
3004
- chunk ||
3005
- ((chunk = response._formData.data.get(response._prefix + id)),
3006
- (chunk =
3058
+ if (!chunk) {
3059
+ chunk = response._prefix;
3060
+ var stringChunks = response._formData.stringChunks;
3061
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
3062
+ chunk =
3007
3063
  "string" === typeof chunk
3008
3064
  ? new ReactPromise(
3009
3065
  "resolved_model",
@@ -3012,8 +3068,9 @@
3012
3068
  )
3013
3069
  : response._closed
3014
3070
  ? new ReactPromise("rejected", null, response._closedReason)
3015
- : new ReactPromise("pending", null, null)),
3016
- chunks.set(id, chunk));
3071
+ : new ReactPromise("pending", null, null);
3072
+ chunks.set(id, chunk);
3073
+ }
3017
3074
  return chunk;
3018
3075
  }
3019
3076
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3260,7 +3317,7 @@
3260
3317
  Error("Already initialized typed array.")
3261
3318
  )
3262
3319
  );
3263
- reference = response._formData.data.get(key).arrayBuffer();
3320
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3264
3321
  if (initializingHandler) {
3265
3322
  var handler = initializingHandler;
3266
3323
  handler.deps++;
@@ -3304,15 +3361,17 @@
3304
3361
  var chunks = response._chunks;
3305
3362
  stream = new ReactPromise("fulfilled", stream, controller);
3306
3363
  chunks.set(id, stream);
3307
- response = response._formData.data.getAll(response._prefix + id);
3308
- for (id = 0; id < response.length; id++)
3309
- (chunks = response[id]),
3310
- "string" === typeof chunks &&
3311
- ("C" === chunks[0]
3364
+ chunks = response._prefix;
3365
+ response = response._formData.streamChunks;
3366
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3367
+ if (void 0 !== id)
3368
+ for (response = 0; response < id.length; response++)
3369
+ (chunks = id[response]),
3370
+ "C" === chunks[0]
3312
3371
  ? controller.close(
3313
3372
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
3314
3373
  )
3315
- : controller.enqueueModel(chunks));
3374
+ : controller.enqueueModel(chunks);
3316
3375
  }
3317
3376
  function parseReadableStream(response, reference, type) {
3318
3377
  function enqueue(value) {
@@ -3476,7 +3535,14 @@
3476
3535
  });
3477
3536
  return iterator;
3478
3537
  }
3479
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3538
+ function parseModelString(
3539
+ response,
3540
+ obj,
3541
+ key$jscomp$0,
3542
+ value,
3543
+ reference,
3544
+ arrayRoot
3545
+ ) {
3480
3546
  if ("$" === value[0]) {
3481
3547
  switch (value[1]) {
3482
3548
  case "$":
@@ -3496,7 +3562,7 @@
3496
3562
  response,
3497
3563
  arrayRoot,
3498
3564
  obj,
3499
- key,
3565
+ key$jscomp$0,
3500
3566
  null,
3501
3567
  loadServerReference$1
3502
3568
  )
@@ -3516,41 +3582,44 @@
3516
3582
  case "Q":
3517
3583
  return (
3518
3584
  (arrayRoot = value.slice(2)),
3519
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3585
+ getOutlinedModel(
3586
+ response,
3587
+ arrayRoot,
3588
+ obj,
3589
+ key$jscomp$0,
3590
+ null,
3591
+ createMap
3592
+ )
3520
3593
  );
3521
3594
  case "W":
3522
3595
  return (
3523
3596
  (arrayRoot = value.slice(2)),
3524
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3597
+ getOutlinedModel(
3598
+ response,
3599
+ arrayRoot,
3600
+ obj,
3601
+ key$jscomp$0,
3602
+ null,
3603
+ createSet
3604
+ )
3525
3605
  );
3526
3606
  case "K":
3527
- key = value.slice(2);
3528
- obj = response._prefix + "_";
3529
- key = obj + key + "_";
3530
- arrayRoot = new FormData();
3531
- for (response = response._formData; ; ) {
3532
- value = response;
3533
- reference = value.keys;
3534
- null === reference &&
3535
- ((reference = value.keys = Array.from(value.data.keys())),
3536
- (value.keyPointer = 0));
3537
- value = reference[value.keyPointer];
3538
- if (void 0 === value) break;
3539
- if (value.startsWith(key)) {
3540
- reference = response.data.getAll(value);
3541
- for (
3542
- var referencedFormDataKey = value.slice(key.length), i = 0;
3543
- i < reference.length;
3544
- i++
3545
- )
3546
- arrayRoot.append(referencedFormDataKey, reference[i]);
3547
- reference = response;
3548
- reference.data.delete(value);
3549
- reference.keyPointer++;
3550
- } else if (value.startsWith(obj)) break;
3551
- else response.keyPointer++;
3607
+ key$jscomp$0 = value.slice(2);
3608
+ obj = response._formData;
3609
+ response = response._prefix + "_" + key$jscomp$0 + "_";
3610
+ key$jscomp$0 = new FormData();
3611
+ arrayRoot = obj.referencedEntries;
3612
+ if (null !== arrayRoot) {
3613
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
3614
+ reference = arrayRoot[value];
3615
+ var key = reference[0];
3616
+ if (!key.startsWith(response)) break;
3617
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
3618
+ value++;
3619
+ }
3620
+ obj.keyPointer = value;
3552
3621
  }
3553
- return arrayRoot;
3622
+ return key$jscomp$0;
3554
3623
  case "i":
3555
3624
  return (
3556
3625
  (arrayRoot = value.slice(2)),
@@ -3558,7 +3627,7 @@
3558
3627
  response,
3559
3628
  arrayRoot,
3560
3629
  obj,
3561
- key,
3630
+ key$jscomp$0,
3562
3631
  null,
3563
3632
  extractIterator
3564
3633
  )
@@ -3593,7 +3662,7 @@
3593
3662
  ArrayBuffer,
3594
3663
  1,
3595
3664
  obj,
3596
- key,
3665
+ key$jscomp$0,
3597
3666
  arrayRoot
3598
3667
  );
3599
3668
  case "O":
@@ -3603,7 +3672,7 @@
3603
3672
  Int8Array,
3604
3673
  1,
3605
3674
  obj,
3606
- key,
3675
+ key$jscomp$0,
3607
3676
  arrayRoot
3608
3677
  );
3609
3678
  case "o":
@@ -3613,7 +3682,7 @@
3613
3682
  Uint8Array,
3614
3683
  1,
3615
3684
  obj,
3616
- key,
3685
+ key$jscomp$0,
3617
3686
  arrayRoot
3618
3687
  );
3619
3688
  case "U":
@@ -3623,7 +3692,7 @@
3623
3692
  Uint8ClampedArray,
3624
3693
  1,
3625
3694
  obj,
3626
- key,
3695
+ key$jscomp$0,
3627
3696
  arrayRoot
3628
3697
  );
3629
3698
  case "S":
@@ -3633,7 +3702,7 @@
3633
3702
  Int16Array,
3634
3703
  2,
3635
3704
  obj,
3636
- key,
3705
+ key$jscomp$0,
3637
3706
  arrayRoot
3638
3707
  );
3639
3708
  case "s":
@@ -3643,7 +3712,7 @@
3643
3712
  Uint16Array,
3644
3713
  2,
3645
3714
  obj,
3646
- key,
3715
+ key$jscomp$0,
3647
3716
  arrayRoot
3648
3717
  );
3649
3718
  case "L":
@@ -3653,7 +3722,7 @@
3653
3722
  Int32Array,
3654
3723
  4,
3655
3724
  obj,
3656
- key,
3725
+ key$jscomp$0,
3657
3726
  arrayRoot
3658
3727
  );
3659
3728
  case "l":
@@ -3663,7 +3732,7 @@
3663
3732
  Uint32Array,
3664
3733
  4,
3665
3734
  obj,
3666
- key,
3735
+ key$jscomp$0,
3667
3736
  arrayRoot
3668
3737
  );
3669
3738
  case "G":
@@ -3673,7 +3742,7 @@
3673
3742
  Float32Array,
3674
3743
  4,
3675
3744
  obj,
3676
- key,
3745
+ key$jscomp$0,
3677
3746
  arrayRoot
3678
3747
  );
3679
3748
  case "g":
@@ -3683,7 +3752,7 @@
3683
3752
  Float64Array,
3684
3753
  8,
3685
3754
  obj,
3686
- key,
3755
+ key$jscomp$0,
3687
3756
  arrayRoot
3688
3757
  );
3689
3758
  case "M":
@@ -3693,7 +3762,7 @@
3693
3762
  BigInt64Array,
3694
3763
  8,
3695
3764
  obj,
3696
- key,
3765
+ key$jscomp$0,
3697
3766
  arrayRoot
3698
3767
  );
3699
3768
  case "m":
@@ -3703,7 +3772,7 @@
3703
3772
  BigUint64Array,
3704
3773
  8,
3705
3774
  obj,
3706
- key,
3775
+ key$jscomp$0,
3707
3776
  arrayRoot
3708
3777
  );
3709
3778
  case "V":
@@ -3713,13 +3782,13 @@
3713
3782
  DataView,
3714
3783
  1,
3715
3784
  obj,
3716
- key,
3785
+ key$jscomp$0,
3717
3786
  arrayRoot
3718
3787
  );
3719
3788
  case "B":
3720
3789
  return (
3721
3790
  (obj = parseInt(value.slice(2), 16)),
3722
- response._formData.data.get(response._prefix + obj)
3791
+ getBackingBlob(response._formData, response._prefix + obj)
3723
3792
  );
3724
3793
  case "R":
3725
3794
  return parseReadableStream(response, value, void 0);
@@ -3735,7 +3804,7 @@
3735
3804
  response,
3736
3805
  value,
3737
3806
  obj,
3738
- key,
3807
+ key$jscomp$0,
3739
3808
  arrayRoot,
3740
3809
  createModel
3741
3810
  );
@@ -3754,11 +3823,20 @@
3754
3823
  : new FormData(),
3755
3824
  arraySizeLimit =
3756
3825
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3757
- chunks = new Map();
3826
+ chunks = new Map(),
3827
+ backingStore = {
3828
+ prefix: formFieldPrefix,
3829
+ referencedEntries: null,
3830
+ keyPointer: 0,
3831
+ stringChunks: null,
3832
+ streamChunks: null,
3833
+ blobs: null
3834
+ };
3835
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3758
3836
  return {
3759
3837
  _bundlerConfig: bundlerConfig,
3760
3838
  _prefix: formFieldPrefix,
3761
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3839
+ _formData: backingStore,
3762
3840
  _chunks: chunks,
3763
3841
  _closed: !1,
3764
3842
  _closedReason: null,
@@ -3879,6 +3957,11 @@
3879
3957
  Symbol.for("react.postpone");
3880
3958
  var MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
3881
3959
  ASYNC_ITERATOR = Symbol.asyncIterator,
3960
+ supportsArrayBufferDetached = hasOwnProperty.call(
3961
+ ArrayBuffer.prototype,
3962
+ "detached"
3963
+ ),
3964
+ didWarnAboutMissingArrayBufferDetached = !1,
3882
3965
  LocalPromise = Promise,
3883
3966
  scheduleMicrotask =
3884
3967
  "function" === typeof queueMicrotask
@@ -4360,20 +4443,40 @@
4360
4443
  function progress(entry) {
4361
4444
  if (entry.done) close(response$jscomp$0);
4362
4445
  else {
4363
- entry = entry.value;
4364
- var name = entry[0];
4365
- entry = entry[1];
4366
- if ("string" === typeof entry) {
4367
- var response = response$jscomp$0;
4368
- appendBackingEntry(response._formData, name, entry);
4369
- var prefix = response._prefix;
4370
- if (name.startsWith(prefix)) {
4371
- var chunks = response._chunks;
4372
- name = +name.slice(prefix.length);
4373
- (chunks = chunks.get(name)) &&
4374
- resolveModelChunk(response, chunks, entry, name);
4446
+ var _entry$value = entry.value;
4447
+ entry = _entry$value[0];
4448
+ _entry$value = _entry$value[1];
4449
+ if ("string" === typeof _entry$value)
4450
+ a: {
4451
+ var response = response$jscomp$0,
4452
+ prefix = response._prefix;
4453
+ if (entry.startsWith(prefix)) {
4454
+ var chunks = response._chunks;
4455
+ if ("S" === entry[prefix.length]) {
4456
+ if (
4457
+ entry.length > prefix.length + 1 &&
4458
+ ((prefix = +entry.slice(prefix.length + 1)),
4459
+ (chunks = chunks.get(prefix)))
4460
+ ) {
4461
+ resolveModelChunk(response, chunks, _entry$value, prefix);
4462
+ break a;
4463
+ }
4464
+ } else if (
4465
+ ((prefix = +entry.slice(prefix.length)),
4466
+ (chunks = chunks.get(prefix)))
4467
+ ) {
4468
+ resolveModelChunk(response, chunks, _entry$value, prefix);
4469
+ break a;
4470
+ }
4471
+ }
4472
+ appendBackingEntry(response._formData, _entry$value, entry);
4375
4473
  }
4376
- } else appendBackingEntry(response$jscomp$0._formData, name, entry);
4474
+ else
4475
+ appendBackingEntry(
4476
+ response$jscomp$0._formData,
4477
+ _entry$value,
4478
+ entry
4479
+ );
4377
4480
  iterator.next().then(progress, error);
4378
4481
  }
4379
4482
  }