tw-framework 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/testing.cjs CHANGED
@@ -151715,9 +151715,9 @@ ${lanes.join("\n")}
151715
151715
  /*ignoreCase*/
151716
151716
  false
151717
151717
  )) {
151718
- const basename3 = getBaseFileName(a.fileName);
151719
- if (basename3 === "lib.d.ts" || basename3 === "lib.es6.d.ts") return 0;
151720
- const name = removeSuffix(removePrefix(basename3, "lib."), ".d.ts");
151718
+ const basename4 = getBaseFileName(a.fileName);
151719
+ if (basename4 === "lib.d.ts" || basename4 === "lib.es6.d.ts") return 0;
151720
+ const name = removeSuffix(removePrefix(basename4, "lib."), ".d.ts");
151721
151721
  const index = libs.indexOf(name);
151722
151722
  if (index !== -1) return index + 1;
151723
151723
  }
@@ -215313,8 +215313,8 @@ ${options.prefix}` : "\n" : options.prefix
215313
215313
  }
215314
215314
  };
215315
215315
  for (const file of files) {
215316
- const basename3 = getBaseFileName(file);
215317
- if (basename3 === "package.json" || basename3 === "bower.json") {
215316
+ const basename4 = getBaseFileName(file);
215317
+ if (basename4 === "package.json" || basename4 === "bower.json") {
215318
215318
  createProjectWatcher(
215319
215319
  file,
215320
215320
  "FileWatcher"
@@ -218982,8 +218982,8 @@ All files are: ${JSON.stringify(names)}`,
218982
218982
  var _a;
218983
218983
  const fileOrDirectoryPath = removeIgnoredPath(this.toPath(fileOrDirectory));
218984
218984
  if (!fileOrDirectoryPath) return;
