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.
@@ -22,31 +22,39 @@
22
22
  });
23
23
  }
24
24
  function writeChunk(destination, chunk) {
25
- if (0 !== chunk.byteLength)
26
- if (2048 < chunk.byteLength)
27
- 0 < writtenBytes &&
28
- (destination.enqueue(
29
- new Uint8Array(currentView.buffer, 0, writtenBytes)
25
+ if (0 === chunk.byteLength)
26
+ if (supportsArrayBufferDetached) {
27
+ if (chunk.buffer.detached)
28
+ throw Error(
29
+ "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()`."
30
+ );
31
+ } else
32
+ didWarnAboutMissingArrayBufferDetached ||
33
+ (console.error(
34
+ "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 browser that supports ArrayBuffer.prototype.detached."
30
35
  ),
31
- (currentView = new Uint8Array(2048)),
32
- (writtenBytes = 0)),
33
- destination.enqueue(chunk);
34
- else {
35
- var allowableBytes = currentView.length - writtenBytes;
36
- allowableBytes < chunk.byteLength &&
37
- (0 === allowableBytes
38
- ? destination.enqueue(currentView)
39
- : (currentView.set(
40
- chunk.subarray(0, allowableBytes),
41
- writtenBytes
42
- ),
43
- destination.enqueue(currentView),
44
- (chunk = chunk.subarray(allowableBytes))),
45
- (currentView = new Uint8Array(2048)),
46
- (writtenBytes = 0));
47
- currentView.set(chunk, writtenBytes);
48
- writtenBytes += chunk.byteLength;
49
- }
36
+ (didWarnAboutMissingArrayBufferDetached = !0));
37
+ else if (2048 < chunk.byteLength)
38
+ 0 < writtenBytes &&
39
+ (destination.enqueue(
40
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
41
+ ),
42
+ (currentView = new Uint8Array(2048)),
43
+ (writtenBytes = 0)),
44
+ destination.enqueue(chunk);
45
+ else {
46
+ var allowableBytes = currentView.length - writtenBytes;
47
+ allowableBytes < chunk.byteLength &&
48
+ (0 === allowableBytes
49
+ ? destination.enqueue(currentView)
50
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
51
+ destination.enqueue(currentView),
52
+ (chunk = chunk.subarray(allowableBytes))),
53
+ (currentView = new Uint8Array(2048)),
54
+ (writtenBytes = 0));
55
+ currentView.set(chunk, writtenBytes);
56
+ writtenBytes += chunk.byteLength;
57
+ }
50
58
  }
51
59
  function writeChunkAndReturn(destination, chunk) {
52
60
  writeChunk(destination, chunk);
@@ -3034,14 +3042,35 @@
3034
3042
  }
3035
3043
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
3036
3044
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
3037
- var buffer = new Uint8Array(
3038
- typedArray.buffer,
3039
- typedArray.byteOffset,
3040
- typedArray.byteLength
3041
- );
3042
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
3043
- buffer = typedArray.byteLength;
3044
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
3045
+ a: {
3046
+ var view = new Uint8Array(
3047
+ typedArray.buffer,
3048
+ typedArray.byteOffset,
3049
+ typedArray.byteLength
3050
+ );
3051
+ if (2048 < typedArray.byteLength) {
3052
+ if (
3053
+ 0 !== typedArray.byteOffset ||
3054
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
3055
+ typedArray.buffer.resizable
3056
+ ) {
3057
+ typedArray = view.slice();
3058
+ break a;
3059
+ }
3060
+ if (!supportsArrayBufferDetached) {
3061
+ didWarnAboutMissingArrayBufferDetached ||
3062
+ (console.error(
3063
+ "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 use a modern browser that supports ArrayBuffer.prototype.detached."
3064
+ ),
3065
+ (didWarnAboutMissingArrayBufferDetached = !0));
3066
+ typedArray = view.slice();
3067
+ break a;
3068
+ }
3069
+ }
3070
+ typedArray = view;
3071
+ }
3072
+ view = typedArray.byteLength;
3073
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
3045
3074
  id = stringToChunk(id);
3046
3075
  debug
3047
3076
  ? request.completedDebugChunks.push(
@@ -4191,6 +4220,39 @@
4191
4220
  if (hasOwnProperty.call(moduleExports, metadata[2]))
4192
4221
  return moduleExports[metadata[2]];
4193
4222
  }
