react-server-dom-turbopack 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.
@@ -26,12 +26,17 @@ function formatProdErrorMessage(code) {
26
26
  " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."
27
27
  );
28
28
  }
29
- var channel = new MessageChannel(),
29
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
30
+ channel = new MessageChannel(),
30
31
  taskQueue = [];
31
32
  channel.port1.onmessage = function () {
32
33
  var task = taskQueue.shift();
33
34
  task && task();
34
35
  };
36
+ var supportsArrayBufferDetached = hasOwnProperty.call(
37
+ ArrayBuffer.prototype,
38
+ "detached"
39
+ );
35
40
  function scheduleWork(callback) {
36
41
  taskQueue.push(callback);
37
42
  channel.port2.postMessage(null);
@@ -53,28 +58,28 @@ var LocalPromise = Promise,
53
58
  currentView = null,
54
59
  writtenBytes = 0;
55
60
  function writeChunk(destination, chunk) {
56
- if (0 !== chunk.byteLength)
57
- if (2048 < chunk.byteLength)
58
- 0 < writtenBytes &&
59
- (destination.enqueue(
60
- new Uint8Array(currentView.buffer, 0, writtenBytes)
61
- ),
62
- (currentView = new Uint8Array(2048)),
63
- (writtenBytes = 0)),
64
- destination.enqueue(chunk);
65
- else {
66
- var allowableBytes = currentView.length - writtenBytes;
67
- allowableBytes < chunk.byteLength &&
68
- (0 === allowableBytes
69
- ? destination.enqueue(currentView)
70
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
71
- destination.enqueue(currentView),
72
- (chunk = chunk.subarray(allowableBytes))),
73
- (currentView = new Uint8Array(2048)),
74
- (writtenBytes = 0));
75
- currentView.set(chunk, writtenBytes);
76
- writtenBytes += chunk.byteLength;
77
- }
61
+ if (0 === chunk.byteLength) {
62
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
63
+ throw Error(formatProdErrorMessage(612));
64
+ } else if (2048 < chunk.byteLength)
65
+ 0 < writtenBytes &&
66
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
67
+ (currentView = new Uint8Array(2048)),
68
+ (writtenBytes = 0)),
69
+ destination.enqueue(chunk);
70
+ else {
71
+ var allowableBytes = currentView.length - writtenBytes;
72
+ allowableBytes < chunk.byteLength &&
73
+ (0 === allowableBytes
74
+ ? destination.enqueue(currentView)
75
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
76
+ destination.enqueue(currentView),
77
+ (chunk = chunk.subarray(allowableBytes))),
78
+ (currentView = new Uint8Array(2048)),
79
+ (writtenBytes = 0));
80
+ currentView.set(chunk, writtenBytes);
81
+ writtenBytes += chunk.byteLength;
82
+ }
78
83
  }
79
84
  function writeChunkAndReturn(destination, chunk) {
80
85
  writeChunk(destination, chunk);
@@ -809,8 +814,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
809
814
  "\n " + str + "\n " + objectOrArray)
810
815
  : "\n " + str;
811
816
  }
812
- var hasOwnProperty = Object.prototype.hasOwnProperty,
813
- ObjectPrototype$1 = Object.prototype,
817
+ var ObjectPrototype$1 = Object.prototype,
814
818
  stringify = JSON.stringify,
815
819
  NEXT_TWO_CHUNKS_ARE_ATOMIC = Symbol();
