@shopify/hydrogen 1.2.0 → 1.3.2

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 (98) hide show
  1. package/README.md +1 -1
  2. package/dist/esnext/components/CartProvider/CartProvider.client.js +6 -0
  3. package/dist/esnext/components/CartProvider/cart-queries.d.ts +1 -1
  4. package/dist/esnext/components/CartProvider/cart-queries.js +1 -0
  5. package/dist/esnext/components/ExternalVideo/ExternalVideo.js +2 -2
  6. package/dist/esnext/components/Image/Image.d.ts +1 -1
  7. package/dist/esnext/components/Image/Image.js +4 -4
  8. package/dist/esnext/components/Image/index.d.ts +1 -1
  9. package/dist/esnext/components/index.d.ts +1 -1
  10. package/dist/esnext/components/index.js +1 -1
  11. package/dist/esnext/constants.d.ts +1 -0
  12. package/dist/esnext/constants.js +1 -0
  13. package/dist/esnext/entry-client.js +1 -1
  14. package/dist/esnext/entry-server.js +30 -28
  15. package/dist/esnext/experimental.d.ts +1 -0
  16. package/dist/esnext/experimental.js +1 -0
  17. package/dist/esnext/foundation/Cache/cache.js +0 -1
  18. package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.d.ts +1 -0
  19. package/dist/esnext/foundation/HydrogenRequest/HydrogenRequest.server.js +1 -0
  20. package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.d.ts +4 -2
  21. package/dist/esnext/foundation/HydrogenResponse/HydrogenResponse.server.js +17 -16
  22. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +1 -3
  23. package/dist/esnext/foundation/fetchSync/ResponseSync.d.ts +2 -1
  24. package/dist/esnext/foundation/fetchSync/ResponseSync.js +14 -2
  25. package/dist/esnext/foundation/session/session-types.d.ts +2 -0
  26. package/dist/esnext/foundation/session/session.d.ts +3 -0
  27. package/dist/esnext/foundation/session/session.js +16 -0
  28. package/dist/esnext/foundation/useQuery/hooks.d.ts +3 -0
  29. package/dist/esnext/foundation/useQuery/hooks.js +1 -1
  30. package/dist/esnext/foundation/useSession/useSession.d.ts +1 -0
  31. package/dist/esnext/foundation/useSession/useSession.js +13 -0
  32. package/dist/esnext/framework/plugin.js +6 -5
  33. package/dist/esnext/framework/plugins/vite-plugin-assets-version.d.ts +2 -0
  34. package/dist/esnext/framework/plugins/vite-plugin-assets-version.js +12 -0
  35. package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +6 -3
  36. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +3 -0
  37. package/dist/esnext/framework/plugins/vite-plugin-css-rsc.js +8 -5
  38. package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.js +7 -1
  39. package/dist/{node/framework/plugins/vite-plugin-purge-query-cache.d.ts → esnext/framework/plugins/vite-plugin-hydrogen-client-components-cache.d.ts} +1 -1
  40. package/dist/esnext/framework/plugins/{vite-plugin-hydrogen-client-middleware.js → vite-plugin-hydrogen-client-components-cache.js} +2 -2
  41. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.d.ts +2 -1
  42. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +104 -90
  43. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +6 -6
  44. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +5 -0
  45. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +45 -7
  46. package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +14 -1
  47. package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.js +5 -1
  48. package/dist/esnext/framework/types.d.ts +1 -0
  49. package/dist/esnext/framework/viteception.js +7 -1
  50. package/dist/esnext/storefront-api-types.d.ts +38 -31
  51. package/dist/esnext/storefront-api-types.js +4 -2
  52. package/dist/esnext/types.d.ts +2 -1
  53. package/dist/esnext/utilities/apiRoutes.d.ts +2 -0
  54. package/dist/esnext/utilities/apiRoutes.js +12 -1
  55. package/dist/esnext/utilities/fetch.js +4 -1
  56. package/dist/esnext/utilities/log/log.js +20 -5
  57. package/dist/esnext/utilities/log/utils.js +1 -1
  58. package/dist/esnext/utilities/template.d.ts +7 -6
  59. package/dist/esnext/utilities/template.js +39 -1
  60. package/dist/esnext/utilities/vite.d.ts +1 -0
  61. package/dist/esnext/utilities/vite.js +4 -0
  62. package/dist/esnext/version.d.ts +1 -1
  63. package/dist/esnext/version.js +1 -1
  64. package/dist/node/foundation/session/session-types.d.ts +2 -0
  65. package/dist/node/framework/plugin.js +6 -5
  66. package/dist/node/framework/plugins/vite-plugin-assets-version.d.ts +2 -0
  67. package/dist/node/framework/plugins/vite-plugin-assets-version.js +15 -0
  68. package/dist/node/framework/plugins/vite-plugin-client-imports.js +6 -3
  69. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +3 -0
  70. package/dist/node/framework/plugins/vite-plugin-css-rsc.js +8 -5
  71. package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.js +7 -1
  72. package/dist/{esnext/framework/plugins/vite-plugin-purge-query-cache.d.ts → node/framework/plugins/vite-plugin-hydrogen-client-components-cache.d.ts} +1 -1
  73. package/dist/node/framework/plugins/{vite-plugin-hydrogen-client-middleware.js → vite-plugin-hydrogen-client-components-cache.js} +2 -2
  74. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.d.ts +2 -1
  75. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +107 -90
  76. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +6 -6
  77. package/dist/node/framework/plugins/vite-plugin-hydrogen-suppress-warnings.js +5 -0
  78. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +45 -7
  79. package/dist/node/framework/plugins/vite-plugin-platform-entry.js +14 -1
  80. package/dist/node/framework/plugins/vite-plugin-ssr-interop.js +5 -1
  81. package/dist/node/framework/types.d.ts +1 -0
  82. package/dist/node/framework/viteception.js +7 -1
  83. package/dist/node/utilities/vite.d.ts +1 -0
  84. package/dist/node/utilities/vite.js +30 -0
  85. package/package.json +7 -6
  86. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +36 -25
  87. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +105 -29
  88. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +30 -29
  89. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +92 -29
  90. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +31 -29
  91. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +29 -18
  92. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +105 -29
  93. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +92 -29
  94. package/vendor/react-server-dom-vite/package.json +2 -2
  95. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +0 -9
  96. package/dist/esnext/framework/plugins/vite-plugin-purge-query-cache.js +0 -11
  97. package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +0 -9
  98. package/dist/node/framework/plugins/vite-plugin-purge-query-cache.js +0 -16
@@ -14,9 +14,9 @@
14
14
 
15
15
  var esModuleLexer = require('es-module-lexer');
16
16
  var MagicString = require('magic-string');
17
- var vite = require('vite');
18
17
  var fs = require('fs');
19
18
  var path = require('path');
19
+ var vite = require('vite');
20
20
 
