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.
@@ -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 () {});
@@ -1012,6 +1044,28 @@ function missingCall() {
1012
1044
  'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.'
1013
1045
  );
1014
1046
  }
1047
+ function ResponseInstance(
1048
+ bundlerConfig,
1049
+ moduleLoading,
1050
+ callServer,
1051
+ encodeFormAction,
1052
+ nonce,
1053
+ temporaryReferences
1054
+ ) {
1055
+ var chunks = new Map();
1056
+ this._bundlerConfig = bundlerConfig;
1057
+ this._moduleLoading = moduleLoading;
1058
+ this._callServer = void 0 !== callServer ? callServer : missingCall;
1059
+ this._encodeFormAction = encodeFormAction;
1060
+ this._nonce = nonce;
1061
+ this._chunks = chunks;
1062
+ this._stringDecoder = new TextDecoder();
1063
+ this._fromJSON = null;
1064
+ this._rowLength = this._rowTag = this._rowID = this._rowState = 0;
1065
+ this._buffer = [];
1066
+ this._tempRefs = temporaryReferences;
1067
+ this._fromJSON = createFromJSONCallback(this);
1068
+ }
1015
1069
  function resolveBuffer(response, id, buffer) {
1016
1070
  var chunks = response._chunks,
1017
1071
  chunk = chunks.get(id);
@@ -1098,8 +1152,8 @@ function startReadableStream(response, id, type) {
1098
1152
  (previousBlockedChunk = chunk));
1099
1153
  } else {
1100
1154
  chunk = previousBlockedChunk;
1101
- var chunk$51 = createPendingChunk(response);
1102
- chunk$51.then(
1155
+ var chunk$52 = createPendingChunk(response);
1156
+ chunk$52.then(
1103
1157
  function (v) {
1104
1158
  return controller.enqueue(v);
1105
1159
  },
@@ -1107,10 +1161,10 @@ function startReadableStream(response, id, type) {
1107
1161
  return controller.error(e);
1108
1162
  }
1109
1163
  );
1110
- previousBlockedChunk = chunk$51;
1164
+ previousBlockedChunk = chunk$52;
1111
1165
  chunk.then(function () {
1112
- previousBlockedChunk === chunk$51 && (previousBlockedChunk = null);
1113
- resolveModelChunk(chunk$51, json);
1166
+ previousBlockedChunk === chunk$52 && (previousBlockedChunk = null);
1167
+ resolveModelChunk(chunk$52, json);
1114
1168
  });
1115
1169
  }
1116
1170
  },
@@ -1238,8 +1292,8 @@ function mergeBuffer(buffer, lastChunk) {
1238
1292
  for (var l = buffer.length, byteLength = lastChunk.length, i = 0; i < l; i++)
1239
1293
  byteLength += buffer[i].byteLength;
1240
1294
  byteLength = new Uint8Array(byteLength);
1241
- for (var i$52 = (i = 0); i$52 < l; i$52++) {
1242
- var chunk = buffer[i$52];
1295
+ for (var i$53 = (i = 0); i$53 < l; i$53++) {
1296
+ var chunk = buffer[i$53];
1243
1297
  byteLength.set(chunk, i);
1244
1298
  i += chunk.byteLength;
1245
1299
  }
@@ -1415,21 +1469,37 @@ function processFullRow(response, id, tag, buffer, chunk) {
1415
1469
  }
1416
1470
  function createFromJSONCallback(response) {
1417
1471
  return function (key, value) {
1418
- return "string" === typeof value
1419
- ? parseModelString(response, this, key, value)
1420
- : "object" === typeof value && null !== value
1421
- ? ((key =
1422
- value[0] === REACT_ELEMENT_TYPE
1423
- ? {
1424
- $$typeof: REACT_ELEMENT_TYPE,
1425
- type: value[1],
1426
- key: value[2],
1427
- ref: null,
1428
- props: value[3]
1429
- }
1430
- : value),
1431
- key)
1432
- : 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;
1433
1503
  };
1434
1504
  }
1435
1505
  function noServerCall() {
@@ -1438,33 +1508,16 @@ function noServerCall() {
1438
1508
  );
1439
1509
  }
1440
1510
  function createResponseFromOptions(options) {
1441
- var bundlerConfig = options.ssrManifest.moduleMap,
1442
- moduleLoading = options.ssrManifest.moduleLoading,
1443
- encodeFormAction = options.encodeFormAction,
1444
- nonce = "string" === typeof options.nonce ? options.nonce : void 0;
1445
- options =
1511
+ return new ResponseInstance(
1512
+ options.ssrManifest.moduleMap,
1513
+ options.ssrManifest.moduleLoading,
1514
+ noServerCall,
1515
+ options.encodeFormAction,
1516
+ "string" === typeof options.nonce ? options.nonce : void 0,
1446
1517
  options && options.temporaryReferences
1447
1518
  ? options.temporaryReferences
1448
- : void 0;
1449
- var chunks = new Map();
1450
- bundlerConfig = {
1451
- _bundlerConfig: bundlerConfig,
1452
- _moduleLoading: moduleLoading,
1453
- _callServer: void 0 !== noServerCall ? noServerCall : missingCall,
1454
- _encodeFormAction: encodeFormAction,
1455
- _nonce: nonce,
1456
- _chunks: chunks,
1457
- _stringDecoder: new TextDecoder(),
1458
- _fromJSON: null,
1459
- _rowState: 0,
1460
- _rowID: 0,
1461
- _rowTag: 0,
1462
- _rowLength: 0,
1463
- _buffer: [],
1464
- _tempRefs: options
1465
- };
1466
- bundlerConfig._fromJSON = createFromJSONCallback(bundlerConfig);
1467
- return bundlerConfig;
1519
+ : void 0
1520
+ );
1468
1521
  }
1469
1522
  function startReadingFromStream(response, stream) {
1470
1523
  function progress(_ref) {