vinext 0.0.26 → 0.0.28
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 +89 -85
- package/dist/build/static-export.d.ts +1 -1
- package/dist/build/static-export.d.ts.map +1 -1
- package/dist/build/static-export.js +5 -9
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +152 -48
- package/dist/check.js.map +1 -1
- package/dist/cli.js +10 -11
- package/dist/cli.js.map +1 -1
- package/dist/cloudflare/kv-cache-handler.d.ts +43 -1
- package/dist/cloudflare/kv-cache-handler.d.ts.map +1 -1
- package/dist/cloudflare/kv-cache-handler.js +135 -44
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.d.ts.map +1 -1
- package/dist/cloudflare/tpr.js +15 -4
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +28 -0
- package/dist/config/config-matchers.d.ts.map +1 -1
- package/dist/config/config-matchers.js +353 -79
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts.map +1 -1
- package/dist/config/dotenv.js +1 -6
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +7 -0
- package/dist/config/next-config.d.ts.map +1 -1
- package/dist/config/next-config.js +44 -19
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts +1 -1
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +81 -48
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +3 -1
- package/dist/entries/app-rsc-entry.d.ts.map +1 -1
- package/dist/entries/app-rsc-entry.js +584 -113
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts.map +1 -1
- package/dist/entries/pages-client-entry.js +5 -3
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.d.ts.map +1 -1
- package/dist/entries/pages-server-entry.js +100 -32
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +24 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +327 -154
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +6 -5
- package/dist/init.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +19 -0
- package/dist/plugins/client-reference-dedup.d.ts.map +1 -0
- package/dist/plugins/client-reference-dedup.js +96 -0
- package/dist/plugins/client-reference-dedup.js.map +1 -0
- package/dist/routing/app-router.d.ts +2 -0
- package/dist/routing/app-router.d.ts.map +1 -1
- package/dist/routing/app-router.js +70 -107
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts.map +1 -1
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +3 -1
- package/dist/routing/pages-router.d.ts.map +1 -1
- package/dist/routing/pages-router.js +33 -18
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/route-validation.d.ts +8 -0
- package/dist/routing/route-validation.d.ts.map +1 -0
- package/dist/routing/route-validation.js +124 -0
- package/dist/routing/route-validation.js.map +1 -0
- package/dist/routing/utils.d.ts.map +1 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.d.ts.map +1 -1
- package/dist/server/api-handler.js +31 -9
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-router-entry.d.ts +3 -2
- package/dist/server/app-router-entry.d.ts.map +1 -1
- package/dist/server/app-router-entry.js +8 -4
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/dev-module-runner.d.ts.map +1 -1
- package/dist/server/dev-module-runner.js +1 -1
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/dev-origin-check.d.ts.map +1 -1
- package/dist/server/dev-origin-check.js.map +1 -1
- package/dist/server/dev-server.d.ts.map +1 -1
- package/dist/server/dev-server.js +39 -21
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/image-optimization.d.ts.map +1 -1
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/instrumentation.js +1 -1
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +5 -1
- package/dist/server/isr-cache.d.ts.map +1 -1
- package/dist/server/isr-cache.js +13 -3
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-routes.d.ts +8 -2
- package/dist/server/metadata-routes.d.ts.map +1 -1
- package/dist/server/metadata-routes.js +78 -45
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-codegen.d.ts +1 -1
- package/dist/server/middleware-codegen.d.ts.map +1 -1
- package/dist/server/middleware-codegen.js +177 -22
- package/dist/server/middleware-codegen.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +9 -0
- package/dist/server/middleware-request-headers.d.ts.map +1 -0
- package/dist/server/middleware-request-headers.js +77 -0
- package/dist/server/middleware-request-headers.js.map +1 -0
- package/dist/server/middleware.d.ts +9 -8
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +112 -32
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/prod-server.d.ts +1 -1
- package/dist/server/prod-server.d.ts.map +1 -1
- package/dist/server/prod-server.js +127 -82
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +2 -1
- package/dist/server/request-pipeline.d.ts.map +1 -1
- package/dist/server/request-pipeline.js +5 -7
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/shims/cache-runtime.d.ts.map +1 -1
- package/dist/shims/cache-runtime.js +21 -16
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +2 -0
- package/dist/shims/cache.d.ts.map +1 -1
- package/dist/shims/cache.js +38 -25
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/constants.d.ts.map +1 -1
- package/dist/shims/constants.js +1 -6
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/dynamic.d.ts.map +1 -1
- package/dist/shims/dynamic.js +1 -1
- package/dist/shims/dynamic.js.map +1 -1
- package/dist/shims/error-boundary.d.ts.map +1 -1
- package/dist/shims/error-boundary.js +2 -3
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts.map +1 -1
- package/dist/shims/error.js +1 -3
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts.map +1 -1
- package/dist/shims/fetch-cache.js +57 -30
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts.map +1 -1
- package/dist/shims/font-google-base.js +16 -4
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-google.d.ts +1 -1
- package/dist/shims/font-google.d.ts.map +1 -1
- package/dist/shims/font-google.generated.d.ts.map +1 -1
- package/dist/shims/font-google.generated.js +412 -206
- package/dist/shims/font-google.generated.js.map +1 -1
- package/dist/shims/font-google.js +1 -1
- package/dist/shims/font-google.js.map +1 -1
- package/dist/shims/font-local.d.ts.map +1 -1
- package/dist/shims/font-local.js +13 -3
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.d.ts.map +1 -1
- package/dist/shims/form.js +105 -10
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head.d.ts.map +1 -1
- package/dist/shims/head.js +10 -8
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +34 -8
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/headers.js +268 -53
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts.map +1 -1
- package/dist/shims/image.js +35 -8
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/parse-cookie-header.d.ts +12 -0
- package/dist/shims/internal/parse-cookie-header.d.ts.map +1 -0
- package/dist/shims/internal/parse-cookie-header.js +32 -0
- package/dist/shims/internal/parse-cookie-header.js.map +1 -0
- package/dist/shims/legacy-image.d.ts.map +1 -1
- package/dist/shims/legacy-image.js +1 -1
- package/dist/shims/legacy-image.js.map +1 -1
- package/dist/shims/link.d.ts +2 -1
- package/dist/shims/link.d.ts.map +1 -1
- package/dist/shims/link.js +37 -17
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +12 -2
- package/dist/shims/metadata.d.ts.map +1 -1
- package/dist/shims/metadata.js +10 -8
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.d.ts.map +1 -1
- package/dist/shims/navigation-state.js +3 -2
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +3 -7
- package/dist/shims/navigation.d.ts.map +1 -1
- package/dist/shims/navigation.js +46 -29
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/readonly-url-search-params.d.ts +11 -0
- package/dist/shims/readonly-url-search-params.d.ts.map +1 -0
- package/dist/shims/readonly-url-search-params.js +24 -0
- package/dist/shims/readonly-url-search-params.js.map +1 -0
- package/dist/shims/request-context.d.ts +50 -0
- package/dist/shims/request-context.d.ts.map +1 -0
- package/dist/shims/request-context.js +59 -0
- package/dist/shims/request-context.js.map +1 -0
- package/dist/shims/router-state.d.ts.map +1 -1
- package/dist/shims/router-state.js +2 -1
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +4 -3
- package/dist/shims/router.d.ts.map +1 -1
- package/dist/shims/router.js +59 -53
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts.map +1 -1
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.d.ts +14 -1
- package/dist/shims/server.d.ts.map +1 -1
- package/dist/shims/server.js +107 -47
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/url-utils.d.ts.map +1 -1
- package/dist/shims/url-utils.js +1 -3
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/utils/base-path.d.ts +17 -0
- package/dist/utils/base-path.d.ts.map +1 -0
- package/dist/utils/base-path.js +25 -0
- package/dist/utils/base-path.js.map +1 -0
- package/dist/utils/manifest-paths.d.ts +4 -0
- package/dist/utils/manifest-paths.d.ts.map +1 -0
- package/dist/utils/manifest-paths.js +20 -0
- package/dist/utils/manifest-paths.js.map +1 -0
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +2 -4
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/query.d.ts +9 -0
- package/dist/utils/query.d.ts.map +1 -1
- package/dist/utils/query.js +59 -7
- package/dist/utils/query.js.map +1 -1
- package/package.json +47 -33
package/dist/shims/navigation.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
// bindings are just `undefined` on the namespace object and we can guard at runtime.
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { toSameOriginPath } from "./url-utils.js";
|
|
14
|
+
import { stripBasePath } from "../utils/base-path.js";
|
|
15
|
+
import { ReadonlyURLSearchParams } from "./readonly-url-search-params.js";
|
|
14
16
|
// ─── Layout segment context ───────────────────────────────────────────────────
|
|
15
17
|
// Stores the child segments below the current layout. Each layout wraps its
|
|
16
18
|
// children with a provider whose value is the remaining route tree segments
|
|
@@ -62,6 +64,8 @@ function useChildSegments() {
|
|
|
62
64
|
return [];
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
const _READONLY_SEARCH_PARAMS = Symbol("vinext.navigation.readonlySearchParams");
|
|
68
|
+
const _READONLY_SEARCH_PARAMS_SOURCE = Symbol("vinext.navigation.readonlySearchParamsSource");
|
|
65
69
|
// ---------------------------------------------------------------------------
|
|
66
70
|
// Server-side navigation state lives in a separate server-only module
|
|
67
71
|
// (navigation-state.ts) that uses AsyncLocalStorage for request isolation.
|
|
@@ -74,9 +78,13 @@ let _serverContext = null;
|
|
|
74
78
|
let _serverInsertedHTMLCallbacks = [];
|
|
75
79
|
// These are overridden by navigation-state.ts on the server to use ALS.
|
|
76
80
|
let _getServerContext = () => _serverContext;
|
|
77
|
-
let _setServerContext = (ctx) => {
|
|
81
|
+
let _setServerContext = (ctx) => {
|
|
82
|
+
_serverContext = ctx;
|
|
83
|
+
};
|
|
78
84
|
let _getInsertedHTMLCallbacks = () => _serverInsertedHTMLCallbacks;
|
|
79
|
-
let _clearInsertedHTMLCallbacks = () => {
|
|
85
|
+
let _clearInsertedHTMLCallbacks = () => {
|
|
86
|
+
_serverInsertedHTMLCallbacks = [];
|
|
87
|
+
};
|
|
80
88
|
/**
|
|
81
89
|
* Register ALS-backed state accessors. Called by navigation-state.ts on import.
|
|
82
90
|
* @internal
|
|
@@ -108,14 +116,6 @@ export function setNavigationContext(ctx) {
|
|
|
108
116
|
const isServer = typeof window === "undefined";
|
|
109
117
|
/** basePath from next.config.js, injected by the plugin at build time */
|
|
110
118
|
const __basePath = process.env.__NEXT_ROUTER_BASEPATH ?? "";
|
|
111
|
-
/** Strip basePath prefix from a browser pathname */
|
|
112
|
-
function stripBasePath(p) {
|
|
113
|
-
if (!__basePath)
|
|
114
|
-
return p;
|
|
115
|
-
if (p.startsWith(__basePath))
|
|
116
|
-
return p.slice(__basePath.length) || "/";
|
|
117
|
-
return p;
|
|
118
|
-
}
|
|
119
119
|
/** Prepend basePath to a path for browser URLs / fetches */
|
|
120
120
|
function withBasePath(p) {
|
|
121
121
|
if (!__basePath)
|
|
@@ -140,9 +140,7 @@ export function toRscUrl(href) {
|
|
|
140
140
|
const pathname = qIdx === -1 ? beforeHash : beforeHash.slice(0, qIdx);
|
|
141
141
|
const query = qIdx === -1 ? "" : beforeHash.slice(qIdx);
|
|
142
142
|
// Strip trailing slash (but preserve "/" root) for consistent cache keys
|
|
143
|
-
const normalizedPath = pathname.length > 1 && pathname.endsWith("/")
|
|
144
|
-
? pathname.slice(0, -1)
|
|
145
|
-
: pathname;
|
|
143
|
+
const normalizedPath = pathname.length > 1 && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
|
|
146
144
|
return normalizedPath + ".rsc" + query;
|
|
147
145
|
}
|
|
148
146
|
/** Get or create the shared in-memory RSC prefetch cache on window. */
|
|
@@ -190,11 +188,11 @@ function notifyListeners() {
|
|
|
190
188
|
// useSyncExternalStore compares snapshots with Object.is — avoid creating
|
|
191
189
|
// new instances on every render (infinite re-renders).
|
|
192
190
|
let _cachedSearch = !isServer ? window.location.search : "";
|
|
193
|
-
let
|
|
194
|
-
let
|
|
195
|
-
let _cachedPathname = !isServer ? stripBasePath(window.location.pathname) : "/";
|
|
191
|
+
let _cachedReadonlySearchParams = new ReadonlyURLSearchParams(_cachedSearch);
|
|
192
|
+
let _cachedEmptyServerSearchParams = null;
|
|
193
|
+
let _cachedPathname = !isServer ? stripBasePath(window.location.pathname, __basePath) : "/";
|
|
196
194
|
function getPathnameSnapshot() {
|
|
197
|
-
const current = stripBasePath(window.location.pathname);
|
|
195
|
+
const current = stripBasePath(window.location.pathname, __basePath);
|
|
198
196
|
if (current !== _cachedPathname) {
|
|
199
197
|
_cachedPathname = current;
|
|
200
198
|
}
|
|
@@ -204,18 +202,24 @@ function getSearchParamsSnapshot() {
|
|
|
204
202
|
const current = window.location.search;
|
|
205
203
|
if (current !== _cachedSearch) {
|
|
206
204
|
_cachedSearch = current;
|
|
207
|
-
|
|
205
|
+
_cachedReadonlySearchParams = new ReadonlyURLSearchParams(current);
|
|
208
206
|
}
|
|
209
|
-
return
|
|
207
|
+
return _cachedReadonlySearchParams;
|
|
210
208
|
}
|
|
211
209
|
function getServerSearchParamsSnapshot() {
|
|
212
210
|
const ctx = _getServerContext();
|
|
213
|
-
if (ctx
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
if (ctx != null) {
|
|
212
|
+
const searchParams = ctx.searchParams;
|
|
213
|
+
if (ctx[_READONLY_SEARCH_PARAMS_SOURCE] !== searchParams) {
|
|
214
|
+
ctx[_READONLY_SEARCH_PARAMS_SOURCE] = searchParams;
|
|
215
|
+
ctx[_READONLY_SEARCH_PARAMS] = new ReadonlyURLSearchParams(searchParams);
|
|
216
|
+
}
|
|
217
|
+
return ctx[_READONLY_SEARCH_PARAMS];
|
|
218
|
+
}
|
|
219
|
+
if (_cachedEmptyServerSearchParams === null) {
|
|
220
|
+
_cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();
|
|
217
221
|
}
|
|
218
|
-
return
|
|
222
|
+
return _cachedEmptyServerSearchParams;
|
|
219
223
|
}
|
|
220
224
|
// Track client-side params (set during RSC hydration/navigation)
|
|
221
225
|
// We cache the params object for referential stability — only create a new
|
|
@@ -247,7 +251,12 @@ export function usePathname() {
|
|
|
247
251
|
return _getServerContext()?.pathname ?? "/";
|
|
248
252
|
}
|
|
249
253
|
// Client-side: use the hook system for reactivity
|
|
250
|
-
return React.useSyncExternalStore((cb) => {
|
|
254
|
+
return React.useSyncExternalStore((cb) => {
|
|
255
|
+
_listeners.add(cb);
|
|
256
|
+
return () => {
|
|
257
|
+
_listeners.delete(cb);
|
|
258
|
+
};
|
|
259
|
+
}, getPathnameSnapshot, () => _getServerContext()?.pathname ?? "/");
|
|
251
260
|
}
|
|
252
261
|
/**
|
|
253
262
|
* Returns the current search params as a read-only URLSearchParams.
|
|
@@ -256,9 +265,14 @@ export function useSearchParams() {
|
|
|
256
265
|
if (isServer) {
|
|
257
266
|
// During SSR of "use client" components, the navigation context may not be set.
|
|
258
267
|
// Return a safe fallback — the client will hydrate with the real value.
|
|
259
|
-
return
|
|
268
|
+
return getServerSearchParamsSnapshot();
|
|
260
269
|
}
|
|
261
|
-
return React.useSyncExternalStore((cb) => {
|
|
270
|
+
return React.useSyncExternalStore((cb) => {
|
|
271
|
+
_listeners.add(cb);
|
|
272
|
+
return () => {
|
|
273
|
+
_listeners.delete(cb);
|
|
274
|
+
};
|
|
275
|
+
}, getSearchParamsSnapshot, getServerSearchParamsSnapshot);
|
|
262
276
|
}
|
|
263
277
|
/**
|
|
264
278
|
* Returns the dynamic params for the current route.
|
|
@@ -483,7 +497,8 @@ const _appRouter = {
|
|
|
483
497
|
headers: { Accept: "text/x-component" },
|
|
484
498
|
credentials: "include",
|
|
485
499
|
priority: "low",
|
|
486
|
-
})
|
|
500
|
+
})
|
|
501
|
+
.then((response) => {
|
|
487
502
|
if (response.ok) {
|
|
488
503
|
storePrefetchResponse(rscUrl, response);
|
|
489
504
|
}
|
|
@@ -491,7 +506,8 @@ const _appRouter = {
|
|
|
491
506
|
// Non-ok response: allow retry on next prefetch() call
|
|
492
507
|
prefetched.delete(rscUrl);
|
|
493
508
|
}
|
|
494
|
-
})
|
|
509
|
+
})
|
|
510
|
+
.catch(() => {
|
|
495
511
|
// Network error: allow retry on next prefetch() call
|
|
496
512
|
prefetched.delete(rscUrl);
|
|
497
513
|
});
|
|
@@ -541,6 +557,7 @@ export function useSelectedLayoutSegments(
|
|
|
541
557
|
_parallelRoutesKey) {
|
|
542
558
|
return useChildSegments();
|
|
543
559
|
}
|
|
560
|
+
export { ReadonlyURLSearchParams };
|
|
544
561
|
/**
|
|
545
562
|
* useServerInsertedHTML — inject HTML during SSR from client components.
|
|
546
563
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/shims/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AACjF,iFAAiF;AACjF,+EAA+E;AAC/E,qFAAqF;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,iFAAiF;AACjF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,uEAAuE;AACvE,8EAA8E;AAE9E,IAAI,iBAAiB,GAAmC,IAAI,CAAC;AAE7D,kFAAkF;AAClF,6EAA6E;AAC7E,iEAAiE;AACjE,yEAAyE;AACzE,0DAA0D;AAC1D,EAAE;AACF,0DAA0D;AAC1D,8CAA8C;AAC9C,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,4EAA4E;AAC5E,kEAAkE;AAElE,MAAM,CAAC,MAAM,yBAAyB,GAGpC,OAAO,KAAK,CAAC,aAAa,KAAK,UAAU;IACvC,CAAC,CAAC,KAAK,CAAC,aAAa,CAA6C,IAAI,CAAC;IACv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KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,8EAA8E;IAC9E,kEAAkE;IAClE,EAAE;IACF,uEAAuE;IACvE,yEAAyE;IACzE,sEAAsE;IACtE,mEAAmE;IACnE,oDAAoD;IACpD,EAAE;IACF,2EAA2E;IAC3E,uEAAuE;IACvE,cAAc;IACd,8EAA8E;IAC9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE9E,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,gBAAgB,CAClD,IAAa,EACb,MAAc,EACd,GAAyB;QAEzB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACrC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,SAAS,mBAAmB,CACxD,IAAa,EACb,MAAc,EACd,GAAyB;QAEzB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACxC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * next/navigation shim\n *\n * App Router navigation hooks. These work on both server (RSC) and client.\n * Server-side: reads from a request context set by the RSC handler.\n * Client-side: reads from browser Location API and provides navigation.\n */\n\n// Use namespace import for RSC safety: the react-server condition doesn't export\n// createContext/useContext/useSyncExternalStore as named exports, and strict ESM\n// would throw at link time for missing bindings. With `import * as React`, the\n// bindings are just `undefined` on the namespace object and we can guard at runtime.\nimport * as React from \"react\";\nimport { toSameOriginPath } from \"./url-utils.js\";\n\n// ─── Layout segment context ───────────────────────────────────────────────────\n// Stores the child segments below the current layout. Each layout wraps its\n// children with a provider whose value is the remaining route tree segments\n// (including route groups, with dynamic params resolved to actual values).\n// Created lazily because `React.createContext` is NOT available in the\n// react-server condition of React. In the RSC environment, this remains null.\n\nlet _LayoutSegmentCtx: React.Context<string[]> | null = null;\n\n// ─── ServerInsertedHTML context ────────────────────────────────────────────────\n// Used by CSS-in-JS libraries (Apollo Client, styled-components, emotion) to\n// register HTML injection callbacks during SSR via useContext().\n// The SSR entry wraps the rendered tree with a Provider whose value is a\n// callback registration function (useServerInsertedHTML).\n//\n// In Next.js, ServerInsertedHTMLContext holds a function:\n// (callback: () => React.ReactNode) => void\n// Libraries call useContext(ServerInsertedHTMLContext) to get this function,\n// then call it to register callbacks that inject HTML during SSR.\n//\n// Created eagerly at module load time. In the RSC environment (react-server\n// condition), createContext isn't available so this will be null.\n\nexport const ServerInsertedHTMLContext: React.Context<\n ((callback: () => unknown) => void) | null\n> | null =\n typeof React.createContext === \"function\"\n ? React.createContext<((callback: () => unknown) => void) | null>(null)\n : null;\n\n/**\n * Get or create the layout segment context.\n * Returns null in the RSC environment (createContext unavailable).\n */\nexport function getLayoutSegmentContext(): React.Context<string[]> | null {\n if (_LayoutSegmentCtx === null && typeof React.createContext === \"function\") {\n _LayoutSegmentCtx = React.createContext<string[]>([]);\n }\n return _LayoutSegmentCtx;\n}\n\n/**\n * Read the child segments below the current layout from context.\n * Returns [] if no context is available (RSC environment, outside React tree).\n */\nfunction useChildSegments(): string[] {\n const ctx = getLayoutSegmentContext();\n if (!ctx) return [];\n // useContext is safe here because if createContext exists, useContext does too.\n // This branch is only taken in SSR/Browser, never in RSC.\n // Try/catch for unit tests that call this hook outside a React render tree.\n try {\n return React.useContext(ctx);\n } catch {\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Server-side request context (set by the RSC entry before rendering)\n// ---------------------------------------------------------------------------\n\nexport interface NavigationContext {\n pathname: string;\n searchParams: URLSearchParams;\n params: Record<string, string | string[]>;\n}\n\n// ---------------------------------------------------------------------------\n// Server-side navigation state lives in a separate server-only module\n// (navigation-state.ts) that uses AsyncLocalStorage for request isolation.\n// This module is bundled for the browser, so it can't import node:async_hooks.\n//\n// On the server: state functions are set by navigation-state.ts at import time.\n// On the client: _serverContext falls back to null (hooks use window instead).\n// ---------------------------------------------------------------------------\n\nlet _serverContext: NavigationContext | null = null;\nlet _serverInsertedHTMLCallbacks: Array<() => unknown> = [];\n\n// These are overridden by navigation-state.ts on the server to use ALS.\nlet _getServerContext = (): NavigationContext | null => _serverContext;\nlet _setServerContext = (ctx: NavigationContext | null): void => { _serverContext = ctx; };\nlet _getInsertedHTMLCallbacks = (): Array<() => unknown> => _serverInsertedHTMLCallbacks;\nlet _clearInsertedHTMLCallbacks = (): void => { _serverInsertedHTMLCallbacks = []; };\n\n/**\n * Register ALS-backed state accessors. Called by navigation-state.ts on import.\n * @internal\n */\nexport function _registerStateAccessors(accessors: {\n getServerContext: () => NavigationContext | null;\n setServerContext: (ctx: NavigationContext | null) => void;\n getInsertedHTMLCallbacks: () => Array<() => unknown>;\n clearInsertedHTMLCallbacks: () => void;\n}): void {\n _getServerContext = accessors.getServerContext;\n _setServerContext = accessors.setServerContext;\n _getInsertedHTMLCallbacks = accessors.getInsertedHTMLCallbacks;\n _clearInsertedHTMLCallbacks = accessors.clearInsertedHTMLCallbacks;\n}\n\n/**\n * Get the navigation context for the current SSR/RSC render.\n * Reads from AsyncLocalStorage when available (concurrent-safe),\n * otherwise falls back to module-level state.\n */\nexport function getNavigationContext(): NavigationContext | null {\n return _getServerContext();\n}\n\n/**\n * Set the navigation context for the current SSR/RSC render.\n * Called by the framework entry before rendering each request.\n */\nexport function setNavigationContext(ctx: NavigationContext | null): void {\n _setServerContext(ctx);\n}\n\n// ---------------------------------------------------------------------------\n// Client-side state\n// ---------------------------------------------------------------------------\n\nconst isServer = typeof window === \"undefined\";\n\n/** basePath from next.config.js, injected by the plugin at build time */\nconst __basePath: string = process.env.__NEXT_ROUTER_BASEPATH ?? \"\";\n\n/** Strip basePath prefix from a browser pathname */\nfunction stripBasePath(p: string): string {\n if (!__basePath) return p;\n if (p.startsWith(__basePath)) return p.slice(__basePath.length) || \"/\";\n return p;\n}\n\n/** Prepend basePath to a path for browser URLs / fetches */\nfunction withBasePath(p: string): string {\n if (!__basePath) return p;\n return __basePath + p;\n}\n\n// ---------------------------------------------------------------------------\n// RSC prefetch cache utilities (shared between link.tsx and browser entry)\n// ---------------------------------------------------------------------------\n\n/** Maximum number of entries in the RSC prefetch cache. */\nconst MAX_PREFETCH_CACHE_SIZE = 50;\n\n/** TTL for prefetch cache entries in ms (matches Next.js static prefetch TTL). */\nexport const PREFETCH_CACHE_TTL = 30_000;\n\nexport interface PrefetchCacheEntry {\n response: Response;\n timestamp: number;\n}\n\n/**\n * Convert a pathname (with optional query/hash) to its .rsc URL.\n * Strips trailing slashes before appending `.rsc` so that cache keys\n * are consistent regardless of the `trailingSlash` config setting.\n */\nexport function toRscUrl(href: string): string {\n const [beforeHash] = href.split(\"#\");\n const qIdx = beforeHash.indexOf(\"?\");\n const pathname = qIdx === -1 ? beforeHash : beforeHash.slice(0, qIdx);\n const query = qIdx === -1 ? \"\" : beforeHash.slice(qIdx);\n // Strip trailing slash (but preserve \"/\" root) for consistent cache keys\n const normalizedPath = pathname.length > 1 && pathname.endsWith(\"/\")\n ? pathname.slice(0, -1)\n : pathname;\n return normalizedPath + \".rsc\" + query;\n}\n\n/** Get or create the shared in-memory RSC prefetch cache on window. */\nexport function getPrefetchCache(): Map<string, PrefetchCacheEntry> {\n if (isServer) return new Map();\n if (!window.__VINEXT_RSC_PREFETCH_CACHE__) {\n window.__VINEXT_RSC_PREFETCH_CACHE__ = new Map<string, PrefetchCacheEntry>();\n }\n return window.__VINEXT_RSC_PREFETCH_CACHE__;\n}\n\n/**\n * Get or create the shared set of already-prefetched RSC URLs on window.\n * Keyed by rscUrl so that the browser entry can clear entries when consumed.\n */\nexport function getPrefetchedUrls(): Set<string> {\n if (isServer) return new Set();\n if (!window.__VINEXT_RSC_PREFETCHED_URLS__) {\n window.__VINEXT_RSC_PREFETCHED_URLS__ = new Set<string>();\n }\n return window.__VINEXT_RSC_PREFETCHED_URLS__;\n}\n\n/**\n * Store a prefetched RSC response in the cache.\n * Enforces a maximum cache size to prevent unbounded memory growth on\n * link-heavy pages.\n */\nexport function storePrefetchResponse(rscUrl: string, response: Response): void {\n const cache = getPrefetchCache();\n // Evict oldest entry if at capacity (Map iterates in insertion order)\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) cache.delete(oldest);\n }\n cache.set(rscUrl, { response, timestamp: Date.now() });\n}\n\n// Client navigation listeners\ntype NavigationListener = () => void;\nconst _listeners: Set<NavigationListener> = new Set();\n\nfunction notifyListeners(): void {\n for (const fn of _listeners) fn();\n}\n\n// Cached URLSearchParams, pathname, etc. for referential stability\n// useSyncExternalStore compares snapshots with Object.is — avoid creating\n// new instances on every render (infinite re-renders).\nlet _cachedSearch = !isServer ? window.location.search : \"\";\nlet _cachedSearchParams: URLSearchParams = new URLSearchParams(_cachedSearch);\nlet _cachedServerSearchParams: URLSearchParams | null = null;\nlet _cachedPathname = !isServer ? stripBasePath(window.location.pathname) : \"/\";\n\nfunction getPathnameSnapshot(): string {\n const current = stripBasePath(window.location.pathname);\n if (current !== _cachedPathname) {\n _cachedPathname = current;\n }\n return _cachedPathname;\n}\n\nfunction getSearchParamsSnapshot(): URLSearchParams {\n const current = window.location.search;\n if (current !== _cachedSearch) {\n _cachedSearch = current;\n _cachedSearchParams = new URLSearchParams(current);\n }\n return _cachedSearchParams;\n}\n\nfunction getServerSearchParamsSnapshot(): URLSearchParams {\n const ctx = _getServerContext();\n if (ctx?.searchParams != null) return ctx.searchParams;\n if (_cachedServerSearchParams === null) {\n _cachedServerSearchParams = new URLSearchParams();\n }\n return _cachedServerSearchParams;\n}\n\n// Track client-side params (set during RSC hydration/navigation)\n// We cache the params object for referential stability — only create a new\n// object when the params actually change (shallow key/value comparison).\nlet _clientParams: Record<string, string | string[]> = {};\nlet _clientParamsJson = \"{}\";\n\nexport function setClientParams(params: Record<string, string | string[]>): void {\n const json = JSON.stringify(params);\n if (json !== _clientParamsJson) {\n _clientParams = params;\n _clientParamsJson = json;\n }\n}\n\n/** Get the current client params (for testing referential stability). */\nexport function getClientParams(): Record<string, string | string[]> {\n return _clientParams;\n}\n\n// ---------------------------------------------------------------------------\n// Hooks\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the current pathname.\n * Server: from request context. Client: from window.location.\n */\nexport function usePathname(): string {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return _getServerContext()?.pathname ?? \"/\";\n }\n // Client-side: use the hook system for reactivity\n return React.useSyncExternalStore(\n (cb: () => void) => { _listeners.add(cb); return () => { _listeners.delete(cb); }; },\n getPathnameSnapshot,\n () => _getServerContext()?.pathname ?? \"/\",\n );\n}\n\n/**\n * Returns the current search params as a read-only URLSearchParams.\n */\nexport function useSearchParams(): URLSearchParams {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return _getServerContext()?.searchParams ?? new URLSearchParams();\n }\n return React.useSyncExternalStore(\n (cb: () => void) => { _listeners.add(cb); return () => { _listeners.delete(cb); }; },\n getSearchParamsSnapshot,\n getServerSearchParamsSnapshot,\n );\n}\n\n/**\n * Returns the dynamic params for the current route.\n */\nexport function useParams<\n T extends Record<string, string | string[]> = Record<string, string | string[]>,\n>(): T {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n return (_getServerContext()?.params ?? {}) as T;\n }\n return _clientParams as T;\n}\n\n/**\n * Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).\n */\nfunction isExternalUrl(href: string): boolean {\n return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith(\"//\");\n}\n\n/**\n * Check if a href is only a hash change relative to the current URL.\n */\nfunction isHashOnlyChange(href: string): boolean {\n if (typeof window === \"undefined\") return false;\n if (href.startsWith(\"#\")) return true;\n try {\n const current = new URL(window.location.href);\n const next = new URL(href, window.location.href);\n return current.pathname === next.pathname && current.search === next.search && next.hash !== \"\";\n } catch {\n return false;\n }\n}\n\n/**\n * Scroll to a hash target element, or to the top if no hash.\n */\nfunction scrollToHash(hash: string): void {\n if (!hash || hash === \"#\") {\n window.scrollTo(0, 0);\n return;\n }\n const id = hash.slice(1);\n const element = document.getElementById(id);\n if (element) {\n element.scrollIntoView({ behavior: \"auto\" });\n }\n}\n\n/**\n * Reference to the native history.replaceState before patching.\n * Used internally to avoid triggering the interception for internal operations\n * (e.g. saving scroll position shouldn't cause re-renders).\n * Captured before the history method patching at the bottom of this module.\n */\nconst _nativeReplaceState = !isServer\n ? window.history.replaceState.bind(window.history)\n : (null as unknown as typeof window.history.replaceState);\n\n/**\n * Save the current scroll position into the current history state.\n * Called before every navigation to enable scroll restoration on back/forward.\n *\n * Uses _nativeReplaceState to avoid triggering the history.replaceState\n * interception (which would cause spurious re-renders from notifyListeners).\n */\nfunction saveScrollPosition(): void {\n const state = window.history.state ?? {};\n _nativeReplaceState.call(\n window.history,\n { ...state, __vinext_scrollX: window.scrollX, __vinext_scrollY: window.scrollY },\n \"\",\n );\n}\n\n/**\n * Restore scroll position from a history state object (used on popstate).\n *\n * When an RSC navigation is in flight (back/forward triggers both this\n * handler and the browser entry's popstate handler which calls\n * __VINEXT_RSC_NAVIGATE__), we must wait for the new content to render\n * before scrolling. Otherwise the user sees old content flash at the\n * restored scroll position.\n *\n * This handler fires before the browser entry's popstate handler (because\n * navigation.ts is loaded before hydration completes), so we defer via a\n * microtask to give the browser entry handler a chance to set\n * __VINEXT_RSC_PENDING__ first.\n */\nfunction restoreScrollPosition(state: unknown): void {\n if (state && typeof state === \"object\" && \"__vinext_scrollY\" in state) {\n const { __vinext_scrollX: x, __vinext_scrollY: y } = state as {\n __vinext_scrollX: number;\n __vinext_scrollY: number;\n };\n\n // Defer to allow other popstate listeners (browser entry) to run first\n // and set __VINEXT_RSC_PENDING__. Promise.resolve() schedules a microtask\n // that runs after all synchronous event listeners have completed.\n void Promise.resolve().then(() => {\n const pending: Promise<void> | null = window.__VINEXT_RSC_PENDING__ ?? null;\n\n if (pending) {\n // Wait for the RSC navigation to finish rendering, then scroll.\n void pending.then(() => {\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n });\n } else {\n // No RSC navigation in flight (Pages Router or already settled).\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n }\n });\n }\n}\n\n/**\n * Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.\n */\nasync function navigateImpl(\n href: string,\n mode: \"push\" | \"replace\",\n scroll: boolean,\n): Promise<void> {\n // Normalize same-origin absolute URLs to local paths for SPA navigation\n let normalizedHref = href;\n if (isExternalUrl(href)) {\n const localPath = toSameOriginPath(href);\n if (localPath == null) {\n // Truly external: use full page navigation\n if (mode === \"replace\") {\n window.location.replace(href);\n } else {\n window.location.assign(href);\n }\n return;\n }\n normalizedHref = localPath;\n }\n\n const fullHref = withBasePath(normalizedHref);\n\n // Save scroll position before navigating (for back/forward restoration)\n if (mode === \"push\") {\n saveScrollPosition();\n }\n\n // Hash-only change: update URL and scroll to target, skip RSC fetch\n if (isHashOnlyChange(fullHref)) {\n const hash = fullHref.includes(\"#\") ? fullHref.slice(fullHref.indexOf(\"#\")) : \"\";\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n if (scroll) {\n scrollToHash(hash);\n }\n return;\n }\n\n // Extract hash for post-navigation scrolling\n const hashIdx = fullHref.indexOf(\"#\");\n const hash = hashIdx !== -1 ? fullHref.slice(hashIdx) : \"\";\n\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n\n // Trigger RSC re-fetch if available, and wait for the new content to render\n // before scrolling. This prevents the old page from visibly jumping to the\n // top before the new content paints.\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n await window.__VINEXT_RSC_NAVIGATE__(fullHref);\n }\n\n if (scroll) {\n if (hash) {\n scrollToHash(hash);\n } else {\n window.scrollTo(0, 0);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// App Router router singleton\n//\n// All methods close over module-level state (navigateImpl, withBasePath, etc.)\n// and carry no per-render data, so the object can be created once and reused.\n// Next.js returns the same router reference on every call to useRouter(), which\n// matters for components that rely on referential equality (e.g. useMemo /\n// useEffect dependency arrays, React.memo bailouts).\n// ---------------------------------------------------------------------------\n\nconst _appRouter = {\n push(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"push\", options?.scroll !== false);\n },\n replace(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"replace\", options?.scroll !== false);\n },\n back(): void {\n if (isServer) return;\n window.history.back();\n },\n forward(): void {\n if (isServer) return;\n window.history.forward();\n },\n refresh(): void {\n if (isServer) return;\n // Re-fetch the current page's RSC stream\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n window.__VINEXT_RSC_NAVIGATE__(window.location.href);\n }\n },\n prefetch(href: string): void {\n if (isServer) return;\n // Prefetch the RSC payload for the target route and store in cache\n const fullHref = withBasePath(href);\n const rscUrl = toRscUrl(fullHref);\n const prefetched = getPrefetchedUrls();\n if (prefetched.has(rscUrl)) return;\n prefetched.add(rscUrl);\n fetch(rscUrl, {\n headers: { Accept: \"text/x-component\" },\n credentials: \"include\",\n priority: \"low\" as RequestInit[\"priority\"],\n }).then((response) => {\n if (response.ok) {\n storePrefetchResponse(rscUrl, response);\n } else {\n // Non-ok response: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n }\n }).catch(() => {\n // Network error: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n });\n },\n};\n\n/**\n * App Router's useRouter — returns push/replace/back/forward/refresh.\n * Different from Pages Router's useRouter (next/router).\n *\n * Returns a stable singleton: the same object reference on every call,\n * matching Next.js behavior so components using referential equality\n * (e.g. useMemo / useEffect deps, React.memo) don't re-render unnecessarily.\n */\nexport function useRouter() {\n return _appRouter;\n}\n\n/**\n * Returns the active child segment one level below the layout where it's called.\n *\n * Returns the first segment from the route tree below this layout, including\n * route groups (e.g., \"(marketing)\") and resolved dynamic params. Returns null\n * if at the leaf (no child segments).\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegment(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string | null {\n const segments = useSelectedLayoutSegments(_parallelRoutesKey);\n return segments.length > 0 ? segments[0] : null;\n}\n\n/**\n * Returns all active segments below the layout where it's called.\n *\n * Each layout in the App Router tree wraps its children with a\n * LayoutSegmentProvider whose value is the remaining route tree segments\n * (including route groups, with dynamic params resolved to actual values\n * and catch-all segments joined with \"/\"). This hook reads those segments\n * directly from context.\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegments(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string[] {\n return useChildSegments();\n}\n\n/**\n * ReadonlyURLSearchParams — type alias matching Next.js.\n * In Next.js this prevents mutation, but since URLSearchParams is the underlying\n * type in our implementation, we export it as-is for type compatibility.\n */\nexport type ReadonlyURLSearchParams = URLSearchParams;\n\n/**\n * useServerInsertedHTML — inject HTML during SSR from client components.\n *\n * Used by CSS-in-JS libraries (styled-components, emotion, StyleX) to inject\n * <style> tags during SSR so styles appear in the initial HTML (no FOUC).\n *\n * The callback is called once after each SSR render pass. The returned JSX/HTML\n * is serialized and injected into the HTML stream.\n *\n * Usage (in a \"use client\" component wrapping children):\n * useServerInsertedHTML(() => {\n * const styles = sheet.getStyleElement();\n * sheet.instance.clearTag();\n * return <>{styles}</>;\n * });\n */\n\nexport function useServerInsertedHTML(callback: () => unknown): void {\n if (typeof document !== \"undefined\") {\n // Client-side: no-op (styles are already in the DOM)\n return;\n }\n _getInsertedHTMLCallbacks().push(callback);\n}\n\n/**\n * Flush all collected useServerInsertedHTML callbacks.\n * Returns an array of results (React elements or strings).\n * Clears the callback list so the next render starts fresh.\n *\n * Called by the SSR entry after renderToReadableStream completes.\n */\nexport function flushServerInsertedHTML(): unknown[] {\n const callbacks = _getInsertedHTMLCallbacks();\n const results: unknown[] = [];\n for (const cb of callbacks) {\n try {\n const result = cb();\n if (result != null) results.push(result);\n } catch {\n // Ignore errors from individual callbacks\n }\n }\n callbacks.length = 0;\n return results;\n}\n\n/**\n * Clear all collected useServerInsertedHTML callbacks without flushing.\n * Used for cleanup between requests.\n */\nexport function clearServerInsertedHTML(): void {\n _clearInsertedHTMLCallbacks();\n}\n\n// ---------------------------------------------------------------------------\n// Non-hook utilities (can be called from Server Components)\n// ---------------------------------------------------------------------------\n\n/**\n * HTTP Access Fallback error code — shared prefix for notFound/forbidden/unauthorized.\n * Matches Next.js 16's unified error handling approach.\n */\nexport const HTTP_ERROR_FALLBACK_ERROR_CODE = \"NEXT_HTTP_ERROR_FALLBACK\";\n\n/**\n * Check if an error is an HTTP Access Fallback error (notFound, forbidden, unauthorized).\n */\nexport function isHTTPAccessFallbackError(error: unknown): boolean {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n return (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)\n );\n }\n return false;\n}\n\n/**\n * Extract the HTTP status code from an HTTP Access Fallback error.\n * Returns 404 for legacy NEXT_NOT_FOUND errors.\n */\nexport function getAccessFallbackHTTPStatus(error: unknown): number {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (digest === \"NEXT_NOT_FOUND\") return 404;\n if (digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)) {\n return parseInt(digest.split(\";\")[1], 10);\n }\n }\n return 404;\n}\n\n/**\n * Enum matching Next.js RedirectType for type-safe redirect calls.\n */\nexport enum RedirectType {\n push = \"push\",\n replace = \"replace\",\n}\n\n/**\n * Throw a redirect. Caught by the framework to send a redirect response.\n */\nexport function redirect(url: string, type?: \"replace\" | \"push\" | RedirectType): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;${type ?? \"replace\"};${encodeURIComponent(url)}`;\n throw error;\n}\n\n/**\n * Trigger a permanent redirect (308).\n */\nexport function permanentRedirect(url: string): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;replace;${encodeURIComponent(url)};308`;\n throw error;\n}\n\n/**\n * Trigger a not-found response (404). Caught by the framework.\n */\nexport function notFound(): never {\n const error = new Error(\"NEXT_NOT_FOUND\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};404`;\n throw error;\n}\n\n/**\n * Trigger a forbidden response (403). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function forbidden(): never {\n const error = new Error(\"NEXT_FORBIDDEN\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};403`;\n throw error;\n}\n\n/**\n * Trigger an unauthorized response (401). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function unauthorized(): never {\n const error = new Error(\"NEXT_UNAUTHORIZED\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};401`;\n throw error;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n// React hooks are imported at the top level via ESM.\n\n// Listen for popstate on the client\nif (!isServer) {\n window.addEventListener(\"popstate\", (event) => {\n notifyListeners();\n // Restore scroll position for back/forward navigation\n restoreScrollPosition(event.state);\n });\n\n // ---------------------------------------------------------------------------\n // history.pushState / replaceState interception (shallow routing)\n //\n // Next.js intercepts these native methods so that when user code calls\n // `window.history.pushState(null, '', '/new-path?filter=abc')` directly,\n // React hooks like usePathname() and useSearchParams() re-render with\n // the new URL. This is the foundation for shallow routing patterns\n // (filter UIs, tabs, URL search param state, etc.).\n //\n // We wrap the original methods, call through to the native implementation,\n // then notify our listener system so useSyncExternalStore picks up the\n // URL change.\n // ---------------------------------------------------------------------------\n const originalPushState = window.history.pushState.bind(window.history);\n const originalReplaceState = window.history.replaceState.bind(window.history);\n\n window.history.pushState = function patchedPushState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalPushState(data, unused, url);\n notifyListeners();\n };\n\n window.history.replaceState = function patchedReplaceState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalReplaceState(data, unused, url);\n notifyListeners();\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/shims/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AACjF,iFAAiF;AACjF,+EAA+E;AAC/E,qFAAqF;AACrF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,iFAAiF;AACjF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,uEAAuE;AACvE,8EAA8E;AAE9E,IAAI,iBAAiB,GAAmC,IAAI,CAAC;AAE7D,kFAAkF;AAClF,6EAA6E;AAC7E,iEAAiE;AACjE,yEAAyE;AACzE,0DAA0D;AAC1D,EAAE;AACF,0DAA0D;AAC1D,8CAA8C;AAC9C,6EAA6E;AAC7E,kEAAkE;AAClE,EAAE;AACF,4EAA4E;AAC5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C,MAAM,GAAG,GAAG,8BAA8B,MAAM,CAAC;IAChE,MAAM,KAAK,CAAC;AACd,CAAC;AAED,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,qDAAqD;AAErD,oCAAoC;AACpC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACd,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5C,eAAe,EAAE,CAAC;QAClB,sDAAsD;QACtD,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,8EAA8E;IAC9E,kEAAkE;IAClE,EAAE;IACF,uEAAuE;IACvE,yEAAyE;IACzE,sEAAsE;IACtE,mEAAmE;IACnE,oDAAoD;IACpD,EAAE;IACF,2EAA2E;IAC3E,uEAAuE;IACvE,cAAc;IACd,8EAA8E;IAC9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE9E,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,gBAAgB,CAClD,IAAa,EACb,MAAc,EACd,GAAyB;QAEzB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACrC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,YAAY,GAAG,SAAS,mBAAmB,CACxD,IAAa,EACb,MAAc,EACd,GAAyB;QAEzB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACxC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * next/navigation shim\n *\n * App Router navigation hooks. These work on both server (RSC) and client.\n * Server-side: reads from a request context set by the RSC handler.\n * Client-side: reads from browser Location API and provides navigation.\n */\n\n// Use namespace import for RSC safety: the react-server condition doesn't export\n// createContext/useContext/useSyncExternalStore as named exports, and strict ESM\n// would throw at link time for missing bindings. With `import * as React`, the\n// bindings are just `undefined` on the namespace object and we can guard at runtime.\nimport * as React from \"react\";\nimport { toSameOriginPath } from \"./url-utils.js\";\nimport { stripBasePath } from \"../utils/base-path.js\";\nimport { ReadonlyURLSearchParams } from \"./readonly-url-search-params.js\";\n\n// ─── Layout segment context ───────────────────────────────────────────────────\n// Stores the child segments below the current layout. Each layout wraps its\n// children with a provider whose value is the remaining route tree segments\n// (including route groups, with dynamic params resolved to actual values).\n// Created lazily because `React.createContext` is NOT available in the\n// react-server condition of React. In the RSC environment, this remains null.\n\nlet _LayoutSegmentCtx: React.Context<string[]> | null = null;\n\n// ─── ServerInsertedHTML context ────────────────────────────────────────────────\n// Used by CSS-in-JS libraries (Apollo Client, styled-components, emotion) to\n// register HTML injection callbacks during SSR via useContext().\n// The SSR entry wraps the rendered tree with a Provider whose value is a\n// callback registration function (useServerInsertedHTML).\n//\n// In Next.js, ServerInsertedHTMLContext holds a function:\n// (callback: () => React.ReactNode) => void\n// Libraries call useContext(ServerInsertedHTMLContext) to get this function,\n// then call it to register callbacks that inject HTML during SSR.\n//\n// Created eagerly at module load time. In the RSC environment (react-server\n// condition), createContext isn't available so this will be null.\n\nexport const ServerInsertedHTMLContext: React.Context<\n ((callback: () => unknown) => void) | null\n> | null =\n typeof React.createContext === \"function\"\n ? React.createContext<((callback: () => unknown) => void) | null>(null)\n : null;\n\n/**\n * Get or create the layout segment context.\n * Returns null in the RSC environment (createContext unavailable).\n */\nexport function getLayoutSegmentContext(): React.Context<string[]> | null {\n if (_LayoutSegmentCtx === null && typeof React.createContext === \"function\") {\n _LayoutSegmentCtx = React.createContext<string[]>([]);\n }\n return _LayoutSegmentCtx;\n}\n\n/**\n * Read the child segments below the current layout from context.\n * Returns [] if no context is available (RSC environment, outside React tree).\n */\nfunction useChildSegments(): string[] {\n const ctx = getLayoutSegmentContext();\n if (!ctx) return [];\n // useContext is safe here because if createContext exists, useContext does too.\n // This branch is only taken in SSR/Browser, never in RSC.\n // Try/catch for unit tests that call this hook outside a React render tree.\n try {\n return React.useContext(ctx);\n } catch {\n return [];\n }\n}\n\n// ---------------------------------------------------------------------------\n// Server-side request context (set by the RSC entry before rendering)\n// ---------------------------------------------------------------------------\n\nexport interface NavigationContext {\n pathname: string;\n searchParams: URLSearchParams;\n params: Record<string, string | string[]>;\n}\n\nconst _READONLY_SEARCH_PARAMS = Symbol(\"vinext.navigation.readonlySearchParams\");\nconst _READONLY_SEARCH_PARAMS_SOURCE = Symbol(\"vinext.navigation.readonlySearchParamsSource\");\n\ntype NavigationContextWithReadonlyCache = NavigationContext & {\n [_READONLY_SEARCH_PARAMS]?: ReadonlyURLSearchParams;\n [_READONLY_SEARCH_PARAMS_SOURCE]?: URLSearchParams;\n};\n\n// ---------------------------------------------------------------------------\n// Server-side navigation state lives in a separate server-only module\n// (navigation-state.ts) that uses AsyncLocalStorage for request isolation.\n// This module is bundled for the browser, so it can't import node:async_hooks.\n//\n// On the server: state functions are set by navigation-state.ts at import time.\n// On the client: _serverContext falls back to null (hooks use window instead).\n// ---------------------------------------------------------------------------\n\nlet _serverContext: NavigationContext | null = null;\nlet _serverInsertedHTMLCallbacks: Array<() => unknown> = [];\n\n// These are overridden by navigation-state.ts on the server to use ALS.\nlet _getServerContext = (): NavigationContext | null => _serverContext;\nlet _setServerContext = (ctx: NavigationContext | null): void => {\n _serverContext = ctx;\n};\nlet _getInsertedHTMLCallbacks = (): Array<() => unknown> => _serverInsertedHTMLCallbacks;\nlet _clearInsertedHTMLCallbacks = (): void => {\n _serverInsertedHTMLCallbacks = [];\n};\n\n/**\n * Register ALS-backed state accessors. Called by navigation-state.ts on import.\n * @internal\n */\nexport function _registerStateAccessors(accessors: {\n getServerContext: () => NavigationContext | null;\n setServerContext: (ctx: NavigationContext | null) => void;\n getInsertedHTMLCallbacks: () => Array<() => unknown>;\n clearInsertedHTMLCallbacks: () => void;\n}): void {\n _getServerContext = accessors.getServerContext;\n _setServerContext = accessors.setServerContext;\n _getInsertedHTMLCallbacks = accessors.getInsertedHTMLCallbacks;\n _clearInsertedHTMLCallbacks = accessors.clearInsertedHTMLCallbacks;\n}\n\n/**\n * Get the navigation context for the current SSR/RSC render.\n * Reads from AsyncLocalStorage when available (concurrent-safe),\n * otherwise falls back to module-level state.\n */\nexport function getNavigationContext(): NavigationContext | null {\n return _getServerContext();\n}\n\n/**\n * Set the navigation context for the current SSR/RSC render.\n * Called by the framework entry before rendering each request.\n */\nexport function setNavigationContext(ctx: NavigationContext | null): void {\n _setServerContext(ctx);\n}\n\n// ---------------------------------------------------------------------------\n// Client-side state\n// ---------------------------------------------------------------------------\n\nconst isServer = typeof window === \"undefined\";\n\n/** basePath from next.config.js, injected by the plugin at build time */\nconst __basePath: string = process.env.__NEXT_ROUTER_BASEPATH ?? \"\";\n\n/** Prepend basePath to a path for browser URLs / fetches */\nfunction withBasePath(p: string): string {\n if (!__basePath) return p;\n return __basePath + p;\n}\n\n// ---------------------------------------------------------------------------\n// RSC prefetch cache utilities (shared between link.tsx and browser entry)\n// ---------------------------------------------------------------------------\n\n/** Maximum number of entries in the RSC prefetch cache. */\nconst MAX_PREFETCH_CACHE_SIZE = 50;\n\n/** TTL for prefetch cache entries in ms (matches Next.js static prefetch TTL). */\nexport const PREFETCH_CACHE_TTL = 30_000;\n\nexport interface PrefetchCacheEntry {\n response: Response;\n timestamp: number;\n}\n\n/**\n * Convert a pathname (with optional query/hash) to its .rsc URL.\n * Strips trailing slashes before appending `.rsc` so that cache keys\n * are consistent regardless of the `trailingSlash` config setting.\n */\nexport function toRscUrl(href: string): string {\n const [beforeHash] = href.split(\"#\");\n const qIdx = beforeHash.indexOf(\"?\");\n const pathname = qIdx === -1 ? beforeHash : beforeHash.slice(0, qIdx);\n const query = qIdx === -1 ? \"\" : beforeHash.slice(qIdx);\n // Strip trailing slash (but preserve \"/\" root) for consistent cache keys\n const normalizedPath =\n pathname.length > 1 && pathname.endsWith(\"/\") ? pathname.slice(0, -1) : pathname;\n return normalizedPath + \".rsc\" + query;\n}\n\n/** Get or create the shared in-memory RSC prefetch cache on window. */\nexport function getPrefetchCache(): Map<string, PrefetchCacheEntry> {\n if (isServer) return new Map();\n if (!window.__VINEXT_RSC_PREFETCH_CACHE__) {\n window.__VINEXT_RSC_PREFETCH_CACHE__ = new Map<string, PrefetchCacheEntry>();\n }\n return window.__VINEXT_RSC_PREFETCH_CACHE__;\n}\n\n/**\n * Get or create the shared set of already-prefetched RSC URLs on window.\n * Keyed by rscUrl so that the browser entry can clear entries when consumed.\n */\nexport function getPrefetchedUrls(): Set<string> {\n if (isServer) return new Set();\n if (!window.__VINEXT_RSC_PREFETCHED_URLS__) {\n window.__VINEXT_RSC_PREFETCHED_URLS__ = new Set<string>();\n }\n return window.__VINEXT_RSC_PREFETCHED_URLS__;\n}\n\n/**\n * Store a prefetched RSC response in the cache.\n * Enforces a maximum cache size to prevent unbounded memory growth on\n * link-heavy pages.\n */\nexport function storePrefetchResponse(rscUrl: string, response: Response): void {\n const cache = getPrefetchCache();\n // Evict oldest entry if at capacity (Map iterates in insertion order)\n if (cache.size >= MAX_PREFETCH_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) cache.delete(oldest);\n }\n cache.set(rscUrl, { response, timestamp: Date.now() });\n}\n\n// Client navigation listeners\ntype NavigationListener = () => void;\nconst _listeners: Set<NavigationListener> = new Set();\n\nfunction notifyListeners(): void {\n for (const fn of _listeners) fn();\n}\n\n// Cached URLSearchParams, pathname, etc. for referential stability\n// useSyncExternalStore compares snapshots with Object.is — avoid creating\n// new instances on every render (infinite re-renders).\nlet _cachedSearch = !isServer ? window.location.search : \"\";\nlet _cachedReadonlySearchParams = new ReadonlyURLSearchParams(_cachedSearch);\nlet _cachedEmptyServerSearchParams: ReadonlyURLSearchParams | null = null;\nlet _cachedPathname = !isServer ? stripBasePath(window.location.pathname, __basePath) : \"/\";\n\nfunction getPathnameSnapshot(): string {\n const current = stripBasePath(window.location.pathname, __basePath);\n if (current !== _cachedPathname) {\n _cachedPathname = current;\n }\n return _cachedPathname;\n}\n\nfunction getSearchParamsSnapshot(): ReadonlyURLSearchParams {\n const current = window.location.search;\n if (current !== _cachedSearch) {\n _cachedSearch = current;\n _cachedReadonlySearchParams = new ReadonlyURLSearchParams(current);\n }\n return _cachedReadonlySearchParams;\n}\n\nfunction getServerSearchParamsSnapshot(): ReadonlyURLSearchParams {\n const ctx = _getServerContext() as NavigationContextWithReadonlyCache | null;\n if (ctx != null) {\n const searchParams = ctx.searchParams;\n if (ctx[_READONLY_SEARCH_PARAMS_SOURCE] !== searchParams) {\n ctx[_READONLY_SEARCH_PARAMS_SOURCE] = searchParams;\n ctx[_READONLY_SEARCH_PARAMS] = new ReadonlyURLSearchParams(searchParams);\n }\n return ctx[_READONLY_SEARCH_PARAMS]!;\n }\n if (_cachedEmptyServerSearchParams === null) {\n _cachedEmptyServerSearchParams = new ReadonlyURLSearchParams();\n }\n return _cachedEmptyServerSearchParams;\n}\n\n// Track client-side params (set during RSC hydration/navigation)\n// We cache the params object for referential stability — only create a new\n// object when the params actually change (shallow key/value comparison).\nlet _clientParams: Record<string, string | string[]> = {};\nlet _clientParamsJson = \"{}\";\n\nexport function setClientParams(params: Record<string, string | string[]>): void {\n const json = JSON.stringify(params);\n if (json !== _clientParamsJson) {\n _clientParams = params;\n _clientParamsJson = json;\n }\n}\n\n/** Get the current client params (for testing referential stability). */\nexport function getClientParams(): Record<string, string | string[]> {\n return _clientParams;\n}\n\n// ---------------------------------------------------------------------------\n// Hooks\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the current pathname.\n * Server: from request context. Client: from window.location.\n */\nexport function usePathname(): string {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return _getServerContext()?.pathname ?? \"/\";\n }\n // Client-side: use the hook system for reactivity\n return React.useSyncExternalStore(\n (cb: () => void) => {\n _listeners.add(cb);\n return () => {\n _listeners.delete(cb);\n };\n },\n getPathnameSnapshot,\n () => _getServerContext()?.pathname ?? \"/\",\n );\n}\n\n/**\n * Returns the current search params as a read-only URLSearchParams.\n */\nexport function useSearchParams(): ReadonlyURLSearchParams {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n // Return a safe fallback — the client will hydrate with the real value.\n return getServerSearchParamsSnapshot();\n }\n return React.useSyncExternalStore(\n (cb: () => void) => {\n _listeners.add(cb);\n return () => {\n _listeners.delete(cb);\n };\n },\n getSearchParamsSnapshot,\n getServerSearchParamsSnapshot,\n );\n}\n\n/**\n * Returns the dynamic params for the current route.\n */\nexport function useParams<\n T extends Record<string, string | string[]> = Record<string, string | string[]>,\n>(): T {\n if (isServer) {\n // During SSR of \"use client\" components, the navigation context may not be set.\n return (_getServerContext()?.params ?? {}) as T;\n }\n return _clientParams as T;\n}\n\n/**\n * Check if a href is an external URL (any URL scheme per RFC 3986, or protocol-relative).\n */\nfunction isExternalUrl(href: string): boolean {\n return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith(\"//\");\n}\n\n/**\n * Check if a href is only a hash change relative to the current URL.\n */\nfunction isHashOnlyChange(href: string): boolean {\n if (typeof window === \"undefined\") return false;\n if (href.startsWith(\"#\")) return true;\n try {\n const current = new URL(window.location.href);\n const next = new URL(href, window.location.href);\n return current.pathname === next.pathname && current.search === next.search && next.hash !== \"\";\n } catch {\n return false;\n }\n}\n\n/**\n * Scroll to a hash target element, or to the top if no hash.\n */\nfunction scrollToHash(hash: string): void {\n if (!hash || hash === \"#\") {\n window.scrollTo(0, 0);\n return;\n }\n const id = hash.slice(1);\n const element = document.getElementById(id);\n if (element) {\n element.scrollIntoView({ behavior: \"auto\" });\n }\n}\n\n/**\n * Reference to the native history.replaceState before patching.\n * Used internally to avoid triggering the interception for internal operations\n * (e.g. saving scroll position shouldn't cause re-renders).\n * Captured before the history method patching at the bottom of this module.\n */\nconst _nativeReplaceState = !isServer\n ? window.history.replaceState.bind(window.history)\n : (null as unknown as typeof window.history.replaceState);\n\n/**\n * Save the current scroll position into the current history state.\n * Called before every navigation to enable scroll restoration on back/forward.\n *\n * Uses _nativeReplaceState to avoid triggering the history.replaceState\n * interception (which would cause spurious re-renders from notifyListeners).\n */\nfunction saveScrollPosition(): void {\n const state = window.history.state ?? {};\n _nativeReplaceState.call(\n window.history,\n { ...state, __vinext_scrollX: window.scrollX, __vinext_scrollY: window.scrollY },\n \"\",\n );\n}\n\n/**\n * Restore scroll position from a history state object (used on popstate).\n *\n * When an RSC navigation is in flight (back/forward triggers both this\n * handler and the browser entry's popstate handler which calls\n * __VINEXT_RSC_NAVIGATE__), we must wait for the new content to render\n * before scrolling. Otherwise the user sees old content flash at the\n * restored scroll position.\n *\n * This handler fires before the browser entry's popstate handler (because\n * navigation.ts is loaded before hydration completes), so we defer via a\n * microtask to give the browser entry handler a chance to set\n * __VINEXT_RSC_PENDING__ first.\n */\nfunction restoreScrollPosition(state: unknown): void {\n if (state && typeof state === \"object\" && \"__vinext_scrollY\" in state) {\n const { __vinext_scrollX: x, __vinext_scrollY: y } = state as {\n __vinext_scrollX: number;\n __vinext_scrollY: number;\n };\n\n // Defer to allow other popstate listeners (browser entry) to run first\n // and set __VINEXT_RSC_PENDING__. Promise.resolve() schedules a microtask\n // that runs after all synchronous event listeners have completed.\n void Promise.resolve().then(() => {\n const pending: Promise<void> | null = window.__VINEXT_RSC_PENDING__ ?? null;\n\n if (pending) {\n // Wait for the RSC navigation to finish rendering, then scroll.\n void pending.then(() => {\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n });\n } else {\n // No RSC navigation in flight (Pages Router or already settled).\n requestAnimationFrame(() => {\n window.scrollTo(x, y);\n });\n }\n });\n }\n}\n\n/**\n * Navigate to a URL, handling external URLs, hash-only changes, and RSC navigation.\n */\nasync function navigateImpl(\n href: string,\n mode: \"push\" | \"replace\",\n scroll: boolean,\n): Promise<void> {\n // Normalize same-origin absolute URLs to local paths for SPA navigation\n let normalizedHref = href;\n if (isExternalUrl(href)) {\n const localPath = toSameOriginPath(href);\n if (localPath == null) {\n // Truly external: use full page navigation\n if (mode === \"replace\") {\n window.location.replace(href);\n } else {\n window.location.assign(href);\n }\n return;\n }\n normalizedHref = localPath;\n }\n\n const fullHref = withBasePath(normalizedHref);\n\n // Save scroll position before navigating (for back/forward restoration)\n if (mode === \"push\") {\n saveScrollPosition();\n }\n\n // Hash-only change: update URL and scroll to target, skip RSC fetch\n if (isHashOnlyChange(fullHref)) {\n const hash = fullHref.includes(\"#\") ? fullHref.slice(fullHref.indexOf(\"#\")) : \"\";\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n if (scroll) {\n scrollToHash(hash);\n }\n return;\n }\n\n // Extract hash for post-navigation scrolling\n const hashIdx = fullHref.indexOf(\"#\");\n const hash = hashIdx !== -1 ? fullHref.slice(hashIdx) : \"\";\n\n if (mode === \"replace\") {\n window.history.replaceState(null, \"\", fullHref);\n } else {\n window.history.pushState(null, \"\", fullHref);\n }\n notifyListeners();\n\n // Trigger RSC re-fetch if available, and wait for the new content to render\n // before scrolling. This prevents the old page from visibly jumping to the\n // top before the new content paints.\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n await window.__VINEXT_RSC_NAVIGATE__(fullHref);\n }\n\n if (scroll) {\n if (hash) {\n scrollToHash(hash);\n } else {\n window.scrollTo(0, 0);\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// App Router router singleton\n//\n// All methods close over module-level state (navigateImpl, withBasePath, etc.)\n// and carry no per-render data, so the object can be created once and reused.\n// Next.js returns the same router reference on every call to useRouter(), which\n// matters for components that rely on referential equality (e.g. useMemo /\n// useEffect dependency arrays, React.memo bailouts).\n// ---------------------------------------------------------------------------\n\nconst _appRouter = {\n push(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"push\", options?.scroll !== false);\n },\n replace(href: string, options?: { scroll?: boolean }): void {\n if (isServer) return;\n void navigateImpl(href, \"replace\", options?.scroll !== false);\n },\n back(): void {\n if (isServer) return;\n window.history.back();\n },\n forward(): void {\n if (isServer) return;\n window.history.forward();\n },\n refresh(): void {\n if (isServer) return;\n // Re-fetch the current page's RSC stream\n if (typeof window.__VINEXT_RSC_NAVIGATE__ === \"function\") {\n window.__VINEXT_RSC_NAVIGATE__(window.location.href);\n }\n },\n prefetch(href: string): void {\n if (isServer) return;\n // Prefetch the RSC payload for the target route and store in cache\n const fullHref = withBasePath(href);\n const rscUrl = toRscUrl(fullHref);\n const prefetched = getPrefetchedUrls();\n if (prefetched.has(rscUrl)) return;\n prefetched.add(rscUrl);\n fetch(rscUrl, {\n headers: { Accept: \"text/x-component\" },\n credentials: \"include\",\n priority: \"low\" as RequestInit[\"priority\"],\n })\n .then((response) => {\n if (response.ok) {\n storePrefetchResponse(rscUrl, response);\n } else {\n // Non-ok response: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n }\n })\n .catch(() => {\n // Network error: allow retry on next prefetch() call\n prefetched.delete(rscUrl);\n });\n },\n};\n\n/**\n * App Router's useRouter — returns push/replace/back/forward/refresh.\n * Different from Pages Router's useRouter (next/router).\n *\n * Returns a stable singleton: the same object reference on every call,\n * matching Next.js behavior so components using referential equality\n * (e.g. useMemo / useEffect deps, React.memo) don't re-render unnecessarily.\n */\nexport function useRouter() {\n return _appRouter;\n}\n\n/**\n * Returns the active child segment one level below the layout where it's called.\n *\n * Returns the first segment from the route tree below this layout, including\n * route groups (e.g., \"(marketing)\") and resolved dynamic params. Returns null\n * if at the leaf (no child segments).\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegment(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string | null {\n const segments = useSelectedLayoutSegments(_parallelRoutesKey);\n return segments.length > 0 ? segments[0] : null;\n}\n\n/**\n * Returns all active segments below the layout where it's called.\n *\n * Each layout in the App Router tree wraps its children with a\n * LayoutSegmentProvider whose value is the remaining route tree segments\n * (including route groups, with dynamic params resolved to actual values\n * and catch-all segments joined with \"/\"). This hook reads those segments\n * directly from context.\n *\n * @param parallelRoutesKey - Which parallel route to read (default: \"children\")\n */\nexport function useSelectedLayoutSegments(\n // parallelRoutesKey is accepted for API compat but not yet supported —\n // vinext doesn't implement parallel routes with separate segment tracking.\n _parallelRoutesKey?: string,\n): string[] {\n return useChildSegments();\n}\n\nexport { ReadonlyURLSearchParams };\n\n/**\n * useServerInsertedHTML — inject HTML during SSR from client components.\n *\n * Used by CSS-in-JS libraries (styled-components, emotion, StyleX) to inject\n * <style> tags during SSR so styles appear in the initial HTML (no FOUC).\n *\n * The callback is called once after each SSR render pass. The returned JSX/HTML\n * is serialized and injected into the HTML stream.\n *\n * Usage (in a \"use client\" component wrapping children):\n * useServerInsertedHTML(() => {\n * const styles = sheet.getStyleElement();\n * sheet.instance.clearTag();\n * return <>{styles}</>;\n * });\n */\n\nexport function useServerInsertedHTML(callback: () => unknown): void {\n if (typeof document !== \"undefined\") {\n // Client-side: no-op (styles are already in the DOM)\n return;\n }\n _getInsertedHTMLCallbacks().push(callback);\n}\n\n/**\n * Flush all collected useServerInsertedHTML callbacks.\n * Returns an array of results (React elements or strings).\n * Clears the callback list so the next render starts fresh.\n *\n * Called by the SSR entry after renderToReadableStream completes.\n */\nexport function flushServerInsertedHTML(): unknown[] {\n const callbacks = _getInsertedHTMLCallbacks();\n const results: unknown[] = [];\n for (const cb of callbacks) {\n try {\n const result = cb();\n if (result != null) results.push(result);\n } catch {\n // Ignore errors from individual callbacks\n }\n }\n callbacks.length = 0;\n return results;\n}\n\n/**\n * Clear all collected useServerInsertedHTML callbacks without flushing.\n * Used for cleanup between requests.\n */\nexport function clearServerInsertedHTML(): void {\n _clearInsertedHTMLCallbacks();\n}\n\n// ---------------------------------------------------------------------------\n// Non-hook utilities (can be called from Server Components)\n// ---------------------------------------------------------------------------\n\n/**\n * HTTP Access Fallback error code — shared prefix for notFound/forbidden/unauthorized.\n * Matches Next.js 16's unified error handling approach.\n */\nexport const HTTP_ERROR_FALLBACK_ERROR_CODE = \"NEXT_HTTP_ERROR_FALLBACK\";\n\n/**\n * Check if an error is an HTTP Access Fallback error (notFound, forbidden, unauthorized).\n */\nexport function isHTTPAccessFallbackError(error: unknown): boolean {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n return (\n digest === \"NEXT_NOT_FOUND\" || // legacy compat\n digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)\n );\n }\n return false;\n}\n\n/**\n * Extract the HTTP status code from an HTTP Access Fallback error.\n * Returns 404 for legacy NEXT_NOT_FOUND errors.\n */\nexport function getAccessFallbackHTTPStatus(error: unknown): number {\n if (error && typeof error === \"object\" && \"digest\" in error) {\n const digest = String((error as any).digest);\n if (digest === \"NEXT_NOT_FOUND\") return 404;\n if (digest.startsWith(`${HTTP_ERROR_FALLBACK_ERROR_CODE};`)) {\n return parseInt(digest.split(\";\")[1], 10);\n }\n }\n return 404;\n}\n\n/**\n * Enum matching Next.js RedirectType for type-safe redirect calls.\n */\nexport enum RedirectType {\n push = \"push\",\n replace = \"replace\",\n}\n\n/**\n * Throw a redirect. Caught by the framework to send a redirect response.\n */\nexport function redirect(url: string, type?: \"replace\" | \"push\" | RedirectType): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;${type ?? \"replace\"};${encodeURIComponent(url)}`;\n throw error;\n}\n\n/**\n * Trigger a permanent redirect (308).\n */\nexport function permanentRedirect(url: string): never {\n const error = new Error(`NEXT_REDIRECT:${url}`);\n (error as any).digest = `NEXT_REDIRECT;replace;${encodeURIComponent(url)};308`;\n throw error;\n}\n\n/**\n * Trigger a not-found response (404). Caught by the framework.\n */\nexport function notFound(): never {\n const error = new Error(\"NEXT_NOT_FOUND\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};404`;\n throw error;\n}\n\n/**\n * Trigger a forbidden response (403). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function forbidden(): never {\n const error = new Error(\"NEXT_FORBIDDEN\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};403`;\n throw error;\n}\n\n/**\n * Trigger an unauthorized response (401). Caught by the framework.\n * In Next.js, this is gated behind experimental.authInterrupts — we\n * support it unconditionally for maximum compatibility.\n */\nexport function unauthorized(): never {\n const error = new Error(\"NEXT_UNAUTHORIZED\");\n (error as any).digest = `${HTTP_ERROR_FALLBACK_ERROR_CODE};401`;\n throw error;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n// React hooks are imported at the top level via ESM.\n\n// Listen for popstate on the client\nif (!isServer) {\n window.addEventListener(\"popstate\", (event) => {\n notifyListeners();\n // Restore scroll position for back/forward navigation\n restoreScrollPosition(event.state);\n });\n\n // ---------------------------------------------------------------------------\n // history.pushState / replaceState interception (shallow routing)\n //\n // Next.js intercepts these native methods so that when user code calls\n // `window.history.pushState(null, '', '/new-path?filter=abc')` directly,\n // React hooks like usePathname() and useSearchParams() re-render with\n // the new URL. This is the foundation for shallow routing patterns\n // (filter UIs, tabs, URL search param state, etc.).\n //\n // We wrap the original methods, call through to the native implementation,\n // then notify our listener system so useSyncExternalStore picks up the\n // URL change.\n // ---------------------------------------------------------------------------\n const originalPushState = window.history.pushState.bind(window.history);\n const originalReplaceState = window.history.replaceState.bind(window.history);\n\n window.history.pushState = function patchedPushState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalPushState(data, unused, url);\n notifyListeners();\n };\n\n window.history.replaceState = function patchedReplaceState(\n data: unknown,\n unused: string,\n url?: string | URL | null,\n ): void {\n originalReplaceState(data, unused, url);\n notifyListeners();\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only URLSearchParams wrapper matching Next.js runtime behavior.
|
|
3
|
+
* Mutation methods remain present for instanceof/API compatibility but throw.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ReadonlyURLSearchParams extends URLSearchParams {
|
|
6
|
+
append(_name: string, _value: string): never;
|
|
7
|
+
delete(_name: string, _value?: string): never;
|
|
8
|
+
set(_name: string, _value: string): never;
|
|
9
|
+
sort(): never;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=readonly-url-search-params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonly-url-search-params.d.ts","sourceRoot":"","sources":["../../src/shims/readonly-url-search-params.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;IAC1D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK;IAI5C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK;IAI7C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK;IAIzC,IAAI,IAAI,KAAK;CAGd"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class ReadonlyURLSearchParamsError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super("Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Read-only URLSearchParams wrapper matching Next.js runtime behavior.
|
|
8
|
+
* Mutation methods remain present for instanceof/API compatibility but throw.
|
|
9
|
+
*/
|
|
10
|
+
export class ReadonlyURLSearchParams extends URLSearchParams {
|
|
11
|
+
append(_name, _value) {
|
|
12
|
+
throw new ReadonlyURLSearchParamsError();
|
|
13
|
+
}
|
|
14
|
+
delete(_name, _value) {
|
|
15
|
+
throw new ReadonlyURLSearchParamsError();
|
|
16
|
+
}
|
|
17
|
+
set(_name, _value) {
|
|
18
|
+
throw new ReadonlyURLSearchParamsError();
|
|
19
|
+
}
|
|
20
|
+
sort() {
|
|
21
|
+
throw new ReadonlyURLSearchParamsError();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=readonly-url-search-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readonly-url-search-params.js","sourceRoot":"","sources":["../../src/shims/readonly-url-search-params.ts"],"names":[],"mappings":"AAAA,MAAM,4BAA6B,SAAQ,KAAK;IAC9C;QACE,KAAK,CACH,yJAAyJ,CAC1J,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,eAAe;IAC1D,MAAM,CAAC,KAAa,EAAE,MAAc;QAClC,MAAM,IAAI,4BAA4B,EAAE,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,KAAa,EAAE,MAAe;QACnC,MAAM,IAAI,4BAA4B,EAAE,CAAC;IAC3C,CAAC;IAED,GAAG,CAAC,KAAa,EAAE,MAAc;QAC/B,MAAM,IAAI,4BAA4B,EAAE,CAAC;IAC3C,CAAC;IAED,IAAI;QACF,MAAM,IAAI,4BAA4B,EAAE,CAAC;IAC3C,CAAC;CACF","sourcesContent":["class ReadonlyURLSearchParamsError extends Error {\n constructor() {\n super(\n \"Method unavailable on `ReadonlyURLSearchParams`. Read more: https://nextjs.org/docs/app/api-reference/functions/use-search-params#updating-searchparams\",\n );\n }\n}\n\n/**\n * Read-only URLSearchParams wrapper matching Next.js runtime behavior.\n * Mutation methods remain present for instanceof/API compatibility but throw.\n */\nexport class ReadonlyURLSearchParams extends URLSearchParams {\n append(_name: string, _value: string): never {\n throw new ReadonlyURLSearchParamsError();\n }\n\n delete(_name: string, _value?: string): never {\n throw new ReadonlyURLSearchParamsError();\n }\n\n set(_name: string, _value: string): never {\n throw new ReadonlyURLSearchParamsError();\n }\n\n sort(): never {\n throw new ReadonlyURLSearchParamsError();\n }\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request ExecutionContext — AsyncLocalStorage-backed accessor.
|
|
3
|
+
*
|
|
4
|
+
* Makes the Cloudflare Workers `ExecutionContext` (which provides
|
|
5
|
+
* `waitUntil`) available to any code on the call stack during a request
|
|
6
|
+
* without requiring it to be threaded through every function signature.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
*
|
|
10
|
+
* // In the worker entry, wrap the handler:
|
|
11
|
+
* import { runWithExecutionContext } from "vinext/shims/request-context";
|
|
12
|
+
* export default {
|
|
13
|
+
* fetch(request, env, ctx) {
|
|
14
|
+
* return runWithExecutionContext(ctx, () => handler.fetch(request, env, ctx));
|
|
15
|
+
* }
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* // Anywhere downstream:
|
|
19
|
+
* import { getRequestExecutionContext } from "vinext/shims/request-context";
|
|
20
|
+
* const ctx = getRequestExecutionContext(); // null on Node.js dev
|
|
21
|
+
* ctx?.waitUntil(somePromise);
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Minimal ExecutionContext interface matching the Cloudflare Workers runtime.
|
|
25
|
+
* Using a structural interface so this file has no runtime dependency on
|
|
26
|
+
* Cloudflare types packages.
|
|
27
|
+
*/
|
|
28
|
+
export interface ExecutionContextLike {
|
|
29
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
30
|
+
passThroughOnException?(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Run `fn` with the given `ExecutionContext` available via
|
|
34
|
+
* `getRequestExecutionContext()` for the duration of the call (including
|
|
35
|
+
* all async continuations, such as RSC streaming).
|
|
36
|
+
*
|
|
37
|
+
* Call this at the top of your Worker's `fetch` handler, wrapping the
|
|
38
|
+
* delegation to vinext so the context propagates through the entire
|
|
39
|
+
* request pipeline.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runWithExecutionContext<T>(ctx: ExecutionContextLike, fn: () => T | Promise<T>): T | Promise<T>;
|
|
42
|
+
/**
|
|
43
|
+
* Get the `ExecutionContext` for the current request, or `null` when called
|
|
44
|
+
* outside a `runWithExecutionContext()` scope (e.g. on Node.js dev server).
|
|
45
|
+
*
|
|
46
|
+
* Use `ctx?.waitUntil(promise)` to schedule background work that must
|
|
47
|
+
* complete before the Worker isolate is torn down.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getRequestExecutionContext(): ExecutionContextLike | null;
|
|
50
|
+
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/shims/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,sBAAsB,CAAC,IAAI,IAAI,CAAC;CACjC;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,GAAG,EAAE,oBAAoB,EACzB,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEhB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,oBAAoB,GAAG,IAAI,CAIxE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request ExecutionContext — AsyncLocalStorage-backed accessor.
|
|
3
|
+
*
|
|
4
|
+
* Makes the Cloudflare Workers `ExecutionContext` (which provides
|
|
5
|
+
* `waitUntil`) available to any code on the call stack during a request
|
|
6
|
+
* without requiring it to be threaded through every function signature.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
*
|
|
10
|
+
* // In the worker entry, wrap the handler:
|
|
11
|
+
* import { runWithExecutionContext } from "vinext/shims/request-context";
|
|
12
|
+
* export default {
|
|
13
|
+
* fetch(request, env, ctx) {
|
|
14
|
+
* return runWithExecutionContext(ctx, () => handler.fetch(request, env, ctx));
|
|
15
|
+
* }
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* // Anywhere downstream:
|
|
19
|
+
* import { getRequestExecutionContext } from "vinext/shims/request-context";
|
|
20
|
+
* const ctx = getRequestExecutionContext(); // null on Node.js dev
|
|
21
|
+
* ctx?.waitUntil(somePromise);
|
|
22
|
+
*/
|
|
23
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// ALS setup — stored on globalThis so all Vite environments (RSC/SSR/client)
|
|
26
|
+
// share the same instance and see the same per-request context.
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
const _ALS_KEY = Symbol.for("vinext.requestContext.als");
|
|
29
|
+
const _g = globalThis;
|
|
30
|
+
const _als = (_g[_ALS_KEY] ??=
|
|
31
|
+
new AsyncLocalStorage());
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Public API
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
/**
|
|
36
|
+
* Run `fn` with the given `ExecutionContext` available via
|
|
37
|
+
* `getRequestExecutionContext()` for the duration of the call (including
|
|
38
|
+
* all async continuations, such as RSC streaming).
|
|
39
|
+
*
|
|
40
|
+
* Call this at the top of your Worker's `fetch` handler, wrapping the
|
|
41
|
+
* delegation to vinext so the context propagates through the entire
|
|
42
|
+
* request pipeline.
|
|
43
|
+
*/
|
|
44
|
+
export function runWithExecutionContext(ctx, fn) {
|
|
45
|
+
return _als.run(ctx, fn);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get the `ExecutionContext` for the current request, or `null` when called
|
|
49
|
+
* outside a `runWithExecutionContext()` scope (e.g. on Node.js dev server).
|
|
50
|
+
*
|
|
51
|
+
* Use `ctx?.waitUntil(promise)` to schedule background work that must
|
|
52
|
+
* complete before the Worker isolate is torn down.
|
|
53
|
+
*/
|
|
54
|
+
export function getRequestExecutionContext() {
|
|
55
|
+
// getStore() returns undefined when called outside an ALS scope;
|
|
56
|
+
// normalise to null for a consistent return type.
|
|
57
|
+
return _als.getStore() ?? null;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/shims/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgBrD,8EAA8E;AAC9E,6EAA6E;AAC7E,gEAAgE;AAChE,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;AACzD,MAAM,EAAE,GAAG,UAAqD,CAAC;AACjE,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC;IACxB,IAAI,iBAAiB,EAA+B,CAAmD,CAAC;AAE1G,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,GAAyB,EACzB,EAAwB;IAExB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B;IACxC,iEAAiE;IACjE,kDAAkD;IAClD,OAAO,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC;AACjC,CAAC","sourcesContent":["/**\n * Request ExecutionContext — AsyncLocalStorage-backed accessor.\n *\n * Makes the Cloudflare Workers `ExecutionContext` (which provides\n * `waitUntil`) available to any code on the call stack during a request\n * without requiring it to be threaded through every function signature.\n *\n * Usage:\n *\n * // In the worker entry, wrap the handler:\n * import { runWithExecutionContext } from \"vinext/shims/request-context\";\n * export default {\n * fetch(request, env, ctx) {\n * return runWithExecutionContext(ctx, () => handler.fetch(request, env, ctx));\n * }\n * };\n *\n * // Anywhere downstream:\n * import { getRequestExecutionContext } from \"vinext/shims/request-context\";\n * const ctx = getRequestExecutionContext(); // null on Node.js dev\n * ctx?.waitUntil(somePromise);\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\n// ---------------------------------------------------------------------------\n// ExecutionContext interface\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal ExecutionContext interface matching the Cloudflare Workers runtime.\n * Using a structural interface so this file has no runtime dependency on\n * Cloudflare types packages.\n */\nexport interface ExecutionContextLike {\n waitUntil(promise: Promise<unknown>): void;\n passThroughOnException?(): void;\n}\n\n// ---------------------------------------------------------------------------\n// ALS setup — stored on globalThis so all Vite environments (RSC/SSR/client)\n// share the same instance and see the same per-request context.\n// ---------------------------------------------------------------------------\n\nconst _ALS_KEY = Symbol.for(\"vinext.requestContext.als\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??=\n new AsyncLocalStorage<ExecutionContextLike | null>()) as AsyncLocalStorage<ExecutionContextLike | null>;\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Run `fn` with the given `ExecutionContext` available via\n * `getRequestExecutionContext()` for the duration of the call (including\n * all async continuations, such as RSC streaming).\n *\n * Call this at the top of your Worker's `fetch` handler, wrapping the\n * delegation to vinext so the context propagates through the entire\n * request pipeline.\n */\nexport function runWithExecutionContext<T>(\n ctx: ExecutionContextLike,\n fn: () => T | Promise<T>,\n): T | Promise<T> {\n return _als.run(ctx, fn);\n}\n\n/**\n * Get the `ExecutionContext` for the current request, or `null` when called\n * outside a `runWithExecutionContext()` scope (e.g. on Node.js dev server).\n *\n * Use `ctx?.waitUntil(promise)` to schedule background work that must\n * complete before the Worker isolate is torn down.\n */\nexport function getRequestExecutionContext(): ExecutionContextLike | null {\n // getStore() returns undefined when called outside an ALS scope;\n // normalise to null for a consistent return type.\n return _als.getStore() ?? null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-state.d.ts","sourceRoot":"","sources":["../../src/shims/router-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"router-state.d.ts","sourceRoot":"","sources":["../../src/shims/router-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoCH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAK9E"}
|
|
@@ -12,7 +12,8 @@ import { _registerRouterStateAccessors } from "./router.js";
|
|
|
12
12
|
const _ALS_KEY = Symbol.for("vinext.router.als");
|
|
13
13
|
const _FALLBACK_KEY = Symbol.for("vinext.router.fallback");
|
|
14
14
|
const _g = globalThis;
|
|
15
|
-
const _als = (_g[_ALS_KEY] ??=
|
|
15
|
+
const _als = (_g[_ALS_KEY] ??=
|
|
16
|
+
new AsyncLocalStorage());
|
|
16
17
|
const _fallbackState = (_g[_FALLBACK_KEY] ??= {
|
|
17
18
|
ssrContext: null,
|
|
18
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-state.js","sourceRoot":"","sources":["../../src/shims/router-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAC;AAmB5D,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG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,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,uEAAuE;YACvE,cAAc,CAAC,UAAU,GAAG,GAAG,CAAC;QAClC,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["/**\n * Server-only Pages Router state backed by AsyncLocalStorage.\n *\n * Provides request-scoped isolation for SSR context (pathname, query,\n * locale) so concurrent requests on Workers don't share state.\n *\n * This module is server-only — it imports node:async_hooks and must NOT\n * be bundled for the browser.\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { _registerRouterStateAccessors } from \"./router.js\";\n\n// ---------------------------------------------------------------------------\n// ALS setup\n// ---------------------------------------------------------------------------\n\ninterface SSRContext {\n pathname: string;\n query: Record<string, string | string[]>;\n asPath: string;\n locale?: string;\n locales?: string[];\n defaultLocale?: string;\n}\n\ninterface RouterState {\n ssrContext: SSRContext | null;\n}\n\nconst _ALS_KEY = Symbol.for(\"vinext.router.als\");\nconst _FALLBACK_KEY = Symbol.for(\"vinext.router.fallback\");\nconst _g = globalThis as unknown as Record<PropertyKey, unknown>;\nconst _als = (_g[_ALS_KEY] ??=\n new AsyncLocalStorage<RouterState>()) as AsyncLocalStorage<RouterState>;\n\nconst _fallbackState = (_g[_FALLBACK_KEY] ??= {\n ssrContext: null,\n} satisfies RouterState) as RouterState;\n\nfunction _getState(): RouterState {\n return _als.getStore() ?? _fallbackState;\n}\n\n/**\n * Run a function within a router state ALS scope.\n * Ensures per-request isolation for Pages Router SSR context\n * on concurrent runtimes.\n */\nexport function runWithRouterState<T>(fn: () => T | Promise<T>): T | Promise<T> {\n const state: RouterState = {\n ssrContext: null,\n };\n return _als.run(state, fn);\n}\n\n// ---------------------------------------------------------------------------\n// Register ALS-backed accessors into router.ts\n// ---------------------------------------------------------------------------\n\n_registerRouterStateAccessors({\n getSSRContext(): SSRContext | null {\n return _getState().ssrContext;\n },\n\n setSSRContext(ctx: SSRContext | null): void {\n const state = _als.getStore();\n if (state) {\n state.ssrContext = ctx;\n } else {\n // No ALS scope — fallback for environments without als.run() wrapping.\n _fallbackState.ssrContext = ctx;\n }\n },\n});\n"]}
|