vinext 0.0.41 → 0.0.43
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 +0 -1
- package/dist/build/client-build-config.d.ts +119 -0
- package/dist/build/client-build-config.js +149 -0
- package/dist/build/client-build-config.js.map +1 -0
- package/dist/build/layout-classification-types.d.ts +62 -0
- package/dist/build/layout-classification-types.js +1 -0
- package/dist/build/layout-classification.d.ts +60 -0
- package/dist/build/layout-classification.js +98 -0
- package/dist/build/layout-classification.js.map +1 -0
- package/dist/build/report.d.ts +15 -1
- package/dist/build/report.js +50 -1
- package/dist/build/report.js.map +1 -1
- package/dist/build/route-classification-manifest.d.ts +53 -0
- package/dist/build/route-classification-manifest.js +145 -0
- package/dist/build/route-classification-manifest.js.map +1 -0
- package/dist/build/run-prerender.js +1 -1
- package/dist/build/ssr-manifest.d.ts +19 -0
- package/dist/build/ssr-manifest.js +71 -0
- package/dist/build/ssr-manifest.js.map +1 -0
- package/dist/check.js +2 -2
- package/dist/check.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/entry.js +1 -1
- package/dist/config/config-matchers.js +1 -0
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/entries/app-rsc-entry.js +315 -101
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/index.d.ts +1 -169
- package/dist/index.js +112 -432
- package/dist/index.js.map +1 -1
- package/dist/plugins/fonts.d.ts +49 -1
- package/dist/plugins/fonts.js +96 -3
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/plugins/postcss.d.ts +27 -0
- package/dist/plugins/postcss.js +94 -0
- package/dist/plugins/postcss.js.map +1 -0
- package/dist/plugins/strip-server-exports.d.ts +14 -0
- package/dist/plugins/strip-server-exports.js +73 -0
- package/dist/plugins/strip-server-exports.js.map +1 -0
- package/dist/routing/app-router.d.ts +6 -4
- package/dist/routing/app-router.js +44 -25
- package/dist/routing/app-router.js.map +1 -1
- package/dist/server/app-browser-entry.js +307 -100
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-browser-error.d.ts +8 -0
- package/dist/server/app-browser-error.js +9 -0
- package/dist/server/app-browser-error.js.map +1 -0
- package/dist/server/app-browser-state.d.ts +93 -0
- package/dist/server/app-browser-state.js +132 -0
- package/dist/server/app-browser-state.js.map +1 -0
- package/dist/server/app-elements.d.ts +92 -0
- package/dist/server/app-elements.js +122 -0
- package/dist/server/app-elements.js.map +1 -0
- package/dist/server/app-page-boundary-render.d.ts +2 -1
- package/dist/server/app-page-boundary-render.js +40 -1
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +6 -3
- package/dist/server/app-page-cache.js +14 -8
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +36 -3
- package/dist/server/app-page-execution.js +50 -10
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-probe.d.ts +10 -4
- package/dist/server/app-page-probe.js +24 -15
- package/dist/server/app-page-probe.js.map +1 -1
- package/dist/server/app-page-render.d.ts +7 -4
- package/dist/server/app-page-render.js +13 -4
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-request.d.ts +52 -4
- package/dist/server/app-page-request.js +86 -16
- package/dist/server/app-page-request.js.map +1 -1
- package/dist/server/app-page-response.d.ts +1 -0
- package/dist/server/app-page-response.js +1 -0
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +22 -8
- package/dist/server/app-page-route-wiring.js +219 -83
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-render-dependency.d.ts +13 -0
- package/dist/server/app-render-dependency.js +35 -0
- package/dist/server/app-render-dependency.js.map +1 -0
- package/dist/server/app-route-handler-execution.d.ts +1 -0
- package/dist/server/app-route-handler-execution.js +1 -0
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-policy.js +5 -3
- package/dist/server/app-route-handler-policy.js.map +1 -1
- package/dist/server/app-route-handler-response.js +2 -0
- package/dist/server/app-route-handler-response.js.map +1 -1
- package/dist/server/app-route-handler-runtime.d.ts +1 -0
- package/dist/server/app-route-handler-runtime.js +26 -1
- package/dist/server/app-route-handler-runtime.js.map +1 -1
- package/dist/server/app-ssr-entry.js +6 -2
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/dev-server.js +2 -4
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/middleware.js +1 -5
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/prod-server.d.ts +3 -3
- package/dist/server/prod-server.js +1 -1
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +2 -1
- package/dist/server/request-pipeline.js +34 -5
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts +1 -0
- package/dist/shims/cache-runtime.js +0 -5
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +1 -0
- package/dist/shims/cache.js +1 -8
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-hook-error.d.ts +14 -0
- package/dist/shims/client-hook-error.js +19 -0
- package/dist/shims/client-hook-error.js.map +1 -0
- package/dist/shims/constants.d.ts +3 -3
- package/dist/shims/constants.js +3 -3
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/document.d.ts +6 -6
- package/dist/shims/error-boundary.d.ts +4 -4
- package/dist/shims/error-boundary.js +1 -1
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/form.d.ts +3 -3
- package/dist/shims/head-state.d.ts +1 -0
- package/dist/shims/head-state.js +0 -5
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/headers.d.ts +11 -0
- package/dist/shims/headers.js +13 -10
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-state.d.ts +1 -0
- package/dist/shims/i18n-state.js +0 -4
- package/dist/shims/i18n-state.js.map +1 -1
- package/dist/shims/internal/app-router-context.d.ts +6 -6
- package/dist/shims/internal/router-context.d.ts +2 -2
- package/dist/shims/layout-segment-context.d.ts +2 -2
- package/dist/shims/link.js +19 -11
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +3 -3
- package/dist/shims/navigation-state.d.ts +2 -0
- package/dist/shims/navigation-state.js +0 -13
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +56 -9
- package/dist/shims/navigation.js +112 -28
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/navigation.react-server.d.ts +14 -0
- package/dist/shims/navigation.react-server.js +29 -0
- package/dist/shims/navigation.react-server.js.map +1 -0
- package/dist/shims/request-context.d.ts +1 -0
- package/dist/shims/request-context.js +0 -9
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/request-state-types.d.ts +1 -1
- package/dist/shims/router-state.d.ts +1 -0
- package/dist/shims/router-state.js +0 -5
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/slot.d.ts +11 -7
- package/dist/shims/slot.js +28 -19
- package/dist/shims/slot.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +2 -0
- package/dist/shims/unified-request-context.js +0 -14
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/utils/mdx-scan.d.ts +10 -0
- package/dist/utils/mdx-scan.js +36 -0
- package/dist/utils/mdx-scan.js.map +1 -0
- package/dist/utils/public-routes.d.ts +5 -0
- package/dist/utils/public-routes.js +50 -0
- package/dist/utils/public-routes.js.map +1 -0
- package/package.json +3 -3
- package/dist/plugins/fix-use-server-closure-collision.d.ts +0 -29
- package/dist/plugins/fix-use-server-closure-collision.js +0 -204
- package/dist/plugins/fix-use-server-closure-collision.js.map +0 -1
package/dist/shims/navigation.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stripBasePath } from "../utils/base-path.js";
|
|
2
2
|
import { toBrowserNavigationHref, toSameOriginAppPath } from "./url-utils.js";
|
|
3
3
|
import { notifyAppRouterTransitionStart } from "../client/instrumentation-client-state.js";
|
|
4
|
+
import { createAppPayloadCacheKey } from "../server/app-elements.js";
|
|
4
5
|
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
5
6
|
import * as React$1 from "react";
|
|
6
7
|
//#region src/shims/navigation.ts
|
|
@@ -115,6 +116,14 @@ function toRscUrl(href) {
|
|
|
115
116
|
const query = qIdx === -1 ? "" : beforeHash.slice(qIdx);
|
|
116
117
|
return (pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname) + ".rsc" + query;
|
|
117
118
|
}
|
|
119
|
+
function getCurrentInterceptionContext() {
|
|
120
|
+
if (isServer) return null;
|
|
121
|
+
return stripBasePath(window.location.pathname, __basePath);
|
|
122
|
+
}
|
|
123
|
+
function getCurrentNextUrl() {
|
|
124
|
+
if (isServer) return "/";
|
|
125
|
+
return window.location.pathname + window.location.search;
|
|
126
|
+
}
|
|
118
127
|
/** Get or create the shared in-memory RSC prefetch cache on window. */
|
|
119
128
|
function getPrefetchCache() {
|
|
120
129
|
if (isServer) return /* @__PURE__ */ new Map();
|
|
@@ -123,7 +132,7 @@ function getPrefetchCache() {
|
|
|
123
132
|
}
|
|
124
133
|
/**
|
|
125
134
|
* Get or create the shared set of already-prefetched RSC URLs on window.
|
|
126
|
-
* Keyed by
|
|
135
|
+
* Keyed by interception-aware cache key so distinct source routes do not alias.
|
|
127
136
|
*/
|
|
128
137
|
function getPrefetchedUrls() {
|
|
129
138
|
if (isServer) return /* @__PURE__ */ new Set();
|
|
@@ -158,23 +167,27 @@ function evictPrefetchCacheIfNeeded() {
|
|
|
158
167
|
* (the caller falls back to a fresh fetch, which is acceptable).
|
|
159
168
|
*
|
|
160
169
|
* Prefer prefetchRscResponse() for new call-sites — it handles the full
|
|
161
|
-
* prefetch lifecycle including dedup
|
|
162
|
-
* backward compatibility and test
|
|
170
|
+
* prefetch lifecycle including dedup and explicit slot context.
|
|
171
|
+
* storePrefetchResponse() is kept for backward compatibility and test
|
|
172
|
+
* helpers. It is slot-unaware: the snapshot's mountedSlotsHeader comes
|
|
173
|
+
* from the response headers, not the caller, so consumePrefetchResponse
|
|
174
|
+
* may reject the entry if the caller's slot context differs.
|
|
163
175
|
*
|
|
164
176
|
* NB: Caller is responsible for managing getPrefetchedUrls() — this
|
|
165
177
|
* function only stores the response in the prefetch cache.
|
|
166
178
|
*/
|
|
167
|
-
function storePrefetchResponse(rscUrl, response) {
|
|
179
|
+
function storePrefetchResponse(rscUrl, response, interceptionContext = null) {
|
|
180
|
+
const cacheKey = createAppPayloadCacheKey(rscUrl, interceptionContext);
|
|
168
181
|
evictPrefetchCacheIfNeeded();
|
|
169
182
|
const entry = { timestamp: Date.now() };
|
|
170
183
|
entry.pending = snapshotRscResponse(response).then((snapshot) => {
|
|
171
184
|
entry.snapshot = snapshot;
|
|
172
185
|
}).catch(() => {
|
|
173
|
-
getPrefetchCache().delete(
|
|
186
|
+
getPrefetchCache().delete(cacheKey);
|
|
174
187
|
}).finally(() => {
|
|
175
188
|
entry.pending = void 0;
|
|
176
189
|
});
|
|
177
|
-
getPrefetchCache().set(
|
|
190
|
+
getPrefetchCache().set(cacheKey, entry);
|
|
178
191
|
}
|
|
179
192
|
/**
|
|
180
193
|
* Snapshot an RSC response to an ArrayBuffer for caching and replay.
|
|
@@ -184,6 +197,7 @@ async function snapshotRscResponse(response) {
|
|
|
184
197
|
return {
|
|
185
198
|
buffer: await response.arrayBuffer(),
|
|
186
199
|
contentType: response.headers.get("content-type") ?? "text/x-component",
|
|
200
|
+
mountedSlotsHeader: response.headers.get("X-Vinext-Mounted-Slots"),
|
|
187
201
|
paramsHeader: response.headers.get("X-Vinext-Params"),
|
|
188
202
|
url: response.url
|
|
189
203
|
};
|
|
@@ -205,6 +219,7 @@ async function snapshotRscResponse(response) {
|
|
|
205
219
|
*/
|
|
206
220
|
function restoreRscResponse(cached, copy = true) {
|
|
207
221
|
const headers = new Headers({ "content-type": cached.contentType });
|
|
222
|
+
if (cached.mountedSlotsHeader != null) headers.set("X-Vinext-Mounted-Slots", cached.mountedSlotsHeader);
|
|
208
223
|
if (cached.paramsHeader != null) headers.set("X-Vinext-Params", cached.paramsHeader);
|
|
209
224
|
return new Response(copy ? cached.buffer.slice(0) : cached.buffer, {
|
|
210
225
|
status: 200,
|
|
@@ -218,23 +233,27 @@ function restoreRscResponse(cached, copy = true) {
|
|
|
218
233
|
* Enforces a maximum cache size to prevent unbounded memory growth on
|
|
219
234
|
* link-heavy pages.
|
|
220
235
|
*/
|
|
221
|
-
function prefetchRscResponse(rscUrl, fetchPromise) {
|
|
236
|
+
function prefetchRscResponse(rscUrl, fetchPromise, interceptionContext = null, mountedSlotsHeader = null) {
|
|
237
|
+
const cacheKey = createAppPayloadCacheKey(rscUrl, interceptionContext);
|
|
222
238
|
const cache = getPrefetchCache();
|
|
223
239
|
const prefetched = getPrefetchedUrls();
|
|
224
240
|
const entry = { timestamp: Date.now() };
|
|
225
241
|
entry.pending = fetchPromise.then(async (response) => {
|
|
226
|
-
if (response.ok) entry.snapshot =
|
|
242
|
+
if (response.ok) entry.snapshot = {
|
|
243
|
+
...await snapshotRscResponse(response),
|
|
244
|
+
mountedSlotsHeader
|
|
245
|
+
};
|
|
227
246
|
else {
|
|
228
|
-
prefetched.delete(
|
|
229
|
-
cache.delete(
|
|
247
|
+
prefetched.delete(cacheKey);
|
|
248
|
+
cache.delete(cacheKey);
|
|
230
249
|
}
|
|
231
250
|
}).catch(() => {
|
|
232
|
-
prefetched.delete(
|
|
233
|
-
cache.delete(
|
|
251
|
+
prefetched.delete(cacheKey);
|
|
252
|
+
cache.delete(cacheKey);
|
|
234
253
|
}).finally(() => {
|
|
235
254
|
entry.pending = void 0;
|
|
236
255
|
});
|
|
237
|
-
cache.set(
|
|
256
|
+
cache.set(cacheKey, entry);
|
|
238
257
|
evictPrefetchCacheIfNeeded();
|
|
239
258
|
}
|
|
240
259
|
/**
|
|
@@ -242,20 +261,32 @@ function prefetchRscResponse(rscUrl, fetchPromise) {
|
|
|
242
261
|
* Only returns settled (non-pending) snapshots synchronously.
|
|
243
262
|
* Returns null if the entry is still in flight or doesn't exist.
|
|
244
263
|
*/
|
|
245
|
-
function consumePrefetchResponse(rscUrl) {
|
|
264
|
+
function consumePrefetchResponse(rscUrl, interceptionContext = null, mountedSlotsHeader = null) {
|
|
265
|
+
const cacheKey = createAppPayloadCacheKey(rscUrl, interceptionContext);
|
|
246
266
|
const cache = getPrefetchCache();
|
|
247
|
-
const entry = cache.get(
|
|
267
|
+
const entry = cache.get(cacheKey);
|
|
248
268
|
if (!entry) return null;
|
|
249
269
|
if (entry.pending) return null;
|
|
250
|
-
cache.delete(
|
|
251
|
-
getPrefetchedUrls().delete(
|
|
270
|
+
cache.delete(cacheKey);
|
|
271
|
+
getPrefetchedUrls().delete(cacheKey);
|
|
252
272
|
if (entry.snapshot) {
|
|
273
|
+
if ((entry.snapshot.mountedSlotsHeader ?? null) !== mountedSlotsHeader) return null;
|
|
253
274
|
if (Date.now() - entry.timestamp >= 3e4) return null;
|
|
254
275
|
return entry.snapshot;
|
|
255
276
|
}
|
|
256
277
|
return null;
|
|
257
278
|
}
|
|
258
279
|
const _CLIENT_NAV_STATE_KEY = Symbol.for("vinext.clientNavigationState");
|
|
280
|
+
const _MOUNTED_SLOTS_HEADER_KEY = Symbol.for("vinext.mountedSlotsHeader");
|
|
281
|
+
function setMountedSlotsHeader(header) {
|
|
282
|
+
if (isServer) return;
|
|
283
|
+
const globalState = window;
|
|
284
|
+
globalState[_MOUNTED_SLOTS_HEADER_KEY] = header;
|
|
285
|
+
}
|
|
286
|
+
function getMountedSlotsHeader() {
|
|
287
|
+
if (isServer) return null;
|
|
288
|
+
return window[_MOUNTED_SLOTS_HEADER_KEY] ?? null;
|
|
289
|
+
}
|
|
259
290
|
function getClientNavigationState() {
|
|
260
291
|
if (isServer) return null;
|
|
261
292
|
const globalState = window;
|
|
@@ -268,6 +299,8 @@ function getClientNavigationState() {
|
|
|
268
299
|
clientParamsJson: "{}",
|
|
269
300
|
pendingClientParams: null,
|
|
270
301
|
pendingClientParamsJson: null,
|
|
302
|
+
pendingPathname: null,
|
|
303
|
+
pendingPathnameNavId: null,
|
|
271
304
|
originalPushState: window.history.pushState.bind(window.history),
|
|
272
305
|
originalReplaceState: window.history.replaceState.bind(window.history),
|
|
273
306
|
patchInstalled: false,
|
|
@@ -413,6 +446,30 @@ function replaceClientParamsWithoutNotify(params) {
|
|
|
413
446
|
function getClientParams() {
|
|
414
447
|
return getClientNavigationState()?.clientParams ?? _fallbackClientParams;
|
|
415
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Set the pending pathname for client-side navigation.
|
|
451
|
+
* Strips the base path before storing. Associates the pathname with the given navId
|
|
452
|
+
* so only that navigation (or a newer one) can clear it.
|
|
453
|
+
*/
|
|
454
|
+
function setPendingPathname(pathname, navId) {
|
|
455
|
+
const state = getClientNavigationState();
|
|
456
|
+
if (!state) return;
|
|
457
|
+
state.pendingPathname = stripBasePath(pathname, __basePath);
|
|
458
|
+
state.pendingPathnameNavId = navId;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Clear the pending pathname, but only if the given navId matches the one
|
|
462
|
+
* that set it, or if pendingPathnameNavId is null (no active owner).
|
|
463
|
+
* This prevents superseded navigations from clearing state belonging to newer navigations.
|
|
464
|
+
*/
|
|
465
|
+
function clearPendingPathname(navId) {
|
|
466
|
+
const state = getClientNavigationState();
|
|
467
|
+
if (!state) return;
|
|
468
|
+
if (state.pendingPathnameNavId === null || state.pendingPathnameNavId === navId) {
|
|
469
|
+
state.pendingPathname = null;
|
|
470
|
+
state.pendingPathnameNavId = null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
416
473
|
function getClientParamsSnapshot() {
|
|
417
474
|
return getClientNavigationState()?.clientParams ?? _EMPTY_PARAMS;
|
|
418
475
|
}
|
|
@@ -500,7 +557,14 @@ function withSuppressedUrlNotifications(fn) {
|
|
|
500
557
|
state.suppressUrlNotifyCount -= 1;
|
|
501
558
|
}
|
|
502
559
|
}
|
|
503
|
-
|
|
560
|
+
/**
|
|
561
|
+
* Commit pending client navigation state to committed snapshots.
|
|
562
|
+
*
|
|
563
|
+
* navId is optional: callers that don't own pendingPathname (for example,
|
|
564
|
+
* superseded pre-paint cleanup) may pass undefined to flush snapshot/params
|
|
565
|
+
* state without clearing pendingPathname owned by the active navigation.
|
|
566
|
+
*/
|
|
567
|
+
function commitClientNavigationState(navId) {
|
|
504
568
|
if (isServer) return;
|
|
505
569
|
const state = getClientNavigationState();
|
|
506
570
|
if (!state) return;
|
|
@@ -512,6 +576,10 @@ function commitClientNavigationState() {
|
|
|
512
576
|
state.pendingClientParams = null;
|
|
513
577
|
state.pendingClientParamsJson = null;
|
|
514
578
|
}
|
|
579
|
+
if (state.pendingPathnameNavId === null || navId !== void 0 && state.pendingPathnameNavId === navId) {
|
|
580
|
+
state.pendingPathname = null;
|
|
581
|
+
state.pendingPathnameNavId = null;
|
|
582
|
+
}
|
|
515
583
|
const shouldNotify = urlChanged || state.hasPendingNavigationUpdate;
|
|
516
584
|
state.hasPendingNavigationUpdate = false;
|
|
517
585
|
if (shouldNotify) notifyNavigationListeners();
|
|
@@ -574,7 +642,7 @@ function restoreScrollPosition(state) {
|
|
|
574
642
|
/**
|
|
575
643
|
* Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.
|
|
576
644
|
*/
|
|
577
|
-
async function navigateClientSide(href, mode, scroll) {
|
|
645
|
+
async function navigateClientSide(href, mode, scroll, programmaticTransition = false) {
|
|
578
646
|
let normalizedHref = href;
|
|
579
647
|
if (isExternalUrl(href)) {
|
|
580
648
|
const localPath = toSameOriginAppPath(href, __basePath);
|
|
@@ -598,7 +666,7 @@ async function navigateClientSide(href, mode, scroll) {
|
|
|
598
666
|
}
|
|
599
667
|
const hashIdx = fullHref.indexOf("#");
|
|
600
668
|
const hash = hashIdx !== -1 ? fullHref.slice(hashIdx) : "";
|
|
601
|
-
if (typeof window.__VINEXT_RSC_NAVIGATE__ === "function") await window.__VINEXT_RSC_NAVIGATE__(fullHref, 0, "navigate", mode);
|
|
669
|
+
if (typeof window.__VINEXT_RSC_NAVIGATE__ === "function") await window.__VINEXT_RSC_NAVIGATE__(fullHref, 0, "navigate", mode, void 0, programmaticTransition);
|
|
602
670
|
else {
|
|
603
671
|
if (mode === "replace") replaceHistoryStateWithoutNotify(null, "", fullHref);
|
|
604
672
|
else pushHistoryStateWithoutNotify(null, "", fullHref);
|
|
@@ -610,11 +678,15 @@ async function navigateClientSide(href, mode, scroll) {
|
|
|
610
678
|
const _appRouter = {
|
|
611
679
|
push(href, options) {
|
|
612
680
|
if (isServer) return;
|
|
613
|
-
|
|
681
|
+
React$1.startTransition(() => {
|
|
682
|
+
navigateClientSide(href, "push", options?.scroll !== false, true);
|
|
683
|
+
});
|
|
614
684
|
},
|
|
615
685
|
replace(href, options) {
|
|
616
686
|
if (isServer) return;
|
|
617
|
-
|
|
687
|
+
React$1.startTransition(() => {
|
|
688
|
+
navigateClientSide(href, "replace", options?.scroll !== false, true);
|
|
689
|
+
});
|
|
618
690
|
},
|
|
619
691
|
back() {
|
|
620
692
|
if (isServer) return;
|
|
@@ -626,19 +698,31 @@ const _appRouter = {
|
|
|
626
698
|
},
|
|
627
699
|
refresh() {
|
|
628
700
|
if (isServer) return;
|
|
629
|
-
|
|
701
|
+
const rscNavigate = window.__VINEXT_RSC_NAVIGATE__;
|
|
702
|
+
if (typeof rscNavigate === "function") {
|
|
703
|
+
const navigate = () => {
|
|
704
|
+
rscNavigate(window.location.href, 0, "refresh", void 0, void 0, true);
|
|
705
|
+
};
|
|
706
|
+
React$1.startTransition(navigate);
|
|
707
|
+
}
|
|
630
708
|
},
|
|
631
709
|
prefetch(href) {
|
|
632
710
|
if (isServer) return;
|
|
633
711
|
const rscUrl = toRscUrl(toBrowserNavigationHref(href, window.location.href, __basePath));
|
|
712
|
+
const interceptionContext = getCurrentInterceptionContext();
|
|
713
|
+
const cacheKey = createAppPayloadCacheKey(rscUrl, interceptionContext);
|
|
634
714
|
const prefetched = getPrefetchedUrls();
|
|
635
|
-
if (prefetched.has(
|
|
636
|
-
prefetched.add(
|
|
715
|
+
if (prefetched.has(cacheKey)) return;
|
|
716
|
+
prefetched.add(cacheKey);
|
|
717
|
+
const mountedSlotsHeader = getMountedSlotsHeader();
|
|
718
|
+
const headers = new Headers({ Accept: "text/x-component" });
|
|
719
|
+
if (mountedSlotsHeader) headers.set("X-Vinext-Mounted-Slots", mountedSlotsHeader);
|
|
720
|
+
if (interceptionContext !== null) headers.set("X-Vinext-Interception-Context", interceptionContext);
|
|
637
721
|
prefetchRscResponse(rscUrl, fetch(rscUrl, {
|
|
638
|
-
headers
|
|
722
|
+
headers,
|
|
639
723
|
credentials: "include",
|
|
640
724
|
priority: "low"
|
|
641
|
-
}));
|
|
725
|
+
}), interceptionContext, mountedSlotsHeader);
|
|
642
726
|
}
|
|
643
727
|
};
|
|
644
728
|
/**
|
|
@@ -838,6 +922,6 @@ if (!isServer) {
|
|
|
838
922
|
}
|
|
839
923
|
}
|
|
840
924
|
//#endregion
|
|
841
|
-
export { GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, __basePath, _registerStateAccessors, activateNavigationSnapshot, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, createClientNavigationRenderSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getClientNavigationRenderContext, getClientParams, getLayoutSegmentContext, getNavigationContext, getPrefetchCache, getPrefetchedUrls, isHTTPAccessFallbackError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, restoreRscResponse, setClientParams, setNavigationContext, snapshotRscResponse, storePrefetchResponse, toRscUrl, unauthorized, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
925
|
+
export { GLOBAL_ACCESSORS_KEY, HTTP_ERROR_FALLBACK_ERROR_CODE, MAX_PREFETCH_CACHE_SIZE, PREFETCH_CACHE_TTL, ReadonlyURLSearchParams, RedirectType, ServerInsertedHTMLContext, __basePath, _registerStateAccessors, activateNavigationSnapshot, clearPendingPathname, clearServerInsertedHTML, commitClientNavigationState, consumePrefetchResponse, createClientNavigationRenderSnapshot, flushServerInsertedHTML, forbidden, getAccessFallbackHTTPStatus, getClientNavigationRenderContext, getClientNavigationState, getClientParams, getCurrentInterceptionContext, getCurrentNextUrl, getLayoutSegmentContext, getMountedSlotsHeader, getNavigationContext, getPrefetchCache, getPrefetchedUrls, isHTTPAccessFallbackError, navigateClientSide, notFound, permanentRedirect, prefetchRscResponse, pushHistoryStateWithoutNotify, redirect, replaceClientParamsWithoutNotify, replaceHistoryStateWithoutNotify, restoreRscResponse, setClientParams, setMountedSlotsHeader, setNavigationContext, setPendingPathname, snapshotRscResponse, storePrefetchResponse, toRscUrl, unauthorized, useParams, usePathname, useRouter, useSearchParams, useSelectedLayoutSegment, useSelectedLayoutSegments, useServerInsertedHTML };
|
|
842
926
|
|
|
843
927
|
//# sourceMappingURL=navigation.js.map
|