@qwik.dev/router 2.0.0-beta.39 → 2.0.0-beta.40
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 +45 -54
- package/lib/adapters/bun-server/vite/index.mjs +16 -22
- package/lib/adapters/cloud-run/vite/index.mjs +15 -19
- package/lib/adapters/cloudflare-pages/vite/index.mjs +46 -67
- package/lib/adapters/deno-server/vite/index.mjs +25 -39
- package/lib/adapters/netlify-edge/vite/index.mjs +50 -76
- package/lib/adapters/node-server/vite/index.mjs +16 -22
- package/lib/adapters/shared/vite/index.mjs +271 -360
- package/lib/adapters/ssg/vite/index.mjs +11 -15
- package/lib/adapters/vercel-edge/vite/index.mjs +74 -95
- package/lib/chunks/dev-preloaded-route-loader.mjs +2 -3
- package/lib/chunks/format.mjs +16 -23
- package/lib/chunks/fs.mjs +93 -106
- package/lib/chunks/head.qwik.mjs +1174 -1382
- package/lib/chunks/http-error.qwik.mjs +20 -28
- package/lib/chunks/pathname.mjs +50 -69
- package/lib/chunks/request-body-limit.mjs +25 -35
- package/lib/chunks/request-path.mjs +44 -55
- package/lib/chunks/routes.mjs +20 -41
- package/lib/chunks/server-error.mjs +15 -18
- package/lib/chunks/system.mjs +258 -326
- package/lib/chunks/url.mjs +56 -58
- package/lib/chunks/user-response.mjs +1616 -1804
- package/lib/chunks/worker-thread.mjs +254 -307
- package/lib/index.qwik.mjs +1637 -1918
- package/lib/middleware/aws-lambda/index.mjs +44 -52
- package/lib/middleware/azure-swa/index.mjs +85 -94
- package/lib/middleware/bun/index.mjs +118 -138
- package/lib/middleware/cloudflare-pages/index.mjs +83 -96
- package/lib/middleware/deno/index.mjs +104 -125
- package/lib/middleware/firebase/index.mjs +21 -25
- package/lib/middleware/netlify-edge/index.mjs +63 -71
- package/lib/middleware/node/index.mjs +297 -357
- package/lib/middleware/request-handler/index.mjs +110 -133
- package/lib/middleware/vercel-edge/index.mjs +82 -98
- package/lib/service-worker/index.mjs +12 -3
- package/lib/ssg/index.mjs +249 -289
- package/lib/vite/index.mjs +2344 -3030
- package/package.json +5 -5
- package/lib/chunks/use-functions.qwik.mjs +0 -23
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const style = `
|
|
1
|
+
import { useHttpStatus } from "../index.qwik.mjs";
|
|
2
|
+
import { _fnSignal, _jsxSorted, componentQrl, inlinedQrl } from "@qwik.dev/core";
|
|
3
|
+
var _hf0 = (p0) => p0.status || 500;
|
|
4
|
+
var _hf0_str = "p0.status||500";
|
|
5
|
+
var _hf1 = (p0) => p0.message || "";
|
|
6
|
+
var _hf1_str = "p0.message||\"\"";
|
|
7
|
+
/** Cache error pages per status code so all 404s (or 500s) share one cache entry. */ var cacheKey = (ev) => String(ev.status);
|
|
8
|
+
var COLOR_400 = "#006ce9";
|
|
9
|
+
var COLOR_500 = "#713fc2";
|
|
10
|
+
var DisplayHttpStatus = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl(() => {
|
|
11
|
+
const httpstatus = useHttpStatus();
|
|
12
|
+
const width = httpstatus.message ? "600px" : "300px";
|
|
13
|
+
const color = httpstatus.status < 500 ? COLOR_400 : COLOR_500;
|
|
14
|
+
const style = `
|
|
16
15
|
body { color: ${color}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
17
16
|
p { max-width: ${width}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${color}; overflow: hidden; }
|
|
18
17
|
strong { display: inline-block; padding: 15px; background: ${color}; color: white; }
|
|
19
18
|
span { display: inline-block; padding: 15px; }
|
|
20
19
|
`;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
], _hf0_str), 3, null),
|
|
28
|
-
" ",
|
|
29
|
-
/* @__PURE__ */ _jsxSorted("span", null, null, _fnSignal(_hf1, [
|
|
30
|
-
httpstatus
|
|
31
|
-
], _hf1_str), 3, null)
|
|
32
|
-
], 1, "vY_0");
|
|
20
|
+
return /*#__PURE__*/ _jsxSorted("p", null, null, [
|
|
21
|
+
/*#__PURE__*/ _jsxSorted("style", { dangerouslySetInnerHTML: style }, null, null, 3, null),
|
|
22
|
+
/*#__PURE__*/ _jsxSorted("strong", null, null, _fnSignal(_hf0, [httpstatus], _hf0_str), 3, null),
|
|
23
|
+
" ",
|
|
24
|
+
/*#__PURE__*/ _jsxSorted("span", null, null, _fnSignal(_hf1, [httpstatus], _hf1_str), 3, null)
|
|
25
|
+
], 1, "vY_0");
|
|
33
26
|
}, "DisplayHttpStatus_component_PJf4K4PL7Oc"));
|
|
34
|
-
|
|
35
27
|
export { cacheKey, DisplayHttpStatus as default };
|
package/lib/chunks/pathname.mjs
CHANGED
|
@@ -1,76 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
/** Ensures the pathname ends with a slash */ var ensureSlash = (pathname) => pathname.endsWith("/") ? pathname : pathname + "/";
|
|
2
2
|
function normalizePathname(pathname, basePathname) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
pathname = pathname.slice(0, pathname.length - 1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return pathname;
|
|
28
|
-
} catch (e) {
|
|
29
|
-
console.error(e);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
3
|
+
if (typeof pathname === "string") {
|
|
4
|
+
pathname = pathname.trim();
|
|
5
|
+
if (pathname !== "") try {
|
|
6
|
+
pathname = pathname.replace(/\/+/g, "/");
|
|
7
|
+
if (pathname.startsWith("/")) pathname = pathname.slice(1);
|
|
8
|
+
pathname = new URL(basePathname + pathname, `https://qwik.dev`).pathname;
|
|
9
|
+
if (pathname !== basePathname) {
|
|
10
|
+
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
11
|
+
if (!pathname.endsWith("/")) {
|
|
12
|
+
const segments = pathname.split("/");
|
|
13
|
+
if (!segments[segments.length - 1].includes(".")) pathname = ensureSlash(pathname);
|
|
14
|
+
}
|
|
15
|
+
} else if (pathname.endsWith("/")) pathname = pathname.slice(0, pathname.length - 1);
|
|
16
|
+
}
|
|
17
|
+
return pathname;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
34
23
|
}
|
|
35
24
|
function getPathnameForDynamicRoute(originalPathname, paramNames, params) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return pathname;
|
|
25
|
+
let pathname = originalPathname;
|
|
26
|
+
if (paramNames && params) for (const paramName of paramNames) {
|
|
27
|
+
const paramKey = `[${paramName}]`;
|
|
28
|
+
const restParamKey = `[...${paramName}]`;
|
|
29
|
+
const paramValue = params[paramName];
|
|
30
|
+
pathname = pathname.replace(restParamKey, paramValue);
|
|
31
|
+
pathname = pathname.replace(paramKey, paramValue);
|
|
32
|
+
}
|
|
33
|
+
return pathname;
|
|
47
34
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
var PROTOCOLS = {
|
|
36
|
+
https: true,
|
|
37
|
+
http: true,
|
|
38
|
+
about: true,
|
|
39
|
+
javascript: true,
|
|
40
|
+
file: true
|
|
54
41
|
};
|
|
55
42
|
function isSameOriginUrl(url) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
43
|
+
if (typeof url === "string") {
|
|
44
|
+
url = url.trim();
|
|
45
|
+
if (url !== "") {
|
|
46
|
+
const firstChar = url.charAt(0);
|
|
47
|
+
if (firstChar !== "/" && firstChar !== ".") {
|
|
48
|
+
if (firstChar === "#") return false;
|
|
49
|
+
const i = url.indexOf(":");
|
|
50
|
+
if (i > -1) return !PROTOCOLS[url.slice(0, i).toLowerCase()];
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
74
56
|
}
|
|
75
|
-
|
|
76
|
-
export { ensureSlash as e, getPathnameForDynamicRoute as g, isSameOriginUrl as i, normalizePathname as n };
|
|
57
|
+
export { normalizePathname as i, getPathnameForDynamicRoute as n, isSameOriginUrl as r, ensureSlash as t };
|
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const validateRequestBodyLimit = (requestBodyLimit) => {
|
|
12
|
-
if (!Number.isSafeInteger(requestBodyLimit) || requestBodyLimit <= 0) {
|
|
13
|
-
throw new TypeError("requestBodyLimit must be a positive safe integer");
|
|
14
|
-
}
|
|
1
|
+
import { t as ServerError } from "./server-error.mjs";
|
|
2
|
+
var DEFAULT_REQUEST_BODY_LIMIT = 10485760;
|
|
3
|
+
var RequestBodyLimitError = class extends ServerError {
|
|
4
|
+
code = "QWIK_REQUEST_BODY_LIMIT";
|
|
5
|
+
statusCode = 413;
|
|
6
|
+
constructor(limit) {
|
|
7
|
+
super(413, `Request body exceeds ${limit} bytes`);
|
|
8
|
+
}
|
|
15
9
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!request.body) {
|
|
19
|
-
return request;
|
|
20
|
-
}
|
|
21
|
-
let received = 0;
|
|
22
|
-
const body = request.body.pipeThrough(new TransformStream({
|
|
23
|
-
transform(chunk, controller) {
|
|
24
|
-
if (chunk.byteLength > requestBodyLimit - received) {
|
|
25
|
-
throw new RequestBodyLimitError(requestBodyLimit);
|
|
26
|
-
}
|
|
27
|
-
received += chunk.byteLength;
|
|
28
|
-
controller.enqueue(chunk);
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
return new Request(request, {
|
|
32
|
-
body,
|
|
33
|
-
duplex: "half"
|
|
34
|
-
});
|
|
10
|
+
var validateRequestBodyLimit = (requestBodyLimit) => {
|
|
11
|
+
if (!Number.isSafeInteger(requestBodyLimit) || requestBodyLimit <= 0) throw new TypeError("requestBodyLimit must be a positive safe integer");
|
|
35
12
|
};
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
var limitRequestBody = (request, requestBodyLimit = DEFAULT_REQUEST_BODY_LIMIT) => {
|
|
14
|
+
validateRequestBodyLimit(requestBodyLimit);
|
|
15
|
+
if (!request.body) return request;
|
|
16
|
+
let received = 0;
|
|
17
|
+
const body = request.body.pipeThrough(new TransformStream({ transform(chunk, controller) {
|
|
18
|
+
if (chunk.byteLength > requestBodyLimit - received) throw new RequestBodyLimitError(requestBodyLimit);
|
|
19
|
+
received += chunk.byteLength;
|
|
20
|
+
controller.enqueue(chunk);
|
|
21
|
+
} }));
|
|
22
|
+
return new Request(request, {
|
|
23
|
+
body,
|
|
24
|
+
duplex: "half"
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export { validateRequestBodyLimit as i, RequestBodyLimitError as n, limitRequestBody as r, DEFAULT_REQUEST_BODY_LIMIT as t };
|
|
@@ -1,60 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { t as ensureSlash } from "./pathname.mjs";
|
|
2
|
+
var IsQLoader = "@isQLoader";
|
|
3
|
+
var IsQAction = "@isQAction";
|
|
4
|
+
var QLoaderId = "@loaderId";
|
|
5
|
+
var QActionId = "@actionId";
|
|
6
|
+
/** Matches the final `/q-loader-{loaderId}.{manifestHash}.json` path segment. */ var LOADER_REGEX = /\/(q-loader-([^/.]+)\.([^/.]+)\.json)$/;
|
|
7
|
+
var getLoaderName = (loaderId, manifestHash) => `q-loader-${loaderId}.${manifestHash}.json`;
|
|
8
|
+
/**
|
|
9
|
+
* Recognize internal request types from the URL pathname.
|
|
10
|
+
*
|
|
11
|
+
* Returns the request type, how many characters to trim from the pathname, and any extracted data
|
|
12
|
+
* (e.g. loaderId for loader requests).
|
|
13
|
+
*/ function recognizeRequest(pathname) {
|
|
14
|
+
if (pathname.length < 10) return null;
|
|
15
|
+
const loaderMatch = pathname.match(LOADER_REGEX);
|
|
16
|
+
if (loaderMatch) return {
|
|
17
|
+
type: IsQLoader,
|
|
18
|
+
trimLength: loaderMatch[1].length + 1,
|
|
19
|
+
data: {
|
|
20
|
+
loaderId: loaderMatch[2],
|
|
21
|
+
manifestHash: loaderMatch[3]
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return null;
|
|
25
25
|
}
|
|
26
|
-
function trimRecognizedInternalPathname(pathname, recognized) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
return trimmed;
|
|
26
|
+
/** Trim a recognized internal URL suffix from a pathname, returning the clean route pathname. */ function trimRecognizedInternalPathname(pathname, recognized) {
|
|
27
|
+
let trimmed = pathname.slice(0, pathname.length - recognized.trimLength) || "/";
|
|
28
|
+
if (!globalThis.__NO_TRAILING_SLASH__ && !trimmed.endsWith("/")) trimmed = ensureSlash(trimmed);
|
|
29
|
+
return trimmed;
|
|
32
30
|
}
|
|
33
|
-
function trimInternalPathname(pathname) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return pathname;
|
|
31
|
+
/** Trim any recognized internal URL suffix from a pathname, returning the clean route pathname. */ function trimInternalPathname(pathname) {
|
|
32
|
+
const recognized = recognizeRequest(pathname);
|
|
33
|
+
if (recognized) return trimRecognizedInternalPathname(pathname, recognized);
|
|
34
|
+
return pathname;
|
|
39
35
|
}
|
|
40
36
|
function resolveValidInternalFullPathname(loaderPathname, fullPath) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
const loaderPrefix = ensureSlash(loaderPathname);
|
|
54
|
-
return pagePathname.startsWith(loaderPrefix) ? pagePathname : void 0;
|
|
55
|
-
} catch {
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
37
|
+
if (!fullPath || !fullPath.startsWith("/") || fullPath.startsWith("//")) return;
|
|
38
|
+
try {
|
|
39
|
+
const pageUrl = new URL(fullPath, "http://qwik.internal");
|
|
40
|
+
if (pageUrl.origin !== "http://qwik.internal") return;
|
|
41
|
+
const pagePathname = pageUrl.pathname;
|
|
42
|
+
if (pagePathname === loaderPathname) return;
|
|
43
|
+
const loaderPrefix = ensureSlash(loaderPathname);
|
|
44
|
+
return pagePathname.startsWith(loaderPrefix) ? pagePathname : void 0;
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
58
48
|
}
|
|
59
|
-
|
|
60
|
-
export { IsQLoader as I, LOADER_REGEX as L, QLoaderId as Q, resolveValidInternalFullPathname as a, trimInternalPathname as b, IsQAction as c, QActionId as d, getLoaderName as g, recognizeRequest as r, trimRecognizedInternalPathname as t };
|
|
49
|
+
export { QLoaderId as a, resolveValidInternalFullPathname as c, QActionId as i, trimInternalPathname as l, IsQLoader as n, getLoaderName as o, LOADER_REGEX as r, recognizeRequest as s, IsQAction as t, trimRecognizedInternalPathname as u };
|
package/lib/chunks/routes.mjs
CHANGED
|
@@ -1,47 +1,26 @@
|
|
|
1
1
|
function routeToRegExp(rule) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
transformedRule = rule;
|
|
11
|
-
} else {
|
|
12
|
-
transformedRule = `${rule}(/)?`;
|
|
13
|
-
}
|
|
14
|
-
transformedRule = `^${transformedRule.replace(/\*/g, ".*")}$`;
|
|
15
|
-
return new RegExp(transformedRule);
|
|
2
|
+
let transformedRule;
|
|
3
|
+
if (rule === "/" || rule === "/*") transformedRule = rule;
|
|
4
|
+
else if (rule.endsWith("/*")) transformedRule = `${rule.substring(0, rule.length - 2)}(/*)?`;
|
|
5
|
+
else if (rule.endsWith("/")) transformedRule = `${rule.substring(0, rule.length - 1)}(/)?`;
|
|
6
|
+
else if (rule.endsWith("*")) transformedRule = rule;
|
|
7
|
+
else transformedRule = `${rule}(/)?`;
|
|
8
|
+
transformedRule = `^${transformedRule.replace(/\*/g, ".*")}$`;
|
|
9
|
+
return new RegExp(transformedRule);
|
|
16
10
|
}
|
|
17
11
|
function routesToRegExps(routes) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return routes.filter((r) => typeof r === "string").map(routeToRegExp);
|
|
12
|
+
if (!Array.isArray(routes)) return [];
|
|
13
|
+
return routes.filter((r) => typeof r === "string").map(routeToRegExp);
|
|
22
14
|
}
|
|
23
15
|
function createRouteTester(basePathname, includeRoutes, excludeRoutes) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (pathname.endsWith("/404.html")) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
for (const include of includes) {
|
|
39
|
-
if (include.test(pathname)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
16
|
+
const includes = routesToRegExps(includeRoutes);
|
|
17
|
+
const excludes = routesToRegExps(excludeRoutes);
|
|
18
|
+
return (pathname) => {
|
|
19
|
+
if (basePathname !== "/") pathname = pathname.slice(basePathname.length - 1);
|
|
20
|
+
for (const exclude of excludes) if (exclude.test(pathname)) return false;
|
|
21
|
+
if (pathname.endsWith("/404.html")) return true;
|
|
22
|
+
for (const include of includes) if (include.test(pathname)) return true;
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
45
25
|
}
|
|
46
|
-
|
|
47
|
-
export { createRouteTester as c };
|
|
26
|
+
export { createRouteTester as t };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
}
|
|
3
|
-
class
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor(status, data) {
|
|
10
|
-
super(typeof data === "string" ? data : void 0), this.status = status, this.data = data;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const throwIfControlFlowSignal = (value) => {
|
|
14
|
-
if (value instanceof AbortMessage || value instanceof ServerError) {
|
|
15
|
-
throw value;
|
|
16
|
-
}
|
|
1
|
+
/** @public */ var AbortMessage = class {};
|
|
2
|
+
/** @public */ var RedirectMessage = class extends AbortMessage {};
|
|
3
|
+
/** @public */ var ServerError = class extends Error {
|
|
4
|
+
status;
|
|
5
|
+
data;
|
|
6
|
+
constructor(status, data) {
|
|
7
|
+
super(typeof data === "string" ? data : void 0), this.status = status, this.data = data;
|
|
8
|
+
}
|
|
17
9
|
};
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `ev.redirect()`, `ev.error()`, etc. return a control-flow signal meant to be thrown. Throw it for
|
|
12
|
+
* the user when they return it instead, so returning and throwing behave the same.
|
|
13
|
+
*/ var throwIfControlFlowSignal = (value) => {
|
|
14
|
+
if (value instanceof AbortMessage || value instanceof ServerError) throw value;
|
|
15
|
+
};
|
|
16
|
+
export { RedirectMessage as i, throwIfControlFlowSignal as n, AbortMessage as r, ServerError as t };
|