react-server-dom-turbopack 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.
@@ -33,31 +33,39 @@
33
33
  });
34
34
  }
35
35
  function writeChunkAndReturn(destination, chunk) {
36
- if (0 !== chunk.byteLength)
37
- if (2048 < chunk.byteLength)
38
- 0 < writtenBytes &&
39
- (destination.enqueue(
40
- new Uint8Array(currentView.buffer, 0, writtenBytes)
36
+ if (0 === chunk.byteLength)
37
+ if (supportsArrayBufferDetached) {
38
+ if (chunk.buffer.detached)
39
+ throw Error(
40
+ "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()`."
41
+ );
42
+ } else
43
+ didWarnAboutMissingArrayBufferDetached ||
44
+ (console.error(
45
+ "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."
41
46
  ),
42
- (currentView = new Uint8Array(2048)),
43
- (writtenBytes = 0)),
44
- destination.enqueue(chunk);
45
- else {
46
- var allowableBytes = currentView.length - writtenBytes;
47
- allowableBytes < chunk.byteLength &&
48
- (0 === allowableBytes
49
- ? destination.enqueue(currentView)
50
- : (currentView.set(
51
- chunk.subarray(0, allowableBytes),
52
- writtenBytes
53
- ),
54
- destination.enqueue(currentView),
55
- (chunk = chunk.subarray(allowableBytes))),
56
- (currentView = new Uint8Array(2048)),
57
- (writtenBytes = 0));
58
- currentView.set(chunk, writtenBytes);
59
- writtenBytes += chunk.byteLength;
60
- }
47
+ (didWarnAboutMissingArrayBufferDetached = !0));
48
+ else if (2048 < chunk.byteLength)
49
+ 0 < writtenBytes &&
50
+ (destination.enqueue(
51
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
52
+ ),
53
+ (currentView = new Uint8Array(2048)),
54
+ (writtenBytes = 0)),
55
+ destination.enqueue(chunk);
56
+ else {
57
+ var allowableBytes = currentView.length - writtenBytes;
58
+ allowableBytes < chunk.byteLength &&
59
+ (0 === allowableBytes
60
+ ? destination.enqueue(currentView)
61
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
62
+ destination.enqueue(currentView),
63
+ (chunk = chunk.subarray(allowableBytes))),
64
+ (currentView = new Uint8Array(2048)),
65
+ (writtenBytes = 0));
66
+ currentView.set(chunk, writtenBytes);
67
+ writtenBytes += chunk.byteLength;
68
+ }
61
69
  return !0;
62
70
  }
63
71
  function stringToChunk(content) {
@@ -1880,14 +1888,35 @@
1880
1888
  }
1881
1889
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1882
1890
  request.pendingChunks++;
1883
- var buffer = new Uint8Array(
1884
- typedArray.buffer,
1885
- typedArray.byteOffset,
1886
- typedArray.byteLength
1887
- );
1888
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1889
- buffer = typedArray.byteLength;
1890
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1891
+ a: {
1892
+ var view = new Uint8Array(
1893
+ typedArray.buffer,
1894
+ typedArray.byteOffset,
1895
+ typedArray.byteLength
1896
+ );
1897
+ if (2048 < typedArray.byteLength) {
1898
+ if (
1899
+ 0 !== typedArray.byteOffset ||
1900
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1901
+ typedArray.buffer.resizable
1902
+ ) {
1903
+ typedArray = view.slice();
1904
+ break a;
1905
+ }
1906
+ if (!supportsArrayBufferDetached) {
1907
+ didWarnAboutMissingArrayBufferDetached ||
1908
+ (console.error(
1909
+ "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."
1910
+ ),
1911
+ (didWarnAboutMissingArrayBufferDetached = !0));
1912
+ typedArray = view.slice();
1913
+ break a;
1914
+ }
1915
+ }
1916
+ typedArray = view;
1917
+ }
1918
+ view = typedArray.byteLength;
1919
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
1891
1920
  id = stringToChunk(id);
1892
1921
  request.completedRegularChunks.push(id, typedArray);
1893
1922
  }
@@ -2510,6 +2539,39 @@
2510
2539
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2511
2540
  return moduleExports[metadata[2]];
2512
2541
  }
