react-server-dom-webpack 19.0.8 → 19.0.9

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.
@@ -29,31 +29,39 @@
29
29
  });
30
30
  }
31
31
  function writeChunkAndReturn(destination, chunk) {
32
- if (0 !== chunk.byteLength)
33
- if (2048 < chunk.byteLength)
34
- 0 < writtenBytes &&
35
- (destination.enqueue(
36
- new Uint8Array(currentView.buffer, 0, writtenBytes)
32
+ if (0 === chunk.byteLength)
33
+ if (supportsArrayBufferDetached) {
34
+ if (chunk.buffer.detached)
35
+ throw Error(
36
+ "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()`."
37
+ );
38
+ } else
39
+ didWarnAboutMissingArrayBufferDetached ||
40
+ (console.error(
41
+ "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."
37
42
  ),
38
- (currentView = new Uint8Array(2048)),
39
- (writtenBytes = 0)),
40
- destination.enqueue(chunk);
41
- else {
42
- var allowableBytes = currentView.length - writtenBytes;
43
- allowableBytes < chunk.byteLength &&
44
- (0 === allowableBytes
45
- ? destination.enqueue(currentView)
46
- : (currentView.set(
47
- chunk.subarray(0, allowableBytes),
48
- writtenBytes
49
- ),
50
- destination.enqueue(currentView),
51
- (chunk = chunk.subarray(allowableBytes))),
52
- (currentView = new Uint8Array(2048)),
53
- (writtenBytes = 0));
54
- currentView.set(chunk, writtenBytes);
55
- writtenBytes += chunk.byteLength;
56
- }
43
+ (didWarnAboutMissingArrayBufferDetached = !0));
44
+ else if (2048 < chunk.byteLength)
45
+ 0 < writtenBytes &&
46
+ (destination.enqueue(
47
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
48
+ ),
49
+ (currentView = new Uint8Array(2048)),
50
+ (writtenBytes = 0)),
51
+ destination.enqueue(chunk);
52
+ else {
53
+ var allowableBytes = currentView.length - writtenBytes;
54
+ allowableBytes < chunk.byteLength &&
55
+ (0 === allowableBytes
56
+ ? destination.enqueue(currentView)
57
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
58
+ destination.enqueue(currentView),
59
+ (chunk = chunk.subarray(allowableBytes))),
60
+ (currentView = new Uint8Array(2048)),
61
+ (writtenBytes = 0));
62
+ currentView.set(chunk, writtenBytes);
63
+ writtenBytes += chunk.byteLength;
64
+ }
57
65
  return !0;
58
66
  }
59
67
  function stringToChunk(content) {
@@ -1914,14 +1922,35 @@
1914
1922
  }
1915
1923
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1916
1924
  request.pendingChunks++;
1917
- var buffer = new Uint8Array(
1918
- typedArray.buffer,
1919
- typedArray.byteOffset,
1920
- typedArray.byteLength
1921
- );
1922
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1923
- buffer = typedArray.byteLength;
1924
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1925
+ a: {
1926
+ var view = new Uint8Array(
1927
+ typedArray.buffer,
1928
+ typedArray.byteOffset,
1929
+ typedArray.byteLength
1930
+ );
1931
+ if (2048 < typedArray.byteLength) {
1932
+ if (
1933
+ 0 !== typedArray.byteOffset ||
1934
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1935
+ typedArray.buffer.resizable
1936
+ ) {
1937
+ typedArray = view.slice();
1938
+ break a;
1939
+ }
1940
+ if (!supportsArrayBufferDetached) {
1941
+ didWarnAboutMissingArrayBufferDetached ||
1942
+ (console.error(
1943
+ "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."
1944
+ ),
1945
+ (didWarnAboutMissingArrayBufferDetached = !0));
1946
+ typedArray = view.slice();
1947
+ break a;
1948
+ }
1949
+ }
1950
+ typedArray = view;
1951
+ }
1952
+ view = typedArray.byteLength;
1953
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1925
1954
  id = stringToChunk(id);
1926
1955
  request.completedRegularChunks.push(id, typedArray);
1927
1956
  }
@@ -2551,6 +2580,39 @@
2551
2580
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2552
2581
  return moduleExports[metadata[2]];
2553
2582
  }
