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.
@@ -27,31 +27,39 @@
27
27
  });
28
28
  }
29
29
  function writeChunk(destination, chunk) {
30
- if (0 !== chunk.byteLength)
31
- if (4096 < chunk.byteLength)
32
- 0 < writtenBytes &&
33
- (destination.enqueue(
34
- new Uint8Array(currentView.buffer, 0, writtenBytes)
30
+ if (0 === chunk.byteLength)
31
+ if (supportsArrayBufferDetached) {
32
+ if (chunk.buffer.detached)
33
+ throw Error(
34
+ "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()`."
35
+ );
36
+ } else
37
+ didWarnAboutMissingArrayBufferDetached ||
38
+ (console.error(
39
+ "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 Edge runtime that supports ArrayBuffer.prototype.detached."
35
40
  ),
36
- (currentView = new Uint8Array(4096)),
37
- (writtenBytes = 0)),
38
- destination.enqueue(chunk);
39
- else {
40
- var allowableBytes = currentView.length - writtenBytes;
41
- allowableBytes < chunk.byteLength &&
42
- (0 === allowableBytes
43
- ? destination.enqueue(currentView)
44
- : (currentView.set(
45
- chunk.subarray(0, allowableBytes),
46
- writtenBytes
47
- ),
48
- destination.enqueue(currentView),
49
- (chunk = chunk.subarray(allowableBytes))),
50
- (currentView = new Uint8Array(4096)),
51
- (writtenBytes = 0));
52
- currentView.set(chunk, writtenBytes);
53
- writtenBytes += chunk.byteLength;
54
- }
41
+ (didWarnAboutMissingArrayBufferDetached = !0));
42
+ else if (4096 < chunk.byteLength)
43
+ 0 < writtenBytes &&
44
+ (destination.enqueue(
45
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
46
+ ),
47
+ (currentView = new Uint8Array(4096)),
48
+ (writtenBytes = 0)),
49
+ destination.enqueue(chunk);
50
+ else {
51
+ var allowableBytes = currentView.length - writtenBytes;
52
+ allowableBytes < chunk.byteLength &&
53
+ (0 === allowableBytes
54
+ ? destination.enqueue(currentView)
55
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
56
+ destination.enqueue(currentView),
57
+ (chunk = chunk.subarray(allowableBytes))),
58
+ (currentView = new Uint8Array(4096)),
59
+ (writtenBytes = 0));
60
+ currentView.set(chunk, writtenBytes);
61
+ writtenBytes += chunk.byteLength;
62
+ }
55
63
  }
56
64
  function writeChunkAndReturn(destination, chunk) {
57
65
  writeChunk(destination, chunk);
@@ -3105,13 +3113,35 @@
3105
3113
  }
3106
3114
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
3107
3115
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
3108
- typedArray = new Uint8Array(
3109
- typedArray.buffer,
3110
- typedArray.byteOffset,
3111
- typedArray.byteLength
3112
- );
3113
- var binaryLength = typedArray.byteLength;
3114
- id = id.toString(16) + ":" + tag + binaryLength.toString(16) + ",";
3116
+ a: {
3117
+ var view = new Uint8Array(
3118
+ typedArray.buffer,
3119
+ typedArray.byteOffset,
3120
+ typedArray.byteLength
3121
+ );
3122
+ if (4096 < typedArray.byteLength) {
3123
+ if (
3124
+ 0 !== typedArray.byteOffset ||
3125
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
3126
+ typedArray.buffer.resizable
3127
+ ) {
3128
+ typedArray = view.slice();
3129
+ break a;
3130
+ }
3131
+ if (!supportsArrayBufferDetached) {
3132
+ didWarnAboutMissingArrayBufferDetached ||
3133
+ (console.error(
3134
+ "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 upgrade to a modern Edge runtime."
3135
+ ),
3136
+ (didWarnAboutMissingArrayBufferDetached = !0));
3137
+ typedArray = view.slice();
3138
+ break a;
3139
+ }
3140
+ }
3141
+ typedArray = view;
3142
+ }
3143
+ view = typedArray.byteLength;
3144
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
3115
3145
  id = stringToChunk(id);
