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.
@@ -626,7 +626,6 @@ Chunk.prototype.then = function (resolve, reject) {
626
626
  break;
627
627
  case "pending":
628
628
  case "blocked":
629
- case "cyclic":
630
629
  resolve &&
631
630
  (null === this.value && (this.value = []), this.value.push(resolve));
632
631
  reject &&
@@ -649,7 +648,6 @@ function readChunk(chunk) {
649
648
  return chunk.value;
650
649
  case "pending":
651
650
  case "blocked":
652
- case "cyclic":
653
651
  throw chunk;
654
652
  default:
655
653
  throw chunk.reason;
@@ -668,7 +666,6 @@ function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
668
666
  break;
669
667
  case "pending":
670
668
  case "blocked":
671
- case "cyclic":
672
669
  if (chunk.value)
673
670
  for (var i = 0; i < resolveListeners.length; i++)
674
671
  chunk.value.push(resolveListeners[i]);
@@ -734,35 +731,35 @@ function resolveModuleChunk(chunk, value) {
734
731
  wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners));
735
732
  }
736
733
  }
737
- var initializingChunk = null,
738
- initializingChunkBlockedModel = null;
734
+ var initializingHandler = null;
739
735
  function initializeModelChunk(chunk) {
740
- var prevChunk = initializingChunk,
741
- prevBlocked = initializingChunkBlockedModel;
742
- initializingChunk = chunk;
743
- initializingChunkBlockedModel = null;
736
+ var prevHandler = initializingHandler;
737
+ initializingHandler = null;
744
738
  var resolvedModel = chunk.value;
745
- chunk.status = "cyclic";
739
+ chunk.status = "blocked";
746
740
  chunk.value = null;
747
741
  chunk.reason = null;
748
742
  try {
749
- var value = JSON.parse(resolvedModel, chunk._response._fromJSON);
750
- if (
751
- null !== initializingChunkBlockedModel &&
752
- 0 < initializingChunkBlockedModel.deps
753
- )
754
- (initializingChunkBlockedModel.value = value), (chunk.status = "blocked");
755
- else {
756
- var resolveListeners = chunk.value;
757
- chunk.status = "fulfilled";
758
- chunk.value = value;
759
- null !== resolveListeners && wakeChunk(resolveListeners, value);
743
+ var value = JSON.parse(resolvedModel, chunk._response._fromJSON),
744
+ resolveListeners = chunk.value;
745
+ null !== resolveListeners &&
746
+ ((chunk.value = null),
747
+ (chunk.reason = null),
748
+ wakeChunk(resolveListeners, value));
749
+ if (null !== initializingHandler) {
750
+ if (initializingHandler.errored) throw initializingHandler.value;
751
+ if (0 < initializingHandler.deps) {
752
+ initializingHandler.value = value;
753
+ initializingHandler.chunk = chunk;
754
+ return;
755
+ }
760
756
  }
757
+ chunk.status = "fulfilled";
758
+ chunk.value = value;
761
759
  } catch (error) {
762
760
  (chunk.status = "rejected"), (chunk.reason = error);
763
761
  } finally {
764
- (initializingChunk = prevChunk),
765
- (initializingChunkBlockedModel = prevBlocked);
762
+ initializingHandler = prevHandler;
766
763
  }
767
764
  }
768
765
  function initializeModuleChunk(chunk) {
@@ -788,46 +785,71 @@ function reportGlobalError(response, error) {
788
785
  "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
789
786
  });
790
787
  }
788
+ function createLazyChunkWrapper(chunk) {
789
+ return { $$typeof: REACT_LAZY_TYPE, _payload: chunk, _init: readChunk };
790
+ }
791
791
  function getChunk(response, id) {
792
792
  var chunks = response._chunks,
793
793
  chunk = chunks.get(id);
794
794
  chunk || ((chunk = createPendingChunk(response)), chunks.set(id, chunk));
795
795
  return chunk;
796
796
  }
