vinext 1.0.0-beta.6 → 1.0.0-beta.8

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 (179) hide show
  1. package/README.md +47 -3
  2. package/dist/build/action-owner-manifest.d.ts +42 -0
  3. package/dist/build/action-owner-manifest.js +110 -0
  4. package/dist/build/clean-output.js +1 -4
  5. package/dist/build/client-build-config.js +10 -11
  6. package/dist/build/prerender.d.ts +1 -1
  7. package/dist/build/prerender.js +12 -6
  8. package/dist/build/report.d.ts +1 -1
  9. package/dist/build/route-classification-manifest.d.ts +1 -1
  10. package/dist/build/static-export.d.ts +1 -1
  11. package/dist/client/app-nav-failure-handler.js +1 -0
  12. package/dist/client/navigation-runtime.d.ts +5 -3
  13. package/dist/client/navigation-runtime.js +4 -8
  14. package/dist/entries/app-browser-entry.d.ts +1 -1
  15. package/dist/entries/app-rsc-entry.d.ts +2 -1
  16. package/dist/entries/app-rsc-entry.js +111 -8
  17. package/dist/entries/pages-client-entry.d.ts +1 -1
  18. package/dist/entries/pages-server-entry.d.ts +1 -1
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.js +119 -26
  21. package/dist/plugins/action-owner-manifest.d.ts +14 -0
  22. package/dist/plugins/action-owner-manifest.js +84 -0
  23. package/dist/plugins/ast-utils.d.ts +30 -1
  24. package/dist/plugins/ast-utils.js +76 -1
  25. package/dist/plugins/css-module-imports.d.ts +2 -2
  26. package/dist/plugins/css-module-imports.js +5 -13
  27. package/dist/plugins/dynamic-preload-metadata.js +13 -34
  28. package/dist/plugins/environment.d.ts +11 -0
  29. package/dist/plugins/environment.js +7 -0
  30. package/dist/plugins/extensionless-dynamic-import.js +11 -35
  31. package/dist/plugins/fonts.js +8 -12
  32. package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
  33. package/dist/plugins/ignore-dynamic-requests.js +29 -59
  34. package/dist/plugins/import-meta-url.d.ts +15 -9
  35. package/dist/plugins/import-meta-url.js +310 -85
  36. package/dist/plugins/instrumentation-client.js +4 -5
  37. package/dist/plugins/middleware-export-validation.js +5 -17
  38. package/dist/plugins/middleware-server-only.js +2 -2
  39. package/dist/plugins/og-asset-ownership.js +18 -26
  40. package/dist/plugins/og-assets.js +2 -4
  41. package/dist/plugins/optimize-imports.js +2 -4
  42. package/dist/plugins/pages-node-externals.js +13 -40
  43. package/dist/plugins/remove-console.js +2 -4
  44. package/dist/plugins/require-condition-resolution.d.ts +16 -0
  45. package/dist/plugins/require-condition-resolution.js +167 -0
  46. package/dist/plugins/require-context.js +11 -46
  47. package/dist/plugins/sass.js +1 -1
  48. package/dist/plugins/server-externals-manifest.js +1 -23
  49. package/dist/plugins/strip-server-exports.js +13 -19
  50. package/dist/plugins/styled-jsx.js +17 -19
  51. package/dist/plugins/transform-result.d.ts +10 -0
  52. package/dist/plugins/transform-result.js +10 -0
  53. package/dist/plugins/transitive-externals.js +7 -21
  54. package/dist/plugins/typeof-window.d.ts +3 -8
  55. package/dist/plugins/typeof-window.js +5 -15
  56. package/dist/plugins/use-cache-callable.js +12 -22
  57. package/dist/plugins/wasm-module-import.js +1 -1
  58. package/dist/plugins/worker-image-imports.d.ts +12 -0
  59. package/dist/plugins/worker-image-imports.js +136 -0
  60. package/dist/routing/app-route-graph.d.ts +3 -2
  61. package/dist/routing/app-route-graph.js +1 -1
  62. package/dist/routing/route-pattern.d.ts +8 -1
  63. package/dist/routing/route-pattern.js +28 -1
  64. package/dist/routing/route-validation.js +7 -1
  65. package/dist/server/accept-encoding.d.ts +1 -2
  66. package/dist/server/accept-encoding.js +1 -4
  67. package/dist/server/app-action-forwarding.d.ts +18 -0
  68. package/dist/server/app-action-forwarding.js +140 -0
  69. package/dist/server/app-browser-entry.js +231 -50
  70. package/dist/server/app-browser-error.d.ts +1 -2
  71. package/dist/server/app-browser-error.js +1 -5
  72. package/dist/server/app-browser-history-controller.d.ts +16 -1
  73. package/dist/server/app-browser-history-controller.js +135 -18
  74. package/dist/server/app-browser-navigation-abort.d.ts +16 -0
  75. package/dist/server/app-browser-navigation-abort.js +29 -0
  76. package/dist/server/app-browser-navigation-controller.d.ts +4 -0
  77. package/dist/server/app-browser-navigation-controller.js +22 -6
  78. package/dist/server/app-browser-navigation-response.d.ts +11 -0
  79. package/dist/server/app-browser-navigation-response.js +8 -0
  80. package/dist/server/app-browser-popstate.d.ts +6 -1
  81. package/dist/server/app-browser-popstate.js +6 -2
  82. package/dist/server/app-browser-server-action-client.js +1 -1
  83. package/dist/server/app-browser-state.d.ts +2 -2
  84. package/dist/server/app-browser-state.js +3 -3
  85. package/dist/server/app-browser-stream.d.ts +0 -2
  86. package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
  87. package/dist/server/app-browser-supplemental-refresh.js +190 -0
  88. package/dist/server/app-browser-visible-commit.js +23 -12
  89. package/dist/server/app-elements-wire.d.ts +2 -0
  90. package/dist/server/app-elements-wire.js +7 -0
  91. package/dist/server/app-history-state.d.ts +22 -1
  92. package/dist/server/app-history-state.js +93 -9
  93. package/dist/server/app-optimistic-routing.d.ts +22 -1
  94. package/dist/server/app-optimistic-routing.js +137 -12
  95. package/dist/server/app-page-cache-finalizer.d.ts +3 -1
  96. package/dist/server/app-page-cache-finalizer.js +6 -6
  97. package/dist/server/app-page-cache.d.ts +2 -1
  98. package/dist/server/app-page-cache.js +2 -2
  99. package/dist/server/app-page-dispatch.d.ts +4 -1
  100. package/dist/server/app-page-dispatch.js +10 -1
  101. package/dist/server/app-page-element-builder.d.ts +1 -0
  102. package/dist/server/app-page-element-builder.js +1 -0
  103. package/dist/server/app-page-ppr-runtime.js +3 -2
  104. package/dist/server/app-page-render.d.ts +2 -1
  105. package/dist/server/app-page-render.js +6 -3
  106. package/dist/server/app-page-request.d.ts +2 -33
  107. package/dist/server/app-page-request.js +1 -27
  108. package/dist/server/app-page-route-wiring.d.ts +1 -0
  109. package/dist/server/app-page-route-wiring.js +4 -0
  110. package/dist/server/app-page-segment-state.d.ts +2 -2
  111. package/dist/server/app-page-segment-state.js +14 -8
  112. package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
  113. package/dist/server/app-ppr-fallback-shell.js +3 -6
  114. package/dist/server/app-route-handler-dispatch.js +4 -1
  115. package/dist/server/app-route-handler-execution.js +1 -1
  116. package/dist/server/app-rsc-cache-busting.d.ts +2 -1
  117. package/dist/server/app-rsc-cache-busting.js +34 -8
  118. package/dist/server/app-rsc-handler.d.ts +4 -2
  119. package/dist/server/app-rsc-handler.js +57 -9
  120. package/dist/server/app-rsc-request-normalization.d.ts +2 -0
  121. package/dist/server/app-rsc-request-normalization.js +5 -1
  122. package/dist/server/app-rsc-route-matching.d.ts +4 -3
  123. package/dist/server/app-rsc-route-matching.js +14 -42
  124. package/dist/server/app-server-action-execution.d.ts +3 -0
  125. package/dist/server/app-server-action-execution.js +77 -2
  126. package/dist/server/app-ssr-entry.js +6 -6
  127. package/dist/server/app-ssr-stream.d.ts +1 -1
  128. package/dist/server/app-ssr-stream.js +2 -2
  129. package/dist/server/app-visited-response-cache.d.ts +6 -1
  130. package/dist/server/app-visited-response-cache.js +18 -2
  131. package/dist/server/dev-route-files.js +2 -5
  132. package/dist/server/dev-server.d.ts +5 -13
  133. package/dist/server/dev-server.js +22 -22
  134. package/dist/server/dev-stack-sourcemap.d.ts +1 -2
  135. package/dist/server/dev-stack-sourcemap.js +1 -4
  136. package/dist/server/headers.d.ts +5 -1
  137. package/dist/server/headers.js +5 -1
  138. package/dist/server/isr-cache.d.ts +6 -14
  139. package/dist/server/isr-cache.js +6 -27
  140. package/dist/server/middleware.d.ts +3 -16
  141. package/dist/server/middleware.js +2 -19
  142. package/dist/server/navigation-planner.d.ts +1 -0
  143. package/dist/server/navigation-planner.js +57 -9
  144. package/dist/server/navigation-trace.d.ts +1 -0
  145. package/dist/server/navigation-trace.js +1 -0
  146. package/dist/server/pages-data-route.d.ts +1 -10
  147. package/dist/server/pages-data-route.js +1 -12
  148. package/dist/server/pages-node-compat.d.ts +1 -4
  149. package/dist/server/pages-node-compat.js +1 -7
  150. package/dist/server/pages-readiness.js +4 -4
  151. package/dist/server/prerender-route-params.d.ts +1 -2
  152. package/dist/server/prerender-route-params.js +1 -4
  153. package/dist/server/prod-server.js +3 -1
  154. package/dist/shims/cache-runtime.js +39 -22
  155. package/dist/shims/cache.d.ts +1 -1
  156. package/dist/shims/dynamic.d.ts +3 -3
  157. package/dist/shims/dynamic.js +4 -6
  158. package/dist/shims/error.js +1 -1
  159. package/dist/shims/fetch-cache.d.ts +3 -1
  160. package/dist/shims/fetch-cache.js +23 -4
  161. package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
  162. package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
  163. package/dist/shims/link.js +1 -1
  164. package/dist/shims/navigation.d.ts +12 -3
  165. package/dist/shims/navigation.js +46 -11
  166. package/dist/shims/navigation.react-server.js +1 -1
  167. package/dist/shims/request-state-types.d.ts +1 -1
  168. package/dist/shims/router.js +75 -4
  169. package/dist/shims/unified-request-context.d.ts +1 -1
  170. package/dist/shims/unified-request-context.js +1 -0
  171. package/dist/utils/built-asset-url.d.ts +1 -1
  172. package/dist/utils/built-asset-url.js +4 -2
  173. package/dist/utils/package-name.d.ts +11 -0
  174. package/dist/utils/package-name.js +18 -0
  175. package/dist/utils/path.d.ts +8 -1
  176. package/dist/utils/path.js +21 -1
  177. package/dist/utils/react-compiler-support.d.ts +20 -0
  178. package/dist/utils/react-compiler-support.js +29 -0
  179. package/package.json +3 -2
