@vesk/vesk-cli 0.2.39 → 0.2.41

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.
Files changed (2) hide show
  1. package/dist/cli.js +71 -17
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -19926,7 +19926,7 @@ function containsJSX(node) {
19926
19926
  return false;
19927
19927
  }
19928
19928
  function slotReadPropName(expr) {
19929
- if (expr.type === "MemberExpression" && !expr.computed && expr.object.type === "Identifier" && expr.object.name === "props" && expr.property.type === "Identifier") {
19929
+ if (expr.type === "MemberExpression" && !expr.computed && expr.object.type === "Identifier" && expr.object.name === (__propsParam || "props") && expr.property.type === "Identifier") {
19930
19930
  return expr.property.name;
19931
19931
  }
19932
19932
  return null;
@@ -20130,7 +20130,7 @@ function processJSXChildren(source, children) {
20130
20130
  i++;
20131
20131
  continue;
20132
20132
  }
20133
- if (expr.type === "MemberExpression" && !expr.computed && expr.object.type === "Identifier" && expr.object.name === "props" && expr.property.type === "Identifier" && expr.property.name === "children" || expr.type === "Identifier" && expr.name === "children") {
20133
+ if (expr.type === "MemberExpression" && !expr.computed && expr.object.type === "Identifier" && expr.object.name === (__propsParam || "props") && expr.property.type === "Identifier" && expr.property.name === "children" || expr.type === "Identifier" && expr.name === "children") {
20134
20134
  result.push(new SlotNode());
20135
20135
  i++;
20136
20136
  continue;
@@ -20200,7 +20200,7 @@ function exprToIR(source, expr) {
20200
20200
  const consequent = exprToIR(source, expr.right);
20201
20201
  return [new OpaqueDynamicRegion(condExpr, consequent)];
20202
20202
  }
20203
- if (expr.type === "MemberExpression" && !expr.computed && expr.object.type === "Identifier" && expr.object.name === "props" && expr.property.type === "Identifier" && expr.property.name === "children" || expr.type === "Identifier" && expr.name === "children") {
20203
+ if (expr.type === "MemberExpression" && !expr.computed && expr.object.type === "Identifier" && expr.object.name === (__propsParam || "props") && expr.property.type === "Identifier" && expr.property.name === "children" || expr.type === "Identifier" && expr.name === "children") {
20204
20204
  return [new SlotNode()];
20205
20205
  }
20206
20206
  const slotName = slotReadPropName(expr);
@@ -20728,6 +20728,7 @@ function generateIR(ast, source, filename) {
20728
20728
  const isClientComp = !!inner.client;
20729
20729
  const prevSlotProps = __slotProps;
20730
20730
  __slotProps = slotPropNamesFromType(propsType);
20731
+ __propsParam = propsAlias || null;
20731
20732
  if (isStatementMode(bodyStmts)) {
20732
20733
  const raw2 = processStatementModeBody(source, bodyStmts, file);
20733
20734
  const { body, css } = extractStyle(raw2);
@@ -20771,7 +20772,7 @@ function generateIR(ast, source, filename) {
20771
20772
  const guardBody = buildGuardChain(source, guardClauses, mainReturn);
20772
20773
  const { body, css } = extractStyle([...preamble, ...guardBody]);
20773
20774
  validateBlocks(name, isClientComp, body, file, source);
20774
- const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType });
20775
+ const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
20775
20776
  comp.style = css;
20776
20777
  components.push(comp);
20777
20778
  __slotProps = prevSlotProps;
@@ -20865,7 +20866,7 @@ function generateIR(ast, source, filename) {
20865
20866
  }
20866
20867
  return new IRRoot(components, imports, importedNames, staticProps, loadFn, topLevelCode);
20867
20868
  }
20868
- var __vskAnnotations, __slotProps;
20869
+ var __vskAnnotations, __slotProps, __propsParam;
20869
20870
  var init_ir_generator = __esm({
20870
20871
  "../compiler/src/ir-generator.ts"() {
20871
20872
  "use strict";
@@ -20879,6 +20880,7 @@ var init_ir_generator = __esm({
20879
20880
  init_tokens();
20880
20881
  __vskAnnotations = [];
20881
20882
  __slotProps = null;
20883
+ __propsParam = null;
20882
20884
  }
20883
20885
  });
20884
20886
 
@@ -32692,6 +32694,7 @@ __export(image_pipeline_exports, {
32692
32694
  optimizeImages: () => optimizeImages
32693
32695
  });
32694
32696
  import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
32697
+ import { spawnSync } from "node:child_process";
32695
32698
  import { resolve as resolve16, extname as extname5, dirname as dirname12 } from "node:path";
32696
32699
  async function processImage(srcPath, outDir, baseName) {
32697
32700
  const image = sharpFn ? sharpFn(srcPath) : null;
@@ -32806,8 +32809,17 @@ var init_image_pipeline = __esm({
32806
32809
  FORMATS = ["webp", "avif"];
32807
32810
  sharpFn = null;
32808
32811
  try {
32809
- const mod = await import("sharp");
32810
- sharpFn = mod.default;
32812
+ const probe = spawnSync(process.execPath, [
32813
+ "--input-type=module",
32814
+ "-e",
32815
+ "import sharp from 'sharp'; await sharp({ create: { width: 2, height: 2, channels: 3, background: 'red' } }).png().toBuffer();"
32816
+ ], { stdio: "ignore" });
32817
+ if (probe.status === 0) {
32818
+ const mod = await import("sharp");
32819
+ sharpFn = mod.default;
32820
+ } else {
32821
+ console.warn("vesk images: sharp native probe failed; using copy-only image pipeline");
32822
+ }
32811
32823
  } catch {
32812
32824
  }
32813
32825
  }
@@ -37915,9 +37927,6 @@ function compileVskCodegen(source, opts = {}) {
37915
37927
  }
37916
37928
  return { code, mappings: g2.mappings, styleRegions: g2.styleRegions, errors: [] };
37917
37929
  }
37918
- function vskToTsx(source) {
37919
- return compileVskCodegen(source).code;
37920
- }
37921
37930
  function isTypeDecl(stmt) {
37922
37931
  return stmt.type === "TSInterfaceDeclaration" || stmt.type === "TSTypeAliasDeclaration" || stmt.type === "ExportNamedDeclaration" && (stmt.declaration?.type === "TSInterfaceDeclaration" || stmt.declaration?.type === "TSTypeAliasDeclaration");
37923
37932
  }
@@ -38118,7 +38127,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
38118
38127
  } else if (file.endsWith(".css.d.ts")) {
38119
38128
  content = "";
38120
38129
  } else if (vskFiles.has(file)) {
38121
- content = vskToTsx(vskFiles.get(file));
38130
+ content = compileVskCodegen(vskFiles.get(file)).code;
38122
38131
  } else if (ts8.sys.fileExists(file)) {
38123
38132
  content = ts8.sys.readFile(file);
38124
38133
  }
@@ -38159,7 +38168,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
38159
38168
  if (file.endsWith(".css.d.ts"))
38160
38169
  return "";
38161
38170
  if (vskFiles.has(file))
38162
- return vskToTsx(vskFiles.get(file));
38171
+ return compileVskCodegen(vskFiles.get(file)).code;
38163
38172
  return ts8.sys.readFile(file);
38164
38173
  },
38165
38174
  writeFile: () => {
@@ -38209,6 +38218,35 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
38209
38218
  };
38210
38219
  return host;
38211
38220
  }
38221
+ function mapGeneratedOffset(mappings, generatedOffset) {
38222
+ let nearest = null;
38223
+ for (const mapping of mappings) {
38224
+ for (let i = 0; i < mapping.generatedOffsets.length; i++) {
38225
+ const generated = mapping.generatedOffsets[i];
38226
+ const length = mapping.lengths[i] ?? 0;
38227
+ const source = mapping.sourceOffsets[i];
38228
+ if (generated <= generatedOffset && generated + length >= generatedOffset) {
38229
+ return source + (generatedOffset - generated);
38230
+ }
38231
+ if (generated <= generatedOffset && (!nearest || generated > nearest.generated)) {
38232
+ nearest = { source, generated, length };
38233
+ }
38234
+ }
38235
+ }
38236
+ return nearest ? nearest.source + Math.min(nearest.length, Math.max(0, generatedOffset - nearest.generated)) : null;
38237
+ }
38238
+ function sourcePosition(source, offset2) {
38239
+ const bounded = Math.max(0, Math.min(offset2, source.length));
38240
+ let line = 1;
38241
+ let lineStart = 0;
38242
+ for (let i = 0; i < bounded; i++) {
38243
+ if (source.charCodeAt(i) === 10) {
38244
+ line++;
38245
+ lineStart = i + 1;
38246
+ }
38247
+ }
38248
+ return { line, character: bounded - lineStart + 1 };
38249
+ }
38212
38250
  function typecheckProject(projectRoot, opts = {}) {
38213
38251
  const appDir = opts.appDir ?? join25(projectRoot, "app");
38214
38252
  const vskFiles = /* @__PURE__ */ new Map();
@@ -38289,12 +38327,28 @@ function typecheckProject(projectRoot, opts = {}) {
38289
38327
  }
38290
38328
  if (!rootSet.has(filePath) && !vskSet.has(filePath))
38291
38329
  continue;
38292
- const pos = file.getLineAndCharacterOfPosition(diag.start ?? 0);
38330
+ let sourceOffset = diag.start ?? 0;
38331
+ let line;
38332
+ let column;
38333
+ if (vskFiles.has(filePath)) {
38334
+ const source = vskFiles.get(filePath);
38335
+ const generated = compileVskCodegen(source);
38336
+ const mapped = mapGeneratedOffset(generated.mappings, sourceOffset);
38337
+ if (mapped !== null)
38338
+ sourceOffset = mapped;
38339
+ const pos = sourcePosition(source, sourceOffset);
38340
+ line = pos.line;
38341
+ column = pos.character;
38342
+ } else {
38343
+ const pos = file.getLineAndCharacterOfPosition(diag.start ?? 0);
38344
+ line = pos.line + 1;
38345
+ column = pos.character + 1;
38346
+ }
38293
38347
  const code = typeof diag.code === "number" ? `TS${diag.code}` : String(diag.code);
38294
38348
  errors.push({
38295
38349
  file: relative8(projectRoot, filePath),
38296
- line: pos.line + 1,
38297
- column: pos.character + 1,
38350
+ line,
38351
+ column,
38298
38352
  code,
38299
38353
  message: ts8.flattenDiagnosticMessageText(diag.messageText, "\n")
38300
38354
  });
@@ -52837,7 +52891,7 @@ function renderDevErrorPage(payload, opts) {
52837
52891
  }
52838
52892
 
52839
52893
  // src/build-packages.ts
52840
- import { spawnSync } from "node:child_process";
52894
+ import { spawnSync as spawnSync2 } from "node:child_process";
52841
52895
  import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync18, readFileSync as readFileSync36, readdirSync as readdirSync11, statSync as statSync20, writeFileSync as writeFileSync20 } from "node:fs";
52842
52896
  import { createRequire as createRequire6 } from "node:module";
52843
52897
  import { dirname as dirname25, join as join23, resolve as resolve36 } from "node:path";
@@ -52912,7 +52966,7 @@ function buildPackages(force = false) {
52912
52966
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
52913
52967
  console.log(`[build] ${cfg.name} -> tsc`);
52914
52968
  const tscBin = require2.resolve("typescript/bin/tsc");
52915
- const result = spawnSync(process.execPath, [tscBin, "-p", join23(pkgDir, "tsconfig.build.json")], {
52969
+ const result = spawnSync2(process.execPath, [tscBin, "-p", join23(pkgDir, "tsconfig.build.json")], {
52916
52970
  stdio: "inherit"
52917
52971
  });
52918
52972
  if (result.status !== 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
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.39",
12
- "@vesk/compiler": "^0.2.39",
13
- "@vesk/plugin-tailwind": "^0.2.39",
14
- "@vesk/runtime": "^0.2.39",
11
+ "@vesk/adapter": "^0.2.41",
12
+ "@vesk/compiler": "^0.2.41",
13
+ "@vesk/plugin-tailwind": "^0.2.41",
14
+ "@vesk/runtime": "^0.2.41",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",