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.
@@ -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);
@@ -2464,6 +2484,38 @@ __webpack_require__.u = function (chunkId) {
2464
2484
  ? flightChunk
2465
2485
  : webpackGetChunkFilename(chunkId);
2466
2486
  };
2487
+ function appendBackingEntry(backingStore, value, key) {
2488
+ var prefix = backingStore.prefix;
2489
+ if (key.startsWith(prefix)) {
2490
+ switch (key[prefix.length]) {
2491
+ case "_":
2492
+ prefix = backingStore.referencedEntries;
2493
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2494
+ prefix.push([key, value]);
2495
+ return;
2496
+ case "S":
2497
+ "string" === typeof value &&
2498
+ ((prefix = backingStore.streamChunks),
2499
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2500
+ (backingStore = prefix.get(key)),
2501
+ void 0 === backingStore
2502
+ ? prefix.set(key, [value])
2503
+ : backingStore.push(value));
2504
+ return;
2505
+ }
2506
+ "string" === typeof value
2507
+ ? ((prefix = backingStore.stringChunks),
2508
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2509
+ prefix.set(key, value))
2510
+ : ((prefix = backingStore.blobs),
2511
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2512
+ prefix.set(key, value));
2513
+ }
2514
+ }
2515
+ function getBackingBlob(backingStore, key) {
2516
+ backingStore = backingStore.blobs;
2517
+ return null === backingStore ? void 0 : backingStore.get(key);
2518
+ }
2467
2519
  var RESPONSE_SYMBOL = Symbol();
