@vesk/vesk-cli 0.2.89 → 0.2.91
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 +58 -2
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -34850,6 +34850,11 @@ function bodyNeedsRuntimeCells(nodes) {
|
|
|
34850
34850
|
return false;
|
|
34851
34851
|
}
|
|
34852
34852
|
function buildComponentEntries(irRoot) {
|
|
34853
|
+
for (const name of ["redirect", "permanentRedirect", "notFound"]) {
|
|
34854
|
+
if (!irRoot.imports.includes(`import { ${name} } from '@vesk/runtime';`)) {
|
|
34855
|
+
irRoot.imports.push(`import { ${name} } from '@vesk/runtime';`);
|
|
34856
|
+
}
|
|
34857
|
+
}
|
|
34853
34858
|
const runtimeNames = extractRuntimeNames(irRoot.imports);
|
|
34854
34859
|
const localValueNames = localValueImportNames(irRoot.imports);
|
|
34855
34860
|
const topNames = extractTopLevelNames(irRoot.topLevelCode);
|
|
@@ -37528,6 +37533,19 @@ export async function handleRequest(request) {
|
|
|
37528
37533
|
const pathname = url.pathname;
|
|
37529
37534
|
const isDataRequest = request.headers.get('x-vesk-data') === '1';
|
|
37530
37535
|
${serverStoreLine}
|
|
37536
|
+
// During SSR, fetch() with a relative URL (e.g. '/api/student') throws
|
|
37537
|
+
// because undici requires an absolute URL and there is no browser
|
|
37538
|
+
// origin to resolve against. Wrap globalThis.fetch for the duration
|
|
37539
|
+
// of the handler so relative API calls resolve against the request's
|
|
37540
|
+
// origin \u2014 matching what the client does automatically.
|
|
37541
|
+
const origin = url.origin;
|
|
37542
|
+
const origFetch = globalThis.fetch;
|
|
37543
|
+
globalThis.fetch = async (input, init) => {
|
|
37544
|
+
if (typeof input === 'string' && input.startsWith('/')) {
|
|
37545
|
+
input = origin + input;
|
|
37546
|
+
}
|
|
37547
|
+
return origFetch(input, init);
|
|
37548
|
+
};
|
|
37531
37549
|
|
|
37532
37550
|
if (__prerendered.has(pathname) && !isDataRequest) {
|
|
37533
37551
|
return new Response(null, { status: 308, headers: { Location: '/_vesk/static/public' + (pathname.endsWith('/') ? pathname + 'index.html' : pathname + '.html') } });
|
|
@@ -37622,6 +37640,7 @@ ${eventsRequestLine}
|
|
|
37622
37640
|
headers: { 'Content-Type': 'text/html' },
|
|
37623
37641
|
});
|
|
37624
37642
|
} catch (e) {
|
|
37643
|
+
globalThis.fetch = origFetch;
|
|
37625
37644
|
// Any error that escapes the route (a thrown exception, a bad import, a
|
|
37626
37645
|
// middleware failure, ...) must not bubble out of handleRequest. On
|
|
37627
37646
|
// serverless platforms (Vercel, Netlify, Cloudflare) an uncaught throw is
|
|
@@ -51010,7 +51029,16 @@ function extractMiddlewareParts(src2) {
|
|
|
51010
51029
|
}
|
|
51011
51030
|
const params = target.params.length ? src2.slice(target.params[0].start, target.params[target.params.length - 1].end) : "";
|
|
51012
51031
|
const body = src2.slice(target.body.start + 1, target.body.end - 1);
|
|
51013
|
-
|
|
51032
|
+
const decls = [];
|
|
51033
|
+
for (const stmt of ast.body) {
|
|
51034
|
+
if (stmt.type === "VariableDeclaration") {
|
|
51035
|
+
decls.push(src2.slice(stmt.start, stmt.end).trim());
|
|
51036
|
+
} else if (stmt.type === "ExportNamedDeclaration" && stmt.declaration?.type === "VariableDeclaration") {
|
|
51037
|
+
decls.push(src2.slice(stmt.declaration.start, stmt.declaration.end).trim());
|
|
51038
|
+
}
|
|
51039
|
+
}
|
|
51040
|
+
const bodyWithDecls = decls.length > 0 ? decls.join("\n") + "\n" + body.trim() : body.trim();
|
|
51041
|
+
return { params, body: bodyWithDecls };
|
|
51014
51042
|
} catch {
|
|
51015
51043
|
return fallbackExtractMiddleware(src2);
|
|
51016
51044
|
}
|
|
@@ -53968,8 +53996,16 @@ async function startProdServer(outDir, options) {
|
|
|
53968
53996
|
if (params) {
|
|
53969
53997
|
const mod = await loadFunction(route.function);
|
|
53970
53998
|
if (mod) {
|
|
53999
|
+
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
54000
|
+
const origin = new URL(url.href).origin;
|
|
54001
|
+
const origFetch = globalThis.fetch;
|
|
54002
|
+
globalThis.fetch = async (input, init) => {
|
|
54003
|
+
if (typeof input === "string" && input.startsWith("/")) {
|
|
54004
|
+
input = origin + input;
|
|
54005
|
+
}
|
|
54006
|
+
return origFetch(input, init);
|
|
54007
|
+
};
|
|
53971
54008
|
try {
|
|
53972
|
-
const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
|
|
53973
54009
|
let cachedResult = null;
|
|
53974
54010
|
if (route.revalidate && route.revalidate > 0) {
|
|
53975
54011
|
const { pageIsr: pageIsr2 } = await Promise.resolve().then(() => (init_index_server(), index_server_exports));
|
|
@@ -54040,6 +54076,8 @@ async function startProdServer(outDir, options) {
|
|
|
54040
54076
|
res.writeHead(500, { "Content-Type": "text/html" });
|
|
54041
54077
|
res.end(errorHtml || renderDefaultErrorPage({ message: process.env.NODE_ENV !== "production" ? err.message : void 0, url: url.pathname, headExtra: bakedHeadExtra }));
|
|
54042
54078
|
return;
|
|
54079
|
+
} finally {
|
|
54080
|
+
globalThis.fetch = origFetch;
|
|
54043
54081
|
}
|
|
54044
54082
|
}
|
|
54045
54083
|
}
|
|
@@ -67630,6 +67668,14 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
|
|
|
67630
67668
|
async function renderSSR() {
|
|
67631
67669
|
const ssg2 = globalThis;
|
|
67632
67670
|
ssg2.__vsk_ssr_data = {};
|
|
67671
|
+
const origin = url.origin;
|
|
67672
|
+
const origFetch = globalThis.fetch;
|
|
67673
|
+
globalThis.fetch = async (input, init) => {
|
|
67674
|
+
if (typeof input === "string" && input.startsWith("/")) {
|
|
67675
|
+
input = origin + input;
|
|
67676
|
+
}
|
|
67677
|
+
return origFetch(input, init);
|
|
67678
|
+
};
|
|
67633
67679
|
let freshToken;
|
|
67634
67680
|
try {
|
|
67635
67681
|
return await withSsrStore2(async () => {
|
|
@@ -67709,6 +67755,7 @@ ${prettifyHtml(body)}
|
|
|
67709
67755
|
});
|
|
67710
67756
|
} finally {
|
|
67711
67757
|
const token = freshToken;
|
|
67758
|
+
globalThis.fetch = origFetch;
|
|
67712
67759
|
dropSsrSlot2(token);
|
|
67713
67760
|
delete ssg2[`__vsk_ssr_data_${token}`];
|
|
67714
67761
|
delete ssg2[`__vsk_ssr_promises_${token}`];
|
|
@@ -67719,6 +67766,14 @@ ${prettifyHtml(body)}
|
|
|
67719
67766
|
function renderSSRStream() {
|
|
67720
67767
|
const sst = globalThis;
|
|
67721
67768
|
sst.__vsk_ssr_data = {};
|
|
67769
|
+
const origin = url.origin;
|
|
67770
|
+
const origFetchStream = globalThis.fetch;
|
|
67771
|
+
globalThis.fetch = async (input, init) => {
|
|
67772
|
+
if (typeof input === "string" && input.startsWith("/")) {
|
|
67773
|
+
input = origin + input;
|
|
67774
|
+
}
|
|
67775
|
+
return origFetchStream(input, init);
|
|
67776
|
+
};
|
|
67722
67777
|
async function* raw2() {
|
|
67723
67778
|
const chain = cleanChain;
|
|
67724
67779
|
const hasLayout = chain.some((n) => n.layout && existsSync43(resolve39(appDirPath, n.sourceDir, "layout.vsk")));
|
|
@@ -67791,6 +67846,7 @@ ${prettifyHtml(body)}
|
|
|
67791
67846
|
} while (!result.done);
|
|
67792
67847
|
} finally {
|
|
67793
67848
|
const token = streamStore.token;
|
|
67849
|
+
globalThis.fetch = origFetchStream;
|
|
67794
67850
|
dropSsrSlot2(token);
|
|
67795
67851
|
if (token) {
|
|
67796
67852
|
delete sst[`__vsk_ssr_data_${token}`];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/vesk-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.91",
|
|
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.91",
|
|
12
|
+
"@vesk/compiler": "^0.2.91",
|
|
13
|
+
"@vesk/plugin-tailwind": "^0.2.91",
|
|
14
|
+
"@vesk/runtime": "^0.2.91",
|
|
15
15
|
"esrap": "^2.3.0",
|
|
16
16
|
"typescript": "^5.8.0",
|
|
17
17
|
"ws": "^8.18.0",
|