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
@@ -14,6 +14,7 @@ require("crypto");
14
14
  var async_hooks = require("async_hooks"),
15
15
  ReactDOM = require("react-dom"),
16
16
  React = require("react"),
17
+ scheduleMicrotask = queueMicrotask,
17
18
  currentView = null,
18
19
  writtenBytes = 0,
19
20
  destinationHasCapacity = !0;
@@ -32,7 +33,7 @@ function writeChunkAndReturn(destination, chunk) {
32
33
  ),
33
34
  (currentView = new Uint8Array(2048)),
34
35
  (writtenBytes = 0)),
35
- writeToDestination(destination, textEncoder.encode(chunk));
36
+ writeToDestination(destination, chunk);
36
37
  else {
37
38
  var target = currentView;
38
39
  0 < writtenBytes && (target = currentView.subarray(writtenBytes));
@@ -83,8 +84,13 @@ function writeChunkAndReturn(destination, chunk) {
83
84
  (writtenBytes = 0))));
84
85
  return destinationHasCapacity;
85
86
  }
86
- var textEncoder = new util.TextEncoder(),
87
- CLIENT_REFERENCE_TAG$1 = Symbol.for("react.client.reference"),
87
+ var textEncoder = new util.TextEncoder();
88
+ function byteLengthOfChunk(chunk) {
89
+ return "string" === typeof chunk
90
+ ? Buffer.byteLength(chunk, "utf8")
91
+ : chunk.byteLength;
92
+ }
93
+ var CLIENT_REFERENCE_TAG$1 = Symbol.for("react.client.reference"),
88
94
  SERVER_REFERENCE_TAG = Symbol.for("react.server.reference");