2468
2520
  function ReactPromise(status, value, reason) {
2469
2521
  this.status = status;
@@ -2838,15 +2890,18 @@ function reportGlobalError(response, error) {
2838
2890
  function getChunk(response, id) {
2839
2891
  var chunks = response._chunks,
2840
2892
  chunk = chunks.get(id);
2841
- chunk ||
2842
- ((chunk = response._formData.data.get(response._prefix + id)),
2843
- (chunk =
2893
+ if (!chunk) {
2894
+ chunk = response._prefix;
2895
+ var stringChunks = response._formData.stringChunks;
2896
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2897
+ chunk =
2844
2898
  "string" === typeof chunk
2845
2899
  ? createResolvedModelChunk(response, chunk, id)
2846
2900
  : response._closed
2847
2901
  ? createErroredChunk(response, response._closedReason)
2848
- : new ReactPromise("pending", null, null)),
2849
- chunks.set(id, chunk));
2902
+ : new ReactPromise("pending", null, null);
2903
+ chunks.set(id, chunk);
2904
+ }
2850
2905
  return chunk;
2851
2906
  }
2852
2907
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -3070,7 +3125,7 @@ function parseTypedArray(
3070
3125
  reference,
3071
3126
  createErroredChunk(response, Error(formatProdErrorMessage(568)))
3072
3127
  );
3073
- reference = response._formData.data.get(key).arrayBuffer();
3128
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
3074
3129
  if (initializingHandler) {
3075
3130
  var handler = initializingHandler;
3076
3131
  handler.deps++;
@@ -3114,13 +3169,15 @@ function resolveStream(response, id, stream, controller) {
3114
3169
  var chunks = response._chunks;
3115
3170
  stream = new ReactPromise("fulfilled", stream, controller);
3116
3171
  chunks.set(id, stream);
3117
- response = response._formData.data.getAll(response._prefix + id);
3118
- for (id = 0; id < response.length; id++)
3119
- (chunks = response[id]),
3120
- "string" === typeof chunks &&
3121
- ("C" === chunks[0]
3172
+ chunks = response._prefix;
3173
+ response = response._formData.streamChunks;
3174
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3175
+ if (void 0 !== id)
3176
+ for (response = 0; response < id.length; response++)
3177
+ (chunks = id[response]),
3178
+ "C" === chunks[0]
3122
3179
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
3123
- : controller.enqueueModel(chunks));
3180
+ : controller.enqueueModel(chunks);
3124
3181
  }
3125
3182
  function parseReadableStream(response, reference, type) {
3126
3183
  function enqueue(value) {
@@ -3281,7 +3338,14 @@ function parseAsyncIterable(response, reference, iterator) {
3281
3338
  });
3282
3339
  return iterator;
3283
3340
  }
3284
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3341
+ function parseModelString(
3342
+ response,
3343
+ obj,
3344
+ key$jscomp$0,
3345
+ value,
3346
+ reference,
3347
+ arrayRoot
3348
+ ) {
3285
3349
  if ("$" === value[0]) {
3286
3350
  switch (value[1]) {
3287
3351
  case "$":
@@ -3299,7 +3363,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3299
3363
  response,
3300
3364
  arrayRoot,
3301
3365
  obj,
3302
- key,
3366
+ key$jscomp$0,
3303
3367
  null,
3304
3368
  loadServerReference$1
3305
3369
  )
@@ -3314,43 +3378,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3314
3378
  case "Q":
3315
3379
  return (
3316
3380
  (arrayRoot = value.slice(2)),
3317
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3381
+ getOutlinedModel(
3382
+ response,
3383
+ arrayRoot,
3384
+ obj,
3385
+ key$jscomp$0,
3386
+ null,
3387
+ createMap
3388
+ )
3318
3389
  );
3319
3390
  case "W":
3320
3391
  return (
3321
3392
  (arrayRoot = value.slice(2)),
3322
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3393
+ getOutlinedModel(
3394
+ response,
3395
+ arrayRoot,
3396
+ obj,
3397
+ key$jscomp$0,
3398
+ null,
3399
+ createSet
3400
+ )
3323
3401
  );
3324
3402
  case "K":
3325
- key = value.slice(2);
3326
- obj = response._prefix + "_";
3327
- key = obj + key + "_";
3328
- arrayRoot = new FormData();
3329
- for (response = response._formData; ; ) {
3330
- value = response.keys;
3331
- null === value &&
3332
- ((value = response.keys = Array.from(response.data.keys())),
3333
- (response.keyPointer = 0));
3334
- value = value[response.keyPointer];
3335
- if (void 0 === value) break;
3336
- if (value.startsWith(key)) {
3337
- reference = response.data.getAll(value);
3338
- for (
3339
- var referencedFormDataKey = value.slice(key.length), i = 0;
3340
- i < reference.length;
3341
- i++
3342
- )
3343
- arrayRoot.append(referencedFormDataKey, reference[i]);
3344
- response.data.delete(value);
3345
- response.keyPointer++;
3346
- } else if (value.startsWith(obj)) break;
3347
- else response.keyPointer++;
3403
+ obj = value.slice(2);
3404
+ obj = response._prefix + "_" + obj + "_";
3405
+ response = response._formData;
3406
+ key$jscomp$0 = new FormData();
3407
+ arrayRoot = response.referencedEntries;
3408
+ if (null !== arrayRoot) {
3409
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3410
+ reference = arrayRoot[value];
3411
+ var key = reference[0];
3412
+ if (!key.startsWith(obj)) break;
3413
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3414
+ value++;
3415
+ }
3416
+ response.keyPointer = value;
3348
3417
  }
3349
- return arrayRoot;
3418
+ return key$jscomp$0;
3350
3419
  case "i":
3351
3420
  return (
3352
3421
  (arrayRoot = value.slice(2)),
3353
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3422
+ getOutlinedModel(
3423
+ response,
3424
+ arrayRoot,
3425
+ obj,
3426
+ key$jscomp$0,
3427
+ null,
3428
+ extractIterator
3429
+ )
3354
3430
  );
3355
3431
  case "I":
3356
3432
  return Infinity;
@@ -3375,7 +3451,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3375
3451
  ArrayBuffer,
3376
3452
  1,
3377
3453
  obj,
3378
- key,
3454
+ key$jscomp$0,
3379
3455
  arrayRoot
3380
3456
  );
3381
3457
  case "O":
@@ -3385,7 +3461,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3385
3461
  Int8Array,
3386
3462
  1,
3387
3463
  obj,
3388
- key,
3464
+ key$jscomp$0,
3389
3465
  arrayRoot
3390
3466
  );
3391
3467
  case "o":
@@ -3395,7 +3471,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3395
3471
  Uint8Array,
3396
3472
  1,
3397
3473
  obj,
3398
- key,
3474
+ key$jscomp$0,
3399
3475
  arrayRoot
3400
3476
  );
3401
3477
  case "U":
@@ -3405,7 +3481,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3405
3481
  Uint8ClampedArray,
3406
3482
  1,
3407
3483
  obj,
3408
- key,
3484
+ key$jscomp$0,
3409
3485
  arrayRoot
3410
3486
  );
3411
3487
  case "S":
@@ -3415,7 +3491,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3415
3491
  Int16Array,
3416
3492
  2,
3417
3493
  obj,
3418
- key,
3494
+ key$jscomp$0,
3419
3495
  arrayRoot
3420
3496
  );