816
820
  function defaultErrorHandler(error) {
@@ -2028,12 +2032,28 @@ function emitModelChunk(request, id, json) {
2028
2032
  }
2029
2033
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
2030
2034
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
2031
- debug = new Uint8Array(
2032
- typedArray.buffer,
2033
- typedArray.byteOffset,
2034
- typedArray.byteLength
2035
- );
2036
- typedArray = 2048 < typedArray.byteLength ? debug.slice() : debug;
2035
+ a: {
2036
+ debug = new Uint8Array(
2037
+ typedArray.buffer,
2038
+ typedArray.byteOffset,
2039
+ typedArray.byteLength
2040
+ );
2041
+ if (2048 < typedArray.byteLength) {
2042
+ if (
2043
+ 0 !== typedArray.byteOffset ||
2044
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
2045
+ typedArray.buffer.resizable
2046
+ ) {
2047
+ typedArray = debug.slice();
2048
+ break a;
2049
+ }
2050
+ if (!supportsArrayBufferDetached) {
2051
+ typedArray = debug.slice();
2052
+ break a;
2053
+ }
2054
+ }
2055
+ typedArray = debug;
2056
+ }
2037
2057
  debug = typedArray.byteLength;
2038
2058
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
2039
2059
  id = stringToChunk(id);
@@ -2453,6 +2473,38 @@ function requireModule(metadata) {
2453
2473
  if (hasOwnProperty.call(moduleExports, metadata[2]))
2454
2474
  return moduleExports[metadata[2]];
2455
2475
  }
2476
+ function appendBackingEntry(backingStore, value, key) {
2477
+ var prefix = backingStore.prefix;
2478
+ if (key.startsWith(prefix)) {
2479
+ switch (key[prefix.length]) {
2480
+ case "_":
2481
+ prefix = backingStore.referencedEntries;
2482
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2483
+ prefix.push([key, value]);
2484
+ return;
2485
+ case "S":
2486
+ "string" === typeof value &&
2487
+ ((prefix = backingStore.streamChunks),
2488
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2489
+ (backingStore = prefix.get(key)),
2490
+ void 0 === backingStore
2491
+ ? prefix.set(key, [value])
2492
+ : backingStore.push(value));
2493
+ return;
2494
+ }
2495
+ "string" === typeof value
2496
+ ? ((prefix = backingStore.stringChunks),
2497
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2498
+ prefix.set(key, value))
2499
+ : ((prefix = backingStore.blobs),
2500
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2501
+ prefix.set(key, value));
2502
+ }
2503
+ }
2504
+ function getBackingBlob(backingStore, key) {
2505
+ backingStore = backingStore.blobs;
2506
+ return null === backingStore ? void 0 : backingStore.get(key);
2507
+ }
2456
2508
  var RESPONSE_SYMBOL = Symbol();
2457
2509
  function ReactPromise(status, value, reason) {
2458
2510
  this.status = status;
@@ -2827,15 +2879,18 @@ function reportGlobalError(response, error) {
2827
2879
  function getChunk(response, id) {
2828
2880
  var chunks = response._chunks,
2829
2881
  chunk = chunks.get(id);
2830
- chunk ||
2831
- ((chunk = response._formData.data.get(response._prefix + id)),
2832
- (chunk =
2882
+ if (!chunk) {
2883
+ chunk = response._prefix;
2884
+ var stringChunks = response._formData.stringChunks;
2885
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2886
+ chunk =
2833
2887
  "string" === typeof chunk
2834
2888
  ? createResolvedModelChunk(response, chunk, id)
2835
2889
  : response._closed
2836
2890
  ? createErroredChunk(response, response._closedReason)
2837
- : new ReactPromise("pending", null, null)),
2838
- chunks.set(id, chunk));
2891
+ : new ReactPromise("pending", null, null);
2892
+ chunks.set(id, chunk);
2893
+ }
2839
2894
  return chunk;
2840
2895
  }
2841
2896
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3059,7 +3114,7 @@ function parseTypedArray(
3059
3114
  reference,
3060
3115
  createErroredChunk(response, Error(formatProdErrorMessage(568)))
3061
3116
  );
3062
- reference = response._formData.data.get(key).arrayBuffer();
3117
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3063
3118
  if (initializingHandler) {
3064
3119
  var handler = initializingHandler;
3065
3120
  handler.deps++;
@@ -3103,13 +3158,15 @@ function resolveStream(response, id, stream, controller) {
3103
3158
  var chunks = response._chunks;
3104
3159
  stream = new ReactPromise("fulfilled", stream, controller);
3105
3160
  chunks.set(id, stream);
3106
- response = response._formData.data.getAll(response._prefix + id);
3107
- for (id = 0; id < response.length; id++)
3108
- (chunks = response[id]),
3109
- "string" === typeof chunks &&
3110
- ("C" === chunks[0]
3161
+ chunks = response._prefix;
3162
+ response = response._formData.streamChunks;
3163
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3164
+ if (void 0 !== id)
3165
+ for (response = 0; response < id.length; response++)
3166
+ (chunks = id[response]),
3167
+ "C" === chunks[0]
3111
3168
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
3112
- : controller.enqueueModel(chunks));
3169
+ : controller.enqueueModel(chunks);
3113
3170
  }
3114
3171
  function parseReadableStream(response, reference, type) {
3115
3172
  function enqueue(value) {
@@ -3270,7 +3327,14 @@ function parseAsyncIterable(response, reference, iterator) {
3270
3327
  });
3271
3328
  return iterator;
3272
3329
  }
3273
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3330
+ function parseModelString(
3331
+ response,
3332
+ obj,
3333
+ key$jscomp$0,
3334
+ value,
3335
+ reference,
3336
+ arrayRoot
3337
+ ) {
3274
3338
  if ("$" === value[0]) {
3275
3339
  switch (value[1]) {
3276
3340
  case "$":
@@ -3288,7 +3352,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3288
3352
  response,
3289
3353
  arrayRoot,
3290
3354
  obj,
3291
- key,
3355
+ key$jscomp$0,
3292
3356
  null,
3293
3357
  loadServerReference$1
3294
3358
  )
@@ -3303,43 +3367,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3303
3367
  case "Q":
3304
3368
  return (
3305
3369
  (arrayRoot = value.slice(2)),
3306
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3370
+ getOutlinedModel(
3371
+ response,
3372
+ arrayRoot,
3373
+ obj,
3374
+ key$jscomp$0,
3375
+ null,
3376
+ createMap
3377
+ )
3307
3378
  );
3308
3379
  case "W":
3309
3380
  return (
3310
3381
  (arrayRoot = value.slice(2)),
3311
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3382
+ getOutlinedModel(
3383
+ response,
3384
+ arrayRoot,
3385
+ obj,
3386
+ key$jscomp$0,
3387
+ null,
3388
+ createSet
3389
+ )
3312
3390
  );
3313
3391
  case "K":
3314
- key = value.slice(2);
3315
- obj = response._prefix + "_";
3316
- key = obj + key + "_";
3317
- arrayRoot = new FormData();
3318
- for (response = response._formData; ; ) {
3319
- value = response.keys;
3320
- null === value &&
3321
- ((value = response.keys = Array.from(response.data.keys())),
3322
- (response.keyPointer = 0));
3323
- value = value[response.keyPointer];
3324
- if (void 0 === value) break;
3325
- if (value.startsWith(key)) {
3326
- reference = response.data.getAll(value);
3327
- for (
3328
- var referencedFormDataKey = value.slice(key.length), i = 0;
3329
- i < reference.length;
3330
- i++
3331
- )
3332
- arrayRoot.append(referencedFormDataKey, reference[i]);
3333
- response.data.delete(value);
3334
- response.keyPointer++;
3335
- } else if (value.startsWith(obj)) break;
3336
- else response.keyPointer++;
3392
+ obj = value.slice(2);
3393
+ obj = response._prefix + "_" + obj + "_";
3394
+ response = response._formData;
3395
+ key$jscomp$0 = new FormData();
3396
+ arrayRoot = response.referencedEntries;
3397
+ if (null !== arrayRoot) {
3398
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3399
+ reference = arrayRoot[value];
3400
+ var key = reference[0];
3401
+ if (!key.startsWith(obj)) break;
3402
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3403
+ value++;
3404
+ }
3405
+ response.keyPointer = value;
3337
3406
  }
3338
- return arrayRoot;
3407
+ return key$jscomp$0;
3339
3408
  case "i":
3340
3409
  return (
3341
3410
  (arrayRoot = value.slice(2)),
3342
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3411
+ getOutlinedModel(
3412
+ response,
3413
+ arrayRoot,
3414
+ obj,
3415
+ key$jscomp$0,
3416
+ null,
3417
+ extractIterator
3418
+ )
3343
3419
  );
3344
3420
  case "I":
3345
3421
  return Infinity;
@@ -3364,7 +3440,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3364
3440
  ArrayBuffer,
3365
3441
  1,
3366
3442
  obj,
3367
- key,
3443
+ key$jscomp$0,
3368
3444
  arrayRoot
3369
3445
  );
3370
3446
  case "O":
@@ -3374,7 +3450,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3374
3450
  Int8Array,
3375
3451
  1,
3376
3452
  obj,
3377
- key,
3453
+ key$jscomp$0,
3378
3454
  arrayRoot
3379
3455
  );
3380
3456
  case "o":
@@ -3384,7 +3460,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3384
3460
  Uint8Array,
3385
3461
  1,
3386
3462
  obj,
3387
- key,
3463
+ key$jscomp$0,
3388
3464
  arrayRoot
3389
3465
  );
3390
3466
  case "U":
@@ -3394,7 +3470,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3394
3470
  Uint8ClampedArray,
3395
3471
  1,
3396
3472
  obj,
3397
- key,
3473
+ key$jscomp$0,
3398
3474
  arrayRoot
3399
3475
  );
3400
3476
  case "S":
@@ -3404,7 +3480,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3404
3480
  Int16Array,
3405
3481
  2,
3406
3482
  obj,
3407
- key,
3483
+ key$jscomp$0,
3408
3484
  arrayRoot
3409
3485
  );
3410
3486
  case "s":
@@ -3414,7 +3490,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3414
3490
  Uint16Array,
3415
3491
  2,
3416
3492
  obj,
3417
- key,
3493
+ key$jscomp$0,
3418
3494
  arrayRoot
3419
3495
  );
