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.
@@ -45,31 +45,39 @@
45
45
  });
46
46
  }
47
47
  function writeChunk(destination, chunk) {
48
- if (0 !== chunk.byteLength)
49
- if (2048 < chunk.byteLength)
50
- 0 < writtenBytes &&
51
- (destination.enqueue(
52
- new Uint8Array(currentView.buffer, 0, writtenBytes)
48
+ if (0 === chunk.byteLength)
49
+ if (supportsArrayBufferDetached) {
50
+ if (chunk.buffer.detached)
51
+ throw Error(
52
+ "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()`."
53
+ );
54
+ } else
55
+ didWarnAboutMissingArrayBufferDetached ||
56
+ (console.error(
57
+ "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."
53
58
  ),
54
- (currentView = new Uint8Array(2048)),
55
- (writtenBytes = 0)),
56
- destination.enqueue(chunk);
57
- else {
58
- var allowableBytes = currentView.length - writtenBytes;
59
- allowableBytes < chunk.byteLength &&
60
- (0 === allowableBytes
61
- ? destination.enqueue(currentView)
62
- : (currentView.set(
63
- chunk.subarray(0, allowableBytes),
64
- writtenBytes
65
- ),
66
- destination.enqueue(currentView),
67
- (chunk = chunk.subarray(allowableBytes))),
68
- (currentView = new Uint8Array(2048)),
69
- (writtenBytes = 0));
70
- currentView.set(chunk, writtenBytes);
71
- writtenBytes += chunk.byteLength;
72
- }
59
+ (didWarnAboutMissingArrayBufferDetached = !0));
60
+ else if (2048 < chunk.byteLength)
61
+ 0 < writtenBytes &&
62
+ (destination.enqueue(
63
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
64
+ ),
65
+ (currentView = new Uint8Array(2048)),
66
+ (writtenBytes = 0)),
67
+ destination.enqueue(chunk);
68
+ else {
69
+ var allowableBytes = currentView.length - writtenBytes;
70
+ allowableBytes < chunk.byteLength &&
71
+ (0 === allowableBytes
72
+ ? destination.enqueue(currentView)
73
+ : (currentView.set(chunk.subarray(0, allowableBytes), writtenBytes),
74
+ destination.enqueue(currentView),
75
+ (chunk = chunk.subarray(allowableBytes))),
76
+ (currentView = new Uint8Array(2048)),
77
+ (writtenBytes = 0));
78
+ currentView.set(chunk, writtenBytes);
79
+ writtenBytes += chunk.byteLength;
80
+ }
73
81
  }
74
82
  function writeChunkAndReturn(destination, chunk) {
75
83
  writeChunk(destination, chunk);
@@ -2957,14 +2965,35 @@
2957
2965
  }
2958
2966
  function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
2959
2967
  debug ? request.pendingDebugChunks++ : request.pendingChunks++;
2960
- var buffer = new Uint8Array(
2961
- typedArray.buffer,
2962
- typedArray.byteOffset,
2963
- typedArray.byteLength
2964
- );
2965
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
2966
- buffer = typedArray.byteLength;
2967
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
2968
+ a: {
2969
+ var view = new Uint8Array(
2970
+ typedArray.buffer,
2971
+ typedArray.byteOffset,
2972
+ typedArray.byteLength
2973
+ );
2974
+ if (2048 < typedArray.byteLength) {
2975
+ if (
2976
+ 0 !== typedArray.byteOffset ||
2977
+ typedArray.byteLength !== typedArray.buffer.byteLength ||
2978
+ typedArray.buffer.resizable
2979
+ ) {
2980
+ typedArray = view.slice();
2981
+ break a;
2982
+ }
2983
+ if (!supportsArrayBufferDetached) {
2984
+ didWarnAboutMissingArrayBufferDetached ||
2985
+ (console.error(
2986
+ "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."
2987
+ ),
2988
+ (didWarnAboutMissingArrayBufferDetached = !0));
2989
+ typedArray = view.slice();
2990
+ break a;
2991
+ }
2992
+ }
2993
+ typedArray = view;
2994
+ }
2995
+ view = typedArray.byteLength;
2996
+ id = id.toString(16) + ":" + tag + view.toString(16) + ",";
2968
2997
  id = stringToChunk(id);
2969
2998
  debug
2970
2999
  ? request.completedDebugChunks.push(
@@ -4041,6 +4070,39 @@
4041
4070
  });
4042
4071
  enqueueFlush(request);
4043
4072
  }
