@fluenti/cli 0.6.1 → 0.6.2

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.
Files changed (87) hide show
  1. package/dist/cli/src/ai-provider.d.ts +0 -1
  2. package/dist/cli/src/catalog.d.ts +0 -1
  3. package/dist/cli/src/check.d.ts +0 -1
  4. package/dist/cli/src/cli.d.ts +0 -1
  5. package/dist/cli/src/codemod.d.ts +0 -1
  6. package/dist/cli/src/compile-cache.d.ts +0 -1
  7. package/dist/cli/src/compile-runner.d.ts +0 -1
  8. package/dist/cli/src/compile-worker.d.ts +0 -1
  9. package/dist/cli/src/compile.d.ts +0 -1
  10. package/dist/cli/src/config-loader.d.ts +0 -1
  11. package/dist/cli/src/config.d.ts +0 -1
  12. package/dist/cli/src/doctor.d.ts +0 -1
  13. package/dist/cli/src/extract-cache.d.ts +0 -1
  14. package/dist/cli/src/extract-runner.d.ts +0 -1
  15. package/dist/cli/src/glossary.d.ts +0 -1
  16. package/dist/cli/src/index.d.ts +0 -1
  17. package/dist/cli/src/init.d.ts +0 -1
  18. package/dist/cli/src/json-format.d.ts +0 -1
  19. package/dist/cli/src/lint.d.ts +0 -1
  20. package/dist/cli/src/migrate.d.ts +0 -1
  21. package/dist/cli/src/parallel-compile.d.ts +0 -1
  22. package/dist/cli/src/po-format.d.ts +0 -1
  23. package/dist/cli/src/stats-format.d.ts +0 -1
  24. package/dist/cli/src/translate-parse.d.ts +0 -1
  25. package/dist/cli/src/translate-prompt.d.ts +0 -1
  26. package/dist/cli/src/translate.d.ts +0 -1
  27. package/dist/cli/src/tsx-extractor.d.ts +0 -1
  28. package/dist/cli/src/validation.d.ts +0 -1
  29. package/dist/cli/src/vue-extractor.d.ts +0 -1
  30. package/dist/cli.cjs +1 -2
  31. package/dist/cli.js +0 -2
  32. package/dist/compile-C3VLvhUf.cjs +1 -2
  33. package/dist/compile-CZVpE5Md.js +0 -2
  34. package/dist/compile-worker.cjs +1 -2
  35. package/dist/compile-worker.js +0 -2
  36. package/dist/doctor-BqXXxyST.js +0 -2
  37. package/dist/doctor-xp8WS8sr.cjs +1 -2
  38. package/dist/index.cjs +1 -2
  39. package/dist/index.js +28 -13
  40. package/dist/tsx-extractor-AOjsbOmp.cjs +1 -2
  41. package/dist/tsx-extractor-C-HZNobu.js +0 -2
  42. package/dist/vue-extractor.cjs +1 -2
  43. package/dist/vue-extractor.js +0 -2
  44. package/package.json +2 -2
  45. package/dist/cli/src/ai-provider.d.ts.map +0 -1
  46. package/dist/cli/src/catalog.d.ts.map +0 -1
  47. package/dist/cli/src/check.d.ts.map +0 -1
  48. package/dist/cli/src/cli.d.ts.map +0 -1
  49. package/dist/cli/src/codemod.d.ts.map +0 -1
  50. package/dist/cli/src/compile-cache.d.ts.map +0 -1
  51. package/dist/cli/src/compile-runner.d.ts.map +0 -1
  52. package/dist/cli/src/compile-worker.d.ts.map +0 -1
  53. package/dist/cli/src/compile.d.ts.map +0 -1
  54. package/dist/cli/src/config-loader.d.ts.map +0 -1
  55. package/dist/cli/src/config.d.ts.map +0 -1
  56. package/dist/cli/src/doctor.d.ts.map +0 -1
  57. package/dist/cli/src/extract-cache.d.ts.map +0 -1
  58. package/dist/cli/src/extract-runner.d.ts.map +0 -1
  59. package/dist/cli/src/glossary.d.ts.map +0 -1
  60. package/dist/cli/src/index.d.ts.map +0 -1
  61. package/dist/cli/src/init.d.ts.map +0 -1
  62. package/dist/cli/src/json-format.d.ts.map +0 -1
  63. package/dist/cli/src/lint.d.ts.map +0 -1
  64. package/dist/cli/src/migrate.d.ts.map +0 -1
  65. package/dist/cli/src/parallel-compile.d.ts.map +0 -1
  66. package/dist/cli/src/po-format.d.ts.map +0 -1
  67. package/dist/cli/src/stats-format.d.ts.map +0 -1
  68. package/dist/cli/src/translate-parse.d.ts.map +0 -1
  69. package/dist/cli/src/translate-prompt.d.ts.map +0 -1
  70. package/dist/cli/src/translate.d.ts.map +0 -1
  71. package/dist/cli/src/tsx-extractor.d.ts.map +0 -1
  72. package/dist/cli/src/validation.d.ts.map +0 -1
  73. package/dist/cli/src/vue-extractor.d.ts.map +0 -1
  74. package/dist/cli.cjs.map +0 -1
  75. package/dist/cli.js.map +0 -1
  76. package/dist/compile-C3VLvhUf.cjs.map +0 -1
  77. package/dist/compile-CZVpE5Md.js.map +0 -1
  78. package/dist/compile-worker.cjs.map +0 -1
  79. package/dist/compile-worker.js.map +0 -1
  80. package/dist/doctor-BqXXxyST.js.map +0 -1
  81. package/dist/doctor-xp8WS8sr.cjs.map +0 -1
  82. package/dist/index.cjs.map +0 -1
  83. package/dist/index.js.map +0 -1
  84. package/dist/tsx-extractor-AOjsbOmp.cjs.map +0 -1
  85. package/dist/tsx-extractor-C-HZNobu.js.map +0 -1
  86. package/dist/vue-extractor.cjs.map +0 -1
  87. package/dist/vue-extractor.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"doctor-xp8WS8sr.cjs","names":[],"sources":["../src/catalog.ts","../src/json-format.ts","../src/po-format.ts","../src/parallel-compile.ts","../src/extract-cache.ts","../src/codemod.ts","../src/init.ts","../src/doctor.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core/compiler'\n\nexport interface CatalogEntry {\n message?: string | undefined\n context?: string | undefined\n comment?: string | undefined\n translation?: string | undefined\n origin?: string | string[] | undefined\n obsolete?: boolean | undefined\n fuzzy?: boolean | undefined\n}\n\nexport type CatalogData = Record<string, CatalogEntry>\n\nexport interface UpdateResult {\n added: number\n unchanged: number\n obsolete: number\n}\n\nexport interface UpdateCatalogOptions {\n stripFuzzy?: boolean\n}\n\n/** Update catalog with newly extracted messages */\nexport function updateCatalog(\n existing: CatalogData,\n extracted: ExtractedMessage[],\n options?: UpdateCatalogOptions,\n): { catalog: CatalogData; result: UpdateResult } {\n const extractedIds = new Set(extracted.map((m) => m.id))\n const consumedCarryForwardIds = new Set<string>()\n const catalog: CatalogData = {}\n let added = 0\n let unchanged = 0\n let obsolete = 0\n\n for (const msg of extracted) {\n const existingEntry = existing[msg.id]\n const carried = existingEntry\n ? undefined\n : findCarryForwardEntry(existing, msg, consumedCarryForwardIds)\n const origin = `${msg.origin.file}:${msg.origin.line}`\n const baseEntry = existingEntry ?? carried?.entry\n\n if (carried) {\n consumedCarryForwardIds.add(carried.id)\n }\n\n if (baseEntry) {\n catalog[msg.id] = {\n ...baseEntry,\n message: msg.message ?? baseEntry.message,\n context: msg.context,\n comment: msg.comment,\n origin,\n obsolete: false,\n }\n unchanged++\n } else if (catalog[msg.id]) {\n // Same ID already seen in this extraction batch — merge origin\n const existing = catalog[msg.id]!\n catalog[msg.id] = {\n ...existing,\n origin: mergeOrigins(existing.origin, origin),\n }\n } else {\n catalog[msg.id] = {\n message: msg.message,\n context: msg.context,\n comment: msg.comment,\n origin,\n }\n added++\n }\n\n if (options?.stripFuzzy) {\n const { fuzzy: _fuzzy, ...rest } = catalog[msg.id]!\n catalog[msg.id] = rest\n }\n }\n\n for (const [id, entry] of Object.entries(existing)) {\n if (!extractedIds.has(id)) {\n const { fuzzy: _fuzzy, ...rest } = entry\n const obsoleteEntry = options?.stripFuzzy\n ? { ...rest, obsolete: true }\n : { ...entry, obsolete: true }\n catalog[id] = obsoleteEntry\n obsolete++\n }\n }\n\n return { catalog, result: { added, unchanged, obsolete } }\n}\n\nfunction mergeOrigins(\n existing: string | string[] | undefined,\n newOrigin: string,\n): string | string[] {\n if (!existing) return newOrigin\n const existingArray = Array.isArray(existing) ? existing : [existing]\n const merged = [...new Set([...existingArray, newOrigin])]\n return merged.length === 1 ? merged[0]! : merged\n}\n\nfunction findCarryForwardEntry(\n existing: CatalogData,\n extracted: ExtractedMessage,\n consumedCarryForwardIds: Set<string>,\n): { id: string; entry: CatalogEntry } | undefined {\n if (!extracted.context) {\n return undefined\n }\n\n const extractedOrigin = `${extracted.origin.file}:${extracted.origin.line}`\n for (const [id, entry] of Object.entries(existing)) {\n if (consumedCarryForwardIds.has(id)) continue\n if (entry.context !== undefined) continue\n if (entry.message !== extracted.message) continue\n if (!sameOrigin(entry.origin, extractedOrigin)) continue\n return { id, entry }\n }\n\n return undefined\n}\n\nfunction sameOrigin(previous: string | string[] | undefined, next: string): boolean {\n if (!previous) return false\n const origins = Array.isArray(previous) ? previous : [previous]\n return origins.some((o) => o === next || originFile(o) === originFile(next))\n}\n\nfunction originFile(origin: string): string {\n const match = origin.match(/^(.*):\\d+$/)\n return match?.[1] ?? origin\n}\n","import type { CatalogData } from './catalog'\n\n/** Read a JSON catalog file */\nexport function readJsonCatalog(content: string): CatalogData {\n const raw = JSON.parse(content) as Record<string, unknown>\n const catalog: CatalogData = {}\n\n for (const [id, entry] of Object.entries(raw)) {\n if (typeof entry === 'object' && entry !== null) {\n const e = entry as Record<string, unknown>\n catalog[id] = {\n message: typeof e['message'] === 'string' ? e['message'] : undefined,\n context: typeof e['context'] === 'string' ? e['context'] : undefined,\n comment: typeof e['comment'] === 'string' ? e['comment'] : undefined,\n translation: typeof e['translation'] === 'string' ? e['translation'] : undefined,\n origin: typeof e['origin'] === 'string'\n ? e['origin']\n : Array.isArray(e['origin']) && (e['origin'] as unknown[]).every((v) => typeof v === 'string')\n ? (e['origin'] as string[])\n : undefined,\n obsolete: typeof e['obsolete'] === 'boolean' ? e['obsolete'] : undefined,\n fuzzy: typeof e['fuzzy'] === 'boolean' ? e['fuzzy'] : undefined,\n }\n }\n }\n\n return catalog\n}\n\n/** Write a catalog to JSON format */\nexport function writeJsonCatalog(catalog: CatalogData): string {\n const output: Record<string, Record<string, unknown>> = {}\n\n for (const [id, entry] of Object.entries(catalog)) {\n const obj: Record<string, unknown> = {}\n if (entry.message !== undefined) obj['message'] = entry.message\n if (entry.context !== undefined) obj['context'] = entry.context\n if (entry.comment !== undefined) obj['comment'] = entry.comment\n if (entry.translation !== undefined) obj['translation'] = entry.translation\n if (entry.origin !== undefined) obj['origin'] = entry.origin\n if (entry.obsolete) obj['obsolete'] = true\n if (entry.fuzzy) obj['fuzzy'] = true\n output[id] = obj\n }\n\n return JSON.stringify(output, null, 2) + '\\n'\n}\n","import type { CatalogData } from './catalog'\nimport { hashMessage } from '@fluenti/core/compiler'\nimport * as gettextParser from 'gettext-parser'\n\nconst CUSTOM_ID_MARKER = 'fluenti-id:'\n\ninterface POTranslation {\n msgid: string\n msgctxt?: string\n msgstr: string[]\n comments?: {\n reference?: string\n extracted?: string\n flag?: string\n translator?: string\n previous?: string\n }\n}\n\ninterface POData {\n headers?: Record<string, string>\n translations: Record<string, Record<string, POTranslation>>\n obsolete?: Record<string, Record<string, POTranslation>>\n}\n\ninterface ParsedExtractedComment {\n comment?: string\n customId?: string\n sourceMessage?: string\n}\n\nfunction processPoEntries(\n contextMap: Record<string, Record<string, POTranslation>>,\n catalog: CatalogData,\n isObsolete: boolean,\n): void {\n for (const [contextKey, entries] of Object.entries(contextMap)) {\n for (const [msgid, entry] of Object.entries(entries)) {\n if (!msgid) continue\n\n const context = contextKey || entry.msgctxt || undefined\n const translation = entry.msgstr?.[0] ?? undefined\n const rawReference = entry.comments?.reference ?? undefined\n const origin = rawReference?.includes('\\n')\n ? rawReference.split('\\n').map((r: string) => r.trim()).filter(Boolean)\n : rawReference?.includes(' ')\n ? rawReference.split(/\\s+/).filter(Boolean)\n : rawReference\n const normalizedOrigin = Array.isArray(origin) && origin.length === 1 ? origin[0] : origin\n const isFuzzy = !isObsolete && (entry.comments?.flag?.includes('fuzzy') ?? false)\n const { comment, customId, sourceMessage } = parseExtractedComment(entry.comments?.extracted)\n // When a custom ID is present, the msgid may be the custom key (not source text),\n // so accept sourceMessage directly without requiring a hash match.\n // For hash-ID entries (no customId), verify the hash to prevent double-hashing.\n const resolvedSourceMessage = sourceMessage\n && (customId !== undefined || hashMessage(sourceMessage, context) === msgid)\n ? sourceMessage\n : undefined\n const id = customId\n ?? (resolvedSourceMessage ? msgid : hashMessage(msgid, context))\n\n catalog[id] = {\n message: resolvedSourceMessage ?? msgid,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n ...(translation ? { translation } : {}),\n ...(normalizedOrigin !== undefined ? { origin: normalizedOrigin } : {}),\n ...(isFuzzy ? { fuzzy: true } : {}),\n ...(isObsolete ? { obsolete: true } : {}),\n }\n }\n }\n}\n\n/** Read a PO catalog file */\nexport function readPoCatalog(content: string): CatalogData {\n const po = gettextParser.po.parse(content) as POData\n const catalog: CatalogData = {}\n\n processPoEntries(po.translations ?? {}, catalog, false)\n if (po.obsolete) {\n processPoEntries(po.obsolete, catalog, true)\n }\n\n return catalog\n}\n\n/** Write a catalog to PO format */\nexport function writePoCatalog(catalog: CatalogData): string {\n const translations: POData['translations'] = {\n '': {\n '': {\n msgid: '',\n msgstr: ['Content-Type: text/plain; charset=UTF-8\\n'],\n },\n },\n }\n const obsolete: POData['obsolete'] = {}\n\n for (const [id, entry] of Object.entries(catalog)) {\n // Use custom ID as msgid for non-hash entries to prevent collision when two\n // entries share the same source message but have different custom IDs.\n // Hash-ID entries keep source message as msgid (PO-friendly for translators).\n const isHashId = entry.message !== undefined && hashMessage(entry.message, entry.context) === id\n const msgid = isHashId ? (entry.message ?? id) : id\n const poEntry: POTranslation = {\n msgid,\n ...(entry.context !== undefined ? { msgctxt: entry.context } : {}),\n msgstr: [entry.translation ?? ''],\n }\n\n const comments: POTranslation['comments'] = {}\n if (entry.origin && !entry.obsolete) {\n comments.reference = Array.isArray(entry.origin)\n ? entry.origin.join('\\n')\n : entry.origin\n }\n const extractedComment = buildExtractedComment(id, entry.message ?? id, entry.context, entry.comment)\n if (extractedComment) {\n comments.extracted = extractedComment\n }\n if (entry.fuzzy && !entry.obsolete) {\n comments.flag = 'fuzzy'\n }\n if (comments.reference || comments.extracted || comments.flag) {\n poEntry.comments = comments\n }\n\n if (entry.obsolete) {\n const contextKey = entry.context ?? ''\n obsolete[contextKey] ??= {}\n obsolete[contextKey]![poEntry.msgid] = poEntry\n } else {\n const contextKey = entry.context ?? ''\n translations[contextKey] ??= {}\n translations[contextKey]![poEntry.msgid] = poEntry\n }\n }\n\n const poData: POData = {\n headers: {\n 'Content-Type': 'text/plain; charset=UTF-8',\n },\n translations,\n ...(Object.keys(obsolete).length > 0 ? { obsolete } : {}),\n }\n\n const buffer = gettextParser.po.compile(poData as Parameters<typeof gettextParser.po.compile>[0])\n return buffer.toString()\n}\n\nfunction parseExtractedComment(\n extracted: string | undefined,\n): ParsedExtractedComment {\n if (!extracted) {\n return {}\n }\n\n const lines = extracted.split('\\n').map((line) => line.trim()).filter(Boolean)\n let customId: string | undefined\n let sourceMessage: string | undefined\n const commentLines: string[] = []\n\n for (const line of lines) {\n if (line.startsWith(CUSTOM_ID_MARKER)) {\n customId = line.slice(CUSTOM_ID_MARKER.length).trim() || undefined\n continue\n }\n if (line.startsWith('msg`') && line.endsWith('`')) {\n sourceMessage = line.slice(4, -1)\n continue\n }\n if (line.startsWith('Trans: ')) {\n sourceMessage = normalizeRichTextComment(line.slice('Trans: '.length))\n continue\n }\n commentLines.push(line)\n }\n\n return {\n ...(commentLines.length > 0 ? { comment: commentLines.join('\\n') } : {}),\n ...(customId ? { customId } : {}),\n ...(sourceMessage ? { sourceMessage } : {}),\n }\n}\n\nfunction normalizeRichTextComment(comment: string): string {\n let stack: Array<{ tag: string; index: number }> = []\n let nextIndex = 0\n\n return comment.replace(/<\\/?([a-zA-Z][\\w-]*)>/g, (match, rawTag: string) => {\n const tag = rawTag\n if (match.startsWith('</')) {\n for (let index = stack.length - 1; index >= 0; index--) {\n const entry = stack[index]\n if (entry?.tag !== tag) continue\n stack = stack.filter((_, i) => i !== index)\n return `</${entry.index}>`\n }\n return match\n }\n\n const index = nextIndex++\n stack.push({ tag, index })\n return `<${index}>`\n })\n}\n\nfunction buildExtractedComment(\n id: string,\n message: string,\n context: string | undefined,\n comment: string | undefined,\n): string | undefined {\n const lines: string[] = []\n\n if (comment) {\n lines.push(comment)\n }\n\n if (id !== hashMessage(message, context)) {\n lines.push(`${CUSTOM_ID_MARKER} ${id}`)\n // Preserve source message so round-trip works when msgid is the custom ID (not source text)\n lines.push(`msg\\`${message}\\``)\n }\n\n return lines.length > 0 ? lines.join('\\n') : undefined\n}\n","import { Worker } from 'node:worker_threads'\nimport { availableParallelism } from 'node:os'\nimport { existsSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { CatalogData } from './catalog'\nimport type { CompileOptions, CompileStats } from './compile'\nimport type { CompileWorkerRequest, CompileWorkerResponse } from './compile-worker'\n\nexport interface ParallelCompileTask {\n locale: string\n catalog: CatalogData\n allIds: string[]\n sourceLocale: string\n options?: CompileOptions\n}\n\nexport interface ParallelCompileResult {\n locale: string\n code: string\n stats: CompileStats\n}\n\n/** Default timeout per worker in milliseconds (30 seconds) */\nconst WORKER_TIMEOUT_MS = 30_000\n\nfunction getWorkerPath(): string {\n const thisDir = typeof __dirname !== 'undefined'\n ? __dirname\n : dirname(fileURLToPath(import.meta.url))\n return resolve(thisDir, 'compile-worker.js')\n}\n\n/**\n * Compile multiple locales in parallel using worker threads.\n *\n * - Single task → returns result directly (no worker overhead)\n * - Multiple tasks → spawns min(tasks, availableParallelism()) workers\n * - Workers are created per-call and destroyed after completion\n *\n * Falls back to in-process compilation when the compiled worker is unavailable\n * (e.g. when running from TypeScript source in development/tests).\n */\nexport async function parallelCompile(\n tasks: ParallelCompileTask[],\n concurrency?: number,\n): Promise<ParallelCompileResult[]> {\n if (tasks.length === 0) return []\n\n // Single task: compile in-process, no worker overhead\n if (tasks.length === 1) {\n const { compileCatalog } = await import('./compile')\n const task = tasks[0]!\n const { code, stats } = compileCatalog(task.catalog, task.locale, task.allIds, task.sourceLocale, task.options)\n return [{ locale: task.locale, code, stats }]\n }\n\n const workerPath = getWorkerPath()\n\n // If compiled worker doesn't exist (dev/test), fall back to concurrent in-process compilation\n if (!existsSync(workerPath)) {\n return inProcessParallelCompile(tasks)\n }\n\n const maxWorkers = concurrency ?? Math.min(tasks.length, availableParallelism())\n const results: ParallelCompileResult[] = []\n const queue = [...tasks]\n let rejected = false\n\n return new Promise<ParallelCompileResult[]>((resolveAll, rejectAll) => {\n let activeWorkers = 0\n\n function spawnNext(): void {\n if (rejected) return\n const task = queue.shift()\n if (!task) {\n if (activeWorkers === 0) {\n resolveAll(results)\n }\n return\n }\n\n activeWorkers++\n const worker = new Worker(workerPath)\n\n const timer = setTimeout(() => {\n if (!rejected) {\n rejected = true\n activeWorkers--\n worker.terminate()\n rejectAll(new Error(`Worker timed out after ${WORKER_TIMEOUT_MS}ms compiling locale \"${task.locale}\"`))\n }\n }, WORKER_TIMEOUT_MS)\n\n worker.on('message', (response: CompileWorkerResponse) => {\n clearTimeout(timer)\n if (rejected) return\n if (response.error) {\n rejected = true\n activeWorkers--\n worker.terminate()\n rejectAll(new Error(`Failed to compile locale \"${response.locale}\": ${response.error}`))\n return\n }\n results.push({\n locale: response.locale,\n code: response.code,\n stats: response.stats,\n })\n activeWorkers--\n worker.terminate()\n spawnNext()\n })\n\n worker.on('error', (err: Error) => {\n clearTimeout(timer)\n if (!rejected) {\n rejected = true\n worker.terminate()\n rejectAll(new Error(`Worker error compiling locale \"${task.locale}\": ${err.message}`))\n }\n })\n\n worker.on('exit', (code) => {\n clearTimeout(timer)\n if (code !== 0 && !rejected) {\n rejected = true\n rejectAll(new Error(`Worker exited with code ${code} while compiling locale \"${task.locale}\"`))\n }\n })\n\n const request: CompileWorkerRequest = {\n locale: task.locale,\n catalog: task.catalog,\n allIds: task.allIds,\n sourceLocale: task.sourceLocale,\n options: task.options,\n }\n worker.postMessage(request)\n }\n\n // Start initial batch of workers\n const initialBatch = Math.min(maxWorkers, queue.length)\n for (let i = 0; i < initialBatch; i++) {\n spawnNext()\n }\n })\n}\n\n/**\n * In-process fallback for parallel compilation.\n * Uses Promise.all for concurrency when workers are unavailable.\n */\nasync function inProcessParallelCompile(\n tasks: ParallelCompileTask[],\n): Promise<ParallelCompileResult[]> {\n const { compileCatalog } = await import('./compile')\n return Promise.all(\n tasks.map((task) => {\n const { code, stats } = compileCatalog(task.catalog, task.locale, task.allIds, task.sourceLocale, task.options)\n return { locale: task.locale, code, stats }\n }),\n )\n}\n","import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport type { ExtractedMessage } from '@fluenti/core/compiler'\n\n/** Cache format version — bump when the structure changes */\nconst CACHE_VERSION = '1'\n\ninterface ExtractCacheEntry {\n mtime: number\n size: number\n messages: ExtractedMessage[]\n}\n\ninterface ExtractCacheData {\n version: string\n entries: Record<string, ExtractCacheEntry>\n}\n\n/**\n * File-level extract cache that skips re-extraction for unchanged files.\n *\n * Cache is keyed by file path, with mtime + size as change detection.\n */\nexport class ExtractCache {\n private data: ExtractCacheData\n private cachePath: string\n private dirty = false\n\n constructor(catalogDir: string, projectId?: string) {\n const cacheDir = projectId\n ? resolve(catalogDir, '.cache', projectId)\n : resolve(catalogDir, '.cache')\n this.cachePath = resolve(cacheDir, 'extract-cache.json')\n this.data = this.load()\n }\n\n /**\n * Check if a file has changed since the last extraction.\n * Returns cached messages if unchanged, undefined if re-extraction needed.\n */\n get(filePath: string): ExtractedMessage[] | undefined {\n const entry = this.data.entries[filePath]\n if (!entry) return undefined\n\n try {\n const stat = statSync(filePath)\n if (stat.mtimeMs === entry.mtime && stat.size === entry.size) {\n return entry.messages\n }\n } catch {\n // File no longer exists or can't be stat'd — cache miss\n }\n\n return undefined\n }\n\n /**\n * Update the cache for a file after extraction.\n */\n set(filePath: string, messages: ExtractedMessage[]): void {\n try {\n const stat = statSync(filePath)\n this.data.entries[filePath] = {\n mtime: stat.mtimeMs,\n size: stat.size,\n messages,\n }\n this.dirty = true\n } catch {\n // File doesn't exist — skip caching\n }\n }\n\n /**\n * Remove entries for files that no longer exist in the file list.\n */\n prune(currentFiles: Set<string>): void {\n for (const filePath of Object.keys(this.data.entries)) {\n if (!currentFiles.has(filePath)) {\n delete this.data.entries[filePath]\n this.dirty = true\n }\n }\n }\n\n /**\n * Write the cache to disk if any changes were made.\n */\n save(): void {\n if (!this.dirty) return\n\n try {\n mkdirSync(dirname(this.cachePath), { recursive: true })\n writeFileSync(this.cachePath, JSON.stringify(this.data), 'utf-8')\n this.dirty = false\n } catch {\n // Cache write failure is non-fatal — next run will re-extract\n }\n }\n\n /** Number of cached entries */\n get size(): number {\n return Object.keys(this.data.entries).length\n }\n\n private load(): ExtractCacheData {\n try {\n if (existsSync(this.cachePath)) {\n const raw = readFileSync(this.cachePath, 'utf-8')\n const parsed = JSON.parse(raw) as ExtractCacheData\n if (parsed.version === CACHE_VERSION) {\n return parsed\n }\n }\n } catch {\n // Corrupt or unreadable cache — start fresh\n }\n\n return { version: CACHE_VERSION, entries: {} }\n }\n}\n","import { readFileSync, writeFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport fg from 'fast-glob'\n\nconst FRAMEWORKS = ['react', 'vue', 'solid'] as const\nconst COMPONENT_EXPORTS = new Set(['Trans', 'Plural', 'Select', 'DateTime', 'NumberFormat'])\n\ntype FrameworkName = (typeof FRAMEWORKS)[number]\n\nexport interface CodemodOptions {\n cwd: string\n include?: string[]\n write?: boolean\n}\n\nexport interface CodemodFileResult {\n file: string\n changed: boolean\n}\n\nexport interface CodemodResult {\n changedFiles: CodemodFileResult[]\n changedCount: number\n}\n\ninterface ParsedSpecifier {\n imported: string\n local: string\n isType: boolean\n}\n\nconst DEFAULT_GLOBS = [\n 'src/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'app/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'pages/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'components/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'layouts/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n]\n\nfunction parseSpecifier(raw: string): ParsedSpecifier {\n const trimmed = raw.trim()\n const isType = trimmed.startsWith('type ')\n const normalized = isType ? trimmed.slice(5).trim() : trimmed\n const parts = normalized.split(/\\s+as\\s+/)\n const imported = parts[0]!.trim()\n const local = (parts[1] ?? parts[0])!.trim()\n return {\n imported,\n local,\n isType,\n }\n}\n\nfunction formatSpecifier(specifier: ParsedSpecifier): string {\n const prefix = specifier.isType ? 'type ' : ''\n if (specifier.imported === specifier.local) {\n return `${prefix}${specifier.imported}`\n }\n return `${prefix}${specifier.imported} as ${specifier.local}`\n}\n\nfunction dedupeSpecifiers(specifiers: ParsedSpecifier[]): ParsedSpecifier[] {\n const seen = new Set<string>()\n const result: ParsedSpecifier[] = []\n for (const specifier of specifiers) {\n const key = `${specifier.isType ? 'type:' : 'value:'}${specifier.imported}:${specifier.local}`\n if (seen.has(key)) continue\n seen.add(key)\n result.push(specifier)\n }\n return result\n}\n\nfunction mergeNamedImports(code: string, source: string): string {\n const pattern = new RegExp(`import\\\\s*\\\\{([\\\\s\\\\S]*?)\\\\}\\\\s*from\\\\s*['\"]${source.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}['\"];?\\\\n?`, 'g')\n const matches = [...code.matchAll(pattern)]\n if (matches.length <= 1) return code\n\n const specifiers = dedupeSpecifiers(\n matches.flatMap((match) => match[1]!.split(',').map((entry) => parseSpecifier(entry)).filter((entry) => entry.imported.length > 0)),\n )\n const mergedImport = `import { ${specifiers.map(formatSpecifier).join(', ')} } from '${source}'\\n`\n\n let first = true\n return code.replace(pattern, () => {\n if (first) {\n first = false\n return mergedImport\n }\n return ''\n })\n}\n\nexport function rewriteFluentiImports(source: string): { code: string; changed: boolean } {\n let code = source\n let changed = false\n let renameSolidFactory = false\n\n const importPattern = /import\\s*\\{([\\s\\S]*?)\\}\\s*from\\s*['\"](@fluenti\\/(react|vue|solid)(?:\\/components)?)['\"];?/g\n\n code = code.replace(importPattern, (full, specifiersRaw: string, sourcePath: string, framework: FrameworkName) => {\n const specifiers = specifiersRaw\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n .map(parseSpecifier)\n\n const main: ParsedSpecifier[] = []\n const components: ParsedSpecifier[] = []\n const runtime: ParsedSpecifier[] = []\n\n for (const specifier of specifiers) {\n const next = { ...specifier }\n if (framework === 'solid' && next.imported === 'createFluentiContext') {\n next.imported = 'createFluenti'\n if (next.local === 'createFluentiContext') {\n next.local = 'createFluenti'\n renameSolidFactory = true\n }\n }\n\n if (next.imported === 'interpolate') {\n runtime.push({ ...next, isType: false })\n continue\n }\n\n if (!next.isType && COMPONENT_EXPORTS.has(next.imported) && sourcePath.endsWith('/components')) {\n components.push(next)\n continue\n }\n\n main.push(next)\n }\n\n const nextImports: string[] = []\n if (main.length > 0 && !sourcePath.endsWith('/components')) {\n nextImports.push(`import { ${dedupeSpecifiers(main).map(formatSpecifier).join(', ')} } from '@fluenti/${framework}'`)\n }\n if (components.length > 0) {\n nextImports.push(`import { ${dedupeSpecifiers(components).map(formatSpecifier).join(', ')} } from '@fluenti/${framework}/components'`)\n }\n if (runtime.length > 0) {\n nextImports.push(`import { ${dedupeSpecifiers(runtime).map(formatSpecifier).join(', ')} } from '@fluenti/core/runtime'`)\n }\n if (main.length > 0 && sourcePath.endsWith('/components')) {\n nextImports.unshift(`import { ${dedupeSpecifiers(main).map(formatSpecifier).join(', ')} } from '@fluenti/${framework}'`)\n }\n\n const replacement = nextImports.join('\\n')\n if (replacement !== full) {\n changed = true\n }\n return replacement\n })\n\n if (renameSolidFactory) {\n const renamed = code.replace(/\\bcreateFluentiContext\\b/g, 'createFluenti')\n if (renamed !== code) {\n code = renamed\n changed = true\n }\n }\n\n for (const sourcePath of [\n '@fluenti/react',\n '@fluenti/react/components',\n '@fluenti/vue',\n '@fluenti/vue/components',\n '@fluenti/solid',\n '@fluenti/solid/components',\n '@fluenti/core/runtime',\n ]) {\n const merged = mergeNamedImports(code, sourcePath)\n if (merged !== code) {\n code = merged\n changed = true\n }\n }\n\n return { code, changed }\n}\n\nexport async function runCodemod(options: CodemodOptions): Promise<CodemodResult> {\n const include = options.include && options.include.length > 0 ? options.include : DEFAULT_GLOBS\n const files = await fg(include, {\n cwd: options.cwd,\n absolute: false,\n ignore: ['**/node_modules/**', '**/dist/**', '**/.fluenti/**'],\n })\n\n const changedFiles: CodemodFileResult[] = []\n\n for (const file of files) {\n const path = resolve(options.cwd, file)\n const current = readFileSync(path, 'utf-8')\n const rewritten = rewriteFluentiImports(current)\n if (!rewritten.changed) continue\n\n if (options.write) {\n writeFileSync(path, rewritten.code, 'utf-8')\n }\n\n changedFiles.push({ file, changed: true })\n }\n\n return {\n changedFiles,\n changedCount: changedFiles.length,\n }\n}\n","import { readFileSync, writeFileSync, existsSync, appendFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport consola from 'consola'\n\nconst LOCALE_PATTERN = /^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{1,8})*$/\n\nexport function validateLocale(locale: string): string {\n if (!LOCALE_PATTERN.test(locale)) {\n throw new Error(`Invalid locale format: \"${locale}\"`)\n }\n return locale\n}\n\nexport interface DetectedFramework {\n name: 'nextjs' | 'nuxt' | 'vue' | 'solid' | 'solidstart' | 'react' | 'unknown'\n pluginPackage: string | null\n}\n\nconst FRAMEWORK_DETECTION: Array<{\n dep: string\n name: DetectedFramework['name']\n pluginPackage: string\n}> = [\n { dep: 'next', name: 'nextjs', pluginPackage: '@fluenti/next' },\n { dep: 'nuxt', name: 'nuxt', pluginPackage: '@fluenti/vue' },\n { dep: '@solidjs/start', name: 'solidstart', pluginPackage: '@fluenti/solid' },\n { dep: 'vue', name: 'vue', pluginPackage: '@fluenti/vue' },\n { dep: 'solid-js', name: 'solid', pluginPackage: '@fluenti/solid' },\n { dep: 'react', name: 'react', pluginPackage: '@fluenti/react' },\n]\n\n/**\n * Detect the framework from package.json dependencies.\n */\nexport function detectFramework(deps: Record<string, string>): DetectedFramework {\n for (const entry of FRAMEWORK_DETECTION) {\n if (entry.dep in deps) {\n return { name: entry.name, pluginPackage: entry.pluginPackage }\n }\n }\n return { name: 'unknown', pluginPackage: null }\n}\n\n/**\n * Generate fluenti.config.ts content.\n */\nexport function generateFluentiConfig(opts: {\n sourceLocale: string\n locales: string[]\n format: 'po' | 'json'\n}): string {\n const localesList = opts.locales.map((l) => JSON.stringify(l)).join(', ')\n return `import { defineConfig } from '@fluenti/cli'\n\nexport default defineConfig({\n sourceLocale: ${JSON.stringify(opts.sourceLocale)},\n locales: [${localesList}],\n catalogDir: './locales',\n format: ${JSON.stringify(opts.format)},\n include: ['./src/**/*.{vue,tsx,jsx,ts,js}'],\n compileOutDir: './src/locales/compiled',\n})\n`\n}\n\n/**\n * Interactive init flow.\n */\nexport async function runInit(options: { cwd: string }): Promise<void> {\n const pkgPath = resolve(options.cwd, 'package.json')\n if (!existsSync(pkgPath)) {\n consola.error('No package.json found in current directory.')\n return\n }\n\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8')) as {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n scripts?: Record<string, string>\n }\n const allDeps = { ...pkg.dependencies, ...pkg.devDependencies }\n const framework = detectFramework(allDeps)\n\n consola.info(`Detected framework: ${framework.name}`)\n if (framework.pluginPackage) {\n consola.info(`Recommended plugin: ${framework.pluginPackage}`)\n }\n\n // Check if config already exists\n const configPath = resolve(options.cwd, 'fluenti.config.ts')\n if (existsSync(configPath)) {\n consola.warn('fluenti.config.ts already exists. Skipping config generation.')\n return\n }\n\n // Prompt for configuration\n const sourceLocale = await consola.prompt('Source locale?', {\n type: 'text',\n default: 'en',\n placeholder: 'en',\n }) as unknown as string\n\n if (typeof sourceLocale === 'symbol') return // user cancelled\n\n const targetLocalesInput = await consola.prompt('Target locales (comma-separated)?', {\n type: 'text',\n default: 'ja,zh-CN',\n placeholder: 'ja,zh-CN',\n }) as unknown as string\n\n if (typeof targetLocalesInput === 'symbol') return\n\n const format = await consola.prompt('Catalog format?', {\n type: 'select',\n options: ['po', 'json'],\n initial: 'po',\n }) as unknown as string\n\n if (typeof format === 'symbol') return\n\n const targetLocales = targetLocalesInput.split(',').map((l) => l.trim()).filter(Boolean)\n\n // Validate locale formats\n validateLocale(sourceLocale)\n for (const locale of targetLocales) {\n validateLocale(locale)\n }\n\n const allLocales = [sourceLocale, ...targetLocales.filter((l) => l !== sourceLocale)]\n\n // Write config\n const configContent = generateFluentiConfig({\n sourceLocale,\n locales: allLocales,\n format: format as 'po' | 'json',\n })\n writeFileSync(configPath, configContent, 'utf-8')\n consola.success('Created fluenti.config.ts')\n\n // Append to .gitignore\n const gitignorePath = resolve(options.cwd, '.gitignore')\n const gitignoreEntry = 'src/locales/compiled/'\n if (existsSync(gitignorePath)) {\n const existing = readFileSync(gitignorePath, 'utf-8')\n if (!existing.includes(gitignoreEntry)) {\n appendFileSync(gitignorePath, `\\n# Fluenti compiled catalogs\\n${gitignoreEntry}\\n`)\n consola.success('Updated .gitignore')\n }\n } else {\n writeFileSync(gitignorePath, `# Fluenti compiled catalogs\\n${gitignoreEntry}\\n`)\n consola.success('Created .gitignore')\n }\n\n // Patch package.json scripts\n const existingScripts = pkg.scripts ?? {}\n const newScripts: Record<string, string> = {}\n let scriptsChanged = false\n if (!existingScripts['i18n:extract']) {\n newScripts['i18n:extract'] = 'fluenti extract'\n scriptsChanged = true\n }\n if (!existingScripts['i18n:compile']) {\n newScripts['i18n:compile'] = 'fluenti compile'\n scriptsChanged = true\n }\n if (scriptsChanged) {\n const updatedPkg = {\n ...pkg,\n scripts: { ...existingScripts, ...newScripts },\n }\n writeFileSync(pkgPath, JSON.stringify(updatedPkg, null, 2) + '\\n', 'utf-8')\n consola.success('Added i18n:extract and i18n:compile scripts to package.json')\n }\n\n // Print next steps\n consola.log('')\n consola.box({\n title: 'Next steps',\n message: [\n framework.pluginPackage\n ? `1. Install: pnpm add -D ${framework.pluginPackage} @fluenti/cli`\n : '1. Install: pnpm add -D @fluenti/cli',\n framework.name === 'nextjs'\n ? '2. Add withFluenti() to your next.config.ts'\n : framework.name !== 'unknown'\n ? '2. Add the Vite plugin to your vite.config.ts (e.g. fluentiVue() from @fluenti/vue/vite-plugin)'\n : '2. Configure your build tool with the framework Vite plugin or @fluenti/next',\n '3. Run: npx fluenti extract',\n '4. Translate your messages',\n '5. Run: npx fluenti compile',\n ].join('\\n'),\n })\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport fg from 'fast-glob'\nimport { detectFramework, type DetectedFramework } from './init'\nimport { loadConfig } from './config-loader'\n\nexport type DoctorSeverity = 'error' | 'warning' | 'info'\n\nexport interface DoctorFinding {\n severity: DoctorSeverity\n code: string\n message: string\n}\n\nexport interface DoctorReport {\n framework: DetectedFramework['name']\n findings: DoctorFinding[]\n configPath?: string\n}\n\nexport interface DoctorOptions {\n cwd: string\n config?: string\n}\n\nconst SOURCE_GLOBS = [\n 'src/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'app/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'pages/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'components/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n 'layouts/**/*.{ts,tsx,js,jsx,mts,cts,mjs,cjs,vue,mdx}',\n]\n\nconst MAIN_INTERPOLATE_IMPORT_RE = /import\\s*\\{[\\s\\S]*?\\binterpolate\\b[\\s\\S]*?\\}\\s*from\\s*['\"]@fluenti\\/(react|vue|solid)(?:\\/components)?['\"]/g\nconst INTERNAL_IMPORT_RE = /from\\s*['\"]@fluenti\\/core\\/internal['\"]/g\n\nfunction readIfExists(path: string): string | undefined {\n return existsSync(path) ? readFileSync(path, 'utf-8') : undefined\n}\n\nfunction detectConfigPath(cwd: string, explicit?: string): string | undefined {\n if (explicit) return resolve(cwd, explicit)\n\n for (const candidate of ['fluenti.config.ts', 'fluenti.config.mts', 'fluenti.config.js', 'fluenti.config.mjs']) {\n const resolved = resolve(cwd, candidate)\n if (existsSync(resolved)) return resolved\n }\n\n return undefined\n}\n\nasync function collectSourceFiles(cwd: string): Promise<string[]> {\n return fg(SOURCE_GLOBS, {\n cwd,\n absolute: false,\n ignore: ['**/node_modules/**', '**/dist/**', '**/.fluenti/**'],\n })\n}\n\nfunction pushFinding(findings: DoctorFinding[], severity: DoctorSeverity, code: string, message: string): void {\n findings.push({ severity, code, message })\n}\n\nfunction getPackageJson(cwd: string): { dependencies?: Record<string, string>; devDependencies?: Record<string, string> } | undefined {\n const pkgPath = resolve(cwd, 'package.json')\n const content = readIfExists(pkgPath)\n if (!content) return undefined\n return JSON.parse(content) as { dependencies?: Record<string, string>; devDependencies?: Record<string, string> }\n}\n\nfunction hasVitePlugin(content: string | undefined): boolean {\n if (!content) return false\n return content.includes('@fluenti/') && content.includes('vite-plugin')\n}\n\nfunction countMatches(content: string, pattern: RegExp): number {\n return [...content.matchAll(pattern)].length\n}\n\nexport async function runDoctor(options: DoctorOptions): Promise<DoctorReport> {\n const findings: DoctorFinding[] = []\n const pkg = getPackageJson(options.cwd)\n\n if (!pkg) {\n return {\n framework: 'unknown',\n findings: [{ severity: 'error', code: 'missing-package-json', message: 'No package.json found in the current directory.' }],\n }\n }\n\n const framework = detectFramework({ ...pkg.dependencies, ...pkg.devDependencies })\n const configPath = detectConfigPath(options.cwd, options.config)\n const files = await collectSourceFiles(options.cwd)\n\n let mainInterpolateImports = 0\n let internalImports = 0\n let importsFluenti = false\n let usesCompileTimeT = false\n\n for (const file of files) {\n const content = readFileSync(resolve(options.cwd, file), 'utf-8')\n mainInterpolateImports += countMatches(content, MAIN_INTERPOLATE_IMPORT_RE)\n internalImports += countMatches(content, INTERNAL_IMPORT_RE)\n importsFluenti = importsFluenti || content.includes('@fluenti/')\n usesCompileTimeT = usesCompileTimeT || content.includes(\"from '@fluenti/\") && content.includes(' t`')\n }\n\n if (mainInterpolateImports > 0) {\n pushFinding(\n findings,\n 'warning',\n 'main-entry-interpolate',\n `Found ${mainInterpolateImports} import(s) of interpolate from framework packages. Import interpolate from @fluenti/core/runtime instead.`,\n )\n }\n\n if (internalImports > 0) {\n pushFinding(\n findings,\n 'warning',\n 'core-internal-imports',\n `Found ${internalImports} import(s) from @fluenti/core/internal. Use @fluenti/core/runtime or @fluenti/core/compiler.`,\n )\n }\n\n if (!configPath) {\n pushFinding(findings, 'warning', 'missing-config', 'No fluenti.config.* file found.')\n }\n\n if (framework.name === 'nextjs') {\n const nextConfig = ['next.config.ts', 'next.config.mjs', 'next.config.js']\n .map((name) => resolve(options.cwd, name))\n .find((candidate) => existsSync(candidate))\n const nextContent = nextConfig ? readIfExists(nextConfig) : undefined\n if (importsFluenti && !nextContent?.includes('withFluenti(')) {\n pushFinding(findings, 'error', 'missing-with-fluenti', 'Next.js project imports Fluenti but next.config does not call withFluenti().')\n }\n }\n\n if (framework.name === 'react' || framework.name === 'vue' || framework.name === 'solid') {\n const viteConfig = ['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs']\n .map((name) => resolve(options.cwd, name))\n .find((candidate) => existsSync(candidate))\n const viteContent = viteConfig ? readIfExists(viteConfig) : undefined\n if ((importsFluenti || usesCompileTimeT) && !hasVitePlugin(viteContent)) {\n pushFinding(findings, 'warning', 'missing-vite-plugin', 'Project imports Fluenti but vite.config does not appear to include a Fluenti Vite plugin.')\n }\n }\n\n if (configPath && existsSync(configPath)) {\n try {\n const config = await loadConfig(configPath)\n const sourceCatalogExt = config.format === 'json' ? '.json' : '.po'\n const sourceCatalog = resolve(options.cwd, config.catalogDir, `${config.sourceLocale}${sourceCatalogExt}`)\n if (!existsSync(sourceCatalog)) {\n pushFinding(findings, 'warning', 'missing-source-catalog', `Source catalog not found: ${sourceCatalog}`)\n }\n\n const compiledIndex = resolve(options.cwd, config.compileOutDir, 'index.js')\n if (!existsSync(compiledIndex)) {\n pushFinding(findings, 'warning', 'missing-compiled-catalogs', `Compiled catalogs not found at ${compiledIndex}. Run \"fluenti compile\".`)\n }\n } catch (error) {\n pushFinding(\n findings,\n 'error',\n 'invalid-config',\n `Failed to load Fluenti config: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n if (findings.length === 0) {\n pushFinding(findings, 'info', 'ok', 'No Fluenti migration or configuration issues detected.')\n }\n\n return {\n framework: framework.name,\n findings,\n ...(configPath ? { configPath } : {}),\n }\n}\n\nexport function formatDoctorReport(report: DoctorReport): string {\n const lines: string[] = [`Framework: ${report.framework}`]\n if (report.configPath) {\n lines.push(`Config: ${report.configPath}`)\n }\n lines.push('')\n\n for (const finding of report.findings) {\n const prefix = finding.severity === 'error'\n ? '✖'\n : finding.severity === 'warning'\n ? '⚠'\n : '•'\n lines.push(`${prefix} [${finding.code}] ${finding.message}`)\n }\n\n return lines.join('\\n')\n}\n"],"mappings":"63BAyBA,SAAgB,EACd,EACA,EACA,EACgD,CAChD,IAAM,EAAe,IAAI,IAAI,EAAU,IAAK,GAAM,EAAE,GAAG,CAAC,CAClD,EAA0B,IAAI,IAC9B,EAAuB,EAAE,CAC3B,EAAQ,EACR,EAAY,EACZ,EAAW,EAEf,IAAK,IAAM,KAAO,EAAW,CAC3B,IAAM,EAAgB,EAAS,EAAI,IAC7B,EAAU,EACZ,IAAA,GACA,EAAsB,EAAU,EAAK,EAAwB,CAC3D,EAAS,GAAG,EAAI,OAAO,KAAK,GAAG,EAAI,OAAO,OAC1C,EAAY,GAAiB,GAAS,MAM5C,GAJI,GACF,EAAwB,IAAI,EAAQ,GAAG,CAGrC,EACF,EAAQ,EAAI,IAAM,CAChB,GAAG,EACH,QAAS,EAAI,SAAW,EAAU,QAClC,QAAS,EAAI,QACb,QAAS,EAAI,QACb,SACA,SAAU,GACX,CACD,YACS,EAAQ,EAAI,IAAK,CAE1B,IAAM,EAAW,EAAQ,EAAI,IAC7B,EAAQ,EAAI,IAAM,CAChB,GAAG,EACH,OAAQ,EAAa,EAAS,OAAQ,EAAO,CAC9C,MAED,EAAQ,EAAI,IAAM,CAChB,QAAS,EAAI,QACb,QAAS,EAAI,QACb,QAAS,EAAI,QACb,SACD,CACD,IAGF,GAAI,GAAS,WAAY,CACvB,GAAM,CAAE,MAAO,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QACA,iBACA,kCAAkC,aAAiB,MAAQ,EAAM,QAAU,OAAO,EAAM,GACzF,CAQL,OAJI,EAAS,SAAW,GACtB,EAAY,EAAU,OAAQ,KAAM,yDAAyD,CAGxF,CACL,UAAW,EAAU,KACrB,WACA,GAAI,EAAa,CAAE,aAAY,CAAG,EAAE,CACrC,CAGH,SAAgB,GAAmB,EAA8B,CAC/D,IAAM,EAAkB,CAAC,cAAc,EAAO,YAAY,CACtD,EAAO,YACT,EAAM,KAAK,WAAW,EAAO,aAAa,CAE5C,EAAM,KAAK,GAAG,CAEd,IAAK,IAAM,KAAW,EAAO,SAAU,CACrC,IAAM,EAAS,EAAQ,WAAa,QAChC,IACA,EAAQ,WAAa,UACnB,IACA,IACN,EAAM,KAAK,GAAG,EAAO,IAAI,EAAQ,KAAK,IAAI,EAAQ,UAAU,CAG9D,OAAO,EAAM,KAAK;EAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/config.ts","../src/compile-runner.ts","../src/extract-runner.ts"],"sourcesContent":["import type { FluentiBuildConfig } from '@fluenti/core/compiler'\n\n/**\n * Define a Fluenti configuration with full type inference and IDE autocompletion.\n *\n * @example\n * ```ts\n * // fluenti.config.ts\n * import { defineConfig } from '@fluenti/cli'\n *\n * export default defineConfig({\n * sourceLocale: 'en',\n * locales: ['en', 'ja', 'zh-CN'],\n * catalogDir: './locales',\n * format: 'po',\n * include: ['./src/**\\/*.{vue,tsx,ts}'],\n * compileOutDir: './src/locales/compiled',\n * })\n * ```\n */\nexport function defineConfig(config: Partial<FluentiBuildConfig>): Partial<FluentiBuildConfig> {\n return config\n}\n","import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { resolveLocaleCodes, createPluginRunner } from '@fluenti/core/compiler'\nimport type { PluginCompileContext } from '@fluenti/core/compiler'\nimport { loadConfig } from './config-loader'\nimport { compileCatalog, compileIndex, collectAllIds, compileTypeDeclaration } from './compile'\nimport { parallelCompile } from './parallel-compile'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog } from './json-format'\nimport { readPoCatalog } from './po-format'\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\n/** Build a messages record (id → translation or message) from catalog data */\nfunction catalogToMessages(catalog: CatalogData): Record<string, string> {\n const messages: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n const text = entry.translation ?? entry.message ?? id\n messages[id] = text\n }\n return messages\n}\n\nexport interface RunCompileOptions {\n parallel?: boolean\n}\n\n/**\n * Programmatic compile entry point.\n * Loads config from `cwd`, reads catalogs, and writes compiled output.\n * This is the in-process equivalent of `fluenti compile`.\n */\nexport async function runCompile(cwd: string, options?: RunCompileOptions): Promise<void> {\n const config = await loadConfig(undefined, cwd)\n const localeCodes = resolveLocaleCodes(config.locales)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const outDir = resolve(cwd, config.compileOutDir)\n mkdirSync(outDir, { recursive: true })\n\n const pluginRunner = config.plugins?.length\n ? createPluginRunner(config.plugins)\n : undefined\n\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of localeCodes) {\n const catalogPath = resolve(cwd, config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n\n // Run plugin hooks around compilation\n for (const locale of localeCodes) {\n if (pluginRunner) {\n const compileContext: PluginCompileContext = {\n locale,\n messages: catalogToMessages(allCatalogs[locale]!),\n outDir,\n config,\n }\n await pluginRunner.runBeforeCompile(compileContext)\n }\n }\n\n if (options?.parallel && localeCodes.length > 1) {\n const tasks = localeCodes.map((locale) => ({\n locale,\n catalog: allCatalogs[locale]!,\n allIds,\n sourceLocale: config.sourceLocale,\n }))\n\n const results = await parallelCompile(tasks)\n\n for (const result of results) {\n writeFileSync(resolve(outDir, `${result.locale}.js`), result.code, 'utf-8')\n }\n } else {\n for (const locale of localeCodes) {\n const { code } = compileCatalog(allCatalogs[locale]!, locale, allIds, config.sourceLocale)\n writeFileSync(resolve(outDir, `${locale}.js`), code, 'utf-8')\n }\n }\n\n const indexCode = compileIndex(localeCodes, config.compileOutDir)\n writeFileSync(resolve(outDir, 'index.js'), indexCode, 'utf-8')\n\n const typesCode = compileTypeDeclaration(allIds, allCatalogs, config.sourceLocale)\n writeFileSync(resolve(outDir, 'messages.d.ts'), typesCode, 'utf-8')\n\n // Run after-compile hooks\n for (const locale of localeCodes) {\n if (pluginRunner) {\n const compileContext: PluginCompileContext = {\n locale,\n messages: catalogToMessages(allCatalogs[locale]!),\n outDir,\n config,\n }\n await pluginRunner.runAfterCompile(compileContext)\n }\n }\n}\n","import fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { ExtractCache } from './extract-cache'\nimport { loadConfig } from './config-loader'\nimport type { ExtractedMessage } from '@fluenti/core/compiler'\nimport { resolveLocaleCodes, createPluginRunner } from '@fluenti/core/compiler'\nimport type { PluginExtractContext } from '@fluenti/core/compiler'\n\nfunction deriveProjectId(cwd: string): string {\n return createHash('md5').update(cwd).digest('hex').slice(0, 8)\n}\n\nexport interface RunExtractOptions {\n clean?: boolean\n stripFuzzy?: boolean\n useCache?: boolean\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n try {\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content, 'utf-8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(`Failed to write catalog \"${filePath}\": ${message}`)\n }\n}\n\nasync function extractFromFile(filePath: string, code: string): Promise<ExtractedMessage[]> {\n const ext = extname(filePath)\n if (ext === '.vue') {\n try {\n const { extractFromVue } = await import('./vue-extractor')\n return extractFromVue(code, filePath)\n } catch {\n return []\n }\n }\n return extractFromTsx(code, filePath)\n}\n\n/**\n * Programmatic extract entry point.\n * Loads config from `cwd`, extracts messages, and writes catalogs.\n * This is the in-process equivalent of `fluenti extract`.\n */\nexport async function runExtract(cwd: string, options?: RunExtractOptions): Promise<void> {\n const config = await loadConfig(undefined, cwd)\n const localeCodes = resolveLocaleCodes(config.locales)\n\n const files = await fg(config.include, { cwd, ignore: config.exclude ?? [], absolute: false })\n const allMessages: ExtractedMessage[] = []\n const useCache = options?.useCache !== false\n const cache = useCache ? new ExtractCache(resolve(cwd, config.catalogDir), deriveProjectId(cwd)) : null\n\n for (const file of files) {\n const absFile = resolve(cwd, file)\n if (cache) {\n const cached = cache.get(absFile)\n if (cached) {\n allMessages.push(...cached)\n continue\n }\n }\n\n const code = readFileSync(absFile, 'utf-8')\n const messages = await extractFromFile(absFile, code)\n allMessages.push(...messages)\n\n if (cache) {\n cache.set(absFile, messages)\n }\n }\n\n if (cache) {\n cache.prune(new Set(files.map((f) => resolve(cwd, f))))\n cache.save()\n }\n\n // Run onAfterExtract plugin hooks\n const pluginRunner = config.plugins?.length\n ? createPluginRunner(config.plugins)\n : undefined\n\n if (pluginRunner) {\n const messageMap = new Map<string, ExtractedMessage>()\n for (const msg of allMessages) {\n messageMap.set(msg.id, msg)\n }\n const extractContext: PluginExtractContext = {\n messages: messageMap,\n sourceLocale: config.sourceLocale,\n targetLocales: localeCodes.filter((l) => l !== config.sourceLocale),\n config,\n }\n await pluginRunner.runAfterExtract(extractContext)\n }\n\n const ext = config.format === 'json' ? '.json' : '.po'\n const clean = options?.clean ?? false\n const stripFuzzy = options?.stripFuzzy ?? false\n\n for (const locale of localeCodes) {\n const catalogPath = resolve(cwd, config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog } = updateCatalog(existing, allMessages, { stripFuzzy })\n\n const finalCatalog = clean\n ? Object.fromEntries(Object.entries(catalog).filter(([, entry]) => !entry.obsolete))\n : catalog\n\n writeCatalog(catalogPath, finalCatalog, config.format)\n }\n}\n"],"mappings":"6WAoBA,SAAgB,EAAa,EAAkE,CAC7F,OAAO,ECVT,SAAS,EAAY,EAAkB,EAAoC,CACzE,GAAI,EAAA,EAAA,EAAA,YAAY,EAAS,CAAE,MAAO,EAAE,CACpC,IAAM,GAAA,EAAA,EAAA,cAAuB,EAAU,QAAQ,CAC/C,OAAO,IAAW,OAAS,EAAA,EAAgB,EAAQ,CAAG,EAAA,EAAc,EAAQ,CAI9E,SAAS,EAAkB,EAA8C,CACvE,IAAM,EAAmC,EAAE,CAC3C,IAAK,GAAM,CAAC,EAAI,KAAU,OAAO,QAAQ,EAAQ,CAC3C,EAAM,WAEV,EAAS,GADI,EAAM,aAAe,EAAM,SAAW,GAGrD,OAAO,EAYT,eAAsB,EAAW,EAAa,EAA4C,CACxF,IAAM,EAAS,MAAA,EAAA,EAAA,YAAiB,IAAA,GAAW,EAAI,CACzC,GAAA,EAAA,EAAA,oBAAiC,EAAO,QAAQ,CAChD,EAAM,EAAO,SAAW,OAAS,QAAU,MAE3C,GAAA,EAAA,EAAA,SAAiB,EAAK,EAAO,cAAc,EACjD,EAAA,EAAA,WAAU,EAAQ,CAAE,UAAW,GAAM,CAAC,CAEtC,IAAM,EAAe,EAAO,SAAS,QAAA,EAAA,EAAA,oBACd,EAAO,QAAQ,CAClC,IAAA,GAEE,EAA2C,EAAE,CACnD,IAAK,IA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,CAAC,CAClF,EAEoC,EAAO,OAAO"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/config.ts","../src/compile-runner.ts","../src/extract-runner.ts"],"sourcesContent":["import type { FluentiBuildConfig } from '@fluenti/core/compiler'\n\n/**\n * Define a Fluenti configuration with full type inference and IDE autocompletion.\n *\n * @example\n * ```ts\n * // fluenti.config.ts\n * import { defineConfig } from '@fluenti/cli'\n *\n * export default defineConfig({\n * sourceLocale: 'en',\n * locales: ['en', 'ja', 'zh-CN'],\n * catalogDir: './locales',\n * format: 'po',\n * include: ['./src/**\\/*.{vue,tsx,ts}'],\n * compileOutDir: './src/locales/compiled',\n * })\n * ```\n */\nexport function defineConfig(config: Partial<FluentiBuildConfig>): Partial<FluentiBuildConfig> {\n return config\n}\n","import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { resolveLocaleCodes, createPluginRunner } from '@fluenti/core/compiler'\nimport type { PluginCompileContext } from '@fluenti/core/compiler'\nimport { loadConfig } from './config-loader'\nimport { compileCatalog, compileIndex, collectAllIds, compileTypeDeclaration } from './compile'\nimport { parallelCompile } from './parallel-compile'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog } from './json-format'\nimport { readPoCatalog } from './po-format'\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\n/** Build a messages record (id → translation or message) from catalog data */\nfunction catalogToMessages(catalog: CatalogData): Record<string, string> {\n const messages: Record<string, string> = {}\n for (const [id, entry] of Object.entries(catalog)) {\n if (entry.obsolete) continue\n const text = entry.translation ?? entry.message ?? id\n messages[id] = text\n }\n return messages\n}\n\nexport interface RunCompileOptions {\n parallel?: boolean\n}\n\n/**\n * Programmatic compile entry point.\n * Loads config from `cwd`, reads catalogs, and writes compiled output.\n * This is the in-process equivalent of `fluenti compile`.\n */\nexport async function runCompile(cwd: string, options?: RunCompileOptions): Promise<void> {\n const config = await loadConfig(undefined, cwd)\n const localeCodes = resolveLocaleCodes(config.locales)\n const ext = config.format === 'json' ? '.json' : '.po'\n\n const outDir = resolve(cwd, config.compileOutDir)\n mkdirSync(outDir, { recursive: true })\n\n const pluginRunner = config.plugins?.length\n ? createPluginRunner(config.plugins)\n : undefined\n\n const allCatalogs: Record<string, CatalogData> = {}\n for (const locale of localeCodes) {\n const catalogPath = resolve(cwd, config.catalogDir, `${locale}${ext}`)\n allCatalogs[locale] = readCatalog(catalogPath, config.format)\n }\n\n const allIds = collectAllIds(allCatalogs)\n\n // Run plugin hooks around compilation\n for (const locale of localeCodes) {\n if (pluginRunner) {\n const compileContext: PluginCompileContext = {\n locale,\n messages: catalogToMessages(allCatalogs[locale]!),\n outDir,\n config,\n }\n await pluginRunner.runBeforeCompile(compileContext)\n }\n }\n\n if (options?.parallel && localeCodes.length > 1) {\n const tasks = localeCodes.map((locale) => ({\n locale,\n catalog: allCatalogs[locale]!,\n allIds,\n sourceLocale: config.sourceLocale,\n }))\n\n const results = await parallelCompile(tasks)\n\n for (const result of results) {\n writeFileSync(resolve(outDir, `${result.locale}.js`), result.code, 'utf-8')\n }\n } else {\n for (const locale of localeCodes) {\n const { code } = compileCatalog(allCatalogs[locale]!, locale, allIds, config.sourceLocale)\n writeFileSync(resolve(outDir, `${locale}.js`), code, 'utf-8')\n }\n }\n\n const indexCode = compileIndex(localeCodes, config.compileOutDir)\n writeFileSync(resolve(outDir, 'index.js'), indexCode, 'utf-8')\n\n const typesCode = compileTypeDeclaration(allIds, allCatalogs, config.sourceLocale)\n writeFileSync(resolve(outDir, 'messages.d.ts'), typesCode, 'utf-8')\n\n // Run after-compile hooks\n for (const locale of localeCodes) {\n if (pluginRunner) {\n const compileContext: PluginCompileContext = {\n locale,\n messages: catalogToMessages(allCatalogs[locale]!),\n outDir,\n config,\n }\n await pluginRunner.runAfterCompile(compileContext)\n }\n }\n}\n","import fg from 'fast-glob'\nimport { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { resolve, dirname, extname } from 'node:path'\nimport { extractFromTsx } from './tsx-extractor'\nimport { updateCatalog } from './catalog'\nimport type { CatalogData } from './catalog'\nimport { readJsonCatalog, writeJsonCatalog } from './json-format'\nimport { readPoCatalog, writePoCatalog } from './po-format'\nimport { ExtractCache } from './extract-cache'\nimport { loadConfig } from './config-loader'\nimport type { ExtractedMessage } from '@fluenti/core/compiler'\nimport { resolveLocaleCodes, createPluginRunner } from '@fluenti/core/compiler'\nimport type { PluginExtractContext } from '@fluenti/core/compiler'\n\nfunction deriveProjectId(cwd: string): string {\n return createHash('md5').update(cwd).digest('hex').slice(0, 8)\n}\n\nexport interface RunExtractOptions {\n clean?: boolean\n stripFuzzy?: boolean\n useCache?: boolean\n}\n\nfunction readCatalog(filePath: string, format: 'json' | 'po'): CatalogData {\n if (!existsSync(filePath)) return {}\n const content = readFileSync(filePath, 'utf-8')\n return format === 'json' ? readJsonCatalog(content) : readPoCatalog(content)\n}\n\nfunction writeCatalog(filePath: string, catalog: CatalogData, format: 'json' | 'po'): void {\n const content = format === 'json' ? writeJsonCatalog(catalog) : writePoCatalog(catalog)\n try {\n mkdirSync(dirname(filePath), { recursive: true })\n writeFileSync(filePath, content, 'utf-8')\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(`Failed to write catalog \"${filePath}\": ${message}`)\n }\n}\n\nasync function extractFromFile(filePath: string, code: string): Promise<ExtractedMessage[]> {\n const ext = extname(filePath)\n if (ext === '.vue') {\n try {\n const { extractFromVue } = await import('./vue-extractor')\n return extractFromVue(code, filePath)\n } catch {\n return []\n }\n }\n return extractFromTsx(code, filePath)\n}\n\n/**\n * Programmatic extract entry point.\n * Loads config from `cwd`, extracts messages, and writes catalogs.\n * This is the in-process equivalent of `fluenti extract`.\n */\nexport async function runExtract(cwd: string, options?: RunExtractOptions): Promise<void> {\n const config = await loadConfig(undefined, cwd)\n const localeCodes = resolveLocaleCodes(config.locales)\n\n const files = await fg(config.include, { cwd, ignore: config.exclude ?? [], absolute: false })\n const allMessages: ExtractedMessage[] = []\n const useCache = options?.useCache !== false\n const cache = useCache ? new ExtractCache(resolve(cwd, config.catalogDir), deriveProjectId(cwd)) : null\n\n for (const file of files) {\n const absFile = resolve(cwd, file)\n if (cache) {\n const cached = cache.get(absFile)\n if (cached) {\n allMessages.push(...cached)\n continue\n }\n }\n\n const code = readFileSync(absFile, 'utf-8')\n const messages = await extractFromFile(absFile, code)\n allMessages.push(...messages)\n\n if (cache) {\n cache.set(absFile, messages)\n }\n }\n\n if (cache) {\n cache.prune(new Set(files.map((f) => resolve(cwd, f))))\n cache.save()\n }\n\n // Run onAfterExtract plugin hooks\n const pluginRunner = config.plugins?.length\n ? createPluginRunner(config.plugins)\n : undefined\n\n if (pluginRunner) {\n const messageMap = new Map<string, ExtractedMessage>()\n for (const msg of allMessages) {\n messageMap.set(msg.id, msg)\n }\n const extractContext: PluginExtractContext = {\n messages: messageMap,\n sourceLocale: config.sourceLocale,\n targetLocales: localeCodes.filter((l) => l !== config.sourceLocale),\n config,\n }\n await pluginRunner.runAfterExtract(extractContext)\n }\n\n const ext = config.format === 'json' ? '.json' : '.po'\n const clean = options?.clean ?? false\n const stripFuzzy = options?.stripFuzzy ?? false\n\n for (const locale of localeCodes) {\n const catalogPath = resolve(cwd, config.catalogDir, `${locale}${ext}`)\n const existing = readCatalog(catalogPath, config.format)\n const { catalog } = updateCatalog(existing, allMessages, { stripFuzzy })\n\n const finalCatalog = clean\n ? Object.fromEntries(Object.entries(catalog).filter(([, entry]) => !entry.obsolete))\n : catalog\n\n writeCatalog(catalogPath, finalCatalog, config.format)\n }\n}\n"],"mappings":";;;;;;;;;AAoBA,SAAgB,EAAa,GAAkE;AAC7F,QAAO;;;;ACVT,SAAS,EAAY,GAAkB,GAAoC;AACzE,KAAI,C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,cAAc;AAE1C,MAAK,IAAM,KAAU,GAAa;EAChC,IAAM,IAAc,EAAQ,GAAK,EAAO,YAAY,GAAG,IAAS,IAAM,EAEhE,EAAE,eAAY,EADH,EAAY,GAAa,EAAO,OAAO,EACZ,GAAa,EAAE,eAAY,CAAC;AAMxE,IAAa,GAJQ,IACjB,OAAO,YAAY,OAAO,QAAQ,EAAQ,CAAC,QAAQ,GAAG,OAAW,CAAC,EAAM,SAAS,CAAC,GAClF,GAEoC,EAAO,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsx-extractor-AOjsbOmp.cjs","names":[],"sources":["../src/tsx-extractor.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core/compiler'\nimport {\n createMessageId,\n isSourceNode,\n parseSourceModule,\n walkSourceAst,\n type SourceNode,\n} from '@fluenti/core/transform'\n\ninterface IdentifierNode extends SourceNode {\n type: 'Identifier'\n name: string\n}\n\ninterface StringLiteralNode extends SourceNode {\n type: 'StringLiteral'\n value: string\n}\n\ninterface NumericLiteralNode extends SourceNode {\n type: 'NumericLiteral'\n value: number\n}\n\ninterface TemplateElementNode extends SourceNode {\n type: 'TemplateElement'\n value: { raw: string; cooked: string | null }\n}\n\ninterface TemplateLiteralNode extends SourceNode {\n type: 'TemplateLiteral'\n quasis: TemplateElementNode[]\n expressions: SourceNode[]\n}\n\ninterface TaggedTemplateExpressionNode extends SourceNode {\n type: 'TaggedTemplateExpression'\n tag: SourceNode\n quasi: TemplateLiteralNode\n}\n\ninterface CallExpressionNode extends SourceNode {\n type: 'CallExpression'\n callee: SourceNode\n arguments: SourceNode[]\n}\n\ninterface ImportDeclarationNode extends SourceNode {\n type: 'ImportDeclaration'\n source: StringLiteralNode\n specifiers: SourceNode[]\n}\n\ninterface ImportSpecifierNode extends SourceNode {\n type: 'ImportSpecifier'\n imported: IdentifierNode | StringLiteralNode\n local: IdentifierNode\n}\n\ninterface ObjectExpressionNode extends SourceNode {\n type: 'ObjectExpression'\n properties: SourceNode[]\n}\n\ninterface ObjectPropertyNode extends SourceNode {\n type: 'ObjectProperty'\n key: SourceNode\n value: SourceNode\n computed?: boolean\n}\n\ninterface JSXElementNode extends SourceNode {\n type: 'JSXElement'\n openingElement: JSXOpeningElementNode\n children: SourceNode[]\n}\n\ninterface JSXFragmentNode extends SourceNode {\n type: 'JSXFragment'\n children: SourceNode[]\n}\n\ninterface JSXOpeningElementNode extends SourceNode {\n type: 'JSXOpeningElement'\n name: SourceNode\n attributes: SourceNode[]\n}\n\ninterface JSXAttributeNode extends SourceNode {\n type: 'JSXAttribute'\n name: SourceNode\n value?: SourceNode | null\n}\n\ninterface JSXExpressionContainerNode extends SourceNode {\n type: 'JSXExpressionContainer'\n expression: SourceNode\n}\n\ninterface JSXTextNode extends SourceNode {\n type: 'JSXText'\n value: string\n}\n\ninterface ExtractedDescriptor {\n id: string\n message?: string\n context?: string\n comment?: string\n}\n\nconst DIRECT_T_SOURCES = new Set([\n '@fluenti/core',\n '@fluenti/react',\n '@fluenti/vue',\n '@fluenti/solid',\n '@fluenti/next',\n])\n\nfunction classifyExpression(expr: string): string {\n const trimmed = expr.trim()\n // Simple identifier: name, count\n if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {\n return trimmed\n }\n // Dotted path: user.name → name\n if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(trimmed) && !trimmed.endsWith('.')) {\n const parts = trimmed.split('.')\n return parts[parts.length - 1]!\n }\n // Function call: fun() → fun, obj.method() → obj_method\n const callMatch = trimmed.match(/^([a-zA-Z_$][a-zA-Z0-9_$.]*)\\s*\\(/)\n if (callMatch) {\n return callMatch[1]!.replace(/\\./g, '_')\n }\n return ''\n}\n\nfunction buildICUFromTemplate(\n strings: readonly string[],\n expressions: readonly string[],\n): string {\n let result = ''\n let positionalIndex = 0\n\n for (let index = 0; index < strings.length; index++) {\n result += strings[index]!\n if (index >= expressions.length) continue\n\n const name = classifyExpression(expressions[index]!)\n if (name === '') {\n result += `{arg${positionalIndex}}`\n positionalIndex++\n continue\n }\n\n result += `{${name}}`\n }\n\n return result\n}\n\nfunction createExtractedMessage(\n descriptor: ExtractedDescriptor,\n filename: string,\n node: SourceNode,\n): ExtractedMessage | undefined {\n if (!descriptor.message) {\n return undefined\n }\n\n const line = node.loc?.start.line ?? 1\n const column = (node.loc?.start.column ?? 0) + 1\n\n return {\n id: descriptor.id,\n message: descriptor.message,\n ...(descriptor.context !== undefined ? { context: descriptor.context } : {}),\n ...(descriptor.comment !== undefined ? { comment: descriptor.comment } : {}),\n origin: { file: filename, line, column },\n }\n}\n\nfunction descriptorFromStaticParts(\n parts: {\n id?: string\n message?: string\n context?: string\n comment?: string\n },\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor | undefined {\n if (!parts.message) {\n return undefined\n }\n\n const generateId = idGenerator ?? createMessageId\n\n return {\n id: parts.id ?? generateId(parts.message, parts.context),\n message: parts.message,\n ...(parts.context !== undefined ? { context: parts.context } : {}),\n ...(parts.comment !== undefined ? { comment: parts.comment } : {}),\n }\n}\n\nfunction extractDescriptorFromCallArgument(\n argument: SourceNode,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor | undefined {\n if (argument.type === 'StringLiteral') {\n return descriptorFromStaticParts({ message: (argument as StringLiteralNode).value }, idGenerator)\n }\n\n if (argument.type === 'TemplateLiteral') {\n const template = argument as TemplateLiteralNode\n if (template.expressions.length === 0) {\n const message = template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join('')\n return descriptorFromStaticParts({ message }, idGenerator)\n }\n return undefined\n }\n\n if (argument.type !== 'ObjectExpression') {\n return undefined\n }\n\n const staticParts: { id?: string; message?: string; context?: string; comment?: string } = {}\n for (const property of (argument as ObjectExpressionNode).properties) {\n if (property.type !== 'ObjectProperty') continue\n\n const objectProperty = property as ObjectPropertyNode\n if (objectProperty.computed || !isIdentifier(objectProperty.key)) continue\n\n const key = objectProperty.key.name\n if (!['id', 'message', 'context', 'comment'].includes(key)) continue\n\n const value = readStaticStringValue(objectProperty.value)\n if (value === undefined) continue\n staticParts[key as keyof typeof staticParts] = value\n }\n\n if (!staticParts.message) {\n return undefined\n }\n\n return descriptorFromStaticParts(staticParts, idGenerator)\n}\n\nconst SELECT_RESERVED_PROPS = new Set(['id', 'value', 'context', 'comment', 'options', 'other', 'tag'])\n\nfunction buildSelectICU(varName: string, cases: Record<string, string>, other: string): string {\n const options: string[] = []\n for (const [key, value] of Object.entries(cases)) {\n options.push(`${key} {${value}}`)\n }\n options.push(`other {${other}}`)\n return `{${varName}, select, ${options.join(' ')}}`\n}\n\nfunction extractSelectProps(\n openingElement: JSXOpeningElementNode,\n code: string,\n): { varName: string | undefined; id: string | undefined; context: string | undefined; comment: string | undefined; cases: Record<string, string>; other: string | undefined } {\n let varName: string | undefined\n let id: string | undefined\n let context: string | undefined\n let comment: string | undefined\n let other: string | undefined\n const cases: Record<string, string> = {}\n\n for (const attribute of openingElement.attributes) {\n if (attribute.type !== 'JSXAttribute') continue\n const attr = attribute as JSXAttributeNode\n if (attr.name.type !== 'JSXIdentifier') continue\n const name = String(attr.name['name'])\n\n if (name === 'id') {\n id = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (name === 'value') {\n const raw = attr.value ? (readStaticStringValue(attr.value) ?? readExpressionSource(attr.value, code)) : undefined\n varName = raw ? classifyExpression(raw) || raw : undefined\n continue\n }\n if (name === 'context') {\n context = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (name === 'comment') {\n comment = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (name === 'other') {\n other = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (SELECT_RESERVED_PROPS.has(name)) continue\n\n const staticValue = attr.value ? readStaticStringValue(attr.value) : undefined\n if (staticValue === undefined) continue\n\n cases[name] = staticValue\n }\n\n return { varName, id, context, comment, cases, other }\n}\n\nfunction buildPluralICU(props: Record<string, string>): string {\n const categories = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n const countVar = props['value'] ?? props['count'] ?? 'count'\n const options: string[] = []\n const offset = props['offset']\n\n for (const category of categories) {\n const value = props[category]\n if (value === undefined) continue\n const key = category === 'zero' ? '=0' : category\n options.push(`${key} {${value}}`)\n }\n\n if (options.length === 0) {\n return ''\n }\n\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{${countVar}, plural, ${offsetPrefix}${options.join(' ')}}`\n}\n\nfunction extractRichTextMessage(children: readonly SourceNode[]): string | undefined {\n let nextIndex = 0\n\n function render(nodes: readonly SourceNode[]): string | undefined {\n let message = ''\n\n for (const node of nodes) {\n if (node.type === 'JSXText') {\n message += normalizeJsxText((node as JSXTextNode).value)\n continue\n }\n\n if (node.type === 'JSXElement') {\n const idx = nextIndex++\n const inner = render((node as JSXElementNode).children)\n if (inner === undefined) return undefined\n message += `<${idx}>${inner}</${idx}>`\n continue\n }\n\n if (node.type === 'JSXFragment') {\n const inner = render((node as JSXFragmentNode).children)\n if (inner === undefined) return undefined\n message += inner\n continue\n }\n\n if (node.type === 'JSXExpressionContainer') {\n const expression = (node as JSXExpressionContainerNode).expression\n if (expression.type === 'StringLiteral') {\n message += (expression as StringLiteralNode).value\n continue\n }\n if (expression.type === 'NumericLiteral') {\n message += String((expression as NumericLiteralNode).value)\n continue\n }\n return undefined\n }\n }\n\n return message\n }\n\n const message = render(children)\n if (message === undefined) return undefined\n\n const normalized = message.replace(/\\s+/g, ' ').trim()\n return normalized || undefined\n}\n\nfunction normalizeJsxText(value: string): string {\n return value.replace(/\\s+/g, ' ')\n}\n\nfunction readStaticStringValue(node: SourceNode): string | undefined {\n if (node.type === 'StringLiteral') {\n return (node as StringLiteralNode).value\n }\n\n if (node.type === 'NumericLiteral') {\n return String((node as NumericLiteralNode).value)\n }\n\n if (node.type === 'JSXExpressionContainer') {\n return readStaticStringValue((node as JSXExpressionContainerNode).expression)\n }\n\n if (node.type === 'TemplateLiteral') {\n const template = node as TemplateLiteralNode\n if (template.expressions.length === 0) {\n return template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join('')\n }\n }\n\n return undefined\n}\n\nfunction readExpressionSource(node: SourceNode, code: string): string | undefined {\n if (node.start == null || node.end == null) {\n return undefined\n }\n\n if (node.type === 'JSXExpressionContainer') {\n return readExpressionSource((node as JSXExpressionContainerNode).expression, code)\n }\n\n return code.slice(node.start, node.end).trim()\n}\n\nfunction getJsxAttribute(\n openingElement: JSXOpeningElementNode,\n name: string,\n): JSXAttributeNode | undefined {\n for (const attribute of openingElement.attributes) {\n if (attribute.type !== 'JSXAttribute') continue\n\n const jsxAttribute = attribute as JSXAttributeNode\n if (jsxAttribute.name.type === 'JSXIdentifier' && jsxAttribute.name['name'] === name) {\n return jsxAttribute\n }\n }\n\n return undefined\n}\n\nfunction extractPluralProps(\n openingElement: JSXOpeningElementNode,\n code: string,\n): Record<string, string> {\n const props: Record<string, string> = {}\n const propNames = ['id', 'value', 'count', 'offset', 'zero', 'one', 'two', 'few', 'many', 'other']\n\n for (const name of propNames) {\n const attribute = getJsxAttribute(openingElement, name)\n if (!attribute?.value) continue\n\n const staticValue = readStaticStringValue(attribute.value)\n if (staticValue !== undefined) {\n props[name] = staticValue\n continue\n }\n\n const exprValue = readExpressionSource(attribute.value, code)\n if (exprValue !== undefined && (name === 'value' || name === 'count' || name === 'offset')) {\n props[name] = exprValue\n }\n }\n\n return props\n}\n\nfunction extractTaggedTemplateMessage(\n code: string,\n node: TaggedTemplateExpressionNode,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor {\n const strings = node.quasi.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw)\n const expressions = node.quasi.expressions.map((expression) => {\n if (expression.start == null || expression.end == null) {\n return ''\n }\n return code.slice(expression.start, expression.end)\n })\n const message = buildICUFromTemplate(strings, expressions)\n const generateId = idGenerator ?? createMessageId\n\n return {\n id: generateId(message),\n message,\n }\n}\n\nfunction collectDirectBindings(ast: SourceNode): Map<string, 't' | 'msg'> {\n const bindings = new Map<string, 't' | 'msg'>()\n const body = Array.isArray(ast['body']) ? ast['body'] : []\n\n for (const entry of body) {\n if (!isImportDeclaration(entry)) continue\n if (!DIRECT_T_SOURCES.has(entry.source.value)) continue\n\n for (const specifier of entry.specifiers) {\n if (!isImportSpecifier(specifier)) continue\n const importedName = readImportedName(specifier)\n if (importedName === 't' || importedName === 'msg') {\n bindings.set(specifier.local.name, importedName as 't' | 'msg')\n }\n }\n }\n\n return bindings\n}\n\nexport function extractFromTsx(\n code: string,\n filename: string,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedMessage[] {\n const ast = parseSourceModule(code)\n if (!ast) {\n console.warn(`[fluenti] Failed to parse ${filename} — skipping message extraction`)\n return []\n }\n\n const messages: ExtractedMessage[] = []\n const directBindings = collectDirectBindings(ast)\n\n walkSourceAst(ast, (node: SourceNode) => {\n if (node.type === 'TaggedTemplateExpression') {\n const tagged = node as TaggedTemplateExpressionNode\n if (\n isIdentifier(tagged.tag)\n && (tagged.tag.name === 't' || directBindings.has(tagged.tag.name))\n ) {\n const descriptor = extractTaggedTemplateMessage(code, tagged, idGenerator)\n const bindingType = directBindings.get(tagged.tag.name)\n if (bindingType === 'msg') {\n descriptor.comment = 'msg tagged template'\n }\n const extracted = createExtractedMessage(\n descriptor,\n filename,\n tagged,\n )\n if (extracted) {\n messages.push(extracted)\n }\n }\n return\n }\n\n if (node.type === 'CallExpression') {\n const call = node as CallExpressionNode\n const callBindingType = directBindings.get(call.callee && isIdentifier(call.callee) ? call.callee.name : '')\n if (isIdentifier(call.callee) && (call.callee.name === 't' || (directBindings.has(call.callee.name) && callBindingType === 't'))) {\n if (directBindings.has(call.callee.name) && call.arguments[0]?.type !== 'ObjectExpression') {\n return\n }\n const descriptor = call.arguments[0] ? extractDescriptorFromCallArgument(call.arguments[0], idGenerator) : undefined\n const extracted = descriptor\n ? createExtractedMessage(descriptor, filename, call)\n : undefined\n if (extracted) {\n messages.push(extracted)\n }\n } else if (\n call.callee.type === 'MemberExpression'\n && isIdentifier(call.callee['object'])\n && directBindings.get((call.callee['object'] as IdentifierNode).name) === 'msg'\n && isIdentifier(call.callee['property'])\n && (call.callee['property'] as IdentifierNode).name === 'descriptor'\n && call.arguments[0]\n ) {\n const descriptor = extractDescriptorFromCallArgument(call.arguments[0], idGenerator)\n const extracted = descriptor ? createExtractedMessage(descriptor, filename, call) : undefined\n if (extracted) {\n messages.push(extracted)\n }\n }\n return\n }\n\n if (node.type !== 'JSXElement') {\n return\n }\n\n const element = node as JSXElementNode\n const openingElement = element.openingElement\n const elementName = readJsxElementName(openingElement.name)\n\n if (elementName === 'Trans') {\n const messageAttr = getJsxAttribute(openingElement, 'message')\n const idAttr = getJsxAttribute(openingElement, 'id')\n const contextAttr = getJsxAttribute(openingElement, 'context')\n const commentAttr = getJsxAttribute(openingElement, 'comment')\n\n const descriptor = messageAttr?.value\n ? buildStaticTransDescriptor({\n id: idAttr?.value ? readStaticStringValue(idAttr.value) : undefined,\n message: readStaticStringValue(messageAttr.value),\n context: contextAttr?.value ? readStaticStringValue(contextAttr.value) : undefined,\n comment: commentAttr?.value ? readStaticStringValue(commentAttr.value) : undefined,\n }, idGenerator)\n : buildStaticTransDescriptor({\n id: idAttr?.value ? readStaticStringValue(idAttr.value) : undefined,\n message: extractRichTextMessage(element.children),\n context: contextAttr?.value ? readStaticStringValue(contextAttr.value) : undefined,\n comment: commentAttr?.value ? readStaticStringValue(commentAttr.value) : undefined,\n }, idGenerator)\n\n const extracted = descriptor\n ? createExtractedMessage(descriptor, filename, element)\n : undefined\n if (extracted) {\n messages.push(extracted)\n }\n return\n }\n\n if (elementName === 'Plural') {\n const props = extractPluralProps(openingElement, code)\n const message = buildPluralICU(props)\n if (!message) {\n return\n }\n\n const generateId = idGenerator ?? createMessageId\n const extracted = createExtractedMessage(\n {\n id: props['id'] ?? generateId(message),\n message,\n },\n filename,\n element,\n )\n if (extracted) {\n messages.push(extracted)\n }\n return\n }\n\n if (elementName === 'Select') {\n const { varName, id, context, comment, cases, other } = extractSelectProps(openingElement, code)\n if (!varName || !other || Object.keys(cases).length === 0) {\n return\n }\n\n const message = buildSelectICU(varName, cases, other)\n const generateId = idGenerator ?? createMessageId\n const extracted = createExtractedMessage(\n {\n id: id ?? generateId(message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n filename,\n element,\n )\n if (extracted) {\n messages.push(extracted)\n }\n }\n })\n\n return messages\n}\n\nfunction isImportDeclaration(node: unknown): node is ImportDeclarationNode {\n return isSourceNode(node) && node.type === 'ImportDeclaration'\n}\n\nfunction isImportSpecifier(node: unknown): node is ImportSpecifierNode {\n return isSourceNode(node) && node.type === 'ImportSpecifier'\n}\n\nfunction readImportedName(specifier: ImportSpecifierNode): string | undefined {\n if (specifier.imported.type === 'Identifier') {\n return (specifier.imported as IdentifierNode).name\n }\n if (specifier.imported.type === 'StringLiteral') {\n return (specifier.imported as StringLiteralNode).value\n }\n return undefined\n}\n\nfunction readJsxElementName(node: SourceNode): string | undefined {\n if (node.type === 'JSXIdentifier') {\n return String(node['name'])\n }\n return undefined\n}\n\nfunction buildStaticTransDescriptor(\n parts: {\n id: string | undefined\n message: string | undefined\n context: string | undefined\n comment: string | undefined\n },\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor | undefined {\n const payload: {\n id?: string\n message?: string\n context?: string\n comment?: string\n } = {}\n\n if (parts.id !== undefined) payload.id = parts.id\n if (parts.message !== undefined) payload.message = parts.message\n if (parts.context !== undefined) payload.context = parts.context\n if (parts.comment !== undefined) payload.comment = parts.comment\n\n return descriptorFromStaticParts(payload, idGenerator)\n}\n\nfunction isIdentifier(node: unknown): node is IdentifierNode {\n return isSourceNode(node) && node.type === 'Identifier'\n}\n"],"mappings":"0EA+GA,IAAM,EAAmB,IAAI,IAAI,CAC/B,gBACA,iBACA,eACA,iBACA,gBACD,CAAC,CAEF,SAAS,EAAmB,EAAsB,CAChD,IAAM,EAAU,EAAK,MAAM,C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AA+B,MAKrD,SAAS,EAAmB,EAAsC,CAChE,GAAI,EAAK,OAAS,gBAChB,OAAO,OAAO,EAAK,KAAQ,CAK/B,SAAS,EACP,EAMA,EACiC,CACjC,IAAM,EAKF,EAAE,CAON,OALI,EAAM,KAAO,IAAA,KAAW,EAAQ,GAAK,EAAM,IAC3C,EAAM,UAAY,IAAA,KAAW,EAAQ,QAAU,EAAM,SACrD,EAAM,UAAY,IAAA,KAAW,EAAQ,QAAU,EAAM,SACrD,EAAM,UAAY,IAAA,KAAW,EAAQ,QAAU,EAAM,SAElD,EAA0B,EAAS,EAAY,CAGxD,SAAS,EAAa,EAAuC,CAC3D,OAAA,EAAA,EAAA,cAAoB,EAAK,EAAI,EAAK,OAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsx-extractor-C-HZNobu.js","names":[],"sources":["../src/tsx-extractor.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core/compiler'\nimport {\n createMessageId,\n isSourceNode,\n parseSourceModule,\n walkSourceAst,\n type SourceNode,\n} from '@fluenti/core/transform'\n\ninterface IdentifierNode extends SourceNode {\n type: 'Identifier'\n name: string\n}\n\ninterface StringLiteralNode extends SourceNode {\n type: 'StringLiteral'\n value: string\n}\n\ninterface NumericLiteralNode extends SourceNode {\n type: 'NumericLiteral'\n value: number\n}\n\ninterface TemplateElementNode extends SourceNode {\n type: 'TemplateElement'\n value: { raw: string; cooked: string | null }\n}\n\ninterface TemplateLiteralNode extends SourceNode {\n type: 'TemplateLiteral'\n quasis: TemplateElementNode[]\n expressions: SourceNode[]\n}\n\ninterface TaggedTemplateExpressionNode extends SourceNode {\n type: 'TaggedTemplateExpression'\n tag: SourceNode\n quasi: TemplateLiteralNode\n}\n\ninterface CallExpressionNode extends SourceNode {\n type: 'CallExpression'\n callee: SourceNode\n arguments: SourceNode[]\n}\n\ninterface ImportDeclarationNode extends SourceNode {\n type: 'ImportDeclaration'\n source: StringLiteralNode\n specifiers: SourceNode[]\n}\n\ninterface ImportSpecifierNode extends SourceNode {\n type: 'ImportSpecifier'\n imported: IdentifierNode | StringLiteralNode\n local: IdentifierNode\n}\n\ninterface ObjectExpressionNode extends SourceNode {\n type: 'ObjectExpression'\n properties: SourceNode[]\n}\n\ninterface ObjectPropertyNode extends SourceNode {\n type: 'ObjectProperty'\n key: SourceNode\n value: SourceNode\n computed?: boolean\n}\n\ninterface JSXElementNode extends SourceNode {\n type: 'JSXElement'\n openingElement: JSXOpeningElementNode\n children: SourceNode[]\n}\n\ninterface JSXFragmentNode extends SourceNode {\n type: 'JSXFragment'\n children: SourceNode[]\n}\n\ninterface JSXOpeningElementNode extends SourceNode {\n type: 'JSXOpeningElement'\n name: SourceNode\n attributes: SourceNode[]\n}\n\ninterface JSXAttributeNode extends SourceNode {\n type: 'JSXAttribute'\n name: SourceNode\n value?: SourceNode | null\n}\n\ninterface JSXExpressionContainerNode extends SourceNode {\n type: 'JSXExpressionContainer'\n expression: SourceNode\n}\n\ninterface JSXTextNode extends SourceNode {\n type: 'JSXText'\n value: string\n}\n\ninterface ExtractedDescriptor {\n id: string\n message?: string\n context?: string\n comment?: string\n}\n\nconst DIRECT_T_SOURCES = new Set([\n '@fluenti/core',\n '@fluenti/react',\n '@fluenti/vue',\n '@fluenti/solid',\n '@fluenti/next',\n])\n\nfunction classifyExpression(expr: string): string {\n const trimmed = expr.trim()\n // Simple identifier: name, count\n if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(trimmed)) {\n return trimmed\n }\n // Dotted path: user.name → name\n if (/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/.test(trimmed) && !trimmed.endsWith('.')) {\n const parts = trimmed.split('.')\n return parts[parts.length - 1]!\n }\n // Function call: fun() → fun, obj.method() → obj_method\n const callMatch = trimmed.match(/^([a-zA-Z_$][a-zA-Z0-9_$.]*)\\s*\\(/)\n if (callMatch) {\n return callMatch[1]!.replace(/\\./g, '_')\n }\n return ''\n}\n\nfunction buildICUFromTemplate(\n strings: readonly string[],\n expressions: readonly string[],\n): string {\n let result = ''\n let positionalIndex = 0\n\n for (let index = 0; index < strings.length; index++) {\n result += strings[index]!\n if (index >= expressions.length) continue\n\n const name = classifyExpression(expressions[index]!)\n if (name === '') {\n result += `{arg${positionalIndex}}`\n positionalIndex++\n continue\n }\n\n result += `{${name}}`\n }\n\n return result\n}\n\nfunction createExtractedMessage(\n descriptor: ExtractedDescriptor,\n filename: string,\n node: SourceNode,\n): ExtractedMessage | undefined {\n if (!descriptor.message) {\n return undefined\n }\n\n const line = node.loc?.start.line ?? 1\n const column = (node.loc?.start.column ?? 0) + 1\n\n return {\n id: descriptor.id,\n message: descriptor.message,\n ...(descriptor.context !== undefined ? { context: descriptor.context } : {}),\n ...(descriptor.comment !== undefined ? { comment: descriptor.comment } : {}),\n origin: { file: filename, line, column },\n }\n}\n\nfunction descriptorFromStaticParts(\n parts: {\n id?: string\n message?: string\n context?: string\n comment?: string\n },\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor | undefined {\n if (!parts.message) {\n return undefined\n }\n\n const generateId = idGenerator ?? createMessageId\n\n return {\n id: parts.id ?? generateId(parts.message, parts.context),\n message: parts.message,\n ...(parts.context !== undefined ? { context: parts.context } : {}),\n ...(parts.comment !== undefined ? { comment: parts.comment } : {}),\n }\n}\n\nfunction extractDescriptorFromCallArgument(\n argument: SourceNode,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor | undefined {\n if (argument.type === 'StringLiteral') {\n return descriptorFromStaticParts({ message: (argument as StringLiteralNode).value }, idGenerator)\n }\n\n if (argument.type === 'TemplateLiteral') {\n const template = argument as TemplateLiteralNode\n if (template.expressions.length === 0) {\n const message = template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join('')\n return descriptorFromStaticParts({ message }, idGenerator)\n }\n return undefined\n }\n\n if (argument.type !== 'ObjectExpression') {\n return undefined\n }\n\n const staticParts: { id?: string; message?: string; context?: string; comment?: string } = {}\n for (const property of (argument as ObjectExpressionNode).properties) {\n if (property.type !== 'ObjectProperty') continue\n\n const objectProperty = property as ObjectPropertyNode\n if (objectProperty.computed || !isIdentifier(objectProperty.key)) continue\n\n const key = objectProperty.key.name\n if (!['id', 'message', 'context', 'comment'].includes(key)) continue\n\n const value = readStaticStringValue(objectProperty.value)\n if (value === undefined) continue\n staticParts[key as keyof typeof staticParts] = value\n }\n\n if (!staticParts.message) {\n return undefined\n }\n\n return descriptorFromStaticParts(staticParts, idGenerator)\n}\n\nconst SELECT_RESERVED_PROPS = new Set(['id', 'value', 'context', 'comment', 'options', 'other', 'tag'])\n\nfunction buildSelectICU(varName: string, cases: Record<string, string>, other: string): string {\n const options: string[] = []\n for (const [key, value] of Object.entries(cases)) {\n options.push(`${key} {${value}}`)\n }\n options.push(`other {${other}}`)\n return `{${varName}, select, ${options.join(' ')}}`\n}\n\nfunction extractSelectProps(\n openingElement: JSXOpeningElementNode,\n code: string,\n): { varName: string | undefined; id: string | undefined; context: string | undefined; comment: string | undefined; cases: Record<string, string>; other: string | undefined } {\n let varName: string | undefined\n let id: string | undefined\n let context: string | undefined\n let comment: string | undefined\n let other: string | undefined\n const cases: Record<string, string> = {}\n\n for (const attribute of openingElement.attributes) {\n if (attribute.type !== 'JSXAttribute') continue\n const attr = attribute as JSXAttributeNode\n if (attr.name.type !== 'JSXIdentifier') continue\n const name = String(attr.name['name'])\n\n if (name === 'id') {\n id = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (name === 'value') {\n const raw = attr.value ? (readStaticStringValue(attr.value) ?? readExpressionSource(attr.value, code)) : undefined\n varName = raw ? classifyExpression(raw) || raw : undefined\n continue\n }\n if (name === 'context') {\n context = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (name === 'comment') {\n comment = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (name === 'other') {\n other = attr.value ? readStaticStringValue(attr.value) : undefined\n continue\n }\n if (SELECT_RESERVED_PROPS.has(name)) continue\n\n const staticValue = attr.value ? readStaticStringValue(attr.value) : undefined\n if (staticValue === undefined) continue\n\n cases[name] = staticValue\n }\n\n return { varName, id, context, comment, cases, other }\n}\n\nfunction buildPluralICU(props: Record<string, string>): string {\n const categories = ['zero', 'one', 'two', 'few', 'many', 'other'] as const\n const countVar = props['value'] ?? props['count'] ?? 'count'\n const options: string[] = []\n const offset = props['offset']\n\n for (const category of categories) {\n const value = props[category]\n if (value === undefined) continue\n const key = category === 'zero' ? '=0' : category\n options.push(`${key} {${value}}`)\n }\n\n if (options.length === 0) {\n return ''\n }\n\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{${countVar}, plural, ${offsetPrefix}${options.join(' ')}}`\n}\n\nfunction extractRichTextMessage(children: readonly SourceNode[]): string | undefined {\n let nextIndex = 0\n\n function render(nodes: readonly SourceNode[]): string | undefined {\n let message = ''\n\n for (const node of nodes) {\n if (node.type === 'JSXText') {\n message += normalizeJsxText((node as JSXTextNode).value)\n continue\n }\n\n if (node.type === 'JSXElement') {\n const idx = nextIndex++\n const inner = render((node as JSXElementNode).children)\n if (inner === undefined) return undefined\n message += `<${idx}>${inner}</${idx}>`\n continue\n }\n\n if (node.type === 'JSXFragment') {\n const inner = render((node as JSXFragmentNode).children)\n if (inner === undefined) return undefined\n message += inner\n continue\n }\n\n if (node.type === 'JSXExpressionContainer') {\n const expression = (node as JSXExpressionContainerNode).expression\n if (expression.type === 'StringLiteral') {\n message += (expression as StringLiteralNode).value\n continue\n }\n if (expression.type === 'NumericLiteral') {\n message += String((expression as NumericLiteralNode).value)\n continue\n }\n return undefined\n }\n }\n\n return message\n }\n\n const message = render(children)\n if (message === undefined) return undefined\n\n const normalized = message.replace(/\\s+/g, ' ').trim()\n return normalized || undefined\n}\n\nfunction normalizeJsxText(value: string): string {\n return value.replace(/\\s+/g, ' ')\n}\n\nfunction readStaticStringValue(node: SourceNode): string | undefined {\n if (node.type === 'StringLiteral') {\n return (node as StringLiteralNode).value\n }\n\n if (node.type === 'NumericLiteral') {\n return String((node as NumericLiteralNode).value)\n }\n\n if (node.type === 'JSXExpressionContainer') {\n return readStaticStringValue((node as JSXExpressionContainerNode).expression)\n }\n\n if (node.type === 'TemplateLiteral') {\n const template = node as TemplateLiteralNode\n if (template.expressions.length === 0) {\n return template.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw).join('')\n }\n }\n\n return undefined\n}\n\nfunction readExpressionSource(node: SourceNode, code: string): string | undefined {\n if (node.start == null || node.end == null) {\n return undefined\n }\n\n if (node.type === 'JSXExpressionContainer') {\n return readExpressionSource((node as JSXExpressionContainerNode).expression, code)\n }\n\n return code.slice(node.start, node.end).trim()\n}\n\nfunction getJsxAttribute(\n openingElement: JSXOpeningElementNode,\n name: string,\n): JSXAttributeNode | undefined {\n for (const attribute of openingElement.attributes) {\n if (attribute.type !== 'JSXAttribute') continue\n\n const jsxAttribute = attribute as JSXAttributeNode\n if (jsxAttribute.name.type === 'JSXIdentifier' && jsxAttribute.name['name'] === name) {\n return jsxAttribute\n }\n }\n\n return undefined\n}\n\nfunction extractPluralProps(\n openingElement: JSXOpeningElementNode,\n code: string,\n): Record<string, string> {\n const props: Record<string, string> = {}\n const propNames = ['id', 'value', 'count', 'offset', 'zero', 'one', 'two', 'few', 'many', 'other']\n\n for (const name of propNames) {\n const attribute = getJsxAttribute(openingElement, name)\n if (!attribute?.value) continue\n\n const staticValue = readStaticStringValue(attribute.value)\n if (staticValue !== undefined) {\n props[name] = staticValue\n continue\n }\n\n const exprValue = readExpressionSource(attribute.value, code)\n if (exprValue !== undefined && (name === 'value' || name === 'count' || name === 'offset')) {\n props[name] = exprValue\n }\n }\n\n return props\n}\n\nfunction extractTaggedTemplateMessage(\n code: string,\n node: TaggedTemplateExpressionNode,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor {\n const strings = node.quasi.quasis.map((quasi) => quasi.value.cooked ?? quasi.value.raw)\n const expressions = node.quasi.expressions.map((expression) => {\n if (expression.start == null || expression.end == null) {\n return ''\n }\n return code.slice(expression.start, expression.end)\n })\n const message = buildICUFromTemplate(strings, expressions)\n const generateId = idGenerator ?? createMessageId\n\n return {\n id: generateId(message),\n message,\n }\n}\n\nfunction collectDirectBindings(ast: SourceNode): Map<string, 't' | 'msg'> {\n const bindings = new Map<string, 't' | 'msg'>()\n const body = Array.isArray(ast['body']) ? ast['body'] : []\n\n for (const entry of body) {\n if (!isImportDeclaration(entry)) continue\n if (!DIRECT_T_SOURCES.has(entry.source.value)) continue\n\n for (const specifier of entry.specifiers) {\n if (!isImportSpecifier(specifier)) continue\n const importedName = readImportedName(specifier)\n if (importedName === 't' || importedName === 'msg') {\n bindings.set(specifier.local.name, importedName as 't' | 'msg')\n }\n }\n }\n\n return bindings\n}\n\nexport function extractFromTsx(\n code: string,\n filename: string,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedMessage[] {\n const ast = parseSourceModule(code)\n if (!ast) {\n console.warn(`[fluenti] Failed to parse ${filename} — skipping message extraction`)\n return []\n }\n\n const messages: ExtractedMessage[] = []\n const directBindings = collectDirectBindings(ast)\n\n walkSourceAst(ast, (node: SourceNode) => {\n if (node.type === 'TaggedTemplateExpression') {\n const tagged = node as TaggedTemplateExpressionNode\n if (\n isIdentifier(tagged.tag)\n && (tagged.tag.name === 't' || directBindings.has(tagged.tag.name))\n ) {\n const descriptor = extractTaggedTemplateMessage(code, tagged, idGenerator)\n const bindingType = directBindings.get(tagged.tag.name)\n if (bindingType === 'msg') {\n descriptor.comment = 'msg tagged template'\n }\n const extracted = createExtractedMessage(\n descriptor,\n filename,\n tagged,\n )\n if (extracted) {\n messages.push(extracted)\n }\n }\n return\n }\n\n if (node.type === 'CallExpression') {\n const call = node as CallExpressionNode\n const callBindingType = directBindings.get(call.callee && isIdentifier(call.callee) ? call.callee.name : '')\n if (isIdentifier(call.callee) && (call.callee.name === 't' || (directBindings.has(call.callee.name) && callBindingType === 't'))) {\n if (directBindings.has(call.callee.name) && call.arguments[0]?.type !== 'ObjectExpression') {\n return\n }\n const descriptor = call.arguments[0] ? extractDescriptorFromCallArgument(call.arguments[0], idGenerator) : undefined\n const extracted = descriptor\n ? createExtractedMessage(descriptor, filename, call)\n : undefined\n if (extracted) {\n messages.push(extracted)\n }\n } else if (\n call.callee.type === 'MemberExpression'\n && isIdentifier(call.callee['object'])\n && directBindings.get((call.callee['object'] as IdentifierNode).name) === 'msg'\n && isIdentifier(call.callee['property'])\n && (call.callee['property'] as IdentifierNode).name === 'descriptor'\n && call.arguments[0]\n ) {\n const descriptor = extractDescriptorFromCallArgument(call.arguments[0], idGenerator)\n const extracted = descriptor ? createExtractedMessage(descriptor, filename, call) : undefined\n if (extracted) {\n messages.push(extracted)\n }\n }\n return\n }\n\n if (node.type !== 'JSXElement') {\n return\n }\n\n const element = node as JSXElementNode\n const openingElement = element.openingElement\n const elementName = readJsxElementName(openingElement.name)\n\n if (elementName === 'Trans') {\n const messageAttr = getJsxAttribute(openingElement, 'message')\n const idAttr = getJsxAttribute(openingElement, 'id')\n const contextAttr = getJsxAttribute(openingElement, 'context')\n const commentAttr = getJsxAttribute(openingElement, 'comment')\n\n const descriptor = messageAttr?.value\n ? buildStaticTransDescriptor({\n id: idAttr?.value ? readStaticStringValue(idAttr.value) : undefined,\n message: readStaticStringValue(messageAttr.value),\n context: contextAttr?.value ? readStaticStringValue(contextAttr.value) : undefined,\n comment: commentAttr?.value ? readStaticStringValue(commentAttr.value) : undefined,\n }, idGenerator)\n : buildStaticTransDescriptor({\n id: idAttr?.value ? readStaticStringValue(idAttr.value) : undefined,\n message: extractRichTextMessage(element.children),\n context: contextAttr?.value ? readStaticStringValue(contextAttr.value) : undefined,\n comment: commentAttr?.value ? readStaticStringValue(commentAttr.value) : undefined,\n }, idGenerator)\n\n const extracted = descriptor\n ? createExtractedMessage(descriptor, filename, element)\n : undefined\n if (extracted) {\n messages.push(extracted)\n }\n return\n }\n\n if (elementName === 'Plural') {\n const props = extractPluralProps(openingElement, code)\n const message = buildPluralICU(props)\n if (!message) {\n return\n }\n\n const generateId = idGenerator ?? createMessageId\n const extracted = createExtractedMessage(\n {\n id: props['id'] ?? generateId(message),\n message,\n },\n filename,\n element,\n )\n if (extracted) {\n messages.push(extracted)\n }\n return\n }\n\n if (elementName === 'Select') {\n const { varName, id, context, comment, cases, other } = extractSelectProps(openingElement, code)\n if (!varName || !other || Object.keys(cases).length === 0) {\n return\n }\n\n const message = buildSelectICU(varName, cases, other)\n const generateId = idGenerator ?? createMessageId\n const extracted = createExtractedMessage(\n {\n id: id ?? generateId(message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n filename,\n element,\n )\n if (extracted) {\n messages.push(extracted)\n }\n }\n })\n\n return messages\n}\n\nfunction isImportDeclaration(node: unknown): node is ImportDeclarationNode {\n return isSourceNode(node) && node.type === 'ImportDeclaration'\n}\n\nfunction isImportSpecifier(node: unknown): node is ImportSpecifierNode {\n return isSourceNode(node) && node.type === 'ImportSpecifier'\n}\n\nfunction readImportedName(specifier: ImportSpecifierNode): string | undefined {\n if (specifier.imported.type === 'Identifier') {\n return (specifier.imported as IdentifierNode).name\n }\n if (specifier.imported.type === 'StringLiteral') {\n return (specifier.imported as StringLiteralNode).value\n }\n return undefined\n}\n\nfunction readJsxElementName(node: SourceNode): string | undefined {\n if (node.type === 'JSXIdentifier') {\n return String(node['name'])\n }\n return undefined\n}\n\nfunction buildStaticTransDescriptor(\n parts: {\n id: string | undefined\n message: string | undefined\n context: string | undefined\n comment: string | undefined\n },\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedDescriptor | undefined {\n const payload: {\n id?: string\n message?: string\n context?: string\n comment?: string\n } = {}\n\n if (parts.id !== undefined) payload.id = parts.id\n if (parts.message !== undefined) payload.message = parts.message\n if (parts.context !== undefined) payload.context = parts.context\n if (parts.comment !== undefined) payload.comment = parts.comment\n\n return descriptorFromStaticParts(payload, idGenerator)\n}\n\nfunction isIdentifier(node: unknown): node is IdentifierNode {\n return isSourceNode(node) && node.type === 'Identifier'\n}\n"],"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4C;AACrE,QAAO,EAAa,EAAK,IAAI,EAAK,SAAS;;AAG7C,SAAS,EAAiB,GAAoD;AAC5E,KAAI,EAAU,SAAS,SAAS,aAC9B,QAAQ,EAAU,SAA4B;AAEhD,KAAI,EAAU,SAAS,SAAS,gBAC9B,QAAQ,EAAU,SAA+B;;AAKrD,SAAS,EAAmB,GAAsC;AAChE,KAAI,EAAK,SAAS,gBAChB,QAAO,OAAO,EAAK,KAAQ;;AAK/B,SAAS,EACP,GAMA,GACiC;CACjC,IAAM,IAKF,EAAE;AAON,QALI,EAAM,OAAO,KAAA,MAAW,EAAQ,KAAK,EAAM,KAC3C,EAAM,YAAY,KAAA,MAAW,EAAQ,UAAU,EAAM,UACrD,EAAM,YAAY,KAAA,MAAW,EAAQ,UAAU,EAAM,UACrD,EAAM,YAAY,KAAA,MAAW,EAAQ,UAAU,EAAM,UAElD,EAA0B,GAAS,EAAY;;AAGxD,SAAS,EAAa,GAAuC;AAC3D,QAAO,EAAa,EAAK,IAAI,EAAK,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue-extractor.cjs","names":[],"sources":["../src/vue-extractor.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core/compiler'\nimport { parse as parseSFC } from '@vue/compiler-sfc'\nimport { createMessageId } from '@fluenti/core/transform'\nimport { extractFromTsx } from './tsx-extractor'\n\n// Vue template AST node types\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 2\nconst DIRECTIVE_PROP = 7\nconst ATTRIBUTE_PROP = 6\n\ninterface LocInfo {\n line: number\n column: number\n offset: number\n}\n\ninterface SourceLoc {\n start: LocInfo\n end: LocInfo\n source: string\n}\n\ninterface TemplateNode {\n type: number\n tag?: string\n tagType?: number\n props?: TemplateProp[]\n children?: TemplateNode[]\n content?: string\n loc: SourceLoc\n}\n\ninterface TemplateProp {\n type: number\n name: string | { content: string }\n rawName?: string\n arg?: { content: string; isStatic: boolean }\n exp?: { content: string }\n modifiers?: Array<{ content: string } | string>\n value?: { content: string }\n nameLoc?: SourceLoc\n loc: SourceLoc\n}\n\nfunction getTextContent(children: TemplateNode[]): string {\n return children\n .filter((c) => c.type === TEXT_NODE)\n .map((c) => (c.content ?? '').trim())\n .join('')\n}\n\nfunction buildPluralICUFromPipe(text: string, countVar: string): string {\n const forms = text.split('|').map((s) => s.trim())\n const categories = ['one', 'other', 'zero', 'few', 'many']\n const options: string[] = []\n\n if (forms.length === 2) {\n options.push(`one {${forms[0]}}`)\n options.push(`other {${forms[1]}}`)\n } else {\n for (let i = 0; i < forms.length && i < categories.length; i++) {\n options.push(`${categories[i]} {${forms[i]}}`)\n }\n }\n\n return `{${countVar}, plural, ${options.join(' ')}}`\n}\n\nconst SELECT_RESERVED_PROPS = new Set(['id', 'value', 'context', 'comment', 'options', 'other', 'tag'])\n\nfunction buildSelectICUFromProps(varName: string, cases: Record<string, string>, other: string): string {\n const options: string[] = []\n for (const [key, value] of Object.entries(cases)) {\n options.push(`${key} {${value}}`)\n }\n options.push(`other {${other}}`)\n return `{${varName}, select, ${options.join(' ')}}`\n}\n\nfunction buildPluralICUFromProps(props: Record<string, string>): string {\n const countVar = props['count'] ?? 'count'\n const categories = ['zero', 'one', 'two', 'few', 'many', 'other']\n const options: string[] = []\n const offset = props['offset']\n\n for (const cat of categories) {\n if (props[cat] !== undefined) {\n const key = cat === 'zero' ? '=0' : cat\n options.push(`${key} {${props[cat]}}`)\n }\n }\n\n if (options.length === 0) return ''\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{${countVar}, plural, ${offsetPrefix}${options.join(' ')}}`\n}\n\nfunction walkTemplate(\n node: TemplateNode,\n filename: string,\n messages: ExtractedMessage[],\n idGenerator?: (message: string, context?: string) => string,\n): void {\n if (node.type === ELEMENT_NODE) {\n const vtDirective = node.props?.find(\n (p) => p.type === DIRECTIVE_PROP && getPropName(p) === 't',\n )\n\n if (vtDirective) {\n const RESERVED_MODIFIERS = new Set(['plural'])\n const modifiers = (vtDirective.modifiers ?? []).map(\n (m: string | { content: string }) => (typeof m === 'string' ? m : m.content),\n )\n const isPlural = modifiers.includes('plural')\n // Reconstruct dotted ID: v-t:checkout.title → arg=\"checkout\", modifier=\"title\" → \"checkout.title\"\n // Non-reserved modifiers are treated as ID path segments\n const idSegments = modifiers.filter((m: string) => !RESERVED_MODIFIERS.has(m))\n const argContent = vtDirective.arg?.content\n const explicitId = argContent\n ? [argContent, ...idSegments].join('.')\n : undefined\n const textContent = getTextContent(node.children ?? [])\n\n if (isPlural) {\n const countVar = vtDirective.exp?.content ?? 'count'\n const message = buildPluralICUFromPipe(textContent, countVar)\n const id = explicitId ?? (idGenerator ?? createMessageId)(message)\n messages.push({\n id,\n message,\n origin: {\n file: filename,\n line: vtDirective.loc.start.line,\n column: vtDirective.loc.start.column,\n },\n })\n } else if (textContent) {\n const id = explicitId ?? (idGenerator ?? createMessageId)(textContent)\n messages.push({\n id,\n message: textContent,\n origin: {\n file: filename,\n line: vtDirective.loc.start.line,\n column: vtDirective.loc.start.column,\n },\n })\n }\n }\n\n if (node.tag === 'Trans') {\n const messageProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'message',\n )\n const idProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'id',\n )\n const contextProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'context',\n )\n const commentProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'comment',\n )\n const context = contextProp?.value?.content\n const comment = commentProp?.value?.content\n\n if (messageProp?.value) {\n // Old API: <Trans message=\"...\" />\n const message = messageProp.value.content\n const generateId = idGenerator ?? createMessageId\n const id = idProp?.value?.content ?? generateId(message, context)\n messages.push({\n id,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n } else if (node.children && node.children.length > 0) {\n // New API: <Trans>content with <a>rich text</a></Trans>\n const richText = extractRichTextFromTemplateChildren(node.children)\n if (richText.message) {\n const generateId = idGenerator ?? createMessageId\n const id = idProp?.value?.content ?? generateId(richText.message, context)\n messages.push({\n id,\n message: richText.message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n }\n\n if (node.tag === 'Plural') {\n const propsMap: Record<string, string> = {}\n let valueExpr: string | undefined\n let offsetExpr: string | undefined\n for (const prop of node.props ?? []) {\n if (prop.type === ATTRIBUTE_PROP && prop.value) {\n propsMap[getPropName(prop)] = prop.value.content\n }\n // Handle :value=\"expr\" binding (directive prop)\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'value' && prop.exp) {\n valueExpr = prop.exp.content\n }\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'offset' && prop.exp) {\n offsetExpr = prop.exp.content\n }\n }\n\n // Use :value binding expression as count variable, fall back to 'count' static prop\n const countVar = valueExpr ?? propsMap['count'] ?? 'count'\n const offset = offsetExpr ?? propsMap['offset']\n const pluralMessage = buildPluralICUFromProps({\n ...propsMap,\n count: countVar,\n ...(offset !== undefined ? { offset } : {}),\n })\n if (pluralMessage) {\n const id = propsMap['id'] ?? (idGenerator ?? createMessageId)(pluralMessage)\n messages.push({\n id,\n message: pluralMessage,\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n\n if (node.tag === 'Select') {\n let varName: string | undefined\n let selectId: string | undefined\n let selectContext: string | undefined\n let selectComment: string | undefined\n let other: string | undefined\n const cases: Record<string, string> = {}\n\n for (const prop of node.props ?? []) {\n if (prop.type === ATTRIBUTE_PROP && prop.value) {\n const name = getPropName(prop)\n if (name === 'id') { selectId = prop.value.content; continue }\n if (name === 'context') { selectContext = prop.value.content; continue }\n if (name === 'comment') { selectComment = prop.value.content; continue }\n if (name === 'other') { other = prop.value.content; continue }\n if (SELECT_RESERVED_PROPS.has(name)) continue\n cases[name] = prop.value.content\n }\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'value' && prop.exp) {\n varName = prop.exp.content\n }\n }\n\n if (varName && other && Object.keys(cases).length > 0) {\n const message = buildSelectICUFromProps(varName, cases, other)\n const generateId = idGenerator ?? createMessageId\n const id = selectId ?? generateId(message, selectContext)\n messages.push({\n id,\n message,\n ...(selectContext !== undefined ? { context: selectContext } : {}),\n ...(selectComment !== undefined ? { comment: selectComment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n }\n\n if (node.children) {\n for (const child of node.children) {\n walkTemplate(child, filename, messages, idGenerator)\n }\n }\n}\n\nfunction extractRichTextFromTemplateChildren(\n children: TemplateNode[],\n): { message: string; hasElements: boolean } {\n let elementIndex = 0\n let hasElements = false\n\n const parts = children.map((child) => {\n if (child.type === TEXT_NODE) {\n return (child.content ?? '').trim() ? child.content ?? '' : ''\n }\n if (child.type === ELEMENT_NODE && child.tag) {\n hasElements = true\n const idx = elementIndex++\n const innerText = extractRichTextFromTemplateChildren(child.children ?? []).message\n return `<${idx}>${innerText}</${idx}>`\n }\n return ''\n })\n\n return {\n message: parts.join('').trim(),\n hasElements,\n }\n}\n\nfunction getPropName(prop: TemplateProp): string {\n if (typeof prop.name === 'string') return prop.name\n return prop.name.content\n}\n\nfunction extractTemplateInterpolations(\n content: string,\n filename: string,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedMessage[] {\n const messages: ExtractedMessage[] = []\n const interpolationRegex = /\\{\\{([\\s\\S]*?)\\}\\}/g\n let match: RegExpExecArray | null\n\n while ((match = interpolationRegex.exec(content)) !== null) {\n const expression = match[1]?.trim()\n if (!expression) continue\n\n const extracted = extractFromTsx(expression, filename, idGenerator)\n if (extracted.length === 0) continue\n\n const lineOffset = content.slice(0, match.index).split('\\n').length - 1\n for (const msg of extracted) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n return messages\n}\n\n/** Extract messages from Vue SFC files */\nexport function extractFromVue(\n code: string,\n filename: string,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedMessage[] {\n const messages: ExtractedMessage[] = []\n\n const { descriptor } = parseSFC(code, { filename })\n\n if (descriptor.template?.ast) {\n walkTemplate(descriptor.template.ast as unknown as TemplateNode, filename, messages, idGenerator)\n }\n\n // Also extract t() function calls from raw template source\n // (picks up t('source text') in template expressions like {{ t('...') }})\n if (descriptor.template?.content) {\n const templateMessages = extractFromTsx(descriptor.template.content, filename, idGenerator)\n const templateLoc = descriptor.template.loc\n const lineOffset = templateLoc.start.line - 1\n const existingIds = new Set(messages.map((m) => m.id))\n for (const msg of templateMessages) {\n if (!existingIds.has(msg.id)) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n // Rebuild the set after template pass to include newly added IDs\n const afterTemplateIds = new Set(messages.map((m) => m.id))\n const interpolationMessages = extractTemplateInterpolations(descriptor.template.content, filename, idGenerator)\n for (const msg of interpolationMessages) {\n if (!afterTemplateIds.has(msg.id)) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n }\n\n if (descriptor.scriptSetup?.content) {\n const scriptMessages = extractFromTsx(descriptor.scriptSetup.content, filename, idGenerator)\n const scriptLoc = descriptor.scriptSetup.loc\n const lineOffset = scriptLoc.start.line - 1\n for (const msg of scriptMessages) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n if (descriptor.script?.content) {\n const scriptMessages = extractFromTsx(descriptor.script.content, filename, idGenerator)\n const scriptLoc = descriptor.script.loc\n const lineOffset = scriptLoc.start.line - 1\n for (const msg of scriptMessages) {\n messages.push({\n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,EAAI,OAAO,KAAO,EACzB,CACF,CAAC,CAKR,GAAI,EAAW,aAAa,QAAS,CACnC,IAAM,EAAiB,EAAA,EAAe,EAAW,YAAY,QAAS,EAAU,EAAY,CAEtF,EADY,EAAW,YAAY,IACZ,MAAM,KAAO,EAC1C,IAAK,IAAM,KAAO,EAChB,EAAS,KAAK,CACZ,GAAG,EACH,OAAQ,CACN,GAAG,EAAI,OACP,KAAM,EAAI,OAAO,KAAO,EACzB,CACF,CAAC,CAIN,GAAI,EAAW,QAAQ,QAAS,CAC9B,IAAM,EAAiB,EAAA,EAAe,EAAW,OAAO,QAAS,EAAU,EAAY,CAEjF,EADY,EAAW,OAAO,IACP,MAAM,KAAO,EAC1C,IAAK,IAAM,KAAO,EAChB,EAAS,KAAK,CACZ,GAAG,EACH,OAAQ,CACN,GAAG,EAAI,OACP,KAAM,EAAI,OAAO,KAAO,EACzB,CACF,CAAC,CAIN,OAAO"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue-extractor.js","names":[],"sources":["../src/vue-extractor.ts"],"sourcesContent":["import type { ExtractedMessage } from '@fluenti/core/compiler'\nimport { parse as parseSFC } from '@vue/compiler-sfc'\nimport { createMessageId } from '@fluenti/core/transform'\nimport { extractFromTsx } from './tsx-extractor'\n\n// Vue template AST node types\nconst ELEMENT_NODE = 1\nconst TEXT_NODE = 2\nconst DIRECTIVE_PROP = 7\nconst ATTRIBUTE_PROP = 6\n\ninterface LocInfo {\n line: number\n column: number\n offset: number\n}\n\ninterface SourceLoc {\n start: LocInfo\n end: LocInfo\n source: string\n}\n\ninterface TemplateNode {\n type: number\n tag?: string\n tagType?: number\n props?: TemplateProp[]\n children?: TemplateNode[]\n content?: string\n loc: SourceLoc\n}\n\ninterface TemplateProp {\n type: number\n name: string | { content: string }\n rawName?: string\n arg?: { content: string; isStatic: boolean }\n exp?: { content: string }\n modifiers?: Array<{ content: string } | string>\n value?: { content: string }\n nameLoc?: SourceLoc\n loc: SourceLoc\n}\n\nfunction getTextContent(children: TemplateNode[]): string {\n return children\n .filter((c) => c.type === TEXT_NODE)\n .map((c) => (c.content ?? '').trim())\n .join('')\n}\n\nfunction buildPluralICUFromPipe(text: string, countVar: string): string {\n const forms = text.split('|').map((s) => s.trim())\n const categories = ['one', 'other', 'zero', 'few', 'many']\n const options: string[] = []\n\n if (forms.length === 2) {\n options.push(`one {${forms[0]}}`)\n options.push(`other {${forms[1]}}`)\n } else {\n for (let i = 0; i < forms.length && i < categories.length; i++) {\n options.push(`${categories[i]} {${forms[i]}}`)\n }\n }\n\n return `{${countVar}, plural, ${options.join(' ')}}`\n}\n\nconst SELECT_RESERVED_PROPS = new Set(['id', 'value', 'context', 'comment', 'options', 'other', 'tag'])\n\nfunction buildSelectICUFromProps(varName: string, cases: Record<string, string>, other: string): string {\n const options: string[] = []\n for (const [key, value] of Object.entries(cases)) {\n options.push(`${key} {${value}}`)\n }\n options.push(`other {${other}}`)\n return `{${varName}, select, ${options.join(' ')}}`\n}\n\nfunction buildPluralICUFromProps(props: Record<string, string>): string {\n const countVar = props['count'] ?? 'count'\n const categories = ['zero', 'one', 'two', 'few', 'many', 'other']\n const options: string[] = []\n const offset = props['offset']\n\n for (const cat of categories) {\n if (props[cat] !== undefined) {\n const key = cat === 'zero' ? '=0' : cat\n options.push(`${key} {${props[cat]}}`)\n }\n }\n\n if (options.length === 0) return ''\n const offsetPrefix = offset ? `offset:${offset} ` : ''\n return `{${countVar}, plural, ${offsetPrefix}${options.join(' ')}}`\n}\n\nfunction walkTemplate(\n node: TemplateNode,\n filename: string,\n messages: ExtractedMessage[],\n idGenerator?: (message: string, context?: string) => string,\n): void {\n if (node.type === ELEMENT_NODE) {\n const vtDirective = node.props?.find(\n (p) => p.type === DIRECTIVE_PROP && getPropName(p) === 't',\n )\n\n if (vtDirective) {\n const RESERVED_MODIFIERS = new Set(['plural'])\n const modifiers = (vtDirective.modifiers ?? []).map(\n (m: string | { content: string }) => (typeof m === 'string' ? m : m.content),\n )\n const isPlural = modifiers.includes('plural')\n // Reconstruct dotted ID: v-t:checkout.title → arg=\"checkout\", modifier=\"title\" → \"checkout.title\"\n // Non-reserved modifiers are treated as ID path segments\n const idSegments = modifiers.filter((m: string) => !RESERVED_MODIFIERS.has(m))\n const argContent = vtDirective.arg?.content\n const explicitId = argContent\n ? [argContent, ...idSegments].join('.')\n : undefined\n const textContent = getTextContent(node.children ?? [])\n\n if (isPlural) {\n const countVar = vtDirective.exp?.content ?? 'count'\n const message = buildPluralICUFromPipe(textContent, countVar)\n const id = explicitId ?? (idGenerator ?? createMessageId)(message)\n messages.push({\n id,\n message,\n origin: {\n file: filename,\n line: vtDirective.loc.start.line,\n column: vtDirective.loc.start.column,\n },\n })\n } else if (textContent) {\n const id = explicitId ?? (idGenerator ?? createMessageId)(textContent)\n messages.push({\n id,\n message: textContent,\n origin: {\n file: filename,\n line: vtDirective.loc.start.line,\n column: vtDirective.loc.start.column,\n },\n })\n }\n }\n\n if (node.tag === 'Trans') {\n const messageProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'message',\n )\n const idProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'id',\n )\n const contextProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'context',\n )\n const commentProp = node.props?.find(\n (p) => p.type === ATTRIBUTE_PROP && getPropName(p) === 'comment',\n )\n const context = contextProp?.value?.content\n const comment = commentProp?.value?.content\n\n if (messageProp?.value) {\n // Old API: <Trans message=\"...\" />\n const message = messageProp.value.content\n const generateId = idGenerator ?? createMessageId\n const id = idProp?.value?.content ?? generateId(message, context)\n messages.push({\n id,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n } else if (node.children && node.children.length > 0) {\n // New API: <Trans>content with <a>rich text</a></Trans>\n const richText = extractRichTextFromTemplateChildren(node.children)\n if (richText.message) {\n const generateId = idGenerator ?? createMessageId\n const id = idProp?.value?.content ?? generateId(richText.message, context)\n messages.push({\n id,\n message: richText.message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n }\n\n if (node.tag === 'Plural') {\n const propsMap: Record<string, string> = {}\n let valueExpr: string | undefined\n let offsetExpr: string | undefined\n for (const prop of node.props ?? []) {\n if (prop.type === ATTRIBUTE_PROP && prop.value) {\n propsMap[getPropName(prop)] = prop.value.content\n }\n // Handle :value=\"expr\" binding (directive prop)\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'value' && prop.exp) {\n valueExpr = prop.exp.content\n }\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'offset' && prop.exp) {\n offsetExpr = prop.exp.content\n }\n }\n\n // Use :value binding expression as count variable, fall back to 'count' static prop\n const countVar = valueExpr ?? propsMap['count'] ?? 'count'\n const offset = offsetExpr ?? propsMap['offset']\n const pluralMessage = buildPluralICUFromProps({\n ...propsMap,\n count: countVar,\n ...(offset !== undefined ? { offset } : {}),\n })\n if (pluralMessage) {\n const id = propsMap['id'] ?? (idGenerator ?? createMessageId)(pluralMessage)\n messages.push({\n id,\n message: pluralMessage,\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n\n if (node.tag === 'Select') {\n let varName: string | undefined\n let selectId: string | undefined\n let selectContext: string | undefined\n let selectComment: string | undefined\n let other: string | undefined\n const cases: Record<string, string> = {}\n\n for (const prop of node.props ?? []) {\n if (prop.type === ATTRIBUTE_PROP && prop.value) {\n const name = getPropName(prop)\n if (name === 'id') { selectId = prop.value.content; continue }\n if (name === 'context') { selectContext = prop.value.content; continue }\n if (name === 'comment') { selectComment = prop.value.content; continue }\n if (name === 'other') { other = prop.value.content; continue }\n if (SELECT_RESERVED_PROPS.has(name)) continue\n cases[name] = prop.value.content\n }\n if (prop.type === DIRECTIVE_PROP && getPropName(prop) === 'bind' && prop.arg?.content === 'value' && prop.exp) {\n varName = prop.exp.content\n }\n }\n\n if (varName && other && Object.keys(cases).length > 0) {\n const message = buildSelectICUFromProps(varName, cases, other)\n const generateId = idGenerator ?? createMessageId\n const id = selectId ?? generateId(message, selectContext)\n messages.push({\n id,\n message,\n ...(selectContext !== undefined ? { context: selectContext } : {}),\n ...(selectComment !== undefined ? { comment: selectComment } : {}),\n origin: {\n file: filename,\n line: node.loc.start.line,\n column: node.loc.start.column,\n },\n })\n }\n }\n }\n\n if (node.children) {\n for (const child of node.children) {\n walkTemplate(child, filename, messages, idGenerator)\n }\n }\n}\n\nfunction extractRichTextFromTemplateChildren(\n children: TemplateNode[],\n): { message: string; hasElements: boolean } {\n let elementIndex = 0\n let hasElements = false\n\n const parts = children.map((child) => {\n if (child.type === TEXT_NODE) {\n return (child.content ?? '').trim() ? child.content ?? '' : ''\n }\n if (child.type === ELEMENT_NODE && child.tag) {\n hasElements = true\n const idx = elementIndex++\n const innerText = extractRichTextFromTemplateChildren(child.children ?? []).message\n return `<${idx}>${innerText}</${idx}>`\n }\n return ''\n })\n\n return {\n message: parts.join('').trim(),\n hasElements,\n }\n}\n\nfunction getPropName(prop: TemplateProp): string {\n if (typeof prop.name === 'string') return prop.name\n return prop.name.content\n}\n\nfunction extractTemplateInterpolations(\n content: string,\n filename: string,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedMessage[] {\n const messages: ExtractedMessage[] = []\n const interpolationRegex = /\\{\\{([\\s\\S]*?)\\}\\}/g\n let match: RegExpExecArray | null\n\n while ((match = interpolationRegex.exec(content)) !== null) {\n const expression = match[1]?.trim()\n if (!expression) continue\n\n const extracted = extractFromTsx(expression, filename, idGenerator)\n if (extracted.length === 0) continue\n\n const lineOffset = content.slice(0, match.index).split('\\n').length - 1\n for (const msg of extracted) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n return messages\n}\n\n/** Extract messages from Vue SFC files */\nexport function extractFromVue(\n code: string,\n filename: string,\n idGenerator?: (message: string, context?: string) => string,\n): ExtractedMessage[] {\n const messages: ExtractedMessage[] = []\n\n const { descriptor } = parseSFC(code, { filename })\n\n if (descriptor.template?.ast) {\n walkTemplate(descriptor.template.ast as unknown as TemplateNode, filename, messages, idGenerator)\n }\n\n // Also extract t() function calls from raw template source\n // (picks up t('source text') in template expressions like {{ t('...') }})\n if (descriptor.template?.content) {\n const templateMessages = extractFromTsx(descriptor.template.content, filename, idGenerator)\n const templateLoc = descriptor.template.loc\n const lineOffset = templateLoc.start.line - 1\n const existingIds = new Set(messages.map((m) => m.id))\n for (const msg of templateMessages) {\n if (!existingIds.has(msg.id)) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n // Rebuild the set after template pass to include newly added IDs\n const afterTemplateIds = new Set(messages.map((m) => m.id))\n const interpolationMessages = extractTemplateInterpolations(descriptor.template.content, filename, idGenerator)\n for (const msg of interpolationMessages) {\n if (!afterTemplateIds.has(msg.id)) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n }\n\n if (descriptor.scriptSetup?.content) {\n const scriptMessages = extractFromTsx(descriptor.scriptSetup.content, filename, idGenerator)\n const scriptLoc = descriptor.scriptSetup.loc\n const lineOffset = scriptLoc.start.line - 1\n for (const msg of scriptMessages) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\n }\n\n if (descriptor.script?.content) {\n const scriptMessages = extractFromTsx(descriptor.script.content, filename, idGenerator)\n const scriptLoc = descriptor.script.loc\n const lineOffset = scriptLoc.start.line - 1\n for (const msg of scriptMessages) {\n messages.push({\n ...msg,\n origin: {\n ...msg.origin,\n line: msg.origin.line + lineOffset,\n },\n })\n }\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