@qwik.dev/router 2.0.0-beta.13 → 2.0.0-beta.15
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 +7 -7
- package/lib/adapters/bun-server/vite/index.mjs +7 -7
- package/lib/adapters/cloud-run/vite/index.mjs +7 -7
- package/lib/adapters/cloudflare-pages/vite/index.mjs +8 -8
- package/lib/adapters/deno-server/vite/index.mjs +7 -7
- package/lib/adapters/netlify-edge/vite/index.mjs +7 -7
- package/lib/adapters/node-server/vite/index.mjs +7 -7
- package/lib/adapters/shared/vite/index.mjs +8 -8
- package/lib/adapters/ssg/vite/index.mjs +7 -8
- package/lib/adapters/vercel-edge/vite/index.mjs +7 -7
- package/lib/chunks/error-handler.mjs +2 -4
- package/lib/chunks/format-error.mjs +6 -6
- package/lib/chunks/fs.mjs +6 -27
- package/lib/chunks/index.mjs +39 -31
- package/lib/chunks/mime-types.mjs +2 -3
- package/lib/chunks/routing.qwik.mjs +23 -47
- package/lib/chunks/types.qwik.mjs +2 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.qwik.mjs +48 -68
- package/lib/middleware/aws-lambda/index.mjs +4 -5
- package/lib/middleware/azure-swa/index.mjs +6 -7
- package/lib/middleware/bun/index.mjs +8 -9
- package/lib/middleware/cloudflare-pages/index.mjs +5 -6
- package/lib/middleware/deno/index.mjs +7 -8
- package/lib/middleware/firebase/index.mjs +4 -5
- package/lib/middleware/netlify-edge/index.mjs +5 -6
- package/lib/middleware/node/index.mjs +15 -11
- package/lib/middleware/request-handler/index.d.ts +2 -2
- package/lib/middleware/request-handler/index.mjs +64 -79
- package/lib/middleware/vercel-edge/index.mjs +5 -6
- package/lib/service-worker/index.mjs +2 -3
- package/lib/ssg/index.mjs +3 -4
- package/lib/vite/index.d.ts +7 -1
- package/lib/vite/index.mjs +91 -68
- package/package.json +21 -39
- package/lib/adapters/azure-swa/vite/index.cjs +0 -61
- package/lib/adapters/bun-server/vite/index.cjs +0 -27
- package/lib/adapters/cloud-run/vite/index.cjs +0 -24
- package/lib/adapters/cloudflare-pages/vite/index.cjs +0 -65
- package/lib/adapters/deno-server/vite/index.cjs +0 -39
- package/lib/adapters/netlify-edge/vite/index.cjs +0 -88
- package/lib/adapters/node-server/vite/index.cjs +0 -27
- package/lib/adapters/shared/vite/index.cjs +0 -306
- package/lib/adapters/ssg/vite/index.cjs +0 -19
- package/lib/adapters/vercel-edge/vite/index.cjs +0 -81
- package/lib/chunks/error-handler.cjs +0 -58
- package/lib/chunks/format-error.cjs +0 -136
- package/lib/chunks/fs.cjs +0 -274
- package/lib/chunks/index.cjs +0 -877
- package/lib/chunks/mime-types.cjs +0 -52
- package/lib/chunks/routing.qwik.cjs +0 -452
- package/lib/chunks/types.qwik.cjs +0 -24
- package/lib/index.qwik.cjs +0 -1662
- package/lib/middleware/aws-lambda/index.cjs +0 -52
- package/lib/middleware/azure-swa/index.cjs +0 -92
- package/lib/middleware/bun/index.cjs +0 -143
- package/lib/middleware/cloudflare-pages/index.cjs +0 -96
- package/lib/middleware/deno/index.cjs +0 -130
- package/lib/middleware/firebase/index.cjs +0 -33
- package/lib/middleware/netlify-edge/index.cjs +0 -71
- package/lib/middleware/node/index.cjs +0 -219
- package/lib/middleware/request-handler/index.cjs +0 -1488
- package/lib/middleware/vercel-edge/index.cjs +0 -98
- package/lib/service-worker/index.cjs +0 -5
- package/lib/ssg/index.cjs +0 -15
- package/lib/vite/index.cjs +0 -2021
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function getErrorHtml(status, e) {
|
|
3
|
-
let message = "Server Error";
|
|
4
|
-
if (e != null) {
|
|
5
|
-
if (typeof e.message === "string") {
|
|
6
|
-
message = e.message;
|
|
7
|
-
} else {
|
|
8
|
-
message = String(e);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
|
|
12
|
-
}
|
|
13
|
-
function minimalHtmlResponse(status, message) {
|
|
14
|
-
if (typeof status !== "number") {
|
|
15
|
-
status = 500;
|
|
16
|
-
}
|
|
17
|
-
if (typeof message === "string") {
|
|
18
|
-
message = escapeHtml(message);
|
|
19
|
-
} else {
|
|
20
|
-
message = "";
|
|
21
|
-
}
|
|
22
|
-
const width = typeof message === "string" ? "600px" : "300px";
|
|
23
|
-
const color = status >= 500 ? COLOR_500 : COLOR_400;
|
|
24
|
-
return `
|
|
25
|
-
<head>
|
|
26
|
-
<meta charset="utf-8">
|
|
27
|
-
<meta http-equiv="Status" content="${status}">
|
|
28
|
-
<title>${status} ${message}</title>
|
|
29
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
30
|
-
<style>
|
|
31
|
-
body { color: ${color}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
32
|
-
p { max-width: ${width}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${color}; overflow: hidden; }
|
|
33
|
-
strong { display: inline-block; padding: 15px; background: ${color}; color: white; }
|
|
34
|
-
span { display: inline-block; padding: 15px; }
|
|
35
|
-
</style>
|
|
36
|
-
</head>
|
|
37
|
-
<body><p><strong>${status}</strong> <span>${message}</span></p></body>
|
|
38
|
-
`;
|
|
39
|
-
}
|
|
40
|
-
const ESCAPE_HTML = /[&<>]/g;
|
|
41
|
-
const escapeHtml = (s) => {
|
|
42
|
-
return s.replace(ESCAPE_HTML, (c) => {
|
|
43
|
-
switch (c) {
|
|
44
|
-
case "&":
|
|
45
|
-
return "&";
|
|
46
|
-
case "<":
|
|
47
|
-
return "<";
|
|
48
|
-
case ">":
|
|
49
|
-
return ">";
|
|
50
|
-
default:
|
|
51
|
-
return "";
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
const COLOR_400 = "#006ce9";
|
|
56
|
-
const COLOR_500 = "#713fc2";
|
|
57
|
-
exports.getErrorHtml = getErrorHtml;
|
|
58
|
-
exports.minimalHtmlResponse = minimalHtmlResponse;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const fs = require("./fs.cjs");
|
|
3
|
-
const fs$1 = require("node:fs");
|
|
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
|
-
function formatError(e) {
|
|
113
|
-
if (e instanceof Error) {
|
|
114
|
-
const err = e;
|
|
115
|
-
let loc = err.loc;
|
|
116
|
-
if (!err.frame && !err.plugin) {
|
|
117
|
-
if (!loc) {
|
|
118
|
-
loc = findLocation(err);
|
|
119
|
-
}
|
|
120
|
-
if (loc) {
|
|
121
|
-
err.loc = loc;
|
|
122
|
-
if (loc.file) {
|
|
123
|
-
err.id = fs.normalizePath(err.loc.file);
|
|
124
|
-
try {
|
|
125
|
-
const code = fs$1.readFileSync(err.loc.file, "utf-8");
|
|
126
|
-
err.frame = generateCodeFrame(code, err.loc);
|
|
127
|
-
} catch {
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return e;
|
|
134
|
-
}
|
|
135
|
-
exports.formatError = formatError;
|
|
136
|
-
exports.parseId = parseId;
|
package/lib/chunks/fs.cjs
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const path = require("node:path");
|
|
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
|
-
function normalizePathname(pathname, basePathname) {
|
|
33
|
-
if (typeof pathname === "string") {
|
|
34
|
-
pathname = pathname.trim();
|
|
35
|
-
if (pathname !== "") {
|
|
36
|
-
try {
|
|
37
|
-
pathname = pathname.replace(/\/+/g, "/");
|
|
38
|
-
if (pathname.startsWith("/")) {
|
|
39
|
-
pathname = pathname.slice(1);
|
|
40
|
-
}
|
|
41
|
-
pathname = new URL(basePathname + pathname, `https://qwik.dev`).pathname;
|
|
42
|
-
if (pathname !== basePathname) {
|
|
43
|
-
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
44
|
-
if (!pathname.endsWith("/")) {
|
|
45
|
-
const segments = pathname.split("/");
|
|
46
|
-
const lastSegment = segments[segments.length - 1];
|
|
47
|
-
if (!lastSegment.includes(".")) {
|
|
48
|
-
pathname += "/";
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
if (pathname.endsWith("/")) {
|
|
53
|
-
pathname = pathname.slice(0, pathname.length - 1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return pathname;
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.error(e);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
function getPathnameForDynamicRoute(originalPathname, paramNames, params) {
|
|
66
|
-
let pathname = originalPathname;
|
|
67
|
-
if (paramNames && params) {
|
|
68
|
-
for (const paramName of paramNames) {
|
|
69
|
-
const paramKey = `[${paramName}]`;
|
|
70
|
-
const restParamKey = `[...${paramName}]`;
|
|
71
|
-
const paramValue = params[paramName];
|
|
72
|
-
pathname = pathname.replace(restParamKey, paramValue);
|
|
73
|
-
pathname = pathname.replace(paramKey, paramValue);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return pathname;
|
|
77
|
-
}
|
|
78
|
-
function isSameOriginUrl(url) {
|
|
79
|
-
if (typeof url === "string") {
|
|
80
|
-
url = url.trim();
|
|
81
|
-
if (url !== "") {
|
|
82
|
-
const firstChar = url.charAt(0);
|
|
83
|
-
if (firstChar !== "/" && firstChar !== ".") {
|
|
84
|
-
if (firstChar === "#") {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
const i = url.indexOf(":");
|
|
88
|
-
if (i > -1) {
|
|
89
|
-
const protocol = url.slice(0, i).toLowerCase();
|
|
90
|
-
return !PROTOCOLS[protocol];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
const PROTOCOLS = {
|
|
99
|
-
https: true,
|
|
100
|
-
http: true,
|
|
101
|
-
about: true,
|
|
102
|
-
javascript: true,
|
|
103
|
-
file: true
|
|
104
|
-
};
|
|
105
|
-
function parseRouteIndexName(extlessName) {
|
|
106
|
-
let layoutName = "";
|
|
107
|
-
const layoutStop = extlessName.endsWith("!");
|
|
108
|
-
if (layoutStop) {
|
|
109
|
-
extlessName = extlessName.slice(0, extlessName.length - 1);
|
|
110
|
-
}
|
|
111
|
-
const namedLayoutParts = extlessName.split("@");
|
|
112
|
-
if (namedLayoutParts.length > 1) {
|
|
113
|
-
namedLayoutParts.shift();
|
|
114
|
-
layoutName = namedLayoutParts.join("@");
|
|
115
|
-
}
|
|
116
|
-
return { layoutName, layoutStop };
|
|
117
|
-
}
|
|
118
|
-
function getPathnameFromDirPath(opts, dirPath) {
|
|
119
|
-
const relFilePath = path.relative(opts.routesDir, dirPath);
|
|
120
|
-
let pathname = normalizePath(relFilePath);
|
|
121
|
-
pathname = normalizePathname(pathname, opts.basePathname).split("/").filter((segment) => !isGroupedLayoutName(segment)).join("/");
|
|
122
|
-
if (pathname === "") {
|
|
123
|
-
return "/";
|
|
124
|
-
}
|
|
125
|
-
return pathname;
|
|
126
|
-
}
|
|
127
|
-
function getMenuPathname(opts, filePath) {
|
|
128
|
-
let pathname = normalizePath(path.relative(opts.routesDir, filePath));
|
|
129
|
-
pathname = `/` + normalizePath(path.dirname(pathname));
|
|
130
|
-
let result = normalizePathname(pathname, opts.basePathname);
|
|
131
|
-
if (!result.endsWith("/")) {
|
|
132
|
-
result += "/";
|
|
133
|
-
}
|
|
134
|
-
return result;
|
|
135
|
-
}
|
|
136
|
-
function getExtension(fileName) {
|
|
137
|
-
if (typeof fileName === "string") {
|
|
138
|
-
const parts = fileName.trim().toLowerCase().split(".");
|
|
139
|
-
if (parts.length > 1) {
|
|
140
|
-
const ext = parts.pop().split("?")[0].split("#")[0];
|
|
141
|
-
if (ext === "ts" && parts.pop() === "d") {
|
|
142
|
-
return ".d.ts";
|
|
143
|
-
}
|
|
144
|
-
return "." + ext;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return "";
|
|
148
|
-
}
|
|
149
|
-
function removeExtension(fileName) {
|
|
150
|
-
if (typeof fileName === "string") {
|
|
151
|
-
fileName = fileName.trim();
|
|
152
|
-
const ext = getExtension(fileName);
|
|
153
|
-
return fileName.slice(0, fileName.length - ext.length);
|
|
154
|
-
}
|
|
155
|
-
return "";
|
|
156
|
-
}
|
|
157
|
-
function normalizePath(path$1) {
|
|
158
|
-
return normalizePathSlash(path.normalize(path$1));
|
|
159
|
-
}
|
|
160
|
-
function normalizePathSlash(path2) {
|
|
161
|
-
const isExtendedLengthPath = path2.startsWith("\\\\?\\");
|
|
162
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(path2);
|
|
163
|
-
if (isExtendedLengthPath || hasNonAscii) {
|
|
164
|
-
return path2;
|
|
165
|
-
}
|
|
166
|
-
path2 = path2.replace(/\\/g, "/");
|
|
167
|
-
if (path2.endsWith("/")) {
|
|
168
|
-
path2 = path2.slice(0, path2.length - 1);
|
|
169
|
-
}
|
|
170
|
-
return path2;
|
|
171
|
-
}
|
|
172
|
-
function createFileId(routesDir, fsPath, explicitFileType) {
|
|
173
|
-
const ids = [];
|
|
174
|
-
for (let i = 0; i < 25; i++) {
|
|
175
|
-
let baseName = removeExtension(path.basename(fsPath));
|
|
176
|
-
baseName = baseName.replace(/[\W_]+/g, "");
|
|
177
|
-
if (baseName === "") {
|
|
178
|
-
baseName = "Q" + i;
|
|
179
|
-
} else if (!isNaN(baseName.charAt(0))) {
|
|
180
|
-
baseName = "Q" + baseName;
|
|
181
|
-
}
|
|
182
|
-
ids.push(toTitleCase(baseName));
|
|
183
|
-
fsPath = normalizePath(path.dirname(fsPath));
|
|
184
|
-
if (fsPath === routesDir) {
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (ids.length > 1 && ids[0] === "Index") {
|
|
189
|
-
ids.shift();
|
|
190
|
-
}
|
|
191
|
-
return ids.reverse().join("").concat(explicitFileType || "");
|
|
192
|
-
}
|
|
193
|
-
const PAGE_MODULE_EXTS = {
|
|
194
|
-
".tsx": true,
|
|
195
|
-
".jsx": true
|
|
196
|
-
};
|
|
197
|
-
const MODULE_EXTS = {
|
|
198
|
-
".ts": true,
|
|
199
|
-
".js": true
|
|
200
|
-
};
|
|
201
|
-
const MARKDOWN_EXTS = {
|
|
202
|
-
".md": true,
|
|
203
|
-
".mdx": true
|
|
204
|
-
};
|
|
205
|
-
function isIndexModule(extlessName) {
|
|
206
|
-
return /^index(|!|@.+)$/.test(extlessName);
|
|
207
|
-
}
|
|
208
|
-
function isPluginModule(extlessName) {
|
|
209
|
-
return /^plugin(|@.+)$/.test(extlessName);
|
|
210
|
-
}
|
|
211
|
-
function isLayoutModule(extlessName) {
|
|
212
|
-
return /^layout(|!|-.+)$/.test(extlessName);
|
|
213
|
-
}
|
|
214
|
-
function isPageModuleExt(ext) {
|
|
215
|
-
return ext in PAGE_MODULE_EXTS;
|
|
216
|
-
}
|
|
217
|
-
function isModuleExt(ext) {
|
|
218
|
-
return ext in MODULE_EXTS;
|
|
219
|
-
}
|
|
220
|
-
function isMarkdownExt(ext) {
|
|
221
|
-
return ext in MARKDOWN_EXTS;
|
|
222
|
-
}
|
|
223
|
-
function isPageExt(ext) {
|
|
224
|
-
return ext in PAGE_MODULE_EXTS || ext in MARKDOWN_EXTS;
|
|
225
|
-
}
|
|
226
|
-
function isMenuFileName(fileName) {
|
|
227
|
-
return fileName === "menu.md";
|
|
228
|
-
}
|
|
229
|
-
function isServiceWorkerName(extlessName) {
|
|
230
|
-
return extlessName === "service-worker";
|
|
231
|
-
}
|
|
232
|
-
function isEntryName(extlessName) {
|
|
233
|
-
return extlessName === "entry";
|
|
234
|
-
}
|
|
235
|
-
function isErrorName(extlessName) {
|
|
236
|
-
return /^[45][0-9]{2}$/.test(extlessName);
|
|
237
|
-
}
|
|
238
|
-
function isGroupedLayoutName(dirName, warn = true) {
|
|
239
|
-
if (dirName.startsWith("__")) {
|
|
240
|
-
if (warn) {
|
|
241
|
-
console.warn(
|
|
242
|
-
`Grouped (pathless) layout "${dirName}" should use the "(${dirName.slice(
|
|
243
|
-
2
|
|
244
|
-
)})" directory name instead. Prefixing a directory with "__" has been deprecated and will be removed in future versions.`
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
return dirName.startsWith("(") && dirName.endsWith(")");
|
|
250
|
-
}
|
|
251
|
-
exports.addError = addError;
|
|
252
|
-
exports.addWarning = addWarning;
|
|
253
|
-
exports.createFileId = createFileId;
|
|
254
|
-
exports.getExtension = getExtension;
|
|
255
|
-
exports.getMenuPathname = getMenuPathname;
|
|
256
|
-
exports.getPathnameForDynamicRoute = getPathnameForDynamicRoute;
|
|
257
|
-
exports.getPathnameFromDirPath = getPathnameFromDirPath;
|
|
258
|
-
exports.isEntryName = isEntryName;
|
|
259
|
-
exports.isErrorName = isErrorName;
|
|
260
|
-
exports.isIndexModule = isIndexModule;
|
|
261
|
-
exports.isLayoutModule = isLayoutModule;
|
|
262
|
-
exports.isMarkdownExt = isMarkdownExt;
|
|
263
|
-
exports.isMenuFileName = isMenuFileName;
|
|
264
|
-
exports.isModuleExt = isModuleExt;
|
|
265
|
-
exports.isPageExt = isPageExt;
|
|
266
|
-
exports.isPageModuleExt = isPageModuleExt;
|
|
267
|
-
exports.isPluginModule = isPluginModule;
|
|
268
|
-
exports.isSameOriginUrl = isSameOriginUrl;
|
|
269
|
-
exports.isServiceWorkerName = isServiceWorkerName;
|
|
270
|
-
exports.msToString = msToString;
|
|
271
|
-
exports.normalizePath = normalizePath;
|
|
272
|
-
exports.normalizePathSlash = normalizePathSlash;
|
|
273
|
-
exports.parseRouteIndexName = parseRouteIndexName;
|
|
274
|
-
exports.removeExtension = removeExtension;
|