4073
+ function appendBackingEntry(backingStore, value, key) {
4074
+ var prefix = backingStore.prefix;
4075
+ if (key.startsWith(prefix)) {
4076
+ switch (key[prefix.length]) {
4077
+ case "_":
4078
+ prefix = backingStore.referencedEntries;
4079
+ null === prefix && (prefix = backingStore.referencedEntries = []);
4080
+ prefix.push([key, value]);
4081
+ return;
4082
+ case "S":
4083
+ "string" === typeof value &&
4084
+ ((prefix = backingStore.streamChunks),
4085
+ null === prefix &&
4086
+ (prefix = backingStore.streamChunks = new Map()),
4087
+ (backingStore = prefix.get(key)),
4088
+ void 0 === backingStore
4089
+ ? prefix.set(key, [value])
4090
+ : backingStore.push(value));
4091
+ return;
4092
+ }
4093
+ "string" === typeof value
4094
+ ? ((prefix = backingStore.stringChunks),
4095
+ null === prefix && (prefix = backingStore.stringChunks = new Map()),
4096
+ prefix.set(key, value))
4097
+ : ((prefix = backingStore.blobs),
4098
+ null === prefix && (prefix = backingStore.blobs = new Map()),
4099
+ prefix.set(key, value));
4100
+ }
4101
+ }
4102
+ function getBackingBlob(backingStore, key) {
4103
+ backingStore = backingStore.blobs;
4104
+ return null === backingStore ? void 0 : backingStore.get(key);
4105
+ }
4044
4106
  function ReactPromise(status, value, reason) {
4045
4107
  this.status = status;
4046
4108
  this.value = value;
@@ -4377,15 +4439,18 @@
4377
4439
  function getChunk(response, id) {
4378
4440
  var chunks = response._chunks,
4379
4441
  chunk = chunks.get(id);
4380
- chunk ||
4381
- ((chunk = response._formData.data.get(response._prefix + id)),
4382
- (chunk =
4442
+ if (!chunk) {
4443
+ chunk = response._prefix;
4444
+ var stringChunks = response._formData.stringChunks;
4445
+ chunk = null === stringChunks ? void 0 : stringChunks.get(chunk + id);
4446
+ chunk =
4383
4447
  "string" === typeof chunk
4384
4448
  ? createResolvedModelChunk(response, chunk, id)
4385
4449
  : response._closed
4386
4450
  ? new ReactPromise("rejected", null, response._closedReason)
4387
- : new ReactPromise("pending", null, null)),
4388
- chunks.set(id, chunk));
4451
+ : new ReactPromise("pending", null, null);
4452
+ chunks.set(id, chunk);
4453
+ }
4389
4454
  return chunk;
4390
4455
  }
4391
4456
  function fulfillReference(response, reference, value, arrayRoot) {
@@ -4632,7 +4697,7 @@
4632
4697
  Error("Already initialized typed array.")
4633
4698
  )
4634
4699
  );
4635
- reference = response._formData.data.get(key).arrayBuffer();
4700
+ reference = getBackingBlob(response._formData, key).arrayBuffer();
4636
4701
  if (initializingHandler) {
4637
4702
  var handler = initializingHandler;
4638
4703
  handler.deps++;
@@ -4676,15 +4741,17 @@
4676
4741
  var chunks = response._chunks;
4677
4742
  stream = new ReactPromise("fulfilled", stream, controller);
4678
4743
  chunks.set(id, stream);
4679
- response = response._formData.data.getAll(response._prefix + id);
4680
- for (id = 0; id < response.length; id++)
4681
- (chunks = response[id]),
4682
- "string" === typeof chunks &&
4683
- ("C" === chunks[0]
4744
+ chunks = response._prefix;
4745
+ response = response._formData.streamChunks;
4746
+ id = null === response ? void 0 : response.get(chunks + "S" + id);
4747
+ if (void 0 !== id)
4748
+ for (response = 0; response < id.length; response++)
4749
+ (chunks = id[response]),
4750
+ "C" === chunks[0]
4684
4751
  ? controller.close(
4685
4752
  "C" === chunks ? '"$undefined"' : chunks.slice(1)
4686
4753
  )
4687
- : controller.enqueueModel(chunks));
4754
+ : controller.enqueueModel(chunks);
4688
4755
  }
4689
4756
  function parseReadableStream(response, reference, type) {
4690
4757
  function enqueue(value) {
@@ -4849,7 +4916,14 @@
4849
4916
  });
4850
4917
  return iterator;
4851
4918
  }