@@ -0,0 +1,190 @@
1
+ import { normalizePathnameForRouteMatch } from "../routing/utils.js";
2
+ import { addBasePathToPathname, removeTrailingSlash, stripBasePath } from "../utils/base-path.js";
3
+ import { normalizePath } from "./normalize-path.js";
4
+ import { APP_INTERCEPTION_CONTEXT_KEY, APP_INTERCEPTION_KEY, APP_SLOT_BINDINGS_KEY, AppElementsWire, normalizeAppElementsSlotBindings } from "./app-elements-wire.js";
5
+ import "./app-elements.js";
6
+ //#region src/server/app-browser-supplemental-refresh.ts
7
+ const SUPPLEMENTAL_REFRESH_TIMEOUT_MS = 1e4;
8
+ var SupplementalRefreshError = class extends Error {
9
+ reason;
10
+ constructor(reason) {
11
+ super(`[vinext] Supplemental parallel-route refresh ${reason}`);
12
+ this.name = "SupplementalRefreshError";
13
+ this.reason = reason;
14
+ }
15
+ };
16
+ function requireCompleteSupplementalRefresh(result) {
17
+ if (result.degraded) throw new SupplementalRefreshError(result.reason);
18
+ return result.value;
19
+ }
20
+ function resolveServerActionSupplementalRefresh(result, currentValue) {
21
+ return result.degraded ? {
22
+ retry: result.reason !== "aborted",
23
+ value: currentValue
24
+ } : {
25
+ retry: false,
26
+ value: result.value
27
+ };
28
+ }
29
+ function mergeRefreshedParallelSlot(currentElements, refreshedElements) {
30
+ const refreshedMetadata = AppElementsWire.readMetadata(refreshedElements);
31
+ const interception = refreshedMetadata.interception;
32
+ if (interception === null) {
33
+ const refreshedBindings = refreshedMetadata.slotBindings.filter((binding) => binding.state === "active" && Object.hasOwn(refreshedElements, binding.slotId));
34
+ if (refreshedBindings.length === 0) return currentElements;
35
+ const currentMetadata = AppElementsWire.readMetadata(currentElements);
36
+ if (refreshedBindings.some((binding) => {
37
+ const parsedSlot = AppElementsWire.parseElementKey(binding.slotId);
38
+ return parsedSlot?.kind === "slot" && parsedSlot.name === "children";
39
+ })) {
40
+ const refreshedSlotIds = new Set(refreshedBindings.map((binding) => binding.slotId));
41
+ const refreshedChildrenBindings = refreshedBindings.filter((binding) => {
42
+ const parsedSlot = AppElementsWire.parseElementKey(binding.slotId);
43
+ return parsedSlot?.kind === "slot" && parsedSlot.name === "children";
44
+ });
45
+ const retainedBindings = currentMetadata.slotBindings.filter((binding) => {
46
+ const parsedSlot = AppElementsWire.parseElementKey(binding.slotId);
47
+ return binding.state === "active" && parsedSlot?.kind === "slot" && !refreshedSlotIds.has(binding.slotId) && Object.hasOwn(currentElements, binding.slotId);
48
+ });
49
+ const promotableChildrenBindings = currentMetadata.slotBindings.filter((binding) => {
50
+ const parsedSlot = AppElementsWire.parseElementKey(binding.slotId);
51
+ return binding.state === "unmatched" && parsedSlot?.kind === "slot" && parsedSlot.name === "children" && !refreshedSlotIds.has(binding.slotId);
52
+ });
53
+ const promotedBindings = refreshedChildrenBindings.length === 1 && promotableChildrenBindings.length === 1 ? [{
54
+ ...promotableChildrenBindings[0],
55
+ activeRouteId: refreshedChildrenBindings[0].activeRouteId,
56
+ state: "active"
57
+ }] : [];
58
+ const retainedSlotIds = new Set([...retainedBindings, ...promotedBindings].map((binding) => binding.slotId));
59
+ const slotBindings = refreshedMetadata.slotBindings.filter((binding) => !retainedSlotIds.has(binding.slotId));
60
+ slotBindings.push(...retainedBindings, ...promotedBindings);
61
+ const merged = {
62
+ ...refreshedElements,
63
+ ...currentMetadata.interception === null ? {} : {
64
+ [APP_INTERCEPTION_KEY]: currentMetadata.interception,
65
+ [APP_INTERCEPTION_CONTEXT_KEY]: currentMetadata.interceptionContext
66
+ },
67
+ [APP_SLOT_BINDINGS_KEY]: normalizeAppElementsSlotBindings(slotBindings, { layoutIds: refreshedMetadata.layoutIds })
68
+ };
69
+ for (const binding of retainedBindings) merged[binding.slotId] = currentElements[binding.slotId];
70
+ if (promotedBindings.length === 1) merged[promotedBindings[0].slotId] = refreshedElements[refreshedChildrenBindings[0].slotId];
71
+ copyRefreshedBranchElements(merged, currentElements, { overwrite: false });
72
+ return merged;
73
+ }
74
+ const refreshedSlotIds = new Set(refreshedBindings.map((binding) => binding.slotId));
75
+ const slotBindings = currentMetadata.slotBindings.filter((binding) => !refreshedSlotIds.has(binding.slotId));
76
+ slotBindings.push(...refreshedBindings);
77
+ const merged = {
78
+ ...currentElements,
79
+ [APP_SLOT_BINDINGS_KEY]: normalizeAppElementsSlotBindings(slotBindings, { layoutIds: currentMetadata.layoutIds })
80
+ };
81
+ for (const binding of refreshedBindings) merged[binding.slotId] = refreshedElements[binding.slotId];
82
+ copyRefreshedBranchElements(merged, refreshedElements);
83
+ return merged;
84
+ }
85
+ const refreshedSlot = refreshedElements[interception.slotId];
86
+ if (refreshedSlot === void 0) return currentElements;
87
+ const currentMetadata = AppElementsWire.readMetadata(currentElements);
88
+ const refreshedBinding = refreshedMetadata.slotBindings.find((binding) => binding.slotId === interception.slotId);
89
+ const slotBindings = currentMetadata.slotBindings.filter((binding) => binding.slotId !== interception.slotId);
90
+ if (refreshedBinding) slotBindings.push(refreshedBinding);
91
+ const merged = {
92
+ ...currentElements,
93
+ [interception.slotId]: refreshedSlot,
94
+ [APP_SLOT_BINDINGS_KEY]: normalizeAppElementsSlotBindings(slotBindings, { layoutIds: currentMetadata.layoutIds })
95
+ };
96
+ copyRefreshedBranchElements(merged, refreshedElements);
97
+ return merged;
98
+ }
99
+ function copyRefreshedBranchElements(target, refreshedElements, options = {}) {
100
+ for (const [elementId, element] of Object.entries(refreshedElements)) {
101
+ const parsed = AppElementsWire.parseElementKey(elementId);
102
+ if ((parsed?.kind === "page" || parsed?.kind === "route") && (options.overwrite !== false || !Object.hasOwn(target, elementId))) target[elementId] = element;
103
+ }
104
+ }
105
+ function resolvePersistedSourcePageRefreshes(options) {
106
+ const sourceUrlsByPathname = /* @__PURE__ */ new Map();
107
+ const refreshRoutePathname = removeTrailingSlash(normalizePath(normalizePathnameForRouteMatch(stripBasePath(options.refreshUrl.pathname, options.basePath))));
108
+ if (options.state.previousNextUrl !== null) {
109
+ const sourceUrl = new URL(options.state.previousNextUrl, options.refreshUrl);
110
+ sourceUrlsByPathname.set(sourceUrl.pathname, sourceUrl);
111
+ }
112
+ const activeRoutePaths = options.activeRoutePaths ?? options.state.slotBindings.flatMap((binding) => {
113
+ if (binding.state !== "active" || binding.activeRouteId == null) return [];
114
+ const activeRoute = AppElementsWire.parseElementKey(binding.activeRouteId);
115
+ return activeRoute?.kind === "route" && activeRoute.interceptionContext === null ? [activeRoute.path] : [];
116
+ });
117
+ for (const activeRoutePath of activeRoutePaths) {
118
+ if (activeRoutePath !== refreshRoutePathname && (refreshRoutePathname === "/" || activeRoutePath.startsWith(refreshRoutePathname + "/"))) continue;
119
+ const pathname = addBasePathToPathname(activeRoutePath, options.basePath);
120
+ if (sourceUrlsByPathname.has(pathname)) continue;
121
+ const sourceUrl = new URL(pathname, options.refreshUrl);
122
+ sourceUrl.search = options.refreshUrl.search;
123
+ sourceUrlsByPathname.set(pathname, sourceUrl);
124
+ }
125
+ const refreshPathAndSearch = `${options.refreshUrl.pathname}${options.refreshUrl.search}`;
126
+ const resolved = [];
127
+ for (const sourceUrl of sourceUrlsByPathname.values()) {
128
+ const pathAndSearch = `${sourceUrl.pathname}${sourceUrl.search}`;
129
+ if (pathAndSearch !== refreshPathAndSearch) resolved.push(pathAndSearch);
130
+ }
131
+ return resolved;
132
+ }
133
+ function createSupplementalRefreshCoordinator() {
134
+ const controllers = /* @__PURE__ */ new Set();
135
+ return {
136
+ abortAll() {
137
+ for (const controller of controllers) controller.abort();
138
+ },
139
+ begin(options) {
140
+ const controller = new AbortController();
141
+ controllers.add(controller);
142
+ if (options.activeNavigationId !== options.startedNavigationId) controller.abort();
143
+ return {
144
+ finish() {
145
+ controllers.delete(controller);
146
+ },
147
+ signal: controller.signal
148
+ };
149
+ }
150
+ };
151
+ }
152
+ async function resolveSupplementalRefreshes(options) {
153
+ if (options.supplemental.length === 0) return {
154
+ degraded: false,
155
+ value: await options.primary
156
+ };
157
+ const controller = new AbortController();
158
+ const abort = () => controller.abort(options.signal.reason);
159
+ if (options.signal.aborted) abort();
160
+ else options.signal.addEventListener("abort", abort, { once: true });
161
+ const timeout = setTimeout(() => controller.abort(new DOMException("Supplemental refresh timed out", "TimeoutError")), options.timeoutMs ?? SUPPLEMENTAL_REFRESH_TIMEOUT_MS);
162
+ try {
163
+ if (controller.signal.aborted) return {
164
+ degraded: true,
165
+ reason: "aborted",
166
+ value: await options.primary
167
+ };
168
+ const supplemental = options.supplemental.map((load) => load(controller.signal));
169
+ const [primary, supplementalValues] = await Promise.all([options.primary, Promise.all(supplemental)]);
170
+ let value = primary;
171
+ for (const supplementalValue of supplementalValues) value = options.merge(value, supplementalValue);
172
+ return {
173
+ degraded: false,
174
+ value
175
+ };
176
+ } catch {
177
+ const reason = options.signal.aborted ? "aborted" : controller.signal.reason instanceof DOMException && controller.signal.reason.name === "TimeoutError" ? "timeout" : "failed";
178
+ controller.abort();
179
+ return {
180
+ degraded: true,
181
+ reason,
182
+ value: await options.primary
183
+ };
184
+ } finally {
185
+ clearTimeout(timeout);
186
+ options.signal.removeEventListener("abort", abort);
187
+ }
188
+ }
189
+ //#endregion
190
+ export { SupplementalRefreshError, createSupplementalRefreshCoordinator, mergeRefreshedParallelSlot, requireCompleteSupplementalRefresh, resolvePersistedSourcePageRefreshes, resolveServerActionSupplementalRefresh, resolveSupplementalRefreshes };
@@ -1,11 +1,18 @@
1
- import { normalizeAppElementsSlotBindings } from "./app-elements-wire.js";
1
+ import { AppElementsWire, normalizeAppElementsSlotBindings } from "./app-elements-wire.js";
2
2
  import "./app-elements.js";
