@qwik.dev/router 2.0.0-beta.27 → 2.0.0-beta.29

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 (42) hide show
  1. package/lib/adapters/azure-swa/vite/index.mjs +31 -36
  2. package/lib/adapters/bun-server/vite/index.mjs +0 -3
  3. package/lib/adapters/cloud-run/vite/index.mjs +0 -3
  4. package/lib/adapters/cloudflare-pages/vite/index.mjs +15 -9
  5. package/lib/adapters/deno-server/vite/index.mjs +7 -5
  6. package/lib/adapters/netlify-edge/vite/index.mjs +13 -23
  7. package/lib/adapters/node-server/vite/index.mjs +0 -3
  8. package/lib/adapters/shared/vite/index.d.ts +1 -7
  9. package/lib/adapters/shared/vite/index.mjs +171 -157
  10. package/lib/adapters/ssg/vite/index.mjs +3 -4
  11. package/lib/adapters/vercel-edge/vite/index.mjs +25 -9
  12. package/lib/chunks/error-handler.mjs +26 -26
  13. package/lib/chunks/fs.mjs +28 -138
  14. package/lib/chunks/http-error.qwik.mjs +27 -0
  15. package/lib/chunks/not-found-wrapper.qwik.mjs +25 -0
  16. package/lib/chunks/pathname.mjs +105 -0
  17. package/lib/chunks/routing.qwik.mjs +592 -216
  18. package/lib/chunks/system.mjs +328 -0
  19. package/lib/chunks/use-functions.qwik.mjs +35 -0
  20. package/lib/chunks/worker-thread.mjs +271 -0
  21. package/lib/index.d.ts +136 -102
  22. package/lib/index.qwik.mjs +699 -751
  23. package/lib/middleware/aws-lambda/index.mjs +7 -1
  24. package/lib/middleware/azure-swa/index.mjs +7 -2
  25. package/lib/middleware/bun/index.mjs +24 -8
  26. package/lib/middleware/cloudflare-pages/index.mjs +10 -3
  27. package/lib/middleware/deno/index.mjs +23 -8
  28. package/lib/middleware/netlify-edge/index.mjs +10 -3
  29. package/lib/middleware/node/index.mjs +10 -14
  30. package/lib/middleware/request-handler/index.d.ts +82 -12
  31. package/lib/middleware/request-handler/index.mjs +661 -524
  32. package/lib/middleware/vercel-edge/index.mjs +10 -3
  33. package/lib/modules.d.ts +7 -4
  34. package/lib/ssg/index.d.ts +48 -16
  35. package/lib/ssg/index.mjs +320 -7
  36. package/lib/vite/index.d.ts +6 -0
  37. package/lib/vite/index.mjs +1106 -630
  38. package/modules.d.ts +7 -4
  39. package/package.json +9 -9
  40. package/lib/chunks/format-error.mjs +0 -137
  41. package/lib/chunks/index.mjs +0 -884
  42. package/lib/chunks/types.qwik.mjs +0 -22
@@ -1,7 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { viteAdapter } from '../../shared/vite/index.mjs';
4
- import '../../../chunks/error-handler.mjs';
5
4
 