4852
- function parseModelString(response, obj, key, value, reference, arrayRoot) {
4919
+ function parseModelString(
4920
+ response,
4921
+ obj,
4922
+ key$jscomp$0,
4923
+ value,
4924
+ reference,
4925
+ arrayRoot
4926
+ ) {
4853
4927
  if ("$" === value[0]) {
4854
4928
  switch (value[1]) {
4855
4929
  case "$":
@@ -4869,7 +4943,7 @@
4869
4943
  response,
4870
4944
  arrayRoot,
4871
4945
  obj,
4872
- key,
4946
+ key$jscomp$0,
4873
4947
  null,
4874
4948
  loadServerReference$1
4875
4949
  )
@@ -4889,41 +4963,44 @@
4889
4963
  case "Q":
4890
4964
  return (
4891
4965
  (arrayRoot = value.slice(2)),
4892
- getOutlinedModel(response, arrayRoot, obj, key, null, createMap)
4966
+ getOutlinedModel(
4967
+ response,
4968
+ arrayRoot,
4969
+ obj,
4970
+ key$jscomp$0,
4971
+ null,
4972
+ createMap
4973
+ )
4893
4974
  );
4894
4975
  case "W":
4895
4976
  return (
4896
4977
  (arrayRoot = value.slice(2)),
4897
- getOutlinedModel(response, arrayRoot, obj, key, null, createSet)
4978
+ getOutlinedModel(
4979
+ response,
4980
+ arrayRoot,
4981
+ obj,
4982
+ key$jscomp$0,
4983
+ null,
4984
+ createSet
4985
+ )
4898
4986
  );
4899
4987
  case "K":
4900
- key = value.slice(2);
4901
- obj = response._prefix + "_";
4902
- key = obj + key + "_";
4903
- arrayRoot = new FormData();
4904
- for (response = response._formData; ; ) {
4905
- value = response;
4906
- reference = value.keys;
4907
- null === reference &&
4908
- ((reference = value.keys = Array.from(value.data.keys())),
4909
- (value.keyPointer = 0));
4910
- value = reference[value.keyPointer];
4911
- if (void 0 === value) break;
4912
- if (value.startsWith(key)) {
4913
- reference = response.data.getAll(value);
4914
- for (
4915
- var referencedFormDataKey = value.slice(key.length), i = 0;
4916
- i < reference.length;
4917
- i++
4918
- )
4919
- arrayRoot.append(referencedFormDataKey, reference[i]);
4920
- reference = response;
4921
- reference.data.delete(value);
4922
- reference.keyPointer++;
4923
- } else if (value.startsWith(obj)) break;
4924
- else response.keyPointer++;
4988
+ key$jscomp$0 = value.slice(2);
4989
+ obj = response._formData;
4990
+ response = response._prefix + "_" + key$jscomp$0 + "_";
4991
+ key$jscomp$0 = new FormData();
4992
+ arrayRoot = obj.referencedEntries;
4993
+ if (null !== arrayRoot) {
4994
+ for (value = obj.keyPointer; value < arrayRoot.length; ) {
4995
+ reference = arrayRoot[value];
4996
+ var key = reference[0];
4997
+ if (!key.startsWith(response)) break;
4998
+ key$jscomp$0.append(key.slice(response.length), reference[1]);
4999
+ value++;
5000
+ }
5001
+ obj.keyPointer = value;
4925
5002
  }
4926
- return arrayRoot;
5003
+ return key$jscomp$0;
4927
5004
  case "i":
4928
5005
  return (
4929
5006
  (arrayRoot = value.slice(2)),
@@ -4931,7 +5008,7 @@
4931
5008
  response,
4932
5009
  arrayRoot,
4933
5010
  obj,
4934
- key,
5011
+ key$jscomp$0,
4935
5012
  null,
4936
5013
  extractIterator
4937
5014
  )
@@ -4966,7 +5043,7 @@
4966
5043
  ArrayBuffer,
4967
5044
  1,
4968
5045
  obj,
4969
- key,
5046
+ key$jscomp$0,
4970
5047
  arrayRoot
4971
5048
  );
4972
5049
  case "O":
@@ -4976,7 +5053,7 @@
4976
5053
  Int8Array,
4977
5054
  1,
4978
5055
  obj,
4979
- key,
5056
+ key$jscomp$0,
4980
5057
  arrayRoot
4981
5058
  );
4982
5059
  case "o":
@@ -4986,7 +5063,7 @@
4986
5063
  Uint8Array,
4987
5064
  1,
4988
5065
  obj,
4989
- key,
5066
+ key$jscomp$0,
4990
5067
  arrayRoot
4991
5068
  );
4992
5069
  case "U":
@@ -4996,7 +5073,7 @@
4996
5073
  Uint8ClampedArray,
4997
5074
  1,
4998
5075
  obj,
4999
- key,
5076
+ key$jscomp$0,
5000
5077
  arrayRoot
5001
5078
  );
5002
5079
  case "S":
@@ -5006,7 +5083,7 @@
5006
5083
  Int16Array,
5007
5084
  2,
5008
5085
  obj,
