@qwik.dev/router 2.0.0-beta.43 → 2.0.0-beta.47

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 (50) hide show
  1. package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
  2. package/lib/adapters/azure-swa/vite/index.mjs +2 -1
  3. package/lib/adapters/bun-server/vite/index.d.ts +2 -2
  4. package/lib/adapters/bun-server/vite/index.mjs +2 -1
  5. package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
  6. package/lib/adapters/cloud-run/vite/index.mjs +2 -1
  7. package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
  8. package/lib/adapters/cloudflare-pages/vite/index.mjs +2 -1
  9. package/lib/adapters/deno-server/vite/index.d.ts +2 -2
  10. package/lib/adapters/deno-server/vite/index.mjs +2 -1
  11. package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
  12. package/lib/adapters/netlify-edge/vite/index.mjs +2 -1
  13. package/lib/adapters/node-server/vite/index.d.ts +2 -2
  14. package/lib/adapters/node-server/vite/index.mjs +2 -1
  15. package/lib/adapters/shared/vite/index.d.ts +1 -1
  16. package/lib/adapters/shared/vite/index.mjs +36 -32
  17. package/lib/adapters/ssg/vite/index.d.ts +1 -1
  18. package/lib/adapters/ssg/vite/index.mjs +4 -2
  19. package/lib/adapters/vercel-edge/vite/index.d.ts +2 -2
  20. package/lib/adapters/vercel-edge/vite/index.mjs +18 -15
  21. package/lib/chunks/fs.mjs +28 -25
  22. package/lib/chunks/head.qwik.mjs +731 -448
  23. package/lib/chunks/http-error.qwik.mjs +8 -7
  24. package/lib/chunks/pathname.mjs +9 -8
  25. package/lib/chunks/request-path.mjs +8 -4
  26. package/lib/chunks/route-trie-key.mjs +10 -0
  27. package/lib/chunks/routes.mjs +14 -14
  28. package/lib/chunks/server-error.mjs +28 -6
  29. package/lib/chunks/{url.mjs → static-file.mjs} +12 -2
  30. package/lib/chunks/system.mjs +31 -25
  31. package/lib/chunks/user-response.mjs +455 -348
  32. package/lib/chunks/worker-thread.mjs +90 -88
  33. package/lib/index.d.ts +94 -63
  34. package/lib/index.qwik.mjs +615 -523
  35. package/lib/middleware/aws-lambda/index.mjs +6 -3
  36. package/lib/middleware/azure-swa/index.mjs +4 -2
  37. package/lib/middleware/bun/index.mjs +12 -12
  38. package/lib/middleware/cloudflare-pages/index.mjs +19 -4
  39. package/lib/middleware/deno/index.mjs +12 -12
  40. package/lib/middleware/firebase/index.mjs +4 -2
  41. package/lib/middleware/netlify-edge/index.mjs +4 -2
  42. package/lib/middleware/node/index.mjs +16 -15
  43. package/lib/middleware/request-handler/index.d.ts +102 -2
  44. package/lib/middleware/request-handler/index.mjs +30 -34
  45. package/lib/middleware/vercel-edge/index.mjs +4 -2
  46. package/lib/service-worker/index.mjs +2 -1
  47. package/lib/ssg/index.mjs +23 -18
  48. package/lib/vite/index.d.ts +1 -1
  49. package/lib/vite/index.mjs +669 -604
  50. package/package.json +5 -5
package/lib/ssg/index.mjs CHANGED
@@ -1,20 +1,9 @@
1
1
  import { n as getPathnameForDynamicRoute, t as ensureSlash } from "../chunks/pathname.mjs";
2
+ import { n as isStaticTrieKey, r as unescapeStaticTrieKey } from "../chunks/route-trie-key.mjs";
2
3
  import { r as msToString } from "../chunks/format.mjs";
3
4
  import { t as createRouteTester } from "../chunks/routes.mjs";
4
5
  import { relative } from "node:path";
5
6
  import { bold, dim, green, magenta, red } from "kleur/colors";