3
3
  import { mergeElements } from "../shims/slot.js";
4
- import { createBfcacheSegmentIdentityMap, preserveBfcacheIdsForMergedElements } from "./app-bfcache-identity.js";
4
+ import { resolveAppPageRouteStateKey } from "./app-page-segment-state.js";
5
5
  import { NavigationTraceReasonCodes, NavigationTraceTransactionCodes, createNavigationTrace, prependNavigationTraceEntry } from "./navigation-trace.js";
6
+ import { createBfcacheSegmentIdentityMap, preserveBfcacheIdsForMergedElements } from "./app-bfcache-identity.js";
6
7
  import { createPendingNavigationCommit, resolvePendingNavigationCommitDispositionDecision } from "./app-browser-state.js";
7
8
  //#region src/server/app-browser-visible-commit.ts
8
9
  const approvedVisibleCommitBrand = Symbol("ApprovedVisibleCommit");
10
+ function hasSameServerTemplateSeedIdentity(id, currentSnapshot, nextSnapshot) {
11
+ const parsed = AppElementsWire.parseElementKey(id);
12
+ if (parsed?.kind !== "template") return false;
13
+ const templateSegments = parsed.treePath.split("/").filter(Boolean);
14
+ return resolveAppPageRouteStateKey(templateSegments, currentSnapshot.params) === resolveAppPageRouteStateKey(templateSegments, nextSnapshot.params);
15
+ }
9
16
  function applyApprovedVisibleCommit(state, commit) {
10
17
  assertApprovedVisibleCommit(commit);
11
18
  return reduceApprovedVisibleCommitState(state, commit);
@@ -32,14 +39,14 @@ function commitVisibleRouterState(state, nextState, operation) {
32
39
  visibleCommitVersion
33
40
  };
34
41
  }
