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.
- package/README.md +47 -3
- package/dist/build/action-owner-manifest.d.ts +42 -0
- package/dist/build/action-owner-manifest.js +110 -0
- package/dist/build/clean-output.js +1 -4
- package/dist/build/client-build-config.js +10 -11
- package/dist/build/prerender.d.ts +1 -1
- package/dist/build/prerender.js +12 -6
- package/dist/build/report.d.ts +1 -1
- package/dist/build/route-classification-manifest.d.ts +1 -1
- package/dist/build/static-export.d.ts +1 -1
- package/dist/client/app-nav-failure-handler.js +1 -0
- package/dist/client/navigation-runtime.d.ts +5 -3
- package/dist/client/navigation-runtime.js +4 -8
- package/dist/entries/app-browser-entry.d.ts +1 -1
- package/dist/entries/app-rsc-entry.d.ts +2 -1
- package/dist/entries/app-rsc-entry.js +111 -8
- package/dist/entries/pages-client-entry.d.ts +1 -1
- package/dist/entries/pages-server-entry.d.ts +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +119 -26
- package/dist/plugins/action-owner-manifest.d.ts +14 -0
- package/dist/plugins/action-owner-manifest.js +84 -0
- package/dist/plugins/ast-utils.d.ts +30 -1
- package/dist/plugins/ast-utils.js +76 -1
- package/dist/plugins/css-module-imports.d.ts +2 -2
- package/dist/plugins/css-module-imports.js +5 -13
- package/dist/plugins/dynamic-preload-metadata.js +13 -34
- package/dist/plugins/environment.d.ts +11 -0
- package/dist/plugins/environment.js +7 -0
- package/dist/plugins/extensionless-dynamic-import.js +11 -35
- package/dist/plugins/fonts.js +8 -12
- package/dist/plugins/ignore-dynamic-requests.d.ts +2 -4
- package/dist/plugins/ignore-dynamic-requests.js +29 -59
- package/dist/plugins/import-meta-url.d.ts +15 -9
- package/dist/plugins/import-meta-url.js +310 -85
- package/dist/plugins/instrumentation-client.js +4 -5
- package/dist/plugins/middleware-export-validation.js +5 -17
- package/dist/plugins/middleware-server-only.js +2 -2
- package/dist/plugins/og-asset-ownership.js +18 -26
- package/dist/plugins/og-assets.js +2 -4
- package/dist/plugins/optimize-imports.js +2 -4
- package/dist/plugins/pages-node-externals.js +13 -40
- package/dist/plugins/remove-console.js +2 -4
- package/dist/plugins/require-condition-resolution.d.ts +16 -0
- package/dist/plugins/require-condition-resolution.js +167 -0
- package/dist/plugins/require-context.js +11 -46
- package/dist/plugins/sass.js +1 -1
- package/dist/plugins/server-externals-manifest.js +1 -23
- package/dist/plugins/strip-server-exports.js +13 -19
- package/dist/plugins/styled-jsx.js +17 -19
- package/dist/plugins/transform-result.d.ts +10 -0
- package/dist/plugins/transform-result.js +10 -0
- package/dist/plugins/transitive-externals.js +7 -21
- package/dist/plugins/typeof-window.d.ts +3 -8
- package/dist/plugins/typeof-window.js +5 -15
- package/dist/plugins/use-cache-callable.js +12 -22
- package/dist/plugins/wasm-module-import.js +1 -1
- package/dist/plugins/worker-image-imports.d.ts +12 -0
- package/dist/plugins/worker-image-imports.js +136 -0
- package/dist/routing/app-route-graph.d.ts +3 -2
- package/dist/routing/app-route-graph.js +1 -1
- package/dist/routing/route-pattern.d.ts +8 -1
- package/dist/routing/route-pattern.js +28 -1
- package/dist/routing/route-validation.js +7 -1
- package/dist/server/accept-encoding.d.ts +1 -2
- package/dist/server/accept-encoding.js +1 -4
- package/dist/server/app-action-forwarding.d.ts +18 -0
- package/dist/server/app-action-forwarding.js +140 -0
- package/dist/server/app-browser-entry.js +231 -50
- package/dist/server/app-browser-error.d.ts +1 -2
- package/dist/server/app-browser-error.js +1 -5
- package/dist/server/app-browser-history-controller.d.ts +16 -1
- package/dist/server/app-browser-history-controller.js +135 -18
- package/dist/server/app-browser-navigation-abort.d.ts +16 -0
- package/dist/server/app-browser-navigation-abort.js +29 -0
- package/dist/server/app-browser-navigation-controller.d.ts +4 -0
- package/dist/server/app-browser-navigation-controller.js +22 -6
- package/dist/server/app-browser-navigation-response.d.ts +11 -0
- package/dist/server/app-browser-navigation-response.js +8 -0
- package/dist/server/app-browser-popstate.d.ts +6 -1
- package/dist/server/app-browser-popstate.js +6 -2
- package/dist/server/app-browser-server-action-client.js +1 -1
- package/dist/server/app-browser-state.d.ts +2 -2
- package/dist/server/app-browser-state.js +3 -3
- package/dist/server/app-browser-stream.d.ts +0 -2
- package/dist/server/app-browser-supplemental-refresh.d.ts +49 -0
- package/dist/server/app-browser-supplemental-refresh.js +190 -0
- package/dist/server/app-browser-visible-commit.js +23 -12
- package/dist/server/app-elements-wire.d.ts +2 -0
- package/dist/server/app-elements-wire.js +7 -0
- package/dist/server/app-history-state.d.ts +22 -1
- package/dist/server/app-history-state.js +93 -9
- package/dist/server/app-optimistic-routing.d.ts +22 -1
- package/dist/server/app-optimistic-routing.js +137 -12
- package/dist/server/app-page-cache-finalizer.d.ts +3 -1
- package/dist/server/app-page-cache-finalizer.js +6 -6
- package/dist/server/app-page-cache.d.ts +2 -1
- package/dist/server/app-page-cache.js +2 -2
- package/dist/server/app-page-dispatch.d.ts +4 -1
- package/dist/server/app-page-dispatch.js +10 -1
- package/dist/server/app-page-element-builder.d.ts +1 -0
- package/dist/server/app-page-element-builder.js +1 -0
- package/dist/server/app-page-ppr-runtime.js +3 -2
- package/dist/server/app-page-render.d.ts +2 -1
- package/dist/server/app-page-render.js +6 -3
- package/dist/server/app-page-request.d.ts +2 -33
- package/dist/server/app-page-request.js +1 -27
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +4 -0
- package/dist/server/app-page-segment-state.d.ts +2 -2
- package/dist/server/app-page-segment-state.js +14 -8
- package/dist/server/app-ppr-fallback-shell.d.ts +2 -2
- package/dist/server/app-ppr-fallback-shell.js +3 -6
- package/dist/server/app-route-handler-dispatch.js +4 -1
- package/dist/server/app-route-handler-execution.js +1 -1
- package/dist/server/app-rsc-cache-busting.d.ts +2 -1
- package/dist/server/app-rsc-cache-busting.js +34 -8
- package/dist/server/app-rsc-handler.d.ts +4 -2
- package/dist/server/app-rsc-handler.js +57 -9
- package/dist/server/app-rsc-request-normalization.d.ts +2 -0
- package/dist/server/app-rsc-request-normalization.js +5 -1
- package/dist/server/app-rsc-route-matching.d.ts +4 -3
- package/dist/server/app-rsc-route-matching.js +14 -42
- package/dist/server/app-server-action-execution.d.ts +3 -0
- package/dist/server/app-server-action-execution.js +77 -2
- package/dist/server/app-ssr-entry.js +6 -6
- package/dist/server/app-ssr-stream.d.ts +1 -1
- package/dist/server/app-ssr-stream.js +2 -2
- package/dist/server/app-visited-response-cache.d.ts +6 -1
- package/dist/server/app-visited-response-cache.js +18 -2
- package/dist/server/dev-route-files.js +2 -5
- package/dist/server/dev-server.d.ts +5 -13
- package/dist/server/dev-server.js +22 -22
- package/dist/server/dev-stack-sourcemap.d.ts +1 -2
- package/dist/server/dev-stack-sourcemap.js +1 -4
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/isr-cache.d.ts +6 -14
- package/dist/server/isr-cache.js +6 -27
- package/dist/server/middleware.d.ts +3 -16
- package/dist/server/middleware.js +2 -19
- package/dist/server/navigation-planner.d.ts +1 -0
- package/dist/server/navigation-planner.js +57 -9
- package/dist/server/navigation-trace.d.ts +1 -0
- package/dist/server/navigation-trace.js +1 -0
- package/dist/server/pages-data-route.d.ts +1 -10
- package/dist/server/pages-data-route.js +1 -12
- package/dist/server/pages-node-compat.d.ts +1 -4
- package/dist/server/pages-node-compat.js +1 -7
- package/dist/server/pages-readiness.js +4 -4
- package/dist/server/prerender-route-params.d.ts +1 -2
- package/dist/server/prerender-route-params.js +1 -4
- package/dist/server/prod-server.js +3 -1
- package/dist/shims/cache-runtime.js +39 -22
- package/dist/shims/cache.d.ts +1 -1
- package/dist/shims/dynamic.d.ts +3 -3
- package/dist/shims/dynamic.js +4 -6
- package/dist/shims/error.js +1 -1
- package/dist/shims/fetch-cache.d.ts +3 -1
- package/dist/shims/fetch-cache.js +23 -4
- package/dist/shims/internal/app-route-prefetch-policy.d.ts +6 -7
- package/dist/shims/internal/app-route-prefetch-policy.js +5 -4
- package/dist/shims/link.js +1 -1
- package/dist/shims/navigation.d.ts +12 -3
- package/dist/shims/navigation.js +46 -11
- package/dist/shims/navigation.react-server.js +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router.js +75 -4
- package/dist/shims/unified-request-context.d.ts +1 -1
- package/dist/shims/unified-request-context.js +1 -0
- package/dist/utils/built-asset-url.d.ts +1 -1
- package/dist/utils/built-asset-url.js +4 -2
- package/dist/utils/package-name.d.ts +11 -0
- package/dist/utils/package-name.js +18 -0
- package/dist/utils/path.d.ts +8 -1
- package/dist/utils/path.js +21 -1
- package/dist/utils/react-compiler-support.d.ts +20 -0
- package/dist/utils/react-compiler-support.js +29 -0
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RestorableClientStateController, createHistoryStateWithNavigationMetadata, readHistoryStateBfcacheIds, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
1
|
+
import { RestorableClientStateController, clearHistoryStateTreeSnapshotId, createAppOwnedHistoryState, createExternalHistoryStatePreservingMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithTreeSnapshotClaim, createHistoryStateWithTreeSnapshotId, isExternalHistoryState, isHistoryStateTreeSnapshotClaimed, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, readHistoryStateTreeSnapshotId, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
2
2
|
//#region src/server/app-browser-history-controller.ts
|
|
3
3
|
function createCanonicalBrowserHistoryHref(href) {
|
|
4
4
|
const url = new URL(href);
|
|
@@ -28,6 +28,9 @@ function stripVinextScrollState(state) {
|
|
|
28
28
|
*/
|
|
29
29
|
var AppBrowserHistoryController = class {
|
|
30
30
|
#restorableClientState;
|
|
31
|
+
#treeSnapshots = /* @__PURE__ */ new Map();
|
|
32
|
+
#treeSnapshotClaimCounts = /* @__PURE__ */ new Map();
|
|
33
|
+
#treeSnapshotClaimByHistoryIndex = /* @__PURE__ */ new Map();
|
|
31
34
|
#readHistoryState;
|
|
32
35
|
#readCurrentHref;
|
|
33
36
|
#pushHistoryState;
|
|
@@ -35,6 +38,9 @@ var AppBrowserHistoryController = class {
|
|
|
35
38
|
#readVisibleNavigationMetadata;
|
|
36
39
|
#currentHistoryTraversalIndex;
|
|
37
40
|
#nextHistoryTraversalIndex;
|
|
41
|
+
#currentTreeSnapshotId = null;
|
|
42
|
+
#nextTreeSnapshotId = 0;
|
|
43
|
+
#treeSnapshotIdPendingFreshState = null;
|
|
38
44
|
constructor(deps) {
|
|
39
45
|
this.#readHistoryState = deps.readHistoryState;
|
|
40
46
|
this.#readCurrentHref = deps.readCurrentHref;
|
|
@@ -86,32 +92,117 @@ var AppBrowserHistoryController = class {
|
|
|
86
92
|
}
|
|
87
93
|
invalidateRestorableClientState() {
|
|
88
94
|
this.#restorableClientState.invalidateClientState();
|
|
95
|
+
const historyTreeSnapshotId = readHistoryStateTreeSnapshotId(this.#readHistoryState());
|
|
96
|
+
this.#treeSnapshotIdPendingFreshState = historyTreeSnapshotId !== null && this.#treeSnapshots.has(historyTreeSnapshotId) ? historyTreeSnapshotId : null;
|
|
89
97
|
}
|
|
90
98
|
rememberHistoryStateSnapshot(state) {
|
|
91
99
|
this.#restorableClientState.rememberHistoryStateSnapshot({
|
|
92
100
|
historyIndex: this.#currentHistoryTraversalIndex,
|
|
93
101
|
state
|
|
94
102
|
});
|
|
103
|
+
const historyTreeSnapshotId = readHistoryStateTreeSnapshotId(this.#readHistoryState());
|
|
104
|
+
const treeSnapshotId = historyTreeSnapshotId !== null && this.#treeSnapshots.has(historyTreeSnapshotId) && (historyTreeSnapshotId === this.#treeSnapshotIdPendingFreshState || this.#treeSnapshotClaimCounts.has(historyTreeSnapshotId)) ? historyTreeSnapshotId : this.#nextTreeSnapshotId++;
|
|
105
|
+
this.#treeSnapshotIdPendingFreshState = null;
|
|
106
|
+
const previousTreeSnapshotId = this.#currentTreeSnapshotId;
|
|
107
|
+
this.#currentTreeSnapshotId = treeSnapshotId;
|
|
108
|
+
this.#treeSnapshots.set(treeSnapshotId, state);
|
|
109
|
+
if (previousTreeSnapshotId !== null && previousTreeSnapshotId !== treeSnapshotId && !this.#treeSnapshotClaimCounts.has(previousTreeSnapshotId)) this.#treeSnapshots.delete(previousTreeSnapshotId);
|
|
110
|
+
if (historyTreeSnapshotId !== treeSnapshotId) this.#replaceHistoryState(createHistoryStateWithTreeSnapshotId(this.#readHistoryState(), treeSnapshotId));
|
|
111
|
+
}
|
|
112
|
+
isCurrentExternalHistoryTree(historyState) {
|
|
113
|
+
const treeSnapshotId = readHistoryStateTreeSnapshotId(historyState);
|
|
114
|
+
return treeSnapshotId !== null && treeSnapshotId === this.#currentTreeSnapshotId;
|
|
115
|
+
}
|
|
116
|
+
/** Records the raw/hash history entry that now claims the live tree. */
|
|
117
|
+
claimCurrentHistoryTreeSnapshot(historyUpdateMode, previousHistoryState) {
|
|
118
|
+
let historyState = this.#readHistoryState();
|
|
119
|
+
const treeSnapshotId = readHistoryStateTreeSnapshotId(historyState);
|
|
120
|
+
if (treeSnapshotId === null || !this.#treeSnapshots.has(treeSnapshotId)) return;
|
|
121
|
+
let historyIndex;
|
|
122
|
+
if (historyUpdateMode === "push") {
|
|
123
|
+
this.#releaseForwardTreeSnapshotClaims();
|
|
124
|
+
historyIndex = this.#nextHistoryTraversalIndex + 1;
|
|
125
|
+
} else historyIndex = readHistoryStateTraversalIndex(previousHistoryState) ?? this.#currentHistoryTraversalIndex;
|
|
126
|
+
if (historyIndex === null) return;
|
|
127
|
+
historyState = createHistoryStateWithTreeSnapshotClaim(createHistoryStateWithNavigationMetadata(historyState, {
|
|
128
|
+
previousNextUrl: readHistoryStatePreviousNextUrl(historyState),
|
|
129
|
+
traversalIndex: historyIndex
|
|
130
|
+
}), true);
|
|
131
|
+
this.#replaceHistoryState(historyState);
|
|
132
|
+
this.#claimTreeSnapshotAtHistoryIndex(historyIndex, treeSnapshotId);
|
|
133
|
+
this.commitHistoryTraversalIndex(historyIndex);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Applies only the claim cleanup caused by a successful raw History API write
|
|
137
|
+
* whose caller state is already app-owned. The browser write intentionally
|
|
138
|
+
* bypasses external-tree claiming (matching Next.js' `data?.__NA` path), but
|
|
139
|
+
* it still overwrites or truncates entries that may own retained snapshots.
|
|
140
|
+
* Every cleanup operation is idempotent so duplicate runtime delivery is safe.
|
|
141
|
+
*/
|
|
142
|
+
commitAppOwnedHistoryStateWrite(historyUpdateMode, previousHistoryState) {
|
|
143
|
+
if (historyUpdateMode === "push") {
|
|
144
|
+
this.#releaseForwardTreeSnapshotClaims();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!isExternalHistoryState(previousHistoryState) && !isHistoryStateTreeSnapshotClaimed(previousHistoryState)) return;
|
|
148
|
+
const previousHistoryIndex = readHistoryStateTraversalIndex(previousHistoryState) ?? this.#currentHistoryTraversalIndex;
|
|
149
|
+
if (previousHistoryIndex !== null) this.#releaseTreeSnapshotClaimAtHistoryIndex(previousHistoryIndex);
|
|
150
|
+
}
|
|
151
|
+
#claimTreeSnapshotAtHistoryIndex(historyIndex, treeSnapshotId) {
|
|
152
|
+
const previousTreeSnapshotId = this.#treeSnapshotClaimByHistoryIndex.get(historyIndex);
|
|
153
|
+
if (previousTreeSnapshotId === treeSnapshotId) return;
|
|
154
|
+
if (previousTreeSnapshotId !== void 0) this.#releaseTreeSnapshotClaim(previousTreeSnapshotId);
|
|
155
|
+
this.#treeSnapshotClaimByHistoryIndex.set(historyIndex, treeSnapshotId);
|
|
156
|
+
this.#treeSnapshotClaimCounts.set(treeSnapshotId, (this.#treeSnapshotClaimCounts.get(treeSnapshotId) ?? 0) + 1);
|
|
157
|
+
}
|
|
158
|
+
#releaseTreeSnapshotClaimAtHistoryIndex(historyIndex) {
|
|
159
|
+
const treeSnapshotId = this.#treeSnapshotClaimByHistoryIndex.get(historyIndex);
|
|
160
|
+
if (treeSnapshotId === void 0) return;
|
|
161
|
+
this.#treeSnapshotClaimByHistoryIndex.delete(historyIndex);
|
|
162
|
+
this.#releaseTreeSnapshotClaim(treeSnapshotId);
|
|
163
|
+
}
|
|
164
|
+
#releaseForwardTreeSnapshotClaims() {
|
|
165
|
+
const currentHistoryIndex = this.#currentHistoryTraversalIndex;
|
|
166
|
+
if (currentHistoryIndex === null) return;
|
|
167
|
+
for (const historyIndex of this.#treeSnapshotClaimByHistoryIndex.keys()) if (historyIndex > currentHistoryIndex) this.#releaseTreeSnapshotClaimAtHistoryIndex(historyIndex);
|
|
168
|
+
}
|
|
169
|
+
#releaseTreeSnapshotClaim(treeSnapshotId) {
|
|
170
|
+
const claimCount = this.#treeSnapshotClaimCounts.get(treeSnapshotId);
|
|
171
|
+
if (claimCount === void 0) return;
|
|
172
|
+
if (claimCount > 1) {
|
|
173
|
+
this.#treeSnapshotClaimCounts.set(treeSnapshotId, claimCount - 1);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.#treeSnapshotClaimCounts.delete(treeSnapshotId);
|
|
177
|
+
if (treeSnapshotId !== this.#currentTreeSnapshotId) this.#treeSnapshots.delete(treeSnapshotId);
|
|
95
178
|
}
|
|
96
179
|
commitHashOnlyNavigation(href, historyUpdateMode, scroll) {
|
|
180
|
+
if (historyUpdateMode === "push") this.#releaseForwardTreeSnapshotClaims();
|
|
97
181
|
const navigationHistoryIndex = this.allocateNavigationHistoryTraversalIndex(historyUpdateMode);
|
|
98
182
|
const historyState = this.#readHistoryState();
|
|
99
183
|
const visible = this.#readVisibleNavigationMetadata();
|
|
100
184
|
const previousNextUrl = visible ? visible.previousNextUrl : readHistoryStatePreviousNextUrl(historyState);
|
|
101
185
|
const bfcacheIds = visible ? visible.bfcacheIds : this.#restorableClientState.readCurrentBfcacheVersionHistoryIds(historyState);
|
|
102
|
-
const
|
|
186
|
+
const activeRoutePaths = visible ? visible.activeRoutePaths : readHistoryStateActiveRoutePaths(historyState);
|
|
187
|
+
const nextHistoryState = createHistoryStateWithTreeSnapshotClaim(createHistoryStateWithNavigationMetadata(this.#createHashOnlyNavigationBaseHistoryState(historyUpdateMode, scroll), {
|
|
188
|
+
activeRoutePaths,
|
|
103
189
|
bfcacheIds,
|
|
104
190
|
bfcacheVersion: bfcacheIds === null ? void 0 : this.#restorableClientState.currentBfcacheVersion,
|
|
105
191
|
previousNextUrl,
|
|
106
192
|
traversalIndex: navigationHistoryIndex
|
|
107
|
-
});
|
|
193
|
+
}), true);
|
|
108
194
|
if (historyUpdateMode === "replace") this.#replaceHistoryState(nextHistoryState, href);
|
|
109
195
|
else this.#pushHistoryState(nextHistoryState, href);
|
|
196
|
+
const treeSnapshotId = readHistoryStateTreeSnapshotId(nextHistoryState);
|
|
197
|
+
if (navigationHistoryIndex !== null && treeSnapshotId !== null) this.#claimTreeSnapshotAtHistoryIndex(navigationHistoryIndex, treeSnapshotId);
|
|
110
198
|
this.commitHistoryTraversalIndex(navigationHistoryIndex);
|
|
111
199
|
}
|
|
112
200
|
#createHashOnlyNavigationBaseHistoryState(historyUpdateMode, scroll) {
|
|
113
|
-
if (historyUpdateMode !== "replace") return null;
|
|
114
201
|
const historyState = this.#readHistoryState();
|
|
202
|
+
if (historyUpdateMode !== "replace") {
|
|
203
|
+
const treeState = createHistoryStateWithTreeSnapshotId(null, readHistoryStateTreeSnapshotId(historyState));
|
|
204
|
+
return isExternalHistoryState(historyState) ? createExternalHistoryStatePreservingMetadata(treeState, historyState) : treeState;
|
|
205
|
+
}
|
|
115
206
|
return scroll ? stripVinextScrollState(historyState) : historyState;
|
|
116
207
|
}
|
|
117
208
|
/**
|
|
@@ -123,63 +214,71 @@ var AppBrowserHistoryController = class {
|
|
|
123
214
|
*/
|
|
124
215
|
commitNavigationHistory(options) {
|
|
125
216
|
const currentHref = this.#readCurrentHref();
|
|
217
|
+
const currentHistoryState = this.#readHistoryState();
|
|
126
218
|
const origin = new URL(currentHref).origin;
|
|
127
219
|
const targetHref = new URL(options.href, origin).href;
|
|
128
220
|
const preserveExistingState = options.historyUpdateMode === "replace";
|
|
221
|
+
const replacesClaimedOrExternalTree = preserveExistingState && (isExternalHistoryState(currentHistoryState) || isHistoryStateTreeSnapshotClaimed(currentHistoryState));
|
|
129
222
|
const navigationHistoryIndex = options.targetHistoryIndex !== void 0 ? options.targetHistoryIndex : this.allocateNavigationHistoryTraversalIndex(options.historyUpdateMode);
|
|
130
|
-
const historyState = createHistoryStateWithNavigationMetadata(preserveExistingState ?
|
|
223
|
+
const historyState = clearHistoryStateTreeSnapshotId(createAppOwnedHistoryState(createHistoryStateWithNavigationMetadata(preserveExistingState ? currentHistoryState : null, {
|
|
224
|
+
activeRoutePaths: options.activeRoutePaths,
|
|
131
225
|
bfcacheIds: options.bfcacheIds,
|
|
132
226
|
bfcacheVersion: this.#restorableClientState.currentBfcacheVersion,
|
|
133
227
|
previousNextUrl: options.previousNextUrl,
|
|
134
228
|
traversalIndex: navigationHistoryIndex
|
|
135
|
-
});
|
|
229
|
+
})));
|
|
136
230
|
let wroteHistoryState = false;
|
|
137
|
-
if (options.historyUpdateMode === "replace" && currentHref !== targetHref) {
|
|
231
|
+
if (options.historyUpdateMode === "replace" && (currentHref !== targetHref || replacesClaimedOrExternalTree)) {
|
|
138
232
|
options.stageClientParams();
|
|
233
|
+
const currentHistoryIndex = readHistoryStateTraversalIndex(currentHistoryState) ?? this.#currentHistoryTraversalIndex;
|
|
234
|
+
if (currentHistoryIndex !== null) this.#releaseTreeSnapshotClaimAtHistoryIndex(currentHistoryIndex);
|
|
139
235
|
this.#replaceHistoryState(historyState, options.href);
|
|
140
236
|
wroteHistoryState = true;
|
|
141
237
|
this.commitHistoryTraversalIndex(navigationHistoryIndex);
|
|
142
238
|
} else if (options.historyUpdateMode === "push" && currentHref !== targetHref) {
|
|
143
239
|
options.stageClientParams();
|
|
240
|
+
this.#releaseForwardTreeSnapshotClaims();
|
|
144
241
|
this.#pushHistoryState(historyState, options.href);
|
|
145
242
|
wroteHistoryState = true;
|
|
146
243
|
this.commitHistoryTraversalIndex(navigationHistoryIndex);
|
|
147
244
|
}
|
|
148
245
|
if (!wroteHistoryState) {
|
|
149
|
-
this.syncCurrentHistoryStatePreviousNextUrl(options.previousNextUrl, options.bfcacheIds);
|
|
246
|
+
this.syncCurrentHistoryStatePreviousNextUrl(options.previousNextUrl, options.bfcacheIds, options.activeRoutePaths);
|
|
150
247
|
options.stageClientParams();
|
|
151
248
|
if (options.targetHistoryIndex !== void 0) this.commitHistoryTraversalIndex(options.targetHistoryIndex);
|
|
152
249
|
}
|
|
153
250
|
}
|
|
154
|
-
syncCurrentHistoryStatePreviousNextUrl(previousNextUrl, bfcacheIds) {
|
|
155
|
-
if (this.#isHistoryStateNavigationMetadataInSync(this.#readHistoryState(), previousNextUrl, bfcacheIds)) return;
|
|
251
|
+
syncCurrentHistoryStatePreviousNextUrl(previousNextUrl, bfcacheIds, activeRoutePaths) {
|
|
252
|
+
if (this.#isHistoryStateNavigationMetadataInSync(this.#readHistoryState(), previousNextUrl, bfcacheIds, activeRoutePaths)) return;
|
|
156
253
|
const nextHistoryState = createHistoryStateWithNavigationMetadata(this.#readHistoryState(), {
|
|
254
|
+
activeRoutePaths,
|
|
157
255
|
bfcacheIds,
|
|
158
256
|
bfcacheVersion: bfcacheIds === void 0 ? void 0 : this.#restorableClientState.currentBfcacheVersion,
|
|
159
257
|
previousNextUrl
|
|
160
258
|
});
|
|
161
259
|
this.#replaceHistoryState(nextHistoryState);
|
|
162
|
-
if (this.#isHistoryStateNavigationMetadataInSync(this.#readHistoryState(), previousNextUrl, bfcacheIds)) return;
|
|
260
|
+
if (this.#isHistoryStateNavigationMetadataInSync(this.#readHistoryState(), previousNextUrl, bfcacheIds, activeRoutePaths)) return;
|
|
163
261
|
this.#replaceHistoryState(nextHistoryState);
|
|
164
262
|
}
|
|
165
|
-
#isHistoryStateNavigationMetadataInSync(state, previousNextUrl, bfcacheIds) {
|
|
166
|
-
return readHistoryStatePreviousNextUrl(state) === previousNextUrl && (bfcacheIds === void 0 || areBfcacheIdMapsEqual(readHistoryStateBfcacheIds(state), bfcacheIds) && this.#restorableClientState.isCurrentBfcacheVersion(state));
|
|
263
|
+
#isHistoryStateNavigationMetadataInSync(state, previousNextUrl, bfcacheIds, activeRoutePaths) {
|
|
264
|
+
return readHistoryStatePreviousNextUrl(state) === previousNextUrl && (activeRoutePaths === void 0 || areStringArraysEqual(readHistoryStateActiveRoutePaths(state), activeRoutePaths)) && (bfcacheIds === void 0 || areBfcacheIdMapsEqual(readHistoryStateBfcacheIds(state), bfcacheIds) && this.#restorableClientState.isCurrentBfcacheVersion(state));
|
|
167
265
|
}
|
|
168
266
|
/** Initial history write performed before hydration starts. */
|
|
169
267
|
writeBootstrapHistoryMetadata() {
|
|
170
|
-
this.#replaceHistoryState(createHistoryStateWithNavigationMetadata(this.#readHistoryState(), {
|
|
268
|
+
this.#replaceHistoryState(clearHistoryStateTreeSnapshotId(createAppOwnedHistoryState(createHistoryStateWithNavigationMetadata(this.#readHistoryState(), {
|
|
171
269
|
previousNextUrl: null,
|
|
172
270
|
traversalIndex: this.#currentHistoryTraversalIndex
|
|
173
|
-
}), createCanonicalBrowserHistoryHref(this.#readCurrentHref()));
|
|
271
|
+
}))), createCanonicalBrowserHistoryHref(this.#readCurrentHref()));
|
|
174
272
|
}
|
|
175
273
|
/** History write performed on the first committed (hydrated) render. */
|
|
176
274
|
writeHydratedHistoryMetadata(options) {
|
|
177
|
-
this.#replaceHistoryState(createHistoryStateWithNavigationMetadata(this.#readHistoryState(), {
|
|
275
|
+
this.#replaceHistoryState(createAppOwnedHistoryState(createHistoryStateWithNavigationMetadata(this.#readHistoryState(), {
|
|
276
|
+
activeRoutePaths: options.activeRoutePaths,
|
|
178
277
|
bfcacheIds: options.bfcacheIds,
|
|
179
278
|
bfcacheVersion: this.#restorableClientState.currentBfcacheVersion,
|
|
180
279
|
previousNextUrl: options.previousNextUrl,
|
|
181
280
|
traversalIndex: this.#currentHistoryTraversalIndex
|
|
182
|
-
}));
|
|
281
|
+
})));
|
|
183
282
|
}
|
|
184
283
|
/**
|
|
185
284
|
* Resolves a restorable snapshot candidate for the given history entry and
|
|
@@ -191,8 +290,21 @@ var AppBrowserHistoryController = class {
|
|
|
191
290
|
* not approved.
|
|
192
291
|
*/
|
|
193
292
|
restoreHistorySnapshot(options) {
|
|
293
|
+
const restoreTreeSnapshot = () => {
|
|
294
|
+
const treeSnapshotId = readHistoryStateTreeSnapshotId(options.historyState);
|
|
295
|
+
const state = treeSnapshotId === null ? void 0 : this.#treeSnapshots.get(treeSnapshotId);
|
|
296
|
+
if (!state) return false;
|
|
297
|
+
return options.approveVisibleRestore({
|
|
298
|
+
state,
|
|
299
|
+
beforeCommit: () => {
|
|
300
|
+
this.commitTraversalIndexFromHistoryState(options.historyState);
|
|
301
|
+
options.stageClientParams(state.navigationSnapshot.params);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
if (options.preferExternalSnapshot) return restoreTreeSnapshot();
|
|
194
306
|
const decision = this.#restorableClientState.resolveHistoryStateSnapshotRestore(options.historyState);
|
|
195
|
-
if (decision.kind === "skip") return
|
|
307
|
+
if (decision.kind === "skip") return restoreTreeSnapshot();
|
|
196
308
|
return options.approveVisibleRestore({
|
|
197
309
|
state: decision.state,
|
|
198
310
|
beforeCommit: () => {
|
|
@@ -202,6 +314,11 @@ var AppBrowserHistoryController = class {
|
|
|
202
314
|
});
|
|
203
315
|
}
|
|
204
316
|
};
|
|
317
|
+
function areStringArraysEqual(a, b) {
|
|
318
|
+
if (a === b) return true;
|
|
319
|
+
if (a === null || b === null || a.length !== b.length) return false;
|
|
320
|
+
return a.every((value, index) => b[index] === value);
|
|
321
|
+
}
|
|
205
322
|
function areBfcacheIdMapsEqual(a, b) {
|
|
206
323
|
if (a === b) return true;
|
|
207
324
|
if (a === null || b === null) return false;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/server/app-browser-navigation-abort.d.ts
|
|
2
|
+
type AppBrowserNavigationAbortHandle = {
|
|
3
|
+
release(): void;
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Owns cancellation only while a navigation still has abortable transport work.
|
|
8
|
+
* Once a Flight response is handed to React, release the handle so a newer
|
|
9
|
+
* navigation does not abort the response body while React is decoding it.
|
|
10
|
+
*/
|
|
11
|
+
declare function createAppBrowserNavigationAbortCoordinator(): {
|
|
12
|
+
abortActive(): void;
|
|
13
|
+
begin(): AppBrowserNavigationAbortHandle;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { AppBrowserNavigationAbortHandle, createAppBrowserNavigationAbortCoordinator };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/server/app-browser-navigation-abort.ts
|
|
2
|
+
/**
|
|
3
|
+
* Owns cancellation only while a navigation still has abortable transport work.
|
|
4
|
+
* Once a Flight response is handed to React, release the handle so a newer
|
|
5
|
+
* navigation does not abort the response body while React is decoding it.
|
|
6
|
+
*/
|
|
7
|
+
function createAppBrowserNavigationAbortCoordinator() {
|
|
8
|
+
let activeController = null;
|
|
9
|
+
const abortActive = () => {
|
|
10
|
+
activeController?.abort();
|
|
11
|
+
activeController = null;
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
abortActive,
|
|
15
|
+
begin() {
|
|
16
|
+
abortActive();
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
activeController = controller;
|
|
19
|
+
return {
|
|
20
|
+
release() {
|
|
21
|
+
if (activeController === controller) activeController = null;
|
|
22
|
+
},
|
|
23
|
+
signal: controller.signal
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { createAppBrowserNavigationAbortCoordinator };
|
|
@@ -19,6 +19,7 @@ type NavigationPayloadOutcome = "committed" | "no-commit" | "hard-navigate";
|
|
|
19
19
|
type HardNavigationMode = "assign" | "replace";
|
|
20
20
|
type BrowserNavigationCommitEffect = () => void;
|
|
21
21
|
type BrowserNavigationCommitEffectFactory = (options: {
|
|
22
|
+
activeRoutePaths: readonly string[];
|
|
22
23
|
bfcacheIds: Readonly<Record<string, string>>;
|
|
23
24
|
href: string;
|
|
24
25
|
historyUpdateMode: HistoryUpdateMode | undefined;
|
|
@@ -49,6 +50,7 @@ type BrowserNavigationPayloadOptions = {
|
|
|
49
50
|
historyUpdateMode: HistoryUpdateMode | undefined;
|
|
50
51
|
navigationCommitKind?: "authoritative" | "detached";
|
|
51
52
|
navigationInitiationState: AppRouterState;
|
|
53
|
+
navigationResponseCompletion?: Promise<unknown>;
|
|
52
54
|
navigationSnapshot: ClientNavigationRenderSnapshot;
|
|
53
55
|
navId: number;
|
|
54
56
|
nextElements: Promise<AppElements> | AppElements;
|
|
@@ -77,6 +79,7 @@ type BrowserNavigationController = {
|
|
|
77
79
|
beginPendingBrowserRouterState(): PendingBrowserRouterState;
|
|
78
80
|
finalizeNavigation(navId: number, pending: PendingBrowserRouterState | null | undefined): void;
|
|
79
81
|
restoreHistorySnapshotVisibleState(options: {
|
|
82
|
+
restoreCopiedExternalHistoryEntry?: boolean;
|
|
80
83
|
beforeCommit?: () => void;
|
|
81
84
|
navId: number;
|
|
82
85
|
state: AppRouterState;
|
|
@@ -97,6 +100,7 @@ type BrowserNavigationController = {
|
|
|
97
100
|
* navigation would otherwise be lost.
|
|
98
101
|
*/
|
|
99
102
|
drainPrePaintEffects(renderId: number): void;
|
|
103
|
+
commitNavigationRender(renderId: number): void;
|
|
100
104
|
clearCommittedNavigationFailureTargets(renderId: number): void;
|
|
101
105
|
NavigationCommitSignal(this: void, { renderId, children }: {
|
|
102
106
|
renderId: number;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { clearAppNavigationFailureTarget, getAppNavigationFailureTarget } from "../client/app-nav-failure-handler.js";
|
|
3
3
|
import { claimAppRouterScrollIntentForCommit, consumeAppRouterScrollIntent } from "../shims/app-router-scroll-state.js";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveActiveRoutePaths } from "./app-history-state.js";
|
|
5
5
|
import { activateNavigationSnapshot, clearPendingPathname, commitClientNavigationState, createSnapshotPathAndSearch } from "../shims/navigation.js";
|
|
6
|
+
import { resolveServerActionOperationLane, shouldScheduleRefreshForDiscardedServerAction } from "./app-browser-action-result.js";
|
|
6
7
|
import { FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, createPendingNavigationCommit, createPendingNavigationCommitFromElements } from "./app-browser-state.js";
|
|
7
8
|
import { applyApprovedVisibleCommit, approveHmrVisibleCommit, approvePendingNavigationCommit, resolveAndClassifyNavigationCommit } from "./app-browser-visible-commit.js";
|
|
8
9
|
import { startTransition, useInsertionEffect, useLayoutEffect } from "react";
|
|
@@ -198,6 +199,10 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
198
199
|
pendingCommit.resolve(didCommit);
|
|
199
200
|
}
|
|
200
201
|
}
|
|
202
|
+
function commitNavigationRender(renderId) {
|
|
203
|
+
drainPrePaintEffects(renderId);
|
|
204
|
+
settleNavigationCommits(renderId, true);
|
|
205
|
+
}
|
|
201
206
|
function clearCommittedNavigationFailureTargets(renderId) {
|
|
202
207
|
for (const [pendingId, targetHref] of pendingNavigationFailureTargets) {
|
|
203
208
|
if (pendingId > renderId) continue;
|
|
@@ -234,8 +239,7 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
234
239
|
clearCommittedNavigationFailureTargets(renderId);
|
|
235
240
|
}, [renderId]);
|
|
236
241
|
useLayoutEffect(() => {
|
|
237
|
-
|
|
238
|
-
settleNavigationCommits(renderId, true);
|
|
242
|
+
commitNavigationRender(renderId);
|
|
239
243
|
return () => {
|
|
240
244
|
settleNavigationCommits(renderId, false);
|
|
241
245
|
};
|
|
@@ -311,7 +315,8 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
311
315
|
};
|
|
312
316
|
}
|
|
313
317
|
function restoreHistorySnapshotVisibleState(options) {
|
|
314
|
-
if (!isSnapshotTargetHref(basePath, options.state.navigationSnapshot, options.targetHref)) return false;
|
|
318
|
+
if (!options.restoreCopiedExternalHistoryEntry && !isSnapshotTargetHref(basePath, options.state.navigationSnapshot, options.targetHref)) return false;
|
|
319
|
+
const approvalTargetHref = options.restoreCopiedExternalHistoryEntry ? createSnapshotPathAndSearch(options.state.navigationSnapshot) : options.targetHref;
|
|
315
320
|
const currentState = getBrowserRouterState();
|
|
316
321
|
const pending = createRestoredHistorySnapshotCommit({
|
|
317
322
|
currentState,
|
|
@@ -324,7 +329,7 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
324
329
|
pending,
|
|
325
330
|
routeManifest: getRouteManifest(),
|
|
326
331
|
startedNavigationId: options.navId,
|
|
327
|
-
targetHref:
|
|
332
|
+
targetHref: approvalTargetHref
|
|
328
333
|
});
|
|
329
334
|
if (approval.approvedCommit === null) return false;
|
|
330
335
|
options.beforeCommit?.();
|
|
@@ -415,8 +420,10 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
415
420
|
}
|
|
416
421
|
const approvedCommit = approval.approvedCommit;
|
|
417
422
|
if (approvedCommit === null) throw new Error("[vinext] Commit decision did not approve a visible commit");
|
|
423
|
+
const approvedVisibleState = applyApprovedVisibleCommit(getBrowserRouterState(), approvedCommit);
|
|
418
424
|
queuePrePaintNavigationEffect(renderId, options.createNavigationCommitEffect({
|
|
419
|
-
|
|
425
|
+
activeRoutePaths: resolveActiveRoutePaths(approvedVisibleState.slotBindings),
|
|
426
|
+
bfcacheIds: approvedVisibleState.bfcacheIds,
|
|
420
427
|
href: options.targetHref,
|
|
421
428
|
historyUpdateMode: options.historyUpdateMode,
|
|
422
429
|
navId: options.navId,
|
|
@@ -428,6 +435,14 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
428
435
|
activateNavigationSnapshot();
|
|
429
436
|
snapshotActivated = true;
|
|
430
437
|
dispatchApprovedVisibleCommit(renderId, approvedCommit, options.pendingRouterState, shouldForceSynchronousCommit(options) ? "synchronous" : options.visibleCommitMode ?? "transition");
|
|
438
|
+
if (options.navigationResponseCompletion) options.navigationResponseCompletion.then(() => {
|
|
439
|
+
if (!isCurrentNavigation(options.navId) || !hasBrowserRouterState()) return;
|
|
440
|
+
const committedState = pendingNavigationCommits.get(renderId)?.committedState;
|
|
441
|
+
if (!committedState) return;
|
|
442
|
+
flushSync(() => {
|
|
443
|
+
getBrowserRouterStateSetter()(committedState);
|
|
444
|
+
});
|
|
445
|
+
}, () => {});
|
|
431
446
|
} catch (error) {
|
|
432
447
|
pendingNavigationFailureTargets.delete(renderId);
|
|
433
448
|
pendingNavigationPrePaintEffects.delete(renderId);
|
|
@@ -516,6 +531,7 @@ function createAppBrowserNavigationController(deps = {}) {
|
|
|
516
531
|
commitSameUrlNavigatePayload,
|
|
517
532
|
hmrReplaceTree,
|
|
518
533
|
drainPrePaintEffects,
|
|
534
|
+
commitNavigationRender,
|
|
519
535
|
clearCommittedNavigationFailureTargets,
|
|
520
536
|
NavigationCommitSignal
|
|
521
537
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClientNavigationRenderSnapshot } from "../shims/navigation.js";
|
|
2
|
+
//#region src/server/app-browser-navigation-response.d.ts
|
|
3
|
+
declare function shouldRecoverSamePathSearchCommitOnResponseCompletion(options: {
|
|
4
|
+
basePath: string;
|
|
5
|
+
currentSnapshot: ClientNavigationRenderSnapshot;
|
|
6
|
+
navigationKind: "navigate" | "traverse" | "refresh";
|
|
7
|
+
programmaticTransition: boolean;
|
|
8
|
+
targetUrl: URL;
|
|
9
|
+
}): boolean;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { shouldRecoverSamePathSearchCommitOnResponseCompletion };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { stripBasePath } from "../utils/base-path.js";
|
|
2
|
+
//#region src/server/app-browser-navigation-response.ts
|
|
3
|
+
function shouldRecoverSamePathSearchCommitOnResponseCompletion(options) {
|
|
4
|
+
if (!options.programmaticTransition || options.navigationKind !== "navigate") return false;
|
|
5
|
+
return options.currentSnapshot.pathname === stripBasePath(options.targetUrl.pathname, options.basePath) && options.currentSnapshot.search !== options.targetUrl.search;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { shouldRecoverSamePathSearchCommitOnResponseCompletion };
|
|
@@ -20,6 +20,11 @@ type SynchronousPopstateScrollRestoreDeps = {
|
|
|
20
20
|
restorePopstateScrollPosition: RestoreScrollPosition;
|
|
21
21
|
};
|
|
22
22
|
declare function restoreSynchronousPopstateScrollPosition(deps: SynchronousPopstateScrollRestoreDeps, state: unknown): void;
|
|
23
|
+
declare function shouldCommitPopstateUrlWithoutNavigation(options: {
|
|
24
|
+
historyState: unknown;
|
|
25
|
+
isCurrentExternalHistoryTree: boolean;
|
|
26
|
+
isSameAppRouteTarget: boolean;
|
|
27
|
+
}): boolean;
|
|
23
28
|
declare function createPopstateRestoreHandler(deps: BrowserPopstateRestoreDeps): (event: PopStateEvent) => void;
|
|
24
29
|
//#endregion
|
|
25
|
-
export { createPopstateRestoreHandler, restoreSynchronousPopstateScrollPosition };
|
|
30
|
+
export { createPopstateRestoreHandler, restoreSynchronousPopstateScrollPosition, shouldCommitPopstateUrlWithoutNavigation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readHistoryStateTraversalIndex } from "./app-history-state.js";
|
|
1
|
+
import { isExternalHistoryState, readHistoryStateTraversalIndex } from "./app-history-state.js";
|
|
2
2
|
import "./app-browser-state.js";
|
|
3
3
|
//#region src/server/app-browser-popstate.ts
|
|
4
4
|
function hasSavedScrollPosition(state) {
|
|
@@ -23,6 +23,10 @@ function createPopstateTraversalIntent(historyState) {
|
|
|
23
23
|
targetHistoryIndex: readHistoryStateTraversalIndex(historyState)
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
function shouldCommitPopstateUrlWithoutNavigation(options) {
|
|
27
|
+
if (isExternalHistoryState(options.historyState)) return options.isCurrentExternalHistoryTree;
|
|
28
|
+
return options.isSameAppRouteTarget;
|
|
29
|
+
}
|
|
26
30
|
function createPopstateRestoreHandler(deps) {
|
|
27
31
|
return (event) => {
|
|
28
32
|
deps.notifyAppRouterTransitionStart(window.location.href);
|
|
@@ -41,4 +45,4 @@ function createPopstateRestoreHandler(deps) {
|
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
//#endregion
|
|
44
|
-
export { createPopstateRestoreHandler, restoreSynchronousPopstateScrollPosition };
|
|
48
|
+
export { createPopstateRestoreHandler, restoreSynchronousPopstateScrollPosition, shouldCommitPopstateUrlWithoutNavigation };
|
|
@@ -4,10 +4,10 @@ import { DANGEROUS_URL_BLOCK_MESSAGE, isDangerousScheme } from "../shims/url-saf
|
|
|
4
4
|
import { AppElementsWire } from "./app-elements-wire.js";
|
|
5
5
|
import "./app-elements.js";
|
|
6
6
|
import { VINEXT_RSC_COMPATIBILITY_ID_HEADER, createServerActionRequestUrl } from "./app-rsc-cache-busting.js";
|
|
7
|
+
import { throwOnServerActionNotFound } from "./server-action-not-found.js";
|
|
7
8
|
import { createServerActionResultFacts, isServerActionResult, normalizeServerActionThrownValue, parseServerActionRevalidationHeader, readInvalidServerActionResponseError, shouldClearClientNavigationCachesForServerActionResult, shouldSyncServerActionHttpFallbackHead } from "./app-browser-action-result.js";
|
|
8
9
|
import { resolveServerActionRequestState } from "./app-browser-state.js";
|
|
9
10
|
import { applyServerActionResultDecision } from "./app-browser-server-action-navigation.js";
|
|
10
|
-
import { throwOnServerActionNotFound } from "./server-action-not-found.js";
|
|
11
11
|
import { createFromFetch, createTemporaryReferenceSet, encodeReply } from "@vitejs/plugin-rsc/browser";
|
|
12
12
|
//#region src/server/app-browser-server-action-client.ts
|
|
13
13
|
function resolveActionRedirectTarget(response, basePath, performHardNavigation) {
|
|
@@ -5,7 +5,7 @@ import "./app-elements.js";
|
|
|
5
5
|
import { NavigationTrace } from "./navigation-trace.js";
|
|
6
6
|
import { OperationLane } from "./operation-token.js";
|
|
7
7
|
import "./navigation-planner.js";
|
|
8
|
-
import { BfcacheIdMap, HistoryTraversalIntent, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, isHistoryStateBfcacheVersionCurrent, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
8
|
+
import { BfcacheIdMap, HistoryTraversalIntent, createAppOwnedHistoryState, createExternalHistoryStatePreservingMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createHistoryStateWithTreeSnapshotId, isExternalHistoryState, isHistoryStateBfcacheVersionCurrent, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveActiveRoutePaths, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
9
9
|
import { createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements } from "./app-bfcache-identity.js";
|
|
10
10
|
import { ClientNavigationRenderSnapshot } from "../shims/navigation.js";
|
|
11
11
|
//#region src/server/app-browser-state.d.ts
|
|
@@ -154,4 +154,4 @@ declare function createPendingNavigationCommit(options: CreatePendingNavigationC
|
|
|
154
154
|
nextElements: Promise<AppElements>;
|
|
155
155
|
}): Promise<PendingNavigationCommit>;
|
|
156
156
|
//#endregion
|
|
157
|
-
export { AppNavigationPayloadOrigin, AppRouterAction, AppRouterState, COMMITTED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, CommittedOperationRecord, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, type HistoryTraversalIntent, type OperationLane, PendingNavigationCommit, PendingOperationRecord, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, createBfcacheSegmentIdentityMap, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createInitialBfcacheIdMap, createNextBfcacheIdMap, createPendingNavigationCommit, createPendingNavigationCommitFromElements, isCacheRestorableAppPayloadMetadata, isCompleteAppPayloadMetadata, isHistoryStateBfcacheVersionCurrent, preserveBfcacheIdsForMergedElements, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent, resolveInterceptionContextFromPreviousNextUrl, resolvePendingNavigationCommitDispositionDecision, resolveServerActionRequestState };
|
|
157
|
+
export { AppNavigationPayloadOrigin, AppRouterAction, AppRouterState, COMMITTED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, CommittedOperationRecord, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, type HistoryTraversalIntent, type OperationLane, PendingNavigationCommit, PendingOperationRecord, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, createAppOwnedHistoryState, createBfcacheSegmentIdentityMap, createExternalHistoryStatePreservingMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createHistoryStateWithTreeSnapshotId, createInitialBfcacheIdMap, createNextBfcacheIdMap, createPendingNavigationCommit, createPendingNavigationCommitFromElements, isCacheRestorableAppPayloadMetadata, isCompleteAppPayloadMetadata, isExternalHistoryState, isHistoryStateBfcacheVersionCurrent, preserveBfcacheIdsForMergedElements, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveActiveRoutePaths, resolveHistoryTraversalIntent, resolveInterceptionContextFromPreviousNextUrl, resolvePendingNavigationCommitDispositionDecision, resolveServerActionRequestState };
|
|
@@ -6,12 +6,12 @@ import { AppElementsWire } from "./app-elements-wire.js";
|
|
|
6
6
|
import { getMountedSlotIds, getMountedSlotIdsHeader } from "./app-elements.js";
|
|
7
7
|
import { createRscRequestHeaders } from "./app-rsc-cache-busting.js";
|
|
8
8
|
import { createCacheEntryReuseProof } from "./cache-proof.js";
|
|
9
|
-
import { createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, isHistoryStateBfcacheVersionCurrent, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
10
|
-
import { createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements } from "./app-bfcache-identity.js";
|
|
9
|
+
import { createAppOwnedHistoryState, createExternalHistoryStatePreservingMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createHistoryStateWithTreeSnapshotId, isExternalHistoryState, isHistoryStateBfcacheVersionCurrent, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveActiveRoutePaths, resolveHistoryTraversalIntent } from "./app-history-state.js";
|
|
11
10
|
import { NavigationTraceReasonCodes, createNavigationLifecycleTraceFields, createNavigationTrace } from "./navigation-trace.js";
|
|
12
11
|
import { verifyOperationTokenForCommit } from "./operation-token.js";
|
|
13
12
|
import { navigationPlanner, resolveDefaultOrUnmatchedSlotPersistenceForLayouts } from "./navigation-planner.js";
|
|
14
13
|
import { createSnapshotPathAndSearch } from "../shims/navigation.js";
|
|
14
|
+
import { createBfcacheSegmentIdentityMap, createInitialBfcacheIdMap, createNextBfcacheIdMap, preserveBfcacheIdsForMergedElements } from "./app-bfcache-identity.js";
|
|
15
15
|
//#region src/server/app-browser-state.ts
|
|
16
16
|
const COMMITTED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN = { origin: "committed-cache" };
|
|
17
17
|
const FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN = { origin: "fresh" };
|
|
@@ -333,4 +333,4 @@ async function createPendingNavigationCommit(options) {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
//#endregion
|
|
336
|
-
export { COMMITTED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, createBfcacheSegmentIdentityMap, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createInitialBfcacheIdMap, createNextBfcacheIdMap, createPendingNavigationCommit, createPendingNavigationCommitFromElements, isCacheRestorableAppPayloadMetadata, isCompleteAppPayloadMetadata, isHistoryStateBfcacheVersionCurrent, preserveBfcacheIdsForMergedElements, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveHistoryTraversalIntent, resolveInterceptionContextFromPreviousNextUrl, resolvePendingNavigationCommitDispositionDecision, resolveServerActionRequestState };
|
|
336
|
+
export { COMMITTED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, FRESH_APP_NAVIGATION_PAYLOAD_ORIGIN, VISITED_CACHE_APP_NAVIGATION_PAYLOAD_ORIGIN, createAppOwnedHistoryState, createBfcacheSegmentIdentityMap, createExternalHistoryStatePreservingMetadata, createHistoryStateWithNavigationMetadata, createHistoryStateWithPreviousNextUrl, createHistoryStateWithTreeSnapshotId, createInitialBfcacheIdMap, createNextBfcacheIdMap, createPendingNavigationCommit, createPendingNavigationCommitFromElements, isCacheRestorableAppPayloadMetadata, isCompleteAppPayloadMetadata, isExternalHistoryState, isHistoryStateBfcacheVersionCurrent, preserveBfcacheIdsForMergedElements, readHistoryStateActiveRoutePaths, readHistoryStateBfcacheIds, readHistoryStateBfcacheVersion, readHistoryStatePreviousNextUrl, readHistoryStateTraversalIndex, resolveActiveRoutePaths, resolveHistoryTraversalIntent, resolveInterceptionContextFromPreviousNextUrl, resolvePendingNavigationCommitDispositionDecision, resolveServerActionRequestState };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NavigationRuntimeSnapshot } from "../client/navigation-runtime.js";
|
|
2
1
|
import { RSC_FORM_STATE_GLOBAL } from "./app-browser-hydration.js";
|
|
3
2
|
import { RscEmbeddedChunk } from "./app-rsc-embedded-chunks.js";
|
|
4
3
|
import { ReactFormState } from "react-dom/client";
|
|
@@ -8,7 +7,6 @@ type VinextBrowserGlobals = {
|
|
|
8
7
|
__VINEXT_RSC_DONE__?: boolean;
|
|
9
8
|
[RSC_FORM_STATE_GLOBAL]?: ReactFormState;
|
|
10
9
|
__VINEXT_RSC_PARAMS__?: Record<string, string | string[]>;
|
|
11
|
-
__VINEXT_RSC_NAV__?: NavigationRuntimeSnapshot;
|
|
12
10
|
};
|
|
13
11
|
declare function getVinextBrowserGlobal(): typeof globalThis & VinextBrowserGlobals;
|
|
14
12
|
/**
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AppElements } from "./app-elements-wire.js";
|
|
2
|
+
import "./app-elements.js";
|
|
3
|
+
import { AppRouterState } from "./app-browser-state.js";
|
|
4
|
+
//#region src/server/app-browser-supplemental-refresh.d.ts
|
|
5
|
+
type SupplementalRefreshDegradedReason = "aborted" | "failed" | "timeout";
|
|
6
|
+
type SupplementalRefreshResult<T> = {
|
|
7
|
+
degraded: false;
|
|
8
|
+
value: Awaited<T>;
|
|
9
|
+
} | {
|
|
10
|
+
degraded: true;
|
|
11
|
+
reason: SupplementalRefreshDegradedReason;
|
|
12
|
+
value: Awaited<T>;
|
|
13
|
+
};
|
|
14
|
+
declare class SupplementalRefreshError extends Error {
|
|
15
|
+
readonly reason: SupplementalRefreshDegradedReason;
|
|
16
|
+
constructor(reason: SupplementalRefreshDegradedReason);
|
|
17
|
+
}
|
|
18
|
+
declare function requireCompleteSupplementalRefresh<T>(result: SupplementalRefreshResult<T>): Awaited<T>;
|
|
19
|
+
declare function resolveServerActionSupplementalRefresh<T>(result: SupplementalRefreshResult<T>, currentValue: Awaited<T>): {
|
|
20
|
+
retry: boolean;
|
|
21
|
+
value: Awaited<T>;
|
|
22
|
+
};
|
|
23
|
+
type SupplementalRefreshHandle = {
|
|
24
|
+
finish(): void;
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
};
|
|
27
|
+
declare function mergeRefreshedParallelSlot(currentElements: AppElements, refreshedElements: AppElements): AppElements;
|
|
28
|
+
declare function resolvePersistedSourcePageRefreshes(options: {
|
|
29
|
+
activeRoutePaths?: readonly string[];
|
|
30
|
+
basePath: string;
|
|
31
|
+
refreshUrl: URL;
|
|
32
|
+
state: Pick<AppRouterState, "previousNextUrl" | "slotBindings">;
|
|
33
|
+
}): string[];
|
|
34
|
+
declare function createSupplementalRefreshCoordinator(): {
|
|
35
|
+
abortAll(): void;
|
|
36
|
+
begin(options: {
|
|
37
|
+
activeNavigationId: number;
|
|
38
|
+
startedNavigationId: number;
|
|
39
|
+
}): SupplementalRefreshHandle;
|
|
40
|
+
};
|
|
41
|
+
declare function resolveSupplementalRefreshes<T>(options: {
|
|
42
|
+
merge: (current: Awaited<T>, supplemental: Awaited<T>) => Awaited<T>;
|
|
43
|
+
primary: Promise<T>;
|
|
44
|
+
signal: AbortSignal;
|
|
45
|
+
supplemental: ReadonlyArray<(signal: AbortSignal) => Promise<T>>;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
}): Promise<SupplementalRefreshResult<T>>;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { SupplementalRefreshDegradedReason, SupplementalRefreshError, SupplementalRefreshHandle, SupplementalRefreshResult, createSupplementalRefreshCoordinator, mergeRefreshedParallelSlot, requireCompleteSupplementalRefresh, resolvePersistedSourcePageRefreshes, resolveServerActionSupplementalRefresh, resolveSupplementalRefreshes };
|