react-server-dom-parcel 19.1.8 → 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.
@@ -66,31 +66,39 @@
66
66
  });
67
67
  }
68
68
  function writeChunkAndReturn(destination, chunk) {
69
- if (0 !== chunk.byteLength)
70
- if (2048 < chunk.byteLength)
71
- 0 < writtenBytes &&
72
- (destination.enqueue(
73
- new Uint8Array(currentView.buffer, 0, writtenBytes)
69
+ if (0 === chunk.byteLength)
70
+ if (supportsArrayBufferDetached) {
71
+ if (chunk.buffer.detached)
72
+ throw Error(
73
+ "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()`."
74
+ );
75
+ } else
76
+ didWarnAboutMissingArrayBufferDetached ||
77
+ (console.error(
78
+ "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."
74
79
  ),
75
- (currentView = new Uint8Array(2048)),
76
- (writtenBytes = 0)),
77
- destination.enqueue(chunk);
78
- else {
79
- var allowableBytes = currentView.length - writtenBytes;
80
- allowableBytes < chunk.byteLength &&
81
- (0 === allowableBytes
82
- ? destination.enqueue(currentView)
83
- : (currentView.set(
84
- chunk.subarray(0, allowableBytes),
85
- writtenBytes
86
- ),
87
- destination.enqueue(currentView),
88
- (chunk = chunk.subarray(allowableBytes))),
89
- (currentView = new Uint8Array(2048)),
90
- (writtenBytes = 0));
91
- currentView.set(chunk, writtenBytes);
92
- writtenBytes += chunk.byteLength;
93
- }
80
+ (didWarnAboutMissingArrayBufferDetached = !0));
81
+ else if (2048 < chunk.byteLength)
82
+ 0 < writtenBytes &&
83
+ (destination.enqueue(
84
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
85
+ ),
86
+ (currentView = new Uint8Array(2048)),
87
+ (writtenBytes = 0)),
88
+ destination.enqueue(chunk);
89
+ else {
90
+ var allowableBytes = currentView.length - writtenBytes;
91
+ allowableBytes < chunk.byteLength &&
92
+ (0 === allowableBytes
93
+ ? destination.enqueue(currentView)
94
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
95
+ destination.enqueue(currentView),
96
+ (chunk = chunk.subarray(allowableBytes))),
97
+ (currentView = new Uint8Array(2048)),
98
+ (writtenBytes = 0));
99
+ currentView.set(chunk, writtenBytes);
100
+ writtenBytes += chunk.byteLength;
101
+ }
94
102
  return !0;
95
103
  }
96
104
  function stringToChunk(content) {
@@ -859,7 +867,7 @@
859
867
  erroredTask(request, streamTask, reason),
860
868
  enqueueFlush(request),
861
869
  "function" === typeof iterator.throw &&
862
- iterator.throw(reason).then(error, error));
870
+ iterator.throw(reason).then(noop, noop));
863
871
  }
864
872
  function abortIterable(reason) {
865
873
  aborted ||
@@ -868,7 +876,7 @@
868
876
  erroredTask(request, streamTask, reason),
869
877
  enqueueFlush(request),
870
878
  "function" === typeof iterator.throw &&
871
- iterator.throw(reason).then(error, error));
879
+ iterator.throw(reason).then(noop, noop));
872
880
  }
873
881
  var isIterator = iterable === iterator,
874
882
  streamTask = createTask(
@@ -2035,14 +2043,35 @@
2035
2043
  }
2036
2044
  function emitTypedArrayChunk(request, id, tag, typedArray) {
2037
2045
  request.pendingChunks++;
2038
- var buffer = new Uint8Array(
2039
- typedArray.buffer,
2040
- typedArray.byteOffset,
2041
- typedArray.byteLength
2042
- );
2043
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
2044
- buffer = typedArray.byteLength;
2045
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
2046
+ a: {
2047
+ var view = new Uint8Array(
2048
+ typedArray.buffer,
2049
+ typedArray.byteOffset,
2050
+ typedArray.byteLength
2051
+ );
2052
+ if (2048 < typedArray.byteLength) {
2053
+ if (
2054
+ 0 !== typedArray.byteOffset ||
2055
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
2056
+ typedArray.buffer.resizable
2057
+ ) {
2058
+ typedArray = view.slice();
2059
+ break a;
2060
+ }
2061
+ if (!supportsArrayBufferDetached) {
2062
+ didWarnAboutMissingArrayBufferDetached ||
2063
+ (console.error(
2064
+ "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."
2065
+ ),
2066
+ (didWarnAboutMissingArrayBufferDetached = !0));
2067
+ typedArray = view.slice();
2068
+ break a;
2069
+ }
2070
+ }
2071
+ typedArray = view;
2072
+ }
2073
+ view = typedArray.byteLength;
2074
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
2046
2075
  id = stringToChunk(id);
2047
2076
  request.completedRegularChunks.push(id, typedArray);
2048
2077
  }
