react-server-dom-webpack 19.0.0-rc-a26e3f403e-20240611 → 19.0.0-rc-dfd30974ab-20240613

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.
@@ -643,7 +643,6 @@ Chunk.prototype.then = function (resolve, reject) {
643
643
  break;
644
644
  case "pending":
645
645
  case "blocked":
646
- case "cyclic":
647
646
  resolve &&
648
647
  (null === this.value && (this.value = []), this.value.push(resolve));
649
648
  reject &&
@@ -666,7 +665,6 @@ function readChunk(chunk) {
666
665
  return chunk.value;
667
666
  case "pending":
668
667
  case "blocked":
669
- case "cyclic":
670
668
  throw chunk;
671
669
  default:
672
670
  throw chunk.reason;
@@ -685,7 +683,6 @@ function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
685
683
  break;
686
684
  case "pending":
687
685
  case "blocked":
688
- case "cyclic":
689
686
  if (chunk.value)
690
687
  for (var i = 0; i < resolveListeners.length; i++)
691
688
  chunk.value.push(resolveListeners[i]);
@@ -751,35 +748,35 @@ function resolveModuleChunk(chunk, value) {
751
748
  wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners));
752
749
  }
753
750
  }
754
- var initializingChunk = null,
755
- initializingChunkBlockedModel = null;
751
+ var initializingHandler = null;
756
752
  function initializeModelChunk(chunk) {
757
- var prevChunk = initializingChunk,
758
- prevBlocked = initializingChunkBlockedModel;
759
- initializingChunk = chunk;
760
- initializingChunkBlockedModel = null;
753
+ var prevHandler = initializingHandler;
754
+ initializingHandler = null;
761
755
  var resolvedModel = chunk.value;
762
- chunk.status = "cyclic";
756
+ chunk.status = "blocked";
763
757
  chunk.value = null;
764
758
  chunk.reason = null;
765
759
  try {
766
- var value = JSON.parse(resolvedModel, chunk._response._fromJSON);
767
- if (
768
- null !== initializingChunkBlockedModel &&
769
- 0 < initializingChunkBlockedModel.deps
770
- )
771
- (initializingChunkBlockedModel.value = value), (chunk.status = "blocked");
772
- else {
773
- var resolveListeners = chunk.value;
774
- chunk.status = "fulfilled";
775
- chunk.value = value;
776
- null !== resolveListeners && wakeChunk(resolveListeners, value);
760
+ var value = JSON.parse(resolvedModel, chunk._response._fromJSON),
761
+ resolveListeners = chunk.value;
762
+ null !== resolveListeners &&
763
+ ((chunk.value = null),
764
+ (chunk.reason = null),
765
+ wakeChunk(resolveListeners, value));
766
+ if (null !== initializingHandler) {
767
+ if (initializingHandler.errored) throw initializingHandler.value;
768
+ if (0 < initializingHandler.deps) {
769
+ initializingHandler.value = value;
770
+ initializingHandler.chunk = chunk;
771
+ return;
772
+ }
777
773
  }
774
+ chunk.status = "fulfilled";
775
+ chunk.value = value;
778
776
  } catch (error) {
779
777
  (chunk.status = "rejected"), (chunk.reason = error);
780
778
  } finally {
781
- (initializingChunk = prevChunk),
782
- (initializingChunkBlockedModel = prevBlocked);
779
+ initializingHandler = prevHandler;
783
780
  }
784
781
  }
785
782
  function initializeModuleChunk(chunk) {
@@ -809,46 +806,71 @@ function reportGlobalError(response, error) {
809
806
  "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
810
807
  });
811
808
  }
809
+ function createLazyChunkWrapper(chunk) {
810
+ return { $$typeof: REACT_LAZY_TYPE, _payload: chunk, _init: readChunk };
811
+ }
812
812
  function getChunk(response, id) {
813
813
  var chunks = response._chunks,
814
814
  chunk = chunks.get(id);
815
815
  chunk || ((chunk = createPendingChunk(response)), chunks.set(id, chunk));
816
816
  return chunk;
817
817
  }