4223
+ function appendBackingEntry(backingStore, value, key) {
4224
+ var prefix = backingStore.prefix;
4225
+ if (key.startsWith(prefix)) {
4226
+ switch (key[prefix.length]) {
4227
+ case "_":
4228
+ prefix = backingStore.referencedEntries;
4229
+ null === prefix && (prefix = backingStore.referencedEntries = []);
4230
+ prefix.push([key, value]);
4231
+ return;
4232
+ case "S":
4233
+ "string" === typeof value &&
4234
+ ((prefix = backingStore.streamChunks),
4235
+ null === prefix &&
4236
+ (prefix = backingStore.streamChunks = new Map()),
4237
+ (backingStore = prefix.get(key)),
4238
+ void 0 === backingStore
4239
+ ? prefix.set(key, [value])
4240
+ : backingStore.push(value));
4241
+ return;
4242
+ }
4243
+ "string" === typeof value
4244
+ ? ((prefix = backingStore.stringChunks),
4245
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
4246
+ prefix.set(key, value))
4247
+ : ((prefix = backingStore.blobs),
4248
+ null === prefix && (prefix = backingStore.blobs = new Map()),
4249
+ prefix.set(key, value));
4250
+ }
4251
+ }
4252
+ function getBackingBlob(backingStore, key) {
4253
+ backingStore = backingStore.blobs;
4254
+ return null === backingStore ? void 0 : backingStore.get(key);
4255
+ }
4194
4256
  function ReactPromise(status, value, reason) {
4195
4257
  this.status = status;
4196
4258
  this.value = value;
@@ -4527,15 +4589,18 @@
4527
4589
  function getChunk(response, id) {
4528
4590
  var chunks = response._chunks,
4529
4591
  chunk = chunks.get(id);
4530
- chunk ||
4531
- ((chunk = response._formData.data.get(response._prefix + id)),
4532
- (chunk =
4592
+ if (!chunk) {
4593
+ chunk = response._prefix;
4594
+ var stringChunks = response._formData.stringChunks;
4595
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
4596
+ chunk =
4533
4597
  "string" === typeof chunk
4534
4598
  ? createResolvedModelChunk(response, chunk, id)
4535
4599
  : response._closed
4536
4600
  ? new ReactPromise("rejected", null, response._closedReason)
4537
- : new ReactPromise("pending", null, null)),
4538
- chunks.set(id, chunk));
4601
+ : new ReactPromise("pending", null, null);
4602
+ chunks.set(id, chunk);
4603
+ }
4539
4604
  return chunk;
4540
4605
  }
4541
4606
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -4782,7 +4847,7 @@
4782
4847
  Error("Already initialized typed array.")
4783
4848
  )
4784
4849
  );
4785
- reference = response._formData.data.get(key).arrayBuffer();
4850
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
4786
4851
  if (initializingHandler) {
4787
4852
  var handler = initializingHandler;
4788
4853
  handler.deps++;
@@ -4826,15 +4891,17 @@
4826
4891
  var chunks = response._chunks;
4827
4892
  stream = new ReactPromise("fulfilled", stream, controller);
4828
4893
  chunks.set(id, stream);
4829
- response = response._formData.data.getAll(response._prefix + id);
4830
- for (id = 0; id < response.length; id++)
4831
- (chunks = response[id]),
4832
- "string" === typeof chunks &&
4833
- ("C" === chunks[0]
4894
+ chunks = response._prefix;
4895
+ response = response._formData.streamChunks;
4896
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
4897
+ if (void 0 !== id)
4898
+ for (response = 0; response < id.length; response++)
4899
+ (chunks = id[response]),
4900
+ "C" === chunks[0]
4834
4901
  ? controller.close(
4835
4902
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
4836
4903
  )
4837
- : controller.enqueueModel(chunks));
4904
+ : controller.enqueueModel(chunks);
4838
4905
  }
4839
4906
  function parseReadableStream(response, reference, type) {
4840
4907
  function enqueue(value) {
@@ -4999,7 +5066,14 @@
4999
5066
  });
5000
5067
  return iterator;
5001
5068
  }