@@ -2604,6 +2633,39 @@
2604
2633
  fatalError(request, error$2);
2605
2634
  }
2606
2635
  }
2636
+ function appendBackingEntry(backingStore, value, key) {
2637
+ var prefix = backingStore.prefix;
2638
+ if (key.startsWith(prefix)) {
2639
+ switch (key[prefix.length]) {
2640
+ case "_":
2641
+ prefix = backingStore.referencedEntries;
2642
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2643
+ prefix.push([key, value]);
2644
+ return;
2645
+ case "S":
2646
+ "string" === typeof value &&
2647
+ ((prefix = backingStore.streamChunks),
2648
+ null === prefix &&
2649
+ (prefix = backingStore.streamChunks = new Map()),
2650
+ (backingStore = prefix.get(key)),
2651
+ void 0 === backingStore
2652
+ ? prefix.set(key, [value])
2653
+ : backingStore.push(value));
2654
+ return;
2655
+ }
2656
+ "string" === typeof value
2657
+ ? ((prefix = backingStore.stringChunks),
2658
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2659
+ prefix.set(key, value))
2660
+ : ((prefix = backingStore.blobs),
2661
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2662
+ prefix.set(key, value));
2663
+ }
2664
+ }
2665
+ function getBackingBlob(backingStore, key) {
2666
+ backingStore = backingStore.blobs;
2667
+ return null === backingStore ? void 0 : backingStore.get(key);
2668
+ }
2607
2669
  function ReactPromise(status, value, reason) {
2608
2670
  this.status = status;
2609
2671
  this.value = value;
@@ -2915,9 +2977,11 @@
2915
2977
  function getChunk(response, id) {
2916
2978
  var chunks = response._chunks,
2917
2979
  chunk = chunks.get(id);
2918
- chunk ||
2919
- ((chunk = response._formData.data.get(response._prefix + id)),
2920
- (chunk =
2980
+ if (!chunk) {
2981
+ chunk = response._prefix;
2982
+ var stringChunks = response._formData.stringChunks;
2983
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2984
+ chunk =
2921
2985
  "string" === typeof chunk
2922
2986
  ? new ReactPromise(
2923
2987
  "resolved_model",
@@ -2926,8 +2990,9 @@
2926
2990
  )
2927
2991
  : response._closed
2928
2992
  ? new ReactPromise("rejected", null, response._closedReason)
2929
- : new ReactPromise("pending", null, null)),
2930
- chunks.set(id, chunk));
2993
+ : new ReactPromise("pending", null, null);
2994
+ chunks.set(id, chunk);
2995
+ }
2931
2996
  return chunk;
2932
2997
  }
2933
2998
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3174,7 +3239,7 @@
3174
3239
  Error("Already initialized typed array.")
3175
3240
  )
3176
3241
  );
3177
- reference = response._formData.data.get(key).arrayBuffer();
3242
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3178
3243
  if (initializingHandler) {
3179
3244
  var handler = initializingHandler;
3180
3245
  handler.deps++;
@@ -3218,15 +3283,17 @@
3218
3283
  var chunks = response._chunks;
3219
3284
  stream = new ReactPromise("fulfilled", stream, controller);
3220
3285
  chunks.set(id, stream);
3221
- response = response._formData.data.getAll(response._prefix + id);
3222
- for (id = 0; id < response.length; id++)
3223
- (chunks = response[id]),
3224
- "string" === typeof chunks &&
3225
- ("C" === chunks[0]
3286
+ chunks = response._prefix;
3287
+ response = response._formData.streamChunks;
3288
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3289
+ if (void 0 !== id)
3290
+ for (response = 0; response < id.length; response++)
3291
+ (chunks = id[response]),
3292
+ "C" === chunks[0]
3226
3293
  ? controller.close(
3227
3294
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
3228
3295
  )
3229
- : controller.enqueueModel(chunks));
3296
+ : controller.enqueueModel(chunks);
3230
3297
  }
