react-server-dom-webpack 19.3.0 → 19.3.1

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.
@@ -32,7 +32,12 @@ function getIteratorFn(maybeIterable) {
32
32
  return "function" === typeof maybeIterable ? maybeIterable : null;
33
33
  }
34
34
  var ASYNC_ITERATOR = Symbol.asyncIterator,
35
- REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key");
35
+ REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"),
36
+ hasOwnProperty = Object.prototype.hasOwnProperty,
37
+ supportsArrayBufferDetached = hasOwnProperty.call(
38
+ ArrayBuffer.prototype,
39
+ "detached"
40
+ );
36
41
  function handleErrorInNextTick(error) {
37
42
  setTimeout(function () {
38
43
  throw error;
@@ -50,28 +55,30 @@ var LocalPromise = Promise,
50
55
  currentView = null,
51
56
  writtenBytes = 0;
52
57
  function writeChunk(destination, chunk) {
53
- if (0 !== chunk.byteLength)
54
- if (4096 < chunk.byteLength)
55
- 0 < writtenBytes &&
56
- (destination.enqueue(
57
- new Uint8Array(currentView.buffer, 0, writtenBytes)
58
- ),
59
- (currentView = new Uint8Array(4096)),
60
- (writtenBytes = 0)),
61
- destination.enqueue(chunk);
62
- else {
63
- var allowableBytes = currentView.length - writtenBytes;
64
- allowableBytes < chunk.byteLength &&
65
- (0 === allowableBytes
66
- ? destination.enqueue(currentView)
67
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
68
- destination.enqueue(currentView),
69
- (chunk = chunk.subarray(allowableBytes))),
70
- (currentView = new Uint8Array(4096)),
71
- (writtenBytes = 0));
72
- currentView.set(chunk, writtenBytes);
73
- writtenBytes += chunk.byteLength;
74
- }
58
+ if (0 === chunk.byteLength) {
59
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
60
+ throw Error(
61
+ "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()`."
62
+ );
63
+ } else if (4096 < chunk.byteLength)
64
+ 0 < writtenBytes &&
65
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
66
+ (currentView = new Uint8Array(4096)),
67
+ (writtenBytes = 0)),
68
+ destination.enqueue(chunk);
69
+ else {
70
+ var allowableBytes = currentView.length - writtenBytes;
71
+ allowableBytes < chunk.byteLength &&
72
+ (0 === allowableBytes
73
+ ? destination.enqueue(currentView)
74
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
75
+ destination.enqueue(currentView),
76
+ (chunk = chunk.subarray(allowableBytes))),
77
+ (currentView = new Uint8Array(4096)),
78
+ (writtenBytes = 0));
79
+ currentView.set(chunk, writtenBytes);
80
+ writtenBytes += chunk.byteLength;
81
+ }
75
82
  }
76
83
  function writeChunkAndReturn(destination, chunk) {
77
84
  writeChunk(destination, chunk);
@@ -821,8 +828,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
821
828
  "\n " + str + "\n " + objectOrArray)
822
829
  : "\n " + str;
823
830
  }
824
- var hasOwnProperty = Object.prototype.hasOwnProperty,
825
- ObjectPrototype$1 = Object.prototype,
831
+ var ObjectPrototype$1 = Object.prototype,
826
832
  stringify = JSON.stringify,
827
833
  NEXT_TWO_CHUNKS_ARE_ATOMIC = Symbol();
