react-server-dom-webpack 19.0.0-rc.0 → 19.0.0-rc.1

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.
Files changed (28) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +2483 -3269
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +420 -215
  3. package/cjs/react-server-dom-webpack-client.edge.development.js +2656 -3546
  4. package/cjs/react-server-dom-webpack-client.edge.production.js +424 -218
  5. package/cjs/react-server-dom-webpack-client.node.development.js +2693 -3498
  6. package/cjs/react-server-dom-webpack-client.node.production.js +546 -263
  7. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2638 -3434
  8. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +526 -257
  9. package/cjs/react-server-dom-webpack-plugin.js +11 -11
  10. package/cjs/react-server-dom-webpack-server.browser.development.js +3700 -5229
  11. package/cjs/react-server-dom-webpack-server.browser.production.js +447 -276
  12. package/cjs/react-server-dom-webpack-server.edge.development.js +3730 -5241
  13. package/cjs/react-server-dom-webpack-server.edge.production.js +435 -283
  14. package/cjs/react-server-dom-webpack-server.node.development.js +3794 -5384
  15. package/cjs/react-server-dom-webpack-server.node.production.js +428 -289
  16. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +3756 -5310
  17. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +421 -284
  18. package/esm/react-server-dom-webpack-node-loader.production.js +238 -44
  19. package/package.json +27 -4
  20. package/server.browser.js +12 -2
  21. package/server.edge.js +12 -2
  22. package/server.node.js +13 -2
  23. package/server.node.unbundled.js +13 -2
  24. package/static.browser.js +12 -0
  25. package/static.edge.js +12 -0
  26. package/static.js +6 -0
  27. package/static.node.js +12 -0
  28. package/static.node.unbundled.js +12 -0
@@ -10,7 +10,21 @@
10
10
 
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
- React = require("react"),
13
+ React = require("react");
14
+ function handleErrorInNextTick(error) {
15
+ setTimeout(function () {
16
+ throw error;
17
+ });
18
+ }
19
+ var LocalPromise = Promise,
20
+ scheduleMicrotask =
21
+ "function" === typeof queueMicrotask
22
+ ? queueMicrotask
23
+ : function (callback) {
24
+ LocalPromise.resolve(null)
25
+ .then(callback)
26
+ .catch(handleErrorInNextTick);
27
+ },
14
28
  currentView = null,
15
29
  writtenBytes = 0;
16
30
  function writeChunkAndReturn(destination, chunk) {
@@ -42,6 +56,9 @@ var textEncoder = new TextEncoder();
42
56
  function stringToChunk(content) {
43
57
  return textEncoder.encode(content);
44
58
  }
59
+ function byteLengthOfChunk(chunk) {
60
+ return chunk.byteLength;
61
+ }
45
62
  function closeWithError(destination, error) {
46
63
  "function" === typeof destination.error
47
64
  ? destination.error(error)
@@ -61,12 +78,15 @@ var FunctionBind = Function.prototype.bind,
61
78
  function bind() {
62
79
  var newFn = FunctionBind.apply(this, arguments);
63
80
  if (this.$$typeof === SERVER_REFERENCE_TAG) {
64
- var args = ArraySlice.call(arguments, 1);
81
+ var args = ArraySlice.call(arguments, 1),
82
+ $$typeof = { value: SERVER_REFERENCE_TAG },
83
+ $$id = { value: this.$$id };
84
+ args = { value: this.$$bound ? this.$$bound.concat(args) : args };
65
85
  return Object.defineProperties(newFn, {
66
- $$typeof: { value: SERVER_REFERENCE_TAG },
67
- $$id: { value: this.$$id },
68
- $$bound: { value: this.$$bound ? this.$$bound.concat(args) : args },
69
- bind: { value: bind }
86
+ $$typeof: $$typeof,
87
+ $$id: $$id,
88
+ $$bound: args,
89
+ bind: { value: bind, configurable: !0 }
70
90
  });
71
91
  }
72
92
  return newFn;
@@ -97,6 +117,10 @@ var PROMISE_PROTOTYPE = Promise.prototype,
97
117
  throw Error(
98
118
  "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
99
119
  );
120
+ case "then":
121
+ throw Error(
122
+ "Cannot await or return from a thenable. You cannot await a client module from a server component."
123
+ );
100
124
  }
101
125
  throw Error(
102
126
  "Cannot access " +
@@ -295,8 +319,8 @@ function preinitStyle(href, precedence, options) {
295
319
  options
296
320
  ])
297
321
  : "string" === typeof precedence
298
- ? emitHint(request, "S", [href, precedence])
299
- : emitHint(request, "S", href);
322
+ ? emitHint(request, "S", [href, precedence])
323
+ : emitHint(request, "S", href);
300
324
  }
301
325
  previousDispatcher.S(href, precedence, options);
302
326
  }
@@ -420,12 +444,12 @@ var ASYNC_ITERATOR = Symbol.asyncIterator,
420
444
  SuspenseException = Error(
421
445
  "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`"
422
446
  );
