@qwik.dev/router 2.0.0-rc.0 → 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.
@@ -1,7 +1,7 @@
1
1
  import { t as ensureSlash } from "./chunks/pathname.mjs";
2
- import { $ as RoutePreventNavigateContext, B as _setRouterConfig, C as getRequestEvent, F as routeLoader$, G as ContentContext, H as getRouterConfig, I as routeLoaderQrl, J as HttpStatusContext, K as ContentInternalContext, L as setLoaderSignalValue, M as prepareRouteLoaders, P as restoreRouteLoaders, Q as RouteNavigateContext, S as getModuleRouteLoaders, U as getRoutes, V as getBasePathname, W as getTrailingSlash, X as RouteLoaderCtxContext, Y as RouteActionContext, Z as RouteLocationContext, _ as commitRouteLoaders, a as isPromise, b as getClientRouteLoaders, c as shouldPreload, d as loadRoute, et as RouteStateContext, h as clearNavFetchCache, i as getClientNavPath, it as Q_ROUTE, k as isImmutableLoader, l as toPath, m as abortRouteLoaderNavigation, n as resolveHead, nt as QDATA_KEY, o as isSameOrigin, q as DocumentHeadContext, rt as QFN_KEY, s as isSamePath, t as createDocumentHead, tt as QACTION_KEY, u as toUrl, v as ensureRouteLoaderSignals, y as fetchRouteLoaderData, z as _getServiceWorkerUrl } from "./chunks/head.qwik.mjs";
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], registerPreventNav = _capturesObj._[1];
81
+ let fn = _capturesObj._[0];
79
82
  return registerPreventNav(fn);
80
- }, "usePreventNavigateQrl_useVisibleTask_BsYUaz9XhUs", [fn, registerPreventNav]));
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
@@ -334,7 +337,9 @@ var dispatchRouterPopstate = (document1, href) => {
334
337
  };