828
834
  function defaultErrorHandler(error) {
@@ -2058,11 +2064,28 @@ function emitModelChunk(request, id, json) {
2058
2064
  }
2059
2065
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
2060
2066
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
2061
- typedArray = new Uint8Array(
2062
- typedArray.buffer,
2063
- typedArray.byteOffset,
2064
- typedArray.byteLength
2065
- );
2067
+ a: {
2068
+ debug = new Uint8Array(
2069
+ typedArray.buffer,
2070
+ typedArray.byteOffset,
2071
+ typedArray.byteLength
2072
+ );
2073
+ if (4096 < typedArray.byteLength) {
2074
+ if (
2075
+ 0 !== typedArray.byteOffset ||
2076
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
2077
+ typedArray.buffer.resizable
2078
+ ) {
2079
+ typedArray = debug.slice();
2080
+ break a;
2081
+ }
2082
+ if (!supportsArrayBufferDetached) {
2083
+ typedArray = debug.slice();
2084
+ break a;
2085
+ }
2086
+ }
2087
+ typedArray = debug;
2088
+ }
2066
2089
  debug = typedArray.byteLength;
2067
2090
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
2068
2091
  id = stringToChunk(id);
@@ -2500,13 +2523,37 @@ function requireModule(metadata) {
2500
2523
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2501
2524
  return moduleExports[metadata[2]];
2502
2525
  }
2503
- function appendBackingEntry(backingStore, key, value) {
2504
- backingStore.data.append(key, value);
2505
- value = backingStore.keys;
2506
- null === value
2507
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2508
- (backingStore.keyPointer = 0))
2509
- : value.push(key);
2526
+ function appendBackingEntry(backingStore, value, key) {
2527
+ var prefix = backingStore.prefix;
2528
+ if (key.startsWith(prefix)) {
2529
+ switch (key[prefix.length]) {
2530
+ case "_":
2531
+ prefix = backingStore.referencedEntries;
2532
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2533
+ prefix.push([key, value]);
2534
+ return;
2535
+ case "S":
2536
+ "string" === typeof value &&
2537
+ ((prefix = backingStore.streamChunks),
2538
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2539
+ (backingStore = prefix.get(key)),
2540
+ void 0 === backingStore
2541
+ ? prefix.set(key, [value])
2542
+ : backingStore.push(value));
2543
+ return;
2544
+ }
2545
+ "string" === typeof value
2546
+ ? ((prefix = backingStore.stringChunks),
2547
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2548
+ prefix.set(key, value))
2549
+ : ((prefix = backingStore.blobs),
2550
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2551
+ prefix.set(key, value));
2552
+ }
2553
+ }
2554
+ function getBackingBlob(backingStore, key) {
2555
+ backingStore = backingStore.blobs;
2556
+ return null === backingStore ? void 0 : backingStore.get(key);
2510
2557
  }
2511
2558
  var RESPONSE_SYMBOL = Symbol();
2512
2559
  function ReactPromise(status, value, reason) {
@@ -2887,15 +2934,18 @@ function reportGlobalError(response, error) {
2887
2934
  function getChunk(response, id) {
2888
2935
  var chunks = response._chunks,
2889
2936
  chunk = chunks.get(id);
2890
- chunk ||
2891
- ((chunk = response._formData.data.get(response._prefix + id)),
2892
- (chunk =
2937
+ if (!chunk) {
2938
+ chunk = response._prefix;
2939
+ var stringChunks = response._formData.stringChunks;
2940
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2941
+ chunk =
2893
2942
  "string" === typeof chunk
2894
2943
  ? createResolvedModelChunk(response, chunk, id)
2895
2944
  : response._closed
2896
2945
  ? new ReactPromise("rejected", null, response._closedReason)
2897
- : new ReactPromise("pending", null, null)),
2898
- chunks.set(id, chunk));
2946
+ : new ReactPromise("pending", null, null);
2947
+ chunks.set(id, chunk);
2948
+ }
2899
2949
  return chunk;
2900
2950
  }
2901
2951
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3126,7 +3176,7 @@ function parseTypedArray(
3126
3176
  Error("Already initialized typed array.")
3127
3177
  )
3128
3178
  );
3129
- reference = response._formData.data.get(key).arrayBuffer();
3179
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3130
3180
  if (initializingHandler) {
3131
3181
  var handler = initializingHandler;
3132
3182
  handler.deps++;
@@ -3170,13 +3220,15 @@ function resolveStream(response, id, stream, controller) {
3170
3220
  var chunks = response._chunks;
3171
3221
  stream = new ReactPromise("fulfilled", stream, controller);
3172
3222
  chunks.set(id, stream);
3173
- response = response._formData.data.getAll(response._prefix + id);
3174
- for (id = 0; id < response.length; id++)
3175
- (chunks = response[id]),
3176
- "string" === typeof chunks &&
3177
- ("C" === chunks[0]
3223
+ chunks = response._prefix;
3224
+ response = response._formData.streamChunks;
3225
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3226
+ if (void 0 !== id)
3227
+ for (response = 0; response < id.length; response++)
3228
+ (chunks = id[response]),
3229
+ "C" === chunks[0]
3178
3230
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
3179
- : controller.enqueueModel(chunks));
3231
+ : controller.enqueueModel(chunks);
3180
3232
  }
3181
3233
  function parseReadableStream(response, reference, type) {
3182
3234
  function enqueue(value) {
@@ -3342,7 +3394,14 @@ function parseAsyncIterable(response, reference, iterator) {
3342
3394
  });
3343
3395
  return iterator;
3344
3396
  }
3345
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3397
+ function parseModelString(
3398
+ response,
3399
+ obj,
3400
+ key$jscomp$0,
3401
+ value,
3402
+ reference,
3403
+ arrayRoot
3404
+ ) {
3346
3405
  if ("$" === value[0]) {
3347
3406
  switch (value[1]) {
3348
3407
  case "$":
@@ -3360,7 +3419,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3360
3419
  response,
3361
3420
  arrayRoot,
3362
3421
  obj,
3363
- key,
3422
+ key$jscomp$0,
3364
3423
  null,
3365
3424
  loadServerReference$1
3366
3425
  )
@@ -3377,43 +3436,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3377
3436
  case "Q":
3378
3437
  return (
3379
3438
  (arrayRoot = value.slice(2)),
3380
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3439
+ getOutlinedModel(
3440
+ response,
3441
+ arrayRoot,
3442
+ obj,
3443
+ key$jscomp$0,
3444
+ null,
3445
+ createMap
3446
+ )
3381
3447
  );
3382
3448
  case "W":
3383
3449
  return (
3384
3450
  (arrayRoot = value.slice(2)),
3385
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3451
+ getOutlinedModel(
3452
+ response,
3453
+ arrayRoot,
3454
+ obj,
3455
+ key$jscomp$0,
3456
+ null,
3457
+ createSet
3458
+ )
3386
3459
  );
3387
3460
  case "K":
3388
- key = value.slice(2);
3389
- obj = response._prefix + "_";
3390
- key = obj + key + "_";
3391
- arrayRoot = new FormData();
3392
- for (response = response._formData; ; ) {
3393
- value = response.keys;
3394
- null === value &&
3395
- ((value = response.keys = Array.from(response.data.keys())),
3396
- (response.keyPointer = 0));
3397
- value = value[response.keyPointer];
3398
- if (void 0 === value) break;
3399
- if (value.startsWith(key)) {
3400
- reference = response.data.getAll(value);
3401
- for (
3402
- var referencedFormDataKey = value.slice(key.length), i = 0;
3403
- i < reference.length;
3404
- i++
3405
- )
3406
- arrayRoot.append(referencedFormDataKey, reference[i]);
3407
- response.data.delete(value);
3408
- response.keyPointer++;
3409
- } else if (value.startsWith(obj)) break;
3410
- else response.keyPointer++;
3461
+ obj = value.slice(2);
3462
+ obj = response._prefix + "_" + obj + "_";
3463
+ response = response._formData;
3464
+ key$jscomp$0 = new FormData();
3465
+ arrayRoot = response.referencedEntries;
3466
+ if (null !== arrayRoot) {
3467
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3468
+ reference = arrayRoot[value];
3469
+ var key = reference[0];
3470
+ if (!key.startsWith(obj)) break;
3471
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3472
+ value++;
3473
+ }
3474
+ response.keyPointer = value;
3411
3475
  }
3412
- return arrayRoot;
3476
+ return key$jscomp$0;
3413
3477
  case "i":
3414
3478
  return (
3415
3479
  (arrayRoot = value.slice(2)),
3416
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3480
+ getOutlinedModel(
3481
+ response,
3482
+ arrayRoot,
3483
+ obj,
3484
+ key$jscomp$0,
3485
+ null,
3486
+ extractIterator
3487
+ )
3417
3488
  );
3418
3489
  case "I":
3419
3490
  return Infinity;
@@ -3442,7 +3513,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3442
3513
  ArrayBuffer,
3443
3514
  1,
3444
3515
  obj,
3445
- key,
3516
+ key$jscomp$0,
3446
3517
  arrayRoot
3447
3518
  );
3448
3519
  case "O":
@@ -3452,7 +3523,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3452
3523
  Int8Array,
3453
3524
  1,
3454
3525
  obj,
3455
- key,
3526
+ key$jscomp$0,
3456
3527
  arrayRoot
3457
3528
  );
3458
3529
  case "o":
@@ -3462,7 +3533,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3462
3533
  Uint8Array,
3463
3534
  1,
3464
3535
  obj,
3465
- key,
3536
+ key$jscomp$0,
3466
3537
  arrayRoot
3467
3538
  );
3468
3539
  case "U":
@@ -3472,7 +3543,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3472
3543
  Uint8ClampedArray,
3473
3544
  1,
3474
3545
  obj,
3475
- key,
3546
+ key$jscomp$0,
3476
3547
  arrayRoot
3477
3548
  );
3478
3549
  case "S":
@@ -3482,7 +3553,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3482
3553
  Int16Array,
3483
3554
  2,
3484
3555
  obj,
3485
- key,
3556
+ key$jscomp$0,
3486
3557
  arrayRoot
3487
3558
  );