21
21
  function _unsupportedIterableToArray(o, minLen) {
22
22
  if (!o) return;
@@ -94,6 +94,10 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
94
94
 
95
95
  var assign = Object.assign;
96
96
 
97
+ var normalizePath = vite.normalizePath,
98
+ transformWithEsbuild = vite.transformWithEsbuild,
99
+ createServer = vite.createServer;
100
+ var isVite3 = vite.version && vite.version.startsWith('3.');
97
101
  var rscViteFileRE = /\/react-server-dom-vite.js/;
98
102
  var noProxyRE = /[&?]no-proxy($|&)/;
99
103
 
@@ -128,10 +132,10 @@ function ReactFlightVitePlugin() {
128
132
  enforce: 'pre',
129
133
  buildStart: function () {
130
134
  // Let other plugins differentiate between pure SSR and RSC builds
131
- if (config?.build?.ssr) process.env.RSC_BUILD = 'true';
135
+ if (config?.build?.ssr) process.env.VITE_RSC_BUILD = 'true';
132
136
  },
133
137
  buildEnd: function () {
134
- if (config?.build?.ssr) delete process.env.RSC_BUILD;
138
+ if (config?.build?.ssr) delete process.env.VITE_RSC_BUILD;
135
139
  },
136
140
  configureServer: function (_server) {
137
141
  server = _server;
@@ -267,11 +271,11 @@ function ReactFlightVitePlugin() {
267
271
  var injectGlobs = function (clientComponents) {
268
272
  var importerPath = path.dirname(id);
269
273
  var importers = clientComponents.map(function (absolutePath) {
270
- return vite.normalizePath(path.relative(importerPath, absolutePath));
274
+ return normalizePath(path.relative(importerPath, absolutePath));
271
275
  });
272
276
  var injectedGlobs = "Object.assign(Object.create(null), " + importers.map(function (glob) {
273
277
  return (// Mark the globs to modify the result after Vite resolves them.
274
- "\n/* HASH_BEGIN */ " + ("import.meta.glob('" + vite.normalizePath(glob) + "') /* HASH_END */")
278
+ "\n/* HASH_BEGIN */ " + ("import.meta.glob('" + normalizePath(glob) + "') /* HASH_END */")
275
279
  );
276
280
  }).join(', ') + ");";
277
281
  s.replace(INJECTING_RE, injectedGlobs);
@@ -302,7 +306,7 @@ function ReactFlightVitePlugin() {
302
306
  throw new Error('[react-server-dom-vite] Parameter serverBuildEntries is required for client build');
303
307
  }
304
308
 
305
- return findClientBoundariesForClientBuild(serverBuildEntries, optimizeBoundaries !== false).then(injectGlobs);
309
+ return findClientBoundariesForClientBuild(serverBuildEntries, optimizeBoundaries !== false, config.root).then(injectGlobs);
306
310
  }
307
311
  },
308
312
  handleHotUpdate: function (_ref2) {
@@ -358,7 +362,7 @@ async function proxyClientComponent(filepath, src) {
358
362
  src = await fs.promises.readFile(filepath, 'utf-8');
359
363
  }
360
364
 
361
- var _await$transformWithE = await vite.transformWithEsbuild(src, filepath),
365
+ var _await$transformWithE = await transformWithEsbuild(src, filepath),
362
366
  code = _await$transformWithE.code;
363
367
 
364
368
  var _parse = esModuleLexer.parse(code),
@@ -405,13 +409,16 @@ function findClientBoundaries(moduleGraph) {
405
409
  return clientBoundaries;
406
410
  }
407
411
 
408
- async function findClientBoundariesForClientBuild(serverEntries, optimizeBoundaries) {
412
+ async function findClientBoundariesForClientBuild(serverEntries, optimizeBoundaries, root) {
409
413
  // Viteception
410
- var server = await vite.createServer({
414
+ var server = await createServer({
415
+ root: root,
411
416
  clearScreen: false,
412
417
  server: {
413
- middlewareMode: 'ssr'
414
- }
418
+ middlewareMode: isVite3 ? true : 'ssr',
419
+ hmr: false
420
+ },
421
+ appType: 'custom'
415
422
  });
416
423
 
417
424
  try {
@@ -434,9 +441,10 @@ var hashImportsPlugin = {
434
441
  if (rscViteFileRE.test(id)) {
435
442
  var s = new MagicString(code);
436
443
  s.replace(/\/\*\s*HASH_BEGIN\s*\*\/\s*([^]+?)\/\*\s*HASH_END\s*\*\//gm, function (_, imports) {
437
- return imports.trim().replace(/"([^"]+?)":/gm, function (__, relativePath) {
444
+ return imports.trim().replace(/"([^"]+?)":/gm, function (all, relativePath) {
445
+ if (relativePath === '__VITE_PRELOAD__') return all;
438
446
  var absolutePath = path.resolve(path.dirname(id.split('?')[0]), relativePath);
439
- return "\"" + getComponentId(vite.normalizePath(absolutePath)) + "\":";
447
+ return "\"" + getComponentId(normalizePath(absolutePath)) + "\":";
440
448
  });
441
449
  });
442
450
  return {
@@ -528,17 +536,20 @@ function isDirectImportInServer(originalMod, currentMod, accModInfo) {
528
536
  });
529
537
  }
530
538
 
531
- function resolveModPath(modPath, dirname, retryExtension) {
532
- var absolutePath = '';
539
+ var RESOLVE_EXTENSIONS = ['', '.js', '.ts', '.jsx', '.tsx', '/index', '/index.js', '/index.ts', '/index.jsx', '/index.tsx']; // Resolve relative paths and aliases. Examples:
540
+ // - import {XYZ} from '~/components' => import {XYZ} from '<absolute>/src/components/index.ts'
541
+ // - import {XYZ} from '/src/component.client' => import {XYZ} from '<absolute>/src/component.client.jsx'`
533
542
 
534
- try {
535
- absolutePath = modPath.startsWith('.') ? vite.normalizePath(path.resolve(dirname, modPath)) : modPath;
536
- return vite.normalizePath(require.resolve(absolutePath + (retryExtension || '')));
537
- } catch (error) {
538
- if (!/\.[jt]sx?$/.test(absolutePath) && retryExtension !== '.tsx') {
539
- // Node cannot infer .[jt]sx extensions.
540
- // Append them here and retry a couple of times.
541
- return resolveModPath(absolutePath, dirname, retryExtension ? '.tsx' : '.jsx');
543
+ function resolveModPath(modPath, dirname) {
544
+ var extensions = /\.[jt]sx?$/.test(modPath) ? [''] : RESOLVE_EXTENSIONS;
545
+
546
+ for (var i = 0; i < extensions.length; i++) {
547
+ var extension = extensions[i];
548
+
549
+ try {
550
+ var absolutePath = modPath.startsWith('.') ? normalizePath(path.resolve(dirname, modPath)) : modPath;
551
+ return normalizePath(require.resolve(absolutePath + extension));
552
+ } catch (error) {// Do not throw, this is likely a virtual module or another exception
542
553
  }
543
554
  }
544
555
  }
@@ -550,7 +561,7 @@ function augmentModuleGraph(moduleGraph, id, code, root, resolveAlias) {
550
561
  var _id$split = id.split('?'),
551
562
  source = _id$split[0];
552
563
 
553
- var dirname = vite.normalizePath(path.dirname(source));
564
+ var dirname = normalizePath(path.dirname(source));
554
565
 
555
566
  var _parse2 = esModuleLexer.parse(code),
556
567
  rawImports = _parse2[0],
@@ -581,7 +592,7 @@ function augmentModuleGraph(moduleGraph, id, code, root, resolveAlias) {
581
592
 
582
593
  if (modPath && modPath.startsWith('/src/')) {
583
594
  // Vite default alias
584
- modPath = vite.normalizePath(path.join(root, modPath));
595
+ modPath = normalizePath(path.join(root, modPath));
585
596
  }
586
597
 
587
598
  var resolvedPath = resolveModPath(modPath, dirname);
@@ -168,6 +168,11 @@ function processModelChunk(request, id, model) {
168
168
  var row = serializeRowHeader('J', id) + json + '\n';
169
169
  return stringToChunk(row);
170
170
  }
171
+ function processReferenceChunk(request, id, reference) {
172
+ var json = stringify(reference);
173
+ var row = serializeRowHeader('J', id) + json + '\n';
174
+ return stringToChunk(row);
175
+ }
171
176
  function processModuleChunk(request, id, moduleMetaData) {
172
177
  var json = stringify(moduleMetaData);
173
178
  var row = serializeRowHeader('M', id) + json + '\n';
@@ -510,6 +515,7 @@ var startInlineScript = stringToPrecomputedChunk('<script>');
510
515
  var endInlineScript = stringToPrecomputedChunk('</script>');
511
516
  var startScriptSrc = stringToPrecomputedChunk('<script src="');
512
517
  var startModuleSrc = stringToPrecomputedChunk('<script type="module" src="');
518
+ var scriptIntegirty = stringToPrecomputedChunk('" integrity="');
513
519
  var endAsyncScript = stringToPrecomputedChunk('" async=""></script>');
514
520
 
515
521
  var textSeparator = stringToPrecomputedChunk('<!-- -->');
@@ -987,6 +993,10 @@ function getOrCreateServerContext(globalName) {
987
993
  return ContextRegistry[globalName];
988
994
  }
989
995
 
996
+ var PENDING = 0;
997
+ var COMPLETED = 1;
998
+ var ABORTED = 3;
999
+ var ERRORED = 4;
990
1000
  var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
991
1001
 
992
1002
  function defaultErrorHandler(error) {
@@ -997,7 +1007,8 @@ var OPEN = 0;
997
1007
  var CLOSING = 1;
998
1008
  var CLOSED = 2;
999
1009
  function createRequest(model, bundlerConfig, onError, context, identifierPrefix) {
1000
- var pingedSegments = [];
1010
+ var abortSet = new Set();
1011
+ var pingedTasks = [];
1001
1012
  var request = {
1002
1013
  status: OPEN,
1003
1014
  fatalError: null,
@@ -1006,7 +1017,8 @@ function createRequest(model, bundlerConfig, onError, context, identifierPrefix)
1006
1017
  cache: new Map(),
1007
1018
  nextChunkId: 0,
1008
1019
  pendingChunks: 0,
1009
- pingedSegments: pingedSegments,
1020
+ abortableTasks: abortSet,
1021
+ pingedTasks: pingedTasks,
1010
1022
  completedModuleChunks: [],
1011
1023
  completedJSONChunks: [],
1012
1024
  completedErrorChunks: [],
@@ -1022,8 +1034,8 @@ function createRequest(model, bundlerConfig, onError, context, identifierPrefix)
1022
1034
  };
1023
1035
  request.pendingChunks++;
1024
1036
  var rootContext = createRootContext(context);
1025
- var rootSegment = createSegment(request, model, rootContext);
1026
- pingedSegments.push(rootSegment);
1037
+ var rootTask = createTask(request, model, rootContext, abortSet);
1038
+ pingedTasks.push(rootTask);
1027
1039
  return request;
1028
1040
  }
1029
1041
 
@@ -1121,28 +1133,30 @@ function attemptResolveElement(type, key, ref, props) {
1121
1133
  throw new Error("Unsupported server component type: " + describeValueForErrorMessage(type));
1122
1134
  }
1123
1135
 
1124
- function pingSegment(request, segment) {
1125
- var pingedSegments = request.pingedSegments;
1126
- pingedSegments.push(segment);
1136
+ function pingTask(request, task) {
1137
+ var pingedTasks = request.pingedTasks;
1138
+ pingedTasks.push(task);
1127
1139
 
1128
- if (pingedSegments.length === 1) {
1140
+ if (pingedTasks.length === 1) {
1129
1141
  scheduleWork(function () {
1130
1142
  return performWork(request);
1131
1143
  });
1132
1144
  }
1133
1145
  }
1134
1146
 
1135
- function createSegment(request, model, context) {
1147
+ function createTask(request, model, context, abortSet) {
1136
1148
  var id = request.nextChunkId++;
1137
- var segment = {
1149
+ var task = {
1138
1150
  id: id,
1151
+ status: PENDING,
1139
1152
  model: model,
1140
1153
  context: context,
1141
1154
  ping: function () {
1142
- return pingSegment(request, segment);
1155
+ return pingTask(request, task);
1143
1156
  }
1144
1157
  };
1145
- return segment;
1158
+ abortSet.add(task);
1159
+ return task;
1146
1160
  }
1147
1161
 
1148
1162
  function serializeByValueID(id) {
@@ -1377,12 +1391,12 @@ function resolveModelToJSON(request, parent, key, value) {
1377
1391
  }
1378
1392
  } catch (x) {
1379
1393
  if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
1380
- // Something suspended, we'll need to create a new segment and resolve it later.
1394
+ // Something suspended, we'll need to create a new task and resolve it later.
1381
1395
  request.pendingChunks++;
1382
- var newSegment = createSegment(request, value, getActiveContext());
1383
- var ping = newSegment.ping;
1396
+ var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
1397
+ var ping = newTask.ping;
1384
1398
  x.then(ping, ping);
1385
- return serializeByRefID(newSegment.id);
1399
+ return serializeByRefID(newTask.id);
1386
1400
  } else {
1387
1401
  logRecoverableError(request, x); // Something errored. We'll still send everything we have up until this point.
1388
1402
  // We'll replace this element with a lazy reference that throws on the client
@@ -1590,34 +1604,43 @@ function emitProviderChunk(request, id, contextName) {
1590
1604
  request.completedJSONChunks.push(processedChunk);
1591
1605
  }
1592
1606
 
1593
- function retrySegment(request, segment) {
1594
- switchContext(segment.context);
1607
+ function retryTask(request, task) {
1608
+ if (task.status !== PENDING) {
1609
+ // We completed this by other means before we had a chance to retry it.
1610
+ return;
1611
+ }
1612
+
1613
+ switchContext(task.context);
1595
1614
 
1596
1615
  try {
1597
- var _value3 = segment.model;
1616
+ var _value3 = task.model;
1598
1617
 
1599
1618
  while (typeof _value3 === 'object' && _value3 !== null && _value3.$$typeof === REACT_ELEMENT_TYPE) {
1600
1619
  // TODO: Concatenate keys of parents onto children.
1601
1620
  var element = _value3; // Attempt to render the server component.
1602
- // Doing this here lets us reuse this same segment if the next component
1621
+ // Doing this here lets us reuse this same task if the next component
1603
1622
  // also suspends.
1604
1623
 
1605
- segment.model = _value3;
1624
+ task.model = _value3;
1606
1625
  _value3 = attemptResolveElement(element.type, element.key, element.ref, element.props);
1607
1626
  }
1608
1627
 
1609
- var processedChunk = processModelChunk(request, segment.id, _value3);
1628
+ var processedChunk = processModelChunk(request, task.id, _value3);
1610
1629
  request.completedJSONChunks.push(processedChunk);
1630
+ request.abortableTasks.delete(task);
1631
+ task.status = COMPLETED;
1611
1632
  } catch (x) {
1612
1633
  if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
1613
1634
  // Something suspended again, let's pick it back up later.
1614
- var ping = segment.ping;
1635
+ var ping = task.ping;
1615
1636
  x.then(ping, ping);
1616
1637
  return;
1617
1638
  } else {
1639
+ request.abortableTasks.delete(task);
1640
+ task.status = ERRORED;
1618
1641
  logRecoverableError(request, x); // This errored, we need to serialize this error to the
1619
1642
 
1620
- emitErrorChunk(request, segment.id, x);
1643
+ emitErrorChunk(request, task.id, x);
1621
1644
  }
1622
1645
  }
1623
1646
  }
@@ -1630,12 +1653,12 @@ function performWork(request) {
1630
1653
  prepareToUseHooksForRequest(request);
1631
1654
 
1632
1655
  try {
1633
- var pingedSegments = request.pingedSegments;
1634
- request.pingedSegments = [];
1656
+ var pingedTasks = request.pingedTasks;
1657
+ request.pingedTasks = [];
1635
1658
 
1636
- for (var i = 0; i < pingedSegments.length; i++) {
1637
- var segment = pingedSegments[i];
1638
- retrySegment(request, segment);
1659
+ for (var i = 0; i < pingedTasks.length; i++) {
1660
+ var task = pingedTasks[i];
1661
+ retryTask(request, task);
1639
1662
  }
1640
1663
 
1641
1664
  if (request.destination !== null) {
@@ -1651,6 +1674,15 @@ function performWork(request) {
1651
1674
  }
1652
1675
  }
1653
1676
 
1677
+ function abortTask(task, request, errorId) {
1678
+ task.status = ABORTED; // Instead of emitting an error per task.id, we emit a model that only
1679
+ // has a single value referencing the error.
1680
+
1681
+ var ref = serializeByValueID(errorId);
1682
+ var processedChunk = processReferenceChunk(request, task.id, ref);
1683
+ request.completedJSONChunks.push(processedChunk);
1684
+ }
1685
+
1654
1686
  function flushCompletedChunks(request, destination) {
1655
1687
  beginWriting();
1656
1688
 
@@ -1750,6 +1782,34 @@ function startFlowing(request, destination) {
1750
1782
  logRecoverableError(request, error);
1751
1783
  fatalError(request, error);
1752
1784
  }
1785
+ } // This is called to early terminate a request. It creates an error at all pending tasks.
1786
+
1787
+ function abort(request, reason) {
1788
+ try {
1789
+ var abortableTasks = request.abortableTasks;
1790
+
1791
+ if (abortableTasks.size > 0) {
1792
+ // We have tasks to abort. We'll emit one error row and then emit a reference
1793
+ // to that row from every row that's still remaining.
1794
+ var _error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
1795
+
1796
+ logRecoverableError(request, _error);
1797
+ request.pendingChunks++;
1798
+ var errorId = request.nextChunkId++;
1799
+ emitErrorChunk(request, errorId, _error);
1800
+ abortableTasks.forEach(function (task) {
1801
+ return abortTask(task, request, errorId);
1802
+ });
1803
+ abortableTasks.clear();
1804
+ }
1805
+
1806
+ if (request.destination !== null) {
1807
+ flushCompletedChunks(request, request.destination);
1808
+ }
1809
+ } catch (error) {
1810
+ logRecoverableError(request, error);
1811
+ fatalError(request, error);
1812
+ }
1753
1813
  }
1754
1814
 
1755
1815
  function importServerContexts(contexts) {
@@ -1787,6 +1847,22 @@ function renderToReadableStream(model, options) {
1787
1847
  }
1788
1848
  }), {}, // Manifest, not used
1789
1849
  options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined);
1850
+
1851
+ if (options && options.signal) {
1852
+ var signal = options.signal;
1853
+
1854
+ if (signal.aborted) {
1855
+ abort(request, signal.reason);
1856
+ } else {
1857
+ var listener = function () {
1858
+ abort(request, signal.reason);
1859
+ signal.removeEventListener('abort', listener);
1860
+ };
1861
+
1862
+ signal.addEventListener('abort', listener);
1863
+ }
1864
+ }
1865
+
1790
1866
  var stream = new ReadableStream({
1791
1867
  type: 'bytes',
1792
1868
  start: function (controller) {
@@ -7,7 +7,7 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- 'use strict';var e=require("react"),aa=Object.assign,k=null,m=0;function n(a,b){if(0!==b.length)if(512<b.length)0<m&&(a.enqueue(new Uint8Array(k.buffer,0,m)),k=new Uint8Array(512),m=0),a.enqueue(b);else{var d=k.length-m;d<b.length&&(0===d?a.enqueue(k):(k.set(b.subarray(0,d),m),a.enqueue(k),b=b.subarray(d)),k=new Uint8Array(512),m=0);k.set(b,m);m+=b.length}return!0}var q=new TextEncoder;function r(a){return q.encode(a)}function u(a,b){"function"===typeof a.error?a.error(b):a.close()}
10
+ 'use strict';var e=require("react"),aa=Object.assign,l=null,n=0;function p(a,b){if(0!==b.length)if(512<b.length)0<n&&(a.enqueue(new Uint8Array(l.buffer,0,n)),l=new Uint8Array(512),n=0),a.enqueue(b);else{var d=l.length-n;d<b.length&&(0===d?a.enqueue(l):(l.set(b.subarray(0,d),n),a.enqueue(l),b=b.subarray(d)),l=new Uint8Array(512),n=0);l.set(b,n);n+=b.length}return!0}var q=new TextEncoder;function r(a){return q.encode(a)}function u(a,b){"function"===typeof a.error?a.error(b):a.close()}
11
11
  var w=JSON.stringify,ba=Symbol.for("react.module.reference");function x(a){return"string"===typeof a?!!globalThis.__STRING_REFERENCE_INDEX[a]:a.$$typeof===ba}var y=Symbol.for("react.element"),ca=Symbol.for("react.fragment"),z=Symbol.for("react.provider"),da=Symbol.for("react.forward_ref"),ea=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),B=Symbol.for("react.default_value");
12
12
  function C(a,b,d,c,f,g,h){this.acceptsBooleans=2===b||3===b||4===b;this.attributeName=c;this.attributeNamespace=f;this.mustUseProperty=d;this.propertyName=a;this.type=b;this.sanitizeURL=g;this.removeEmptyString=h}var D="children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ");D.push("innerText","textContent");D.forEach(function(a){new C(a,0,!1,a,null,!1,!1)});
13
13
  [["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){new C(a[0],1,!1,a[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(a){new C(a,2,!1,a.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){new C(a,2,!1,a,null,!1,!1)});
@@ -17,31 +17,32 @@ function C(a,b,d,c,f,g,h){this.acceptsBooleans=2===b||3===b||4===b;this.attribut
17
17
  F);new C(b,1,!1,a,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var b=a.replace(E,F);new C(b,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(a){var b=a.replace(E,F);new C(b,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(a){new C(a,1,!1,a.toLowerCase(),null,!1,!1)});
18
18
  new C("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(a){new C(a,1,!1,a.toLowerCase(),null,!0,!0)});
19
19
  var G={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,
20
- fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fa=["Webkit","ms","Moz","O"];Object.keys(G).forEach(function(a){fa.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);G[b]=G[a]})});var H=Array.isArray;r("<script>");r("\x3c/script>");r('<script src="');r('<script type="module" src="');r('" async="">\x3c/script>');r("\x3c!-- --\x3e");r(' style="');r(":");r(";");r(" ");r('="');r('"');r('=""');r(">");
21
- r("/>");r(' selected=""');r("\n");r("<!DOCTYPE html>");r("</");r(">");r('<template id="');r('"></template>');r("\x3c!--$--\x3e");r('\x3c!--$?--\x3e<template id="');r('"></template>');r("\x3c!--$!--\x3e");r("\x3c!--/$--\x3e");r("<template");r('"');r(' data-dgst="');r(' data-msg="');r(' data-stck="');r("></template>");r('<div hidden id="');r('">');r("</div>");r('<svg aria-hidden="true" style="display:none" id="');r('">');r("</svg>");r('<math aria-hidden="true" style="display:none" id="');r('">');r("</math>");
22
- r('<table hidden id="');r('">');r("</table>");r('<table hidden><tbody id="');r('">');r("</tbody></table>");r('<table hidden><tr id="');r('">');r("</tr></table>");r('<table hidden><colgroup id="');r('">');r("</colgroup></table>");r('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("');r('$RS("');r('","');r('")\x3c/script>');r('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("');
23
- r('$RC("');r('","');r('")\x3c/script>');r('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("');r('$RX("');r('"');r(")\x3c/script>");r(",");var I=null;
24
- function J(a,b){if(a!==b){a.context._currentValue=a.parentValue;a=a.parent;var d=b.parent;if(null===a){if(null!==d)throw Error("The stacks must reach the root at the same time. This is a bug in React.");}else{if(null===d)throw Error("The stacks must reach the root at the same time. This is a bug in React.");J(a,d);b.context._currentValue=b.value}}}function K(a){a.context._currentValue=a.parentValue;a=a.parent;null!==a&&K(a)}
25
- function ha(a){var b=a.parent;null!==b&&ha(b);a.context._currentValue=a.value}function ia(a,b){a.context._currentValue=a.parentValue;a=a.parent;if(null===a)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===b.depth?J(a,b):ia(a,b)}
26
- function ja(a,b){var d=b.parent;if(null===d)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===d.depth?J(a,d):ja(a,d);b.context._currentValue=b.value}function L(a){var b=I;b!==a&&(null===b?ha(a):null===a?K(b):b.depth===a.depth?J(b,a):b.depth>a.depth?ia(b,a):ja(b,a),I=a)}function ka(a,b){var d=a._currentValue;a._currentValue=b;var c=I;return I=a={parent:c,depth:null===c?0:c.depth+1,context:a,parentValue:d,value:b}}var M=null;
27
- function ma(a){return a._currentValue}
28
- var pa={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:N,useTransition:N,getCacheForType:function(a){if(!O)throw Error("Reading the cache is only supported while rendering.");var b=O.get(a);void 0===b&&(b=a(),O.set(a,b));return b},readContext:ma,useContext:ma,useReducer:N,useRef:N,useState:N,useInsertionEffect:N,useLayoutEffect:N,useImperativeHandle:N,useEffect:N,useId:na,useMutableSource:N,useSyncExternalStore:N,useCacheRefresh:function(){return oa}};
29
- function N(){throw Error("This Hook is not supported in Server Components.");}function oa(){if(!O)throw Error("Refreshing the cache is not supported in Server Components.");}var O=null;function na(){if(null===M)throw Error("useId can only be used while React is rendering");var a=M.identifierCount++;return":"+M.identifierPrefix+"S"+a.toString(32)+":"}var qa=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,P=qa.ContextRegistry,Q=qa.ReactCurrentDispatcher;function ra(a){console.error(a)}
30
- function sa(a,b,d,c,f){var g=[],h={status:0,fatalError:null,destination:null,bundlerConfig:b,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:g,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,writtenProviders:new Map,identifierPrefix:f||"",identifierCount:1,onError:void 0===d?ra:d,toJSON:function(a,b){return ta(h,this,a,b)}};h.pendingChunks++;b=ua(c);a=va(h,a,b);g.push(a);return h}var wa={};
31
- function U(a,b,d,c){if(null!==d&&void 0!==d)throw Error("Refs cannot be used in server components, nor passed to client components.");if("function"===typeof a)return x(a)?[y,a,b,c]:a(c);if("string"===typeof a)return[y,a,b,c];if("symbol"===typeof a)return a===ca?c.children:[y,a,b,c];if(null!=a&&"object"===typeof a){if(x(a))return[y,a,b,c];switch(a.$$typeof){case A:var f=a._init;a=f(a._payload);return U(a,b,d,c);case da:return b=a.render,b(c,void 0);case ea:return U(a.type,b,d,c);case z:return ka(a._context,
32
- c.value),[y,a,b,{value:c.value,children:c.children,__pop:wa}]}}throw Error("Unsupported server component type: "+V(a));}function va(a,b,d){var c={id:a.nextChunkId++,model:b,context:d,ping:function(){var b=a.pingedSegments;b.push(c);1===b.length&&xa(a)}};return c}function ya(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function W(a){var b=JSON.stringify(a);return'"'+a+'"'===b?a:b}
33
- function V(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(H(a))return"[...]";a=ya(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}}
34
- function X(a,b){if(H(a)){for(var d="[",c=0;c<a.length;c++){0<c&&(d+=", ");if(6<c){d+="...";break}var f=a[c];d=""+c===b&&"object"===typeof f&&null!==f?d+X(f):d+V(f)}return d+"]"}d="{";c=Object.keys(a);for(f=0;f<c.length;f++){0<f&&(d+=", ");if(6<f){d+="...";break}var g=c[f];d+=W(g)+": ";var h=a[g];d=g===b&&"object"===typeof h&&null!==h?d+X(h):d+V(h)}return d+"}"}
35
- function ta(a,b,d,c){switch(c){case y:return"$"}for(;"object"===typeof c&&null!==c&&(c.$$typeof===y||c.$$typeof===A);)try{switch(c.$$typeof){case y:var f=c;c=U(f.type,f.key,f.ref,f.props);break;case A:var g=c._init;c=g(c._payload)}}catch(t){if("object"===typeof t&&null!==t&&"function"===typeof t.then)return a.pendingChunks++,a=va(a,c,I),d=a.ping,t.then(d,d),"@"+a.id.toString(16);Y(a,t);a.pendingChunks++;d=a.nextChunkId++;Z(a,d,t);return"@"+d.toString(16)}if(null==c)return c;if("object"===typeof c||
36
- x(c)){if(x(c)){f=c;"string"===typeof f&&(f=globalThis.__STRING_REFERENCE_INDEX[f]);f=f.filepath+"#"+f.name;g=a.writtenModules;var h=g.get(f);if(void 0!==h)return b[0]===y&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{"string"===typeof c&&(c=globalThis.__STRING_REFERENCE_INDEX[c]);var p={id:c.filepath,name:c.name};a.pendingChunks++;var l=a.nextChunkId++,R=w(p),S="M"+l.toString(16)+":"+R+"\n";var T=q.encode(S);a.completedModuleChunks.push(T);g.set(f,l);return b[0]===y&&"1"===d?"@"+l.toString(16):
37
- "$"+l.toString(16)}catch(t){return a.pendingChunks++,d=a.nextChunkId++,Z(a,d,t),"$"+d.toString(16)}}else{if(c.$$typeof===z)return b=c._context._globalName,c=a.writtenProviders,d=c.get(d),void 0===d&&(a.pendingChunks++,d=a.nextChunkId++,c.set(b,d),b="P"+d.toString(16)+":"+b+"\n",b=q.encode(b),a.completedJSONChunks.push(b)),"$"+d.toString(16);if(c===wa){a=I;if(null===a)throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");d=a.parentValue;a.context._currentValue=d===B?
38
- a.context._defaultValue:d;I=a.parent;return}}return c}if("string"===typeof c)return a="$"===c[0]||"@"===c[0]?"$"+c:c,a;if("boolean"===typeof c||"number"===typeof c||"undefined"===typeof c)return c;if("function"===typeof c){if(/^on[A-Z]/.test(d))throw Error("Event handlers cannot be passed to client component props. Remove "+(W(d)+" from these props if possible: "+X(b)+"\nIf you need interactivity, consider converting part of this to a client component."));throw Error("Functions cannot be passed directly to client components because they're not serializable. Remove "+
39
- (W(d)+" ("+(c.displayName||c.name||"function")+") from this object, or avoid the entire object: "+X(b)));}if("symbol"===typeof c){p=a.writtenSymbols;l=p.get(c);if(void 0!==l)return"$"+l.toString(16);l=c.description;if(Symbol.for(l)!==c)throw Error("Only global symbols received from Symbol.for(...) can be passed to client components. The symbol Symbol.for("+(c.description+") cannot be found among global symbols. Remove ")+(W(d)+" from this object, or avoid the entire object: "+X(b)));a.pendingChunks++;
40
- d=a.nextChunkId++;b=w(l);b="S"+d.toString(16)+":"+b+"\n";b=q.encode(b);a.completedModuleChunks.push(b);p.set(c,d);return"$"+d.toString(16)}if("bigint"===typeof c)throw Error("BigInt ("+c+") is not yet supported in client component props. Remove "+(W(d)+" from this object or use a plain number instead: "+X(b)));throw Error("Type "+typeof c+" is not supported in client component props. Remove "+(W(d)+" from this object, or avoid the entire object: "+X(b)));}function Y(a,b){a=a.onError;a(b)}
41
- function za(a,b){null!==a.destination?(a.status=2,u(a.destination,b)):(a.status=1,a.fatalError=b)}function Z(a,b,d){var c="";try{if(d instanceof Error){var f=String(d.message);c=String(d.stack)}else f="Error: "+d}catch(g){f="An error occurred but serializing the error message failed."}d={message:f,stack:c};b="E"+b.toString(16)+":"+w(d)+"\n";b=q.encode(b);a.completedErrorChunks.push(b)}
42
- function xa(a){var b=Q.current,d=O;Q.current=pa;O=a.cache;M=a;try{var c=a.pingedSegments;a.pingedSegments=[];for(var f=0;f<c.length;f++){var g=c[f];var h=a;L(g.context);try{for(var p=g.model;"object"===typeof p&&null!==p&&p.$$typeof===y;){var l=p;g.model=p;p=U(l.type,l.key,l.ref,l.props)}var R=g.id,S=w(p,h.toJSON),T="J"+R.toString(16)+":"+S+"\n";var t=q.encode(T);h.completedJSONChunks.push(t)}catch(v){if("object"===typeof v&&null!==v&&"function"===typeof v.then){var la=g.ping;v.then(la,la)}else Y(h,
43
- v),Z(h,g.id,v)}}null!==a.destination&&Aa(a,a.destination)}catch(v){Y(a,v),za(a,v)}finally{Q.current=b,O=d,M=null}}
44
- function Aa(a,b){k=new Uint8Array(512);m=0;try{for(var d=a.completedModuleChunks,c=0;c<d.length;c++)if(a.pendingChunks--,!n(b,d[c])){a.destination=null;c++;break}d.splice(0,c);var f=a.completedJSONChunks;for(c=0;c<f.length;c++)if(a.pendingChunks--,!n(b,f[c])){a.destination=null;c++;break}f.splice(0,c);var g=a.completedErrorChunks;for(c=0;c<g.length;c++)if(a.pendingChunks--,!n(b,g[c])){a.destination=null;c++;break}g.splice(0,c)}finally{k&&0<m&&(b.enqueue(new Uint8Array(k.buffer,0,m)),k=null,m=0)}0===
45
- a.pendingChunks&&b.close()}function ua(a){if(a){var b=I;L(null);for(var d=0;d<a.length;d++){var c=a[d],f=c[0];c=c[1];P[f]||(P[f]=e.createServerContext(f,B));ka(P[f],c)}a=I;L(b);return a}return null}
46
- exports.renderToReadableStream=function(a,b){var d=sa(aa({},a,{$$typeof:Symbol.for("react.element"),props:{children:a},type:function(){e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current.isRsc=!0;return a}}),{},b?b.onError:void 0,b?b.context:void 0,b?b.identifierPrefix:void 0);return new ReadableStream({type:"bytes",start:function(){xa(d)},pull:function(a){if(1===d.status)d.status=2,u(a,d.fatalError);else if(2!==d.status&&null===d.destination){d.destination=a;try{Aa(d,
47
- a)}catch(f){Y(d,f),za(d,f)}}},cancel:function(){}},{highWaterMark:0})};
20
+ fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},fa=["Webkit","ms","Moz","O"];Object.keys(G).forEach(function(a){fa.forEach(function(b){b=b+a.charAt(0).toUpperCase()+a.substring(1);G[b]=G[a]})});var ha=Array.isArray;r("<script>");r("\x3c/script>");r('<script src="');r('<script type="module" src="');r('" integrity="');r('" async="">\x3c/script>');r("\x3c!-- --\x3e");r(' style="');r(":");r(";");r(" ");r('="');r('"');
21
+ r('=""');r(">");r("/>");r(' selected=""');r("\n");r("<!DOCTYPE html>");r("</");r(">");r('<template id="');r('"></template>');r("\x3c!--$--\x3e");r('\x3c!--$?--\x3e<template id="');r('"></template>');r("\x3c!--$!--\x3e");r("\x3c!--/$--\x3e");r("<template");r('"');r(' data-dgst="');r(' data-msg="');r(' data-stck="');r("></template>");r('<div hidden id="');r('">');r("</div>");r('<svg aria-hidden="true" style="display:none" id="');r('">');r("</svg>");r('<math aria-hidden="true" style="display:none" id="');
22
+ r('">');r("</math>");r('<table hidden id="');r('">');r("</table>");r('<table hidden><tbody id="');r('">');r("</tbody></table>");r('<table hidden><tr id="');r('">');r("</tr></table>");r('<table hidden><colgroup id="');r('">');r("</colgroup></table>");r('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("');r('$RS("');r('","');r('")\x3c/script>');r('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("');
23
+ r('$RC("');r('","');r('")\x3c/script>');r('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("');r('$RX("');r('"');r(")\x3c/script>");r(",");var H=null;
24
+ function I(a,b){if(a!==b){a.context._currentValue=a.parentValue;a=a.parent;var d=b.parent;if(null===a){if(null!==d)throw Error("The stacks must reach the root at the same time. This is a bug in React.");}else{if(null===d)throw Error("The stacks must reach the root at the same time. This is a bug in React.");I(a,d);b.context._currentValue=b.value}}}function ia(a){a.context._currentValue=a.parentValue;a=a.parent;null!==a&&ia(a)}
25
+ function ja(a){var b=a.parent;null!==b&&ja(b);a.context._currentValue=a.value}function ka(a,b){a.context._currentValue=a.parentValue;a=a.parent;if(null===a)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===b.depth?I(a,b):ka(a,b)}
26
+ function la(a,b){var d=b.parent;if(null===d)throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");a.depth===d.depth?I(a,d):la(a,d);b.context._currentValue=b.value}function J(a){var b=H;b!==a&&(null===b?ja(a):null===a?ia(b):b.depth===a.depth?I(b,a):b.depth>a.depth?ka(b,a):la(b,a),H=a)}function na(a,b){var d=a._currentValue;a._currentValue=b;var c=H;return H=a={parent:c,depth:null===c?0:c.depth+1,context:a,parentValue:d,value:b}}var K=null;
27
+ function oa(a){return a._currentValue}
28
+ var ra={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:L,useTransition:L,getCacheForType:function(a){if(!M)throw Error("Reading the cache is only supported while rendering.");var b=M.get(a);void 0===b&&(b=a(),M.set(a,b));return b},readContext:oa,useContext:oa,useReducer:L,useRef:L,useState:L,useInsertionEffect:L,useLayoutEffect:L,useImperativeHandle:L,useEffect:L,useId:pa,useMutableSource:L,useSyncExternalStore:L,useCacheRefresh:function(){return qa}};
29
+ function L(){throw Error("This Hook is not supported in Server Components.");}function qa(){if(!M)throw Error("Refreshing the cache is not supported in Server Components.");}var M=null;function pa(){if(null===K)throw Error("useId can only be used while React is rendering");var a=K.identifierCount++;return":"+K.identifierPrefix+"S"+a.toString(32)+":"}var sa=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,N=sa.ContextRegistry,O=sa.ReactCurrentDispatcher;function ta(a){console.error(a)}
30
+ function ua(a,b,d,c,f){var g=new Set,h=[],k={status:0,fatalError:null,destination:null,bundlerConfig:b,cache:new Map,nextChunkId:0,pendingChunks:0,abortableTasks:g,pingedTasks:h,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,writtenProviders:new Map,identifierPrefix:f||"",identifierCount:1,onError:void 0===d?ta:d,toJSON:function(a,b){return va(k,this,a,b)}};k.pendingChunks++;b=wa(c);a=xa(k,a,b,g);h.push(a);return k}var ya={};
31
+ function P(a,b,d,c){if(null!==d&&void 0!==d)throw Error("Refs cannot be used in server components, nor passed to client components.");if("function"===typeof a)return x(a)?[y,a,b,c]:a(c);if("string"===typeof a)return[y,a,b,c];if("symbol"===typeof a)return a===ca?c.children:[y,a,b,c];if(null!=a&&"object"===typeof a){if(x(a))return[y,a,b,c];switch(a.$$typeof){case A:var f=a._init;a=f(a._payload);return P(a,b,d,c);case da:return b=a.render,b(c,void 0);case ea:return P(a.type,b,d,c);case z:return na(a._context,
32
+ c.value),[y,a,b,{value:c.value,children:c.children,__pop:ya}]}}throw Error("Unsupported server component type: "+R(a));}function xa(a,b,d,c){var f={id:a.nextChunkId++,status:0,model:b,context:d,ping:function(){var b=a.pingedTasks;b.push(f);1===b.length&&za(a)}};c.add(f);return f}function Aa(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function U(a){var b=JSON.stringify(a);return'"'+a+'"'===b?a:b}
33
+ function R(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(ha(a))return"[...]";a=Aa(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}}
34
+ function V(a,b){if(ha(a)){for(var d="[",c=0;c<a.length;c++){0<c&&(d+=", ");if(6<c){d+="...";break}var f=a[c];d=""+c===b&&"object"===typeof f&&null!==f?d+V(f):d+R(f)}return d+"]"}d="{";c=Object.keys(a);for(f=0;f<c.length;f++){0<f&&(d+=", ");if(6<f){d+="...";break}var g=c[f];d+=U(g)+": ";var h=a[g];d=g===b&&"object"===typeof h&&null!==h?d+V(h):d+R(h)}return d+"}"}
35
+ function va(a,b,d,c){switch(c){case y:return"$"}for(;"object"===typeof c&&null!==c&&(c.$$typeof===y||c.$$typeof===A);)try{switch(c.$$typeof){case y:var f=c;c=P(f.type,f.key,f.ref,f.props);break;case A:var g=c._init;c=g(c._payload)}}catch(t){if("object"===typeof t&&null!==t&&"function"===typeof t.then)return a.pendingChunks++,a=xa(a,c,H,a.abortableTasks),d=a.ping,t.then(d,d),"@"+a.id.toString(16);W(a,t);a.pendingChunks++;d=a.nextChunkId++;X(a,d,t);return"@"+d.toString(16)}if(null==c)return c;if("object"===
36
+ typeof c||x(c)){if(x(c)){f=c;"string"===typeof f&&(f=globalThis.__STRING_REFERENCE_INDEX[f]);f=f.filepath+"#"+f.name;g=a.writtenModules;var h=g.get(f);if(void 0!==h)return b[0]===y&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{"string"===typeof c&&(c=globalThis.__STRING_REFERENCE_INDEX[c]);var k={id:c.filepath,name:c.name};a.pendingChunks++;var m=a.nextChunkId++,Q=w(k),S="M"+m.toString(16)+":"+Q+"\n";var T=q.encode(S);a.completedModuleChunks.push(T);g.set(f,m);return b[0]===y&&"1"===d?"@"+m.toString(16):
37
+ "$"+m.toString(16)}catch(t){return a.pendingChunks++,d=a.nextChunkId++,X(a,d,t),"$"+d.toString(16)}}else{if(c.$$typeof===z)return b=c._context._globalName,c=a.writtenProviders,d=c.get(d),void 0===d&&(a.pendingChunks++,d=a.nextChunkId++,c.set(b,d),b="P"+d.toString(16)+":"+b+"\n",b=q.encode(b),a.completedJSONChunks.push(b)),"$"+d.toString(16);if(c===ya){a=H;if(null===a)throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");d=a.parentValue;a.context._currentValue=d===B?
38
+ a.context._defaultValue:d;H=a.parent;return}}return c}if("string"===typeof c)return a="$"===c[0]||"@"===c[0]?"$"+c:c,a;if("boolean"===typeof c||"number"===typeof c||"undefined"===typeof c)return c;if("function"===typeof c){if(/^on[A-Z]/.test(d))throw Error("Event handlers cannot be passed to client component props. Remove "+(U(d)+" from these props if possible: "+V(b)+"\nIf you need interactivity, consider converting part of this to a client component."));throw Error("Functions cannot be passed directly to client components because they're not serializable. Remove "+
39
+ (U(d)+" ("+(c.displayName||c.name||"function")+") from this object, or avoid the entire object: "+V(b)));}if("symbol"===typeof c){k=a.writtenSymbols;m=k.get(c);if(void 0!==m)return"$"+m.toString(16);m=c.description;if(Symbol.for(m)!==c)throw Error("Only global symbols received from Symbol.for(...) can be passed to client components. The symbol Symbol.for("+(c.description+") cannot be found among global symbols. Remove ")+(U(d)+" from this object, or avoid the entire object: "+V(b)));a.pendingChunks++;
40
+ d=a.nextChunkId++;b=w(m);b="S"+d.toString(16)+":"+b+"\n";b=q.encode(b);a.completedModuleChunks.push(b);k.set(c,d);return"$"+d.toString(16)}if("bigint"===typeof c)throw Error("BigInt ("+c+") is not yet supported in client component props. Remove "+(U(d)+" from this object or use a plain number instead: "+V(b)));throw Error("Type "+typeof c+" is not supported in client component props. Remove "+(U(d)+" from this object, or avoid the entire object: "+V(b)));}function W(a,b){a=a.onError;a(b)}
41
+ function Y(a,b){null!==a.destination?(a.status=2,u(a.destination,b)):(a.status=1,a.fatalError=b)}function X(a,b,d){var c="";try{if(d instanceof Error){var f=String(d.message);c=String(d.stack)}else f="Error: "+d}catch(g){f="An error occurred but serializing the error message failed."}d={message:f,stack:c};b="E"+b.toString(16)+":"+w(d)+"\n";b=q.encode(b);a.completedErrorChunks.push(b)}
42
+ function za(a){var b=O.current,d=M;O.current=ra;M=a.cache;K=a;try{var c=a.pingedTasks;a.pingedTasks=[];for(var f=0;f<c.length;f++){var g=c[f];var h=a;if(0===g.status){J(g.context);try{for(var k=g.model;"object"===typeof k&&null!==k&&k.$$typeof===y;){var m=k;g.model=k;k=P(m.type,m.key,m.ref,m.props)}var Q=g.id,S=w(k,h.toJSON),T="J"+Q.toString(16)+":"+S+"\n";var t=q.encode(T);h.completedJSONChunks.push(t);h.abortableTasks.delete(g);g.status=1}catch(v){if("object"===typeof v&&null!==v&&"function"===
43
+ typeof v.then){var ma=g.ping;v.then(ma,ma)}else h.abortableTasks.delete(g),g.status=4,W(h,v),X(h,g.id,v)}}}null!==a.destination&&Z(a,a.destination)}catch(v){W(a,v),Y(a,v)}finally{O.current=b,M=d,K=null}}
44
+ function Z(a,b){l=new Uint8Array(512);n=0;try{for(var d=a.completedModuleChunks,c=0;c<d.length;c++)if(a.pendingChunks--,!p(b,d[c])){a.destination=null;c++;break}d.splice(0,c);var f=a.completedJSONChunks;for(c=0;c<f.length;c++)if(a.pendingChunks--,!p(b,f[c])){a.destination=null;c++;break}f.splice(0,c);var g=a.completedErrorChunks;for(c=0;c<g.length;c++)if(a.pendingChunks--,!p(b,g[c])){a.destination=null;c++;break}g.splice(0,c)}finally{l&&0<n&&(b.enqueue(new Uint8Array(l.buffer,0,n)),l=null,n=0)}0===
45
+ a.pendingChunks&&b.close()}function Ba(a,b){try{var d=a.abortableTasks;if(0<d.size){var c=void 0===b?Error("The render was aborted by the server without a reason."):b;W(a,c);a.pendingChunks++;var f=a.nextChunkId++;X(a,f,c);d.forEach(function(b){b.status=3;var c="$"+f.toString(16);b=b.id;c=w(c);c="J"+b.toString(16)+":"+c+"\n";c=q.encode(c);a.completedJSONChunks.push(c)});d.clear()}null!==a.destination&&Z(a,a.destination)}catch(g){W(a,g),Y(a,g)}}
46
+ function wa(a){if(a){var b=H;J(null);for(var d=0;d<a.length;d++){var c=a[d],f=c[0];c=c[1];N[f]||(N[f]=e.createServerContext(f,B));na(N[f],c)}a=H;J(b);return a}return null}
47
+ exports.renderToReadableStream=function(a,b){var d=ua(aa({},a,{$$typeof:Symbol.for("react.element"),props:{children:a},type:function(){e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher.current.isRsc=!0;return a}}),{},b?b.onError:void 0,b?b.context:void 0,b?b.identifierPrefix:void 0);if(b&&b.signal){var c=b.signal;if(c.aborted)Ba(d,c.reason);else{var f=function(){Ba(d,c.reason);c.removeEventListener("abort",f)};c.addEventListener("abort",f)}}return new ReadableStream({type:"bytes",
48
+ start:function(){za(d)},pull:function(a){if(1===d.status)d.status=2,u(a,d.fatalError);else if(2!==d.status&&null===d.destination){d.destination=a;try{Z(d,a)}catch(h){W(d,h),Y(d,h)}}},cancel:function(){}},{highWaterMark:0})};