@fluenti/react 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/Number-DfzWPfIE.js +0 -2
  2. package/dist/Number-JCugssFE.cjs +1 -2
  3. package/dist/components-entry.cjs +1 -2
  4. package/dist/components-entry.js +0 -2
  5. package/dist/icu-rich-BlDjwT5Z.cjs +1 -2
  6. package/dist/icu-rich-C6B9ns4t.js +0 -2
  7. package/dist/index.cjs +1 -2
  8. package/dist/index.js +0 -2
  9. package/dist/react/src/compile-time-t.d.ts +0 -1
  10. package/dist/react/src/components/DateTime.d.ts +0 -1
  11. package/dist/react/src/components/Number.d.ts +0 -1
  12. package/dist/react/src/components/Plural.d.ts +0 -1
  13. package/dist/react/src/components/Select.d.ts +0 -1
  14. package/dist/react/src/components/Trans.d.ts +0 -1
  15. package/dist/react/src/components/compiled.d.ts +0 -1
  16. package/dist/react/src/components/icu-rich.d.ts +0 -1
  17. package/dist/react/src/components/plain.d.ts +0 -1
  18. package/dist/react/src/components/plural-core.d.ts +0 -1
  19. package/dist/react/src/components/trans-core.d.ts +0 -1
  20. package/dist/react/src/components-entry.d.ts +0 -1
  21. package/dist/react/src/context.d.ts +0 -1
  22. package/dist/react/src/create-fluenti.d.ts +0 -1
  23. package/dist/react/src/global-registry.d.ts +0 -1
  24. package/dist/react/src/hooks/__useI18n.d.ts +0 -1
  25. package/dist/react/src/hooks/useI18n.d.ts +0 -1
  26. package/dist/react/src/index.d.ts +0 -1
  27. package/dist/react/src/msg.d.ts +0 -1
  28. package/dist/react/src/provider.d.ts +0 -1
  29. package/dist/react/src/react-runtime.d.ts +0 -1
  30. package/dist/react/src/server.d.ts +0 -1
  31. package/dist/react/src/types.d.ts +0 -1
  32. package/dist/react/src/vite-plugin.d.ts +0 -1
  33. package/dist/server.cjs +1 -2
  34. package/dist/server.js +0 -2
  35. package/dist/vite-plugin.cjs +1 -2
  36. package/dist/vite-plugin.js +0 -2
  37. package/package.json +3 -3
  38. package/dist/Number-DfzWPfIE.js.map +0 -1
  39. package/dist/Number-JCugssFE.cjs.map +0 -1
  40. package/dist/components-entry.cjs.map +0 -1
  41. package/dist/components-entry.js.map +0 -1
  42. package/dist/icu-rich-BlDjwT5Z.cjs.map +0 -1
  43. package/dist/icu-rich-C6B9ns4t.js.map +0 -1
  44. package/dist/index.cjs.map +0 -1
  45. package/dist/index.js.map +0 -1
  46. package/dist/react/src/compile-time-t.d.ts.map +0 -1
  47. package/dist/react/src/components/DateTime.d.ts.map +0 -1
  48. package/dist/react/src/components/Number.d.ts.map +0 -1
  49. package/dist/react/src/components/Plural.d.ts.map +0 -1
  50. package/dist/react/src/components/Select.d.ts.map +0 -1
  51. package/dist/react/src/components/Trans.d.ts.map +0 -1
  52. package/dist/react/src/components/compiled.d.ts.map +0 -1
  53. package/dist/react/src/components/icu-rich.d.ts.map +0 -1
  54. package/dist/react/src/components/plain.d.ts.map +0 -1
  55. package/dist/react/src/components/plural-core.d.ts.map +0 -1
  56. package/dist/react/src/components/trans-core.d.ts.map +0 -1
  57. package/dist/react/src/components-entry.d.ts.map +0 -1
  58. package/dist/react/src/context.d.ts.map +0 -1
  59. package/dist/react/src/create-fluenti.d.ts.map +0 -1
  60. package/dist/react/src/global-registry.d.ts.map +0 -1
  61. package/dist/react/src/hooks/__useI18n.d.ts.map +0 -1
  62. package/dist/react/src/hooks/useI18n.d.ts.map +0 -1
  63. package/dist/react/src/index.d.ts.map +0 -1
  64. package/dist/react/src/msg.d.ts.map +0 -1
  65. package/dist/react/src/provider.d.ts.map +0 -1
  66. package/dist/react/src/react-runtime.d.ts.map +0 -1
  67. package/dist/react/src/server.d.ts.map +0 -1
  68. package/dist/react/src/types.d.ts.map +0 -1
  69. package/dist/react/src/vite-plugin.d.ts.map +0 -1
  70. package/dist/server.cjs.map +0 -1
  71. package/dist/server.js.map +0 -1
  72. package/dist/vite-plugin.cjs.map +0 -1
  73. package/dist/vite-plugin.js.map +0 -1
@@ -138,5 +138,3 @@ var D = /* @__PURE__ */ d(function({ value: t, id: r, context: i, comment: o, ze
138
138
  });
139
139
  //#endregion
140
140
  export { C as a, D as i, k as n, S as o, O as r, x as s, A as t };
141
-
142
- //# sourceMappingURL=Number-DfzWPfIE.js.map
@@ -1,2 +1 @@
1
- const e=require(`./icu-rich-BlDjwT5Z.cjs`);let t=require(`react`),n=require(`react/jsx-runtime`),r=require(`@fluenti/core/runtime`);var i=(0,t.createContext)(null),a=(0,t.memo)(function({children:a,id:o,context:s,comment:c,tag:l,render:u,__id:d,__message:f,__components:p}){let m=(0,t.useContext)(i);if(!m)throw Error(`[fluenti] <Trans> must be used within an <I18nProvider>`);if(f!==void 0){let i=f,a=p??[],h=o??d??(0,r.hashMessage)(i,s),g=m.t({id:h,message:i,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c}}),_=a.length>0?e.i(g,a):g;return u?u(_):l?(0,t.createElement)(l,null,_):(0,n.jsx)(n.Fragment,{children:_})}let{message:h,components:g}=(0,t.useMemo)(()=>e.r(a),[a]),_=(0,t.useMemo)(()=>o??d??(0,r.hashMessage)(h,s),[o,d,h,s]),v=m.t({id:_,message:h,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c}}),y=g.length>0?e.i(v,g):v;return u?u(y):l?(0,t.createElement)(l,null,y):(0,n.jsx)(n.Fragment,{children:y})});function o(e,t,n){return e??(n===void 0?t:(0,r.hashMessage)(t,n))}function s(e){return typeof e==`string`||typeof e==`number`}function c(e,t){let n={};for(let t of r.PLURAL_CATEGORIES){let r=e[t];if(r!==void 0){if(!s(r))return;n[t]=String(r)}}if(n.other!==void 0)return(0,r.buildICUPluralMessage)(n,t)}function l(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(!s(r))return;t[n]=String(r)}if(t.other===void 0)return;let n=(0,r.normalizeSelectForms)(t);return{message:(0,r.buildICUSelectMessage)(n.forms),valueMap:n.valueMap}}var u=(0,t.memo)(function({value:a,id:s,context:l,comment:u,zero:d,one:f,two:p,few:m,many:h,other:g,offset:_}){let v=(0,t.useContext)(i);if(!v)throw Error(`[fluenti] <Plural> must be used within an <I18nProvider>`);let y={zero:d,one:f,two:p,few:m,many:h,other:g},b=c(y,_);if(b!==void 0)return(0,n.jsx)(n.Fragment,{children:v.t({id:o(s,b,l),message:b,...l===void 0?{}:{context:l},...u===void 0?{}:{comment:u}},{count:a})});let{messages:x,components:S}=e.n(r.PLURAL_CATEGORIES,y),C=(0,r.buildICUPluralMessage)({...x.zero!==void 0&&{zero:x.zero},...x.one!==void 0&&{one:x.one},...x.two!==void 0&&{two:x.two},...x.few!==void 0&&{few:x.few},...x.many!==void 0&&{many:x.many},other:x.other??``},_);return(0,n.jsx)(n.Fragment,{children:e.t({id:o(s,C,l),message:C,...l===void 0?{}:{context:l},...u===void 0?{}:{comment:u}},{count:a},(e,t)=>v.t(e,t),S)})}),d=(0,t.memo)(function(a){let s=(0,t.useContext)(i);if(!s)throw Error(`[fluenti] <Select> must be used within an <I18nProvider>`);let{value:c,id:u,context:d,comment:f,other:p,options:m,tag:h,...g}=a,_=m===void 0?{...Object.fromEntries(Object.entries(g).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`,`tag`].includes(e))),other:p}:{...m,other:p},v=l(_);if(v!==void 0){let e=s.t({id:o(u,v.message,d),message:v.message,...d===void 0?{}:{context:d},...f===void 0?{}:{comment:f}},{value:v.valueMap[c]??`other`});return h?(0,t.createElement)(h,null,e):(0,n.jsx)(n.Fragment,{children:e})}let y=[...Object.keys(_).filter(e=>e!==`other`),`other`],{messages:b,components:x}=e.n(y,_),S=(0,r.normalizeSelectForms)(Object.fromEntries([...y].map(e=>[e,b[e]??``]))),C=(0,r.buildICUSelectMessage)(S.forms),w=e.t({id:o(u,C,d),message:C,...d===void 0?{}:{context:d},...f===void 0?{}:{comment:f}},{value:S.valueMap[c]??`other`},(e,t)=>s.t(e,t),x);return h?(0,t.createElement)(h,null,w):(0,n.jsx)(n.Fragment,{children:w})}),f=(0,t.memo)(function({value:e,format:r}){let a=(0,t.useContext)(i);if(!a)throw Error(`[fluenti] <DateTime> must be used within an <I18nProvider>`);return(0,n.jsx)(n.Fragment,{children:a.d(e,r)})}),p=(0,t.memo)(function({value:e,format:r}){let a=(0,t.useContext)(i);if(!a)throw Error(`[fluenti] <Number> must be used within an <I18nProvider>`);return(0,n.jsx)(n.Fragment,{children:a.n(e,r)})});Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
2
- //# sourceMappingURL=Number-JCugssFE.cjs.map
1
+ const e=require(`./icu-rich-BlDjwT5Z.cjs`);let t=require(`react`),n=require(`react/jsx-runtime`),r=require(`@fluenti/core/runtime`);var i=(0,t.createContext)(null),a=(0,t.memo)(function({children:a,id:o,context:s,comment:c,tag:l,render:u,__id:d,__message:f,__components:p}){let m=(0,t.useContext)(i);if(!m)throw Error(`[fluenti] <Trans> must be used within an <I18nProvider>`);if(f!==void 0){let i=f,a=p??[],h=o??d??(0,r.hashMessage)(i,s),g=m.t({id:h,message:i,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c}}),_=a.length>0?e.i(g,a):g;return u?u(_):l?(0,t.createElement)(l,null,_):(0,n.jsx)(n.Fragment,{children:_})}let{message:h,components:g}=(0,t.useMemo)(()=>e.r(a),[a]),_=(0,t.useMemo)(()=>o??d??(0,r.hashMessage)(h,s),[o,d,h,s]),v=m.t({id:_,message:h,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c}}),y=g.length>0?e.i(v,g):v;return u?u(y):l?(0,t.createElement)(l,null,y):(0,n.jsx)(n.Fragment,{children:y})});function o(e,t,n){return e??(n===void 0?t:(0,r.hashMessage)(t,n))}function s(e){return typeof e==`string`||typeof e==`number`}function c(e,t){let n={};for(let t of r.PLURAL_CATEGORIES){let r=e[t];if(r!==void 0){if(!s(r))return;n[t]=String(r)}}if(n.other!==void 0)return(0,r.buildICUPluralMessage)(n,t)}function l(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0){if(!s(r))return;t[n]=String(r)}if(t.other===void 0)return;let n=(0,r.normalizeSelectForms)(t);return{message:(0,r.buildICUSelectMessage)(n.forms),valueMap:n.valueMap}}var u=(0,t.memo)(function({value:a,id:s,context:l,comment:u,zero:d,one:f,two:p,few:m,many:h,other:g,offset:_}){let v=(0,t.useContext)(i);if(!v)throw Error(`[fluenti] <Plural> must be used within an <I18nProvider>`);let y={zero:d,one:f,two:p,few:m,many:h,other:g},b=c(y,_);if(b!==void 0)return(0,n.jsx)(n.Fragment,{children:v.t({id:o(s,b,l),message:b,...l===void 0?{}:{context:l},...u===void 0?{}:{comment:u}},{count:a})});let{messages:x,components:S}=e.n(r.PLURAL_CATEGORIES,y),C=(0,r.buildICUPluralMessage)({...x.zero!==void 0&&{zero:x.zero},...x.one!==void 0&&{one:x.one},...x.two!==void 0&&{two:x.two},...x.few!==void 0&&{few:x.few},...x.many!==void 0&&{many:x.many},other:x.other??``},_);return(0,n.jsx)(n.Fragment,{children:e.t({id:o(s,C,l),message:C,...l===void 0?{}:{context:l},...u===void 0?{}:{comment:u}},{count:a},(e,t)=>v.t(e,t),S)})}),d=(0,t.memo)(function(a){let s=(0,t.useContext)(i);if(!s)throw Error(`[fluenti] <Select> must be used within an <I18nProvider>`);let{value:c,id:u,context:d,comment:f,other:p,options:m,tag:h,...g}=a,_=m===void 0?{...Object.fromEntries(Object.entries(g).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`,`tag`].includes(e))),other:p}:{...m,other:p},v=l(_);if(v!==void 0){let e=s.t({id:o(u,v.message,d),message:v.message,...d===void 0?{}:{context:d},...f===void 0?{}:{comment:f}},{value:v.valueMap[c]??`other`});return h?(0,t.createElement)(h,null,e):(0,n.jsx)(n.Fragment,{children:e})}let y=[...Object.keys(_).filter(e=>e!==`other`),`other`],{messages:b,components:x}=e.n(y,_),S=(0,r.normalizeSelectForms)(Object.fromEntries([...y].map(e=>[e,b[e]??``]))),C=(0,r.buildICUSelectMessage)(S.forms),w=e.t({id:o(u,C,d),message:C,...d===void 0?{}:{context:d},...f===void 0?{}:{comment:f}},{value:S.valueMap[c]??`other`},(e,t)=>s.t(e,t),x);return h?(0,t.createElement)(h,null,w):(0,n.jsx)(n.Fragment,{children:w})}),f=(0,t.memo)(function({value:e,format:r}){let a=(0,t.useContext)(i);if(!a)throw Error(`[fluenti] <DateTime> must be used within an <I18nProvider>`);return(0,n.jsx)(n.Fragment,{children:a.d(e,r)})}),p=(0,t.memo)(function({value:e,format:r}){let a=(0,t.useContext)(i);if(!a)throw Error(`[fluenti] <Number> must be used within an <I18nProvider>`);return(0,n.jsx)(n.Fragment,{children:a.n(e,r)})});Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return p}});
@@ -1,2 +1 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Number-JCugssFE.cjs`),t=require(`./icu-rich-BlDjwT5Z.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`),i=require(`@fluenti/core/runtime`);function a(e,t,i){return i?i(e):t?(0,n.createElement)(t,null,e):(0,r.jsx)(r.Fragment,{children:e})}var o=(0,n.memo)(function({message:t,id:r,context:o,comment:s,tag:c,render:l}){let u=(0,n.useContext)(e.s);if(!u)throw Error(`[fluenti] <Trans> must be used within an <I18nProvider>`);return a(u.t({id:r??(0,i.hashMessage)(t,o),message:t,...o===void 0?{}:{context:o},...s===void 0?{}:{comment:s}}),c,l)}),s=(0,n.memo)(function({message:r,components:o,id:s,context:c,comment:l,tag:u,render:d}){let f=(0,n.useContext)(e.s);if(!f)throw Error(`[fluenti] <Trans> must be used within an <I18nProvider>`);return a(t.t({id:s??(0,i.hashMessage)(r,c),message:r,...c===void 0?{}:{context:c},...l===void 0?{}:{comment:l}},void 0,(e,t)=>f.t(e,t),o),u,d)}),c=(0,n.memo)(function({value:t,message:i,id:a,context:o,comment:s}){let c=(0,n.useContext)(e.s);if(!c)throw Error(`[fluenti] <Plural> must be used within an <I18nProvider>`);return(0,r.jsx)(r.Fragment,{children:c.t({id:e.a(a,i,o),message:i,...o===void 0?{}:{context:o},...s===void 0?{}:{comment:s}},{count:t})})}),l=(0,n.memo)(function({value:t,message:i,valueMap:a,id:o,context:s,comment:c,tag:l}){let u=(0,n.useContext)(e.s);if(!u)throw Error(`[fluenti] <Select> must be used within an <I18nProvider>`);let d=u.t({id:e.a(o,i,s),message:i,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c}},{value:a?.[t]??`other`});return l?(0,n.createElement)(l,null,d):(0,r.jsx)(r.Fragment,{children:d})}),u=(0,n.memo)(function({value:i,message:a,components:o,id:s,context:c,comment:l}){let u=(0,n.useContext)(e.s);if(!u)throw Error(`[fluenti] <Plural> must be used within an <I18nProvider>`);return(0,r.jsx)(r.Fragment,{children:t.t({id:e.a(s,a,c),message:a,...c===void 0?{}:{context:c},...l===void 0?{}:{comment:l}},{count:i},(e,t)=>u.t(e,t),o)})}),d=(0,n.memo)(function({value:i,message:a,valueMap:o,components:s,id:c,context:l,comment:u,tag:d}){let f=(0,n.useContext)(e.s);if(!f)throw Error(`[fluenti] <Select> must be used within an <I18nProvider>`);let p=t.t({id:e.a(c,a,l),message:a,...l===void 0?{}:{context:l},...u===void 0?{}:{comment:u}},{value:o?.[i]??`other`},(e,t)=>f.t(e,t),s);return d?(0,n.createElement)(d,null,p):(0,r.jsx)(r.Fragment,{children:p})});exports.DateTime=e.n,exports.NumberFormat=e.t,exports.Plural=e.i,exports.Select=e.r,exports.Trans=e.o,exports.__FluentiCompiledPlural=c,exports.__FluentiCompiledRichPlural=u,exports.__FluentiCompiledRichSelect=d,exports.__FluentiCompiledRichTrans=s,exports.__FluentiCompiledSelect=l,exports.__FluentiCompiledTrans=o;
2
- //# sourceMappingURL=components-entry.cjs.map
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Number-JCugssFE.cjs`),t=require(`./icu-rich-BlDjwT5Z.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`),i=require(`@fluenti/core/runtime`);function a(e,t,i){return i?i(e):t?(0,n.createElement)(t,null,e):(0,r.jsx)(r.Fragment,{children:e})}var o=(0,n.memo)(function({message:t,id:r,context:o,comment:s,tag:c,render:l}){let u=(0,n.useContext)(e.s);if(!u)throw Error(`[fluenti] <Trans> must be used within an <I18nProvider>`);return a(u.t({id:r??(0,i.hashMessage)(t,o),message:t,...o===void 0?{}:{context:o},...s===void 0?{}:{comment:s}}),c,l)}),s=(0,n.memo)(function({message:r,components:o,id:s,context:c,comment:l,tag:u,render:d}){let f=(0,n.useContext)(e.s);if(!f)throw Error(`[fluenti] <Trans> must be used within an <I18nProvider>`);return a(t.t({id:s??(0,i.hashMessage)(r,c),message:r,...c===void 0?{}:{context:c},...l===void 0?{}:{comment:l}},void 0,(e,t)=>f.t(e,t),o),u,d)}),c=(0,n.memo)(function({value:t,message:i,id:a,context:o,comment:s}){let c=(0,n.useContext)(e.s);if(!c)throw Error(`[fluenti] <Plural> must be used within an <I18nProvider>`);return(0,r.jsx)(r.Fragment,{children:c.t({id:e.a(a,i,o),message:i,...o===void 0?{}:{context:o},...s===void 0?{}:{comment:s}},{count:t})})}),l=(0,n.memo)(function({value:t,message:i,valueMap:a,id:o,context:s,comment:c,tag:l}){let u=(0,n.useContext)(e.s);if(!u)throw Error(`[fluenti] <Select> must be used within an <I18nProvider>`);let d=u.t({id:e.a(o,i,s),message:i,...s===void 0?{}:{context:s},...c===void 0?{}:{comment:c}},{value:a?.[t]??`other`});return l?(0,n.createElement)(l,null,d):(0,r.jsx)(r.Fragment,{children:d})}),u=(0,n.memo)(function({value:i,message:a,components:o,id:s,context:c,comment:l}){let u=(0,n.useContext)(e.s);if(!u)throw Error(`[fluenti] <Plural> must be used within an <I18nProvider>`);return(0,r.jsx)(r.Fragment,{children:t.t({id:e.a(s,a,c),message:a,...c===void 0?{}:{context:c},...l===void 0?{}:{comment:l}},{count:i},(e,t)=>u.t(e,t),o)})}),d=(0,n.memo)(function({value:i,message:a,valueMap:o,components:s,id:c,context:l,comment:u,tag:d}){let f=(0,n.useContext)(e.s);if(!f)throw Error(`[fluenti] <Select> must be used within an <I18nProvider>`);let p=t.t({id:e.a(c,a,l),message:a,...l===void 0?{}:{context:l},...u===void 0?{}:{comment:u}},{value:o?.[i]??`other`},(e,t)=>f.t(e,t),s);return d?(0,n.createElement)(d,null,p):(0,r.jsx)(r.Fragment,{children:p})});exports.DateTime=e.n,exports.NumberFormat=e.t,exports.Plural=e.i,exports.Select=e.r,exports.Trans=e.o,exports.__FluentiCompiledPlural=c,exports.__FluentiCompiledRichPlural=u,exports.__FluentiCompiledRichSelect=d,exports.__FluentiCompiledRichTrans=s,exports.__FluentiCompiledSelect=l,exports.__FluentiCompiledTrans=o;
@@ -66,5 +66,3 @@ var h = /* @__PURE__ */ u(function({ message: e, id: t, context: n, comment: r,
66
66
  });
67
67
  //#endregion
68
68
  export { n as DateTime, o as NumberFormat, t as Plural, i as Select, r as Trans, _ as __FluentiCompiledPlural, y as __FluentiCompiledRichPlural, b as __FluentiCompiledRichSelect, g as __FluentiCompiledRichTrans, v as __FluentiCompiledSelect, h as __FluentiCompiledTrans };
69
-
70
- //# sourceMappingURL=components-entry.js.map
@@ -1,2 +1 @@
1
- let e=require(`react`),t=require(`@fluenti/core/runtime`);function n(r){let i=[],a=``;return e.Children.forEach(r,r=>{if(typeof r==`string`||typeof r==`number`)a+=String(r);else if((0,e.isValidElement)(r)){if(r.type===e.Fragment){let e=n(r.props.children);a+=(0,t.offsetIndices)(e.message,i.length),i.push(...e.components);return}let o=i.length,s=n(r.props.children);i.push(r),i.push(...s.components),s.message===``&&s.components.length===0?a+=`<${o}/>`:a+=`<${o}>${(0,t.offsetIndices)(s.message,o+1)}</${o}>`}}),{message:a,components:i}}function r(t,n){let i=/<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g;if(!t.includes(`<`))return t;let a=[],o=0,s=0,c;if(i.lastIndex=0,c=i.exec(t),c===null)return t;for(;c!==null;){c.index>o&&a.push(t.slice(o,c.index));let l=Number(c[1]),u=c[2]===void 0,d=c[3]??``;if(!Number.isInteger(l)||l<0||l>=n.length){d&&a.push(d),o=i.lastIndex,c=i.exec(t);continue}let f=n[l];if(f){let t=`trans-${s++}`;if(u)a.push((0,e.cloneElement)(f,{key:t}));else{let i=r(d,n);a.push((0,e.cloneElement)(f,{key:t},i))}}else d&&a.push(d);o=i.lastIndex,c=i.exec(t)}return o<t.length&&a.push(t.slice(o)),a.length===1?a[0]:(0,e.createElement)(e.Fragment,null,...a)}function i(e){let t=n(e);return{message:t.message,components:t.components}}function a(e,n){let r=[],a={};for(let o of e){let e=n[o];if(e===void 0)continue;let s=i(e);a[o]=(0,t.offsetIndices)(s.message,r.length),r.push(...s.components)}for(let[o,s]of Object.entries(n)){if(e.includes(o)||s===void 0)continue;let n=i(s);a[o]=(0,t.offsetIndices)(n.message,r.length),r.push(...n.components)}return{messages:a,components:r}}function o(e,t,n,i){let a=n(e,t);return i.length>0?r(a,i):a}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
2
- //# sourceMappingURL=icu-rich-BlDjwT5Z.cjs.map
1
+ let e=require(`react`),t=require(`@fluenti/core/runtime`);function n(r){let i=[],a=``;return e.Children.forEach(r,r=>{if(typeof r==`string`||typeof r==`number`)a+=String(r);else if((0,e.isValidElement)(r)){if(r.type===e.Fragment){let e=n(r.props.children);a+=(0,t.offsetIndices)(e.message,i.length),i.push(...e.components);return}let o=i.length,s=n(r.props.children);i.push(r),i.push(...s.components),s.message===``&&s.components.length===0?a+=`<${o}/>`:a+=`<${o}>${(0,t.offsetIndices)(s.message,o+1)}</${o}>`}}),{message:a,components:i}}function r(t,n){let i=/<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g;if(!t.includes(`<`))return t;let a=[],o=0,s=0,c;if(i.lastIndex=0,c=i.exec(t),c===null)return t;for(;c!==null;){c.index>o&&a.push(t.slice(o,c.index));let l=Number(c[1]),u=c[2]===void 0,d=c[3]??``;if(!Number.isInteger(l)||l<0||l>=n.length){d&&a.push(d),o=i.lastIndex,c=i.exec(t);continue}let f=n[l];if(f){let t=`trans-${s++}`;if(u)a.push((0,e.cloneElement)(f,{key:t}));else{let i=r(d,n);a.push((0,e.cloneElement)(f,{key:t},i))}}else d&&a.push(d);o=i.lastIndex,c=i.exec(t)}return o<t.length&&a.push(t.slice(o)),a.length===1?a[0]:(0,e.createElement)(e.Fragment,null,...a)}function i(e){let t=n(e);return{message:t.message,components:t.components}}function a(e,n){let r=[],a={};for(let o of e){let e=n[o];if(e===void 0)continue;let s=i(e);a[o]=(0,t.offsetIndices)(s.message,r.length),r.push(...s.components)}for(let[o,s]of Object.entries(n)){if(e.includes(o)||s===void 0)continue;let n=i(s);a[o]=(0,t.offsetIndices)(n.message,r.length),r.push(...n.components)}return{messages:a,components:r}}function o(e,t,n,i){let a=n(e,t);return i.length>0?r(a,i):a}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
@@ -77,5 +77,3 @@ function h(e, t, n, r) {
77
77
  }
78
78
  //#endregion
79
79
  export { m as a, c, h as i, f as l, s as n, a as o, l as r, d as s, o as t };
80
-
81
- //# sourceMappingURL=icu-rich-C6B9ns4t.js.map
package/dist/index.cjs CHANGED
@@ -1,3 +1,2 @@
1
1
  "use client";
2
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Number-JCugssFE.cjs`);let t=require(`react`),n=require(`@fluenti/core`),r=require(`react/jsx-runtime`);function i(e){let t={};for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&`default`in r?r.default:r;return t}function a(e){let{locale:r,messages:a,loadMessages:o,fallbackLocale:s,fallbackChain:c,dateFormats:l,numberFormats:u,missing:d,diagnostics:f,interpolate:p}=e,[m,h]=(0,t.useState)(r),[g,_]=(0,t.useState)(!1),[v,y]=(0,t.useState)(a?i(a):{}),[b,x]=(0,t.useState)(a?Object.keys(a):[]),S=(0,t.useRef)(v);S.current=v;let C=(0,t.useRef)(0),w=Symbol.for(`fluenti.runtime.react.v1`);function T(){let e=globalThis[w];return typeof e==`object`&&e?e:null}let E=(0,t.useMemo)(()=>{let e={locale:m,messages:v};return s!==void 0&&(e.fallbackLocale=s),c!==void 0&&(e.fallbackChain=c),l!==void 0&&(e.dateFormats=l),u!==void 0&&(e.numberFormats=u),d!==void 0&&(e.missing=d),f!==void 0&&(e.diagnostics=f),p!==void 0&&(e.interpolate=p),e.devWarnings=e.devWarnings??(typeof process<`u`&&process.env.NODE_ENV===`development`),(0,n.createFluentiCore)(e)},[m,v,s,c,l,u,d,f,p]);(0,t.useEffect)(()=>{r!==m&&D(r)},[r]);let D=(0,t.useCallback)(async e=>{let t=++C.current,n=o?T():null;if(S.current[e]&&!o){h(e);return}if(S.current[e]){try{n?.__switchLocale&&await n.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}h(e);return}if(!o){console.warn(`[fluenti] No messages for locale "${e}" and no loadMessages function provided`);return}_(!0);try{let r=await o(e);if(t!==C.current)return;let i=typeof r==`object`&&r&&`default`in r?r.default:r;try{n?.__switchLocale&&await n.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}if(t!==C.current)return;y(t=>({...t,[e]:i})),x(t=>[...new Set([...t,e])]),h(e)}catch(n){t===C.current&&console.error(`[fluenti] Failed to load locale "${e}"`,n)}finally{t===C.current&&_(!1)}},[o]),O=(0,t.useCallback)(async e=>{if(!(S.current[e]||!o))try{let t=await o(e),n=typeof t==`object`&&t&&`default`in t?t.default:t;y(t=>({...t,[e]:n})),x(t=>[...new Set([...t,e])]);let r=T();r?.__preloadLocale&&await r.__preloadLocale(e)}catch{}},[o]),k=(0,t.useCallback)((e,t)=>{let n=v[t??m];return n!==void 0&&e in n},[v,m]),A=(0,t.useCallback)((e,t)=>{let n=v[t??m];if(n)return n[e]},[v,m]);return(0,t.useMemo)(()=>({t:E.t.bind(E),d:E.d.bind(E),n:E.n.bind(E),locale:m,setLocale:D,isLoading:g,preloadLocale:O,te:k,tm:A,i18n:E,format:E.format.bind(E),loadMessages:E.loadMessages.bind(E),getLocales:E.getLocales.bind(E),loadedLocales:b}),[E,m,D,g,O,k,A,b])}function o(e){globalThis.__fluenti_i18n=e}function s({instance:n,children:i}){let a=(0,t.useMemo)(()=>({t:n.t,d:n.d,n:n.n,format:n.format,loadMessages:n.loadMessages,getLocales:n.getLocales,locale:n.locale,setLocale:n.setLocale,isLoading:n.isLoading,loadedLocales:n.loadedLocales,preloadLocale:n.preloadLocale,te:n.te,tm:n.tm,i18n:n.i18n}),[n]);return(0,r.jsx)(e.s.Provider,{value:a,children:i})}function c(e){return e.instance?(0,r.jsx)(s,{instance:e.instance,children:e.children}):(0,r.jsx)(l,{...e})}function l({locale:e,fallbackLocale:n,messages:i,loadMessages:c,fallbackChain:l,dateFormats:u,numberFormats:d,missing:f,diagnostics:p,interpolate:m,children:h}){let g=a({locale:e??`en`,messages:i,loadMessages:c,fallbackLocale:n,fallbackChain:l,dateFormats:u,numberFormats:d,missing:f,diagnostics:p,interpolate:m});return(0,t.useEffect)(()=>{o(g.i18n)},[g.i18n]),(0,r.jsx)(s,{instance:g,children:h})}function u(){let n=(0,t.useContext)(e.s);if(!n)throw Error(`[fluenti] useI18n() must be used within an <I18nProvider>. Wrap your app with <I18nProvider> to provide i18n context.`);return n}function d(){return u().locale}var f=((...e)=>{throw Error("[fluenti] `t` imported from '@fluenti/react' is a compile-time API. Use it only with the Fluenti build transform inside a component or custom hook. For runtime lookups, use useI18n().t(...).")});exports.DateTime=e.n,exports.I18nContext=e.s,exports.I18nProvider=c,exports.NumberFormat=e.t,exports.Plural=e.i,exports.Select=e.r,exports.Trans=e.o,exports.createFluenti=a,Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return n.msg}}),exports.t=f,exports.useI18n=u,exports.useLocale=d;
3
- //# sourceMappingURL=index.cjs.map
2
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./Number-JCugssFE.cjs`);let t=require(`react`),n=require(`@fluenti/core`),r=require(`react/jsx-runtime`);function i(e){let t={};for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&`default`in r?r.default:r;return t}function a(e){let{locale:r,messages:a,loadMessages:o,fallbackLocale:s,fallbackChain:c,dateFormats:l,numberFormats:u,missing:d,diagnostics:f,interpolate:p}=e,[m,h]=(0,t.useState)(r),[g,_]=(0,t.useState)(!1),[v,y]=(0,t.useState)(a?i(a):{}),[b,x]=(0,t.useState)(a?Object.keys(a):[]),S=(0,t.useRef)(v);S.current=v;let C=(0,t.useRef)(0),w=Symbol.for(`fluenti.runtime.react.v1`);function T(){let e=globalThis[w];return typeof e==`object`&&e?e:null}let E=(0,t.useMemo)(()=>{let e={locale:m,messages:v};return s!==void 0&&(e.fallbackLocale=s),c!==void 0&&(e.fallbackChain=c),l!==void 0&&(e.dateFormats=l),u!==void 0&&(e.numberFormats=u),d!==void 0&&(e.missing=d),f!==void 0&&(e.diagnostics=f),p!==void 0&&(e.interpolate=p),e.devWarnings=e.devWarnings??(typeof process<`u`&&process.env.NODE_ENV===`development`),(0,n.createFluentiCore)(e)},[m,v,s,c,l,u,d,f,p]);(0,t.useEffect)(()=>{r!==m&&D(r)},[r]);let D=(0,t.useCallback)(async e=>{let t=++C.current,n=o?T():null;if(S.current[e]&&!o){h(e);return}if(S.current[e]){try{n?.__switchLocale&&await n.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}h(e);return}if(!o){console.warn(`[fluenti] No messages for locale "${e}" and no loadMessages function provided`);return}_(!0);try{let r=await o(e);if(t!==C.current)return;let i=typeof r==`object`&&r&&`default`in r?r.default:r;try{n?.__switchLocale&&await n.__switchLocale(e)}catch(t){console.warn(`[fluenti] split runtime switch failed for locale "${e}"`,t)}if(t!==C.current)return;y(t=>({...t,[e]:i})),x(t=>[...new Set([...t,e])]),h(e)}catch(n){t===C.current&&console.error(`[fluenti] Failed to load locale "${e}"`,n)}finally{t===C.current&&_(!1)}},[o]),O=(0,t.useCallback)(async e=>{if(!(S.current[e]||!o))try{let t=await o(e),n=typeof t==`object`&&t&&`default`in t?t.default:t;y(t=>({...t,[e]:n})),x(t=>[...new Set([...t,e])]);let r=T();r?.__preloadLocale&&await r.__preloadLocale(e)}catch{}},[o]),k=(0,t.useCallback)((e,t)=>{let n=v[t??m];return n!==void 0&&e in n},[v,m]),A=(0,t.useCallback)((e,t)=>{let n=v[t??m];if(n)return n[e]},[v,m]);return(0,t.useMemo)(()=>({t:E.t.bind(E),d:E.d.bind(E),n:E.n.bind(E),locale:m,setLocale:D,isLoading:g,preloadLocale:O,te:k,tm:A,i18n:E,format:E.format.bind(E),loadMessages:E.loadMessages.bind(E),getLocales:E.getLocales.bind(E),loadedLocales:b}),[E,m,D,g,O,k,A,b])}function o(e){globalThis.__fluenti_i18n=e}function s({instance:n,children:i}){let a=(0,t.useMemo)(()=>({t:n.t,d:n.d,n:n.n,format:n.format,loadMessages:n.loadMessages,getLocales:n.getLocales,locale:n.locale,setLocale:n.setLocale,isLoading:n.isLoading,loadedLocales:n.loadedLocales,preloadLocale:n.preloadLocale,te:n.te,tm:n.tm,i18n:n.i18n}),[n]);return(0,r.jsx)(e.s.Provider,{value:a,children:i})}function c(e){return e.instance?(0,r.jsx)(s,{instance:e.instance,children:e.children}):(0,r.jsx)(l,{...e})}function l({locale:e,fallbackLocale:n,messages:i,loadMessages:c,fallbackChain:l,dateFormats:u,numberFormats:d,missing:f,diagnostics:p,interpolate:m,children:h}){let g=a({locale:e??`en`,messages:i,loadMessages:c,fallbackLocale:n,fallbackChain:l,dateFormats:u,numberFormats:d,missing:f,diagnostics:p,interpolate:m});return(0,t.useEffect)(()=>{o(g.i18n)},[g.i18n]),(0,r.jsx)(s,{instance:g,children:h})}function u(){let n=(0,t.useContext)(e.s);if(!n)throw Error(`[fluenti] useI18n() must be used within an <I18nProvider>. Wrap your app with <I18nProvider> to provide i18n context.`);return n}function d(){return u().locale}var f=((...e)=>{throw Error("[fluenti] `t` imported from '@fluenti/react' is a compile-time API. Use it only with the Fluenti build transform inside a component or custom hook. For runtime lookups, use useI18n().t(...).")});exports.DateTime=e.n,exports.I18nContext=e.s,exports.I18nProvider=c,exports.NumberFormat=e.t,exports.Plural=e.i,exports.Select=e.r,exports.Trans=e.o,exports.createFluenti=a,Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return n.msg}}),exports.t=f,exports.useI18n=u,exports.useLocale=d;
package/dist/index.js CHANGED
@@ -192,5 +192,3 @@ var C = ((...e) => {
192
192
  });
