@fluenti/vite-plugin 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/mode-detect.ts","../src/dev-runner.ts","../src/build-transform.ts","../src/virtual-modules.ts","../src/route-resolve.ts","../src/index.ts"],"sourcesContent":["/**\n * Detect whether Vite is running in build or dev mode.\n * Supports Vite 7 (configResolved) and Vite 8 (environment API).\n */\n\nlet resolvedMode: 'build' | 'dev' = 'dev'\n\n/** Called from configResolved hook to capture the mode early */\nexport function setResolvedMode(command: string): void {\n resolvedMode = command === 'build' ? 'build' : 'dev'\n}\n\n/** Get the current resolved mode */\nexport function getResolvedMode(): 'build' | 'dev' {\n return resolvedMode\n}\n\n/**\n * Check if we're in build mode.\n * Tries environment API (Vite 8), then falls back to configResolved capture,\n * then falls back to NODE_ENV.\n */\nexport function isBuildMode(environment?: { mode?: string }): boolean {\n // Vite 8: environment.mode === 'build'\n if (environment?.mode === 'build') return true\n\n // Vite 7: captured from configResolved\n if (resolvedMode === 'build') return true\n\n // Last resort: NODE_ENV\n if (process.env['NODE_ENV'] === 'production') return true\n\n return false\n}\n","import { exec } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve, dirname, join } from 'node:path'\nimport { createRequire } from 'node:module'\n\nexport interface DevRunnerOptions {\n cwd: string\n onSuccess?: () => void\n onError?: (err: Error) => void\n /** If true, reject the promise on failure instead of swallowing the error */\n throwOnError?: boolean\n /** Run only compile (skip extract). Useful for production builds where source is unchanged. */\n compileOnly?: boolean\n}\n\n/**\n * Walk up from `cwd` to find `node_modules/.bin/fluenti`.\n * Returns the absolute path or null if not found.\n */\nexport function resolveCliBin(cwd: string): string | null {\n let dir = cwd\n for (;;) {\n const bin = resolve(dir, 'node_modules/.bin/fluenti')\n if (existsSync(bin)) return bin\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return null\n}\n\n/**\n * Run compile in-process via `@fluenti/cli` (for compileOnly mode),\n * or fall back to shell-out for extract + compile (dev mode).\n */\nexport async function runExtractCompile(options: DevRunnerOptions): Promise<void> {\n if (options.compileOnly) {\n try {\n // Resolve @fluenti/cli from the project's cwd (not from this package's location)\n // using createRequire so pnpm's strict node_modules layout works correctly.\n // Use require() (not import()) to load @fluenti/cli — avoids CJS/ESM interop\n // issues when dynamic import() loads minified CJS with chunk requires.\n const projectRequire = createRequire(join(options.cwd, 'package.json'))\n const { runCompile } = projectRequire('@fluenti/cli')\n await runCompile(options.cwd)\n console.log('[fluenti] Compiling... done')\n options.onSuccess?.()\n return\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e))\n if (options.throwOnError) throw error\n console.warn('[fluenti] Compile failed:', error.message)\n options.onError?.(error)\n return\n }\n }\n\n // Dev mode: shell out for extract + compile\n const bin = resolveCliBin(options.cwd)\n if (!bin) {\n const msg = '[fluenti] CLI not found — skipping auto-compile. Install @fluenti/cli as a devDependency.'\n if (options.throwOnError) {\n return Promise.reject(new Error(msg))\n }\n console.warn(msg)\n return Promise.resolve()\n }\n\n const command = `${bin} extract && ${bin} compile`\n return new Promise<void>((resolve, reject) => {\n exec(\n command,\n { cwd: options.cwd },\n (err, _stdout, stderr) => {\n if (err) {\n const error = new Error(stderr || err.message)\n if (options.throwOnError) {\n reject(error)\n return\n }\n console.warn('[fluenti] Extract/compile failed:', error.message)\n options.onError?.(error)\n } else {\n console.log('[fluenti] Extracting and compiling... done')\n options.onSuccess?.()\n }\n resolve()\n },\n )\n })\n}\n\n/**\n * Create a debounced runner that collapses rapid calls.\n *\n * - If called while idle, schedules a run after `delay` ms.\n * - If called while a run is in progress, marks a pending rerun.\n * - Never runs concurrently.\n */\nexport function createDebouncedRunner(\n options: DevRunnerOptions,\n delay = 300,\n): () => void {\n let timer: ReturnType<typeof setTimeout> | null = null\n let running = false\n let pendingRerun = false\n\n async function execute(): Promise<void> {\n running = true\n try {\n await runExtractCompile(options)\n } finally {\n running = false\n if (pendingRerun) {\n pendingRerun = false\n schedule()\n }\n }\n }\n\n function schedule(): void {\n if (timer !== null) {\n clearTimeout(timer)\n }\n timer = setTimeout(() => {\n timer = null\n if (running) {\n pendingRerun = true\n } else {\n execute()\n }\n }, delay)\n }\n\n return schedule\n}\n","/**\n * Build-mode transform for code-splitting.\n *\n * Strategy 'dynamic': rewrites supported translation calls to __catalog._<hash> references.\n * Strategy 'static': rewrites to direct named imports from compiled locale modules.\n */\n\nimport { hashMessage } from '@fluenti/core'\nimport { parseSourceModule, walkSourceAst, type SourceNode } from '@fluenti/core/internal'\n\nexport interface BuildTransformResult {\n code: string\n needsCatalogImport: boolean\n usedHashes: Set<string>\n}\n\ntype SplitStrategy = 'dynamic' | 'static'\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: { cooked: string | null; raw: string }\n}\n\ninterface TemplateLiteralNode extends SourceNode {\n type: 'TemplateLiteral'\n expressions: SourceNode[]\n quasis: TemplateElementNode[]\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 CallExpressionNode extends SourceNode {\n type: 'CallExpression'\n callee: SourceNode\n arguments: SourceNode[]\n}\n\ninterface AwaitExpressionNode extends SourceNode {\n type: 'AwaitExpression'\n argument: SourceNode\n}\n\ninterface VariableDeclaratorNode extends SourceNode {\n type: 'VariableDeclarator'\n id: SourceNode\n init?: SourceNode | null\n}\n\ninterface ProgramNode extends SourceNode {\n type: 'Program'\n body: SourceNode[]\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 ObjectPatternNode extends SourceNode {\n type: 'ObjectPattern'\n properties: SourceNode[]\n}\n\ninterface MemberExpressionNode extends SourceNode {\n type: 'MemberExpression'\n object: SourceNode\n property: SourceNode\n computed?: boolean\n}\n\ninterface JSXElementNode extends SourceNode {\n type: 'JSXElement'\n openingElement: JSXOpeningElementNode\n}\n\ninterface JSXOpeningElementNode extends SourceNode {\n type: 'JSXOpeningElement'\n name: SourceNode\n attributes: SourceNode[]\n}\n\ninterface JSXIdentifierNode extends SourceNode {\n type: 'JSXIdentifier'\n name: string\n}\n\ninterface JSXAttributeNode extends SourceNode {\n type: 'JSXAttribute'\n name: JSXIdentifierNode\n value?: SourceNode | null\n}\n\ninterface JSXExpressionContainerNode extends SourceNode {\n type: 'JSXExpressionContainer'\n expression: SourceNode\n}\n\ninterface SplitReplacement {\n start: number\n end: number\n replacement: string\n}\n\ninterface SplitTarget {\n catalogId: string\n valuesSource?: string\n}\n\ninterface RuntimeBindings {\n tracked: Set<string>\n unref: Set<string>\n}\n\nexport function transformForDynamicSplit(code: string): BuildTransformResult {\n return transformForSplitStrategy(code, 'dynamic')\n}\n\nexport function transformForStaticSplit(code: string): BuildTransformResult {\n return transformForSplitStrategy(code, 'static')\n}\n\nfunction transformForSplitStrategy(\n code: string,\n strategy: SplitStrategy,\n): BuildTransformResult {\n const ast = parseSourceModule(code)\n if (!ast || ast.type !== 'Program') {\n return { code, needsCatalogImport: false, usedHashes: new Set() }\n }\n\n const bindings = collectTrackedRuntimeBindings(ast as ProgramNode)\n const replacements: SplitReplacement[] = []\n const usedHashes = new Set<string>()\n\n walkSourceAst(ast, (node) => {\n const replacement = extractCallReplacement(code, node, bindings, strategy, usedHashes)\n if (replacement) {\n replacements.push(replacement)\n return\n }\n\n collectComponentUsage(node, usedHashes)\n })\n\n if (replacements.length === 0) {\n return { code, needsCatalogImport: false, usedHashes }\n }\n\n let result = code\n for (let i = replacements.length - 1; i >= 0; i--) {\n const { start, end, replacement } = replacements[i]!\n result = result.slice(0, start) + replacement + result.slice(end)\n }\n\n return { code: result, needsCatalogImport: true, usedHashes }\n}\n\nfunction collectTrackedRuntimeBindings(program: ProgramNode): RuntimeBindings {\n const tracked = new Set<string>()\n const useI18nBindings = new Set<string>()\n const getI18nBindings = new Set<string>()\n const unrefBindings = new Set<string>()\n\n for (const statement of program.body) {\n if (!isImportDeclaration(statement)) continue\n for (const specifier of statement.specifiers) {\n if (!isImportSpecifier(specifier)) continue\n const importedName = readImportedName(specifier)\n if (!importedName) continue\n if (importedName === 'useI18n') {\n useI18nBindings.add(specifier.local.name)\n }\n if (importedName === 'getI18n') {\n getI18nBindings.add(specifier.local.name)\n }\n if (importedName === 'unref') {\n unrefBindings.add(specifier.local.name)\n }\n }\n }\n\n walkSourceAst(program, (node) => {\n if (!isVariableDeclarator(node) || !node.init || !isObjectPattern(node.id)) return\n\n if (isCallExpression(node.init) && isIdentifier(node.init.callee) && useI18nBindings.has(node.init.callee.name)) {\n addTrackedObjectPatternBindings(node.id, tracked)\n return\n }\n\n const awaitedCall = node.init.type === 'AwaitExpression'\n ? (node.init as AwaitExpressionNode).argument\n : null\n\n if (\n awaitedCall\n && isCallExpression(awaitedCall)\n && isIdentifier(awaitedCall.callee)\n && getI18nBindings.has(awaitedCall.callee.name)\n ) {\n addTrackedObjectPatternBindings(node.id, tracked)\n }\n })\n\n return { tracked, unref: unrefBindings }\n}\n\nfunction addTrackedObjectPatternBindings(pattern: ObjectPatternNode, tracked: Set<string>): void {\n for (const property of pattern.properties) {\n if (!isObjectProperty(property) || property.computed) continue\n if (!isIdentifier(property.key) || property.key.name !== 't') continue\n if (isIdentifier(property.value)) {\n tracked.add(property.value.name)\n }\n }\n}\n\nfunction extractCallReplacement(\n code: string,\n node: SourceNode,\n bindings: RuntimeBindings,\n strategy: SplitStrategy,\n usedHashes: Set<string>,\n): SplitReplacement | undefined {\n if (!isCallExpression(node) || node.start == null || node.end == null) {\n return undefined\n }\n\n const splitTarget = resolveSplitTarget(code, node, bindings)\n if (!splitTarget) {\n return undefined\n }\n\n const { catalogId } = splitTarget\n usedHashes.add(catalogId)\n const exportHash = hashMessage(catalogId)\n const replacementTarget = strategy === 'dynamic'\n ? `__catalog[${JSON.stringify(catalogId)}]`\n : `_${exportHash}`\n const replacement = splitTarget.valuesSource\n ? `${replacementTarget}(${splitTarget.valuesSource})`\n : replacementTarget\n\n return {\n start: node.start,\n end: node.end,\n replacement,\n }\n}\n\nfunction resolveSplitTarget(\n code: string,\n call: CallExpressionNode,\n bindings: RuntimeBindings,\n): SplitTarget | undefined {\n if (call.arguments.length === 0) return undefined\n\n const callee = call.callee\n const isTrackedIdentifierCall = isIdentifier(callee) && (bindings.tracked.has(callee.name) || callee.name === '$t')\n const isTemplateMemberCall = isMemberExpression(callee)\n && !callee.computed\n && isIdentifier(callee.property)\n && (\n callee.property.name === '$t'\n || (\n callee.property.name === 't'\n && isIdentifier(callee.object)\n && (callee.object.name === '_ctx' || callee.object.name === '$setup')\n )\n )\n const isVueUnrefCall = isCallExpression(callee)\n && isIdentifier(callee.callee)\n && bindings.unref.has(callee.callee.name)\n && callee.arguments.length === 1\n && isIdentifier(callee.arguments[0])\n && bindings.tracked.has(callee.arguments[0].name)\n\n if (!isTrackedIdentifierCall && !isTemplateMemberCall && !isVueUnrefCall) {\n return undefined\n }\n\n const catalogId = extractCatalogId(call.arguments[0]!)\n if (!catalogId) return undefined\n\n const valuesSource = call.arguments[1] && call.arguments[1]!.start != null && call.arguments[1]!.end != null\n ? code.slice(call.arguments[1]!.start, call.arguments[1]!.end)\n : undefined\n\n return valuesSource === undefined\n ? { catalogId }\n : { catalogId, valuesSource }\n}\n\nfunction extractCatalogId(argument: SourceNode): string | undefined {\n const staticString = readStaticString(argument)\n if (staticString !== undefined) {\n return hashMessage(staticString)\n }\n\n if (!isObjectExpression(argument)) {\n return undefined\n }\n\n let id: string | undefined\n let message: string | undefined\n let context: string | undefined\n\n for (const property of argument.properties) {\n if (!isObjectProperty(property) || property.computed) continue\n const key = readPropertyKey(property.key)\n if (!key) continue\n\n const value = readStaticString(property.value)\n if (value === undefined) continue\n\n if (key === 'id') id = value\n if (key === 'message') message = value\n if (key === 'context') context = value\n }\n\n if (id) return id\n if (message) return hashMessage(message, context)\n return undefined\n}\n\nfunction collectComponentUsage(node: SourceNode, usedHashes: Set<string>): void {\n if (!isJsxElement(node)) return\n\n const componentName = readJsxName(node.openingElement.name)\n if (!componentName) return\n\n if (componentName === 'Trans') {\n const id = readJsxStaticAttribute(node.openingElement, '__id') ?? readJsxStaticAttribute(node.openingElement, 'id')\n if (id) {\n usedHashes.add(id)\n return\n }\n\n const message = readJsxStaticAttribute(node.openingElement, '__message')\n const context = readJsxStaticAttribute(node.openingElement, 'context')\n if (message) {\n usedHashes.add(hashMessage(message, context))\n }\n return\n }\n\n if (componentName === 'Plural') {\n const messageId = buildPluralMessageId(node.openingElement)\n if (messageId) {\n usedHashes.add(messageId)\n }\n return\n }\n\n if (componentName === 'Select') {\n const messageId = buildSelectMessageId(node.openingElement)\n if (messageId) {\n usedHashes.add(messageId)\n }\n }\n}\n\nfunction buildPluralMessageId(openingElement: JSXOpeningElementNode): string | undefined {\n const id = readJsxStaticAttribute(openingElement, 'id')\n if (id) return id\n\n const context = readJsxStaticAttribute(openingElement, 'context')\n const offsetRaw = readJsxStaticNumber(openingElement, 'offset')\n const forms = [\n readJsxStaticAttribute(openingElement, 'zero') === undefined ? undefined : `=0 {${readJsxStaticAttribute(openingElement, 'zero')}}`,\n readJsxStaticAttribute(openingElement, 'one') === undefined ? undefined : `one {${readJsxStaticAttribute(openingElement, 'one')}}`,\n readJsxStaticAttribute(openingElement, 'two') === undefined ? undefined : `two {${readJsxStaticAttribute(openingElement, 'two')}}`,\n readJsxStaticAttribute(openingElement, 'few') === undefined ? undefined : `few {${readJsxStaticAttribute(openingElement, 'few')}}`,\n readJsxStaticAttribute(openingElement, 'many') === undefined ? undefined : `many {${readJsxStaticAttribute(openingElement, 'many')}}`,\n readJsxStaticAttribute(openingElement, 'other') === undefined ? undefined : `other {${readJsxStaticAttribute(openingElement, 'other')}}`,\n ].filter(Boolean)\n\n if (forms.length === 0) return undefined\n\n const offsetPart = typeof offsetRaw === 'number' ? ` offset:${offsetRaw}` : ''\n const icuMessage = `{count, plural,${offsetPart} ${forms.join(' ')}}`\n return hashMessage(icuMessage, context)\n}\n\nfunction buildSelectMessageId(openingElement: JSXOpeningElementNode): string | undefined {\n const id = readJsxStaticAttribute(openingElement, 'id')\n if (id) return id\n\n const context = readJsxStaticAttribute(openingElement, 'context')\n const forms = readStaticSelectForms(openingElement)\n if (!forms || forms['other'] === undefined) return undefined\n\n const orderedKeys = [...Object.keys(forms).filter((key) => key !== 'other').sort(), 'other']\n const icuMessage = `{value, select, ${orderedKeys.map((key) => `${key} {${forms[key]!}}`).join(' ')}}`\n return hashMessage(icuMessage, context)\n}\n\nfunction readStaticSelectForms(openingElement: JSXOpeningElementNode): Record<string, string> | undefined {\n const optionForms = readJsxStaticObject(openingElement, 'options')\n if (optionForms) {\n const other = readJsxStaticAttribute(openingElement, 'other')\n return {\n ...optionForms,\n ...(other !== undefined ? { other } : {}),\n }\n }\n\n const forms: Record<string, string> = {}\n for (const attribute of openingElement.attributes) {\n if (!isJsxAttribute(attribute)) continue\n const name = attribute.name.name\n if (['value', 'id', 'context', 'comment', 'options'].includes(name)) continue\n const value = readJsxAttributeValue(attribute)\n if (value !== undefined) {\n forms[name] = value\n }\n }\n\n return Object.keys(forms).length > 0 ? forms : undefined\n}\n\nfunction readStaticSelectObjectValue(node: SourceNode): Record<string, string> | undefined {\n if (!isObjectExpression(node)) return undefined\n const values: Record<string, string> = {}\n\n for (const property of node.properties) {\n if (!isObjectProperty(property) || property.computed) return undefined\n const key = readPropertyKey(property.key)\n const value = readStaticString(property.value)\n if (!key || value === undefined) return undefined\n values[key] = value\n }\n\n return values\n}\n\nfunction readJsxStaticObject(openingElement: JSXOpeningElementNode, name: string): Record<string, string> | undefined {\n const attribute = findJsxAttribute(openingElement, name)\n if (!attribute?.value) return undefined\n if (attribute.value.type !== 'JSXExpressionContainer') return undefined\n return readStaticSelectObjectValue((attribute.value as JSXExpressionContainerNode).expression)\n}\n\nfunction readJsxStaticAttribute(openingElement: JSXOpeningElementNode, name: string): string | undefined {\n return readJsxAttributeValue(findJsxAttribute(openingElement, name))\n}\n\nfunction readJsxStaticNumber(openingElement: JSXOpeningElementNode, name: string): number | undefined {\n const attribute = findJsxAttribute(openingElement, name)\n if (!attribute?.value || attribute.value.type !== 'JSXExpressionContainer') return undefined\n const expression = (attribute.value as JSXExpressionContainerNode).expression\n return expression.type === 'NumericLiteral' ? (expression as NumericLiteralNode).value : undefined\n}\n\nfunction findJsxAttribute(openingElement: JSXOpeningElementNode, name: string): JSXAttributeNode | undefined {\n return openingElement.attributes.find((attribute) => {\n return isJsxAttribute(attribute) && attribute.name.name === name\n }) as JSXAttributeNode | undefined\n}\n\nfunction readJsxAttributeValue(attribute: JSXAttributeNode | undefined): string | undefined {\n if (!attribute?.value) return undefined\n\n if (attribute.value.type === 'StringLiteral') {\n return (attribute.value as StringLiteralNode).value\n }\n\n if (attribute.value.type === 'JSXExpressionContainer') {\n return readStaticString((attribute.value as JSXExpressionContainerNode).expression)\n }\n\n return undefined\n}\n\nfunction readJsxName(node: SourceNode): string | undefined {\n return node.type === 'JSXIdentifier' ? (node as JSXIdentifierNode).name : undefined\n}\n\nfunction readStaticString(node: SourceNode): string | undefined {\n if (node.type === 'StringLiteral') {\n return (node as StringLiteralNode).value\n }\n\n if (node.type === 'TemplateLiteral') {\n const template = node as TemplateLiteralNode\n if (template.expressions.length === 0 && template.quasis.length === 1) {\n return template.quasis[0]!.value.cooked ?? template.quasis[0]!.value.raw\n }\n }\n\n return undefined\n}\n\nfunction readPropertyKey(node: SourceNode): string | undefined {\n if (isIdentifier(node)) return node.name\n if (node.type === 'StringLiteral') return (node as StringLiteralNode).value\n return undefined\n}\n\nfunction isImportDeclaration(node: SourceNode): node is ImportDeclarationNode {\n return node.type === 'ImportDeclaration'\n}\n\nfunction isImportSpecifier(node: SourceNode): node is ImportSpecifierNode {\n return node.type === 'ImportSpecifier'\n}\n\nfunction isVariableDeclarator(node: SourceNode): node is VariableDeclaratorNode {\n return node.type === 'VariableDeclarator'\n}\n\nfunction isObjectPattern(node: SourceNode): node is ObjectPatternNode {\n return node.type === 'ObjectPattern'\n}\n\nfunction isObjectExpression(node: SourceNode): node is ObjectExpressionNode {\n return node.type === 'ObjectExpression'\n}\n\nfunction isObjectProperty(node: SourceNode): node is ObjectPropertyNode {\n return node.type === 'ObjectProperty'\n}\n\nfunction isCallExpression(node: SourceNode): node is CallExpressionNode {\n return node.type === 'CallExpression'\n}\n\nfunction isMemberExpression(node: SourceNode): node is MemberExpressionNode {\n return node.type === 'MemberExpression'\n}\n\nfunction isIdentifier(node: SourceNode | undefined | null): node is IdentifierNode {\n return node?.type === 'Identifier'\n}\n\nfunction isJsxElement(node: SourceNode): node is JSXElementNode {\n return node.type === 'JSXElement'\n}\n\nfunction isJsxAttribute(node: SourceNode): node is JSXAttributeNode {\n return node.type === 'JSXAttribute'\n}\n\nfunction readImportedName(specifier: ImportSpecifierNode): string | undefined {\n const imported = specifier.imported\n if (imported.type === 'Identifier') return imported.name\n if (imported.type === 'StringLiteral') return imported.value\n return undefined\n}\n\n/**\n * Inject the catalog import statement at the top of the module.\n */\nexport function injectCatalogImport(code: string, strategy: 'dynamic' | 'static' | 'per-route', hashes: Set<string>): string {\n if (strategy === 'dynamic') {\n return `import { __catalog } from 'virtual:fluenti/runtime';\\n${code}`\n }\n\n if (strategy === 'per-route') {\n return `import { __catalog } from 'virtual:fluenti/route-runtime';\\n${code}`\n }\n\n // Static: import named exports directly\n const imports = [...hashes].map((id) => `_${hashMessage(id)}`).join(', ')\n return `import { ${imports} } from 'virtual:fluenti/messages';\\n${code}`\n}\n","/**\n * Virtual module resolution for code-splitting mode.\n *\n * Provides:\n * - virtual:fluenti/runtime → reactive catalog + switchLocale + preloadLocale\n * - virtual:fluenti/messages → re-export from static locale (for static strategy)\n * - virtual:fluenti/route-runtime → per-route splitting runtime\n */\n\nimport { resolve } from 'node:path'\nimport { validateLocale } from '@fluenti/core'\nimport type { RuntimeGenerator, RuntimeGeneratorOptions } from './types'\n\nconst VIRTUAL_RUNTIME = 'virtual:fluenti/runtime'\nconst VIRTUAL_MESSAGES = 'virtual:fluenti/messages'\nconst VIRTUAL_ROUTE_RUNTIME = 'virtual:fluenti/route-runtime'\nconst RESOLVED_RUNTIME = '\\0virtual:fluenti/runtime'\nconst RESOLVED_MESSAGES = '\\0virtual:fluenti/messages'\nconst RESOLVED_ROUTE_RUNTIME = '\\0virtual:fluenti/route-runtime'\n\nexport interface VirtualModuleOptions {\n catalogDir: string\n locales: string[]\n sourceLocale: string\n defaultBuildLocale: string\n framework: 'vue' | 'solid' | 'react'\n runtimeGenerator?: RuntimeGenerator | undefined\n}\n\nexport function resolveVirtualSplitId(id: string): string | undefined {\n if (id === VIRTUAL_RUNTIME) return RESOLVED_RUNTIME\n if (id === VIRTUAL_MESSAGES) return RESOLVED_MESSAGES\n if (id === VIRTUAL_ROUTE_RUNTIME) return RESOLVED_ROUTE_RUNTIME\n return undefined\n}\n\nexport function loadVirtualSplitModule(\n id: string,\n options: VirtualModuleOptions,\n): string | undefined {\n if (id === RESOLVED_RUNTIME) {\n return generateRuntimeModule(options)\n }\n if (id === RESOLVED_MESSAGES) {\n return generateStaticMessagesModule(options)\n }\n if (id === RESOLVED_ROUTE_RUNTIME) {\n return generateRouteRuntimeModule(options)\n }\n return undefined\n}\n\nfunction generateRuntimeModule(options: VirtualModuleOptions): string {\n const { locales, runtimeGenerator } = options\n for (const locale of locales) {\n validateLocale(locale, 'vite-plugin')\n }\n\n if (runtimeGenerator) {\n return runtimeGenerator.generateRuntime(toRuntimeGeneratorOptions(options))\n }\n\n // Legacy fallback: inline generation for backward compat\n return generateLegacyRuntimeModule(options)\n}\n\nfunction generateStaticMessagesModule(options: VirtualModuleOptions): string {\n const { catalogDir, defaultBuildLocale, sourceLocale } = options\n const defaultLocale = defaultBuildLocale || sourceLocale\n const absoluteCatalogDir = resolve(process.cwd(), catalogDir)\n\n return `export * from '${absoluteCatalogDir}/${defaultLocale}.js'\\n`\n}\n\n/**\n * Generate the route runtime module for per-route splitting.\n */\nexport function generateRouteRuntimeModule(options: VirtualModuleOptions): string {\n const { locales, runtimeGenerator } = options\n for (const locale of locales) {\n validateLocale(locale, 'vite-plugin')\n }\n\n if (runtimeGenerator) {\n return runtimeGenerator.generateRouteRuntime(toRuntimeGeneratorOptions(options))\n }\n\n // Legacy fallback\n return generateLegacyRouteRuntimeModule(options)\n}\n\nfunction toRuntimeGeneratorOptions(options: VirtualModuleOptions): RuntimeGeneratorOptions {\n const { catalogDir, locales, sourceLocale, defaultBuildLocale } = options\n return { catalogDir, locales, sourceLocale, defaultBuildLocale }\n}\n\n// ─── Legacy inline runtime generators (used when no RuntimeGenerator is provided) ──\n\nfunction generateLegacyRuntimeModule(options: VirtualModuleOptions): string {\n const { catalogDir, locales, sourceLocale, defaultBuildLocale, framework } = options\n const defaultLocale = defaultBuildLocale || sourceLocale\n const absoluteCatalogDir = resolve(process.cwd(), catalogDir)\n const runtimeKey = `fluenti.runtime.${framework}`\n const lazyLocales = locales.filter((locale) => locale !== defaultLocale)\n\n if (framework === 'react') {\n return `\nimport __defaultMsgs from '${absoluteCatalogDir}/${defaultLocale}.js'\n\nconst __catalog = { ...__defaultMsgs }\nlet __currentLocale = '${defaultLocale}'\nconst __loadedLocales = new Set(['${defaultLocale}'])\nlet __loading = false\nconst __cache = new Map()\nconst __normalizeMessages = (mod) => mod.default ?? mod\n\nconst __loaders = {\n${lazyLocales.map((l) => ` '${l}': () => import('${absoluteCatalogDir}/${l}.js'),`).join('\\n')}\n}\n\nasync function __switchLocale(locale) {\n if (__loadedLocales.has(locale)) {\n Object.assign(__catalog, __cache.get(locale) || __defaultMsgs)\n __currentLocale = locale\n return\n }\n __loading = true\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n Object.assign(__catalog, mod)\n __currentLocale = locale\n } finally {\n __loading = false\n }\n}\n\nasync function __preloadLocale(locale) {\n if (__loadedLocales.has(locale) || !__loaders[locale]) return\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n } catch (e) { console.warn('[fluenti] preload failed:', locale, e) }\n}\n\nglobalThis[Symbol.for('${runtimeKey}')] = { __switchLocale, __preloadLocale }\n\nexport { __catalog, __switchLocale, __preloadLocale, __currentLocale, __loading, __loadedLocales }\n`\n }\n\n if (framework === 'vue') {\n return `\nimport { shallowReactive, triggerRef, ref } from 'vue'\nimport __defaultMsgs from '${absoluteCatalogDir}/${defaultLocale}.js'\n\nconst __catalog = shallowReactive({ ...__defaultMsgs })\nconst __currentLocale = ref('${defaultLocale}')\nconst __loadedLocales = new Set(['${defaultLocale}'])\nconst __loading = ref(false)\nconst __cache = new Map()\nconst __normalizeMessages = (mod) => mod.default ?? mod\n\nconst __loaders = {\n${lazyLocales.map((l) => ` '${l}': () => import('${absoluteCatalogDir}/${l}.js'),`).join('\\n')}\n}\n\nasync function __switchLocale(locale) {\n if (__loadedLocales.has(locale)) {\n Object.assign(__catalog, __cache.get(locale) || __defaultMsgs)\n __currentLocale.value = locale\n return\n }\n __loading.value = true\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n Object.assign(__catalog, mod)\n __currentLocale.value = locale\n } finally {\n __loading.value = false\n }\n}\n\nasync function __preloadLocale(locale) {\n if (__loadedLocales.has(locale) || !__loaders[locale]) return\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n } catch (e) { console.warn('[fluenti] preload failed:', locale, e) }\n}\n\nglobalThis[Symbol.for('${runtimeKey}')] = { __switchLocale, __preloadLocale }\n\nexport { __catalog, __switchLocale, __preloadLocale, __currentLocale, __loading, __loadedLocales }\n`\n }\n\n // Solid\n return `\nimport { createSignal } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport __defaultMsgs from '${absoluteCatalogDir}/${defaultLocale}.js'\n\nconst [__catalog, __setCatalog] = createStore({ ...__defaultMsgs })\nconst [__currentLocale, __setCurrentLocale] = createSignal('${defaultLocale}')\nconst __loadedLocales = new Set(['${defaultLocale}'])\nconst [__loading, __setLoading] = createSignal(false)\nconst __cache = new Map()\nconst __normalizeMessages = (mod) => mod.default ?? mod\n\nconst __loaders = {\n${lazyLocales.map((l) => ` '${l}': () => import('${absoluteCatalogDir}/${l}.js'),`).join('\\n')}\n}\n\nasync function __switchLocale(locale) {\n if (__loadedLocales.has(locale)) {\n __setCatalog(reconcile(__cache.get(locale) || __defaultMsgs))\n __setCurrentLocale(locale)\n return\n }\n __setLoading(true)\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n __setCatalog(reconcile(mod))\n __setCurrentLocale(locale)\n } finally {\n __setLoading(false)\n }\n}\n\nasync function __preloadLocale(locale) {\n if (__loadedLocales.has(locale) || !__loaders[locale]) return\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n } catch (e) { console.warn('[fluenti] preload failed:', locale, e) }\n}\n\nglobalThis[Symbol.for('${runtimeKey}')] = { __switchLocale, __preloadLocale }\n\nexport { __catalog, __switchLocale, __preloadLocale, __currentLocale, __loading, __loadedLocales }\n`\n}\n\nfunction generateLegacyRouteRuntimeModule(options: VirtualModuleOptions): string {\n const { catalogDir, locales, sourceLocale, defaultBuildLocale, framework } = options\n const defaultLocale = defaultBuildLocale || sourceLocale\n const absoluteCatalogDir = resolve(process.cwd(), catalogDir)\n const runtimeKey = `fluenti.runtime.${framework}`\n const lazyLocales = locales.filter((locale) => locale !== defaultLocale)\n\n if (framework === 'vue') {\n return `\nimport { shallowReactive, ref } from 'vue'\nimport __defaultMsgs from '${absoluteCatalogDir}/${defaultLocale}.js'\n\nconst __catalog = shallowReactive({ ...__defaultMsgs })\nconst __currentLocale = ref('${defaultLocale}')\nconst __loadedLocales = new Set(['${defaultLocale}'])\nconst __loading = ref(false)\nconst __cache = new Map()\nconst __loadedRoutes = new Set()\nconst __normalizeMessages = (mod) => mod.default ?? mod\n\nconst __loaders = {\n${lazyLocales.map((l) => ` '${l}': () => import('${absoluteCatalogDir}/${l}.js'),`).join('\\n')}\n}\n\nconst __routeLoaders = {}\n\nfunction __registerRouteLoader(routeId, locale, loader) {\n const key = routeId + ':' + locale\n __routeLoaders[key] = loader\n}\n\nasync function __loadRoute(routeId, locale) {\n const key = routeId + ':' + (locale || __currentLocale.value)\n if (__loadedRoutes.has(key)) return\n const loader = __routeLoaders[key]\n if (!loader) return\n const mod = __normalizeMessages(await loader())\n Object.assign(__catalog, mod)\n __loadedRoutes.add(key)\n}\n\nasync function __switchLocale(locale) {\n if (locale === __currentLocale.value) return\n __loading.value = true\n try {\n if (__cache.has(locale)) {\n Object.assign(__catalog, __cache.get(locale))\n } else {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n Object.assign(__catalog, mod)\n }\n __loadedLocales.add(locale)\n __currentLocale.value = locale\n } finally {\n __loading.value = false\n }\n}\n\nasync function __preloadLocale(locale) {\n if (__cache.has(locale) || !__loaders[locale]) return\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n } catch (e) { console.warn('[fluenti] preload failed:', locale, e) }\n}\n\nglobalThis[Symbol.for('${runtimeKey}')] = { __switchLocale, __preloadLocale }\n\nexport { __catalog, __switchLocale, __preloadLocale, __loadRoute, __registerRouteLoader, __currentLocale, __loading, __loadedLocales }\n`\n }\n\n // Solid\n return `\nimport { createSignal } from 'solid-js'\nimport { createStore, reconcile } from 'solid-js/store'\nimport __defaultMsgs from '${absoluteCatalogDir}/${defaultLocale}.js'\n\nconst [__catalog, __setCatalog] = createStore({ ...__defaultMsgs })\nconst [__currentLocale, __setCurrentLocale] = createSignal('${defaultLocale}')\nconst __loadedLocales = new Set(['${defaultLocale}'])\nconst [__loading, __setLoading] = createSignal(false)\nconst __cache = new Map()\nconst __loadedRoutes = new Set()\nconst __normalizeMessages = (mod) => mod.default ?? mod\n\nconst __loaders = {\n${lazyLocales.map((l) => ` '${l}': () => import('${absoluteCatalogDir}/${l}.js'),`).join('\\n')}\n}\n\nconst __routeLoaders = {}\n\nfunction __registerRouteLoader(routeId, locale, loader) {\n const key = routeId + ':' + locale\n __routeLoaders[key] = loader\n}\n\nasync function __loadRoute(routeId, locale) {\n const key = routeId + ':' + (locale || __currentLocale())\n if (__loadedRoutes.has(key)) return\n const loader = __routeLoaders[key]\n if (!loader) return\n const mod = __normalizeMessages(await loader())\n __setCatalog(reconcile({ ...__catalog, ...mod }))\n __loadedRoutes.add(key)\n}\n\nasync function __switchLocale(locale) {\n if (locale === __currentLocale()) return\n __setLoading(true)\n try {\n if (__cache.has(locale)) {\n __setCatalog(reconcile(__cache.get(locale)))\n } else {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __setCatalog(reconcile(mod))\n }\n __loadedLocales.add(locale)\n __setCurrentLocale(locale)\n } finally {\n __setLoading(false)\n }\n}\n\nasync function __preloadLocale(locale) {\n if (__cache.has(locale) || !__loaders[locale]) return\n try {\n const mod = __normalizeMessages(await __loaders[locale]())\n __cache.set(locale, mod)\n __loadedLocales.add(locale)\n } catch (e) { console.warn('[fluenti] preload failed:', locale, e) }\n}\n\nglobalThis[Symbol.for('${runtimeKey}')] = { __switchLocale, __preloadLocale }\n\nexport { __catalog, __switchLocale, __preloadLocale, __loadRoute, __registerRouteLoader, __currentLocale, __loading, __loadedLocales }\n`\n}\n","/**\n * Utilities for per-route message splitting.\n *\n * - deriveRouteName: strips hash/dir/ext from chunk filenames to produce stable route IDs\n * - parseCompiledCatalog: extracts Map<hash, exportLine> from compiled catalog source\n * - readCatalogSource: reads compiled catalog file from disk\n */\n\nimport { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { hashMessage } from '@fluenti/core'\n\n/**\n * Derive a stable route name from a Rollup chunk filename.\n *\n * Examples:\n * 'assets/index-abc123.js' → 'index'\n * 'assets/about-def456.js' → 'about'\n * 'pages/settings-g7h8.js' → 'settings'\n * 'index.js' → 'index'\n */\nexport function deriveRouteName(chunkFileName: string): string {\n // Strip directory prefix\n const base = chunkFileName.includes('/')\n ? chunkFileName.slice(chunkFileName.lastIndexOf('/') + 1)\n : chunkFileName\n\n // Strip extension\n const withoutExt = base.replace(/\\.[^.]+$/, '')\n\n // Strip trailing hash (e.g., 'index-abc123' → 'index')\n // Hash pattern: dash followed by alphanumeric chars at end\n const withoutHash = withoutExt.replace(/-[a-zA-Z0-9]{4,}$/, '')\n\n return withoutHash || withoutExt\n}\n\n/**\n * Parse a compiled catalog source and extract named exports by hash.\n *\n * The CLI outputs lines like:\n * export const _abc123 = \"Hello\"\n * export const _def456 = (v) => `Hello ${v.name}`\n *\n * Returns a Map from hash (without underscore prefix) to the full export line.\n */\nexport function parseCompiledCatalog(source: string): Map<string, string> {\n const exports = new Map<string, string>()\n\n // Match lines: export const _<hash> = <anything until end of statement>\n // Handles multi-line arrow functions by tracking balanced braces\n const lines = source.split('\\n')\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const match = line.match(/^(?:\\/\\*.*?\\*\\/\\s*)?export\\s+const\\s+_([a-z0-9]+)\\s*=\\s*/)\n if (!match) continue\n\n const hash = match[1]!\n\n // Collect the full statement — may span multiple lines if it contains template literals or functions\n let statement = line\n let braceDepth = 0\n let parenDepth = 0\n let templateDepth = 0\n\n for (const ch of line.slice(match[0].length)) {\n if (ch === '{') braceDepth++\n if (ch === '}') braceDepth--\n if (ch === '(') parenDepth++\n if (ch === ')') parenDepth--\n if (ch === '`') templateDepth = templateDepth === 0 ? 1 : 0\n }\n\n while ((braceDepth > 0 || parenDepth > 0 || templateDepth > 0) && i + 1 < lines.length) {\n i++\n const nextLine = lines[i]!\n statement += '\\n' + nextLine\n for (const ch of nextLine) {\n if (ch === '{') braceDepth++\n if (ch === '}') braceDepth--\n if (ch === '(') parenDepth++\n if (ch === ')') parenDepth--\n if (ch === '`') templateDepth = templateDepth === 0 ? 1 : 0\n }\n }\n\n exports.set(hash, statement)\n }\n\n return exports\n}\n\n/**\n * Build a JS module that re-exports only the specified hashes from a catalog.\n *\n * Given hashes ['abc', 'def'] and catalog exports, produces:\n * export const _abc = \"Hello\"\n * export const _def = (v) => `Hi ${v.name}`\n */\nexport function buildChunkModule(\n catalogIds: ReadonlySet<string>,\n catalogExports: Map<string, string>,\n): string {\n const lines: string[] = []\n const defaultEntries: string[] = []\n\n for (const catalogId of catalogIds) {\n const exportHash = hashMessage(catalogId)\n const exportLine = catalogExports.get(exportHash)\n if (exportLine) {\n lines.push(exportLine)\n defaultEntries.push(` '${escapeStringLiteral(catalogId)}': _${exportHash},`)\n }\n }\n\n if (defaultEntries.length > 0) {\n lines.push('', 'export default {', ...defaultEntries, '}')\n }\n\n return lines.join('\\n') + '\\n'\n}\n\n/**\n * Read a compiled catalog file from disk.\n * Returns the source string, or undefined if the file doesn't exist.\n */\nexport function readCatalogSource(catalogDir: string, locale: string): string | undefined {\n try {\n return readFileSync(resolve(catalogDir, `${locale}.js`), 'utf-8')\n } catch {\n return undefined\n }\n}\n\nfunction escapeStringLiteral(value: string): string {\n return value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\r/g, '\\\\r')\n .replace(/\\n/g, '\\\\n')\n}\n","import type { Plugin } from 'vite'\nimport type { FluentiCoreOptions, RuntimeGenerator } from './types'\nimport { setResolvedMode, isBuildMode } from './mode-detect'\nimport { resolve } from 'node:path'\nimport { createDebouncedRunner, runExtractCompile } from './dev-runner'\nimport { transformForDynamicSplit, transformForStaticSplit, injectCatalogImport } from './build-transform'\nimport { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules'\nimport { deriveRouteName, parseCompiledCatalog, buildChunkModule, readCatalogSource } from './route-resolve'\nimport { scopeTransform } from './scope-transform'\nimport { transformTransComponents } from './trans-transform'\nexport type { FluentiPluginOptions, FluentiCoreOptions, RuntimeGenerator, RuntimeGeneratorOptions } from './types'\nexport { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules'\nexport { setResolvedMode, isBuildMode } from './mode-detect'\n\nconst VIRTUAL_PREFIX = 'virtual:fluenti/messages/'\nconst RESOLVED_PREFIX = '\\0virtual:fluenti/messages/'\ntype InternalSplitStrategy = FluentiCoreOptions['splitting'] | 'per-route'\n\n// ─── Public factory for framework packages ─────────────────────────────────\n\n/**\n * Create the Fluenti plugin pipeline.\n * Framework packages call this with their framework-specific plugins and runtime generator.\n */\nexport function createFluentiPlugins(\n options: FluentiCoreOptions,\n frameworkPlugins: Plugin[],\n runtimeGenerator?: RuntimeGenerator,\n): Plugin[] {\n const catalogDir = options.catalogDir ?? 'src/locales/compiled'\n const framework = options.framework\n const splitting = (options.splitting as InternalSplitStrategy | undefined) ?? false\n const sourceLocale = options.sourceLocale ?? 'en'\n const locales = options.locales ?? [sourceLocale]\n const defaultBuildLocale = options.defaultBuildLocale ?? sourceLocale\n\n const virtualPlugin: Plugin = {\n name: 'fluenti:virtual',\n configResolved(config) {\n setResolvedMode(config.command)\n },\n resolveId(id) {\n if (id.startsWith(VIRTUAL_PREFIX)) {\n return '\\0' + id\n }\n if (splitting) {\n const resolved = resolveVirtualSplitId(id)\n if (resolved) return resolved\n }\n return undefined\n },\n load(id) {\n if (id.startsWith(RESOLVED_PREFIX)) {\n const locale = id.slice(RESOLVED_PREFIX.length)\n const catalogPath = `${catalogDir}/${locale}.js`\n return `export { default } from '${catalogPath}'`\n }\n if (splitting) {\n const result = loadVirtualSplitModule(id, {\n catalogDir,\n locales,\n sourceLocale,\n defaultBuildLocale,\n framework,\n runtimeGenerator,\n })\n if (result) return result\n }\n return undefined\n },\n }\n\n const scriptTransformPlugin: Plugin = {\n name: 'fluenti:script-transform',\n enforce: 'pre',\n transform(code, id) {\n if (id.includes('node_modules')) return undefined\n if (!id.match(/\\.(vue|tsx|jsx|ts|js)(\\?|$)/)) return undefined\n if (id.includes('.vue') && !id.includes('type=script')) return undefined\n\n let result = code\n let changed = false\n\n // ── <Trans> compile-time optimization (JSX/TSX only) ──────────────\n if (id.match(/\\.[jt]sx(\\?|$)/) && /<Trans[\\s>]/.test(result)) {\n const transResult = transformTransComponents(result)\n if (transResult.transformed) {\n result = transResult.code\n changed = true\n }\n }\n\n // ── t`` / t() scope-aware transform ────────────────────────────────\n if (hasScopeTransformCandidate(result)) {\n const scoped = scopeTransform(result, {\n framework,\n allowTopLevelImportedT: framework === 'vue' && id.includes('.vue'),\n })\n if (scoped.transformed) {\n return { code: scoped.code, map: null }\n }\n }\n\n return changed ? { code: result, map: null } : undefined\n },\n }\n\n // Track module → used hashes for per-route splitting\n const moduleMessages = new Map<string, Set<string>>()\n\n const buildSplitPlugin: Plugin = {\n name: 'fluenti:build-split',\n transform(code, id) {\n if (!splitting) return undefined\n if (!isBuildMode((this as any).environment)) return undefined\n if (id.includes('node_modules')) return undefined\n if (!id.match(/\\.(vue|tsx|jsx|ts|js)(\\?|$)/)) return undefined\n\n const strategy = splitting === 'static' ? 'static' : 'dynamic'\n const transformed = strategy === 'static'\n ? transformForStaticSplit(code)\n : transformForDynamicSplit(code)\n\n if (splitting === 'per-route' && transformed.usedHashes.size > 0) {\n moduleMessages.set(id, transformed.usedHashes)\n }\n\n if (!transformed.needsCatalogImport) return undefined\n\n const importStrategy = splitting === 'per-route' ? 'per-route' : strategy\n const finalCode = injectCatalogImport(transformed.code, importStrategy, transformed.usedHashes)\n return { code: finalCode, map: null }\n },\n\n generateBundle(_outputOptions, bundle) {\n if (splitting !== 'per-route') return\n if (moduleMessages.size === 0) return\n\n const chunkHashes = new Map<string, Set<string>>()\n for (const [fileName, chunk] of Object.entries(bundle)) {\n if (chunk.type !== 'chunk') continue\n const hashes = new Set<string>()\n for (const moduleId of Object.keys(chunk.modules)) {\n const modHashes = moduleMessages.get(moduleId)\n if (modHashes) {\n for (const h of modHashes) hashes.add(h)\n }\n }\n if (hashes.size > 0) {\n chunkHashes.set(fileName, hashes)\n }\n }\n\n if (chunkHashes.size === 0) return\n\n const hashToChunks = new Map<string, string[]>()\n for (const [chunkName, hashes] of chunkHashes) {\n for (const h of hashes) {\n const chunks = hashToChunks.get(h) ?? []\n chunks.push(chunkName)\n hashToChunks.set(h, chunks)\n }\n }\n\n const sharedHashes = new Set<string>()\n const routeHashes = new Map<string, Set<string>>()\n\n for (const [hash, chunks] of hashToChunks) {\n if (chunks.length > 1) {\n sharedHashes.add(hash)\n } else {\n const routeName = deriveRouteName(chunks[0]!)\n const existing = routeHashes.get(routeName) ?? new Set()\n existing.add(hash)\n routeHashes.set(routeName, existing)\n }\n }\n\n const absoluteCatalogDir = resolve(process.cwd(), catalogDir)\n for (const locale of locales) {\n const catalogSource = readCatalogSource(absoluteCatalogDir, locale)\n if (!catalogSource) continue\n const catalogExports = parseCompiledCatalog(catalogSource)\n\n if (sharedHashes.size > 0) {\n const sharedCode = buildChunkModule(sharedHashes, catalogExports)\n this.emitFile({\n type: 'asset',\n fileName: `_fluenti/shared-${locale}.js`,\n source: sharedCode,\n })\n }\n\n for (const [routeName, hashes] of routeHashes) {\n const routeCode = buildChunkModule(hashes, catalogExports)\n this.emitFile({\n type: 'asset',\n fileName: `_fluenti/${routeName}-${locale}.js`,\n source: routeCode,\n })\n }\n }\n },\n }\n\n const buildAutoCompile = options.buildAutoCompile ?? true\n\n const buildCompilePlugin: Plugin = {\n name: 'fluenti:build-compile',\n async buildStart() {\n if (!isBuildMode((this as any).environment) || !buildAutoCompile) return\n const cwd = process.cwd()\n await runExtractCompile({ cwd, throwOnError: true, compileOnly: true })\n },\n }\n\n const devAutoCompile = options.devAutoCompile ?? true\n const includePatterns = options.include ?? ['src/**/*.{vue,tsx,jsx,ts,js}']\n\n const devPlugin: Plugin = {\n name: 'fluenti:dev',\n configureServer(server) {\n if (!devAutoCompile) return\n\n const debouncedRun = createDebouncedRunner({\n cwd: server.config.root,\n onSuccess: () => {\n // Existing hotUpdate will pick up catalog changes\n },\n })\n\n debouncedRun()\n\n server.watcher.on('change', (file) => {\n if (matchesInclude(file, includePatterns) && !file.includes(catalogDir)) {\n debouncedRun()\n }\n })\n },\n hotUpdate({ file }) {\n if (file.includes(catalogDir)) {\n const modules = [...this.environment.moduleGraph.urlToModuleMap.entries()]\n .filter(([url]) => url.includes('virtual:fluenti'))\n .map(([, mod]) => mod)\n\n if (modules.length > 0) {\n return modules\n }\n }\n return undefined\n },\n }\n\n return [virtualPlugin, ...frameworkPlugins, scriptTransformPlugin, buildCompilePlugin, buildSplitPlugin, devPlugin]\n}\n\n// ─── Utilities ──────────────────────────────────────────────────────────────\n\nfunction matchesInclude(file: string, patterns: string[]): boolean {\n const extMatch = /\\.(vue|tsx|jsx|ts|js)$/.test(file)\n if (!extMatch) return false\n if (file.includes('node_modules')) return false\n return patterns.some((p) => {\n const dirPart = p.split('*')[0] ?? ''\n return dirPart === '' || file.includes(dirPart.replace('./', ''))\n })\n}\n\nfunction hasScopeTransformCandidate(code: string): boolean {\n if (/(?<![.\\w$])t\\(\\s*['\"]/.test(code) || /[A-Za-z_$][\\w$]*\\(\\s*\\{/.test(code)) {\n return true\n }\n\n if (/[A-Za-z_$][\\w$]*`/.test(code) && (code.includes('useI18n') || code.includes('getI18n'))) {\n return true\n }\n\n return /import\\s*\\{[^}]*\\bt(?:\\s+as\\s+[A-Za-z_$][\\w$]*)?\\b[^}]*\\}/.test(code)\n && /@fluenti\\/(react|vue|solid|next)/.test(code)\n}\n"],"mappings":"2OAKA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B,EAAQ,CACtB,GAAI,CAAC,EAAgB,OAErB,IAAM,EAAe,GAAsB,CACzC,IAAK,EAAO,OAAO,KACnB,cAAiB,GAGlB,CAAC,CAEF,GAAc,CAEd,EAAO,QAAQ,GAAG,SAAW,GAAS,CAChC,GAAe,EAAM,EAAgB,EAAI,CAAC,EAAK,SAAS,EAAW,EACrE,GAAc,EAEhB,EAEJ,UAAU,CAAE,QAAQ,CAClB,GAAI,EAAK,SAAS,EAAW,CAAE,CAC7B,IAAM,EAAU,CAAC,GAAG,KAAK,YAAY,YAAY,eAAe,SAAS,CAAC,CACvE,QAAQ,CAAC,KAAS,EAAI,SAAS,kBAAkB,CAAC,CAClD,KAAK,EAAG,KAAS,EAAI,CAExB,GAAI,EAAQ,OAAS,EACnB,OAAO,IAKd,CAED,MAAO,CAAC,EAAe,GAAG,EAAkB,EAAuB,EAAoB,EAAkB,EAAU,CAKrH,SAAS,GAAe,EAAc,EAA6B,CAIjE,MAFI,CADa,yBAAyB,KAAK,EAAK,EAEhD,EAAK,SAAS,eAAe,CAAS,GACnC,EAAS,KAAM,GAAM,CAC1B,IAAM,EAAU,EAAE,MAAM,IAAI,CAAC,IAAM,GACnC,OAAO,IAAY,IAAM,EAAK,SAAS,EAAQ,QAAQ,KAAM,GAAG,CAAC,EACjE,CAGJ,SAAS,GAA2B,EAAuB,CASzD,MARI,wBAAwB,KAAK,EAAK,EAAI,0BAA0B,KAAK,EAAK,EAI1E,oBAAoB,KAAK,EAAK,GAAK,EAAK,SAAS,UAAU,EAAI,EAAK,SAAS,UAAU,EAClF,GAGF,4DAA4D,KAAK,EAAK,EACxE,mCAAmC,KAAK,EAAK"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/mode-detect.ts","../src/dev-runner.ts","../src/build-transform.ts","../src/virtual-modules.ts","../src/route-resolve.ts","../src/index.ts"],"sourcesContent":["/**\n * Detect whether Vite is running in build or dev mode.\n * Supports Vite 7 (configResolved) and Vite 8+ (environment API).\n */\n\nlet resolvedMode: 'build' | 'dev' = 'dev'\n\n/** Called from configResolved hook to capture the mode early */\nexport function setResolvedMode(command: string): void {\n resolvedMode = command === 'build' ? 'build' : 'dev'\n}\n\n/** Get the current resolved mode */\nexport function getResolvedMode(): 'build' | 'dev' {\n return resolvedMode\n}\n\n/**\n * Safely extract the environment object from a Vite plugin context.\n * Handles Vite 8+ environment API without direct `(this as any)` casts at call sites.\n */\nexport function getPluginEnvironment(pluginContext: unknown): { mode?: string } | undefined {\n if (\n typeof pluginContext === 'object' &&\n pluginContext !== null &&\n 'environment' in pluginContext\n ) {\n const env = (pluginContext as Record<string, unknown>)['environment']\n if (typeof env === 'object' && env !== null) {\n return env as { mode?: string }\n }\n }\n return undefined\n}\n\n/**\n * Check if we're in build mode.\n * Tries environment API (Vite 8+), then falls back to configResolved capture,\n * then falls back to NODE_ENV.\n */\nexport function isBuildMode(environment?: { mode?: string }): boolean {\n // Vite 8+: environment.mode === 'build'\n if (environment?.mode === 'build') return true\n\n // Vite 7: captured from configResolved\n if (resolvedMode === 'build') return true\n\n // Last resort: NODE_ENV\n if (process.env['NODE_ENV'] === 'production') return true\n\n return false\n}\n","import { execFile } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { resolve, dirname, join } from 'node:path'\nimport { createRequire } from 'node:module'\n\nexport interface DevRunnerOptions {\n cwd: string\n onSuccess?: () => void\n onError?: (err: Error) => void\n /** If true, reject the promise on failure instead of swallowing the error */\n throwOnError?: boolean\n /** Run only compile (skip extract). Useful for production builds where source is unchanged. */\n compileOnly?: boolean\n /** Enable parallel compilation across locales using worker threads */\n parallelCompile?: boolean\n /** Called before compile runs. Return false to skip compilation. */\n onBeforeCompile?: () => boolean | void | Promise<boolean | void>\n /** Called after compile completes successfully */\n onAfterCompile?: () => void | Promise<void>\n}\n\n/**\n * Walk up from `cwd` to find `node_modules/.bin/fluenti`.\n * Returns the absolute path or null if not found.\n */\nexport function resolveCliBin(cwd: string): string | null {\n let dir = cwd\n for (;;) {\n const bin = resolve(dir, 'node_modules/.bin/fluenti')\n if (existsSync(bin)) return bin\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return null\n}\n\n/**\n * Run compile in-process via `@fluenti/cli` (for compileOnly mode),\n * or fall back to shell-out for extract + compile (dev mode).\n */\nexport async function runExtractCompile(options: DevRunnerOptions): Promise<void> {\n if (options.onBeforeCompile) {\n const result = await options.onBeforeCompile()\n if (result === false) return\n }\n\n if (options.compileOnly) {\n try {\n // Resolve @fluenti/cli from the project's cwd (not from this package's location)\n // using createRequire so pnpm's strict node_modules layout works correctly.\n // Use require() (not import()) to load @fluenti/cli — avoids CJS/ESM interop\n // issues when dynamic import() loads minified CJS with chunk requires.\n const projectRequire = createRequire(join(options.cwd, 'package.json'))\n const { runCompile } = projectRequire('@fluenti/cli')\n await runCompile(options.cwd)\n console.log('[fluenti] Compiling... done')\n if (options.onAfterCompile) await options.onAfterCompile()\n options.onSuccess?.()\n return\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e))\n if (options.throwOnError) throw error\n console.warn('[fluenti] Compile failed:', error.message)\n options.onError?.(error)\n return\n }\n }\n\n // Dev mode: in-process extract + compile (avoids shell-out overhead)\n try {\n const projectRequire = createRequire(join(options.cwd, 'package.json'))\n const { runExtract, runCompile } = projectRequire('@fluenti/cli')\n await runExtract(options.cwd)\n await runCompile(options.cwd, { parallel: options.parallelCompile })\n console.log('[fluenti] Extracting and compiling... done')\n if (options.onAfterCompile) await options.onAfterCompile()\n options.onSuccess?.()\n return\n } catch {\n // In-process failed — fall back to shell-out\n }\n\n const bin = resolveCliBin(options.cwd)\n if (!bin) {\n const msg = '[fluenti] CLI not found — skipping auto-compile. Install @fluenti/cli as a devDependency.'\n if (options.throwOnError) {\n return Promise.reject(new Error(msg))\n }\n console.warn(msg)\n return Promise.resolve()\n }\n\n const compileArgs = options.parallelCompile ? ['compile', '--parallel'] : ['compile']\n return new Promise<void>((resolve, reject) => {\n execFile(\n bin,\n ['extract'],\n { cwd: options.cwd },\n (extractErr, _stdout, extractStderr) => {\n if (extractErr) {\n const error = new Error(extractStderr || extractErr.message)\n if (options.throwOnError) {\n reject(error)\n return\n }\n console.warn('[fluenti] Extract/compile failed:', error.message)\n options.onError?.(error)\n resolve()\n return\n }\n execFile(\n bin,\n compileArgs,\n { cwd: options.cwd },\n (compileErr, _compileStdout, compileStderr) => {\n if (compileErr) {\n const error = new Error(compileStderr || compileErr.message)\n if (options.throwOnError) {\n reject(error)\n return\n }\n console.warn('[fluenti] Extract/compile failed:', error.message)\n options.onError?.(error)\n } else {\n console.log('[fluenti] Extracting and compiling... done')\n if (options.onAfterCompile) void Promise.resolve(options.onAfterCompile()).catch(() => {})\n options.onSuccess?.()\n }\n resolve()\n },\n )\n },\n )\n })\n}\n\n/**\n * Create a debounced runner that collapses rapid calls.\n *\n * - If called while idle, schedules a run after `delay` ms.\n * - If called while a run is in progress, marks a pending rerun.\n * - Never runs concurrently.\n */\nexport function createDebouncedRunner(\n options: DevRunnerOptions,\n delay = 300,\n): () => void {\n let timer: ReturnType<typeof setTimeout> | null = null\n let running = false\n let pendingRerun = false\n\n async function execute(): Promise<void> {\n running = true\n try {\n await runExtractCompile(options)\n } finally {\n running = false\n if (pendingRerun) {\n pendingRerun = false\n schedule()\n }\n }\n }\n\n function schedule(): void {\n if (timer !== null) {\n clearTimeout(timer)\n }\n timer = setTimeout(() => {\n timer = null\n if (running) {\n pendingRerun = true\n } else {\n execute()\n }\n }, delay)\n }\n\n return schedule\n}\n","/**\n * Build-mode transform for code-splitting.\n *\n * Strategy 'dynamic': rewrites supported translation calls to __catalog._<hash> references.\n * Strategy 'static': rewrites to direct named imports from compiled locale modules.\n */\n\nimport { hashMessage as defaultHashMessage } from '@fluenti/core/internal'\nimport { parseSourceModule, walkSourceAst, type SourceNode } from '@fluenti/core/transform'\n\nexport type HashFunction = (message: string, context?: string) => string\n\nexport interface BuildTransformResult {\n code: string\n needsCatalogImport: boolean\n usedHashes: Set<string>\n}\n\nexport interface BuildTransformOptions {\n /** Custom hash function for message IDs (defaults to @fluenti/core hashMessage) */\n hashFn?: HashFunction\n}\n\ntype SplitStrategy = 'dynamic' | 'static'\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: { cooked: string | null; raw: string }\n}\n\ninterface TemplateLiteralNode extends SourceNode {\n type: 'TemplateLiteral'\n expressions: SourceNode[]\n quasis: TemplateElementNode[]\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 CallExpressionNode extends SourceNode {\n type: 'CallExpression'\n callee: SourceNode\n arguments: SourceNode[]\n}\n\ninterface AwaitExpressionNode extends SourceNode {\n type: 'AwaitExpression'\n argument: SourceNode\n}\n\ninterface VariableDeclaratorNode extends SourceNode {\n type: 'VariableDeclarator'\n id: SourceNode\n init?: SourceNode | null\n}\n\ninterface ProgramNode extends SourceNode {\n type: 'Program'\n body: SourceNode[]\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 ObjectPatternNode extends SourceNode {\n type: 'ObjectPattern'\n properties: SourceNode[]\n}\n\ninterface MemberExpressionNode extends SourceNode {\n type: 'MemberExpression'\n object: SourceNode\n property: SourceNode\n computed?: boolean\n}\n\ninterface JSXElementNode extends SourceNode {\n type: 'JSXElement'\n openingElement: JSXOpeningElementNode\n}\n\ninterface JSXOpeningElementNode extends SourceNode {\n type: 'JSXOpeningElement'\n name: SourceNode\n attributes: SourceNode[]\n}\n\ninterface JSXIdentifierNode extends SourceNode {\n type: 'JSXIdentifier'\n name: string\n}\n\ninterface JSXAttributeNode extends SourceNode {\n type: 'JSXAttribute'\n name: JSXIdentifierNode\n value?: SourceNode | null\n}\n\ninterface JSXExpressionContainerNode extends SourceNode {\n type: 'JSXExpressionContainer'\n expression: SourceNode\n}\n\ninterface SplitReplacement {\n start: number\n end: number\n replacement: string\n}\n\ninterface SplitTarget {\n catalogId: string\n valuesSource?: string\n}\n\ninterface RuntimeBindings {\n tracked: Set<string>\n unref: Set<string>\n}\n\nexport function transformForDynamicSplit(code: string, options?: BuildTransformOptions): BuildTransformResult {\n return transformForSplitStrategy(code, 'dynamic', options)\n}\n\nexport function transformForStaticSplit(code: string, options?: BuildTransformOptions): BuildTransformResult {\n return transformForSplitStrategy(code, 'static', options)\n}\n\nfunction transformForSplitStrategy(\n code: string,\n strategy: SplitStrategy,\n options?: BuildTransformOptions,\n): BuildTransformResult {\n const hashFn = options?.hashFn ?? defaultHashMessage\n const ast = parseSourceModule(code)\n if (!ast || ast.type !== 'Program') {\n return { code, needsCatalogImport: false, usedHashes: new Set() }\n }\n\n const bindings = collectTrackedRuntimeBindings(ast as ProgramNode)\n const replacements: SplitReplacement[] = []\n const usedHashes = new Set<string>()\n\n walkSourceAst(ast, (node) => {\n const replacement = extractCallReplacement(code, node, bindings, strategy, usedHashes, hashFn)\n if (replacement) {\n replacements.push(replacement)\n return\n }\n\n collectComponentUsage(node, usedHashes, hashFn)\n })\n\n if (replacements.length === 0) {\n return { code, needsCatalogImport: false, usedHashes }\n }\n\n let result = code\n for (let i = replacements.length - 1; i >= 0; i--) {\n const { start, end, replacement } = replacements[i]!\n result = result.slice(0, start) + replacement + result.slice(end)\n }\n\n return { code: result, needsCatalogImport: true, usedHashes }\n}\n\nfunction collectTrackedRuntimeBindings(program: ProgramNode): RuntimeBindings {\n const tracked = new Set<string>()\n const useI18nBindings = new Set<string>()\n const getI18nBindings = new Set<string>()\n const unrefBindings = new Set<string>()\n\n for (const statement of program.body) {\n if (!isImportDeclaration(statement)) continue\n for (const specifier of statement.specifiers) {\n if (!isImportSpecifier(specifier)) continue\n const importedName = readImportedName(specifier)\n if (!importedName) continue\n if (importedName === 'useI18n') {\n useI18nBindings.add(specifier.local.name)\n }\n if (importedName === 'getI18n') {\n getI18nBindings.add(specifier.local.name)\n }\n if (importedName === 'unref') {\n unrefBindings.add(specifier.local.name)\n }\n }\n }\n\n walkSourceAst(program, (node) => {\n if (!isVariableDeclarator(node) || !node.init || !isObjectPattern(node.id)) return\n\n if (isCallExpression(node.init) && isIdentifier(node.init.callee) && useI18nBindings.has(node.init.callee.name)) {\n addTrackedObjectPatternBindings(node.id, tracked)\n return\n }\n\n const awaitedCall = node.init.type === 'AwaitExpression'\n ? (node.init as AwaitExpressionNode).argument\n : null\n\n if (\n awaitedCall\n && isCallExpression(awaitedCall)\n && isIdentifier(awaitedCall.callee)\n && getI18nBindings.has(awaitedCall.callee.name)\n ) {\n addTrackedObjectPatternBindings(node.id, tracked)\n }\n })\n\n return { tracked, unref: unrefBindings }\n}\n\nfunction addTrackedObjectPatternBindings(pattern: ObjectPatternNode, tracked: Set<string>): void {\n for (const property of pattern.properties) {\n if (!isObjectProperty(property) || property.computed) continue\n if (!isIdentifier(property.key) || property.key.name !== 't') continue\n if (isIdentifier(property.value)) {\n tracked.add(property.value.name)\n }\n }\n}\n\nfunction extractCallReplacement(\n code: string,\n node: SourceNode,\n bindings: RuntimeBindings,\n strategy: SplitStrategy,\n usedHashes: Set<string>,\n hashFn: HashFunction,\n): SplitReplacement | undefined {\n if (!isCallExpression(node) || node.start == null || node.end == null) {\n return undefined\n }\n\n const splitTarget = resolveSplitTarget(code, node, bindings, hashFn)\n if (!splitTarget) {\n return undefined\n }\n\n const { catalogId } = splitTarget\n usedHashes.add(catalogId)\n const exportHash = hashFn(catalogId)\n const replacementTarget = strategy === 'dynamic'\n ? `__catalog[${JSON.stringify(catalogId)}]`\n : `_${exportHash}`\n const replacement = splitTarget.valuesSource\n ? `${replacementTarget}(${splitTarget.valuesSource})`\n : replacementTarget\n\n return {\n start: node.start,\n end: node.end,\n replacement,\n }\n}\n\nfunction resolveSplitTarget(\n code: string,\n call: CallExpressionNode,\n bindings: RuntimeBindings,\n hashFn: HashFunction,\n): SplitTarget | undefined {\n if (call.arguments.length === 0) return undefined\n\n const callee = call.callee\n const isTrackedIdentifierCall = isIdentifier(callee) && (bindings.tracked.has(callee.name) || callee.name === '$t')\n const isTemplateMemberCall = isMemberExpression(callee)\n && !callee.computed\n && isIdentifier(callee.property)\n && (\n callee.property.name === '$t'\n || (\n callee.property.name === 't'\n && isIdentifier(callee.object)\n && (callee.object.name === '_ctx' || callee.object.name === '$setup')\n )\n )\n const isVueUnrefCall = isCallExpression(callee)\n && isIdentifier(callee.callee)\n && bindings.unref.has(callee.callee.name)\n && callee.arguments.length === 1\n && isIdentifier(callee.arguments[0])\n && bindings.tracked.has(callee.arguments[0].name)\n\n if (!isTrackedIdentifierCall && !isTemplateMemberCall && !isVueUnrefCall) {\n return undefined\n }\n\n const catalogId = extractCatalogId(call.arguments[0]!, hashFn)\n if (!catalogId) return undefined\n\n const valuesSource = call.arguments[1] && call.arguments[1]!.start != null && call.arguments[1]!.end != null\n ? code.slice(call.arguments[1]!.start, call.arguments[1]!.end)\n : undefined\n\n return valuesSource === undefined\n ? { catalogId }\n : { catalogId, valuesSource }\n}\n\nfunction extractCatalogId(argument: SourceNode, hashFn: HashFunction): string | undefined {\n const staticString = readStaticString(argument)\n if (staticString !== undefined) {\n return hashFn(staticString)\n }\n\n if (!isObjectExpression(argument)) {\n return undefined\n }\n\n let id: string | undefined\n let message: string | undefined\n let context: string | undefined\n\n for (const property of argument.properties) {\n if (!isObjectProperty(property) || property.computed) continue\n const key = readPropertyKey(property.key)\n if (!key) continue\n\n const value = readStaticString(property.value)\n if (value === undefined) continue\n\n if (key === 'id') id = value\n if (key === 'message') message = value\n if (key === 'context') context = value\n }\n\n if (id) return id\n if (message) return hashFn(message, context)\n return undefined\n}\n\nfunction collectComponentUsage(node: SourceNode, usedHashes: Set<string>, hashFn: HashFunction): void {\n if (!isJsxElement(node)) return\n\n const componentName = readJsxName(node.openingElement.name)\n if (!componentName) return\n\n if (componentName === 'Trans') {\n const id = readJsxStaticAttribute(node.openingElement, '__id') ?? readJsxStaticAttribute(node.openingElement, 'id')\n if (id) {\n usedHashes.add(id)\n return\n }\n\n const message = readJsxStaticAttribute(node.openingElement, '__message')\n const context = readJsxStaticAttribute(node.openingElement, 'context')\n if (message) {\n usedHashes.add(hashFn(message, context))\n }\n return\n }\n\n if (componentName === 'Plural') {\n const messageId = buildPluralMessageId(node.openingElement, hashFn)\n if (messageId) {\n usedHashes.add(messageId)\n }\n return\n }\n\n if (componentName === 'Select') {\n const messageId = buildSelectMessageId(node.openingElement, hashFn)\n if (messageId) {\n usedHashes.add(messageId)\n }\n }\n}\n\nfunction buildPluralMessageId(openingElement: JSXOpeningElementNode, hashFn: HashFunction): string | undefined {\n const id = readJsxStaticAttribute(openingElement, 'id')\n if (id) return id\n\n const context = readJsxStaticAttribute(openingElement, 'context')\n const offsetRaw = readJsxStaticNumber(openingElement, 'offset')\n const forms = [\n readJsxStaticAttribute(openingElement, 'zero') === undefined ? undefined : `=0 {${readJsxStaticAttribute(openingElement, 'zero')}}`,\n readJsxStaticAttribute(openingElement, 'one') === undefined ? undefined : `one {${readJsxStaticAttribute(openingElement, 'one')}}`,\n readJsxStaticAttribute(openingElement, 'two') === undefined ? undefined : `two {${readJsxStaticAttribute(openingElement, 'two')}}`,\n readJsxStaticAttribute(openingElement, 'few') === undefined ? undefined : `few {${readJsxStaticAttribute(openingElement, 'few')}}`,\n readJsxStaticAttribute(openingElement, 'many') === undefined ? undefined : `many {${readJsxStaticAttribute(openingElement, 'many')}}`,\n readJsxStaticAttribute(openingElement, 'other') === undefined ? undefined : `other {${readJsxStaticAttribute(openingElement, 'other')}}`,\n ].filter(Boolean)\n\n if (forms.length === 0) return undefined\n\n const offsetPart = typeof offsetRaw === 'number' ? ` offset:${offsetRaw}` : ''\n const icuMessage = `{count, plural,${offsetPart} ${forms.join(' ')}}`\n return hashFn(icuMessage, context)\n}\n\nfunction buildSelectMessageId(openingElement: JSXOpeningElementNode, hashFn: HashFunction): string | undefined {\n const id = readJsxStaticAttribute(openingElement, 'id')\n if (id) return id\n\n const context = readJsxStaticAttribute(openingElement, 'context')\n const forms = readStaticSelectForms(openingElement)\n if (!forms || forms['other'] === undefined) return undefined\n\n const orderedKeys = [...Object.keys(forms).filter((key) => key !== 'other').sort(), 'other']\n const icuMessage = `{value, select, ${orderedKeys.map((key) => `${key} {${forms[key]!}}`).join(' ')}}`\n return hashFn(icuMessage, context)\n}\n\nfunction readStaticSelectForms(openingElement: JSXOpeningElementNode): Record<string, string> | undefined {\n const optionForms = readJsxStaticObject(openingElement, 'options')\n if (optionForms) {\n const other = readJsxStaticAttribute(openingElement, 'other')\n return {\n ...optionForms,\n ...(other !== undefined ? { other } : {}),\n }\n }\n\n const forms: Record<string, string> = {}\n for (const attribute of openingElement.attributes) {\n if (!isJsxAttribute(attribute)) continue\n const name = attribute.name.name\n if (['value', 'id', 'context', 'comment', 'options'].includes(name)) continue\n const value = readJsxAttributeValue(attribute)\n if (value !== undefined) {\n forms[name] = value\n }\n }\n\n return Object.keys(forms).length > 0 ? forms : undefined\n}\n\nfunction readStaticSelectObjectValue(node: SourceNode): Record<string, string> | undefined {\n if (!isObjectExpression(node)) return undefined\n const values: Record<string, string> = {}\n\n for (const property of node.properties) {\n if (!isObjectProperty(property) || property.computed) return undefined\n const key = readPropertyKey(property.key)\n const value = readStaticString(property.value)\n if (!key || value === undefined) return undefined\n values[key] = value\n }\n\n return values\n}\n\nfunction readJsxStaticObject(openingElement: JSXOpeningElementNode, name: string): Record<string, string> | undefined {\n const attribute = findJsxAttribute(openingElement, name)\n if (!attribute?.value) return undefined\n if (attribute.value.type !== 'JSXExpressionContainer') return undefined\n return readStaticSelectObjectValue((attribute.value as JSXExpressionContainerNode).expression)\n}\n\nfunction readJsxStaticAttribute(openingElement: JSXOpeningElementNode, name: string): string | undefined {\n return readJsxAttributeValue(findJsxAttribute(openingElement, name))\n}\n\nfunction readJsxStaticNumber(openingElement: JSXOpeningElementNode, name: string): number | undefined {\n const attribute = findJsxAttribute(openingElement, name)\n if (!attribute?.value || attribute.value.type !== 'JSXExpressionContainer') return undefined\n const expression = (attribute.value as JSXExpressionContainerNode).expression\n return expression.type === 'NumericLiteral' ? (expression as NumericLiteralNode).value : undefined\n}\n\nfunction findJsxAttribute(openingElement: JSXOpeningElementNode, name: string): JSXAttributeNode | undefined {\n return openingElement.attributes.find((attribute) => {\n return isJsxAttribute(attribute) && attribute.name.name === name\n }) as JSXAttributeNode | undefined\n}\n\nfunction readJsxAttributeValue(attribute: JSXAttributeNode | undefined): string | undefined {\n if (!attribute?.value) return undefined\n\n if (attribute.value.type === 'StringLiteral') {\n return (attribute.value as StringLiteralNode).value\n }\n\n if (attribute.value.type === 'JSXExpressionContainer') {\n return readStaticString((attribute.value as JSXExpressionContainerNode).expression)\n }\n\n return undefined\n}\n\nfunction readJsxName(node: SourceNode): string | undefined {\n return node.type === 'JSXIdentifier' ? (node as JSXIdentifierNode).name : undefined\n}\n\nfunction readStaticString(node: SourceNode): string | undefined {\n if (node.type === 'StringLiteral') {\n return (node as StringLiteralNode).value\n }\n\n if (node.type === 'TemplateLiteral') {\n const template = node as TemplateLiteralNode\n if (template.expressions.length === 0 && template.quasis.length === 1) {\n return template.quasis[0]!.value.cooked ?? template.quasis[0]!.value.raw\n }\n }\n\n return undefined\n}\n\nfunction readPropertyKey(node: SourceNode): string | undefined {\n if (isIdentifier(node)) return node.name\n if (node.type === 'StringLiteral') return (node as StringLiteralNode).value\n return undefined\n}\n\nfunction isImportDeclaration(node: SourceNode): node is ImportDeclarationNode {\n return node.type === 'ImportDeclaration'\n}\n\nfunction isImportSpecifier(node: SourceNode): node is ImportSpecifierNode {\n return node.type === 'ImportSpecifier'\n}\n\nfunction isVariableDeclarator(node: SourceNode): node is VariableDeclaratorNode {\n return node.type === 'VariableDeclarator'\n}\n\nfunction isObjectPattern(node: SourceNode): node is ObjectPatternNode {\n return node.type === 'ObjectPattern'\n}\n\nfunction isObjectExpression(node: SourceNode): node is ObjectExpressionNode {\n return node.type === 'ObjectExpression'\n}\n\nfunction isObjectProperty(node: SourceNode): node is ObjectPropertyNode {\n return node.type === 'ObjectProperty'\n}\n\nfunction isCallExpression(node: SourceNode): node is CallExpressionNode {\n return node.type === 'CallExpression'\n}\n\nfunction isMemberExpression(node: SourceNode): node is MemberExpressionNode {\n return node.type === 'MemberExpression'\n}\n\nfunction isIdentifier(node: SourceNode | undefined | null): node is IdentifierNode {\n return node?.type === 'Identifier'\n}\n\nfunction isJsxElement(node: SourceNode): node is JSXElementNode {\n return node.type === 'JSXElement'\n}\n\nfunction isJsxAttribute(node: SourceNode): node is JSXAttributeNode {\n return node.type === 'JSXAttribute'\n}\n\nfunction readImportedName(specifier: ImportSpecifierNode): string | undefined {\n const imported = specifier.imported\n if (imported.type === 'Identifier') return imported.name\n if (imported.type === 'StringLiteral') return imported.value\n return undefined\n}\n\n/**\n * Inject the catalog import statement at the top of the module.\n */\nexport function injectCatalogImport(code: string, strategy: 'dynamic' | 'static' | 'per-route', hashes: Set<string>, hashFn?: HashFunction): string {\n if (strategy === 'dynamic') {\n return `import { __catalog } from 'virtual:fluenti/runtime';\\n${code}`\n }\n\n if (strategy === 'per-route') {\n return `import { __catalog } from 'virtual:fluenti/route-runtime';\\n${code}`\n }\n\n // Static: import named exports directly\n const hash = hashFn ?? defaultHashMessage\n const imports = [...hashes].map((id) => `_${hash(id)}`).join(', ')\n return `import { ${imports} } from 'virtual:fluenti/messages';\\n${code}`\n}\n","/**\n * Virtual module resolution for code-splitting mode.\n *\n * Provides:\n * - virtual:fluenti/runtime → reactive catalog + switchLocale + preloadLocale\n * - virtual:fluenti/messages → re-export from static locale (for static strategy)\n * - virtual:fluenti/route-runtime → per-route splitting runtime\n */\n\nimport { resolve } from 'node:path'\nimport { validateLocale } from '@fluenti/core'\nimport type { RuntimeGenerator, RuntimeGeneratorOptions } from './types'\n\n/**\n * Escapes a string value for safe embedding in generated JavaScript code.\n * Returns a JSON-encoded string (with double quotes), preventing injection\n * of quotes, backticks, template interpolation, and other special characters.\n */\nfunction safeStringLiteral(value: string): string {\n return JSON.stringify(value)\n}\n\n/**\n * Validates that a catalog directory path does not contain characters\n * that could enable code injection in generated template literals.\n */\nfunction validateCatalogDir(catalogDir: string): void {\n if (catalogDir.includes('`') || catalogDir.includes('$')) {\n throw new Error(\n `[fluenti] vite-plugin: catalogDir must not contain backticks or $ characters, got ${JSON.stringify(catalogDir)}`,\n )\n }\n}\n\nconst VIRTUAL_RUNTIME = 'virtual:fluenti/runtime'\nconst VIRTUAL_MESSAGES = 'virtual:fluenti/messages'\nconst VIRTUAL_ROUTE_RUNTIME = 'virtual:fluenti/route-runtime'\nconst RESOLVED_RUNTIME = '\\0virtual:fluenti/runtime'\nconst RESOLVED_MESSAGES = '\\0virtual:fluenti/messages'\nconst RESOLVED_ROUTE_RUNTIME = '\\0virtual:fluenti/route-runtime'\n\nexport interface VirtualModuleOptions {\n rootDir: string\n catalogDir: string\n catalogExtension: string\n locales: string[]\n sourceLocale: string\n defaultBuildLocale: string\n framework: string\n runtimeGenerator?: RuntimeGenerator | undefined\n}\n\nexport function resolveVirtualSplitId(id: string): string | undefined {\n if (id === VIRTUAL_RUNTIME) return RESOLVED_RUNTIME\n if (id === VIRTUAL_MESSAGES) return RESOLVED_MESSAGES\n if (id === VIRTUAL_ROUTE_RUNTIME) return RESOLVED_ROUTE_RUNTIME\n return undefined\n}\n\nexport function loadVirtualSplitModule(\n id: string,\n options: VirtualModuleOptions,\n): string | undefined {\n if (id === RESOLVED_RUNTIME) {\n return generateRuntimeModule(options)\n }\n if (id === RESOLVED_MESSAGES) {\n return generateStaticMessagesModule(options)\n }\n if (id === RESOLVED_ROUTE_RUNTIME) {\n return generateRouteRuntimeModule(options)\n }\n return undefined\n}\n\nfunction generateRuntimeModule(options: VirtualModuleOptions): string {\n const { locales, runtimeGenerator, catalogDir } = options\n validateCatalogDir(catalogDir)\n for (const locale of locales) {\n validateLocale(locale, 'vite-plugin')\n }\n\n if (!runtimeGenerator) {\n throw new Error('[fluenti] vite-plugin: runtimeGenerator is required. Use a framework-specific plugin (e.g. @fluenti/vue/vite-plugin).')\n }\n\n return runtimeGenerator.generateRuntime(toRuntimeGeneratorOptions(options))\n}\n\nfunction generateStaticMessagesModule(options: VirtualModuleOptions): string {\n const { rootDir, catalogDir, catalogExtension, defaultBuildLocale, sourceLocale } = options\n const defaultLocale = defaultBuildLocale || sourceLocale\n validateLocale(defaultLocale, 'vite-plugin')\n validateCatalogDir(catalogDir)\n const absoluteCatalogDir = resolve(rootDir, catalogDir)\n\n return `export * from ${safeStringLiteral(absoluteCatalogDir + '/' + defaultLocale + catalogExtension)}\\n`\n}\n\n/**\n * Generate the route runtime module for per-route splitting.\n */\nexport function generateRouteRuntimeModule(options: VirtualModuleOptions): string {\n const { locales, runtimeGenerator, catalogDir } = options\n validateCatalogDir(catalogDir)\n for (const locale of locales) {\n validateLocale(locale, 'vite-plugin')\n }\n\n if (!runtimeGenerator) {\n throw new Error('[fluenti] vite-plugin: runtimeGenerator is required. Use a framework-specific plugin (e.g. @fluenti/vue/vite-plugin).')\n }\n\n return runtimeGenerator.generateRouteRuntime(toRuntimeGeneratorOptions(options))\n}\n\nfunction toRuntimeGeneratorOptions(options: VirtualModuleOptions): RuntimeGeneratorOptions {\n const { rootDir, catalogDir, catalogExtension, locales, sourceLocale, defaultBuildLocale } = options\n return { rootDir, catalogDir, catalogExtension, locales, sourceLocale, defaultBuildLocale }\n}\n\n","/**\n * Utilities for per-route message splitting.\n *\n * - deriveRouteName: strips hash/dir/ext from chunk filenames to produce stable route IDs\n * - parseCompiledCatalog: extracts Map<hash, exportLine> from compiled catalog source\n * - readCatalogSource: reads compiled catalog file from disk\n */\n\nimport { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { hashMessage } from '@fluenti/core/internal'\n\n/**\n * Derive a stable route name from a Rollup chunk filename.\n *\n * Examples:\n * 'assets/index-abc123.js' → 'index'\n * 'assets/about-def456.js' → 'about'\n * 'pages/settings-g7h8.js' → 'settings'\n * 'index.js' → 'index'\n */\nexport function deriveRouteName(chunkFileName: string): string {\n // Strip directory prefix\n const base = chunkFileName.includes('/')\n ? chunkFileName.slice(chunkFileName.lastIndexOf('/') + 1)\n : chunkFileName\n\n // Strip extension\n const withoutExt = base.replace(/\\.[^.]+$/, '')\n\n // Strip trailing hash (e.g., 'index-abc123' → 'index')\n // Hash pattern: dash followed by alphanumeric chars at end\n const withoutHash = withoutExt.replace(/-[a-zA-Z0-9]{4,}$/, '')\n\n return withoutHash || withoutExt\n}\n\n/**\n * Parse a compiled catalog source and extract named exports by hash.\n *\n * The CLI outputs lines like:\n * export const _abc123 = \"Hello\"\n * export const _def456 = (v) => `Hello ${v.name}`\n *\n * Returns a Map from hash (without underscore prefix) to the full export line.\n */\nexport function parseCompiledCatalog(source: string): Map<string, string> {\n const exports = new Map<string, string>()\n\n // Match lines: export const _<hash> = <anything until end of statement>\n // Handles multi-line arrow functions by tracking balanced braces\n const lines = source.split('\\n')\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!\n const match = line.match(/^(?:\\/\\*.*?\\*\\/\\s*)?export\\s+const\\s+_([a-z0-9]+)\\s*=\\s*/)\n if (!match) continue\n\n const hash = match[1]!\n\n // Collect the full statement — may span multiple lines if it contains template literals or functions\n let statement = line\n let braceDepth = 0\n let parenDepth = 0\n let templateDepth = 0\n\n for (const ch of line.slice(match[0].length)) {\n if (ch === '{') braceDepth++\n if (ch === '}') braceDepth--\n if (ch === '(') parenDepth++\n if (ch === ')') parenDepth--\n if (ch === '`') templateDepth = templateDepth === 0 ? 1 : 0\n }\n\n while ((braceDepth > 0 || parenDepth > 0 || templateDepth > 0) && i + 1 < lines.length) {\n i++\n const nextLine = lines[i]!\n statement += '\\n' + nextLine\n for (const ch of nextLine) {\n if (ch === '{') braceDepth++\n if (ch === '}') braceDepth--\n if (ch === '(') parenDepth++\n if (ch === ')') parenDepth--\n if (ch === '`') templateDepth = templateDepth === 0 ? 1 : 0\n }\n }\n\n exports.set(hash, statement)\n }\n\n return exports\n}\n\n/**\n * Build a JS module that re-exports only the specified hashes from a catalog.\n *\n * Given hashes ['abc', 'def'] and catalog exports, produces:\n * export const _abc = \"Hello\"\n * export const _def = (v) => `Hi ${v.name}`\n */\nexport function buildChunkModule(\n catalogIds: ReadonlySet<string>,\n catalogExports: Map<string, string>,\n): string {\n const lines: string[] = []\n const defaultEntries: string[] = []\n\n for (const catalogId of catalogIds) {\n const exportHash = hashMessage(catalogId)\n const exportLine = catalogExports.get(exportHash)\n if (exportLine) {\n lines.push(exportLine)\n defaultEntries.push(` '${escapeStringLiteral(catalogId)}': _${exportHash},`)\n }\n }\n\n if (defaultEntries.length > 0) {\n lines.push('', 'export default {', ...defaultEntries, '}')\n }\n\n return lines.join('\\n') + '\\n'\n}\n\n/**\n * Read a compiled catalog file from disk.\n * Returns the source string, or undefined if the file doesn't exist.\n */\nexport function readCatalogSource(catalogDir: string, locale: string): string | undefined {\n try {\n return readFileSync(resolve(catalogDir, `${locale}.js`), 'utf-8')\n } catch {\n return undefined\n }\n}\n\nfunction escapeStringLiteral(value: string): string {\n return value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\r/g, '\\\\r')\n .replace(/\\n/g, '\\\\n')\n}\n","import type { Plugin } from 'vite'\nimport { createFilter } from 'vite'\nimport type { FluentiCoreOptions, RuntimeGenerator } from './types'\nimport type { FluentiBuildConfig } from '@fluenti/core/internal'\nimport { resolveLocaleCodes } from '@fluenti/core/internal'\nimport { setResolvedMode, isBuildMode, getPluginEnvironment } from './mode-detect'\nimport { resolve } from 'node:path'\nimport { createRequire } from 'node:module'\n\nconst _require = createRequire(import.meta.url)\nimport { createDebouncedRunner, runExtractCompile } from './dev-runner'\nimport { transformForDynamicSplit, transformForStaticSplit, injectCatalogImport } from './build-transform'\nimport { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules'\nimport { deriveRouteName, parseCompiledCatalog, buildChunkModule, readCatalogSource } from './route-resolve'\nimport { createTransformPipeline, hasScopeTransformCandidate } from '@fluenti/core/transform'\nexport type { FluentiPluginOptions, FluentiCoreOptions, RuntimeGenerator, RuntimeGeneratorOptions, IdGenerator } from './types'\nexport { createRuntimeGenerator } from './runtime-template'\nexport type { RuntimePrimitives } from './runtime-template'\nexport { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules'\nexport { setResolvedMode, isBuildMode, getPluginEnvironment } from './mode-detect'\n\nconst VIRTUAL_PREFIX = 'virtual:fluenti/messages/'\nconst RESOLVED_PREFIX = '\\0virtual:fluenti/messages/'\n\n/**\n * Resolve a config option (string path, inline object, or undefined) into a full FluentiBuildConfig.\n */\nfunction resolvePluginConfig(configOption?: string | FluentiBuildConfig, cwd?: string): FluentiBuildConfig {\n if (typeof configOption === 'object') {\n // Inline config — merge with defaults\n const { DEFAULT_FLUENTI_CONFIG } = _require('@fluenti/core/config') as {\n DEFAULT_FLUENTI_CONFIG: FluentiBuildConfig\n }\n return { ...DEFAULT_FLUENTI_CONFIG, ...configOption }\n }\n // string → specified path; undefined → auto-discover\n const { loadConfigSync: loadSync } = _require('@fluenti/core/config') as {\n loadConfigSync: (configPath?: string, cwd?: string) => FluentiBuildConfig\n }\n return loadSync(\n typeof configOption === 'string' ? configOption : undefined,\n cwd,\n )\n}\n\n// ─── Public factory for framework packages ─────────────────────────────────\n\n/**\n * Create the Fluenti plugin pipeline.\n * Framework packages call this with their framework-specific plugins and runtime generator.\n */\nexport function createFluentiPlugins(\n options: FluentiCoreOptions,\n frameworkPlugins: Plugin[],\n runtimeGenerator?: RuntimeGenerator,\n): Plugin[] {\n // Resolve the full FluentiBuildConfig from the config option\n let fluentiConfig: FluentiBuildConfig | undefined\n\n function getConfig(cwd?: string): FluentiBuildConfig {\n if (!fluentiConfig) {\n fluentiConfig = resolvePluginConfig(options.config, cwd)\n }\n return fluentiConfig\n }\n\n // Eagerly resolve config for values needed at plugin construction time\n // (we can't defer these since they're used in resolveId/load which have no cwd context)\n const earlyConfig = resolvePluginConfig(options.config)\n\n const catalogDir = earlyConfig.compileOutDir.replace(/^\\.\\//, '')\n const catalogExtension = earlyConfig.catalogExtension ?? '.js'\n const framework = options.framework\n const splitting = earlyConfig.splitting ?? false\n const sourceLocale = earlyConfig.sourceLocale\n const localeCodes = resolveLocaleCodes(earlyConfig.locales)\n const defaultBuildLocale = earlyConfig.defaultBuildLocale ?? sourceLocale\n const idGenerator = earlyConfig.idGenerator\n const onBeforeCompile = earlyConfig.onBeforeCompile\n const onAfterCompile = earlyConfig.onAfterCompile\n\n let rootDir = process.cwd()\n\n const virtualPlugin: Plugin = {\n name: 'fluenti:virtual',\n configResolved(config) {\n rootDir = config.root\n setResolvedMode(config.command)\n },\n resolveId(id) {\n if (id.startsWith(VIRTUAL_PREFIX)) {\n return '\\0' + id\n }\n if (splitting) {\n const resolved = resolveVirtualSplitId(id)\n if (resolved) return resolved\n }\n return undefined\n },\n load(id) {\n if (id.startsWith(RESOLVED_PREFIX)) {\n const locale = id.slice(RESOLVED_PREFIX.length)\n const catalogPath = `${catalogDir}/${locale}${catalogExtension}`\n return `export { default } from '${catalogPath}'`\n }\n if (splitting) {\n const result = loadVirtualSplitModule(id, {\n rootDir,\n catalogDir,\n catalogExtension,\n locales: localeCodes,\n sourceLocale,\n defaultBuildLocale,\n framework,\n runtimeGenerator,\n })\n if (result) return result\n }\n return undefined\n },\n }\n\n const pipeline = createTransformPipeline({ framework })\n\n const scriptTransformPlugin: Plugin = {\n name: 'fluenti:script-transform',\n enforce: 'pre',\n transform(code, id) {\n if (id.includes('node_modules')) return undefined\n if (!id.match(/\\.(vue|tsx|jsx|ts|js)(\\?|$)/)) return undefined\n if (id.includes('.vue') && !id.includes('type=script')) return undefined\n\n // Vue .vue files need allowTopLevelImportedT for top-level `import { t }`\n const isVueSfc = framework === 'vue' && id.includes('.vue')\n\n let result = code\n let changed = false\n\n // ── <Trans> compile-time optimization (JSX/TSX only) ──────────────\n if (id.match(/\\.[jt]sx(\\?|$)/) && /<Trans[\\s>]/.test(result)) {\n const transResult = pipeline.transformTrans(result)\n if (transResult.transformed) {\n result = transResult.code\n changed = true\n }\n }\n\n // ── t`` / t() scope-aware transform ────────────────────────────────\n if (hasScopeTransformCandidate(result)) {\n const scoped = pipeline.transformScope(result,\n isVueSfc ? { allowTopLevelImportedT: true } : undefined,\n )\n if (scoped.transformed) {\n return { code: scoped.code, map: null }\n }\n }\n\n return changed ? { code: result, map: null } : undefined\n },\n }\n\n // Track module → used hashes for per-route splitting\n const moduleMessages = new Map<string, Set<string>>()\n\n const buildSplitPlugin: Plugin = {\n name: 'fluenti:build-split',\n transform(code, id) {\n if (!splitting) return undefined\n if (!isBuildMode(getPluginEnvironment(this))) return undefined\n if (id.includes('node_modules')) return undefined\n if (!id.match(/\\.(vue|tsx|jsx|ts|js)(\\?|$)/)) return undefined\n\n const strategy = splitting === 'static' ? 'static' : 'dynamic'\n const transformOptions = idGenerator ? { hashFn: idGenerator } : undefined\n const transformed = strategy === 'static'\n ? transformForStaticSplit(code, transformOptions)\n : transformForDynamicSplit(code, transformOptions)\n\n if (splitting === 'per-route' && transformed.usedHashes.size > 0) {\n moduleMessages.set(id, transformed.usedHashes)\n }\n\n if (!transformed.needsCatalogImport) return undefined\n\n const importStrategy = splitting === 'per-route' ? 'per-route' : strategy\n const finalCode = injectCatalogImport(transformed.code, importStrategy, transformed.usedHashes, idGenerator)\n return { code: finalCode, map: null }\n },\n\n generateBundle(_outputOptions, bundle) {\n if (splitting !== 'per-route') return\n if (moduleMessages.size === 0) return\n\n const chunkHashes = new Map<string, Set<string>>()\n for (const [fileName, chunk] of Object.entries(bundle)) {\n if (chunk.type !== 'chunk') continue\n const hashes = new Set<string>()\n for (const moduleId of Object.keys(chunk.modules)) {\n const modHashes = moduleMessages.get(moduleId)\n if (modHashes) {\n for (const h of modHashes) hashes.add(h)\n }\n }\n if (hashes.size > 0) {\n chunkHashes.set(fileName, hashes)\n }\n }\n\n if (chunkHashes.size === 0) return\n\n const hashToChunks = new Map<string, string[]>()\n for (const [chunkName, hashes] of chunkHashes) {\n for (const h of hashes) {\n const chunks = hashToChunks.get(h) ?? []\n chunks.push(chunkName)\n hashToChunks.set(h, chunks)\n }\n }\n\n const sharedHashes = new Set<string>()\n const routeHashes = new Map<string, Set<string>>()\n\n for (const [hash, chunks] of hashToChunks) {\n if (chunks.length > 1) {\n sharedHashes.add(hash)\n } else {\n const routeName = deriveRouteName(chunks[0]!)\n const existing = routeHashes.get(routeName) ?? new Set()\n existing.add(hash)\n routeHashes.set(routeName, existing)\n }\n }\n\n const absoluteCatalogDir = resolve(rootDir, catalogDir)\n for (const locale of localeCodes) {\n const catalogSource = readCatalogSource(absoluteCatalogDir, locale)\n if (!catalogSource) continue\n const catalogExports = parseCompiledCatalog(catalogSource)\n\n if (sharedHashes.size > 0) {\n const sharedCode = buildChunkModule(sharedHashes, catalogExports)\n this.emitFile({\n type: 'asset',\n fileName: `_fluenti/shared-${locale}.js`,\n source: sharedCode,\n })\n }\n\n for (const [routeName, hashes] of routeHashes) {\n const routeCode = buildChunkModule(hashes, catalogExports)\n this.emitFile({\n type: 'asset',\n fileName: `_fluenti/${routeName}-${locale}.js`,\n source: routeCode,\n })\n }\n }\n },\n }\n\n const buildAutoCompile = earlyConfig.buildAutoCompile ?? true\n\n const buildCompilePlugin: Plugin = {\n name: 'fluenti:build-compile',\n async buildStart() {\n if (!isBuildMode(getPluginEnvironment(this)) || !buildAutoCompile) return\n if (onBeforeCompile) {\n const result = await onBeforeCompile()\n if (result === false) return\n }\n await runExtractCompile({ cwd: rootDir, throwOnError: true, compileOnly: true })\n if (onAfterCompile) {\n await onAfterCompile()\n }\n },\n }\n\n const devAutoCompile = earlyConfig.devAutoCompile ?? true\n\n const devPlugin: Plugin = {\n name: 'fluenti:dev',\n configureServer(server) {\n if (!devAutoCompile) return\n\n // Use include/exclude from resolved config\n const cfg = getConfig(server.config.root)\n const includePatterns = cfg.include ?? ['src/**/*.{vue,tsx,jsx,ts,js}']\n const excludePatterns = cfg.exclude ?? []\n\n const filter = createFilter(includePatterns, [\n ...excludePatterns,\n '**/node_modules/**',\n `**/${catalogDir}/**`,\n ])\n\n const runnerOptions: Parameters<typeof createDebouncedRunner>[0] = {\n cwd: server.config.root,\n onSuccess: () => {\n // Existing hotUpdate will pick up catalog changes\n },\n }\n if (earlyConfig.parallelCompile) runnerOptions.parallelCompile = true\n if (onBeforeCompile) runnerOptions.onBeforeCompile = onBeforeCompile\n if (onAfterCompile) runnerOptions.onAfterCompile = onAfterCompile\n const debouncedRun = createDebouncedRunner(runnerOptions, earlyConfig.devAutoCompileDelay ?? 500)\n\n debouncedRun()\n\n server.watcher.on('change', (file) => {\n if (filter(file)) {\n debouncedRun()\n }\n })\n },\n hotUpdate({ file }) {\n if (file.includes(catalogDir)) {\n const modules = [...this.environment.moduleGraph.urlToModuleMap.entries()]\n .filter(([url]) => url.includes('virtual:fluenti'))\n .map(([, mod]) => mod)\n\n if (modules.length > 0) {\n return modules\n }\n }\n return undefined\n },\n }\n\n // Plugin order matters:\n // 1. virtualPlugin — resolves virtual:fluenti/* module IDs (must be first)\n // 2. frameworkPlugins — framework-specific template transforms (e.g., Vue v-t directive)\n // must run after virtual resolution but before script transforms\n // 3. scriptTransformPlugin — t()/t`` scope transforms + <Trans> optimization (enforce: 'pre')\n // 4. buildCompilePlugin — triggers extract+compile before the build starts\n // 5. buildSplitPlugin — rewrites t() calls to catalog refs + emits per-route chunks\n // 6. devPlugin — file watcher + HMR for dev mode (must be last)\n return [virtualPlugin, ...frameworkPlugins, scriptTransformPlugin, buildCompilePlugin, buildSplitP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GAAG,KAAK,YAAY,YAAY,eAAe,SAAS,CAAC,CACvE,QAAQ,CAAC,KAAS,EAAI,SAAS,kBAAkB,CAAC,CAClD,KAAK,EAAG,KAAS,EAAI,CAExB,GAAI,EAAQ,OAAS,EACnB,OAAO,IAKd,CAUD,MAAO,CAAC,EAAe,GAAG,EAAkB,EAAuB,EAAoB,EAAkB,EAAU"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { Plugin } from 'vite';
2
2
  import { FluentiCoreOptions, RuntimeGenerator } from './types';
3
- export type { FluentiPluginOptions, FluentiCoreOptions, RuntimeGenerator, RuntimeGeneratorOptions } from './types';
3
+ export type { FluentiPluginOptions, FluentiCoreOptions, RuntimeGenerator, RuntimeGeneratorOptions, IdGenerator } from './types';
4
+ export { createRuntimeGenerator } from './runtime-template';
5
+ export type { RuntimePrimitives } from './runtime-template';
4
6
  export { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules';
5
- export { setResolvedMode, isBuildMode } from './mode-detect';
7
+ export { setResolvedMode, isBuildMode, getPluginEnvironment } from './mode-detect';
6
8
  /**
7
9
  * Create the Fluenti plugin pipeline.
8
10
  * Framework packages call this with their framework-specific plugins and runtime generator.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AASnE,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAClH,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAQ5D;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAA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