@qwik.dev/router 2.0.0-alpha.3 → 2.0.0-alpha.4

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.
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("@qwik.dev/core/jsx-runtime");
4
4
  const core = require("@qwik.dev/core");
5
- const build = require("@qwik.dev/core/build");
6
5
  const internal = require("@qwik.dev/core/internal");
7
6
  const qwikRouterConfig = require("@qwik-router-config");
8
7
  const zod = require("zod");
@@ -120,7 +119,7 @@ const newScrollState = () => {
120
119
  };
121
120
  };
122
121
  const prefetchSymbols = (path) => {
123
- if (build.isBrowser) {
122
+ if (core.isBrowser) {
124
123
  path = path.endsWith("/") ? path : path + "/";
125
124
  if (!PREFETCHED_NAVIGATE_PATHS.has(path)) {
126
125
  PREFETCHED_NAVIGATE_PATHS.add(path);
@@ -321,7 +320,7 @@ const Link = core.component$((props) => {
321
320
  // Don't prefetch on visible in dev mode
322
321
  onQVisible$: [
323
322
  linkProps.onQVisible$,
324
- !build.isDev ? handlePrefetch : void 0
323
+ !core.isDev ? handlePrefetch : void 0
325
324
  ],
326
325
  children: /* @__PURE__ */ jsxRuntime.jsx(core.Slot, {})
327
326
  });
@@ -678,7 +677,7 @@ const spaInit = core.event$((_, el) => {
678
677
  state = {
679
678
  _data: state
680
679
  };
681
- if (build.isDev) {
680
+ if (core.isDev) {
682
681
  console.warn("In a Qwik SPA context, `history.state` is used to store scroll state. Direct calls to `pushState()` and `replaceState()` must supply an actual Object type. We need to be able to automatically attach the scroll state to your state object. A new state object has been created, your data has been moved to: `history.state._data`");
683
682
  }
684
683
  }
@@ -816,7 +815,7 @@ const QwikRouterProvider = core.component$((props) => {
816
815
  }
817
816
  } : void 0);
818
817
  const registerPreventNav = core.$((fn$) => {
819
- if (!build.isBrowser) {
818
+ if (!core.isBrowser) {
820
819
  return;
821
820
  }
822
821
  preventNav.$handler$ || (preventNav.$handler$ = (event) => {
@@ -865,19 +864,19 @@ const QwikRouterProvider = core.component$((props) => {
865
864
  }
866
865
  }
867
866
  if (typeof dest === "number") {
868
- if (build.isBrowser) {
867
+ if (core.isBrowser) {
869
868
  history.go(dest);
870
869
  }
871
870
  return;
872
871
  }
873
872
  if (!isSameOrigin(dest, lastDest)) {
874
- if (build.isBrowser) {
873
+ if (core.isBrowser) {
875
874
  location.href = dest.href;
876
875
  }
877
876
  return;
878
877
  }
879
878
  if (!forceReload && isSamePath(dest, lastDest)) {
880
- if (build.isBrowser) {
879
+ if (core.isBrowser) {
881
880
  if (type === "link" && dest.href !== location.href) {
882
881
  history.pushState(null, "", dest);
883
882
  }
@@ -905,7 +904,7 @@ const QwikRouterProvider = core.component$((props) => {
905
904
  replaceState,
906
905
  scroll
907
906
  };
908
- if (build.isBrowser) {
907
+ if (core.isBrowser) {
909
908
  loadClientData(dest, internal._getContextElement());
910
909
  loadRoute(qwikRouterConfig__namespace.routes, qwikRouterConfig__namespace.menus, qwikRouterConfig__namespace.cacheModules, dest.pathname);
911
910
  }
@@ -938,7 +937,7 @@ const QwikRouterProvider = core.component$((props) => {
938
937
  let clientPageData;
939
938
  let loadedRoute = null;
940
939
  let elm;
941
- if (build.isServer) {
940
+ if (core.isServer) {
942
941
  trackUrl = new URL(navigation.dest, routeLocation.url);
943
942
  loadedRoute = env.loadedRoute;
944
943
  clientPageData = env.response;
@@ -1006,7 +1005,7 @@ const QwikRouterProvider = core.component$((props) => {
1006
1005
  documentHead.scripts = resolvedHead.scripts;
1007
1006
  documentHead.title = resolvedHead.title;
1008
1007
  documentHead.frontmatter = resolvedHead.frontmatter;
1009
- if (build.isBrowser) {
1008
+ if (core.isBrowser) {
1010
1009
  if (props.viewTransition !== false) {
1011
1010
  document.__q_view_transition__ = true;
1012
1011
  }
@@ -1047,7 +1046,7 @@ const QwikRouterProvider = core.component$((props) => {
1047
1046
  state = {
1048
1047
  _data: state
1049
1048
  };
1050
- if (build.isDev) {
1049
+ if (core.isDev) {
1051
1050
  console.warn("In a Qwik SPA context, `history.state` is used to store scroll state. Direct calls to `pushState()` and `replaceState()` must supply an actual Object type. We need to be able to automatically attach the scroll state to your state object. A new state object has been created, your data has been moved to: `history.state._data`");
1052
1051
  }
1053
1052
  }
@@ -1141,7 +1140,7 @@ const QwikRouterProvider = core.component$((props) => {
1141
1140
  const scrollState2 = currentScrollState(scroller);
1142
1141
  saveScrollHistory(scrollState2);
1143
1142
  win._qRouterScrollEnabled = true;
1144
- if (build.isBrowser) {
1143
+ if (core.isBrowser) {
1145
1144
  callRestoreScrollOnDocument();
1146
1145
  }
1147
1146
  routeLocation.isNavigating = false;
@@ -1151,7 +1150,7 @@ const QwikRouterProvider = core.component$((props) => {
1151
1150
  }
1152
1151
  }
1153
1152
  const promise = run();
1154
- if (build.isServer) {
1153
+ if (core.isServer) {
1155
1154
  return promise;
1156
1155
  } else {
1157
1156
  return;
@@ -1339,7 +1338,7 @@ const routeActionQrl = (actionQrl, ...rest) => {
1339
1338
  return initialState;
1340
1339
  });
1341
1340
  const submit = core.$((input = {}) => {
1342
- if (build.isServer) {
1341
+ if (core.isServer) {
1343
1342
  throw new Error(`Actions can not be invoked within the server during SSR.
1344
1343
  Action.run() can only be called on the browser, for example when a user clicks a button, or submits a form.`);
1345
1344
  }
@@ -1405,7 +1404,7 @@ Action.run() can only be called on the browser, for example when a user clicks a
1405
1404
  };
1406
1405
  const globalActionQrl = (actionQrl, ...rest) => {
1407
1406
  const action = routeActionQrl(actionQrl, ...rest);
1408
- if (build.isServer) {
1407
+ if (core.isServer) {
1409
1408
  if (typeof globalThis._qwikActionsMap === "undefined") {
1410
1409
  globalThis._qwikActionsMap = /* @__PURE__ */ new Map();
1411
1410
  }
@@ -1439,7 +1438,7 @@ const routeLoaderQrl = (loaderQrl, ...rest) => {
1439
1438
  };
1440
1439
  const routeLoader$ = /* @__PURE__ */ core.implicit$FirstArg(routeLoaderQrl);
1441
1440
  const validatorQrl = (validator) => {
1442
- if (build.isServer) {
1441
+ if (core.isServer) {
1443
1442
  return {
1444
1443
  validate: validator
1445
1444
  };
@@ -1470,7 +1469,7 @@ const valibotQrl = (qrl) => {
1470
1469
  if (!__EXPERIMENTAL__.valibot) {
1471
1470
  throw new Error('Valibot is an experimental feature and is not enabled. Please enable the feature flag by adding `experimental: ["valibot"]` to your qwikVite plugin options.');
1472
1471
  }
1473
- if (build.isServer) {
1472
+ if (core.isServer) {
1474
1473
  return {
1475
1474
  __brand: "valibot",
1476
1475
  async validate(ev, inputData) {
@@ -1483,7 +1482,7 @@ const valibotQrl = (qrl) => {
1483
1482
  data: result.output
1484
1483
  };
1485
1484
  } else {
1486
- if (build.isDev) {
1485
+ if (core.isDev) {
1487
1486
  console.error("ERROR: Valibot validation failed", result.issues);
1488
1487
  }
1489
1488
  return {
@@ -1523,7 +1522,7 @@ const flattenZodIssues = (issues) => {
1523
1522
  }, {});
1524
1523
  };
1525
1524
  const zodQrl = (qrl) => {
1526
- if (build.isServer) {
1525
+ if (core.isServer) {
1527
1526
  return {
1528
1527
  __brand: "zod",
1529
1528
  async validate(ev, inputData) {
@@ -1542,7 +1541,7 @@ const zodQrl = (qrl) => {
1542
1541
  if (result.success) {
1543
1542
  return result;
1544
1543
  } else {
1545
- if (build.isDev) {
1544
+ if (core.isDev) {
1546
1545
  console.error("ERROR: Zod validation failed", result.error.issues);
1547
1546
  }
1548
1547
  return {
@@ -1561,7 +1560,7 @@ const zodQrl = (qrl) => {
1561
1560
  };
1562
1561
  const zod$ = /* @__PURE__ */ core.implicit$FirstArg(zodQrl);
1563
1562
  const serverQrl = (qrl, options) => {
1564
- if (build.isServer) {
1563
+ if (core.isServer) {
1565
1564
  const captured = qrl.getCaptured();
1566
1565
  if (captured && captured.length > 0 && !internal._getContextElement()) {
1567
1566
  throw new Error("For security reasons, we cannot serialize QRLs that capture lexical scope.");
@@ -1574,7 +1573,7 @@ const serverQrl = (qrl, options) => {
1574
1573
  function rpc() {
1575
1574
  return core.$(async function(...args) {
1576
1575
  const abortSignal = args.length > 0 && args[0] instanceof AbortSignal ? args.shift() : void 0;
1577
- if (build.isServer) {
1576
+ if (core.isServer) {
1578
1577
  let requestEvent = globalThis.qcAsyncRequestStore?.getStore();
1579
1578
  if (!requestEvent) {
1580
1579
  const contexts = [
@@ -1584,7 +1583,7 @@ const serverQrl = (qrl, options) => {
1584
1583
  ];
1585
1584
  requestEvent = contexts.find((v2) => v2 && Object.prototype.hasOwnProperty.call(v2, "sharedMap") && Object.prototype.hasOwnProperty.call(v2, "cookie"));
1586
1585
  }
1587
- return qrl.apply(requestEvent, build.isDev ? deepFreeze(args) : args);
1586
+ return qrl.apply(requestEvent, core.isDev ? deepFreeze(args) : args);
1588
1587
  } else {
1589
1588
  const ctxElm = internal._getContextElement();
1590
1589
  const filteredArgs = args.map((arg) => {
@@ -1678,7 +1677,7 @@ const getValidators = (rest, qrl) => {
1678
1677
  validators.push(...rest.filter((v2) => !!v2));
1679
1678
  }
1680
1679
  if (typeof id === "string") {
1681
- if (build.isDev) {
1680
+ if (core.isDev) {
1682
1681
  if (!/^[\w/.-]+$/.test(id)) {
1683
1682
  throw new Error(`Invalid id: ${id}, id can only contain [a-zA-Z0-9_.-]`);
1684
1683
  }
@@ -1,6 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "@qwik.dev/core/jsx-runtime";
2
- import { createContextId, implicit$FirstArg, useContext, useVisibleTask$, noSerialize, useServerData, component$, untrack, $, sync$, Slot, withLocale, event$, useStyles$, useStore, useSignal, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender } from "@qwik.dev/core";
3
- import { isBrowser, isDev, isServer } from "@qwik.dev/core/build";
2
+ import { isBrowser, createContextId, implicit$FirstArg, useContext, useVisibleTask$, noSerialize, useServerData, component$, untrack, $, sync$, isDev, Slot, withLocale, event$, useStyles$, useStore, useSignal, useContextProvider, useTask$, isServer, getLocale, jsx as jsx$1, SkipRender } from "@qwik.dev/core";
4
3
  import { _deserialize, _weakSerialize, _getContextElement, _waitUntilRendered, _getQContainerElement, _wrapProp, _getContextEvent, _serialize } from "@qwik.dev/core/internal";
5
4
  import * as qwikRouterConfig from "@qwik-router-config";
6
5
  import { z } from "zod";
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-alpha.3",
4
+ "version": "2.0.0-alpha.4",
5
5
  "bugs": "https://github.com/QwikDev/qwik/issues",
6
6
  "dependencies": {
7
7
  "@mdx-js/mdx": "^3",
@@ -41,7 +41,7 @@
41
41
  "unist-util-visit": "5.0.0",
42
42
  "uvu": "0.5.6",
43
43
  "yaml": "2.4.5",
44
- "@qwik.dev/core": "2.0.0-alpha.3"
44
+ "@qwik.dev/core": "2.0.0-alpha.4"
45
45
  },
46
46
  "engines": {
47
47
  "node": "^18.17.0 || ^20.3.0 || >=21.0.0"