@vesk/vesk-cli 0.2.42 → 0.2.43

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 +1227 -496
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -184,6 +184,24 @@ var init_errors = __esm({
184
184
  tip: isBuiltin ? `"${name}" is a Vesk built-in. Use it directly \u2014 no manual import needed.` : ""
185
185
  });
186
186
  }
187
+ static vskNamespaceTag(context = {}) {
188
+ return new _VeskError(
189
+ "Namespace imports are not supported for `.vsk` modules.",
190
+ {
191
+ ...context,
192
+ code: context.code || "V0410",
193
+ suggestions: [
194
+ "Import the component by name: import { MyIcon } from './icons.vsk'",
195
+ "Rename on import: import { MyIcon as Icon } from './icons.vsk'"
196
+ ],
197
+ nextSteps: [
198
+ "A `.vsk` component is a registry entry keyed by its name, not a module namespace object, so `<ns.Icon />` cannot be resolved.",
199
+ "If you need a namespace object, import from a `.ts`/`.js` module instead \u2014 those are real ES modules."
200
+ ],
201
+ tip: "A `.vsk` module exposes its components as named exports; use a named or renamed import rather than `import * as ns`."
202
+ }
203
+ );
204
+ }
187
205
  static classDecl(context = {}) {
188
206
  return new _VeskError(
189
207
  "class declarations are not supported inside Vesk components.",
@@ -367,13 +385,30 @@ var init_ir = __esm({
367
385
  staticProps;
368
386
  loadFn;
369
387
  topLevelCode;
370
- constructor(components, imports = [], importedNames = /* @__PURE__ */ new Set(), staticProps = null, loadFn = null, topLevelCode = []) {
388
+ /**
389
+ * Same-file specifier exports (`export { A }`, `export { A as B }`) as
390
+ * `{ local, exported }` pairs. These are NOT emitted as JS: components live
391
+ * in the component registry rather than as top-level bindings, so a raw
392
+ * `export { A }` would reference an undefined identifier. The pairs become
393
+ * registry alias entries so the exported name is importable.
394
+ */
395
+ exportAliases;
396
+ /**
397
+ * Module specifiers re-exported from this file (`export * from './x.vsk'`,
398
+ * `export { A } from './x.vsk'`, `export * as ns from './x.vsk'`). The
399
+ * statements themselves are dropped — the target file is compiled and
400
+ * merged into this one's component registry instead.
401
+ */
402
+ reexportSources;
403
+ constructor(components, imports = [], importedNames = /* @__PURE__ */ new Set(), staticProps = null, loadFn = null, topLevelCode = [], exportAliases = [], reexportSources = []) {
371
404
  this.components = components;
372
405
  this.imports = imports;
373
406
  this.importedNames = importedNames;
374
407
  this.staticProps = staticProps;
375
408
  this.loadFn = loadFn;
376
409
  this.topLevelCode = topLevelCode;
410
+ this.exportAliases = exportAliases;
411
+ this.reexportSources = reexportSources;
377
412
  }
378
413
  };
379
414
  ComponentIR = class {
@@ -3440,10 +3475,10 @@ function flattenLayoutChain(tree, pathParts, result = []) {
3440
3475
  if (matched) {
3441
3476
  const consumeCount = node.isCatchAll ? pathParts.length : segCount;
3442
3477
  const remaining = pathParts.slice(consumeCount);
3443
- const isLeaf = remaining.length === 0 || remaining.every((p) => p === "");
3478
+ const isLeaf2 = remaining.length === 0 || remaining.every((p) => p === "");
3444
3479
  if (node.standalone) result.length = 0;
3445
3480
  result.push(node);
3446
- if (isLeaf) {
3481
+ if (isLeaf2) {
3447
3482
  break;
3448
3483
  } else if ((node.children || []).length > 0) {
3449
3484
  flattenLayoutChain(node.children || [], remaining, result);
@@ -16853,9 +16888,9 @@ function looksLikeTypeAssertionAt(input, pos) {
16853
16888
  while (i < input.length && isIdentCharCode(input.charCodeAt(i))) i++;
16854
16889
  const name = input.slice(nameStart, i);
16855
16890
  if (HTML_TAGS.has(name) || VOID_ELEMENTS.has(name)) return false;
16856
- const isPrimitive = TS_PRIMITIVE_TYPES.has(name);
16891
+ const isPrimitive2 = TS_PRIMITIVE_TYPES.has(name);
16857
16892
  const isCapitalized = name[0] >= "A" && name[0] <= "Z";
16858
- if (!isPrimitive && !isCapitalized) return false;
16893
+ if (!isPrimitive2 && !isCapitalized) return false;
16859
16894
  if (input.charCodeAt(i) === 60) {
16860
16895
  let depth = 0;
16861
16896
  let j = i;
@@ -16904,6 +16939,15 @@ function matchKeywordSequence(input, words) {
16904
16939
  const c = input.charCodeAt(p);
16905
16940
  return isWsChar(c) || c === 123;
16906
16941
  }
16942
+ function withStandaloneTokens(fn) {
16943
+ const prev = standaloneTokens;
16944
+ standaloneTokens = true;
16945
+ try {
16946
+ return fn();
16947
+ } finally {
16948
+ standaloneTokens = prev;
16949
+ }
16950
+ }
16907
16951
  function VeskParserPlugin(config = {}) {
16908
16952
  return (Parser3) => {
16909
16953
  const tt = Parser3.tokTypes || types$1;
@@ -16919,6 +16963,10 @@ function VeskParserPlugin(config = {}) {
16919
16963
  constructor(options, input) {
16920
16964
  super(options, input);
16921
16965
  }
16966
+ /** True when JSX tags are recognised without parser-driven componentDepth. */
16967
+ #jsxAllowed() {
16968
+ return this.#componentDepth > 0 || standaloneTokens;
16969
+ }
16922
16970
  #isBlockContext() {
16923
16971
  const ctx2 = this.curContext();
16924
16972
  return ctx2 && (ctx2.token === "{" || ctx2.token === "function");
@@ -17148,7 +17196,7 @@ function VeskParserPlugin(config = {}) {
17148
17196
  }
17149
17197
  return super.readToken(this.input.codePointAt(this.pos));
17150
17198
  }
17151
- if (this.#componentDepth > 0 && code === 60 && this.#isBlockContext()) {
17199
+ if (this.#jsxAllowed() && code === 60 && this.#isBlockContext()) {
17152
17200
  const next = this.input.charCodeAt(this.pos + 1);
17153
17201
  const startsNewStatement = this.hasPrecedingLineBreak();
17154
17202
  const inType = this.inType;
@@ -17599,7 +17647,7 @@ function VeskParserPlugin(config = {}) {
17599
17647
  return VeskParser;
17600
17648
  };
17601
17649
  }
17602
- var VOID_ELEMENTS, TS_PRIMITIVE_TYPES, HTML_TAGS;
17650
+ var VOID_ELEMENTS, TS_PRIMITIVE_TYPES, HTML_TAGS, standaloneTokens;
17603
17651
  var init_vesk_plugin = __esm({
17604
17652
  "../compiler/src/vesk-plugin.ts"() {
17605
17653
  "use strict";
@@ -17622,6 +17670,7 @@ var init_vesk_plugin = __esm({
17622
17670
  ]);
17623
17671
  TS_PRIMITIVE_TYPES = /* @__PURE__ */ new Set(["number", "string", "boolean", "any", "unknown", "never", "void", "object", "symbol", "bigint", "undefined", "null"]);
17624
17672
  HTML_TAGS = /* @__PURE__ */ new Set(["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "menu", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "slot", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr"]);
17673
+ standaloneTokens = false;
17625
17674
  }
17626
17675
  });
17627
17676
 
@@ -17993,6 +18042,340 @@ var init_scan = __esm({
17993
18042
  }
17994
18043
  });
17995
18044
 
18045
+ // ../compiler/src/tokens.ts
18046
+ function tokenizeCode(code) {
18047
+ return withStandaloneTokens(() => {
18048
+ try {
18049
+ const ParserClass = createBaseParser();
18050
+ const tok = ParserClass.tokenizer(code, {
18051
+ ecmaVersion: "latest",
18052
+ sourceType: "module"
18053
+ });
18054
+ const out = [];
18055
+ let t;
18056
+ while ((t = tok.getToken()) && t.type && t.type.label !== "eof") {
18057
+ out.push({
18058
+ label: t.type.label,
18059
+ value: typeof t.value === "string" ? t.value : "",
18060
+ start: t.start,
18061
+ end: t.end
18062
+ });
18063
+ }
18064
+ return out;
18065
+ } catch {
18066
+ return null;
18067
+ }
18068
+ });
18069
+ }
18070
+ function containsIdentifier(code, name) {
18071
+ const tokens = tokenizeCode(code);
18072
+ if (tokens !== null) {
18073
+ for (const t of tokens) {
18074
+ if ((t.label === "name" || t.label === "jsxName") && t.value === name) return true;
18075
+ }
18076
+ return false;
18077
+ }
18078
+ return manualContainsIdentifier(code, name);
18079
+ }
18080
+ function isIdentifierImported(code, name) {
18081
+ const tokens = tokenizeCode(code);
18082
+ if (tokens !== null) {
18083
+ for (let i = 0; i < tokens.length; i++) {
18084
+ if (tokens[i].label !== "import") continue;
18085
+ let j = i + 1;
18086
+ while (j < tokens.length && tokens[j].label !== ";" && !(tokens[j].label === "name" && tokens[j].value === "from")) {
18087
+ j++;
18088
+ }
18089
+ for (let k = i + 1; k < j; k++) {
18090
+ if ((tokens[k].label === "name" || tokens[k].label === "jsxName") && tokens[k].value === name) return true;
18091
+ }
18092
+ i = j;
18093
+ }
18094
+ return false;
18095
+ }
18096
+ return manualIsIdentifierImported(code, name);
18097
+ }
18098
+ function extractImportNames(importText) {
18099
+ const tokens = tokenizeCode(importText);
18100
+ if (tokens !== null) {
18101
+ const names = [];
18102
+ let i = 0;
18103
+ while (i < tokens.length && tokens[i].label !== "import") i++;
18104
+ if (i >= tokens.length) return names;
18105
+ i++;
18106
+ if (i < tokens.length && tokens[i].label === "name" && tokens[i].value === "type") i++;
18107
+ if (i < tokens.length && tokens[i].label === "{") {
18108
+ i++;
18109
+ while (i < tokens.length && tokens[i].label !== "}") {
18110
+ const t = tokens[i];
18111
+ if (t.label === "name") {
18112
+ if (t.value === "type" || t.value === "typeof") {
18113
+ i++;
18114
+ continue;
18115
+ }
18116
+ let name = t.value;
18117
+ if (i + 2 < tokens.length && tokens[i + 1].label === "name" && tokens[i + 1].value === "as" && tokens[i + 2].label === "name") {
18118
+ name = tokens[i + 2].value;
18119
+ i += 2;
18120
+ }
18121
+ names.push(name);
18122
+ }
18123
+ i++;
18124
+ }
18125
+ return names;
18126
+ }
18127
+ if (i < tokens.length && tokens[i].label === "*") {
18128
+ while (i < tokens.length && tokens[i].label !== "name") i++;
18129
+ if (i < tokens.length) names.push(tokens[i].value);
18130
+ } else if (i < tokens.length && tokens[i].label === "name") {
18131
+ names.push(tokens[i].value);
18132
+ }
18133
+ return names;
18134
+ }
18135
+ return manualExtractImportNames(importText);
18136
+ }
18137
+ function importModuleTarget(importText) {
18138
+ const tokens = tokenizeCode(importText);
18139
+ if (tokens === null) return null;
18140
+ for (let i = tokens.length - 1; i >= 0; i--) {
18141
+ if (tokens[i].label === "string") return tokens[i].value;
18142
+ }
18143
+ return null;
18144
+ }
18145
+ function manualContainsIdentifier(code, name) {
18146
+ let i = 0;
18147
+ while (i < code.length) {
18148
+ const c = code[i];
18149
+ if (c === '"' || c === "'" || c === "`") {
18150
+ i = skipString(code, i);
18151
+ continue;
18152
+ }
18153
+ if (c === "/" && (code[i + 1] === "/" || code[i + 1] === "*")) {
18154
+ i = skipComment(code, i);
18155
+ continue;
18156
+ }
18157
+ if (isIdentStart(c) && code.slice(i, i + name.length) === name) {
18158
+ const after = i + name.length;
18159
+ if ((after >= code.length || !isIdentChar(code[after])) && (i === 0 || !isIdentChar(code[i - 1]))) return true;
18160
+ }
18161
+ i++;
18162
+ }
18163
+ return false;
18164
+ }
18165
+ function manualIsIdentifierImported(code, name) {
18166
+ let i = 0;
18167
+ while (i < code.length) {
18168
+ const c = code[i];
18169
+ if (c === '"' || c === "'" || c === "`") {
18170
+ i = skipString(code, i);
18171
+ continue;
18172
+ }
18173
+ if (c === "/" && (code[i + 1] === "/" || code[i + 1] === "*")) {
18174
+ i = skipComment(code, i);
18175
+ continue;
18176
+ }
18177
+ if (isIdentStart(c)) {
18178
+ let j = i + 1;
18179
+ while (j < code.length && isIdentChar(code[j])) j++;
18180
+ const word = code.slice(i, j);
18181
+ if (word === "import") {
18182
+ let k = j;
18183
+ while (k < code.length) {
18184
+ if (code[k] === ";" || code[k] === "\n") break;
18185
+ if (code[k] === '"' || code[k] === "'" || code[k] === "`") {
18186
+ k = skipString(code, k);
18187
+ continue;
18188
+ }
18189
+ if (isIdentStart(code[k]) && code.slice(k, k + name.length) === name) {
18190
+ const a = k + name.length;
18191
+ if ((a >= code.length || !isIdentChar(code[a])) && (k === 0 || !isIdentChar(code[k - 1]))) return true;
18192
+ }
18193
+ k++;
18194
+ }
18195
+ }
18196
+ i = j;
18197
+ continue;
18198
+ }
18199
+ i++;
18200
+ }
18201
+ return false;
18202
+ }
18203
+ function manualExtractImportNames(importText) {
18204
+ const names = [];
18205
+ const open = importText.indexOf("{");
18206
+ if (open !== -1) {
18207
+ const close = importText.indexOf("}", open + 1);
18208
+ if (close !== -1) {
18209
+ let i2 = open + 1;
18210
+ while (i2 < close) {
18211
+ const c = importText[i2];
18212
+ if (c === '"' || c === "'" || c === "`") {
18213
+ i2 = skipString(importText, i2);
18214
+ continue;
18215
+ }
18216
+ if (isIdentStart(c)) {
18217
+ let j = i2 + 1;
18218
+ while (j < close && isIdentChar(importText[j])) j++;
18219
+ let word = importText.slice(i2, j);
18220
+ if (word === "type" || word === "typeof") {
18221
+ i2 = j;
18222
+ continue;
18223
+ }
18224
+ let k = skipWhitespace(importText, j);
18225
+ if (importText.slice(k, k + 2) === "as" && !isIdentChar(importText[k + 2])) {
18226
+ let m = skipWhitespace(importText, k + 2);
18227
+ if (isIdentStart(importText[m])) {
18228
+ let n = m + 1;
18229
+ while (n < close && isIdentChar(importText[n])) n++;
18230
+ word = importText.slice(m, n);
18231
+ }
18232
+ }
18233
+ names.push(word);
18234
+ i2 = j;
18235
+ continue;
18236
+ }
18237
+ i2++;
18238
+ }
18239
+ return names;
18240
+ }
18241
+ }
18242
+ let i = 0;
18243
+ while (i < importText.length && !isIdentStart(importText[i])) i++;
18244
+ while (i < importText.length && isIdentChar(importText[i])) i++;
18245
+ i = skipWhitespace(importText, i);
18246
+ if (importText[i] === "*") {
18247
+ i = skipWhitespace(importText, i + 1);
18248
+ if (importText.slice(i, i + 2) === "as") i = skipWhitespace(importText, i + 2);
18249
+ if (isIdentStart(importText[i])) {
18250
+ let j = i + 1;
18251
+ while (j < importText.length && isIdentChar(importText[j])) j++;
18252
+ names.push(importText.slice(i, j));
18253
+ }
18254
+ } else if (isIdentStart(importText[i])) {
18255
+ let j = i + 1;
18256
+ while (j < importText.length && isIdentChar(importText[j])) j++;
18257
+ names.push(importText.slice(i, j));
18258
+ }
18259
+ return names;
18260
+ }
18261
+ function hasTopLevelValueDeclaration(code, name) {
18262
+ const tokens = tokenizeCode(code);
18263
+ if (tokens === null) return false;
18264
+ const declWords = ["const", "let", "var", "function", "class"];
18265
+ for (let i = 1; i < tokens.length; i++) {
18266
+ if (tokens[i].label !== "name" || tokens[i].value !== name) continue;
18267
+ const prev = tokens[i - 1];
18268
+ if (!prev || !declWords.includes(prev.value)) continue;
18269
+ if (i >= 2) {
18270
+ const pp2 = tokens[i - 2];
18271
+ if (pp2 && pp2.label === "name" && pp2.value === "export") continue;
18272
+ }
18273
+ return true;
18274
+ }
18275
+ return false;
18276
+ }
18277
+ function findSpecifierExports(code) {
18278
+ const tokens = tokenizeCode(code);
18279
+ if (tokens === null) return [];
18280
+ const out = [];
18281
+ for (let i = 0; i < tokens.length; i++) {
18282
+ if (tokens[i].label !== "export") continue;
18283
+ if (!tokens[i + 1] || tokens[i + 1].label !== "{") continue;
18284
+ let k = i + 2;
18285
+ let depth = 1;
18286
+ for (; k < tokens.length; k++) {
18287
+ const lbl = tokens[k].label;
18288
+ if (lbl === "string") {
18289
+ continue;
18290
+ }
18291
+ if (lbl === "{") depth++;
18292
+ else if (lbl === "}") {
18293
+ depth--;
18294
+ if (depth === 0) break;
18295
+ }
18296
+ }
18297
+ let isReexport = false;
18298
+ for (let j = k + 1; j < tokens.length; j++) {
18299
+ const lbl = tokens[j].label;
18300
+ if (lbl === "string") {
18301
+ isReexport = true;
18302
+ break;
18303
+ }
18304
+ if (lbl === ";" || lbl === "export" || lbl === "import" || lbl === "}") break;
18305
+ }
18306
+ if (depth !== 0 || isReexport) continue;
18307
+ const pairs = readSpecifierPairs(code, tokens[i + 1].end, tokens[k].end);
18308
+ if (pairs === null) continue;
18309
+ const stmtEnd = tokens[k].end;
18310
+ for (const [local, exported] of pairs) out.push({ local, exported, start: tokens[i].start, end: stmtEnd });
18311
+ i = k;
18312
+ }
18313
+ return out;
18314
+ }
18315
+ function readSpecifierPairs(code, from, to) {
18316
+ const tokens = tokenizeCode(`(${code.slice(from, to)})`);
18317
+ if (tokens === null || tokens.length < 2) return null;
18318
+ const pairs = [];
18319
+ let i = 1;
18320
+ while (i < tokens.length) {
18321
+ const local = tokens[i];
18322
+ if (!local || local.label === ")" || local.label === ";") break;
18323
+ if (local.label !== "name") return null;
18324
+ const asTok = tokens[i + 1];
18325
+ if (asTok && asTok.label === "name" && asTok.value === "as") {
18326
+ const exported = tokens[i + 2];
18327
+ if (!exported || exported.label !== "name") return null;
18328
+ pairs.push([local.value, exported.value]);
18329
+ i += 3;
18330
+ } else {
18331
+ pairs.push([local.value, local.value]);
18332
+ i += 1;
18333
+ }
18334
+ const sep8 = tokens[i];
18335
+ if (!sep8 || sep8.label !== ",") break;
18336
+ i += 1;
18337
+ }
18338
+ return pairs.length > 0 ? pairs : null;
18339
+ }
18340
+ function collectTrackDeclMarkers(node, out) {
18341
+ if (!node || typeof node !== "object") return;
18342
+ if (Array.isArray(node)) {
18343
+ for (const child of node) collectTrackDeclMarkers(child, out);
18344
+ return;
18345
+ }
18346
+ if (node.type === "ArrayPattern" && node.lazy === true && typeof node.start === "number") {
18347
+ out.add(node.start - 1);
18348
+ return;
18349
+ }
18350
+ for (const key of Object.keys(node)) {
18351
+ const value = node[key];
18352
+ if (value && typeof value === "object") collectTrackDeclMarkers(value, out);
18353
+ }
18354
+ }
18355
+ function stripTrackDeclMarkers(text, base, node) {
18356
+ const offsets = /* @__PURE__ */ new Set();
18357
+ collectTrackDeclMarkers(node, offsets);
18358
+ if (offsets.size === 0) return text;
18359
+ const sorted = [...offsets].sort((a, b) => a - b);
18360
+ let out = "";
18361
+ let prev = 0;
18362
+ for (const offset2 of sorted) {
18363
+ const i = offset2 - base;
18364
+ if (i < prev || i >= text.length) continue;
18365
+ out += text.slice(prev, i) + " ";
18366
+ prev = i + 1;
18367
+ }
18368
+ return out + text.slice(prev);
18369
+ }
18370
+ var init_tokens = __esm({
18371
+ "../compiler/src/tokens.ts"() {
18372
+ "use strict";
18373
+ init_parser();
18374
+ init_vesk_plugin();
18375
+ init_scan();
18376
+ }
18377
+ });
18378
+
17996
18379
  // ../compiler/src/parser.ts
17997
18380
  function isIdentChar2(code) {
17998
18381
  return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95 || code === 36;
@@ -18213,8 +18596,19 @@ function createBaseParser() {
18213
18596
  function parse4(source, options = {}) {
18214
18597
  const ParserClass = createBaseParser();
18215
18598
  const { code, annotations } = preprocessForClauses(blankComments(source));
18599
+ const vskSource = !options.filename || String(options.filename).endsWith(".vsk");
18600
+ const specifierExports = vskSource ? findSpecifierExports(code).filter((e) => !hasTopLevelValueDeclaration(code, e.local)) : [];
18601
+ let parseable = code;
18602
+ if (specifierExports.length > 0) {
18603
+ const edits = specifierExports.map((e) => code.slice(e.start, e.end)).map((text) => text.split("").map((ch) => ch === "\n" ? "\n" : " ").join(""));
18604
+ let cut = 0;
18605
+ for (const spec of specifierExports) {
18606
+ const blanked = edits[cut++];
18607
+ parseable = parseable.slice(0, spec.start) + blanked + parseable.slice(spec.end);
18608
+ }
18609
+ }
18216
18610
  try {
18217
- const ast = ParserClass.parse(code, {
18611
+ const ast = ParserClass.parse(parseable, {
18218
18612
  ecmaVersion: "latest",
18219
18613
  sourceType: "module",
18220
18614
  locations: true,
@@ -18224,6 +18618,11 @@ function parse4(source, options = {}) {
18224
18618
  if (annotations.length > 0) {
18225
18619
  ast.__vskAnnotations = annotations;
18226
18620
  }
18621
+ if (specifierExports.length > 0) {
18622
+ ast.__vskSpecifierExports = specifierExports.map(
18623
+ (e) => ({ local: e.local, exported: e.exported })
18624
+ );
18625
+ }
18227
18626
  return ast;
18228
18627
  } catch (e) {
18229
18628
  const err = e;
@@ -18264,6 +18663,7 @@ var init_parser = __esm({
18264
18663
  init_vesk_plugin();
18265
18664
  init_scan();
18266
18665
  init_errors();
18666
+ init_tokens();
18267
18667
  }
18268
18668
  });
18269
18669
 
@@ -18458,228 +18858,6 @@ var init_strip_ts = __esm({
18458
18858
  }
18459
18859
  });
18460
18860
 
18461
- // ../compiler/src/tokens.ts
18462
- function tokenizeCode(code) {
18463
- try {
18464
- const ParserClass = createBaseParser();
18465
- const tok = ParserClass.tokenizer(code, {
18466
- ecmaVersion: "latest",
18467
- sourceType: "module"
18468
- });
18469
- const out = [];
18470
- let t;
18471
- while ((t = tok.getToken()) && t.type && t.type.label !== "eof") {
18472
- out.push({
18473
- label: t.type.label,
18474
- value: typeof t.value === "string" ? t.value : "",
18475
- start: t.start,
18476
- end: t.end
18477
- });
18478
- }
18479
- return out;
18480
- } catch {
18481
- return null;
18482
- }
18483
- }
18484
- function containsIdentifier(code, name) {
18485
- const tokens = tokenizeCode(code);
18486
- if (tokens !== null) {
18487
- for (const t of tokens) {
18488
- if ((t.label === "name" || t.label === "jsxName") && t.value === name) return true;
18489
- }
18490
- return false;
18491
- }
18492
- return manualContainsIdentifier(code, name);
18493
- }
18494
- function isIdentifierImported(code, name) {
18495
- const tokens = tokenizeCode(code);
18496
- if (tokens !== null) {
18497
- for (let i = 0; i < tokens.length; i++) {
18498
- if (tokens[i].label !== "import") continue;
18499
- let j = i + 1;
18500
- while (j < tokens.length && tokens[j].label !== ";" && !(tokens[j].label === "name" && tokens[j].value === "from")) {
18501
- j++;
18502
- }
18503
- for (let k = i + 1; k < j; k++) {
18504
- if ((tokens[k].label === "name" || tokens[k].label === "jsxName") && tokens[k].value === name) return true;
18505
- }
18506
- i = j;
18507
- }
18508
- return false;
18509
- }
18510
- return manualIsIdentifierImported(code, name);
18511
- }
18512
- function extractImportNames(importText) {
18513
- const tokens = tokenizeCode(importText);
18514
- if (tokens !== null) {
18515
- const names = [];
18516
- let i = 0;
18517
- while (i < tokens.length && tokens[i].label !== "import") i++;
18518
- if (i >= tokens.length) return names;
18519
- i++;
18520
- if (i < tokens.length && tokens[i].label === "name" && tokens[i].value === "type") i++;
18521
- if (i < tokens.length && tokens[i].label === "{") {
18522
- i++;
18523
- while (i < tokens.length && tokens[i].label !== "}") {
18524
- const t = tokens[i];
18525
- if (t.label === "name") {
18526
- if (t.value === "type" || t.value === "typeof") {
18527
- i++;
18528
- continue;
18529
- }
18530
- let name = t.value;
18531
- if (i + 2 < tokens.length && tokens[i + 1].label === "name" && tokens[i + 1].value === "as" && tokens[i + 2].label === "name") {
18532
- name = tokens[i + 2].value;
18533
- i += 2;
18534
- }
18535
- names.push(name);
18536
- }
18537
- i++;
18538
- }
18539
- return names;
18540
- }
18541
- if (i < tokens.length && tokens[i].label === "*") {
18542
- while (i < tokens.length && tokens[i].label !== "name") i++;
18543
- if (i < tokens.length) names.push(tokens[i].value);
18544
- } else if (i < tokens.length && tokens[i].label === "name") {
18545
- names.push(tokens[i].value);
18546
- }
18547
- return names;
18548
- }
18549
- return manualExtractImportNames(importText);
18550
- }
18551
- function importModuleTarget(importText) {
18552
- const tokens = tokenizeCode(importText);
18553
- if (tokens === null) return null;
18554
- for (let i = tokens.length - 1; i >= 0; i--) {
18555
- if (tokens[i].label === "string") return tokens[i].value;
18556
- }
18557
- return null;
18558
- }
18559
- function manualContainsIdentifier(code, name) {
18560
- let i = 0;
18561
- while (i < code.length) {
18562
- const c = code[i];
18563
- if (c === '"' || c === "'" || c === "`") {
18564
- i = skipString(code, i);
18565
- continue;
18566
- }
18567
- if (c === "/" && (code[i + 1] === "/" || code[i + 1] === "*")) {
18568
- i = skipComment(code, i);
18569
- continue;
18570
- }
18571
- if (isIdentStart(c) && code.slice(i, i + name.length) === name) {
18572
- const after = i + name.length;
18573
- if ((after >= code.length || !isIdentChar(code[after])) && (i === 0 || !isIdentChar(code[i - 1]))) return true;
18574
- }
18575
- i++;
18576
- }
18577
- return false;
18578
- }
18579
- function manualIsIdentifierImported(code, name) {
18580
- let i = 0;
18581
- while (i < code.length) {
18582
- const c = code[i];
18583
- if (c === '"' || c === "'" || c === "`") {
18584
- i = skipString(code, i);
18585
- continue;
18586
- }
18587
- if (c === "/" && (code[i + 1] === "/" || code[i + 1] === "*")) {
18588
- i = skipComment(code, i);
18589
- continue;
18590
- }
18591
- if (isIdentStart(c)) {
18592
- let j = i + 1;
18593
- while (j < code.length && isIdentChar(code[j])) j++;
18594
- const word = code.slice(i, j);
18595
- if (word === "import") {
18596
- let k = j;
18597
- while (k < code.length) {
18598
- if (code[k] === ";" || code[k] === "\n") break;
18599
- if (code[k] === '"' || code[k] === "'" || code[k] === "`") {
18600
- k = skipString(code, k);
18601
- continue;
18602
- }
18603
- if (isIdentStart(code[k]) && code.slice(k, k + name.length) === name) {
18604
- const a = k + name.length;
18605
- if ((a >= code.length || !isIdentChar(code[a])) && (k === 0 || !isIdentChar(code[k - 1]))) return true;
18606
- }
18607
- k++;
18608
- }
18609
- }
18610
- i = j;
18611
- continue;
18612
- }
18613
- i++;
18614
- }
18615
- return false;
18616
- }
18617
- function manualExtractImportNames(importText) {
18618
- const names = [];
18619
- const open = importText.indexOf("{");
18620
- if (open !== -1) {
18621
- const close = importText.indexOf("}", open + 1);
18622
- if (close !== -1) {
18623
- let i2 = open + 1;
18624
- while (i2 < close) {
18625
- const c = importText[i2];
18626
- if (c === '"' || c === "'" || c === "`") {
18627
- i2 = skipString(importText, i2);
18628
- continue;
18629
- }
18630
- if (isIdentStart(c)) {
18631
- let j = i2 + 1;
18632
- while (j < close && isIdentChar(importText[j])) j++;
18633
- let word = importText.slice(i2, j);
18634
- if (word === "type" || word === "typeof") {
18635
- i2 = j;
18636
- continue;
18637
- }
18638
- let k = skipWhitespace(importText, j);
18639
- if (importText.slice(k, k + 2) === "as" && !isIdentChar(importText[k + 2])) {
18640
- let m = skipWhitespace(importText, k + 2);
18641
- if (isIdentStart(importText[m])) {
18642
- let n = m + 1;
18643
- while (n < close && isIdentChar(importText[n])) n++;
18644
- word = importText.slice(m, n);
18645
- }
18646
- }
18647
- names.push(word);
18648
- i2 = j;
18649
- continue;
18650
- }
18651
- i2++;
18652
- }
18653
- return names;
18654
- }
18655
- }
18656
- let i = 0;
18657
- while (i < importText.length && !isIdentStart(importText[i])) i++;
18658
- while (i < importText.length && isIdentChar(importText[i])) i++;
18659
- i = skipWhitespace(importText, i);
18660
- if (importText[i] === "*") {
18661
- i = skipWhitespace(importText, i + 1);
18662
- if (importText.slice(i, i + 2) === "as") i = skipWhitespace(importText, i + 2);
18663
- if (isIdentStart(importText[i])) {
18664
- let j = i + 1;
18665
- while (j < importText.length && isIdentChar(importText[j])) j++;
18666
- names.push(importText.slice(i, j));
18667
- }
18668
- } else if (isIdentStart(importText[i])) {
18669
- let j = i + 1;
18670
- while (j < importText.length && isIdentChar(importText[j])) j++;
18671
- names.push(importText.slice(i, j));
18672
- }
18673
- return names;
18674
- }
18675
- var init_tokens = __esm({
18676
- "../compiler/src/tokens.ts"() {
18677
- "use strict";
18678
- init_parser();
18679
- init_scan();
18680
- }
18681
- });
18682
-
18683
18861
  // ../compiler/src/module-imports.ts
18684
18862
  import { readFileSync as readFileSync2, existsSync as existsSync2, realpathSync, statSync } from "node:fs";
18685
18863
  import { createRequire as createRequire2 } from "node:module";
@@ -19629,19 +19807,65 @@ function collectVskImportPaths(imports, sourcePath2) {
19629
19807
  if (stripTypeImport(imp) === null) continue;
19630
19808
  const target = vskImportTarget(imp);
19631
19809
  if (!target) continue;
19632
- if (target.startsWith(".")) {
19633
- const full = resolve2(dirname3(sourcePath2), target);
19634
- if (existsSync3(full)) out.push(full);
19635
- continue;
19636
- }
19637
- const aliased = resolveImportPath(target, dirname3(sourcePath2));
19638
- if (aliased !== target && existsSync3(aliased)) out.push(aliased);
19810
+ const full = resolveVskTarget(target, sourcePath2);
19811
+ if (full) out.push(full);
19639
19812
  }
19640
19813
  return out;
19641
19814
  }
19815
+ function collectVskReexportPaths(reexportSources, sourcePath2) {
19816
+ const out = [];
19817
+ for (const spec of reexportSources) {
19818
+ if (!spec.endsWith(".vsk")) continue;
19819
+ const full = resolveVskTarget(spec, sourcePath2);
19820
+ if (full) out.push(full);
19821
+ }
19822
+ return out;
19823
+ }
19824
+ function resolveVskTarget(target, sourcePath2) {
19825
+ if (target.startsWith(".")) {
19826
+ const full = resolve2(dirname3(sourcePath2), target);
19827
+ return existsSync3(full) ? full : null;
19828
+ }
19829
+ const aliased = resolveImportPath(target, dirname3(sourcePath2));
19830
+ return aliased !== target && existsSync3(aliased) ? aliased : null;
19831
+ }
19832
+ function vskImportValueNames(imports) {
19833
+ const names = [];
19834
+ for (const imp of imports) {
19835
+ if (stripTypeImport(imp) === null) continue;
19836
+ if (vskImportTarget(imp) === null) continue;
19837
+ for (const pair of importBindingPairs(imp)) {
19838
+ if (pair.imported === "default" || pair.imported === "*") continue;
19839
+ names.push(pair.local);
19840
+ }
19841
+ }
19842
+ return names;
19843
+ }
19642
19844
  function vskImportLines(source) {
19643
19845
  return extractImportStatements(source).filter((imp) => vskImportTarget(imp) !== null && stripTypeImport(imp) !== null);
19644
19846
  }
19847
+ function vskRegistryAliases(importLines, exportAliases) {
19848
+ const aliases = [];
19849
+ for (const alias of exportAliases) {
19850
+ if (alias.local !== alias.exported) aliases.push({ local: alias.local, exported: alias.exported });
19851
+ }
19852
+ for (const imp of importLines) {
19853
+ if (stripTypeImport(imp) === null) continue;
19854
+ if (vskImportTarget(imp) === null) continue;
19855
+ for (const pair of importBindingPairs(imp)) {
19856
+ if (pair.imported === "default" || pair.imported === "*") continue;
19857
+ if (pair.local !== pair.imported) aliases.push({ local: pair.imported, exported: pair.local });
19858
+ }
19859
+ }
19860
+ return aliases;
19861
+ }
19862
+ function applyVskRegistryAliases(componentMap, aliases) {
19863
+ for (const { local, exported } of aliases) {
19864
+ if (componentMap.has(exported)) continue;
19865
+ const fn = componentMap.get(local);
19866
+ if (fn) componentMap.set(exported, fn);
19867
+ }
19868
+ }
19645
19869
  function isTypeOnlyImport(stmt) {
19646
19870
  if (!stmt || stmt.type !== "ImportDeclaration") return false;
19647
19871
  if (stmt.importKind === "type") return true;
@@ -19952,6 +20176,22 @@ function getJSXTagName(nameNode) {
19952
20176
  }
19953
20177
  return "unknown";
19954
20178
  }
20179
+ function jsxTagRootName(nameNode) {
20180
+ let node = nameNode;
20181
+ while (node && node.type === "JSXMemberExpression") node = node.object;
20182
+ return node && node.type === "JSXIdentifier" ? node.name : "";
20183
+ }
20184
+ function collectVskNamespaceLocals(ast) {
20185
+ const out = /* @__PURE__ */ new Set();
20186
+ for (const node of ast.body || []) {
20187
+ if (node.type !== "ImportDeclaration") continue;
20188
+ if (typeof node.source?.value !== "string" || !node.source.value.endsWith(".vsk")) continue;
20189
+ for (const spec of node.specifiers || []) {
20190
+ if (spec.type === "ImportNamespaceSpecifier" && spec.local?.name) out.add(spec.local.name);
20191
+ }
20192
+ }
20193
+ return out;
20194
+ }
19955
20195
  function isHTMLTag(name) {
19956
20196
  return name.length > 0 && name[0] === name[0].toLowerCase();
19957
20197
  }
@@ -20320,6 +20560,11 @@ function processJSXElement(source, element) {
20320
20560
  return [new HeadBlock(children2)];
20321
20561
  }
20322
20562
  if (nameNode && nameNode.type === "JSXMemberExpression") {
20563
+ const root3 = jsxTagRootName(nameNode);
20564
+ if (currentVskNamespaceLocals && currentVskNamespaceLocals.has(root3)) {
20565
+ const { line, column } = offsetToLineCol2(source, nameNode.start ?? 0);
20566
+ throw VeskError.vskNamespaceTag({ file: currentSourceFile, line, column, code: codeFrame(source, line, column) });
20567
+ }
20323
20568
  const { props, spreadProps, slots } = extractProps(source, element);
20324
20569
  const children2 = selfClosing ? [] : processJSXChildren(source, element.children || []);
20325
20570
  return [new ComponentCall(tagName, props, [...children2, ...slots.map((s) => new PropSlot(s.name, s.nodes))], spreadProps, element.start, getSource(source, nameNode))];
@@ -20735,217 +20980,263 @@ function generateIR(ast, source, filename) {
20735
20980
  let staticProps = null;
20736
20981
  let loadFn = null;
20737
20982
  const topLevelCode = [];
20738
- for (const node of ast.body) {
20739
- if (node.type === "ImportDeclaration") {
20740
- const raw2 = getSource(source, node);
20741
- let cleaned = stripTypeImport(raw2);
20742
- if (cleaned === null) continue;
20743
- cleaned = normalizeRuntimeSpecifier(cleaned);
20744
- imports.push(cleaned);
20745
- for (const spec of node.specifiers) {
20746
- if (spec.importKind === "type") continue;
20747
- if (spec.type === "ImportSpecifier") {
20748
- importedNames.add(spec.local.name);
20983
+ const exportAliases = [];
20984
+ const reexportSources = [];
20985
+ for (const pair of ast.__vskSpecifierExports || []) {
20986
+ exportAliases.push({ local: pair.local, exported: pair.exported });
20987
+ }
20988
+ const vskNamespaceLocals = collectVskNamespaceLocals(ast);
20989
+ const prevNamespaceLocals = currentVskNamespaceLocals;
20990
+ const prevSourceFile = currentSourceFile;
20991
+ currentVskNamespaceLocals = vskNamespaceLocals;
20992
+ currentSourceFile = file;
20993
+ try {
20994
+ for (const node of ast.body) {
20995
+ if (node.type === "ImportDeclaration") {
20996
+ const raw2 = getSource(source, node);
20997
+ let cleaned = stripTypeImport(raw2);
20998
+ if (cleaned === null) continue;
20999
+ cleaned = normalizeRuntimeSpecifier(cleaned);
21000
+ imports.push(cleaned);
21001
+ for (const spec of node.specifiers) {
21002
+ if (spec.importKind === "type") continue;
21003
+ if (spec.type === "ImportSpecifier") {
21004
+ importedNames.add(spec.local.name);
21005
+ }
20749
21006
  }
21007
+ continue;
20750
21008
  }
20751
- continue;
20752
- }
20753
- if (node.type === "ExportNamedDeclaration" && node.declaration && !staticProps) {
20754
- const decl = node.declaration;
20755
- const fnName = decl.type === "FunctionDeclaration" ? decl.id?.name : decl.type === "VariableDeclaration" ? decl.declarations[0]?.id?.name : null;
20756
- if (fnName === "getStaticProps") {
20757
- staticProps = stripCodeTypes(getSource(source, decl));
21009
+ if (node.type === "ExportNamedDeclaration" && node.declaration && !staticProps) {
21010
+ const decl = node.declaration;
21011
+ const fnName = decl.type === "FunctionDeclaration" ? decl.id?.name : decl.type === "VariableDeclaration" ? decl.declarations[0]?.id?.name : null;
21012
+ if (fnName === "getStaticProps") {
21013
+ staticProps = stripCodeTypes(getSource(source, decl));
21014
+ continue;
21015
+ }
21016
+ }
21017
+ if (node.type === "ExportNamedDeclaration" && node.declaration && !loadFn) {
21018
+ const decl = node.declaration;
21019
+ const fnName = decl.type === "FunctionDeclaration" ? decl.id?.name : decl.type === "VariableDeclaration" ? decl.declarations[0]?.id?.name : null;
21020
+ if (fnName === "load") {
21021
+ loadFn = stripCodeTypes(getSource(source, decl));
21022
+ continue;
21023
+ }
21024
+ }
21025
+ if (node.type === "ExportNamedDeclaration" && node.declaration) {
21026
+ const decl = node.declaration;
21027
+ if (decl.type === "VariableDeclaration") {
21028
+ const declName = decl.declarations[0]?.id?.name;
21029
+ if (declName === "standalone") {
21030
+ continue;
21031
+ }
21032
+ }
21033
+ }
21034
+ if (node.type === "ExportNamedDeclaration" && !node.declaration) {
21035
+ if (node.source) {
21036
+ if (typeof node.source.value === "string") reexportSources.push(node.source.value);
21037
+ for (const spec of node.specifiers || []) {
21038
+ if (spec.type === "ExportSpecifier") {
21039
+ const localName = spec.local && spec.local.name;
21040
+ const exportedName = spec.exported && spec.exported.name;
21041
+ if (typeof localName === "string" && typeof exportedName === "string") {
21042
+ exportAliases.push({ local: localName, exported: exportedName });
21043
+ }
21044
+ }
21045
+ }
21046
+ continue;
21047
+ }
21048
+ for (const spec of node.specifiers || []) {
21049
+ if (spec.type === "ExportSpecifier") {
21050
+ const localName = spec.local && spec.local.name;
21051
+ const exportedName = spec.exported && spec.exported.name;
21052
+ if (typeof localName === "string" && typeof exportedName === "string") {
21053
+ exportAliases.push({ local: localName, exported: exportedName });
21054
+ }
21055
+ }
21056
+ }
20758
21057
  continue;
20759
21058
  }
20760
- }
20761
- if (node.type === "ExportNamedDeclaration" && node.declaration && !loadFn) {
20762
- const decl = node.declaration;
20763
- const fnName = decl.type === "FunctionDeclaration" ? decl.id?.name : decl.type === "VariableDeclaration" ? decl.declarations[0]?.id?.name : null;
20764
- if (fnName === "load") {
20765
- loadFn = stripCodeTypes(getSource(source, decl));
21059
+ if (node.type === "ExportAllDeclaration") {
21060
+ if (node.source && typeof node.source.value === "string") reexportSources.push(node.source.value);
20766
21061
  continue;
20767
21062
  }
20768
- }
20769
- if (node.type === "ExportNamedDeclaration" && node.declaration) {
20770
- const decl = node.declaration;
20771
- if (decl.type === "VariableDeclaration") {
20772
- const declName = decl.declarations[0]?.id?.name;
20773
- if (declName === "standalone") {
20774
- continue;
21063
+ let inner = node;
21064
+ let exported = false;
21065
+ let defaultExport = false;
21066
+ if (node.type === "ExportNamedDeclaration" && node.declaration) {
21067
+ inner = node.declaration;
21068
+ exported = true;
21069
+ } else if (node.type === "ExportDefaultDeclaration" && node.declaration) {
21070
+ inner = node.declaration;
21071
+ exported = true;
21072
+ defaultExport = true;
21073
+ }
21074
+ if (inner.type === "ComponentDeclaration") {
21075
+ } else if (inner.type === "ClassDeclaration") {
21076
+ const { line, column } = offsetToLineCol2(source, inner.start ?? 0);
21077
+ throw VeskError.classDecl({ file, line, column, code: codeFrame(source, line, column) });
21078
+ } else if (inner.type === "TSEnumDeclaration") {
21079
+ const code = processEnum(inner, source, exported);
21080
+ topLevelCode.push(code);
21081
+ continue;
21082
+ } else {
21083
+ topLevelCode.push(getSource(source, node));
21084
+ continue;
21085
+ }
21086
+ const name = inner.id.name;
21087
+ const paramNames = getParamNames(inner.params, source);
21088
+ const firstParam = inner.params?.[0];
21089
+ const propsAlias = firstParam && firstParam.type === "Identifier" ? firstParam.name : null;
21090
+ const propsType = getPropsType(inner.params, source);
21091
+ const bodyStmts = inner.body.body;
21092
+ const isClientComp = !!inner.client;
21093
+ const prevSlotProps = __slotProps;
21094
+ __slotProps = slotPropNamesFromType(propsType);
21095
+ __propsParam = propsAlias || null;
21096
+ if (isStatementMode(bodyStmts)) {
21097
+ const raw2 = processStatementModeBody(source, bodyStmts, file);
21098
+ const { body, css } = extractStyle(raw2);
21099
+ validateBlocks(name, isClientComp, body, file, source);
21100
+ const comp = new ComponentIR(name, paramNames, body, { mode: "statement", exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
21101
+ comp.style = css;
21102
+ components.push(comp);
21103
+ __slotProps = prevSlotProps;
21104
+ } else {
21105
+ const guardClauses = [];
21106
+ let mainReturn = null;
21107
+ const preamble = [];
21108
+ for (const stmt of bodyStmts) {
21109
+ if (stmt.type === "VeskBlock") {
21110
+ const innerBody = processStatementModeBody(source, stmt.body, file);
21111
+ if (stmt.tag === "server") {
21112
+ preamble.push(new ServerBlock(innerBody));
21113
+ } else if (stmt.tag === "client") {
21114
+ preamble.push(new ClientBlock(innerBody));
21115
+ }
21116
+ } else if (stmt.type === "ReturnStatement") {
21117
+ mainReturn = stmt;
21118
+ } else if (isTrackDeclaration(stmt)) {
21119
+ const elements = stmt.declarations[0].id.elements;
21120
+ const trackName = elements[0]?.name;
21121
+ const rawName = elements.length > 1 ? elements[1]?.name : null;
21122
+ const init = getSource(source, stmt.declarations[0].init);
21123
+ if (trackName) preamble.push(new TrackDecl(trackName, init, rawName));
21124
+ const refName = getComponentRefName(stmt);
21125
+ if (refName) preamble.push(new ComponentRef(refName));
21126
+ } else if (stmt.type === "IfStatement" && !mainReturn && stmt.consequent.type !== "ThrowStatement") {
21127
+ guardClauses.push(stmt);
21128
+ } else if (stmt.type === "ClassDeclaration") {
21129
+ const { line, column } = offsetToLineCol2(source, stmt.start ?? 0);
21130
+ throw VeskError.classDecl({ file, line, column, code: codeFrame(source, line, column) });
21131
+ } else {
21132
+ const raw2 = getSource(source, stmt);
21133
+ if (raw2) preamble.push(new RuntimeStatement(raw2, stmt, source));
21134
+ }
20775
21135
  }
21136
+ const guardBody = buildGuardChain(source, guardClauses, mainReturn);
21137
+ const { body, css } = extractStyle([...preamble, ...guardBody]);
21138
+ validateBlocks(name, isClientComp, body, file, source);
21139
+ const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
21140
+ comp.style = css;
21141
+ components.push(comp);
21142
+ __slotProps = prevSlotProps;
20776
21143
  }
20777
21144
  }
20778
- let inner = node;
20779
- let exported = false;
20780
- let defaultExport = false;
20781
- if (node.type === "ExportNamedDeclaration" && node.declaration) {
20782
- inner = node.declaration;
20783
- exported = true;
20784
- } else if (node.type === "ExportDefaultDeclaration" && node.declaration) {
20785
- inner = node.declaration;
20786
- exported = true;
20787
- defaultExport = true;
20788
- }
20789
- if (inner.type === "ComponentDeclaration") {
20790
- } else if (inner.type === "ClassDeclaration") {
20791
- const { line, column } = offsetToLineCol2(source, inner.start ?? 0);
20792
- throw VeskError.classDecl({ file, line, column, code: codeFrame(source, line, column) });
20793
- } else if (inner.type === "TSEnumDeclaration") {
20794
- const code = processEnum(inner, source, exported);
20795
- topLevelCode.push(code);
20796
- continue;
20797
- } else {
20798
- topLevelCode.push(getSource(source, node));
20799
- continue;
20800
- }
20801
- const name = inner.id.name;
20802
- const paramNames = getParamNames(inner.params, source);
20803
- const firstParam = inner.params?.[0];
20804
- const propsAlias = firstParam && firstParam.type === "Identifier" ? firstParam.name : null;
20805
- const propsType = getPropsType(inner.params, source);
20806
- const bodyStmts = inner.body.body;
20807
- const isClientComp = !!inner.client;
20808
- const prevSlotProps = __slotProps;
20809
- __slotProps = slotPropNamesFromType(propsType);
20810
- __propsParam = propsAlias || null;
20811
- if (isStatementMode(bodyStmts)) {
20812
- const raw2 = processStatementModeBody(source, bodyStmts, file);
20813
- const { body, css } = extractStyle(raw2);
20814
- validateBlocks(name, isClientComp, body, file, source);
20815
- const comp = new ComponentIR(name, paramNames, body, { mode: "statement", exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
20816
- comp.style = css;
20817
- components.push(comp);
20818
- __slotProps = prevSlotProps;
20819
- } else {
20820
- const guardClauses = [];
20821
- let mainReturn = null;
20822
- const preamble = [];
20823
- for (const stmt of bodyStmts) {
20824
- if (stmt.type === "VeskBlock") {
20825
- const innerBody = processStatementModeBody(source, stmt.body, file);
20826
- if (stmt.tag === "server") {
20827
- preamble.push(new ServerBlock(innerBody));
20828
- } else if (stmt.tag === "client") {
20829
- preamble.push(new ClientBlock(innerBody));
20830
- }
20831
- } else if (stmt.type === "ReturnStatement") {
20832
- mainReturn = stmt;
20833
- } else if (isTrackDeclaration(stmt)) {
20834
- const elements = stmt.declarations[0].id.elements;
20835
- const trackName = elements[0]?.name;
20836
- const rawName = elements.length > 1 ? elements[1]?.name : null;
20837
- const init = getSource(source, stmt.declarations[0].init);
20838
- if (trackName) preamble.push(new TrackDecl(trackName, init, rawName));
20839
- const refName = getComponentRefName(stmt);
20840
- if (refName) preamble.push(new ComponentRef(refName));
20841
- } else if (stmt.type === "IfStatement" && !mainReturn && stmt.consequent.type !== "ThrowStatement") {
20842
- guardClauses.push(stmt);
20843
- } else if (stmt.type === "ClassDeclaration") {
20844
- const { line, column } = offsetToLineCol2(source, stmt.start ?? 0);
20845
- throw VeskError.classDecl({ file, line, column, code: codeFrame(source, line, column) });
20846
- } else {
20847
- const raw2 = getSource(source, stmt);
20848
- if (raw2) preamble.push(new RuntimeStatement(raw2, stmt, source));
20849
- }
20850
- }
20851
- const guardBody = buildGuardChain(source, guardClauses, mainReturn);
20852
- const { body, css } = extractStyle([...preamble, ...guardBody]);
20853
- validateBlocks(name, isClientComp, body, file, source);
20854
- const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
20855
- comp.style = css;
20856
- components.push(comp);
20857
- __slotProps = prevSlotProps;
20858
- }
20859
- }
20860
- const asyncNames = new Set(components.filter((c) => c.isAsync || c.ssrAwait).map((c) => c.name));
20861
- for (const comp of components) {
20862
- if (asyncNames.has(comp.name)) continue;
20863
- const called2 = /* @__PURE__ */ new Map();
20864
- collectComponentCalls(comp.body, called2);
20865
- for (const [childName, start] of called2) {
20866
- if (!asyncNames.has(childName)) continue;
20867
- const { line, column } = offsetToLineCol2(source, start >= 0 ? start : 0);
20868
- throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column, code: codeFrame(source, line, column) });
20869
- }
20870
- }
20871
- const autoImportable = [
20872
- "useFetch",
20873
- "useRouter",
20874
- "useParams",
20875
- "usePathname",
20876
- "useSearchParams",
20877
- "useNavigate",
20878
- "defineAction",
20879
- "Form",
20880
- "Field",
20881
- "required",
20882
- "email",
20883
- "minLength",
20884
- "maxLength",
20885
- "pattern",
20886
- "custom",
20887
- "Link",
20888
- "NavLink",
20889
- "Outlet",
20890
- "Redirect",
20891
- "Image",
20892
- "Portal",
20893
- "Experiment",
20894
- "LoadingIndicator",
20895
- "useLoadingIndicator",
20896
- "JsonLd",
20897
- "ArticleSchema",
20898
- "ProductSchema",
20899
- "FAQPageSchema",
20900
- "BreadcrumbListSchema",
20901
- "OrganizationSchema",
20902
- "LocalBusinessSchema",
20903
- "VideoSchema",
20904
- "effect",
20905
- "derived",
20906
- "untrack",
20907
- "peek",
20908
- "tick",
20909
- "flushSync",
20910
- "on_destroy",
20911
- "createContext",
20912
- "redirect",
20913
- "permanentRedirect",
20914
- "notFound",
20915
- "NotFoundError",
20916
- "createResource",
20917
- "getAction",
20918
- "validateActionInput",
20919
- "issuesToFieldMap",
20920
- "isFormAction",
20921
- "Show",
20922
- "For",
20923
- "Switch",
20924
- "Match"
20925
- ];
20926
- const called = collectCallAndJsxTargets(ast);
20927
- const usedFunctions = /* @__PURE__ */ new Set();
20928
- for (const fn of autoImportable) {
20929
- if (called.has(fn)) usedFunctions.add(fn);
20930
- }
20931
- if (usedFunctions.size > 0) {
20932
- const existing = /* @__PURE__ */ new Set();
20933
- for (const imp of imports) {
20934
- if (importModuleTarget(imp) !== "@vesk/runtime") continue;
20935
- for (const n of extractImportNames(imp)) existing.add(n);
21145
+ const asyncNames = new Set(components.filter((c) => c.isAsync || c.ssrAwait).map((c) => c.name));
21146
+ for (const comp of components) {
21147
+ if (asyncNames.has(comp.name)) continue;
21148
+ const called2 = /* @__PURE__ */ new Map();
21149
+ collectComponentCalls(comp.body, called2);
21150
+ for (const [childName, start] of called2) {
21151
+ if (!asyncNames.has(childName)) continue;
21152
+ const { line, column } = offsetToLineCol2(source, start >= 0 ? start : 0);
21153
+ throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column, code: codeFrame(source, line, column) });
21154
+ }
20936
21155
  }
20937
- const boundLocally = /* @__PURE__ */ new Set();
20938
- for (const imp of imports) {
20939
- for (const pair of importBindingPairs(imp)) boundLocally.add(pair.local);
21156
+ const autoImportable = [
21157
+ "useFetch",
21158
+ "useRouter",
21159
+ "useParams",
21160
+ "usePathname",
21161
+ "useSearchParams",
21162
+ "useNavigate",
21163
+ "defineAction",
21164
+ "Form",
21165
+ "Field",
21166
+ "required",
21167
+ "email",
21168
+ "minLength",
21169
+ "maxLength",
21170
+ "pattern",
21171
+ "custom",
21172
+ "Link",
21173
+ "NavLink",
21174
+ "Outlet",
21175
+ "Redirect",
21176
+ "Image",
21177
+ "Portal",
21178
+ "Experiment",
21179
+ "LoadingIndicator",
21180
+ "useLoadingIndicator",
21181
+ "JsonLd",
21182
+ "ArticleSchema",
21183
+ "ProductSchema",
21184
+ "FAQPageSchema",
21185
+ "BreadcrumbListSchema",
21186
+ "OrganizationSchema",
21187
+ "LocalBusinessSchema",
21188
+ "VideoSchema",
21189
+ "effect",
21190
+ "derived",
21191
+ "untrack",
21192
+ "peek",
21193
+ "tick",
21194
+ "flushSync",
21195
+ "on_destroy",
21196
+ "createContext",
21197
+ "redirect",
21198
+ "permanentRedirect",
21199
+ "notFound",
21200
+ "NotFoundError",
21201
+ "createResource",
21202
+ "getAction",
21203
+ "validateActionInput",
21204
+ "issuesToFieldMap",
21205
+ "isFormAction",
21206
+ "Show",
21207
+ "For",
21208
+ "Switch",
21209
+ "Match",
21210
+ "primitive",
21211
+ "leaf"
21212
+ ];
21213
+ const called = collectCallAndJsxTargets(ast);
21214
+ const usedFunctions = /* @__PURE__ */ new Set();
21215
+ for (const fn of autoImportable) {
21216
+ if (called.has(fn)) usedFunctions.add(fn);
20940
21217
  }
20941
- const missing = [...usedFunctions].filter((f) => !existing.has(f) && !boundLocally.has(f));
20942
- if (missing.length > 0) {
20943
- imports.push(`import { ${missing.join(", ")} } from '@vesk/runtime';`);
21218
+ if (usedFunctions.size > 0) {
21219
+ const existing = /* @__PURE__ */ new Set();
21220
+ for (const imp of imports) {
21221
+ if (importModuleTarget(imp) !== "@vesk/runtime") continue;
21222
+ for (const n of extractImportNames(imp)) existing.add(n);
21223
+ }
21224
+ const boundLocally = /* @__PURE__ */ new Set();
21225
+ for (const imp of imports) {
21226
+ for (const pair of importBindingPairs(imp)) boundLocally.add(pair.local);
21227
+ }
21228
+ const missing = [...usedFunctions].filter((f) => !existing.has(f) && !boundLocally.has(f));
21229
+ if (missing.length > 0) {
21230
+ imports.push(`import { ${missing.join(", ")} } from '@vesk/runtime';`);
21231
+ }
20944
21232
  }
21233
+ return new IRRoot(components, imports, importedNames, staticProps, loadFn, topLevelCode, exportAliases, reexportSources);
21234
+ } finally {
21235
+ currentVskNamespaceLocals = prevNamespaceLocals;
21236
+ currentSourceFile = prevSourceFile;
20945
21237
  }
20946
- return new IRRoot(components, imports, importedNames, staticProps, loadFn, topLevelCode);
20947
21238
  }
20948
- var __vskAnnotations, __slotProps, __propsParam;
21239
+ var __vskAnnotations, __slotProps, __propsParam, currentVskNamespaceLocals, currentSourceFile;
20949
21240
  var init_ir_generator = __esm({
20950
21241
  "../compiler/src/ir-generator.ts"() {
20951
21242
  "use strict";
@@ -20960,6 +21251,7 @@ var init_ir_generator = __esm({
20960
21251
  __vskAnnotations = [];
20961
21252
  __slotProps = null;
20962
21253
  __propsParam = null;
21254
+ currentVskNamespaceLocals = null;
20963
21255
  }
20964
21256
  });
20965
21257
 
@@ -21853,6 +22145,13 @@ function loadRuntimeImports(importStrs) {
21853
22145
  }
21854
22146
  return {};
21855
22147
  }
22148
+ function patternElementName(element) {
22149
+ if (!element) return null;
22150
+ if (element.type === "Identifier") return element.name;
22151
+ if (element.type === "AssignmentPattern" && element.left) return patternElementName(element.left);
22152
+ if (element.type === "RestElement" && element.argument) return patternElementName(element.argument);
22153
+ return null;
22154
+ }
21856
22155
  function evalTopLevelCode(topLevelCode, __vesk) {
21857
22156
  for (const code of topLevelCode) {
21858
22157
  const ast = tryParseTopLevel(code);
@@ -21863,8 +22162,11 @@ function evalTopLevelCode(topLevelCode, __vesk) {
21863
22162
  if (!target) continue;
21864
22163
  if (target.type === "VariableDeclaration") {
21865
22164
  for (const d of target.declarations) {
21866
- if (!d.id || d.id.type !== "Identifier") continue;
21867
- const initSrc = d.init ? code.slice(d.init.start, d.init.end) : "undefined";
22165
+ if (!d.id) continue;
22166
+ const isTrack = d.id.type === "ArrayPattern" && d.id.lazy === true;
22167
+ const names = isTrack ? (d.id.elements || []).map(patternElementName) : d.id.type === "Identifier" ? [d.id.name] : [];
22168
+ if (names.every((n) => n === null)) continue;
22169
+ const initSrc = d.init ? stripTrackDeclMarkers(code.slice(d.init.start, d.init.end), d.init.start, d.init) : "undefined";
21868
22170
  try {
21869
22171
  const keys = Object.keys(__vesk);
21870
22172
  const params = [...keys, "__vesk", "result"];
@@ -21872,7 +22174,10 @@ function evalTopLevelCode(topLevelCode, __vesk) {
21872
22174
  const fn = new Function(...params, body);
21873
22175
  const result = { value: void 0 };
21874
22176
  fn(...keys.map((k) => __vesk[k]), __vesk, result);
21875
- __vesk[d.id.name] = result.value;
22177
+ names.forEach((name, i) => {
22178
+ if (name === null) return;
22179
+ __vesk[name] = isTrack ? Array.isArray(result.value) ? result.value[i] : void 0 : result.value;
22180
+ });
21876
22181
  } catch {
21877
22182
  }
21878
22183
  }
@@ -21882,7 +22187,7 @@ function evalTopLevelCode(topLevelCode, __vesk) {
21882
22187
  const keys = Object.keys(__vesk);
21883
22188
  const params = [...keys, "__vesk"];
21884
22189
  const paramSrc = target.params.length ? code.slice(target.params[0].start, target.params[target.params.length - 1].end) : "";
21885
- const bodySrc = code.slice(target.body.start, target.body.end);
22190
+ const bodySrc = stripTrackDeclMarkers(code.slice(target.body.start, target.body.end), target.body.start, target.body);
21886
22191
  const asyncKw = target.async ? "async " : "";
21887
22192
  const fn = new Function(...params, `__vesk['${target.id.name}'] = ${asyncKw}function ${target.id.name}(${paramSrc}) ${bodySrc};`);
21888
22193
  fn(...keys.map((k) => __vesk[k]), __vesk);
@@ -25830,6 +26135,96 @@ var init_headless = __esm({
25830
26135
  }
25831
26136
  });
25832
26137
 
26138
+ // ../runtime/src/primitive.ts
26139
+ function primitive(fn) {
26140
+ const wrapped = ((props, registry, scope2) => {
26141
+ return fn(props == null ? EMPTY_PROPS : props, registry, scope2);
26142
+ });
26143
+ wrapped.__veskPrimitive = true;
26144
+ return wrapped;
26145
+ }
26146
+ function leaf(fn) {
26147
+ fn.__veskLeaf = true;
26148
+ return fn;
26149
+ }
26150
+ function isPrimitive(value) {
26151
+ return typeof value === "function" && value.__veskPrimitive === true;
26152
+ }
26153
+ function isLeaf(value) {
26154
+ return typeof value === "function" && value.__veskLeaf === true;
26155
+ }
26156
+ function isVeskComponent(value) {
26157
+ return typeof value === "function";
26158
+ }
26159
+ function toDomNode(value) {
26160
+ if (typeof document === "undefined") return value;
26161
+ if (value == null || typeof value === "boolean") return value;
26162
+ if (typeof value.nodeType === "number") {
26163
+ return value;
26164
+ }
26165
+ if (typeof value !== "string") return value;
26166
+ if (value === "") return document.createDocumentFragment();
26167
+ const template = document.createElement("template");
26168
+ template.innerHTML = value;
26169
+ const { content } = template;
26170
+ if (content.childNodes.length === 1) {
26171
+ const only = content.firstChild;
26172
+ content.removeChild(only);
26173
+ return only;
26174
+ }
26175
+ return content;
26176
+ }
26177
+ function isCell2(value) {
26178
+ return typeof value === "object" && value !== null && typeof value.f === "number";
26179
+ }
26180
+ function readDep(dep) {
26181
+ return isCell2(dep) ? get(dep) : dep;
26182
+ }
26183
+ function rerenderNode(node, deps, call) {
26184
+ if (typeof document === "undefined") return node;
26185
+ if (deps.length === 0) return node;
26186
+ let owned = null;
26187
+ let current2 = null;
26188
+ if (Array.isArray(node)) {
26189
+ const roots = node.filter((n) => n && typeof n.nodeType === "number");
26190
+ owned = roots.length ? roots : null;
26191
+ current2 = owned ? owned[0] : null;
26192
+ } else if (node && typeof node.nodeType === "number") {
26193
+ current2 = node;
26194
+ }
26195
+ if (!current2) return node;
26196
+ const liveRange = () => {
26197
+ if (owned) return owned;
26198
+ return current2 && current2.parentNode ? [current2] : null;
26199
+ };
26200
+ let seen = deps.map(readDep);
26201
+ effect(() => {
26202
+ const now2 = deps.map(readDep);
26203
+ if (now2.length === seen.length && now2.every((v, i) => Object.is(v, seen[i]))) return;
26204
+ seen = now2;
26205
+ const old = liveRange();
26206
+ if (!old || !old[0].parentNode) return;
26207
+ const next = toDomNode(call());
26208
+ if (!next || typeof next.nodeType !== "number") return;
26209
+ const fresh = next.nodeType === 11 ? Array.from(next.childNodes) : [next];
26210
+ const parent = old[0].parentNode;
26211
+ for (const freshNode of fresh) parent.insertBefore(freshNode, old[0]);
26212
+ for (const oldNode of old) if (oldNode.parentNode) oldNode.parentNode.removeChild(oldNode);
26213
+ owned = next.nodeType === 11 ? fresh : null;
26214
+ current2 = fresh[0] ?? current2;
26215
+ });
26216
+ return node;
26217
+ }
26218
+ var EMPTY_PROPS;
26219
+ var init_primitive = __esm({
26220
+ "../runtime/src/primitive.ts"() {
26221
+ "use strict";
26222
+ init_ripple_runtime();
26223
+ init_ripple_blocks();
26224
+ EMPTY_PROPS = Object.freeze({});
26225
+ }
26226
+ });
26227
+
25833
26228
  // ../runtime/src/action.ts
25834
26229
  function getActionRegistry() {
25835
26230
  const g2 = globalThis;
@@ -25983,11 +26378,15 @@ __export(index_server_exports, {
25983
26378
  get_server_context: () => get_server_context,
25984
26379
  headers: () => headers,
25985
26380
  isFormAction: () => isFormAction,
26381
+ isLeaf: () => isLeaf,
25986
26382
  isLoadingActive: () => isLoadingActive,
26383
+ isPrimitive: () => isPrimitive,
26384
+ isVeskComponent: () => isVeskComponent,
25987
26385
  is_destroyed: () => is_destroyed,
25988
26386
  isr: () => isr,
25989
26387
  isrConfigToRevalidate: () => isrConfigToRevalidate,
25990
26388
  issuesToFieldMap: () => issuesToFieldMap,
26389
+ leaf: () => leaf,
25991
26390
  locals: () => locals,
25992
26391
  maxLength: () => maxLength,
25993
26392
  minLength: () => minLength,
@@ -26001,12 +26400,14 @@ __export(index_server_exports, {
26001
26400
  permanentRedirect: () => permanentRedirect,
26002
26401
  pop_component: () => pop_component,
26003
26402
  pre_effect: () => pre_effect,
26403
+ primitive: () => primitive,
26004
26404
  push_component: () => push_component,
26005
26405
  readSignedCookie: () => readSignedCookie2,
26006
26406
  redirect: () => redirect,
26007
26407
  removeHook: () => removeHook,
26008
26408
  render: () => render,
26009
26409
  required: () => required,
26410
+ rerenderNode: () => rerenderNode,
26010
26411
  resolveSsrResources: () => resolveSsrResources,
26011
26412
  resume_block: () => resume_block,
26012
26413
  revalidateComponent: () => revalidateComponent,
@@ -26030,6 +26431,7 @@ __export(index_server_exports, {
26030
26431
  set_server_context: () => set_server_context,
26031
26432
  signCookie: () => signCookie2,
26032
26433
  tick: () => tick,
26434
+ toDomNode: () => toDomNode,
26033
26435
  track: () => track,
26034
26436
  unlink_block: () => unlink_block,
26035
26437
  unsignCookie: () => unsignCookie2,
@@ -26068,6 +26470,7 @@ var init_index_server = __esm({
26068
26470
  init_form();
26069
26471
  init_md();
26070
26472
  init_headless();
26473
+ init_primitive();
26071
26474
  init_loading_indicator();
26072
26475
  init_action();
26073
26476
  }
@@ -28497,11 +28900,20 @@ function printWithTypesStripped(ast, code, hadTs = hasTsSyntax(ast)) {
28497
28900
  function transformTopLevelForActions(topLevelCode, mode) {
28498
28901
  const out = [];
28499
28902
  for (const c of topLevelCode) {
28500
- const rewritten = rewriteTopLevelActions(c, mode);
28903
+ const rewritten = rewriteTopLevelActions(stripTopLevelTrackDecls(c), mode);
28501
28904
  if (rewritten !== "") out.push(rewritten);
28502
28905
  }
28503
28906
  return out;
28504
28907
  }
28908
+ function stripTopLevelTrackDecls(code) {
28909
+ let ast;
28910
+ try {
28911
+ ast = parse4(code);
28912
+ } catch {
28913
+ return code;
28914
+ }
28915
+ return stripTrackDeclMarkers(code, 0, ast);
28916
+ }
28505
28917
  function collectActionIds(source) {
28506
28918
  const ids = [];
28507
28919
  const stmts = collectTopLevelStatements(source);
@@ -28557,6 +28969,7 @@ var init_actions = __esm({
28557
28969
  "use strict";
28558
28970
  init_parser();
28559
28971
  init_strip_ts();
28972
+ init_tokens();
28560
28973
  ACTION_PREFIX = "/_vesk/action/";
28561
28974
  }
28562
28975
  });
@@ -28684,6 +29097,39 @@ function simpleGetName(expr) {
28684
29097
  }
28685
29098
  return inner;
28686
29099
  }
29100
+ function untrackBindingArg(expr) {
29101
+ let head = -1;
29102
+ for (const name of BINDING_REF_CALLS) {
29103
+ if (expr.startsWith(`${name}(`)) {
29104
+ head = name.length;
29105
+ break;
29106
+ }
29107
+ }
29108
+ if (head < 0) return expr;
29109
+ const rest = expr.slice(head + 1);
29110
+ if (rest[0] !== "g" || rest[1] !== "e" || rest[2] !== "t" || rest[3] !== "(") return expr;
29111
+ let i = 4;
29112
+ let word = "";
29113
+ for (; i < rest.length; i++) {
29114
+ const c = rest.charCodeAt(i);
29115
+ const ok = c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95 || c === 36;
29116
+ if (!ok) break;
29117
+ word += rest[i];
29118
+ }
29119
+ if (word.length === 0 || rest[i] !== ")") return expr;
29120
+ const after = i + 1;
29121
+ if (rest[after] !== "," && rest[after] !== ")") return expr;
29122
+ return expr.slice(0, head + 1) + word + rest.slice(after);
29123
+ }
29124
+ function trackedRefTarget(expr, tracked2) {
29125
+ const cell = simpleGetName(expr);
29126
+ if (cell !== null) return cell;
29127
+ if (/^[A-Za-z_$][\w$]*$/.test(expr)) {
29128
+ const info = tracked2.get(expr);
29129
+ if (info && info.kind === "cell" && info.cellName === expr) return expr;
29130
+ }
29131
+ return null;
29132
+ }
28687
29133
  function semicolonizeStatement(code) {
28688
29134
  const trimmed = code.trimEnd();
28689
29135
  if (!trimmed || trimmed.endsWith(";") || trimmed.endsWith("}")) return code;
@@ -28782,6 +29228,21 @@ function transformTracked(irNode, tracked2) {
28782
29228
  }
28783
29229
  return context.next();
28784
29230
  },
29231
+ Property(node, context) {
29232
+ if (node.shorthand && node.value && node.value.type === "Identifier" && !node.computed) {
29233
+ const info = context.state.get(node.value.name);
29234
+ if (info && info.kind === "virtual") {
29235
+ return {
29236
+ ...node,
29237
+ shorthand: false,
29238
+ value: callExpr({ type: "Identifier", name: "get" }, [
29239
+ { type: "Identifier", name: info.cellName }
29240
+ ])
29241
+ };
29242
+ }
29243
+ }
29244
+ return context.next();
29245
+ },
28785
29246
  Identifier(node, context) {
28786
29247
  const parent = context.path.at(-1);
28787
29248
  if (parent) {
@@ -28793,6 +29254,8 @@ function transformTracked(irNode, tracked2) {
28793
29254
  return context.next();
28794
29255
  if (parent.type === "Property" && parent.value === node && parent.key && parent.key.type === "Identifier" && parent.key.name === "into")
28795
29256
  return context.next();
29257
+ if (parent.type === "Property" && parent.key === node && !parent.computed && !parent.shorthand)
29258
+ return context.next();
28796
29259
  if (parent.type === "MemberExpression" && !parent.computed && parent.object === node && parent.property && parent.property.type === "Identifier" && parent.property.name === "set")
28797
29260
  return context.next();
28798
29261
  }
@@ -28819,6 +29282,28 @@ function collectTrackedNames(body) {
28819
29282
  }
28820
29283
  return names;
28821
29284
  }
29285
+ function collectTrackedDeps(value, tracked2) {
29286
+ const ast = value?.ast;
29287
+ if (!ast || typeof ast !== "object" || tracked2.size === 0) return [];
29288
+ const found = [];
29289
+ const seen = /* @__PURE__ */ new Set();
29290
+ walk4(ast, tracked2, {
29291
+ Identifier(node, context) {
29292
+ const parent = context.path.at(-1);
29293
+ if (parent) {
29294
+ if (parent.type === "MemberExpression" && !parent.computed && parent.property === node) return context.next();
29295
+ if (parent.type === "Property" && parent.key === node) return context.next();
29296
+ }
29297
+ const info = context.state.get(node.name);
29298
+ if (info && !seen.has(node.name)) {
29299
+ seen.add(node.name);
29300
+ found.push(node.name);
29301
+ }
29302
+ return context.next();
29303
+ }
29304
+ });
29305
+ return found;
29306
+ }
28822
29307
  function transformTrackedInit(init, tracked2) {
28823
29308
  if (!init) return init;
28824
29309
  let expr = null;
@@ -29012,8 +29497,9 @@ function emitStatic(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
29012
29497
  const target = attr.target || "";
29013
29498
  const isEvent2 = target.startsWith("on") && target.length > 2;
29014
29499
  if (target === "ref") {
29015
- const expr = transformTracked(attr.expression, tracked2);
29016
- ctx2.push(`(${expr})(${ssrEl});`);
29500
+ const expr = untrackBindingArg(transformTracked(attr.expression, tracked2));
29501
+ const cell = trackedRefTarget(expr, tracked2);
29502
+ ctx2.push(cell !== null ? `set(${cell}, ${ssrEl});` : `(${expr})(${ssrEl});`);
29017
29503
  } else if (isEvent2) {
29018
29504
  const eventName = target.slice(2).toLowerCase();
29019
29505
  const handler = transformTracked(attr.expression, tracked2);
@@ -29070,8 +29556,9 @@ function emitStatic(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget) {
29070
29556
  const target = attr.target || "";
29071
29557
  const isEvent2 = target.startsWith("on") && target.length > 2;
29072
29558
  if (target === "ref") {
29073
- const expr = transformTracked(attr.expression, tracked2);
29074
- ctx2.push(`(${expr})(${el});`);
29559
+ const expr = untrackBindingArg(transformTracked(attr.expression, tracked2));
29560
+ const cell = trackedRefTarget(expr, tracked2);
29561
+ ctx2.push(cell !== null ? `set(${cell}, ${el});` : `(${expr})(${el});`);
29075
29562
  } else if (isEvent2) {
29076
29563
  const eventName = target.slice(2).toLowerCase();
29077
29564
  const handler = transformTracked(attr.expression, tracked2);
@@ -29265,19 +29752,29 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
29265
29752
  const calleeExpr = node.calleeExpr ? `(${node.calleeExpr})` : null;
29266
29753
  const slotChildren = node.children.filter((c) => c instanceof PropSlot);
29267
29754
  const regChildren = node.children.filter((c) => !(c instanceof PropSlot));
29268
- const callArgs = () => `{ ${propsEntries.join(", ")} }`;
29755
+ const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
29756
+ const trackedDeps = [];
29757
+ if (plainTarget) {
29758
+ for (const p of node.props) {
29759
+ if (typeof p.value === "string") continue;
29760
+ for (const d of collectTrackedDeps(p.value, tracked2)) if (!trackedDeps.includes(d)) trackedDeps.push(d);
29761
+ }
29762
+ for (const sp of node.spreadProps) {
29763
+ for (const d of collectTrackedDeps(sp, tracked2)) if (!trackedDeps.includes(d)) trackedDeps.push(d);
29764
+ }
29765
+ }
29766
+ const callArgs = () => plainTarget ? `reactiveProps({ ${propsEntries.join(", ")} })` : `{ ${propsEntries.join(", ")} }`;
29269
29767
  if (ctx2.hydrate) {
29270
29768
  const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `__components[${JSON.stringify(node.componentName)}]`);
29271
29769
  if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
29272
29770
  ctx2.push(`if (${access} == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
29273
29771
  }
29274
- const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
29275
29772
  const walkerArg = ctx2.walker;
29276
29773
  const promptExpr = ctx2.markerless && (regionBudget || skipK > 0) ? markerlessSkipExpr(regionBudget, skipK) : null;
29277
29774
  const maybeReplace = (v2) => {
29278
29775
  if (!plainTarget) return;
29279
29776
  const claim = promptExpr ? `${walkerArg}.claimOnly(undefined, ${promptExpr})` : `${walkerArg}.claimOnly()`;
29280
- ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
29777
+ ctx2.push(`if (${v2} && ${v2}.parentNode == null) { if (${v2}.nodeType === 11) { const __cnt = ${v2}.childNodes.length; let __sr = null; for (let __i = 0; __i < __cnt; __i++) { const __c = ${claim}; if (__c && __c.parentNode) { if (__sr) { __c.remove(); } else { __sr = __c; } } } if (__sr) { const __p = __sr.parentNode; while (${v2}.firstChild) __p.insertBefore(${v2}.firstChild, __sr); __p.removeChild(__sr); } } else { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); } }`);
29281
29778
  if (regionBudget && ctx2.markerless) ctx2.push(`${regionBudget} = 0;`);
29282
29779
  };
29283
29780
  const maybeRetire = () => {
@@ -29312,10 +29809,15 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
29312
29809
  }
29313
29810
  ctx2.push(`let ${v} = undefined;`);
29314
29811
  ctx2.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
29315
- ctx2.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
29812
+ ctx2.push(`try { ${v} = toDomNode(${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg})); } finally { if (__hydrate) __hydrate.childFrame--; }`);
29813
+ const rootsVar = trackedDeps.length > 0 ? ctx2.n() : null;
29814
+ if (rootsVar) ctx2.push(`const ${rootsVar} = ${v} && ${v}.nodeType === 11 ? Array.from(${v}.childNodes) : [${v}];`);
29316
29815
  if (ctx2.markerless && promptExpr && !plainTarget && regionBudget) ctx2.push(`${regionBudget} = 0;`);
29317
29816
  maybeReplace(v);
29318
29817
  maybeRetire();
29818
+ if (trackedDeps.length > 0) {
29819
+ ctx2.push(`rerenderNode(${rootsVar}, [${trackedDeps.join(", ")}], () => ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}));`);
29820
+ }
29319
29821
  return v;
29320
29822
  } else {
29321
29823
  for (const slot of slotChildren) {
@@ -29337,12 +29839,18 @@ function emitComponentCall(ctx2, node, tracked2, effectsVar, parentVar, compPref
29337
29839
  propsEntries.push(`children: ${frag}`);
29338
29840
  }
29339
29841
  if (calleeExpr) {
29340
- ctx2.push(`const ${v} = ${calleeExpr}(${callArgs()});`);
29842
+ ctx2.push(`const ${v} = toDomNode(${calleeExpr}(${callArgs()}));`);
29341
29843
  } else if (ctx2.importedNames.has(node.componentName)) {
29342
- ctx2.push(`const ${v} = ${awaitKw}${node.componentName}(${callArgs()});`);
29844
+ ctx2.push(`const ${v} = toDomNode(${awaitKw}${node.componentName}(${callArgs()}));`);
29343
29845
  } else {
29344
29846
  ctx2.push(`if (${compPrefix}[${JSON.stringify(node.componentName)}] == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
29345
- ctx2.push(`const ${v} = ${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()});`);
29847
+ ctx2.push(`const ${v} = toDomNode(${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()}));`);
29848
+ }
29849
+ if (trackedDeps.length > 0) {
29850
+ const calleeRef = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `${compPrefix}[${JSON.stringify(node.componentName)}]`);
29851
+ const rootsVar2 = ctx2.n();
29852
+ ctx2.push(`const ${rootsVar2} = ${v} && ${v}.nodeType === 11 ? Array.from(${v}.childNodes) : [${v}];`);
29853
+ ctx2.push(`rerenderNode(${rootsVar2}, [${trackedDeps.join(", ")}], () => ${awaitKw}${calleeRef}(${callArgs()}));`);
29346
29854
  }
29347
29855
  }
29348
29856
  return v;
@@ -30428,7 +30936,7 @@ function emitClientFromIR(ir, options) {
30428
30936
  }
30429
30937
  }
30430
30938
  const exportCode = exportLines.join("\n");
30431
- const runtimeNames = ["track", "get", "set", "destroy_block", "getActiveComponent", "setActiveComponent", "reactiveProps", "applyStyle"];
30939
+ const runtimeNames = ["track", "get", "set", "destroy_block", "getActiveComponent", "setActiveComponent", "reactiveProps", "applyStyle", "toDomNode", "rerenderNode"];
30432
30940
  if (ir.components.some((c) => !isStaticIR(c.body))) runtimeNames.push("effect");
30433
30941
  for (const name of usedRuntimeBindings(ir)) runtimeNames.push(name);
30434
30942
  for (const name of ["derived"]) {
@@ -30489,14 +30997,18 @@ function compileClientBoth(source, _componentName, sourcePath2, opts) {
30489
30997
  }
30490
30998
  const alloc = nameAllocFor(sourcePath2);
30491
30999
  const comp = emitClientFromIR(ir, { forceClient: true, nameAllocator: alloc });
30492
- if (opts?.skipHyd) return { comp, hyd: "", name };
31000
+ const aliases = vskRegistryAliases(ir.imports, ir.exportAliases);
31001
+ const reexportPaths = sourcePath2 ? collectVskReexportPaths(ir.reexportSources, sourcePath2) : [];
31002
+ if (opts?.skipHyd) return { comp, hyd: "", name, aliases, reexportPaths };
30493
31003
  return {
30494
31004
  comp,
30495
31005
  hyd: emitClientFromIR(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
30496
- name
31006
+ name,
31007
+ aliases,
31008
+ reexportPaths
30497
31009
  };
30498
31010
  }
30499
- var NON_BUBBLING_EVENTS, Ctx, PROPERTY_ATTRS;
31011
+ var BINDING_REF_CALLS, NON_BUBBLING_EVENTS, Ctx, PROPERTY_ATTRS;
30500
31012
  var init_client_codegen = __esm({
30501
31013
  "../compiler/src/client-codegen.ts"() {
30502
31014
  "use strict";
@@ -30508,8 +31020,10 @@ var init_client_codegen = __esm({
30508
31020
  init_module_imports();
30509
31021
  init_scan();
30510
31022
  init_tokens();
31023
+ init_vsk_imports();
30511
31024
  init_md_inline();
30512
31025
  init_strip_ts();
31026
+ BINDING_REF_CALLS = ["bindValue", "bindChecked", "bindGroup"];
30513
31027
  NON_BUBBLING_EVENTS = /* @__PURE__ */ new Set([
30514
31028
  "focus",
30515
31029
  "blur",
@@ -31045,7 +31559,8 @@ function buildComponentEntries(irRoot) {
31045
31559
  const importedNames = /* @__PURE__ */ new Set([...runtimeNames, ...localValueNames, ...topValueNames]);
31046
31560
  const hasTracked = irRoot.components.some((c) => c.body.some((n) => n instanceof TrackDecl));
31047
31561
  const extraNames = hasTracked ? ["get", "set", "track"] : [];
31048
- const allNames = [.../* @__PURE__ */ new Set([...runtimeNames, ...topNames, ...extraNames, ...localValueNames])];
31562
+ const vskValueNames = vskImportValueNames(irRoot.imports);
31563
+ const allNames = [.../* @__PURE__ */ new Set([...runtimeNames, ...topNames, ...extraNames, ...localValueNames, ...vskValueNames])];
31049
31564
  const scopeDecl = allNames.length > 0 ? `const { ${allNames.join(", ")} } = __vesk;
31050
31565
  ` : "";
31051
31566
  setVskImportedNames(importedNames);
@@ -31086,6 +31601,7 @@ var init_server_jsgen = __esm({
31086
31601
  init_scan();
31087
31602
  init_server_utils();
31088
31603
  init_module_imports();
31604
+ init_vsk_imports();
31089
31605
  __currentCompName = "";
31090
31606
  }
31091
31607
  });
@@ -31158,7 +31674,11 @@ function compileFileInternal(source, sourcePath2, seenImportFiles) {
31158
31674
  const __vesk = loadRuntimeImports(ir.imports);
31159
31675
  applyLocalModuleImports(__vesk, ir.imports, sourcePath2);
31160
31676
  if (sourcePath2) {
31161
- for (const importPath of collectVskImportPaths(ir.imports, sourcePath2)) {
31677
+ const vskPaths = [
31678
+ ...collectVskImportPaths(ir.imports, sourcePath2),
31679
+ ...collectVskReexportPaths(ir.reexportSources, sourcePath2)
31680
+ ];
31681
+ for (const importPath of vskPaths) {
31162
31682
  if (seenImportFiles.has(importPath)) continue;
31163
31683
  seenImportFiles.add(importPath);
31164
31684
  let importedSrc;
@@ -31178,6 +31698,7 @@ function compileFileInternal(source, sourcePath2, seenImportFiles) {
31178
31698
  }
31179
31699
  }
31180
31700
  evalTopLevelCode(transformTopLevelForActions(ir.topLevelCode, "server"), __vesk);
31701
+ applyVskRegistryAliases(componentMap, vskRegistryAliases(ir.imports, ir.exportAliases));
31181
31702
  for (const name of ownComponentNames) {
31182
31703
  const fn = componentMap.get(name);
31183
31704
  if (fn && !fn.__veskScope) fn.__veskScope = __vesk;
@@ -34147,7 +34668,7 @@ function unwrapMaybeCell2(v) {
34147
34668
  }
34148
34669
  return v;
34149
34670
  }
34150
- function isCell2(v) {
34671
+ function isCell3(v) {
34151
34672
  return v !== null && typeof v === "object" && typeof v.get === "function";
34152
34673
  }
34153
34674
  function escapeHtml7(s) {
@@ -36152,7 +36673,7 @@ function Md2(props, _registry, hydrate) {
36152
36673
  if (propFg && propFg !== "none")
36153
36674
  wrapperParts.push(`--md-code-fg:${propFg}`);
36154
36675
  const wrapperStyle = wrapperParts.length > 0 ? escapeHtml7(wrapperParts.join(";")) : "";
36155
- const reactive = isCell2(contentCell);
36676
+ const reactive = isCell3(contentCell);
36156
36677
  const pathMode = isPublicMarkdownPath2(content);
36157
36678
  if (mdIsSSR2()) {
36158
36679
  const attrs = className ? ` class="${escapeHtml7(className)}"` : "";
@@ -36813,6 +37334,21 @@ var init_errors2 = __esm({
36813
37334
  tip: isBuiltin ? `"${name}" is a Vesk built-in. Use it directly \u2014 no manual import needed.` : ""
36814
37335
  });
36815
37336
  }
37337
+ static vskNamespaceTag(context = {}) {
37338
+ return new _VeskError("Namespace imports are not supported for `.vsk` modules.", {
37339
+ ...context,
37340
+ code: context.code || "V0410",
37341
+ suggestions: [
37342
+ "Import the component by name: import { MyIcon } from './icons.vsk'",
37343
+ "Rename on import: import { MyIcon as Icon } from './icons.vsk'"
37344
+ ],
37345
+ nextSteps: [
37346
+ "A `.vsk` component is a registry entry keyed by its name, not a module namespace object, so `<ns.Icon />` cannot be resolved.",
37347
+ "If you need a namespace object, import from a `.ts`/`.js` module instead \u2014 those are real ES modules."
37348
+ ],
37349
+ tip: "A `.vsk` module exposes its components as named exports; use a named or renamed import rather than `import * as ns`."
37350
+ });
37351
+ }
36816
37352
  static classDecl(context = {}) {
36817
37353
  return new _VeskError("class declarations are not supported inside Vesk components.", {
36818
37354
  ...context,
@@ -39778,6 +40314,7 @@ init_server_jsgen();
39778
40314
  // ../compiler/src/precompile-runtime.ts
39779
40315
  init_ir();
39780
40316
  init_server_utils();
40317
+ init_vsk_imports();
39781
40318
  var IR_CLASSES = [
39782
40319
  ["Expression", Expression.prototype],
39783
40320
  ["IRRoot", IRRoot.prototype],
@@ -39864,7 +40401,11 @@ function precompileFileInternal(source, sourcePath2, seenImportFiles) {
39864
40401
  const bindings = sourcePath2 !== void 0 ? collectModuleBundle(ir.imports, dirname6(sourcePath2), collector) : [];
39865
40402
  const subFiles = [];
39866
40403
  if (sourcePath2 !== void 0) {
39867
- for (const importPath of collectVskImportPaths(ir.imports, sourcePath2)) {
40404
+ const vskPaths = [
40405
+ ...collectVskImportPaths(ir.imports, sourcePath2),
40406
+ ...collectVskReexportPaths(ir.reexportSources, sourcePath2)
40407
+ ];
40408
+ for (const importPath of vskPaths) {
39868
40409
  if (seenImportFiles.has(importPath)) continue;
39869
40410
  seenImportFiles.add(importPath);
39870
40411
  try {
@@ -41001,6 +41542,31 @@ function extractCompiledNodes(code, isTarget) {
41001
41542
  function isModuleLevel(node) {
41002
41543
  return node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration";
41003
41544
  }
41545
+ function nativeLibraryImportStubs(code) {
41546
+ let ast;
41547
+ try {
41548
+ ast = parse4(code);
41549
+ } catch {
41550
+ return "";
41551
+ }
41552
+ const body = ast.body ?? [];
41553
+ const bindings = [];
41554
+ for (const node of body) {
41555
+ if (node?.type !== "ImportDeclaration") continue;
41556
+ const src2 = node.source?.value;
41557
+ if (typeof src2 !== "string" || !src2.startsWith("@vesk/") || src2.startsWith("@vesk/runtime")) continue;
41558
+ for (const spec of node.specifiers ?? []) {
41559
+ if (typeof spec?.local?.name === "string") bindings.push([spec.local.name, src2]);
41560
+ }
41561
+ }
41562
+ if (bindings.length === 0) return "";
41563
+ const lines = bindings.map(([local, spec]) => {
41564
+ const message = `web preview: native library "${spec}" has no browser equivalent on the web (dev-only) \u2014 binding "${local}" cannot be provided in vesk dev --web. Build for Android to use it.`;
41565
+ const thrower = `throw Object.assign(new Error(${JSON.stringify(message)}), { __veskPreviewMissing: ${JSON.stringify(spec)} })`;
41566
+ return `const ${local} = new Proxy(function () {}, { get: function () { ${thrower}; }, apply: function () { ${thrower}; }, construct: function () { ${thrower}; } });`;
41567
+ });
41568
+ return lines.join("\n") + "\n\n";
41569
+ }
41004
41570
  function demoteExports(code) {
41005
41571
  let ast;
41006
41572
  try {
@@ -41334,7 +41900,7 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
41334
41900
  }
41335
41901
  const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
41336
41902
  const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
41337
- const { comp: rawComp, hyd: rawHyd, name: actualName } = compileClientBoth(src2, null, filePath);
41903
+ const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths } = compileClientBoth(src2, null, filePath);
41338
41904
  const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
41339
41905
  const hydWithImports = rawHyd ? stripExports(stripVskImports(stripRuntimeImport(rawHyd))) : "";
41340
41906
  const compSpecs = [];
@@ -41354,6 +41920,11 @@ async function generateClientBundle(routeTree, appDir, componentMap, options) {
41354
41920
  output.push(`Object.defineProperty(__components, ${JSON.stringify(resolvedName)}, { get: () => __components[${JSON.stringify(actualName)}], configurable: true });`);
41355
41921
  output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(resolvedName)}, { get: () => __hydrators[${JSON.stringify(actualName)}], configurable: true });`);
41356
41922
  }
41923
+ for (const alias of aliases || []) {
41924
+ output.push(`Object.defineProperty(__components, ${JSON.stringify(alias.exported)}, { get: () => __components[${JSON.stringify(alias.local)}], configurable: true });`);
41925
+ output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(alias.exported)}, { get: () => __hydrators[${JSON.stringify(alias.local)}], configurable: true });`);
41926
+ }
41927
+ for (const reexportPath of reexportPaths || []) compileFile2(reexportPath, null, output, imports);
41357
41928
  if (cache2 && namesBefore) {
41358
41929
  const st = statSync3(filePath);
41359
41930
  cache2.files.set(filePath, {
@@ -41491,7 +42062,7 @@ ${entry.code}
41491
42062
  const err = e;
41492
42063
  console.error("[vesk] chunk bundle failed", entry.name, err?.errors?.map((x) => x.text).join(" | ") || err?.message || String(e));
41493
42064
  const stripped = demoteExports(removeCompiledNodes(entry.code, isAnyImport));
41494
- finalCode = chunkIIFE(stripped);
42065
+ finalCode = chunkIIFE(nativeLibraryImportStubs(entry.code) + stripped);
41495
42066
  } finally {
41496
42067
  try {
41497
42068
  rmSync(tmpBase, { recursive: true, force: true });
@@ -41499,7 +42070,7 @@ ${entry.code}
41499
42070
  }
41500
42071
  }
41501
42072
  } else {
41502
- finalCode = chunkIIFE(entry.code);
42073
+ finalCode = chunkIIFE(demoteExports(entry.code));
41503
42074
  }
41504
42075
  chunks.push({ name: entry.name, code: finalCode });
41505
42076
  }
@@ -41708,7 +42279,7 @@ function appendHmrGlobals(code) {
41708
42279
  return code + "globalThis.__vesk_hmr_eval = (code, n) => {\n if (!n || n !== globalThis.__vesk_hmr_nonce) throw new Error('vesk hmr: invalid nonce');\n return eval(code);\n};\n";
41709
42280
  }
41710
42281
  async function buildMainBundle(routeTree, runtimeDir, codeSplit, mono, hmr, importRuntime, runtimeImportNames, routeDataCache) {
41711
- const baseRuntimeImports = ["createFileRouter", "get", "set", "effect", "track", "destroy_block", "getActiveComponent", "setActiveComponent", "NavLink", "Link", "reactiveProps", "matchRoute", "ensureChunk"];
42282
+ const baseRuntimeImports = ["createFileRouter", "get", "set", "effect", "track", "destroy_block", "getActiveComponent", "setActiveComponent", "NavLink", "Link", "reactiveProps", "matchRoute", "ensureChunk", "toDomNode", "rerenderNode"];
41712
42283
  const allRuntimeImports = runtimeImportNames && runtimeImportNames.size > 0 ? [.../* @__PURE__ */ new Set([...baseRuntimeImports, ...runtimeImportNames])] : baseRuntimeImports;
41713
42284
  const runtimeGlobals = [
41714
42285
  "reconcile",
@@ -43028,6 +43599,7 @@ init_server_utils();
43028
43599
  init_module_imports();
43029
43600
  init_scan();
43030
43601
  init_tokens();
43602
+ init_vsk_imports();
43031
43603
  init_md_inline();
43032
43604
  init_strip_ts();
43033
43605
  import { walk as walk6 } from "zimmerframe";
@@ -43051,6 +43623,47 @@ function simpleGetName2(expr) {
43051
43623
  }
43052
43624
  return inner;
43053
43625
  }
43626
+ var BINDING_REF_CALLS2 = ["bindValue", "bindChecked", "bindGroup"];
43627
+ function untrackBindingArg2(expr) {
43628
+ let head = -1;
43629
+ for (const name of BINDING_REF_CALLS2) {
43630
+ if (expr.startsWith(`${name}(`)) {
43631
+ head = name.length;
43632
+ break;
43633
+ }
43634
+ }
43635
+ if (head < 0)
43636
+ return expr;
43637
+ const rest = expr.slice(head + 1);
43638
+ if (rest[0] !== "g" || rest[1] !== "e" || rest[2] !== "t" || rest[3] !== "(")
43639
+ return expr;
43640
+ let i = 4;
43641
+ let word = "";
43642
+ for (; i < rest.length; i++) {
43643
+ const c = rest.charCodeAt(i);
43644
+ const ok = c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || c === 95 || c === 36;
43645
+ if (!ok)
43646
+ break;
43647
+ word += rest[i];
43648
+ }
43649
+ if (word.length === 0 || rest[i] !== ")")
43650
+ return expr;
43651
+ const after = i + 1;
43652
+ if (rest[after] !== "," && rest[after] !== ")")
43653
+ return expr;
43654
+ return expr.slice(0, head + 1) + word + rest.slice(after);
43655
+ }
43656
+ function trackedRefTarget2(expr, tracked2) {
43657
+ const cell = simpleGetName2(expr);
43658
+ if (cell !== null)
43659
+ return cell;
43660
+ if (/^[A-Za-z_$][\w$]*$/.test(expr)) {
43661
+ const info = tracked2.get(expr);
43662
+ if (info && info.kind === "cell" && info.cellName === expr)
43663
+ return expr;
43664
+ }
43665
+ return null;
43666
+ }
43054
43667
  function semicolonizeStatement2(code) {
43055
43668
  const trimmed = code.trimEnd();
43056
43669
  if (!trimmed || trimmed.endsWith(";") || trimmed.endsWith("}"))
@@ -43157,6 +43770,21 @@ function transformTracked2(irNode, tracked2) {
43157
43770
  }
43158
43771
  return context.next();
43159
43772
  },
43773
+ Property(node, context) {
43774
+ if (node.shorthand && node.value && node.value.type === "Identifier" && !node.computed) {
43775
+ const info = context.state.get(node.value.name);
43776
+ if (info && info.kind === "virtual") {
43777
+ return {
43778
+ ...node,
43779
+ shorthand: false,
43780
+ value: callExpr2({ type: "Identifier", name: "get" }, [
43781
+ { type: "Identifier", name: info.cellName }
43782
+ ])
43783
+ };
43784
+ }
43785
+ }
43786
+ return context.next();
43787
+ },
43160
43788
  Identifier(node, context) {
43161
43789
  const parent = context.path.at(-1);
43162
43790
  if (parent) {
@@ -43168,6 +43796,8 @@ function transformTracked2(irNode, tracked2) {
43168
43796
  return context.next();
43169
43797
  if (parent.type === "Property" && parent.value === node && parent.key && parent.key.type === "Identifier" && parent.key.name === "into")
43170
43798
  return context.next();
43799
+ if (parent.type === "Property" && parent.key === node && !parent.computed && !parent.shorthand)
43800
+ return context.next();
43171
43801
  if (parent.type === "MemberExpression" && !parent.computed && parent.object === node && parent.property && parent.property.type === "Identifier" && parent.property.name === "set")
43172
43802
  return context.next();
43173
43803
  }
@@ -43195,6 +43825,31 @@ function collectTrackedNames2(body) {
43195
43825
  }
43196
43826
  return names;
43197
43827
  }
43828
+ function collectTrackedDeps2(value, tracked2) {
43829
+ const ast = value?.ast;
43830
+ if (!ast || typeof ast !== "object" || tracked2.size === 0)
43831
+ return [];
43832
+ const found = [];
43833
+ const seen = /* @__PURE__ */ new Set();
43834
+ walk6(ast, tracked2, {
43835
+ Identifier(node, context) {
43836
+ const parent = context.path.at(-1);
43837
+ if (parent) {
43838
+ if (parent.type === "MemberExpression" && !parent.computed && parent.property === node)
43839
+ return context.next();
43840
+ if (parent.type === "Property" && parent.key === node)
43841
+ return context.next();
43842
+ }
43843
+ const info = context.state.get(node.name);
43844
+ if (info && !seen.has(node.name)) {
43845
+ seen.add(node.name);
43846
+ found.push(node.name);
43847
+ }
43848
+ return context.next();
43849
+ }
43850
+ });
43851
+ return found;
43852
+ }
43198
43853
  function transformTrackedInit2(init, tracked2) {
43199
43854
  if (!init)
43200
43855
  return init;
@@ -43531,8 +44186,9 @@ function emitStatic2(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget)
43531
44186
  const target = attr.target || "";
43532
44187
  const isEvent2 = target.startsWith("on") && target.length > 2;
43533
44188
  if (target === "ref") {
43534
- const expr = transformTracked2(attr.expression, tracked2);
43535
- ctx2.push(`(${expr})(${ssrEl});`);
44189
+ const expr = untrackBindingArg2(transformTracked2(attr.expression, tracked2));
44190
+ const cell = trackedRefTarget2(expr, tracked2);
44191
+ ctx2.push(cell !== null ? `set(${cell}, ${ssrEl});` : `(${expr})(${ssrEl});`);
43536
44192
  } else if (isEvent2) {
43537
44193
  const eventName = target.slice(2).toLowerCase();
43538
44194
  const handler = transformTracked2(attr.expression, tracked2);
@@ -43590,8 +44246,9 @@ function emitStatic2(ctx2, node, tracked2, effectsVar, skipK = 0, regionBudget)
43590
44246
  const target = attr.target || "";
43591
44247
  const isEvent2 = target.startsWith("on") && target.length > 2;
43592
44248
  if (target === "ref") {
43593
- const expr = transformTracked2(attr.expression, tracked2);
43594
- ctx2.push(`(${expr})(${el});`);
44249
+ const expr = untrackBindingArg2(transformTracked2(attr.expression, tracked2));
44250
+ const cell = trackedRefTarget2(expr, tracked2);
44251
+ ctx2.push(cell !== null ? `set(${cell}, ${el});` : `(${expr})(${el});`);
43595
44252
  } else if (isEvent2) {
43596
44253
  const eventName = target.slice(2).toLowerCase();
43597
44254
  const handler = transformTracked2(attr.expression, tracked2);
@@ -43810,20 +44467,35 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
43810
44467
  const calleeExpr = node.calleeExpr ? `(${node.calleeExpr})` : null;
43811
44468
  const slotChildren = node.children.filter((c) => c instanceof PropSlot);
43812
44469
  const regChildren = node.children.filter((c) => !(c instanceof PropSlot));
43813
- const callArgs = () => `{ ${propsEntries.join(", ")} }`;
44470
+ const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
44471
+ const trackedDeps = [];
44472
+ if (plainTarget) {
44473
+ for (const p of node.props) {
44474
+ if (typeof p.value === "string")
44475
+ continue;
44476
+ for (const d of collectTrackedDeps2(p.value, tracked2))
44477
+ if (!trackedDeps.includes(d))
44478
+ trackedDeps.push(d);
44479
+ }
44480
+ for (const sp of node.spreadProps) {
44481
+ for (const d of collectTrackedDeps2(sp, tracked2))
44482
+ if (!trackedDeps.includes(d))
44483
+ trackedDeps.push(d);
44484
+ }
44485
+ }
44486
+ const callArgs = () => plainTarget ? `reactiveProps({ ${propsEntries.join(", ")} })` : `{ ${propsEntries.join(", ")} }`;
43814
44487
  if (ctx2.hydrate) {
43815
44488
  const access = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `__components[${JSON.stringify(node.componentName)}]`);
43816
44489
  if (!calleeExpr && !ctx2.importedNames.has(node.componentName)) {
43817
44490
  ctx2.push(`if (${access} == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
43818
44491
  }
43819
- const plainTarget = !!(calleeExpr || ctx2.importedNames.has(node.componentName)) && !ctx2.selfClaimNames.has(node.componentName);
43820
44492
  const walkerArg = ctx2.walker;
43821
44493
  const promptExpr = ctx2.markerless && (regionBudget || skipK > 0) ? markerlessSkipExpr2(regionBudget, skipK) : null;
43822
44494
  const maybeReplace = (v2) => {
43823
44495
  if (!plainTarget)
43824
44496
  return;
43825
44497
  const claim = promptExpr ? `${walkerArg}.claimOnly(undefined, ${promptExpr})` : `${walkerArg}.claimOnly()`;
43826
- ctx2.push(`if (${v2} && ${v2}.parentNode == null && ${v2}.nodeType !== 11) { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); }`);
44498
+ ctx2.push(`if (${v2} && ${v2}.parentNode == null) { if (${v2}.nodeType === 11) { const __cnt = ${v2}.childNodes.length; let __sr = null; for (let __i = 0; __i < __cnt; __i++) { const __c = ${claim}; if (__c && __c.parentNode) { if (__sr) { __c.remove(); } else { __sr = __c; } } } if (__sr) { const __p = __sr.parentNode; while (${v2}.firstChild) __p.insertBefore(${v2}.firstChild, __sr); __p.removeChild(__sr); } } else { const __sr = ${claim}; if (__sr && __sr.parentNode) __sr.parentNode.replaceChild(${v2}, __sr); } }`);
43827
44499
  if (regionBudget && ctx2.markerless)
43828
44500
  ctx2.push(`${regionBudget} = 0;`);
43829
44501
  };
@@ -43862,11 +44534,17 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
43862
44534
  }
43863
44535
  ctx2.push(`let ${v} = undefined;`);
43864
44536
  ctx2.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
43865
- ctx2.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
44537
+ ctx2.push(`try { ${v} = toDomNode(${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg})); } finally { if (__hydrate) __hydrate.childFrame--; }`);
44538
+ const rootsVar = trackedDeps.length > 0 ? ctx2.n() : null;
44539
+ if (rootsVar)
44540
+ ctx2.push(`const ${rootsVar} = ${v} && ${v}.nodeType === 11 ? Array.from(${v}.childNodes) : [${v}];`);
43866
44541
  if (ctx2.markerless && promptExpr && !plainTarget && regionBudget)
43867
44542
  ctx2.push(`${regionBudget} = 0;`);
43868
44543
  maybeReplace(v);
43869
44544
  maybeRetire();
44545
+ if (trackedDeps.length > 0) {
44546
+ ctx2.push(`rerenderNode(${rootsVar}, [${trackedDeps.join(", ")}], () => ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}));`);
44547
+ }
43870
44548
  return v;
43871
44549
  } else {
43872
44550
  for (const slot of slotChildren) {
@@ -43890,12 +44568,18 @@ function emitComponentCall2(ctx2, node, tracked2, effectsVar, parentVar, compPre
43890
44568
  propsEntries.push(`children: ${frag}`);
43891
44569
  }
43892
44570
  if (calleeExpr) {
43893
- ctx2.push(`const ${v} = ${calleeExpr}(${callArgs()});`);
44571
+ ctx2.push(`const ${v} = toDomNode(${calleeExpr}(${callArgs()}));`);
43894
44572
  } else if (ctx2.importedNames.has(node.componentName)) {
43895
- ctx2.push(`const ${v} = ${awaitKw}${node.componentName}(${callArgs()});`);
44573
+ ctx2.push(`const ${v} = toDomNode(${awaitKw}${node.componentName}(${callArgs()}));`);
43896
44574
  } else {
43897
44575
  ctx2.push(`if (${compPrefix}[${JSON.stringify(node.componentName)}] == null) throw new Error(${JSON.stringify(`Component "${node.componentName}" was not found while rendering. Declare it with the \`component\` keyword, import it, or register it in the component registry.`)});`);
43898
- ctx2.push(`const ${v} = ${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()});`);
44576
+ ctx2.push(`const ${v} = toDomNode(${awaitKw}${compPrefix}[${JSON.stringify(node.componentName)}](${callArgs()}));`);
44577
+ }
44578
+ if (trackedDeps.length > 0) {
44579
+ const calleeRef = calleeExpr ?? (ctx2.importedNames.has(node.componentName) ? node.componentName : `${compPrefix}[${JSON.stringify(node.componentName)}]`);
44580
+ const rootsVar2 = ctx2.n();
44581
+ ctx2.push(`const ${rootsVar2} = ${v} && ${v}.nodeType === 11 ? Array.from(${v}.childNodes) : [${v}];`);
44582
+ ctx2.push(`rerenderNode(${rootsVar2}, [${trackedDeps.join(", ")}], () => ${awaitKw}${calleeRef}(${callArgs()}));`);
43899
44583
  }
43900
44584
  }
43901
44585
  return v;
@@ -45135,7 +45819,7 @@ function emitClientFromIR2(ir, options) {
45135
45819
  }
45136
45820
  }
45137
45821
  const exportCode = exportLines.join("\n");
45138
- const runtimeNames = ["track", "get", "set", "destroy_block", "getActiveComponent", "setActiveComponent", "reactiveProps", "applyStyle"];
45822
+ const runtimeNames = ["track", "get", "set", "destroy_block", "getActiveComponent", "setActiveComponent", "reactiveProps", "applyStyle", "toDomNode", "rerenderNode"];
45139
45823
  if (ir.components.some((c) => !isStaticIR2(c.body)))
45140
45824
  runtimeNames.push("effect");
45141
45825
  for (const name of usedRuntimeBindings2(ir))
@@ -45203,12 +45887,16 @@ function compileClientBoth2(source, _componentName, sourcePath2, opts) {
45203
45887
  }
45204
45888
  const alloc = nameAllocFor2(sourcePath2);
45205
45889
  const comp = emitClientFromIR2(ir, { forceClient: true, nameAllocator: alloc });
45890
+ const aliases = vskRegistryAliases(ir.imports, ir.exportAliases);
45891
+ const reexportPaths = sourcePath2 ? collectVskReexportPaths(ir.reexportSources, sourcePath2) : [];
45206
45892
  if (opts?.skipHyd)
45207
- return { comp, hyd: "", name };
45893
+ return { comp, hyd: "", name, aliases, reexportPaths };
45208
45894
  return {
45209
45895
  comp,
45210
45896
  hyd: emitClientFromIR2(irHyd, { forceClient: true, hydrate: true, includeTopLevel: false, nameAllocator: alloc, markerless: opts?.markerless !== false }),
45211
- name
45897
+ name,
45898
+ aliases,
45899
+ reexportPaths
45212
45900
  };
45213
45901
  }
45214
45902
 
@@ -46529,6 +47217,35 @@ function extractCompiledNodes2(code, isTarget) {
46529
47217
  function isModuleLevel2(node) {
46530
47218
  return node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration";
46531
47219
  }
47220
+ function nativeLibraryImportStubs2(code) {
47221
+ let ast;
47222
+ try {
47223
+ ast = parse4(code);
47224
+ } catch {
47225
+ return "";
47226
+ }
47227
+ const body = ast.body ?? [];
47228
+ const bindings = [];
47229
+ for (const node of body) {
47230
+ if (node?.type !== "ImportDeclaration")
47231
+ continue;
47232
+ const src2 = node.source?.value;
47233
+ if (typeof src2 !== "string" || !src2.startsWith("@vesk/") || src2.startsWith("@vesk/runtime"))
47234
+ continue;
47235
+ for (const spec of node.specifiers ?? []) {
47236
+ if (typeof spec?.local?.name === "string")
47237
+ bindings.push([spec.local.name, src2]);
47238
+ }
47239
+ }
47240
+ if (bindings.length === 0)
47241
+ return "";
47242
+ const lines = bindings.map(([local, spec]) => {
47243
+ const message = `web preview: native library "${spec}" has no browser equivalent on the web (dev-only) \u2014 binding "${local}" cannot be provided in vesk dev --web. Build for Android to use it.`;
47244
+ const thrower = `throw Object.assign(new Error(${JSON.stringify(message)}), { __veskPreviewMissing: ${JSON.stringify(spec)} })`;
47245
+ return `const ${local} = new Proxy(function () {}, { get: function () { ${thrower}; }, apply: function () { ${thrower}; }, construct: function () { ${thrower}; } });`;
47246
+ });
47247
+ return lines.join("\n") + "\n\n";
47248
+ }
46532
47249
  function demoteExports2(code) {
46533
47250
  let ast;
46534
47251
  try {
@@ -46895,7 +47612,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
46895
47612
  }
46896
47613
  const namesBefore = cache2 ? new Set(runtimeImportNames) : null;
46897
47614
  const importedPaths = resolveVskImports(filePath, (p, n) => compileFile2(p, n, output, imports));
46898
- const { comp: rawComp, hyd: rawHyd, name: actualName } = compileClientBoth(src2, null, filePath);
47615
+ const { comp: rawComp, hyd: rawHyd, name: actualName, aliases, reexportPaths } = compileClientBoth(src2, null, filePath);
46899
47616
  const compWithImports = rawComp ? stripExports(stripVskImports(stripRuntimeImport(rawComp))) : "";
46900
47617
  const hydWithImports = rawHyd ? stripExports(stripVskImports(stripRuntimeImport(rawHyd))) : "";
46901
47618
  const compSpecs = [];
@@ -46918,6 +47635,12 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options) {
46918
47635
  output.push(`Object.defineProperty(__components, ${JSON.stringify(resolvedName)}, { get: () => __components[${JSON.stringify(actualName)}], configurable: true });`);
46919
47636
  output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(resolvedName)}, { get: () => __hydrators[${JSON.stringify(actualName)}], configurable: true });`);
46920
47637
  }
47638
+ for (const alias of aliases || []) {
47639
+ output.push(`Object.defineProperty(__components, ${JSON.stringify(alias.exported)}, { get: () => __components[${JSON.stringify(alias.local)}], configurable: true });`);
47640
+ output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(alias.exported)}, { get: () => __hydrators[${JSON.stringify(alias.local)}], configurable: true });`);
47641
+ }
47642
+ for (const reexportPath of reexportPaths || [])
47643
+ compileFile2(reexportPath, null, output, imports);
46921
47644
  if (cache2 && namesBefore) {
46922
47645
  const st = statSync14(filePath);
46923
47646
  cache2.files.set(filePath, {
@@ -47061,7 +47784,7 @@ ${entry.code}
47061
47784
  const err = e;
47062
47785
  console.error("[vesk] chunk bundle failed", entry.name, err?.errors?.map((x) => x.text).join(" | ") || err?.message || String(e));
47063
47786
  const stripped = demoteExports2(removeCompiledNodes2(entry.code, isAnyImport2));
47064
- finalCode = chunkIIFE(stripped);
47787
+ finalCode = chunkIIFE(nativeLibraryImportStubs2(entry.code) + stripped);
47065
47788
  } finally {
47066
47789
  try {
47067
47790
  rmSync4(tmpBase, { recursive: true, force: true });
@@ -47069,7 +47792,7 @@ ${entry.code}
47069
47792
  }
47070
47793
  }
47071
47794
  } else {
47072
- finalCode = chunkIIFE(entry.code);
47795
+ finalCode = chunkIIFE(demoteExports2(entry.code));
47073
47796
  }
47074
47797
  chunks.push({ name: entry.name, code: finalCode });
47075
47798
  }
@@ -47292,7 +48015,7 @@ function appendHmrGlobals2(code) {
47292
48015
  return code + "globalThis.__vesk_hmr_eval = (code, n) => {\n if (!n || n !== globalThis.__vesk_hmr_nonce) throw new Error('vesk hmr: invalid nonce');\n return eval(code);\n};\n";
47293
48016
  }
47294
48017
  async function buildMainBundle2(routeTree, runtimeDir, codeSplit, mono, hmr, importRuntime, runtimeImportNames, routeDataCache) {
47295
- const baseRuntimeImports = ["createFileRouter", "get", "set", "effect", "track", "destroy_block", "getActiveComponent", "setActiveComponent", "NavLink", "Link", "reactiveProps", "matchRoute", "ensureChunk"];
48018
+ const baseRuntimeImports = ["createFileRouter", "get", "set", "effect", "track", "destroy_block", "getActiveComponent", "setActiveComponent", "NavLink", "Link", "reactiveProps", "matchRoute", "ensureChunk", "toDomNode", "rerenderNode"];
47296
48019
  const allRuntimeImports = runtimeImportNames && runtimeImportNames.size > 0 ? [.../* @__PURE__ */ new Set([...baseRuntimeImports, ...runtimeImportNames])] : baseRuntimeImports;
47297
48020
  const runtimeGlobals = [
47298
48021
  "reconcile",
@@ -53292,11 +54015,11 @@ ${prettifyHtml(body)}
53292
54015
  </html>`;
53293
54016
  return applyHtmlPlugins(fullHtml, ctx2.plugins, { sourcePath: ctx2.url.pathname });
53294
54017
  }
53295
- const leaf = chain.find((n) => n.page);
53296
- if (!leaf) return null;
53297
- const src2 = readFileSync37(resolve37(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
53298
- const compName = resolveComponentName(src2) || leaf.page;
53299
- const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: actionCssUrls(ctx2.appDirPath), security: ctx2.security, sourcePath: resolve37(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), plugins: ctx2.plugins });
54018
+ const leaf2 = chain.find((n) => n.page);
54019
+ if (!leaf2) return null;
54020
+ const src2 = readFileSync37(resolve37(ctx2.appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
54021
+ const compName = resolveComponentName(src2) || leaf2.page;
54022
+ const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: actionCssUrls(ctx2.appDirPath), security: ctx2.security, sourcePath: resolve37(ctx2.appDirPath, leaf2.sourceDir, "page.vsk"), plugins: ctx2.plugins });
53300
54023
  return applyHtmlPlugins(html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>'), ctx2.plugins, { sourcePath: ctx2.url.pathname });
53301
54024
  }
53302
54025
  async function handleActionRequest(req, res, ctx2) {
@@ -54753,11 +55476,11 @@ ${prettifyHtml(body)}
54753
55476
  html = injectDevScripts(html);
54754
55477
  html = await applyHtmlPlugins(html, getActiveDevPlugins(), { sourcePath: url.pathname });
54755
55478
  } else {
54756
- const leaf = chain.find((n) => n.page);
54757
- if (leaf) {
54758
- const src2 = readFileSync38(resolve38(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
54759
- const compName = extractCompName2(src2) || leaf.page;
54760
- html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf.sourceDir, "page.vsk"), cached: cachedSsrCompile(ssrCompileCache, src2, resolve38(appDirPath, leaf.sourceDir, "page.vsk")), plugins: getActiveDevPlugins() });
55479
+ const leaf2 = chain.find((n) => n.page);
55480
+ if (leaf2) {
55481
+ const src2 = readFileSync38(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
55482
+ const compName = extractCompName2(src2) || leaf2.page;
55483
+ html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), cached: cachedSsrCompile(ssrCompileCache, src2, resolve38(appDirPath, leaf2.sourceDir, "page.vsk")), plugins: getActiveDevPlugins() });
54761
55484
  html = html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
54762
55485
  html = await applyHtmlPlugins(html, getActiveDevPlugins(), { sourcePath: url.pathname });
54763
55486
  } else {
@@ -54783,11 +55506,11 @@ ${prettifyHtml(body)}
54783
55506
  const chain = cleanChain;
54784
55507
  const hasLayout = chain.some((n) => n.layout && existsSync42(resolve38(appDirPath, n.sourceDir, "layout.vsk")));
54785
55508
  if (!hasLayout) {
54786
- const leaf = chain.find((n) => n.page);
54787
- if (leaf) {
54788
- const src2 = readFileSync38(resolve38(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
54789
- const compName = extractCompName2(src2) || leaf.page;
54790
- yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf.sourceDir, "page.vsk"), cached: cachedSsrCompile(ssrCompileCache, src2, resolve38(appDirPath, leaf.sourceDir, "page.vsk")), plugins: getActiveDevPlugins() });
55509
+ const leaf2 = chain.find((n) => n.page);
55510
+ if (leaf2) {
55511
+ const src2 = readFileSync38(resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), "utf-8");
55512
+ const compName = extractCompName2(src2) || leaf2.page;
55513
+ yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: activeCssUrls(), security, externalDataScript: storeDataScript, sourcePath: resolve38(appDirPath, leaf2.sourceDir, "page.vsk"), cached: cachedSsrCompile(ssrCompileCache, src2, resolve38(appDirPath, leaf2.sourceDir, "page.vsk")), plugins: getActiveDevPlugins() });
54791
55514
  } else {
54792
55515
  throw new Error("No page or layout matched");
54793
55516
  }
@@ -55242,11 +55965,15 @@ __export(index_server_exports2, {
55242
55965
  get_server_context: () => get_server_context,
55243
55966
  headers: () => headers,
55244
55967
  isFormAction: () => isFormAction,
55968
+ isLeaf: () => isLeaf,
55245
55969
  isLoadingActive: () => isLoadingActive,
55970
+ isPrimitive: () => isPrimitive,
55971
+ isVeskComponent: () => isVeskComponent,
55246
55972
  is_destroyed: () => is_destroyed,
55247
55973
  isr: () => isr,
55248
55974
  isrConfigToRevalidate: () => isrConfigToRevalidate,
55249
55975
  issuesToFieldMap: () => issuesToFieldMap,
55976
+ leaf: () => leaf,
55250
55977
  locals: () => locals,
55251
55978
  maxLength: () => maxLength,
55252
55979
  minLength: () => minLength,
@@ -55260,12 +55987,14 @@ __export(index_server_exports2, {
55260
55987
  permanentRedirect: () => permanentRedirect,
55261
55988
  pop_component: () => pop_component,
55262
55989
  pre_effect: () => pre_effect,
55990
+ primitive: () => primitive,
55263
55991
  push_component: () => push_component,
55264
55992
  readSignedCookie: () => readSignedCookie2,
55265
55993
  redirect: () => redirect,
55266
55994
  removeHook: () => removeHook,
55267
55995
  render: () => render,
55268
55996
  required: () => required,
55997
+ rerenderNode: () => rerenderNode,
55269
55998
  resolveSsrResources: () => resolveSsrResources,
55270
55999
  resume_block: () => resume_block,
55271
56000
  revalidateComponent: () => revalidateComponent,
@@ -55289,6 +56018,7 @@ __export(index_server_exports2, {
55289
56018
  set_server_context: () => set_server_context,
55290
56019
  signCookie: () => signCookie2,
55291
56020
  tick: () => tick,
56021
+ toDomNode: () => toDomNode,
55292
56022
  track: () => track,
55293
56023
  unlink_block: () => unlink_block,
55294
56024
  unsignCookie: () => unsignCookie2,
@@ -55324,6 +56054,7 @@ init_experiment();
55324
56054
  init_form();
55325
56055
  init_md();
55326
56056
  init_headless();
56057
+ init_primitive();
55327
56058
  init_loading_indicator();
55328
56059
  init_action();
55329
56060