3116
3146
  debug
3117
3147
  ? request.completedDebugChunks.push(
@@ -4268,13 +4298,38 @@
4268
4298
  if (hasOwnProperty.call(moduleExports, metadata[2]))
4269
4299
  return moduleExports[metadata[2]];
4270
4300
  }
4271
- function appendBackingEntry(backingStore, key, value) {
4272
- backingStore.data.append(key, value);
4273
- value = backingStore.keys;
4274
- null === value
4275
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
4276
- (backingStore.keyPointer = 0))
4277
- : value.push(key);
4301
+ function appendBackingEntry(backingStore, value, key) {
4302
+ var prefix = backingStore.prefix;
4303
+ if (key.startsWith(prefix)) {
4304
+ switch (key[prefix.length]) {
4305
+ case "_":
4306
+ prefix = backingStore.referencedEntries;
4307
+ null === prefix && (prefix = backingStore.referencedEntries = []);
4308
+ prefix.push([key, value]);
4309
+ return;
4310
+ case "S":
4311
+ "string" === typeof value &&
4312
+ ((prefix = backingStore.streamChunks),
4313
+ null === prefix &&
4314
+ (prefix = backingStore.streamChunks = new Map()),
4315
+ (backingStore = prefix.get(key)),
4316
+ void 0 === backingStore
4317
+ ? prefix.set(key, [value])
4318
+ : backingStore.push(value));
4319
+ return;
4320
+ }
4321
+ "string" === typeof value
4322
+ ? ((prefix = backingStore.stringChunks),
4323
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
4324
+ prefix.set(key, value))
4325
+ : ((prefix = backingStore.blobs),
4326
+ null === prefix && (prefix = backingStore.blobs = new Map()),
4327
+ prefix.set(key, value));
4328
+ }
4329
+ }
4330
+ function getBackingBlob(backingStore, key) {
4331
+ backingStore = backingStore.blobs;
4332
+ return null === backingStore ? void 0 : backingStore.get(key);
4278
4333
  }
4279
4334
  function ReactPromise(status, value, reason) {
4280
4335
  this.status = status;
@@ -4612,15 +4667,18 @@
4612
4667
  function getChunk(response, id) {
4613
4668
  var chunks = response._chunks,
4614
4669
  chunk = chunks.get(id);
4615
- chunk ||
4616
- ((chunk = response._formData.data.get(response._prefix + id)),
4617
- (chunk =
4670
+ if (!chunk) {
4671
+ chunk = response._prefix;
4672
+ var stringChunks = response._formData.stringChunks;
4673
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
4674
+ chunk =
4618
4675
  "string" === typeof chunk
4619
4676
  ? createResolvedModelChunk(response, chunk, id)
4620
4677
  : response._closed
4621
4678
  ? new ReactPromise("rejected", null, response._closedReason)
4622
- : new ReactPromise("pending", null, null)),
4623
- chunks.set(id, chunk));
4679
+ : new ReactPromise("pending", null, null);
4680
+ chunks.set(id, chunk);
4681
+ }
4624
4682
  return chunk;
4625
4683
  }
4626
4684
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -4867,7 +4925,7 @@
4867
4925
  Error("Already initialized typed array.")
4868
4926
  )
4869
4927
  );
4870
- reference = response._formData.data.get(key).arrayBuffer();
4928
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
4871
4929
  if (initializingHandler) {
4872
4930
  var handler = initializingHandler;
4873
4931
  handler.deps++;
@@ -4911,15 +4969,17 @@
4911
4969
  var chunks = response._chunks;
4912
4970
  stream = new ReactPromise("fulfilled", stream, controller);
4913
4971
  chunks.set(id, stream);
4914
- response = response._formData.data.getAll(response._prefix + id);
4915
- for (id = 0; id < response.length; id++)
4916
- (chunks = response[id]),
4917
- "string" === typeof chunks &&
4918
- ("C" === chunks[0]
4972
+ chunks = response._prefix;
4973
+ response = response._formData.streamChunks;
4974
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
4975
+ if (void 0 !== id)
4976
+ for (response = 0; response < id.length; response++)
4977
+ (chunks = id[response]),
4978
+ "C" === chunks[0]
4919
4979
  ? controller.close(
4920
4980
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
4921
4981
  )
4922
- : controller.enqueueModel(chunks));
4982
+ : controller.enqueueModel(chunks);
4923
4983
  }
