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.
@@ -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(
@@ -4265,13 +4295,38 @@
4265
4295
  if (hasOwnProperty.call(moduleExports, metadata[2]))
4266
4296
  return moduleExports[metadata[2]];
4267
4297
  }
4268
- function appendBackingEntry(backingStore, key, value) {
4269
- backingStore.data.append(key, value);
4270
- value = backingStore.keys;
4271
- null === value
4272
- ? ((backingStore.keys = Array.from(backingStore.data.keys())),
4273
- (backingStore.keyPointer = 0))
4274
- : value.push(key);
4298
+ function appendBackingEntry(backingStore, value, key) {
4299
+ var prefix = backingStore.prefix;
4300
+ if (key.startsWith(prefix)) {
4301
+ switch (key[prefix.length]) {
4302
+ case "_":
4303
+ prefix = backingStore.referencedEntries;
4304
+ null === prefix && (prefix = backingStore.referencedEntries = []);
4305
+ prefix.push([key, value]);
4306
+ return;
4307
+ case "S":
4308
+ "string" === typeof value &&
4309
+ ((prefix = backingStore.streamChunks),
4310
+ null === prefix &&
4311
+ (prefix = backingStore.streamChunks = new Map()),
4312
+ (backingStore = prefix.get(key)),
4313
+ void 0 === backingStore
4314
+ ? prefix.set(key, [value])
4315
+ : backingStore.push(value));
4316
+ return;
4317
+ }
4318
+ "string" === typeof value
4319
+ ? ((prefix = backingStore.stringChunks),
4320
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
4321
+ prefix.set(key, value))
4322
+ : ((prefix = backingStore.blobs),
4323
+ null === prefix && (prefix = backingStore.blobs = new Map()),
4324
+ prefix.set(key, value));
4325
+ }
4326
+ }
4327
+ function getBackingBlob(backingStore, key) {
4328
+ backingStore = backingStore.blobs;
4329
+ return null === backingStore ? void 0 : backingStore.get(key);
4275
4330
  }
4276
4331
  function ReactPromise(status, value, reason) {
4277
4332
  this.status = status;
@@ -4609,15 +4664,18 @@
4609
4664
  function getChunk(response, id) {
4610
4665
  var chunks = response._chunks,
4611
4666
  chunk = chunks.get(id);
4612
- chunk ||
4613
- ((chunk = response._formData.data.get(response._prefix + id)),
4614
- (chunk =
4667
+ if (!chunk) {
4668
+ chunk = response._prefix;
4669
+ var stringChunks = response._formData.stringChunks;
4670
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
4671
+ chunk =
4615
4672
  "string" === typeof chunk
4616
4673
  ? createResolvedModelChunk(response, chunk, id)
4617
4674
  : response._closed
4618
4675
  ? new ReactPromise("rejected", null, response._closedReason)
4619
- : new ReactPromise("pending", null, null)),
4620
- chunks.set(id, chunk));
4676
+ : new ReactPromise("pending", null, null);
4677
+ chunks.set(id, chunk);
4678
+ }
4621
4679
  return chunk;
4622
4680
  }
4623
4681
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -4864,7 +4922,7 @@
4864
4922
  Error("Already initialized typed array.")
4865
4923
  )
4866
4924
  );
4867
- reference = response._formData.data.get(key).arrayBuffer();
4925
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
4868
4926
  if (initializingHandler) {
4869
4927
  var handler = initializingHandler;
4870
4928
  handler.deps++;
@@ -4908,15 +4966,17 @@
4908
4966
  var chunks = response._chunks;
4909
4967
  stream = new ReactPromise("fulfilled", stream, controller);
4910
4968
  chunks.set(id, stream);
4911
- response = response._formData.data.getAll(response._prefix + id);
4912
- for (id = 0; id < response.length; id++)
4913
- (chunks = response[id]),
4914
- "string" === typeof chunks &&
4915
- ("C" === chunks[0]
4969
+ chunks = response._prefix;
4970
+ response = response._formData.streamChunks;
4971
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
4972
+ if (void 0 !== id)
4973
+ for (response = 0; response < id.length; response++)
4974
+ (chunks = id[response]),
4975
+ "C" === chunks[0]
4916
4976
  ? controller.close(
4917
4977
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
4918
4978
  )
4919
- : controller.enqueueModel(chunks));
4979
+ : controller.enqueueModel(chunks);
4920
4980
  }
