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,6 +58,10 @@ channel.port1.onmessage = function () {
58
58
  var task = taskQueue.shift();
59
59
  task && task();
60
60
  };
61
+ var supportsArrayBufferDetached = hasOwnProperty.call(
62
+ ArrayBuffer.prototype,
63
+ "detached"
64
+ );
61
65
  function scheduleWork(callback) {
62
66
  taskQueue.push(callback);
63
67
  channel.port2.postMessage(null);
@@ -79,28 +83,28 @@ var LocalPromise = Promise,
79
83
  currentView = null,
80
84
  writtenBytes = 0;
81
85
  function writeChunk(destination, chunk) {
82
- if (0 !== chunk.byteLength)
83
- if (2048 < chunk.byteLength)
84
- 0 < writtenBytes &&
85
- (destination.enqueue(
86
- new Uint8Array(currentView.buffer, 0, writtenBytes)
87
- ),
88
- (currentView = new Uint8Array(2048)),
89
- (writtenBytes = 0)),
90
- destination.enqueue(chunk);
91
- else {
92
- var allowableBytes = currentView.length - writtenBytes;
93
- allowableBytes < chunk.byteLength &&
94
- (0 === allowableBytes
95
- ? destination.enqueue(currentView)
96
- : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
97
- destination.enqueue(currentView),
98
- (chunk = chunk.subarray(allowableBytes))),
99
- (currentView = new Uint8Array(2048)),
100
- (writtenBytes = 0));
101
- currentView.set(chunk, writtenBytes);
102
- writtenBytes += chunk.byteLength;
103
- }
86
+ if (0 === chunk.byteLength) {
87
+ if (supportsArrayBufferDetached && chunk.buffer.detached)
88
+ throw Error(formatProdErrorMessage(612));
89
+ } else if (2048 < chunk.byteLength)
90
+ 0 < writtenBytes &&
91
+ (destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes)),
92
+ (currentView = new Uint8Array(2048)),
93
+ (writtenBytes = 0)),
94
+ destination.enqueue(chunk);
95
+ else {
96
+ var allowableBytes = currentView.length - writtenBytes;
97
+ allowableBytes < chunk.byteLength &&
98
+ (0 === allowableBytes
99
+ ? destination.enqueue(currentView)
100
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
101
+ destination.enqueue(currentView),
102
+ (chunk = chunk.subarray(allowableBytes))),
103
+ (currentView = new Uint8Array(2048)),
104
+ (writtenBytes = 0));
105
+ currentView.set(chunk, writtenBytes);
106
+ writtenBytes += chunk.byteLength;
107
+ }
104
108
  }
105
109
  function writeChunkAndReturn(destination, chunk) {
106
110
  writeChunk(destination, chunk);
@@ -1915,12 +1919,28 @@ function emitModelChunk(request, id, json) {
1915
1919
  }
1916
1920
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1917
1921
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1918
- debug = new Uint8Array(
1919
- typedArray.buffer,
1920
- typedArray.byteOffset,
1921
- typedArray.byteLength
1922
- );
1923
- typedArray = 2048 < typedArray.byteLength ? debug.slice() : debug;
1922
+ a: {
1923
+ debug = new Uint8Array(
1924
+ typedArray.buffer,
1925
+ typedArray.byteOffset,
1926
+ typedArray.byteLength
1927
+ );
1928
+ if (2048 < typedArray.byteLength) {
1929
+ if (
1930
+ 0 !== typedArray.byteOffset ||
1931
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
1932
+ typedArray.buffer.resizable
1933
+ ) {
1934
+ typedArray = debug.slice();
1935
+ break a;
1936
+ }
1937
+ if (!supportsArrayBufferDetached) {
1938
+ typedArray = debug.slice();
1939
+ break a;
1940
+ }
1941
+ }
1942
+ typedArray = debug;
1943
+ }
1924
1944
  debug = typedArray.byteLength;
1925
1945
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1926
1946
  id = stringToChunk(id);
@@ -2274,6 +2294,38 @@ function abort(request, reason) {
2274
2294
  fatalError(request, error$32);
2275
2295
  }
2276
2296
  }