4924
4984
  function parseReadableStream(response, reference, type) {
4925
4985
  function enqueue(value) {
@@ -5084,7 +5144,14 @@
5084
5144
  });
5085
5145
  return iterator;
5086
5146
  }
5087
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
5147
+ function parseModelString(
5148
+ response,
5149
+ obj,
5150
+ key$jscomp$0,
5151
+ value,
5152
+ reference,
5153
+ arrayRoot
5154
+ ) {
5088
5155
  if ("$" === value[0]) {
5089
5156
  switch (value[1]) {
5090
5157
  case "$":
@@ -5104,7 +5171,7 @@
5104
5171
  response,
5105
5172
  arrayRoot,
5106
5173
  obj,
5107
- key,
5174
+ key$jscomp$0,
5108
5175
  null,
5109
5176
  loadServerReference$1
5110
5177
  )
@@ -5124,41 +5191,44 @@
5124
5191
  case "Q":
5125
5192
  return (
5126
5193
  (arrayRoot = value.slice(2)),
5127
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
5194
+ getOutlinedModel(
5195
+ response,
5196
+ arrayRoot,
5197
+ obj,
5198
+ key$jscomp$0,
5199
+ null,
5200
+ createMap
5201
+ )
5128
5202
  );
5129
5203
  case "W":
5130
5204
  return (
5131
5205
  (arrayRoot = value.slice(2)),
5132
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
5206
+ getOutlinedModel(
5207
+ response,
5208
+ arrayRoot,
5209
+ obj,
5210
+ key$jscomp$0,
5211
+ null,
5212
+ createSet
5213
+ )
5133
5214
  );
5134
5215
  case "K":
5135
- key = value.slice(2);
5136
- obj = response._prefix + "_";
5137
- key = obj + key + "_";
5138
- arrayRoot = new FormData();
5139
- for (response = response._formData; ; ) {
5140
- value = response;
5141
- reference = value.keys;
5142
- null === reference &&
5143
- ((reference = value.keys = Array.from(value.data.keys())),
5144
- (value.keyPointer = 0));
5145
- value = reference[value.keyPointer];
5146
- if (void 0 === value) break;
5147
- if (value.startsWith(key)) {
5148
- reference = response.data.getAll(value);
5149
- for (
5150
- var referencedFormDataKey = value.slice(key.length), i = 0;
5151
- i < reference.length;
5152
- i++
5153
- )
5154
- arrayRoot.append(referencedFormDataKey, reference[i]);
5155
- reference = response;
5156
- reference.data.delete(value);
5157
- reference.keyPointer++;
5158
- } else if (value.startsWith(obj)) break;
5159
- else response.keyPointer++;
5216
+ key$jscomp$0 = value.slice(2);
5217
+ obj = response._formData;
5218
+ response = response._prefix + "_" + key$jscomp$0 + "_";
5219
+ key$jscomp$0 = new FormData();
5220
+ arrayRoot = obj.referencedEntries;
5221
+ if (null !== arrayRoot) {
5222
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
5223
+ reference = arrayRoot[value];
5224
+ var key = reference[0];
5225
+ if (!key.startsWith(response)) break;
5226
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
5227
+ value++;
5228
+ }
5229
+ obj.keyPointer = value;
5160
5230
  }
5161
- return arrayRoot;
5231
+ return key$jscomp$0;
5162
5232
  case "i":
5163
5233
  return (
5164
5234
  (arrayRoot = value.slice(2)),
@@ -5166,7 +5236,7 @@
5166
5236
  response,
5167
5237
  arrayRoot,
5168
5238
  obj,
5169
- key,
5239
+ key$jscomp$0,
5170
5240
  null,
5171
5241
  extractIterator
5172
5242
  )
@@ -5201,7 +5271,7 @@
5201
5271
  ArrayBuffer,
5202
5272
  1,
5203
5273
  obj,
5204
- key,
5274
+ key$jscomp$0,
5205
5275
  arrayRoot
5206
5276
  );
5207
5277
  case "O":
@@ -5211,7 +5281,7 @@
5211
5281
  Int8Array,
5212
5282
  1,
5213
5283
  obj,
5214
- key,
5284
+ key$jscomp$0,
5215
5285
  arrayRoot
5216
5286
  );