3231
3298
  function parseReadableStream(response, reference, type) {
3232
3299
  function enqueue(value) {
@@ -3390,7 +3457,14 @@
3390
3457
  });
3391
3458
  return iterator;
3392
3459
  }
3393
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3460
+ function parseModelString(
3461
+ response,
3462
+ obj,
3463
+ key$jscomp$0,
3464
+ value,
3465
+ reference,
3466
+ arrayRoot
3467
+ ) {
3394
3468
  if ("$" === value[0]) {
3395
3469
  switch (value[1]) {
3396
3470
  case "$":
@@ -3410,7 +3484,7 @@
3410
3484
  response,
3411
3485
  arrayRoot,
3412
3486
  obj,
3413
- key,
3487
+ key$jscomp$0,
3414
3488
  null,
3415
3489
  loadServerReference$1
3416
3490
  )
@@ -3430,41 +3504,44 @@
3430
3504
  case "Q":
3431
3505
  return (
3432
3506
  (arrayRoot = value.slice(2)),
3433
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3507
+ getOutlinedModel(
3508
+ response,
3509
+ arrayRoot,
3510
+ obj,
3511
+ key$jscomp$0,
3512
+ null,
3513
+ createMap
3514
+ )
3434
3515
  );
3435
3516
  case "W":
3436
3517
  return (
3437
3518
  (arrayRoot = value.slice(2)),
3438
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3519
+ getOutlinedModel(
3520
+ response,
3521
+ arrayRoot,
3522
+ obj,
3523
+ key$jscomp$0,
3524
+ null,
3525
+ createSet
3526
+ )
3439
3527
  );
3440
3528
  case "K":
3441
- key = value.slice(2);
3442
- obj = response._prefix + "_";
3443
- key = obj + key + "_";
3444
- arrayRoot = new FormData();
3445
- for (response = response._formData; ; ) {
3446
- value = response;
3447
- reference = value.keys;
3448
- null === reference &&
3449
- ((reference = value.keys = Array.from(value.data.keys())),
3450
- (value.keyPointer = 0));
3451
- value = reference[value.keyPointer];
3452
- if (void 0 === value) break;
3453
- if (value.startsWith(key)) {
3454
- reference = response.data.getAll(value);
3455
- for (
3456
- var referencedFormDataKey = value.slice(key.length), i = 0;
3457
- i < reference.length;
3458
- i++
3459
- )
3460
- arrayRoot.append(referencedFormDataKey, reference[i]);
3461
- reference = response;
3462
- reference.data.delete(value);
3463
- reference.keyPointer++;
3464
- } else if (value.startsWith(obj)) break;
3465
- else response.keyPointer++;
3529
+ key$jscomp$0 = value.slice(2);
3530
+ obj = response._formData;
3531
+ response = response._prefix + "_" + key$jscomp$0 + "_";
3532
+ key$jscomp$0 = new FormData();
3533
+ arrayRoot = obj.referencedEntries;
3534
+ if (null !== arrayRoot) {
3535
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
3536
+ reference = arrayRoot[value];
3537
+ var key = reference[0];
3538
+ if (!key.startsWith(response)) break;
3539
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
3540
+ value++;
3541
+ }
3542
+ obj.keyPointer = value;
3466
3543
  }
3467
- return arrayRoot;
3544
+ return key$jscomp$0;
3468
3545
  case "i":
3469
3546
  return (
3470
3547
  (arrayRoot = value.slice(2)),
@@ -3472,7 +3549,7 @@
3472
3549
  response,
3473
3550
  arrayRoot,
3474
3551
  obj,
3475
- key,
3552
+ key$jscomp$0,
3476
3553
  null,
3477
3554
  extractIterator
3478
3555
  )
@@ -3507,7 +3584,7 @@
3507
3584
  ArrayBuffer,
3508
3585
  1,
3509
3586
  obj,
3510
- key,
3587
+ key$jscomp$0,
3511
3588
  arrayRoot
3512
3589
  );
3513
3590
  case "O":
@@ -3517,7 +3594,7 @@
3517
3594
  Int8Array,
3518
3595
  1,
3519
3596
  obj,
3520
- key,
3597
+ key$jscomp$0,
3521
3598
  arrayRoot
3522
3599
  );