3488
3559
  case "s":
@@ -3492,7 +3563,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3492
3563
  Uint16Array,
3493
3564
  2,
3494
3565
  obj,
3495
- key,
3566
+ key$jscomp$0,
3496
3567
  arrayRoot
3497
3568
  );
3498
3569
  case "L":
@@ -3502,7 +3573,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3502
3573
  Int32Array,
3503
3574
  4,
3504
3575
  obj,
3505
- key,
3576
+ key$jscomp$0,
3506
3577
  arrayRoot
3507
3578
  );
3508
3579
  case "l":
@@ -3512,7 +3583,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3512
3583
  Uint32Array,
3513
3584
  4,
3514
3585
  obj,
3515
- key,
3586
+ key$jscomp$0,
3516
3587
  arrayRoot
3517
3588
  );
3518
3589
  case "G":
@@ -3522,7 +3593,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3522
3593
  Float32Array,
3523
3594
  4,
3524
3595
  obj,
3525
- key,
3596
+ key$jscomp$0,
3526
3597
  arrayRoot
3527
3598
  );
3528
3599
  case "g":
@@ -3532,7 +3603,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3532
3603
  Float64Array,
3533
3604
  8,
3534
3605
  obj,
3535
- key,
3606
+ key$jscomp$0,
3536
3607
  arrayRoot