2297
+ function appendBackingEntry(backingStore, value, key) {
2298
+ var prefix = backingStore.prefix;
2299
+ if (key.startsWith(prefix)) {
2300
+ switch (key[prefix.length]) {
2301
+ case "_":
2302
+ prefix = backingStore.referencedEntries;
2303
+ null === prefix && (prefix = backingStore.referencedEntries = []);
2304
+ prefix.push([key, value]);
2305
+ return;
2306
+ case "S":
2307
+ "string" === typeof value &&
2308
+ ((prefix = backingStore.streamChunks),
2309
+ null === prefix && (prefix = backingStore.streamChunks = new Map()),
2310
+ (backingStore = prefix.get(key)),
2311
+ void 0 === backingStore
2312
+ ? prefix.set(key, [value])
2313
+ : backingStore.push(value));
2314
+ return;
2315
+ }
2316
+ "string" === typeof value
2317
+ ? ((prefix = backingStore.stringChunks),
2318
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
2319
+ prefix.set(key, value))
2320
+ : ((prefix = backingStore.blobs),
2321
+ null === prefix && (prefix = backingStore.blobs = new Map()),
2322
+ prefix.set(key, value));
2323
+ }
2324
+ }
2325
+ function getBackingBlob(backingStore, key) {
2326
+ backingStore = backingStore.blobs;
2327
+ return null === backingStore ? void 0 : backingStore.get(key);
2328
+ }
2277
2329
  var RESPONSE_SYMBOL = Symbol();
