react-server-dom-webpack 19.0.0-beta-04b058868c-20240508 → 19.0.0-beta-9d76c954cf-20240510

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.
@@ -39,6 +39,9 @@ function writeChunkAndReturn(destination, chunk) {
39
39
  return !0;
40
40
  }
41
41
  var textEncoder = new TextEncoder();
42
+ function stringToChunk(content) {
43
+ return textEncoder.encode(content);
44
+ }
42
45
  function closeWithError(destination, error) {
43
46
  "function" === typeof destination.error
44
47
  ? destination.error(error)
@@ -352,10 +355,6 @@ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
352
355
  switch (name) {
353
356
  case "$$typeof":
354
357
  return target.$$typeof;
355
- case "$$id":
356
- return target.$$id;
357
- case "$$async":
358
- return target.$$async;
359
358
  case "name":
360
359
  return;
361
360
  case "displayName":
@@ -385,18 +384,21 @@ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
385
384
  );
386
385
  }
387
386
  };
388
- function createTemporaryReference(id) {
389
- id = Object.defineProperties(
387
+ function createTemporaryReference(temporaryReferences, id) {
388
+ var reference = Object.defineProperties(
390
389
  function () {
391
390
  throw Error(
392
391
  "Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component."
393
392
  );
394
393
  },
395
- { $$typeof: { value: TEMPORARY_REFERENCE_TAG }, $$id: { value: id } }
394
+ { $$typeof: { value: TEMPORARY_REFERENCE_TAG } }
396
395
  );
397
- return new Proxy(id, proxyHandlers);
396
+ reference = new Proxy(reference, proxyHandlers);
397
+ temporaryReferences.set(reference, id);
398
+ return reference;
398
399
  }
399
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
400
+ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
401
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
400
402
  REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
401
403
  REACT_CONTEXT_TYPE = Symbol.for("react.context"),
402
404
  REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
@@ -414,9 +416,10 @@ function getIteratorFn(maybeIterable) {
414
416
  maybeIterable["@@iterator"];
415
417
  return "function" === typeof maybeIterable ? maybeIterable : null;
416
418
  }
417
- var SuspenseException = Error(
418
- "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`"
419
- );
419
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
420
+ SuspenseException = Error(
421
+ "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
+ );
420
423
  function noop() {}
421
424
  function trackUsedThenable(thenableState, thenable, index) {
422
425
  index = thenableState[index];
@@ -684,7 +687,9 @@ function createRequest(
684
687
  bundlerConfig,
685
688
  onError,
686
689
  identifierPrefix,
687
- onPostpone
690
+ onPostpone,
691
+ environmentName,
692
+ temporaryReferences
688
693
  ) {
689
694
  if (
690
695
  null !== ReactSharedInternalsServer.A &&
@@ -692,9 +697,9 @@ function createRequest(
692
697
  )
693
698
  throw Error("Currently React only supports one RSC renderer at a time.");
694
699
  ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
695
- var abortSet = new Set(),
696
- pingedTasks = [],
697
- hints = new Set();
700
+ var abortSet = new Set();
701
+ environmentName = [];
702
+ var hints = new Set();
698
703
  bundlerConfig = {
699
704
  status: 0,
700
705
  flushScheduled: !1,
@@ -707,7 +712,7 @@ function createRequest(
707
712
  hints: hints,
708
713
  abortListeners: new Set(),
709
714
  abortableTasks: abortSet,
710
- pingedTasks: pingedTasks,
715
+ pingedTasks: environmentName,
711
716
  completedImportChunks: [],
712
717
  completedHintChunks: [],
713
718
  completedRegularChunks: [],
@@ -716,6 +721,7 @@ function createRequest(
716
721
  writtenClientReferences: new Map(),
717
722
  writtenServerReferences: new Map(),
718
723
  writtenObjects: new WeakMap(),
724
+ temporaryReferences: temporaryReferences,
719
725
  identifierPrefix: identifierPrefix || "",
720
726
  identifierCount: 1,
721
727
  taintCleanupQueue: [],
@@ -723,7 +729,7 @@ function createRequest(
723
729
  onPostpone: void 0 === onPostpone ? defaultPostponeHandler : onPostpone
724
730
  };
725
731
  model = createTask(bundlerConfig, model, null, !1, abortSet);
726
- pingedTasks.push(model);
732
+ environmentName.push(model);
727
733
  return bundlerConfig;
728
734
  }
729
735
  var currentRequest = null;
@@ -784,12 +790,127 @@ function serializeThenable(request, task, thenable) {
784
790
  );
785
791
  return newTask.id;
786
792
  }
793
+ function serializeReadableStream(request, task, stream) {
794
+ function progress(entry) {
795
+ if (!aborted)
796
+ if (entry.done)
797
+ request.abortListeners.delete(error),
798
+ (entry = streamTask.id.toString(16) + ":C\n"),
799
+ request.completedRegularChunks.push(stringToChunk(entry)),
800
+ enqueueFlush(request),
801
+ (aborted = !0);
802
+ else
803
+ try {
804
+ (streamTask.model = entry.value),
805
+ request.pendingChunks++,
806
+ emitChunk(request, streamTask, streamTask.model),
807
+ enqueueFlush(request),
808
+ reader.read().then(progress, error);
809
+ } catch (x$8) {
810
+ error(x$8);
811
+ }
812
+ }
813
+ function error(reason) {
814
+ if (!aborted) {
815
+ aborted = !0;
816
+ request.abortListeners.delete(error);
817
+ var digest = logRecoverableError(request, reason);
818
+ emitErrorChunk(request, streamTask.id, digest);
819
+ enqueueFlush(request);
820
+ reader.cancel(reason).then(error, error);
821
+ }
822
+ }
823
+ var supportsBYOB = stream.supportsBYOB;
824
+ if (void 0 === supportsBYOB)
825
+ try {
826
+ stream.getReader({ mode: "byob" }).releaseLock(), (supportsBYOB = !0);
827
+ } catch (x) {
828
+ supportsBYOB = !1;
829
+ }
830
+ var reader = stream.getReader(),
831
+ streamTask = createTask(
832
+ request,
833
+ task.model,
834
+ task.keyPath,
835
+ task.implicitSlot,
836
+ request.abortableTasks
837
+ );
838
+ request.abortableTasks.delete(streamTask);
839
+ request.pendingChunks++;
840
+ task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
841
+ request.completedRegularChunks.push(stringToChunk(task));
842
+ var aborted = !1;
843
+ request.abortListeners.add(error);
844
+ reader.read().then(progress, error);
845
+ return serializeByValueID(streamTask.id);
846
+ }
847
+ function serializeAsyncIterable(request, task, iterable, iterator) {
848
+ function progress(entry) {
849
+ if (!aborted)
850
+ if (entry.done) {
851
+ request.abortListeners.delete(error);
852
+ if (void 0 === entry.value)
853
+ var endStreamRow = streamTask.id.toString(16) + ":C\n";
854
+ else
855
+ try {
856
+ var chunkId = outlineModel(request, entry.value);
857
+ endStreamRow =
858
+ streamTask.id.toString(16) +
859
+ ":C" +
860
+ stringify(serializeByValueID(chunkId)) +
861
+ "\n";
862
+ } catch (x) {
863
+ error(x);
864
+ return;
865
+ }
866
+ request.completedRegularChunks.push(stringToChunk(endStreamRow));
867
+ enqueueFlush(request);
868
+ aborted = !0;
869
+ } else
870
+ try {
871
+ (streamTask.model = entry.value),
872
+ request.pendingChunks++,
873
+ emitChunk(request, streamTask, streamTask.model),
874
+ enqueueFlush(request),
875
+ iterator.next().then(progress, error);
876
+ } catch (x$9) {
877
+ error(x$9);
878
+ }
879
+ }
880
+ function error(reason) {
881
+ if (!aborted) {
882
+ aborted = !0;
883
+ request.abortListeners.delete(error);
884
+ var digest = logRecoverableError(request, reason);
885
+ emitErrorChunk(request, streamTask.id, digest);
886
+ enqueueFlush(request);
887
+ "function" === typeof iterator.throw &&
888
+ iterator.throw(reason).then(error, error);
889
+ }
890
+ }
891
+ iterable = iterable === iterator;
892
+ var streamTask = createTask(
893
+ request,
894
+ task.model,
895
+ task.keyPath,
896
+ task.implicitSlot,
897
+ request.abortableTasks
898
+ );
899
+ request.abortableTasks.delete(streamTask);
900
+ request.pendingChunks++;
901
+ task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
902
+ request.completedRegularChunks.push(stringToChunk(task));
903
+ var aborted = !1;
904
+ request.abortListeners.add(error);
905
+ iterator.next().then(progress, error);
906
+ return serializeByValueID(streamTask.id);
907
+ }
787
908
  function emitHint(request, code, model) {
788
909
  model = stringify(model);
789
910
  var id = request.nextChunkId++;
790
911
  code = "H" + code;
791
912
  code = id.toString(16) + ":" + code;
792
- model = textEncoder.encode(code + model + "\n");
913
+ model = stringToChunk(code + model + "\n");
793
914
  request.completedHintChunks.push(model);
794
915
  enqueueFlush(request);
795
916
  }
@@ -841,6 +962,20 @@ function renderFunctionComponent(request, task, key, Component, props) {
841
962
  return iteratorFn.call(iterableChild);
842
963
  }),
843
964
  Component);
965
+ } else if (
966
+ !(
967
+ "function" !== typeof Component[ASYNC_ITERATOR] ||
968
+ ("function" === typeof ReadableStream &&
969
+ Component instanceof ReadableStream)
970
+ )
971
+ ) {
972
+ var iterableChild$10 = Component;
973
+ Component = {};
974
+ Component =
975
+ ((Component[ASYNC_ITERATOR] = function () {
976
+ return iterableChild$10[ASYNC_ITERATOR]();
977
+ }),
978
+ Component);
844
979
  }
845
980
  }
846
981
  props = task.keyPath;
@@ -932,7 +1067,7 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
932
1067
  null === model ||
933
1068
  null !== keyPath ||
934
1069
  implicitSlot ||
935
- request.writtenObjects.set(model, id);
1070
+ request.writtenObjects.set(model, serializeByValueID(id));
936
1071
  var task = {
937
1072
  id: id,
938
1073
  status: 0,
@@ -1013,7 +1148,7 @@ function serializeByValueID(id) {
1013
1148
  function encodeReferenceChunk(request, id, reference) {
1014
1149
  request = stringify(reference);
1015
1150
  id = id.toString(16) + ":" + request + "\n";
1016
- return textEncoder.encode(id);
1151
+ return stringToChunk(id);
1017
1152
  }
1018
1153
  function serializeClientReference(
1019
1154
  request,
@@ -1056,7 +1191,7 @@ function serializeClientReference(
1056
1191
  var importId = request.nextChunkId++,
1057
1192
  json = stringify(JSCompiler_inline_result),
1058
1193
  row = importId.toString(16) + ":I" + json + "\n",
1059
- processedChunk = textEncoder.encode(row);
1194
+ processedChunk = stringToChunk(row);
1060
1195
  request.completedImportChunks.push(processedChunk);
1061
1196
  writtenClientReferences.set(clientReferenceKey, importId);
1062
1197
  return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
@@ -1077,6 +1212,43 @@ function outlineModel(request, value) {
1077
1212
  retryTask(request, value);
1078
1213
  return value.id;
1079
1214
  }
1215
+ function serializeTypedArray(request, tag, typedArray) {
1216
+ request.pendingChunks++;
1217
+ var bufferId = request.nextChunkId++;
1218
+ emitTypedArrayChunk(request, bufferId, tag, typedArray);
1219
+ return serializeByValueID(bufferId);
1220
+ }
1221
+ function serializeBlob(request, blob) {
1222
+ function progress(entry) {
1223
+ if (!aborted)
1224
+ if (entry.done)
1225
+ request.abortListeners.delete(error),
1226
+ (aborted = !0),
1227
+ pingTask(request, newTask);
1228
+ else
1229
+ return (
1230
+ model.push(entry.value), reader.read().then(progress).catch(error)
1231
+ );
1232
+ }
1233
+ function error(reason) {
1234
+ if (!aborted) {
1235
+ aborted = !0;
1236
+ request.abortListeners.delete(error);
1237
+ var digest = logRecoverableError(request, reason);
1238
+ emitErrorChunk(request, newTask.id, digest);
1239
+ request.abortableTasks.delete(newTask);
1240
+ enqueueFlush(request);
1241
+ reader.cancel(reason).then(error, error);
1242
+ }
1243
+ }
1244
+ var model = [blob.type],
1245
+ newTask = createTask(request, model, null, !1, request.abortableTasks),
1246
+ reader = blob.stream().getReader(),
1247
+ aborted = !1;
1248
+ request.abortListeners.add(error);
1249
+ reader.read().then(progress).catch(error);
1250
+ return "$B" + newTask.id.toString(16);
1251
+ }
1080
1252
  var modelRoot = !1;
1081
1253
  function renderModelDestructive(
1082
1254
  request,
@@ -1091,34 +1263,39 @@ function renderModelDestructive(
1091
1263
  if ("object" === typeof value) {
1092
1264
  switch (value.$$typeof) {
1093
1265
  case REACT_ELEMENT_TYPE:
1094
- parent = request.writtenObjects;
1095
- parentPropertyName = parent.get(value);
1096
- if (void 0 !== parentPropertyName) {
1097
- if (null === task.keyPath && !task.implicitSlot)
1266
+ var writtenObjects = request.writtenObjects;
1267
+ if (null === task.keyPath && !task.implicitSlot) {
1268
+ var existingReference = writtenObjects.get(value);
1269
+ if (void 0 !== existingReference)
1098
1270
  if (modelRoot === value) modelRoot = null;
1099
- else
1100
- return -1 === parentPropertyName
1101
- ? ((request = outlineModel(request, value)),
1102
- serializeByValueID(request))
1103
- : serializeByValueID(parentPropertyName);
1104
- } else parent.set(value, -1), parent.set(value.props, -2);
1105
- parent = value.props;
1106
- parentPropertyName = parent.ref;
1271
+ else return existingReference;
1272
+ else
1273
+ -1 === parentPropertyName.indexOf(":") &&
1274
+ ((parent = writtenObjects.get(parent)),
1275
+ void 0 !== parent &&
1276
+ writtenObjects.set(value, parent + ":" + parentPropertyName));
1277
+ }
1278
+ parentPropertyName = value.props;
1279
+ parent = parentPropertyName.ref;
1107
1280
  return renderElement(
1108
1281
  request,
1109
1282
  task,
1110
1283
  value.type,
1111
1284
  value.key,
1112
- void 0 !== parentPropertyName ? parentPropertyName : null,
1113
- parent
1285
+ void 0 !== parent ? parent : null,
1286
+ parentPropertyName
1114
1287
  );
1115
1288
  case REACT_LAZY_TYPE:
1116
1289
  return (
1117
1290
  (task.thenableState = null),
1118
- (parent = value._init),
1119
- (value = parent(value._payload)),
1291
+ (parentPropertyName = value._init),
1292
+ (value = parentPropertyName(value._payload)),
1120
1293
  renderModelDestructive(request, task, emptyRoot, "", value)
1121
1294
  );
1295
+ case REACT_LEGACY_ELEMENT_TYPE:
1296
+ throw Error(
1297
+ '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.'
1298
+ );
1122
1299
  }
1123
1300
  if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
1124
1301
  return serializeClientReference(
@@ -1127,65 +1304,120 @@ function renderModelDestructive(
1127
1304
  parentPropertyName,
1128
1305
  value
1129
1306
  );
1130
- parent = request.writtenObjects;
1131
- parentPropertyName = parent.get(value);
1307
+ if (
1308
+ void 0 !== request.temporaryReferences &&
1309
+ ((writtenObjects = request.temporaryReferences.get(value)),
1310
+ void 0 !== writtenObjects)
1311
+ )
1312
+ return "$T" + writtenObjects;
1313
+ writtenObjects = request.writtenObjects;
1314
+ existingReference = writtenObjects.get(value);
1132
1315
  if ("function" === typeof value.then) {
1133
- if (void 0 !== parentPropertyName) {
1316
+ if (void 0 !== existingReference) {
1134
1317
  if (null !== task.keyPath || task.implicitSlot)
1135
1318
  return "$@" + serializeThenable(request, task, value).toString(16);
1136
1319
  if (modelRoot === value) modelRoot = null;
1137
- else return "$@" + parentPropertyName.toString(16);
1320
+ else return existingReference;
1138
1321
  }
1139
- request = serializeThenable(request, task, value);
1140
- parent.set(value, request);
1141
- return "$@" + request.toString(16);
1322
+ request = "$@" + serializeThenable(request, task, value).toString(16);
1323
+ writtenObjects.set(value, request);
1324
+ return request;
1142
1325
  }
1143
- if (void 0 !== parentPropertyName)
1326
+ if (void 0 !== existingReference)
1144
1327
  if (modelRoot === value) modelRoot = null;
1145
- else {
1146
- if (-1 === parentPropertyName)
1147
- return (
1148
- (request = outlineModel(request, value)),
1149
- serializeByValueID(request)
1150
- );
1151
- if (-2 !== parentPropertyName)
1152
- return serializeByValueID(parentPropertyName);
1153
- }
1154
- else parent.set(value, -1);
1155
- if (isArrayImpl(value)) return renderFragment(request, task, value);
1156
- if (value instanceof Map) {
1157
- value = Array.from(value);
1158
- for (task = 0; task < value.length; task++)
1159
- (parent = value[task][0]),
1160
- "object" === typeof parent &&
1161
- null !== parent &&
1162
- ((parentPropertyName = request.writtenObjects),
1163
- void 0 === parentPropertyName.get(parent) &&
1164
- parentPropertyName.set(parent, -1));
1165
- return "$Q" + outlineModel(request, value).toString(16);
1166
- }
1167
- if (value instanceof Set) {
1168
- value = Array.from(value);
1169
- for (task = 0; task < value.length; task++)
1170
- (parent = value[task]),
1171
- "object" === typeof parent &&
1172
- null !== parent &&
1173
- ((parentPropertyName = request.writtenObjects),
1174
- void 0 === parentPropertyName.get(parent) &&
1175
- parentPropertyName.set(parent, -1));
1176
- return "$W" + outlineModel(request, value).toString(16);
1328
+ else return existingReference;
1329
+ else if (
1330
+ -1 === parentPropertyName.indexOf(":") &&
1331
+ ((existingReference = writtenObjects.get(parent)),
1332
+ void 0 !== existingReference)
1333
+ ) {
1334
+ var propertyName = parentPropertyName;
1335
+ if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1336
+ switch (parentPropertyName) {
1337
+ case "1":
1338
+ propertyName = "type";
1339
+ break;
1340
+ case "2":
1341
+ propertyName = "key";
1342
+ break;
1343
+ case "3":
1344
+ propertyName = "props";
1345
+ }
1346
+ writtenObjects.set(value, existingReference + ":" + propertyName);
1177
1347
  }
1348
+ if (isArrayImpl(value)) return renderFragment(request, task, value);
1349
+ if (value instanceof Map)
1350
+ return (
1351
+ (value = Array.from(value)),
1352
+ "$Q" + outlineModel(request, value).toString(16)
1353
+ );
1354
+ if (value instanceof Set)
1355
+ return (
1356
+ (value = Array.from(value)),
1357
+ "$W" + outlineModel(request, value).toString(16)
1358
+ );
1178
1359
  if ("function" === typeof FormData && value instanceof FormData)
1179
1360
  return (
1180
1361
  (value = Array.from(value.entries())),
1181
1362
  "$K" + outlineModel(request, value).toString(16)
1182
1363
  );
1183
- if ((parent = getIteratorFn(value)))
1364
+ if (value instanceof ArrayBuffer)
1365
+ return serializeTypedArray(request, "A", new Uint8Array(value));
1366
+ if (value instanceof Int8Array)
1367
+ return serializeTypedArray(request, "O", value);
1368
+ if (value instanceof Uint8Array)
1369
+ return serializeTypedArray(request, "o", value);
1370
+ if (value instanceof Uint8ClampedArray)
1371
+ return serializeTypedArray(request, "U", value);
1372
+ if (value instanceof Int16Array)
1373
+ return serializeTypedArray(request, "S", value);
1374
+ if (value instanceof Uint16Array)
1375
+ return serializeTypedArray(request, "s", value);
1376
+ if (value instanceof Int32Array)
1377
+ return serializeTypedArray(request, "L", value);
1378
+ if (value instanceof Uint32Array)
1379
+ return serializeTypedArray(request, "l", value);
1380
+ if (value instanceof Float32Array)
1381
+ return serializeTypedArray(request, "G", value);
1382
+ if (value instanceof Float64Array)
1383
+ return serializeTypedArray(request, "g", value);
1384
+ if (value instanceof BigInt64Array)
1385
+ return serializeTypedArray(request, "M", value);
1386
+ if (value instanceof BigUint64Array)
1387
+ return serializeTypedArray(request, "m", value);
1388
+ if (value instanceof DataView)
1389
+ return serializeTypedArray(request, "V", value);
1390
+ if ("function" === typeof Blob && value instanceof Blob)
1391
+ return serializeBlob(request, value);
1392
+ if ((parentPropertyName = getIteratorFn(value)))
1184
1393
  return (
1185
- (parent = parent.call(value)),
1186
- parent === value
1187
- ? "$i" + outlineModel(request, Array.from(parent)).toString(16)
1188
- : renderFragment(request, task, Array.from(parent))
1394
+ (parentPropertyName = parentPropertyName.call(value)),
1395
+ parentPropertyName === value
1396
+ ? "$i" +
1397
+ outlineModel(request, Array.from(parentPropertyName)).toString(16)
1398
+ : renderFragment(request, task, Array.from(parentPropertyName))
1399
+ );
1400
+ if ("function" === typeof ReadableStream && value instanceof ReadableStream)
1401
+ return serializeReadableStream(request, task, value);
1402
+ parentPropertyName = value[ASYNC_ITERATOR];
1403
+ if ("function" === typeof parentPropertyName)
1404
+ return (
1405
+ null !== task.keyPath
1406
+ ? ((request = [
1407
+ REACT_ELEMENT_TYPE,
1408
+ REACT_FRAGMENT_TYPE,
1409
+ task.keyPath,
1410
+ { children: value }
1411
+ ]),
1412
+ (request = task.implicitSlot ? [request] : request))
1413
+ : ((parentPropertyName = parentPropertyName.call(value)),
1414
+ (request = serializeAsyncIterable(
1415
+ request,
1416
+ task,
1417
+ value,
1418
+ parentPropertyName
1419
+ ))),
1420
+ request
1189
1421
  );
1190
1422
  request = getPrototypeOf(value);
1191
1423
  if (
@@ -1236,20 +1468,30 @@ function renderModelDestructive(
1236
1468
  if (value.$$typeof === SERVER_REFERENCE_TAG)
1237
1469
  return (
1238
1470
  (task = request.writtenServerReferences),
1239
- (parent = task.get(value)),
1240
- void 0 !== parent
1241
- ? (request = "$F" + parent.toString(16))
1242
- : ((parent = value.$$bound),
1243
- (parent = {
1471
+ (parentPropertyName = task.get(value)),
1472
+ void 0 !== parentPropertyName
1473
+ ? (request = "$F" + parentPropertyName.toString(16))
1474
+ : ((parentPropertyName = value.$$bound),
1475
+ (parentPropertyName = {
1244
1476
  id: value.$$id,
1245
- bound: parent ? Promise.resolve(parent) : null
1477
+ bound: parentPropertyName
1478
+ ? Promise.resolve(parentPropertyName)
1479
+ : null
1246
1480
  }),
1247
- (request = outlineModel(request, parent)),
1481
+ (request = outlineModel(request, parentPropertyName)),
1248
1482
  task.set(value, request),
1249
1483
  (request = "$F" + request.toString(16))),
1250
1484
  request
1251
1485
  );
1252
- if (value.$$typeof === TEMPORARY_REFERENCE_TAG) return "$T" + value.$$id;
1486
+ if (
1487
+ void 0 !== request.temporaryReferences &&
1488
+ ((request = request.temporaryReferences.get(value)), void 0 !== request)
1489
+ )
1490
+ return "$T" + request;
1491
+ if (value.$$typeof === TEMPORARY_REFERENCE_TAG)
1492
+ throw Error(
1493
+ "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
1494
+ );
1253
1495
  if (/^on[A-Z]/.test(parentPropertyName))
1254
1496
  throw Error(
1255
1497
  "Event handlers cannot be passed to Client Component props." +
@@ -1263,25 +1505,25 @@ function renderModelDestructive(
1263
1505
  }
1264
1506
  if ("symbol" === typeof value) {
1265
1507
  task = request.writtenSymbols;
1266
- var existingId$10 = task.get(value);
1267
- if (void 0 !== existingId$10) return serializeByValueID(existingId$10);
1268
- existingId$10 = value.description;
1269
- if (Symbol.for(existingId$10) !== value)
1508
+ writtenObjects = task.get(value);
1509
+ if (void 0 !== writtenObjects) return serializeByValueID(writtenObjects);
1510
+ writtenObjects = value.description;
1511
+ if (Symbol.for(writtenObjects) !== value)
1270
1512
  throw Error(
1271
1513
  "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1272
1514
  (value.description + ") cannot be found among global symbols.") +
1273
1515
  describeObjectForErrorMessage(parent, parentPropertyName)
1274
1516
  );
1275
1517
  request.pendingChunks++;
1276
- parent = request.nextChunkId++;
1277
- parentPropertyName = encodeReferenceChunk(
1518
+ parentPropertyName = request.nextChunkId++;
1519
+ parent = encodeReferenceChunk(
1278
1520
  request,
1279
- parent,
1280
- "$S" + existingId$10
1521
+ parentPropertyName,
1522
+ "$S" + writtenObjects
1281
1523
  );
1282
- request.completedImportChunks.push(parentPropertyName);
1283
- task.set(value, parent);
1284
- return serializeByValueID(parent);
1524
+ request.completedImportChunks.push(parent);
1525
+ task.set(value, parentPropertyName);
1526
+ return serializeByValueID(parentPropertyName);
1285
1527
  }
1286
1528
  if ("bigint" === typeof value) return "$n" + value.toString(10);
1287
1529
  throw Error(
@@ -1318,22 +1560,68 @@ function fatalError(request, error) {
1318
1560
  function emitErrorChunk(request, id, digest) {
1319
1561
  digest = { digest: digest };
1320
1562
  id = id.toString(16) + ":E" + stringify(digest) + "\n";
1321
- id = textEncoder.encode(id);
1563
+ id = stringToChunk(id);
1322
1564
  request.completedErrorChunks.push(id);
1323
1565
  }
1324
1566
  function emitModelChunk(request, id, json) {
1325
1567
  id = id.toString(16) + ":" + json + "\n";
1326
- id = textEncoder.encode(id);
1568
+ id = stringToChunk(id);
1327
1569
  request.completedRegularChunks.push(id);
1328
1570
  }
1571
+ function emitTypedArrayChunk(request, id, tag, typedArray) {
1572
+ request.pendingChunks++;
1573
+ var buffer = new Uint8Array(
1574
+ typedArray.buffer,
1575
+ typedArray.byteOffset,
1576
+ typedArray.byteLength
1577
+ );
1578
+ typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1579
+ buffer = typedArray.byteLength;
1580
+ id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1581
+ id = stringToChunk(id);
1582
+ request.completedRegularChunks.push(id, typedArray);
1583
+ }
1329
1584
  function emitTextChunk(request, id, text) {
1330
1585
  request.pendingChunks++;
1331
- text = textEncoder.encode(text);
1586
+ text = stringToChunk(text);
1332
1587
  var binaryLength = text.byteLength;
1333
1588
  id = id.toString(16) + ":T" + binaryLength.toString(16) + ",";
1334
- id = textEncoder.encode(id);
1589
+ id = stringToChunk(id);
1335
1590
  request.completedRegularChunks.push(id, text);
1336
1591
  }
1592
+ function emitChunk(request, task, value) {
1593
+ var id = task.id;
1594
+ "string" === typeof value
1595
+ ? emitTextChunk(request, id, value)
1596
+ : value instanceof ArrayBuffer
1597
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1598
+ : value instanceof Int8Array
1599
+ ? emitTypedArrayChunk(request, id, "O", value)
1600
+ : value instanceof Uint8Array
1601
+ ? emitTypedArrayChunk(request, id, "o", value)
1602
+ : value instanceof Uint8ClampedArray
1603
+ ? emitTypedArrayChunk(request, id, "U", value)
1604
+ : value instanceof Int16Array
1605
+ ? emitTypedArrayChunk(request, id, "S", value)
1606
+ : value instanceof Uint16Array
1607
+ ? emitTypedArrayChunk(request, id, "s", value)
1608
+ : value instanceof Int32Array
1609
+ ? emitTypedArrayChunk(request, id, "L", value)
1610
+ : value instanceof Uint32Array
1611
+ ? emitTypedArrayChunk(request, id, "l", value)
1612
+ : value instanceof Float32Array
1613
+ ? emitTypedArrayChunk(request, id, "G", value)
1614
+ : value instanceof Float64Array
1615
+ ? emitTypedArrayChunk(request, id, "g", value)
1616
+ : value instanceof BigInt64Array
1617
+ ? emitTypedArrayChunk(request, id, "M", value)
1618
+ : value instanceof BigUint64Array
1619
+ ? emitTypedArrayChunk(request, id, "m", value)
1620
+ : value instanceof DataView
1621
+ ? emitTypedArrayChunk(request, id, "V", value)
1622
+ : ((value = stringify(value, task.toJSON)),
1623
+ emitModelChunk(request, task.id, value));
1624
+ }
1337
1625
  var emptyRoot = {};
1338
1626
  function retryTask(request, task) {
1339
1627
  if (0 === task.status)
@@ -1349,17 +1637,12 @@ function retryTask(request, task) {
1349
1637
  modelRoot = resolvedModel;
1350
1638
  task.keyPath = null;
1351
1639
  task.implicitSlot = !1;
1352
- if ("object" === typeof resolvedModel && null !== resolvedModel) {
1353
- var id = task.id;
1354
- if ("string" === typeof resolvedModel)
1355
- emitTextChunk(request, id, resolvedModel);
1356
- else {
1357
- var json = stringify(resolvedModel, task.toJSON);
1358
- emitModelChunk(request, task.id, json);
1359
- }
1360
- } else {
1361
- var json$jscomp$0 = stringify(resolvedModel);
1362
- emitModelChunk(request, task.id, json$jscomp$0);
1640
+ if ("object" === typeof resolvedModel && null !== resolvedModel)
1641
+ request.writtenObjects.set(resolvedModel, serializeByValueID(task.id)),
1642
+ emitChunk(request, task, resolvedModel);
1643
+ else {
1644
+ var json = stringify(resolvedModel);
1645
+ emitModelChunk(request, task.id, json);
1363
1646
  }
1364
1647
  request.abortableTasks.delete(task);
1365
1648
  task.status = 1;
@@ -1484,19 +1767,19 @@ function abort(request, reason) {
1484
1767
  }
1485
1768
  var abortListeners = request.abortListeners;
1486
1769
  if (0 < abortListeners.size) {
1487
- var error$17 =
1770
+ var error$22 =
1488
1771
  void 0 === reason
1489
1772
  ? Error("The render was aborted by the server without a reason.")
1490
1773
  : reason;
1491
1774
  abortListeners.forEach(function (callback) {
1492
- return callback(error$17);
1775
+ return callback(error$22);
1493
1776
  });
1494
1777
  abortListeners.clear();
1495
1778
  }
1496
1779
  null !== request.destination &&
1497
1780
  flushCompletedChunks(request, request.destination);
1498
- } catch (error$18) {
1499
- logRecoverableError(request, error$18), fatalError(request, error$18);
1781
+ } catch (error$23) {
1782
+ logRecoverableError(request, error$23), fatalError(request, error$23);
1500
1783
  }
1501
1784
  }
1502
1785
  function resolveServerReference(bundlerConfig, id) {
@@ -1572,6 +1855,7 @@ function requireModule(metadata) {
1572
1855
  : moduleExports
1573
1856
  : moduleExports[metadata[2]];
1574
1857
  }
1858
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
1575
1859
  function Chunk(status, value, reason, response) {
1576
1860
  this.status = status;
1577
1861
  this.value = value;
@@ -1590,6 +1874,7 @@ Chunk.prototype.then = function (resolve, reject) {
1590
1874
  break;
1591
1875
  case "pending":
1592
1876
  case "blocked":
1877
+ case "cyclic":
1593
1878
  resolve &&
1594
1879
  (null === this.value && (this.value = []), this.value.push(resolve));
1595
1880
  reject &&
@@ -1599,17 +1884,65 @@ Chunk.prototype.then = function (resolve, reject) {
1599
1884
  reject(this.reason);
1600
1885
  }
1601
1886
  };
1887
+ function createPendingChunk(response) {
1888
+ return new Chunk("pending", null, null, response);
1889
+ }
1602
1890
  function wakeChunk(listeners, value) {
1603
1891
  for (var i = 0; i < listeners.length; i++) (0, listeners[i])(value);
1604
1892
  }
1605
1893
  function triggerErrorOnChunk(chunk, error) {
1606
- if ("pending" === chunk.status || "blocked" === chunk.status) {
1894
+ if ("pending" !== chunk.status && "blocked" !== chunk.status)
1895
+ chunk.reason.error(error);
1896
+ else {
1607
1897
  var listeners = chunk.reason;
1608
1898
  chunk.status = "rejected";
1609
1899
  chunk.reason = error;
1610
1900
  null !== listeners && wakeChunk(listeners, error);
1611
1901
  }
1612
1902
  }
1903
+ function resolveModelChunk(chunk, value, id) {
1904
+ if ("pending" !== chunk.status)
1905
+ (chunk = chunk.reason),
1906
+ "C" === value[0]
1907
+ ? chunk.close("C" === value ? '"$undefined"' : value.slice(1))
1908
+ : chunk.enqueueModel(value);
1909
+ else {
1910
+ var resolveListeners = chunk.value,
1911
+ rejectListeners = chunk.reason;
1912
+ chunk.status = "resolved_model";
1913
+ chunk.value = value;
1914
+ chunk.reason = id;
1915
+ if (null !== resolveListeners)
1916
+ switch ((initializeModelChunk(chunk), chunk.status)) {
1917
+ case "fulfilled":
1918
+ wakeChunk(resolveListeners, chunk.value);
1919
+ break;
1920
+ case "pending":
1921
+ case "blocked":
1922
+ case "cyclic":
1923
+ chunk.value = resolveListeners;
1924
+ chunk.reason = rejectListeners;
1925
+ break;
1926
+ case "rejected":
1927
+ rejectListeners && wakeChunk(rejectListeners, chunk.reason);
1928
+ }
1929
+ }
1930
+ }
1931
+ function createResolvedIteratorResultChunk(response, value, done) {
1932
+ return new Chunk(
1933
+ "resolved_model",
1934
+ (done ? '{"done":true,"value":' : '{"done":false,"value":') + value + "}",
1935
+ -1,
1936
+ response
1937
+ );
1938
+ }
1939
+ function resolveIteratorResultChunk(chunk, value, done) {
1940
+ resolveModelChunk(
1941
+ chunk,
1942
+ (done ? '{"done":true,"value":' : '{"done":false,"value":') + value + "}",
1943
+ -1
1944
+ );
1945
+ }
1613
1946
  function loadServerReference$1(
1614
1947
  response,
1615
1948
  id,
@@ -1638,12 +1971,42 @@ function loadServerReference$1(
1638
1971
  key,
1639
1972
  !1,
1640
1973
  response,
1641
- createModel
1974
+ createModel,
1975
+ []
1642
1976
  ),
1643
1977
  createModelReject(parentChunk)
1644
1978
  );
1645
1979
  return null;
1646
1980
  }
1981
+ function reviveModel(response, parentObj, parentKey, value, reference) {
1982
+ if ("string" === typeof value)
1983
+ return parseModelString(response, parentObj, parentKey, value, reference);
1984
+ if ("object" === typeof value && null !== value)
1985
+ if (
1986
+ (void 0 !== reference &&
1987
+ void 0 !== response._temporaryReferences &&
1988
+ response._temporaryReferences.set(value, reference),
1989
+ Array.isArray(value))
1990
+ )
1991
+ for (var i = 0; i < value.length; i++)
1992
+ value[i] = reviveModel(
1993
+ response,
1994
+ value,
1995
+ "" + i,
1996
+ value[i],
1997
+ void 0 !== reference ? reference + ":" + i : void 0
1998
+ );
1999
+ else
2000
+ for (i in value)
2001
+ hasOwnProperty.call(value, i) &&
2002
+ ((parentObj =
2003
+ void 0 !== reference && -1 === i.indexOf(":")
2004
+ ? reference + ":" + i
2005
+ : void 0),
2006
+ (parentObj = reviveModel(response, value, i, value[i], parentObj)),
2007
+ void 0 !== parentObj ? (value[i] = parentObj) : delete value[i]);
2008
+ return value;
2009
+ }
1647
2010
  var initializingChunk = null,
1648
2011
  initializingChunkBlockedModel = null;
1649
2012
  function initializeModelChunk(chunk) {
@@ -1651,15 +2014,34 @@ function initializeModelChunk(chunk) {
1651
2014
  prevBlocked = initializingChunkBlockedModel;
1652
2015
  initializingChunk = chunk;
1653
2016
  initializingChunkBlockedModel = null;
2017
+ var rootReference = -1 === chunk.reason ? void 0 : chunk.reason.toString(16),
2018
+ resolvedModel = chunk.value;
2019
+ chunk.status = "cyclic";
2020
+ chunk.value = null;
2021
+ chunk.reason = null;
1654
2022
  try {
1655
- var value = JSON.parse(chunk.value, chunk._response._fromJSON);
1656
- null !== initializingChunkBlockedModel &&
1657
- 0 < initializingChunkBlockedModel.deps
1658
- ? ((initializingChunkBlockedModel.value = value),
2023
+ var rawModel = JSON.parse(resolvedModel),
2024
+ value = reviveModel(
2025
+ chunk._response,
2026
+ { "": rawModel },
2027
+ "",
2028
+ rawModel,
2029
+ rootReference
2030
+ );
2031
+ if (
2032
+ null !== initializingChunkBlockedModel &&
2033
+ 0 < initializingChunkBlockedModel.deps
2034
+ )
2035
+ (initializingChunkBlockedModel.value = value),
1659
2036
  (chunk.status = "blocked"),
1660
2037
  (chunk.value = null),
1661
- (chunk.reason = null))
1662
- : ((chunk.status = "fulfilled"), (chunk.value = value));
2038
+ (chunk.reason = null);
2039
+ else {
2040
+ var resolveListeners = chunk.value;
2041
+ chunk.status = "fulfilled";
2042
+ chunk.value = value;
2043
+ null !== resolveListeners && wakeChunk(resolveListeners, value);
2044
+ }
1663
2045
  } catch (error) {
1664
2046
  (chunk.status = "rejected"), (chunk.reason = error);
1665
2047
  } finally {
@@ -1679,12 +2061,20 @@ function getChunk(response, id) {
1679
2061
  ((chunk = response._formData.get(response._prefix + id)),
1680
2062
  (chunk =
1681
2063
  null != chunk
1682
- ? new Chunk("resolved_model", chunk, null, response)
1683
- : new Chunk("pending", null, null, response)),
2064
+ ? new Chunk("resolved_model", chunk, id, response)
2065
+ : createPendingChunk(response)),
1684
2066
  chunks.set(id, chunk));
1685
2067
  return chunk;
1686
2068
  }
1687
- function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
2069
+ function createModelResolver(
2070
+ chunk,
2071
+ parentObject,
2072
+ key,
2073
+ cyclic,
2074
+ response,
2075
+ map,
2076
+ path
2077
+ ) {
1688
2078
  if (initializingChunkBlockedModel) {
1689
2079
  var blocked = initializingChunkBlockedModel;
1690
2080
  cyclic || blocked.deps++;
@@ -1694,6 +2084,7 @@ function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
1694
2084
  value: null
1695
2085
  };
1696
2086
  return function (value) {
2087
+ for (var i = 1; i < path.length; i++) value = value[path[i]];
1697
2088
  parentObject[key] = map(response, value);
1698
2089
  "" === key && null === blocked.value && (blocked.value = parentObject[key]);
1699
2090
  blocked.deps--;
@@ -1710,7 +2101,9 @@ function createModelReject(chunk) {
1710
2101
  return triggerErrorOnChunk(chunk, error);
1711
2102
  };
1712
2103
  }
1713
- function getOutlinedModel(response, id, parentObject, key, map) {
2104
+ function getOutlinedModel(response, reference, parentObject, key, map) {
2105
+ reference = reference.split(":");
2106
+ var id = parseInt(reference[0], 16);
1714
2107
  id = getChunk(response, id);
1715
2108
  switch (id.status) {
1716
2109
  case "resolved_model":
@@ -1718,12 +2111,24 @@ function getOutlinedModel(response, id, parentObject, key, map) {
1718
2111
  }
1719
2112
  switch (id.status) {
1720
2113
  case "fulfilled":
1721
- return map(response, id.value);
2114
+ parentObject = id.value;
2115
+ for (key = 1; key < reference.length; key++)
2116
+ parentObject = parentObject[reference[key]];
2117
+ return map(response, parentObject);
1722
2118
  case "pending":
1723
2119
  case "blocked":
2120
+ case "cyclic":
1724
2121
  var parentChunk = initializingChunk;
1725
2122
  id.then(
1726
- createModelResolver(parentChunk, parentObject, key, !1, response, map),
2123
+ createModelResolver(
2124
+ parentChunk,
2125
+ parentObject,
2126
+ key,
2127
+ "cyclic" === id.status,
2128
+ response,
2129
+ map,
2130
+ reference
2131
+ ),
1727
2132
  createModelReject(parentChunk)
1728
2133
  );
1729
2134
  return null;
@@ -1743,7 +2148,193 @@ function extractIterator(response, model) {
1743
2148
  function createModel(response, model) {
1744
2149
  return model;
1745
2150
  }
1746
- function parseModelString(response, obj, key, value) {
2151
+ function parseTypedArray(
2152
+ response,
2153
+ reference,
2154
+ constructor,
2155
+ bytesPerElement,
2156
+ parentObject,
2157
+ parentKey
2158
+ ) {
2159
+ reference = parseInt(reference.slice(2), 16);
2160
+ reference = response._formData.get(response._prefix + reference);
2161
+ reference =
2162
+ constructor === ArrayBuffer
2163
+ ? reference.arrayBuffer()
2164
+ : reference.arrayBuffer().then(function (buffer) {
2165
+ return new constructor(buffer);
2166
+ });
2167
+ bytesPerElement = initializingChunk;
2168
+ reference.then(
2169
+ createModelResolver(
2170
+ bytesPerElement,
2171
+ parentObject,
2172
+ parentKey,
2173
+ !1,
2174
+ response,
2175
+ createModel,
2176
+ []
2177
+ ),
2178
+ createModelReject(bytesPerElement)
2179
+ );
2180
+ return null;
2181
+ }
2182
+ function resolveStream(response, id, stream, controller) {
2183
+ var chunks = response._chunks;
2184
+ stream = new Chunk("fulfilled", stream, controller, response);
2185
+ chunks.set(id, stream);
2186
+ response = response._formData.getAll(response._prefix + id);
2187
+ for (id = 0; id < response.length; id++)
2188
+ (chunks = response[id]),
2189
+ "C" === chunks[0]
2190
+ ? controller.close("C" === chunks ? '"$undefined"' : chunks.slice(1))
2191
+ : controller.enqueueModel(chunks);
2192
+ }
2193
+ function parseReadableStream(response, reference, type) {
2194
+ reference = parseInt(reference.slice(2), 16);
2195
+ var controller = null;
2196
+ type = new ReadableStream({
2197
+ type: type,
2198
+ start: function (c) {
2199
+ controller = c;
2200
+ }
2201
+ });
2202
+ var previousBlockedChunk = null;
2203
+ resolveStream(response, reference, type, {
2204
+ enqueueModel: function (json) {
2205
+ if (null === previousBlockedChunk) {
2206
+ var chunk = new Chunk("resolved_model", json, -1, response);
2207
+ initializeModelChunk(chunk);
2208
+ "fulfilled" === chunk.status
2209
+ ? controller.enqueue(chunk.value)
2210
+ : (chunk.then(
2211
+ function (v) {
2212
+ return controller.enqueue(v);
2213
+ },
2214
+ function (e) {
2215
+ return controller.error(e);
2216
+ }
2217
+ ),
2218
+ (previousBlockedChunk = chunk));
2219
+ } else {
2220
+ chunk = previousBlockedChunk;
2221
+ var chunk$25 = createPendingChunk(response);
2222
+ chunk$25.then(
2223
+ function (v) {
2224
+ return controller.enqueue(v);
2225
+ },
2226
+ function (e) {
2227
+ return controller.error(e);
2228
+ }
2229
+ );
2230
+ previousBlockedChunk = chunk$25;
2231
+ chunk.then(function () {
2232
+ previousBlockedChunk === chunk$25 && (previousBlockedChunk = null);
2233
+ resolveModelChunk(chunk$25, json, -1);
2234
+ });
2235
+ }
2236
+ },
2237
+ close: function () {
2238
+ if (null === previousBlockedChunk) controller.close();
2239
+ else {
2240
+ var blockedChunk = previousBlockedChunk;
2241
+ previousBlockedChunk = null;
2242
+ blockedChunk.then(function () {
2243
+ return controller.close();
2244
+ });
2245
+ }
2246
+ },
2247
+ error: function (error) {
2248
+ if (null === previousBlockedChunk) controller.error(error);
2249
+ else {
2250
+ var blockedChunk = previousBlockedChunk;
2251
+ previousBlockedChunk = null;
2252
+ blockedChunk.then(function () {
2253
+ return controller.error(error);
2254
+ });
2255
+ }
2256
+ }
2257
+ });
2258
+ return type;
2259
+ }
2260
+ function asyncIterator() {
2261
+ return this;
2262
+ }
2263
+ function createIterator(next) {
2264
+ next = { next: next };
2265
+ next[ASYNC_ITERATOR] = asyncIterator;
2266
+ return next;
2267
+ }
2268
+ function parseAsyncIterable(response, reference, iterator) {
2269
+ reference = parseInt(reference.slice(2), 16);
2270
+ var buffer = [],
2271
+ closed = !1,
2272
+ nextWriteIndex = 0,
2273
+ $jscomp$compprop2 = {};
2274
+ $jscomp$compprop2 =
2275
+ (($jscomp$compprop2[ASYNC_ITERATOR] = function () {
2276
+ var nextReadIndex = 0;
2277
+ return createIterator(function (arg) {
2278
+ if (void 0 !== arg)
2279
+ throw Error(
2280
+ "Values cannot be passed to next() of AsyncIterables passed to Client Components."
2281
+ );
2282
+ if (nextReadIndex === buffer.length) {
2283
+ if (closed)
2284
+ return new Chunk(
2285
+ "fulfilled",
2286
+ { done: !0, value: void 0 },
2287
+ null,
2288
+ response
2289
+ );
2290
+ buffer[nextReadIndex] = createPendingChunk(response);
2291
+ }
2292
+ return buffer[nextReadIndex++];
2293
+ });
2294
+ }),
2295
+ $jscomp$compprop2);
2296
+ iterator = iterator ? $jscomp$compprop2[ASYNC_ITERATOR]() : $jscomp$compprop2;
2297
+ resolveStream(response, reference, iterator, {
2298
+ enqueueModel: function (value) {
2299
+ nextWriteIndex === buffer.length
2300
+ ? (buffer[nextWriteIndex] = createResolvedIteratorResultChunk(
2301
+ response,
2302
+ value,
2303
+ !1
2304
+ ))
2305
+ : resolveIteratorResultChunk(buffer[nextWriteIndex], value, !1);
2306
+ nextWriteIndex++;
2307
+ },
2308
+ close: function (value) {
2309
+ closed = !0;
2310
+ nextWriteIndex === buffer.length
2311
+ ? (buffer[nextWriteIndex] = createResolvedIteratorResultChunk(
2312
+ response,
2313
+ value,
2314
+ !0
2315
+ ))
2316
+ : resolveIteratorResultChunk(buffer[nextWriteIndex], value, !0);
2317
+ for (nextWriteIndex++; nextWriteIndex < buffer.length; )
2318
+ resolveIteratorResultChunk(
2319
+ buffer[nextWriteIndex++],
2320
+ '"$undefined"',
2321
+ !0
2322
+ );
2323
+ },
2324
+ error: function (error) {
2325
+ closed = !0;
2326
+ for (
2327
+ nextWriteIndex === buffer.length &&
2328
+ (buffer[nextWriteIndex] = createPendingChunk(response));
2329
+ nextWriteIndex < buffer.length;
2330
+
2331
+ )
2332
+ triggerErrorOnChunk(buffer[nextWriteIndex++], error);
2333
+ }
2334
+ });
2335
+ return iterator;
2336
+ }
2337
+ function parseModelString(response, obj, key, value, reference) {
1747
2338
  if ("$" === value[0]) {
1748
2339
  switch (value[1]) {
1749
2340
  case "$":
@@ -1752,7 +2343,7 @@ function parseModelString(response, obj, key, value) {
1752
2343
  return (obj = parseInt(value.slice(2), 16)), getChunk(response, obj);
1753
2344
  case "F":
1754
2345
  return (
1755
- (value = parseInt(value.slice(2), 16)),
2346
+ (value = value.slice(2)),
1756
2347
  (value = getOutlinedModel(response, value, obj, key, createModel)),
1757
2348
  loadServerReference$1(
1758
2349
  response,
@@ -1764,15 +2355,22 @@ function parseModelString(response, obj, key, value) {
1764
2355
  )
1765
2356
  );
1766
2357
  case "T":
1767
- return createTemporaryReference(value.slice(2));
2358
+ if (void 0 === reference || void 0 === response._temporaryReferences)
2359
+ throw Error(
2360
+ "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
2361
+ );
2362
+ return createTemporaryReference(
2363
+ response._temporaryReferences,
2364
+ reference
2365
+ );
1768
2366
  case "Q":
1769
2367
  return (
1770
- (value = parseInt(value.slice(2), 16)),
2368
+ (value = value.slice(2)),
1771
2369
  getOutlinedModel(response, value, obj, key, createMap)
1772
2370
  );
1773
2371
  case "W":
1774
2372
  return (
1775
- (value = parseInt(value.slice(2), 16)),
2373
+ (value = value.slice(2)),
1776
2374
  getOutlinedModel(response, value, obj, key, createSet)
1777
2375
  );
1778
2376
  case "K":
@@ -1786,7 +2384,7 @@ function parseModelString(response, obj, key, value) {
1786
2384
  return data;
1787
2385
  case "i":
1788
2386
  return (
1789
- (value = parseInt(value.slice(2), 16)),
2387
+ (value = value.slice(2)),
1790
2388
  getOutlinedModel(response, value, obj, key, extractIterator)
1791
2389
  );
1792
2390
  case "I":
@@ -1802,29 +2400,67 @@ function parseModelString(response, obj, key, value) {
1802
2400
  case "n":
1803
2401
  return BigInt(value.slice(2));
1804
2402
  }
1805
- value = parseInt(value.slice(1), 16);
2403
+ switch (value[1]) {
2404
+ case "A":
2405
+ return parseTypedArray(response, value, ArrayBuffer, 1, obj, key);
2406
+ case "O":
2407
+ return parseTypedArray(response, value, Int8Array, 1, obj, key);
2408
+ case "o":
2409
+ return parseTypedArray(response, value, Uint8Array, 1, obj, key);
2410
+ case "U":
2411
+ return parseTypedArray(response, value, Uint8ClampedArray, 1, obj, key);
2412
+ case "S":
2413
+ return parseTypedArray(response, value, Int16Array, 2, obj, key);
2414
+ case "s":
2415
+ return parseTypedArray(response, value, Uint16Array, 2, obj, key);
2416
+ case "L":
2417
+ return parseTypedArray(response, value, Int32Array, 4, obj, key);
2418
+ case "l":
2419
+ return parseTypedArray(response, value, Uint32Array, 4, obj, key);
2420
+ case "G":
2421
+ return parseTypedArray(response, value, Float32Array, 4, obj, key);
2422
+ case "g":
2423
+ return parseTypedArray(response, value, Float64Array, 8, obj, key);
2424
+ case "M":
2425
+ return parseTypedArray(response, value, BigInt64Array, 8, obj, key);
2426
+ case "m":
2427
+ return parseTypedArray(response, value, BigUint64Array, 8, obj, key);
2428
+ case "V":
2429
+ return parseTypedArray(response, value, DataView, 1, obj, key);
2430
+ case "B":
2431
+ return (
2432
+ (obj = parseInt(value.slice(2), 16)),
2433
+ response._formData.get(response._prefix + obj)
2434
+ );
2435
+ }
2436
+ switch (value[1]) {
2437
+ case "R":
2438
+ return parseReadableStream(response, value, void 0);
2439
+ case "r":
2440
+ return parseReadableStream(response, value, "bytes");
2441
+ case "X":
2442
+ return parseAsyncIterable(response, value, !1);
2443
+ case "x":
2444
+ return parseAsyncIterable(response, value, !0);
2445
+ }
2446
+ value = value.slice(1);
1806
2447
  return getOutlinedModel(response, value, obj, key, createModel);
1807
2448
  }
1808
2449
  return value;
1809
2450
  }
1810
- function createResponse(bundlerConfig, formFieldPrefix) {
2451
+ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
1811
2452
  var backingFormData =
1812
- 2 < arguments.length && void 0 !== arguments[2]
1813
- ? arguments[2]
2453
+ 3 < arguments.length && void 0 !== arguments[3]
2454
+ ? arguments[3]
1814
2455
  : new FormData(),
1815
- chunks = new Map(),
1816
- response = {
1817
- _bundlerConfig: bundlerConfig,
1818
- _prefix: formFieldPrefix,
1819
- _formData: backingFormData,
1820
- _chunks: chunks,
1821
- _fromJSON: function (key, value) {
1822
- return "string" === typeof value
1823
- ? parseModelString(response, this, key, value)
1824
- : value;
1825
- }
1826
- };
1827
- return response;
2456
+ chunks = new Map();
2457
+ return {
2458
+ _bundlerConfig: bundlerConfig,
2459
+ _prefix: formFieldPrefix,
2460
+ _formData: backingFormData,
2461
+ _chunks: chunks,
2462
+ _temporaryReferences: temporaryReferences
2463
+ };
1828
2464
  }
1829
2465
  function close(response) {
1830
2466
  reportGlobalError(response, Error("Connection closed."));
@@ -1845,7 +2481,7 @@ function loadServerReference(bundlerConfig, id, bound) {
1845
2481
  : Promise.resolve(requireModule(serverReference));
1846
2482
  }
1847
2483
  function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
1848
- body = createResponse(serverManifest, formFieldPrefix, body);
2484
+ body = createResponse(serverManifest, formFieldPrefix, void 0, body);
1849
2485
  close(body);
1850
2486
  body = getChunk(body, 0);
1851
2487
  body.then(function () {});
@@ -1856,6 +2492,9 @@ exports.createClientModuleProxy = function (moduleId) {
1856
2492
  moduleId = registerClientReferenceImpl({}, moduleId, !1);
1857
2493
  return new Proxy(moduleId, proxyHandlers$1);
1858
2494
  };
2495
+ exports.createTemporaryReferenceSet = function () {
2496
+ return new WeakMap();
2497
+ };
1859
2498
  exports.decodeAction = function (body, serverManifest) {
1860
2499
  var formData = new FormData(),
1861
2500
  action = null;
@@ -1893,13 +2532,18 @@ exports.decodeFormState = function (actionResult, body, serverManifest) {
1893
2532
  : [actionResult, keyPath, referenceId, bound.length - 1];
1894
2533
  });
1895
2534
  };
1896
- exports.decodeReply = function (body, webpackMap) {
2535
+ exports.decodeReply = function (body, webpackMap, options) {
1897
2536
  if ("string" === typeof body) {
1898
2537
  var form = new FormData();
1899
2538
  form.append("0", body);
1900
2539
  body = form;
1901
2540
  }
1902
- body = createResponse(webpackMap, "", body);
2541
+ body = createResponse(
2542
+ webpackMap,
2543
+ "",
2544
+ options ? options.temporaryReferences : void 0,
2545
+ body
2546
+ );
1903
2547
  webpackMap = getChunk(body, 0);
1904
2548
  close(body);
1905
2549
  return webpackMap;
@@ -1932,7 +2576,9 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
1932
2576
  webpackMap,
1933
2577
  options ? options.onError : void 0,
1934
2578
  options ? options.identifierPrefix : void 0,
1935
- options ? options.onPostpone : void 0
2579
+ options ? options.onPostpone : void 0,
2580
+ options ? options.environmentName : void 0,
2581
+ options ? options.temporaryReferences : void 0
1936
2582
  );
1937
2583
  if (options && options.signal) {
1938
2584
  var signal = options.signal;