@vesk/vesk-cli 0.2.50-canary.3 → 0.2.50-canary.5

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 +526 -122
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -399,6 +399,13 @@ var init_ir = __esm({
399
399
  importedNames;
400
400
  staticProps;
401
401
  loadFn;
402
+ /**
403
+ * Source of `export const metadata = defineMetadata({...})`, when present.
404
+ * Static by construction: evaluated with only `defineMetadata` in scope, at
405
+ * build time where possible and in a sealed sandbox at request time
406
+ * otherwise, so the head never depends on the component's frame.
407
+ */
408
+ metadataSource;
402
409
  topLevelCode;
403
410
  /**
404
411
  * Same-file specifier exports (`export { A }`, `export { A as B }`) as
@@ -1966,8 +1973,16 @@ function writeCache(key, data2) {
1966
1973
  const entry = getClientCache().get(key);
1967
1974
  if (!entry || entry.data !== data2) getClientCache().set(key, { data: data2, fetchedAt: Date.now() });
1968
1975
  }
1969
- function trackSsrPromise(promise) {
1976
+ function trackSsrPromise(promise, defer = false) {
1970
1977
  const tk = g().__vsk_ssr_token || "";
1978
+ if (defer) {
1979
+ const deferredKey = tk ? `__vsk_ssr_deferred_${tk}` : "__vsk_ssr_deferred";
1980
+ if (!g()[deferredKey]) g()[deferredKey] = [];
1981
+ g()[deferredKey].push(promise);
1982
+ promise.then(void 0, () => {
1983
+ });
1984
+ return;
1985
+ }
1971
1986
  const promisesKey = tk ? `__vsk_ssr_promises_${tk}` : "__vsk_ssr_promises";
1972
1987
  if (!g()[promisesKey]) g()[promisesKey] = [];
1973
1988
  g()[promisesKey].push(promise);
@@ -2034,7 +2049,7 @@ function startRequest(handle2, skipCache) {
2034
2049
  } else {
2035
2050
  attachSettle(handle2, prom2);
2036
2051
  }
2037
- trackSsrPromise(prom2);
2052
+ trackSsrPromise(prom2, options.ssr === "defer");
2038
2053
  return prom2;
2039
2054
  }
2040
2055
  if (!skipCache && options.staleTime && options.staleTime > 0) {
@@ -19480,6 +19495,10 @@ function resolveSsrModule(specifier, fromDir) {
19480
19495
  } else {
19481
19496
  const aliased = resolveAliasModule(specifier, fromDir);
19482
19497
  if (aliased) return toRealPath(aliased);
19498
+ const viaExports = resolveViaPackageExports(specifier, fromDir);
19499
+ if (viaExports) return viaExports;
19500
+ const viaModuleField = resolveViaPackageModuleField(specifier, fromDir);
19501
+ if (viaModuleField) return viaModuleField;
19483
19502
  const native = nativeResolve(specifier, fromDir);
19484
19503
  if (native) return native;
19485
19504
  let dir = fromDir;
@@ -19543,6 +19562,98 @@ function statOrNull(p) {
19543
19562
  return null;
19544
19563
  }
19545
19564
  }
19565
+ function resolveExports(exportsField, subpath) {
19566
+ const conditions = ["import", "module", "node", "default"];
19567
+ const target = (value) => {
19568
+ if (typeof value === "string") return value;
19569
+ if (!value || typeof value !== "object") return null;
19570
+ for (const cond of conditions) {
19571
+ if (cond in value) {
19572
+ const got = target(value[cond]);
19573
+ if (got) return got;
19574
+ }
19575
+ }
19576
+ return null;
19577
+ };
19578
+ if (typeof exportsField === "string") return subpath === "." ? exportsField : null;
19579
+ if (!exportsField || typeof exportsField !== "object") return null;
19580
+ const map = exportsField;
19581
+ if (subpath in map) {
19582
+ const direct = target(map[subpath]);
19583
+ if (direct) return direct;
19584
+ return null;
19585
+ }
19586
+ let best = null;
19587
+ for (const key of Object.keys(map)) {
19588
+ const star = key.indexOf("*");
19589
+ if (star === -1) continue;
19590
+ const prefix = key.slice(0, star);
19591
+ const suffix = key.slice(star + 1);
19592
+ if (!subpath.startsWith(prefix) || !subpath.endsWith(suffix)) continue;
19593
+ if (subpath.length < prefix.length + suffix.length) continue;
19594
+ if (best === null || prefix.length > best.key.length) {
19595
+ best = { key: prefix, star: subpath.slice(prefix.length, subpath.length - suffix.length) };
19596
+ }
19597
+ }
19598
+ if (!best) return null;
19599
+ const pattern2 = target(map[Object.keys(map).find((k) => k.startsWith(best.key + "*") && k.endsWith(best.key.slice(0, -1)) + "*")] ?? map[`${best.key}*`]);
19600
+ if (pattern2 === null) return null;
19601
+ return pattern2.split("*").join(best.star);
19602
+ }
19603
+ function resolveViaPackageModuleField(specifier, fromDir) {
19604
+ const firstSlash = specifier.indexOf("/");
19605
+ const splitAt = specifier.startsWith("@") ? specifier.indexOf("/", firstSlash + 1) : firstSlash;
19606
+ const pkgName = splitAt > 0 ? specifier.slice(0, splitAt) : specifier;
19607
+ if (splitAt > 0) return null;
19608
+ let dir = fromDir;
19609
+ for (let depth = 0; depth < 64; depth++) {
19610
+ const pkgPath = join2(dir, "node_modules", pkgName, "package.json");
19611
+ if (statOrNull(pkgPath) !== null) {
19612
+ try {
19613
+ const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
19614
+ if (typeof pkg.module === "string" && pkg.module.length > 0) {
19615
+ const found = probeFile(resolve(join2(dir, "node_modules", pkgName), pkg.module));
19616
+ if (found) return toRealPath(found);
19617
+ }
19618
+ } catch {
19619
+ }
19620
+ return null;
19621
+ }
19622
+ const parent = dirname2(dir);
19623
+ if (parent === dir) break;
19624
+ dir = parent;
19625
+ }
19626
+ return null;
19627
+ }
19628
+ function resolveViaPackageExports(specifier, fromDir) {
19629
+ const firstSlash = specifier.indexOf("/");
19630
+ const splitAt = specifier.startsWith("@") ? specifier.indexOf("/", firstSlash + 1) : firstSlash;
19631
+ const pkgName = splitAt > 0 ? specifier.slice(0, splitAt) : specifier;
19632
+ const subpath = splitAt > 0 ? "." + specifier.slice(splitAt) : ".";
19633
+ let dir = fromDir;
19634
+ for (let depth = 0; depth < 64; depth++) {
19635
+ const pkgDir = join2(dir, "node_modules", pkgName);
19636
+ const pkgPath = join2(pkgDir, "package.json");
19637
+ if (statOrNull(pkgPath) !== null) {
19638
+ try {
19639
+ const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
19640
+ if (pkg.exports !== void 0) {
19641
+ const target = resolveExports(pkg.exports, subpath);
19642
+ if (target) {
19643
+ const found = probeFile(resolve(pkgDir, target));
19644
+ if (found) return toRealPath(found);
19645
+ }
19646
+ }
19647
+ } catch {
19648
+ }
19649
+ return null;
19650
+ }
19651
+ const parent = dirname2(dir);
19652
+ if (parent === dir) break;
19653
+ dir = parent;
19654
+ }
19655
+ return null;
19656
+ }
19546
19657
  function probeFile(base) {
19547
19658
  const st = statOrNull(base);
19548
19659
  if (st && st.isFile()) return base;
@@ -19552,9 +19663,19 @@ function probeFile(base) {
19552
19663
  if (pkgSt && pkgSt.isFile()) {
19553
19664
  try {
19554
19665
  const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
19555
- if (typeof pkg.main === "string" && pkg.main.length > 0) {
19556
- const viaMain = probeFile(resolve(base, pkg.main));
19557
- if (viaMain) return viaMain;
19666
+ if (pkg.exports !== void 0) {
19667
+ const viaExports = resolveExports(pkg.exports, ".");
19668
+ if (viaExports) {
19669
+ const found = probeFile(resolve(base, viaExports));
19670
+ if (found) return found;
19671
+ }
19672
+ }
19673
+ for (const field of ["module", "main"]) {
19674
+ const value = pkg[field];
19675
+ if (typeof value === "string" && value.length > 0) {
19676
+ const found = probeFile(resolve(base, value));
19677
+ if (found) return found;
19678
+ }
19558
19679
  }
19559
19680
  } catch {
19560
19681
  }
@@ -21186,6 +21307,7 @@ function generateIR(ast, source, filename) {
21186
21307
  const importedNames = /* @__PURE__ */ new Set();
21187
21308
  let staticProps = null;
21188
21309
  let loadFn = null;
21310
+ let metadataSource = null;
21189
21311
  const topLevelCode = [];
21190
21312
  const exportAliases = [];
21191
21313
  const reexportSources = [];
@@ -21221,6 +21343,14 @@ function generateIR(ast, source, filename) {
21221
21343
  continue;
21222
21344
  }
21223
21345
  }
21346
+ if (node.type === "ExportNamedDeclaration" && node.declaration && !metadataSource) {
21347
+ const decl = node.declaration;
21348
+ const first = decl.type === "VariableDeclaration" ? decl.declarations[0] : null;
21349
+ if (first?.id?.name === "metadata") {
21350
+ metadataSource = first.init ? stripCodeTypes(getSource(source, first.init)) : null;
21351
+ continue;
21352
+ }
21353
+ }
21224
21354
  if (node.type === "ExportNamedDeclaration" && node.declaration && !loadFn) {
21225
21355
  const decl = node.declaration;
21226
21356
  const fnName = decl.type === "FunctionDeclaration" ? decl.id?.name : decl.type === "VariableDeclaration" ? decl.declarations[0]?.id?.name : null;
@@ -21437,7 +21567,9 @@ function generateIR(ast, source, filename) {
21437
21567
  imports.push(`import { ${missing.join(", ")} } from '@vesk/runtime';`);
21438
21568
  }
21439
21569
  }
21440
- return new IRRoot(components, imports, importedNames, staticProps, loadFn, topLevelCode, exportAliases, reexportSources);
21570
+ const irRoot = new IRRoot(components, imports, importedNames, staticProps, loadFn, topLevelCode, exportAliases, reexportSources);
21571
+ irRoot.metadataSource = metadataSource;
21572
+ return irRoot;
21441
21573
  } finally {
21442
21574
  currentVskNamespaceLocals = prevNamespaceLocals;
21443
21575
  currentSourceFile = prevSourceFile;
@@ -22635,18 +22767,18 @@ function getHooks() {
22635
22767
  return globalThis.__vesk_hooks;
22636
22768
  }
22637
22769
  function defineHook(name, fn) {
22638
- const hooks = getHooks();
22639
- if (!hooks[name]) hooks[name] = [];
22640
- hooks[name].push(fn);
22770
+ const hooks2 = getHooks();
22771
+ if (!hooks2[name]) hooks2[name] = [];
22772
+ hooks2[name].push(fn);
22641
22773
  }
22642
22774
  function removeHook(name, fn) {
22643
- const hooks = getHooks();
22644
- if (!hooks[name]) return;
22645
- hooks[name] = hooks[name].filter((h) => h !== fn);
22775
+ const hooks2 = getHooks();
22776
+ if (!hooks2[name]) return;
22777
+ hooks2[name] = hooks2[name].filter((h) => h !== fn);
22646
22778
  }
22647
22779
  async function runHooks(name, ...args2) {
22648
- const hooks = getHooks()[name] || [];
22649
- for (const fn of hooks) {
22780
+ const hooks2 = getHooks()[name] || [];
22781
+ for (const fn of hooks2) {
22650
22782
  const result = await fn(...args2);
22651
22783
  if (result instanceof Response) return result;
22652
22784
  }
@@ -26508,6 +26640,177 @@ var init_action = __esm({
26508
26640
  }
26509
26641
  });
26510
26642
 
26643
+ // ../runtime/src/metadata.ts
26644
+ function assertPlainObject(value, where) {
26645
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
26646
+ throw new Error(`defineMetadata: ${where} must be a plain object, got ${Array.isArray(value) ? "an array" : typeof value}`);
26647
+ }
26648
+ return value;
26649
+ }
26650
+ function defineMetadata(input) {
26651
+ const meta = assertPlainObject(input, "the argument");
26652
+ if ("title" in meta && meta.title !== void 0) {
26653
+ if (typeof meta.title !== "string" && typeof meta.title !== "object") {
26654
+ throw new Error("defineMetadata: `title` must be a string or { default, template }");
26655
+ }
26656
+ if (typeof meta.title === "object") {
26657
+ const t = assertPlainObject(meta.title, "`title`");
26658
+ for (const key of Object.keys(t)) {
26659
+ if (key !== "default" && key !== "template" && key !== "absolute") {
26660
+ throw new Error(`defineMetadata: unknown \`title.${key}\` (expected default, template or absolute)`);
26661
+ }
26662
+ }
26663
+ }
26664
+ }
26665
+ if ("description" in meta && meta.description !== void 0 && typeof meta.description !== "string") {
26666
+ throw new Error("defineMetadata: `description` must be a string");
26667
+ }
26668
+ for (const key of ["openGraph", "twitter"]) {
26669
+ if (key in meta && meta[key] !== void 0) assertPlainObject(meta[key], `\`${key}\``);
26670
+ }
26671
+ if ("alternates" in meta && meta.alternates !== void 0) {
26672
+ const alt = assertPlainObject(meta.alternates, "`alternates`");
26673
+ for (const key of Object.keys(alt)) {
26674
+ if (key !== "canonical" && key !== "languages") {
26675
+ throw new Error(`defineMetadata: unknown \`alternates.${key}\` (expected canonical or languages)`);
26676
+ }
26677
+ }
26678
+ }
26679
+ for (const key of Object.keys(meta)) {
26680
+ if (!KNOWN_KEYS.has(key)) {
26681
+ throw new Error(
26682
+ `defineMetadata: unknown key "${key}". Known keys: ${[...KNOWN_KEYS].join(", ")}. (\`openGraph\` carries og:* tags, not top-level \`ogTitle\`.)`
26683
+ );
26684
+ }
26685
+ }
26686
+ return meta;
26687
+ }
26688
+ function resolveTitle(meta, child) {
26689
+ if (!meta || meta.title === void 0 || meta.title === null) return null;
26690
+ if (typeof meta.title === "string") return meta.title;
26691
+ if (meta.title.absolute) return meta.title.absolute;
26692
+ if (meta.title.default) return meta.title.default;
26693
+ if (meta.title.template && child) {
26694
+ const childTitle = resolveTitle(child);
26695
+ return childTitle === null ? null : meta.title.template.replace("%s", childTitle);
26696
+ }
26697
+ return null;
26698
+ }
26699
+ function mergeMetadata(...sources) {
26700
+ const out = {};
26701
+ let template;
26702
+ let sawTemplate = false;
26703
+ for (const source of sources) {
26704
+ if (!source) continue;
26705
+ for (const [key, value] of Object.entries(source)) {
26706
+ if (value === void 0) continue;
26707
+ if (key === "openGraph" || key === "twitter") {
26708
+ out[key] = { ...out[key] || {}, ...value };
26709
+ continue;
26710
+ }
26711
+ if (key === "title") {
26712
+ if (value && typeof value === "object" && value.template) {
26713
+ sawTemplate = true;
26714
+ template = value.template || template;
26715
+ }
26716
+ out.title = value;
26717
+ continue;
26718
+ }
26719
+ out[key] = value;
26720
+ }
26721
+ }
26722
+ if (sawTemplate && out.title !== void 0) {
26723
+ const own = out.title;
26724
+ if (typeof own === "string") out.title = { absolute: own };
26725
+ else if (own && typeof own === "object" && own.template) {
26726
+ out.title = { default: own.default, template: own.template || template };
26727
+ } else if (own && typeof own === "object") {
26728
+ out.title = { ...own, template };
26729
+ }
26730
+ }
26731
+ return out;
26732
+ }
26733
+ function escapeAttr2(value) {
26734
+ return String(value).split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;");
26735
+ }
26736
+ function escapeText(value) {
26737
+ return String(value).split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
26738
+ }
26739
+ function metadataToHtml(meta, opts = {}) {
26740
+ if (!meta) return "";
26741
+ const lines = [];
26742
+ const title = resolveTitle(meta, opts.child);
26743
+ if (title !== null) lines.push(`<title data-vesk-head>${escapeText(title)}</title>`);
26744
+ if (typeof meta.description === "string" && meta.description.length > 0) {
26745
+ lines.push(`<meta name="description" content="${escapeAttr2(meta.description)}" data-vesk-head />`);
26746
+ }
26747
+ if (meta.robots) {
26748
+ const content = typeof meta.robots === "string" ? meta.robots : Object.entries(meta.robots).filter(([, on]) => on).map(([k]) => k).join(", ");
26749
+ if (content) lines.push(`<meta name="robots" content="${escapeAttr2(content)}" data-vesk-head />`);
26750
+ }
26751
+ if (meta.themeColor) {
26752
+ lines.push(`<meta name="theme-color" content="${escapeAttr2(meta.themeColor)}" data-vesk-head />`);
26753
+ }
26754
+ const og = meta.openGraph;
26755
+ if (og) {
26756
+ const ogTitle = resolveTitle(og) ?? title;
26757
+ const ogFields = [
26758
+ ["og:title", ogTitle],
26759
+ ["og:description", og.description ?? meta.description],
26760
+ ["og:url", og.url],
26761
+ ["og:site_name", og.siteName],
26762
+ ["og:image", og.image],
26763
+ ["og:type", og.type]
26764
+ ];
26765
+ for (const [prop, value] of ogFields) {
26766
+ if (value === void 0 || value === null || value === "") continue;
26767
+ lines.push(`<meta property="${prop}" content="${escapeAttr2(value)}" data-vesk-head />`);
26768
+ }
26769
+ }
26770
+ const tw = meta.twitter;
26771
+ if (tw) {
26772
+ const twFields = [
26773
+ ["twitter:card", tw.card],
26774
+ ["twitter:site", tw.site],
26775
+ ["twitter:title", resolveTitle(tw) ?? title],
26776
+ ["twitter:description", tw.description ?? meta.description],
26777
+ ["twitter:image", tw.image]
26778
+ ];
26779
+ for (const [name, value] of twFields) {
26780
+ if (value === void 0 || value === null || value === "") continue;
26781
+ lines.push(`<meta name="${name}" content="${escapeAttr2(value)}" data-vesk-head />`);
26782
+ }
26783
+ }
26784
+ const alt = meta.alternates;
26785
+ if (alt) {
26786
+ if (typeof alt === "object" && typeof alt.canonical === "string") {
26787
+ lines.push(`<link rel="canonical" href="${escapeAttr2(alt.canonical)}" data-vesk-head />`);
26788
+ }
26789
+ const languages = alt.languages;
26790
+ if (languages && typeof languages === "object") {
26791
+ for (const [lang, href] of Object.entries(languages)) {
26792
+ lines.push(`<link rel="alternate" hreflang="${escapeAttr2(lang)}" href="${escapeAttr2(href)}" data-vesk-head />`);
26793
+ }
26794
+ }
26795
+ }
26796
+ return lines.join("\n");
26797
+ }
26798
+ var KNOWN_KEYS;
26799
+ var init_metadata = __esm({
26800
+ "../runtime/src/metadata.ts"() {
26801
+ "use strict";
26802
+ KNOWN_KEYS = /* @__PURE__ */ new Set([
26803
+ "title",
26804
+ "description",
26805
+ "robots",
26806
+ "openGraph",
26807
+ "twitter",
26808
+ "alternates",
26809
+ "themeColor"
26810
+ ]);
26811
+ }
26812
+ });
26813
+
26511
26814
  // ../runtime/src/index-server.ts
26512
26815
  var index_server_exports = {};
26513
26816
  __export(index_server_exports, {
@@ -26569,6 +26872,7 @@ __export(index_server_exports, {
26569
26872
  custom: () => custom,
26570
26873
  defineAction: () => defineAction,
26571
26874
  defineHook: () => defineHook,
26875
+ defineMetadata: () => defineMetadata,
26572
26876
  defineRoute: () => defineRoute,
26573
26877
  derived: () => derived,
26574
26878
  destroy_block: () => destroy_block,
@@ -26596,6 +26900,8 @@ __export(index_server_exports, {
26596
26900
  leaf: () => leaf,
26597
26901
  locals: () => locals,
26598
26902
  maxLength: () => maxLength,
26903
+ mergeMetadata: () => mergeMetadata,
26904
+ metadataToHtml: () => metadataToHtml,
26599
26905
  minLength: () => minLength,
26600
26906
  mutate: () => mutate,
26601
26907
  notFound: () => notFound,
@@ -26616,6 +26922,7 @@ __export(index_server_exports, {
26616
26922
  required: () => required,
26617
26923
  rerenderNode: () => rerenderNode,
26618
26924
  resolveSsrResources: () => resolveSsrResources,
26925
+ resolveTitle: () => resolveTitle,
26619
26926
  resume_block: () => resume_block,
26620
26927
  revalidateComponent: () => revalidateComponent,
26621
26928
  revalidatePath: () => revalidatePath,
@@ -26680,6 +26987,7 @@ var init_index_server = __esm({
26680
26987
  init_primitive();
26681
26988
  init_loading_indicator();
26682
26989
  init_action();
26990
+ init_metadata();
26683
26991
  }
26684
26992
  });
26685
26993
 
@@ -31304,6 +31612,17 @@ function irNodeToHeadHtml(node, ctx2, reconcileable = false) {
31304
31612
  }
31305
31613
  return "";
31306
31614
  }
31615
+ function renderStaticMetadataHtml(source) {
31616
+ if (!source) return "";
31617
+ try {
31618
+ const fn = new Function("defineMetadata", "return (" + source + ")");
31619
+ const meta = fn(defineMetadata);
31620
+ return metadataToHtml(meta);
31621
+ } catch (e) {
31622
+ console.error("vesk: static metadata could not be evaluated:", e instanceof Error ? e.message : e);
31623
+ return "";
31624
+ }
31625
+ }
31307
31626
  function renderHeadHtml(comp, props = {}, scope2 = {}) {
31308
31627
  const tracked2 = collectTrackedNames(comp.body);
31309
31628
  const needed = headNeededNames(comp);
@@ -31471,6 +31790,7 @@ var init_server_head = __esm({
31471
31790
  init_scan();
31472
31791
  init_parser();
31473
31792
  init_client_codegen();
31793
+ init_metadata();
31474
31794
  headRuntimeShims = () => ({
31475
31795
  track: (init) => headCell(init),
31476
31796
  derived: (fn) => headCell(typeof fn === "function" ? fn() : fn),
@@ -32138,6 +32458,7 @@ function compileFile(source, options) {
32138
32458
  const owners = new VskComponentOwners();
32139
32459
  const result = compileFileInternal(source, options?.sourcePath, /* @__PURE__ */ new Set(), owners);
32140
32460
  owners.report("SSR");
32461
+ result.metadataSource = result.ir.metadataSource || null;
32141
32462
  return result;
32142
32463
  }
32143
32464
  function compileFileInternal(source, sourcePath2, seenImportFiles, owners) {
@@ -32240,6 +32561,7 @@ function renderPage(source, componentName, props = {}, registry = /* @__PURE__ *
32240
32561
  if (!renderFn) throw new Error(`Component "${componentName}" not found in source`);
32241
32562
  const fullRegistry = new Map([...registry, ...componentMap]);
32242
32563
  const targetComp = ir.components.find((c) => c.name === componentName);
32564
+ const metadataSource = ir.metadataSource || null;
32243
32565
  const doRender = (ssrProps) => {
32244
32566
  globalThis.__vsk_ssr = true;
32245
32567
  if (!globalThis.__vsk_ssr_token) globalThis.__vsk_ssr_token = Math.random().toString(36).slice(2);
@@ -32258,9 +32580,11 @@ function renderPage(source, componentName, props = {}, registry = /* @__PURE__ *
32258
32580
  }
32259
32581
  return {
32260
32582
  body: bodyHtml2,
32261
- // The component's own scope, so head expressions that read an import
32262
- // resolve (see renderHeadHtml).
32263
- head: renderHeadHtml(targetComp, ssrProps, scopedVesk(renderFn, __vesk)),
32583
+ // A static `export const metadata` wins: it is evaluated in a sealed
32584
+ // sandbox, so it cannot depend on the component's frame resolving
32585
+ // (the failure mode that shipped an empty <title>). Whatever the
32586
+ // page's `<Head>` adds is appended, not lost.
32587
+ head: [renderStaticMetadataHtml(metadataSource), renderHeadHtml(targetComp, ssrProps, scopedVesk(renderFn, __vesk))].filter(Boolean).join("\n"),
32264
32588
  props: ssrProps
32265
32589
  };
32266
32590
  })();
@@ -32271,7 +32595,10 @@ function renderPage(source, componentName, props = {}, registry = /* @__PURE__ *
32271
32595
  } finally {
32272
32596
  delete globalThis.__vsk_ssr;
32273
32597
  }
32274
- const headHtml = targetComp ? renderHeadHtml(targetComp, ssrProps, scopedVesk(renderFn, __vesk)) : "";
32598
+ const headHtml = [
32599
+ renderStaticMetadataHtml(metadataSource),
32600
+ targetComp ? renderHeadHtml(targetComp, ssrProps, scopedVesk(renderFn, __vesk)) : ""
32601
+ ].filter(Boolean).join("\n");
32275
32602
  const pending = globalThis[`__vsk_ssr_promises_${renderToken}`];
32276
32603
  if (pending && pending.length > 0) {
32277
32604
  return (async () => {
@@ -32301,6 +32628,7 @@ function renderPage(source, componentName, props = {}, registry = /* @__PURE__ *
32301
32628
  function clearSsrCells(token) {
32302
32629
  if (!token) return;
32303
32630
  delete globalThis[`__vsk_ssr_promises_${token}`];
32631
+ delete globalThis[`__vsk_ssr_deferred_${token}`];
32304
32632
  delete globalThis[`__vsk_ssr_failures_${token}`];
32305
32633
  dropSsrSlot(token);
32306
32634
  const cells = globalThis.__vsk_ssr_cells;
@@ -32573,6 +32901,7 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
32573
32901
  if (!renderFn) throw new Error(`Component "${componentName}" not found in source`);
32574
32902
  resetVskState(!!options.hydrate, options.markerless !== false);
32575
32903
  const targetComp = ir.components.find((c) => c.name === componentName);
32904
+ const metadataSource = cached?.metadataSource ?? ir.metadataSource ?? null;
32576
32905
  const cssUrls = options.cssUrls || (options.cssUrl ? [options.cssUrl] : []);
32577
32906
  const cssLink = cssUrls.map((u) => ` <link rel="stylesheet" href="${u}" />
32578
32907
  `).join("");
@@ -32586,7 +32915,10 @@ function renderPageStream(source, componentName, props = {}, registry = /* @__PU
32586
32915
  }
32587
32916
  let streamHeadHtml = null;
32588
32917
  if (targetComp) {
32589
- let headHtml = renderHeadHtml(targetComp, ssrProps, scopedVesk(renderFn, __vesk));
32918
+ let headHtml = [
32919
+ renderStaticMetadataHtml(metadataSource),
32920
+ renderHeadHtml(targetComp, ssrProps, scopedVesk(renderFn, __vesk))
32921
+ ].filter(Boolean).join("\n");
32590
32922
  if (options.pageHead) {
32591
32923
  const merged = mergeHeadHtml(options.pageHead, headHtml);
32592
32924
  headHtml = merged.html;
@@ -39227,7 +39559,7 @@ __export(typecheck_exports, {
39227
39559
  typecheckProject: () => typecheckProject
39228
39560
  });
39229
39561
  import { readFileSync as readFileSync39, readdirSync as readdirSync14, statSync as statSync22 } from "node:fs";
39230
- import { join as join26, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
39562
+ import { join as join27, dirname as dirname27, normalize, relative as relative8, resolve as resolve39, sep as sep7 } from "node:path";
39231
39563
  import * as ts8 from "typescript";
39232
39564
  function walkProjectFiles(projectRoot) {
39233
39565
  const code = [];
@@ -39240,7 +39572,7 @@ function walkProjectFiles(projectRoot) {
39240
39572
  return;
39241
39573
  }
39242
39574
  for (const e of entries) {
39243
- const p = join26(dir, e);
39575
+ const p = join27(dir, e);
39244
39576
  let st;
39245
39577
  try {
39246
39578
  st = statSync22(p);
@@ -39295,8 +39627,8 @@ function checkStructureFile(appDir, file) {
39295
39627
  return null;
39296
39628
  }
39297
39629
  function createTypecheckHost(projectRoot, appDir, vskFiles) {
39298
- const ambientPath = join26(appDir, "__vesk_ambient.d.ts");
39299
- const overridePath = join26(appDir, "__vesk_runtime_override.d.ts");
39630
+ const ambientPath = join27(appDir, "__vesk_ambient.d.ts");
39631
+ const overridePath = join27(appDir, "__vesk_runtime_override.d.ts");
39300
39632
  const cached = /* @__PURE__ */ new Map();
39301
39633
  const scriptKindFor = (file) => file.endsWith(".vsk") ? ts8.ScriptKind.TSX : ts8.ScriptKind.TS;
39302
39634
  const host = {
@@ -39366,7 +39698,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39366
39698
  directoryExists: (dir) => ts8.sys.directoryExists(dir),
39367
39699
  getDirectories: (dir) => {
39368
39700
  try {
39369
- return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join26(dir, d.name));
39701
+ return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join27(dir, d.name));
39370
39702
  } catch {
39371
39703
  return [];
39372
39704
  }
@@ -39378,7 +39710,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39378
39710
  return moduleLiterals.map(({ text }) => {
39379
39711
  if (text.endsWith(".vsk")) {
39380
39712
  const aliased = text.startsWith(".") ? null : resolveAliasModule(text, dirname27(containingFile));
39381
- const abs = normalize(aliased ?? join26(dirname27(containingFile), text));
39713
+ const abs = normalize(aliased ?? join27(dirname27(containingFile), text));
39382
39714
  return {
39383
39715
  resolvedModule: {
39384
39716
  resolvedFileName: abs + ".d.ts",
@@ -39389,7 +39721,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
39389
39721
  };
39390
39722
  }
39391
39723
  if (text.endsWith(".css")) {
39392
- const abs = normalize(join26(dirname27(containingFile), text));
39724
+ const abs = normalize(join27(dirname27(containingFile), text));
39393
39725
  return {
39394
39726
  resolvedModule: {
39395
39727
  resolvedFileName: abs + ".d.ts",
@@ -39436,7 +39768,7 @@ function sourcePosition(source, offset2) {
39436
39768
  return { line, character: bounded - lineStart + 1 };
39437
39769
  }
39438
39770
  function typecheckProject(projectRoot, opts = {}) {
39439
- const appDir = opts.appDir ?? join26(projectRoot, "app");
39771
+ const appDir = opts.appDir ?? join27(projectRoot, "app");
39440
39772
  const vskFiles = /* @__PURE__ */ new Map();
39441
39773
  const parseErrors = [];
39442
39774
  const warnings = [];
@@ -39475,8 +39807,8 @@ function typecheckProject(projectRoot, opts = {}) {
39475
39807
  }
39476
39808
  rootNames.push(f);
39477
39809
  }
39478
- const ambientPath = join26(appDir, "__vesk_ambient.d.ts");
39479
- const overridePath = join26(appDir, "__vesk_runtime_override.d.ts");
39810
+ const ambientPath = join27(appDir, "__vesk_ambient.d.ts");
39811
+ const overridePath = join27(appDir, "__vesk_runtime_override.d.ts");
39480
39812
  rootNames.push(ambientPath);
39481
39813
  rootNames.push(overridePath);
39482
39814
  const options = {
@@ -45422,7 +45754,7 @@ __export(codemods_exports, {
45422
45754
  compareCore: () => compareCore
45423
45755
  });
45424
45756
  import { readFileSync as readFileSync40, existsSync as existsSync43 } from "node:fs";
45425
- import { join as join27 } from "node:path";
45757
+ import { join as join28 } from "node:path";
45426
45758
  import { walk as walk8 } from "zimmerframe";
45427
45759
  function safeParse(source, filePath) {
45428
45760
  try {
@@ -45442,7 +45774,7 @@ function isVskFile(filePath) {
45442
45774
  }
45443
45775
  function typesPackageExports(projectDir) {
45444
45776
  const candidates = [
45445
- projectDir ? join27(projectDir, "node_modules", "@vesk", "types", "dist", "index.d.ts") : null,
45777
+ projectDir ? join28(projectDir, "node_modules", "@vesk", "types", "dist", "index.d.ts") : null,
45446
45778
  new URL("../../types/dist/index.d.ts", import.meta.url).pathname
45447
45779
  ].filter((p) => typeof p === "string" && existsSync43(p));
45448
45780
  for (const path of candidates) {
@@ -45572,10 +45904,10 @@ __export(migrate_exports, {
45572
45904
  runMigrate: () => runMigrate
45573
45905
  });
45574
45906
  import { readFileSync as readFileSync41, writeFileSync as writeFileSync21, existsSync as existsSync44, statSync as statSync23, readdirSync as readdirSync15 } from "node:fs";
45575
- import { join as join28, relative as relative9, extname as extname9 } from "node:path";
45907
+ import { join as join29, relative as relative9, extname as extname9 } from "node:path";
45576
45908
  function detectInstalledVersion(projectDir, cliVersion) {
45577
45909
  for (const pkg of ["@vesk/vesk-cli", "@vesk/adapter", "@vesk/compiler"]) {
45578
- const p = join28(projectDir, "node_modules", pkg, "package.json");
45910
+ const p = join29(projectDir, "node_modules", pkg, "package.json");
45579
45911
  if (!existsSync44(p)) continue;
45580
45912
  try {
45581
45913
  const version2 = JSON.parse(readFileSync41(p, "utf-8")).version;
@@ -45595,7 +45927,7 @@ function collectTargets(dir, root3 = dir) {
45595
45927
  }
45596
45928
  for (const entry of entries.sort()) {
45597
45929
  if (SKIP_DIRS2.has(entry)) continue;
45598
- const full = join28(dir, entry);
45930
+ const full = join29(dir, entry);
45599
45931
  let st;
45600
45932
  try {
45601
45933
  st = statSync23(full);
@@ -45630,7 +45962,7 @@ function runMigrate(options) {
45630
45962
  return report;
45631
45963
  }
45632
45964
  for (const relPath of collectTargets(options.projectDir)) {
45633
- const abs = join28(options.projectDir, relPath);
45965
+ const abs = join29(options.projectDir, relPath);
45634
45966
  const ctx2 = { filePath: abs, displayPath: relPath, projectDir: options.projectDir };
45635
45967
  if (!existsSync44(abs)) continue;
45636
45968
  let source;
@@ -45676,7 +46008,7 @@ var init_migrate = __esm({
45676
46008
 
45677
46009
  // src/index.ts
45678
46010
  import { readFileSync as readFileSync42, writeFileSync as writeFileSync22, mkdirSync as mkdirSync20, existsSync as existsSync45 } from "fs";
45679
- import { resolve as resolve40, join as join29 } from "path";
46011
+ import { resolve as resolve40, join as join30 } from "path";
45680
46012
  import { fileURLToPath as fileURLToPath9 } from "url";
45681
46013
 
45682
46014
  // ../adapter/dist/load-config.js
@@ -46255,7 +46587,7 @@ function setRuntimeModule2(mod) {
46255
46587
 
46256
46588
  // ../adapter/dist/index.js
46257
46589
  import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, existsSync as existsSync22, readFileSync as readFileSync21 } from "node:fs";
46258
- import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename3 } from "node:path";
46590
+ import { resolve as resolve21, dirname as dirname16, relative as relative4, basename as basename3, join as join15 } from "node:path";
46259
46591
  import { fileURLToPath as fileURLToPath5 } from "node:url";
46260
46592
 
46261
46593
  // ../adapter/src/runtime-bundle.ts
@@ -46551,6 +46883,7 @@ function precompileFileInternal(source, sourcePath2, seenImportFiles) {
46551
46883
  setVskHydrate(false);
46552
46884
  }
46553
46885
  const topLevelCode = transformTopLevelForActions(ir.topLevelCode, "server");
46886
+ const metadataSource = ir.metadataSource || null;
46554
46887
  const runtimeImports = ir.imports.slice();
46555
46888
  const collector = { keysByAbs: /* @__PURE__ */ new Map(), modules: [] };
46556
46889
  const bindings = sourcePath2 !== void 0 ? collectModuleBundle(ir.imports, dirname6(sourcePath2), collector) : [];
@@ -46578,7 +46911,10 @@ function precompileFileInternal(source, sourcePath2, seenImportFiles) {
46578
46911
  modules: collector.modules,
46579
46912
  bindings,
46580
46913
  topLevelCode,
46581
- subFiles
46914
+ subFiles,
46915
+ // A static `export const metadata` rides along so a serverless function can
46916
+ // serialize the head without the `.vsk` source being present at all.
46917
+ ...metadataSource ? { metadataSource } : {}
46582
46918
  };
46583
46919
  }
46584
46920
 
@@ -47541,14 +47877,17 @@ function collectEventsFile(appDir) {
47541
47877
 
47542
47878
  // ../adapter/src/events.ts
47543
47879
  var buildId2 = 0;
47544
- function buildEntry(sourcePath2) {
47880
+ function buildEventsEntry(sourcePath2) {
47545
47881
  return [
47546
47882
  `import * as __events from ${JSON.stringify(sourcePath2)};`,
47547
47883
  "",
47548
47884
  "const __store = () => (globalThis.__vesk_server_ctx ||= {});",
47549
47885
  "",
47550
47886
  "const __handlers = {};",
47551
- "for (const __name of ['onStart', 'onRequest', 'onStop']) {",
47887
+ // `onError` joins the server events: production has no plugin objects, so
47888
+ // this is the seam an error reporter actually uses there (plugins carry
47889
+ // their own `onError` in dev, where plugin objects do exist).
47890
+ "for (const __name of ['onStart', 'onRequest', 'onStop', 'onError']) {",
47552
47891
  " const __fn = __events[__name];",
47553
47892
  " if (typeof __fn === 'function') __handlers[__name] = __fn;",
47554
47893
  "}",
@@ -47589,16 +47928,26 @@ function buildEntry(sourcePath2) {
47589
47928
  "export const onStart = __handlers.onStart;",
47590
47929
  "export const onRequest = __handlers.onRequest;",
47591
47930
  "export const onStop = __handlers.onStop;",
47931
+ "export const onError = __handlers.onError;",
47592
47932
  ""
47593
47933
  ].join("\n");
47594
47934
  }
47935
+ async function executeError(err, base, mod) {
47936
+ const fn = mod?.onError;
47937
+ if (typeof fn !== "function") return;
47938
+ try {
47939
+ await fn(err, base);
47940
+ } catch (e) {
47941
+ console.error("vesk: _events onError threw and was ignored:", e instanceof Error ? e.message : e);
47942
+ }
47943
+ }
47595
47944
  async function compileEvents(appDir, outDir) {
47596
47945
  const sourcePath2 = collectEventsFile(appDir);
47597
47946
  if (!sourcePath2) return false;
47598
47947
  const serverDir = resolve9(outDir, "server");
47599
47948
  mkdirSync2(serverDir, { recursive: true });
47600
47949
  const entryFile = resolve9(serverDir, `.events-entry-${buildId2++}.mjs`);
47601
- writeFileSync3(entryFile, buildEntry(sourcePath2), "utf-8");
47950
+ writeFileSync3(entryFile, buildEventsEntry(sourcePath2), "utf-8");
47602
47951
  try {
47603
47952
  const result = await build({
47604
47953
  entryPoints: [entryFile],
@@ -48668,6 +49017,38 @@ import { resolve as resolve13, extname as extname3, dirname as dirname10, basena
48668
49017
  import { createServer } from "node:http";
48669
49018
  import { fileURLToPath as fileURLToPath3 } from "node:url";
48670
49019
  init_server_utils();
49020
+
49021
+ // ../adapter/src/error-report.ts
49022
+ var hooks = [];
49023
+ var reported = /* @__PURE__ */ new WeakSet();
49024
+ async function reportServerError(err, options) {
49025
+ if (options.dedupe !== false && err && typeof err === "object") {
49026
+ if (reported.has(err)) return;
49027
+ reported.add(err);
49028
+ }
49029
+ const cfg = options.buildConfig || null;
49030
+ const ctx2 = {
49031
+ url: options.url,
49032
+ routePath: options.routePath,
49033
+ target: options.target,
49034
+ status: options.status ?? 500,
49035
+ durationMs: options.durationMs,
49036
+ version: typeof cfg?.veskVersion === "string" ? cfg.veskVersion : void 0,
49037
+ buildId: typeof cfg?.buildId === "string" ? cfg.buildId : void 0,
49038
+ errorName: err instanceof Error ? err.name : typeof err,
49039
+ message: err instanceof Error ? err.message : String(err),
49040
+ stack: err instanceof Error ? err.stack : void 0
49041
+ };
49042
+ for (const hook of hooks) {
49043
+ try {
49044
+ await hook(err, ctx2);
49045
+ } catch (e) {
49046
+ console.error("vesk: an onError hook threw and was ignored:", e?.message ?? e);
49047
+ }
49048
+ }
49049
+ }
49050
+
49051
+ // ../adapter/src/prod-server.ts
48671
49052
  init_paths();
48672
49053
 
48673
49054
  // ../adapter/src/load-config.ts
@@ -49191,6 +49572,16 @@ async function startProdServer(outDir, options) {
49191
49572
  return;
49192
49573
  }
49193
49574
  console.error("vesk ssr error:", err.message);
49575
+ await reportServerError(err, {
49576
+ url: url.pathname + url.search,
49577
+ routePath: route.path,
49578
+ target: "node",
49579
+ status: 500,
49580
+ buildConfig
49581
+ });
49582
+ if (eventsMod) {
49583
+ await executeError(err, { url: url.href, routePath: route.path, target: "node", status: 500 }, eventsMod);
49584
+ }
49194
49585
  const errPath = resolve13(appDir, "error.vsk");
49195
49586
  let errorHtml = null;
49196
49587
  if (existsSync15(errPath)) {
@@ -49255,6 +49646,9 @@ init_parser();
49255
49646
  init_paths();
49256
49647
 
49257
49648
  // ../adapter/dist/index.js
49649
+ function PACKAGES_DIR_SELF() {
49650
+ return resolve21(dirname16(fileURLToPath5(import.meta.url)), "..");
49651
+ }
49258
49652
  var __dirname6 = dirname16(fileURLToPath5(import.meta.url));
49259
49653
  async function resolveCompilerApi(name) {
49260
49654
  const monorepoSrc = resolve21(__dirname6, "..", "..", "compiler", "src");
@@ -49559,6 +49953,9 @@ async function build2(appDir, options) {
49559
49953
  }
49560
49954
  markPhase("ssg+images+seo");
49561
49955
  const manifest = generateManifest(routeTree, ssrRoutes, apiRoutes, prerenderedRoutes, middlewareEnabled, actionMap, pluginHeadExtra, hasEvents);
49956
+ const buildId3 = emittedAssets.map((a) => a.hash).join("-");
49957
+ manifest.buildId = buildId3.slice(0, 32);
49958
+ manifest.veskVersion = JSON.parse(readFileSync21(join15(PACKAGES_DIR_SELF(), "package.json"), "utf-8")).version;
49562
49959
  manifest.assets = {
49563
49960
  hashed,
49564
49961
  client: { file: clientFileName, url: clientUrl, hash: clientAsset.hash, bytes: clientAsset.bytes, integrity: clientAsset.integrity },
@@ -49613,7 +50010,7 @@ init_seo_audit();
49613
50010
 
49614
50011
  // src/dev-server.ts
49615
50012
  import { readFileSync as readFileSync38, watch, statSync as statSync21, existsSync as existsSync42, readdirSync as readdirSync13 } from "node:fs";
49616
- import { resolve as resolve38, extname as extname8, join as join25, dirname as dirname26 } from "node:path";
50013
+ import { resolve as resolve38, extname as extname8, join as join26, dirname as dirname26 } from "node:path";
49617
50014
  import { createServer as createServer2 } from "node:http";
49618
50015
  import { WebSocketServer as WebSocketServer2 } from "ws";
49619
50016
 
@@ -52263,7 +52660,7 @@ init_tokens();
52263
52660
  init_scan();
52264
52661
  init_strip_ts();
52265
52662
  import { readdirSync as readdirSync7, statSync as statSync12, existsSync as existsSync23, readFileSync as readFileSync22 } from "fs";
52266
- import { join as join15, relative as relative5, basename as basename4 } from "path";
52663
+ import { join as join16, relative as relative5, basename as basename4 } from "path";
52267
52664
  function collapseSlashes2(p) {
52268
52665
  let out = "";
52269
52666
  let prevSlash = false;
@@ -52366,7 +52763,7 @@ function scanComponents(componentsDir) {
52366
52763
  return;
52367
52764
  }
52368
52765
  for (const entry of entries) {
52369
- const full = join15(dir, entry);
52766
+ const full = join16(dir, entry);
52370
52767
  let stat;
52371
52768
  try {
52372
52769
  stat = statSync12(full);
@@ -52467,7 +52864,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
52467
52864
  seg = segName;
52468
52865
  }
52469
52866
  const fullPath = seg ? (parentPath === "/" ? "/" : parentPath + "/") + seg : parentPath || "/";
52470
- const isStandalone = hasLayout ? isStandaloneLayoutFile(join15(dir, "layout.vsk")) : false;
52867
+ const isStandalone = hasLayout ? isStandaloneLayoutFile(join16(dir, "layout.vsk")) : false;
52471
52868
  const node = {
52472
52869
  path: seg,
52473
52870
  fullPath: collapseSlashes2(fullPath) || "/",
@@ -52488,7 +52885,7 @@ function scanDirectory(rootDir, dir, parentPath, options) {
52488
52885
  standalone: isStandalone ? true : void 0
52489
52886
  };
52490
52887
  for (const entry of entries) {
52491
- const entryPath = join15(dir, entry);
52888
+ const entryPath = join16(dir, entry);
52492
52889
  let entryStat;
52493
52890
  try {
52494
52891
  entryStat = statSync12(entryPath);
@@ -52540,19 +52937,19 @@ function collectSources(tree) {
52540
52937
  function walk9(nodes) {
52541
52938
  for (const node of nodes) {
52542
52939
  if (node.page)
52543
- map.set(node.page, join15(node.sourceDir, "page.vsk"));
52940
+ map.set(node.page, join16(node.sourceDir, "page.vsk"));
52544
52941
  if (node.layout)
52545
- map.set(node.layout, join15(node.sourceDir, "layout.vsk"));
52942
+ map.set(node.layout, join16(node.sourceDir, "layout.vsk"));
52546
52943
  if (node.loading)
52547
- map.set(node.loading, join15(node.sourceDir, "loading.vsk"));
52944
+ map.set(node.loading, join16(node.sourceDir, "loading.vsk"));
52548
52945
  if (node.error)
52549
- map.set(node.error, join15(node.sourceDir, "error.vsk"));
52946
+ map.set(node.error, join16(node.sourceDir, "error.vsk"));
52550
52947
  if (node.notFound)
52551
- map.set(node.notFound, join15(node.sourceDir, "not-found.vsk"));
52948
+ map.set(node.notFound, join16(node.sourceDir, "not-found.vsk"));
52552
52949
  if (node.offline)
52553
- map.set(node.offline, join15(node.sourceDir, "offline.vsk"));
52950
+ map.set(node.offline, join16(node.sourceDir, "offline.vsk"));
52554
52951
  if (node.network)
52555
- map.set(node.network, join15(node.sourceDir, "network.vsk"));
52952
+ map.set(node.network, join16(node.sourceDir, "network.vsk"));
52556
52953
  walk9(node.children);
52557
52954
  }
52558
52955
  }
@@ -52654,7 +53051,7 @@ function matchUrl(tree, pathname) {
52654
53051
 
52655
53052
  // ../compiler/dist/api-routes.js
52656
53053
  import { readdirSync as readdirSync8, statSync as statSync13, existsSync as existsSync24 } from "fs";
52657
- import { join as join16 } from "path";
53054
+ import { join as join17 } from "path";
52658
53055
  init_server_utils();
52659
53056
  function basename5(p) {
52660
53057
  const idx = p.lastIndexOf("/");
@@ -52691,7 +53088,7 @@ function scanApiDir(rootDir, dir, parentPath) {
52691
53088
  return nodes;
52692
53089
  if (isRouteGroup) {
52693
53090
  for (const entry of entries) {
52694
- const entryPath = join16(dir, entry);
53091
+ const entryPath = join17(dir, entry);
52695
53092
  let entryStat;
52696
53093
  try {
52697
53094
  entryStat = statSync13(entryPath);
@@ -52721,11 +53118,11 @@ function scanApiDir(rootDir, dir, parentPath) {
52721
53118
  fullPath: collapseSlashes(fullPath) || "/",
52722
53119
  isDynamic,
52723
53120
  isCatchAll,
52724
- filePath: hasRoute && routeFileName ? join16(dir, routeFileName) : null,
53121
+ filePath: hasRoute && routeFileName ? join17(dir, routeFileName) : null,
52725
53122
  children: []
52726
53123
  };
52727
53124
  for (const entry of entries) {
52728
- const entryPath = join16(dir, entry);
53125
+ const entryPath = join17(dir, entry);
52729
53126
  let entryStat;
52730
53127
  try {
52731
53128
  entryStat = statSync13(entryPath);
@@ -53255,11 +53652,11 @@ async function executeMiddlewareChain(chain, request, params, options = {}) {
53255
53652
 
53256
53653
  // ../compiler/dist/events.js
53257
53654
  import { existsSync as existsSync26 } from "fs";
53258
- import { join as join17 } from "path";
53655
+ import { join as join18 } from "path";
53259
53656
  var EVENTS_FILE_NAMES2 = ["_events.ts", "_events.js"];
53260
53657
  function collectEventsFile2(appDir) {
53261
53658
  for (const name of EVENTS_FILE_NAMES2) {
53262
- const candidate = join17(appDir, name);
53659
+ const candidate = join18(appDir, name);
53263
53660
  if (existsSync26(candidate))
53264
53661
  return candidate;
53265
53662
  }
@@ -53291,7 +53688,7 @@ async function runEventHandlers(handlers, name, ctx2) {
53291
53688
 
53292
53689
  // ../compiler/dist/md-inline.js
53293
53690
  import { readFileSync as readFileSync23, existsSync as existsSync27 } from "node:fs";
53294
- import { dirname as dirname17, join as join18, resolve as resolve23 } from "node:path";
53691
+ import { dirname as dirname17, join as join19, resolve as resolve23 } from "node:path";
53295
53692
  var MD_EXT_MARKER2 = ".md";
53296
53693
  function looksLikeMarkdownPath2(value) {
53297
53694
  const v = value.trim();
@@ -53368,10 +53765,10 @@ function resolveMdPath2(specifier, importerDir, roots) {
53368
53765
  }
53369
53766
  if (spec.startsWith("/")) {
53370
53767
  for (const root3 of roots) {
53371
- const pub = join18(root3, "public", spec);
53768
+ const pub = join19(root3, "public", spec);
53372
53769
  if (existsSync27(pub))
53373
53770
  return pub;
53374
- const direct = join18(root3, spec);
53771
+ const direct = join19(root3, spec);
53375
53772
  if (existsSync27(direct))
53376
53773
  return direct;
53377
53774
  }
@@ -53385,7 +53782,7 @@ function guessProjectRoots2(dir) {
53385
53782
  let cur = dir;
53386
53783
  for (let i = 0; i < 6; i++) {
53387
53784
  roots.push(cur);
53388
- if (existsSync27(join18(cur, "package.json")))
53785
+ if (existsSync27(join19(cur, "package.json")))
53389
53786
  break;
53390
53787
  const parent = dirname17(cur);
53391
53788
  if (parent === cur)
@@ -53397,7 +53794,7 @@ function guessProjectRoots2(dir) {
53397
53794
 
53398
53795
  // ../adapter/dist/client-bundle.js
53399
53796
  import { readFileSync as readFileSync24, existsSync as existsSync28, writeFileSync as writeFileSync13, unlinkSync as unlinkSync4, statSync as statSync14, rmSync as rmSync4, mkdtempSync as mkdtempSync2, mkdirSync as mkdirSync12 } from "node:fs";
53400
- import { resolve as resolve24, join as join19, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
53797
+ import { resolve as resolve24, join as join20, dirname as dirname18, relative as relative6, sep as sep3 } from "node:path";
53401
53798
  import { fileURLToPath as fileURLToPath6 } from "node:url";
53402
53799
  import { tmpdir as tmpdir3 } from "node:os";
53403
53800
 
@@ -53480,8 +53877,8 @@ function findRuntimeSrc3(appDir) {
53480
53877
  resolve24(appDir, "node_modules", "@vesk/runtime")
53481
53878
  ];
53482
53879
  for (const base of candidates) {
53483
- for (const dir of [base, join19(base, "dist")]) {
53484
- if (existsSync28(join19(dir, "index-client.js")))
53880
+ for (const dir of [base, join20(base, "dist")]) {
53881
+ if (existsSync28(join20(dir, "index-client.js")))
53485
53882
  return dir;
53486
53883
  }
53487
53884
  }
@@ -54133,8 +54530,8 @@ ${body}
54133
54530
  continue;
54134
54531
  let finalCode;
54135
54532
  if (entry.imports) {
54136
- const tmpBase = mkdtempSync2(join19(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
54137
- const tmpFile = join19(tmpBase, "entry.js");
54533
+ const tmpBase = mkdtempSync2(join20(resolve24(appDir, ".."), "tmp-vesk-chunk-"));
54534
+ const tmpFile = join20(tmpBase, "entry.js");
54138
54535
  const toBundle = `const __components = globalThis.__components || (globalThis.__components = {});
54139
54536
  const __hydrators = globalThis.__hydrators || (globalThis.__hydrators = {});
54140
54537
  ${entry.code}
@@ -54286,7 +54683,7 @@ function buildRuntimeCode2(runtimeDir) {
54286
54683
  ];
54287
54684
  let code = "";
54288
54685
  for (const f of runtimeFiles) {
54289
- const p = join19(runtimeDir, f);
54686
+ const p = join20(runtimeDir, f);
54290
54687
  if (existsSync28(p)) {
54291
54688
  let src2 = readFileSync24(p, "utf-8");
54292
54689
  src2 = stripTypes2(src2);
@@ -54300,7 +54697,7 @@ ${src2}
54300
54697
  `;
54301
54698
  }
54302
54699
  }
54303
- const indexSrc = readFileSync24(join19(runtimeDir, "index-client.js"), "utf-8");
54700
+ const indexSrc = readFileSync24(join20(runtimeDir, "index-client.js"), "utf-8");
54304
54701
  const exportNames = stripTypes2(indexSrc).match(/export\s*\{\s*([^}]+)\s*\}\s*from/g)?.flatMap((m) => m.replace(/export\s*\{\s*|\s*\}\s*from/g, "").split(",").map((s) => s.trim())) || [];
54305
54702
  code += "// --- exports ---\n";
54306
54703
  for (const name of [...new Set(exportNames)]) {
@@ -54311,7 +54708,7 @@ ${src2}
54311
54708
  return code;
54312
54709
  }
54313
54710
  function runtimeExportNames2(runtimeDir) {
54314
- const indexSrc = readFileSync24(join19(runtimeDir, "index-client.js"), "utf-8");
54711
+ const indexSrc = readFileSync24(join20(runtimeDir, "index-client.js"), "utf-8");
54315
54712
  const names = /* @__PURE__ */ new Set();
54316
54713
  for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
54317
54714
  for (const raw2 of m[1].split(",")) {
@@ -54327,7 +54724,7 @@ function esbuildPath2(p) {
54327
54724
  return sep3 === "/" ? p : p.split(sep3).join("/");
54328
54725
  }
54329
54726
  function runtimeTreeShakeEntry2() {
54330
- return join19(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
54727
+ return join20(tmpdir3(), "vesk-runtime-tree-shake", RUNTIME_ENTRY2);
54331
54728
  }
54332
54729
  var treeShakeQueue2 = Promise.resolve();
54333
54730
  function buildTreeShakenRuntime2(runtimeDir, usedNames) {
@@ -54344,7 +54741,7 @@ async function buildTreeShakenRuntimeNow2(runtimeDir, usedNames) {
54344
54741
  return buildRuntimeCode2(runtimeDir);
54345
54742
  }
54346
54743
  const entry = runtimeTreeShakeEntry2();
54347
- const indexClient = esbuildPath2(join19(runtimeDir, "index-client.js"));
54744
+ const indexClient = esbuildPath2(join20(runtimeDir, "index-client.js"));
54348
54745
  try {
54349
54746
  try {
54350
54747
  mkdirSync12(dirname18(entry), { recursive: true });
@@ -54583,7 +54980,7 @@ import { resolve as resolve28 } from "node:path";
54583
54980
  // ../adapter/dist/plugins.js
54584
54981
  init_paths();
54585
54982
  import { readFileSync as readFileSync26, writeFileSync as writeFileSync14, existsSync as existsSync30, mkdirSync as mkdirSync13, statSync as statSync16 } from "node:fs";
54586
- import { resolve as resolve26, dirname as dirname19, join as join20, extname as extname7, basename as basename6 } from "node:path";
54983
+ import { resolve as resolve26, dirname as dirname19, join as join21, extname as extname7, basename as basename6 } from "node:path";
54587
54984
  import { createRequire as createRequire6 } from "node:module";
54588
54985
  import { spawn as spawn2 } from "node:child_process";
54589
54986
  var PLUGIN_STATE_FILENAME2 = "plugins.json";
@@ -54643,7 +55040,7 @@ function resolvePackage2(appDir, pkg) {
54643
55040
  const seen = /* @__PURE__ */ new Set();
54644
55041
  while (cur && cur !== dirname19(cur) && !seen.has(cur)) {
54645
55042
  seen.add(cur);
54646
- const candidate = join20(cur, "package.json");
55043
+ const candidate = join21(cur, "package.json");
54647
55044
  if (existsSync30(candidate)) {
54648
55045
  pkgJsonPath = candidate;
54649
55046
  break;
@@ -54672,7 +55069,7 @@ function resolvePackage2(appDir, pkg) {
54672
55069
  }
54673
55070
  }
54674
55071
  if (localPath) {
54675
- const localJson = join20(localPath, "package.json");
55072
+ const localJson = join21(localPath, "package.json");
54676
55073
  let json = null;
54677
55074
  if (existsSync30(localJson)) {
54678
55075
  json = readJsonFile2(localJson);
@@ -55560,7 +55957,7 @@ var __internals2 = {
55560
55957
  // ../adapter/dist/dev-config.js
55561
55958
  import { existsSync as existsSync31, readFileSync as readFileSync27, writeFileSync as writeFileSync15, mkdirSync as mkdirSync14, mkdtempSync as mkdtempSync3, rmSync as rmSync5 } from "node:fs";
55562
55959
  import { tmpdir as tmpdir4 } from "node:os";
55563
- import { resolve as resolve27, dirname as dirname20, join as join21 } from "node:path";
55960
+ import { resolve as resolve27, dirname as dirname20, join as join22 } from "node:path";
55564
55961
  init_parser();
55565
55962
  function findConfigFile2(projectDir) {
55566
55963
  const ts9 = resolve27(projectDir, "vesk.config.ts");
@@ -55588,9 +55985,9 @@ async function parseConfigSource(source, isTs, projectDir) {
55588
55985
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
55589
55986
  ` + js;
55590
55987
  }
55591
- const base = projectDir ? (mkdirSync14(join21(projectDir, ".vesk"), { recursive: true }), join21(projectDir, ".vesk")) : void 0;
55592
- const dir = base ? mkdtempSync3(join21(base, "cfg-")) : mkdtempSync3(join21(tmpdir4(), "vesk-cfg-"));
55593
- const tmpFile = join21(dir, "config.mjs");
55988
+ const base = projectDir ? (mkdirSync14(join22(projectDir, ".vesk"), { recursive: true }), join22(projectDir, ".vesk")) : void 0;
55989
+ const dir = base ? mkdtempSync3(join22(base, "cfg-")) : mkdtempSync3(join22(tmpdir4(), "vesk-cfg-"));
55990
+ const tmpFile = join22(dir, "config.mjs");
55594
55991
  try {
55595
55992
  writeFileSync15(tmpFile, js, "utf-8");
55596
55993
  globalThis.__vesk_inject = {
@@ -56900,7 +57297,7 @@ function produceDiagnostics(input) {
56900
57297
 
56901
57298
  // ../agentic/dist/checkpoints.js
56902
57299
  import { existsSync as existsSync33, mkdirSync as mkdirSync15, readFileSync as readFileSync29, writeFileSync as writeFileSync16, statSync as statSync18, unlinkSync as unlinkSync5, rmSync as rmSync6, renameSync } from "node:fs";
56903
- import { join as join22, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
57300
+ import { join as join23, resolve as resolve29, dirname as dirname21, sep as sep5 } from "node:path";
56904
57301
  import { randomUUID as nodeRandomUUID } from "node:crypto";
56905
57302
  function generateId() {
56906
57303
  try {
@@ -57033,16 +57430,16 @@ var CheckpointManager = class {
57033
57430
  }
57034
57431
  };
57035
57432
  function getAgenticDir(projectDir) {
57036
- return join22(resolve29(projectDir), ".vesk", "agentic");
57433
+ return join23(resolve29(projectDir), ".vesk", "agentic");
57037
57434
  }
57038
57435
  function getHistoryPath(projectDir) {
57039
- return join22(getAgenticDir(projectDir), "history.json");
57436
+ return join23(getAgenticDir(projectDir), "history.json");
57040
57437
  }
57041
57438
  function getCheckpointDir(projectDir, id) {
57042
- return join22(getAgenticDir(projectDir), "checkpoints", id);
57439
+ return join23(getAgenticDir(projectDir), "checkpoints", id);
57043
57440
  }
57044
57441
  function getCheckpointPath(projectDir, id) {
57045
- return join22(getCheckpointDir(projectDir, id), "checkpoint.json");
57442
+ return join23(getCheckpointDir(projectDir, id), "checkpoint.json");
57046
57443
  }
57047
57444
  function ensureDir(dir) {
57048
57445
  mkdirSync15(dir, { recursive: true });
@@ -57122,7 +57519,7 @@ function createCheckpoint(projectDir, message, changes = {}, buildResult) {
57122
57519
  };
57123
57520
  const agenticDir = getAgenticDir(projectDir);
57124
57521
  ensureDir(agenticDir);
57125
- ensureDir(join22(agenticDir, "checkpoints"));
57522
+ ensureDir(join23(agenticDir, "checkpoints"));
57126
57523
  const cpDir = getCheckpointDir(projectDir, id);
57127
57524
  ensureDir(cpDir);
57128
57525
  writeJsonAtomic(getCheckpointPath(projectDir, id), checkpoint);
@@ -58627,7 +59024,7 @@ var Agent = class {
58627
59024
 
58628
59025
  // ../agentic/dist/tools/vesk.js
58629
59026
  import { existsSync as existsSync36, readFileSync as readFileSync32, writeFileSync as writeFileSync18, mkdirSync as mkdirSync17, readdirSync as readdirSync10, statSync as statSync19 } from "node:fs";
58630
- import { resolve as resolve32, join as join23, dirname as dirname23, sep as sep6 } from "node:path";
59027
+ import { resolve as resolve32, join as join24, dirname as dirname23, sep as sep6 } from "node:path";
58631
59028
  function resolveWithin3(baseDir, relPath) {
58632
59029
  const base = resolve32(baseDir);
58633
59030
  const target = resolve32(baseDir, relPath);
@@ -58689,7 +59086,7 @@ function findConfigFile3(projectDir) {
58689
59086
  return { path: null, isTs: false };
58690
59087
  }
58691
59088
  function checkpointDir(veskDir) {
58692
- return join23(resolve32(veskDir), "checkpoints");
59089
+ return join24(resolve32(veskDir), "checkpoints");
58693
59090
  }
58694
59091
  function findMatchingBrace2(src2, openIdx) {
58695
59092
  let inStr = null;
@@ -59304,7 +59701,7 @@ function createVeskTools(deps) {
59304
59701
  const dir = checkpointDir(veskDir);
59305
59702
  mkdirSync17(dir, { recursive: true });
59306
59703
  const id = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
59307
- const file = join23(dir, `${id}.json`);
59704
+ const file = join24(dir, `${id}.json`);
59308
59705
  const check = resolveWithin3(dir, `${id}.json`);
59309
59706
  if (!check)
59310
59707
  return jsonError("path escapes project root");
@@ -59353,7 +59750,7 @@ function createVeskTools(deps) {
59353
59750
  } catch {
59354
59751
  }
59355
59752
  const dir = checkpointDir(veskDir);
59356
- const file = join23(dir, `${checkpointId}.json`);
59753
+ const file = join24(dir, `${checkpointId}.json`);
59357
59754
  const contained = resolveWithin3(dir, `${checkpointId}.json`);
59358
59755
  if (!contained)
59359
59756
  return jsonError("path escapes project root");
@@ -60076,7 +60473,7 @@ function renderDevErrorPage(payload, opts) {
60076
60473
  import { spawnSync as spawnSync2 } from "node:child_process";
60077
60474
  import { cpSync as cpSync2, existsSync as existsSync40, mkdirSync as mkdirSync18, readFileSync as readFileSync36, readdirSync as readdirSync11, statSync as statSync20, writeFileSync as writeFileSync20 } from "node:fs";
60078
60475
  import { createRequire as createRequire7 } from "node:module";
60079
- import { dirname as dirname25, join as join24, resolve as resolve36 } from "node:path";
60476
+ import { dirname as dirname25, join as join25, resolve as resolve36 } from "node:path";
60080
60477
  import { fileURLToPath as fileURLToPath8 } from "node:url";
60081
60478
  var require2 = createRequire7(import.meta.url);
60082
60479
  var __dirname9 = dirname25(fileURLToPath8(import.meta.url));
@@ -60100,12 +60497,14 @@ var PACKAGES = {
60100
60497
  // vesk.config.ts imports them, so their dist must exist for e2e/dev
60101
60498
  // servers on fresh checkouts (CI).
60102
60499
  "plugin-pwa": { name: "@vesk/plugin-pwa", entry: "index" },
60103
- "plugin-tailwind": { name: "@vesk/plugin-tailwind", entry: "index" }
60500
+ "plugin-tailwind": { name: "@vesk/plugin-tailwind", entry: "index" },
60501
+ // testing last — it depends on the compiler.
60502
+ testing: { name: "@vesk/testing", entry: "index" }
60104
60503
  };
60105
60504
  function newestSourceMtime(srcDir) {
60106
60505
  let newest = 0;
60107
60506
  for (const name of readdirSync11(srcDir)) {
60108
- const p = join24(srcDir, name);
60507
+ const p = join25(srcDir, name);
60109
60508
  const st = statSync20(p);
60110
60509
  if (st.isDirectory()) {
60111
60510
  newest = Math.max(newest, newestSourceMtime(p));
@@ -60116,11 +60515,11 @@ function newestSourceMtime(srcDir) {
60116
60515
  return newest;
60117
60516
  }
60118
60517
  function distStale(pkgDir, entry) {
60119
- const distIndex = join24(pkgDir, "dist", `${entry}.js`);
60518
+ const distIndex = join25(pkgDir, "dist", `${entry}.js`);
60120
60519
  if (!existsSync40(distIndex)) return true;
60121
- const distPkg = join24(pkgDir, "dist", "package.json");
60520
+ const distPkg = join25(pkgDir, "dist", "package.json");
60122
60521
  const distStamp = Math.max(statSync20(distIndex).mtimeMs, existsSync40(distPkg) ? statSync20(distPkg).mtimeMs : 0);
60123
- return newestSourceMtime(join24(pkgDir, "src")) > distStamp;
60522
+ return newestSourceMtime(join25(pkgDir, "src")) > distStamp;
60124
60523
  }
60125
60524
  function distPackageJson(pkgName, entry, serverEntry, version2) {
60126
60525
  const exports = {
@@ -60144,23 +60543,23 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
60144
60543
  function buildPackages(force = false) {
60145
60544
  for (const [pkg, cfg] of Object.entries(PACKAGES)) {
60146
60545
  const pkgDir = resolve36(root2, "packages", pkg);
60147
- if (!existsSync40(join24(pkgDir, "src"))) continue;
60546
+ if (!existsSync40(join25(pkgDir, "src"))) continue;
60148
60547
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
60149
60548
  console.log(`[build] ${cfg.name} -> tsc`);
60150
60549
  const tscBin = require2.resolve("typescript/bin/tsc");
60151
- const result = spawnSync2(process.execPath, [tscBin, "-p", join24(pkgDir, "tsconfig.build.json")], {
60550
+ const result = spawnSync2(process.execPath, [tscBin, "-p", join25(pkgDir, "tsconfig.build.json")], {
60152
60551
  stdio: "inherit"
60153
60552
  });
60154
60553
  if (result.status !== 0) {
60155
60554
  throw new Error(`tsc failed for ${cfg.name}`);
60156
60555
  }
60157
- const distDir = join24(pkgDir, "dist");
60556
+ const distDir = join25(pkgDir, "dist");
60158
60557
  for (const c of cfg.copy || []) {
60159
- const to = join24(distDir, c.to);
60558
+ const to = join25(distDir, c.to);
60160
60559
  mkdirSync18(dirname25(to), { recursive: true });
60161
- cpSync2(join24(pkgDir, c.from), to, { recursive: true });
60560
+ cpSync2(join25(pkgDir, c.from), to, { recursive: true });
60162
60561
  }
60163
- const srcPkg = JSON.parse(readFileSync36(join24(pkgDir, "package.json"), "utf-8"));
60562
+ const srcPkg = JSON.parse(readFileSync36(join25(pkgDir, "package.json"), "utf-8"));
60164
60563
  if (pkg === "lucide-vesk") {
60165
60564
  const lucideDistPkg = {
60166
60565
  name: srcPkg.name,
@@ -60174,9 +60573,9 @@ function buildPackages(force = false) {
60174
60573
  "./package.json": "./package.json"
60175
60574
  }
60176
60575
  };
60177
- writeFileSync20(join24(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
60576
+ writeFileSync20(join25(distDir, "package.json"), JSON.stringify(lucideDistPkg, null, 2) + "\n");
60178
60577
  } else {
60179
- writeFileSync20(join24(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
60578
+ writeFileSync20(join25(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
60180
60579
  }
60181
60580
  console.log(`[build] ${cfg.name} -> dist`);
60182
60581
  }
@@ -60653,9 +61052,9 @@ function resolveRuntimeDir(projectDir) {
60653
61052
  resolve38(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
60654
61053
  ];
60655
61054
  for (const dir of candidates) {
60656
- if (existsSync42(join25(dir, "ripple-runtime.js"))) return dir;
60657
- const distDir = join25(dir, "dist");
60658
- if (existsSync42(join25(distDir, "ripple-runtime.js"))) return distDir;
61055
+ if (existsSync42(join26(dir, "ripple-runtime.js"))) return dir;
61056
+ const distDir = join26(dir, "dist");
61057
+ if (existsSync42(join26(distDir, "ripple-runtime.js"))) return distDir;
60659
61058
  }
60660
61059
  return null;
60661
61060
  }
@@ -60895,7 +61294,7 @@ function countFilesNamed(dir, name) {
60895
61294
  if (!existsSync42(dir)) return 0;
60896
61295
  let n = 0;
60897
61296
  for (const entry of readdirSync13(dir, { withFileTypes: true })) {
60898
- const p = join25(dir, entry.name);
61297
+ const p = join26(dir, entry.name);
60899
61298
  if (entry.isDirectory()) n += countFilesNamed(p, name);
60900
61299
  else if (entry.name === name) n++;
60901
61300
  }
@@ -60938,7 +61337,7 @@ async function startDevServer(port, projectDir, config, host) {
60938
61337
  process.exit(1);
60939
61338
  }
60940
61339
  const runtimeDir = runtimeDirUnchecked;
60941
- const veskStateDir = join25(projectDir, ".vesk");
61340
+ const veskStateDir = join26(projectDir, ".vesk");
60942
61341
  const configPluginsRaw = config.plugins || [];
60943
61342
  const configPluginNames = configPluginsRaw.map((p) => typeof p === "string" ? p : p?.name).filter((n) => !!n);
60944
61343
  const rawDevPlugins = config.plugins || [];
@@ -61037,10 +61436,10 @@ async function startDevServer(port, projectDir, config, host) {
61037
61436
  }
61038
61437
  let devGlobalCssContent = "";
61039
61438
  let lastServedCssGlobal = "";
61040
- const appCssPath = join25(appDirPath, "global.css");
61041
- const srcDir = join25(projectDir, "src");
61042
- const cssPath = join25(srcDir, "global.css");
61043
- const altCssPath = join25(srcDir, "app.css");
61439
+ const appCssPath = join26(appDirPath, "global.css");
61440
+ const srcDir = join26(projectDir, "src");
61441
+ const cssPath = join26(srcDir, "global.css");
61442
+ const altCssPath = join26(srcDir, "app.css");
61044
61443
  let rawCss = "";
61045
61444
  let devCssSource = "";
61046
61445
  if (existsSync42(appCssPath)) {
@@ -61327,7 +61726,7 @@ async function startDevServer(port, projectDir, config, host) {
61327
61726
  if (!filename) return;
61328
61727
  const kind = classifyHmrWatchPath(filename);
61329
61728
  if (kind === "ignored") return;
61330
- const fullPath = filename.startsWith("/") ? filename : join25(watchDir, filename);
61729
+ const fullPath = filename.startsWith("/") ? filename : join26(watchDir, filename);
61331
61730
  const fileExists = existsSync42(fullPath);
61332
61731
  const bcast = (msg) => {
61333
61732
  const f = globalThis.__vesk_broadcastHmr;
@@ -61542,8 +61941,8 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
61542
61941
  ".json": "application/json",
61543
61942
  ".webmanifest": "application/manifest+json"
61544
61943
  };
61545
- const hmrJsPath = join25(runtimeDir, "hmr-client.js");
61546
- const hmrTsPath = join25(runtimeDir, "hmr-client.ts");
61944
+ const hmrJsPath = join26(runtimeDir, "hmr-client.js");
61945
+ const hmrTsPath = join26(runtimeDir, "hmr-client.ts");
61547
61946
  const hmrClientPath = existsSync42(hmrJsPath) ? hmrJsPath : existsSync42(hmrTsPath) ? hmrTsPath : null;
61548
61947
  function extractCompName2(src2) {
61549
61948
  return resolveComponentName(src2);
@@ -61715,7 +62114,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
61715
62114
  return;
61716
62115
  }
61717
62116
  const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
61718
- const apiDirPath = join25(appDirPath, "api");
62117
+ const apiDirPath = join26(appDirPath, "api");
61719
62118
  if (url.pathname.startsWith("/api") && existsSync42(apiDirPath)) {
61720
62119
  const apiRoutes = await scanApiRoutes(apiDirPath);
61721
62120
  const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
@@ -62207,7 +62606,7 @@ ${prettifyHtml(body)}
62207
62606
  LOG.ok(`dev server at http://localhost:${port} (listening on ${bindHost})`);
62208
62607
  const routes = collectRoutePaths(routeTree);
62209
62608
  const pageCount = countPages(routeTree);
62210
- const apiCount = countFilesNamed(join25(appDirPath, "api"), "route.ts");
62609
+ const apiCount = countFilesNamed(join26(appDirPath, "api"), "route.ts");
62211
62610
  LOG.info(`${projectDir}`);
62212
62611
  LOG.info(`${pageCount} page${pageCount === 1 ? "" : "s"}: ${routes.join(", ") || "(none)"}`);
62213
62612
  if (apiCount > 0) LOG.info(`${apiCount} api route${apiCount === 1 ? "" : "s"} (app/api)`);
@@ -62365,6 +62764,7 @@ __export(index_server_exports2, {
62365
62764
  custom: () => custom,
62366
62765
  defineAction: () => defineAction,
62367
62766
  defineHook: () => defineHook,
62767
+ defineMetadata: () => defineMetadata,
62368
62768
  defineRoute: () => defineRoute,
62369
62769
  derived: () => derived,
62370
62770
  destroy_block: () => destroy_block,
@@ -62392,6 +62792,8 @@ __export(index_server_exports2, {
62392
62792
  leaf: () => leaf,
62393
62793
  locals: () => locals,
62394
62794
  maxLength: () => maxLength,
62795
+ mergeMetadata: () => mergeMetadata,
62796
+ metadataToHtml: () => metadataToHtml,
62395
62797
  minLength: () => minLength,
62396
62798
  mutate: () => mutate,
62397
62799
  notFound: () => notFound,
@@ -62412,6 +62814,7 @@ __export(index_server_exports2, {
62412
62814
  required: () => required,
62413
62815
  rerenderNode: () => rerenderNode,
62414
62816
  resolveSsrResources: () => resolveSsrResources,
62817
+ resolveTitle: () => resolveTitle,
62415
62818
  resume_block: () => resume_block,
62416
62819
  revalidateComponent: () => revalidateComponent,
62417
62820
  revalidatePath: () => revalidatePath,
@@ -62473,6 +62876,7 @@ init_headless();
62473
62876
  init_primitive();
62474
62877
  init_loading_indicator();
62475
62878
  init_action();
62879
+ init_metadata();
62476
62880
 
62477
62881
  // src/index.ts
62478
62882
  var __filename2 = fileURLToPath9(import.meta.url);
@@ -62521,8 +62925,8 @@ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
62521
62925
  }
62522
62926
  function loadEnvFiles(projectDir) {
62523
62927
  const files = [
62524
- join29(projectDir, ".env"),
62525
- join29(projectDir, ".env.local")
62928
+ join30(projectDir, ".env"),
62929
+ join30(projectDir, ".env.local")
62526
62930
  ];
62527
62931
  for (const filePath of files) {
62528
62932
  if (!existsSync45(filePath)) continue;
@@ -62693,7 +63097,7 @@ if (cmd === "start") {
62693
63097
  if (cmd === "init") {
62694
63098
  const projectDir = process.cwd();
62695
63099
  const { appDir: appDirPath } = resolveProjectDirs(projectDir, await loadConfig(projectDir) || {});
62696
- const target = join29(appDirPath, "global.css");
63100
+ const target = join30(appDirPath, "global.css");
62697
63101
  if (existsSync45(target)) {
62698
63102
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
62699
63103
  process.exit(0);
@@ -62714,7 +63118,7 @@ if (cmd === "migrate") {
62714
63118
  const projectDir = process.cwd();
62715
63119
  const { runMigrate: runMigrate2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
62716
63120
  const { CODEMODS: CODEMODS2 } = await Promise.resolve().then(() => (init_codemods(), codemods_exports));
62717
- const { version: cliVersion } = JSON.parse(readFileSync42(join29(__dirname10, "..", "package.json"), "utf-8"));
63121
+ const { version: cliVersion } = JSON.parse(readFileSync42(join30(__dirname10, "..", "package.json"), "utf-8"));
62718
63122
  if (args.includes("--list")) {
62719
63123
  console.error("vesk migrate: available codemods");
62720
63124
  for (const c of CODEMODS2) {