4921
4981
  function parseReadableStream(response, reference, type) {
4922
4982
  function enqueue(value) {
@@ -5081,7 +5141,14 @@
5081
5141
  });
5082
5142
  return iterator;
5083
5143
  }
5084
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
5144
+ function parseModelString(
5145
+ response,
5146
+ obj,
5147
+ key$jscomp$0,
5148
+ value,
5149
+ reference,
5150
+ arrayRoot
5151
+ ) {
5085
5152
  if ("$" === value[0]) {
5086
5153
  switch (value[1]) {
5087
5154
  case "$":
@@ -5101,7 +5168,7 @@
5101
5168
  response,
5102
5169
  arrayRoot,
5103
5170
  obj,
5104
- key,
5171
+ key$jscomp$0,
5105
5172
  null,
5106
5173
  loadServerReference$1
5107
5174
  )
@@ -5121,41 +5188,44 @@
5121
5188
  case "Q":
5122
5189
  return (
5123
5190
  (arrayRoot = value.slice(2)),
5124
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
5191
+ getOutlinedModel(
5192
+ response,
5193
+ arrayRoot,
5194
+ obj,
5195
+ key$jscomp$0,
5196
+ null,
5197
+ createMap
5198
+ )
5125
5199
  );
5126
5200
  case "W":
5127
5201
  return (
5128
5202
  (arrayRoot = value.slice(2)),
5129
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
5203
+ getOutlinedModel(
5204
+ response,
5205
+ arrayRoot,
5206
+ obj,
5207
+ key$jscomp$0,
5208
+ null,
5209
+ createSet
5210
+ )
5130
5211
  );
5131
5212
  case "K":
5132
- key = value.slice(2);
5133
- obj = response._prefix + "_";
5134
- key = obj + key + "_";
5135
- arrayRoot = new FormData();
5136
- for (response = response._formData; ; ) {
5137
- value = response;
5138
- reference = value.keys;
5139
- null === reference &&
5140
- ((reference = value.keys = Array.from(value.data.keys())),
5141
- (value.keyPointer = 0));
5142
- value = reference[value.keyPointer];
5143
- if (void 0 === value) break;
5144
- if (value.startsWith(key)) {
5145
- reference = response.data.getAll(value);
5146
- for (
5147
- var referencedFormDataKey = value.slice(key.length), i = 0;
5148
- i < reference.length;
5149
- i++
5150
- )
5151
- arrayRoot.append(referencedFormDataKey, reference[i]);
5152
- reference = response;
5153
- reference.data.delete(value);
5154
- reference.keyPointer++;
5155
- } else if (value.startsWith(obj)) break;
5156
- else response.keyPointer++;
5213
+ key$jscomp$0 = value.slice(2);
5214
+ obj = response._formData;
5215
+ response = response._prefix + "_" + key$jscomp$0 + "_";
5216
+ key$jscomp$0 = new FormData();
5217
+ arrayRoot = obj.referencedEntries;
5218
+ if (null !== arrayRoot) {
5219
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
5220
+ reference = arrayRoot[value];
5221
+ var key = reference[0];
5222
+ if (!key.startsWith(response)) break;
5223
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
5224
+ value++;
5225
+ }
5226
+ obj.keyPointer = value;
5157
5227
  }
5158
- return arrayRoot;
5228
+ return key$jscomp$0;
5159
5229
  case "i":
5160
5230
  return (
5161
5231
  (arrayRoot = value.slice(2)),
@@ -5163,7 +5233,7 @@
5163
5233
  response,
5164
5234
  arrayRoot,
5165
5235
  obj,
5166
- key,
5236
+ key$jscomp$0,
5167
5237
  null,
5168
5238
  extractIterator
5169
5239
  )
@@ -5198,7 +5268,7 @@
5198
5268
  ArrayBuffer,
5199
5269
  1,
5200
5270
  obj,
5201
- key,
5271
+ key$jscomp$0,
5202
5272
  arrayRoot
5203
5273
  );
5204
5274
  case "O":
@@ -5208,7 +5278,7 @@
5208
5278
  Int8Array,
5209
5279
  1,
5210
5280
  obj,
5211
- key,
5281
+ key$jscomp$0,
5212
5282
  arrayRoot
5213
5283
  );