5002
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
5069
+ function parseModelString(
5070
+ response,
5071
+ obj,
5072
+ key$jscomp$0,
5073
+ value,
5074
+ reference,
5075
+ arrayRoot
5076
+ ) {
5003
5077
  if ("$" === value[0]) {
5004
5078
  switch (value[1]) {
5005
5079
  case "$":
@@ -5019,7 +5093,7 @@
5019
5093
  response,
5020
5094
  arrayRoot,
5021
5095
  obj,
5022
- key,
5096
+ key$jscomp$0,
5023
5097
  null,
5024
5098
  loadServerReference$1
5025
5099
  )
@@ -5039,41 +5113,44 @@
5039
5113
  case "Q":
5040
5114
  return (
5041
5115
  (arrayRoot = value.slice(2)),
5042
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
5116
+ getOutlinedModel(
5117
+ response,
5118
+ arrayRoot,
5119
+ obj,
5120
+ key$jscomp$0,
5121
+ null,
5122
+ createMap
5123
+ )
5043
5124
  );
5044
5125
  case "W":
5045
5126
  return (
5046
5127
  (arrayRoot = value.slice(2)),
5047
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
5128
+ getOutlinedModel(
5129
+ response,
5130
+ arrayRoot,
5131
+ obj,
5132
+ key$jscomp$0,
5133
+ null,
5134
+ createSet
5135
+ )
5048
5136
  );
5049
5137
  case "K":
5050
- key = value.slice(2);
5051
- obj = response._prefix + "_";
5052
- key = obj + key + "_";
5053
- arrayRoot = new FormData();
5054
- for (response = response._formData; ; ) {
5055
- value = response;
5056
- reference = value.keys;
5057
- null === reference &&
5058
- ((reference = value.keys = Array.from(value.data.keys())),
5059
- (value.keyPointer = 0));
5060
- value = reference[value.keyPointer];
5061
- if (void 0 === value) break;
5062
- if (value.startsWith(key)) {
5063
- reference = response.data.getAll(value);
5064
- for (
5065
- var referencedFormDataKey = value.slice(key.length), i = 0;
5066
- i < reference.length;
5067
- i++
5068
- )
5069
- arrayRoot.append(referencedFormDataKey, reference[i]);
5070
- reference = response;
5071
- reference.data.delete(value);
5072
- reference.keyPointer++;
5073
- } else if (value.startsWith(obj)) break;
5074
- else response.keyPointer++;
5138
+ key$jscomp$0 = value.slice(2);
5139
+ obj = response._formData;
5140
+ response = response._prefix + "_" + key$jscomp$0 + "_";
5141
+ key$jscomp$0 = new FormData();
5142
+ arrayRoot = obj.referencedEntries;
5143
+ if (null !== arrayRoot) {
5144
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
5145
+ reference = arrayRoot[value];
5146
+ var key = reference[0];
5147
+ if (!key.startsWith(response)) break;
5148
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
5149
+ value++;
5150
+ }
5151
+ obj.keyPointer = value;
5075
5152
  }
5076
- return arrayRoot;
5153
+ return key$jscomp$0;
5077
5154
  case "i":
5078
5155
  return (
5079
5156
  (arrayRoot = value.slice(2)),
@@ -5081,7 +5158,7 @@
5081
5158
  response,
5082
5159
  arrayRoot,
5083
5160
  obj,
5084
- key,
5161
+ key$jscomp$0,
5085
5162
  null,
5086
5163
  extractIterator
5087
5164
  )
@@ -5116,7 +5193,7 @@
5116
5193
  ArrayBuffer,
5117
5194
  1,
5118
5195
  obj,
5119
- key,
5196
+ key$jscomp$0,
5120
5197
  arrayRoot
5121
5198
  );
5122
5199
  case "O":
@@ -5126,7 +5203,7 @@
5126
5203
  Int8Array,
5127
5204
  1,
5128
5205
  obj,
5129
- key,
5206
+ key$jscomp$0,
5130
5207
  arrayRoot
5131
5208
  );
5132
5209
  case "o":
@@ -5136,7 +5213,7 @@
5136
5213
  Uint8Array,
5137
5214
  1,
5138
5215
  obj,
5139
- key,
5216
+ key$jscomp$0,
5140
5217
  arrayRoot
5141
5218
  );
5142
5219
  case "U":
@@ -5146,7 +5223,7 @@
5146
5223
  Uint8ClampedArray,
5147
5224
  1,
5148
5225
  obj,
5149
- key,
5226
+ key$jscomp$0,
5150
5227
  arrayRoot
5151
5228
  );
5152
5229
  case "S":
@@ -5156,7 +5233,7 @@
5156
5233
  Int16Array,
5157
5234
  2,
5158
5235
  obj,
5159
- key,
5236
+ key$jscomp$0,
5160
5237
  arrayRoot
5161
5238
  );
5162
5239
  case "s":
@@ -5166,7 +5243,7 @@
5166
5243
  Uint16Array,
5167
5244
  2,
5168
5245
  obj,
5169
- key,
5246
+ key$jscomp$0,
5170
5247
  arrayRoot
5171
5248
  );
5172
5249
  case "L":
@@ -5176,7 +5253,7 @@
5176
5253
  Int32Array,
5177
5254
  4,
5178
5255
  obj,
5179
- key,
5256
+ key$jscomp$0,
5180
5257
  arrayRoot
