react-server-dom-webpack 19.0.0-rc-a26e3f403e-20240611 → 19.0.0-rc-f3e09d6328-20240612

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