2542
+ function appendBackingEntry(backingStore, value, key) {
2543
+ var prefix = backingStore.prefix;
2544
+ if (key.startsWith(prefix)) {
2545
+ switch (key[prefix.length]) {
2546
+ case "_":
2547
+ prefix = backingStore.referencedEntries;
2548
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2549
+ prefix.push([key, value]);
2550
+ return;
2551
+ case "S":
2552
+ "string" === typeof value &&
2553
+ ((prefix = backingStore.streamChunks),
2554
+ null === prefix &&
2555
+ (prefix = backingStore.streamChunks = new Map()),
2556
+ (backingStore = prefix.get(key)),
2557
+ void 0 === backingStore
2558
+ ? prefix.set(key, [value])
2559
+ : backingStore.push(value));
2560
+ return;
2561
+ }
2562
+ "string" === typeof value
2563
+ ? ((prefix = backingStore.stringChunks),
2564
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2565
+ prefix.set(key, value))
2566
+ : ((prefix = backingStore.blobs),
2567
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2568
+ prefix.set(key, value));
2569
+ }
2570
+ }
2571
+ function getBackingBlob(backingStore, key) {
2572
+ backingStore = backingStore.blobs;
2573
+ return null === backingStore ? void 0 : backingStore.get(key);
2574
+ }
2513
2575
  function ReactPromise(status, value, reason) {
2514
2576
  this.status = status;
2515
2577
  this.value = value;
@@ -2819,17 +2881,20 @@
2819
2881
  function getChunk(response, id) {
2820
2882
  var chunks = response._chunks,
2821
2883
  chunk = chunks.get(id);
2822
- chunk ||
2823
- ((chunk = response._formData.data.get(response._prefix + id)),
2824
- (chunk =
2884
+ if (!chunk) {
2885
+ chunk = response._prefix;
2886
+ var stringChunks = response._formData.stringChunks;
2887
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2888
+ chunk =
2825
2889
  "string" === typeof chunk
2826
2890
  ? new ReactPromise(
2827
2891
  "resolved_model",
2828
2892
  chunk,
2829
2893
  _defineProperty({ id: id }, RESPONSE_SYMBOL, response)
2830
2894
  )
2831
- : new ReactPromise("pending", null, null)),
2832
- chunks.set(id, chunk));
2895
+ : new ReactPromise("pending", null, null);
2896
+ chunks.set(id, chunk);
2897
+ }
2833
2898
  return chunk;
2834
2899
  }
2835
2900
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3076,7 +3141,7 @@
3076
3141
  Error("Already initialized typed array.")
3077
3142
  )
3078
3143
  );
3079
- reference = response._formData.data.get(key).arrayBuffer();
3144
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3080
3145
  if (initializingHandler) {
3081
3146
  var handler = initializingHandler;
3082
3147
  handler.deps++;
@@ -3120,15 +3185,17 @@
3120
3185
  var chunks = response._chunks;
3121
3186
  stream = new ReactPromise("fulfilled", stream, controller);
3122
3187
  chunks.set(id, stream);
3123
- response = response._formData.data.getAll(response._prefix + id);
3124
- for (id = 0; id < response.length; id++)
3125
- (chunks = response[id]),
3126
- "string" === typeof chunks &&
3127
- ("C" === chunks[0]
3188
+ chunks = response._prefix;
3189
+ response = response._formData.streamChunks;
3190
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3191
+ if (void 0 !== id)
3192
+ for (response = 0; response < id.length; response++)
3193
+ (chunks = id[response]),
3194
+ "C" === chunks[0]
3128
3195
  ? controller.close(
3129
3196
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
3130
3197
  )
3131
- : controller.enqueueModel(chunks));
3198
+ : controller.enqueueModel(chunks);
3132
3199
  }
3133
3200
  function parseReadableStream(response, reference, type) {
3134
3201
  function enqueue(value) {
@@ -3292,7 +3359,14 @@
3292
3359
  });
3293
3360
  return iterator;
3294
3361
  }
