@qwik.dev/router 2.0.0-beta.19 → 2.0.0-beta.21

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,4 +1,4 @@
1
- import { createAsyncComputed$, isBrowser } from '@qwik.dev/core';
1
+ import { createAsync$, isBrowser } from '@qwik.dev/core';
2
2
  import { p } from '@qwik.dev/core/preloader';
3
3
  import { _deserialize, _UNINITIALIZED } from '@qwik.dev/core/internal';
4
4
  import { R as RouteDataProp, M as MenuDataProp } from './types.qwik.mjs';
@@ -13,7 +13,7 @@ const Q_ROUTE = "q:route";
13
13
  const DEFAULT_LOADERS_SERIALIZATION_STRATEGY = globalThis.__DEFAULT_LOADERS_SERIALIZATION_STRATEGY__ || "never";
14
14
 
15
15
  const MAX_Q_DATA_RETRY_COUNT = 3;
16
- const loadClientData = async (url, element, opts, retryCount = 0) => {
16
+ const loadClientData = async (url, opts, retryCount = 0) => {
17
17
  const pagePathname = url.pathname;
18
18
  const pageSearch = url.search;
19
19
  const clientDataPath = getClientDataPath(pagePathname, pageSearch, {
@@ -36,7 +36,7 @@ const loadClientData = async (url, element, opts, retryCount = 0) => {
36
36
  qData = fetch(clientDataPath, fetchOptions).then((rsp) => {
37
37
  if (rsp.status === 404 && opts?.loaderIds && retryCount < MAX_Q_DATA_RETRY_COUNT) {
38
38
  opts.loaderIds = void 0;
39
- return loadClientData(url, element, opts, retryCount + 1);
39
+ return loadClientData(url, opts, retryCount + 1);
40
40
  }
41
41
  if (rsp.redirected) {
42
42
  const redirectedURL = new URL(rsp.url);
@@ -50,7 +50,7 @@ const loadClientData = async (url, element, opts, retryCount = 0) => {
50
50
  }
51
51
  if ((rsp.headers.get("content-type") || "").includes("json")) {
52
52
  return rsp.text().then((text) => {
53
- const [clientData] = _deserialize(text, element);
53
+ const [clientData] = _deserialize(text);
54
54
  if (!clientData) {
55
55
  location.href = url.href;
56
56
  return;
@@ -169,10 +169,10 @@ const isPromise = (value) => {
169
169
  return value && typeof value.then === "function";
170
170
  };
171
171
  const createLoaderSignal = (loadersObject, loaderId, url, serializationStrategy, container) => {
172
- return createAsyncComputed$(
172
+ return createAsync$(
173
173
  async () => {
174
174
  if (isBrowser && loadersObject[loaderId] === _UNINITIALIZED) {
175
- const data = await loadClientData(url, void 0, {
175
+ const data = await loadClientData(url, {
176
176
  loaderIds: [loaderId]
177
177
  });
178
178
  loadersObject[loaderId] = data?.loaders[loaderId] ?? _UNINITIALIZED;
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="./modules.d.ts" />
2
2
 
3
- import type { AsyncComputedReadonlySignal } from '@qwik.dev/core/internal';
3
+ import type { AsyncSignal } from '@qwik.dev/core/internal';
4
4
  import { Component } from '@qwik.dev/core';
5
5
  import { Cookie } from '@qwik.dev/router/middleware/request-handler';
6
6
  import { CookieOptions } from '@qwik.dev/router/middleware/request-handler';
@@ -477,7 +477,7 @@ export declare interface LinkProps extends AnchorAttributes {
477
477
  *
478
478
  * This **improves UX performance** for client-side (**SPA**) navigations.
479
479
  *
480
- * Prefetching occurs when a the Link enters the viewport in production (**`on:qvisible`**), or
480
+ * Prefetching occurs when a the Link enters the viewport in production (**`q-e:qvisible`**), or
481
481
  * with **`mouseover`/`focus`** during dev.
482
482
  *
483
483
  * Prefetching will not occur if the user has the **data saver** setting enabled.
@@ -529,7 +529,7 @@ declare type LoaderOptions = {
529
529
  };
530
530
 
531
531
  /** @public */
532
- export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? ReadonlySignal<ValueOrPromise<VALIDATOR>> : ReadonlySignal<TYPE>) & Pick<AsyncComputedReadonlySignal, 'promise' | 'loading' | 'error'>;
532
+ export declare type LoaderSignal<TYPE> = (TYPE extends () => ValueOrPromise<infer VALIDATOR> ? ReadonlySignal<ValueOrPromise<VALIDATOR>> : ReadonlySignal<TYPE>) & Pick<AsyncSignal, 'promise' | 'loading' | 'error'>;
533
533
 
534
534
  /** @public */
535
535
  export declare type MenuData = [pathname: string, menuLoader: MenuModuleLoader];
@@ -2,7 +2,7 @@ import { jsx, Fragment, jsxs } from '@qwik.dev/core/jsx-runtime';
2
2
  import { component$, useErrorBoundary, useOnWindow, $, Slot, createContextId, useContext, implicit$FirstArg, noSerialize, useVisibleTask$, useServerData, useSignal, untrack, sync$, isDev, withLocale, event$, isServer, useStyles$, useStore, isBrowser, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender, createElement } from '@qwik.dev/core';
3
3
  import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isPromise, a as isSamePath, c as createLoaderSignal, t as toUrl, b as isSameOrigin, d as loadRoute, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, C as CLIENT_DATA_CACHE, Q as Q_ROUTE, e as clientNavigate, f as deepFreeze, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from './chunks/routing.qwik.mjs';
4
4
  import * as qwikRouterConfig from '@qwik-router-config';
5
- import { _getContextContainer, SerializerSymbol, _UNINITIALIZED, _getContextElement, _hasStoreEffects, _getQContainerElement, forceStoreEffects, _waitUntilRendered, _getContextEvent, _serialize, _deserialize, _resolveContextWithoutSequentialScope } from '@qwik.dev/core/internal';
5
+ import { _getContextContainer, SerializerSymbol, _UNINITIALIZED, _hasStoreEffects, forceStoreEffects, _waitUntilRendered, _getContextHostElement, _getContextEvent, _serialize, _deserialize, _resolveContextWithoutSequentialScope } from '@qwik.dev/core/internal';
6
6
  import { _asyncRequestStore } from '@qwik.dev/router/middleware/request-handler';
7
7
  import * as v from 'valibot';
8
8
  import * as z from 'zod';
@@ -77,7 +77,7 @@ const Link = component$((props) => {
77
77
  const url = new URL(elm.href);
78
78
  preloadRouteBundles(url.pathname);
79
79
  if (elm.hasAttribute("data-prefetch")) {
80
- loadClientData(url, elm, {
80
+ loadClientData(url, {
81
81
  preloadRouteBundles: false,
82
82
  isPrefetch: true
83
83
  });
@@ -216,6 +216,8 @@ const createDocumentHead = (defaults) => ({
216
216
  frontmatter: { ...defaults?.frontmatter }
217
217
  });
218
218
 
219
+ const transitionCss = "@layer qwik{@supports selector(html:active-view-transition-type(type)){html:active-view-transition-type(qwik-navigation){:root{view-transition-name:none}}}@supports not selector(html:active-view-transition-type(type)){:root{view-transition-name:none}}}";
220
+
219
221
  function callRestoreScrollOnDocument() {
220
222
  if (document.__q_scroll_restore__) {
221
223
  document.__q_scroll_restore__();
@@ -420,8 +422,6 @@ const startViewTransition = (params) => {
420
422
  }
421
423
  };
422
424
 
423
- const transitionCss = "@layer qwik{@supports selector(html:active-view-transition-type(type)){html:active-view-transition-type(qwik-navigation){:root{view-transition-name:none}}}@supports not selector(html:active-view-transition-type(type)){:root{view-transition-name:none}}}";
424
-
425
425
  const QWIK_CITY_SCROLLER = "_qCityScroller";
426
426
  const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
427
427
  const preventNav = {};
@@ -606,7 +606,7 @@ const useQwikRouter = (props) => {
606
606
  scroll
607
607
  };
608
608
  if (isBrowser) {
609
- loadClientData(dest, _getContextElement());
609
+ loadClientData(dest);
610
610
  loadRoute(
611
611
  qwikRouterConfig.routes,
612
612
  qwikRouterConfig.menus,
@@ -639,7 +639,7 @@ const useQwikRouter = (props) => {
639
639
  let trackUrl;
640
640
  let clientPageData;
641
641
  let loadedRoute = null;
642
- let elm;
642
+ let container2;
643
643
  if (isServer) {
644
644
  trackUrl = new URL(navigation.dest, routeLocation.url);
645
645
  loadedRoute = env.loadedRoute;
@@ -659,8 +659,8 @@ const useQwikRouter = (props) => {
659
659
  qwikRouterConfig.cacheModules,
660
660
  trackUrl.pathname
661
661
  );
662
- elm = _getContextElement();
663
- const pageData = clientPageData = await loadClientData(trackUrl, elm, {
662
+ container2 = _getContextContainer();
663
+ const pageData = clientPageData = await loadClientData(trackUrl, {
664
664
  action,
665
665
  clearCache: true
666
666
  });
@@ -747,7 +747,7 @@ const useQwikRouter = (props) => {
747
747
  }
748
748
  const loaders = clientPageData?.loaders;
749
749
  if (loaders) {
750
- const container2 = _getContextContainer();
750
+ const container3 = _getContextContainer();
751
751
  for (const [key, value] of Object.entries(loaders)) {
752
752
  const signal = loaderState[key];
753
753
  const awaitedValue = await value;
@@ -758,7 +758,7 @@ const useQwikRouter = (props) => {
758
758
  key,
759
759
  trackUrl,
760
760
  DEFAULT_LOADERS_SERIALIZATION_STRATEGY,
761
- container2
761
+ container3
762
762
  );
763
763
  } else {
764
764
  signal.invalidate();
@@ -883,7 +883,7 @@ const useQwikRouter = (props) => {
883
883
  const navigate = () => {
884
884
  clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
885
885
  contentInternal.force();
886
- return _waitUntilRendered(elm);
886
+ return _waitUntilRendered(container2);
887
887
  };
888
888
  const _waitNextPage = () => {
889
889
  if (isServer || props?.viewTransition === false) {
@@ -903,8 +903,7 @@ const useQwikRouter = (props) => {
903
903
  navigate();
904
904
  throw err;
905
905
  }).finally(() => {
906
- const container2 = _getQContainerElement(elm);
907
- container2.setAttribute(Q_ROUTE, routeName);
906
+ container2.element.setAttribute?.(Q_ROUTE, routeName);
908
907
  const scrollState2 = currentScrollState(scroller);
909
908
  saveScrollHistory(scrollState2);
910
909
  window._qRouterScrollEnabled = true;
@@ -1153,6 +1152,7 @@ const routeAction$ = /* @__PURE__ */ implicit$FirstArg(
1153
1152
  const globalAction$ = /* @__PURE__ */ implicit$FirstArg(
1154
1153
  globalActionQrl
1155
1154
  );
1155
+ const getValue = (obj) => obj.value;
1156
1156
  const routeLoaderQrl = ((loaderQrl, ...rest) => {
1157
1157
  const { id, validators, serializationStrategy } = getValidators(rest, loaderQrl);
1158
1158
  function loader() {
@@ -1165,8 +1165,9 @@ const routeLoaderQrl = ((loaderQrl, ...rest) => {
1165
1165
  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.
1166
1166
  For more information check: https://qwik.dev/docs/re-exporting-loaders/`);
1167
1167
  }
1168
- untrack(() => state[id].value);
1169
- return state[id];
1168
+ const loaderData = state[id];
1169
+ untrack(getValue, loaderData);
1170
+ return loaderData;
1170
1171
  }
1171
1172
  loader.__brand = "server_loader";
1172
1173
  loader.__qrl = loaderQrl;
@@ -1303,7 +1304,7 @@ const zod$ = /* @__PURE__ */ implicit$FirstArg(zodQrl);
1303
1304
  const serverQrl = (qrl, options) => {
1304
1305
  if (isServer) {
1305
1306
  const captured = qrl.getCaptured();
1306
- if (captured && captured.length > 0 && !_getContextElement()) {
1307
+ if (captured && captured.length > 0 && !_getContextHostElement()) {
1307
1308
  throw new Error("For security reasons, we cannot serialize QRLs that capture lexical scope.");
1308
1309
  }
1309
1310
  }
@@ -1323,7 +1324,6 @@ const serverQrl = (qrl, options) => {
1323
1324
  }
1324
1325
  return qrl.apply(requestEvent, isDev ? deepFreeze(args) : args);
1325
1326
  } else {
1326
- const ctxElm = _getContextElement();
1327
1327
  const filteredArgs = args.map((arg) => {
1328
1328
  if (arg instanceof SubmitEvent && arg.target instanceof HTMLFormElement) {
1329
1329
  return new FormData(arg.target);
@@ -1366,11 +1366,7 @@ const serverQrl = (qrl, options) => {
1366
1366
  if (res.ok && contentType === "text/qwik-json-stream" && res.body) {
1367
1367
  return (async function* () {
1368
1368
  try {
1369
- for await (const result of deserializeStream(
1370
- res.body,
1371
- ctxElm ?? document.documentElement,
1372
- abortSignal
1373
- )) {
1369
+ for await (const result of deserializeStream(res.body, abortSignal)) {
1374
1370
  yield result;
1375
1371
  }
1376
1372
  } finally {
@@ -1381,7 +1377,7 @@ const serverQrl = (qrl, options) => {
1381
1377
  })();
1382
1378
  } else if (contentType === "application/qwik-json") {
1383
1379
  const str = await res.text();
1384
- const [obj] = _deserialize(str, ctxElm ?? document.documentElement);
1380
+ const [obj] = _deserialize(str);
1385
1381
  if (res.status >= 400) {
1386
1382
  throw obj;
1387
1383
  }
@@ -1441,7 +1437,7 @@ const getValidators = (rest, qrl) => {
1441
1437
  serializationStrategy
1442
1438
  };
1443
1439
  };
1444
- const deserializeStream = async function* (stream, ctxElm, abortSignal) {
1440
+ const deserializeStream = async function* (stream, abortSignal) {
1445
1441
  const reader = stream.getReader();
1446
1442
  try {
1447
1443
  let buffer = "";
@@ -1455,7 +1451,7 @@ const deserializeStream = async function* (stream, ctxElm, abortSignal) {
1455
1451
  const lines = buffer.split(/\n/);
1456
1452
  buffer = lines.pop();
1457
1453
  for (const line of lines) {
1458
- const [deserializedData] = _deserialize(line, ctxElm);
1454
+ const [deserializedData] = _deserialize(line);
1459
1455
  yield deserializedData;
1460
1456
  }
1461
1457
  }
@@ -1322,6 +1322,9 @@ async function requestHandler(serverRequestEv, opts) {
1322
1322
  throw new Error("qwikRouterConfig is required.");
1323
1323
  }
1324
1324
  const { pathname, isInternal } = getRouteMatchPathname(serverRequestEv.url.pathname);
1325
+ if (pathname === "/.well-known" || pathname.startsWith("/.well-known/")) {
1326
+ return null;
1327
+ }
1325
1328
  const routeAndHandlers = await loadRequestHandlers(
1326
1329
  qwikRouterConfig,
1327
1330
  pathname,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qwik.dev/router",
3
3
  "description": "The router for Qwik.",
4
- "version": "2.0.0-beta.19",
4
+ "version": "2.0.0-beta.21",
5
5
  "bugs": "https://github.com/QwikDev/qwik/issues",
6
6
  "dependencies": {
7
7
  "@azure/functions": "3.5.1",
@@ -40,7 +40,7 @@
40
40
  "tsm": "2.3.0",
41
41
  "typescript": "5.9.3",
42
42
  "uvu": "0.5.6",
43
- "@qwik.dev/core": "2.0.0-beta.19"
43
+ "@qwik.dev/core": "2.0.0-beta.21"
44
44
  },
45
45
  "engines": {
46
46
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
@@ -169,7 +169,7 @@
169
169
  "main": "./lib/index.qwik.mjs",
170
170
  "peerDependencies": {
171
171
  "vite": ">=5 <8",
172
- "@qwik.dev/core": "^2.0.0-beta.19"
172
+ "@qwik.dev/core": "^2.0.0-beta.21"
173
173
  },
174
174
  "publishConfig": {
175
175
  "access": "public"