2278
2330
  function ReactPromise(status, value, reason) {
2279
2331
  this.status = status;
@@ -2648,15 +2700,18 @@ function reportGlobalError(response, error) {
2648
2700
  function getChunk(response, id) {
2649
2701
  var chunks = response._chunks,
2650
2702
  chunk = chunks.get(id);
2651
- chunk ||
2652
- ((chunk = response._formData.data.get(response._prefix + id)),
2653
- (chunk =
2703
+ if (!chunk) {
2704
+ chunk = response._prefix;
2705
+ var stringChunks = response._formData.stringChunks;
2706
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
2707
+ chunk =
2654
2708
  "string" === typeof chunk
2655
2709
  ? createResolvedModelChunk(response, chunk, id)
2656
2710
  : response._closed
2657
2711
  ? createErroredChunk(response, response._closedReason)
2658
- : new ReactPromise("pending", null, null)),
2659
- chunks.set(id, chunk));
2712
+ : new ReactPromise("pending", null, null);
2713
+ chunks.set(id, chunk);
2714
+ }
2660
2715
  return chunk;
2661
2716
  }
2662
2717
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -2880,7 +2935,7 @@ function parseTypedArray(
2880
2935
  reference,
2881
2936
  createErroredChunk(response, Error(formatProdErrorMessage(568)))
2882
2937
  );
2883
- reference = response._formData.data.get(key).arrayBuffer();
2938
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
2884
2939
  if (initializingHandler) {
2885
2940
  var handler = initializingHandler;
2886
2941
  handler.deps++;
@@ -2924,13 +2979,15 @@ function resolveStream(response, id, stream, controller) {
2924
2979
  var chunks = response._chunks;
2925
2980
  stream = new ReactPromise("fulfilled", stream, controller);
2926
2981
  chunks.set(id, stream);
2927
- response = response._formData.data.getAll(response._prefix + id);
2928
- for (id = 0; id < response.length; id++)
2929
- (chunks = response[id]),
2930
- "string" === typeof chunks &&
2931
- ("C" === chunks[0]
2982
+ chunks = response._prefix;
2983
+ response = response._formData.streamChunks;
2984
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
2985
+ if (void 0 !== id)
2986
+ for (response = 0; response < id.length; response++)
2987
+ (chunks = id[response]),
2988
+ "C" === chunks[0]
2932
2989
  ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2933
- : controller.enqueueModel(chunks));
2990
+ : controller.enqueueModel(chunks);
2934
2991
  }
2935
2992
  function parseReadableStream(response, reference, type) {
2936
2993
  function enqueue(value) {
@@ -3091,7 +3148,14 @@ function parseAsyncIterable(response, reference, iterator) {
3091
3148
  });
3092
3149
  return iterator;
3093
3150
  }
3094
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
3151
+ function parseModelString(
3152
+ response,
3153
+ obj,
3154
+ key$jscomp$0,
3155
+ value,
3156
+ reference,
3157
+ arrayRoot
3158
+ ) {
3095
3159
  if ("$" === value[0]) {
3096
3160
  switch (value[1]) {
3097
3161
  case "$":
@@ -3109,7 +3173,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3109
3173
  response,
3110
3174
  arrayRoot,
3111
3175
  obj,
3112
- key,
3176
+ key$jscomp$0,
3113
3177
  null,
3114
3178
  loadServerReference$1
3115
3179
  )
@@ -3124,43 +3188,55 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3124
3188
  case "Q":
3125
3189
  return (
3126
3190
  (arrayRoot = value.slice(2)),
3127
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
3191
+ getOutlinedModel(
3192
+ response,
3193
+ arrayRoot,
3194
+ obj,
3195
+ key$jscomp$0,
3196
+ null,
3197
+ createMap
3198
+ )
3128
3199
  );
3129
3200
  case "W":
3130
3201
  return (
3131
3202
  (arrayRoot = value.slice(2)),
3132
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
3203
+ getOutlinedModel(
3204
+ response,
3205
+ arrayRoot,
3206
+ obj,
3207
+ key$jscomp$0,
3208
+ null,
3209
+ createSet
3210
+ )
3133
3211
  );
3134
3212
  case "K":
3135
- key = value.slice(2);
3136
- obj = response._prefix + "_";
3137
- key = obj + key + "_";
3138
- arrayRoot = new FormData();
3139
- for (response = response._formData; ; ) {
3140
- value = response.keys;
3141
- null === value &&
3142
- ((value = response.keys = Array.from(response.data.keys())),
3143
- (response.keyPointer = 0));
3144
- value = value[response.keyPointer];
3145
- if (void 0 === value) break;
3146
- if (value.startsWith(key)) {
3147
- reference = response.data.getAll(value);
3148
- for (
3149
- var referencedFormDataKey = value.slice(key.length), i = 0;
3150
- i < reference.length;
3151
- i++
3152
- )
3153
- arrayRoot.append(referencedFormDataKey, reference[i]);
3154
- response.data.delete(value);
3155
- response.keyPointer++;
3156
- } else if (value.startsWith(obj)) break;
3157
- else response.keyPointer++;
3213
+ obj = value.slice(2);
3214
+ obj = response._prefix + "_" + obj + "_";
3215
+ response = response._formData;
3216
+ key$jscomp$0 = new FormData();
3217
+ arrayRoot = response.referencedEntries;
3218
+ if (null !== arrayRoot) {
3219
+ for (value = response.keyPointer; value < arrayRoot.length; ) {
3220
+ reference = arrayRoot[value];
3221
+ var key = reference[0];
3222
+ if (!key.startsWith(obj)) break;
3223
+ key$jscomp$0.append(key.slice(obj.length), reference[1]);
3224
+ value++;
3225
+ }
3226
+ response.keyPointer = value;
3158
3227
  }
3159
- return arrayRoot;
3228
+ return key$jscomp$0;
3160
3229
  case "i":
3161
3230
  return (
3162
3231
  (arrayRoot = value.slice(2)),
3163
- getOutlinedModel(response, arrayRoot, obj, key, null, extractIterator)
3232
+ getOutlinedModel(
3233
+ response,
3234
+ arrayRoot,
3235
+ obj,
3236
+ key$jscomp$0,
3237
+ null,
3238
+ extractIterator
3239
+ )
3164
3240
  );
3165
3241
  case "I":
3166
3242
  return Infinity;
@@ -3185,7 +3261,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3185
3261
  ArrayBuffer,
3186
3262
  1,
3187
3263
  obj,
3188
- key,
3264
+ key$jscomp$0,
3189
3265
  arrayRoot
3190
3266
  );
3191
3267
  case "O":
@@ -3195,7 +3271,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3195
3271
  Int8Array,
3196
3272
  1,
3197
3273
  obj,
3198
- key,
3274
+ key$jscomp$0,
3199
3275
  arrayRoot
3200
3276
  );
3201
3277
  case "o":
@@ -3205,7 +3281,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3205
3281
  Uint8Array,
3206
3282
  1,
3207
3283
  obj,
3208
- key,
3284
+ key$jscomp$0,
3209
3285
  arrayRoot
3210
3286
  );
3211
3287
  case "U":
@@ -3215,7 +3291,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3215
3291
  Uint8ClampedArray,
3216
3292
  1,
3217
3293
  obj,
3218
- key,
3294
+ key$jscomp$0,
3219
3295
  arrayRoot
3220
3296
  );
3221
3297
  case "S":
@@ -3225,7 +3301,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3225
3301
  Int16Array,
3226
3302
  2,
3227
3303
  obj,
3228
- key,
3304
+ key$jscomp$0,
3229
3305
  arrayRoot
3230
3306
  );
3231
3307
  case "s":
@@ -3235,7 +3311,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3235
3311
  Uint16Array,
3236
3312
  2,
3237
3313
  obj,
3238
- key,
3314
+ key$jscomp$0,
3239
3315
  arrayRoot
3240
3316
  );