335
338
  var spa_init_default = eventQrl(/*#__PURE__*/ inlinedQrl((_, el) => {
336
339
  if (!window._qRouterSPA && !window._qRouterInitPopstate) {
337
- const hasPathChanged = createCurrentPathTracker(location.pathname + location.search);
340
+ const currentPath = location.pathname + location.search;
341
+ const renderedPath = window._qcp ?? currentPath;
342
+ const hasPathChanged = createCurrentPathTracker(renderedPath);
338
343
  const checkAndScroll = (scrollState) => {
339
344
  if (scrollState) window.scrollTo(scrollState.x, scrollState.y);
340
345
  };
@@ -352,7 +357,7 @@ var spa_init_default = eventQrl(/*#__PURE__*/ inlinedQrl((_, el) => {
352
357
  state._qRouterScroll = scrollState || currentScrollState();
353
358
  history.replaceState(state, "");
354
359
  };
355
- saveScrollState();
360
+ if (renderedPath === currentPath) saveScrollState();
356
361
  window._qRouterInitPopstate = () => {
357
362
  if (window._qRouterSPA) return;
358
363
  window._qRouterScrollEnabled = false;
@@ -431,6 +436,7 @@ var spa_init_default = eventQrl(/*#__PURE__*/ inlinedQrl((_, el) => {
431
436
  };
432
437
  window._qRouterScrollEnabled = true;
433
438
  window.addEventListener("popstate", window._qRouterInitPopstate);
439
+ if (renderedPath !== currentPath) window._qRouterInitPopstate();
434
440
  window.addEventListener("scroll", window._qRouterInitScroll, { passive: true });
435
441
  document.addEventListener("click", window._qRouterInitAnchors);
436
442
  if (!window.navigation) document.addEventListener("visibilitychange", window._qRouterInitVisibility, { passive: true });
@@ -517,10 +523,48 @@ var startViewTransition = (params) => {
517
523
  var QWIK_CITY_SCROLLER = "_qCityScroller";
518
524
  /** @public */
519
525
  var QWIK_ROUTER_SCROLLER = "_qRouterScroller";
520
- var preventNav = {};
521
- var internalState = {
522
- navCount: 0,
523
- attemptCount: 0
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;
524
568
  };
525
569
  var getScroller = () => {
526
570
  let scroller = document.getElementById(QWIK_ROUTER_SCROLLER);
@@ -544,17 +588,19 @@ var useQwikRouter = (props) => {
544
588
  if (!urlEnv) throw new Error(`Missing Qwik URL Env Data`);
545
589
  const serverHead = useServerData("documentHead");
546
590
  const manifestHash = useServerData("containerAttributes")?.["q:manifest-hash"];
547
- const url = new URL(urlEnv);
591
+ const locale = getLocale("");
592
+ const viewTransition = props?.viewTransition;
548
593
  const routeLocationTarget = {
549
- url,
594
+ url: new URL(urlEnv),
550
595
  params: env.params,
551
596
  isNavigating: false,
552
597
  prevUrl: void 0
553
598
  };
554
599
  const routeLocation = useStore(routeLocationTarget, { deep: false });
555
600
  const navResolver = {};
556
- const routeLoaderCtx = useStore(env.routeLoaderCtx);
601
+ const routeLoaderCtx = env.routeLoaderCtx;
557
602
  routeLoaderCtx.manifestHash = manifestHash;
603
+ Object.assign(routeLoaderCtx.loaderPaths, env.loadedRoute.$loaderPaths$);
558
604
  const loaderState = {};
559
605
  const contentModulesForInit = env.loadedRoute.$mods$;
560
606
  const loaders = ensureRouteLoaderSignals(contentModulesForInit, loaderState, routeLoaderCtx, env.ev);
@@ -562,25 +608,15 @@ var useQwikRouter = (props) => {
562
608
  const value = env.loaderValues[loader.__id];
563
609
  setLoaderSignalValue(loaderState[loader.__id], value);
564
610
  }
565
- const routeInternal = useSignal({
566
- type: "initial",
567
- dest: url
568
- });
569
- 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];
570
614
  const content = useStore({
571
- headings: void 0,
572
- menu: void 0
573
- });
574
- const contentInternal = useSignal();
575
- /**
576
- * Non-serializable navigation context passed from the nav task to the navigation task. Only the
577
- * data that can't be derived from existing stores/signals.
578
- */
579
- const navContext = useSignal();
580
- const httpStatus = useSignal({
581
- status: env.response.status,
582
- message: env.loadedRoute.$notFound$ ? "Not Found" : env.response.statusMessage ?? ""
615
+ headings: pageModule.headings,
616
+ menu: env.loadedRoute.$menu$
583
617
  });
618
+ const contentInternal = useSignal(noSerialize(contentModulesForInit));
619
+ const httpStatus = useSignal(getServerHttpStatus(env.loadedRoute.$notFound$, env.response));
584
620
  const currentActionId = env.response.action;
585
621
  const currentAction = currentActionId ? env.response.actionResult : void 0;
586
622
  const actionState = useSignal(currentAction ? {
@@ -591,34 +627,15 @@ var useQwikRouter = (props) => {
591
627
  status: env.response.status
592
628
  }
593
629
  } : void 0);
594
- const actionDataSignal = useSignal(currentActionId ? {
630
+ const serverActionData = currentActionId || env.response.status !== 200 ? {
595
631
  action: currentActionId,
596
632
  actionResult: currentAction,
597
633
  status: env.response.status
598
- } : void 0);
599
- const registerPreventNav = /*#__PURE__*/ inlinedQrl((fn$) => {
600
- if (!isBrowser) return;
601
- preventNav.$handler$ ||= (event) => {
602
- internalState.attemptCount++;
603
- if (!preventNav.$cbs$) return;
604
- if ([...preventNav.$cbs$.values()].map((cb) => cb.resolved ? cb.resolved() : cb()).some(Boolean)) {
605
- event.preventDefault();
606
- event.returnValue = true;
607
- }
608
- };
609
- (preventNav.$cbs$ ||= /* @__PURE__ */ new Set()).add(fn$);
610
- fn$.resolve();
611
- window.addEventListener("beforeunload", preventNav.$handler$);
612
- return () => {
613
- if (preventNav.$cbs$) {
614
- preventNav.$cbs$.delete(fn$);
615
- if (!preventNav.$cbs$.size) {
616
- preventNav.$cbs$ = void 0;
617
- window.removeEventListener("beforeunload", preventNav.$handler$);
618
- }
619
- }
620
- };
621
- }, "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)));
622
639
  /**
623
640
  * This is the `nav()` function that `useNavigation()` returns. It is also used internally for SPA
624
641
  * navigations and is provided in context for use in loaders and actions.
@@ -627,132 +644,113 @@ var useQwikRouter = (props) => {
627
644
  * treat it as a user-initiated navigation and allow scroll restoration to work. For this reason,
628
645
  * make sure to change the address bar before awaiting anything.
629
646
  */
630
- const goto = /*#__PURE__*/ inlinedQrl(async (path, opt) => {
631
- let actionState = _capturesObj._[0], manifestHash = _capturesObj._[1], navResolver = _capturesObj._[2], routeInternal = _capturesObj._[3], routeLoaderCtx = _capturesObj._[4], routeLocation = _capturesObj._[5];
632
- const { type = "link", forceReload = path === void 0, replaceState = false, scroll = true } = typeof opt === "object" ? opt : { forceReload: opt };
633
- if (isBrowser && type === "link" && routeInternal.value.type === "initial") {
634
- const url = new URL(window.location.href);
635
- routeInternal.value.dest = url;
636
- routeLocation.url = url;
637
- }
638
- const lastDest = routeInternal.value.dest;
639
- const dest = path === void 0 ? lastDest : typeof path === "number" ? path : toUrl(path, routeLocation.url);
640
- if (navResolver.p && !forceReload && typeof dest !== "number" && isSamePath(dest, lastDest) && dest.href === lastDest.href) return navResolver.p;
641
- const attemptCount = ++internalState.attemptCount;
642
- if (preventNav.$cbs$ && (forceReload || typeof dest === "number" || !isSamePath(dest, lastDest) || !isSameOrigin(dest, lastDest))) {
643
- const prevents = await Promise.all([...preventNav.$cbs$.values()].map((cb) => cb(dest)));
644
- if (attemptCount !== internalState.attemptCount || prevents.some(Boolean)) {
645
- 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);
646
653
  return;
647
654
  }
648
- }
649
- if (typeof dest === "number") {
650
- if (isBrowser) history.go(dest);
651
- return;
652
- }
653
- if (!isSameOrigin(dest, lastDest)) {
654
- if (isBrowser) location.href = dest.href;
655
- return;
656
- }
657
- if (!forceReload && isSamePath(dest, lastDest)) {
658
- if (isBrowser) {
659
- if (type === "link" && dest.href !== location.href) history.pushState(null, "", dest);
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) {
660
706
  const scroller = getScroller();
661
- restoreScroll(type, dest, new URL(location.href), scroller, getScrollHistory());
662
- if (type === "popstate") window._qRouterScrollEnabled = true;
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;
663
712
  }
664
- if (dest.href !== routeLocation.url.href) {
665
- const newUrl = new URL(dest.href);
666
- routeInternal.value.dest = newUrl;
667
- routeLocation.url = newUrl;
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;
668
719
  }
669
- return navResolver.p;
670
- }
671
- const navCount = ++internalState.navCount;
672
- internalState.currentTransition?.skipTransition();
673
- navResolver.cancel?.();
674
- navResolver.cancel = void 0;
675
- navResolver.r?.();
676
- let historyUpdated = false;
677
- if (isBrowser) getClientRouteLoaders(routeLoaderCtx, routeLocation.url.href);
678
- if (isBrowser && type === "link" && !forceReload) {
679
- const scroller = getScroller();
680
- window._qRouterScrollEnabled = false;
681
- clearTimeout(window._qRouterScrollDebounce);
682
- saveScrollHistory(currentScrollState(scroller));
683
- clientNavigate(window, type, new URL(location.href), dest, replaceState);
684
- historyUpdated = true;
685
- }
686
- const wasNavigating = routeLocation.isNavigating;
687
- routeLocation.isNavigating = true;
688
- const container = isBrowser ? _getContextContainer() : void 0;
689
- if (container && !wasNavigating) {
690
- await _waitUntilRendered(container);
691
- if (navCount !== internalState.navCount) return;
692
- }
693
- actionState.value = void 0;
694
- routeInternal.value = {
695
- type,
696
- dest,
697
- forceReload,
698
- replaceState,
699
- scroll,
700
- historyUpdated
701
- };
702
- if (wasNavigating) abortRouteLoaderNavigation(routeLoaderCtx);
703
- if (isBrowser) prefetchRoute(dest, false, .8, manifestHash, true);
704
- navResolver.p = new Promise((resolve) => {
705
- navResolver.r = () => {
706
- navResolver.r = void 0;
707
- navResolver.p = void 0;
708
- resolve();
720
+ actionState.value = void 0;
721
+ const navigation = {
722
+ type,
723
+ dest,
724
+ forceReload,
725
+ replaceState,
726
+ scroll,
727
+ historyUpdated
709
728
  };
710
- });
711
- return navResolver.p;
712
- }, "useQwikRouter_goto_8j8Vrz2yUIM", [
713
- actionState,
714
- manifestHash,
715
- navResolver,
716
- routeInternal,
717
- routeLoaderCtx,
718
- routeLocation
719
- ]);
720
- useContextProvider(ContentContext, content);
721
- useContextProvider(ContentInternalContext, contentInternal);
722
- useContextProvider(DocumentHeadContext, documentHead);
723
- useContextProvider(HttpStatusContext, httpStatus);
724
- useContextProvider(RouteLocationContext, routeLocation);
725
- useContextProvider(RouteNavigateContext, goto);
726
- useContextProvider(RouteStateContext, loaderState);
727
- useContextProvider(RouteLoaderCtxContext, routeLoaderCtx);
728
- useContextProvider(RouteActionContext, actionState);
729
- useContextProvider(RoutePreventNavigateContext, registerPreventNav);
730
- /**
731
- * This is split in 3 tasks because we need to update the head once we figured out the route, and
732
- * before we trigger the render, and we need to subscribe only head to loader signal updates
733
- */
734
- useTaskQrl(/*#__PURE__*/ inlinedQrl(async ({ track }) => {
735
- 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];
736
- const navigation = track(routeInternal);
737
- const action = track(actionState);
738
- action?.resolveDispatch?.();
739
- if (action) action.resolveDispatch = void 0;
740
- const prevUrl = routeLocation.url;
741
- const navType = action ? "form" : navigation.type;
742
- const replaceState = navigation.replaceState;
743
- const navCountBefore = internalState.navCount;
744
- let trackUrl;
745
- let endpointResponse;
746
- let actionData;
747
- let actionLoaderHashes;
748
- let loadedRoute;
749
- if (isServer) {
750
- trackUrl = new URL(navigation.dest, routeLocation.url);
751
- loadedRoute = env.loadedRoute;
752
- endpointResponse = env.response;
753
- actionData = endpointResponse;
754
- } else {
755
- 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);
756
754
  const canceled = new Promise((resolve) => {
757
755
  navResolver.cancel = () => resolve(void 0);
758
756
  });
@@ -798,7 +796,7 @@ var useQwikRouter = (props) => {
798
796
  }
799
797
  if (result.redirect) {
800
798
  if (result.redirect instanceof URL) location.href = result.redirect.href;
801
- else goto(result.redirect, { replaceState: true });
799
+ else startNavigation(result.redirect, { replaceState: true });
802
800
  return;
803
801
  }
804
802
  actionData = {
@@ -809,210 +807,187 @@ var useQwikRouter = (props) => {
809
807
  actionLoaderHashes = result.loaderHashes;
810
808
  }
811
809
  navResolver.cancel = void 0;
812
- }
813
- const { $routeName$, $params$, $mods$, $menu$, $notFound$ } = loadedRoute;
814
- const contentModules = $mods$;
815
- if (!isServer) routeLoaderCtx.goto = noSerialize(goto);
816
- let routeLoaders;
817
- if (isServer) {
818
- Object.assign(routeLoaderCtx.loaderPaths, loadedRoute.$loaderPaths$);
819
- routeLoaders = ensureRouteLoaderSignals(contentModules, loaderState, routeLoaderCtx, env.ev);
820
- } else routeLoaders = prepareRouteLoaders(contentModules, loaderState, routeLoaderCtx, loadedRoute.$loaderPaths$, trackUrl, prevUrl, navCountBefore, action ? actionLoaderHashes ?? null : void 0, action ?? navigation);
821
- if (routeLoaders.length > 0) for (let i = 0; i < routeLoaders.length; i++) {
822
- const loader = routeLoaders[i];
823
- if (!isImmutableLoader(loader.__id)) loaderState[loader.__id].untrackedPending;
824
- }
825
- if (!isServer) clearNavFetchCache();
826
- if (internalState.navCount !== navCountBefore) return;
827
- if ($notFound$) httpStatus.value = {
828
- status: 404,
829
- message: "Not Found"
830
- };
831
- else if (endpointResponse) httpStatus.value = {
832
- status: endpointResponse.status,
833
- message: endpointResponse.statusMessage ?? "OK"
834
- };
835
- else if (actionData) httpStatus.value = {
836
- status: actionData.status,
837
- message: "OK"
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);
838
877
  };
839
- else httpStatus.value = {
840
- status: 200,
841
- message: "OK"
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);
842
893
  };
843
- const pageModule = contentModules[contentModules.length - 1];
844
- if (isSamePath(trackUrl, navigation.dest)) trackUrl.hash = navigation.dest.hash;
845
- if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) trackUrl.search = navigation.dest.search;
846
- let shouldForcePrevUrl = false;
847
- let shouldForceUrl = false;
848
- let shouldForceParams = false;
849
- if (!isSamePath(trackUrl, prevUrl)) {
850
- if (_hasStoreEffects(routeLocation, "prevUrl")) shouldForcePrevUrl = true;
851
- routeLocationTarget.prevUrl = prevUrl;
852
- }
853
- if (routeLocationTarget.url !== trackUrl) {
854
- if (_hasStoreEffects(routeLocation, "url")) shouldForceUrl = true;
855
- routeLocationTarget.url = trackUrl;
856
- }
857
- if (routeLocationTarget.params !== $params$) {
858
- if (_hasStoreEffects(routeLocation, "params")) shouldForceParams = true;
859
- routeLocationTarget.params = $params$;
860
- }
861
- const nextRouteInternal = {
862
- type: navType,
863
- dest: trackUrl
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
+ });
864
960
  };
865
- if (navigation.forceReload !== void 0) nextRouteInternal.forceReload = navigation.forceReload;
866
- if (navigation.replaceState !== void 0) nextRouteInternal.replaceState = navigation.replaceState;
867
- if (navigation.scroll !== void 0) nextRouteInternal.scroll = navigation.scroll;
868
- if (navigation.historyUpdated !== void 0) nextRouteInternal.historyUpdated = navigation.historyUpdated;
869
- routeInternal.untrackedValue = nextRouteInternal;
870
- content.headings = pageModule.headings;
871
- content.menu = $menu$;
872
- contentInternal.untrackedValue = noSerialize(contentModules);
873
- actionDataSignal.value = actionData;
874
- navContext.value = noSerialize({
875
- routeName: $routeName$,
876
- navType,
877
- prevUrl,
878
- replaceState,
879
- shouldForcePrevUrl,
880
- shouldForceUrl,
881
- shouldForceParams,
882
- navCount: navCountBefore
883
- });
884
- }, "useQwikRouter_useTask_XpalYii770E", [
961
+ return startNavigation(path, opt);
962
+ }, "useQwikRouter_goto_8j8Vrz2yUIM", [
885
963
  actionDataSignal,
886
964
  actionState,
887
965
  content,
888
966
  contentInternal,
889
- env,
890
- goto,
891
- httpStatus,
892
- loaderState,
893
- navContext,
894
- navResolver,
895
- routeInternal,
896
- routeLoaderCtx,
897
- routeLocation,
898
- routeLocationTarget
899
- ]), { deferUpdates: isServer });
900
- /**
901
- * Calc head. This is in a separate task so that loader updates can trigger head recalculation
902
- * without re-running the navigation logic.
903
- *
904
- * Note that on the server these tasks run sequentially.
905
- */
906
- useTaskQrl(/*#__PURE__*/ inlinedQrl(({ track }) => {
907
- let actionDataSignal = _capturesObj._[0], contentInternal = _capturesObj._[1], documentHead = _capturesObj._[2], loaderState = _capturesObj._[3], navContext = _capturesObj._[4], routeLocation = _capturesObj._[5], serverHead = _capturesObj._[6];
908
- const contentModules = track(contentInternal);
909
- const nav = navContext.untrackedValue;
910
- if (!isServer && routeLocation.isNavigating && nav && nav.navCount !== internalState.navCount) return;
911
- if (!contentModules) return;
912
- const actionData = track(actionDataSignal);
913
- let head;
914
- try {
915
- head = track(() => resolveHead(actionData, loaderState, routeLocation, contentModules, getLocale(""), serverHead));
916
- } catch (error) {
917
- if (isServer || isPromise(error)) throw error;
918
- console.error(error);
919
- return;
920
- }
921
- documentHead.links = head.links;
922
- documentHead.meta = head.meta;
923
- documentHead.styles = head.styles;
924
- documentHead.scripts = head.scripts;
925
- documentHead.title = head.title;
926
- documentHead.frontmatter = head.frontmatter;
927
- }, "useQwikRouter_useTask_1_1sKEZ9Pg1ow", [
928
- actionDataSignal,
929
- contentInternal,
930
967
  documentHead,
968
+ httpStatus,
931
969
  loaderState,
932
- navContext,
933
- routeLocation,
934
- serverHead
935
- ]), { deferUpdates: isServer });
936
- /** Actual navigation */
937
- useTaskQrl(/*#__PURE__*/ inlinedQrl(({ track }) => {
938
- 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];
939
- const nav = track(navContext);
940
- if (isServer || !nav) return;
941
- if (nav.navCount !== internalState.navCount) return;
942
- const container = _getContextContainer();
943
- const navigation = routeInternal.untrackedValue;
944
- const { navType, prevUrl, replaceState, routeName } = nav;
945
- const trackUrl = routeLocation.url;
946
- const scroller = getScroller();
947
- let scrollState;
948
- if (navType === "popstate") scrollState = getScrollHistory();
949
- 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);
950
- initializeSPA(goto, scroller);
951
- if (navType !== "popstate") {
952
- window._qRouterScrollEnabled = false;
953
- clearTimeout(window._qRouterScrollDebounce);
954
- if (!navigation.historyUpdated) saveScrollHistory(currentScrollState(scroller));
955
- }
956
- let didNavigate = false;
957
- let navigatePromise;
958
- let currentTransition;
959
- const navigate = () => {
960
- if (navigatePromise) return navigatePromise;
961
- if (nav.navCount !== internalState.navCount) return Promise.resolve();
962
- didNavigate = true;
963
- if (navigation.historyUpdated) {
964
- const currentPath = location.pathname + location.search + location.hash;
965
- const nextPath = toPath(trackUrl);
966
- if (currentPath !== nextPath) history.replaceState(history.state, "", nextPath);
967
- } else clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
968
- contentInternal.trigger();
969
- return navigatePromise = _waitUntilRendered(container).then(() => {
970
- if (nav.navCount === internalState.navCount) commitRouteLoaders(loaderState, routeLoaderCtx, nav.navCount);
971
- }, (error) => {
972
- if (nav.navCount === internalState.navCount) restoreRouteLoaders(loaderState, routeLoaderCtx, nav.navCount);
973
- throw error;
974
- });
975
- };
976
- const _waitNextPage = () => {
977
- if (!shouldStartViewTransition(props?.viewTransition)) return navigate().then(() => void 0);
978
- const { ready, transition } = startViewTransition({
979
- update: navigate,
980
- types: ["qwik-navigation"]
981
- });
982
- currentTransition = transition;
983
- internalState.currentTransition = transition;
984
- return ready.then(() => transition, (reason) => {
985
- if (!didNavigate && nav.navCount === internalState.navCount) return navigate().then(() => transition);
986
- if (reason?.name === "AbortError") return transition;
987
- throw reason;
988
- });
989
- };
990
- _waitNextPage().finally(() => {
991
- if (currentTransition && internalState.currentTransition === currentTransition) internalState.currentTransition = void 0;
992
- if (nav.navCount !== internalState.navCount) return;
993
- container.element.setAttribute?.(Q_ROUTE, routeName);
994
- saveScrollHistory(currentScrollState(scroller));
995
- window._qRouterScrollEnabled = true;
996
- callRestoreScrollOnDocument();
997
- refreshLinkPrefetchObserver(manifestHash);
998
- if (nav.shouldForcePrevUrl) forceStoreEffects(routeLocation, "prevUrl");
999
- if (nav.shouldForceUrl) forceStoreEffects(routeLocation, "url");
1000
- if (nav.shouldForceParams) forceStoreEffects(routeLocation, "params");
1001
- routeLocation.isNavigating = false;
1002
- navResolver.r?.();
1003
- });
1004
- }, "useQwikRouter_useTask_2_yw17chooOac", [
1005
- contentInternal,
1006
- goto,
1007
- loaderState,
970
+ locale,
1008
971
  manifestHash,
1009
- navContext,
1010
972
  navResolver,
1011
- props,
1012
973
  routeInternal,
1013
974
  routeLoaderCtx,
1014
- routeLocation
1015
- ]), { deferUpdates: false });
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);
1016
991
  };
1017
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. */
1018
993
  function initializeSPA(goto, scroller) {
@@ -1190,6 +1165,7 @@ var RouterOutlet = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(() => {
1190
1165
  ((w, h) => {
1191
1166
  if (!w._qcs) {
1192
1167
  w._qcs = true;
1168
+ w._qcp = location.pathname + location.search;
1193
1169
  const s = h.state?._qRouterScroll;
1194
1170
  if (s) {
1195
1171
  h.scrollRestoration = "manual";
@@ -1198,7 +1174,7 @@ var RouterOutlet = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(() => {
1198
1174
  document.dispatchEvent(new Event("qcinit"));
1199
1175
  }
1200
1176
  })(window, history);
1201
- }, "()=>{((w,h)=>{if(!w._qcs){w._qcs=!0;const s=h.state?._qRouterScroll;if(s){h.scrollRestoration=\"manual\";w.scrollTo(s.x,s.y);}document.dispatchEvent(new Event(\"qcinit\"));}})(window,history);}"),
1177
+ }, "()=>{((w,h)=>{if(!w._qcs){w._qcs=!0;w._qcp=location.pathname+location.search;const s=h.state?._qRouterScroll;if(s){h.scrollRestoration=\"manual\";w.scrollTo(s.x,s.y);}document.dispatchEvent(new Event(\"qcinit\"));}})(window,history);}"),
1202
1178
  "q:p": nav
1203
1179
  }, { "q-d:qrouterpopstate": /*#__PURE__*/ inlinedQrl((event, _1, nav) => handleRouterPopstate(nav, event), "RouterOutlet_component_Fragment_script_q_d_qrouterpopstate_aRL6GvFyews").m() }, null, 6, "yd_0")], 1, "yd_1");
1204
1180
  }
