@vesk/compiler 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/middleware.d.ts.map +1 -1
- package/dist/middleware.js +19 -1
- package/package.json +2 -2
package/dist/middleware.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAiC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEtG,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE,CAsE7G;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAiBvG;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,eAAe,EAAE,EACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAiC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEtG,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE,CAsE7G;AAED,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAiBvG;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,eAAe,EAAE,EACxB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAqJzH"}
|
package/dist/middleware.js
CHANGED
|
@@ -91,7 +91,7 @@ export async function executeMiddlewareChain(chain, request, params, options = {
|
|
|
91
91
|
const url = new URL(request.url, 'http://localhost');
|
|
92
92
|
const serverStore = globalThis.__vesk_server_ctx;
|
|
93
93
|
const locals = Object.assign({}, serverStore || {});
|
|
94
|
-
const cookies = parseCookies(request.headers?.get('cookie') || '');
|
|
94
|
+
const cookies = parseCookies(request.headers?.get('cookie') || '') || {};
|
|
95
95
|
const ctx = new Proxy({
|
|
96
96
|
request,
|
|
97
97
|
params,
|
|
@@ -201,6 +201,24 @@ export async function executeMiddlewareChain(chain, request, params, options = {
|
|
|
201
201
|
headers: { Location: err.url || '' },
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
+
// undici's `Response.redirect()` rejects *relative* URLs with a
|
|
205
|
+
// TypeError ("Failed to parse URL from /login"). A middleware returning
|
|
206
|
+
// `Response.redirect('/login', 302)` should work just like
|
|
207
|
+
// `ServerResponse.redirect('/login')` — normalize it into a redirect
|
|
208
|
+
// response instead of surfacing a 500.
|
|
209
|
+
if (e instanceof TypeError && /Failed to parse URL from/.test(String(e.message))) {
|
|
210
|
+
const target = /Failed to parse URL from (\S+)/.exec(String(e.message))?.[1] ?? '';
|
|
211
|
+
return new Response(null, { status: 302, headers: { Location: target } });
|
|
212
|
+
}
|
|
213
|
+
// Any other TypeError from the middleware (e.g. reading a property of
|
|
214
|
+
// `undefined` like `ctx.cookies[SESSION_COOKIE]` when `ctx.cookies` is
|
|
215
|
+
// missing) must not crash the server. On serverless platforms (Vercel,
|
|
216
|
+
// Netlify, Cloudflare) an uncaught throw surfaces as
|
|
217
|
+
// FUNCTION_INVOCATION_FAILED — Next.js avoids this by wrapping entry
|
|
218
|
+
// points the same way. Return a 500 instead.
|
|
219
|
+
if (e instanceof TypeError) {
|
|
220
|
+
return new Response(null, { status: 500 });
|
|
221
|
+
}
|
|
204
222
|
throw e;
|
|
205
223
|
}
|
|
206
224
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.89",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk compiler — lexer, parser, semantic analysis, IR, codegen",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@sveltejs/acorn-typescript": "^1.0.0",
|
|
23
|
-
"@vesk/types": "^0.2.
|
|
23
|
+
"@vesk/types": "^0.2.89",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|