@verbaly/compiler 0.35.0 → 0.37.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/README.md +1 -1
- package/dist/cli.js +67 -5
- package/dist/cli.js.map +1 -1
- package/dist/config-D8gkaunO.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +59 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["walk","parse","parse"],"sources":["../src/catalog.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/warn.ts","../src/transform.ts","../src/plugin.ts","../src/drafts.ts","../src/status.ts","../src/translate.ts","../src/render.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\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// corrupt catalog throws: read as empty, the next extract would wipe the translations\nexport function readCatalog(cfg: ResolvedConfig, locale: string): Catalog {\n let content: string;\n try {\n content = readFileSync(catalogPath(cfg, locale), 'utf8');\n } catch {\n return {};\n }\n try {\n return JSON.parse(content.replace(/^\\uFEFF/, '')) as Catalog;\n } catch (error) {\n throw new Error(\n `[verbaly] ${catalogPath(cfg, locale)} is not valid JSON, fix or delete the file`,\n { cause: error },\n );\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\nexport function serializeCatalog(catalog: Catalog): string {\n const sorted: Catalog = {};\n for (const key of Object.keys(catalog).sort()) {\n const value = catalog[key];\n if (value !== undefined) sorted[key] = value;\n }\n return JSON.stringify(sorted, null, 2) + '\\n';\n}\n\nexport function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string {\n const serialized = serializeCatalog(catalog);\n const path = catalogPath(cfg, locale);\n // identical writes are skipped: a rewrite retriggers whatever watches the catalog\n try {\n if (readFileSync(path, 'utf8') === serialized) return serialized;\n } catch {\n mkdirSync(cfg.dir, { recursive: true });\n }\n writeFileSync(path, serialized);\n return serialized;\n}\n","import type { Analysis, StrayImport, TaggedMessage } from './analyze';\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 console.warn(\n `[verbaly] key collision \"${msg.key}\": ` +\n `${JSON.stringify(existing.message)} vs ${JSON.stringify(msg.message)}, second dropped.`,\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","const warned = new Set<string>();\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 const line = `[verbaly] ${file}: could not be parsed (${message}), its messages were not extracted`;\n if (warned.has(line)) return;\n warned.add(line);\n console.warn(line);\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","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 { 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] ${result.messages} messages · 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 { 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}\n\nexport type TranslateProvider = (request: TranslateRequest) => Promise<Record<string, string>>;\n\nexport interface TranslateOptions {\n locales?: string[];\n batchSize?: number;\n dryRun?: boolean;\n origins?: Record<string, string[]>;\n}\n\nexport interface TranslateResult {\n translated: Record<string, string[]>;\n invalid: Record<string, string[]>;\n pending: Record<string, string[]>;\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 targets = targetLocales(cfg, options.locales);\n const source = catalogs[cfg.sourceLocale] ?? {};\n const result: TranslateResult = { translated: {}, invalid: {}, pending: {} };\n\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 for (let i = 0; i < missing.length; i += batchSize) {\n const keys = missing.slice(i, i + batchSize);\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 const out = await provider({\n sourceLocale: cfg.sourceLocale,\n targetLocale: locale,\n messages,\n origins,\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 }\n }\n return result;\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","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 normalizeLink,\n parseTags,\n RICH_TAGS,\n safeAttribute,\n VOID_TAGS,\n type MessageTree,\n type Params,\n type RichLink,\n type TagNode,\n} from 'verbaly';\nimport type { Catalogs } from './catalog';\nimport { loadCatalogs } from './catalog';\nimport type { 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 pages: ReadonlySet<string>;\n}\n\nexport interface RenderHtmlOptions {\n locale: string;\n // nested trees welcome: the runtime flattens them (verbaly-web's shape)\n catalogs: Catalogs | Record<string, MessageTree>;\n sourceLocale?: string;\n attribute?: string;\n richTags?: string[];\n richLinks?: Record<string, RichLink>;\n setLang?: boolean;\n alternates?: Alternate[];\n mirror?: MirrorLinks;\n}\n\nexport interface RenderHtmlResult {\n html: string;\n missing: string[];\n}\n\nconst HREFLANG_OPEN = '<!--verbaly:hreflang-->';\nconst HREFLANG_CLOSE = '<!--/verbaly:hreflang-->';\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 // '' = untranslated: the runtime lookup falls back on its own (nested or flat)\n const v = createVerbaly({\n locale: options.locale,\n fallback: sourceLocale,\n messages: options.catalogs,\n });\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\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 cut = href.search(/[?#]/);\n const path = cut < 0 ? href : href.slice(0, cut);\n if (!mirror.pages.has(publicPath(path.replace(/^\\//, '')))) return undefined;\n return `${mirror.prefix}${href}`;\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 baseUrl?: string;\n hreflang?: boolean;\n sitemap?: boolean | string;\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 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 catalogs = loadCatalogs(cfg);\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 for (const locale of locales) {\n const result = renderHtml(html, {\n locale,\n catalogs,\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}`, pages },\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, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nfunction escapeAttr(text: string): string {\n return escapeHtml(text).replace(/\"/g, '"');\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&');\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAgB,YAAY,KAAqB,QAAwB;CACvE,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO,MAAM;AACvC;AAGA,SAAgB,YAAY,KAAqB,QAAyB;CACxE,IAAI;CACJ,IAAI;EACF,UAAU,aAAa,YAAY,KAAK,MAAM,GAAG,MAAM;CACzD,QAAQ;EACN,OAAO,CAAC;CACV;CACA,IAAI;EACF,OAAO,KAAK,MAAM,QAAQ,QAAQ,WAAW,EAAE,CAAC;CAClD,SAAS,OAAO;EACd,MAAM,IAAI,MACR,aAAa,YAAY,KAAK,MAAM,EAAE,6CACtC,EAAE,OAAO,MAAM,CACjB;CACF;AACF;AAEA,SAAgB,aAAa,KAA+B;CAC1D,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,UAAU,IAAI,SAAS,SAAS,UAAU,YAAY,KAAK,MAAM;CAC5E,OAAO;AACT;AAEA,SAAgB,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,GAAG,CAAC,CACtB,QAAQ,SAAS,GAAG,CAAC,CACrB,QAAQ,SAAS,GAAG,CAAC,CACrB,QAAQ,UAAU,GAAG;AAC1B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["walk","parse","parse"],"sources":["../src/catalog.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/warn.ts","../src/transform.ts","../src/plugin.ts","../src/drafts.ts","../src/status.ts","../src/translate.ts","../src/render.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join } from 'node:path';\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// corrupt catalog throws: read as empty, the next extract would wipe the translations\nexport function readCatalog(cfg: ResolvedConfig, locale: string): Catalog {\n let content: string;\n try {\n content = readFileSync(catalogPath(cfg, locale), 'utf8');\n } catch {\n return {};\n }\n try {\n return JSON.parse(content.replace(/^\\uFEFF/, '')) as Catalog;\n } catch (error) {\n throw new Error(\n `[verbaly] ${catalogPath(cfg, locale)} is not valid JSON, fix or delete the file`,\n { cause: error },\n );\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\nexport function serializeCatalog(catalog: Catalog): string {\n const sorted: Catalog = {};\n for (const key of Object.keys(catalog).sort()) {\n const value = catalog[key];\n if (value !== undefined) sorted[key] = value;\n }\n return JSON.stringify(sorted, null, 2) + '\\n';\n}\n\nexport function writeCatalog(cfg: ResolvedConfig, locale: string, catalog: Catalog): string {\n const serialized = serializeCatalog(catalog);\n const path = catalogPath(cfg, locale);\n // identical writes are skipped: a rewrite retriggers whatever watches the catalog\n try {\n if (readFileSync(path, 'utf8') === serialized) return serialized;\n } catch {\n mkdirSync(cfg.dir, { recursive: true });\n }\n writeFileSync(path, serialized);\n return serialized;\n}\n","import type { Analysis, StrayImport, TaggedMessage } from './analyze';\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 console.warn(\n `[verbaly] key collision \"${msg.key}\": ` +\n `${JSON.stringify(existing.message)} vs ${JSON.stringify(msg.message)}, second dropped.`,\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","const warned = new Set<string>();\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 const line = `[verbaly] ${file}: could not be parsed (${message}), its messages were not extracted`;\n if (warned.has(line)) return;\n warned.add(line);\n console.warn(line);\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","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 { 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] ${result.messages} messages · 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 { 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}\n\nexport type TranslateProvider = (request: TranslateRequest) => Promise<Record<string, string>>;\n\nexport interface TranslateOptions {\n locales?: string[];\n batchSize?: number;\n dryRun?: boolean;\n origins?: Record<string, string[]>;\n}\n\nexport interface TranslateResult {\n translated: Record<string, string[]>;\n invalid: Record<string, string[]>;\n pending: Record<string, string[]>;\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 targets = targetLocales(cfg, options.locales);\n const source = catalogs[cfg.sourceLocale] ?? {};\n const result: TranslateResult = { translated: {}, invalid: {}, pending: {} };\n\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 for (let i = 0; i < missing.length; i += batchSize) {\n const keys = missing.slice(i, i + batchSize);\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 const out = await provider({\n sourceLocale: cfg.sourceLocale,\n targetLocale: locale,\n messages,\n origins,\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 }\n }\n return result;\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","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} 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\nexport interface RenderHtmlOptions {\n locale: string;\n // nested trees welcome: the runtime flattens them (verbaly-web's shape)\n catalogs: Catalogs | Record<string, MessageTree>;\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\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 // '' = untranslated: the runtime lookup falls back on its own (nested or flat)\n const v = createVerbaly({\n locale: options.locale,\n fallback: sourceLocale,\n messages: options.catalogs,\n });\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\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 catalogs,\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, '&').replace(/</g, '<').replace(/>/g, '>');\n}\n\nfunction escapeAttr(text: string): string {\n return escapeHtml(text).replace(/\"/g, '"');\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/"/g, '\"')\n .replace(/'/g, \"'\")\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/&/g, '&');\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAgB,YAAY,KAAqB,QAAwB;CACvE,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO,MAAM;AACvC;AAGA,SAAgB,YAAY,KAAqB,QAAyB;CACxE,IAAI;CACJ,IAAI;EACF,UAAU,aAAa,YAAY,KAAK,MAAM,GAAG,MAAM;CACzD,QAAQ;EACN,OAAO,CAAC;CACV;CACA,IAAI;EACF,OAAO,KAAK,MAAM,QAAQ,QAAQ,WAAW,EAAE,CAAC;CAClD,SAAS,OAAO;EACd,MAAM,IAAI,MACR,aAAa,YAAY,KAAK,MAAM,EAAE,6CACtC,EAAE,OAAO,MAAM,CACjB;CACF;AACF;AAEA,SAAgB,aAAa,KAA+B;CAC1D,MAAM,WAAqB,CAAC;CAC5B,KAAK,MAAM,UAAU,IAAI,SAAS,SAAS,UAAU,YAAY,KAAK,MAAM;CAC5E,OAAO;AACT;AAEA,SAAgB,iBAAiB,SAA0B;CACzD,MAAM,SAAkB,CAAC;CACzB,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,GAAG;EAC7C,MAAM,QAAQ,QAAQ;EACtB,IAAI,UAAU,KAAA,GAAW,OAAO,OAAO;CACzC;CACA,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI;AAC3C;AAEA,SAAgB,aAAa,KAAqB,QAAgB,SAA0B;CAC1F,MAAM,aAAa,iBAAiB,OAAO;CAC3C,MAAM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