5217
5287
  case "o":
@@ -5221,7 +5291,7 @@
5221
5291
  Uint8Array,
5222
5292
  1,
5223
5293
  obj,
5224
- key,
5294
+ key$jscomp$0,
5225
5295
  arrayRoot
5226
5296
  );
5227
5297
  case "U":
@@ -5231,7 +5301,7 @@
5231
5301
  Uint8ClampedArray,
5232
5302
  1,
5233
5303
  obj,
5234
- key,
5304
+ key$jscomp$0,
5235
5305
  arrayRoot
5236
5306
  );
5237
5307
  case "S":
@@ -5241,7 +5311,7 @@
5241
5311
  Int16Array,
5242
5312
  2,
5243
5313
  obj,
5244
- key,
5314
+ key$jscomp$0,
5245
5315
  arrayRoot
5246
5316
  );
5247
5317
  case "s":
@@ -5251,7 +5321,7 @@
5251
5321
  Uint16Array,
5252
5322
  2,
5253
5323
  obj,
5254
- key,
5324
+ key$jscomp$0,
5255
5325
  arrayRoot
5256
5326
  );
5257
5327
  case "L":
@@ -5261,7 +5331,7 @@
5261
5331
  Int32Array,
5262
5332
  4,
5263
5333
  obj,
5264
- key,
5334
+ key$jscomp$0,
5265
5335
  arrayRoot
5266
5336
  );
5267
5337
  case "l":
@@ -5271,7 +5341,7 @@
5271
5341
  Uint32Array,
5272
5342
  4,
5273
5343
  obj,
5274
- key,
5344
+ key$jscomp$0,
5275
5345
  arrayRoot
5276
5346
  );
5277
5347
  case "G":
@@ -5281,7 +5351,7 @@
5281
5351
  Float32Array,
5282
5352
  4,
5283
5353
  obj,
5284
- key,
5354
+ key$jscomp$0,
5285
5355
  arrayRoot
5286
5356
  );
5287
5357
  case "g":
@@ -5291,7 +5361,7 @@
5291
5361
  Float64Array,
5292
5362
  8,
5293
5363
  obj,
5294
- key,
5364
+ key$jscomp$0,
5295
5365
  arrayRoot
5296
5366
  );
5297
5367
  case "M":
@@ -5301,7 +5371,7 @@
5301
5371
  BigInt64Array,
5302
5372
  8,
5303
5373
  obj,
5304
- key,
5374
+ key$jscomp$0,
5305
5375
  arrayRoot
5306
5376
  );
5307
5377
  case "m":
@@ -5311,7 +5381,7 @@
5311
5381
  BigUint64Array,
5312
5382
  8,
5313
5383
  obj,
5314
- key,
5384
+ key$jscomp$0,
5315
5385
  arrayRoot
5316
5386
  );
5317
5387
  case "V":
@@ -5321,12 +5391,15 @@
5321
5391
  DataView,
5322
5392
  1,
5323
5393
  obj,
5324
- key,
5394
+ key$jscomp$0,
5325
5395
  arrayRoot
5326
5396
  );
5327
5397
  case "B":
5328
5398
  obj = parseInt(value.slice(2), 16);
5329
- response = response._formData.data.get(response._prefix + obj);
5399
+ response = getBackingBlob(
5400
+ response._formData,
5401
+ response._prefix + obj
5402
+ );
5330
5403
  if (!(response instanceof Blob))
5331
5404
  throw Error("Referenced Blob is not a Blob.");
5332
5405
  return response;
@@ -5344,7 +5417,7 @@
5344
5417
  response,
5345
5418
  value,
5346
5419
  obj,
5347
- key,
5420
+ key$jscomp$0,
5348
5421
  arrayRoot,
5349
5422
  createModel
5350
5423
  );