5214
5284
  case "o":
@@ -5218,7 +5288,7 @@
5218
5288
  Uint8Array,
5219
5289
  1,
5220
5290
  obj,
5221
- key,
5291
+ key$jscomp$0,
5222
5292
  arrayRoot
5223
5293
  );
5224
5294
  case "U":
@@ -5228,7 +5298,7 @@
5228
5298
  Uint8ClampedArray,
5229
5299
  1,
5230
5300
  obj,
5231
- key,
5301
+ key$jscomp$0,
5232
5302
  arrayRoot
5233
5303
  );
5234
5304
  case "S":
@@ -5238,7 +5308,7 @@
5238
5308
  Int16Array,
5239
5309
  2,
5240
5310
  obj,
5241
- key,
5311
+ key$jscomp$0,
5242
5312
  arrayRoot
5243
5313
  );
5244
5314
  case "s":
@@ -5248,7 +5318,7 @@
5248
5318
  Uint16Array,
5249
5319
  2,
5250
5320
  obj,
5251
- key,
5321
+ key$jscomp$0,
5252
5322
  arrayRoot
5253
5323
  );
5254
5324
  case "L":
@@ -5258,7 +5328,7 @@
5258
5328
  Int32Array,
5259
5329
  4,
5260
5330
  obj,
5261
- key,
5331
+ key$jscomp$0,
5262
5332
  arrayRoot
5263
5333
  );
5264
5334
  case "l":
@@ -5268,7 +5338,7 @@
5268
5338
  Uint32Array,
5269
5339
  4,
5270
5340
  obj,
5271
- key,
5341
+ key$jscomp$0,
5272
5342
  arrayRoot
5273
5343
  );
5274
5344
  case "G":
@@ -5278,7 +5348,7 @@
5278
5348
  Float32Array,
5279
5349
  4,
5280
5350
  obj,
5281
- key,
5351
+ key$jscomp$0,
5282
5352
  arrayRoot
5283
5353
  );
5284
5354
  case "g":
@@ -5288,7 +5358,7 @@
5288
5358
  Float64Array,
5289
5359
  8,
5290
5360
  obj,
5291
- key,
5361
+ key$jscomp$0,
5292
5362
  arrayRoot
5293
5363
  );
5294
5364
  case "M":
@@ -5298,7 +5368,7 @@
5298
5368
  BigInt64Array,
5299
5369
  8,
5300
5370
  obj,
5301
- key,
5371
+ key$jscomp$0,
5302
5372
  arrayRoot
5303
5373
  );
5304
5374
  case "m":
@@ -5308,7 +5378,7 @@
5308
5378
  BigUint64Array,
5309
5379
  8,
5310
5380
  obj,
5311
- key,
5381
+ key$jscomp$0,
5312
5382
  arrayRoot
5313
5383
  );
5314
5384
  case "V":
@@ -5318,12 +5388,15 @@
5318
5388
  DataView,
5319
5389
  1,
5320
5390
  obj,
5321
- key,
5391
+ key$jscomp$0,
5322
5392
  arrayRoot
5323
5393
  );
5324
5394
  case "B":
5325
5395
  obj = parseInt(value.slice(2), 16);
5326
- response = response._formData.data.get(response._prefix + obj);
5396
+ response = getBackingBlob(
5397
+ response._formData,
5398
+ response._prefix + obj
5399
+ );
5327
5400
  if (!(response instanceof Blob))
5328
5401
  throw Error("Referenced Blob is not a Blob.");
5329
5402
  return response;
@@ -5341,7 +5414,7 @@
5341
5414
  response,
5342
5415
  value,
5343
5416
  obj,
5344
- key,
5417
+ key$jscomp$0,
5345
5418
  arrayRoot,
5346
5419
  createModel
5347
5420
  );
@@ -5360,11 +5433,20 @@
5360
5433
  : new FormData(),
5361
5434
  arraySizeLimit =