3420
3496
  case "L":
@@ -3424,7 +3500,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3424
3500
  Int32Array,
3425
3501
  4,
3426
3502
  obj,
3427
- key,
3503
+ key$jscomp$0,
3428
3504
  arrayRoot
3429
3505
  );
3430
3506
  case "l":
@@ -3434,7 +3510,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3434
3510
  Uint32Array,
3435
3511
  4,
3436
3512
  obj,
3437
- key,
3513
+ key$jscomp$0,
3438
3514
  arrayRoot
3439
3515
  );
3440
3516
  case "G":
@@ -3444,7 +3520,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3444
3520
  Float32Array,
3445
3521
  4,
3446
3522
  obj,
3447
- key,
3523
+ key$jscomp$0,
3448
3524
  arrayRoot
3449
3525
  );
3450
3526
  case "g":
@@ -3454,7 +3530,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3454
3530
  Float64Array,
3455
3531
  8,
3456
3532
  obj,
3457
- key,
3533
+ key$jscomp$0,
3458
3534
  arrayRoot
3459
3535
  );
3460
3536
  case "M":
@@ -3464,7 +3540,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3464
3540
  BigInt64Array,
3465
3541
  8,
3466
3542
  obj,
3467
- key,
3543
+ key$jscomp$0,
3468
3544
  arrayRoot
