@verbaly/compiler 0.39.0 → 0.41.0

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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["parse","walk","parse"],"sources":["../src/catalog.ts","../src/warn.ts","../src/registry.ts","../src/key.ts","../src/analyze.ts","../src/sfc.ts","../src/extract.ts","../src/validate.ts","../src/params.ts","../src/codegen.ts","../src/check.ts","../src/transform.ts","../src/plugin.ts","../src/drafts.ts","../src/text.ts","../src/status.ts","../src/translate.ts","../src/init.ts","../src/doctor.ts","../src/wrap.ts","../src/render.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { ResolvedConfig } from './config';\n\nexport type Catalog = Record<string, string>;\nexport type Catalogs = Record<string, Catalog>;\n\nexport function catalogPath(cfg: ResolvedConfig, locale: string): string {\n return join(cfg.dir, `${locale}.json`);\n}\n\n// the flat view is the shape t() sees, so every command reads a catalog the way the runtime does\nexport function readCatalog(cfg: ResolvedConfig, locale: string): Catalog {\n const tree = readTree(cfg, locale);\n const bad = badLeaf(tree);\n // the runtime skips this leaf with a warn; a build tool that skipped it would write the skip back\n if (bad) {\n throw new Error(\n `[verbaly] ${catalogPath(cfg, locale)} has a non-string value at \"${bad}\", ` +\n 'catalog values are text (groups of text are fine): fix the value',\n );\n }\n return flatten(tree);\n}\n\n// dotted path of the first value that is neither text nor a group of text (an array is a bad leaf)\nexport function badLeaf(tree: MessageTree, prefix = ''): string | undefined {\n for (const [key, value] of Object.entries(tree)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'string') continue;\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return path;\n const bad = badLeaf(value, path);\n if (bad) return bad;\n }\n return undefined;\n}\n\n// corrupt catalog throws: read as empty, the next extract would wipe the translations\nfunction readTree(cfg: ResolvedConfig, locale: string): MessageTree {\n let content: string;\n try {\n content = readFileSync(catalogPath(cfg, locale), 'utf8');\n } catch {\n return {};\n }\n const parsed = parseTree(content);\n if (parsed) return parsed;\n throw new Error(\n `[verbaly] ${catalogPath(cfg, locale)} is not valid JSON, fix or delete the file`,\n );\n}\n\n// a byte order mark is legal in the file and illegal to JSON.parse: drop it by code, never by regex\nfunction parseTree(content: string): MessageTree | undefined {\n const body = content.charCodeAt(0) === 0xfeff ? content.slice(1) : content;\n try {\n return JSON.parse(body) as MessageTree;\n } catch {\n return undefined;\n }\n}\n\nexport function loadCatalogs(cfg: ResolvedConfig): Catalogs {\n const catalogs: Catalogs = {};\n for (const locale of cfg.locales) catalogs[locale] = readCatalog(cfg, locale);\n return catalogs;\n}\n\n// the nesting is the author's: a file written as groups is handed back as groups\nfunction isNested(tree: MessageTree): boolean {\n return Object.values(tree).some((value) => typeof value === 'object' && value !== null);\n}\n\n// dotted key back to its group; a path already taken by text stays flat so nothing is overwritten\nfunction nest(catalog: Catalog): MessageTree {\n const tree: MessageTree = {};\n // sorted, so \"hero\" always lands before \"hero.title\" and a message is never replaced by its group\n for (const [key, message] of Object.entries(catalog).sort(([a], [b]) => (a < b ? -1 : 1))) {\n const parts = key.split('.');\n const leaf = parts[parts.length - 1]!;\n let node: MessageTree | undefined = parts.length > 1 ? tree : undefined;\n for (let i = 0; node && i < parts.length - 1; i++) {\n const next = (node[parts[i]!] ??= {});\n node = typeof next === 'object' && next !== null ? (next as MessageTree) : undefined;\n }\n if (node && typeof node[leaf] !== 'object') node[leaf] = message;\n else tree[key] = message;\n }\n return tree;\n}\n\nfunction sortTree(tree: MessageTree): MessageTree {\n const sorted: MessageTree = {};\n for (const key of Object.keys(tree).sort()) {\n const value = tree[key];\n if (typeof value === 'string') sorted[key] = value;\n else if (value !== undefined) sorted[key] = sortTree(value as MessageTree);\n }\n return sorted;\n}\n\nexport function serializeCatalog(catalog: Catalog, nested = false): string {\n return JSON.stringify(sortTree(nested ? nest(catalog) : catalog), null, 2) + '\\n';\n}\n\nexport function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string {\n const path = catalogPath(cfg, locale);\n let existing: string | undefined;\n try {\n existing = readFileSync(path, 'utf8');\n } catch {\n mkdirSync(cfg.dir, { recursive: true });\n }\n const serialized = serializeCatalog(catalog, wantsNesting(cfg, locale, existing));\n // identical writes are skipped: a rewrite retriggers whatever watches the catalog\n if (existing === serialized) return serialized;\n writeFileSync(path, serialized);\n return serialized;\n}\n\n// the file's own shape, and for a locale that does not exist yet, the source catalog's\nfunction wantsNesting(cfg: ResolvedConfig, locale: string, existing: string | undefined): boolean {\n if (existing !== undefined) {\n const tree = parseTree(existing);\n return tree !== undefined && isNested(tree);\n }\n if (locale === cfg.sourceLocale) return false;\n return isNested(readTree(cfg, cfg.sourceLocale));\n}\n","const warned = new Set<string>();\n\n// one warn-once for the whole compiler: dedupe by static content, never by a value being edited\nexport function warnOnce(message: string, dedupeKey = message): void {\n if (warned.has(dedupeKey)) return;\n warned.add(dedupeKey);\n console.warn(`[verbaly] ${message}`);\n}\n\n// bundler paths only: the CLI reports its own run, so a file is never announced twice\nexport function warnParseError(file: string, message: string): void {\n warnOnce(`${file}: could not be parsed (${message}), its messages were not extracted`);\n}\n","import type { Analysis, StrayImport, TaggedMessage } from './analyze';\nimport { warnOnce } from './warn';\n\nexport class MessageRegistry {\n private files = new Map<string, Analysis>();\n\n update(file: string, analysis: Analysis): void {\n this.files.set(file, analysis);\n }\n\n remove(file: string): void {\n this.files.delete(file);\n }\n\n messages(): Map<string, TaggedMessage> {\n const out = new Map<string, TaggedMessage>();\n for (const analysis of this.files.values()) {\n for (const msg of analysis.tagged) {\n const existing = out.get(msg.key);\n if (existing) {\n if (existing.message !== msg.message) {\n warnOnce(\n `key collision \"${msg.key}\": ` +\n `${JSON.stringify(existing.message)} vs ${JSON.stringify(msg.message)}, second dropped`,\n `collision:${msg.key}`,\n );\n }\n continue;\n }\n out.set(msg.key, msg);\n }\n }\n return out;\n }\n\n usedKeys(): Map<string, string[]> {\n const out = new Map<string, string[]>();\n for (const analysis of this.files.values()) {\n for (const used of analysis.usedKeys) {\n const files = out.get(used.key) ?? [];\n if (!files.includes(used.file)) files.push(used.file);\n out.set(used.key, files);\n }\n }\n return out;\n }\n\n strayImports(): StrayImport[] {\n return [...this.files.values()].flatMap((analysis) => analysis.strayImports);\n }\n\n // files the parser could not read: they contributed no messages and nothing else can tell\n parseErrors(): { file: string; message: string }[] {\n const out: { file: string; message: string }[] = [];\n for (const [file, analysis] of this.files) {\n if (analysis.parseError) out.push({ file, message: analysis.parseError });\n }\n return out;\n }\n\n // key → every source file that writes or uses it (translator context)\n origins(): Map<string, string[]> {\n const out = this.usedKeys();\n for (const analysis of this.files.values()) {\n for (const msg of analysis.tagged) {\n const files = out.get(msg.key) ?? [];\n if (!files.includes(msg.file)) files.push(msg.file);\n out.set(msg.key, files);\n }\n }\n return out;\n }\n}\n","import { createHash } from 'node:crypto';\n\nexport function stableKey(message: string): string {\n return createHash('sha256').update(message).digest('base64url').slice(0, 8);\n}\n","import { parse } from '@babel/parser';\nimport { stableKey } from './key';\n\nexport interface TaggedParam {\n name: string;\n start: number;\n end: number;\n}\n\nexport interface TransComponent {\n name: string;\n source: string;\n}\n\nexport interface TaggedMessage {\n key: string;\n message: string;\n params: TaggedParam[];\n start: number;\n end: number;\n tagStart: number;\n tagEnd: number;\n file: string;\n jsx?: { name: string; components: TransComponent[] };\n singleQuote?: boolean;\n}\n\nexport interface UsedKey {\n key: string;\n file: string;\n}\n\n// a named import the verbaly packages do not export: t comes from an instance, never from a package\nexport interface StrayImport {\n name: string;\n source: string;\n file: string;\n}\n\nexport interface Analysis {\n tagged: TaggedMessage[];\n usedKeys: UsedKey[];\n strayImports: StrayImport[];\n parseError?: string;\n}\n\n// babel's message carries the position but never the path: every caller adds the file itself\nexport function parseErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n// exported for wrap.ts (module-internal reuse, not part of the package surface)\nexport interface AstNode {\n type: string;\n start: number;\n end: number;\n [key: string]: unknown;\n}\n\nconst SKIP_KEYS = new Set(['loc', 'leadingComments', 'trailingComments', 'innerComments', 'extra']);\n\nexport interface AnalyzeOptions {\n tNames?: readonly string[];\n}\n\nconst DEFAULT_T_NAMES: readonly string[] = ['t'];\nconst JSX_FILE_RE = /\\.(?:[cm]?jsx?|tsx)$/;\n\nexport function analyze(code: string, file: string, options: AnalyzeOptions = {}): Analysis {\n const names = new Set(options.tNames ?? DEFAULT_T_NAMES);\n const ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: JSX_FILE_RE.test(file) ? ['typescript', 'jsx'] : ['typescript'],\n });\n\n const tagged: TaggedMessage[] = [];\n const usedKeys: UsedKey[] = [];\n const strayImports: StrayImport[] = [];\n\n walk(ast.program as unknown as AstNode, (node) => {\n if (node.type === 'ImportDeclaration') {\n collectStrayImports(node, file, strayImports);\n } else if (node.type === 'TaggedTemplateExpression') {\n const tag = node.tag as AstNode;\n const explicit = explicitId(tag, names);\n if (!explicit && !isTReference(tag, names)) return;\n const quasi = node.quasi as AstNode;\n const message = buildMessage(code, quasi, names);\n if (!message) return;\n tagged.push({\n key: explicit ? explicit.key : stableKey(message.text),\n message: message.text,\n params: message.params,\n start: node.start,\n end: node.end,\n tagStart: explicit ? explicit.refStart : tag.start,\n tagEnd: explicit ? explicit.refEnd : tag.end,\n file,\n });\n } else if (node.type === 'CallExpression') {\n const callee = node.callee as AstNode;\n if (!isTReference(callee, names)) return;\n const args = node.arguments as AstNode[];\n const first = args[0];\n if (first?.type === 'StringLiteral') {\n usedKeys.push({ key: first.value as string, file });\n }\n } else if (node.type === 'JSXElement') {\n handleTrans(code, node, file, tagged, usedKeys, names);\n }\n });\n\n return { tagged, usedKeys, strayImports };\n}\n\nconst VERBALY_PACKAGE = /^(?:verbaly|@verbaly\\/[\\w-]+)$/;\n\n// the most plausible onboarding error: only the bundler used to complain, and never about verbaly\nfunction collectStrayImports(node: AstNode, file: string, out: StrayImport[]): void {\n const source = node.source as { value?: unknown };\n if (typeof source.value !== 'string' || !VERBALY_PACKAGE.test(source.value)) return;\n for (const spec of node.specifiers as AstNode[]) {\n if (spec.type !== 'ImportSpecifier') continue;\n const imported = spec.imported as AstNode;\n if (imported.type === 'Identifier' && imported.name === 't') {\n out.push({ name: 't', source: source.value, file });\n }\n }\n}\n\nfunction handleTrans(\n code: string,\n node: AstNode,\n file: string,\n tagged: TaggedMessage[],\n usedKeys: UsedKey[],\n names: ReadonlySet<string>,\n): void {\n const opening = node.openingElement as AstNode;\n const nameNode = opening.name as AstNode;\n if (nameNode.type !== 'JSXIdentifier' || nameNode.name !== 'Trans') return;\n\n const attrs = opening.attributes as AstNode[];\n const idAttr = attrs.find((a) => a.type === 'JSXAttribute' && (a.name as AstNode).name === 'id');\n const children = node.children as AstNode[] | undefined;\n const push = (key: string, built: BuiltTrans) =>\n tagged.push({\n key,\n message: built.text,\n params: built.params,\n start: node.start,\n end: node.end,\n tagStart: nameNode.start,\n tagEnd: nameNode.end,\n file,\n jsx: { name: nameNode.name as string, components: built.components },\n });\n\n if (idAttr) {\n const value = idAttr.value as AstNode | null;\n if (value?.type !== 'StringLiteral') return;\n const id = value.value as string;\n // id + children → extract under the explicit key\n if (attrs.length === 1 && children?.length) {\n const built = buildTransMessage(code, children, names);\n if (built?.text.trim()) {\n push(id, built);\n return;\n }\n }\n usedKeys.push({ key: id, file });\n return; // runtime-first, untouched\n }\n if (attrs.length > 0) return; // hand-written props → don't guess\n\n if (!children?.length) return;\n\n const built = buildTransMessage(code, children, names);\n if (!built || !built.text.trim()) return;\n\n push(stableKey(built.text), built);\n}\n\n// t.id('key')`…` → explicit readable key\nfunction explicitId(\n tag: AstNode,\n names: ReadonlySet<string>,\n): { key: string; refStart: number; refEnd: number } | undefined {\n if (tag.type !== 'CallExpression') return undefined;\n const callee = tag.callee as AstNode;\n if (callee.type !== 'MemberExpression' || callee.computed) return undefined;\n const prop = callee.property as AstNode;\n if (prop.type !== 'Identifier' || prop.name !== 'id') return undefined;\n const obj = callee.object as AstNode;\n if (!isTReference(obj, names)) return undefined;\n const args = tag.arguments as AstNode[];\n const first = args[0];\n if (args.length !== 1 || first?.type !== 'StringLiteral') return undefined;\n return { key: first.value as string, refStart: obj.start, refEnd: obj.end };\n}\n\ninterface BuiltTrans {\n text: string;\n params: TaggedParam[];\n components: TransComponent[];\n}\n\nfunction buildTransMessage(\n code: string,\n children: AstNode[],\n names: ReadonlySet<string>,\n): BuiltTrans | undefined {\n const params: TaggedParam[] = [];\n const components: TransComponent[] = [];\n const takenParams = new Map<string, string>();\n const takenTags = new Map<string, string>();\n\n function walkChildren(nodes: AstNode[]): string | undefined {\n let text = '';\n for (const child of nodes) {\n if (child.type === 'JSXText') {\n text += escapeText(cleanJsxText(child.value as string));\n } else if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression as AstNode;\n if (expr.type === 'JSXEmptyExpression') continue;\n if (expr.type === 'StringLiteral') {\n text += escapeText(expr.value as string);\n continue;\n }\n if (containsTaggedT(expr, names)) return undefined; // overlap hazard\n const source = code.slice(expr.start, expr.end);\n const name = uniqueName(deriveName(expr, params.length), source, takenParams);\n params.push({ name, start: expr.start, end: expr.end });\n text += `{${name}}`;\n } else if (child.type === 'JSXElement') {\n const opening = child.openingElement as AstNode;\n const nameNode = opening.name as AstNode;\n if (nameNode.type !== 'JSXIdentifier' || nameNode.name === 'Trans') return undefined;\n const source = selfClosedSource(code, opening);\n const tag = uniqueName((nameNode.name as string).toLowerCase(), source, takenTags);\n if (!components.some((c) => c.name === tag)) components.push({ name: tag, source });\n if (!child.closingElement) {\n text += `<${tag}/>`;\n } else {\n const inner = walkChildren(child.children as AstNode[]);\n if (inner === undefined) return undefined;\n text += `<${tag}>${inner}</${tag}>`;\n }\n } else {\n return undefined; // fragments / spread children → bail\n }\n }\n return text;\n }\n\n const text = walkChildren(children);\n if (text === undefined) return undefined;\n return { text, params, components };\n}\n\n// JSX text semantics: newline-indent boundaries removed, interior joins = one space\nexport function cleanJsxText(raw: string): string {\n const lines = raw.split(/\\r\\n|[\\r\\n]/);\n let out = '';\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i]!.replace(/\\t/g, ' ');\n if (i !== 0) line = line.replace(/^ +/, '');\n if (i !== lines.length - 1) line = line.replace(/ +$/, '');\n if (!line) continue;\n if (out && i !== 0) out += ' ';\n out += line;\n }\n return out;\n}\n\nfunction selfClosedSource(code: string, opening: AstNode): string {\n const src = code.slice(opening.start, opening.end);\n return src.endsWith('/>') ? src : `${src.slice(0, -1).trimEnd()} />`;\n}\n\n// true if the subtree holds a t`…` / t.id('…')`…` that analyze would extract itself\nfunction containsTaggedT(node: AstNode, names: ReadonlySet<string>): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type !== 'TaggedTemplateExpression') return;\n const tag = n.tag as AstNode;\n if (isTReference(tag, names) || explicitId(tag, names)) found = true;\n });\n return found;\n}\n\nexport function isTReference(node: AstNode, names: ReadonlySet<string>): boolean {\n if (node.type === 'Identifier') return names.has(node.name as string);\n if (node.type === 'MemberExpression' && !node.computed) {\n const prop = node.property as AstNode;\n return prop.type === 'Identifier' && names.has(prop.name as string);\n }\n return false;\n}\n\ninterface BuiltMessage {\n text: string;\n params: TaggedParam[];\n}\n\nfunction buildMessage(\n code: string,\n quasi: AstNode,\n names: ReadonlySet<string>,\n): BuiltMessage | undefined {\n const quasis = quasi.quasis as AstNode[];\n const expressions = quasi.expressions as AstNode[];\n const params: TaggedParam[] = [];\n const taken = new Map<string, string>();\n\n let text = escapeText(cookedValue(quasis[0]));\n\n for (let i = 0; i < expressions.length; i++) {\n const expr = expressions[i];\n if (!expr) return undefined;\n // a nested t`…` would be extracted on its own: overlapping rewrites; bail the outer\n if (containsTaggedT(expr, names)) return undefined;\n const source = code.slice(expr.start, expr.end);\n const name = uniqueName(deriveName(expr, i), source, taken);\n params.push({ name, start: expr.start, end: expr.end });\n text += `{${name}}` + escapeText(cookedValue(quasis[i + 1]));\n }\n return { text, params };\n}\n\nfunction cookedValue(element: AstNode | undefined): string {\n if (!element) return '';\n const value = element.value as { cooked?: string; raw: string };\n return value.cooked ?? value.raw;\n}\n\n// literal braces → escaped\nfunction escapeText(text: string): string {\n return text.replace(/[{}]/g, (m) => m + m);\n}\n\nfunction deriveName(expr: AstNode, index: number): string {\n if (expr.type === 'Identifier') return expr.name as string;\n if (expr.type === 'MemberExpression' && !expr.computed) {\n const prop = expr.property as AstNode;\n if (prop.type === 'Identifier') return prop.name as string;\n }\n return `_${index}`;\n}\n\nfunction uniqueName(base: string, source: string, taken: Map<string, string>): string {\n let name = base;\n let n = 2;\n while (taken.has(name) && taken.get(name) !== source) {\n name = `${base}${n}`;\n n += 1;\n }\n taken.set(name, source);\n return name;\n}\n\nexport function walk(node: AstNode, visit: (node: AstNode) => void): void {\n visit(node);\n for (const key in node) {\n if (SKIP_KEYS.has(key)) continue;\n const value = node[key];\n if (Array.isArray(value)) {\n for (const item of value) {\n if (isNode(item)) walk(item, visit);\n }\n } else if (isNode(value)) {\n walk(value, visit);\n }\n }\n}\n\nfunction isNode(value: unknown): value is AstNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { type?: unknown }).type === 'string'\n );\n}\n","import {\n analyze,\n parseErrorMessage,\n type Analysis,\n type StrayImport,\n type TaggedParam,\n type UsedKey,\n} from './analyze';\n\nexport const SFC_FILE_RE = /\\.(?:svelte|vue|astro)$/;\n\n// single dispatch point: SFCs get the block/markup analyzer, everything else plain analyze\nexport function analyzeFile(code: string, file: string): Analysis {\n if (SFC_FILE_RE.test(file)) return analyzeSfc(code, file);\n try {\n return analyze(code, file);\n } catch (error) {\n // one file the parser cannot read must never take down a whole extract, check or doctor\n return { tagged: [], usedKeys: [], strayImports: [], parseError: parseErrorMessage(error) };\n }\n}\n\nconst SCRIPT_RE = /(<script\\b[^>]*>)([\\s\\S]*?)(<\\/script\\s*>)/gi;\nconst STYLE_RE = /<style\\b[^>]*>[\\s\\S]*?<\\/style\\s*>/gi;\nconst COMMENT_RE = /<!--[\\s\\S]*?-->/g;\n// astro component script: --- fences at the top of the file\nconst FRONTMATTER_RE = /^(\\uFEFF?\\s*---\\r?\\n)([\\s\\S]*?)\\r?\\n---(?=\\r?\\n|$)/;\n\n// no whitespace after t: prose like \"won't ('x')\" must never become a used key\nconst CANDIDATE_SVELTE = /(?<![\\w$])\\$?t(?=[`(]|\\.id\\()/g;\nconst CANDIDATE_VUE = /(?<![\\w$])t(?=[`(]|\\.id\\()/g;\n\nconst MUSTACHE_RE = /\\{\\{[\\s\\S]*?\\}\\}/g;\nconst DIRECTIVE_RE = /\\s(?:v-[\\w-]+(?::[^\\s=>/]+)?|[:@][^\\s=>/]+)\\s*=\\s*(\"[^\"]*\"|'[^']*')/g;\n\nexport function analyzeSfc(code: string, file: string): Analysis {\n // svelte components consume t as a store: $t`…` is the idiomatic form\n const svelte = file.endsWith('.svelte');\n const options = svelte ? { tNames: ['t', '$t'] } : undefined;\n\n const tagged: Analysis['tagged'] = [];\n const usedKeys: UsedKey[] = [];\n const strayImports: StrayImport[] = [];\n let parseError: string | undefined;\n\n // a script block is structural: if it does not parse, the file is reported, unlike a markup slice\n const block = (segment: SegmentResult, offset: number): void => {\n parseError ??= segment.error;\n merge(segment.analysis, offset, false);\n };\n\n const frontmatter = file.endsWith('.astro') ? FRONTMATTER_RE.exec(code) : null;\n if (frontmatter?.[2]) {\n block(analyzeSegment(frontmatter[2], file, options), frontmatter[1]!.length);\n }\n\n for (const match of code.matchAll(SCRIPT_RE)) {\n const content = match[2]!;\n if (!content) continue;\n block(analyzeSegment(content, file, options), match.index + match[1]!.length);\n }\n\n // markup = everything left once frontmatter, scripts, styles and comments are blanked out\n const body = frontmatter\n ? ' '.repeat(frontmatter[0].length) + code.slice(frontmatter[0].length)\n : code;\n const markup = blank(blank(blank(body, SCRIPT_RE), STYLE_RE), COMMENT_RE);\n const candidates = svelte ? CANDIDATE_SVELTE : CANDIDATE_VUE;\n // display-only text never yields candidates: only expression context counts\n const ranges = file.endsWith('.vue') ? vueExpressionRanges(markup) : braceRanges(markup);\n let range = 0;\n let consumedTo = 0;\n for (const match of markup.matchAll(candidates)) {\n const start = match.index;\n if (start < consumedTo) continue;\n while (range < ranges.length && ranges[range]![1] <= start) range += 1;\n if (range >= ranges.length || start < ranges[range]![0]) continue;\n const end = expressionExtent(markup, start);\n if (end === undefined) continue;\n merge(analyzeSegment(code.slice(start, end), file, options).analysis, start, true);\n consumedTo = end;\n }\n\n return { tagged, usedKeys, strayImports, ...(parseError && { parseError }) };\n\n function merge(analysis: Analysis | undefined, offset: number, markupSegment: boolean): void {\n if (!analysis) return;\n for (const msg of analysis.tagged) {\n tagged.push({\n ...msg,\n start: msg.start + offset,\n end: msg.end + offset,\n tagStart: msg.tagStart + offset,\n tagEnd: msg.tagEnd + offset,\n params: msg.params.map((p): TaggedParam => ({\n ...p,\n start: p.start + offset,\n end: p.end + offset,\n })),\n ...(markupSegment && { singleQuote: true }),\n });\n }\n usedKeys.push(...analysis.usedKeys);\n strayImports.push(...analysis.strayImports);\n }\n}\n\ninterface SegmentResult {\n analysis?: Analysis;\n error?: string;\n}\n\nfunction analyzeSegment(code: string, file: string, options?: { tNames: string[] }): SegmentResult {\n try {\n return { analysis: analyze(code, file, options) };\n } catch (error) {\n return { error: parseErrorMessage(error) }; // never fail the whole file over one segment\n }\n}\n\nfunction blank(source: string, re: RegExp): string {\n return source.replace(re, (m) => ' '.repeat(m.length));\n}\n\n// [start, end) content spans of balanced {…} regions (astro expressions, svelte mustaches)\nfunction braceRanges(markup: string): Array<[number, number]> {\n const ranges: Array<[number, number]> = [];\n let i = 0;\n while (i < markup.length) {\n if (markup[i] === '{') {\n const end = balancedEnd(markup, i);\n if (end !== undefined) {\n ranges.push([i + 1, end - 1]);\n i = end;\n continue;\n }\n }\n i += 1;\n }\n return ranges;\n}\n\n// vue expression context: {{ mustaches }} plus quoted values of :/@/v- directive attributes\nfunction vueExpressionRanges(markup: string): Array<[number, number]> {\n const ranges: Array<[number, number]> = [];\n for (const match of markup.matchAll(MUSTACHE_RE)) {\n ranges.push([match.index + 2, match.index + match[0].length - 2]);\n }\n for (const match of markup.matchAll(DIRECTIVE_RE)) {\n const valueStart = match.index + match[0].length - match[1]!.length + 1;\n ranges.push([valueStart, valueStart + match[1]!.length - 2]);\n }\n return ranges.sort((a, b) => a[0] - b[0]);\n}\n\n// end (exclusive) of the expression starting at a candidate: t`…` | t(...) | t.id('…')`…`\nfunction expressionExtent(code: string, start: number): number | undefined {\n let i = start;\n if (code[i] === '$') i += 1;\n i += 1; // the t itself\n if (code.startsWith('.id(', i)) {\n const close = balancedEnd(code, i + 3);\n if (close === undefined || code[close] !== '`') return undefined;\n return balancedEnd(code, close);\n }\n if (code[i] === '`' || code[i] === '(') return balancedEnd(code, i);\n return undefined;\n}\n\n// scans a template literal or paren group to its close, tracking nested ${…}, strings and groups\nfunction balancedEnd(code: string, open: number): number | undefined {\n const stack: string[] = [];\n let i = open;\n while (i < code.length) {\n const ch = code[i]!;\n if (stack[stack.length - 1] === '`') {\n if (ch === '\\\\') i += 1;\n else if (ch === '`') stack.pop();\n else if (ch === '$' && code[i + 1] === '{') {\n stack.push('{');\n i += 1;\n }\n } else if (ch === \"'\" || ch === '\"') {\n i = stringEnd(code, i);\n } else if (ch === '`' || ch === '(' || ch === '{') {\n stack.push(ch);\n } else if (ch === ')' || ch === '}') {\n if (stack[stack.length - 1] !== (ch === ')' ? '(' : '{')) return undefined;\n stack.pop();\n }\n i += 1;\n if (stack.length === 0) return i;\n }\n return undefined;\n}\n\nfunction stringEnd(code: string, start: number): number {\n const quote = code[start];\n let i = start + 1;\n while (i < code.length) {\n if (code[i] === '\\\\') i += 2;\n else if (code[i] === quote) return i;\n else i += 1;\n }\n return code.length;\n}\n","import { readFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { glob } from 'tinyglobby';\nimport type { Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport { MessageRegistry } from './registry';\nimport { analyzeFile } from './sfc';\n\nexport async function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry> {\n const files = await glob(cfg.include, {\n cwd: cfg.root,\n ignore: cfg.exclude,\n absolute: true,\n });\n const registry = new MessageRegistry();\n for (const file of files) {\n registry.update(file, analyzeFile(readFileSync(file, 'utf8'), file));\n }\n return registry;\n}\n\n// root-relative, forward slashes: paths a translator can read on any OS\nexport async function collectOrigins(cfg: ResolvedConfig): Promise<Record<string, string[]>> {\n const registry = await extractProject(cfg);\n const origins: Record<string, string[]> = {};\n for (const [key, files] of registry.origins()) {\n origins[key] = files.map((file) => relative(cfg.root, file).replaceAll('\\\\', '/'));\n }\n return origins;\n}\n\nexport interface SyncResult {\n added: Record<string, string[]>;\n}\n\n// fills source texts + '' placeholders\nexport function syncCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): SyncResult {\n const added: Record<string, string[]> = {};\n const source = (catalogs[cfg.sourceLocale] ??= {});\n\n for (const [key, msg] of registry.messages()) {\n if (source[key] !== msg.message) {\n source[key] = msg.message;\n (added[cfg.sourceLocale] ??= []).push(key);\n }\n }\n\n const needed = Object.keys(source);\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n const catalog = (catalogs[locale] ??= {});\n for (const key of needed) {\n if (catalog[key] === undefined) {\n catalog[key] = '';\n (added[locale] ??= []).push(key);\n }\n }\n }\n return { added };\n}\n\n// drops keys no longer referenced\nexport function pruneCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): Record<string, string[]> {\n const keep = new Set([...registry.messages().keys(), ...registry.usedKeys().keys()]);\n const removed: Record<string, string[]> = {};\n for (const locale of cfg.locales) {\n const catalog = catalogs[locale];\n if (!catalog) continue;\n for (const key of Object.keys(catalog)) {\n if (!keep.has(key)) {\n delete catalog[key];\n (removed[locale] ??= []).push(key);\n }\n }\n }\n return removed;\n}\n","import { parse, type MessageNode } from 'verbaly';\n\nexport const PLURAL_CATEGORIES = new Set(['zero', 'one', 'two', 'few', 'many']);\nexport type IssueSeverity = 'error' | 'warning';\n\nexport interface StructureIssue {\n severity: IssueSeverity;\n message: string;\n}\n\ninterface VariantShape {\n selectors: string[];\n plural: boolean;\n ordinal: boolean;\n}\n\nconst EXACT = /^=\\d+$/;\n\n// param name → its plural/select block, when it has one; first block per name wins\nfunction shapes(message: string): Map<string, VariantShape> {\n const out = new Map<string, VariantShape>();\n walk(parse(message), out);\n return out;\n}\n\nfunction walk(nodes: MessageNode[], out: Map<string, VariantShape>): void {\n for (const node of nodes) {\n if (node.kind !== 'param' || !node.variants) continue;\n const selectors = node.variants.map(([key]) => key);\n if (!out.has(node.name)) {\n out.set(node.name, {\n selectors,\n plural: selectors.some((key) => PLURAL_CATEGORIES.has(key)),\n ordinal: node.ordinal === true,\n });\n }\n for (const [, body] of node.variants) walk(body, out);\n }\n}\n\nfunction paramNames(message: string): string[] {\n const names = new Set<string>();\n collect(parse(message), names);\n return [...names].sort();\n}\n\nfunction collect(nodes: MessageNode[], out: Set<string>): void {\n for (const node of nodes) {\n if (node.kind !== 'param') continue;\n out.add(node.name);\n if (node.variants) for (const [, body] of node.variants) collect(body, out);\n }\n}\n\nconst TAG = /<(\\/?)([a-zA-Z][\\w-]*)(\\/?)>/g;\n\n// markup is only what the message closes (</x>) or self-closes (<x/>): a lone <Enter> is prose\nfunction markupNames(message: string): Set<string> {\n const out = new Set<string>();\n for (const match of message.matchAll(TAG)) {\n if (match[1] || match[3]) out.add(match[2]!);\n }\n return out;\n}\n\nfunction tagTokens(message: string, markup: Set<string>): string[] {\n const out: string[] = [];\n for (const match of message.matchAll(TAG)) {\n if (markup.has(match[2]!)) out.push(`${match[1]}${match[2]}${match[3]}`);\n }\n return out.sort();\n}\n\n// items in a that are missing from b, counting duplicates\nfunction surplus(a: string[], b: string[]): string[] {\n const rest = [...b];\n const out: string[] = [];\n for (const item of a) {\n const at = rest.indexOf(item);\n if (at < 0) out.push(item);\n else rest.splice(at, 1);\n }\n return out;\n}\n\nfunction list(items: string[]): string {\n return items.length > 1\n ? `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`\n : items[0]!;\n}\n\n// a tagged template escapes its own braces, so a block written inside one ships as literal text\nconst ESCAPED_SYNTAX = /(?<!\\{)\\{\\{\\s*[\\w.]+\\s*[|:][^{}]*\\}\\}/;\n\n// the escaped slice of an extracted message, when the author meant a plural or format block\nexport function escapedSyntax(message: string): string | undefined {\n return ESCAPED_SYNTAX.exec(message)?.[0];\n}\n\n// one message on its own: defects that need no source to be visible\nexport function validateMessage(message: string, locale?: string): StructureIssue[] {\n const issues: StructureIssue[] = [];\n for (const [name, shape] of shapes(message)) {\n if (!shape.plural) continue; // a select block without 'other' is the author's design\n if (!shape.selectors.includes('other')) {\n issues.push({\n severity: 'error',\n message: `the plural block for {${name}} has no \"other\" case, so any count it does not list renders empty`,\n });\n continue;\n }\n if (!locale) continue;\n const missing = reachableCategories(locale, shape.ordinal).filter(\n (category) => category !== 'other' && !shape.selectors.includes(category),\n );\n if (missing.length > 0) {\n issues.push({\n severity: 'warning',\n message: `${locale} also needs the ${list(missing)} plural ${missing.length > 1 ? 'forms' : 'form'} for {${name}}`,\n });\n }\n }\n return issues;\n}\n\n// a translation against the source it must mirror\nexport function validatePair(source: string, translated: string): StructureIssue[] {\n const issues: StructureIssue[] = [];\n\n const lostParams = surplus(paramNames(source), paramNames(translated));\n const newParams = surplus(paramNames(translated), paramNames(source));\n if (lostParams.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(lostParams.map((name) => `{${name}}`))} ${lostParams.length > 1 ? 'are' : 'is'} missing, so ${lostParams.length > 1 ? 'their values' : 'its value'} never reaches the text`,\n });\n }\n if (newParams.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(newParams.map((name) => `{${name}}`))} ${newParams.length > 1 ? 'are' : 'is'} not in the source message, so ${newParams.length > 1 ? 'they render' : 'it renders'} as literal text`,\n });\n }\n\n // one vocabulary for both sides: a tag the translation invents is still caught\n const markup = new Set([...markupNames(source), ...markupNames(translated)]);\n const lostTags = tagReport(surplus(tagTokens(source, markup), tagTokens(translated, markup)));\n const newTags = tagReport(surplus(tagTokens(translated, markup), tagTokens(source, markup)));\n if (lostTags.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(lostTags)} ${lostTags.length > 1 ? 'are' : 'is'} missing from the translation`,\n });\n }\n if (newTags.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(newTags)} ${newTags.length > 1 ? 'are' : 'is'} not in the source message`,\n });\n }\n\n const target = shapes(translated);\n for (const [name, shape] of shapes(source)) {\n const other = target.get(name);\n if (!other) {\n issues.push({\n severity: 'error',\n message: `the ${shape.plural ? 'plural' : 'select'} block for {${name}} was flattened into plain text`,\n });\n continue;\n }\n // 'other' is the catch-all: losing it renders empty (the plural case is validateMessage's)\n if (shape.selectors.includes('other') && !other.selectors.includes('other') && !other.plural) {\n issues.push({\n severity: 'error',\n message: `the \"other\" case for {${name}} is missing, so unlisted values render empty`,\n });\n }\n const lostExact = shape.selectors\n .filter((key) => EXACT.test(key))\n .filter((key) => !other.selectors.includes(key));\n if (lostExact.length > 0) {\n issues.push({\n severity: 'warning',\n message: `the ${list(lostExact)} ${lostExact.length > 1 ? 'cases' : 'case'} for {${name}} ${lostExact.length > 1 ? 'are' : 'is'} missing, so ${lostExact.length > 1 ? 'those counts' : 'that count'} falls back to \"other\"`,\n });\n }\n }\n\n return issues;\n}\n\n// one entry per tag name: a translator restores the pair, not a lone closing tag\nfunction tagReport(tokens: string[]): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n for (const token of tokens) {\n const name = token.replaceAll('/', '');\n if (seen.has(name)) continue;\n seen.add(name);\n out.push(token.endsWith('/') ? `<${name}/>` : `<${name}>`);\n }\n return out;\n}\n\nconst COUNT_PROBE = 200; // the range a UI counter realistically reaches\nconst reachable = new Map<string, string[]>();\n\nfunction reachableCategories(locale: string, ordinal: boolean): string[] {\n const type = ordinal ? 'ordinal' : 'cardinal';\n // the escape, never the raw character: a literal NUL makes git treat the file as binary\n const cacheKey = `${locale}\\u0000${type}`;\n const hit = reachable.get(cacheKey);\n if (hit) return hit;\n\n let out: string[];\n try {\n const rules = new Intl.PluralRules(locale, { type });\n const seen = new Set<string>();\n for (let n = 0; n <= COUNT_PROBE; n++) seen.add(rules.select(n));\n out = [...seen];\n } catch {\n out = []; // unknown tag: nothing is ever reported missing\n }\n reachable.set(cacheKey, out);\n return out;\n}\n","import { parse, type MessageNode } from 'verbaly';\nimport { PLURAL_CATEGORIES } from './validate';\n\nexport type ParamType = 'number' | 'string' | 'date' | 'unknown';\n\nconst NUMBER_FORMATS = new Set(['number', 'integer', 'percent', 'currency']);\nconst DATE_FORMATS = new Set(['date', 'time']);\n\nexport function collectParams(message: string): Map<string, Set<ParamType>> {\n const out = new Map<string, Set<ParamType>>();\n visit(parse(message), out);\n return out;\n}\n\nfunction visit(nodes: MessageNode[], out: Map<string, Set<ParamType>>): void {\n for (const node of nodes) {\n if (node.kind !== 'param') continue;\n const types = out.get(node.name) ?? new Set<ParamType>();\n out.set(node.name, types);\n\n if (node.variants) {\n for (const [key, body] of node.variants) {\n if (PLURAL_CATEGORIES.has(key) || /^=\\d+$/.test(key)) types.add('number');\n else if (key !== 'other') types.add('string');\n visit(body, out);\n }\n if (types.size === 0) types.add('string');\n } else if (node.format && NUMBER_FORMATS.has(node.format)) {\n types.add('number');\n } else if (node.format && DATE_FORMATS.has(node.format)) {\n types.add('date');\n } else {\n types.add('unknown');\n }\n }\n}\n\nexport function renderParamType(types: Set<ParamType>): string {\n if (types.has('unknown') || types.size === 0) return 'unknown';\n const members = new Set<string>();\n if (types.has('number')) members.add('number');\n if (types.has('string')) members.add('string');\n if (types.has('date')) for (const m of ['Date', 'number', 'string']) members.add(m);\n return [...members].join(' | ');\n}\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { Catalog } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport { collectParams, renderParamType } from './params';\n\nexport const VIRTUAL_ID = 'virtual:verbaly';\n\nexport interface RuntimeModuleOptions {\n localeImport?: (locale: string) => string;\n extraExports?: string;\n}\n\nexport function generateRuntimeModule(\n cfg: ResolvedConfig,\n options: RuntimeModuleOptions = {},\n): string {\n const importPath = options.localeImport ?? ((locale: string) => `${VIRTUAL_ID}/locale/${locale}`);\n const others = cfg.locales.filter((locale) => locale !== cfg.sourceLocale);\n const src = JSON.stringify(cfg.sourceLocale);\n const loaders = others\n .map((locale) => ` ${JSON.stringify(locale)}: () => import('${importPath(locale)}'),`)\n .join('\\n');\n\n return `import { createVerbaly } from 'verbaly';\nimport source from '${importPath(cfg.sourceLocale)}';\n\nexport const sourceLocale = ${src};\nexport const locales = ${JSON.stringify(cfg.locales)};\n\nconst localeLoaders = {\n${loaders}\n};\n\n// raw catalog access: SSR integrations serialize it across the client boundary\nexport async function loadMessages(locale) {\n if (locale === ${src}) return source;\n const loader = localeLoaders[locale];\n return loader ? (await loader()).default : {};\n}\n\n// per-request/per-instance factory (SSR): the singleton below is browser/SPA-only\nexport function createInstance(options) {\n return createVerbaly({\n locale: ${src},\n fallback: ${src},\n messages: { [${src}]: source },\n loaders: localeLoaders,\n ...options,\n });\n}\n\n// the no-FOUC contract in one call: fresh instance + catalog awaited before render\nexport async function createRequestInstance(locale) {\n const instance = createInstance({ locale });\n await instance.loadLocale(locale);\n return instance;\n}\n\nconst v = createInstance();\n\nexport const verbaly = v;\nexport const t = v.t;\n\nexport function getLocale() {\n return v.locale;\n}\n\nexport function subscribe(listener) {\n return v.subscribe(listener);\n}\n\nexport async function setLocale(locale) {\n await v.loadLocale(locale);\n v.setLocale(locale);\n}\n${options.extraExports ?? ''}`;\n}\n\nexport function generateLocaleModule(catalog: Catalog): string {\n return `export default ${JSON.stringify(catalog)};\\n`;\n}\n\nexport function generateDts(catalog: Catalog): string {\n const lines: string[] = [];\n for (const [key, message] of Object.entries(catalog).sort(([a], [b]) => a.localeCompare(b))) {\n const params = collectParams(message);\n if (params.size === 0) {\n lines.push(` ${JSON.stringify(key)}: never;`);\n } else {\n const fields = [...params.entries()]\n .map(([name, types]) => `${JSON.stringify(name)}: ${renderParamType(types)}`)\n .join('; ');\n lines.push(` ${JSON.stringify(key)}: { ${fields} };`);\n }\n }\n\n return `// generated by verbaly: do not edit\ndeclare module 'virtual:verbaly' {\n export interface VerbalyMessages {\n${lines.join('\\n')}\n }\n export type VerbalyKey = keyof VerbalyMessages & string;\n\n export const verbaly: import('verbaly').Verbaly<VerbalyKey>;\n\n export const sourceLocale: string;\n export const locales: string[];\n export function loadMessages(locale: string): Promise<Record<string, string>>;\n export function createInstance(\n options?: import('verbaly').VerbalyOptions<VerbalyKey>,\n ): import('verbaly').Verbaly<VerbalyKey>;\n export function createRequestInstance(\n locale: string,\n ): Promise<import('verbaly').Verbaly<VerbalyKey>>;\n\n export function t<K extends VerbalyKey>(\n key: K,\n ...args: [VerbalyMessages[K]] extends [never] ? [] : [VerbalyMessages[K]]\n ): string;\n export function t(strings: TemplateStringsArray, ...values: unknown[]): string;\n export namespace t {\n export function id(\n key: string,\n ): (strings: TemplateStringsArray, ...values: unknown[]) => string;\n }\n\n export function setLocale(locale: string): Promise<void>;\n export function getLocale(): string;\n export function subscribe(listener: () => void): () => void;\n}\n\ndeclare module 'virtual:verbaly/locale/*' {\n const messages: Record<string, string>;\n export default messages;\n}\n`;\n}\n\n// unchanged writes are skipped: a rewritten verbaly.d.ts churns the consumer's TS server\nexport function writeDts(cfg: ResolvedConfig, catalog: Catalog, file?: string): void {\n file ??= join(cfg.root, 'verbaly.d.ts');\n const content = generateDts(catalog);\n try {\n if (readFileSync(file, 'utf8') === content) return;\n } catch {\n // new file\n }\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, content);\n}\n","import { readFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport type { MessageRegistry } from './registry';\nimport { validateMessage, validatePair, type IssueSeverity, type StructureIssue } from './validate';\n\nexport interface MissingEntry {\n locale: string;\n key: string;\n source?: string;\n}\n\nexport interface UnknownEntry {\n key: string;\n files: string[];\n}\n\nexport interface BrokenEntry {\n locale: string;\n key: string;\n severity: IssueSeverity;\n issue: string;\n}\n\nexport interface CheckResult {\n ok: boolean;\n missing: MissingEntry[];\n unknown: UnknownEntry[];\n broken: BrokenEntry[];\n}\n\nexport function gatePasses(result: Omit<CheckResult, 'ok'>): boolean {\n return (\n result.missing.length === 0 &&\n result.unknown.length === 0 &&\n !result.broken.some((entry) => entry.severity === 'error')\n );\n}\n\nexport function check(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): CheckResult {\n const extracted = registry.messages();\n\n // one flat view per locale: the shape t() sees, so nested catalogs compare leaf by leaf\n const flat: Record<string, Catalog> = {};\n for (const locale of cfg.locales) {\n flat[locale] = flatten((catalogs[locale] ?? {}) as MessageTree);\n }\n const source = flat[cfg.sourceLocale] ?? {};\n\n const unknown: UnknownEntry[] = [];\n for (const [key, files] of registry.usedKeys()) {\n const known =\n extracted.has(key) || cfg.locales.some((locale) => flat[locale]?.[key] !== undefined);\n if (!known) unknown.push({ key, files });\n }\n\n const needed = new Set<string>([...extracted.keys(), ...Object.keys(source)]);\n\n const missing: MissingEntry[] = [];\n for (const key of extracted.keys()) {\n if (!source[key]) {\n missing.push({ locale: cfg.sourceLocale, key, source: extracted.get(key)?.message });\n }\n }\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n for (const key of needed) {\n if (!flat[locale]?.[key]) {\n missing.push({ locale, key, source: source[key] ?? extracted.get(key)?.message });\n }\n }\n }\n\n // presence is not correctness: a translation can be there and still render wrong\n const broken: BrokenEntry[] = [];\n const add = (locale: string, key: string, issues: StructureIssue[]): void => {\n for (const issue of issues) {\n broken.push({ locale, key, severity: issue.severity, issue: issue.message });\n }\n };\n\n // a key can be used in code before it reaches the catalog: validate that text too\n const sourceText: Catalog = { ...source };\n for (const [key, entry] of extracted) {\n if (!sourceText[key]) sourceText[key] = entry.message;\n }\n for (const [key, text] of Object.entries(sourceText)) {\n add(cfg.sourceLocale, key, validateMessage(text, cfg.sourceLocale));\n }\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n for (const [key, translated] of Object.entries(flat[locale] ?? {})) {\n if (!translated) continue; // '' is untranslated, already reported as missing\n add(locale, key, validateMessage(translated, locale));\n const text = sourceText[key];\n if (text) add(locale, key, validatePair(text, translated));\n }\n }\n\n return { ok: gatePasses({ missing, unknown, broken }), missing, unknown, broken };\n}\n\nexport function formatCheckResult(result: CheckResult): string {\n const lines: string[] = [];\n if (result.missing.length > 0) {\n lines.push('missing translations:');\n for (const entry of result.missing) {\n const hint = entry.source ? `: \"${truncate(entry.source, 40)}\"` : '';\n lines.push(` [${entry.locale}] ${entry.key}${hint}`);\n }\n }\n if (result.unknown.length > 0) {\n lines.push('unknown keys (not in any catalog):');\n for (const entry of result.unknown) {\n lines.push(` ${entry.key} (used in ${entry.files.join(', ')})`);\n }\n }\n const errors = result.broken.filter((entry) => entry.severity === 'error');\n if (errors.length > 0) {\n lines.push('broken translations:');\n for (const entry of errors) lines.push(` [${entry.locale}] ${entry.key}: ${entry.issue}`);\n }\n return lines.join('\\n');\n}\n\n// what to do about each kind of failure: extract only fixes one of the three\nexport function checkNextSteps(result: CheckResult): string {\n const steps: string[] = [];\n if (result.missing.length > 0) {\n steps.push(\n 'missing: run `npx verbaly extract` to scaffold the keys, then fill them (or run `npx verbaly translate`)',\n );\n }\n if (result.unknown.length > 0) {\n steps.push(\n 'unknown keys: the key used in the code is in no catalog, fix the key or run `npx verbaly extract`',\n );\n }\n if (result.broken.some((entry) => entry.severity === 'error')) {\n steps.push(\n 'broken: a translation has to keep the params, tags and plural cases of its source message',\n );\n }\n return steps.join('\\n');\n}\n\n// warnings never fail the gate, so they print on their own\nexport function formatCheckWarnings(result: CheckResult): string {\n return result.broken\n .filter((entry) => entry.severity === 'warning')\n .map((entry) => ` [${entry.locale}] ${entry.key}: ${entry.issue}`)\n .join('\\n');\n}\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? text.slice(0, max - 1) + '…' : text;\n}\n\n// GitHub workflow commands: every failure becomes a clickable ::error annotation on the PR\nexport function githubCheckAnnotations(\n result: CheckResult,\n registry: MessageRegistry,\n root: string,\n): string[] {\n const messages = registry.messages();\n const contents = new Map<string, string | undefined>();\n const readSource = (file: string): string | undefined => {\n if (!contents.has(file)) {\n try {\n contents.set(file, readFileSync(file, 'utf8'));\n } catch {\n contents.set(file, undefined);\n }\n }\n return contents.get(file);\n };\n\n const lines: string[] = [];\n\n // one annotation per key, locales grouped: N locales must not bury the PR in N copies\n const byKey = new Map<string, MissingEntry & { locales: string[] }>();\n for (const entry of result.missing) {\n const grouped = byKey.get(entry.key);\n if (grouped) grouped.locales.push(entry.locale);\n else byKey.set(entry.key, { ...entry, locales: [entry.locale] });\n }\n\n for (const entry of byKey.values()) {\n const origin = messages.get(entry.key);\n const hint = entry.source ? `: \"${truncate(entry.source, 60)}\"` : '';\n const text = escapeData(`missing [${entry.locales.join(', ')}] ${entry.key}${hint}`);\n if (origin) {\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::error file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n } else {\n lines.push(`::error::${text}`);\n }\n }\n\n for (const entry of result.unknown) {\n const text = escapeData(`unknown key \"${entry.key}\" (not in any catalog)`);\n const file = entry.files[0];\n lines.push(\n file\n ? `::error file=${escapeProperty(relative(root, file).replaceAll('\\\\', '/'))}::${text}`\n : `::error::${text}`,\n );\n }\n\n // a broken translation points at the source line that wrote the message\n for (const entry of result.broken) {\n const origin = messages.get(entry.key);\n const text = escapeData(`[${entry.locale}] ${entry.key}: ${entry.issue}`);\n const command = entry.severity === 'error' ? 'error' : 'warning';\n if (!origin) {\n lines.push(`::${command}::${text}`);\n continue;\n }\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::${command} file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n }\n return lines;\n}\n\nfunction lineAt(content: string, offset: number): number {\n let line = 1;\n const end = Math.min(offset, content.length);\n for (let i = 0; i < end; i++) {\n if (content[i] === '\\n') line += 1;\n }\n return line;\n}\n\nfunction escapeData(text: string): string {\n return text.replaceAll('%', '%25').replaceAll('\\r', '%0D').replaceAll('\\n', '%0A');\n}\n\nfunction escapeProperty(text: string): string {\n return escapeData(text).replaceAll(':', '%3A').replaceAll(',', '%2C');\n}\n","import MagicString from 'magic-string';\nimport type { Analysis } from './analyze';\nimport { analyzeFile } from './sfc';\nimport { warnParseError } from './warn';\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n}\n\nfunction quote(text: string, single: boolean | undefined): string {\n if (!single) return JSON.stringify(text);\n return `'${text.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n}\n\nexport function transformCode(\n code: string,\n file: string,\n analysis?: Analysis,\n): TransformResult | null {\n const own = analysis ?? analyzeFile(code, file);\n if (!analysis && own.parseError) warnParseError(file, own.parseError);\n const { tagged } = own;\n if (tagged.length === 0) return null;\n\n const s = new MagicString(code);\n for (const msg of tagged) {\n const seen = new Set<string>();\n const entries = msg.params.filter((p) => !seen.has(p.name) && seen.add(p.name));\n const pairs = entries\n .map((p) => `${quote(p.name, msg.singleQuote)}: ${code.slice(p.start, p.end)}`)\n .join(', ');\n\n if (msg.jsx) {\n const values = entries.length ? ` values={{ ${pairs} }}` : '';\n const components = msg.jsx.components.length\n ? ` components={{ ${msg.jsx.components\n .map((c) => `${JSON.stringify(c.name)}: ${c.source}`)\n .join(', ')} }}`\n : '';\n s.overwrite(\n msg.start,\n msg.end,\n `<${msg.jsx.name} id=${JSON.stringify(msg.key)}${values}${components} />`,\n );\n continue;\n }\n\n const tagSource = code.slice(msg.tagStart, msg.tagEnd);\n const args = entries.length ? `, { ${pairs} }` : '';\n s.overwrite(msg.start, msg.end, `${tagSource}(${quote(msg.key, msg.singleQuote)}${args})`);\n }\n return { code: s.toString(), map: s.generateMap({ hires: true }) };\n}\n","import { relative } from 'node:path';\nimport picomatch from 'picomatch';\nimport { loadCatalogs, type Catalog, type Catalogs } from './catalog';\nimport { check, checkNextSteps, formatCheckResult, gatePasses } from './check';\nimport { VIRTUAL_ID, generateLocaleModule, generateRuntimeModule } from './codegen';\nimport type { ResolvedConfig, VerbalyConfig } from './config';\nimport type { MessageRegistry } from './registry';\nimport { analyzeFile } from './sfc';\nimport { transformCode, type TransformResult } from './transform';\nimport { warnParseError } from './warn';\n\nexport interface PluginOptions extends VerbalyConfig {\n failOnMissing?: boolean;\n}\n\nexport const RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID;\nexport const LOCALE_MODULE_PREFIX = `${RESOLVED_VIRTUAL_ID}/locale/`;\nexport const SOURCE_FILE_RE = /\\.(?:[cm]?[jt]sx?|svelte|vue|astro)$/;\n\nexport function resolveVirtualId(id: string): string | undefined {\n if (id === VIRTUAL_ID || id.startsWith(`${VIRTUAL_ID}/`)) return '\\0' + id;\n return undefined;\n}\n\nexport function loadVirtualModule(\n id: string,\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n): string | undefined {\n if (id === RESOLVED_VIRTUAL_ID) return generateRuntimeModule(cfg);\n if (id.startsWith(LOCALE_MODULE_PREFIX)) {\n return generateLocaleModule(catalogs[id.slice(LOCALE_MODULE_PREFIX.length)] ?? {});\n }\n return undefined;\n}\n\nexport function isTransformTarget(id: string): boolean {\n return SOURCE_FILE_RE.test(id) && !id.includes('node_modules') && !id.startsWith('\\0');\n}\n\nexport function createSourceFilter(cfg: ResolvedConfig): (id: string) => boolean {\n if (cfg.include.length === 0) return () => false;\n const matches = picomatch(cfg.include, { ignore: cfg.exclude });\n return (id) => {\n const rel = relative(cfg.root, id).replaceAll('\\\\', '/');\n return !rel.startsWith('..') && matches(rel);\n };\n}\n\n// analyze + register + rewrite: the per-file transform every bundler plugin runs\nexport function transformSource(\n code: string,\n id: string,\n registry: MessageRegistry,\n): { messages: Catalog; result: TransformResult | null } {\n const analysis = analyzeFile(code, id);\n registry.update(id, analysis);\n if (analysis.parseError) warnParseError(id, analysis.parseError);\n // key → text for live extraction; first wins, mirroring the registry's collision rule\n const messages: Catalog = {};\n for (const msg of analysis.tagged) messages[msg.key] ??= msg.message;\n return { messages, result: transformCode(code, id, analysis) ?? null };\n}\n\n// the one build-blocking error message, kept in one place (undefined = gate on)\nexport function runBuildGate(\n cfg: ResolvedConfig,\n registry: MessageRegistry,\n failOnMissing?: boolean,\n): void {\n const found = check(cfg, loadCatalogs(cfg), registry);\n // false = build with untranslated strings, never with broken ones: those render wrong\n const result = failOnMissing === false ? { ...found, missing: [] } : found;\n if (gatePasses(result)) return;\n throw new Error(\n `[verbaly] build blocked\\n${formatCheckResult(result)}\\n${checkNextSteps(result)}`,\n );\n}\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\n\nexport const DRAFTS_FILE = '.verbaly-drafts.json';\n\nexport type Drafts = Record<string, string[]>;\n\nfunction draftsPath(cfg: ResolvedConfig): string {\n return join(cfg.dir, DRAFTS_FILE);\n}\n\nexport function loadDrafts(cfg: ResolvedConfig): Drafts {\n let content: string;\n try {\n content = readFileSync(draftsPath(cfg), 'utf8');\n } catch {\n return {};\n }\n try {\n return JSON.parse(content.replace(/^\\uFEFF/, '')) as Drafts;\n } catch (error) {\n throw new Error(`[verbaly] ${draftsPath(cfg)} is not valid JSON, fix or delete the file`, {\n cause: error,\n });\n }\n}\n\nfunction serializeDrafts(drafts: Drafts): string {\n const sorted: Drafts = {};\n for (const locale of Object.keys(drafts).sort()) {\n const keys = [...new Set(drafts[locale])].sort();\n if (keys.length) sorted[locale] = keys;\n }\n return JSON.stringify(sorted, null, 2) + '\\n';\n}\n\n// content-compared like catalogs: an unchanged write must not churn the file\nexport function saveDrafts(cfg: ResolvedConfig, drafts: Drafts): void {\n const serialized = serializeDrafts(drafts);\n const path = draftsPath(cfg);\n try {\n if (readFileSync(path, 'utf8') === serialized) return;\n } catch {\n mkdirSync(cfg.dir, { recursive: true });\n }\n writeFileSync(path, serialized);\n}\n\nexport function markDrafts(drafts: Drafts, locale: string, keys: string[]): void {\n if (!keys.length) return;\n drafts[locale] = [...new Set([...(drafts[locale] ?? []), ...keys])];\n}\n\n// clears specific keys, or the whole locale when keys is omitted (approve everything)\nexport function clearDrafts(drafts: Drafts, locale: string, keys?: string[]): void {\n if (!drafts[locale]) return;\n if (!keys) {\n delete drafts[locale];\n return;\n }\n const drop = new Set(keys);\n drafts[locale] = drafts[locale].filter((key) => !drop.has(key));\n if (!drafts[locale].length) delete drafts[locale];\n}\n\n// a draft counts only while its translation is present: a pruned key is missing, not a draft\nexport function effectiveDrafts(drafts: Drafts, catalogs: Catalogs): Drafts {\n const out: Drafts = {};\n for (const [locale, keys] of Object.entries(drafts)) {\n const catalog = catalogs[locale] ?? {};\n const live = keys.filter((key) => catalog[key]);\n if (live.length) out[locale] = live;\n }\n return out;\n}\n","// counts read like text, so the tool that translates apps never prints \"1 messages\"\nexport function counted(count: number, noun: string, many = `${noun}s`): string {\n return `${count} ${count === 1 ? noun : many}`;\n}\n","import type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport { effectiveDrafts, type Drafts } from './drafts';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { MessageRegistry } from './registry';\nimport { counted } from './text';\nimport { validateMessage, validatePair } from './validate';\n\nexport interface LocaleStatus {\n locale: string;\n translated: number;\n total: number;\n drafts: number;\n broken: number;\n}\n\nexport interface StatusResult {\n messages: number;\n source: string;\n locales: LocaleStatus[];\n}\n\n// coverage overview for humans; check stays the CI gate\nexport function status(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n drafts: Drafts = {},\n): StatusResult {\n const extracted = registry.messages();\n\n // one flat view per locale, like check: the shape t() sees, counted leaf by leaf\n const flat: Record<string, Catalog> = {};\n for (const locale of cfg.locales) {\n flat[locale] = flatten((catalogs[locale] ?? {}) as MessageTree);\n }\n const source = flat[cfg.sourceLocale] ?? {};\n const needed = new Set<string>([...extracted.keys(), ...Object.keys(source)]);\n const live = effectiveDrafts(drafts, flat);\n\n const locales: LocaleStatus[] = [];\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n const catalog = flat[locale] ?? {};\n let translated = 0;\n for (const key of needed) {\n if (catalog[key]) translated += 1;\n }\n let broken = 0;\n for (const [key, text] of Object.entries(catalog)) {\n if (!text) continue;\n const from = source[key] ?? extracted.get(key)?.message;\n const issues = [...validateMessage(text, locale), ...(from ? validatePair(from, text) : [])];\n if (issues.some((issue) => issue.severity === 'error')) broken += 1;\n }\n locales.push({\n locale,\n translated,\n total: needed.size,\n drafts: live[locale]?.length ?? 0,\n broken,\n });\n }\n return { messages: needed.size, source: cfg.sourceLocale, locales };\n}\n\nexport function formatStatusResult(result: StatusResult): string {\n const lines = [`[verbaly] ${counted(result.messages, 'message')} · source: ${result.source}`];\n if (result.locales.length === 0) {\n lines.push(' no target locales (add locales to your config)');\n return lines.join('\\n');\n }\n for (const { locale, translated, total, drafts, broken } of result.locales) {\n const pct = total === 0 ? 100 : Math.floor((translated / total) * 100);\n const mark = translated === total && broken === 0 ? ' ✓' : '';\n const notes = [\n drafts > 0 ? `${drafts} unreviewed` : '',\n broken > 0 ? `${broken} broken` : '',\n ].filter(Boolean);\n const note = notes.length > 0 ? `, ${notes.join(', ')}` : '';\n lines.push(` ${locale}: ${translated}/${total} translated (${pct}%${note})${mark}`);\n }\n return lines.join('\\n');\n}\n","import type { Catalogs } from './catalog';\nimport { targetLocales, type ResolvedConfig } from './config';\nimport { counted } from './text';\nimport { validateMessage, validatePair } from './validate';\n\nexport interface TranslateRequest {\n sourceLocale: string;\n targetLocale: string;\n messages: Record<string, string>;\n origins?: Record<string, string[]>;\n instructions?: string;\n glossary?: Record<string, string>;\n}\n\nexport type TranslateProvider = (request: TranslateRequest) => Promise<Record<string, string>>;\n\nexport interface TranslateProgress {\n locale: string;\n batch: number;\n batches: number;\n keys: number;\n error?: string;\n}\n\nexport interface TranslateOptions {\n locales?: string[];\n batchSize?: number;\n concurrency?: number;\n retries?: number;\n retryDelay?: number;\n dryRun?: boolean;\n origins?: Record<string, string[]>;\n onProgress?: (progress: TranslateProgress) => void;\n}\n\n// carries its reason, which the per-locale records cannot: a batch fails as a batch\nexport interface TranslateFailure {\n locale: string;\n keys: string[];\n error: string;\n}\n\nexport interface TranslateResult {\n translated: Record<string, string[]>;\n invalid: Record<string, string[]>;\n pending: Record<string, string[]>;\n failed: TranslateFailure[];\n}\n\ninterface Batch {\n locale: string;\n index: number;\n batches: number;\n keys: string[];\n}\n\nconst RETRY_STATUS = new Set([408, 409, 425, 429, 500, 502, 503, 504, 529]);\n\n// a provider is an extension point: retry what looks transient, never a request the api refused\nfunction retryable(error: unknown): boolean {\n const status = (error as { status?: number; statusCode?: number } | null)?.status;\n const code = (error as { statusCode?: number } | null)?.statusCode;\n const value = typeof status === 'number' ? status : code;\n return typeof value === 'number' ? RETRY_STATUS.has(value) : true;\n}\n\nfunction reason(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nconst wait = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n// a batch that never gets an answer is a failed batch, never a thrown run: everything else lands\nasync function attempt(\n run: () => Promise<Record<string, string>>,\n retries: number,\n delay: number,\n): Promise<Record<string, string>> {\n for (let round = 0; ; round++) {\n try {\n return await run();\n } catch (error) {\n if (round >= retries || !retryable(error)) throw error;\n await wait(delay * 2 ** round);\n }\n }\n}\n\n// bounded pool: independent batches, so the only reason to serialize them is the provider's limit\nasync function pooled<T>(jobs: T[], limit: number, run: (job: T) => Promise<void>): Promise<void> {\n let next = 0;\n const workers = Array.from({ length: Math.min(limit, jobs.length) }, async () => {\n while (next < jobs.length) {\n await run(jobs[next++]!);\n }\n });\n await Promise.all(workers);\n}\n\n// fills '' entries via the provider; invalid translations stay '' (check keeps failing)\nexport async function translateCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n provider: TranslateProvider,\n options: TranslateOptions = {},\n): Promise<TranslateResult> {\n const batchSize = options.batchSize ?? 20;\n const concurrency = Math.max(1, options.concurrency ?? 4);\n const retries = Math.max(0, options.retries ?? 2);\n const retryDelay = options.retryDelay ?? 500;\n const targets = targetLocales(cfg, options.locales);\n const source = catalogs[cfg.sourceLocale] ?? {};\n const result: TranslateResult = { translated: {}, invalid: {}, pending: {}, failed: [] };\n\n const jobs: Batch[] = [];\n for (const locale of targets) {\n const catalog = (catalogs[locale] ??= {});\n const missing = Object.keys(source).filter((key) => source[key] && !catalog[key]);\n if (missing.length === 0) continue;\n\n if (options.dryRun) {\n result.pending[locale] = missing;\n continue;\n }\n\n const batches = Math.ceil(missing.length / batchSize);\n for (let i = 0; i < missing.length; i += batchSize) {\n const index = Math.floor(i / batchSize) + 1;\n jobs.push({ locale, index, batches, keys: missing.slice(i, i + batchSize) });\n }\n }\n\n await pooled(jobs, concurrency, async (job) => {\n const { locale, keys } = job;\n const catalog = catalogs[locale]!;\n const messages = Object.fromEntries(keys.map((key) => [key, source[key]!]));\n const origins = options.origins\n ? Object.fromEntries(\n keys.filter((key) => options.origins![key]).map((key) => [key, options.origins![key]!]),\n )\n : undefined;\n\n let out: Record<string, string>;\n try {\n out = await attempt(\n () =>\n provider({\n sourceLocale: cfg.sourceLocale,\n targetLocale: locale,\n messages,\n origins,\n instructions: cfg.translate.instructions,\n glossary: glossaryFor(cfg, locale, messages),\n }),\n retries,\n retryDelay,\n );\n } catch (error) {\n const message = reason(error);\n result.failed.push({ locale, keys, error: message });\n options.onProgress?.({ ...progressOf(job), error: message });\n return;\n }\n\n for (const key of keys) {\n const text = out[key];\n if (typeof text === 'string' && text.trim() && structureMatches(source[key]!, text)) {\n catalog[key] = text;\n (result.translated[locale] ??= []).push(key);\n } else {\n (result.invalid[locale] ??= []).push(key);\n }\n }\n options.onProgress?.(progressOf(job));\n });\n\n // batches land out of order once they run in parallel, and a report has to read the same twice\n for (const locale of Object.keys(result.translated)) result.translated[locale]!.sort();\n for (const locale of Object.keys(result.invalid)) result.invalid[locale]!.sort();\n result.failed.sort((a, b) => a.locale.localeCompare(b.locale) || compare(a.keys, b.keys));\n return result;\n}\n\nfunction compare(a: string[], b: string[]): number {\n return (a[0] ?? '').localeCompare(b[0] ?? '');\n}\n\n// the same reason repeats across batches: say it once and name every key it cost\nexport function formatTranslateFailures(failed: TranslateFailure[]): string[] {\n const grouped: TranslateFailure[] = [];\n for (const entry of failed) {\n const same = grouped.find((it) => it.locale === entry.locale && it.error === entry.error);\n if (same) same.keys = [...same.keys, ...entry.keys];\n else grouped.push({ ...entry, keys: [...entry.keys] });\n }\n return grouped.map(\n ({ locale, error, keys }) =>\n ` ${locale}: ${counted(keys.length, 'message')} not translated (${error}): ${keys.join(', ')}`,\n );\n}\n\n// config provider wins; claude loads lazily so only translate pays for its optional SDK\nexport async function resolveProvider(\n cfg: ResolvedConfig,\n model?: string,\n): Promise<TranslateProvider> {\n const configured = cfg.translate.provider;\n if (typeof configured === 'function') return configured;\n const { claudeProvider } = await import('./providers/claude');\n return claudeProvider({ model: model ?? cfg.translate.model });\n}\n\n// no locale on purpose: a locale-specific plural gap must never drop a translator's file\nexport function structureMatches(source: string, translated: string): boolean {\n try {\n const issues = [...validateMessage(translated), ...validatePair(source, translated)];\n return !issues.some((issue) => issue.severity === 'error');\n } catch {\n return false; // unparseable input rejects the translation, it never crashes the caller\n }\n}\n\nfunction progressOf(job: Batch): TranslateProgress {\n return { locale: job.locale, batch: job.index, batches: job.batches, keys: job.keys.length };\n}\n\n// only the terms this batch actually contains: a glossary of hundreds must not become the prompt\nfunction glossaryFor(\n cfg: ResolvedConfig,\n locale: string,\n messages: Record<string, string>,\n): Record<string, string> | undefined {\n const entries = cfg.translate.glossary;\n if (!entries) return undefined;\n const text = Object.values(messages).join('\\n').toLowerCase();\n const out: Record<string, string> = {};\n for (const [term, rendering] of Object.entries(entries)) {\n if (!text.includes(term.toLowerCase())) continue;\n const value = typeof rendering === 'string' ? rendering : rendering[locale];\n if (value) out[term] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { findConfigFile } from './config';\n\nexport interface InitOptions {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n}\n\nexport interface InitResult {\n created: string[];\n skipped: string[];\n host: Host | undefined;\n configFile: string;\n next: string[];\n}\n\nexport type Host =\n 'nuxt' | 'next' | 'sveltekit' | 'astro' | 'vite' | 'webpack' | 'rspack' | 'rollup' | 'esbuild';\n\nexport interface HostSetup {\n name: Host;\n pkg: string;\n wire: string;\n}\n\nconst HOSTS: (HostSetup & { dep: string })[] = [\n {\n name: 'nuxt',\n dep: 'nuxt',\n pkg: '@verbaly/nuxt',\n wire: \"add '@verbaly/nuxt' to the modules in nuxt.config\",\n },\n {\n name: 'next',\n dep: 'next',\n pkg: '@verbaly/next',\n wire: 'wrap the export of next.config with withVerbaly',\n },\n {\n name: 'sveltekit',\n dep: '@sveltejs/kit',\n pkg: '@verbaly/vite',\n wire: 'add verbaly() to the plugins in vite.config (per-request locale: @verbaly/sveltekit)',\n },\n {\n name: 'astro',\n dep: 'astro',\n pkg: '@verbaly/astro',\n wire: 'add verbaly() to the integrations in astro.config',\n },\n {\n name: 'vite',\n dep: 'vite',\n pkg: '@verbaly/vite',\n wire: 'add verbaly() to the plugins in vite.config',\n },\n {\n name: 'webpack',\n dep: 'webpack',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly webpack plugin to your build config',\n },\n {\n name: 'rspack',\n dep: '@rspack/core',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly rspack plugin to your build config',\n },\n {\n name: 'rollup',\n dep: 'rollup',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly rollup plugin to your build config',\n },\n {\n name: 'esbuild',\n dep: 'esbuild',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly esbuild plugin to your build config',\n },\n];\n\n// any of these wires the build; the detected host only decides which one we recommend\nexport const WIRING_PACKAGES = [...new Set(HOSTS.map((host) => host.pkg))];\n\nexport function readDependencies(root: string): Record<string, string> {\n const path = join(root, 'package.json');\n if (!existsSync(path)) return {};\n try {\n const pkg = JSON.parse(readFileSync(path, 'utf8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return { ...pkg.dependencies, ...pkg.devDependencies };\n } catch {\n return {};\n }\n}\n\nexport function detectHost(root: string): HostSetup | undefined {\n const deps = readDependencies(root);\n return HOSTS.find((host) => deps[host.dep]);\n}\n\nfunction configSource(options: InitOptions, typescript: boolean): string {\n const fields = [` sourceLocale: '${options.sourceLocale ?? 'en'}',`];\n if (options.locales?.length) {\n fields.push(` locales: [${options.locales.map((l) => `'${l}'`).join(', ')}],`);\n }\n if (options.dir) fields.push(` dir: '${options.dir}',`);\n const body = `export default {\\n${fields.join('\\n')}\\n}`;\n if (typescript) {\n return `import type { VerbalyConfig } from '@verbaly/compiler';\\n\\n${body} satisfies VerbalyConfig;\\n`;\n }\n return `/** @type {import('@verbaly/compiler').VerbalyConfig} */\\n${body};\\n`;\n}\n\nexport function init(options: InitOptions = {}): InitResult {\n const root = options.root ?? process.cwd();\n const created: string[] = [];\n const skipped: string[] = [];\n\n const existing = findConfigFile(root);\n const typescript = existsSync(join(root, 'tsconfig.json'));\n const configFile = existing ?? (typescript ? 'verbaly.config.ts' : 'verbaly.config.mjs');\n if (existing) {\n skipped.push(existing);\n } else {\n writeFileSync(join(root, configFile), configSource(options, typescript));\n created.push(configFile);\n }\n\n const dir = join(root, options.dir ?? 'locales');\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n for (const locale of new Set([options.sourceLocale ?? 'en', ...(options.locales ?? [])])) {\n const file = join(dir, `${locale}.json`);\n const label = relative(root, file).replaceAll('\\\\', '/');\n if (existsSync(file)) {\n skipped.push(label);\n } else {\n writeFileSync(file, '{}\\n');\n created.push(label);\n }\n }\n\n const host = detectHost(root);\n const next = host\n ? [`pnpm add -D ${host.pkg}`, host.wire]\n : ['run \"verbaly extract\" after writing your first t`…` message'];\n\n return { created, skipped, host: host?.name, configFile, next };\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport { badLeaf, type Catalogs } from './catalog';\nimport { check } from './check';\nimport { generateDts } from './codegen';\nimport { findConfigFile, type ResolvedConfig } from './config';\nimport { extractProject } from './extract';\nimport { detectHost, readDependencies, WIRING_PACKAGES } from './init';\nimport { counted } from './text';\nimport { escapedSyntax } from './validate';\n\nexport interface DoctorEntry {\n level: 'ok' | 'warn' | 'error';\n check: string;\n message: string;\n fix?: string;\n}\n\nexport interface DoctorResult {\n ok: boolean; // no error-level entries (warns allowed)\n entries: DoctorEntry[];\n}\n\nconst PREVIEW = 5; // keys shown before \"…\"\n\nconst ICON = { ok: '✓', warn: '⚠', error: '✗' } as const;\n\n// one definition of a doctor line: the cli routes it by level, the mcp tool joins the block\nexport function formatDoctorEntry(entry: DoctorEntry): string {\n const head = ` ${ICON[entry.level]} ${entry.check}: ${entry.message}`;\n return entry.fix\n ? `${head}\n fix: ${entry.fix}`\n : head;\n}\n\nexport async function doctor(cfg: ResolvedConfig): Promise<DoctorResult> {\n const entries: DoctorEntry[] = [];\n const ok = (name: string, message: string) => entries.push({ level: 'ok', check: name, message });\n const warn = (name: string, message: string, fix: string) =>\n entries.push({ level: 'warn', check: name, message, fix });\n const error = (name: string, message: string, fix: string) =>\n entries.push({ level: 'error', check: name, message, fix });\n const rel = (path: string) => relative(cfg.root, path).replaceAll('\\\\', '/');\n\n const configFile = findConfigFile(cfg.root);\n if (configFile) ok('config', `${configFile} found`);\n else warn('config', 'no config file, running on defaults', 'run `npx verbaly init`');\n\n const catalogs: Catalogs = {};\n let catalogsHealthy = true;\n if (!existsSync(cfg.dir)) {\n catalogsHealthy = false;\n error(\n 'catalogs',\n `catalogs directory ${rel(cfg.dir)}/ does not exist`,\n 'run `npx verbaly init` to scaffold it',\n );\n } else {\n for (const locale of cfg.locales) {\n const file = join(cfg.dir, `${locale}.json`);\n if (!existsSync(file)) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is missing`,\n 'run `npx verbaly extract` to create it',\n );\n continue;\n }\n try {\n const parsed = JSON.parse(readFileSync(file, 'utf8')) as MessageTree;\n // nested groups are a real shape: only a leaf that is not text is broken\n const bad = badLeaf(parsed);\n if (bad) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} has a non-string value at \"${bad}\"`,\n 'catalog values are text (groups of text are fine); fix the value',\n );\n } else {\n catalogs[locale] = flatten(parsed);\n }\n } catch {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is not valid JSON`,\n 'repair the file (or delete it and run `npx verbaly extract`)',\n );\n }\n }\n if (catalogsHealthy) {\n ok(\n 'catalogs',\n `${counted(cfg.locales.length, 'locale')} (${cfg.locales.join(', ')}) in ${rel(cfg.dir)}/`,\n );\n }\n }\n\n const source = catalogs[cfg.sourceLocale];\n if (source && Object.keys(source).length === 0) {\n warn(\n 'source',\n `source catalog ${cfg.sourceLocale}.json is empty`,\n 'write your first t`…` message and run `npx verbaly extract`',\n );\n }\n\n const deps = readDependencies(cfg.root);\n const host = detectHost(cfg.root);\n const installed = WIRING_PACKAGES.find((pkg) => deps[pkg]);\n if (!host) {\n ok('plugin', 'no framework or bundler detected, the CLI flow (extract/check) applies');\n } else if (installed) {\n ok('plugin', `${installed} installed for ${host.name}`);\n } else {\n warn(\n 'plugin',\n `${host.name} detected but ${host.pkg} is not installed`,\n `pnpm add -D ${host.pkg} and ${host.wire}`,\n );\n }\n\n // with include: [] no code is read, so orphans and types cannot be claimed here\n const scanning = cfg.include.length > 0;\n if (!scanning) {\n ok('sources', 'source scanning is off (include: []), the catalogs are the source of truth');\n }\n\n if (source && scanning && cfg.dts !== false) {\n const dtsPath = cfg.dts ?? join(cfg.root, 'verbaly.d.ts');\n if (!existsSync(dtsPath)) {\n warn('types', 'verbaly.d.ts has not been generated', 'run `npx verbaly extract`');\n } else if (readFileSync(dtsPath, 'utf8') !== generateDts(source)) {\n warn('types', 'verbaly.d.ts is stale', 'run `npx verbaly extract`');\n } else {\n ok('types', 'verbaly.d.ts is up to date');\n }\n }\n\n const registry = await extractProject(cfg);\n if (scanning) {\n // a warn, not an error: decorators or a dialect babel does not read still build in the project\n const unreadable = registry.parseErrors();\n if (unreadable.length > 0) {\n const first = unreadable[0]!;\n warn(\n 'sources',\n `could not parse ${counted(unreadable.length, 'file')}, so the messages inside are not extracted (${rel(first.file)}: ${first.message})`,\n 'fix the syntax error, or exclude the file in your config if it is not source',\n );\n }\n const stray = registry.strayImports();\n if (stray.length > 0) {\n const files = [...new Set(stray.map((entry) => rel(entry.file)))];\n error(\n 'imports',\n `t is imported from a verbaly package, which never exports it, in ${counted(files.length, 'file')} (${preview(files)})`,\n 't comes from your instance (React: const t = useT()) or from virtual:verbaly',\n );\n }\n const escaped = [...registry.messages().values()]\n .map((msg) => ({ file: rel(msg.file), slice: escapedSyntax(msg.message) }))\n .filter((entry) => entry.slice !== undefined);\n if (escaped.length > 0) {\n warn(\n 'messages',\n `a block ships as literal text in ${counted(escaped.length, 'extracted message')} (${escaped[0]!.file}: ${escaped[0]!.slice})`,\n 'a tagged template takes its values from ${…}: use t(key, params) for a plural or format block',\n );\n }\n }\n if (source && scanning) {\n const extracted = registry.messages();\n const used = registry.usedKeys();\n const orphans = Object.keys(source).filter((key) => !extracted.has(key) && !used.has(key));\n if (orphans.length > 0) {\n warn(\n 'orphans',\n `${counted(orphans.length, 'catalog key')} no longer referenced in code (${preview(orphans)})`,\n 'run `npx verbaly extract --prune` to drop them',\n );\n } else {\n ok('orphans', 'no orphan keys');\n }\n }\n\n if (catalogsHealthy) {\n const result = check(cfg, catalogs, registry);\n if (result.unknown.length > 0) {\n error(\n 'keys',\n `${counted(result.unknown.length, 'unknown key')} used in code (${preview(result.unknown.map((u) => u.key))})`,\n 'fix the key or add it to the catalogs (`npx verbaly check` for details)',\n );\n }\n if (result.missing.length > 0) {\n const locales = [...new Set(result.missing.map((m) => m.locale))];\n warn(\n 'translations',\n `${counted(result.missing.length, 'missing translation')} (${locales.join(', ')})`,\n 'run `npx verbaly translate` or fill the catalogs (`npx verbaly check` for details)',\n );\n }\n // the gate fails on these, so doctor cannot keep calling the setup healthy\n const broken = result.broken.filter((entry) => entry.severity === 'error');\n if (broken.length > 0) {\n const locales = [...new Set(broken.map((b) => b.locale))];\n error(\n 'translations',\n `${counted(broken.length, 'broken translation')} (${locales.join(', ')}): present but not rendering what the source renders`,\n 'run `npx verbaly check` to read what each one lost',\n );\n }\n const warnings = result.broken.filter((entry) => entry.severity === 'warning');\n if (warnings.length > 0) {\n warn(\n 'translations',\n `${counted(warnings.length, 'structural warning')} (plural forms a language asks for)`,\n 'run `npx verbaly check` to read them, they never fail the build',\n );\n }\n if (result.ok) ok('translations', 'all translations complete');\n }\n\n return { ok: entries.every((entry) => entry.level !== 'error'), entries };\n}\n\nfunction preview(keys: string[]): string {\n const head = keys.slice(0, PREVIEW).join(', ');\n return keys.length > PREVIEW ? `${head}, …` : head;\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { parse } from '@babel/parser';\nimport MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport { cleanJsxText, isTReference, walk, type AstNode } from './analyze';\nimport type { ResolvedConfig } from './config';\n\nexport interface WrapEntry {\n file: string;\n line: number;\n text: string;\n kind: 'text' | 'attribute';\n attribute?: string;\n}\n\nexport interface WrapSkip {\n file: string;\n line: number;\n text: string;\n reason: string;\n}\n\nexport interface WrapResult {\n files: number;\n changed: string[];\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport interface WrapOptions {\n write?: boolean;\n}\n\n// user-visible string attributes worth translating; everything else stays code\nconst WRAP_ATTRS = new Set(['title', 'alt', 'placeholder', 'aria-label']);\n\nconst T_NAMES: ReadonlySet<string> = new Set(['t']);\nconst LETTER = /\\p{L}/u;\n\n// onboarding codemod: errs on skipping, never on inventing (ambiguous goes to the report)\nexport async function wrapProject(\n cfg: ResolvedConfig,\n options: WrapOptions = {},\n): Promise<WrapResult> {\n const files = (\n await glob(cfg.include, { cwd: cfg.root, ignore: cfg.exclude, absolute: true })\n ).filter((file) => /\\.[jt]sx$/.test(file));\n\n const result: WrapResult = { files: files.length, changed: [], wrapped: [], skipped: [] };\n\n for (const file of files) {\n const code = readFileSync(file, 'utf8');\n const label = relative(cfg.root, file).replaceAll('\\\\', '/');\n const out = wrapCode(code, label);\n result.wrapped.push(...out.wrapped);\n result.skipped.push(...out.skipped);\n if (out.code !== undefined) {\n result.changed.push(label);\n if (options.write) writeFileSync(file, out.code);\n }\n }\n return result;\n}\n\nexport interface WrapCodeResult {\n code?: string;\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport function wrapCode(code: string, file: string): WrapCodeResult {\n const wrapped: WrapEntry[] = [];\n const skipped: WrapSkip[] = [];\n\n let ast: AstNode;\n try {\n ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: ['typescript', 'jsx'],\n }).program as unknown as AstNode;\n } catch {\n return { wrapped, skipped }; // unparseable file: leave it alone\n }\n\n const s = new MagicString(code);\n const visited = new Set<AstNode>();\n let changed = false;\n\n walk(ast, (node) => {\n if (node.type !== 'JSXElement' && node.type !== 'JSXFragment') return;\n if (visited.has(node)) return;\n processElement(node);\n });\n\n return changed ? { code: s.toString(), wrapped, skipped } : { wrapped, skipped };\n\n function processElement(node: AstNode): void {\n visited.add(node);\n\n if (node.type === 'JSXElement') {\n const opening = node.openingElement as AstNode;\n const name = opening.name as AstNode;\n // <Trans> children and data-verbaly subtrees are already message-managed\n if (name.type === 'JSXIdentifier' && name.name === 'Trans') return markSubtree(node);\n if (hasVerbalyAttr(opening)) return markSubtree(node);\n wrapAttributes(opening);\n }\n\n const children = (node.children as AstNode[] | undefined) ?? [];\n const hasElementChild = children.some(\n (c) => c.type === 'JSXElement' || c.type === 'JSXFragment',\n );\n const hasText = children.some(\n (c) =>\n (c.type === 'JSXText' && LETTER.test(c.value as string)) ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type === 'StringLiteral' &&\n LETTER.test((c.expression as AstNode).value as string)),\n );\n\n if (hasElementChild && hasText) {\n // splitting the sentence into fragments would ship broken translations\n skip(node, snippet(children), 'mixed text and markup: wrap by hand or use <Trans>');\n return markSubtree(node);\n }\n if (hasText) {\n wrapSegment(node, children);\n return markSubtree(node);\n }\n for (const child of children) {\n if (child.type === 'JSXElement' || child.type === 'JSXFragment') processElement(child);\n }\n }\n\n function wrapSegment(parent: AstNode, children: AstNode[]): void {\n const meaningful = children.filter(\n (c) =>\n (c.type === 'JSXText' && (c.value as string).trim() !== '') ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type !== 'JSXEmptyExpression'),\n );\n if (meaningful.length === 0) return;\n\n const first = meaningful[0]!;\n const last = meaningful[meaningful.length - 1]!;\n\n let template = '';\n let report = '';\n for (let i = children.indexOf(first); i <= children.indexOf(last); i++) {\n const child = children[i]!;\n if (child.type === 'JSXText') {\n let value = cleanJsxText(child.value as string);\n if (child === first) value = value.trimStart();\n if (child === last) value = value.trimEnd();\n template += escapeTemplate(value);\n report += value;\n } else if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression as AstNode;\n if (expr.type === 'JSXEmptyExpression') continue;\n if (usesT(expr)) {\n skip(parent, snippet(children), 'already uses t: finish it by hand');\n return;\n }\n if (containsJsx(expr)) {\n skip(\n parent,\n snippet(children),\n 'an expression renders markup: wrap by hand or use <Trans>',\n );\n markSubtree(child);\n return;\n }\n if (expr.type === 'StringLiteral') {\n template += escapeTemplate(expr.value as string);\n report += expr.value as string;\n } else {\n const source = code.slice(expr.start, expr.end);\n template += '${' + source + '}';\n report += '${' + source + '}';\n }\n } else {\n return; // spread children and friends: bail quietly\n }\n }\n if (!LETTER.test(report)) return;\n\n const start =\n first.type === 'JSXText' ? first.start + leadingWs(first.value as string) : first.start;\n const end = last.type === 'JSXText' ? last.end - trailingWs(last.value as string) : last.end;\n\n s.overwrite(start, end, '{t`' + template + '`}');\n changed = true;\n wrapped.push({ file, line: line(first), text: report, kind: 'text' });\n }\n\n function wrapAttributes(opening: AstNode): void {\n for (const attr of opening.attributes as AstNode[]) {\n if (attr.type !== 'JSXAttribute') continue;\n const name = attr.name as AstNode;\n if (name.type !== 'JSXIdentifier' || !WRAP_ATTRS.has(name.name as string)) continue;\n const value = attr.value as AstNode | null;\n if (value?.type !== 'StringLiteral') continue;\n const raw = value.value as string;\n if (!LETTER.test(raw)) continue;\n s.overwrite(value.start, value.end, '{t`' + escapeTemplate(raw) + '`}');\n changed = true;\n wrapped.push({\n file,\n line: line(value),\n text: raw,\n kind: 'attribute',\n attribute: name.name as string,\n });\n }\n }\n\n function skip(node: AstNode, text: string, reason: string): void {\n skipped.push({ file, line: line(node), text, reason });\n }\n\n function snippet(children: AstNode[]): string {\n const start = children[0]?.start ?? 0;\n const end = children[children.length - 1]?.end ?? start;\n const text = code.slice(start, end).replace(/\\s+/g, ' ').trim();\n return text.length > 60 ? text.slice(0, 59) + '…' : text;\n }\n\n function markSubtree(node: AstNode): void {\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') visited.add(n);\n });\n }\n}\n\nfunction hasVerbalyAttr(opening: AstNode): boolean {\n return (opening.attributes as AstNode[]).some((attr) => {\n if (attr.type !== 'JSXAttribute') return false;\n const name = attr.name as AstNode;\n return name.type === 'JSXIdentifier' && (name.name as string).startsWith('data-verbaly');\n });\n}\n\n// a t`…` / t(...) / t.id anywhere in the expression means a human already started here\nfunction usesT(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'TaggedTemplateExpression' && isTReference(n.tag as AstNode, T_NAMES)) {\n found = true;\n }\n if (n.type === 'CallExpression' && isTReference(n.callee as AstNode, T_NAMES)) found = true;\n });\n return found;\n}\n\nfunction containsJsx(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') found = true;\n });\n return found;\n}\n\n// literal text run → template-literal-safe\nfunction escapeTemplate(text: string): string {\n return text.replace(/[\\\\`]/g, '\\\\$&').replace(/\\$\\{/g, '\\\\${');\n}\n\nfunction leadingWs(text: string): number {\n return text.length - text.trimStart().length;\n}\n\nfunction trailingWs(text: string): number {\n return text.length - text.trimEnd().length;\n}\n\nfunction line(node: AstNode): number {\n const loc = node.loc as { start?: { line?: number } } | undefined;\n return loc?.start?.line ?? 1;\n}\n","import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative } from 'node:path';\nimport MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport {\n createVerbaly,\n localeDirection,\n LOCALE_STORAGE_KEY,\n normalizeLink,\n parseTags,\n RICH_TAGS,\n safeAttribute,\n VOID_TAGS,\n type MessageTree,\n type Params,\n type RichLink,\n type TagNode,\n type Verbaly,\n} from 'verbaly';\nimport type { Catalogs } from './catalog';\nimport { loadCatalogs } from './catalog';\nimport type { RedirectConfig, ResolvedConfig } from './config';\n\nexport interface Alternate {\n hreflang: string;\n href: string;\n}\n\n// links that point at a page this mirror also holds get its prefix, so the visitor stays inside\nexport interface MirrorLinks {\n prefix: string;\n base?: string;\n pages: ReadonlySet<string>;\n}\n\n// the pre-paint script: the locale set it chooses from, and where a saved choice lives\nexport interface RedirectScript {\n locales: string[];\n sourceLocale: string;\n base?: string;\n storageKey?: string | false;\n}\n\ninterface RenderHtmlBase {\n locale: string;\n sourceLocale?: string;\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n setLang?: boolean;\n alternates?: Alternate[];\n mirror?: MirrorLinks;\n redirect?: RedirectScript;\n}\n\n// one of the two, never both: an instance already carries the catalogs it was built from\nexport type RenderHtmlOptions = RenderHtmlBase &\n (\n | { catalogs: Catalogs | Record<string, MessageTree>; instance?: never }\n | { catalogs?: never; instance: Verbaly }\n );\n\n// nested trees welcome: the runtime flattens them (verbaly-web's shape)\nexport function localeInstance(\n catalogs: Catalogs | Record<string, MessageTree>,\n locale: string,\n sourceLocale: string,\n): Verbaly {\n return createVerbaly({ locale, fallback: sourceLocale, messages: catalogs });\n}\n\nexport interface RenderHtmlResult {\n html: string;\n missing: string[];\n}\n\nconst HREFLANG_OPEN = '<!--verbaly:hreflang-->';\nconst HREFLANG_CLOSE = '<!--/verbaly:hreflang-->';\nconst REDIRECT_OPEN = '<!--verbaly:redirect-->';\nconst REDIRECT_CLOSE = '<!--/verbaly:redirect-->';\n\nconst VOID = new Set(VOID_TAGS);\n\nconst START_TAG = /<([a-zA-Z][a-zA-Z0-9-]*)((?:\"[^\"]*\"|'[^']*'|[^\"'>])*)>/g;\nconst ATTR = /([^\\s=/\"'<>]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+)))?/g;\n\n// pre-fills data-verbaly elements for one locale; the runtime stays functional\nexport function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult {\n const attr = options.attribute ?? 'data-verbaly';\n const argsAttr = `${attr}-args`;\n const attrsAttr = `${attr}-attr`;\n const richAttr = `${attr}-rich`;\n const linksAttr = `${attr}-links`;\n const richTags = new Set(options.richTags ?? RICH_TAGS);\n const globalLinks = options.richLinks;\n const sourceLocale = options.sourceLocale ?? 'en';\n\n const v = options.instance ?? localeInstance(options.catalogs, options.locale, sourceLocale);\n const t = v.t as unknown as (key: string, params?: Params) => string;\n\n const ms = new MagicString(html);\n const missing = new Set<string>();\n const skip = protectedRanges(html);\n const inSkip = (index: number): boolean => skip.some(([from, to]) => index >= from && index < to);\n\n // a message can carry markup of its own, and MagicString refuses to edit inside what it replaced\n const filled: Array<[number, number]> = [];\n const inFilled = (index: number): boolean =>\n filled.some(([from, to]) => index >= from && index < to);\n\n // per-locale canonical/og:url: a cross-locale canonical would void the hreflang set\n const selfUrl = options.alternates?.find((a) => a.hreflang === options.locale)?.href;\n const sourceUrl = options.alternates?.find((a) => a.hreflang === 'x-default')?.href;\n const rewriteUrl = selfUrl !== undefined && selfUrl !== sourceUrl;\n\n START_TAG.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = START_TAG.exec(html)) !== null) {\n if (inSkip(m.index) || inFilled(m.index)) continue;\n const [full, rawName, attrChunk] = m as unknown as [string, string, string];\n const tagName = rawName.toLowerCase();\n const openEnd = m.index + full.length;\n\n const chunkStart = m.index + 1 + rawName.length;\n\n if (tagName === 'html' && options.setLang !== false) {\n // lang and dir together: what persistLocale/switchLocale set at runtime\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'lang', options.locale);\n setAttribute(\n ms,\n html,\n chunkStart,\n openEnd,\n attrChunk,\n 'dir',\n localeDirection(options.locale),\n );\n continue;\n }\n\n const attrs = parseAttrs(attrChunk);\n\n if (\n rewriteUrl &&\n tagName === 'link' &&\n attrs.get('rel')?.toLowerCase() === 'canonical' &&\n decodeEntities(attrs.get('href') ?? '') === sourceUrl\n ) {\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'href', selfUrl!);\n }\n if (\n rewriteUrl &&\n tagName === 'meta' &&\n attrs.get('property') === 'og:url' &&\n decodeEntities(attrs.get('content') ?? '') === sourceUrl\n ) {\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'content', selfUrl!);\n }\n\n const mirror = options.mirror;\n if (mirror) {\n if (tagName === 'a' || tagName === 'area') {\n const inside = mirroredHref(attrs.get('href'), mirror);\n if (inside) setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'href', inside);\n } else if (tagName === 'meta' && attrs.get('http-equiv')?.toLowerCase() === 'refresh') {\n // a redirect page ships inside the mirror too, and its target must not leave it\n const content = attrs.get('content') ?? '';\n const url = /^([^;]*;\\s*url\\s*=\\s*)(.*)$/i.exec(decodeEntities(content));\n const inside = url && mirroredHref(url[2], mirror);\n if (inside) {\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'content', `${url![1]}${inside}`);\n }\n }\n }\n\n const key = attrs.get(attr);\n const attrMapRaw = attrs.get(attrsAttr);\n if (key === undefined && attrMapRaw === undefined) continue;\n\n const args = parseArgs(attrs.get(argsAttr));\n\n if (key) {\n if (!v.has(key)) {\n missing.add(key);\n } else if (!VOID.has(tagName) && !attrChunk.trimEnd().endsWith('/')) {\n const close = findClose(html, tagName, openEnd, inSkip);\n if (close) {\n const text = t(key, args);\n const own = parseArgs(attrs.get(linksAttr)) as Record<string, RichLink> | undefined;\n const links = own ? (globalLinks ? { ...globalLinks, ...own } : own) : globalLinks;\n const content = attrs.has(richAttr)\n ? richToHtml(parseTags(text), richTags, links)\n : escapeHtml(text);\n if (html.slice(openEnd, close.contentEnd) !== content) {\n if (openEnd === close.contentEnd) ms.appendLeft(openEnd, content);\n else ms.overwrite(openEnd, close.contentEnd, content);\n }\n filled.push([openEnd, close.contentEnd]);\n }\n }\n }\n\n if (attrMapRaw !== undefined) {\n const map = parseArgs(attrMapRaw);\n if (map) {\n for (const [name, attrKey] of Object.entries(map)) {\n if (typeof attrKey !== 'string') continue;\n if (!v.has(attrKey)) {\n missing.add(attrKey);\n continue;\n }\n const value = safeAttribute(name, t(attrKey, args));\n if (value !== undefined)\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, name, value);\n }\n }\n }\n }\n\n if (options.alternates?.length) injectAlternates(ms, html, options.alternates);\n if (options.redirect) injectRedirect(ms, html, options.redirect);\n\n return { html: ms.toString(), missing: [...missing] };\n}\n\n// the public path of a built page, the shape both the page set and an author's href reduce to\nexport function publicPath(rel: string): string {\n const path = `/${rel.replace(/(^|\\/)index\\.html$/, '$1')}`;\n return path.length > 1 ? path.replace(/\\/+$/, '') : path;\n}\n\n// only a root-relative link to a page the mirror contains: assets, externals and anchors stay\nfunction mirroredHref(raw: string | undefined, mirror: MirrorLinks): string | undefined {\n if (raw === undefined) return undefined;\n const href = decodeEntities(raw);\n if (!href.startsWith('/') || href.startsWith('//')) return undefined;\n const base = mirror.base ?? '';\n // hrefs carry the base the site is served under, the page set never does: compare like with like\n const inside = base ? stripBase(href, base) : href;\n if (base && inside === href) return undefined;\n const cut = inside.search(/[?#]/);\n const path = cut < 0 ? inside : inside.slice(0, cut);\n if (!mirror.pages.has(publicPath(path.replace(/^\\//, '')))) return undefined;\n return `${base}${mirror.prefix}${inside}`;\n}\n\n// the boundary check is what keeps base /app from swallowing /application\nfunction stripBase(path: string, base: string): string {\n if (!path.startsWith(base)) return path;\n const rest = path.slice(base.length);\n if (rest === '') return '/';\n return rest.startsWith('/') ? rest : path;\n}\n\n// 'app', '/app' and '/app/' all read as '/app'; nothing means the site sits at the root\nfunction normalizeBase(base: string | undefined): string {\n const trimmed = base?.replace(/^\\/+/, '').replace(/\\/+$/, '');\n return trimmed ? `/${trimmed}` : '';\n}\n\n// the narrowing of matchPathSegment, inlined: render == runtime has to hold here too\nconst REDIRECT_BODY =\n '(function(){var T=/^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|[0-9]{3}))?$/i;' +\n 'function M(t,g){t=String(t||\"\");if(S.indexOf(t)>=0)return t;if(g&&!T.test(t))return;' +\n 'while(t){var i=t.lastIndexOf(\"-\");if(i<0)return;t=t.slice(0,i);if(S.indexOf(t)>=0)return t}}' +\n 'var p=location.pathname;' +\n 'if(B){if(p.indexOf(B)!==0)return;p=p.slice(B.length)||\"/\";if(p.charAt(0)!==\"/\")return}' +\n 'if(M(p.split(\"/\")[1],1))return;' +\n 'var w;if(K)try{w=M(localStorage.getItem(K))}catch(e){}' +\n 'if(!w){var l=navigator.languages||[navigator.language];for(var i=0;i<l.length&&!w;i++)w=M(l[i])}' +\n 'if(!w||w===D)return;location.replace(B+\"/\"+w+p+location.search+location.hash)})()';\n\n// </script> can never appear in a locale code, but a catalog is untrusted and this costs nothing\nfunction jsLiteral(value: unknown): string {\n return JSON.stringify(value ?? null).replace(/</g, '\\\\u003c');\n}\n\n// pre-paint, in the source tree only: the mirror page a visitor lands on is already the answer\nfunction redirectScript(options: RedirectScript): string {\n const vars = [\n `S=${jsLiteral(options.locales)}`,\n `D=${jsLiteral(options.sourceLocale)}`,\n `B=${jsLiteral(normalizeBase(options.base))}`,\n `K=${options.storageKey === false ? 'null' : jsLiteral(options.storageKey ?? LOCALE_STORAGE_KEY)}`,\n ].join(',');\n return `<script>var ${vars};${REDIRECT_BODY};</script>`;\n}\n\n// goes first in <head> so it runs before a stylesheet can paint, idempotent via markers\nfunction injectRedirect(ms: MagicString, html: string, options: RedirectScript): void {\n const block = `${REDIRECT_OPEN}${redirectScript(options)}${REDIRECT_CLOSE}`;\n const from = html.indexOf(REDIRECT_OPEN);\n if (from !== -1) {\n const to = html.indexOf(REDIRECT_CLOSE, from);\n if (to !== -1) {\n const end = to + REDIRECT_CLOSE.length;\n if (html.slice(from, end) !== block) ms.overwrite(from, end, block);\n return;\n }\n }\n const head = /<head\\b(?:\"[^\"]*\"|'[^']*'|[^\"'>])*>/i.exec(html);\n if (head) ms.appendRight(head.index + head[0].length, block);\n}\n\n// injects <link rel=\"alternate\" hreflang> into <head>, idempotent via markers\nfunction injectAlternates(ms: MagicString, html: string, alternates: Alternate[]): void {\n const links = alternates\n .map(\n (a) =>\n `<link rel=\"alternate\" hreflang=\"${escapeAttr(a.hreflang)}\" href=\"${escapeAttr(a.href)}\">`,\n )\n .join('');\n const block = `${HREFLANG_OPEN}${links}${HREFLANG_CLOSE}`;\n const from = html.indexOf(HREFLANG_OPEN);\n if (from !== -1) {\n const to = html.indexOf(HREFLANG_CLOSE, from);\n if (to !== -1) {\n const end = to + HREFLANG_CLOSE.length;\n if (html.slice(from, end) !== block) ms.overwrite(from, end, block);\n return;\n }\n }\n const head = /<\\/head\\s*>/i.exec(html);\n if (head) ms.appendLeft(head.index, block);\n}\n\nexport interface RenderSiteOptions {\n site?: string;\n locales?: string[];\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n base?: string;\n baseUrl?: string;\n hreflang?: boolean;\n sitemap?: boolean | string;\n redirect?: boolean | RedirectConfig;\n clean?: boolean;\n}\n\nexport interface RenderSiteResult {\n files: number;\n locales: string[];\n missing: Record<string, string[]>;\n}\n\n// mirrors the built site per locale: dist/index.html → dist/<locale>/index.html\nexport async function renderSite(\n cfg: ResolvedConfig,\n options: RenderSiteOptions = {},\n): Promise<RenderSiteResult> {\n const site = join(cfg.root, options.site ?? cfg.render.site ?? 'dist');\n const locales = options.locales ?? cfg.locales;\n const attribute = options.attribute ?? cfg.render.attribute;\n const base = normalizeBase(options.base ?? cfg.render.base);\n const baseUrl = (options.baseUrl ?? cfg.render.baseUrl)?.replace(/\\/+$/, '');\n const wantHreflang = (options.hreflang ?? cfg.render.hreflang ?? true) && baseUrl !== undefined;\n const sitemap = options.sitemap ?? cfg.render.sitemap ?? false;\n const wantSitemap = sitemap !== false && baseUrl !== undefined;\n const clean = options.clean ?? cfg.render.clean ?? false;\n const wanted = options.redirect ?? cfg.render.redirect ?? false;\n const redirect = wanted === false ? undefined : wanted === true ? {} : wanted;\n const script: RedirectScript | undefined = redirect && {\n locales,\n sourceLocale: cfg.sourceLocale,\n base,\n storageKey: redirect.storageKey,\n };\n const catalogs = loadCatalogs(cfg);\n // one runtime per locale for the whole run: rebuilding it per page reflattened every catalog\n const instances = new Map(\n locales.map((locale) => [locale, localeInstance(catalogs, locale, cfg.sourceLocale)]),\n );\n\n if (clean) {\n for (const locale of locales) {\n if (locale !== cfg.sourceLocale) rmSync(join(site, locale), { recursive: true, force: true });\n }\n }\n\n const files = await glob('**/*.html', {\n cwd: site,\n absolute: true,\n ignore: locales.map((locale) => `${locale}/**`),\n });\n\n // every page the mirror will hold, so a link into one of them can keep the visitor inside\n const pages = new Set(files.map((file) => publicPath(relative(site, file).replace(/\\\\/g, '/'))));\n\n const missing: Record<string, string[]> = {};\n const urls: Array<{ rel: string; alternates: Alternate[] }> = [];\n for (const file of files) {\n const html = readFileSync(file, 'utf8');\n const rel = relative(site, file).replace(/\\\\/g, '/');\n const alternates = wantHreflang ? pageAlternates(baseUrl!, rel, locales, cfg.sourceLocale) : [];\n if (wantHreflang) urls.push({ rel, alternates });\n // only the source tree carries it: the mirror page a visitor reaches is already the answer\n const routed = script && (redirect!.on === 'all' || rel === 'index.html');\n for (const locale of locales) {\n const result = renderHtml(html, {\n locale,\n instance: instances.get(locale)!,\n sourceLocale: cfg.sourceLocale,\n attribute,\n richTags: options.richTags,\n richLinks: options.richLinks ?? cfg.render.links,\n alternates,\n mirror: locale === cfg.sourceLocale ? undefined : { prefix: `/${locale}`, base, pages },\n redirect: routed && locale === cfg.sourceLocale ? script : undefined,\n });\n for (const key of result.missing) {\n const list = (missing[locale] ??= []);\n if (!list.includes(key)) list.push(key);\n }\n const out = locale === cfg.sourceLocale ? file : join(site, locale, rel);\n mkdirSync(dirname(out), { recursive: true });\n writeFileSync(out, result.html);\n }\n }\n\n if (wantSitemap && urls.length) {\n const name = typeof sitemap === 'string' ? sitemap : 'sitemap-i18n.xml';\n writeFileSync(join(site, name), buildSitemap(urls));\n }\n\n return { files: files.length, locales: [...locales], missing };\n}\n\n// public URL of a built page path (index.html → directory URL)\nfunction pageUrl(baseUrl: string, prefix: string, rel: string): string {\n const path = rel.replace(/(^|\\/)index\\.html$/, '$1');\n return `${baseUrl}${prefix}${path ? `/${path}` : '/'}`;\n}\n\n// reciprocal hreflang set for one page across every locale (+ x-default = source)\nfunction pageAlternates(\n baseUrl: string,\n rel: string,\n locales: string[],\n sourceLocale: string,\n): Alternate[] {\n const alternates: Alternate[] = [];\n for (const locale of locales) {\n const prefix = locale === sourceLocale ? '' : `/${locale}`;\n alternates.push({ hreflang: locale, href: pageUrl(baseUrl, prefix, rel) });\n }\n alternates.push({ hreflang: 'x-default', href: pageUrl(baseUrl, '', rel) });\n return alternates;\n}\n\nfunction buildSitemap(urls: Array<{ rel: string; alternates: Alternate[] }>): string {\n const body = urls\n .flatMap(({ alternates }) => {\n const alts = alternates\n .map(\n (a) =>\n `<xhtml:link rel=\"alternate\" hreflang=\"${a.hreflang}\" href=\"${escapeAttr(a.href)}\"/>`,\n )\n .join('');\n return alternates\n .filter((a) => a.hreflang !== 'x-default')\n .map((self) => `<url><loc>${escapeAttr(self.href)}</loc>${alts}</url>`);\n })\n .join('');\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">${body}</urlset>\\n`;\n}\n\nfunction parseAttrs(chunk: string): Map<string, string> {\n const attrs = new Map<string, string>();\n ATTR.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = ATTR.exec(chunk)) !== null) {\n attrs.set(m[1]!.toLowerCase(), m[2] ?? m[3] ?? m[4] ?? '');\n }\n return attrs;\n}\n\nfunction parseArgs(raw: string | undefined): Params | undefined {\n if (!raw) return undefined;\n try {\n return JSON.parse(decodeEntities(raw)) as Params;\n } catch {\n console.warn(`[verbaly] invalid args JSON: ${raw}`);\n return undefined;\n }\n}\n\n// comments and script/style bodies are opaque to the scanner\nfunction protectedRanges(html: string): Array<[number, number]> {\n const ranges: Array<[number, number]> = [];\n const re = /<!--[\\s\\S]*?-->|<script\\b[\\s\\S]*?<\\/script\\s*>|<style\\b[\\s\\S]*?<\\/style\\s*>/gi;\n let m: RegExpExecArray | null;\n while ((m = re.exec(html)) !== null) {\n // keep script/style open tags scannable; protect only their bodies\n const openEnd = m[0].startsWith('<!--') ? m.index : html.indexOf('>', m.index) + 1;\n ranges.push([openEnd, m.index + m[0].length]);\n }\n return ranges;\n}\n\nfunction findClose(\n html: string,\n tagName: string,\n from: number,\n inSkip: (index: number) => boolean,\n): { contentEnd: number } | null {\n const re = new RegExp(\n `<${tagName}(?=[\\\\s/>])(?:\"[^\"]*\"|'[^']*'|[^\"'>])*>|</${tagName}\\\\s*>`,\n 'gi',\n );\n re.lastIndex = from;\n let depth = 1;\n let m: RegExpExecArray | null;\n while ((m = re.exec(html)) !== null) {\n if (inSkip(m.index)) continue;\n if (m[0][1] === '/') {\n depth -= 1;\n if (depth === 0) return { contentEnd: m.index };\n } else if (!m[0].endsWith('/>')) {\n depth += 1;\n }\n }\n return null;\n}\n\nfunction setAttribute(\n ms: MagicString,\n html: string,\n chunkStart: number,\n openEnd: number,\n attrChunk: string,\n name: string,\n value: string,\n): void {\n const escaped = escapeAttr(value);\n const existing = new RegExp(`(\\\\s${name}\\\\s*=\\\\s*)(\"[^\"]*\"|'[^']*'|[^\\\\s>]+)`, 'i').exec(\n attrChunk,\n );\n if (existing) {\n const valueStart = chunkStart + existing.index + existing[1]!.length;\n const valueEnd = valueStart + existing[2]!.length;\n if (html.slice(valueStart, valueEnd) !== `\"${escaped}\"`) {\n ms.overwrite(valueStart, valueEnd, `\"${escaped}\"`);\n }\n return;\n }\n const selfClosing = html.slice(openEnd - 2, openEnd) === '/>';\n const insertAt = openEnd - (selfClosing ? 2 : 1);\n ms.appendLeft(insertAt, ` ${name}=\"${escaped}\"`);\n}\n\nfunction richToHtml(\n nodes: TagNode[],\n allowed: Set<string>,\n links?: Record<string, RichLink>,\n): string {\n let out = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n out += escapeHtml(node);\n } else if (links?.[node.name] !== undefined) {\n const { href, target, rel } = normalizeLink(links[node.name]!);\n let attrs = href !== undefined ? ` href=\"${escapeAttr(href)}\"` : '';\n if (target) attrs += ` target=\"${escapeAttr(target)}\"`;\n if (rel) attrs += ` rel=\"${escapeAttr(rel)}\"`;\n out += `<a${attrs}>${richToHtml(node.children, allowed, links)}</a>`;\n } else if (allowed.has(node.name)) {\n out += VOID.has(node.name)\n ? `<${node.name}>`\n : `<${node.name}>${richToHtml(node.children, allowed, links)}</${node.name}>`;\n } else {\n out += richToHtml(node.children, allowed, links); // unknown tag → unwrap\n }\n }\n return out;\n}\n\nfunction escapeHtml(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nfunction escapeAttr(text: string): string {\n return escapeHtml(text).replace(/\"/g, '&quot;');\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&amp;/g, '&');\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,YAAY,KAAqB,QAAwB;CACvE,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO,MAAM;AACvC;AAGA,SAAgB,YAAY,KAAqB,QAAyB;CACxE,MAAM,OAAO,SAAS,KAAK,MAAM;CACjC,MAAM,MAAM,QAAQ,IAAI;CAExB,IAAI,KACF,MAAM,IAAI,MACR,aAAa,YAAY,KAAK,MAAM,EAAE,8BAA8B,IAAI,oEAE1E;CAEF,OAAO,QAAQ,IAAI;AACrB;AAGA,SAAgB,QAAQ,MAAmB,SAAS,IAAwB;CAC1E,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;EAC/C,MAAM,OAAO,SAAS,GAAG,OAAO,GAAG,QAAQ;EAC3C,IAAI,OAAO,UAAU,UAAU;EAC/B,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;EAChF,MAAM,MAAM,QAAQ,OAAO,IAAI;EAC/B,IAAI,KAAK,OAAO;CAClB;AAEF;AAGA,SAAS,SAAS,KAAqB,QAA6B;CAClE,IAAI;CACJ,IAAI;EACF,UAAU,aAAa,YAAY,KAAK,MAAM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,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AAC/E;AAEA,SAAS,WAAW,MAAsB;CACxC,OAAO,WAAW,IAAI,CAAC,CAAC,QAAQ,MAAM,QAAQ;AAChD;AAEA,SAAS,eAAe,MAAsB;CAC5C,OAAO,KACJ,QAAQ,WAAW,IAAG,CAAC,CACvB,QAAQ,UAAU,GAAG,CAAC,CACtB,QAAQ,SAAS,GAAG,CAAC,CACrB,QAAQ,SAAS,GAAG,CAAC,CACrB,QAAQ,UAAU,GAAG;AAC1B"}
1
+ {"version":3,"file":"index.js","names":["parse","walk","parse"],"sources":["../src/catalog.ts","../src/warn.ts","../src/registry.ts","../src/key.ts","../src/analyze.ts","../src/sfc.ts","../src/extract.ts","../src/validate.ts","../src/params.ts","../src/codegen.ts","../src/check.ts","../src/transform.ts","../src/plugin.ts","../src/drafts.ts","../src/text.ts","../src/status.ts","../src/translate.ts","../src/init.ts","../src/doctor.ts","../src/wrap.ts","../src/render.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { ResolvedConfig } from './config';\n\nexport type Catalog = Record<string, string>;\nexport type Catalogs = Record<string, Catalog>;\n\nexport function catalogPath(cfg: ResolvedConfig, locale: string): string {\n return join(cfg.dir, `${locale}.json`);\n}\n\n// the flat view is the shape t() sees, so every command reads a catalog the way the runtime does\nexport function readCatalog(cfg: ResolvedConfig, locale: string): Catalog {\n const tree = readTree(cfg, locale);\n const bad = badLeaf(tree);\n // the runtime skips this leaf with a warn; a build tool that skipped it would write the skip back\n if (bad) {\n throw new Error(\n `[verbaly] ${catalogPath(cfg, locale)} has a non-string value at \"${bad}\", ` +\n 'catalog values are text (groups of text are fine): fix the value',\n );\n }\n return flatten(tree);\n}\n\n// dotted path of the first value that is neither text nor a group of text (an array is a bad leaf)\nexport function badLeaf(tree: MessageTree, prefix = ''): string | undefined {\n for (const [key, value] of Object.entries(tree)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'string') continue;\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return path;\n const bad = badLeaf(value, path);\n if (bad) return bad;\n }\n return undefined;\n}\n\n// corrupt catalog throws: read as empty, the next extract would wipe the translations\nfunction readTree(cfg: ResolvedConfig, locale: string): MessageTree {\n let content: string;\n try {\n content = readFileSync(catalogPath(cfg, locale), 'utf8');\n } catch {\n return {};\n }\n const parsed = parseTree(content);\n if (parsed) return parsed;\n throw new Error(\n `[verbaly] ${catalogPath(cfg, locale)} is not valid JSON, fix or delete the file`,\n );\n}\n\n// a byte order mark is legal in the file and illegal to JSON.parse: drop it by code, never by regex\nfunction parseTree(content: string): MessageTree | undefined {\n const body = content.charCodeAt(0) === 0xfeff ? content.slice(1) : content;\n try {\n return JSON.parse(body) as MessageTree;\n } catch {\n return undefined;\n }\n}\n\nexport function loadCatalogs(cfg: ResolvedConfig): Catalogs {\n const catalogs: Catalogs = {};\n for (const locale of cfg.locales) catalogs[locale] = readCatalog(cfg, locale);\n return catalogs;\n}\n\n// the nesting is the author's: a file written as groups is handed back as groups\nfunction isNested(tree: MessageTree): boolean {\n return Object.values(tree).some((value) => typeof value === 'object' && value !== null);\n}\n\n// dotted key back to its group; a path already taken by text stays flat so nothing is overwritten\nfunction nest(catalog: Catalog): MessageTree {\n const tree: MessageTree = {};\n // sorted, so \"hero\" always lands before \"hero.title\" and a message is never replaced by its group\n for (const [key, message] of Object.entries(catalog).sort(([a], [b]) => (a < b ? -1 : 1))) {\n const parts = key.split('.');\n const leaf = parts[parts.length - 1]!;\n let node: MessageTree | undefined = parts.length > 1 ? tree : undefined;\n for (let i = 0; node && i < parts.length - 1; i++) {\n const next = (node[parts[i]!] ??= {});\n node = typeof next === 'object' && next !== null ? (next as MessageTree) : undefined;\n }\n if (node && typeof node[leaf] !== 'object') node[leaf] = message;\n else tree[key] = message;\n }\n return tree;\n}\n\nfunction sortTree(tree: MessageTree): MessageTree {\n const sorted: MessageTree = {};\n for (const key of Object.keys(tree).sort()) {\n const value = tree[key];\n if (typeof value === 'string') sorted[key] = value;\n else if (value !== undefined) sorted[key] = sortTree(value as MessageTree);\n }\n return sorted;\n}\n\nexport function serializeCatalog(catalog: Catalog, nested = false): string {\n return JSON.stringify(sortTree(nested ? nest(catalog) : catalog), null, 2) + '\\n';\n}\n\nexport function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string {\n const path = catalogPath(cfg, locale);\n let existing: string | undefined;\n try {\n existing = readFileSync(path, 'utf8');\n } catch {\n mkdirSync(cfg.dir, { recursive: true });\n }\n const serialized = serializeCatalog(catalog, wantsNesting(cfg, locale, existing));\n // identical writes are skipped: a rewrite retriggers whatever watches the catalog\n if (existing === serialized) return serialized;\n writeFileSync(path, serialized);\n return serialized;\n}\n\n// the file's own shape, and for a locale that does not exist yet, the source catalog's\nfunction wantsNesting(cfg: ResolvedConfig, locale: string, existing: string | undefined): boolean {\n if (existing !== undefined) {\n const tree = parseTree(existing);\n return tree !== undefined && isNested(tree);\n }\n if (locale === cfg.sourceLocale) return false;\n return isNested(readTree(cfg, cfg.sourceLocale));\n}\n","const warned = new Set<string>();\n\n// one warn-once for the whole compiler: dedupe by static content, never by a value being edited\nexport function warnOnce(message: string, dedupeKey = message): void {\n if (warned.has(dedupeKey)) return;\n warned.add(dedupeKey);\n console.warn(`[verbaly] ${message}`);\n}\n\n// bundler paths only: the CLI reports its own run, so a file is never announced twice\nexport function warnParseError(file: string, message: string): void {\n warnOnce(`${file}: could not be parsed (${message}), its messages were not extracted`);\n}\n","import type { Analysis, StrayImport, TaggedMessage } from './analyze';\nimport { warnOnce } from './warn';\n\nexport class MessageRegistry {\n private files = new Map<string, Analysis>();\n\n update(file: string, analysis: Analysis): void {\n this.files.set(file, analysis);\n }\n\n remove(file: string): void {\n this.files.delete(file);\n }\n\n messages(): Map<string, TaggedMessage> {\n const out = new Map<string, TaggedMessage>();\n for (const analysis of this.files.values()) {\n for (const msg of analysis.tagged) {\n const existing = out.get(msg.key);\n if (existing) {\n if (existing.message !== msg.message) {\n warnOnce(\n `key collision \"${msg.key}\": ` +\n `${JSON.stringify(existing.message)} vs ${JSON.stringify(msg.message)}, second dropped`,\n `collision:${msg.key}`,\n );\n }\n continue;\n }\n out.set(msg.key, msg);\n }\n }\n return out;\n }\n\n usedKeys(): Map<string, string[]> {\n const out = new Map<string, string[]>();\n for (const analysis of this.files.values()) {\n for (const used of analysis.usedKeys) {\n const files = out.get(used.key) ?? [];\n if (!files.includes(used.file)) files.push(used.file);\n out.set(used.key, files);\n }\n }\n return out;\n }\n\n strayImports(): StrayImport[] {\n return [...this.files.values()].flatMap((analysis) => analysis.strayImports);\n }\n\n // files the parser could not read: they contributed no messages and nothing else can tell\n parseErrors(): { file: string; message: string }[] {\n const out: { file: string; message: string }[] = [];\n for (const [file, analysis] of this.files) {\n if (analysis.parseError) out.push({ file, message: analysis.parseError });\n }\n return out;\n }\n\n // key → every source file that writes or uses it (translator context)\n origins(): Map<string, string[]> {\n const out = this.usedKeys();\n for (const analysis of this.files.values()) {\n for (const msg of analysis.tagged) {\n const files = out.get(msg.key) ?? [];\n if (!files.includes(msg.file)) files.push(msg.file);\n out.set(msg.key, files);\n }\n }\n return out;\n }\n}\n","import { createHash } from 'node:crypto';\n\nexport function stableKey(message: string): string {\n return createHash('sha256').update(message).digest('base64url').slice(0, 8);\n}\n","import { parse } from '@babel/parser';\nimport { stableKey } from './key';\n\nexport interface TaggedParam {\n name: string;\n start: number;\n end: number;\n}\n\nexport interface TransComponent {\n name: string;\n source: string;\n}\n\nexport interface TaggedMessage {\n key: string;\n message: string;\n params: TaggedParam[];\n start: number;\n end: number;\n tagStart: number;\n tagEnd: number;\n file: string;\n jsx?: { name: string; components: TransComponent[] };\n singleQuote?: boolean;\n}\n\nexport interface UsedKey {\n key: string;\n file: string;\n}\n\n// a named import the verbaly packages do not export: t comes from an instance, never from a package\nexport interface StrayImport {\n name: string;\n source: string;\n file: string;\n}\n\nexport interface Analysis {\n tagged: TaggedMessage[];\n usedKeys: UsedKey[];\n strayImports: StrayImport[];\n parseError?: string;\n}\n\n// babel's message carries the position but never the path: every caller adds the file itself\nexport function parseErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n// exported for wrap.ts (module-internal reuse, not part of the package surface)\nexport interface AstNode {\n type: string;\n start: number;\n end: number;\n [key: string]: unknown;\n}\n\nconst SKIP_KEYS = new Set(['loc', 'leadingComments', 'trailingComments', 'innerComments', 'extra']);\n\nexport interface AnalyzeOptions {\n tNames?: readonly string[];\n}\n\nconst DEFAULT_T_NAMES: readonly string[] = ['t'];\nconst JSX_FILE_RE = /\\.(?:[cm]?jsx?|tsx)$/;\n\nexport function analyze(code: string, file: string, options: AnalyzeOptions = {}): Analysis {\n const names = new Set(options.tNames ?? DEFAULT_T_NAMES);\n const ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: JSX_FILE_RE.test(file) ? ['typescript', 'jsx'] : ['typescript'],\n });\n\n const tagged: TaggedMessage[] = [];\n const usedKeys: UsedKey[] = [];\n const strayImports: StrayImport[] = [];\n\n walk(ast.program as unknown as AstNode, (node) => {\n if (node.type === 'ImportDeclaration') {\n collectStrayImports(node, file, strayImports);\n } else if (node.type === 'TaggedTemplateExpression') {\n const tag = node.tag as AstNode;\n const explicit = explicitId(tag, names);\n if (!explicit && !isTReference(tag, names)) return;\n const quasi = node.quasi as AstNode;\n const message = buildMessage(code, quasi, names);\n if (!message) return;\n tagged.push({\n key: explicit ? explicit.key : stableKey(message.text),\n message: message.text,\n params: message.params,\n start: node.start,\n end: node.end,\n tagStart: explicit ? explicit.refStart : tag.start,\n tagEnd: explicit ? explicit.refEnd : tag.end,\n file,\n });\n } else if (node.type === 'CallExpression') {\n const callee = node.callee as AstNode;\n if (!isTReference(callee, names)) return;\n const args = node.arguments as AstNode[];\n const first = args[0];\n if (first?.type === 'StringLiteral') {\n usedKeys.push({ key: first.value as string, file });\n }\n } else if (node.type === 'JSXElement') {\n handleTrans(code, node, file, tagged, usedKeys, names);\n }\n });\n\n return { tagged, usedKeys, strayImports };\n}\n\nconst VERBALY_PACKAGE = /^(?:verbaly|@verbaly\\/[\\w-]+)$/;\n\n// the most plausible onboarding error: only the bundler used to complain, and never about verbaly\nfunction collectStrayImports(node: AstNode, file: string, out: StrayImport[]): void {\n const source = node.source as { value?: unknown };\n if (typeof source.value !== 'string' || !VERBALY_PACKAGE.test(source.value)) return;\n for (const spec of node.specifiers as AstNode[]) {\n if (spec.type !== 'ImportSpecifier') continue;\n const imported = spec.imported as AstNode;\n if (imported.type === 'Identifier' && imported.name === 't') {\n out.push({ name: 't', source: source.value, file });\n }\n }\n}\n\nfunction handleTrans(\n code: string,\n node: AstNode,\n file: string,\n tagged: TaggedMessage[],\n usedKeys: UsedKey[],\n names: ReadonlySet<string>,\n): void {\n const opening = node.openingElement as AstNode;\n const nameNode = opening.name as AstNode;\n if (nameNode.type !== 'JSXIdentifier' || nameNode.name !== 'Trans') return;\n\n const attrs = opening.attributes as AstNode[];\n const idAttr = attrs.find((a) => a.type === 'JSXAttribute' && (a.name as AstNode).name === 'id');\n const children = node.children as AstNode[] | undefined;\n const push = (key: string, built: BuiltTrans) =>\n tagged.push({\n key,\n message: built.text,\n params: built.params,\n start: node.start,\n end: node.end,\n tagStart: nameNode.start,\n tagEnd: nameNode.end,\n file,\n jsx: { name: nameNode.name as string, components: built.components },\n });\n\n if (idAttr) {\n const value = idAttr.value as AstNode | null;\n if (value?.type !== 'StringLiteral') return;\n const id = value.value as string;\n // id + children → extract under the explicit key\n if (attrs.length === 1 && children?.length) {\n const built = buildTransMessage(code, children, names);\n if (built?.text.trim()) {\n push(id, built);\n return;\n }\n }\n usedKeys.push({ key: id, file });\n return; // runtime-first, untouched\n }\n if (attrs.length > 0) return; // hand-written props → don't guess\n\n if (!children?.length) return;\n\n const built = buildTransMessage(code, children, names);\n if (!built || !built.text.trim()) return;\n\n push(stableKey(built.text), built);\n}\n\n// t.id('key')`…` → explicit readable key\nfunction explicitId(\n tag: AstNode,\n names: ReadonlySet<string>,\n): { key: string; refStart: number; refEnd: number } | undefined {\n if (tag.type !== 'CallExpression') return undefined;\n const callee = tag.callee as AstNode;\n if (callee.type !== 'MemberExpression' || callee.computed) return undefined;\n const prop = callee.property as AstNode;\n if (prop.type !== 'Identifier' || prop.name !== 'id') return undefined;\n const obj = callee.object as AstNode;\n if (!isTReference(obj, names)) return undefined;\n const args = tag.arguments as AstNode[];\n const first = args[0];\n if (args.length !== 1 || first?.type !== 'StringLiteral') return undefined;\n return { key: first.value as string, refStart: obj.start, refEnd: obj.end };\n}\n\ninterface BuiltTrans {\n text: string;\n params: TaggedParam[];\n components: TransComponent[];\n}\n\nfunction buildTransMessage(\n code: string,\n children: AstNode[],\n names: ReadonlySet<string>,\n): BuiltTrans | undefined {\n const params: TaggedParam[] = [];\n const components: TransComponent[] = [];\n const takenParams = new Map<string, string>();\n const takenTags = new Map<string, string>();\n\n function walkChildren(nodes: AstNode[]): string | undefined {\n let text = '';\n for (const child of nodes) {\n if (child.type === 'JSXText') {\n text += escapeText(cleanJsxText(child.value as string));\n } else if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression as AstNode;\n if (expr.type === 'JSXEmptyExpression') continue;\n if (expr.type === 'StringLiteral') {\n text += escapeText(expr.value as string);\n continue;\n }\n if (containsTaggedT(expr, names)) return undefined; // overlap hazard\n const source = code.slice(expr.start, expr.end);\n const name = uniqueName(deriveName(expr, params.length), source, takenParams);\n params.push({ name, start: expr.start, end: expr.end });\n text += `{${name}}`;\n } else if (child.type === 'JSXElement') {\n const opening = child.openingElement as AstNode;\n const nameNode = opening.name as AstNode;\n if (nameNode.type !== 'JSXIdentifier' || nameNode.name === 'Trans') return undefined;\n const source = selfClosedSource(code, opening);\n const tag = uniqueName((nameNode.name as string).toLowerCase(), source, takenTags);\n if (!components.some((c) => c.name === tag)) components.push({ name: tag, source });\n if (!child.closingElement) {\n text += `<${tag}/>`;\n } else {\n const inner = walkChildren(child.children as AstNode[]);\n if (inner === undefined) return undefined;\n text += `<${tag}>${inner}</${tag}>`;\n }\n } else {\n return undefined; // fragments / spread children → bail\n }\n }\n return text;\n }\n\n const text = walkChildren(children);\n if (text === undefined) return undefined;\n return { text, params, components };\n}\n\n// JSX text semantics: newline-indent boundaries removed, interior joins = one space\nexport function cleanJsxText(raw: string): string {\n const lines = raw.split(/\\r\\n|[\\r\\n]/);\n let out = '';\n for (let i = 0; i < lines.length; i++) {\n let line = lines[i]!.replace(/\\t/g, ' ');\n if (i !== 0) line = line.replace(/^ +/, '');\n if (i !== lines.length - 1) line = line.replace(/ +$/, '');\n if (!line) continue;\n if (out && i !== 0) out += ' ';\n out += line;\n }\n return out;\n}\n\nfunction selfClosedSource(code: string, opening: AstNode): string {\n const src = code.slice(opening.start, opening.end);\n return src.endsWith('/>') ? src : `${src.slice(0, -1).trimEnd()} />`;\n}\n\n// true if the subtree holds a t`…` / t.id('…')`…` that analyze would extract itself\nfunction containsTaggedT(node: AstNode, names: ReadonlySet<string>): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type !== 'TaggedTemplateExpression') return;\n const tag = n.tag as AstNode;\n if (isTReference(tag, names) || explicitId(tag, names)) found = true;\n });\n return found;\n}\n\nexport function isTReference(node: AstNode, names: ReadonlySet<string>): boolean {\n if (node.type === 'Identifier') return names.has(node.name as string);\n if (node.type === 'MemberExpression' && !node.computed) {\n const prop = node.property as AstNode;\n return prop.type === 'Identifier' && names.has(prop.name as string);\n }\n return false;\n}\n\ninterface BuiltMessage {\n text: string;\n params: TaggedParam[];\n}\n\nfunction buildMessage(\n code: string,\n quasi: AstNode,\n names: ReadonlySet<string>,\n): BuiltMessage | undefined {\n const quasis = quasi.quasis as AstNode[];\n const expressions = quasi.expressions as AstNode[];\n const params: TaggedParam[] = [];\n const taken = new Map<string, string>();\n\n let text = escapeText(cookedValue(quasis[0]));\n\n for (let i = 0; i < expressions.length; i++) {\n const expr = expressions[i];\n if (!expr) return undefined;\n // a nested t`…` would be extracted on its own: overlapping rewrites; bail the outer\n if (containsTaggedT(expr, names)) return undefined;\n const source = code.slice(expr.start, expr.end);\n const name = uniqueName(deriveName(expr, i), source, taken);\n params.push({ name, start: expr.start, end: expr.end });\n text += `{${name}}` + escapeText(cookedValue(quasis[i + 1]));\n }\n return { text, params };\n}\n\nfunction cookedValue(element: AstNode | undefined): string {\n if (!element) return '';\n const value = element.value as { cooked?: string; raw: string };\n return value.cooked ?? value.raw;\n}\n\n// literal braces → escaped\nfunction escapeText(text: string): string {\n return text.replace(/[{}]/g, (m) => m + m);\n}\n\nfunction deriveName(expr: AstNode, index: number): string {\n if (expr.type === 'Identifier') return expr.name as string;\n if (expr.type === 'MemberExpression' && !expr.computed) {\n const prop = expr.property as AstNode;\n if (prop.type === 'Identifier') return prop.name as string;\n }\n return `_${index}`;\n}\n\nfunction uniqueName(base: string, source: string, taken: Map<string, string>): string {\n let name = base;\n let n = 2;\n while (taken.has(name) && taken.get(name) !== source) {\n name = `${base}${n}`;\n n += 1;\n }\n taken.set(name, source);\n return name;\n}\n\nexport function walk(node: AstNode, visit: (node: AstNode) => void): void {\n visit(node);\n for (const key in node) {\n if (SKIP_KEYS.has(key)) continue;\n const value = node[key];\n if (Array.isArray(value)) {\n for (const item of value) {\n if (isNode(item)) walk(item, visit);\n }\n } else if (isNode(value)) {\n walk(value, visit);\n }\n }\n}\n\nfunction isNode(value: unknown): value is AstNode {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { type?: unknown }).type === 'string'\n );\n}\n","import {\n analyze,\n parseErrorMessage,\n type Analysis,\n type StrayImport,\n type TaggedParam,\n type UsedKey,\n} from './analyze';\n\nexport const SFC_FILE_RE = /\\.(?:svelte|vue|astro)$/;\n\n// single dispatch point: SFCs get the block/markup analyzer, everything else plain analyze\nexport function analyzeFile(code: string, file: string): Analysis {\n if (SFC_FILE_RE.test(file)) return analyzeSfc(code, file);\n try {\n return analyze(code, file);\n } catch (error) {\n // one file the parser cannot read must never take down a whole extract, check or doctor\n return { tagged: [], usedKeys: [], strayImports: [], parseError: parseErrorMessage(error) };\n }\n}\n\nconst SCRIPT_RE = /(<script\\b[^>]*>)([\\s\\S]*?)(<\\/script\\s*>)/gi;\nconst STYLE_RE = /<style\\b[^>]*>[\\s\\S]*?<\\/style\\s*>/gi;\nconst COMMENT_RE = /<!--[\\s\\S]*?-->/g;\n// astro component script: --- fences at the top of the file\nconst FRONTMATTER_RE = /^(\\uFEFF?\\s*---\\r?\\n)([\\s\\S]*?)\\r?\\n---(?=\\r?\\n|$)/;\n\n// no whitespace after t: prose like \"won't ('x')\" must never become a used key\nconst CANDIDATE_SVELTE = /(?<![\\w$])\\$?t(?=[`(]|\\.id\\()/g;\nconst CANDIDATE_VUE = /(?<![\\w$])t(?=[`(]|\\.id\\()/g;\n\nconst MUSTACHE_RE = /\\{\\{[\\s\\S]*?\\}\\}/g;\nconst DIRECTIVE_RE = /\\s(?:v-[\\w-]+(?::[^\\s=>/]+)?|[:@][^\\s=>/]+)\\s*=\\s*(\"[^\"]*\"|'[^']*')/g;\n\nexport function analyzeSfc(code: string, file: string): Analysis {\n // svelte components consume t as a store: $t`…` is the idiomatic form\n const svelte = file.endsWith('.svelte');\n const options = svelte ? { tNames: ['t', '$t'] } : undefined;\n\n const tagged: Analysis['tagged'] = [];\n const usedKeys: UsedKey[] = [];\n const strayImports: StrayImport[] = [];\n let parseError: string | undefined;\n\n // a script block is structural: if it does not parse, the file is reported, unlike a markup slice\n const block = (segment: SegmentResult, offset: number): void => {\n parseError ??= segment.error;\n merge(segment.analysis, offset, false);\n };\n\n const frontmatter = file.endsWith('.astro') ? FRONTMATTER_RE.exec(code) : null;\n if (frontmatter?.[2]) {\n block(analyzeSegment(frontmatter[2], file, options), frontmatter[1]!.length);\n }\n\n for (const match of code.matchAll(SCRIPT_RE)) {\n const content = match[2]!;\n if (!content) continue;\n block(analyzeSegment(content, file, options), match.index + match[1]!.length);\n }\n\n // markup = everything left once frontmatter, scripts, styles and comments are blanked out\n const body = frontmatter\n ? ' '.repeat(frontmatter[0].length) + code.slice(frontmatter[0].length)\n : code;\n const markup = blank(blank(blank(body, SCRIPT_RE), STYLE_RE), COMMENT_RE);\n const candidates = svelte ? CANDIDATE_SVELTE : CANDIDATE_VUE;\n // display-only text never yields candidates: only expression context counts\n const ranges = file.endsWith('.vue') ? vueExpressionRanges(markup) : braceRanges(markup);\n let range = 0;\n let consumedTo = 0;\n for (const match of markup.matchAll(candidates)) {\n const start = match.index;\n if (start < consumedTo) continue;\n while (range < ranges.length && ranges[range]![1] <= start) range += 1;\n if (range >= ranges.length || start < ranges[range]![0]) continue;\n const end = expressionExtent(markup, start);\n if (end === undefined) continue;\n merge(analyzeSegment(code.slice(start, end), file, options).analysis, start, true);\n consumedTo = end;\n }\n\n return { tagged, usedKeys, strayImports, ...(parseError && { parseError }) };\n\n function merge(analysis: Analysis | undefined, offset: number, markupSegment: boolean): void {\n if (!analysis) return;\n for (const msg of analysis.tagged) {\n tagged.push({\n ...msg,\n start: msg.start + offset,\n end: msg.end + offset,\n tagStart: msg.tagStart + offset,\n tagEnd: msg.tagEnd + offset,\n params: msg.params.map((p): TaggedParam => ({\n ...p,\n start: p.start + offset,\n end: p.end + offset,\n })),\n ...(markupSegment && { singleQuote: true }),\n });\n }\n usedKeys.push(...analysis.usedKeys);\n strayImports.push(...analysis.strayImports);\n }\n}\n\ninterface SegmentResult {\n analysis?: Analysis;\n error?: string;\n}\n\nfunction analyzeSegment(code: string, file: string, options?: { tNames: string[] }): SegmentResult {\n try {\n return { analysis: analyze(code, file, options) };\n } catch (error) {\n return { error: parseErrorMessage(error) }; // never fail the whole file over one segment\n }\n}\n\nfunction blank(source: string, re: RegExp): string {\n return source.replace(re, (m) => ' '.repeat(m.length));\n}\n\n// [start, end) content spans of balanced {…} regions (astro expressions, svelte mustaches)\nfunction braceRanges(markup: string): Array<[number, number]> {\n const ranges: Array<[number, number]> = [];\n let i = 0;\n while (i < markup.length) {\n if (markup[i] === '{') {\n const end = balancedEnd(markup, i);\n if (end !== undefined) {\n ranges.push([i + 1, end - 1]);\n i = end;\n continue;\n }\n }\n i += 1;\n }\n return ranges;\n}\n\n// vue expression context: {{ mustaches }} plus quoted values of :/@/v- directive attributes\nfunction vueExpressionRanges(markup: string): Array<[number, number]> {\n const ranges: Array<[number, number]> = [];\n for (const match of markup.matchAll(MUSTACHE_RE)) {\n ranges.push([match.index + 2, match.index + match[0].length - 2]);\n }\n for (const match of markup.matchAll(DIRECTIVE_RE)) {\n const valueStart = match.index + match[0].length - match[1]!.length + 1;\n ranges.push([valueStart, valueStart + match[1]!.length - 2]);\n }\n return ranges.sort((a, b) => a[0] - b[0]);\n}\n\n// end (exclusive) of the expression starting at a candidate: t`…` | t(...) | t.id('…')`…`\nfunction expressionExtent(code: string, start: number): number | undefined {\n let i = start;\n if (code[i] === '$') i += 1;\n i += 1; // the t itself\n if (code.startsWith('.id(', i)) {\n const close = balancedEnd(code, i + 3);\n if (close === undefined || code[close] !== '`') return undefined;\n return balancedEnd(code, close);\n }\n if (code[i] === '`' || code[i] === '(') return balancedEnd(code, i);\n return undefined;\n}\n\n// scans a template literal or paren group to its close, tracking nested ${…}, strings and groups\nfunction balancedEnd(code: string, open: number): number | undefined {\n const stack: string[] = [];\n let i = open;\n while (i < code.length) {\n const ch = code[i]!;\n if (stack[stack.length - 1] === '`') {\n if (ch === '\\\\') i += 1;\n else if (ch === '`') stack.pop();\n else if (ch === '$' && code[i + 1] === '{') {\n stack.push('{');\n i += 1;\n }\n } else if (ch === \"'\" || ch === '\"') {\n i = stringEnd(code, i);\n } else if (ch === '`' || ch === '(' || ch === '{') {\n stack.push(ch);\n } else if (ch === ')' || ch === '}') {\n if (stack[stack.length - 1] !== (ch === ')' ? '(' : '{')) return undefined;\n stack.pop();\n }\n i += 1;\n if (stack.length === 0) return i;\n }\n return undefined;\n}\n\nfunction stringEnd(code: string, start: number): number {\n const quote = code[start];\n let i = start + 1;\n while (i < code.length) {\n if (code[i] === '\\\\') i += 2;\n else if (code[i] === quote) return i;\n else i += 1;\n }\n return code.length;\n}\n","import { readFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { glob } from 'tinyglobby';\nimport type { Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport { MessageRegistry } from './registry';\nimport { analyzeFile } from './sfc';\n\nexport async function extractProject(cfg: ResolvedConfig): Promise<MessageRegistry> {\n const files = await glob(cfg.include, {\n cwd: cfg.root,\n ignore: cfg.exclude,\n absolute: true,\n });\n const registry = new MessageRegistry();\n for (const file of files) {\n registry.update(file, analyzeFile(readFileSync(file, 'utf8'), file));\n }\n return registry;\n}\n\n// root-relative, forward slashes: paths a translator can read on any OS\nexport async function collectOrigins(cfg: ResolvedConfig): Promise<Record<string, string[]>> {\n const registry = await extractProject(cfg);\n const origins: Record<string, string[]> = {};\n for (const [key, files] of registry.origins()) {\n origins[key] = files.map((file) => relative(cfg.root, file).replaceAll('\\\\', '/'));\n }\n return origins;\n}\n\nexport interface SyncResult {\n added: Record<string, string[]>;\n}\n\n// fills source texts + '' placeholders\nexport function syncCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): SyncResult {\n const added: Record<string, string[]> = {};\n const source = (catalogs[cfg.sourceLocale] ??= {});\n\n for (const [key, msg] of registry.messages()) {\n if (source[key] !== msg.message) {\n source[key] = msg.message;\n (added[cfg.sourceLocale] ??= []).push(key);\n }\n }\n\n const needed = Object.keys(source);\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n const catalog = (catalogs[locale] ??= {});\n for (const key of needed) {\n if (catalog[key] === undefined) {\n catalog[key] = '';\n (added[locale] ??= []).push(key);\n }\n }\n }\n return { added };\n}\n\n// drops keys no longer referenced\nexport function pruneCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): Record<string, string[]> {\n const keep = new Set([...registry.messages().keys(), ...registry.usedKeys().keys()]);\n const removed: Record<string, string[]> = {};\n for (const locale of cfg.locales) {\n const catalog = catalogs[locale];\n if (!catalog) continue;\n for (const key of Object.keys(catalog)) {\n if (!keep.has(key)) {\n delete catalog[key];\n (removed[locale] ??= []).push(key);\n }\n }\n }\n return removed;\n}\n","import { parse, type MessageNode } from 'verbaly';\n\nexport const PLURAL_CATEGORIES = new Set(['zero', 'one', 'two', 'few', 'many']);\nexport type IssueSeverity = 'error' | 'warning';\n\nexport interface StructureIssue {\n severity: IssueSeverity;\n message: string;\n}\n\ninterface VariantShape {\n selectors: string[];\n plural: boolean;\n ordinal: boolean;\n}\n\nconst EXACT = /^=\\d+$/;\n\n// param name → its plural/select block, when it has one; first block per name wins\nfunction shapes(message: string): Map<string, VariantShape> {\n const out = new Map<string, VariantShape>();\n walk(parse(message), out);\n return out;\n}\n\nfunction walk(nodes: MessageNode[], out: Map<string, VariantShape>): void {\n for (const node of nodes) {\n if (node.kind !== 'param' || !node.variants) continue;\n const selectors = node.variants.map(([key]) => key);\n if (!out.has(node.name)) {\n out.set(node.name, {\n selectors,\n plural: selectors.some((key) => PLURAL_CATEGORIES.has(key)),\n ordinal: node.ordinal === true,\n });\n }\n for (const [, body] of node.variants) walk(body, out);\n }\n}\n\nfunction paramNames(message: string): string[] {\n const names = new Set<string>();\n collect(parse(message), names);\n return [...names].sort();\n}\n\nfunction collect(nodes: MessageNode[], out: Set<string>): void {\n for (const node of nodes) {\n if (node.kind !== 'param') continue;\n out.add(node.name);\n if (node.variants) for (const [, body] of node.variants) collect(body, out);\n }\n}\n\nconst TAG = /<(\\/?)([a-zA-Z][\\w-]*)(\\/?)>/g;\n\n// markup is only what the message closes (</x>) or self-closes (<x/>): a lone <Enter> is prose\nfunction markupNames(message: string): Set<string> {\n const out = new Set<string>();\n for (const match of message.matchAll(TAG)) {\n if (match[1] || match[3]) out.add(match[2]!);\n }\n return out;\n}\n\nfunction tagTokens(message: string, markup: Set<string>): string[] {\n const out: string[] = [];\n for (const match of message.matchAll(TAG)) {\n if (markup.has(match[2]!)) out.push(`${match[1]}${match[2]}${match[3]}`);\n }\n return out.sort();\n}\n\n// items in a that are missing from b, counting duplicates\nfunction surplus(a: string[], b: string[]): string[] {\n const rest = [...b];\n const out: string[] = [];\n for (const item of a) {\n const at = rest.indexOf(item);\n if (at < 0) out.push(item);\n else rest.splice(at, 1);\n }\n return out;\n}\n\nfunction list(items: string[]): string {\n return items.length > 1\n ? `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`\n : items[0]!;\n}\n\n// a tagged template escapes its own braces, so a block written inside one ships as literal text\nconst ESCAPED_SYNTAX = /(?<!\\{)\\{\\{\\s*[\\w.]+\\s*[|:][^{}]*\\}\\}/;\n\n// the escaped slice of an extracted message, when the author meant a plural or format block\nexport function escapedSyntax(message: string): string | undefined {\n return ESCAPED_SYNTAX.exec(message)?.[0];\n}\n\n// one message on its own: defects that need no source to be visible\nexport function validateMessage(message: string, locale?: string): StructureIssue[] {\n const issues: StructureIssue[] = [];\n for (const [name, shape] of shapes(message)) {\n if (!shape.plural) continue; // a select block without 'other' is the author's design\n if (!shape.selectors.includes('other')) {\n issues.push({\n severity: 'error',\n message: `the plural block for {${name}} has no \"other\" case, so any count it does not list renders empty`,\n });\n continue;\n }\n if (!locale) continue;\n const missing = reachableCategories(locale, shape.ordinal).filter(\n (category) => category !== 'other' && !shape.selectors.includes(category),\n );\n if (missing.length > 0) {\n issues.push({\n severity: 'warning',\n message: `${locale} also needs the ${list(missing)} plural ${missing.length > 1 ? 'forms' : 'form'} for {${name}}`,\n });\n }\n }\n return issues;\n}\n\n// a translation against the source it must mirror\nexport function validatePair(source: string, translated: string): StructureIssue[] {\n const issues: StructureIssue[] = [];\n\n const lostParams = surplus(paramNames(source), paramNames(translated));\n const newParams = surplus(paramNames(translated), paramNames(source));\n if (lostParams.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(lostParams.map((name) => `{${name}}`))} ${lostParams.length > 1 ? 'are' : 'is'} missing, so ${lostParams.length > 1 ? 'their values' : 'its value'} never reaches the text`,\n });\n }\n if (newParams.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(newParams.map((name) => `{${name}}`))} ${newParams.length > 1 ? 'are' : 'is'} not in the source message, so ${newParams.length > 1 ? 'they render' : 'it renders'} as literal text`,\n });\n }\n\n // one vocabulary for both sides: a tag the translation invents is still caught\n const markup = new Set([...markupNames(source), ...markupNames(translated)]);\n const lostTags = tagReport(surplus(tagTokens(source, markup), tagTokens(translated, markup)));\n const newTags = tagReport(surplus(tagTokens(translated, markup), tagTokens(source, markup)));\n if (lostTags.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(lostTags)} ${lostTags.length > 1 ? 'are' : 'is'} missing from the translation`,\n });\n }\n if (newTags.length > 0) {\n issues.push({\n severity: 'error',\n message: `${list(newTags)} ${newTags.length > 1 ? 'are' : 'is'} not in the source message`,\n });\n }\n\n const target = shapes(translated);\n for (const [name, shape] of shapes(source)) {\n const other = target.get(name);\n if (!other) {\n issues.push({\n severity: 'error',\n message: `the ${shape.plural ? 'plural' : 'select'} block for {${name}} was flattened into plain text`,\n });\n continue;\n }\n // 'other' is the catch-all: losing it renders empty (the plural case is validateMessage's)\n if (shape.selectors.includes('other') && !other.selectors.includes('other') && !other.plural) {\n issues.push({\n severity: 'error',\n message: `the \"other\" case for {${name}} is missing, so unlisted values render empty`,\n });\n }\n const lostExact = shape.selectors\n .filter((key) => EXACT.test(key))\n .filter((key) => !other.selectors.includes(key));\n if (lostExact.length > 0) {\n issues.push({\n severity: 'warning',\n message: `the ${list(lostExact)} ${lostExact.length > 1 ? 'cases' : 'case'} for {${name}} ${lostExact.length > 1 ? 'are' : 'is'} missing, so ${lostExact.length > 1 ? 'those counts' : 'that count'} falls back to \"other\"`,\n });\n }\n }\n\n return issues;\n}\n\n// one entry per tag name: a translator restores the pair, not a lone closing tag\nfunction tagReport(tokens: string[]): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n for (const token of tokens) {\n const name = token.replaceAll('/', '');\n if (seen.has(name)) continue;\n seen.add(name);\n out.push(token.endsWith('/') ? `<${name}/>` : `<${name}>`);\n }\n return out;\n}\n\nconst COUNT_PROBE = 200; // the range a UI counter realistically reaches\nconst reachable = new Map<string, string[]>();\n\nfunction reachableCategories(locale: string, ordinal: boolean): string[] {\n const type = ordinal ? 'ordinal' : 'cardinal';\n // the escape, never the raw character: a literal NUL makes git treat the file as binary\n const cacheKey = `${locale}\\u0000${type}`;\n const hit = reachable.get(cacheKey);\n if (hit) return hit;\n\n let out: string[];\n try {\n const rules = new Intl.PluralRules(locale, { type });\n const seen = new Set<string>();\n for (let n = 0; n <= COUNT_PROBE; n++) seen.add(rules.select(n));\n out = [...seen];\n } catch {\n out = []; // unknown tag: nothing is ever reported missing\n }\n reachable.set(cacheKey, out);\n return out;\n}\n","import { parse, type MessageNode } from 'verbaly';\nimport { PLURAL_CATEGORIES } from './validate';\n\nexport type ParamType = 'number' | 'string' | 'date' | 'unknown';\n\nconst NUMBER_FORMATS = new Set(['number', 'integer', 'percent', 'currency']);\nconst DATE_FORMATS = new Set(['date', 'time']);\n\nexport function collectParams(message: string): Map<string, Set<ParamType>> {\n const out = new Map<string, Set<ParamType>>();\n visit(parse(message), out);\n return out;\n}\n\nfunction visit(nodes: MessageNode[], out: Map<string, Set<ParamType>>): void {\n for (const node of nodes) {\n if (node.kind !== 'param') continue;\n const types = out.get(node.name) ?? new Set<ParamType>();\n out.set(node.name, types);\n\n if (node.variants) {\n for (const [key, body] of node.variants) {\n if (PLURAL_CATEGORIES.has(key) || /^=\\d+$/.test(key)) types.add('number');\n else if (key !== 'other') types.add('string');\n visit(body, out);\n }\n if (types.size === 0) types.add('string');\n } else if (node.format && NUMBER_FORMATS.has(node.format)) {\n types.add('number');\n } else if (node.format && DATE_FORMATS.has(node.format)) {\n types.add('date');\n } else {\n types.add('unknown');\n }\n }\n}\n\nexport function renderParamType(types: Set<ParamType>): string {\n if (types.has('unknown') || types.size === 0) return 'unknown';\n const members = new Set<string>();\n if (types.has('number')) members.add('number');\n if (types.has('string')) members.add('string');\n if (types.has('date')) for (const m of ['Date', 'number', 'string']) members.add(m);\n return [...members].join(' | ');\n}\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type { Catalog } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport { collectParams, renderParamType } from './params';\n\nexport const VIRTUAL_ID = 'virtual:verbaly';\n\nexport interface RuntimeModuleOptions {\n localeImport?: (locale: string) => string;\n extraExports?: string;\n}\n\nexport function generateRuntimeModule(\n cfg: ResolvedConfig,\n options: RuntimeModuleOptions = {},\n): string {\n const importPath = options.localeImport ?? ((locale: string) => `${VIRTUAL_ID}/locale/${locale}`);\n const others = cfg.locales.filter((locale) => locale !== cfg.sourceLocale);\n const src = JSON.stringify(cfg.sourceLocale);\n const loaders = others\n .map((locale) => ` ${JSON.stringify(locale)}: () => import('${importPath(locale)}'),`)\n .join('\\n');\n\n return `import {\n createVerbaly,\n localeFromPath as readPath,\n localePath as writePath,\n switchLocale as runSwitch,\n} from 'verbaly';\nimport source from '${importPath(cfg.sourceLocale)}';\n\nexport const sourceLocale = ${src};\nexport const locales = ${JSON.stringify(cfg.locales)};\nexport const routing = ${JSON.stringify(cfg.routing)};\n\n// bound to this project: the locale set, the source and the routing mode are never passed in\nexport function localePath(locale, options) {\n return writePath(locale, { ...options, supported: locales, sourceLocale, routing });\n}\n\nexport function localeFromPath(options) {\n return readPath({ ...options, supported: locales });\n}\n\n// the whole switch a language control needs, in either mode: catalog or navigation, then persistence\nexport function switchLocale(locale, options) {\n return runSwitch(v, locale, { supported: locales, sourceLocale, routing, ...options });\n}\n\nconst localeLoaders = {\n${loaders}\n};\n\n// raw catalog access: SSR integrations serialize it across the client boundary\nexport async function loadMessages(locale) {\n if (locale === ${src}) return source;\n const loader = localeLoaders[locale];\n return loader ? (await loader()).default : {};\n}\n\n// per-request/per-instance factory (SSR): the singleton below is browser/SPA-only\nexport function createInstance(options) {\n return createVerbaly({\n locale: ${src},\n fallback: ${src},\n messages: { [${src}]: source },\n loaders: localeLoaders,\n ...options,\n });\n}\n\n// the no-FOUC contract in one call: fresh instance + catalog awaited before render\nexport async function createRequestInstance(locale) {\n const instance = createInstance({ locale });\n await instance.loadLocale(locale);\n return instance;\n}\n\nconst v = createInstance();\n\nexport const verbaly = v;\nexport const t = v.t;\n\nexport function getLocale() {\n return v.locale;\n}\n\nexport function subscribe(listener) {\n return v.subscribe(listener);\n}\n\nexport async function setLocale(locale) {\n await v.loadLocale(locale);\n v.setLocale(locale);\n}\n${options.extraExports ?? ''}`;\n}\n\nexport function generateLocaleModule(catalog: Catalog): string {\n return `export default ${JSON.stringify(catalog)};\\n`;\n}\n\nexport function generateDts(catalog: Catalog): string {\n const lines: string[] = [];\n for (const [key, message] of Object.entries(catalog).sort(([a], [b]) => a.localeCompare(b))) {\n const params = collectParams(message);\n if (params.size === 0) {\n lines.push(` ${JSON.stringify(key)}: never;`);\n } else {\n const fields = [...params.entries()]\n .map(([name, types]) => `${JSON.stringify(name)}: ${renderParamType(types)}`)\n .join('; ');\n lines.push(` ${JSON.stringify(key)}: { ${fields} };`);\n }\n }\n\n return `// generated by verbaly: do not edit\ndeclare module 'virtual:verbaly' {\n export interface VerbalyMessages {\n${lines.join('\\n')}\n }\n export type VerbalyKey = keyof VerbalyMessages & string;\n\n export const verbaly: import('verbaly').Verbaly<VerbalyKey>;\n\n export const sourceLocale: string;\n export const locales: string[];\n export const routing: import('verbaly').Routing;\n export function localePath(\n locale: string,\n options?: { path?: string; base?: string },\n ): string;\n export function localeFromPath(options?: {\n path?: string;\n base?: string;\n }): string | undefined;\n export function loadMessages(locale: string): Promise<Record<string, string>>;\n export function createInstance(\n options?: import('verbaly').VerbalyOptions<VerbalyKey>,\n ): import('verbaly').Verbaly<VerbalyKey>;\n export function createRequestInstance(\n locale: string,\n ): Promise<import('verbaly').Verbaly<VerbalyKey>>;\n\n export function t<K extends VerbalyKey>(\n key: K,\n ...args: [VerbalyMessages[K]] extends [never] ? [] : [VerbalyMessages[K]]\n ): string;\n export function t(strings: TemplateStringsArray, ...values: unknown[]): string;\n export namespace t {\n export function id(\n key: string,\n ): (strings: TemplateStringsArray, ...values: unknown[]) => string;\n }\n\n export function setLocale(locale: string): Promise<void>;\n export function switchLocale(\n locale: string,\n options?: Omit<\n import('verbaly').SwitchLocaleOptions,\n 'routing' | 'supported' | 'sourceLocale'\n >,\n ): Promise<void>;\n export function getLocale(): string;\n export function subscribe(listener: () => void): () => void;\n}\n\ndeclare module 'virtual:verbaly/locale/*' {\n const messages: Record<string, string>;\n export default messages;\n}\n`;\n}\n\n// unchanged writes are skipped: a rewritten verbaly.d.ts churns the consumer's TS server\nexport function writeDts(cfg: ResolvedConfig, catalog: Catalog, file?: string): void {\n file ??= join(cfg.root, 'verbaly.d.ts');\n const content = generateDts(catalog);\n try {\n if (readFileSync(file, 'utf8') === content) return;\n } catch {\n // new file\n }\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, content);\n}\n","import { readFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport type { MessageRegistry } from './registry';\nimport { validateMessage, validatePair, type IssueSeverity, type StructureIssue } from './validate';\n\nexport interface MissingEntry {\n locale: string;\n key: string;\n source?: string;\n}\n\nexport interface UnknownEntry {\n key: string;\n files: string[];\n}\n\nexport interface BrokenEntry {\n locale: string;\n key: string;\n severity: IssueSeverity;\n issue: string;\n}\n\nexport interface CheckResult {\n ok: boolean;\n missing: MissingEntry[];\n unknown: UnknownEntry[];\n broken: BrokenEntry[];\n}\n\nexport function gatePasses(result: Omit<CheckResult, 'ok'>): boolean {\n return (\n result.missing.length === 0 &&\n result.unknown.length === 0 &&\n !result.broken.some((entry) => entry.severity === 'error')\n );\n}\n\nexport function check(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): CheckResult {\n const extracted = registry.messages();\n\n // one flat view per locale: the shape t() sees, so nested catalogs compare leaf by leaf\n const flat: Record<string, Catalog> = {};\n for (const locale of cfg.locales) {\n flat[locale] = flatten((catalogs[locale] ?? {}) as MessageTree);\n }\n const source = flat[cfg.sourceLocale] ?? {};\n\n const unknown: UnknownEntry[] = [];\n for (const [key, files] of registry.usedKeys()) {\n const known =\n extracted.has(key) || cfg.locales.some((locale) => flat[locale]?.[key] !== undefined);\n if (!known) unknown.push({ key, files });\n }\n\n const needed = new Set<string>([...extracted.keys(), ...Object.keys(source)]);\n\n const missing: MissingEntry[] = [];\n for (const key of extracted.keys()) {\n if (!source[key]) {\n missing.push({ locale: cfg.sourceLocale, key, source: extracted.get(key)?.message });\n }\n }\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n for (const key of needed) {\n if (!flat[locale]?.[key]) {\n missing.push({ locale, key, source: source[key] ?? extracted.get(key)?.message });\n }\n }\n }\n\n // presence is not correctness: a translation can be there and still render wrong\n const broken: BrokenEntry[] = [];\n const add = (locale: string, key: string, issues: StructureIssue[]): void => {\n for (const issue of issues) {\n broken.push({ locale, key, severity: issue.severity, issue: issue.message });\n }\n };\n\n // a key can be used in code before it reaches the catalog: validate that text too\n const sourceText: Catalog = { ...source };\n for (const [key, entry] of extracted) {\n if (!sourceText[key]) sourceText[key] = entry.message;\n }\n for (const [key, text] of Object.entries(sourceText)) {\n add(cfg.sourceLocale, key, validateMessage(text, cfg.sourceLocale));\n }\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n for (const [key, translated] of Object.entries(flat[locale] ?? {})) {\n if (!translated) continue; // '' is untranslated, already reported as missing\n add(locale, key, validateMessage(translated, locale));\n const text = sourceText[key];\n if (text) add(locale, key, validatePair(text, translated));\n }\n }\n\n return { ok: gatePasses({ missing, unknown, broken }), missing, unknown, broken };\n}\n\nexport function formatCheckResult(result: CheckResult): string {\n const lines: string[] = [];\n if (result.missing.length > 0) {\n lines.push('missing translations:');\n for (const entry of result.missing) {\n const hint = entry.source ? `: \"${truncate(entry.source, 40)}\"` : '';\n lines.push(` [${entry.locale}] ${entry.key}${hint}`);\n }\n }\n if (result.unknown.length > 0) {\n lines.push('unknown keys (not in any catalog):');\n for (const entry of result.unknown) {\n lines.push(` ${entry.key} (used in ${entry.files.join(', ')})`);\n }\n }\n const errors = result.broken.filter((entry) => entry.severity === 'error');\n if (errors.length > 0) {\n lines.push('broken translations:');\n for (const entry of errors) lines.push(` [${entry.locale}] ${entry.key}: ${entry.issue}`);\n }\n return lines.join('\\n');\n}\n\n// what to do about each kind of failure: extract only fixes one of the three\nexport function checkNextSteps(result: CheckResult): string {\n const steps: string[] = [];\n if (result.missing.length > 0) {\n steps.push(\n 'missing: run `npx verbaly extract` to scaffold the keys, then fill them (or run `npx verbaly translate`)',\n );\n }\n if (result.unknown.length > 0) {\n steps.push(\n 'unknown keys: the key used in the code is in no catalog, fix the key or run `npx verbaly extract`',\n );\n }\n if (result.broken.some((entry) => entry.severity === 'error')) {\n steps.push(\n 'broken: a translation has to keep the params, tags and plural cases of its source message',\n );\n }\n return steps.join('\\n');\n}\n\n// warnings never fail the gate, so they print on their own\nexport function formatCheckWarnings(result: CheckResult): string {\n return result.broken\n .filter((entry) => entry.severity === 'warning')\n .map((entry) => ` [${entry.locale}] ${entry.key}: ${entry.issue}`)\n .join('\\n');\n}\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? text.slice(0, max - 1) + '…' : text;\n}\n\n// GitHub workflow commands: every failure becomes a clickable ::error annotation on the PR\nexport function githubCheckAnnotations(\n result: CheckResult,\n registry: MessageRegistry,\n root: string,\n): string[] {\n const messages = registry.messages();\n const contents = new Map<string, string | undefined>();\n const readSource = (file: string): string | undefined => {\n if (!contents.has(file)) {\n try {\n contents.set(file, readFileSync(file, 'utf8'));\n } catch {\n contents.set(file, undefined);\n }\n }\n return contents.get(file);\n };\n\n const lines: string[] = [];\n\n // one annotation per key, locales grouped: N locales must not bury the PR in N copies\n const byKey = new Map<string, MissingEntry & { locales: string[] }>();\n for (const entry of result.missing) {\n const grouped = byKey.get(entry.key);\n if (grouped) grouped.locales.push(entry.locale);\n else byKey.set(entry.key, { ...entry, locales: [entry.locale] });\n }\n\n for (const entry of byKey.values()) {\n const origin = messages.get(entry.key);\n const hint = entry.source ? `: \"${truncate(entry.source, 60)}\"` : '';\n const text = escapeData(`missing [${entry.locales.join(', ')}] ${entry.key}${hint}`);\n if (origin) {\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::error file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n } else {\n lines.push(`::error::${text}`);\n }\n }\n\n for (const entry of result.unknown) {\n const text = escapeData(`unknown key \"${entry.key}\" (not in any catalog)`);\n const file = entry.files[0];\n lines.push(\n file\n ? `::error file=${escapeProperty(relative(root, file).replaceAll('\\\\', '/'))}::${text}`\n : `::error::${text}`,\n );\n }\n\n // a broken translation points at the source line that wrote the message\n for (const entry of result.broken) {\n const origin = messages.get(entry.key);\n const text = escapeData(`[${entry.locale}] ${entry.key}: ${entry.issue}`);\n const command = entry.severity === 'error' ? 'error' : 'warning';\n if (!origin) {\n lines.push(`::${command}::${text}`);\n continue;\n }\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::${command} file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n }\n return lines;\n}\n\nfunction lineAt(content: string, offset: number): number {\n let line = 1;\n const end = Math.min(offset, content.length);\n for (let i = 0; i < end; i++) {\n if (content[i] === '\\n') line += 1;\n }\n return line;\n}\n\nfunction escapeData(text: string): string {\n return text.replaceAll('%', '%25').replaceAll('\\r', '%0D').replaceAll('\\n', '%0A');\n}\n\nfunction escapeProperty(text: string): string {\n return escapeData(text).replaceAll(':', '%3A').replaceAll(',', '%2C');\n}\n","import MagicString from 'magic-string';\nimport type { Analysis } from './analyze';\nimport { analyzeFile } from './sfc';\nimport { warnParseError } from './warn';\n\nexport interface TransformResult {\n code: string;\n map: ReturnType<MagicString['generateMap']>;\n}\n\nfunction quote(text: string, single: boolean | undefined): string {\n if (!single) return JSON.stringify(text);\n return `'${text.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n}\n\nexport function transformCode(\n code: string,\n file: string,\n analysis?: Analysis,\n): TransformResult | null {\n const own = analysis ?? analyzeFile(code, file);\n if (!analysis && own.parseError) warnParseError(file, own.parseError);\n const { tagged } = own;\n if (tagged.length === 0) return null;\n\n const s = new MagicString(code);\n for (const msg of tagged) {\n const seen = new Set<string>();\n const entries = msg.params.filter((p) => !seen.has(p.name) && seen.add(p.name));\n const pairs = entries\n .map((p) => `${quote(p.name, msg.singleQuote)}: ${code.slice(p.start, p.end)}`)\n .join(', ');\n\n if (msg.jsx) {\n const values = entries.length ? ` values={{ ${pairs} }}` : '';\n const components = msg.jsx.components.length\n ? ` components={{ ${msg.jsx.components\n .map((c) => `${JSON.stringify(c.name)}: ${c.source}`)\n .join(', ')} }}`\n : '';\n s.overwrite(\n msg.start,\n msg.end,\n `<${msg.jsx.name} id=${JSON.stringify(msg.key)}${values}${components} />`,\n );\n continue;\n }\n\n const tagSource = code.slice(msg.tagStart, msg.tagEnd);\n const args = entries.length ? `, { ${pairs} }` : '';\n s.overwrite(msg.start, msg.end, `${tagSource}(${quote(msg.key, msg.singleQuote)}${args})`);\n }\n return { code: s.toString(), map: s.generateMap({ hires: true }) };\n}\n","import { relative } from 'node:path';\nimport picomatch from 'picomatch';\nimport { loadCatalogs, type Catalog, type Catalogs } from './catalog';\nimport { check, checkNextSteps, formatCheckResult, gatePasses } from './check';\nimport { VIRTUAL_ID, generateLocaleModule, generateRuntimeModule } from './codegen';\nimport type { ResolvedConfig, VerbalyConfig } from './config';\nimport type { MessageRegistry } from './registry';\nimport { analyzeFile } from './sfc';\nimport { transformCode, type TransformResult } from './transform';\nimport { warnParseError } from './warn';\n\nexport interface PluginOptions extends VerbalyConfig {\n failOnMissing?: boolean;\n}\n\nexport const RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID;\nexport const LOCALE_MODULE_PREFIX = `${RESOLVED_VIRTUAL_ID}/locale/`;\nexport const SOURCE_FILE_RE = /\\.(?:[cm]?[jt]sx?|svelte|vue|astro)$/;\n\nexport function resolveVirtualId(id: string): string | undefined {\n if (id === VIRTUAL_ID || id.startsWith(`${VIRTUAL_ID}/`)) return '\\0' + id;\n return undefined;\n}\n\nexport function loadVirtualModule(\n id: string,\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n): string | undefined {\n if (id === RESOLVED_VIRTUAL_ID) return generateRuntimeModule(cfg);\n if (id.startsWith(LOCALE_MODULE_PREFIX)) {\n return generateLocaleModule(catalogs[id.slice(LOCALE_MODULE_PREFIX.length)] ?? {});\n }\n return undefined;\n}\n\nexport function isTransformTarget(id: string): boolean {\n return SOURCE_FILE_RE.test(id) && !id.includes('node_modules') && !id.startsWith('\\0');\n}\n\nexport function createSourceFilter(cfg: ResolvedConfig): (id: string) => boolean {\n if (cfg.include.length === 0) return () => false;\n const matches = picomatch(cfg.include, { ignore: cfg.exclude });\n return (id) => {\n const rel = relative(cfg.root, id).replaceAll('\\\\', '/');\n return !rel.startsWith('..') && matches(rel);\n };\n}\n\n// analyze + register + rewrite: the per-file transform every bundler plugin runs\nexport function transformSource(\n code: string,\n id: string,\n registry: MessageRegistry,\n): { messages: Catalog; result: TransformResult | null } {\n const analysis = analyzeFile(code, id);\n registry.update(id, analysis);\n if (analysis.parseError) warnParseError(id, analysis.parseError);\n // key → text for live extraction; first wins, mirroring the registry's collision rule\n const messages: Catalog = {};\n for (const msg of analysis.tagged) messages[msg.key] ??= msg.message;\n return { messages, result: transformCode(code, id, analysis) ?? null };\n}\n\n// the one build-blocking error message, kept in one place (undefined = gate on)\nexport function runBuildGate(\n cfg: ResolvedConfig,\n registry: MessageRegistry,\n failOnMissing?: boolean,\n): void {\n const found = check(cfg, loadCatalogs(cfg), registry);\n // false = build with untranslated strings, never with broken ones: those render wrong\n const result = failOnMissing === false ? { ...found, missing: [] } : found;\n if (gatePasses(result)) return;\n throw new Error(\n `[verbaly] build blocked\\n${formatCheckResult(result)}\\n${checkNextSteps(result)}`,\n );\n}\n","import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type { Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\n\nexport const DRAFTS_FILE = '.verbaly-drafts.json';\n\nexport type Drafts = Record<string, string[]>;\n\nfunction draftsPath(cfg: ResolvedConfig): string {\n return join(cfg.dir, DRAFTS_FILE);\n}\n\nexport function loadDrafts(cfg: ResolvedConfig): Drafts {\n let content: string;\n try {\n content = readFileSync(draftsPath(cfg), 'utf8');\n } catch {\n return {};\n }\n try {\n return JSON.parse(content.replace(/^\\uFEFF/, '')) as Drafts;\n } catch (error) {\n throw new Error(`[verbaly] ${draftsPath(cfg)} is not valid JSON, fix or delete the file`, {\n cause: error,\n });\n }\n}\n\nfunction serializeDrafts(drafts: Drafts): string {\n const sorted: Drafts = {};\n for (const locale of Object.keys(drafts).sort()) {\n const keys = [...new Set(drafts[locale])].sort();\n if (keys.length) sorted[locale] = keys;\n }\n return JSON.stringify(sorted, null, 2) + '\\n';\n}\n\n// content-compared like catalogs: an unchanged write must not churn the file\nexport function saveDrafts(cfg: ResolvedConfig, drafts: Drafts): void {\n const serialized = serializeDrafts(drafts);\n const path = draftsPath(cfg);\n try {\n if (readFileSync(path, 'utf8') === serialized) return;\n } catch {\n mkdirSync(cfg.dir, { recursive: true });\n }\n writeFileSync(path, serialized);\n}\n\nexport function markDrafts(drafts: Drafts, locale: string, keys: string[]): void {\n if (!keys.length) return;\n drafts[locale] = [...new Set([...(drafts[locale] ?? []), ...keys])];\n}\n\n// clears specific keys, or the whole locale when keys is omitted (approve everything)\nexport function clearDrafts(drafts: Drafts, locale: string, keys?: string[]): void {\n if (!drafts[locale]) return;\n if (!keys) {\n delete drafts[locale];\n return;\n }\n const drop = new Set(keys);\n drafts[locale] = drafts[locale].filter((key) => !drop.has(key));\n if (!drafts[locale].length) delete drafts[locale];\n}\n\n// a draft counts only while its translation is present: a pruned key is missing, not a draft\nexport function effectiveDrafts(drafts: Drafts, catalogs: Catalogs): Drafts {\n const out: Drafts = {};\n for (const [locale, keys] of Object.entries(drafts)) {\n const catalog = catalogs[locale] ?? {};\n const live = keys.filter((key) => catalog[key]);\n if (live.length) out[locale] = live;\n }\n return out;\n}\n","// counts read like text, so the tool that translates apps never prints \"1 messages\"\nexport function counted(count: number, noun: string, many = `${noun}s`): string {\n return `${count} ${count === 1 ? noun : many}`;\n}\n","import type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\nimport { effectiveDrafts, type Drafts } from './drafts';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { MessageRegistry } from './registry';\nimport { counted } from './text';\nimport { validateMessage, validatePair } from './validate';\n\nexport interface LocaleStatus {\n locale: string;\n translated: number;\n total: number;\n drafts: number;\n broken: number;\n}\n\nexport interface StatusResult {\n messages: number;\n source: string;\n locales: LocaleStatus[];\n}\n\n// coverage overview for humans; check stays the CI gate\nexport function status(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n drafts: Drafts = {},\n): StatusResult {\n const extracted = registry.messages();\n\n // one flat view per locale, like check: the shape t() sees, counted leaf by leaf\n const flat: Record<string, Catalog> = {};\n for (const locale of cfg.locales) {\n flat[locale] = flatten((catalogs[locale] ?? {}) as MessageTree);\n }\n const source = flat[cfg.sourceLocale] ?? {};\n const needed = new Set<string>([...extracted.keys(), ...Object.keys(source)]);\n const live = effectiveDrafts(drafts, flat);\n\n const locales: LocaleStatus[] = [];\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n const catalog = flat[locale] ?? {};\n let translated = 0;\n for (const key of needed) {\n if (catalog[key]) translated += 1;\n }\n let broken = 0;\n for (const [key, text] of Object.entries(catalog)) {\n if (!text) continue;\n const from = source[key] ?? extracted.get(key)?.message;\n const issues = [...validateMessage(text, locale), ...(from ? validatePair(from, text) : [])];\n if (issues.some((issue) => issue.severity === 'error')) broken += 1;\n }\n locales.push({\n locale,\n translated,\n total: needed.size,\n drafts: live[locale]?.length ?? 0,\n broken,\n });\n }\n return { messages: needed.size, source: cfg.sourceLocale, locales };\n}\n\nexport function formatStatusResult(result: StatusResult): string {\n const lines = [`[verbaly] ${counted(result.messages, 'message')} · source: ${result.source}`];\n if (result.locales.length === 0) {\n lines.push(' no target locales (add locales to your config)');\n return lines.join('\\n');\n }\n for (const { locale, translated, total, drafts, broken } of result.locales) {\n const pct = total === 0 ? 100 : Math.floor((translated / total) * 100);\n const mark = translated === total && broken === 0 ? ' ✓' : '';\n const notes = [\n drafts > 0 ? `${drafts} unreviewed` : '',\n broken > 0 ? `${broken} broken` : '',\n ].filter(Boolean);\n const note = notes.length > 0 ? `, ${notes.join(', ')}` : '';\n lines.push(` ${locale}: ${translated}/${total} translated (${pct}%${note})${mark}`);\n }\n return lines.join('\\n');\n}\n","import type { Catalogs } from './catalog';\nimport { targetLocales, type ResolvedConfig } from './config';\nimport { counted } from './text';\nimport { validateMessage, validatePair } from './validate';\n\nexport interface TranslateRequest {\n sourceLocale: string;\n targetLocale: string;\n messages: Record<string, string>;\n origins?: Record<string, string[]>;\n instructions?: string;\n glossary?: Record<string, string>;\n}\n\nexport type TranslateProvider = (request: TranslateRequest) => Promise<Record<string, string>>;\n\nexport interface TranslateProgress {\n locale: string;\n batch: number;\n batches: number;\n keys: number;\n error?: string;\n}\n\nexport interface TranslateOptions {\n locales?: string[];\n batchSize?: number;\n concurrency?: number;\n retries?: number;\n retryDelay?: number;\n dryRun?: boolean;\n origins?: Record<string, string[]>;\n onProgress?: (progress: TranslateProgress) => void;\n}\n\n// carries its reason, which the per-locale records cannot: a batch fails as a batch\nexport interface TranslateFailure {\n locale: string;\n keys: string[];\n error: string;\n}\n\nexport interface TranslateResult {\n translated: Record<string, string[]>;\n invalid: Record<string, string[]>;\n pending: Record<string, string[]>;\n failed: TranslateFailure[];\n}\n\ninterface Batch {\n locale: string;\n index: number;\n batches: number;\n keys: string[];\n}\n\nconst RETRY_STATUS = new Set([408, 409, 425, 429, 500, 502, 503, 504, 529]);\n\n// a provider is an extension point: retry what looks transient, never a request the api refused\nfunction retryable(error: unknown): boolean {\n const status = (error as { status?: number; statusCode?: number } | null)?.status;\n const code = (error as { statusCode?: number } | null)?.statusCode;\n const value = typeof status === 'number' ? status : code;\n return typeof value === 'number' ? RETRY_STATUS.has(value) : true;\n}\n\nfunction reason(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nconst wait = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));\n\n// a batch that never gets an answer is a failed batch, never a thrown run: everything else lands\nasync function attempt(\n run: () => Promise<Record<string, string>>,\n retries: number,\n delay: number,\n): Promise<Record<string, string>> {\n for (let round = 0; ; round++) {\n try {\n return await run();\n } catch (error) {\n if (round >= retries || !retryable(error)) throw error;\n await wait(delay * 2 ** round);\n }\n }\n}\n\n// bounded pool: independent batches, so the only reason to serialize them is the provider's limit\nasync function pooled<T>(jobs: T[], limit: number, run: (job: T) => Promise<void>): Promise<void> {\n let next = 0;\n const workers = Array.from({ length: Math.min(limit, jobs.length) }, async () => {\n while (next < jobs.length) {\n await run(jobs[next++]!);\n }\n });\n await Promise.all(workers);\n}\n\n// fills '' entries via the provider; invalid translations stay '' (check keeps failing)\nexport async function translateCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n provider: TranslateProvider,\n options: TranslateOptions = {},\n): Promise<TranslateResult> {\n const batchSize = options.batchSize ?? 20;\n const concurrency = Math.max(1, options.concurrency ?? 4);\n const retries = Math.max(0, options.retries ?? 2);\n const retryDelay = options.retryDelay ?? 500;\n const targets = targetLocales(cfg, options.locales);\n const source = catalogs[cfg.sourceLocale] ?? {};\n const result: TranslateResult = { translated: {}, invalid: {}, pending: {}, failed: [] };\n\n const jobs: Batch[] = [];\n for (const locale of targets) {\n const catalog = (catalogs[locale] ??= {});\n const missing = Object.keys(source).filter((key) => source[key] && !catalog[key]);\n if (missing.length === 0) continue;\n\n if (options.dryRun) {\n result.pending[locale] = missing;\n continue;\n }\n\n const batches = Math.ceil(missing.length / batchSize);\n for (let i = 0; i < missing.length; i += batchSize) {\n const index = Math.floor(i / batchSize) + 1;\n jobs.push({ locale, index, batches, keys: missing.slice(i, i + batchSize) });\n }\n }\n\n await pooled(jobs, concurrency, async (job) => {\n const { locale, keys } = job;\n const catalog = catalogs[locale]!;\n const messages = Object.fromEntries(keys.map((key) => [key, source[key]!]));\n const origins = options.origins\n ? Object.fromEntries(\n keys.filter((key) => options.origins![key]).map((key) => [key, options.origins![key]!]),\n )\n : undefined;\n\n let out: Record<string, string>;\n try {\n out = await attempt(\n () =>\n provider({\n sourceLocale: cfg.sourceLocale,\n targetLocale: locale,\n messages,\n origins,\n instructions: cfg.translate.instructions,\n glossary: glossaryFor(cfg, locale, messages),\n }),\n retries,\n retryDelay,\n );\n } catch (error) {\n const message = reason(error);\n result.failed.push({ locale, keys, error: message });\n options.onProgress?.({ ...progressOf(job), error: message });\n return;\n }\n\n for (const key of keys) {\n const text = out[key];\n if (typeof text === 'string' && text.trim() && structureMatches(source[key]!, text)) {\n catalog[key] = text;\n (result.translated[locale] ??= []).push(key);\n } else {\n (result.invalid[locale] ??= []).push(key);\n }\n }\n options.onProgress?.(progressOf(job));\n });\n\n // batches land out of order once they run in parallel, and a report has to read the same twice\n for (const locale of Object.keys(result.translated)) result.translated[locale]!.sort();\n for (const locale of Object.keys(result.invalid)) result.invalid[locale]!.sort();\n result.failed.sort((a, b) => a.locale.localeCompare(b.locale) || compare(a.keys, b.keys));\n return result;\n}\n\nfunction compare(a: string[], b: string[]): number {\n return (a[0] ?? '').localeCompare(b[0] ?? '');\n}\n\n// the same reason repeats across batches: say it once and name every key it cost\nexport function formatTranslateFailures(failed: TranslateFailure[]): string[] {\n const grouped: TranslateFailure[] = [];\n for (const entry of failed) {\n const same = grouped.find((it) => it.locale === entry.locale && it.error === entry.error);\n if (same) same.keys = [...same.keys, ...entry.keys];\n else grouped.push({ ...entry, keys: [...entry.keys] });\n }\n return grouped.map(\n ({ locale, error, keys }) =>\n ` ${locale}: ${counted(keys.length, 'message')} not translated (${error}): ${keys.join(', ')}`,\n );\n}\n\n// config provider wins; claude loads lazily so only translate pays for its optional SDK\nexport async function resolveProvider(\n cfg: ResolvedConfig,\n model?: string,\n): Promise<TranslateProvider> {\n const configured = cfg.translate.provider;\n if (typeof configured === 'function') return configured;\n const { claudeProvider } = await import('./providers/claude');\n return claudeProvider({ model: model ?? cfg.translate.model });\n}\n\n// no locale on purpose: a locale-specific plural gap must never drop a translator's file\nexport function structureMatches(source: string, translated: string): boolean {\n try {\n const issues = [...validateMessage(translated), ...validatePair(source, translated)];\n return !issues.some((issue) => issue.severity === 'error');\n } catch {\n return false; // unparseable input rejects the translation, it never crashes the caller\n }\n}\n\nfunction progressOf(job: Batch): TranslateProgress {\n return { locale: job.locale, batch: job.index, batches: job.batches, keys: job.keys.length };\n}\n\n// only the terms this batch actually contains: a glossary of hundreds must not become the prompt\nfunction glossaryFor(\n cfg: ResolvedConfig,\n locale: string,\n messages: Record<string, string>,\n): Record<string, string> | undefined {\n const entries = cfg.translate.glossary;\n if (!entries) return undefined;\n const text = Object.values(messages).join('\\n').toLowerCase();\n const out: Record<string, string> = {};\n for (const [term, rendering] of Object.entries(entries)) {\n if (!text.includes(term.toLowerCase())) continue;\n const value = typeof rendering === 'string' ? rendering : rendering[locale];\n if (value) out[term] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { findConfigFile } from './config';\n\nexport interface InitOptions {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n}\n\nexport interface InitResult {\n created: string[];\n skipped: string[];\n host: Host | undefined;\n configFile: string;\n next: string[];\n}\n\nexport type Host =\n 'nuxt' | 'next' | 'sveltekit' | 'astro' | 'vite' | 'webpack' | 'rspack' | 'rollup' | 'esbuild';\n\nexport interface HostSetup {\n name: Host;\n pkg: string;\n wire: string;\n}\n\nconst HOSTS: (HostSetup & { dep: string })[] = [\n {\n name: 'nuxt',\n dep: 'nuxt',\n pkg: '@verbaly/nuxt',\n wire: \"add '@verbaly/nuxt' to the modules in nuxt.config\",\n },\n {\n name: 'next',\n dep: 'next',\n pkg: '@verbaly/next',\n wire: 'wrap the export of next.config with withVerbaly',\n },\n {\n name: 'sveltekit',\n dep: '@sveltejs/kit',\n pkg: '@verbaly/vite',\n wire: 'add verbaly() to the plugins in vite.config (per-request locale: @verbaly/sveltekit)',\n },\n {\n name: 'astro',\n dep: 'astro',\n pkg: '@verbaly/astro',\n wire: 'add verbaly() to the integrations in astro.config',\n },\n {\n name: 'vite',\n dep: 'vite',\n pkg: '@verbaly/vite',\n wire: 'add verbaly() to the plugins in vite.config',\n },\n {\n name: 'webpack',\n dep: 'webpack',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly webpack plugin to your build config',\n },\n {\n name: 'rspack',\n dep: '@rspack/core',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly rspack plugin to your build config',\n },\n {\n name: 'rollup',\n dep: 'rollup',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly rollup plugin to your build config',\n },\n {\n name: 'esbuild',\n dep: 'esbuild',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly esbuild plugin to your build config',\n },\n];\n\n// any of these wires the build; the detected host only decides which one we recommend\nexport const WIRING_PACKAGES = [...new Set(HOSTS.map((host) => host.pkg))];\n\nexport function readDependencies(root: string): Record<string, string> {\n const path = join(root, 'package.json');\n if (!existsSync(path)) return {};\n try {\n const pkg = JSON.parse(readFileSync(path, 'utf8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return { ...pkg.dependencies, ...pkg.devDependencies };\n } catch {\n return {};\n }\n}\n\nexport function detectHost(root: string): HostSetup | undefined {\n const deps = readDependencies(root);\n return HOSTS.find((host) => deps[host.dep]);\n}\n\nfunction configSource(options: InitOptions, typescript: boolean): string {\n const fields = [` sourceLocale: '${options.sourceLocale ?? 'en'}',`];\n if (options.locales?.length) {\n fields.push(` locales: [${options.locales.map((l) => `'${l}'`).join(', ')}],`);\n }\n if (options.dir) fields.push(` dir: '${options.dir}',`);\n const body = `export default {\\n${fields.join('\\n')}\\n}`;\n if (typescript) {\n return `import type { VerbalyConfig } from '@verbaly/compiler';\\n\\n${body} satisfies VerbalyConfig;\\n`;\n }\n return `/** @type {import('@verbaly/compiler').VerbalyConfig} */\\n${body};\\n`;\n}\n\nexport function init(options: InitOptions = {}): InitResult {\n const root = options.root ?? process.cwd();\n const created: string[] = [];\n const skipped: string[] = [];\n\n const existing = findConfigFile(root);\n const typescript = existsSync(join(root, 'tsconfig.json'));\n const configFile = existing ?? (typescript ? 'verbaly.config.ts' : 'verbaly.config.mjs');\n if (existing) {\n skipped.push(existing);\n } else {\n writeFileSync(join(root, configFile), configSource(options, typescript));\n created.push(configFile);\n }\n\n const dir = join(root, options.dir ?? 'locales');\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n for (const locale of new Set([options.sourceLocale ?? 'en', ...(options.locales ?? [])])) {\n const file = join(dir, `${locale}.json`);\n const label = relative(root, file).replaceAll('\\\\', '/');\n if (existsSync(file)) {\n skipped.push(label);\n } else {\n writeFileSync(file, '{}\\n');\n created.push(label);\n }\n }\n\n const host = detectHost(root);\n const next = host\n ? [`pnpm add -D ${host.pkg}`, host.wire]\n : ['run \"verbaly extract\" after writing your first t`…` message'];\n\n return { created, skipped, host: host?.name, configFile, next };\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport { badLeaf, type Catalogs } from './catalog';\nimport { check } from './check';\nimport { generateDts } from './codegen';\nimport { findConfigFile, type ResolvedConfig } from './config';\nimport { extractProject } from './extract';\nimport { detectHost, readDependencies, WIRING_PACKAGES } from './init';\nimport { counted } from './text';\nimport { escapedSyntax } from './validate';\n\nexport interface DoctorEntry {\n level: 'ok' | 'warn' | 'error';\n check: string;\n message: string;\n fix?: string;\n}\n\nexport interface DoctorResult {\n ok: boolean; // no error-level entries (warns allowed)\n entries: DoctorEntry[];\n}\n\nconst PREVIEW = 5; // keys shown before \"…\"\n\n// a mode nobody wrote down was inferred, and doctor says which of the two it is reading\nfunction readRoutingChoice(root: string, configFile: string): boolean {\n try {\n return /\\brouting[\"']?\\s*[:=]/.test(readFileSync(join(root, configFile), 'utf8'));\n } catch {\n return false;\n }\n}\n\nconst ROUTING_SAYS: Record<ResolvedConfig['routing'], string> = {\n 'prefix-except-source': 'the source locale has no prefix, every other locale does',\n 'prefix-all': 'every locale has a prefix, the source included',\n 'no-prefix': 'the language is not in the url, one address serves every locale',\n};\n\nconst ICON = { ok: '✓', warn: '⚠', error: '✗' } as const;\n\n// one definition of a doctor line: the cli routes it by level, the mcp tool joins the block\nexport function formatDoctorEntry(entry: DoctorEntry): string {\n const head = ` ${ICON[entry.level]} ${entry.check}: ${entry.message}`;\n return entry.fix\n ? `${head}\n fix: ${entry.fix}`\n : head;\n}\n\nexport async function doctor(cfg: ResolvedConfig): Promise<DoctorResult> {\n const entries: DoctorEntry[] = [];\n const ok = (name: string, message: string) => entries.push({ level: 'ok', check: name, message });\n const warn = (name: string, message: string, fix: string) =>\n entries.push({ level: 'warn', check: name, message, fix });\n const error = (name: string, message: string, fix: string) =>\n entries.push({ level: 'error', check: name, message, fix });\n const rel = (path: string) => relative(cfg.root, path).replaceAll('\\\\', '/');\n\n const configFile = findConfigFile(cfg.root);\n if (configFile) ok('config', `${configFile} found`);\n else warn('config', 'no config file, running on defaults', 'run `npx verbaly init`');\n\n const catalogs: Catalogs = {};\n let catalogsHealthy = true;\n if (!existsSync(cfg.dir)) {\n catalogsHealthy = false;\n error(\n 'catalogs',\n `catalogs directory ${rel(cfg.dir)}/ does not exist`,\n 'run `npx verbaly init` to scaffold it',\n );\n } else {\n for (const locale of cfg.locales) {\n const file = join(cfg.dir, `${locale}.json`);\n if (!existsSync(file)) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is missing`,\n 'run `npx verbaly extract` to create it',\n );\n continue;\n }\n try {\n const parsed = JSON.parse(readFileSync(file, 'utf8')) as MessageTree;\n // nested groups are a real shape: only a leaf that is not text is broken\n const bad = badLeaf(parsed);\n if (bad) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} has a non-string value at \"${bad}\"`,\n 'catalog values are text (groups of text are fine); fix the value',\n );\n } else {\n catalogs[locale] = flatten(parsed);\n }\n } catch {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is not valid JSON`,\n 'repair the file (or delete it and run `npx verbaly extract`)',\n );\n }\n }\n if (catalogsHealthy) {\n ok(\n 'catalogs',\n `${counted(cfg.locales.length, 'locale')} (${cfg.locales.join(', ')}) in ${rel(cfg.dir)}/`,\n );\n }\n }\n\n const source = catalogs[cfg.sourceLocale];\n if (source && Object.keys(source).length === 0) {\n warn(\n 'source',\n `source catalog ${cfg.sourceLocale}.json is empty`,\n 'write your first t`…` message and run `npx verbaly extract`',\n );\n }\n\n const mirrors = cfg.render.site !== undefined || Object.keys(cfg.render).length > 0;\n if (cfg.routing === 'no-prefix' && mirrors) {\n warn(\n 'routing',\n 'routing is \"no-prefix\" but a render section is configured, and render writes one url tree per locale',\n 'drop the render section, or set routing to \"prefix-except-source\" so the helpers agree with the urls',\n );\n } else {\n const named = configFile ? readRoutingChoice(cfg.root, configFile) : false;\n const how = named ? '' : ' (from your setup, no routing set)';\n ok('routing', `${cfg.routing}${how}: ${ROUTING_SAYS[cfg.routing]}`);\n }\n\n const deps = readDependencies(cfg.root);\n const host = detectHost(cfg.root);\n const installed = WIRING_PACKAGES.find((pkg) => deps[pkg]);\n if (!host) {\n ok('plugin', 'no framework or bundler detected, the CLI flow (extract/check) applies');\n } else if (installed) {\n ok('plugin', `${installed} installed for ${host.name}`);\n } else {\n warn(\n 'plugin',\n `${host.name} detected but ${host.pkg} is not installed`,\n `pnpm add -D ${host.pkg} and ${host.wire}`,\n );\n }\n\n // with include: [] no code is read, so orphans and types cannot be claimed here\n const scanning = cfg.include.length > 0;\n if (!scanning) {\n ok('sources', 'source scanning is off (include: []), the catalogs are the source of truth');\n }\n\n if (source && scanning && cfg.dts !== false) {\n const dtsPath = cfg.dts ?? join(cfg.root, 'verbaly.d.ts');\n if (!existsSync(dtsPath)) {\n warn('types', 'verbaly.d.ts has not been generated', 'run `npx verbaly extract`');\n } else if (readFileSync(dtsPath, 'utf8') !== generateDts(source)) {\n warn('types', 'verbaly.d.ts is stale', 'run `npx verbaly extract`');\n } else {\n ok('types', 'verbaly.d.ts is up to date');\n }\n }\n\n const registry = await extractProject(cfg);\n if (scanning) {\n // a warn, not an error: decorators or a dialect babel does not read still build in the project\n const unreadable = registry.parseErrors();\n if (unreadable.length > 0) {\n const first = unreadable[0]!;\n warn(\n 'sources',\n `could not parse ${counted(unreadable.length, 'file')}, so the messages inside are not extracted (${rel(first.file)}: ${first.message})`,\n 'fix the syntax error, or exclude the file in your config if it is not source',\n );\n }\n const stray = registry.strayImports();\n if (stray.length > 0) {\n const files = [...new Set(stray.map((entry) => rel(entry.file)))];\n error(\n 'imports',\n `t is imported from a verbaly package, which never exports it, in ${counted(files.length, 'file')} (${preview(files)})`,\n 't comes from your instance (React: const t = useT()) or from virtual:verbaly',\n );\n }\n const escaped = [...registry.messages().values()]\n .map((msg) => ({ file: rel(msg.file), slice: escapedSyntax(msg.message) }))\n .filter((entry) => entry.slice !== undefined);\n if (escaped.length > 0) {\n warn(\n 'messages',\n `a block ships as literal text in ${counted(escaped.length, 'extracted message')} (${escaped[0]!.file}: ${escaped[0]!.slice})`,\n 'a tagged template takes its values from ${…}: use t(key, params) for a plural or format block',\n );\n }\n }\n if (source && scanning) {\n const extracted = registry.messages();\n const used = registry.usedKeys();\n const orphans = Object.keys(source).filter((key) => !extracted.has(key) && !used.has(key));\n if (orphans.length > 0) {\n warn(\n 'orphans',\n `${counted(orphans.length, 'catalog key')} no longer referenced in code (${preview(orphans)})`,\n 'run `npx verbaly extract --prune` to drop them',\n );\n } else {\n ok('orphans', 'no orphan keys');\n }\n }\n\n if (catalogsHealthy) {\n const result = check(cfg, catalogs, registry);\n if (result.unknown.length > 0) {\n error(\n 'keys',\n `${counted(result.unknown.length, 'unknown key')} used in code (${preview(result.unknown.map((u) => u.key))})`,\n 'fix the key or add it to the catalogs (`npx verbaly check` for details)',\n );\n }\n if (result.missing.length > 0) {\n const locales = [...new Set(result.missing.map((m) => m.locale))];\n warn(\n 'translations',\n `${counted(result.missing.length, 'missing translation')} (${locales.join(', ')})`,\n 'run `npx verbaly translate` or fill the catalogs (`npx verbaly check` for details)',\n );\n }\n // the gate fails on these, so doctor cannot keep calling the setup healthy\n const broken = result.broken.filter((entry) => entry.severity === 'error');\n if (broken.length > 0) {\n const locales = [...new Set(broken.map((b) => b.locale))];\n error(\n 'translations',\n `${counted(broken.length, 'broken translation')} (${locales.join(', ')}): present but not rendering what the source renders`,\n 'run `npx verbaly check` to read what each one lost',\n );\n }\n const warnings = result.broken.filter((entry) => entry.severity === 'warning');\n if (warnings.length > 0) {\n warn(\n 'translations',\n `${counted(warnings.length, 'structural warning')} (plural forms a language asks for)`,\n 'run `npx verbaly check` to read them, they never fail the build',\n );\n }\n if (result.ok) ok('translations', 'all translations complete');\n }\n\n return { ok: entries.every((entry) => entry.level !== 'error'), entries };\n}\n\nfunction preview(keys: string[]): string {\n const head = keys.slice(0, PREVIEW).join(', ');\n return keys.length > PREVIEW ? `${head}, …` : head;\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { parse } from '@babel/parser';\nimport MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport { cleanJsxText, isTReference, walk, type AstNode } from './analyze';\nimport type { ResolvedConfig } from './config';\n\nexport interface WrapEntry {\n file: string;\n line: number;\n text: string;\n kind: 'text' | 'attribute';\n attribute?: string;\n}\n\nexport interface WrapSkip {\n file: string;\n line: number;\n text: string;\n reason: string;\n}\n\nexport interface WrapResult {\n files: number;\n changed: string[];\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport interface WrapOptions {\n write?: boolean;\n}\n\n// user-visible string attributes worth translating; everything else stays code\nconst WRAP_ATTRS = new Set(['title', 'alt', 'placeholder', 'aria-label']);\n\nconst T_NAMES: ReadonlySet<string> = new Set(['t']);\nconst LETTER = /\\p{L}/u;\n\n// onboarding codemod: errs on skipping, never on inventing (ambiguous goes to the report)\nexport async function wrapProject(\n cfg: ResolvedConfig,\n options: WrapOptions = {},\n): Promise<WrapResult> {\n const files = (\n await glob(cfg.include, { cwd: cfg.root, ignore: cfg.exclude, absolute: true })\n ).filter((file) => /\\.[jt]sx$/.test(file));\n\n const result: WrapResult = { files: files.length, changed: [], wrapped: [], skipped: [] };\n\n for (const file of files) {\n const code = readFileSync(file, 'utf8');\n const label = relative(cfg.root, file).replaceAll('\\\\', '/');\n const out = wrapCode(code, label);\n result.wrapped.push(...out.wrapped);\n result.skipped.push(...out.skipped);\n if (out.code !== undefined) {\n result.changed.push(label);\n if (options.write) writeFileSync(file, out.code);\n }\n }\n return result;\n}\n\nexport interface WrapCodeResult {\n code?: string;\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport function wrapCode(code: string, file: string): WrapCodeResult {\n const wrapped: WrapEntry[] = [];\n const skipped: WrapSkip[] = [];\n\n let ast: AstNode;\n try {\n ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: ['typescript', 'jsx'],\n }).program as unknown as AstNode;\n } catch {\n return { wrapped, skipped }; // unparseable file: leave it alone\n }\n\n const s = new MagicString(code);\n const visited = new Set<AstNode>();\n let changed = false;\n\n walk(ast, (node) => {\n if (node.type !== 'JSXElement' && node.type !== 'JSXFragment') return;\n if (visited.has(node)) return;\n processElement(node);\n });\n\n return changed ? { code: s.toString(), wrapped, skipped } : { wrapped, skipped };\n\n function processElement(node: AstNode): void {\n visited.add(node);\n\n if (node.type === 'JSXElement') {\n const opening = node.openingElement as AstNode;\n const name = opening.name as AstNode;\n // <Trans> children and data-verbaly subtrees are already message-managed\n if (name.type === 'JSXIdentifier' && name.name === 'Trans') return markSubtree(node);\n if (hasVerbalyAttr(opening)) return markSubtree(node);\n wrapAttributes(opening);\n }\n\n const children = (node.children as AstNode[] | undefined) ?? [];\n const hasElementChild = children.some(\n (c) => c.type === 'JSXElement' || c.type === 'JSXFragment',\n );\n const hasText = children.some(\n (c) =>\n (c.type === 'JSXText' && LETTER.test(c.value as string)) ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type === 'StringLiteral' &&\n LETTER.test((c.expression as AstNode).value as string)),\n );\n\n if (hasElementChild && hasText) {\n // splitting the sentence into fragments would ship broken translations\n skip(node, snippet(children), 'mixed text and markup: wrap by hand or use <Trans>');\n return markSubtree(node);\n }\n if (hasText) {\n wrapSegment(node, children);\n return markSubtree(node);\n }\n for (const child of children) {\n if (child.type === 'JSXElement' || child.type === 'JSXFragment') processElement(child);\n }\n }\n\n function wrapSegment(parent: AstNode, children: AstNode[]): void {\n const meaningful = children.filter(\n (c) =>\n (c.type === 'JSXText' && (c.value as string).trim() !== '') ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type !== 'JSXEmptyExpression'),\n );\n if (meaningful.length === 0) return;\n\n const first = meaningful[0]!;\n const last = meaningful[meaningful.length - 1]!;\n\n let template = '';\n let report = '';\n for (let i = children.indexOf(first); i <= children.indexOf(last); i++) {\n const child = children[i]!;\n if (child.type === 'JSXText') {\n let value = cleanJsxText(child.value as string);\n if (child === first) value = value.trimStart();\n if (child === last) value = value.trimEnd();\n template += escapeTemplate(value);\n report += value;\n } else if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression as AstNode;\n if (expr.type === 'JSXEmptyExpression') continue;\n if (usesT(expr)) {\n skip(parent, snippet(children), 'already uses t: finish it by hand');\n return;\n }\n if (containsJsx(expr)) {\n skip(\n parent,\n snippet(children),\n 'an expression renders markup: wrap by hand or use <Trans>',\n );\n markSubtree(child);\n return;\n }\n if (expr.type === 'StringLiteral') {\n template += escapeTemplate(expr.value as string);\n report += expr.value as string;\n } else {\n const source = code.slice(expr.start, expr.end);\n template += '${' + source + '}';\n report += '${' + source + '}';\n }\n } else {\n return; // spread children and friends: bail quietly\n }\n }\n if (!LETTER.test(report)) return;\n\n const start =\n first.type === 'JSXText' ? first.start + leadingWs(first.value as string) : first.start;\n const end = last.type === 'JSXText' ? last.end - trailingWs(last.value as string) : last.end;\n\n s.overwrite(start, end, '{t`' + template + '`}');\n changed = true;\n wrapped.push({ file, line: line(first), text: report, kind: 'text' });\n }\n\n function wrapAttributes(opening: AstNode): void {\n for (const attr of opening.attributes as AstNode[]) {\n if (attr.type !== 'JSXAttribute') continue;\n const name = attr.name as AstNode;\n if (name.type !== 'JSXIdentifier' || !WRAP_ATTRS.has(name.name as string)) continue;\n const value = attr.value as AstNode | null;\n if (value?.type !== 'StringLiteral') continue;\n const raw = value.value as string;\n if (!LETTER.test(raw)) continue;\n s.overwrite(value.start, value.end, '{t`' + escapeTemplate(raw) + '`}');\n changed = true;\n wrapped.push({\n file,\n line: line(value),\n text: raw,\n kind: 'attribute',\n attribute: name.name as string,\n });\n }\n }\n\n function skip(node: AstNode, text: string, reason: string): void {\n skipped.push({ file, line: line(node), text, reason });\n }\n\n function snippet(children: AstNode[]): string {\n const start = children[0]?.start ?? 0;\n const end = children[children.length - 1]?.end ?? start;\n const text = code.slice(start, end).replace(/\\s+/g, ' ').trim();\n return text.length > 60 ? text.slice(0, 59) + '…' : text;\n }\n\n function markSubtree(node: AstNode): void {\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') visited.add(n);\n });\n }\n}\n\nfunction hasVerbalyAttr(opening: AstNode): boolean {\n return (opening.attributes as AstNode[]).some((attr) => {\n if (attr.type !== 'JSXAttribute') return false;\n const name = attr.name as AstNode;\n return name.type === 'JSXIdentifier' && (name.name as string).startsWith('data-verbaly');\n });\n}\n\n// a t`…` / t(...) / t.id anywhere in the expression means a human already started here\nfunction usesT(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'TaggedTemplateExpression' && isTReference(n.tag as AstNode, T_NAMES)) {\n found = true;\n }\n if (n.type === 'CallExpression' && isTReference(n.callee as AstNode, T_NAMES)) found = true;\n });\n return found;\n}\n\nfunction containsJsx(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') found = true;\n });\n return found;\n}\n\n// literal text run → template-literal-safe\nfunction escapeTemplate(text: string): string {\n return text.replace(/[\\\\`]/g, '\\\\$&').replace(/\\$\\{/g, '\\\\${');\n}\n\nfunction leadingWs(text: string): number {\n return text.length - text.trimStart().length;\n}\n\nfunction trailingWs(text: string): number {\n return text.length - text.trimEnd().length;\n}\n\nfunction line(node: AstNode): number {\n const loc = node.loc as { start?: { line?: number } } | undefined;\n return loc?.start?.line ?? 1;\n}\n","import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative } from 'node:path';\nimport MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport {\n createVerbaly,\n localeDirection,\n LOCALE_STORAGE_KEY,\n normalizeLink,\n parseTags,\n RICH_TAGS,\n safeAttribute,\n VOID_TAGS,\n type MessageTree,\n type Params,\n type RichLink,\n type TagNode,\n type Verbaly,\n} from 'verbaly';\nimport type { Catalogs } from './catalog';\nimport { loadCatalogs } from './catalog';\nimport type { RedirectConfig, ResolvedConfig } from './config';\nimport { counted } from './text';\n\nexport interface Alternate {\n hreflang: string;\n href: string;\n}\n\n// links that point at a page this mirror also holds get its prefix, so the visitor stays inside\nexport interface MirrorLinks {\n prefix: string;\n base?: string;\n pages: ReadonlySet<string>;\n}\n\n// the pre-paint script: the locale set it chooses from, and where a saved choice lives\nexport interface RedirectScript {\n locales: string[];\n sourceLocale: string;\n base?: string;\n storageKey?: string | false;\n}\n\ninterface RenderHtmlBase {\n locale: string;\n sourceLocale?: string;\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n setLang?: boolean;\n alternates?: Alternate[];\n mirror?: MirrorLinks;\n redirect?: RedirectScript;\n}\n\n// one of the two, never both: an instance already carries the catalogs it was built from\nexport type RenderHtmlOptions = RenderHtmlBase &\n (\n | { catalogs: Catalogs | Record<string, MessageTree>; instance?: never }\n | { catalogs?: never; instance: Verbaly }\n );\n\n// nested trees welcome: the runtime flattens them (verbaly-web's shape)\nexport function localeInstance(\n catalogs: Catalogs | Record<string, MessageTree>,\n locale: string,\n sourceLocale: string,\n): Verbaly {\n return createVerbaly({ locale, fallback: sourceLocale, messages: catalogs });\n}\n\nexport interface RenderHtmlResult {\n html: string;\n missing: string[];\n}\n\nconst HREFLANG_OPEN = '<!--verbaly:hreflang-->';\nconst HREFLANG_CLOSE = '<!--/verbaly:hreflang-->';\nconst REDIRECT_OPEN = '<!--verbaly:redirect-->';\nconst REDIRECT_CLOSE = '<!--/verbaly:redirect-->';\n\nconst VOID = new Set(VOID_TAGS);\n\nconst START_TAG = /<([a-zA-Z][a-zA-Z0-9-]*)((?:\"[^\"]*\"|'[^']*'|[^\"'>])*)>/g;\nconst ATTR = /([^\\s=/\"'<>]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+)))?/g;\n\n// pre-fills data-verbaly elements for one locale; the runtime stays functional\nexport function renderHtml(html: string, options: RenderHtmlOptions): RenderHtmlResult {\n const attr = options.attribute ?? 'data-verbaly';\n const argsAttr = `${attr}-args`;\n const attrsAttr = `${attr}-attr`;\n const richAttr = `${attr}-rich`;\n const linksAttr = `${attr}-links`;\n const richTags = new Set(options.richTags ?? RICH_TAGS);\n const globalLinks = options.richLinks;\n const sourceLocale = options.sourceLocale ?? 'en';\n\n const v = options.instance ?? localeInstance(options.catalogs, options.locale, sourceLocale);\n const t = v.t as unknown as (key: string, params?: Params) => string;\n\n const ms = new MagicString(html);\n const missing = new Set<string>();\n const skip = protectedRanges(html);\n const inSkip = (index: number): boolean => skip.some(([from, to]) => index >= from && index < to);\n\n // a message can carry markup of its own, and MagicString refuses to edit inside what it replaced\n const filled: Array<[number, number]> = [];\n const inFilled = (index: number): boolean =>\n filled.some(([from, to]) => index >= from && index < to);\n\n // per-locale canonical/og:url: a cross-locale canonical would void the hreflang set\n const selfUrl = options.alternates?.find((a) => a.hreflang === options.locale)?.href;\n const sourceUrl = options.alternates?.find((a) => a.hreflang === 'x-default')?.href;\n const rewriteUrl = selfUrl !== undefined && selfUrl !== sourceUrl;\n\n START_TAG.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = START_TAG.exec(html)) !== null) {\n if (inSkip(m.index) || inFilled(m.index)) continue;\n const [full, rawName, attrChunk] = m as unknown as [string, string, string];\n const tagName = rawName.toLowerCase();\n const openEnd = m.index + full.length;\n\n const chunkStart = m.index + 1 + rawName.length;\n\n if (tagName === 'html' && options.setLang !== false) {\n // lang and dir together: what persistLocale/switchLocale set at runtime\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'lang', options.locale);\n setAttribute(\n ms,\n html,\n chunkStart,\n openEnd,\n attrChunk,\n 'dir',\n localeDirection(options.locale),\n );\n continue;\n }\n\n const attrs = parseAttrs(attrChunk);\n\n if (\n rewriteUrl &&\n tagName === 'link' &&\n attrs.get('rel')?.toLowerCase() === 'canonical' &&\n decodeEntities(attrs.get('href') ?? '') === sourceUrl\n ) {\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'href', selfUrl!);\n }\n if (\n rewriteUrl &&\n tagName === 'meta' &&\n attrs.get('property') === 'og:url' &&\n decodeEntities(attrs.get('content') ?? '') === sourceUrl\n ) {\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'content', selfUrl!);\n }\n\n const mirror = options.mirror;\n if (mirror) {\n if (tagName === 'a' || tagName === 'area') {\n const inside = mirroredHref(attrs.get('href'), mirror);\n if (inside) setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'href', inside);\n } else if (tagName === 'meta' && attrs.get('http-equiv')?.toLowerCase() === 'refresh') {\n // a redirect page ships inside the mirror too, and its target must not leave it\n const content = attrs.get('content') ?? '';\n const url = /^([^;]*;\\s*url\\s*=\\s*)(.*)$/i.exec(decodeEntities(content));\n const inside = url && mirroredHref(url[2], mirror);\n if (inside) {\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, 'content', `${url![1]}${inside}`);\n }\n }\n }\n\n const key = attrs.get(attr);\n const attrMapRaw = attrs.get(attrsAttr);\n if (key === undefined && attrMapRaw === undefined) continue;\n\n const args = parseArgs(attrs.get(argsAttr));\n\n if (key) {\n if (!v.has(key)) {\n missing.add(key);\n } else if (!VOID.has(tagName) && !attrChunk.trimEnd().endsWith('/')) {\n const close = findClose(html, tagName, openEnd, inSkip);\n if (close) {\n const text = t(key, args);\n const own = parseArgs(attrs.get(linksAttr)) as Record<string, RichLink> | undefined;\n const links = own ? (globalLinks ? { ...globalLinks, ...own } : own) : globalLinks;\n const content = attrs.has(richAttr)\n ? richToHtml(parseTags(text), richTags, links)\n : escapeHtml(text);\n if (html.slice(openEnd, close.contentEnd) !== content) {\n if (openEnd === close.contentEnd) ms.appendLeft(openEnd, content);\n else ms.overwrite(openEnd, close.contentEnd, content);\n }\n filled.push([openEnd, close.contentEnd]);\n }\n }\n }\n\n if (attrMapRaw !== undefined) {\n const map = parseArgs(attrMapRaw);\n if (map) {\n for (const [name, attrKey] of Object.entries(map)) {\n if (typeof attrKey !== 'string') continue;\n if (!v.has(attrKey)) {\n missing.add(attrKey);\n continue;\n }\n const value = safeAttribute(name, t(attrKey, args));\n if (value !== undefined)\n setAttribute(ms, html, chunkStart, openEnd, attrChunk, name, value);\n }\n }\n }\n }\n\n if (options.alternates?.length) injectAlternates(ms, html, options.alternates);\n if (options.redirect) injectRedirect(ms, html, options.redirect);\n\n return { html: ms.toString(), missing: [...missing] };\n}\n\n// the public path of a built page, the shape both the page set and an author's href reduce to\nexport function publicPath(rel: string): string {\n const path = `/${rel.replace(/(^|\\/)index\\.html$/, '$1')}`;\n return path.length > 1 ? path.replace(/\\/+$/, '') : path;\n}\n\n// only a root-relative link to a page the mirror contains: assets, externals and anchors stay\nfunction mirroredHref(raw: string | undefined, mirror: MirrorLinks): string | undefined {\n if (raw === undefined) return undefined;\n const href = decodeEntities(raw);\n if (!href.startsWith('/') || href.startsWith('//')) return undefined;\n const base = mirror.base ?? '';\n // hrefs carry the base the site is served under, the page set never does: compare like with like\n const inside = base ? stripBase(href, base) : href;\n if (base && inside === href) return undefined;\n const cut = inside.search(/[?#]/);\n const path = cut < 0 ? inside : inside.slice(0, cut);\n if (!mirror.pages.has(publicPath(path.replace(/^\\//, '')))) return undefined;\n return `${base}${mirror.prefix}${inside}`;\n}\n\n// the boundary check is what keeps base /app from swallowing /application\nfunction stripBase(path: string, base: string): string {\n if (!path.startsWith(base)) return path;\n const rest = path.slice(base.length);\n if (rest === '') return '/';\n return rest.startsWith('/') ? rest : path;\n}\n\n// 'app', '/app' and '/app/' all read as '/app'; nothing means the site sits at the root\nfunction normalizeBase(base: string | undefined): string {\n const trimmed = base?.replace(/^\\/+/, '').replace(/\\/+$/, '');\n return trimmed ? `/${trimmed}` : '';\n}\n\n// the narrowing of matchPathSegment, inlined: render == runtime has to hold here too\nconst REDIRECT_BODY =\n '(function(){var T=/^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|[0-9]{3}))?$/i;' +\n 'function M(t,g){t=String(t||\"\");if(S.indexOf(t)>=0)return t;if(g&&!T.test(t))return;' +\n 'while(t){var i=t.lastIndexOf(\"-\");if(i<0)return;t=t.slice(0,i);if(S.indexOf(t)>=0)return t}}' +\n 'var p=location.pathname;' +\n 'if(B){if(p.indexOf(B)!==0)return;p=p.slice(B.length)||\"/\";if(p.charAt(0)!==\"/\")return}' +\n 'if(M(p.split(\"/\")[1],1))return;' +\n 'var w;if(K)try{w=M(localStorage.getItem(K))}catch(e){}' +\n 'if(!w){var l=navigator.languages||[navigator.language];for(var i=0;i<l.length&&!w;i++)w=M(l[i])}' +\n 'if(!w||w===D)return;location.replace(B+\"/\"+w+p+location.search+location.hash)})()';\n\n// </script> can never appear in a locale code, but a catalog is untrusted and this costs nothing\nfunction jsLiteral(value: unknown): string {\n return JSON.stringify(value ?? null).replace(/</g, '\\\\u003c');\n}\n\n// pre-paint, in the source tree only: the mirror page a visitor lands on is already the answer\nfunction redirectScript(options: RedirectScript): string {\n const vars = [\n `S=${jsLiteral(options.locales)}`,\n `D=${jsLiteral(options.sourceLocale)}`,\n `B=${jsLiteral(normalizeBase(options.base))}`,\n `K=${options.storageKey === false ? 'null' : jsLiteral(options.storageKey ?? LOCALE_STORAGE_KEY)}`,\n ].join(',');\n return `<script>var ${vars};${REDIRECT_BODY};</script>`;\n}\n\n// goes first in <head> so it runs before a stylesheet can paint, idempotent via markers\nfunction injectRedirect(ms: MagicString, html: string, options: RedirectScript): void {\n const block = `${REDIRECT_OPEN}${redirectScript(options)}${REDIRECT_CLOSE}`;\n const from = html.indexOf(REDIRECT_OPEN);\n if (from !== -1) {\n const to = html.indexOf(REDIRECT_CLOSE, from);\n if (to !== -1) {\n const end = to + REDIRECT_CLOSE.length;\n if (html.slice(from, end) !== block) ms.overwrite(from, end, block);\n return;\n }\n }\n const head = /<head\\b(?:\"[^\"]*\"|'[^']*'|[^\"'>])*>/i.exec(html);\n if (head) ms.appendRight(head.index + head[0].length, block);\n}\n\n// injects <link rel=\"alternate\" hreflang> into <head>, idempotent via markers\nfunction injectAlternates(ms: MagicString, html: string, alternates: Alternate[]): void {\n const links = alternates\n .map(\n (a) =>\n `<link rel=\"alternate\" hreflang=\"${escapeAttr(a.hreflang)}\" href=\"${escapeAttr(a.href)}\">`,\n )\n .join('');\n const block = `${HREFLANG_OPEN}${links}${HREFLANG_CLOSE}`;\n const from = html.indexOf(HREFLANG_OPEN);\n if (from !== -1) {\n const to = html.indexOf(HREFLANG_CLOSE, from);\n if (to !== -1) {\n const end = to + HREFLANG_CLOSE.length;\n if (html.slice(from, end) !== block) ms.overwrite(from, end, block);\n return;\n }\n }\n const head = /<\\/head\\s*>/i.exec(html);\n if (head) ms.appendLeft(head.index, block);\n}\n\nexport interface RenderSiteOptions {\n site?: string;\n locales?: string[];\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n base?: string;\n baseUrl?: string;\n hreflang?: boolean;\n sitemap?: boolean | string;\n redirect?: boolean | RedirectConfig;\n clean?: boolean;\n}\n\nexport interface RenderSiteResult {\n files: number;\n locales: string[];\n missing: Record<string, string[]>;\n untranslatedHead: string[];\n}\n\nconst TITLE_TAG = /<title\\b([^>]*)>/i;\nconst REFRESH_META = /<meta\\b[^>]*http-equiv\\s*=\\s*[\"']?refresh/i;\n\n// a page whose <title> carries no key ships the source language to every locale, and the title is\n// most of what a search result shows: putting the locale in the url buys nothing without it\nfunction headIsBound(html: string, attr: string): boolean {\n // a page that only redirects is never a search result, so its title is nobody's to translate\n if (REFRESH_META.test(html)) return true;\n const title = TITLE_TAG.exec(html);\n return title ? title[1]!.includes(attr) : true;\n}\n\n// mirrors the built site per locale: dist/index.html → dist/<locale>/index.html\nexport async function renderSite(\n cfg: ResolvedConfig,\n options: RenderSiteOptions = {},\n): Promise<RenderSiteResult> {\n const site = join(cfg.root, options.site ?? cfg.render.site ?? 'dist');\n const locales = options.locales ?? cfg.locales;\n const attribute = options.attribute ?? cfg.render.attribute;\n const base = normalizeBase(options.base ?? cfg.render.base);\n const baseUrl = (options.baseUrl ?? cfg.render.baseUrl)?.replace(/\\/+$/, '');\n const wantHreflang = (options.hreflang ?? cfg.render.hreflang ?? true) && baseUrl !== undefined;\n const sitemap = options.sitemap ?? cfg.render.sitemap ?? false;\n const wantSitemap = sitemap !== false && baseUrl !== undefined;\n const clean = options.clean ?? cfg.render.clean ?? false;\n const wanted = options.redirect ?? cfg.render.redirect ?? false;\n const redirect = wanted === false ? undefined : wanted === true ? {} : wanted;\n const script: RedirectScript | undefined = redirect && {\n locales,\n sourceLocale: cfg.sourceLocale,\n base,\n storageKey: redirect.storageKey,\n };\n const catalogs = loadCatalogs(cfg);\n // one runtime per locale for the whole run: rebuilding it per page reflattened every catalog\n const instances = new Map(\n locales.map((locale) => [locale, localeInstance(catalogs, locale, cfg.sourceLocale)]),\n );\n\n if (clean) {\n for (const locale of locales) {\n if (locale !== cfg.sourceLocale) rmSync(join(site, locale), { recursive: true, force: true });\n }\n }\n\n const files = await glob('**/*.html', {\n cwd: site,\n absolute: true,\n ignore: locales.map((locale) => `${locale}/**`),\n });\n\n // every page the mirror will hold, so a link into one of them can keep the visitor inside\n const pages = new Set(files.map((file) => publicPath(relative(site, file).replace(/\\\\/g, '/'))));\n\n const missing: Record<string, string[]> = {};\n const untranslatedHead: string[] = [];\n const urls: Array<{ rel: string; alternates: Alternate[] }> = [];\n for (const file of files) {\n const html = readFileSync(file, 'utf8');\n const rel = relative(site, file).replace(/\\\\/g, '/');\n // one locale is not a mirror, so there is no second title for this one to disagree with\n if (locales.length > 1 && !headIsBound(html, attribute ?? 'data-verbaly')) {\n untranslatedHead.push(rel);\n }\n const alternates = wantHreflang ? pageAlternates(baseUrl!, rel, locales, cfg.sourceLocale) : [];\n if (wantHreflang) urls.push({ rel, alternates });\n // only the source tree carries it: the mirror page a visitor reaches is already the answer\n const routed = script && (redirect!.on === 'all' || rel === 'index.html');\n for (const locale of locales) {\n const result = renderHtml(html, {\n locale,\n instance: instances.get(locale)!,\n sourceLocale: cfg.sourceLocale,\n attribute,\n richTags: options.richTags,\n richLinks: options.richLinks ?? cfg.render.links,\n alternates,\n mirror: locale === cfg.sourceLocale ? undefined : { prefix: `/${locale}`, base, pages },\n redirect: routed && locale === cfg.sourceLocale ? script : undefined,\n });\n for (const key of result.missing) {\n const list = (missing[locale] ??= []);\n if (!list.includes(key)) list.push(key);\n }\n const out = locale === cfg.sourceLocale ? file : join(site, locale, rel);\n mkdirSync(dirname(out), { recursive: true });\n writeFileSync(out, result.html);\n }\n }\n\n if (wantSitemap && urls.length) {\n const name = typeof sitemap === 'string' ? sitemap : 'sitemap-i18n.xml';\n writeFileSync(join(site, name), buildSitemap(urls));\n }\n\n return { files: files.length, locales: [...locales], missing, untranslatedHead };\n}\n\n// the cli and @verbaly/astro both run the mirror, so what it warns about is written once\nexport function formatRenderWarnings(result: RenderSiteResult, sourceLocale: string): string[] {\n const lines: string[] = [];\n for (const [locale, keys] of Object.entries(result.missing)) {\n lines.push(` ${locale}: ${counted(keys.length, 'key')} not pre-filled: ${keys.join(', ')}`);\n }\n if (result.untranslatedHead.length > 0) {\n lines.push(\n ` ${counted(result.untranslatedHead.length, 'page')} of ${result.files} ship the same <title> in every locale (${result.untranslatedHead[0]}), so search results read in ${sourceLocale}`,\n ` fix: bind the head too, <title data-verbaly=\"key\"> and a meta through data-verbaly-attr`,\n );\n }\n return lines;\n}\n\n// public URL of a built page path (index.html → directory URL)\nfunction pageUrl(baseUrl: string, prefix: string, rel: string): string {\n const path = rel.replace(/(^|\\/)index\\.html$/, '$1');\n return `${baseUrl}${prefix}${path ? `/${path}` : '/'}`;\n}\n\n// reciprocal hreflang set for one page across every locale (+ x-default = source)\nfunction pageAlternates(\n baseUrl: string,\n rel: string,\n locales: string[],\n sourceLocale: string,\n): Alternate[] {\n const alternates: Alternate[] = [];\n for (const locale of locales) {\n const prefix = locale === sourceLocale ? '' : `/${locale}`;\n alternates.push({ hreflang: locale, href: pageUrl(baseUrl, prefix, rel) });\n }\n alternates.push({ hreflang: 'x-default', href: pageUrl(baseUrl, '', rel) });\n return alternates;\n}\n\nfunction buildSitemap(urls: Array<{ rel: string; alternates: Alternate[] }>): string {\n const body = urls\n .flatMap(({ alternates }) => {\n const alts = alternates\n .map(\n (a) =>\n `<xhtml:link rel=\"alternate\" hreflang=\"${a.hreflang}\" href=\"${escapeAttr(a.href)}\"/>`,\n )\n .join('');\n return alternates\n .filter((a) => a.hreflang !== 'x-default')\n .map((self) => `<url><loc>${escapeAttr(self.href)}</loc>${alts}</url>`);\n })\n .join('');\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">${body}</urlset>\\n`;\n}\n\nfunction parseAttrs(chunk: string): Map<string, string> {\n const attrs = new Map<string, string>();\n ATTR.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = ATTR.exec(chunk)) !== null) {\n attrs.set(m[1]!.toLowerCase(), m[2] ?? m[3] ?? m[4] ?? '');\n }\n return attrs;\n}\n\nfunction parseArgs(raw: string | undefined): Params | undefined {\n if (!raw) return undefined;\n try {\n return JSON.parse(decodeEntities(raw)) as Params;\n } catch {\n console.warn(`[verbaly] invalid args JSON: ${raw}`);\n return undefined;\n }\n}\n\n// comments and script/style bodies are opaque to the scanner\nfunction protectedRanges(html: string): Array<[number, number]> {\n const ranges: Array<[number, number]> = [];\n const re = /<!--[\\s\\S]*?-->|<script\\b[\\s\\S]*?<\\/script\\s*>|<style\\b[\\s\\S]*?<\\/style\\s*>/gi;\n let m: RegExpExecArray | null;\n while ((m = re.exec(html)) !== null) {\n // keep script/style open tags scannable; protect only their bodies\n const openEnd = m[0].startsWith('<!--') ? m.index : html.indexOf('>', m.index) + 1;\n ranges.push([openEnd, m.index + m[0].length]);\n }\n return ranges;\n}\n\nfunction findClose(\n html: string,\n tagName: string,\n from: number,\n inSkip: (index: number) => boolean,\n): { contentEnd: number } | null {\n const re = new RegExp(\n `<${tagName}(?=[\\\\s/>])(?:\"[^\"]*\"|'[^']*'|[^\"'>])*>|</${tagName}\\\\s*>`,\n 'gi',\n );\n re.lastIndex = from;\n let depth = 1;\n let m: RegExpExecArray | null;\n while ((m = re.exec(html)) !== null) {\n if (inSkip(m.index)) continue;\n if (m[0][1] === '/') {\n depth -= 1;\n if (depth === 0) return { contentEnd: m.index };\n } else if (!m[0].endsWith('/>')) {\n depth += 1;\n }\n }\n return null;\n}\n\nfunction setAttribute(\n ms: MagicString,\n html: string,\n chunkStart: number,\n openEnd: number,\n attrChunk: string,\n name: string,\n value: string,\n): void {\n const escaped = escapeAttr(value);\n const existing = new RegExp(`(\\\\s${name}\\\\s*=\\\\s*)(\"[^\"]*\"|'[^']*'|[^\\\\s>]+)`, 'i').exec(\n attrChunk,\n );\n if (existing) {\n const valueStart = chunkStart + existing.index + existing[1]!.length;\n const valueEnd = valueStart + existing[2]!.length;\n if (html.slice(valueStart, valueEnd) !== `\"${escaped}\"`) {\n ms.overwrite(valueStart, valueEnd, `\"${escaped}\"`);\n }\n return;\n }\n const selfClosing = html.slice(openEnd - 2, openEnd) === '/>';\n const insertAt = openEnd - (selfClosing ? 2 : 1);\n ms.appendLeft(insertAt, ` ${name}=\"${escaped}\"`);\n}\n\nfunction richToHtml(\n nodes: TagNode[],\n allowed: Set<string>,\n links?: Record<string, RichLink>,\n): string {\n let out = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n out += escapeHtml(node);\n } else if (links?.[node.name] !== undefined) {\n const { href, target, rel } = normalizeLink(links[node.name]!);\n let attrs = href !== undefined ? ` href=\"${escapeAttr(href)}\"` : '';\n if (target) attrs += ` target=\"${escapeAttr(target)}\"`;\n if (rel) attrs += ` rel=\"${escapeAttr(rel)}\"`;\n out += `<a${attrs}>${richToHtml(node.children, allowed, links)}</a>`;\n } else if (allowed.has(node.name)) {\n out += VOID.has(node.name)\n ? `<${node.name}>`\n : `<${node.name}>${richToHtml(node.children, allowed, links)}</${node.name}>`;\n } else {\n out += richToHtml(node.children, allowed, links); // unknown tag → unwrap\n }\n }\n return out;\n}\n\nfunction escapeHtml(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nfunction escapeAttr(text: string): string {\n return escapeHtml(text).replace(/\"/g, '&quot;');\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&amp;/g, '&');\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,YAAY,KAAqB,QAAwB;CACvE,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO,MAAM;AACvC;AAGA,SAAgB,YAAY,KAAqB,QAAyB;CACxE,MAAM,OAAO,SAAS,KAAK,MAAM;CACjC,MAAM,MAAM,QAAQ,IAAI;CAExB,IAAI,KACF,MAAM,IAAI,MACR,aAAa,YAAY,KAAK,MAAM,EAAE,8BAA8B,IAAI,oEAE1E;CAEF,OAAO,QAAQ,IAAI;AACrB;AAGA,SAAgB,QAAQ,MAAmB,SAAS,IAAwB;CAC1E,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,GAAG;EAC/C,MAAM,OAAO,SAAS,GAAG,OAAO,GAAG,QAAQ;EAC3C,IAAI,OAAO,UAAU,UAAU;EAC/B,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO;EAChF,MAAM,MAAM,QAAQ,OAAO,IAAI;EAC/B,IAAI,KAAK,OAAO;CAClB;AAEF;AAGA,SAAS,SAAS,KAAqB,QAA6B;CAClE,IAAI;CACJ,IAAI;EACF,UAAU,aAAa,YAAY,KAAK,MAAM,GAAG,MAAM;CACzD,QAAQ;EACN,OAAO,CAAC;CACV;CACA,MAAM,SAAS,UAAU,OAAO;CAChC,IAAI,QAAQ,OAAO;CACnB,MAAM,IAAI,MACR,aAAa,YAAY,KAAK,MAAM,EAAE,2CACxC;AACF;AAGA,SAAS,UAAU,SAA0C;CAC3D,MAAM,OAAO,QAA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