@qwik.dev/router 2.0.0-beta.7 → 2.0.0-beta.9

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.
@@ -316,16 +316,17 @@ const Link = core.component$((props) => {
316
316
  event.preventDefault();
317
317
  }
318
318
  }) : void 0;
319
- const handleClick = clientNavPath ? core.$(async (event, elm) => {
319
+ const handleClick = clientNavPath ? core.$((event, elm) => {
320
320
  if (event.defaultPrevented) {
321
321
  if (elm.href) {
322
322
  elm.setAttribute("aria-pressed", "true");
323
- await nav(elm.href, {
323
+ nav(elm.href, {
324
324
  forceReload: reload,
325
325
  replaceState,
326
326
  scroll
327
+ }).then(() => {
328
+ elm.removeAttribute("aria-pressed");
327
329
  });
328
- elm.removeAttribute("aria-pressed");
329
330
  }
330
331
  }
331
332
  }) : void 0;
@@ -880,12 +881,13 @@ const useQwikRouter = (props) => {
880
881
  }
881
882
  }
882
883
  const url = new URL(urlEnv);
883
- const routeLocation = core.useStore({
884
+ const routeLocationTarget = {
884
885
  url,
885
886
  params: env.params,
886
887
  isNavigating: false,
887
888
  prevUrl: void 0
888
- }, {
889
+ };
890
+ const routeLocation = core.useStore(routeLocationTarget, {
889
891
  deep: false
890
892
  });
891
893
  const navResolver = {};
@@ -1107,13 +1109,27 @@ const useQwikRouter = (props) => {
1107
1109
  if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
1108
1110
  trackUrl.search = navigation.dest.search;
1109
1111
  }
1112
+ let shouldForcePrevUrl = false;
1113
+ let shouldForceUrl = false;
1114
+ let shouldForceParams = false;
1110
1115
  if (!isSamePath(trackUrl, prevUrl)) {
1111
- routeLocation.prevUrl = prevUrl;
1116
+ if (internal._hasStoreEffects(routeLocation, "prevUrl")) {
1117
+ shouldForcePrevUrl = true;
1118
+ }
1119
+ routeLocationTarget.prevUrl = prevUrl;
1120
+ }
1121
+ if (routeLocationTarget.url !== trackUrl) {
1122
+ if (internal._hasStoreEffects(routeLocation, "url")) {
1123
+ shouldForceUrl = true;
1124
+ }
1125
+ routeLocationTarget.url = trackUrl;
1126
+ }
1127
+ if (routeLocationTarget.params !== params) {
1128
+ if (internal._hasStoreEffects(routeLocation, "params")) {
1129
+ shouldForceParams = true;
1130
+ }
1131
+ routeLocationTarget.params = params;
1112
1132
  }
1113
- routeLocation.url = trackUrl;
1114
- routeLocation.params = {
1115
- ...params
1116
- };
1117
1133
  routeInternal.untrackedValue = {
1118
1134
  type: navType,
1119
1135
  dest: trackUrl
@@ -1121,7 +1137,7 @@ const useQwikRouter = (props) => {
1121
1137
  const resolvedHead = resolveHead(clientPageData, routeLocation, contentModules, locale, serverHead);
1122
1138
  content.headings = pageModule.headings;
1123
1139
  content.menu = menu;
1124
- contentInternal.value = core.noSerialize(contentModules);
1140
+ contentInternal.untrackedValue = core.noSerialize(contentModules);
1125
1141
  documentHead.links = resolvedHead.links;
1126
1142
  documentHead.meta = resolvedHead.meta;
1127
1143
  documentHead.styles = resolvedHead.styles;
@@ -1263,6 +1279,7 @@ const useQwikRouter = (props) => {
1263
1279
  }
1264
1280
  const navigate = () => {
1265
1281
  clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
1282
+ contentInternal.force();
1266
1283
  return internal._waitUntilRendered(elm);
1267
1284
  };
1268
1285
  const _waitNextPage = () => {
@@ -1290,6 +1307,15 @@ const useQwikRouter = (props) => {
1290
1307
  if (core.isBrowser) {
1291
1308
  callRestoreScrollOnDocument();
1292
1309
  }
1310
+ if (shouldForcePrevUrl) {
1311
+ internal.forceStoreEffects(routeLocation, "prevUrl");
1312
+ }
1313
+ if (shouldForceUrl) {
1314
+ internal.forceStoreEffects(routeLocation, "url");
1315
+ }
1316
+ if (shouldForceParams) {
1317
+ internal.forceStoreEffects(routeLocation, "params");
1318
+ }
1293
1319
  routeLocation.isNavigating = false;
1294
1320
  navResolver.r?.();
1295
1321
  });
@@ -1357,13 +1383,14 @@ const RouterOutlet = core.component$(() => {
1357
1383
  if (!serverData) {
1358
1384
  throw new Error("PrefetchServiceWorker component must be rendered on the server.");
1359
1385
  }
1360
- const { value } = core.useContext(ContentInternalContext);
1361
- if (value && value.length > 0) {
1362
- const contentsLen = value.length;
1386
+ const internalContext = core.useContext(ContentInternalContext);
1387
+ const contents = internalContext.value;
1388
+ if (contents && contents.length > 0) {
1389
+ const contentsLen = contents.length;
1363
1390
  let cmp = null;
1364
1391
  for (let i = contentsLen - 1; i >= 0; i--) {
1365
- if (value[i].default) {
1366
- cmp = core.jsx(value[i].default, {
1392
+ if (contents[i].default) {
1393
+ cmp = core.jsx(contents[i].default, {
1367
1394
  children: cmp
1368
1395
  });
1369
1396
  }
@@ -1690,7 +1717,7 @@ const zodQrl = (qrl) => {
1690
1717
  }
1691
1718
  });
1692
1719
  const data = inputData ?? await ev.parseBody();
1693
- const result = await schema.safeParseAsync(data);
1720
+ const result = await core.withLocale(ev.locale(), () => schema.safeParseAsync(data));
1694
1721
  if (result.success) {
1695
1722
  return result;
1696
1723
  } else {
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from "@qwik.dev/core/jsx-runtime";
2
2
  import { component$, useErrorBoundary, useOnWindow, $, Slot, createAsyncComputed$, isBrowser, createContextId, implicit$FirstArg, useContext, useVisibleTask$, noSerialize, useServerData, useSignal, untrack, sync$, isDev, withLocale, event$, useStyles$, isServer, useStore, useContextProvider, useTask$, getLocale, jsx as jsx$1, SkipRender, createElement } from "@qwik.dev/core";
3
3
  import { p } from "@qwik.dev/core/preloader";
4
- import { _deserialize, _UNINITIALIZED, _getContextContainer, SerializerSymbol, _getContextElement, _getQContainerElement, _waitUntilRendered, _resolveContextWithoutSequentialScope, _getContextEvent, _serialize } from "@qwik.dev/core/internal";
4
+ import { _deserialize, _UNINITIALIZED, _getContextContainer, SerializerSymbol, _getContextElement, _hasStoreEffects, _getQContainerElement, forceStoreEffects, _waitUntilRendered, _resolveContextWithoutSequentialScope, _getContextEvent, _serialize } from "@qwik.dev/core/internal";
5
5
  import * as qwikRouterConfig from "@qwik-router-config";
6
6
  import { z } from "zod";
7
7
  import { z as z2 } from "zod";
@@ -298,16 +298,17 @@ const Link = component$((props) => {
298
298
  event.preventDefault();
299
299
  }
300
300
  }) : void 0;
301
- const handleClick = clientNavPath ? $(async (event, elm) => {
301
+ const handleClick = clientNavPath ? $((event, elm) => {
302
302
  if (event.defaultPrevented) {
303
303
  if (elm.href) {
304
304
  elm.setAttribute("aria-pressed", "true");
305
- await nav(elm.href, {
305
+ nav(elm.href, {
306
306
  forceReload: reload,
307
307
  replaceState,
308
308
  scroll
309
+ }).then(() => {
310
+ elm.removeAttribute("aria-pressed");
309
311
  });
310
- elm.removeAttribute("aria-pressed");
311
312
  }
312
313
  }
313
314
  }) : void 0;
@@ -862,12 +863,13 @@ const useQwikRouter = (props) => {
862
863
  }
863
864
  }
864
865
  const url = new URL(urlEnv);
865
- const routeLocation = useStore({
866
+ const routeLocationTarget = {
866
867
  url,
867
868
  params: env.params,
868
869
  isNavigating: false,
869
870
  prevUrl: void 0
870
- }, {
871
+ };
872
+ const routeLocation = useStore(routeLocationTarget, {
871
873
  deep: false
872
874
  });
873
875
  const navResolver = {};
@@ -1089,13 +1091,27 @@ const useQwikRouter = (props) => {
1089
1091
  if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
1090
1092
  trackUrl.search = navigation.dest.search;
1091
1093
  }
1094
+ let shouldForcePrevUrl = false;
1095
+ let shouldForceUrl = false;
1096
+ let shouldForceParams = false;
1092
1097
  if (!isSamePath(trackUrl, prevUrl)) {
1093
- routeLocation.prevUrl = prevUrl;
1098
+ if (_hasStoreEffects(routeLocation, "prevUrl")) {
1099
+ shouldForcePrevUrl = true;
1100
+ }
1101
+ routeLocationTarget.prevUrl = prevUrl;
1102
+ }
1103
+ if (routeLocationTarget.url !== trackUrl) {
1104
+ if (_hasStoreEffects(routeLocation, "url")) {
1105
+ shouldForceUrl = true;
1106
+ }
1107
+ routeLocationTarget.url = trackUrl;
1108
+ }
1109
+ if (routeLocationTarget.params !== params) {
1110
+ if (_hasStoreEffects(routeLocation, "params")) {
1111
+ shouldForceParams = true;
1112
+ }
1113
+ routeLocationTarget.params = params;
1094
1114
  }
1095
- routeLocation.url = trackUrl;
1096
- routeLocation.params = {
1097
- ...params
1098
- };
1099
1115
  routeInternal.untrackedValue = {
1100
1116
  type: navType,
1101
1117
  dest: trackUrl
@@ -1103,7 +1119,7 @@ const useQwikRouter = (props) => {
1103
1119
  const resolvedHead = resolveHead(clientPageData, routeLocation, contentModules, locale, serverHead);
1104
1120
  content.headings = pageModule.headings;
1105
1121
  content.menu = menu;
1106
- contentInternal.value = noSerialize(contentModules);
1122
+ contentInternal.untrackedValue = noSerialize(contentModules);
1107
1123
  documentHead.links = resolvedHead.links;
1108
1124
  documentHead.meta = resolvedHead.meta;
1109
1125
  documentHead.styles = resolvedHead.styles;
@@ -1245,6 +1261,7 @@ const useQwikRouter = (props) => {
1245
1261
  }
1246
1262
  const navigate = () => {
1247
1263
  clientNavigate(window, navType, prevUrl, trackUrl, replaceState);
1264
+ contentInternal.force();
1248
1265
  return _waitUntilRendered(elm);
1249
1266
  };
1250
1267
  const _waitNextPage = () => {
@@ -1272,6 +1289,15 @@ const useQwikRouter = (props) => {
1272
1289
  if (isBrowser) {
1273
1290
  callRestoreScrollOnDocument();
1274
1291
  }
1292
+ if (shouldForcePrevUrl) {
1293
+ forceStoreEffects(routeLocation, "prevUrl");
1294
+ }
1295
+ if (shouldForceUrl) {
1296
+ forceStoreEffects(routeLocation, "url");
1297
+ }
1298
+ if (shouldForceParams) {
1299
+ forceStoreEffects(routeLocation, "params");
1300
+ }
1275
1301
  routeLocation.isNavigating = false;
1276
1302
  navResolver.r?.();
1277
1303
  });
@@ -1339,13 +1365,14 @@ const RouterOutlet = component$(() => {
1339
1365
  if (!serverData) {
1340
1366
  throw new Error("PrefetchServiceWorker component must be rendered on the server.");
1341
1367
  }
1342
- const { value } = useContext(ContentInternalContext);
1343
- if (value && value.length > 0) {
1344
- const contentsLen = value.length;
1368
+ const internalContext = useContext(ContentInternalContext);
1369
+ const contents = internalContext.value;
1370
+ if (contents && contents.length > 0) {
1371
+ const contentsLen = contents.length;
1345
1372
  let cmp = null;
1346
1373
  for (let i = contentsLen - 1; i >= 0; i--) {
1347
- if (value[i].default) {
1348
- cmp = jsx$1(value[i].default, {
1374
+ if (contents[i].default) {
1375
+ cmp = jsx$1(contents[i].default, {
1349
1376
  children: cmp
1350
1377
  });
1351
1378
  }
@@ -1672,7 +1699,7 @@ const zodQrl = (qrl) => {
1672
1699
  }
1673
1700
  });
1674
1701
  const data = inputData ?? await ev.parseBody();
1675
- const result = await schema.safeParseAsync(data);
1702
+ const result = await withLocale(ev.locale(), () => schema.safeParseAsync(data));
1676
1703
  if (result.success) {
1677
1704
  return result;
1678
1705
  } else {
@@ -24,9 +24,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  mod
25
25
  ));
26
26
 
27
- // node_modules/.pnpm/set-cookie-parser@2.6.0/node_modules/set-cookie-parser/lib/set-cookie.js
27
+ // node_modules/.pnpm/set-cookie-parser@2.7.1/node_modules/set-cookie-parser/lib/set-cookie.js
28
28
  var require_set_cookie = __commonJS({
29
- "node_modules/.pnpm/set-cookie-parser@2.6.0/node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
29
+ "node_modules/.pnpm/set-cookie-parser@2.7.1/node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
30
30
  "use strict";
31
31
  var defaultParseOptions = {
32
32
  decodeValues: true,
@@ -69,6 +69,8 @@ var require_set_cookie = __commonJS({
69
69
  cookie.httpOnly = true;
70
70
  } else if (key === "samesite") {
71
71
  cookie.sameSite = value2;
72
+ } else if (key === "partitioned") {
73
+ cookie.partitioned = true;
72
74
  } else {
73
75
  cookie[key] = value2;
74
76
  }
@@ -116,7 +118,6 @@ var require_set_cookie = __commonJS({
116
118
  if (!Array.isArray(input)) {
117
119
  input = [input];
118
120
  }
119
- options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
120
121
  if (!options.map) {
121
122
  return input.filter(isNonEmptyString).map(function(str) {
122
123
  return parseString2(str, options);
package/lib/ssg/node.cjs CHANGED
@@ -99,6 +99,7 @@ var import_request_handler = require("../middleware/request-handler/index.cjs");
99
99
  var import_web = require("node:stream/web");
100
100
  var import_node_url = require("node:url");
101
101
  async function workerThread(sys) {
102
+ delete globalThis.__qwik;
102
103
  const ssgOpts = sys.getOptions();
103
104
  const pendingPromises = /* @__PURE__ */ new Set();
104
105
  const opts = {
@@ -123,6 +124,7 @@ async function workerThread(sys) {
123
124
  });
124
125
  }
125
126
  async function createSingleThreadWorker(sys) {
127
+ delete globalThis.__qwik;
126
128
  const ssgOpts = sys.getOptions();
127
129
  const pendingPromises = /* @__PURE__ */ new Set();
128
130
  const opts = {
package/lib/ssg/node.mjs CHANGED
@@ -63,6 +63,7 @@ import { requestHandler, RequestEvShareQData } from "../middleware/request-handl
63
63
  import { WritableStream } from "node:stream/web";
64
64
  import { pathToFileURL } from "node:url";
65
65
  async function workerThread(sys) {
66
+ delete globalThis.__qwik;
66
67
  const ssgOpts = sys.getOptions();
67
68
  const pendingPromises = /* @__PURE__ */ new Set();
68
69
  const opts = {
@@ -87,6 +88,7 @@ async function workerThread(sys) {
87
88
  });
88
89
  }
89
90
  async function createSingleThreadWorker(sys) {
91
+ delete globalThis.__qwik;
90
92
  const ssgOpts = sys.getOptions();
91
93
  const pendingPromises = /* @__PURE__ */ new Set();
92
94
  const opts = {