@qwik.dev/router 2.0.0-rc.2 → 2.0.0-rc.3
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/netlify-edge/vite/index.d.ts +1 -1
- package/lib/adapters/netlify-edge/vite/index.mjs +1 -1
- package/lib/chunks/head.qwik.mjs +93 -29
- package/lib/chunks/user-response.mjs +8 -6
- package/lib/index.d.ts +13 -5
- package/lib/index.qwik.mjs +354 -372
- package/lib/middleware/request-handler/index.mjs +1 -1
- package/package.json +3 -3
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as ensureSlash } from "./chunks/pathname.mjs";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as HttpStatusContext, B as _setRouterConfig, C as getRequestEvent, F as routeLoader$, G as REFRESH_HEAD, H as getRouterConfig, I as routeLoaderQrl, J as preventNav, K as RUN_PENDING_ACTION, L as setLoaderSignalValue, M as prepareRouteLoaders, P as restoreRouteLoaders, Q as DocumentHeadContext, S as getModuleRouteLoaders, U as getRoutes, V as getBasePathname, W as getTrailingSlash, X as ContentContext, Y as registerPreventNav, Z as ContentInternalContext, _ as commitRouteLoaders, a as isPromise, at as RouteStateContext, b as getClientRouteLoaders, c as shouldPreload, ct as QFN_KEY, d as loadRoute, et as RouteActionContext, h as clearNavFetchCache, i as getClientNavPath, it as RouteNavigateContext, k as isImmutableLoader, l as toPath, lt as Q_ROUTE, m as abortRouteLoaderNavigation, n as resolveHead, nt as RouteLoaderCtxContext, o as isSameOrigin, ot as QACTION_KEY, q as internalState, rt as RouteLocationContext, s as isSamePath, st as QDATA_KEY, t as createDocumentHead, tt as RouteActionRunnerContext, u as toUrl, v as ensureRouteLoaderSignals, y as fetchRouteLoaderData, z as _getServiceWorkerUrl } from "./chunks/head.qwik.mjs";
|
|
3
3
|
import { SkipRender, Slot, _capturesObj, _fnSignal, _getConstProps, _getVarProps, _jsxSorted, _jsxSplit, _qrlSync, _restProps, _wrapProp, componentQrl, createComputedQrl, createElement, eventQrl, getLocale, implicit$FirstArg, inlinedQrl, isBrowser, isDev, isServer, noSerialize, untrack, useContext, useContextProvider, useServerData, useSignal, useStore, useTaskQrl, useVisibleTaskQrl, withLocale } from "@qwik.dev/core";
|
|
4
|
-
import { _deserialize, _getContextContainer, _getContextHostElement, _hasStoreEffects, _regInlinedQrl, _requestPreload, _serialize, _waitUntilRendered, forceStoreEffects } from "@qwik.dev/core/internal";
|
|
4
|
+
import { _deserialize, _getContextContainer, _getContextHostElement, _getDomContainer, _hasStoreEffects, _regInlinedQrl, _requestPreload, _serialize, _waitOn, _waitUntilRendered, forceStoreEffects } from "@qwik.dev/core/internal";
|
|
5
5
|
import { Fragment } from "@qwik.dev/core/jsx-runtime";
|
|
6
6
|
import * as v from "valibot";
|
|
7
7
|
import * as z$1 from "zod";
|
|
@@ -57,8 +57,12 @@ var prefetchLoaderData = (loadedRoute, url, manifestHash) => {
|
|
|
57
57
|
}).catch(() => {});
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
var DEFAULT_HTTP_STATUS = Object.freeze({
|
|
61
|
+
status: 200,
|
|
62
|
+
message: "OK"
|
|
63
|
+
});
|
|
60
64
|
/** @public */
|
|
61
|
-
var useHttpStatus = () => useContext(HttpStatusContext).value;
|
|
65
|
+
var useHttpStatus = () => useContext(HttpStatusContext).value ?? DEFAULT_HTTP_STATUS;
|
|
62
66
|
/** @public */
|
|
63
67
|
var useContent = () => useContext(ContentContext);
|
|
64
68
|
/**
|
|
@@ -73,11 +77,10 @@ var useLocation = () => useContext(RouteLocationContext);
|
|
|
73
77
|
var useNavigate = () => useContext(RouteNavigateContext);
|
|
74
78
|
/** @internal Implementation of usePreventNavigate$ */
|
|
75
79
|
var usePreventNavigateQrl = (fn) => {
|
|
76
|
-
const registerPreventNav = useContext(RoutePreventNavigateContext);
|
|
77
80
|
useVisibleTaskQrl(/*#__PURE__*/ inlinedQrl(() => {
|
|
78
|
-
let fn = _capturesObj._[0]
|
|
81
|
+
let fn = _capturesObj._[0];
|
|
79
82
|
return registerPreventNav(fn);
|
|
80
|
-
}, "usePreventNavigateQrl_useVisibleTask_BsYUaz9XhUs", [fn
|
|
83
|
+
}, "usePreventNavigateQrl_useVisibleTask_BsYUaz9XhUs", [fn]));
|
|
81
84
|
};
|
|
82
85
|
/**
|
|
83
86
|
* Prevent navigation attempts. This hook registers a callback that will be called before SPA or
|
|
@@ -520,10 +523,48 @@ var startViewTransition = (params) => {
|
|
|
520
523
|
var QWIK_CITY_SCROLLER = "_qCityScroller";
|
|
521
524
|
/** @public */
|
|
522
525
|
var QWIK_ROUTER_SCROLLER = "_qRouterScroller";
|
|
523
|
-
var
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
526
|
+
var ensureRouteInternal = (routeInternal, routeLocation) => routeInternal.untrackedValue ||= {
|
|
527
|
+
type: "initial",
|
|
528
|
+
dest: routeLocation.url
|
|
529
|
+
};
|
|
530
|
+
var getRouterContainer = () => _getDomContainer(document.documentElement);
|
|
531
|
+
var getServerHttpStatus = (notFound, response) => {
|
|
532
|
+
if (notFound) return {
|
|
533
|
+
status: 404,
|
|
534
|
+
message: "Not Found"
|
|
535
|
+
};
|
|
536
|
+
const message = response.statusMessage ?? "OK";
|
|
537
|
+
return response.status === 200 && message === "OK" ? void 0 : {
|
|
538
|
+
status: response.status,
|
|
539
|
+
message
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
/** Resolves once the loaders still fetching have settled and the renders they trigger have flushed. */
|
|
543
|
+
var whenRouteLoadersSettled = async (loaderState, container) => {
|
|
544
|
+
const pending = [];
|
|
545
|
+
for (const id in loaderState) {
|
|
546
|
+
const signal = loaderState[id];
|
|
547
|
+
if (signal.untrackedPending) pending.push(signal.promise().catch(() => {}));
|
|
548
|
+
}
|
|
549
|
+
if (pending.length === 0) return;
|
|
550
|
+
await Promise.all(pending);
|
|
551
|
+
await _waitUntilRendered(container);
|
|
552
|
+
};
|
|
553
|
+
var whenReady = async (read) => {
|
|
554
|
+
for (;;) try {
|
|
555
|
+
return untrack(read);
|
|
556
|
+
} catch (error) {
|
|
557
|
+
if (!isPromise(error)) throw error;
|
|
558
|
+
await error.catch(() => {});
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
var assignDocumentHead = (documentHead, head) => {
|
|
562
|
+
documentHead.links = head.links;
|
|
563
|
+
documentHead.meta = head.meta;
|
|
564
|
+
documentHead.styles = head.styles;
|
|
565
|
+
documentHead.scripts = head.scripts;
|
|
566
|
+
documentHead.title = head.title;
|
|
567
|
+
documentHead.frontmatter = head.frontmatter;
|
|
527
568
|
};
|
|
528
569
|
var getScroller = () => {
|
|
529
570
|
let scroller = document.getElementById(QWIK_ROUTER_SCROLLER);
|
|
@@ -547,17 +588,19 @@ var useQwikRouter = (props) => {
|
|
|
547
588
|
if (!urlEnv) throw new Error(`Missing Qwik URL Env Data`);
|
|
548
589
|
const serverHead = useServerData("documentHead");
|
|
549
590
|
const manifestHash = useServerData("containerAttributes")?.["q:manifest-hash"];
|
|
550
|
-
const
|
|
591
|
+
const locale = getLocale("");
|
|
592
|
+
const viewTransition = props?.viewTransition;
|
|
551
593
|
const routeLocationTarget = {
|
|
552
|
-
url,
|
|
594
|
+
url: new URL(urlEnv),
|
|
553
595
|
params: env.params,
|
|
554
596
|
isNavigating: false,
|
|
555
597
|
prevUrl: void 0
|
|
556
598
|
};
|
|
557
599
|
const routeLocation = useStore(routeLocationTarget, { deep: false });
|
|
558
600
|
const navResolver = {};
|
|
559
|
-
const routeLoaderCtx =
|
|
601
|
+
const routeLoaderCtx = env.routeLoaderCtx;
|
|
560
602
|
routeLoaderCtx.manifestHash = manifestHash;
|
|
603
|
+
Object.assign(routeLoaderCtx.loaderPaths, env.loadedRoute.$loaderPaths$);
|
|
561
604
|
const loaderState = {};
|
|
562
605
|
const contentModulesForInit = env.loadedRoute.$mods$;
|
|
563
606
|
const loaders = ensureRouteLoaderSignals(contentModulesForInit, loaderState, routeLoaderCtx, env.ev);
|
|
@@ -565,25 +608,15 @@ var useQwikRouter = (props) => {
|
|
|
565
608
|
const value = env.loaderValues[loader.__id];
|
|
566
609
|
setLoaderSignalValue(loaderState[loader.__id], value);
|
|
567
610
|
}
|
|
568
|
-
const routeInternal = useSignal(
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
});
|
|
572
|
-
const documentHead = useStore(() => createDocumentHead(serverHead, manifestHash));
|
|
611
|
+
const routeInternal = useSignal();
|
|
612
|
+
const documentHead = useStore(() => createDocumentHead(serverHead, manifestHash), { deep: false });
|
|
613
|
+
const pageModule = contentModulesForInit[contentModulesForInit.length - 1];
|
|
573
614
|
const content = useStore({
|
|
574
|
-
headings:
|
|
575
|
-
menu:
|
|
576
|
-
});
|
|
577
|
-
const contentInternal = useSignal();
|
|
578
|
-
/**
|
|
579
|
-
* Non-serializable navigation context passed from the nav task to the navigation task. Only the
|
|
580
|
-
* data that can't be derived from existing stores/signals.
|
|
581
|
-
*/
|
|
582
|
-
const navContext = useSignal();
|
|
583
|
-
const httpStatus = useSignal({
|
|
584
|
-
status: env.response.status,
|
|
585
|
-
message: env.loadedRoute.$notFound$ ? "Not Found" : env.response.statusMessage ?? ""
|
|
615
|
+
headings: pageModule.headings,
|
|
616
|
+
menu: env.loadedRoute.$menu$
|
|
586
617
|
});
|
|
618
|
+
const contentInternal = useSignal(noSerialize(contentModulesForInit));
|
|
619
|
+
const httpStatus = useSignal(getServerHttpStatus(env.loadedRoute.$notFound$, env.response));
|
|
587
620
|
const currentActionId = env.response.action;
|
|
588
621
|
const currentAction = currentActionId ? env.response.actionResult : void 0;
|
|
589
622
|
const actionState = useSignal(currentAction ? {
|
|
@@ -594,34 +627,15 @@ var useQwikRouter = (props) => {
|
|
|
594
627
|
status: env.response.status
|
|
595
628
|
}
|
|
596
629
|
} : void 0);
|
|
597
|
-
const
|
|
630
|
+
const serverActionData = currentActionId || env.response.status !== 200 ? {
|
|
598
631
|
action: currentActionId,
|
|
599
632
|
actionResult: currentAction,
|
|
600
633
|
status: env.response.status
|
|
601
|
-
} : void 0
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (!preventNav.$cbs$) return;
|
|
607
|
-
if ([...preventNav.$cbs$.values()].map((cb) => cb.resolved ? cb.resolved() : cb()).some(Boolean)) {
|
|
608
|
-
event.preventDefault();
|
|
609
|
-
event.returnValue = true;
|
|
610
|
-
}
|
|
611
|
-
};
|
|
612
|
-
(preventNav.$cbs$ ||= /* @__PURE__ */ new Set()).add(fn$);
|
|
613
|
-
fn$.resolve();
|
|
614
|
-
window.addEventListener("beforeunload", preventNav.$handler$);
|
|
615
|
-
return () => {
|
|
616
|
-
if (preventNav.$cbs$) {
|
|
617
|
-
preventNav.$cbs$.delete(fn$);
|
|
618
|
-
if (!preventNav.$cbs$.size) {
|
|
619
|
-
preventNav.$cbs$ = void 0;
|
|
620
|
-
window.removeEventListener("beforeunload", preventNav.$handler$);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
|
-
}, "useQwikRouter_registerPreventNav_69B0DK0eZJc");
|
|
634
|
+
} : void 0;
|
|
635
|
+
const actionDataSignal = useSignal(serverActionData);
|
|
636
|
+
_waitOn(whenReady(() => {
|
|
637
|
+
for (const loader of loaders) if (!isImmutableLoader(loader.__id)) loaderState[loader.__id].untrackedPending;
|
|
638
|
+
}).then(() => whenReady(() => resolveHead(serverActionData, loaderState, routeLocation, contentModulesForInit, locale, serverHead))).then((head) => assignDocumentHead(documentHead, head)));
|
|
625
639
|
/**
|
|
626
640
|
* This is the `nav()` function that `useNavigation()` returns. It is also used internally for SPA
|
|
627
641
|
* navigations and is provided in context for use in loaders and actions.
|
|
@@ -630,132 +644,113 @@ var useQwikRouter = (props) => {
|
|
|
630
644
|
* treat it as a user-initiated navigation and allow scroll restoration to work. For this reason,
|
|
631
645
|
* make sure to change the address bar before awaiting anything.
|
|
632
646
|
*/
|
|
633
|
-
const goto = /*#__PURE__*/ inlinedQrl(
|
|
634
|
-
let
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
routeLocation.url = url;
|
|
640
|
-
}
|
|
641
|
-
const lastDest = routeInternal.value.dest;
|
|
642
|
-
const dest = path === void 0 ? lastDest : typeof path === "number" ? path : toUrl(path, routeLocation.url);
|
|
643
|
-
if (navResolver.p && !forceReload && typeof dest !== "number" && isSamePath(dest, lastDest) && dest.href === lastDest.href) return navResolver.p;
|
|
644
|
-
const attemptCount = ++internalState.attemptCount;
|
|
645
|
-
if (preventNav.$cbs$ && (forceReload || typeof dest === "number" || !isSamePath(dest, lastDest) || !isSameOrigin(dest, lastDest))) {
|
|
646
|
-
const prevents = await Promise.all([...preventNav.$cbs$.values()].map((cb) => cb(dest)));
|
|
647
|
-
if (attemptCount !== internalState.attemptCount || prevents.some(Boolean)) {
|
|
648
|
-
if (attemptCount === internalState.attemptCount && type === "popstate") history.pushState(null, "", lastDest);
|
|
647
|
+
const goto = /*#__PURE__*/ inlinedQrl((path, opt) => {
|
|
648
|
+
let actionDataSignal = _capturesObj._[0], actionState = _capturesObj._[1], content = _capturesObj._[2], contentInternal = _capturesObj._[3], documentHead = _capturesObj._[4], httpStatus = _capturesObj._[5], loaderState = _capturesObj._[6], locale = _capturesObj._[7], manifestHash = _capturesObj._[8], navResolver = _capturesObj._[9], routeInternal = _capturesObj._[10], routeLoaderCtx = _capturesObj._[11], routeLocation = _capturesObj._[12], routeLocationTarget = _capturesObj._[13], serverHead = _capturesObj._[14], viewTransition = _capturesObj._[15];
|
|
649
|
+
const startNavigation = async (path, opt) => {
|
|
650
|
+
if (path === REFRESH_HEAD) {
|
|
651
|
+
const contentModules = contentInternal.untrackedValue;
|
|
652
|
+
if (contentModules) updateHead(contentModules, actionDataSignal.untrackedValue, internalState.navCount);
|
|
649
653
|
return;
|
|
650
654
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
if (
|
|
662
|
-
|
|
655
|
+
if (path === RUN_PENDING_ACTION) return loadNavigation(ensureRouteInternal(routeInternal, routeLocation), actionState.value, getRouterContainer());
|
|
656
|
+
const { type = "link", forceReload = path === void 0, replaceState = false, scroll = true } = typeof opt === "object" ? opt : { forceReload: opt };
|
|
657
|
+
const current = ensureRouteInternal(routeInternal, routeLocation);
|
|
658
|
+
if (isBrowser && type === "link" && current.type === "initial") {
|
|
659
|
+
const url = new URL(window.location.href);
|
|
660
|
+
current.dest = url;
|
|
661
|
+
routeLocation.url = url;
|
|
662
|
+
}
|
|
663
|
+
const lastDest = current.dest;
|
|
664
|
+
const dest = path === void 0 ? lastDest : typeof path === "number" ? path : toUrl(path, routeLocation.url);
|
|
665
|
+
if (navResolver.p && !forceReload && typeof dest !== "number" && isSamePath(dest, lastDest) && dest.href === lastDest.href) return navResolver.p;
|
|
666
|
+
const attemptCount = ++internalState.attemptCount;
|
|
667
|
+
if (preventNav.$cbs$ && (forceReload || typeof dest === "number" || !isSamePath(dest, lastDest) || !isSameOrigin(dest, lastDest))) {
|
|
668
|
+
const prevents = await Promise.all([...preventNav.$cbs$.values()].map((cb) => cb(dest)));
|
|
669
|
+
if (attemptCount !== internalState.attemptCount || prevents.some(Boolean)) {
|
|
670
|
+
if (attemptCount === internalState.attemptCount && type === "popstate") history.pushState(null, "", lastDest);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (typeof dest === "number") {
|
|
675
|
+
if (isBrowser) history.go(dest);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
if (!isSameOrigin(dest, lastDest)) {
|
|
679
|
+
if (isBrowser) location.href = dest.href;
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
if (!forceReload && isSamePath(dest, lastDest)) {
|
|
683
|
+
if (isBrowser) {
|
|
684
|
+
if (type === "link" && dest.href !== location.href) history.pushState(null, "", dest);
|
|
685
|
+
const scroller = getScroller();
|
|
686
|
+
restoreScroll(type, dest, new URL(location.href), scroller, getScrollHistory());
|
|
687
|
+
if (type === "popstate") window._qRouterScrollEnabled = true;
|
|
688
|
+
}
|
|
689
|
+
if (dest.href !== routeLocation.url.href) {
|
|
690
|
+
const newUrl = new URL(dest.href);
|
|
691
|
+
ensureRouteInternal(routeInternal, routeLocation).dest = newUrl;
|
|
692
|
+
routeLocation.url = newUrl;
|
|
693
|
+
const contentModules = contentInternal.untrackedValue;
|
|
694
|
+
if (contentModules) updateHead(contentModules, actionDataSignal.untrackedValue, internalState.navCount);
|
|
695
|
+
}
|
|
696
|
+
return navResolver.p;
|
|
697
|
+
}
|
|
698
|
+
const navCount = ++internalState.navCount;
|
|
699
|
+
internalState.currentTransition?.skipTransition();
|
|
700
|
+
navResolver.cancel?.();
|
|
701
|
+
navResolver.cancel = void 0;
|
|
702
|
+
navResolver.r?.();
|
|
703
|
+
let historyUpdated = false;
|
|
704
|
+
if (isBrowser) getClientRouteLoaders(routeLoaderCtx, routeLocation.url.href);
|
|
705
|
+
if (isBrowser && type === "link" && !forceReload) {
|
|
663
706
|
const scroller = getScroller();
|
|
664
|
-
|
|
665
|
-
|
|
707
|
+
window._qRouterScrollEnabled = false;
|
|
708
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
709
|
+
saveScrollHistory(currentScrollState(scroller));
|
|
710
|
+
clientNavigate(window, type, new URL(location.href), dest, replaceState);
|
|
711
|
+
historyUpdated = true;
|
|
666
712
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
713
|
+
const wasNavigating = routeLocation.isNavigating;
|
|
714
|
+
routeLocation.isNavigating = true;
|
|
715
|
+
const container = isBrowser ? _getContextContainer() : void 0;
|
|
716
|
+
if (container && !wasNavigating) {
|
|
717
|
+
await _waitUntilRendered(container);
|
|
718
|
+
if (navCount !== internalState.navCount) return;
|
|
671
719
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
if (isBrowser) getClientRouteLoaders(routeLoaderCtx, routeLocation.url.href);
|
|
681
|
-
if (isBrowser && type === "link" && !forceReload) {
|
|
682
|
-
const scroller = getScroller();
|
|
683
|
-
window._qRouterScrollEnabled = false;
|
|
684
|
-
clearTimeout(window._qRouterScrollDebounce);
|
|
685
|
-
saveScrollHistory(currentScrollState(scroller));
|
|
686
|
-
clientNavigate(window, type, new URL(location.href), dest, replaceState);
|
|
687
|
-
historyUpdated = true;
|
|
688
|
-
}
|
|
689
|
-
const wasNavigating = routeLocation.isNavigating;
|
|
690
|
-
routeLocation.isNavigating = true;
|
|
691
|
-
const container = isBrowser ? _getContextContainer() : void 0;
|
|
692
|
-
if (container && !wasNavigating) {
|
|
693
|
-
await _waitUntilRendered(container);
|
|
694
|
-
if (navCount !== internalState.navCount) return;
|
|
695
|
-
}
|
|
696
|
-
actionState.value = void 0;
|
|
697
|
-
routeInternal.value = {
|
|
698
|
-
type,
|
|
699
|
-
dest,
|
|
700
|
-
forceReload,
|
|
701
|
-
replaceState,
|
|
702
|
-
scroll,
|
|
703
|
-
historyUpdated
|
|
704
|
-
};
|
|
705
|
-
if (wasNavigating) abortRouteLoaderNavigation(routeLoaderCtx);
|
|
706
|
-
if (isBrowser) prefetchRoute(dest, false, .8, manifestHash, true);
|
|
707
|
-
navResolver.p = new Promise((resolve) => {
|
|
708
|
-
navResolver.r = () => {
|
|
709
|
-
navResolver.r = void 0;
|
|
710
|
-
navResolver.p = void 0;
|
|
711
|
-
resolve();
|
|
720
|
+
actionState.value = void 0;
|
|
721
|
+
const navigation = {
|
|
722
|
+
type,
|
|
723
|
+
dest,
|
|
724
|
+
forceReload,
|
|
725
|
+
replaceState,
|
|
726
|
+
scroll,
|
|
727
|
+
historyUpdated
|
|
712
728
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
let actionDataSignal = _capturesObj._[0], actionState = _capturesObj._[1], content = _capturesObj._[2], contentInternal = _capturesObj._[3], env = _capturesObj._[4], goto = _capturesObj._[5], httpStatus = _capturesObj._[6], loaderState = _capturesObj._[7], navContext = _capturesObj._[8], navResolver = _capturesObj._[9], routeInternal = _capturesObj._[10], routeLoaderCtx = _capturesObj._[11], routeLocation = _capturesObj._[12], routeLocationTarget = _capturesObj._[13];
|
|
739
|
-
const navigation = track(routeInternal);
|
|
740
|
-
const action = track(actionState);
|
|
741
|
-
action?.resolveDispatch?.();
|
|
742
|
-
if (action) action.resolveDispatch = void 0;
|
|
743
|
-
const prevUrl = routeLocation.url;
|
|
744
|
-
const navType = action ? "form" : navigation.type;
|
|
745
|
-
const replaceState = navigation.replaceState;
|
|
746
|
-
const navCountBefore = internalState.navCount;
|
|
747
|
-
let trackUrl;
|
|
748
|
-
let endpointResponse;
|
|
749
|
-
let actionData;
|
|
750
|
-
let actionLoaderHashes;
|
|
751
|
-
let loadedRoute;
|
|
752
|
-
if (isServer) {
|
|
753
|
-
trackUrl = new URL(navigation.dest, routeLocation.url);
|
|
754
|
-
loadedRoute = env.loadedRoute;
|
|
755
|
-
endpointResponse = env.response;
|
|
756
|
-
actionData = endpointResponse;
|
|
757
|
-
} else {
|
|
758
|
-
trackUrl = new URL(navigation.dest, location);
|
|
729
|
+
routeInternal.value = navigation;
|
|
730
|
+
if (wasNavigating) abortRouteLoaderNavigation(routeLoaderCtx);
|
|
731
|
+
if (isBrowser) prefetchRoute(dest, false, .8, manifestHash, true);
|
|
732
|
+
navResolver.p = new Promise((resolve) => {
|
|
733
|
+
navResolver.r = () => {
|
|
734
|
+
navResolver.r = void 0;
|
|
735
|
+
navResolver.p = void 0;
|
|
736
|
+
resolve();
|
|
737
|
+
};
|
|
738
|
+
});
|
|
739
|
+
const navigated = navResolver.p;
|
|
740
|
+
loadNavigation(navigation, void 0, container ?? getRouterContainer());
|
|
741
|
+
return navigated;
|
|
742
|
+
};
|
|
743
|
+
const loadNavigation = async (navigation, action, container) => {
|
|
744
|
+
action?.resolveDispatch?.();
|
|
745
|
+
if (action) action.resolveDispatch = void 0;
|
|
746
|
+
const prevUrl = routeLocation.url;
|
|
747
|
+
const navType = action ? "form" : navigation.type;
|
|
748
|
+
const replaceState = navigation.replaceState;
|
|
749
|
+
const navCountBefore = internalState.navCount;
|
|
750
|
+
let actionData;
|
|
751
|
+
let actionLoaderHashes;
|
|
752
|
+
let loadedRoute;
|
|
753
|
+
const trackUrl = new URL(navigation.dest, location);
|
|
759
754
|
const canceled = new Promise((resolve) => {
|
|
760
755
|
navResolver.cancel = () => resolve(void 0);
|
|
761
756
|
});
|
|
@@ -801,7 +796,7 @@ var useQwikRouter = (props) => {
|
|
|
801
796
|
}
|
|
802
797
|
if (result.redirect) {
|
|
803
798
|
if (result.redirect instanceof URL) location.href = result.redirect.href;
|
|
804
|
-
else
|
|
799
|
+
else startNavigation(result.redirect, { replaceState: true });
|
|
805
800
|
return;
|
|
806
801
|
}
|
|
807
802
|
actionData = {
|
|
@@ -812,210 +807,187 @@ var useQwikRouter = (props) => {
|
|
|
812
807
|
actionLoaderHashes = result.loaderHashes;
|
|
813
808
|
}
|
|
814
809
|
navResolver.cancel = void 0;
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
if (
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
810
|
+
const { $routeName$, $params$, $mods$, $menu$, $notFound$ } = loadedRoute;
|
|
811
|
+
const contentModules = $mods$;
|
|
812
|
+
routeLoaderCtx.goto = noSerialize(startNavigation);
|
|
813
|
+
const routeLoaders = prepareRouteLoaders(contentModules, loaderState, routeLoaderCtx, loadedRoute.$loaderPaths$, trackUrl, prevUrl, navCountBefore, action ? actionLoaderHashes ?? null : void 0, action ?? navigation);
|
|
814
|
+
await whenReady(() => {
|
|
815
|
+
for (let i = 0; i < routeLoaders.length; i++) {
|
|
816
|
+
const loader = routeLoaders[i];
|
|
817
|
+
if (!isImmutableLoader(loader.__id)) loaderState[loader.__id].untrackedPending;
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
clearNavFetchCache();
|
|
821
|
+
if (internalState.navCount !== navCountBefore) return;
|
|
822
|
+
if ($notFound$) httpStatus.value = {
|
|
823
|
+
status: 404,
|
|
824
|
+
message: "Not Found"
|
|
825
|
+
};
|
|
826
|
+
else if (actionData) httpStatus.value = {
|
|
827
|
+
status: actionData.status,
|
|
828
|
+
message: "OK"
|
|
829
|
+
};
|
|
830
|
+
else httpStatus.value = {
|
|
831
|
+
status: 200,
|
|
832
|
+
message: "OK"
|
|
833
|
+
};
|
|
834
|
+
const pageModule = contentModules[contentModules.length - 1];
|
|
835
|
+
if (isSamePath(trackUrl, navigation.dest)) trackUrl.hash = navigation.dest.hash;
|
|
836
|
+
if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) trackUrl.search = navigation.dest.search;
|
|
837
|
+
let shouldForcePrevUrl = false;
|
|
838
|
+
let shouldForceUrl = false;
|
|
839
|
+
let shouldForceParams = false;
|
|
840
|
+
if (!isSamePath(trackUrl, prevUrl)) {
|
|
841
|
+
if (_hasStoreEffects(routeLocation, "prevUrl")) shouldForcePrevUrl = true;
|
|
842
|
+
routeLocationTarget.prevUrl = prevUrl;
|
|
843
|
+
}
|
|
844
|
+
if (routeLocationTarget.url !== trackUrl) {
|
|
845
|
+
if (_hasStoreEffects(routeLocation, "url")) shouldForceUrl = true;
|
|
846
|
+
routeLocationTarget.url = trackUrl;
|
|
847
|
+
}
|
|
848
|
+
if (routeLocationTarget.params !== $params$) {
|
|
849
|
+
if (_hasStoreEffects(routeLocation, "params")) shouldForceParams = true;
|
|
850
|
+
routeLocationTarget.params = $params$;
|
|
851
|
+
}
|
|
852
|
+
const nextRouteInternal = {
|
|
853
|
+
type: navType,
|
|
854
|
+
dest: trackUrl
|
|
855
|
+
};
|
|
856
|
+
if (navigation.forceReload !== void 0) nextRouteInternal.forceReload = navigation.forceReload;
|
|
857
|
+
if (navigation.replaceState !== void 0) nextRouteInternal.replaceState = navigation.replaceState;
|
|
858
|
+
if (navigation.scroll !== void 0) nextRouteInternal.scroll = navigation.scroll;
|
|
859
|
+
if (navigation.historyUpdated !== void 0) nextRouteInternal.historyUpdated = navigation.historyUpdated;
|
|
860
|
+
routeInternal.untrackedValue = nextRouteInternal;
|
|
861
|
+
content.headings = pageModule.headings;
|
|
862
|
+
content.menu = $menu$;
|
|
863
|
+
contentInternal.untrackedValue = noSerialize(contentModules);
|
|
864
|
+
actionDataSignal.untrackedValue = actionData;
|
|
865
|
+
commitNavigation({
|
|
866
|
+
routeName: $routeName$,
|
|
867
|
+
navType,
|
|
868
|
+
prevUrl,
|
|
869
|
+
replaceState,
|
|
870
|
+
shouldForcePrevUrl,
|
|
871
|
+
shouldForceUrl,
|
|
872
|
+
shouldForceParams,
|
|
873
|
+
navCount: navCountBefore,
|
|
874
|
+
contentModules,
|
|
875
|
+
actionData
|
|
876
|
+
}, nextRouteInternal, container);
|
|
841
877
|
};
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
878
|
+
const updateHead = (contentModules, actionData, navCount) => {
|
|
879
|
+
let head;
|
|
880
|
+
try {
|
|
881
|
+
head = resolveHead(actionData, loaderState, routeLocation, contentModules, locale, serverHead);
|
|
882
|
+
} catch (error) {
|
|
883
|
+
if (isPromise(error)) {
|
|
884
|
+
const retry = () => {
|
|
885
|
+
if (navCount === internalState.navCount) return updateHead(contentModules, actionData, navCount);
|
|
886
|
+
};
|
|
887
|
+
return error.then(retry, retry);
|
|
888
|
+
}
|
|
889
|
+
console.error(error);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
assignDocumentHead(documentHead, head);
|
|
845
893
|
};
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if (
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
894
|
+
const commitNavigation = (nav, navigation, container) => {
|
|
895
|
+
if (nav.navCount !== internalState.navCount) return;
|
|
896
|
+
const { navType, prevUrl, replaceState, routeName } = nav;
|
|
897
|
+
const trackUrl = routeLocation.url;
|
|
898
|
+
const scroller = getScroller();
|
|
899
|
+
let scrollState;
|
|
900
|
+
if (navType === "popstate") scrollState = getScrollHistory();
|
|
901
|
+
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
902
|
+
initializeSPA(startNavigation, scroller);
|
|
903
|
+
if (navType !== "popstate") {
|
|
904
|
+
window._qRouterScrollEnabled = false;
|
|
905
|
+
clearTimeout(window._qRouterScrollDebounce);
|
|
906
|
+
if (!navigation.historyUpdated) saveScrollHistory(currentScrollState(scroller));
|
|
907
|
+
}
|
|
908
|
+
let didNavigate = false;
|
|
909
|
+
let navigatePromise;
|
|
910
|
+
let currentTransition;
|
|
911
|
+
const navigate = () => {
|
|
912
|
+
if (navigatePromise) return navigatePromise;
|
|
913
|
+
if (nav.navCount !== internalState.navCount) return Promise.resolve();
|
|
914
|
+
didNavigate = true;
|
|
915
|
+
if (navigation.historyUpdated) {
|
|
916
|
+
const currentPath = location.pathname + location.search + location.hash;
|
|
917
|
+
const nextPath = toPath(trackUrl);
|
|
918
|
+
if (currentPath !== nextPath) history.replaceState(history.state, "", nextPath);
|
|
919
|
+
} else clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
|
|
920
|
+
const headUpdated = updateHead(nav.contentModules, nav.actionData, nav.navCount);
|
|
921
|
+
contentInternal.trigger();
|
|
922
|
+
return navigatePromise = Promise.all([_waitUntilRendered(container), headUpdated]).then(() => {
|
|
923
|
+
if (nav.navCount === internalState.navCount) commitRouteLoaders(loaderState, routeLoaderCtx, nav.navCount);
|
|
924
|
+
}, (error) => {
|
|
925
|
+
if (nav.navCount === internalState.navCount) restoreRouteLoaders(loaderState, routeLoaderCtx, nav.navCount);
|
|
926
|
+
throw error;
|
|
927
|
+
});
|
|
928
|
+
};
|
|
929
|
+
const _waitNextPage = () => {
|
|
930
|
+
if (!shouldStartViewTransition(viewTransition)) return navigate().then(() => void 0);
|
|
931
|
+
const { ready, transition } = startViewTransition({
|
|
932
|
+
update: navigate,
|
|
933
|
+
types: ["qwik-navigation"]
|
|
934
|
+
});
|
|
935
|
+
currentTransition = transition;
|
|
936
|
+
internalState.currentTransition = transition;
|
|
937
|
+
return ready.then(() => transition, (reason) => {
|
|
938
|
+
if (!didNavigate && nav.navCount === internalState.navCount) return navigate().then(() => transition);
|
|
939
|
+
if (reason?.name === "AbortError") return transition;
|
|
940
|
+
throw reason;
|
|
941
|
+
});
|
|
942
|
+
};
|
|
943
|
+
_waitNextPage().finally(() => {
|
|
944
|
+
if (currentTransition && internalState.currentTransition === currentTransition) internalState.currentTransition = void 0;
|
|
945
|
+
if (nav.navCount !== internalState.navCount) return;
|
|
946
|
+
container.element.setAttribute?.(Q_ROUTE, routeName);
|
|
947
|
+
saveScrollHistory(currentScrollState(scroller));
|
|
948
|
+
window._qRouterScrollEnabled = true;
|
|
949
|
+
callRestoreScrollOnDocument();
|
|
950
|
+
refreshLinkPrefetchObserver(manifestHash);
|
|
951
|
+
if (nav.shouldForcePrevUrl) forceStoreEffects(routeLocation, "prevUrl");
|
|
952
|
+
if (nav.shouldForceUrl) forceStoreEffects(routeLocation, "url");
|
|
953
|
+
if (nav.shouldForceParams) forceStoreEffects(routeLocation, "params");
|
|
954
|
+
whenRouteLoadersSettled(loaderState, container).then(() => {
|
|
955
|
+
if (nav.navCount !== internalState.navCount) return;
|
|
956
|
+
routeLocation.isNavigating = false;
|
|
957
|
+
navResolver.r?.();
|
|
958
|
+
});
|
|
959
|
+
});
|
|
867
960
|
};
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
if (navigation.scroll !== void 0) nextRouteInternal.scroll = navigation.scroll;
|
|
871
|
-
if (navigation.historyUpdated !== void 0) nextRouteInternal.historyUpdated = navigation.historyUpdated;
|
|
872
|
-
routeInternal.untrackedValue = nextRouteInternal;
|
|
873
|
-
content.headings = pageModule.headings;
|
|
874
|
-
content.menu = $menu$;
|
|
875
|
-
contentInternal.untrackedValue = noSerialize(contentModules);
|
|
876
|
-
actionDataSignal.value = actionData;
|
|
877
|
-
navContext.value = noSerialize({
|
|
878
|
-
routeName: $routeName$,
|
|
879
|
-
navType,
|
|
880
|
-
prevUrl,
|
|
881
|
-
replaceState,
|
|
882
|
-
shouldForcePrevUrl,
|
|
883
|
-
shouldForceUrl,
|
|
884
|
-
shouldForceParams,
|
|
885
|
-
navCount: navCountBefore
|
|
886
|
-
});
|
|
887
|
-
}, "useQwikRouter_useTask_XpalYii770E", [
|
|
961
|
+
return startNavigation(path, opt);
|
|
962
|
+
}, "useQwikRouter_goto_8j8Vrz2yUIM", [
|
|
888
963
|
actionDataSignal,
|
|
889
964
|
actionState,
|
|
890
965
|
content,
|
|
891
966
|
contentInternal,
|
|
892
|
-
env,
|
|
893
|
-
goto,
|
|
894
|
-
httpStatus,
|
|
895
|
-
loaderState,
|
|
896
|
-
navContext,
|
|
897
|
-
navResolver,
|
|
898
|
-
routeInternal,
|
|
899
|
-
routeLoaderCtx,
|
|
900
|
-
routeLocation,
|
|
901
|
-
routeLocationTarget
|
|
902
|
-
]), { deferUpdates: isServer });
|
|
903
|
-
/**
|
|
904
|
-
* Calc head. This is in a separate task so that loader updates can trigger head recalculation
|
|
905
|
-
* without re-running the navigation logic.
|
|
906
|
-
*
|
|
907
|
-
* Note that on the server these tasks run sequentially.
|
|
908
|
-
*/
|
|
909
|
-
useTaskQrl(/*#__PURE__*/ inlinedQrl(({ track }) => {
|
|
910
|
-
let actionDataSignal = _capturesObj._[0], contentInternal = _capturesObj._[1], documentHead = _capturesObj._[2], loaderState = _capturesObj._[3], navContext = _capturesObj._[4], routeLocation = _capturesObj._[5], serverHead = _capturesObj._[6];
|
|
911
|
-
const contentModules = track(contentInternal);
|
|
912
|
-
const nav = navContext.untrackedValue;
|
|
913
|
-
if (!isServer && routeLocation.isNavigating && nav && nav.navCount !== internalState.navCount) return;
|
|
914
|
-
if (!contentModules) return;
|
|
915
|
-
const actionData = track(actionDataSignal);
|
|
916
|
-
let head;
|
|
917
|
-
try {
|
|
918
|
-
head = track(() => resolveHead(actionData, loaderState, routeLocation, contentModules, getLocale(""), serverHead));
|
|
919
|
-
} catch (error) {
|
|
920
|
-
if (isServer || isPromise(error)) throw error;
|
|
921
|
-
console.error(error);
|
|
922
|
-
return;
|
|
923
|
-
}
|
|
924
|
-
documentHead.links = head.links;
|
|
925
|
-
documentHead.meta = head.meta;
|
|
926
|
-
documentHead.styles = head.styles;
|
|
927
|
-
documentHead.scripts = head.scripts;
|
|
928
|
-
documentHead.title = head.title;
|
|
929
|
-
documentHead.frontmatter = head.frontmatter;
|
|
930
|
-
}, "useQwikRouter_useTask_1_1sKEZ9Pg1ow", [
|
|
931
|
-
actionDataSignal,
|
|
932
|
-
contentInternal,
|
|
933
967
|
documentHead,
|
|
968
|
+
httpStatus,
|
|
934
969
|
loaderState,
|
|
935
|
-
|
|
936
|
-
routeLocation,
|
|
937
|
-
serverHead
|
|
938
|
-
]), { deferUpdates: isServer });
|
|
939
|
-
/** Actual navigation */
|
|
940
|
-
useTaskQrl(/*#__PURE__*/ inlinedQrl(({ track }) => {
|
|
941
|
-
let contentInternal = _capturesObj._[0], goto = _capturesObj._[1], loaderState = _capturesObj._[2], manifestHash = _capturesObj._[3], navContext = _capturesObj._[4], navResolver = _capturesObj._[5], props = _capturesObj._[6], routeInternal = _capturesObj._[7], routeLoaderCtx = _capturesObj._[8], routeLocation = _capturesObj._[9];
|
|
942
|
-
const nav = track(navContext);
|
|
943
|
-
if (isServer || !nav) return;
|
|
944
|
-
if (nav.navCount !== internalState.navCount) return;
|
|
945
|
-
const container = _getContextContainer();
|
|
946
|
-
const navigation = routeInternal.untrackedValue;
|
|
947
|
-
const { navType, prevUrl, replaceState, routeName } = nav;
|
|
948
|
-
const trackUrl = routeLocation.url;
|
|
949
|
-
const scroller = getScroller();
|
|
950
|
-
let scrollState;
|
|
951
|
-
if (navType === "popstate") scrollState = getScrollHistory();
|
|
952
|
-
if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
|
|
953
|
-
initializeSPA(goto, scroller);
|
|
954
|
-
if (navType !== "popstate") {
|
|
955
|
-
window._qRouterScrollEnabled = false;
|
|
956
|
-
clearTimeout(window._qRouterScrollDebounce);
|
|
957
|
-
if (!navigation.historyUpdated) saveScrollHistory(currentScrollState(scroller));
|
|
958
|
-
}
|
|
959
|
-
let didNavigate = false;
|
|
960
|
-
let navigatePromise;
|
|
961
|
-
let currentTransition;
|
|
962
|
-
const navigate = () => {
|
|
963
|
-
if (navigatePromise) return navigatePromise;
|
|
964
|
-
if (nav.navCount !== internalState.navCount) return Promise.resolve();
|
|
965
|
-
didNavigate = true;
|
|
966
|
-
if (navigation.historyUpdated) {
|
|
967
|
-
const currentPath = location.pathname + location.search + location.hash;
|
|
968
|
-
const nextPath = toPath(trackUrl);
|
|
969
|
-
if (currentPath !== nextPath) history.replaceState(history.state, "", nextPath);
|
|
970
|
-
} else clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
|
|
971
|
-
contentInternal.trigger();
|
|
972
|
-
return navigatePromise = _waitUntilRendered(container).then(() => {
|
|
973
|
-
if (nav.navCount === internalState.navCount) commitRouteLoaders(loaderState, routeLoaderCtx, nav.navCount);
|
|
974
|
-
}, (error) => {
|
|
975
|
-
if (nav.navCount === internalState.navCount) restoreRouteLoaders(loaderState, routeLoaderCtx, nav.navCount);
|
|
976
|
-
throw error;
|
|
977
|
-
});
|
|
978
|
-
};
|
|
979
|
-
const _waitNextPage = () => {
|
|
980
|
-
if (!shouldStartViewTransition(props?.viewTransition)) return navigate().then(() => void 0);
|
|
981
|
-
const { ready, transition } = startViewTransition({
|
|
982
|
-
update: navigate,
|
|
983
|
-
types: ["qwik-navigation"]
|
|
984
|
-
});
|
|
985
|
-
currentTransition = transition;
|
|
986
|
-
internalState.currentTransition = transition;
|
|
987
|
-
return ready.then(() => transition, (reason) => {
|
|
988
|
-
if (!didNavigate && nav.navCount === internalState.navCount) return navigate().then(() => transition);
|
|
989
|
-
if (reason?.name === "AbortError") return transition;
|
|
990
|
-
throw reason;
|
|
991
|
-
});
|
|
992
|
-
};
|
|
993
|
-
_waitNextPage().finally(() => {
|
|
994
|
-
if (currentTransition && internalState.currentTransition === currentTransition) internalState.currentTransition = void 0;
|
|
995
|
-
if (nav.navCount !== internalState.navCount) return;
|
|
996
|
-
container.element.setAttribute?.(Q_ROUTE, routeName);
|
|
997
|
-
saveScrollHistory(currentScrollState(scroller));
|
|
998
|
-
window._qRouterScrollEnabled = true;
|
|
999
|
-
callRestoreScrollOnDocument();
|
|
1000
|
-
refreshLinkPrefetchObserver(manifestHash);
|
|
1001
|
-
if (nav.shouldForcePrevUrl) forceStoreEffects(routeLocation, "prevUrl");
|
|
1002
|
-
if (nav.shouldForceUrl) forceStoreEffects(routeLocation, "url");
|
|
1003
|
-
if (nav.shouldForceParams) forceStoreEffects(routeLocation, "params");
|
|
1004
|
-
routeLocation.isNavigating = false;
|
|
1005
|
-
navResolver.r?.();
|
|
1006
|
-
});
|
|
1007
|
-
}, "useQwikRouter_useTask_2_yw17chooOac", [
|
|
1008
|
-
contentInternal,
|
|
1009
|
-
goto,
|
|
1010
|
-
loaderState,
|
|
970
|
+
locale,
|
|
1011
971
|
manifestHash,
|
|
1012
|
-
navContext,
|
|
1013
972
|
navResolver,
|
|
1014
|
-
props,
|
|
1015
973
|
routeInternal,
|
|
1016
974
|
routeLoaderCtx,
|
|
1017
|
-
routeLocation
|
|
1018
|
-
|
|
975
|
+
routeLocation,
|
|
976
|
+
routeLocationTarget,
|
|
977
|
+
serverHead,
|
|
978
|
+
viewTransition
|
|
979
|
+
]);
|
|
980
|
+
routeLoaderCtx.onValue = goto;
|
|
981
|
+
useContextProvider(ContentContext, content);
|
|
982
|
+
useContextProvider(ContentInternalContext, contentInternal);
|
|
983
|
+
useContextProvider(DocumentHeadContext, documentHead);
|
|
984
|
+
useContextProvider(HttpStatusContext, httpStatus);
|
|
985
|
+
useContextProvider(RouteLocationContext, routeLocation);
|
|
986
|
+
useContextProvider(RouteNavigateContext, goto);
|
|
987
|
+
useContextProvider(RouteActionRunnerContext, goto);
|
|
988
|
+
useContextProvider(RouteStateContext, loaderState);
|
|
989
|
+
useContextProvider(RouteLoaderCtxContext, routeLoaderCtx);
|
|
990
|
+
useContextProvider(RouteActionContext, actionState);
|
|
1019
991
|
};
|
|
1020
992
|
/** @public This is a wrapper around the `useQwikRouter()` hook. We recommend using the hook instead of this component, unless you have a good reason to make your root component reactive. */
|
|
1021
993
|
function initializeSPA(goto, scroller) {
|
|
@@ -1220,6 +1192,7 @@ function routeActionQrl(actionQrl, ...rest) {
|
|
|
1220
1192
|
function action() {
|
|
1221
1193
|
const loc = useLocation();
|
|
1222
1194
|
const currentAction = useAction();
|
|
1195
|
+
const runAction = useContext(RouteActionRunnerContext, null);
|
|
1223
1196
|
const initialState = {
|
|
1224
1197
|
actionPath: `?${QACTION_KEY}=${id}`,
|
|
1225
1198
|
submitted: false,
|
|
@@ -1242,7 +1215,7 @@ function routeActionQrl(actionQrl, ...rest) {
|
|
|
1242
1215
|
return initialState;
|
|
1243
1216
|
});
|
|
1244
1217
|
initialState.submit = /* @__PURE__ */ inlinedQrl((input = {}) => {
|
|
1245
|
-
let currentAction = _capturesObj._[0], id = _capturesObj._[1], latestSubmission = _capturesObj._[2], loc = _capturesObj._[3],
|
|
1218
|
+
let currentAction = _capturesObj._[0], id = _capturesObj._[1], latestSubmission = _capturesObj._[2], loc = _capturesObj._[3], runAction = _capturesObj._[4], state = _capturesObj._[5];
|
|
1246
1219
|
if (isServer) throw new Error(`Actions can not be invoked within the server during SSR.
|
|
1247
1220
|
Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
|
|
1248
1221
|
let data;
|
|
@@ -1272,6 +1245,7 @@ Action.run() can only be called on the browser, for example when a user clicks a
|
|
|
1272
1245
|
resolve: noSerialize(resolve),
|
|
1273
1246
|
resolveDispatch: noSerialize(resolveDispatch)
|
|
1274
1247
|
};
|
|
1248
|
+
runAction?.(RUN_PENDING_ACTION);
|
|
1275
1249
|
})).then(({ result, status }) => {
|
|
1276
1250
|
const isLatestSubmission = latestSubmission.current === submission;
|
|
1277
1251
|
if (isLatestSubmission) {
|
|
@@ -1302,6 +1276,7 @@ Action.run() can only be called on the browser, for example when a user clicks a
|
|
|
1302
1276
|
id,
|
|
1303
1277
|
{ current: void 0 },
|
|
1304
1278
|
loc,
|
|
1279
|
+
runAction,
|
|
1305
1280
|
state
|
|
1306
1281
|
]);
|
|
1307
1282
|
return state;
|
|
@@ -1729,6 +1704,10 @@ var createRenderer = (getOptions) => {
|
|
|
1729
1704
|
return renderToStream(jsx, renderOptions);
|
|
1730
1705
|
});
|
|
1731
1706
|
};
|
|
1707
|
+
var trackWholeStore = (store) => {
|
|
1708
|
+
Object.keys(store);
|
|
1709
|
+
return untrack(() => ({ ...store }));
|
|
1710
|
+
};
|
|
1732
1711
|
/**
|
|
1733
1712
|
* This renders all the tags collected from `head`.
|
|
1734
1713
|
*
|
|
@@ -1752,10 +1731,13 @@ var createRenderer = (getOptions) => {
|
|
|
1752
1731
|
* @public
|
|
1753
1732
|
*/
|
|
1754
1733
|
var DocumentHeadTags = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl((props) => {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1734
|
+
const documentHead = trackWholeStore(useDocumentHead());
|
|
1735
|
+
const head = {
|
|
1736
|
+
title: props.title ?? documentHead.title,
|
|
1737
|
+
meta: props.meta ?? documentHead.meta,
|
|
1738
|
+
links: props.links ?? documentHead.links,
|
|
1739
|
+
styles: props.styles ?? documentHead.styles,
|
|
1740
|
+
scripts: props.scripts ?? documentHead.scripts
|
|
1759
1741
|
};
|
|
1760
1742
|
return /*#__PURE__*/ _jsxSorted(Fragment, null, null, [
|
|
1761
1743
|
head.title && /*#__PURE__*/ _jsxSorted("title", null, null, head.title, 1, "eL_0"),
|