3537
3608
  );
3538
3609
  case "M":
@@ -3542,7 +3613,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3542
3613
  BigInt64Array,
3543
3614
  8,
3544
3615
  obj,
3545
- key,
3616
+ key$jscomp$0,
3546
3617
  arrayRoot
3547
3618
  );
3548
3619
  case "m":
@@ -3552,7 +3623,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3552
3623
  BigUint64Array,
3553
3624
  8,
3554
3625
  obj,
3555
- key,
3626
+ key$jscomp$0,
3556
3627
  arrayRoot
3557
3628
  );
3558
3629
  case "V":
@@ -3562,12 +3633,12 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3562
3633
  DataView,
3563
3634
  1,
3564
3635
  obj,
3565
- key,
3636
+ key$jscomp$0,
3566
3637
  arrayRoot
3567
3638
  );
3568
3639
  case "B":
3569
3640
  obj = parseInt(value.slice(2), 16);
3570
- response = response._formData.data.get(response._prefix + obj);
3641
+ response = getBackingBlob(response._formData, response._prefix + obj);
3571
3642
  if (!(response instanceof Blob))
3572
3643
  throw Error("Referenced Blob is not a Blob.");
3573
3644
  return response;
@@ -3581,7 +3652,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3581
3652
  return parseAsyncIterable(response, value, !0);
