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.
@@ -488,7 +488,6 @@ Chunk.prototype.then = function (resolve, reject) {
488
488
  break;
489
489
  case "pending":
490
490
  case "blocked":
491
- case "cyclic":
492
491
  resolve &&
493
492
  (null === this.value && (this.value = []), this.value.push(resolve));
494
493
  reject &&
@@ -511,7 +510,6 @@ function readChunk(chunk) {
511
510
  return chunk.value;
512
511
  case "pending":
513
512
  case "blocked":
514
- case "cyclic":
515
513
  throw chunk;
516
514
  default:
517
515
  throw chunk.reason;
@@ -530,7 +528,6 @@ function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
530
528
  break;
531
529
  case "pending":
532
530
  case "blocked":
533
- case "cyclic":
534
531
  if (chunk.value)
535
532
  for (var i = 0; i < resolveListeners.length; i++)
536
533
  chunk.value.push(resolveListeners[i]);
@@ -596,35 +593,35 @@ function resolveModuleChunk(chunk, value) {
596
593
  wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners));
597
594
  }
598
595
  }
599
- var initializingChunk = null,
600
- initializingChunkBlockedModel = null;
596
+ var initializingHandler = null;
601
597
  function initializeModelChunk(chunk) {
602
- var prevChunk = initializingChunk,
603
- prevBlocked = initializingChunkBlockedModel;
604
- initializingChunk = chunk;
605
- initializingChunkBlockedModel = null;
598
+ var prevHandler = initializingHandler;
599
+ initializingHandler = null;
606
600
  var resolvedModel = chunk.value;
607
- chunk.status = "cyclic";
601
+ chunk.status = "blocked";
608
602
  chunk.value = null;
609
603
  chunk.reason = null;
610
604
  try {
611
- var value = JSON.parse(resolvedModel, chunk._response._fromJSON);
612
- if (
613
- null !== initializingChunkBlockedModel &&
614
- 0 < initializingChunkBlockedModel.deps
615
- )
616
- (initializingChunkBlockedModel.value = value), (chunk.status = "blocked");
617
- else {
618
- var resolveListeners = chunk.value;
619
- chunk.status = "fulfilled";
620
- chunk.value = value;
621
- null !== resolveListeners && wakeChunk(resolveListeners, value);
605
+ var value = JSON.parse(resolvedModel, chunk._response._fromJSON),
606
+ resolveListeners = chunk.value;
607
+ null !== resolveListeners &&
608
+ ((chunk.value = null),
609
+ (chunk.reason = null),
610
+ wakeChunk(resolveListeners, value));
611
+ if (null !== initializingHandler) {
612
+ if (initializingHandler.errored) throw initializingHandler.value;
613
+ if (0 < initializingHandler.deps) {
614
+ initializingHandler.value = value;
615
+ initializingHandler.chunk = chunk;
616
+ return;
617
+ }
622
618
  }
619
+ chunk.status = "fulfilled";
620
+ chunk.value = value;
623
621
  } catch (error) {
624
622
  (chunk.status = "rejected"), (chunk.reason = error);
625
623
  } finally {
626
- (initializingChunk = prevChunk),
627
- (initializingChunkBlockedModel = prevBlocked);
624
+ initializingHandler = prevHandler;
628
625
  }
629
626
  }
630
627
  function initializeModuleChunk(chunk) {
@@ -654,46 +651,71 @@ function reportGlobalError(response, error) {
654
651
  "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
655
652
  });
656
653
  }
654
+ function createLazyChunkWrapper(chunk) {
655
+ return { $$typeof: REACT_LAZY_TYPE, _payload: chunk, _init: readChunk };
656
+ }
657
657
  function getChunk(response, id) {
658
658
  var chunks = response._chunks,
659
659
  chunk = chunks.get(id);
660
660
  chunk || ((chunk = createPendingChunk(response)), chunks.set(id, chunk));
661
661
  return chunk;
662
662
  }
