@vesk/vesk-cli 0.2.87 → 0.2.89
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/dist/cli.js +105 -16
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -37523,9 +37523,10 @@ function __matchPath(pattern, pathname) {
|
|
|
37523
37523
|
}
|
|
37524
37524
|
|
|
37525
37525
|
export async function handleRequest(request) {
|
|
37526
|
-
|
|
37527
|
-
|
|
37528
|
-
|
|
37526
|
+
try {
|
|
37527
|
+
const url = new URL(request.url);
|
|
37528
|
+
const pathname = url.pathname;
|
|
37529
|
+
const isDataRequest = request.headers.get('x-vesk-data') === '1';
|
|
37529
37530
|
${serverStoreLine}
|
|
37530
37531
|
|
|
37531
37532
|
if (__prerendered.has(pathname) && !isDataRequest) {
|
|
@@ -37620,6 +37621,17 @@ ${eventsRequestLine}
|
|
|
37620
37621
|
status: 404,
|
|
37621
37622
|
headers: { 'Content-Type': 'text/html' },
|
|
37622
37623
|
});
|
|
37624
|
+
} catch (e) {
|
|
37625
|
+
// Any error that escapes the route (a thrown exception, a bad import, a
|
|
37626
|
+
// middleware failure, ...) must not bubble out of handleRequest. On
|
|
37627
|
+
// serverless platforms (Vercel, Netlify, Cloudflare) an uncaught throw is
|
|
37628
|
+
// surfaced as FUNCTION_INVOCATION_FAILED \u2014 Next.js avoids this by wrapping
|
|
37629
|
+
// its entry points the same way. Convert it into a proper 500 response.
|
|
37630
|
+
return new Response(renderDefaultErrorPage({ url: request.url }), {
|
|
37631
|
+
status: 500,
|
|
37632
|
+
headers: { 'Content-Type': 'text/html' },
|
|
37633
|
+
});
|
|
37634
|
+
}
|
|
37623
37635
|
}
|
|
37624
37636
|
`;
|
|
37625
37637
|
}
|
|
@@ -51097,13 +51109,48 @@ ${extracted.body}
|
|
|
51097
51109
|
" nextResult = await run(index + 1);",
|
|
51098
51110
|
" return nextResult;",
|
|
51099
51111
|
" }",
|
|
51100
|
-
"
|
|
51101
|
-
"
|
|
51102
|
-
"
|
|
51103
|
-
"
|
|
51104
|
-
"
|
|
51112
|
+
" try {",
|
|
51113
|
+
" const result = await fn(ctx, next);",
|
|
51114
|
+
" if (result instanceof Response) return result;",
|
|
51115
|
+
" if (nextResult instanceof Response) return nextResult;",
|
|
51116
|
+
" if (!nextCalled) return run(index + 1);",
|
|
51117
|
+
" return null;",
|
|
51118
|
+
" } catch (e) {",
|
|
51119
|
+
" if (e && typeof e === 'object' && e.name === 'Redirect') {",
|
|
51120
|
+
" return new Response(null, {",
|
|
51121
|
+
" status: Number(e.status) || 302,",
|
|
51122
|
+
" headers: { Location: String(e.url || '') },",
|
|
51123
|
+
" });",
|
|
51124
|
+
" }",
|
|
51125
|
+
" if (e instanceof TypeError && /Failed to parse URL from/.test(String(e.message))) {",
|
|
51126
|
+
" const msg = String(e.message);",
|
|
51127
|
+
" const prefix = 'Failed to parse URL from ';",
|
|
51128
|
+
" const start = msg.indexOf(prefix);",
|
|
51129
|
+
" const target = start === -1 ? '' : msg.slice(start + prefix.length).trim().split(' ')[0];",
|
|
51130
|
+
" return new Response(null, { status: 302, headers: { Location: target } });",
|
|
51131
|
+
" }",
|
|
51132
|
+
" // Any other TypeError from the middleware (e.g. reading a property of",
|
|
51133
|
+
" // `undefined` like `ctx.cookies[SESSION_COOKIE]` when `ctx.cookies` is",
|
|
51134
|
+
" // missing) must not crash the server. On serverless platforms (Vercel,",
|
|
51135
|
+
" // Netlify, Cloudflare) an uncaught throw surfaces as",
|
|
51136
|
+
" // FUNCTION_INVOCATION_FAILED \u2014 Next.js avoids this by wrapping entry",
|
|
51137
|
+
" // points the same way. Return a 500 instead.",
|
|
51138
|
+
" if (e instanceof TypeError) {",
|
|
51139
|
+
" return new Response(null, { status: 500 });",
|
|
51140
|
+
" }",
|
|
51141
|
+
" throw e;",
|
|
51142
|
+
" }",
|
|
51143
|
+
" }",
|
|
51144
|
+
" let response = null;",
|
|
51145
|
+
" try {",
|
|
51146
|
+
" response = await run(0);",
|
|
51147
|
+
" } catch (e) {",
|
|
51148
|
+
" // Unexpected middleware errors must not crash the server. On serverless",
|
|
51149
|
+
" // platforms (Vercel, Netlify, Cloudflare) an uncaught throw surfaces as",
|
|
51150
|
+
" // FUNCTION_INVOCATION_FAILED \u2014 Next.js avoids this by wrapping entry",
|
|
51151
|
+
" // points the same way. Convert it into a 500 response.",
|
|
51152
|
+
" response = new Response(null, { status: 500 });",
|
|
51105
51153
|
" }",
|
|
51106
|
-
" const response = await run(0);",
|
|
51107
51154
|
" return { response, rewriteUrl };",
|
|
51108
51155
|
"}",
|
|
51109
51156
|
""
|
|
@@ -51142,13 +51189,48 @@ ${extracted.body}
|
|
|
51142
51189
|
" ncResult = await run(index + 1);",
|
|
51143
51190
|
" return ncResult;",
|
|
51144
51191
|
" }",
|
|
51145
|
-
"
|
|
51146
|
-
"
|
|
51147
|
-
"
|
|
51148
|
-
"
|
|
51149
|
-
"
|
|
51192
|
+
" try {",
|
|
51193
|
+
" const result = await fn(ctx, next);",
|
|
51194
|
+
" if (result instanceof Response) return result;",
|
|
51195
|
+
" if (ncResult instanceof Response) return ncResult;",
|
|
51196
|
+
" if (!nc) return run(index + 1);",
|
|
51197
|
+
" return null;",
|
|
51198
|
+
" } catch (e) {",
|
|
51199
|
+
" if (e && typeof e === 'object' && e.name === 'Redirect') {",
|
|
51200
|
+
" return new Response(null, {",
|
|
51201
|
+
" status: Number(e.status) || 302,",
|
|
51202
|
+
" headers: { Location: String(e.url || '') },",
|
|
51203
|
+
" });",
|
|
51204
|
+
" }",
|
|
51205
|
+
" if (e instanceof TypeError && /Failed to parse URL from/.test(String(e.message))) {",
|
|
51206
|
+
" const msg = String(e.message);",
|
|
51207
|
+
" const prefix = 'Failed to parse URL from ';",
|
|
51208
|
+
" const start = msg.indexOf(prefix);",
|
|
51209
|
+
" const target = start === -1 ? '' : msg.slice(start + prefix.length).trim().split(' ')[0];",
|
|
51210
|
+
" return new Response(null, { status: 302, headers: { Location: target } });",
|
|
51211
|
+
" }",
|
|
51212
|
+
" // Any other TypeError from the middleware (e.g. reading a property of",
|
|
51213
|
+
" // `undefined` like `ctx.cookies[SESSION_COOKIE]` when `ctx.cookies` is",
|
|
51214
|
+
" // missing) must not crash the server. On serverless platforms (Vercel,",
|
|
51215
|
+
" // Netlify, Cloudflare) an uncaught throw surfaces as",
|
|
51216
|
+
" // FUNCTION_INVOCATION_FAILED \u2014 Next.js avoids this by wrapping entry",
|
|
51217
|
+
" // points the same way. Return a 500 instead.",
|
|
51218
|
+
" if (e instanceof TypeError) {",
|
|
51219
|
+
" return new Response(null, { status: 500 });",
|
|
51220
|
+
" }",
|
|
51221
|
+
" throw e;",
|
|
51222
|
+
" }",
|
|
51223
|
+
" }",
|
|
51224
|
+
" let response = null;",
|
|
51225
|
+
" try {",
|
|
51226
|
+
" response = await run(0);",
|
|
51227
|
+
" } catch (e) {",
|
|
51228
|
+
" // Unexpected middleware errors must not crash the server. On serverless",
|
|
51229
|
+
" // platforms (Vercel, Netlify, Cloudflare) an uncaught throw surfaces as",
|
|
51230
|
+
" // FUNCTION_INVOCATION_FAILED \u2014 Next.js avoids this by wrapping entry",
|
|
51231
|
+
" // points the same way. Convert it into a 500 response.",
|
|
51232
|
+
" response = new Response(null, { status: 500 });",
|
|
51150
51233
|
" }",
|
|
51151
|
-
" const response = await run(0);",
|
|
51152
51234
|
" return { response, rewriteUrl };",
|
|
51153
51235
|
"}",
|
|
51154
51236
|
""
|
|
@@ -58245,7 +58327,7 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
|
|
|
58245
58327
|
const url = new URL(request.url, "http://localhost");
|
|
58246
58328
|
const serverStore = globalThis.__vesk_server_ctx;
|
|
58247
58329
|
const locals2 = Object.assign({}, serverStore || {});
|
|
58248
|
-
const cookies2 = parseCookies2(request.headers?.get("cookie") || "");
|
|
58330
|
+
const cookies2 = parseCookies2(request.headers?.get("cookie") || "") || {};
|
|
58249
58331
|
const ctx2 = new Proxy({
|
|
58250
58332
|
request,
|
|
58251
58333
|
params,
|
|
@@ -58349,6 +58431,13 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
|
|
|
58349
58431
|
headers: { Location: err.url || "" }
|
|
58350
58432
|
});
|
|
58351
58433
|
}
|
|
58434
|
+
if (e instanceof TypeError && /Failed to parse URL from/.test(String(e.message))) {
|
|
58435
|
+
const target = /Failed to parse URL from (\S+)/.exec(String(e.message))?.[1] ?? "";
|
|
58436
|
+
return new Response(null, { status: 302, headers: { Location: target } });
|
|
58437
|
+
}
|
|
58438
|
+
if (e instanceof TypeError) {
|
|
58439
|
+
return new Response(null, { status: 500 });
|
|
58440
|
+
}
|
|
58352
58441
|
throw e;
|
|
58353
58442
|
}
|
|
58354
58443
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/vesk-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.89",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
|
|
6
6
|
"bin": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/cli.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@vesk/adapter": "^0.2.
|
|
12
|
-
"@vesk/compiler": "^0.2.
|
|
13
|
-
"@vesk/plugin-tailwind": "^0.2.
|
|
14
|
-
"@vesk/runtime": "^0.2.
|
|
11
|
+
"@vesk/adapter": "^0.2.89",
|
|
12
|
+
"@vesk/compiler": "^0.2.89",
|
|
13
|
+
"@vesk/plugin-tailwind": "^0.2.89",
|
|
14
|
+
"@vesk/runtime": "^0.2.89",
|
|
15
15
|
"esrap": "^2.3.0",
|
|
16
16
|
"typescript": "^5.8.0",
|
|
17
17
|
"ws": "^8.18.0",
|