3523
3600
  case "o":
@@ -3527,7 +3604,7 @@
3527
3604
  Uint8Array,
3528
3605
  1,
3529
3606
  obj,
3530
- key,
3607
+ key$jscomp$0,
3531
3608
  arrayRoot
3532
3609
  );
3533
3610
  case "U":
@@ -3537,7 +3614,7 @@
3537
3614
  Uint8ClampedArray,
3538
3615
  1,
3539
3616
  obj,
3540
- key,
3617
+ key$jscomp$0,
3541
3618
  arrayRoot
3542
3619
  );
3543
3620
  case "S":
@@ -3547,7 +3624,7 @@
3547
3624
  Int16Array,
3548
3625
  2,
3549
3626
  obj,
3550
- key,
3627
+ key$jscomp$0,
3551
3628
  arrayRoot
3552
3629
  );
3553
3630
  case "s":
@@ -3557,7 +3634,7 @@
3557
3634
  Uint16Array,
3558
3635
  2,
3559
3636
  obj,
3560
- key,
3637
+ key$jscomp$0,
3561
3638
  arrayRoot
3562
3639
  );
3563
3640
  case "L":
@@ -3567,7 +3644,7 @@
3567
3644
  Int32Array,
3568
3645
  4,
3569
3646
  obj,
3570
- key,
3647
+ key$jscomp$0,
3571
3648
  arrayRoot
3572
3649
  );
3573
3650
  case "l":
@@ -3577,7 +3654,7 @@
3577
3654
  Uint32Array,
3578
3655
  4,
3579
3656
  obj,
3580
- key,
3657
+ key$jscomp$0,
3581
3658
  arrayRoot
3582
3659
  );
3583
3660
  case "G":
@@ -3587,7 +3664,7 @@
3587
3664
  Float32Array,
3588
3665
  4,
3589
3666
  obj,
3590
- key,
3667
+ key$jscomp$0,
3591
3668
  arrayRoot
3592
3669
  );
3593
3670
  case "g":
@@ -3597,7 +3674,7 @@
3597
3674
  Float64Array,
3598
3675
  8,
3599
3676
  obj,
3600
- key,
3677
+ key$jscomp$0,
3601
3678
  arrayRoot
3602
3679
  );
3603
3680
  case "M":
@@ -3607,7 +3684,7 @@
3607
3684
  BigInt64Array,
3608
3685
  8,
3609
3686
  obj,
3610
- key,
3687
+ key$jscomp$0,
3611
3688
  arrayRoot
3612
3689
  );
3613
3690
  case "m":
@@ -3617,7 +3694,7 @@
3617
3694
  BigUint64Array,
3618
3695
  8,
3619
3696
  obj,
3620
- key,
3697
+ key$jscomp$0,
3621
3698
  arrayRoot
3622
3699
  );
3623
3700
  case "V":
@@ -3627,13 +3704,13 @@
3627
3704
  DataView,
3628
3705
  1,
3629
3706
  obj,
3630
- key,
3707
+ key$jscomp$0,
3631
3708
  arrayRoot
3632
3709
  );
3633
3710
  case "B":
3634
3711
  return (
3635
3712
  (obj = parseInt(value.slice(2), 16)),
3636
- response._formData.data.get(response._prefix + obj)
3713
+ getBackingBlob(response._formData, response._prefix + obj)
3637
3714
  );
3638
3715
  case "R":
3639
3716
  return parseReadableStream(response, value, void 0);
@@ -3649,7 +3726,7 @@
3649
3726
  response,
3650
3727
  value,
3651
3728
  obj,
3652
- key,
3729
+ key$jscomp$0,
3653
3730
  arrayRoot,
3654
3731
  createModel
3655
3732
  );
@@ -3668,11 +3745,20 @@
3668
3745
  : new FormData(),
3669
3746
  arraySizeLimit =
3670
3747
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3671
- chunks = new Map();
3748
+ chunks = new Map(),
3749
+ backingStore = {
3750
+ prefix: formFieldPrefix,
3751
+ referencedEntries: null,
3752
+ keyPointer: 0,
3753
+ stringChunks: null,
3754
+ streamChunks: null,
3755
+ blobs: null
3756
+ };
3757
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3672
3758
  return {
3673
3759
  _bundlerConfig: bundlerConfig,
3674
3760
  _prefix: formFieldPrefix,
3675
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3761
+ _formData: backingStore,
3676
3762
  _chunks: chunks,
3677
3763
  _closed: !1,
3678
3764
  _closedReason: null,
@@ -3731,44 +3817,44 @@
3731
3817
  }
