@vesk/vesk-cli 0.2.95 → 0.2.97

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 +117 -21
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -2660,6 +2660,12 @@ var init_portal = __esm({
2660
2660
  });
2661
2661
 
2662
2662
  // ../runtime/src/hydrate.ts
2663
+ function createFreshElement(tag) {
2664
+ if (SVG_ONLY_TAGS.has(tag.toLowerCase())) {
2665
+ return document.createElementNS(SVG_NAMESPACE, tag);
2666
+ }
2667
+ return document.createElement(tag);
2668
+ }
2663
2669
  function runInHydrateBlock(fn) {
2664
2670
  const previous = scope();
2665
2671
  const block2 = root(() => {
@@ -3228,12 +3234,75 @@ function hydrateOnInteraction(container, componentFn, props, options = {}) {
3228
3234
  }
3229
3235
  };
3230
3236
  }
3231
- var __hydrateDevMode, claimRegistry, walkerClaimRecords, __hydrateStrict, __mismatchHandler, _SHOW_COMMENT, _FILTER_ACCEPT, _FILTER_SKIP, WalkerEngine, StructuralWalker;
3237
+ var SVG_NAMESPACE, SVG_ONLY_TAGS, __hydrateDevMode, claimRegistry, walkerClaimRecords, __hydrateStrict, __mismatchHandler, _SHOW_COMMENT, _FILTER_ACCEPT, _FILTER_SKIP, WalkerEngine, StructuralWalker;
3232
3238
  var init_hydrate = __esm({
3233
3239
  "../runtime/src/hydrate.ts"() {
3234
3240
  "use strict";
3235
3241
  init_ripple_runtime();
3236
3242
  init_ripple_blocks();
3243
+ SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3244
+ SVG_ONLY_TAGS = new Set(
3245
+ [
3246
+ "svg",
3247
+ "animate",
3248
+ "animateMotion",
3249
+ "animateTransform",
3250
+ "circle",
3251
+ "clipPath",
3252
+ "defs",
3253
+ "desc",
3254
+ "ellipse",
3255
+ "feBlend",
3256
+ "feColorMatrix",
3257
+ "feComponentTransfer",
3258
+ "feComposite",
3259
+ "feConvolveMatrix",
3260
+ "feDiffuseLighting",
3261
+ "feDisplacementMap",
3262
+ "feDistantLight",
3263
+ "feDropShadow",
3264
+ "feFlood",
3265
+ "feFuncA",
3266
+ "feFuncB",
3267
+ "feFuncG",
3268
+ "feFuncR",
3269
+ "feGaussianBlur",
3270
+ "feImage",
3271
+ "feMerge",
3272
+ "feMergeNode",
3273
+ "feMorphology",
3274
+ "feOffset",
3275
+ "fePointLight",
3276
+ "feSpecularLighting",
3277
+ "feSpotLight",
3278
+ "feTile",
3279
+ "feTurbulence",
3280
+ "filter",
3281
+ "foreignObject",
3282
+ "g",
3283
+ "line",
3284
+ "linearGradient",
3285
+ "marker",
3286
+ "mask",
3287
+ "metadata",
3288
+ "mpath",
3289
+ "path",
3290
+ "pattern",
3291
+ "polygon",
3292
+ "polyline",
3293
+ "radialGradient",
3294
+ "rect",
3295
+ "set",
3296
+ "stop",
3297
+ "switch",
3298
+ "symbol",
3299
+ "text",
3300
+ "textPath",
3301
+ "tspan",
3302
+ "use",
3303
+ "view"
3304
+ ].map((tag) => tag.toLowerCase())
3305
+ );
3237
3306
  __hydrateDevMode = true;
3238
3307
  claimRegistry = /* @__PURE__ */ new WeakMap();
3239
3308
  walkerClaimRecords = /* @__PURE__ */ new WeakMap();
@@ -3347,7 +3416,7 @@ var init_hydrate = __esm({
3347
3416
  ${String(this.root.outerHTML).slice(0, 800)}` : ""),
3348
3417
  hasUnconsumed && __hydrateDevMode
3349
3418
  );
3350
- return document.createElement(tag || "div");
3419
+ return createFreshElement(tag || "div");
3351
3420
  }
3352
3421
  claimOnly(tag) {
3353
3422
  while (this.idx < this.markers.length) {
@@ -3390,7 +3459,7 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
3390
3459
  `hydration static claim missed <${tag || "element"}> (${this.markers.length - this.idx} markers unconsumed); the client rendered more or different content than SSR.`,
3391
3460
  hasUnconsumed && __hydrateDevMode
3392
3461
  );
3393
- return document.createElement(tag || "div");
3462
+ return createFreshElement(tag || "div");
3394
3463
  }
3395
3464
  retireDetached() {
3396
3465
  while (this.idx < this.markers.length) {
@@ -3672,7 +3741,7 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
3672
3741
  } catch {
3673
3742
  }
3674
3743
  }
3675
- const fresh2 = document.createElement(expectedTag);
3744
+ const fresh2 = createFreshElement(expectedTag);
3676
3745
  recordClaim(this.root, {
3677
3746
  state: "fresh",
3678
3747
  el: fresh2,
@@ -3698,7 +3767,7 @@ ${String(this.root.outerHTML).slice(0, 800)}` : ""),
3698
3767
  return el;
3699
3768
  }
3700
3769
  this.idx = this.els.length;
3701
- const fresh = document.createElement(tag || "div");
3770
+ const fresh = createFreshElement(tag || "div");
3702
3771
  recordClaim(this.root, {
3703
3772
  state: "fresh",
3704
3773
  el: fresh,
@@ -3964,6 +4033,7 @@ function flattenLayoutChain(tree, pathParts, result = []) {
3964
4033
  const remaining = pathParts.slice(consumeCount);
3965
4034
  const isLeaf2 = remaining.length === 0 || remaining.every((p) => p === "");
3966
4035
  if (node.standalone) result.length = 0;
4036
+ const marker = result.length;
3967
4037
  result.push(node);
3968
4038
  if (isLeaf2) {
3969
4039
  if (!node.page && (node.children || []).length > 0) {
@@ -3973,8 +4043,17 @@ function flattenLayoutChain(tree, pathParts, result = []) {
3973
4043
  }
3974
4044
  break;
3975
4045
  } else if ((node.children || []).length > 0) {
4046
+ const before = result.length;
3976
4047
  flattenLayoutChain(node.children || [], remaining, result);
4048
+ if (result.length > before) break;
4049
+ if (node.isDynamic) {
4050
+ result.length = marker;
4051
+ continue;
4052
+ }
3977
4053
  break;
4054
+ } else if (node.isDynamic) {
4055
+ result.length = marker;
4056
+ continue;
3978
4057
  }
3979
4058
  }
3980
4059
  }
@@ -4523,7 +4602,8 @@ function Link(props, registry, hydrate) {
4523
4602
  props.class ? `class="${String(props.class).replace(/"/g, "&quot;")}"` : "",
4524
4603
  props.style ? `style="${String(props.style).replace(/"/g, "&quot;")}"` : "",
4525
4604
  props.target ? `target="${String(props.target).replace(/"/g, "&quot;")}"` : "",
4526
- props.rel ? `rel="${String(props.rel).replace(/"/g, "&quot;")}"` : ""
4605
+ props.rel ? `rel="${String(props.rel).replace(/"/g, "&quot;")}"` : "",
4606
+ ...passThroughAttrs(props).map(([key, value]) => `${key}="${value.replace(/"/g, "&quot;")}"`)
4527
4607
  ].filter(Boolean).join(" ");
4528
4608
  let childStr = "";
4529
4609
  if (props.children != null) {
@@ -4554,6 +4634,17 @@ function Link(props, registry, hydrate) {
4554
4634
  });
4555
4635
  return a;
4556
4636
  }
4637
+ function passThroughAttrs(props) {
4638
+ const out = [];
4639
+ for (const [key, value] of Object.entries(props)) {
4640
+ if (value == null || value === false) continue;
4641
+ const lower2 = key.toLowerCase();
4642
+ const allowed = lower2.startsWith("data-") || lower2.startsWith("aria-") || lower2 === "role" || lower2 === "id" || lower2 === "title" || lower2 === "tabindex" || lower2 === "download" || lower2 === "hreflang" || lower2 === "referrerpolicy";
4643
+ if (!allowed) continue;
4644
+ out.push([key, value === true ? "" : String(value)]);
4645
+ }
4646
+ return out;
4647
+ }
4557
4648
  function applyLinkDom(a, props, href) {
4558
4649
  const displayHref = routerMode() && !href.startsWith("#") ? "#" + href : href;
4559
4650
  a.href = displayHref;
@@ -4561,6 +4652,7 @@ function applyLinkDom(a, props, href) {
4561
4652
  if (props.style) a.setAttribute("style", props.style);
4562
4653
  if (props.target) a.target = props.target;
4563
4654
  if (props.rel) a.rel = props.rel;
4655
+ for (const [key, value] of passThroughAttrs(props)) a.setAttribute(key, value);
4564
4656
  }
4565
4657
  function NavLink(props, registry, hydrate) {
4566
4658
  if (typeof document === "undefined") {
@@ -19138,7 +19230,7 @@ function offsetToLineCol(source, offset2) {
19138
19230
  }
19139
19231
  return { line, column };
19140
19232
  }
19141
- function preprocessForClauses(source, delimiters) {
19233
+ function preprocessForClauses(source, delimiters, filename = "") {
19142
19234
  const annotations = [];
19143
19235
  const chars = source.split("");
19144
19236
  const isString = (ch) => ch === '"' || ch === "'" || ch === "`";
@@ -19289,9 +19381,11 @@ function preprocessForClauses(source, delimiters) {
19289
19381
  throw new VeskError(
19290
19382
  `Invalid \`; key\` clause \u2014 write the key expression after \`key\` without a colon: \`key ${expr.slice(1).trim()}\`.`,
19291
19383
  {
19384
+ file: filename || "",
19292
19385
  line,
19293
19386
  column,
19294
- code: codeFrame(source, line, column),
19387
+ code: "V0411",
19388
+ frame: codeFrame(source, line, column),
19295
19389
  nextSteps: [
19296
19390
  "Use `; key <expr>` (no colon), e.g. `for (const item of items; key item.id)`.",
19297
19391
  "For the iteration index use `; index <name>`, e.g. `for (const item of items; key item.id; index i)`."
@@ -19506,7 +19600,8 @@ function parse4(source, options = {}) {
19506
19600
  const ParserClass = createBaseParser();
19507
19601
  const sourceTokens = tokenizeCode(source);
19508
19602
  const delimiters = sourceTokens === null ? null : collectStringDelimiters(source, sourceTokens);
19509
- const { code, annotations } = preprocessForClauses(blankGenericArrowTypeParams(blankComments(source)), delimiters);
19603
+ const filename = options.filename || "";
19604
+ const { code, annotations } = preprocessForClauses(blankGenericArrowTypeParams(blankComments(source)), delimiters, filename);
19510
19605
  const vskSource = !options.filename || String(options.filename).endsWith(".vsk");
19511
19606
  const specifierExports = vskSource && sourceTokens !== null ? findSpecifierExports(code, sourceTokens).filter((e) => !hasTopLevelValueDeclaration(code, e.local, sourceTokens)) : [];
19512
19607
  let parseable = code;
@@ -19556,7 +19651,6 @@ function parse4(source, options = {}) {
19556
19651
  }
19557
19652
  }
19558
19653
  }
19559
- const filename = options.filename || "";
19560
19654
  let cleanMessage = err.message;
19561
19655
  const lastParen = cleanMessage.lastIndexOf("(");
19562
19656
  if (lastParen >= 0) {
@@ -21802,7 +21896,7 @@ function assertNoVskNamespaceValue(source, expr) {
21802
21896
  const hit = findNamespaceValueUse(expr, currentVskNamespaceLocals);
21803
21897
  if (!hit) return;
21804
21898
  const { line, column } = offsetToLineCol2(source, hit.start ?? 0);
21805
- throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, code: codeFrame(source, line, column), form: "value" });
21899
+ throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, frame: codeFrame(source, line, column), form: "value" });
21806
21900
  }
21807
21901
  function findNamespaceValueUse(node, locals2) {
21808
21902
  if (!node || typeof node !== "object") return null;
@@ -22375,7 +22469,7 @@ function processJSXElement(source, element) {
22375
22469
  const isVskNamespace = !!currentVskNamespaceLocals && currentVskNamespaceLocals.has(root3);
22376
22470
  if (isVskNamespace && jsxTagDepth(nameNode) > 1) {
22377
22471
  const { line, column } = offsetToLineCol2(source, nameNode.start ?? 0);
22378
- throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, code: codeFrame(source, line, column), form: "nested" });
22472
+ throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, frame: codeFrame(source, line, column), form: "nested" });
22379
22473
  }
22380
22474
  const { props, spreadProps, slots } = extractProps(source, element);
22381
22475
  const children2 = selfClosing ? [] : processJSXChildren(source, element.children || []);
@@ -22701,7 +22795,7 @@ function processStatementModeBody(source, bodyStmts, filename) {
22701
22795
  file: filename || "",
22702
22796
  line,
22703
22797
  column,
22704
- code: codeFrame(source, line, column)
22798
+ frame: codeFrame(source, line, column)
22705
22799
  });
22706
22800
  }
22707
22801
  for (const child of innerStmts) {
@@ -22770,7 +22864,7 @@ function processStatementModeBody(source, bodyStmts, filename) {
22770
22864
  }
22771
22865
  } else if (stmt.type === "ClassDeclaration") {
22772
22866
  const { line, column } = offsetToLineCol2(source, stmt.start ?? 0);
22773
- throw VeskError.classDecl({ file: filename || "", line, column, code: codeFrame(source, line, column) });
22867
+ throw VeskError.classDecl({ file: filename || "", line, column, frame: codeFrame(source, line, column) });
22774
22868
  } else if (stmt.type === "ContinueStatement") {
22775
22869
  break;
22776
22870
  } else if (stmt.type === "BreakStatement") {
@@ -23105,7 +23199,7 @@ function generateIR(ast, source, filename) {
23105
23199
  if (inner.type === "ComponentDeclaration") {
23106
23200
  } else if (inner.type === "ClassDeclaration") {
23107
23201
  const { line, column } = offsetToLineCol2(source, inner.start ?? 0);
23108
- throw VeskError.classDecl({ file, line, column, code: codeFrame(source, line, column) });
23202
+ throw VeskError.classDecl({ file, line, column, frame: codeFrame(source, line, column) });
23109
23203
  } else if (inner.type === "TSEnumDeclaration") {
23110
23204
  const code = processEnum(inner, source, exported);
23111
23205
  topLevelCode.push(code);
@@ -23162,7 +23256,7 @@ function generateIR(ast, source, filename) {
23162
23256
  guardClauses.push(stmt);
23163
23257
  } else if (stmt.type === "ClassDeclaration") {
23164
23258
  const { line, column } = offsetToLineCol2(source, stmt.start ?? 0);
23165
- throw VeskError.classDecl({ file, line, column, code: codeFrame(source, line, column) });
23259
+ throw VeskError.classDecl({ file, line, column, frame: codeFrame(source, line, column) });
23166
23260
  } else {
23167
23261
  const raw2 = getSource(source, stmt);
23168
23262
  if (raw2) preamble.push(new RuntimeStatement(raw2, stmt, source));
@@ -23188,7 +23282,7 @@ function generateIR(ast, source, filename) {
23188
23282
  for (const [childName, start] of called2) {
23189
23283
  if (!asyncNames.has(childName)) continue;
23190
23284
  const { line, column } = offsetToLineCol2(source, start >= 0 ? start : 0);
23191
- throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column, code: codeFrame(source, line, column) });
23285
+ throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column, frame: codeFrame(source, line, column) });
23192
23286
  }
23193
23287
  }
23194
23288
  const autoImportable = [
@@ -44217,7 +44311,7 @@ function offsetToLineCol3(source, offset2) {
44217
44311
  }
44218
44312
  return { line, column };
44219
44313
  }
44220
- function preprocessForClauses2(source, delimiters) {
44314
+ function preprocessForClauses2(source, delimiters, filename = "") {
44221
44315
  const annotations = [];
44222
44316
  const chars = source.split("");
44223
44317
  const isString = (ch) => ch === '"' || ch === "'" || ch === "`";
@@ -44380,9 +44474,11 @@ function preprocessForClauses2(source, delimiters) {
44380
44474
  if (expr[0] === ":") {
44381
44475
  const { line, column } = offsetToLineCol3(source, start);
44382
44476
  throw new VeskError(`Invalid \`; key\` clause \u2014 write the key expression after \`key\` without a colon: \`key ${expr.slice(1).trim()}\`.`, {
44477
+ file: filename || "",
44383
44478
  line,
44384
44479
  column,
44385
- code: codeFrame(source, line, column),
44480
+ code: "V0411",
44481
+ frame: codeFrame(source, line, column),
44386
44482
  nextSteps: [
44387
44483
  "Use `; key <expr>` (no colon), e.g. `for (const item of items; key item.id)`.",
44388
44484
  "For the iteration index use `; index <name>`, e.g. `for (const item of items; key item.id; index i)`."
@@ -44607,7 +44703,8 @@ function parse5(source, options = {}) {
44607
44703
  const ParserClass = createBaseParser2();
44608
44704
  const sourceTokens = tokenizeCode(source);
44609
44705
  const delimiters = sourceTokens === null ? null : collectStringDelimiters(source, sourceTokens);
44610
- const { code, annotations } = preprocessForClauses2(blankGenericArrowTypeParams2(blankComments(source)), delimiters);
44706
+ const filename = options.filename || "";
44707
+ const { code, annotations } = preprocessForClauses2(blankGenericArrowTypeParams2(blankComments(source)), delimiters, filename);
44611
44708
  const vskSource = !options.filename || String(options.filename).endsWith(".vsk");
44612
44709
  const specifierExports = vskSource && sourceTokens !== null ? findSpecifierExports(code, sourceTokens).filter((e) => !hasTopLevelValueDeclaration(code, e.local, sourceTokens)) : [];
44613
44710
  let parseable = code;
@@ -44655,7 +44752,6 @@ function parse5(source, options = {}) {
44655
44752
  }
44656
44753
  }
44657
44754
  }
44658
- const filename = options.filename || "";
44659
44755
  let cleanMessage = err.message;
44660
44756
  const lastParen = cleanMessage.lastIndexOf("(");
44661
44757
  if (lastParen >= 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesk/vesk-cli",
3
- "version": "0.2.95",
3
+ "version": "0.2.97",
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.95",
12
- "@vesk/compiler": "^0.2.95",
13
- "@vesk/plugin-tailwind": "^0.2.95",
14
- "@vesk/runtime": "^0.2.95",
11
+ "@vesk/adapter": "^0.2.97",
12
+ "@vesk/compiler": "^0.2.97",
13
+ "@vesk/plugin-tailwind": "^0.2.97",
14
+ "@vesk/runtime": "^0.2.97",
15
15
  "esrap": "^2.3.0",
16
16
  "typescript": "^5.8.0",
17
17
  "ws": "^8.18.0",