663
- function createModelResolver(
664
- chunk,
663
+ function waitForReference(
664
+ referencedChunk,
665
665
  parentObject,
666
666
  key,
667
- cyclic,
668
667
  response,
669
668
  map,
670
669
  path
671
670
  ) {
672
- if (initializingChunkBlockedModel) {
673
- var blocked = initializingChunkBlockedModel;
674
- cyclic || blocked.deps++;
671
+ function fulfill(value) {
672
+ for (var i = 1; i < path.length; i++) {
673
+ for (; value.$$typeof === REACT_LAZY_TYPE; )
674
+ if (((value = value._payload), value === handler.chunk))
675
+ value = handler.value;
676
+ else if ("fulfilled" === value.status) value = value.value;
677
+ else {
678
+ path.splice(0, i - 1);
679
+ value.then(fulfill, reject);
680
+ return;
681
+ }
682
+ value = value[path[i]];
683
+ }
684
+ parentObject[key] = map(response, value);
685
+ "" === key && null === handler.value && (handler.value = parentObject[key]);
686
+ handler.deps--;
687
+ 0 === handler.deps &&
688
+ ((i = handler.chunk),
689
+ null !== i &&
690
+ "blocked" === i.status &&
691
+ ((value = i.value),
692
+ (i.status = "fulfilled"),
693
+ (i.value = handler.value),
694
+ null !== value && wakeChunk(value, handler.value)));
695
+ }
696
+ function reject(error) {
697
+ if (!handler.errored) {
698
+ handler.errored = !0;
699
+ handler.value = error;
700
+ var chunk = handler.chunk;
701
+ null !== chunk &&
702
+ "blocked" === chunk.status &&
703
+ triggerErrorOnChunk(chunk, error);
704
+ }
705
+ }
706
+ if (initializingHandler) {
707
+ var handler = initializingHandler;
708
+ handler.deps++;
675
709
  } else
676
- blocked = initializingChunkBlockedModel = {
677
- deps: cyclic ? 0 : 1,
678
- value: null
710
+ handler = initializingHandler = {
711
+ parent: null,
712
+ chunk: null,
713
+ value: null,
714
+ deps: 1,
715
+ errored: !1
679
716
  };
680
- return function (value) {
681
- for (var i = 1; i < path.length; i++) value = value[path[i]];
682
- parentObject[key] = map(response, value);
683
- "" === key && null === blocked.value && (blocked.value = parentObject[key]);
684
- blocked.deps--;
685
- 0 === blocked.deps &&
686
- "blocked" === chunk.status &&
687
- ((value = chunk.value),
688
- (chunk.status = "fulfilled"),
689
- (chunk.value = blocked.value),
690
- null !== value && wakeChunk(value, blocked.value));
691
- };
692
- }
693
- function createModelReject(chunk) {
694
- return function (error) {
695
- return triggerErrorOnChunk(chunk, error);
696
- };
717
+ referencedChunk.then(fulfill, reject);
718
+ return null;
697
719
  }
698
720
  function createServerReferenceProxy(response, metaData) {
699
721
  function proxy() {
@@ -730,23 +752,21 @@ function getOutlinedModel(response, reference, parentObject, key, map) {
730
752
  return map(response, parentObject);
731
753
  case "pending":
732
754
  case "blocked":
733
- case "cyclic":
734
- var parentChunk = initializingChunk;
735
- id.then(
736
- createModelResolver(
737
- parentChunk,
738
- parentObject,
739
- key,
740
- "cyclic" === id.status,
741
- response,
742
- map,
743
- reference
744
- ),
745
- createModelReject(parentChunk)
746
- );
747
- return null;
755
+ return waitForReference(id, parentObject, key, response, map, reference);
748
756
  default:
749
- throw id.reason;
757
+ return (
758
+ initializingHandler
759
+ ? ((initializingHandler.errored = !0),
760
+ (initializingHandler.value = id.reason))
761
+ : (initializingHandler = {
762
+ parent: null,
763
+ chunk: null,
764
+ value: id.reason,
765
+ deps: 0,
766
+ errored: !0
767
+ }),
768
+ null
769
+ );
750
770
  }
751
771
  }
752
772
  function createMap(response, model) {
@@ -772,7 +792,19 @@ function createModel(response, model) {
772
792
  }
773
793
  function parseModelString(response, parentObject, key, value) {
774
794
  if ("$" === value[0]) {
775
- if ("$" === value) return REACT_ELEMENT_TYPE;
795
+ if ("$" === value)
796
+ return (
797
+ null !== initializingHandler &&
798
+ "0" === key &&
799
+ (initializingHandler = {
800
+ parent: initializingHandler,
801
+ chunk: null,
802
+ value: null,
803
+ deps: 0,
804
+ errored: !1
805
+ }),
806
+ REACT_ELEMENT_TYPE
807
+ );
776
808
  switch (value[1]) {
777
809
  case "$":
778
810
  return value.slice(1);
@@ -780,7 +812,7 @@ function parseModelString(response, parentObject, key, value) {
780
812
  return (
781
813
  (parentObject = parseInt(value.slice(2), 16)),
782
814
  (response = getChunk(response, parentObject)),
783
- { $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
815
+ createLazyChunkWrapper(response)
784
816
  );
785
817
  case "@":
786
818
  if (2 === value.length) return new Promise(function () {});
@@ -858,6 +890,28 @@ function missingCall() {
858
890
  'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.'
859
891
  );
860
892
  }
893
+ function ResponseInstance(
894
+ bundlerConfig,
895
+ moduleLoading,
896
+ callServer,
897
+ encodeFormAction,
898
+ nonce,
899
+ temporaryReferences
900
+ ) {
901
+ var chunks = new Map();
902
+ this._bundlerConfig = bundlerConfig;
903
+ this._moduleLoading = moduleLoading;
904
+ this._callServer = void 0 !== callServer ? callServer : missingCall;
905
+ this._encodeFormAction = encodeFormAction;
906
+ this._nonce = nonce;
907
+ this._chunks = chunks;
908
+ this._stringDecoder = new TextDecoder();
909
+ this._fromJSON = null;
910
+ this._rowLength = this._rowTag = this._rowID = this._rowState = 0;
911
+ this._buffer = [];
912
+ this._tempRefs = temporaryReferences;
913
+ this._fromJSON = createFromJSONCallback(this);
914
+ }
861
915
  function resolveBuffer(response, id, buffer) {
862
916
  var chunks = response._chunks,
863
917
  chunk = chunks.get(id);
@@ -939,8 +993,8 @@ function startReadableStream(response, id, type) {
939
993
  (previousBlockedChunk = chunk));
940
994
  } else {
941
995
  chunk = previousBlockedChunk;
942
- var chunk$51 = createPendingChunk(response);
943
- chunk$51.then(
996
+ var chunk$52 = createPendingChunk(response);
997
+ chunk$52.then(
944
998
  function (v) {
945
999
  return controller.enqueue(v);
946
1000
  },
@@ -948,10 +1002,10 @@ function startReadableStream(response, id, type) {
948
1002
  return controller.error(e);
949
1003
  }
950
1004
  );
951
- previousBlockedChunk = chunk$51;
1005
+ previousBlockedChunk = chunk$52;
952
1006
  chunk.then(function () {
953
- previousBlockedChunk === chunk$51 && (previousBlockedChunk = null);
954
- resolveModelChunk(chunk$51, json);
1007
+ previousBlockedChunk === chunk$52 && (previousBlockedChunk = null);
1008
+ resolveModelChunk(chunk$52, json);
955
1009
  });
956
1010
  }
957
1011
  },
@@ -1079,8 +1133,8 @@ function mergeBuffer(buffer, lastChunk) {
1079
1133
  for (var l = buffer.length, byteLength = lastChunk.length, i = 0; i < l; i++)
1080
1134
  byteLength += buffer[i].byteLength;
1081
1135
  byteLength = new Uint8Array(byteLength);
1082
- for (var i$52 = (i = 0); i$52 < l; i$52++) {
1083
- var chunk = buffer[i$52];
1136
+ for (var i$53 = (i = 0); i$53 < l; i$53++) {
1137
+ var chunk = buffer[i$53];
1084
1138
  byteLength.set(chunk, i);
1085
1139
  i += chunk.byteLength;
1086
1140
  }
@@ -1256,48 +1310,50 @@ function processFullRow(response, id, tag, buffer, chunk) {
1256
1310
  }
1257
1311
  function createFromJSONCallback(response) {
1258
1312
  return function (key, value) {
1259
- return "string" === typeof value
1260
- ? parseModelString(response, this, key, value)
1261
- : "object" === typeof value && null !== value
1262
- ? ((key =
1263
- value[0] === REACT_ELEMENT_TYPE
1264
- ? {
1265
- $$typeof: REACT_ELEMENT_TYPE,
1266
- type: value[1],
1267
- key: value[2],
1268
- ref: null,
1269
- props: value[3]
1270
- }
1271
- : value),
1272
- key)
1273
- : value;
1313
+ if ("string" === typeof value)
1314
+ return parseModelString(response, this, key, value);
1315
+ if ("object" === typeof value && null !== value) {
1316
+ if (value[0] === REACT_ELEMENT_TYPE) {
1317
+ if (
1318
+ ((key = {
1319
+ $$typeof: REACT_ELEMENT_TYPE,
1320
+ type: value[1],
1321
+ key: value[2],
1322
+ ref: null,
1323
+ props: value[3]
1324
+ }),
1325
+ null !== initializingHandler)
1326
+ )
1327
+ if (
1328
+ ((value = initializingHandler),
1329
+ (initializingHandler = value.parent),
1330
+ value.errored)
1331
+ )
1332
+ (key = new Chunk("rejected", null, value.value, response)),
1333
+ (key = createLazyChunkWrapper(key));
1334
+ else if (0 < value.deps) {
1335
+ var blockedChunk = new Chunk("blocked", null, null, response);
1336
+ value.value = key;
1337
+ value.chunk = blockedChunk;
1338
+ key = createLazyChunkWrapper(blockedChunk);
1339
+ }
1340
+ } else key = value;
1341
+ return key;
1342
+ }
1343
+ return value;
1274
1344
  };
1275
1345
  }
1276
1346
  function createResponseFromOptions(options) {
1277
- var callServer = options && options.callServer ? options.callServer : void 0;
1278
- options =
1347
+ return new ResponseInstance(
1348
+ null,
1349
+ null,
1350
+ options && options.callServer ? options.callServer : void 0,
1351
+ void 0,
1352
+ void 0,
1279
1353
  options && options.temporaryReferences
1280
1354
  ? options.temporaryReferences
1281
- : void 0;
1282
- var chunks = new Map();
1283
- callServer = {
1284
- _bundlerConfig: null,
1285
- _moduleLoading: null,
1286
- _callServer: void 0 !== callServer ? callServer : missingCall,
1287
- _encodeFormAction: void 0,
1288
- _nonce: void 0,
1289
- _chunks: chunks,
1290
- _stringDecoder: new TextDecoder(),
1291
- _fromJSON: null,
1292
- _rowState: 0,
1293
- _rowID: 0,
1294
- _rowTag: 0,
1295
- _rowLength: 0,
1296
- _buffer: [],
1297
- _tempRefs: options
1298
- };
1299
- callServer._fromJSON = createFromJSONCallback(callServer);
1300
- return callServer;
1355
+ : void 0
1356
+ );
1301
1357
  }
1302
1358
  function startReadingFromStream(response, stream) {
1303
1359
  function progress(_ref) {