3732
3818
  function decodeAction$1(body, serverManifest) {
3733
3819
  var formData = new FormData(),
3734
- action = null,
3735
- seenActions = new Set();
3820
+ maybeActionKey = null;
3736
3821
  body.forEach(function (value, key) {
3737
3822
  key.startsWith("$ACTION_")
3738
3823
  ? key.startsWith("$ACTION_REF_")
3739
- ? seenActions.has(key) ||
3740
- (seenActions.add(key),
3741
- (value = "$ACTION_" + key.slice(12) + ":"),
3742
- (value = decodeBoundActionMetaData(body, serverManifest, value)),
3743
- (action = loadServerReference(serverManifest, value)))
3744
- : key.startsWith("$ACTION_ID_") &&
3745
- !seenActions.has(key) &&
3746
- (seenActions.add(key),
3747
- (value = key.slice(11)),
3748
- (action = loadServerReference(serverManifest, {
3749
- id: value,
3750
- bound: null
3751
- })))
3824
+ ? (maybeActionKey = key)
3825
+ : key.startsWith("$ACTION_ID_") && (maybeActionKey = key)
3752
3826
  : formData.append(key, value);
3753
3827
  });
3754
- return null === action
3755
- ? null
3756
- : action.then(function (fn) {
3757
- return fn.bind(null, formData);
3758
- });
3828
+ if (null === maybeActionKey) return null;
3829
+ var actionKey = maybeActionKey,
3830
+ action = null;
3831
+ if (actionKey.startsWith("$ACTION_REF_"))
3832
+ (actionKey = "$ACTION_" + actionKey.slice(12) + ":"),
3833
+ (body = decodeBoundActionMetaData(body, serverManifest, actionKey)),
3834
+ (action = loadServerReference(serverManifest, body));
3835
+ else if (actionKey.startsWith("$ACTION_ID_"))
3836
+ (body = actionKey.slice(11)),
3837
+ (action = loadServerReference(serverManifest, {
3838
+ id: body,
3839
+ bound: null
3840
+ }));
3841
+ else throw Error("Cannot handle action key. This is a bug in React.");
3842
+ return action.then(function (fn) {
3843
+ return fn.bind(null, formData);
3844
+ });
3759
3845
  }
3760
3846
  function decodeFormState$1(actionResult, body, serverManifest) {
3761
3847
  var keyPath = body.get("$ACTION_KEY");
3762
3848
  if ("string" !== typeof keyPath) return Promise.resolve(null);
3763
- var metaData = null;
3849
+ var actionKey = null;
3764
3850
  body.forEach(function (value, key) {
3765
- key.startsWith("$ACTION_REF_") &&
3766
- ((value = "$ACTION_" + key.slice(12) + ":"),
3767
- (metaData = decodeBoundActionMetaData(body, serverManifest, value)));
3851
+ key.startsWith("$ACTION_REF_") && (actionKey = key);
3768
3852
  });
3769
- if (null === metaData) return Promise.resolve(null);
3770
- var referenceId = metaData.id;
3771
- return Promise.resolve(metaData.bound).then(function (bound) {
3853
+ if (null === actionKey) return Promise.resolve(null);
3854
+ var formFieldPrefix = "$ACTION_" + actionKey.slice(12) + ":";
3855
+ body = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
3856
+ var referenceId = body.id;
3857
+ return Promise.resolve(body.bound).then(function (bound) {
3772
3858
  return null === bound
3773
3859
  ? null
3774
3860
  : [actionResult, keyPath, referenceId, bound.length - 1];
@@ -3785,7 +3871,12 @@
3785
3871
  var task = taskQueue.shift();
3786
3872
  task && task();
3787
3873
  };
3788
- var LocalPromise = Promise,
3874
+ var supportsArrayBufferDetached = hasOwnProperty.call(
3875
+ ArrayBuffer.prototype,
3876
+ "detached"
3877
+ ),
3878
+ didWarnAboutMissingArrayBufferDetached = !1,
3879
+ LocalPromise = Promise,
3789
3880
  scheduleMicrotask =
3790
3881
  "function" === typeof queueMicrotask
3791
3882
  ? queueMicrotask