@qwik.dev/router 2.0.0-beta.6 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +161 -48
- package/lib/index.qwik.cjs +80 -15
- package/lib/index.qwik.mjs +81 -16
- package/lib/middleware/azure-swa/index.mjs +4 -3
- package/lib/middleware/request-handler/index.d.ts +38 -43
- package/lib/vite/index.cjs +558 -311
- package/lib/vite/index.mjs +558 -311
- package/package.json +15 -17
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from "@qwik.dev/core/jsx-runtime";
|
|
2
|
-
import { component$, useErrorBoundary, useOnWindow, $, Slot, createAsyncComputed$, isBrowser, createContextId, implicit$FirstArg, useContext, useVisibleTask$, noSerialize, useServerData, useSignal, untrack, sync$, isDev, withLocale, event$, useStyles$, isServer, useStore, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender } from "@qwik.dev/core";
|
|
2
|
+
import { component$, useErrorBoundary, useOnWindow, $, Slot, createAsyncComputed$, isBrowser, createContextId, implicit$FirstArg, useContext, useVisibleTask$, noSerialize, useServerData, useSignal, untrack, sync$, isDev, withLocale, event$, useStyles$, isServer, useStore, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender, createElement } from "@qwik.dev/core";
|
|
3
3
|
import { p } from "@qwik.dev/core/preloader";
|
|
4
4
|
import { _deserialize, _UNINITIALIZED, _getContextContainer, SerializerSymbol, _getContextElement, _getQContainerElement, _waitUntilRendered, _resolveContextWithoutSequentialScope, _getContextEvent, _serialize } from "@qwik.dev/core/internal";
|
|
5
5
|
import * as qwikRouterConfig from "@qwik-router-config";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { z as z2 } from "zod";
|
|
8
8
|
import swRegister from "@qwik-router-sw-register";
|
|
9
|
+
import { renderToStream } from "@qwik.dev/core/server";
|
|
9
10
|
const ErrorBoundary = component$((props) => {
|
|
10
11
|
const store2 = useErrorBoundary();
|
|
11
12
|
useOnWindow("qerror", $((e) => {
|
|
@@ -348,8 +349,8 @@ const Link = component$((props) => {
|
|
|
348
349
|
children: /* @__PURE__ */ jsx(Slot, {})
|
|
349
350
|
});
|
|
350
351
|
});
|
|
351
|
-
const resolveHead = (endpoint, routeLocation, contentModules, locale) => {
|
|
352
|
-
const head = createDocumentHead();
|
|
352
|
+
const resolveHead = (endpoint, routeLocation, contentModules, locale, defaults) => {
|
|
353
|
+
const head = createDocumentHead(defaults);
|
|
353
354
|
const getData = (loaderOrAction) => {
|
|
354
355
|
const id = loaderOrAction.__id;
|
|
355
356
|
if (loaderOrAction.__brand === "server_loader") {
|
|
@@ -405,13 +406,23 @@ const mergeArray = (existingArr, newArr) => {
|
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
408
|
};
|
|
408
|
-
const createDocumentHead = () => ({
|
|
409
|
-
title: "",
|
|
410
|
-
meta: [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
409
|
+
const createDocumentHead = (defaults) => ({
|
|
410
|
+
title: defaults?.title || "",
|
|
411
|
+
meta: [
|
|
412
|
+
...defaults?.meta || []
|
|
413
|
+
],
|
|
414
|
+
links: [
|
|
415
|
+
...defaults?.links || []
|
|
416
|
+
],
|
|
417
|
+
styles: [
|
|
418
|
+
...defaults?.styles || []
|
|
419
|
+
],
|
|
420
|
+
scripts: [
|
|
421
|
+
...defaults?.scripts || []
|
|
422
|
+
],
|
|
423
|
+
frontmatter: {
|
|
424
|
+
...defaults?.frontmatter
|
|
425
|
+
}
|
|
415
426
|
});
|
|
416
427
|
function matchRoute(route, path) {
|
|
417
428
|
const routeIdx = startIdxSkipSlash(route);
|
|
@@ -823,7 +834,7 @@ const preventNav = {};
|
|
|
823
834
|
const internalState = {
|
|
824
835
|
navCount: 0
|
|
825
836
|
};
|
|
826
|
-
const
|
|
837
|
+
const useQwikRouter = (props) => {
|
|
827
838
|
useStyles$(`
|
|
828
839
|
@layer qwik {
|
|
829
840
|
@supports selector(html:active-view-transition-type(type)) {
|
|
@@ -844,6 +855,7 @@ const QwikRouterProvider = component$((props) => {
|
|
|
844
855
|
if (!urlEnv) {
|
|
845
856
|
throw new Error(`Missing Qwik URL Env Data`);
|
|
846
857
|
}
|
|
858
|
+
const serverHead = useServerData("documentHead");
|
|
847
859
|
if (isServer) {
|
|
848
860
|
if (env.ev.originalUrl.pathname !== env.ev.url.pathname && !__EXPERIMENTAL__.enableRequestRewrite) {
|
|
849
861
|
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.`);
|
|
@@ -883,7 +895,7 @@ const QwikRouterProvider = component$((props) => {
|
|
|
883
895
|
replaceState: false,
|
|
884
896
|
scroll: true
|
|
885
897
|
});
|
|
886
|
-
const documentHead = useStore(createDocumentHead);
|
|
898
|
+
const documentHead = useStore(() => createDocumentHead(serverHead));
|
|
887
899
|
const content = useStore({
|
|
888
900
|
headings: void 0,
|
|
889
901
|
menu: void 0
|
|
@@ -1088,7 +1100,7 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1088
1100
|
type: navType,
|
|
1089
1101
|
dest: trackUrl
|
|
1090
1102
|
};
|
|
1091
|
-
const resolvedHead = resolveHead(clientPageData, routeLocation, contentModules, locale);
|
|
1103
|
+
const resolvedHead = resolveHead(clientPageData, routeLocation, contentModules, locale, serverHead);
|
|
1092
1104
|
content.headings = pageModule.headings;
|
|
1093
1105
|
content.menu = menu;
|
|
1094
1106
|
contentInternal.value = noSerialize(contentModules);
|
|
@@ -1236,7 +1248,7 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1236
1248
|
return _waitUntilRendered(elm);
|
|
1237
1249
|
};
|
|
1238
1250
|
const _waitNextPage = () => {
|
|
1239
|
-
if (isServer || props
|
|
1251
|
+
if (isServer || props?.viewTransition === false) {
|
|
1240
1252
|
return navigate();
|
|
1241
1253
|
} else {
|
|
1242
1254
|
const viewTransition = startViewTransition({
|
|
@@ -1272,10 +1284,13 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1272
1284
|
run();
|
|
1273
1285
|
}
|
|
1274
1286
|
});
|
|
1287
|
+
};
|
|
1288
|
+
const QwikRouterProvider = component$((props) => {
|
|
1289
|
+
useQwikRouter(props);
|
|
1275
1290
|
return /* @__PURE__ */ jsx(Slot, {});
|
|
1276
1291
|
});
|
|
1277
1292
|
const QwikCityProvider = QwikRouterProvider;
|
|
1278
|
-
const
|
|
1293
|
+
const useQwikMockRouter = (props) => {
|
|
1279
1294
|
const urlEnv = props.url ?? "http://localhost/";
|
|
1280
1295
|
const url = new URL(urlEnv);
|
|
1281
1296
|
const routeLocation = useStore({
|
|
@@ -1313,6 +1328,9 @@ const QwikRouterMockProvider = component$((props) => {
|
|
|
1313
1328
|
useContextProvider(RouteStateContext, loaderState);
|
|
1314
1329
|
useContextProvider(RouteActionContext, actionState);
|
|
1315
1330
|
useContextProvider(RouteInternalContext, routeInternal);
|
|
1331
|
+
};
|
|
1332
|
+
const QwikRouterMockProvider = component$((props) => {
|
|
1333
|
+
useQwikMockRouter(props);
|
|
1316
1334
|
return /* @__PURE__ */ jsx(Slot, {});
|
|
1317
1335
|
});
|
|
1318
1336
|
const QwikCityMockProvider = QwikRouterMockProvider;
|
|
@@ -1654,7 +1672,7 @@ const zodQrl = (qrl) => {
|
|
|
1654
1672
|
}
|
|
1655
1673
|
});
|
|
1656
1674
|
const data = inputData ?? await ev.parseBody();
|
|
1657
|
-
const result = await schema.safeParseAsync(data);
|
|
1675
|
+
const result = await withLocale(ev.locale(), () => schema.safeParseAsync(data));
|
|
1658
1676
|
if (result.success) {
|
|
1659
1677
|
return result;
|
|
1660
1678
|
} else {
|
|
@@ -1963,7 +1981,52 @@ function omitProps(obj, keys) {
|
|
|
1963
1981
|
}
|
|
1964
1982
|
return omittedObj;
|
|
1965
1983
|
}
|
|
1984
|
+
const createRenderer = (getOptions) => {
|
|
1985
|
+
return (opts) => {
|
|
1986
|
+
const { jsx: jsx2, options } = getOptions(opts);
|
|
1987
|
+
return renderToStream(jsx2, options);
|
|
1988
|
+
};
|
|
1989
|
+
};
|
|
1990
|
+
const DocumentHeadTags = component$((props) => {
|
|
1991
|
+
let head = useDocumentHead();
|
|
1992
|
+
if (props) {
|
|
1993
|
+
head = {
|
|
1994
|
+
...head,
|
|
1995
|
+
...props
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
1999
|
+
children: [
|
|
2000
|
+
head.title && /* @__PURE__ */ jsx("title", {
|
|
2001
|
+
children: head.title
|
|
2002
|
+
}),
|
|
2003
|
+
head.meta.map((m) => /* @__PURE__ */ jsx("meta", {
|
|
2004
|
+
...m
|
|
2005
|
+
})),
|
|
2006
|
+
head.links.map((l) => /* @__PURE__ */ jsx("link", {
|
|
2007
|
+
...l
|
|
2008
|
+
})),
|
|
2009
|
+
head.styles.map((s) => {
|
|
2010
|
+
const props2 = s.props || s;
|
|
2011
|
+
return /* @__PURE__ */ createElement("style", {
|
|
2012
|
+
...props2,
|
|
2013
|
+
dangerouslySetInnerHTML: s.style || props2.dangerouslySetInnerHTML,
|
|
2014
|
+
key: s.key
|
|
2015
|
+
});
|
|
2016
|
+
}),
|
|
2017
|
+
head.scripts.map((s) => {
|
|
2018
|
+
const props2 = s.props || s;
|
|
2019
|
+
return /* @__PURE__ */ createElement("script", {
|
|
2020
|
+
...props2,
|
|
2021
|
+
dangerouslySetInnerHTML: s.script || props2.dangerouslySetInnerHTML,
|
|
2022
|
+
key: s.key
|
|
2023
|
+
});
|
|
2024
|
+
})
|
|
2025
|
+
]
|
|
2026
|
+
});
|
|
2027
|
+
});
|
|
1966
2028
|
export {
|
|
2029
|
+
DocumentHeadTags,
|
|
1967
2030
|
ErrorBoundary,
|
|
1968
2031
|
Form,
|
|
1969
2032
|
Link,
|
|
@@ -1975,6 +2038,7 @@ export {
|
|
|
1975
2038
|
QwikRouterProvider,
|
|
1976
2039
|
RouterOutlet,
|
|
1977
2040
|
ServiceWorkerRegister,
|
|
2041
|
+
createRenderer,
|
|
1978
2042
|
globalAction$,
|
|
1979
2043
|
globalActionQrl,
|
|
1980
2044
|
omitProps,
|
|
@@ -1991,6 +2055,7 @@ export {
|
|
|
1991
2055
|
useNavigate,
|
|
1992
2056
|
usePreventNavigate$,
|
|
1993
2057
|
usePreventNavigateQrl,
|
|
2058
|
+
useQwikRouter,
|
|
1994
2059
|
valibot$,
|
|
1995
2060
|
valibotQrl,
|
|
1996
2061
|
validator$,
|
|
@@ -24,9 +24,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// node_modules/.pnpm/set-cookie-parser@2.
|
|
27
|
+
// node_modules/.pnpm/set-cookie-parser@2.7.1/node_modules/set-cookie-parser/lib/set-cookie.js
|
|
28
28
|
var require_set_cookie = __commonJS({
|
|
29
|
-
"node_modules/.pnpm/set-cookie-parser@2.
|
|
29
|
+
"node_modules/.pnpm/set-cookie-parser@2.7.1/node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
|
|
30
30
|
"use strict";
|
|
31
31
|
var defaultParseOptions = {
|
|
32
32
|
decodeValues: true,
|
|
@@ -69,6 +69,8 @@ var require_set_cookie = __commonJS({
|
|
|
69
69
|
cookie.httpOnly = true;
|
|
70
70
|
} else if (key === "samesite") {
|
|
71
71
|
cookie.sameSite = value2;
|
|
72
|
+
} else if (key === "partitioned") {
|
|
73
|
+
cookie.partitioned = true;
|
|
72
74
|
} else {
|
|
73
75
|
cookie[key] = value2;
|
|
74
76
|
}
|
|
@@ -116,7 +118,6 @@ var require_set_cookie = __commonJS({
|
|
|
116
118
|
if (!Array.isArray(input)) {
|
|
117
119
|
input = [input];
|
|
118
120
|
}
|
|
119
|
-
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
120
121
|
if (!options.map) {
|
|
121
122
|
return input.filter(isNonEmptyString).map(function(str) {
|
|
122
123
|
return parseString2(str, options);
|
|
@@ -215,10 +215,7 @@ declare interface DocumentHeadProps extends RouteLocation {
|
|
|
215
215
|
declare interface DocumentHeadValue<FrontMatter extends Record<string, any> = Record<string, unknown>> {
|
|
216
216
|
/** Sets `document.title`. */
|
|
217
217
|
readonly title?: string;
|
|
218
|
-
/**
|
|
219
|
-
* Used to manually set meta tags in the head. Additionally, the `data` property could be used to
|
|
220
|
-
* set arbitrary data which the `<head>` component could later use to generate `<meta>` tags.
|
|
221
|
-
*/
|
|
218
|
+
/** Used to manually set meta tags in the head. */
|
|
222
219
|
readonly meta?: readonly DocumentMeta[];
|
|
223
220
|
/** Used to manually append `<link>` elements to the `<head>`. */
|
|
224
221
|
readonly links?: readonly DocumentLink[];
|
|
@@ -235,50 +232,48 @@ declare interface DocumentHeadValue<FrontMatter extends Record<string, any> = Re
|
|
|
235
232
|
}
|
|
236
233
|
|
|
237
234
|
/** @public */
|
|
238
|
-
declare
|
|
239
|
-
as?: string;
|
|
240
|
-
crossorigin?: string;
|
|
241
|
-
disabled?: boolean;
|
|
242
|
-
href?: string;
|
|
243
|
-
hreflang?: string;
|
|
244
|
-
id?: string;
|
|
245
|
-
imagesizes?: string;
|
|
246
|
-
imagesrcset?: string;
|
|
247
|
-
integrity?: string;
|
|
248
|
-
media?: string;
|
|
249
|
-
prefetch?: string;
|
|
250
|
-
referrerpolicy?: string;
|
|
251
|
-
rel?: string;
|
|
252
|
-
sizes?: string;
|
|
253
|
-
title?: string;
|
|
254
|
-
type?: string;
|
|
255
|
-
key?: string;
|
|
256
|
-
}
|
|
235
|
+
declare type DocumentLink = QwikIntrinsicElements['link'];
|
|
257
236
|
|
|
258
237
|
/** @public */
|
|
259
|
-
declare
|
|
260
|
-
readonly content?: string;
|
|
261
|
-
readonly httpEquiv?: string;
|
|
262
|
-
readonly name?: string;
|
|
263
|
-
readonly property?: string;
|
|
264
|
-
readonly key?: string;
|
|
265
|
-
readonly itemprop?: string;
|
|
266
|
-
readonly media?: string;
|
|
267
|
-
}
|
|
238
|
+
declare type DocumentMeta = QwikIntrinsicElements['meta'];
|
|
268
239
|
|
|
269
|
-
/** @
|
|
270
|
-
declare
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
240
|
+
/** @public */
|
|
241
|
+
declare type DocumentScript = ((Omit<QwikIntrinsicElements['script'], 'dangerouslySetInnerHTML'> & {
|
|
242
|
+
props?: never;
|
|
243
|
+
}) | {
|
|
244
|
+
key?: string;
|
|
245
|
+
/**
|
|
246
|
+
* The props of the script element. @deprecated Prefer setting the properties directly instead
|
|
247
|
+
* of using this property.
|
|
248
|
+
*/
|
|
249
|
+
props: Readonly<QwikIntrinsicElements['script']>;
|
|
250
|
+
}) & ({
|
|
251
|
+
/** The inline script content. */
|
|
252
|
+
script?: string;
|
|
253
|
+
dangerouslySetInnerHTML?: never;
|
|
254
|
+
} | {
|
|
255
|
+
dangerouslySetInnerHTML?: string;
|
|
256
|
+
script?: never;
|
|
257
|
+
});
|
|
275
258
|
|
|
276
259
|
/** @public */
|
|
277
|
-
declare
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
260
|
+
declare type DocumentStyle = Readonly<((Omit<QwikIntrinsicElements['style'], 'dangerouslySetInnerHTML'> & {
|
|
261
|
+
props?: never;
|
|
262
|
+
}) | {
|
|
263
|
+
key?: string;
|
|
264
|
+
/**
|
|
265
|
+
* The props of the style element. @deprecated Prefer setting the properties directly
|
|
266
|
+
* instead of using this property.
|
|
267
|
+
*/
|
|
268
|
+
props: Readonly<QwikIntrinsicElements['style']>;
|
|
269
|
+
}) & ({
|
|
270
|
+
/** The inline style content. */
|
|
271
|
+
style?: string;
|
|
272
|
+
dangerouslySetInnerHTML?: never;
|
|
273
|
+
} | {
|
|
274
|
+
dangerouslySetInnerHTML?: string;
|
|
275
|
+
style?: never;
|
|
276
|
+
})>;
|
|
282
277
|
|
|
283
278
|
/** @public */
|
|
284
279
|
export declare interface EnvGetter {
|