@qwik.dev/router 2.0.0-beta.3 → 2.0.0-beta.30
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/adapters/static/vite.d.ts +1 -1
- package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
- package/lib/adapters/azure-swa/vite/index.mjs +39 -44
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.mjs +6 -7
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.mjs +6 -7
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.mjs +23 -32
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.mjs +13 -9
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +22 -36
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/node-server/vite/index.mjs +6 -7
- package/lib/adapters/shared/vite/index.d.ts +7 -19
- package/lib/adapters/shared/vite/index.mjs +244 -233
- package/lib/adapters/ssg/vite/index.d.ts +13 -0
- package/lib/adapters/ssg/vite/index.mjs +17 -0
- package/lib/adapters/vercel-edge/vite/index.d.ts +3 -3
- package/lib/adapters/vercel-edge/vite/index.mjs +33 -19
- package/lib/chunks/deepFreeze.qwik.mjs +18 -0
- package/lib/chunks/error-handler.mjs +57 -0
- package/lib/chunks/fs.mjs +144 -0
- package/lib/chunks/http-error.qwik.mjs +35 -0
- package/lib/chunks/mime-types.mjs +52 -0
- package/lib/chunks/not-found-wrapper.qwik.mjs +25 -0
- package/lib/chunks/pathname.mjs +105 -0
- package/lib/chunks/redirect-handler.mjs +6 -0
- package/lib/chunks/routing.qwik.mjs +820 -0
- package/lib/chunks/system.mjs +333 -0
- package/lib/chunks/use-functions.qwik.mjs +35 -0
- package/lib/chunks/worker-thread.qwik.mjs +2572 -0
- package/lib/index.d.ts +358 -141
- package/lib/index.qwik.mjs +865 -1156
- package/lib/middleware/aws-lambda/index.d.ts +3 -2
- package/lib/middleware/aws-lambda/index.mjs +15 -13
- package/lib/middleware/azure-swa/index.mjs +17 -218
- package/lib/middleware/bun/index.d.ts +11 -0
- package/lib/middleware/bun/index.mjs +51 -94
- package/lib/middleware/cloudflare-pages/index.mjs +23 -28
- package/lib/middleware/deno/index.d.ts +11 -0
- package/lib/middleware/deno/index.mjs +50 -94
- package/lib/middleware/firebase/index.mjs +7 -11
- package/lib/middleware/netlify-edge/index.mjs +23 -29
- package/lib/middleware/node/index.mjs +31 -100
- package/lib/middleware/request-handler/index.d.ts +161 -83
- package/lib/middleware/request-handler/index.mjs +1458 -1257
- package/lib/middleware/vercel-edge/index.mjs +28 -33
- package/lib/modules.d.ts +11 -16
- package/lib/service-worker/index.mjs +4 -0
- package/lib/{static → ssg}/index.d.ts +45 -13
- package/lib/ssg/index.mjs +336 -0
- package/lib/vite/index.d.ts +38 -10
- package/lib/vite/index.mjs +2067 -26841
- package/modules.d.ts +11 -16
- package/package.json +62 -67
- package/ssg.d.ts +2 -0
- package/static.d.ts +1 -1
- package/lib/adapters/azure-swa/vite/index.cjs +0 -96
- package/lib/adapters/bun-server/vite/index.cjs +0 -50
- package/lib/adapters/cloud-run/vite/index.cjs +0 -47
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -115
- package/lib/adapters/deno-server/vite/index.cjs +0 -62
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -129
- package/lib/adapters/node-server/vite/index.cjs +0 -50
- package/lib/adapters/shared/vite/index.cjs +0 -378
- package/lib/adapters/static/vite/index.cjs +0 -368
- package/lib/adapters/static/vite/index.d.ts +0 -10
- package/lib/adapters/static/vite/index.mjs +0 -331
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -118
- package/lib/index.qwik.cjs +0 -1947
- package/lib/middleware/node/index.cjs +0 -314
- package/lib/middleware/request-handler/index.cjs +0 -1614
- package/lib/service-worker.cjs +0 -17
- package/lib/service-worker.mjs +0 -15
- package/lib/static/deno.mjs +0 -8
- package/lib/static/index.cjs +0 -67
- package/lib/static/index.mjs +0 -48
- package/lib/static/node.cjs +0 -1124
- package/lib/static/node.mjs +0 -1086
- package/lib/vite/index.cjs +0 -27445
- package/middleware/request-handler/generated/not-found-paths.ts +0 -7
- package/middleware/request-handler/generated/static-paths.ts +0 -35
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,583 +1,163 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { p } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl, isDev, _jsxSplit, _getConstProps, _getVarProps, eventQrl, isServer, useStylesQrl, useServerData, useStore, useContextProvider, useTaskQrl, isBrowser, getLocale, noSerialize, useContext, SkipRender, implicit$FirstArg, withLocale, _wrapProp, _restProps, _fnSignal, createElement } from '@qwik.dev/core';
|
|
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, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, t as toUrl, b as isSameOrigin, d as clientNavigate, e as loadRoute, r as resolveHead, C as CLIENT_DATA_CACHE, Q as Q_ROUTE, f as toPath, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from './chunks/routing.qwik.mjs';
|
|
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
|
+
export { j as useContent, k as useHttpStatus, l as usePreventNavigate$, m as usePreventNavigateQrl } from './chunks/use-functions.qwik.mjs';
|
|
6
|
+
import * as qwikRouterConfig from '@qwik-router-config';
|
|
7
|
+
import { _getContextContainer, SerializerSymbol, _UNINITIALIZED, _hasStoreEffects, forceStoreEffects, _waitUntilRendered, _getContextHostElement, _getContextEvent, _serialize, _deserialize, _resolveContextWithoutSequentialScope } from '@qwik.dev/core/internal';
|
|
8
|
+
import { _asyncRequestStore } from '@qwik.dev/router/middleware/request-handler';
|
|
9
|
+
import * as v from 'valibot';
|
|
10
|
+
import * as z from 'zod';
|
|
11
|
+
export { z } from 'zod';
|
|
12
|
+
import swRegister from '@qwik-router-sw-register';
|
|
13
|
+
import { renderToStream } from '@qwik.dev/core/server';
|
|
14
|
+
|
|
15
|
+
const ErrorBoundary = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
16
|
+
const store = useErrorBoundary();
|
|
17
|
+
useOnWindow("qerror", /* @__PURE__ */ inlinedQrl((e) => {
|
|
18
|
+
const store2 = _captures[0];
|
|
12
19
|
store2.error = e.detail.error;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return /* @__PURE__ */ jsx(Slot, {});
|
|
20
|
-
});
|
|
21
|
-
const MODULE_CACHE = /* @__PURE__ */ new WeakMap();
|
|
22
|
-
const CLIENT_DATA_CACHE = /* @__PURE__ */ new Map();
|
|
23
|
-
const QACTION_KEY = "qaction";
|
|
24
|
-
const QFN_KEY = "qfunc";
|
|
25
|
-
const QDATA_KEY = "qdata";
|
|
26
|
-
const toPath = (url) => url.pathname + url.search + url.hash;
|
|
27
|
-
const toUrl = (url, baseUrl) => new URL(url, baseUrl.href);
|
|
28
|
-
const isSameOrigin = (a, b) => a.origin === b.origin;
|
|
29
|
-
const withSlash = (path) => path.endsWith("/") ? path : path + "/";
|
|
30
|
-
const isSamePathname = ({ pathname: a }, { pathname: b }) => {
|
|
31
|
-
const lDiff = Math.abs(a.length - b.length);
|
|
32
|
-
return lDiff === 0 ? a === b : lDiff === 1 && withSlash(a) === withSlash(b);
|
|
33
|
-
};
|
|
34
|
-
const isSameSearchQuery = (a, b) => a.search === b.search;
|
|
35
|
-
const isSamePath = (a, b) => isSameSearchQuery(a, b) && isSamePathname(a, b);
|
|
36
|
-
const getClientDataPath = (pathname, pageSearch, action) => {
|
|
37
|
-
let search = pageSearch ?? "";
|
|
38
|
-
if (action) {
|
|
39
|
-
search += (search ? "&" : "?") + QACTION_KEY + "=" + encodeURIComponent(action.id);
|
|
40
|
-
}
|
|
41
|
-
return pathname + (pathname.endsWith("/") ? "" : "/") + "q-data.json" + search;
|
|
42
|
-
};
|
|
43
|
-
const getClientNavPath = (props, baseUrl) => {
|
|
44
|
-
const href = props.href;
|
|
45
|
-
if (typeof href === "string" && typeof props.target !== "string" && !props.reload) {
|
|
46
|
-
try {
|
|
47
|
-
const linkUrl = toUrl(href.trim(), baseUrl.url);
|
|
48
|
-
const currentUrl = toUrl("", baseUrl.url);
|
|
49
|
-
if (isSameOrigin(linkUrl, currentUrl)) {
|
|
50
|
-
return toPath(linkUrl);
|
|
51
|
-
}
|
|
52
|
-
} catch (e) {
|
|
53
|
-
console.error(e);
|
|
54
|
-
}
|
|
55
|
-
} else if (props.reload) {
|
|
56
|
-
return toPath(toUrl("", baseUrl.url));
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
};
|
|
60
|
-
const shouldPreload = (clientNavPath, currentLoc) => {
|
|
61
|
-
if (clientNavPath) {
|
|
62
|
-
const prefetchUrl = toUrl(clientNavPath, currentLoc.url);
|
|
63
|
-
const currentUrl = toUrl("", currentLoc.url);
|
|
64
|
-
return !isSamePathname(prefetchUrl, currentUrl);
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
};
|
|
68
|
-
const isPromise = (value) => {
|
|
69
|
-
return value && typeof value.then === "function";
|
|
70
|
-
};
|
|
71
|
-
const deepFreeze = (obj) => {
|
|
72
|
-
if (obj == null) {
|
|
73
|
-
return obj;
|
|
74
|
-
}
|
|
75
|
-
Object.getOwnPropertyNames(obj).forEach((prop) => {
|
|
76
|
-
const value = obj[prop];
|
|
77
|
-
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
78
|
-
deepFreeze(value);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return Object.freeze(obj);
|
|
82
|
-
};
|
|
83
|
-
const clientNavigate = (win, navType, fromURL, toURL, replaceState = false) => {
|
|
84
|
-
if (navType !== "popstate") {
|
|
85
|
-
const samePath = isSamePath(fromURL, toURL);
|
|
86
|
-
const sameHash = fromURL.hash === toURL.hash;
|
|
87
|
-
if (!samePath || !sameHash) {
|
|
88
|
-
const newState = {
|
|
89
|
-
_qRouterScroll: newScrollState()
|
|
90
|
-
};
|
|
91
|
-
if (replaceState) {
|
|
92
|
-
win.history.replaceState(newState, "", toPath(toURL));
|
|
93
|
-
} else {
|
|
94
|
-
win.history.pushState(newState, "", toPath(toURL));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const newScrollState = () => {
|
|
100
|
-
return {
|
|
101
|
-
x: 0,
|
|
102
|
-
y: 0,
|
|
103
|
-
w: 0,
|
|
104
|
-
h: 0
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
const prefetchSymbols = (path) => {
|
|
108
|
-
if (isBrowser) {
|
|
109
|
-
path = path.endsWith("/") ? path : path + "/";
|
|
110
|
-
path = path.length > 1 && path.startsWith("/") ? path.slice(1) : path;
|
|
111
|
-
p(path, 0.8);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const loadClientData = async (url, element, opts) => {
|
|
115
|
-
const pagePathname = url.pathname;
|
|
116
|
-
const pageSearch = url.search;
|
|
117
|
-
const clientDataPath = getClientDataPath(pagePathname, pageSearch, opts?.action);
|
|
118
|
-
let qData;
|
|
119
|
-
if (!opts?.action) {
|
|
120
|
-
qData = CLIENT_DATA_CACHE.get(clientDataPath);
|
|
121
|
-
}
|
|
122
|
-
if (opts?.prefetchSymbols !== false) {
|
|
123
|
-
prefetchSymbols(pagePathname);
|
|
124
|
-
}
|
|
125
|
-
let resolveFn;
|
|
126
|
-
if (!qData) {
|
|
127
|
-
const fetchOptions = getFetchOptions(opts?.action, opts?.clearCache);
|
|
128
|
-
if (opts?.action) {
|
|
129
|
-
opts.action.data = void 0;
|
|
130
|
-
}
|
|
131
|
-
qData = fetch(clientDataPath, fetchOptions).then((rsp) => {
|
|
132
|
-
if (rsp.redirected) {
|
|
133
|
-
const redirectedURL = new URL(rsp.url);
|
|
134
|
-
const isQData = redirectedURL.pathname.endsWith("/q-data.json");
|
|
135
|
-
if (!isQData || redirectedURL.origin !== location.origin) {
|
|
136
|
-
location.href = redirectedURL.href;
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if ((rsp.headers.get("content-type") || "").includes("json")) {
|
|
141
|
-
return rsp.text().then((text) => {
|
|
142
|
-
const [clientData] = _deserialize(text, element);
|
|
143
|
-
if (!clientData) {
|
|
144
|
-
location.href = url.href;
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (opts?.clearCache) {
|
|
148
|
-
CLIENT_DATA_CACHE.delete(clientDataPath);
|
|
149
|
-
}
|
|
150
|
-
if (clientData.redirect) {
|
|
151
|
-
location.href = clientData.redirect;
|
|
152
|
-
} else if (opts?.action) {
|
|
153
|
-
const { action } = opts;
|
|
154
|
-
const actionData = clientData.loaders[action.id];
|
|
155
|
-
resolveFn = () => {
|
|
156
|
-
action.resolve({
|
|
157
|
-
status: rsp.status,
|
|
158
|
-
result: actionData
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return clientData;
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
if (opts?.isPrefetch !== true) {
|
|
166
|
-
location.href = url.href;
|
|
167
|
-
}
|
|
168
|
-
return void 0;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
if (!opts?.action) {
|
|
172
|
-
CLIENT_DATA_CACHE.set(clientDataPath, qData);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return qData.then((v) => {
|
|
176
|
-
if (!v) {
|
|
177
|
-
CLIENT_DATA_CACHE.delete(clientDataPath);
|
|
178
|
-
}
|
|
179
|
-
resolveFn && resolveFn();
|
|
180
|
-
return v;
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
const getFetchOptions = (action, noCache) => {
|
|
184
|
-
const actionData = action?.data;
|
|
185
|
-
if (!actionData) {
|
|
186
|
-
if (noCache) {
|
|
187
|
-
return {
|
|
188
|
-
cache: "no-cache",
|
|
189
|
-
headers: {
|
|
190
|
-
"Cache-Control": "no-cache",
|
|
191
|
-
Pragma: "no-cache"
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
return void 0;
|
|
196
|
-
}
|
|
197
|
-
if (actionData instanceof FormData) {
|
|
198
|
-
return {
|
|
199
|
-
method: "POST",
|
|
200
|
-
body: actionData
|
|
201
|
-
};
|
|
202
|
-
} else {
|
|
203
|
-
return {
|
|
204
|
-
method: "POST",
|
|
205
|
-
body: JSON.stringify(actionData),
|
|
206
|
-
headers: {
|
|
207
|
-
"Content-Type": "application/json, charset=UTF-8"
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
const RouteStateContext = /* @__PURE__ */ createContextId("qc-s");
|
|
213
|
-
const ContentContext = /* @__PURE__ */ createContextId("qc-c");
|
|
214
|
-
const ContentInternalContext = /* @__PURE__ */ createContextId("qc-ic");
|
|
215
|
-
const DocumentHeadContext = /* @__PURE__ */ createContextId("qc-h");
|
|
216
|
-
const RouteLocationContext = /* @__PURE__ */ createContextId("qc-l");
|
|
217
|
-
const RouteNavigateContext = /* @__PURE__ */ createContextId("qc-n");
|
|
218
|
-
const RouteActionContext = /* @__PURE__ */ createContextId("qc-a");
|
|
219
|
-
const RouteInternalContext = /* @__PURE__ */ createContextId("qc-ir");
|
|
220
|
-
const RoutePreventNavigateContext = /* @__PURE__ */ createContextId("qc-p");
|
|
221
|
-
const useContent = () => useContext(ContentContext);
|
|
222
|
-
const useDocumentHead = () => useContext(DocumentHeadContext);
|
|
223
|
-
const useLocation = () => useContext(RouteLocationContext);
|
|
224
|
-
const useNavigate = () => useContext(RouteNavigateContext);
|
|
225
|
-
const usePreventNavigateQrl = (fn) => {
|
|
226
|
-
if (!__EXPERIMENTAL__.preventNavigate) {
|
|
227
|
-
throw new Error('usePreventNavigate$ is experimental and must be enabled with `experimental: ["preventNavigate"]` in the `qwikVite` plugin.');
|
|
20
|
+
}, "ErrorBoundary_component_useOnWindow_G0jFRpoNY0M", [
|
|
21
|
+
store
|
|
22
|
+
]));
|
|
23
|
+
if (store.error && props.fallback$) {
|
|
24
|
+
return /* @__PURE__ */ _jsxSorted(Fragment, null, null, props.fallback$(store.error), 1, "bA_0");
|
|
228
25
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
const useAction = () => useContext(RouteActionContext);
|
|
234
|
-
const useQwikRouterEnv = () => noSerialize(useServerData("qwikrouter"));
|
|
235
|
-
const Link = component$((props) => {
|
|
26
|
+
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "bA_1");
|
|
27
|
+
}, "ErrorBoundary_component_pOa6vjtC7ik"));
|
|
28
|
+
|
|
29
|
+
const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
236
30
|
const nav = useNavigate();
|
|
237
31
|
const loc = useLocation();
|
|
238
32
|
const originalHref = props.href;
|
|
239
33
|
const anchorRef = useSignal();
|
|
240
34
|
const { onClick$, prefetch: prefetchProp, reload, replaceState, scroll, ...linkProps } = /* @__PURE__ */ (() => props)();
|
|
241
|
-
const clientNavPath = untrack(
|
|
35
|
+
const clientNavPath = untrack(getClientNavPath, {
|
|
242
36
|
...linkProps,
|
|
243
37
|
reload
|
|
244
|
-
}, loc)
|
|
38
|
+
}, loc);
|
|
245
39
|
linkProps.href = clientNavPath || originalHref;
|
|
246
|
-
const prefetchData =
|
|
247
|
-
const prefetch =
|
|
248
|
-
const handlePrefetch = prefetch ?
|
|
40
|
+
const prefetchData = !!clientNavPath && prefetchProp !== false && prefetchProp !== "js" || void 0;
|
|
41
|
+
const prefetch = prefetchData || !!clientNavPath && prefetchProp !== false && untrack(shouldPreload, clientNavPath, loc);
|
|
42
|
+
const handlePrefetch = prefetch ? /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
249
43
|
if (navigator.connection?.saveData) {
|
|
250
44
|
return;
|
|
251
45
|
}
|
|
252
46
|
if (elm && elm.href) {
|
|
253
47
|
const url = new URL(elm.href);
|
|
254
|
-
|
|
48
|
+
preloadRouteBundles(url.pathname);
|
|
255
49
|
if (elm.hasAttribute("data-prefetch")) {
|
|
256
|
-
loadClientData(url,
|
|
257
|
-
|
|
50
|
+
loadClientData(url, {
|
|
51
|
+
preloadRouteBundles: false,
|
|
258
52
|
isPrefetch: true
|
|
259
53
|
});
|
|
260
54
|
}
|
|
261
55
|
}
|
|
262
|
-
}) : void 0;
|
|
263
|
-
const preventDefault = clientNavPath ?
|
|
56
|
+
}, "Link_component_handlePrefetch_AGvVXzXKbms") : void 0;
|
|
57
|
+
const preventDefault = clientNavPath ? _qrlSync((event) => {
|
|
264
58
|
if (!(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {
|
|
265
59
|
event.preventDefault();
|
|
266
60
|
}
|
|
267
|
-
}) : void 0;
|
|
268
|
-
const
|
|
61
|
+
}, "event=>{if(!(event.metaKey||event.ctrlKey||event.shiftKey||event.altKey)){event.preventDefault();}}") : void 0;
|
|
62
|
+
const handleClientSideNavigation = clientNavPath ? /* @__PURE__ */ inlinedQrl((event, elm) => {
|
|
63
|
+
const nav2 = _captures[0], reload2 = _captures[1], replaceState2 = _captures[2], scroll2 = _captures[3];
|
|
269
64
|
if (event.defaultPrevented) {
|
|
270
65
|
if (elm.href) {
|
|
271
66
|
elm.setAttribute("aria-pressed", "true");
|
|
272
|
-
|
|
273
|
-
forceReload:
|
|
274
|
-
replaceState,
|
|
275
|
-
scroll
|
|
67
|
+
nav2(elm.href, {
|
|
68
|
+
forceReload: reload2,
|
|
69
|
+
replaceState: replaceState2,
|
|
70
|
+
scroll: scroll2
|
|
71
|
+
}).then(() => {
|
|
72
|
+
elm.removeAttribute("aria-pressed");
|
|
276
73
|
});
|
|
277
|
-
elm.removeAttribute("aria-pressed");
|
|
278
74
|
}
|
|
279
75
|
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
76
|
+
}, "Link_component_handleClientSideNavigation_h3qenoGeI6M", [
|
|
77
|
+
nav,
|
|
78
|
+
reload,
|
|
79
|
+
replaceState,
|
|
80
|
+
scroll
|
|
81
|
+
]) : void 0;
|
|
82
|
+
const handlePreload = /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
83
|
+
const url = new URL(elm.href);
|
|
84
|
+
preloadRouteBundles(url.pathname, 1);
|
|
85
|
+
}, "Link_component_handlePreload_AAemwtuBjsE");
|
|
86
|
+
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
|
|
87
|
+
const anchorRef2 = _captures[0], handlePrefetch2 = _captures[1], linkProps2 = _captures[2], loc2 = _captures[3];
|
|
88
|
+
track(() => loc2.url.pathname);
|
|
89
|
+
const handler = linkProps2.onQVisible$;
|
|
284
90
|
if (handler) {
|
|
285
91
|
const event = new CustomEvent("qvisible");
|
|
286
92
|
if (Array.isArray(handler)) {
|
|
287
|
-
handler.flat(10).forEach((handler2) => handler2?.(event,
|
|
93
|
+
handler.flat(10).forEach((handler2) => handler2?.(event, anchorRef2.value));
|
|
288
94
|
} else {
|
|
289
|
-
handler?.(event,
|
|
95
|
+
handler?.(event, anchorRef2.value);
|
|
290
96
|
}
|
|
291
97
|
}
|
|
292
|
-
if (!isDev &&
|
|
293
|
-
|
|
98
|
+
if (!isDev && anchorRef2.value) {
|
|
99
|
+
handlePrefetch2?.(void 0, anchorRef2.value);
|
|
294
100
|
}
|
|
295
|
-
}
|
|
296
|
-
|
|
101
|
+
}, "Link_component_useVisibleTask_xKeuRmnoNSA", [
|
|
102
|
+
anchorRef,
|
|
103
|
+
handlePrefetch,
|
|
104
|
+
linkProps,
|
|
105
|
+
loc
|
|
106
|
+
]));
|
|
107
|
+
return /* @__PURE__ */ _jsxSplit("a", {
|
|
297
108
|
ref: anchorRef,
|
|
298
109
|
"q:link": !!clientNavPath,
|
|
299
|
-
...linkProps,
|
|
300
|
-
|
|
110
|
+
..._getVarProps(linkProps),
|
|
111
|
+
..._getConstProps(linkProps),
|
|
112
|
+
"q-e:click": [
|
|
301
113
|
preventDefault,
|
|
114
|
+
handlePreload,
|
|
302
115
|
onClick$,
|
|
303
|
-
|
|
116
|
+
handleClientSideNavigation
|
|
304
117
|
],
|
|
305
118
|
"data-prefetch": prefetchData,
|
|
306
|
-
|
|
119
|
+
"q-e:mouseover": [
|
|
307
120
|
linkProps.onMouseOver$,
|
|
308
121
|
handlePrefetch
|
|
309
122
|
],
|
|
310
|
-
|
|
123
|
+
"q-e:focus": [
|
|
311
124
|
linkProps.onFocus$,
|
|
312
125
|
handlePrefetch
|
|
313
|
-
]
|
|
126
|
+
]
|
|
127
|
+
}, {
|
|
314
128
|
// We need to prevent the onQVisible$ from being called twice since it is handled in the visible task
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
const getData = (loaderOrAction) => {
|
|
322
|
-
const id = loaderOrAction.__id;
|
|
323
|
-
if (loaderOrAction.__brand === "server_loader") {
|
|
324
|
-
if (!(id in endpoint.loaders)) {
|
|
325
|
-
throw new Error("You can not get the returned data of a loader that has not been executed for this request.");
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
const data = endpoint.loaders[id];
|
|
329
|
-
if (isPromise(data)) {
|
|
330
|
-
throw new Error("Loaders returning a promise can not be resolved for the head function.");
|
|
331
|
-
}
|
|
332
|
-
return data;
|
|
333
|
-
};
|
|
334
|
-
const headProps = {
|
|
335
|
-
head,
|
|
336
|
-
withLocale: (fn) => withLocale(locale, fn),
|
|
337
|
-
resolveValue: getData,
|
|
338
|
-
...routeLocation
|
|
339
|
-
};
|
|
340
|
-
for (let i = contentModules.length - 1; i >= 0; i--) {
|
|
341
|
-
const contentModuleHead = contentModules[i] && contentModules[i].head;
|
|
342
|
-
if (contentModuleHead) {
|
|
343
|
-
if (typeof contentModuleHead === "function") {
|
|
344
|
-
resolveDocumentHead(head, withLocale(locale, () => contentModuleHead(headProps)));
|
|
345
|
-
} else if (typeof contentModuleHead === "object") {
|
|
346
|
-
resolveDocumentHead(head, contentModuleHead);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return headProps.head;
|
|
351
|
-
};
|
|
352
|
-
const resolveDocumentHead = (resolvedHead, updatedHead) => {
|
|
353
|
-
if (typeof updatedHead.title === "string") {
|
|
354
|
-
resolvedHead.title = updatedHead.title;
|
|
355
|
-
}
|
|
356
|
-
mergeArray(resolvedHead.meta, updatedHead.meta);
|
|
357
|
-
mergeArray(resolvedHead.links, updatedHead.links);
|
|
358
|
-
mergeArray(resolvedHead.styles, updatedHead.styles);
|
|
359
|
-
mergeArray(resolvedHead.scripts, updatedHead.scripts);
|
|
360
|
-
Object.assign(resolvedHead.frontmatter, updatedHead.frontmatter);
|
|
361
|
-
};
|
|
362
|
-
const mergeArray = (existingArr, newArr) => {
|
|
363
|
-
if (Array.isArray(newArr)) {
|
|
364
|
-
for (const newItem of newArr) {
|
|
365
|
-
if (typeof newItem.key === "string") {
|
|
366
|
-
const existingIndex = existingArr.findIndex((i) => i.key === newItem.key);
|
|
367
|
-
if (existingIndex > -1) {
|
|
368
|
-
existingArr[existingIndex] = newItem;
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
existingArr.push(newItem);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
const createDocumentHead = () => ({
|
|
377
|
-
title: "",
|
|
378
|
-
meta: [],
|
|
379
|
-
links: [],
|
|
380
|
-
styles: [],
|
|
381
|
-
scripts: [],
|
|
382
|
-
frontmatter: {}
|
|
383
|
-
});
|
|
384
|
-
function matchRoute(route, path) {
|
|
385
|
-
const routeIdx = startIdxSkipSlash(route);
|
|
386
|
-
const routeLength = lengthNoTrailingSlash(route);
|
|
387
|
-
const pathIdx = startIdxSkipSlash(path);
|
|
388
|
-
const pathLength = lengthNoTrailingSlash(path);
|
|
389
|
-
return matchRoutePart(route, routeIdx, routeLength, path, pathIdx, pathLength);
|
|
390
|
-
}
|
|
391
|
-
function matchRoutePart(route, routeIdx, routeLength, path, pathIdx, pathLength) {
|
|
392
|
-
let params = null;
|
|
393
|
-
while (routeIdx < routeLength) {
|
|
394
|
-
const routeCh = route.charCodeAt(routeIdx++);
|
|
395
|
-
const pathCh = path.charCodeAt(pathIdx++);
|
|
396
|
-
if (routeCh === 91) {
|
|
397
|
-
const isMany = isThreeDots(route, routeIdx);
|
|
398
|
-
const paramNameStart = routeIdx + (isMany ? 3 : 0);
|
|
399
|
-
const paramNameEnd = scan(route, paramNameStart, routeLength, 93);
|
|
400
|
-
const paramName = route.substring(paramNameStart, paramNameEnd);
|
|
401
|
-
const paramSuffixEnd = scan(route, paramNameEnd + 1, routeLength, 47);
|
|
402
|
-
const suffix = route.substring(paramNameEnd + 1, paramSuffixEnd);
|
|
403
|
-
routeIdx = paramNameEnd + 1;
|
|
404
|
-
const paramValueStart = pathIdx - 1;
|
|
405
|
-
if (isMany) {
|
|
406
|
-
const match = recursiveScan(paramName, suffix, path, paramValueStart, pathLength, route, routeIdx + suffix.length + 1, routeLength);
|
|
407
|
-
if (match) {
|
|
408
|
-
return Object.assign(params || (params = {}), match);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
const paramValueEnd = scan(path, paramValueStart, pathLength, 47, suffix);
|
|
412
|
-
if (paramValueEnd == -1) {
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
const paramValue = path.substring(paramValueStart, paramValueEnd);
|
|
416
|
-
if (!isMany && !suffix && !paramValue) {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
pathIdx = paramValueEnd;
|
|
420
|
-
(params || (params = {}))[paramName] = decodeURIComponent(paramValue);
|
|
421
|
-
} else if (routeCh !== pathCh) {
|
|
422
|
-
if (!(isNaN(pathCh) && isRestParameter(route, routeIdx))) {
|
|
423
|
-
return null;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
if (allConsumed(route, routeIdx) && allConsumed(path, pathIdx)) {
|
|
428
|
-
return params || {};
|
|
429
|
-
} else {
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
function isRestParameter(text, idx) {
|
|
434
|
-
return text.charCodeAt(idx) === 91 && isThreeDots(text, idx + 1);
|
|
435
|
-
}
|
|
436
|
-
function lengthNoTrailingSlash(text) {
|
|
437
|
-
const length = text.length;
|
|
438
|
-
return length > 1 && text.charCodeAt(length - 1) === 47 ? length - 1 : length;
|
|
439
|
-
}
|
|
440
|
-
function allConsumed(text, idx) {
|
|
441
|
-
const length = text.length;
|
|
442
|
-
return idx >= length || idx == length - 1 && text.charCodeAt(idx) === 47;
|
|
443
|
-
}
|
|
444
|
-
function startIdxSkipSlash(text) {
|
|
445
|
-
return text.charCodeAt(0) === 47 ? 1 : 0;
|
|
446
|
-
}
|
|
447
|
-
function isThreeDots(text, idx) {
|
|
448
|
-
return text.charCodeAt(idx) === 46 && text.charCodeAt(idx + 1) === 46 && text.charCodeAt(idx + 2) === 46;
|
|
449
|
-
}
|
|
450
|
-
function scan(text, idx, end, ch, suffix = "") {
|
|
451
|
-
while (idx < end && text.charCodeAt(idx) !== ch) {
|
|
452
|
-
idx++;
|
|
453
|
-
}
|
|
454
|
-
const suffixLength = suffix.length;
|
|
455
|
-
for (let i = 0; i < suffixLength; i++) {
|
|
456
|
-
if (text.charCodeAt(idx - suffixLength + i) !== suffix.charCodeAt(i)) {
|
|
457
|
-
return -1;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
return idx - suffixLength;
|
|
461
|
-
}
|
|
462
|
-
function recursiveScan(paramName, suffix, path, pathStart, pathLength, route, routeStart, routeLength) {
|
|
463
|
-
if (path.charCodeAt(pathStart) === 47) {
|
|
464
|
-
pathStart++;
|
|
465
|
-
}
|
|
466
|
-
let pathIdx = pathLength;
|
|
467
|
-
const sep = suffix + "/";
|
|
468
|
-
while (pathIdx >= pathStart) {
|
|
469
|
-
const match = matchRoutePart(route, routeStart, routeLength, path, pathIdx, pathLength);
|
|
470
|
-
if (match) {
|
|
471
|
-
let value = path.substring(pathStart, Math.min(pathIdx, pathLength));
|
|
472
|
-
if (value.endsWith(sep)) {
|
|
473
|
-
value = value.substring(0, value.length - sep.length);
|
|
474
|
-
}
|
|
475
|
-
match[paramName] = decodeURIComponent(value);
|
|
476
|
-
return match;
|
|
477
|
-
}
|
|
478
|
-
const newPathIdx = lastIndexOf(path, pathStart, sep, pathIdx, pathStart - 1) + sep.length;
|
|
479
|
-
if (pathIdx === newPathIdx) {
|
|
480
|
-
break;
|
|
481
|
-
}
|
|
482
|
-
pathIdx = newPathIdx;
|
|
483
|
-
}
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
function lastIndexOf(text, start, match, searchIdx, notFoundIdx) {
|
|
487
|
-
let idx = text.lastIndexOf(match, searchIdx);
|
|
488
|
-
if (idx == searchIdx - match.length) {
|
|
489
|
-
idx = text.lastIndexOf(match, searchIdx - match.length - 1);
|
|
490
|
-
}
|
|
491
|
-
return idx > start ? idx : notFoundIdx;
|
|
492
|
-
}
|
|
493
|
-
const loadRoute = async (routes, menus, cacheModules, pathname) => {
|
|
494
|
-
if (!Array.isArray(routes)) {
|
|
495
|
-
return null;
|
|
496
|
-
}
|
|
497
|
-
for (const routeData of routes) {
|
|
498
|
-
const routeName = routeData[0];
|
|
499
|
-
const params = matchRoute(routeName, pathname);
|
|
500
|
-
if (!params) {
|
|
501
|
-
continue;
|
|
502
|
-
}
|
|
503
|
-
const loaders = routeData[1];
|
|
504
|
-
const routeBundleNames = routeData[3];
|
|
505
|
-
const modules = new Array(loaders.length);
|
|
506
|
-
const pendingLoads = [];
|
|
507
|
-
loaders.forEach((moduleLoader, i) => {
|
|
508
|
-
loadModule(moduleLoader, pendingLoads, (routeModule) => modules[i] = routeModule, cacheModules);
|
|
509
|
-
});
|
|
510
|
-
const menuLoader = getMenuLoader(menus, pathname);
|
|
511
|
-
let menu = void 0;
|
|
512
|
-
loadModule(menuLoader, pendingLoads, (menuModule) => menu = menuModule?.default, cacheModules);
|
|
513
|
-
if (pendingLoads.length > 0) {
|
|
514
|
-
await Promise.all(pendingLoads);
|
|
515
|
-
}
|
|
516
|
-
return [
|
|
517
|
-
routeName,
|
|
518
|
-
params,
|
|
519
|
-
modules,
|
|
520
|
-
deepFreeze(menu),
|
|
521
|
-
routeBundleNames
|
|
522
|
-
];
|
|
523
|
-
}
|
|
524
|
-
return null;
|
|
525
|
-
};
|
|
526
|
-
const loadModule = (moduleLoader, pendingLoads, moduleSetter, cacheModules) => {
|
|
527
|
-
if (typeof moduleLoader === "function") {
|
|
528
|
-
const loadedModule = MODULE_CACHE.get(moduleLoader);
|
|
529
|
-
if (loadedModule) {
|
|
530
|
-
moduleSetter(loadedModule);
|
|
531
|
-
} else {
|
|
532
|
-
const moduleOrPromise = moduleLoader();
|
|
533
|
-
if (typeof moduleOrPromise.then === "function") {
|
|
534
|
-
pendingLoads.push(moduleOrPromise.then((loadedModule2) => {
|
|
535
|
-
if (cacheModules !== false) {
|
|
536
|
-
MODULE_CACHE.set(moduleLoader, loadedModule2);
|
|
537
|
-
}
|
|
538
|
-
moduleSetter(loadedModule2);
|
|
539
|
-
}));
|
|
540
|
-
} else if (moduleOrPromise) {
|
|
541
|
-
moduleSetter(moduleOrPromise);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
const getMenuLoader = (menus, pathname) => {
|
|
547
|
-
if (menus) {
|
|
548
|
-
pathname = pathname.endsWith("/") ? pathname : pathname + "/";
|
|
549
|
-
const menu = menus.find((m) => m[0] === pathname || pathname.startsWith(m[0] + (pathname.endsWith("/") ? "" : "/")));
|
|
550
|
-
if (menu) {
|
|
551
|
-
return menu[1];
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
};
|
|
129
|
+
"q-e:qvisible": []
|
|
130
|
+
}, /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "jO_0"), 0, "jO_1");
|
|
131
|
+
}, "Link_component_VPmar9tb3t4"));
|
|
132
|
+
|
|
133
|
+
const transitionCss = "@layer qwik{@supports selector(html:active-view-transition-type(type)){html:active-view-transition-type(qwik-navigation){:root{view-transition-name:none}}}@supports not selector(html:active-view-transition-type(type)){:root{view-transition-name:none}}}";
|
|
134
|
+
|
|
555
135
|
function callRestoreScrollOnDocument() {
|
|
556
136
|
if (document.__q_scroll_restore__) {
|
|
557
137
|
document.__q_scroll_restore__();
|
|
558
138
|
document.__q_scroll_restore__ = void 0;
|
|
559
139
|
}
|
|
560
140
|
}
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
scroller.scrollTo(scrollState.x, scrollState.y);
|
|
564
|
-
} else if (type === "link" || type === "form") {
|
|
565
|
-
if (!hashScroll(toUrl2, fromUrl)) {
|
|
566
|
-
scroller.scrollTo(0, 0);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
const hashScroll = (toUrl2, fromUrl) => {
|
|
571
|
-
const elmId = toUrl2.hash.slice(1);
|
|
141
|
+
const hashScroll = (toUrl, fromUrl) => {
|
|
142
|
+
const elmId = toUrl.hash.slice(1);
|
|
572
143
|
const elm = elmId && document.getElementById(elmId);
|
|
573
144
|
if (elm) {
|
|
574
145
|
elm.scrollIntoView();
|
|
575
146
|
return true;
|
|
576
|
-
} else if (!elm &&
|
|
147
|
+
} else if (!elm && toUrl.hash && isSamePath(toUrl, fromUrl)) {
|
|
577
148
|
return true;
|
|
578
149
|
}
|
|
579
150
|
return false;
|
|
580
151
|
};
|
|
152
|
+
const restoreScroll = (type, toUrl, fromUrl, scroller, scrollState) => {
|
|
153
|
+
if (type === "popstate" && scrollState) {
|
|
154
|
+
scroller.scrollTo(scrollState.x, scrollState.y);
|
|
155
|
+
} else if (type === "link" || type === "form") {
|
|
156
|
+
if (!hashScroll(toUrl, fromUrl)) {
|
|
157
|
+
scroller.scrollTo(0, 0);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
581
161
|
const currentScrollState = (elm) => {
|
|
582
162
|
return {
|
|
583
163
|
x: elm.scrollLeft,
|
|
@@ -595,25 +175,16 @@ const saveScrollHistory = (scrollState) => {
|
|
|
595
175
|
state._qRouterScroll = scrollState;
|
|
596
176
|
history.replaceState(state, "");
|
|
597
177
|
};
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
const initPopstate = "_qRouterInitPopstate";
|
|
602
|
-
const initAnchors = "_qRouterInitAnchors";
|
|
603
|
-
const initVisibility = "_qRouterInitVisibility";
|
|
604
|
-
const initScroll = "_qRouterInitScroll";
|
|
605
|
-
if (!win[spa] && !win[initPopstate] && !win[initAnchors] && !win[initVisibility] && !win[initScroll]) {
|
|
178
|
+
|
|
179
|
+
const spaInit = eventQrl(/* @__PURE__ */ inlinedQrl((_, el) => {
|
|
180
|
+
if (!window._qRouterSPA && !window._qRouterInitPopstate) {
|
|
606
181
|
const currentPath = location.pathname + location.search;
|
|
607
|
-
const historyPatch = "_qRouterHistoryPatch";
|
|
608
|
-
const scrollEnabled = "_qRouterScrollEnabled";
|
|
609
|
-
const debounceTimeout = "_qRouterScrollDebounce";
|
|
610
|
-
const scrollHistory = "_qRouterScroll";
|
|
611
182
|
const checkAndScroll = (scrollState) => {
|
|
612
183
|
if (scrollState) {
|
|
613
|
-
|
|
184
|
+
window.scrollTo(scrollState.x, scrollState.y);
|
|
614
185
|
}
|
|
615
186
|
};
|
|
616
|
-
const
|
|
187
|
+
const currentScrollState = () => {
|
|
617
188
|
const elm = document.documentElement;
|
|
618
189
|
return {
|
|
619
190
|
x: elm.scrollLeft,
|
|
@@ -624,23 +195,23 @@ const spaInit = event$((_, el) => {
|
|
|
624
195
|
};
|
|
625
196
|
const saveScrollState = (scrollState) => {
|
|
626
197
|
const state = history.state || {};
|
|
627
|
-
state
|
|
198
|
+
state._qRouterScroll = scrollState || currentScrollState();
|
|
628
199
|
history.replaceState(state, "");
|
|
629
200
|
};
|
|
630
201
|
saveScrollState();
|
|
631
|
-
|
|
632
|
-
if (
|
|
202
|
+
window._qRouterInitPopstate = () => {
|
|
203
|
+
if (window._qRouterSPA) {
|
|
633
204
|
return;
|
|
634
205
|
}
|
|
635
|
-
|
|
636
|
-
clearTimeout(
|
|
206
|
+
window._qRouterScrollEnabled = false;
|
|
207
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
637
208
|
if (currentPath !== location.pathname + location.search) {
|
|
638
209
|
const getContainer = (el2) => el2.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])");
|
|
639
210
|
const container = getContainer(el);
|
|
640
211
|
const domContainer = container.qContainer;
|
|
641
212
|
const hostElement = domContainer.vNodeLocate(el);
|
|
642
213
|
const nav = domContainer?.resolveContext(hostElement, {
|
|
643
|
-
id: "
|
|
214
|
+
id: "qr-n"
|
|
644
215
|
});
|
|
645
216
|
if (nav) {
|
|
646
217
|
nav(location.href, {
|
|
@@ -651,14 +222,14 @@ const spaInit = event$((_, el) => {
|
|
|
651
222
|
}
|
|
652
223
|
} else {
|
|
653
224
|
if (history.scrollRestoration === "manual") {
|
|
654
|
-
const scrollState = history.state?.
|
|
225
|
+
const scrollState = history.state?._qRouterScroll;
|
|
655
226
|
checkAndScroll(scrollState);
|
|
656
|
-
|
|
227
|
+
window._qRouterScrollEnabled = true;
|
|
657
228
|
}
|
|
658
229
|
}
|
|
659
230
|
};
|
|
660
|
-
if (!
|
|
661
|
-
|
|
231
|
+
if (!window._qRouterHistoryPatch) {
|
|
232
|
+
window._qRouterHistoryPatch = true;
|
|
662
233
|
const pushState = history.pushState;
|
|
663
234
|
const replaceState = history.replaceState;
|
|
664
235
|
const prepareState = (state) => {
|
|
@@ -672,7 +243,7 @@ const spaInit = event$((_, el) => {
|
|
|
672
243
|
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`");
|
|
673
244
|
}
|
|
674
245
|
}
|
|
675
|
-
state._qRouterScroll = state._qRouterScroll ||
|
|
246
|
+
state._qRouterScroll = state._qRouterScroll || currentScrollState();
|
|
676
247
|
return state;
|
|
677
248
|
};
|
|
678
249
|
history.pushState = (state, title, url) => {
|
|
@@ -684,8 +255,8 @@ const spaInit = event$((_, el) => {
|
|
|
684
255
|
return replaceState.call(history, state, title, url);
|
|
685
256
|
};
|
|
686
257
|
}
|
|
687
|
-
|
|
688
|
-
if (
|
|
258
|
+
window._qRouterInitAnchors = (event) => {
|
|
259
|
+
if (window._qRouterSPA || event.defaultPrevented) {
|
|
689
260
|
return;
|
|
690
261
|
}
|
|
691
262
|
const target = event.target.closest("a[href]");
|
|
@@ -704,10 +275,10 @@ const spaInit = event$((_, el) => {
|
|
|
704
275
|
if (dest.href.endsWith("#")) {
|
|
705
276
|
window.scrollTo(0, 0);
|
|
706
277
|
} else {
|
|
707
|
-
|
|
708
|
-
clearTimeout(
|
|
278
|
+
window._qRouterScrollEnabled = false;
|
|
279
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
709
280
|
saveScrollState({
|
|
710
|
-
...
|
|
281
|
+
...currentScrollState(),
|
|
711
282
|
x: 0,
|
|
712
283
|
y: 0
|
|
713
284
|
});
|
|
@@ -723,36 +294,37 @@ const spaInit = event$((_, el) => {
|
|
|
723
294
|
}
|
|
724
295
|
}
|
|
725
296
|
};
|
|
726
|
-
|
|
727
|
-
if (!
|
|
297
|
+
window._qRouterInitVisibility = () => {
|
|
298
|
+
if (!window._qRouterSPA && window._qRouterScrollEnabled && document.visibilityState === "hidden") {
|
|
728
299
|
saveScrollState();
|
|
729
300
|
}
|
|
730
301
|
};
|
|
731
|
-
|
|
732
|
-
if (
|
|
302
|
+
window._qRouterInitScroll = () => {
|
|
303
|
+
if (window._qRouterSPA || !window._qRouterScrollEnabled) {
|
|
733
304
|
return;
|
|
734
305
|
}
|
|
735
|
-
clearTimeout(
|
|
736
|
-
|
|
306
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
307
|
+
window._qRouterScrollDebounce = setTimeout(() => {
|
|
737
308
|
saveScrollState();
|
|
738
|
-
|
|
309
|
+
window._qRouterScrollDebounce = void 0;
|
|
739
310
|
}, 200);
|
|
740
311
|
};
|
|
741
|
-
|
|
312
|
+
window._qRouterScrollEnabled = true;
|
|
742
313
|
setTimeout(() => {
|
|
743
|
-
addEventListener("popstate",
|
|
744
|
-
addEventListener("scroll",
|
|
314
|
+
window.addEventListener("popstate", window._qRouterInitPopstate);
|
|
315
|
+
window.addEventListener("scroll", window._qRouterInitScroll, {
|
|
745
316
|
passive: true
|
|
746
317
|
});
|
|
747
|
-
document.
|
|
748
|
-
if (!
|
|
749
|
-
document.addEventListener("visibilitychange",
|
|
318
|
+
document.addEventListener("click", window._qRouterInitAnchors);
|
|
319
|
+
if (!window.navigation) {
|
|
320
|
+
document.addEventListener("visibilitychange", window._qRouterInitVisibility, {
|
|
750
321
|
passive: true
|
|
751
322
|
});
|
|
752
323
|
}
|
|
753
324
|
}, 0);
|
|
754
325
|
}
|
|
755
|
-
});
|
|
326
|
+
}, "spa_init_event_igI1pUsax0E"));
|
|
327
|
+
|
|
756
328
|
const startViewTransition = (params) => {
|
|
757
329
|
if (!params.update) {
|
|
758
330
|
return;
|
|
@@ -773,25 +345,18 @@ const startViewTransition = (params) => {
|
|
|
773
345
|
params.update?.();
|
|
774
346
|
}
|
|
775
347
|
};
|
|
348
|
+
|
|
776
349
|
const QWIK_CITY_SCROLLER = "_qCityScroller";
|
|
777
350
|
const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
|
|
778
351
|
const preventNav = {};
|
|
779
352
|
const internalState = {
|
|
780
353
|
navCount: 0
|
|
781
354
|
};
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
:root{view-transition-name:none}
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
@supports not selector(html:active-view-transition-type(type)) {
|
|
791
|
-
:root{view-transition-name:none}
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
`);
|
|
355
|
+
const useQwikRouter = (props) => {
|
|
356
|
+
if (!isServer) {
|
|
357
|
+
throw new Error("useQwikRouter can only run during SSR on the server. If you are seeing this, it means you are re-rendering the root of your application. Fix that or use the <QwikRouterProvider> component around the root of your application.");
|
|
358
|
+
}
|
|
359
|
+
useStylesQrl(/* @__PURE__ */ inlinedQrl(transitionCss, "qwik_view_transition_css_inline_vNfd9raIMI0"));
|
|
795
360
|
const env = useQwikRouterEnv();
|
|
796
361
|
if (!env?.params) {
|
|
797
362
|
throw new Error(`Missing Qwik Router Env Data for help visit https://github.com/QwikDev/qwik/issues/6237`);
|
|
@@ -800,37 +365,53 @@ const QwikRouterProvider = component$((props) => {
|
|
|
800
365
|
if (!urlEnv) {
|
|
801
366
|
throw new Error(`Missing Qwik URL Env Data`);
|
|
802
367
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}
|
|
368
|
+
const serverHead = useServerData("documentHead");
|
|
369
|
+
if (env.ev.originalUrl.pathname !== env.ev.url.pathname && !__EXPERIMENTAL__.enableRequestRewrite) {
|
|
370
|
+
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.`);
|
|
807
371
|
}
|
|
808
372
|
const url = new URL(urlEnv);
|
|
809
|
-
const
|
|
373
|
+
const routeLocationTarget = {
|
|
810
374
|
url,
|
|
811
375
|
params: env.params,
|
|
812
376
|
isNavigating: false,
|
|
813
377
|
prevUrl: void 0
|
|
814
|
-
}
|
|
378
|
+
};
|
|
379
|
+
const routeLocation = useStore(routeLocationTarget, {
|
|
815
380
|
deep: false
|
|
816
381
|
});
|
|
817
382
|
const navResolver = {};
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
383
|
+
const container = _getContextContainer();
|
|
384
|
+
const getSerializationStrategy = (loaderId) => {
|
|
385
|
+
return env.response.loadersSerializationStrategy.get(loaderId) || DEFAULT_LOADERS_SERIALIZATION_STRATEGY;
|
|
386
|
+
};
|
|
387
|
+
const loadersObject = {};
|
|
388
|
+
const loaderState = {};
|
|
389
|
+
for (const [key, value] of Object.entries(env.response.loaders)) {
|
|
390
|
+
loadersObject[key] = value;
|
|
391
|
+
loaderState[key] = createLoaderSignal(loadersObject, key, url, getSerializationStrategy(key), container);
|
|
392
|
+
}
|
|
393
|
+
loadersObject[SerializerSymbol] = (obj) => {
|
|
394
|
+
const loadersSerializationObject = {};
|
|
395
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
396
|
+
loadersSerializationObject[k] = getSerializationStrategy(k) === "always" ? v : _UNINITIALIZED;
|
|
397
|
+
}
|
|
398
|
+
return loadersSerializationObject;
|
|
399
|
+
};
|
|
821
400
|
const routeInternal = useSignal({
|
|
822
401
|
type: "initial",
|
|
823
402
|
dest: url,
|
|
824
|
-
forceReload: false,
|
|
825
|
-
replaceState: false,
|
|
826
403
|
scroll: true
|
|
827
404
|
});
|
|
828
|
-
const documentHead = useStore(createDocumentHead);
|
|
405
|
+
const documentHead = useStore(() => createDocumentHead(serverHead));
|
|
829
406
|
const content = useStore({
|
|
830
407
|
headings: void 0,
|
|
831
408
|
menu: void 0
|
|
832
409
|
});
|
|
833
410
|
const contentInternal = useSignal();
|
|
411
|
+
const httpStatus = useSignal({
|
|
412
|
+
status: env.response.status,
|
|
413
|
+
message: env.loadedRoute.$notFound$ ? "Not Found" : env.response.statusMessage ?? ""
|
|
414
|
+
});
|
|
834
415
|
const currentActionId = env.response.action;
|
|
835
416
|
const currentAction = currentActionId ? env.response.loaders[currentActionId] : void 0;
|
|
836
417
|
const actionState = useSignal(currentAction ? {
|
|
@@ -841,11 +422,11 @@ const QwikRouterProvider = component$((props) => {
|
|
|
841
422
|
status: env.response.status
|
|
842
423
|
}
|
|
843
424
|
} : void 0);
|
|
844
|
-
const registerPreventNav =
|
|
425
|
+
const registerPreventNav = /* @__PURE__ */ inlinedQrl((fn$) => {
|
|
845
426
|
if (!isBrowser) {
|
|
846
427
|
return;
|
|
847
428
|
}
|
|
848
|
-
preventNav.$handler$
|
|
429
|
+
preventNav.$handler$ ||= (event) => {
|
|
849
430
|
internalState.navCount++;
|
|
850
431
|
if (!preventNav.$cbs$) {
|
|
851
432
|
return;
|
|
@@ -857,8 +438,8 @@ const QwikRouterProvider = component$((props) => {
|
|
|
857
438
|
event.preventDefault();
|
|
858
439
|
event.returnValue = true;
|
|
859
440
|
}
|
|
860
|
-
}
|
|
861
|
-
(preventNav.$cbs$
|
|
441
|
+
};
|
|
442
|
+
(preventNav.$cbs$ ||= /* @__PURE__ */ new Set()).add(fn$);
|
|
862
443
|
fn$.resolve();
|
|
863
444
|
window.addEventListener("beforeunload", preventNav.$handler$);
|
|
864
445
|
return () => {
|
|
@@ -870,14 +451,30 @@ const QwikRouterProvider = component$((props) => {
|
|
|
870
451
|
}
|
|
871
452
|
}
|
|
872
453
|
};
|
|
873
|
-
});
|
|
874
|
-
const
|
|
454
|
+
}, "useQwikRouter_registerPreventNav_69B0DK0eZJc");
|
|
455
|
+
const getScroller = /* @__PURE__ */ inlinedQrl(() => {
|
|
456
|
+
let scroller = document.getElementById(QWIK_ROUTER_SCROLLER);
|
|
457
|
+
if (!scroller) {
|
|
458
|
+
scroller = document.getElementById(QWIK_CITY_SCROLLER);
|
|
459
|
+
if (scroller && isDev) {
|
|
460
|
+
console.warn(`Please update your scroller ID to "${QWIK_ROUTER_SCROLLER}" as "${QWIK_CITY_SCROLLER}" is deprecated and will be removed in V3`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return scroller ?? document.documentElement;
|
|
464
|
+
}, "useQwikRouter_getScroller_0UhDFwlxeFQ");
|
|
465
|
+
const goto = /* @__PURE__ */ inlinedQrl(async (path, opt) => {
|
|
466
|
+
const actionState2 = _captures[0], getScroller2 = _captures[1], navResolver2 = _captures[2], routeInternal2 = _captures[3], routeLocation2 = _captures[4];
|
|
875
467
|
const { type = "link", forceReload = path === void 0, replaceState = false, scroll = true } = typeof opt === "object" ? opt : {
|
|
876
468
|
forceReload: opt
|
|
877
469
|
};
|
|
878
470
|
internalState.navCount++;
|
|
879
|
-
|
|
880
|
-
|
|
471
|
+
if (isBrowser && type === "link" && routeInternal2.value.type === "initial") {
|
|
472
|
+
const url2 = new URL(window.location.href);
|
|
473
|
+
routeInternal2.value.dest = url2;
|
|
474
|
+
routeLocation2.url = url2;
|
|
475
|
+
}
|
|
476
|
+
const lastDest = routeInternal2.value.dest;
|
|
477
|
+
const dest = path === void 0 ? lastDest : typeof path === "number" ? path : toUrl(path, routeLocation2.url);
|
|
881
478
|
if (preventNav.$cbs$ && (forceReload || typeof dest === "number" || !isSamePath(dest, lastDest) || !isSameOrigin(dest, lastDest))) {
|
|
882
479
|
const ourNavId = internalState.navCount;
|
|
883
480
|
const prevents = await Promise.all([
|
|
@@ -907,84 +504,96 @@ const QwikRouterProvider = component$((props) => {
|
|
|
907
504
|
if (type === "link" && dest.href !== location.href) {
|
|
908
505
|
history.pushState(null, "", dest);
|
|
909
506
|
}
|
|
910
|
-
|
|
911
|
-
if (!scroller) {
|
|
912
|
-
scroller = document.getElementById(QWIK_CITY_SCROLLER);
|
|
913
|
-
if (scroller) {
|
|
914
|
-
console.warn(`Please update your scroller ID to "${QWIK_ROUTER_SCROLLER}" as "${QWIK_CITY_SCROLLER}" is deprecated and will be removed in V3`);
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
if (!scroller) {
|
|
918
|
-
scroller = document.documentElement;
|
|
919
|
-
}
|
|
507
|
+
const scroller = await getScroller2();
|
|
920
508
|
restoreScroll(type, dest, new URL(location.href), scroller, getScrollHistory());
|
|
921
509
|
if (type === "popstate") {
|
|
922
510
|
window._qRouterScrollEnabled = true;
|
|
923
511
|
}
|
|
924
512
|
}
|
|
513
|
+
if (dest.href !== routeLocation2.url.href) {
|
|
514
|
+
const newUrl = new URL(dest.href);
|
|
515
|
+
routeInternal2.value.dest = newUrl;
|
|
516
|
+
routeLocation2.url = newUrl;
|
|
517
|
+
}
|
|
925
518
|
return;
|
|
926
519
|
}
|
|
927
|
-
|
|
520
|
+
let historyUpdated = false;
|
|
521
|
+
if (isBrowser && type === "link" && !forceReload) {
|
|
522
|
+
const scroller = await getScroller2();
|
|
523
|
+
window._qRouterScrollEnabled = false;
|
|
524
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
525
|
+
const scrollState = currentScrollState(scroller);
|
|
526
|
+
saveScrollHistory(scrollState);
|
|
527
|
+
clientNavigate(window, type, new URL(location.href), dest, replaceState);
|
|
528
|
+
historyUpdated = true;
|
|
529
|
+
}
|
|
530
|
+
routeInternal2.value = {
|
|
928
531
|
type,
|
|
929
532
|
dest,
|
|
930
533
|
forceReload,
|
|
931
534
|
replaceState,
|
|
932
|
-
scroll
|
|
535
|
+
scroll,
|
|
536
|
+
historyUpdated
|
|
933
537
|
};
|
|
934
538
|
if (isBrowser) {
|
|
935
|
-
loadClientData(dest
|
|
936
|
-
loadRoute(qwikRouterConfig.routes, qwikRouterConfig.
|
|
539
|
+
loadClientData(dest);
|
|
540
|
+
loadRoute(qwikRouterConfig.routes, qwikRouterConfig.cacheModules, dest.pathname);
|
|
937
541
|
}
|
|
938
|
-
|
|
939
|
-
|
|
542
|
+
actionState2.value = void 0;
|
|
543
|
+
routeLocation2.isNavigating = true;
|
|
940
544
|
return new Promise((resolve) => {
|
|
941
|
-
|
|
545
|
+
navResolver2.r = resolve;
|
|
942
546
|
});
|
|
943
|
-
}
|
|
547
|
+
}, "useQwikRouter_goto_8j8Vrz2yUIM", [
|
|
548
|
+
actionState,
|
|
549
|
+
getScroller,
|
|
550
|
+
navResolver,
|
|
551
|
+
routeInternal,
|
|
552
|
+
routeLocation
|
|
553
|
+
]);
|
|
944
554
|
useContextProvider(ContentContext, content);
|
|
945
555
|
useContextProvider(ContentInternalContext, contentInternal);
|
|
946
556
|
useContextProvider(DocumentHeadContext, documentHead);
|
|
557
|
+
useContextProvider(HttpStatusContext, httpStatus);
|
|
947
558
|
useContextProvider(RouteLocationContext, routeLocation);
|
|
948
559
|
useContextProvider(RouteNavigateContext, goto);
|
|
949
560
|
useContextProvider(RouteStateContext, loaderState);
|
|
950
561
|
useContextProvider(RouteActionContext, actionState);
|
|
951
|
-
useContextProvider(RouteInternalContext, routeInternal);
|
|
952
562
|
useContextProvider(RoutePreventNavigateContext, registerPreventNav);
|
|
953
|
-
|
|
563
|
+
useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
|
|
564
|
+
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];
|
|
954
565
|
async function run() {
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
actionState.value
|
|
958
|
-
]);
|
|
566
|
+
const navigation = track(routeInternal2);
|
|
567
|
+
const action = track(actionState2);
|
|
959
568
|
const locale = getLocale("");
|
|
960
|
-
const prevUrl =
|
|
569
|
+
const prevUrl = routeLocation2.url;
|
|
961
570
|
const navType = action ? "form" : navigation.type;
|
|
962
571
|
const replaceState = navigation.replaceState;
|
|
963
572
|
let trackUrl;
|
|
964
573
|
let clientPageData;
|
|
965
574
|
let loadedRoute = null;
|
|
966
|
-
let
|
|
575
|
+
let container2;
|
|
967
576
|
if (isServer) {
|
|
968
|
-
trackUrl = new URL(navigation.dest,
|
|
969
|
-
loadedRoute =
|
|
970
|
-
clientPageData =
|
|
577
|
+
trackUrl = new URL(navigation.dest, routeLocation2.url);
|
|
578
|
+
loadedRoute = env2.loadedRoute;
|
|
579
|
+
clientPageData = env2.response;
|
|
971
580
|
} else {
|
|
972
581
|
trackUrl = new URL(navigation.dest, location);
|
|
973
582
|
if (trackUrl.pathname.endsWith("/")) {
|
|
974
|
-
if (
|
|
583
|
+
if (globalThis.__NO_TRAILING_SLASH__) {
|
|
975
584
|
trackUrl.pathname = trackUrl.pathname.slice(0, -1);
|
|
976
585
|
}
|
|
977
|
-
} else if (
|
|
586
|
+
} else if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
978
587
|
trackUrl.pathname += "/";
|
|
979
588
|
}
|
|
980
|
-
let loadRoutePromise = loadRoute(qwikRouterConfig.routes, qwikRouterConfig.
|
|
981
|
-
|
|
982
|
-
const pageData = clientPageData = await loadClientData(trackUrl,
|
|
589
|
+
let loadRoutePromise = loadRoute(qwikRouterConfig.routes, qwikRouterConfig.cacheModules, trackUrl.pathname);
|
|
590
|
+
container2 = _getContextContainer();
|
|
591
|
+
const pageData = clientPageData = await loadClientData(trackUrl, {
|
|
983
592
|
action,
|
|
984
593
|
clearCache: true
|
|
985
594
|
});
|
|
986
595
|
if (!pageData) {
|
|
987
|
-
|
|
596
|
+
routeInternal2.untrackedValue = {
|
|
988
597
|
type: navType,
|
|
989
598
|
dest: trackUrl
|
|
990
599
|
};
|
|
@@ -998,7 +607,6 @@ const QwikRouterProvider = component$((props) => {
|
|
|
998
607
|
}
|
|
999
608
|
loadRoutePromise = loadRoute(
|
|
1000
609
|
qwikRouterConfig.routes,
|
|
1001
|
-
qwikRouterConfig.menus,
|
|
1002
610
|
qwikRouterConfig.cacheModules,
|
|
1003
611
|
newURL.pathname
|
|
1004
612
|
// Load the actual required path.
|
|
@@ -1013,63 +621,96 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1013
621
|
}
|
|
1014
622
|
}
|
|
1015
623
|
if (loadedRoute) {
|
|
1016
|
-
const
|
|
1017
|
-
const contentModules = mods
|
|
624
|
+
const { $routeName$, $params$, $mods$, $menu$, $notFound$ } = loadedRoute;
|
|
625
|
+
const contentModules = $mods$;
|
|
626
|
+
if ($notFound$) {
|
|
627
|
+
httpStatus2.value = {
|
|
628
|
+
status: 404,
|
|
629
|
+
message: "Not Found"
|
|
630
|
+
};
|
|
631
|
+
} else {
|
|
632
|
+
httpStatus2.value = {
|
|
633
|
+
status: clientPageData?.status ?? 200,
|
|
634
|
+
message: clientPageData?.statusMessage ?? ""
|
|
635
|
+
};
|
|
636
|
+
}
|
|
1018
637
|
const pageModule = contentModules[contentModules.length - 1];
|
|
1019
|
-
|
|
1020
|
-
if (navigation.dest.search && !isRedirect) {
|
|
638
|
+
if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
|
|
1021
639
|
trackUrl.search = navigation.dest.search;
|
|
1022
640
|
}
|
|
641
|
+
let shouldForcePrevUrl = false;
|
|
642
|
+
let shouldForceUrl = false;
|
|
643
|
+
let shouldForceParams = false;
|
|
1023
644
|
if (!isSamePath(trackUrl, prevUrl)) {
|
|
1024
|
-
|
|
645
|
+
if (_hasStoreEffects(routeLocation2, "prevUrl")) {
|
|
646
|
+
shouldForcePrevUrl = true;
|
|
647
|
+
}
|
|
648
|
+
routeLocationTarget2.prevUrl = prevUrl;
|
|
1025
649
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
650
|
+
if (routeLocationTarget2.url !== trackUrl) {
|
|
651
|
+
if (_hasStoreEffects(routeLocation2, "url")) {
|
|
652
|
+
shouldForceUrl = true;
|
|
653
|
+
}
|
|
654
|
+
routeLocationTarget2.url = trackUrl;
|
|
655
|
+
}
|
|
656
|
+
if (routeLocationTarget2.params !== $params$) {
|
|
657
|
+
if (_hasStoreEffects(routeLocation2, "params")) {
|
|
658
|
+
shouldForceParams = true;
|
|
659
|
+
}
|
|
660
|
+
routeLocationTarget2.params = $params$;
|
|
661
|
+
}
|
|
662
|
+
routeInternal2.untrackedValue = {
|
|
1031
663
|
type: navType,
|
|
1032
664
|
dest: trackUrl
|
|
1033
665
|
};
|
|
1034
|
-
const resolvedHead = resolveHead(clientPageData,
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
666
|
+
const resolvedHead = resolveHead(clientPageData, routeLocation2, contentModules, locale, serverHead2);
|
|
667
|
+
content2.headings = pageModule.headings;
|
|
668
|
+
content2.menu = $menu$;
|
|
669
|
+
contentInternal2.untrackedValue = noSerialize(contentModules);
|
|
670
|
+
documentHead2.links = resolvedHead.links;
|
|
671
|
+
documentHead2.meta = resolvedHead.meta;
|
|
672
|
+
documentHead2.styles = resolvedHead.styles;
|
|
673
|
+
documentHead2.scripts = resolvedHead.scripts;
|
|
674
|
+
documentHead2.title = resolvedHead.title;
|
|
675
|
+
documentHead2.frontmatter = resolvedHead.frontmatter;
|
|
1044
676
|
if (isBrowser) {
|
|
1045
677
|
let scrollState;
|
|
1046
678
|
if (navType === "popstate") {
|
|
1047
679
|
scrollState = getScrollHistory();
|
|
1048
680
|
}
|
|
1049
|
-
const scroller =
|
|
1050
|
-
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") ||
|
|
681
|
+
const scroller = await getScroller2();
|
|
682
|
+
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
|
|
1051
683
|
document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
1052
684
|
}
|
|
1053
685
|
const loaders = clientPageData?.loaders;
|
|
1054
|
-
const win = window;
|
|
1055
686
|
if (loaders) {
|
|
1056
|
-
|
|
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
|
+
}
|
|
697
|
+
}
|
|
1057
698
|
}
|
|
1058
699
|
CLIENT_DATA_CACHE.clear();
|
|
1059
|
-
if (!
|
|
1060
|
-
|
|
700
|
+
if (!window._qRouterSPA) {
|
|
701
|
+
window._qRouterSPA = true;
|
|
1061
702
|
history.scrollRestoration = "manual";
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
clearTimeout(
|
|
1065
|
-
|
|
703
|
+
window.addEventListener("popstate", () => {
|
|
704
|
+
window._qRouterScrollEnabled = false;
|
|
705
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
706
|
+
goto2(location.href, {
|
|
1066
707
|
type: "popstate"
|
|
1067
708
|
});
|
|
1068
709
|
});
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
if (!
|
|
1072
|
-
|
|
710
|
+
window.removeEventListener("popstate", window._qRouterInitPopstate);
|
|
711
|
+
window._qRouterInitPopstate = void 0;
|
|
712
|
+
if (!window._qRouterHistoryPatch) {
|
|
713
|
+
window._qRouterHistoryPatch = true;
|
|
1073
714
|
const pushState = history.pushState;
|
|
1074
715
|
const replaceState2 = history.replaceState;
|
|
1075
716
|
const prepareState = (state) => {
|
|
@@ -1095,7 +736,7 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1095
736
|
return replaceState2.call(history, state, title, url2);
|
|
1096
737
|
};
|
|
1097
738
|
}
|
|
1098
|
-
document.
|
|
739
|
+
document.addEventListener("click", (event) => {
|
|
1099
740
|
if (event.defaultPrevented) {
|
|
1100
741
|
return;
|
|
1101
742
|
}
|
|
@@ -1110,8 +751,8 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1110
751
|
if (dest.href !== prev.href) {
|
|
1111
752
|
history.pushState(null, "", dest);
|
|
1112
753
|
}
|
|
1113
|
-
|
|
1114
|
-
clearTimeout(
|
|
754
|
+
window._qRouterScrollEnabled = false;
|
|
755
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
1115
756
|
saveScrollHistory({
|
|
1116
757
|
...currentScrollState(scroller),
|
|
1117
758
|
x: 0,
|
|
@@ -1120,16 +761,16 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1120
761
|
location.reload();
|
|
1121
762
|
return;
|
|
1122
763
|
}
|
|
1123
|
-
|
|
764
|
+
goto2(target.getAttribute("href"));
|
|
1124
765
|
}
|
|
1125
766
|
}
|
|
1126
767
|
});
|
|
1127
|
-
document.
|
|
1128
|
-
|
|
768
|
+
document.removeEventListener("click", window._qRouterInitAnchors);
|
|
769
|
+
window._qRouterInitAnchors = void 0;
|
|
1129
770
|
if (!window.navigation) {
|
|
1130
771
|
document.addEventListener("visibilitychange", () => {
|
|
1131
|
-
if ((
|
|
1132
|
-
if (
|
|
772
|
+
if ((window._qRouterScrollEnabled || window._qCityScrollEnabled) && document.visibilityState === "hidden") {
|
|
773
|
+
if (window._qCityScrollEnabled) {
|
|
1133
774
|
console.warn('"_qCityScrollEnabled" is deprecated. Use "_qRouterScrollEnabled" instead.');
|
|
1134
775
|
}
|
|
1135
776
|
const scrollState2 = currentScrollState(scroller);
|
|
@@ -1138,38 +779,49 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1138
779
|
}, {
|
|
1139
780
|
passive: true
|
|
1140
781
|
});
|
|
1141
|
-
document.removeEventListener("visibilitychange",
|
|
1142
|
-
|
|
782
|
+
document.removeEventListener("visibilitychange", window._qRouterInitVisibility);
|
|
783
|
+
window._qRouterInitVisibility = void 0;
|
|
1143
784
|
}
|
|
1144
|
-
|
|
1145
|
-
if (!
|
|
785
|
+
window.addEventListener("scroll", () => {
|
|
786
|
+
if (!window._qRouterScrollEnabled && !window._qCityScrollEnabled) {
|
|
1146
787
|
return;
|
|
1147
788
|
}
|
|
1148
|
-
clearTimeout(
|
|
1149
|
-
|
|
789
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
790
|
+
window._qRouterScrollDebounce = setTimeout(() => {
|
|
1150
791
|
const scrollState2 = currentScrollState(scroller);
|
|
1151
792
|
saveScrollHistory(scrollState2);
|
|
1152
|
-
|
|
793
|
+
window._qRouterScrollDebounce = void 0;
|
|
1153
794
|
}, 200);
|
|
1154
795
|
}, {
|
|
1155
796
|
passive: true
|
|
1156
797
|
});
|
|
1157
|
-
removeEventListener("scroll",
|
|
1158
|
-
|
|
798
|
+
removeEventListener("scroll", window._qRouterInitScroll);
|
|
799
|
+
window._qRouterInitScroll = void 0;
|
|
1159
800
|
spaInit.resolve();
|
|
1160
801
|
}
|
|
1161
802
|
if (navType !== "popstate") {
|
|
1162
|
-
|
|
1163
|
-
clearTimeout(
|
|
1164
|
-
|
|
1165
|
-
|
|
803
|
+
window._qRouterScrollEnabled = false;
|
|
804
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
805
|
+
if (!navigation.historyUpdated) {
|
|
806
|
+
const scrollState2 = currentScrollState(scroller);
|
|
807
|
+
saveScrollHistory(scrollState2);
|
|
808
|
+
}
|
|
1166
809
|
}
|
|
1167
810
|
const navigate = () => {
|
|
1168
|
-
|
|
1169
|
-
|
|
811
|
+
if (navigation.historyUpdated) {
|
|
812
|
+
const currentPath = location.pathname + location.search + location.hash;
|
|
813
|
+
const nextPath = toPath(trackUrl);
|
|
814
|
+
if (currentPath !== nextPath) {
|
|
815
|
+
history.replaceState(history.state, "", nextPath);
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
|
|
819
|
+
}
|
|
820
|
+
contentInternal2.trigger();
|
|
821
|
+
return _waitUntilRendered(container2);
|
|
1170
822
|
};
|
|
1171
823
|
const _waitNextPage = () => {
|
|
1172
|
-
if (isServer ||
|
|
824
|
+
if (isServer || props2?.viewTransition === false) {
|
|
1173
825
|
return navigate();
|
|
1174
826
|
} else {
|
|
1175
827
|
const viewTransition = startViewTransition({
|
|
@@ -1184,17 +836,28 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1184
836
|
return viewTransition.ready;
|
|
1185
837
|
}
|
|
1186
838
|
};
|
|
1187
|
-
_waitNextPage().
|
|
1188
|
-
|
|
1189
|
-
|
|
839
|
+
_waitNextPage().catch((err) => {
|
|
840
|
+
navigate();
|
|
841
|
+
throw err;
|
|
842
|
+
}).finally(() => {
|
|
843
|
+
container2.element.setAttribute?.(Q_ROUTE, $routeName$);
|
|
1190
844
|
const scrollState2 = currentScrollState(scroller);
|
|
1191
845
|
saveScrollHistory(scrollState2);
|
|
1192
|
-
|
|
846
|
+
window._qRouterScrollEnabled = true;
|
|
1193
847
|
if (isBrowser) {
|
|
1194
848
|
callRestoreScrollOnDocument();
|
|
1195
849
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
850
|
+
if (shouldForcePrevUrl) {
|
|
851
|
+
forceStoreEffects(routeLocation2, "prevUrl");
|
|
852
|
+
}
|
|
853
|
+
if (shouldForceUrl) {
|
|
854
|
+
forceStoreEffects(routeLocation2, "url");
|
|
855
|
+
}
|
|
856
|
+
if (shouldForceParams) {
|
|
857
|
+
forceStoreEffects(routeLocation2, "params");
|
|
858
|
+
}
|
|
859
|
+
routeLocation2.isNavigating = false;
|
|
860
|
+
navResolver2.r?.();
|
|
1198
861
|
});
|
|
1199
862
|
}
|
|
1200
863
|
}
|
|
@@ -1204,11 +867,31 @@ const QwikRouterProvider = component$((props) => {
|
|
|
1204
867
|
} else {
|
|
1205
868
|
run();
|
|
1206
869
|
}
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
|
|
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
|
+
]));
|
|
888
|
+
};
|
|
889
|
+
const QwikRouterProvider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
890
|
+
useQwikRouter(props);
|
|
891
|
+
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "5y_0");
|
|
892
|
+
}, "QwikRouterProvider_component_6Kjfa79mqlY"));
|
|
1210
893
|
const QwikCityProvider = QwikRouterProvider;
|
|
1211
|
-
const
|
|
894
|
+
const useQwikMockRouter = (props) => {
|
|
1212
895
|
const urlEnv = props.url ?? "http://localhost/";
|
|
1213
896
|
const url = new URL(urlEnv);
|
|
1214
897
|
const routeLocation = useStore({
|
|
@@ -1219,14 +902,16 @@ const QwikRouterMockProvider = component$((props) => {
|
|
|
1219
902
|
}, {
|
|
1220
903
|
deep: false
|
|
1221
904
|
});
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
905
|
+
const loadersData = props.loaders?.reduce((acc, { loader, data }) => {
|
|
906
|
+
acc[loader.__id] = data;
|
|
907
|
+
return acc;
|
|
908
|
+
}, {});
|
|
909
|
+
const loaderState = useStore(loadersData ?? {}, {
|
|
910
|
+
deep: false
|
|
1226
911
|
});
|
|
1227
|
-
const goto = props.goto ??
|
|
912
|
+
const goto = props.goto ?? /* @__PURE__ */ inlinedQrl(async () => {
|
|
1228
913
|
console.warn("QwikRouterMockProvider: goto not provided");
|
|
1229
|
-
});
|
|
914
|
+
}, "useQwikMockRouter_goto_aViHFxQ1a3s");
|
|
1230
915
|
const documentHead = useStore(createDocumentHead, {
|
|
1231
916
|
deep: false
|
|
1232
917
|
});
|
|
@@ -1238,277 +923,106 @@ const QwikRouterMockProvider = component$((props) => {
|
|
|
1238
923
|
});
|
|
1239
924
|
const contentInternal = useSignal();
|
|
1240
925
|
const actionState = useSignal();
|
|
926
|
+
const httpStatus = useSignal({
|
|
927
|
+
status: 200,
|
|
928
|
+
message: ""
|
|
929
|
+
});
|
|
1241
930
|
useContextProvider(ContentContext, content);
|
|
1242
931
|
useContextProvider(ContentInternalContext, contentInternal);
|
|
1243
932
|
useContextProvider(DocumentHeadContext, documentHead);
|
|
933
|
+
useContextProvider(HttpStatusContext, httpStatus);
|
|
1244
934
|
useContextProvider(RouteLocationContext, routeLocation);
|
|
1245
935
|
useContextProvider(RouteNavigateContext, goto);
|
|
1246
936
|
useContextProvider(RouteStateContext, loaderState);
|
|
1247
937
|
useContextProvider(RouteActionContext, actionState);
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
938
|
+
const actionsMocks = props.actions?.reduce((acc, { action, handler }) => {
|
|
939
|
+
acc[action.__id] = handler;
|
|
940
|
+
return acc;
|
|
941
|
+
}, {});
|
|
942
|
+
useTaskQrl(/* @__PURE__ */ inlinedQrl(async ({ track }) => {
|
|
943
|
+
const actionState2 = _captures[0], actionsMocks2 = _captures[1];
|
|
944
|
+
const action = track(actionState2);
|
|
945
|
+
if (!action?.resolve) {
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
const mock = actionsMocks2?.[action.id];
|
|
949
|
+
if (mock) {
|
|
950
|
+
const actionResult = await mock(action.data);
|
|
951
|
+
action.resolve(actionResult);
|
|
952
|
+
}
|
|
953
|
+
}, "useQwikMockRouter_useTask_tXTLR4tzCy0", [
|
|
954
|
+
actionState,
|
|
955
|
+
actionsMocks
|
|
956
|
+
]));
|
|
957
|
+
};
|
|
958
|
+
const QwikRouterMockProvider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
959
|
+
useQwikMockRouter(props);
|
|
960
|
+
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "5y_1");
|
|
961
|
+
}, "QwikRouterMockProvider_component_IN4dVpT0x74"));
|
|
1251
962
|
const QwikCityMockProvider = QwikRouterMockProvider;
|
|
1252
|
-
|
|
963
|
+
|
|
964
|
+
const RouterOutlet = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
1253
965
|
const serverData = useServerData("containerAttributes");
|
|
1254
966
|
if (!serverData) {
|
|
1255
967
|
throw new Error("PrefetchServiceWorker component must be rendered on the server.");
|
|
1256
968
|
}
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
|
|
969
|
+
const internalContext = useContext(ContentInternalContext);
|
|
970
|
+
const contents = internalContext.value;
|
|
971
|
+
if (contents && contents.length > 0) {
|
|
972
|
+
const contentsLen = contents.length;
|
|
1260
973
|
let cmp = null;
|
|
1261
974
|
for (let i = contentsLen - 1; i >= 0; i--) {
|
|
1262
|
-
if (
|
|
1263
|
-
cmp =
|
|
1264
|
-
children: cmp
|
|
1265
|
-
});
|
|
975
|
+
if (contents[i].default) {
|
|
976
|
+
cmp = _jsxSorted(contents[i].default, null, null, cmp, 1, "Fn_0");
|
|
1266
977
|
}
|
|
1267
978
|
}
|
|
1268
|
-
return /* @__PURE__ */
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
if (s) {
|
|
1279
|
-
w.scrollTo(s.x, s.y);
|
|
1280
|
-
}
|
|
1281
|
-
document.dispatchEvent(new Event("qcinit"));
|
|
979
|
+
return /* @__PURE__ */ _jsxSorted(Fragment, null, null, [
|
|
980
|
+
cmp,
|
|
981
|
+
!__EXPERIMENTAL__.noSPA && /* @__PURE__ */ _jsxSorted("script", {
|
|
982
|
+
"q-d:qinit": _qrlSync(() => {
|
|
983
|
+
((w, h) => {
|
|
984
|
+
if (!w._qcs && h.scrollRestoration === "manual") {
|
|
985
|
+
w._qcs = true;
|
|
986
|
+
const s = h.state?._qRouterScroll;
|
|
987
|
+
if (s) {
|
|
988
|
+
w.scrollTo(s.x, s.y);
|
|
1282
989
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
990
|
+
document.dispatchEvent(new Event("qcinit"));
|
|
991
|
+
}
|
|
992
|
+
})(window, history);
|
|
993
|
+
}, '()=>{((w,h)=>{if(!w._qcs&&h.scrollRestoration==="manual"){w._qcs=!0;const s=h.state?._qRouterScroll;if(s){w.scrollTo(s.x,s.y);}document.dispatchEvent(new Event("qcinit"));}})(window,history);}')
|
|
994
|
+
}, {
|
|
995
|
+
"q-d:qcinit": spaInit
|
|
996
|
+
}, null, 2, "Fn_1")
|
|
997
|
+
], 1, "Fn_2");
|
|
1288
998
|
}
|
|
1289
999
|
return SkipRender;
|
|
1290
|
-
});
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
function getDotPath(issue) {
|
|
1301
|
-
if (issue.path) {
|
|
1302
|
-
let key = "";
|
|
1303
|
-
for (const item of issue.path) {
|
|
1304
|
-
if (typeof item.key === "string" || typeof item.key === "number") {
|
|
1305
|
-
if (key) {
|
|
1306
|
-
key += `.${item.key}`;
|
|
1307
|
-
} else {
|
|
1308
|
-
key += item.key;
|
|
1309
|
-
}
|
|
1310
|
-
} else {
|
|
1311
|
-
return null;
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
return key;
|
|
1000
|
+
}, "RouterOutlet_component_QwONcWD5gIg"));
|
|
1001
|
+
|
|
1002
|
+
const getValue = (obj) => obj.value;
|
|
1003
|
+
const validatorQrl = (validator) => {
|
|
1004
|
+
if (isServer) {
|
|
1005
|
+
return {
|
|
1006
|
+
validate: validator
|
|
1007
|
+
};
|
|
1315
1008
|
}
|
|
1316
|
-
return
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1009
|
+
return void 0;
|
|
1010
|
+
};
|
|
1011
|
+
const validator$ = /* @__PURE__ */ implicit$FirstArg(validatorQrl);
|
|
1012
|
+
const flattenValibotIssues = (issues) => {
|
|
1013
|
+
return issues.reduce((acc, issue) => {
|
|
1321
1014
|
if (issue.path) {
|
|
1322
|
-
const
|
|
1323
|
-
if (
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
if (
|
|
1328
|
-
|
|
1329
|
-
} else {
|
|
1330
|
-
flatErrors.nested[dotPath] = [issue.message];
|
|
1015
|
+
const hasArrayType = issue.path.some((path) => path.type === "array");
|
|
1016
|
+
if (hasArrayType) {
|
|
1017
|
+
const keySuffix = issue.expected === "Array" ? "[]" : "";
|
|
1018
|
+
const key = issue.path.map((item) => item.type === "array" ? "*" : item.key).join(".").replace(/\.\*/g, "[]") + keySuffix;
|
|
1019
|
+
acc[key] = acc[key] || [];
|
|
1020
|
+
if (Array.isArray(acc[key])) {
|
|
1021
|
+
acc[key].push(issue.message);
|
|
1331
1022
|
}
|
|
1023
|
+
return acc;
|
|
1332
1024
|
} else {
|
|
1333
|
-
|
|
1334
|
-
flatErrors.other.push(issue.message);
|
|
1335
|
-
} else {
|
|
1336
|
-
flatErrors.other = [issue.message];
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
} else {
|
|
1340
|
-
if (flatErrors.root) {
|
|
1341
|
-
flatErrors.root.push(issue.message);
|
|
1342
|
-
} else {
|
|
1343
|
-
flatErrors.root = [issue.message];
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
return flatErrors;
|
|
1348
|
-
}
|
|
1349
|
-
async function safeParseAsync(schema, input, config2) {
|
|
1350
|
-
const dataset = await schema._run(
|
|
1351
|
-
{ typed: false, value: input },
|
|
1352
|
-
getGlobalConfig(config2)
|
|
1353
|
-
);
|
|
1354
|
-
return {
|
|
1355
|
-
typed: dataset.typed,
|
|
1356
|
-
success: !dataset.issues,
|
|
1357
|
-
output: dataset.value,
|
|
1358
|
-
issues: dataset.issues
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
const routeActionQrl = (actionQrl, ...rest) => {
|
|
1362
|
-
const { id, validators } = getValidators(rest, actionQrl);
|
|
1363
|
-
function action() {
|
|
1364
|
-
const loc = useLocation();
|
|
1365
|
-
const currentAction = useAction();
|
|
1366
|
-
const initialState = {
|
|
1367
|
-
actionPath: `?${QACTION_KEY}=${id}`,
|
|
1368
|
-
submitted: false,
|
|
1369
|
-
isRunning: false,
|
|
1370
|
-
status: void 0,
|
|
1371
|
-
value: void 0,
|
|
1372
|
-
formData: void 0
|
|
1373
|
-
};
|
|
1374
|
-
const state = useStore(() => {
|
|
1375
|
-
const value = currentAction.value;
|
|
1376
|
-
if (value && value?.id === id) {
|
|
1377
|
-
const data = value.data;
|
|
1378
|
-
if (data instanceof FormData) {
|
|
1379
|
-
initialState.formData = data;
|
|
1380
|
-
}
|
|
1381
|
-
if (value.output) {
|
|
1382
|
-
const { status, result } = value.output;
|
|
1383
|
-
initialState.status = status;
|
|
1384
|
-
initialState.value = result;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
return initialState;
|
|
1388
|
-
});
|
|
1389
|
-
const submit = $((input = {}) => {
|
|
1390
|
-
if (isServer) {
|
|
1391
|
-
throw new Error(`Actions can not be invoked within the server during SSR.
|
|
1392
|
-
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
|
|
1393
|
-
}
|
|
1394
|
-
let data;
|
|
1395
|
-
let form;
|
|
1396
|
-
if (input instanceof SubmitEvent) {
|
|
1397
|
-
form = input.target;
|
|
1398
|
-
data = new FormData(form);
|
|
1399
|
-
if ((input.submitter instanceof HTMLInputElement || input.submitter instanceof HTMLButtonElement) && input.submitter.name) {
|
|
1400
|
-
if (input.submitter.name) {
|
|
1401
|
-
data.append(input.submitter.name, input.submitter.value);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
} else {
|
|
1405
|
-
data = input;
|
|
1406
|
-
}
|
|
1407
|
-
return new Promise((resolve) => {
|
|
1408
|
-
if (data instanceof FormData) {
|
|
1409
|
-
state.formData = data;
|
|
1410
|
-
}
|
|
1411
|
-
state.submitted = true;
|
|
1412
|
-
state.isRunning = true;
|
|
1413
|
-
loc.isNavigating = true;
|
|
1414
|
-
currentAction.value = {
|
|
1415
|
-
data,
|
|
1416
|
-
id,
|
|
1417
|
-
resolve: noSerialize(resolve)
|
|
1418
|
-
};
|
|
1419
|
-
}).then(({ result, status }) => {
|
|
1420
|
-
state.isRunning = false;
|
|
1421
|
-
state.status = status;
|
|
1422
|
-
state.value = result;
|
|
1423
|
-
if (form) {
|
|
1424
|
-
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1425
|
-
form.reset();
|
|
1426
|
-
}
|
|
1427
|
-
const detail = {
|
|
1428
|
-
status,
|
|
1429
|
-
value: result
|
|
1430
|
-
};
|
|
1431
|
-
form.dispatchEvent(new CustomEvent("submitcompleted", {
|
|
1432
|
-
bubbles: false,
|
|
1433
|
-
cancelable: false,
|
|
1434
|
-
composed: false,
|
|
1435
|
-
detail
|
|
1436
|
-
}));
|
|
1437
|
-
}
|
|
1438
|
-
return {
|
|
1439
|
-
status,
|
|
1440
|
-
value: result
|
|
1441
|
-
};
|
|
1442
|
-
});
|
|
1443
|
-
});
|
|
1444
|
-
initialState.submit = submit;
|
|
1445
|
-
return state;
|
|
1446
|
-
}
|
|
1447
|
-
action.__brand = "server_action";
|
|
1448
|
-
action.__validators = validators;
|
|
1449
|
-
action.__qrl = actionQrl;
|
|
1450
|
-
action.__id = id;
|
|
1451
|
-
Object.freeze(action);
|
|
1452
|
-
return action;
|
|
1453
|
-
};
|
|
1454
|
-
const globalActionQrl = (actionQrl, ...rest) => {
|
|
1455
|
-
const action = routeActionQrl(actionQrl, ...rest);
|
|
1456
|
-
if (isServer) {
|
|
1457
|
-
if (typeof globalThis._qwikActionsMap === "undefined") {
|
|
1458
|
-
globalThis._qwikActionsMap = /* @__PURE__ */ new Map();
|
|
1459
|
-
}
|
|
1460
|
-
globalThis._qwikActionsMap.set(action.__id, action);
|
|
1461
|
-
}
|
|
1462
|
-
return action;
|
|
1463
|
-
};
|
|
1464
|
-
const routeAction$ = /* @__PURE__ */ implicit$FirstArg(routeActionQrl);
|
|
1465
|
-
const globalAction$ = /* @__PURE__ */ implicit$FirstArg(globalActionQrl);
|
|
1466
|
-
const routeLoaderQrl = (loaderQrl, ...rest) => {
|
|
1467
|
-
const { id, validators } = getValidators(rest, loaderQrl);
|
|
1468
|
-
function loader() {
|
|
1469
|
-
return useContext(RouteStateContext, (state) => {
|
|
1470
|
-
if (!(id in state)) {
|
|
1471
|
-
throw new Error(`routeLoader$ "${loaderQrl.getSymbol()}" was invoked in a route where it was not declared.
|
|
1472
|
-
This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
|
|
1473
|
-
For more information check: https://qwik.dev/docs/route-loader/
|
|
1474
|
-
|
|
1475
|
-
If your are managing reusable logic or a library it is essential that this function is re-exported from within 'layout.tsx' or 'index.tsx file of the existing route otherwise it will not run or throw exception.
|
|
1476
|
-
For more information check: https://qwik.dev/docs/re-exporting-loaders/`);
|
|
1477
|
-
}
|
|
1478
|
-
return _wrapStore(state, id);
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
loader.__brand = "server_loader";
|
|
1482
|
-
loader.__qrl = loaderQrl;
|
|
1483
|
-
loader.__validators = validators;
|
|
1484
|
-
loader.__id = id;
|
|
1485
|
-
Object.freeze(loader);
|
|
1486
|
-
return loader;
|
|
1487
|
-
};
|
|
1488
|
-
const routeLoader$ = /* @__PURE__ */ implicit$FirstArg(routeLoaderQrl);
|
|
1489
|
-
const validatorQrl = (validator) => {
|
|
1490
|
-
if (isServer) {
|
|
1491
|
-
return {
|
|
1492
|
-
validate: validator
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
return void 0;
|
|
1496
|
-
};
|
|
1497
|
-
const validator$ = /* @__PURE__ */ implicit$FirstArg(validatorQrl);
|
|
1498
|
-
const flattenValibotIssues = (issues) => {
|
|
1499
|
-
return issues.reduce((acc, issue) => {
|
|
1500
|
-
if (issue.path) {
|
|
1501
|
-
const hasArrayType = issue.path.some((path) => path.type === "array");
|
|
1502
|
-
if (hasArrayType) {
|
|
1503
|
-
const keySuffix = issue.expected === "Array" ? "[]" : "";
|
|
1504
|
-
const key = issue.path.map((item) => item.type === "array" ? "*" : item.key).join(".").replace(/\.\*/g, "[]") + keySuffix;
|
|
1505
|
-
acc[key] = acc[key] || [];
|
|
1506
|
-
if (Array.isArray(acc[key])) {
|
|
1507
|
-
acc[key].push(issue.message);
|
|
1508
|
-
}
|
|
1509
|
-
return acc;
|
|
1510
|
-
} else {
|
|
1511
|
-
acc[issue.path.map((item) => item.key).join(".")] = issue.message;
|
|
1025
|
+
acc[issue.path.map((item) => item.key).join(".")] = issue.message;
|
|
1512
1026
|
}
|
|
1513
1027
|
}
|
|
1514
1028
|
return acc;
|
|
@@ -1524,7 +1038,7 @@ const valibotQrl = (qrl) => {
|
|
|
1524
1038
|
async validate(ev, inputData) {
|
|
1525
1039
|
const schema = await qrl.resolve().then((obj) => typeof obj === "function" ? obj(ev) : obj);
|
|
1526
1040
|
const data = inputData ?? await ev.parseBody();
|
|
1527
|
-
const result = await safeParseAsync(schema, data);
|
|
1041
|
+
const result = await v.safeParseAsync(schema, data);
|
|
1528
1042
|
if (result.success) {
|
|
1529
1043
|
return {
|
|
1530
1044
|
success: true,
|
|
@@ -1538,7 +1052,7 @@ const valibotQrl = (qrl) => {
|
|
|
1538
1052
|
success: false,
|
|
1539
1053
|
status: 400,
|
|
1540
1054
|
error: {
|
|
1541
|
-
formErrors: flatten(result.issues).root ?? [],
|
|
1055
|
+
formErrors: v.flatten(result.issues).root ?? [],
|
|
1542
1056
|
fieldErrors: flattenValibotIssues(result.issues)
|
|
1543
1057
|
}
|
|
1544
1058
|
};
|
|
@@ -1586,7 +1100,7 @@ const zodQrl = (qrl) => {
|
|
|
1586
1100
|
}
|
|
1587
1101
|
});
|
|
1588
1102
|
const data = inputData ?? await ev.parseBody();
|
|
1589
|
-
const result = await schema.safeParseAsync(data);
|
|
1103
|
+
const result = await withLocale(ev.locale(), () => schema.safeParseAsync(data));
|
|
1590
1104
|
if (result.success) {
|
|
1591
1105
|
return result;
|
|
1592
1106
|
} else {
|
|
@@ -1608,108 +1122,9 @@ const zodQrl = (qrl) => {
|
|
|
1608
1122
|
return void 0;
|
|
1609
1123
|
};
|
|
1610
1124
|
const zod$ = /* @__PURE__ */ implicit$FirstArg(zodQrl);
|
|
1611
|
-
const serverQrl = (qrl, options) => {
|
|
1612
|
-
if (isServer) {
|
|
1613
|
-
const captured = qrl.getCaptured();
|
|
1614
|
-
if (captured && captured.length > 0 && !_getContextElement()) {
|
|
1615
|
-
throw new Error("For security reasons, we cannot serialize QRLs that capture lexical scope.");
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
const method = options?.method?.toUpperCase?.() || "POST";
|
|
1619
|
-
const headers = options?.headers || {};
|
|
1620
|
-
const origin = options?.origin || "";
|
|
1621
|
-
const fetchOptions = options?.fetchOptions || {};
|
|
1622
|
-
function rpc() {
|
|
1623
|
-
return $(async function(...args) {
|
|
1624
|
-
const abortSignal = args.length > 0 && args[0] instanceof AbortSignal ? args.shift() : void 0;
|
|
1625
|
-
if (isServer) {
|
|
1626
|
-
let requestEvent = globalThis.qcAsyncRequestStore?.getStore();
|
|
1627
|
-
if (!requestEvent) {
|
|
1628
|
-
const contexts = [
|
|
1629
|
-
useQwikRouterEnv()?.ev,
|
|
1630
|
-
this,
|
|
1631
|
-
_getContextEvent()
|
|
1632
|
-
];
|
|
1633
|
-
requestEvent = contexts.find((v2) => v2 && Object.prototype.hasOwnProperty.call(v2, "sharedMap") && Object.prototype.hasOwnProperty.call(v2, "cookie"));
|
|
1634
|
-
}
|
|
1635
|
-
return qrl.apply(requestEvent, isDev ? deepFreeze(args) : args);
|
|
1636
|
-
} else {
|
|
1637
|
-
const ctxElm = _getContextElement();
|
|
1638
|
-
const filteredArgs = args.map((arg) => {
|
|
1639
|
-
if (arg instanceof SubmitEvent && arg.target instanceof HTMLFormElement) {
|
|
1640
|
-
return new FormData(arg.target);
|
|
1641
|
-
} else if (arg instanceof Event) {
|
|
1642
|
-
return null;
|
|
1643
|
-
} else if (arg instanceof Node) {
|
|
1644
|
-
return null;
|
|
1645
|
-
}
|
|
1646
|
-
return arg;
|
|
1647
|
-
});
|
|
1648
|
-
const qrlHash = qrl.getHash();
|
|
1649
|
-
let query = "";
|
|
1650
|
-
const config = {
|
|
1651
|
-
...fetchOptions,
|
|
1652
|
-
method,
|
|
1653
|
-
headers: {
|
|
1654
|
-
...headers,
|
|
1655
|
-
"Content-Type": "application/qwik-json",
|
|
1656
|
-
Accept: "application/json, application/qwik-json, text/qwik-json-stream, text/plain",
|
|
1657
|
-
// Required so we don't call accidentally
|
|
1658
|
-
"X-QRL": qrlHash
|
|
1659
|
-
},
|
|
1660
|
-
signal: abortSignal
|
|
1661
|
-
};
|
|
1662
|
-
const body = await _serialize([
|
|
1663
|
-
qrl,
|
|
1664
|
-
...filteredArgs
|
|
1665
|
-
]);
|
|
1666
|
-
if (method === "GET") {
|
|
1667
|
-
query += `&${QDATA_KEY}=${encodeURIComponent(body)}`;
|
|
1668
|
-
} else {
|
|
1669
|
-
config.body = body;
|
|
1670
|
-
}
|
|
1671
|
-
const res = await fetch(`${origin}?${QFN_KEY}=${qrlHash}${query}`, config);
|
|
1672
|
-
const contentType = res.headers.get("Content-Type");
|
|
1673
|
-
if (res.ok && contentType === "text/qwik-json-stream" && res.body) {
|
|
1674
|
-
return async function* () {
|
|
1675
|
-
try {
|
|
1676
|
-
for await (const result of deserializeStream(res.body, ctxElm ?? document.documentElement, abortSignal)) {
|
|
1677
|
-
yield result;
|
|
1678
|
-
}
|
|
1679
|
-
} finally {
|
|
1680
|
-
if (!abortSignal?.aborted) {
|
|
1681
|
-
await res.body.cancel();
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
}();
|
|
1685
|
-
} else if (contentType === "application/qwik-json") {
|
|
1686
|
-
const str = await res.text();
|
|
1687
|
-
const [obj] = _deserialize(str, ctxElm ?? document.documentElement);
|
|
1688
|
-
if (res.status >= 400) {
|
|
1689
|
-
throw obj;
|
|
1690
|
-
}
|
|
1691
|
-
return obj;
|
|
1692
|
-
} else if (contentType === "application/json") {
|
|
1693
|
-
const obj = await res.json();
|
|
1694
|
-
if (res.status >= 400) {
|
|
1695
|
-
throw obj;
|
|
1696
|
-
}
|
|
1697
|
-
return obj;
|
|
1698
|
-
} else if (contentType === "text/plain" || contentType === "text/html") {
|
|
1699
|
-
const str = await res.text();
|
|
1700
|
-
if (res.status >= 400) {
|
|
1701
|
-
throw str;
|
|
1702
|
-
}
|
|
1703
|
-
return str;
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
return rpc();
|
|
1709
|
-
};
|
|
1710
|
-
const server$ = /* @__PURE__ */ implicit$FirstArg(serverQrl);
|
|
1711
1125
|
const getValidators = (rest, qrl) => {
|
|
1712
1126
|
let id;
|
|
1127
|
+
let serializationStrategy = DEFAULT_LOADERS_SERIALIZATION_STRATEGY;
|
|
1713
1128
|
const validators = [];
|
|
1714
1129
|
if (rest.length === 1) {
|
|
1715
1130
|
const options = rest[0];
|
|
@@ -1718,6 +1133,9 @@ const getValidators = (rest, qrl) => {
|
|
|
1718
1133
|
validators.push(options);
|
|
1719
1134
|
} else {
|
|
1720
1135
|
id = options.id;
|
|
1136
|
+
if (options.serializationStrategy) {
|
|
1137
|
+
serializationStrategy = options.serializationStrategy;
|
|
1138
|
+
}
|
|
1721
1139
|
if (options.validation) {
|
|
1722
1140
|
validators.push(...options.validation);
|
|
1723
1141
|
}
|
|
@@ -1738,10 +1156,148 @@ const getValidators = (rest, qrl) => {
|
|
|
1738
1156
|
}
|
|
1739
1157
|
return {
|
|
1740
1158
|
validators: validators.reverse(),
|
|
1741
|
-
id
|
|
1159
|
+
id,
|
|
1160
|
+
serializationStrategy
|
|
1742
1161
|
};
|
|
1743
1162
|
};
|
|
1744
|
-
const
|
|
1163
|
+
const routeActionQrl = (actionQrl, ...rest) => {
|
|
1164
|
+
const { id, validators } = getValidators(rest, actionQrl);
|
|
1165
|
+
function action() {
|
|
1166
|
+
const loc = useLocation();
|
|
1167
|
+
const currentAction = useAction();
|
|
1168
|
+
const initialState = {
|
|
1169
|
+
actionPath: `?${QACTION_KEY}=${id}`,
|
|
1170
|
+
submitted: false,
|
|
1171
|
+
isRunning: false,
|
|
1172
|
+
status: void 0,
|
|
1173
|
+
value: void 0,
|
|
1174
|
+
formData: void 0
|
|
1175
|
+
};
|
|
1176
|
+
const state = useStore(() => {
|
|
1177
|
+
const value = currentAction.value;
|
|
1178
|
+
if (value && value?.id === id) {
|
|
1179
|
+
const data = value.data;
|
|
1180
|
+
if (data instanceof FormData) {
|
|
1181
|
+
initialState.formData = data;
|
|
1182
|
+
}
|
|
1183
|
+
if (value.output) {
|
|
1184
|
+
const { status, result } = value.output;
|
|
1185
|
+
initialState.status = status;
|
|
1186
|
+
initialState.value = result;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return initialState;
|
|
1190
|
+
});
|
|
1191
|
+
const submit = /* @__PURE__ */ inlinedQrl((input = {}) => {
|
|
1192
|
+
const currentAction2 = _captures[0], id2 = _captures[1], loc2 = _captures[2], state2 = _captures[3];
|
|
1193
|
+
if (isServer) {
|
|
1194
|
+
throw new Error(`Actions can not be invoked within the server during SSR.
|
|
1195
|
+
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
|
|
1196
|
+
}
|
|
1197
|
+
let data;
|
|
1198
|
+
let form;
|
|
1199
|
+
if (input instanceof SubmitEvent) {
|
|
1200
|
+
form = input.target;
|
|
1201
|
+
data = new FormData(form);
|
|
1202
|
+
if ((input.submitter instanceof HTMLInputElement || input.submitter instanceof HTMLButtonElement) && input.submitter.name) {
|
|
1203
|
+
if (input.submitter.name) {
|
|
1204
|
+
data.append(input.submitter.name, input.submitter.value);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
} else {
|
|
1208
|
+
data = input;
|
|
1209
|
+
}
|
|
1210
|
+
return new Promise((resolve) => {
|
|
1211
|
+
if (data instanceof FormData) {
|
|
1212
|
+
state2.formData = data;
|
|
1213
|
+
}
|
|
1214
|
+
state2.submitted = true;
|
|
1215
|
+
state2.isRunning = true;
|
|
1216
|
+
loc2.isNavigating = true;
|
|
1217
|
+
currentAction2.value = {
|
|
1218
|
+
data,
|
|
1219
|
+
id: id2,
|
|
1220
|
+
resolve: noSerialize(resolve)
|
|
1221
|
+
};
|
|
1222
|
+
}).then((_rawProps) => {
|
|
1223
|
+
state2.isRunning = false;
|
|
1224
|
+
state2.status = _rawProps.status;
|
|
1225
|
+
state2.value = _rawProps.result;
|
|
1226
|
+
if (form) {
|
|
1227
|
+
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1228
|
+
form.reset();
|
|
1229
|
+
}
|
|
1230
|
+
const detail = {
|
|
1231
|
+
status: _rawProps.status,
|
|
1232
|
+
value: _rawProps.result
|
|
1233
|
+
};
|
|
1234
|
+
form.dispatchEvent(new CustomEvent("submitcompleted", {
|
|
1235
|
+
bubbles: false,
|
|
1236
|
+
cancelable: false,
|
|
1237
|
+
composed: false,
|
|
1238
|
+
detail
|
|
1239
|
+
}));
|
|
1240
|
+
}
|
|
1241
|
+
return {
|
|
1242
|
+
status: _rawProps.status,
|
|
1243
|
+
value: _rawProps.result
|
|
1244
|
+
};
|
|
1245
|
+
});
|
|
1246
|
+
}, "routeActionQrl_action_submit_YuS5bpdQ360", [
|
|
1247
|
+
currentAction,
|
|
1248
|
+
id,
|
|
1249
|
+
loc,
|
|
1250
|
+
state
|
|
1251
|
+
]);
|
|
1252
|
+
initialState.submit = submit;
|
|
1253
|
+
return state;
|
|
1254
|
+
}
|
|
1255
|
+
action.__brand = "server_action";
|
|
1256
|
+
action.__validators = validators;
|
|
1257
|
+
action.__qrl = actionQrl;
|
|
1258
|
+
action.__id = id;
|
|
1259
|
+
Object.freeze(action);
|
|
1260
|
+
return action;
|
|
1261
|
+
};
|
|
1262
|
+
const globalActionQrl = (actionQrl, ...rest) => {
|
|
1263
|
+
const action = routeActionQrl(actionQrl, ...rest);
|
|
1264
|
+
if (isServer) {
|
|
1265
|
+
if (typeof globalThis._qwikActionsMap === "undefined") {
|
|
1266
|
+
globalThis._qwikActionsMap = /* @__PURE__ */ new Map();
|
|
1267
|
+
}
|
|
1268
|
+
globalThis._qwikActionsMap.set(action.__id, action);
|
|
1269
|
+
}
|
|
1270
|
+
return action;
|
|
1271
|
+
};
|
|
1272
|
+
const routeAction$ = /* @__PURE__ */ implicit$FirstArg(routeActionQrl);
|
|
1273
|
+
const globalAction$ = /* @__PURE__ */ implicit$FirstArg(globalActionQrl);
|
|
1274
|
+
const routeLoaderQrl = (loaderQrl, ...rest) => {
|
|
1275
|
+
const { id, validators, serializationStrategy } = getValidators(rest, loaderQrl);
|
|
1276
|
+
function loader() {
|
|
1277
|
+
const state = _resolveContextWithoutSequentialScope(RouteStateContext);
|
|
1278
|
+
if (!(id in state)) {
|
|
1279
|
+
throw new Error(`routeLoader$ "${loaderQrl.getSymbol()}" was invoked in a route where it was not declared.
|
|
1280
|
+
This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
|
|
1281
|
+
For more information check: https://qwik.dev/docs/route-loader/
|
|
1282
|
+
|
|
1283
|
+
If your are managing reusable logic or a library it is essential that this function is re-exported from within 'layout.tsx' or 'index.tsx file of the existing route otherwise it will not run or throw exception.
|
|
1284
|
+
For more information check: https://qwik.dev/docs/re-exporting-loaders/`);
|
|
1285
|
+
}
|
|
1286
|
+
const loaderData = state[id];
|
|
1287
|
+
untrack(getValue, loaderData);
|
|
1288
|
+
return loaderData;
|
|
1289
|
+
}
|
|
1290
|
+
loader.__brand = "server_loader";
|
|
1291
|
+
loader.__qrl = loaderQrl;
|
|
1292
|
+
loader.__validators = validators;
|
|
1293
|
+
loader.__id = id;
|
|
1294
|
+
loader.__serializationStrategy = serializationStrategy;
|
|
1295
|
+
loader.__expires = -1;
|
|
1296
|
+
Object.freeze(loader);
|
|
1297
|
+
return loader;
|
|
1298
|
+
};
|
|
1299
|
+
const routeLoader$ = /* @__PURE__ */ implicit$FirstArg(routeLoaderQrl);
|
|
1300
|
+
const deserializeStream = async function* (stream, abortSignal) {
|
|
1745
1301
|
const reader = stream.getReader();
|
|
1746
1302
|
try {
|
|
1747
1303
|
let buffer = "";
|
|
@@ -1757,7 +1313,7 @@ const deserializeStream = async function* (stream, ctxElm, abortSignal) {
|
|
|
1757
1313
|
const lines = buffer.split(/\n/);
|
|
1758
1314
|
buffer = lines.pop();
|
|
1759
1315
|
for (const line of lines) {
|
|
1760
|
-
const
|
|
1316
|
+
const deserializedData = _deserialize(line);
|
|
1761
1317
|
yield deserializedData;
|
|
1762
1318
|
}
|
|
1763
1319
|
}
|
|
@@ -1765,66 +1321,159 @@ const deserializeStream = async function* (stream, ctxElm, abortSignal) {
|
|
|
1765
1321
|
reader.releaseLock();
|
|
1766
1322
|
}
|
|
1767
1323
|
};
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
const Form = ({ action, spaReset, reloadDocument, onSubmit$, ...rest }, key) => {
|
|
1774
|
-
if (action) {
|
|
1775
|
-
const isArrayApi = Array.isArray(onSubmit$);
|
|
1776
|
-
if (isArrayApi) {
|
|
1777
|
-
return jsx$1("form", {
|
|
1778
|
-
...rest,
|
|
1779
|
-
action: action.actionPath,
|
|
1780
|
-
"preventdefault:submit": !reloadDocument,
|
|
1781
|
-
onSubmit$: [
|
|
1782
|
-
...onSubmit$,
|
|
1783
|
-
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1784
|
-
!reloadDocument ? $((evt) => {
|
|
1785
|
-
if (!action.submitted) {
|
|
1786
|
-
return action.submit(evt);
|
|
1787
|
-
}
|
|
1788
|
-
}) : void 0
|
|
1789
|
-
],
|
|
1790
|
-
method: "post",
|
|
1791
|
-
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1792
|
-
}, key);
|
|
1324
|
+
const serverQrl = (qrl, options) => {
|
|
1325
|
+
if (isServer) {
|
|
1326
|
+
const captured = qrl.getCaptured();
|
|
1327
|
+
if (captured && captured.length > 0 && !_getContextHostElement()) {
|
|
1328
|
+
throw new Error("For security reasons, we cannot serialize QRLs that capture lexical scope.");
|
|
1793
1329
|
}
|
|
1794
|
-
return jsx$1("form", {
|
|
1795
|
-
...rest,
|
|
1796
|
-
action: action.actionPath,
|
|
1797
|
-
"preventdefault:submit": !reloadDocument,
|
|
1798
|
-
onSubmit$: [
|
|
1799
|
-
// Since v2, this fires before the action is executed so it can be prevented
|
|
1800
|
-
onSubmit$,
|
|
1801
|
-
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1802
|
-
!reloadDocument ? action.submit : void 0
|
|
1803
|
-
],
|
|
1804
|
-
method: "post",
|
|
1805
|
-
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1806
|
-
}, key);
|
|
1807
|
-
} else {
|
|
1808
|
-
return /* @__PURE__ */ jsx(GetForm, {
|
|
1809
|
-
spaReset,
|
|
1810
|
-
reloadDocument,
|
|
1811
|
-
onSubmit$,
|
|
1812
|
-
...rest
|
|
1813
|
-
}, key);
|
|
1814
1330
|
}
|
|
1331
|
+
const method = options?.method?.toUpperCase?.() || "POST";
|
|
1332
|
+
const headers = options?.headers || {};
|
|
1333
|
+
const origin = options?.origin || "";
|
|
1334
|
+
const fetchOptions = options?.fetchOptions || {};
|
|
1335
|
+
return /* @__PURE__ */ inlinedQrl(async function(...args) {
|
|
1336
|
+
const fetchOptions2 = _captures[0], headers2 = _captures[1], method2 = _captures[2], origin2 = _captures[3], qrl2 = _captures[4];
|
|
1337
|
+
const abortSignal = args.length > 0 && args[0] instanceof AbortSignal ? args.shift() : void 0;
|
|
1338
|
+
if (isServer) {
|
|
1339
|
+
let requestEvent = _asyncRequestStore?.getStore();
|
|
1340
|
+
if (!requestEvent) {
|
|
1341
|
+
const contexts = [
|
|
1342
|
+
useQwikRouterEnv()?.ev,
|
|
1343
|
+
this,
|
|
1344
|
+
_getContextEvent()
|
|
1345
|
+
];
|
|
1346
|
+
requestEvent = contexts.find((v2) => v2 && Object.prototype.hasOwnProperty.call(v2, "sharedMap") && Object.prototype.hasOwnProperty.call(v2, "cookie"));
|
|
1347
|
+
}
|
|
1348
|
+
return qrl2.apply(requestEvent, args);
|
|
1349
|
+
} else {
|
|
1350
|
+
let filteredArgs = args.map((arg) => {
|
|
1351
|
+
if (arg instanceof SubmitEvent && arg.target instanceof HTMLFormElement) {
|
|
1352
|
+
return new FormData(arg.target);
|
|
1353
|
+
} else if (arg instanceof Event) {
|
|
1354
|
+
return null;
|
|
1355
|
+
} else if (arg instanceof Node) {
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
return arg;
|
|
1359
|
+
});
|
|
1360
|
+
if (!filteredArgs.length) {
|
|
1361
|
+
filteredArgs = void 0;
|
|
1362
|
+
}
|
|
1363
|
+
const qrlHash = qrl2.getHash();
|
|
1364
|
+
let query = "";
|
|
1365
|
+
const config = {
|
|
1366
|
+
...fetchOptions2,
|
|
1367
|
+
method: method2,
|
|
1368
|
+
headers: {
|
|
1369
|
+
...headers2,
|
|
1370
|
+
"Content-Type": "application/qwik-json",
|
|
1371
|
+
Accept: "application/json, application/qwik-json, text/qwik-json-stream, text/plain",
|
|
1372
|
+
// Required so we don't call accidentally
|
|
1373
|
+
"X-QRL": qrlHash
|
|
1374
|
+
},
|
|
1375
|
+
signal: abortSignal
|
|
1376
|
+
};
|
|
1377
|
+
const captured = qrl2.getCaptured();
|
|
1378
|
+
let toSend = [
|
|
1379
|
+
filteredArgs
|
|
1380
|
+
];
|
|
1381
|
+
if (captured?.length) {
|
|
1382
|
+
toSend = [
|
|
1383
|
+
filteredArgs,
|
|
1384
|
+
...captured
|
|
1385
|
+
];
|
|
1386
|
+
} else {
|
|
1387
|
+
toSend = filteredArgs ? [
|
|
1388
|
+
filteredArgs
|
|
1389
|
+
] : [];
|
|
1390
|
+
}
|
|
1391
|
+
const body = await _serialize(toSend);
|
|
1392
|
+
if (method2 === "GET") {
|
|
1393
|
+
query += `&${QDATA_KEY}=${encodeURIComponent(body)}`;
|
|
1394
|
+
} else {
|
|
1395
|
+
config.body = body;
|
|
1396
|
+
}
|
|
1397
|
+
const res = await fetch(`${origin2}?${QFN_KEY}=${qrlHash}${query}`, config);
|
|
1398
|
+
const contentType = res.headers.get("Content-Type");
|
|
1399
|
+
if (res.ok && contentType === "text/qwik-json-stream" && res.body) {
|
|
1400
|
+
return (async function* () {
|
|
1401
|
+
try {
|
|
1402
|
+
for await (const result of deserializeStream(res.body, abortSignal)) {
|
|
1403
|
+
yield result;
|
|
1404
|
+
}
|
|
1405
|
+
} finally {
|
|
1406
|
+
if (!abortSignal?.aborted) {
|
|
1407
|
+
await res.body.cancel();
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
})();
|
|
1411
|
+
} else if (contentType === "application/qwik-json") {
|
|
1412
|
+
const str = await res.text();
|
|
1413
|
+
const obj = _deserialize(str);
|
|
1414
|
+
if (res.status >= 400) {
|
|
1415
|
+
throw obj;
|
|
1416
|
+
}
|
|
1417
|
+
return obj;
|
|
1418
|
+
} else if (contentType === "application/json") {
|
|
1419
|
+
const obj = await res.json();
|
|
1420
|
+
if (res.status >= 400) {
|
|
1421
|
+
throw obj;
|
|
1422
|
+
}
|
|
1423
|
+
return obj;
|
|
1424
|
+
} else if (contentType === "text/plain" || contentType === "text/html") {
|
|
1425
|
+
const str = await res.text();
|
|
1426
|
+
if (res.status >= 400) {
|
|
1427
|
+
throw str;
|
|
1428
|
+
}
|
|
1429
|
+
return str;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}, "serverQrl_w03grD0Ag68", [
|
|
1433
|
+
fetchOptions,
|
|
1434
|
+
headers,
|
|
1435
|
+
method,
|
|
1436
|
+
origin,
|
|
1437
|
+
qrl
|
|
1438
|
+
]);
|
|
1815
1439
|
};
|
|
1816
|
-
const
|
|
1440
|
+
const server$ = /* @__PURE__ */ implicit$FirstArg(serverQrl);
|
|
1441
|
+
|
|
1442
|
+
const ServiceWorkerRegister = (props) => /* @__PURE__ */ _jsxSorted("script", {
|
|
1443
|
+
nonce: _wrapProp(props, "nonce")
|
|
1444
|
+
}, {
|
|
1445
|
+
type: "module",
|
|
1446
|
+
dangerouslySetInnerHTML: swRegister
|
|
1447
|
+
}, null, 3, "1x_0");
|
|
1448
|
+
|
|
1449
|
+
const _hf0 = (p0) => !p0.reloadDocument;
|
|
1450
|
+
const _hf0_str = "!p0.reloadDocument";
|
|
1451
|
+
const _hf1 = (p0) => p0.spaReset ? "true" : void 0;
|
|
1452
|
+
const _hf1_str = 'p0.spaReset?"true":undefined';
|
|
1453
|
+
const GetForm = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((_rawProps) => {
|
|
1454
|
+
const rest = _restProps(_rawProps, [
|
|
1455
|
+
"action",
|
|
1456
|
+
"spaReset",
|
|
1457
|
+
"reloadDocument",
|
|
1458
|
+
"onSubmit$"
|
|
1459
|
+
]);
|
|
1817
1460
|
const nav = useNavigate();
|
|
1818
|
-
return /* @__PURE__ */
|
|
1461
|
+
return /* @__PURE__ */ _jsxSplit("form", {
|
|
1819
1462
|
action: "get",
|
|
1820
|
-
"preventdefault:submit":
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1463
|
+
"preventdefault:submit": _fnSignal(_hf0, [
|
|
1464
|
+
_rawProps
|
|
1465
|
+
], _hf0_str),
|
|
1466
|
+
"data-spa-reset": _fnSignal(_hf1, [
|
|
1467
|
+
_rawProps
|
|
1468
|
+
], _hf1_str),
|
|
1469
|
+
..._getVarProps(rest),
|
|
1470
|
+
..._getConstProps(rest),
|
|
1471
|
+
"q-e:submit": [
|
|
1472
|
+
...Array.isArray(_rawProps.onSubmit$) ? _rawProps.onSubmit$ : [
|
|
1473
|
+
_rawProps.onSubmit$
|
|
1826
1474
|
],
|
|
1827
|
-
|
|
1475
|
+
/* @__PURE__ */ inlinedQrl(async (_evt, form) => {
|
|
1476
|
+
const nav2 = _captures[0];
|
|
1828
1477
|
const formData = new FormData(form);
|
|
1829
1478
|
const params = new URLSearchParams();
|
|
1830
1479
|
formData.forEach((value, key) => {
|
|
@@ -1832,12 +1481,14 @@ const GetForm = component$(({ action: _0, spaReset, reloadDocument, onSubmit$, .
|
|
|
1832
1481
|
params.append(key, value);
|
|
1833
1482
|
}
|
|
1834
1483
|
});
|
|
1835
|
-
await
|
|
1484
|
+
await nav2("?" + params.toString(), {
|
|
1836
1485
|
type: "form",
|
|
1837
1486
|
forceReload: true
|
|
1838
1487
|
});
|
|
1839
|
-
}
|
|
1840
|
-
|
|
1488
|
+
}, "GetForm_component_form_q_e_submit_r3dkP9d2cF8", [
|
|
1489
|
+
nav
|
|
1490
|
+
]),
|
|
1491
|
+
/* @__PURE__ */ inlinedQrl((_evt, form) => {
|
|
1841
1492
|
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1842
1493
|
form.reset();
|
|
1843
1494
|
}
|
|
@@ -1849,11 +1500,61 @@ const GetForm = component$(({ action: _0, spaReset, reloadDocument, onSubmit$, .
|
|
|
1849
1500
|
status: 200
|
|
1850
1501
|
}
|
|
1851
1502
|
}));
|
|
1852
|
-
})
|
|
1853
|
-
]
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
})
|
|
1503
|
+
}, "GetForm_component_form_q_e_submit_1_cuYklZAOHrA")
|
|
1504
|
+
]
|
|
1505
|
+
}, null, /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "Q4_0"), 0, "Q4_1");
|
|
1506
|
+
}, "GetForm_component_2U5Z2Z8ryc0"));
|
|
1507
|
+
const Form = ({ action, spaReset, reloadDocument, onSubmit$, ...rest }, key) => {
|
|
1508
|
+
if (action) {
|
|
1509
|
+
const isArrayApi = Array.isArray(onSubmit$);
|
|
1510
|
+
if (isArrayApi) {
|
|
1511
|
+
return _jsxSplit("form", {
|
|
1512
|
+
..._getVarProps(rest),
|
|
1513
|
+
..._getConstProps(rest),
|
|
1514
|
+
action: _wrapProp(action, "actionPath"),
|
|
1515
|
+
"preventdefault:submit": !reloadDocument,
|
|
1516
|
+
"q-e:submit": [
|
|
1517
|
+
...onSubmit$,
|
|
1518
|
+
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1519
|
+
!reloadDocument ? /* @__PURE__ */ inlinedQrl((evt) => {
|
|
1520
|
+
const action2 = _captures[0];
|
|
1521
|
+
if (!action2.submitted) {
|
|
1522
|
+
return action2.submit(evt);
|
|
1523
|
+
}
|
|
1524
|
+
}, "Form_form_q_e_submit_6i0Jq5q8JFg", [
|
|
1525
|
+
action
|
|
1526
|
+
]) : void 0
|
|
1527
|
+
],
|
|
1528
|
+
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1529
|
+
}, {
|
|
1530
|
+
method: "post"
|
|
1531
|
+
}, null, 0, key);
|
|
1532
|
+
}
|
|
1533
|
+
return _jsxSplit("form", {
|
|
1534
|
+
..._getVarProps(rest),
|
|
1535
|
+
..._getConstProps(rest),
|
|
1536
|
+
action: _wrapProp(action, "actionPath"),
|
|
1537
|
+
"preventdefault:submit": !reloadDocument,
|
|
1538
|
+
"q-e:submit": [
|
|
1539
|
+
// Since v2, this fires before the action is executed so it can be prevented
|
|
1540
|
+
onSubmit$,
|
|
1541
|
+
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1542
|
+
!reloadDocument ? action.submit : void 0
|
|
1543
|
+
],
|
|
1544
|
+
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1545
|
+
}, {
|
|
1546
|
+
method: "post"
|
|
1547
|
+
}, null, 0, key);
|
|
1548
|
+
} else {
|
|
1549
|
+
return /* @__PURE__ */ _jsxSplit(GetForm, {
|
|
1550
|
+
spaReset,
|
|
1551
|
+
reloadDocument,
|
|
1552
|
+
onSubmit$,
|
|
1553
|
+
...rest
|
|
1554
|
+
}, null, null, 0, key);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1857
1558
|
const untypedAppUrl = function appUrl(route, params, paramsPrefix = "") {
|
|
1858
1559
|
const path = route.split("/");
|
|
1859
1560
|
for (let i = 0; i < path.length; i++) {
|
|
@@ -1890,39 +1591,47 @@ function omitProps(obj, keys) {
|
|
|
1890
1591
|
}
|
|
1891
1592
|
return omittedObj;
|
|
1892
1593
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
QwikCityMockProvider,
|
|
1900
|
-
QwikCityProvider,
|
|
1901
|
-
QwikRouterMockProvider,
|
|
1902
|
-
QwikRouterProvider,
|
|
1903
|
-
RouterOutlet,
|
|
1904
|
-
ServiceWorkerRegister,
|
|
1905
|
-
globalAction$,
|
|
1906
|
-
globalActionQrl,
|
|
1907
|
-
omitProps,
|
|
1908
|
-
routeAction$,
|
|
1909
|
-
routeActionQrl,
|
|
1910
|
-
routeLoader$,
|
|
1911
|
-
routeLoaderQrl,
|
|
1912
|
-
server$,
|
|
1913
|
-
serverQrl,
|
|
1914
|
-
untypedAppUrl,
|
|
1915
|
-
useContent,
|
|
1916
|
-
useDocumentHead,
|
|
1917
|
-
useLocation,
|
|
1918
|
-
useNavigate,
|
|
1919
|
-
usePreventNavigate$,
|
|
1920
|
-
usePreventNavigateQrl,
|
|
1921
|
-
valibot$,
|
|
1922
|
-
valibotQrl,
|
|
1923
|
-
validator$,
|
|
1924
|
-
validatorQrl,
|
|
1925
|
-
z2 as z,
|
|
1926
|
-
zod$,
|
|
1927
|
-
zodQrl
|
|
1594
|
+
|
|
1595
|
+
const createRenderer = (getOptions) => {
|
|
1596
|
+
return (opts) => {
|
|
1597
|
+
const { jsx, options } = getOptions(opts);
|
|
1598
|
+
return renderToStream(jsx, options);
|
|
1599
|
+
};
|
|
1928
1600
|
};
|
|
1601
|
+
|
|
1602
|
+
const DocumentHeadTags = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
1603
|
+
let head = useDocumentHead();
|
|
1604
|
+
if (props) {
|
|
1605
|
+
head = {
|
|
1606
|
+
...head,
|
|
1607
|
+
...props
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
return /* @__PURE__ */ _jsxSorted(Fragment, null, null, [
|
|
1611
|
+
head.title && /* @__PURE__ */ _jsxSorted("title", null, null, head.title, 1, "r5_0"),
|
|
1612
|
+
head.meta.map((m) => /* @__PURE__ */ _jsxSplit("meta", {
|
|
1613
|
+
..._getVarProps(m)
|
|
1614
|
+
}, _getConstProps(m), null, 0, "r5_1")),
|
|
1615
|
+
head.links.map((l) => /* @__PURE__ */ _jsxSplit("link", {
|
|
1616
|
+
..._getVarProps(l)
|
|
1617
|
+
}, _getConstProps(l), null, 0, "r5_2")),
|
|
1618
|
+
head.styles.map((s) => {
|
|
1619
|
+
const props2 = s.props || s;
|
|
1620
|
+
return /* @__PURE__ */ createElement("style", {
|
|
1621
|
+
...props2,
|
|
1622
|
+
dangerouslySetInnerHTML: s.style || props2.dangerouslySetInnerHTML,
|
|
1623
|
+
key: s.key
|
|
1624
|
+
});
|
|
1625
|
+
}),
|
|
1626
|
+
head.scripts.map((s) => {
|
|
1627
|
+
const props2 = s.props || s;
|
|
1628
|
+
return /* @__PURE__ */ createElement("script", {
|
|
1629
|
+
...props2,
|
|
1630
|
+
dangerouslySetInnerHTML: s.script || props2.dangerouslySetInnerHTML,
|
|
1631
|
+
key: s.key
|
|
1632
|
+
});
|
|
1633
|
+
})
|
|
1634
|
+
], 1, "r5_3");
|
|
1635
|
+
}, "DocumentHeadTags_component_9CrWYOoCpgY"));
|
|
1636
|
+
|
|
1637
|
+
export { DocumentHeadTags, ErrorBoundary, Form, Link, QWIK_CITY_SCROLLER, QWIK_ROUTER_SCROLLER, QwikCityMockProvider, QwikCityProvider, QwikRouterMockProvider, QwikRouterProvider, RouterOutlet, ServiceWorkerRegister, createRenderer, globalAction$, globalActionQrl, omitProps, routeAction$, routeActionQrl, routeLoader$, routeLoaderQrl, server$, serverQrl, untypedAppUrl, useDocumentHead, useLocation, useNavigate, useQwikRouter, valibot$, valibotQrl, validator$, validatorQrl, zod$, zodQrl };
|