@verbaly/compiler 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["walk","parse","parse","matchBrace"],"sources":["../src/key.ts","../src/analyze.ts","../src/sfc.ts","../src/catalog.ts","../src/validate.ts","../src/check.ts","../src/params.ts","../src/codegen.ts","../src/pseudo.ts","../src/config.ts","../src/transform.ts","../src/plugin.ts","../src/registry.ts","../src/extract.ts","../src/init.ts","../src/doctor.ts","../src/drafts.ts","../src/inline.ts","../src/mobile.ts","../src/po.ts","../src/translate.ts","../src/exchange.ts","../src/providers/claude.ts","../src/render.ts","../src/status.ts","../src/watch.ts","../src/wrap.ts"],"sourcesContent":["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\nexport interface Analysis {\n tagged: TaggedMessage[];\n usedKeys: UsedKey[];\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'];\n\nexport function analyze(code: string, file: string, options: AnalyzeOptions = {}): Analysis {\n const names = new Set(options.tNames ?? DEFAULT_T_NAMES);\n const jsx = /\\.[jt]sx$/.test(file);\n const ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: jsx ? ['typescript', 'jsx'] : ['typescript'],\n });\n\n const tagged: TaggedMessage[] = [];\n const usedKeys: UsedKey[] = [];\n\n walk(ast.program as unknown as AstNode, (node) => {\n 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 };\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 { analyze, type Analysis, type TaggedParam, type UsedKey } 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 return SFC_FILE_RE.test(file) ? analyzeSfc(code, file) : analyze(code, file);\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\n const frontmatter = file.endsWith('.astro') ? FRONTMATTER_RE.exec(code) : null;\n if (frontmatter?.[2]) {\n merge(analyzeSegment(frontmatter[2], file, options), frontmatter[1]!.length, false);\n }\n\n for (const match of code.matchAll(SCRIPT_RE)) {\n const content = match[2]!;\n if (!content) continue;\n merge(analyzeSegment(content, file, options), match.index + match[1]!.length, false);\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), start, true);\n consumedTo = end;\n }\n\n return { tagged, usedKeys };\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 }\n}\n\nfunction analyzeSegment(\n code: string,\n file: string,\n options?: { tNames: string[] },\n): Analysis | undefined {\n try {\n return analyze(code, file, options);\n } catch {\n return undefined; // malformed segment: skip it, never fail the whole file\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 { 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// missing file = empty catalog; a corrupt one must fail loudly (read as empty,\n// the next extract would rewrite it and lose every translation)\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 { 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\nfunction tagTokens(message: string): string[] {\n const out: string[] = [];\n for (const match of message.matchAll(TAG)) out.push(`${match[1]}${match[2]}${match[3]}`);\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// 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 const lostTags = tagReport(surplus(tagTokens(source), tagTokens(translated)));\n const newTags = tagReport(surplus(tagTokens(translated), tagTokens(source)));\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 is an empty render, whatever the block selects on.\n // a plural block that lost it is validateMessage's report, so it is not repeated here\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 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 { readFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { 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 check(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n registry: MessageRegistry,\n): CheckResult {\n const source = catalogs[cfg.sourceLocale] ?? {};\n const extracted = registry.messages();\n\n const unknown: UnknownEntry[] = [];\n for (const [key, files] of registry.usedKeys()) {\n const known =\n extracted.has(key) || cfg.locales.some((locale) => catalogs[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 (!catalogs[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 // flatten first, so a hand-written nested catalog is validated leaf by leaf like a\n // generated flat one (the runtime flattens too, so both shapes reach t() the same)\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 const sourceFlat = flatten(source as MessageTree);\n for (const key of needed) {\n const text = sourceFlat[key] ?? extracted.get(key)?.message;\n if (text) sourceFlat[key] = text;\n }\n for (const [key, text] of Object.entries(sourceFlat)) {\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(\n flatten((catalogs[locale] ?? {}) as MessageTree),\n )) {\n if (!translated) continue; // '' is untranslated, already reported as missing\n add(locale, key, validateMessage(translated, locale));\n const text = sourceFlat[key];\n if (text) add(locale, key, validatePair(text, translated));\n }\n }\n\n const ok =\n missing.length === 0 &&\n unknown.length === 0 &&\n !broken.some((entry) => entry.severity === 'error');\n return { ok, 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// warnings never fail the gate, so they print on their own\nexport function formatCheckWarnings(result: CheckResult): string {\n return result.broken\n .filter((entry) => entry.severity === 'warning')\n .map((entry) => ` [${entry.locale}] ${entry.key}: ${entry.issue}`)\n .join('\\n');\n}\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? text.slice(0, max - 1) + '…' : text;\n}\n\n// GitHub workflow commands: every failure becomes a clickable ::error annotation on the PR\nexport function githubCheckAnnotations(\n result: CheckResult,\n registry: MessageRegistry,\n root: string,\n): string[] {\n const messages = registry.messages();\n const contents = new Map<string, string | undefined>();\n const readSource = (file: string): string | undefined => {\n if (!contents.has(file)) {\n try {\n contents.set(file, readFileSync(file, 'utf8'));\n } catch {\n contents.set(file, undefined);\n }\n }\n return contents.get(file);\n };\n\n const lines: string[] = [];\n\n // one annotation per key, locales grouped: N locales must not bury the PR in N copies\n const byKey = new Map<string, MissingEntry & { locales: string[] }>();\n for (const entry of result.missing) {\n const grouped = byKey.get(entry.key);\n if (grouped) grouped.locales.push(entry.locale);\n else byKey.set(entry.key, { ...entry, locales: [entry.locale] });\n }\n\n for (const entry of byKey.values()) {\n const origin = messages.get(entry.key);\n const hint = entry.source ? `: \"${truncate(entry.source, 60)}\"` : '';\n const text = escapeData(`missing [${entry.locales.join(', ')}] ${entry.key}${hint}`);\n if (origin) {\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::error file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n } else {\n lines.push(`::error::${text}`);\n }\n }\n\n for (const entry of result.unknown) {\n const text = escapeData(`unknown key \"${entry.key}\" (not in any catalog)`);\n const file = entry.files[0];\n lines.push(\n file\n ? `::error file=${escapeProperty(relative(root, file).replaceAll('\\\\', '/'))}::${text}`\n : `::error::${text}`,\n );\n }\n\n // a broken translation points at the source line that wrote the message\n for (const entry of result.broken) {\n const origin = messages.get(entry.key);\n const text = escapeData(`[${entry.locale}] ${entry.key}: ${entry.issue}`);\n const command = entry.severity === 'error' ? 'error' : 'warning';\n if (!origin) {\n lines.push(`::${command}::${text}`);\n continue;\n }\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::${command} file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n }\n return lines;\n}\n\nfunction lineAt(content: string, offset: number): number {\n let line = 1;\n const end = Math.min(offset, content.length);\n for (let i = 0; i < end; i++) {\n if (content[i] === '\\n') line += 1;\n }\n return line;\n}\n\nfunction escapeData(text: string): string {\n return text.replaceAll('%', '%25').replaceAll('\\r', '%0D').replaceAll('\\n', '%0A');\n}\n\nfunction escapeProperty(text: string): string {\n return escapeData(text).replaceAll(':', '%3A').replaceAll(',', '%2C');\n}\n","import { 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// skip unchanged writes: a rewritten verbaly.d.ts churns the consumer's TS server.\n// file defaults to the project root: the one spot TS includes with zero tsconfig;\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 type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\n\nexport const PSEUDO_LOCALE = 'en-XA';\n\nconst ACCENTS: Record<string, string> = {\n a: 'á',\n b: 'ƀ',\n c: 'ç',\n d: 'đ',\n e: 'é',\n f: 'ƒ',\n g: 'ğ',\n h: 'ĥ',\n i: 'í',\n j: 'ĵ',\n k: 'ķ',\n l: 'ĺ',\n m: 'ɱ',\n n: 'ñ',\n o: 'ó',\n p: 'þ',\n q: 'ǫ',\n r: 'ŕ',\n s: 'š',\n t: 'ţ',\n u: 'ú',\n v: 'ṽ',\n w: 'ŵ',\n x: 'ẋ',\n y: 'ý',\n z: 'ž',\n A: 'Á',\n B: 'Ɓ',\n C: 'Ç',\n D: 'Đ',\n E: 'É',\n F: 'Ƒ',\n G: 'Ğ',\n H: 'Ĥ',\n I: 'Í',\n J: 'Ĵ',\n K: 'Ķ',\n L: 'Ĺ',\n M: 'Ḿ',\n N: 'Ñ',\n O: 'Ó',\n P: 'Þ',\n Q: 'Ǫ',\n R: 'Ŕ',\n S: 'Š',\n T: 'Ţ',\n U: 'Ú',\n V: 'Ṽ',\n W: 'Ŵ',\n X: 'Ẍ',\n Y: 'Ý',\n Z: 'Ž',\n};\n\nconst TAG_AT = /<\\/?[a-zA-Z][\\w-]*\\/?>/y;\n\n// params, variant blocks, tags and escapes survive verbatim\nexport function pseudoLocalize(message: string): string {\n let out = '';\n let letters = 0;\n let i = 0;\n while (i < message.length) {\n const two = message.slice(i, i + 2);\n if (two === '{{' || two === '}}' || two === '||' || two === '##') {\n out += two;\n i += 2;\n continue;\n }\n const ch = message[i]!;\n if (ch === '{') {\n const end = matchBrace(message, i);\n out += message.slice(i, end);\n i = end;\n continue;\n }\n if (ch === '<') {\n TAG_AT.lastIndex = i;\n const m = TAG_AT.exec(message);\n if (m) {\n out += m[0];\n i += m[0].length;\n continue;\n }\n }\n const mapped = ACCENTS[ch];\n if (mapped) {\n out += mapped;\n letters += 1;\n } else {\n out += ch;\n }\n i += 1;\n }\n const pad = '~'.repeat(Math.ceil(letters / 3));\n return `⟦${out}${pad ? ' ' + pad : ''}⟧`;\n}\n\nfunction matchBrace(message: string, start: number): number {\n let depth = 0;\n for (let i = start; i < message.length; i++) {\n const two = message.slice(i, i + 2);\n if (two === '{{' || two === '}}') {\n i += 1;\n continue;\n }\n const ch = message[i];\n if (ch === '{') depth += 1;\n else if (ch === '}') {\n depth -= 1;\n if (depth === 0) return i + 1;\n }\n }\n return message.length; // unbalanced → verbatim\n}\n\n// regenerates the whole pseudo catalog from the source catalog\nexport function pseudoCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n locale: string = PSEUDO_LOCALE,\n): string[] {\n const source = catalogs[cfg.sourceLocale] ?? {};\n const target: Catalog = {};\n for (const [key, msg] of Object.entries(source)) {\n target[key] = msg ? pseudoLocalize(msg) : '';\n }\n catalogs[locale] = target;\n return Object.keys(target).filter((key) => target[key]);\n}\n","import { existsSync, readFileSync, readdirSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { RichLink } from 'verbaly';\nimport { PSEUDO_LOCALE } from './pseudo';\nimport type { TranslateProvider } from './translate';\n\nexport interface TranslateConfig {\n provider?: 'claude' | TranslateProvider;\n model?: string;\n batchSize?: number;\n}\n\nexport interface RenderConfig {\n links?: Record<string, RichLink>;\n site?: string;\n attribute?: string;\n baseUrl?: string;\n hreflang?: boolean;\n sitemap?: boolean | string;\n clean?: boolean;\n}\n\nexport interface VerbalyConfig {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n include?: string[];\n exclude?: string[];\n dts?: string | false;\n translate?: TranslateConfig;\n render?: RenderConfig;\n}\n\nexport interface ResolvedConfig {\n root: string;\n dir: string;\n sourceLocale: string;\n locales: string[];\n include: string[];\n exclude: string[];\n dts: string | false | undefined;\n translate: TranslateConfig;\n render: RenderConfig;\n}\n\nexport function resolveConfig(config: VerbalyConfig = {}): ResolvedConfig {\n const root = resolve(config.root ?? process.cwd());\n const dir = resolve(root, config.dir ?? 'locales');\n const sourceLocale = config.sourceLocale ?? 'en';\n\n const locales = new Set<string>([sourceLocale, ...(config.locales ?? [])]);\n if (existsSync(dir)) {\n for (const file of readdirSync(dir)) {\n if (file.endsWith('.json') && !file.startsWith('.') && file !== `${PSEUDO_LOCALE}.json`) {\n locales.add(file.slice(0, -5));\n }\n }\n }\n\n return {\n root,\n dir,\n sourceLocale,\n locales: [...locales],\n include: config.include ?? ['{src,app}/**/*.{js,jsx,ts,tsx,mjs,mts,svelte,vue,astro}'],\n exclude: config.exclude ?? ['**/node_modules/**', '**/dist/**'],\n dts: typeof config.dts === 'string' ? resolve(root, config.dts) : config.dts,\n translate: config.translate ?? {},\n render: config.render ?? {},\n };\n}\n\nconst CONFIG_FILES = [\n 'verbaly.config.js',\n 'verbaly.config.mjs',\n 'verbaly.config.ts',\n 'verbaly.config.mts',\n 'verbaly.config.json',\n];\n\nexport function findConfigFile(root: string): string | undefined {\n return CONFIG_FILES.find((name) => existsSync(join(root, name)));\n}\n\nexport async function loadConfigFile(root: string): Promise<VerbalyConfig> {\n for (const name of ['verbaly.config.js', 'verbaly.config.mjs']) {\n const path = join(root, name);\n if (existsSync(path)) {\n const mod = (await import(pathToFileURL(path).href)) as { default?: VerbalyConfig };\n return mod.default ?? {};\n }\n }\n for (const name of ['verbaly.config.ts', 'verbaly.config.mts']) {\n const path = join(root, name);\n if (existsSync(path)) return loadTsConfig(path);\n }\n const jsonPath = join(root, 'verbaly.config.json');\n if (existsSync(jsonPath)) {\n return JSON.parse(readFileSync(jsonPath, 'utf8')) as VerbalyConfig;\n }\n return {};\n}\n\nasync function loadTsConfig(path: string): Promise<VerbalyConfig> {\n try {\n const { bundleRequire } = await import('bundle-require');\n const { mod } = await bundleRequire<{ default?: VerbalyConfig }>({ filepath: path });\n return mod.default ?? {};\n } catch (error) {\n if (isModuleNotFound(error, 'esbuild')) {\n throw new Error(`[verbaly] ${path} needs esbuild: install it with pnpm add -D esbuild`, {\n cause: error,\n });\n }\n throw error;\n }\n}\n\nexport function isModuleNotFound(error: unknown, name: string): boolean {\n return (\n error instanceof Error &&\n (error as { code?: string }).code === 'ERR_MODULE_NOT_FOUND' &&\n error.message.includes(name)\n );\n}\n\n// non-source locales a command may write to (optional CLI override, always config-bounded)\nexport function targetLocales(cfg: ResolvedConfig, override?: string[]): string[] {\n return (override ?? cfg.locales).filter(\n (locale) => locale !== cfg.sourceLocale && cfg.locales.includes(locale),\n );\n}\n\n// file config + inline overrides\nexport async function loadConfig(\n root: string,\n overrides: VerbalyConfig = {},\n): Promise<ResolvedConfig> {\n const fileConfig = await loadConfigFile(root);\n return resolveConfig({ ...fileConfig, ...definedOnly(overrides), root });\n}\n\nfunction definedOnly(config: VerbalyConfig): VerbalyConfig {\n return Object.fromEntries(\n Object.entries(config).filter(([, value]) => value !== undefined),\n ) as VerbalyConfig;\n}\n","import MagicString from 'magic-string';\nimport type { Analysis } from './analyze';\nimport { analyzeFile } from './sfc';\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 { tagged } = analysis ?? analyzeFile(code, file);\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 type { Analysis } from './analyze';\nimport { loadCatalogs, type Catalogs } from './catalog';\nimport { check, formatCheckResult } 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';\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): { analysis: Analysis; result: TransformResult | null } {\n const analysis = analyzeFile(code, id);\n registry.update(id, analysis);\n return { analysis, 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 if (failOnMissing === false) return;\n const result = check(cfg, loadCatalogs(cfg), registry);\n if (!result.ok) {\n throw new Error(\n `[verbaly] build blocked\\n${formatCheckResult(result)}\\n` +\n `Run \\`npx verbaly extract\\` and fill the missing translations.`,\n );\n }\n}\n","import type { Analysis, 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 // 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 { 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 { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { findConfigFile } from './config';\n\nexport interface InitOptions {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n}\n\nexport interface InitResult {\n created: string[];\n skipped: string[];\n bundler: 'astro' | 'vite' | 'webpack' | 'rollup' | 'rspack' | 'esbuild' | undefined;\n configFile: string;\n next: string[];\n}\n\nconst BUNDLERS = ['astro', 'vite', 'webpack', 'rollup', 'rspack', 'esbuild'] as const;\n\nexport function detectBundler(root: string): InitResult['bundler'] {\n const path = join(root, 'package.json');\n if (!existsSync(path)) return undefined;\n try {\n const pkg = JSON.parse(readFileSync(path, 'utf8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n return BUNDLERS.find((name) => deps[name]);\n } catch {\n return undefined;\n }\n}\n\nfunction configSource(options: InitOptions, typescript: boolean): string {\n const fields = [` sourceLocale: '${options.sourceLocale ?? 'en'}',`];\n if (options.locales?.length) {\n fields.push(` locales: [${options.locales.map((l) => `'${l}'`).join(', ')}],`);\n }\n if (options.dir) fields.push(` dir: '${options.dir}',`);\n const body = `export default {\\n${fields.join('\\n')}\\n}`;\n if (typescript) {\n return `import type { VerbalyConfig } from '@verbaly/compiler';\\n\\n${body} satisfies VerbalyConfig;\\n`;\n }\n return `/** @type {import('@verbaly/compiler').VerbalyConfig} */\\n${body};\\n`;\n}\n\nexport function init(options: InitOptions = {}): InitResult {\n const root = options.root ?? process.cwd();\n const created: string[] = [];\n const skipped: string[] = [];\n\n const existing = findConfigFile(root);\n const typescript = existsSync(join(root, 'tsconfig.json'));\n const configFile = existing ?? (typescript ? 'verbaly.config.ts' : 'verbaly.config.mjs');\n if (existing) {\n skipped.push(existing);\n } else {\n writeFileSync(join(root, configFile), configSource(options, typescript));\n created.push(configFile);\n }\n\n const dir = join(root, options.dir ?? 'locales');\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n for (const locale of new Set([options.sourceLocale ?? 'en', ...(options.locales ?? [])])) {\n const file = join(dir, `${locale}.json`);\n const label = relative(root, file).replaceAll('\\\\', '/');\n if (existsSync(file)) {\n skipped.push(label);\n } else {\n writeFileSync(file, '{}\\n');\n created.push(label);\n }\n }\n\n const bundler = detectBundler(root);\n const next: string[] = [];\n if (bundler === 'astro') {\n next.push(\n 'install the integration: pnpm add -D @verbaly/astro',\n 'add verbaly() to the integrations in astro.config',\n );\n } else if (bundler === 'vite') {\n next.push(\n 'install the plugin: pnpm add -D @verbaly/vite',\n 'add verbaly() to the plugins in vite.config',\n );\n } else if (bundler) {\n next.push(\n 'install the plugin: pnpm add -D @verbaly/unplugin',\n `add the verbaly ${bundler} plugin to your build config`,\n );\n } else {\n next.push('run \"verbaly extract\" after writing your first t`…` message');\n }\n\n return { created, skipped, bundler, configFile, next };\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport type { Catalogs } from './catalog';\nimport { check } from './check';\nimport { generateDts } from './codegen';\nimport { findConfigFile, type ResolvedConfig } from './config';\nimport { extractProject } from './extract';\nimport { detectBundler } from './init';\n\nexport interface DoctorEntry {\n level: 'ok' | 'warn' | 'error';\n check: string;\n message: string;\n fix?: string;\n}\n\nexport interface DoctorResult {\n ok: boolean; // no error-level entries (warns allowed)\n entries: DoctorEntry[];\n}\n\nconst PREVIEW = 5; // keys shown before \"…\"\n\nexport async function doctor(cfg: ResolvedConfig): Promise<DoctorResult> {\n const entries: DoctorEntry[] = [];\n const ok = (name: string, message: string) => entries.push({ level: 'ok', check: name, message });\n const warn = (name: string, message: string, fix: string) =>\n entries.push({ level: 'warn', check: name, message, fix });\n const error = (name: string, message: string, fix: string) =>\n entries.push({ level: 'error', check: name, message, fix });\n const rel = (path: string) => relative(cfg.root, path).replaceAll('\\\\', '/');\n\n const configFile = findConfigFile(cfg.root);\n if (configFile) ok('config', `${configFile} found`);\n else warn('config', 'no config file, running on defaults', 'run `npx verbaly init`');\n\n const catalogs: Catalogs = {};\n let catalogsHealthy = true;\n if (!existsSync(cfg.dir)) {\n catalogsHealthy = false;\n error(\n 'catalogs',\n `catalogs directory ${rel(cfg.dir)}/ does not exist`,\n 'run `npx verbaly init` to scaffold it',\n );\n } else {\n for (const locale of cfg.locales) {\n const file = join(cfg.dir, `${locale}.json`);\n if (!existsSync(file)) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is missing`,\n 'run `npx verbaly extract` to create it',\n );\n continue;\n }\n try {\n const parsed = JSON.parse(readFileSync(file, 'utf8')) as Record<string, unknown>;\n const bad = Object.entries(parsed).find(([, value]) => typeof value !== 'string');\n if (bad) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} has a non-string value at \"${bad[0]}\"`,\n 'catalogs are flat key → string JSON; fix the value',\n );\n } else {\n catalogs[locale] = parsed as Record<string, string>;\n }\n } catch {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is not valid JSON`,\n 'repair the file (or delete it and run `npx verbaly extract`)',\n );\n }\n }\n if (catalogsHealthy) {\n ok(\n 'catalogs',\n `${cfg.locales.length} locales (${cfg.locales.join(', ')}) in ${rel(cfg.dir)}/`,\n );\n }\n }\n\n const source = catalogs[cfg.sourceLocale];\n if (source && Object.keys(source).length === 0) {\n warn(\n 'source',\n `source catalog ${cfg.sourceLocale}.json is empty`,\n 'write your first t`…` message and run `npx verbaly extract`',\n );\n }\n\n const deps = readDeps(cfg.root);\n const bundler = detectBundler(cfg.root);\n const wired = deps['@verbaly/vite'] || deps['@verbaly/unplugin'];\n if (!bundler) {\n ok('plugin', 'no bundler detected, the CLI flow (extract/check) applies');\n } else if (wired) {\n ok(\n 'plugin',\n `${deps['@verbaly/vite'] ? '@verbaly/vite' : '@verbaly/unplugin'} installed for ${bundler}`,\n );\n } else if (bundler === 'vite') {\n warn(\n 'plugin',\n 'vite detected but @verbaly/vite is not installed',\n 'pnpm add -D @verbaly/vite and add verbaly() to the plugins in vite.config',\n );\n } else {\n warn(\n 'plugin',\n `${bundler} detected but @verbaly/unplugin is not installed`,\n `pnpm add -D @verbaly/unplugin and add the verbaly ${bundler} plugin to your build config`,\n );\n }\n\n if (source && cfg.dts !== false) {\n const dtsPath = cfg.dts ?? join(cfg.root, 'verbaly.d.ts');\n if (!existsSync(dtsPath)) {\n warn('types', 'verbaly.d.ts has not been generated', 'run `npx verbaly extract`');\n } else if (readFileSync(dtsPath, 'utf8') !== generateDts(source)) {\n warn('types', 'verbaly.d.ts is stale', 'run `npx verbaly extract`');\n } else {\n ok('types', 'verbaly.d.ts is up to date');\n }\n }\n\n const registry = await extractProject(cfg);\n if (source) {\n const extracted = registry.messages();\n const used = registry.usedKeys();\n const orphans = Object.keys(source).filter((key) => !extracted.has(key) && !used.has(key));\n if (orphans.length > 0) {\n warn(\n 'orphans',\n `${orphans.length} catalog ${orphans.length === 1 ? 'key is' : 'keys are'} no longer referenced (${preview(orphans)})`,\n 'run `npx verbaly extract --prune` to drop them',\n );\n } else {\n ok('orphans', 'no orphan keys');\n }\n }\n\n if (catalogsHealthy) {\n const result = check(cfg, catalogs, registry);\n if (result.unknown.length > 0) {\n error(\n 'keys',\n `${result.unknown.length} unknown ${result.unknown.length === 1 ? 'key' : 'keys'} used in code (${preview(result.unknown.map((u) => u.key))})`,\n 'fix the key or add it to the catalogs (`npx verbaly check` for details)',\n );\n }\n if (result.missing.length > 0) {\n const locales = [...new Set(result.missing.map((m) => m.locale))];\n warn(\n 'translations',\n `${result.missing.length} missing ${result.missing.length === 1 ? 'translation' : 'translations'} (${locales.join(', ')})`,\n 'run `npx verbaly translate` or fill the catalogs (`npx verbaly check` for details)',\n );\n }\n if (result.ok) ok('translations', 'all translations complete');\n }\n\n return { ok: entries.every((entry) => entry.level !== 'error'), entries };\n}\n\nfunction preview(keys: string[]): string {\n const head = keys.slice(0, PREVIEW).join(', ');\n return keys.length > PREVIEW ? `${head}, …` : head;\n}\n\nfunction readDeps(root: string): Record<string, string> {\n try {\n const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return { ...pkg.dependencies, ...pkg.devDependencies };\n } catch {\n return {};\n }\n}\n","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 only counts while its translation is still present: a pruned or re-emptied\n// key is no longer a \"reviewable\" draft, it is simply missing again\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","// XLIFF 2.0 inline codes: simple {params} export as <ph>, paired rich tags as <pc>,\n// with semantic ids (the param/tag name) so TMS editors protect them as chips instead\n// of exposing raw syntax. disp carries the exact source slice: decoding reconstructs\n// the message verbatim, so the round-trip is lossless. Variant params ({v | one: …})\n// hold translatable text and stay raw on purpose.\n\ntype Part =\n | { kind: 'text'; text: string }\n | { kind: 'ph'; name: string; src: string }\n | { kind: 'pc'; name: string; openSrc: string; closeSrc: string; children: Part[] };\n\nconst OPEN_TAG = /^<([a-zA-Z][a-zA-Z0-9-]*)\\s*(\\/?)>/;\n\nexport function messageToInline(text: string): string {\n const parsed = parseParts(text, 0);\n return renderParts(parsed.parts, new Map());\n}\n\nexport function inlineToMessage(xml: string): string {\n let out = '';\n let text = '';\n let i = 0;\n const flush = () => {\n out += unescapeXml(text);\n text = '';\n };\n while (i < xml.length) {\n if (xml[i] === '<') {\n const slice = xml.slice(i);\n const ph = /^<ph\\b([^>]*?)\\/\\s*>/.exec(slice) ?? /^<ph\\b([^>]*)>\\s*<\\/ph\\s*>/.exec(slice);\n if (ph) {\n flush();\n out += attr(ph[1]!, 'disp') ?? `{${attr(ph[1]!, 'id') ?? 'ph'}}`;\n i += ph[0].length;\n continue;\n }\n const pc = /^<pc\\b([^>]*)>/.exec(slice);\n if (pc) {\n const close = findPcClose(xml, i + pc[0].length);\n if (close) {\n flush();\n const id = attr(pc[1]!, 'id') ?? 'pc';\n out += attr(pc[1]!, 'dispStart') ?? `<${id}>`;\n out += inlineToMessage(xml.slice(i + pc[0].length, close.innerEnd));\n out += attr(pc[1]!, 'dispEnd') ?? `</${id}>`;\n i = close.end;\n continue;\n }\n }\n }\n text += xml[i];\n i += 1;\n }\n flush();\n return out;\n}\n\nexport function escapeXml(text: string): string {\n return text\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nexport function unescapeXml(text: string): string {\n return text.replace(/&(lt|gt|amp|quot|apos|#x?[0-9a-fA-F]+);/g, (_, entity: string) => {\n if (entity === 'lt') return '<';\n if (entity === 'gt') return '>';\n if (entity === 'amp') return '&';\n if (entity === 'quot') return '\"';\n if (entity === 'apos') return \"'\";\n const code = entity.startsWith('#x')\n ? parseInt(entity.slice(2), 16)\n : parseInt(entity.slice(1), 10);\n return String.fromCodePoint(code);\n });\n}\n\ninterface ParsedParts {\n parts: Part[];\n end: number;\n closed: boolean;\n}\n\nfunction parseParts(text: string, pos: number, closeTag?: string): ParsedParts {\n const parts: Part[] = [];\n let plain = '';\n const flush = () => {\n if (plain) parts.push({ kind: 'text', text: plain });\n plain = '';\n };\n let i = pos;\n while (i < text.length) {\n const pair = text[i]! + (text[i + 1] ?? '');\n if (pair === '{{' || pair === '}}') {\n plain += pair;\n i += 2;\n continue;\n }\n if (text[i] === '{') {\n const end = matchBrace(text, i);\n if (end === -1) {\n plain += '{';\n i += 1;\n continue;\n }\n const src = text.slice(i, end + 1);\n if (hasTopLevelPipe(src)) {\n plain += src;\n } else {\n flush();\n parts.push({ kind: 'ph', name: paramName(src), src });\n }\n i = end + 1;\n continue;\n }\n if (text[i] === '<') {\n if (closeTag && text.startsWith(`</${closeTag}>`, i)) {\n flush();\n return { parts, end: i + closeTag.length + 3, closed: true };\n }\n const open = OPEN_TAG.exec(text.slice(i));\n if (open) {\n const [openSrc, name, selfClose] = open as unknown as [string, string, string];\n if (selfClose) {\n flush();\n parts.push({ kind: 'ph', name: idSafe(name), src: openSrc });\n i += openSrc.length;\n continue;\n }\n const inner = parseParts(text, i + openSrc.length, name);\n if (inner.closed) {\n flush();\n parts.push({\n kind: 'pc',\n name: idSafe(name),\n openSrc,\n closeSrc: `</${name}>`,\n children: inner.parts,\n });\n i = inner.end;\n continue;\n }\n }\n // no closing tag ahead: keep the '<' as plain text\n plain += '<';\n i += 1;\n continue;\n }\n plain += text[i];\n i += 1;\n }\n flush();\n return { parts, end: i, closed: false };\n}\n\nfunction matchBrace(text: string, start: number): number {\n let depth = 0;\n for (let i = start; i < text.length; i++) {\n const pair = text[i]! + (text[i + 1] ?? '');\n if (pair === '{{' || pair === '}}') {\n i += 1;\n continue;\n }\n if (text[i] === '{') depth += 1;\n else if (text[i] === '}') {\n depth -= 1;\n if (depth === 0) return i;\n }\n }\n return -1;\n}\n\n// a top-level pipe means variants (plural/select): their bodies are translatable\nfunction hasTopLevelPipe(src: string): boolean {\n let depth = 0;\n for (let i = 0; i < src.length; i++) {\n const pair = src[i]! + (src[i + 1] ?? '');\n if (pair === '{{' || pair === '}}' || pair === '||') {\n i += 1;\n continue;\n }\n if (src[i] === '{') depth += 1;\n else if (src[i] === '}') depth -= 1;\n else if (src[i] === '|' && depth === 1) return true;\n }\n return false;\n}\n\nfunction paramName(src: string): string {\n const name = /^\\{\\s*([^{}|:\\s]+)/.exec(src)?.[1];\n return name ? idSafe(name) : 'ph';\n}\n\n// XLIFF ids are NMTOKEN: keep letters, digits, dot, dash, underscore\nfunction idSafe(name: string): string {\n const safe = name.replace(/[^a-zA-Z0-9._-]/g, '_');\n return safe || 'ph';\n}\n\nfunction renderParts(parts: Part[], taken: Map<string, number>): string {\n let out = '';\n for (const part of parts) {\n if (part.kind === 'text') {\n out += escapeXml(part.text);\n } else if (part.kind === 'ph') {\n out += `<ph id=\"${uniqueId(part.name, taken)}\" disp=\"${escapeXml(part.src)}\"/>`;\n } else {\n const id = uniqueId(part.name, taken);\n out += `<pc id=\"${id}\" dispStart=\"${escapeXml(part.openSrc)}\" dispEnd=\"${escapeXml(part.closeSrc)}\">`;\n out += renderParts(part.children, taken);\n out += '</pc>';\n }\n }\n return out;\n}\n\nfunction uniqueId(name: string, taken: Map<string, number>): string {\n const count = taken.get(name) ?? 0;\n taken.set(name, count + 1);\n return count === 0 ? name : `${name}${count + 1}`;\n}\n\nfunction findPcClose(xml: string, from: number): { innerEnd: number; end: number } | undefined {\n const tags = /<pc\\b[^>]*>|<\\/pc\\s*>/g;\n tags.lastIndex = from;\n let depth = 1;\n for (let match = tags.exec(xml); match; match = tags.exec(xml)) {\n depth += match[0].startsWith('</') ? -1 : 1;\n if (depth === 0) return { innerEnd: match.index, end: tags.lastIndex };\n }\n return undefined;\n}\n\nfunction attr(attrs: string, name: string): string | undefined {\n const value = new RegExp(`\\\\b${name}\\\\s*=\\\\s*\"([^\"]*)\"`).exec(attrs)?.[1];\n return value === undefined ? undefined : unescapeXml(value);\n}\n","export interface MobileEntry {\n key: string;\n text: string;\n}\n\n// Android resource qualifier: source = default values/, two-letter region = -r suffix, else BCP-47 b+ syntax\nexport function androidValuesDir(locale: string, sourceLocale: string): string {\n if (locale === sourceLocale) return 'values';\n const parts = locale.split('-');\n if (parts.length === 1) return `values-${locale}`;\n if (parts.length === 2 && /^[a-zA-Z]{2}$/.test(parts[1]!)) {\n return `values-${parts[0]}-r${parts[1]!.toUpperCase()}`;\n }\n return `values-b+${parts.join('+')}`;\n}\n\nexport function toAndroidXml(entries: MobileEntry[]): string {\n const names = new Map<string, string>();\n const lines = entries.map(({ key, text }) => {\n const name = androidName(key);\n const clash = names.get(name);\n if (clash !== undefined) {\n throw new Error(\n `[verbaly] android-xml: keys \"${clash}\" and \"${key}\" both become resource name \"${name}\", rename one of them.`,\n );\n }\n names.set(name, key);\n return ` <string name=\"${name}\">${androidText(text)}</string>`;\n });\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n '<resources>',\n ...lines,\n '</resources>',\n '',\n ].join('\\n');\n}\n\nexport function toIosStrings(entries: MobileEntry[]): string {\n const lines = entries.map(({ key, text }) => `\"${iosText(key)}\" = \"${iosText(text)}\";`);\n return [...lines, ''].join('\\n');\n}\n\n// resource names must be identifiers: every other char collapses to _ (collisions rejected in toAndroidXml)\nfunction androidName(key: string): string {\n const name = key.replace(/[^A-Za-z0-9_]/g, '_');\n return /^[0-9]/.test(name) ? `_${name}` : name;\n}\n\n// aapt unescapes XML first, then Android's own backslash escapes; leading @/? would read as a resource reference\nfunction androidText(text: string): string {\n const escaped = text\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\t/g, '\\\\t')\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n return /^[@?]/.test(escaped) ? `\\\\${escaped}` : escaped;\n}\n\nfunction iosText(text: string): string {\n return text\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\t/g, '\\\\t');\n}\n","// gettext PO: msgctxt carries the catalog key (keys are hashes, msgid is the source\n// text), locations ride as #: comments. Params keep the {name} syntax verbatim, the\n// gettext norm. Entries flagged fuzzy read as untranslated (msgfmt semantics); an\n// empty msgstr means untranslated, matching the catalog's '' convention.\n\nexport interface PoEntry {\n key: string;\n source: string;\n target: string;\n location?: string[];\n}\n\nexport function toPo(sourceLocale: string, locale: string, entries: PoEntry[]): string {\n const header = [\n 'msgid \"\"',\n 'msgstr \"\"',\n `${poString('Project-Id-Version: verbaly\\n')}`,\n `${poString('MIME-Version: 1.0\\n')}`,\n `${poString('Content-Type: text/plain; charset=UTF-8\\n')}`,\n `${poString('Content-Transfer-Encoding: 8bit\\n')}`,\n `${poString(`Language: ${locale}\\n`)}`,\n `${poString(`X-Source-Language: ${sourceLocale}\\n`)}`,\n ].join('\\n');\n const blocks = entries.map(({ key, source, target, location }) =>\n [\n ...(location?.length ? [`#: ${location.join(' ')}`] : []),\n `msgctxt ${poString(key)}`,\n `msgid ${poString(source)}`,\n `msgstr ${poString(target)}`,\n ].join('\\n'),\n );\n return [header, ...blocks, ''].join('\\n\\n');\n}\n\nexport function parsePo(content: string): { locale?: string; entries: Record<string, string> } {\n const entries: Record<string, string> = {};\n let locale: string | undefined;\n\n let msgctxt: string | undefined;\n let msgid: string | undefined;\n let msgstr: string | undefined;\n let fuzzy = false;\n let field: 'msgctxt' | 'msgid' | 'msgstr' | 'other' | undefined;\n\n const finish = () => {\n if (msgid === '' && msgctxt === undefined) {\n const lang = /^Language:[ \\t]*(.+?)[ \\t]*$/m.exec(msgstr ?? '')?.[1];\n if (lang) locale = lang;\n } else if (msgctxt !== undefined && msgid !== undefined) {\n entries[msgctxt] = fuzzy ? '' : (msgstr ?? '');\n }\n msgctxt = msgid = msgstr = field = undefined;\n fuzzy = false;\n };\n\n // Windows editors may prepend a BOM; strip it before the first line parses\n for (const raw of content.replace(/^\\uFEFF/, '').split(/\\r\\n|[\\r\\n]/)) {\n const line = raw.trim();\n if (line === '') {\n finish();\n continue;\n }\n if (line.startsWith('#')) {\n if (/^#,.*\\bfuzzy\\b/.test(line)) fuzzy = true;\n continue;\n }\n const keyword = /^(msgctxt|msgid_plural|msgid|msgstr(?:\\[\\d+\\])?)\\s+(.*)$/.exec(line);\n if (keyword) {\n const [, name, rest] = keyword as unknown as [string, string, string];\n const value = poUnquote(rest);\n if (value === undefined) continue;\n if (name === 'msgctxt') {\n msgctxt = value;\n field = 'msgctxt';\n } else if (name === 'msgid') {\n msgid = value;\n field = 'msgid';\n } else if (name === 'msgstr' || name === 'msgstr[0]') {\n msgstr = value;\n field = 'msgstr';\n } else {\n // msgid_plural / msgstr[n>0]: verbaly plurals live inside one message, discard\n field = 'other';\n }\n continue;\n }\n const continuation = poUnquote(line);\n if (continuation === undefined || field === undefined || field === 'other') continue;\n if (field === 'msgctxt') msgctxt = (msgctxt ?? '') + continuation;\n else if (field === 'msgid') msgid = (msgid ?? '') + continuation;\n else msgstr = (msgstr ?? '') + continuation;\n }\n finish();\n return { locale, entries };\n}\n\nfunction poString(text: string): string {\n const escaped = text\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\t/g, '\\\\t')\n .replace(/\\r/g, '\\\\r');\n return `\"${escaped}\"`;\n}\n\nfunction poUnquote(text: string): string | undefined {\n const match = /^\"((?:[^\"\\\\]|\\\\.)*)\"$/.exec(text);\n if (!match) return undefined;\n return match[1]!.replace(/\\\\(.)/g, (_, ch: string) => {\n if (ch === 'n') return '\\n';\n if (ch === 't') return '\\t';\n if (ch === 'r') return '\\r';\n return ch;\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 function wins; otherwise the claude provider, imported lazily\n// (its SDK peer is optional: only translate should ever pay for it)\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// params, tags and the plural/select blocks must survive translation verbatim.\n// no locale here on purpose: this gate only rejects what renders wrong, and the\n// locale-specific plural advice is check's warning, never a reason to drop a 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, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport type { Catalogs } from './catalog';\nimport { targetLocales, type ResolvedConfig } from './config';\nimport { escapeXml, inlineToMessage, messageToInline, unescapeXml } from './inline';\nimport { androidValuesDir, toAndroidXml, toIosStrings } from './mobile';\nimport { parsePo, toPo } from './po';\nimport { structureMatches } from './translate';\n\nexport type ExchangeFormat = 'xliff' | 'csv' | 'po';\nexport type MobileFormat = 'android-xml' | 'ios-strings';\nexport type ExportFormat = ExchangeFormat | MobileFormat;\n\nexport function isMobileFormat(format: ExportFormat): format is MobileFormat {\n return format === 'android-xml' || format === 'ios-strings';\n}\n\nexport interface ExportOptions {\n locales?: string[];\n format?: ExportFormat;\n out?: string;\n missing?: boolean;\n origins?: Record<string, string[]>;\n}\n\nexport interface ExportedFile {\n locale: string;\n path: string;\n total: number;\n untranslated: number;\n}\n\nexport interface ExportResult {\n format: ExportFormat;\n dir: string;\n files: ExportedFile[];\n}\n\nexport interface ImportOptions {\n locale?: string;\n overwrite?: boolean;\n dryRun?: boolean;\n}\n\nexport interface ImportResult {\n imported: Record<string, string[]>;\n rejected: Record<string, string[]>;\n skipped: Record<string, string[]>;\n unknown: Record<string, string[]>;\n}\n\n// One file per target locale: source text + current translation\nexport function exportCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n options: ExportOptions = {},\n): ExportResult {\n const format = options.format ?? 'xliff';\n const dir = resolve(cfg.root, options.out ?? 'verbaly-export');\n const source = catalogs[cfg.sourceLocale] ?? {};\n const targets = targetLocales(cfg, options.locales);\n if (isMobileFormat(format)) {\n return exportMobile(cfg, catalogs, format, dir, source, targets);\n }\n\n const files: ExportedFile[] = [];\n mkdirSync(dir, { recursive: true });\n for (const locale of targets) {\n const catalog = catalogs[locale] ?? {};\n const all = Object.keys(source)\n .filter((key) => source[key])\n .sort()\n .map((key) => ({\n key,\n source: source[key]!,\n target: catalog[key] ?? '',\n location: options.origins?.[key],\n }));\n const untranslated = all.filter((entry) => !entry.target);\n const entries = options.missing ? untranslated : all;\n\n const ext = format === 'xliff' ? 'xlf' : format;\n const path = join(dir, `${locale}.${ext}`);\n const content =\n format === 'csv'\n ? toCsv(entries)\n : format === 'po'\n ? toPo(cfg.sourceLocale, locale, entries)\n : toXliff(cfg.sourceLocale, locale, entries);\n writeFileSync(path, content);\n files.push({\n locale,\n path,\n total: entries.length,\n untranslated: untranslated.length,\n });\n }\n return { format, dir, files };\n}\n\n// drop-in native resources (res/values-*, *.lproj); the source locale ships as the default,\n// untranslated keys are skipped so the platform falls back to it\nfunction exportMobile(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n format: MobileFormat,\n dir: string,\n source: Record<string, string>,\n targets: string[],\n): ExportResult {\n const keys = Object.keys(source)\n .filter((key) => source[key])\n .sort();\n const files: ExportedFile[] = [];\n for (const locale of [cfg.sourceLocale, ...targets]) {\n const catalog = locale === cfg.sourceLocale ? source : (catalogs[locale] ?? {});\n const entries = keys\n .map((key) => ({ key, text: catalog[key] ?? '' }))\n .filter((entry) => entry.text);\n const relative =\n format === 'android-xml'\n ? join(androidValuesDir(locale, cfg.sourceLocale), 'strings.xml')\n : join(`${locale}.lproj`, 'Localizable.strings');\n const path = join(dir, relative);\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, format === 'android-xml' ? toAndroidXml(entries) : toIosStrings(entries));\n files.push({\n locale,\n path,\n total: entries.length,\n untranslated: keys.length - entries.length,\n });\n }\n return { format, dir, files };\n}\n\n// fills catalogs from translated files\nexport function importCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n files: string[],\n options: ImportOptions = {},\n): ImportResult {\n const source = catalogs[cfg.sourceLocale] ?? {};\n const result: ImportResult = { imported: {}, rejected: {}, skipped: {}, unknown: {} };\n\n for (const file of files) {\n const parsed = parseExchangeFile(file, options.locale);\n const locale = parsed.locale;\n if (!/^[a-zA-Z]{2,3}([-_][a-zA-Z0-9]+)*$/.test(locale)) {\n throw new Error(\n `[verbaly] ${file}: \"${locale}\" doesn't look like a locale, pass --locale <id>.`,\n );\n }\n if (locale === cfg.sourceLocale) {\n throw new Error(\n `[verbaly] ${file} targets the source locale \"${locale}\": import fills translations, not the source. Pass --locale if the detection is wrong.`,\n );\n }\n const catalog = (catalogs[locale] ??= {});\n for (const [key, text] of Object.entries(parsed.entries)) {\n if (!text.trim()) continue;\n if (!source[key]) {\n (result.unknown[locale] ??= []).push(key);\n continue;\n }\n if (catalog[key] && !options.overwrite) {\n (result.skipped[locale] ??= []).push(key);\n continue;\n }\n if (!structureMatches(source[key], text)) {\n (result.rejected[locale] ??= []).push(key);\n continue;\n }\n if (!options.dryRun) catalog[key] = text;\n (result.imported[locale] ??= []).push(key);\n }\n }\n return result;\n}\n\ninterface ExchangeEntry {\n key: string;\n source: string;\n target: string;\n location?: string[];\n}\n\ninterface ParsedFile {\n locale: string;\n entries: Record<string, string>;\n}\n\nexport function parseExchangeFile(file: string, localeOverride?: string): ParsedFile {\n const content = readFileSync(file, 'utf8');\n if (/\\.(xlf|xliff)$/i.test(file)) {\n const parsed = parseXliff(content);\n const locale = localeOverride ?? parsed.locale;\n if (!locale) {\n throw new Error(`[verbaly] ${file} has no trgLang/target-language, pass --locale <id>.`);\n }\n return { locale, entries: parsed.entries };\n }\n if (/\\.csv$/i.test(file)) {\n const locale = localeOverride ?? basename(file).replace(/\\.csv$/i, '');\n return { locale, entries: parseCsv(content) };\n }\n if (/\\.po$/i.test(file)) {\n const parsed = parsePo(content);\n const locale = localeOverride ?? parsed.locale ?? basename(file).replace(/\\.po$/i, '');\n return { locale, entries: parsed.entries };\n }\n throw new Error(`[verbaly] ${file}: unsupported format, expected .xlf, .xliff, .csv or .po.`);\n}\n\n// XLIFF 2.0 (writes) / 2.0 + 1.2 (reads); params/tags travel as <ph>/<pc> inline codes\nfunction toXliff(sourceLocale: string, locale: string, entries: ExchangeEntry[]): string {\n const units = entries\n .map(({ key, source, target, location }) =>\n [\n ` <unit id=\"${escapeXml(key)}\">`,\n ...(location?.length\n ? [\n ' <notes>',\n ...location.map(\n (file) => ` <note category=\"location\">${escapeXml(file)}</note>`,\n ),\n ' </notes>',\n ]\n : []),\n ` <segment state=\"${target ? 'translated' : 'initial'}\">`,\n ` <source>${messageToInline(source)}</source>`,\n ` <target>${messageToInline(target)}</target>`,\n ' </segment>',\n ' </unit>',\n ].join('\\n'),\n )\n .join('\\n');\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n `<xliff xmlns=\"urn:oasis:names:tc:xliff:document:2.0\" version=\"2.0\" srcLang=\"${escapeXml(sourceLocale)}\" trgLang=\"${escapeXml(locale)}\">`,\n ` <file id=\"verbaly\" original=\"${escapeXml(`${locale}.json`)}\">`,\n units,\n ' </file>',\n '</xliff>',\n '',\n ].join('\\n');\n}\n\nfunction parseXliff(content: string): { locale?: string; entries: Record<string, string> } {\n const locale =\n /\\btrgLang\\s*=\\s*\"([^\"]+)\"/.exec(content)?.[1] ??\n /\\btarget-language\\s*=\\s*\"([^\"]+)\"/.exec(content)?.[1];\n const entries: Record<string, string> = {};\n const UNIT = /<(?:trans-)?unit\\b([^>]*)>([\\s\\S]*?)<\\/(?:trans-)?unit>/g;\n for (const match of content.matchAll(UNIT)) {\n const id = /\\bid\\s*=\\s*\"([^\"]*)\"/.exec(match[1]!)?.[1];\n if (!id) continue;\n const target = /<target\\b[^>]*>([\\s\\S]*?)<\\/target>/.exec(match[2]!)?.[1];\n entries[unescapeXml(id)] = target === undefined ? '' : inlineToMessage(stripCdata(target));\n }\n return { locale, entries };\n}\n\nfunction stripCdata(text: string): string {\n return text.replace(/<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>/g, '$1');\n}\n\n// CSV (RFC 4180); import reads columns by header name, so location round-trips inert\nfunction toCsv(entries: ExchangeEntry[]): string {\n const rows = entries.map(\n ({ key, source, target, location }) =>\n `${csvField(key)},${csvField(source)},${csvField(target)},${csvField(location?.join('; ') ?? '')}`,\n );\n return ['key,source,target,location', ...rows, ''].join('\\r\\n');\n}\n\nfunction csvField(text: string): string {\n return /[\",\\r\\n]/.test(text) ? `\"${text.replace(/\"/g, '\"\"')}\"` : text;\n}\n\nfunction parseCsv(content: string): Record<string, string> {\n const rows = csvRows(content);\n const header = rows[0]?.map((cell) => cell.trim().toLowerCase()) ?? [];\n const keyCol = header.indexOf('key');\n const targetCol = header.indexOf('target');\n if (keyCol === -1 || targetCol === -1) {\n throw new Error('[verbaly] CSV needs a header row with \"key\" and \"target\" columns.');\n }\n const entries: Record<string, string> = {};\n for (const row of rows.slice(1)) {\n const key = row[keyCol];\n if (key) entries[key] = row[targetCol] ?? '';\n }\n return entries;\n}\n\nfunction csvRows(content: string): string[][] {\n const rows: string[][] = [];\n let row: string[] = [];\n let field = '';\n let quoted = false;\n for (let i = 0; i < content.length; i++) {\n const char = content[i]!;\n if (quoted) {\n if (char === '\"') {\n if (content[i + 1] === '\"') {\n field += '\"';\n i++;\n } else {\n quoted = false;\n }\n } else {\n field += char;\n }\n } else if (char === '\"') {\n quoted = true;\n } else if (char === ',') {\n row.push(field);\n field = '';\n } else if (char === '\\n' || char === '\\r') {\n if (char === '\\r' && content[i + 1] === '\\n') i++;\n row.push(field);\n field = '';\n if (row.some((cell) => cell !== '')) rows.push(row);\n row = [];\n } else {\n field += char;\n }\n }\n row.push(field);\n if (row.some((cell) => cell !== '')) rows.push(row);\n return rows;\n}\n","import { isModuleNotFound } from '../config';\nimport type { TranslateProvider, TranslateRequest } from '../translate';\n\nexport interface ClaudeProviderOptions {\n model?: string;\n apiKey?: string;\n maxTokens?: number;\n}\n\n// balanced default for translation\nconst DEFAULT_MODEL = 'claude-sonnet-5';\n\nconst SYSTEM = `You translate UI strings for the Verbaly i18n library.\nRules:\n- Translate only the human-readable text, naturally for the target locale.\n- Preserve verbatim: placeholders like {name}, format specs like {price:currency/EUR}, variant blocks like {count | one: ... | other: # ...} (translate only the text inside each variant, keep keys and # as-is), ICU syntax, named tags like <em>...</em> and escapes {{ }} || ##.\n- Keys are opaque identifiers: return exactly the same keys, never translate or rename them.`;\n\nexport function claudeProvider(options: ClaudeProviderOptions = {}): TranslateProvider {\n return async (request: TranslateRequest) => {\n const Anthropic = await loadSdk();\n const client = new Anthropic(options.apiKey ? { apiKey: options.apiKey } : {});\n const response = await client.messages.create({\n model: options.model ?? DEFAULT_MODEL,\n max_tokens: options.maxTokens ?? 16000,\n thinking: { type: 'disabled' },\n system: SYSTEM,\n messages: [{ role: 'user', content: buildPrompt(request) }],\n output_config: { format: batchFormat(request) },\n });\n const text = response.content.find((block) => block.type === 'text')?.text ?? '{}';\n return JSON.parse(text) as Record<string, string>;\n };\n}\n\nexport function buildPrompt(request: TranslateRequest): string {\n const origins = request.origins;\n const context =\n origins && Object.keys(origins).length\n ? `\\n\\nWhere each string appears (context for tone and length, do not translate these paths):\\n` +\n Object.entries(origins)\n .map(([key, files]) => ` ${key}: ${files.join(', ')}`)\n .join('\\n')\n : '';\n return (\n `Translate each value from \"${request.sourceLocale}\" to \"${request.targetLocale}\". ` +\n `Return a JSON object with the same keys and translated values.\\n\\n` +\n JSON.stringify(request.messages, null, 2) +\n context\n );\n}\n\nexport function batchFormat(request: TranslateRequest) {\n const keys = Object.keys(request.messages);\n return {\n type: 'json_schema' as const,\n schema: {\n type: 'object',\n properties: Object.fromEntries(keys.map((key) => [key, { type: 'string' }])),\n required: keys,\n additionalProperties: false,\n },\n };\n}\n\ntype SdkModule = { default: typeof import('@anthropic-ai/sdk').default };\n\n// injectable for tests\nexport async function loadSdk(\n load: () => Promise<SdkModule> = () => import('@anthropic-ai/sdk'),\n): Promise<SdkModule['default']> {\n try {\n const mod = await load();\n return mod.default;\n } catch (error) {\n if (isModuleNotFound(error, '@anthropic-ai/sdk')) {\n throw new Error(\n '[verbaly] the claude translate provider needs @anthropic-ai/sdk: install it as a dev dependency (e.g. `pnpm add -D @anthropic-ai/sdk` / `npm i -D @anthropic-ai/sdk`) and set ANTHROPIC_API_KEY',\n { cause: error },\n );\n }\n throw error;\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 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\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}\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_TAGS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\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 // 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)) 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 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_TAGS.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 }\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// 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 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 });\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 += `<${node.name}>${richToHtml(node.children, allowed, links)}</${node.name}>`;\n } else {\n out += richToHtml(node.children, allowed, links); // unknown tag → unwrap\n }\n }\n return out;\n}\n\nfunction escapeHtml(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nfunction escapeAttr(text: string): string {\n return escapeHtml(text).replace(/\"/g, '&quot;');\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&amp;/g, '&');\n}\n","import type { 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 source = catalogs[cfg.sourceLocale] ?? {};\n const needed = new Set<string>([...registry.messages().keys(), ...Object.keys(source)]);\n const live = effectiveDrafts(drafts, catalogs);\n\n const extracted = registry.messages();\n const locales: LocaleStatus[] = [];\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n let translated = 0;\n for (const key of needed) {\n if (catalogs[locale]?.[key]) translated += 1;\n }\n // counted over the flattened catalog: a nested hand-written one has no top-level messages\n let broken = 0;\n const flatSource = flatten((source ?? {}) as MessageTree);\n for (const [key, text] of Object.entries(flatten((catalogs[locale] ?? {}) as MessageTree))) {\n if (!text) continue;\n const from = flatSource[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 { watch } from 'node:fs';\nimport { relative } from 'node:path';\nimport type { ResolvedConfig } from './config';\nimport { SOURCE_FILE_RE } from './plugin';\n\nexport interface WatchProjectOptions {\n debounce?: number;\n}\n\n// source files only: extract's own catalog/dts writes must never retrigger a run\nexport function watchProject(\n cfg: ResolvedConfig,\n run: () => Promise<void>,\n options: WatchProjectOptions = {},\n): () => void {\n const catalogDir = relative(cfg.root, cfg.dir).replaceAll('\\\\', '/');\n let timer: ReturnType<typeof setTimeout> | undefined;\n let running = false;\n let queued = false;\n\n async function refresh(): Promise<void> {\n if (running) {\n queued = true;\n return;\n }\n running = true;\n try {\n await run();\n } catch (error) {\n console.warn('[verbaly] watch run failed:', error);\n } finally {\n running = false;\n if (queued) {\n queued = false;\n schedule();\n }\n }\n }\n\n function schedule(): void {\n clearTimeout(timer);\n timer = setTimeout(() => void refresh(), options.debounce ?? 150);\n }\n\n const watcher = watch(cfg.root, { recursive: true }, (_event, filename) => {\n if (!filename) return;\n const file = filename.replaceAll('\\\\', '/');\n if (file.includes('node_modules/') || file.endsWith('.d.ts')) return;\n if (catalogDir && file.startsWith(`${catalogDir}/`)) return;\n if (SOURCE_FILE_RE.test(file)) schedule();\n });\n\n return (): void => {\n clearTimeout(timer);\n watcher.close();\n };\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { parse } from '@babel/parser';\nimport MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport { cleanJsxText, isTReference, walk, type AstNode } from './analyze';\nimport type { ResolvedConfig } from './config';\n\nexport interface WrapEntry {\n file: string;\n line: number;\n text: string;\n kind: 'text' | 'attribute';\n attribute?: string;\n}\n\nexport interface WrapSkip {\n file: string;\n line: number;\n text: string;\n reason: string;\n}\n\nexport interface WrapResult {\n files: number;\n changed: string[];\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport interface WrapOptions {\n write?: boolean;\n}\n\n// user-visible string attributes worth translating; everything else stays code\nconst WRAP_ATTRS = new Set(['title', 'alt', 'placeholder', 'aria-label']);\n\nconst T_NAMES: ReadonlySet<string> = new Set(['t']);\nconst LETTER = /\\p{L}/u;\n\n// onboarding codemod: finds hardcoded JSX text and wraps it in t`…`.\n// Errs on skipping, never on inventing: anything ambiguous lands in the report instead.\nexport async function wrapProject(\n cfg: ResolvedConfig,\n options: WrapOptions = {},\n): Promise<WrapResult> {\n const files = (\n await glob(cfg.include, { cwd: cfg.root, ignore: cfg.exclude, absolute: true })\n ).filter((file) => /\\.[jt]sx$/.test(file));\n\n const result: WrapResult = { files: files.length, changed: [], wrapped: [], skipped: [] };\n\n for (const file of files) {\n const code = readFileSync(file, 'utf8');\n const label = relative(cfg.root, file).replaceAll('\\\\', '/');\n const out = wrapCode(code, label);\n result.wrapped.push(...out.wrapped);\n result.skipped.push(...out.skipped);\n if (out.code !== undefined) {\n result.changed.push(label);\n if (options.write) writeFileSync(file, out.code);\n }\n }\n return result;\n}\n\nexport interface WrapCodeResult {\n code?: string;\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport function wrapCode(code: string, file: string): WrapCodeResult {\n const wrapped: WrapEntry[] = [];\n const skipped: WrapSkip[] = [];\n\n let ast: AstNode;\n try {\n ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: ['typescript', 'jsx'],\n }).program as unknown as AstNode;\n } catch {\n return { wrapped, skipped }; // unparseable file: leave it alone\n }\n\n const s = new MagicString(code);\n const visited = new Set<AstNode>();\n let changed = false;\n\n walk(ast, (node) => {\n if (node.type !== 'JSXElement' && node.type !== 'JSXFragment') return;\n if (visited.has(node)) return;\n processElement(node);\n });\n\n return changed ? { code: s.toString(), wrapped, skipped } : { wrapped, skipped };\n\n function processElement(node: AstNode): void {\n visited.add(node);\n\n if (node.type === 'JSXElement') {\n const opening = node.openingElement as AstNode;\n const name = opening.name as AstNode;\n // <Trans> children and data-verbaly subtrees are already message-managed\n if (name.type === 'JSXIdentifier' && name.name === 'Trans') return markSubtree(node);\n if (hasVerbalyAttr(opening)) return markSubtree(node);\n wrapAttributes(opening);\n }\n\n const children = (node.children as AstNode[] | undefined) ?? [];\n const hasElementChild = children.some(\n (c) => c.type === 'JSXElement' || c.type === 'JSXFragment',\n );\n const hasText = children.some(\n (c) =>\n (c.type === 'JSXText' && LETTER.test(c.value as string)) ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type === 'StringLiteral' &&\n LETTER.test((c.expression as AstNode).value as string)),\n );\n\n if (hasElementChild && hasText) {\n // splitting the sentence into fragments would ship broken translations\n skip(node, snippet(children), 'mixed text and markup: wrap by hand or use <Trans>');\n return markSubtree(node);\n }\n if (hasText) {\n wrapSegment(node, children);\n return markSubtree(node);\n }\n for (const child of children) {\n if (child.type === 'JSXElement' || child.type === 'JSXFragment') processElement(child);\n }\n }\n\n function wrapSegment(parent: AstNode, children: AstNode[]): void {\n const meaningful = children.filter(\n (c) =>\n (c.type === 'JSXText' && (c.value as string).trim() !== '') ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type !== 'JSXEmptyExpression'),\n );\n if (meaningful.length === 0) return;\n\n const first = meaningful[0]!;\n const last = meaningful[meaningful.length - 1]!;\n\n let template = '';\n let report = '';\n for (let i = children.indexOf(first); i <= children.indexOf(last); i++) {\n const child = children[i]!;\n if (child.type === 'JSXText') {\n let value = cleanJsxText(child.value as string);\n if (child === first) value = value.trimStart();\n if (child === last) value = value.trimEnd();\n template += escapeTemplate(value);\n report += value;\n } else if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression as AstNode;\n if (expr.type === 'JSXEmptyExpression') continue;\n if (usesT(expr)) {\n skip(parent, snippet(children), 'already uses t: finish it by hand');\n return;\n }\n if (containsJsx(expr)) {\n skip(\n parent,\n snippet(children),\n 'an expression renders markup: wrap by hand or use <Trans>',\n );\n markSubtree(child);\n return;\n }\n if (expr.type === 'StringLiteral') {\n template += escapeTemplate(expr.value as string);\n report += expr.value as string;\n } else {\n const source = code.slice(expr.start, expr.end);\n template += '${' + source + '}';\n report += '${' + source + '}';\n }\n } else {\n return; // spread children and friends: bail quietly\n }\n }\n if (!LETTER.test(report)) return;\n\n const start =\n first.type === 'JSXText' ? first.start + leadingWs(first.value as string) : first.start;\n const end = last.type === 'JSXText' ? last.end - trailingWs(last.value as string) : last.end;\n\n s.overwrite(start, end, '{t`' + template + '`}');\n changed = true;\n wrapped.push({ file, line: line(first), text: report, kind: 'text' });\n }\n\n function wrapAttributes(opening: AstNode): void {\n for (const attr of opening.attributes as AstNode[]) {\n if (attr.type !== 'JSXAttribute') continue;\n const name = attr.name as AstNode;\n if (name.type !== 'JSXIdentifier' || !WRAP_ATTRS.has(name.name as string)) continue;\n const value = attr.value as AstNode | null;\n if (value?.type !== 'StringLiteral') continue;\n const raw = value.value as string;\n if (!LETTER.test(raw)) continue;\n s.overwrite(value.start, value.end, '{t`' + escapeTemplate(raw) + '`}');\n changed = true;\n wrapped.push({\n file,\n line: line(value),\n text: raw,\n kind: 'attribute',\n attribute: name.name as string,\n });\n }\n }\n\n function skip(node: AstNode, text: string, reason: string): void {\n skipped.push({ file, line: line(node), text, reason });\n }\n\n function snippet(children: AstNode[]): string {\n const start = children[0]?.start ?? 0;\n const end = children[children.length - 1]?.end ?? start;\n const text = code.slice(start, end).replace(/\\s+/g, ' ').trim();\n return text.length > 60 ? text.slice(0, 59) + '…' : text;\n }\n\n function markSubtree(node: AstNode): void {\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') visited.add(n);\n });\n }\n}\n\nfunction hasVerbalyAttr(opening: AstNode): boolean {\n return (opening.attributes as AstNode[]).some((attr) => {\n if (attr.type !== 'JSXAttribute') return false;\n const name = attr.name as AstNode;\n return name.type === 'JSXIdentifier' && (name.name as string).startsWith('data-verbaly');\n });\n}\n\n// a t`…` / t(...) / t.id anywhere in the expression means a human already started here\nfunction usesT(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'TaggedTemplateExpression' && isTReference(n.tag as AstNode, T_NAMES)) {\n found = true;\n }\n if (n.type === 'CallExpression' && isTReference(n.callee as AstNode, T_NAMES)) found = true;\n });\n return found;\n}\n\nfunction containsJsx(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') found = true;\n });\n return found;\n}\n\n// literal text run → template-literal-safe\nfunction escapeTemplate(text: string): string {\n return text.replace(/[\\\\`]/g, '\\\\$&').replace(/\\$\\{/g, '\\\\${');\n}\n\nfunction leadingWs(text: string): number {\n return text.length - text.trimStart().length;\n}\n\nfunction trailingWs(text: string): number {\n return text.length - text.trimEnd().length;\n}\n\nfunction line(node: AstNode): number {\n const loc = node.loc as { start?: { line?: number } } | undefined;\n return loc?.start?.line ?? 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAgB,UAAU,SAAyB;CACjD,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC;AAC5E;;;ACyCA,MAAM,4BAAY,IAAI,IAAI;CAAC;CAAO;CAAmB;CAAoB;CAAiB;AAAO,CAAC;AAMlG,MAAM,kBAAqC,CAAC,GAAG;AAE/C,SAAgB,QAAQ,MAAc,MAAc,UAA0B,CAAC,GAAa;CAC1F,MAAM,QAAQ,IAAI,IAAI,QAAQ,UAA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AU,MAAsB;CACvC,OAAO,KAAK,SAAS,KAAK,UAAU,CAAC,CAAC;AACxC;AAEA,SAAS,WAAW,MAAsB;CACxC,OAAO,KAAK,SAAS,KAAK,QAAQ,CAAC,CAAC;AACtC;AAEA,SAAS,KAAK,MAAuB;CAEnC,OADY,KAAK,KACL,OAAO,QAAQ;AAC7B"}
1
+ {"version":3,"file":"index.js","names":["walk","parse","parse","matchBrace"],"sources":["../src/key.ts","../src/analyze.ts","../src/sfc.ts","../src/catalog.ts","../src/validate.ts","../src/check.ts","../src/params.ts","../src/codegen.ts","../src/pseudo.ts","../src/config.ts","../src/transform.ts","../src/plugin.ts","../src/registry.ts","../src/extract.ts","../src/init.ts","../src/doctor.ts","../src/drafts.ts","../src/inline.ts","../src/mobile.ts","../src/po.ts","../src/translate.ts","../src/exchange.ts","../src/providers/claude.ts","../src/render.ts","../src/status.ts","../src/watch.ts","../src/wrap.ts"],"sourcesContent":["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\nexport interface Analysis {\n tagged: TaggedMessage[];\n usedKeys: UsedKey[];\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'];\n\nexport function analyze(code: string, file: string, options: AnalyzeOptions = {}): Analysis {\n const names = new Set(options.tNames ?? DEFAULT_T_NAMES);\n const jsx = /\\.[jt]sx$/.test(file);\n const ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: jsx ? ['typescript', 'jsx'] : ['typescript'],\n });\n\n const tagged: TaggedMessage[] = [];\n const usedKeys: UsedKey[] = [];\n\n walk(ast.program as unknown as AstNode, (node) => {\n 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 };\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 { analyze, type Analysis, type TaggedParam, type UsedKey } 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 return SFC_FILE_RE.test(file) ? analyzeSfc(code, file) : analyze(code, file);\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\n const frontmatter = file.endsWith('.astro') ? FRONTMATTER_RE.exec(code) : null;\n if (frontmatter?.[2]) {\n merge(analyzeSegment(frontmatter[2], file, options), frontmatter[1]!.length, false);\n }\n\n for (const match of code.matchAll(SCRIPT_RE)) {\n const content = match[2]!;\n if (!content) continue;\n merge(analyzeSegment(content, file, options), match.index + match[1]!.length, false);\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), start, true);\n consumedTo = end;\n }\n\n return { tagged, usedKeys };\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 }\n}\n\nfunction analyzeSegment(\n code: string,\n file: string,\n options?: { tNames: string[] },\n): Analysis | undefined {\n try {\n return analyze(code, file, options);\n } catch {\n return undefined; // malformed segment: skip it, never fail the whole file\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 { 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// missing file = empty catalog; a corrupt one must fail loudly (read as empty,\n// the next extract would rewrite it and lose every translation)\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 { 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// a name is markup only where the message closes it (</x>) or self-closes it (<x/>).\n// a lone <Enter> is prose: rich rendering drops the wrapper and plain text prints it\n// verbatim, so demanding it back from the translator failed correct translations\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// 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 is an empty render, whatever the block selects on.\n // a plural block that lost it is validateMessage's report, so it is not repeated here\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\n // binary, so this one shipped with zero reviewable diffs\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 { 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 of every catalog, because that is the shape t() sees: a hand-written\n // nested tree is flattened by the runtime, so comparing its top-level namespaces\n // reported a locale as complete while its leaves were untranslated\n const flat: Record<string, Catalog> = {};\n for (const locale of cfg.locales) {\n flat[locale] = flatten((catalogs[locale] ?? {}) as MessageTree);\n }\n const source = flat[cfg.sourceLocale] ?? {};\n\n const unknown: UnknownEntry[] = [];\n for (const [key, files] of registry.usedKeys()) {\n const known =\n extracted.has(key) || cfg.locales.some((locale) => flat[locale]?.[key] !== undefined);\n if (!known) unknown.push({ key, files });\n }\n\n const needed = new Set<string>([...extracted.keys(), ...Object.keys(source)]);\n\n const missing: MissingEntry[] = [];\n for (const key of extracted.keys()) {\n if (!source[key]) {\n missing.push({ locale: cfg.sourceLocale, key, source: extracted.get(key)?.message });\n }\n }\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n for (const key of needed) {\n if (!flat[locale]?.[key]) {\n missing.push({ locale, key, source: source[key] ?? extracted.get(key)?.message });\n }\n }\n }\n\n // presence is not correctness: a translation can be there and still render wrong\n const broken: BrokenEntry[] = [];\n const add = (locale: string, key: string, issues: StructureIssue[]): void => {\n for (const issue of issues) {\n broken.push({ locale, key, severity: issue.severity, issue: issue.message });\n }\n };\n\n // a key can be used in code before it reaches the catalog: validate that text too\n const sourceText: Catalog = { ...source };\n for (const [key, entry] of extracted) {\n if (!sourceText[key]) sourceText[key] = entry.message;\n }\n for (const [key, text] of Object.entries(sourceText)) {\n add(cfg.sourceLocale, key, validateMessage(text, cfg.sourceLocale));\n }\n for (const locale of cfg.locales) {\n if (locale === cfg.sourceLocale) continue;\n for (const [key, translated] of Object.entries(flat[locale] ?? {})) {\n if (!translated) continue; // '' is untranslated, already reported as missing\n add(locale, key, validateMessage(translated, locale));\n const text = sourceText[key];\n if (text) add(locale, key, validatePair(text, translated));\n }\n }\n\n return { ok: gatePasses({ missing, unknown, broken }), missing, unknown, broken };\n}\n\nexport function formatCheckResult(result: CheckResult): string {\n const lines: string[] = [];\n if (result.missing.length > 0) {\n lines.push('missing translations:');\n for (const entry of result.missing) {\n const hint = entry.source ? `: \"${truncate(entry.source, 40)}\"` : '';\n lines.push(` [${entry.locale}] ${entry.key}${hint}`);\n }\n }\n if (result.unknown.length > 0) {\n lines.push('unknown keys (not in any catalog):');\n for (const entry of result.unknown) {\n lines.push(` ${entry.key} (used in ${entry.files.join(', ')})`);\n }\n }\n const errors = result.broken.filter((entry) => entry.severity === 'error');\n if (errors.length > 0) {\n lines.push('broken translations:');\n for (const entry of errors) lines.push(` [${entry.locale}] ${entry.key}: ${entry.issue}`);\n }\n return lines.join('\\n');\n}\n\n// what to do about each kind of failure: extract only fixes one of the three\nexport function checkNextSteps(result: CheckResult): string {\n const steps: string[] = [];\n if (result.missing.length > 0) {\n steps.push(\n 'missing: run `npx verbaly extract` to scaffold the keys, then fill them (or run `npx verbaly translate`)',\n );\n }\n if (result.unknown.length > 0) {\n steps.push(\n 'unknown keys: the key used in the code is in no catalog, fix the key or run `npx verbaly extract`',\n );\n }\n if (result.broken.some((entry) => entry.severity === 'error')) {\n steps.push(\n 'broken: a translation has to keep the params, tags and plural cases of its source message',\n );\n }\n return steps.join('\\n');\n}\n\n// warnings never fail the gate, so they print on their own\nexport function formatCheckWarnings(result: CheckResult): string {\n return result.broken\n .filter((entry) => entry.severity === 'warning')\n .map((entry) => ` [${entry.locale}] ${entry.key}: ${entry.issue}`)\n .join('\\n');\n}\n\nfunction truncate(text: string, max: number): string {\n return text.length > max ? text.slice(0, max - 1) + '…' : text;\n}\n\n// GitHub workflow commands: every failure becomes a clickable ::error annotation on the PR\nexport function githubCheckAnnotations(\n result: CheckResult,\n registry: MessageRegistry,\n root: string,\n): string[] {\n const messages = registry.messages();\n const contents = new Map<string, string | undefined>();\n const readSource = (file: string): string | undefined => {\n if (!contents.has(file)) {\n try {\n contents.set(file, readFileSync(file, 'utf8'));\n } catch {\n contents.set(file, undefined);\n }\n }\n return contents.get(file);\n };\n\n const lines: string[] = [];\n\n // one annotation per key, locales grouped: N locales must not bury the PR in N copies\n const byKey = new Map<string, MissingEntry & { locales: string[] }>();\n for (const entry of result.missing) {\n const grouped = byKey.get(entry.key);\n if (grouped) grouped.locales.push(entry.locale);\n else byKey.set(entry.key, { ...entry, locales: [entry.locale] });\n }\n\n for (const entry of byKey.values()) {\n const origin = messages.get(entry.key);\n const hint = entry.source ? `: \"${truncate(entry.source, 60)}\"` : '';\n const text = escapeData(`missing [${entry.locales.join(', ')}] ${entry.key}${hint}`);\n if (origin) {\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::error file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n } else {\n lines.push(`::error::${text}`);\n }\n }\n\n for (const entry of result.unknown) {\n const text = escapeData(`unknown key \"${entry.key}\" (not in any catalog)`);\n const file = entry.files[0];\n lines.push(\n file\n ? `::error file=${escapeProperty(relative(root, file).replaceAll('\\\\', '/'))}::${text}`\n : `::error::${text}`,\n );\n }\n\n // a broken translation points at the source line that wrote the message\n for (const entry of result.broken) {\n const origin = messages.get(entry.key);\n const text = escapeData(`[${entry.locale}] ${entry.key}: ${entry.issue}`);\n const command = entry.severity === 'error' ? 'error' : 'warning';\n if (!origin) {\n lines.push(`::${command}::${text}`);\n continue;\n }\n const file = relative(root, origin.file).replaceAll('\\\\', '/');\n const content = readSource(origin.file);\n const line = content === undefined ? undefined : lineAt(content, origin.start);\n lines.push(`::${command} file=${escapeProperty(file)}${line ? `,line=${line}` : ''}::${text}`);\n }\n return lines;\n}\n\nfunction lineAt(content: string, offset: number): number {\n let line = 1;\n const end = Math.min(offset, content.length);\n for (let i = 0; i < end; i++) {\n if (content[i] === '\\n') line += 1;\n }\n return line;\n}\n\nfunction escapeData(text: string): string {\n return text.replaceAll('%', '%25').replaceAll('\\r', '%0D').replaceAll('\\n', '%0A');\n}\n\nfunction escapeProperty(text: string): string {\n return escapeData(text).replaceAll(':', '%3A').replaceAll(',', '%2C');\n}\n","import { 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// skip unchanged writes: a rewritten verbaly.d.ts churns the consumer's TS server.\n// file defaults to the project root: the one spot TS includes with zero tsconfig;\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 type { Catalog, Catalogs } from './catalog';\nimport type { ResolvedConfig } from './config';\n\nexport const PSEUDO_LOCALE = 'en-XA';\n\nconst ACCENTS: Record<string, string> = {\n a: 'á',\n b: 'ƀ',\n c: 'ç',\n d: 'đ',\n e: 'é',\n f: 'ƒ',\n g: 'ğ',\n h: 'ĥ',\n i: 'í',\n j: 'ĵ',\n k: 'ķ',\n l: 'ĺ',\n m: 'ɱ',\n n: 'ñ',\n o: 'ó',\n p: 'þ',\n q: 'ǫ',\n r: 'ŕ',\n s: 'š',\n t: 'ţ',\n u: 'ú',\n v: 'ṽ',\n w: 'ŵ',\n x: 'ẋ',\n y: 'ý',\n z: 'ž',\n A: 'Á',\n B: 'Ɓ',\n C: 'Ç',\n D: 'Đ',\n E: 'É',\n F: 'Ƒ',\n G: 'Ğ',\n H: 'Ĥ',\n I: 'Í',\n J: 'Ĵ',\n K: 'Ķ',\n L: 'Ĺ',\n M: 'Ḿ',\n N: 'Ñ',\n O: 'Ó',\n P: 'Þ',\n Q: 'Ǫ',\n R: 'Ŕ',\n S: 'Š',\n T: 'Ţ',\n U: 'Ú',\n V: 'Ṽ',\n W: 'Ŵ',\n X: 'Ẍ',\n Y: 'Ý',\n Z: 'Ž',\n};\n\nconst TAG_AT = /<\\/?[a-zA-Z][\\w-]*\\/?>/y;\n\n// params, variant blocks, tags and escapes survive verbatim\nexport function pseudoLocalize(message: string): string {\n let out = '';\n let letters = 0;\n let i = 0;\n while (i < message.length) {\n const two = message.slice(i, i + 2);\n if (two === '{{' || two === '}}' || two === '||' || two === '##') {\n out += two;\n i += 2;\n continue;\n }\n const ch = message[i]!;\n if (ch === '{') {\n const end = matchBrace(message, i);\n out += message.slice(i, end);\n i = end;\n continue;\n }\n if (ch === '<') {\n TAG_AT.lastIndex = i;\n const m = TAG_AT.exec(message);\n if (m) {\n out += m[0];\n i += m[0].length;\n continue;\n }\n }\n const mapped = ACCENTS[ch];\n if (mapped) {\n out += mapped;\n letters += 1;\n } else {\n out += ch;\n }\n i += 1;\n }\n const pad = '~'.repeat(Math.ceil(letters / 3));\n return `⟦${out}${pad ? ' ' + pad : ''}⟧`;\n}\n\nfunction matchBrace(message: string, start: number): number {\n let depth = 0;\n for (let i = start; i < message.length; i++) {\n const two = message.slice(i, i + 2);\n if (two === '{{' || two === '}}') {\n i += 1;\n continue;\n }\n const ch = message[i];\n if (ch === '{') depth += 1;\n else if (ch === '}') {\n depth -= 1;\n if (depth === 0) return i + 1;\n }\n }\n return message.length; // unbalanced → verbatim\n}\n\n// regenerates the whole pseudo catalog from the source catalog\nexport function pseudoCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n locale: string = PSEUDO_LOCALE,\n): string[] {\n const source = catalogs[cfg.sourceLocale] ?? {};\n const target: Catalog = {};\n for (const [key, msg] of Object.entries(source)) {\n target[key] = msg ? pseudoLocalize(msg) : '';\n }\n catalogs[locale] = target;\n return Object.keys(target).filter((key) => target[key]);\n}\n","import { existsSync, readFileSync, readdirSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { RichLink } from 'verbaly';\nimport { PSEUDO_LOCALE } from './pseudo';\nimport type { TranslateProvider } from './translate';\n\nexport interface TranslateConfig {\n provider?: 'claude' | TranslateProvider;\n model?: string;\n batchSize?: number;\n}\n\nexport interface RenderConfig {\n links?: Record<string, RichLink>;\n site?: string;\n attribute?: string;\n baseUrl?: string;\n hreflang?: boolean;\n sitemap?: boolean | string;\n clean?: boolean;\n}\n\nexport interface VerbalyConfig {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n include?: string[];\n exclude?: string[];\n dts?: string | false;\n translate?: TranslateConfig;\n render?: RenderConfig;\n}\n\nexport interface ResolvedConfig {\n root: string;\n dir: string;\n sourceLocale: string;\n locales: string[];\n include: string[];\n exclude: string[];\n dts: string | false | undefined;\n translate: TranslateConfig;\n render: RenderConfig;\n}\n\nexport function resolveConfig(config: VerbalyConfig = {}): ResolvedConfig {\n const root = resolve(config.root ?? process.cwd());\n const dir = resolve(root, config.dir ?? 'locales');\n const sourceLocale = config.sourceLocale ?? 'en';\n\n const locales = new Set<string>([sourceLocale, ...(config.locales ?? [])]);\n if (existsSync(dir)) {\n for (const file of readdirSync(dir)) {\n if (file.endsWith('.json') && !file.startsWith('.') && file !== `${PSEUDO_LOCALE}.json`) {\n locales.add(file.slice(0, -5));\n }\n }\n }\n\n return {\n root,\n dir,\n sourceLocale,\n locales: [...locales],\n include: config.include ?? ['{src,app}/**/*.{js,jsx,ts,tsx,mjs,mts,svelte,vue,astro}'],\n exclude: config.exclude ?? ['**/node_modules/**', '**/dist/**'],\n dts: typeof config.dts === 'string' ? resolve(root, config.dts) : config.dts,\n translate: config.translate ?? {},\n render: config.render ?? {},\n };\n}\n\nconst CONFIG_FILES = [\n 'verbaly.config.js',\n 'verbaly.config.mjs',\n 'verbaly.config.ts',\n 'verbaly.config.mts',\n 'verbaly.config.json',\n];\n\nexport function findConfigFile(root: string): string | undefined {\n return CONFIG_FILES.find((name) => existsSync(join(root, name)));\n}\n\nexport async function loadConfigFile(root: string): Promise<VerbalyConfig> {\n for (const name of ['verbaly.config.js', 'verbaly.config.mjs']) {\n const path = join(root, name);\n if (existsSync(path)) {\n const mod = (await import(pathToFileURL(path).href)) as { default?: VerbalyConfig };\n return mod.default ?? {};\n }\n }\n for (const name of ['verbaly.config.ts', 'verbaly.config.mts']) {\n const path = join(root, name);\n if (existsSync(path)) return loadTsConfig(path);\n }\n const jsonPath = join(root, 'verbaly.config.json');\n if (existsSync(jsonPath)) {\n return JSON.parse(readFileSync(jsonPath, 'utf8')) as VerbalyConfig;\n }\n return {};\n}\n\nasync function loadTsConfig(path: string): Promise<VerbalyConfig> {\n try {\n const { bundleRequire } = await import('bundle-require');\n const { mod } = await bundleRequire<{ default?: VerbalyConfig }>({ filepath: path });\n return mod.default ?? {};\n } catch (error) {\n if (isModuleNotFound(error, 'esbuild')) {\n throw new Error(`[verbaly] ${path} needs esbuild: install it with pnpm add -D esbuild`, {\n cause: error,\n });\n }\n throw error;\n }\n}\n\nexport function isModuleNotFound(error: unknown, name: string): boolean {\n return (\n error instanceof Error &&\n (error as { code?: string }).code === 'ERR_MODULE_NOT_FOUND' &&\n error.message.includes(name)\n );\n}\n\n// non-source locales a command may write to (optional CLI override, always config-bounded)\nexport function targetLocales(cfg: ResolvedConfig, override?: string[]): string[] {\n return (override ?? cfg.locales).filter(\n (locale) => locale !== cfg.sourceLocale && cfg.locales.includes(locale),\n );\n}\n\n// file config + inline overrides\nexport async function loadConfig(\n root: string,\n overrides: VerbalyConfig = {},\n): Promise<ResolvedConfig> {\n const fileConfig = await loadConfigFile(root);\n return resolveConfig({ ...fileConfig, ...definedOnly(overrides), root });\n}\n\nfunction definedOnly(config: VerbalyConfig): VerbalyConfig {\n return Object.fromEntries(\n Object.entries(config).filter(([, value]) => value !== undefined),\n ) as VerbalyConfig;\n}\n","import MagicString from 'magic-string';\nimport type { Analysis } from './analyze';\nimport { analyzeFile } from './sfc';\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 { tagged } = analysis ?? analyzeFile(code, file);\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 type { Analysis } from './analyze';\nimport { loadCatalogs, 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';\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): { analysis: Analysis; result: TransformResult | null } {\n const analysis = analyzeFile(code, id);\n registry.update(id, analysis);\n return { analysis, 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 // `failOnMissing: false` means \"let me build with untranslated strings\", never \"let me\n // ship a translation that renders wrong\": a missing one falls back to the source locale,\n // a broken one renders the wrong text or nothing at all\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 type { Analysis, 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 // 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 { 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 { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { findConfigFile } from './config';\n\nexport interface InitOptions {\n root?: string;\n dir?: string;\n sourceLocale?: string;\n locales?: string[];\n}\n\nexport interface InitResult {\n created: string[];\n skipped: string[];\n host: Host | undefined;\n configFile: string;\n next: string[];\n}\n\nexport type Host =\n 'nuxt' | 'next' | 'sveltekit' | 'astro' | 'vite' | 'webpack' | 'rspack' | 'rollup' | 'esbuild';\n\nexport interface HostSetup {\n name: Host;\n pkg: string;\n wire: string;\n}\n\nconst HOSTS: (HostSetup & { dep: string })[] = [\n {\n name: 'nuxt',\n dep: 'nuxt',\n pkg: '@verbaly/nuxt',\n wire: \"add '@verbaly/nuxt' to the modules in nuxt.config\",\n },\n {\n name: 'next',\n dep: 'next',\n pkg: '@verbaly/next',\n wire: 'wrap the export of next.config with withVerbaly',\n },\n {\n name: 'sveltekit',\n dep: '@sveltejs/kit',\n pkg: '@verbaly/vite',\n wire: 'add verbaly() to the plugins in vite.config (per-request locale: @verbaly/sveltekit)',\n },\n {\n name: 'astro',\n dep: 'astro',\n pkg: '@verbaly/astro',\n wire: 'add verbaly() to the integrations in astro.config',\n },\n {\n name: 'vite',\n dep: 'vite',\n pkg: '@verbaly/vite',\n wire: 'add verbaly() to the plugins in vite.config',\n },\n {\n name: 'webpack',\n dep: 'webpack',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly webpack plugin to your build config',\n },\n {\n name: 'rspack',\n dep: '@rspack/core',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly rspack plugin to your build config',\n },\n {\n name: 'rollup',\n dep: 'rollup',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly rollup plugin to your build config',\n },\n {\n name: 'esbuild',\n dep: 'esbuild',\n pkg: '@verbaly/unplugin',\n wire: 'add the verbaly esbuild plugin to your build config',\n },\n];\n\n// any of these wires the build; the detected host only decides which one we recommend\nexport const WIRING_PACKAGES = [...new Set(HOSTS.map((host) => host.pkg))];\n\nexport function readDependencies(root: string): Record<string, string> {\n const path = join(root, 'package.json');\n if (!existsSync(path)) return {};\n try {\n const pkg = JSON.parse(readFileSync(path, 'utf8')) as {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n return { ...pkg.dependencies, ...pkg.devDependencies };\n } catch {\n return {};\n }\n}\n\nexport function detectHost(root: string): HostSetup | undefined {\n const deps = readDependencies(root);\n return HOSTS.find((host) => deps[host.dep]);\n}\n\nfunction configSource(options: InitOptions, typescript: boolean): string {\n const fields = [` sourceLocale: '${options.sourceLocale ?? 'en'}',`];\n if (options.locales?.length) {\n fields.push(` locales: [${options.locales.map((l) => `'${l}'`).join(', ')}],`);\n }\n if (options.dir) fields.push(` dir: '${options.dir}',`);\n const body = `export default {\\n${fields.join('\\n')}\\n}`;\n if (typescript) {\n return `import type { VerbalyConfig } from '@verbaly/compiler';\\n\\n${body} satisfies VerbalyConfig;\\n`;\n }\n return `/** @type {import('@verbaly/compiler').VerbalyConfig} */\\n${body};\\n`;\n}\n\nexport function init(options: InitOptions = {}): InitResult {\n const root = options.root ?? process.cwd();\n const created: string[] = [];\n const skipped: string[] = [];\n\n const existing = findConfigFile(root);\n const typescript = existsSync(join(root, 'tsconfig.json'));\n const configFile = existing ?? (typescript ? 'verbaly.config.ts' : 'verbaly.config.mjs');\n if (existing) {\n skipped.push(existing);\n } else {\n writeFileSync(join(root, configFile), configSource(options, typescript));\n created.push(configFile);\n }\n\n const dir = join(root, options.dir ?? 'locales');\n if (!existsSync(dir)) mkdirSync(dir, { recursive: true });\n for (const locale of new Set([options.sourceLocale ?? 'en', ...(options.locales ?? [])])) {\n const file = join(dir, `${locale}.json`);\n const label = relative(root, file).replaceAll('\\\\', '/');\n if (existsSync(file)) {\n skipped.push(label);\n } else {\n writeFileSync(file, '{}\\n');\n created.push(label);\n }\n }\n\n const host = detectHost(root);\n const next = host\n ? [`pnpm add -D ${host.pkg}`, host.wire]\n : ['run \"verbaly extract\" after writing your first t`…` message'];\n\n return { created, skipped, host: host?.name, configFile, next };\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { flatten, type MessageTree } from 'verbaly';\nimport type { Catalogs } from './catalog';\nimport { check } from './check';\nimport { generateDts } from './codegen';\nimport { findConfigFile, type ResolvedConfig } from './config';\nimport { extractProject } from './extract';\nimport { detectHost, readDependencies, WIRING_PACKAGES } from './init';\n\nexport interface DoctorEntry {\n level: 'ok' | 'warn' | 'error';\n check: string;\n message: string;\n fix?: string;\n}\n\nexport interface DoctorResult {\n ok: boolean; // no error-level entries (warns allowed)\n entries: DoctorEntry[];\n}\n\nconst PREVIEW = 5; // keys shown before \"…\"\n\nexport async function doctor(cfg: ResolvedConfig): Promise<DoctorResult> {\n const entries: DoctorEntry[] = [];\n const ok = (name: string, message: string) => entries.push({ level: 'ok', check: name, message });\n const warn = (name: string, message: string, fix: string) =>\n entries.push({ level: 'warn', check: name, message, fix });\n const error = (name: string, message: string, fix: string) =>\n entries.push({ level: 'error', check: name, message, fix });\n const rel = (path: string) => relative(cfg.root, path).replaceAll('\\\\', '/');\n\n const configFile = findConfigFile(cfg.root);\n if (configFile) ok('config', `${configFile} found`);\n else warn('config', 'no config file, running on defaults', 'run `npx verbaly init`');\n\n const catalogs: Catalogs = {};\n let catalogsHealthy = true;\n if (!existsSync(cfg.dir)) {\n catalogsHealthy = false;\n error(\n 'catalogs',\n `catalogs directory ${rel(cfg.dir)}/ does not exist`,\n 'run `npx verbaly init` to scaffold it',\n );\n } else {\n for (const locale of cfg.locales) {\n const file = join(cfg.dir, `${locale}.json`);\n if (!existsSync(file)) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is missing`,\n 'run `npx verbaly extract` to create it',\n );\n continue;\n }\n try {\n const parsed = JSON.parse(readFileSync(file, 'utf8')) as MessageTree;\n // nested groups are a real shape: the runtime flattens them and so does the gate,\n // so the only broken value is a leaf that is not text\n const bad = badLeaf(parsed);\n if (bad) {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} has a non-string value at \"${bad}\"`,\n 'catalog values are text (groups of text are fine); fix the value',\n );\n } else {\n catalogs[locale] = flatten(parsed);\n }\n } catch {\n catalogsHealthy = false;\n error(\n `locale ${locale}`,\n `${rel(file)} is not valid JSON`,\n 'repair the file (or delete it and run `npx verbaly extract`)',\n );\n }\n }\n if (catalogsHealthy) {\n ok(\n 'catalogs',\n `${cfg.locales.length} locales (${cfg.locales.join(', ')}) in ${rel(cfg.dir)}/`,\n );\n }\n }\n\n const source = catalogs[cfg.sourceLocale];\n if (source && Object.keys(source).length === 0) {\n warn(\n 'source',\n `source catalog ${cfg.sourceLocale}.json is empty`,\n 'write your first t`…` message and run `npx verbaly extract`',\n );\n }\n\n const deps = readDependencies(cfg.root);\n const host = detectHost(cfg.root);\n const installed = WIRING_PACKAGES.find((pkg) => deps[pkg]);\n if (!host) {\n ok('plugin', 'no bundler detected, the CLI flow (extract/check) applies');\n } else if (installed) {\n ok('plugin', `${installed} installed for ${host.name}`);\n } else {\n warn(\n 'plugin',\n `${host.name} detected but ${host.pkg} is not installed`,\n `pnpm add -D ${host.pkg} and ${host.wire}`,\n );\n }\n\n // with source scanning off the compiler reads no code, so it cannot claim a key is\n // unreferenced nor generate types for it: the catalogs are the whole truth there\n const scanning = cfg.include.length > 0;\n if (!scanning) {\n ok('sources', 'source scanning is off (include: []), the catalogs are the source of truth');\n }\n\n if (source && scanning && cfg.dts !== false) {\n const dtsPath = cfg.dts ?? join(cfg.root, 'verbaly.d.ts');\n if (!existsSync(dtsPath)) {\n warn('types', 'verbaly.d.ts has not been generated', 'run `npx verbaly extract`');\n } else if (readFileSync(dtsPath, 'utf8') !== generateDts(source)) {\n warn('types', 'verbaly.d.ts is stale', 'run `npx verbaly extract`');\n } else {\n ok('types', 'verbaly.d.ts is up to date');\n }\n }\n\n const registry = await extractProject(cfg);\n if (source && scanning) {\n const extracted = registry.messages();\n const used = registry.usedKeys();\n const orphans = Object.keys(source).filter((key) => !extracted.has(key) && !used.has(key));\n if (orphans.length > 0) {\n warn(\n 'orphans',\n `${orphans.length} catalog ${orphans.length === 1 ? 'key is' : 'keys are'} no longer referenced (${preview(orphans)})`,\n 'run `npx verbaly extract --prune` to drop them',\n );\n } else {\n ok('orphans', 'no orphan keys');\n }\n }\n\n if (catalogsHealthy) {\n const result = check(cfg, catalogs, registry);\n if (result.unknown.length > 0) {\n error(\n 'keys',\n `${result.unknown.length} unknown ${result.unknown.length === 1 ? 'key' : 'keys'} used in code (${preview(result.unknown.map((u) => u.key))})`,\n 'fix the key or add it to the catalogs (`npx verbaly check` for details)',\n );\n }\n if (result.missing.length > 0) {\n const locales = [...new Set(result.missing.map((m) => m.locale))];\n warn(\n 'translations',\n `${result.missing.length} missing ${result.missing.length === 1 ? 'translation' : 'translations'} (${locales.join(', ')})`,\n 'run `npx verbaly translate` or fill the catalogs (`npx verbaly check` for details)',\n );\n }\n // the gate fails on these, so doctor cannot keep calling the setup healthy\n const broken = result.broken.filter((entry) => entry.severity === 'error');\n if (broken.length > 0) {\n const locales = [...new Set(broken.map((b) => b.locale))];\n error(\n 'translations',\n `${broken.length} broken ${broken.length === 1 ? 'translation' : 'translations'} (${locales.join(', ')}): present but not rendering what the source renders`,\n 'run `npx verbaly check` to read what each one lost',\n );\n }\n const warnings = result.broken.filter((entry) => entry.severity === 'warning');\n if (warnings.length > 0) {\n warn(\n 'translations',\n `${warnings.length} structural ${warnings.length === 1 ? 'warning' : 'warnings'} (plural forms a language asks for)`,\n 'run `npx verbaly check` to read them, they never fail the build',\n );\n }\n if (result.ok) ok('translations', 'all translations complete');\n }\n\n return { ok: entries.every((entry) => entry.level !== 'error'), entries };\n}\n\nfunction preview(keys: string[]): string {\n const head = keys.slice(0, PREVIEW).join(', ');\n return keys.length > PREVIEW ? `${head}, …` : head;\n}\n\n// dotted path of the first value that is neither text nor a group of text\nfunction badLeaf(tree: MessageTree, prefix = ''): string | undefined {\n for (const [key, value] of Object.entries(tree)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'string') continue;\n if (value === null || typeof value !== 'object' || Array.isArray(value)) return path;\n const bad = badLeaf(value as MessageTree, path);\n if (bad) return bad;\n }\n return undefined;\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 only counts while its translation is still present: a pruned or re-emptied\n// key is no longer a \"reviewable\" draft, it is simply missing again\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","// XLIFF 2.0 inline codes: simple {params} export as <ph>, paired rich tags as <pc>,\n// with semantic ids (the param/tag name) so TMS editors protect them as chips instead\n// of exposing raw syntax. disp carries the exact source slice: decoding reconstructs\n// the message verbatim, so the round-trip is lossless. Variant params ({v | one: …})\n// hold translatable text and stay raw on purpose.\n\ntype Part =\n | { kind: 'text'; text: string }\n | { kind: 'ph'; name: string; src: string }\n | { kind: 'pc'; name: string; openSrc: string; closeSrc: string; children: Part[] };\n\nconst OPEN_TAG = /^<([a-zA-Z][a-zA-Z0-9-]*)\\s*(\\/?)>/;\n\nexport function messageToInline(text: string): string {\n const parsed = parseParts(text, 0);\n return renderParts(parsed.parts, new Map());\n}\n\nexport function inlineToMessage(xml: string): string {\n let out = '';\n let text = '';\n let i = 0;\n const flush = () => {\n out += unescapeXml(text);\n text = '';\n };\n while (i < xml.length) {\n if (xml[i] === '<') {\n const slice = xml.slice(i);\n const ph = /^<ph\\b([^>]*?)\\/\\s*>/.exec(slice) ?? /^<ph\\b([^>]*)>\\s*<\\/ph\\s*>/.exec(slice);\n if (ph) {\n flush();\n out += attr(ph[1]!, 'disp') ?? `{${attr(ph[1]!, 'id') ?? 'ph'}}`;\n i += ph[0].length;\n continue;\n }\n const pc = /^<pc\\b([^>]*)>/.exec(slice);\n if (pc) {\n const close = findPcClose(xml, i + pc[0].length);\n if (close) {\n flush();\n const id = attr(pc[1]!, 'id') ?? 'pc';\n out += attr(pc[1]!, 'dispStart') ?? `<${id}>`;\n out += inlineToMessage(xml.slice(i + pc[0].length, close.innerEnd));\n out += attr(pc[1]!, 'dispEnd') ?? `</${id}>`;\n i = close.end;\n continue;\n }\n }\n }\n text += xml[i];\n i += 1;\n }\n flush();\n return out;\n}\n\nexport function escapeXml(text: string): string {\n return text\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;');\n}\n\nexport function unescapeXml(text: string): string {\n return text.replace(/&(lt|gt|amp|quot|apos|#x?[0-9a-fA-F]+);/g, (_, entity: string) => {\n if (entity === 'lt') return '<';\n if (entity === 'gt') return '>';\n if (entity === 'amp') return '&';\n if (entity === 'quot') return '\"';\n if (entity === 'apos') return \"'\";\n const code = entity.startsWith('#x')\n ? parseInt(entity.slice(2), 16)\n : parseInt(entity.slice(1), 10);\n return String.fromCodePoint(code);\n });\n}\n\ninterface ParsedParts {\n parts: Part[];\n end: number;\n closed: boolean;\n}\n\nfunction parseParts(text: string, pos: number, closeTag?: string): ParsedParts {\n const parts: Part[] = [];\n let plain = '';\n const flush = () => {\n if (plain) parts.push({ kind: 'text', text: plain });\n plain = '';\n };\n let i = pos;\n while (i < text.length) {\n const pair = text[i]! + (text[i + 1] ?? '');\n if (pair === '{{' || pair === '}}') {\n plain += pair;\n i += 2;\n continue;\n }\n if (text[i] === '{') {\n const end = matchBrace(text, i);\n if (end === -1) {\n plain += '{';\n i += 1;\n continue;\n }\n const src = text.slice(i, end + 1);\n if (hasTopLevelPipe(src)) {\n plain += src;\n } else {\n flush();\n parts.push({ kind: 'ph', name: paramName(src), src });\n }\n i = end + 1;\n continue;\n }\n if (text[i] === '<') {\n if (closeTag && text.startsWith(`</${closeTag}>`, i)) {\n flush();\n return { parts, end: i + closeTag.length + 3, closed: true };\n }\n const open = OPEN_TAG.exec(text.slice(i));\n if (open) {\n const [openSrc, name, selfClose] = open as unknown as [string, string, string];\n if (selfClose) {\n flush();\n parts.push({ kind: 'ph', name: idSafe(name), src: openSrc });\n i += openSrc.length;\n continue;\n }\n const inner = parseParts(text, i + openSrc.length, name);\n if (inner.closed) {\n flush();\n parts.push({\n kind: 'pc',\n name: idSafe(name),\n openSrc,\n closeSrc: `</${name}>`,\n children: inner.parts,\n });\n i = inner.end;\n continue;\n }\n }\n // no closing tag ahead: keep the '<' as plain text\n plain += '<';\n i += 1;\n continue;\n }\n plain += text[i];\n i += 1;\n }\n flush();\n return { parts, end: i, closed: false };\n}\n\nfunction matchBrace(text: string, start: number): number {\n let depth = 0;\n for (let i = start; i < text.length; i++) {\n const pair = text[i]! + (text[i + 1] ?? '');\n if (pair === '{{' || pair === '}}') {\n i += 1;\n continue;\n }\n if (text[i] === '{') depth += 1;\n else if (text[i] === '}') {\n depth -= 1;\n if (depth === 0) return i;\n }\n }\n return -1;\n}\n\n// a top-level pipe means variants (plural/select): their bodies are translatable\nfunction hasTopLevelPipe(src: string): boolean {\n let depth = 0;\n for (let i = 0; i < src.length; i++) {\n const pair = src[i]! + (src[i + 1] ?? '');\n if (pair === '{{' || pair === '}}' || pair === '||') {\n i += 1;\n continue;\n }\n if (src[i] === '{') depth += 1;\n else if (src[i] === '}') depth -= 1;\n else if (src[i] === '|' && depth === 1) return true;\n }\n return false;\n}\n\nfunction paramName(src: string): string {\n const name = /^\\{\\s*([^{}|:\\s]+)/.exec(src)?.[1];\n return name ? idSafe(name) : 'ph';\n}\n\n// XLIFF ids are NMTOKEN: keep letters, digits, dot, dash, underscore\nfunction idSafe(name: string): string {\n const safe = name.replace(/[^a-zA-Z0-9._-]/g, '_');\n return safe || 'ph';\n}\n\nfunction renderParts(parts: Part[], taken: Map<string, number>): string {\n let out = '';\n for (const part of parts) {\n if (part.kind === 'text') {\n out += escapeXml(part.text);\n } else if (part.kind === 'ph') {\n out += `<ph id=\"${uniqueId(part.name, taken)}\" disp=\"${escapeXml(part.src)}\"/>`;\n } else {\n const id = uniqueId(part.name, taken);\n out += `<pc id=\"${id}\" dispStart=\"${escapeXml(part.openSrc)}\" dispEnd=\"${escapeXml(part.closeSrc)}\">`;\n out += renderParts(part.children, taken);\n out += '</pc>';\n }\n }\n return out;\n}\n\nfunction uniqueId(name: string, taken: Map<string, number>): string {\n const count = taken.get(name) ?? 0;\n taken.set(name, count + 1);\n return count === 0 ? name : `${name}${count + 1}`;\n}\n\nfunction findPcClose(xml: string, from: number): { innerEnd: number; end: number } | undefined {\n const tags = /<pc\\b[^>]*>|<\\/pc\\s*>/g;\n tags.lastIndex = from;\n let depth = 1;\n for (let match = tags.exec(xml); match; match = tags.exec(xml)) {\n depth += match[0].startsWith('</') ? -1 : 1;\n if (depth === 0) return { innerEnd: match.index, end: tags.lastIndex };\n }\n return undefined;\n}\n\nfunction attr(attrs: string, name: string): string | undefined {\n const value = new RegExp(`\\\\b${name}\\\\s*=\\\\s*\"([^\"]*)\"`).exec(attrs)?.[1];\n return value === undefined ? undefined : unescapeXml(value);\n}\n","export interface MobileEntry {\n key: string;\n text: string;\n}\n\n// Android resource qualifier: source = default values/, two-letter region = -r suffix, else BCP-47 b+ syntax\nexport function androidValuesDir(locale: string, sourceLocale: string): string {\n if (locale === sourceLocale) return 'values';\n const parts = locale.split('-');\n if (parts.length === 1) return `values-${locale}`;\n if (parts.length === 2 && /^[a-zA-Z]{2}$/.test(parts[1]!)) {\n return `values-${parts[0]}-r${parts[1]!.toUpperCase()}`;\n }\n return `values-b+${parts.join('+')}`;\n}\n\nexport function toAndroidXml(entries: MobileEntry[]): string {\n const names = new Map<string, string>();\n const lines = entries.map(({ key, text }) => {\n const name = androidName(key);\n const clash = names.get(name);\n if (clash !== undefined) {\n throw new Error(\n `[verbaly] android-xml: keys \"${clash}\" and \"${key}\" both become resource name \"${name}\", rename one of them.`,\n );\n }\n names.set(name, key);\n return ` <string name=\"${name}\">${androidText(text)}</string>`;\n });\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n '<resources>',\n ...lines,\n '</resources>',\n '',\n ].join('\\n');\n}\n\nexport function toIosStrings(entries: MobileEntry[]): string {\n const lines = entries.map(({ key, text }) => `\"${iosText(key)}\" = \"${iosText(text)}\";`);\n return [...lines, ''].join('\\n');\n}\n\n// resource names must be identifiers: every other char collapses to _ (collisions rejected in toAndroidXml)\nfunction androidName(key: string): string {\n const name = key.replace(/[^A-Za-z0-9_]/g, '_');\n return /^[0-9]/.test(name) ? `_${name}` : name;\n}\n\n// aapt unescapes XML first, then Android's own backslash escapes; leading @/? would read as a resource reference\nfunction androidText(text: string): string {\n const escaped = text\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\t/g, '\\\\t')\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n return /^[@?]/.test(escaped) ? `\\\\${escaped}` : escaped;\n}\n\nfunction iosText(text: string): string {\n return text\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\t/g, '\\\\t');\n}\n","// gettext PO: msgctxt carries the catalog key (keys are hashes, msgid is the source\n// text), locations ride as #: comments. Params keep the {name} syntax verbatim, the\n// gettext norm. Entries flagged fuzzy read as untranslated (msgfmt semantics); an\n// empty msgstr means untranslated, matching the catalog's '' convention.\n\nexport interface PoEntry {\n key: string;\n source: string;\n target: string;\n location?: string[];\n}\n\nexport function toPo(sourceLocale: string, locale: string, entries: PoEntry[]): string {\n const header = [\n 'msgid \"\"',\n 'msgstr \"\"',\n `${poString('Project-Id-Version: verbaly\\n')}`,\n `${poString('MIME-Version: 1.0\\n')}`,\n `${poString('Content-Type: text/plain; charset=UTF-8\\n')}`,\n `${poString('Content-Transfer-Encoding: 8bit\\n')}`,\n `${poString(`Language: ${locale}\\n`)}`,\n `${poString(`X-Source-Language: ${sourceLocale}\\n`)}`,\n ].join('\\n');\n const blocks = entries.map(({ key, source, target, location }) =>\n [\n ...(location?.length ? [`#: ${location.join(' ')}`] : []),\n `msgctxt ${poString(key)}`,\n `msgid ${poString(source)}`,\n `msgstr ${poString(target)}`,\n ].join('\\n'),\n );\n return [header, ...blocks, ''].join('\\n\\n');\n}\n\nexport function parsePo(content: string): { locale?: string; entries: Record<string, string> } {\n const entries: Record<string, string> = {};\n let locale: string | undefined;\n\n let msgctxt: string | undefined;\n let msgid: string | undefined;\n let msgstr: string | undefined;\n let fuzzy = false;\n let field: 'msgctxt' | 'msgid' | 'msgstr' | 'other' | undefined;\n\n const finish = () => {\n if (msgid === '' && msgctxt === undefined) {\n const lang = /^Language:[ \\t]*(.+?)[ \\t]*$/m.exec(msgstr ?? '')?.[1];\n if (lang) locale = lang;\n } else if (msgctxt !== undefined && msgid !== undefined) {\n entries[msgctxt] = fuzzy ? '' : (msgstr ?? '');\n }\n msgctxt = msgid = msgstr = field = undefined;\n fuzzy = false;\n };\n\n // Windows editors may prepend a BOM; strip it before the first line parses\n for (const raw of content.replace(/^\\uFEFF/, '').split(/\\r\\n|[\\r\\n]/)) {\n const line = raw.trim();\n if (line === '') {\n finish();\n continue;\n }\n if (line.startsWith('#')) {\n if (/^#,.*\\bfuzzy\\b/.test(line)) fuzzy = true;\n continue;\n }\n const keyword = /^(msgctxt|msgid_plural|msgid|msgstr(?:\\[\\d+\\])?)\\s+(.*)$/.exec(line);\n if (keyword) {\n const [, name, rest] = keyword as unknown as [string, string, string];\n const value = poUnquote(rest);\n if (value === undefined) continue;\n if (name === 'msgctxt') {\n msgctxt = value;\n field = 'msgctxt';\n } else if (name === 'msgid') {\n msgid = value;\n field = 'msgid';\n } else if (name === 'msgstr' || name === 'msgstr[0]') {\n msgstr = value;\n field = 'msgstr';\n } else {\n // msgid_plural / msgstr[n>0]: verbaly plurals live inside one message, discard\n field = 'other';\n }\n continue;\n }\n const continuation = poUnquote(line);\n if (continuation === undefined || field === undefined || field === 'other') continue;\n if (field === 'msgctxt') msgctxt = (msgctxt ?? '') + continuation;\n else if (field === 'msgid') msgid = (msgid ?? '') + continuation;\n else msgstr = (msgstr ?? '') + continuation;\n }\n finish();\n return { locale, entries };\n}\n\nfunction poString(text: string): string {\n const escaped = text\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')\n .replace(/\\t/g, '\\\\t')\n .replace(/\\r/g, '\\\\r');\n return `\"${escaped}\"`;\n}\n\nfunction poUnquote(text: string): string | undefined {\n const match = /^\"((?:[^\"\\\\]|\\\\.)*)\"$/.exec(text);\n if (!match) return undefined;\n return match[1]!.replace(/\\\\(.)/g, (_, ch: string) => {\n if (ch === 'n') return '\\n';\n if (ch === 't') return '\\t';\n if (ch === 'r') return '\\r';\n return ch;\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 function wins; otherwise the claude provider, imported lazily\n// (its SDK peer is optional: only translate should ever pay for it)\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// params, tags and the plural/select blocks must survive translation verbatim.\n// no locale here on purpose: this gate only rejects what renders wrong, and the\n// locale-specific plural advice is check's warning, never a reason to drop a 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, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport type { Catalogs } from './catalog';\nimport { targetLocales, type ResolvedConfig } from './config';\nimport { escapeXml, inlineToMessage, messageToInline, unescapeXml } from './inline';\nimport { androidValuesDir, toAndroidXml, toIosStrings } from './mobile';\nimport { parsePo, toPo } from './po';\nimport { structureMatches } from './translate';\n\nexport type ExchangeFormat = 'xliff' | 'csv' | 'po';\nexport type MobileFormat = 'android-xml' | 'ios-strings';\nexport type ExportFormat = ExchangeFormat | MobileFormat;\n\nexport function isMobileFormat(format: ExportFormat): format is MobileFormat {\n return format === 'android-xml' || format === 'ios-strings';\n}\n\nexport interface ExportOptions {\n locales?: string[];\n format?: ExportFormat;\n out?: string;\n missing?: boolean;\n origins?: Record<string, string[]>;\n}\n\nexport interface ExportedFile {\n locale: string;\n path: string;\n total: number;\n untranslated: number;\n}\n\nexport interface ExportResult {\n format: ExportFormat;\n dir: string;\n files: ExportedFile[];\n}\n\nexport interface ImportOptions {\n locale?: string;\n overwrite?: boolean;\n dryRun?: boolean;\n}\n\nexport interface ImportResult {\n imported: Record<string, string[]>;\n rejected: Record<string, string[]>;\n skipped: Record<string, string[]>;\n unknown: Record<string, string[]>;\n}\n\n// One file per target locale: source text + current translation\nexport function exportCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n options: ExportOptions = {},\n): ExportResult {\n const format = options.format ?? 'xliff';\n const dir = resolve(cfg.root, options.out ?? 'verbaly-export');\n const source = catalogs[cfg.sourceLocale] ?? {};\n const targets = targetLocales(cfg, options.locales);\n if (isMobileFormat(format)) {\n return exportMobile(cfg, catalogs, format, dir, source, targets);\n }\n\n const files: ExportedFile[] = [];\n mkdirSync(dir, { recursive: true });\n for (const locale of targets) {\n const catalog = catalogs[locale] ?? {};\n const all = Object.keys(source)\n .filter((key) => source[key])\n .sort()\n .map((key) => ({\n key,\n source: source[key]!,\n target: catalog[key] ?? '',\n location: options.origins?.[key],\n }));\n const untranslated = all.filter((entry) => !entry.target);\n const entries = options.missing ? untranslated : all;\n\n const ext = format === 'xliff' ? 'xlf' : format;\n const path = join(dir, `${locale}.${ext}`);\n const content =\n format === 'csv'\n ? toCsv(entries)\n : format === 'po'\n ? toPo(cfg.sourceLocale, locale, entries)\n : toXliff(cfg.sourceLocale, locale, entries);\n writeFileSync(path, content);\n files.push({\n locale,\n path,\n total: entries.length,\n untranslated: untranslated.length,\n });\n }\n return { format, dir, files };\n}\n\n// drop-in native resources (res/values-*, *.lproj); the source locale ships as the default,\n// untranslated keys are skipped so the platform falls back to it\nfunction exportMobile(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n format: MobileFormat,\n dir: string,\n source: Record<string, string>,\n targets: string[],\n): ExportResult {\n const keys = Object.keys(source)\n .filter((key) => source[key])\n .sort();\n const files: ExportedFile[] = [];\n for (const locale of [cfg.sourceLocale, ...targets]) {\n const catalog = locale === cfg.sourceLocale ? source : (catalogs[locale] ?? {});\n const entries = keys\n .map((key) => ({ key, text: catalog[key] ?? '' }))\n .filter((entry) => entry.text);\n const relative =\n format === 'android-xml'\n ? join(androidValuesDir(locale, cfg.sourceLocale), 'strings.xml')\n : join(`${locale}.lproj`, 'Localizable.strings');\n const path = join(dir, relative);\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, format === 'android-xml' ? toAndroidXml(entries) : toIosStrings(entries));\n files.push({\n locale,\n path,\n total: entries.length,\n untranslated: keys.length - entries.length,\n });\n }\n return { format, dir, files };\n}\n\n// fills catalogs from translated files\nexport function importCatalogs(\n cfg: ResolvedConfig,\n catalogs: Catalogs,\n files: string[],\n options: ImportOptions = {},\n): ImportResult {\n const source = catalogs[cfg.sourceLocale] ?? {};\n const result: ImportResult = { imported: {}, rejected: {}, skipped: {}, unknown: {} };\n\n for (const file of files) {\n const parsed = parseExchangeFile(file, options.locale);\n const locale = parsed.locale;\n if (!/^[a-zA-Z]{2,3}([-_][a-zA-Z0-9]+)*$/.test(locale)) {\n throw new Error(\n `[verbaly] ${file}: \"${locale}\" doesn't look like a locale, pass --locale <id>.`,\n );\n }\n if (locale === cfg.sourceLocale) {\n throw new Error(\n `[verbaly] ${file} targets the source locale \"${locale}\": import fills translations, not the source. Pass --locale if the detection is wrong.`,\n );\n }\n const catalog = (catalogs[locale] ??= {});\n for (const [key, text] of Object.entries(parsed.entries)) {\n if (!text.trim()) continue;\n if (!source[key]) {\n (result.unknown[locale] ??= []).push(key);\n continue;\n }\n if (catalog[key] && !options.overwrite) {\n (result.skipped[locale] ??= []).push(key);\n continue;\n }\n if (!structureMatches(source[key], text)) {\n (result.rejected[locale] ??= []).push(key);\n continue;\n }\n if (!options.dryRun) catalog[key] = text;\n (result.imported[locale] ??= []).push(key);\n }\n }\n return result;\n}\n\ninterface ExchangeEntry {\n key: string;\n source: string;\n target: string;\n location?: string[];\n}\n\ninterface ParsedFile {\n locale: string;\n entries: Record<string, string>;\n}\n\nexport function parseExchangeFile(file: string, localeOverride?: string): ParsedFile {\n const content = readFileSync(file, 'utf8');\n if (/\\.(xlf|xliff)$/i.test(file)) {\n const parsed = parseXliff(content);\n const locale = localeOverride ?? parsed.locale;\n if (!locale) {\n throw new Error(`[verbaly] ${file} has no trgLang/target-language, pass --locale <id>.`);\n }\n return { locale, entries: parsed.entries };\n }\n if (/\\.csv$/i.test(file)) {\n const locale = localeOverride ?? basename(file).replace(/\\.csv$/i, '');\n return { locale, entries: parseCsv(content) };\n }\n if (/\\.po$/i.test(file)) {\n const parsed = parsePo(content);\n const locale = localeOverride ?? parsed.locale ?? basename(file).replace(/\\.po$/i, '');\n return { locale, entries: parsed.entries };\n }\n throw new Error(`[verbaly] ${file}: unsupported format, expected .xlf, .xliff, .csv or .po.`);\n}\n\n// XLIFF 2.0 (writes) / 2.0 + 1.2 (reads); params/tags travel as <ph>/<pc> inline codes\nfunction toXliff(sourceLocale: string, locale: string, entries: ExchangeEntry[]): string {\n const units = entries\n .map(({ key, source, target, location }) =>\n [\n ` <unit id=\"${escapeXml(key)}\">`,\n ...(location?.length\n ? [\n ' <notes>',\n ...location.map(\n (file) => ` <note category=\"location\">${escapeXml(file)}</note>`,\n ),\n ' </notes>',\n ]\n : []),\n ` <segment state=\"${target ? 'translated' : 'initial'}\">`,\n ` <source>${messageToInline(source)}</source>`,\n ` <target>${messageToInline(target)}</target>`,\n ' </segment>',\n ' </unit>',\n ].join('\\n'),\n )\n .join('\\n');\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n `<xliff xmlns=\"urn:oasis:names:tc:xliff:document:2.0\" version=\"2.0\" srcLang=\"${escapeXml(sourceLocale)}\" trgLang=\"${escapeXml(locale)}\">`,\n ` <file id=\"verbaly\" original=\"${escapeXml(`${locale}.json`)}\">`,\n units,\n ' </file>',\n '</xliff>',\n '',\n ].join('\\n');\n}\n\nfunction parseXliff(content: string): { locale?: string; entries: Record<string, string> } {\n const locale =\n /\\btrgLang\\s*=\\s*\"([^\"]+)\"/.exec(content)?.[1] ??\n /\\btarget-language\\s*=\\s*\"([^\"]+)\"/.exec(content)?.[1];\n const entries: Record<string, string> = {};\n const UNIT = /<(?:trans-)?unit\\b([^>]*)>([\\s\\S]*?)<\\/(?:trans-)?unit>/g;\n for (const match of content.matchAll(UNIT)) {\n const id = /\\bid\\s*=\\s*\"([^\"]*)\"/.exec(match[1]!)?.[1];\n if (!id) continue;\n const target = /<target\\b[^>]*>([\\s\\S]*?)<\\/target>/.exec(match[2]!)?.[1];\n entries[unescapeXml(id)] = target === undefined ? '' : inlineToMessage(stripCdata(target));\n }\n return { locale, entries };\n}\n\nfunction stripCdata(text: string): string {\n return text.replace(/<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>/g, '$1');\n}\n\n// CSV (RFC 4180); import reads columns by header name, so location round-trips inert\nfunction toCsv(entries: ExchangeEntry[]): string {\n const rows = entries.map(\n ({ key, source, target, location }) =>\n `${csvField(key)},${csvField(source)},${csvField(target)},${csvField(location?.join('; ') ?? '')}`,\n );\n return ['key,source,target,location', ...rows, ''].join('\\r\\n');\n}\n\nfunction csvField(text: string): string {\n return /[\",\\r\\n]/.test(text) ? `\"${text.replace(/\"/g, '\"\"')}\"` : text;\n}\n\nfunction parseCsv(content: string): Record<string, string> {\n const rows = csvRows(content);\n const header = rows[0]?.map((cell) => cell.trim().toLowerCase()) ?? [];\n const keyCol = header.indexOf('key');\n const targetCol = header.indexOf('target');\n if (keyCol === -1 || targetCol === -1) {\n throw new Error('[verbaly] CSV needs a header row with \"key\" and \"target\" columns.');\n }\n const entries: Record<string, string> = {};\n for (const row of rows.slice(1)) {\n const key = row[keyCol];\n if (key) entries[key] = row[targetCol] ?? '';\n }\n return entries;\n}\n\nfunction csvRows(content: string): string[][] {\n const rows: string[][] = [];\n let row: string[] = [];\n let field = '';\n let quoted = false;\n for (let i = 0; i < content.length; i++) {\n const char = content[i]!;\n if (quoted) {\n if (char === '\"') {\n if (content[i + 1] === '\"') {\n field += '\"';\n i++;\n } else {\n quoted = false;\n }\n } else {\n field += char;\n }\n } else if (char === '\"') {\n quoted = true;\n } else if (char === ',') {\n row.push(field);\n field = '';\n } else if (char === '\\n' || char === '\\r') {\n if (char === '\\r' && content[i + 1] === '\\n') i++;\n row.push(field);\n field = '';\n if (row.some((cell) => cell !== '')) rows.push(row);\n row = [];\n } else {\n field += char;\n }\n }\n row.push(field);\n if (row.some((cell) => cell !== '')) rows.push(row);\n return rows;\n}\n","import { isModuleNotFound } from '../config';\nimport type { TranslateProvider, TranslateRequest } from '../translate';\n\nexport interface ClaudeProviderOptions {\n model?: string;\n apiKey?: string;\n maxTokens?: number;\n}\n\n// balanced default for translation\nconst DEFAULT_MODEL = 'claude-sonnet-5';\n\nconst SYSTEM = `You translate UI strings for the Verbaly i18n library.\nRules:\n- Translate only the human-readable text, naturally for the target locale.\n- Preserve verbatim: placeholders like {name}, format specs like {price:currency/EUR}, variant blocks like {count | one: ... | other: # ...} (translate only the text inside each variant, keep keys and # as-is), ICU syntax, named tags like <em>...</em> and escapes {{ }} || ##.\n- Keys are opaque identifiers: return exactly the same keys, never translate or rename them.`;\n\nexport function claudeProvider(options: ClaudeProviderOptions = {}): TranslateProvider {\n return async (request: TranslateRequest) => {\n const Anthropic = await loadSdk();\n const client = new Anthropic(options.apiKey ? { apiKey: options.apiKey } : {});\n const response = await client.messages.create({\n model: options.model ?? DEFAULT_MODEL,\n max_tokens: options.maxTokens ?? 16000,\n thinking: { type: 'disabled' },\n system: SYSTEM,\n messages: [{ role: 'user', content: buildPrompt(request) }],\n output_config: { format: batchFormat(request) },\n });\n const text = response.content.find((block) => block.type === 'text')?.text ?? '{}';\n return JSON.parse(text) as Record<string, string>;\n };\n}\n\nexport function buildPrompt(request: TranslateRequest): string {\n const origins = request.origins;\n const context =\n origins && Object.keys(origins).length\n ? `\\n\\nWhere each string appears (context for tone and length, do not translate these paths):\\n` +\n Object.entries(origins)\n .map(([key, files]) => ` ${key}: ${files.join(', ')}`)\n .join('\\n')\n : '';\n return (\n `Translate each value from \"${request.sourceLocale}\" to \"${request.targetLocale}\". ` +\n `Return a JSON object with the same keys and translated values.\\n\\n` +\n JSON.stringify(request.messages, null, 2) +\n context\n );\n}\n\nexport function batchFormat(request: TranslateRequest) {\n const keys = Object.keys(request.messages);\n return {\n type: 'json_schema' as const,\n schema: {\n type: 'object',\n properties: Object.fromEntries(keys.map((key) => [key, { type: 'string' }])),\n required: keys,\n additionalProperties: false,\n },\n };\n}\n\ntype SdkModule = { default: typeof import('@anthropic-ai/sdk').default };\n\n// injectable for tests\nexport async function loadSdk(\n load: () => Promise<SdkModule> = () => import('@anthropic-ai/sdk'),\n): Promise<SdkModule['default']> {\n try {\n const mod = await load();\n return mod.default;\n } catch (error) {\n if (isModuleNotFound(error, '@anthropic-ai/sdk')) {\n throw new Error(\n '[verbaly] the claude translate provider needs @anthropic-ai/sdk: install it as a dev dependency (e.g. `pnpm add -D @anthropic-ai/sdk` / `npm i -D @anthropic-ai/sdk`) and set ANTHROPIC_API_KEY',\n { cause: error },\n );\n }\n throw error;\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 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\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}\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_TAGS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\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 // 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)) 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 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_TAGS.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 }\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// 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 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 });\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 += `<${node.name}>${richToHtml(node.children, allowed, links)}</${node.name}>`;\n } else {\n out += richToHtml(node.children, allowed, links); // unknown tag → unwrap\n }\n }\n return out;\n}\n\nfunction escapeHtml(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n}\n\nfunction escapeAttr(text: string): string {\n return escapeHtml(text).replace(/\"/g, '&quot;');\n}\n\nfunction decodeEntities(text: string): string {\n return text\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&lt;/g, '<')\n .replace(/&gt;/g, '>')\n .replace(/&amp;/g, '&');\n}\n","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, like check: it is the shape t() sees, and counting a nested catalog by\n // its top-level namespaces reported 100% while its leaves were still untranslated\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 { watch } from 'node:fs';\nimport { relative } from 'node:path';\nimport type { ResolvedConfig } from './config';\nimport { SOURCE_FILE_RE } from './plugin';\n\nexport interface WatchProjectOptions {\n debounce?: number;\n}\n\n// source files only: extract's own catalog/dts writes must never retrigger a run\nexport function watchProject(\n cfg: ResolvedConfig,\n run: () => Promise<void>,\n options: WatchProjectOptions = {},\n): () => void {\n const catalogDir = relative(cfg.root, cfg.dir).replaceAll('\\\\', '/');\n let timer: ReturnType<typeof setTimeout> | undefined;\n let running = false;\n let queued = false;\n\n async function refresh(): Promise<void> {\n if (running) {\n queued = true;\n return;\n }\n running = true;\n try {\n await run();\n } catch (error) {\n console.warn('[verbaly] watch run failed:', error);\n } finally {\n running = false;\n if (queued) {\n queued = false;\n schedule();\n }\n }\n }\n\n function schedule(): void {\n clearTimeout(timer);\n timer = setTimeout(() => void refresh(), options.debounce ?? 150);\n }\n\n const watcher = watch(cfg.root, { recursive: true }, (_event, filename) => {\n if (!filename) return;\n const file = filename.replaceAll('\\\\', '/');\n if (file.includes('node_modules/') || file.endsWith('.d.ts')) return;\n if (catalogDir && file.startsWith(`${catalogDir}/`)) return;\n if (SOURCE_FILE_RE.test(file)) schedule();\n });\n\n return (): void => {\n clearTimeout(timer);\n watcher.close();\n };\n}\n","import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative } from 'node:path';\nimport { parse } from '@babel/parser';\nimport MagicString from 'magic-string';\nimport { glob } from 'tinyglobby';\nimport { cleanJsxText, isTReference, walk, type AstNode } from './analyze';\nimport type { ResolvedConfig } from './config';\n\nexport interface WrapEntry {\n file: string;\n line: number;\n text: string;\n kind: 'text' | 'attribute';\n attribute?: string;\n}\n\nexport interface WrapSkip {\n file: string;\n line: number;\n text: string;\n reason: string;\n}\n\nexport interface WrapResult {\n files: number;\n changed: string[];\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport interface WrapOptions {\n write?: boolean;\n}\n\n// user-visible string attributes worth translating; everything else stays code\nconst WRAP_ATTRS = new Set(['title', 'alt', 'placeholder', 'aria-label']);\n\nconst T_NAMES: ReadonlySet<string> = new Set(['t']);\nconst LETTER = /\\p{L}/u;\n\n// onboarding codemod: finds hardcoded JSX text and wraps it in t`…`.\n// Errs on skipping, never on inventing: anything ambiguous lands in the report instead.\nexport async function wrapProject(\n cfg: ResolvedConfig,\n options: WrapOptions = {},\n): Promise<WrapResult> {\n const files = (\n await glob(cfg.include, { cwd: cfg.root, ignore: cfg.exclude, absolute: true })\n ).filter((file) => /\\.[jt]sx$/.test(file));\n\n const result: WrapResult = { files: files.length, changed: [], wrapped: [], skipped: [] };\n\n for (const file of files) {\n const code = readFileSync(file, 'utf8');\n const label = relative(cfg.root, file).replaceAll('\\\\', '/');\n const out = wrapCode(code, label);\n result.wrapped.push(...out.wrapped);\n result.skipped.push(...out.skipped);\n if (out.code !== undefined) {\n result.changed.push(label);\n if (options.write) writeFileSync(file, out.code);\n }\n }\n return result;\n}\n\nexport interface WrapCodeResult {\n code?: string;\n wrapped: WrapEntry[];\n skipped: WrapSkip[];\n}\n\nexport function wrapCode(code: string, file: string): WrapCodeResult {\n const wrapped: WrapEntry[] = [];\n const skipped: WrapSkip[] = [];\n\n let ast: AstNode;\n try {\n ast = parse(code, {\n sourceType: 'module',\n errorRecovery: true,\n plugins: ['typescript', 'jsx'],\n }).program as unknown as AstNode;\n } catch {\n return { wrapped, skipped }; // unparseable file: leave it alone\n }\n\n const s = new MagicString(code);\n const visited = new Set<AstNode>();\n let changed = false;\n\n walk(ast, (node) => {\n if (node.type !== 'JSXElement' && node.type !== 'JSXFragment') return;\n if (visited.has(node)) return;\n processElement(node);\n });\n\n return changed ? { code: s.toString(), wrapped, skipped } : { wrapped, skipped };\n\n function processElement(node: AstNode): void {\n visited.add(node);\n\n if (node.type === 'JSXElement') {\n const opening = node.openingElement as AstNode;\n const name = opening.name as AstNode;\n // <Trans> children and data-verbaly subtrees are already message-managed\n if (name.type === 'JSXIdentifier' && name.name === 'Trans') return markSubtree(node);\n if (hasVerbalyAttr(opening)) return markSubtree(node);\n wrapAttributes(opening);\n }\n\n const children = (node.children as AstNode[] | undefined) ?? [];\n const hasElementChild = children.some(\n (c) => c.type === 'JSXElement' || c.type === 'JSXFragment',\n );\n const hasText = children.some(\n (c) =>\n (c.type === 'JSXText' && LETTER.test(c.value as string)) ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type === 'StringLiteral' &&\n LETTER.test((c.expression as AstNode).value as string)),\n );\n\n if (hasElementChild && hasText) {\n // splitting the sentence into fragments would ship broken translations\n skip(node, snippet(children), 'mixed text and markup: wrap by hand or use <Trans>');\n return markSubtree(node);\n }\n if (hasText) {\n wrapSegment(node, children);\n return markSubtree(node);\n }\n for (const child of children) {\n if (child.type === 'JSXElement' || child.type === 'JSXFragment') processElement(child);\n }\n }\n\n function wrapSegment(parent: AstNode, children: AstNode[]): void {\n const meaningful = children.filter(\n (c) =>\n (c.type === 'JSXText' && (c.value as string).trim() !== '') ||\n (c.type === 'JSXExpressionContainer' &&\n (c.expression as AstNode).type !== 'JSXEmptyExpression'),\n );\n if (meaningful.length === 0) return;\n\n const first = meaningful[0]!;\n const last = meaningful[meaningful.length - 1]!;\n\n let template = '';\n let report = '';\n for (let i = children.indexOf(first); i <= children.indexOf(last); i++) {\n const child = children[i]!;\n if (child.type === 'JSXText') {\n let value = cleanJsxText(child.value as string);\n if (child === first) value = value.trimStart();\n if (child === last) value = value.trimEnd();\n template += escapeTemplate(value);\n report += value;\n } else if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression as AstNode;\n if (expr.type === 'JSXEmptyExpression') continue;\n if (usesT(expr)) {\n skip(parent, snippet(children), 'already uses t: finish it by hand');\n return;\n }\n if (containsJsx(expr)) {\n skip(\n parent,\n snippet(children),\n 'an expression renders markup: wrap by hand or use <Trans>',\n );\n markSubtree(child);\n return;\n }\n if (expr.type === 'StringLiteral') {\n template += escapeTemplate(expr.value as string);\n report += expr.value as string;\n } else {\n const source = code.slice(expr.start, expr.end);\n template += '${' + source + '}';\n report += '${' + source + '}';\n }\n } else {\n return; // spread children and friends: bail quietly\n }\n }\n if (!LETTER.test(report)) return;\n\n const start =\n first.type === 'JSXText' ? first.start + leadingWs(first.value as string) : first.start;\n const end = last.type === 'JSXText' ? last.end - trailingWs(last.value as string) : last.end;\n\n s.overwrite(start, end, '{t`' + template + '`}');\n changed = true;\n wrapped.push({ file, line: line(first), text: report, kind: 'text' });\n }\n\n function wrapAttributes(opening: AstNode): void {\n for (const attr of opening.attributes as AstNode[]) {\n if (attr.type !== 'JSXAttribute') continue;\n const name = attr.name as AstNode;\n if (name.type !== 'JSXIdentifier' || !WRAP_ATTRS.has(name.name as string)) continue;\n const value = attr.value as AstNode | null;\n if (value?.type !== 'StringLiteral') continue;\n const raw = value.value as string;\n if (!LETTER.test(raw)) continue;\n s.overwrite(value.start, value.end, '{t`' + escapeTemplate(raw) + '`}');\n changed = true;\n wrapped.push({\n file,\n line: line(value),\n text: raw,\n kind: 'attribute',\n attribute: name.name as string,\n });\n }\n }\n\n function skip(node: AstNode, text: string, reason: string): void {\n skipped.push({ file, line: line(node), text, reason });\n }\n\n function snippet(children: AstNode[]): string {\n const start = children[0]?.start ?? 0;\n const end = children[children.length - 1]?.end ?? start;\n const text = code.slice(start, end).replace(/\\s+/g, ' ').trim();\n return text.length > 60 ? text.slice(0, 59) + '…' : text;\n }\n\n function markSubtree(node: AstNode): void {\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') visited.add(n);\n });\n }\n}\n\nfunction hasVerbalyAttr(opening: AstNode): boolean {\n return (opening.attributes as AstNode[]).some((attr) => {\n if (attr.type !== 'JSXAttribute') return false;\n const name = attr.name as AstNode;\n return name.type === 'JSXIdentifier' && (name.name as string).startsWith('data-verbaly');\n });\n}\n\n// a t`…` / t(...) / t.id anywhere in the expression means a human already started here\nfunction usesT(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'TaggedTemplateExpression' && isTReference(n.tag as AstNode, T_NAMES)) {\n found = true;\n }\n if (n.type === 'CallExpression' && isTReference(n.callee as AstNode, T_NAMES)) found = true;\n });\n return found;\n}\n\nfunction containsJsx(node: AstNode): boolean {\n let found = false;\n walk(node, (n) => {\n if (n.type === 'JSXElement' || n.type === 'JSXFragment') found = true;\n });\n return found;\n}\n\n// literal text run → template-literal-safe\nfunction escapeTemplate(text: string): string {\n return text.replace(/[\\\\`]/g, '\\\\$&').replace(/\\$\\{/g, '\\\\${');\n}\n\nfunction leadingWs(text: string): number {\n return text.length - text.trimStart().length;\n}\n\nfunction trailingWs(text: string): number {\n return text.length - text.trimEnd().length;\n}\n\nfunction line(node: AstNode): number {\n const loc = node.loc as { start?: { line?: number } } | undefined;\n return loc?.start?.line ?? 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAgB,UAAU,SAAyB;CACjD,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC;AAC5E;;;ACyCA,MAAM,4BAAY,IAAI,IAAI;CAAC;CAAO;CAAmB;CAAoB;CAAiB;AAAO,CAAC;AAMlG,MAAM,kBAAqC,CAAC,GAAG;AAE/C,SAAgB,QAAQ,MAAc,MAAc,UAA0B,CAAC,GAAa;CAC1F,MAAM,QAAQ,IAAI,IAAI,QAAQ,UAAU,eAAe;CAEvD,MAAM,MAAM,MAAM,MAAM;EACtB,YAAY;EACZ,eAAe;EACf,SAJU,YAAY,K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