@fluenti/vite-plugin 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +176 -173
- package/dist/index.js.map +1 -1
- package/dist/sfc-transform.cjs +1 -1
- package/dist/sfc-transform.cjs.map +1 -1
- package/dist/sfc-transform.js +1 -1
- package/dist/sfc-transform.js.map +1 -1
- package/dist/vite-plugin/src/build-transform.d.ts.map +1 -0
- package/dist/vite-plugin/src/dev-runner.d.ts.map +1 -0
- package/dist/vite-plugin/src/index.d.ts.map +1 -0
- package/dist/vite-plugin/src/mode-detect.d.ts.map +1 -0
- package/dist/vite-plugin/src/runtime-template.d.ts.map +1 -0
- package/dist/vite-plugin/src/sfc-transform.d.ts.map +1 -0
- package/dist/{types.d.ts → vite-plugin/src/types.d.ts} +1 -1
- package/dist/vite-plugin/src/types.d.ts.map +1 -0
- package/dist/vite-plugin/src/virtual-modules.d.ts.map +1 -0
- package/dist/vite-plugin/src/vt-transform.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/build-transform.d.ts.map +0 -1
- package/dist/dev-runner.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mode-detect.d.ts.map +0 -1
- package/dist/runtime-template.d.ts.map +0 -1
- package/dist/sfc-transform.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/virtual-modules.d.ts.map +0 -1
- package/dist/vt-transform.d.ts.map +0 -1
- /package/dist/{build-transform.d.ts → vite-plugin/src/build-transform.d.ts} +0 -0
- /package/dist/{dev-runner.d.ts → vite-plugin/src/dev-runner.d.ts} +0 -0
- /package/dist/{index.d.ts → vite-plugin/src/index.d.ts} +0 -0
- /package/dist/{mode-detect.d.ts → vite-plugin/src/mode-detect.d.ts} +0 -0
- /package/dist/{runtime-template.d.ts → vite-plugin/src/runtime-template.d.ts} +0 -0
- /package/dist/{sfc-transform.d.ts → vite-plugin/src/sfc-transform.d.ts} +0 -0
- /package/dist/{virtual-modules.d.ts → vite-plugin/src/virtual-modules.d.ts} +0 -0
- /package/dist/{vt-transform.d.ts → vite-plugin/src/vt-transform.d.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`vite`),t=require(`@fluenti/core/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`vite`),t=require(`@fluenti/core/compiler`),n=require(`@fluenti/core/config`),r=require(`node:path`),i=require(`node:module`),a=require(`node:fs`),o=require(`@fluenti/core/transform`),s=require(`@fluenti/core`);var c=`dev`;function l(e){c=e===`build`?`build`:`dev`}function u(e){if(typeof e==`object`&&e&&`environment`in e){let t=e.environment;if(typeof t==`object`&&t)return t}}function d(e){return e?.mode===`build`||c===`build`||process.env.NODE_ENV===`production`}async function f(e){try{let{DEFAULT_FLUENTI_CONFIG:t,loadConfigSync:n}=(0,i.createRequire)((0,r.join)(e.cwd,`package.json`))(`@fluenti/core/config`),o;try{o=n(void 0,e.cwd)}catch{o=t}(0,a.mkdirSync)((0,r.resolve)(e.cwd,o.compileOutDir),{recursive:!0}),(0,a.mkdirSync)((0,r.resolve)(e.cwd,o.catalogDir),{recursive:!0})}catch{}if(!(e.onBeforeCompile&&await e.onBeforeCompile()===!1)){if(e.compileOnly)try{let{runCompile:t}=(0,i.createRequire)((0,r.join)(e.cwd,`package.json`))(`@fluenti/cli`);await t(e.cwd),console.log(`[fluenti] Compiling... done`),e.onAfterCompile&&await e.onAfterCompile(),e.onSuccess?.();return}catch(t){let n=t instanceof Error?t:Error(String(t));if(e.throwOnError)throw n;console.warn(`[fluenti] Compile failed:`,n.message),e.onError?.(n);return}try{let{runExtract:t,runCompile:n}=(0,i.createRequire)((0,r.join)(e.cwd,`package.json`))(`@fluenti/cli`);await t(e.cwd),await n(e.cwd,{parallel:e.parallelCompile}),console.log(`[fluenti] Extracting and compiling... done`),e.onAfterCompile&&await e.onAfterCompile(),e.onSuccess?.();return}catch(t){let n=t instanceof Error?t:Error(String(t));if(n.message.includes(`Cannot find module`)){let t=`[fluenti] @fluenti/cli is required for auto-compile.
|
|
2
2
|
Install it as a devDependency:
|
|
3
3
|
pnpm add -D @fluenti/cli
|
|
4
|
-
See: https://fluenti.dev/start/introduction/`;if(e.throwOnError)throw Error(t);console.warn(t),e.onError?.(Error(t));return}if(e.throwOnError)throw n;console.warn(`[fluenti] Extract/compile failed:`,n.message),e.onError?.(n)}}}function f(e,t=300){let n=null,r=!1,i=!1;async function a(){r=!0;try{await d(e)}finally{r=!1,i&&(i=!1,o())}}function o(){n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,r?i=!0:a()},t)}return o}function p(e,t){return h(e,`dynamic`,t)}function m(e,t){return h(e,`static`,t)}function h(e,n,r){let i=r?.hashFn??t.hashMessage,o=(0,a.parseSourceModule)(e);if(!o||o.type!==`Program`)return{code:e,needsCatalogImport:!1,usedHashes:new Set};let s=g(o),c=[],l=new Set;if((0,a.walkSourceAst)(o,t=>{let r=v(e,t,s,n,l,i);if(r){c.push(r);return}x(t,l,i)}),c.length===0)return{code:e,needsCatalogImport:!1,usedHashes:l};let u=e;for(let e=c.length-1;e>=0;e--){let{start:t,end:n,replacement:r}=c[e];u=u.slice(0,t)+r+u.slice(n)}return{code:u,needsCatalogImport:!0,usedHashes:l}}function g(e){let t=new Set,n=new Set,r=new Set,i=new Set;for(let t of e.body)if(N(t))for(let e of t.specifiers){if(!P(e))continue;let t=H(e);t&&(t===`useI18n`&&n.add(e.local.name),t===`getI18n`&&r.add(e.local.name),t===`unref`&&i.add(e.local.name))}return(0,a.walkSourceAst)(e,e=>{if(!te(e)||!e.init||!ne(e.id))return;if(L(e.init)&&z(e.init.callee)&&n.has(e.init.callee.name)){_(e.id,t);return}let i=e.init.type===`AwaitExpression`?e.init.argument:null;i&&L(i)&&z(i.callee)&&r.has(i.callee.name)&&_(e.id,t)}),{tracked:t,unref:i}}function _(e,t){for(let n of e.properties)!I(n)||n.computed||!z(n.key)||n.key.name!==`t`||z(n.value)&&t.add(n.value.name)}function v(e,t,n,r,i,a){if(!L(t)||t.start==null||t.end==null)return;let o=y(e,t,n,a);if(!o)return;let{catalogId:s}=o;i.add(s);let c=a(s),l=r===`dynamic`?`__catalog[${JSON.stringify(s)}]`:`_${c}`,u=o.valuesSource?`${l}(${o.valuesSource})`:l;return{start:t.start,end:t.end,replacement:u}}function y(e,t,n,r){if(t.arguments.length===0)return;let i=t.callee,a=z(i)&&(n.tracked.has(i.name)||i.name===`$t`),o=R(i)&&!i.computed&&z(i.property)&&(i.property.name===`$t`||i.property.name===`t`&&z(i.object)&&(i.object.name===`_ctx`||i.object.name===`$setup`)),s=L(i)&&z(i.callee)&&n.unref.has(i.callee.name)&&i.arguments.length===1&&z(i.arguments[0])&&n.tracked.has(i.arguments[0].name);if(!a&&!o&&!s)return;let c=b(t.arguments[0],r);if(!c)return;let l=t.arguments[1]&&t.arguments[1].start!=null&&t.arguments[1].end!=null?e.slice(t.arguments[1].start,t.arguments[1].end):void 0;return l===void 0?{catalogId:c}:{catalogId:c,valuesSource:l}}function b(e,t){let n=j(e);if(n!==void 0)return t(n);if(!F(e))return;let r,i,a;for(let t of e.properties){if(!I(t)||t.computed)continue;let e=M(t.key);if(!e)continue;let n=j(t.value);n!==void 0&&(e===`id`&&(r=n),e===`message`&&(i=n),e===`context`&&(a=n))}if(r)return r;if(i)return t(i,a)}function x(e,t,n){if(!B(e))return;let r=A(e.openingElement.name);if(r){if(r===`Trans`){let r=E(e.openingElement,`__id`)??E(e.openingElement,`id`);if(r){t.add(r);return}let i=E(e.openingElement,`__message`),a=E(e.openingElement,`context`);i&&t.add(n(i,a));return}if(r===`Plural`){let r=S(e.openingElement,n);r&&t.add(r);return}if(r===`Select`){let r=C(e.openingElement,n);r&&t.add(r)}}}function S(e,t){let n=E(e,`id`);if(n)return n;let r=E(e,`context`),i=D(e,`offset`),a=[E(e,`zero`)===void 0?void 0:`=0 {${E(e,`zero`)}}`,E(e,`one`)===void 0?void 0:`one {${E(e,`one`)}}`,E(e,`two`)===void 0?void 0:`two {${E(e,`two`)}}`,E(e,`few`)===void 0?void 0:`few {${E(e,`few`)}}`,E(e,`many`)===void 0?void 0:`many {${E(e,`many`)}}`,E(e,`other`)===void 0?void 0:`other {${E(e,`other`)}}`].filter(Boolean);if(a.length!==0)return t(`{count, plural,${typeof i==`number`?` offset:${i}`:``} ${a.join(` `)}}`,r)}function C(e,t){let n=E(e,`id`);if(n)return n;let r=E(e,`context`),i=w(e);if(!(!i||i.other===void 0))return t(`{value, select, ${[...Object.keys(i).filter(e=>e!==`other`).sort(),`other`].map(e=>`${e} {${i[e]}}`).join(` `)}}`,r)}function w(e){let t=ee(e,`options`);if(t){let n=E(e,`other`);return{...t,...n===void 0?{}:{other:n}}}let n={};for(let t of e.attributes){if(!V(t))continue;let e=t.name.name;if([`value`,`id`,`context`,`comment`,`options`].includes(e))continue;let r=k(t);r!==void 0&&(n[e]=r)}return Object.keys(n).length>0?n:void 0}function T(e){if(!F(e))return;let t={};for(let n of e.properties){if(!I(n)||n.computed)return;let e=M(n.key),r=j(n.value);if(!e||r===void 0)return;t[e]=r}return t}function ee(e,t){let n=O(e,t);if(n?.value&&n.value.type===`JSXExpressionContainer`)return T(n.value.expression)}function E(e,t){return k(O(e,t))}function D(e,t){let n=O(e,t);if(!n?.value||n.value.type!==`JSXExpressionContainer`)return;let r=n.value.expression;return r.type===`NumericLiteral`?r.value:void 0}function O(e,t){return e.attributes.find(e=>V(e)&&e.name.name===t)}function k(e){if(e?.value){if(e.value.type===`StringLiteral`)return e.value.value;if(e.value.type===`JSXExpressionContainer`)return j(e.value.expression)}}function A(e){return e.type===`JSXIdentifier`?e.name:void 0}function j(e){if(e.type===`StringLiteral`)return e.value;if(e.type===`TemplateLiteral`){let t=e;if(t.expressions.length===0&&t.quasis.length===1)return t.quasis[0].value.cooked??t.quasis[0].value.raw}}function M(e){if(z(e))return e.name;if(e.type===`StringLiteral`)return e.value}function N(e){return e.type===`ImportDeclaration`}function P(e){return e.type===`ImportSpecifier`}function te(e){return e.type===`VariableDeclarator`}function ne(e){return e.type===`ObjectPattern`}function F(e){return e.type===`ObjectExpression`}function I(e){return e.type===`ObjectProperty`}function L(e){return e.type===`CallExpression`}function R(e){return e.type===`MemberExpression`}function z(e){return e?.type===`Identifier`}function B(e){return e.type===`JSXElement`}function V(e){return e.type===`JSXAttribute`}function H(e){let t=e.imported;if(t.type===`Identifier`)return t.name;if(t.type===`StringLiteral`)return t.value}function U(e,n,r,i){if(n===`dynamic`)return`import { __catalog } from 'virtual:fluenti/runtime';\n${e}`;let a=i??t.hashMessage;return`import { ${[...r].map(e=>`_${a(e)}`).join(`, `)} } from 'virtual:fluenti/messages';\n${e}`}function W(e){return JSON.stringify(e)}function G(e){if(e.includes("`")||e.includes(`$`))throw Error(`[fluenti] vite-plugin: catalogDir must not contain backticks or $ characters, got ${JSON.stringify(e)}`)}var K=`virtual:fluenti/runtime`,q=`virtual:fluenti/messages`,J=`\0virtual:fluenti/runtime`,Y=`\0virtual:fluenti/messages`;function X(e){if(e===K)return J;if(e===q)return Y}function Z(e,t){if(e===J)return re(t);if(e===Y)return ie(t)}function re(e){let{locales:t,runtimeGenerator:n,catalogDir:r}=e;G(r);for(let e of t)(0,o.validateLocale)(e,`vite-plugin`);if(!n)throw Error(`[fluenti] vite-plugin: runtimeGenerator is required. Use a framework-specific plugin (e.g. @fluenti/vue/vite-plugin).`);return n.generateRuntime(ae(e))}function ie(e){let{rootDir:t,catalogDir:n,catalogExtension:a,defaultBuildLocale:s,sourceLocale:c}=e,l=s||c;(0,o.validateLocale)(l,`vite-plugin`),G(n);let u=(0,r.resolve)((0,r.resolve)(t,n),l+a);return(0,i.existsSync)(u)||console.warn(`[fluenti] Compiled catalog for locale "${l}" not found at ${u}. Run "fluenti compile" first.`),`export * from ${W(u)}\n`}function ae(e){let{rootDir:t,catalogDir:n,catalogExtension:r,locales:i,sourceLocale:a,defaultBuildLocale:o}=e;return{rootDir:t,catalogDir:n,catalogExtension:r,locales:i,sourceLocale:a,defaultBuildLocale:o}}var Q=(0,n.createRequire)(typeof __filename<`u`?__filename:{}.url),oe=`virtual:fluenti/messages/`,se=`\0virtual:fluenti/messages/`;function $(e,t){if(typeof e==`object`){let{DEFAULT_FLUENTI_CONFIG:t}=Q(`@fluenti/core/config`);return{...t,...e}}let{loadConfigSync:n}=Q(`@fluenti/core/config`);return n(typeof e==`string`?e:void 0,t)}function ce(n,r,i){let o,s=process.cwd();function h(e){let t=e??s;return o||=$(n.config,t),o}let g=n.framework;function _(e){let n=h(e),r=n.compileOutDir.replace(/^\.\//,``),i=n.catalogExtension??`.js`,a=n.splitting??!1;a&&a!==`dynamic`&&a!==`static`&&console.warn(`[fluenti] Invalid splitting value "${a}". Expected 'dynamic', 'static', or false. Falling back to 'dynamic'.`);let o=a===`static`?`static`:a?`dynamic`:!1,s=n.sourceLocale;return{config:n,catalogDir:r,catalogExtension:i,splitting:o,sourceLocale:s,localeCodes:(0,t.resolveLocaleCodes)(n.locales),defaultBuildLocale:n.defaultBuildLocale??s}}let v={name:`fluenti:virtual`,configResolved(e){s=e.root,o=$(n.config,s),c(e.command)},resolveId(e){if(e.startsWith(oe))return`\0`+e;let{splitting:t}=_();if(t){let t=X(e);if(t)return t}},load(e){let{catalogDir:t,catalogExtension:n,splitting:r,localeCodes:a,sourceLocale:o,defaultBuildLocale:c}=_();if(e.startsWith(se)){let r=e.slice(26);return a.includes(r)?`export { default } from '${`${t}/${r}${n}`}'`:void 0}if(r){let r=Z(e,{rootDir:s,catalogDir:t,catalogExtension:n,locales:a,sourceLocale:o,defaultBuildLocale:c,framework:g,runtimeGenerator:i});if(r)return r}}},y=(0,a.createTransformPipeline)({framework:g}),b={name:`fluenti:script-transform`,enforce:`pre`,transform(e,t){if(t.includes(`node_modules`)||!t.match(/\.(vue|tsx|jsx|ts|js)(\?|$)/)||t.includes(`.vue`)&&!t.includes(`type=script`))return;let n=g===`vue`&&t.includes(`.vue`),r=e,i=!1;if(t.match(/\.[jt]sx(\?|$)/)&&/<Trans[\s>]/.test(r)){let e=y.transformTrans(r);e.transformed&&(r=e.code,i=!0)}if((0,a.hasScopeTransformCandidate)(r)){let e=y.transformScope(r,n?{allowTopLevelImportedT:!0}:void 0);if(e.transformed)return{code:e.code,map:null}}return i?{code:r,map:null}:void 0}},x={name:`fluenti:build-split`,transform(e,t){let{splitting:n,config:r}=_();if(!n||!u(l(this))||t.includes(`node_modules`)||!t.match(/\.(vue|tsx|jsx|ts|js)(\?|$)/))return;let i=n===`static`?`static`:`dynamic`,a=r.idGenerator?{hashFn:r.idGenerator}:void 0,o=i===`static`?m(e,a):p(e,a);if(o.needsCatalogImport)return{code:U(o.code,i,o.usedHashes,r.idGenerator),map:null}}},S={name:`fluenti:build-compile`,async buildStart(){let{config:e}=_();u(l(this))&&(e.buildAutoCompile??!0)&&(e.onBeforeCompile&&await e.onBeforeCompile()===!1||(await d({cwd:s,throwOnError:!0,compileOnly:!0}),e.onAfterCompile&&await e.onAfterCompile()))}},C={name:`fluenti:dev`,configureServer(t){let{config:n,catalogDir:r}=_(t.config.root);if(!(n.devAutoCompile??!0))return;let i=(0,e.createFilter)(n.include??[`src/**/*.{vue,tsx,jsx,ts,js}`],[...n.exclude??[],`**/node_modules/**`,`**/${r}/**`]),a={cwd:t.config.root,onSuccess:()=>{}};n.parallelCompile&&(a.parallelCompile=!0),n.onBeforeCompile&&(a.onBeforeCompile=n.onBeforeCompile),n.onAfterCompile&&(a.onAfterCompile=n.onAfterCompile);let o=f(a,n.devAutoCompileDelay??500);o(),t.watcher.on(`change`,e=>{i(e)&&o()})},hotUpdate({file:e}){let{catalogDir:t}=_();if(e.includes(t)){let e=[...this.environment.moduleGraph.urlToModuleMap.entries()].filter(([e])=>e.includes(`virtual:fluenti`)).map(([,e])=>e);if(e.length>0)return e}}};return[v,...r,b,S,x,C]}exports.createFluentiPlugins=ce,Object.defineProperty(exports,`createRuntimeGenerator`,{enumerable:!0,get:function(){return a.createRuntimeGenerator}}),exports.getPluginEnvironment=l,exports.isBuildMode=u,exports.loadVirtualSplitModule=Z,exports.resolveVirtualSplitId=X,exports.setResolvedMode=c;
|
|
4
|
+
See: https://fluenti.dev/start/introduction/`;if(e.throwOnError)throw Error(t);console.warn(t),e.onError?.(Error(t));return}if(e.throwOnError)throw n;console.warn(`[fluenti] Extract/compile failed:`,n.message),e.onError?.(n)}}}function p(e,t=300){let n=null,r=!1,i=!1;async function a(){r=!0;try{await f(e)}finally{r=!1,i&&(i=!1,o())}}function o(){n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,r?i=!0:a()},t)}return o}function m(e,t){return g(e,`dynamic`,t)}function h(e,t){return g(e,`static`,t)}function g(e,n,r){let i=r?.hashFn??t.hashMessage,a=(0,o.parseSourceModule)(e);if(!a||a.type!==`Program`)return{code:e,needsCatalogImport:!1,usedHashes:new Set};let s=_(a),c=[],l=new Set;if((0,o.walkSourceAst)(a,t=>{let r=y(e,t,s,n,l,i);if(r){c.push(r);return}S(t,l,i)}),c.length===0)return{code:e,needsCatalogImport:!1,usedHashes:l};let u=e;for(let e=c.length-1;e>=0;e--){let{start:t,end:n,replacement:r}=c[e];u=u.slice(0,t)+r+u.slice(n)}return{code:u,needsCatalogImport:!0,usedHashes:l}}function _(e){let t=new Set,n=new Set,r=new Set,i=new Set;for(let t of e.body)if(ee(t))for(let e of t.specifiers){if(!te(e))continue;let t=U(e);t&&(t===`useI18n`&&n.add(e.local.name),t===`getI18n`&&r.add(e.local.name),t===`unref`&&i.add(e.local.name))}return(0,o.walkSourceAst)(e,e=>{if(!ne(e)||!e.init||!F(e.id))return;if(R(e.init)&&B(e.init.callee)&&n.has(e.init.callee.name)){v(e.id,t);return}let i=e.init.type===`AwaitExpression`?e.init.argument:null;i&&R(i)&&B(i.callee)&&r.has(i.callee.name)&&v(e.id,t)}),{tracked:t,unref:i}}function v(e,t){for(let n of e.properties)!L(n)||n.computed||!B(n.key)||n.key.name!==`t`||B(n.value)&&t.add(n.value.name)}function y(e,t,n,r,i,a){if(!R(t)||t.start==null||t.end==null)return;let o=b(e,t,n,a);if(!o)return;let{catalogId:s}=o;i.add(s);let c=a(s),l=r===`dynamic`?`__catalog[${JSON.stringify(s)}]`:`_${c}`,u=o.valuesSource?`${l}(${o.valuesSource})`:l;return{start:t.start,end:t.end,replacement:u}}function b(e,t,n,r){if(t.arguments.length===0)return;let i=t.callee,a=B(i)&&(n.tracked.has(i.name)||i.name===`$t`),o=z(i)&&!i.computed&&B(i.property)&&(i.property.name===`$t`||i.property.name===`t`&&B(i.object)&&(i.object.name===`_ctx`||i.object.name===`$setup`)),s=R(i)&&B(i.callee)&&n.unref.has(i.callee.name)&&i.arguments.length===1&&B(i.arguments[0])&&n.tracked.has(i.arguments[0].name);if(!a&&!o&&!s)return;let c=x(t.arguments[0],r);if(!c)return;let l=t.arguments[1]&&t.arguments[1].start!=null&&t.arguments[1].end!=null?e.slice(t.arguments[1].start,t.arguments[1].end):void 0;return l===void 0?{catalogId:c}:{catalogId:c,valuesSource:l}}function x(e,t){let n=N(e);if(n!==void 0)return t(n);if(!I(e))return;let r,i,a;for(let t of e.properties){if(!L(t)||t.computed)continue;let e=P(t.key);if(!e)continue;let n=N(t.value);n!==void 0&&(e===`id`&&(r=n),e===`message`&&(i=n),e===`context`&&(a=n))}if(r)return r;if(i)return t(i,a)}function S(e,t,n){if(!V(e))return;let r=M(e.openingElement.name);if(r){if(r===`Trans`){let r=O(e.openingElement,`__id`)??O(e.openingElement,`id`);if(r){t.add(r);return}let i=O(e.openingElement,`__message`),a=O(e.openingElement,`context`);i&&t.add(n(i,a));return}if(r===`Plural`){let r=C(e.openingElement,n);r&&t.add(r);return}if(r===`Select`){let r=w(e.openingElement,n);r&&t.add(r)}}}function C(e,t){let n=O(e,`id`);if(n)return n;let r=O(e,`context`),i=k(e,`offset`),a=[O(e,`zero`)===void 0?void 0:`=0 {${O(e,`zero`)}}`,O(e,`one`)===void 0?void 0:`one {${O(e,`one`)}}`,O(e,`two`)===void 0?void 0:`two {${O(e,`two`)}}`,O(e,`few`)===void 0?void 0:`few {${O(e,`few`)}}`,O(e,`many`)===void 0?void 0:`many {${O(e,`many`)}}`,O(e,`other`)===void 0?void 0:`other {${O(e,`other`)}}`].filter(Boolean);if(a.length!==0)return t(`{count, plural,${typeof i==`number`?` offset:${i}`:``} ${a.join(` `)}}`,r)}function w(e,t){let n=O(e,`id`);if(n)return n;let r=O(e,`context`),i=T(e);if(!(!i||i.other===void 0))return t(`{value, select, ${[...Object.keys(i).filter(e=>e!==`other`).sort(),`other`].map(e=>`${e} {${i[e]}}`).join(` `)}}`,r)}function T(e){let t=D(e,`options`);if(t){let n=O(e,`other`);return{...t,...n===void 0?{}:{other:n}}}let n={};for(let t of e.attributes){if(!H(t))continue;let e=t.name.name;if([`value`,`id`,`context`,`comment`,`options`].includes(e))continue;let r=j(t);r!==void 0&&(n[e]=r)}return Object.keys(n).length>0?n:void 0}function E(e){if(!I(e))return;let t={};for(let n of e.properties){if(!L(n)||n.computed)return;let e=P(n.key),r=N(n.value);if(!e||r===void 0)return;t[e]=r}return t}function D(e,t){let n=A(e,t);if(n?.value&&n.value.type===`JSXExpressionContainer`)return E(n.value.expression)}function O(e,t){return j(A(e,t))}function k(e,t){let n=A(e,t);if(!n?.value||n.value.type!==`JSXExpressionContainer`)return;let r=n.value.expression;return r.type===`NumericLiteral`?r.value:void 0}function A(e,t){return e.attributes.find(e=>H(e)&&e.name.name===t)}function j(e){if(e?.value){if(e.value.type===`StringLiteral`)return e.value.value;if(e.value.type===`JSXExpressionContainer`)return N(e.value.expression)}}function M(e){return e.type===`JSXIdentifier`?e.name:void 0}function N(e){if(e.type===`StringLiteral`)return e.value;if(e.type===`TemplateLiteral`){let t=e;if(t.expressions.length===0&&t.quasis.length===1)return t.quasis[0].value.cooked??t.quasis[0].value.raw}}function P(e){if(B(e))return e.name;if(e.type===`StringLiteral`)return e.value}function ee(e){return e.type===`ImportDeclaration`}function te(e){return e.type===`ImportSpecifier`}function ne(e){return e.type===`VariableDeclarator`}function F(e){return e.type===`ObjectPattern`}function I(e){return e.type===`ObjectExpression`}function L(e){return e.type===`ObjectProperty`}function R(e){return e.type===`CallExpression`}function z(e){return e.type===`MemberExpression`}function B(e){return e?.type===`Identifier`}function V(e){return e.type===`JSXElement`}function H(e){return e.type===`JSXAttribute`}function U(e){let t=e.imported;if(t.type===`Identifier`)return t.name;if(t.type===`StringLiteral`)return t.value}function W(e,n,r,i){if(n===`dynamic`)return`import { __catalog } from 'virtual:fluenti/runtime';\n${e}`;let a=i??t.hashMessage;return`import { ${[...r].map(e=>`_${a(e)}`).join(`, `)} } from 'virtual:fluenti/messages';\n${e}`}function G(e){return JSON.stringify(e)}function K(e){if(e.includes("`")||e.includes(`$`))throw Error(`[fluenti] vite-plugin: catalogDir must not contain backticks or $ characters, got ${JSON.stringify(e)}`)}var q=`virtual:fluenti/runtime`,J=`virtual:fluenti/messages`,Y=`\0virtual:fluenti/runtime`,X=`\0virtual:fluenti/messages`;function Z(e){if(e===q)return Y;if(e===J)return X}function Q(e,t){if(e===Y)return re(t);if(e===X)return ie(t)}function re(e){let{locales:t,runtimeGenerator:n,catalogDir:r}=e;K(r);for(let e of t)(0,s.validateLocale)(e,`vite-plugin`);if(!n)throw Error(`[fluenti] vite-plugin: runtimeGenerator is required. Use a framework-specific plugin (e.g. @fluenti/vue/vite-plugin).`);return n.generateRuntime(ae(e))}function ie(e){let{rootDir:t,catalogDir:n,catalogExtension:i,defaultBuildLocale:o,sourceLocale:c}=e,l=o||c;(0,s.validateLocale)(l,`vite-plugin`),K(n);let u=(0,r.resolve)((0,r.resolve)(t,n),l+i);return(0,a.existsSync)(u)||console.warn(`[fluenti] Compiled catalog for locale "${l}" not found at ${u}. Run "fluenti compile" first.`),`export * from ${G(u)}\n`}function ae(e){let{rootDir:t,catalogDir:n,catalogExtension:r,locales:i,sourceLocale:a,defaultBuildLocale:o}=e;return{rootDir:t,catalogDir:n,catalogExtension:r,locales:i,sourceLocale:a,defaultBuildLocale:o}}var oe=`virtual:fluenti/messages/`,se=`\0virtual:fluenti/messages/`;function $(e,t){return typeof e==`object`?{...n.DEFAULT_FLUENTI_CONFIG,...e}:(0,n.loadConfigSync)(typeof e==`string`?e:void 0,t)}function ce(n,r,i){let a,s=process.cwd();function c(e){let t=e??s;return a||=$(n.config,t),a}let g=n.framework;function _(e){let n=c(e),r=n.compileOutDir.replace(/^\.\//,``),i=n.catalogExtension??`.js`,a=n.splitting??!1;a&&a!==`dynamic`&&a!==`static`&&console.warn(`[fluenti] Invalid splitting value "${a}". Expected 'dynamic', 'static', or false. Falling back to 'dynamic'.`);let o=a===`static`?`static`:a?`dynamic`:!1,s=n.sourceLocale;return{config:n,catalogDir:r,catalogExtension:i,splitting:o,sourceLocale:s,localeCodes:(0,t.resolveLocaleCodes)(n.locales),defaultBuildLocale:n.defaultBuildLocale??s}}let v={name:`fluenti:virtual`,configResolved(e){s=e.root,a=$(n.config,s),l(e.command)},resolveId(e){if(e.startsWith(oe))return`\0`+e;let{splitting:t}=_();if(t){let t=Z(e);if(t)return t}},load(e){let{catalogDir:t,catalogExtension:n,splitting:r,localeCodes:a,sourceLocale:o,defaultBuildLocale:c}=_();if(e.startsWith(se)){let r=e.slice(26);return a.includes(r)?`export { default } from '${`${t}/${r}${n}`}'`:void 0}if(r){let r=Q(e,{rootDir:s,catalogDir:t,catalogExtension:n,locales:a,sourceLocale:o,defaultBuildLocale:c,framework:g,runtimeGenerator:i});if(r)return r}}},y=(0,o.createTransformPipeline)({framework:g}),b={name:`fluenti:script-transform`,enforce:`pre`,transform(e,t){if(t.includes(`node_modules`)||!t.match(/\.(vue|tsx|jsx|ts|js)(\?|$)/)||t.includes(`.vue`)&&!t.includes(`type=script`))return;let n=g===`vue`&&t.includes(`.vue`),r=`@fluenti/${g}/components`,i=e,a=!1;if(t.match(/\.[jt]sx(\?|$)/)&&/<Trans[\s>]/.test(i)){let e=y.transformTrans(i);e.transformed&&(i=e.code,a=!0)}if(t.match(/\.[jt]sx(\?|$)/)&&(g===`react`||g===`solid`)&&/<(Plural|Select)[\s/>]/.test(i)){let e=y.transformPluralSelect(i,r);e.transformed&&(i=e.code,a=!0)}if((0,o.hasScopeTransformCandidate)(i)){let e=y.transformScope(i,{componentModuleImport:r,...n?{allowTopLevelImportedT:!0}:{}});if(e.transformed)return{code:e.code,map:null}}return a?{code:i,map:null}:void 0}},x={name:`fluenti:build-split`,transform(e,t){let{splitting:n,config:r}=_();if(!n||!d(u(this))||t.includes(`node_modules`)||!t.match(/\.(vue|tsx|jsx|ts|js)(\?|$)/))return;let i=n===`static`?`static`:`dynamic`,a=r.idGenerator?{hashFn:r.idGenerator}:void 0,o=i===`static`?h(e,a):m(e,a);if(o.needsCatalogImport)return{code:W(o.code,i,o.usedHashes,r.idGenerator),map:null}}},S={name:`fluenti:build-compile`,async buildStart(){let{config:e}=_();d(u(this))&&(e.buildAutoCompile??!0)&&(e.onBeforeCompile&&await e.onBeforeCompile()===!1||(await f({cwd:s,throwOnError:!0,compileOnly:!0}),e.onAfterCompile&&await e.onAfterCompile()))}},C={name:`fluenti:dev`,configureServer(t){let{config:n,catalogDir:r}=_(t.config.root);if(!(n.devAutoCompile??!0))return;let i=(0,e.createFilter)(n.include??[`src/**/*.{vue,tsx,jsx,ts,js}`],[...n.exclude??[],`**/node_modules/**`,`**/${r}/**`]),a={cwd:t.config.root,onSuccess:()=>{}};n.parallelCompile&&(a.parallelCompile=!0),n.onBeforeCompile&&(a.onBeforeCompile=n.onBeforeCompile),n.onAfterCompile&&(a.onAfterCompile=n.onAfterCompile);let o=p(a,n.devAutoCompileDelay??500);o(),t.watcher.on(`change`,e=>{i(e)&&o()})},hotUpdate({file:e}){let{catalogDir:t}=_();if(e.includes(t)){let e=[...this.environment.moduleGraph.urlToModuleMap.entries()].filter(([e])=>e.includes(`virtual:fluenti`)).map(([,e])=>e);if(e.length>0)return e}}};return[v,...r,b,S,x,C]}exports.createFluentiPlugins=ce,Object.defineProperty(exports,`createRuntimeGenerator`,{enumerable:!0,get:function(){return o.createRuntimeGenerator}}),exports.getPluginEnvironment=u,exports.isBuildMode=d,exports.loadVirtualSplitModule=Q,exports.resolveVirtualSplitId=Z,exports.setResolvedMode=l;
|
|
5
5
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -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/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 { join, resolve } from 'node:path'\nimport { createRequire } from 'node:module'\nimport { mkdirSync } from 'node:fs'\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 * Run compile in-process via `@fluenti/cli`.\n *\n * In `compileOnly` mode, only compilation is performed (extract is skipped).\n * In dev mode, both extract and compile run in sequence.\n *\n * If `@fluenti/cli` is not installed, shows an install guide instead of\n * falling back to shell-out — keeping the process boundary clean.\n */\nexport async function runExtractCompile(options: DevRunnerOptions): Promise<void> {\n // Ensure compileOutDir exists on first run (auto-init for zero-config DX)\n try {\n const projectRequire = createRequire(join(options.cwd, 'package.json'))\n const { DEFAULT_FLUENTI_CONFIG, loadConfigSync } = projectRequire('@fluenti/core/config') as {\n DEFAULT_FLUENTI_CONFIG: { compileOutDir: string; catalogDir: string }\n loadConfigSync: (path?: string, cwd?: string) => { compileOutDir: string; catalogDir: string }\n }\n let config: { compileOutDir: string; catalogDir: string }\n try {\n config = loadConfigSync(undefined, options.cwd)\n } catch {\n config = DEFAULT_FLUENTI_CONFIG\n }\n mkdirSync(resolve(options.cwd, config.compileOutDir), { recursive: true })\n mkdirSync(resolve(options.cwd, config.catalogDir), { recursive: true })\n } catch {\n // Non-critical — directories may already exist or config may not be available\n }\n\n if (options.onBeforeCompile) {\n const result = await options.onBeforeCompile()\n if (result === false) return\n }\n\n if (options.compileOnly) {\n try {\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\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 (e) {\n const error = e instanceof Error ? e : new Error(String(e))\n const isNotInstalled = error.message.includes('Cannot find module')\n\n if (isNotInstalled) {\n const msg =\n '[fluenti] @fluenti/cli is required for auto-compile.\\n' +\n ' Install it as a devDependency:\\n' +\n ' pnpm add -D @fluenti/cli\\n' +\n ' See: https://fluenti.dev/start/introduction/'\n if (options.throwOnError) throw new Error(msg)\n console.warn(msg)\n options.onError?.(new Error(msg))\n return\n }\n\n if (options.throwOnError) throw error\n console.warn('[fluenti] Extract/compile failed:', error.message)\n options.onError?.(error)\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', hashes: Set<string>, hashFn?: HashFunction): string {\n if (strategy === 'dynamic') {\n return `import { __catalog } from 'virtual:fluenti/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 */\n\nimport { resolve } from 'node:path'\nimport { existsSync } from 'node:fs'\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 RESOLVED_RUNTIME = '\\0virtual:fluenti/runtime'\nconst RESOLVED_MESSAGES = '\\0virtual:fluenti/messages'\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 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 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 const catalogFile = resolve(absoluteCatalogDir, defaultLocale + catalogExtension)\n\n if (!existsSync(catalogFile)) {\n console.warn(\n `[fluenti] Compiled catalog for locale \"${defaultLocale}\" not found at ${catalogFile}. Run \"fluenti compile\" first.`,\n )\n }\n\n return `export * from ${safeStringLiteral(catalogFile)}\\n`\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","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 { createRequire } from 'node:module'\n\nconst _require = createRequire(\n typeof __filename !== 'undefined' ? __filename : import.meta.url,\n)\nimport { createDebouncedRunner, runExtractCompile } from './dev-runner'\nimport { transformForDynamicSplit, transformForStaticSplit, injectCatalogImport } from './build-transform'\nimport { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules'\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 let fluentiConfig: FluentiBuildConfig | undefined\n let rootDir = process.cwd()\n\n function getConfig(cwd?: string): FluentiBuildConfig {\n const effectiveCwd = cwd ?? rootDir\n if (!fluentiConfig) {\n fluentiConfig = resolvePluginConfig(options.config, effectiveCwd)\n }\n return fluentiConfig\n }\n\n const framework = options.framework\n\n function getResolvedSettings(cwd?: string) {\n const config = getConfig(cwd)\n const catalogDir = config.compileOutDir.replace(/^\\.\\//, '')\n const catalogExtension = config.catalogExtension ?? '.js'\n const rawSplitting = config.splitting ?? false\n if (rawSplitting && rawSplitting !== 'dynamic' && rawSplitting !== 'static') {\n console.warn(`[fluenti] Invalid splitting value \"${rawSplitting}\". Expected 'dynamic', 'static', or false. Falling back to 'dynamic'.`)\n }\n const splitting = rawSplitting === 'static' ? 'static' as const : rawSplitting ? 'dynamic' as const : false as const\n const sourceLocale = config.sourceLocale\n const localeCodes = resolveLocaleCodes(config.locales)\n const defaultBuildLocale = config.defaultBuildLocale ?? sourceLocale\n return {\n config,\n catalogDir,\n catalogExtension,\n splitting,\n sourceLocale,\n localeCodes,\n defaultBuildLocale,\n }\n }\n\n const virtualPlugin: Plugin = {\n name: 'fluenti:virtual',\n configResolved(config) {\n rootDir = config.root\n fluentiConfig = resolvePluginConfig(options.config, rootDir)\n setResolvedMode(config.command)\n },\n resolveId(id) {\n if (id.startsWith(VIRTUAL_PREFIX)) {\n return '\\0' + id\n }\n const { splitting } = getResolvedSettings()\n if (splitting) {\n const resolved = resolveVirtualSplitId(id)\n if (resolved) return resolved\n }\n return undefined\n },\n load(id) {\n const {\n catalogDir,\n catalogExtension,\n splitting,\n localeCodes,\n sourceLocale,\n defaultBuildLocale,\n } = getResolvedSettings()\n if (id.startsWith(RESOLVED_PREFIX)) {\n const locale = id.slice(RESOLVED_PREFIX.length)\n if (!localeCodes.includes(locale)) {\n return undefined\n }\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 const buildSplitPlugin: Plugin = {\n name: 'fluenti:build-split',\n transform(code, id) {\n const { splitting, config } = getResolvedSettings()\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 = config.idGenerator ? { hashFn: config.idGenerator } : undefined\n const transformed = strategy === 'static'\n ? transformForStaticSplit(code, transformOptions)\n : transformForDynamicSplit(code, transformOptions)\n\n if (!transformed.needsCatalogImport) return undefined\n\n const finalCode = injectCatalogImport(\n transformed.code,\n strategy,\n transformed.usedHashes,\n config.idGenerator,\n )\n return { code: finalCode, map: null }\n },\n }\n\n const buildCompilePlugin: Plugin = {\n name: 'fluenti:build-compile',\n async buildStart() {\n const { config } = getResolvedSettings()\n if (!isBuildMode(getPluginEnvironment(this))) return\n const buildAutoCompile = config.buildAutoCompile ?? true\n if (!buildAutoCompile) return\n if (config.onBeforeCompile) {\n const result = await config.onBeforeCompile()\n if (result === false) return\n }\n await runExtractCompile({ cwd: rootDir, throwOnError: true, compileOnly: true })\n if (config.onAfterCompile) {\n await config.onAfterCompile()\n }\n },\n }\n\n const devPlugin: Plugin = {\n name: 'fluenti:dev',\n configureServer(server) {\n const { config, catalogDir } = getResolvedSettings(server.config.root)\n const devAutoCompile = config.devAutoCompile ?? true\n if (!devAutoCompile) return\n\n const includePatterns = config.include ?? ['src/**/*.{vue,tsx,jsx,ts,js}']\n const excludePatterns = config.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 (config.parallelCompile) runnerOptions.parallelCompile = true\n if (config.onBeforeCompile) runnerOptions.onBeforeCompile = config.onBeforeCompile\n if (config.onAfterCompile) runnerOptions.onAfterCompile = config.onAfterCompile\n const debouncedRun = createDebouncedRunner(runnerOptions, config.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 const { catalogDir } = getResolvedSettings()\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 (dynamic/static)\n // 6. devPlugin — file watcher + HMR for dev mode (must be last)\n return [virtualPlugin, ...frameworkPlugins, scriptTransformPlugin, buildCompilePlugin, buildSplitPlugin, devPlugin]\n}\n"],"mappings":"kQAKA,IAAI,EAAgC,MAGpC,SAAgB,EAAgB,EAAuB,CACrD,EAAe,IAAY,QAAU,QAAU,MAYjD,SAAgB,EAAqB,EAAuD,CAC1F,GACE,OAAO,GAAkB,UACzB,GACA,gBAAiB,EACjB,CACA,IAAM,EAAO,EAA0C,YACvD,GAAI,OAAO,GAAQ,UAAY,EAC7B,OAAO,GAWb,SAAgB,EAAY,EAA0C,CAUpE,OARI,GAAa,OAAS,SAGtB,IAAiB,SAGrB,QAAA,IAAA,WAAgC,aCnBlC,eAAsB,EAAkB,EAA0C,CAEhF,GAAI,CAEF,GAAM,CAAE,yBAAwB,mBAAA,EAAA,EAAA,gBAAA,EAAA,EAAA,MADU,EAAQ,IAAK,eAAe,CAAC,CACL,uBAAuB,CAIrF,EACJ,GAAI,CACF,EAAS,EAAe,IAAA,GAAW,EAAQ,IAAI,MACzC,CACN,EAAS,GAEX,EAAA,EAAA,YAAA,EAAA,EAAA,SAAkB,EAAQ,IAAK,EAAO,cAAc,CAAE,CAAE,UAAW,GAAM,CAAC,EAC1E,EAAA,EAAA,YAAA,EAAA,EAAA,SAAkB,EAAQ,IAAK,EAAO,WAAW,CAAE,CAAE,UAAW,GAAM,CAAC,MACjE,OAIJ,EAAQ,iBACK,MAAM,EAAQ,iBAAiB,GAC/B,IAGjB,IAAI,EAAQ,YACV,GAAI,CAEF,GAAM,CAAE,eAAA,EAAA,EAAA,gBAAA,EAAA,EAAA,MADkC,EAAQ,IAAK,eAAe,CAAC,CACjC,eAAe,CACrD,MAAM,EAAW,EAAQ,IAAI,CAC7B,QAAQ,IAAI,8BAA8B,CACtC,EAAQ,gBAAgB,MAAM,EAAQ,gBAAgB,CAC1D,EAAQ,aAAa,CACrB,aACO,EAAG,CACV,IAAM,EAAQ,aAAa,MAAQ,EAAQ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AiB,EAAc,gBAAkB,IACxD,EAAO,kBAAiB,EAAc,gBAAkB,EAAO,iBAC/D,EAAO,iBAAgB,EAAc,eAAiB,EAAO,gBACjE,IAAM,EAAe,EAAsB,EAAe,EAAO,qBAAuB,IAAI,CAE5F,GAAc,CAEd,EAAO,QAAQ,GAAG,SAAW,GAAS,CAChC,EAAO,EAAK,EACd,GAAc,EAEhB,EAEJ,UAAU,CAAE,QAAQ,CAClB,GAAM,CAAE,cAAe,GAAqB,CAC5C,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,CAUD,MAAO,CAAC,EAAe,GAAG,EAAkB,EAAuB,EAAoB,EAAkB,EAAU"}
|
|
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/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 { join, resolve } from 'node:path'\nimport { createRequire } from 'node:module'\nimport { mkdirSync } from 'node:fs'\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 * Run compile in-process via `@fluenti/cli`.\n *\n * In `compileOnly` mode, only compilation is performed (extract is skipped).\n * In dev mode, both extract and compile run in sequence.\n *\n * If `@fluenti/cli` is not installed, shows an install guide instead of\n * falling back to shell-out — keeping the process boundary clean.\n */\nexport async function runExtractCompile(options: DevRunnerOptions): Promise<void> {\n // Ensure compileOutDir exists on first run (auto-init for zero-config DX)\n try {\n const projectRequire = createRequire(join(options.cwd, 'package.json'))\n const { DEFAULT_FLUENTI_CONFIG, loadConfigSync } = projectRequire('@fluenti/core/config') as {\n DEFAULT_FLUENTI_CONFIG: { compileOutDir: string; catalogDir: string }\n loadConfigSync: (path?: string, cwd?: string) => { compileOutDir: string; catalogDir: string }\n }\n let config: { compileOutDir: string; catalogDir: string }\n try {\n config = loadConfigSync(undefined, options.cwd)\n } catch {\n config = DEFAULT_FLUENTI_CONFIG\n }\n mkdirSync(resolve(options.cwd, config.compileOutDir), { recursive: true })\n mkdirSync(resolve(options.cwd, config.catalogDir), { recursive: true })\n } catch {\n // Non-critical — directories may already exist or config may not be available\n }\n\n if (options.onBeforeCompile) {\n const result = await options.onBeforeCompile()\n if (result === false) return\n }\n\n if (options.compileOnly) {\n try {\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\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 (e) {\n const error = e instanceof Error ? e : new Error(String(e))\n const isNotInstalled = error.message.includes('Cannot find module')\n\n if (isNotInstalled) {\n const msg =\n '[fluenti] @fluenti/cli is required for auto-compile.\\n' +\n ' Install it as a devDependency:\\n' +\n ' pnpm add -D @fluenti/cli\\n' +\n ' See: https://fluenti.dev/start/introduction/'\n if (options.throwOnError) throw new Error(msg)\n console.warn(msg)\n options.onError?.(new Error(msg))\n return\n }\n\n if (options.throwOnError) throw error\n console.warn('[fluenti] Extract/compile failed:', error.message)\n options.onError?.(error)\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/compiler'\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', hashes: Set<string>, hashFn?: HashFunction): string {\n if (strategy === 'dynamic') {\n return `import { __catalog } from 'virtual:fluenti/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 */\n\nimport { resolve } from 'node:path'\nimport { existsSync } from 'node:fs'\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 RESOLVED_RUNTIME = '\\0virtual:fluenti/runtime'\nconst RESOLVED_MESSAGES = '\\0virtual:fluenti/messages'\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 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 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 const catalogFile = resolve(absoluteCatalogDir, defaultLocale + catalogExtension)\n\n if (!existsSync(catalogFile)) {\n console.warn(\n `[fluenti] Compiled catalog for locale \"${defaultLocale}\" not found at ${catalogFile}. Run \"fluenti compile\" first.`,\n )\n }\n\n return `export * from ${safeStringLiteral(catalogFile)}\\n`\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","import type { Plugin } from 'vite'\nimport { createFilter } from 'vite'\nimport type { FluentiCoreOptions, RuntimeGenerator } from './types'\nimport type { FluentiBuildConfig } from '@fluenti/core/compiler'\nimport { resolveLocaleCodes } from '@fluenti/core/compiler'\nimport { DEFAULT_FLUENTI_CONFIG, loadConfigSync } from '@fluenti/core/config'\nimport { setResolvedMode, isBuildMode, getPluginEnvironment } from './mode-detect'\nimport { createDebouncedRunner, runExtractCompile } from './dev-runner'\nimport { transformForDynamicSplit, transformForStaticSplit, injectCatalogImport } from './build-transform'\nimport { resolveVirtualSplitId, loadVirtualSplitModule } from './virtual-modules'\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 return { ...DEFAULT_FLUENTI_CONFIG, ...configOption }\n }\n // string → specified path; undefined → auto-discover\n return loadConfigSync(\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 let fluentiConfig: FluentiBuildConfig | undefined\n let rootDir = process.cwd()\n\n function getConfig(cwd?: string): FluentiBuildConfig {\n const effectiveCwd = cwd ?? rootDir\n if (!fluentiConfig) {\n fluentiConfig = resolvePluginConfig(options.config, effectiveCwd)\n }\n return fluentiConfig\n }\n\n const framework = options.framework\n\n function getResolvedSettings(cwd?: string) {\n const config = getConfig(cwd)\n const catalogDir = config.compileOutDir.replace(/^\\.\\//, '')\n const catalogExtension = config.catalogExtension ?? '.js'\n const rawSplitting = config.splitting ?? false\n if (rawSplitting && rawSplitting !== 'dynamic' && rawSplitting !== 'static') {\n console.warn(`[fluenti] Invalid splitting value \"${rawSplitting}\". Expected 'dynamic', 'static', or false. Falling back to 'dynamic'.`)\n }\n const splitting = rawSplitting === 'static' ? 'static' as const : rawSplitting ? 'dynamic' as const : false as const\n const sourceLocale = config.sourceLocale\n const localeCodes = resolveLocaleCodes(config.locales)\n const defaultBuildLocale = config.defaultBuildLocale ?? sourceLocale\n return {\n config,\n catalogDir,\n catalogExtension,\n splitting,\n sourceLocale,\n localeCodes,\n defaultBuildLocale,\n }\n }\n\n const virtualPlugin: Plugin = {\n name: 'fluenti:virtual',\n configResolved(config) {\n rootDir = config.root\n fluentiConfig = resolvePluginConfig(options.config, rootDir)\n setResolvedMode(config.command)\n },\n resolveId(id) {\n if (id.startsWith(VIRTUAL_PREFIX)) {\n return '\\0' + id\n }\n const { splitting } = getResolvedSettings()\n if (splitting) {\n const resolved = resolveVirtualSplitId(id)\n if (resolved) return resolved\n }\n return undefined\n },\n load(id) {\n const {\n catalogDir,\n catalogExtension,\n splitting,\n localeCodes,\n sourceLocale,\n defaultBuildLocale,\n } = getResolvedSettings()\n if (id.startsWith(RESOLVED_PREFIX)) {\n const locale = id.slice(RESOLVED_PREFIX.length)\n if (!localeCodes.includes(locale)) {\n return undefined\n }\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 const componentModuleImport = `@fluenti/${framework}/components`\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 if (\n id.match(/\\.[jt]sx(\\?|$)/)\n && (framework === 'react' || framework === 'solid')\n && /<(Plural|Select)[\\s/>]/.test(result)\n ) {\n const componentResult = pipeline.transformPluralSelect(result, componentModuleImport)\n if (componentResult.transformed) {\n result = componentResult.code\n changed = true\n }\n }\n\n // ── t`` / t() scope-aware transform ────────────────────────────────\n if (hasScopeTransformCandidate(result)) {\n const scoped = pipeline.transformScope(result, {\n componentModuleImport,\n ...(isVueSfc ? { allowTopLevelImportedT: true } : {}),\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 const buildSplitPlugin: Plugin = {\n name: 'fluenti:build-split',\n transform(code, id) {\n const { splitting, config } = getResolvedSettings()\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 = config.idGenerator ? { hashFn: config.idGenerator } : undefined\n const transformed = strategy === 'static'\n ? transformForStaticSplit(code, transformOptions)\n : transformForDynamicSplit(code, transformOptions)\n\n if (!transformed.needsCatalogImport) return undefined\n\n const finalCode = injectCatalogImport(\n transformed.code,\n strategy,\n transformed.usedHashes,\n config.idGenerator,\n )\n return { code: finalCode, map: null }\n },\n }\n\n const buildCompilePlugin: Plugin = {\n name: 'fluenti:build-compile',\n async buildStart() {\n const { config } = getResolvedSettings()\n if (!isBuildMode(getPluginEnvironment(this))) return\n const buildAutoCompile = config.buildAutoCompile ?? true\n if (!buildAutoCompile) return\n if (config.onBeforeCompile) {\n const result = await config.onBeforeCompile()\n if (result === false) return\n }\n await runExtractCompile({ cwd: rootDir, throwOnError: true, compileOnly: true })\n if (config.onAfterCompile) {\n await config.onAfterCompile()\n }\n },\n }\n\n const devPlugin: Plugin = {\n name: 'fluenti:dev',\n configureServer(server) {\n const { config, catalogDir } = getResolvedSettings(server.config.root)\n const devAutoCompile = config.devAutoCompile ?? true\n if (!devAutoCompile) return\n\n const includePatterns = config.include ?? ['src/**/*.{vue,tsx,jsx,ts,js}']\n const excludePatterns = config.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 (config.parallelCompile) runnerOptions.parallelCompile = true\n if (config.onBeforeCompile) runnerOptions.onBeforeCompile = config.onBeforeCompile\n if (config.onAfterCompile) runnerOptions.onAfterCompile = config.onAfterCompile\n const debouncedRun = createDebouncedRunner(runnerOptions, config.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 const { catalogDir } = getResolvedSettings()\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 (dynamic/static)\n // 6. devPlugin — file watcher + HMR for dev mode (must be last)\n return [virtualPlugin, ...frameworkPlugins, scriptTransformPlugin, buildCompilePlugin, buildSplitPlugin, devPlugin]\n}\n"],"mappings":"oSAKA,IAAI,EAAgC,MAGpC,SAAgB,EAAgB,EAAuB,CACrD,EAAe,IAAY,QAAU,QAAU,MAYjD,SAAgB,EAAqB,EAAuD,CAC1F,GACE,OAAO,GAAkB,UACzB,GACA,gBAAiB,EACjB,CACA,IAAM,EAAO,EAA0C,YACvD,GAAI,OAAO,GAAQ,UAAY,EAC7B,OAAO,GAWb,SAAgB,EAAY,EAA0C,CAUpE,OARI,GAAa,OAAS,SAGtB,IAAiB,SAGrB,QAAA,IAAA,WAAgC,aCnBlC,eAAsB,EAAkB,EAA0C,CAEhF,GAAI,CAEF,GAAM,CAAE,yBAAwB,mBAAA,EAAA,EAAA,gBAAA,EAAA,EAAA,MADU,EAAQ,IAAK,eAAe,CAAC,CACL,uBAAuB,CAIrF,EACJ,GAAI,CACF,EAAS,EAAe,IAAA,GAAW,EAAQ,IAAI,MACzC,CACN,EAAS,GAEX,EAAA,EAAA,YAAA,EAAA,EAAA,SAAkB,EAAQ,IAAK,EAAO,cAAc,CAAE,CAAE,UAAW,GAAM,CAAC,EAC1E,EAAA,EAAA,YAAA,EAAA,EAAA,SAAkB,EAAQ,IAAK,EAAO,WAAW,CAAE,CAAE,UAAW,GAAM,CAAC,MACjE,OAIJ,EAAQ,iBACK,MAAM,EAAQ,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