@vesk/vesk-cli 0.2.9 → 0.2.10

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 +615 -198
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -1605,8 +1605,11 @@ function buildRequestInit(options2) {
1605
1605
  }
1606
1606
  function resolveFetchUrl(url) {
1607
1607
  if (/^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//")) return url;
1608
- const reqUrl = g().__vesk_request?.url;
1609
- const base = typeof reqUrl === "string" && /^https?:\/\//i.test(reqUrl) ? reqUrl : g().__vesk_ssr_base_url || "";
1608
+ const ctx2 = g().__vesk_request;
1609
+ const resolver = ctx2 && typeof ctx2.resolveUrl === "function" ? ctx2.resolveUrl : null;
1610
+ if (resolver) return resolver(url);
1611
+ const reqUrl = ctx2?.url;
1612
+ const base = typeof reqUrl === "string" && /^https?:\/\//i.test(reqUrl) ? reqUrl : globalThis.__vesk_ssr_base_url || "";
1610
1613
  if (base) return new URL(url, base).href;
1611
1614
  return url;
1612
1615
  }
@@ -1668,6 +1671,33 @@ async function runFetcher(handle2, timeout) {
1668
1671
  function sleep(ms) {
1669
1672
  return new Promise((resolve27) => setTimeout(resolve27, ms));
1670
1673
  }
1674
+ function streamText(res, into, onChunk) {
1675
+ const decoder = new TextDecoder();
1676
+ let total = "";
1677
+ const emit = (text) => {
1678
+ if (!text) return;
1679
+ total += text;
1680
+ if (into) setInto(into, total);
1681
+ if (onChunk) onChunk(text, total);
1682
+ };
1683
+ const body = res.body;
1684
+ if (body && typeof body.getReader === "function") {
1685
+ const reader = body.getReader();
1686
+ return (async () => {
1687
+ for (; ; ) {
1688
+ const { done, value } = await reader.read();
1689
+ if (done) break;
1690
+ emit(decoder.decode(value, { stream: true }));
1691
+ }
1692
+ emit(decoder.decode());
1693
+ return total;
1694
+ })();
1695
+ }
1696
+ return res.text().then((text) => {
1697
+ emit(text);
1698
+ return total;
1699
+ });
1700
+ }
1671
1701
  function settle(handle2, data2) {
1672
1702
  if (handle2.block !== null && is_destroyed(handle2.block)) return;
1673
1703
  if (handle2.into) setInto(handle2.into, data2);
@@ -1959,6 +1989,22 @@ var init_resource = __esm({
1959
1989
  ...options2,
1960
1990
  key: options2?.key ?? url
1961
1991
  });
1992
+ useFetch.stream = (urlOrFn, options2) => {
1993
+ const streamInto = options2?.into;
1994
+ const streamOnChunk = options2?.onChunk;
1995
+ const fetcher = (signal) => {
1996
+ const url = typeof urlOrFn === "function" ? urlOrFn() : urlOrFn;
1997
+ const init = buildRequestInit(options2 ?? {});
1998
+ return doFetch(resolveFetchUrl(url), signal ? { ...init, signal } : init).then(async (res) => {
1999
+ if (!res.ok) throw new HttpError(res.status, res.statusText);
2000
+ return streamText(res, streamInto, streamOnChunk);
2001
+ });
2002
+ };
2003
+ const key = options2?.key ?? (typeof urlOrFn === "string" ? urlOrFn : void 0);
2004
+ const resource = useFetch(fetcher, { ...options2, key });
2005
+ resource.into = streamInto;
2006
+ return resource;
2007
+ };
1962
2008
  }
1963
2009
  });
1964
2010
 
@@ -20205,7 +20251,7 @@ var init_request = __esm({
20205
20251
  });
20206
20252
  }
20207
20253
  };
