@qwik.dev/router 2.0.0-beta.4 → 2.0.0-beta.6

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.
Files changed (49) hide show
  1. package/adapters/static/vite.d.ts +1 -1
  2. package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
  3. package/lib/adapters/bun-server/vite/index.d.ts +2 -2
  4. package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
  5. package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
  6. package/lib/adapters/deno-server/vite/index.d.ts +2 -2
  7. package/lib/adapters/netlify-edge/vite/index.cjs +1 -0
  8. package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
  9. package/lib/adapters/netlify-edge/vite/index.mjs +1 -0
  10. package/lib/adapters/node-server/vite/index.d.ts +2 -2
  11. package/lib/adapters/shared/vite/index.cjs +88 -128
  12. package/lib/adapters/shared/vite/index.d.ts +9 -15
  13. package/lib/adapters/shared/vite/index.mjs +88 -124
  14. package/lib/adapters/{static → ssg}/vite/index.cjs +95 -124
  15. package/lib/adapters/ssg/vite/index.d.ts +13 -0
  16. package/lib/adapters/{static → ssg}/vite/index.mjs +93 -123
  17. package/lib/adapters/vercel-edge/vite/index.d.ts +2 -2
  18. package/lib/index.qwik.cjs +9 -11
  19. package/lib/index.qwik.mjs +10 -12
  20. package/lib/middleware/aws-lambda/index.d.ts +3 -2
  21. package/lib/middleware/aws-lambda/index.mjs +2 -4
  22. package/lib/middleware/azure-swa/index.mjs +6 -6
  23. package/lib/middleware/bun/index.mjs +4 -6
  24. package/lib/middleware/cloudflare-pages/index.mjs +4 -6
  25. package/lib/middleware/deno/index.mjs +8 -7
  26. package/lib/middleware/firebase/index.mjs +1 -3
  27. package/lib/middleware/netlify-edge/index.mjs +7 -6
  28. package/lib/middleware/node/index.cjs +4 -8
  29. package/lib/middleware/node/index.mjs +7 -7
  30. package/lib/middleware/request-handler/index.cjs +343 -268
  31. package/lib/middleware/request-handler/index.d.ts +19 -7
  32. package/lib/middleware/request-handler/index.mjs +347 -264
  33. package/lib/middleware/vercel-edge/index.mjs +7 -6
  34. package/lib/modules.d.ts +4 -12
  35. package/lib/{static → ssg}/deno.mjs +1 -1
  36. package/lib/{static → ssg}/index.cjs +1 -1
  37. package/lib/{static → ssg}/index.d.ts +17 -17
  38. package/lib/{static → ssg}/index.mjs +1 -1
  39. package/lib/{static → ssg}/node.cjs +16 -16
  40. package/lib/{static → ssg}/node.mjs +15 -15
  41. package/lib/vite/index.cjs +10264 -10429
  42. package/lib/vite/index.mjs +5871 -6026
  43. package/modules.d.ts +4 -12
  44. package/package.json +19 -8
  45. package/ssg.d.ts +2 -0
  46. package/static.d.ts +1 -1
  47. package/lib/adapters/static/vite/index.d.ts +0 -10
  48. package/middleware/request-handler/generated/not-found-paths.ts +0 -7
  49. package/middleware/request-handler/generated/static-paths.ts +0 -35
@@ -1,16 +1,18 @@
1
1
  // packages/qwik-router/src/adapters/shared/vite/index.ts
2
- import fs2 from "node:fs";
3
2
  import { basename, dirname, join as join2, resolve } from "node:path";
4
3
 
5
4
  // packages/qwik-router/src/adapters/shared/vite/post-build.ts
6
5
  import { getErrorHtml } from "@qwik.dev/router/middleware/request-handler";
7
6
  import fs from "node:fs";
8
7
  import { join } from "node:path";