35
- function mergeSlotBindings(previousBindings, nextBindings, layoutIds, preservePreviousSlotIds) {
36
- if (preservePreviousSlotIds.length === 0) return nextBindings;
42
+ function mergeSlotBindings(previousBindings, nextBindings, nextElements, layoutIds, preserveAbsentSlots, preservePreviousSlotIds) {
37
43
  const preservedSlotIds = new Set(preservePreviousSlotIds);
38
44
  const previousBindingsBySlotId = /* @__PURE__ */ new Map();
39
45
  for (const binding of previousBindings) {
40
- if (!preservedSlotIds.has(binding.slotId)) continue;
46
+ if (!preservedSlotIds.has(binding.slotId) && !(preserveAbsentSlots && binding.state === "active" && !Object.hasOwn(nextElements, binding.slotId))) continue;
41
47
  previousBindingsBySlotId.set(binding.slotId, binding);
42
48
  }
49
+ if (previousBindingsBySlotId.size === 0) return nextBindings;
43
50
  const mergedBindings = [];
44
51
  const seenSlotIds = /* @__PURE__ */ new Set();
45
52
  for (const binding of nextBindings) {
@@ -66,29 +73,33 @@ function reduceApprovedVisibleCommitState(state, commit) {
66
73
  }) : [];
67
74
  const preservedSlotOwnerElementIdSet = new Set(bfcacheCompatiblePreserveElementIds);
68
75
  const preservePreviousSlotIds = action.reuseCurrentBfcacheIds ? commit.decision.preservePreviousSlotIds.filter((slotId) => {
69
- const targetBinding = action.slotBindings.find((binding) => binding.slotId === slotId);
76
+ const targetBinding = action.slotBindings.find((binding) => binding.slotId === slotId) ?? state.slotBindings.find((binding) => binding.slotId === slotId);
70
77
  return targetBinding?.ownerLayoutId !== null && targetBinding?.ownerLayoutId !== void 0 && preservedSlotOwnerElementIdSet.has(targetBinding.ownerLayoutId);
71
78
  }) : [];
79
+ const suppliedActiveSlotIds = action.operation.lane === "refresh" ? new Set(action.slotBindings.filter((binding) => binding.state === "active" && Object.hasOwn(action.elements, binding.slotId)).map((binding) => binding.slotId)) : /* @__PURE__ */ new Set();
80
+ const effectivePreservePreviousSlotIds = preservePreviousSlotIds.filter((slotId) => !suppliedActiveSlotIds.has(slotId));
72
81
  const previousBfcacheIdentities = createBfcacheSegmentIdentityMap({ elements: state.elements });
73
- const preservePreviousBfcacheIdIds = preservePreviousSlotIds.filter((id) => previousBfcacheIdentities[id] !== void 0);
74
- const hmrPreservedSlotOwnerLayoutIds = action.operation.lane === "hmr" ? bfcacheCompatiblePreserveElementIds.filter((id) => preservePreviousSlotIds.some((slotId) => {
82
+ const preservePreviousBfcacheIdIds = effectivePreservePreviousSlotIds.filter((id) => previousBfcacheIdentities[id] !== void 0);
83
+ const hmrPreservedSlotOwnerLayoutIds = action.operation.lane === "hmr" ? bfcacheCompatiblePreserveElementIds.filter((id) => effectivePreservePreviousSlotIds.some((slotId) => {
75
84
  return action.slotBindings.find((binding) => binding.slotId === slotId)?.ownerLayoutId === id;
76
85
  })) : [];
77
86
  const hmrPreserveElementIds = action.operation.lane === "hmr" && state.routeId === action.routeId && Object.hasOwn(state.elements, state.routeId) ? [state.routeId, ...hmrPreservedSlotOwnerLayoutIds] : hmrPreservedSlotOwnerLayoutIds;
78
87
  const hmrUniquePreserveElementIds = hmrPreserveElementIds.length > 1 ? [...new Set(hmrPreserveElementIds)] : hmrPreserveElementIds;
79
88
  const preserveElementIds = action.operation.lane === "hmr" ? hmrUniquePreserveElementIds : bfcacheCompatiblePreserveElementIds;
89
+ const preserveTemplateIds = action.reuseCurrentBfcacheIds && (action.operation.lane === "navigation" || action.operation.lane === "traverse" || action.operation.lane === "server-action") ? Object.keys(state.elements).filter((id) => Object.hasOwn(action.elements, id) && hasSameServerTemplateSeedIdentity(id, state.navigationSnapshot, action.navigationSnapshot)) : [];
90
+ const mergedPreserveElementIds = preserveTemplateIds.length === 0 ? preserveElementIds : [.../* @__PURE__ */ new Set([...preserveElementIds, ...preserveTemplateIds])];
80
91
  const mergedElements = mergeElements(state.elements, action.elements, {
81
92
  clearAbsentSlots: action.type === "traverse" || !action.reuseCurrentBfcacheIds,
82
93
  preserveAbsentSlots: action.reuseCurrentBfcacheIds && commit.decision.preserveAbsentSlots,
83
- preserveElementIds,
84
- preservePreviousSlotIds
94
+ preserveElementIds: mergedPreserveElementIds,
95
+ preservePreviousSlotIds: effectivePreservePreviousSlotIds
85
96
  });
86
97
  return commitVisibleRouterState(state, {
87
98
  bfcacheIds: preserveBfcacheIdsForMergedElements({
88
99
  elements: mergedElements,
89
100
  next: action.bfcacheIds,
90
101
  previous: action.reuseCurrentBfcacheIds ? state.bfcacheIds : {},
91
- preservedElementIds: preservePreviousSlotIds,
102
+ preservedElementIds: effectivePreservePreviousSlotIds,
92
103
  preservePreviousIds: preservePreviousBfcacheIdIds
93
104
  }),
94
105
  elements: mergedElements,
@@ -101,7 +112,7 @@ function reduceApprovedVisibleCommitState(state, commit) {
101
112
  renderId: action.renderId,
102
113
  rootLayoutTreePath: action.rootLayoutTreePath,
103
114
  routeId: action.routeId,
104
- slotBindings: mergeSlotBindings(state.slotBindings, action.slotBindings, action.layoutIds, preservePreviousSlotIds)
115
+ slotBindings: mergeSlotBindings(state.slotBindings, action.slotBindings, action.elements, action.layoutIds, action.reuseCurrentBfcacheIds && commit.decision.preserveAbsentSlots, effectivePreservePreviousSlotIds)
105
116
  }, action.operation);
106
117
  }
107
118
  default: {
@@ -33,6 +33,8 @@ declare const UNMATCHED_SLOT: unique symbol;
33
33
  type AppElementsSlotBindingState = "active" | "default" | "unmatched";
34
34
  type AppElementsSlotBinding = Readonly<{
35
35
  activeRouteId?: string | null;
36
+ interceptionId?: string | null;
37
+ interceptionSourceMatchedUrl?: string | null;
36
38
  ownerLayoutId: string | null;
37
39
  slotId: string;
38
40
  state: AppElementsSlotBindingState;
@@ -261,8 +261,15 @@ function parseSlotBindings(value, options = {}) {
261
261
  if (!isSlotBindingState(state)) throw new Error("[vinext] Invalid __slotBindings in App Router payload: expected state");
262
262
  const activeRouteId = entry.activeRouteId;
263
263
  if (activeRouteId !== void 0 && activeRouteId !== null && (typeof activeRouteId !== "string" || parseAppElementsWireElementKey(activeRouteId)?.kind !== "route")) throw new Error("[vinext] Invalid __slotBindings in App Router payload: expected route ids");
264
+ const interceptionId = entry.interceptionId;
265
+ if (interceptionId !== void 0 && interceptionId !== null && (typeof interceptionId !== "string" || interceptionId.length === 0)) throw new Error("[vinext] Invalid __slotBindings in App Router payload: expected interception ids");
266
+ const interceptionSourceMatchedUrl = entry.interceptionSourceMatchedUrl;
267
+ if (interceptionSourceMatchedUrl !== void 0 && interceptionSourceMatchedUrl !== null && typeof interceptionSourceMatchedUrl !== "string") throw new Error("[vinext] Invalid __slotBindings in App Router payload: expected interception source URLs");
268
+ if (typeof interceptionSourceMatchedUrl === "string") parseInterceptionMatchedUrl(interceptionSourceMatchedUrl);
264
269
  slotBindings.push({
265
270
  ...activeRouteId !== void 0 ? { activeRouteId } : {},
271
+ ...interceptionId !== void 0 ? { interceptionId } : {},
272
+ ...interceptionSourceMatchedUrl !== void 0 ? { interceptionSourceMatchedUrl } : {},
266
273
  ownerLayoutId,
267
274
  slotId,
268
275
  state
@@ -55,12 +55,33 @@ declare class RestorableClientStateController<TState> {
55
55
  }
56
56
  declare function createHistoryStateWithPreviousNextUrl(state: unknown, previousNextUrl: string | null): HistoryStateRecord | null;
57
57
  declare function createHistoryStateWithNavigationMetadata(state: unknown, metadata: {
58
+ activeRoutePaths?: readonly string[] | null;
58
59
  bfcacheIds?: BfcacheIdMap | null;
59
60
  bfcacheVersion?: number | null;
60
61
  previousNextUrl: string | null;
61
62
  traversalIndex?: number | null;
62
63
  }): HistoryStateRecord | null;
63
64
  declare function createExternalHistoryStatePreservingMetadata(callerState: unknown, currentHistoryState: unknown): unknown;
65
+ declare function isExternalHistoryState(state: unknown): boolean;
66
+ /**
67
+ * Mirrors Next.js' `data?.__NA` guard in its patched History API. Passing a
68
+ * previously captured App Router history entry back to pushState/replaceState
69
+ * is an internal traversal write, not a new shallow-routing entry. App-owned
70
+ * entries always carry a traversal index after bootstrap; externally patched
71
+ * entries are distinguished by their explicit external marker.
72
+ */
73
+ declare function isAppOwnedHistoryState(state: unknown): boolean;
74
+ declare function createAppOwnedHistoryState(state: unknown): unknown;
75
+ declare function createHistoryStateWithTreeSnapshotId(state: unknown, treeSnapshotId: number | null): unknown;
76
+ declare function createHistoryStateWithTreeSnapshotClaim(state: unknown, claimed: boolean): unknown;
77
+ declare function isHistoryStateTreeSnapshotClaimed(state: unknown): boolean;
78
+ declare function clearHistoryStateTreeSnapshotId(state: unknown): unknown;
79
+ declare function readHistoryStateTreeSnapshotId(state: unknown): number | null;
80
+ declare function readHistoryStateActiveRoutePaths(state: unknown): readonly string[] | null;
81
+ declare function resolveActiveRoutePaths(slotBindings: readonly {
82
+ activeRouteId?: string | null;
83
+ state: string;
84
+ }[]): string[];
64
85
  declare function readHistoryStatePreviousNextUrl(state: unknown): string | null;
65
86
  declare function isBfcacheSegmentId(id: string): boolean;
66
87
  declare function readHistoryStateBfcacheIds(state: unknown): BfcacheIdMap | null;
@@ -82,4 +103,4 @@ declare function resolveHistoryTraversalIntent(options: {
82
103
  historyState: unknown;
83
104
  }): HistoryTraversalIntent;
84
105
  //#endregion
85
- export { BfcacheIdMap, HistoryStateSnapshotCache, HistoryTraversalIntent, RestorableClientStateController, createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, isBfcacheSegmentId, isHistoryStateBfcacheVersionCurrent, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent };
106
+ export { BfcacheIdMap, HistoryStateSnapshotCache, HistoryTraversalIntent, RestorableClientStateController, clearHistoryStateTreeSnapshotId, createAppOwnedHistoryState, createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createHistoryStateWithTreeSnapshotClaim, createHistoryStateWithTreeSnapshotId, isAppOwnedHistoryState, isBfcacheSegmentId, isExternalHistoryState, isHistoryStateBfcacheVersionCurrent, isHistoryStateTreeSnapshotClaimed, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, readHistoryStateTreeSnapshotId, resolveActiveRoutePaths, resolveHistoryTraversalIntent };
@@ -6,6 +6,10 @@ const VINEXT_PREVIOUS_NEXT_URL_HISTORY_STATE_KEY = "__vinext_previousNextUrl";
6
6
  const VINEXT_HISTORY_INDEX_HISTORY_STATE_KEY = "__vinext_historyIndex";
7
7
  const VINEXT_BFCACHE_IDS_HISTORY_STATE_KEY = "__vinext_bfcacheIds";
8
8
  const VINEXT_BFCACHE_VERSION_HISTORY_STATE_KEY = "__vinext_bfcacheVersion";
9
+ const VINEXT_EXTERNAL_HISTORY_STATE_KEY = "__vinext_externalHistoryState";
10
+ const VINEXT_TREE_SNAPSHOT_ID_HISTORY_STATE_KEY = "__vinext_treeSnapshotId";
11
+ const VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY = "__vinext_treeSnapshotClaimed";
12
+ const VINEXT_ACTIVE_ROUTE_PATHS_HISTORY_STATE_KEY = "__vinext_activeRoutePaths";
9
13
  var HistoryStateSnapshotCache = class {
10
14
  #maxEntries;
11
15
  #snapshots = /* @__PURE__ */ new Map();
@@ -130,6 +134,8 @@ function createHistoryStateWithPreviousNextUrl(state, previousNextUrl) {
130
134
  function createHistoryStateWithNavigationMetadata(state, metadata) {
131
135
  const nextState = cloneHistoryState(state);
132
136
  const bfcacheIdsWereCleared = metadata.bfcacheIds !== void 0 && (metadata.bfcacheIds === null || Object.keys(metadata.bfcacheIds).length === 0);
137
+ if (metadata.activeRoutePaths !== void 0) if (metadata.activeRoutePaths === null || metadata.activeRoutePaths.length === 0) delete nextState[VINEXT_ACTIVE_ROUTE_PATHS_HISTORY_STATE_KEY];
138
+ else nextState[VINEXT_ACTIVE_ROUTE_PATHS_HISTORY_STATE_KEY] = [...new Set(metadata.activeRoutePaths)];
133
139
  if (metadata.previousNextUrl === null) delete nextState[VINEXT_PREVIOUS_NEXT_URL_HISTORY_STATE_KEY];
134
140
  else nextState[VINEXT_PREVIOUS_NEXT_URL_HISTORY_STATE_KEY] = metadata.previousNextUrl;
135
141
  if (metadata.traversalIndex !== void 0) if (isNonNegativeSafeInteger(metadata.traversalIndex)) nextState[VINEXT_HISTORY_INDEX_HISTORY_STATE_KEY] = metadata.traversalIndex;
@@ -148,13 +154,89 @@ function createExternalHistoryStatePreservingMetadata(callerState, currentHistor
148
154
  const traversalIndex = readHistoryStateTraversalIndex(currentHistoryState);
149
155
  const bfcacheIds = readHistoryStateBfcacheIds(currentHistoryState);
150
156
  const bfcacheVersion = readHistoryStateBfcacheVersion(currentHistoryState);
151
- if (previousNextUrl === null && traversalIndex === null && bfcacheIds === null) return callerState;
152
- return createHistoryStateWithNavigationMetadata(callerState, {
153
- bfcacheIds,
154
- bfcacheVersion: bfcacheIds === null ? void 0 : bfcacheVersion,
155
- previousNextUrl,
156
- traversalIndex
157
- });
157
+ const treeSnapshotId = readHistoryStateTreeSnapshotId(currentHistoryState);
158
+ return {
159
+ ...createHistoryStateWithNavigationMetadata(callerState, {
160
+ activeRoutePaths: readHistoryStateActiveRoutePaths(currentHistoryState),
161
+ bfcacheIds,
162
+ bfcacheVersion: bfcacheIds === null ? void 0 : bfcacheVersion,
163
+ previousNextUrl,
164
+ traversalIndex
165
+ }),
166
+ ...createExternalHistoryStateMarker(),
167
+ ...treeSnapshotId === null ? {} : {
168
+ [VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY]: true,
169
+ [VINEXT_TREE_SNAPSHOT_ID_HISTORY_STATE_KEY]: treeSnapshotId
170
+ }
171
+ };
172
+ }
173
+ function createExternalHistoryStateMarker() {
174
+ return { [VINEXT_EXTERNAL_HISTORY_STATE_KEY]: true };
175
+ }
176
+ function isExternalHistoryState(state) {
177
+ return readHistoryStateRecord(state)?.[VINEXT_EXTERNAL_HISTORY_STATE_KEY] === true;
178
+ }
179
+ /**
180
+ * Mirrors Next.js' `data?.__NA` guard in its patched History API. Passing a
181
+ * previously captured App Router history entry back to pushState/replaceState
182
+ * is an internal traversal write, not a new shallow-routing entry. App-owned
183
+ * entries always carry a traversal index after bootstrap; externally patched
184
+ * entries are distinguished by their explicit external marker.
185
+ */
186
+ function isAppOwnedHistoryState(state) {
187
+ return !isExternalHistoryState(state) && readHistoryStateTraversalIndex(state) !== null;
188
+ }
189
+ function createAppOwnedHistoryState(state) {
190
+ const nextState = cloneHistoryState(state);
191
+ delete nextState[VINEXT_EXTERNAL_HISTORY_STATE_KEY];
192
+ return Object.keys(nextState).length > 0 ? nextState : null;
193
+ }
194
+ function createHistoryStateWithTreeSnapshotId(state, treeSnapshotId) {
195
+ const nextState = cloneHistoryState(state);
196
+ const previousTreeSnapshotId = readHistoryStateTreeSnapshotId(nextState);
197
+ if (isNonNegativeSafeInteger(treeSnapshotId)) {
198
+ nextState[VINEXT_TREE_SNAPSHOT_ID_HISTORY_STATE_KEY] = treeSnapshotId;
199
+ if (previousTreeSnapshotId !== treeSnapshotId) delete nextState[VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY];
200
+ } else {
201
+ delete nextState[VINEXT_TREE_SNAPSHOT_ID_HISTORY_STATE_KEY];
202
+ delete nextState[VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY];
203
+ }
204
+ return Object.keys(nextState).length > 0 ? nextState : null;
205
+ }
206
+ function createHistoryStateWithTreeSnapshotClaim(state, claimed) {
207
+ const nextState = cloneHistoryState(state);
208
+ if (claimed && readHistoryStateTreeSnapshotId(nextState) !== null) nextState[VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY] = true;
209
+ else delete nextState[VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY];
210
+ return Object.keys(nextState).length > 0 ? nextState : null;
211
+ }
212
+ function isHistoryStateTreeSnapshotClaimed(state) {
213
+ return readHistoryStateRecord(state)?.[VINEXT_TREE_SNAPSHOT_CLAIMED_HISTORY_STATE_KEY] === true;
214
+ }
215
+ function clearHistoryStateTreeSnapshotId(state) {
216
+ return createHistoryStateWithTreeSnapshotId(state, null);
217
+ }
218
+ function readHistoryStateTreeSnapshotId(state) {
219
+ const value = readHistoryStateRecord(state)?.[VINEXT_TREE_SNAPSHOT_ID_HISTORY_STATE_KEY];
220
+ return isNonNegativeSafeInteger(value) ? value : null;
221
+ }
222
+ function readHistoryStateActiveRoutePaths(state) {
223
+ const value = readHistoryStateRecord(state)?.[VINEXT_ACTIVE_ROUTE_PATHS_HISTORY_STATE_KEY];
224
+ if (!Array.isArray(value)) return null;
225
+ const paths = [];
226
+ for (const entry of value) {
227
+ if (typeof entry !== "string" || !entry.startsWith("/") || entry.startsWith("//") || entry.includes("?") || entry.includes("#") || entry.includes("\\") || entry.includes("\0")) return null;
228
+ paths.push(entry);
229
+ }
230
+ return paths.length > 0 ? [...new Set(paths)] : null;
231
+ }
232
+ function resolveActiveRoutePaths(slotBindings) {
233
+ const paths = /* @__PURE__ */ new Set();
234
+ for (const binding of slotBindings) {
235
+ if (binding.state !== "active" || binding.activeRouteId == null) continue;
236
+ const route = AppElementsWire.parseElementKey(binding.activeRouteId);
237
+ if (route?.kind === "route" && route.interceptionContext === null) paths.add(route.path);
238
+ }
239
+ return [...paths];
158
240
  }
159
241
  function readHistoryStatePreviousNextUrl(state) {
160
242
  const value = readHistoryStateRecord(state)?.[VINEXT_PREVIOUS_NEXT_URL_HISTORY_STATE_KEY];
@@ -195,8 +277,10 @@ function createHashOnlyHistoryStatePreservingNavigationMetadata(state) {
195
277
  const previousNextUrl = readHistoryStatePreviousNextUrl(state);
196
278
  const bfcacheIds = readHistoryStateBfcacheIds(state);
197
279
  const bfcacheVersion = readHistoryStateBfcacheVersion(state);
198
- if (previousNextUrl === null && bfcacheIds === null) return null;
280
+ const activeRoutePaths = readHistoryStateActiveRoutePaths(state);
281
+ if (previousNextUrl === null && bfcacheIds === null && activeRoutePaths === null) return null;
199
282
  return createHistoryStateWithNavigationMetadata(null, {
283
+ activeRoutePaths,
200
284
  bfcacheIds,
201
285
  bfcacheVersion: bfcacheIds === null ? void 0 : bfcacheVersion,
202
286
  previousNextUrl
@@ -220,4 +304,4 @@ function resolveHistoryTraversalIntent(options) {
220
304
  };
221
305
  }
222
306
  //#endregion
223
- export { HistoryStateSnapshotCache, RestorableClientStateController, createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, isBfcacheSegmentId, isHistoryStateBfcacheVersionCurrent, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent };
307
+ export { HistoryStateSnapshotCache, RestorableClientStateController, clearHistoryStateTreeSnapshotId, createAppOwnedHistoryState, createExternalHistoryStatePreservingMetadata, createHashOnlyHistoryStatePreservingNavigationMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createHistoryStateWithTreeSnapshotClaim, createHistoryStateWithTreeSnapshotId, isAppOwnedHistoryState, isBfcacheSegmentId, isExternalHistoryState, isHistoryStateBfcacheVersionCurrent, isHistoryStateTreeSnapshotClaimed, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, readHistoryStateTreeSnapshotId, resolveActiveRoutePaths, resolveHistoryTraversalIntent };
@@ -9,13 +9,17 @@ type OptimisticRouteMatch = {
9
9
  type OptimisticRouteTemplate = {
10
10
  elements: AppElements;
11
11
  mountedSlotsHeader: string | null;
12
+ omittedBfcacheSegmentIds: readonly string[];
13
+ omittedLayoutIds: readonly string[];
12
14
  pageElementIds: readonly string[];
13
15
  routeId: string;
14
16
  };
15
17
  type OptimisticNavigationPayload = {
16
18
  elements: AppElements;
17
19
  params: Record<string, string | string[]>;
20
+ routeParams: Record<string, string | string[]>;
18
21
  template: OptimisticRouteTemplate;
22
+ urlParts: readonly string[];
19
23
  };
20
24
  declare function getOptimisticRouteTemplateKey(options: {
21
25
  interceptionContext: string | null;
@@ -42,6 +46,23 @@ declare function createOptimisticRouteTemplate(options: {
42
46
  routeManifest: RouteManifest;
43
47
  }): OptimisticRouteTemplate | null;
44
48
  declare function createOptimisticRouteElements(template: OptimisticRouteTemplate): AppElements;
49
+ /**
50
+ * A loading-shell prefetch stops at the first loading boundary, so layouts
51
+ * below that boundary are present in the route metadata but absent from the
52
+ * rendered shell. Do not commit that ancestor fallback when one of those
53
+ * omitted layouts is already mounted with the same semantic identity. Next.js
54
+ * keeps the shared segment active in this case, which also means the ancestor
55
+ * loading boundary does not re-trigger.
56
+ */
57
+ declare function canCommitOptimisticRouteTemplate(options: {
58
+ currentElements: AppElements;
59
+ currentLayoutIds: readonly string[];
60
+ currentParams: Readonly<Record<string, string | string[]>>;
61
+ routeManifest: RouteManifest;
62
+ targetRouteParams: Readonly<Record<string, string | string[]>>;
63
+ targetUrlParts: readonly string[];
64
+ template: OptimisticRouteTemplate;
65
+ }): boolean;
45
66
  declare function resolveOptimisticNavigationPayload(options: {
46
67
  basePath: string;
47
68
  href: string;
@@ -51,4 +72,4 @@ declare function resolveOptimisticNavigationPayload(options: {
51
72
  templates: ReadonlyMap<string, OptimisticRouteTemplate>;
52
73
  }): OptimisticNavigationPayload | null;
53
74
  //#endregion
54
- export { OptimisticRouteTemplate, createOptimisticRouteElements, createOptimisticRouteTemplate, getOptimisticPrefetchSourceKey, getOptimisticRouteTemplateKey, matchOptimisticRouteManifestRoute, resolveOptimisticNavigationPayload };
75
+ export { OptimisticRouteTemplate, canCommitOptimisticRouteTemplate, createOptimisticRouteElements, createOptimisticRouteTemplate, getOptimisticPrefetchSourceKey, getOptimisticRouteTemplateKey, matchOptimisticRouteManifestRoute, resolveOptimisticNavigationPayload };