3295
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3362
+ function parseModelString(
3363
+ response,
3364
+ obj,
3365
+ key$jscomp$0,
3366
+ value,
3367
+ reference,
3368
+ arrayRoot
3369
+ ) {
3296
3370
  if ("$" === value[0]) {
3297
3371
  switch (value[1]) {
3298
3372
  case "$":
@@ -3312,7 +3386,7 @@
3312
3386
  response,
3313
3387
  arrayRoot,
3314
3388
  obj,
3315
- key,
3389
+ key$jscomp$0,
3316
3390
  null,
3317
3391
  loadServerReference$1
3318
3392
  )
@@ -3332,41 +3406,44 @@
3332
3406
  case "Q":
3333
3407
  return (
3334
3408
  (arrayRoot = value.slice(2)),
3335
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3409
+ getOutlinedModel(
3410
+ response,
3411
+ arrayRoot,
3412
+ obj,
3413
+ key$jscomp$0,
3414
+ null,
3415
+ createMap
3416
+ )
3336
3417
  );
3337
3418
  case "W":
3338
3419
  return (
3339
3420
  (arrayRoot = value.slice(2)),
3340
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3421
+ getOutlinedModel(
3422
+ response,
3423
+ arrayRoot,
3424
+ obj,
3425
+ key$jscomp$0,
3426
+ null,
3427
+ createSet
3428
+ )
3341
3429
  );
3342
3430
  case "K":
3343
- key = value.slice(2);
3344
- obj = response._prefix + "_";
3345
- key = obj + key + "_";
3346
- arrayRoot = new FormData();
3347
- for (response = response._formData; ; ) {
3348
- value = response;
3349
- reference = value.keys;
3350
- null === reference &&
3351
- ((reference = value.keys = Array.from(value.data.keys())),
3352
- (value.keyPointer = 0));
3353
- value = reference[value.keyPointer];
3354
- if (void 0 === value) break;
3355
- if (value.startsWith(key)) {
3356
- reference = response.data.getAll(value);
3357
- for (
3358
- var referencedFormDataKey = value.slice(key.length), i = 0;
3359
- i < reference.length;
3360
- i++
3361
- )
3362
- arrayRoot.append(referencedFormDataKey, reference[i]);
3363
- reference = response;
3364
- reference.data.delete(value);
3365
- reference.keyPointer++;
3366
- } else if (value.startsWith(obj)) break;
3367
- else response.keyPointer++;
3431
+ key$jscomp$0 = value.slice(2);
3432
+ obj = response._formData;
3433
+ response = response._prefix + "_" + key$jscomp$0 + "_";
3434
+ key$jscomp$0 = new FormData();
3435
+ arrayRoot = obj.referencedEntries;
3436
+ if (null !== arrayRoot) {
3437
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
3438
+ reference = arrayRoot[value];
3439
+ var key = reference[0];
3440
+ if (!key.startsWith(response)) break;
3441
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
3442
+ value++;
3443
+ }
3444
+ obj.keyPointer = value;
3368
3445
  }
3369
- return arrayRoot;
3446
+ return key$jscomp$0;
3370
3447
  case "i":
3371
3448
  return (
3372
3449
  (arrayRoot = value.slice(2)),
@@ -3374,7 +3451,7 @@
3374
3451
  response,
3375
3452
  arrayRoot,
3376
3453
  obj,
3377
- key,
3454
+ key$jscomp$0,
3378
3455
  null,
3379
3456
  extractIterator
3380
3457
  )
@@ -3411,7 +3488,7 @@
3411
3488
  ArrayBuffer,
3412
3489
  1,
3413
3490
  obj,
3414
- key,
3491
+ key$jscomp$0,
3415
3492
  arrayRoot
3416
3493
  );
3417
3494
  case "O":
@@ -3421,7 +3498,7 @@
3421
3498
  Int8Array,
3422
3499
  1,
3423
3500
  obj,
3424
- key,
3501
+ key$jscomp$0,
3425
3502
  arrayRoot
3426
3503
  );
3427
3504
  case "o":
@@ -3431,7 +3508,7 @@
3431
3508
  Uint8Array,
3432
3509
  1,
3433
3510
  obj,
3434
- key,
3511
+ key$jscomp$0,
3435
3512
  arrayRoot
3436
3513
  );
3437
3514
  case "U":
@@ -3441,7 +3518,7 @@
3441
3518
  Uint8ClampedArray,
3442
3519
  1,
3443
3520
  obj,
3444
- key,
3521
+ key$jscomp$0,
3445
3522
  arrayRoot
3446
3523
  );
3447
3524
  case "S":
@@ -3451,7 +3528,7 @@
3451
3528
  Int16Array,
3452
3529
  2,
3453
3530
  obj,
3454
- key,
3531
+ key$jscomp$0,
3455
3532
  arrayRoot
3456
3533
  );
3457
3534
  case "s":
@@ -3461,7 +3538,7 @@
3461
3538
  Uint16Array,
3462
3539
  2,
3463
3540
  obj,
3464
- key,
3541
+ key$jscomp$0,
3465
3542
  arrayRoot
3466
3543
  );
3467
3544
  case "L":
@@ -3471,7 +3548,7 @@
3471
3548
  Int32Array,
3472
3549
  4,
3473
3550
  obj,
3474
- key,
3551
+ key$jscomp$0,
3475
3552
  arrayRoot
3476
3553
  );