9
- async function postBuild(clientOutDir, pathName, userStaticPaths, format, cleanStatic) {
8
+ async function postBuild(clientOutDir, serverOutDir, pathName, userStaticPaths, cleanStatic) {
10
9
  if (pathName && !pathName.endsWith("/")) {
11
10
  pathName += "/";
12
11
  }
13
- const ignorePathnames = /* @__PURE__ */ new Set([pathName + "build/", pathName + "assets/"]);
12
+ const ignorePathnames = /* @__PURE__ */ new Set([
13
+ pathName + "/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/",
14
+ pathName + "/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/"
15
+ ]);
14
16
  const staticPaths = new Set(userStaticPaths.map(normalizeTrailingSlash));
15
17
  const notFounds = [];
16
18
  const loadItem = async (fsDir, fsName, pathname) => {
@@ -44,12 +46,9 @@ async function postBuild(clientOutDir, pathName, userStaticPaths, format, cleanS
44
46
  if (fs.existsSync(clientOutDir)) {
45
47
  await loadDir(clientOutDir, pathName);
46
48
  }
47
- const notFoundPathsCode = createNotFoundPathsModule(pathName, notFounds, format);
48
- const staticPathsCode = createStaticPathsModule(pathName, staticPaths, format);
49
- return {
50
- notFoundPathsCode,
51
- staticPathsCode
52
- };
49
+ const notFoundPathsCode = createNotFoundPathsCode(pathName, notFounds);
50
+ const staticPathsCode = createStaticPathsCode(staticPaths);
51
+ await injectStatics(staticPathsCode, notFoundPathsCode, serverOutDir);
53
52
  }
54
53
  function normalizeTrailingSlash(pathname) {
55
54
  if (!pathname.endsWith("/")) {
@@ -57,7 +56,7 @@ function normalizeTrailingSlash(pathname) {
57
56
  }
58
57
  return pathname;
59
58
  }
60
- function createNotFoundPathsModule(basePathname, notFounds, format) {
59
+ function createNotFoundPathsCode(basePathname, notFounds) {
61
60
  notFounds.sort((a, b) => {
62
61
  if (a[0].length > b[0].length) {
63
62
  return -1;
@@ -77,64 +76,43 @@ function createNotFoundPathsModule(basePathname, notFounds, format) {
77
76
  const html = getErrorHtml(404, "Resource Not Found");
78
77
  notFounds.push([basePathname, html]);
79
78
  }
80
- const c = [];
81
- c.push(`const notFounds = ${JSON.stringify(notFounds, null, 2)};`);
82
- c.push(`function getNotFound(p) {`);
83
- c.push(` for (const r of notFounds) {`);
84
- c.push(` if (p.startsWith(r[0])) {`);
85
- c.push(` return r[1];`);
86
- c.push(` }`);
87
- c.push(` }`);
88
- c.push(` return "Resource Not Found";`);
89
- c.push(`}`);
90
- if (format === "cjs") {
91
- c.push("exports.getNotFound = getNotFound;");
92
- } else {
93
- c.push("export { getNotFound };");
94
- }
95
- return c.join("\n");
79
+ return JSON.stringify(notFounds, null, 2).slice(1, -1);
96
80
  }
97
- function createStaticPathsModule(basePathname, staticPaths, format) {
98
- const assetsPath = basePathname + "assets/";
99
- const baseBuildPath = basePathname + "build/";
100
- const c = [];
101
- c.push(
102
- `const staticPaths = new Set(${JSON.stringify(
103
- Array.from(new Set(staticPaths)).sort()
104
- )});`
105
- );
106
- c.push(`function isStaticPath(method, url) {`);
107
- c.push(` if (method.toUpperCase() !== 'GET') {`);
108
- c.push(` return false;`);
109
- c.push(` }`);
110
- c.push(` const p = url.pathname;`);
111
- c.push(` if (p.startsWith(${JSON.stringify(baseBuildPath)})) {`);
112
- c.push(` return true;`);
113
- c.push(` }`);
114
- c.push(` if (p.startsWith(${JSON.stringify(assetsPath)})) {`);
115
- c.push(` return true;`);
116
- c.push(` }`);
117
- c.push(` if (staticPaths.has(p)) {`);
118
- c.push(` return true;`);
119
- c.push(` }`);
120
- c.push(` if (p.endsWith('/q-data.json')) {`);
121
- c.push(` const pWithoutQdata = p.replace(/\\/q-data.json$/, '');`);
122
- c.push(` if (staticPaths.has(pWithoutQdata + '/')) {`);
123
- c.push(` return true;`);
124
- c.push(` }`);
125
- c.push(` if (staticPaths.has(pWithoutQdata)) {`);
126
- c.push(` return true;`);
127
- c.push(` }`);
128
- c.push(` }`);
129
- c.push(` return false;`);
130
- c.push(`}`);
131
- if (format === "cjs") {
132
- c.push("exports.isStaticPath = isStaticPath;");
133
- } else {
134
- c.push("export { isStaticPath };");
135
- }
136
- return c.join("\n");
81
+ function createStaticPathsCode(staticPaths) {
82
+ return JSON.stringify(Array.from(new Set(staticPaths)).sort()).slice(1, -1);
137
83
  }
84
+ var injectStatics = async (staticPathsCode, notFoundPathsCode, outDir) => {
85
+ const promises = /* @__PURE__ */ new Set();
86
+ const doReplace = async (path) => {
87
+ const code = await fs.promises.readFile(path, "utf-8");
88
+ let replaced = false;
89
+ const newCode = code.replace(
90
+ /(['"])__QWIK_ROUTER_(STATIC_PATHS|NOT_FOUND)_ARRAY__\1/g,
91
+ (_, _quote, type) => {
92
+ replaced = true;
93
+ return type === "STATIC_PATHS" ? staticPathsCode : notFoundPathsCode;
94
+ }
95
+ );
96
+ if (replaced) {
97
+ await fs.promises.writeFile(path, newCode);
98
+ }
99
+ };
100
+ const walk = async (dir) => {
101
+ const entries = await fs.promises.readdir(dir, { withFileTypes: true });
102
+ for (const entry of entries) {
103
+ if (entry.isDirectory()) {
104
+ await walk(join(dir, entry.name));
105
+ } else if (entry.name.endsWith("js")) {
106
+ const p = doReplace(join(dir, entry.name)).finally(() => {
107
+ promises.delete(p);
108
+ });
109
+ promises.add(p);
110
+ }
111
+ }
112
+ };
113
+ await walk(outDir);
114
+ await Promise.all(promises);
115
+ };
138
116
 
139
117
  // packages/qwik-router/src/adapters/shared/vite/index.ts
140
118
  function viteAdapter(opts) {
@@ -144,10 +122,9 @@ function viteAdapter(opts) {
144
122
  let renderModulePath = null;
145
123
  let qwikRouterConfigModulePath = null;
146
124
  let isSsrBuild = false;
147
- let format = "esm";
148
125
  const outputEntries = [];
149
126
  const plugin = {
150
- name: `vite-plugin-qwik-router-${opts.name}`,
127
+ name: `vite-plugin-qwik-router-ssg-${opts.name}`,
151
128
  enforce: "post",
152
129
  apply: "build",
153
130
  config(config) {
@@ -161,7 +138,7 @@ function viteAdapter(opts) {
161
138
  return config;
162
139
  },
163
140
  configResolved(config) {
164
- var _a, _b, _c, _d;
141
+ var _a, _b, _c;
165
142
  isSsrBuild = !!config.build.ssr;
166
143
  if (isSsrBuild) {
167
144
  qwikRouterPlugin = config.plugins.find(
@@ -187,9 +164,21 @@ function viteAdapter(opts) {
187
164
  `"build.rollupOptions.input" must be set in order to use the "${opts.name}" adapter.`
188
165
  );
189
166
  }
190
- if (((_d = config.ssr) == null ? void 0 : _d.format) === "cjs") {
191
- format = "cjs";
192
- }
167
+ }
168
+ },
169
+ buildStart() {
170
+ if (isSsrBuild && opts.ssg !== null) {
171
+ const { srcDir } = qwikVitePlugin.api.getOptions();
172
+ this.emitFile({
173
+ id: "@qwik-router-config",
174
+ type: "chunk",
175
+ fileName: "@qwik-router-config.js"
176
+ });
177
+ this.emitFile({
178
+ id: `${srcDir}/entry.ssr`,
179
+ type: "chunk",
180
+ fileName: "entry.ssr.js"
181
+ });
193
182
  }
194
183
  },
195
184
  generateBundle(_, bundles) {
@@ -206,23 +195,13 @@ function viteAdapter(opts) {
206
195
  }
207
196
  }
208
197
  }
209
- if (!renderModulePath) {
210
- throw new Error(
211
- 'Unable to find "entry.ssr" entry point. Did you forget to add it to "build.rollupOptions.input"?'
212
- );
213
- }
214
- if (!qwikRouterConfigModulePath) {
215
- throw new Error(
216
- 'Unable to find "@qwik-router-config" entry point. Did you forget to add it to "build.rollupOptions.input"?'
217
- );
218
- }
219
198
  }
220
199
  },
221
200
  closeBundle: {
222
201
  sequential: true,
223
202
  async handler() {
224
203
  var _a;
225
- if (isSsrBuild && opts.ssg !== null && serverOutDir && (qwikRouterPlugin == null ? void 0 : qwikRouterPlugin.api) && (qwikVitePlugin == null ? void 0 : qwikVitePlugin.api)) {
204
+ if (isSsrBuild && serverOutDir && (qwikRouterPlugin == null ? void 0 : qwikRouterPlugin.api) && (qwikVitePlugin == null ? void 0 : qwikVitePlugin.api)) {
226
205
  const staticPaths = opts.staticPaths || [];
227
206
  const routes = qwikRouterPlugin.api.getRoutes();
228
207
  const basePathname = qwikRouterPlugin.api.getBasePathname();
@@ -230,7 +209,7 @@ function viteAdapter(opts) {
230
209
  const clientPublicOutDir = qwikVitePlugin.api.getClientPublicOutDir();
231
210
  const assetsDir = qwikVitePlugin.api.getAssetsDir();
232
211
  const rootDir = qwikVitePlugin.api.getRootDir() ?? void 0;
233
- if (renderModulePath && qwikRouterConfigModulePath && clientOutDir && clientPublicOutDir) {
212
+ if (opts.ssg !== null && renderModulePath && qwikRouterConfigModulePath && clientOutDir && clientPublicOutDir) {
234
213
  let ssgOrigin = ((_a = opts.ssg) == null ? void 0 : _a.origin) ?? opts.origin;
235
214
  if (!ssgOrigin) {
236
215
  ssgOrigin = `https://yoursite.qwik.dev`;
@@ -243,13 +222,13 @@ function viteAdapter(opts) {
243
222
  }
244
223
  try {
245
224
  ssgOrigin = new URL(ssgOrigin).origin;
246
- } catch (e) {
225
+ } catch {
247
226
  this.warn(
248
227
  `Invalid "origin" option: "${ssgOrigin}". Using default origin: "https://yoursite.qwik.dev"`
249
228
  );
250
229
  ssgOrigin = `https://yoursite.qwik.dev`;
251
230
  }
252
- const staticGenerate = await import("../../../static/index.mjs");
231
+ const staticGenerate = await import("../../../ssg/index.mjs");
253
232
  const generateOpts = {
254
233
  maxWorkers: opts.maxWorkers,
255
234
  basePathname,
@@ -269,56 +248,45 @@ function viteAdapter(opts) {
269
248
  this.error(err);
270
249
  }
271
250
  staticPaths.push(...staticGenerateResult.staticPaths);
272
- const { staticPathsCode, notFoundPathsCode } = await postBuild(
251
+ }
252
+ await postBuild(
253
+ clientPublicOutDir,
254
+ serverOutDir,
255
+ assetsDir ? join2(basePathname, assetsDir) : basePathname,
256
+ staticPaths,
257
+ !!opts.cleanStaticGenerated
258
+ );
259
+ if (typeof opts.generate === "function") {
260
+ await opts.generate({
261
+ outputEntries,
262
+ serverOutDir,
263
+ clientOutDir,
273
264
  clientPublicOutDir,
274
- assetsDir ? join2(basePathname, assetsDir) : basePathname,
275
- staticPaths,
276
- format,
277
- !!opts.cleanStaticGenerated
278
- );
279
- await Promise.all([
280
- fs2.promises.writeFile(join2(serverOutDir, RESOLVED_STATIC_PATHS_ID), staticPathsCode),
281
- fs2.promises.writeFile(
282
- join2(serverOutDir, RESOLVED_NOT_FOUND_PATHS_ID),
283
- notFoundPathsCode
284
- )
285
- ]);
286
- if (typeof opts.generate === "function") {
287
- await opts.generate({
288
- outputEntries,
289
- serverOutDir,
290
- clientOutDir,
291
- clientPublicOutDir,
292
- basePathname,
293
- routes,
294
- assetsDir,
295
- warn: (message) => this.warn(message),
296
- error: (message) => this.error(message)
297
- });
298
- }
299
- this.warn(
300
- `
265
+ basePathname,
266
+ routes,
267
+ assetsDir,
268
+ warn: (message) => this.warn(message),
269
+ error: (message) => this.error(message)
270
+ });
271
+ }
272
+ this.warn(
273
+ `
301
274
  ==============================================
302
275
  Note: Make sure that you are serving the built files with proper cache headers.
303
276
  See https://qwik.dev/docs/deployments/#cache-headers for more information.
304
277
  ==============================================`
305
- );
306
- }
278
+ );
307
279
  }
308
280
  }
309
281
  }
310
282
  };
311
283
  return plugin;
312
284
  }
313
- var STATIC_PATHS_ID = "@qwik-router-static-paths";
314
- var RESOLVED_STATIC_PATHS_ID = `${STATIC_PATHS_ID}.js`;
315
- var NOT_FOUND_PATHS_ID = "@qwik-router-not-found-paths";
316
- var RESOLVED_NOT_FOUND_PATHS_ID = `${NOT_FOUND_PATHS_ID}.js`;
317
285
 
318
- // packages/qwik-router/src/adapters/static/vite/index.ts
319
- function staticAdapter(opts) {
286
+ // packages/qwik-router/src/adapters/ssg/vite/index.ts
287
+ function ssgAdapter(opts) {
320
288
  return viteAdapter({
321
- name: "static-generate",
289
+ name: "static-site-generation",
322
290
  origin: opts.origin,
323
291
  ssg: {
324
292
  include: ["/*"],
@@ -326,6 +294,8 @@ function staticAdapter(opts) {
326
294
  }
327
295
  });
328
296
  }
297
+ var staticAdapter = ssgAdapter;
329
298
  export {
299
+ ssgAdapter,
330
300
  staticAdapter
331
301
  };
@@ -1,7 +1,7 @@
1
1
  import { ServerAdapterOptions } from '../../shared/vite';
2
- import type { StaticGenerateRenderOptions } from '@qwik.dev/router/static';
2
+ import type { SsgRenderOptions } from 'packages/qwik-router/src/ssg';
3
3
 
4
- export { StaticGenerateRenderOptions }
4
+ export { SsgRenderOptions }
5
5
 
6
6
  /** @public */
7
7
  export declare function vercelEdgeAdapter(opts?: VercelEdgeAdapterOptions): any;
@@ -145,7 +145,7 @@ const getFetchOptions = (action, noCache) => {
145
145
  method: "POST",
146
146
  body: JSON.stringify(actionData),
147
147
  headers: {
148
- "Content-Type": "application/json, charset=UTF-8"
148
+ "Content-Type": "application/json; charset=UTF-8"
149
149
  }
150
150
  };
151
151
  }
@@ -802,8 +802,8 @@ const spaInit = core.event$((_, el) => {
802
802
  };
803
803
  win[scrollEnabled] = true;
804
804
  setTimeout(() => {
805
- addEventListener("popstate", win[initPopstate]);
806
- addEventListener("scroll", win[initScroll], {
805
+ win.addEventListener("popstate", win[initPopstate]);
806
+ win.addEventListener("scroll", win[initScroll], {
807
807
  passive: true
808
808
  });
809
809
  document.body.addEventListener("click", win[initAnchors]);
@@ -845,7 +845,7 @@ const QwikRouterProvider = core.component$((props) => {
845
845
  core.useStyles$(`
846
846
  @layer qwik {
847
847
  @supports selector(html:active-view-transition-type(type)) {
848
- html:active-view-transition-type(qwik-router-spa) {
848
+ html:active-view-transition-type(qwik-navigation) {
849
849
  :root{view-transition-name:none}
850
850
  }
851
851
  }
@@ -1047,10 +1047,10 @@ const QwikRouterProvider = core.component$((props) => {
1047
1047
  } else {
1048
1048
  trackUrl = new URL(navigation.dest, location);
1049
1049
  if (trackUrl.pathname.endsWith("/")) {
1050
- if (!qwikRouterConfig__namespace.trailingSlash) {
1050
+ if (globalThis.__NO_TRAILING_SLASH__) {
1051
1051
  trackUrl.pathname = trackUrl.pathname.slice(0, -1);
1052
1052
  }
1053
- } else if (qwikRouterConfig__namespace.trailingSlash) {
1053
+ } else if (!globalThis.__NO_TRAILING_SLASH__) {
1054
1054
  trackUrl.pathname += "/";
1055
1055
  }
1056
1056
  let loadRoutePromise = loadRoute(qwikRouterConfig__namespace.routes, qwikRouterConfig__namespace.menus, qwikRouterConfig__namespace.cacheModules, trackUrl.pathname);
@@ -1092,8 +1092,7 @@ const QwikRouterProvider = core.component$((props) => {
1092
1092
  const [routeName, params, mods, menu] = loadedRoute;
1093
1093
  const contentModules = mods;
1094
1094
  const pageModule = contentModules[contentModules.length - 1];
1095
- const isRedirect = navType === "form" && !isSamePath(trackUrl, prevUrl);
1096
- if (navigation.dest.search && !isRedirect) {
1095
+ if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
1097
1096
  trackUrl.search = navigation.dest.search;
1098
1097
  }
1099
1098
  if (!isSamePath(trackUrl, prevUrl)) {
@@ -1123,7 +1122,7 @@ const QwikRouterProvider = core.component$((props) => {
1123
1122
  scrollState = getScrollHistory();
1124
1123
  }
1125
1124
  const scroller = document.getElementById(QWIK_ROUTER_SCROLLER) ?? document.documentElement;
1126
- if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || isRedirect) {
1125
+ if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
1127
1126
  document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
1128
1127
  }
1129
1128
  const loaders = clientPageData?.loaders;
@@ -1552,8 +1551,7 @@ const globalAction$ = /* @__PURE__ */ core.implicit$FirstArg(globalActionQrl);
1552
1551
  const routeLoaderQrl = (loaderQrl, ...rest) => {
1553
1552
  const { id, validators, serializationStrategy } = getValidators(rest, loaderQrl);
1554
1553
  function loader() {
1555
- const iCtx = internal._useInvokeContext();
1556
- const state = iCtx.$container$.resolveContext(iCtx.$hostElement$, RouteStateContext);
1554
+ const state = internal._resolveContextWithoutSequentialScope(RouteStateContext);
1557
1555
  if (!(id in state)) {
1558
1556
  throw new Error(`routeLoader$ "${loaderQrl.getSymbol()}" was invoked in a route where it was not declared.
1559
1557
  This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
@@ -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 } from "@qwik.dev/core";
3
3
  import { p } from "@qwik.dev/core/preloader";
4
- import { _deserialize, _UNINITIALIZED, _getContextContainer, SerializerSymbol, _getContextElement, _getQContainerElement, _waitUntilRendered, _useInvokeContext, _getContextEvent, _serialize } from "@qwik.dev/core/internal";
4
+ import { _deserialize, _UNINITIALIZED, _getContextContainer, SerializerSymbol, _getContextElement, _getQContainerElement, _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";
@@ -127,7 +127,7 @@ const getFetchOptions = (action, noCache) => {
127
127
  method: "POST",
128
128
  body: JSON.stringify(actionData),
129
129
  headers: {
130
- "Content-Type": "application/json, charset=UTF-8"
130
+ "Content-Type": "application/json; charset=UTF-8"
131
131
  }
132
132
  };
133
133
  }
@@ -784,8 +784,8 @@ const spaInit = event$((_, el) => {
784
784
  };
785
785
  win[scrollEnabled] = true;
786
786
  setTimeout(() => {
787
- addEventListener("popstate", win[initPopstate]);
788
- addEventListener("scroll", win[initScroll], {
787
+ win.addEventListener("popstate", win[initPopstate]);
788
+ win.addEventListener("scroll", win[initScroll], {
789
789
  passive: true
790
790
  });
791
791
  document.body.addEventListener("click", win[initAnchors]);
@@ -827,7 +827,7 @@ const QwikRouterProvider = component$((props) => {
827
827
  useStyles$(`
828
828
  @layer qwik {
829
829
  @supports selector(html:active-view-transition-type(type)) {
830
- html:active-view-transition-type(qwik-router-spa) {
830
+ html:active-view-transition-type(qwik-navigation) {
831
831
  :root{view-transition-name:none}
832
832
  }
833
833
  }
@@ -1029,10 +1029,10 @@ const QwikRouterProvider = component$((props) => {
1029
1029
  } else {
1030
1030
  trackUrl = new URL(navigation.dest, location);
1031
1031
  if (trackUrl.pathname.endsWith("/")) {
1032
- if (!qwikRouterConfig.trailingSlash) {
1032
+ if (globalThis.__NO_TRAILING_SLASH__) {
1033
1033
  trackUrl.pathname = trackUrl.pathname.slice(0, -1);
1034
1034
  }
1035
- } else if (qwikRouterConfig.trailingSlash) {
1035
+ } else if (!globalThis.__NO_TRAILING_SLASH__) {
1036
1036
  trackUrl.pathname += "/";
1037
1037
  }
1038
1038
  let loadRoutePromise = loadRoute(qwikRouterConfig.routes, qwikRouterConfig.menus, qwikRouterConfig.cacheModules, trackUrl.pathname);
@@ -1074,8 +1074,7 @@ const QwikRouterProvider = component$((props) => {
1074
1074
  const [routeName, params, mods, menu] = loadedRoute;
1075
1075
  const contentModules = mods;
1076
1076
  const pageModule = contentModules[contentModules.length - 1];
1077
- const isRedirect = navType === "form" && !isSamePath(trackUrl, prevUrl);
1078
- if (navigation.dest.search && !isRedirect) {
1077
+ if (navigation.dest.search && !!isSamePath(trackUrl, prevUrl)) {
1079
1078
  trackUrl.search = navigation.dest.search;
1080
1079
  }
1081
1080
  if (!isSamePath(trackUrl, prevUrl)) {
@@ -1105,7 +1104,7 @@ const QwikRouterProvider = component$((props) => {
1105
1104
  scrollState = getScrollHistory();
1106
1105
  }
1107
1106
  const scroller = document.getElementById(QWIK_ROUTER_SCROLLER) ?? document.documentElement;
1108
- if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || isRedirect) {
1107
+ if (navigation.scroll && (!navigation.forceReload || !isSamePath(trackUrl, prevUrl)) && (navType === "link" || navType === "popstate") || navType === "form" && !isSamePath(trackUrl, prevUrl)) {
1109
1108
  document.__q_scroll_restore__ = () => restoreScroll(navType, trackUrl, prevUrl, scroller, scrollState);
1110
1109
  }
1111
1110
  const loaders = clientPageData?.loaders;
@@ -1534,8 +1533,7 @@ const globalAction$ = /* @__PURE__ */ implicit$FirstArg(globalActionQrl);
1534
1533
  const routeLoaderQrl = (loaderQrl, ...rest) => {
1535
1534
  const { id, validators, serializationStrategy } = getValidators(rest, loaderQrl);
1536
1535
  function loader() {
1537
- const iCtx = _useInvokeContext();
1538
- const state = iCtx.$container$.resolveContext(iCtx.$hostElement$, RouteStateContext);
1536
+ const state = _resolveContextWithoutSequentialScope(RouteStateContext);
1539
1537
  if (!(id in state)) {
1540
1538
  throw new Error(`routeLoader$ "${loaderQrl.getSymbol()}" was invoked in a route where it was not declared.
1541
1539
  This is because the routeLoader$ was not exported in a 'layout.tsx' or 'index.tsx' file of the existing route.
@@ -11,8 +11,9 @@ import { ServerResponse } from 'http';
11
11
  declare interface AwsOpt {
12
12
  render: Render;
13
13
  manifest?: QwikManifest;
14
- qwikRouterConfig: QwikRouterConfig;
15
- /** @deprecated Use `QwikRouterConfig` instead. Will be removed in V3 */
14
+ /** @deprecated Not used */
15
+ qwikRouterConfig?: QwikRouterConfig;
16
+ /** @deprecated Not used */
16
17
  qwikCityPlan?: QwikCityPlan;
17
18
  }
18
19
 
@@ -2,10 +2,8 @@
2
2
  import { createQwikRouter as createQwikRouterNode } from "@qwik.dev/router/middleware/node";
3
3
  function createQwikRouter(opts) {
4
4
  if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
5
- console.warn("qwikCityPlan is deprecated. Use qwikRouterConfig instead.");
5
+ console.warn("qwikCityPlan is deprecated. Simply remove it.");
6
6
  opts.qwikRouterConfig = opts.qwikCityPlan;
7
- } else if (!opts.qwikRouterConfig) {
8
- throw new Error("qwikRouterConfig is required.");
9
7
  }
10
8
  try {
11
9
  const { router, staticFile, notFound } = createQwikRouterNode({
@@ -23,7 +21,7 @@ function createQwikRouter(opts) {
23
21
  }
24
22
  });
25
23
  const fixPath = (pathT) => {
26
- if (opts.qwikRouterConfig.trailingSlash) {
24
+ if (!globalThis.__NO_TRAILING_SLASH__) {
27
25
  const url = new URL(pathT, "http://aws-qwik.local");
28
26
  if (url.pathname.includes(".", url.pathname.lastIndexOf("/"))) {
29
27
  return pathT;
@@ -194,17 +194,17 @@ var require_set_cookie = __commonJS({
194
194
 
195
195
  // packages/qwik-router/src/middleware/azure-swa/index.ts
196
196
  var import_set_cookie_parser = __toESM(require_set_cookie(), 1);
197
- import { getNotFound } from "@qwik-router-not-found-paths";
198
- import { isStaticPath } from "@qwik-router-static-paths";
199
197
  import { _deserialize, _serialize, _verifySerializable } from "@qwik.dev/core/internal";
200
198
  import { setServerPlatform } from "@qwik.dev/core/server";
201
- import { requestHandler } from "../request-handler/index.mjs";
199
+ import {
200
+ getNotFound,
201
+ isStaticPath,
202
+ requestHandler
203
+ } from "../request-handler/index.mjs";
202
204
  function createQwikRouter(opts) {
203
205
  if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
204
- console.warn("qwikCityPlan is deprecated. Use qwikRouterConfig instead.");
206
+ console.warn("qwikCityPlan is deprecated. Simply remove it.");
205
207
  opts.qwikRouterConfig = opts.qwikCityPlan;
206
- } else if (!opts.qwikRouterConfig) {
207
- throw new Error("qwikRouterConfig is required.");
208
208
  }
209
209
  const qwikSerializer = {
210
210
  _deserialize,
@@ -1,10 +1,10 @@
1
1
  // packages/qwik-router/src/middleware/bun/index.ts
2
- import { getNotFound } from "@qwik-router-not-found-paths";
3
- import { isStaticPath } from "@qwik-router-static-paths";
4
2
  import { _deserialize, _serialize, _verifySerializable } from "@qwik.dev/core/internal";
5
3
  import { setServerPlatform } from "@qwik.dev/core/server";
6
4
  import {
7
5
  _TextEncoderStream_polyfill,
6
+ getNotFound,
7
+ isStaticPath,
8
8
  mergeHeadersCookies,
9
9
  requestHandler
10
10
  } from "../request-handler/index.mjs";
@@ -66,10 +66,8 @@ var MIME_TYPES = {
66
66
  function createQwikRouter(opts) {
67
67
  var _a;
68
68
  if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
69
- console.warn("qwikCityPlan is deprecated. Use qwikRouterConfig instead.");
69
+ console.warn("qwikCityPlan is deprecated. Simply remove it.");
70
70
  opts.qwikRouterConfig = opts.qwikCityPlan;
71
- } else if (!opts.qwikRouterConfig) {
72
- throw new Error("qwikRouterConfig is required.");
73
71
  }
74
72
  globalThis.TextEncoderStream ||= _TextEncoderStream_polyfill;
75
73
  const qwikSerializer = { _deserialize, _serialize, _verifySerializable };
@@ -155,7 +153,7 @@ function createQwikRouter(opts) {
155
153
  let filePath;
156
154
  if (fileName.includes(".")) {
157
155
  filePath = join(staticFolder, pathname);
158
- } else if (opts.qwikRouterConfig.trailingSlash) {
156
+ } else if (!globalThis.__NO_TRAILING_SLASH__) {
159
157
  filePath = join(staticFolder, pathname + "index.html");
160
158
  } else {
161
159
  filePath = join(staticFolder, pathname, "index.html");
@@ -1,23 +1,21 @@
1
1
  // packages/qwik-router/src/middleware/cloudflare-pages/index.ts
2
- import { getNotFound } from "@qwik-router-not-found-paths";
3
- import { isStaticPath } from "@qwik-router-static-paths";
4
2
  import { _deserialize, _serialize, _verifySerializable } from "@qwik.dev/core/internal";
5
3
  import { setServerPlatform } from "@qwik.dev/core/server";
6
4
  import {
7
5
  _TextEncoderStream_polyfill,
6
+ getNotFound,
7
+ isStaticPath,
8
8
  mergeHeadersCookies,
9
9
  requestHandler
10
10
  } from "../request-handler/index.mjs";
11
11
  function createQwikRouter(opts) {
12
12
  if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
13
- console.warn("qwikCityPlan is deprecated. Use qwikRouterConfig instead.");
13
+ console.warn("qwikCityPlan is deprecated. Simply remove it.");
14
14
  opts.qwikRouterConfig = opts.qwikCityPlan;
15
- } else if (!opts.qwikRouterConfig) {
16
- throw new Error("qwikRouterConfig is required.");
17
15
  }
18
16
  try {
19
17
  new globalThis.TextEncoderStream();
20
- } catch (e) {
18
+ } catch {
21
19
  globalThis.TextEncoderStream = _TextEncoderStream_polyfill;
22
20
  }
23
21
  const qwikSerializer = { _deserialize, _serialize, _verifySerializable };
@@ -1,9 +1,12 @@
1
1
  // packages/qwik-router/src/middleware/deno/index.ts
2
- import { getNotFound } from "@qwik-router-not-found-paths";
3
- import { isStaticPath } from "@qwik-router-static-paths";
4
2
  import { _deserialize, _serialize, _verifySerializable } from "@qwik.dev/core/internal";
5
3
  import { setServerPlatform } from "@qwik.dev/core/server";
6
- import { mergeHeadersCookies, requestHandler } from "../request-handler/index.mjs";
4
+ import {
5
+ getNotFound,
6
+ isStaticPath,
7
+ mergeHeadersCookies,
8
+ requestHandler
9
+ } from "../request-handler/index.mjs";
7
10
 
8
11
  // packages/qwik-router/src/middleware/request-handler/mime-types.ts
9
12
  var MIME_TYPES = {
@@ -62,10 +65,8 @@ import { extname, fromFileUrl, join } from "https://deno.land/std/path/mod.ts";
62
65
  function createQwikRouter(opts) {
63
66
  var _a;
64
67
  if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
65
- console.warn("qwikCityPlan is deprecated. Use qwikRouterConfig instead.");
68
+ console.warn("qwikCityPlan is deprecated. Simply remove it.");
66
69
  opts.qwikRouterConfig = opts.qwikCityPlan;
67
- } else if (!opts.qwikRouterConfig) {
68
- throw new Error("qwikRouterConfig is required.");
69
70
  }
70
71
  const qwikSerializer = {
71
72
  _deserialize,
@@ -147,7 +148,7 @@ function createQwikRouter(opts) {
147
148
  let filePath;
148
149
  if (fileName.includes(".")) {
149
150
  filePath = join(staticFolder, pathname);
150
- } else if (opts.qwikRouterConfig.trailingSlash) {
151
+ } else if (!globalThis.__NO_TRAILING_SLASH__) {
151
152
  filePath = join(staticFolder, pathname + "index.html");
152
153
  } else {
153
154
  filePath = join(staticFolder, pathname, "index.html");
@@ -2,10 +2,8 @@
2
2
  import { createQwikRouter as createQwikRouterNode } from "@qwik.dev/router/middleware/node";
3
3
  function createQwikRouter(opts) {
4
4
  if (opts.qwikCityPlan && !opts.qwikRouterConfig) {
5
- console.warn("qwikCityPlan is deprecated. Use qwikRouterConfig instead.");
5
+ console.warn("qwikCityPlan is deprecated. Simply remove it.");
6
6
  opts.qwikRouterConfig = opts.qwikCityPlan;
7
- } else if (!opts.qwikRouterConfig) {
8
- throw new Error("qwikRouterConfig is required.");
9
7
  }
10
8
  const { staticFile, notFound, router } = createQwikRouterNode({
11
9
  render: opts.render,