next 15.3.1-canary.3 → 15.3.1-canary.5

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.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (52) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +10 -2
  3. package/dist/build/index.js.map +1 -1
  4. package/dist/build/swc/index.js +1 -1
  5. package/dist/build/webpack-config.js +2 -2
  6. package/dist/client/app-bootstrap.js +1 -1
  7. package/dist/client/components/bfcache.d.ts +27 -0
  8. package/dist/client/components/bfcache.js +90 -0
  9. package/dist/client/components/bfcache.js.map +1 -0
  10. package/dist/client/components/layout-router.d.ts +1 -1
  11. package/dist/client/components/layout-router.js +83 -61
  12. package/dist/client/components/layout-router.js.map +1 -1
  13. package/dist/client/index.js +1 -1
  14. package/dist/compiled/next-server/server.runtime.prod.js +6 -6
  15. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  16. package/dist/esm/build/index.js +10 -2
  17. package/dist/esm/build/index.js.map +1 -1
  18. package/dist/esm/build/swc/index.js +1 -1
  19. package/dist/esm/build/webpack-config.js +2 -2
  20. package/dist/esm/client/app-bootstrap.js +1 -1
  21. package/dist/esm/client/components/bfcache.js +93 -0
  22. package/dist/esm/client/components/bfcache.js.map +1 -0
  23. package/dist/esm/client/components/layout-router.js +83 -61
  24. package/dist/esm/client/components/layout-router.js.map +1 -1
  25. package/dist/esm/client/index.js +1 -1
  26. package/dist/esm/server/config-schema.js +1 -1
  27. package/dist/esm/server/config-schema.js.map +1 -1
  28. package/dist/esm/server/config-shared.js +1 -1
  29. package/dist/esm/server/config-shared.js.map +1 -1
  30. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  31. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  32. package/dist/esm/server/lib/app-info-log.js +1 -1
  33. package/dist/esm/server/lib/start-server.js +1 -1
  34. package/dist/esm/server/next-server.js +8 -7
  35. package/dist/esm/server/next-server.js.map +1 -1
  36. package/dist/esm/shared/lib/canary-only.js +1 -1
  37. package/dist/server/config-schema.js +1 -1
  38. package/dist/server/config-schema.js.map +1 -1
  39. package/dist/server/config-shared.d.ts +4 -4
  40. package/dist/server/config-shared.js +1 -1
  41. package/dist/server/config-shared.js.map +1 -1
  42. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  43. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  44. package/dist/server/lib/app-info-log.js +1 -1
  45. package/dist/server/lib/start-server.js +1 -1
  46. package/dist/server/next-server.js +8 -7
  47. package/dist/server/next-server.js.map +1 -1
  48. package/dist/shared/lib/canary-only.js +1 -1
  49. package/dist/telemetry/anonymous-meta.js +1 -1
  50. package/dist/telemetry/events/session-stopped.js +2 -2
  51. package/dist/telemetry/events/version.js +2 -2
  52. package/package.json +15 -15
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
11
11
  import { getDefineEnv } from '../webpack/plugins/define-env-plugin';
12
12
  import { getReactCompilerLoader } from '../get-babel-loader-config';
13
13
  import { TurbopackInternalError } from '../../shared/lib/turbopack/utils';
14
- const nextVersion = "15.3.1-canary.3";
14
+ const nextVersion = "15.3.1-canary.5";
15
15
  const ArchName = arch();
16
16
  const PlatformName = platform();