218985
- const basename3 = getBaseFileName(fileOrDirectoryPath);
218986
- if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename3 === "package.json" || basename3 === "node_modules")) {
218985
+ const basename4 = getBaseFileName(fileOrDirectoryPath);
218986
+ if (((_a = result.affectedModuleSpecifierCacheProjects) == null ? void 0 : _a.size) && (basename4 === "package.json" || basename4 === "node_modules")) {
218987
218987
  result.affectedModuleSpecifierCacheProjects.forEach((project) => {
218988
218988
  var _a2;
218989
218989
  (_a2 = project.getModuleSpecifierCache()) == null ? void 0 : _a2.clear();
@@ -226947,7 +226947,51 @@ function parseStatements(cursor, errors, opts) {
226947
226947
  "cols",
226948
226948
  "rows",
226949
226949
  "wrap",
226950
- "datetime"
226950
+ "datetime",
226951
+ // SVG attributes. `path d "M4 7h16"` was read as text "path" plus a
226952
+ // <d> element, because `d` was not a known attribute name -- so an
226953
+ // inline icon could not be written at all.
226954
+ "d",
226955
+ "cx",
226956
+ "cy",
226957
+ "r",
226958
+ "rx",
226959
+ "ry",
226960
+ "x",
226961
+ "y",
226962
+ "x1",
226963
+ "y1",
226964
+ "x2",
226965
+ "y2",
226966
+ "points",
226967
+ "viewBox",
226968
+ "fill",
226969
+ "stroke",
226970
+ "stroke-width",
226971
+ "stroke-linecap",
226972
+ "stroke-linejoin",
226973
+ "stroke-dasharray",
226974
+ "stroke-dashoffset",
226975
+ "fill-rule",
226976
+ "clip-rule",
226977
+ "clip-path",
226978
+ "transform",
226979
+ "opacity",
226980
+ "fill-opacity",
226981
+ "stroke-opacity",
226982
+ "stop-color",
226983
+ "offset",
226984
+ "gradientUnits",
226985
+ "gradientTransform",
226986
+ "preserveAspectRatio",
226987
+ "text-anchor",
226988
+ "dominant-baseline",
226989
+ "font-size",
226990
+ "font-family",
226991
+ "marker-end",
226992
+ "marker-start",
226993
+ "mask",
226994
+ "xmlns"
226951
226995
  ]);
226952
226996
  const isSelector = nextTok && (nextTok.type === "DOT" || nextTok.type === "HASH" || nextTok.type === "LBRACE" || nextTok.type === "STRING" || // `width 800` — a bare IDENT followed by a NUMBER is a prop/value
226953
226997
  // pair (builtin component props accept numbers), not text content.
@@ -227516,7 +227560,7 @@ function parseElement(cursor, errors, state, parseBody) {
227516
227560
  const tag2 = tagToken.value;
227517
227561
  if (tag2 && /^[A-Za-z][A-Za-z0-9-]*$/.test(tag2)) {
227518
227562
  errors.add(new CompilerError(
227519
- "raw HTML is not supported in .tw -- write it in TW syntax: " + tag2 + " { ... }",
227563
+ "raw HTML is not supported in .tw -- write it in TW syntax: " + tag2 + ' { ... }. For an inline icon use svg/path/circle with attributes on the tag line; for a script body use script type "..." { ... }; for markup that comes from data use {@html expr}',
227520
227564
  tagToken.pos.line,
227521
227565
  tagToken.pos.col,
227522
227566
  "TW123",
@@ -236180,7 +236224,7 @@ var init_types4 = __esm({
236180
236224
  var TW_VERSION, TW_GENERATOR_META;
236181
236225
  var init_version = __esm({
236182
236226
  "../../packages/compiler/tw/codegen/version.ts"() {
236183
- TW_VERSION = "2.0.4";
236227
+ TW_VERSION = "2.0.5";
236184
236228
  TW_GENERATOR_META = `<meta name="generator" content="TW Framework ${TW_VERSION}">`;
236185
236229
  }
236186
236230
  });
@@ -237779,6 +237823,39 @@ function validatePlainCss(src, filePath) {
237779
237823
  checkDecl();
237780
237824
  return src;
237781
237825
  }
237826
+ function collapseWhitespace(text) {
237827
+ let out = "";
237828
+ let quote = null;
237829
+ let pendingSpace = false;
237830
+ for (let i = 0; i < text.length; i++) {
237831
+ const ch = text[i];
237832
+ if (quote) {
237833
+ out += ch;
237834
+ if (ch === "\\" && i + 1 < text.length) {
237835
+ out += text[i + 1];
237836
+ i++;
237837
+ continue;
237838
+ }
237839
+ if (ch === quote) quote = null;
237840
+ continue;
237841
+ }
237842
+ if (ch === '"' || ch === "'") {
237843
+ if (pendingSpace && out) out += " ";
237844
+ pendingSpace = false;
237845
+ quote = ch;
237846
+ out += ch;
237847
+ continue;
237848
+ }
237849
+ if (/\s/.test(ch)) {
237850
+ pendingSpace = true;
237851
+ continue;
237852
+ }
237853
+ if (pendingSpace && out) out += " ";
237854
+ pendingSpace = false;
237855
+ out += ch;
237856
+ }
237857
+ return out;
237858
+ }
237782
237859
  function compileDecl(decl) {
237783
237860
  const trimmed = decl.trim();
237784
237861
  if (!trimmed) return "";
@@ -237786,10 +237863,10 @@ function compileDecl(decl) {
237786
237863
  if (cssForm) return trimmed.replace(/^([-\w]+)\s*:\s*/, "$1: ");
237787
237864
  const spaceIdx = trimmed.search(/[\s]/);
237788
237865
  if (spaceIdx === -1) {
237789
- return TSS_SHORTHANDS2[trimmed] ?? trimmed;
237866
+ return "";
237790
237867
  }
237791
237868
  const prop = trimmed.slice(0, spaceIdx);
237792
- const value = trimmed.slice(spaceIdx).trim();
237869
+ const value = collapseWhitespace(trimmed.slice(spaceIdx).trim());
237793
237870
  const full = TSS_SHORTHANDS2[prop] ?? prop;
237794
237871
  return `${full}: ${value}`;
237795
237872
  }
@@ -237947,26 +238024,47 @@ function __twCompileTSSInner(source) {
237947
238024
  if (!changed) break;
237948
238025
  }
237949
238026
  }
237950
- const rules = [];
238027
+ const root = [];
237951
238028
  const stack = [];
237952
- const declsByLevel = [];
237953
238029
  let buf = "";
237954
- const emit4 = (selector, decls, wrapStack) => {
237955
- if (decls.length === 0) return;
237956
- let rule = `${selector} { ${decls.join("; ")} }`;
237957
- for (let i2 = wrapStack.length - 1; i2 >= 0; i2--) {
237958
- if (wrapStack[i2].startsWith("@")) rule = `${wrapStack[i2]} { ${rule} }`;
237959
- }
237960
- rules.push(rule);
237961
- };
238030
+ const current2 = () => stack.length ? stack[stack.length - 1] : null;
238031
+ const statements = [];
238032
+ const isStatementAtRule = (t3) => /^@(import|charset|namespace|layer)\b/.test(t3);
237962
238033
  const pushDecl = (text) => {
237963
- const d = compileDecl(text);
237964
- if (d) (declsByLevel[declsByLevel.length - 1] ??= []).push(d);
238034
+ const raw = text.trim();
238035
+ if (!raw) return;
238036
+ if (isStatementAtRule(raw)) {
238037
+ statements.push(raw.endsWith(";") ? raw : raw + ";");
238038
+ return;
238039
+ }
238040
+ const d = compileDecl(raw);
238041
+ if (!d) return;
238042
+ const node = current2();
238043
+ if (node) node.decls.push(d);
238044
+ else root.push({ kind: "rule", selector: "*", decls: [d], children: [] });
237965
238045
  };
237966
- const isDeclLine = (l) => /^[a-zA-Z][\w-]*(\s|:)/.test(l) && !/^[>+~]/.test(l);
238046
+ const isDeclLine = (l) => /^(--[A-Za-z][\w-]*|-?[A-Za-z][\w-]*)(\s|:)/.test(l) && !/^[>+~]/.test(l);
237967
238047
  let i = 0;
238048
+ let quote = null;
237968
238049
  while (i < src.length) {
237969
238050
  const ch = src[i];
238051
+ if (quote) {
238052
+ buf += ch;
238053
+ if (ch === "\\" && i + 1 < src.length) {
238054
+ buf += src[i + 1];
238055
+ i += 2;
238056
+ continue;
238057
+ }
238058
+ if (ch === quote) quote = null;
238059
+ i++;
238060
+ continue;
238061
+ }
238062
+ if (ch === '"' || ch === "'") {
238063
+ quote = ch;
238064
+ buf += ch;
238065
+ i++;
238066
+ continue;
238067
+ }
237970
238068
  if (ch === "{") {
237971
238069
  let sel = buf.trim();
237972
238070
  buf = "";
@@ -237979,53 +238077,38 @@ function __twCompileTSSInner(source) {
237979
238077
  const last = lines[lines.length - 1];
237980
238078
  const prior = lines.slice(0, -1);
237981
238079
  const priorComplete = !/[(,]\s*$/.test(prior[prior.length - 1] ?? "");
237982
- if (priorComplete && prior.every(isDeclLine) && !last.startsWith("@")) {
238080
+ if (priorComplete && prior.every(isDeclLine)) {
237983
238081
  for (const p of prior) pushDecl(p);
237984
238082
  sel = last;
237985
238083
  }
237986
238084
  }
237987
- const parent = stack.length ? stack[stack.length - 1] : "";
237988
- let full;
238085
+ const parent = current2();
237989
238086
  if (sel.startsWith("@")) {
237990
- full = sel;
237991
- } else if (parent && !parent.startsWith("@")) {
237992
- full = combineSelector(parent, sel);
238087
+ const node = { kind: "at", head: sel, decls: [], children: [] };
238088
+ (parent ? parent.children : root).push(node);
238089
+ stack.push(node);
237993
238090
  } else {
237994
- full = sel;
238091
+ const full = parent && parent.kind === "rule" ? combineSelector(parent.selector, sel) : sel;
238092
+ const node = { kind: "rule", selector: full, decls: [], children: [] };
238093
+ (parent ? parent.children : root).push(node);
238094
+ stack.push(node);
237995
238095
  }
237996
- stack.push(full);
237997
- declsByLevel.push([]);
237998
238096
  i++;
237999
238097
  } else if (ch === "}") {
238000
238098
  if (buf.trim()) {
238001
238099
  const blines = buf.split(/\n+/).map((l) => l.trim()).filter(Boolean);
238002
- if (blines.length > 1 && blines.every(isDeclLine)) {
238100
+ const valueContinues = blines.some((l) => /[(,]\s*$/.test(l));
238101
+ if (blines.length > 1 && !valueContinues) {
238003
238102
  for (const l of blines) pushDecl(l);
238004
238103
  } else {
238005
238104
  pushDecl(buf);
238006
238105
  }
238007
238106
  }
238008
238107
  buf = "";
238009
- const level = stack.pop();
238010
- const decls = declsByLevel.pop() ?? [];
238011
- if (level) {
238012
- if (level.startsWith("@") && decls.length > 0) {
238013
- let realSel = null;
238014
- for (let j = stack.length - 1; j >= 0; j--) {
238015
- if (!stack[j].startsWith("@")) {
238016
- realSel = stack[j];
238017
- break;
238018
- }
238019
- }
238020
- if (realSel) emit4(realSel, decls, [...stack, level]);
238021
- else emit4(level, decls, stack);
238022
- } else {
238023
- emit4(level, decls, stack);
238024
- }
238025
- }
238108
+ stack.pop();
238026
238109
  i++;
238027
238110
  } else if (ch === ";") {
238028
- pushDecl(buf);
238111
+ if (buf.trim()) pushDecl(buf);
238029
238112
  buf = "";
238030
238113
  i++;
238031
238114
  } else {
@@ -238033,11 +238116,24 @@ function __twCompileTSSInner(source) {
238033
238116
  i++;
238034
238117
  }
238035
238118
  }
238036
- if (buf.trim()) {
238037
- const d = compileDecl(buf);
238038
- if (d && stack.length === 0) rules.push(`* { ${d} }`);
238039
- }
238040
- return rules.join("\n");
238119
+ if (buf.trim()) pushDecl(buf);
238120
+ const ser = (node, parentSel) => {
238121
+ if (node.kind === "rule") {
238122
+ const lines = [];
238123
+ if (node.decls.length) lines.push(node.selector + " { " + node.decls.join("; ") + " }");
238124
+ for (const c of node.children) lines.push(...ser(c, node.selector));
238125
+ return lines;
238126
+ }
238127
+ const inner = [];
238128
+ if (node.decls.length) {
238129
+ inner.push(parentSel ? parentSel + " { " + node.decls.join("; ") + " }" : node.decls.join("; "));
238130
+ }
238131
+ for (const c of node.children) inner.push(...ser(c, parentSel));
238132
+ return [node.head + " { " + inner.join(" ") + " }"];
238133
+ };
238134
+ const out = [...statements];
238135
+ for (const node of root) out.push(...ser(node, ""));
238136
+ return out.join("\n");
238041
238137
  }
238042
238138
  var TSS_SHORTHANDS2;
238043
238139
  var init_tss = __esm({
@@ -238081,6 +238177,12 @@ var init_tss = __esm({
238081
238177
  "br-t": "border-top-left-radius",
238082
238178
  bxsh: "box-shadow",
238083
238179
  bxz: "box-sizing",
238180
+ // Documented in docs/tss-syntax.md but never implemented, so `br-tl 4px`
238181
+ // emitted the literal property name `br-tl` and the corner stayed square.
238182
+ "br-tl": "border-top-left-radius",
238183
+ "br-tr": "border-top-right-radius",
238184
+ "br-bl": "border-bottom-left-radius",
238185
+ "br-br": "border-bottom-right-radius",
238084
238186
  // `box` is the documented box-sizing shorthand (docs/tss-syntax.md).
238085
238187
  box: "box-sizing",
238086
238188
  // typography
@@ -238122,7 +238224,13 @@ var init_tss = __esm({
238122
238224
  tr: "transition",
238123
238225
  tf: "transform",
238124
238226
  us: "user-select",
238125
- pe: "pointer-events"
238227
+ pe: "pointer-events",
238228
+ // Also documented, also missing.
238229
+ fl: "float",
238230
+ cl: "clear",
238231
+ dir: "direction",
238232
+ ww: "word-wrap",
238233
+ va: "vertical-align"
238126
238234
  };
238127
238235
  }
238128
238236
  });
@@ -239260,7 +239368,9 @@ function generateElement(el, ctx) {
239260
239368
  if (el.children.length === 0 && el.selfClosing) {
239261
239369
  return `<${tag2}${attrPrefix}></${tag2}>`;
239262
239370
  }
239263
- const childrenHTML = el.children.map((c) => generateNode(c, ctx)).join("");
239371
+ const isRawText = tag2 === "script" || tag2 === "style";
239372
+ const childCtx = isRawText ? { ...ctx, rawText: true } : ctx;
239373
+ const childrenHTML = el.children.map((c) => generateNode(c, childCtx)).join("");
239264
239374
  return `<${tag2}${attrPrefix}>${childrenHTML}</${tag2}>`;
239265
239375
  }
239266
239376
  function renderAttrs(el, ctx) {
@@ -239391,10 +239501,30 @@ function wrapInterpolations(rendered, raw) {
239391
239501
  }
239392
239502
  return out;
239393
239503
  }
239504
+ function generateTrustedHtml(text, ctx) {
239505
+ const src = text.isInterpolated ? `{${text.value}}` : String(text.value ?? "");
239506
+ let out = "";
239507
+ let i = 0;
239508
+ const re = /\{@html\s+([^}]*)\}/g;
239509
+ let m;
239510
+ while (m = re.exec(src)) {
239511
+ out += escapeHTML(interpolate2(src.slice(i, m.index), ctx.stateVars));
239512
+ out += String(interpolate2(`{${m[1]}}`, ctx.stateVars));
239513
+ i = m.index + m[0].length;
239514
+ }
239515
+ out += escapeHTML(interpolate2(src.slice(i), ctx.stateVars));
239516
+ return out;
239517
+ }
239394
239518
  function generateText(text, ctx) {
239395
239519
  ctx_global_interactive = ctx.interactive === true;
239396
239520
  ctx_global_inhead = ctx.inHead === true;
239397
239521
  lastStateVars = ctx.stateVars;
239522
+ if (text.value && String(text.value).includes("@html")) return generateTrustedHtml(text, ctx);
239523
+ if (ctx.rawText) {
239524
+ if (text.isInterpolated) return String(interpolate2(`{${text.value}}`, ctx.stateVars));
239525
+ if (text.value && /\{[^}]+\}/.test(text.value)) return String(interpolate2(text.value, ctx.stateVars));
239526
+ return text.value ?? "";
239527
+ }
239398
239528
  if (text.isInterpolated) {
239399
239529
  if (ctx.interactive && ctx.inHead !== true) {
239400
239530
  return `<span data-tw-i="${escapeHTML(text.value)}"${dataTwSFor(text.value)}>${escapeHTML(interpolate2(`{${text.value}}`, ctx.stateVars))}</span>`;
@@ -240697,7 +240827,7 @@ function minifyHTML2(html, options) {
240697
240827
  result = removeComments(result);
240698
240828
  }
240699
240829
  if (opts.collapseWhitespace) {
240700
- result = collapseWhitespace(result);
240830
+ result = collapseWhitespace2(result);
240701
240831
  }
240702
240832
  if (opts.removeRedundantAttrs) {
240703
240833
  result = removeRedundantAttrs(result);
@@ -240720,7 +240850,7 @@ function removeComments(html) {
240720
240850
  if (html.indexOf("<!--") === -1) return html;
240721
240851
  return html.replace(/<!--(?!\[if\s)[\s\S]*?-->/g, "");
240722
240852
  }
240723
- function collapseWhitespace(html) {
240853
+ function collapseWhitespace2(html) {
240724
240854
  const result = [];
240725
240855
  let pos = 0;
240726
240856
  let inPreserved = false;
@@ -243979,7 +244109,7 @@ var init_codes = __esm({
243979
244109
  TW105: { message: "Server blocks in layouts are not supported yet", severity: "error", category: "semantic" },
243980
244110
  TW106: { message: "Request context (headers/cookies/query/params) is not available in a static server block", severity: "error", category: "semantic" },
243981
244111
  TW107: { message: "getSession()/requireUser() are not available in a static page's server block", severity: "error", category: "semantic" },
243982
- TW108: { message: "redirect()/notFound() are not available in a static page's server block", severity: "error", category: "semantic" },
244112
+ TW108: { message: "redirect() is not available in a static page's server block", severity: "error", category: "semantic" },
243983
244113
  TW109: { message: "redirect() target must be a same-origin internal path", severity: "error", category: "semantic" },
243984
244114
  TW110: { message: "A cached fetch must not set an Authorization, Proxy-Authorization or Cookie header", severity: "error", category: "semantic" },
243985
244115
  TW111: { message: "A cached page's server block cannot read headers, cookies, getSession() or requireUser()", severity: "error", category: "semantic" },
@@ -243994,6 +244124,7 @@ var init_codes = __esm({
243994
244124
  TW121: { message: "The same name is declared by more than one state { } block (the earlier one wins)", severity: "warning", category: "semantic" },
243995
244125
  TW122: { message: "More than one default slot in the same component -- a caller's default content has no defined destination", severity: "warning", category: "semantic" },
243996
244126
  TW123: { message: "Raw HTML is not supported in .tw -- write the element in TW syntax", severity: "error", category: "syntax" },
244127
+ TW125: { message: "An import's local name is also a server-block built-in, so the import would be silently overwritten", severity: "error", category: "semantic" },
243997
244128
  // Codes thrown outside the rule engine. TW303 comes from the stylesheet
243998
244129
  // parser (codegen/tss.ts); TW000 is the generic fallback used when an error
243999
244130
  // carries no code of its own.
@@ -244194,8 +244325,17 @@ function checkPerformance(program, filePath, diags) {
244194
244325
  ]));
244195
244326
  }
244196
244327
  if (isElement(node) && node.tag.toLowerCase() === "img") {
244328
+ const attr = (n) => node.attrs.find((a) => a.name === n)?.value;
244197
244329
  const hasLazy = node.attrs.some((a) => a.name === "loading" && a.value === "lazy");
244198
- if (!hasLazy) {
244330
+ const isEager = String(attr("loading") ?? "") === "eager" || String(attr("fetchpriority") ?? "") === "high";
244331
+ const px = (v) => {
244332
+ const n = parseFloat(String(v ?? ""));
244333
+ return Number.isFinite(n) ? n : null;
244334
+ };
244335
+ const w = px(attr("width"));
244336
+ const h3 = px(attr("height"));
244337
+ const isSmallIcon = w !== null && h3 !== null && w <= 32 && h3 <= 32;
244338
+ if (!hasLazy && !isEager && !isSmallIcon) {
244199
244339
  diags.push(createDiagnostic("TW054", node.line, node.col, filePath, void 0, [
244200
244340
  'Add loading="lazy" for below-fold images'
244201
244341
  ]));
@@ -244710,6 +244850,55 @@ var init_rules = __esm({
244710
244850
  "foreignobject"
244711
244851
  ]);
244712
244852
  HTML_ATTRIBUTES2 = /* @__PURE__ */ new Set([
244853
+ // SVG attributes. This rule keeps its own copy of the list, and it was missing
244854
+ // every SVG name, so an inline icon raised a TW006 per attribute.
244855
+ "d",
244856
+ "cx",
244857
+ "cy",
244858
+ "r",
244859
+ "rx",
244860
+ "ry",
244861
+ "x",
244862
+ "y",
244863
+ "x1",
244864
+ "y1",
244865
+ "x2",
244866
+ "y2",
244867
+ "points",
244868
+ "viewBox",
244869
+ "fill",
244870
+ "stroke",
244871
+ "stroke-width",
244872
+ "stroke-linecap",
244873
+ "stroke-linejoin",
244874
+ "stroke-dasharray",
244875
+ "stroke-dashoffset",
244876
+ "stroke-opacity",
244877
+ "fill-opacity",
244878
+ "fill-rule",
244879
+ "clip-rule",
244880
+ "clip-path",
244881
+ "opacity",
244882
+ "transform",
244883
+ "preserveAspectRatio",
244884
+ "xmlns",
244885
+ "gradientUnits",
244886
+ "gradientTransform",
244887
+ "offset",
244888
+ "stop-color",
244889
+ "stop-opacity",
244890
+ "text-anchor",
244891
+ "dominant-baseline",
244892
+ "font-family",
244893
+ "font-size",
244894
+ "font-weight",
244895
+ "font-style",
244896
+ "letter-spacing",
244897
+ "marker-start",
244898
+ "marker-mid",
244899
+ "marker-end",
244900
+ "mask",
244901
+ "pathLength",
244713
244902
  "accept",
244714
244903
  "accept-charset",
244715
244904
  "accesskey",
@@ -247913,17 +248102,32 @@ var node_import_exports = {};
247913
248102
  __export(node_import_exports, {
247914
248103
  twImportTs: () => twImportTs
247915
248104
  });
247916
- async function twImportTs(tsPath, bust) {
248105
+ async function twImportTs(tsPath, bust, opts) {
247917
248106
  const q = bust ? "?v=" + bust : "";
248107
+ const override = opts?.source;
247918
248108
  if (!globalThis.__TW_NODE) {
247919
- return import(tsPath + q);
248109
+ if (override === void 0) return import(tsPath + q);
248110
+ const ext = (0, import_node_path14.extname)(tsPath) || ".ts";
248111
+ const unique = process.pid + "-" + (overrideSeq++).toString(36) + "-" + Math.random().toString(36).slice(2, 8);
248112
+ const tmpPath = (0, import_node_path14.join)((0, import_node_path14.dirname)(tsPath), "." + (0, import_node_path14.basename)(tsPath, ext) + ".tw-override-" + unique + ext);
248113
+ (0, import_node_fs8.writeFileSync)(tmpPath, override, "utf-8");
248114
+ try {
248115
+ return await import(tmpPath + q);
248116
+ } finally {
248117
+ try {
248118
+ (0, import_node_fs8.rmSync)(tmpPath, { force: true });
248119
+ } catch {
248120
+ }
248121
+ }
247920
248122
  }
247921
248123
  const esbuildMain = globalThis.__TW_ESBUILD_MODULE;
247922
248124
  const esbuild = await (esbuildMain ? import(esbuildMain) : import("esbuild"));
247923
248125
  const safe = tsPath.replace(/[^a-zA-Z0-9]/g, "_").slice(-120);
247924
248126
  const cachePath = (0, import_node_path14.join)((0, import_node_os2.tmpdir)(), "tw-" + safe + (bust ? "-" + bust : "") + ".mjs");
247925
248127
  await esbuild.build({
247926
- entryPoints: [tsPath],
248128
+ // stdin + resolveDir keeps relative imports resolving from the original
248129
+ // file's directory, and sourcefile keeps error locations on the real file.
248130
+ ...override === void 0 ? { entryPoints: [tsPath] } : { stdin: { contents: override, resolveDir: (0, import_node_path14.dirname)(tsPath), sourcefile: tsPath, loader: (0, import_node_path14.extname)(tsPath) === ".js" ? "js" : "ts" } },
247927
248131
  bundle: true,
247928
248132
  format: "esm",
247929
248133
  platform: "node",
@@ -247933,12 +248137,14 @@ async function twImportTs(tsPath, bust) {
247933
248137
  });
247934
248138
  return import((0, import_node_url2.pathToFileURL)(cachePath).href + q);
247935
248139
  }
247936
- var import_node_path14, import_node_os2, import_node_url2;
248140
+ var import_node_path14, import_node_os2, import_node_url2, import_node_fs8, overrideSeq;
247937
248141
  var init_node_import = __esm({
247938
248142
  "../../packages/shared/tw/node-import.ts"() {
247939
248143
  import_node_path14 = require("node:path");
247940
248144
  import_node_os2 = require("node:os");
247941
248145
  import_node_url2 = require("node:url");
248146
+ import_node_fs8 = require("node:fs");
248147
+ overrideSeq = 0;
247942
248148
  }
247943
248149
  });
247944
248150
 
@@ -248199,41 +248405,45 @@ function withTimeout2(p, ms, label) {
248199
248405
  });
248200
248406
  });
248201
248407
  }
248202
- function importBindingNames(stmt) {
248203
- const names = [];
248204
- const s = stmt.replace(/^import\s+(type\s+)?/, "");
248408
+ function importBindings(stmt) {
248409
+ const out = [];
248410
+ const s = stmt.replace(/^import\s+(type\s+)?/, "").trim();
248205
248411
  const fromIdx = s.lastIndexOf(" from ");
248206
- if (fromIdx < 0) return names;
248412
+ if (fromIdx < 0) return out;
248207
248413
  const clause = s.slice(0, fromIdx).trim();
248208
- if (clause.startsWith("{")) {
248209
- for (const part of clause.slice(1, -1).split(",")) {
248414
+ if (!clause.startsWith("{") && !clause.startsWith("*")) {
248415
+ const first = clause.split(",")[0].trim();
248416
+ if (first && /^[A-Za-z_$]/.test(first)) out.push({ local: first, imported: "default", kind: "default" });
248417
+ }
248418
+ const ns = clause.match(/\*\s+as\s+([A-Za-z_$][\w$]*)/);
248419
+ if (ns) out.push({ local: ns[1], imported: "*", kind: "namespace" });
248420
+ const braces = clause.match(/\{([\s\S]*)\}/);
248421
+ if (braces) {
248422
+ for (const part of braces[1].split(",")) {
248210
248423
  const t3 = part.trim();
248211
248424
  if (!t3) continue;
248212
- const as = t3.split(/\s+as\s+/);
248213
- names.push((as[1] ?? as[0]).trim());
248425
+ const parts = t3.split(/\s+as\s+/);
248426
+ const imported = parts[0].trim();
248427
+ const local = (parts[1] ?? parts[0]).trim();
248428
+ if (local) out.push({ local, imported, kind: "named" });
248214
248429
  }
248215
- } else if (clause.startsWith("*")) {
248216
- const as = clause.split(/\s+as\s+/);
248217
- if (as[1]) names.push(as[1].trim());
248218
- } else {
248219
- const first = clause.split(",")[0].trim();
248220
- if (first && /^[A-Za-z_$]/.test(first)) names.push(first);
248221
248430
  }
248222
- return names;
248431
+ return out;
248223
248432
  }
248224
248433
  async function resolveServerImports(block, pageFile, opts = {}) {
248225
248434
  if (!block.imports.length) return {};
248226
248435
  const out = {};
248227
248436
  const { twImportTs: twImportTs2 } = await Promise.resolve().then(() => (init_node_import(), node_import_exports));
248228
- const { dirname: dirname10, resolve: resolve4 } = await import("node:path");
248437
+ const { dirname: dirname11, resolve: resolve4 } = await import("node:path");
248229
248438
  const { statSync: statSync7 } = await import("node:fs");
248230
248439
  for (const imp of block.imports) {
248231
248440
  if (!imp.specifier) continue;
248232
248441
  const spec = imp.specifier;
248442
+ if (spec === "@tw/server-only" || spec === "@tw/client-safe") continue;
248233
248443
  let mod;
248234
248444
  if (spec.startsWith("./") || spec.startsWith("../") || spec.startsWith("@./")) {
248235
248445
  const rel = spec.startsWith("@./") ? spec.slice(2) : spec;
248236
- const abs = resolve4(dirname10(pageFile), rel);
248446
+ const abs = resolve4(dirname11(pageFile), rel);
248237
248447
  let bust;
248238
248448
  if (opts.dev) {
248239
248449
  try {
@@ -248241,12 +248451,49 @@ async function resolveServerImports(block, pageFile, opts = {}) {
248241
248451
  } catch {
248242
248452
  }
248243
248453
  }
248244
- mod = await twImportTs2(abs, bust);
248454
+ let override;
248455
+ try {
248456
+ let realAbs = abs;
248457
+ if (!(0, import_node_fs9.existsSync)(realAbs)) {
248458
+ for (const ext of [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]) {
248459
+ if ((0, import_node_fs9.existsSync)(realAbs + ext)) {
248460
+ realAbs = realAbs + ext;
248461
+ break;
248462
+ }
248463
+ }
248464
+ }
248465
+ const raw = (0, import_node_fs9.readFileSync)(realAbs, "utf-8");
248466
+ if (MARKER_IMPORT_RE.test(raw)) {
248467
+ MARKER_IMPORT_RE.lastIndex = 0;
248468
+ override = raw.replace(MARKER_IMPORT_RE, "");
248469
+ }
248470
+ } catch {
248471
+ }
248472
+ mod = override === void 0 ? await twImportTs2(abs, bust) : await twImportTs2(abs, bust, { source: override });
248245
248473
  } else {
248246
248474
  mod = await import(spec);
248247
248475
  }
248248
- const names = importBindingNames(imp.source);
248249
- for (const n of names) out[n] = mod?.[n] ?? mod?.default;
248476
+ for (const bind of importBindings(imp.source)) {
248477
+ if (bind.kind === "namespace") out[bind.local] = mod;
248478
+ else if (bind.kind === "default") out[bind.local] = mod?.default ?? mod?.[bind.imported];
248479
+ else out[bind.local] = mod?.[bind.imported] ?? mod?.default;
248480
+ }
248481
+ }
248482
+ return out;
248483
+ }
248484
+ function serverImportCollisions(source) {
248485
+ const out = [];
248486
+ const re = /^[ \t]*import\s+([\s\S]*?)\s+from\s+["']([^"']+)["'][ \t]*;?/gm;
248487
+ let m;
248488
+ while (m = re.exec(source)) {
248489
+ const stmt = m[0];
248490
+ const specifier = m[2];
248491
+ const line = source.slice(0, m.index).split("\n").length;
248492
+ for (const b of importBindings(stmt)) {
248493
+ if (RESERVED_BLOCK_BINDINGS.includes(b.local)) {
248494
+ out.push({ name: b.local, specifier, line, col: 1 });
248495
+ }
248496
+ }
248250
248497
  }
248251
248498
  return out;
248252
248499
  }
@@ -248285,7 +248532,7 @@ function checkServerBlocks(program, opts = {}) {
248285
248532
  }
248286
248533
  const calls = scanRuntimeCalls(b.source);
248287
248534
  if (calls.getSession || calls.requireUser) push("TW107", "getSession()/requireUser() are not available in a static page's server block", b.line, b.col);
248288
- if (calls.redirect || calls.notFound) push("TW108", "redirect()/notFound() are not available in a static page's server block", b.line, b.col);
248535
+ if (calls.redirect) push("TW108", "redirect() is not available in a static page's server block -- a static page is built before the request, so there is nothing to redirect", b.line, b.col);
248289
248536
  }
248290
248537
  }
248291
248538
  for (const b of blocks) {
@@ -248436,12 +248683,13 @@ function parsePageCache(source) {
248436
248683
  const rv = revalidate ?? 60;
248437
248684
  return { revalidate: rv, expire: expire ?? rv, tag: tagM ? tagM[1] : void 0 };
248438
248685
  }
248439
- var ts3, REQUEST_IDENTIFIERS, SERVER_REDIRECT_BRAND, SERVER_NOT_FOUND_BRAND, ServerRedirect, ServerNotFound, isServerRedirect, isServerNotFound, DEFAULT_SERVER_BLOCK_TIMEOUT_MS;
248686
+ var ts3, import_node_fs9, REQUEST_IDENTIFIERS, SERVER_REDIRECT_BRAND, SERVER_NOT_FOUND_BRAND, ServerRedirect, ServerNotFound, isServerRedirect, isServerNotFound, DEFAULT_SERVER_BLOCK_TIMEOUT_MS, MARKER_IMPORT_RE, RESERVED_BLOCK_BINDINGS;
248440
248687
  var init_server_blocks = __esm({
248441
248688
  "../../packages/compiler/tw/server-blocks/index.ts"() {
248442
248689
  init_codes();
248443
248690
  init_serialize();
248444
248691
  ts3 = __toESM(require_typescript(), 1);
248692
+ import_node_fs9 = require("node:fs");
248445
248693
  REQUEST_IDENTIFIERS = /* @__PURE__ */ new Set(["headers", "cookies", "query", "params"]);
248446
248694
  SERVER_REDIRECT_BRAND = Symbol.for("tw.serverRedirect");
248447
248695
  SERVER_NOT_FOUND_BRAND = Symbol.for("tw.serverNotFound");
@@ -248463,6 +248711,19 @@ var init_server_blocks = __esm({
248463
248711
  isServerRedirect = (e) => !!(e && e[SERVER_REDIRECT_BRAND]);
248464
248712
  isServerNotFound = (e) => !!(e && e[SERVER_NOT_FOUND_BRAND]);
248465
248713
  DEFAULT_SERVER_BLOCK_TIMEOUT_MS = 1e4;
248714
+ MARKER_IMPORT_RE = /^[ \t]*import\s*["']@tw\/(?:server-only|client-safe)["'][ \t]*;?[ \t]*\r?\n?/gm;
248715
+ RESERVED_BLOCK_BINDINGS = [
248716
+ "params",
248717
+ "query",
248718
+ "headers",
248719
+ "cookies",
248720
+ "env",
248721
+ "fetch",
248722
+ "getSession",
248723
+ "requireUser",
248724
+ "redirect",
248725
+ "notFound"
248726
+ ];
248466
248727
  }
248467
248728
  });
248468
248729
 
@@ -249918,24 +250179,24 @@ var init_memory = __esm({
249918
250179
  });
249919
250180
 
249920
250181
  // ../../packages/compiler/tw/cache/disk.ts
249921
- var import_node_fs8, import_node_path15, DiskCache;
250182
+ var import_node_fs10, import_node_path15, DiskCache;
249922
250183
  var init_disk = __esm({
249923
250184
  "../../packages/compiler/tw/cache/disk.ts"() {
249924
- import_node_fs8 = require("node:fs");
250185
+ import_node_fs10 = require("node:fs");
249925
250186
  import_node_path15 = require("node:path");
249926
250187
  init_tw();
249927
250188
  DiskCache = class {
249928
250189
  constructor(cacheDir) {
249929
250190
  this.cacheDir = cacheDir;
249930
- if (!(0, import_node_fs8.existsSync)(cacheDir)) {
249931
- (0, import_node_fs8.mkdirSync)(cacheDir, { recursive: true });
250191
+ if (!(0, import_node_fs10.existsSync)(cacheDir)) {
250192
+ (0, import_node_fs10.mkdirSync)(cacheDir, { recursive: true });
249932
250193
  }
249933
250194
  }
249934
250195
  get(key2) {
249935
250196
  const path = this.keyToPath(key2);
249936
- if (!(0, import_node_fs8.existsSync)(path)) return null;
250197
+ if (!(0, import_node_fs10.existsSync)(path)) return null;
249937
250198
  try {
249938
- const data = JSON.parse((0, import_node_fs8.readFileSync)(path, "utf-8"));
250199
+ const data = JSON.parse((0, import_node_fs10.readFileSync)(path, "utf-8"));
249939
250200
  return data.value;
249940
250201
  } catch {
249941
250202
  return null;
@@ -249943,27 +250204,27 @@ var init_disk = __esm({
249943
250204
  }
249944
250205
  set(key2, value, hash2) {
249945
250206
  const path = this.keyToPath(key2);
249946
- (0, import_node_fs8.mkdirSync)((0, import_node_path15.dirname)(path), { recursive: true });
250207
+ (0, import_node_fs10.mkdirSync)((0, import_node_path15.dirname)(path), { recursive: true });
249947
250208
  const entry = { key: key2, value, hash: hash2, createdAt: Date.now() };
249948
- (0, import_node_fs8.writeFileSync)(path, JSON.stringify(entry));
250209
+ (0, import_node_fs10.writeFileSync)(path, JSON.stringify(entry));
249949
250210
  }
249950
250211
  has(key2) {
249951
- return (0, import_node_fs8.existsSync)(this.keyToPath(key2));
250212
+ return (0, import_node_fs10.existsSync)(this.keyToPath(key2));
249952
250213
  }
249953
250214
  delete(key2) {
249954
250215
  const path = this.keyToPath(key2);
249955
250216
  try {
249956
- (0, import_node_fs8.unlinkSync)(path);
250217
+ (0, import_node_fs10.unlinkSync)(path);
249957
250218
  } catch {
249958
250219
  }
249959
250220
  }
249960
250221
  clear() {
249961
250222
  try {
249962
- const files = (0, import_node_fs8.readdirSync)(this.cacheDir);
250223
+ const files = (0, import_node_fs10.readdirSync)(this.cacheDir);
249963
250224
  for (const f of files) {
249964
250225
  if (f.endsWith(".json")) {
249965
250226
  try {
249966
- (0, import_node_fs8.unlinkSync)((0, import_node_path15.join)(this.cacheDir, f));
250227
+ (0, import_node_fs10.unlinkSync)((0, import_node_path15.join)(this.cacheDir, f));
249967
250228
  } catch {
249968
250229
  }
249969
250230
  }
@@ -249973,7 +250234,7 @@ var init_disk = __esm({
249973
250234
  }
249974
250235
  keys() {
249975
250236
  try {
249976
- return (0, import_node_fs8.readdirSync)(this.cacheDir).filter((f) => f.endsWith(".json")).map((f) => f.replace(".json", ""));
250237
+ return (0, import_node_fs10.readdirSync)(this.cacheDir).filter((f) => f.endsWith(".json")).map((f) => f.replace(".json", ""));
249977
250238
  } catch {
249978
250239
  return [];
249979
250240
  }
@@ -250469,7 +250730,7 @@ function findRustBinary() {
250469
250730
  }
250470
250731
  for (const candidate of candidates) {
250471
250732
  if (candidate.includes("/") || candidate.includes("\\")) {
250472
- if ((0, import_node_fs9.existsSync)(candidate)) {
250733
+ if ((0, import_node_fs11.existsSync)(candidate)) {
250473
250734
  cachedBinaryPath = candidate;
250474
250735
  return candidate;
250475
250736
  }
@@ -250558,11 +250819,11 @@ function destroyPool() {
250558
250819
  pool?.destroy();
250559
250820
  pool = null;
250560
250821
  }
250561
- var import_node_child_process3, import_node_fs9, import_node_path16, cachedBinaryPath, POOL_SIZE, pool, ProcessPool;
250822
+ var import_node_child_process3, import_node_fs11, import_node_path16, cachedBinaryPath, POOL_SIZE, pool, ProcessPool;
250562
250823
  var init_child_process = __esm({
250563
250824
  "../../packages/compiler/tw/native/child-process.ts"() {
250564
250825
  import_node_child_process3 = require("node:child_process");
250565
- import_node_fs9 = require("node:fs");
250826
+ import_node_fs11 = require("node:fs");
250566
250827
  import_node_path16 = require("node:path");
250567
250828
  cachedBinaryPath = void 0;
250568
250829
  POOL_SIZE = 1;
@@ -255090,6 +255351,7 @@ __export(tw_exports2, {
255090
255351
  PropParser: () => PropParser,
255091
255352
  RENDER_MODE_ALIASES: () => RENDER_MODE_ALIASES,
255092
255353
  RENDER_MODE_NAMES: () => RENDER_MODE_NAMES,
255354
+ RESERVED_BLOCK_BINDINGS: () => RESERVED_BLOCK_BINDINGS,
255093
255355
  RESERVED_WORDS: () => RESERVED_WORDS,
255094
255356
  RuleEngine: () => RuleEngine,
255095
255357
  RulesEngine: () => RulesEngine,
@@ -255733,6 +255995,7 @@ __export(tw_exports2, {
255733
255995
  secretEnvValues: () => secretEnvValues,
255734
255996
  separateByType: () => separateByType,
255735
255997
  serializeCache: () => serializeCache,
255998
+ serverImportCollisions: () => serverImportCollisions,
255736
255999
  serverRouteParamCollisions: () => serverRouteParamCollisions,
255737
256000
  serverStateCollisions: () => serverStateCollisions,
255738
256001
  setBackend: () => setBackend,
@@ -257348,7 +257611,7 @@ var init_layout_chain = __esm({
257348
257611
 
257349
257612
  // ../../packages/server/tw/routing/scanner.ts
257350
257613
  function scanRouteTree(opts) {
257351
- if (!(0, import_node_fs10.existsSync)(opts.homeDir)) return null;
257614
+ if (!(0, import_node_fs12.existsSync)(opts.homeDir)) return null;
257352
257615
  const root = {
257353
257616
  segment: "",
257354
257617
  relativePath: "",
@@ -257366,7 +257629,7 @@ function scanRouteTree(opts) {
257366
257629
  function scanDirectory(dirPath, urlPath, groups, parentNode, opts) {
257367
257630
  let entries;
257368
257631
  try {
257369
- entries = (0, import_node_fs10.readdirSync)(dirPath);
257632
+ entries = (0, import_node_fs12.readdirSync)(dirPath);
257370
257633
  } catch {
257371
257634
  console.warn(`[scanner] Cannot read directory: ${dirPath}`);
257372
257635
  return;
@@ -257377,7 +257640,7 @@ function scanDirectory(dirPath, urlPath, groups, parentNode, opts) {
257377
257640
  if (!ROUTE_EXTENSIONS.has(ext)) continue;
257378
257641
  let stat;
257379
257642
  try {
257380
- stat = (0, import_node_fs10.statSync)(fullPath);
257643
+ stat = (0, import_node_fs12.statSync)(fullPath);
257381
257644
  } catch {
257382
257645
  continue;
257383
257646
  }
@@ -257400,7 +257663,7 @@ function scanDirectory(dirPath, urlPath, groups, parentNode, opts) {
257400
257663
  const fullPath = (0, import_node_path17.join)(dirPath, entry);
257401
257664
  let stat;
257402
257665
  try {
257403
- stat = (0, import_node_fs10.statSync)(fullPath);
257666
+ stat = (0, import_node_fs12.statSync)(fullPath);
257404
257667
  } catch {
257405
257668
  continue;
257406
257669
  }
@@ -257691,10 +257954,10 @@ function printNode(node, prefix, isLast, lines) {
257691
257954
  printNode(node.children[i], childPrefix, i === node.children.length - 1, lines);
257692
257955
  }
257693
257956
  }
257694
- var import_node_fs10, import_node_path17;
257957
+ var import_node_fs12, import_node_path17;
257695
257958
  var init_scanner = __esm({
257696
257959
  "../../packages/server/tw/routing/scanner.ts"() {
257697
- import_node_fs10 = require("node:fs");
257960
+ import_node_fs12 = require("node:fs");
257698
257961
  import_node_path17 = require("node:path");
257699
257962
  init_tw();
257700
257963
  }
@@ -257772,10 +258035,10 @@ function getCacheProfiles(rootDir) {
257772
258035
  function createRenderPipeline(opts) {
257773
258036
  return new RenderPipeline(opts);
257774
258037
  }
257775
- var import_node_fs11, import_node_path18, __profilesCache, RenderPipeline;
258038
+ var import_node_fs13, import_node_path18, __profilesCache, RenderPipeline;
257776
258039
  var init_render_pipeline = __esm({
257777
258040
  "../../packages/server/tw/routing/render-pipeline.ts"() {
257778
- import_node_fs11 = require("node:fs");
258041
+ import_node_fs13 = require("node:fs");
257779
258042
  import_node_path18 = require("node:path");
257780
258043
  init_tw7();
257781
258044
  init_tw();
@@ -257799,7 +258062,7 @@ var init_render_pipeline = __esm({
257799
258062
  async isUnenumeratedParam(pageFile, params) {
257800
258063
  if (!/\[[^\]]+\]/.test(pageFile)) return false;
257801
258064
  const paramsTwm = (0, import_node_path18.dirname)(pageFile) + "/params.twm";
257802
- if (!(0, import_node_fs11.existsSync)(paramsTwm)) return false;
258065
+ if (!(0, import_node_fs13.existsSync)(paramsTwm)) return false;
257803
258066
  try {
257804
258067
  const { loadTWMModule: loadTWMModule2 } = await Promise.resolve().then(() => (init_twm_loader(), twm_loader_exports));
257805
258068
  const pmod = await loadTWMModule2(paramsTwm, this.rootDir);
@@ -257890,10 +258153,10 @@ var init_render_pipeline = __esm({
257890
258153
  /** Read a route file, memoised outside dev. See `sourceCache`. */
257891
258154
  readSource(file) {
257892
258155
  const key2 = file.absolutePath;
257893
- if (this.dev) return (0, import_node_fs11.readFileSync)(key2, "utf-8");
258156
+ if (this.dev) return (0, import_node_fs13.readFileSync)(key2, "utf-8");
257894
258157
  const hit = this.sourceCache.get(key2);
257895
258158
  if (hit !== void 0) return hit;
257896
- const src = (0, import_node_fs11.readFileSync)(key2, "utf-8");
258159
+ const src = (0, import_node_fs13.readFileSync)(key2, "utf-8");
257897
258160
  this.sourceCache.set(key2, src);
257898
258161
  return src;
257899
258162
  }
@@ -258353,9 +258616,9 @@ ${bodyHTML}`;
258353
258616
  try {
258354
258617
  const headCandidates = [];
258355
258618
  const globalHead = join16(this.rootDir, "home", "head.tw");
258356
- if ((0, import_node_fs11.existsSync)(globalHead)) headCandidates.push(globalHead);
258619
+ if ((0, import_node_fs13.existsSync)(globalHead)) headCandidates.push(globalHead);
258357
258620
  const siblingHead = join16((0, import_node_path18.dirname)(ctx.page.absolutePath), "head.tw");
258358
- if (siblingHead !== globalHead && (0, import_node_fs11.existsSync)(siblingHead)) headCandidates.push(siblingHead);
258621
+ if (siblingHead !== globalHead && (0, import_node_fs13.existsSync)(siblingHead)) headCandidates.push(siblingHead);
258359
258622
  for (const hp of headCandidates) {
258360
258623
  const headCompiled = this.compileFile({ absolutePath: hp, type: "head" });
258361
258624
  const m = headCompiled.html.match(/<body>([\s\S]*)<\/body>/);
@@ -258489,7 +258752,7 @@ ${bodyHTML}`;
258489
258752
  }
258490
258753
  };
258491
258754
  }
258492
- if (!(0, import_node_fs11.existsSync)(file.absolutePath)) {
258755
+ if (!(0, import_node_fs13.existsSync)(file.absolutePath)) {
258493
258756
  throw new Error(`Route file not found: ${file.absolutePath}`);
258494
258757
  }
258495
258758
  const source = this.readSource(file);
@@ -258883,7 +259146,7 @@ ${devScript}
258883
259146
  */
258884
259147
  async runMiddleware(pathname, request) {
258885
259148
  const middlewarePath = join16(this.rootDir, "middleware.twm");
258886
- if (!(0, import_node_fs11.existsSync)(middlewarePath)) return;
259149
+ if (!(0, import_node_fs13.existsSync)(middlewarePath)) return;
258887
259150
  const mod = await loadTWMModule(middlewarePath, this.rootDir);
258888
259151
  if (mod.config?.matcher && !shouldMatchMiddleware(mod.config.matcher, pathname)) {
258889
259152
  return;
@@ -259035,10 +259298,10 @@ var init_fs_compat = __esm({
259035
259298
  });
259036
259299
 
259037
259300
  // ../../packages/server/tw/router/index.ts
259038
- var import_node_fs12, import_node_path19, RouteRegistry;
259301
+ var import_node_fs14, import_node_path19, RouteRegistry;
259039
259302
  var init_router = __esm({
259040
259303
  "../../packages/server/tw/router/index.ts"() {
259041
- import_node_fs12 = require("node:fs");
259304
+ import_node_fs14 = require("node:fs");
259042
259305
  init_fs_compat();
259043
259306
  import_node_path19 = require("node:path");
259044
259307
  RouteRegistry = class {
@@ -259104,7 +259367,7 @@ var init_router = __esm({
259104
259367
  return [...this.routes];
259105
259368
  }
259106
259369
  loadFromDir(pagesDir, basePath = "/") {
259107
- if (!(0, import_node_fs12.existsSync)(pagesDir)) return;
259370
+ if (!(0, import_node_fs14.existsSync)(pagesDir)) return;
259108
259371
  const files = [];
259109
259372
  this.collectFiles(pagesDir, ".tw", files, "");
259110
259373
  for (const file of files) {
@@ -259138,10 +259401,10 @@ var init_router = __esm({
259138
259401
  }
259139
259402
  }
259140
259403
  collectFiles(dir, ext, results, relPath) {
259141
- const entries = (0, import_node_fs12.readdirSync)(dir);
259404
+ const entries = (0, import_node_fs14.readdirSync)(dir);
259142
259405
  for (const entry of entries) {
259143
259406
  const fullPath = (0, import_node_path19.join)(dir, entry);
259144
- const stat = (0, import_node_fs12.statSync)(fullPath);
259407
+ const stat = (0, import_node_fs14.statSync)(fullPath);
259145
259408
  if (stat.isDirectory()) {
259146
259409
  this.collectFiles(fullPath, ext, results, (0, import_node_path19.join)(relPath, entry));
259147
259410
  } else if (entry.endsWith(ext)) {
@@ -260859,10 +261122,10 @@ var init_signal_transports = __esm({
260859
261122
  });
260860
261123
 
260861
261124
  // ../../packages/server/tw/static/index.ts
260862
- var import_node_fs13, import_node_path20, StaticHandler;
261125
+ var import_node_fs15, import_node_path20, StaticHandler;
260863
261126
  var init_static = __esm({
260864
261127
  "../../packages/server/tw/static/index.ts"() {
260865
- import_node_fs13 = require("node:fs");
261128
+ import_node_fs15 = require("node:fs");
260866
261129
  init_fs_compat();
260867
261130
  import_node_path20 = require("node:path");
260868
261131
  init_tw();
@@ -260900,31 +261163,31 @@ var init_static = __esm({
260900
261163
  return new Response("Not Found", { status: 404, headers: { "Content-Type": "text/plain" } });
260901
261164
  }
260902
261165
  let filePath = (0, import_node_path20.join)(this.root, safePath);
260903
- if ((0, import_node_fs13.existsSync)(filePath) && (0, import_node_fs13.statSync)(filePath).isDirectory()) {
261166
+ if ((0, import_node_fs15.existsSync)(filePath) && (0, import_node_fs15.statSync)(filePath).isDirectory()) {
260904
261167
  filePath = (0, import_node_path20.join)(filePath, this.indexFile);
260905
261168
  }
260906
- if (!(0, import_node_fs13.existsSync)(filePath)) {
261169
+ if (!(0, import_node_fs15.existsSync)(filePath)) {
260907
261170
  filePath = (0, import_node_path20.join)(this.root, safePath + ".html");
260908
261171
  }
260909
261172
  let notFoundFallback = false;
260910
- if (!(0, import_node_fs13.existsSync)(filePath)) {
261173
+ if (!(0, import_node_fs15.existsSync)(filePath)) {
260911
261174
  filePath = (0, import_node_path20.join)(this.root, safePath, this.indexFile);
260912
261175
  }
260913
- if (!(0, import_node_fs13.existsSync)(filePath)) {
261176
+ if (!(0, import_node_fs15.existsSync)(filePath)) {
260914
261177
  if (this.spa) {
260915
261178
  filePath = (0, import_node_path20.join)(this.root, this.indexFile);
260916
- if (!(0, import_node_fs13.existsSync)(filePath)) {
261179
+ if (!(0, import_node_fs15.existsSync)(filePath)) {
260917
261180
  return new Response("Not Found", { status: 404 });
260918
261181
  }
260919
261182
  } else {
260920
261183
  filePath = (0, import_node_path20.join)(this.root, "404.html");
260921
261184
  notFoundFallback = true;
260922
- if (!(0, import_node_fs13.existsSync)(filePath)) {
261185
+ if (!(0, import_node_fs15.existsSync)(filePath)) {
260923
261186
  return new Response("Not Found", { status: 404, headers: { "Content-Type": "text/plain" } });
260924
261187
  }
260925
261188
  }
260926
261189
  }
260927
- const stat = (0, import_node_fs13.statSync)(filePath);
261190
+ const stat = (0, import_node_fs15.statSync)(filePath);
260928
261191
  const ext = (0, import_node_path20.extname)(filePath).toLowerCase();
260929
261192
  const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
260930
261193
  const bytes = await readBytes(filePath);
@@ -263153,8 +263416,8 @@ var init_bot_detection = __esm({
263153
263416
 
263154
263417
  // ../../packages/security/tw/content-security/protector.ts
263155
263418
  function sanitizeFilename(filename) {
263156
- const basename3 = filename.replace(/^.*[\\/]/, "");
263157
- let clean = basename3.replace(/\x00/g, "");
263419
+ const basename4 = filename.replace(/^.*[\\/]/, "");
263420
+ let clean = basename4.replace(/\x00/g, "");
263158
263421
  clean = clean.replace(/[<>:"|?*]/g, "_");
263159
263422
  clean = clean.replace(/^\.+/, "");
263160
263423
  if (clean.length > 255) {
@@ -269904,8 +270167,8 @@ function getCachedSSR(pathname) {
269904
270167
  return { html: mem.html, etag: mem.etag };
269905
270168
  }
269906
270169
  const diskPath = (0, import_node_path21.join)(_diskCacheDir, pathname.replace(/[\/]/g, "_") + ".html");
269907
- if ((0, import_node_fs15.existsSync)(diskPath)) {
269908
- const content = (0, import_node_fs14.readFileSync)(diskPath, "utf-8");
270170
+ if ((0, import_node_fs17.existsSync)(diskPath)) {
270171
+ const content = (0, import_node_fs16.readFileSync)(diskPath, "utf-8");
269909
270172
  const etag = (0, import_node_crypto7.createHash)("sha256").update(content).digest("hex").slice(0, 16);
269910
270173
  _ssrCache.set(pathname, { html: content, etag, expires: Date.now() + 6e4 });
269911
270174
  return { html: content, etag };
@@ -269916,9 +270179,9 @@ function setCachedSSR(pathname, html) {
269916
270179
  const etag = (0, import_node_crypto7.createHash)("sha256").update(html).digest("hex").slice(0, 16);
269917
270180
  _ssrCache.set(pathname, { html, etag, expires: Date.now() + 6e4 });
269918
270181
  try {
269919
- if (!(0, import_node_fs15.existsSync)(_diskCacheDir)) (0, import_node_fs14.mkdirSync)(_diskCacheDir, { recursive: true });
270182
+ if (!(0, import_node_fs17.existsSync)(_diskCacheDir)) (0, import_node_fs16.mkdirSync)(_diskCacheDir, { recursive: true });
269920
270183
  const diskPath = (0, import_node_path21.join)(_diskCacheDir, pathname.replace(/[\/]/g, "_") + ".html");
269921
- (0, import_node_fs14.writeFileSync)(diskPath, html);
270184
+ (0, import_node_fs16.writeFileSync)(diskPath, html);
269922
270185
  } catch {
269923
270186
  }
269924
270187
  return etag;
@@ -269945,15 +270208,15 @@ function generatePreloadHints(assets) {
269945
270208
  }
269946
270209
  return hints.join("\n");
269947
270210
  }
269948
- var import_node_fs14, import_node_crypto7, import_node_path21, import_node_fs15, SSRRenderer, _ssrCache, _diskCacheDir;
270211
+ var import_node_fs16, import_node_crypto7, import_node_path21, import_node_fs17, SSRRenderer, _ssrCache, _diskCacheDir;
269949
270212
  var init_ssr = __esm({
269950
270213
  "../../packages/server/tw/ssr/index.ts"() {
269951
- import_node_fs14 = require("node:fs");
270214
+ import_node_fs16 = require("node:fs");
269952
270215
  init_fs_compat();
269953
270216
  init_tw();
269954
270217
  import_node_crypto7 = require("node:crypto");
269955
270218
  import_node_path21 = require("node:path");
269956
- import_node_fs15 = require("node:fs");
270219
+ import_node_fs17 = require("node:fs");
269957
270220
  SSRRenderer = class {
269958
270221
  pagesDir;
269959
270222
  cacheDir;
@@ -270025,9 +270288,9 @@ var init_ssr = __esm({
270025
270288
  }
270026
270289
  }
270027
270290
  const filePath = this.resolveRoute(pathname);
270028
- if (!filePath || !(0, import_node_fs14.existsSync)(filePath)) return null;
270291
+ if (!filePath || !(0, import_node_fs16.existsSync)(filePath)) return null;
270029
270292
  try {
270030
- const source = (0, import_node_fs14.readFileSync)(filePath, "utf-8");
270293
+ const source = (0, import_node_fs16.readFileSync)(filePath, "utf-8");
270031
270294
  return {
270032
270295
  html: `<html><body>SSR sync not available</body></html>`,
270033
270296
  css: "",
@@ -270062,35 +270325,35 @@ var init_ssr = __esm({
270062
270325
  let currentDir = this.pagesDir;
270063
270326
  if (segments.length === 0) {
270064
270327
  const pagePath = (0, import_node_path21.join)(this.pagesDir, "page.tw");
270065
- if ((0, import_node_fs14.existsSync)(pagePath)) return pagePath;
270328
+ if ((0, import_node_fs16.existsSync)(pagePath)) return pagePath;
270066
270329
  const indexPath = (0, import_node_path21.join)(this.pagesDir, "index.tw");
270067
- if ((0, import_node_fs14.existsSync)(indexPath)) return indexPath;
270330
+ if ((0, import_node_fs16.existsSync)(indexPath)) return indexPath;
270068
270331
  return null;
270069
270332
  }
270070
270333
  for (let i = 0; i < segments.length; i++) {
270071
270334
  const seg = segments[i];
270072
270335
  const isLast = i === segments.length - 1;
270073
- const entries = (0, import_node_fs14.existsSync)(currentDir) ? require("node:fs").readdirSync(currentDir) : [];
270336
+ const entries = (0, import_node_fs16.existsSync)(currentDir) ? require("node:fs").readdirSync(currentDir) : [];
270074
270337
  if (isLast) {
270075
270338
  const exactPath = (0, import_node_path21.join)(currentDir, seg + ".tw");
270076
- if ((0, import_node_fs14.existsSync)(exactPath)) return exactPath;
270339
+ if ((0, import_node_fs16.existsSync)(exactPath)) return exactPath;
270077
270340
  const dirPage = (0, import_node_path21.join)(currentDir, seg, "page.tw");
270078
- if ((0, import_node_fs14.existsSync)(dirPage)) return dirPage;
270341
+ if ((0, import_node_fs16.existsSync)(dirPage)) return dirPage;
270079
270342
  const paramFile = entries.find((e) => e.match(/^\[([^\]]+)\]\.tw$/));
270080
270343
  if (paramFile) return (0, import_node_path21.join)(currentDir, paramFile);
270081
270344
  const paramDir = entries.find((e) => e.match(/^\[([^\]]+)\]$/));
270082
270345
  if (paramDir) {
270083
270346
  const p = (0, import_node_path21.join)(currentDir, paramDir, "page.tw");
270084
- if ((0, import_node_fs14.existsSync)(p)) return p;
270347
+ if ((0, import_node_fs16.existsSync)(p)) return p;
270085
270348
  const pIdx = (0, import_node_path21.join)(currentDir, paramDir, "index.tw");
270086
- if ((0, import_node_fs14.existsSync)(pIdx)) return pIdx;
270349
+ if ((0, import_node_fs16.existsSync)(pIdx)) return pIdx;
270087
270350
  }
270088
270351
  const idx = (0, import_node_path21.join)(currentDir, seg, "index.tw");
270089
- if ((0, import_node_fs14.existsSync)(idx)) return idx;
270352
+ if ((0, import_node_fs16.existsSync)(idx)) return idx;
270090
270353
  return null;
270091
270354
  }
270092
270355
  const dirPath = (0, import_node_path21.join)(currentDir, seg);
270093
- if ((0, import_node_fs14.existsSync)(dirPath) && require("node:fs").statSync(dirPath).isDirectory()) {
270356
+ if ((0, import_node_fs16.existsSync)(dirPath) && require("node:fs").statSync(dirPath).isDirectory()) {
270094
270357
  currentDir = dirPath;
270095
270358
  } else {
270096
270359
  const paramDir = entries.find((e) => e.match(/^\[([^\]]+)\]$/));
@@ -271642,7 +271905,7 @@ function applyRewrites(rewrites, pathname) {
271642
271905
  }
271643
271906
  return null;
271644
271907
  }
271645
- var import_node_path22, import_node_fs16, TWServer;
271908
+ var import_node_path22, import_node_fs18, TWServer;
271646
271909
  var init_tw9 = __esm({
271647
271910
  "../../packages/server/tw/index.ts"() {
271648
271911
  init_tw();
@@ -271651,7 +271914,7 @@ var init_tw9 = __esm({
271651
271914
  init_websocket_manager();
271652
271915
  init_routing2();
271653
271916
  import_node_path22 = require("node:path");
271654
- import_node_fs16 = require("node:fs");
271917
+ import_node_fs18 = require("node:fs");
271655
271918
  init_twm_rules();
271656
271919
  init_router();
271657
271920
  init_middleware2();
@@ -271894,11 +272157,11 @@ var init_tw9 = __esm({
271894
272157
  }
271895
272158
  }
271896
272159
  const staticDir = this.options.staticDir ?? (0, import_node_path22.join)(options.rootDir, ".tw");
271897
- if ((0, import_node_fs16.existsSync)(staticDir)) {
272160
+ if ((0, import_node_fs18.existsSync)(staticDir)) {
271898
272161
  try {
271899
272162
  const manifestPath = (0, import_node_path22.join)(staticDir, "routes.json");
271900
- if ((0, import_node_fs16.existsSync)(manifestPath)) {
271901
- const manifest = JSON.parse((0, import_node_fs16.readFileSync)(manifestPath, "utf-8"));
272163
+ if ((0, import_node_fs18.existsSync)(manifestPath)) {
272164
+ const manifest = JSON.parse((0, import_node_fs18.readFileSync)(manifestPath, "utf-8"));
271902
272165
  for (const [route, secs] of Object.entries(manifest)) {
271903
272166
  this.isrRoutes.set(route, secs);
271904
272167
  }
@@ -271916,7 +272179,7 @@ var init_tw9 = __esm({
271916
272179
  });
271917
272180
  }
271918
272181
  const homeDir = this.options.pagesDir ?? (0, import_node_path22.join)(options.rootDir, "home");
271919
- if ((0, import_node_fs16.existsSync)(homeDir)) {
272182
+ if ((0, import_node_fs18.existsSync)(homeDir)) {
271920
272183
  this.ssr = new SSRRenderer({ pagesDir: homeDir, enableCache: true, cacheTTL: 6e4 });
271921
272184
  }
271922
272185
  }
@@ -271963,11 +272226,11 @@ var init_tw9 = __esm({
271963
272226
  middlewarePath = null;
271964
272227
  loadMiddleware() {
271965
272228
  const middlewarePath = (0, import_node_path22.join)(this.options.rootDir, "middleware.twm");
271966
- if ((0, import_node_fs16.existsSync)(middlewarePath)) {
272229
+ if ((0, import_node_fs18.existsSync)(middlewarePath)) {
271967
272230
  this.middlewarePath = middlewarePath;
271968
272231
  console.log(" Middleware: middleware.twm loaded");
271969
272232
  try {
271970
- const src = (0, import_node_fs16.readFileSync)(middlewarePath, "utf-8");
272233
+ const src = (0, import_node_fs18.readFileSync)(middlewarePath, "utf-8");
271971
272234
  const rules = parseRules(src, "middleware.twm");
271972
272235
  for (const r of rules) {
271973
272236
  const conds = [];
@@ -272458,7 +272721,7 @@ var init_tw9 = __esm({
272458
272721
  return new Response("Bad Request", { status: 400 });
272459
272722
  }
272460
272723
  const homeDir = (0, import_node_path22.join)(this.options.rootDir, "home");
272461
- if (!(0, import_node_fs16.existsSync)(homeDir)) return new Response("Not Found", { status: 404 });
272724
+ if (!(0, import_node_fs18.existsSync)(homeDir)) return new Response("Not Found", { status: 404 });
272462
272725
  try {
272463
272726
  const { createRenderPipeline: createRenderPipeline2 } = await Promise.resolve().then(() => (init_routing2(), routing_exports));
272464
272727
  if (!this.renderPipeline) {
@@ -272607,7 +272870,7 @@ var init_tw9 = __esm({
272607
272870
  try {
272608
272871
  const { createRenderPipeline: createRenderPipeline2 } = await Promise.resolve().then(() => (init_routing2(), routing_exports));
272609
272872
  const homeDir = (0, import_node_path22.join)(this.options.rootDir, "home");
272610
- if ((0, import_node_fs16.existsSync)(homeDir)) {
272873
+ if ((0, import_node_fs18.existsSync)(homeDir)) {
272611
272874
  const pipeline = createRenderPipeline2({
272612
272875
  rootDir: this.options.rootDir,
272613
272876
  homeDir,
@@ -272667,7 +272930,7 @@ ${err2.stack ?? ""}`);
272667
272930
  try {
272668
272931
  const { createRenderPipeline: createRenderPipeline2, setActivePipeline: setActivePipeline2 } = await Promise.resolve().then(() => (init_routing2(), routing_exports));
272669
272932
  const homeDir = (0, import_node_path22.join)(this.options.rootDir, "home");
272670
- if ((0, import_node_fs16.existsSync)(homeDir)) {
272933
+ if ((0, import_node_fs18.existsSync)(homeDir)) {
272671
272934
  if (!this.renderPipeline) {
272672
272935
  this.renderPipeline = createRenderPipeline2({
272673
272936
  rootDir: this.options.rootDir,
@@ -287442,7 +287705,7 @@ function clearTWMCache() {
287442
287705
  function validateTWMSyntax(filePath) {
287443
287706
  let source;
287444
287707
  try {
287445
- source = (0, import_node_fs17.readFileSync)(filePath, "utf-8");
287708
+ source = (0, import_node_fs19.readFileSync)(filePath, "utf-8");
287446
287709
  } catch (err2) {
287447
287710
  return "cannot read: " + (err2?.message ?? err2);
287448
287711
  }
@@ -287542,7 +287805,7 @@ async function loadLibModule(rootDir, name) {
287542
287805
  const cacheKey = rootDir + "/" + rel;
287543
287806
  if (libCache.has(cacheKey)) return libCache.get(cacheKey);
287544
287807
  const libPath = (0, import_node_path23.join)(rootDir, "lib", rel + ".ts");
287545
- if (!(0, import_node_fs17.existsSync)(libPath)) {
287808
+ if (!(0, import_node_fs19.existsSync)(libPath)) {
287546
287809
  throw new Error("Module '" + name + "' not found. Create lib/" + name + ".ts");
287547
287810
  }
287548
287811
  try {
@@ -287584,10 +287847,10 @@ async function loadTWMModule(filePath, rootDir) {
287584
287847
  const cacheKey = filePath;
287585
287848
  const cached2 = moduleCache.get(cacheKey);
287586
287849
  if (cached2) return cached2;
287587
- if (!(0, import_node_fs17.existsSync)(filePath)) {
287850
+ if (!(0, import_node_fs19.existsSync)(filePath)) {
287588
287851
  throw new Error("TWM module not found: " + filePath);
287589
287852
  }
287590
- const source = (0, import_node_fs17.readFileSync)(filePath, "utf-8");
287853
+ const source = (0, import_node_fs19.readFileSync)(filePath, "utf-8");
287591
287854
  const rd = rootDir || process.cwd();
287592
287855
  if (isRuleDsl(source)) {
287593
287856
  try {
@@ -288115,10 +288378,10 @@ function shouldMatchMiddleware(matchers, pathname) {
288115
288378
  }
288116
288379
  return false;
288117
288380
  }
288118
- var import_node_fs17, import_node_path23, moduleCache, libCache, apiRuntime, routeCache, IMPURE_PATTERNS, NONDET_PATTERN, __twmProfiles, handlerCache, pendingHandlerRefresh;
288381
+ var import_node_fs19, import_node_path23, moduleCache, libCache, apiRuntime, routeCache, IMPURE_PATTERNS, NONDET_PATTERN, __twmProfiles, handlerCache, pendingHandlerRefresh;
288119
288382
  var init_twm_loader = __esm({
288120
288383
  "../../packages/server/tw/routing/twm-loader.ts"() {
288121
- import_node_fs17 = require("node:fs");
288384
+ import_node_fs19 = require("node:fs");
288122
288385
  init_revalidate();
288123
288386
  init_signal_stream();
288124
288387
  import_node_path23 = require("node:path");
@@ -288159,15 +288422,15 @@ __export(testing_exports, {
288159
288422
  });
288160
288423
  module.exports = __toCommonJS(testing_exports);
288161
288424
  var import_node_path24 = require("node:path");
288162
- var import_node_fs18 = require("node:fs");
288425
+ var import_node_fs20 = require("node:fs");
288163
288426
  var import_meta = {};
288164
288427
  function resolveRouteFile(rootDir, pathname) {
288165
288428
  const homeDir = (0, import_node_path24.join)(rootDir, "home");
288166
- if (!(0, import_node_fs18.existsSync)(homeDir)) return null;
288429
+ if (!(0, import_node_fs20.existsSync)(homeDir)) return null;
288167
288430
  const segments = pathname.split("/").filter(Boolean).map(decodeURIComponent);
288168
288431
  const isDir = (p) => {
288169
288432
  try {
288170
- return (0, import_node_fs18.existsSync)(p) && (0, import_node_fs18.statSync)(p).isDirectory();
288433
+ return (0, import_node_fs20.existsSync)(p) && (0, import_node_fs20.statSync)(p).isDirectory();
288171
288434
  } catch {
288172
288435
  return false;
288173
288436
  }
@@ -288175,7 +288438,7 @@ function resolveRouteFile(rootDir, pathname) {
288175
288438
  function walk3(dir, i, params) {
288176
288439
  if (i >= segments.length) {
288177
288440
  const f = (0, import_node_path24.join)(dir, "route.twm");
288178
- return (0, import_node_fs18.existsSync)(f) ? { file: f, params } : null;
288441
+ return (0, import_node_fs20.existsSync)(f) ? { file: f, params } : null;
288179
288442
  }
288180
288443
  const seg = segments[i];
288181
288444
  const exact = (0, import_node_path24.join)(dir, seg);
@@ -288183,7 +288446,7 @@ function resolveRouteFile(rootDir, pathname) {
288183
288446
  const r = walk3(exact, i + 1, params);
288184
288447
  if (r) return r;
288185
288448
  }
288186
- for (const entry of (0, import_node_fs18.readdirSync)(dir)) {
288449
+ for (const entry of (0, import_node_fs20.readdirSync)(dir)) {
288187
288450
  if (/^\(.*\)$/.test(entry) && isDir((0, import_node_path24.join)(dir, entry))) {
288188
288451
  const r = walk3((0, import_node_path24.join)(dir, entry), i, params);
288189
288452
  if (r) return r;
@@ -288196,7 +288459,7 @@ function resolveRouteFile(rootDir, pathname) {
288196
288459
  const c = /^\[\.\.\.(.+)\]$/.exec(entry) || /^\[\[\.\.\.(.+)\]\]$/.exec(entry);
288197
288460
  if (c && isDir((0, import_node_path24.join)(dir, entry))) {
288198
288461
  const f = (0, import_node_path24.join)(dir, entry, "route.twm");
288199
- if ((0, import_node_fs18.existsSync)(f)) return { file: f, params: { ...params, [c[1]]: segments.slice(i).join("/") } };
288462
+ if ((0, import_node_fs20.existsSync)(f)) return { file: f, params: { ...params, [c[1]]: segments.slice(i).join("/") } };
288200
288463
  }
288201
288464
  }
288202
288465
  return null;
@@ -288226,7 +288489,7 @@ async function testPage(rootDir, pathname) {
288226
288489
  const segments = pathname.split("/").filter(Boolean);
288227
288490
  const isDir = (p) => {
288228
288491
  try {
288229
- return (0, import_node_fs18.existsSync)(p) && (0, import_node_fs18.statSync)(p).isDirectory();
288492
+ return (0, import_node_fs20.existsSync)(p) && (0, import_node_fs20.statSync)(p).isDirectory();
288230
288493
  } catch {
288231
288494
  return false;
288232
288495
  }
@@ -288234,7 +288497,7 @@ async function testPage(rootDir, pathname) {
288234
288497
  function walk3(dir, i, params) {
288235
288498
  if (i >= segments.length) {
288236
288499
  const f = (0, import_node_path24.join)(dir, "page.tw");
288237
- return (0, import_node_fs18.existsSync)(f) ? { file: f, params } : null;
288500
+ return (0, import_node_fs20.existsSync)(f) ? { file: f, params } : null;
288238
288501
  }
288239
288502
  const seg = segments[i];
288240
288503
  const exact = (0, import_node_path24.join)(dir, seg);
@@ -288242,7 +288505,7 @@ async function testPage(rootDir, pathname) {
288242
288505
  const r = walk3(exact, i + 1, params);
288243
288506
  if (r) return r;
288244
288507
  }
288245
- for (const entry of (0, import_node_fs18.readdirSync)(dir)) {
288508
+ for (const entry of (0, import_node_fs20.readdirSync)(dir)) {
288246
288509
  if (/^\(.*\)$/.test(entry) && isDir((0, import_node_path24.join)(dir, entry))) {
288247
288510
  const r = walk3((0, import_node_path24.join)(dir, entry), i, params);
288248
288511
  if (r) return r;
@@ -288255,7 +288518,7 @@ async function testPage(rootDir, pathname) {
288255
288518
  const c = /^\[\.\.\.(.+)\]$/.exec(entry);
288256
288519
  if (c && isDir((0, import_node_path24.join)(dir, entry))) {
288257
288520
  const f = (0, import_node_path24.join)(dir, entry, "page.tw");
288258
- if ((0, import_node_fs18.existsSync)(f)) return { file: f, params: { ...params, [c[1]]: segments.slice(i).join("/") } };
288521
+ if ((0, import_node_fs20.existsSync)(f)) return { file: f, params: { ...params, [c[1]]: segments.slice(i).join("/") } };
288259
288522
  }
288260
288523
  }
288261
288524
  return null;
@@ -288265,28 +288528,28 @@ async function testPage(rootDir, pathname) {
288265
288528
  const { compileSync: compileSync3, generateWithLayoutChain: generateWithLayoutChain2, registerComponentTemplate: registerComponentTemplate2, clearComponentRegistry: clearComponentRegistry2 } = await findCompiler();
288266
288529
  clearComponentRegistry2();
288267
288530
  const compDir = (0, import_node_path24.join)(rootDir, "components");
288268
- if ((0, import_node_fs18.existsSync)(compDir)) {
288269
- for (const f of (0, import_node_fs18.readdirSync)(compDir).filter((f2) => f2.endsWith(".tw"))) {
288531
+ if ((0, import_node_fs20.existsSync)(compDir)) {
288532
+ for (const f of (0, import_node_fs20.readdirSync)(compDir).filter((f2) => f2.endsWith(".tw"))) {
288270
288533
  const fp = (0, import_node_path24.join)(compDir, f);
288271
- const r = compileSync3((0, import_node_fs18.readFileSync)(fp, "utf-8"), { filePath: fp, transforms: false, diagnostics: false });
288534
+ const r = compileSync3((0, import_node_fs20.readFileSync)(fp, "utf-8"), { filePath: fp, transforms: false, diagnostics: false });
288272
288535
  if (r.ast) registerComponentTemplate2(f.replace(/\.tw$/, ""), r.ast);
288273
288536
  }
288274
288537
  }
288275
- const result = compileSync3((0, import_node_fs18.readFileSync)(resolved.file, "utf-8"), { filePath: resolved.file, stateVars: resolved.params });
288538
+ const result = compileSync3((0, import_node_fs20.readFileSync)(resolved.file, "utf-8"), { filePath: resolved.file, stateVars: resolved.params });
288276
288539
  let html = result.html;
288277
288540
  const pageProgram = result.ast;
288278
288541
  const layouts = [];
288279
288542
  let d = (0, import_node_path24.dirname)(resolved.file);
288280
288543
  while (true) {
288281
288544
  const lp = (0, import_node_path24.join)(d, "layout.tw");
288282
- if ((0, import_node_fs18.existsSync)(lp) && d.startsWith(homeDir)) layouts.unshift(lp);
288545
+ if ((0, import_node_fs20.existsSync)(lp) && d.startsWith(homeDir)) layouts.unshift(lp);
288283
288546
  if (d === homeDir || !d.startsWith(homeDir)) break;
288284
288547
  const parent = (0, import_node_path24.dirname)(d);
288285
288548
  if (parent === d) break;
288286
288549
  d = parent;
288287
288550
  }
288288
288551
  if (layouts.length > 0) {
288289
- const progs = layouts.map((lp) => compileSync3((0, import_node_fs18.readFileSync)(lp, "utf-8"), { filePath: lp }).ast).filter(Boolean);
288552
+ const progs = layouts.map((lp) => compileSync3((0, import_node_fs20.readFileSync)(lp, "utf-8"), { filePath: lp }).ast).filter(Boolean);
288290
288553
  if (progs.length > 0 && generateWithLayoutChain2) {
288291
288554
  html = generateWithLayoutChain2(progs, pageProgram, resolved.params);
288292
288555
  }
@@ -288301,7 +288564,7 @@ async function findCompiler() {
288301
288564
  (0, import_node_path24.join)(rootDirGlobal, "packages/compiler/tw/index.ts"),
288302
288565
  process.env.TW_COMPILER_PATH ?? ""
288303
288566
  ].filter(Boolean);
288304
- for (const c of candidates) if ((0, import_node_fs18.existsSync)(c)) return import(c);
288567
+ for (const c of candidates) if ((0, import_node_fs20.existsSync)(c)) return import(c);
288305
288568
  const selfDir = import_meta.dir ?? (typeof __dirname !== "undefined" ? __dirname : "");
288306
288569
  return import((0, import_node_path24.join)(selfDir, "../../../compiler/tw/index.ts"));
288307
288570
  }