@qwik.dev/router 2.0.0-alpha.1 → 2.0.0-alpha.10
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.cjs +3 -3
- package/lib/adapters/azure-swa/vite/index.d.ts +13 -13
- package/lib/adapters/bun-server/vite/index.cjs +3 -3
- package/lib/adapters/bun-server/vite/index.d.ts +14 -14
- package/lib/adapters/cloud-run/vite/index.cjs +3 -3
- package/lib/adapters/cloud-run/vite/index.d.ts +13 -13
- package/lib/adapters/cloudflare-pages/vite/index.cjs +3 -3
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +27 -27
- package/lib/adapters/deno-server/vite/index.cjs +3 -3
- package/lib/adapters/deno-server/vite/index.d.ts +14 -14
- package/lib/adapters/netlify-edge/vite/index.cjs +3 -3
- package/lib/adapters/netlify-edge/vite/index.d.ts +44 -44
- package/lib/adapters/node-server/vite/index.cjs +3 -3
- package/lib/adapters/node-server/vite/index.d.ts +14 -14
- package/lib/adapters/shared/vite/index.cjs +10 -3
- package/lib/adapters/shared/vite/index.d.ts +114 -114
- package/lib/adapters/shared/vite/index.mjs +7 -0
- package/lib/adapters/static/vite/index.cjs +10 -3
- package/lib/adapters/static/vite/index.d.ts +10 -10
- package/lib/adapters/static/vite/index.mjs +7 -0
- package/lib/adapters/vercel-edge/vite/index.cjs +3 -3
- package/lib/adapters/vercel-edge/vite/index.d.ts +45 -45
- package/lib/index.d.ts +878 -801
- package/lib/index.qwik.cjs +84 -84
- package/lib/index.qwik.mjs +64 -64
- package/lib/middleware/aws-lambda/index.d.ts +48 -50
- package/lib/middleware/azure-swa/index.d.ts +28 -28
- package/lib/middleware/bun/index.d.ts +35 -35
- package/lib/middleware/cloudflare-pages/index.d.ts +35 -35
- package/lib/middleware/deno/index.d.ts +47 -47
- package/lib/middleware/firebase/index.d.ts +26 -26
- package/lib/middleware/netlify-edge/index.d.ts +27 -27
- package/lib/middleware/node/index.cjs +3 -3
- package/lib/middleware/node/index.d.ts +64 -66
- package/lib/middleware/request-handler/index.cjs +37 -38
- package/lib/middleware/request-handler/index.d.ts +676 -681
- package/lib/middleware/request-handler/index.mjs +34 -35
- package/lib/middleware/vercel-edge/index.d.ts +26 -26
- package/lib/service-worker.cjs +13 -263
- package/lib/service-worker.d.ts +15 -4
- package/lib/service-worker.mjs +13 -263
- package/lib/static/index.cjs +3 -3
- package/lib/static/index.d.ts +96 -98
- package/lib/static/node.cjs +3 -3
- package/lib/vite/index.cjs +129 -247
- package/lib/vite/index.d.ts +154 -154
- package/lib/vite/index.mjs +127 -245
- package/package.json +10 -9
package/lib/index.qwik.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@qwik.dev/core/jsx-runtime");
|
|
4
4
|
const core = require("@qwik.dev/core");
|
|
5
|
-
const
|
|
5
|
+
const preloader = require("@qwik.dev/core/preloader");
|
|
6
6
|
const internal = require("@qwik.dev/core/internal");
|
|
7
7
|
const qwikRouterConfig = require("@qwik-router-config");
|
|
8
8
|
const zod = require("zod");
|
|
@@ -24,9 +24,20 @@ function _interopNamespaceDefault(e) {
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
const qwikRouterConfig__namespace = /* @__PURE__ */ _interopNamespaceDefault(qwikRouterConfig);
|
|
27
|
+
const ErrorBoundary = core.component$((props) => {
|
|
28
|
+
const store2 = core.useErrorBoundary();
|
|
29
|
+
core.useOnWindow("qerror", core.$((e) => {
|
|
30
|
+
store2.error = e.detail.error;
|
|
31
|
+
}));
|
|
32
|
+
if (store2.error && props.fallback$) {
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
34
|
+
children: props.fallback$(store2.error)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {});
|
|
38
|
+
});
|
|
27
39
|
const MODULE_CACHE = /* @__PURE__ */ new WeakMap();
|
|
28
40
|
const CLIENT_DATA_CACHE = /* @__PURE__ */ new Map();
|
|
29
|
-
const PREFETCHED_NAVIGATE_PATHS = /* @__PURE__ */ new Set();
|
|
30
41
|
const QACTION_KEY = "qaction";
|
|
31
42
|
const QFN_KEY = "qfunc";
|
|
32
43
|
const QDATA_KEY = "qdata";
|
|
@@ -64,15 +75,7 @@ const getClientNavPath = (props, baseUrl) => {
|
|
|
64
75
|
}
|
|
65
76
|
return null;
|
|
66
77
|
};
|
|
67
|
-
const
|
|
68
|
-
if (clientNavPath) {
|
|
69
|
-
const prefetchUrl = toUrl(clientNavPath, currentLoc.url);
|
|
70
|
-
const currentUrl = toUrl("", currentLoc.url);
|
|
71
|
-
return !isSamePath(prefetchUrl, currentUrl);
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
};
|
|
75
|
-
const shouldPrefetchSymbols = (clientNavPath, currentLoc) => {
|
|
78
|
+
const shouldPreload = (clientNavPath, currentLoc) => {
|
|
76
79
|
if (clientNavPath) {
|
|
77
80
|
const prefetchUrl = toUrl(clientNavPath, currentLoc.url);
|
|
78
81
|
const currentUrl = toUrl("", currentLoc.url);
|
|
@@ -120,18 +123,10 @@ const newScrollState = () => {
|
|
|
120
123
|
};
|
|
121
124
|
};
|
|
122
125
|
const prefetchSymbols = (path) => {
|
|
123
|
-
if (
|
|
126
|
+
if (core.isBrowser) {
|
|
124
127
|
path = path.endsWith("/") ? path : path + "/";
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
document.dispatchEvent(new CustomEvent("qprefetch", {
|
|
128
|
-
detail: {
|
|
129
|
-
links: [
|
|
130
|
-
path
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
128
|
+
path = path.length > 1 && path.startsWith("/") ? path.slice(1) : path;
|
|
129
|
+
preloader.p(path, 0.8);
|
|
135
130
|
}
|
|
136
131
|
};
|
|
137
132
|
const loadClientData = async (url, element, opts) => {
|
|
@@ -147,7 +142,7 @@ const loadClientData = async (url, element, opts) => {
|
|
|
147
142
|
}
|
|
148
143
|
let resolveFn;
|
|
149
144
|
if (!qData) {
|
|
150
|
-
const fetchOptions = getFetchOptions(opts?.action);
|
|
145
|
+
const fetchOptions = getFetchOptions(opts?.action, opts?.clearCache);
|
|
151
146
|
if (opts?.action) {
|
|
152
147
|
opts.action.data = void 0;
|
|
153
148
|
}
|
|
@@ -203,16 +198,19 @@ const loadClientData = async (url, element, opts) => {
|
|
|
203
198
|
return v;
|
|
204
199
|
});
|
|
205
200
|
};
|
|
206
|
-
const getFetchOptions = (action) => {
|
|
201
|
+
const getFetchOptions = (action, noCache) => {
|
|
207
202
|
const actionData = action?.data;
|
|
208
203
|
if (!actionData) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
204
|
+
if (noCache) {
|
|
205
|
+
return {
|
|
206
|
+
cache: "no-cache",
|
|
207
|
+
headers: {
|
|
208
|
+
"Cache-Control": "no-cache",
|
|
209
|
+
Pragma: "no-cache"
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return void 0;
|
|
216
214
|
}
|
|
217
215
|
if (actionData instanceof FormData) {
|
|
218
216
|
return {
|
|
@@ -256,14 +254,15 @@ const Link = core.component$((props) => {
|
|
|
256
254
|
const nav = useNavigate();
|
|
257
255
|
const loc = useLocation();
|
|
258
256
|
const originalHref = props.href;
|
|
257
|
+
const anchorRef = core.useSignal();
|
|
259
258
|
const { onClick$, prefetch: prefetchProp, reload, replaceState, scroll, ...linkProps } = /* @__PURE__ */ (() => props)();
|
|
260
259
|
const clientNavPath = core.untrack(() => getClientNavPath({
|
|
261
260
|
...linkProps,
|
|
262
261
|
reload
|
|
263
262
|
}, loc));
|
|
264
263
|
linkProps.href = clientNavPath || originalHref;
|
|
265
|
-
const prefetchData = core.untrack(() => !!clientNavPath && prefetchProp !== false && prefetchProp !== "js"
|
|
266
|
-
const prefetch = core.untrack(() => prefetchData || !!clientNavPath && prefetchProp !== false &&
|
|
264
|
+
const prefetchData = core.untrack(() => !!clientNavPath && prefetchProp !== false && prefetchProp !== "js" || void 0);
|
|
265
|
+
const prefetch = core.untrack(() => prefetchData || !!clientNavPath && prefetchProp !== false && shouldPreload(clientNavPath, loc));
|
|
267
266
|
const handlePrefetch = prefetch ? core.$((_, elm) => {
|
|
268
267
|
if (navigator.connection?.saveData) {
|
|
269
268
|
return;
|
|
@@ -286,11 +285,7 @@ const Link = core.component$((props) => {
|
|
|
286
285
|
}) : void 0;
|
|
287
286
|
const handleClick = clientNavPath ? core.$(async (event, elm) => {
|
|
288
287
|
if (event.defaultPrevented) {
|
|
289
|
-
if (elm.
|
|
290
|
-
await nav(location.href, {
|
|
291
|
-
type: "popstate"
|
|
292
|
-
});
|
|
293
|
-
} else if (elm.href) {
|
|
288
|
+
if (elm.href) {
|
|
294
289
|
elm.setAttribute("aria-pressed", "true");
|
|
295
290
|
await nav(elm.href, {
|
|
296
291
|
forceReload: reload,
|
|
@@ -301,7 +296,14 @@ const Link = core.component$((props) => {
|
|
|
301
296
|
}
|
|
302
297
|
}
|
|
303
298
|
}) : void 0;
|
|
299
|
+
core.useVisibleTask$(({ track }) => {
|
|
300
|
+
track(() => loc.url.pathname);
|
|
301
|
+
if (!core.isDev && anchorRef.value) {
|
|
302
|
+
handlePrefetch?.(void 0, anchorRef.value);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
304
305
|
return /* @__PURE__ */ jsxRuntime.jsx("a", {
|
|
306
|
+
ref: anchorRef,
|
|
305
307
|
"q:link": !!clientNavPath,
|
|
306
308
|
...linkProps,
|
|
307
309
|
onClick$: [
|
|
@@ -318,11 +320,6 @@ const Link = core.component$((props) => {
|
|
|
318
320
|
linkProps.onFocus$,
|
|
319
321
|
handlePrefetch
|
|
320
322
|
],
|
|
321
|
-
// Don't prefetch on visible in dev mode
|
|
322
|
-
onQVisible$: [
|
|
323
|
-
linkProps.onQVisible$,
|
|
324
|
-
!build.isDev ? handlePrefetch : void 0
|
|
325
|
-
],
|
|
326
323
|
children: /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {})
|
|
327
324
|
});
|
|
328
325
|
});
|
|
@@ -615,7 +612,6 @@ const spaInit = core.event$((_, el) => {
|
|
|
615
612
|
if (!win[spa] && !win[initPopstate] && !win[initAnchors] && !win[initVisibility] && !win[initScroll]) {
|
|
616
613
|
const currentPath = location.pathname + location.search;
|
|
617
614
|
const historyPatch = "_qRouterHistoryPatch";
|
|
618
|
-
const bootstrap = "_qRouterBootstrap";
|
|
619
615
|
const scrollEnabled = "_qRouterScrollEnabled";
|
|
620
616
|
const debounceTimeout = "_qRouterScrollDebounce";
|
|
621
617
|
const scrollHistory = "_qRouterScroll";
|
|
@@ -647,15 +643,16 @@ const spaInit = core.event$((_, el) => {
|
|
|
647
643
|
clearTimeout(win[debounceTimeout]);
|
|
648
644
|
if (currentPath !== location.pathname + location.search) {
|
|
649
645
|
const getContainer = (el2) => el2.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])");
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
646
|
+
const container = getContainer(el);
|
|
647
|
+
const domContainer = container.qContainer;
|
|
648
|
+
const hostElement = domContainer.vNodeLocate(el);
|
|
649
|
+
const nav = domContainer?.resolveContext(hostElement, {
|
|
650
|
+
id: "qc--n"
|
|
651
|
+
});
|
|
652
|
+
if (nav) {
|
|
653
|
+
nav(location.href, {
|
|
654
|
+
type: "popstate"
|
|
655
|
+
});
|
|
659
656
|
} else {
|
|
660
657
|
location.reload();
|
|
661
658
|
}
|
|
@@ -678,7 +675,7 @@ const spaInit = core.event$((_, el) => {
|
|
|
678
675
|
state = {
|
|
679
676
|
_data: state
|
|
680
677
|
};
|
|
681
|
-
if (
|
|
678
|
+
if (core.isDev) {
|
|
682
679
|
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`");
|
|
683
680
|
}
|
|
684
681
|
}
|
|
@@ -816,7 +813,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
816
813
|
}
|
|
817
814
|
} : void 0);
|
|
818
815
|
const registerPreventNav = core.$((fn$) => {
|
|
819
|
-
if (!
|
|
816
|
+
if (!core.isBrowser) {
|
|
820
817
|
return;
|
|
821
818
|
}
|
|
822
819
|
preventNav.$handler$ || (preventNav.$handler$ = (event) => {
|
|
@@ -865,19 +862,19 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
865
862
|
}
|
|
866
863
|
}
|
|
867
864
|
if (typeof dest === "number") {
|
|
868
|
-
if (
|
|
865
|
+
if (core.isBrowser) {
|
|
869
866
|
history.go(dest);
|
|
870
867
|
}
|
|
871
868
|
return;
|
|
872
869
|
}
|
|
873
870
|
if (!isSameOrigin(dest, lastDest)) {
|
|
874
|
-
if (
|
|
871
|
+
if (core.isBrowser) {
|
|
875
872
|
location.href = dest.href;
|
|
876
873
|
}
|
|
877
874
|
return;
|
|
878
875
|
}
|
|
879
876
|
if (!forceReload && isSamePath(dest, lastDest)) {
|
|
880
|
-
if (
|
|
877
|
+
if (core.isBrowser) {
|
|
881
878
|
if (type === "link" && dest.href !== location.href) {
|
|
882
879
|
history.pushState(null, "", dest);
|
|
883
880
|
}
|
|
@@ -905,7 +902,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
905
902
|
replaceState,
|
|
906
903
|
scroll
|
|
907
904
|
};
|
|
908
|
-
if (
|
|
905
|
+
if (core.isBrowser) {
|
|
909
906
|
loadClientData(dest, internal._getContextElement());
|
|
910
907
|
loadRoute(qwikRouterConfig__namespace.routes, qwikRouterConfig__namespace.menus, qwikRouterConfig__namespace.cacheModules, dest.pathname);
|
|
911
908
|
}
|
|
@@ -938,7 +935,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
938
935
|
let clientPageData;
|
|
939
936
|
let loadedRoute = null;
|
|
940
937
|
let elm;
|
|
941
|
-
if (
|
|
938
|
+
if (core.isServer) {
|
|
942
939
|
trackUrl = new URL(navigation.dest, routeLocation.url);
|
|
943
940
|
loadedRoute = env.loadedRoute;
|
|
944
941
|
clientPageData = env.response;
|
|
@@ -985,7 +982,9 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
985
982
|
if (navigation.dest.search && !isRedirect) {
|
|
986
983
|
trackUrl.search = navigation.dest.search;
|
|
987
984
|
}
|
|
988
|
-
|
|
985
|
+
if (!isSamePath(trackUrl, prevUrl)) {
|
|
986
|
+
routeLocation.prevUrl = prevUrl;
|
|
987
|
+
}
|
|
989
988
|
routeLocation.url = trackUrl;
|
|
990
989
|
routeLocation.params = {
|
|
991
990
|
...params
|
|
@@ -1004,7 +1003,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
1004
1003
|
documentHead.scripts = resolvedHead.scripts;
|
|
1005
1004
|
documentHead.title = resolvedHead.title;
|
|
1006
1005
|
documentHead.frontmatter = resolvedHead.frontmatter;
|
|
1007
|
-
if (
|
|
1006
|
+
if (core.isBrowser) {
|
|
1008
1007
|
if (props.viewTransition !== false) {
|
|
1009
1008
|
document.__q_view_transition__ = true;
|
|
1010
1009
|
}
|
|
@@ -1045,7 +1044,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
1045
1044
|
state = {
|
|
1046
1045
|
_data: state
|
|
1047
1046
|
};
|
|
1048
|
-
if (
|
|
1047
|
+
if (core.isDev) {
|
|
1049
1048
|
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`");
|
|
1050
1049
|
}
|
|
1051
1050
|
}
|
|
@@ -1122,8 +1121,6 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
1122
1121
|
});
|
|
1123
1122
|
removeEventListener("scroll", win._qRouterInitScroll);
|
|
1124
1123
|
win._qRouterInitScroll = void 0;
|
|
1125
|
-
win._qRouterBootstrap?.remove();
|
|
1126
|
-
win._qRouterBootstrap = void 0;
|
|
1127
1124
|
spaInit.resolve();
|
|
1128
1125
|
}
|
|
1129
1126
|
if (navType !== "popstate") {
|
|
@@ -1139,7 +1136,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
1139
1136
|
const scrollState2 = currentScrollState(scroller);
|
|
1140
1137
|
saveScrollHistory(scrollState2);
|
|
1141
1138
|
win._qRouterScrollEnabled = true;
|
|
1142
|
-
if (
|
|
1139
|
+
if (core.isBrowser) {
|
|
1143
1140
|
callRestoreScrollOnDocument();
|
|
1144
1141
|
}
|
|
1145
1142
|
routeLocation.isNavigating = false;
|
|
@@ -1149,7 +1146,7 @@ const QwikRouterProvider = core.component$((props) => {
|
|
|
1149
1146
|
}
|
|
1150
1147
|
}
|
|
1151
1148
|
const promise = run();
|
|
1152
|
-
if (
|
|
1149
|
+
if (core.isServer) {
|
|
1153
1150
|
return promise;
|
|
1154
1151
|
} else {
|
|
1155
1152
|
return;
|
|
@@ -1337,7 +1334,7 @@ const routeActionQrl = (actionQrl, ...rest) => {
|
|
|
1337
1334
|
return initialState;
|
|
1338
1335
|
});
|
|
1339
1336
|
const submit = core.$((input = {}) => {
|
|
1340
|
-
if (
|
|
1337
|
+
if (core.isServer) {
|
|
1341
1338
|
throw new Error(`Actions can not be invoked within the server during SSR.
|
|
1342
1339
|
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
|
|
1343
1340
|
}
|
|
@@ -1403,7 +1400,7 @@ Action.run() can only be called on the browser, for example when a user clicks a
|
|
|
1403
1400
|
};
|
|
1404
1401
|
const globalActionQrl = (actionQrl, ...rest) => {
|
|
1405
1402
|
const action = routeActionQrl(actionQrl, ...rest);
|
|
1406
|
-
if (
|
|
1403
|
+
if (core.isServer) {
|
|
1407
1404
|
if (typeof globalThis._qwikActionsMap === "undefined") {
|
|
1408
1405
|
globalThis._qwikActionsMap = /* @__PURE__ */ new Map();
|
|
1409
1406
|
}
|
|
@@ -1423,9 +1420,9 @@ const routeLoaderQrl = (loaderQrl, ...rest) => {
|
|
|
1423
1420
|
For more information check: https://qwik.dev/docs/route-loader/
|
|
1424
1421
|
|
|
1425
1422
|
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.
|
|
1426
|
-
For more information check: https://qwik.dev/docs/
|
|
1423
|
+
For more information check: https://qwik.dev/docs/re-exporting-loaders/`);
|
|
1427
1424
|
}
|
|
1428
|
-
return internal.
|
|
1425
|
+
return internal._wrapStore(state, id);
|
|
1429
1426
|
});
|
|
1430
1427
|
}
|
|
1431
1428
|
loader.__brand = "server_loader";
|
|
@@ -1437,7 +1434,7 @@ const routeLoaderQrl = (loaderQrl, ...rest) => {
|
|
|
1437
1434
|
};
|
|
1438
1435
|
const routeLoader$ = /* @__PURE__ */ core.implicit$FirstArg(routeLoaderQrl);
|
|
1439
1436
|
const validatorQrl = (validator) => {
|
|
1440
|
-
if (
|
|
1437
|
+
if (core.isServer) {
|
|
1441
1438
|
return {
|
|
1442
1439
|
validate: validator
|
|
1443
1440
|
};
|
|
@@ -1468,7 +1465,7 @@ const valibotQrl = (qrl) => {
|
|
|
1468
1465
|
if (!__EXPERIMENTAL__.valibot) {
|
|
1469
1466
|
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.');
|
|
1470
1467
|
}
|
|
1471
|
-
if (
|
|
1468
|
+
if (core.isServer) {
|
|
1472
1469
|
return {
|
|
1473
1470
|
__brand: "valibot",
|
|
1474
1471
|
async validate(ev, inputData) {
|
|
@@ -1481,7 +1478,7 @@ const valibotQrl = (qrl) => {
|
|
|
1481
1478
|
data: result.output
|
|
1482
1479
|
};
|
|
1483
1480
|
} else {
|
|
1484
|
-
if (
|
|
1481
|
+
if (core.isDev) {
|
|
1485
1482
|
console.error("ERROR: Valibot validation failed", result.issues);
|
|
1486
1483
|
}
|
|
1487
1484
|
return {
|
|
@@ -1521,7 +1518,7 @@ const flattenZodIssues = (issues) => {
|
|
|
1521
1518
|
}, {});
|
|
1522
1519
|
};
|
|
1523
1520
|
const zodQrl = (qrl) => {
|
|
1524
|
-
if (
|
|
1521
|
+
if (core.isServer) {
|
|
1525
1522
|
return {
|
|
1526
1523
|
__brand: "zod",
|
|
1527
1524
|
async validate(ev, inputData) {
|
|
@@ -1540,7 +1537,7 @@ const zodQrl = (qrl) => {
|
|
|
1540
1537
|
if (result.success) {
|
|
1541
1538
|
return result;
|
|
1542
1539
|
} else {
|
|
1543
|
-
if (
|
|
1540
|
+
if (core.isDev) {
|
|
1544
1541
|
console.error("ERROR: Zod validation failed", result.error.issues);
|
|
1545
1542
|
}
|
|
1546
1543
|
return {
|
|
@@ -1559,7 +1556,7 @@ const zodQrl = (qrl) => {
|
|
|
1559
1556
|
};
|
|
1560
1557
|
const zod$ = /* @__PURE__ */ core.implicit$FirstArg(zodQrl);
|
|
1561
1558
|
const serverQrl = (qrl, options) => {
|
|
1562
|
-
if (
|
|
1559
|
+
if (core.isServer) {
|
|
1563
1560
|
const captured = qrl.getCaptured();
|
|
1564
1561
|
if (captured && captured.length > 0 && !internal._getContextElement()) {
|
|
1565
1562
|
throw new Error("For security reasons, we cannot serialize QRLs that capture lexical scope.");
|
|
@@ -1572,7 +1569,7 @@ const serverQrl = (qrl, options) => {
|
|
|
1572
1569
|
function rpc() {
|
|
1573
1570
|
return core.$(async function(...args) {
|
|
1574
1571
|
const abortSignal = args.length > 0 && args[0] instanceof AbortSignal ? args.shift() : void 0;
|
|
1575
|
-
if (
|
|
1572
|
+
if (core.isServer) {
|
|
1576
1573
|
let requestEvent = globalThis.qcAsyncRequestStore?.getStore();
|
|
1577
1574
|
if (!requestEvent) {
|
|
1578
1575
|
const contexts = [
|
|
@@ -1582,7 +1579,7 @@ const serverQrl = (qrl, options) => {
|
|
|
1582
1579
|
];
|
|
1583
1580
|
requestEvent = contexts.find((v2) => v2 && Object.prototype.hasOwnProperty.call(v2, "sharedMap") && Object.prototype.hasOwnProperty.call(v2, "cookie"));
|
|
1584
1581
|
}
|
|
1585
|
-
return qrl.apply(requestEvent,
|
|
1582
|
+
return qrl.apply(requestEvent, core.isDev ? deepFreeze(args) : args);
|
|
1586
1583
|
} else {
|
|
1587
1584
|
const ctxElm = internal._getContextElement();
|
|
1588
1585
|
const filteredArgs = args.map((arg) => {
|
|
@@ -1603,6 +1600,7 @@ const serverQrl = (qrl, options) => {
|
|
|
1603
1600
|
headers: {
|
|
1604
1601
|
...headers,
|
|
1605
1602
|
"Content-Type": "application/qwik-json",
|
|
1603
|
+
Accept: "application/json, application/qwik-json, text/qwik-json-stream, text/plain",
|
|
1606
1604
|
// Required so we don't call accidentally
|
|
1607
1605
|
"X-QRL": qrlHash
|
|
1608
1606
|
},
|
|
@@ -1634,19 +1632,19 @@ const serverQrl = (qrl, options) => {
|
|
|
1634
1632
|
} else if (contentType === "application/qwik-json") {
|
|
1635
1633
|
const str = await res.text();
|
|
1636
1634
|
const [obj] = internal._deserialize(str, ctxElm ?? document.documentElement);
|
|
1637
|
-
if (res.status
|
|
1635
|
+
if (res.status >= 400) {
|
|
1638
1636
|
throw obj;
|
|
1639
1637
|
}
|
|
1640
1638
|
return obj;
|
|
1641
1639
|
} else if (contentType === "application/json") {
|
|
1642
1640
|
const obj = await res.json();
|
|
1643
|
-
if (res.status
|
|
1641
|
+
if (res.status >= 400) {
|
|
1644
1642
|
throw obj;
|
|
1645
1643
|
}
|
|
1646
1644
|
return obj;
|
|
1647
1645
|
} else if (contentType === "text/plain" || contentType === "text/html") {
|
|
1648
1646
|
const str = await res.text();
|
|
1649
|
-
if (res.status
|
|
1647
|
+
if (res.status >= 400) {
|
|
1650
1648
|
throw str;
|
|
1651
1649
|
}
|
|
1652
1650
|
return str;
|
|
@@ -1676,7 +1674,7 @@ const getValidators = (rest, qrl) => {
|
|
|
1676
1674
|
validators.push(...rest.filter((v2) => !!v2));
|
|
1677
1675
|
}
|
|
1678
1676
|
if (typeof id === "string") {
|
|
1679
|
-
if (
|
|
1677
|
+
if (core.isDev) {
|
|
1680
1678
|
if (!/^[\w/.-]+$/.test(id)) {
|
|
1681
1679
|
throw new Error(`Invalid id: ${id}, id can only contain [a-zA-Z0-9_.-]`);
|
|
1682
1680
|
}
|
|
@@ -1714,7 +1712,8 @@ const deserializeStream = async function* (stream, ctxElm, abortSignal) {
|
|
|
1714
1712
|
reader.releaseLock();
|
|
1715
1713
|
}
|
|
1716
1714
|
};
|
|
1717
|
-
const ServiceWorkerRegister = (props) =>
|
|
1715
|
+
const ServiceWorkerRegister = (props) => /* @__PURE__ */ jsxRuntime.jsx("script", {
|
|
1716
|
+
type: "module",
|
|
1718
1717
|
dangerouslySetInnerHTML: swRegister,
|
|
1719
1718
|
nonce: props.nonce
|
|
1720
1719
|
});
|
|
@@ -1842,6 +1841,7 @@ Object.defineProperty(exports, "z", {
|
|
|
1842
1841
|
enumerable: true,
|
|
1843
1842
|
get: () => zod.z
|
|
1844
1843
|
});
|
|
1844
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
1845
1845
|
exports.Form = Form;
|
|
1846
1846
|
exports.Link = Link;
|
|
1847
1847
|
exports.QWIK_CITY_SCROLLER = QWIK_CITY_SCROLLER;
|