5181
5258
  );
5182
5259
  case "l":
@@ -5186,7 +5263,7 @@
5186
5263
  Uint32Array,
5187
5264
  4,
5188
5265
  obj,
5189
- key,
5266
+ key$jscomp$0,
5190
5267
  arrayRoot
5191
5268
  );
5192
5269
  case "G":
@@ -5196,7 +5273,7 @@
5196
5273
  Float32Array,
5197
5274
  4,
5198
5275
  obj,
5199
- key,
5276
+ key$jscomp$0,
5200
5277
  arrayRoot
5201
5278
  );
5202
5279
  case "g":
@@ -5206,7 +5283,7 @@
5206
5283
  Float64Array,
5207
5284
  8,
5208
5285
  obj,
5209
- key,
5286
+ key$jscomp$0,
5210
5287
  arrayRoot
5211
5288
  );
5212
5289
  case "M":
@@ -5216,7 +5293,7 @@
5216
5293
  BigInt64Array,
5217
5294
  8,
5218
5295
  obj,
5219
- key,
5296
+ key$jscomp$0,
5220
5297
  arrayRoot
5221
5298
  );
5222
5299
  case "m":
@@ -5226,7 +5303,7 @@
5226
5303
  BigUint64Array,
5227
5304
  8,
5228
5305
  obj,
5229
- key,
5306
+ key$jscomp$0,
5230
5307
  arrayRoot
5231
5308
  );
5232
5309
  case "V":
@@ -5236,12 +5313,15 @@
5236
5313
  DataView,
5237
5314
  1,
5238
5315
  obj,
5239
- key,
5316
+ key$jscomp$0,
5240
5317
  arrayRoot
5241
5318
  );
5242
5319
  case "B":
5243
5320
  obj = parseInt(value.slice(2), 16);
5244
- response = response._formData.data.get(response._prefix + obj);
5321
+ response = getBackingBlob(
5322
+ response._formData,
5323
+ response._prefix + obj
5324
+ );
5245
5325
  if (!(response instanceof Blob))
5246
5326
  throw Error("Referenced Blob is not a Blob.");
5247
5327
  return response;
@@ -5259,7 +5339,7 @@
5259
5339
  response,
5260
5340
  value,
5261
5341
  obj,
5262
- key,
5342
+ key$jscomp$0,
5263
5343
  arrayRoot,
5264
5344
  createModel
5265
5345
  );
@@ -5278,11 +5358,20 @@
5278
5358
  : new FormData(),
5279
5359
  arraySizeLimit =
5280
5360
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
5281
- chunks = new Map();
5361
+ chunks = new Map(),
5362
+ backingStore = {
5363
+ prefix: formFieldPrefix,
5364
+ referencedEntries: null,
5365
+ keyPointer: 0,
5366
+ stringChunks: null,
5367
+ streamChunks: null,
5368
+ blobs: null
5369
+ };
5370
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
5282
5371
  return {
5283
5372
  _bundlerConfig: bundlerConfig,
5284
5373
  _prefix: formFieldPrefix,
5285
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
5374
+ _formData: backingStore,
5286
5375
  _chunks: chunks,
5287
5376
  _closed: !1,
5288
5377
  _closedReason: null,
@@ -5429,13 +5518,19 @@
5429
5518
  }
5430
5519
  var ReactDOM = require("react-dom"),
5431
5520
  React = require("react"),
5521
+ hasOwnProperty = Object.prototype.hasOwnProperty,
5432
5522
  channel = new MessageChannel(),
5433
5523
  taskQueue = [];
5434
5524
  channel.port1.onmessage = function () {
5435
5525
  var task = taskQueue.shift();
5436
5526
  task && task();
5437
5527
  };
5438
- var LocalPromise = Promise,
5528
+ var supportsArrayBufferDetached = hasOwnProperty.call(
5529
+ ArrayBuffer.prototype,
5530
+ "detached"
5531
+ ),
5532
+ didWarnAboutMissingArrayBufferDetached = !1,
5533
+ LocalPromise = Promise,
5439
5534
  scheduleMicrotask =
5440
5535
  "function" === typeof queueMicrotask
5441
5536
  ? queueMicrotask
@@ -5822,7 +5917,6 @@
5822
5917
  jsxPropsParents = new WeakMap(),
5823
5918
  jsxChildrenParents = new WeakMap(),
5824
5919
  CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"),
5825
- hasOwnProperty = Object.prototype.hasOwnProperty,
5826
5920
  doNotLimit = new WeakSet();
5827
5921
  "object" === typeof console &&
5828
5922
  null !== console &&