@vesk/vesk-cli 0.0.1 → 0.1.1
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 +13 -1
- package/dist/sidecar.js +32 -20
- package/package.json +10 -10
package/dist/cli.js
CHANGED
|
@@ -14455,6 +14455,7 @@ function VeskParserPlugin(config = {}) {
|
|
|
14455
14455
|
#componentDepth = 0;
|
|
14456
14456
|
#closeTagName = null;
|
|
14457
14457
|
#jsxStartsStatement = false;
|
|
14458
|
+
#inTSTypeDecl = false;
|
|
14458
14459
|
constructor(options2, input) {
|
|
14459
14460
|
super(options2, input);
|
|
14460
14461
|
}
|
|
@@ -14599,10 +14600,21 @@ function VeskParserPlugin(config = {}) {
|
|
|
14599
14600
|
return this.finishNode(node, "VeskBlock");
|
|
14600
14601
|
}
|
|
14601
14602
|
}
|
|
14603
|
+
if (this.#componentDepth > 0 && tstt) {
|
|
14604
|
+
const isTsDecl = this.type === tstt.interface || this.type === tstt.enum || this.type === tstt.type || this.type === tstt.module || this.type === tstt.namespace;
|
|
14605
|
+
if (isTsDecl) {
|
|
14606
|
+
this.#inTSTypeDecl = true;
|
|
14607
|
+
try {
|
|
14608
|
+
return super.parseStatement(context, ...args2);
|
|
14609
|
+
} finally {
|
|
14610
|
+
this.#inTSTypeDecl = false;
|
|
14611
|
+
}
|
|
14612
|
+
}
|
|
14613
|
+
}
|
|
14602
14614
|
return super.parseStatement(context, ...args2);
|
|
14603
14615
|
}
|
|
14604
14616
|
parseBlock(createNewLexicalScope, node, exitStrict) {
|
|
14605
|
-
if (this.#componentDepth > 0) {
|
|
14617
|
+
if (this.#componentDepth > 0 && !this.#inTSTypeDecl) {
|
|
14606
14618
|
if (createNewLexicalScope === void 0) createNewLexicalScope = true;
|
|
14607
14619
|
if (node === void 0) node = this.startNode();
|
|
14608
14620
|
node.body = [];
|
package/dist/sidecar.js
CHANGED
|
@@ -7442,21 +7442,13 @@ var scanApiRoutes;
|
|
|
7442
7442
|
var collectMiddlewareChain;
|
|
7443
7443
|
async function ensureModules() {
|
|
7444
7444
|
if (compileClient2) return;
|
|
7445
|
-
console.log("sidecar: loading client-codegen");
|
|
7446
7445
|
const clientCodegen = await loadCompilerModule("client-codegen.js");
|
|
7447
|
-
console.log("sidecar: loading server-codegen");
|
|
7448
7446
|
const serverCodegen = await loadCompilerModule("server-codegen.js");
|
|
7449
|
-
console.log("sidecar: loading vsk-tsx");
|
|
7450
7447
|
const vskTsx = await loadCompilerModule("vsk-tsx.js");
|
|
7451
|
-
console.log("sidecar: loading typecheck");
|
|
7452
7448
|
const typecheck = await loadCompilerModule("typecheck.js");
|
|
7453
|
-
console.log("sidecar: loading router");
|
|
7454
7449
|
const router = await loadCompilerModule("router.js");
|
|
7455
|
-
console.log("sidecar: loading middleware");
|
|
7456
7450
|
const middleware = await loadCompilerModule("middleware.js");
|
|
7457
|
-
console.log("sidecar: loading api-routes");
|
|
7458
7451
|
const apiRoutes = await loadCompilerModule("api-routes.js");
|
|
7459
|
-
console.log("sidecar: all modules loaded");
|
|
7460
7452
|
compileClient2 = clientCodegen.compileClient;
|
|
7461
7453
|
compileServer = serverCodegen.compileServer;
|
|
7462
7454
|
generateVskDts = vskTsx.generateVskDts;
|
|
@@ -8798,6 +8790,7 @@ async function prodRenderNotFound(urlPath) {
|
|
|
8798
8790
|
return await rtMod.renderFullPage(src, compName, { params: {}, url: urlPath }, /* @__PURE__ */ new Map(), {
|
|
8799
8791
|
hydrate: true,
|
|
8800
8792
|
cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"],
|
|
8793
|
+
clientScriptUrl: "/_vesk/static/client.js",
|
|
8801
8794
|
security: state.securityConfig.security || {},
|
|
8802
8795
|
externalDataScript: prodStoreDataScript,
|
|
8803
8796
|
sourcePath: nfPath
|
|
@@ -8827,6 +8820,7 @@ async function prodRenderError(props) {
|
|
|
8827
8820
|
return await rtMod.renderFullPage(src, compName, props, /* @__PURE__ */ new Map(), {
|
|
8828
8821
|
hydrate: true,
|
|
8829
8822
|
cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"],
|
|
8823
|
+
clientScriptUrl: "/_vesk/static/client.js",
|
|
8830
8824
|
security: state.securityConfig.security || {},
|
|
8831
8825
|
externalDataScript: prodStoreDataScript,
|
|
8832
8826
|
sourcePath: errPath
|
|
@@ -8887,7 +8881,13 @@ function installSsrFetchHook() {
|
|
|
8887
8881
|
clientIp: prodIpStore.getStore()?.clientIp || "127.0.0.1",
|
|
8888
8882
|
port: state.port
|
|
8889
8883
|
};
|
|
8890
|
-
const
|
|
8884
|
+
const savedBase = globalThis.__vesk_ssr_base_url;
|
|
8885
|
+
let resp;
|
|
8886
|
+
try {
|
|
8887
|
+
resp = await handleProdRequest(devReq);
|
|
8888
|
+
} finally {
|
|
8889
|
+
globalThis.__vesk_ssr_base_url = savedBase;
|
|
8890
|
+
}
|
|
8891
8891
|
const bodyBuf = resp.bodyB64 ? Buffer.from(resp.bodyB64, "base64") : Buffer.alloc(0);
|
|
8892
8892
|
const hdrs = new Headers();
|
|
8893
8893
|
for (const [k, v] of resp.headers) {
|
|
@@ -8906,6 +8906,7 @@ async function handleProdRequest(p) {
|
|
|
8906
8906
|
if (!state) {
|
|
8907
8907
|
return { status: 500, headers: [["Content-Type", "application/json"]], bodyB64: Buffer.from(JSON.stringify({ error: "prod server not initialized" })).toString("base64") };
|
|
8908
8908
|
}
|
|
8909
|
+
let mwLocals = {};
|
|
8909
8910
|
const url = new URL(p.url, `http://localhost:${p.port || state.port}`);
|
|
8910
8911
|
const bodyBuffer = p.bodyB64 ? Buffer.from(p.bodyB64, "base64") : Buffer.alloc(0);
|
|
8911
8912
|
const req = {
|
|
@@ -9006,10 +9007,26 @@ async function handleProdRequest(p) {
|
|
|
9006
9007
|
return withSec({ status: mwResult.response.status, headers, bodyB64: Buffer.from(body).toString("base64") });
|
|
9007
9008
|
}
|
|
9008
9009
|
if (mwResult.rewriteUrl) url.pathname = mwResult.rewriteUrl;
|
|
9010
|
+
mwLocals = mwCtx.locals || {};
|
|
9009
9011
|
} catch (e) {
|
|
9010
9012
|
console.error("prod: middleware error:", e.message);
|
|
9011
9013
|
}
|
|
9012
9014
|
}
|
|
9015
|
+
const withVeskRequest = (fn) => {
|
|
9016
|
+
const prev = globalThis.__vesk_request;
|
|
9017
|
+
globalThis.__vesk_request = {
|
|
9018
|
+
request: req,
|
|
9019
|
+
params: {},
|
|
9020
|
+
url,
|
|
9021
|
+
locals: mwLocals,
|
|
9022
|
+
cookies: {}
|
|
9023
|
+
};
|
|
9024
|
+
try {
|
|
9025
|
+
return fn();
|
|
9026
|
+
} finally {
|
|
9027
|
+
globalThis.__vesk_request = prev;
|
|
9028
|
+
}
|
|
9029
|
+
};
|
|
9013
9030
|
if (url.pathname.startsWith("/_vesk/action/")) {
|
|
9014
9031
|
const actionId = url.pathname.replace("/_vesk/action/", "");
|
|
9015
9032
|
const actionEntry = state.buildConfig.actions && state.buildConfig.actions.find((a) => a.id === actionId);
|
|
@@ -9022,7 +9039,7 @@ async function handleProdRequest(p) {
|
|
|
9022
9039
|
}
|
|
9023
9040
|
try {
|
|
9024
9041
|
const webRequest = makeWebRequest(req, url);
|
|
9025
|
-
const response = await withProdClientIp(p.clientIp, () => mod.handleAction(webRequest, actionId));
|
|
9042
|
+
const response = await withVeskRequest(() => withProdClientIp(p.clientIp, () => mod.handleAction(webRequest, actionId)));
|
|
9026
9043
|
const body = await response.text();
|
|
9027
9044
|
const headers = [];
|
|
9028
9045
|
for (const [k, v] of response.headers.entries()) headers.push([k, v]);
|
|
@@ -9037,17 +9054,14 @@ async function handleProdRequest(p) {
|
|
|
9037
9054
|
if (route.type === "api") {
|
|
9038
9055
|
const params = prodMatchPath(route.path, url.pathname);
|
|
9039
9056
|
if (params) {
|
|
9040
|
-
const t0 = Date.now();
|
|
9041
9057
|
const mod = await prodLoadFunction(route.function);
|
|
9042
|
-
const t1 = Date.now();
|
|
9043
9058
|
if (mod) {
|
|
9044
9059
|
try {
|
|
9045
9060
|
const webRequest = makeWebRequest(req, url);
|
|
9046
|
-
const response = await withProdClientIp(p.clientIp, () => mod.handle(webRequest));
|
|
9061
|
+
const response = await withVeskRequest(() => withProdClientIp(p.clientIp, () => mod.handle(webRequest)));
|
|
9047
9062
|
const body = await response.text();
|
|
9048
9063
|
const headers = [];
|
|
9049
9064
|
for (const [k, v] of response.headers.entries()) headers.push([k, v]);
|
|
9050
|
-
console.error(`sidecar: prod_api ${url.pathname} load=${t1 - t0}ms handle=${Date.now() - t1}ms`);
|
|
9051
9065
|
return withSec({ status: response.status, headers, bodyB64: Buffer.from(body).toString("base64") });
|
|
9052
9066
|
} catch (e) {
|
|
9053
9067
|
const message = e instanceof Error ? e.message : String(e);
|
|
@@ -9069,7 +9083,7 @@ async function handleProdRequest(p) {
|
|
|
9069
9083
|
let cachedResult = null;
|
|
9070
9084
|
if (route.revalidate && route.revalidate > 0) {
|
|
9071
9085
|
cachedResult = await devMods.runtimeServer.pageIsr(url.pathname, async () => {
|
|
9072
|
-
const response2 = await withProdClientIp(p.clientIp, () => mod.handle(webRequest));
|
|
9086
|
+
const response2 = await withVeskRequest(() => withProdClientIp(p.clientIp, () => mod.handle(webRequest)));
|
|
9073
9087
|
return { html: await response2.text(), headers: Object.fromEntries(response2.headers) };
|
|
9074
9088
|
}, { revalidate: route.revalidate, tags: route.tags || [] });
|
|
9075
9089
|
}
|
|
@@ -9077,7 +9091,7 @@ async function handleProdRequest(p) {
|
|
|
9077
9091
|
const headers2 = Object.entries(cachedResult.headers || { "Content-Type": "text/html" });
|
|
9078
9092
|
return withSec({ status: 200, headers: headers2, bodyB64: Buffer.from(cachedResult.html).toString("base64") });
|
|
9079
9093
|
}
|
|
9080
|
-
const response = await withProdClientIp(p.clientIp, () => mod.handle(webRequest));
|
|
9094
|
+
const response = await withVeskRequest(() => withProdClientIp(p.clientIp, () => mod.handle(webRequest)));
|
|
9081
9095
|
const headers = Object.fromEntries(response.headers);
|
|
9082
9096
|
if (!headers["content-type"] && !headers["Content-Type"]) headers["Content-Type"] = "text/html";
|
|
9083
9097
|
const body = await response.text();
|
|
@@ -9086,7 +9100,7 @@ async function handleProdRequest(p) {
|
|
|
9086
9100
|
const err2 = e instanceof Error ? e : new Error(String(e));
|
|
9087
9101
|
if (err2.name === "NotFoundError") {
|
|
9088
9102
|
const nfHtml2 = await prodRenderNotFoundCached(url.pathname);
|
|
9089
|
-
return withSec({ status: 404, headers: [["Content-Type", "text/html"]], bodyB64: Buffer.from(nfHtml2 ||
|
|
9103
|
+
return withSec({ status: 404, headers: [["Content-Type", "text/html"]], bodyB64: Buffer.from(nfHtml2 || '<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="/_vesk/static/_tailwind.css" /><link rel="stylesheet" href="/_vesk/static/global.css" /></head><body><h1>404</h1><p>Not Found</p><script type="module" src="/_vesk/static/client.js"></script></body></html>').toString("base64") });
|
|
9090
9104
|
}
|
|
9091
9105
|
console.error("haul ssr error:", err2.message);
|
|
9092
9106
|
let errorHtml = null;
|
|
@@ -9094,7 +9108,7 @@ async function handleProdRequest(p) {
|
|
|
9094
9108
|
errorHtml = await prodRenderError({ error: err2.message, stack: err2.stack, statusCode: 500, url: url.pathname });
|
|
9095
9109
|
} catch {
|
|
9096
9110
|
}
|
|
9097
|
-
return withSec({ status: 500, headers: [["Content-Type", "text/html"]], bodyB64: Buffer.from(errorHtml ||
|
|
9111
|
+
return withSec({ status: 500, headers: [["Content-Type", "text/html"]], bodyB64: Buffer.from(errorHtml || '<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="/_vesk/static/_tailwind.css" /><link rel="stylesheet" href="/_vesk/static/global.css" /></head><body><div style="font-family:system-ui;padding:2rem"><h1>500 \u2014 Internal Server Error</h1><pre>' + String(err2.message).replace(/</g, "<") + '</pre></div><script type="module" src="/_vesk/static/client.js"></script></body></html>').toString("base64") });
|
|
9098
9112
|
}
|
|
9099
9113
|
}
|
|
9100
9114
|
}
|
|
@@ -9321,9 +9335,7 @@ ${extracted.body}
|
|
|
9321
9335
|
return;
|
|
9322
9336
|
}
|
|
9323
9337
|
case "prod_render": {
|
|
9324
|
-
const t0 = Date.now();
|
|
9325
9338
|
const result = await handleProdRequest(rpcReq.params[0] || {});
|
|
9326
|
-
console.error(`sidecar: prod_render ${(rpcReq.params[0] || {}).url} ${Date.now() - t0}ms`);
|
|
9327
9339
|
respond({ jsonrpc: "2.0", id: rpcReq.id, result });
|
|
9328
9340
|
return;
|
|
9329
9341
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/vesk-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
|
|
6
6
|
"bin": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
},
|
|
10
10
|
"main": "./dist/cli.js",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@vesk/adapter": "^0.
|
|
13
|
-
"@vesk/compiler": "^0.
|
|
14
|
-
"@vesk/plugin-tailwind": "^0.
|
|
15
|
-
"@vesk/runtime": "^0.
|
|
12
|
+
"@vesk/adapter": "^0.1.1",
|
|
13
|
+
"@vesk/compiler": "^0.1.1",
|
|
14
|
+
"@vesk/plugin-tailwind": "^0.1.1",
|
|
15
|
+
"@vesk/runtime": "^0.1.1",
|
|
16
16
|
"esbuild": "^0.25.0",
|
|
17
17
|
"esrap": "^2.3.0",
|
|
18
18
|
"sharp": "^0.35.3",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"README.md"
|
|
47
47
|
],
|
|
48
48
|
"optionalDependencies": {
|
|
49
|
-
"@vesk/haul-darwin-arm64": "^0.
|
|
50
|
-
"@vesk/haul-darwin-x64": "^0.
|
|
51
|
-
"@vesk/haul-linux-arm64": "^0.
|
|
52
|
-
"@vesk/haul-linux-x64": "^0.
|
|
53
|
-
"@vesk/haul-win32-x64": "^0.
|
|
49
|
+
"@vesk/haul-darwin-arm64": "^0.1.1",
|
|
50
|
+
"@vesk/haul-darwin-x64": "^0.1.1",
|
|
51
|
+
"@vesk/haul-linux-arm64": "^0.1.1",
|
|
52
|
+
"@vesk/haul-linux-x64": "^0.1.1",
|
|
53
|
+
"@vesk/haul-win32-x64": "^0.1.1"
|
|
54
54
|
}
|
|
55
55
|
}
|