6
- function validateOptions(opts) {
7
- if (!opts.qwikRouterConfig) throw new Error(`Missing "qwikRouterConfig" option`);
8
- let siteOrigin = opts.origin;
9
- if (typeof siteOrigin !== "string" || siteOrigin.trim().length === 0) throw new Error(`Missing "origin" option`);
10
- siteOrigin = siteOrigin.trim();
11
- if (!/:\/\//.test(siteOrigin) || siteOrigin.startsWith("://")) throw new Error(`"origin" must start with a valid protocol, such as "https://" or "http://", received "${siteOrigin}"`);
12
- try {
13
- new URL(siteOrigin);
14
- } catch (e) {
15
- throw new Error(`Invalid "origin"`, { cause: e });
16
- }
17
- }
18
7
  async function mainThread(sys) {
19
8
  const opts = sys.getOptions();
20
9
  validateOptions(opts);
@@ -136,7 +125,8 @@ async function mainThread(sys) {
136
125
  * Traverse the route tree and call the callback for each route that has module loaders.
137
126
  * Reconstructs the original pathname and param names from the tree path. Accumulates _L
138
127
  * layout loaders from ancestors during traversal.
139
- */ const traverseRouteTree = async (node, pathParts, basePathname, ancestorLoaders) => {
128
+ */
129
+ const traverseRouteTree = async (node, pathParts, basePathname, ancestorLoaders) => {
140
130
  const currentLoaders = node._L ? [...ancestorLoaders, node._L] : ancestorLoaders;
141
131
  const index = node._I;
142
132
  if (index) {
@@ -182,8 +172,8 @@ async function mainThread(sys) {
182
172
  await traverseRouteTree(childNode, [...pathParts, pathPart], basePathname, currentLoaders);
183
173
  }
184
174
  for (const [key, child] of Object.entries(node)) {
185
- if (key.charCodeAt(0) === 95) continue;
186
- await traverseRouteTree(child, [...pathParts, key], basePathname, currentLoaders);
175
+ if (!isStaticTrieKey(key)) continue;
176
+ await traverseRouteTree(child, [...pathParts, unescapeStaticTrieKey(key)], basePathname, currentLoaders);
187
177
  }
188
178
  };
189
179
  const loadStaticRoutes = async () => {
@@ -203,12 +193,25 @@ async function mainThread(sys) {
203
193
  }
204
194
  });
205
195
  }
196
+ function validateOptions(opts) {
197
+ if (!opts.qwikRouterConfig) throw new Error(`Missing "qwikRouterConfig" option`);
198
+ let siteOrigin = opts.origin;
199
+ if (typeof siteOrigin !== "string" || siteOrigin.trim().length === 0) throw new Error(`Missing "origin" option`);
200
+ siteOrigin = siteOrigin.trim();
201
+ if (!/:\/\//.test(siteOrigin) || siteOrigin.startsWith("://")) throw new Error(`"origin" must start with a valid protocol, such as "https://" or "http://", received "${siteOrigin}"`);
202
+ try {
203
+ new URL(siteOrigin);
204
+ } catch (e) {
205
+ throw new Error(`Invalid "origin"`, { cause: e });
206
+ }
207
+ }
206
208
  /**
207
209
  * Use this function when SSG should be generated from another module, such as a Vite plugin. This
208
210
  * function's should be passed the paths of the entry module and Qwik Router Plan.
209
211
  *
210
212
  * @public
211
- */ async function generate(opts) {
213
+ */
214
+ async function generate(opts) {
212
215
  const { createSystem } = await import("../chunks/system.mjs");
213
216
  return mainThread(await createSystem(opts));
214
217
  }
@@ -219,7 +222,8 @@ async function mainThread(sys) {
219
222
  * Intended to be called from a generated `run-ssg.js` wrapper that provides render/config.
220
223
  *
221
224
  * @public
222
- */ async function runSsg(opts) {
225
+ */
226
+ async function runSsg(opts) {
223
227
  try {
224
228
  const result = await generate(opts);
225
229
  const fs = await import("node:fs");
@@ -243,7 +247,8 @@ async function mainThread(sys) {
243
247
  * @param opts - Must include `render` and `qwikRouterConfig` (imported by the worker entry). The
244
248
  * remaining serializable options come from `workerData`.
245
249
  * @public
246
- */ async function startWorker(opts) {
250
+ */
251
+ async function startWorker(opts) {
247
252
  const { workerData } = await import("node:worker_threads");
248
253
  const mergedOpts = {
249
254
  ...workerData,
@@ -1,4 +1,4 @@
1
- import type { BuiltinsWithOptionalParams } from 'svgo/plugins/plugins-types';
1
+ import type { BuiltinsWithOptionalParams } from 'svgo';
2
2
  import type { CompileOptions } from '@mdx-js/mdx';
3
3
  import type { Config } from 'svgo';
4
4
  import { ConfigEnv } from 'vite';