react-server-dom-parcel 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.
@@ -58,7 +58,11 @@ function getIteratorFn(maybeIterable) {
58
58
  return "function" === typeof maybeIterable ? maybeIterable : null;
59
59
  }
60
60
  var ASYNC_ITERATOR = Symbol.asyncIterator,
61
- REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key");
61
+ REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"),
62
+ supportsArrayBufferDetached = hasOwnProperty.call(
63
+ ArrayBuffer.prototype,
64
+ "detached"
65
+ );
62
66
  function handleErrorInNextTick(error) {
63
67
  setTimeout(function () {
64
68
  throw error;
@@ -76,28 +80,30 @@ var LocalPromise = Promise,
76
80
  currentView = null,
77
81
  writtenBytes = 0;
78
82
  function writeChunk(destination, chunk) {
79
- if (0 !== chunk.byteLength)
80
- if (4096 < chunk.byteLength)
81
- 0 < writtenBytes &&
82
- (destination.enqueue(
83
- new Uint8Array(currentView.buffer, 0, writtenBytes)
84
- ),
85
- (currentView = new Uint8Array(4096)),
86
- (writtenBytes = 0)),
87
- destination.enqueue(chunk);
88
- else {
89
- var allowableBytes = currentView.length - writtenBytes;
90
- allowableBytes < chunk.byteLength &&
91
- (0 === allowableBytes
92
- ? destination.enqueue(currentView)
93
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
94
- destination.enqueue(currentView),
95
- (chunk = chunk.subarray(allowableBytes))),
96
- (currentView = new Uint8Array(4096)),
97
- (writtenBytes = 0));
98
- currentView.set(chunk, writtenBytes);
99
- writtenBytes += chunk.byteLength;
100
- }
83
+ if (0 === chunk.byteLength) {
84
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
85
+ throw Error(
86
+ "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()`."
87
+ );
88
+ } else if (4096 < chunk.byteLength)
89
+ 0 < writtenBytes &&
90
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
91
+ (currentView = new Uint8Array(4096)),
92
+ (writtenBytes = 0)),
93
+ destination.enqueue(chunk);
94
+ else {
95
+ var allowableBytes = currentView.length - writtenBytes;
96
+ allowableBytes < chunk.byteLength &&
97
+ (0 === allowableBytes
98
+ ? destination.enqueue(currentView)
99
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
100
+ destination.enqueue(currentView),
101
+ (chunk = chunk.subarray(allowableBytes))),
102
+ (currentView = new Uint8Array(4096)),
103
+ (writtenBytes = 0));
104
+ currentView.set(chunk, writtenBytes);
105
+ writtenBytes += chunk.byteLength;
106
+ }
101
107
  }
102
108
  function writeChunkAndReturn(destination, chunk) {
103
109
  writeChunk(destination, chunk);
@@ -1920,11 +1926,28 @@ function emitModelChunk(request, id, json) {
1920
1926
  }
1921
1927
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1922
1928
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1923
- typedArray = new Uint8Array(
1924
- typedArray.buffer,
1925
- typedArray.byteOffset,
1926
- typedArray.byteLength
1927
- );
1929
+ a: {
1930
+ debug = new Uint8Array(
1931
+ typedArray.buffer,
1932
+ typedArray.byteOffset,
1933
+ typedArray.byteLength
1934
+ );
1935
+ if (4096 < typedArray.byteLength) {
1936
+ if (
1937
+ 0 !== typedArray.byteOffset ||
1938
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1939
+ typedArray.buffer.resizable
1940
+ ) {
1941
+ typedArray = debug.slice();
1942
+ break a;
1943
+ }
1944
+ if (!supportsArrayBufferDetached) {
1945
+ typedArray = debug.slice();
1946
+ break a;
1947
+ }
1948
+ }
1949
+ typedArray = debug;
1950
+ }
1928
1951
  debug = typedArray.byteLength;
1929
1952
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1930
1953
  id = stringToChunk(id);
@@ -2289,13 +2312,37 @@ function abort(request, reason) {
2289
2312
  fatalError(request, error$32);
2290
2313
  }
2291
2314
  }