@@ -1216,6 +1192,7 @@ function routeActionQrl(actionQrl, ...rest) {
1216
1192
  function action() {
1217
1193
  const loc = useLocation();
1218
1194
  const currentAction = useAction();
1195
+ const runAction = useContext(RouteActionRunnerContext, null);
1219
1196
  const initialState = {
1220
1197
  actionPath: `?${QACTION_KEY}=${id}`,
1221
1198
  submitted: false,
@@ -1238,7 +1215,7 @@ function routeActionQrl(actionQrl, ...rest) {
1238
1215
  return initialState;
1239
1216
  });
1240
1217
  initialState.submit = /* @__PURE__ */ inlinedQrl((input = {}) => {
1241
- let currentAction = _capturesObj._[0], id = _capturesObj._[1], latestSubmission = _capturesObj._[2], loc = _capturesObj._[3], state = _capturesObj._[4];
1218
+ let currentAction = _capturesObj._[0], id = _capturesObj._[1], latestSubmission = _capturesObj._[2], loc = _capturesObj._[3], runAction = _capturesObj._[4], state = _capturesObj._[5];
1242
1219
  if (isServer) throw new Error(`Actions can not be invoked within the server during SSR.
1243
1220
  Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
1244
1221
  let data;
@@ -1268,6 +1245,7 @@ Action.run() can only be called on the browser, for example when a user clicks a
1268
1245
  resolve: noSerialize(resolve),
1269
1246
  resolveDispatch: noSerialize(resolveDispatch)
1270
1247
  };
1248
+ runAction?.(RUN_PENDING_ACTION);
1271
1249
  })).then(({ result, status }) => {
1272
1250
  const isLatestSubmission = latestSubmission.current === submission;
1273
1251
  if (isLatestSubmission) {
@@ -1298,6 +1276,7 @@ Action.run() can only be called on the browser, for example when a user clicks a
1298
1276
  id,
1299
1277
  { current: void 0 },
1300
1278
  loc,
1279
+ runAction,
1301
1280
  state
1302
1281
  ]);
1303
1282
  return state;
@@ -1725,6 +1704,10 @@ var createRenderer = (getOptions) => {
1725
1704
  return renderToStream(jsx, renderOptions);
1726
1705
  });
1727
1706
  };
1707
+ var trackWholeStore = (store) => {
1708
+ Object.keys(store);
1709
+ return untrack(() => ({ ...store }));
1710
+ };
1728
1711
  /**
1729
1712
  * This renders all the tags collected from `head`.
1730
1713
  *
@@ -1748,10 +1731,13 @@ var createRenderer = (getOptions) => {
1748
1731
  * @public
1749
1732
  */
1750
1733
  var DocumentHeadTags = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl((props) => {
1751
- let head = useDocumentHead();
1752
- if (props) head = {
1753
- ...head,
1754
- ...props
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
1755
1741
  };
1756
1742
  return /*#__PURE__*/ _jsxSorted(Fragment, null, null, [
1757
1743
  head.title && /*#__PURE__*/ _jsxSorted("title", null, null, head.title, 1, "eL_0"),