5009
- key,
5086
+ key$jscomp$0,
5010
5087
  arrayRoot
5011
5088
  );
5012
5089
  case "s":
@@ -5016,7 +5093,7 @@
5016
5093
  Uint16Array,
5017
5094
  2,
5018
5095
  obj,
5019
- key,
5096
+ key$jscomp$0,
5020
5097
  arrayRoot
5021
5098
  );
5022
5099
  case "L":
@@ -5026,7 +5103,7 @@
5026
5103
  Int32Array,
5027
5104
  4,
5028
5105
  obj,
5029
- key,
5106
+ key$jscomp$0,
5030
5107
  arrayRoot
5031
5108
  );
5032
5109
  case "l":
@@ -5036,7 +5113,7 @@
5036
5113
  Uint32Array,
5037
5114
  4,
5038
5115
  obj,
5039
- key,
5116
+ key$jscomp$0,
5040
5117
  arrayRoot
5041
5118
  );
5042
5119
  case "G":
@@ -5046,7 +5123,7 @@
5046
5123
  Float32Array,
5047
5124
  4,
5048
5125
  obj,
5049
- key,
5126
+ key$jscomp$0,
5050
5127
  arrayRoot
5051
5128
  );
5052
5129
  case "g":
@@ -5056,7 +5133,7 @@
5056
5133
  Float64Array,
5057
5134
  8,
5058
5135
  obj,
5059
- key,
5136
+ key$jscomp$0,
5060
5137
  arrayRoot
5061
5138
  );
5062
5139
  case "M":
@@ -5066,7 +5143,7 @@
5066
5143
  BigInt64Array,
5067
5144
  8,
5068
5145
  obj,
5069
- key,
5146
+ key$jscomp$0,
5070
5147
  arrayRoot
5071
5148
  );
5072
5149
  case "m":
@@ -5076,7 +5153,7 @@
5076
5153
  BigUint64Array,
5077
5154
  8,
5078
5155
  obj,
5079
- key,
5156
+ key$jscomp$0,
5080
5157
  arrayRoot
5081
5158
  );
5082
5159
  case "V":
@@ -5086,12 +5163,15 @@
5086
5163
  DataView,
5087
5164
  1,
5088
5165
  obj,
5089
- key,
5166
+ key$jscomp$0,
5090
5167
  arrayRoot
5091
5168
  );
5092
5169
  case "B":
5093
5170
  obj = parseInt(value.slice(2), 16);
5094
- response = response._formData.data.get(response._prefix + obj);
5171
+ response = getBackingBlob(
5172
+ response._formData,
5173
+ response._prefix + obj
5174
+ );
5095
5175
  if (!(response instanceof Blob))
5096
5176
  throw Error("Referenced Blob is not a Blob.");
5097
5177
  return response;
@@ -5109,7 +5189,7 @@
5109
5189
  response,
5110
5190
  value,
5111
5191
  obj,
5112
- key,
5192
+ key$jscomp$0,
5113
5193
  arrayRoot,
5114
5194
  createModel
5115
5195
  );
@@ -5128,11 +5208,20 @@
5128
5208
  : new FormData(),
5129
5209
  arraySizeLimit =
5130
5210
  4 < arguments.length && void 0 !== arguments[4] ? arguments[4] : 1e6,
5131
- chunks = new Map();
5211
+ chunks = new Map(),
5212
+ backingStore = {
5213
+ prefix: formFieldPrefix,
5214
+ referencedEntries: null,
5215
+ keyPointer: 0,
5216
+ stringChunks: null,
5217
+ streamChunks: null,
5218
+ blobs: null
5219
+ };
5220
+ backingFormData.forEach(appendBackingEntry.bind(null, backingStore));
5132
5221
  return {
5133
5222
  _bundlerConfig: bundlerConfig,
5134
5223
  _prefix: formFieldPrefix,
5135
- _formData: { data: backingFormData, keyPointer: -1, keys: null },
5224
+ _formData: backingStore,
5136
5225
  _chunks: chunks,
5137
5226
  _closed: !1,
5138
5227
  _closedReason: null,
@@ -5334,7 +5423,12 @@
5334
5423
  var task = taskQueue.shift();
5335
5424
  task && task();
5336
5425
  };
5337
- var LocalPromise = Promise,
5426
+ var supportsArrayBufferDetached = hasOwnProperty.call(
5427
+ ArrayBuffer.prototype,
5428
+ "detached"
5429
+ ),
5430
+ didWarnAboutMissingArrayBufferDetached = !1,
5431
+ LocalPromise = Promise,
5338
5432
  scheduleMicrotask =
5339
5433
  "function" === typeof queueMicrotask
5340
5434
  ? queueMicrotask