2292
- function appendBackingEntry(backingStore, key, value) {
2293
- backingStore.data.append(key, value);
2294
- value = backingStore.keys;
2295
- null === value
2296
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
2297
- (backingStore.keyPointer = 0))
2298
- : value.push(key);
2315
+ function appendBackingEntry(backingStore, value, key) {
2316
+ var prefix = backingStore.prefix;
2317
+ if (key.startsWith(prefix)) {
2318
+ switch (key[prefix.length]) {
2319
+ case "_":
2320
+ prefix = backingStore.referencedEntries;
2321
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2322
+ prefix.push([key, value]);
2323
+ return;
2324
+ case "S":
2325
+ "string" === typeof value &&
2326
+ ((prefix = backingStore.streamChunks),
2327
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2328
+ (backingStore = prefix.get(key)),
2329
+ void 0 === backingStore
2330
+ ? prefix.set(key, [value])
2331
+ : backingStore.push(value));
2332
+ return;
2333
+ }
2334
+ "string" === typeof value
2335
+ ? ((prefix = backingStore.stringChunks),
2336
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2337
+ prefix.set(key, value))
2338
+ : ((prefix = backingStore.blobs),
2339
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2340
+ prefix.set(key, value));
2341
+ }
2342
+ }
2343
+ function getBackingBlob(backingStore, key) {
2344
+ backingStore = backingStore.blobs;
2345
+ return null === backingStore ? void 0 : backingStore.get(key);
2299
2346
  }
2300
2347
  var RESPONSE_SYMBOL = Symbol();
2301
2348
  function ReactPromise(status, value, reason) {
@@ -2676,15 +2723,18 @@ function reportGlobalError(response, error) {
2676
2723
  function getChunk(response, id) {
2677
2724
  var chunks = response._chunks,
2678
2725
  chunk = chunks.get(id);
2679
- chunk ||
2680
- ((chunk = response._formData.data.get(response._prefix + id)),
2681
- (chunk =
2726
+ if (!chunk) {
2727
+ chunk = response._prefix;
2728
+ var stringChunks = response._formData.stringChunks;
2729
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2730
+ chunk =
2682
2731
  "string" === typeof chunk
2683
2732
  ? createResolvedModelChunk(response, chunk, id)
2684
2733
  : response._closed
2685
2734
  ? new ReactPromise("rejected", null, response._closedReason)
2686
- : new ReactPromise("pending", null, null)),
2687
- chunks.set(id, chunk));
2735
+ : new ReactPromise("pending", null, null);
2736
+ chunks.set(id, chunk);
2737
+ }
2688
2738
  return chunk;
2689
2739
  }
2690
2740
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2915,7 +2965,7 @@ function parseTypedArray(
2915
2965
  Error("Already initialized typed array.")
2916
2966
  )
2917
2967
  );
2918
- reference = response._formData.data.get(key).arrayBuffer();
2968
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2919
2969
  if (initializingHandler) {
2920
2970
  var handler = initializingHandler;
2921
2971
  handler.deps++;
@@ -2959,13 +3009,15 @@ function resolveStream(response, id, stream, controller) {
2959
3009
  var chunks = response._chunks;
2960
3010
  stream = new ReactPromise("fulfilled", stream, controller);
2961
3011
  chunks.set(id, stream);
2962
- response = response._formData.data.getAll(response._prefix + id);
2963
- for (id = 0; id < response.length; id++)
2964
- (chunks = response[id]),
2965
- "string" === typeof chunks &&
2966
- ("C" === chunks[0]
3012
+ chunks = response._prefix;
3013
+ response = response._formData.streamChunks;
3014
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
3015
+ if (void 0 !== id)
3016
+ for (response = 0; response < id.length; response++)
3017
+ (chunks = id[response]),
3018
+ "C" === chunks[0]
2967
3019
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2968
- : controller.enqueueModel(chunks));
3020
+ : controller.enqueueModel(chunks);
2969
3021
  }
2970
3022
  function parseReadableStream(response, reference, type) {
2971
3023
  function enqueue(value) {
@@ -3131,7 +3183,14 @@ function parseAsyncIterable(response, reference, iterator) {
3131
3183
  });
3132
3184
  return iterator;
3133
3185
  }
3134
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3186
+ function parseModelString(
3187
+ response,
3188
+ obj,
3189
+ key$jscomp$0,
3190
+ value,
3191
+ reference,
3192
+ arrayRoot
3193
+ ) {
3135
3194
  if ("$" === value[0]) {
3136
3195
  switch (value[1]) {
3137
3196
  case "$":
@@ -3149,7 +3208,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3149
3208
  response,
3150
3209
  arrayRoot,
3151
3210
  obj,
3152
- key,
3211
+ key$jscomp$0,
3153
3212
  null,
3154
3213
  loadServerReference$1
3155
3214
  )
@@ -3166,43 +3225,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3166
3225
  case "Q":
3167
3226
  return (
3168
3227
  (arrayRoot = value.slice(2)),
3169
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3228
+ getOutlinedModel(
3229
+ response,
3230
+ arrayRoot,
3231
+ obj,
3232
+ key$jscomp$0,
3233
+ null,
3234
+ createMap
3235
+ )
3170
3236
  );
3171
3237
  case "W":
3172
3238
  return (
3173
3239
  (arrayRoot = value.slice(2)),
3174
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3240
+ getOutlinedModel(
3241
+ response,
3242
+ arrayRoot,
3243
+ obj,
3244
+ key$jscomp$0,
3245
+ null,
3246
+ createSet
3247
+ )
3175
3248
  );
3176
3249
  case "K":
3177
- key = value.slice(2);
3178
- obj = response._prefix + "_";
3179
- key = obj + key + "_";
3180
- arrayRoot = new FormData();
3181
- for (response = response._formData; ; ) {
3182
- value = response.keys;
3183
- null === value &&
3184
- ((value = response.keys = Array.from(response.data.keys())),
3185
- (response.keyPointer = 0));
3186
- value = value[response.keyPointer];
3187
- if (void 0 === value) break;
3188
- if (value.startsWith(key)) {
3189
- reference = response.data.getAll(value);
3190
- for (
3191
- var referencedFormDataKey = value.slice(key.length), i = 0;
3192
- i < reference.length;
3193
- i++
3194
- )
3195
- arrayRoot.append(referencedFormDataKey, reference[i]);
3196
- response.data.delete(value);
3197
- response.keyPointer++;
3198
- } else if (value.startsWith(obj)) break;
3199
- else response.keyPointer++;
3250
+ obj = value.slice(2);
3251
+ obj = response._prefix + "_" + obj + "_";
3252
+ response = response._formData;
3253
+ key$jscomp$0 = new FormData();
3254
+ arrayRoot = response.referencedEntries;
3255
+ if (null !== arrayRoot) {
3256
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3257
+ reference = arrayRoot[value];
3258
+ var key = reference[0];
3259
+ if (!key.startsWith(obj)) break;
3260
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3261
+ value++;
3262
+ }
3263
+ response.keyPointer = value;
3200
3264
  }
3201
- return arrayRoot;
3265
+ return key$jscomp$0;
3202
3266
  case "i":
3203
3267
  return (
3204
3268
  (arrayRoot = value.slice(2)),
3205
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3269
+ getOutlinedModel(
3270
+ response,
3271
+ arrayRoot,
3272
+ obj,
3273
+ key$jscomp$0,
3274
+ null,
3275
+ extractIterator
3276
+ )
3206
3277
  );
3207
3278
  case "I":
3208
3279
  return Infinity;
@@ -3231,7 +3302,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3231
3302
  ArrayBuffer,
3232
3303
  1,
3233
3304
  obj,
3234
- key,
3305
+ key$jscomp$0,
3235
3306
  arrayRoot
3236
3307
  );
3237
3308
  case "O":
@@ -3241,7 +3312,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3241
3312
  Int8Array,
3242
3313
  1,
3243
3314
  obj,
3244
- key,
3315
+ key$jscomp$0,
3245
3316
  arrayRoot
3246
3317
  );
3247
3318
  case "o":
@@ -3251,7 +3322,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3251
3322
  Uint8Array,
3252
3323
  1,
3253
3324
  obj,
3254
- key,
3325
+ key$jscomp$0,
3255
3326
  arrayRoot
3256
3327
  );
3257
3328
  case "U":
@@ -3261,7 +3332,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3261
3332
  Uint8ClampedArray,
3262
3333
  1,
3263
3334
  obj,
3264
- key,
3335
+ key$jscomp$0,
3265
3336
  arrayRoot
3266
3337
  );