423
- function noop() {}
447
+ function noop$1() {}
424
448
  function trackUsedThenable(thenableState, thenable, index) {
425
449
  index = thenableState[index];
426
450
  void 0 === index
427
451
  ? thenableState.push(thenable)
428
- : index !== thenable && (thenable.then(noop, noop), (thenable = index));
452
+ : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
429
453
  switch (thenable.status) {
430
454
  case "fulfilled":
431
455
  return thenable.value;
@@ -433,7 +457,7 @@ function trackUsedThenable(thenableState, thenable, index) {
433
457
  throw thenable.reason;
434
458
  default:
435
459
  "string" === typeof thenable.status
436
- ? thenable.then(noop, noop)
460
+ ? thenable.then(noop$1, noop$1)
437
461
  : ((thenableState = thenable),
438
462
  (thenableState.status = "pending"),
439
463
  thenableState.then(
@@ -559,7 +583,13 @@ var DefaultAsyncDispatcher = {
559
583
  return entry;
560
584
  }
561
585
  },
562
- isArrayImpl = Array.isArray,
586
+ ReactSharedInternalsServer =
587
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
588
+ if (!ReactSharedInternalsServer)
589
+ throw Error(
590
+ 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
591
+ );
592
+ var isArrayImpl = Array.isArray,
563
593
  getPrototypeOf = Object.getPrototypeOf;
564
594
  function objectName(object) {
565
595
  return Object.prototype.toString
@@ -584,8 +614,8 @@ function describeValueForErrorMessage(value) {
584
614
  return value.$$typeof === CLIENT_REFERENCE_TAG
585
615
  ? "client"
586
616
  : (value = value.displayName || value.name)
587
- ? "function " + value
588
- : "function";
617
+ ? "function " + value
618
+ : "function";
589
619
  default:
590
620
  return String(value);
591
621
  }
@@ -666,30 +696,28 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
666
696
  return void 0 === expandedName
667
697
  ? str
668
698
  : -1 < objKind && 0 < length
669
- ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
670
- "\n " + str + "\n " + objectOrArray)
671
- : "\n " + str;
699
+ ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
700
+ "\n " + str + "\n " + objectOrArray)
701
+ : "\n " + str;
672
702
  }
673
- var ReactSharedInternalsServer =
674
- React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
675
- if (!ReactSharedInternalsServer)
676
- throw Error(
677
- 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
678
- );
679
703
  var ObjectPrototype = Object.prototype,
680
704
  stringify = JSON.stringify;
681
705
  function defaultErrorHandler(error) {
682
706
  console.error(error);
683
707
  }
684
708
  function defaultPostponeHandler() {}
685
- function createRequest(
709
+ function RequestInstance(
710
+ type,
686
711
  model,
687
712
  bundlerConfig,
688
713
  onError,
689
714
  identifierPrefix,
690
715
  onPostpone,
716
+ temporaryReferences,
691
717
  environmentName,
692
- temporaryReferences
718
+ filterStackFrame,
719
+ onAllReady,
720
+ onFatalError
693
721
  ) {
694
722
  if (
695
723
  null !== ReactSharedInternalsServer.A &&
@@ -697,41 +725,40 @@ function createRequest(
697
725
  )
698
726
  throw Error("Currently React only supports one RSC renderer at a time.");
699
727
  ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
700
- var abortSet = new Set();
728
+ filterStackFrame = new Set();
701
729
  environmentName = [];
702
730
  var hints = new Set();
703
- bundlerConfig = {
704
- status: 0,
705
- flushScheduled: !1,
706
- fatalError: null,
707
- destination: null,
708
- bundlerConfig: bundlerConfig,
709
- cache: new Map(),
710
- nextChunkId: 0,
711
- pendingChunks: 0,
712
- hints: hints,
713
- abortListeners: new Set(),
714
- abortableTasks: abortSet,
715
- pingedTasks: environmentName,
716
- completedImportChunks: [],
717
- completedHintChunks: [],
718
- completedRegularChunks: [],
719
- completedErrorChunks: [],
720
- writtenSymbols: new Map(),
721
- writtenClientReferences: new Map(),
722
- writtenServerReferences: new Map(),
723
- writtenObjects: new WeakMap(),
724
- temporaryReferences: temporaryReferences,
725
- identifierPrefix: identifierPrefix || "",
726
- identifierCount: 1,
727
- taintCleanupQueue: [],
728
- onError: void 0 === onError ? defaultErrorHandler : onError,
729
- onPostpone: void 0 === onPostpone ? defaultPostponeHandler : onPostpone
730
- };
731
- model = createTask(bundlerConfig, model, null, !1, abortSet);
732
- environmentName.push(model);
733
- return bundlerConfig;
731
+ this.type = type;
732
+ this.status = 10;
733
+ this.flushScheduled = !1;
734
+ this.destination = this.fatalError = null;
735
+ this.bundlerConfig = bundlerConfig;
736
+ this.cache = new Map();
737
+ this.pendingChunks = this.nextChunkId = 0;
738
+ this.hints = hints;
739
+ this.abortListeners = new Set();
740
+ this.abortableTasks = filterStackFrame;
741
+ this.pingedTasks = environmentName;
742
+ this.completedImportChunks = [];
743
+ this.completedHintChunks = [];
744
+ this.completedRegularChunks = [];
745
+ this.completedErrorChunks = [];
746
+ this.writtenSymbols = new Map();
747
+ this.writtenClientReferences = new Map();
748
+ this.writtenServerReferences = new Map();
749
+ this.writtenObjects = new WeakMap();
750
+ this.temporaryReferences = temporaryReferences;
751
+ this.identifierPrefix = identifierPrefix || "";
752
+ this.identifierCount = 1;
753
+ this.taintCleanupQueue = [];
754
+ this.onError = void 0 === onError ? defaultErrorHandler : onError;
755
+ this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
756
+ this.onAllReady = onAllReady;
757
+ this.onFatalError = onFatalError;
758
+ type = createTask(this, model, null, !1, filterStackFrame);
759
+ environmentName.push(type);
734
760
  }
761
+ function noop() {}
735
762
  var currentRequest = null;
736
763
  function resolveRequest() {
737
764
  if (currentRequest) return currentRequest;
@@ -756,11 +783,21 @@ function serializeThenable(request, task, thenable) {
756
783
  );
757
784
  case "rejected":
758
785
  return (
759
- (task = logRecoverableError(request, thenable.reason)),
786
+ (task = logRecoverableError(request, thenable.reason, null)),
760
787
  emitErrorChunk(request, newTask.id, task),
788
+ (newTask.status = 4),
789
+ request.abortableTasks.delete(newTask),
761
790
  newTask.id
762
791
  );
763
792
  default:
793
+ if (12 === request.status)
794
+ return (
795
+ request.abortableTasks.delete(newTask),
796
+ (newTask.status = 3),
797
+ (task = stringify(serializeByValueID(request.fatalError))),
798
+ emitModelChunk(request, newTask.id, task),
799
+ newTask.id
800
+ );
764
801
  "string" !== typeof thenable.status &&
765
802
  ((thenable.status = "pending"),
766
803
  thenable.then(
@@ -781,11 +818,12 @@ function serializeThenable(request, task, thenable) {
781
818
  pingTask(request, newTask);
782
819
  },
783
820
  function (reason) {
784
- newTask.status = 4;
785
- reason = logRecoverableError(request, reason);
786
- emitErrorChunk(request, newTask.id, reason);
787
- request.abortableTasks.delete(newTask);
788
- enqueueFlush(request);
821
+ 0 === newTask.status &&
822
+ ((reason = logRecoverableError(request, reason, newTask)),
823
+ emitErrorChunk(request, newTask.id, reason),
824
+ (newTask.status = 4),
825
+ request.abortableTasks.delete(newTask),
826
+ enqueueFlush(request));
789
827
  }
790
828
  );
791
829
  return newTask.id;
@@ -794,7 +832,7 @@ function serializeReadableStream(request, task, stream) {
794
832
  function progress(entry) {
795
833
  if (!aborted)
796
834
  if (entry.done)
797
- request.abortListeners.delete(error),
835
+ request.abortListeners.delete(abortStream),
798
836
  (entry = streamTask.id.toString(16) + ":C\n"),
799
837
  request.completedRegularChunks.push(stringToChunk(entry)),
800
838
  enqueueFlush(request),
@@ -813,8 +851,18 @@ function serializeReadableStream(request, task, stream) {
813
851
  function error(reason) {
814
852
  if (!aborted) {
815
853
  aborted = !0;
816
- request.abortListeners.delete(error);
817
- var digest = logRecoverableError(request, reason);
854
+ request.abortListeners.delete(abortStream);
855
+ var digest = logRecoverableError(request, reason, streamTask);
856
+ emitErrorChunk(request, streamTask.id, digest);
857
+ enqueueFlush(request);
858
+ reader.cancel(reason).then(error, error);
859
+ }
860
+ }
861
+ function abortStream(reason) {
862
+ if (!aborted) {
863
+ aborted = !0;
864
+ request.abortListeners.delete(abortStream);
865
+ var digest = logRecoverableError(request, reason, streamTask);
818
866
  emitErrorChunk(request, streamTask.id, digest);
819
867
  enqueueFlush(request);
820
868
  reader.cancel(reason).then(error, error);
@@ -840,7 +888,7 @@ function serializeReadableStream(request, task, stream) {
840
888
  task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
841
889
  request.completedRegularChunks.push(stringToChunk(task));
842
890
  var aborted = !1;
843
- request.abortListeners.add(error);
891
+ request.abortListeners.add(abortStream);
844
892
  reader.read().then(progress, error);
845
893
  return serializeByValueID(streamTask.id);
846
894
  }
@@ -848,7 +896,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
848
896
  function progress(entry) {
849
897
  if (!aborted)
850
898
  if (entry.done) {
851
- request.abortListeners.delete(error);
899
+ request.abortListeners.delete(abortIterable);
852
900
  if (void 0 === entry.value)
853
901
  var endStreamRow = streamTask.id.toString(16) + ":C\n";
854
902
  else
@@ -880,8 +928,19 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
880
928
  function error(reason) {
881
929
  if (!aborted) {
882
930
  aborted = !0;
883
- request.abortListeners.delete(error);
884
- var digest = logRecoverableError(request, reason);
931
+ request.abortListeners.delete(abortIterable);
932
+ var digest = logRecoverableError(request, reason, streamTask);
933
+ emitErrorChunk(request, streamTask.id, digest);
934
+ enqueueFlush(request);
935
+ "function" === typeof iterator.throw &&
936
+ iterator.throw(reason).then(error, error);
937
+ }
938
+ }
939
+ function abortIterable(reason) {
940
+ if (!aborted) {
941
+ aborted = !0;
942
+ request.abortListeners.delete(abortIterable);
943
+ var digest = logRecoverableError(request, reason, streamTask);
885
944
  emitErrorChunk(request, streamTask.id, digest);
886
945
  enqueueFlush(request);
887
946
  "function" === typeof iterator.throw &&
@@ -901,7 +960,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
901
960
  task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
902
961
  request.completedRegularChunks.push(stringToChunk(task));
903
962
  var aborted = !1;
904
- request.abortListeners.add(error);
963
+ request.abortListeners.add(abortIterable);
905
964
  iterator.next().then(progress, error);
906
965
  return serializeByValueID(streamTask.id);
907
966
  }
@@ -941,12 +1000,22 @@ function createLazyWrapperAroundWakeable(wakeable) {
941
1000
  }
942
1001
  return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
943
1002
  }
1003
+ function voidHandler() {}
944
1004
  function renderFunctionComponent(request, task, key, Component, props) {
945
1005
  var prevThenableState = task.thenableState;
946
1006
  task.thenableState = null;
947
1007
  thenableIndexCounter = 0;
948
1008
  thenableState = prevThenableState;
949
1009
  Component = Component(props, void 0);
1010
+ if (12 === request.status)
1011
+ throw (
1012
+ ("object" === typeof Component &&
1013
+ null !== Component &&
1014
+ "function" === typeof Component.then &&
1015
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
1016
+ Component.then(voidHandler, voidHandler),
1017
+ null)
1018
+ );
950
1019
  if (
951
1020
  "object" === typeof Component &&
952
1021
  null !== Component &&
@@ -1003,66 +1072,68 @@ function renderFragment(request, task, children) {
1003
1072
  task.implicitSlot ? [request] : request)
1004
1073
  : children;
1005
1074
  }
1006
- function renderClientElement(task, type, key, props) {
1007
- var keyPath = task.keyPath;
1008
- null === key
1009
- ? (key = keyPath)
1010
- : null !== keyPath && (key = keyPath + "," + key);
1011
- type = [REACT_ELEMENT_TYPE, type, key, props];
1012
- return task.implicitSlot && null !== key ? [type] : type;
1013
- }
1014
1075
  function renderElement(request, task, type, key, ref, props) {
1015
1076
  if (null !== ref && void 0 !== ref)
1016
1077
  throw Error(
1017
1078
  "Refs cannot be used in Server Components, nor passed to Client Components."
1018
1079
  );
1019
- if ("function" === typeof type)
1020
- return type.$$typeof === CLIENT_REFERENCE_TAG$1 ||
1021
- type.$$typeof === TEMPORARY_REFERENCE_TAG
1022
- ? renderClientElement(task, type, key, props)
1023
- : renderFunctionComponent(request, task, key, type, props);
1024
- if ("string" === typeof type)
1025
- return renderClientElement(task, type, key, props);
1026
- if ("symbol" === typeof type)
1027
- return type === REACT_FRAGMENT_TYPE && null === key
1028
- ? ((key = task.implicitSlot),
1029
- null === task.keyPath && (task.implicitSlot = !0),
1030
- (request = renderModelDestructive(
1031
- request,
1032
- task,
1033
- emptyRoot,
1034
- "",
1035
- props.children
1036
- )),
1037
- (task.implicitSlot = key),
1038
- request)
1039
- : renderClientElement(task, type, key, props);
1040
- if (null != type && "object" === typeof type) {
1041
- if (type.$$typeof === CLIENT_REFERENCE_TAG$1)
1042
- return renderClientElement(task, type, key, props);
1080
+ if (
1081
+ "function" === typeof type &&
1082
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
1083
+ type.$$typeof !== TEMPORARY_REFERENCE_TAG
1084
+ )
1085
+ return renderFunctionComponent(request, task, key, type, props);
1086
+ if (type === REACT_FRAGMENT_TYPE && null === key)
1087
+ return (
1088
+ (type = task.implicitSlot),
1089
+ null === task.keyPath && (task.implicitSlot = !0),
1090
+ (props = renderModelDestructive(
1091
+ request,
1092
+ task,
1093
+ emptyRoot,
1094
+ "",
1095
+ props.children
1096
+ )),
1097
+ (task.implicitSlot = type),
1098
+ props
1099
+ );
1100
+ if (
1101
+ null != type &&
1102
+ "object" === typeof type &&
1103
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1
1104
+ )
1043
1105
  switch (type.$$typeof) {
1044
1106
  case REACT_LAZY_TYPE:
1045
1107
  var init = type._init;
1046
1108
  type = init(type._payload);
1109
+ if (12 === request.status) throw null;
1047
1110
  return renderElement(request, task, type, key, ref, props);
1048
1111
  case REACT_FORWARD_REF_TYPE:
1049
1112
  return renderFunctionComponent(request, task, key, type.render, props);
1050
1113
  case REACT_MEMO_TYPE:
1051
1114
  return renderElement(request, task, type.type, key, ref, props);
1052
1115
  }
1053
- }
1054
- throw Error(
1055
- "Unsupported Server Component type: " + describeValueForErrorMessage(type)
1056
- );
1116
+ request = key;
1117
+ key = task.keyPath;
1118
+ null === request
1119
+ ? (request = key)
1120
+ : null !== key && (request = key + "," + request);
1121
+ props = [REACT_ELEMENT_TYPE, type, request, props];
1122
+ task = task.implicitSlot && null !== request ? [props] : props;
1123
+ return task;
1057
1124
  }
1058
1125
  function pingTask(request, task) {
1059
1126
  var pingedTasks = request.pingedTasks;
1060
1127
  pingedTasks.push(task);
1061
1128
  1 === pingedTasks.length &&
1062
1129
  ((request.flushScheduled = null !== request.destination),
1063
- setTimeout(function () {
1064
- return performWork(request);
1065
- }, 0));
1130
+ 21 === request.type || 10 === request.status
1131
+ ? scheduleMicrotask(function () {
1132
+ return performWork(request);
1133
+ })
1134
+ : setTimeout(function () {
1135
+ return performWork(request);
1136
+ }, 0));
1066
1137
  }
1067
1138
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1068
1139
  request.pendingChunks++;
@@ -1094,19 +1165,27 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1094
1165
  );
1095
1166
  } catch (thrownValue) {
1096
1167
  if (
1097
- ((parentPropertyName =
1168
+ ((parentPropertyName = task.model),
1169
+ (parentPropertyName =
1170
+ "object" === typeof parentPropertyName &&
1171
+ null !== parentPropertyName &&
1172
+ (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1173
+ parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1174
+ 12 === request.status)
1175
+ )
1176
+ (task.status = 3),
1177
+ (prevKeyPath = request.fatalError),
1178
+ (JSCompiler_inline_result = parentPropertyName
1179
+ ? "$L" + prevKeyPath.toString(16)
1180
+ : serializeByValueID(prevKeyPath));
1181
+ else if (
1182
+ ((value =
1098
1183
  thrownValue === SuspenseException
1099
1184
  ? getSuspendedThenable()
1100
1185
  : thrownValue),
1101
- (value = task.model),
1102
- (value =
1103
- "object" === typeof value &&
1186
+ "object" === typeof value &&
1104
1187
  null !== value &&
1105
- (value.$$typeof === REACT_ELEMENT_TYPE ||
1106
- value.$$typeof === REACT_LAZY_TYPE)),
1107
- "object" === typeof parentPropertyName &&
1108
- null !== parentPropertyName &&
1109
- "function" === typeof parentPropertyName.then)
1188
+ "function" === typeof value.then)
1110
1189
  ) {
1111
1190
  JSCompiler_inline_result = createTask(
1112
1191
  request,
@@ -1116,28 +1195,24 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1116
1195
  request.abortableTasks
1117
1196
  );
1118
1197
  var ping = JSCompiler_inline_result.ping;
1119
- parentPropertyName.then(ping, ping);
1198
+ value.then(ping, ping);
1120
1199
  JSCompiler_inline_result.thenableState =
1121
1200
  getThenableStateAfterSuspending();
1122
1201
  task.keyPath = prevKeyPath;
1123
1202
  task.implicitSlot = prevImplicitSlot;
1124
- JSCompiler_inline_result = value
1203
+ JSCompiler_inline_result = parentPropertyName
1125
1204
  ? "$L" + JSCompiler_inline_result.id.toString(16)
1126
1205
  : serializeByValueID(JSCompiler_inline_result.id);
1127
- } else if (
1128
- ((task.keyPath = prevKeyPath),
1129
- (task.implicitSlot = prevImplicitSlot),
1130
- value)
1131
- )
1132
- request.pendingChunks++,
1206
+ } else
1207
+ (task.keyPath = prevKeyPath),
1208
+ (task.implicitSlot = prevImplicitSlot),
1209
+ request.pendingChunks++,
1133
1210
  (prevKeyPath = request.nextChunkId++),
1134
- (prevImplicitSlot = logRecoverableError(
1135
- request,
1136
- parentPropertyName
1137
- )),
1211
+ (prevImplicitSlot = logRecoverableError(request, value, task)),
1138
1212
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1139
- (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1140
- else throw parentPropertyName;
1213
+ (JSCompiler_inline_result = parentPropertyName
1214
+ ? "$L" + prevKeyPath.toString(16)
1215
+ : serializeByValueID(prevKeyPath));
1141
1216
  }
1142
1217
  return JSCompiler_inline_result;
1143
1218
  },
@@ -1187,8 +1262,14 @@ function serializeClientReference(
1187
1262
  '" in the React Client Manifest. This is probably a bug in the React Server Components bundler.'
1188
1263
  );
1189
1264
  }
1265
+ if (!0 === resolvedModuleData.async && !0 === clientReference.$$async)
1266
+ throw Error(
1267
+ 'The module "' +
1268
+ modulePath +
1269
+ '" is marked as an async ESM module but was loaded as a CJS proxy. This is probably a bug in the React Server Components bundler.'
1270
+ );
1190
1271
  var JSCompiler_inline_result =
1191
- !0 === clientReference.$$async
1272
+ !0 === resolvedModuleData.async || !0 === clientReference.$$async
1192
1273
  ? [resolvedModuleData.id, resolvedModuleData.chunks, existingId, 1]
1193
1274
  : [resolvedModuleData.id, resolvedModuleData.chunks, existingId];
1194
1275
  request.pendingChunks++;
@@ -1205,7 +1286,7 @@ function serializeClientReference(
1205
1286
  return (
1206
1287
  request.pendingChunks++,
1207
1288
  (parent = request.nextChunkId++),
1208
- (parentPropertyName = logRecoverableError(request, x)),
1289
+ (parentPropertyName = logRecoverableError(request, x, null)),
1209
1290
  emitErrorChunk(request, parent, parentPropertyName),
1210
1291
  serializeByValueID(parent)
1211
1292
  );
@@ -1226,7 +1307,7 @@ function serializeBlob(request, blob) {
1226
1307
  function progress(entry) {
1227
1308
  if (!aborted)
1228
1309
  if (entry.done)
1229
- request.abortListeners.delete(error),
1310
+ request.abortListeners.delete(abortBlob),
1230
1311
  (aborted = !0),
1231
1312
  pingTask(request, newTask);
1232
1313
  else
@@ -1237,10 +1318,19 @@ function serializeBlob(request, blob) {
1237
1318
  function error(reason) {
1238
1319
  if (!aborted) {
1239
1320
  aborted = !0;
1240
- request.abortListeners.delete(error);
1241
- var digest = logRecoverableError(request, reason);
1321
+ request.abortListeners.delete(abortBlob);
1322
+ var digest = logRecoverableError(request, reason, newTask);
1323
+ emitErrorChunk(request, newTask.id, digest);
1324
+ enqueueFlush(request);
1325
+ reader.cancel(reason).then(error, error);
1326
+ }
1327
+ }
1328
+ function abortBlob(reason) {
1329
+ if (!aborted) {
1330
+ aborted = !0;
1331
+ request.abortListeners.delete(abortBlob);
1332
+ var digest = logRecoverableError(request, reason, newTask);
1242
1333
  emitErrorChunk(request, newTask.id, digest);
1243
- request.abortableTasks.delete(newTask);
1244
1334
  enqueueFlush(request);
1245
1335
  reader.cancel(reason).then(error, error);
1246
1336
  }
@@ -1249,7 +1339,7 @@ function serializeBlob(request, blob) {
1249
1339
  newTask = createTask(request, model, null, !1, request.abortableTasks),
1250
1340
  reader = blob.stream().getReader(),
1251
1341
  aborted = !1;
1252
- request.abortListeners.add(error);
1342
+ request.abortListeners.add(abortBlob);
1253
1343
  reader.read().then(progress).catch(error);
1254
1344
  return "$B" + newTask.id.toString(16);
1255
1345
  }
@@ -1267,7 +1357,8 @@ function renderModelDestructive(
1267
1357
  if ("object" === typeof value) {
1268
1358
  switch (value.$$typeof) {
1269
1359
  case REACT_ELEMENT_TYPE:
1270
- var writtenObjects = request.writtenObjects;
1360
+ var elementReference = null,
1361
+ writtenObjects = request.writtenObjects;
1271
1362
  if (null === task.keyPath && !task.implicitSlot) {
1272
1363
  var existingReference = writtenObjects.get(value);
1273
1364
  if (void 0 !== existingReference)
@@ -1277,11 +1368,12 @@ function renderModelDestructive(
1277
1368
  -1 === parentPropertyName.indexOf(":") &&
1278
1369
  ((parent = writtenObjects.get(parent)),
1279
1370
  void 0 !== parent &&
1280
- writtenObjects.set(value, parent + ":" + parentPropertyName));
1371
+ ((elementReference = parent + ":" + parentPropertyName),
1372
+ writtenObjects.set(value, elementReference)));
1281
1373
  }
1282
1374
  parentPropertyName = value.props;
1283
1375
  parent = parentPropertyName.ref;
1284
- return renderElement(
1376
+ request = renderElement(
1285
1377
  request,
1286
1378
  task,
1287
1379
  value.type,
@@ -1289,13 +1381,18 @@ function renderModelDestructive(
1289
1381
  void 0 !== parent ? parent : null,
1290
1382
  parentPropertyName
1291
1383
  );
1384
+ "object" === typeof request &&
1385
+ null !== request &&
1386
+ null !== elementReference &&
1387
+ (writtenObjects.has(request) ||
1388
+ writtenObjects.set(request, elementReference));
1389
+ return request;
1292
1390
  case REACT_LAZY_TYPE:
1293
- return (
1294
- (task.thenableState = null),
1295
- (parentPropertyName = value._init),
1296
- (value = parentPropertyName(value._payload)),
1297
- renderModelDestructive(request, task, emptyRoot, "", value)
1298
- );
1391
+ task.thenableState = null;
1392
+ parentPropertyName = value._init;
1393
+ value = parentPropertyName(value._payload);
1394
+ if (12 === request.status) throw null;
1395
+ return renderModelDestructive(request, task, emptyRoot, "", value);
1299
1396
  case REACT_LEGACY_ELEMENT_TYPE:
1300
1397
  throw Error(
1301
1398
  'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.'
@@ -1310,44 +1407,47 @@ function renderModelDestructive(
1310
1407
  );
1311
1408
  if (
1312
1409
  void 0 !== request.temporaryReferences &&
1313
- ((writtenObjects = request.temporaryReferences.get(value)),
1314
- void 0 !== writtenObjects)
1410
+ ((elementReference = request.temporaryReferences.get(value)),
1411
+ void 0 !== elementReference)
1315
1412
  )
1316
- return "$T" + writtenObjects;
1317
- writtenObjects = request.writtenObjects;
1318
- existingReference = writtenObjects.get(value);
1413
+ return "$T" + elementReference;
1414
+ elementReference = request.writtenObjects;
1415
+ writtenObjects = elementReference.get(value);
1319
1416
  if ("function" === typeof value.then) {
1320
- if (void 0 !== existingReference) {
1417
+ if (void 0 !== writtenObjects) {
1321
1418
  if (null !== task.keyPath || task.implicitSlot)
1322
1419
  return "$@" + serializeThenable(request, task, value).toString(16);
1323
1420
  if (modelRoot === value) modelRoot = null;
1324
- else return existingReference;
1421
+ else return writtenObjects;
1325
1422
  }
1326
1423
  request = "$@" + serializeThenable(request, task, value).toString(16);
1327
- writtenObjects.set(value, request);
1424
+ elementReference.set(value, request);
1328
1425
  return request;
1329
1426
  }
1330
- if (void 0 !== existingReference)
1427
+ if (void 0 !== writtenObjects)
1331
1428
  if (modelRoot === value) modelRoot = null;
1332
- else return existingReference;
1429
+ else return writtenObjects;
1333
1430
  else if (
1334
1431
  -1 === parentPropertyName.indexOf(":") &&
1335
- ((existingReference = writtenObjects.get(parent)),
1336
- void 0 !== existingReference)
1432
+ ((writtenObjects = elementReference.get(parent)),
1433
+ void 0 !== writtenObjects)
1337
1434
  ) {
1338
- var propertyName = parentPropertyName;
1435
+ existingReference = parentPropertyName;
1339
1436
  if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1340
1437
  switch (parentPropertyName) {
1341
1438
  case "1":
1342
- propertyName = "type";
1439
+ existingReference = "type";
1343
1440
  break;
1344
1441
  case "2":
1345
- propertyName = "key";
1442
+ existingReference = "key";
1346
1443
  break;
1347
1444
  case "3":
1348
- propertyName = "props";
1445
+ existingReference = "props";
1446
+ break;
1447
+ case "4":
1448
+ existingReference = "_owner";
1349
1449
  }
1350
- writtenObjects.set(value, existingReference + ":" + propertyName);
1450
+ elementReference.set(value, writtenObjects + ":" + existingReference);
1351
1451
  }
1352
1452
  if (isArrayImpl(value)) return renderFragment(request, task, value);
1353
1453
  if (value instanceof Map)
@@ -1365,6 +1465,7 @@ function renderModelDestructive(
1365
1465
  (value = Array.from(value.entries())),
1366
1466
  "$K" + outlineModel(request, value).toString(16)
1367
1467
  );
1468
+ if (value instanceof Error) return "$Z";
1368
1469
  if (value instanceof ArrayBuffer)
1369
1470
  return serializeTypedArray(request, "A", new Uint8Array(value));
1370
1471
  if (value instanceof Int8Array)
@@ -1393,9 +1494,9 @@ function renderModelDestructive(
1393
1494
  return serializeTypedArray(request, "V", value);
1394
1495
  if ("function" === typeof Blob && value instanceof Blob)
1395
1496
  return serializeBlob(request, value);
1396
- if ((parentPropertyName = getIteratorFn(value)))
1497
+ if ((elementReference = getIteratorFn(value)))
1397
1498
  return (
1398
- (parentPropertyName = parentPropertyName.call(value)),
1499
+ (parentPropertyName = elementReference.call(value)),
1399
1500
  parentPropertyName === value
1400
1501
  ? "$i" +
1401
1502
  outlineModel(request, Array.from(parentPropertyName)).toString(16)
@@ -1403,8 +1504,8 @@ function renderModelDestructive(
1403
1504
  );
1404
1505
  if ("function" === typeof ReadableStream && value instanceof ReadableStream)
1405
1506
  return serializeReadableStream(request, task, value);
1406
- parentPropertyName = value[ASYNC_ITERATOR];
1407
- if ("function" === typeof parentPropertyName)
1507
+ elementReference = value[ASYNC_ITERATOR];
1508
+ if ("function" === typeof elementReference)
1408
1509
  return (
1409
1510
  null !== task.keyPath
1410
1511
  ? ((request = [
@@ -1414,7 +1515,7 @@ function renderModelDestructive(
1414
1515
  { children: value }
1415
1516
  ]),
1416
1517
  (request = task.implicitSlot ? [request] : request))
1417
- : ((parentPropertyName = parentPropertyName.call(value)),
1518
+ : ((parentPropertyName = elementReference.call(value)),
1418
1519
  (request = serializeAsyncIterable(
1419
1520
  request,
1420
1521
  task,
@@ -1423,13 +1524,15 @@ function renderModelDestructive(
1423
1524
  ))),
1424
1525
  request
1425
1526
  );
1527
+ if (value instanceof Date) return "$D" + value.toJSON();
1426
1528
  request = getPrototypeOf(value);
1427
1529
  if (
1428
1530
  request !== ObjectPrototype &&
1429
1531
  (null === request || null !== getPrototypeOf(request))
1430
1532
  )
1431
1533
  throw Error(
1432
- "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported."
1534
+ "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." +
1535
+ describeObjectForErrorMessage(parent, parentPropertyName)
1433
1536
  );
1434
1537
  return value;
1435
1538
  }
@@ -1439,7 +1542,7 @@ function renderModelDestructive(
1439
1542
  parent[parentPropertyName] instanceof Date
1440
1543
  )
1441
1544
  return "$D" + value;
1442
- if (1024 <= value.length)
1545
+ if (1024 <= value.length && null !== byteLengthOfChunk)
1443
1546
  return (
1444
1547
  request.pendingChunks++,
1445
1548
  (task = request.nextChunkId++),
@@ -1456,10 +1559,10 @@ function renderModelDestructive(
1456
1559
  ? "$-0"
1457
1560
  : value
1458
1561
  : Infinity === value
1459
- ? "$Infinity"
1460
- : -Infinity === value
1461
- ? "$-Infinity"
1462
- : "$NaN";
1562
+ ? "$Infinity"
1563
+ : -Infinity === value
1564
+ ? "$-Infinity"
1565
+ : "$NaN";
1463
1566
  if ("undefined" === typeof value) return "$undefined";
1464
1567
  if ("function" === typeof value) {
1465
1568
  if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
@@ -1476,13 +1579,14 @@ function renderModelDestructive(
1476
1579
  void 0 !== parentPropertyName
1477
1580
  ? (request = "$F" + parentPropertyName.toString(16))
1478
1581
  : ((parentPropertyName = value.$$bound),
1479
- (parentPropertyName = {
1582
+ (parentPropertyName =
1583
+ null === parentPropertyName
1584
+ ? null
1585
+ : Promise.resolve(parentPropertyName)),
1586
+ (request = outlineModel(request, {
1480
1587
  id: value.$$id,
1481
1588
  bound: parentPropertyName
1482
- ? Promise.resolve(parentPropertyName)
1483
- : null
1484
- }),
1485
- (request = outlineModel(request, parentPropertyName)),
1589
+ })),
1486
1590
  task.set(value, request),
1487
1591
  (request = "$F" + request.toString(16))),
1488
1592
  request
@@ -1509,10 +1613,11 @@ function renderModelDestructive(
1509
1613
  }
1510
1614
  if ("symbol" === typeof value) {
1511
1615
  task = request.writtenSymbols;
1512
- writtenObjects = task.get(value);
1513
- if (void 0 !== writtenObjects) return serializeByValueID(writtenObjects);
1514
- writtenObjects = value.description;
1515
- if (Symbol.for(writtenObjects) !== value)
1616
+ elementReference = task.get(value);
1617
+ if (void 0 !== elementReference)
1618
+ return serializeByValueID(elementReference);
1619
+ elementReference = value.description;
1620
+ if (Symbol.for(elementReference) !== value)
1516
1621
  throw Error(
1517
1622
  "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1518
1623
  (value.description + ") cannot be found among global symbols.") +
@@ -1523,7 +1628,7 @@ function renderModelDestructive(
1523
1628
  parent = encodeReferenceChunk(
1524
1629
  request,
1525
1630
  parentPropertyName,
1526
- "$S" + writtenObjects
1631
+ "$S" + elementReference
1527
1632
  );
1528
1633
  request.completedImportChunks.push(parent);
1529
1634
  task.set(value, parentPropertyName);
@@ -1557,9 +1662,11 @@ function logRecoverableError(request, error) {
1557
1662
  return errorDigest || "";
1558
1663
  }
1559
1664
  function fatalError(request, error) {
1665
+ var onFatalError = request.onFatalError;
1666
+ onFatalError(error);
1560
1667
  null !== request.destination
1561
- ? ((request.status = 2), closeWithError(request.destination, error))
1562
- : ((request.status = 1), (request.fatalError = error));
1668
+ ? ((request.status = 14), closeWithError(request.destination, error))
1669
+ : ((request.status = 13), (request.fatalError = error));
1563
1670
  }
1564
1671
  function emitErrorChunk(request, id, digest) {
1565
1672
  digest = { digest: digest };
@@ -1586,6 +1693,10 @@ function emitTypedArrayChunk(request, id, tag, typedArray) {
1586
1693
  request.completedRegularChunks.push(id, typedArray);
1587
1694
  }
1588
1695
  function emitTextChunk(request, id, text) {
1696
+ if (null === byteLengthOfChunk)
1697
+ throw Error(
1698
+ "Existence of byteLengthOfChunk should have already been checked. This is a bug in React."
1699
+ );
1589
1700
  request.pendingChunks++;
1590
1701
  text = stringToChunk(text);
1591
1702
  var binaryLength = text.byteLength;
@@ -1595,40 +1706,41 @@ function emitTextChunk(request, id, text) {
1595
1706
  }
1596
1707
  function emitChunk(request, task, value) {
1597
1708
  var id = task.id;
1598
- "string" === typeof value
1709
+ "string" === typeof value && null !== byteLengthOfChunk
1599
1710
  ? emitTextChunk(request, id, value)
1600
1711
  : value instanceof ArrayBuffer
1601
- ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1602
- : value instanceof Int8Array
1603
- ? emitTypedArrayChunk(request, id, "O", value)
1604
- : value instanceof Uint8Array
1605
- ? emitTypedArrayChunk(request, id, "o", value)
1606
- : value instanceof Uint8ClampedArray
1607
- ? emitTypedArrayChunk(request, id, "U", value)
1608
- : value instanceof Int16Array
1609
- ? emitTypedArrayChunk(request, id, "S", value)
1610
- : value instanceof Uint16Array
1611
- ? emitTypedArrayChunk(request, id, "s", value)
1612
- : value instanceof Int32Array
1613
- ? emitTypedArrayChunk(request, id, "L", value)
1614
- : value instanceof Uint32Array
1615
- ? emitTypedArrayChunk(request, id, "l", value)
1616
- : value instanceof Float32Array
1617
- ? emitTypedArrayChunk(request, id, "G", value)
1618
- : value instanceof Float64Array
1619
- ? emitTypedArrayChunk(request, id, "g", value)
1620
- : value instanceof BigInt64Array
1621
- ? emitTypedArrayChunk(request, id, "M", value)
1622
- : value instanceof BigUint64Array
1623
- ? emitTypedArrayChunk(request, id, "m", value)
1624
- : value instanceof DataView
1625
- ? emitTypedArrayChunk(request, id, "V", value)
1626
- : ((value = stringify(value, task.toJSON)),
1627
- emitModelChunk(request, task.id, value));
1712
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1713
+ : value instanceof Int8Array
1714
+ ? emitTypedArrayChunk(request, id, "O", value)
1715
+ : value instanceof Uint8Array
1716
+ ? emitTypedArrayChunk(request, id, "o", value)
1717
+ : value instanceof Uint8ClampedArray
1718
+ ? emitTypedArrayChunk(request, id, "U", value)
1719
+ : value instanceof Int16Array
1720
+ ? emitTypedArrayChunk(request, id, "S", value)
1721
+ : value instanceof Uint16Array
1722
+ ? emitTypedArrayChunk(request, id, "s", value)
1723
+ : value instanceof Int32Array
1724
+ ? emitTypedArrayChunk(request, id, "L", value)
1725
+ : value instanceof Uint32Array
1726
+ ? emitTypedArrayChunk(request, id, "l", value)
1727
+ : value instanceof Float32Array
1728
+ ? emitTypedArrayChunk(request, id, "G", value)
1729
+ : value instanceof Float64Array
1730
+ ? emitTypedArrayChunk(request, id, "g", value)
1731
+ : value instanceof BigInt64Array
1732
+ ? emitTypedArrayChunk(request, id, "M", value)
1733
+ : value instanceof BigUint64Array
1734
+ ? emitTypedArrayChunk(request, id, "m", value)
1735
+ : value instanceof DataView
1736
+ ? emitTypedArrayChunk(request, id, "V", value)
1737
+ : ((value = stringify(value, task.toJSON)),
1738
+ emitModelChunk(request, task.id, value));
1628
1739
  }
1629
1740
  var emptyRoot = {};
1630
1741
  function retryTask(request, task) {
1631
- if (0 === task.status)
1742
+ if (0 === task.status) {
1743
+ task.status = 5;
1632
1744
  try {
1633
1745
  modelRoot = task.model;
1634
1746
  var resolvedModel = renderModelDestructive(
@@ -1651,28 +1763,42 @@ function retryTask(request, task) {
1651
1763
  request.abortableTasks.delete(task);
1652
1764
  task.status = 1;
1653
1765
  } catch (thrownValue) {
1654
- var x =
1655
- thrownValue === SuspenseException
1656
- ? getSuspendedThenable()
1657
- : thrownValue;
1658
- if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1659
- var ping = task.ping;
1660
- x.then(ping, ping);
1661
- task.thenableState = getThenableStateAfterSuspending();
1662
- } else {
1766
+ if (12 === request.status) {
1663
1767
  request.abortableTasks.delete(task);
1664
- task.status = 4;
1665
- var digest = logRecoverableError(request, x);
1666
- emitErrorChunk(request, task.id, digest);
1768
+ task.status = 3;
1769
+ var model = stringify(serializeByValueID(request.fatalError));
1770
+ emitModelChunk(request, task.id, model);
1771
+ } else {
1772
+ var x =
1773
+ thrownValue === SuspenseException
1774
+ ? getSuspendedThenable()
1775
+ : thrownValue;
1776
+ if (
1777
+ "object" === typeof x &&
1778
+ null !== x &&
1779
+ "function" === typeof x.then
1780
+ ) {
1781
+ task.status = 0;
1782
+ task.thenableState = getThenableStateAfterSuspending();
1783
+ var ping = task.ping;
1784
+ x.then(ping, ping);
1785
+ } else {
1786
+ request.abortableTasks.delete(task);
1787
+ task.status = 4;
1788
+ var digest = logRecoverableError(request, x, task);
1789
+ emitErrorChunk(request, task.id, digest);
1790
+ }
1667
1791
  }
1668
1792
  } finally {
1669
1793
  }
1794
+ }
1670
1795
  }
1671
1796
  function performWork(request) {
1672
1797
  var prevDispatcher = ReactSharedInternalsServer.H;
1673
1798
  ReactSharedInternalsServer.H = HooksDispatcher;
1674
1799
  var prevRequest = currentRequest;
1675
1800
  currentRequest$1 = currentRequest = request;
1801
+ var hadAbortableTasks = 0 < request.abortableTasks.size;
1676
1802
  try {
1677
1803
  var pingedTasks = request.pingedTasks;
1678
1804
  request.pingedTasks = [];
@@ -1680,8 +1806,12 @@ function performWork(request) {
1680
1806
  retryTask(request, pingedTasks[i]);
1681
1807
  null !== request.destination &&
1682
1808
  flushCompletedChunks(request, request.destination);
1809
+ if (hadAbortableTasks && 0 === request.abortableTasks.size) {
1810
+ var onAllReady = request.onAllReady;
1811
+ onAllReady();
1812
+ }
1683
1813
  } catch (error) {
1684
- logRecoverableError(request, error), fatalError(request, error);
1814
+ logRecoverableError(request, error, null), fatalError(request, error);
1685
1815
  } finally {
1686
1816
  (ReactSharedInternalsServer.H = prevDispatcher),
1687
1817
  (currentRequest$1 = null),
@@ -1724,66 +1854,81 @@ function flushCompletedChunks(request, destination) {
1724
1854
  (writtenBytes = 0));
1725
1855
  }
1726
1856
  0 === request.pendingChunks &&
1727
- (destination.close(), (request.destination = null));
1857
+ ((request.status = 14), destination.close(), (request.destination = null));
1728
1858
  }
1729
1859
  function startWork(request) {
1730
1860
  request.flushScheduled = null !== request.destination;
1731
1861
  supportsRequestStorage
1732
- ? setTimeout(function () {
1733
- return requestStorage.run(request, performWork, request);
1734
- }, 0)
1735
- : setTimeout(function () {
1862
+ ? scheduleMicrotask(function () {
1863
+ requestStorage.run(request, performWork, request);
1864
+ })
1865
+ : scheduleMicrotask(function () {
1736
1866
  return performWork(request);
1737
- }, 0);
1867
+ });
1868
+ setTimeout(function () {
1869
+ 10 === request.status && (request.status = 11);
1870
+ }, 0);
1738
1871
  }
1739
1872
  function enqueueFlush(request) {
1740
- if (
1741
- !1 === request.flushScheduled &&
1873
+ !1 === request.flushScheduled &&
1742
1874
  0 === request.pingedTasks.length &&
1743
- null !== request.destination
1744
- ) {
1745
- var destination = request.destination;
1746
- request.flushScheduled = !0;
1875
+ null !== request.destination &&
1876
+ ((request.flushScheduled = !0),
1747
1877
  setTimeout(function () {
1748
- return flushCompletedChunks(request, destination);
1749
- }, 0);
1750
- }
1878
+ request.flushScheduled = !1;
1879
+ var destination = request.destination;
1880
+ destination && flushCompletedChunks(request, destination);
1881
+ }, 0));
1751
1882
  }
1752
1883
  function abort(request, reason) {
1753
1884
  try {
1885
+ 11 >= request.status && (request.status = 12);
1754
1886
  var abortableTasks = request.abortableTasks;
1755
1887
  if (0 < abortableTasks.size) {
1756
- request.pendingChunks++;
1757
- var errorId = request.nextChunkId++,
1758
- error =
1888
+ var error =
1759
1889
  void 0 === reason
1760
1890
  ? Error("The render was aborted by the server without a reason.")
1761
- : reason,
1762
- digest = logRecoverableError(request, error);
1891
+ : "object" === typeof reason &&
1892
+ null !== reason &&
1893
+ "function" === typeof reason.then
1894
+ ? Error("The render was aborted by the server with a promise.")
1895
+ : reason,
1896
+ digest = logRecoverableError(request, error, null),
1897
+ errorId = request.nextChunkId++;
1898
+ request.fatalError = errorId;
1899
+ request.pendingChunks++;
1763
1900
  emitErrorChunk(request, errorId, digest, error);
1764
1901
  abortableTasks.forEach(function (task) {
1765
- task.status = 3;
1766
- var ref = serializeByValueID(errorId);
1767
- task = encodeReferenceChunk(request, task.id, ref);
1768
- request.completedErrorChunks.push(task);
1902
+ if (5 !== task.status) {
1903
+ task.status = 3;
1904
+ var ref = serializeByValueID(errorId);
1905
+ task = encodeReferenceChunk(request, task.id, ref);
1906
+ request.completedErrorChunks.push(task);
1907
+ }
1769
1908
  });
1770
1909
  abortableTasks.clear();
1910
+ var onAllReady = request.onAllReady;
1911
+ onAllReady();
1771
1912
  }
1772
1913
  var abortListeners = request.abortListeners;
1773
1914
  if (0 < abortListeners.size) {
1774
- var error$22 =
1915
+ var error$23 =
1775
1916
  void 0 === reason
1776
1917
  ? Error("The render was aborted by the server without a reason.")
1777
- : reason;
1918
+ : "object" === typeof reason &&
1919
+ null !== reason &&
1920
+ "function" === typeof reason.then
1921
+ ? Error("The render was aborted by the server with a promise.")
1922
+ : reason;
1778
1923
  abortListeners.forEach(function (callback) {
1779
- return callback(error$22);
1924
+ return callback(error$23);
1780
1925
  });
1781
1926
  abortListeners.clear();
1782
1927
  }
1783
1928
  null !== request.destination &&
1784
1929
  flushCompletedChunks(request, request.destination);
1785
- } catch (error$23) {
1786
- logRecoverableError(request, error$23), fatalError(request, error$23);
1930
+ } catch (error$24) {
1931
+ logRecoverableError(request, error$24, null), fatalError(request, error$24);
1787
1932
  }
1788
1933
  }
1789
1934
  function resolveServerReference(bundlerConfig, id) {
@@ -1802,7 +1947,9 @@ function resolveServerReference(bundlerConfig, id) {
1802
1947
  '" in the React Server Manifest. This is probably a bug in the React Server Components bundler.'
1803
1948
  );
1804
1949
  }
1805
- return [resolvedModuleData.id, resolvedModuleData.chunks, name];
1950
+ return resolvedModuleData.async
1951
+ ? [resolvedModuleData.id, resolvedModuleData.chunks, name, 1]
1952
+ : [resolvedModuleData.id, resolvedModuleData.chunks, name];
1806
1953
  }
1807
1954
  var chunkCache = new Map();
1808
1955
  function requireAsyncModule(id) {
@@ -1842,8 +1989,8 @@ function preloadModule(metadata) {
1842
1989
  return requireAsyncModule(metadata[0]);
1843
1990
  })
1844
1991
  : 0 < promises.length
1845
- ? Promise.all(promises)
1846
- : null;
1992
+ ? Promise.all(promises)
1993
+ : null;
1847
1994
  }
1848
1995
  function requireModule(metadata) {
1849
1996
  var moduleExports = __webpack_require__(metadata[0]);
@@ -1854,10 +2001,10 @@ function requireModule(metadata) {
1854
2001
  return "*" === metadata[2]
1855
2002
  ? moduleExports
1856
2003
  : "" === metadata[2]
1857
- ? moduleExports.__esModule
1858
- ? moduleExports.default
1859
- : moduleExports
1860
- : moduleExports[metadata[2]];
2004
+ ? moduleExports.__esModule
2005
+ ? moduleExports.default
2006
+ : moduleExports
2007
+ : moduleExports[metadata[2]];
1861
2008
  }
1862
2009
  var hasOwnProperty = Object.prototype.hasOwnProperty;
1863
2010
  function Chunk(status, value, reason, response) {
@@ -2226,8 +2373,8 @@ function parseReadableStream(response, reference, type) {
2226
2373
  (previousBlockedChunk = chunk));
2227
2374
  } else {
2228
2375
  chunk = previousBlockedChunk;
2229
- var chunk$26 = createPendingChunk(response);
2230
- chunk$26.then(
2376
+ var chunk$27 = createPendingChunk(response);
2377
+ chunk$27.then(
2231
2378
  function (v) {
2232
2379
  return controller.enqueue(v);
2233
2380
  },
@@ -2235,10 +2382,10 @@ function parseReadableStream(response, reference, type) {
2235
2382
  return controller.error(e);
2236
2383
  }
2237
2384
  );
2238
- previousBlockedChunk = chunk$26;
2385
+ previousBlockedChunk = chunk$27;
2239
2386
  chunk.then(function () {
2240
- previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2241
- resolveModelChunk(chunk$26, json, -1);
2387
+ previousBlockedChunk === chunk$27 && (previousBlockedChunk = null);
2388
+ resolveModelChunk(chunk$27, json, -1);
2242
2389
  });
2243
2390
  }
2244
2391
  },
@@ -2483,10 +2630,10 @@ function loadServerReference(bundlerConfig, id, bound) {
2483
2630
  return fn.bind.apply(fn, [null].concat(_ref));
2484
2631
  })
2485
2632
  : bundlerConfig
2486
- ? Promise.resolve(bundlerConfig).then(function () {
2487
- return requireModule(serverReference);
2488
- })
2489
- : Promise.resolve(requireModule(serverReference));
2633
+ ? Promise.resolve(bundlerConfig).then(function () {
2634
+ return requireModule(serverReference);
2635
+ })
2636
+ : Promise.resolve(requireModule(serverReference));
2490
2637
  }
2491
2638
  function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
2492
2639
  body = createResponse(serverManifest, formFieldPrefix, void 0, body);
@@ -2579,14 +2726,18 @@ exports.registerServerReference = function (reference, id, exportName) {
2579
2726
  });
2580
2727
  };
2581
2728
  exports.renderToReadableStream = function (model, webpackMap, options) {
2582
- var request = createRequest(
2729
+ var request = new RequestInstance(
2730
+ 20,
2583
2731
  model,
2584
2732
  webpackMap,
2585
2733
  options ? options.onError : void 0,
2586
2734
  options ? options.identifierPrefix : void 0,
2587
2735
  options ? options.onPostpone : void 0,
2588
- options ? options.environmentName : void 0,
2589
- options ? options.temporaryReferences : void 0
2736
+ options ? options.temporaryReferences : void 0,
2737
+ void 0,
2738
+ void 0,
2739
+ noop,
2740
+ noop
2590
2741
  );
2591
2742
  if (options && options.signal) {
2592
2743
  var signal = options.signal;
@@ -2606,14 +2757,15 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2606
2757
  startWork(request);
2607
2758
  },
2608
2759
  pull: function (controller) {
2609
- if (1 === request.status)
2610
- (request.status = 2), closeWithError(controller, request.fatalError);
2611
- else if (2 !== request.status && null === request.destination) {
2760
+ if (13 === request.status)
2761
+ (request.status = 14), closeWithError(controller, request.fatalError);
2762
+ else if (14 !== request.status && null === request.destination) {
2612
2763
  request.destination = controller;
2613
2764
  try {
2614
2765
  flushCompletedChunks(request, controller);
2615
2766
  } catch (error) {
2616
- logRecoverableError(request, error), fatalError(request, error);
2767
+ logRecoverableError(request, error, null),
2768
+ fatalError(request, error);
2617
2769
  }
2618
2770
  }
2619
2771
  },