89
95
  function registerClientReferenceImpl(proxyImplementation, id, async) {
90
96
  return Object.defineProperties(proxyImplementation, {
@@ -98,12 +104,15 @@ var FunctionBind = Function.prototype.bind,
98
104
  function bind() {
99
105
  var newFn = FunctionBind.apply(this, arguments);
100
106
  if (this.$$typeof === SERVER_REFERENCE_TAG) {
101
- var args = ArraySlice.call(arguments, 1);
107
+ var args = ArraySlice.call(arguments, 1),
108
+ $$typeof = { value: SERVER_REFERENCE_TAG },
109
+ $$id = { value: this.$$id };
110
+ args = { value: this.$$bound ? this.$$bound.concat(args) : args };
102
111
  return Object.defineProperties(newFn, {
103
- $$typeof: { value: SERVER_REFERENCE_TAG },
104
- $$id: { value: this.$$id },
105
- $$bound: { value: this.$$bound ? this.$$bound.concat(args) : args },
106
- bind: { value: bind }
112
+ $$typeof: $$typeof,
113
+ $$id: $$id,
114
+ $$bound: args,
115
+ bind: { value: bind, configurable: !0 }
107
116
  });
108
117
  }
109
118
  return newFn;
@@ -134,6 +143,10 @@ var PROMISE_PROTOTYPE = Promise.prototype,
134
143
  throw Error(
135
144
  "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
136
145
  );
146
+ case "then":
147
+ throw Error(
148
+ "Cannot await or return from a thenable. You cannot await a client module from a server component."
149
+ );
137
150
  }
138
151
  throw Error(
139
152
  "Cannot access " +
@@ -332,8 +345,8 @@ function preinitStyle(href, precedence, options) {
332
345
  options
333
346
  ])
334
347
  : "string" === typeof precedence
335
- ? emitHint(request, "S", [href, precedence])
336
- : emitHint(request, "S", href);
348
+ ? emitHint(request, "S", [href, precedence])
349
+ : emitHint(request, "S", href);
337
350
  }
338
351
  previousDispatcher.S(href, precedence, options);
339
352
  }
@@ -450,12 +463,12 @@ var ASYNC_ITERATOR = Symbol.asyncIterator,
450
463
  SuspenseException = Error(
451
464
  "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`"
452
465
  );
453
- function noop() {}
466
+ function noop$1() {}
454
467
  function trackUsedThenable(thenableState, thenable, index) {
455
468
  index = thenableState[index];
456
469
  void 0 === index
457
470
  ? thenableState.push(thenable)
458
- : index !== thenable && (thenable.then(noop, noop), (thenable = index));
471
+ : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
459
472
  switch (thenable.status) {
460
473
  case "fulfilled":
461
474
  return thenable.value;
@@ -463,7 +476,7 @@ function trackUsedThenable(thenableState, thenable, index) {
463
476
  throw thenable.reason;
464
477
  default:
465
478
  "string" === typeof thenable.status
466
- ? thenable.then(noop, noop)
479
+ ? thenable.then(noop$1, noop$1)
467
480
  : ((thenableState = thenable),
468
481
  (thenableState.status = "pending"),
469
482
  thenableState.then(
@@ -589,7 +602,13 @@ var DefaultAsyncDispatcher = {
589
602
  return entry;
590
603
  }
591
604
  },
592
- isArrayImpl = Array.isArray,
605
+ ReactSharedInternalsServer =
606
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
607
+ if (!ReactSharedInternalsServer)
608
+ throw Error(
609
+ '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.'
610
+ );
611
+ var isArrayImpl = Array.isArray,
593
612
  getPrototypeOf = Object.getPrototypeOf;
594
613
  function objectName(object) {
595
614
  return Object.prototype.toString
@@ -614,8 +633,8 @@ function describeValueForErrorMessage(value) {
614
633
  return value.$$typeof === CLIENT_REFERENCE_TAG
615
634
  ? "client"
616
635
  : (value = value.displayName || value.name)
617
- ? "function " + value
618
- : "function";
636
+ ? "function " + value
637
+ : "function";
619
638
  default:
620
639
  return String(value);
621
640
  }
@@ -696,30 +715,28 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
696
715
  return void 0 === expandedName
697
716
  ? str
698
717
  : -1 < objKind && 0 < length
699
- ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
700
- "\n " + str + "\n " + objectOrArray)
701
- : "\n " + str;
718
+ ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
719
+ "\n " + str + "\n " + objectOrArray)
720
+ : "\n " + str;
702
721
  }
703
- var ReactSharedInternalsServer =
704
- React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
705
- if (!ReactSharedInternalsServer)
706
- throw Error(
707
- '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.'
708
- );
709
722
  var ObjectPrototype = Object.prototype,
710
723
  stringify = JSON.stringify;
711
724
  function defaultErrorHandler(error) {
712
725
  console.error(error);
713
726
  }
714
727
  function defaultPostponeHandler() {}
715
- function createRequest(
728
+ function RequestInstance(
729
+ type,
716
730
  model,
717
731
  bundlerConfig,
718
732
  onError,
719
733
  identifierPrefix,
720
734
  onPostpone,
735
+ temporaryReferences,
721
736
  environmentName,
722
- temporaryReferences
737
+ filterStackFrame,
738
+ onAllReady,
739
+ onFatalError
723
740
  ) {
724
741
  if (
725
742
  null !== ReactSharedInternalsServer.A &&
@@ -727,41 +744,40 @@ function createRequest(
727
744
  )
728
745
  throw Error("Currently React only supports one RSC renderer at a time.");
729
746
  ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
730
- var abortSet = new Set();
747
+ filterStackFrame = new Set();
731
748
  environmentName = [];
732
749
  var hints = new Set();
733
- bundlerConfig = {
734
- status: 0,
735
- flushScheduled: !1,
736
- fatalError: null,
737
- destination: null,
738
- bundlerConfig: bundlerConfig,
739
- cache: new Map(),
740
- nextChunkId: 0,
741
- pendingChunks: 0,
742
- hints: hints,
743
- abortListeners: new Set(),
744
- abortableTasks: abortSet,
745
- pingedTasks: environmentName,
746
- completedImportChunks: [],
747
- completedHintChunks: [],
748
- completedRegularChunks: [],
749
- completedErrorChunks: [],
750
- writtenSymbols: new Map(),
751
- writtenClientReferences: new Map(),
752
- writtenServerReferences: new Map(),
753
- writtenObjects: new WeakMap(),
754
- temporaryReferences: temporaryReferences,
755
- identifierPrefix: identifierPrefix || "",
756
- identifierCount: 1,
757
- taintCleanupQueue: [],
758
- onError: void 0 === onError ? defaultErrorHandler : onError,
759
- onPostpone: void 0 === onPostpone ? defaultPostponeHandler : onPostpone
760
- };
761
- model = createTask(bundlerConfig, model, null, !1, abortSet);
762
- environmentName.push(model);
763
- return bundlerConfig;
750
+ this.type = type;
751
+ this.status = 10;
752
+ this.flushScheduled = !1;
753
+ this.destination = this.fatalError = null;
754
+ this.bundlerConfig = bundlerConfig;
755
+ this.cache = new Map();
756
+ this.pendingChunks = this.nextChunkId = 0;
757
+ this.hints = hints;
758
+ this.abortListeners = new Set();
759
+ this.abortableTasks = filterStackFrame;
760
+ this.pingedTasks = environmentName;
761
+ this.completedImportChunks = [];
762
+ this.completedHintChunks = [];
763
+ this.completedRegularChunks = [];
764
+ this.completedErrorChunks = [];
765
+ this.writtenSymbols = new Map();
766
+ this.writtenClientReferences = new Map();
767
+ this.writtenServerReferences = new Map();
768
+ this.writtenObjects = new WeakMap();
769
+ this.temporaryReferences = temporaryReferences;
770
+ this.identifierPrefix = identifierPrefix || "";
771
+ this.identifierCount = 1;
772
+ this.taintCleanupQueue = [];
773
+ this.onError = void 0 === onError ? defaultErrorHandler : onError;
774
+ this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
775
+ this.onAllReady = onAllReady;
776
+ this.onFatalError = onFatalError;
777
+ type = createTask(this, model, null, !1, filterStackFrame);
778
+ environmentName.push(type);
764
779
  }
780
+ function noop() {}
765
781
  var currentRequest = null;
766
782
  function resolveRequest() {
767
783
  if (currentRequest) return currentRequest;
@@ -783,11 +799,21 @@ function serializeThenable(request, task, thenable) {
783
799
  );
784
800
  case "rejected":
785
801
  return (
786
- (task = logRecoverableError(request, thenable.reason)),
802
+ (task = logRecoverableError(request, thenable.reason, null)),
787
803
  emitErrorChunk(request, newTask.id, task),
804
+ (newTask.status = 4),
805
+ request.abortableTasks.delete(newTask),
788
806
  newTask.id
789
807
  );
790
808
  default:
809
+ if (12 === request.status)
810
+ return (
811
+ request.abortableTasks.delete(newTask),
812
+ (newTask.status = 3),
813
+ (task = stringify(serializeByValueID(request.fatalError))),
814
+ emitModelChunk(request, newTask.id, task),
815
+ newTask.id
816
+ );
791
817
  "string" !== typeof thenable.status &&
792
818
  ((thenable.status = "pending"),
793
819
  thenable.then(
@@ -808,11 +834,12 @@ function serializeThenable(request, task, thenable) {
808
834
  pingTask(request, newTask);
809
835
  },
810
836
  function (reason) {
811
- newTask.status = 4;
812
- reason = logRecoverableError(request, reason);
813
- emitErrorChunk(request, newTask.id, reason);
814
- request.abortableTasks.delete(newTask);
815
- enqueueFlush(request);
837
+ 0 === newTask.status &&
838
+ ((reason = logRecoverableError(request, reason, newTask)),
839
+ emitErrorChunk(request, newTask.id, reason),
840
+ (newTask.status = 4),
841
+ request.abortableTasks.delete(newTask),
842
+ enqueueFlush(request));
816
843
  }
817
844
  );
818
845
  return newTask.id;
@@ -821,7 +848,7 @@ function serializeReadableStream(request, task, stream) {
821
848
  function progress(entry) {
822
849
  if (!aborted)
823
850
  if (entry.done)
824
- request.abortListeners.delete(error),
851
+ request.abortListeners.delete(abortStream),
825
852
  (entry = streamTask.id.toString(16) + ":C\n"),
826
853
  request.completedRegularChunks.push(entry),
827
854
  enqueueFlush(request),
@@ -840,8 +867,18 @@ function serializeReadableStream(request, task, stream) {
840
867
  function error(reason) {
841
868
  if (!aborted) {
842
869
  aborted = !0;
843
- request.abortListeners.delete(error);
844
- var digest = logRecoverableError(request, reason);
870
+ request.abortListeners.delete(abortStream);
871
+ var digest = logRecoverableError(request, reason, streamTask);
872
+ emitErrorChunk(request, streamTask.id, digest);
873
+ enqueueFlush(request);
874
+ reader.cancel(reason).then(error, error);
875
+ }
876
+ }
877
+ function abortStream(reason) {
878
+ if (!aborted) {
879
+ aborted = !0;
880
+ request.abortListeners.delete(abortStream);
881
+ var digest = logRecoverableError(request, reason, streamTask);
845
882
  emitErrorChunk(request, streamTask.id, digest);
846
883
  enqueueFlush(request);
847
884
  reader.cancel(reason).then(error, error);
@@ -867,7 +904,7 @@ function serializeReadableStream(request, task, stream) {
867
904
  task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
868
905
  request.completedRegularChunks.push(task);
869
906
  var aborted = !1;
870
- request.abortListeners.add(error);
907
+ request.abortListeners.add(abortStream);
871
908
  reader.read().then(progress, error);
872
909
  return serializeByValueID(streamTask.id);
873
910
  }
@@ -875,7 +912,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
875
912
  function progress(entry) {
876
913
  if (!aborted)
877
914
  if (entry.done) {
878
- request.abortListeners.delete(error);
915
+ request.abortListeners.delete(abortIterable);
879
916
  if (void 0 === entry.value)
880
917
  var endStreamRow = streamTask.id.toString(16) + ":C\n";
881
918
  else
@@ -907,8 +944,19 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
907
944
  function error(reason) {
908
945
  if (!aborted) {
909
946
  aborted = !0;
910
- request.abortListeners.delete(error);
911
- var digest = logRecoverableError(request, reason);
947
+ request.abortListeners.delete(abortIterable);
948
+ var digest = logRecoverableError(request, reason, streamTask);
949
+ emitErrorChunk(request, streamTask.id, digest);
950
+ enqueueFlush(request);
951
+ "function" === typeof iterator.throw &&
952
+ iterator.throw(reason).then(error, error);
953
+ }
954
+ }
955
+ function abortIterable(reason) {
956
+ if (!aborted) {
957
+ aborted = !0;
958
+ request.abortListeners.delete(abortIterable);
959
+ var digest = logRecoverableError(request, reason, streamTask);
912
960
  emitErrorChunk(request, streamTask.id, digest);
913
961
  enqueueFlush(request);
914
962
  "function" === typeof iterator.throw &&
@@ -928,7 +976,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
928
976
  task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
929
977
  request.completedRegularChunks.push(task);
930
978
  var aborted = !1;
931
- request.abortListeners.add(error);
979
+ request.abortListeners.add(abortIterable);
932
980
  iterator.next().then(progress, error);
933
981
  return serializeByValueID(streamTask.id);
934
982
  }
@@ -967,12 +1015,22 @@ function createLazyWrapperAroundWakeable(wakeable) {
967
1015
  }
968
1016
  return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
969
1017
  }
1018
+ function voidHandler() {}
970
1019
  function renderFunctionComponent(request, task, key, Component, props) {
971
1020
  var prevThenableState = task.thenableState;
972
1021
  task.thenableState = null;
973
1022
  thenableIndexCounter = 0;
974
1023
  thenableState = prevThenableState;
975
1024
  Component = Component(props, void 0);
1025
+ if (12 === request.status)
1026
+ throw (
1027
+ ("object" === typeof Component &&
1028
+ null !== Component &&
1029
+ "function" === typeof Component.then &&
1030
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
1031
+ Component.then(voidHandler, voidHandler),
1032
+ null)
1033
+ );
976
1034
  if (
977
1035
  "object" === typeof Component &&
978
1036
  null !== Component &&
@@ -1029,66 +1087,68 @@ function renderFragment(request, task, children) {
1029
1087
  task.implicitSlot ? [request] : request)
1030
1088
  : children;
1031
1089
  }
1032
- function renderClientElement(task, type, key, props) {
1033
- var keyPath = task.keyPath;
1034
- null === key
1035
- ? (key = keyPath)
1036
- : null !== keyPath && (key = keyPath + "," + key);
1037
- type = [REACT_ELEMENT_TYPE, type, key, props];
1038
- return task.implicitSlot && null !== key ? [type] : type;
1039
- }
1040
1090
  function renderElement(request, task, type, key, ref, props) {
1041
1091
  if (null !== ref && void 0 !== ref)
1042
1092
  throw Error(
1043
1093
  "Refs cannot be used in Server Components, nor passed to Client Components."
1044
1094
  );
1045
- if ("function" === typeof type)
1046
- return type.$$typeof === CLIENT_REFERENCE_TAG$1 ||
1047
- type.$$typeof === TEMPORARY_REFERENCE_TAG
1048
- ? renderClientElement(task, type, key, props)
1049
- : renderFunctionComponent(request, task, key, type, props);
1050
- if ("string" === typeof type)
1051
- return renderClientElement(task, type, key, props);
1052
- if ("symbol" === typeof type)
1053
- return type === REACT_FRAGMENT_TYPE && null === key
1054
- ? ((key = task.implicitSlot),
1055
- null === task.keyPath && (task.implicitSlot = !0),
1056
- (request = renderModelDestructive(
1057
- request,
1058
- task,
1059
- emptyRoot,
1060
- "",
1061
- props.children
1062
- )),
1063
- (task.implicitSlot = key),
1064
- request)
1065
- : renderClientElement(task, type, key, props);
1066
- if (null != type && "object" === typeof type) {
1067
- if (type.$$typeof === CLIENT_REFERENCE_TAG$1)
1068
- return renderClientElement(task, type, key, props);
1095
+ if (
1096
+ "function" === typeof type &&
1097
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
1098
+ type.$$typeof !== TEMPORARY_REFERENCE_TAG
1099
+ )
1100
+ return renderFunctionComponent(request, task, key, type, props);
1101
+ if (type === REACT_FRAGMENT_TYPE && null === key)
1102
+ return (
1103
+ (type = task.implicitSlot),
1104
+ null === task.keyPath && (task.implicitSlot = !0),
1105
+ (props = renderModelDestructive(
1106
+ request,
1107
+ task,
1108
+ emptyRoot,
1109
+ "",
1110
+ props.children
1111
+ )),
1112
+ (task.implicitSlot = type),
1113
+ props
1114
+ );
1115
+ if (
1116
+ null != type &&
1117
+ "object" === typeof type &&
1118
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1
1119
+ )
1069
1120
  switch (type.$$typeof) {
1070
1121
  case REACT_LAZY_TYPE:
1071
1122
  var init = type._init;
1072
1123
  type = init(type._payload);
1124
+ if (12 === request.status) throw null;
1073
1125
  return renderElement(request, task, type, key, ref, props);
1074
1126
  case REACT_FORWARD_REF_TYPE:
1075
1127
  return renderFunctionComponent(request, task, key, type.render, props);
1076
1128
  case REACT_MEMO_TYPE:
1077
1129
  return renderElement(request, task, type.type, key, ref, props);
1078
1130
  }
1079
- }
1080
- throw Error(
1081
- "Unsupported Server Component type: " + describeValueForErrorMessage(type)
1082
- );
1131
+ request = key;
1132
+ key = task.keyPath;
1133
+ null === request
1134
+ ? (request = key)
1135
+ : null !== key && (request = key + "," + request);
1136
+ props = [REACT_ELEMENT_TYPE, type, request, props];
1137
+ task = task.implicitSlot && null !== request ? [props] : props;
1138
+ return task;
1083
1139
  }
1084
1140
  function pingTask(request, task) {
1085
1141
  var pingedTasks = request.pingedTasks;
1086
1142
  pingedTasks.push(task);
1087
1143
  1 === pingedTasks.length &&
1088
1144
  ((request.flushScheduled = null !== request.destination),
1089
- setImmediate(function () {
1090
- return performWork(request);
1091
- }));
1145
+ 21 === request.type || 10 === request.status
1146
+ ? scheduleMicrotask(function () {
1147
+ return performWork(request);
1148
+ })
1149
+ : setImmediate(function () {
1150
+ return performWork(request);
1151
+ }));
1092
1152
  }
1093
1153
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1094
1154
  request.pendingChunks++;
@@ -1120,19 +1180,27 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1120
1180
  );
1121
1181
  } catch (thrownValue) {
1122
1182
  if (
1123
- ((parentPropertyName =
1183
+ ((parentPropertyName = task.model),
1184
+ (parentPropertyName =
1185
+ "object" === typeof parentPropertyName &&
1186
+ null !== parentPropertyName &&
1187
+ (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1188
+ parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1189
+ 12 === request.status)
1190
+ )
1191
+ (task.status = 3),
1192
+ (prevKeyPath = request.fatalError),
1193
+ (JSCompiler_inline_result = parentPropertyName
1194
+ ? "$L" + prevKeyPath.toString(16)
1195
+ : serializeByValueID(prevKeyPath));
1196
+ else if (
1197
+ ((value =
1124
1198
  thrownValue === SuspenseException
1125
1199
  ? getSuspendedThenable()
1126
1200
  : thrownValue),
1127
- (value = task.model),
1128
- (value =
1129
- "object" === typeof value &&
1201
+ "object" === typeof value &&
1130
1202
  null !== value &&
1131
- (value.$$typeof === REACT_ELEMENT_TYPE ||
1132
- value.$$typeof === REACT_LAZY_TYPE)),
1133
- "object" === typeof parentPropertyName &&
1134
- null !== parentPropertyName &&
1135
- "function" === typeof parentPropertyName.then)
1203
+ "function" === typeof value.then)
1136
1204
  ) {
1137
1205
  JSCompiler_inline_result = createTask(
1138
1206
  request,
@@ -1142,28 +1210,24 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1142
1210
  request.abortableTasks
1143
1211
  );
1144
1212
  var ping = JSCompiler_inline_result.ping;
1145
- parentPropertyName.then(ping, ping);
1213
+ value.then(ping, ping);
1146
1214
  JSCompiler_inline_result.thenableState =
1147
1215
  getThenableStateAfterSuspending();
1148
1216
  task.keyPath = prevKeyPath;
1149
1217
  task.implicitSlot = prevImplicitSlot;
1150
- JSCompiler_inline_result = value
1218
+ JSCompiler_inline_result = parentPropertyName
1151
1219
  ? "$L" + JSCompiler_inline_result.id.toString(16)
1152
1220
  : serializeByValueID(JSCompiler_inline_result.id);
1153
- } else if (
1154
- ((task.keyPath = prevKeyPath),
1155
- (task.implicitSlot = prevImplicitSlot),
1156
- value)
1157
- )
1158
- request.pendingChunks++,
1221
+ } else
1222
+ (task.keyPath = prevKeyPath),
1223
+ (task.implicitSlot = prevImplicitSlot),
1224
+ request.pendingChunks++,
1159
1225
  (prevKeyPath = request.nextChunkId++),
1160
- (prevImplicitSlot = logRecoverableError(
1161
- request,
1162
- parentPropertyName
1163
- )),
1226
+ (prevImplicitSlot = logRecoverableError(request, value, task)),
1164
1227
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1165
- (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1166
- else throw parentPropertyName;
1228
+ (JSCompiler_inline_result = parentPropertyName
1229
+ ? "$L" + prevKeyPath.toString(16)
1230
+ : serializeByValueID(prevKeyPath));
1167
1231
  }
1168
1232
  return JSCompiler_inline_result;
1169
1233
  },
@@ -1212,8 +1276,14 @@ function serializeClientReference(
1212
1276
  '" in the React Client Manifest. This is probably a bug in the React Server Components bundler.'
1213
1277
  );
1214
1278
  }
1279
+ if (!0 === resolvedModuleData.async && !0 === clientReference.$$async)
1280
+ throw Error(
1281
+ 'The module "' +
1282
+ modulePath +
1283
+ '" 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.'
1284
+ );
1215
1285
  var JSCompiler_inline_result =
1216
- !0 === clientReference.$$async
1286
+ !0 === resolvedModuleData.async || !0 === clientReference.$$async
1217
1287
  ? [resolvedModuleData.id, resolvedModuleData.chunks, existingId, 1]
1218
1288
  : [resolvedModuleData.id, resolvedModuleData.chunks, existingId];
1219
1289
  request.pendingChunks++;
@@ -1229,7 +1299,7 @@ function serializeClientReference(
1229
1299
  return (
1230
1300
  request.pendingChunks++,
1231
1301
  (parent = request.nextChunkId++),
1232
- (parentPropertyName = logRecoverableError(request, x)),
1302
+ (parentPropertyName = logRecoverableError(request, x, null)),
1233
1303
  emitErrorChunk(request, parent, parentPropertyName),
1234
1304
  serializeByValueID(parent)
1235
1305
  );
@@ -1250,7 +1320,7 @@ function serializeBlob(request, blob) {
1250
1320
  function progress(entry) {
1251
1321
  if (!aborted)
1252
1322
  if (entry.done)
1253
- request.abortListeners.delete(error),
1323
+ request.abortListeners.delete(abortBlob),
1254
1324
  (aborted = !0),
1255
1325
  pingTask(request, newTask);
1256
1326
  else
@@ -1261,10 +1331,19 @@ function serializeBlob(request, blob) {
1261
1331
  function error(reason) {
1262
1332
  if (!aborted) {
1263
1333
  aborted = !0;
1264
- request.abortListeners.delete(error);
1265
- var digest = logRecoverableError(request, reason);
1334
+ request.abortListeners.delete(abortBlob);
1335
+ var digest = logRecoverableError(request, reason, newTask);
1336
+ emitErrorChunk(request, newTask.id, digest);
1337
+ enqueueFlush(request);
1338
+ reader.cancel(reason).then(error, error);
1339
+ }
1340
+ }
1341
+ function abortBlob(reason) {
1342
+ if (!aborted) {
1343
+ aborted = !0;
1344
+ request.abortListeners.delete(abortBlob);
1345
+ var digest = logRecoverableError(request, reason, newTask);
1266
1346
  emitErrorChunk(request, newTask.id, digest);
1267
- request.abortableTasks.delete(newTask);
1268
1347
  enqueueFlush(request);
1269
1348
  reader.cancel(reason).then(error, error);
1270
1349
  }
@@ -1273,7 +1352,7 @@ function serializeBlob(request, blob) {
1273
1352
  newTask = createTask(request, model, null, !1, request.abortableTasks),
1274
1353
  reader = blob.stream().getReader(),
1275
1354
  aborted = !1;
1276
- request.abortListeners.add(error);
1355
+ request.abortListeners.add(abortBlob);
1277
1356
  reader.read().then(progress).catch(error);
1278
1357
  return "$B" + newTask.id.toString(16);
1279
1358
  }
@@ -1291,7 +1370,8 @@ function renderModelDestructive(
1291
1370
  if ("object" === typeof value) {
1292
1371
  switch (value.$$typeof) {
1293
1372
  case REACT_ELEMENT_TYPE:
1294
- var writtenObjects = request.writtenObjects;
1373
+ var elementReference = null,
1374
+ writtenObjects = request.writtenObjects;
1295
1375
  if (null === task.keyPath && !task.implicitSlot) {
1296
1376
  var existingReference = writtenObjects.get(value);
1297
1377
  if (void 0 !== existingReference)
@@ -1301,11 +1381,12 @@ function renderModelDestructive(
1301
1381
  -1 === parentPropertyName.indexOf(":") &&
1302
1382
  ((parent = writtenObjects.get(parent)),
1303
1383
  void 0 !== parent &&
1304
- writtenObjects.set(value, parent + ":" + parentPropertyName));
1384
+ ((elementReference = parent + ":" + parentPropertyName),
1385
+ writtenObjects.set(value, elementReference)));
1305
1386
  }
1306
1387
  parentPropertyName = value.props;
1307
1388
  parent = parentPropertyName.ref;
1308
- return renderElement(
1389
+ request = renderElement(
1309
1390
  request,
1310
1391
  task,
1311
1392
  value.type,
@@ -1313,13 +1394,18 @@ function renderModelDestructive(
1313
1394
  void 0 !== parent ? parent : null,
1314
1395
  parentPropertyName
1315
1396
  );
1397
+ "object" === typeof request &&
1398
+ null !== request &&
1399
+ null !== elementReference &&
1400
+ (writtenObjects.has(request) ||
1401
+ writtenObjects.set(request, elementReference));
1402
+ return request;
1316
1403
  case REACT_LAZY_TYPE:
1317
- return (
1318
- (task.thenableState = null),
1319
- (parentPropertyName = value._init),
1320
- (value = parentPropertyName(value._payload)),
1321
- renderModelDestructive(request, task, emptyRoot, "", value)
1322
- );
1404
+ task.thenableState = null;
1405
+ parentPropertyName = value._init;
1406
+ value = parentPropertyName(value._payload);
1407
+ if (12 === request.status) throw null;
1408
+ return renderModelDestructive(request, task, emptyRoot, "", value);
1323
1409
  case REACT_LEGACY_ELEMENT_TYPE:
1324
1410
  throw Error(
1325
1411
  '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.'
@@ -1334,44 +1420,47 @@ function renderModelDestructive(
1334
1420
  );
1335
1421
  if (
1336
1422
  void 0 !== request.temporaryReferences &&
1337
- ((writtenObjects = request.temporaryReferences.get(value)),
1338
- void 0 !== writtenObjects)
1423
+ ((elementReference = request.temporaryReferences.get(value)),
1424
+ void 0 !== elementReference)
1339
1425
  )
1340
- return "$T" + writtenObjects;
1341
- writtenObjects = request.writtenObjects;
1342
- existingReference = writtenObjects.get(value);
1426
+ return "$T" + elementReference;
1427
+ elementReference = request.writtenObjects;
1428
+ writtenObjects = elementReference.get(value);
1343
1429
  if ("function" === typeof value.then) {
1344
- if (void 0 !== existingReference) {
1430
+ if (void 0 !== writtenObjects) {
1345
1431
  if (null !== task.keyPath || task.implicitSlot)
1346
1432
  return "$@" + serializeThenable(request, task, value).toString(16);
1347
1433
  if (modelRoot === value) modelRoot = null;
1348
- else return existingReference;
1434
+ else return writtenObjects;
1349
1435
  }
1350
1436
  request = "$@" + serializeThenable(request, task, value).toString(16);
1351
- writtenObjects.set(value, request);
1437
+ elementReference.set(value, request);
1352
1438
  return request;
1353
1439
  }
1354
- if (void 0 !== existingReference)
1440
+ if (void 0 !== writtenObjects)
1355
1441
  if (modelRoot === value) modelRoot = null;
1356
- else return existingReference;
1442
+ else return writtenObjects;
1357
1443
  else if (
1358
1444
  -1 === parentPropertyName.indexOf(":") &&
1359
- ((existingReference = writtenObjects.get(parent)),
1360
- void 0 !== existingReference)
1445
+ ((writtenObjects = elementReference.get(parent)),
1446
+ void 0 !== writtenObjects)
1361
1447
  ) {
1362
- var propertyName = parentPropertyName;
1448
+ existingReference = parentPropertyName;
1363
1449
  if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1364
1450
  switch (parentPropertyName) {
1365
1451
  case "1":
1366
- propertyName = "type";
1452
+ existingReference = "type";
1367
1453
  break;
1368
1454
  case "2":
1369
- propertyName = "key";
1455
+ existingReference = "key";
1370
1456
  break;
1371
1457
  case "3":
1372
- propertyName = "props";
1458
+ existingReference = "props";
1459
+ break;
1460
+ case "4":
1461
+ existingReference = "_owner";
1373
1462
  }
1374
- writtenObjects.set(value, existingReference + ":" + propertyName);
1463
+ elementReference.set(value, writtenObjects + ":" + existingReference);
1375
1464
  }
1376
1465
  if (isArrayImpl(value)) return renderFragment(request, task, value);
1377
1466
  if (value instanceof Map)
@@ -1389,6 +1478,7 @@ function renderModelDestructive(
1389
1478
  (value = Array.from(value.entries())),
1390
1479
  "$K" + outlineModel(request, value).toString(16)
1391
1480
  );
1481
+ if (value instanceof Error) return "$Z";
1392
1482
  if (value instanceof ArrayBuffer)
1393
1483
  return serializeTypedArray(request, "A", new Uint8Array(value));
1394
1484
  if (value instanceof Int8Array)
@@ -1417,9 +1507,9 @@ function renderModelDestructive(
1417
1507
  return serializeTypedArray(request, "V", value);
1418
1508
  if ("function" === typeof Blob && value instanceof Blob)
1419
1509
  return serializeBlob(request, value);
1420
- if ((parentPropertyName = getIteratorFn(value)))
1510
+ if ((elementReference = getIteratorFn(value)))
1421
1511
  return (
1422
- (parentPropertyName = parentPropertyName.call(value)),
1512
+ (parentPropertyName = elementReference.call(value)),
1423
1513
  parentPropertyName === value
1424
1514
  ? "$i" +
1425
1515
  outlineModel(request, Array.from(parentPropertyName)).toString(16)
@@ -1427,8 +1517,8 @@ function renderModelDestructive(
1427
1517
  );
1428
1518
  if ("function" === typeof ReadableStream && value instanceof ReadableStream)
1429
1519
  return serializeReadableStream(request, task, value);
1430
- parentPropertyName = value[ASYNC_ITERATOR];
1431
- if ("function" === typeof parentPropertyName)
1520
+ elementReference = value[ASYNC_ITERATOR];
1521
+ if ("function" === typeof elementReference)
1432
1522
  return (
1433
1523
  null !== task.keyPath
1434
1524
  ? ((request = [
@@ -1438,7 +1528,7 @@ function renderModelDestructive(
1438
1528
  { children: value }
1439
1529
  ]),
1440
1530
  (request = task.implicitSlot ? [request] : request))
1441
- : ((parentPropertyName = parentPropertyName.call(value)),
1531
+ : ((parentPropertyName = elementReference.call(value)),
1442
1532
  (request = serializeAsyncIterable(
1443
1533
  request,
1444
1534
  task,
@@ -1447,13 +1537,15 @@ function renderModelDestructive(
1447
1537
  ))),
1448
1538
  request
1449
1539
  );
1540
+ if (value instanceof Date) return "$D" + value.toJSON();
1450
1541
  request = getPrototypeOf(value);
1451
1542
  if (
1452
1543
  request !== ObjectPrototype &&
1453
1544
  (null === request || null !== getPrototypeOf(request))
1454
1545
  )
1455
1546
  throw Error(
1456
- "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported."
1547
+ "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." +
1548
+ describeObjectForErrorMessage(parent, parentPropertyName)
1457
1549
  );
1458
1550
  return value;
1459
1551
  }
@@ -1463,7 +1555,7 @@ function renderModelDestructive(
1463
1555
  parent[parentPropertyName] instanceof Date
1464
1556
  )
1465
1557
  return "$D" + value;
1466
- if (1024 <= value.length)
1558
+ if (1024 <= value.length && null !== byteLengthOfChunk)
1467
1559
  return (
1468
1560
  request.pendingChunks++,
1469
1561
  (task = request.nextChunkId++),
@@ -1480,10 +1572,10 @@ function renderModelDestructive(
1480
1572
  ? "$-0"
1481
1573
  : value
1482
1574
  : Infinity === value
1483
- ? "$Infinity"
1484
- : -Infinity === value
1485
- ? "$-Infinity"
1486
- : "$NaN";
1575
+ ? "$Infinity"
1576
+ : -Infinity === value
1577
+ ? "$-Infinity"
1578
+ : "$NaN";
1487
1579
  if ("undefined" === typeof value) return "$undefined";
1488
1580
  if ("function" === typeof value) {
1489
1581
  if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
@@ -1500,13 +1592,14 @@ function renderModelDestructive(
1500
1592
  void 0 !== parentPropertyName
1501
1593
  ? (request = "$F" + parentPropertyName.toString(16))
1502
1594
  : ((parentPropertyName = value.$$bound),
1503
- (parentPropertyName = {
1595
+ (parentPropertyName =
1596
+ null === parentPropertyName
1597
+ ? null
1598
+ : Promise.resolve(parentPropertyName)),
1599
+ (request = outlineModel(request, {
1504
1600
  id: value.$$id,
1505
1601
  bound: parentPropertyName
1506
- ? Promise.resolve(parentPropertyName)
1507
- : null
1508
- }),
1509
- (request = outlineModel(request, parentPropertyName)),
1602
+ })),
1510
1603
  task.set(value, request),
1511
1604
  (request = "$F" + request.toString(16))),
1512
1605
  request
@@ -1533,10 +1626,11 @@ function renderModelDestructive(
1533
1626
  }
1534
1627
  if ("symbol" === typeof value) {
1535
1628
  task = request.writtenSymbols;
1536
- writtenObjects = task.get(value);
1537
- if (void 0 !== writtenObjects) return serializeByValueID(writtenObjects);
1538
- writtenObjects = value.description;
1539
- if (Symbol.for(writtenObjects) !== value)
1629
+ elementReference = task.get(value);
1630
+ if (void 0 !== elementReference)
1631
+ return serializeByValueID(elementReference);
1632
+ elementReference = value.description;
1633
+ if (Symbol.for(elementReference) !== value)
1540
1634
  throw Error(
1541
1635
  "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1542
1636
  (value.description + ") cannot be found among global symbols.") +
@@ -1547,7 +1641,7 @@ function renderModelDestructive(
1547
1641
  parent = encodeReferenceChunk(
1548
1642
  request,
1549
1643
  parentPropertyName,
1550
- "$S" + writtenObjects
1644
+ "$S" + elementReference
1551
1645
  );
1552
1646
  request.completedImportChunks.push(parent);
1553
1647
  task.set(value, parentPropertyName);
@@ -1578,15 +1672,21 @@ function logRecoverableError(request, error) {
1578
1672
  return errorDigest || "";
1579
1673
  }
1580
1674
  function fatalError(request, error) {
1675
+ var onFatalError = request.onFatalError;
1676
+ onFatalError(error);
1581
1677
  null !== request.destination
1582
- ? ((request.status = 2), request.destination.destroy(error))
1583
- : ((request.status = 1), (request.fatalError = error));
1678
+ ? ((request.status = 14), request.destination.destroy(error))
1679
+ : ((request.status = 13), (request.fatalError = error));
1584
1680
  }
1585
1681
  function emitErrorChunk(request, id, digest) {
1586
1682
  digest = { digest: digest };
1587
1683
  id = id.toString(16) + ":E" + stringify(digest) + "\n";
1588
1684
  request.completedErrorChunks.push(id);
1589
1685
  }
1686
+ function emitModelChunk(request, id, json) {
1687
+ id = id.toString(16) + ":" + json + "\n";
1688
+ request.completedRegularChunks.push(id);
1689
+ }
1590
1690
  function emitTypedArrayChunk(request, id, tag, typedArray) {
1591
1691
  request.pendingChunks++;
1592
1692
  typedArray = new Uint8Array(
@@ -1599,51 +1699,52 @@ function emitTypedArrayChunk(request, id, tag, typedArray) {
1599
1699
  request.completedRegularChunks.push(id, typedArray);
1600
1700
  }
1601
1701
  function emitTextChunk(request, id, text) {
1702
+ if (null === byteLengthOfChunk)
1703
+ throw Error(
1704
+ "Existence of byteLengthOfChunk should have already been checked. This is a bug in React."
1705
+ );
1602
1706
  request.pendingChunks++;
1603
- var binaryLength =
1604
- "string" === typeof text
1605
- ? Buffer.byteLength(text, "utf8")
1606
- : text.byteLength;
1707
+ var binaryLength = byteLengthOfChunk(text);
1607
1708
  id = id.toString(16) + ":T" + binaryLength.toString(16) + ",";
1608
1709
  request.completedRegularChunks.push(id, text);
1609
1710
  }
1610
1711
  function emitChunk(request, task, value) {
1611
1712
  var id = task.id;
1612
- "string" === typeof value
1713
+ "string" === typeof value && null !== byteLengthOfChunk
1613
1714
  ? emitTextChunk(request, id, value)
1614
1715
  : value instanceof ArrayBuffer
1615
- ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1616
- : value instanceof Int8Array
1617
- ? emitTypedArrayChunk(request, id, "O", value)
1618
- : value instanceof Uint8Array
1619
- ? emitTypedArrayChunk(request, id, "o", value)
1620
- : value instanceof Uint8ClampedArray
1621
- ? emitTypedArrayChunk(request, id, "U", value)
1622
- : value instanceof Int16Array
1623
- ? emitTypedArrayChunk(request, id, "S", value)
1624
- : value instanceof Uint16Array
1625
- ? emitTypedArrayChunk(request, id, "s", value)
1626
- : value instanceof Int32Array
1627
- ? emitTypedArrayChunk(request, id, "L", value)
1628
- : value instanceof Uint32Array
1629
- ? emitTypedArrayChunk(request, id, "l", value)
1630
- : value instanceof Float32Array
1631
- ? emitTypedArrayChunk(request, id, "G", value)
1632
- : value instanceof Float64Array
1633
- ? emitTypedArrayChunk(request, id, "g", value)
1634
- : value instanceof BigInt64Array
1635
- ? emitTypedArrayChunk(request, id, "M", value)
1636
- : value instanceof BigUint64Array
1637
- ? emitTypedArrayChunk(request, id, "m", value)
1638
- : value instanceof DataView
1639
- ? emitTypedArrayChunk(request, id, "V", value)
1640
- : ((value = stringify(value, task.toJSON)),
1641
- (task = task.id.toString(16) + ":" + value + "\n"),
1642
- request.completedRegularChunks.push(task));
1716
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1717
+ : value instanceof Int8Array
1718
+ ? emitTypedArrayChunk(request, id, "O", value)
1719
+ : value instanceof Uint8Array
1720
+ ? emitTypedArrayChunk(request, id, "o", value)
1721
+ : value instanceof Uint8ClampedArray
1722
+ ? emitTypedArrayChunk(request, id, "U", value)
1723
+ : value instanceof Int16Array
1724
+ ? emitTypedArrayChunk(request, id, "S", value)
1725
+ : value instanceof Uint16Array
1726
+ ? emitTypedArrayChunk(request, id, "s", value)
1727
+ : value instanceof Int32Array
1728
+ ? emitTypedArrayChunk(request, id, "L", value)
1729
+ : value instanceof Uint32Array
1730
+ ? emitTypedArrayChunk(request, id, "l", value)
1731
+ : value instanceof Float32Array
1732
+ ? emitTypedArrayChunk(request, id, "G", value)
1733
+ : value instanceof Float64Array
1734
+ ? emitTypedArrayChunk(request, id, "g", value)
1735
+ : value instanceof BigInt64Array
1736
+ ? emitTypedArrayChunk(request, id, "M", value)
1737
+ : value instanceof BigUint64Array
1738
+ ? emitTypedArrayChunk(request, id, "m", value)
1739
+ : value instanceof DataView
1740
+ ? emitTypedArrayChunk(request, id, "V", value)
1741
+ : ((value = stringify(value, task.toJSON)),
1742
+ emitModelChunk(request, task.id, value));
1643
1743
  }
1644
1744
  var emptyRoot = {};
1645
1745
  function retryTask(request, task) {
1646
- if (0 === task.status)
1746
+ if (0 === task.status) {
1747
+ task.status = 5;
1647
1748
  try {
1648
1749
  modelRoot = task.model;
1649
1750
  var resolvedModel = renderModelDestructive(
@@ -1660,35 +1761,48 @@ function retryTask(request, task) {
1660
1761
  request.writtenObjects.set(resolvedModel, serializeByValueID(task.id)),
1661
1762
  emitChunk(request, task, resolvedModel);
1662
1763
  else {
1663
- var json = stringify(resolvedModel),
1664
- processedChunk = task.id.toString(16) + ":" + json + "\n";
1665
- request.completedRegularChunks.push(processedChunk);
1764
+ var json = stringify(resolvedModel);
1765
+ emitModelChunk(request, task.id, json);
1666
1766
  }
1667
1767
  request.abortableTasks.delete(task);
1668
1768
  task.status = 1;
1669
1769
  } catch (thrownValue) {
1670
- var x =
1671
- thrownValue === SuspenseException
1672
- ? getSuspendedThenable()
1673
- : thrownValue;
1674
- if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1675
- var ping = task.ping;
1676
- x.then(ping, ping);
1677
- task.thenableState = getThenableStateAfterSuspending();
1678
- } else {
1770
+ if (12 === request.status) {
1679
1771
  request.abortableTasks.delete(task);
1680
- task.status = 4;
1681
- var digest = logRecoverableError(request, x);
1682
- emitErrorChunk(request, task.id, digest);
1772
+ task.status = 3;
1773
+ var model = stringify(serializeByValueID(request.fatalError));
1774
+ emitModelChunk(request, task.id, model);
1775
+ } else {
1776
+ var x =
1777
+ thrownValue === SuspenseException
1778
+ ? getSuspendedThenable()
1779
+ : thrownValue;
1780
+ if (
1781
+ "object" === typeof x &&
1782
+ null !== x &&
1783
+ "function" === typeof x.then
1784
+ ) {
1785
+ task.status = 0;
1786
+ task.thenableState = getThenableStateAfterSuspending();
1787
+ var ping = task.ping;
1788
+ x.then(ping, ping);
1789
+ } else {
1790
+ request.abortableTasks.delete(task);
1791
+ task.status = 4;
1792
+ var digest = logRecoverableError(request, x, task);
1793
+ emitErrorChunk(request, task.id, digest);
1794
+ }
1683
1795
  }
1684
1796
  } finally {
1685
1797
  }
1798
+ }
1686
1799
  }
1687
1800
  function performWork(request) {
1688
1801
  var prevDispatcher = ReactSharedInternalsServer.H;
1689
1802
  ReactSharedInternalsServer.H = HooksDispatcher;
1690
1803
  var prevRequest = currentRequest;
1691
1804
  currentRequest$1 = currentRequest = request;
1805
+ var hadAbortableTasks = 0 < request.abortableTasks.size;
1692
1806
  try {
1693
1807
  var pingedTasks = request.pingedTasks;
1694
1808
  request.pingedTasks = [];
@@ -1696,8 +1810,12 @@ function performWork(request) {
1696
1810
  retryTask(request, pingedTasks[i]);
1697
1811
  null !== request.destination &&
1698
1812
  flushCompletedChunks(request, request.destination);
1813
+ if (hadAbortableTasks && 0 === request.abortableTasks.size) {
1814
+ var onAllReady = request.onAllReady;
1815
+ onAllReady();
1816
+ }
1699
1817
  } catch (error) {
1700
- logRecoverableError(request, error), fatalError(request, error);
1818
+ logRecoverableError(request, error, null), fatalError(request, error);
1701
1819
  } finally {
1702
1820
  (ReactSharedInternalsServer.H = prevDispatcher),
1703
1821
  (currentRequest$1 = null),
@@ -1764,74 +1882,89 @@ function flushCompletedChunks(request, destination) {
1764
1882
  }
1765
1883
  "function" === typeof destination.flush && destination.flush();
1766
1884
  0 === request.pendingChunks &&
1767
- (destination.end(), (request.destination = null));
1885
+ ((request.status = 14), destination.end(), (request.destination = null));
1768
1886
  }
1769
1887
  function startWork(request) {
1770
1888
  request.flushScheduled = null !== request.destination;
1889
+ scheduleMicrotask(function () {
1890
+ requestStorage.run(request, performWork, request);
1891
+ });
1771
1892
  setImmediate(function () {
1772
- return requestStorage.run(request, performWork, request);
1893
+ 10 === request.status && (request.status = 11);
1773
1894
  });
1774
1895
  }
1775
1896
  function enqueueFlush(request) {
1776
- if (
1777
- !1 === request.flushScheduled &&
1897
+ !1 === request.flushScheduled &&
1778
1898
  0 === request.pingedTasks.length &&
1779
- null !== request.destination
1780
- ) {
1781
- var destination = request.destination;
1782
- request.flushScheduled = !0;
1899
+ null !== request.destination &&
1900
+ ((request.flushScheduled = !0),
1783
1901
  setImmediate(function () {
1784
- return flushCompletedChunks(request, destination);
1785
- });
1786
- }
1902
+ request.flushScheduled = !1;
1903
+ var destination = request.destination;
1904
+ destination && flushCompletedChunks(request, destination);
1905
+ }));
1787
1906
  }
1788
1907
  function startFlowing(request, destination) {
1789
- if (1 === request.status)
1790
- (request.status = 2), destination.destroy(request.fatalError);
1791
- else if (2 !== request.status && null === request.destination) {
1908
+ if (13 === request.status)
1909
+ (request.status = 14), destination.destroy(request.fatalError);
1910
+ else if (14 !== request.status && null === request.destination) {
1792
1911
  request.destination = destination;
1793
1912
  try {
1794
1913
  flushCompletedChunks(request, destination);
1795
1914
  } catch (error) {
1796
- logRecoverableError(request, error), fatalError(request, error);
1915
+ logRecoverableError(request, error, null), fatalError(request, error);
1797
1916
  }
1798
1917
  }
1799
1918
  }
1800
1919
  function abort(request, reason) {
1801
1920
  try {
1921
+ 11 >= request.status && (request.status = 12);
1802
1922
  var abortableTasks = request.abortableTasks;
1803
1923
  if (0 < abortableTasks.size) {
1804
- request.pendingChunks++;
1805
- var errorId = request.nextChunkId++,
1806
- error =
1924
+ var error =
1807
1925
  void 0 === reason
1808
1926
  ? Error("The render was aborted by the server without a reason.")
1809
- : reason,
1810
- digest = logRecoverableError(request, error);
1927
+ : "object" === typeof reason &&
1928
+ null !== reason &&
1929
+ "function" === typeof reason.then
1930
+ ? Error("The render was aborted by the server with a promise.")
1931
+ : reason,
1932
+ digest = logRecoverableError(request, error, null),
1933
+ errorId = request.nextChunkId++;
1934
+ request.fatalError = errorId;
1935
+ request.pendingChunks++;
1811
1936
  emitErrorChunk(request, errorId, digest, error);
1812
1937
  abortableTasks.forEach(function (task) {
1813
- task.status = 3;
1814
- var ref = serializeByValueID(errorId);
1815
- task = encodeReferenceChunk(request, task.id, ref);
1816
- request.completedErrorChunks.push(task);
1938
+ if (5 !== task.status) {
1939
+ task.status = 3;
1940
+ var ref = serializeByValueID(errorId);
1941
+ task = encodeReferenceChunk(request, task.id, ref);
1942
+ request.completedErrorChunks.push(task);
1943
+ }
1817
1944
  });
1818
1945
  abortableTasks.clear();
1946
+ var onAllReady = request.onAllReady;
1947
+ onAllReady();
1819
1948
  }
1820
1949
  var abortListeners = request.abortListeners;
1821
1950
  if (0 < abortListeners.size) {
1822
- var error$22 =
1951
+ var error$23 =
1823
1952
  void 0 === reason
1824
1953
  ? Error("The render was aborted by the server without a reason.")
1825
- : reason;
1954
+ : "object" === typeof reason &&
1955
+ null !== reason &&
1956
+ "function" === typeof reason.then
1957
+ ? Error("The render was aborted by the server with a promise.")
1958
+ : reason;
1826
1959
  abortListeners.forEach(function (callback) {
1827
- return callback(error$22);
1960
+ return callback(error$23);
1828
1961
  });
1829
1962
  abortListeners.clear();
1830
1963
  }
1831
1964
  null !== request.destination &&
1832
1965
  flushCompletedChunks(request, request.destination);
1833
- } catch (error$23) {
1834
- logRecoverableError(request, error$23), fatalError(request, error$23);
1966
+ } catch (error$24) {
1967
+ logRecoverableError(request, error$24, null), fatalError(request, error$24);
1835
1968
  }
1836
1969
  }
1837
1970
  function resolveServerReference(bundlerConfig, id) {
@@ -1850,7 +1983,9 @@ function resolveServerReference(bundlerConfig, id) {
1850
1983
  '" in the React Server Manifest. This is probably a bug in the React Server Components bundler.'
1851
1984
  );
1852
1985
  }
1853
- return [resolvedModuleData.id, resolvedModuleData.chunks, name];
1986
+ return resolvedModuleData.async
1987
+ ? [resolvedModuleData.id, resolvedModuleData.chunks, name, 1]
1988
+ : [resolvedModuleData.id, resolvedModuleData.chunks, name];
1854
1989
  }
1855
1990
  var chunkCache = new Map();
1856
1991
  function requireAsyncModule(id) {
@@ -1890,8 +2025,8 @@ function preloadModule(metadata) {
1890
2025
  return requireAsyncModule(metadata[0]);
1891
2026
  })
1892
2027
  : 0 < promises.length
1893
- ? Promise.all(promises)
1894
- : null;
2028
+ ? Promise.all(promises)
2029
+ : null;
1895
2030
  }
1896
2031
  function requireModule(metadata) {
1897
2032
  var moduleExports = __webpack_require__(metadata[0]);
@@ -1902,10 +2037,10 @@ function requireModule(metadata) {
1902
2037
  return "*" === metadata[2]
1903
2038
  ? moduleExports
1904
2039
  : "" === metadata[2]
1905
- ? moduleExports.__esModule
1906
- ? moduleExports.default
1907
- : moduleExports
1908
- : moduleExports[metadata[2]];
2040
+ ? moduleExports.__esModule
2041
+ ? moduleExports.default
2042
+ : moduleExports
2043
+ : moduleExports[metadata[2]];
1909
2044
  }
1910
2045
  var hasOwnProperty = Object.prototype.hasOwnProperty;
1911
2046
  function Chunk(status, value, reason, response) {
@@ -2274,8 +2409,8 @@ function parseReadableStream(response, reference, type) {
2274
2409
  (previousBlockedChunk = chunk));
2275
2410
  } else {
2276
2411
  chunk = previousBlockedChunk;
2277
- var chunk$26 = createPendingChunk(response);
2278
- chunk$26.then(
2412
+ var chunk$27 = createPendingChunk(response);
2413
+ chunk$27.then(
2279
2414
  function (v) {
2280
2415
  return controller.enqueue(v);
2281
2416
  },
@@ -2283,10 +2418,10 @@ function parseReadableStream(response, reference, type) {
2283
2418
  return controller.error(e);
2284
2419
  }
2285
2420
  );
2286
- previousBlockedChunk = chunk$26;
2421
+ previousBlockedChunk = chunk$27;
2287
2422
  chunk.then(function () {
2288
- previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2289
- resolveModelChunk(chunk$26, json, -1);
2423
+ previousBlockedChunk === chunk$27 && (previousBlockedChunk = null);
2424
+ resolveModelChunk(chunk$27, json, -1);
2290
2425
  });
2291
2426
  }
2292
2427
  },
@@ -2539,10 +2674,10 @@ function loadServerReference(bundlerConfig, id, bound) {
2539
2674
  return fn.bind.apply(fn, [null].concat(_ref));
2540
2675
  })
2541
2676
  : bundlerConfig
2542
- ? Promise.resolve(bundlerConfig).then(function () {
2543
- return requireModule(serverReference);
2544
- })
2545
- : Promise.resolve(requireModule(serverReference));
2677
+ ? Promise.resolve(bundlerConfig).then(function () {
2678
+ return requireModule(serverReference);
2679
+ })
2680
+ : Promise.resolve(requireModule(serverReference));
2546
2681
  }
2547
2682
  function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
2548
2683
  body = createResponse(serverManifest, formFieldPrefix, void 0, body);
@@ -2692,14 +2827,18 @@ exports.registerServerReference = function (reference, id, exportName) {
2692
2827
  });
2693
2828
  };
2694
2829
  exports.renderToPipeableStream = function (model, webpackMap, options) {
2695
- var request = createRequest(
2830
+ var request = new RequestInstance(
2831
+ 20,
2696
2832
  model,
2697
2833
  webpackMap,
2698
2834
  options ? options.onError : void 0,
2699
2835
  options ? options.identifierPrefix : void 0,
2700
2836
  options ? options.onPostpone : void 0,
2701
- options ? options.environmentName : void 0,
2702
- options ? options.temporaryReferences : void 0
2837
+ options ? options.temporaryReferences : void 0,
2838
+ void 0,
2839
+ void 0,
2840
+ noop,
2841
+ noop
2703
2842
  ),
2704
2843
  hasStartedFlowing = !1;
2705
2844
  startWork(request);