@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.
- 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 +171 -157
- 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 +24 -8
- package/lib/middleware/cloudflare-pages/index.mjs +10 -3
- package/lib/middleware/deno/index.mjs +23 -8
- package/lib/middleware/netlify-edge/index.mjs +10 -3
- 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 +10 -3
- 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 +1106 -630
- package/modules.d.ts +7 -4
- package/package.json +9 -9
- package/lib/chunks/format-error.mjs +0 -137
- package/lib/chunks/index.mjs +0 -884
- package/lib/chunks/types.qwik.mjs +0 -22
package/lib/chunks/fs.mjs
CHANGED
|
@@ -1,108 +1,5 @@
|
|
|
1
1
|
import { normalize, basename, dirname, relative } from 'node:path';
|
|
2
|
-
|
|
3
|
-
function toTitleCase(str) {
|
|
4
|
-
return str.replace(/\w\S*/g, (txt) => {
|
|
5
|
-
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
function addError(ctx, e) {
|
|
9
|
-
ctx.diagnostics.push({
|
|
10
|
-
type: "error",
|
|
11
|
-
message: e ? String(e.stack || e) : "Error"
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function addWarning(ctx, message) {
|
|
15
|
-
ctx.diagnostics.push({
|
|
16
|
-
type: "warn",
|
|
17
|
-
message: String(message)
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function msToString(ms) {
|
|
21
|
-
if (ms < 1) {
|
|
22
|
-
return ms.toFixed(2) + " ms";
|
|
23
|
-
}
|
|
24
|
-
if (ms < 1e3) {
|
|
25
|
-
return ms.toFixed(1) + " ms";
|
|
26
|
-
}
|
|
27
|
-
if (ms < 6e4) {
|
|
28
|
-
return (ms / 1e3).toFixed(1) + " s";
|
|
29
|
-
}
|
|
30
|
-
return (ms / 6e4).toFixed(1) + " m";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function normalizePathname(pathname, basePathname) {
|
|
34
|
-
if (typeof pathname === "string") {
|
|
35
|
-
pathname = pathname.trim();
|
|
36
|
-
if (pathname !== "") {
|
|
37
|
-
try {
|
|
38
|
-
pathname = pathname.replace(/\/+/g, "/");
|
|
39
|
-
if (pathname.startsWith("/")) {
|
|
40
|
-
pathname = pathname.slice(1);
|
|
41
|
-
}
|
|
42
|
-
pathname = new URL(basePathname + pathname, `https://qwik.dev`).pathname;
|
|
43
|
-
if (pathname !== basePathname) {
|
|
44
|
-
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
45
|
-
if (!pathname.endsWith("/")) {
|
|
46
|
-
const segments = pathname.split("/");
|
|
47
|
-
const lastSegment = segments[segments.length - 1];
|
|
48
|
-
if (!lastSegment.includes(".")) {
|
|
49
|
-
pathname += "/";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
if (pathname.endsWith("/")) {
|
|
54
|
-
pathname = pathname.slice(0, pathname.length - 1);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return pathname;
|
|
59
|
-
} catch (e) {
|
|
60
|
-
console.error(e);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
function getPathnameForDynamicRoute(originalPathname, paramNames, params) {
|
|
67
|
-
let pathname = originalPathname;
|
|
68
|
-
if (paramNames && params) {
|
|
69
|
-
for (const paramName of paramNames) {
|
|
70
|
-
const paramKey = `[${paramName}]`;
|
|
71
|
-
const restParamKey = `[...${paramName}]`;
|
|
72
|
-
const paramValue = params[paramName];
|
|
73
|
-
pathname = pathname.replace(restParamKey, paramValue);
|
|
74
|
-
pathname = pathname.replace(paramKey, paramValue);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return pathname;
|
|
78
|
-
}
|
|
79
|
-
function isSameOriginUrl(url) {
|
|
80
|
-
if (typeof url === "string") {
|
|
81
|
-
url = url.trim();
|
|
82
|
-
if (url !== "") {
|
|
83
|
-
const firstChar = url.charAt(0);
|
|
84
|
-
if (firstChar !== "/" && firstChar !== ".") {
|
|
85
|
-
if (firstChar === "#") {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
const i = url.indexOf(":");
|
|
89
|
-
if (i > -1) {
|
|
90
|
-
const protocol = url.slice(0, i).toLowerCase();
|
|
91
|
-
return !PROTOCOLS[protocol];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
const PROTOCOLS = {
|
|
100
|
-
https: true,
|
|
101
|
-
http: true,
|
|
102
|
-
about: true,
|
|
103
|
-
javascript: true,
|
|
104
|
-
file: true
|
|
105
|
-
};
|
|
2
|
+
import { t as toTitleCase, n as normalizePathname } from './pathname.mjs';
|
|
106
3
|
|
|
107
4
|
function parseRouteIndexName(extlessName) {
|
|
108
5
|
let layoutName = "";
|
|
@@ -115,25 +12,10 @@ function parseRouteIndexName(extlessName) {
|
|
|
115
12
|
namedLayoutParts.shift();
|
|
116
13
|
layoutName = namedLayoutParts.join("@");
|
|
117
14
|
}
|
|
118
|
-
return {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
let pathname = normalizePath(relFilePath);
|
|
123
|
-
pathname = normalizePathname(pathname, opts.basePathname).split("/").filter((segment) => !isGroupedLayoutName(segment)).join("/");
|
|
124
|
-
if (pathname === "") {
|
|
125
|
-
return "/";
|
|
126
|
-
}
|
|
127
|
-
return pathname;
|
|
128
|
-
}
|
|
129
|
-
function getMenuPathname(opts, filePath) {
|
|
130
|
-
let pathname = normalizePath(relative(opts.routesDir, filePath));
|
|
131
|
-
pathname = `/` + normalizePath(dirname(pathname));
|
|
132
|
-
let result = normalizePathname(pathname, opts.basePathname);
|
|
133
|
-
if (!result.endsWith("/")) {
|
|
134
|
-
result += "/";
|
|
135
|
-
}
|
|
136
|
-
return result;
|
|
15
|
+
return {
|
|
16
|
+
layoutName,
|
|
17
|
+
layoutStop
|
|
18
|
+
};
|
|
137
19
|
}
|
|
138
20
|
function getExtension(fileName) {
|
|
139
21
|
if (typeof fileName === "string") {
|
|
@@ -156,9 +38,6 @@ function removeExtension(fileName) {
|
|
|
156
38
|
}
|
|
157
39
|
return "";
|
|
158
40
|
}
|
|
159
|
-
function normalizePath(path) {
|
|
160
|
-
return normalizePathSlash(normalize(path));
|
|
161
|
-
}
|
|
162
41
|
function normalizePathSlash(path) {
|
|
163
42
|
const isExtendedLengthPath = path.startsWith("\\\\?\\");
|
|
164
43
|
const hasNonAscii = /[^\u0000-\u0080]+/.test(path);
|
|
@@ -171,6 +50,18 @@ function normalizePathSlash(path) {
|
|
|
171
50
|
}
|
|
172
51
|
return path;
|
|
173
52
|
}
|
|
53
|
+
function normalizePath(path) {
|
|
54
|
+
return normalizePathSlash(normalize(path));
|
|
55
|
+
}
|
|
56
|
+
function getMenuPathname(opts, filePath) {
|
|
57
|
+
let pathname = normalizePath(relative(opts.routesDir, filePath));
|
|
58
|
+
pathname = `/` + normalizePath(dirname(pathname));
|
|
59
|
+
let result = normalizePathname(pathname, opts.basePathname);
|
|
60
|
+
if (!result.endsWith("/")) {
|
|
61
|
+
result += "/";
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
174
65
|
function createFileId(routesDir, fsPath, explicitFileType) {
|
|
175
66
|
const ids = [];
|
|
176
67
|
for (let i = 0; i < 25; i++) {
|
|
@@ -235,20 +126,19 @@ function isEntryName(extlessName) {
|
|
|
235
126
|
return extlessName === "entry";
|
|
236
127
|
}
|
|
237
128
|
function isErrorName(extlessName) {
|
|
238
|
-
return
|
|
129
|
+
return extlessName === "error" || extlessName === "404";
|
|
239
130
|
}
|
|
240
131
|
function isGroupedLayoutName(dirName, warn = true) {
|
|
241
|
-
if (dirName.startsWith("__")) {
|
|
242
|
-
if (warn) {
|
|
243
|
-
console.warn(
|
|
244
|
-
`Grouped (pathless) layout "${dirName}" should use the "(${dirName.slice(
|
|
245
|
-
2
|
|
246
|
-
)})" directory name instead. Prefixing a directory with "__" has been deprecated and will be removed in future versions.`
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
251
132
|
return dirName.startsWith("(") && dirName.endsWith(")");
|
|
252
133
|
}
|
|
134
|
+
function getPathnameFromDirPath(opts, dirPath) {
|
|
135
|
+
const relFilePath = relative(opts.routesDir, dirPath);
|
|
136
|
+
let pathname = normalizePath(relFilePath);
|
|
137
|
+
pathname = normalizePathname(pathname, opts.basePathname).split("/").filter((segment) => !isGroupedLayoutName(segment)).join("/");
|
|
138
|
+
if (pathname === "") {
|
|
139
|
+
return "/";
|
|
140
|
+
}
|
|
141
|
+
return pathname;
|
|
142
|
+
}
|
|
253
143
|
|
|
254
|
-
export { isErrorName as a, isLayoutModule as b, isEntryName as c, isMenuFileName as d, isServiceWorkerName as e, isPageModuleExt as f, getExtension as g, isModuleExt as h, isIndexModule as i, isMarkdownExt as j,
|
|
144
|
+
export { isErrorName as a, isLayoutModule as b, isEntryName as c, isMenuFileName as d, isServiceWorkerName as e, isPageModuleExt as f, getExtension as g, isModuleExt as h, isIndexModule as i, isMarkdownExt as j, normalizePath as k, getPathnameFromDirPath as l, getMenuPathname as m, normalizePathSlash as n, createFileId as o, parseRouteIndexName as p, isPluginModule as q, removeExtension as r, isPageExt as s };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { componentQrl, inlinedQrl, _jsxSorted } from '@qwik.dev/core';
|
|
2
|
+
import { k as useHttpStatus } from './use-functions.qwik.mjs';
|
|
3
|
+
|
|
4
|
+
const cacheKey = (status) => String(status);
|
|
5
|
+
const COLOR_400 = "#006ce9";
|
|
6
|
+
const COLOR_500 = "#713fc2";
|
|
7
|
+
const DisplayHttpStatus = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
8
|
+
const { status, message } = useHttpStatus();
|
|
9
|
+
const width = message ? "600px" : "300px";
|
|
10
|
+
const color = status < 500 ? COLOR_400 : COLOR_500;
|
|
11
|
+
const style = `
|
|
12
|
+
body { color: ${color}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
13
|
+
p { max-width: ${width}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${color}; overflow: hidden; }
|
|
14
|
+
strong { display: inline-block; padding: 15px; background: ${color}; color: white; }
|
|
15
|
+
span { display: inline-block; padding: 15px; }
|
|
16
|
+
`;
|
|
17
|
+
return /* @__PURE__ */ _jsxSorted("p", null, null, [
|
|
18
|
+
/* @__PURE__ */ _jsxSorted("style", {
|
|
19
|
+
dangerouslySetInnerHTML: style
|
|
20
|
+
}, null, null, 3, null),
|
|
21
|
+
/* @__PURE__ */ _jsxSorted("strong", null, null, status || 500, 3, null),
|
|
22
|
+
" ",
|
|
23
|
+
/* @__PURE__ */ _jsxSorted("span", null, null, message || "", 3, null)
|
|
24
|
+
], 1, "vY_0");
|
|
25
|
+
}, "DisplayHttpStatus_component_PJf4K4PL7Oc"));
|
|
26
|
+
|
|
27
|
+
export { cacheKey, DisplayHttpStatus as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { k as useHttpStatus } from './use-functions.qwik.mjs';
|
|
2
|
+
|
|
3
|
+
function createNotFoundWrapper(notFoundMod, errorMod) {
|
|
4
|
+
const NotFound = notFoundMod.default;
|
|
5
|
+
const ErrorPage = errorMod.default;
|
|
6
|
+
const Component = () => {
|
|
7
|
+
const { status } = useHttpStatus();
|
|
8
|
+
if (status === 404 && NotFound) {
|
|
9
|
+
return NotFound({});
|
|
10
|
+
}
|
|
11
|
+
if (ErrorPage) {
|
|
12
|
+
return ErrorPage({});
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
const notFoundHead = notFoundMod.routeConfig && typeof notFoundMod.routeConfig !== "function" ? notFoundMod.routeConfig.head : notFoundMod.head;
|
|
17
|
+
const errorHead = errorMod.routeConfig && typeof errorMod.routeConfig !== "function" ? errorMod.routeConfig.head : errorMod.head;
|
|
18
|
+
return {
|
|
19
|
+
default: Component,
|
|
20
|
+
head: notFoundHead ?? errorHead,
|
|
21
|
+
cacheKey: (status) => String(status)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { createNotFoundWrapper };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function toTitleCase(str) {
|
|
2
|
+
return str.replace(/\w\S*/g, (txt) => {
|
|
3
|
+
return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase();
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
function addError(ctx, e) {
|
|
7
|
+
ctx.diagnostics.push({
|
|
8
|
+
type: "error",
|
|
9
|
+
message: e ? String(e.stack || e) : "Error"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function addWarning(ctx, message) {
|
|
13
|
+
ctx.diagnostics.push({
|
|
14
|
+
type: "warn",
|
|
15
|
+
message: String(message)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function msToString(ms) {
|
|
19
|
+
if (ms < 1) {
|
|
20
|
+
return ms.toFixed(2) + " ms";
|
|
21
|
+
}
|
|
22
|
+
if (ms < 1e3) {
|
|
23
|
+
return ms.toFixed(1) + " ms";
|
|
24
|
+
}
|
|
25
|
+
if (ms < 6e4) {
|
|
26
|
+
return (ms / 1e3).toFixed(1) + " s";
|
|
27
|
+
}
|
|
28
|
+
return (ms / 6e4).toFixed(1) + " m";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizePathname(pathname, basePathname) {
|
|
32
|
+
if (typeof pathname === "string") {
|
|
33
|
+
pathname = pathname.trim();
|
|
34
|
+
if (pathname !== "") {
|
|
35
|
+
try {
|
|
36
|
+
pathname = pathname.replace(/\/+/g, "/");
|
|
37
|
+
if (pathname.startsWith("/")) {
|
|
38
|
+
pathname = pathname.slice(1);
|
|
39
|
+
}
|
|
40
|
+
pathname = new URL(basePathname + pathname, `https://qwik.dev`).pathname;
|
|
41
|
+
if (pathname !== basePathname) {
|
|
42
|
+
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
43
|
+
if (!pathname.endsWith("/")) {
|
|
44
|
+
const segments = pathname.split("/");
|
|
45
|
+
const lastSegment = segments[segments.length - 1];
|
|
46
|
+
if (!lastSegment.includes(".")) {
|
|
47
|
+
pathname += "/";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
if (pathname.endsWith("/")) {
|
|
52
|
+
pathname = pathname.slice(0, pathname.length - 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return pathname;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.error(e);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
function getPathnameForDynamicRoute(originalPathname, paramNames, params) {
|
|
65
|
+
let pathname = originalPathname;
|
|
66
|
+
if (paramNames && params) {
|
|
67
|
+
for (const paramName of paramNames) {
|
|
68
|
+
const paramKey = `[${paramName}]`;
|
|
69
|
+
const restParamKey = `[...${paramName}]`;
|
|
70
|
+
const paramValue = params[paramName];
|
|
71
|
+
pathname = pathname.replace(restParamKey, paramValue);
|
|
72
|
+
pathname = pathname.replace(paramKey, paramValue);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return pathname;
|
|
76
|
+
}
|
|
77
|
+
const PROTOCOLS = {
|
|
78
|
+
https: true,
|
|
79
|
+
http: true,
|
|
80
|
+
about: true,
|
|
81
|
+
javascript: true,
|
|
82
|
+
file: true
|
|
83
|
+
};
|
|
84
|
+
function isSameOriginUrl(url) {
|
|
85
|
+
if (typeof url === "string") {
|
|
86
|
+
url = url.trim();
|
|
87
|
+
if (url !== "") {
|
|
88
|
+
const firstChar = url.charAt(0);
|
|
89
|
+
if (firstChar !== "/" && firstChar !== ".") {
|
|
90
|
+
if (firstChar === "#") {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const i = url.indexOf(":");
|
|
94
|
+
if (i > -1) {
|
|
95
|
+
const protocol = url.slice(0, i).toLowerCase();
|
|
96
|
+
return !PROTOCOLS[protocol];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { addError as a, addWarning as b, getPathnameForDynamicRoute as g, isSameOriginUrl as i, msToString as m, normalizePathname as n, toTitleCase as t };
|