meno-astro 0.1.11 → 0.1.12
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/chunks/{chunk-RDEADJXD.js → chunk-S4IA22D6.js} +5 -2
- package/dist/chunks/chunk-S4IA22D6.js.map +7 -0
- package/dist/lib/dialect/index.js +1 -1
- package/dist/lib/integration/index.js +44 -22
- package/dist/lib/integration/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-RDEADJXD.js.map +0 -7
|
@@ -162,9 +162,12 @@ function rewriteItemRefs(str, itemVar, acc) {
|
|
|
162
162
|
const first = `(${idx} === 0)`;
|
|
163
163
|
const last = `(${idx} === ${itemVar}Arr.length - 1)`;
|
|
164
164
|
const namedLast = new RegExp(`\\b${itemVar}Last\\b`);
|
|
165
|
+
const namedArr = new RegExp(`\\b${itemVar}Arr\\b`);
|
|
165
166
|
return str.replace(TEMPLATE_RE, (_m, expr) => {
|
|
166
167
|
let s = String(expr);
|
|
167
|
-
if (/\bitemLast\b/.test(s) || namedLast.test(s))
|
|
168
|
+
if (/\bitemLast\b/.test(s) || namedLast.test(s) || /\bitemArr\b/.test(s) || namedArr.test(s)) {
|
|
169
|
+
acc.needsArr = true;
|
|
170
|
+
}
|
|
168
171
|
if (itemVar !== "item") {
|
|
169
172
|
s = s.replace(new RegExp(`\\b${itemVar}First\\b`, "g"), first).replace(new RegExp(`\\b${itemVar}Last\\b`, "g"), last);
|
|
170
173
|
}
|
|
@@ -1854,4 +1857,4 @@ export {
|
|
|
1854
1857
|
emit,
|
|
1855
1858
|
parse
|
|
1856
1859
|
};
|
|
1857
|
-
//# sourceMappingURL=chunk-
|
|
1860
|
+
//# sourceMappingURL=chunk-S4IA22D6.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../lib/dialect/emit/emitContext.ts", "../../lib/dialect/emit/serialize.ts", "../../lib/dialect/richtext.ts", "../../lib/dialect/emit/emitNode.ts", "../../lib/dialect/emit/frontmatter.ts", "../../lib/dialect/cmsRoute.ts", "../../lib/dialect/emit/emitPage.ts", "../../lib/dialect/scriptBind.ts", "../../lib/dialect/emit/emitComponent.ts", "../../lib/dialect/parse/scan.ts", "../../lib/dialect/parse/parseLiteral.ts", "../../lib/dialect/parse/callArgs.ts", "../../lib/dialect/parse/parseValue.ts", "../../lib/dialect/parse/parseContext.ts", "../../lib/dialect/parse/parseFrontmatter.ts", "../../lib/dialect/parse/parseBody.ts", "../../lib/dialect/parse/parseFile.ts", "../../lib/dialect/normalize.ts", "../../lib/dialect/lineMap.ts", "../../lib/dialect/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * EmitContext \u2014 accumulates everything a single `.astro` file needs that is\n * discovered while walking the node tree: component imports, `meno-astro` runtime\n * symbols/components, and frontmatter const declarations (CMS collection queries).\n *\n * The node walker writes the template body; the page/component assembler reads the\n * context afterwards to emit a deterministic frontmatter (alphabetized imports, then\n * the collected consts).\n */\n\nexport interface EmitContext {\n /** Names of components referenced by `type:\"component\"` instances (need a local import). */\n components: Set<string>;\n /** Symbols imported from `meno-astro` (e.g. style, i18n, list, getCollectionList, when, embedHtml). */\n runtime: Set<string>;\n /** Astro components imported from `meno-astro/components` (e.g. LocaleList, MenoImage). */\n runtimeComponents: Set<string>;\n /** Frontmatter `const \u2026 = \u2026` lines (collection-list queries), in insertion order. */\n frontmatterConsts: string[];\n /**\n * Stack of active list loop-item variable names (e.g. `post` inside a\n * `blogList.map((post, \u2026) => \u2026)`). A component instance emitted inside a list\n * passes these so a CMS-card component bound to `{{post.title}}` receives the item\n * (which it declares from `Astro.props` \u2014 see emitComponent's item bindings).\n */\n loopVars: string[];\n /**\n * True when the file emits a CMS collection list, so the page/component must\n * `import { getCollection } from 'astro:content'` and pass it to getCollectionList\n * (meno-astro never imports astro:content itself \u2014 see runtime/collectionList).\n */\n needsContentApi: boolean;\n /**\n * True when `cms` is in the surrounding render scope \u2014 a CMS template page (which\n * destructures `const { cms } = Astro.props` from getStaticPaths) or a component that\n * itself receives `cms`. In meno-core the CMS item flows to all descendants implicitly;\n * Astro components are isolated, so a component instance emitted here is forwarded\n * `cms={cms}` (renderComponentInstance) \u2014 otherwise a `<BlogPostBody />` whose body uses\n * `{{cms.featuredImage}}` reads `cms` as undefined and crashes. Set before the body walk.\n */\n cmsInScope?: boolean;\n /**\n * Name of the resolved-props object to pass into `style()` (and href/embed) so\n * prop-`_mapping`s resolve \u2014 `'__props'` inside a component, undefined on a page\n * (pages have no props). Set by emitComponent before the body is walked.\n */\n propsVar?: string;\n /**\n * Names of props declared `type:\"rich-text\"` in this component's interface. A text child\n * that is a bare ref to one of these (`{{text}}`) renders as real HTML via\n * `<Fragment set:html={text} />` \u2014 a plain `{text}` would HTML-escape the markup and the\n * inline marks (spans/strong/links) would die. Set by emitComponent before the body walk;\n * undefined on pages (which have no prop interface).\n */\n richTextProps?: Set<string>;\n /** Monotonic counter for generating unique frontmatter binding names. */\n listCounter: number;\n /** Monotonic counter for hoisted verbatim consts (multi-line embed HTML). */\n hoistCounter: number;\n /** Monotonic counter for dynamic-tag consts (`const Tag_0 = \\`h${size}\\``). */\n tagCounter: number;\n /** Max literal line width before objects/arrays expand. */\n width: number;\n}\n\nexport function createEmitContext(width = 80): EmitContext {\n return {\n components: new Set(),\n runtime: new Set(),\n runtimeComponents: new Set(),\n frontmatterConsts: [],\n loopVars: [],\n needsContentApi: false,\n listCounter: 0,\n hoistCounter: 0,\n tagCounter: 0,\n width,\n };\n}\n\n/**\n * Per-file emit options threaded from the converter (and editor save path) so\n * component imports resolve across category subfolders. Absent for flat projects\n * (and tests), where emit falls back to flat `./Name.astro` / `../components/Name.astro`.\n */\nexport interface EmitOptions {\n /** Component name \u2192 its path under `components/` without extension (e.g. `section/Error404`). */\n componentPaths?: Record<string, string>;\n /** For component emit: this component's own path under `components/` (e.g. `ui/Card`). */\n selfPath?: string;\n}\n\n/**\n * POSIX relative import path from a directory to a target (both '/'-separated,\n * extensionless). `relativeComponentImport('ui', 'section/Hero')` \u2192 `'../section/Hero'`.\n */\nexport function relativeComponentImport(fromDir: string, target: string): string {\n const f = fromDir ? fromDir.split('/').filter(Boolean) : [];\n const t = target.split('/').filter(Boolean);\n let i = 0;\n while (i < f.length && i < t.length && f[i] === t[i]) i++;\n const parts = [...Array(f.length - i).fill('..'), ...t.slice(i)];\n const rel = parts.join('/');\n return rel.startsWith('.') ? rel : './' + rel;\n}\n\n/** Register a `meno-astro` runtime symbol and return its name (for fluent use). */\nexport function needRuntime(ctx: EmitContext, name: string): string {\n ctx.runtime.add(name);\n return name;\n}\n\n/** Register a `meno-astro/components` Astro component and return its tag name. */\nexport function needRuntimeComponent(ctx: EmitContext, name: string): string {\n ctx.runtimeComponents.add(name);\n return name;\n}\n", "/**\n * Deterministic JS-literal serializer \u2014 the round-trip linchpin.\n *\n * Every non-structural payload in the meno-astro dialect (style objects, component\n * props, `export const meta`, the `resolveProps(Astro, {\u2026})` argument, i18n values,\n * list config, mappings) is emitted as the literal argument of a known call or a named\n * const. This serializer\n * produces those literals so that:\n * - the output is valid JS (embeds cleanly in `.astro` frontmatter + JSX expressions),\n * - it is parseable back verbatim by a tiny total evaluator (Phase 2 parser),\n * - it is deterministic + diff-stable (stable key order, canonical formatting).\n *\n * Formatting: small values render inline; values whose inline form would exceed\n * `width` columns expand to one entry per line (clean git diffs). Strings use JSON\n * double-quote escaping. Object keys are emitted unquoted when they are valid JS\n * identifiers, quoted otherwise.\n */\n\nconst DEFAULT_WIDTH = 80;\nconst INDENT_STEP = 2;\n\nconst IDENT_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\n/** Whether a key can be emitted unquoted as a JS object key. */\nexport function isIdentifier(key: string): boolean {\n return IDENT_RE.test(key);\n}\n\nfunction renderKey(key: string): string {\n return isIdentifier(key) ? key : JSON.stringify(key);\n}\n\nfunction renderString(value: string): string {\n // JSON string escaping is valid JS string escaping (and single-line).\n return JSON.stringify(value);\n}\n\nfunction renderNumber(value: number): string {\n return Number.isFinite(value) ? String(value) : 'null';\n}\n\n/** Object entries with `undefined` values dropped (JSON semantics; the model should not carry undefined). */\nfunction definedEntries(obj: Record<string, unknown>): Array<[string, unknown]> {\n return Object.entries(obj).filter(([, v]) => v !== undefined);\n}\n\n/** Always-inline rendering (never emits newlines). Used for fit-testing and for short values. */\nfunction renderInline(value: unknown): string {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n switch (typeof value) {\n case 'string':\n return renderString(value);\n case 'number':\n return renderNumber(value);\n case 'boolean':\n return String(value);\n case 'object': {\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]';\n return '[' + value.map(renderInline).join(', ') + ']';\n }\n const entries = definedEntries(value as Record<string, unknown>);\n if (entries.length === 0) return '{}';\n return (\n '{ ' +\n entries.map(([k, v]) => `${renderKey(k)}: ${renderInline(v)}`).join(', ') +\n ' }'\n );\n }\n default:\n // functions/symbols/bigint are not part of the model\n return 'null';\n }\n}\n\nexport interface SerializeOptions {\n /** Column at which continuation lines of this value are indented. Default 0. */\n indent?: number;\n /** Max line width before an object/array expands to multi-line. Default 80. */\n width?: number;\n /**\n * Column where this value begins on the current line (drives the top-level\n * inline-fit test). Defaults to `indent`. Set this when the value is emitted to\n * the right of a prefix (e.g. `resolveProps(Astro, <here>)`) but its\n * continuation lines should still indent relative to `indent`.\n */\n startCol?: number;\n}\n\n/**\n * Serialize a model value to a deterministic JS literal string.\n * The returned string has no leading indentation; continuation lines are indented\n * relative to `opts.indent` (the column where the value starts).\n */\nexport function serializeLiteral(value: unknown, opts: SerializeOptions = {}): string {\n const width = opts.width ?? DEFAULT_WIDTH;\n const baseIndent = opts.indent ?? 0;\n const startCol = opts.startCol ?? baseIndent;\n\n /**\n * @param v value to render\n * @param contIndent indentation (spaces) for continuation lines of this value\n * @param startCol column where this value begins on the current line (for the inline-fit test)\n */\n const render = (v: unknown, contIndent: number, startCol: number): string => {\n // Primitives are always inline.\n if (v === null || typeof v !== 'object') return renderInline(v);\n\n const inline = renderInline(v);\n if (startCol + inline.length <= width) return inline;\n\n const pad = ' '.repeat(contIndent + INDENT_STEP);\n const closePad = ' '.repeat(contIndent);\n\n if (Array.isArray(v)) {\n if (v.length === 0) return '[]';\n const items = v.map(\n (item) => pad + render(item, contIndent + INDENT_STEP, contIndent + INDENT_STEP),\n );\n return '[\\n' + items.join(',\\n') + '\\n' + closePad + ']';\n }\n\n const entries = definedEntries(v as Record<string, unknown>);\n if (entries.length === 0) return '{}';\n const lines = entries.map(([k, val]) => {\n const prefix = pad + renderKey(k) + ': ';\n return prefix + render(val, contIndent + INDENT_STEP, prefix.length);\n });\n return '{\\n' + lines.join(',\\n') + '\\n' + closePad + '}';\n };\n\n return render(value, baseIndent, startCol);\n}\n", "/**\n * Rich-text HTML codec helpers shared by the emitter and the parser.\n *\n * A Meno \"rich-text\" value is an HTML string (Tiptap \u2192 meno-core's `tiptapToHtml`). It\n * must render as REAL HTML in the converted `.astro` (via `set:html` / a backtick literal),\n * otherwise Astro escapes the markup and inline marks (custom spans, `<strong>`, `<a>`, \u2026)\n * ship as literal `<span>` text and their scoped CSS matches nothing. See the task\n * doc `docs/span-richtext-astro-task.md`.\n *\n * **Detection is content-based** (`isRichTextHtml`): a string carrying any tag `tiptapToHtml`\n * emits is rich text. This single heuristic covers both call-site prop values (emitAttr) and\n * direct content typed into a page/element (emitTextChild) \u2014 no parallel `name \u2192 propNames`\n * map is threaded from the converter. Bare rich-text *prop refs* (`{{text}}` where `text` is\n * declared `type:\"rich-text\"`) are recognized separately, by prop type, in `emitTextChild`.\n *\n * **`data-meno-span` round-trip.** A custom span carries an editor-only `data-meno-span`\n * marker \u2014 meno-core's `htmlToTiptap` (`parseSpan`) needs it to recognize a `textStyle`\n * mark. `tiptapToHtml` ALWAYS emits it equal to the class: `<span class=\"X\" data-meno-span=\"X\">`.\n * The codec strips it on emit (cleaner source) and deterministically re-adds it on parse,\n * keyed off the class. `strip`/`add` are mutual inverses on that canonical form, so\n * `parse(emit(model)) === normalizeModel(model)` stays exact; both are no-ops on strings\n * without meno spans, so applying them broadly is safe. meno-core's runtime is NOT touched.\n */\n\n/**\n * Inline + block tags emitted by `tiptapToHtml` (kept in sync with its `applyMark` /\n * `RICH_TEXT_ALLOWED_TAGS`). Their presence marks a string as rich-text HTML. Anchored with\n * `\\b` so prose like `5 < 10` or `<article` is not mistaken for a tag.\n */\nconst RICH_TEXT_TAG_RE =\n /<\\/?(?:strong|em|u|s|code|a|span|sub|sup|mark|b|i|p|br|ul|ol|li|blockquote|h[1-6]|pre|hr|small|figure|figcaption|table|thead|tbody|tr|th|td)\\b/i;\n\n/** True when a string contains rich-text markup (a tag `tiptapToHtml` can produce). */\nexport function isRichTextHtml(s: string): boolean {\n return RICH_TEXT_TAG_RE.test(s);\n}\n\n/** Strip the editor-only `data-meno-span=\"\u2026\"` attribute from every `<span>` opening tag. */\nexport function stripMenoSpanMarker(html: string): string {\n return html.replace(/<span\\b[^>]*>/gi, (tag) => tag.replace(/\\s+data-meno-span=\"[^\"]*\"/gi, ''));\n}\n\n/**\n * Re-add `data-meno-span` (= the span's class) to any classed `<span>` that lacks it \u2014 the\n * exact inverse of {@link stripMenoSpanMarker} on canonical `tiptapToHtml` output, where the\n * marker always equals the class and follows it. Idempotent (skips spans that already carry\n * it); a no-op on spans without a class or strings without spans.\n */\nexport function addMenoSpanMarker(html: string): string {\n return html.replace(/<span\\b[^>]*>/gi, (tag) => {\n if (/\\bdata-meno-span=/i.test(tag)) return tag;\n const m = tag.match(/\\bclass=\"([^\"]*)\"/i);\n if (!m) return tag;\n return tag.replace(/(\\bclass=\"[^\"]*\")/i, `$1 data-meno-span=\"${m[1]}\"`);\n });\n}\n", "/**\n * Node walker \u2014 turns a Meno node tree into meno-astro dialect markup.\n *\n * Model: every node renders into a self-contained block at *column 0*; a placer\n * (`placeChild`) then shifts that block to its target indent and, when the node has\n * an `if`, wraps it in `{cond && ( \u2026 )}`. This separates structure from placement so\n * indentation and conditionals stay simple and deterministic.\n *\n * Two render shapes:\n * - `element` \u2192 JSX markup (`<div \u2026>\u2026</div>`), placed as-is.\n * - `expr` \u2192 a JS expression (list `.map(\u2026)`, or an `if`-wrapped node), placed\n * inside `{ \u2026 }`.\n */\n\nimport { singularize } from 'meno-core/shared';\nimport { serializeLiteral } from './serialize';\nimport { type EmitContext, needRuntime, needRuntimeComponent } from './emitContext';\nimport { isRichTextHtml, stripMenoSpanMarker } from '../richtext';\n\ntype Node = Record<string, any>;\n\nexport type Rendered =\n | { kind: 'element'; markup: string }\n | { kind: 'expr'; expr: string };\n\nconst INDENT = 2;\n\nfunction pad(n: number): string {\n return ' '.repeat(n);\n}\n\n/** Shift every line of a column-0 block to start at `indent`. */\nfunction shift(block: string, indent: number): string {\n const p = pad(indent);\n return block\n .split('\\n')\n .map((line) => (line.length ? p + line : line))\n .join('\\n');\n}\n\n// ---------------------------------------------------------------------------\n// Templates: Meno uses `{{ expr }}`. Convert to a JS expression for `{ \u2026 }`.\n// ---------------------------------------------------------------------------\n\nconst TEMPLATE_RE = /\\{\\{([\\s\\S]*?)\\}\\}/g;\n\nexport function hasTemplate(s: string): boolean {\n return /\\{\\{[\\s\\S]*?\\}\\}/.test(s);\n}\n\n/** Escape literal text for inclusion inside a backtick template literal. */\nfunction escapeBacktick(s: string): string {\n return s.replace(/\\\\/g, '\\\\\\\\').replace(/`/g, '\\\\`').replace(/\\$\\{/g, '\\\\${');\n}\n\n/**\n * Convert a Meno template string to the JS expression that goes inside `{ \u2026 }`.\n * - `\"{{ expr }}\"` (whole string) \u2192 `expr`\n * - `\"Hi {{name}}!\"` \u2192 `` `Hi ${name}!` ``\n */\nexport function templateToExpr(s: string): string {\n const matches = [...s.matchAll(TEMPLATE_RE)];\n // Exactly one template spanning the entire string \u2192 bare expression.\n if (matches.length === 1 && matches[0].index === 0 && matches[0][0].length === s.length) {\n return matches[0][1].trim();\n }\n // Otherwise build a backtick template literal.\n let out = '';\n let last = 0;\n for (const m of matches) {\n out += escapeBacktick(s.slice(last, m.index!));\n out += '${' + m[1].trim() + '}';\n last = m.index! + m[0].length;\n }\n out += escapeBacktick(s.slice(last));\n return '`' + out + '`';\n}\n\n/**\n * Rewrite a list's loop references inside every `{{\u2026}}` template of a string to native JS\n * off the emitted `.map((item, itemIndex[, itemArr]) => \u2026)`. meno-core's runtime binds each\n * item under BOTH the generic names (`item`, `itemIndex`, `itemFirst`, `itemLast`) AND the\n * `itemAs` name variants (see `buildTemplateContext`); a model may reference either.\n *\n * Idiomatic Astro/JS (matching meno-core's own `nodeToAstro` exporter, `replaceItemMetaVars`):\n * - `item` / `itemIndex` \u2192 the loop var / its index param\n * - `itemFirst` / `<var>First` \u2192 `(<var>Index === 0)`\n * - `itemLast` / `<var>Last` \u2192 `(<var>Index === <var>Arr.length - 1)` \u2190 needs the\n * native 3rd `.map` arg (the array); `acc.needsArr` is flagged so renderList emits it.\n * No synthesized context object is ported \u2014 these are plain expressions. Word-boundary\n * anchored so `itemCount`/`lineitem` are untouched.\n */\nfunction rewriteItemRefs(str: string, itemVar: string, acc: { needsArr: boolean }): string {\n const idx = `${itemVar}Index`;\n const first = `(${idx} === 0)`;\n const last = `(${idx} === ${itemVar}Arr.length - 1)`;\n const namedLast = new RegExp(`\\\\b${itemVar}Last\\\\b`);\n // The native `.map` array arg is needed for `itemLast` (\u2192 `index === arr.length - 1`) AND\n // for any template that already references the array directly \u2014 which happens on a\n // re-emit: a prior emit turned `{{itemLast}}` into `(itemIndex === itemArr.length - 1)`,\n // parse keeps that native form, so the loop var is `\u2026Arr`, not `\u2026Last`. Detect both so the\n // arr param is re-declared and the re-emitted `.map` stays buildable (no `itemArr is not\n // defined`). Idempotent: emit(parse(emit(x))) === emit(parse(emit(parse(emit(x))))).\n const namedArr = new RegExp(`\\\\b${itemVar}Arr\\\\b`);\n return str.replace(TEMPLATE_RE, (_m, expr: string) => {\n let s = String(expr);\n if (/\\bitemLast\\b/.test(s) || namedLast.test(s) || /\\bitemArr\\b/.test(s) || namedArr.test(s)) {\n acc.needsArr = true;\n }\n // Named (`<var>First`/`<var>Last`) before generic, and before the bare `item` rename.\n if (itemVar !== 'item') {\n s = s\n .replace(new RegExp(`\\\\b${itemVar}First\\\\b`, 'g'), first)\n .replace(new RegExp(`\\\\b${itemVar}Last\\\\b`, 'g'), last);\n }\n s = s\n .replace(/\\bitemIndex\\b/g, idx)\n .replace(/\\bitemFirst\\b/g, first)\n .replace(/\\bitemLast\\b/g, last)\n .replace(/\\bitem\\b/g, itemVar);\n return `{{${s}}}`;\n });\n}\n\n/**\n * Deep-clone a list's item-template subtree, normalizing generic `item` refs to the loop\n * variable (see {@link rewriteItemRefs}). A nested `type: 'list'` opens a new item scope,\n * so its `children` are left for that inner list's own rewrite; its other fields (e.g. a\n * `source` like `{{item.subItems}}`) are evaluated in THIS scope and so are rewritten.\n */\nfunction rewriteItemRefsInTree<T>(node: T, itemVar: string, acc: { needsArr: boolean }): T {\n if (typeof node === 'string') return rewriteItemRefs(node, itemVar, acc) as unknown as T;\n if (Array.isArray(node)) return node.map((n) => rewriteItemRefsInTree(n, itemVar, acc)) as unknown as T;\n if (node && typeof node === 'object') {\n const obj = node as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n out[k] = k === 'children' && obj.type === 'list' ? v : rewriteItemRefsInTree(v, itemVar, acc);\n }\n return out as unknown as T;\n }\n return node;\n}\n\n/** Globals/keywords that look like identifiers but are never item bindings. */\nconst NON_BINDING_ROOTS = new Set([\n 'Astro', 'Math', 'JSON', 'Object', 'Array', 'Date', 'Number', 'String', 'Boolean',\n 'true', 'false', 'null', 'undefined', 'this',\n]);\n\n/**\n * Scan a component's structure for the root identifiers its `{{root.\u2026}}` / `{{root}}`\n * templates reference that are NOT declared props and NOT bound by an inner list's\n * loop var \u2014 i.e. CMS-item bindings like `post` that the component receives from its\n * parent list. The component declares these from `Astro.props` so its `post.title`\n * references resolve (the parent list passes them; see renderComponentInstance).\n */\nexport function collectItemBindings(root: unknown, declaredProps: Iterable<string>): string[] {\n const free = new Set<string>();\n const rootOf = (expr: string): string | undefined =>\n expr.trim().match(/^[A-Za-z_$][\\w$]*/)?.[0];\n\n const walk = (node: unknown, bound: Set<string>): void => {\n if (node == null) return;\n if (typeof node === 'string') {\n for (const m of node.matchAll(TEMPLATE_RE)) {\n const r = rootOf(m[1]);\n if (r && !bound.has(r) && !NON_BINDING_ROOTS.has(r)) free.add(r);\n }\n return;\n }\n if (Array.isArray(node)) {\n for (const n of node) walk(n, bound);\n return;\n }\n if (typeof node !== 'object') return;\n const obj = node as Record<string, unknown>;\n // A list node binds its own loop vars for its children only; its own fields\n // (source/filter) still reference the surrounding scope.\n let childBound = bound;\n if (obj.type === 'list') {\n const itemVar = (obj.itemAs as string) ?? (obj.sourceType === 'collection' ? singularize(obj.source as string) : 'item');\n // Bind the loop var + all loop metadata (generic and itemAs-named) so they are not\n // mistaken for parent-passed item bindings: they resolve to native `.map` expressions\n // inside the list (see rewriteItemRefs), never to `Astro.props`.\n childBound = new Set(bound)\n .add(itemVar).add(`${itemVar}Index`).add(`${itemVar}First`).add(`${itemVar}Last`).add(`${itemVar}Arr`)\n .add('item').add('itemIndex').add('itemFirst').add('itemLast');\n }\n for (const [k, v] of Object.entries(obj)) {\n walk(v, k === 'children' || k === 'default' ? childBound : bound);\n }\n };\n\n walk(root, new Set(declaredProps));\n return [...free];\n}\n\nfunction isI18nValue(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && (v as any)._i18n === true;\n}\n\n/** A verbatim-code marker: arbitrary JS the model preserves rather than coercing. */\nfunction isCodeMarker(v: unknown): v is { _code: true; expr: string } {\n return typeof v === 'object' && v !== null && (v as any)._code === true && typeof (v as any).expr === 'string';\n}\n\n/**\n * Source for a verbatim JS expression placed inside `{ \u2026 }`. Single-line goes inline;\n * multi-line is hoisted to a frontmatter `const __codeN = \u2026;` (column 0, never re-indented\n * by the placer) and referenced by name \u2014 mirroring the multi-line embed-HTML hoist.\n */\nfunction codeExpr(expr: string, ctx: EmitContext): string {\n if (expr.includes('\\n')) {\n const name = `__code${ctx.hoistCounter++}`;\n ctx.frontmatterConsts.push(`const ${name} = ${expr};`);\n return name;\n }\n return expr;\n}\n\n// ---------------------------------------------------------------------------\n// Attribute / prop emission\n// ---------------------------------------------------------------------------\n\n/**\n * Render one `name=\u2026` attribute. `dropEmptyTemplate` (set for HTML node attributes) emits the\n * meno-core parity guard for an entirely-`{{template}}` value (see below); component props /\n * locale-list props leave it false (they aren't node attributes \u2014 meno-core never skip-empties\n * them).\n */\nfunction emitAttr(name: string, value: unknown, ctx: EmitContext, dropEmptyTemplate = false): string {\n if (isCodeMarker(value)) {\n return `${name}={${codeExpr(value.expr, ctx)}}`;\n }\n if (isI18nValue(value)) {\n needRuntime(ctx, 'i18n');\n return `${name}={i18n(${serializeLiteral(value, { indent: INDENT, width: ctx.width })})}`;\n }\n if (typeof value === 'string') {\n // Rich-text HTML value (a custom span, <strong>, <a>, \u2026) \u2192 a backtick template literal\n // so the markup reads cleanly with no `\\\"` escaping (vs JSON.stringify). The editor-only\n // data-meno-span is stripped (re-added on parse); any nested {{template}} becomes ${\u2026}.\n if (isRichTextHtml(value)) return `${name}={${templateToExpr(stripMenoSpanMarker(value))}}`;\n if (hasTemplate(value)) {\n const expr = templateToExpr(value);\n // Parity with meno-core's skipEmptyTemplateAttributes: a NODE attribute that is entirely\n // a single `{{template}}` and resolves to \"\" must be DROPPED \u2014 Astro renders empty\n // strings (`fade=\"\"`), meno-core omits them. A `\u2026 || undefined` guard makes Astro omit\n // the attr when it resolves falsy. Only the bare whole-string template form (a backtick\n // literal always carries surrounding text, so it can never be the empty case). The parser\n // reverses the guard back to `{{\u2026}}` (interpretExprValue).\n if (dropEmptyTemplate && expr[0] !== '`' && /^\\{\\{.+\\}\\}$/.test(value)) {\n return `${name}={${expr} || undefined}`;\n }\n return `${name}={${expr}}`;\n }\n if (!value.includes('\"') && !value.includes('\\n')) return `${name}=\"${value}\"`;\n return `${name}={${JSON.stringify(value)}}`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return `${name}={${value}}`;\n }\n if (value === null || value === undefined) return `${name}={null}`;\n // objects/arrays (link values, arbitrary structured props). A `{{template}}` nested\n // inside (e.g. `link={{ href: \"{{link.href}}\" }}`) must be resolved to an expression \u2014\n // the child component can't resolve a parent-scope template. Only switch to the\n // template-aware serializer when one is actually present, so template-free literals\n // keep their existing formatting + round-trip exactly.\n if (deepHasTemplate(value)) return `${name}={${serializeExprLiteral(value)}}`;\n return `${name}={${serializeLiteral(value, { indent: INDENT, width: ctx.width })}}`;\n}\n\n/** True when a value deep-contains a `{{\u2026}}` template string. */\nfunction deepHasTemplate(value: unknown): boolean {\n if (typeof value === 'string') return hasTemplate(value);\n if (Array.isArray(value)) return value.some(deepHasTemplate);\n if (value && typeof value === 'object') return Object.values(value).some(deepHasTemplate);\n return false;\n}\n\n/** A JS identifier that needs no quoting as an object key. */\nfunction isBareIdent(key: string): boolean {\n return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);\n}\n\n/**\n * Serialize a value to a JS expression literal, turning every nested `{{template}}` string\n * into the expression it denotes (`\"{{link.href}}\"` \u2192 `link.href`, `\"/p/{{slug}}\"` \u2192\n * `` `/p/${slug}` ``). The inverse is `parseLiteral`, which reads bare expressions /\n * backtick literals back into `{{\u2026}}` templates \u2014 so structured props round-trip.\n */\nfunction serializeExprLiteral(value: unknown): string {\n if (typeof value === 'string') return hasTemplate(value) ? templateToExpr(value) : JSON.stringify(value);\n if (value === null || value === undefined) return 'null';\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n if (Array.isArray(value)) return `[${value.map(serializeExprLiteral).join(', ')}]`;\n if (typeof value === 'object') {\n const entries = Object.entries(value as Record<string, unknown>).map(\n ([k, v]) => `${isBareIdent(k) ? k : JSON.stringify(k)}: ${serializeExprLiteral(v)}`,\n );\n return entries.length ? `{ ${entries.join(', ')} }` : '{}';\n }\n return 'null';\n}\n\n/**\n * Build the `class={style(styleLit[, metaLit])}` attribute for a node, or null when\n * the node carries no style/interactive/label metadata.\n */\nfunction emitClassAttr(node: Node, ctx: EmitContext, extraMeta?: Record<string, unknown>): string | null {\n const meta: Record<string, unknown> = { ...extraMeta };\n if (node.interactiveStyles !== undefined) meta.interactive = node.interactiveStyles;\n if (node.label !== undefined) meta.label = node.label;\n if (node.generateElementClass !== undefined) meta.genClass = node.generateElementClass;\n\n const hasStyle = hasStyleContent(node.style);\n const hasMeta = Object.keys(meta).length > 0;\n if (!hasStyle && !hasMeta) return null;\n\n needRuntime(ctx, 'style');\n const styleLit = serializeLiteral(node.style ?? {}, { indent: INDENT, width: ctx.width });\n // Pass the resolved props object so prop-`_mapping`s resolve (in a component it's\n // `__props`; a page has none). The parser skips the props arg and reads meta from the\n // object-literal arg, so both `style(obj, props, meta)` and `style(obj)` round-trip.\n const propsArg = ctx.propsVar;\n if (!hasMeta) return propsArg ? `class={style(${styleLit}, ${propsArg})}` : `class={style(${styleLit})}`;\n const metaLit = serializeLiteral(meta, { indent: INDENT, width: ctx.width });\n return `class={style(${styleLit}, ${propsArg ?? 'undefined'}, ${metaLit})}`;\n}\n\n/** CSS property name (kebab-case) for a model style key. Idempotent for already-kebab keys. */\nfunction cssPropName(key: string): string {\n return key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n}\n\n/**\n * A style value that is a `{{template}}` string (e.g. `gap: \"{{gap}}px\"`) can't become a\n * static utility class \u2014 its value is per-instance \u2014 so `style()` and the build-time CSS\n * generator skip it. Mirroring meno-core's JSON\u2192Astro export, those props are emitted as\n * an inline `style={`\u2026`}` attribute instead, with each `{{expr}}` resolved against the\n * render scope (host prop / loop var). Returns the flat (or `base`-breakpoint) templated\n * props as `[cssProp, rawValue]`; templated values in `tablet`/`mobile` can't be expressed\n * inline (no media queries) and degrade \u2014 the static cascade still applies.\n */\nfunction templatedStyleProps(style: unknown): Array<[string, string]> {\n if (!style || typeof style !== 'object') return [];\n const s = style as Record<string, unknown>;\n const isResponsive = 'base' in s || 'tablet' in s || 'mobile' in s;\n const flat = isResponsive ? s.base : s;\n if (!flat || typeof flat !== 'object') return [];\n const out: Array<[string, string]> = [];\n for (const [k, v] of Object.entries(flat as Record<string, unknown>)) {\n if (typeof v === 'string' && v.includes('{{')) out.push([cssPropName(k), v]);\n }\n return out;\n}\n\n/** Build an inline `style={`\u2026`}` attr for a node's templated style values, or null. */\nfunction emitInlineStyleAttr(node: Node): string | null {\n const props = templatedStyleProps(node.style);\n if (props.length === 0) return null;\n const decls = props.map(([cssProp, val]) => {\n // `{{expr}}` \u2192 `${expr}` inside a template literal; surrounding text stays literal.\n const resolved = val.replace(TEMPLATE_RE, (_m, e) => '${' + String(e).trim() + '}');\n return `${cssProp}: ${resolved}`;\n });\n return `style={\\`${decls.join('; ')}\\`}`;\n}\n\n/** Whether a style value has any non-empty content worth emitting. */\nfunction hasStyleContent(style: unknown): boolean {\n if (!style || typeof style !== 'object') return false;\n for (const v of Object.values(style as Record<string, unknown>)) {\n if (v === undefined || v === null) continue;\n if (typeof v === 'object') {\n if (Object.keys(v as object).length > 0) return true;\n } else {\n return true;\n }\n }\n return false;\n}\n\n/** HTML `attributes` map \u2192 attribute strings. */\nfunction emitAttributes(node: Node, ctx: EmitContext): string[] {\n if (!node.attributes || typeof node.attributes !== 'object') return [];\n // HTML node attributes: drop entirely-template attrs that resolve to \"\" (meno-core parity).\n return Object.entries(node.attributes).map(([k, v]) => emitAttr(k, v, ctx, true));\n}\n\n// ---------------------------------------------------------------------------\n// Children\n// ---------------------------------------------------------------------------\n\nconst VOID_ELEMENTS = new Set([\n 'img', 'br', 'hr', 'input', 'meta', 'link', 'area', 'base', 'col',\n 'embed', 'param', 'source', 'track', 'wbr',\n]);\n\n/** locale-list keys emitted explicitly (so the passthrough loop skips them). */\nconst LOCALE_KNOWN_KEYS = new Set([\n 'type', 'if', 'showCurrent', 'showSeparator', 'showFlag', 'displayType',\n 'style', 'itemStyle', 'activeItemStyle', 'separatorStyle', 'flagStyle',\n 'interactiveStyles', 'label', 'generateElementClass',\n]);\n\n/** If `s` is exactly one `{{ identifier }}` template, return the identifier; else null. */\nfunction bareTemplateIdent(s: string): string | null {\n const m = s.match(/^\\{\\{\\s*([A-Za-z_$][\\w$]*)\\s*\\}\\}$/);\n return m ? m[1] : null;\n}\n\n/**\n * Render a string child (text node) at column 0.\n *\n * Rich text renders as REAL HTML through `<Fragment set:html={\u2026} />` \u2014 a plain `{text}`\n * HTML-escapes the value, so a custom span / `<strong>` / `<a>` would ship as literal\n * `<\u2026>` and its scoped CSS would match nothing. Two cases:\n * - a bare ref to a `type:\"rich-text\"` prop (`{{text}}`) \u2014 recognized by prop type;\n * - direct rich-text markup typed straight into the body \u2014 recognized by content.\n * (See `../richtext`.) Otherwise: a `{{\u2026}}` template \u2192 `{expr}`; plain text stays pretty\n * raw when it is a sole, trimmed, markup-free child, else a `{\"\u2026\"}` expression so adjacent\n * text nodes stay distinct on parse (`forceExpr`). Every form parses back to the same node.\n */\nfunction emitTextChild(text: string, ctx: EmitContext, forceExpr = false): string {\n const ident = bareTemplateIdent(text);\n if (ident && ctx.richTextProps?.has(ident)) return `<Fragment set:html={${ident}} />`;\n // Direct rich-text content (checked before the generic template branch so HTML carrying a\n // {{template}} still renders as markup): strip the editor-only marker, turn {{\u2026}} into ${\u2026}.\n if (isRichTextHtml(text)) return `<Fragment set:html={${templateToExpr(stripMenoSpanMarker(text))}} />`;\n if (hasTemplate(text)) return `{${templateToExpr(text)}}`;\n const safeRaw = !forceExpr && text.length > 0 && text === text.trim() && !/[{}<>]/.test(text);\n return safeRaw ? text : `{${JSON.stringify(text)}}`;\n}\n\n/** Render a children value (string | array) to an array of column-0 child blocks. */\nfunction emitChildrenList(children: unknown, ctx: EmitContext): string[] {\n if (children === undefined || children === null) return [];\n if (typeof children === 'string') {\n return children.length ? [emitTextChild(children, ctx)] : [];\n }\n if (!Array.isArray(children)) return [];\n const multi = children.length > 1;\n return children.map((child) =>\n typeof child === 'string'\n ? emitTextChild(child, ctx, multi)\n : placeChild(renderNode(child as Node, ctx), 0),\n );\n}\n\n/**\n * Compose an element: `<tag attrs>children</tag>` (or self-closing). Returns markup\n * at column 0. Inlines a single one-line child for compactness.\n */\nfunction composeElement(tag: string, attrs: string[], childBlocks: string[], forceVoid = false): string {\n const attrStr = attrs.length ? ' ' + attrs.join(' ') : '';\n if (forceVoid || childBlocks.length === 0) {\n return `<${tag}${attrStr} />`;\n }\n if (childBlocks.length === 1 && !childBlocks[0].includes('\\n')) {\n return `<${tag}${attrStr}>${childBlocks[0]}</${tag}>`;\n }\n const inner = childBlocks.map((c) => shift(c, INDENT)).join('\\n');\n return `<${tag}${attrStr}>\\n${inner}\\n</${tag}>`;\n}\n\n// ---------------------------------------------------------------------------\n// Per-node renderers (build at column 0)\n// ---------------------------------------------------------------------------\n\nfunction renderHtml(node: Node, ctx: EmitContext): Rendered {\n let tag = node.tag as string;\n // Dynamic tag (e.g. \"h{{size}}\") \u2192 a frontmatter const referenced as <Tag_N>.\n if (typeof tag === 'string' && hasTemplate(tag)) {\n const varName = `Tag_${ctx.tagCounter++}`;\n ctx.frontmatterConsts.push(`const ${varName} = ${tagToTemplateLiteral(tag)};`);\n tag = varName;\n }\n const attrs = [emitClassAttr(node, ctx), emitInlineStyleAttr(node), ...emitAttributes(node, ctx)].filter(Boolean) as string[];\n const isVoid = VOID_ELEMENTS.has(String(node.tag).toLowerCase());\n const childBlocks = isVoid ? [] : emitChildrenList(node.children, ctx);\n return { kind: 'element', markup: composeElement(tag, attrs, childBlocks, isVoid) };\n}\n\n/** A tag string with `{{\u2026}}` \u2192 an Astro template-literal const value, e.g. `` `h${size}` ``. */\nfunction tagToTemplateLiteral(tag: string): string {\n const body = tag.replace(TEMPLATE_RE, (_m, e) => '${' + String(e).trim() + '}');\n return '`' + body + '`';\n}\n\nfunction renderComponentInstance(node: Node, ctx: EmitContext): Rendered {\n const tag = astroComponentName(node.component);\n ctx.components.add(node.component);\n const attrs: string[] = [];\n const explicitProps = node.props && typeof node.props === 'object' ? (node.props as Record<string, unknown>) : {};\n for (const [k, v] of Object.entries(explicitProps)) attrs.push(emitAttr(k, v, ctx));\n // A PROP-LESS component instance inside a list is an item-bound card (e.g. a\n // BlogListCard whose own body renders `{{post.title}}`): forward the active list\n // loop variables so it receives the item, which it declares from `Astro.props`\n // (see emitComponent). A component that already takes explicit props gets its data\n // that way and needs nothing extra.\n if (Object.keys(explicitProps).length === 0) {\n for (const v of ctx.loopVars) attrs.push(`${v}={${v}}`);\n }\n // In a CMS scope the `cms` item flows to every descendant (meno-core propagates it\n // implicitly). Astro components are isolated, so forward `cms={cms}` to each instance \u2014\n // regardless of its other props, since a component can use `{{cms.X}}` internally while\n // also taking explicit props (e.g. `<BlogPostBody />` reading `cms.featuredImage`). Skip\n // when the instance already passes an explicit `cms`; a component that ignores it is\n // unharmed (resolveProps drops undeclared props).\n if (ctx.cmsInScope && !('cms' in explicitProps)) attrs.push('cms={cms}');\n const cls = emitClassAttr(node, ctx, hasStyleContent(node.style) ? { instance: true } : undefined);\n if (cls) attrs.push(cls);\n const inlineStyle = emitInlineStyleAttr(node);\n if (inlineStyle) attrs.push(inlineStyle);\n const childBlocks = emitChildrenList(node.children, ctx);\n return { kind: 'element', markup: composeElement(tag, attrs, childBlocks) };\n}\n\nfunction renderSlot(node: Node, ctx: EmitContext): Rendered {\n const def = node.default;\n if (def === undefined) return { kind: 'element', markup: '<slot />' };\n const childBlocks = emitChildrenList(def, ctx);\n return { kind: 'element', markup: composeElement('slot', [], childBlocks) };\n}\n\nfunction renderLink(node: Node, ctx: EmitContext): Rendered {\n needRuntimeComponent(ctx, 'Link');\n const attrs: string[] = [emitHref(node.href, ctx)];\n const cls = emitClassAttr(node, ctx);\n if (cls) attrs.push(cls);\n const inlineStyle = emitInlineStyleAttr(node);\n if (inlineStyle) attrs.push(inlineStyle);\n attrs.push(...emitAttributes(node, ctx));\n const childBlocks = emitChildrenList(node.children, ctx);\n return { kind: 'element', markup: composeElement('Link', attrs.filter(Boolean), childBlocks) };\n}\n\nfunction emitHref(href: unknown, ctx: EmitContext): string {\n if (typeof href === 'string') {\n if (hasTemplate(href)) return `href={${templateToExpr(href)}}`;\n return `href=\"${href}\"`;\n }\n // LinkMapping / i18n \u2192 carry the literal through a runtime resolver.\n if (isI18nValue(href)) {\n needRuntime(ctx, 'i18n');\n return `href={i18n(${serializeLiteral(href, { indent: INDENT, width: ctx.width })})}`;\n }\n needRuntime(ctx, 'href');\n // Thread the host component's resolved props (like style()) so a prop-bound LinkMapping\n // resolves at render. Pages have no props scope \u2192 1-arg form (mapping degrades to \"#\").\n const hrefLit = serializeLiteral(href, { indent: INDENT, width: ctx.width });\n return ctx.propsVar ? `href={href(${hrefLit}, ${ctx.propsVar})}` : `href={href(${hrefLit})}`;\n}\n\nfunction renderEmbed(node: Node, ctx: EmitContext): Rendered {\n needRuntimeComponent(ctx, 'Embed');\n const attrs: string[] = [];\n if (typeof node.html === 'string') {\n // A `{{template}}` in the HTML (e.g. `{{item.icon}}`) resolves to a native expression\n // (templateToExpr) just like any other attribute \u2014 otherwise the literal `{{\u2026}}` ships\n // to the browser. Verbatim HTML (no template) stays a backtick string literal.\n const expr = hasTemplate(node.html) ? templateToExpr(node.html) : `\\`${escapeBacktick(node.html)}\\``;\n if (node.html.includes('\\n')) {\n // Multi-line HTML must not be re-indented by the placer \u2014 hoist it to a frontmatter\n // const (column 0, never shifted) and reference it by name.\n const name = `__embed${ctx.hoistCounter++}`;\n ctx.frontmatterConsts.push(`const ${name} = ${expr};`);\n attrs.push(`html={${name}}`);\n } else {\n attrs.push(`html={${expr}}`);\n }\n } else {\n needRuntime(ctx, 'embedHtml');\n // Thread props (like style()/href()) so a prop-bound HtmlMapping resolves at render.\n const htmlLit = serializeLiteral(node.html, { indent: INDENT, width: ctx.width });\n attrs.push(\n ctx.propsVar ? `html={embedHtml(${htmlLit}, ${ctx.propsVar})}` : `html={embedHtml(${htmlLit})}`,\n );\n }\n const cls = emitClassAttr(node, ctx);\n if (cls) attrs.push(cls);\n const inlineStyle = emitInlineStyleAttr(node);\n if (inlineStyle) attrs.push(inlineStyle);\n attrs.push(...emitAttributes(node, ctx));\n return { kind: 'element', markup: composeElement('Embed', attrs, [], true) };\n}\n\nfunction renderLocaleList(node: Node, ctx: EmitContext): Rendered {\n needRuntimeComponent(ctx, 'LocaleList');\n const attrs: string[] = [];\n const boolProps = ['showCurrent', 'showSeparator', 'showFlag'] as const;\n for (const p of boolProps) if (node[p] !== undefined) attrs.push(emitAttr(p, node[p], ctx));\n if (node.displayType !== undefined) attrs.push(emitAttr('displayType', node.displayType, ctx));\n const styleProps = ['style', 'itemStyle', 'activeItemStyle', 'separatorStyle', 'flagStyle'] as const;\n for (const sp of styleProps) {\n if (hasStyleContent(node[sp])) {\n needRuntime(ctx, 'style');\n attrs.push(`${sp}={style(${serializeLiteral(node[sp], { indent: INDENT, width: ctx.width })})}`);\n }\n }\n if (node.interactiveStyles !== undefined || node.label !== undefined || node.generateElementClass !== undefined) {\n const meta: Record<string, unknown> = {};\n if (node.interactiveStyles !== undefined) meta.interactive = node.interactiveStyles;\n if (node.label !== undefined) meta.label = node.label;\n if (node.generateElementClass !== undefined) meta.genClass = node.generateElementClass;\n attrs.push(`meta={${serializeLiteral(meta, { indent: INDENT, width: ctx.width })}}`);\n }\n // Preserve any passthrough scalar props (e.g. a legacy `separator` text).\n for (const [k, v] of Object.entries(node)) {\n if (LOCALE_KNOWN_KEYS.has(k)) continue;\n if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') {\n attrs.push(emitAttr(k, v, ctx));\n }\n }\n return { kind: 'element', markup: composeElement('LocaleList', attrs, [], true) };\n}\n\nfunction renderList(node: Node, ctx: EmitContext): Rendered {\n const sourceType = node.sourceType ?? 'prop';\n // Compute the loop-item var BEFORE emitting children, and make it visible on the\n // loopVars stack while they emit \u2014 so a component instance used as the item\n // template receives the item as a prop (e.g. `<BlogListCard post={post} />`).\n const itemVar = node.itemAs ?? (sourceType === 'collection' ? singularize(node.source) : 'item');\n const indexVar = `${itemVar}Index`;\n\n // Resolve every loop reference in the item template to native JS off the `.map` args:\n // a `{{item.text}}` that should be `{{link.text}}` (mixed item/itemAs names), and the\n // metadata `{{itemFirst}}`/`{{itemLast}}` \u2192 `(index === 0)` / `(index === arr.length-1)`.\n // `needsArr` tells us whether `itemLast` was used, so the native 3rd `.map` arg (the\n // array) is only emitted when needed.\n const acc = { needsArr: false };\n const itemChildren = rewriteItemRefsInTree(node.children, itemVar, acc);\n const params = acc.needsArr ? `${itemVar}, ${indexVar}, ${itemVar}Arr` : `${itemVar}, ${indexVar}`;\n\n ctx.loopVars.push(itemVar);\n const childBlocks = emitChildrenList(itemChildren, ctx);\n ctx.loopVars.pop();\n const childRenderedAt2 = childBlocks.map((c) => shift(c, INDENT)).join('\\n');\n\n if (sourceType === 'collection') {\n needRuntime(ctx, 'getCollectionList');\n ctx.needsContentApi = true; // page/component must import + pass getCollection\n const query = listQueryLiteral(node, ctx, ['filter', 'sort', 'limit', 'offset', 'items', 'excludeCurrentItem', 'emitTemplate']);\n const binding = uniqueBinding(ctx, `${sanitizeIdent(node.source)}List`);\n ctx.frontmatterConsts.push(\n `const ${binding} = await getCollectionList(${JSON.stringify(node.source)}${query ? ', ' + query : ''}, Astro, getCollection);`,\n );\n const expr = `${binding}.map((${params}) => (\\n${childRenderedAt2}\\n))`;\n return { kind: 'expr', expr };\n }\n\n // prop list\n needRuntime(ctx, 'list');\n const sourceExpr =\n typeof node.source === 'string' && hasTemplate(node.source)\n ? templateToExpr(node.source)\n : sanitizeIdent(String(node.source));\n const opts = listQueryLiteral(node, ctx, ['limit', 'offset']);\n const listCall = opts ? `list(${sourceExpr}, ${opts})` : `list(${sourceExpr})`;\n const expr = `${listCall}.map((${params}) => (\\n${childRenderedAt2}\\n))`;\n return { kind: 'expr', expr };\n}\n\n/** Build a `{ \u2026 }` literal from selected list fields, or '' when none are set. */\nfunction listQueryLiteral(node: Node, ctx: EmitContext, keys: string[]): string {\n const obj: Record<string, unknown> = {};\n for (const k of keys) if (node[k] !== undefined) obj[k] = node[k];\n if (Object.keys(obj).length === 0) return '';\n return serializeLiteral(obj, { indent: INDENT, width: ctx.width });\n}\n\nfunction uniqueBinding(ctx: EmitContext, base: string): string {\n const existing = ctx.frontmatterConsts.some((l) => l.startsWith(`const ${base} `));\n if (!existing) return base;\n return `${base}_${ctx.listCounter++}`;\n}\n\nfunction sanitizeIdent(s: string): string {\n return /^[A-Za-z_$][\\w$]*$/.test(s) ? s : s.replace(/[^A-Za-z0-9_$]/g, '_');\n}\n\n/** Astro component tag: components must be Capitalized identifiers. */\nexport function astroComponentName(name: string): string {\n const cleaned = name.replace(/[^A-Za-z0-9_$]/g, '');\n return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);\n}\n\n// ---------------------------------------------------------------------------\n// Dispatch + placement\n// ---------------------------------------------------------------------------\n\nexport function renderNode(node: Node, ctx: EmitContext): Rendered {\n // Verbatim-code marker \u2192 emit its JS expression inside `{ \u2026 }` (a marker never carries\n // structure or an `if`, so it bypasses the type switch and `applyIf`).\n if (isCodeMarker(node)) {\n return { kind: 'expr', expr: codeExpr(node.expr, ctx) };\n }\n let rendered: Rendered;\n switch (node.type) {\n case 'node': rendered = renderHtml(node, ctx); break;\n case 'component': rendered = renderComponentInstance(node, ctx); break;\n case 'slot': rendered = renderSlot(node, ctx); break;\n case 'link': rendered = renderLink(node, ctx); break;\n case 'embed': rendered = renderEmbed(node, ctx); break;\n case 'locale-list': rendered = renderLocaleList(node, ctx); break;\n case 'list': rendered = renderList(node, ctx); break;\n default:\n // Unknown node type \u2192 preserve as a comment so nothing is silently dropped.\n rendered = { kind: 'element', markup: `{/* meno:unknown ${JSON.stringify(node.type)} */}` };\n }\n return applyIf(node, rendered, ctx);\n}\n\n/** Wrap a rendered node in `cond && ( \u2026 )` when it has an `if` that is not literally `true`. */\nfunction applyIf(node: Node, rendered: Rendered, ctx: EmitContext): Rendered {\n if (node.if === undefined || node.if === true) return rendered;\n const cond = ifConditionExpr(node.if, ctx);\n if (rendered.kind === 'element') {\n return { kind: 'expr', expr: `${cond} && (\\n${shift(rendered.markup, INDENT)}\\n)` };\n }\n return { kind: 'expr', expr: `${cond} && (${rendered.expr})` };\n}\n\nfunction ifConditionExpr(cond: unknown, ctx: EmitContext): string {\n if (cond === false) return 'false';\n if (cond === true) return 'true';\n // Verbatim-code condition \u2192 its JS inline (`reverseCondition` reads it back; conditions\n // are single-line in practice, so they are not hoisted).\n if (isCodeMarker(cond)) return cond.expr;\n if (typeof cond === 'string') return hasTemplate(cond) ? templateToExpr(cond) : cond;\n // BooleanMapping `{ _mapping, prop, values }` \u2192 carry literal through `when()`, threading\n // the host props (like style()/href()) so it resolves; pages use the 1-arg form.\n needRuntime(ctx, 'when');\n const condLit = serializeLiteral(cond);\n return ctx.propsVar ? `when(${condLit}, ${ctx.propsVar})` : `when(${condLit})`;\n}\n\n/** Shift a rendered node to `indent`, wrapping `expr` nodes in `{ \u2026 }`. */\nexport function placeChild(rendered: Rendered, indent: number): string {\n if (rendered.kind === 'element') return shift(rendered.markup, indent);\n return shift(`{${rendered.expr}}`, indent);\n}\n\n/** Public entry: render a node (and any `if`) to placed markup at `indent`. */\nexport function emitNode(node: Node | string, ctx: EmitContext, indent: number): string {\n if (typeof node === 'string') return shift(emitTextChild(node, ctx), indent);\n return placeChild(renderNode(node, ctx), indent);\n}\n", "/**\n * Frontmatter helpers shared by the page + component assemblers: deterministic\n * import lines and the `resolveProps(Astro, {\u2026})` prop block.\n */\n\nimport type { EmitContext } from './emitContext';\nimport { astroComponentName } from './emitNode';\nimport { serializeLiteral } from './serialize';\n\nexport interface ImportOptions {\n /** Type-only symbols from `meno-astro` (e.g. MenoComponentMeta, MenoPageMeta). */\n typeImports?: string[];\n /** Relative path prefix for local component imports (e.g. './' or '../components/'). */\n componentPrefix: string;\n /**\n * Optional override producing the full relative import path for a referenced\n * component by name (used when components live in category subfolders so imports\n * resolve to `\u2026/section/Error404.astro` instead of a flat `\u2026/Error404.astro`).\n * When absent, falls back to `${componentPrefix}${name}.astro`.\n */\n componentImportPath?: (name: string) => string;\n}\n\n/** Build deterministic, alphabetized import lines from the emit context. */\nexport function buildImportLines(ctx: EmitContext, opts: ImportOptions): string[] {\n const lines: string[] = [];\n const types = [...new Set(opts.typeImports ?? [])].sort();\n if (types.length) lines.push(`import type { ${types.join(', ')} } from 'meno-astro';`);\n if (ctx.runtime.size) {\n lines.push(`import { ${[...ctx.runtime].sort().join(', ')} } from 'meno-astro';`);\n }\n if (ctx.runtimeComponents.size) {\n lines.push(`import { ${[...ctx.runtimeComponents].sort().join(', ')} } from 'meno-astro/components';`);\n }\n for (const name of [...ctx.components].sort()) {\n const path = opts.componentImportPath ? opts.componentImportPath(name) : `${opts.componentPrefix}${name}.astro`;\n lines.push(`import ${astroComponentName(name)} from '${path}';`);\n }\n return lines;\n}\n\n// ---------------------------------------------------------------------------\n// resolveProps(Astro, {\u2026}) \u2014 the single authoritative prop block.\n//\n// The `{\u2026}` literal is the authoritative prop definition (`serializeLiteral` of\n// `def.interface`); the parser reads it back. The destructured names are emit-only\n// (the prop names, minus `children`, plus `class: className`); the parser ignores\n// them. TS types of the locals are inferred from the literal by `resolveProps`.\n// ---------------------------------------------------------------------------\n\nconst WIDTH = 80;\nconst CALL_PREFIX = 'resolveProps(Astro, ';\n\ntype PropDef = Record<string, any>;\n\n/**\n * Build the `const { \u2026names\u2026, class: className } = resolveProps(Astro, {\u2026});`\n * block. Always binds `class: className` so instances can carry wrapper styles, and\n * always emits the call (even for an empty interface: `resolveProps(Astro, {})`).\n */\nexport function buildPropsBlock(propInterface: Record<string, PropDef> | undefined): string[] {\n const def = propInterface ?? {};\n const names: string[] = [];\n for (const name of Object.keys(def)) {\n if (name === 'children') continue;\n names.push(name);\n }\n names.push('class: className');\n\n // Two statements:\n // const __props = resolveProps(Astro, {\u2026}); \u2190 the authoritative prop definition\n // const { x, y, class: className } = __props; \u2190 the destructured locals\n // `__props` (the resolved object) is what style()/href()/embedHtml() receive so that\n // prop-`_mapping`s resolve; the destructure feeds the template's `{x}` references.\n const head = `const __props = ${CALL_PREFIX}`;\n // Serialize the prop literal at its true start column; reserve 2 cols for `);`.\n const literal = serializeLiteral(def, { indent: 0, startCol: head.length + 2, width: WIDTH });\n const assign = `${head}${literal});`;\n\n const destrHead = `const { ${names.join(', ')} } = __props;`;\n const destructure =\n destrHead.length <= WIDTH\n ? destrHead\n : ['const {', ...names.map((n) => ` ${n},`), '} = __props;'].join('\\n');\n\n return [assign, destructure];\n}\n", "/**\n * CMS template-page route helpers \u2014 the single source of truth for \"is this page a\n * CMS template?\" and \"where on disk does it live?\". Shared by the emitter\n * (`emitPage`), the page/CMS providers, and the project converter so they all agree\n * on the `src/pages/<collection>/[slug].astro` layout.\n *\n * A CMS template page is a normal page model whose `meta.source === 'cms'` and which\n * carries a `meta.cms` schema. Its body renders the *current* item via `{{cms.field}}`\n * templates; on disk it becomes an Astro dynamic route with `getStaticPaths()`.\n */\n\n/** The dynamic route filename \u2014 Astro maps `[slug].astro` to a `slug` param. */\nexport const CMS_ROUTE_FILE = '[slug].astro';\n\n/** Minimal shape of the `meta.cms` schema this module reads. */\nexport interface CmsMetaLike {\n id?: string;\n slugField?: string;\n urlPattern?: string;\n}\n\n/** A page-model-ish value with the meta we care about. */\ninterface PageLike {\n meta?: { source?: unknown; cms?: CmsMetaLike } | Record<string, unknown>;\n}\n\n/** True when `page` is a CMS template page (`meta.source === 'cms'` + a `meta.cms` schema). */\nexport function isCmsTemplatePage(page: unknown): page is { meta: { source: 'cms'; cms: CmsMetaLike } } {\n if (!page || typeof page !== 'object') return false;\n const meta = (page as PageLike).meta as Record<string, unknown> | undefined;\n return !!meta && meta.source === 'cms' && !!meta.cms && typeof meta.cms === 'object';\n}\n\n/**\n * Derive the route *directory* (relative to `src/pages`) from a CMS `urlPattern`.\n *\n * \"/blog/{{slug}}\" -> \"blog\"\n * \"/case-studies/{{slug}}\" -> \"case-studies\"\n * \"/docs/guides/{{slug}}\" -> \"docs/guides\" (multi-segment: kept verbatim)\n * \"/{{slug}}\" / \"\" / \u2026 -> \"\" (degrade: file lands at pages root)\n *\n * Mirrors the one-way exporter's `extractPathPrefix` (cmsPageEmitter.ts): everything\n * before the FIRST `{{\u2026}}` placeholder is the static prefix. Locale-prefixed patterns\n * like \"/{{locale}}/blog/{{slug}}\" therefore degrade to \"\" (their first placeholder is\n * the locale) \u2014 those aren't specially handled here (the dialect is single-locale).\n */\nexport function cmsRouteDirFromUrlPattern(urlPattern: string | undefined): string {\n if (!urlPattern) return '';\n const withoutLeading = urlPattern.replace(/^\\/+/, '');\n const idx = withoutLeading.indexOf('{{');\n const prefix = idx < 0 ? withoutLeading : withoutLeading.slice(0, idx);\n // Strip a trailing slash and any stray surrounding slashes.\n return prefix.replace(/^\\/+|\\/+$/g, '');\n}\n\n/**\n * The `.astro` file path (relative to `src/pages`, POSIX separators) for a CMS\n * template page. `\"/blog/{{slug}}\"` \u2192 `\"blog/[slug].astro\"`; a pattern with no static\n * prefix \u2192 just `\"[slug].astro\"`.\n */\nexport function cmsRouteRelPath(urlPattern: string | undefined): string {\n const dir = cmsRouteDirFromUrlPattern(urlPattern);\n return dir ? `${dir}/${CMS_ROUTE_FILE}` : CMS_ROUTE_FILE;\n}\n\n/**\n * The `getStaticPaths()` + `const { cms } = Astro.props;` frontmatter boilerplate for a\n * CMS template page. Deterministic, derived solely from the collection id + slug field\n * (mirrors `core`'s `cmsPageEmitter.buildGetStaticPaths`, single-locale form). This is\n * emit-only: the parser recognizes and SKIPS it, regenerating it from `meta.cms`.\n */\nexport function buildGetStaticPaths(cms: CmsMetaLike): string {\n const collectionId = cms.id ?? '';\n const slugField = cms.slugField || 'slug';\n return [\n `export async function getStaticPaths() {`,\n ` const entries = await getCollection(${JSON.stringify(collectionId)});`,\n ` return entries.map((entry) => ({`,\n ` params: { slug: entry.data.${slugField} ?? entry.id },`,\n ` props: { cms: entry.data },`,\n ` }));`,\n `}`,\n ``,\n `const { cms } = Astro.props;`,\n ].join('\\n');\n}\n", "/**\n * Page assembler \u2014 a `JSONPage` \u2192 a full `.astro` page file.\n *\n * The page `meta` becomes `export const meta = {\u2026} satisfies MenoPageMeta` and the\n * node tree is wrapped in `<BaseLayout meta={meta}>`.\n *\n * **CMS template pages** (`meta.source === 'cms'` + a `meta.cms` schema) emit as an\n * idiomatic Astro dynamic route: an extra `getCollection` import plus a deterministic\n * `getStaticPaths()` + `const { cms } = Astro.props;` block (derived from `meta.cms`)\n * sit ahead of `export const meta`. That block is emit-only boilerplate \u2014 the parser\n * recognizes and SKIPS it (like `interface Props`/`resolveProps` for components), so\n * the model round-trips unchanged. The body is identical to a regular page.\n */\n\nimport type { JSONPage } from 'meno-core/shared/types';\nimport { createEmitContext, needRuntimeComponent, type EmitOptions } from './emitContext';\nimport { emitNode } from './emitNode';\nimport { serializeLiteral } from './serialize';\nimport { buildImportLines } from './frontmatter';\nimport { importedLibraryUrls } from '../libraryImports';\nimport { isCmsTemplatePage, buildGetStaticPaths, cmsRouteDirFromUrlPattern, type CmsMetaLike } from '../cmsRoute';\n\nexport function emitPage(page: JSONPage, opts?: EmitOptions): string {\n const ctx = createEmitContext();\n const isCms = isCmsTemplatePage(page);\n // A CMS template page destructures `const { cms } = Astro.props` (from getStaticPaths),\n // so `cms` is in scope for the whole body \u2014 component instances are forwarded `cms={cms}`.\n // Must be set BEFORE the body walk so renderComponentInstance sees it.\n if (isCms) ctx.cmsInScope = true;\n // Body sits two spaces in, inside <BaseLayout>.\n const body = page.root ? emitNode(page.root as any, ctx, 2) : '';\n needRuntimeComponent(ctx, 'BaseLayout');\n\n // Component import prefix is relative to the page file's directory. Regular pages\n // sit at `src/pages/<name>.astro` (depth 0 \u2192 `../components/`). A CMS template route\n // lives at `src/pages/<routeDir>/[slug].astro`, so its depth (and thus the number of\n // `../` hops up to `src/components/`) is derived from `meta.cms.urlPattern`. This keeps\n // emit a pure function of the model while emitting a correct relative import.\n const routeDir = isCms ? cmsRouteDirFromUrlPattern((page.meta as { cms: CmsMetaLike }).cms.urlPattern) : '';\n const depth = routeDir ? routeDir.split('/').length : 0;\n const componentPrefix = `${'../'.repeat(depth + 1)}components/`;\n\n // With a component\u2192path map (categorized projects), resolve each import to its\n // subfolder (e.g. `../components/section/Error404.astro`); otherwise stay flat.\n const componentImportPath = opts?.componentPaths\n ? (name: string) => `${componentPrefix}${opts.componentPaths![name] ?? name}.astro`\n : undefined;\n\n const importLines = buildImportLines(ctx, {\n // No `satisfies MenoPageMeta` type annotation is emitted (see below), so there's\n // no type import to add. `satisfies` is a TS-only operator that breaks the\n // esbuild/astro frontmatter parse on build, and the published runtime ships no\n // types anyway \u2014 so the annotation was pure build-time fragility.\n typeImports: [],\n componentPrefix,\n componentImportPath,\n });\n\n const fm: string[] = [];\n // Pull entries from Astro's content layer: CMS template routes need it for\n // getStaticPaths; any page with a CMS collection list needs it to pass into\n // getCollectionList (meno-astro never imports astro:content itself).\n if (isCms || ctx.needsContentApi) fm.push(`import { getCollection } from 'astro:content';`);\n fm.push(...importLines);\n // The project's theme stylesheet (`src/styles/theme.css`, written by convertProject from\n // colors.json) \u2014 a plain side-effect CSS import that *defines* the `var(--\u2026)` custom\n // properties every style() references. Same `../` depth as the component imports. Pages\n // are the single global import point (components render inside a page, so `:root` is in\n // scope); the parser ignores bare imports, so this round-trips without a model change.\n fm.push(`import '${'../'.repeat(depth + 1)}styles/theme.css';`);\n // Local libraries (page `meta.libraries`): emit a bare side-effect import per local CSS /\n // ES-module JS so Vite bundles + fingerprints them. The `libraries/` folder sits at the\n // project root (one level above `src/`), so it is `depth + 2` hops up. Bare imports are\n // ignored by the parser (re-derived from meta.libraries on emit), so they round-trip \u2014 the\n // same contract as the theme.css import above. External libs + classic local JS stay as\n // tags rendered by loadLibraries \u2192 BaseLayout.\n for (const url of importedLibraryUrls(page.meta?.libraries)) {\n fm.push(`import '${'../'.repeat(depth + 2)}${url.slice(1)}';`);\n }\n fm.push('');\n if (isCms) {\n // Deterministic boilerplate, derived from meta.cms (emit-only; parser skips it).\n fm.push(buildGetStaticPaths((page.meta as { cms: CmsMetaLike }).cms));\n fm.push('');\n }\n // A plain `const meta` (not `export const meta`): the page's meta is only consumed\n // locally by `<BaseLayout meta={meta}>`, never as a module export. Crucially, Astro's\n // compiler fails to hoist an EMPTY `export const meta = {}` out of the component body\n // (\"Unexpected export\" at build) \u2014 a page with no title/description would otherwise\n // break. A local const sidesteps hoisting entirely and works for empty + non-empty meta.\n fm.push(`const meta = ${serializeLiteral(page.meta ?? {}, { indent: 0 })};`);\n if (ctx.frontmatterConsts.length) {\n fm.push('');\n fm.push(...ctx.frontmatterConsts);\n }\n\n const wrapped = body\n ? `<BaseLayout meta={meta}>\\n${body}\\n</BaseLayout>`\n : `<BaseLayout meta={meta} />`;\n return `---\\n${fm.join('\\n')}\\n---\\n${wrapped}\\n`;\n}\n", "/**\n * `define:vars` `el` + `props` binding \u2014 emit/parse twins.\n *\n * meno-core ran a component's `<script>` as `(function(el, props){ \u2026 })(el, props)`, so\n * component JS is authored assuming BOTH **`el`** (the instance's own root element) and\n * **`props`** (the resolved props object) are in scope \u2014 e.g.\n * `el.querySelector('[counter=\"display\"]')` and `props.columns`. Astro's native\n * `<script define:vars={{\u2026}}>` injects only the individual prop *values* as consts, never\n * `el` and never a `props` object, so that code throws `ReferenceError: el is not defined`\n * / `props is not defined` in the browser.\n *\n * We bridge the gap by wrapping the user JS in an IIFE that binds `el` to the script's own\n * component root and `props` to an object built from the injected define:vars consts. Astro\n * renders a `define:vars` script as a plain **inline** (non-module) script that runs\n * synchronously at its position in the document, so `document.currentScript` is valid and the\n * component's rendered markup is the script's previous element sibling (Astro hoists the\n * component `<style>` to `<head>`, so we skip any STYLE/SCRIPT siblings defensively). The\n * individual prop consts stay available in the enclosing scope too (the IIFE closes over\n * them), so destructured-prop access keeps working.\n *\n * The wrapper is deterministic boilerplate (the only per-component variation is the prop-name\n * list passed to {@link wrapDefineVarsJs}), so {@link unwrapDefineVarsJs} strips it back off on\n * parse \u2014 the model's `javascript` round-trips as the clean user source. An IIFE *parameter*\n * (not a `const`) is used so user code that itself does `var el`/`var props` can't collide.\n */\n\n/** Resolve the component root element from the executing inline `define:vars` script. */\nconst EL_BIND_EXPR =\n \"(function(){var s=document.currentScript,e=s&&s.previousElementSibling;\" +\n \"while(e&&(e.nodeName==='STYLE'||e.nodeName==='SCRIPT'))e=e.previousElementSibling;\" +\n 'return e||null;})()';\n\nconst WRAP_OPEN = '(function(el, props){\\n';\n/** The fixed head of the wrapper close; the `, { \u2026names })` props arg follows it. */\nconst CLOSE_HEAD = `\\n})(${EL_BIND_EXPR}`;\n\n// The previous wrapper bound only `el` \u2014 recognized on parse for back-compat with already\n// emitted `.astro` (so older files still round-trip to clean JS).\nconst OLD_OPEN = '(function(el){\\n';\nconst OLD_CLOSE = `\\n})(${EL_BIND_EXPR});`;\n\n/**\n * Wrap a `define:vars` component's JS so `el` (its root element) and `props` (an object of\n * the injected prop values, keyed by `names`) are in scope at runtime. `names` are the same\n * define:vars consts the `<script define:vars={{\u2026}}>` directive injects.\n */\nexport function wrapDefineVarsJs(js: string, names: string[] = []): string {\n const propsArg = names.length ? `{ ${names.join(', ')} }` : '{}';\n return `${WRAP_OPEN}${js}${CLOSE_HEAD}, ${propsArg});`;\n}\n\n/** Inverse of {@link wrapDefineVarsJs}: recover the clean user JS (no-op if not wrapped). */\nexport function unwrapDefineVarsJs(js: string): string {\n if (js.startsWith(WRAP_OPEN) && js.endsWith(');')) {\n const idx = js.lastIndexOf(CLOSE_HEAD);\n if (idx !== -1) return js.slice(WRAP_OPEN.length, idx);\n }\n // Back-compat: previous el-only wrapper.\n if (js.startsWith(OLD_OPEN) && js.endsWith(OLD_CLOSE)) {\n return js.slice(OLD_OPEN.length, js.length - OLD_CLOSE.length);\n }\n return js;\n}\n", "/**\n * Component assembler \u2014 a `StructuredComponentDefinition` \u2192 a full `.astro` component\n * file (frontmatter + body + optional <style>/<script>).\n *\n * The single `const { \u2026 } = resolveProps(Astro, {\u2026})` call is the authoritative\n * prop block: its `{\u2026}` argument is the serialized prop interface (the parser reads\n * it), and the destructured locals (typed by inference) are emit-only convenience.\n * `__meno` carries the remaining component metadata (category, acceptsStyles,\n * libraries). `defineVars` is NOT in `__meno`: a component's JS that needs its props\n * is emitted as `<script define:vars={{\u2026}}>` (native Astro), reconstructed on parse.\n */\n\nimport type { StructuredComponentDefinition } from 'meno-core/shared/types';\nimport { createEmitContext, relativeComponentImport, type EmitOptions } from './emitContext';\nimport { emitNode, collectItemBindings } from './emitNode';\nimport { serializeLiteral } from './serialize';\nimport { buildImportLines, buildPropsBlock } from './frontmatter';\nimport { importedLibraryUrls } from '../libraryImports';\nimport { wrapDefineVarsJs } from '../scriptBind';\n\nconst META_KEYS = ['category', 'acceptsStyles', 'libraries'] as const;\n\n/**\n * The prop names injected into the client `<script>` via Astro's `define:vars`.\n * `true` \u2192 every interface prop (key order, minus `children`); a `string[]` \u2192 as given.\n */\nfunction defineVarNames(def: StructuredComponentDefinition): string[] {\n if (def.defineVars === true) {\n return Object.keys(def.interface ?? {}).filter((k) => k !== 'children');\n }\n return def.defineVars ?? [];\n}\n\n/**\n * The client `<script>` block. When `defineVars` is set, emit Astro's native\n * `<script define:vars={{ a, b }}>` (which already forces inline \u2014 no `is:inline`);\n * otherwise a plain `<script is:inline>`. No script when there is no `javascript`.\n */\nfunction buildScriptBlock(def: StructuredComponentDefinition): string {\n if (!def.javascript) return '';\n if (def.defineVars) {\n const names = defineVarNames(def);\n // Bind `el` (the component root) and `props` (object of the injected prop values) for the\n // user JS \u2014 define:vars alone injects only individual prop values, so meno-core-style\n // `el.querySelector(...)` / `props.x` would throw. See scriptBind.\n return `\\n\\n<script define:vars={{ ${names.join(', ')} }}>\\n${wrapDefineVarsJs(def.javascript, names)}\\n</script>`;\n }\n return `\\n\\n<script is:inline>\\n${def.javascript}\\n</script>`;\n}\n\nfunction pickComponentMeta(def: StructuredComponentDefinition): Record<string, unknown> {\n const meta: Record<string, unknown> = {};\n for (const k of META_KEYS) {\n const v = (def as Record<string, unknown>)[k];\n if (v !== undefined) meta[k] = v;\n }\n return meta;\n}\n\nexport function emitComponent(def: StructuredComponentDefinition, opts?: EmitOptions): string {\n const ctx = createEmitContext();\n // Every component exposes its resolved props as `__props` (see buildPropsBlock); the\n // body's style()/href()/embedHtml() calls pass it so prop-`_mapping`s resolve.\n ctx.propsVar = '__props';\n // Rich-text props (`type:\"rich-text\"`) carry an HTML string; a bare `{{name}}` text child\n // referencing one must render via `set:html` (see emitTextChild) or its marks are dead.\n ctx.richTextProps = new Set(\n Object.entries(def.interface ?? {})\n .filter(([, d]) => (d as { type?: string })?.type === 'rich-text')\n .map(([name]) => name),\n );\n // CMS-item bindings: identifiers the template references (e.g. `cms` in `{{cms.title}}`,\n // or `post` in `{{post.title}}`) that aren't declared props. Computed before the body\n // walk so a component that itself receives `cms` propagates it (`cms={cms}`) to the\n // component instances it renders (renderComponentInstance) \u2014 the CMS context flows down.\n const itemBindings = collectItemBindings(def.structure, Object.keys(def.interface ?? {}));\n if (itemBindings.includes('cms')) ctx.cmsInScope = true;\n const body = def.structure ? emitNode(def.structure as any, ctx, 0) : '<slot />';\n\n const componentMeta = pickComponentMeta(def);\n const hasMeta = Object.keys(componentMeta).length > 0;\n\n // `resolveProps` is the authoritative prop block; every component imports it.\n ctx.runtime.add('resolveProps');\n\n // No `satisfies MenoComponentMeta` annotation is emitted (see below) \u2014 `satisfies`\n // is TS-only and breaks the esbuild/astro frontmatter parse on build, and no types\n // ship with the runtime \u2014 so there's no type import to add.\n const typeImports: string[] = [];\n\n // Categorized projects: resolve sibling-component imports relative to THIS\n // component's own folder (e.g. a `section/` component importing `ui/Button`\n // emits `../ui/Button.astro`). Flat projects keep `./Button.astro`.\n const selfDir = opts?.selfPath ? opts.selfPath.split('/').slice(0, -1).join('/') : '';\n const componentImportPath = opts?.componentPaths\n ? (name: string) => `${relativeComponentImport(selfDir, opts.componentPaths![name] ?? name)}.astro`\n : undefined;\n\n const importLines = buildImportLines(ctx, { typeImports, componentPrefix: './', componentImportPath });\n const propsBlock = buildPropsBlock(def.interface);\n\n // Local libraries (`__meno.libraries`): a bare side-effect import per local CSS / ES-module\n // JS so Vite bundles + fingerprints them (Vite also dedupes a file imported by several\n // components). The component file sits at `src/components/<selfPath>.astro`, so the project\n // root (where `libraries/` lives) is 2 + selfDir-depth hops up. Bare imports are ignored by\n // the parser, so they round-trip \u2014 same contract as emitPage's theme.css import. External\n // libs + classic local JS stay as tags rendered by loadLibraries \u2192 BaseLayout.\n const libUpToRoot = '../'.repeat(2 + (selfDir ? selfDir.split('/').length : 0));\n const libraryImports = importedLibraryUrls(def.libraries).map((url) => `import '${libUpToRoot}${url.slice(1)}';`);\n\n // `itemBindings` (computed above, before the body walk) are declared from `Astro.props`\n // so the references resolve in this component's own module scope \u2014 the parent list/page\n // passes them (renderComponentInstance).\n const fm: string[] = [];\n // A component containing a CMS collection list must import astro:content's\n // getCollection and pass it to getCollectionList (see runtime/collectionList).\n if (ctx.needsContentApi) fm.push(`import { getCollection } from 'astro:content';`);\n fm.push(...importLines);\n fm.push(...libraryImports);\n fm.push('');\n fm.push(...propsBlock);\n if (itemBindings.length) {\n fm.push(`const { ${itemBindings.join(', ')} } = Astro.props;`);\n }\n if (hasMeta) {\n fm.push('');\n fm.push(`const __meno = ${serializeLiteral(componentMeta, { indent: 0 })};`);\n }\n if (ctx.frontmatterConsts.length) {\n fm.push('');\n fm.push(...ctx.frontmatterConsts);\n }\n\n const styleBlock = def.css ? `\\n\\n<style>\\n${def.css}\\n</style>` : '';\n const scriptBlock = buildScriptBlock(def);\n\n return `---\\n${fm.join('\\n')}\\n---\\n${body}\\n${styleBlock}${scriptBlock}`.replace(/\\n+$/, '\\n');\n}\n", "/**\n * Low-level scanners for the parser: skip strings / template literals and find\n * matching delimiters, so higher layers can treat `{ \u2026 }`, `( \u2026 )`, `[ \u2026 ]` as\n * opaque balanced spans without tripping over braces inside strings or `${\u2026}`.\n */\n\nconst CLOSERS: Record<string, string> = { '{': '}', '(': ')', '[': ']' };\n\n/** From a quote at `i`, return the index just past the matching closing quote. */\nexport function scanString(src: string, i: number): number {\n const q = src[i];\n let j = i + 1;\n while (j < src.length) {\n if (src[j] === '\\\\') { j += 2; continue; }\n if (src[j] === q) return j + 1;\n j++;\n }\n throw new Error(`scanString: unterminated string from ${i}`);\n}\n\n/** From a backtick at `i`, return the index just past the matching backtick (handles `${\u2026}`). */\nexport function scanTemplate(src: string, i: number): number {\n let j = i + 1;\n while (j < src.length) {\n if (src[j] === '\\\\') { j += 2; continue; }\n if (src[j] === '`') return j + 1;\n if (src[j] === '$' && src[j + 1] === '{') { j = scanBalanced(src, j + 1); continue; }\n j++;\n }\n throw new Error(`scanTemplate: unterminated template from ${i}`);\n}\n\n/** From an opening delimiter at `i` ({ ( [), return the index just past its match. */\nexport function scanBalanced(src: string, i: number): number {\n if (!CLOSERS[src[i]]) throw new Error(`scanBalanced: no open delimiter at ${i} (\"${src[i]}\")`);\n let depth = 0;\n let j = i;\n while (j < src.length) {\n const c = src[j];\n if (c === '\"' || c === \"'\") { j = scanString(src, j); continue; }\n if (c === '`') { j = scanTemplate(src, j); continue; }\n if (c === '{' || c === '(' || c === '[') { depth++; j++; continue; }\n if (c === '}' || c === ')' || c === ']') {\n depth--;\n j++;\n if (depth === 0) return j;\n continue;\n }\n j++;\n }\n throw new Error(`scanBalanced: unbalanced from ${i}`);\n}\n\n/**\n * Find the first top-level `openChar \u2026 close` group whose close is the very end of\n * `expr` (e.g. the `( \u2026 )` of `cond && ( \u2026 )` or `head.map(\u2026)`). Returns the inner\n * content, or null. Skips strings/templates/nested groups.\n */\nexport function findTrailingGroup(\n expr: string,\n openChar: '(' | '{' | '[' = '(',\n): { open: number; inner: string } | null {\n let j = 0;\n while (j < expr.length) {\n const c = expr[j];\n if (c === '\"' || c === \"'\") { j = scanString(expr, j); continue; }\n if (c === '`') { j = scanTemplate(expr, j); continue; }\n if (c === '{' || c === '(' || c === '[') {\n const end = scanBalanced(expr, j);\n if (c === openChar && end === expr.length) {\n return { open: j, inner: expr.slice(j + 1, end - 1) };\n }\n j = end;\n continue;\n }\n j++;\n }\n return null;\n}\n\n/** Split `src` on a single-character separator at top level (ignores strings/groups). */\nexport function splitTopLevel(src: string, sep: string): string[] {\n const parts: string[] = [];\n let start = 0;\n let j = 0;\n while (j < src.length) {\n const c = src[j];\n if (c === '\"' || c === \"'\") { j = scanString(src, j); continue; }\n if (c === '`') { j = scanTemplate(src, j); continue; }\n if (c === '{' || c === '(' || c === '[') { j = scanBalanced(src, j); continue; }\n if (c === sep) { parts.push(src.slice(start, j)); start = j + 1; j++; continue; }\n j++;\n }\n parts.push(src.slice(start));\n return parts.map((s) => s.trim());\n}\n", "/**\n * Recursive-descent parser for the JS-literal subset that `serialize.ts` emits \u2014\n * its exact inverse. Grammar: object | array | string | number | boolean | null,\n * with identifier-or-quoted object keys and JSON string escaping. Total over that\n * grammar; throws on anything outside it (which, for in-dialect input, never occurs).\n *\n * This is the \"tiny total evaluator\" that reads back `style(\u2026)`, `i18n(\u2026)`,\n * `export const meta = \u2026`, the `resolveProps(Astro, {\u2026})` argument, etc. \u2014 no\n * `eval`, no JS engine.\n *\n * It additionally reverses the two *expression* forms `serializeExprLiteral` emits for\n * a `{{template}}` nested inside a structured prop value (e.g. `link={{ href: link.href }}`):\n * a bare identifier/member chain (`link.href` \u2192 `{{link.href}}`) and a backtick template\n * literal (`` `/p/${slug}` `` \u2192 `/p/{{slug}}`). Quoted strings / numbers / booleans are\n * unaffected, so existing literal input parses exactly as before.\n */\n\nimport { scanBalanced } from './scan';\n\nexport interface LiteralResult {\n value: unknown;\n /** Index just past the parsed value. */\n end: number;\n}\n\nconst WS = new Set([' ', '\\t', '\\r', '\\n']);\nconst IDENT_START = /[A-Za-z_$]/;\nconst IDENT_CHAR = /[A-Za-z0-9_$]/;\n\nfunction skipWs(src: string, i: number): number {\n while (i < src.length && WS.has(src[i])) i++;\n return i;\n}\n\nfunction fail(src: string, i: number, msg: string): never {\n const around = src.slice(Math.max(0, i - 20), i + 20);\n throw new Error(`parseLiteral: ${msg} at index ${i} (\u2026${around}\u2026)`);\n}\n\nfunction parseString(src: string, i: number): LiteralResult {\n // src[i] === '\"'. Scan to the matching unescaped quote, then JSON.parse the span.\n let j = i + 1;\n while (j < src.length) {\n const c = src[j];\n if (c === '\\\\') { j += 2; continue; }\n if (c === '\"') { j++; break; }\n j++;\n }\n const raw = src.slice(i, j);\n return { value: JSON.parse(raw) as string, end: j };\n}\n\nfunction parseNumber(src: string, i: number): LiteralResult {\n let j = i;\n while (j < src.length && /[-+0-9.eE]/.test(src[j])) j++;\n const raw = src.slice(i, j);\n const n = Number(raw);\n if (Number.isNaN(n) && raw !== 'NaN') fail(src, i, `invalid number \"${raw}\"`);\n return { value: n, end: j };\n}\n\nfunction parseKey(src: string, i: number): LiteralResult {\n if (src[i] === '\"') return parseString(src, i);\n if (!IDENT_START.test(src[i])) fail(src, i, 'expected object key');\n let j = i + 1;\n while (j < src.length && IDENT_CHAR.test(src[j])) j++;\n return { value: src.slice(i, j), end: j };\n}\n\nfunction parseObject(src: string, i: number): LiteralResult {\n const obj: Record<string, unknown> = {};\n let j = skipWs(src, i + 1);\n if (src[j] === '}') return { value: obj, end: j + 1 };\n for (;;) {\n j = skipWs(src, j);\n const key = parseKey(src, j);\n j = skipWs(src, key.end);\n if (src[j] !== ':') fail(src, j, 'expected \":\"');\n j = skipWs(src, j + 1);\n const val = parseValueAt(src, j);\n obj[key.value as string] = val.value;\n j = skipWs(src, val.end);\n if (src[j] === ',') { j++; continue; }\n if (src[j] === '}') return { value: obj, end: j + 1 };\n fail(src, j, 'expected \",\" or \"}\"');\n }\n}\n\nfunction parseArray(src: string, i: number): LiteralResult {\n const arr: unknown[] = [];\n let j = skipWs(src, i + 1);\n if (src[j] === ']') return { value: arr, end: j + 1 };\n for (;;) {\n j = skipWs(src, j);\n const val = parseValueAt(src, j);\n arr.push(val.value);\n j = skipWs(src, val.end);\n if (src[j] === ',') { j++; continue; }\n if (src[j] === ']') return { value: arr, end: j + 1 };\n fail(src, j, 'expected \",\" or \"]\"');\n }\n}\n\n/** Reverse a backtick template-literal body to a `{{\u2026}}` template string. Mirrors the\n * emitter's `escapeBacktick` + `${expr}` interpolation (the inverse of `templateToExpr`). */\nfunction reverseBacktickBody(content: string): string {\n let out = '';\n let i = 0;\n while (i < content.length) {\n const c = content[i];\n if (c === '\\\\') {\n const n = content[i + 1];\n out += n === '\\\\' ? '\\\\' : n === '`' ? '`' : n === '$' ? '$' : n;\n i += 2;\n continue;\n }\n if (c === '$' && content[i + 1] === '{') {\n const end = scanBalanced(content, i + 1); // index past the matching '}'\n out += '{{' + content.slice(i + 2, end - 1).trim() + '}}';\n i = end;\n continue;\n }\n out += c;\n i++;\n }\n return out;\n}\n\n/** Parse a backtick template literal (`src[i] === '\\`'`) \u2192 reversed `{{\u2026}}` template string. */\nfunction parseBacktick(src: string, i: number): LiteralResult {\n let j = i + 1;\n while (j < src.length) {\n const c = src[j];\n if (c === '\\\\') { j += 2; continue; }\n if (c === '`') { j++; break; }\n if (c === '$' && src[j + 1] === '{') { j = scanBalanced(src, j + 1); continue; }\n j++;\n }\n return { value: reverseBacktickBody(src.slice(i + 1, j - 1)), end: j };\n}\n\n/**\n * Parse a bare expression (identifier/member chain, possibly with calls/indexing) up to\n * the first top-level `,`/`}`/`]`, and reverse it to a `{{\u2026}}` template. Only reached for\n * the expression form `serializeExprLiteral` emits inside a structured prop value.\n */\nfunction parseExprToken(src: string, i: number): LiteralResult {\n let j = i;\n let depth = 0;\n while (j < src.length) {\n const c = src[j];\n if (c === '\"' || c === \"'\" || c === '`') {\n const q = c;\n j++;\n while (j < src.length && src[j] !== q) { if (src[j] === '\\\\') j++; j++; }\n j++;\n continue;\n }\n if (c === '(' || c === '[' || c === '{') { depth++; j++; continue; }\n if (c === ')' || c === ']' || c === '}') { if (depth === 0) break; depth--; j++; continue; }\n if (depth === 0 && c === ',') break;\n j++;\n }\n return { value: `{{${src.slice(i, j).trim()}}}`, end: j };\n}\n\n/** Parse a single literal value starting at `i` (after leading whitespace). */\nexport function parseValueAt(src: string, i: number): LiteralResult {\n i = skipWs(src, i);\n const c = src[i];\n if (c === '{') return parseObject(src, i);\n if (c === '[') return parseArray(src, i);\n if (c === '\"') return parseString(src, i);\n if (c === '`') return parseBacktick(src, i);\n // Keyword literals \u2014 guarded so an identifier that merely *starts* with the keyword\n // (`trueValue`, `nullable`) falls through to the bare-expression branch instead.\n if (src.startsWith('true', i) && !IDENT_CHAR.test(src[i + 4] ?? '')) return { value: true, end: i + 4 };\n if (src.startsWith('false', i) && !IDENT_CHAR.test(src[i + 5] ?? '')) return { value: false, end: i + 5 };\n if (src.startsWith('null', i) && !IDENT_CHAR.test(src[i + 4] ?? '')) return { value: null, end: i + 4 };\n if (c === '-' || c === '+' || (c >= '0' && c <= '9')) return parseNumber(src, i);\n if (c !== undefined && IDENT_START.test(c)) return parseExprToken(src, i); // bare expr \u2192 {{\u2026}}\n return fail(src, i, `unexpected character \"${c ?? '<eof>'}\"`);\n}\n\n/** Parse a whole literal string (the entire trimmed input must be one literal). */\nexport function parseLiteral(src: string): unknown {\n const { value, end } = parseValueAt(src, 0);\n const rest = skipWs(src, end);\n if (rest !== src.length) fail(src, rest, 'trailing content after literal');\n return value;\n}\n", "import { scanBalanced } from './scan';\n\n/** Inner text of the first `( \u2026 )` call group in `expr` (e.g. `style( <here> )`). */\nexport function callArgsOf(expr: string): string {\n const open = expr.indexOf('(');\n const end = scanBalanced(expr, open);\n return expr.slice(open + 1, end - 1);\n}\n", "/**\n * Value reversers \u2014 the inverse of the emitter's value/attribute encoders. Turn a\n * JSX attribute/expression string back into the Meno model value it came from.\n */\n\nimport { isSupportedTemplateExpression } from 'meno-core/shared';\nimport { parseLiteral } from './parseLiteral';\nimport { scanBalanced, splitTopLevel } from './scan';\nimport { callArgsOf } from './callArgs';\nimport { addMenoSpanMarker } from '../richtext';\nimport type { ParseContext } from './parseContext';\n\n/** A preserved arbitrary-JS expression the Meno model can't represent as a binding. */\nexport interface CodeMarker {\n _code: true;\n expr: string;\n}\n\n/** Tag an arbitrary JS expression as a verbatim-code marker. */\nexport function codeMarker(expr: string): CodeMarker {\n return { _code: true, expr };\n}\n\n/** Reverse `escapeBacktick` + `${expr}` interpolation: backtick content \u2192 Meno string. */\nexport function reverseTemplate(content: string): string {\n let out = '';\n let i = 0;\n while (i < content.length) {\n const c = content[i];\n if (c === '\\\\') {\n const n = content[i + 1];\n // escapeBacktick produced \\\\, \\` and \\${ \u2014 undo each (\\$ leaves the following { literal).\n out += n === '\\\\' ? '\\\\' : n === '`' ? '`' : n === '$' ? '$' : n;\n i += 2;\n continue;\n }\n if (c === '$' && content[i + 1] === '{') {\n const end = scanBalanced(content, i + 1);\n out += '{{' + content.slice(i + 2, end - 1).trim() + '}}';\n i = end;\n continue;\n }\n out += c;\n i++;\n }\n return out;\n}\n\n/**\n * Interpret a JSX expression-attribute value (the inner of `name={ \u2026 }`) back into a\n * Meno model value.\n */\nexport function interpretExprValue(expr: string, ctx: ParseContext): unknown {\n const e = expr.trim();\n\n if (ctx.embedConsts.has(e)) return ctx.embedConsts.get(e);\n // A hoisted `__codeN` reference \u2192 the verbatim JS expression it stands for.\n if (ctx.codeConsts.has(e)) return codeMarker(ctx.codeConsts.get(e)!);\n if (e.startsWith('i18n(')) return parseLiteral(callArgsOf(e));\n // href()/embedHtml() may carry a threaded `__props` arg after the literal mapping (the\n // emitter passes the host component's props). Take only the first top-level arg.\n if (e.startsWith('href(')) return parseLiteral(splitTopLevel(callArgsOf(e), ',')[0]);\n if (e.startsWith('embedHtml(')) return parseLiteral(splitTopLevel(callArgsOf(e), ',')[0]);\n // Backtick literal \u2192 Meno string. Re-add the editor-only `data-meno-span` that emit strips\n // from custom spans (no-op for non-rich-text backticks like `/p/${slug}`), so rich-text\n // values round-trip to canonical meno-core HTML. See `../richtext`.\n if (e[0] === '`') return addMenoSpanMarker(reverseTemplate(e.slice(1, -1)));\n if (e[0] === '{' || e[0] === '[') return parseLiteral(e);\n if (e[0] === '\"') return parseLiteral(e);\n if (e === 'true') return true;\n if (e === 'false') return false;\n if (e === 'null') return null;\n if (/^[-+]?(\\d|\\.\\d)/.test(e) && !Number.isNaN(Number(e))) return Number(e);\n // Reverse the empty-template node-attribute guard `EXPR || undefined` (emitAttr adds it for\n // HTML attributes meno-core drops when they resolve to \"\") back to `{{EXPR}}`. Only when the\n // inner part is itself a modelable binding, so arbitrary `x || undefined` JS isn't mis-read.\n const guard = e.match(/^(.+?)\\s*\\|\\|\\s*undefined$/);\n if (guard && isSupportedTemplateExpression(guard[1].trim())) return `{{${guard[1].trim()}}}`;\n // A binding the template engine can evaluate (identifier / member / operators /\n // ternary) \u2192 a Meno `{{template}}`. Anything else (function/method calls, arbitrary\n // JS) can't be modeled as a binding \u2014 preserve it verbatim so it is never lost and\n // still renders natively at build (see `isSupportedTemplateExpression`).\n if (isSupportedTemplateExpression(e)) return `{{${e}}}`;\n return codeMarker(e);\n}\n\n/** Reverse a `class={style(LIT[, META])}` attribute into { style, \u2026meta fields }. */\nexport function interpretStyleCall(expr: string): {\n style?: unknown;\n interactiveStyles?: unknown;\n label?: unknown;\n generateElementClass?: unknown;\n} {\n const args = callArgsOf(expr); // inside style( \u2026 )\n const parts = splitTopLevel(args, ',').filter((p) => p.length > 0);\n const out: Record<string, unknown> = {};\n if (parts[0]) out.style = parseLiteral(parts[0]);\n // Meta is the object-literal argument after the style object. Handles both the legacy\n // `style(obj, meta)` form and the current `style(obj, props, meta)` form \u2014 the `props`\n // argument is a bare identifier (`__props`/`undefined`) and is skipped.\n const metaPart = parts.slice(1).find((p) => p.trimStart().startsWith('{'));\n if (metaPart) {\n const meta = parseLiteral(metaPart) as Record<string, unknown>;\n if (meta.interactive !== undefined) out.interactiveStyles = meta.interactive;\n if (meta.label !== undefined) out.label = meta.label;\n if (meta.genClass !== undefined) out.generateElementClass = meta.genClass;\n // `instance` / `kind` are emit-only markers \u2014 intentionally dropped.\n }\n return out;\n}\n\n/** Reverse an `if` condition expression back into a Meno `if` value. */\nexport function reverseCondition(cond: string): boolean | string | unknown {\n const c = cond.trim();\n if (c === 'false') return false;\n if (c === 'true') return true;\n // `when(mapping[, __props])` \u2014 strip the threaded props arg, take the literal mapping.\n if (c.startsWith('when(')) return parseLiteral(splitTopLevel(callArgsOf(c), ',')[0]);\n // A condition the template engine can evaluate \u2192 a `{{template}}`; arbitrary JS is\n // preserved verbatim (symmetric with interpretExprValue).\n if (isSupportedTemplateExpression(c)) return `{{${c}}}`;\n return codeMarker(c);\n}\n", "/**\n * Shared state the body parser needs from the frontmatter: collection-list bindings,\n * hoisted embed consts, and the set of imported component tag names.\n */\n\nexport interface CollectionBinding {\n source: string;\n query?: Record<string, unknown>;\n}\n\n/** Absolute byte span of a model node in the original source: `[start, end)`. */\nexport interface NodeSpan {\n start: number;\n end: number;\n}\n\nexport interface ParseContext {\n /** `const blogList = await getCollectionList(\"blog\", {\u2026}, Astro)` \u2192 binding name \u2192 info. */\n collectionBindings: Map<string, CollectionBinding>;\n /** `const __embed0 = \\`\u2026\\`` \u2192 const name \u2192 verbatim (un-escaped) HTML. */\n embedConsts: Map<string, string>;\n /** `const __code0 = <raw expr>` \u2192 const name \u2192 verbatim JS expression (hoisted multi-line). */\n codeConsts: Map<string, string>;\n /** `const Tag_0 = \\`h${size}\\`` \u2192 const name \u2192 the Meno tag string (`h{{size}}`). */\n tagConsts: Map<string, string>;\n /** Component tag names brought in by local imports (`import X from './X.astro'`). */\n componentNames: Set<string>;\n /**\n * Optional sink for source-line mapping: when present, the body parser records the\n * absolute source span of every object node it produces (keyed by node identity).\n * Off by default (the round-trip codec never sets it) so normal parsing is unchanged;\n * `buildAstroLineMap` opts in to recover `.astro` line ranges for the editor/selection.\n */\n spans?: Map<object, NodeSpan>;\n}\n\nexport function createParseContext(): ParseContext {\n return {\n collectionBindings: new Map(),\n embedConsts: new Map(),\n codeConsts: new Map(),\n tagConsts: new Map(),\n componentNames: new Set(),\n };\n}\n", "/**\n * Frontmatter parser \u2014 extracts the named consts/exports the emitter wrote:\n * `export const meta`, the `resolveProps(Astro, {\u2026})` prop literal, `const __meno`,\n * hoisted `__embedN` template consts, `getCollectionList` bindings, and local\n * component imports.\n */\n\nimport { parseValueAt, parseLiteral } from './parseLiteral';\nimport { scanBalanced, scanString, scanTemplate, splitTopLevel } from './scan';\nimport { reverseTemplate } from './parseValue';\nimport { createParseContext, type ParseContext } from './parseContext';\n\n/**\n * Scan a hoisted-const RHS (an arbitrary JS expression) from `i` to its terminating\n * top-level `;`, skipping over strings, template literals, and balanced bracket groups.\n * The hoisted value is always an expression (no statements), so the first `;` at depth 0\n * is the end. Returns the index of that `;` (or end-of-string if none).\n */\nfunction scanExprToSemicolon(code: string, i: number): number {\n let j = i;\n while (j < code.length) {\n const c = code[j];\n if (c === '\"' || c === \"'\") { j = scanString(code, j); continue; }\n if (c === '`') { j = scanTemplate(code, j); continue; }\n if (c === '(' || c === '[' || c === '{') { j = scanBalanced(code, j); continue; }\n if (c === ';') return j;\n j++;\n }\n return code.length;\n}\n\nexport interface Frontmatter {\n kind: 'page' | 'component';\n ctx: ParseContext;\n meta?: unknown;\n propsInterface?: Record<string, unknown>;\n componentMeta: Record<string, unknown>;\n}\n\n/** Read the literal RHS that follows an anchor like `export const meta = `. */\nfunction literalAfter(code: string, anchor: string): unknown | undefined {\n const idx = code.indexOf(anchor);\n if (idx < 0) return undefined;\n return parseValueAt(code, idx + anchor.length).value;\n}\n\nexport function parseFrontmatter(code: string): Frontmatter {\n const ctx = createParseContext();\n\n // Local component imports: `import Name from './Name.astro'` or a `\u2026/components/Name.astro`\n // path with one-or-more `../` hops (top-level page \u2192 `../components/`; a nested CMS\n // template route at src/pages/<col>/[slug].astro \u2192 `../../components/`).\n for (const m of code.matchAll(/import\\s+(\\w+)\\s+from\\s+'(?:\\.\\/|(?:\\.\\.\\/)+components\\/)[\\w.-]+\\.astro'/g)) {\n ctx.componentNames.add(m[1]);\n }\n\n // Hoisted embed consts: `const __embed0 = ` + backtick template.\n for (const m of code.matchAll(/const\\s+(__embed\\d+)\\s*=\\s*/g)) {\n const tickStart = code.indexOf('`', m.index! + m[0].length);\n if (tickStart < 0) continue;\n const tickEnd = scanTemplate(code, tickStart);\n ctx.embedConsts.set(m[1], reverseTemplate(code.slice(tickStart + 1, tickEnd - 1)));\n }\n\n // Hoisted verbatim-code consts: `const __code0 = <raw expr>;` (multi-line foreign JS\n // lifted out of a `{\u2026}` value/attribute so the placer never re-indents it).\n for (const m of code.matchAll(/const\\s+(__code\\d+)\\s*=\\s*/g)) {\n const start = m.index! + m[0].length;\n const end = scanExprToSemicolon(code, start);\n ctx.codeConsts.set(m[1], code.slice(start, end).trim());\n }\n\n // Dynamic-tag consts: `const Tag_0 = ` + backtick template \u2192 Meno tag string.\n for (const m of code.matchAll(/const\\s+(Tag_\\d+)\\s*=\\s*/g)) {\n const tickStart = code.indexOf('`', m.index! + m[0].length);\n if (tickStart < 0) continue;\n const tickEnd = scanTemplate(code, tickStart);\n ctx.tagConsts.set(m[1], reverseTemplate(code.slice(tickStart + 1, tickEnd - 1)));\n }\n\n // Collection-list bindings:\n // const X = await getCollectionList(\"src\"[, {query}], Astro, getCollection)\n // The optional `{query}` is the only object-literal arg; the trailing `Astro` and\n // `getCollection` identifiers are emit-only plumbing and ignored.\n for (const m of code.matchAll(/const\\s+(\\w+)\\s*=\\s*await\\s+getCollectionList\\(/g)) {\n const open = m.index! + m[0].length - 1; // the '(' of getCollectionList(\n const inner = code.slice(open + 1, scanBalanced(code, open) - 1);\n const args = splitTopLevel(inner, ',').filter(Boolean);\n const source = parseLiteral(args[0]) as string;\n const query = args[1]?.trim().startsWith('{')\n ? (parseLiteral(args[1]) as Record<string, unknown>)\n : undefined;\n ctx.collectionBindings.set(m[1], { source, query });\n }\n\n // The authoritative prop definition is the second argument of the single\n // `resolveProps(Astro, {\u2026})` call. `literalAfter` scans the balanced `{\u2026}`\n // literal that follows the anchor and stops at its matching brace, so the trailing\n // `)`/`;` are ignored. The (cosmetic) destructured names are never read.\n const propsInterface = literalAfter(code, 'resolveProps(Astro, ') as Record<string, unknown> | undefined;\n const componentMeta = (literalAfter(code, 'const __meno = ') as Record<string, unknown>) ?? {};\n // `const meta = ` \u2014 also a substring of the legacy `export const meta = `, so this\n // anchor reads both the current (non-exported) form and older emitted pages.\n const meta = literalAfter(code, 'const meta = ');\n const kind: Frontmatter['kind'] = code.includes('resolveProps(') ? 'component' : 'page';\n\n return { kind, ctx, meta, propsInterface, componentMeta };\n}\n", "/**\n * Markup parser \u2014 the inverse of the node walker. Parses meno-astro dialect template\n * markup back into the Meno node tree, reversing every emitter encoding (style()/i18n()\n * calls, {{}} templates, {cond && (\u2026)} conditionals, list .map(), runtime components).\n */\n\nimport { singularize } from 'meno-core/shared/types';\nimport { scanBalanced, findTrailingGroup, splitTopLevel } from './scan';\nimport { parseLiteral } from './parseLiteral';\nimport {\n interpretExprValue,\n interpretStyleCall,\n reverseCondition,\n} from './parseValue';\nimport { callArgsOf } from './callArgs';\nimport type { ParseContext } from './parseContext';\n\ntype Node = Record<string, any>;\ntype Child = Node | string;\n\nconst WS = new Set([' ', '\\t', '\\r', '\\n']);\nconst RUNTIME_TAGS = new Set(['Link', 'Embed', 'LocaleList', 'BaseLayout']);\nconst LOCALE_STYLE_PROPS = new Set([\n 'style', 'itemStyle', 'activeItemStyle', 'separatorStyle', 'flagStyle',\n]);\n\nfunction skipWs(src: string, i: number): number {\n while (i < src.length && WS.has(src[i])) i++;\n return i;\n}\n\ninterface Attr {\n name: string;\n raw: string;\n isExpr: boolean;\n shorthand?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Tag + attribute scanning\n// ---------------------------------------------------------------------------\n\nfunction readTagName(src: string, i: number): { name: string; end: number } {\n let j = i;\n while (j < src.length && /[A-Za-z0-9.\\-_]/.test(src[j])) j++;\n return { name: src.slice(i, j), end: j };\n}\n\n/** Like {@link readTagName} but allows `:` so Astro directives (`set:html`) read as one name. */\nfunction readAttrName(src: string, i: number): { name: string; end: number } {\n let j = i;\n while (j < src.length && /[A-Za-z0-9.\\-_:]/.test(src[j])) j++;\n return { name: src.slice(i, j), end: j };\n}\n\nfunction parseAttributes(src: string, i: number): { attrs: Attr[]; end: number; selfClose: boolean } {\n const attrs: Attr[] = [];\n let j = i;\n for (;;) {\n j = skipWs(src, j);\n if (src[j] === '/' && src[j + 1] === '>') return { attrs, end: j + 2, selfClose: true };\n if (src[j] === '>') return { attrs, end: j + 1, selfClose: false };\n const { name, end } = readAttrName(src, j);\n if (!name) throw new Error(`parseAttributes: expected attribute name at ${j} (\"${src.slice(j, j + 15)}\")`);\n j = end;\n if (src[j] === '=') {\n j++;\n if (src[j] === '\"' || src[j] === \"'\") {\n const q = src[j];\n let k = j + 1;\n while (k < src.length && src[k] !== q) { if (src[k] === '\\\\') k++; k++; }\n attrs.push({ name, raw: src.slice(j + 1, k), isExpr: false });\n j = k + 1;\n } else if (src[j] === '{') {\n const close = scanBalanced(src, j);\n attrs.push({ name, raw: src.slice(j + 1, close - 1), isExpr: true });\n j = close;\n } else {\n throw new Error(`parseAttributes: bad attribute value for \"${name}\" at ${j}`);\n }\n } else {\n attrs.push({ name, raw: '', isExpr: false, shorthand: true });\n }\n }\n}\n\nfunction attrValue(a: Attr, ctx: ParseContext): unknown {\n if (a.shorthand) return true;\n if (!a.isExpr) return a.raw;\n return interpretExprValue(a.raw, ctx);\n}\n\n// ---------------------------------------------------------------------------\n// Element + children\n// ---------------------------------------------------------------------------\n\n/**\n * `base` is the absolute offset (in the original full source) of `src[0]`, so recorded\n * spans are absolute even though parsing happens on extracted substrings. It defaults\n * to 0 and is only consulted when `ctx.spans` is set (line-map mode); normal parsing\n * ignores it entirely.\n */\nexport function parseElement(src: string, i: number, ctx: ParseContext, base = 0): { node: Child; end: number } {\n i = skipWs(src, i);\n if (src[i] !== '<') throw new Error(`parseElement: expected \"<\" at ${i}`);\n const { name: tag, end: afterTag } = readTagName(src, i + 1);\n const { attrs, end: afterAttrs, selfClose } = parseAttributes(src, afterTag);\n\n let children: Child[] = [];\n let end = afterAttrs;\n if (!selfClose) {\n // Children share `src` (and therefore `base`) \u2014 only `{\u2026}`/substring re-parsing shifts it.\n const inner = parseNodes(src, afterAttrs, ctx, tag, base);\n children = inner.nodes;\n const close = src.indexOf('>', inner.end);\n end = close + 1;\n }\n return { node: elementToNode(tag, attrs, children, ctx), end };\n}\n\n/** Record an object node's absolute span when the line-map sink is active. */\nfunction recordSpan(ctx: ParseContext, node: Child, start: number, end: number): void {\n if (ctx.spans && node && typeof node === 'object') ctx.spans.set(node, { start, end });\n}\n\nexport function parseNodes(\n src: string,\n i: number,\n ctx: ParseContext,\n stopTag?: string,\n base = 0,\n): { nodes: Child[]; end: number } {\n const nodes: Child[] = [];\n let j = i;\n while (j < src.length) {\n const k = skipWs(src, j);\n if (k >= src.length) { j = k; break; }\n if (stopTag && src[k] === '<' && src[k + 1] === '/') return { nodes, end: k };\n if (src[k] === '<') {\n const { node, end } = parseElement(src, k, ctx, base);\n recordSpan(ctx, node, base + k, base + end);\n nodes.push(node);\n j = end;\n continue;\n }\n if (src[k] === '{') {\n const end = scanBalanced(src, k);\n const child = interpretChildExpr(src.slice(k + 1, end - 1), ctx, base + k + 1);\n if (child !== undefined && child !== null && child !== '') {\n // Record the whole `{\u2026}` span for the resulting node (list / if-wrapped element).\n recordSpan(ctx, child, base + k, base + end);\n nodes.push(child);\n }\n j = end;\n continue;\n }\n // text run until the next tag/expression\n let t = k;\n while (t < src.length && src[t] !== '<' && src[t] !== '{') t++;\n const text = src.slice(k, t).trim();\n if (text.length) nodes.push(text);\n j = t;\n }\n return { nodes, end: j };\n}\n\n// ---------------------------------------------------------------------------\n// Expression children: if-wrappers, list .map(), text/value\n// ---------------------------------------------------------------------------\n\nexport function interpretChildExpr(inner: string, ctx: ParseContext, base = 0): Child | undefined {\n const e = inner.trim();\n if (!e) return undefined;\n const eBase = base + leadingWs(inner);\n\n const grp = findTrailingGroup(e, '(');\n if (grp) {\n const before = e.slice(0, grp.open).trim();\n if (before.endsWith('&&')) {\n const cond = before.slice(0, -2).trim();\n const bodyRaw = grp.inner;\n const body = bodyRaw.trim();\n const bodyBase = eBase + grp.open + 1 + leadingWs(bodyRaw);\n const node = body.startsWith('<')\n ? parseElement(body, 0, ctx, bodyBase).node\n : interpretChildExpr(body, ctx, bodyBase);\n if (node && typeof node === 'object') node.if = reverseCondition(cond);\n return node;\n }\n if (before.endsWith('.map')) {\n // Only a genuine Meno list is a list node: a prop list `list(src).map(\u2026)` or a\n // collection list off a `getCollectionList` binding. A bare `items.map(\u2026)` is\n // arbitrary JS \u2014 fall through to interpretExprValue, which preserves it verbatim.\n const head = before.slice(0, -'.map'.length).trim();\n if (head.startsWith('list(') || ctx.collectionBindings.has(head)) {\n return parseMapExpr(e, ctx, eBase);\n }\n }\n }\n\n const val = interpretExprValue(e, ctx);\n return val as Child;\n}\n\n/** Count of leading whitespace characters (how far `s.trim()` shifts `s`'s start). */\nfunction leadingWs(s: string): number {\n return s.length - s.trimStart().length;\n}\n\nfunction parseMapExpr(e: string, ctx: ParseContext, base = 0): Node {\n const mapIdx = e.indexOf('.map(');\n const head = e.slice(0, mapIdx).trim();\n const argOpen = mapIdx + 4; // '(' of '.map('\n const argEnd = scanBalanced(e, argOpen);\n const argRaw = e.slice(argOpen + 1, argEnd - 1); // interior of `.map( \u2026 )`\n const arg = argRaw.trim(); // (item, index) => ( children )\n const argBase = base + argOpen + 1 + leadingWs(argRaw);\n\n const paramsEnd = scanBalanced(arg, 0);\n const params = splitTopLevel(arg.slice(1, paramsEnd - 1), ',').filter(Boolean);\n const itemVar = params[0];\n const afterParams = arg.slice(paramsEnd);\n const bodyGrp = findTrailingGroup(afterParams.trim(), '(');\n let children: Child[] = [];\n if (bodyGrp) {\n const childrenBase = argBase + paramsEnd + leadingWs(afterParams) + bodyGrp.open + 1;\n children = parseNodes(bodyGrp.inner, 0, ctx, undefined, childrenBase).nodes;\n }\n\n if (head.startsWith('list(')) {\n const inner = callArgsOf(head);\n const parts = splitTopLevel(inner, ',').filter(Boolean);\n const opts = parts[1] ? (parseLiteral(parts[1]) as Record<string, unknown>) : {};\n const node: Node = {\n type: 'list',\n sourceType: 'prop',\n source: `{{${parts[0]}}}`,\n ...opts,\n children,\n };\n if (itemVar && itemVar !== 'item') node.itemAs = itemVar;\n return node;\n }\n\n const binding = ctx.collectionBindings.get(head);\n const source = binding?.source ?? head;\n const node: Node = {\n type: 'list',\n sourceType: 'collection',\n source,\n ...(binding?.query ?? {}),\n children,\n };\n if (itemVar && itemVar !== singularize(source)) node.itemAs = itemVar;\n return node;\n}\n\n// ---------------------------------------------------------------------------\n// Element \u2192 node\n// ---------------------------------------------------------------------------\n\nfunction applyClass(node: Node, attrs: Attr[]): void {\n const cls = attrs.find((a) => a.name === 'class');\n if (!cls) return;\n const parsed = interpretStyleCall(cls.raw);\n if (parsed.style !== undefined) node.style = parsed.style;\n if (parsed.interactiveStyles !== undefined) node.interactiveStyles = parsed.interactiveStyles;\n if (parsed.label !== undefined) node.label = parsed.label;\n if (parsed.generateElementClass !== undefined) node.generateElementClass = parsed.generateElementClass;\n}\n\nfunction otherAttrs(attrs: Attr[], ctx: ParseContext, skip: Set<string>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const a of attrs) {\n if (skip.has(a.name)) continue;\n // Drop the ambient CMS forward `cms={cms}` \u2014 emit-only plumbing that\n // renderComponentInstance threads for Astro's component isolation (the CMS item flows\n // down implicitly in meno-core). `cms` is a reserved ambient name, never an authored\n // prop, so this never strips real data; it keeps `parse(emit(x)) === x`.\n if (a.name === 'cms' && a.isExpr && a.raw.trim() === 'cms') continue;\n out[a.name] = attrValue(a, ctx);\n }\n return out;\n}\n\nfunction elementToNode(tag: string, attrs: Attr[], children: Child[], ctx: ParseContext): Child {\n // `<Fragment set:html={\u2026} />` is the emit form for a rich-text text child (a bare\n // `type:\"rich-text\"` prop ref, or direct rich-text markup). Reverse it back to the text\n // child: a bare identifier \u2192 `{{ident}}`; a backtick HTML literal \u2192 the HTML string (with\n // `data-meno-span` re-added by interpretExprValue). See emitTextChild + `../richtext`.\n if (tag === 'Fragment') {\n const setHtml = attrs.find((a) => a.name === 'set:html');\n if (setHtml) return attrValue(setHtml, ctx) as Child;\n }\n\n // Dynamic tag: `<Tag_0 \u2026>` \u2192 an HTML node whose tag is the original `h{{size}}`.\n if (ctx.tagConsts.has(tag)) {\n const node: Node = { type: 'node', tag: ctx.tagConsts.get(tag)! };\n applyClass(node, attrs);\n const attributes = otherAttrs(attrs, ctx, new Set(['class', 'style']));\n if (Object.keys(attributes).length) node.attributes = attributes;\n if (children.length) node.children = children;\n return node;\n }\n\n if (tag === 'slot') {\n const node: Node = { type: 'slot' };\n if (children.length) node.default = children;\n return node;\n }\n\n if (tag === 'Link') {\n const node: Node = { type: 'link' };\n const href = attrs.find((a) => a.name === 'href');\n if (href) node.href = attrValue(href, ctx);\n applyClass(node, attrs);\n const rest = otherAttrs(attrs, ctx, new Set(['href', 'class', 'style']));\n if (Object.keys(rest).length) node.attributes = rest;\n if (children.length) node.children = children;\n return node;\n }\n\n if (tag === 'Embed') {\n const node: Node = { type: 'embed' };\n const html = attrs.find((a) => a.name === 'html');\n if (html) node.html = attrValue(html, ctx);\n applyClass(node, attrs);\n const rest = otherAttrs(attrs, ctx, new Set(['html', 'class', 'style']));\n if (Object.keys(rest).length) node.attributes = rest;\n return node;\n }\n\n if (tag === 'LocaleList') {\n const node: Node = { type: 'locale-list' };\n for (const a of attrs) {\n if (LOCALE_STYLE_PROPS.has(a.name) && a.isExpr && a.raw.trimStart().startsWith('style(')) {\n node[a.name] = parseLiteral(callArgsOf(a.raw));\n } else if (a.name === 'meta' && a.isExpr) {\n const meta = parseLiteral(a.raw) as Record<string, unknown>;\n if (meta.interactive !== undefined) node.interactiveStyles = meta.interactive;\n if (meta.label !== undefined) node.label = meta.label;\n if (meta.genClass !== undefined) node.generateElementClass = meta.genClass;\n } else {\n node[a.name] = attrValue(a, ctx);\n }\n }\n return node;\n }\n\n // Component instance (Capitalized, or a known imported component).\n const isComponent = /^[A-Z]/.test(tag) && !RUNTIME_TAGS.has(tag);\n if (isComponent) {\n const node: Node = { type: 'component', component: tag };\n applyClass(node, attrs);\n const props = otherAttrs(attrs, ctx, new Set(['class', 'style']));\n if (Object.keys(props).length) node.props = props;\n if (children.length) node.children = children;\n return node;\n }\n\n // HTML element.\n const node: Node = { type: 'node', tag };\n applyClass(node, attrs);\n const attributes = otherAttrs(attrs, ctx, new Set(['class', 'style']));\n if (Object.keys(attributes).length) node.attributes = attributes;\n if (children.length) node.children = children;\n return node;\n}\n", "/**\n * File orchestrator \u2014 split `---` frontmatter from body, parse both, and reassemble\n * the Meno model (a `{ component }` file or a `JSONPage`).\n */\n\nimport { parseFrontmatter } from './parseFrontmatter';\nimport { parseElement, parseNodes } from './parseBody';\nimport { unwrapDefineVarsJs } from '../scriptBind';\nimport type { ParseContext } from './parseContext';\n\nimport type { NodeSpan } from './parseContext';\n\nexport interface ParsedFile {\n model: Record<string, unknown>;\n /** Absolute source spans per object node, only present when `collectSpans` is set. */\n spans?: Map<object, NodeSpan>;\n}\n\nexport interface ParseFileOptions {\n /** Record each node's absolute source span (for `buildAstroLineMap`). Off by default. */\n collectSpans?: boolean;\n}\n\n/** Leading-whitespace count \u2014 how far `s.trim()` shifts `s`'s start. */\nfunction leadingWs(s: string): number {\n return s.length - s.trimStart().length;\n}\n\nfunction splitFrontmatter(source: string): { code: string; body: string; bodyStart: number } {\n const m = source.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n // The body is always the suffix of `source`, so its start offset is exact.\n const body = m ? m[2] : source;\n return { code: m ? m[1] : '', body, bodyStart: source.length - body.length };\n}\n\n/** Extract the shorthand names from a `define:vars={{ a, b }}` attribute, or undefined. */\nfunction parseDefineVars(openTag: string): string[] | undefined {\n const m = openTag.match(/define:vars=\\{\\{([^}]*)\\}\\}/);\n if (!m) return undefined;\n return m[1]\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n}\n\nfunction splitComponentBody(\n body: string,\n ctx: ParseContext,\n bodyStart: number,\n): { structure?: unknown; css?: string; javascript?: string; defineVars?: string[] } {\n let rest = body;\n let javascript: string | undefined;\n let defineVars: string[] | undefined;\n let css: string | undefined;\n\n // The client script is either `<script is:inline>` or `<script define:vars={{\u2026}}>`\n // (native Astro \u2014 the latter injects the listed props into the inline script).\n const scriptM = rest.match(/\\n*<script([^>]*)>\\n([\\s\\S]*?)\\n<\\/script>\\s*$/);\n if (scriptM) {\n javascript = scriptM[2];\n defineVars = parseDefineVars(scriptM[1]);\n // define:vars scripts are emitted wrapped in an `el`-binding IIFE (see scriptBind) \u2014\n // strip it back off so the model's `javascript` is the clean authored source.\n if (defineVars) javascript = unwrapDefineVarsJs(javascript);\n rest = rest.slice(0, scriptM.index);\n }\n const styleM = rest.match(/\\n*<style>\\n([\\s\\S]*?)\\n<\\/style>\\s*$/);\n if (styleM) {\n css = styleM[1];\n rest = rest.slice(0, styleM.index);\n }\n\n const markup = rest.trim();\n // `rest` keeps `body`'s start, so the markup's absolute base is bodyStart + its leading ws.\n const base = bodyStart + leadingWs(rest);\n const structure = markup ? parseNodes(markup, 0, ctx, undefined, base).nodes[0] : undefined;\n return { structure, css, javascript, defineVars };\n}\n\nfunction parsePageRoot(body: string, ctx: ParseContext, bodyStart: number): unknown {\n const trimmed = body.trim();\n if (!trimmed.startsWith('<')) return undefined;\n const base = bodyStart + leadingWs(body);\n const wrapper = parseElement(trimmed, 0, ctx, base).node as Record<string, unknown>;\n const children = wrapper.children;\n return Array.isArray(children) ? children[0] : undefined;\n}\n\nexport function parseFile(source: string, opts: ParseFileOptions = {}): ParsedFile {\n const { code, body, bodyStart } = splitFrontmatter(source);\n const front = parseFrontmatter(code);\n const spans = opts.collectSpans ? new Map<object, NodeSpan>() : undefined;\n if (spans) front.ctx.spans = spans;\n\n if (front.kind === 'component') {\n const { structure, css, javascript, defineVars } = splitComponentBody(body, front.ctx, bodyStart);\n const def: Record<string, unknown> = {};\n if (front.propsInterface && Object.keys(front.propsInterface).length) {\n def.interface = front.propsInterface;\n }\n if (structure !== undefined) def.structure = structure;\n Object.assign(def, front.componentMeta);\n if (css !== undefined) def.css = css;\n if (javascript !== undefined) def.javascript = javascript;\n // `defineVars` is reconstructed from the script's `define:vars={{\u2026}}` attribute\n // (it's no longer carried in `__meno`). normalizeModel canonicalizes it.\n if (defineVars !== undefined) def.defineVars = defineVars;\n return { model: { component: def }, spans };\n }\n\n const root = parsePageRoot(body, front.ctx, bodyStart);\n const page: Record<string, unknown> = {};\n if (front.meta !== undefined) page.meta = front.meta;\n if (root !== undefined) page.root = root;\n return { model: page, spans };\n}\n", "/**\n * Canonicalization for the round-trip contract. The emitter drops content-free\n * defaults (empty styles, empty `children`, empty `meta`) and a single text child is\n * indistinguishable from a one-element array on parse. `normalizeModel` puts a model\n * into the canonical form the parser produces, so the contract is:\n *\n * parse(emit(x)) === normalizeModel(x) (exact up to normalization)\n * parse(emit(normalizeModel(x))) === normalizeModel(x) (exact on canonical input)\n *\n * The codec applies this on load, so the editor always works with canonical models.\n */\n\nimport { singularize } from 'meno-core/shared/types';\n\nfunction hasStyleContent(style: unknown): boolean {\n if (!style || typeof style !== 'object') return false;\n for (const v of Object.values(style as Record<string, unknown>)) {\n if (v === undefined || v === null) continue;\n if (typeof v === 'object') {\n if (Object.keys(v as object).length > 0) return true;\n } else {\n return true;\n }\n }\n return false;\n}\n\n/** Canonicalize a children/default list: normalize items, drop if empty, collapse a lone string. */\nfunction normalizeChildren(children: unknown): unknown {\n if (typeof children === 'string') return children;\n if (!Array.isArray(children)) return undefined;\n const items = children.map(normalizeChild);\n if (items.length === 0) return undefined;\n if (items.length === 1 && typeof items[0] === 'string') return items[0];\n return items;\n}\n\nfunction normalizeChild(child: unknown): unknown {\n return typeof child === 'string' ? child : normalizeNode(child);\n}\n\n/** Migrate legacy node types (cms-list, image) to the unified model. */\nfunction migrateLegacy(n: Record<string, unknown>): Record<string, unknown> {\n if (n.type === 'cms-list') {\n const { type, collection, style, attributes, children, ...rest } = n;\n const list: Record<string, unknown> = {\n type: 'list',\n sourceType: 'collection',\n source: collection,\n ...rest,\n };\n // Legacy cms-list children reference `{{item.*}}`, so bind the loop to `item`\n // (otherwise the migrated collection list would default to singularize(source)\n // and the generated loop var wouldn't match the children's templates).\n if (list.itemAs === undefined) list.itemAs = 'item';\n if (children !== undefined) list.children = children;\n // A cms-list bundled a styled container + repeater \u2192 split into div > list.\n if (style !== undefined || attributes !== undefined) {\n const wrapper: Record<string, unknown> = { type: 'node', tag: 'div' };\n if (style !== undefined) wrapper.style = style;\n if (attributes !== undefined) wrapper.attributes = attributes;\n wrapper.children = [list];\n return wrapper;\n }\n return list;\n }\n if (n.type === 'image') {\n const { type, src, alt, style, attributes, ...rest } = n;\n const attrs: Record<string, unknown> = { ...(attributes as object) };\n if (src !== undefined) attrs.src = src;\n if (alt !== undefined) attrs.alt = alt;\n const img: Record<string, unknown> = { type: 'node', tag: 'img', ...rest };\n if (Object.keys(attrs).length) img.attributes = attrs;\n if (style !== undefined) img.style = style;\n return img;\n }\n return n;\n}\n\nfunction normalizeNode(node: unknown): unknown {\n if (typeof node === 'string') return node;\n if (!node || typeof node !== 'object') return node;\n // Verbatim-code marker ({ _code, expr }) is canonical by construction \u2014 pass through\n // untouched so it stays idempotent and is never mistaken for a structural node.\n if ((node as Record<string, unknown>)._code === true) return node;\n const out = migrateLegacy({ ...(node as Record<string, unknown>) });\n\n if ('style' in out && !hasStyleContent(out.style)) delete out.style;\n\n // Legacy HTML `props` is the old way of specifying attributes (backward-compat\n // field on `node`). Merge it into `attributes` (newer wins) and drop it.\n if (out.type === 'node' && out.props && typeof out.props === 'object') {\n out.attributes = { ...(out.props as object), ...((out.attributes as object) ?? {}) };\n delete out.props;\n }\n\n if (out.type === 'list') {\n const sourceType = (out.sourceType as string) ?? 'prop';\n // Prop-list source: bare `items` \u2261 `{{items}}` (canonical form the editor uses).\n if (sourceType !== 'collection' && typeof out.source === 'string' && !out.source.includes('{{')) {\n out.source = `{{${out.source}}}`;\n }\n // Drop a redundant `itemAs` that equals the implicit default.\n const defaultItem = sourceType === 'collection' ? singularize(String(out.source)) : 'item';\n if (out.itemAs === defaultItem) delete out.itemAs;\n }\n\n if ('children' in out) {\n const c = normalizeChildren(out.children);\n if (c === undefined) delete out.children;\n else out.children = c;\n }\n if ('default' in out) {\n const d = normalizeChildren(out.default);\n if (d === undefined) delete out.default;\n else out.default = d;\n }\n return out;\n}\n\n/**\n * Canonicalize a component's `defineVars` so round-trip is exact (mutates `comp`):\n *\n * - **Collapse \"all props\" \u2192 `true`.** A `string[]` whose set equals all interface\n * prop names (excluding `children`) becomes `true`. So model `true` \u2192 emit\n * `define:vars={{ \u2026all\u2026 }}` \u2192 parse `[\u2026all\u2026]` \u2192 normalize back to `true`. An\n * explicit list that happens to name every prop is semantically identical and is\n * canonicalized the same way (matching how the editor regenerates props on save).\n * - **Drop a meaningless `defineVars`.** With no `javascript` there is no `<script>`\n * to carry the directive, so `defineVars` round-trips as absent \u2192 drop it here.\n *\n * Idempotent: re-running over canonical output is a no-op.\n */\nfunction normalizeDefineVars(comp: Record<string, unknown>): void {\n if (comp.defineVars === undefined) return;\n\n // No script \u2192 no `define:vars` directive emitted \u2192 drop the meaningless field.\n if (!comp.javascript) {\n delete comp.defineVars;\n return;\n }\n\n if (Array.isArray(comp.defineVars)) {\n const names = comp.defineVars as string[];\n const all = Object.keys((comp.interface as Record<string, unknown>) ?? {}).filter(\n (k) => k !== 'children',\n );\n const sameSet =\n names.length === all.length && new Set(names).size === all.length && all.every((k) => names.includes(k));\n if (sameSet) comp.defineVars = true;\n }\n}\n\nexport function normalizeModel(model: unknown): unknown {\n if (!model || typeof model !== 'object') return model;\n const m = model as Record<string, unknown>;\n\n // Component file: { component: { structure, \u2026 } }\n if (m.component && typeof m.component === 'object') {\n const comp = { ...(m.component as Record<string, unknown>) };\n if ('interface' in comp && (!comp.interface || Object.keys(comp.interface as object).length === 0)) {\n delete comp.interface;\n }\n if (comp.structure !== undefined) comp.structure = normalizeNode(comp.structure);\n normalizeDefineVars(comp);\n return { ...m, component: comp };\n }\n\n // Page: { meta?, root?, \u2026 }\n const out: Record<string, unknown> = { ...m };\n if ('meta' in out && (!out.meta || Object.keys(out.meta as object).length === 0)) delete out.meta;\n if (out.root !== undefined) out.root = normalizeNode(out.root);\n return out;\n}\n", "/**\n * `.astro` line mapper \u2014 the dialect counterpart to meno-core's `buildLineMap` for JSON.\n *\n * The Studio editor and the `.meno/selection.json` writer locate a selected node by a\n * `filePath:lineStart-lineEnd` pointer. For JSON projects the line range comes from\n * `buildLineMap(jsonText)`. For `.astro` projects the on-disk file bears no relation to\n * the JSON-stringified model, so we recover ranges from the `.astro` source directly:\n * parse it once with source-span collection on, then walk the node tree assigning the\n * SAME path keys meno-core's mapper uses (`\"\"` = root, `\"0\"`/`\"1,2\"` = child index\n * chains, following only `children` arrays). Keys therefore line up 1:1 with the editor's\n * selection paths, so a selection resolves to the right `.astro` lines.\n *\n * Built from the raw parsed model (pre-normalize), which for `.astro` input has the same\n * `children` shape the editor indexes into \u2014 the only divergence (a lone string child\n * collapsing array\u2192string) adds harmless extra keys the editor never requests.\n */\n\nimport { parseFile } from './parse/parseFile';\nimport type { NodeSpan } from './parse/parseContext';\n\nexport interface LineRange {\n startLine: number;\n endLine: number;\n}\n\nexport type LineMap = Map<string, LineRange>;\n\ntype Node = Record<string, unknown>;\n\n/** Per-character line-number lookup (1-based), matching meno-core's jsonLineMapper. */\nfunction buildCharToLine(source: string): number[] {\n const charToLine = new Array<number>(source.length);\n let line = 1;\n for (let i = 0; i < source.length; i++) {\n charToLine[i] = line;\n if (source[i] === '\\n') line++;\n }\n return charToLine;\n}\n\n/** The tracked root node of a parsed model: a page's `root` or a component's `structure`. */\nfunction rootNode(model: Record<string, unknown>): Node | undefined {\n const component = model.component as Record<string, unknown> | undefined;\n const candidate = component ? component.structure : model.root;\n return candidate && typeof candidate === 'object' ? (candidate as Node) : undefined;\n}\n\n/**\n * Build a `path-key \u2192 line range` map for an `.astro` source, keyed identically to\n * meno-core's `buildLineMap` so selection/copy line lookups work unchanged. Returns an\n * empty map for unparseable input (best-effort, never throws).\n */\nexport function buildAstroLineMap(source: string): LineMap {\n const lineMap: LineMap = new Map();\n try {\n const { model, spans } = parseFile(source, { collectSpans: true });\n if (!spans) return lineMap;\n const root = rootNode(model);\n if (!root) return lineMap;\n\n const charToLine = buildCharToLine(source);\n const toRange = (span: NodeSpan): LineRange => ({\n startLine: charToLine[span.start] ?? 1,\n endLine: charToLine[span.end - 1] ?? charToLine[span.start] ?? 1,\n });\n\n const walk = (node: Node, key: string): void => {\n const span = spans.get(node);\n if (span) lineMap.set(key, toRange(span));\n const children = node.children;\n if (Array.isArray(children)) {\n children.forEach((child, i) => {\n if (child && typeof child === 'object') {\n walk(child as Node, key === '' ? String(i) : `${key},${i}`);\n }\n });\n }\n };\n walk(root, '');\n } catch {\n // Best-effort: a malformed file yields an empty map rather than breaking the editor.\n }\n return lineMap;\n}\n", "/**\n * meno-astro/dialect \u2014 the editor/build-only codec between the Meno in-memory\n * model and the round-trippable `.astro` dialect.\n *\n * This module is NOT shipped to generated projects' runtime; it is used by the\n * Studio editor (read/save) and the build/convert tooling.\n *\n * emit(model) -> .astro source (deterministic, git-stable)\n * parse(source) -> { model, regions }\n *\n * Round-trip contract:\n * - parse(emit(x)) === x (exact: every payload read back verbatim)\n * - emit(parse(y)) === y (stable up to canonical formatting)\n *\n * Bodies are implemented in Phase 1 (emit) and Phase 2 (parse). This file pins\n * the public types/signatures so later phases and downstream callers compile\n * against a stable contract.\n */\n\nimport type { JSONPage, StructuredComponentDefinition } from 'meno-core/shared/types';\nimport { emitPage } from './emit/emitPage';\nimport { emitComponent } from './emit/emitComponent';\nimport { parseFile } from './parse/parseFile';\nimport type { NodeSpan } from './parse/parseContext';\nimport { normalizeModel } from './normalize';\nimport type { EmitOptions } from './emit/emitContext';\n\nexport type { EmitOptions };\n\nexport { normalizeModel };\nexport { buildAstroLineMap, type LineMap, type LineRange } from './lineMap';\n\n/** The on-disk component file shape: `{ component: StructuredComponentDefinition }`. */\nexport interface ComponentFile {\n component: StructuredComponentDefinition;\n}\n\n/** A page or a component definition \u2014 the two top-level things a `.astro` file maps to. */\nexport type DialectModel = JSONPage | StructuredComponentDefinition | ComponentFile;\n\n/**\n * A tracked span of the source file. The parser returns these so the emitter can\n * re-emit non-dialect / hand-written regions verbatim (escape hatch) and so editing\n * one section never reformats an untouched region.\n */\nexport interface MenoRegion {\n /** Stable id of the model node this region corresponds to, if any. */\n nodeId?: string;\n /**\n * - `editable`: in-dialect, fully round-tripped.\n * - `rawClass`: foreign `class=\"\u2026\"` captured as read-only passthrough.\n * - `verbatim`: arbitrary Astro/JS preserved byte-for-byte.\n */\n kind: 'editable' | 'rawClass' | 'verbatim';\n /** Byte offset start (inclusive) in the source. */\n start: number;\n /** Byte offset end (exclusive) in the source. */\n end: number;\n}\n\nexport interface ParseResult {\n model: DialectModel;\n regions: MenoRegion[];\n}\n\n/** Serialize the Meno model to deterministic `.astro` dialect source. */\nexport function emit(model: DialectModel, opts?: EmitOptions): string {\n // Canonicalize first (migrate legacy types, drop empties) so emit accepts raw models\n // and always produces canonical .astro. Symmetric with parse() normalizing its output.\n const m = normalizeModel(model) as Record<string, any>;\n if (m && typeof m === 'object') {\n // On-disk component file: { component: { \u2026 } }\n if (m.component && typeof m.component === 'object') return emitComponent(m.component, opts);\n // Raw component definition (structure/interface/js/css at the top level).\n if (\n m.structure !== undefined ||\n m.interface !== undefined ||\n m.javascript !== undefined ||\n m.css !== undefined\n ) {\n return emitComponent(m as StructuredComponentDefinition, opts);\n }\n }\n // Otherwise it's a page (meta / root / components).\n return emitPage(m as JSONPage, opts);\n}\n\n/**\n * Walk the (pre-normalize) parsed model for verbatim-code markers and report each as a\n * `kind: 'verbatim'` region, using the byte spans `parseFile` recorded. Run BEFORE\n * `normalizeModel`, which copies node objects and would break the span map's identity keys.\n * Child/element-position markers carry spans; attribute-position markers may not (Phase 1).\n */\nfunction collectVerbatimRegions(model: unknown, spans: Map<object, NodeSpan>): MenoRegion[] {\n const regions: MenoRegion[] = [];\n const seen = new Set<object>();\n const walk = (node: unknown): void => {\n if (!node || typeof node !== 'object') return;\n if (seen.has(node)) return;\n seen.add(node);\n if ((node as Record<string, unknown>)._code === true) {\n const span = spans.get(node);\n if (span) regions.push({ kind: 'verbatim', start: span.start, end: span.end });\n return;\n }\n if (Array.isArray(node)) {\n for (const child of node) walk(child);\n return;\n }\n for (const value of Object.values(node as Record<string, unknown>)) walk(value);\n };\n walk(model);\n regions.sort((a, b) => a.start - b.start);\n return regions;\n}\n\n/** Parse `.astro` dialect source back into the Meno model (+ tracked regions). */\nexport function parse(source: string): ParseResult {\n const { model, spans } = parseFile(source, { collectSpans: true });\n const regions = spans ? collectVerbatimRegions(model, spans) : [];\n // Output is canonicalized so the editor always sees a normalized model.\n return { model: normalizeModel(model) as DialectModel, regions };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAiEO,SAAS,kBAAkB,QAAQ,IAAiB;AACzD,SAAO;AAAA,IACL,YAAY,oBAAI,IAAI;AAAA,IACpB,SAAS,oBAAI,IAAI;AAAA,IACjB,mBAAmB,oBAAI,IAAI;AAAA,IAC3B,mBAAmB,CAAC;AAAA,IACpB,UAAU,CAAC;AAAA,IACX,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,cAAc;AAAA,IACd,YAAY;AAAA,IACZ;AAAA,EACF;AACF;AAkBO,SAAS,wBAAwB,SAAiB,QAAwB;AAC/E,QAAM,IAAI,UAAU,QAAQ,MAAM,GAAG,EAAE,OAAO,OAAO,IAAI,CAAC;AAC1D,QAAM,IAAI,OAAO,MAAM,GAAG,EAAE,OAAO,OAAO;AAC1C,MAAI,IAAI;AACR,SAAO,IAAI,EAAE,UAAU,IAAI,EAAE,UAAU,EAAE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AA,IACF;AACA,eAAW,SAAS,OAAO,OAAO,IAA+B,EAAG,MAAK,KAAK;AAAA,EAChF;AACA,OAAK,KAAK;AACV,UAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;AACxC,SAAO;AACT;AAGO,SAAS,MAAM,QAA6B;AACjD,QAAM,EAAE,OAAO,MAAM,IAAI,UAAU,QAAQ,EAAE,cAAc,KAAK,CAAC;AACjE,QAAM,UAAU,QAAQ,uBAAuB,OAAO,KAAK,IAAI,CAAC;AAEhE,SAAO,EAAE,OAAO,eAAe,KAAK,GAAmB,QAAQ;AACjE;",
|
|
6
|
+
"names": ["startCol", "pad", "expr", "WS", "skipWs", "node", "attributes", "leadingWs", "hasStyleContent"]
|
|
7
|
+
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "../../chunks/chunk-FTAXQYZ6.js";
|
|
5
5
|
import {
|
|
6
6
|
parse
|
|
7
|
-
} from "../../chunks/chunk-
|
|
7
|
+
} from "../../chunks/chunk-S4IA22D6.js";
|
|
8
8
|
import "../../chunks/chunk-WKW2JJ35.js";
|
|
9
9
|
import {
|
|
10
10
|
loadI18nConfig
|
|
@@ -146,30 +146,34 @@ function resolveProjectRoot(root) {
|
|
|
146
146
|
return process.cwd();
|
|
147
147
|
}
|
|
148
148
|
var UTILITY_CSS_MODULE = "virtual:meno-utilities.css";
|
|
149
|
+
function collectUtilitySources(projectRoot) {
|
|
150
|
+
const sources = [];
|
|
151
|
+
const srcDir = join(projectRoot, "src");
|
|
152
|
+
const walk = (dir) => {
|
|
153
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
154
|
+
const p = join(dir, e.name);
|
|
155
|
+
if (e.isDirectory()) walk(p);
|
|
156
|
+
else if (e.name.endsWith(".astro")) {
|
|
157
|
+
try {
|
|
158
|
+
sources.push({ src: readFileSync(p, "utf8"), path: p });
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
try {
|
|
165
|
+
if (existsSync(srcDir)) walk(srcDir);
|
|
166
|
+
} catch {
|
|
167
|
+
}
|
|
168
|
+
return sources;
|
|
169
|
+
}
|
|
149
170
|
function utilityCssVitePlugin(projectRoot) {
|
|
150
171
|
const RESOLVED = "\0" + UTILITY_CSS_MODULE;
|
|
151
172
|
let css = "";
|
|
152
173
|
const rebuild = () => {
|
|
153
|
-
|
|
154
|
-
const srcDir = join(projectRoot, "src");
|
|
155
|
-
const walk = (dir) => {
|
|
156
|
-
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
157
|
-
const p = join(dir, e.name);
|
|
158
|
-
if (e.isDirectory()) walk(p);
|
|
159
|
-
else if (e.name.endsWith(".astro")) {
|
|
160
|
-
try {
|
|
161
|
-
sources.push({ src: readFileSync(p, "utf8"), path: p });
|
|
162
|
-
} catch {
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
try {
|
|
168
|
-
if (existsSync(srcDir)) walk(srcDir);
|
|
169
|
-
} catch {
|
|
170
|
-
}
|
|
171
|
-
css = buildUtilityStylesheet(sources);
|
|
174
|
+
css = buildUtilityStylesheet(collectUtilitySources(projectRoot));
|
|
172
175
|
};
|
|
176
|
+
const baseId = (id) => id.replace(/[?#].*$/, "");
|
|
173
177
|
return {
|
|
174
178
|
name: "meno-astro:utility-css",
|
|
175
179
|
enforce: "pre",
|
|
@@ -177,10 +181,27 @@ function utilityCssVitePlugin(projectRoot) {
|
|
|
177
181
|
rebuild();
|
|
178
182
|
},
|
|
179
183
|
resolveId(id) {
|
|
180
|
-
|
|
184
|
+
const base = baseId(id);
|
|
185
|
+
if (base !== UTILITY_CSS_MODULE && base !== RESOLVED) return null;
|
|
186
|
+
const query = id.slice(base.length);
|
|
187
|
+
return RESOLVED + query;
|
|
181
188
|
},
|
|
182
189
|
load(id) {
|
|
183
|
-
return id === RESOLVED ? css : null;
|
|
190
|
+
return baseId(id) === RESOLVED ? css : null;
|
|
191
|
+
},
|
|
192
|
+
// Dev only: keep the virtual sheet in sync with `.astro` edits and reload the page.
|
|
193
|
+
configureServer(server) {
|
|
194
|
+
const srcDir = join(projectRoot, "src");
|
|
195
|
+
const onChange = (file) => {
|
|
196
|
+
if (!file.endsWith(".astro") || !file.startsWith(srcDir)) return;
|
|
197
|
+
rebuild();
|
|
198
|
+
const mod = server.moduleGraph.getModuleById(RESOLVED);
|
|
199
|
+
if (mod) server.moduleGraph.invalidateModule(mod);
|
|
200
|
+
server.ws.send({ type: "full-reload" });
|
|
201
|
+
};
|
|
202
|
+
server.watcher.on("add", onChange);
|
|
203
|
+
server.watcher.on("change", onChange);
|
|
204
|
+
server.watcher.on("unlink", onChange);
|
|
184
205
|
}
|
|
185
206
|
};
|
|
186
207
|
}
|
|
@@ -281,6 +302,7 @@ export {
|
|
|
281
302
|
MENO_ASSET_DIRS,
|
|
282
303
|
UTILITY_CSS_MODULE,
|
|
283
304
|
assetDirForPath,
|
|
305
|
+
collectUtilitySources,
|
|
284
306
|
copyAssetDirsToOutput,
|
|
285
307
|
meno as default,
|
|
286
308
|
resolveAssetFile,
|