3267
3338
  case "S":
@@ -3271,7 +3342,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3271
3342
  Int16Array,
3272
3343
  2,
3273
3344
  obj,
3274
- key,
3345
+ key$jscomp$0,
3275
3346
  arrayRoot
3276
3347
  );
3277
3348
  case "s":
@@ -3281,7 +3352,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3281
3352
  Uint16Array,
3282
3353
  2,
3283
3354
  obj,
3284
- key,
3355
+ key$jscomp$0,
3285
3356
  arrayRoot
3286
3357
  );
3287
3358
  case "L":
@@ -3291,7 +3362,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3291
3362
  Int32Array,
3292
3363
  4,
3293
3364
  obj,
3294
- key,
3365
+ key$jscomp$0,
3295
3366
  arrayRoot
3296
3367
  );
3297
3368
  case "l":
@@ -3301,7 +3372,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3301
3372
  Uint32Array,
3302
3373
  4,
3303
3374
  obj,
3304
- key,
3375
+ key$jscomp$0,
3305
3376
  arrayRoot
3306
3377
  );
3307
3378
  case "G":
@@ -3311,7 +3382,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3311
3382
  Float32Array,
3312
3383
  4,
3313
3384
  obj,
3314
- key,
3385
+ key$jscomp$0,
3315
3386
  arrayRoot
3316
3387
  );
3317
3388
  case "g":