193
193
  //#endregion
194
194
  export { t as DateTime, i as I18nContext, y as I18nProvider, a as NumberFormat, e as Plural, r as Select, n as Trans, g as createFluenti, p as msg, C as t, x as useI18n, S as useLocale };
195
-
196
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  import { CompileTimeT } from '@fluenti/core';
2
2
  export declare const t: CompileTimeT;
3
- //# sourceMappingURL=compile-time-t.d.ts.map
@@ -13,4 +13,3 @@ export interface FluentiDateTimeProps {
13
13
  * ```
14
14
  */
15
15
  export declare const DateTime: import('react').NamedExoticComponent<FluentiDateTimeProps>;
16
- //# sourceMappingURL=DateTime.d.ts.map
@@ -15,4 +15,3 @@ export type FluentiNumberFormatProps = NumberFormatProps;
15
15
  * ```
16
16
  */
17
17
  export declare const NumberFormat: import('react').NamedExoticComponent<NumberFormatProps>;
18
- //# sourceMappingURL=Number.d.ts.map
@@ -32,4 +32,3 @@ export interface FluentiPluralProps {
32
32
  * ```
33
33
  */
34
34
  export declare const Plural: import('react').NamedExoticComponent<FluentiPluralProps>;
35
- //# sourceMappingURL=Plural.d.ts.map
@@ -31,4 +31,3 @@ export interface FluentiSelectProps {
31
31
  * ```
32
32
  */
33
33
  export declare const Select: import('react').NamedExoticComponent<FluentiSelectProps>;
34
- //# sourceMappingURL=Select.d.ts.map
@@ -28,4 +28,3 @@ export interface FluentiTransProps {
28
28
  * ```
29
29
  */
30
30
  export declare const Trans: import('react').NamedExoticComponent<FluentiTransProps>;
31
- //# sourceMappingURL=Trans.d.ts.map
@@ -43,4 +43,3 @@ export declare const __FluentiCompiledSelect: import('react').NamedExoticCompone
43
43
  export declare const __FluentiCompiledRichPlural: import('react').NamedExoticComponent<FluentiCompiledRichPluralProps>;
44
44
  /** @internal Build-plugin fast path for rich-text `<Select>` usage. */
45
45
  export declare const __FluentiCompiledRichSelect: import('react').NamedExoticComponent<FluentiCompiledRichSelectProps>;
46
- //# sourceMappingURL=compiled.d.ts.map
@@ -12,4 +12,3 @@ export declare function serializeRichForms<T extends string>(keys: readonly T[],
12
12
  components: ReactElement[];
13
13
  };
14
14
  export declare function renderRichTranslation(descriptor: MessageDescriptor, values: Record<string, unknown> | undefined, translate: (descriptor: MessageDescriptor, values?: Record<string, unknown>) => string, components: ReactElement[]): ReactNode;
15
- //# sourceMappingURL=icu-rich.d.ts.map
@@ -6,4 +6,3 @@ export declare function buildPlainSelectMessage(forms: Record<string, ReactNode
6
6
  message: string;
7
7
  valueMap: Record<string, string>;
8
8
  } | undefined;
9
- //# sourceMappingURL=plain.d.ts.map
@@ -12,4 +12,3 @@ export declare function resolveCategory(value: number, locale: string, available
12
12
  * @internal
13
13
  */
14
14
  export declare function replaceHash(node: ReactNode, formatted: string): ReactNode;
15
- //# sourceMappingURL=plural-core.d.ts.map
@@ -24,4 +24,3 @@ export declare function extractMessage(children: ReactNode): {
24
24
  * @internal
25
25
  */
26
26
  export declare function reconstruct(translated: string, components: ReactElement[]): ReactNode;
27
- //# sourceMappingURL=trans-core.d.ts.map
@@ -9,4 +9,3 @@ export type { FluentiDateTimeProps } from './components/DateTime';
9
9
  export { NumberFormat } from './components/Number';
10
10
  export type { NumberFormatProps, FluentiNumberFormatProps } from './components/Number';
11
11
  export { __FluentiCompiledTrans, __FluentiCompiledRichTrans, __FluentiCompiledPlural, __FluentiCompiledSelect, __FluentiCompiledRichPlural, __FluentiCompiledRichSelect, } from './components/compiled';
12
- //# sourceMappingURL=components-entry.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import { FluentiContext } from './types';
2
2
  export declare const I18nContext: import('react').Context<FluentiContext | null>;
3
- //# sourceMappingURL=context.d.ts.map
@@ -88,4 +88,3 @@ export interface FluentiInstance {
88
88
  * ```
89
89
  */
90
90
  export declare function createFluenti(config: FluentiConfig): FluentiInstance;
91
- //# sourceMappingURL=create-fluenti.d.ts.map
@@ -15,4 +15,3 @@ export declare function getGlobalI18n(): FluentiCoreInstanceFull | undefined;
15
15
  export declare function setGlobalI18n(instance: FluentiCoreInstanceFull): void;
16
16
  /** Clear the global i18n instance. Primarily for testing. */
17
17
  export declare function clearGlobalI18n(): void;
18
- //# sourceMappingURL=global-registry.d.ts.map
@@ -9,4 +9,3 @@ import { FluentiCoreInstanceFull } from '@fluenti/core';
9
9
  * @internal
10
10
  */
11
11
  export declare function __useI18n(): FluentiCoreInstanceFull;
12
- //# sourceMappingURL=__useI18n.d.ts.map
@@ -17,4 +17,3 @@ export declare function useI18n(): FluentiContext;
17
17
  * ```
18
18
  */
19
19
  export declare function useLocale(): string;
20
- //# sourceMappingURL=useI18n.d.ts.map
@@ -16,4 +16,3 @@ export { NumberFormat } from './components/Number';
16
16
  export type { NumberFormatProps, FluentiNumberFormatProps } from './components/Number';
17
17
  export { msg } from './msg';
18
18
  export type { FluentiContext, I18nProviderProps, Messages, AllMessages, MessageDescriptor, CompileTimeMessageDescriptor, CompileTimeT, Locale, DateFormatOptions, NumberFormatOptions, } from './types';
19
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1 @@
1
1
  export { msg } from '@fluenti/core';
2
- //# sourceMappingURL=msg.d.ts.map
@@ -41,4 +41,3 @@ import { FluentiProviderProps } from './types';
41
41
  * ```
42
42
  */
43
43
  export declare function I18nProvider(props: FluentiProviderProps): import("react/jsx-runtime").JSX.Element;
44
- //# sourceMappingURL=provider.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import { RuntimeGenerator } from '@fluenti/vite-plugin';
2
2
  export declare const reactRuntimeGenerator: RuntimeGenerator;
3
- //# sourceMappingURL=react-runtime.d.ts.map
@@ -262,4 +262,3 @@ export interface ServerI18n {
262
262
  * ```
263
263
  */
264
264
  export declare function createServerI18n(config: ServerI18nConfig): ServerI18n;
265
- //# sourceMappingURL=server.d.ts.map
@@ -64,4 +64,3 @@ export interface I18nProviderProps {
64
64
  }
65
65
  export type FluentiProviderProps = I18nProviderProps;
66
66
  export type { Locale, LocalizedString, Messages, AllMessages, MessageDescriptor, CompileTimeMessageDescriptor, CompileTimeT, DateFormatOptions, NumberFormatOptions, };
67
- //# sourceMappingURL=types.d.ts.map
@@ -22,4 +22,3 @@ export type { FluentiPluginOptions as FluentiReactOptions } from '@fluenti/vite-
22
22
  * ```
23
23
  */
24
24
  export default function fluentiReact(options?: FluentiPluginOptions): Plugin[];
25
- //# sourceMappingURL=vite-plugin.d.ts.map
package/dist/server.cjs CHANGED
@@ -1,2 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./icu-rich-BlDjwT5Z.cjs`);let t=require(`react`),n=require(`@fluenti/core`),r=require(`@fluenti/core/runtime`),i=require(`@fluenti/core/ssr`);function a(i){let a=(0,t.cache)(()=>({locale:null,instance:null})),o=(0,t.cache)(()=>new Map),s=null,c=0,l=0;function u(e){a().locale=e,c++,s=null}async function d(e){let t=o(),n=t.get(e);if(n)return n;let r=await i.loadMessages(e),a=typeof r==`object`&&r&&`default`in r?r.default:r;return t.set(e,a),a}async function f(){let e=a();!e.locale&&i.resolveLocale&&(e.locale=await i.resolveLocale());let t=e.locale;if(!t)throw Error(`[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), or provide a resolveLocale function in createServerI18n config to auto-detect locale in Server Actions and other contexts where the layout does not run.`);if(e.instance&&e.instance.locale===t)return e.instance;let r={};r[t]=await d(t),i.fallbackLocale&&i.fallbackLocale!==t&&(r[i.fallbackLocale]=await d(i.fallbackLocale));let o={locale:t,messages:r};return i.fallbackLocale!==void 0&&(o.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(o.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(o.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(o.numberFormats=i.numberFormats),i.missing!==void 0&&(o.missing=i.missing),i.interpolate!==void 0&&(o.interpolate=i.interpolate),e.instance=(0,n.createFluentiCore)(o),s=e.instance,l=c,e.instance}async function p({children:n,id:i,context:a,comment:o,render:s}){let c=await f(),{message:l,components:u}=e.r(n),d=i??(0,r.hashMessage)(l,a),p=e.i(c.t({id:d,message:l,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}}),u);return(0,t.createElement)(t.Fragment,null,s?s(p):p)}async function m({value:n,id:i,context:a,comment:o,zero:s,one:c,two:l,few:u,many:d,other:p,offset:m}){let h=await f(),{messages:g,components:_}=e.n(r.PLURAL_CATEGORIES,{zero:s,one:c,two:l,few:u,many:d,other:p}),v=(0,r.buildICUPluralMessage)({...g.zero!==void 0&&{zero:g.zero},...g.one!==void 0&&{one:g.one},...g.two!==void 0&&{two:g.two},...g.few!==void 0&&{few:g.few},...g.many!==void 0&&{many:g.many},other:g.other??``},m);return(0,t.createElement)(t.Fragment,null,e.t({id:i??(a===void 0?v:(0,r.hashMessage)(v,a)),message:v,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}},{count:n},(e,t)=>h.t(e,t),_))}async function h({value:n,id:i,context:a,comment:o,other:s,options:c,...l}){let u=await f(),d=c===void 0?{...Object.fromEntries(Object.entries(l).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`].includes(e))),other:s}:{...c,other:s},p=[...Object.keys(d).filter(e=>e!==`other`),`other`],{messages:m,components:h}=e.n(p,d),g=(0,r.normalizeSelectForms)(Object.fromEntries([...p].map(e=>[e,m[e]??``]))),_=(0,r.buildICUSelectMessage)(g.forms);return(0,t.createElement)(t.Fragment,null,e.t({id:i??(a===void 0?_:(0,r.hashMessage)(_,a)),message:_,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}},{value:g.valueMap[n]??`other`},(e,t)=>u.t(e,t),h))}async function g({value:e,format:n}){return(0,t.createElement)(t.Fragment,null,(await f()).d(e,n))}async function _({value:e,format:n}){return(0,t.createElement)(t.Fragment,null,(await f()).n(e,n))}function v(){let e=a();if(e.instance)return e.instance;if(s&&l===c)return s;let t=e.locale??i.fallbackLocale??`en`,r=o(),u={},d=r.get(t);if(d&&(u[t]=d),i.fallbackLocale&&i.fallbackLocale!==t){let e=r.get(i.fallbackLocale);e&&(u[i.fallbackLocale]=e)}let f={locale:t,messages:u};return i.fallbackLocale!==void 0&&(f.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(f.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(f.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(f.numberFormats=i.numberFormats),i.missing!==void 0&&(f.missing=i.missing),i.interpolate!==void 0&&(f.interpolate=i.interpolate),e.instance=(0,n.createFluentiCore)(f),e.instance}async function y(e,t){let n=await f();return(await d(t??n.locale))[e]!==void 0}async function b(e,t){let n=await f();return(await d(t??n.locale))[e]}return{setLocale:u,getI18n:f,__getSyncInstance:v,te:y,tm:b,Trans:p,Plural:m,Select:h,DateTime:g,NumberFormat:_}}exports.createServerI18n=a,Object.defineProperty(exports,`detectLocale`,{enumerable:!0,get:function(){return i.detectLocale}}),Object.defineProperty(exports,`getDirection`,{enumerable:!0,get:function(){return n.getDirection}}),Object.defineProperty(exports,`getHydratedLocale`,{enumerable:!0,get:function(){return i.getHydratedLocale}}),Object.defineProperty(exports,`getSSRLocaleScript`,{enumerable:!0,get:function(){return i.getSSRLocaleScript}}),Object.defineProperty(exports,`isRTL`,{enumerable:!0,get:function(){return n.isRTL}});
2
- //# sourceMappingURL=server.cjs.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./icu-rich-BlDjwT5Z.cjs`);let t=require(`react`),n=require(`@fluenti/core`),r=require(`@fluenti/core/runtime`),i=require(`@fluenti/core/ssr`);function a(i){let a=(0,t.cache)(()=>({locale:null,instance:null})),o=(0,t.cache)(()=>new Map),s=null,c=0,l=0;function u(e){a().locale=e,c++,s=null}async function d(e){let t=o(),n=t.get(e);if(n)return n;let r=await i.loadMessages(e),a=typeof r==`object`&&r&&`default`in r?r.default:r;return t.set(e,a),a}async function f(){let e=a();!e.locale&&i.resolveLocale&&(e.locale=await i.resolveLocale());let t=e.locale;if(!t)throw Error(`[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), or provide a resolveLocale function in createServerI18n config to auto-detect locale in Server Actions and other contexts where the layout does not run.`);if(e.instance&&e.instance.locale===t)return e.instance;let r={};r[t]=await d(t),i.fallbackLocale&&i.fallbackLocale!==t&&(r[i.fallbackLocale]=await d(i.fallbackLocale));let o={locale:t,messages:r};return i.fallbackLocale!==void 0&&(o.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(o.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(o.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(o.numberFormats=i.numberFormats),i.missing!==void 0&&(o.missing=i.missing),i.interpolate!==void 0&&(o.interpolate=i.interpolate),e.instance=(0,n.createFluentiCore)(o),s=e.instance,l=c,e.instance}async function p({children:n,id:i,context:a,comment:o,render:s}){let c=await f(),{message:l,components:u}=e.r(n),d=i??(0,r.hashMessage)(l,a),p=e.i(c.t({id:d,message:l,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}}),u);return(0,t.createElement)(t.Fragment,null,s?s(p):p)}async function m({value:n,id:i,context:a,comment:o,zero:s,one:c,two:l,few:u,many:d,other:p,offset:m}){let h=await f(),{messages:g,components:_}=e.n(r.PLURAL_CATEGORIES,{zero:s,one:c,two:l,few:u,many:d,other:p}),v=(0,r.buildICUPluralMessage)({...g.zero!==void 0&&{zero:g.zero},...g.one!==void 0&&{one:g.one},...g.two!==void 0&&{two:g.two},...g.few!==void 0&&{few:g.few},...g.many!==void 0&&{many:g.many},other:g.other??``},m);return(0,t.createElement)(t.Fragment,null,e.t({id:i??(a===void 0?v:(0,r.hashMessage)(v,a)),message:v,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}},{count:n},(e,t)=>h.t(e,t),_))}async function h({value:n,id:i,context:a,comment:o,other:s,options:c,...l}){let u=await f(),d=c===void 0?{...Object.fromEntries(Object.entries(l).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`].includes(e))),other:s}:{...c,other:s},p=[...Object.keys(d).filter(e=>e!==`other`),`other`],{messages:m,components:h}=e.n(p,d),g=(0,r.normalizeSelectForms)(Object.fromEntries([...p].map(e=>[e,m[e]??``]))),_=(0,r.buildICUSelectMessage)(g.forms);return(0,t.createElement)(t.Fragment,null,e.t({id:i??(a===void 0?_:(0,r.hashMessage)(_,a)),message:_,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}},{value:g.valueMap[n]??`other`},(e,t)=>u.t(e,t),h))}async function g({value:e,format:n}){return(0,t.createElement)(t.Fragment,null,(await f()).d(e,n))}async function _({value:e,format:n}){return(0,t.createElement)(t.Fragment,null,(await f()).n(e,n))}function v(){let e=a();if(e.instance)return e.instance;if(s&&l===c)return s;let t=e.locale??i.fallbackLocale??`en`,r=o(),u={},d=r.get(t);if(d&&(u[t]=d),i.fallbackLocale&&i.fallbackLocale!==t){let e=r.get(i.fallbackLocale);e&&(u[i.fallbackLocale]=e)}let f={locale:t,messages:u};return i.fallbackLocale!==void 0&&(f.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(f.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(f.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(f.numberFormats=i.numberFormats),i.missing!==void 0&&(f.missing=i.missing),i.interpolate!==void 0&&(f.interpolate=i.interpolate),e.instance=(0,n.createFluentiCore)(f),e.instance}async function y(e,t){let n=await f();return(await d(t??n.locale))[e]!==void 0}async function b(e,t){let n=await f();return(await d(t??n.locale))[e]}return{setLocale:u,getI18n:f,__getSyncInstance:v,te:y,tm:b,Trans:p,Plural:m,Select:h,DateTime:g,NumberFormat:_}}exports.createServerI18n=a,Object.defineProperty(exports,`detectLocale`,{enumerable:!0,get:function(){return i.detectLocale}}),Object.defineProperty(exports,`getDirection`,{enumerable:!0,get:function(){return n.getDirection}}),Object.defineProperty(exports,`getHydratedLocale`,{enumerable:!0,get:function(){return i.getHydratedLocale}}),Object.defineProperty(exports,`getSSRLocaleScript`,{enumerable:!0,get:function(){return i.getSSRLocaleScript}}),Object.defineProperty(exports,`isRTL`,{enumerable:!0,get:function(){return n.isRTL}});
package/dist/server.js CHANGED
@@ -130,5 +130,3 @@ function y(p) {
130
130
  }
131
131
  //#endregion
132
132
  export { y as createServerI18n, g as detectLocale, p as getDirection, _ as getHydratedLocale, v as getSSRLocaleScript, m as isRTL };
133
-
134
- //# sourceMappingURL=server.js.map
@@ -1,2 +1 @@
1
- let e=require(`@fluenti/vite-plugin`);var t=(0,e.createRuntimeGenerator)({imports:``,catalogInit:`const __catalog = { ...__defaultMsgs }`,localeInit:e=>`let __currentLocale = ${JSON.stringify(e)}`,loadingInit:`let __loading = false`,catalogUpdate:e=>`Object.assign(__catalog, ${e})`,localeUpdate:e=>`__currentLocale = ${e}`,loadingUpdate:e=>`__loading = ${e}`,localeRead:`__currentLocale`,runtimeKey:`fluenti.runtime.react.v1`});function n(n){return(0,e.createFluentiPlugins)({...n?.config===void 0?{}:{config:n.config},framework:`react`},[],t)}module.exports=n;
2
- //# sourceMappingURL=vite-plugin.cjs.map
1
+ let e=require(`@fluenti/vite-plugin`);var t=(0,e.createRuntimeGenerator)({imports:``,catalogInit:`const __catalog = { ...__defaultMsgs }`,localeInit:e=>`let __currentLocale = ${JSON.stringify(e)}`,loadingInit:`let __loading = false`,catalogUpdate:e=>`Object.assign(__catalog, ${e})`,localeUpdate:e=>`__currentLocale = ${e}`,loadingUpdate:e=>`__loading = ${e}`,localeRead:`__currentLocale`,runtimeKey:`fluenti.runtime.react.v1`});function n(n){return(0,e.createFluentiPlugins)({...n?.config===void 0?{}:{config:n.config},framework:`react`},[],t)}module.exports=n;
@@ -21,5 +21,3 @@ function r(t) {
21
21
  }
22
22
  //#endregion
23
23
  export { r as default };
24
-
25
- //# sourceMappingURL=vite-plugin.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluenti/react",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "React bindings for Fluenti — I18nProvider, useI18n, Trans/Plural/Select components",
6
6
  "homepage": "https://fluenti.dev",
@@ -89,8 +89,8 @@
89
89
  }
90
90
  },