5362
5435
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
5363
- chunks = new Map();
5436
+ chunks = new Map(),
5437
+ backingStore = {
5438
+ prefix: formFieldPrefix,
5439
+ referencedEntries: null,
5440
+ keyPointer: 0,
5441
+ stringChunks: null,
5442
+ streamChunks: null,
5443
+ blobs: null
5444
+ };
5445
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
5364
5446
  return {
5365
5447
  _bundlerConfig: bundlerConfig,
5366
5448
  _prefix: formFieldPrefix,
5367
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
5449
+ _formData: backingStore,
5368
5450
  _chunks: chunks,
5369
5451
  _closed: !1,
5370
5452
  _closedReason: null,
@@ -5525,6 +5607,12 @@
5525
5607
  MAYBE_ITERATOR_SYMBOL = Symbol.iterator,
5526
5608
  ASYNC_ITERATOR = Symbol.asyncIterator,
5527
5609
  REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key"),
5610
+ hasOwnProperty = Object.prototype.hasOwnProperty,
5611
+ supportsArrayBufferDetached = hasOwnProperty.call(
5612
+ ArrayBuffer.prototype,
5613
+ "detached"
5614
+ ),
5615
+ didWarnAboutMissingArrayBufferDetached = !1,
5528
5616
  LocalPromise = Promise,
5529
5617
  scheduleMicrotask =
5530
5618
  "function" === typeof queueMicrotask
@@ -5904,7 +5992,6 @@
5904
5992
  jsxPropsParents = new WeakMap(),
5905
5993
  jsxChildrenParents = new WeakMap(),
5906
5994
  CLIENT_REFERENCE_TAG = Symbol.for("react.client.reference"),
5907
- hasOwnProperty = Object.prototype.hasOwnProperty,
5908
5995
  doNotLimit = new WeakSet();
5909
5996
  "object" === typeof console &&
5910
5997
  null !== console &&
@@ -6091,20 +6178,40 @@
6091
6178
  function progress(entry) {
6092
6179
  if (entry.done) close(response$jscomp$0);
6093
6180
  else {
6094
- entry = entry.value;
6095
- var name = entry[0];
6096
- entry = entry[1];
6097
- if ("string" === typeof entry) {
6098
- var response = response$jscomp$0;
6099
- appendBackingEntry(response._formData, name, entry);
6100
- var prefix = response._prefix;
6101
- if (name.startsWith(prefix)) {
6102
- var chunks = response._chunks;
6103
- name = +name.slice(prefix.length);
6104
- (chunks = chunks.get(name)) &&
6105
- resolveModelChunk(response, chunks, entry, name);
6181
+ var _entry$value = entry.value;
6182
+ entry = _entry$value[0];
6183
+ _entry$value = _entry$value[1];
6184
+ if ("string" === typeof _entry$value)
6185
+ a: {
6186
+ var response = response$jscomp$0,
6187
+ prefix = response._prefix;
6188
+ if (entry.startsWith(prefix)) {
6189
+ var chunks = response._chunks;
6190
+ if ("S" === entry[prefix.length]) {
6191
+ if (
6192
+ entry.length > prefix.length + 1 &&
6193
+ ((prefix = +entry.slice(prefix.length + 1)),
6194
+ (chunks = chunks.get(prefix)))
6195
+ ) {
6196
+ resolveModelChunk(response, chunks, _entry$value, prefix);
6197
+ break a;
6198
+ }
6199
+ } else if (
6200
+ ((prefix = +entry.slice(prefix.length)),
6201
+ (chunks = chunks.get(prefix)))
6202
+ ) {
6203
+ resolveModelChunk(response, chunks, _entry$value, prefix);
6204
+ break a;
6205
+ }
6206
+ }
6207
+ appendBackingEntry(response._formData, _entry$value, entry);
6106
6208
  }
6107
- } else appendBackingEntry(response$jscomp$0._formData, name, entry);
6209
+ else
6210
+ appendBackingEntry(
6211
+ response$jscomp$0._formData,
6212
+ _entry$value,
6213
+ entry
6214
+ );
6108
6215
  iterator.next().then(progress, error);
6109
6216
  }
6110
6217
  }