@qwik.dev/router 2.0.0-beta.30 → 2.0.0-beta.31
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/lib/chunks/fs.mjs +1 -1
- package/lib/chunks/routing.qwik.mjs +4 -3
- package/lib/chunks/{mime-types.mjs → url.mjs} +10 -1
- package/lib/chunks/worker-thread.qwik.mjs +29 -28
- package/lib/index.d.ts +4 -1
- package/lib/index.qwik.mjs +241 -245
- package/lib/middleware/aws-lambda/index.d.ts +0 -6
- package/lib/middleware/aws-lambda/index.mjs +0 -5
- package/lib/middleware/azure-swa/index.mjs +0 -4
- package/lib/middleware/bun/index.mjs +3 -7
- package/lib/middleware/cloudflare-pages/index.mjs +0 -4
- package/lib/middleware/deno/index.mjs +2 -6
- package/lib/middleware/firebase/index.mjs +0 -5
- package/lib/middleware/netlify-edge/index.mjs +0 -4
- package/lib/middleware/node/index.mjs +2 -7
- package/lib/middleware/request-handler/index.d.ts +4 -7
- package/lib/middleware/request-handler/index.mjs +41 -44
- package/lib/middleware/vercel-edge/index.mjs +0 -4
- package/lib/vite/index.mjs +2 -2
- package/package.json +3 -3
package/lib/chunks/fs.mjs
CHANGED
|
@@ -99,7 +99,7 @@ function isIndexModule(extlessName) {
|
|
|
99
99
|
return /^index(|!|@.+)$/.test(extlessName);
|
|
100
100
|
}
|
|
101
101
|
function isPluginModule(extlessName) {
|
|
102
|
-
return /^plugin(|@.+)$/.test(extlessName);
|
|
102
|
+
return /^plugin(|@.+)$/.test(extlessName) && !/\.(test|unit|spec)(\.[jt]s)?$/.test(extlessName);
|
|
103
103
|
}
|
|
104
104
|
function isLayoutModule(extlessName) {
|
|
105
105
|
return /^layout(|!|-.+)$/.test(extlessName);
|
|
@@ -248,7 +248,7 @@ const resolveDocumentHead = (resolvedHead, updatedHead) => {
|
|
|
248
248
|
mergeArray(resolvedHead.scripts, updatedHead.scripts);
|
|
249
249
|
Object.assign(resolvedHead.frontmatter, updatedHead.frontmatter);
|
|
250
250
|
};
|
|
251
|
-
const createDocumentHead = (defaults) => ({
|
|
251
|
+
const createDocumentHead = (defaults, manifestHash) => ({
|
|
252
252
|
title: defaults?.title || "",
|
|
253
253
|
meta: [
|
|
254
254
|
...defaults?.meta || []
|
|
@@ -264,7 +264,8 @@ const createDocumentHead = (defaults) => ({
|
|
|
264
264
|
],
|
|
265
265
|
frontmatter: {
|
|
266
266
|
...defaults?.frontmatter
|
|
267
|
-
}
|
|
267
|
+
},
|
|
268
|
+
manifestHash: manifestHash || "dev"
|
|
268
269
|
});
|
|
269
270
|
const resolveRouteConfig = (resolveValue, routeLocation, contentModules, locale, status, defaults) => withLocale(locale, () => {
|
|
270
271
|
const head = createDocumentHead(defaults);
|
|
@@ -817,4 +818,4 @@ const loadRoute = async (routes, cacheModules, pathname, isInternal) => {
|
|
|
817
818
|
};
|
|
818
819
|
};
|
|
819
820
|
|
|
820
|
-
export { CLIENT_DATA_CACHE as C, DEFAULT_LOADERS_SERIALIZATION_STRATEGY as D, Q_ROUTE as Q, createDocumentHead as a,
|
|
821
|
+
export { CLIENT_DATA_CACHE as C, DEFAULT_LOADERS_SERIALIZATION_STRATEGY as D, Q_ROUTE as Q, createDocumentHead as a, loadRoute as b, createLoaderSignal as c, isSameOrigin as d, clientNavigate as e, toPath as f, getClientNavPath as g, QFN_KEY as h, isSamePath as i, QACTION_KEY as j, QDATA_KEY as k, loadClientData as l, resolveRouteConfig as m, QLOADER_KEY as n, isPromise as o, preloadRouteBundles as p, resolveHead as r, shouldPreload as s, toUrl as t };
|
|
@@ -49,4 +49,13 @@ const MIME_TYPES = {
|
|
|
49
49
|
zip: "application/zip"
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const LEADING_DOUBLE_SLASH_REG = /^[\\/]{2,}/;
|
|
53
|
+
function normalizeRequestUrl(url, base) {
|
|
54
|
+
const DOUBLE_SLASH_REG = /\/\/|\\\\/g;
|
|
55
|
+
const queryOrHashIndex = url.search(/[?#]/);
|
|
56
|
+
const path = queryOrHashIndex === -1 ? url : url.slice(0, queryOrHashIndex);
|
|
57
|
+
const suffix = queryOrHashIndex === -1 ? "" : url.slice(queryOrHashIndex);
|
|
58
|
+
return new URL(`${path.replace(LEADING_DOUBLE_SLASH_REG, "/").replace(DOUBLE_SLASH_REG, "/")}${suffix}`, base);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { MIME_TYPES as M, normalizeRequestUrl as n };
|
|
@@ -35,7 +35,7 @@ const resolveDocumentHead = (resolvedHead, updatedHead) => {
|
|
|
35
35
|
mergeArray(resolvedHead.scripts, updatedHead.scripts);
|
|
36
36
|
Object.assign(resolvedHead.frontmatter, updatedHead.frontmatter);
|
|
37
37
|
};
|
|
38
|
-
const createDocumentHead = (defaults) => ({
|
|
38
|
+
const createDocumentHead = (defaults, manifestHash) => ({
|
|
39
39
|
title: defaults?.title || "",
|
|
40
40
|
meta: [
|
|
41
41
|
...defaults?.meta || []
|
|
@@ -51,7 +51,8 @@ const createDocumentHead = (defaults) => ({
|
|
|
51
51
|
],
|
|
52
52
|
frontmatter: {
|
|
53
53
|
...defaults?.frontmatter
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
|
+
manifestHash: manifestHash || "dev"
|
|
55
56
|
});
|
|
56
57
|
const resolveRouteConfig = (resolveValue, routeLocation, contentModules, locale, status, defaults) => withLocale(locale, () => {
|
|
57
58
|
const head = createDocumentHead(defaults);
|
|
@@ -1183,7 +1184,7 @@ function createResolveRequestHandlers(deps) {
|
|
|
1183
1184
|
const routeLoaders = [];
|
|
1184
1185
|
const routeActions = [];
|
|
1185
1186
|
const requestHandlers = [];
|
|
1186
|
-
const isPageRoute = !!
|
|
1187
|
+
const isPageRoute = !!isLastModulePageRoute(route.$mods$);
|
|
1187
1188
|
if (isInternal) {
|
|
1188
1189
|
requestHandlers.push(handleQDataRedirect);
|
|
1189
1190
|
}
|
|
@@ -1193,36 +1194,36 @@ function createResolveRequestHandlers(deps) {
|
|
|
1193
1194
|
if (serverPlugins) {
|
|
1194
1195
|
_resolveRequestHandlers(routeLoaders, routeActions, requestHandlers, serverPlugins, isPageRoute, method);
|
|
1195
1196
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
if (checkOrigin
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
requestHandlers.unshift(csrfCheckMiddleware);
|
|
1205
|
-
}
|
|
1197
|
+
const routeModules = route.$mods$;
|
|
1198
|
+
_resolveRequestHandlers(routeLoaders, routeActions, requestHandlers, routeModules, isPageRoute, method);
|
|
1199
|
+
const routeName = route.$routeName$;
|
|
1200
|
+
if (checkOrigin && (method === "POST" || method === "PUT" || method === "PATCH" || method === "DELETE")) {
|
|
1201
|
+
if (checkOrigin === "lax-proto") {
|
|
1202
|
+
requestHandlers.unshift(csrfLaxProtoCheckMiddleware);
|
|
1203
|
+
} else {
|
|
1204
|
+
requestHandlers.unshift(csrfCheckMiddleware);
|
|
1206
1205
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1206
|
+
}
|
|
1207
|
+
if (isPageRoute) {
|
|
1208
|
+
if (method === "POST" || method === "GET") {
|
|
1209
|
+
requestHandlers.push(runServerFunction);
|
|
1210
|
+
}
|
|
1211
|
+
if (!route.$notFound$) {
|
|
1211
1212
|
requestHandlers.push(fixTrailingSlash);
|
|
1212
|
-
if (isInternal) {
|
|
1213
|
-
requestHandlers.push(renderQData);
|
|
1214
|
-
}
|
|
1215
1213
|
}
|
|
1216
|
-
if (
|
|
1217
|
-
requestHandlers.push(
|
|
1218
|
-
ev.sharedMap.set(deps.RequestRouteName, routeName);
|
|
1219
|
-
});
|
|
1220
|
-
requestHandlers.push(actionsMiddleware(routeActions));
|
|
1221
|
-
requestHandlers.push(loadersMiddleware(routeLoaders));
|
|
1222
|
-
requestHandlers.push(eTagMiddleware(route));
|
|
1223
|
-
requestHandlers.push(renderHandler);
|
|
1214
|
+
if (isInternal) {
|
|
1215
|
+
requestHandlers.push(renderQData);
|
|
1224
1216
|
}
|
|
1225
1217
|
}
|
|
1218
|
+
if (isPageRoute) {
|
|
1219
|
+
requestHandlers.push((ev) => {
|
|
1220
|
+
ev.sharedMap.set(deps.RequestRouteName, routeName);
|
|
1221
|
+
});
|
|
1222
|
+
requestHandlers.push(actionsMiddleware(routeActions));
|
|
1223
|
+
requestHandlers.push(loadersMiddleware(routeLoaders));
|
|
1224
|
+
requestHandlers.push(eTagMiddleware(route));
|
|
1225
|
+
requestHandlers.push(renderHandler);
|
|
1226
|
+
}
|
|
1226
1227
|
return requestHandlers;
|
|
1227
1228
|
};
|
|
1228
1229
|
const _resolveRequestHandlers = (routeLoaders, routeActions, requestHandlers, routeModules, collectActions, method) => {
|
package/lib/index.d.ts
CHANGED
|
@@ -740,7 +740,10 @@ export { RequestEventLoader }
|
|
|
740
740
|
export { RequestHandler }
|
|
741
741
|
|
|
742
742
|
/** @public */
|
|
743
|
-
export declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter
|
|
743
|
+
export declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>> & {
|
|
744
|
+
/** The build's manifest hash, used for per-loader data URLs. Always defined (`'dev'` in dev). */
|
|
745
|
+
readonly manifestHash: string;
|
|
746
|
+
};
|
|
744
747
|
|
|
745
748
|
/** @public */
|
|
746
749
|
export declare const routeAction$: ActionConstructor;
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl, isDev, _jsxSplit, _getConstProps, _getVarProps, eventQrl, isServer, useStylesQrl, useServerData, useStore, useContextProvider, useTaskQrl,
|
|
1
|
+
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl, isDev, _jsxSplit, _getConstProps, _getVarProps, eventQrl, isServer, useStylesQrl, useServerData, useStore, useContextProvider, useTaskQrl, getLocale, noSerialize, isBrowser, useContext, SkipRender, implicit$FirstArg, withLocale, _wrapProp, _restProps, _fnSignal, createElement } from '@qwik.dev/core';
|
|
2
2
|
import { Fragment } from '@qwik.dev/core/jsx-runtime';
|
|
3
|
-
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isSamePath, c as createLoaderSignal, a as createDocumentHead,
|
|
3
|
+
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isSamePath, c as createLoaderSignal, a as createDocumentHead, b as loadRoute, r as resolveHead, C as CLIENT_DATA_CACHE, d as isSameOrigin, Q as Q_ROUTE, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, t as toUrl, e as clientNavigate, f as toPath, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from './chunks/routing.qwik.mjs';
|
|
4
4
|
import { u as useNavigate, a as useLocation, b as useQwikRouterEnv, C as ContentContext, c as ContentInternalContext, D as DocumentHeadContext, H as HttpStatusContext, R as RouteLocationContext, d as RouteNavigateContext, e as RouteStateContext, f as RouteActionContext, g as RoutePreventNavigateContext, h as useAction, i as useDocumentHead } from './chunks/use-functions.qwik.mjs';
|
|
5
5
|
export { j as useContent, k as useHttpStatus, l as usePreventNavigate$, m as usePreventNavigateQrl } from './chunks/use-functions.qwik.mjs';
|
|
6
6
|
import * as qwikRouterConfig from '@qwik-router-config';
|
|
@@ -366,6 +366,7 @@ const useQwikRouter = (props) => {
|
|
|
366
366
|
throw new Error(`Missing Qwik URL Env Data`);
|
|
367
367
|
}
|
|
368
368
|
const serverHead = useServerData("documentHead");
|
|
369
|
+
const manifestHash = useServerData("containerAttributes")?.["q:manifest-hash"];
|
|
369
370
|
if (env.ev.originalUrl.pathname !== env.ev.url.pathname && !__EXPERIMENTAL__.enableRequestRewrite) {
|
|
370
371
|
throw new Error(`enableRequestRewrite is an experimental feature and is not enabled. Please enable the feature flag by adding \`experimental: ["enableRequestRewrite"]\` to your qwikVite plugin options.`);
|
|
371
372
|
}
|
|
@@ -402,7 +403,7 @@ const useQwikRouter = (props) => {
|
|
|
402
403
|
dest: url,
|
|
403
404
|
scroll: true
|
|
404
405
|
});
|
|
405
|
-
const documentHead = useStore(() => createDocumentHead(serverHead));
|
|
406
|
+
const documentHead = useStore(() => createDocumentHead(serverHead, manifestHash));
|
|
406
407
|
const content = useStore({
|
|
407
408
|
headings: void 0,
|
|
408
409
|
menu: void 0
|
|
@@ -560,9 +561,10 @@ const useQwikRouter = (props) => {
|
|
|
560
561
|
useContextProvider(RouteStateContext, loaderState);
|
|
561
562
|
useContextProvider(RouteActionContext, actionState);
|
|
562
563
|
useContextProvider(RoutePreventNavigateContext, registerPreventNav);
|
|
563
|
-
useTaskQrl(
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
useTaskQrl(
|
|
565
|
+
/* @__PURE__ */ inlinedQrl(async ({ track }) => {
|
|
566
|
+
const actionState2 = _captures[0], content2 = _captures[1], contentInternal2 = _captures[2], documentHead2 = _captures[3], env2 = _captures[4], getScroller2 = _captures[5], goto2 = _captures[6], httpStatus2 = _captures[7], loaderState2 = _captures[8], loadersObject2 = _captures[9], navResolver2 = _captures[10], props2 = _captures[11], routeInternal2 = _captures[12], routeLocation2 = _captures[13], routeLocationTarget2 = _captures[14], serverHead2 = _captures[15];
|
|
567
|
+
const container2 = _getContextContainer();
|
|
566
568
|
const navigation = track(routeInternal2);
|
|
567
569
|
const action = track(actionState2);
|
|
568
570
|
const locale = getLocale("");
|
|
@@ -571,8 +573,7 @@ const useQwikRouter = (props) => {
|
|
|
571
573
|
const replaceState = navigation.replaceState;
|
|
572
574
|
let trackUrl;
|
|
573
575
|
let clientPageData;
|
|
574
|
-
let loadedRoute
|
|
575
|
-
let container2;
|
|
576
|
+
let loadedRoute;
|
|
576
577
|
if (isServer) {
|
|
577
578
|
trackUrl = new URL(navigation.dest, routeLocation2.url);
|
|
578
579
|
loadedRoute = env2.loadedRoute;
|
|
@@ -587,7 +588,6 @@ const useQwikRouter = (props) => {
|
|
|
587
588
|
trackUrl.pathname += "/";
|
|
588
589
|
}
|
|
589
590
|
let loadRoutePromise = loadRoute(qwikRouterConfig.routes, qwikRouterConfig.cacheModules, trackUrl.pathname);
|
|
590
|
-
container2 = _getContextContainer();
|
|
591
591
|
const pageData = clientPageData = await loadClientData(trackUrl, {
|
|
592
592
|
action,
|
|
593
593
|
clearCache: true
|
|
@@ -620,271 +620,267 @@ const useQwikRouter = (props) => {
|
|
|
620
620
|
return;
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
623
|
+
const { $routeName$, $params$, $mods$, $menu$, $notFound$ } = loadedRoute;
|
|
624
|
+
const contentModules = $mods$;
|
|
625
|
+
if ($notFound$) {
|
|
626
|
+
httpStatus2.value = {
|
|
627
|
+
status: 404,
|
|
628
|
+
message: "Not Found"
|
|
629
|
+
};
|
|
630
|
+
} else {
|
|
631
|
+
httpStatus2.value = {
|
|
632
|
+
status: clientPageData?.status ?? 200,
|
|
633
|
+
message: clientPageData?.statusMessage ?? ""
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
const pageModule = contentModules[contentModules.length - 1];
|
|
637
|
+
if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
|
|
638
|
+
trackUrl.search = navigation.dest.search;
|
|
639
|
+
}
|
|
640
|
+
let shouldForcePrevUrl = false;
|
|
641
|
+
let shouldForceUrl = false;
|
|
642
|
+
let shouldForceParams = false;
|
|
643
|
+
if (!isSamePath(trackUrl, prevUrl)) {
|
|
644
|
+
if (_hasStoreEffects(routeLocation2, "prevUrl")) {
|
|
645
|
+
shouldForcePrevUrl = true;
|
|
636
646
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
647
|
+
routeLocationTarget2.prevUrl = prevUrl;
|
|
648
|
+
}
|
|
649
|
+
if (routeLocationTarget2.url !== trackUrl) {
|
|
650
|
+
if (_hasStoreEffects(routeLocation2, "url")) {
|
|
651
|
+
shouldForceUrl = true;
|
|
640
652
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
shouldForcePrevUrl = true;
|
|
647
|
-
}
|
|
648
|
-
routeLocationTarget2.prevUrl = prevUrl;
|
|
653
|
+
routeLocationTarget2.url = trackUrl;
|
|
654
|
+
}
|
|
655
|
+
if (routeLocationTarget2.params !== $params$) {
|
|
656
|
+
if (_hasStoreEffects(routeLocation2, "params")) {
|
|
657
|
+
shouldForceParams = true;
|
|
649
658
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
659
|
+
routeLocationTarget2.params = $params$;
|
|
660
|
+
}
|
|
661
|
+
routeInternal2.untrackedValue = {
|
|
662
|
+
type: navType,
|
|
663
|
+
dest: trackUrl
|
|
664
|
+
};
|
|
665
|
+
const resolvedHead = resolveHead(clientPageData, routeLocation2, contentModules, locale, serverHead2);
|
|
666
|
+
content2.headings = pageModule.headings;
|
|
667
|
+
content2.menu = $menu$;
|
|
668
|
+
contentInternal2.untrackedValue = noSerialize(contentModules);
|
|
669
|
+
documentHead2.links = resolvedHead.links;
|
|
670
|
+
documentHead2.meta = resolvedHead.meta;
|
|
671
|
+
documentHead2.styles = resolvedHead.styles;
|
|
672
|
+
documentHead2.scripts = resolvedHead.scripts;
|
|
673
|
+
documentHead2.title = resolvedHead.title;
|
|
674
|
+
documentHead2.frontmatter = resolvedHead.frontmatter;
|
|
675
|
+
if (isBrowser) {
|
|
676
|
+
let scrollState;
|
|
677
|
+
if (navType === "popstate") {
|
|
678
|
+
scrollState = getScrollHistory();
|
|
655
679
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
routeLocationTarget2.params = $params$;
|
|
680
|
+
const scroller = await getScroller2();
|
|
681
|
+
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
|
|
682
|
+
document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
661
683
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
documentHead2.styles = resolvedHead.styles;
|
|
673
|
-
documentHead2.scripts = resolvedHead.scripts;
|
|
674
|
-
documentHead2.title = resolvedHead.title;
|
|
675
|
-
documentHead2.frontmatter = resolvedHead.frontmatter;
|
|
676
|
-
if (isBrowser) {
|
|
677
|
-
let scrollState;
|
|
678
|
-
if (navType === "popstate") {
|
|
679
|
-
scrollState = getScrollHistory();
|
|
680
|
-
}
|
|
681
|
-
const scroller = await getScroller2();
|
|
682
|
-
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
|
|
683
|
-
document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
684
|
-
}
|
|
685
|
-
const loaders = clientPageData?.loaders;
|
|
686
|
-
if (loaders) {
|
|
687
|
-
const container3 = _getContextContainer();
|
|
688
|
-
for (const [key, value] of Object.entries(loaders)) {
|
|
689
|
-
const signal = loaderState2[key];
|
|
690
|
-
const awaitedValue = await value;
|
|
691
|
-
loadersObject2[key] = awaitedValue;
|
|
692
|
-
if (!signal) {
|
|
693
|
-
loaderState2[key] = createLoaderSignal(loadersObject2, key, trackUrl, DEFAULT_LOADERS_SERIALIZATION_STRATEGY, container3);
|
|
694
|
-
} else {
|
|
695
|
-
signal.invalidate();
|
|
696
|
-
}
|
|
684
|
+
const loaders = clientPageData?.loaders;
|
|
685
|
+
if (loaders) {
|
|
686
|
+
for (const [key, value] of Object.entries(loaders)) {
|
|
687
|
+
const signal = loaderState2[key];
|
|
688
|
+
const awaitedValue = await value;
|
|
689
|
+
loadersObject2[key] = awaitedValue;
|
|
690
|
+
if (!signal) {
|
|
691
|
+
loaderState2[key] = createLoaderSignal(loadersObject2, key, trackUrl, DEFAULT_LOADERS_SERIALIZATION_STRATEGY, container2);
|
|
692
|
+
} else {
|
|
693
|
+
signal.invalidate();
|
|
697
694
|
}
|
|
698
695
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
696
|
+
}
|
|
697
|
+
CLIENT_DATA_CACHE.clear();
|
|
698
|
+
if (!window._qRouterSPA) {
|
|
699
|
+
window._qRouterSPA = true;
|
|
700
|
+
history.scrollRestoration = "manual";
|
|
701
|
+
window.addEventListener("popstate", () => {
|
|
702
|
+
window._qRouterScrollEnabled = false;
|
|
703
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
704
|
+
goto2(location.href, {
|
|
705
|
+
type: "popstate"
|
|
709
706
|
});
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
707
|
+
});
|
|
708
|
+
window.removeEventListener("popstate", window._qRouterInitPopstate);
|
|
709
|
+
window._qRouterInitPopstate = void 0;
|
|
710
|
+
if (!window._qRouterHistoryPatch) {
|
|
711
|
+
window._qRouterHistoryPatch = true;
|
|
712
|
+
const pushState = history.pushState;
|
|
713
|
+
const replaceState2 = history.replaceState;
|
|
714
|
+
const prepareState = (state) => {
|
|
715
|
+
if (state === null || typeof state === "undefined") {
|
|
716
|
+
state = {};
|
|
717
|
+
} else if (state?.constructor !== Object) {
|
|
718
|
+
state = {
|
|
719
|
+
_data: state
|
|
720
|
+
};
|
|
721
|
+
if (isDev) {
|
|
722
|
+
console.warn("In a Qwik SPA context, `history.state` is used to store scroll state. Direct calls to `pushState()` and `replaceState()` must supply an actual Object type. We need to be able to automatically attach the scroll state to your state object. A new state object has been created, your data has been moved to: `history.state._data`");
|
|
726
723
|
}
|
|
727
|
-
state._qRouterScroll = state._qRouterScroll || currentScrollState(scroller);
|
|
728
|
-
return state;
|
|
729
|
-
};
|
|
730
|
-
history.pushState = (state, title, url2) => {
|
|
731
|
-
state = prepareState(state);
|
|
732
|
-
return pushState.call(history, state, title, url2);
|
|
733
|
-
};
|
|
734
|
-
history.replaceState = (state, title, url2) => {
|
|
735
|
-
state = prepareState(state);
|
|
736
|
-
return replaceState2.call(history, state, title, url2);
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
document.addEventListener("click", (event) => {
|
|
740
|
-
if (event.defaultPrevented) {
|
|
741
|
-
return;
|
|
742
724
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
725
|
+
state._qRouterScroll = state._qRouterScroll || currentScrollState(scroller);
|
|
726
|
+
return state;
|
|
727
|
+
};
|
|
728
|
+
history.pushState = (state, title, url2) => {
|
|
729
|
+
state = prepareState(state);
|
|
730
|
+
return pushState.call(history, state, title, url2);
|
|
731
|
+
};
|
|
732
|
+
history.replaceState = (state, title, url2) => {
|
|
733
|
+
state = prepareState(state);
|
|
734
|
+
return replaceState2.call(history, state, title, url2);
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
document.addEventListener("click", (event) => {
|
|
738
|
+
if (event.defaultPrevented) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const target = event.target.closest("a[href]");
|
|
742
|
+
if (target && !target.hasAttribute("preventdefault:click")) {
|
|
743
|
+
const href = target.getAttribute("href");
|
|
744
|
+
const prev = new URL(location.href);
|
|
745
|
+
const dest = new URL(href, prev);
|
|
746
|
+
if (isSameOrigin(dest, prev) && isSamePath(dest, prev)) {
|
|
747
|
+
event.preventDefault();
|
|
748
|
+
if (!dest.hash && !dest.href.endsWith("#")) {
|
|
749
|
+
if (dest.href !== prev.href) {
|
|
750
|
+
history.pushState(null, "", dest);
|
|
763
751
|
}
|
|
764
|
-
|
|
752
|
+
window._qRouterScrollEnabled = false;
|
|
753
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
754
|
+
saveScrollHistory({
|
|
755
|
+
...currentScrollState(scroller),
|
|
756
|
+
x: 0,
|
|
757
|
+
y: 0
|
|
758
|
+
});
|
|
759
|
+
location.reload();
|
|
760
|
+
return;
|
|
765
761
|
}
|
|
762
|
+
goto2(target.getAttribute("href"));
|
|
766
763
|
}
|
|
767
|
-
});
|
|
768
|
-
document.removeEventListener("click", window._qRouterInitAnchors);
|
|
769
|
-
window._qRouterInitAnchors = void 0;
|
|
770
|
-
if (!window.navigation) {
|
|
771
|
-
document.addEventListener("visibilitychange", () => {
|
|
772
|
-
if ((window._qRouterScrollEnabled || window._qCityScrollEnabled) && document.visibilityState === "hidden") {
|
|
773
|
-
if (window._qCityScrollEnabled) {
|
|
774
|
-
console.warn('"_qCityScrollEnabled" is deprecated. Use "_qRouterScrollEnabled" instead.');
|
|
775
|
-
}
|
|
776
|
-
const scrollState2 = currentScrollState(scroller);
|
|
777
|
-
saveScrollHistory(scrollState2);
|
|
778
|
-
}
|
|
779
|
-
}, {
|
|
780
|
-
passive: true
|
|
781
|
-
});
|
|
782
|
-
document.removeEventListener("visibilitychange", window._qRouterInitVisibility);
|
|
783
|
-
window._qRouterInitVisibility = void 0;
|
|
784
764
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
window.
|
|
765
|
+
});
|
|
766
|
+
document.removeEventListener("click", window._qRouterInitAnchors);
|
|
767
|
+
window._qRouterInitAnchors = void 0;
|
|
768
|
+
if (!window.navigation) {
|
|
769
|
+
document.addEventListener("visibilitychange", () => {
|
|
770
|
+
if ((window._qRouterScrollEnabled || window._qCityScrollEnabled) && document.visibilityState === "hidden") {
|
|
771
|
+
if (window._qCityScrollEnabled) {
|
|
772
|
+
console.warn('"_qCityScrollEnabled" is deprecated. Use "_qRouterScrollEnabled" instead.');
|
|
773
|
+
}
|
|
791
774
|
const scrollState2 = currentScrollState(scroller);
|
|
792
775
|
saveScrollHistory(scrollState2);
|
|
793
|
-
|
|
794
|
-
}, 200);
|
|
776
|
+
}
|
|
795
777
|
}, {
|
|
796
778
|
passive: true
|
|
797
779
|
});
|
|
798
|
-
removeEventListener("
|
|
799
|
-
window.
|
|
800
|
-
spaInit.resolve();
|
|
780
|
+
document.removeEventListener("visibilitychange", window._qRouterInitVisibility);
|
|
781
|
+
window._qRouterInitVisibility = void 0;
|
|
801
782
|
}
|
|
802
|
-
|
|
803
|
-
window._qRouterScrollEnabled
|
|
783
|
+
window.addEventListener("scroll", () => {
|
|
784
|
+
if (!window._qRouterScrollEnabled && !window._qCityScrollEnabled) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
804
787
|
clearTimeout(window._qRouterScrollDebounce);
|
|
805
|
-
|
|
788
|
+
window._qRouterScrollDebounce = setTimeout(() => {
|
|
806
789
|
const scrollState2 = currentScrollState(scroller);
|
|
807
790
|
saveScrollHistory(scrollState2);
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
return _waitUntilRendered(container2);
|
|
822
|
-
};
|
|
823
|
-
const _waitNextPage = () => {
|
|
824
|
-
if (isServer || props2?.viewTransition === false) {
|
|
825
|
-
return navigate();
|
|
826
|
-
} else {
|
|
827
|
-
const viewTransition = startViewTransition({
|
|
828
|
-
update: navigate,
|
|
829
|
-
types: [
|
|
830
|
-
"qwik-navigation"
|
|
831
|
-
]
|
|
832
|
-
});
|
|
833
|
-
if (!viewTransition) {
|
|
834
|
-
return Promise.resolve();
|
|
835
|
-
}
|
|
836
|
-
return viewTransition.ready;
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
_waitNextPage().catch((err) => {
|
|
840
|
-
navigate();
|
|
841
|
-
throw err;
|
|
842
|
-
}).finally(() => {
|
|
843
|
-
container2.element.setAttribute?.(Q_ROUTE, $routeName$);
|
|
791
|
+
window._qRouterScrollDebounce = void 0;
|
|
792
|
+
}, 200);
|
|
793
|
+
}, {
|
|
794
|
+
passive: true
|
|
795
|
+
});
|
|
796
|
+
removeEventListener("scroll", window._qRouterInitScroll);
|
|
797
|
+
window._qRouterInitScroll = void 0;
|
|
798
|
+
spaInit.resolve();
|
|
799
|
+
}
|
|
800
|
+
if (navType !== "popstate") {
|
|
801
|
+
window._qRouterScrollEnabled = false;
|
|
802
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
803
|
+
if (!navigation.historyUpdated) {
|
|
844
804
|
const scrollState2 = currentScrollState(scroller);
|
|
845
805
|
saveScrollHistory(scrollState2);
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
forceStoreEffects(routeLocation2, "url");
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const navigate = () => {
|
|
809
|
+
if (navigation.historyUpdated) {
|
|
810
|
+
const currentPath = location.pathname + location.search + location.hash;
|
|
811
|
+
const nextPath = toPath(trackUrl);
|
|
812
|
+
if (currentPath !== nextPath) {
|
|
813
|
+
history.replaceState(history.state, "", nextPath);
|
|
855
814
|
}
|
|
856
|
-
|
|
857
|
-
|
|
815
|
+
} else {
|
|
816
|
+
clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
|
|
817
|
+
}
|
|
818
|
+
contentInternal2.trigger();
|
|
819
|
+
return _waitUntilRendered(container2);
|
|
820
|
+
};
|
|
821
|
+
const _waitNextPage = () => {
|
|
822
|
+
if (isServer || props2?.viewTransition === false) {
|
|
823
|
+
return navigate();
|
|
824
|
+
} else {
|
|
825
|
+
const viewTransition = startViewTransition({
|
|
826
|
+
update: navigate,
|
|
827
|
+
types: [
|
|
828
|
+
"qwik-navigation"
|
|
829
|
+
]
|
|
830
|
+
});
|
|
831
|
+
if (!viewTransition) {
|
|
832
|
+
return Promise.resolve();
|
|
858
833
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
834
|
+
return viewTransition.ready;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
_waitNextPage().catch((err) => {
|
|
838
|
+
navigate();
|
|
839
|
+
throw err;
|
|
840
|
+
}).finally(() => {
|
|
841
|
+
container2.element.setAttribute?.(Q_ROUTE, $routeName$);
|
|
842
|
+
const scrollState2 = currentScrollState(scroller);
|
|
843
|
+
saveScrollHistory(scrollState2);
|
|
844
|
+
window._qRouterScrollEnabled = true;
|
|
845
|
+
if (isBrowser) {
|
|
846
|
+
callRestoreScrollOnDocument();
|
|
847
|
+
}
|
|
848
|
+
if (shouldForcePrevUrl) {
|
|
849
|
+
forceStoreEffects(routeLocation2, "prevUrl");
|
|
850
|
+
}
|
|
851
|
+
if (shouldForceUrl) {
|
|
852
|
+
forceStoreEffects(routeLocation2, "url");
|
|
853
|
+
}
|
|
854
|
+
if (shouldForceParams) {
|
|
855
|
+
forceStoreEffects(routeLocation2, "params");
|
|
856
|
+
}
|
|
857
|
+
routeLocation2.isNavigating = false;
|
|
858
|
+
navResolver2.r?.();
|
|
859
|
+
});
|
|
863
860
|
}
|
|
861
|
+
}, "useQwikRouter_useTask_XpalYii770E", [
|
|
862
|
+
actionState,
|
|
863
|
+
content,
|
|
864
|
+
contentInternal,
|
|
865
|
+
documentHead,
|
|
866
|
+
env,
|
|
867
|
+
getScroller,
|
|
868
|
+
goto,
|
|
869
|
+
httpStatus,
|
|
870
|
+
loaderState,
|
|
871
|
+
loadersObject,
|
|
872
|
+
navResolver,
|
|
873
|
+
props,
|
|
874
|
+
routeInternal,
|
|
875
|
+
routeLocation,
|
|
876
|
+
routeLocationTarget,
|
|
877
|
+
serverHead
|
|
878
|
+
]),
|
|
879
|
+
// We should only wait for navigation to complete on the server
|
|
880
|
+
{
|
|
881
|
+
deferUpdates: isServer
|
|
864
882
|
}
|
|
865
|
-
|
|
866
|
-
return run();
|
|
867
|
-
} else {
|
|
868
|
-
run();
|
|
869
|
-
}
|
|
870
|
-
}, "useQwikRouter_useTask_XpalYii770E", [
|
|
871
|
-
actionState,
|
|
872
|
-
content,
|
|
873
|
-
contentInternal,
|
|
874
|
-
documentHead,
|
|
875
|
-
env,
|
|
876
|
-
getScroller,
|
|
877
|
-
goto,
|
|
878
|
-
httpStatus,
|
|
879
|
-
loaderState,
|
|
880
|
-
loadersObject,
|
|
881
|
-
navResolver,
|
|
882
|
-
props,
|
|
883
|
-
routeInternal,
|
|
884
|
-
routeLocation,
|
|
885
|
-
routeLocationTarget,
|
|
886
|
-
serverHead
|
|
887
|
-
]));
|
|
883
|
+
);
|
|
888
884
|
};
|
|
889
885
|
const QwikRouterProvider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
890
886
|
useQwikRouter(props);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Http2ServerRequest } from 'http2';
|
|
2
2
|
import { IncomingMessage } from 'http';
|
|
3
3
|
import { NodeRequestNextFunction } from '@qwik.dev/router/middleware/node';
|
|
4
|
-
import type { QwikCityPlan } from '@qwik.dev/router';
|
|
5
4
|
import type { QwikManifest } from '@qwik.dev/core/optimizer';
|
|
6
|
-
import type { QwikRouterConfig } from '@qwik.dev/router';
|
|
7
5
|
import type { Render } from '@qwik.dev/core/server';
|
|
8
6
|
import type { ServerRenderOptions } from '@qwik.dev/router/middleware/request-handler';
|
|
9
7
|
import { ServerResponse } from 'http';
|
|
@@ -11,10 +9,6 @@ import { ServerResponse } from 'http';
|
|
|
11
9
|
declare interface AwsOpt {
|
|
12
10
|
render: Render;
|
|
13
11
|
manifest?: QwikManifest;
|
|
14
|
-
/** @deprecated Not used */
|
|
15
|
-
qwikRouterConfig?: QwikRouterConfig;
|
|
16
|
-
/** @deprecated Not used */
|
|
17
|
-
qwikCityPlan?: QwikCityPlan;
|
|
18
12
|
}
|
|
19
13
|
|
|
20
14
|
/**
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { createQwikRouter as createQwikRouter$1 } from '@qwik.dev/router/middleware/node';
|
|
2
2
|
|
|
3
3
|
function createQwikRouter(opts) {
|
|
4
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
5
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
6
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
7
|
-
}
|
|
8
4
|
try {
|
|
9
5
|
const { router, staticFile, notFound } = createQwikRouter$1({
|
|
10
6
|
render: opts.render,
|
|
11
|
-
qwikRouterConfig: opts.qwikRouterConfig,
|
|
12
7
|
manifest: opts.manifest,
|
|
13
8
|
static: {
|
|
14
9
|
cacheControl: "public, max-age=31557600"
|
|
@@ -3,10 +3,6 @@ import { requestHandler, isStaticPath, getNotFound } from '@qwik.dev/router/midd
|
|
|
3
3
|
import { parseString } from 'set-cookie-parser';
|
|
4
4
|
|
|
5
5
|
function createQwikRouter(opts) {
|
|
6
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
7
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
8
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
9
|
-
}
|
|
10
6
|
if (opts.manifest) {
|
|
11
7
|
setServerPlatform(opts.manifest);
|
|
12
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { isDev } from '@qwik.dev/core/build';
|
|
1
2
|
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
3
|
import { _TextEncoderStream_polyfill, isStaticPath, getNotFound, mergeHeadersCookies, requestHandler } from '@qwik.dev/router/middleware/request-handler';
|
|
3
4
|
import { join, extname } from 'node:path';
|
|
4
|
-
import { M as MIME_TYPES } from '../../chunks/
|
|
5
|
-
import { isDev } from '@qwik.dev/core/build';
|
|
5
|
+
import { M as MIME_TYPES, n as normalizeRequestUrl } from '../../chunks/url.mjs';
|
|
6
6
|
|
|
7
7
|
function getRequestUrl(request, opts) {
|
|
8
8
|
const url = new URL(request.url);
|
|
@@ -10,13 +10,9 @@ function getRequestUrl(request, opts) {
|
|
|
10
10
|
if (!origin) {
|
|
11
11
|
return url;
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return normalizeRequestUrl(`${url.pathname}${url.search}${url.hash}`, origin);
|
|
14
14
|
}
|
|
15
15
|
function createQwikRouter(opts) {
|
|
16
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
17
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
18
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
19
|
-
}
|
|
20
16
|
globalThis.TextEncoderStream ||= _TextEncoderStream_polyfill;
|
|
21
17
|
if (opts.manifest) {
|
|
22
18
|
setServerPlatform(opts.manifest);
|
|
@@ -3,10 +3,6 @@ import { _TextEncoderStream_polyfill, isStaticPath, mergeHeadersCookies, request
|
|
|
3
3
|
import { isDev } from '@qwik.dev/core/build';
|
|
4
4
|
|
|
5
5
|
function createQwikRouter(opts) {
|
|
6
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
7
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
8
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
9
|
-
}
|
|
10
6
|
try {
|
|
11
7
|
new globalThis.TextEncoderStream();
|
|
12
8
|
} catch {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setServerPlatform } from '@qwik.dev/core/server';
|
|
2
2
|
import { isStaticPath, getNotFound, mergeHeadersCookies, requestHandler } from '@qwik.dev/router/middleware/request-handler';
|
|
3
|
-
import { M as MIME_TYPES } from '../../chunks/
|
|
3
|
+
import { M as MIME_TYPES, n as normalizeRequestUrl } from '../../chunks/url.mjs';
|
|
4
4
|
import { join, fromFileUrl, extname } from 'https://deno.land/std/path/mod.ts';
|
|
5
5
|
import { isDev } from '@qwik.dev/core/build';
|
|
6
6
|
|
|
@@ -10,13 +10,9 @@ function getRequestUrl(request, opts, info) {
|
|
|
10
10
|
if (!origin) {
|
|
11
11
|
return url;
|
|
12
12
|
}
|
|
13
|
-
return
|
|
13
|
+
return normalizeRequestUrl(`${url.pathname}${url.search}${url.hash}`, origin);
|
|
14
14
|
}
|
|
15
15
|
function createQwikRouter(opts) {
|
|
16
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
17
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
18
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
19
|
-
}
|
|
20
16
|
if (opts.manifest) {
|
|
21
17
|
setServerPlatform(opts.manifest);
|
|
22
18
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { createQwikRouter as createQwikRouter$1 } from '@qwik.dev/router/middleware/node';
|
|
2
2
|
|
|
3
3
|
function createQwikRouter(opts) {
|
|
4
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
5
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
6
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
7
|
-
}
|
|
8
4
|
const { staticFile, notFound, router } = createQwikRouter$1({
|
|
9
5
|
render: opts.render,
|
|
10
6
|
manifest: opts.manifest,
|
|
11
|
-
qwikRouterConfig: opts.qwikRouterConfig,
|
|
12
7
|
static: {
|
|
13
8
|
cacheControl: "public, max-age=31557600"
|
|
14
9
|
},
|
|
@@ -3,10 +3,6 @@ import { isStaticPath, mergeHeadersCookies, requestHandler, getNotFound } from '
|
|
|
3
3
|
import { isDev } from '@qwik.dev/core/build';
|
|
4
4
|
|
|
5
5
|
function createQwikRouter(opts) {
|
|
6
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
7
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
8
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
9
|
-
}
|
|
10
6
|
if (opts.manifest) {
|
|
11
7
|
setServerPlatform(opts.manifest);
|
|
12
8
|
}
|
|
@@ -4,7 +4,7 @@ import { isStaticPath, getNotFound, requestHandler } from '@qwik.dev/router/midd
|
|
|
4
4
|
import { createReadStream } from 'node:fs';
|
|
5
5
|
import { join, basename, extname } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import { M as MIME_TYPES } from '../../chunks/
|
|
7
|
+
import { n as normalizeRequestUrl, M as MIME_TYPES } from '../../chunks/url.mjs';
|
|
8
8
|
import { Http2ServerRequest } from 'node:http2';
|
|
9
9
|
|
|
10
10
|
function fallbackOrigin(req) {
|
|
@@ -27,8 +27,7 @@ function isIgnoredError(message = "") {
|
|
|
27
27
|
}
|
|
28
28
|
const invalidHeadersPattern = /^:(method|scheme|authority|path)$/i;
|
|
29
29
|
function normalizeUrl(url, base) {
|
|
30
|
-
|
|
31
|
-
return new URL(url.replace(DOUBLE_SLASH_REG, "/"), base);
|
|
30
|
+
return normalizeRequestUrl(url, base);
|
|
32
31
|
}
|
|
33
32
|
function getUrl(req, origin) {
|
|
34
33
|
return normalizeUrl(req.originalUrl || req.url || "/", origin);
|
|
@@ -126,10 +125,6 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
function createQwikRouter(opts) {
|
|
129
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
130
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
131
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
132
|
-
}
|
|
133
128
|
if (opts.manifest) {
|
|
134
129
|
setServerPlatform(opts.manifest);
|
|
135
130
|
}
|
|
@@ -4,9 +4,7 @@ import type { EnvGetter as EnvGetter_2 } from '@qwik.dev/router/middleware/reque
|
|
|
4
4
|
import type { FailReturn } from '@qwik.dev/router';
|
|
5
5
|
import type { JSXOutput } from '@qwik.dev/core';
|
|
6
6
|
import type { Loader as Loader_2 } from '@qwik.dev/router';
|
|
7
|
-
import type { QwikCityPlan } from '@qwik.dev/router';
|
|
8
7
|
import type { QwikIntrinsicElements } from '@qwik.dev/core';
|
|
9
|
-
import type { QwikRouterConfig } from '@qwik.dev/router';
|
|
10
8
|
import type { Render } from '@qwik.dev/core/server';
|
|
11
9
|
import type { RenderOptions } from '@qwik.dev/core/server';
|
|
12
10
|
import { RequestEvent as RequestEvent_2 } from '@qwik.dev/router/middleware/request-handler';
|
|
@@ -632,7 +630,10 @@ export declare type RequestHandler<PLATFORM = QwikRouterPlatform> = (ev: Request
|
|
|
632
630
|
export declare function requestHandler<T = unknown>(serverRequestEv: ServerRequestEvent<T>, opts: ServerRenderOptions): Promise<QwikRouterRun<T> | null>;
|
|
633
631
|
|
|
634
632
|
/** @public */
|
|
635
|
-
declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter
|
|
633
|
+
declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>> & {
|
|
634
|
+
/** The build's manifest hash, used for per-loader data URLs. Always defined (`'dev'` in dev). */
|
|
635
|
+
readonly manifestHash: string;
|
|
636
|
+
};
|
|
636
637
|
|
|
637
638
|
/** @public */
|
|
638
639
|
export declare interface ResolveSyncValue {
|
|
@@ -715,10 +716,6 @@ declare type ServerErrorCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 5
|
|
|
715
716
|
/** @public */
|
|
716
717
|
export declare interface ServerRenderOptions extends RenderOptions {
|
|
717
718
|
render: Render;
|
|
718
|
-
/** @deprecated Not used */
|
|
719
|
-
qwikCityPlan?: QwikCityPlan;
|
|
720
|
-
/** @deprecated Not used */
|
|
721
|
-
qwikRouterConfig?: QwikRouterConfig;
|
|
722
719
|
/**
|
|
723
720
|
* Protection against cross-site request forgery (CSRF) attacks.
|
|
724
721
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as Q_ROUTE, m as resolveRouteConfig, n as QLOADER_KEY, h as QFN_KEY, j as QACTION_KEY, o as isPromise, k as QDATA_KEY,
|
|
1
|
+
import { Q as Q_ROUTE, m as resolveRouteConfig, n as QLOADER_KEY, h as QFN_KEY, j as QACTION_KEY, o as isPromise, k as QDATA_KEY, b as loadRoute } from '../../chunks/routing.qwik.mjs';
|
|
2
2
|
import { isDev, _UNINITIALIZED, _deserialize, _verifySerializable, _serialize } from '@qwik.dev/core/internal';
|
|
3
3
|
import { inlinedQrl } from '@qwik.dev/core';
|
|
4
4
|
import { R as RedirectMessage, A as AbortMessage } from '../../chunks/redirect-handler.mjs';
|
|
@@ -647,7 +647,7 @@ function createResolveRequestHandlers(deps) {
|
|
|
647
647
|
const routeLoaders = [];
|
|
648
648
|
const routeActions = [];
|
|
649
649
|
const requestHandlers = [];
|
|
650
|
-
const isPageRoute = !!
|
|
650
|
+
const isPageRoute = !!isLastModulePageRoute(route.$mods$);
|
|
651
651
|
if (isInternal) {
|
|
652
652
|
requestHandlers.push(handleQDataRedirect);
|
|
653
653
|
}
|
|
@@ -657,36 +657,36 @@ function createResolveRequestHandlers(deps) {
|
|
|
657
657
|
if (serverPlugins) {
|
|
658
658
|
_resolveRequestHandlers(routeLoaders, routeActions, requestHandlers, serverPlugins, isPageRoute, method);
|
|
659
659
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if (checkOrigin
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
requestHandlers.unshift(csrfCheckMiddleware);
|
|
669
|
-
}
|
|
660
|
+
const routeModules = route.$mods$;
|
|
661
|
+
_resolveRequestHandlers(routeLoaders, routeActions, requestHandlers, routeModules, isPageRoute, method);
|
|
662
|
+
const routeName = route.$routeName$;
|
|
663
|
+
if (checkOrigin && (method === "POST" || method === "PUT" || method === "PATCH" || method === "DELETE")) {
|
|
664
|
+
if (checkOrigin === "lax-proto") {
|
|
665
|
+
requestHandlers.unshift(csrfLaxProtoCheckMiddleware);
|
|
666
|
+
} else {
|
|
667
|
+
requestHandlers.unshift(csrfCheckMiddleware);
|
|
670
668
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
669
|
+
}
|
|
670
|
+
if (isPageRoute) {
|
|
671
|
+
if (method === "POST" || method === "GET") {
|
|
672
|
+
requestHandlers.push(runServerFunction);
|
|
673
|
+
}
|
|
674
|
+
if (!route.$notFound$) {
|
|
675
675
|
requestHandlers.push(fixTrailingSlash);
|
|
676
|
-
if (isInternal) {
|
|
677
|
-
requestHandlers.push(renderQData);
|
|
678
|
-
}
|
|
679
676
|
}
|
|
680
|
-
if (
|
|
681
|
-
requestHandlers.push(
|
|
682
|
-
ev.sharedMap.set(deps.RequestRouteName, routeName);
|
|
683
|
-
});
|
|
684
|
-
requestHandlers.push(actionsMiddleware(routeActions));
|
|
685
|
-
requestHandlers.push(loadersMiddleware(routeLoaders));
|
|
686
|
-
requestHandlers.push(eTagMiddleware(route));
|
|
687
|
-
requestHandlers.push(renderHandler);
|
|
677
|
+
if (isInternal) {
|
|
678
|
+
requestHandlers.push(renderQData);
|
|
688
679
|
}
|
|
689
680
|
}
|
|
681
|
+
if (isPageRoute) {
|
|
682
|
+
requestHandlers.push((ev) => {
|
|
683
|
+
ev.sharedMap.set(deps.RequestRouteName, routeName);
|
|
684
|
+
});
|
|
685
|
+
requestHandlers.push(actionsMiddleware(routeActions));
|
|
686
|
+
requestHandlers.push(loadersMiddleware(routeLoaders));
|
|
687
|
+
requestHandlers.push(eTagMiddleware(route));
|
|
688
|
+
requestHandlers.push(renderHandler);
|
|
689
|
+
}
|
|
690
690
|
return requestHandlers;
|
|
691
691
|
};
|
|
692
692
|
const _resolveRequestHandlers = (routeLoaders, routeActions, requestHandlers, routeModules, collectActions, method) => {
|
|
@@ -1632,9 +1632,15 @@ function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRou
|
|
|
1632
1632
|
});
|
|
1633
1633
|
}
|
|
1634
1634
|
|
|
1635
|
-
let
|
|
1636
|
-
async function
|
|
1637
|
-
|
|
1635
|
+
let qwikRouterConfig;
|
|
1636
|
+
async function getConfig() {
|
|
1637
|
+
if (!qwikRouterConfig) {
|
|
1638
|
+
qwikRouterConfig = await import('@qwik-router-config');
|
|
1639
|
+
}
|
|
1640
|
+
return qwikRouterConfig;
|
|
1641
|
+
}
|
|
1642
|
+
async function loadRequestHandlers(qwikRouterConfig2, pathname, method, checkOrigin, renderFn, isInternal) {
|
|
1643
|
+
const { routes, serverPlugins, cacheModules } = qwikRouterConfig2;
|
|
1638
1644
|
const loadedRoute = await loadRoute(routes, cacheModules, pathname, isInternal);
|
|
1639
1645
|
const requestHandlers = resolveRequestHandlers(serverPlugins, loadedRoute, method, checkOrigin, renderQwikMiddleware(renderFn), isInternal);
|
|
1640
1646
|
return {
|
|
@@ -1644,29 +1650,20 @@ async function loadRequestHandlers(qwikRouterConfig, pathname, method, checkOrig
|
|
|
1644
1650
|
}
|
|
1645
1651
|
async function requestHandler(serverRequestEv, opts) {
|
|
1646
1652
|
const { render, checkOrigin } = opts;
|
|
1647
|
-
|
|
1648
|
-
if (!qwikRouterConfig) {
|
|
1649
|
-
if (!qwikRouterConfigActual) {
|
|
1650
|
-
qwikRouterConfigActual = await import('@qwik-router-config');
|
|
1651
|
-
}
|
|
1652
|
-
qwikRouterConfig = qwikRouterConfigActual;
|
|
1653
|
-
}
|
|
1654
|
-
if (!qwikRouterConfig) {
|
|
1655
|
-
throw new Error("qwikRouterConfig is required.");
|
|
1656
|
-
}
|
|
1653
|
+
const config = await getConfig();
|
|
1657
1654
|
const { pathname, isInternal } = getRouteMatchPathname(serverRequestEv.url.pathname);
|
|
1658
1655
|
if (pathname === "/.well-known" || pathname.startsWith("/.well-known/")) {
|
|
1659
1656
|
return null;
|
|
1660
1657
|
}
|
|
1661
|
-
const { loadedRoute, requestHandlers } = await loadRequestHandlers(
|
|
1662
|
-
if (
|
|
1658
|
+
const { loadedRoute, requestHandlers } = await loadRequestHandlers(config, pathname, serverRequestEv.request.method, checkOrigin ?? true, render, isInternal);
|
|
1659
|
+
if (config.fallthrough && loadedRoute.$notFound$) {
|
|
1663
1660
|
return null;
|
|
1664
1661
|
}
|
|
1665
1662
|
const rebuildRouteInfo = async (url) => {
|
|
1666
1663
|
const { pathname: pathname2 } = getRouteMatchPathname(url.pathname);
|
|
1667
|
-
return loadRequestHandlers(
|
|
1664
|
+
return loadRequestHandlers(config, pathname2, serverRequestEv.request.method, checkOrigin ?? true, render, isInternal);
|
|
1668
1665
|
};
|
|
1669
|
-
return runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo,
|
|
1666
|
+
return runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, config.basePathname);
|
|
1670
1667
|
}
|
|
1671
1668
|
|
|
1672
1669
|
const notFounds = [
|
|
@@ -9,10 +9,6 @@ const VERCEL_SKEW_PROTECTION_ENABLED = "VERCEL_SKEW_PROTECTION_ENABLED";
|
|
|
9
9
|
const VERCEL_DEPLOYMENT_ID = "VERCEL_DEPLOYMENT_ID";
|
|
10
10
|
const BASE_URL = "BASE_URL";
|
|
11
11
|
function createQwikRouter(opts) {
|
|
12
|
-
if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
|
|
13
|
-
console.warn("qwikCityPlan is deprecated. Simply remove it.");
|
|
14
|
-
opts.qwikRouterConfig = opts.qwikCityPlan;
|
|
15
|
-
}
|
|
16
12
|
if (opts.manifest) {
|
|
17
13
|
setServerPlatform(opts.manifest);
|
|
18
14
|
}
|
package/lib/vite/index.mjs
CHANGED
|
@@ -1608,10 +1608,10 @@ function isBundlePartOfRoute(bundle, routeAndLayoutPaths) {
|
|
|
1608
1608
|
if (!bundle.origins) {
|
|
1609
1609
|
return false;
|
|
1610
1610
|
}
|
|
1611
|
-
|
|
1611
|
+
return bundle.origins.some((bundleOrigin) => {
|
|
1612
1612
|
const originPath = removeExtension(bundleOrigin);
|
|
1613
1613
|
return routeAndLayoutPaths.some((path) => path.endsWith(originPath));
|
|
1614
|
-
}
|
|
1614
|
+
});
|
|
1615
1615
|
}
|
|
1616
1616
|
function getRouteImports(routes, manifest) {
|
|
1617
1617
|
const result = {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/router",
|
|
3
3
|
"description": "The router for Qwik.",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.31",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@azure/functions": "3.5.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsm": "2.3.0",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
42
|
"uvu": "0.5.6",
|
|
43
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
43
|
+
"@qwik.dev/core": "2.0.0-beta.31"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"main": "./lib/index.qwik.mjs",
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"vite": ">=6 <9",
|
|
172
|
-
"@qwik.dev/core": "^2.0.0-beta.
|
|
172
|
+
"@qwik.dev/core": "^2.0.0-beta.31"
|
|
173
173
|
},
|
|
174
174
|
"publishConfig": {
|
|
175
175
|
"access": "public"
|