3582
3653
  }
3583
3654
  value = value.slice(1);
3584
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3655
+ return getOutlinedModel(
3656
+ response,
3657
+ value,
3658
+ obj,
3659
+ key$jscomp$0,
3660
+ arrayRoot,
3661
+ createModel
3662
+ );
3585
3663
  }
3586
3664
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3587
3665
  return value;
@@ -3593,11 +3671,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3593
3671
  : new FormData(),
3594
3672
  arraySizeLimit =
3595
3673
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3596
- chunks = new Map();
3674
+ chunks = new Map(),
3675
+ backingStore = {
3676
+ prefix: formFieldPrefix,
3677
+ referencedEntries: null,
3678
+ keyPointer: 0,
3679
+ stringChunks: null,
3680
+ streamChunks: null,
3681
+ blobs: null
3682
+ };
3683
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3597
3684
  return {
3598
3685
  _bundlerConfig: bundlerConfig,
3599
3686
  _prefix: formFieldPrefix,
3600
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3687
+ _formData: backingStore,
3601
3688
  _chunks: chunks,
3602
3689
  _closed: !1,
3603
3690
  _closedReason: null,
@@ -3726,19 +3813,34 @@ exports.decodeReplyFromAsyncIterable = function (
3726
3813
  function progress(entry) {
3727
3814
  if (entry.done) close(response);
3728
3815
  else {
3729
- entry = entry.value;
3730
- var name = entry[0];
3731
- entry = entry[1];
3732
- if ("string" === typeof entry) {
3733
- appendBackingEntry(response._formData, name, entry);
3734
- var prefix = response._prefix;
3735
- if (name.startsWith(prefix)) {
3736
- var chunks = response._chunks;
3737
- name = +name.slice(prefix.length);
3738
- (chunks = chunks.get(name)) &&
3739
- resolveModelChunk(response, chunks, entry, name);
3816
+ var _entry$value = entry.value;
3817
+ entry = _entry$value[0];
3818
+ _entry$value = _entry$value[1];
3819
+ if ("string" === typeof _entry$value)
3820
+ a: {
3821
+ var prefix = response._prefix;
3822
+ if (entry.startsWith(prefix)) {
3823
+ var chunks = response._chunks;
3824
+ if ("S" === entry[prefix.length]) {
3825
+ if (
3826
+ entry.length > prefix.length + 1 &&
3827
+ ((prefix = +entry.slice(prefix.length + 1)),
3828
+ (chunks = chunks.get(prefix)))
3829
+ ) {
3830
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3831
+ break a;
3832
+ }
3833
+ } else if (
3834
+ ((prefix = +entry.slice(prefix.length)),
3835
+ (chunks = chunks.get(prefix)))
3836
+ ) {
3837
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3838
+ break a;
3839
+ }
3840
+ }
3841
+ appendBackingEntry(response._formData, _entry$value, entry);
3740
3842
  }
3741
- } else appendBackingEntry(response._formData, name, entry);
3843
+ else appendBackingEntry(response._formData, _entry$value, entry);
3742
3844
  iterator.next().then(progress, error);
3743
3845
  }
3744
3846
  }