91
91
  "dependencies": {
92
- "@fluenti/core": "0.6.1",
93
- "@fluenti/vite-plugin": "0.6.1"
92
+ "@fluenti/vite-plugin": "0.6.2",
93
+ "@fluenti/core": "0.6.2"
94
94
  },
95
95
  "devDependencies": {
96
96
  "typescript": "^5.9",
@@ -1 +0,0 @@
1
- {"version":3,"file":"Number-DfzWPfIE.js","names":[],"sources":["../src/context.ts","../src/components/Trans.tsx","../src/components/plain.ts","../src/components/Plural.tsx","../src/components/Select.tsx","../src/components/DateTime.tsx","../src/components/Number.tsx"],"sourcesContent":["import { createContext } from 'react'\nimport type { FluentiContext } from './types'\n\nexport const I18nContext = /* @__PURE__ */ createContext<FluentiContext | null>(null)\n","import {\n createElement,\n memo,\n useContext,\n useMemo,\n type ReactElement,\n type ReactNode,\n} from 'react'\nimport { I18nContext } from '../context'\nimport { hashMessage, extractMessage, reconstruct } from './trans-core'\n\nexport interface FluentiTransProps {\n /** Source text with embedded components */\n children?: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Wrapper element tag name (e.g. 'span', 'div'). Defaults to Fragment (no wrapper). */\n tag?: keyof React.JSX.IntrinsicElements\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n /** @internal Pre-computed message ID from build plugin */\n __id?: string\n /** @internal Pre-computed ICU message from build plugin */\n __message?: string\n /** @internal Pre-computed component list from build plugin */\n __components?: ReactElement[]\n}\n\n/**\n * `<Trans>` component for rich-text translations containing nested React elements.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a> for more info.</Trans>\n * ```\n */\nexport const Trans = /* @__PURE__ */ memo(function Trans({\n children,\n id,\n context,\n comment,\n tag,\n render,\n __id,\n __message,\n __components,\n}: FluentiTransProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Trans> must be used within an <I18nProvider>')\n }\n\n // Fast path: build plugin pre-computed message and components\n const hasPrecomputed = __message !== undefined\n if (hasPrecomputed) {\n const message = __message!\n const components = __components ?? []\n const messageId = id ?? __id ?? hashMessage(message, context)\n const translated = ctx.t(\n {\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (render) return render(result)\n return tag ? createElement(tag, null, result) : <>{result}</>\n }\n\n const { message, components } = useMemo(\n () => extractMessage(children),\n [children],\n )\n const messageId = useMemo(\n () => id ?? __id ?? hashMessage(message, context),\n [id, __id, message, context],\n )\n\n const translated = ctx.t(\n {\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (render) return render(result)\n return tag ? createElement(tag, null, result) : <>{result}</>\n})\n","import {\n PLURAL_CATEGORIES,\n buildICUPluralMessage,\n buildICUSelectMessage,\n hashMessage,\n normalizeSelectForms,\n type PluralCategory,\n} from '@fluenti/core/runtime'\nimport type { ReactNode } from 'react'\n\nexport function resolveCompiledMessageId(\n id: string | undefined,\n message: string,\n context: string | undefined,\n): string {\n return id ?? (context === undefined ? message : hashMessage(message, context))\n}\n\nfunction isPlainReactNode(value: ReactNode | undefined): value is string | number {\n return typeof value === 'string' || typeof value === 'number'\n}\n\nexport function buildPlainPluralMessage(\n forms: Record<PluralCategory, ReactNode | undefined>,\n offset?: number,\n): string | undefined {\n const plainForms: Partial<Record<PluralCategory, string>> = {}\n\n for (const category of PLURAL_CATEGORIES) {\n const value = forms[category]\n if (value === undefined) continue\n if (!isPlainReactNode(value)) return undefined\n plainForms[category] = String(value)\n }\n\n if (plainForms['other'] === undefined) return undefined\n return buildICUPluralMessage(plainForms as Partial<Record<PluralCategory, string>> & { other: string }, offset)\n}\n\nexport function buildPlainSelectMessage(\n forms: Record<string, ReactNode | undefined>,\n): { message: string; valueMap: Record<string, string> } | undefined {\n const plainForms: Record<string, string> = {}\n\n for (const [key, value] of Object.entries(forms)) {\n if (value === undefined) continue\n if (!isPlainReactNode(value)) return undefined\n plainForms[key] = String(value)\n }\n\n if (plainForms['other'] === undefined) return undefined\n\n const normalized = normalizeSelectForms(plainForms)\n return {\n message: buildICUSelectMessage(normalized.forms),\n valueMap: normalized.valueMap,\n }\n}\n","import { memo, useContext, type ReactNode } from 'react'\nimport { I18nContext } from '../context'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './plural-core'\nimport { buildICUPluralMessage, renderRichTranslation, serializeRichForms } from './icu-rich'\nimport { buildPlainPluralMessage, resolveCompiledMessageId } from './plain'\n\nexport interface FluentiPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\n/**\n * `<Plural>` — ICU plural handling as a component.\n *\n * @example\n * ```tsx\n * <Plural value={count} zero=\"No messages\" one=\"# message\" other=\"# messages\" />\n * ```\n */\nexport const Plural = /* @__PURE__ */ memo(function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n}: FluentiPluralProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Plural> must be used within an <I18nProvider>')\n }\n\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const plainMessage = buildPlainPluralMessage(forms, offset)\n if (plainMessage !== undefined) {\n return <>{ctx.t(\n {\n id: resolveCompiledMessageId(id, plainMessage, context),\n message: plainMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n )}</>\n }\n\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const descriptor = {\n id: resolveCompiledMessageId(id, icuMessage, context),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n\n return <>{renderRichTranslation(descriptor, { count: value }, (desc, values) => ctx.t(desc, values), components)}</>\n})\n","import { createElement, memo, useContext, type ReactNode } from 'react'\nimport { I18nContext } from '../context'\nimport { buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './icu-rich'\nimport { buildPlainSelectMessage, resolveCompiledMessageId } from './plain'\n\nexport interface FluentiSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Wrapper element tag name (e.g. 'span', 'div'). Defaults to Fragment (no wrapper). */\n tag?: keyof React.JSX.IntrinsicElements\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | keyof React.JSX.IntrinsicElements | undefined\n}\n\n/**\n * `<Select>` — ICU select for gender, role, or other categorical values.\n *\n * @example\n * ```tsx\n * <Select\n * value={gender}\n * male=\"He liked your post\"\n * female=\"She liked your post\"\n * other=\"They liked your post\"\n * />\n * ```\n */\nexport const Select = /* @__PURE__ */ memo(function Select(props: FluentiSelectProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Select> must be used within an <I18nProvider>')\n }\n\n const { value, id, context, comment, other, options, tag, ...cases } = props\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n const plain = buildPlainSelectMessage(forms)\n if (plain !== undefined) {\n const translated = ctx.t(\n {\n id: resolveCompiledMessageId(id, plain.message, context),\n message: plain.message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: plain.valueMap[value] ?? 'other' },\n )\n\n return tag ? createElement(tag, null, translated) : <>{translated}</>\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const descriptor = {\n id: resolveCompiledMessageId(id, icuMessage, context),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n\n const result = renderRichTranslation(\n descriptor,\n { value: normalized.valueMap[value] ?? 'other' },\n (desc, values) => ctx.t(desc, values),\n components,\n )\n return tag ? createElement(tag, null, result) : <>{result}</>\n})\n","import { memo, useContext } from 'react'\nimport { I18nContext } from '../context'\n\nexport interface FluentiDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/**\n * `<DateTime>` — formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport const DateTime = /* @__PURE__ */ memo(function DateTime({ value, format }: FluentiDateTimeProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <DateTime> must be used within an <I18nProvider>')\n }\n return <>{ctx.d(value, format)}</>\n})\n","import { memo, useContext } from 'react'\nimport { I18nContext } from '../context'\n\nexport interface NumberFormatProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberFormatProps */\nexport type FluentiNumberFormatProps = NumberFormatProps\n\n/**\n * `<Number>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <Number value={1234.56} format=\"currency\" />\n * ```\n */\nexport const NumberFormat = /* @__PURE__ */ memo(function NumberFormat({ value, format }: NumberFormatProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Number> must be used within an <I18nProvider>')\n }\n return <>{ctx.n(value, format)}</>\n})\n"],"mappings":";;;;;AAGA,IAAa,IAA8B,kBAAqC,KAAK,ECqCxE,IAAwB,kBAAK,SAAe,EACvD,aACA,OACA,YACA,YACA,QACA,WACA,SACA,cACA,mBACoB;CACpB,IAAM,IAAM,EAAW,EAAY;AACnC,KAAI,CAAC,EACH,OAAU,MAAM,0DAA0D;AAK5E,KADuB,MAAc,KAAA,GACjB;EAClB,IAAM,IAAU,GACV,IAAa,KAAgB,EAAE,EAC/B,IAAY,KAAM,KAAQ,EAAY,GAAS,EAAQ,EACvD,IAAa,EAAI,EACrB;GACE,IAAI;GACJ;GACA,GAAI,MAAY,KAAA,IAA0B,EAAE,GAAhB,EAAE,YAAS;GACvC,GAAI,MAAY,KAAA,IAA0B,EAAE,GAAhB,EAAE,YAAS;GACxC,CACF,EAEK,IAAS,EAAW,SAAS,IAAI,EAAY,GAAY,EAAW,GAAG;AAE7E,SADI,IAAe,EAAO,EAAO,GAC1B,IAAM,EAAc,GAAK,MAAM,EAAO,GAAG,kBAAA,GAAA,EAAA,UAAG,GAAU,CAAA;;CAG/D,IAAM,EAAE,YAAS,kBAAe,QACxB,EAAe,EAAS,EAC9B,CAAC,EAAS,CACX,EACK,IAAY,QACV,KAAM,KAAQ,EAAY,GAAS,EAAQ,EACjD;EAAC;EAAI;EAAM;EAAS;EAAQ,CAC7B,EAEK,IAAa,EAAI,EACrB;EAC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EACrC,EACD;AACD,QAAO,IAAM,EAAc,GAAK,MAAM,EAAO,GAAG,kBAAA,GAAA,EAAA,UAAG,GAAU,CAAA;EAC7D,EC3EW,IAA2B,kBAAK,SAAkB,EAAE,UAAO,aAAgC;CACtG,IAAM,IAAM,EAAW,EAAY;AACnC,KAAI,CAAC,EACH,OAAU,MAAM,6DAA6D;AAE/E,QAAO,kBAAA,GAAA,EAAA,UAAG,EAAI,EAAE,GAAO,EAAO,EAAI,CAAA;EAClC,ECHW,IAA+B,kBAAK,SAAsB,EAAE,UAAO,aAA6B;CAC3G,IAAM,IAAM,EAAW,EAAY;AACnC,KAAI,CAAC,EACH,OAAU,MAAM,2DAA2D;AAE7E,QAAO,kBAAA,GAAA,EAAA,UAAG,EAAI,EAAE,GAAO,EAAO,EAAI,CAAA;EAClC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Number-JCugssFE.cjs","names":[],"sources":["../src/context.ts","../src/components/Trans.tsx","../src/components/plain.ts","../src/components/Plural.tsx","../src/components/Select.tsx","../src/components/DateTime.tsx","../src/components/Number.tsx"],"sourcesContent":["import { createContext } from 'react'\nimport type { FluentiContext } from './types'\n\nexport const I18nContext = /* @__PURE__ */ createContext<FluentiContext | null>(null)\n","import {\n createElement,\n memo,\n useContext,\n useMemo,\n type ReactElement,\n type ReactNode,\n} from 'react'\nimport { I18nContext } from '../context'\nimport { hashMessage, extractMessage, reconstruct } from './trans-core'\n\nexport interface FluentiTransProps {\n /** Source text with embedded components */\n children?: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Wrapper element tag name (e.g. 'span', 'div'). Defaults to Fragment (no wrapper). */\n tag?: keyof React.JSX.IntrinsicElements\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n /** @internal Pre-computed message ID from build plugin */\n __id?: string\n /** @internal Pre-computed ICU message from build plugin */\n __message?: string\n /** @internal Pre-computed component list from build plugin */\n __components?: ReactElement[]\n}\n\n/**\n * `<Trans>` component for rich-text translations containing nested React elements.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a> for more info.</Trans>\n * ```\n */\nexport const Trans = /* @__PURE__ */ memo(function Trans({\n children,\n id,\n context,\n comment,\n tag,\n render,\n __id,\n __message,\n __components,\n}: FluentiTransProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Trans> must be used within an <I18nProvider>')\n }\n\n // Fast path: build plugin pre-computed message and components\n const hasPrecomputed = __message !== undefined\n if (hasPrecomputed) {\n const message = __message!\n const components = __components ?? []\n const messageId = id ?? __id ?? hashMessage(message, context)\n const translated = ctx.t(\n {\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (render) return render(result)\n return tag ? createElement(tag, null, result) : <>{result}</>\n }\n\n const { message, components } = useMemo(\n () => extractMessage(children),\n [children],\n )\n const messageId = useMemo(\n () => id ?? __id ?? hashMessage(message, context),\n [id, __id, message, context],\n )\n\n const translated = ctx.t(\n {\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (render) return render(result)\n return tag ? createElement(tag, null, result) : <>{result}</>\n})\n","import {\n PLURAL_CATEGORIES,\n buildICUPluralMessage,\n buildICUSelectMessage,\n hashMessage,\n normalizeSelectForms,\n type PluralCategory,\n} from '@fluenti/core/runtime'\nimport type { ReactNode } from 'react'\n\nexport function resolveCompiledMessageId(\n id: string | undefined,\n message: string,\n context: string | undefined,\n): string {\n return id ?? (context === undefined ? message : hashMessage(message, context))\n}\n\nfunction isPlainReactNode(value: ReactNode | undefined): value is string | number {\n return typeof value === 'string' || typeof value === 'number'\n}\n\nexport function buildPlainPluralMessage(\n forms: Record<PluralCategory, ReactNode | undefined>,\n offset?: number,\n): string | undefined {\n const plainForms: Partial<Record<PluralCategory, string>> = {}\n\n for (const category of PLURAL_CATEGORIES) {\n const value = forms[category]\n if (value === undefined) continue\n if (!isPlainReactNode(value)) return undefined\n plainForms[category] = String(value)\n }\n\n if (plainForms['other'] === undefined) return undefined\n return buildICUPluralMessage(plainForms as Partial<Record<PluralCategory, string>> & { other: string }, offset)\n}\n\nexport function buildPlainSelectMessage(\n forms: Record<string, ReactNode | undefined>,\n): { message: string; valueMap: Record<string, string> } | undefined {\n const plainForms: Record<string, string> = {}\n\n for (const [key, value] of Object.entries(forms)) {\n if (value === undefined) continue\n if (!isPlainReactNode(value)) return undefined\n plainForms[key] = String(value)\n }\n\n if (plainForms['other'] === undefined) return undefined\n\n const normalized = normalizeSelectForms(plainForms)\n return {\n message: buildICUSelectMessage(normalized.forms),\n valueMap: normalized.valueMap,\n }\n}\n","import { memo, useContext, type ReactNode } from 'react'\nimport { I18nContext } from '../context'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './plural-core'\nimport { buildICUPluralMessage, renderRichTranslation, serializeRichForms } from './icu-rich'\nimport { buildPlainPluralMessage, resolveCompiledMessageId } from './plain'\n\nexport interface FluentiPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\n/**\n * `<Plural>` — ICU plural handling as a component.\n *\n * @example\n * ```tsx\n * <Plural value={count} zero=\"No messages\" one=\"# message\" other=\"# messages\" />\n * ```\n */\nexport const Plural = /* @__PURE__ */ memo(function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n}: FluentiPluralProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Plural> must be used within an <I18nProvider>')\n }\n\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const plainMessage = buildPlainPluralMessage(forms, offset)\n if (plainMessage !== undefined) {\n return <>{ctx.t(\n {\n id: resolveCompiledMessageId(id, plainMessage, context),\n message: plainMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n )}</>\n }\n\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const descriptor = {\n id: resolveCompiledMessageId(id, icuMessage, context),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n\n return <>{renderRichTranslation(descriptor, { count: value }, (desc, values) => ctx.t(desc, values), components)}</>\n})\n","import { createElement, memo, useContext, type ReactNode } from 'react'\nimport { I18nContext } from '../context'\nimport { buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './icu-rich'\nimport { buildPlainSelectMessage, resolveCompiledMessageId } from './plain'\n\nexport interface FluentiSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Wrapper element tag name (e.g. 'span', 'div'). Defaults to Fragment (no wrapper). */\n tag?: keyof React.JSX.IntrinsicElements\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | keyof React.JSX.IntrinsicElements | undefined\n}\n\n/**\n * `<Select>` — ICU select for gender, role, or other categorical values.\n *\n * @example\n * ```tsx\n * <Select\n * value={gender}\n * male=\"He liked your post\"\n * female=\"She liked your post\"\n * other=\"They liked your post\"\n * />\n * ```\n */\nexport const Select = /* @__PURE__ */ memo(function Select(props: FluentiSelectProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Select> must be used within an <I18nProvider>')\n }\n\n const { value, id, context, comment, other, options, tag, ...cases } = props\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n const plain = buildPlainSelectMessage(forms)\n if (plain !== undefined) {\n const translated = ctx.t(\n {\n id: resolveCompiledMessageId(id, plain.message, context),\n message: plain.message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: plain.valueMap[value] ?? 'other' },\n )\n\n return tag ? createElement(tag, null, translated) : <>{translated}</>\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const descriptor = {\n id: resolveCompiledMessageId(id, icuMessage, context),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n\n const result = renderRichTranslation(\n descriptor,\n { value: normalized.valueMap[value] ?? 'other' },\n (desc, values) => ctx.t(desc, values),\n components,\n )\n return tag ? createElement(tag, null, result) : <>{result}</>\n})\n","import { memo, useContext } from 'react'\nimport { I18nContext } from '../context'\n\nexport interface FluentiDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/**\n * `<DateTime>` — formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport const DateTime = /* @__PURE__ */ memo(function DateTime({ value, format }: FluentiDateTimeProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <DateTime> must be used within an <I18nProvider>')\n }\n return <>{ctx.d(value, format)}</>\n})\n","import { memo, useContext } from 'react'\nimport { I18nContext } from '../context'\n\nexport interface NumberFormatProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberFormatProps */\nexport type FluentiNumberFormatProps = NumberFormatProps\n\n/**\n * `<Number>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <Number value={1234.56} format=\"currency\" />\n * ```\n */\nexport const NumberFormat = /* @__PURE__ */ memo(function NumberFormat({ value, format }: NumberFormatProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Number> must be used within an <I18nProvider>')\n }\n return <>{ctx.n(value, format)}</>\n})\n"],"mappings":"oIAGA,IAAa,GAA8B,EAAA,EAAA,eAAqC,KAAK,CCqCxE,GAAwB,EAAA,EAAA,MAAK,SAAe,CACvD,WACA,KACA,UACA,UACA,MACA,SACA,OACA,YACA,gBACoB,CACpB,IAAM,GAAA,EAAA,EAAA,YAAiB,EAAY,CACnC,GAAI,CAAC,EACH,MAAU,MAAM,0DAA0D,CAK5E,GADuB,IAAc,IAAA,GACjB,CAClB,IAAM,EAAU,EACV,EAAa,GAAgB,EAAE,CAC/B,EAAY,GAAM,IAAA,EAAA,EAAA,aAAoB,EAAS,EAAQ,CACvD,EAAa,EAAI,EACrB,CACE,GAAI,EACJ,UACA,GAAI,IAAY,IAAA,GAA0B,EAAE,CA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,EAAA,EAAA,YAAiB,EAAY,CACnC,GAAI,CAAC,EACH,MAAU,MAAM,2DAA2D,CAE7E,OAAO,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAAG,EAAI,EAAE,EAAO,EAAO,CAAI,CAAA,EAClC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-entry.cjs","names":[],"sources":["../src/components/compiled.tsx"],"sourcesContent":["import { createElement, memo, useContext } from 'react'\nimport { I18nContext } from '../context'\nimport { hashMessage } from './trans-core'\nimport { renderRichTranslation } from './icu-rich'\nimport { resolveCompiledMessageId } from './plain'\n\nexport interface FluentiCompiledTransProps {\n message: string\n id?: string\n context?: string\n comment?: string\n tag?: keyof React.JSX.IntrinsicElements\n render?: (translation: React.ReactNode) => React.ReactNode\n}\n\nexport interface FluentiCompiledPluralProps {\n value: number\n message: string\n id?: string\n context?: string\n comment?: string\n}\n\nexport interface FluentiCompiledSelectProps {\n value: string\n message: string\n valueMap?: Record<string, string>\n id?: string\n context?: string\n comment?: string\n tag?: keyof React.JSX.IntrinsicElements\n}\n\nexport interface FluentiCompiledRichTransProps extends FluentiCompiledTransProps {\n components: React.ReactElement[]\n}\n\nexport interface FluentiCompiledRichPluralProps extends FluentiCompiledPluralProps {\n components: React.ReactElement[]\n}\n\nexport interface FluentiCompiledRichSelectProps extends FluentiCompiledSelectProps {\n components: React.ReactElement[]\n}\n\nfunction renderCompiledTransResult(\n result: React.ReactNode,\n tag: keyof React.JSX.IntrinsicElements | undefined,\n render: ((translation: React.ReactNode) => React.ReactNode) | undefined,\n) {\n if (render) {\n return render(result)\n }\n return tag ? createElement(tag, null, result) : <>{result}</>\n}\n\n/** @internal Build-plugin fast path for plain-text `<Trans>` usage. */\nexport const __FluentiCompiledTrans = /* @__PURE__ */ memo(function FluentiCompiledTrans({\n message,\n id,\n context,\n comment,\n tag,\n render,\n}: FluentiCompiledTransProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Trans> must be used within an <I18nProvider>')\n }\n\n const translated = ctx.t(\n {\n id: id ?? hashMessage(message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n )\n\n return renderCompiledTransResult(translated, tag, render)\n})\n\n/** @internal Build-plugin fast path for rich-text `<Trans>` usage. */\nexport const __FluentiCompiledRichTrans = /* @__PURE__ */ memo(function FluentiCompiledRichTrans({\n message,\n components,\n id,\n context,\n comment,\n tag,\n render,\n}: FluentiCompiledRichTransProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Trans> must be used within an <I18nProvider>')\n }\n\n const descriptor = {\n id: id ?? hashMessage(message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n const translated = renderRichTranslation(\n descriptor,\n undefined,\n (desc, values) => ctx.t(desc, values),\n components,\n )\n\n return renderCompiledTransResult(translated, tag, render)\n})\n\n/** @internal Build-plugin fast path for plain-text `<Plural>` usage. */\nexport const __FluentiCompiledPlural = /* @__PURE__ */ memo(function FluentiCompiledPlural({\n value,\n message,\n id,\n context,\n comment,\n}: FluentiCompiledPluralProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Plural> must be used within an <I18nProvider>')\n }\n\n const translated = ctx.t(\n {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n )\n\n return <>{translated}</>\n})\n\n/** @internal Build-plugin fast path for plain-text `<Select>` usage. */\nexport const __FluentiCompiledSelect = /* @__PURE__ */ memo(function FluentiCompiledSelect({\n value,\n message,\n valueMap,\n id,\n context,\n comment,\n tag,\n}: FluentiCompiledSelectProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Select> must be used within an <I18nProvider>')\n }\n\n const translated = ctx.t(\n {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: valueMap?.[value] ?? 'other' },\n )\n\n return tag ? createElement(tag, null, translated) : <>{translated}</>\n})\n\n/** @internal Build-plugin fast path for rich-text `<Plural>` usage. */\nexport const __FluentiCompiledRichPlural = /* @__PURE__ */ memo(function FluentiCompiledRichPlural({\n value,\n message,\n components,\n id,\n context,\n comment,\n}: FluentiCompiledRichPluralProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Plural> must be used within an <I18nProvider>')\n }\n\n const descriptor = {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n\n return <>{renderRichTranslation(descriptor, { count: value }, (desc, values) => ctx.t(desc, values), components)}</>\n})\n\n/** @internal Build-plugin fast path for rich-text `<Select>` usage. */\nexport const __FluentiCompiledRichSelect = /* @__PURE__ */ memo(function FluentiCompiledRichSelect({\n value,\n message,\n valueMap,\n components,\n id,\n context,\n comment,\n tag,\n}: FluentiCompiledRichSelectProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Select> must be used within an <I18nProvider>')\n }\n\n const descriptor = {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n const translated = renderRichTranslation(\n descriptor,\n { value: valueMap?.[value] ?? 'other' },\n (desc, values) => ctx.t(desc, values),\n components,\n )\n\n return tag ? createElement(tag, null, translated) : <>{translated}</>\n})\n"],"mappings":"uPA6CA,SAAS,EACP,EACA,EACA,EACA,CAIA,OAHI,EACK,EAAO,EAAO,CAEhB,GAAA,EAAA,EAAA,eAAoB,EAAK,KAAM,EAAO,EAAG,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAAG,EAAU,CAAA,CAI/D,IAAa,GAAyC,EAAA,EAAA,MAAK,SAA8B,CACvF,UACA,KACA,UACA,UACA,MACA,U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7E,IAAM,EAAa,EAAA,EANA,CACjB,GAAI,EAAA,EAAyB,EAAI,EAAS,EAAQ,CAClD,UACA,GAAI,IAAY,IAAA,GAA0B,EAAE,CAAhB,CAAE,UAAS,CACvC,GAAI,IAAY,IAAA,GAA0B,EAAE,CAAhB,CAAE,UAAS,CACxC,CAGC,CAAE,MAAO,IAAW,IAAU,QAAS,EACtC,EAAM,IAAW,EAAI,EAAE,EAAM,EAAO,CACrC,EACD,CAED,OAAO,GAAA,EAAA,EAAA,eAAoB,EAAK,KAAM,EAAW,EAAG,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SAAG,EAAc,CAAA,EACrE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-entry.js","names":[],"sources":["../src/components/compiled.tsx"],"sourcesContent":["import { createElement, memo, useContext } from 'react'\nimport { I18nContext } from '../context'\nimport { hashMessage } from './trans-core'\nimport { renderRichTranslation } from './icu-rich'\nimport { resolveCompiledMessageId } from './plain'\n\nexport interface FluentiCompiledTransProps {\n message: string\n id?: string\n context?: string\n comment?: string\n tag?: keyof React.JSX.IntrinsicElements\n render?: (translation: React.ReactNode) => React.ReactNode\n}\n\nexport interface FluentiCompiledPluralProps {\n value: number\n message: string\n id?: string\n context?: string\n comment?: string\n}\n\nexport interface FluentiCompiledSelectProps {\n value: string\n message: string\n valueMap?: Record<string, string>\n id?: string\n context?: string\n comment?: string\n tag?: keyof React.JSX.IntrinsicElements\n}\n\nexport interface FluentiCompiledRichTransProps extends FluentiCompiledTransProps {\n components: React.ReactElement[]\n}\n\nexport interface FluentiCompiledRichPluralProps extends FluentiCompiledPluralProps {\n components: React.ReactElement[]\n}\n\nexport interface FluentiCompiledRichSelectProps extends FluentiCompiledSelectProps {\n components: React.ReactElement[]\n}\n\nfunction renderCompiledTransResult(\n result: React.ReactNode,\n tag: keyof React.JSX.IntrinsicElements | undefined,\n render: ((translation: React.ReactNode) => React.ReactNode) | undefined,\n) {\n if (render) {\n return render(result)\n }\n return tag ? createElement(tag, null, result) : <>{result}</>\n}\n\n/** @internal Build-plugin fast path for plain-text `<Trans>` usage. */\nexport const __FluentiCompiledTrans = /* @__PURE__ */ memo(function FluentiCompiledTrans({\n message,\n id,\n context,\n comment,\n tag,\n render,\n}: FluentiCompiledTransProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Trans> must be used within an <I18nProvider>')\n }\n\n const translated = ctx.t(\n {\n id: id ?? hashMessage(message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n )\n\n return renderCompiledTransResult(translated, tag, render)\n})\n\n/** @internal Build-plugin fast path for rich-text `<Trans>` usage. */\nexport const __FluentiCompiledRichTrans = /* @__PURE__ */ memo(function FluentiCompiledRichTrans({\n message,\n components,\n id,\n context,\n comment,\n tag,\n render,\n}: FluentiCompiledRichTransProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Trans> must be used within an <I18nProvider>')\n }\n\n const descriptor = {\n id: id ?? hashMessage(message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n const translated = renderRichTranslation(\n descriptor,\n undefined,\n (desc, values) => ctx.t(desc, values),\n components,\n )\n\n return renderCompiledTransResult(translated, tag, render)\n})\n\n/** @internal Build-plugin fast path for plain-text `<Plural>` usage. */\nexport const __FluentiCompiledPlural = /* @__PURE__ */ memo(function FluentiCompiledPlural({\n value,\n message,\n id,\n context,\n comment,\n}: FluentiCompiledPluralProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Plural> must be used within an <I18nProvider>')\n }\n\n const translated = ctx.t(\n {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n )\n\n return <>{translated}</>\n})\n\n/** @internal Build-plugin fast path for plain-text `<Select>` usage. */\nexport const __FluentiCompiledSelect = /* @__PURE__ */ memo(function FluentiCompiledSelect({\n value,\n message,\n valueMap,\n id,\n context,\n comment,\n tag,\n}: FluentiCompiledSelectProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Select> must be used within an <I18nProvider>')\n }\n\n const translated = ctx.t(\n {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: valueMap?.[value] ?? 'other' },\n )\n\n return tag ? createElement(tag, null, translated) : <>{translated}</>\n})\n\n/** @internal Build-plugin fast path for rich-text `<Plural>` usage. */\nexport const __FluentiCompiledRichPlural = /* @__PURE__ */ memo(function FluentiCompiledRichPlural({\n value,\n message,\n components,\n id,\n context,\n comment,\n}: FluentiCompiledRichPluralProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Plural> must be used within an <I18nProvider>')\n }\n\n const descriptor = {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n\n return <>{renderRichTranslation(descriptor, { count: value }, (desc, values) => ctx.t(desc, values), components)}</>\n})\n\n/** @internal Build-plugin fast path for rich-text `<Select>` usage. */\nexport const __FluentiCompiledRichSelect = /* @__PURE__ */ memo(function FluentiCompiledRichSelect({\n value,\n message,\n valueMap,\n components,\n id,\n context,\n comment,\n tag,\n}: FluentiCompiledRichSelectProps) {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error('[fluenti] <Select> must be used within an <I18nProvider>')\n }\n\n const descriptor = {\n id: resolveCompiledMessageId(id, message, context),\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n }\n const translated = renderRichTranslation(\n descriptor,\n { value: valueMap?.[value] ?? 'other' },\n (desc, values) => ctx.t(desc, values),\n components,\n )\n\n return tag ? createElement(tag, null, translated) : <>{translated}</>\n})\n"],"mappings":";;;;;;AA6CA,SA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A0B,EAAE,GAAhB,EAAE,YAAS;EACvC,GAAI,MAAY,KAAA,IAA0B,EAAE,GAAhB,EAAE,YAAS;EACxC,EAGC,EAAE,OAAO,IAAW,MAAU,SAAS,GACtC,GAAM,MAAW,EAAI,EAAE,GAAM,EAAO,EACrC,EACD;AAED,QAAO,IAAM,EAAc,GAAK,MAAM,EAAW,GAAG,kBAAA,GAAA,EAAA,UAAG,GAAc,CAAA;EACrE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"icu-rich-BlDjwT5Z.cjs","names":[],"sources":["../src/components/trans-core.ts","../src/components/icu-rich.tsx"],"sourcesContent":["import {\n Children,\n isValidElement,\n cloneElement,\n createElement,\n Fragment,\n type ReactNode,\n type ReactElement,\n} from 'react'\nimport { hashMessage, offsetIndices } from '@fluenti/core/runtime'\n\nexport { hashMessage }\n\n/**\n * Extract a message string and component list from React children.\n *\n * Converts:\n * <Trans>Hello <b>{name}</b>, welcome!</Trans>\n * Into:\n * message: \"Hello <0>{name}</0>, welcome!\"\n * components: [<b>{name}</b>]\n *\n * @internal\n */\nexport function extractMessage(children: ReactNode): {\n message: string\n components: ReactElement[]\n} {\n const components: ReactElement[] = []\n let message = ''\n\n Children.forEach(children, (child) => {\n if (typeof child === 'string' || typeof child === 'number') {\n message += String(child)\n } else if (isValidElement(child)) {\n if (child.type === Fragment) {\n const inner = extractMessage((child.props as { children?: ReactNode }).children)\n message += offsetIndices(inner.message, components.length)\n components.push(...inner.components)\n return\n }\n\n const idx = components.length\n const inner = extractMessage((child.props as { children?: ReactNode }).children)\n components.push(child)\n components.push(...inner.components)\n if (inner.message === '' && inner.components.length === 0) {\n message += `<${idx}/>`\n } else {\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n }\n })\n\n return { message, components }\n}\n\n/**\n * Reconstruct a translated message string back into React elements.\n *\n * Parses \"<0>content</0>\" tags and replaces them with cloned components.\n *\n * @internal\n */\nexport function reconstruct(\n translated: string,\n components: ReactElement[],\n): ReactNode {\n const COMBINED_RE = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n if (!translated.includes('<')) {\n return translated\n }\n\n const result: ReactNode[] = []\n let lastIndex = 0\n let keyCounter = 0\n let match: RegExpExecArray | null\n\n COMBINED_RE.lastIndex = 0\n match = COMBINED_RE.exec(translated)\n if (match === null) {\n return translated\n }\n\n while (match !== null) {\n if (match.index > lastIndex) {\n result.push(translated.slice(lastIndex, match.index))\n }\n\n const idx = Number(match[1])\n const isSelfClosing = match[2] === undefined\n const innerText = match[3] ?? ''\n\n if (!Number.isInteger(idx) || idx < 0 || idx >= components.length) {\n if (innerText) result.push(innerText)\n lastIndex = COMBINED_RE.lastIndex\n match = COMBINED_RE.exec(translated)\n continue\n }\n\n const component = components[idx]\n\n if (component) {\n // Use keyCounter (not idx) so duplicate component indices get unique keys\n const key = `trans-${keyCounter++}`\n if (isSelfClosing) {\n result.push(cloneElement(component, { key }))\n } else {\n const innerContent = reconstruct(innerText, components)\n result.push(cloneElement(component, { key }, innerContent))\n }\n } else {\n // Only push non-empty text to avoid inserting blank DOM nodes\n if (innerText) result.push(innerText)\n }\n\n lastIndex = COMBINED_RE.lastIndex\n match = COMBINED_RE.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return result.length === 1 ? result[0]! : createElement(Fragment, null, ...result)\n}\n","import type { MessageDescriptor } from '@fluenti/core'\nimport {\n buildICUPluralMessage,\n buildICUSelectMessage,\n normalizeSelectForms,\n offsetIndices,\n} from '@fluenti/core/runtime'\nimport type { ReactElement, ReactNode } from 'react'\nimport { extractMessage, reconstruct } from './trans-core'\n\nexport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms }\n\nexport interface RichMessagePart {\n message: string\n components: ReactElement[]\n}\n\nexport function serializeRichNode(node: ReactNode): RichMessagePart {\n const extracted = extractMessage(node)\n return {\n message: extracted.message,\n components: extracted.components,\n }\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, ReactNode>> & Record<string, ReactNode | undefined>,\n): {\n messages: Partial<Record<T, string>> & Record<string, string>\n components: ReactElement[]\n} {\n const components: ReactElement[] = []\n const messages: Record<string, string> = {}\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = serializeRichNode(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n for (const [key, value] of Object.entries(forms)) {\n if (keys.includes(key as T) || value === undefined) continue\n const extracted = serializeRichNode(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages: messages as Partial<Record<T, string>> & Record<string, string>, components }\n}\n\nexport function renderRichTranslation(\n descriptor: MessageDescriptor,\n values: Record<string, unknown> | undefined,\n translate: (descriptor: MessageDescriptor, values?: Record<string, unknown>) => string,\n components: ReactElement[],\n): ReactNode {\n const translated = translate(descriptor, values)\n return components.length > 0 ? reconstruct(translated, components) : translated\n}\n"],"mappings":"0DAwBA,SAAgB,EAAe,EAG7B,CACA,IAAM,EAA6B,EAAE,CACjC,EAAU,GAyBd,OAvBA,EAAA,SAAS,QAAQ,EAAW,GAAU,CACpC,GAAI,OAAO,GAAU,UAAY,OAAO,GAAU,SAChD,GAAW,OAAO,EAAM,8BACA,EAAM,CAAE,CAChC,GAAI,EAAM,OAAS,EAAA,SAAU,CAC3B,IAAM,EAAQ,EAAgB,EAAM,MAAmC,SAAS,CAChF,IAAA,EAAA,EAAA,eAAyB,EAAM,QAAS,EAAW,OAAO,CAC1D,EAAW,KAAK,GAAG,EAAM,WAAW,CACpC,OAGF,IAAM,EAAM,EAAW,OACjB,EAAQ,EAAgB,EAAM,MAAmC,SAAS,CAChF,EAAW,KAAK,EAAM,CACtB,EAAW,KAAK,GAAG,EAAM,WAAW,CAChC,EAAM,UAAY,IAAM,EAAM,WAAW,SAAW,EACtD,GAAW,IAAI,EAAI,IAEnB,GAAW,IAAI,EAAI,IAAA,EAAA,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,MAAO,CACL,QAAS,EAAU,QACnB,WAAY,EAAU,WACvB,CAGH,SAAgB,EACd,EACA,EAIA,CACA,IAAM,EAA6B,EAAE,CAC/B,EAAmC,EAAE,CAE3C,IAAK,IAAM,KAAO,EAAM,CACtB,IAAM,EAAQ,EAAM,GACpB,GAAI,IAAU,IAAA,GAAW,SACzB,IAAM,EAAY,EAAkB,EAAM,CAC1C,EAAS,IAAA,EAAA,EAAA,eAAqB,EAAU,QAAS,EAAW,OAAO,CACnE,EAAW,KAAK,GAAG,EAAU,WAAW,CAG1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAM,CAAE,CAChD,GAAI,EAAK,SAAS,EAAS,EAAI,IAAU,IAAA,GAAW,SACpD,IAAM,EAAY,EAAkB,EAAM,CAC1C,EAAS,IAAA,EAAA,EAAA,eAAqB,EAAU,QAAS,EAAW,OAAO,CACnE,EAAW,KAAK,GAAG,EAAU,WAAW,CAG1C,MAAO,CAAY,WAAiE,aAAY,CAGlG,SAAgB,EACd,EACA,EACA,EACA,EACW,CACX,IAAM,EAAa,EAAU,EAAY,EAAO,CAChD,OAAO,EAAW,OAAS,EAAI,EAAY,EAAY,EAAW,CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"icu-rich-C6B9ns4t.js","names":[],"sources":["../src/components/trans-core.ts","../src/components/icu-rich.tsx"],"sourcesContent":["import {\n Children,\n isValidElement,\n cloneElement,\n createElement,\n Fragment,\n type ReactNode,\n type ReactElement,\n} from 'react'\nimport { hashMessage, offsetIndices } from '@fluenti/core/runtime'\n\nexport { hashMessage }\n\n/**\n * Extract a message string and component list from React children.\n *\n * Converts:\n * <Trans>Hello <b>{name}</b>, welcome!</Trans>\n * Into:\n * message: \"Hello <0>{name}</0>, welcome!\"\n * components: [<b>{name}</b>]\n *\n * @internal\n */\nexport function extractMessage(children: ReactNode): {\n message: string\n components: ReactElement[]\n} {\n const components: ReactElement[] = []\n let message = ''\n\n Children.forEach(children, (child) => {\n if (typeof child === 'string' || typeof child === 'number') {\n message += String(child)\n } else if (isValidElement(child)) {\n if (child.type === Fragment) {\n const inner = extractMessage((child.props as { children?: ReactNode }).children)\n message += offsetIndices(inner.message, components.length)\n components.push(...inner.components)\n return\n }\n\n const idx = components.length\n const inner = extractMessage((child.props as { children?: ReactNode }).children)\n components.push(child)\n components.push(...inner.components)\n if (inner.message === '' && inner.components.length === 0) {\n message += `<${idx}/>`\n } else {\n message += `<${idx}>${offsetIndices(inner.message, idx + 1)}</${idx}>`\n }\n }\n })\n\n return { message, components }\n}\n\n/**\n * Reconstruct a translated message string back into React elements.\n *\n * Parses \"<0>content</0>\" tags and replaces them with cloned components.\n *\n * @internal\n */\nexport function reconstruct(\n translated: string,\n components: ReactElement[],\n): ReactNode {\n const COMBINED_RE = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n if (!translated.includes('<')) {\n return translated\n }\n\n const result: ReactNode[] = []\n let lastIndex = 0\n let keyCounter = 0\n let match: RegExpExecArray | null\n\n COMBINED_RE.lastIndex = 0\n match = COMBINED_RE.exec(translated)\n if (match === null) {\n return translated\n }\n\n while (match !== null) {\n if (match.index > lastIndex) {\n result.push(translated.slice(lastIndex, match.index))\n }\n\n const idx = Number(match[1])\n const isSelfClosing = match[2] === undefined\n const innerText = match[3] ?? ''\n\n if (!Number.isInteger(idx) || idx < 0 || idx >= components.length) {\n if (innerText) result.push(innerText)\n lastIndex = COMBINED_RE.lastIndex\n match = COMBINED_RE.exec(translated)\n continue\n }\n\n const component = components[idx]\n\n if (component) {\n // Use keyCounter (not idx) so duplicate component indices get unique keys\n const key = `trans-${keyCounter++}`\n if (isSelfClosing) {\n result.push(cloneElement(component, { key }))\n } else {\n const innerContent = reconstruct(innerText, components)\n result.push(cloneElement(component, { key }, innerContent))\n }\n } else {\n // Only push non-empty text to avoid inserting blank DOM nodes\n if (innerText) result.push(innerText)\n }\n\n lastIndex = COMBINED_RE.lastIndex\n match = COMBINED_RE.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return result.length === 1 ? result[0]! : createElement(Fragment, null, ...result)\n}\n","import type { MessageDescriptor } from '@fluenti/core'\nimport {\n buildICUPluralMessage,\n buildICUSelectMessage,\n normalizeSelectForms,\n offsetIndices,\n} from '@fluenti/core/runtime'\nimport type { ReactElement, ReactNode } from 'react'\nimport { extractMessage, reconstruct } from './trans-core'\n\nexport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms }\n\nexport interface RichMessagePart {\n message: string\n components: ReactElement[]\n}\n\nexport function serializeRichNode(node: ReactNode): RichMessagePart {\n const extracted = extractMessage(node)\n return {\n message: extracted.message,\n components: extracted.components,\n }\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, ReactNode>> & Record<string, ReactNode | undefined>,\n): {\n messages: Partial<Record<T, string>> & Record<string, string>\n components: ReactElement[]\n} {\n const components: ReactElement[] = []\n const messages: Record<string, string> = {}\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = serializeRichNode(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n for (const [key, value] of Object.entries(forms)) {\n if (keys.includes(key as T) || value === undefined) continue\n const extracted = serializeRichNode(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages: messages as Partial<Record<T, string>> & Record<string, string>, components }\n}\n\nexport function renderRichTranslation(\n descriptor: MessageDescriptor,\n values: Record<string, unknown> | undefined,\n translate: (descriptor: MessageDescriptor, values?: Record<string, unknown>) => string,\n components: ReactElement[],\n): ReactNode {\n const translated = translate(descriptor, values)\n return components.length > 0 ? reconstruct(translated, components) : translated\n}\n"],"mappings":";;;AAwBA,SAAgB,EAAe,GAG7B;CACA,IAAM,IAA6B,EAAE,EACjC,IAAU;AAyBd,QAvBA,EAAS,QAAQ,IAAW,MAAU;AACpC,MAAI,OAAO,KAAU,YAAY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../src/global-registry.ts","../src/provider.tsx","../src/hooks/useI18n.ts","../src/compile-time-t.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull as FluentInstanceExtended,\n CompiledMessage,\n Locale,\n Messages,\n AllMessages,\n DateFormatOptions,\n NumberFormatOptions,\n LocalizedString,\n MessageDescriptor,\n} from '@fluenti/core'\n\n/**\n * Configuration for `createFluenti()`.\n */\nexport interface FluentiConfig {\n /** Active locale code */\n locale: string\n /** Static message catalogs keyed by locale */\n messages?: AllMessages | undefined\n /** Async loader for lazy-loading locale messages */\n loadMessages?: ((locale: string) => Promise<Messages | { default: Messages }>) | undefined\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string | undefined\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, string[]> | undefined\n /** Date format styles */\n dateFormats?: DateFormatOptions | undefined\n /** Number format styles */\n numberFormats?: NumberFormatOptions | undefined\n /** Missing message handler */\n missing?: ((locale: Locale, id: string) => string | undefined) | undefined\n /** Runtime diagnostics (pre-created instance or config) */\n diagnostics?: unknown | undefined\n /** Custom interpolation function for full ICU support at runtime */\n interpolate?: ((message: string, values: Record<string, unknown> | undefined, locale: string, formatters?: Record<string, unknown>) => string) | undefined\n}\n\n/**\n * The object returned by `createFluenti()`.\n *\n * Contains all i18n state and methods. Pass to `<I18nProvider instance={...}>`\n * or use directly in tests/non-React contexts.\n */\nexport interface FluentiInstance {\n /** Translate a message by id with optional interpolation values */\n t: {\n (id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n (strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n }\n /** Format a date value for the current locale */\n d: (value: Date | number, style?: string) => LocalizedString\n /** Format a number value for the current locale */\n n: (value: number, style?: string) => LocalizedString\n /** Current locale */\n locale: string\n /** Change the active locale (async when lazy loading) */\n setLocale: (locale: string) => Promise<void>\n /** Whether a locale is currently being loaded */\n isLoading: boolean\n /** Preload a locale in the background without switching to it */\n preloadLocale: (locale: string) => Promise<void>\n /** Check whether a translation key exists for the given or current locale */\n te: (key: string, locale?: string) => boolean\n /** Get the raw compiled message for a key without interpolation */\n tm: (key: string, locale?: string) => CompiledMessage | undefined\n /** The underlying Fluent instance (escape hatch for advanced use) */\n i18n: FluentInstanceExtended\n /** Format an ICU message string directly (no catalog lookup) */\n format: (message: string, values?: Record<string, unknown>) => LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages: (locale: string, messages: Messages) => void\n /** Return all locale codes that have loaded messages */\n getLocales: () => string[]\n /** Set of locales whose messages have been loaded */\n loadedLocales: string[]\n}\n\nfunction unwrapMessages(allMessages: Record<string, unknown>): Record<string, Messages> {\n const result: Record<string, Messages> = {}\n for (const [locale, msgs] of Object.entries(allMessages)) {\n result[locale] = typeof msgs === 'object' && msgs !== null && 'default' in msgs\n ? (msgs as { default: Messages }).default\n : msgs as Messages\n }\n return result\n}\n\n/**\n * Create a standalone Fluenti i18n instance.\n *\n * This is a React hook that manages locale state, message loading, and\n * provides all i18n methods. The returned instance can be passed to\n * `<I18nProvider instance={...}>` to share it with the component tree.\n *\n * @example\n * ```tsx\n * function App() {\n * const i18n = createFluenti({\n * locale: 'en',\n * messages: { en: enMessages, fr: frMessages },\n * })\n * return (\n * <I18nProvider instance={i18n}>\n * <MyApp />\n * </I18nProvider>\n * )\n * }\n * ```\n */\nexport function createFluenti(config: FluentiConfig): FluentiInstance {\n const {\n locale: initialLocale,\n messages: initialMessages,\n loadMessages: loadMessagesFn,\n fallbackLocale,\n fallbackChain,\n dateFormats,\n numberFormats,\n missing,\n diagnostics,\n interpolate,\n } = config\n\n const [currentLocale, setCurrentLocale] = useState(initialLocale)\n const [isLoading, setIsLoading] = useState(false)\n const [loadedMessages, setLoadedMessages] = useState<Record<string, Messages>>(\n initialMessages ? unwrapMessages(initialMessages) : {},\n )\n const [loadedLocales, setLoadedLocales] = useState<string[]>(\n initialMessages ? Object.keys(initialMessages) : [],\n )\n\n const loadedMessagesRef = useRef(loadedMessages)\n loadedMessagesRef.current = loadedMessages\n\n const localeRequestRef = useRef(0)\n\n // Split runtime integration (for Vite plugin code splitting)\n const SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.react.v1')\n function getSplitRuntime(): { __switchLocale?: (l: string) => Promise<void>; __preloadLocale?: (l: string) => Promise<void> } | null {\n const rt = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof rt === 'object' && rt !== null ? rt as any : null\n }\n\n const i18n = useMemo(() => {\n const cfg: Parameters<typeof createFluentiCore>[0] = {\n locale: currentLocale,\n messages: loadedMessages,\n }\n if (fallbackLocale !== undefined) cfg.fallbackLocale = fallbackLocale\n if (fallbackChain !== undefined) cfg.fallbackChain = fallbackChain\n if (dateFormats !== undefined) cfg.dateFormats = dateFormats\n if (numberFormats !== undefined) cfg.numberFormats = numberFormats\n if (missing !== undefined) cfg.missing = missing\n if (diagnostics !== undefined) cfg.diagnostics = diagnostics as Parameters<typeof createFluentiCore>[0]['diagnostics']\n if (interpolate !== undefined) cfg.interpolate = interpolate\n cfg.devWarnings = cfg.devWarnings ?? (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development')\n return createFluentiCore(cfg)\n }, [currentLocale, loadedMessages, fallbackLocale, fallbackChain, dateFormats, numberFormats, missing, diagnostics, interpolate])\n\n // Sync external locale changes\n useEffect(() => {\n if (initialLocale !== currentLocale) {\n void handleSetLocale(initialLocale)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [initialLocale])\n\n const handleSetLocale = useCallback(\n async (newLocale: string) => {\n const requestId = ++localeRequestRef.current\n\n const splitRuntime = loadMessagesFn ? getSplitRuntime() : null\n\n if (loadedMessagesRef.current[newLocale] && !loadMessagesFn) {\n setCurrentLocale(newLocale)\n return\n }\n\n if (loadedMessagesRef.current[newLocale]) {\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n setCurrentLocale(newLocale)\n return\n }\n\n if (!loadMessagesFn) {\n console.warn(\n `[fluenti] No messages for locale \"${newLocale}\" and no loadMessages function provided`,\n )\n return\n }\n\n setIsLoading(true)\n try {\n const msgs = await loadMessagesFn(newLocale)\n if (requestId !== localeRequestRef.current) return\n\n const resolved: Messages =\n typeof msgs === 'object' && msgs !== null && 'default' in msgs\n ? (msgs as { default: Messages }).default\n : (msgs as Messages)\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n if (requestId !== localeRequestRef.current) return\n setLoadedMessages((prev) => ({ ...prev, [newLocale]: resolved }))\n setLoadedLocales((prev) => [...new Set([...prev, newLocale])])\n setCurrentLocale(newLocale)\n } catch (err) {\n if (requestId === localeRequestRef.current) {\n console.error(`[fluenti] Failed to load locale \"${newLocale}\"`, err)\n }\n } finally {\n if (requestId === localeRequestRef.current) {\n setIsLoading(false)\n }\n }\n },\n [loadMessagesFn],\n )\n\n const preloadLocale = useCallback(\n async (loc: string) => {\n if (loadedMessagesRef.current[loc] || !loadMessagesFn) return\n try {\n const msgs = await loadMessagesFn(loc)\n const resolved: Messages =\n typeof msgs === 'object' && msgs !== null && 'default' in msgs\n ? (msgs as { default: Messages }).default\n : (msgs as Messages)\n setLoadedMessages((prev) => ({ ...prev, [loc]: resolved }))\n setLoadedLocales((prev) => [...new Set([...prev, loc])])\n const splitRuntime = getSplitRuntime()\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n } catch {\n // Silent fail for preload\n }\n },\n [loadMessagesFn],\n )\n\n const te = useCallback(\n (key: string, loc?: string): boolean => {\n const msgs = loadedMessages[loc ?? currentLocale]\n return msgs !== undefined && key in msgs\n },\n [loadedMessages, currentLocale],\n )\n\n const tm = useCallback(\n (key: string, loc?: string): Messages[string] | undefined => {\n const msgs = loadedMessages[loc ?? currentLocale]\n if (!msgs) return undefined\n return msgs[key]\n },\n [loadedMessages, currentLocale],\n )\n\n return useMemo(\n () => ({\n t: i18n.t.bind(i18n),\n d: i18n.d.bind(i18n),\n n: i18n.n.bind(i18n),\n locale: currentLocale,\n setLocale: handleSetLocale,\n isLoading,\n preloadLocale,\n te,\n tm,\n i18n,\n format: i18n.format.bind(i18n),\n loadMessages: i18n.loadMessages.bind(i18n),\n getLocales: i18n.getLocales.bind(i18n),\n loadedLocales,\n }),\n [i18n, currentLocale, handleSetLocale, isLoading, preloadLocale, te, tm, loadedLocales],\n )\n}\n","import type { FluentiCoreInstanceFull } from '@fluenti/core'\n\n/**\n * Global i18n instance registry.\n *\n * Used by `@fluenti/next` webpack loader and `@fluenti/vite-plugin` to access\n * the i18n instance from module-level code via a Proxy. The instance is set by\n * `<I18nProvider>` on mount.\n */\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __fluenti_i18n: FluentiCoreInstanceFull | undefined\n}\n\n/** Get the global i18n instance (set by `<I18nProvider>`). */\nexport function getGlobalI18n(): FluentiCoreInstanceFull | undefined {\n return globalThis.__fluenti_i18n\n}\n\n/** Set the global i18n instance. Called by `<I18nProvider>` on mount. */\nexport function setGlobalI18n(instance: FluentiCoreInstanceFull): void {\n globalThis.__fluenti_i18n = instance\n}\n\n/** Clear the global i18n instance. Primarily for testing. */\nexport function clearGlobalI18n(): void {\n globalThis.__fluenti_i18n = undefined\n}\n","import { useEffect, useMemo } from 'react'\nimport { I18nContext } from './context'\nimport type { FluentiProviderProps, FluentiContext } from './types'\nimport type { FluentiInstance } from './create-fluenti'\nimport { createFluenti } from './create-fluenti'\nimport { setGlobalI18n } from './global-registry'\n\n/**\n * Internal provider that uses a pre-created `FluentiInstance`.\n */\nfunction InstanceProvider({ instance, children }: { instance: FluentiInstance; children: React.ReactNode }) {\n const ctx: FluentiContext = useMemo(\n () => ({\n t: instance.t,\n d: instance.d,\n n: instance.n,\n format: instance.format,\n loadMessages: instance.loadMessages,\n getLocales: instance.getLocales,\n locale: instance.locale,\n setLocale: instance.setLocale,\n isLoading: instance.isLoading,\n loadedLocales: instance.loadedLocales,\n preloadLocale: instance.preloadLocale,\n te: instance.te,\n tm: instance.tm,\n // Internal: used by __useI18n hook and compiled components — not part of public API\n i18n: instance.i18n,\n }) as FluentiContext,\n [instance],\n )\n\n return <I18nContext.Provider value={ctx}>{children}</I18nContext.Provider>\n}\n\n/**\n * Provides the Fluenti i18n context to the React component tree.\n *\n * Accepts either a `locale` + `messages` pair for inline configuration,\n * or a pre-created `instance` from `createFluenti()`.\n *\n * @example\n * ```tsx\n * import { I18nProvider, useI18n } from '@fluenti/react'\n * import messages from './locales/compiled/en.js'\n *\n * function App() {\n * return (\n * <I18nProvider locale=\"en\" messages={{ en: messages }}>\n * <Content />\n * </I18nProvider>\n * )\n * }\n *\n * function Content() {\n * const { t } = useI18n()\n * return <h1>{t`Welcome to our app`}</h1>\n * }\n * ```\n *\n * @example Using a pre-created instance\n * ```tsx\n * import { I18nProvider, createFluenti } from '@fluenti/react'\n * import messages from './locales/compiled/en.js'\n *\n * const i18n = createFluenti({ locale: 'en', messages: { en: messages } })\n *\n * function App() {\n * return (\n * <I18nProvider instance={i18n}>\n * <Content />\n * </I18nProvider>\n * )\n * }\n * ```\n */\nexport function I18nProvider(props: FluentiProviderProps) {\n if (props.instance) {\n return <InstanceProvider instance={props.instance}>{props.children}</InstanceProvider>\n }\n\n return <InlineProvider {...props} />\n}\n\n/**\n * Inline provider that delegates to `createFluenti()` for state management.\n */\nfunction InlineProvider({\n locale,\n fallbackLocale,\n messages,\n loadMessages,\n fallbackChain,\n dateFormats,\n numberFormats,\n missing,\n diagnostics,\n interpolate,\n children,\n}: FluentiProviderProps) {\n const instance = createFluenti({\n locale: locale ?? 'en',\n messages,\n loadMessages,\n fallbackLocale,\n fallbackChain,\n dateFormats,\n numberFormats,\n missing,\n diagnostics,\n interpolate,\n })\n\n // Set global i18n instance for webpack loader / vite plugin access\n useEffect(() => {\n setGlobalI18n(instance.i18n)\n }, [instance.i18n])\n\n return <InstanceProvider instance={instance}>{children}</InstanceProvider>\n}\n","import { useContext } from 'react'\nimport { I18nContext } from '../context'\nimport type { FluentiContext } from '../types'\n\n/**\n * Primary hook for accessing i18n functions.\n *\n * Returns locale, setLocale, isLoading, loadedLocales, preloadLocale,\n * and the underlying i18n instance with t(), d(), n() methods.\n *\n * @throws If used outside of `<I18nProvider>`\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error(\n '[fluenti] useI18n() must be used within an <I18nProvider>. ' +\n 'Wrap your app with <I18nProvider> to provide i18n context.',\n )\n }\n return ctx\n}\n\n/**\n * Shorthand hook that returns only the current locale string.\n *\n * @example\n * ```tsx\n * const locale = useLocale() // 'en'\n * ```\n */\nexport function useLocale(): string {\n return useI18n().locale\n}\n","import type { CompileTimeT } from '@fluenti/core'\n\nexport const t: CompileTimeT = ((..._args: unknown[]) => {\n throw new Error(\n \"[fluenti] `t` imported from '@fluenti/react' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside a component or custom hook. ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":"0MAgFA,SAAS,EAAe,EAAgE,CACtF,IAAM,EAAmC,EAAE,CAC3C,IAAK,GAAM,CAAC,EAAQ,KAAS,OAAO,QAAQ,EAAY,CACtD,EAAO,GAAU,OAAO,GAAS,UAAY,GAAiB,YAAa,EACtE,EAA+B,QAChC,EAEN,OAAO,EAyBT,SAAgB,EAAc,EAAwC,CACpE,GAAM,CACJ,OAAQ,EACR,SAAU,EACV,aAAc,EACd,iBACA,gBACA,cACA,gBACA,UACA,cACA,eACE,EAEE,CAAC,EAAe,IAAA,EAAA,EAAA,UAA6B,EAAc,CAC3D,CAAC,EAAW,IAAA,EAAA,EAAA,UAAyB,GAAM,CAC3C,CAAC,EAAgB,IAA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EAAM,SAA4B,CAAA,EAGjF,EAAA,EAAA,KAAC,EAAD,CAAgB,GAAI,EAAS,CAAA,CAMtC,SAAS,EAAe,CACtB,SACA,iBACA,WACA,eACA,gBACA,cACA,gBACA,UACA,cACA,cACA,YACuB,CACvB,IAAM,EAAW,EAAc,CAC7B,OAAQ,GAAU,KAClB,WACA,eACA,iBACA,gBACA,cACA,gBACA,UACA,cACA,cACD,CAAC,CAOF,OAJA,EAAA,EAAA,eAAgB,CACd,EAAc,EAAS,KAAK,EAC3B,CAAC,EAAS,KAAK,CAAC,EAEZ,EAAA,EAAA,KAAC,EAAD,CAA4B,WAAW,WAA4B,CAAA,CC1G5E,SAAgB,GAA0B,CACxC,IAAM,GAAA,EAAA,EAAA,YAAiB,EAAA,EAAY,CACnC,GAAI,CAAC,EACH,MAAU,MACR,wHAED,CAEH,OAAO,EAWT,SAAgB,GAAoB,CAClC,OAAO,GAAS,CAAC,OC9BnB,IAAa,IAAoB,GAAG,IAAqB,CACvD,MAAU,MACR,iMAGD"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/create-fluenti.ts","../src/global-registry.ts","../src/provider.tsx","../src/hooks/useI18n.ts","../src/compile-time-t.ts"],"sourcesContent":["import { useState, useCallback, useEffect, useMemo, useRef } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull as FluentInstanceExtended,\n CompiledMessage,\n Locale,\n Messages,\n AllMessages,\n DateFormatOptions,\n NumberFormatOptions,\n LocalizedString,\n MessageDescriptor,\n} from '@fluenti/core'\n\n/**\n * Configuration for `createFluenti()`.\n */\nexport interface FluentiConfig {\n /** Active locale code */\n locale: string\n /** Static message catalogs keyed by locale */\n messages?: AllMessages | undefined\n /** Async loader for lazy-loading locale messages */\n loadMessages?: ((locale: string) => Promise<Messages | { default: Messages }>) | undefined\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string | undefined\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, string[]> | undefined\n /** Date format styles */\n dateFormats?: DateFormatOptions | undefined\n /** Number format styles */\n numberFormats?: NumberFormatOptions | undefined\n /** Missing message handler */\n missing?: ((locale: Locale, id: string) => string | undefined) | undefined\n /** Runtime diagnostics (pre-created instance or config) */\n diagnostics?: unknown | undefined\n /** Custom interpolation function for full ICU support at runtime */\n interpolate?: ((message: string, values: Record<string, unknown> | undefined, locale: string, formatters?: Record<string, unknown>) => string) | undefined\n}\n\n/**\n * The object returned by `createFluenti()`.\n *\n * Contains all i18n state and methods. Pass to `<I18nProvider instance={...}>`\n * or use directly in tests/non-React contexts.\n */\nexport interface FluentiInstance {\n /** Translate a message by id with optional interpolation values */\n t: {\n (id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n (strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n }\n /** Format a date value for the current locale */\n d: (value: Date | number, style?: string) => LocalizedString\n /** Format a number value for the current locale */\n n: (value: number, style?: string) => LocalizedString\n /** Current locale */\n locale: string\n /** Change the active locale (async when lazy loading) */\n setLocale: (locale: string) => Promise<void>\n /** Whether a locale is currently being loaded */\n isLoading: boolean\n /** Preload a locale in the background without switching to it */\n preloadLocale: (locale: string) => Promise<void>\n /** Check whether a translation key exists for the given or current locale */\n te: (key: string, locale?: string) => boolean\n /** Get the raw compiled message for a key without interpolation */\n tm: (key: string, locale?: string) => CompiledMessage | undefined\n /** The underlying Fluent instance (escape hatch for advanced use) */\n i18n: FluentInstanceExtended\n /** Format an ICU message string directly (no catalog lookup) */\n format: (message: string, values?: Record<string, unknown>) => LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages: (locale: string, messages: Messages) => void\n /** Return all locale codes that have loaded messages */\n getLocales: () => string[]\n /** Set of locales whose messages have been loaded */\n loadedLocales: string[]\n}\n\nfunction unwrapMessages(allMessages: Record<string, unknown>): Record<string, Messages> {\n const result: Record<string, Messages> = {}\n for (const [locale, msgs] of Object.entries(allMessages)) {\n result[locale] = typeof msgs === 'object' && msgs !== null && 'default' in msgs\n ? (msgs as { default: Messages }).default\n : msgs as Messages\n }\n return result\n}\n\n/**\n * Create a standalone Fluenti i18n instance.\n *\n * This is a React hook that manages locale state, message loading, and\n * provides all i18n methods. The returned instance can be passed to\n * `<I18nProvider instance={...}>` to share it with the component tree.\n *\n * @example\n * ```tsx\n * function App() {\n * const i18n = createFluenti({\n * locale: 'en',\n * messages: { en: enMessages, fr: frMessages },\n * })\n * return (\n * <I18nProvider instance={i18n}>\n * <MyApp />\n * </I18nProvider>\n * )\n * }\n * ```\n */\nexport function createFluenti(config: FluentiConfig): FluentiInstance {\n const {\n locale: initialLocale,\n messages: initialMessages,\n loadMessages: loadMessagesFn,\n fallbackLocale,\n fallbackChain,\n dateFormats,\n numberFormats,\n missing,\n diagnostics,\n interpolate,\n } = config\n\n const [currentLocale, setCurrentLocale] = useState(initialLocale)\n const [isLoading, setIsLoading] = useState(false)\n const [loadedMessages, setLoadedMessages] = useState<Record<string, Messages>>(\n initialMessages ? unwrapMessages(initialMessages) : {},\n )\n const [loadedLocales, setLoadedLocales] = useState<string[]>(\n initialMessages ? Object.keys(initialMessages) : [],\n )\n\n const loadedMessagesRef = useRef(loadedMessages)\n loadedMessagesRef.current = loadedMessages\n\n const localeRequestRef = useRef(0)\n\n // Split runtime integration (for Vite plugin code splitting)\n const SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.react.v1')\n function getSplitRuntime(): { __switchLocale?: (l: string) => Promise<void>; __preloadLocale?: (l: string) => Promise<void> } | null {\n const rt = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof rt === 'object' && rt !== null ? rt as any : null\n }\n\n const i18n = useMemo(() => {\n const cfg: Parameters<typeof createFluentiCore>[0] = {\n locale: currentLocale,\n messages: loadedMessages,\n }\n if (fallbackLocale !== undefined) cfg.fallbackLocale = fallbackLocale\n if (fallbackChain !== undefined) cfg.fallbackChain = fallbackChain\n if (dateFormats !== undefined) cfg.dateFormats = dateFormats\n if (numberFormats !== undefined) cfg.numberFormats = numberFormats\n if (missing !== undefined) cfg.missing = missing\n if (diagnostics !== undefined) cfg.diagnostics = diagnostics as Parameters<typeof createFluentiCore>[0]['diagnostics']\n if (interpolate !== undefined) cfg.interpolate = interpolate\n cfg.devWarnings = cfg.devWarnings ?? (typeof process !== 'undefined' && process.env?.['NODE_ENV'] === 'development')\n return createFluentiCore(cfg)\n }, [currentLocale, loadedMessages, fallbackLocale, fallbackChain, dateFormats, numberFormats, missing, diagnostics, interpolate])\n\n // Sync external locale changes\n useEffect(() => {\n if (initialLocale !== currentLocale) {\n void handleSetLocale(initialLocale)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [initialLocale])\n\n const handleSetLocale = useCallback(\n async (newLocale: string) => {\n const requestId = ++localeRequestRef.current\n\n const splitRuntime = loadMessagesFn ? getSplitRuntime() : null\n\n if (loadedMessagesRef.current[newLocale] && !loadMessagesFn) {\n setCurrentLocale(newLocale)\n return\n }\n\n if (loadedMessagesRef.current[newLocale]) {\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n setCurrentLocale(newLocale)\n return\n }\n\n if (!loadMessagesFn) {\n console.warn(\n `[fluenti] No messages for locale \"${newLocale}\" and no loadMessages function provided`,\n )\n return\n }\n\n setIsLoading(true)\n try {\n const msgs = await loadMessagesFn(newLocale)\n if (requestId !== localeRequestRef.current) return\n\n const resolved: Messages =\n typeof msgs === 'object' && msgs !== null && 'default' in msgs\n ? (msgs as { default: Messages }).default\n : (msgs as Messages)\n try {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n } catch (e) {\n console.warn(`[fluenti] split runtime switch failed for locale \"${newLocale}\"`, e)\n }\n if (requestId !== localeRequestRef.current) return\n setLoadedMessages((prev) => ({ ...prev, [newLocale]: resolved }))\n setLoadedLocales((prev) => [...new Set([...prev, newLocale])])\n setCurrentLocale(newLocale)\n } catch (err) {\n if (requestId === localeRequestRef.current) {\n console.error(`[fluenti] Failed to load locale \"${newLocale}\"`, err)\n }\n } finally {\n if (requestId === localeRequestRef.current) {\n setIsLoading(false)\n }\n }\n },\n [loadMessagesFn],\n )\n\n const preloadLocale = useCallback(\n async (loc: string) => {\n if (loadedMessagesRef.current[loc] || !loadMessagesFn) return\n try {\n const msgs = await loadMessagesFn(loc)\n const resolved: Messages =\n typeof msgs === 'object' && msgs !== null && 'default' in msgs\n ? (msgs as { default: Messages }).default\n : (msgs as Messages)\n setLoadedMessages((prev) => ({ ...prev, [loc]: resolved }))\n setLoadedLocales((prev) => [...new Set([...prev, loc])])\n const splitRuntime = getSplitRuntime()\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n } catch {\n // Silent fail for preload\n }\n },\n [loadMessagesFn],\n )\n\n const te = useCallback(\n (key: string, loc?: string): boolean => {\n const msgs = loadedMessages[loc ?? currentLocale]\n return msgs !== undefined && key in msgs\n },\n [loadedMessages, currentLocale],\n )\n\n const tm = useCallback(\n (key: string, loc?: string): Messages[string] | undefined => {\n const msgs = loadedMessages[loc ?? currentLocale]\n if (!msgs) return undefined\n return msgs[key]\n },\n [loadedMessages, currentLocale],\n )\n\n return useMemo(\n () => ({\n t: i18n.t.bind(i18n),\n d: i18n.d.bind(i18n),\n n: i18n.n.bind(i18n),\n locale: currentLocale,\n setLocale: handleSetLocale,\n isLoading,\n preloadLocale,\n te,\n tm,\n i18n,\n format: i18n.format.bind(i18n),\n loadMessages: i18n.loadMessages.bind(i18n),\n getLocales: i18n.getLocales.bind(i18n),\n loadedLocales,\n }),\n [i18n, currentLocale, handleSetLocale, isLoading, preloadLocale, te, tm, loadedLocales],\n )\n}\n","import type { FluentiCoreInstanceFull } from '@fluenti/core'\n\n/**\n * Global i18n instance registry.\n *\n * Used by `@fluenti/next` webpack loader and `@fluenti/vite-plugin` to access\n * the i18n instance from module-level code via a Proxy. The instance is set by\n * `<I18nProvider>` on mount.\n */\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __fluenti_i18n: FluentiCoreInstanceFull | undefined\n}\n\n/** Get the global i18n instance (set by `<I18nProvider>`). */\nexport function getGlobalI18n(): FluentiCoreInstanceFull | undefined {\n return globalThis.__fluenti_i18n\n}\n\n/** Set the global i18n instance. Called by `<I18nProvider>` on mount. */\nexport function setGlobalI18n(instance: FluentiCoreInstanceFull): void {\n globalThis.__fluenti_i18n = instance\n}\n\n/** Clear the global i18n instance. Primarily for testing. */\nexport function clearGlobalI18n(): void {\n globalThis.__fluenti_i18n = undefined\n}\n","import { useEffect, useMemo } from 'react'\nimport { I18nContext } from './context'\nimport type { FluentiProviderProps, FluentiContext } from './types'\nimport type { FluentiInstance } from './create-fluenti'\nimport { createFluenti } from './create-fluenti'\nimport { setGlobalI18n } from './global-registry'\n\n/**\n * Internal provider that uses a pre-created `FluentiInstance`.\n */\nfunction InstanceProvider({ instance, children }: { instance: FluentiInstance; children: React.ReactNode }) {\n const ctx: FluentiContext = useMemo(\n () => ({\n t: instance.t,\n d: instance.d,\n n: instance.n,\n format: instance.format,\n loadMessages: instance.loadMessages,\n getLocales: instance.getLocales,\n locale: instance.locale,\n setLocale: instance.setLocale,\n isLoading: instance.isLoading,\n loadedLocales: instance.loadedLocales,\n preloadLocale: instance.preloadLocale,\n te: instance.te,\n tm: instance.tm,\n // Internal: used by __useI18n hook and compiled components — not part of public API\n i18n: instance.i18n,\n }) as FluentiContext,\n [instance],\n )\n\n return <I18nContext.Provider value={ctx}>{children}</I18nContext.Provider>\n}\n\n/**\n * Provides the Fluenti i18n context to the React component tree.\n *\n * Accepts either a `locale` + `messages` pair for inline configuration,\n * or a pre-created `instance` from `createFluenti()`.\n *\n * @example\n * ```tsx\n * import { I18nProvider, useI18n } from '@fluenti/react'\n * import messages from './locales/compiled/en.js'\n *\n * function App() {\n * return (\n * <I18nProvider locale=\"en\" messages={{ en: messages }}>\n * <Content />\n * </I18nProvider>\n * )\n * }\n *\n * function Content() {\n * const { t } = useI18n()\n * return <h1>{t`Welcome to our app`}</h1>\n * }\n * ```\n *\n * @example Using a pre-created instance\n * ```tsx\n * import { I18nProvider, createFluenti } from '@fluenti/react'\n * import messages from './locales/compiled/en.js'\n *\n * const i18n = createFluenti({ locale: 'en', messages: { en: messages } })\n *\n * function App() {\n * return (\n * <I18nProvider instance={i18n}>\n * <Content />\n * </I18nProvider>\n * )\n * }\n * ```\n */\nexport function I18nProvider(props: FluentiProviderProps) {\n if (props.instance) {\n return <InstanceProvider instance={props.instance}>{props.children}</InstanceProvider>\n }\n\n return <InlineProvider {...props} />\n}\n\n/**\n * Inline provider that delegates to `createFluenti()` for state management.\n */\nfunction InlineProvider({\n locale,\n fallbackLocale,\n messages,\n loadMessages,\n fallbackChain,\n dateFormats,\n numberFormats,\n missing,\n diagnostics,\n interpolate,\n children,\n}: FluentiProviderProps) {\n const instance = createFluenti({\n locale: locale ?? 'en',\n messages,\n loadMessages,\n fallbackLocale,\n fallbackChain,\n dateFormats,\n numberFormats,\n missing,\n diagnostics,\n interpolate,\n })\n\n // Set global i18n instance for webpack loader / vite plugin access\n useEffect(() => {\n setGlobalI18n(instance.i18n)\n }, [instance.i18n])\n\n return <InstanceProvider instance={instance}>{children}</InstanceProvider>\n}\n","import { useContext } from 'react'\nimport { I18nContext } from '../context'\nimport type { FluentiContext } from '../types'\n\n/**\n * Primary hook for accessing i18n functions.\n *\n * Returns locale, setLocale, isLoading, loadedLocales, preloadLocale,\n * and the underlying i18n instance with t(), d(), n() methods.\n *\n * @throws If used outside of `<I18nProvider>`\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nContext)\n if (!ctx) {\n throw new Error(\n '[fluenti] useI18n() must be used within an <I18nProvider>. ' +\n 'Wrap your app with <I18nProvider> to provide i18n context.',\n )\n }\n return ctx\n}\n\n/**\n * Shorthand hook that returns only the current locale string.\n *\n * @example\n * ```tsx\n * const locale = useLocale() // 'en'\n * ```\n */\nexport function useLocale(): string {\n return useI18n().locale\n}\n","import type { CompileTimeT } from '@fluenti/core'\n\nexport const t: CompileTimeT = ((..._args: unknown[]) => {\n throw new Error(\n \"[fluenti] `t` imported from '@fluenti/react' is a compile-time API. \" +\n 'Use it only with the Fluenti build transform inside a component or custom hook. ' +\n 'For runtime lookups, use useI18n().t(...).',\n )\n}) as CompileTimeT\n"],"mappings":";;;;;;AAgFA,SAAS,EAAe,GAAgE;CACtF,IAAM,IAAmC,EAAE;AAC3C,MAAK,IAAM,CAAC,GAAQ,MAAS,OAAO,QAAQ,EAAY,CACtD,GAAO,KAAU,OAAO,KAAS,YAAY,KAAiB,aAAa,IACtE,EAA+B,UAChC;AAEN,QAAO;;AAyBT,SAAgB,EAAc,GAAwC;CACpE,IAAM,EACJ,QAAQ,GACR,UAAU,GACV,cAAc,GACd,mBACA,kBACA,gBACA,kBACA,YACA,gBACA,mBACE,GAEE,CAAC,GAAe,KAAoB,EAAS,EAAc,EAC3D,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAgB,KAAqB,EAC1C,IAAkB,EAAe,EAAgB,GAAG,EAAE,CACvD,EACK,CAAC,GAAe,KAAoB,EACxC,IAAkB,OAAO,KAAK,EAAgB,GAAG,EAAE,CACpD,EAEK,IAAoB,EAAO,EAAe;AAChD,GAAkB,UAAU;CAE5B,IAAM,IAAmB,EAAO,EAAE,EAG5B,IAAoB,OAAO,IAAI,2BAA2B;CAChE,SAAS,IAA4H;EACnI,IAAM,IAAM,WAA4C;AACxD,SAAO,OAAO,KAAO,YAAY,IAAc,IAAY;;CAG7D,IAAM,IAAO,QAAc;EACzB,IAAM,IAA+C;GACnD,QAAQ;GACR,UAAU;GACX;AASD,SARI,MAAmB,KAAA,MAAW,EAAI,iBAAiB,IACnD,MAAkB,KAAA,MAAW,EAAI,gBAAgB,IACjD,MAAgB,KAAA,MAAW,EAAI,cAAc,IAC7C,MAAk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","sourceRoot":"","sources":["../../../src/compile-time-t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,eAAO,MAAM,CAAC,EAAE,YAME,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,4DAMnB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../../../src/components/Number.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,+BAA+B;AAC/B,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAA;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,yDAMvB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../../../src/components/Plural.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAMxD,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,SAAS,CAAA;IACf,+BAA+B;IAC/B,GAAG,CAAC,EAAE,SAAS,CAAA;IACf,wCAAwC;IACxC,GAAG,CAAC,EAAE,SAAS,CAAA;IACf,gBAAgB;IAChB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,0BAA0B;IAC1B,KAAK,EAAE,SAAS,CAAA;IAChB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,0DA4DjB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/components/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAKvE,MAAM,WAAW,kBAAkB;IACjC,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mBAAmB;IACnB,KAAK,EAAE,SAAS,CAAA;IAChB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACnC,wFAAwF;IACxF,GAAG,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAA;IACvC,uDAAuD;IACvD,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAA;CACrG;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,0DAwDjB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Trans.d.ts","sourceRoot":"","sources":["../../../../src/components/Trans.tsx"],"names":[],"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wBAAwB,CACtC,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,MAAM,CAER;AAMD,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,CAAC,cAAc,EAAE,SAAS,GAAG,SAAS,CAAC,EACpD,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,GAC3C;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,SAAS,CAgBnE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plural-core.d.ts","sourceRoot":"","sources":["../../../../src/components/plural-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAE9E;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,cAAc,CAKhB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAKzE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"trans-core.d.ts","sourceRoot":"","sources":["../../../../src/components/trans-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,WAAW,EAAiB,MAAM,uBAAuB,CAAA;AAElE,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,GAAG;IACnD,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,YAAY,EAAE,CAAA;CAC3B,CA4BA;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,YAAY,EAAE,GACzB,SAAS,CA0DX"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-entry.d.ts","sourceRoot":"","sources":["../../../src/components-entry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,uBAAuB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,WAAW,gDAA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,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,eAAe,CAAA;IAC9E,iEAAiE;IACjE,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC1D,wDAAwD;IACxD,UAAU,EAAE,MAAM,MAAM,EAAE,CAAA;IAC1B,qDAAqD;IACrD,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAYD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,eAAe,CAoLpE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"global-registry.d.ts","sourceRoot":"","sources":["../../../src/global-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAE5D;;;;;;GAMG;AAEH,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,cAAc,EAAE,uBAAuB,GAAG,SAAS,CAAA;CACxD;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,IAAI,uBAAuB,GAAG,SAAS,CAEnE;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,uBAAuB,GAAG,IAAI,CAErE;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"__useI18n.d.ts","sourceRoot":"","sources":["../../../../src/hooks/__useI18n.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAE5D;;;;;;;;GAQG;AACH,wBAAgB,SAAS,IAAI,uBAAuB,CAUnD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useI18n.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAA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EACN,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"msg.d.ts","sourceRoot":"","sources":["../../../src/msg.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAkB,MAAM,SAAS,CAAA;AAiCnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,oBAAoB,2CAMvD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-runtime.d.ts","sourceRoot":"","sources":["../../../src/react-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,eAAO,MAAM,qBAAqB,EAAE,gBAUlC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAA2B,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAMlF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK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E,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;IAC5I,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,kBAAkB,EAAE,eAAe,CAAA;CACtD;AAED,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAA;AAEpD,YAAY,EACV,MAAM,EACN,eAAe,EACf,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,4BAA4B,EAC5B,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACpB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,YAAY,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAM7E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.cjs","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { cache } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull,\n FluentiCoreConfigFull,\n Locale,\n Messages,\n DateFormatOptions,\n NumberFormatOptions,\n} from '@fluenti/core'\nimport { hashMessage as hashSyntheticMessage } from '@fluenti/core/runtime'\nimport { createElement, Fragment, type ReactNode, type ReactElement } from 'react'\nimport { hashMessage, extractMessage, reconstruct } from './components/trans-core'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './components/plural-core'\nimport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './components/icu-rich'\n\n// Re-export SSR utilities from core for convenience\nexport { detectLocale, getSSRLocaleScript, getHydratedLocale } from '@fluenti/core/ssr'\nexport type { DetectLocaleOptions } from '@fluenti/core/ssr'\nexport { isRTL, getDirection } from '@fluenti/core'\n\n/**\n * Configuration for `createServerI18n`.\n */\nexport interface ServerI18nConfig {\n /** Load messages for a given locale. Called once per locale per request. */\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string\n /**\n * Auto-resolve locale when `setLocale()` was not called.\n *\n * This is the fallback for contexts where the layout doesn't run — most\n * notably **Server Actions** (`'use server'`), which are independent\n * requests that skip the layout tree entirely.\n *\n * Common patterns:\n * - Read from a cookie (Next.js: `cookies().get('locale')`)\n * - Read from a request header set by middleware\n * - Query the database for the authenticated user's preference\n *\n * If omitted and `setLocale()` was not called, `getI18n()` will throw.\n *\n * @example\n * ```ts\n * resolveLocale: async () => {\n * const { cookies } = await import('next/headers')\n * return (await cookies()).get('locale')?.value ?? 'en'\n * }\n * ```\n */\n resolveLocale?: () => string | Promise<string>\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, Locale[]>\n /** Custom date format styles */\n dateFormats?: DateFormatOptions\n /** Custom number format styles */\n numberFormats?: NumberFormatOptions\n /** Handler for missing translation keys */\n missing?: (locale: Locale, id: string) => string | undefined\n /**\n * Custom interpolation function for ICU MessageFormat parsing.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/runtime` for runtime\n * ICU MessageFormat parsing (plurals, selects, nested arguments).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/runtime'\n * createServerI18n({ interpolate, ... })\n * ```\n */\n interpolate?: FluentiCoreConfigFull['interpolate']\n}\n\n// ─── Server Component Props ──────────────────────────────────────────────────\n\nexport interface ServerTransProps {\n /** Source text with embedded components */\n children: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n}\n\nexport interface ServerPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\nexport interface ServerSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}\n\nexport interface ServerDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\nexport interface ServerNumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n// ─── Server Component Types ──────────────────────────────────────────────────\n\ntype ServerTransComponent = (props: ServerTransProps) => Promise<ReactElement>\ntype ServerPluralComponent = (props: ServerPluralProps) => Promise<ReactElement>\ntype ServerSelectComponent = (props: ServerSelectProps) => Promise<ReactElement>\ntype ServerDateTimeComponent = (props: ServerDateTimeProps) => Promise<ReactElement>\ntype ServerNumberComponent = (props: ServerNumberProps) => Promise<ReactElement>\n\n/**\n * The object returned by `createServerI18n`.\n */\nexport interface ServerI18n {\n /**\n * Set the locale for the current server request.\n * Call this once in your root layout or page before any `getI18n()` calls.\n *\n * Uses `React.cache()` — scoped to the current request automatically.\n */\n setLocale: (locale: string) => void\n\n /**\n * Get a fully configured i18n instance for the current request.\n * Messages are loaded lazily and cached per-request.\n *\n * @example\n * ```tsx\n * // In any Server Component\n * const { t, d, n, locale } = await getI18n()\n * return <h1>{t('welcome')}</h1>\n * ```\n */\n getI18n: () => Promise<FluentiCoreInstanceFull & { locale: string }>\n\n /**\n * `<Trans>` for React Server Components.\n * Async component — automatically resolves the i18n instance.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * ```\n */\n Trans: ServerTransComponent\n\n /**\n * `<Plural>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Plural value={count} one=\"# item\" other=\"# items\" />\n * ```\n */\n Plural: ServerPluralComponent\n\n /**\n * `<Select>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Select value={gender} male=\"He liked this\" other=\"They liked this\" />\n * ```\n */\n Select: ServerSelectComponent\n\n /**\n * `<DateTime>` for React Server Components.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\n DateTime: ServerDateTimeComponent\n\n /**\n * `<NumberFormat>` for React Server Components.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\n NumberFormat: ServerNumberComponent\n\n /**\n * Check if a translation key exists in the catalog.\n * Optionally check a specific locale instead of the current one.\n */\n te: (key: string, locale?: string) => Promise<boolean>\n\n /**\n * Get the raw compiled message without interpolation.\n * Optionally look up in a specific locale instead of the current one.\n */\n tm: (key: string, locale?: string) => Promise<Messages[string] | undefined>\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used internally by @fluenti/next webpack loader.\n * @internal\n */\n __getSyncInstance: () => FluentiCoreInstanceFull & { locale: string }\n}\n\n/**\n * Create server-side i18n utilities for React Server Components.\n *\n * Uses `React.cache()` to share state within a single server request\n * without React Context (which is unavailable in Server Components).\n *\n * @example\n * ```ts\n * // lib/i18n.server.ts — define once\n * import { createServerI18n } from '@fluenti/react/server'\n *\n * export const { setLocale, getI18n, Trans, Plural, Select, DateTime, NumberFormat } = createServerI18n({\n * loadMessages: (locale) => import(`../messages/${locale}.json`),\n * fallbackLocale: 'en',\n * })\n * ```\n *\n * ```tsx\n * // app/[locale]/layout.tsx — set locale once\n * import { setLocale } from '@/lib/i18n.server'\n *\n * export default async function Layout({ params, children }) {\n * const { locale } = await params\n * setLocale(locale)\n * return <html lang={locale}><body>{children}</body></html>\n * }\n * ```\n *\n * ```tsx\n * // app/[locale]/page.tsx — use Trans, Plural, etc. directly\n * import { Trans, Plural, Select } from '@/lib/i18n.server'\n *\n * export default async function Page() {\n * return (\n * <div>\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * <Plural value={5} one=\"# item\" other=\"# items\" />\n * <Select value=\"male\" male=\"He liked this\" other=\"They liked this\" />\n * </div>\n * )\n * }\n * ```\n */\nexport function createServerI18n(config: ServerI18nConfig): ServerI18n {\n // Request-scoped store using React.cache()\n // Each server request gets its own isolated state\n const getRequestStore = cache((): {\n locale: string | null\n instance: (FluentiCoreInstanceFull & { locale: string }) | null\n } => ({\n locale: null,\n instance: null,\n }))\n\n // Cache loaded messages per-request to avoid redundant imports\n const getMessageCache = cache((): Map<string, Messages> => new Map())\n\n // Module-level fallback for server actions where React.cache()\n // may not share state with the page render.\n let _lastInstance: (FluentiCoreInstanceFull & { locale: string }) | null = null\n let _requestId = 0\n let _lastRequestId = 0\n\n function setLocale(locale: string): void {\n getRequestStore().locale = locale\n _requestId++\n _lastInstance = null\n }\n\n async function loadLocaleMessages(locale: string): Promise<Messages> {\n const messageCache = getMessageCache()\n const cached = messageCache.get(locale)\n if (cached) return cached\n\n const raw = await config.loadMessages(locale)\n const messages: Messages =\n typeof raw === 'object' && raw !== null && 'default' in raw\n ? (raw as { default: Messages }).default\n : (raw as Messages)\n\n messageCache.set(locale, messages)\n return messages\n }\n\n async function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }> {\n const store = getRequestStore()\n\n // If setLocale() was never called (e.g. Server Action — independent request\n // that skips the layout), try the resolveLocale fallback.\n if (!store.locale && config.resolveLocale) {\n store.locale = await config.resolveLocale()\n }\n\n const locale = store.locale\n\n if (!locale) {\n throw new Error(\n '[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), ' +\n 'or provide a resolveLocale function in createServerI18n config to auto-detect locale ' +\n 'in Server Actions and other contexts where the layout does not run.',\n )\n }\n\n // Return cached instance if locale hasn't changed\n if (store.instance && store.instance.locale === locale) {\n return store.instance\n }\n\n // Load messages for current locale (and fallback if configured)\n const allMessages: Record<string, Messages> = {}\n allMessages[locale] = await loadLocaleMessages(locale)\n\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n allMessages[config.fallbackLocale] = await loadLocaleMessages(config.fallbackLocale)\n }\n\n const fluentConfig: FluentiCoreConfigFull = {\n locale,\n messages: allMessages,\n }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n _lastInstance = store.instance\n _lastRequestId = _requestId\n return store.instance\n }\n\n // ─── Async Server Components ─────────────────────────────────────────────\n\n async function Trans({ children, id, context, comment, render }: ServerTransProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const { message, components } = extractMessage(children)\n const messageId = id ?? hashMessage(message, context)\n const translated = i18n.t({\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n })\n const result = reconstruct(translated, components)\n return createElement(Fragment, null, render ? render(result) : result)\n }\n\n async function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n }: ServerPluralProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function Select({\n value,\n id,\n context,\n comment,\n other,\n options,\n ...cases\n }: ServerSelectProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: normalized.valueMap[value] ?? 'other' },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function DateTime({ value, format }: ServerDateTimeProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.d(value, format))\n }\n\n async function NumberFormat({ value, format }: ServerNumberProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.n(value, format))\n }\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used by @fluenti/next webpack loader for t`` in RSC.\n *\n * Falls back to creating a minimal instance from the message cache when the\n * React.cache() request store hasn't been populated yet — this handles\n * Suspense boundaries and streamed components where React.cache() state\n * may not propagate from the layout render into streamed children.\n * @internal\n */\n function __getSyncInstance(): FluentiCoreInstanceFull & { locale: string } {\n const store = getRequestStore()\n if (store.instance) {\n return store.instance\n }\n\n // Module-level fallback for server actions where React.cache()\n // may not share state across different call contexts.\n // Only use within the same request (tracked by _requestId).\n if (_lastInstance && _lastRequestId === _requestId) {\n return _lastInstance\n }\n\n // Final fallback: create instance synchronously with the default locale.\n // This handles Suspense boundaries and streamed components where\n // the React.cache store may not have been populated yet.\n const locale = store.locale ?? config.fallbackLocale ?? 'en'\n const messageCache = getMessageCache()\n const messages: Record<string, Messages> = {}\n const cached = messageCache.get(locale)\n if (cached) messages[locale] = cached\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n const fallback = messageCache.get(config.fallbackLocale)\n if (fallback) messages[config.fallbackLocale] = fallback\n }\n\n const fluentConfig: FluentiCoreConfigFull = { locale, messages }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n return store.instance\n }\n\n /**\n * Check if a translation key exists in the catalog for the given (or current) locale.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function te(key: string, locale?: string): Promise<boolean> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key] !== undefined\n }\n\n /**\n * Get the raw compiled message for the given key without interpolation.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function tm(key: string, locale?: string): Promise<Messages[string] | undefined> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key]\n }\n\n return { setLocale, getI18n, __getSyncInstance, te, tm, Trans, Plural, Select, DateTime, NumberFormat }\n}\n"],"mappings":"kOAsSA,SAAgB,EAAiB,EAAsC,CAGrE,IAAM,GAAA,EAAA,EAAA,YAGA,CACJ,OAAQ,KACR,SAAU,KACX,EAAE,CAGG,GAAA,EAAA,EAAA,WAAqD,IAAI,IAAM,CAIjE,EAAuE,KACvE,EAAa,EACb,EAAiB,EAErB,SAAS,EAAU,EAAsB,CACvC,GAAiB,CAAC,OAAS,EAC3B,IACA,EAAgB,KAGlB,eAAe,EAAmB,EAAmC,CACnE,IAAM,EAAe,GAAiB,CAChC,EAAS,EAAa,IAAI,EAAO,CACvC,GAAI,EAAQ,OAAO,EAEnB,IAAM,EAAM,MAAM,EAAO,aAAa,EAAO,CACvC,EACJ,OAAO,GAAQ,UAAY,GAAgB,YAAa,EACnD,EAA8B,QAC9B,EAGP,OADA,EAAa,IAAI,EAAQ,EAAS,CAC3B,EAGT,eAAe,GAAiE,CAC9E,IAAM,EAAQ,GAAiB,CAI3B,CAAC,EAAM,QAAU,EAAO,gBAC1B,EAAM,OAAS,MAAM,EAAO,eAAe,EAG7C,IAAM,EAAS,EAAM,OAErB,GAAI,CAAC,EACH,MAAU,MACR,kPAGD,CAIH,GAAI,EAAM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EAAO,iBAAmB,IAAA,KAAW,EAAa,eAAiB,EAAO,gBAC1E,EAAO,gBAAkB,IAAA,KAAW,EAAa,cAAgB,EAAO,eACxE,EAAO,cAAgB,IAAA,KAAW,EAAa,YAAc,EAAO,aACpE,EAAO,gBAAkB,IAAA,KAAW,EAAa,cAAgB,EAAO,eACxE,EAAO,UAAY,IAAA,KAAW,EAAa,QAAU,EAAO,SAC5D,EAAO,cAAgB,IAAA,KAAW,EAAa,YAAc,EAAO,aAExE,EAAM,UAAA,EAAA,EAAA,mBAA6B,EAAa,CACzC,EAAM,SAOf,eAAe,EAAG,EAAa,EAAmC,CAChE,IAAM,EAAO,MAAM,GAAS,CAG5B,OADa,MAAM,EADE,GAAU,EAAK,OACe,EACvC,KAAS,IAAA,GAOvB,eAAe,EAAG,EAAa,EAAwD,CACrF,IAAM,EAAO,MAAM,GAAS,CAG5B,OADa,MAAM,EADE,GAAU,EAAK,OACe,EACvC,GAGd,MAAO,CAAE,YAAW,UAAS,oBAAmB,KAAI,KAAI,QAAO,SAAQ,SAAQ,WAAU,eAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { cache } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull,\n FluentiCoreConfigFull,\n Locale,\n Messages,\n DateFormatOptions,\n NumberFormatOptions,\n} from '@fluenti/core'\nimport { hashMessage as hashSyntheticMessage } from '@fluenti/core/runtime'\nimport { createElement, Fragment, type ReactNode, type ReactElement } from 'react'\nimport { hashMessage, extractMessage, reconstruct } from './components/trans-core'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './components/plural-core'\nimport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './components/icu-rich'\n\n// Re-export SSR utilities from core for convenience\nexport { detectLocale, getSSRLocaleScript, getHydratedLocale } from '@fluenti/core/ssr'\nexport type { DetectLocaleOptions } from '@fluenti/core/ssr'\nexport { isRTL, getDirection } from '@fluenti/core'\n\n/**\n * Configuration for `createServerI18n`.\n */\nexport interface ServerI18nConfig {\n /** Load messages for a given locale. Called once per locale per request. */\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string\n /**\n * Auto-resolve locale when `setLocale()` was not called.\n *\n * This is the fallback for contexts where the layout doesn't run — most\n * notably **Server Actions** (`'use server'`), which are independent\n * requests that skip the layout tree entirely.\n *\n * Common patterns:\n * - Read from a cookie (Next.js: `cookies().get('locale')`)\n * - Read from a request header set by middleware\n * - Query the database for the authenticated user's preference\n *\n * If omitted and `setLocale()` was not called, `getI18n()` will throw.\n *\n * @example\n * ```ts\n * resolveLocale: async () => {\n * const { cookies } = await import('next/headers')\n * return (await cookies()).get('locale')?.value ?? 'en'\n * }\n * ```\n */\n resolveLocale?: () => string | Promise<string>\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, Locale[]>\n /** Custom date format styles */\n dateFormats?: DateFormatOptions\n /** Custom number format styles */\n numberFormats?: NumberFormatOptions\n /** Handler for missing translation keys */\n missing?: (locale: Locale, id: string) => string | undefined\n /**\n * Custom interpolation function for ICU MessageFormat parsing.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/runtime` for runtime\n * ICU MessageFormat parsing (plurals, selects, nested arguments).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/runtime'\n * createServerI18n({ interpolate, ... })\n * ```\n */\n interpolate?: FluentiCoreConfigFull['interpolate']\n}\n\n// ─── Server Component Props ──────────────────────────────────────────────────\n\nexport interface ServerTransProps {\n /** Source text with embedded components */\n children: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n}\n\nexport interface ServerPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\nexport interface ServerSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}\n\nexport interface ServerDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\nexport interface ServerNumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n// ─── Server Component Types ──────────────────────────────────────────────────\n\ntype ServerTransComponent = (props: ServerTransProps) => Promise<ReactElement>\ntype ServerPluralComponent = (props: ServerPluralProps) => Promise<ReactElement>\ntype ServerSelectComponent = (props: ServerSelectProps) => Promise<ReactElement>\ntype ServerDateTimeComponent = (props: ServerDateTimeProps) => Promise<ReactElement>\ntype ServerNumberComponent = (props: ServerNumberProps) => Promise<ReactElement>\n\n/**\n * The object returned by `createServerI18n`.\n */\nexport interface ServerI18n {\n /**\n * Set the locale for the current server request.\n * Call this once in your root layout or page before any `getI18n()` calls.\n *\n * Uses `React.cache()` — scoped to the current request automatically.\n */\n setLocale: (locale: string) => void\n\n /**\n * Get a fully configured i18n instance for the current request.\n * Messages are loaded lazily and cached per-request.\n *\n * @example\n * ```tsx\n * // In any Server Component\n * const { t, d, n, locale } = await getI18n()\n * return <h1>{t('welcome')}</h1>\n * ```\n */\n getI18n: () => Promise<FluentiCoreInstanceFull & { locale: string }>\n\n /**\n * `<Trans>` for React Server Components.\n * Async component — automatically resolves the i18n instance.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * ```\n */\n Trans: ServerTransComponent\n\n /**\n * `<Plural>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Plural value={count} one=\"# item\" other=\"# items\" />\n * ```\n */\n Plural: ServerPluralComponent\n\n /**\n * `<Select>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Select value={gender} male=\"He liked this\" other=\"They liked this\" />\n * ```\n */\n Select: ServerSelectComponent\n\n /**\n * `<DateTime>` for React Server Components.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\n DateTime: ServerDateTimeComponent\n\n /**\n * `<NumberFormat>` for React Server Components.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\n NumberFormat: ServerNumberComponent\n\n /**\n * Check if a translation key exists in the catalog.\n * Optionally check a specific locale instead of the current one.\n */\n te: (key: string, locale?: string) => Promise<boolean>\n\n /**\n * Get the raw compiled message without interpolation.\n * Optionally look up in a specific locale instead of the current one.\n */\n tm: (key: string, locale?: string) => Promise<Messages[string] | undefined>\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used internally by @fluenti/next webpack loader.\n * @internal\n */\n __getSyncInstance: () => FluentiCoreInstanceFull & { locale: string }\n}\n\n/**\n * Create server-side i18n utilities for React Server Components.\n *\n * Uses `React.cache()` to share state within a single server request\n * without React Context (which is unavailable in Server Components).\n *\n * @example\n * ```ts\n * // lib/i18n.server.ts — define once\n * import { createServerI18n } from '@fluenti/react/server'\n *\n * export const { setLocale, getI18n, Trans, Plural, Select, DateTime, NumberFormat } = createServerI18n({\n * loadMessages: (locale) => import(`../messages/${locale}.json`),\n * fallbackLocale: 'en',\n * })\n * ```\n *\n * ```tsx\n * // app/[locale]/layout.tsx — set locale once\n * import { setLocale } from '@/lib/i18n.server'\n *\n * export default async function Layout({ params, children }) {\n * const { locale } = await params\n * setLocale(locale)\n * return <html lang={locale}><body>{children}</body></html>\n * }\n * ```\n *\n * ```tsx\n * // app/[locale]/page.tsx — use Trans, Plural, etc. directly\n * import { Trans, Plural, Select } from '@/lib/i18n.server'\n *\n * export default async function Page() {\n * return (\n * <div>\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * <Plural value={5} one=\"# item\" other=\"# items\" />\n * <Select value=\"male\" male=\"He liked this\" other=\"They liked this\" />\n * </div>\n * )\n * }\n * ```\n */\nexport function createServerI18n(config: ServerI18nConfig): ServerI18n {\n // Request-scoped store using React.cache()\n // Each server request gets its own isolated state\n const getRequestStore = cache((): {\n locale: string | null\n instance: (FluentiCoreInstanceFull & { locale: string }) | null\n } => ({\n locale: null,\n instance: null,\n }))\n\n // Cache loaded messages per-request to avoid redundant imports\n const getMessageCache = cache((): Map<string, Messages> => new Map())\n\n // Module-level fallback for server actions where React.cache()\n // may not share state with the page render.\n let _lastInstance: (FluentiCoreInstanceFull & { locale: string }) | null = null\n let _requestId = 0\n let _lastRequestId = 0\n\n function setLocale(locale: string): void {\n getRequestStore().locale = locale\n _requestId++\n _lastInstance = null\n }\n\n async function loadLocaleMessages(locale: string): Promise<Messages> {\n const messageCache = getMessageCache()\n const cached = messageCache.get(locale)\n if (cached) return cached\n\n const raw = await config.loadMessages(locale)\n const messages: Messages =\n typeof raw === 'object' && raw !== null && 'default' in raw\n ? (raw as { default: Messages }).default\n : (raw as Messages)\n\n messageCache.set(locale, messages)\n return messages\n }\n\n async function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }> {\n const store = getRequestStore()\n\n // If setLocale() was never called (e.g. Server Action — independent request\n // that skips the layout), try the resolveLocale fallback.\n if (!store.locale && config.resolveLocale) {\n store.locale = await config.resolveLocale()\n }\n\n const locale = store.locale\n\n if (!locale) {\n throw new Error(\n '[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), ' +\n 'or provide a resolveLocale function in createServerI18n config to auto-detect locale ' +\n 'in Server Actions and other contexts where the layout does not run.',\n )\n }\n\n // Return cached instance if locale hasn't changed\n if (store.instance && store.instance.locale === locale) {\n return store.instance\n }\n\n // Load messages for current locale (and fallback if configured)\n const allMessages: Record<string, Messages> = {}\n allMessages[locale] = await loadLocaleMessages(locale)\n\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n allMessages[config.fallbackLocale] = await loadLocaleMessages(config.fallbackLocale)\n }\n\n const fluentConfig: FluentiCoreConfigFull = {\n locale,\n messages: allMessages,\n }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n _lastInstance = store.instance\n _lastRequestId = _requestId\n return store.instance\n }\n\n // ─── Async Server Components ─────────────────────────────────────────────\n\n async function Trans({ children, id, context, comment, render }: ServerTransProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const { message, components } = extractMessage(children)\n const messageId = id ?? hashMessage(message, context)\n const translated = i18n.t({\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n })\n const result = reconstruct(translated, components)\n return createElement(Fragment, null, render ? render(result) : result)\n }\n\n async function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n }: ServerPluralProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function Select({\n value,\n id,\n context,\n comment,\n other,\n options,\n ...cases\n }: ServerSelectProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: normalized.valueMap[value] ?? 'other' },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function DateTime({ value, format }: ServerDateTimeProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.d(value, format))\n }\n\n async function NumberFormat({ value, format }: ServerNumberProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.n(value, format))\n }\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used by @fluenti/next webpack loader for t`` in RSC.\n *\n * Falls back to creating a minimal instance from the message cache when the\n * React.cache() request store hasn't been populated yet — this handles\n * Suspense boundaries and streamed components where React.cache() state\n * may not propagate from the layout render into streamed children.\n * @internal\n */\n function __getSyncInstance(): FluentiCoreInstanceFull & { locale: string } {\n const store = getRequestStore()\n if (store.instance) {\n return store.instance\n }\n\n // Module-level fallback for server actions where React.cache()\n // may not share state across different call contexts.\n // Only use within the same request (tracked by _requestId).\n if (_lastInstance && _lastRequestId === _requestId) {\n return _lastInstance\n }\n\n // Final fallback: create instance synchronously with the default locale.\n // This handles Suspense boundaries and streamed components where\n // the React.cache store may not have been populated yet.\n const locale = store.locale ?? config.fallbackLocale ?? 'en'\n const messageCache = getMessageCache()\n const messages: Record<string, Messages> = {}\n const cached = messageCache.get(locale)\n if (cached) messages[locale] = cached\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n const fallback = messageCache.get(config.fallbackLocale)\n if (fallback) messages[config.fallbackLocale] = fallback\n }\n\n const fluentConfig: FluentiCoreConfigFull = { locale, messages }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n return store.instance\n }\n\n /**\n * Check if a translation key exists in the catalog for the given (or current) locale.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function te(key: string, locale?: string): Promise<boolean> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key] !== undefined\n }\n\n /**\n * Get the raw compiled message for the given key without interpolation.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function tm(key: string, locale?: string): Promise<Messages[string] | undefined> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key]\n }\n\n return { setLocale, getI18n, __getSyncInstance, te, tm, Trans, Plural, Select, DateTime, NumberFormat }\n}\n"],"mappings":";;;;;;AAsSA,SAAgB,EAAiB,GAAsC;CAGrE,IAAM,IAAkB,SAGlB;EACJ,QAAQ;EACR,UAAU;EACX,EAAE,EAGG,IAAkB,wBAAmC,IAAI,KAAK,CAAC,EAIjE,IAAuE,MACvE,IAAa,GACb,IAAiB;CAErB,SAAS,EAAU,GAAsB;AAGvC,EAFA,GAAiB,CAAC,SAAS,GAC3B,KACA,IAAgB;;CAGlB,eAAe,EAAmB,GAAmC;EACnE,IAAM,IAAe,GAAiB,EAChC,IAAS,EAAa,IAAI,EAAO;AACvC,MAAI,EAAQ,QAAO;EAEnB,IAAM,IAAM,MAAM,EAAO,aAAa,EAAO,EACvC,IACJ,OAAO,KAAQ,YAAY,KAAgB,aAAa,IACnD,EAA8B,UAC9B;AAGP,SADA,EAAa,IAAI,GAAQ,EAAS,EAC3B;;CAGT,eAAe,IAAiE;EAC9E,IAAM,IAAQ,GAAiB;AAI/B,EAAI,CAAC,EAAM,UAAU,EAAO,kBAC1B,EAAM,SAAS,MAAM,EAAO,eAAe;EAG7C,IAAM,IAAS,EAAM;AAErB,MAAI,CAAC,EACH,OAAU,MACR,kPAGD;AAIH,MAAI,EAAM,YAAY,EAAM,SAAS,WAAW,EAC9C,QAAO,EAAM;EAIf,IAAM,IAAwC,EAAE;AAGhD,EAFA,EAAY,KAAU,MAAM,EAAmB,EAAO,EAElD,EAAO,kBAAkB,EAAO,mBAAmB,MACrD,EAAY,EAAO,kBAAkB,MAAM,EAAmB,EAAO,eAAe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IAAO,MAAM,GAAS;AAG5B,UADa,MAAM,EADE,KAAU,EAAK,OACe,EACvC,OAAS,KAAA;;CAOvB,eAAe,EAAG,GAAa,GAAwD;EACrF,IAAM,IAAO,MAAM,GAAS;AAG5B,UADa,MAAM,EADE,KAAU,EAAK,OACe,EACvC;;AAGd,QAAO;EAAE;EAAW;EAAS;EAAmB;EAAI;EAAI;EAAO;EAAQ;EAAQ;EAAU;EAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin.cjs","names":[],"sources":["../src/react-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const reactRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: '',\n catalogInit: 'const __catalog = { ...__defaultMsgs }',\n localeInit: (defaultLocale) => `let __currentLocale = ${JSON.stringify(defaultLocale)}`,\n loadingInit: 'let __loading = false',\n catalogUpdate: (msgs) => `Object.assign(__catalog, ${msgs})`,\n localeUpdate: (locale) => `__currentLocale = ${locale}`,\n loadingUpdate: (value) => `__loading = ${value}`,\n localeRead: '__currentLocale',\n runtimeKey: 'fluenti.runtime.react.v1',\n})\n","import type { Plugin } from 'vite'\nimport type { FluentiPluginOptions } from '@fluenti/vite-plugin'\nimport { createFluentiPlugins } from '@fluenti/vite-plugin'\nimport { reactRuntimeGenerator } from './react-runtime'\n\nexport type { FluentiPluginOptions as FluentiReactOptions } from '@fluenti/vite-plugin'\n\n/**\n * Fluenti React Vite plugin.\n *\n * @example Minimal — no fluenti.config.ts needed\n * ```ts\n * // vite.config.ts\n * import fluentiReact from '@fluenti/react/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fluentiReact({ config: { locales: ['en', 'ja'] } })],\n * })\n * ```\n *\n * @example With fluenti.config.ts (for advanced options)\n * ```ts\n * export default defineConfig({\n * plugins: [fluentiReact()], // auto-reads fluenti.config.ts\n * })\n * ```\n */\nexport default function fluentiReact(options?: FluentiPluginOptions): Plugin[] {\n return createFluentiPlugins(\n { ...(options?.config !== undefined ? { config: options.config } : {}), framework: 'react' },\n [],\n reactRuntimeGenerator,\n )\n}\n"],"mappings":"sCAGA,IAAa,GAAA,EAAA,EAAA,wBAAiE,CAC5E,QAAS,GACT,YAAa,yCACb,WAAa,GAAkB,yBAAyB,KAAK,UAAU,EAAc,GACrF,YAAa,wBACb,cAAgB,GAAS,4BAA4B,EAAK,GAC1D,aAAe,GAAW,qBAAqB,IAC/C,cAAgB,GAAU,eAAe,IACzC,WAAY,kBACZ,WAAY,2BACb,CAAC,CCcF,SAAwB,EAAa,EAA0C,CAC7E,OAAA,EAAA,EAAA,sBACE,CAAE,GAAI,GAAS,SAAW,IAAA,GAAyC,EAAE,CAA/B,CAAE,OAAQ,EAAQ,OAAQ,CAAQ,UAAW,QAAS,CAC5F,EAAE,CACF,EACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite-plugin.js","names":[],"sources":["../src/react-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const reactRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: '',\n catalogInit: 'const __catalog = { ...__defaultMsgs }',\n localeInit: (defaultLocale) => `let __currentLocale = ${JSON.stringify(defaultLocale)}`,\n loadingInit: 'let __loading = false',\n catalogUpdate: (msgs) => `Object.assign(__catalog, ${msgs})`,\n localeUpdate: (locale) => `__currentLocale = ${locale}`,\n loadingUpdate: (value) => `__loading = ${value}`,\n localeRead: '__currentLocale',\n runtimeKey: 'fluenti.runtime.react.v1',\n})\n","import type { Plugin } from 'vite'\nimport type { FluentiPluginOptions } from '@fluenti/vite-plugin'\nimport { createFluentiPlugins } from '@fluenti/vite-plugin'\nimport { reactRuntimeGenerator } from './react-runtime'\n\nexport type { FluentiPluginOptions as FluentiReactOptions } from '@fluenti/vite-plugin'\n\n/**\n * Fluenti React Vite plugin.\n *\n * @example Minimal — no fluenti.config.ts needed\n * ```ts\n * // vite.config.ts\n * import fluentiReact from '@fluenti/react/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fluentiReact({ config: { locales: ['en', 'ja'] } })],\n * })\n * ```\n *\n * @example With fluenti.config.ts (for advanced options)\n * ```ts\n * export default defineConfig({\n * plugins: [fluentiReact()], // auto-reads fluenti.config.ts\n * })\n * ```\n */\nexport default function fluentiReact(options?: FluentiPluginOptions): Plugin[] {\n return createFluentiPlugins(\n { ...(options?.config !== undefined ? { config: options.config } : {}), framework: 'react' },\n [],\n reactRuntimeGenerator,\n )\n}\n"],"mappings":";;AAGA,IAAa,IAA0C,EAAuB;CAC5E,SAAS;CACT,aAAa;CACb,aAAa,MAAkB,yBAAyB,KAAK,UAAU,EAAc;CACrF,aAAa;CACb,gBAAgB,MAAS,4BAA4B,EAAK;CAC1D,eAAe,MAAW,qBAAqB;CAC/C,gBAAgB,MAAU,eAAe;CACzC,YAAY;CACZ,YAAY;CACb,CAAC;;;ACcF,SAAwB,EAAa,GAA0C;AAC7E,QAAO,EACL;EAAE,GAAI,GAAS,WAAW,KAAA,IAAyC,EAAE,GAA/B,EAAE,QAAQ,EAAQ,QAAQ;EAAQ,WAAW;EAAS,EAC5F,EAAE,EACF,EACD"}