2583
+ function appendBackingEntry(backingStore, value, key) {
2584
+ var prefix = backingStore.prefix;
2585
+ if (key.startsWith(prefix)) {
2586
+ switch (key[prefix.length]) {
2587
+ case "_":
2588
+ prefix = backingStore.referencedEntries;
2589
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2590
+ prefix.push([key, value]);
2591
+ return;
2592
+ case "S":
2593
+ "string" === typeof value &&
2594
+ ((prefix = backingStore.streamChunks),
2595
+ null === prefix &&
2596
+ (prefix = backingStore.streamChunks = new Map()),
2597
+ (backingStore = prefix.get(key)),
2598
+ void 0 === backingStore
2599
+ ? prefix.set(key, [value])
2600
+ : backingStore.push(value));
2601
+ return;
2602
+ }
2603
+ "string" === typeof value
2604
+ ? ((prefix = backingStore.stringChunks),
2605
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2606
+ prefix.set(key, value))
2607
+ : ((prefix = backingStore.blobs),
2608
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2609
+ prefix.set(key, value));
2610
+ }
2611
+ }
2612
+ function getBackingBlob(backingStore, key) {
2613
+ backingStore = backingStore.blobs;
2614
+ return null === backingStore ? void 0 : backingStore.get(key);
2615
+ }
2554
2616
  function ReactPromise(status, value, reason) {
2555
2617
  this.status = status;
2556
2618
  this.value = value;
@@ -2860,17 +2922,20 @@
2860
2922
  function getChunk(response, id) {
2861
2923
  var chunks = response._chunks,
2862
2924
  chunk = chunks.get(id);
2863
- chunk ||
2864
- ((chunk = response._formData.data.get(response._prefix + id)),
2865
- (chunk =
2925
+ if (!chunk) {
2926
+ chunk = response._prefix;
2927
+ var stringChunks = response._formData.stringChunks;
2928
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2929
+ chunk =
2866
2930
  "string" === typeof chunk
2867
2931
  ? new ReactPromise(
2868
2932
  "resolved_model",
2869
2933
  chunk,
2870
2934
  _defineProperty({ id: id }, RESPONSE_SYMBOL, response)
2871
2935
  )
2872
- : new ReactPromise("pending", null, null)),
2873
- chunks.set(id, chunk));
2936
+ : new ReactPromise("pending", null, null);
2937
+ chunks.set(id, chunk);
2938
+ }
2874
2939
  return chunk;
2875
2940
  }
2876
2941
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3117,7 +3182,7 @@
3117
3182
  Error("Already initialized typed array.")
3118
3183
  )
3119
3184
  );
3120
- reference = response._formData.data.get(key).arrayBuffer();
3185
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3121
3186
  if (initializingHandler) {
3122
3187
  var handler = initializingHandler;
3123
3188
  handler.deps++;
@@ -3161,15 +3226,17 @@
3161
3226
  var chunks = response._chunks;
3162
3227
  stream = new ReactPromise("fulfilled", stream, controller);
3163
3228
  chunks.set(id, stream);
3164
- response = response._formData.data.getAll(response._prefix + id);
3165
- for (id = 0; id < response.length; id++)
3166
- (chunks = response[id]),
3167
- "string" === typeof chunks &&
3168
- ("C" === chunks[0]
3229
+ chunks = response._prefix;
3230
+ response = response._formData.streamChunks;
3231
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3232
+ if (void 0 !== id)
3233
+ for (response = 0; response < id.length; response++)
3234
+ (chunks = id[response]),
3235
+ "C" === chunks[0]
3169
3236
  ? controller.close(
3170
3237
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
3171
3238
  )
3172
- : controller.enqueueModel(chunks));
3239
+ : controller.enqueueModel(chunks);
3173
3240
  }
3174
3241
  function parseReadableStream(response, reference, type) {
3175
3242
  function enqueue(value) {
@@ -3333,7 +3400,14 @@
3333
3400
  });
3334
3401
  return iterator;
3335
3402
  }