797
- function createModelResolver(
798
- chunk,
797
+ function waitForReference(
798
+ referencedChunk,
799
799
  parentObject,
800
800
  key,
801
- cyclic,
802
801
  response,
803
802
  map,
804
803
  path
805
804
  ) {
806
- if (initializingChunkBlockedModel) {
807
- var blocked = initializingChunkBlockedModel;
808
- cyclic || blocked.deps++;
805
+ function fulfill(value) {
806
+ for (var i = 1; i < path.length; i++) {
807
+ for (; value.$$typeof === REACT_LAZY_TYPE; )
808
+ if (((value = value._payload), value === handler.chunk))
809
+ value = handler.value;
810
+ else if ("fulfilled" === value.status) value = value.value;
811
+ else {
812
+ path.splice(0, i - 1);
813
+ value.then(fulfill, reject);
814
+ return;
815
+ }
816
+ value = value[path[i]];
817
+ }
818
+ parentObject[key] = map(response, value);
819
+ "" === key && null === handler.value && (handler.value = parentObject[key]);
820
+ handler.deps--;
821
+ 0 === handler.deps &&
822
+ ((i = handler.chunk),
823
+ null !== i &&
824
+ "blocked" === i.status &&
825
+ ((value = i.value),
826
+ (i.status = "fulfilled"),
827
+ (i.value = handler.value),
828
+ null !== value && wakeChunk(value, handler.value)));
829
+ }
830
+ function reject(error) {
831
+ if (!handler.errored) {
832
+ handler.errored = !0;
833
+ handler.value = error;
834
+ var chunk = handler.chunk;
835
+ null !== chunk &&
836
+ "blocked" === chunk.status &&
837
+ triggerErrorOnChunk(chunk, error);
838
+ }
839
+ }
840
+ if (initializingHandler) {
841
+ var handler = initializingHandler;
842
+ handler.deps++;
809
843
  } else
810
- blocked = initializingChunkBlockedModel = {
811
- deps: cyclic ? 0 : 1,
812
- value: null
844
+ handler = initializingHandler = {
845
+ parent: null,
846
+ chunk: null,
847
+ value: null,
848
+ deps: 1,
849
+ errored: !1
813
850
  };
814
- return function (value) {
815
- for (var i = 1; i < path.length; i++) value = value[path[i]];
816
- parentObject[key] = map(response, value);
817
- "" === key && null === blocked.value && (blocked.value = parentObject[key]);
818
- blocked.deps--;
819
- 0 === blocked.deps &&
820
- "blocked" === chunk.status &&
821
- ((value = chunk.value),
822
- (chunk.status = "fulfilled"),
823
- (chunk.value = blocked.value),
824
- null !== value && wakeChunk(value, blocked.value));
825
- };
826
- }
827
- function createModelReject(chunk) {
828
- return function (error) {
829
- return triggerErrorOnChunk(chunk, error);
830
- };
851
+ referencedChunk.then(fulfill, reject);
852
+ return null;
831
853
  }
832
854
  function createServerReferenceProxy(response, metaData) {
833
855
  function proxy() {
@@ -864,23 +886,21 @@ function getOutlinedModel(response, reference, parentObject, key, map) {
864
886
  return map(response, parentObject);
865
887
  case "pending":
866
888
  case "blocked":
867
- case "cyclic":
868
- var parentChunk = initializingChunk;
869
- id.then(
870
- createModelResolver(
871
- parentChunk,
872
- parentObject,
873
- key,
874
- "cyclic" === id.status,
875
- response,
876
- map,
877
- reference
878
- ),
879
- createModelReject(parentChunk)
880
- );
881
- return null;
889
+ return waitForReference(id, parentObject, key, response, map, reference);
882
890
  default:
883
- throw id.reason;
891
+ return (
892
+ initializingHandler
893
+ ? ((initializingHandler.errored = !0),
894
+ (initializingHandler.value = id.reason))
895
+ : (initializingHandler = {
896
+ parent: null,
897
+ chunk: null,
898
+ value: id.reason,
899
+ deps: 0,
900
+ errored: !0
901
+ }),
902
+ null
903
+ );
884
904
  }
885
905
  }
886
906
  function createMap(response, model) {
@@ -906,7 +926,19 @@ function createModel(response, model) {
906
926
  }
907
927
  function parseModelString(response, parentObject, key, value) {
908
928
  if ("$" === value[0]) {
909
- if ("$" === value) return REACT_ELEMENT_TYPE;
929
+ if ("$" === value)
930
+ return (
931
+ null !== initializingHandler &&
932
+ "0" === key &&
933
+ (initializingHandler = {
934
+ parent: initializingHandler,
935
+ chunk: null,
936
+ value: null,
937
+ deps: 0,
938
+ errored: !1
939
+ }),
940
+ REACT_ELEMENT_TYPE
941
+ );
910
942
  switch (value[1]) {
911
943
  case "$":
912
944
  return value.slice(1);
@@ -914,7 +946,7 @@ function parseModelString(response, parentObject, key, value) {
914
946
  return (
915
947
  (parentObject = parseInt(value.slice(2), 16)),
916
948
  (response = getChunk(response, parentObject)),
917
- { $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
949
+ createLazyChunkWrapper(response)
918
950
  );
919
951
  case "@":
920
952
  if (2 === value.length) return new Promise(function () {});
@@ -992,7 +1024,7 @@ function missingCall() {
992
1024
  'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.'
993
1025
  );
994
1026
  }
995
- function createResponse(
1027
+ function ResponseInstance(
996
1028
  bundlerConfig,
997
1029
  moduleLoading,
998
1030
  callServer,
@@ -1001,24 +1033,18 @@ function createResponse(
1001
1033
  temporaryReferences
1002
1034
  ) {
1003
1035
  var chunks = new Map();
1004
- bundlerConfig = {
1005
- _bundlerConfig: bundlerConfig,
1006
- _moduleLoading: moduleLoading,
1007
- _callServer: void 0 !== callServer ? callServer : missingCall,
1008
- _encodeFormAction: encodeFormAction,
1009
- _nonce: nonce,
1010
- _chunks: chunks,
1011
- _stringDecoder: new util.TextDecoder(),
1012
- _fromJSON: null,
1013
- _rowState: 0,
1014
- _rowID: 0,
1015
- _rowTag: 0,
1016
- _rowLength: 0,
1017
- _buffer: [],
1018
- _tempRefs: temporaryReferences
1019
- };
1020
- bundlerConfig._fromJSON = createFromJSONCallback(bundlerConfig);
1021
- return bundlerConfig;
1036
+ this._bundlerConfig = bundlerConfig;
1037
+ this._moduleLoading = moduleLoading;
1038
+ this._callServer = void 0 !== callServer ? callServer : missingCall;
1039
+ this._encodeFormAction = encodeFormAction;
1040
+ this._nonce = nonce;
1041
+ this._chunks = chunks;
1042
+ this._stringDecoder = new util.TextDecoder();
1043
+ this._fromJSON = null;
1044
+ this._rowLength = this._rowTag = this._rowID = this._rowState = 0;
1045
+ this._buffer = [];
1046
+ this._tempRefs = temporaryReferences;
1047
+ this._fromJSON = createFromJSONCallback(this);
1022
1048
  }
1023
1049
  function resolveBuffer(response, id, buffer) {
1024
1050
  var chunks = response._chunks,
@@ -1106,8 +1132,8 @@ function startReadableStream(response, id, type) {
1106
1132
  (previousBlockedChunk = chunk));
1107
1133
  } else {
1108
1134
  chunk = previousBlockedChunk;
1109
- var chunk$51 = createPendingChunk(response);
1110
- chunk$51.then(
1135
+ var chunk$52 = createPendingChunk(response);
1136
+ chunk$52.then(
1111
1137
  function (v) {
1112
1138
  return controller.enqueue(v);
1113
1139
  },
@@ -1115,10 +1141,10 @@ function startReadableStream(response, id, type) {
1115
1141
  return controller.error(e);
1116
1142
  }
1117
1143
  );
1118
- previousBlockedChunk = chunk$51;
1144
+ previousBlockedChunk = chunk$52;
1119
1145
  chunk.then(function () {
1120
- previousBlockedChunk === chunk$51 && (previousBlockedChunk = null);
1121
- resolveModelChunk(chunk$51, json);
1146
+ previousBlockedChunk === chunk$52 && (previousBlockedChunk = null);
1147
+ resolveModelChunk(chunk$52, json);
1122
1148
  });
1123
1149
  }
1124
1150
  },
@@ -1246,8 +1272,8 @@ function mergeBuffer(buffer, lastChunk) {
1246
1272
  for (var l = buffer.length, byteLength = lastChunk.length, i = 0; i < l; i++)
1247
1273
  byteLength += buffer[i].byteLength;
1248
1274
  byteLength = new Uint8Array(byteLength);
1249
- for (var i$52 = (i = 0); i$52 < l; i$52++) {
1250
- var chunk = buffer[i$52];
1275
+ for (var i$53 = (i = 0); i$53 < l; i$53++) {
1276
+ var chunk = buffer[i$53];
1251
1277
  byteLength.set(chunk, i);
1252
1278
  i += chunk.byteLength;
1253
1279
  }
@@ -1423,21 +1449,37 @@ function processFullRow(response, id, tag, buffer, chunk) {
1423
1449
  }
1424
1450
  function createFromJSONCallback(response) {
1425
1451
  return function (key, value) {
1426
- return "string" === typeof value
1427
- ? parseModelString(response, this, key, value)
1428
- : "object" === typeof value && null !== value
1429
- ? ((key =
1430
- value[0] === REACT_ELEMENT_TYPE
1431
- ? {
1432
- $$typeof: REACT_ELEMENT_TYPE,
1433
- type: value[1],
1434
- key: value[2],
1435
- ref: null,
1436
- props: value[3]
1437
- }
1438
- : value),
1439
- key)
1440
- : value;
1452
+ if ("string" === typeof value)
1453
+ return parseModelString(response, this, key, value);
1454
+ if ("object" === typeof value && null !== value) {
1455
+ if (value[0] === REACT_ELEMENT_TYPE) {
1456
+ if (
1457
+ ((key = {
1458
+ $$typeof: REACT_ELEMENT_TYPE,
1459
+ type: value[1],
1460
+ key: value[2],
1461
+ ref: null,
1462
+ props: value[3]
1463
+ }),
1464
+ null !== initializingHandler)
1465
+ )
1466
+ if (
1467
+ ((value = initializingHandler),
1468
+ (initializingHandler = value.parent),
1469
+ value.errored)
1470
+ )
1471
+ (key = new Chunk("rejected", null, value.value, response)),
1472
+ (key = createLazyChunkWrapper(key));
1473
+ else if (0 < value.deps) {
1474
+ var blockedChunk = new Chunk("blocked", null, null, response);
1475
+ value.value = key;
1476
+ value.chunk = blockedChunk;
1477
+ key = createLazyChunkWrapper(blockedChunk);
1478
+ }
1479
+ } else key = value;
1480
+ return key;
1481
+ }
1482
+ return value;
1441
1483
  };
1442
1484
  }
1443
1485
  function noServerCall() {
@@ -1446,7 +1488,7 @@ function noServerCall() {
1446
1488
  );
1447
1489
  }
1448
1490
  exports.createFromNodeStream = function (stream, ssrManifest, options) {
1449
- var response = createResponse(
1491
+ var response = new ResponseInstance(
1450
1492
  ssrManifest.moduleMap,
1451
1493
  ssrManifest.moduleLoading,
1452
1494
  noServerCall,