20208
- VeskRequest = class extends ServerRequest {
20254
+ VeskRequest = class _VeskRequest extends ServerRequest {
20209
20255
  _query;
20210
20256
  _ip;
20211
20257
  _protocol;
@@ -20223,6 +20269,21 @@ var init_request = __esm({
20223
20269
  this._body = null;
20224
20270
  this._bodyPromise = null;
20225
20271
  this._parsedUrl = null;
20272
+ const cookieHeader = this.headers?.get("cookie") || "";
20273
+ if (cookieHeader) {
20274
+ for (const part of cookieHeader.split(";")) {
20275
+ const eq = part.indexOf("=");
20276
+ if (eq > 0) {
20277
+ const name = part.slice(0, eq).trim();
20278
+ const val = part.slice(eq + 1).trim();
20279
+ try {
20280
+ this._cookies[name] = decodeURIComponent(val);
20281
+ } catch {
20282
+ this._cookies[name] = val;
20283
+ }
20284
+ }
20285
+ }
20286
+ }
20226
20287
  Object.defineProperty(this, "body", {
20227
20288
  get: () => {
20228
20289
  if (!this._bodyPromise) {
@@ -20234,6 +20295,52 @@ var init_request = __esm({
20234
20295
  enumerable: true
20235
20296
  });
20236
20297
  }
20298
+ /**
20299
+ * The request's host header (honoring `x-forwarded-host` when
20300
+ * setTrustProxy() is enabled). Falls back to the parsed URL host.
20301
+ */
20302
+ get host() {
20303
+ const trust = this._security.trustProxy === true;
20304
+ const fwd = trust ? this.headers?.get("x-forwarded-host") : void 0;
20305
+ const header = typeof fwd === "string" && fwd ? fwd : this.headers?.get("host") || "";
20306
+ if (header) return header;
20307
+ return this.parsedUrl.host || "localhost";
20308
+ }
20309
+ /** Absolute origin (`protocol://host`) — the base for resolving relative URLs. */
20310
+ get origin() {
20311
+ return `${this.protocol}://${this.host}`;
20312
+ }
20313
+ /**
20314
+ * Resolves a possibly-relative URL against this request's own origin.
20315
+ * Absolute URLs (scheme or protocol-relative `//`) pass through untouched.
20316
+ * Used by the runtime SSR fetcher (`resolveFetchUrl`) to make in-app
20317
+ * fetches (e.g. `/api/...`) work during server rendering.
20318
+ */
20319
+ resolveUrl(url) {
20320
+ if (/^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith("//")) return url;
20321
+ return new URL(url, this.origin).href;
20322
+ }
20323
+ /** locals map accessors so <VeskRequest> can double as the middleware ctx. */
20324
+ set(key, value) {
20325
+ this._locals[key] = value;
20326
+ }
20327
+ get(key) {
20328
+ return this._locals[key];
20329
+ }
20330
+ /**
20331
+ * Wraps an inbound platform `Request` (from dev/prod/platform handlers)
20332
+ * into a VeskRequest carrying the same method, headers and cookie store.
20333
+ * Params/locals can be seeded so useParams()/useRequest() work in renders.
20334
+ */
20335
+ static from(request, init) {
20336
+ const vreq = new _VeskRequest(request instanceof Request ? request.url : String(request), {
20337
+ method: request.method,
20338
+ headers: request.headers
20339
+ });
20340
+ if (init?.params) vreq._params = { ...init.params };
20341
+ if (init?.locals) vreq._locals = { ...init.locals };
20342
+ return vreq;
20343
+ }
20237
20344
  get parsedUrl() {
20238
20345
  if (!this._parsedUrl) {
20239
20346
  this._parsedUrl = new URL(this.url);
@@ -20437,6 +20544,10 @@ var init_request = __esm({
20437
20544
  headers: { "Content-Type": "text/html; charset=utf-8", ...init?.headers }
20438
20545
  });
20439
20546
  }
20547
+ /** Chunked streaming response over a `ReadableStream` body (SSE, file streams, …). */
20548
+ static stream(readable, init) {
20549
+ return new __VeskResponse(readable, init);
20550
+ }
20440
20551
  };
20441
20552
  VeskResponse = new Proxy(_VeskResponse, {
20442
20553
  apply(target, _thisArg, args2) {
@@ -22803,6 +22914,84 @@ function wireCopyHandlers(root3) {
22803
22914
  function mdIsSSR() {
22804
22915
  return typeof document === "undefined";
22805
22916
  }
22917
+ function stringEndsWith(s, suffix) {
22918
+ if (suffix.length > s.length) return false;
22919
+ for (let i = 0; i < suffix.length; i++) {
22920
+ if (s[s.length - suffix.length + i] !== suffix[i]) return false;
22921
+ }
22922
+ return true;
22923
+ }
22924
+ function isPublicMarkdownPath(v) {
22925
+ if (typeof v !== "string") return false;
22926
+ const s = v;
22927
+ if (s.length < 2 || s.charCodeAt(0) !== 47) return false;
22928
+ if (s.charCodeAt(1) === 47) return false;
22929
+ for (let i = 0; i < s.length; i++) {
22930
+ const c = s.charCodeAt(i);
22931
+ if (c === 63 || c === 35 || c === 92) return false;
22932
+ }
22933
+ const lower = s.toLowerCase();
22934
+ return stringEndsWith(lower, ".md") || stringEndsWith(lower, ".markdown");
22935
+ }
22936
+ function getMdPathCell(path) {
22937
+ let cell = mdPathCells.get(path);
22938
+ if (!cell) {
22939
+ cell = tracked(void 0);
22940
+ mdPathCells.set(path, cell);
22941
+ }
22942
+ return cell;
22943
+ }
22944
+ function ensureMdPathLoaded(path) {
22945
+ if (mdPathCache.has(path) || mdPathInflight.has(path)) return;
22946
+ const ssr = getSsrData("md:" + path);
22947
+ if (typeof ssr === "string") {
22948
+ mdPathCache.set(path, ssr);
22949
+ return;
22950
+ }
22951
+ mdPathInflight.add(path);
22952
+ fetch(path).then((r) => r.ok ? r.text() : Promise.reject(r)).then((text) => {
22953
+ mdPathCache.set(path, text);
22954
+ set(getMdPathCell(path), text);
22955
+ }).catch(() => {
22956
+ mdPathCache.set(path, null);
22957
+ set(getMdPathCell(path), null);
22958
+ }).finally(() => {
22959
+ mdPathInflight.delete(path);
22960
+ });
22961
+ }
22962
+ function readServerMdPath(path) {
22963
+ const hook = globalThis.__vsk_md_read_file;
22964
+ if (typeof hook !== "function") return null;
22965
+ try {
22966
+ const out = hook(path);
22967
+ if (typeof out === "string") return out;
22968
+ } catch {
22969
+ }
22970
+ return null;
22971
+ }
22972
+ function resolveMdSource(value) {
22973
+ const s = String(value ?? "");
22974
+ if (!isPublicMarkdownPath(s)) return s;
22975
+ if (mdIsSSR()) {
22976
+ const content = readServerMdPath(s);
22977
+ if (content !== null) {
22978
+ setSsrData("md:" + s, content);
22979
+ return content;
22980
+ }
22981
+ return s;
22982
+ }
22983
+ ensureMdPathLoaded(s);
22984
+ const cached = mdPathCache.get(s);
22985
+ return cached === void 0 || cached === null ? s : cached;
22986
+ }
22987
+ function streamCellFrom(rawContent) {
22988
+ if (rawContent === null || typeof rawContent !== "object") return null;
22989
+ const into = rawContent.into;
22990
+ if (into !== null && typeof into === "object" && typeof into.get === "function") {
22991
+ return into;
22992
+ }
22993
+ return null;
22994
+ }
22806
22995
  function buildHtml(content, props) {
22807
22996
  const global = getMdPolicy();
22808
22997
  const mode = props.html || global.html;
@@ -22839,8 +23028,10 @@ function buildHtml(content, props) {
22839
23028
  }
22840
23029
  function Md(props, _registry, hydrate) {
22841
23030
  const rawContent = props.content;
22842
- const content = String(unwrapMaybeCell(rawContent) ?? "");
22843
- const html = buildHtml(content, props);
23031
+ const streamTarget = streamCellFrom(rawContent);
23032
+ const contentCell = streamTarget ?? rawContent;
23033
+ const content = String(unwrapMaybeCell(contentCell) ?? "");
23034
+ const html = buildHtml(resolveMdSource(content), props);
22844
23035
  const classNameRaw = props.className != null ? String(props.className) : props.class != null ? String(props.class) : "";
22845
23036
  const themeClass = props.theme === "dark" ? " vesk-md-dark" : "";
22846
23037
  const className = `vesk-md${themeClass}${classNameRaw ? " " + classNameRaw : ""}`;
@@ -22851,7 +23042,8 @@ function Md(props, _registry, hydrate) {
22851
23042
  const propFg = safeColorValue(String(props.codeFg ?? ""));
22852
23043
  if (propFg && propFg !== "none") wrapperParts.push(`--md-code-fg:${propFg}`);
22853
23044
  const wrapperStyle = wrapperParts.length > 0 ? escapeHtml3(wrapperParts.join(";")) : "";
22854
- const reactive = isCell(rawContent);
23045
+ const reactive = isCell(contentCell);
23046
+ const pathMode = isPublicMarkdownPath(content);
22855
23047
  if (mdIsSSR()) {
22856
23048
  const attrs = className ? ` class="${escapeHtml3(className)}"` : "";
22857
23049
  const styleAttr = style || wrapperStyle ? ` style="${[wrapperStyle, style.split('"').join("&quot;")].filter(Boolean).join(";")}"` : "";
@@ -22863,11 +23055,19 @@ function Md(props, _registry, hydrate) {
22863
23055
  const existing = hydrate.root.querySelector("div");
22864
23056
  if (existing) el = existing;
22865
23057
  }
22866
- el.innerHTML = html;
23058
+ const claimed = !!el.parentNode;
23059
+ if (pathMode && claimed) {
23060
+ el.setAttribute("data-vsk-md-ssr", "1");
23061
+ if (mdPathCache.has(content)) el.innerHTML = html;
23062
+ } else {
23063
+ el.innerHTML = html;
23064
+ }
22867
23065
  el.className = className;
22868
23066
  el.style.cssText = [wrapperStyle, style].filter(Boolean).join(";");
22869
23067
  wireCopyHandlers(el);
22870
- if (reactive) subscribeContent(el, rawContent, props);
23068
+ if (reactive || pathMode) {
23069
+ subscribeContent(el, contentCell, props, pathMode && claimed ? { trustInitialSsr: true, initialValue: content } : void 0);
23070
+ }
22871
23071
  if (el.parentNode) return document.createDocumentFragment();
22872
23072
  return el;
22873
23073
  }
@@ -22876,21 +23076,41 @@ function Md(props, _registry, hydrate) {
22876
23076
  div.className = className;
22877
23077
  div.style.cssText = [wrapperStyle, style].filter(Boolean).join(";");
22878
23078
  wireCopyHandlers(div);
22879
- if (reactive) subscribeContent(div, rawContent, props);
23079
+ if (reactive || pathMode) subscribeContent(div, contentCell, props);
22880
23080
  return div;
22881
23081
  }
22882
- function subscribeContent(el, rawContent, props) {
23082
+ function subscribeContent(el, rawContent, props, opts) {
23083
+ const trust = opts?.trustInitialSsr === true;
23084
+ const initial = opts?.initialValue;
23085
+ let ran = false;
22883
23086
  effect(() => {
22884
23087
  const value = String(unwrapMaybeCell(rawContent) ?? "");
22885
- el.innerHTML = buildHtml(value, props);
23088
+ if (isPublicMarkdownPath(value)) {
23089
+ const known = getSsrData("md:" + value) !== void 0 || mdPathCache.has(value);
23090
+ ensureMdPathLoaded(value);
23091
+ const cell = getMdPathCell(value);
23092
+ get(cell);
23093
+ if (trust && !ran && value === initial && !known) {
23094
+ ran = true;
23095
+ return;
23096
+ }
23097
+ ran = true;
23098
+ el.innerHTML = buildHtml(resolveMdSource(value), props);
23099
+ wireCopyHandlers(el);
23100
+ return;
23101
+ }
23102
+ ran = true;
23103
+ el.innerHTML = buildHtml(resolveMdSource(value), props);
22886
23104
  wireCopyHandlers(el);
22887
23105
  });
22888
23106
  }
22889
- var COLOR_FUNCS, SAFE_SCHEMES, KW_JS, KW_VSK, LIT_JS, KW_PY, LIT_PY, KW_GO, LIT_GO, KW_RUST, LIT_RUST, KW_SQL, KW_BASH, NAMED_ENTITIES, URL_ATTRS, MD_DEFAULT_ALLOW_TAGS, MD_BASE_CSS, __globalMode, __globalAllowTags, __sessionWarnings, __warnedKeys, __suppressMdConsoleWarnings;
23107
+ var COLOR_FUNCS, SAFE_SCHEMES, KW_JS, KW_VSK, LIT_JS, KW_PY, LIT_PY, KW_GO, LIT_GO, KW_RUST, LIT_RUST, KW_SQL, KW_BASH, NAMED_ENTITIES, URL_ATTRS, MD_DEFAULT_ALLOW_TAGS, MD_BASE_CSS, __globalMode, __globalAllowTags, __sessionWarnings, __warnedKeys, __suppressMdConsoleWarnings, mdPathCache, mdPathCells, mdPathInflight;
22890
23108
  var init_md = __esm({
22891
23109
  "../runtime/src/md.ts"() {
22892
23110
  "use strict";
22893
23111
  init_ripple_blocks();
23112
+ init_ripple_runtime();
23113
+ init_resource();
22894
23114
  COLOR_FUNCS = /* @__PURE__ */ new Set(["rgb", "rgba", "hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "color", "color-mix"]);
22895
23115
  SAFE_SCHEMES = ["http:", "https:", "mailto:", "tel:"];
22896
23116
  KW_JS = /* @__PURE__ */ new Set([
@@ -23292,6 +23512,9 @@ var init_md = __esm({
23292
23512
  __sessionWarnings = [];
23293
23513
  __warnedKeys = /* @__PURE__ */ new Set();
23294
23514
  __suppressMdConsoleWarnings = false;
23515
+ mdPathCache = /* @__PURE__ */ new Map();
23516
+ mdPathCells = /* @__PURE__ */ new Map();
23517
+ mdPathInflight = /* @__PURE__ */ new Set();
23295
23518
  }
23296
23519
  });
23297
23520
 
@@ -28316,6 +28539,7 @@ var init_server_render = __esm({
28316
28539
 
28317
28540
  // ../adapter/src/paths.ts
28318
28541
  import { resolve as resolve9, sep as sep2 } from "node:path";
28542
+ import { existsSync as existsSync8, statSync as statSync4, readFileSync as readFileSync9 } from "node:fs";
28319
28543
  function resolveWithin(baseDir, relPath) {
28320
28544
  const base = resolve9(baseDir);
28321
28545
  const target = resolve9(baseDir, relPath);
@@ -28323,6 +28547,24 @@ function resolveWithin(baseDir, relPath) {
28323
28547
  if (!target.startsWith(prefix)) return null;
28324
28548
  return target;
28325
28549
  }
28550
+ function installMdReadHook(publicDirs) {
28551
+ const dirs = publicDirs.map((d) => resolve9(d));
28552
+ globalThis.__vsk_md_read_file = (p) => {
28553
+ for (const dir of dirs) {
28554
+ try {
28555
+ let rel = String(p);
28556
+ while (rel.length > 0 && rel.charCodeAt(0) === 47) rel = rel.slice(1);
28557
+ const abs = resolveWithin(dir, rel);
28558
+ if (!abs) continue;
28559
+ const lower = abs.toLowerCase();
28560
+ if (!lower.endsWith(".md") && !lower.endsWith(".markdown")) continue;
28561
+ if (existsSync8(abs) && statSync4(abs).isFile()) return readFileSync9(abs, "utf8");
28562
+ } catch {
28563
+ }
28564
+ }
28565
+ return null;
28566
+ };
28567
+ }
28326
28568
  var init_paths = __esm({
28327
28569
  "../adapter/src/paths.ts"() {
28328
28570
  "use strict";
@@ -28337,12 +28579,12 @@ __export(static_exports, {
28337
28579
  generateSitemap: () => generateSitemap,
28338
28580
  generateSsgRoutes: () => generateSsgRoutes
28339
28581
  });
28340
- import { mkdirSync as mkdirSync2, copyFileSync as copyFileSync2, readdirSync as readdirSync3, statSync as statSync6, existsSync as existsSync10, writeFileSync as writeFileSync4, readFileSync as readFileSync11 } from "node:fs";
28582
+ import { mkdirSync as mkdirSync2, copyFileSync as copyFileSync2, readdirSync as readdirSync3, statSync as statSync7, existsSync as existsSync11, writeFileSync as writeFileSync4, readFileSync as readFileSync12 } from "node:fs";
28341
28583
  import { resolve as resolve12, join as join7 } from "node:path";
28342
28584
  function copyStaticAssets2(publicDir, outDir2) {
28343
28585
  const targetDir = resolve12(outDir2, "static", "public");
28344
28586
  mkdirSync2(targetDir, { recursive: true });
28345
- if (!existsSync10(publicDir))
28587
+ if (!existsSync11(publicDir))
28346
28588
  return;
28347
28589
  function copyDir(src2, dest) {
28348
28590
  mkdirSync2(dest, { recursive: true });
@@ -28350,7 +28592,7 @@ function copyStaticAssets2(publicDir, outDir2) {
28350
28592
  for (const entry of entries) {
28351
28593
  const srcPath = join7(src2, entry);
28352
28594
  const destPath = join7(dest, entry);
28353
- const st = statSync6(srcPath);
28595
+ const st = statSync7(srcPath);
28354
28596
  if (st.isDirectory()) {
28355
28597
  copyDir(srcPath, destPath);
28356
28598
  } else {
@@ -28382,7 +28624,7 @@ async function generateSsgRoutes(routeTree, appDir, outDir2) {
28382
28624
  for (const node of nodes) {
28383
28625
  if (node.page) {
28384
28626
  const pagePath = resolve12(appDir, node.sourceDir, "page.vsk");
28385
- const src2 = readFileSync11(pagePath, "utf-8");
28627
+ const src2 = readFileSync12(pagePath, "utf-8");
28386
28628
  const hasStaticProps = src2.includes("getStaticProps");
28387
28629
  const hasStaticPaths = src2.includes("getStaticPaths");
28388
28630
  if (hasStaticPaths) {
@@ -28482,12 +28724,12 @@ var image_pipeline_exports = {};
28482
28724
  __export(image_pipeline_exports, {
28483
28725
  optimizeImages: () => optimizeImages
28484
28726
  });
28485
- import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5, readFileSync as readFileSync12, existsSync as existsSync11, readdirSync as readdirSync4, statSync as statSync7 } from "node:fs";
28727
+ import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5, readFileSync as readFileSync13, existsSync as existsSync12, readdirSync as readdirSync4, statSync as statSync8 } from "node:fs";
28486
28728
  import { resolve as resolve13, extname as extname4, dirname as dirname8 } from "node:path";
28487
28729
  async function processImage(srcPath, outDir2, baseName) {
28488
28730
  const image = sharpFn ? sharpFn(srcPath) : null;
28489
28731
  if (!image) {
28490
- const original = readFileSync12(srcPath);
28732
+ const original = readFileSync13(srcPath);
28491
28733
  for (const w of OUTPUT_WIDTHS) {
28492
28734
  const outputPath = resolve13(outDir2, `${baseName}-${w}w`);
28493
28735
  mkdirSync3(dirname8(outputPath), { recursive: true });
@@ -28526,13 +28768,13 @@ function collectImageRefs(appDir) {
28526
28768
  }
28527
28769
  for (const entry of entries) {
28528
28770
  const full = resolve13(dir, entry);
28529
- const st = statSync7(full);
28771
+ const st = statSync8(full);
28530
28772
  if (st.isDirectory()) {
28531
28773
  if (entry.startsWith("."))
28532
28774
  continue;
28533
28775
  walk6(full);
28534
28776
  } else if (entry === "page.vsk") {
28535
- const src2 = readFileSync12(full, "utf-8");
28777
+ const src2 = readFileSync13(full, "utf-8");
28536
28778
  const imgRegex = /<Image\s+src=["']([^"']+)["']/g;
28537
28779
  let m;
28538
28780
  while ((m = imgRegex.exec(src2)) !== null) {
@@ -28562,7 +28804,7 @@ async function optimizeImages(appDir, outDir2) {
28562
28804
  ];
28563
28805
  let srcPath = null;
28564
28806
  for (const p of possiblePaths) {
28565
- if (existsSync11(p)) {
28807
+ if (existsSync12(p)) {
28566
28808
  srcPath = p;
28567
28809
  break;
28568
28810
  }
@@ -28609,7 +28851,7 @@ var seo_audit_exports = {};
28609
28851
  __export(seo_audit_exports, {
28610
28852
  runSeoAudit: () => runSeoAudit
28611
28853
  });
28612
- import { readFileSync as readFileSync13, existsSync as existsSync12, readdirSync as readdirSync5, statSync as statSync8 } from "node:fs";
28854
+ import { readFileSync as readFileSync14, existsSync as existsSync13, readdirSync as readdirSync5, statSync as statSync9 } from "node:fs";
28613
28855
  import { resolve as resolve14 } from "node:path";
28614
28856
  function walkFiles(dir) {
28615
28857
  const results = [];
@@ -28621,7 +28863,7 @@ function walkFiles(dir) {
28621
28863
  }
28622
28864
  for (const entry of entries) {
28623
28865
  const full = resolve14(dir, entry);
28624
- const st = statSync8(full);
28866
+ const st = statSync9(full);
28625
28867
  if (st.isDirectory()) {
28626
28868
  if (!entry.startsWith("."))
28627
28869
  results.push(...walkFiles(full));
@@ -28637,8 +28879,8 @@ function collectCombinedSource(appDir) {
28637
28879
  for (const pagePath of pages) {
28638
28880
  const dir = resolve14(pagePath, "..");
28639
28881
  const layoutPath = resolve14(dir, "layout.vsk");
28640
- const pageSrc = readFileSync13(pagePath, "utf-8");
28641
- const layoutSrc = existsSync12(layoutPath) ? readFileSync13(layoutPath, "utf-8") : "";
28882
+ const pageSrc = readFileSync14(pagePath, "utf-8");
28883
+ const layoutSrc = existsSync13(layoutPath) ? readFileSync14(layoutPath, "utf-8") : "";
28642
28884
  const combinedSrc = layoutSrc ? layoutSrc + "\n" + pageSrc : pageSrc;
28643
28885
  combined.push({
28644
28886
  path: pagePath,
@@ -28813,7 +29055,7 @@ var init_platform = __esm({
28813
29055
  });
28814
29056
 
28815
29057
  // ../adapter/src/platform-handler.ts
28816
- import { existsSync as existsSync13 } from "node:fs";
29058
+ import { existsSync as existsSync14 } from "node:fs";
28817
29059
  import { resolve as resolve15, dirname as dirname9 } from "node:path";
28818
29060
  import { fileURLToPath as fileURLToPath4 } from "node:url";
28819
29061
  function routeName2(segments) {
@@ -28832,7 +29074,7 @@ function toId(s) {
28832
29074
  }
28833
29075
  function findCompilerSrc2() {
28834
29076
  const monorepo = resolve15(__dirname5, "..", "..", "..", "packages", "compiler", "dist");
28835
- if (existsSync13(monorepo)) return monorepo;
29077
+ if (existsSync14(monorepo)) return monorepo;
28836
29078
  throw new Error('@vesk/compiler/dist not found \u2014 run "npm run build" first');
28837
29079
  }
28838
29080
  function generatePlatformHandlerSource(input) {
@@ -28901,7 +29143,7 @@ export async function handleRequest(request) {
28901
29143
  return new Response(null, { status: 308, headers: { Location: '/_vesk/static/public' + (pathname.endsWith('/') ? pathname + 'index.html' : pathname + '.html') } });
28902
29144
  }
28903
29145
 
28904
- let mwCtx = { params: {}, url, locals: {}, cookies: {}, request, set() {}, get() { return undefined; } };
29146
+ let mwCtx = { params: {}, url, locals: {}, cookies: {}, request, resolveUrl(u) { return new URL(u, request.url).href; }, set() {}, get() { return undefined; } };
28905
29147
  if (${hasMwLiteral}) {
28906
29148
  mwCtx = {
28907
29149
  request,
@@ -28909,6 +29151,7 @@ export async function handleRequest(request) {
28909
29151
  url,
28910
29152
  locals: {},
28911
29153
  cookies: typeof parseCookies !== 'undefined' ? parseCookies(request.headers.get('cookie') || '') : {},
29154
+ resolveUrl(u) { return new URL(u, request.url).href; },
28912
29155
  set(key, value) { this.locals[key] = value; },
28913
29156
  get(key) { return this.locals[key]; },
28914
29157
  };
@@ -29052,11 +29295,11 @@ import {
29052
29295
  mkdirSync as mkdirSync4,
29053
29296
  copyFileSync as copyFileSync3,
29054
29297
  readdirSync as readdirSync6,
29055
- statSync as statSync9,
29056
- existsSync as existsSync14,
29298
+ statSync as statSync10,
29299
+ existsSync as existsSync15,
29057
29300
  writeFileSync as writeFileSync6,
29058
29301
  rmSync,
29059
- readFileSync as readFileSync14
29302
+ readFileSync as readFileSync15
29060
29303
  } from "node:fs";
29061
29304
  import { resolve as resolve16, join as join8, extname as extname5, dirname as dirname10 } from "node:path";
29062
29305
  function ensureCleanDir(dir) {
@@ -29064,12 +29307,12 @@ function ensureCleanDir(dir) {
29064
29307
  mkdirSync4(dir, { recursive: true });
29065
29308
  }
29066
29309
  function copyDirContents(srcDir, destDir) {
29067
- if (!existsSync14(srcDir)) return;
29310
+ if (!existsSync15(srcDir)) return;
29068
29311
  mkdirSync4(destDir, { recursive: true });
29069
29312
  for (const entry of readdirSync6(srcDir)) {
29070
29313
  const srcPath = join8(srcDir, entry);
29071
29314
  const destPath = join8(destDir, entry);
29072
- if (statSync9(srcPath).isDirectory()) {
29315
+ if (statSync10(srcPath).isDirectory()) {
29073
29316
  copyDirContents(srcPath, destPath);
29074
29317
  } else {
29075
29318
  mkdirSync4(dirname10(destPath), { recursive: true });
@@ -29084,22 +29327,22 @@ function writeFile(path, content) {
29084
29327
  function writePlatformStatic(buildStaticDir, platformStaticDir) {
29085
29328
  mkdirSync4(platformStaticDir, { recursive: true });
29086
29329
  const publicDir = resolve16(buildStaticDir, "public");
29087
- if (existsSync14(publicDir)) {
29330
+ if (existsSync15(publicDir)) {
29088
29331
  copyDirContents(publicDir, platformStaticDir);
29089
29332
  }
29090
29333
  const assetsDir = resolve16(platformStaticDir, "_vesk", "static");
29091
29334
  copyDirContents(buildStaticDir, assetsDir);
29092
29335
  const runtimeAlias = resolve16(platformStaticDir, "_vesk", "runtime.js");
29093
29336
  const clientPath = resolve16(buildStaticDir, "client.js");
29094
- if (existsSync14(clientPath)) {
29337
+ if (existsSync15(clientPath)) {
29095
29338
  mkdirSync4(dirname10(runtimeAlias), { recursive: true });
29096
29339
  copyFileSync3(clientPath, runtimeAlias);
29097
29340
  }
29098
29341
  }
29099
29342
  function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
29100
29343
  for (const route of prerenderedRoutes) {
29101
- if (!existsSync14(route.html)) continue;
29102
- const content = readFileSync14(route.html);
29344
+ if (!existsSync15(route.html)) continue;
29345
+ const content = readFileSync15(route.html);
29103
29346
  const htmlRel = route.path === "/" ? "index.html" : `${route.path.replace(/^\//, "")}.html`;
29104
29347
  const target = resolve16(platformStaticDir, "_vesk", "static", "public", htmlRel);
29105
29348
  writeFile(target, content);
@@ -29111,15 +29354,15 @@ function writePrerenderedStatic(prerenderedRoutes, platformStaticDir) {
29111
29354
  }
29112
29355
  function listStaticDir(dir) {
29113
29356
  const out = [];
29114
- if (!existsSync14(dir)) return out;
29357
+ if (!existsSync15(dir)) return out;
29115
29358
  function walk6(d, prefix) {
29116
29359
  for (const entry of readdirSync6(d)) {
29117
29360
  const full = join8(d, entry);
29118
29361
  const rel = prefix ? `${prefix}/${entry}` : entry;
29119
- if (statSync9(full).isDirectory()) {
29362
+ if (statSync10(full).isDirectory()) {
29120
29363
  walk6(full, rel);
29121
29364
  } else {
29122
- out.push({ rel, buffer: readFileSync14(full) });
29365
+ out.push({ rel, buffer: readFileSync15(full) });
29123
29366
  }
29124
29367
  }
29125
29368
  }
@@ -31406,6 +31649,95 @@ function wireCopyHandlers2(root3) {
31406
31649
  function mdIsSSR2() {
31407
31650
  return typeof document === "undefined";
31408
31651
  }
31652
+ function stringEndsWith2(s, suffix) {
31653
+ if (suffix.length > s.length)
31654
+ return false;
31655
+ for (let i = 0; i < suffix.length; i++) {
31656
+ if (s[s.length - suffix.length + i] !== suffix[i])
31657
+ return false;
31658
+ }
31659
+ return true;
31660
+ }
31661
+ function isPublicMarkdownPath2(v) {
31662
+ if (typeof v !== "string")
31663
+ return false;
31664
+ const s = v;
31665
+ if (s.length < 2 || s.charCodeAt(0) !== 47)
31666
+ return false;
31667
+ if (s.charCodeAt(1) === 47)
31668
+ return false;
31669
+ for (let i = 0; i < s.length; i++) {
31670
+ const c = s.charCodeAt(i);
31671
+ if (c === 63 || c === 35 || c === 92)
31672
+ return false;
31673
+ }
31674
+ const lower = s.toLowerCase();
31675
+ return stringEndsWith2(lower, ".md") || stringEndsWith2(lower, ".markdown");
31676
+ }
31677
+ function getMdPathCell2(path) {
31678
+ let cell = mdPathCells2.get(path);
31679
+ if (!cell) {
31680
+ cell = tracked(void 0);
31681
+ mdPathCells2.set(path, cell);
31682
+ }
31683
+ return cell;
31684
+ }
31685
+ function ensureMdPathLoaded2(path) {
31686
+ if (mdPathCache2.has(path) || mdPathInflight2.has(path))
31687
+ return;
31688
+ const ssr = getSsrData("md:" + path);
31689
+ if (typeof ssr === "string") {
31690
+ mdPathCache2.set(path, ssr);
31691
+ return;
31692
+ }
31693
+ mdPathInflight2.add(path);
31694
+ fetch(path).then((r) => r.ok ? r.text() : Promise.reject(r)).then((text) => {
31695
+ mdPathCache2.set(path, text);
31696
+ set(getMdPathCell2(path), text);
31697
+ }).catch(() => {
31698
+ mdPathCache2.set(path, null);
31699
+ set(getMdPathCell2(path), null);
31700
+ }).finally(() => {
31701
+ mdPathInflight2.delete(path);
31702
+ });
31703
+ }
31704
+ function readServerMdPath2(path) {
31705
+ const hook = globalThis.__vsk_md_read_file;
31706
+ if (typeof hook !== "function")
31707
+ return null;
31708
+ try {
31709
+ const out = hook(path);
31710
+ if (typeof out === "string")
31711
+ return out;
31712
+ } catch {
31713
+ }
31714
+ return null;
31715
+ }
31716
+ function resolveMdSource2(value) {
31717
+ const s = String(value ?? "");
31718
+ if (!isPublicMarkdownPath2(s))
31719
+ return s;
31720
+ if (mdIsSSR2()) {
31721
+ const content = readServerMdPath2(s);
31722
+ if (content !== null) {
31723
+ setSsrData("md:" + s, content);
31724
+ return content;
31725
+ }
31726
+ return s;
31727
+ }
31728
+ ensureMdPathLoaded2(s);
31729
+ const cached = mdPathCache2.get(s);
31730
+ return cached === void 0 || cached === null ? s : cached;
31731
+ }
31732
+ function streamCellFrom2(rawContent) {
31733
+ if (rawContent === null || typeof rawContent !== "object")
31734
+ return null;
31735
+ const into = rawContent.into;
31736
+ if (into !== null && typeof into === "object" && typeof into.get === "function") {
31737
+ return into;
31738
+ }
31739
+ return null;
31740
+ }
31409
31741
  function buildHtml2(content, props) {
31410
31742
  const global = getMdPolicy2();
31411
31743
  const mode = props.html || global.html;
@@ -31441,8 +31773,10 @@ function buildHtml2(content, props) {
31441
31773
  }
31442
31774
  function Md2(props, _registry, hydrate) {
31443
31775
  const rawContent = props.content;
31444
- const content = String(unwrapMaybeCell2(rawContent) ?? "");
31445
- const html = buildHtml2(content, props);
31776
+ const streamTarget = streamCellFrom2(rawContent);
31777
+ const contentCell = streamTarget ?? rawContent;
31778
+ const content = String(unwrapMaybeCell2(contentCell) ?? "");
31779
+ const html = buildHtml2(resolveMdSource2(content), props);
31446
31780
  const classNameRaw = props.className != null ? String(props.className) : props.class != null ? String(props.class) : "";
31447
31781
  const themeClass = props.theme === "dark" ? " vesk-md-dark" : "";
31448
31782
  const className = `vesk-md${themeClass}${classNameRaw ? " " + classNameRaw : ""}`;
@@ -31455,7 +31789,8 @@ function Md2(props, _registry, hydrate) {
31455
31789
  if (propFg && propFg !== "none")
31456
31790
  wrapperParts.push(`--md-code-fg:${propFg}`);
31457
31791
  const wrapperStyle = wrapperParts.length > 0 ? escapeHtml6(wrapperParts.join(";")) : "";
31458
- const reactive = isCell2(rawContent);
31792
+ const reactive = isCell2(contentCell);
31793
+ const pathMode = isPublicMarkdownPath2(content);
31459
31794
  if (mdIsSSR2()) {
31460
31795
  const attrs = className ? ` class="${escapeHtml6(className)}"` : "";
31461
31796
  const styleAttr = style || wrapperStyle ? ` style="${[wrapperStyle, style.split('"').join("&quot;")].filter(Boolean).join(";")}"` : "";
@@ -31468,12 +31803,20 @@ function Md2(props, _registry, hydrate) {
31468
31803
  if (existing)
31469
31804
  el = existing;
31470
31805
  }
31471
- el.innerHTML = html;
31806
+ const claimed = !!el.parentNode;
31807
+ if (pathMode && claimed) {
31808
+ el.setAttribute("data-vsk-md-ssr", "1");
31809
+ if (mdPathCache2.has(content))
31810
+ el.innerHTML = html;
31811
+ } else {
31812
+ el.innerHTML = html;
31813
+ }
31472
31814
  el.className = className;
31473
31815
  el.style.cssText = [wrapperStyle, style].filter(Boolean).join(";");
31474
31816
  wireCopyHandlers2(el);
31475
- if (reactive)
31476
- subscribeContent2(el, rawContent, props);
31817
+ if (reactive || pathMode) {
31818
+ subscribeContent2(el, contentCell, props, pathMode && claimed ? { trustInitialSsr: true, initialValue: content } : void 0);
31819
+ }
31477
31820
  if (el.parentNode)
31478
31821
  return document.createDocumentFragment();
31479
31822
  return el;
@@ -31483,22 +31826,42 @@ function Md2(props, _registry, hydrate) {
31483
31826
  div.className = className;
31484
31827
  div.style.cssText = [wrapperStyle, style].filter(Boolean).join(";");
31485
31828
  wireCopyHandlers2(div);
31486
- if (reactive)
31487
- subscribeContent2(div, rawContent, props);
31829
+ if (reactive || pathMode)
31830
+ subscribeContent2(div, contentCell, props);
31488
31831
  return div;
31489
31832
  }
31490
- function subscribeContent2(el, rawContent, props) {
31833
+ function subscribeContent2(el, rawContent, props, opts) {
31834
+ const trust = opts?.trustInitialSsr === true;
31835
+ const initial = opts?.initialValue;
31836
+ let ran = false;
31491
31837
  effect(() => {
31492
31838
  const value = String(unwrapMaybeCell2(rawContent) ?? "");
31493
- el.innerHTML = buildHtml2(value, props);
31839
+ if (isPublicMarkdownPath2(value)) {
31840
+ const known = getSsrData("md:" + value) !== void 0 || mdPathCache2.has(value);
31841
+ ensureMdPathLoaded2(value);
31842
+ const cell = getMdPathCell2(value);
31843
+ get(cell);
31844
+ if (trust && !ran && value === initial && !known) {
31845
+ ran = true;
31846
+ return;
31847
+ }
31848
+ ran = true;
31849
+ el.innerHTML = buildHtml2(resolveMdSource2(value), props);
31850
+ wireCopyHandlers2(el);
31851
+ return;
31852
+ }
31853
+ ran = true;
31854
+ el.innerHTML = buildHtml2(resolveMdSource2(value), props);
31494
31855
  wireCopyHandlers2(el);
31495
31856
  });
31496
31857
  }
31497
- var COLOR_FUNCS2, SAFE_SCHEMES2, KW_JS2, KW_VSK2, LIT_JS2, KW_PY2, LIT_PY2, KW_GO2, LIT_GO2, KW_RUST2, LIT_RUST2, KW_SQL2, KW_BASH2, NAMED_ENTITIES2, URL_ATTRS2, MD_DEFAULT_ALLOW_TAGS2, MD_BASE_CSS2, __globalMode2, __globalAllowTags2, __sessionWarnings2, __warnedKeys2, __suppressMdConsoleWarnings2;
31858
+ var COLOR_FUNCS2, SAFE_SCHEMES2, KW_JS2, KW_VSK2, LIT_JS2, KW_PY2, LIT_PY2, KW_GO2, LIT_GO2, KW_RUST2, LIT_RUST2, KW_SQL2, KW_BASH2, NAMED_ENTITIES2, URL_ATTRS2, MD_DEFAULT_ALLOW_TAGS2, MD_BASE_CSS2, __globalMode2, __globalAllowTags2, __sessionWarnings2, __warnedKeys2, __suppressMdConsoleWarnings2, mdPathCache2, mdPathCells2, mdPathInflight2;
31498
31859
  var init_md2 = __esm({
31499
31860
  "../runtime/dist/md.js"() {
31500
31861
  "use strict";
31501
31862
  init_ripple_blocks();
31863
+ init_ripple_runtime();
31864
+ init_resource();
31502
31865
  COLOR_FUNCS2 = /* @__PURE__ */ new Set(["rgb", "rgba", "hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "color", "color-mix"]);
31503
31866
  SAFE_SCHEMES2 = ["http:", "https:", "mailto:", "tel:"];
31504
31867
  KW_JS2 = /* @__PURE__ */ new Set([
@@ -31900,6 +32263,9 @@ var init_md2 = __esm({
31900
32263
  __sessionWarnings2 = [];
31901
32264
  __warnedKeys2 = /* @__PURE__ */ new Set();
31902
32265
  __suppressMdConsoleWarnings2 = false;
32266
+ mdPathCache2 = /* @__PURE__ */ new Map();
32267
+ mdPathCells2 = /* @__PURE__ */ new Map();
32268
+ mdPathInflight2 = /* @__PURE__ */ new Set();
31903
32269
  }
31904
32270
  });
31905
32271
 
@@ -32871,7 +33237,7 @@ __export(typecheck_exports, {
32871
33237
  formatTypecheckWarnings: () => formatTypecheckWarnings,
32872
33238
  typecheckProject: () => typecheckProject
32873
33239
  });
32874
- import { readFileSync as readFileSync21, readdirSync as readdirSync12, statSync as statSync15 } from "node:fs";
33240
+ import { readFileSync as readFileSync23, readdirSync as readdirSync12, statSync as statSync17 } from "node:fs";
32875
33241
  import { join as join14, dirname as dirname15, normalize, relative as relative7, resolve as resolve25, sep as sep5 } from "node:path";
32876
33242
  import * as ts8 from "typescript";
32877
33243
  function walkProjectFiles(projectRoot) {
@@ -32888,7 +33254,7 @@ function walkProjectFiles(projectRoot) {
32888
33254
  const p = join14(dir, e);
32889
33255
  let st;
32890
33256
  try {
32891
- st = statSync15(p);
33257
+ st = statSync17(p);
32892
33258
  } catch {
32893
33259
  continue;
32894
33260
  }
@@ -33073,7 +33439,7 @@ function typecheckProject(projectRoot, opts = {}) {
33073
33439
  }
33074
33440
  }
33075
33441
  if (f.endsWith(".vsk")) {
33076
- const src2 = readFileSync21(f, "utf-8");
33442
+ const src2 = readFileSync23(f, "utf-8");
33077
33443
  try {
33078
33444
  parse4(src2);
33079
33445
  } catch (e) {
@@ -33655,7 +34021,7 @@ declare module '@vesk/runtime' {
33655
34021
  });
33656
34022
 
33657
34023
  // src/index.ts
33658
- import { readFileSync as readFileSync22, writeFileSync as writeFileSync11, mkdirSync as mkdirSync9, existsSync as existsSync23 } from "fs";
34024
+ import { readFileSync as readFileSync24, writeFileSync as writeFileSync11, mkdirSync as mkdirSync9, existsSync as existsSync25 } from "fs";
33659
34025
  import { resolve as resolve26, join as join15, dirname as dirname16 } from "path";
33660
34026
  import { fileURLToPath as fileURLToPath8 } from "url";
33661
34027
 
@@ -34155,7 +34521,7 @@ function setRuntimeModule2(mod) {
34155
34521
 
34156
34522
  // ../adapter/dist/index.js
34157
34523
  init_scan();
34158
- import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync8, existsSync as existsSync15, readFileSync as readFileSync15 } from "node:fs";
34524
+ import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync8, existsSync as existsSync16, readFileSync as readFileSync16 } from "node:fs";
34159
34525
  import { resolve as resolve18, dirname as dirname12, relative as relative4 } from "node:path";
34160
34526
  import { fileURLToPath as fileURLToPath5 } from "node:url";
34161
34527
 
@@ -34607,6 +34973,7 @@ ${compRegEntries.join("\n")}
34607
34973
  " url,",
34608
34974
  " locals: Object.assign({}, __rootLocals),",
34609
34975
  " cookies: parseCookies(request.headers.get('cookie') || ''),",
34976
+ " resolveUrl(u) { return new URL(u, request.url).href; },",
34610
34977
  " set(key, value) { this.locals[key] = value; },",
34611
34978
  " get(key) { return this.locals[key]; },",
34612
34979
  " };",
@@ -34622,7 +34989,17 @@ ${compRegEntries.join("\n")}
34622
34989
  " }"
34623
34990
  ].join("\n");
34624
34991
  } else {
34625
- bodyCode = dataCode;
34992
+ const indentedRender = dataCode.split("\n").map((l) => l ? ` ${l}` : "").join("\n");
34993
+ bodyCode = [
34994
+ " // Request context for SSR helpers (useParams/useRequest, relative useFetch resolution).",
34995
+ " const prevReq = globalThis.__vesk_request;",
34996
+ " globalThis.__vesk_request = VeskRequest.from(request, { params });",
34997
+ " try {",
34998
+ indentedRender,
34999
+ " } finally {",
35000
+ " globalThis.__vesk_request = prevReq;",
35001
+ " }"
35002
+ ].join("\n");
34626
35003
  }
34627
35004
  let registerActionsCode;
34628
35005
  if (hasLayout || hasAncestorLayout) {
@@ -34695,6 +35072,7 @@ ${compRegEntries.join("\n")}
34695
35072
  " url: pageUrl,",
34696
35073
  " locals: {},",
34697
35074
  " cookies: parseCookies(request.headers.get('cookie') || ''),",
35075
+ " resolveUrl(u) { return new URL(u, pageUrl.href).href; },",
34698
35076
  " };",
34699
35077
  " try {",
34700
35078
  " const result = await action.execute(input, {",
@@ -34725,7 +35103,7 @@ ${compRegEntries.join("\n")}
34725
35103
  ""
34726
35104
  ].join("\n");
34727
35105
  const funcCode = [
34728
- "import { renderFullPage, renderPageStream, renderPage, compileFile, setVskHydrate, parseCookies, getAction, validateActionInput, issuesToFieldMap, storeDataScriptGlobal, withSsrStore, assertSameOrigin } from '../runtime.js';",
35106
+ "import { renderFullPage, renderPageStream, renderPage, compileFile, setVskHydrate, parseCookies, getAction, validateActionInput, issuesToFieldMap, storeDataScriptGlobal, withSsrStore, assertSameOrigin, VeskRequest } from '../runtime.js';",
34729
35107
  "",
34730
35108
  middlewareCode || "",
34731
35109
  registryCode,
@@ -35674,19 +36052,19 @@ function generateManifest(routes, ssrRoutes, apiRoutes, staticRoutes, middleware
35674
36052
 
35675
36053
  // ../adapter/src/static.ts
35676
36054
  init_paths();
35677
- import { mkdirSync, copyFileSync, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync8, writeFileSync as writeFileSync3, readFileSync as readFileSync9 } from "node:fs";
36055
+ import { mkdirSync, copyFileSync, readdirSync as readdirSync2, statSync as statSync5, existsSync as existsSync9, writeFileSync as writeFileSync3, readFileSync as readFileSync10 } from "node:fs";
35678
36056
  import { resolve as resolve10, join as join6 } from "node:path";
35679
36057
  function copyStaticAssets(publicDir, outDir2) {
35680
36058
  const targetDir = resolve10(outDir2, "static", "public");
35681
36059
  mkdirSync(targetDir, { recursive: true });
35682
- if (!existsSync8(publicDir)) return;
36060
+ if (!existsSync9(publicDir)) return;
35683
36061
  function copyDir(src2, dest) {
35684
36062
  mkdirSync(dest, { recursive: true });
35685
36063
  const entries = readdirSync2(src2);
35686
36064
  for (const entry of entries) {
35687
36065
  const srcPath = join6(src2, entry);
35688
36066
  const destPath = join6(dest, entry);
35689
- const st = statSync4(srcPath);
36067
+ const st = statSync5(srcPath);
35690
36068
  if (st.isDirectory()) {
35691
36069
  copyDir(srcPath, destPath);
35692
36070
  } else {
@@ -35698,7 +36076,7 @@ function copyStaticAssets(publicDir, outDir2) {
35698
36076
  }
35699
36077
 
35700
36078
  // ../adapter/src/prod-server.ts
35701
- import { readFileSync as readFileSync10, existsSync as existsSync9, statSync as statSync5 } from "node:fs";
36079
+ import { readFileSync as readFileSync11, existsSync as existsSync10, statSync as statSync6 } from "node:fs";
35702
36080
  import { resolve as resolve11, extname as extname3, dirname as dirname7 } from "node:path";
35703
36081
  import { createServer } from "node:http";
35704
36082
  import { createRequire as createRequire2 } from "node:module";
@@ -35717,6 +36095,24 @@ async function readBody(req, maxBytes = DEFAULT_MAX_BODY_BYTES) {
35717
36095
  }
35718
36096
  return Buffer.concat(chunks);
35719
36097
  }
36098
+ async function deliverResponse(res, response) {
36099
+ res.writeHead(response.status, Object.fromEntries(response.headers));
36100
+ const body = response.body;
36101
+ if (body && typeof body.getReader === "function") {
36102
+ const reader = body.getReader();
36103
+ try {
36104
+ for (; ; ) {
36105
+ const { done, value } = await reader.read();
36106
+ if (done) break;
36107
+ res.write(Buffer.from(value));
36108
+ }
36109
+ } catch {
36110
+ }
36111
+ res.end();
36112
+ return;
36113
+ }
36114
+ res.end(await response.text());
36115
+ }
35720
36116
  function bodyTooLarge(maxBytes) {
35721
36117
  const err = new Error(`Request body exceeds limit (${maxBytes} bytes)`);
35722
36118
  err.status = 413;
@@ -35797,12 +36193,13 @@ async function startProdServer(outDir, options) {
35797
36193
  if (!process.env.NODE_ENV) process.env.NODE_ENV = "production";
35798
36194
  const staticDir = resolve11(outDir, "static");
35799
36195
  const configPath = resolve11(outDir, "config.json");
35800
- if (!existsSync9(configPath)) {
36196
+ installMdReadHook([resolve11(staticDir, "public")]);
36197
+ if (!existsSync10(configPath)) {
35801
36198
  console.error(`vesk start: no build found at ${outDir}`);
35802
36199
  console.error('Run "vesk build" first');
35803
36200
  process.exit(1);
35804
36201
  }
35805
- const buildConfig = JSON.parse(readFileSync10(configPath, "utf-8"));
36202
+ const buildConfig = JSON.parse(readFileSync11(configPath, "utf-8"));
35806
36203
  console.error(`vesk start: serving from ${outDir}`);
35807
36204
  const projectDir = resolve11(outDir, "..");
35808
36205
  let securityConfig = {};
@@ -35811,11 +36208,11 @@ async function startProdServer(outDir, options) {
35811
36208
  const veskConfigPath = resolve11(projectDir, "vesk.config.js");
35812
36209
  const veskConfigTsPath = resolve11(projectDir, "vesk.config.ts");
35813
36210
  let rawConfig = {};
35814
- if (existsSync9(veskConfigPath)) {
36211
+ if (existsSync10(veskConfigPath)) {
35815
36212
  rawConfig = _require(veskConfigPath);
35816
- } else if (existsSync9(veskConfigTsPath)) {
36213
+ } else if (existsSync10(veskConfigTsPath)) {
35817
36214
  const { transpile } = _require("typescript");
35818
- const src = readFileSync10(veskConfigTsPath, "utf-8");
36215
+ const src = readFileSync11(veskConfigTsPath, "utf-8");
35819
36216
  const result = transpile(src, { module: 99, target: 99 });
35820
36217
  rawConfig = eval(`(${result})`);
35821
36218
  }
@@ -35845,7 +36242,7 @@ async function startProdServer(outDir, options) {
35845
36242
  }
35846
36243
  let middlewareMod = null;
35847
36244
  const mwPath = resolve11(outDir, "server", "middleware.js");
35848
- if (existsSync9(mwPath)) {
36245
+ if (existsSync10(mwPath)) {
35849
36246
  try {
35850
36247
  middlewareMod = await import(`${mwPath}?t=${Date.now()}`);
35851
36248
  } catch {
@@ -35855,7 +36252,7 @@ async function startProdServer(outDir, options) {
35855
36252
  async function loadFunction(funcPath) {
35856
36253
  if (functionCache.has(funcPath)) return functionCache.get(funcPath);
35857
36254
  const fullPath = resolve11(outDir, funcPath);
35858
- if (!existsSync9(fullPath)) return null;
36255
+ if (!existsSync10(fullPath)) return null;
35859
36256
  try {
35860
36257
  const mod = await import(`${fullPath}?t=${Date.now()}`);
35861
36258
  functionCache.set(funcPath, mod);
@@ -35917,10 +36314,10 @@ async function startProdServer(outDir, options) {
35917
36314
  });
35918
36315
  const publicDir = resolve11(staticDir, "public");
35919
36316
  const rootFile = url.pathname.length > 1 ? resolveWithin(publicDir, url.pathname.slice(1)) : null;
35920
- if (rootFile && existsSync9(rootFile) && statSync5(rootFile).isFile()) {
36317
+ if (rootFile && existsSync10(rootFile) && statSync6(rootFile).isFile()) {
35921
36318
  const ext = extname3(rootFile);
35922
36319
  res.writeHead(200, { "Content-Type": MIME[ext] || "application/octet-stream" });
35923
- res.end(readFileSync10(rootFile));
36320
+ res.end(readFileSync11(rootFile));
35924
36321
  return;
35925
36322
  }
35926
36323
  if (url.pathname === "/ssr-data.js") {
@@ -35937,9 +36334,9 @@ async function startProdServer(outDir, options) {
35937
36334
  }
35938
36335
  if (url.pathname === "/_vesk/runtime.js") {
35939
36336
  const clientPath = resolve11(staticDir, "client.js");
35940
- if (existsSync9(clientPath)) {
36337
+ if (existsSync10(clientPath)) {
35941
36338
  res.writeHead(200, { "Content-Type": "application/javascript" });
35942
- res.end(readFileSync10(clientPath));
36339
+ res.end(readFileSync11(clientPath));
35943
36340
  return;
35944
36341
  }
35945
36342
  }
@@ -35951,10 +36348,10 @@ async function startProdServer(outDir, options) {
35951
36348
  res.end("Forbidden");
35952
36349
  return;
35953
36350
  }
35954
- if (existsSync9(staticPath) && statSync5(staticPath).isFile()) {
36351
+ if (existsSync10(staticPath) && statSync6(staticPath).isFile()) {
35955
36352
  const ext = extname3(staticPath);
35956
36353
  res.writeHead(200, { "Content-Type": MIME[ext] || "application/octet-stream" });
35957
- res.end(readFileSync10(staticPath));
36354
+ res.end(readFileSync11(staticPath));
35958
36355
  return;
35959
36356
  }
35960
36357
  }
@@ -35962,9 +36359,9 @@ async function startProdServer(outDir, options) {
35962
36359
  const prerendered = buildConfig.prerendered.find((r) => r.path === url.pathname);
35963
36360
  if (prerendered) {
35964
36361
  const htmlPath = resolve11(outDir, prerendered.file);
35965
- if (existsSync9(htmlPath)) {
36362
+ if (existsSync10(htmlPath)) {
35966
36363
  res.writeHead(200, { "Content-Type": "text/html" });
35967
- res.end(readFileSync10(htmlPath));
36364
+ res.end(readFileSync11(htmlPath));
35968
36365
  return;
35969
36366
  }
35970
36367
  }
@@ -36026,9 +36423,7 @@ async function startProdServer(outDir, options) {
36026
36423
  try {
36027
36424
  const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
36028
36425
  const response = await mod.handleAction(webRequest, actionId);
36029
- const body = await response.text();
36030
- res.writeHead(response.status, Object.fromEntries(response.headers));
36031
- res.end(body);
36426
+ await deliverResponse(res, response);
36032
36427
  } catch (e) {
36033
36428
  const status = errorStatus(e, 500);
36034
36429
  const message = status === 500 && process.env.NODE_ENV === "production" ? "Internal Server Error" : e instanceof Error ? e.message : String(e);
@@ -36047,9 +36442,7 @@ async function startProdServer(outDir, options) {
36047
36442
  try {
36048
36443
  const webRequest = makeWebRequest(req, url.href, maxBodyBytes);
36049
36444
  const response = await mod.handle(webRequest);
36050
- const body = await response.text();
36051
- res.writeHead(response.status, Object.fromEntries(response.headers));
36052
- res.end(body);
36445
+ await deliverResponse(res, response);
36053
36446
  return;
36054
36447
  } catch (e) {
36055
36448
  const status = errorStatus(e, 500);
@@ -36065,11 +36458,11 @@ async function startProdServer(outDir, options) {
36065
36458
  const appDir = resolve11(projectDir, "app");
36066
36459
  const nfPath = resolve11(appDir, "not-found.vsk");
36067
36460
  let notFoundHtml = null;
36068
- if (existsSync9(nfPath)) {
36461
+ if (existsSync10(nfPath)) {
36069
36462
  try {
36070
36463
  const runtimePath = resolve11(outDir, "server", "runtime.js");
36071
36464
  const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
36072
- const src2 = readFileSync10(nfPath, "utf-8");
36465
+ const src2 = readFileSync11(nfPath, "utf-8");
36073
36466
  const compName = resolveComponentName(src2) || "NotFound";
36074
36467
  notFoundHtml = await renderFullPage2(src2, compName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: nfPath });
36075
36468
  } catch {
@@ -36129,11 +36522,11 @@ async function startProdServer(outDir, options) {
36129
36522
  console.error("vesk ssr error:", err.message);
36130
36523
  const errPath = resolve11(appDir, "error.vsk");
36131
36524
  let errorHtml = null;
36132
- if (existsSync9(errPath)) {
36525
+ if (existsSync10(errPath)) {
36133
36526
  try {
36134
36527
  const runtimePath = resolve11(outDir, "server", "runtime.js");
36135
36528
  const { renderFullPage: renderFullPage2, storeDataScriptGlobal } = await import(runtimePath);
36136
- const src2 = readFileSync10(errPath, "utf-8");
36529
+ const src2 = readFileSync11(errPath, "utf-8");
36137
36530
  const compName = resolveComponentName(src2) || "Error";
36138
36531
  const expose = process.env.NODE_ENV !== "production";
36139
36532
  errorHtml = await renderFullPage2(src2, compName, { error: expose ? err.message : "Internal Server Error", stack: expose ? err.stack : "", statusCode: 500, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], clientScriptUrl: "/_vesk/static/client.js", security: securityConfig?.security || {}, externalDataScript: storeDataScriptGlobal, sourcePath: errPath });
@@ -36161,9 +36554,9 @@ async function startProdServer(outDir, options) {
36161
36554
  var __dirname6 = dirname12(fileURLToPath5(import.meta.url));
36162
36555
  async function resolveCompilerApi(name) {
36163
36556
  const monorepoSrc = resolve18(__dirname6, "..", "..", "compiler", "src");
36164
- if (existsSync15(monorepoSrc)) {
36557
+ if (existsSync16(monorepoSrc)) {
36165
36558
  const tsFile = resolve18(monorepoSrc, name.replace(/\.js$/, ".ts"));
36166
- if (existsSync15(tsFile)) {
36559
+ if (existsSync16(tsFile)) {
36167
36560
  return import(tsFile);
36168
36561
  }
36169
36562
  return import(resolve18(monorepoSrc, name));
@@ -36208,7 +36601,7 @@ async function build2(appDir, options2) {
36208
36601
  console.error(`vesk build: ${componentMap.size} external components found in ${componentsDir}`);
36209
36602
  }
36210
36603
  const apiDir = resolve18(appDir, "api");
36211
- const apiTree = existsSync15(apiDir) ? scanApiRoutes2(apiDir) : [];
36604
+ const apiTree = existsSync16(apiDir) ? scanApiRoutes2(apiDir) : [];
36212
36605
  console.error(`vesk build: ${routeTree.length} root routes, ${apiTree.length} API routes`);
36213
36606
  console.error("vesk build: bundling server runtime...");
36214
36607
  await bundleRuntime(appDir, outDir2);
@@ -36221,21 +36614,21 @@ async function build2(appDir, options2) {
36221
36614
  const mwChain2 = collectMiddlewareChain2(routeTree, node.fullPath, appDir);
36222
36615
  let mwCode = null;
36223
36616
  if (mwChain2.length > 0) {
36224
- const mwSources = mwChain2.map((m) => readFileSync15(m.sourcePath, "utf-8"));
36617
+ const mwSources = mwChain2.map((m) => readFileSync16(m.sourcePath, "utf-8"));
36225
36618
  mwCode = compileMiddlewareCode(mwSources);
36226
36619
  }
36227
36620
  const { funcPath, funcCode, name } = generateSsrFunction(node, appDir, outDir2, componentMap, { ancestorLayouts, middlewareCode: mwCode });
36228
36621
  writeFileSync8(funcPath, funcCode, "utf-8");
36229
36622
  const pagePath = resolve18(appDir, node.sourceDir, "page.vsk");
36230
- if (existsSync15(pagePath)) {
36231
- const src2 = readFileSync15(pagePath, "utf-8");
36623
+ if (existsSync16(pagePath)) {
36624
+ const src2 = readFileSync16(pagePath, "utf-8");
36232
36625
  const actionIds = collectActionIds(src2);
36233
36626
  if (node.layout) {
36234
- const layoutSrc = readFileSync15(resolve18(appDir, node.sourceDir, "layout.vsk"), "utf-8");
36627
+ const layoutSrc = readFileSync16(resolve18(appDir, node.sourceDir, "layout.vsk"), "utf-8");
36235
36628
  actionIds.push(...collectActionIds(layoutSrc));
36236
36629
  }
36237
36630
  for (const a of ancestorLayouts) {
36238
- const ancestorSrc = readFileSync15(resolve18(appDir, a.sourceDir, "layout.vsk"), "utf-8");
36631
+ const ancestorSrc = readFileSync16(resolve18(appDir, a.sourceDir, "layout.vsk"), "utf-8");
36239
36632
  actionIds.push(...collectActionIds(ancestorSrc));
36240
36633
  }
36241
36634
  for (const id of actionIds) {
@@ -36306,11 +36699,11 @@ async function build2(appDir, options2) {
36306
36699
  const altCssSrc = resolve18(srcDir, "app.css");
36307
36700
  let cssContent = null;
36308
36701
  let cssSourcePath = null;
36309
- if (existsSync15(cssSrc)) {
36310
- cssContent = readFileSync15(cssSrc, "utf-8");
36702
+ if (existsSync16(cssSrc)) {
36703
+ cssContent = readFileSync16(cssSrc, "utf-8");
36311
36704
  cssSourcePath = cssSrc;
36312
- } else if (existsSync15(altCssSrc)) {
36313
- cssContent = readFileSync15(altCssSrc, "utf-8");
36705
+ } else if (existsSync16(altCssSrc)) {
36706
+ cssContent = readFileSync16(altCssSrc, "utf-8");
36314
36707
  cssSourcePath = altCssSrc;
36315
36708
  }
36316
36709
  function stripTailwindDirectives2(css) {
@@ -36389,13 +36782,13 @@ async function build2(appDir, options2) {
36389
36782
  const publicDirResolved = resolve18(outDir2, "static", "public");
36390
36783
  const siteUrl = options2?.siteUrl || "http://localhost:3000";
36391
36784
  const sitemapOverride = resolve18(publicDirResolved, "sitemap.xml");
36392
- if (!existsSync15(sitemapOverride)) {
36785
+ if (!existsSync16(sitemapOverride)) {
36393
36786
  const sitemap = generateSitemap2(routeTree, ssrRoutes, prerenderedRoutes, { siteUrl });
36394
36787
  writeFileSync8(sitemapOverride, sitemap, "utf-8");
36395
36788
  console.error(`vesk build: seo \u2192 static/public/sitemap.xml (${sitemap.length} bytes)`);
36396
36789
  }
36397
36790
  const robotsOverride = resolve18(publicDirResolved, "robots.txt");
36398
- if (!existsSync15(robotsOverride)) {
36791
+ if (!existsSync16(robotsOverride)) {
36399
36792
  const robots = generateRobotsTxt2(siteUrl);
36400
36793
  writeFileSync8(robotsOverride, robots, "utf-8");
36401
36794
  console.error(`vesk build: seo \u2192 static/public/robots.txt (${robots.length} bytes)`);
@@ -36441,7 +36834,7 @@ vesk build: done (${outDir2})`);
36441
36834
  init_seo_audit();
36442
36835
 
36443
36836
  // src/dev-server.ts
36444
- import { readFileSync as readFileSync20, watch, statSync as statSync14, existsSync as existsSync22, readdirSync as readdirSync11 } from "node:fs";
36837
+ import { readFileSync as readFileSync22, watch, statSync as statSync16, existsSync as existsSync24, readdirSync as readdirSync11 } from "node:fs";
36445
36838
  import { resolve as resolve24, extname as extname6, join as join13 } from "node:path";
36446
36839
  import { createServer as createServer2 } from "node:http";
36447
36840
  import { WebSocketServer } from "ws";
@@ -38130,7 +38523,7 @@ init_parser();
38130
38523
  init_tokens();
38131
38524
  init_scan();
38132
38525
  init_strip_ts();
38133
- import { readdirSync as readdirSync7, statSync as statSync10, existsSync as existsSync16, readFileSync as readFileSync16 } from "fs";
38526
+ import { readdirSync as readdirSync7, statSync as statSync11, existsSync as existsSync17, readFileSync as readFileSync17 } from "fs";
38134
38527
  import { join as join9, relative as relative5, basename } from "path";
38135
38528
  function collapseSlashes2(p) {
38136
38529
  let out = "";
@@ -38148,7 +38541,7 @@ function collapseSlashes2(p) {
38148
38541
  return out;
38149
38542
  }
38150
38543
  function scanRoutes(appDir, options2 = {}) {
38151
- if (!existsSync16(appDir)) {
38544
+ if (!existsSync17(appDir)) {
38152
38545
  return [];
38153
38546
  }
38154
38547
  return scanDirectory(appDir, appDir, "/", options2);
@@ -38254,7 +38647,7 @@ function scanDirectory(rootDir, dir, parentPath, options2) {
38254
38647
  const entryPath = join9(dir, entry);
38255
38648
  let entryStat;
38256
38649
  try {
38257
- entryStat = statSync10(entryPath);
38650
+ entryStat = statSync11(entryPath);
38258
38651
  } catch {
38259
38652
  continue;
38260
38653
  }
@@ -38401,7 +38794,7 @@ function matchUrl(tree, pathname) {
38401
38794
  }
38402
38795
 
38403
38796
  // ../compiler/dist/api-routes.js
38404
- import { readdirSync as readdirSync8, statSync as statSync11, existsSync as existsSync17 } from "fs";
38797
+ import { readdirSync as readdirSync8, statSync as statSync12, existsSync as existsSync18 } from "fs";
38405
38798
  import { join as join10 } from "path";
38406
38799
  init_server_utils();
38407
38800
  function basename2(p) {
@@ -38409,7 +38802,7 @@ function basename2(p) {
38409
38802
  return idx === -1 ? p : p.slice(idx + 1);
38410
38803
  }
38411
38804
  function scanApiRoutes(apiDir) {
38412
- if (!existsSync17(apiDir))
38805
+ if (!existsSync18(apiDir))
38413
38806
  return [];
38414
38807
  return scanApiDir(apiDir, apiDir, "/");
38415
38808
  }
@@ -38442,7 +38835,7 @@ function scanApiDir(rootDir, dir, parentPath) {
38442
38835
  const entryPath = join10(dir, entry);
38443
38836
  let entryStat;
38444
38837
  try {
38445
- entryStat = statSync11(entryPath);
38838
+ entryStat = statSync12(entryPath);
38446
38839
  } catch {
38447
38840
  continue;
38448
38841
  }
@@ -38476,7 +38869,7 @@ function scanApiDir(rootDir, dir, parentPath) {
38476
38869
  const entryPath = join10(dir, entry);
38477
38870
  let entryStat;
38478
38871
  try {
38479
- entryStat = statSync11(entryPath);
38872
+ entryStat = statSync12(entryPath);
38480
38873
  } catch {
38481
38874
  continue;
38482
38875
  }
@@ -38774,7 +39167,7 @@ async function executeRewrite(url, originalRequest) {
38774
39167
  }
38775
39168
 
38776
39169
  // ../compiler/dist/middleware.js
38777
- import { existsSync as existsSync18 } from "fs";
39170
+ import { existsSync as existsSync19 } from "fs";
38778
39171
  import { resolve as resolve19 } from "path";
38779
39172
 
38780
39173
  // ../compiler/src/api-routes.ts
@@ -38835,7 +39228,7 @@ function collectMiddlewareChain(routeTree, url, appDir) {
38835
39228
  function collectForNode(node) {
38836
39229
  if (node.hasMiddleware) {
38837
39230
  const mwPath2 = resolve19(appDir, node.sourceDir, "middleware.ts");
38838
- if (existsSync18(mwPath2)) {
39231
+ if (existsSync19(mwPath2)) {
38839
39232
  chain.push({ sourcePath: mwPath2, node });
38840
39233
  }
38841
39234
  }
@@ -38998,7 +39391,7 @@ async function executeMiddlewareChain(chain, request, params, options2 = {}) {
38998
39391
  }
38999
39392
 
39000
39393
  // ../adapter/dist/client-bundle.js
39001
- import { readFileSync as readFileSync17, existsSync as existsSync19, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3, statSync as statSync12 } from "node:fs";
39394
+ import { readFileSync as readFileSync18, existsSync as existsSync20, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3, statSync as statSync13 } from "node:fs";
39002
39395
  import { resolve as resolve20, join as join11, dirname as dirname13, relative as relative6, sep as sep3 } from "node:path";
39003
39396
  import { fileURLToPath as fileURLToPath6 } from "node:url";
39004
39397
 
@@ -39057,7 +39450,7 @@ init_md_inline();
39057
39450
  var __dirname7 = dirname13(fileURLToPath6(import.meta.url));
39058
39451
  function fileUnchanged2(filePath, cached) {
39059
39452
  try {
39060
- const st = statSync12(filePath);
39453
+ const st = statSync13(filePath);
39061
39454
  return st.mtimeMs === cached.mtimeMs && st.size === cached.size;
39062
39455
  } catch {
39063
39456
  return false;
@@ -39079,7 +39472,7 @@ function findRuntimeSrc3(appDir) {
39079
39472
  ];
39080
39473
  for (const base of candidates) {
39081
39474
  for (const dir of [base, join11(base, "dist")]) {
39082
- if (existsSync19(join11(dir, "index-client.js")))
39475
+ if (existsSync20(join11(dir, "index-client.js")))
39083
39476
  return dir;
39084
39477
  }
39085
39478
  }
@@ -39119,11 +39512,11 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
39119
39512
  return code.replace(/^import\s*\{[^}]*\}\s*from\s*['"][^'"]*\.vsk['"];?\s*\n?/gm, "");
39120
39513
  }
39121
39514
  function resolveVskImports(filePath, compile) {
39122
- const src2 = readFileSync17(filePath, "utf-8");
39515
+ const src2 = readFileSync18(filePath, "utf-8");
39123
39516
  const resolved = [];
39124
39517
  for (const importPath of collectVskImportPaths(vskImportLines(src2), filePath)) {
39125
39518
  try {
39126
- readFileSync17(importPath);
39519
+ readFileSync18(importPath);
39127
39520
  } catch {
39128
39521
  continue;
39129
39522
  }
@@ -39168,7 +39561,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
39168
39561
  return;
39169
39562
  }
39170
39563
  compiledFiles++;
39171
- let src2 = readFileSync17(filePath, "utf-8");
39564
+ let src2 = readFileSync18(filePath, "utf-8");
39172
39565
  if (/content=["'][^"']*\.md["']/i.test(src2)) {
39173
39566
  src2 = inlineMdContentAttrs(src2, dirname13(filePath), guessProjectRoots(appDir));
39174
39567
  }
@@ -39195,7 +39588,7 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
39195
39588
  output.push(`Object.defineProperty(__hydrators, ${JSON.stringify(resolvedName)}, { get: () => __hydrators[${JSON.stringify(actualName)}], configurable: true });`);
39196
39589
  }
39197
39590
  if (cache2 && namesBefore) {
39198
- const st = statSync12(filePath);
39591
+ const st = statSync13(filePath);
39199
39592
  cache2.files.set(filePath, {
39200
39593
  mtimeMs: st.mtimeMs,
39201
39594
  size: st.size,
@@ -39219,31 +39612,31 @@ async function generateClientBundle2(routeTree, appDir, componentMap, options2)
39219
39612
  for (const node of nodes) {
39220
39613
  const chunkCode = [];
39221
39614
  const pagePath = resolve20(appDir, node.sourceDir, "page.vsk");
39222
- if (node.page && existsSync19(pagePath)) {
39615
+ if (node.page && existsSync20(pagePath)) {
39223
39616
  compileFile2(pagePath, node.page, chunkCode);
39224
39617
  }
39225
39618
  const layoutPath = resolve20(appDir, node.sourceDir, "layout.vsk");
39226
- if (node.layout && existsSync19(layoutPath)) {
39619
+ if (node.layout && existsSync20(layoutPath)) {
39227
39620
  compileFile2(layoutPath, node.layout, chunkCode);
39228
39621
  }
39229
39622
  const errorPath = resolve20(appDir, node.sourceDir, "error.vsk");
39230
- if (node.error && existsSync19(errorPath)) {
39623
+ if (node.error && existsSync20(errorPath)) {
39231
39624
  compileFile2(errorPath, node.error, chunkCode);
39232
39625
  }
39233
39626
  const notFoundPath = resolve20(appDir, node.sourceDir, "not-found.vsk");
39234
- if (node.notFound && existsSync19(notFoundPath)) {
39627
+ if (node.notFound && existsSync20(notFoundPath)) {
39235
39628
  compileFile2(notFoundPath, node.notFound, chunkCode);
39236
39629
  }
39237
39630
  const offlinePath = resolve20(appDir, node.sourceDir, "offline.vsk");
39238
- if (node.offline && existsSync19(offlinePath)) {
39631
+ if (node.offline && existsSync20(offlinePath)) {
39239
39632
  compileFile2(offlinePath, node.offline, chunkCode);
39240
39633
  }
39241
39634
  const networkPath = resolve20(appDir, node.sourceDir, "network.vsk");
39242
- if (node.network && existsSync19(networkPath)) {
39635
+ if (node.network && existsSync20(networkPath)) {
39243
39636
  compileFile2(networkPath, node.network, chunkCode);
39244
39637
  }
39245
39638
  const loadingPath = resolve20(appDir, node.sourceDir, "loading.vsk");
39246
- if (node.loading && existsSync19(loadingPath)) {
39639
+ if (node.loading && existsSync20(loadingPath)) {
39247
39640
  compileFile2(loadingPath, node.loading, chunkCode);
39248
39641
  }
39249
39642
  if (chunkCode.length > 0) {
@@ -39302,7 +39695,7 @@ ${entry.code}
39302
39695
  if (seen.has(filePath))
39303
39696
  return;
39304
39697
  seen.add(filePath);
39305
- const src2 = readFileSync17(filePath, "utf-8");
39698
+ const src2 = readFileSync18(filePath, "utf-8");
39306
39699
  resolveVskImports(filePath, (p, n) => compileFileMono2(p, n || ""));
39307
39700
  const compCode = compileClient(src2, null, { forceClient: true });
39308
39701
  if (compCode) {
@@ -39324,25 +39717,25 @@ ${entry.code}
39324
39717
  }, walkMono2 = function(nodes) {
39325
39718
  for (const node of nodes) {
39326
39719
  const pagePath = resolve20(appDir, node.sourceDir, "page.vsk");
39327
- if (node.page && existsSync19(pagePath))
39720
+ if (node.page && existsSync20(pagePath))
39328
39721
  compileFileMono2(pagePath, node.page);
39329
39722
  const layoutPath = resolve20(appDir, node.sourceDir, "layout.vsk");
39330
- if (node.layout && existsSync19(layoutPath))
39723
+ if (node.layout && existsSync20(layoutPath))
39331
39724
  compileFileMono2(layoutPath, node.layout);
39332
39725
  const errorPath = resolve20(appDir, node.sourceDir, "error.vsk");
39333
- if (node.error && existsSync19(errorPath))
39726
+ if (node.error && existsSync20(errorPath))
39334
39727
  compileFileMono2(errorPath, node.error);
39335
39728
  const notFoundPath = resolve20(appDir, node.sourceDir, "not-found.vsk");
39336
- if (node.notFound && existsSync19(notFoundPath))
39729
+ if (node.notFound && existsSync20(notFoundPath))
39337
39730
  compileFileMono2(notFoundPath, node.notFound);
39338
39731
  const offlinePath = resolve20(appDir, node.sourceDir, "offline.vsk");
39339
- if (node.offline && existsSync19(offlinePath))
39732
+ if (node.offline && existsSync20(offlinePath))
39340
39733
  compileFileMono2(offlinePath, node.offline);
39341
39734
  const networkPath = resolve20(appDir, node.sourceDir, "network.vsk");
39342
- if (node.network && existsSync19(networkPath))
39735
+ if (node.network && existsSync20(networkPath))
39343
39736
  compileFileMono2(networkPath, node.network);
39344
39737
  const loadingPath = resolve20(appDir, node.sourceDir, "loading.vsk");
39345
- if (node.loading && existsSync19(loadingPath))
39738
+ if (node.loading && existsSync20(loadingPath))
39346
39739
  compileFileMono2(loadingPath, node.loading);
39347
39740
  walkMono2(node.children || []);
39348
39741
  }
@@ -39393,8 +39786,8 @@ function buildRuntimeCode2(runtimeDir) {
39393
39786
  let code = "";
39394
39787
  for (const f of runtimeFiles) {
39395
39788
  const p = join11(runtimeDir, f);
39396
- if (existsSync19(p)) {
39397
- let src2 = readFileSync17(p, "utf-8");
39789
+ if (existsSync20(p)) {
39790
+ let src2 = readFileSync18(p, "utf-8");
39398
39791
  src2 = stripTypes2(src2);
39399
39792
  src2 = src2.replace(/^import\s+[\s\S]*?from\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
39400
39793
  src2 = src2.replace(/^import\s+['"](?:\.\/.*?|@vesk\/runtime\/src\/.*?)['"];?\n?/gm, "");
@@ -39406,7 +39799,7 @@ ${src2}
39406
39799
  `;
39407
39800
  }
39408
39801
  }
39409
- const indexSrc = readFileSync17(join11(runtimeDir, "index-client.js"), "utf-8");
39802
+ const indexSrc = readFileSync18(join11(runtimeDir, "index-client.js"), "utf-8");
39410
39803
  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())) || [];
39411
39804
  code += "// --- exports ---\n";
39412
39805
  for (const name of [...new Set(exportNames)]) {
@@ -39417,7 +39810,7 @@ ${src2}
39417
39810
  return code;
39418
39811
  }
39419
39812
  function runtimeExportNames2(runtimeDir) {
39420
- const indexSrc = readFileSync17(join11(runtimeDir, "index-client.js"), "utf-8");
39813
+ const indexSrc = readFileSync18(join11(runtimeDir, "index-client.js"), "utf-8");
39421
39814
  const names = /* @__PURE__ */ new Set();
39422
39815
  for (const m of indexSrc.matchAll(/export\s*\{([^}]+)\}\s*from/g)) {
39423
39816
  for (const raw2 of m[1].split(",")) {
@@ -39564,6 +39957,7 @@ if (typeof document !== 'undefined') __router.start();
39564
39957
 
39565
39958
  // ../adapter/dist/paths.js
39566
39959
  import { resolve as resolve21, sep as sep4 } from "node:path";
39960
+ import { existsSync as existsSync21, statSync as statSync14, readFileSync as readFileSync19 } from "node:fs";
39567
39961
  function resolveWithin2(baseDir, relPath) {
39568
39962
  const base = resolve21(baseDir);
39569
39963
  const target = resolve21(baseDir, relPath);
@@ -39572,6 +39966,28 @@ function resolveWithin2(baseDir, relPath) {
39572
39966
  return null;
39573
39967
  return target;
39574
39968
  }
39969
+ function installMdReadHook2(publicDirs) {
39970
+ const dirs = publicDirs.map((d) => resolve21(d));
39971
+ globalThis.__vsk_md_read_file = (p) => {
39972
+ for (const dir of dirs) {
39973
+ try {
39974
+ let rel = String(p);
39975
+ while (rel.length > 0 && rel.charCodeAt(0) === 47)
39976
+ rel = rel.slice(1);
39977
+ const abs = resolveWithin2(dir, rel);
39978
+ if (!abs)
39979
+ continue;
39980
+ const lower = abs.toLowerCase();
39981
+ if (!lower.endsWith(".md") && !lower.endsWith(".markdown"))
39982
+ continue;
39983
+ if (existsSync21(abs) && statSync14(abs).isFile())
39984
+ return readFileSync19(abs, "utf8");
39985
+ } catch {
39986
+ }
39987
+ }
39988
+ return null;
39989
+ };
39990
+ }
39575
39991
  function isAllowedWsUpgrade(headers2) {
39576
39992
  const origin = typeof headers2["origin"] === "string" ? headers2["origin"] : "";
39577
39993
  if (!origin)
@@ -39633,7 +40049,7 @@ function urlAuthority3(url) {
39633
40049
 
39634
40050
  // src/build-packages.ts
39635
40051
  import { spawnSync } from "node:child_process";
39636
- import { cpSync, existsSync as existsSync20, mkdirSync as mkdirSync7, readFileSync as readFileSync18, readdirSync as readdirSync9, statSync as statSync13, writeFileSync as writeFileSync10 } from "node:fs";
40052
+ import { cpSync, existsSync as existsSync22, mkdirSync as mkdirSync7, readFileSync as readFileSync20, readdirSync as readdirSync9, statSync as statSync15, writeFileSync as writeFileSync10 } from "node:fs";
39637
40053
  import { createRequire as createRequire3 } from "node:module";
39638
40054
  import { dirname as dirname14, join as join12, resolve as resolve22 } from "node:path";
39639
40055
  import { fileURLToPath as fileURLToPath7 } from "node:url";
@@ -39656,7 +40072,7 @@ function newestSourceMtime(srcDir) {
39656
40072
  let newest = 0;
39657
40073
  for (const name of readdirSync9(srcDir)) {
39658
40074
  const p = join12(srcDir, name);
39659
- const st = statSync13(p);
40075
+ const st = statSync15(p);
39660
40076
  if (st.isDirectory()) {
39661
40077
  newest = Math.max(newest, newestSourceMtime(p));
39662
40078
  } else if (st.isFile() && /\.ts$/.test(name) && !name.endsWith(".test.ts")) {
@@ -39667,9 +40083,9 @@ function newestSourceMtime(srcDir) {
39667
40083
  }
39668
40084
  function distStale(pkgDir, entry) {
39669
40085
  const distIndex = join12(pkgDir, "dist", `${entry}.js`);
39670
- if (!existsSync20(distIndex)) return true;
40086
+ if (!existsSync22(distIndex)) return true;
39671
40087
  const distPkg = join12(pkgDir, "dist", "package.json");
39672
- const distStamp = Math.max(statSync13(distIndex).mtimeMs, existsSync20(distPkg) ? statSync13(distPkg).mtimeMs : 0);
40088
+ const distStamp = Math.max(statSync15(distIndex).mtimeMs, existsSync22(distPkg) ? statSync15(distPkg).mtimeMs : 0);
39673
40089
  return newestSourceMtime(join12(pkgDir, "src")) > distStamp;
39674
40090
  }
39675
40091
  function distPackageJson(pkgName, entry, serverEntry, version2) {
@@ -39694,7 +40110,7 @@ function distPackageJson(pkgName, entry, serverEntry, version2) {
39694
40110
  function buildPackages(force = false) {
39695
40111
  for (const [pkg, cfg] of Object.entries(PACKAGES)) {
39696
40112
  const pkgDir = resolve22(root2, "packages", pkg);
39697
- if (!existsSync20(join12(pkgDir, "src"))) continue;
40113
+ if (!existsSync22(join12(pkgDir, "src"))) continue;
39698
40114
  if (!force && !distStale(pkgDir, cfg.entry)) continue;
39699
40115
  console.log(`[build] ${cfg.name} -> tsc`);
39700
40116
  const tscBin = require2.resolve("typescript/bin/tsc");
@@ -39710,7 +40126,7 @@ function buildPackages(force = false) {
39710
40126
  mkdirSync7(dirname14(to), { recursive: true });
39711
40127
  cpSync(join12(pkgDir, c.from), to, { recursive: true });
39712
40128
  }
39713
- const srcPkg = JSON.parse(readFileSync18(join12(pkgDir, "package.json"), "utf-8"));
40129
+ const srcPkg = JSON.parse(readFileSync20(join12(pkgDir, "package.json"), "utf-8"));
39714
40130
  writeFileSync10(join12(distDir, "package.json"), distPackageJson(cfg.name, cfg.entry, cfg.serverEntry, srcPkg.version || "1.0.0"));
39715
40131
  console.log(`[build] ${cfg.name} -> dist`);
39716
40132
  }
@@ -39723,7 +40139,7 @@ if (process.argv[1] && resolve22(process.argv[1]) === fileURLToPath7(import.meta
39723
40139
  }
39724
40140
 
39725
40141
  // src/action-handler.ts
39726
- import { existsSync as existsSync21, readFileSync as readFileSync19, readdirSync as readdirSync10 } from "node:fs";
40142
+ import { existsSync as existsSync23, readFileSync as readFileSync21, readdirSync as readdirSync10 } from "node:fs";
39727
40143
  import { resolve as resolve23 } from "node:path";
39728
40144
 
39729
40145
  // ../compiler/dist/server-cookies.js
@@ -39810,7 +40226,7 @@ function pageSourcesFor(appDirPath, routeTree) {
39810
40226
  return out;
39811
40227
  }
39812
40228
  function walkVskFiles(dir, out, seen) {
39813
- if (!existsSync21(dir)) return;
40229
+ if (!existsSync23(dir)) return;
39814
40230
  let entries;
39815
40231
  try {
39816
40232
  entries = readdirSync10(dir, { withFileTypes: true });
@@ -39845,9 +40261,9 @@ function candidateSources(appDirPath, routeTree) {
39845
40261
  return out;
39846
40262
  }
39847
40263
  function registerSource(sourcePath2) {
39848
- if (!existsSync21(sourcePath2)) return;
40264
+ if (!existsSync23(sourcePath2)) return;
39849
40265
  try {
39850
- compileFile(readFileSync19(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
40266
+ compileFile(readFileSync21(sourcePath2, "utf-8"), { sourcePath: sourcePath2 });
39851
40267
  } catch {
39852
40268
  }
39853
40269
  }
@@ -39885,22 +40301,22 @@ async function renderPageHtml(pagePathname, params, ctx2) {
39885
40301
  const node = chain[i];
39886
40302
  const pageFilePath = resolve23(ctx2.appDirPath, node.sourceDir, "page.vsk");
39887
40303
  const layoutFilePath = resolve23(ctx2.appDirPath, node.sourceDir, "layout.vsk");
39888
- if (i === chain.length - 1 && node.page && existsSync21(pageFilePath)) {
39889
- const src3 = readFileSync19(pageFilePath, "utf-8");
40304
+ if (i === chain.length - 1 && node.page && existsSync23(pageFilePath)) {
40305
+ const src3 = readFileSync21(pageFilePath, "utf-8");
39890
40306
  const compName2 = resolveComponentName(src3) || node.page;
39891
40307
  const result2 = await renderPage(src3, compName2, { params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
39892
40308
  body = result2.body;
39893
40309
  head = result2.head || "";
39894
40310
  }
39895
- if (node.layout && existsSync21(layoutFilePath)) {
39896
- const src3 = readFileSync19(layoutFilePath, "utf-8");
40311
+ if (node.layout && existsSync23(layoutFilePath)) {
40312
+ const src3 = readFileSync21(layoutFilePath, "utf-8");
39897
40313
  const compName2 = resolveComponentName(src3) || node.layout;
39898
40314
  const result2 = await renderPage(src3, compName2, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
39899
40315
  body = result2.body;
39900
40316
  head = (result2.head || "") + head;
39901
40317
  }
39902
40318
  }
39903
- const hasLayout = chain.some((n) => n.layout && existsSync21(resolve23(ctx2.appDirPath, n.sourceDir, "layout.vsk")));
40319
+ const hasLayout = chain.some((n) => n.layout && existsSync23(resolve23(ctx2.appDirPath, n.sourceDir, "layout.vsk")));
39904
40320
  if (hasLayout) {
39905
40321
  const secMeta = securityMeta(ctx2.security);
39906
40322
  return `<!DOCTYPE html>
@@ -39922,7 +40338,7 @@ ${prettifyHtml(body)}
39922
40338
  }
39923
40339
  const leaf = chain.find((n) => n.page);
39924
40340
  if (!leaf) return null;
39925
- const src2 = readFileSync19(resolve23(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
40341
+ const src2 = readFileSync21(resolve23(ctx2.appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
39926
40342
  const compName = resolveComponentName(src2) || leaf.page;
39927
40343
  const html = await renderFullPage(src2, compName, { params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security: ctx2.security, sourcePath: resolve23(ctx2.appDirPath, leaf.sourceDir, "page.vsk") });
39928
40344
  return html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
@@ -40073,9 +40489,9 @@ function resolveRuntimeDir(projectDir2) {
40073
40489
  resolve24(import.meta.dirname ?? ".", "..", "..", "runtime", "dist")
40074
40490
  ];
40075
40491
  for (const dir of candidates) {
40076
- if (existsSync22(join13(dir, "ripple-runtime.js"))) return dir;
40492
+ if (existsSync24(join13(dir, "ripple-runtime.js"))) return dir;
40077
40493
  const distDir = join13(dir, "dist");
40078
- if (existsSync22(join13(distDir, "ripple-runtime.js"))) return distDir;
40494
+ if (existsSync24(join13(distDir, "ripple-runtime.js"))) return distDir;
40079
40495
  }
40080
40496
  return null;
40081
40497
  }
@@ -40145,7 +40561,7 @@ function collectRoutePaths(nodes, out = []) {
40145
40561
  return out;
40146
40562
  }
40147
40563
  function countFilesNamed(dir, name) {
40148
- if (!existsSync22(dir)) return 0;
40564
+ if (!existsSync24(dir)) return 0;
40149
40565
  let n = 0;
40150
40566
  for (const entry of readdirSync11(dir, { withFileTypes: true })) {
40151
40567
  const p = join13(dir, entry.name);
@@ -40161,6 +40577,7 @@ async function startDevServer(port2, projectDir2, config, host2) {
40161
40577
  const maxBodyBytes2 = (typeof secCfg.maxBodyBytes === "number" ? secCfg.maxBodyBytes : void 0) || DEFAULT_MAX_BODY_BYTES;
40162
40578
  const appDirPath = join13(projectDir2, "app");
40163
40579
  const publicDir = join13(projectDir2, "public");
40580
+ installMdReadHook2([publicDir]);
40164
40581
  try {
40165
40582
  ensurePackagesBuilt();
40166
40583
  } catch (e) {
@@ -40181,10 +40598,10 @@ async function startDevServer(port2, projectDir2, config, host2) {
40181
40598
  const cssPath = join13(srcDir, "global.css");
40182
40599
  const altCssPath = join13(srcDir, "app.css");
40183
40600
  let rawCss = "";
40184
- if (existsSync22(cssPath)) {
40185
- rawCss = readFileSync20(cssPath, "utf-8");
40186
- } else if (existsSync22(altCssPath)) {
40187
- rawCss = readFileSync20(altCssPath, "utf-8");
40601
+ if (existsSync24(cssPath)) {
40602
+ rawCss = readFileSync22(cssPath, "utf-8");
40603
+ } else if (existsSync24(altCssPath)) {
40604
+ rawCss = readFileSync22(altCssPath, "utf-8");
40188
40605
  }
40189
40606
  if (rawCss) {
40190
40607
  for (const plugin of devPlugins) {
@@ -40310,7 +40727,7 @@ async function startDevServer(port2, projectDir2, config, host2) {
40310
40727
  let debounceTimer = null;
40311
40728
  let cssDebounceTimer = null;
40312
40729
  const watchDirs = [appDirPath];
40313
- if (existsSync22(srcDir)) watchDirs.push(srcDir);
40730
+ if (existsSync24(srcDir)) watchDirs.push(srcDir);
40314
40731
  for (const watchDir of watchDirs) {
40315
40732
  watch(watchDir, { recursive: true }, (eventType, filename) => {
40316
40733
  if (!filename) return;
@@ -40319,7 +40736,7 @@ async function startDevServer(port2, projectDir2, config, host2) {
40319
40736
  const isApiRoute = filename.endsWith(".ts") || filename.endsWith(".js") || filename.endsWith(".tsx");
40320
40737
  if (!isVsk && !isCss && !isApiRoute) return;
40321
40738
  const fullPath = filename.startsWith("/") ? filename : join13(watchDir, filename);
40322
- const fileExists = existsSync22(fullPath);
40739
+ const fileExists = existsSync24(fullPath);
40323
40740
  if (isVsk) {
40324
40741
  if (debounceTimer) clearTimeout(debounceTimer);
40325
40742
  debounceTimer = setTimeout(async () => {
@@ -40368,7 +40785,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40368
40785
  if (compCode.trim()) fnSources = { _raw: compCode };
40369
40786
  } else if (fileExists && !bundleError) {
40370
40787
  try {
40371
- const src2 = readFileSync20(fullPath, "utf-8");
40788
+ const src2 = readFileSync22(fullPath, "utf-8");
40372
40789
  let compCode = compileClient2(src2, null, { forceClient: true, sourcePath: fullPath, mdRoots: [projectDir2] });
40373
40790
  compCode = compCode.replace(/^import\s*[\s\S]*?from\s*['"][^'"]+['"];?\s*\n?/gm, "");
40374
40791
  compCode = compCode.replace(/^const __components = \{\};\s*\n?/m, "");
@@ -40424,7 +40841,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40424
40841
  let code = "";
40425
40842
  if (line > 0 && fileExists) {
40426
40843
  try {
40427
- const src2 = readFileSync20(fullPath, "utf-8");
40844
+ const src2 = readFileSync22(fullPath, "utf-8");
40428
40845
  const lines = src2.split("\n");
40429
40846
  const start = Math.max(0, line - 3);
40430
40847
  const end = Math.min(lines.length, line + 2);
@@ -40475,7 +40892,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40475
40892
  cssDebounceTimer = setTimeout(async () => {
40476
40893
  try {
40477
40894
  if (fileExists) {
40478
- rawCss = readFileSync20(fullPath, "utf-8");
40895
+ rawCss = readFileSync22(fullPath, "utf-8");
40479
40896
  }
40480
40897
  const cssChanged = await rebuildTailwindCss();
40481
40898
  if (cssChanged && typeof globalThis.__vesk_broadcastHmr === "function") {
@@ -40509,7 +40926,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40509
40926
  };
40510
40927
  const hmrJsPath = join13(runtimeDir, "hmr-client.js");
40511
40928
  const hmrTsPath = join13(runtimeDir, "hmr-client.ts");
40512
- const hmrClientPath = existsSync22(hmrJsPath) ? hmrJsPath : existsSync22(hmrTsPath) ? hmrTsPath : null;
40929
+ const hmrClientPath = existsSync24(hmrJsPath) ? hmrJsPath : existsSync24(hmrTsPath) ? hmrTsPath : null;
40513
40930
  function extractCompName2(src2) {
40514
40931
  return resolveComponentName(src2);
40515
40932
  }
@@ -40610,7 +41027,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40610
41027
  }
40611
41028
  if (url.pathname === "/_vesk/hmr" || url.pathname === "/_vesk/hmr.js") {
40612
41029
  if (hmrClientPath) {
40613
- let hmrContent = readFileSync20(hmrClientPath, "utf-8");
41030
+ let hmrContent = readFileSync22(hmrClientPath, "utf-8");
40614
41031
  if (hmrClientPath.endsWith(".ts")) {
40615
41032
  hmrContent = stripCodeTypes2(hmrContent);
40616
41033
  }
@@ -40624,16 +41041,16 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40624
41041
  }
40625
41042
  if (url.pathname !== "/") {
40626
41043
  const staticPath = url.pathname.length > 1 ? resolveWithin2(publicDir, url.pathname.slice(1)) : null;
40627
- if (staticPath && existsSync22(staticPath) && statSync14(staticPath).isFile()) {
41044
+ if (staticPath && existsSync24(staticPath) && statSync16(staticPath).isFile()) {
40628
41045
  const ext = extname6(staticPath);
40629
41046
  res.writeHead(200, { "Content-Type": MIME3[ext] || "application/octet-stream" });
40630
- res.end(readFileSync20(staticPath));
41047
+ res.end(readFileSync22(staticPath));
40631
41048
  return;
40632
41049
  }
40633
41050
  }
40634
41051
  const mwChain = collectMiddlewareChain(routeTree, url.pathname, appDirPath);
40635
41052
  const apiDirPath = join13(appDirPath, "api");
40636
- if (url.pathname.startsWith("/api") && existsSync22(apiDirPath)) {
41053
+ if (url.pathname.startsWith("/api") && existsSync24(apiDirPath)) {
40637
41054
  const apiRoutes = await scanApiRoutes(apiDirPath);
40638
41055
  const apiMatch = matchApiUrl(apiRoutes, req.url || url.pathname);
40639
41056
  if (apiMatch) {
@@ -40709,9 +41126,9 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40709
41126
  let notFoundHtml = null;
40710
41127
  if (rootNode && rootNode.notFound) {
40711
41128
  const nfPath = resolve24(appDirPath, rootNode.sourceDir, "not-found.vsk");
40712
- if (existsSync22(nfPath)) {
41129
+ if (existsSync24(nfPath)) {
40713
41130
  try {
40714
- const nfSrc = readFileSync20(nfPath, "utf-8");
41131
+ const nfSrc = readFileSync22(nfPath, "utf-8");
40715
41132
  const nfCompName = extractCompName2(nfSrc) || rootNode.notFound;
40716
41133
  notFoundHtml = await renderFullPage(nfSrc, nfCompName, { params: {}, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: nfPath });
40717
41134
  } catch {
@@ -40750,16 +41167,16 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40750
41167
  const node = chain[i];
40751
41168
  const pageFilePath = resolve24(appDirPath, node.sourceDir, "page.vsk");
40752
41169
  const layoutFilePath = resolve24(appDirPath, node.sourceDir, "layout.vsk");
40753
- if (i === chain.length - 1 && node.page && existsSync22(pageFilePath)) {
40754
- const src2 = readFileSync20(pageFilePath, "utf-8");
41170
+ if (i === chain.length - 1 && node.page && existsSync24(pageFilePath)) {
41171
+ const src2 = readFileSync22(pageFilePath, "utf-8");
40755
41172
  const compName = extractCompName2(src2) || node.page;
40756
41173
  const result2 = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
40757
41174
  body = result2.body;
40758
41175
  head = result2.head || "";
40759
41176
  props = result2.props;
40760
41177
  }
40761
- if (node.layout && existsSync22(layoutFilePath)) {
40762
- const src2 = readFileSync20(layoutFilePath, "utf-8");
41178
+ if (node.layout && existsSync24(layoutFilePath)) {
41179
+ const src2 = readFileSync22(layoutFilePath, "utf-8");
40763
41180
  const compName = extractCompName2(src2) || node.layout;
40764
41181
  const result2 = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
40765
41182
  body = result2.body;
@@ -40769,7 +41186,7 @@ Object.defineProperty(__components, ${JSON.stringify(cname)}, { get: () => __com
40769
41186
  if (forData) {
40770
41187
  return { html: "", props: props || { params: matched.params }, head };
40771
41188
  }
40772
- const hasLayout = chain.some((n) => n.layout && existsSync22(resolve24(appDirPath, n.sourceDir, "layout.vsk")));
41189
+ const hasLayout = chain.some((n) => n.layout && existsSync24(resolve24(appDirPath, n.sourceDir, "layout.vsk")));
40773
41190
  let html;
40774
41191
  if (hasLayout) {
40775
41192
  const ssrData = ssrSink3.snapshot();
@@ -40801,7 +41218,7 @@ ${prettifyHtml(body)}
40801
41218
  } else {
40802
41219
  const leaf = chain.find((n) => n.page);
40803
41220
  if (leaf) {
40804
- const src2 = readFileSync20(resolve24(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
41221
+ const src2 = readFileSync22(resolve24(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
40805
41222
  const compName = extractCompName2(src2) || leaf.page;
40806
41223
  html = await renderFullPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: resolve24(appDirPath, leaf.sourceDir, "page.vsk") });
40807
41224
  html = html.replace("</body>", ' <script type="module" src="/_vesk/hmr.js"></script>\n</body>');
@@ -40815,11 +41232,11 @@ ${prettifyHtml(body)}
40815
41232
  function renderSSRStream() {
40816
41233
  async function* raw2() {
40817
41234
  const chain = cleanChain;
40818
- const hasLayout = chain.some((n) => n.layout && existsSync22(resolve24(appDirPath, n.sourceDir, "layout.vsk")));
41235
+ const hasLayout = chain.some((n) => n.layout && existsSync24(resolve24(appDirPath, n.sourceDir, "layout.vsk")));
40819
41236
  if (!hasLayout) {
40820
41237
  const leaf = chain.find((n) => n.page);
40821
41238
  if (leaf) {
40822
- const src2 = readFileSync20(resolve24(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
41239
+ const src2 = readFileSync22(resolve24(appDirPath, leaf.sourceDir, "page.vsk"), "utf-8");
40823
41240
  const compName = extractCompName2(src2) || leaf.page;
40824
41241
  yield* renderPageStream(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, clientScriptUrl: "/_vesk/client.js", cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: resolve24(appDirPath, leaf.sourceDir, "page.vsk") });
40825
41242
  } else {
@@ -40834,16 +41251,16 @@ ${prettifyHtml(body)}
40834
41251
  const node = chain[i];
40835
41252
  const pageFilePath = resolve24(appDirPath, node.sourceDir, "page.vsk");
40836
41253
  const layoutFilePath = resolve24(appDirPath, node.sourceDir, "layout.vsk");
40837
- if (i === chain.length - 1 && node.page && existsSync22(pageFilePath)) {
40838
- const src2 = readFileSync20(pageFilePath, "utf-8");
41254
+ if (i === chain.length - 1 && node.page && existsSync24(pageFilePath)) {
41255
+ const src2 = readFileSync22(pageFilePath, "utf-8");
40839
41256
  const compName = extractCompName2(src2) || node.page;
40840
41257
  const result2 = await renderPage(src2, compName, { params: matched.params }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: pageFilePath });
40841
41258
  body = result2.body;
40842
41259
  head = result2.head || "";
40843
41260
  props = result2.props;
40844
41261
  }
40845
- if (node.layout && existsSync22(layoutFilePath)) {
40846
- const src2 = readFileSync20(layoutFilePath, "utf-8");
41262
+ if (node.layout && existsSync24(layoutFilePath)) {
41263
+ const src2 = readFileSync22(layoutFilePath, "utf-8");
40847
41264
  const compName = extractCompName2(src2) || node.layout;
40848
41265
  const result2 = await renderPage(src2, compName, { children: body }, /* @__PURE__ */ new Map(), { hydrate: true, sourcePath: layoutFilePath });
40849
41266
  body = result2.body;
@@ -40971,9 +41388,9 @@ ${prettifyHtml(body)}
40971
41388
  const node = match.nodes[i];
40972
41389
  if (node.notFound) {
40973
41390
  const nfPath = resolve24(appDirPath, node.sourceDir, "not-found.vsk");
40974
- if (existsSync22(nfPath)) {
41391
+ if (existsSync24(nfPath)) {
40975
41392
  try {
40976
- const nfSrc = readFileSync20(nfPath, "utf-8");
41393
+ const nfSrc = readFileSync22(nfPath, "utf-8");
40977
41394
  const nfCompName = extractCompName2(nfSrc) || node.notFound;
40978
41395
  const html = await renderFullPage(nfSrc, nfCompName, { params: match.params, url: url.pathname }, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: nfPath });
40979
41396
  notFoundHtml = html.replace(
@@ -40999,9 +41416,9 @@ ${prettifyHtml(body)}
40999
41416
  const node = match.nodes[i];
41000
41417
  if (node.error) {
41001
41418
  const errPath = resolve24(appDirPath, node.sourceDir, "error.vsk");
41002
- if (existsSync22(errPath)) {
41419
+ if (existsSync24(errPath)) {
41003
41420
  try {
41004
- const errSrc = readFileSync20(errPath, "utf-8");
41421
+ const errSrc = readFileSync22(errPath, "utf-8");
41005
41422
  const errCompName = extractCompName2(errSrc) || node.error;
41006
41423
  const errProps = { error: err.message, stack: err.stack, statusCode: errorStatusCode(err), url: url.pathname };
41007
41424
  const html = await renderFullPage(errSrc, errCompName, errProps, /* @__PURE__ */ new Map(), { hydrate: true, cssUrls: ["/_vesk/static/_tailwind.css", "/_vesk/static/global.css"], security, externalDataScript: storeDataScript, sourcePath: errPath });
@@ -41311,8 +41728,8 @@ function loadEnvFiles(projectDir2) {
41311
41728
  join15(projectDir2, ".env.local")
41312
41729
  ];
41313
41730
  for (const filePath of files) {
41314
- if (!existsSync23(filePath)) continue;
41315
- const content = readFileSync22(filePath, "utf-8");
41731
+ if (!existsSync25(filePath)) continue;
41732
+ const content = readFileSync24(filePath, "utf-8");
41316
41733
  for (const line of content.split("\n")) {
41317
41734
  const trimmed = line.trim();
41318
41735
  if (!trimmed || trimmed.startsWith("#")) continue;
@@ -41334,13 +41751,13 @@ async function loadConfig(projectDir2) {
41334
41751
  const jsPath = join15(projectDir2, "vesk.config.js");
41335
41752
  const tsPath = join15(projectDir2, "vesk.config.ts");
41336
41753
  let configPath2 = null;
41337
- if (existsSync23(jsPath)) configPath2 = jsPath;
41338
- else if (existsSync23(tsPath)) configPath2 = tsPath;
41754
+ if (existsSync25(jsPath)) configPath2 = jsPath;
41755
+ else if (existsSync25(tsPath)) configPath2 = tsPath;
41339
41756
  if (!configPath2) return {};
41340
41757
  let raw2;
41341
41758
  if (configPath2.endsWith(".ts")) {
41342
41759
  const { transpile: transpile2 } = await import("typescript");
41343
- const src2 = readFileSync22(configPath2, "utf-8");
41760
+ const src2 = readFileSync24(configPath2, "utf-8");
41344
41761
  let js = transpile2(src2, { module: 99, target: 99 });
41345
41762
  js = js.replace(/import\s+\{[^}]*\}\s*from\s+['"]@vesk\/compiler['"]\s*;?\s*/g, "");
41346
41763
  js = `const { defineConfig, definePlugin, preset } = globalThis.__vesk_inject;
@@ -41369,7 +41786,7 @@ if (cmd === "build") {
41369
41786
  const projectDir2 = process.cwd();
41370
41787
  const appDirPath = join15(projectDir2, "app");
41371
41788
  const publicDir = join15(projectDir2, "public");
41372
- if (!existsSync23(appDirPath)) {
41789
+ if (!existsSync25(appDirPath)) {
41373
41790
  console.error(`vesk build: no app/ directory found in ${projectDir2}`);
41374
41791
  process.exit(1);
41375
41792
  }
@@ -41408,7 +41825,7 @@ if (cmd === "build") {
41408
41825
  if (cmd === "seo") {
41409
41826
  const projectDir2 = process.cwd();
41410
41827
  const appDirPath = join15(projectDir2, "app");
41411
- if (!existsSync23(appDirPath)) {
41828
+ if (!existsSync25(appDirPath)) {
41412
41829
  console.error(`vesk seo: no app/ directory found in ${projectDir2}`);
41413
41830
  process.exit(1);
41414
41831
  }
@@ -41423,7 +41840,7 @@ if (cmd === "seo") {
41423
41840
  if (cmd === "typecheck") {
41424
41841
  const projectDir2 = process.cwd();
41425
41842
  const appDirPath = join15(projectDir2, "app");
41426
- if (!existsSync23(appDirPath)) {
41843
+ if (!existsSync25(appDirPath)) {
41427
41844
  console.error(`vesk typecheck: no app/ directory found in ${projectDir2}`);
41428
41845
  process.exit(1);
41429
41846
  }
@@ -41458,7 +41875,7 @@ if (cmd === "init") {
41458
41875
  const projectDir2 = process.cwd();
41459
41876
  const srcDir = join15(projectDir2, "src");
41460
41877
  const target = join15(srcDir, "global.css");
41461
- if (existsSync23(target)) {
41878
+ if (existsSync25(target)) {
41462
41879
  console.error(`vesk init: ${target} already exists \u2014 skipping`);
41463
41880
  process.exit(0);
41464
41881
  }
@@ -41479,7 +41896,7 @@ if (cmd === "dev") {
41479
41896
  const appDirPath = join15(projectDir2, "app");
41480
41897
  const port2 = parsePortArg(args);
41481
41898
  const host2 = parseHostArg(args);
41482
- if (!existsSync23(appDirPath)) {
41899
+ if (!existsSync25(appDirPath)) {
41483
41900
  console.error(`vesk: no app/ directory found in ${projectDir2}`);
41484
41901
  console.error('Run "npx create-vesk@latest <project-name>" first');
41485
41902
  process.exit(1);