3241
3317
  case "L":
@@ -3245,7 +3321,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3245
3321
  Int32Array,
3246
3322
  4,
3247
3323
  obj,
3248
- key,
3324
+ key$jscomp$0,
3249
3325
  arrayRoot
3250
3326
  );
3251
3327
  case "l":
@@ -3255,7 +3331,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3255
3331
  Uint32Array,
3256
3332
  4,
3257
3333
  obj,
3258
- key,
3334
+ key$jscomp$0,
3259
3335
  arrayRoot
3260
3336
  );
3261
3337
  case "G":
@@ -3265,7 +3341,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3265
3341
  Float32Array,
3266
3342
  4,
3267
3343
  obj,
3268
- key,
3344
+ key$jscomp$0,
3269
3345
  arrayRoot
3270
3346
  );
3271
3347
  case "g":
@@ -3275,7 +3351,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3275
3351
  Float64Array,
3276
3352
  8,
3277
3353
  obj,
3278
- key,
3354
+ key$jscomp$0,
3279
3355
  arrayRoot
3280
3356
  );
3281
3357
  case "M":
@@ -3285,7 +3361,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3285
3361
  BigInt64Array,
3286
3362
  8,
3287
3363
  obj,
3288
- key,
3364
+ key$jscomp$0,
3289
3365
  arrayRoot
3290
3366
  );
3291
3367
  case "m":
@@ -3295,7 +3371,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3295
3371
  BigUint64Array,
3296
3372
  8,
3297
3373
  obj,
3298
- key,
3374
+ key$jscomp$0,
3299
3375
  arrayRoot
3300
3376
  );
3301
3377
  case "V":
@@ -3305,12 +3381,12 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3305
3381
  DataView,
3306
3382
  1,
3307
3383
  obj,
3308
- key,
3384
+ key$jscomp$0,
3309
3385
  arrayRoot
3310
3386
  );
3311
3387
  case "B":
3312
3388
  obj = parseInt(value.slice(2), 16);
3313
- response = response._formData.data.get(response._prefix + obj);
3389
+ response = getBackingBlob(response._formData, response._prefix + obj);
3314
3390
  if (!(response instanceof Blob))
3315
3391
  throw Error(formatProdErrorMessage(582));
3316
3392
  return response;
@@ -3324,7 +3400,14 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3324
3400
  return parseAsyncIterable(response, value, !0);
3325
3401
  }
3326
3402
  value = value.slice(1);
3327
- return getOutlinedModel(response, value, obj, key, arrayRoot, createModel);
3403
+ return getOutlinedModel(
3404
+ response,
3405
+ value,
3406
+ obj,
3407
+ key$jscomp$0,
3408
+ arrayRoot,
3409
+ createModel
3410
+ );
3328
3411
  }
3329
3412
  null !== arrayRoot && bumpArrayCount(arrayRoot, value.length, response);
3330
3413
  return value;
@@ -3336,11 +3419,20 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3336
3419
  : new FormData(),
3337
3420
  arraySizeLimit =
3338
3421
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
3339
- chunks = new Map();
3422
+ chunks = new Map(),
3423
+ backingStore = {
3424
+ prefix: formFieldPrefix,
3425
+ referencedEntries: null,
3426
+ keyPointer: 0,
3427
+ stringChunks: null,
3428
+ streamChunks: null,
3429
+ blobs: null
3430
+ };
3431
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
3340
3432
  return {
3341
3433
  _bundlerConfig: bundlerConfig,
3342
3434
  _prefix: formFieldPrefix,
3343
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
3435
+ _formData: backingStore,
3344
3436
  _chunks: chunks,
3345
3437
  _closed: !1,
3346
3438
  _closedReason: null,