3477
3554
  case "l":
@@ -3481,7 +3558,7 @@
3481
3558
  Uint32Array,
3482
3559
  4,
3483
3560
  obj,
3484
- key,
3561
+ key$jscomp$0,
3485
3562
  arrayRoot
3486
3563
  );
3487
3564
  case "G":
@@ -3491,7 +3568,7 @@
3491
3568
  Float32Array,
3492
3569
  4,
3493
3570
  obj,
3494
- key,
3571
+ key$jscomp$0,
3495
3572
  arrayRoot
3496
3573
  );
3497
3574
  case "g":
@@ -3501,7 +3578,7 @@
3501
3578
  Float64Array,
3502
3579
  8,
3503
3580
  obj,
3504
- key,
3581
+ key$jscomp$0,
3505
3582
  arrayRoot
3506
3583
  );
3507
3584
  case "M":
@@ -3511,7 +3588,7 @@
3511
3588
  BigInt64Array,
3512
3589
  8,
3513
3590
  obj,
3514
- key,
3591
+ key$jscomp$0,
3515
3592
  arrayRoot
3516
3593
  );
3517
3594
  case "m":
@@ -3521,7 +3598,7 @@
3521
3598
  BigUint64Array,
3522
3599
  8,
3523
3600
  obj,
3524
- key,
3601
+ key$jscomp$0,
3525
3602
  arrayRoot
3526
3603
  );
3527
3604
  case "V":
@@ -3531,13 +3608,13 @@
3531
3608
  DataView,
3532
3609
  1,
3533
3610
  obj,
3534
- key,
3611
+ key$jscomp$0,
3535
3612
  arrayRoot
3536
3613
  );
3537
3614
  case "B":
3538
3615
  return (
3539
3616
  (obj = parseInt(value.slice(2), 16)),
3540
- response._formData.data.get(response._prefix + obj)
3617
+ getBackingBlob(response._formData, response._prefix + obj)
3541
3618
  );
3542
3619
  }
3543
3620
  switch (value[1]) {
@@ -3555,7 +3632,7 @@
3555
3632
  response,
3556
3633
  value,
3557
3634
  obj,
3558
- key,
3635
+ key$jscomp$0,
3559
3636
  arrayRoot,
3560
3637
  createModel
3561
3638
  );
@@ -3574,11 +3651,20 @@
3574
3651
  : new FormData(),
3575
3652
  arraySizeLimit =
3576
3653
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3577
- chunks = new Map();
3654
+ chunks = new Map(),
3655
+ backingStore = {
3656
+ prefix: formFieldPrefix,
3657
+ referencedEntries: null,
3658
+ keyPointer: 0,
3659
+ stringChunks: null,
3660
+ streamChunks: null,
3661
+ blobs: null
3662
+ };
3663
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3578
3664
  return {
3579
3665
  _bundlerConfig: bundlerConfig,
3580
3666
  _prefix: formFieldPrefix,
3581
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3667
+ _formData: backingStore,
3582
3668
  _chunks: chunks,
3583
3669
  _temporaryReferences: temporaryReferences,
3584
3670
  _rootArrayContexts: new WeakMap(),
@@ -3635,13 +3721,19 @@
3635
3721
  }
3636
3722
  var ReactDOM = require("react-dom"),
3637
3723
  React = require("react"),
3724
+ hasOwnProperty = Object.prototype.hasOwnProperty,
3638
3725
  channel = new MessageChannel(),
3639
3726
  taskQueue = [];
3640
3727
  channel.port1.onmessage = function () {
3641
3728
  var task = taskQueue.shift();
3642
3729
  task && task();
3643
3730
  };
3644
- var LocalPromise = Promise,
3731
+ var supportsArrayBufferDetached = hasOwnProperty.call(
3732
+ ArrayBuffer.prototype,
3733
+ "detached"
3734
+ ),
3735
+ didWarnAboutMissingArrayBufferDetached = !1,
3736
+ LocalPromise = Promise,
3645
3737
  scheduleMicrotask =
3646
3738
  "function" === typeof queueMicrotask
3647
3739
  ? queueMicrotask
@@ -4069,7 +4161,6 @@
4069
4161
  debugID = null,
4070
4162
  modelRoot = !1,
4071
4163
  emptyRoot = {},
4072
- hasOwnProperty = Object.prototype.hasOwnProperty,
4073
4164
  chunkCache = new Map(),
4074
4165
  RESPONSE_SYMBOL = Symbol();
4075
4166
  ReactPromise.prototype = Object.create(Promise.prototype);