@qwik.dev/router 2.0.0-beta.28 → 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.
- package/lib/adapters/azure-swa/vite/index.mjs +31 -36
- package/lib/adapters/bun-server/vite/index.mjs +0 -3
- package/lib/adapters/cloud-run/vite/index.mjs +0 -3
- package/lib/adapters/cloudflare-pages/vite/index.mjs +15 -9
- package/lib/adapters/deno-server/vite/index.mjs +7 -5
- package/lib/adapters/netlify-edge/vite/index.mjs +13 -23
- package/lib/adapters/node-server/vite/index.mjs +0 -3
- package/lib/adapters/shared/vite/index.d.ts +1 -7
- package/lib/adapters/shared/vite/index.mjs +164 -136
- package/lib/adapters/ssg/vite/index.mjs +3 -4
- package/lib/adapters/vercel-edge/vite/index.mjs +25 -9
- package/lib/chunks/error-handler.mjs +26 -26
- package/lib/chunks/fs.mjs +28 -138
- package/lib/chunks/http-error.qwik.mjs +27 -0
- package/lib/chunks/not-found-wrapper.qwik.mjs +25 -0
- package/lib/chunks/pathname.mjs +105 -0
- package/lib/chunks/routing.qwik.mjs +592 -216
- package/lib/chunks/system.mjs +328 -0
- package/lib/chunks/use-functions.qwik.mjs +35 -0
- package/lib/chunks/worker-thread.mjs +271 -0
- package/lib/index.d.ts +136 -102
- package/lib/index.qwik.mjs +699 -751
- package/lib/middleware/aws-lambda/index.mjs +7 -1
- package/lib/middleware/azure-swa/index.mjs +7 -2
- package/lib/middleware/bun/index.mjs +20 -5
- package/lib/middleware/cloudflare-pages/index.mjs +8 -2
- package/lib/middleware/deno/index.mjs +19 -5
- package/lib/middleware/netlify-edge/index.mjs +8 -2
- package/lib/middleware/node/index.mjs +10 -14
- package/lib/middleware/request-handler/index.d.ts +82 -12
- package/lib/middleware/request-handler/index.mjs +661 -524
- package/lib/middleware/vercel-edge/index.mjs +8 -2
- package/lib/modules.d.ts +7 -4
- package/lib/ssg/index.d.ts +48 -16
- package/lib/ssg/index.mjs +320 -7
- package/lib/vite/index.d.ts +6 -0
- package/lib/vite/index.mjs +1098 -641
- package/modules.d.ts +7 -4
- package/package.json +4 -4
- package/lib/chunks/format-error.mjs +0 -137
- package/lib/chunks/index.mjs +0 -896
- package/lib/chunks/types.qwik.mjs +0 -22
package/modules.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
declare module '@qwik-router-config' {
|
|
2
|
-
|
|
3
|
-
export const
|
|
2
|
+
import type { RouteData, RouteModule } from '@qwik.dev/router';
|
|
3
|
+
export const routes: RouteData;
|
|
4
|
+
export const serverPlugins: RouteModule[];
|
|
4
5
|
export const trailingSlash: boolean;
|
|
5
6
|
export const basePathname: string;
|
|
6
7
|
export const cacheModules: boolean;
|
|
8
|
+
export const fallthrough: boolean;
|
|
7
9
|
const defaultExport: {
|
|
8
|
-
routes:
|
|
9
|
-
|
|
10
|
+
routes: RouteData;
|
|
11
|
+
serverPlugins: RouteModule[];
|
|
10
12
|
trailingSlash: boolean;
|
|
11
13
|
basePathname: string;
|
|
12
14
|
cacheModules: boolean;
|
|
15
|
+
fallthrough: boolean;
|
|
13
16
|
};
|
|
14
17
|
export default defaultExport;
|
|
15
18
|
}
|
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-beta.
|
|
4
|
+
"version": "2.0.0-beta.29",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@azure/functions": "3.5.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsm": "2.3.0",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
42
|
"uvu": "0.5.6",
|
|
43
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
43
|
+
"@qwik.dev/core": "2.0.0-beta.29"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"main": "./lib/index.qwik.mjs",
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"vite": ">=6 <9",
|
|
172
|
-
"@qwik.dev/core": "^2.0.0-beta.
|
|
172
|
+
"@qwik.dev/core": "^2.0.0-beta.29"
|
|
173
173
|
},
|
|
174
174
|
"publishConfig": {
|
|
175
175
|
"access": "public"
|
|
@@ -184,6 +184,6 @@
|
|
|
184
184
|
"type": "module",
|
|
185
185
|
"types": "./lib/index.d.ts",
|
|
186
186
|
"scripts": {
|
|
187
|
-
"build": "vite build"
|
|
187
|
+
"build": "vite build --mode lib"
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { l as normalizePath } from './fs.mjs';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
|
|
4
|
-
const findLocation = (e) => {
|
|
5
|
-
const stack = e.stack;
|
|
6
|
-
if (typeof stack === "string") {
|
|
7
|
-
const lines = stack.split("\n").filter((l) => !l.includes("/node_modules/") && !l.includes("(node:"));
|
|
8
|
-
for (let i = 1; i < lines.length; i++) {
|
|
9
|
-
const line = lines[i].replace("file:///", "/");
|
|
10
|
-
if (/^\s+at/.test(line)) {
|
|
11
|
-
const start = line.indexOf("/");
|
|
12
|
-
const end = line.lastIndexOf(")", start);
|
|
13
|
-
if (start > 0) {
|
|
14
|
-
const path = line.slice(start, end);
|
|
15
|
-
const parts = path.split(":");
|
|
16
|
-
const nu0 = safeParseInt(parts[parts.length - 1]);
|
|
17
|
-
const nu1 = safeParseInt(parts[parts.length - 2]);
|
|
18
|
-
if (typeof nu0 === "number" && typeof nu1 === "number") {
|
|
19
|
-
parts.length -= 2;
|
|
20
|
-
return {
|
|
21
|
-
file: parts.join(":"),
|
|
22
|
-
line: nu1,
|
|
23
|
-
column: nu0
|
|
24
|
-
};
|
|
25
|
-
} else if (typeof nu0 === "number") {
|
|
26
|
-
parts.length -= 1;
|
|
27
|
-
return {
|
|
28
|
-
file: parts.join(":"),
|
|
29
|
-
line: nu0,
|
|
30
|
-
column: void 0
|
|
31
|
-
};
|
|
32
|
-
} else {
|
|
33
|
-
return {
|
|
34
|
-
file: parts.join(":"),
|
|
35
|
-
line: void 0,
|
|
36
|
-
column: void 0
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return void 0;
|
|
44
|
-
};
|
|
45
|
-
const safeParseInt = (nu) => {
|
|
46
|
-
try {
|
|
47
|
-
return parseInt(nu, 10);
|
|
48
|
-
} catch {
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const splitRE = /\r?\n/;
|
|
53
|
-
const range = 2;
|
|
54
|
-
function posToNumber(source, pos) {
|
|
55
|
-
if (typeof pos === "number") {
|
|
56
|
-
return pos;
|
|
57
|
-
}
|
|
58
|
-
if (pos.lo != null) {
|
|
59
|
-
return pos.lo;
|
|
60
|
-
}
|
|
61
|
-
const lines = source.split(splitRE);
|
|
62
|
-
const { line, column } = pos;
|
|
63
|
-
let start = 0;
|
|
64
|
-
for (let i = 0; i < line - 1 && i < lines.length; i++) {
|
|
65
|
-
start += lines[i].length + 1;
|
|
66
|
-
}
|
|
67
|
-
return start + column;
|
|
68
|
-
}
|
|
69
|
-
function generateCodeFrame(source, start = 0, end) {
|
|
70
|
-
start = posToNumber(source, start);
|
|
71
|
-
end = end || start;
|
|
72
|
-
const lines = source.split(splitRE);
|
|
73
|
-
let count = 0;
|
|
74
|
-
const res = [];
|
|
75
|
-
for (let i = 0; i < lines.length; i++) {
|
|
76
|
-
count += lines[i].length + 1;
|
|
77
|
-
if (count >= start) {
|
|
78
|
-
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
79
|
-
if (j < 0 || j >= lines.length) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const line = j + 1;
|
|
83
|
-
res.push(`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
84
|
-
const lineLength = lines[j].length;
|
|
85
|
-
if (j === i) {
|
|
86
|
-
const pad = Math.max(start - (count - lineLength) + 1, 0);
|
|
87
|
-
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
88
|
-
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
|
89
|
-
} else if (j > i) {
|
|
90
|
-
if (end > count) {
|
|
91
|
-
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
92
|
-
res.push(` | ` + "^".repeat(length));
|
|
93
|
-
}
|
|
94
|
-
count += lineLength + 1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return res.join("\n");
|
|
101
|
-
}
|
|
102
|
-
function parseId(originalId) {
|
|
103
|
-
const [pathId, query] = originalId.split("?");
|
|
104
|
-
const queryStr = query || "";
|
|
105
|
-
return {
|
|
106
|
-
originalId,
|
|
107
|
-
pathId,
|
|
108
|
-
query: queryStr ? `?${query}` : "",
|
|
109
|
-
params: new URLSearchParams(queryStr)
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function formatError(e) {
|
|
114
|
-
if (e instanceof Error) {
|
|
115
|
-
const err = e;
|
|
116
|
-
let loc = err.loc;
|
|
117
|
-
if (!err.frame && !err.plugin) {
|
|
118
|
-
if (!loc) {
|
|
119
|
-
loc = findLocation(err);
|
|
120
|
-
}
|
|
121
|
-
if (loc) {
|
|
122
|
-
err.loc = loc;
|
|
123
|
-
if (loc.file) {
|
|
124
|
-
err.id = normalizePath(err.loc.file);
|
|
125
|
-
try {
|
|
126
|
-
const code = fs.readFileSync(err.loc.file, "utf-8");
|
|
127
|
-
err.frame = generateCodeFrame(code, err.loc);
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return e;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export { formatError as f, parseId as p };
|