3421
3497
  case "s":
@@ -3425,7 +3501,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3425
3501
  Uint16Array,
3426
3502
  2,
3427
3503
  obj,
3428
- key,
3504
+ key$jscomp$0,
3429
3505
  arrayRoot
3430
3506
  );
3431
3507
  case "L":
@@ -3435,7 +3511,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3435
3511
  Int32Array,
3436
3512
  4,
3437
3513
  obj,
3438
- key,
3514
+ key$jscomp$0,
3439
3515
  arrayRoot
3440
3516
  );
3441
3517
  case "l":
@@ -3445,7 +3521,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3445
3521
  Uint32Array,
3446
3522
  4,
3447
3523
  obj,
3448
- key,
3524
+ key$jscomp$0,
3449
3525
  arrayRoot
3450
3526
  );
3451
3527
  case "G":
@@ -3455,7 +3531,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3455
3531
  Float32Array,
3456
3532
  4,
3457
3533
  obj,
3458
- key,
3534
+ key$jscomp$0,
3459
3535
  arrayRoot
3460
3536
  );
3461
3537
  case "g":
@@ -3465,7 +3541,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3465
3541
  Float64Array,
3466
3542
  8,
3467
3543
  obj,
3468
- key,
3544
+ key$jscomp$0,
3469
3545
  arrayRoot
3470
3546
  );
3471
3547
  case "M":
@@ -3475,7 +3551,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3475
3551
  BigInt64Array,
3476
3552
  8,
3477
3553
  obj,
3478
- key,
3554
+ key$jscomp$0,
3479
3555
  arrayRoot
3480
3556
  );
3481
3557
  case "m":
@@ -3485,7 +3561,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3485
3561
  BigUint64Array,
3486
3562
  8,
3487
3563
  obj,
3488
- key,
3564
+ key$jscomp$0,
3489
3565
  arrayRoot
3490
3566
  );
3491
3567
  case "V":
@@ -3495,12 +3571,12 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3495
3571
  DataView,
3496
3572
  1,
3497
3573
  obj,
3498
- key,
3574
+ key$jscomp$0,
3499
3575
  arrayRoot
3500
3576
  );
3501
3577
  case "B":
3502
3578
  obj = parseInt(value.slice(2), 16);
3503
- response = response._formData.data.get(response._prefix + obj);
3579
+ response = getBackingBlob(response._formData, response._prefix + obj);
3504
3580
  if (!(response instanceof Blob))
3505
3581
  throw Error(formatProdErrorMessage(582));
3506
3582
  return response;
@@ -3514,7 +3590,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3514
3590
  return parseAsyncIterable(response, value, !0);
3515
3591
  }
3516
3592
  value = value.slice(1);
3517
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3593
+ return getOutlinedModel(
3594
+ response,
3595
+ value,
3596
+ obj,
3597
+ key$jscomp$0,
3598
+ arrayRoot,
3599
+ createModel
3600
+ );
3518
3601
  }
3519
3602
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3520
3603
  return value;
@@ -3526,11 +3609,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3526
3609
  : new FormData(),
3527
3610
  arraySizeLimit =
3528
3611
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3529
- chunks = new Map();
3612
+ chunks = new Map(),
3613
+ backingStore = {
3614
+ prefix: formFieldPrefix,
3615
+ referencedEntries: null,
3616
+ keyPointer: 0,
3617
+ stringChunks: null,
3618
+ streamChunks: null,
3619
+ blobs: null
3620
+ };
3621
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3530
3622
  return {
3531
3623
  _bundlerConfig: bundlerConfig,
3532
3624
  _prefix: formFieldPrefix,
3533
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3625
+ _formData: backingStore,
3534
3626
  _chunks: chunks,
3535
3627
  _closed: !1,
3536
3628
  _closedReason: null,