3469
3545
  );
3470
3546
  case "m":
@@ -3474,7 +3550,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3474
3550
  BigUint64Array,
3475
3551
  8,
3476
3552
  obj,
3477
- key,
3553
+ key$jscomp$0,
3478
3554
  arrayRoot
3479
3555
  );
3480
3556
  case "V":
@@ -3484,12 +3560,12 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3484
3560
  DataView,
3485
3561
  1,
3486
3562
  obj,
3487
- key,
3563
+ key$jscomp$0,
3488
3564
  arrayRoot
3489
3565
  );
3490
3566
  case "B":
3491
3567
  obj = parseInt(value.slice(2), 16);
3492
- response = response._formData.data.get(response._prefix + obj);
3568
+ response = getBackingBlob(response._formData, response._prefix + obj);
3493
3569
  if (!(response instanceof Blob))
3494
3570
  throw Error(formatProdErrorMessage(582));
3495
3571
  return response;
@@ -3503,7 +3579,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3503
3579
  return parseAsyncIterable(response, value, !0);
3504
3580
  }
3505
3581
  value = value.slice(1);
3506
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3582
+ return getOutlinedModel(
3583
+ response,
3584
+ value,
3585
+ obj,
3586
+ key$jscomp$0,
3587
+ arrayRoot,
3588
+ createModel
3589
+ );
3507
3590
  }
3508
3591
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3509
3592
  return value;
@@ -3515,11 +3598,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3515
3598
  : new FormData(),
3516
3599
  arraySizeLimit =
3517
3600
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3518
- chunks = new Map();
3601
+ chunks = new Map(),
3602
+ backingStore = {
3603
+ prefix: formFieldPrefix,
3604
+ referencedEntries: null,
3605
+ keyPointer: 0,
3606
+ stringChunks: null,
3607
+ streamChunks: null,
3608
+ blobs: null
3609
+ };
3610
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3519
3611
  return {
3520
3612
  _bundlerConfig: bundlerConfig,
3521
3613
  _prefix: formFieldPrefix,
3522
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3614
+ _formData: backingStore,
3523
3615
  _chunks: chunks,
3524
3616
  _closed: !1,
3525
3617
  _closedReason: null,