@@ -5363,11 +5436,20 @@
5363
5436
  : new FormData(),
5364
5437
  arraySizeLimit =
5365
5438
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
5366
- chunks = new Map();
5439
+ chunks = new Map(),
5440
+ backingStore = {
5441
+ prefix: formFieldPrefix,
5442
+ referencedEntries: null,
5443
+ keyPointer: 0,
5444
+ stringChunks: null,
5445
+ streamChunks: null,
5446
+ blobs: null
5447
+ };
5448
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
5367
5449
  return {
5368
5450
  _bundlerConfig: bundlerConfig,
5369
5451
  _prefix: formFieldPrefix,
5370
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
5452
+ _formData: backingStore,
5371
5453
  _chunks: chunks,
5372
5454
  _closed: !1,
5373
5455
  _closedReason: null,
@@ -5528,6 +5610,12 @@
5528
5610
  MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
5529
5611
  ASYNC_ITERATOR = Symbol.asyncIterator,
5530
5612
  REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"),
5613
+ hasOwnProperty = Object.prototype.hasOwnProperty,
5614
+ supportsArrayBufferDetached = hasOwnProperty.call(
5615
+ ArrayBuffer.prototype,
5616
+ "detached"
5617
+ ),
5618
+ didWarnAboutMissingArrayBufferDetached = !1,
5531
5619
  LocalPromise = Promise,
5532
5620
  scheduleMicrotask =
5533
5621
  "function" === typeof queueMicrotask
@@ -5907,7 +5995,6 @@
5907
5995
  jsxPropsParents = new WeakMap(),
5908
5996
  jsxChildrenParents = new WeakMap(),
5909
5997
  CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"),
5910
- hasOwnProperty = Object.prototype.hasOwnProperty,
5911
5998
  doNotLimit = new WeakSet();
5912
5999
  "object" === typeof console &&
5913
6000
  null !== console &&
@@ -6093,20 +6180,40 @@
6093
6180
  function progress(entry) {
6094
6181
  if (entry.done) close(response$jscomp$0);
6095
6182
  else {
6096
- entry = entry.value;
6097
- var name = entry[0];
6098
- entry = entry[1];
6099
- if ("string" === typeof entry) {
6100
- var response = response$jscomp$0;
6101
- appendBackingEntry(response._formData, name, entry);
6102
- var prefix = response._prefix;
6103
- if (name.startsWith(prefix)) {
6104
- var chunks = response._chunks;
6105
- name = +name.slice(prefix.length);
6106
- (chunks = chunks.get(name)) &&
6107
- resolveModelChunk(response, chunks, entry, name);
6183
+ var _entry$value = entry.value;
6184
+ entry = _entry$value[0];
6185
+ _entry$value = _entry$value[1];
6186
+ if ("string" === typeof _entry$value)
6187
+ a: {
6188
+ var response = response$jscomp$0,
6189
+ prefix = response._prefix;
6190
+ if (entry.startsWith(prefix)) {
6191
+ var chunks = response._chunks;
6192
+ if ("S" === entry[prefix.length]) {
6193
+ if (
6194
+ entry.length > prefix.length + 1 &&
6195
+ ((prefix = +entry.slice(prefix.length + 1)),
6196
+ (chunks = chunks.get(prefix)))
6197
+ ) {
6198
+ resolveModelChunk(response, chunks, _entry$value, prefix);
6199
+ break a;
6200
+ }
6201
+ } else if (
6202
+ ((prefix = +entry.slice(prefix.length)),
6203
+ (chunks = chunks.get(prefix)))
6204
+ ) {
6205
+ resolveModelChunk(response, chunks, _entry$value, prefix);
6206
+ break a;
6207
+ }
6208
+ }
6209
+ appendBackingEntry(response._formData, _entry$value, entry);
6108
6210
  }
6109
- } else appendBackingEntry(response$jscomp$0._formData, name, entry);
6211
+ else
6212
+ appendBackingEntry(
6213
+ response$jscomp$0._formData,
6214
+ _entry$value,
6215
+ entry
6216
+ );
6110
6217
  iterator.next().then(progress, error);
6111
6218
  }
6112
6219
  }