3336
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3403
+ function parseModelString(
3404
+ response,
3405
+ obj,
3406
+ key$jscomp$0,
3407
+ value,
3408
+ reference,
3409
+ arrayRoot
3410
+ ) {
3337
3411
  if ("$" === value[0]) {
3338
3412
  switch (value[1]) {
3339
3413
  case "$":
@@ -3353,7 +3427,7 @@
3353
3427
  response,
3354
3428
  arrayRoot,
3355
3429
  obj,
3356
- key,
3430
+ key$jscomp$0,
3357
3431
  null,
3358
3432
  loadServerReference$1
3359
3433
  )
@@ -3373,41 +3447,44 @@
3373
3447
  case "Q":
3374
3448
  return (
3375
3449
  (arrayRoot = value.slice(2)),
3376
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3450
+ getOutlinedModel(
3451
+ response,
3452
+ arrayRoot,
3453
+ obj,
3454
+ key$jscomp$0,
3455
+ null,
3456
+ createMap
3457
+ )
3377
3458
  );
3378
3459
  case "W":
3379
3460
  return (
3380
3461
  (arrayRoot = value.slice(2)),
3381
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3462
+ getOutlinedModel(
3463
+ response,
3464
+ arrayRoot,
3465
+ obj,
3466
+ key$jscomp$0,
3467
+ null,
3468
+ createSet
3469
+ )
3382
3470
  );
3383
3471
  case "K":
3384
- key = value.slice(2);
3385
- obj = response._prefix + "_";
3386
- key = obj + key + "_";
3387
- arrayRoot = new FormData();
3388
- for (response = response._formData; ; ) {
3389
- value = response;
3390
- reference = value.keys;
3391
- null === reference &&
3392
- ((reference = value.keys = Array.from(value.data.keys())),
3393
- (value.keyPointer = 0));
3394
- value = reference[value.keyPointer];
3395
- if (void 0 === value) break;
3396
- if (value.startsWith(key)) {
3397
- reference = response.data.getAll(value);
3398
- for (
3399
- var referencedFormDataKey = value.slice(key.length), i = 0;
3400
- i < reference.length;
3401
- i++
3402
- )
3403
- arrayRoot.append(referencedFormDataKey, reference[i]);
3404
- reference = response;
3405
- reference.data.delete(value);
3406
- reference.keyPointer++;
3407
- } else if (value.startsWith(obj)) break;
3408
- else response.keyPointer++;
3472
+ key$jscomp$0 = value.slice(2);
3473
+ obj = response._formData;
3474
+ response = response._prefix + "_" + key$jscomp$0 + "_";
3475
+ key$jscomp$0 = new FormData();
3476
+ arrayRoot = obj.referencedEntries;
3477
+ if (null !== arrayRoot) {
3478
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
3479
+ reference = arrayRoot[value];
3480
+ var key = reference[0];
3481
+ if (!key.startsWith(response)) break;
3482
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
3483
+ value++;
3484
+ }
3485
+ obj.keyPointer = value;
3409
3486
  }
3410
- return arrayRoot;
3487
+ return key$jscomp$0;
3411
3488
  case "i":
3412
3489
  return (
3413
3490
  (arrayRoot = value.slice(2)),
@@ -3415,7 +3492,7 @@
3415
3492
  response,
3416
3493
  arrayRoot,
3417
3494
  obj,
3418
- key,
3495
+ key$jscomp$0,
3419
3496
  null,
3420
3497
  extractIterator
3421
3498
  )
@@ -3452,7 +3529,7 @@
3452
3529
  ArrayBuffer,
3453
3530
  1,
3454
3531
  obj,
3455
- key,
3532
+ key$jscomp$0,
3456
3533
  arrayRoot
3457
3534
  );
3458
3535
  case "O":
@@ -3462,7 +3539,7 @@
3462
3539
  Int8Array,
3463
3540
  1,
3464
3541
  obj,
3465
- key,
3542
+ key$jscomp$0,
3466
3543
  arrayRoot
3467
3544
  );
3468
3545
  case "o":
@@ -3472,7 +3549,7 @@
3472
3549
  Uint8Array,
3473
3550
  1,
3474
3551
  obj,
3475
- key,
3552
+ key$jscomp$0,
3476
3553
  arrayRoot
3477
3554
  );
3478
3555
  case "U":
@@ -3482,7 +3559,7 @@
3482
3559
  Uint8ClampedArray,
3483
3560
  1,
3484
3561
  obj,
3485
- key,
3562
+ key$jscomp$0,
3486
3563
  arrayRoot
3487
3564
  );
3488
3565
  case "S":
@@ -3492,7 +3569,7 @@
3492
3569
  Int16Array,
3493
3570
  2,
3494
3571
  obj,
3495
- key,
3572
+ key$jscomp$0,
3496
3573
  arrayRoot
3497
3574
  );
3498
3575
  case "s":
@@ -3502,7 +3579,7 @@
3502
3579
  Uint16Array,
3503
3580
  2,
3504
3581
  obj,
3505
- key,
3582
+ key$jscomp$0,
3506
3583
  arrayRoot
3507
3584
  );
3508
3585
  case "L":