818
- function createModelResolver(
819
- chunk,
818
+ function waitForReference(
819
+ referencedChunk,
820
820
  parentObject,
821
821
  key,
822
- cyclic,
823
822
  response,
824
823
  map,
825
824
  path
826
825
  ) {
827
- if (initializingChunkBlockedModel) {
828
- var blocked = initializingChunkBlockedModel;
829
- cyclic || blocked.deps++;
826
+ function fulfill(value) {
827
+ for (var i = 1; i < path.length; i++) {
828
+ for (; value.$$typeof === REACT_LAZY_TYPE; )
829
+ if (((value = value._payload), value === handler.chunk))
830
+ value = handler.value;
831
+ else if ("fulfilled" === value.status) value = value.value;
832
+ else {
833
+ path.splice(0, i - 1);
834
+ value.then(fulfill, reject);
835
+ return;
836
+ }
837
+ value = value[path[i]];
838
+ }
839
+ parentObject[key] = map(response, value);
840
+ "" === key && null === handler.value && (handler.value = parentObject[key]);
841
+ handler.deps--;
842
+ 0 === handler.deps &&
843
+ ((i = handler.chunk),
844
+ null !== i &&
845
+ "blocked" === i.status &&
846
+ ((value = i.value),
847
+ (i.status = "fulfilled"),
848
+ (i.value = handler.value),
849
+ null !== value && wakeChunk(value, handler.value)));
850
+ }
851
+ function reject(error) {
852
+ if (!handler.errored) {
853
+ handler.errored = !0;
854
+ handler.value = error;
855
+ var chunk = handler.chunk;
856
+ null !== chunk &&
857
+ "blocked" === chunk.status &&
858
+ triggerErrorOnChunk(chunk, error);
859
+ }
860
+ }
861
+ if (initializingHandler) {
862
+ var handler = initializingHandler;
863
+ handler.deps++;
830
864
  } else
831
- blocked = initializingChunkBlockedModel = {
832
- deps: cyclic ? 0 : 1,
833
- value: null
865
+ handler = initializingHandler = {
866
+ parent: null,
867
+ chunk: null,
868
+ value: null,
869
+ deps: 1,
870
+ errored: !1
834
871
  };
835
- return function (value) {
836
- for (var i = 1; i < path.length; i++) value = value[path[i]];
837
- parentObject[key] = map(response, value);
838
- "" === key && null === blocked.value && (blocked.value = parentObject[key]);
839
- blocked.deps--;
840
- 0 === blocked.deps &&
841
- "blocked" === chunk.status &&
842
- ((value = chunk.value),
843
- (chunk.status = "fulfilled"),
844
- (chunk.value = blocked.value),
845
- null !== value && wakeChunk(value, blocked.value));
846
- };
847
- }
848
- function createModelReject(chunk) {
849
- return function (error) {
850
- return triggerErrorOnChunk(chunk, error);
851
- };
872
+ referencedChunk.then(fulfill, reject);
873
+ return null;
852
874
  }
853
875
  function createServerReferenceProxy(response, metaData) {
854
876
  function proxy() {
@@ -885,23 +907,21 @@ function getOutlinedModel(response, reference, parentObject, key, map) {
885
907
  return map(response, parentObject);
886
908
  case "pending":
887
909
  case "blocked":
888
- case "cyclic":
889
- var parentChunk = initializingChunk;
890
- id.then(
891
- createModelResolver(
892
- parentChunk,
893
- parentObject,
894
- key,
895
- "cyclic" === id.status,
896
- response,
897
- map,
898
- reference
899
- ),
900
- createModelReject(parentChunk)
901
- );
902
- return null;
910
+ return waitForReference(id, parentObject, key, response, map, reference);
903
911
  default:
904
- throw id.reason;
912
+ return (
913
+ initializingHandler
914
+ ? ((initializingHandler.errored = !0),
915
+ (initializingHandler.value = id.reason))
916
+ : (initializingHandler = {
917
+ parent: null,
918
+ chunk: null,
919
+ value: id.reason,
920
+ deps: 0,
921
+ errored: !0
922
+ }),
923
+ null
924
+ );
905
925
  }
906
926
  }
907
927
  function createMap(response, model) {
@@ -927,7 +947,19 @@ function createModel(response, model) {
927
947
  }
928
948
  function parseModelString(response, parentObject, key, value) {
929
949
  if ("$" === value[0]) {
930
- if ("$" === value) return REACT_ELEMENT_TYPE;
950
+ if ("$" === value)
951
+ return (
952
+ null !== initializingHandler &&
953
+ "0" === key &&
954
+ (initializingHandler = {
955
+ parent: initializingHandler,
956
+ chunk: null,
957
+ value: null,
958
+ deps: 0,
959
+ errored: !1
960
+ }),
961
+ REACT_ELEMENT_TYPE
962
+ );
931
963
  switch (value[1]) {
932
964
  case "$":
933
965
  return value.slice(1);
@@ -935,7 +967,7 @@ function parseModelString(response, parentObject, key, value) {
935
967
  return (
936
968
  (parentObject = parseInt(value.slice(2), 16)),
937
969
  (response = getChunk(response, parentObject)),
938
- { $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
970
+ createLazyChunkWrapper(response)
939
971
  );
940
972
  case "@":
941
973
  if (2 === value.length) return new Promise(function () {});
@@ -1121,8 +1153,8 @@ function startReadableStream(response, id, type) {
1121
1153
  (previousBlockedChunk = chunk));
1122
1154
  } else {
1123
1155
  chunk = previousBlockedChunk;
1124
- var chunk$51 = createPendingChunk(response);
1125
- chunk$51.then(
1156
+ var chunk$52 = createPendingChunk(response);
1157
+ chunk$52.then(
1126
1158
  function (v) {
1127
1159
  return controller.enqueue(v);
1128
1160
  },
@@ -1130,10 +1162,10 @@ function startReadableStream(response, id, type) {
1130
1162
  return controller.error(e);
1131
1163
  }
1132
1164
  );
1133
- previousBlockedChunk = chunk$51;
1165
+ previousBlockedChunk = chunk$52;
1134
1166
  chunk.then(function () {
1135
- previousBlockedChunk === chunk$51 && (previousBlockedChunk = null);
1136
- resolveModelChunk(chunk$51, json);
1167
+ previousBlockedChunk === chunk$52 && (previousBlockedChunk = null);
1168
+ resolveModelChunk(chunk$52, json);
1137
1169
  });
1138
1170
  }
1139
1171
  },
@@ -1261,8 +1293,8 @@ function mergeBuffer(buffer, lastChunk) {
1261
1293
  for (var l = buffer.length, byteLength = lastChunk.length, i = 0; i < l; i++)
1262
1294
  byteLength += buffer[i].byteLength;
1263
1295
  byteLength = new Uint8Array(byteLength);
1264
- for (var i$52 = (i = 0); i$52 < l; i$52++) {
1265
- var chunk = buffer[i$52];
1296
+ for (var i$53 = (i = 0); i$53 < l; i$53++) {
1297
+ var chunk = buffer[i$53];
1266
1298
  byteLength.set(chunk, i);
1267
1299
  i += chunk.byteLength;
1268
1300
  }
@@ -1438,21 +1470,37 @@ function processFullRow(response, id, tag, buffer, chunk) {
1438
1470
  }
1439
1471
  function createFromJSONCallback(response) {
1440
1472
  return function (key, value) {
1441
- return "string" === typeof value
1442
- ? parseModelString(response, this, key, value)
1443
- : "object" === typeof value && null !== value
1444
- ? ((key =
1445
- value[0] === REACT_ELEMENT_TYPE
1446
- ? {
1447
- $$typeof: REACT_ELEMENT_TYPE,
1448
- type: value[1],
1449
- key: value[2],
1450
- ref: null,
1451
- props: value[3]
1452
- }
1453
- : value),
1454
- key)
1455
- : value;
1473
+ if ("string" === typeof value)
1474
+ return parseModelString(response, this, key, value);
1475
+ if ("object" === typeof value && null !== value) {
1476
+ if (value[0] === REACT_ELEMENT_TYPE) {
1477
+ if (
1478
+ ((key = {
1479
+ $$typeof: REACT_ELEMENT_TYPE,
1480
+ type: value[1],
1481
+ key: value[2],
1482
+ ref: null,
1483
+ props: value[3]
1484
+ }),
1485
+ null !== initializingHandler)
1486
+ )
1487
+ if (
1488
+ ((value = initializingHandler),
1489
+ (initializingHandler = value.parent),
1490
+ value.errored)
1491
+ )
1492
+ (key = new Chunk("rejected", null, value.value, response)),
1493
+ (key = createLazyChunkWrapper(key));
1494
+ else if (0 < value.deps) {
1495
+ var blockedChunk = new Chunk("blocked", null, null, response);
1496
+ value.value = key;
1497
+ value.chunk = blockedChunk;
1498
+ key = createLazyChunkWrapper(blockedChunk);
1499
+ }
1500
+ } else key = value;
1501
+ return key;
1502
+ }
1503
+ return value;
1456
1504
  };
1457
1505
  }
1458
1506
  function noServerCall() {