@qwik.dev/router 2.0.0-beta.27 → 2.0.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/azure-swa/vite/index.mjs +31 -36
- package/lib/adapters/bun-server/vite/index.mjs +0 -3
- package/lib/adapters/cloud-run/vite/index.mjs +0 -3
- package/lib/adapters/cloudflare-pages/vite/index.mjs +15 -9
- package/lib/adapters/deno-server/vite/index.mjs +7 -5
- package/lib/adapters/netlify-edge/vite/index.mjs +13 -23
- package/lib/adapters/node-server/vite/index.mjs +0 -3
- package/lib/adapters/shared/vite/index.d.ts +1 -7
- package/lib/adapters/shared/vite/index.mjs +171 -157
- package/lib/adapters/ssg/vite/index.mjs +3 -4
- package/lib/adapters/vercel-edge/vite/index.mjs +25 -9
- package/lib/chunks/error-handler.mjs +26 -26
- package/lib/chunks/fs.mjs +28 -138
- package/lib/chunks/http-error.qwik.mjs +27 -0
- package/lib/chunks/not-found-wrapper.qwik.mjs +25 -0
- package/lib/chunks/pathname.mjs +105 -0
- package/lib/chunks/routing.qwik.mjs +592 -216
- package/lib/chunks/system.mjs +328 -0
- package/lib/chunks/use-functions.qwik.mjs +35 -0
- package/lib/chunks/worker-thread.mjs +271 -0
- package/lib/index.d.ts +136 -102
- package/lib/index.qwik.mjs +699 -751
- package/lib/middleware/aws-lambda/index.mjs +7 -1
- package/lib/middleware/azure-swa/index.mjs +7 -2
- package/lib/middleware/bun/index.mjs +24 -8
- package/lib/middleware/cloudflare-pages/index.mjs +10 -3
- package/lib/middleware/deno/index.mjs +23 -8
- package/lib/middleware/netlify-edge/index.mjs +10 -3
- package/lib/middleware/node/index.mjs +10 -14
- package/lib/middleware/request-handler/index.d.ts +82 -12
- package/lib/middleware/request-handler/index.mjs +661 -524
- package/lib/middleware/vercel-edge/index.mjs +10 -3
- package/lib/modules.d.ts +7 -4
- package/lib/ssg/index.d.ts +48 -16
- package/lib/ssg/index.mjs +320 -7
- package/lib/vite/index.d.ts +6 -0
- package/lib/vite/index.mjs +1106 -630
- package/modules.d.ts +7 -4
- package/package.json +9 -9
- package/lib/chunks/format-error.mjs +0 -137
- package/lib/chunks/index.mjs +0 -884
- package/lib/chunks/types.qwik.mjs +0 -22
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as
|
|
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, 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 loadRoute, r as resolveHead, C as CLIENT_DATA_CACHE, Q as Q_ROUTE, e as clientNavigate, f as QFN_KEY, h as QACTION_KEY, j 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';
|
|
4
6
|
import * as qwikRouterConfig from '@qwik-router-config';
|
|
5
7
|
import { _getContextContainer, SerializerSymbol, _UNINITIALIZED, _hasStoreEffects, forceStoreEffects, _waitUntilRendered, _getContextHostElement, _getContextEvent, _serialize, _deserialize, _resolveContextWithoutSequentialScope } from '@qwik.dev/core/internal';
|
|
6
8
|
import { _asyncRequestStore } from '@qwik.dev/router/middleware/request-handler';
|
|
@@ -9,67 +11,35 @@ import * as z from 'zod';
|
|
|
9
11
|
export { z } from 'zod';
|
|
10
12
|
import swRegister from '@qwik-router-sw-register';
|
|
11
13
|
import { renderToStream } from '@qwik.dev/core/server';
|
|
12
|
-
import '@qwik.dev/core/preloader';
|
|
13
|
-
import './chunks/types.qwik.mjs';
|
|
14
14
|
|
|
15
|
-
const ErrorBoundary =
|
|
15
|
+
const ErrorBoundary = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
16
16
|
const store = useErrorBoundary();
|
|
17
|
-
useOnWindow(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
17
|
+
useOnWindow("qerror", /* @__PURE__ */ inlinedQrl((e) => {
|
|
18
|
+
const store2 = _captures[0];
|
|
19
|
+
store2.error = e.detail.error;
|
|
20
|
+
}, "ErrorBoundary_component_useOnWindow_G0jFRpoNY0M", [
|
|
21
|
+
store
|
|
22
|
+
]));
|
|
23
23
|
if (store.error && props.fallback$) {
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
-
}
|
|
26
|
-
return /* @__PURE__ */ jsx(Slot, {});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const RouteStateContext = /* @__PURE__ */ createContextId("qc-s");
|
|
30
|
-
const ContentContext = /* @__PURE__ */ createContextId("qc-c");
|
|
31
|
-
const ContentInternalContext = /* @__PURE__ */ createContextId("qc-ic");
|
|
32
|
-
const DocumentHeadContext = /* @__PURE__ */ createContextId("qc-h");
|
|
33
|
-
const RouteLocationContext = /* @__PURE__ */ createContextId("qc-l");
|
|
34
|
-
const RouteNavigateContext = /* @__PURE__ */ createContextId("qc-n");
|
|
35
|
-
const RouteActionContext = /* @__PURE__ */ createContextId("qc-a");
|
|
36
|
-
const RoutePreventNavigateContext = /* @__PURE__ */ createContextId("qc-p");
|
|
37
|
-
|
|
38
|
-
const useContent = () => useContext(ContentContext);
|
|
39
|
-
const useDocumentHead = () => useContext(DocumentHeadContext);
|
|
40
|
-
const useLocation = () => useContext(RouteLocationContext);
|
|
41
|
-
const useNavigate = () => useContext(RouteNavigateContext);
|
|
42
|
-
const usePreventNavigateQrl = (fn) => {
|
|
43
|
-
if (!__EXPERIMENTAL__.preventNavigate) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
'usePreventNavigate$ is experimental and must be enabled with `experimental: ["preventNavigate"]` in the `qwikVite` plugin.'
|
|
46
|
-
);
|
|
24
|
+
return /* @__PURE__ */ _jsxSorted(Fragment, null, null, props.fallback$(store.error), 1, "bA_0");
|
|
47
25
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
const usePreventNavigate$ = implicit$FirstArg(usePreventNavigateQrl);
|
|
52
|
-
const useAction = () => useContext(RouteActionContext);
|
|
53
|
-
const useQwikRouterEnv = () => noSerialize(useServerData("qwikrouter"));
|
|
26
|
+
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "bA_1");
|
|
27
|
+
}, "ErrorBoundary_component_pOa6vjtC7ik"));
|
|
54
28
|
|
|
55
|
-
const Link =
|
|
29
|
+
const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
56
30
|
const nav = useNavigate();
|
|
57
31
|
const loc = useLocation();
|
|
58
32
|
const originalHref = props.href;
|
|
59
33
|
const anchorRef = useSignal();
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
reload
|
|
64
|
-
|
|
65
|
-
scroll,
|
|
66
|
-
...linkProps
|
|
67
|
-
} = /* @__PURE__ */ (() => props)();
|
|
68
|
-
const clientNavPath = untrack(getClientNavPath, { ...linkProps, reload }, loc);
|
|
34
|
+
const { onClick$, prefetch: prefetchProp, reload, replaceState, scroll, ...linkProps } = /* @__PURE__ */ (() => props)();
|
|
35
|
+
const clientNavPath = untrack(getClientNavPath, {
|
|
36
|
+
...linkProps,
|
|
37
|
+
reload
|
|
38
|
+
}, loc);
|
|
69
39
|
linkProps.href = clientNavPath || originalHref;
|
|
70
40
|
const prefetchData = !!clientNavPath && prefetchProp !== false && prefetchProp !== "js" || void 0;
|
|
71
41
|
const prefetch = prefetchData || !!clientNavPath && prefetchProp !== false && untrack(shouldPreload, clientNavPath, loc);
|
|
72
|
-
const handlePrefetch = prefetch ?
|
|
42
|
+
const handlePrefetch = prefetch ? /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
73
43
|
if (navigator.connection?.saveData) {
|
|
74
44
|
return;
|
|
75
45
|
}
|
|
@@ -83,138 +53,82 @@ const Link = component$((props) => {
|
|
|
83
53
|
});
|
|
84
54
|
}
|
|
85
55
|
}
|
|
86
|
-
}) : void 0;
|
|
87
|
-
const preventDefault = clientNavPath ?
|
|
56
|
+
}, "Link_component_handlePrefetch_AGvVXzXKbms") : void 0;
|
|
57
|
+
const preventDefault = clientNavPath ? _qrlSync((event) => {
|
|
88
58
|
if (!(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {
|
|
89
59
|
event.preventDefault();
|
|
90
60
|
}
|
|
91
|
-
}) : void 0;
|
|
92
|
-
const handleClientSideNavigation = clientNavPath ?
|
|
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];
|
|
93
64
|
if (event.defaultPrevented) {
|
|
94
65
|
if (elm.href) {
|
|
95
66
|
elm.setAttribute("aria-pressed", "true");
|
|
96
|
-
|
|
67
|
+
nav2(elm.href, {
|
|
68
|
+
forceReload: reload2,
|
|
69
|
+
replaceState: replaceState2,
|
|
70
|
+
scroll: scroll2
|
|
71
|
+
}).then(() => {
|
|
97
72
|
elm.removeAttribute("aria-pressed");
|
|
98
73
|
});
|
|
99
74
|
}
|
|
100
75
|
}
|
|
101
|
-
}
|
|
102
|
-
|
|
76
|
+
}, "Link_component_handleClientSideNavigation_h3qenoGeI6M", [
|
|
77
|
+
nav,
|
|
78
|
+
reload,
|
|
79
|
+
replaceState,
|
|
80
|
+
scroll
|
|
81
|
+
]) : void 0;
|
|
82
|
+
const handlePreload = /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
103
83
|
const url = new URL(elm.href);
|
|
104
84
|
preloadRouteBundles(url.pathname, 1);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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$;
|
|
109
90
|
if (handler) {
|
|
110
91
|
const event = new CustomEvent("qvisible");
|
|
111
92
|
if (Array.isArray(handler)) {
|
|
112
|
-
handler.flat(10).forEach(
|
|
113
|
-
(handler2) => handler2?.(event, anchorRef.value)
|
|
114
|
-
);
|
|
93
|
+
handler.flat(10).forEach((handler2) => handler2?.(event, anchorRef2.value));
|
|
115
94
|
} else {
|
|
116
|
-
handler?.(event,
|
|
95
|
+
handler?.(event, anchorRef2.value);
|
|
117
96
|
}
|
|
118
97
|
}
|
|
119
|
-
if (!isDev &&
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return /* @__PURE__ */ jsx(
|
|
124
|
-
"a",
|
|
125
|
-
{
|
|
126
|
-
ref: anchorRef,
|
|
127
|
-
...{ "q:link": !!clientNavPath },
|
|
128
|
-
...linkProps,
|
|
129
|
-
onClick$: [
|
|
130
|
-
preventDefault,
|
|
131
|
-
handlePreload,
|
|
132
|
-
// needs to be in between preventDefault and onClick$ to ensure it starts asap.
|
|
133
|
-
onClick$,
|
|
134
|
-
handleClientSideNavigation
|
|
135
|
-
],
|
|
136
|
-
"data-prefetch": prefetchData,
|
|
137
|
-
onMouseOver$: [linkProps.onMouseOver$, handlePrefetch],
|
|
138
|
-
onFocus$: [linkProps.onFocus$, handlePrefetch],
|
|
139
|
-
onQVisible$: [],
|
|
140
|
-
children: /* @__PURE__ */ jsx(Slot, {})
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const resolveHead = (endpoint, routeLocation, contentModules, locale, defaults) => withLocale(locale, () => {
|
|
146
|
-
const head = createDocumentHead(defaults);
|
|
147
|
-
const getData = ((loaderOrAction) => {
|
|
148
|
-
const id = loaderOrAction.__id;
|
|
149
|
-
if (loaderOrAction.__brand === "server_loader") {
|
|
150
|
-
if (!(id in endpoint.loaders)) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
"You can not get the returned data of a loader that has not been executed for this request."
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const data = endpoint.loaders[id];
|
|
157
|
-
if (isPromise(data)) {
|
|
158
|
-
throw new Error("Loaders returning a promise can not be resolved for the head function.");
|
|
159
|
-
}
|
|
160
|
-
return data;
|
|
161
|
-
});
|
|
162
|
-
const fns = [];
|
|
163
|
-
for (const contentModule of contentModules) {
|
|
164
|
-
const contentModuleHead = contentModule?.head;
|
|
165
|
-
if (contentModuleHead) {
|
|
166
|
-
if (typeof contentModuleHead === "function") {
|
|
167
|
-
fns.unshift(contentModuleHead);
|
|
168
|
-
} else if (typeof contentModuleHead === "object") {
|
|
169
|
-
resolveDocumentHead(head, contentModuleHead);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (fns.length) {
|
|
174
|
-
const headProps = {
|
|
175
|
-
head,
|
|
176
|
-
withLocale: (fn) => fn(),
|
|
177
|
-
resolveValue: getData,
|
|
178
|
-
...routeLocation
|
|
179
|
-
};
|
|
180
|
-
for (const fn of fns) {
|
|
181
|
-
resolveDocumentHead(head, fn(headProps));
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return head;
|
|
185
|
-
});
|
|
186
|
-
const resolveDocumentHead = (resolvedHead, updatedHead) => {
|
|
187
|
-
if (typeof updatedHead.title === "string") {
|
|
188
|
-
resolvedHead.title = updatedHead.title;
|
|
189
|
-
}
|
|
190
|
-
mergeArray(resolvedHead.meta, updatedHead.meta);
|
|
191
|
-
mergeArray(resolvedHead.links, updatedHead.links);
|
|
192
|
-
mergeArray(resolvedHead.styles, updatedHead.styles);
|
|
193
|
-
mergeArray(resolvedHead.scripts, updatedHead.scripts);
|
|
194
|
-
Object.assign(resolvedHead.frontmatter, updatedHead.frontmatter);
|
|
195
|
-
};
|
|
196
|
-
const mergeArray = (existingArr, newArr) => {
|
|
197
|
-
if (Array.isArray(newArr)) {
|
|
198
|
-
for (const newItem of newArr) {
|
|
199
|
-
if (typeof newItem.key === "string") {
|
|
200
|
-
const existingIndex = existingArr.findIndex((i) => i.key === newItem.key);
|
|
201
|
-
if (existingIndex > -1) {
|
|
202
|
-
existingArr[existingIndex] = newItem;
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
existingArr.push(newItem);
|
|
98
|
+
if (!isDev && anchorRef2.value) {
|
|
99
|
+
handlePrefetch2?.(void 0, anchorRef2.value);
|
|
207
100
|
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
101
|
+
}, "Link_component_useVisibleTask_xKeuRmnoNSA", [
|
|
102
|
+
anchorRef,
|
|
103
|
+
handlePrefetch,
|
|
104
|
+
linkProps,
|
|
105
|
+
loc
|
|
106
|
+
]));
|
|
107
|
+
return /* @__PURE__ */ _jsxSplit("a", {
|
|
108
|
+
ref: anchorRef,
|
|
109
|
+
"q:link": !!clientNavPath,
|
|
110
|
+
..._getVarProps(linkProps),
|
|
111
|
+
..._getConstProps(linkProps),
|
|
112
|
+
"q-e:click": [
|
|
113
|
+
preventDefault,
|
|
114
|
+
handlePreload,
|
|
115
|
+
onClick$,
|
|
116
|
+
handleClientSideNavigation
|
|
117
|
+
],
|
|
118
|
+
"data-prefetch": prefetchData,
|
|
119
|
+
"q-e:mouseover": [
|
|
120
|
+
linkProps.onMouseOver$,
|
|
121
|
+
handlePrefetch
|
|
122
|
+
],
|
|
123
|
+
"q-e:focus": [
|
|
124
|
+
linkProps.onFocus$,
|
|
125
|
+
handlePrefetch
|
|
126
|
+
]
|
|
127
|
+
}, {
|
|
128
|
+
// We need to prevent the onQVisible$ from being called twice since it is handled in the visible task
|
|
129
|
+
"q-e:qvisible": []
|
|
130
|
+
}, /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "jO_0"), 0, "jO_1");
|
|
131
|
+
}, "Link_component_VPmar9tb3t4"));
|
|
218
132
|
|
|
219
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}}}";
|
|
220
134
|
|
|
@@ -224,15 +138,6 @@ function callRestoreScrollOnDocument() {
|
|
|
224
138
|
document.__q_scroll_restore__ = void 0;
|
|
225
139
|
}
|
|
226
140
|
}
|
|
227
|
-
const restoreScroll = (type, toUrl, fromUrl, scroller, scrollState) => {
|
|
228
|
-
if (type === "popstate" && scrollState) {
|
|
229
|
-
scroller.scrollTo(scrollState.x, scrollState.y);
|
|
230
|
-
} else if (type === "link" || type === "form") {
|
|
231
|
-
if (!hashScroll(toUrl, fromUrl)) {
|
|
232
|
-
scroller.scrollTo(0, 0);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
141
|
const hashScroll = (toUrl, fromUrl) => {
|
|
237
142
|
const elmId = toUrl.hash.slice(1);
|
|
238
143
|
const elm = elmId && document.getElementById(elmId);
|
|
@@ -244,6 +149,15 @@ const hashScroll = (toUrl, fromUrl) => {
|
|
|
244
149
|
}
|
|
245
150
|
return false;
|
|
246
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
|
+
};
|
|
247
161
|
const currentScrollState = (elm) => {
|
|
248
162
|
return {
|
|
249
163
|
x: elm.scrollLeft,
|
|
@@ -262,7 +176,7 @@ const saveScrollHistory = (scrollState) => {
|
|
|
262
176
|
history.replaceState(state, "");
|
|
263
177
|
};
|
|
264
178
|
|
|
265
|
-
const spaInit =
|
|
179
|
+
const spaInit = eventQrl(/* @__PURE__ */ inlinedQrl((_, el) => {
|
|
266
180
|
if (!window._qRouterSPA && !window._qRouterInitPopstate) {
|
|
267
181
|
const currentPath = location.pathname + location.search;
|
|
268
182
|
const checkAndScroll = (scrollState) => {
|
|
@@ -297,10 +211,12 @@ const spaInit = event$((_, el) => {
|
|
|
297
211
|
const domContainer = container.qContainer;
|
|
298
212
|
const hostElement = domContainer.vNodeLocate(el);
|
|
299
213
|
const nav = domContainer?.resolveContext(hostElement, {
|
|
300
|
-
id: "
|
|
214
|
+
id: "qr-n"
|
|
301
215
|
});
|
|
302
216
|
if (nav) {
|
|
303
|
-
nav(location.href, {
|
|
217
|
+
nav(location.href, {
|
|
218
|
+
type: "popstate"
|
|
219
|
+
});
|
|
304
220
|
} else {
|
|
305
221
|
location.reload();
|
|
306
222
|
}
|
|
@@ -320,11 +236,11 @@ const spaInit = event$((_, el) => {
|
|
|
320
236
|
if (state === null || typeof state === "undefined") {
|
|
321
237
|
state = {};
|
|
322
238
|
} else if (state?.constructor !== Object) {
|
|
323
|
-
state = {
|
|
239
|
+
state = {
|
|
240
|
+
_data: state
|
|
241
|
+
};
|
|
324
242
|
if (isDev) {
|
|
325
|
-
console.warn(
|
|
326
|
-
"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`"
|
|
327
|
-
);
|
|
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`");
|
|
328
244
|
}
|
|
329
245
|
}
|
|
330
246
|
state._qRouterScroll = state._qRouterScroll || currentScrollState();
|
|
@@ -361,7 +277,11 @@ const spaInit = event$((_, el) => {
|
|
|
361
277
|
} else {
|
|
362
278
|
window._qRouterScrollEnabled = false;
|
|
363
279
|
clearTimeout(window._qRouterScrollDebounce);
|
|
364
|
-
saveScrollState({
|
|
280
|
+
saveScrollState({
|
|
281
|
+
...currentScrollState(),
|
|
282
|
+
x: 0,
|
|
283
|
+
y: 0
|
|
284
|
+
});
|
|
365
285
|
location.reload();
|
|
366
286
|
}
|
|
367
287
|
} else {
|
|
@@ -392,7 +312,9 @@ const spaInit = event$((_, el) => {
|
|
|
392
312
|
window._qRouterScrollEnabled = true;
|
|
393
313
|
setTimeout(() => {
|
|
394
314
|
window.addEventListener("popstate", window._qRouterInitPopstate);
|
|
395
|
-
window.addEventListener("scroll", window._qRouterInitScroll, {
|
|
315
|
+
window.addEventListener("scroll", window._qRouterInitScroll, {
|
|
316
|
+
passive: true
|
|
317
|
+
});
|
|
396
318
|
document.addEventListener("click", window._qRouterInitAnchors);
|
|
397
319
|
if (!window.navigation) {
|
|
398
320
|
document.addEventListener("visibilitychange", window._qRouterInitVisibility, {
|
|
@@ -401,7 +323,7 @@ const spaInit = event$((_, el) => {
|
|
|
401
323
|
}
|
|
402
324
|
}, 0);
|
|
403
325
|
}
|
|
404
|
-
});
|
|
326
|
+
}, "spa_init_event_igI1pUsax0E"));
|
|
405
327
|
|
|
406
328
|
const startViewTransition = (params) => {
|
|
407
329
|
if (!params.update) {
|
|
@@ -414,7 +336,9 @@ const startViewTransition = (params) => {
|
|
|
414
336
|
} catch {
|
|
415
337
|
transition = document.startViewTransition(params.update);
|
|
416
338
|
}
|
|
417
|
-
const event = new CustomEvent("qviewtransition", {
|
|
339
|
+
const event = new CustomEvent("qviewtransition", {
|
|
340
|
+
detail: transition
|
|
341
|
+
});
|
|
418
342
|
document.dispatchEvent(event);
|
|
419
343
|
return transition;
|
|
420
344
|
} else {
|
|
@@ -425,19 +349,17 @@ const startViewTransition = (params) => {
|
|
|
425
349
|
const QWIK_CITY_SCROLLER = "_qCityScroller";
|
|
426
350
|
const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
|
|
427
351
|
const preventNav = {};
|
|
428
|
-
const internalState = {
|
|
352
|
+
const internalState = {
|
|
353
|
+
navCount: 0
|
|
354
|
+
};
|
|
429
355
|
const useQwikRouter = (props) => {
|
|
430
356
|
if (!isServer) {
|
|
431
|
-
throw new Error(
|
|
432
|
-
"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."
|
|
433
|
-
);
|
|
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.");
|
|
434
358
|
}
|
|
435
|
-
|
|
359
|
+
useStylesQrl(/* @__PURE__ */ inlinedQrl(transitionCss, "useQwikRouter_useStyles_g40PKfcKmYU"));
|
|
436
360
|
const env = useQwikRouterEnv();
|
|
437
361
|
if (!env?.params) {
|
|
438
|
-
throw new Error(
|
|
439
|
-
`Missing Qwik Router Env Data for help visit https://github.com/QwikDev/qwik/issues/6237`
|
|
440
|
-
);
|
|
362
|
+
throw new Error(`Missing Qwik Router Env Data for help visit https://github.com/QwikDev/qwik/issues/6237`);
|
|
441
363
|
}
|
|
442
364
|
const urlEnv = useServerData("url");
|
|
443
365
|
if (!urlEnv) {
|
|
@@ -445,9 +367,7 @@ const useQwikRouter = (props) => {
|
|
|
445
367
|
}
|
|
446
368
|
const serverHead = useServerData("documentHead");
|
|
447
369
|
if (env.ev.originalUrl.pathname !== env.ev.url.pathname && !__EXPERIMENTAL__.enableRequestRewrite) {
|
|
448
|
-
throw new Error(
|
|
449
|
-
`enableRequestRewrite is an experimental feature and is not enabled. Please enable the feature flag by adding \`experimental: ["enableRequestRewrite"]\` to your qwikVite plugin options.`
|
|
450
|
-
);
|
|
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.`);
|
|
451
371
|
}
|
|
452
372
|
const url = new URL(urlEnv);
|
|
453
373
|
const routeLocationTarget = {
|
|
@@ -456,7 +376,9 @@ const useQwikRouter = (props) => {
|
|
|
456
376
|
isNavigating: false,
|
|
457
377
|
prevUrl: void 0
|
|
458
378
|
};
|
|
459
|
-
const routeLocation = useStore(routeLocationTarget, {
|
|
379
|
+
const routeLocation = useStore(routeLocationTarget, {
|
|
380
|
+
deep: false
|
|
381
|
+
});
|
|
460
382
|
const navResolver = {};
|
|
461
383
|
const container = _getContextContainer();
|
|
462
384
|
const getSerializationStrategy = (loaderId) => {
|
|
@@ -466,13 +388,7 @@ const useQwikRouter = (props) => {
|
|
|
466
388
|
const loaderState = {};
|
|
467
389
|
for (const [key, value] of Object.entries(env.response.loaders)) {
|
|
468
390
|
loadersObject[key] = value;
|
|
469
|
-
loaderState[key] = createLoaderSignal(
|
|
470
|
-
loadersObject,
|
|
471
|
-
key,
|
|
472
|
-
url,
|
|
473
|
-
getSerializationStrategy(key),
|
|
474
|
-
container
|
|
475
|
-
);
|
|
391
|
+
loaderState[key] = createLoaderSignal(loadersObject, key, url, getSerializationStrategy(key), container);
|
|
476
392
|
}
|
|
477
393
|
loadersObject[SerializerSymbol] = (obj) => {
|
|
478
394
|
const loadersSerializationObject = {};
|
|
@@ -486,27 +402,27 @@ const useQwikRouter = (props) => {
|
|
|
486
402
|
dest: url,
|
|
487
403
|
scroll: true
|
|
488
404
|
});
|
|
489
|
-
const documentHead = useStore(
|
|
490
|
-
() => createDocumentHead(serverHead)
|
|
491
|
-
);
|
|
405
|
+
const documentHead = useStore(() => createDocumentHead(serverHead));
|
|
492
406
|
const content = useStore({
|
|
493
407
|
headings: void 0,
|
|
494
408
|
menu: void 0
|
|
495
409
|
});
|
|
496
410
|
const contentInternal = useSignal();
|
|
411
|
+
const httpStatus = useSignal({
|
|
412
|
+
status: env.response.status,
|
|
413
|
+
message: env.loadedRoute.$notFound$ ? "Not Found" : env.response.statusMessage ?? ""
|
|
414
|
+
});
|
|
497
415
|
const currentActionId = env.response.action;
|
|
498
416
|
const currentAction = currentActionId ? env.response.loaders[currentActionId] : void 0;
|
|
499
|
-
const actionState = useSignal(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
);
|
|
509
|
-
const registerPreventNav = $((fn$) => {
|
|
417
|
+
const actionState = useSignal(currentAction ? {
|
|
418
|
+
id: currentActionId,
|
|
419
|
+
data: env.response.formData,
|
|
420
|
+
output: {
|
|
421
|
+
result: currentAction,
|
|
422
|
+
status: env.response.status
|
|
423
|
+
}
|
|
424
|
+
} : void 0);
|
|
425
|
+
const registerPreventNav = /* @__PURE__ */ inlinedQrl((fn$) => {
|
|
510
426
|
if (!isBrowser) {
|
|
511
427
|
return;
|
|
512
428
|
}
|
|
@@ -515,9 +431,9 @@ const useQwikRouter = (props) => {
|
|
|
515
431
|
if (!preventNav.$cbs$) {
|
|
516
432
|
return;
|
|
517
433
|
}
|
|
518
|
-
const prevents = [
|
|
519
|
-
(
|
|
520
|
-
);
|
|
434
|
+
const prevents = [
|
|
435
|
+
...preventNav.$cbs$.values()
|
|
436
|
+
].map((cb) => cb.resolved ? cb.resolved() : cb());
|
|
521
437
|
if (prevents.some(Boolean)) {
|
|
522
438
|
event.preventDefault();
|
|
523
439
|
event.returnValue = true;
|
|
@@ -535,26 +451,25 @@ const useQwikRouter = (props) => {
|
|
|
535
451
|
}
|
|
536
452
|
}
|
|
537
453
|
};
|
|
538
|
-
});
|
|
539
|
-
const goto =
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
forceReload
|
|
543
|
-
|
|
544
|
-
replaceState = false,
|
|
545
|
-
scroll = true
|
|
546
|
-
} = typeof opt === "object" ? opt : { forceReload: opt };
|
|
454
|
+
}, "useQwikRouter_registerPreventNav_69B0DK0eZJc");
|
|
455
|
+
const goto = /* @__PURE__ */ inlinedQrl(async (path, opt) => {
|
|
456
|
+
const actionState2 = _captures[0], navResolver2 = _captures[1], routeInternal2 = _captures[2], routeLocation2 = _captures[3];
|
|
457
|
+
const { type = "link", forceReload = path === void 0, replaceState = false, scroll = true } = typeof opt === "object" ? opt : {
|
|
458
|
+
forceReload: opt
|
|
459
|
+
};
|
|
547
460
|
internalState.navCount++;
|
|
548
|
-
if (isBrowser && type === "link" &&
|
|
461
|
+
if (isBrowser && type === "link" && routeInternal2.value.type === "initial") {
|
|
549
462
|
const url2 = new URL(window.location.href);
|
|
550
|
-
|
|
551
|
-
|
|
463
|
+
routeInternal2.value.dest = url2;
|
|
464
|
+
routeLocation2.url = url2;
|
|
552
465
|
}
|
|
553
|
-
const lastDest =
|
|
554
|
-
const dest = path === void 0 ? lastDest : typeof path === "number" ? path : toUrl(path,
|
|
466
|
+
const lastDest = routeInternal2.value.dest;
|
|
467
|
+
const dest = path === void 0 ? lastDest : typeof path === "number" ? path : toUrl(path, routeLocation2.url);
|
|
555
468
|
if (preventNav.$cbs$ && (forceReload || typeof dest === "number" || !isSamePath(dest, lastDest) || !isSameOrigin(dest, lastDest))) {
|
|
556
469
|
const ourNavId = internalState.navCount;
|
|
557
|
-
const prevents = await Promise.all([
|
|
470
|
+
const prevents = await Promise.all([
|
|
471
|
+
...preventNav.$cbs$.values()
|
|
472
|
+
].map((cb) => cb(dest)));
|
|
558
473
|
if (ourNavId !== internalState.navCount || prevents.some(Boolean)) {
|
|
559
474
|
if (ourNavId === internalState.navCount && type === "popstate") {
|
|
560
475
|
history.pushState(null, "", lastDest);
|
|
@@ -583,9 +498,7 @@ const useQwikRouter = (props) => {
|
|
|
583
498
|
if (!scroller) {
|
|
584
499
|
scroller = document.getElementById(QWIK_CITY_SCROLLER);
|
|
585
500
|
if (scroller && isDev) {
|
|
586
|
-
console.warn(
|
|
587
|
-
`Please update your scroller ID to "${QWIK_ROUTER_SCROLLER}" as "${QWIK_CITY_SCROLLER}" is deprecated and will be removed in V3`
|
|
588
|
-
);
|
|
501
|
+
console.warn(`Please update your scroller ID to "${QWIK_ROUTER_SCROLLER}" as "${QWIK_CITY_SCROLLER}" is deprecated and will be removed in V3`);
|
|
589
502
|
}
|
|
590
503
|
}
|
|
591
504
|
if (!scroller) {
|
|
@@ -596,14 +509,14 @@ const useQwikRouter = (props) => {
|
|
|
596
509
|
window._qRouterScrollEnabled = true;
|
|
597
510
|
}
|
|
598
511
|
}
|
|
599
|
-
if (dest.href !==
|
|
512
|
+
if (dest.href !== routeLocation2.url.href) {
|
|
600
513
|
const newUrl = new URL(dest.href);
|
|
601
|
-
|
|
602
|
-
|
|
514
|
+
routeInternal2.value.dest = newUrl;
|
|
515
|
+
routeLocation2.url = newUrl;
|
|
603
516
|
}
|
|
604
517
|
return;
|
|
605
518
|
}
|
|
606
|
-
|
|
519
|
+
routeInternal2.value = {
|
|
607
520
|
type,
|
|
608
521
|
dest,
|
|
609
522
|
forceReload,
|
|
@@ -612,33 +525,35 @@ const useQwikRouter = (props) => {
|
|
|
612
525
|
};
|
|
613
526
|
if (isBrowser) {
|
|
614
527
|
loadClientData(dest);
|
|
615
|
-
loadRoute(
|
|
616
|
-
qwikRouterConfig.routes,
|
|
617
|
-
qwikRouterConfig.menus,
|
|
618
|
-
qwikRouterConfig.cacheModules,
|
|
619
|
-
dest.pathname
|
|
620
|
-
);
|
|
528
|
+
loadRoute(qwikRouterConfig.routes, qwikRouterConfig.cacheModules, dest.pathname);
|
|
621
529
|
}
|
|
622
|
-
|
|
623
|
-
|
|
530
|
+
actionState2.value = void 0;
|
|
531
|
+
routeLocation2.isNavigating = true;
|
|
624
532
|
return new Promise((resolve) => {
|
|
625
|
-
|
|
533
|
+
navResolver2.r = resolve;
|
|
626
534
|
});
|
|
627
|
-
}
|
|
535
|
+
}, "useQwikRouter_goto_8j8Vrz2yUIM", [
|
|
536
|
+
actionState,
|
|
537
|
+
navResolver,
|
|
538
|
+
routeInternal,
|
|
539
|
+
routeLocation
|
|
540
|
+
]);
|
|
628
541
|
useContextProvider(ContentContext, content);
|
|
629
542
|
useContextProvider(ContentInternalContext, contentInternal);
|
|
630
543
|
useContextProvider(DocumentHeadContext, documentHead);
|
|
544
|
+
useContextProvider(HttpStatusContext, httpStatus);
|
|
631
545
|
useContextProvider(RouteLocationContext, routeLocation);
|
|
632
546
|
useContextProvider(RouteNavigateContext, goto);
|
|
633
547
|
useContextProvider(RouteStateContext, loaderState);
|
|
634
548
|
useContextProvider(RouteActionContext, actionState);
|
|
635
549
|
useContextProvider(RoutePreventNavigateContext, registerPreventNav);
|
|
636
|
-
|
|
550
|
+
useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
|
|
551
|
+
const actionState2 = _captures[0], content2 = _captures[1], contentInternal2 = _captures[2], documentHead2 = _captures[3], env2 = _captures[4], goto2 = _captures[5], httpStatus2 = _captures[6], loaderState2 = _captures[7], loadersObject2 = _captures[8], navResolver2 = _captures[9], props2 = _captures[10], routeInternal2 = _captures[11], routeLocation2 = _captures[12], routeLocationTarget2 = _captures[13], serverHead2 = _captures[14];
|
|
637
552
|
async function run() {
|
|
638
|
-
const navigation = track(
|
|
639
|
-
const action = track(
|
|
553
|
+
const navigation = track(routeInternal2);
|
|
554
|
+
const action = track(actionState2);
|
|
640
555
|
const locale = getLocale("");
|
|
641
|
-
const prevUrl =
|
|
556
|
+
const prevUrl = routeLocation2.url;
|
|
642
557
|
const navType = action ? "form" : navigation.type;
|
|
643
558
|
const replaceState = navigation.replaceState;
|
|
644
559
|
let trackUrl;
|
|
@@ -646,9 +561,9 @@ const useQwikRouter = (props) => {
|
|
|
646
561
|
let loadedRoute = null;
|
|
647
562
|
let container2;
|
|
648
563
|
if (isServer) {
|
|
649
|
-
trackUrl = new URL(navigation.dest,
|
|
650
|
-
loadedRoute =
|
|
651
|
-
clientPageData =
|
|
564
|
+
trackUrl = new URL(navigation.dest, routeLocation2.url);
|
|
565
|
+
loadedRoute = env2.loadedRoute;
|
|
566
|
+
clientPageData = env2.response;
|
|
652
567
|
} else {
|
|
653
568
|
trackUrl = new URL(navigation.dest, location);
|
|
654
569
|
if (trackUrl.pathname.endsWith("/")) {
|
|
@@ -658,19 +573,17 @@ const useQwikRouter = (props) => {
|
|
|
658
573
|
} else if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
659
574
|
trackUrl.pathname += "/";
|
|
660
575
|
}
|
|
661
|
-
let loadRoutePromise = loadRoute(
|
|
662
|
-
qwikRouterConfig.routes,
|
|
663
|
-
qwikRouterConfig.menus,
|
|
664
|
-
qwikRouterConfig.cacheModules,
|
|
665
|
-
trackUrl.pathname
|
|
666
|
-
);
|
|
576
|
+
let loadRoutePromise = loadRoute(qwikRouterConfig.routes, qwikRouterConfig.cacheModules, trackUrl.pathname);
|
|
667
577
|
container2 = _getContextContainer();
|
|
668
578
|
const pageData = clientPageData = await loadClientData(trackUrl, {
|
|
669
579
|
action,
|
|
670
580
|
clearCache: true
|
|
671
581
|
});
|
|
672
582
|
if (!pageData) {
|
|
673
|
-
|
|
583
|
+
routeInternal2.untrackedValue = {
|
|
584
|
+
type: navType,
|
|
585
|
+
dest: trackUrl
|
|
586
|
+
};
|
|
674
587
|
return;
|
|
675
588
|
}
|
|
676
589
|
const newHref = pageData.href;
|
|
@@ -681,7 +594,6 @@ const useQwikRouter = (props) => {
|
|
|
681
594
|
}
|
|
682
595
|
loadRoutePromise = loadRoute(
|
|
683
596
|
qwikRouterConfig.routes,
|
|
684
|
-
qwikRouterConfig.menus,
|
|
685
597
|
qwikRouterConfig.cacheModules,
|
|
686
598
|
newURL.pathname
|
|
687
599
|
// Load the actual required path.
|
|
@@ -696,8 +608,19 @@ const useQwikRouter = (props) => {
|
|
|
696
608
|
}
|
|
697
609
|
}
|
|
698
610
|
if (loadedRoute) {
|
|
699
|
-
const
|
|
700
|
-
const contentModules = mods
|
|
611
|
+
const { $routeName$, $params$, $mods$, $menu$, $notFound$ } = loadedRoute;
|
|
612
|
+
const contentModules = $mods$;
|
|
613
|
+
if ($notFound$) {
|
|
614
|
+
httpStatus2.value = {
|
|
615
|
+
status: 404,
|
|
616
|
+
message: "Not Found"
|
|
617
|
+
};
|
|
618
|
+
} else {
|
|
619
|
+
httpStatus2.value = {
|
|
620
|
+
status: clientPageData?.status ?? 200,
|
|
621
|
+
message: clientPageData?.statusMessage ?? ""
|
|
622
|
+
};
|
|
623
|
+
}
|
|
701
624
|
const pageModule = contentModules[contentModules.length - 1];
|
|
702
625
|
if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
|
|
703
626
|
trackUrl.search = navigation.dest.search;
|
|
@@ -706,65 +629,55 @@ const useQwikRouter = (props) => {
|
|
|
706
629
|
let shouldForceUrl = false;
|
|
707
630
|
let shouldForceParams = false;
|
|
708
631
|
if (!isSamePath(trackUrl, prevUrl)) {
|
|
709
|
-
if (_hasStoreEffects(
|
|
632
|
+
if (_hasStoreEffects(routeLocation2, "prevUrl")) {
|
|
710
633
|
shouldForcePrevUrl = true;
|
|
711
634
|
}
|
|
712
|
-
|
|
635
|
+
routeLocationTarget2.prevUrl = prevUrl;
|
|
713
636
|
}
|
|
714
|
-
if (
|
|
715
|
-
if (_hasStoreEffects(
|
|
637
|
+
if (routeLocationTarget2.url !== trackUrl) {
|
|
638
|
+
if (_hasStoreEffects(routeLocation2, "url")) {
|
|
716
639
|
shouldForceUrl = true;
|
|
717
640
|
}
|
|
718
|
-
|
|
641
|
+
routeLocationTarget2.url = trackUrl;
|
|
719
642
|
}
|
|
720
|
-
if (
|
|
721
|
-
if (_hasStoreEffects(
|
|
643
|
+
if (routeLocationTarget2.params !== $params$) {
|
|
644
|
+
if (_hasStoreEffects(routeLocation2, "params")) {
|
|
722
645
|
shouldForceParams = true;
|
|
723
646
|
}
|
|
724
|
-
|
|
647
|
+
routeLocationTarget2.params = $params$;
|
|
725
648
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
);
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
documentHead.scripts = resolvedHead.scripts;
|
|
741
|
-
documentHead.title = resolvedHead.title;
|
|
742
|
-
documentHead.frontmatter = resolvedHead.frontmatter;
|
|
649
|
+
routeInternal2.untrackedValue = {
|
|
650
|
+
type: navType,
|
|
651
|
+
dest: trackUrl
|
|
652
|
+
};
|
|
653
|
+
const resolvedHead = resolveHead(clientPageData, routeLocation2, contentModules, locale, serverHead2);
|
|
654
|
+
content2.headings = pageModule.headings;
|
|
655
|
+
content2.menu = $menu$;
|
|
656
|
+
contentInternal2.untrackedValue = noSerialize(contentModules);
|
|
657
|
+
documentHead2.links = resolvedHead.links;
|
|
658
|
+
documentHead2.meta = resolvedHead.meta;
|
|
659
|
+
documentHead2.styles = resolvedHead.styles;
|
|
660
|
+
documentHead2.scripts = resolvedHead.scripts;
|
|
661
|
+
documentHead2.title = resolvedHead.title;
|
|
662
|
+
documentHead2.frontmatter = resolvedHead.frontmatter;
|
|
743
663
|
if (isBrowser) {
|
|
744
664
|
let scrollState;
|
|
745
665
|
if (navType === "popstate") {
|
|
746
666
|
scrollState = getScrollHistory();
|
|
747
667
|
}
|
|
748
668
|
const scroller = document.getElementById(QWIK_ROUTER_SCROLLER) ?? document.documentElement;
|
|
749
|
-
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") ||
|
|
750
|
-
navType === "form" && !isSamePath(trackUrl, prevUrl)) {
|
|
669
|
+
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
|
|
751
670
|
document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
752
671
|
}
|
|
753
672
|
const loaders = clientPageData?.loaders;
|
|
754
673
|
if (loaders) {
|
|
755
674
|
const container3 = _getContextContainer();
|
|
756
675
|
for (const [key, value] of Object.entries(loaders)) {
|
|
757
|
-
const signal =
|
|
676
|
+
const signal = loaderState2[key];
|
|
758
677
|
const awaitedValue = await value;
|
|
759
|
-
|
|
678
|
+
loadersObject2[key] = awaitedValue;
|
|
760
679
|
if (!signal) {
|
|
761
|
-
|
|
762
|
-
loadersObject,
|
|
763
|
-
key,
|
|
764
|
-
trackUrl,
|
|
765
|
-
DEFAULT_LOADERS_SERIALIZATION_STRATEGY,
|
|
766
|
-
container3
|
|
767
|
-
);
|
|
680
|
+
loaderState2[key] = createLoaderSignal(loadersObject2, key, trackUrl, DEFAULT_LOADERS_SERIALIZATION_STRATEGY, container3);
|
|
768
681
|
} else {
|
|
769
682
|
signal.invalidate();
|
|
770
683
|
}
|
|
@@ -777,7 +690,7 @@ const useQwikRouter = (props) => {
|
|
|
777
690
|
window.addEventListener("popstate", () => {
|
|
778
691
|
window._qRouterScrollEnabled = false;
|
|
779
692
|
clearTimeout(window._qRouterScrollDebounce);
|
|
780
|
-
|
|
693
|
+
goto2(location.href, {
|
|
781
694
|
type: "popstate"
|
|
782
695
|
});
|
|
783
696
|
});
|
|
@@ -791,11 +704,11 @@ const useQwikRouter = (props) => {
|
|
|
791
704
|
if (state === null || typeof state === "undefined") {
|
|
792
705
|
state = {};
|
|
793
706
|
} else if (state?.constructor !== Object) {
|
|
794
|
-
state = {
|
|
707
|
+
state = {
|
|
708
|
+
_data: state
|
|
709
|
+
};
|
|
795
710
|
if (isDev) {
|
|
796
|
-
console.warn(
|
|
797
|
-
"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`"
|
|
798
|
-
);
|
|
711
|
+
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`");
|
|
799
712
|
}
|
|
800
713
|
}
|
|
801
714
|
state._qRouterScroll = state._qRouterScroll || currentScrollState(scroller);
|
|
@@ -835,46 +748,40 @@ const useQwikRouter = (props) => {
|
|
|
835
748
|
location.reload();
|
|
836
749
|
return;
|
|
837
750
|
}
|
|
838
|
-
|
|
751
|
+
goto2(target.getAttribute("href"));
|
|
839
752
|
}
|
|
840
753
|
}
|
|
841
754
|
});
|
|
842
755
|
document.removeEventListener("click", window._qRouterInitAnchors);
|
|
843
756
|
window._qRouterInitAnchors = void 0;
|
|
844
757
|
if (!window.navigation) {
|
|
845
|
-
document.addEventListener(
|
|
846
|
-
"
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (window._qCityScrollEnabled) {
|
|
850
|
-
console.warn(
|
|
851
|
-
'"_qCityScrollEnabled" is deprecated. Use "_qRouterScrollEnabled" instead.'
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
const scrollState2 = currentScrollState(scroller);
|
|
855
|
-
saveScrollHistory(scrollState2);
|
|
758
|
+
document.addEventListener("visibilitychange", () => {
|
|
759
|
+
if ((window._qRouterScrollEnabled || window._qCityScrollEnabled) && document.visibilityState === "hidden") {
|
|
760
|
+
if (window._qCityScrollEnabled) {
|
|
761
|
+
console.warn('"_qCityScrollEnabled" is deprecated. Use "_qRouterScrollEnabled" instead.');
|
|
856
762
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
763
|
+
const scrollState2 = currentScrollState(scroller);
|
|
764
|
+
saveScrollHistory(scrollState2);
|
|
765
|
+
}
|
|
766
|
+
}, {
|
|
767
|
+
passive: true
|
|
768
|
+
});
|
|
860
769
|
document.removeEventListener("visibilitychange", window._qRouterInitVisibility);
|
|
861
770
|
window._qRouterInitVisibility = void 0;
|
|
862
771
|
}
|
|
863
|
-
window.addEventListener(
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
{ passive: true }
|
|
877
|
-
);
|
|
772
|
+
window.addEventListener("scroll", () => {
|
|
773
|
+
if (!window._qRouterScrollEnabled && !window._qCityScrollEnabled) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
777
|
+
window._qRouterScrollDebounce = setTimeout(() => {
|
|
778
|
+
const scrollState2 = currentScrollState(scroller);
|
|
779
|
+
saveScrollHistory(scrollState2);
|
|
780
|
+
window._qRouterScrollDebounce = void 0;
|
|
781
|
+
}, 200);
|
|
782
|
+
}, {
|
|
783
|
+
passive: true
|
|
784
|
+
});
|
|
878
785
|
removeEventListener("scroll", window._qRouterInitScroll);
|
|
879
786
|
window._qRouterInitScroll = void 0;
|
|
880
787
|
spaInit.resolve();
|
|
@@ -887,16 +794,18 @@ const useQwikRouter = (props) => {
|
|
|
887
794
|
}
|
|
888
795
|
const navigate = () => {
|
|
889
796
|
clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
|
|
890
|
-
|
|
797
|
+
contentInternal2.trigger();
|
|
891
798
|
return _waitUntilRendered(container2);
|
|
892
799
|
};
|
|
893
800
|
const _waitNextPage = () => {
|
|
894
|
-
if (isServer ||
|
|
801
|
+
if (isServer || props2?.viewTransition === false) {
|
|
895
802
|
return navigate();
|
|
896
803
|
} else {
|
|
897
804
|
const viewTransition = startViewTransition({
|
|
898
805
|
update: navigate,
|
|
899
|
-
types: [
|
|
806
|
+
types: [
|
|
807
|
+
"qwik-navigation"
|
|
808
|
+
]
|
|
900
809
|
});
|
|
901
810
|
if (!viewTransition) {
|
|
902
811
|
return Promise.resolve();
|
|
@@ -908,7 +817,7 @@ const useQwikRouter = (props) => {
|
|
|
908
817
|
navigate();
|
|
909
818
|
throw err;
|
|
910
819
|
}).finally(() => {
|
|
911
|
-
container2.element.setAttribute?.(Q_ROUTE, routeName);
|
|
820
|
+
container2.element.setAttribute?.(Q_ROUTE, $routeName$);
|
|
912
821
|
const scrollState2 = currentScrollState(scroller);
|
|
913
822
|
saveScrollHistory(scrollState2);
|
|
914
823
|
window._qRouterScrollEnabled = true;
|
|
@@ -916,16 +825,16 @@ const useQwikRouter = (props) => {
|
|
|
916
825
|
callRestoreScrollOnDocument();
|
|
917
826
|
}
|
|
918
827
|
if (shouldForcePrevUrl) {
|
|
919
|
-
forceStoreEffects(
|
|
828
|
+
forceStoreEffects(routeLocation2, "prevUrl");
|
|
920
829
|
}
|
|
921
830
|
if (shouldForceUrl) {
|
|
922
|
-
forceStoreEffects(
|
|
831
|
+
forceStoreEffects(routeLocation2, "url");
|
|
923
832
|
}
|
|
924
833
|
if (shouldForceParams) {
|
|
925
|
-
forceStoreEffects(
|
|
834
|
+
forceStoreEffects(routeLocation2, "params");
|
|
926
835
|
}
|
|
927
|
-
|
|
928
|
-
|
|
836
|
+
routeLocation2.isNavigating = false;
|
|
837
|
+
navResolver2.r?.();
|
|
929
838
|
});
|
|
930
839
|
}
|
|
931
840
|
}
|
|
@@ -935,79 +844,100 @@ const useQwikRouter = (props) => {
|
|
|
935
844
|
} else {
|
|
936
845
|
run();
|
|
937
846
|
}
|
|
938
|
-
}
|
|
847
|
+
}, "useQwikRouter_useTask_XpalYii770E", [
|
|
848
|
+
actionState,
|
|
849
|
+
content,
|
|
850
|
+
contentInternal,
|
|
851
|
+
documentHead,
|
|
852
|
+
env,
|
|
853
|
+
goto,
|
|
854
|
+
httpStatus,
|
|
855
|
+
loaderState,
|
|
856
|
+
loadersObject,
|
|
857
|
+
navResolver,
|
|
858
|
+
props,
|
|
859
|
+
routeInternal,
|
|
860
|
+
routeLocation,
|
|
861
|
+
routeLocationTarget,
|
|
862
|
+
serverHead
|
|
863
|
+
]));
|
|
939
864
|
};
|
|
940
|
-
const QwikRouterProvider =
|
|
865
|
+
const QwikRouterProvider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
941
866
|
useQwikRouter(props);
|
|
942
|
-
return /* @__PURE__ */
|
|
943
|
-
});
|
|
867
|
+
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "5y_0");
|
|
868
|
+
}, "QwikRouterProvider_component_6Kjfa79mqlY"));
|
|
944
869
|
const QwikCityProvider = QwikRouterProvider;
|
|
945
870
|
const useQwikMockRouter = (props) => {
|
|
946
871
|
const urlEnv = props.url ?? "http://localhost/";
|
|
947
872
|
const url = new URL(urlEnv);
|
|
948
|
-
const routeLocation = useStore(
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
)
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
)
|
|
964
|
-
const loaderState = useStore(loadersData ?? {}, { deep: false });
|
|
965
|
-
const goto = props.goto ?? $(async () => {
|
|
873
|
+
const routeLocation = useStore({
|
|
874
|
+
url,
|
|
875
|
+
params: props.params ?? {},
|
|
876
|
+
isNavigating: false,
|
|
877
|
+
prevUrl: void 0
|
|
878
|
+
}, {
|
|
879
|
+
deep: false
|
|
880
|
+
});
|
|
881
|
+
const loadersData = props.loaders?.reduce((acc, { loader, data }) => {
|
|
882
|
+
acc[loader.__id] = data;
|
|
883
|
+
return acc;
|
|
884
|
+
}, {});
|
|
885
|
+
const loaderState = useStore(loadersData ?? {}, {
|
|
886
|
+
deep: false
|
|
887
|
+
});
|
|
888
|
+
const goto = props.goto ?? /* @__PURE__ */ inlinedQrl(async () => {
|
|
966
889
|
console.warn("QwikRouterMockProvider: goto not provided");
|
|
890
|
+
}, "useQwikMockRouter_goto_aViHFxQ1a3s");
|
|
891
|
+
const documentHead = useStore(createDocumentHead, {
|
|
892
|
+
deep: false
|
|
893
|
+
});
|
|
894
|
+
const content = useStore({
|
|
895
|
+
headings: void 0,
|
|
896
|
+
menu: void 0
|
|
897
|
+
}, {
|
|
898
|
+
deep: false
|
|
967
899
|
});
|
|
968
|
-
const documentHead = useStore(createDocumentHead, { deep: false });
|
|
969
|
-
const content = useStore(
|
|
970
|
-
{
|
|
971
|
-
headings: void 0,
|
|
972
|
-
menu: void 0
|
|
973
|
-
},
|
|
974
|
-
{ deep: false }
|
|
975
|
-
);
|
|
976
900
|
const contentInternal = useSignal();
|
|
977
901
|
const actionState = useSignal();
|
|
902
|
+
const httpStatus = useSignal({
|
|
903
|
+
status: 200,
|
|
904
|
+
message: ""
|
|
905
|
+
});
|
|
978
906
|
useContextProvider(ContentContext, content);
|
|
979
907
|
useContextProvider(ContentInternalContext, contentInternal);
|
|
980
908
|
useContextProvider(DocumentHeadContext, documentHead);
|
|
909
|
+
useContextProvider(HttpStatusContext, httpStatus);
|
|
981
910
|
useContextProvider(RouteLocationContext, routeLocation);
|
|
982
911
|
useContextProvider(RouteNavigateContext, goto);
|
|
983
912
|
useContextProvider(RouteStateContext, loaderState);
|
|
984
913
|
useContextProvider(RouteActionContext, actionState);
|
|
985
|
-
const actionsMocks = props.actions?.reduce(
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
useTask$(async ({ track }) => {
|
|
993
|
-
const action = track(actionState);
|
|
914
|
+
const actionsMocks = props.actions?.reduce((acc, { action, handler }) => {
|
|
915
|
+
acc[action.__id] = handler;
|
|
916
|
+
return acc;
|
|
917
|
+
}, {});
|
|
918
|
+
useTaskQrl(/* @__PURE__ */ inlinedQrl(async ({ track }) => {
|
|
919
|
+
const actionState2 = _captures[0], actionsMocks2 = _captures[1];
|
|
920
|
+
const action = track(actionState2);
|
|
994
921
|
if (!action?.resolve) {
|
|
995
922
|
return;
|
|
996
923
|
}
|
|
997
|
-
const mock =
|
|
924
|
+
const mock = actionsMocks2?.[action.id];
|
|
998
925
|
if (mock) {
|
|
999
926
|
const actionResult = await mock(action.data);
|
|
1000
927
|
action.resolve(actionResult);
|
|
1001
928
|
}
|
|
1002
|
-
}
|
|
929
|
+
}, "useQwikMockRouter_useTask_tXTLR4tzCy0", [
|
|
930
|
+
actionState,
|
|
931
|
+
actionsMocks
|
|
932
|
+
]));
|
|
1003
933
|
};
|
|
1004
|
-
const QwikRouterMockProvider =
|
|
934
|
+
const QwikRouterMockProvider = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
1005
935
|
useQwikMockRouter(props);
|
|
1006
|
-
return /* @__PURE__ */
|
|
1007
|
-
});
|
|
936
|
+
return /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "5y_1");
|
|
937
|
+
}, "QwikRouterMockProvider_component_IN4dVpT0x74"));
|
|
1008
938
|
const QwikCityMockProvider = QwikRouterMockProvider;
|
|
1009
939
|
|
|
1010
|
-
const RouterOutlet =
|
|
940
|
+
const RouterOutlet = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
1011
941
|
const serverData = useServerData("containerAttributes");
|
|
1012
942
|
if (!serverData) {
|
|
1013
943
|
throw new Error("PrefetchServiceWorker component must be rendered on the server.");
|
|
@@ -1019,179 +949,41 @@ const RouterOutlet = component$(() => {
|
|
|
1019
949
|
let cmp = null;
|
|
1020
950
|
for (let i = contentsLen - 1; i >= 0; i--) {
|
|
1021
951
|
if (contents[i].default) {
|
|
1022
|
-
cmp =
|
|
1023
|
-
children: cmp
|
|
1024
|
-
});
|
|
952
|
+
cmp = _jsxSorted(contents[i].default, null, null, cmp, 1, "Fn_0");
|
|
1025
953
|
}
|
|
1026
954
|
}
|
|
1027
|
-
return /* @__PURE__ */
|
|
955
|
+
return /* @__PURE__ */ _jsxSorted(Fragment, null, null, [
|
|
1028
956
|
cmp,
|
|
1029
|
-
!__EXPERIMENTAL__.noSPA && /* @__PURE__ */
|
|
1030
|
-
"
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
if (
|
|
1036
|
-
w.
|
|
1037
|
-
const s = h.state?._qRouterScroll;
|
|
1038
|
-
if (s) {
|
|
1039
|
-
w.scrollTo(s.x, s.y);
|
|
1040
|
-
}
|
|
1041
|
-
document.dispatchEvent(new Event("qcinit"));
|
|
957
|
+
!__EXPERIMENTAL__.noSPA && /* @__PURE__ */ _jsxSorted("script", {
|
|
958
|
+
"q-d:qinit": _qrlSync(() => {
|
|
959
|
+
((w, h) => {
|
|
960
|
+
if (!w._qcs && h.scrollRestoration === "manual") {
|
|
961
|
+
w._qcs = true;
|
|
962
|
+
const s = h.state?._qRouterScroll;
|
|
963
|
+
if (s) {
|
|
964
|
+
w.scrollTo(s.x, s.y);
|
|
1042
965
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
966
|
+
document.dispatchEvent(new Event("qcinit"));
|
|
967
|
+
}
|
|
968
|
+
})(window, history);
|
|
969
|
+
}, '()=>{((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);}')
|
|
970
|
+
}, {
|
|
971
|
+
"q-d:qcinit": spaInit
|
|
972
|
+
}, null, 2, "Fn_1")
|
|
973
|
+
], 1, "Fn_2");
|
|
1048
974
|
}
|
|
1049
975
|
return SkipRender;
|
|
1050
|
-
});
|
|
976
|
+
}, "RouterOutlet_component_QwONcWD5gIg"));
|
|
1051
977
|
|
|
1052
|
-
const routeActionQrl = ((actionQrl, ...rest) => {
|
|
1053
|
-
const { id, validators } = getValidators(rest, actionQrl);
|
|
1054
|
-
function action() {
|
|
1055
|
-
const loc = useLocation();
|
|
1056
|
-
const currentAction = useAction();
|
|
1057
|
-
const initialState = {
|
|
1058
|
-
actionPath: `?${QACTION_KEY}=${id}`,
|
|
1059
|
-
submitted: false,
|
|
1060
|
-
isRunning: false,
|
|
1061
|
-
status: void 0,
|
|
1062
|
-
value: void 0,
|
|
1063
|
-
formData: void 0
|
|
1064
|
-
};
|
|
1065
|
-
const state = useStore(() => {
|
|
1066
|
-
const value = currentAction.value;
|
|
1067
|
-
if (value && value?.id === id) {
|
|
1068
|
-
const data = value.data;
|
|
1069
|
-
if (data instanceof FormData) {
|
|
1070
|
-
initialState.formData = data;
|
|
1071
|
-
}
|
|
1072
|
-
if (value.output) {
|
|
1073
|
-
const { status, result } = value.output;
|
|
1074
|
-
initialState.status = status;
|
|
1075
|
-
initialState.value = result;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
return initialState;
|
|
1079
|
-
});
|
|
1080
|
-
const submit = $((input = {}) => {
|
|
1081
|
-
if (isServer) {
|
|
1082
|
-
throw new Error(`Actions can not be invoked within the server during SSR.
|
|
1083
|
-
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
|
|
1084
|
-
}
|
|
1085
|
-
let data;
|
|
1086
|
-
let form;
|
|
1087
|
-
if (input instanceof SubmitEvent) {
|
|
1088
|
-
form = input.target;
|
|
1089
|
-
data = new FormData(form);
|
|
1090
|
-
if ((input.submitter instanceof HTMLInputElement || input.submitter instanceof HTMLButtonElement) && input.submitter.name) {
|
|
1091
|
-
if (input.submitter.name) {
|
|
1092
|
-
data.append(input.submitter.name, input.submitter.value);
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
} else {
|
|
1096
|
-
data = input;
|
|
1097
|
-
}
|
|
1098
|
-
return new Promise((resolve) => {
|
|
1099
|
-
if (data instanceof FormData) {
|
|
1100
|
-
state.formData = data;
|
|
1101
|
-
}
|
|
1102
|
-
state.submitted = true;
|
|
1103
|
-
state.isRunning = true;
|
|
1104
|
-
loc.isNavigating = true;
|
|
1105
|
-
currentAction.value = {
|
|
1106
|
-
data,
|
|
1107
|
-
id,
|
|
1108
|
-
resolve: noSerialize(resolve)
|
|
1109
|
-
};
|
|
1110
|
-
}).then(({ result, status }) => {
|
|
1111
|
-
state.isRunning = false;
|
|
1112
|
-
state.status = status;
|
|
1113
|
-
state.value = result;
|
|
1114
|
-
if (form) {
|
|
1115
|
-
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1116
|
-
form.reset();
|
|
1117
|
-
}
|
|
1118
|
-
const detail = { status, value: result };
|
|
1119
|
-
form.dispatchEvent(
|
|
1120
|
-
new CustomEvent("submitcompleted", {
|
|
1121
|
-
bubbles: false,
|
|
1122
|
-
cancelable: false,
|
|
1123
|
-
composed: false,
|
|
1124
|
-
detail
|
|
1125
|
-
})
|
|
1126
|
-
);
|
|
1127
|
-
}
|
|
1128
|
-
return {
|
|
1129
|
-
status,
|
|
1130
|
-
value: result
|
|
1131
|
-
};
|
|
1132
|
-
});
|
|
1133
|
-
});
|
|
1134
|
-
initialState.submit = submit;
|
|
1135
|
-
return state;
|
|
1136
|
-
}
|
|
1137
|
-
action.__brand = "server_action";
|
|
1138
|
-
action.__validators = validators;
|
|
1139
|
-
action.__qrl = actionQrl;
|
|
1140
|
-
action.__id = id;
|
|
1141
|
-
Object.freeze(action);
|
|
1142
|
-
return action;
|
|
1143
|
-
});
|
|
1144
|
-
const globalActionQrl = ((actionQrl, ...rest) => {
|
|
1145
|
-
const action = routeActionQrl(actionQrl, ...rest);
|
|
1146
|
-
if (isServer) {
|
|
1147
|
-
if (typeof globalThis._qwikActionsMap === "undefined") {
|
|
1148
|
-
globalThis._qwikActionsMap = /* @__PURE__ */ new Map();
|
|
1149
|
-
}
|
|
1150
|
-
globalThis._qwikActionsMap.set(action.__id, action);
|
|
1151
|
-
}
|
|
1152
|
-
return action;
|
|
1153
|
-
});
|
|
1154
|
-
const routeAction$ = /* @__PURE__ */ implicit$FirstArg(
|
|
1155
|
-
routeActionQrl
|
|
1156
|
-
);
|
|
1157
|
-
const globalAction$ = /* @__PURE__ */ implicit$FirstArg(
|
|
1158
|
-
globalActionQrl
|
|
1159
|
-
);
|
|
1160
978
|
const getValue = (obj) => obj.value;
|
|
1161
|
-
const
|
|
1162
|
-
const { id, validators, serializationStrategy } = getValidators(rest, loaderQrl);
|
|
1163
|
-
function loader() {
|
|
1164
|
-
const state = _resolveContextWithoutSequentialScope(RouteStateContext);
|
|
1165
|
-
if (!(id in state)) {
|
|
1166
|
-
throw new Error(`routeLoader$ "${loaderQrl.getSymbol()}" was invoked in a route where it was not declared.
|
|
1167
|
-
This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
|
|
1168
|
-
For more information check: https://qwik.dev/docs/route-loader/
|
|
1169
|
-
|
|
1170
|
-
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.
|
|
1171
|
-
For more information check: https://qwik.dev/docs/re-exporting-loaders/`);
|
|
1172
|
-
}
|
|
1173
|
-
const loaderData = state[id];
|
|
1174
|
-
untrack(getValue, loaderData);
|
|
1175
|
-
return loaderData;
|
|
1176
|
-
}
|
|
1177
|
-
loader.__brand = "server_loader";
|
|
1178
|
-
loader.__qrl = loaderQrl;
|
|
1179
|
-
loader.__validators = validators;
|
|
1180
|
-
loader.__id = id;
|
|
1181
|
-
loader.__serializationStrategy = serializationStrategy;
|
|
1182
|
-
loader.__expires = -1;
|
|
1183
|
-
Object.freeze(loader);
|
|
1184
|
-
return loader;
|
|
1185
|
-
});
|
|
1186
|
-
const routeLoader$ = /* @__PURE__ */ implicit$FirstArg(routeLoaderQrl);
|
|
1187
|
-
const validatorQrl = ((validator) => {
|
|
979
|
+
const validatorQrl = (validator) => {
|
|
1188
980
|
if (isServer) {
|
|
1189
981
|
return {
|
|
1190
982
|
validate: validator
|
|
1191
983
|
};
|
|
1192
984
|
}
|
|
1193
985
|
return void 0;
|
|
1194
|
-
}
|
|
986
|
+
};
|
|
1195
987
|
const validator$ = /* @__PURE__ */ implicit$FirstArg(validatorQrl);
|
|
1196
988
|
const flattenValibotIssues = (issues) => {
|
|
1197
989
|
return issues.reduce((acc, issue) => {
|
|
@@ -1214,9 +1006,7 @@ const flattenValibotIssues = (issues) => {
|
|
|
1214
1006
|
};
|
|
1215
1007
|
const valibotQrl = (qrl) => {
|
|
1216
1008
|
if (!__EXPERIMENTAL__.valibot) {
|
|
1217
|
-
throw new Error(
|
|
1218
|
-
'Valibot is an experimental feature and is not enabled. Please enable the feature flag by adding `experimental: ["valibot"]` to your qwikVite plugin options.'
|
|
1219
|
-
);
|
|
1009
|
+
throw new Error('Valibot is an experimental feature and is not enabled. Please enable the feature flag by adding `experimental: ["valibot"]` to your qwikVite plugin options.');
|
|
1220
1010
|
}
|
|
1221
1011
|
if (isServer) {
|
|
1222
1012
|
return {
|
|
@@ -1250,7 +1040,9 @@ const valibotQrl = (qrl) => {
|
|
|
1250
1040
|
};
|
|
1251
1041
|
const valibot$ = /* @__PURE__ */ implicit$FirstArg(valibotQrl);
|
|
1252
1042
|
const flattenZodIssues = (issues) => {
|
|
1253
|
-
issues = Array.isArray(issues) ? issues : [
|
|
1043
|
+
issues = Array.isArray(issues) ? issues : [
|
|
1044
|
+
issues
|
|
1045
|
+
];
|
|
1254
1046
|
return issues.reduce((acc, issue) => {
|
|
1255
1047
|
const isExpectingArray = "expected" in issue && issue.expected === "array";
|
|
1256
1048
|
const hasArrayType = issue.path.some((path) => typeof path === "number") || isExpectingArray;
|
|
@@ -1306,6 +1098,205 @@ const zodQrl = (qrl) => {
|
|
|
1306
1098
|
return void 0;
|
|
1307
1099
|
};
|
|
1308
1100
|
const zod$ = /* @__PURE__ */ implicit$FirstArg(zodQrl);
|
|
1101
|
+
const getValidators = (rest, qrl) => {
|
|
1102
|
+
let id;
|
|
1103
|
+
let serializationStrategy = DEFAULT_LOADERS_SERIALIZATION_STRATEGY;
|
|
1104
|
+
const validators = [];
|
|
1105
|
+
if (rest.length === 1) {
|
|
1106
|
+
const options = rest[0];
|
|
1107
|
+
if (options && typeof options === "object") {
|
|
1108
|
+
if ("validate" in options) {
|
|
1109
|
+
validators.push(options);
|
|
1110
|
+
} else {
|
|
1111
|
+
id = options.id;
|
|
1112
|
+
if (options.serializationStrategy) {
|
|
1113
|
+
serializationStrategy = options.serializationStrategy;
|
|
1114
|
+
}
|
|
1115
|
+
if (options.validation) {
|
|
1116
|
+
validators.push(...options.validation);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
} else if (rest.length > 1) {
|
|
1121
|
+
validators.push(...rest.filter((v2) => !!v2));
|
|
1122
|
+
}
|
|
1123
|
+
if (typeof id === "string") {
|
|
1124
|
+
if (isDev) {
|
|
1125
|
+
if (!/^[\w/.-]+$/.test(id)) {
|
|
1126
|
+
throw new Error(`Invalid id: ${id}, id can only contain [a-zA-Z0-9_.-]`);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
id = `id_${id}`;
|
|
1130
|
+
} else {
|
|
1131
|
+
id = qrl.getHash();
|
|
1132
|
+
}
|
|
1133
|
+
return {
|
|
1134
|
+
validators: validators.reverse(),
|
|
1135
|
+
id,
|
|
1136
|
+
serializationStrategy
|
|
1137
|
+
};
|
|
1138
|
+
};
|
|
1139
|
+
const routeActionQrl = (actionQrl, ...rest) => {
|
|
1140
|
+
const { id, validators } = getValidators(rest, actionQrl);
|
|
1141
|
+
function action() {
|
|
1142
|
+
const loc = useLocation();
|
|
1143
|
+
const currentAction = useAction();
|
|
1144
|
+
const initialState = {
|
|
1145
|
+
actionPath: `?${QACTION_KEY}=${id}`,
|
|
1146
|
+
submitted: false,
|
|
1147
|
+
isRunning: false,
|
|
1148
|
+
status: void 0,
|
|
1149
|
+
value: void 0,
|
|
1150
|
+
formData: void 0
|
|
1151
|
+
};
|
|
1152
|
+
const state = useStore(() => {
|
|
1153
|
+
const value = currentAction.value;
|
|
1154
|
+
if (value && value?.id === id) {
|
|
1155
|
+
const data = value.data;
|
|
1156
|
+
if (data instanceof FormData) {
|
|
1157
|
+
initialState.formData = data;
|
|
1158
|
+
}
|
|
1159
|
+
if (value.output) {
|
|
1160
|
+
const { status, result } = value.output;
|
|
1161
|
+
initialState.status = status;
|
|
1162
|
+
initialState.value = result;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return initialState;
|
|
1166
|
+
});
|
|
1167
|
+
const submit = /* @__PURE__ */ inlinedQrl((input = {}) => {
|
|
1168
|
+
const currentAction2 = _captures[0], id2 = _captures[1], loc2 = _captures[2], state2 = _captures[3];
|
|
1169
|
+
if (isServer) {
|
|
1170
|
+
throw new Error(`Actions can not be invoked within the server during SSR.
|
|
1171
|
+
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
|
|
1172
|
+
}
|
|
1173
|
+
let data;
|
|
1174
|
+
let form;
|
|
1175
|
+
if (input instanceof SubmitEvent) {
|
|
1176
|
+
form = input.target;
|
|
1177
|
+
data = new FormData(form);
|
|
1178
|
+
if ((input.submitter instanceof HTMLInputElement || input.submitter instanceof HTMLButtonElement) && input.submitter.name) {
|
|
1179
|
+
if (input.submitter.name) {
|
|
1180
|
+
data.append(input.submitter.name, input.submitter.value);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
} else {
|
|
1184
|
+
data = input;
|
|
1185
|
+
}
|
|
1186
|
+
return new Promise((resolve) => {
|
|
1187
|
+
if (data instanceof FormData) {
|
|
1188
|
+
state2.formData = data;
|
|
1189
|
+
}
|
|
1190
|
+
state2.submitted = true;
|
|
1191
|
+
state2.isRunning = true;
|
|
1192
|
+
loc2.isNavigating = true;
|
|
1193
|
+
currentAction2.value = {
|
|
1194
|
+
data,
|
|
1195
|
+
id: id2,
|
|
1196
|
+
resolve: noSerialize(resolve)
|
|
1197
|
+
};
|
|
1198
|
+
}).then(({ result, status }) => {
|
|
1199
|
+
state2.isRunning = false;
|
|
1200
|
+
state2.status = status;
|
|
1201
|
+
state2.value = result;
|
|
1202
|
+
if (form) {
|
|
1203
|
+
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1204
|
+
form.reset();
|
|
1205
|
+
}
|
|
1206
|
+
const detail = {
|
|
1207
|
+
status,
|
|
1208
|
+
value: result
|
|
1209
|
+
};
|
|
1210
|
+
form.dispatchEvent(new CustomEvent("submitcompleted", {
|
|
1211
|
+
bubbles: false,
|
|
1212
|
+
cancelable: false,
|
|
1213
|
+
composed: false,
|
|
1214
|
+
detail
|
|
1215
|
+
}));
|
|
1216
|
+
}
|
|
1217
|
+
return {
|
|
1218
|
+
status,
|
|
1219
|
+
value: result
|
|
1220
|
+
};
|
|
1221
|
+
});
|
|
1222
|
+
}, "routeActionQrl_action_submit_YuS5bpdQ360", [
|
|
1223
|
+
currentAction,
|
|
1224
|
+
id,
|
|
1225
|
+
loc,
|
|
1226
|
+
state
|
|
1227
|
+
]);
|
|
1228
|
+
initialState.submit = submit;
|
|
1229
|
+
return state;
|
|
1230
|
+
}
|
|
1231
|
+
action.__brand = "server_action";
|
|
1232
|
+
action.__validators = validators;
|
|
1233
|
+
action.__qrl = actionQrl;
|
|
1234
|
+
action.__id = id;
|
|
1235
|
+
Object.freeze(action);
|
|
1236
|
+
return action;
|
|
1237
|
+
};
|
|
1238
|
+
const globalActionQrl = (actionQrl, ...rest) => {
|
|
1239
|
+
const action = routeActionQrl(actionQrl, ...rest);
|
|
1240
|
+
if (isServer) {
|
|
1241
|
+
if (typeof globalThis._qwikActionsMap === "undefined") {
|
|
1242
|
+
globalThis._qwikActionsMap = /* @__PURE__ */ new Map();
|
|
1243
|
+
}
|
|
1244
|
+
globalThis._qwikActionsMap.set(action.__id, action);
|
|
1245
|
+
}
|
|
1246
|
+
return action;
|
|
1247
|
+
};
|
|
1248
|
+
const routeAction$ = /* @__PURE__ */ implicit$FirstArg(routeActionQrl);
|
|
1249
|
+
const globalAction$ = /* @__PURE__ */ implicit$FirstArg(globalActionQrl);
|
|
1250
|
+
const routeLoaderQrl = (loaderQrl, ...rest) => {
|
|
1251
|
+
const { id, validators, serializationStrategy } = getValidators(rest, loaderQrl);
|
|
1252
|
+
function loader() {
|
|
1253
|
+
const state = _resolveContextWithoutSequentialScope(RouteStateContext);
|
|
1254
|
+
if (!(id in state)) {
|
|
1255
|
+
throw new Error(`routeLoader$ "${loaderQrl.getSymbol()}" was invoked in a route where it was not declared.
|
|
1256
|
+
This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
|
|
1257
|
+
For more information check: https://qwik.dev/docs/route-loader/
|
|
1258
|
+
|
|
1259
|
+
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.
|
|
1260
|
+
For more information check: https://qwik.dev/docs/re-exporting-loaders/`);
|
|
1261
|
+
}
|
|
1262
|
+
const loaderData = state[id];
|
|
1263
|
+
untrack(getValue, loaderData);
|
|
1264
|
+
return loaderData;
|
|
1265
|
+
}
|
|
1266
|
+
loader.__brand = "server_loader";
|
|
1267
|
+
loader.__qrl = loaderQrl;
|
|
1268
|
+
loader.__validators = validators;
|
|
1269
|
+
loader.__id = id;
|
|
1270
|
+
loader.__serializationStrategy = serializationStrategy;
|
|
1271
|
+
loader.__expires = -1;
|
|
1272
|
+
Object.freeze(loader);
|
|
1273
|
+
return loader;
|
|
1274
|
+
};
|
|
1275
|
+
const routeLoader$ = /* @__PURE__ */ implicit$FirstArg(routeLoaderQrl);
|
|
1276
|
+
const deserializeStream = async function* (stream, abortSignal) {
|
|
1277
|
+
const reader = stream.getReader();
|
|
1278
|
+
try {
|
|
1279
|
+
let buffer = "";
|
|
1280
|
+
const decoder = new TextDecoder();
|
|
1281
|
+
while (!abortSignal?.aborted) {
|
|
1282
|
+
const result = await reader.read();
|
|
1283
|
+
if (result.done) {
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
buffer += decoder.decode(result.value, {
|
|
1287
|
+
stream: true
|
|
1288
|
+
});
|
|
1289
|
+
const lines = buffer.split(/\n/);
|
|
1290
|
+
buffer = lines.pop();
|
|
1291
|
+
for (const line of lines) {
|
|
1292
|
+
const deserializedData = _deserialize(line);
|
|
1293
|
+
yield deserializedData;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
} finally {
|
|
1297
|
+
reader.releaseLock();
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1309
1300
|
const serverQrl = (qrl, options) => {
|
|
1310
1301
|
if (isServer) {
|
|
1311
1302
|
const captured = qrl.getCaptured();
|
|
@@ -1317,17 +1308,20 @@ const serverQrl = (qrl, options) => {
|
|
|
1317
1308
|
const headers = options?.headers || {};
|
|
1318
1309
|
const origin = options?.origin || "";
|
|
1319
1310
|
const fetchOptions = options?.fetchOptions || {};
|
|
1320
|
-
return
|
|
1311
|
+
return /* @__PURE__ */ inlinedQrl(async function(...args) {
|
|
1312
|
+
const fetchOptions2 = _captures[0], headers2 = _captures[1], method2 = _captures[2], origin2 = _captures[3], qrl2 = _captures[4];
|
|
1321
1313
|
const abortSignal = args.length > 0 && args[0] instanceof AbortSignal ? args.shift() : void 0;
|
|
1322
1314
|
if (isServer) {
|
|
1323
1315
|
let requestEvent = _asyncRequestStore?.getStore();
|
|
1324
1316
|
if (!requestEvent) {
|
|
1325
|
-
const contexts = [
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1317
|
+
const contexts = [
|
|
1318
|
+
useQwikRouterEnv()?.ev,
|
|
1319
|
+
this,
|
|
1320
|
+
_getContextEvent()
|
|
1321
|
+
];
|
|
1322
|
+
requestEvent = contexts.find((v2) => v2 && Object.prototype.hasOwnProperty.call(v2, "sharedMap") && Object.prototype.hasOwnProperty.call(v2, "cookie"));
|
|
1329
1323
|
}
|
|
1330
|
-
return
|
|
1324
|
+
return qrl2.apply(requestEvent, args);
|
|
1331
1325
|
} else {
|
|
1332
1326
|
let filteredArgs = args.map((arg) => {
|
|
1333
1327
|
if (arg instanceof SubmitEvent && arg.target instanceof HTMLFormElement) {
|
|
@@ -1342,13 +1336,13 @@ const serverQrl = (qrl, options) => {
|
|
|
1342
1336
|
if (!filteredArgs.length) {
|
|
1343
1337
|
filteredArgs = void 0;
|
|
1344
1338
|
}
|
|
1345
|
-
const qrlHash =
|
|
1339
|
+
const qrlHash = qrl2.getHash();
|
|
1346
1340
|
let query = "";
|
|
1347
1341
|
const config = {
|
|
1348
|
-
...
|
|
1349
|
-
method,
|
|
1342
|
+
...fetchOptions2,
|
|
1343
|
+
method: method2,
|
|
1350
1344
|
headers: {
|
|
1351
|
-
...
|
|
1345
|
+
...headers2,
|
|
1352
1346
|
"Content-Type": "application/qwik-json",
|
|
1353
1347
|
Accept: "application/json, application/qwik-json, text/qwik-json-stream, text/plain",
|
|
1354
1348
|
// Required so we don't call accidentally
|
|
@@ -1356,20 +1350,27 @@ const serverQrl = (qrl, options) => {
|
|
|
1356
1350
|
},
|
|
1357
1351
|
signal: abortSignal
|
|
1358
1352
|
};
|
|
1359
|
-
const captured =
|
|
1360
|
-
let toSend = [
|
|
1353
|
+
const captured = qrl2.getCaptured();
|
|
1354
|
+
let toSend = [
|
|
1355
|
+
filteredArgs
|
|
1356
|
+
];
|
|
1361
1357
|
if (captured?.length) {
|
|
1362
|
-
toSend = [
|
|
1358
|
+
toSend = [
|
|
1359
|
+
filteredArgs,
|
|
1360
|
+
...captured
|
|
1361
|
+
];
|
|
1363
1362
|
} else {
|
|
1364
|
-
toSend = filteredArgs ? [
|
|
1363
|
+
toSend = filteredArgs ? [
|
|
1364
|
+
filteredArgs
|
|
1365
|
+
] : [];
|
|
1365
1366
|
}
|
|
1366
1367
|
const body = await _serialize(toSend);
|
|
1367
|
-
if (
|
|
1368
|
+
if (method2 === "GET") {
|
|
1368
1369
|
query += `&${QDATA_KEY}=${encodeURIComponent(body)}`;
|
|
1369
1370
|
} else {
|
|
1370
1371
|
config.body = body;
|
|
1371
1372
|
}
|
|
1372
|
-
const res = await fetch(`${
|
|
1373
|
+
const res = await fetch(`${origin2}?${QFN_KEY}=${qrlHash}${query}`, config);
|
|
1373
1374
|
const contentType = res.headers.get("Content-Type");
|
|
1374
1375
|
if (res.ok && contentType === "text/qwik-json-stream" && res.body) {
|
|
1375
1376
|
return (async function* () {
|
|
@@ -1404,171 +1405,117 @@ const serverQrl = (qrl, options) => {
|
|
|
1404
1405
|
return str;
|
|
1405
1406
|
}
|
|
1406
1407
|
}
|
|
1407
|
-
}
|
|
1408
|
+
}, "serverQrl_w03grD0Ag68", [
|
|
1409
|
+
fetchOptions,
|
|
1410
|
+
headers,
|
|
1411
|
+
method,
|
|
1412
|
+
origin,
|
|
1413
|
+
qrl
|
|
1414
|
+
]);
|
|
1408
1415
|
};
|
|
1409
1416
|
const server$ = /* @__PURE__ */ implicit$FirstArg(serverQrl);
|
|
1410
|
-
const getValidators = (rest, qrl) => {
|
|
1411
|
-
let id;
|
|
1412
|
-
let serializationStrategy = DEFAULT_LOADERS_SERIALIZATION_STRATEGY;
|
|
1413
|
-
const validators = [];
|
|
1414
|
-
if (rest.length === 1) {
|
|
1415
|
-
const options = rest[0];
|
|
1416
|
-
if (options && typeof options === "object") {
|
|
1417
|
-
if ("validate" in options) {
|
|
1418
|
-
validators.push(options);
|
|
1419
|
-
} else {
|
|
1420
|
-
id = options.id;
|
|
1421
|
-
if (options.serializationStrategy) {
|
|
1422
|
-
serializationStrategy = options.serializationStrategy;
|
|
1423
|
-
}
|
|
1424
|
-
if (options.validation) {
|
|
1425
|
-
validators.push(...options.validation);
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
} else if (rest.length > 1) {
|
|
1430
|
-
validators.push(...rest.filter((v2) => !!v2));
|
|
1431
|
-
}
|
|
1432
|
-
if (typeof id === "string") {
|
|
1433
|
-
if (isDev) {
|
|
1434
|
-
if (!/^[\w/.-]+$/.test(id)) {
|
|
1435
|
-
throw new Error(`Invalid id: ${id}, id can only contain [a-zA-Z0-9_.-]`);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
id = `id_${id}`;
|
|
1439
|
-
} else {
|
|
1440
|
-
id = qrl.getHash();
|
|
1441
|
-
}
|
|
1442
|
-
return {
|
|
1443
|
-
validators: validators.reverse(),
|
|
1444
|
-
id,
|
|
1445
|
-
serializationStrategy
|
|
1446
|
-
};
|
|
1447
|
-
};
|
|
1448
|
-
const deserializeStream = async function* (stream, abortSignal) {
|
|
1449
|
-
const reader = stream.getReader();
|
|
1450
|
-
try {
|
|
1451
|
-
let buffer = "";
|
|
1452
|
-
const decoder = new TextDecoder();
|
|
1453
|
-
while (!abortSignal?.aborted) {
|
|
1454
|
-
const result = await reader.read();
|
|
1455
|
-
if (result.done) {
|
|
1456
|
-
break;
|
|
1457
|
-
}
|
|
1458
|
-
buffer += decoder.decode(result.value, { stream: true });
|
|
1459
|
-
const lines = buffer.split(/\n/);
|
|
1460
|
-
buffer = lines.pop();
|
|
1461
|
-
for (const line of lines) {
|
|
1462
|
-
const deserializedData = _deserialize(line);
|
|
1463
|
-
yield deserializedData;
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
} finally {
|
|
1467
|
-
reader.releaseLock();
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1470
1417
|
|
|
1471
|
-
const ServiceWorkerRegister = (props) => /* @__PURE__ */
|
|
1418
|
+
const ServiceWorkerRegister = (props) => /* @__PURE__ */ _jsxSorted("script", {
|
|
1419
|
+
nonce: _wrapProp(props, "nonce")
|
|
1420
|
+
}, {
|
|
1421
|
+
type: "module",
|
|
1422
|
+
dangerouslySetInnerHTML: swRegister
|
|
1423
|
+
}, null, 3, "1x_0");
|
|
1472
1424
|
|
|
1425
|
+
const GetForm = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(({ action: _0, spaReset, reloadDocument, onSubmit$, ...rest }) => {
|
|
1426
|
+
const nav = useNavigate();
|
|
1427
|
+
return /* @__PURE__ */ _jsxSplit("form", {
|
|
1428
|
+
action: "get",
|
|
1429
|
+
"preventdefault:submit": !reloadDocument,
|
|
1430
|
+
"data-spa-reset": spaReset ? "true" : void 0,
|
|
1431
|
+
..._getVarProps(rest),
|
|
1432
|
+
..._getConstProps(rest),
|
|
1433
|
+
"q-e:submit": [
|
|
1434
|
+
...Array.isArray(onSubmit$) ? onSubmit$ : [
|
|
1435
|
+
onSubmit$
|
|
1436
|
+
],
|
|
1437
|
+
/* @__PURE__ */ inlinedQrl(async (_evt, form) => {
|
|
1438
|
+
const nav2 = _captures[0];
|
|
1439
|
+
const formData = new FormData(form);
|
|
1440
|
+
const params = new URLSearchParams();
|
|
1441
|
+
formData.forEach((value, key) => {
|
|
1442
|
+
if (typeof value === "string") {
|
|
1443
|
+
params.append(key, value);
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
await nav2("?" + params.toString(), {
|
|
1447
|
+
type: "form",
|
|
1448
|
+
forceReload: true
|
|
1449
|
+
});
|
|
1450
|
+
}, "GetForm_component_form_q_e_submit_r3dkP9d2cF8", [
|
|
1451
|
+
nav
|
|
1452
|
+
]),
|
|
1453
|
+
/* @__PURE__ */ inlinedQrl((_evt, form) => {
|
|
1454
|
+
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1455
|
+
form.reset();
|
|
1456
|
+
}
|
|
1457
|
+
form.dispatchEvent(new CustomEvent("submitcompleted", {
|
|
1458
|
+
bubbles: false,
|
|
1459
|
+
cancelable: false,
|
|
1460
|
+
composed: false,
|
|
1461
|
+
detail: {
|
|
1462
|
+
status: 200
|
|
1463
|
+
}
|
|
1464
|
+
}));
|
|
1465
|
+
}, "GetForm_component_form_q_e_submit_1_cuYklZAOHrA")
|
|
1466
|
+
]
|
|
1467
|
+
}, null, /* @__PURE__ */ _jsxSorted(Slot, null, null, null, 3, "Q4_0"), 0, "Q4_1");
|
|
1468
|
+
}, "GetForm_component_2U5Z2Z8ryc0"));
|
|
1473
1469
|
const Form = ({ action, spaReset, reloadDocument, onSubmit$, ...rest }, key) => {
|
|
1474
1470
|
if (action) {
|
|
1475
1471
|
const isArrayApi = Array.isArray(onSubmit$);
|
|
1476
1472
|
if (isArrayApi) {
|
|
1477
|
-
return
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
action: action.actionPath,
|
|
1482
|
-
"preventdefault:submit": !reloadDocument,
|
|
1483
|
-
onSubmit$: [
|
|
1484
|
-
...onSubmit$,
|
|
1485
|
-
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1486
|
-
!reloadDocument ? $((evt) => {
|
|
1487
|
-
if (!action.submitted) {
|
|
1488
|
-
return action.submit(evt);
|
|
1489
|
-
}
|
|
1490
|
-
}) : void 0
|
|
1491
|
-
],
|
|
1492
|
-
method: "post",
|
|
1493
|
-
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1494
|
-
},
|
|
1495
|
-
key
|
|
1496
|
-
);
|
|
1497
|
-
}
|
|
1498
|
-
return jsx$1(
|
|
1499
|
-
"form",
|
|
1500
|
-
{
|
|
1501
|
-
...rest,
|
|
1502
|
-
action: action.actionPath,
|
|
1473
|
+
return _jsxSplit("form", {
|
|
1474
|
+
..._getVarProps(rest),
|
|
1475
|
+
..._getConstProps(rest),
|
|
1476
|
+
action: _wrapProp(action, "actionPath"),
|
|
1503
1477
|
"preventdefault:submit": !reloadDocument,
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
onSubmit$,
|
|
1478
|
+
"q-e:submit": [
|
|
1479
|
+
...onSubmit$,
|
|
1507
1480
|
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1508
|
-
!reloadDocument ?
|
|
1481
|
+
!reloadDocument ? /* @__PURE__ */ inlinedQrl((evt) => {
|
|
1482
|
+
const action2 = _captures[0];
|
|
1483
|
+
if (!action2.submitted) {
|
|
1484
|
+
return action2.submit(evt);
|
|
1485
|
+
}
|
|
1486
|
+
}, "Form_form_q_e_submit_6i0Jq5q8JFg", [
|
|
1487
|
+
action
|
|
1488
|
+
]) : void 0
|
|
1509
1489
|
],
|
|
1510
|
-
method: "post",
|
|
1511
1490
|
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1512
|
-
},
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
return
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1491
|
+
}, {
|
|
1492
|
+
method: "post"
|
|
1493
|
+
}, null, 0, key);
|
|
1494
|
+
}
|
|
1495
|
+
return _jsxSplit("form", {
|
|
1496
|
+
..._getVarProps(rest),
|
|
1497
|
+
..._getConstProps(rest),
|
|
1498
|
+
action: _wrapProp(action, "actionPath"),
|
|
1499
|
+
"preventdefault:submit": !reloadDocument,
|
|
1500
|
+
"q-e:submit": [
|
|
1501
|
+
// Since v2, this fires before the action is executed so it can be prevented
|
|
1521
1502
|
onSubmit$,
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1503
|
+
// action.submit "submitcompleted" event for onSubmitCompleted$ events
|
|
1504
|
+
!reloadDocument ? action.submit : void 0
|
|
1505
|
+
],
|
|
1506
|
+
["data-spa-reset"]: spaReset ? "true" : void 0
|
|
1507
|
+
}, {
|
|
1508
|
+
method: "post"
|
|
1509
|
+
}, null, 0, key);
|
|
1510
|
+
} else {
|
|
1511
|
+
return /* @__PURE__ */ _jsxSplit(GetForm, {
|
|
1512
|
+
spaReset,
|
|
1513
|
+
reloadDocument,
|
|
1514
|
+
onSubmit$,
|
|
1515
|
+
...rest
|
|
1516
|
+
}, null, null, 0, key);
|
|
1526
1517
|
}
|
|
1527
1518
|
};
|
|
1528
|
-
const GetForm = component$(
|
|
1529
|
-
({ action: _0, spaReset, reloadDocument, onSubmit$, ...rest }) => {
|
|
1530
|
-
const nav = useNavigate();
|
|
1531
|
-
return /* @__PURE__ */ jsx(
|
|
1532
|
-
"form",
|
|
1533
|
-
{
|
|
1534
|
-
action: "get",
|
|
1535
|
-
"preventdefault:submit": !reloadDocument,
|
|
1536
|
-
"data-spa-reset": spaReset ? "true" : void 0,
|
|
1537
|
-
...rest,
|
|
1538
|
-
onSubmit$: [
|
|
1539
|
-
...Array.isArray(onSubmit$) ? onSubmit$ : [onSubmit$],
|
|
1540
|
-
$(async (_evt, form) => {
|
|
1541
|
-
const formData = new FormData(form);
|
|
1542
|
-
const params = new URLSearchParams();
|
|
1543
|
-
formData.forEach((value, key) => {
|
|
1544
|
-
if (typeof value === "string") {
|
|
1545
|
-
params.append(key, value);
|
|
1546
|
-
}
|
|
1547
|
-
});
|
|
1548
|
-
await nav("?" + params.toString(), { type: "form", forceReload: true });
|
|
1549
|
-
}),
|
|
1550
|
-
$((_evt, form) => {
|
|
1551
|
-
if (form.getAttribute("data-spa-reset") === "true") {
|
|
1552
|
-
form.reset();
|
|
1553
|
-
}
|
|
1554
|
-
form.dispatchEvent(
|
|
1555
|
-
new CustomEvent("submitcompleted", {
|
|
1556
|
-
bubbles: false,
|
|
1557
|
-
cancelable: false,
|
|
1558
|
-
composed: false,
|
|
1559
|
-
detail: {
|
|
1560
|
-
status: 200
|
|
1561
|
-
}
|
|
1562
|
-
})
|
|
1563
|
-
);
|
|
1564
|
-
})
|
|
1565
|
-
// end of array
|
|
1566
|
-
],
|
|
1567
|
-
children: /* @__PURE__ */ jsx(Slot, {})
|
|
1568
|
-
}
|
|
1569
|
-
);
|
|
1570
|
-
}
|
|
1571
|
-
);
|
|
1572
1519
|
|
|
1573
1520
|
const untypedAppUrl = function appUrl(route, params, paramsPrefix = "") {
|
|
1574
1521
|
const path = route.split("/");
|
|
@@ -1608,44 +1555,45 @@ function omitProps(obj, keys) {
|
|
|
1608
1555
|
}
|
|
1609
1556
|
|
|
1610
1557
|
const createRenderer = (getOptions) => {
|
|
1611
|
-
return (
|
|
1558
|
+
return (opts) => {
|
|
1612
1559
|
const { jsx, options } = getOptions(opts);
|
|
1613
1560
|
return renderToStream(jsx, options);
|
|
1614
|
-
}
|
|
1561
|
+
};
|
|
1615
1562
|
};
|
|
1616
1563
|
|
|
1617
|
-
const DocumentHeadTags =
|
|
1564
|
+
const DocumentHeadTags = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
1618
1565
|
let head = useDocumentHead();
|
|
1619
1566
|
if (props) {
|
|
1620
|
-
head = {
|
|
1567
|
+
head = {
|
|
1568
|
+
...head,
|
|
1569
|
+
...props
|
|
1570
|
+
};
|
|
1621
1571
|
}
|
|
1622
|
-
return /* @__PURE__ */
|
|
1623
|
-
head.title && /* @__PURE__ */
|
|
1624
|
-
head.meta.map((m) => /* @__PURE__ */
|
|
1625
|
-
|
|
1572
|
+
return /* @__PURE__ */ _jsxSorted(Fragment, null, null, [
|
|
1573
|
+
head.title && /* @__PURE__ */ _jsxSorted("title", null, null, head.title, 1, "r5_0"),
|
|
1574
|
+
head.meta.map((m) => /* @__PURE__ */ _jsxSplit("meta", {
|
|
1575
|
+
..._getVarProps(m)
|
|
1576
|
+
}, _getConstProps(m), null, 0, "r5_1")),
|
|
1577
|
+
head.links.map((l) => /* @__PURE__ */ _jsxSplit("link", {
|
|
1578
|
+
..._getVarProps(l)
|
|
1579
|
+
}, _getConstProps(l), null, 0, "r5_2")),
|
|
1626
1580
|
head.styles.map((s) => {
|
|
1627
1581
|
const props2 = s.props || s;
|
|
1628
|
-
return /* @__PURE__ */ createElement(
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
key: s.key
|
|
1634
|
-
}
|
|
1635
|
-
);
|
|
1582
|
+
return /* @__PURE__ */ createElement("style", {
|
|
1583
|
+
...props2,
|
|
1584
|
+
dangerouslySetInnerHTML: s.style || props2.dangerouslySetInnerHTML,
|
|
1585
|
+
key: s.key
|
|
1586
|
+
});
|
|
1636
1587
|
}),
|
|
1637
1588
|
head.scripts.map((s) => {
|
|
1638
1589
|
const props2 = s.props || s;
|
|
1639
|
-
return /* @__PURE__ */ createElement(
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
key: s.key
|
|
1645
|
-
}
|
|
1646
|
-
);
|
|
1590
|
+
return /* @__PURE__ */ createElement("script", {
|
|
1591
|
+
...props2,
|
|
1592
|
+
dangerouslySetInnerHTML: s.script || props2.dangerouslySetInnerHTML,
|
|
1593
|
+
key: s.key
|
|
1594
|
+
});
|
|
1647
1595
|
})
|
|
1648
|
-
]
|
|
1649
|
-
});
|
|
1596
|
+
], 1, "r5_3");
|
|
1597
|
+
}, "DocumentHeadTags_component_9CrWYOoCpgY"));
|
|
1650
1598
|
|
|
1651
|
-
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,
|
|
1599
|
+
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 };
|