@@ -3512,7 +3589,7 @@
3512
3589
  Int32Array,
3513
3590
  4,
3514
3591
  obj,
3515
- key,
3592
+ key$jscomp$0,
3516
3593
  arrayRoot
3517
3594
  );
3518
3595
  case "l":
@@ -3522,7 +3599,7 @@
3522
3599
  Uint32Array,
3523
3600
  4,
3524
3601
  obj,
3525
- key,
3602
+ key$jscomp$0,
3526
3603
  arrayRoot
3527
3604
  );
3528
3605
  case "G":
@@ -3532,7 +3609,7 @@
3532
3609
  Float32Array,
3533
3610
  4,
3534
3611
  obj,
3535
- key,
3612
+ key$jscomp$0,
3536
3613
  arrayRoot
3537
3614
  );
3538
3615
  case "g":
@@ -3542,7 +3619,7 @@
3542
3619
  Float64Array,
3543
3620
  8,
3544
3621
  obj,
3545
- key,
3622
+ key$jscomp$0,
3546
3623
  arrayRoot
3547
3624
  );
3548
3625
  case "M":
@@ -3552,7 +3629,7 @@
3552
3629
  BigInt64Array,
3553
3630
  8,
3554
3631
  obj,
3555
- key,
3632
+ key$jscomp$0,
3556
3633
  arrayRoot
3557
3634
  );
3558
3635
  case "m":
@@ -3562,7 +3639,7 @@
3562
3639
  BigUint64Array,
3563
3640
  8,
3564
3641
  obj,
3565
- key,
3642
+ key$jscomp$0,
3566
3643
  arrayRoot
3567
3644
  );
3568
3645
  case "V":
@@ -3572,13 +3649,13 @@
3572
3649
  DataView,
3573
3650
  1,
3574
3651
  obj,
3575
- key,
3652
+ key$jscomp$0,
3576
3653
  arrayRoot
3577
3654
  );
3578
3655
  case "B":
3579
3656
  return (
3580
3657
  (obj = parseInt(value.slice(2), 16)),
3581
- response._formData.data.get(response._prefix + obj)
3658
+ getBackingBlob(response._formData, response._prefix + obj)
3582
3659
  );
3583
3660
  }
3584
3661
  switch (value[1]) {
@@ -3596,7 +3673,7 @@
3596
3673
  response,
3597
3674
  value,
3598
3675
  obj,
3599
- key,
3676
+ key$jscomp$0,
3600
3677
  arrayRoot,
3601
3678
  createModel
3602
3679
  );
@@ -3615,11 +3692,20 @@
3615
3692
  : new FormData(),
3616
3693
  arraySizeLimit =
3617
3694
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3618
- chunks = new Map();
3695
+ chunks = new Map(),
3696
+ backingStore = {
3697
+ prefix: formFieldPrefix,
3698
+ referencedEntries: null,
3699
+ keyPointer: 0,
3700
+ stringChunks: null,
3701
+ streamChunks: null,
3702
+ blobs: null
3703
+ };
3704
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3619
3705
  return {
3620
3706
  _bundlerConfig: bundlerConfig,
3621
3707
  _prefix: formFieldPrefix,
3622
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3708
+ _formData: backingStore,
3623
3709
  _chunks: chunks,
3624
3710
  _temporaryReferences: temporaryReferences,
3625
3711
  _rootArrayContexts: new WeakMap(),
@@ -3676,6 +3762,12 @@
3676
3762
  }
3677
3763
  var ReactDOM = require("react-dom"),
3678
3764
  React = require("react"),
3765
+ hasOwnProperty = Object.prototype.hasOwnProperty,
3766
+ supportsArrayBufferDetached = hasOwnProperty.call(
3767
+ ArrayBuffer.prototype,
3768
+ "detached"
3769
+ ),
3770
+ didWarnAboutMissingArrayBufferDetached = !1,
3679
3771
  LocalPromise = Promise,
3680
3772
  scheduleMicrotask =
3681
3773
  "function" === typeof queueMicrotask
@@ -4114,7 +4206,6 @@
4114
4206
  debugID = null,
4115
4207
  modelRoot = !1,
4116
4208
  emptyRoot = {},
4117
- hasOwnProperty = Object.prototype.hasOwnProperty,
4118
4209
  chunkCache = new Map(),
4119
4210
  RESPONSE_SYMBOL = Symbol();
4120
4211
  ReactPromise.prototype = Object.create(Promise.prototype);