17
17
  function infoLog(...args) {
@@ -1551,7 +1551,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1551
1551
  isClient && new CopyFilePlugin({
1552
1552
  // file path to build output of `@next/polyfill-nomodule`
1553
1553
  filePath: require.resolve('./polyfills/polyfill-nomodule'),
1554
- cacheKey: "15.3.1-canary.3",
1554
+ cacheKey: "15.3.1-canary.5",
1555
1555
  name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
1556
1556
  minimize: false,
1557
1557
  info: {
@@ -1728,7 +1728,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
1728
1728
  // - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
1729
1729
  // - Next.js version
1730
1730
  // - next.config.js keys that affect compilation
1731
- version: `${__dirname}|${"15.3.1-canary.3"}|${configVars}`,
1731
+ version: `${__dirname}|${"15.3.1-canary.5"}|${configVars}`,
1732
1732
  cacheDirectory: path.join(distDir, 'cache', 'webpack'),
1733
1733
  // For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
1734
1734
  // So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
@@ -3,7 +3,7 @@
3
3
  * sure the following scripts are executed in the correct order:
4
4
  * - Polyfills
5
5
  * - next/script with `beforeInteractive` strategy
6
- */ const version = "15.3.1-canary.3";
6
+ */ const version = "15.3.1-canary.5";
7
7
  window.next = {
8
8
  version,
9
9
  appDir: true
@@ -0,0 +1,93 @@
1
+ import { useState } from 'react';
2
+ // When the flag is disabled, only track the currently active tree
3
+ const MAX_BF_CACHE_ENTRIES = process.env.__NEXT_ROUTER_BF_CACHE ? 3 : 1;
4
+ /**
5
+ * Keeps track of the most recent N trees (FlightRouterStates) that were active
6
+ * at a certain segment level. E.g. for a segment "/a/b/[param]", this hook
7
+ * tracks the last N param values that the router rendered for N.
8
+ *
9
+ * The result of this hook precisely determines the number and order of
10
+ * trees that are rendered in parallel at their segment level.
11
+ *
12
+ * The purpose of this cache is to we can preserve the React and DOM state of
13
+ * some number of inactive trees, by rendering them in an <Activity> boundary.
14
+ * That means it would not make sense for the the lifetime of the cache to be
15
+ * any longer than the lifetime of the React tree; e.g. if the hook were
16
+ * unmounted, then the React tree would be, too. So, we use React state to
17
+ * manage it.
18
+ *
19
+ * Note that we don't store the RSC data for the cache entries in this hook —
20
+ * the data for inactive segments is stored in the parent CacheNode, which
21
+ * *does* have a longer lifetime than the React tree. This hook only determines
22
+ * which of those trees should have their *state* preserved, by <Activity>.
23
+ */ export function useRouterBFCache(activeTree, activeStateKey) {
24
+ // The currently active entry. The entries form a linked list, sorted in
25
+ // order of most recently active. This allows us to reuse parts of the list
26
+ // without cloning, unless there's a reordering or removal.
27
+ // TODO: Once we start tracking back/forward history at each route level,
28
+ // we should use the history order instead. In other words, when traversing
29
+ // to an existing entry as a result of a popstate event, we should maintain
30
+ // the existing order instead of moving it to the front of the list. I think
31
+ // an initial implementation of this could be to pass an incrementing id
32
+ // to history.pushState/replaceState, then use that here for ordering.
33
+ const [prevActiveEntry, setPrevActiveEntry] = useState(()=>{
34
+ const initialEntry = {
35
+ tree: activeTree,
36
+ stateKey: activeStateKey,
37
+ next: null
38
+ };
39
+ return initialEntry;
40
+ });
41
+ if (prevActiveEntry.tree === activeTree) {
42
+ // Fast path. The active tree hasn't changed, so we can reuse the
43
+ // existing state.
44
+ return prevActiveEntry;
45
+ }
46
+ // The route tree changed. Note that this doesn't mean that the tree changed
47
+ // *at this level* — the change may be due to a child route. Either way, we
48
+ // need to either add or update the router tree in the bfcache.
49
+ //
50
+ // The rest of the code looks more complicated than it actually is because we
51
+ // can't mutate the state in place; we have to copy-on-write.
52
+ // Create a new entry for the active cache key. This is the head of the new
53
+ // linked list.
54
+ const newActiveEntry = {
55
+ tree: activeTree,
56
+ stateKey: activeStateKey,
57
+ next: null
58
+ };
59
+ // We need to append the old list onto the new list. If the head of the new
60
+ // list was already present in the cache, then we'll need to clone everything
61
+ // that came before it. Then we can reuse the rest.
62
+ let n = 1;
63
+ let oldEntry = prevActiveEntry;
64
+ let clonedEntry = newActiveEntry;
65
+ while(oldEntry !== null && n < MAX_BF_CACHE_ENTRIES){
66
+ if (oldEntry.stateKey === activeStateKey) {
67
+ // Fast path. This entry in the old list that corresponds to the key that
68
+ // is now active. We've already placed a clone of this entry at the front
69
+ // of the new list. We can reuse the rest of the old list without cloning.
70
+ // NOTE: We don't need to worry about eviction in this case because we
71
+ // haven't increased the size of the cache, and we assume the max size
72
+ // is constant across renders. If we were to change it to a dynamic limit,
73
+ // then the implementation would need to account for that.
74
+ clonedEntry.next = oldEntry.next;
75
+ break;
76
+ } else {
77
+ // Clone the entry and append it to the list.
78
+ n++;
79
+ const entry = {
80
+ tree: oldEntry.tree,
81
+ stateKey: oldEntry.stateKey,
82
+ next: null
83
+ };
84
+ clonedEntry.next = entry;
85
+ clonedEntry = entry;
86
+ }
87
+ oldEntry = oldEntry.next;
88
+ }
89
+ setPrevActiveEntry(newActiveEntry);
90
+ return newActiveEntry;
91
+ }
92
+
93
+ //# sourceMappingURL=bfcache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/client/components/bfcache.ts"],"sourcesContent":["import type { FlightRouterState } from '../../server/app-render/types'\nimport { useState } from 'react'\n\n// When the flag is disabled, only track the currently active tree\nconst MAX_BF_CACHE_ENTRIES = process.env.__NEXT_ROUTER_BF_CACHE ? 3 : 1\n\nexport type RouterBFCacheEntry = {\n tree: FlightRouterState\n stateKey: string\n // The entries form a linked list, sorted in order of most recently active.\n next: RouterBFCacheEntry | null\n}\n\n/**\n * Keeps track of the most recent N trees (FlightRouterStates) that were active\n * at a certain segment level. E.g. for a segment \"/a/b/[param]\", this hook\n * tracks the last N param values that the router rendered for N.\n *\n * The result of this hook precisely determines the number and order of\n * trees that are rendered in parallel at their segment level.\n *\n * The purpose of this cache is to we can preserve the React and DOM state of\n * some number of inactive trees, by rendering them in an <Activity> boundary.\n * That means it would not make sense for the the lifetime of the cache to be\n * any longer than the lifetime of the React tree; e.g. if the hook were\n * unmounted, then the React tree would be, too. So, we use React state to\n * manage it.\n *\n * Note that we don't store the RSC data for the cache entries in this hook —\n * the data for inactive segments is stored in the parent CacheNode, which\n * *does* have a longer lifetime than the React tree. This hook only determines\n * which of those trees should have their *state* preserved, by <Activity>.\n */\nexport function useRouterBFCache(\n activeTree: FlightRouterState,\n activeStateKey: string\n): RouterBFCacheEntry {\n // The currently active entry. The entries form a linked list, sorted in\n // order of most recently active. This allows us to reuse parts of the list\n // without cloning, unless there's a reordering or removal.\n // TODO: Once we start tracking back/forward history at each route level,\n // we should use the history order instead. In other words, when traversing\n // to an existing entry as a result of a popstate event, we should maintain\n // the existing order instead of moving it to the front of the list. I think\n // an initial implementation of this could be to pass an incrementing id\n // to history.pushState/replaceState, then use that here for ordering.\n const [prevActiveEntry, setPrevActiveEntry] = useState<RouterBFCacheEntry>(\n () => {\n const initialEntry: RouterBFCacheEntry = {\n tree: activeTree,\n stateKey: activeStateKey,\n next: null,\n }\n return initialEntry\n }\n )\n\n if (prevActiveEntry.tree === activeTree) {\n // Fast path. The active tree hasn't changed, so we can reuse the\n // existing state.\n return prevActiveEntry\n }\n\n // The route tree changed. Note that this doesn't mean that the tree changed\n // *at this level* — the change may be due to a child route. Either way, we\n // need to either add or update the router tree in the bfcache.\n //\n // The rest of the code looks more complicated than it actually is because we\n // can't mutate the state in place; we have to copy-on-write.\n\n // Create a new entry for the active cache key. This is the head of the new\n // linked list.\n const newActiveEntry: RouterBFCacheEntry = {\n tree: activeTree,\n stateKey: activeStateKey,\n next: null,\n }\n\n // We need to append the old list onto the new list. If the head of the new\n // list was already present in the cache, then we'll need to clone everything\n // that came before it. Then we can reuse the rest.\n let n = 1\n let oldEntry: RouterBFCacheEntry | null = prevActiveEntry\n let clonedEntry: RouterBFCacheEntry = newActiveEntry\n while (oldEntry !== null && n < MAX_BF_CACHE_ENTRIES) {\n if (oldEntry.stateKey === activeStateKey) {\n // Fast path. This entry in the old list that corresponds to the key that\n // is now active. We've already placed a clone of this entry at the front\n // of the new list. We can reuse the rest of the old list without cloning.\n // NOTE: We don't need to worry about eviction in this case because we\n // haven't increased the size of the cache, and we assume the max size\n // is constant across renders. If we were to change it to a dynamic limit,\n // then the implementation would need to account for that.\n clonedEntry.next = oldEntry.next\n break\n } else {\n // Clone the entry and append it to the list.\n n++\n const entry: RouterBFCacheEntry = {\n tree: oldEntry.tree,\n stateKey: oldEntry.stateKey,\n next: null,\n }\n clonedEntry.next = entry\n clonedEntry = entry\n }\n oldEntry = oldEntry.next\n }\n\n setPrevActiveEntry(newActiveEntry)\n return newActiveEntry\n}\n"],"names":["useState","MAX_BF_CACHE_ENTRIES","process","env","__NEXT_ROUTER_BF_CACHE","useRouterBFCache","activeTree","activeStateKey","prevActiveEntry","setPrevActiveEntry","initialEntry","tree","stateKey","next","newActiveEntry","n","oldEntry","clonedEntry","entry"],"mappings":"AACA,SAASA,QAAQ,QAAQ,QAAO;AAEhC,kEAAkE;AAClE,MAAMC,uBAAuBC,QAAQC,GAAG,CAACC,sBAAsB,GAAG,IAAI;AAStE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,iBACdC,UAA6B,EAC7BC,cAAsB;IAEtB,wEAAwE;IACxE,2EAA2E;IAC3E,2DAA2D;IAC3D,yEAAyE;IACzE,2EAA2E;IAC3E,2EAA2E;IAC3E,4EAA4E;IAC5E,wEAAwE;IACxE,sEAAsE;IACtE,MAAM,CAACC,iBAAiBC,mBAAmB,GAAGT,SAC5C;QACE,MAAMU,eAAmC;YACvCC,MAAML;YACNM,UAAUL;YACVM,MAAM;QACR;QACA,OAAOH;IACT;IAGF,IAAIF,gBAAgBG,IAAI,KAAKL,YAAY;QACvC,iEAAiE;QACjE,kBAAkB;QAClB,OAAOE;IACT;IAEA,4EAA4E;IAC5E,2EAA2E;IAC3E,+DAA+D;IAC/D,EAAE;IACF,6EAA6E;IAC7E,6DAA6D;IAE7D,2EAA2E;IAC3E,eAAe;IACf,MAAMM,iBAAqC;QACzCH,MAAML;QACNM,UAAUL;QACVM,MAAM;IACR;IAEA,2EAA2E;IAC3E,6EAA6E;IAC7E,mDAAmD;IACnD,IAAIE,IAAI;IACR,IAAIC,WAAsCR;IAC1C,IAAIS,cAAkCH;IACtC,MAAOE,aAAa,QAAQD,IAAId,qBAAsB;QACpD,IAAIe,SAASJ,QAAQ,KAAKL,gBAAgB;YACxC,yEAAyE;YACzE,yEAAyE;YACzE,0EAA0E;YAC1E,sEAAsE;YACtE,sEAAsE;YACtE,0EAA0E;YAC1E,0DAA0D;YAC1DU,YAAYJ,IAAI,GAAGG,SAASH,IAAI;YAChC;QACF,OAAO;YACL,6CAA6C;YAC7CE;YACA,MAAMG,QAA4B;gBAChCP,MAAMK,SAASL,IAAI;gBACnBC,UAAUI,SAASJ,QAAQ;gBAC3BC,MAAM;YACR;YACAI,YAAYJ,IAAI,GAAGK;YACnBD,cAAcC;QAChB;QACAF,WAAWA,SAASH,IAAI;IAC1B;IAEAJ,mBAAmBK;IACnB,OAAOA;AACT"}
@@ -14,6 +14,8 @@ import { HTTPAccessFallbackBoundary } from './http-access-fallback/error-boundar
14
14
  import { createRouterCacheKey } from './router-reducer/create-router-cache-key';
15
15
  import { hasInterceptionRouteInCurrentTree } from './router-reducer/reducers/has-interception-route-in-current-tree';
16
16
  import { dispatchAppRouterAction } from './use-action-queue';
17
+ import { useRouterBFCache } from './bfcache';
18
+ const Activity = process.env.__NEXT_ROUTER_BF_CACHE ? require('react').unstable_Activity : null;
17
19
  /**
18
20
  * Add refetch marker to router state at the point of the current layout segment.
19
21
  * This ensures the response returned is not further down than the current layout segment.
@@ -371,11 +373,7 @@ function ScrollAndFocusHandler(param) {
371
373
  segmentMap = new Map();
372
374
  parentParallelRoutes.set(parallelRouterKey, segmentMap);
373
375
  }
374
- // Get the active segment in the tree
375
- // The reason arrays are used in the data format is that these are transferred from the server to the browser so it's optimized to save bytes.
376
376
  const parentTreeSegment = parentTree[0];
377
- const tree = parentTree[1][parallelRouterKey];
378
- const treeSegment = tree[0];
379
377
  const segmentPath = parentSegmentPath === null ? // path. This has led to a bunch of special cases scattered throughout
380
378
  // the code. We should clean this up.
381
379
  [
@@ -394,29 +392,43 @@ function ScrollAndFocusHandler(param) {
394
392
  // it's possible that the segment accessed the search params on the server.
395
393
  // (This only applies to page segments; layout segments cannot access search
396
394
  // params on the server.)
397
- const cacheKey = createRouterCacheKey(treeSegment);
398
- const stateKey = createRouterCacheKey(treeSegment, true) // no search params
395
+ const activeTree = parentTree[1][parallelRouterKey];
396
+ const activeSegment = activeTree[0];
397
+ const activeStateKey = createRouterCacheKey(activeSegment, true) // no search params
399
398
  ;
400
- // Read segment path from the parallel router cache node.
401
- let cacheNode = segmentMap.get(cacheKey);
402
- if (cacheNode === undefined) {
403
- // When data is not available during rendering client-side we need to fetch
404
- // it from the server.
405
- const newLazyCacheNode = {
406
- lazyData: null,
407
- rsc: null,
408
- prefetchRsc: null,
409
- head: null,
410
- prefetchHead: null,
411
- parallelRoutes: new Map(),
412
- loading: null,
413
- navigatedAt: -1
414
- };
415
- // Flight data fetch kicked off during render and put into the cache.
416
- cacheNode = newLazyCacheNode;
417
- segmentMap.set(cacheKey, newLazyCacheNode);
418
- }
419
- /*
399
+ // At each level of the route tree, not only do we render the currently
400
+ // active segment — we also render the last N segments that were active at
401
+ // this level inside a hidden <Activity> boundary, to preserve their state
402
+ // if or when the user navigates to them again.
403
+ //
404
+ // bfcacheEntry is a linked list of FlightRouterStates.
405
+ let bfcacheEntry = useRouterBFCache(activeTree, activeStateKey);
406
+ let children = [];
407
+ do {
408
+ const tree = bfcacheEntry.tree;
409
+ const stateKey = bfcacheEntry.stateKey;
410
+ const segment = tree[0];
411
+ const cacheKey = createRouterCacheKey(segment);
412
+ // Read segment path from the parallel router cache node.
413
+ let cacheNode = segmentMap.get(cacheKey);
414
+ if (cacheNode === undefined) {
415
+ // When data is not available during rendering client-side we need to fetch
416
+ // it from the server.
417
+ const newLazyCacheNode = {
418
+ lazyData: null,
419
+ rsc: null,
420
+ prefetchRsc: null,
421
+ head: null,
422
+ prefetchHead: null,
423
+ parallelRoutes: new Map(),
424
+ loading: null,
425
+ navigatedAt: -1
426
+ };
427
+ // Flight data fetch kicked off during render and put into the cache.
428
+ cacheNode = newLazyCacheNode;
429
+ segmentMap.set(cacheKey, newLazyCacheNode);
430
+ }
431
+ /*
420
432
  - Error boundary
421
433
  - Only renders error boundary if error component is provided.
422
434
  - Rendered for each segment to ensure they have their own error state.
@@ -425,45 +437,55 @@ function ScrollAndFocusHandler(param) {
425
437
  - Rendered for each segment to ensure they have their own loading state.
426
438
  - Passed to the router during rendering to ensure it can be immediately rendered when suspending on a Flight fetch.
427
439
  */ // TODO: The loading module data for a segment is stored on the parent, then
428
- // applied to each of that parent segment's parallel route slots. In the
429
- // simple case where there's only one parallel route (the `children` slot),
430
- // this is no different from if the loading module data where stored on the
431
- // child directly. But I'm not sure this actually makes sense when there are
432
- // multiple parallel routes. It's not a huge issue because you always have
433
- // the option to define a narrower loading boundary for a particular slot. But
434
- // this sort of smells like an implementation accident to me.
435
- const loadingModuleData = parentCacheNode.loading;
436
- return /*#__PURE__*/ _jsxs(TemplateContext.Provider, {
437
- value: /*#__PURE__*/ _jsx(ScrollAndFocusHandler, {
438
- segmentPath: segmentPath,
439
- children: /*#__PURE__*/ _jsx(ErrorBoundary, {
440
- errorComponent: error,
441
- errorStyles: errorStyles,
442
- errorScripts: errorScripts,
443
- children: /*#__PURE__*/ _jsx(LoadingBoundary, {
444
- loading: loadingModuleData,
445
- children: /*#__PURE__*/ _jsx(HTTPAccessFallbackBoundary, {
446
- notFound: notFound,
447
- forbidden: forbidden,
448
- unauthorized: unauthorized,
449
- children: /*#__PURE__*/ _jsx(RedirectBoundary, {
450
- children: /*#__PURE__*/ _jsx(InnerLayoutRouter, {
451
- url: url,
452
- tree: tree,
453
- cacheNode: cacheNode,
454
- segmentPath: segmentPath
440
+ // applied to each of that parent segment's parallel route slots. In the
441
+ // simple case where there's only one parallel route (the `children` slot),
442
+ // this is no different from if the loading module data where stored on the
443
+ // child directly. But I'm not sure this actually makes sense when there are
444
+ // multiple parallel routes. It's not a huge issue because you always have
445
+ // the option to define a narrower loading boundary for a particular slot. But
446
+ // this sort of smells like an implementation accident to me.
447
+ const loadingModuleData = parentCacheNode.loading;
448
+ let child = /*#__PURE__*/ _jsxs(TemplateContext.Provider, {
449
+ value: /*#__PURE__*/ _jsx(ScrollAndFocusHandler, {
450
+ segmentPath: segmentPath,
451
+ children: /*#__PURE__*/ _jsx(ErrorBoundary, {
452
+ errorComponent: error,
453
+ errorStyles: errorStyles,
454
+ errorScripts: errorScripts,
455
+ children: /*#__PURE__*/ _jsx(LoadingBoundary, {
456
+ loading: loadingModuleData,
457
+ children: /*#__PURE__*/ _jsx(HTTPAccessFallbackBoundary, {
458
+ notFound: notFound,
459
+ forbidden: forbidden,
460
+ unauthorized: unauthorized,
461
+ children: /*#__PURE__*/ _jsx(RedirectBoundary, {
462
+ children: /*#__PURE__*/ _jsx(InnerLayoutRouter, {
463
+ url: url,
464
+ tree: tree,
465
+ cacheNode: cacheNode,
466
+ segmentPath: segmentPath
467
+ })
455
468
  })
456
469
  })
457
470
  })
458
471
  })
459
- })
460
- }),
461
- children: [
462
- templateStyles,
463
- templateScripts,
464
- template
465
- ]
466
- }, stateKey);
472
+ }),
473
+ children: [
474
+ templateStyles,
475
+ templateScripts,
476
+ template
477
+ ]
478
+ }, stateKey);
479
+ if (process.env.__NEXT_ROUTER_BF_CACHE) {
480
+ child = /*#__PURE__*/ _jsx(Activity, {
481
+ mode: stateKey === activeStateKey ? 'visible' : 'hidden',
482
+ children: child
483
+ }, stateKey);
484
+ }
485
+ children.push(child);
486
+ bfcacheEntry = bfcacheEntry.next;
487
+ }while (bfcacheEntry !== null);
488
+ return children;
467
489
  }
468
490
 
469
491
  //# sourceMappingURL=layout-router.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/components/layout-router.tsx"],"sourcesContent":["'use client'\n\nimport type {\n CacheNode,\n LazyCacheNode,\n LoadingModuleData,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport type {\n FlightRouterState,\n FlightSegmentPath,\n} from '../../server/app-render/types'\nimport type { ErrorComponent } from './error-boundary'\nimport {\n ACTION_SERVER_PATCH,\n type FocusAndScrollRef,\n} from './router-reducer/router-reducer-types'\n\nimport React, {\n useContext,\n use,\n startTransition,\n Suspense,\n useDeferredValue,\n type JSX,\n} from 'react'\nimport ReactDOM from 'react-dom'\nimport {\n LayoutRouterContext,\n GlobalLayoutRouterContext,\n TemplateContext,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport { fetchServerResponse } from './router-reducer/fetch-server-response'\nimport { unresolvedThenable } from './unresolved-thenable'\nimport { ErrorBoundary } from './error-boundary'\nimport { matchSegment } from './match-segments'\nimport { handleSmoothScroll } from '../../shared/lib/router/utils/handle-smooth-scroll'\nimport { RedirectBoundary } from './redirect-boundary'\nimport { HTTPAccessFallbackBoundary } from './http-access-fallback/error-boundary'\nimport { createRouterCacheKey } from './router-reducer/create-router-cache-key'\nimport { hasInterceptionRouteInCurrentTree } from './router-reducer/reducers/has-interception-route-in-current-tree'\nimport { dispatchAppRouterAction } from './use-action-queue'\n\n/**\n * Add refetch marker to router state at the point of the current layout segment.\n * This ensures the response returned is not further down than the current layout segment.\n */\nfunction walkAddRefetch(\n segmentPathToWalk: FlightSegmentPath | undefined,\n treeToRecreate: FlightRouterState\n): FlightRouterState {\n if (segmentPathToWalk) {\n const [segment, parallelRouteKey] = segmentPathToWalk\n const isLast = segmentPathToWalk.length === 2\n\n if (matchSegment(treeToRecreate[0], segment)) {\n if (treeToRecreate[1].hasOwnProperty(parallelRouteKey)) {\n if (isLast) {\n const subTree = walkAddRefetch(\n undefined,\n treeToRecreate[1][parallelRouteKey]\n )\n return [\n treeToRecreate[0],\n {\n ...treeToRecreate[1],\n [parallelRouteKey]: [\n subTree[0],\n subTree[1],\n subTree[2],\n 'refetch',\n ],\n },\n ]\n }\n\n return [\n treeToRecreate[0],\n {\n ...treeToRecreate[1],\n [parallelRouteKey]: walkAddRefetch(\n segmentPathToWalk.slice(2),\n treeToRecreate[1][parallelRouteKey]\n ),\n },\n ]\n }\n }\n }\n\n return treeToRecreate\n}\n\nconst __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = (\n ReactDOM as any\n).__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE\n\n// TODO-APP: Replace with new React API for finding dom nodes without a `ref` when available\n/**\n * Wraps ReactDOM.findDOMNode with additional logic to hide React Strict Mode warning\n */\nfunction findDOMNode(\n instance: React.ReactInstance | null | undefined\n): Element | Text | null {\n // Tree-shake for server bundle\n if (typeof window === 'undefined') return null\n\n // __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode is null during module init.\n // We need to lazily reference it.\n const internal_reactDOMfindDOMNode =\n __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode\n return internal_reactDOMfindDOMNode(instance)\n}\n\nconst rectProperties = [\n 'bottom',\n 'height',\n 'left',\n 'right',\n 'top',\n 'width',\n 'x',\n 'y',\n] as const\n/**\n * Check if a HTMLElement is hidden or fixed/sticky position\n */\nfunction shouldSkipElement(element: HTMLElement) {\n // we ignore fixed or sticky positioned elements since they'll likely pass the \"in-viewport\" check\n // and will result in a situation we bail on scroll because of something like a fixed nav,\n // even though the actual page content is offscreen\n if (['sticky', 'fixed'].includes(getComputedStyle(element).position)) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n 'Skipping auto-scroll behavior due to `position: sticky` or `position: fixed` on element:',\n element\n )\n }\n return true\n }\n\n // Uses `getBoundingClientRect` to check if the element is hidden instead of `offsetParent`\n // because `offsetParent` doesn't consider document/body\n const rect = element.getBoundingClientRect()\n return rectProperties.every((item) => rect[item] === 0)\n}\n\n/**\n * Check if the top corner of the HTMLElement is in the viewport.\n */\nfunction topOfElementInViewport(element: HTMLElement, viewportHeight: number) {\n const rect = element.getBoundingClientRect()\n return rect.top >= 0 && rect.top <= viewportHeight\n}\n\n/**\n * Find the DOM node for a hash fragment.\n * If `top` the page has to scroll to the top of the page. This mirrors the browser's behavior.\n * If the hash fragment is an id, the page has to scroll to the element with that id.\n * If the hash fragment is a name, the page has to scroll to the first element with that name.\n */\nfunction getHashFragmentDomNode(hashFragment: string) {\n // If the hash fragment is `top` the page has to scroll to the top of the page.\n if (hashFragment === 'top') {\n return document.body\n }\n\n // If the hash fragment is an id, the page has to scroll to the element with that id.\n return (\n document.getElementById(hashFragment) ??\n // If the hash fragment is a name, the page has to scroll to the first element with that name.\n document.getElementsByName(hashFragment)[0]\n )\n}\ninterface ScrollAndFocusHandlerProps {\n focusAndScrollRef: FocusAndScrollRef\n children: React.ReactNode\n segmentPath: FlightSegmentPath\n}\nclass InnerScrollAndFocusHandler extends React.Component<ScrollAndFocusHandlerProps> {\n handlePotentialScroll = () => {\n // Handle scroll and focus, it's only applied once in the first useEffect that triggers that changed.\n const { focusAndScrollRef, segmentPath } = this.props\n\n if (focusAndScrollRef.apply) {\n // segmentPaths is an array of segment paths that should be scrolled to\n // if the current segment path is not in the array, the scroll is not applied\n // unless the array is empty, in which case the scroll is always applied\n if (\n focusAndScrollRef.segmentPaths.length !== 0 &&\n !focusAndScrollRef.segmentPaths.some((scrollRefSegmentPath) =>\n segmentPath.every((segment, index) =>\n matchSegment(segment, scrollRefSegmentPath[index])\n )\n )\n ) {\n return\n }\n\n let domNode:\n | ReturnType<typeof getHashFragmentDomNode>\n | ReturnType<typeof findDOMNode> = null\n const hashFragment = focusAndScrollRef.hashFragment\n\n if (hashFragment) {\n domNode = getHashFragmentDomNode(hashFragment)\n }\n\n // `findDOMNode` is tricky because it returns just the first child if the component is a fragment.\n // This already caused a bug where the first child was a <link/> in head.\n if (!domNode) {\n domNode = findDOMNode(this)\n }\n\n // If there is no DOM node this layout-router level is skipped. It'll be handled higher-up in the tree.\n if (!(domNode instanceof Element)) {\n return\n }\n\n // Verify if the element is a HTMLElement and if we want to consider it for scroll behavior.\n // If the element is skipped, try to select the next sibling and try again.\n while (!(domNode instanceof HTMLElement) || shouldSkipElement(domNode)) {\n if (process.env.NODE_ENV !== 'production') {\n if (domNode.parentElement?.localName === 'head') {\n // TODO: We enter this state when metadata was rendered as part of the page or via Next.js.\n // This is always a bug in Next.js and caused by React hoisting metadata.\n // We need to replace `findDOMNode` in favor of Fragment Refs (when available) so that we can skip over metadata.\n }\n }\n\n // No siblings found that match the criteria are found, so handle scroll higher up in the tree instead.\n if (domNode.nextElementSibling === null) {\n return\n }\n domNode = domNode.nextElementSibling\n }\n\n // State is mutated to ensure that the focus and scroll is applied only once.\n focusAndScrollRef.apply = false\n focusAndScrollRef.hashFragment = null\n focusAndScrollRef.segmentPaths = []\n\n handleSmoothScroll(\n () => {\n // In case of hash scroll, we only need to scroll the element into view\n if (hashFragment) {\n ;(domNode as HTMLElement).scrollIntoView()\n\n return\n }\n // Store the current viewport height because reading `clientHeight` causes a reflow,\n // and it won't change during this function.\n const htmlElement = document.documentElement\n const viewportHeight = htmlElement.clientHeight\n\n // If the element's top edge is already in the viewport, exit early.\n if (topOfElementInViewport(domNode as HTMLElement, viewportHeight)) {\n return\n }\n\n // Otherwise, try scrolling go the top of the document to be backward compatible with pages\n // scrollIntoView() called on `<html/>` element scrolls horizontally on chrome and firefox (that shouldn't happen)\n // We could use it to scroll horizontally following RTL but that also seems to be broken - it will always scroll left\n // scrollLeft = 0 also seems to ignore RTL and manually checking for RTL is too much hassle so we will scroll just vertically\n htmlElement.scrollTop = 0\n\n // Scroll to domNode if domNode is not in viewport when scrolled to top of document\n if (!topOfElementInViewport(domNode as HTMLElement, viewportHeight)) {\n // Scroll into view doesn't scroll horizontally by default when not needed\n ;(domNode as HTMLElement).scrollIntoView()\n }\n },\n {\n // We will force layout by querying domNode position\n dontForceLayout: true,\n onlyHashChange: focusAndScrollRef.onlyHashChange,\n }\n )\n\n // Mutate after scrolling so that it can be read by `handleSmoothScroll`\n focusAndScrollRef.onlyHashChange = false\n\n // Set focus on the element\n domNode.focus()\n }\n }\n\n componentDidMount() {\n this.handlePotentialScroll()\n }\n\n componentDidUpdate() {\n // Because this property is overwritten in handlePotentialScroll it's fine to always run it when true as it'll be set to false for subsequent renders.\n if (this.props.focusAndScrollRef.apply) {\n this.handlePotentialScroll()\n }\n }\n\n render() {\n return this.props.children\n }\n}\n\nfunction ScrollAndFocusHandler({\n segmentPath,\n children,\n}: {\n segmentPath: FlightSegmentPath\n children: React.ReactNode\n}) {\n const context = useContext(GlobalLayoutRouterContext)\n if (!context) {\n throw new Error('invariant global layout router not mounted')\n }\n\n return (\n <InnerScrollAndFocusHandler\n segmentPath={segmentPath}\n focusAndScrollRef={context.focusAndScrollRef}\n >\n {children}\n </InnerScrollAndFocusHandler>\n )\n}\n\n/**\n * InnerLayoutRouter handles rendering the provided segment based on the cache.\n */\nfunction InnerLayoutRouter({\n tree,\n segmentPath,\n cacheNode,\n url,\n}: {\n tree: FlightRouterState\n segmentPath: FlightSegmentPath\n cacheNode: CacheNode\n url: string\n}) {\n const context = useContext(GlobalLayoutRouterContext)\n if (!context) {\n throw new Error('invariant global layout router not mounted')\n }\n\n const { tree: fullTree } = context\n\n // `rsc` represents the renderable node for this segment.\n\n // If this segment has a `prefetchRsc`, it's the statically prefetched data.\n // We should use that on initial render instead of `rsc`. Then we'll switch\n // to `rsc` when the dynamic response streams in.\n //\n // If no prefetch data is available, then we go straight to rendering `rsc`.\n const resolvedPrefetchRsc =\n cacheNode.prefetchRsc !== null ? cacheNode.prefetchRsc : cacheNode.rsc\n\n // We use `useDeferredValue` to handle switching between the prefetched and\n // final values. The second argument is returned on initial render, then it\n // re-renders with the first argument.\n const rsc: any = useDeferredValue(cacheNode.rsc, resolvedPrefetchRsc)\n\n // `rsc` is either a React node or a promise for a React node, except we\n // special case `null` to represent that this segment's data is missing. If\n // it's a promise, we need to unwrap it so we can determine whether or not the\n // data is missing.\n const resolvedRsc: React.ReactNode =\n typeof rsc === 'object' && rsc !== null && typeof rsc.then === 'function'\n ? use(rsc)\n : rsc\n\n if (!resolvedRsc) {\n // The data for this segment is not available, and there's no pending\n // navigation that will be able to fulfill it. We need to fetch more from\n // the server and patch the cache.\n\n // Check if there's already a pending request.\n let lazyData = cacheNode.lazyData\n if (lazyData === null) {\n /**\n * Router state with refetch marker added\n */\n // TODO-APP: remove ''\n const refetchTree = walkAddRefetch(['', ...segmentPath], fullTree)\n const includeNextUrl = hasInterceptionRouteInCurrentTree(fullTree)\n const navigatedAt = Date.now()\n cacheNode.lazyData = lazyData = fetchServerResponse(\n new URL(url, location.origin),\n {\n flightRouterState: refetchTree,\n nextUrl: includeNextUrl ? context.nextUrl : null,\n }\n ).then((serverResponse) => {\n startTransition(() => {\n dispatchAppRouterAction({\n type: ACTION_SERVER_PATCH,\n previousTree: fullTree,\n serverResponse,\n navigatedAt,\n })\n })\n\n return serverResponse\n })\n\n // Suspend while waiting for lazyData to resolve\n use(lazyData)\n }\n // Suspend infinitely as `changeByServerResponse` will cause a different part of the tree to be rendered.\n // A falsey `resolvedRsc` indicates missing data -- we should not commit that branch, and we need to wait for the data to arrive.\n use(unresolvedThenable) as never\n }\n\n // If we get to this point, then we know we have something we can render.\n const subtree = (\n // The layout router context narrows down tree and childNodes at each level.\n <LayoutRouterContext.Provider\n value={{\n parentTree: tree,\n parentCacheNode: cacheNode,\n parentSegmentPath: segmentPath,\n\n // TODO-APP: overriding of url for parallel routes\n url: url,\n }}\n >\n {resolvedRsc}\n </LayoutRouterContext.Provider>\n )\n // Ensure root layout is not wrapped in a div as the root layout renders `<html>`\n return subtree\n}\n\n/**\n * Renders suspense boundary with the provided \"loading\" property as the fallback.\n * If no loading property is provided it renders the children without a suspense boundary.\n */\nfunction LoadingBoundary({\n loading,\n children,\n}: {\n loading: LoadingModuleData | Promise<LoadingModuleData>\n children: React.ReactNode\n}): JSX.Element {\n // If loading is a promise, unwrap it. This happens in cases where we haven't\n // yet received the loading data from the server — which includes whether or\n // not this layout has a loading component at all.\n //\n // It's OK to suspend here instead of inside the fallback because this\n // promise will resolve simultaneously with the data for the segment itself.\n // So it will never suspend for longer than it would have if we didn't use\n // a Suspense fallback at all.\n let loadingModuleData\n if (\n typeof loading === 'object' &&\n loading !== null &&\n typeof (loading as any).then === 'function'\n ) {\n const promiseForLoading = loading as Promise<LoadingModuleData>\n loadingModuleData = use(promiseForLoading)\n } else {\n loadingModuleData = loading as LoadingModuleData\n }\n\n if (loadingModuleData) {\n const loadingRsc = loadingModuleData[0]\n const loadingStyles = loadingModuleData[1]\n const loadingScripts = loadingModuleData[2]\n return (\n <Suspense\n fallback={\n <>\n {loadingStyles}\n {loadingScripts}\n {loadingRsc}\n </>\n }\n >\n {children}\n </Suspense>\n )\n }\n\n return <>{children}</>\n}\n\n/**\n * OuterLayoutRouter handles the current segment as well as <Offscreen> rendering of other segments.\n * It can be rendered next to each other with a different `parallelRouterKey`, allowing for Parallel routes.\n */\nexport default function OuterLayoutRouter({\n parallelRouterKey,\n error,\n errorStyles,\n errorScripts,\n templateStyles,\n templateScripts,\n template,\n notFound,\n forbidden,\n unauthorized,\n}: {\n parallelRouterKey: string\n error: ErrorComponent | undefined\n errorStyles: React.ReactNode | undefined\n errorScripts: React.ReactNode | undefined\n templateStyles: React.ReactNode | undefined\n templateScripts: React.ReactNode | undefined\n template: React.ReactNode\n notFound: React.ReactNode | undefined\n forbidden: React.ReactNode | undefined\n unauthorized: React.ReactNode | undefined\n}) {\n const context = useContext(LayoutRouterContext)\n if (!context) {\n throw new Error('invariant expected layout router to be mounted')\n }\n\n const { parentTree, parentCacheNode, parentSegmentPath, url } = context\n\n // Get the CacheNode for this segment by reading it from the parent segment's\n // child map.\n const parentParallelRoutes = parentCacheNode.parallelRoutes\n let segmentMap = parentParallelRoutes.get(parallelRouterKey)\n // If the parallel router cache node does not exist yet, create it.\n // This writes to the cache when there is no item in the cache yet. It never *overwrites* existing cache items which is why it's safe in concurrent mode.\n if (!segmentMap) {\n segmentMap = new Map()\n parentParallelRoutes.set(parallelRouterKey, segmentMap)\n }\n\n // Get the active segment in the tree\n // The reason arrays are used in the data format is that these are transferred from the server to the browser so it's optimized to save bytes.\n const parentTreeSegment = parentTree[0]\n const tree = parentTree[1][parallelRouterKey]\n const treeSegment = tree[0]\n\n const segmentPath =\n parentSegmentPath === null\n ? // TODO: The root segment value is currently omitted from the segment\n // path. This has led to a bunch of special cases scattered throughout\n // the code. We should clean this up.\n [parallelRouterKey]\n : parentSegmentPath.concat([parentTreeSegment, parallelRouterKey])\n\n // The \"state\" key of a segment is the one passed to React — it represents the\n // identity of the UI tree. Whenever the state key changes, the tree is\n // recreated and the state is reset. In the App Router model, search params do\n // not cause state to be lost, so two segments with the same segment path but\n // different search params should have the same state key.\n //\n // The \"cache\" key of a segment, however, *does* include the search params, if\n // it's possible that the segment accessed the search params on the server.\n // (This only applies to page segments; layout segments cannot access search\n // params on the server.)\n const cacheKey = createRouterCacheKey(treeSegment)\n const stateKey = createRouterCacheKey(treeSegment, true) // no search params\n\n // Read segment path from the parallel router cache node.\n let cacheNode = segmentMap.get(cacheKey)\n if (cacheNode === undefined) {\n // When data is not available during rendering client-side we need to fetch\n // it from the server.\n const newLazyCacheNode: LazyCacheNode = {\n lazyData: null,\n rsc: null,\n prefetchRsc: null,\n head: null,\n prefetchHead: null,\n parallelRoutes: new Map(),\n loading: null,\n navigatedAt: -1,\n }\n\n // Flight data fetch kicked off during render and put into the cache.\n cacheNode = newLazyCacheNode\n segmentMap.set(cacheKey, newLazyCacheNode)\n }\n\n /*\n - Error boundary\n - Only renders error boundary if error component is provided.\n - Rendered for each segment to ensure they have their own error state.\n - Loading boundary\n - Only renders suspense boundary if loading components is provided.\n - Rendered for each segment to ensure they have their own loading state.\n - Passed to the router during rendering to ensure it can be immediately rendered when suspending on a Flight fetch.\n */\n\n // TODO: The loading module data for a segment is stored on the parent, then\n // applied to each of that parent segment's parallel route slots. In the\n // simple case where there's only one parallel route (the `children` slot),\n // this is no different from if the loading module data where stored on the\n // child directly. But I'm not sure this actually makes sense when there are\n // multiple parallel routes. It's not a huge issue because you always have\n // the option to define a narrower loading boundary for a particular slot. But\n // this sort of smells like an implementation accident to me.\n const loadingModuleData = parentCacheNode.loading\n\n return (\n <TemplateContext.Provider\n key={stateKey}\n value={\n <ScrollAndFocusHandler segmentPath={segmentPath}>\n <ErrorBoundary\n errorComponent={error}\n errorStyles={errorStyles}\n errorScripts={errorScripts}\n >\n <LoadingBoundary loading={loadingModuleData}>\n <HTTPAccessFallbackBoundary\n notFound={notFound}\n forbidden={forbidden}\n unauthorized={unauthorized}\n >\n <RedirectBoundary>\n <InnerLayoutRouter\n url={url}\n tree={tree}\n cacheNode={cacheNode}\n segmentPath={segmentPath}\n />\n </RedirectBoundary>\n </HTTPAccessFallbackBoundary>\n </LoadingBoundary>\n </ErrorBoundary>\n </ScrollAndFocusHandler>\n }\n >\n {templateStyles}\n {templateScripts}\n {template}\n </TemplateContext.Provider>\n )\n}\n"],"names":["ACTION_SERVER_PATCH","React","useContext","use","startTransition","Suspense","useDeferredValue","ReactDOM","LayoutRouterContext","GlobalLayoutRouterContext","TemplateContext","fetchServerResponse","unresolvedThenable","ErrorBoundary","matchSegment","handleSmoothScroll","RedirectBoundary","HTTPAccessFallbackBoundary","createRouterCacheKey","hasInterceptionRouteInCurrentTree","dispatchAppRouterAction","walkAddRefetch","segmentPathToWalk","treeToRecreate","segment","parallelRouteKey","isLast","length","hasOwnProperty","subTree","undefined","slice","__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE","findDOMNode","instance","window","internal_reactDOMfindDOMNode","rectProperties","shouldSkipElement","element","includes","getComputedStyle","position","process","env","NODE_ENV","console","warn","rect","getBoundingClientRect","every","item","topOfElementInViewport","viewportHeight","top","getHashFragmentDomNode","hashFragment","document","body","getElementById","getElementsByName","InnerScrollAndFocusHandler","Component","componentDidMount","handlePotentialScroll","componentDidUpdate","props","focusAndScrollRef","apply","render","children","segmentPath","segmentPaths","some","scrollRefSegmentPath","index","domNode","Element","HTMLElement","parentElement","localName","nextElementSibling","scrollIntoView","htmlElement","documentElement","clientHeight","scrollTop","dontForceLayout","onlyHashChange","focus","ScrollAndFocusHandler","context","Error","InnerLayoutRouter","tree","cacheNode","url","fullTree","resolvedPrefetchRsc","prefetchRsc","rsc","resolvedRsc","then","lazyData","refetchTree","includeNextUrl","navigatedAt","Date","now","URL","location","origin","flightRouterState","nextUrl","serverResponse","type","previousTree","subtree","Provider","value","parentTree","parentCacheNode","parentSegmentPath","LoadingBoundary","loading","loadingModuleData","promiseForLoading","loadingRsc","loadingStyles","loadingScripts","fallback","OuterLayoutRouter","parallelRouterKey","error","errorStyles","errorScripts","templateStyles","templateScripts","template","notFound","forbidden","unauthorized","parentParallelRoutes","parallelRoutes","segmentMap","get","Map","set","parentTreeSegment","treeSegment","concat","cacheKey","stateKey","newLazyCacheNode","head","prefetchHead","errorComponent"],"mappings":"AAAA;;AAYA,SACEA,mBAAmB,QAEd,wCAAuC;AAE9C,OAAOC,SACLC,UAAU,EACVC,GAAG,EACHC,eAAe,EACfC,QAAQ,EACRC,gBAAgB,QAEX,QAAO;AACd,OAAOC,cAAc,YAAW;AAChC,SACEC,mBAAmB,EACnBC,yBAAyB,EACzBC,eAAe,QACV,qDAAoD;AAC3D,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,aAAa,QAAQ,mBAAkB;AAChD,SAASC,YAAY,QAAQ,mBAAkB;AAC/C,SAASC,kBAAkB,QAAQ,qDAAoD;AACvF,SAASC,gBAAgB,QAAQ,sBAAqB;AACtD,SAASC,0BAA0B,QAAQ,wCAAuC;AAClF,SAASC,oBAAoB,QAAQ,2CAA0C;AAC/E,SAASC,iCAAiC,QAAQ,mEAAkE;AACpH,SAASC,uBAAuB,QAAQ,qBAAoB;AAE5D;;;CAGC,GACD,SAASC,eACPC,iBAAgD,EAChDC,cAAiC;IAEjC,IAAID,mBAAmB;QACrB,MAAM,CAACE,SAASC,iBAAiB,GAAGH;QACpC,MAAMI,SAASJ,kBAAkBK,MAAM,KAAK;QAE5C,IAAIb,aAAaS,cAAc,CAAC,EAAE,EAAEC,UAAU;YAC5C,IAAID,cAAc,CAAC,EAAE,CAACK,cAAc,CAACH,mBAAmB;gBACtD,IAAIC,QAAQ;oBACV,MAAMG,UAAUR,eACdS,WACAP,cAAc,CAAC,EAAE,CAACE,iBAAiB;oBAErC,OAAO;wBACLF,cAAc,CAAC,EAAE;wBACjB;4BACE,GAAGA,cAAc,CAAC,EAAE;4BACpB,CAACE,iBAAiB,EAAE;g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;IAC3E,4EAA4E;IAC5E,yBAAyB;IACzB,MAAMmB,WAAWrI,qBAAqBmI;IACtC,MAAMG,WAAWtI,qBAAqBmI,aAAa,MAAM,mBAAmB;;IAE5E,yDAAyD;IACzD,IAAItD,YAAYiD,WAAWC,GAAG,CAACM;IAC/B,IAAIxD,cAAcjE,WAAW;QAC3B,2EAA2E;QAC3E,sBAAsB;QACtB,MAAM2H,mBAAkC;YACtClD,UAAU;YACVH,KAAK;YACLD,aAAa;YACbuD,MAAM;YACNC,cAAc;YACdZ,gBAAgB,IAAIG;YACpBtB,SAAS;YACTlB,aAAa,CAAC;QAChB;QAEA,qEAAqE;QACrEX,YAAY0D;QACZT,WAAWG,GAAG,CAACI,UAAUE;IAC3B;IAEA;;;;;;;;EAQA,GAEA,4EAA4E;IAC5E,wEAAwE;IACxE,2EAA2E;IAC3E,2EAA2E;IAC3E,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,6DAA6D;IAC7D,MAAM5B,oBAAoBJ,gBAAgBG,OAAO;IAEjD,qBACE,MAAClH,gBAAgB4G,QAAQ;QAEvBC,qBACE,KAAC7B;YAAsBnB,aAAaA;sBAClC,cAAA,KAAC1D;gBACC+I,gBAAgBvB;gBAChBC,aAAaA;gBACbC,cAAcA;0BAEd,cAAA,KAACZ;oBAAgBC,SAASC;8BACxB,cAAA,KAAC5G;wBACC0H,UAAUA;wBACVC,WAAWA;wBACXC,cAAcA;kCAEd,cAAA,KAAC7H;sCACC,cAAA,KAAC6E;gCACCG,KAAKA;gCACLF,MAAMA;gCACNC,WAAWA;gCACXxB,aAAaA;;;;;;;;YAS1BiE;YACAC;YACAC;;OA9BIc;AAiCX"}
1
+ {"version":3,"sources":["../../../src/client/components/layout-router.tsx"],"sourcesContent":["'use client'\n\nimport type {\n CacheNode,\n LazyCacheNode,\n LoadingModuleData,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport type {\n FlightRouterState,\n FlightSegmentPath,\n} from '../../server/app-render/types'\nimport type { ErrorComponent } from './error-boundary'\nimport {\n ACTION_SERVER_PATCH,\n type FocusAndScrollRef,\n} from './router-reducer/router-reducer-types'\n\nimport React, {\n useContext,\n use,\n startTransition,\n Suspense,\n useDeferredValue,\n type JSX,\n} from 'react'\nimport ReactDOM from 'react-dom'\nimport {\n LayoutRouterContext,\n GlobalLayoutRouterContext,\n TemplateContext,\n} from '../../shared/lib/app-router-context.shared-runtime'\nimport { fetchServerResponse } from './router-reducer/fetch-server-response'\nimport { unresolvedThenable } from './unresolved-thenable'\nimport { ErrorBoundary } from './error-boundary'\nimport { matchSegment } from './match-segments'\nimport { handleSmoothScroll } from '../../shared/lib/router/utils/handle-smooth-scroll'\nimport { RedirectBoundary } from './redirect-boundary'\nimport { HTTPAccessFallbackBoundary } from './http-access-fallback/error-boundary'\nimport { createRouterCacheKey } from './router-reducer/create-router-cache-key'\nimport { hasInterceptionRouteInCurrentTree } from './router-reducer/reducers/has-interception-route-in-current-tree'\nimport { dispatchAppRouterAction } from './use-action-queue'\nimport { useRouterBFCache, type RouterBFCacheEntry } from './bfcache'\n\nconst Activity = process.env.__NEXT_ROUTER_BF_CACHE\n ? require('react').unstable_Activity\n : null\n\n/**\n * Add refetch marker to router state at the point of the current layout segment.\n * This ensures the response returned is not further down than the current layout segment.\n */\nfunction walkAddRefetch(\n segmentPathToWalk: FlightSegmentPath | undefined,\n treeToRecreate: FlightRouterState\n): FlightRouterState {\n if (segmentPathToWalk) {\n const [segment, parallelRouteKey] = segmentPathToWalk\n const isLast = segmentPathToWalk.length === 2\n\n if (matchSegment(treeToRecreate[0], segment)) {\n if (treeToRecreate[1].hasOwnProperty(parallelRouteKey)) {\n if (isLast) {\n const subTree = walkAddRefetch(\n undefined,\n treeToRecreate[1][parallelRouteKey]\n )\n return [\n treeToRecreate[0],\n {\n ...treeToRecreate[1],\n [parallelRouteKey]: [\n subTree[0],\n subTree[1],\n subTree[2],\n 'refetch',\n ],\n },\n ]\n }\n\n return [\n treeToRecreate[0],\n {\n ...treeToRecreate[1],\n [parallelRouteKey]: walkAddRefetch(\n segmentPathToWalk.slice(2),\n treeToRecreate[1][parallelRouteKey]\n ),\n },\n ]\n }\n }\n }\n\n return treeToRecreate\n}\n\nconst __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = (\n ReactDOM as any\n).__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE\n\n// TODO-APP: Replace with new React API for finding dom nodes without a `ref` when available\n/**\n * Wraps ReactDOM.findDOMNode with additional logic to hide React Strict Mode warning\n */\nfunction findDOMNode(\n instance: React.ReactInstance | null | undefined\n): Element | Text | null {\n // Tree-shake for server bundle\n if (typeof window === 'undefined') return null\n\n // __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode is null during module init.\n // We need to lazily reference it.\n const internal_reactDOMfindDOMNode =\n __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE.findDOMNode\n return internal_reactDOMfindDOMNode(instance)\n}\n\nconst rectProperties = [\n 'bottom',\n 'height',\n 'left',\n 'right',\n 'top',\n 'width',\n 'x',\n 'y',\n] as const\n/**\n * Check if a HTMLElement is hidden or fixed/sticky position\n */\nfunction shouldSkipElement(element: HTMLElement) {\n // we ignore fixed or sticky positioned elements since they'll likely pass the \"in-viewport\" check\n // and will result in a situation we bail on scroll because of something like a fixed nav,\n // even though the actual page content is offscreen\n if (['sticky', 'fixed'].includes(getComputedStyle(element).position)) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n 'Skipping auto-scroll behavior due to `position: sticky` or `position: fixed` on element:',\n element\n )\n }\n return true\n }\n\n // Uses `getBoundingClientRect` to check if the element is hidden instead of `offsetParent`\n // because `offsetParent` doesn't consider document/body\n const rect = element.getBoundingClientRect()\n return rectProperties.every((item) => rect[item] === 0)\n}\n\n/**\n * Check if the top corner of the HTMLElement is in the viewport.\n */\nfunction topOfElementInViewport(element: HTMLElement, viewportHeight: number) {\n const rect = element.getBoundingClientRect()\n return rect.top >= 0 && rect.top <= viewportHeight\n}\n\n/**\n * Find the DOM node for a hash fragment.\n * If `top` the page has to scroll to the top of the page. This mirrors the browser's behavior.\n * If the hash fragment is an id, the page has to scroll to the element with that id.\n * If the hash fragment is a name, the page has to scroll to the first element with that name.\n */\nfunction getHashFragmentDomNode(hashFragment: string) {\n // If the hash fragment is `top` the page has to scroll to the top of the page.\n if (hashFragment === 'top') {\n return document.body\n }\n\n // If the hash fragment is an id, the page has to scroll to the element with that id.\n return (\n document.getElementById(hashFragment) ??\n // If the hash fragment is a name, the page has to scroll to the first element with that name.\n document.getElementsByName(hashFragment)[0]\n )\n}\ninterface ScrollAndFocusHandlerProps {\n focusAndScrollRef: FocusAndScrollRef\n children: React.ReactNode\n segmentPath: FlightSegmentPath\n}\nclass InnerScrollAndFocusHandler extends React.Component<ScrollAndFocusHandlerProps> {\n handlePotentialScroll = () => {\n // Handle scroll and focus, it's only applied once in the first useEffect that triggers that changed.\n const { focusAndScrollRef, segmentPath } = this.props\n\n if (focusAndScrollRef.apply) {\n // segmentPaths is an array of segment paths that should be scrolled to\n // if the current segment path is not in the array, the scroll is not applied\n // unless the array is empty, in which case the scroll is always applied\n if (\n focusAndScrollRef.segmentPaths.length !== 0 &&\n !focusAndScrollRef.segmentPaths.some((scrollRefSegmentPath) =>\n segmentPath.every((segment, index) =>\n matchSegment(segment, scrollRefSegmentPath[index])\n )\n )\n ) {\n return\n }\n\n let domNode:\n | ReturnType<typeof getHashFragmentDomNode>\n | ReturnType<typeof findDOMNode> = null\n const hashFragment = focusAndScrollRef.hashFragment\n\n if (hashFragment) {\n domNode = getHashFragmentDomNode(hashFragment)\n }\n\n // `findDOMNode` is tricky because it returns just the first child if the component is a fragment.\n // This already caused a bug where the first child was a <link/> in head.\n if (!domNode) {\n domNode = findDOMNode(this)\n }\n\n // If there is no DOM node this layout-router level is skipped. It'll be handled higher-up in the tree.\n if (!(domNode instanceof Element)) {\n return\n }\n\n // Verify if the element is a HTMLElement and if we want to consider it for scroll behavior.\n // If the element is skipped, try to select the next sibling and try again.\n while (!(domNode instanceof HTMLElement) || shouldSkipElement(domNode)) {\n if (process.env.NODE_ENV !== 'production') {\n if (domNode.parentElement?.localName === 'head') {\n // TODO: We enter this state when metadata was rendered as part of the page or via Next.js.\n // This is always a bug in Next.js and caused by React hoisting metadata.\n // We need to replace `findDOMNode` in favor of Fragment Refs (when available) so that we can skip over metadata.\n }\n }\n\n // No siblings found that match the criteria are found, so handle scroll higher up in the tree instead.\n if (domNode.nextElementSibling === null) {\n return\n }\n domNode = domNode.nextElementSibling\n }\n\n // State is mutated to ensure that the focus and scroll is applied only once.\n focusAndScrollRef.apply = false\n focusAndScrollRef.hashFragment = null\n focusAndScrollRef.segmentPaths = []\n\n handleSmoothScroll(\n () => {\n // In case of hash scroll, we only need to scroll the element into view\n if (hashFragment) {\n ;(domNode as HTMLElement).scrollIntoView()\n\n return\n }\n // Store the current viewport height because reading `clientHeight` causes a reflow,\n // and it won't change during this function.\n const htmlElement = document.documentElement\n const viewportHeight = htmlElement.clientHeight\n\n // If the element's top edge is already in the viewport, exit early.\n if (topOfElementInViewport(domNode as HTMLElement, viewportHeight)) {\n return\n }\n\n // Otherwise, try scrolling go the top of the document to be backward compatible with pages\n // scrollIntoView() called on `<html/>` element scrolls horizontally on chrome and firefox (that shouldn't happen)\n // We could use it to scroll horizontally following RTL but that also seems to be broken - it will always scroll left\n // scrollLeft = 0 also seems to ignore RTL and manually checking for RTL is too much hassle so we will scroll just vertically\n htmlElement.scrollTop = 0\n\n // Scroll to domNode if domNode is not in viewport when scrolled to top of document\n if (!topOfElementInViewport(domNode as HTMLElement, viewportHeight)) {\n // Scroll into view doesn't scroll horizontally by default when not needed\n ;(domNode as HTMLElement).scrollIntoView()\n }\n },\n {\n // We will force layout by querying domNode position\n dontForceLayout: true,\n onlyHashChange: focusAndScrollRef.onlyHashChange,\n }\n )\n\n // Mutate after scrolling so that it can be read by `handleSmoothScroll`\n focusAndScrollRef.onlyHashChange = false\n\n // Set focus on the element\n domNode.focus()\n }\n }\n\n componentDidMount() {\n this.handlePotentialScroll()\n }\n\n componentDidUpdate() {\n // Because this property is overwritten in handlePotentialScroll it's fine to always run it when true as it'll be set to false for subsequent renders.\n if (this.props.focusAndScrollRef.apply) {\n this.handlePotentialScroll()\n }\n }\n\n render() {\n return this.props.children\n }\n}\n\nfunction ScrollAndFocusHandler({\n segmentPath,\n children,\n}: {\n segmentPath: FlightSegmentPath\n children: React.ReactNode\n}) {\n const context = useContext(GlobalLayoutRouterContext)\n if (!context) {\n throw new Error('invariant global layout router not mounted')\n }\n\n return (\n <InnerScrollAndFocusHandler\n segmentPath={segmentPath}\n focusAndScrollRef={context.focusAndScrollRef}\n >\n {children}\n </InnerScrollAndFocusHandler>\n )\n}\n\n/**\n * InnerLayoutRouter handles rendering the provided segment based on the cache.\n */\nfunction InnerLayoutRouter({\n tree,\n segmentPath,\n cacheNode,\n url,\n}: {\n tree: FlightRouterState\n segmentPath: FlightSegmentPath\n cacheNode: CacheNode\n url: string\n}) {\n const context = useContext(GlobalLayoutRouterContext)\n if (!context) {\n throw new Error('invariant global layout router not mounted')\n }\n\n const { tree: fullTree } = context\n\n // `rsc` represents the renderable node for this segment.\n\n // If this segment has a `prefetchRsc`, it's the statically prefetched data.\n // We should use that on initial render instead of `rsc`. Then we'll switch\n // to `rsc` when the dynamic response streams in.\n //\n // If no prefetch data is available, then we go straight to rendering `rsc`.\n const resolvedPrefetchRsc =\n cacheNode.prefetchRsc !== null ? cacheNode.prefetchRsc : cacheNode.rsc\n\n // We use `useDeferredValue` to handle switching between the prefetched and\n // final values. The second argument is returned on initial render, then it\n // re-renders with the first argument.\n const rsc: any = useDeferredValue(cacheNode.rsc, resolvedPrefetchRsc)\n\n // `rsc` is either a React node or a promise for a React node, except we\n // special case `null` to represent that this segment's data is missing. If\n // it's a promise, we need to unwrap it so we can determine whether or not the\n // data is missing.\n const resolvedRsc: React.ReactNode =\n typeof rsc === 'object' && rsc !== null && typeof rsc.then === 'function'\n ? use(rsc)\n : rsc\n\n if (!resolvedRsc) {\n // The data for this segment is not available, and there's no pending\n // navigation that will be able to fulfill it. We need to fetch more from\n // the server and patch the cache.\n\n // Check if there's already a pending request.\n let lazyData = cacheNode.lazyData\n if (lazyData === null) {\n /**\n * Router state with refetch marker added\n */\n // TODO-APP: remove ''\n const refetchTree = walkAddRefetch(['', ...segmentPath], fullTree)\n const includeNextUrl = hasInterceptionRouteInCurrentTree(fullTree)\n const navigatedAt = Date.now()\n cacheNode.lazyData = lazyData = fetchServerResponse(\n new URL(url, location.origin),\n {\n flightRouterState: refetchTree,\n nextUrl: includeNextUrl ? context.nextUrl : null,\n }\n ).then((serverResponse) => {\n startTransition(() => {\n dispatchAppRouterAction({\n type: ACTION_SERVER_PATCH,\n previousTree: fullTree,\n serverResponse,\n navigatedAt,\n })\n })\n\n return serverResponse\n })\n\n // Suspend while waiting for lazyData to resolve\n use(lazyData)\n }\n // Suspend infinitely as `changeByServerResponse` will cause a different part of the tree to be rendered.\n // A falsey `resolvedRsc` indicates missing data -- we should not commit that branch, and we need to wait for the data to arrive.\n use(unresolvedThenable) as never\n }\n\n // If we get to this point, then we know we have something we can render.\n const subtree = (\n // The layout router context narrows down tree and childNodes at each level.\n <LayoutRouterContext.Provider\n value={{\n parentTree: tree,\n parentCacheNode: cacheNode,\n parentSegmentPath: segmentPath,\n\n // TODO-APP: overriding of url for parallel routes\n url: url,\n }}\n >\n {resolvedRsc}\n </LayoutRouterContext.Provider>\n )\n // Ensure root layout is not wrapped in a div as the root layout renders `<html>`\n return subtree\n}\n\n/**\n * Renders suspense boundary with the provided \"loading\" property as the fallback.\n * If no loading property is provided it renders the children without a suspense boundary.\n */\nfunction LoadingBoundary({\n loading,\n children,\n}: {\n loading: LoadingModuleData | Promise<LoadingModuleData>\n children: React.ReactNode\n}): JSX.Element {\n // If loading is a promise, unwrap it. This happens in cases where we haven't\n // yet received the loading data from the server — which includes whether or\n // not this layout has a loading component at all.\n //\n // It's OK to suspend here instead of inside the fallback because this\n // promise will resolve simultaneously with the data for the segment itself.\n // So it will never suspend for longer than it would have if we didn't use\n // a Suspense fallback at all.\n let loadingModuleData\n if (\n typeof loading === 'object' &&\n loading !== null &&\n typeof (loading as any).then === 'function'\n ) {\n const promiseForLoading = loading as Promise<LoadingModuleData>\n loadingModuleData = use(promiseForLoading)\n } else {\n loadingModuleData = loading as LoadingModuleData\n }\n\n if (loadingModuleData) {\n const loadingRsc = loadingModuleData[0]\n const loadingStyles = loadingModuleData[1]\n const loadingScripts = loadingModuleData[2]\n return (\n <Suspense\n fallback={\n <>\n {loadingStyles}\n {loadingScripts}\n {loadingRsc}\n </>\n }\n >\n {children}\n </Suspense>\n )\n }\n\n return <>{children}</>\n}\n\n/**\n * OuterLayoutRouter handles the current segment as well as <Offscreen> rendering of other segments.\n * It can be rendered next to each other with a different `parallelRouterKey`, allowing for Parallel routes.\n */\nexport default function OuterLayoutRouter({\n parallelRouterKey,\n error,\n errorStyles,\n errorScripts,\n templateStyles,\n templateScripts,\n template,\n notFound,\n forbidden,\n unauthorized,\n}: {\n parallelRouterKey: string\n error: ErrorComponent | undefined\n errorStyles: React.ReactNode | undefined\n errorScripts: React.ReactNode | undefined\n templateStyles: React.ReactNode | undefined\n templateScripts: React.ReactNode | undefined\n template: React.ReactNode\n notFound: React.ReactNode | undefined\n forbidden: React.ReactNode | undefined\n unauthorized: React.ReactNode | undefined\n}) {\n const context = useContext(LayoutRouterContext)\n if (!context) {\n throw new Error('invariant expected layout router to be mounted')\n }\n\n const { parentTree, parentCacheNode, parentSegmentPath, url } = context\n\n // Get the CacheNode for this segment by reading it from the parent segment's\n // child map.\n const parentParallelRoutes = parentCacheNode.parallelRoutes\n let segmentMap = parentParallelRoutes.get(parallelRouterKey)\n // If the parallel router cache node does not exist yet, create it.\n // This writes to the cache when there is no item in the cache yet. It never *overwrites* existing cache items which is why it's safe in concurrent mode.\n if (!segmentMap) {\n segmentMap = new Map()\n parentParallelRoutes.set(parallelRouterKey, segmentMap)\n }\n const parentTreeSegment = parentTree[0]\n const segmentPath =\n parentSegmentPath === null\n ? // TODO: The root segment value is currently omitted from the segment\n // path. This has led to a bunch of special cases scattered throughout\n // the code. We should clean this up.\n [parallelRouterKey]\n : parentSegmentPath.concat([parentTreeSegment, parallelRouterKey])\n\n // The \"state\" key of a segment is the one passed to React — it represents the\n // identity of the UI tree. Whenever the state key changes, the tree is\n // recreated and the state is reset. In the App Router model, search params do\n // not cause state to be lost, so two segments with the same segment path but\n // different search params should have the same state key.\n //\n // The \"cache\" key of a segment, however, *does* include the search params, if\n // it's possible that the segment accessed the search params on the server.\n // (This only applies to page segments; layout segments cannot access search\n // params on the server.)\n const activeTree = parentTree[1][parallelRouterKey]\n const activeSegment = activeTree[0]\n const activeStateKey = createRouterCacheKey(activeSegment, true) // no search params\n\n // At each level of the route tree, not only do we render the currently\n // active segment — we also render the last N segments that were active at\n // this level inside a hidden <Activity> boundary, to preserve their state\n // if or when the user navigates to them again.\n //\n // bfcacheEntry is a linked list of FlightRouterStates.\n let bfcacheEntry: RouterBFCacheEntry | null = useRouterBFCache(\n activeTree,\n activeStateKey\n )\n let children: Array<React.ReactNode> = []\n do {\n const tree = bfcacheEntry.tree\n const stateKey = bfcacheEntry.stateKey\n const segment = tree[0]\n const cacheKey = createRouterCacheKey(segment)\n\n // Read segment path from the parallel router cache node.\n let cacheNode = segmentMap.get(cacheKey)\n if (cacheNode === undefined) {\n // When data is not available during rendering client-side we need to fetch\n // it from the server.\n const newLazyCacheNode: LazyCacheNode = {\n lazyData: null,\n rsc: null,\n prefetchRsc: null,\n head: null,\n prefetchHead: null,\n parallelRoutes: new Map(),\n loading: null,\n navigatedAt: -1,\n }\n\n // Flight data fetch kicked off during render and put into the cache.\n cacheNode = newLazyCacheNode\n segmentMap.set(cacheKey, newLazyCacheNode)\n }\n\n /*\n - Error boundary\n - Only renders error boundary if error component is provided.\n - Rendered for each segment to ensure they have their own error state.\n - Loading boundary\n - Only renders suspense boundary if loading components is provided.\n - Rendered for each segment to ensure they have their own loading state.\n - Passed to the router during rendering to ensure it can be immediately rendered when suspending on a Flight fetch.\n */\n\n // TODO: The loading module data for a segment is stored on the parent, then\n // applied to each of that parent segment's parallel route slots. In the\n // simple case where there's only one parallel route (the `children` slot),\n // this is no different from if the loading module data where stored on the\n // child directly. But I'm not sure this actually makes sense when there are\n // multiple parallel routes. It's not a huge issue because you always have\n // the option to define a narrower loading boundary for a particular slot. But\n // this sort of smells like an implementation accident to me.\n const loadingModuleData = parentCacheNode.loading\n let child = (\n <TemplateContext.Provider\n key={stateKey}\n value={\n <ScrollAndFocusHandler segmentPath={segmentPath}>\n <ErrorBoundary\n errorComponent={error}\n errorStyles={errorStyles}\n errorScripts={errorScripts}\n >\n <LoadingBoundary loading={loadingModuleData}>\n <HTTPAccessFallbackBoundary\n notFound={notFound}\n forbidden={forbidden}\n unauthorized={unauthorized}\n >\n <RedirectBoundary>\n <InnerLayoutRouter\n url={url}\n tree={tree}\n cacheNode={cacheNode}\n segmentPath={segmentPath}\n />\n </RedirectBoundary>\n </HTTPAccessFallbackBoundary>\n </LoadingBoundary>\n </ErrorBoundary>\n </ScrollAndFocusHandler>\n }\n >\n {templateStyles}\n {templateScripts}\n {template}\n </TemplateContext.Provider>\n )\n\n if (process.env.__NEXT_ROUTER_BF_CACHE) {\n child = (\n <Activity\n key={stateKey}\n mode={stateKey === activeStateKey ? 'visible' : 'hidden'}\n >\n {child}\n </Activity>\n )\n }\n\n children.push(child)\n\n bfcacheEntry = bfcacheEntry.next\n } while (bfcacheEntry !== null)\n\n return children\n}\n"],"names":["ACTION_SERVER_PATCH","React","useContext","use","startTransition","Suspense","useDeferredValue","ReactDOM","LayoutRouterContext","GlobalLayoutRouterContext","TemplateContext","fetchServerResponse","unresolvedThenable","ErrorBoundary","matchSegment","handleSmoothScroll","RedirectBoundary","HTTPAccessFallbackBoundary","createRouterCacheKey","hasInterceptionRouteInCurrentTree","dispatchAppRouterAction","useRouterBFCache","Activity","process","env","__NEXT_ROUTER_BF_CACHE","require","unstable_Activity","walkAddRefetch","segmentPathToWalk","treeToRecreate","segment","parallelRouteKey","isLast","length","hasOwnProperty","subTree","undefined","slice","__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE","findDOMNode","instance","window","internal_reactDOMfindDOMNode","rectProperties","shouldSkipElement","element","includes","getComputedStyle","position","NODE_ENV","console","warn","rect","getBoundingClientRect","every","item","topOfElementInViewport","viewportHeight","top","getHashFragmentDomNode","hashFragment","document","body","getElementById","getElementsByName","InnerScrollAndFocusHandler","Component","componentDidMount","handlePotentialScroll","componentDidUpdate","props","focusAndScrollRef","apply","render","children","segmentPath","segmentPaths","some","scrollRefSegmentPath","index","domNode","Element","HTMLElement","parentElement","localName","nextElementSibling","scrollIntoView","htmlElement","documentElement","clientHeight","scrollTop","dontForceLayout","onlyHashChange","focus","ScrollAndFocusHandler","context","Error","InnerLayoutRouter","tree","cacheNode","url","fullTree","resolvedPrefetchRsc","prefetchRsc","rsc","resolvedRsc","then","lazyData","refetchTree","includeNextUrl","navigatedAt","Date","now","URL","location","origin","flightRouterState","nextUrl","serverResponse","type","previousTree","subtree","Provider","value","parentTree","parentCacheNode","parentSegmentPath","LoadingBoundary","loading","loadingModuleData","promiseForLoading","loadingRsc","loadingStyles","loadingScripts","fallback","OuterLayoutRouter","parallelRouterKey","error","errorStyles","errorScripts","templateStyles","templateScripts","template","notFound","forbidden","unauthorized","parentParallelRoutes","parallelRoutes","segmentMap","get","Map","set","parentTreeSegment","concat","activeTree","activeSegment","activeStateKey","bfcacheEntry","stateKey","cacheKey","newLazyCacheNode","head","prefetchHead","child","errorComponent","mode","push","next"],"mappings":"AAAA;;AAYA,SACEA,mBAAmB,QAEd,wCAAuC;AAE9C,OAAOC,SACLC,UAAU,EACVC,GAAG,EACHC,eAAe,EACfC,QAAQ,EACRC,gB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AAiB,YAAY;0BAE/CO;eAHIL;QAMX;QAEApF,SAAS4F,IAAI,CAACH;QAEdN,eAAeA,aAAaU,IAAI;IAClC,QAASV,iBAAiB,MAAK;IAE/B,OAAOnF;AACT"}
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
26
26
  import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
27
27
  import tracer from './tracing/tracer';
28
28
  import { isNextRouterError } from './components/is-next-router-error';
29
- export const version = "15.3.1-canary.3";
29
+ export const version = "15.3.1-canary.5";
30
30
  export let router;
31
31
  export const emitter = mitt();
32
32
  const looseToArray = (input)=>[].slice.call(input);
@@ -340,7 +340,7 @@ export const configSchema = z.lazy(()=>z.strictObject({
340
340
  prerenderEarlyExit: z.boolean().optional(),
341
341
  proxyTimeout: z.number().gte(0).optional(),
342
342
  routerBFCache: z.boolean().optional(),
343
- removeUnhandledRejectionListeners: z.boolean().optional(),
343
+ removeUncaughtErrorAndRejectionListeners: z.boolean().optional(),
344
344
  scrollRestoration: z.boolean().optional(),
345
345
  sri: z.object({
346
346
  algorithm: z.enum([