react-server-dom-webpack 19.0.0-rc-6230622a1a-20240610 → 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.
@@ -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 () {});
@@ -1013,7 +1045,7 @@ function missingCall() {
1013
1045
  'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.'
1014
1046
  );
1015
1047
  }
1016
- function createResponse(
1048
+ function ResponseInstance(
1017
1049
  bundlerConfig,
1018
1050
  moduleLoading,
1019
1051
  callServer,
@@ -1022,24 +1054,18 @@ function createResponse(
1022
1054
  temporaryReferences
1023
1055
  ) {
1024
1056
  var chunks = new Map();
1025
- bundlerConfig = {
1026
- _bundlerConfig: bundlerConfig,
1027
- _moduleLoading: moduleLoading,
1028
- _callServer: void 0 !== callServer ? callServer : missingCall,
1029
- _encodeFormAction: encodeFormAction,
1030
- _nonce: nonce,
1031
- _chunks: chunks,
1032
- _stringDecoder: new util.TextDecoder(),
1033
- _fromJSON: null,
1034
- _rowState: 0,
1035
- _rowID: 0,
1036
- _rowTag: 0,
1037
- _rowLength: 0,
1038
- _buffer: [],
1039
- _tempRefs: temporaryReferences
1040
- };
1041
- bundlerConfig._fromJSON = createFromJSONCallback(bundlerConfig);
1042
- return bundlerConfig;
1057
+ this._bundlerConfig = bundlerConfig;
1058
+ this._moduleLoading = moduleLoading;
1059
+ this._callServer = void 0 !== callServer ? callServer : missingCall;
1060
+ this._encodeFormAction = encodeFormAction;
1061
+ this._nonce = nonce;
1062
+ this._chunks = chunks;
1063
+ this._stringDecoder = new util.TextDecoder();
1064
+ this._fromJSON = null;
1065
+ this._rowLength = this._rowTag = this._rowID = this._rowState = 0;
1066
+ this._buffer = [];
1067
+ this._tempRefs = temporaryReferences;
1068
+ this._fromJSON = createFromJSONCallback(this);
1043
1069
  }
1044
1070
  function resolveBuffer(response, id, buffer) {
1045
1071
  var chunks = response._chunks,
@@ -1127,8 +1153,8 @@ function startReadableStream(response, id, type) {
1127
1153
  (previousBlockedChunk = chunk));
1128
1154
  } else {
1129
1155
  chunk = previousBlockedChunk;
1130
- var chunk$51 = createPendingChunk(response);
1131
- chunk$51.then(
1156
+ var chunk$52 = createPendingChunk(response);
1157
+ chunk$52.then(
1132
1158
  function (v) {
1133
1159
  return controller.enqueue(v);
1134
1160
  },
@@ -1136,10 +1162,10 @@ function startReadableStream(response, id, type) {
1136
1162
  return controller.error(e);
1137
1163
  }
1138
1164
  );
1139
- previousBlockedChunk = chunk$51;
1165
+ previousBlockedChunk = chunk$52;
1140
1166
  chunk.then(function () {
1141
- previousBlockedChunk === chunk$51 && (previousBlockedChunk = null);
1142
- resolveModelChunk(chunk$51, json);
1167
+ previousBlockedChunk === chunk$52 && (previousBlockedChunk = null);
1168
+ resolveModelChunk(chunk$52, json);
1143
1169
  });
1144
1170
  }
1145
1171
  },
@@ -1267,8 +1293,8 @@ function mergeBuffer(buffer, lastChunk) {
1267
1293
  for (var l = buffer.length, byteLength = lastChunk.length, i = 0; i < l; i++)
1268
1294
  byteLength += buffer[i].byteLength;
1269
1295
  byteLength = new Uint8Array(byteLength);
1270
- for (var i$52 = (i = 0); i$52 < l; i$52++) {
1271
- var chunk = buffer[i$52];
1296
+ for (var i$53 = (i = 0); i$53 < l; i$53++) {
1297
+ var chunk = buffer[i$53];
1272
1298
  byteLength.set(chunk, i);
1273
1299
  i += chunk.byteLength;
1274
1300
  }
@@ -1444,21 +1470,37 @@ function processFullRow(response, id, tag, buffer, chunk) {
1444
1470
  }
1445
1471
  function createFromJSONCallback(response) {
1446
1472
  return function (key, value) {
1447
- return "string" === typeof value
1448
- ? parseModelString(response, this, key, value)
1449
- : "object" === typeof value && null !== value
1450
- ? ((key =
1451
- value[0] === REACT_ELEMENT_TYPE
1452
- ? {
1453
- $$typeof: REACT_ELEMENT_TYPE,
1454
- type: value[1],
1455
- key: value[2],
1456
- ref: null,
1457
- props: value[3]
1458
- }
1459
- : value),
1460
- key)
1461
- : 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;
1462
1504
  };
1463
1505
  }
1464
1506
  function noServerCall() {
@@ -1467,7 +1509,7 @@ function noServerCall() {
1467
1509
  );
1468
1510
  }
1469
1511
  exports.createFromNodeStream = function (stream, ssrManifest, options) {
1470
- var response = createResponse(
1512
+ var response = new ResponseInstance(
1471
1513
  ssrManifest.moduleMap,
1472
1514
  ssrManifest.moduleLoading,
1473
1515
  noServerCall,