@@ -3321,7 +3392,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3321
3392
  Float64Array,
3322
3393
  8,
3323
3394
  obj,
3324
- key,
3395
+ key$jscomp$0,
3325
3396
  arrayRoot
3326
3397
  );
3327
3398
  case "M":
@@ -3331,7 +3402,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3331
3402
  BigInt64Array,
3332
3403
  8,
3333
3404
  obj,
3334
- key,
3405
+ key$jscomp$0,
3335
3406
  arrayRoot
3336
3407
  );
3337
3408
  case "m":
@@ -3341,7 +3412,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3341
3412
  BigUint64Array,
3342
3413
  8,
3343
3414
  obj,
3344
- key,
3415
+ key$jscomp$0,
3345
3416
  arrayRoot
3346
3417
  );
3347
3418
  case "V":
@@ -3351,12 +3422,12 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3351
3422
  DataView,
3352
3423
  1,
3353
3424
  obj,
3354
- key,
3425
+ key$jscomp$0,
3355
3426
  arrayRoot
3356
3427
  );
3357
3428
  case "B":
3358
3429
  obj = parseInt(value.slice(2), 16);
3359
- response = response._formData.data.get(response._prefix + obj);
3430
+ response = getBackingBlob(response._formData, response._prefix + obj);
3360
3431
  if (!(response instanceof Blob))
3361
3432
  throw Error("Referenced Blob is not a Blob.");
3362
3433
  return response;
@@ -3370,7 +3441,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3370
3441
  return parseAsyncIterable(response, value, !0);
3371
3442
  }
3372
3443
  value = value.slice(1);
3373
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3444
+ return getOutlinedModel(
3445
+ response,
3446
+ value,
3447
+ obj,
3448
+ key$jscomp$0,
3449
+ arrayRoot,
3450
+ createModel
3451
+ );
3374
3452
  }
3375
3453
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3376
3454
  return value;
@@ -3382,11 +3460,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3382
3460
  : new FormData(),
3383
3461
  arraySizeLimit =
3384
3462
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3385
- chunks = new Map();
3463
+ chunks = new Map(),
3464
+ backingStore = {
3465
+ prefix: formFieldPrefix,
3466
+ referencedEntries: null,
3467
+ keyPointer: 0,
3468
+ stringChunks: null,
3469
+ streamChunks: null,
3470
+ blobs: null
3471
+ };
3472
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3386
3473
  return {
3387
3474
  _bundlerConfig: bundlerConfig,
3388
3475
  _prefix: formFieldPrefix,
3389
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3476
+ _formData: backingStore,
3390
3477
  _chunks: chunks,
3391
3478
  _closed: !1,
3392
3479
  _closedReason: null,
@@ -3523,19 +3610,34 @@ exports.decodeReplyFromAsyncIterable = function (iterable, options) {
3523
3610
  function progress(entry) {
3524
3611
  if (entry.done) close(response);
3525
3612
  else {
3526
- entry = entry.value;
3527
- var name = entry[0];
3528
- entry = entry[1];
3529
- if ("string" === typeof entry) {
3530
- appendBackingEntry(response._formData, name, entry);
3531
- var prefix = response._prefix;
3532
- if (name.startsWith(prefix)) {
3533
- var chunks = response._chunks;
3534
- name = +name.slice(prefix.length);
3535
- (chunks = chunks.get(name)) &&
3536
- resolveModelChunk(response, chunks, entry, name);
3613
+ var _entry$value = entry.value;
3614
+ entry = _entry$value[0];
3615
+ _entry$value = _entry$value[1];
3616
+ if ("string" === typeof _entry$value)
3617
+ a: {
3618
+ var prefix = response._prefix;
3619
+ if (entry.startsWith(prefix)) {
3620
+ var chunks = response._chunks;
3621
+ if ("S" === entry[prefix.length]) {
3622
+ if (
3623
+ entry.length > prefix.length + 1 &&
3624
+ ((prefix = +entry.slice(prefix.length + 1)),
3625
+ (chunks = chunks.get(prefix)))
3626
+ ) {
3627
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3628
+ break a;
3629
+ }
3630
+ } else if (
3631
+ ((prefix = +entry.slice(prefix.length)),
3632
+ (chunks = chunks.get(prefix)))
3633
+ ) {
3634
+ resolveModelChunk(response, chunks, _entry$value, prefix);
3635
+ break a;
3636
+ }
3637
+ }
3638
+ appendBackingEntry(response._formData, _entry$value, entry);
3537
3639
  }
3538
- } else appendBackingEntry(response._formData, name, entry);
3640
+ else appendBackingEntry(response._formData, _entry$value, entry);
3539
3641
  iterator.next().then(progress, error);
3540
3642
  }
3541
3643
  }