6
5
  function azureSwaAdapter(opts = {}) {
7
6
  const env = process?.env;
@@ -13,43 +12,39 @@ function azureSwaAdapter(opts = {}) {
13
12
  async generate({ outputEntries, serverOutDir, clientPublicOutDir }) {
14
13
  const serverPackageJsonPath = join(serverOutDir, "package.json");
15
14
  const serverPackageJsonCode = `{"type":"module"}`;
16
- await fs.promises.mkdir(serverOutDir, { recursive: true });
15
+ await fs.promises.mkdir(serverOutDir, {
16
+ recursive: true
17
+ });
17
18
  await fs.promises.writeFile(serverPackageJsonPath, serverPackageJsonCode);
18
- const azureSwaModulePath = outputEntries.find(
19
- (entryName) => entryName.indexOf("entry.azure-swa") === 0
20
- );
19
+ const azureSwaModulePath = outputEntries.find((entryName) => entryName.indexOf("entry.azure-swa") === 0);
21
20
  const funcJsonPath = join(serverOutDir, "function.json");
22
- const funcJson = JSON.stringify(
23
- {
24
- bindings: [
25
- {
26
- authLevel: "anonymous",
27
- type: "httpTrigger",
28
- direction: "in",
29
- name: "req",
30
- methods: [
31
- "get",
32
- "head",
33
- "post",
34
- "put",
35
- "delete",
36
- "connect",
37
- "options",
38
- "trace",
39
- "patch"
40
- ]
41
- },
42
- {
43
- type: "http",
44
- direction: "out",
45
- name: "$return"
46
- }
47
- ],
48
- scriptFile: azureSwaModulePath
49
- },
50
- null,
51
- 2
52
- );
21
+ const funcJson = JSON.stringify({
22
+ bindings: [
23
+ {
24
+ authLevel: "anonymous",
25
+ type: "httpTrigger",
26
+ direction: "in",
27
+ name: "req",
28
+ methods: [
29
+ "get",
30
+ "head",
31
+ "post",
32
+ "put",
33
+ "delete",
34
+ "connect",
35
+ "options",
36
+ "trace",
37
+ "patch"
38
+ ]
39
+ },
40
+ {
41
+ type: "http",
42
+ direction: "out",
43
+ name: "$return"
44
+ }
45
+ ],
46
+ scriptFile: azureSwaModulePath
47
+ }, null, 2);
53
48
  await fs.promises.writeFile(funcJsonPath, funcJson);
54
49
  if (!fs.existsSync(join(clientPublicOutDir, "index.html"))) {
55
50
  await fs.promises.writeFile(join(clientPublicOutDir, "index.html"), "");
@@ -1,7 +1,4 @@
1
1
  import { viteAdapter } from '../../shared/vite/index.mjs';
2
- import 'node:path';
3
- import 'node:fs';
4
- import '../../../chunks/error-handler.mjs';
5
2
 
6
3
  function bunServerAdapter(opts = {}) {
7
4
  const env = process?.env;
@@ -1,7 +1,4 @@
1
1
  import { viteAdapter } from '../../shared/vite/index.mjs';
2
- import 'node:path';
3
- import 'node:fs';
4
- import '../../../chunks/error-handler.mjs';
5
2
 
6
3
  function cloudRunAdapter(opts = {}) {
7
4
  const env = process?.env;
@@ -2,7 +2,6 @@ import fs from 'node:fs';
2
2
  import { join, relative } from 'node:path';
3
3
  import { n as normalizePathSlash } from '../../../chunks/fs.mjs';
4
4
  import { viteAdapter } from '../../shared/vite/index.mjs';
5
- import '../../../chunks/error-handler.mjs';
6
5
 
7
6
  function cloudflarePagesAdapter(opts = {}) {
8
7
  const env = process?.env;
@@ -15,12 +14,17 @@ function cloudflarePagesAdapter(opts = {}) {
15
14
  config() {
16
15
  return {
17
16
  resolve: {
18
- conditions: ["webworker", "worker"]
17
+ conditions: [
18
+ "webworker",
19
+ "worker"
20
+ ]
19
21
  },
20
22
  ssr: {
21
23
  target: "webworker",
22
24
  noExternal: true,
23
- external: ["node:async_hooks"]
25
+ external: [
26
+ "node:async_hooks"
27
+ ]
24
28
  },
25
29
  build: {
26
30
  ssr: true,
@@ -44,8 +48,13 @@ function cloudflarePagesAdapter(opts = {}) {
44
48
  }
45
49
  const routesJson = {
46
50
  version: 1,
47
- include: [basePathname + "*"],
48
- exclude: [pathName + "build/*", pathName + "assets/*"]
51
+ include: [
52
+ basePathname + "*"
53
+ ],
54
+ exclude: [
55
+ pathName + "build/*",
56
+ pathName + "assets/*"
57
+ ]
49
58
  };
50
59
  await fs.promises.writeFile(routesJsonPath, JSON.stringify(routesJson, void 0, 2));
51
60
  }
@@ -53,10 +62,7 @@ function cloudflarePagesAdapter(opts = {}) {
53
62
  const hasWorkerJs = fs.existsSync(workerJsPath);
54
63
  if (!hasWorkerJs) {
55
64
  const importPath = relative(clientOutDir, join(serverOutDir, "entry.cloudflare-pages"));
56
- await fs.promises.writeFile(
57
- workerJsPath,
58
- `import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`
59
- );
65
+ await fs.promises.writeFile(workerJsPath, `import { fetch } from "${normalizePathSlash(importPath)}"; export default { fetch };`);
60
66
  }
61
67
  }
62
68
  });
@@ -1,7 +1,4 @@
1
1
  import { viteAdapter } from '../../shared/vite/index.mjs';
2
- import 'node:path';
3
- import 'node:fs';
4
- import '../../../chunks/error-handler.mjs';
5
2
 
6
3
  function denoServerAdapter(opts = {}) {
7
4
  const env = process?.env;
@@ -13,12 +10,17 @@ function denoServerAdapter(opts = {}) {
13
10
  config() {
14
11
  return {
15
12
  resolve: {
16
- conditions: ["webworker", "worker"]
13
+ conditions: [
14
+ "webworker",
15
+ "worker"
16
+ ]
17
17
  },
18
18
  ssr: {
19
19
  target: "webworker",
20
20
  noExternal: true,
21
- external: ["node:async_hooks"]
21
+ external: [
22
+ "node:async_hooks"
23
+ ]
22
24
  },
23
25
  build: {
24
26
  ssr: true,
@@ -1,7 +1,6 @@
1
1
  import fs, { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { viteAdapter, getParentDir } from '../../shared/vite/index.mjs';
4
- import '../../../chunks/error-handler.mjs';
5
4
 
6
5
  function netlifyEdgeAdapter(opts = {}) {
7
6
  const env = process?.env;
@@ -15,12 +14,17 @@ function netlifyEdgeAdapter(opts = {}) {
15
14
  const outDir = config.build?.outDir || ".netlify/edge-functions/entry.netlify-edge";
16
15
  return {
17
16
  resolve: {
18
- conditions: ["webworker", "worker"]
17
+ conditions: [
18
+ "webworker",
19
+ "worker"
20
+ ]
19
21
  },
20
22
  ssr: {
21
23
  target: "webworker",
22
24
  noExternal: true,
23
- external: ["node:async_hooks"]
25
+ external: [
26
+ "node:async_hooks"
27
+ ]
24
28
  },
25
29
  build: {
26
30
  ssr: true,
@@ -43,15 +47,7 @@ function netlifyEdgeAdapter(opts = {}) {
43
47
  } else if (Array.isArray(opts.excludedPath)) {
44
48
  excludedPath.push(...opts.excludedPath);
45
49
  } else {
46
- excludedPath.push(
47
- "/build/*",
48
- "/favicon.ico",
49
- "/robots.txt",
50
- "/mainifest.json",
51
- "/~partytown/*",
52
- "/service-worker.js",
53
- "/sitemap.xml"
54
- );
50
+ excludedPath.push("/build/*", "/favicon.ico", "/robots.txt", "/mainifest.json", "/~partytown/*", "/service-worker.js", "/sitemap.xml");
55
51
  }
56
52
  const netlifyEdgeManifest = {
57
53
  functions: [
@@ -67,19 +63,13 @@ function netlifyEdgeAdapter(opts = {}) {
67
63
  const jsPath = join(serverOutDir, "entry.netlify-edge.js");
68
64
  const mjsPath = join(serverOutDir, "entry.netlify-edge.mjs");
69
65
  if (existsSync(mjsPath)) {
70
- await fs.promises.writeFile(
71
- jsPath,
72
- [
73
- `import entry_netlifyEdge from './entry.netlify-edge.mjs';`,
74
- `export default entry_netlifyEdge;`
75
- ].join("\n")
76
- );
66
+ await fs.promises.writeFile(jsPath, [
67
+ `import entry_netlifyEdge from './entry.netlify-edge.mjs';`,
68
+ `export default entry_netlifyEdge;`
69
+ ].join("\n"));
77
70
  }
78
71
  const netlifyEdgeFnsDir = getParentDir(serverOutDir, "edge-functions");
79
- await fs.promises.writeFile(
80
- join(netlifyEdgeFnsDir, "manifest.json"),
81
- JSON.stringify(netlifyEdgeManifest, null, 2)
82
- );
72
+ await fs.promises.writeFile(join(netlifyEdgeFnsDir, "manifest.json"), JSON.stringify(netlifyEdgeManifest, null, 2));
83
73
  }
84
74
  }
85
75
  });
@@ -1,7 +1,4 @@
1
1
  import { viteAdapter } from '../../shared/vite/index.mjs';
2
- import 'node:path';
3
- import 'node:fs';
4
- import '../../../chunks/error-handler.mjs';
5
2
 
6
3
  function nodeServerAdapter(opts = {}) {
7
4
  const env = process?.env;
@@ -74,13 +74,7 @@ export declare interface ServerAdapterOptions {
74
74
  ssg?: AdapterSSGOptions | null;
75
75
  }
76
76
 
77
- /**
78
- * Implements the SSG after the build is complete. Also provides a `generate(...)` callback that is
79
- * called after the SSG is complete, which allows for custom post-processing of the complete build
80
- * results.
81
- *
82
- * @public
83
- */
77
+ /** @public */
84
78
  export declare function viteAdapter(opts: ViteAdapterPluginOptions): Plugin_2<never>;
85
79
 
86
80
  /** @public */