@fluenti/solid 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/DateTime.d.ts +5 -3
- package/dist/components/DateTime.d.ts.map +1 -1
- package/dist/components/NumberFormat.d.ts +5 -3
- package/dist/components/NumberFormat.d.ts.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -34
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/DateTime.tsx +7 -4
- package/src/components/NumberFormat.tsx +7 -4
- package/src/context.ts +27 -7
- package/src/index.ts +2 -0
package/README.md
CHANGED
|
@@ -217,7 +217,7 @@ ICU select patterns as a component:
|
|
|
217
217
|
```tsx
|
|
218
218
|
import { DateTime } from '@fluenti/solid'
|
|
219
219
|
|
|
220
|
-
<DateTime value={new Date()}
|
|
220
|
+
<DateTime value={new Date()} format="long" />
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
| Prop | Type | Default | Description |
|
|
@@ -230,7 +230,7 @@ import { DateTime } from '@fluenti/solid'
|
|
|
230
230
|
```tsx
|
|
231
231
|
import { NumberFormat } from '@fluenti/solid'
|
|
232
232
|
|
|
233
|
-
<NumberFormat value={1234.56}
|
|
233
|
+
<NumberFormat value={1234.56} format="currency" />
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
| Prop | Type | Default | Description |
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export interface DateTimeProps {
|
|
2
2
|
/** Date value to format */
|
|
3
3
|
value: Date | number;
|
|
4
|
-
/** Named format
|
|
5
|
-
|
|
4
|
+
/** Named format key defined in dateFormats config */
|
|
5
|
+
format?: string;
|
|
6
6
|
}
|
|
7
|
+
/** @alias DateTimeProps */
|
|
8
|
+
export type FluentiDateTimeProps = DateTimeProps;
|
|
7
9
|
/**
|
|
8
10
|
* `<DateTime>` — date formatting component using Intl APIs.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```tsx
|
|
12
|
-
* <DateTime value={new Date()}
|
|
14
|
+
* <DateTime value={new Date()} format="long" />
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
17
|
export declare function DateTime(props: DateTimeProps): import("solid-js").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/components/DateTime.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,
|
|
1
|
+
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/components/DateTime.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,2BAA2B;AAC3B,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAA;AAEhD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,kCAG5C"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export interface NumberProps {
|
|
2
2
|
/** Number value to format */
|
|
3
3
|
value: number;
|
|
4
|
-
/** Named format
|
|
5
|
-
|
|
4
|
+
/** Named format key defined in numberFormats config */
|
|
5
|
+
format?: string;
|
|
6
6
|
}
|
|
7
|
+
/** @alias NumberProps */
|
|
8
|
+
export type FluentiNumberFormatProps = NumberProps;
|
|
7
9
|
/**
|
|
8
10
|
* `<NumberFormat>` — number formatting component using Intl APIs.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```tsx
|
|
12
|
-
* <NumberFormat value={1234.56}
|
|
14
|
+
* <NumberFormat value={1234.56} format="currency" />
|
|
13
15
|
* ```
|
|
14
16
|
*/
|
|
15
17
|
export declare function NumberFormat(props: NumberProps): import("solid-js").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../src/components/NumberFormat.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,
|
|
1
|
+
{"version":3,"file":"NumberFormat.d.ts","sourceRoot":"","sources":["../../src/components/NumberFormat.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,yBAAyB;AACzB,MAAM,MAAM,wBAAwB,GAAG,WAAW,CAAA;AAElD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,kCAG9C"}
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGxL,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,CAAC,CAAA;AAwB5F,uDAAuD;AACvD,MAAM,WAAW,aAAc,S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B,qDAAqD;IACrD,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACpC,iEAAiE;IACjE,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC,wEAAwE;IACxE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACtC,mEAAmE;IACnE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAA;CAC3D;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,aAAa,GAAG,cAAc,CA0P9F"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`solid-js`),t=require(`@fluenti/core`),n=require(`@fluenti/core/internal`),r=require(`solid-js/web`);var i=Symbol.for(`fluenti.runtime.solid.v1`);function a(){let e=globalThis[i];return typeof e==`object`&&e?e:null}function o(e){return typeof e==`object`&&e&&`default`in e?e.default:e}function s(r){let[i,s]=(0,e.createSignal)(r.locale),[c,l]=(0,e.createSignal)(!1),u=new Set([r.locale]),[d,f]=(0,e.createSignal)(new Set(u)),p={...r.messages},m=r,h=m.diagnostics?(0,t.createDiagnostics)(m.diagnostics):void 0,g=m.lazyLocaleLoading??r.splitting??!1;function _(e,t,r){let i=p[t];if(!i)return;let a=i[e];if(a!==void 0)return typeof a==`function`?a(r):typeof a==`string`&&r?(0,n.interpolate)(a,r,t):String(a)}function v(e,t,n){let i=[t],a=new Set(i);r.fallbackLocale&&!a.has(r.fallbackLocale)&&(i.push(r.fallbackLocale),a.add(r.fallbackLocale));let o=m.fallbackChain?.[t]??m.fallbackChain?.[`*`];if(o)for(let e of o)a.has(e)||(i.push(e),a.add(e));for(let r of i){let i=_(e,r,n);if(i!==void 0)return r!==t&&h?.fallbackUsed(t,r,e),i}}function y(e,t){if(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`solid-js`),t=require(`@fluenti/core`),n=require(`@fluenti/core/internal`),r=require(`solid-js/web`);var i=Symbol.for(`fluenti.runtime.solid.v1`);function a(){let e=globalThis[i];return typeof e==`object`&&e?e:null}function o(e){return typeof e==`object`&&e&&`default`in e?e.default:e}function s(r){let[i,s]=(0,e.createSignal)(r.locale),[c,l]=(0,e.createSignal)(!1),u=new Set([r.locale]),[d,f]=(0,e.createSignal)(new Set(u)),p={...r.messages},m=r,h=m.diagnostics?(0,t.createDiagnostics)(m.diagnostics):void 0,g=m.lazyLocaleLoading??r.splitting??!1;function _(e,t,r){let i=p[t];if(!i)return;let a=i[e];if(a!==void 0)return typeof a==`function`?a(r):typeof a==`string`&&r?(0,n.interpolate)(a,r,t):String(a)}function v(e,t,n){let i=[t],a=new Set(i);r.fallbackLocale&&!a.has(r.fallbackLocale)&&(i.push(r.fallbackLocale),a.add(r.fallbackLocale));let o=m.fallbackChain?.[t]??m.fallbackChain?.[`*`];if(o)for(let e of o)a.has(e)||(i.push(e),a.add(e));for(let r of i){let i=_(e,r,n);if(i!==void 0)return r!==t&&h?.fallbackUsed(t,r,e),i}}function y(e,t){if(r.missing)try{let n=r.missing(t,e);if(n!==void 0)return n}catch{}}function b(e,t,r){let i=v(e,t,r);if(i!==void 0)return i;h?.missingKey(t,e);let a=y(e,t);return a===void 0?e.includes(`{`)?(0,n.interpolate)(e,r,t):e:a}function x(e,...t){if(Array.isArray(e)&&`raw`in e){let r=(0,n.buildICUMessage)(e,t),a=Object.fromEntries(t.map((e,t)=>[`arg${t}`,e]));return b(r,i(),a)}let r=e,a=t[0],o=i();if(typeof r==`object`&&r){let e=(0,n.resolveDescriptorId)(r);if(e){let t=v(e,o,a);if(t!==void 0)return t;let n=y(e,o);if(n!==void 0)return n}return r.message===void 0?e??``:(0,n.interpolate)(r.message,a,o)}return b(r,o,a)}let S=(e,t)=>{p[e]={...p[e],...t},u.add(e),f(new Set(u))},C=0,w=async e=>{if(!g||!m.chunkLoader){s(e);return}let t=a();if(u.has(e)){t?.__switchLocale&&await t.__switchLocale(e),s(e);return}let n=++C;l(!0);try{let r=o(await m.chunkLoader(e));if(p[e]={...p[e],...r},u.add(e),f(new Set(u)),n!==C||(t?.__switchLocale&&await t.__switchLocale(e),n!==C))return;s(e)}finally{n===C&&l(!1)}},T=new Set;return{locale:i,setLocale:w,t:x,loadMessages:S,getLocales:()=>Object.keys(p),d:(e,n)=>(0,t.formatDate)(e,i(),n,m.dateFormats),n:(e,n)=>(0,t.formatNumber)(e,i(),n,m.numberFormats),format:(e,t)=>(0,n.interpolate)(e,t,i()),isLoading:c,loadedLocales:d,preloadLocale:e=>{if(!g||u.has(e)||!m.chunkLoader||T.has(e))return;T.add(e);let t=a();m.chunkLoader(e).then(async n=>{let r=o(n);p[e]={...p[e],...r},u.add(e),f(new Set(u)),t?.__preloadLocale&&await t.__preloadLocale(e)}).catch(t=>{console.warn(`[fluenti] preload failed:`,e,t)}).finally(()=>{T.delete(e)})},te:(e,t)=>{let n=p[t??i()];return n!==void 0&&e in n},tm:(e,t)=>{let n=p[t??i()];return n?n[e]:void 0}}}var c=(0,e.createContext)(),l=e=>{let t=s(e);return(0,r.createComponent)(c.Provider,{value:t,get children(){return e.children}})};function u(){let t=(0,e.useContext)(c);if(t)return t;throw Error(`useI18n() must be used inside an <I18nProvider>.`)}var d=((...e)=>{throw Error("[fluenti] `t` imported from '@fluenti/solid' 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(...).")});function f(e){return typeof Node<`u`&&e instanceof Node}function p(e){return typeof e==`function`&&!e.length?e():e}function m(e){let t=[],r=``;function i(e){let a=p(e);if(a==null||typeof a==`boolean`)return;if(Array.isArray(a)){for(let e of a)i(e);return}if(typeof a==`string`||typeof a==`number`){r+=String(a);return}if(!f(a))return;if(a.nodeType===Node.TEXT_NODE){r+=a.textContent??``;return}if(a.nodeType===Node.DOCUMENT_FRAGMENT_NODE){i(Array.from(a.childNodes));return}let o=t.length,s=m(Array.from(a.childNodes));t.push(a.cloneNode(!1)),t.push(...s.components),s.message===``&&s.components.length===0?r+=`<${o}/>`:r+=`<${o}>${(0,n.offsetIndices)(s.message,o+1)}</${o}>`}return i(e),{message:r,components:t}}function h(e,t){let n=p(t);if(!(n==null||typeof n==`boolean`)){if(Array.isArray(n)){for(let t of n)h(e,t);return}if(typeof n==`string`||typeof n==`number`){e.appendChild(document.createTextNode(String(n)));return}f(n)&&e.appendChild(n)}}function g(e,t){let n=/<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g,r=[],i=0,a;for(n.lastIndex=0,a=n.exec(e);a!==null;){a.index>i&&r.push(e.slice(i,a.index));let o=Number(a[1]),s=a[2]===void 0,c=t[o];if(s)c&&r.push(c.cloneNode(!1));else{let e=g(a[2]===void 0?``:a[3],t);if(c){let t=c.cloneNode(!1);h(t,e),r.push(t)}else r.push(a[3]??``)}i=n.lastIndex,a=n.exec(e)}return i<e.length&&r.push(e.slice(i)),r.length<=1?r[0]??``:r}function _(e,t){let r={},i=[];for(let a of e){let e=t[a];if(e===void 0)continue;let o=m(e);r[a]=(0,n.offsetIndices)(o.message,i.length),i.push(...o.components)}for(let[a,o]of Object.entries(t)){if(e.includes(a)||o===void 0)continue;let t=m(o);r[a]=(0,n.offsetIndices)(t.message,i.length),i.push(...t.components)}return{messages:r,components:i}}function v(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r===-1){t.push({type:`text`,value:e.slice(n)});break}r>n&&t.push({type:`text`,value:e.slice(n,r)});let i=e.slice(r).match(/^<(\w+)\s*\/>/);if(i){t.push({type:`tag`,name:i[1],children:[]}),n=r+i[0].length;continue}let a=e.slice(r).match(/^<(\w+)>/);if(!a){t.push({type:`text`,value:`<`}),n=r+1;continue}let o=a[1],s=r+a[0].length,c=y(e,o,s);if(c===-1){t.push({type:`text`,value:e.slice(r,s)}),n=s;continue}let l=e.slice(s,c),u=`</${o}>`;t.push({type:`tag`,name:o,children:v(l)}),n=c+u.length}return t}function y(e,t,n){let r=`<${t}>`,i=`</${t}>`,a=1,o=n;for(;o<e.length&&a>0;){let t=e.indexOf(r,o),n=e.indexOf(i,o);if(n===-1)return-1;if(t!==-1&&t<n)a++,o=t+r.length;else{if(a--,a===0)return n;o=n+i.length}}return-1}function b(e,t){let n=e.map(e=>{if(e.type===`text`)return e.value;let n=t[e.name];return n?(0,r.createComponent)(r.Dynamic,{component:n,children:e.children.length>0?b(e.children,t):void 0}):b(e.children,t)});return n.length===1?n[0]:n}var x=t=>{let{t:n}=u(),i=(0,e.children)(()=>t.children),a=(0,e.createMemo)(()=>{let e=t.__message??t.message;return typeof e==`function`?e():e}),o=(0,e.createMemo)(()=>t.__components??t.components);return(()=>{let e=a(),s=o();if(e!==void 0&&s)return b(v(n({...t.id===void 0?{}:{id:t.id},message:e,...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}})),s);let c=i.toArray();if(c.length===0)return null;let l=m(c),u=n({...t.id===void 0?{}:{id:t.id},message:l.message,...t.context===void 0?{}:{context:t.context},...t.comment===void 0?{}:{comment:t.comment}}),d=l.components.length>0?g(u,l.components):u;return Array.isArray(d)&&d.length>1&&t.tag?(0,r.createComponent)(r.Dynamic,{get component(){return t.tag},children:d}):d})},S=e=>{let{t}=u();function i(e){return typeof e==`function`?e():e}return(()=>{let a={};for(let t of n.PLURAL_CATEGORIES){let n=i(e[t]);n!==void 0&&(a[t]=n)}let{messages:o,components:s}=_(n.PLURAL_CATEGORIES,a),c=(0,n.buildICUPluralMessage)({...o.zero!==void 0&&{zero:o.zero},...o.one!==void 0&&{one:o.one},...o.two!==void 0&&{two:o.two},...o.few!==void 0&&{few:o.few},...o.many!==void 0&&{many:o.many},other:o.other??``},e.offset),l=t({id:e.id??(e.context===void 0?c:(0,n.hashMessage)(c,e.context)),message:c,...e.context===void 0?{}:{context:e.context},...e.comment===void 0?{}:{comment:e.comment}},{count:e.value}),u=s.length>0?g(l,s):l;return e.tag?(0,r.createComponent)(r.Dynamic,{get component(){return e.tag},children:u}):u})},C=e=>{let{t}=u(),i=()=>{let r=e.options===void 0?{...Object.fromEntries(Object.entries(e).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`,`tag`].includes(e))),other:e.other}:{...e.options,other:e.other},i=[...Object.keys(r).filter(e=>e!==`other`),`other`],{messages:a,components:o}=_(i,r),s=(0,n.normalizeSelectForms)(Object.fromEntries([...i].map(e=>[e,a[e]??``]))),c=t({id:e.id??(e.context===void 0?(0,n.buildICUSelectMessage)(s.forms):(0,n.hashMessage)((0,n.buildICUSelectMessage)(s.forms),e.context)),message:(0,n.buildICUSelectMessage)(s.forms),...e.context===void 0?{}:{context:e.context},...e.comment===void 0?{}:{comment:e.comment}},{value:s.valueMap[e.value]??`other`});return o.length>0?g(c,o):c};return(()=>e.tag?(0,r.createComponent)(r.Dynamic,{get component(){return e.tag},get children(){return i()}}):(0,r.memo)(i))};function w(e){let{d:t}=u();return(0,r.memo)(()=>t(e.value,e.format))}function T(e){let{n:t}=u();return(0,r.memo)(()=>t(e.value,e.format))}exports.DateTime=w,exports.I18nProvider=l,exports.NumberFormat=T,exports.Plural=S,exports.Select=C,exports.Trans=x,exports.createFluentiContext=s,Object.defineProperty(exports,`msg`,{enumerable:!0,get:function(){return t.msg}}),exports.t=d,exports.useI18n=u;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createContext","ParentComponent","createFluentiContext","FluentiConfig","FluentiContext","I18nCtx","I18nProvider","props","ctx","_$createComponent","Provider","value","children","JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","parseTokens","input","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","depth","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","style","DateTime","props","d","_$memo","useI18n","NumberProps","value","style","NumberFormat","props","n","_$memo"],"sources":["../src/context.ts","../src/provider.tsx","../src/use-i18n.ts","../src/compile-time-t.ts","../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import { createSignal, type Accessor } from 'solid-js'\nimport { createDiagnostics, formatDate, formatNumber } from '@fluenti/core'\nimport type { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig } from '@fluenti/core'\nimport { interpolate as coreInterpolate, buildICUMessage, resolveDescriptorId } from '@fluenti/core/internal'\n\n/** Chunk loader for lazy locale loading */\nexport type ChunkLoader = (\n locale: string,\n) => Promise<Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> }>\n\ninterface SplitRuntimeModule {\n __switchLocale?: (locale: string) => Promise<void>\n __preloadLocale?: (locale: string) => Promise<void>\n}\n\nconst SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.solid.v1')\n\nfunction getSplitRuntimeModule(): SplitRuntimeModule | null {\n const runtime = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof runtime === 'object' && runtime !== null\n ? runtime as SplitRuntimeModule\n : null\n}\n\nfunction resolveChunkMessages(\n loaded: Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> },\n): Record<string, CompiledMessage> {\n return typeof loaded === 'object' && loaded !== null && 'default' in loaded\n ? (loaded as { default: Record<string, CompiledMessage> }).default\n : loaded\n}\n\n/** Extended config with lazy locale loading support */\nexport interface FluentiConfig extends FluentiCoreConfig {\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /** Locale-specific fallback chains */\n fallbackChain?: Record<string, Locale[]>\n /** Named date format styles */\n dateFormats?: DateFormatOptions\n /** Named number format styles */\n numberFormats?: NumberFormatOptions\n /** Runtime diagnostics configuration */\n diagnostics?: DiagnosticsConfig\n}\n\n/** Reactive i18n context holding locale signal and translation utilities */\nexport interface FluentiContext {\n /** Reactive accessor for the current locale */\n locale(): Locale\n /** Set the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Translate a message by id with optional interpolation values */\n t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n /** Tagged template form: t`Hello ${name}` */\n t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages(locale: Locale, messages: Messages): void\n /** Return all locale codes that have loaded messages */\n getLocales(): Locale[]\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 /** Format an ICU message string directly (no catalog lookup) */\n format(message: string, values?: Record<string, unknown>): LocalizedString\n /** Whether a locale chunk is currently being loaded */\n isLoading: Accessor<boolean>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Accessor<Set<string>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists for the given or current locale */\n te(key: string, loc?: string): boolean\n /** Get the raw compiled message for a key without interpolation */\n tm(key: string, loc?: string): CompiledMessage | undefined\n}\n\n/**\n * Create a reactive i18n context backed by Solid signals.\n *\n * The returned `t()` reads the internal `locale()` signal, so any\n * Solid computation that calls `t()` will re-run when the locale changes.\n */\nexport function createFluentiContext(config: FluentiCoreConfig | FluentiConfig): FluentiContext {\n const [locale, setLocaleSignal] = createSignal<Locale>(config.locale)\n const [isLoading, setIsLoading] = createSignal(false)\n const loadedLocalesSet = new Set<string>([config.locale])\n const [loadedLocales, setLoadedLocales] = createSignal(new Set(loadedLocalesSet))\n const messages: Record<string, Messages> = { ...config.messages }\n const i18nConfig = config as FluentiConfig\n const diagnostics = i18nConfig.diagnostics ? createDiagnostics(i18nConfig.diagnostics) : undefined\n const lazyLocaleLoading = i18nConfig.lazyLocaleLoading\n ?? (config as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n function lookupCatalog(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const catalog = messages[loc]\n if (!catalog) {\n return undefined\n }\n\n const msg = catalog[id]\n if (msg === undefined) {\n return undefined\n }\n\n if (typeof msg === 'function') {\n return msg(values) as LocalizedString\n }\n\n if (typeof msg === 'string' && values) {\n return coreInterpolate(msg, values, loc) as LocalizedString\n }\n\n return String(msg) as LocalizedString\n }\n\n function lookupWithFallbacks(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const localesToTry: Locale[] = [loc]\n const seen = new Set(localesToTry)\n\n if (config.fallbackLocale && !seen.has(config.fallbackLocale)) {\n localesToTry.push(config.fallbackLocale)\n seen.add(config.fallbackLocale)\n }\n\n const chainLocales = i18nConfig.fallbackChain?.[loc] ?? i18nConfig.fallbackChain?.['*']\n if (chainLocales) {\n for (const chainLocale of chainLocales) {\n if (!seen.has(chainLocale)) {\n localesToTry.push(chainLocale)\n seen.add(chainLocale)\n }\n }\n }\n\n for (const targetLocale of localesToTry) {\n const result = lookupCatalog(id, targetLocale, values)\n if (result !== undefined) {\n if (targetLocale !== loc) {\n diagnostics?.fallbackUsed(loc, targetLocale, id)\n }\n return result\n }\n }\n\n return undefined\n }\n\n function resolveMissing(\n id: string,\n loc: Locale,\n ): LocalizedString | undefined {\n if (!config.missing) {\n return undefined\n }\n\n const result = config.missing(loc, id)\n if (result !== undefined) {\n return result as LocalizedString\n }\n return undefined\n }\n\n function resolveMessage(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString {\n const catalogResult = lookupWithFallbacks(id, loc, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n diagnostics?.missingKey(loc, id)\n\n const missingResult = resolveMissing(id, loc)\n if (missingResult !== undefined) {\n return missingResult\n }\n\n if (id.includes('{')) {\n return coreInterpolate(id, values, loc) as LocalizedString\n }\n\n return id as LocalizedString\n }\n\n function t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n function t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n function t(idOrStrings: string | MessageDescriptor | TemplateStringsArray, ...rest: unknown[]): LocalizedString {\n // Tagged template form: t`Hello ${name}`\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n const strings = idOrStrings as TemplateStringsArray\n const icu = buildICUMessage(strings, rest)\n const values = Object.fromEntries(rest.map((v, i) => [String(i), v]))\n return t(icu, values)\n }\n\n const id = idOrStrings as string | MessageDescriptor\n const values = rest[0] as Record<string, unknown> | undefined\n const currentLocale = locale() // reactive dependency\n if (typeof id === 'object' && id !== null) {\n const messageId = resolveDescriptorId(id)\n if (messageId) {\n const catalogResult = lookupWithFallbacks(messageId, currentLocale, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(messageId, currentLocale)\n if (missingResult !== undefined) {\n return missingResult\n }\n }\n\n if (id.message !== undefined) {\n return coreInterpolate(id.message, values, currentLocale) as LocalizedString\n }\n\n return (messageId ?? '') as LocalizedString\n }\n\n return resolveMessage(id, currentLocale, values)\n }\n\n const loadMessages = (loc: Locale, msgs: Messages): void => {\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...msgs }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n }\n\n const setLocale = async (newLocale: Locale): Promise<void> => {\n if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {\n setLocaleSignal(newLocale)\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n return\n }\n\n setIsLoading(true)\n try {\n const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[newLocale] = { ...messages[newLocale], ...loaded }\n loadedLocalesSet.add(newLocale)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n } finally {\n setIsLoading(false)\n }\n }\n\n const preloadLocale = (loc: string): void => {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader) return\n const splitRuntime = getSplitRuntimeModule()\n i18nConfig.chunkLoader(loc).then(async (loaded) => {\n const resolved = resolveChunkMessages(loaded)\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...resolved }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n }).catch((e: unknown) => {\n console.warn('[fluenti] preload failed:', loc, e)\n })\n }\n\n const getLocales = (): Locale[] => Object.keys(messages)\n\n const d = (value: Date | number, style?: string): LocalizedString =>\n formatDate(value, locale(), style, i18nConfig.dateFormats) as LocalizedString\n\n const n = (value: number, style?: string): LocalizedString =>\n formatNumber(value, locale(), style, i18nConfig.numberFormats) as LocalizedString\n\n const format = (message: string, values?: Record<string, unknown>): LocalizedString => {\n return coreInterpolate(message, values, locale()) as LocalizedString\n }\n\n const te = (key: string, loc?: string): boolean => {\n const msgs = messages[loc ?? locale()]\n return msgs !== undefined && key in msgs\n }\n\n const tm = (key: string, loc?: string): CompiledMessage | undefined => {\n const msgs = messages[loc ?? locale()]\n return msgs ? msgs[key] : undefined\n }\n\n return { locale, setLocale, t, loadMessages, getLocales, d, n, format, isLoading, loadedLocales, preloadLocale, te, tm }\n}\n","import { createContext } from 'solid-js'\nimport type { ParentComponent } from 'solid-js'\nimport { createFluentiContext } from './context'\nimport type { FluentiConfig, FluentiContext } from './context'\n\n/** Solid context object for i18n — used internally by useI18n() */\nexport const I18nCtx = createContext<FluentiContext>()\n\n/**\n * Provide i18n context to the component tree.\n *\n */\nexport const I18nProvider: ParentComponent<FluentiConfig> = (props) => {\n const ctx = createFluentiContext(props)\n return <I18nCtx.Provider value={ctx}>{props.children}</I18nCtx.Provider>\n}\n","import { useContext } from 'solid-js'\nimport { I18nCtx } from './provider'\nimport type { FluentiContext } from './context'\n\n/**\n * Access the i18n context from the nearest `<I18nProvider>`.\n *\n * Throws if no provider is found in the component tree.\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nCtx)\n if (ctx) {\n return ctx\n }\n\n throw new Error(\n 'useI18n() must be used inside an <I18nProvider>.',\n )\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/solid' 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","import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\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 visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.exec(translated)\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 template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return (result.length <= 1 ? result[0] ?? '' : result) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(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 = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\n /** Override auto-generated hash 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 /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string): readonly Token[] {\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\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 /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\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 props.offset,\n )\n\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\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 /** Fallback message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.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([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format style */\n style?: string\n}\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} style=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.style)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format style */\n style?: string\n}\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} style=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.style)}</>\n}\n"],"mappings":"sLAeA,IAAM,EAAoB,OAAO,IAAI,2BAA2B,CAEhE,SAAS,GAAmD,CAC1D,IAAM,EAAW,WAA4C,GAC7D,OAAO,OAAO,GAAY,UAAY,EAClC,EACA,KAGN,SAAS,EACP,EACiC,CACjC,OAAO,OAAO,GAAW,UAAY,GAAmB,YAAa,EAChE,EAAwD,QACzD,EAyDN,SAAgB,EAAqB,EAA2D,CAC9F,GAAM,CAAC,EAAQ,IAAA,EAAA,EAAA,cAAwC,EAAO,OAAO,CAC/D,CAAC,EAAW,IAAA,EAAA,EAAA,cAA6B,GAAM,CAC/C,EAAmB,IAAI,IAAY,CAAC,EAAO,OAAO,CAAC,CACnD,CAAC,EAAe,IAAA,EAAA,EAAA,cAAiC,IAAI,IAAI,EAAiB,CAAC,CAC3E,EAAqC,CAAE,GAAG,EAAO,SAAU,CAC3D,EAAa,EACb,EAAc,EAAW,aAAA,EAAA,EAAA,mBAAgC,EAAW,YAAY,CAAG,IAAA,GACnF,EAAoB,EAAW,mBAC/B,EAAmD,WACpD,GAEL,SAAS,EACP,EACA,EACA,EAC6B,CAC7B,IAAM,EAAU,EAAS,GACzB,GAAI,CAAC,EACH,OAGF,I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ParentComponent","createFluentiContext","FluentiConfig","FluentiContext","I18nCtx","I18nProvider","props","ctx","_$createComponent","Provider","value","children","JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","parseTokens","input","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","depth","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","format","FluentiDateTimeProps","DateTime","props","d","_$memo","useI18n","NumberProps","value","format","FluentiNumberFormatProps","NumberFormat","props","n","_$memo"],"sources":["../src/context.ts","../src/provider.tsx","../src/use-i18n.ts","../src/compile-time-t.ts","../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import { createSignal, type Accessor } from 'solid-js'\nimport { createDiagnostics, formatDate, formatNumber } from '@fluenti/core'\nimport type { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig } from '@fluenti/core'\nimport { interpolate as coreInterpolate, buildICUMessage, resolveDescriptorId } from '@fluenti/core/internal'\n\n/** Chunk loader for lazy locale loading */\nexport type ChunkLoader = (\n locale: string,\n) => Promise<Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> }>\n\ninterface SplitRuntimeModule {\n __switchLocale?: (locale: string) => Promise<void>\n __preloadLocale?: (locale: string) => Promise<void>\n}\n\nconst SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.solid.v1')\n\nfunction getSplitRuntimeModule(): SplitRuntimeModule | null {\n const runtime = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof runtime === 'object' && runtime !== null\n ? runtime as SplitRuntimeModule\n : null\n}\n\nfunction resolveChunkMessages(\n loaded: Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> },\n): Record<string, CompiledMessage> {\n return typeof loaded === 'object' && loaded !== null && 'default' in loaded\n ? (loaded as { default: Record<string, CompiledMessage> }).default\n : loaded\n}\n\n/** Extended config with lazy locale loading support */\nexport interface FluentiConfig extends FluentiCoreConfig {\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /** Locale-specific fallback chains */\n fallbackChain?: Record<string, Locale[]>\n /** Named date format styles */\n dateFormats?: DateFormatOptions\n /** Named number format styles */\n numberFormats?: NumberFormatOptions\n /** Runtime diagnostics configuration */\n diagnostics?: DiagnosticsConfig\n}\n\n/** Reactive i18n context holding locale signal and translation utilities */\nexport interface FluentiContext {\n /** Reactive accessor for the current locale */\n locale(): Locale\n /** Set the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Translate a message by id with optional interpolation values */\n t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n /** Tagged template form: t`Hello ${name}` */\n t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages(locale: Locale, messages: Messages): void\n /** Return all locale codes that have loaded messages */\n getLocales(): Locale[]\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 /** Format an ICU message string directly (no catalog lookup) */\n format(message: string, values?: Record<string, unknown>): LocalizedString\n /** Whether a locale chunk is currently being loaded */\n isLoading: Accessor<boolean>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Accessor<Set<string>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists for the given or current locale */\n te(key: string, loc?: string): boolean\n /** Get the raw compiled message for a key without interpolation */\n tm(key: string, loc?: string): CompiledMessage | undefined\n}\n\n/**\n * Create a reactive i18n context backed by Solid signals.\n *\n * The returned `t()` reads the internal `locale()` signal, so any\n * Solid computation that calls `t()` will re-run when the locale changes.\n */\nexport function createFluentiContext(config: FluentiCoreConfig | FluentiConfig): FluentiContext {\n const [locale, setLocaleSignal] = createSignal<Locale>(config.locale)\n const [isLoading, setIsLoading] = createSignal(false)\n const loadedLocalesSet = new Set<string>([config.locale])\n const [loadedLocales, setLoadedLocales] = createSignal(new Set(loadedLocalesSet))\n const messages: Record<string, Messages> = { ...config.messages }\n const i18nConfig = config as FluentiConfig\n const diagnostics = i18nConfig.diagnostics ? createDiagnostics(i18nConfig.diagnostics) : undefined\n const lazyLocaleLoading = i18nConfig.lazyLocaleLoading\n ?? (config as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n function lookupCatalog(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const catalog = messages[loc]\n if (!catalog) {\n return undefined\n }\n\n const msg = catalog[id]\n if (msg === undefined) {\n return undefined\n }\n\n if (typeof msg === 'function') {\n return msg(values) as LocalizedString\n }\n\n if (typeof msg === 'string' && values) {\n return coreInterpolate(msg, values, loc) as LocalizedString\n }\n\n return String(msg) as LocalizedString\n }\n\n function lookupWithFallbacks(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const localesToTry: Locale[] = [loc]\n const seen = new Set(localesToTry)\n\n if (config.fallbackLocale && !seen.has(config.fallbackLocale)) {\n localesToTry.push(config.fallbackLocale)\n seen.add(config.fallbackLocale)\n }\n\n const chainLocales = i18nConfig.fallbackChain?.[loc] ?? i18nConfig.fallbackChain?.['*']\n if (chainLocales) {\n for (const chainLocale of chainLocales) {\n if (!seen.has(chainLocale)) {\n localesToTry.push(chainLocale)\n seen.add(chainLocale)\n }\n }\n }\n\n for (const targetLocale of localesToTry) {\n const result = lookupCatalog(id, targetLocale, values)\n if (result !== undefined) {\n if (targetLocale !== loc) {\n diagnostics?.fallbackUsed(loc, targetLocale, id)\n }\n return result\n }\n }\n\n return undefined\n }\n\n function resolveMissing(\n id: string,\n loc: Locale,\n ): LocalizedString | undefined {\n if (!config.missing) {\n return undefined\n }\n\n try {\n const result = config.missing(loc, id)\n if (result !== undefined) {\n return result as LocalizedString\n }\n } catch {\n // Missing handler threw — fall through to next resolution path\n }\n return undefined\n }\n\n function resolveMessage(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString {\n const catalogResult = lookupWithFallbacks(id, loc, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n diagnostics?.missingKey(loc, id)\n\n const missingResult = resolveMissing(id, loc)\n if (missingResult !== undefined) {\n return missingResult\n }\n\n if (id.includes('{')) {\n return coreInterpolate(id, values, loc) as LocalizedString\n }\n\n return id as LocalizedString\n }\n\n function t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n function t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n function t(idOrStrings: string | MessageDescriptor | TemplateStringsArray, ...rest: unknown[]): LocalizedString {\n // Tagged template form: t`Hello ${name}`\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n const strings = idOrStrings as TemplateStringsArray\n const icu = buildICUMessage(strings, rest)\n const values = Object.fromEntries(rest.map((v, i) => [`arg${i}`, v]))\n return resolveMessage(icu, locale(), values)\n }\n\n const id = idOrStrings as string | MessageDescriptor\n const values = rest[0] as Record<string, unknown> | undefined\n const currentLocale = locale() // reactive dependency\n if (typeof id === 'object' && id !== null) {\n const messageId = resolveDescriptorId(id)\n if (messageId) {\n const catalogResult = lookupWithFallbacks(messageId, currentLocale, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(messageId, currentLocale)\n if (missingResult !== undefined) {\n return missingResult\n }\n }\n\n if (id.message !== undefined) {\n return coreInterpolate(id.message, values, currentLocale) as LocalizedString\n }\n\n return (messageId ?? '') as LocalizedString\n }\n\n return resolveMessage(id, currentLocale, values)\n }\n\n const loadMessages = (loc: Locale, msgs: Messages): void => {\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...msgs }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n }\n\n let _localeRequestId = 0\n\n const setLocale = async (newLocale: Locale): Promise<void> => {\n if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {\n setLocaleSignal(newLocale)\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n setIsLoading(true)\n try {\n const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))\n // Always store loaded messages — they may be needed if locale is switched back\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[newLocale] = { ...messages[newLocale], ...loaded }\n loadedLocalesSet.add(newLocale)\n setLoadedLocales(new Set(loadedLocalesSet))\n // Stale request — a newer setLocale call superseded this one; don't switch locale\n if (thisRequest !== _localeRequestId) return\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n setLocaleSignal(newLocale)\n } finally {\n if (thisRequest === _localeRequestId) {\n setIsLoading(false)\n }\n }\n }\n\n const _preloadInFlight = new Set<string>()\n\n const preloadLocale = (loc: string): void => {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n i18nConfig.chunkLoader(loc).then(async (loaded) => {\n const resolved = resolveChunkMessages(loaded)\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...resolved }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n }).catch((e: unknown) => {\n console.warn('[fluenti] preload failed:', loc, e)\n }).finally(() => {\n _preloadInFlight.delete(loc)\n })\n }\n\n const getLocales = (): Locale[] => Object.keys(messages)\n\n const d = (value: Date | number, style?: string): LocalizedString =>\n formatDate(value, locale(), style, i18nConfig.dateFormats) as LocalizedString\n\n const n = (value: number, style?: string): LocalizedString =>\n formatNumber(value, locale(), style, i18nConfig.numberFormats) as LocalizedString\n\n const format = (message: string, values?: Record<string, unknown>): LocalizedString => {\n return coreInterpolate(message, values, locale()) as LocalizedString\n }\n\n const te = (key: string, loc?: string): boolean => {\n const msgs = messages[loc ?? locale()]\n return msgs !== undefined && key in msgs\n }\n\n const tm = (key: string, loc?: string): CompiledMessage | undefined => {\n const msgs = messages[loc ?? locale()]\n return msgs ? msgs[key] : undefined\n }\n\n return { locale, setLocale, t, loadMessages, getLocales, d, n, format, isLoading, loadedLocales, preloadLocale, te, tm }\n}\n","import { createContext } from 'solid-js'\nimport type { ParentComponent } from 'solid-js'\nimport { createFluentiContext } from './context'\nimport type { FluentiConfig, FluentiContext } from './context'\n\n/** Solid context object for i18n — used internally by useI18n() */\nexport const I18nCtx = createContext<FluentiContext>()\n\n/**\n * Provide i18n context to the component tree.\n *\n */\nexport const I18nProvider: ParentComponent<FluentiConfig> = (props) => {\n const ctx = createFluentiContext(props)\n return <I18nCtx.Provider value={ctx}>{props.children}</I18nCtx.Provider>\n}\n","import { useContext } from 'solid-js'\nimport { I18nCtx } from './provider'\nimport type { FluentiContext } from './context'\n\n/**\n * Access the i18n context from the nearest `<I18nProvider>`.\n *\n * Throws if no provider is found in the component tree.\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nCtx)\n if (ctx) {\n return ctx\n }\n\n throw new Error(\n 'useI18n() must be used inside an <I18nProvider>.',\n )\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/solid' 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","import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\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 visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.exec(translated)\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 template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return (result.length <= 1 ? result[0] ?? '' : result) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(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 = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\n /** Override auto-generated hash 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 /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string): readonly Token[] {\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\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 /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\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 props.offset,\n )\n\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\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 /** Fallback message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.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([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/** @alias DateTimeProps */\nexport type FluentiDateTimeProps = DateTimeProps\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.format)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberProps */\nexport type FluentiNumberFormatProps = NumberProps\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.format)}</>\n}\n"],"mappings":"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UAAYa,IAAAA,IAAAA,EAAAA,EAAAA,uBACTW,EAAWZ,MAAM,EAAA,EAAA,EAAA,cAAA,EAAA,EAAA,uBACLY,EAAWZ,MAAM,CAAEH,EAAMT,QAAQ,EACvE2B,SAAAA,EAAAA,EAAAA,uBAA+BH,EAAWZ,MAAM,CAChD,GAAIH,EAAMT,UAAYa,IAAAA,GAAyC,EAAE,CAA/B,CAAEb,QAASS,EAAMT,QAAS,CAC5D,GAAIS,EAAMR,UAAYY,IAAAA,GAAyC,EAAE,CAA/B,CAAEZ,QAASQ,EAAMR,QAAS,CAC7D,CACD,CAAEH,MAAO0B,EAAWI,SAASnB,EAAMX,QAAU,QAC/C,CAAC,CAED,OAAOyB,EAAWM,OAAS,EAAIlC,EAAY+B,EAAYH,EAAW,CAAGG,GAGvE,WACMjB,EAAMH,KACR,EAAA,EAAA,iBAAShB,EAAAA,QAAO,CAAA,IAACyC,WAAS,CAAA,OAAEtB,EAAMH,KAAG,IAAA0B,UAAA,CAAA,OAAGrB,GAAS,EAAA,CAAA,EAEnD,EAAA,EAAA,MAAWA,EAAO,GCtEtB,SAAgB6B,EAASC,EAAsB,CAC7C,GAAM,CAAEC,KAAMR,GAAS,CACvB,OAAA,EAAA,EAAA,UAAUQ,EAAED,EAAML,MAAOK,EAAMH,OAAO,CAAA,CCFxC,SAAgBW,EAAaC,EAAoB,CAC/C,GAAM,CAAEC,KAAMP,GAAS,CACvB,OAAA,EAAA,EAAA,UAAUO,EAAED,EAAMJ,MAAOI,EAAMH,OAAO,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,7 @@ export { SelectComp as Select } from './select';
|
|
|
11
11
|
export type { FluentiSelectProps } from './select';
|
|
12
12
|
export { msg } from './msg';
|
|
13
13
|
export { DateTime } from './components/DateTime';
|
|
14
|
+
export type { DateTimeProps, FluentiDateTimeProps } from './components/DateTime';
|
|
14
15
|
export { NumberFormat } from './components/NumberFormat';
|
|
16
|
+
export type { NumberProps, FluentiNumberFormatProps } from './components/NumberFormat';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -30,9 +30,10 @@ function w(e) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
function x(t, n) {
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (e.missing) try {
|
|
34
|
+
let r = e.missing(n, t);
|
|
35
|
+
if (r !== void 0) return r;
|
|
36
|
+
} catch {}
|
|
36
37
|
}
|
|
37
38
|
function w(e, t, n) {
|
|
38
39
|
let r = b(e, t, n);
|
|
@@ -42,7 +43,10 @@ function w(e) {
|
|
|
42
43
|
return i === void 0 ? e.includes("{") ? m(e, n, t) : e : i;
|
|
43
44
|
}
|
|
44
45
|
function T(e, ...n) {
|
|
45
|
-
if (Array.isArray(e) && "raw" in e)
|
|
46
|
+
if (Array.isArray(e) && "raw" in e) {
|
|
47
|
+
let r = u(e, n), i = Object.fromEntries(n.map((e, t) => [`arg${t}`, e]));
|
|
48
|
+
return w(r, t(), i);
|
|
49
|
+
}
|
|
46
50
|
let r = e, i = n[0], a = t();
|
|
47
51
|
if (typeof r == "object" && r) {
|
|
48
52
|
let e = _(r);
|
|
@@ -56,36 +60,39 @@ function w(e) {
|
|
|
56
60
|
}
|
|
57
61
|
return w(r, a, i);
|
|
58
62
|
}
|
|
63
|
+
let E = (e, t) => {
|
|
64
|
+
p[e] = {
|
|
65
|
+
...p[e],
|
|
66
|
+
...t
|
|
67
|
+
}, l.add(e), f(new Set(l));
|
|
68
|
+
}, D = 0, O = async (e) => {
|
|
69
|
+
if (!v || !h.chunkLoader) {
|
|
70
|
+
n(e);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let t = S();
|
|
74
|
+
if (l.has(e)) {
|
|
75
|
+
t?.__switchLocale && await t.__switchLocale(e), n(e);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let r = ++D;
|
|
79
|
+
c(!0);
|
|
80
|
+
try {
|
|
81
|
+
let i = C(await h.chunkLoader(e));
|
|
82
|
+
if (p[e] = {
|
|
83
|
+
...p[e],
|
|
84
|
+
...i
|
|
85
|
+
}, l.add(e), f(new Set(l)), r !== D || (t?.__switchLocale && await t.__switchLocale(e), r !== D)) return;
|
|
86
|
+
n(e);
|
|
87
|
+
} finally {
|
|
88
|
+
r === D && c(!1);
|
|
89
|
+
}
|
|
90
|
+
}, k = /* @__PURE__ */ new Set();
|
|
59
91
|
return {
|
|
60
92
|
locale: t,
|
|
61
|
-
setLocale:
|
|
62
|
-
if (!v || !h.chunkLoader) {
|
|
63
|
-
n(e);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
let t = S();
|
|
67
|
-
if (l.has(e)) {
|
|
68
|
-
t?.__switchLocale && await t.__switchLocale(e), n(e);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
c(!0);
|
|
72
|
-
try {
|
|
73
|
-
let r = C(await h.chunkLoader(e));
|
|
74
|
-
p[e] = {
|
|
75
|
-
...p[e],
|
|
76
|
-
...r
|
|
77
|
-
}, l.add(e), f(new Set(l)), t?.__switchLocale && await t.__switchLocale(e), n(e);
|
|
78
|
-
} finally {
|
|
79
|
-
c(!1);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
93
|
+
setLocale: O,
|
|
82
94
|
t: T,
|
|
83
|
-
loadMessages:
|
|
84
|
-
p[e] = {
|
|
85
|
-
...p[e],
|
|
86
|
-
...t
|
|
87
|
-
}, l.add(e), f(new Set(l));
|
|
88
|
-
},
|
|
95
|
+
loadMessages: E,
|
|
89
96
|
getLocales: () => Object.keys(p),
|
|
90
97
|
d: (e, n) => o(e, t(), n, h.dateFormats),
|
|
91
98
|
n: (e, n) => s(e, t(), n, h.numberFormats),
|
|
@@ -93,7 +100,8 @@ function w(e) {
|
|
|
93
100
|
isLoading: i,
|
|
94
101
|
loadedLocales: d,
|
|
95
102
|
preloadLocale: (e) => {
|
|
96
|
-
if (!v || l.has(e) || !h.chunkLoader) return;
|
|
103
|
+
if (!v || l.has(e) || !h.chunkLoader || k.has(e)) return;
|
|
104
|
+
k.add(e);
|
|
97
105
|
let t = S();
|
|
98
106
|
h.chunkLoader(e).then(async (n) => {
|
|
99
107
|
let r = C(n);
|
|
@@ -103,6 +111,8 @@ function w(e) {
|
|
|
103
111
|
}, l.add(e), f(new Set(l)), t?.__preloadLocale && await t.__preloadLocale(e);
|
|
104
112
|
}).catch((t) => {
|
|
105
113
|
console.warn("[fluenti] preload failed:", e, t);
|
|
114
|
+
}).finally(() => {
|
|
115
|
+
k.delete(e);
|
|
106
116
|
});
|
|
107
117
|
},
|
|
108
118
|
te: (e, n) => {
|
|
@@ -396,13 +406,13 @@ var R = (t) => {
|
|
|
396
406
|
//#region src/components/DateTime.tsx
|
|
397
407
|
function V(e) {
|
|
398
408
|
let { d: t } = D();
|
|
399
|
-
return b(() => t(e.value, e.
|
|
409
|
+
return b(() => t(e.value, e.format));
|
|
400
410
|
}
|
|
401
411
|
//#endregion
|
|
402
412
|
//#region src/components/NumberFormat.tsx
|
|
403
413
|
function H(e) {
|
|
404
414
|
let { n: t } = D();
|
|
405
|
-
return b(() => t(e.value, e.
|
|
415
|
+
return b(() => t(e.value, e.format));
|
|
406
416
|
}
|
|
407
417
|
//#endregion
|
|
408
418
|
export { V as DateTime, E as I18nProvider, H as NumberFormat, z as Plural, B as Select, R as Trans, w as createFluentiContext, c as msg, O as t, D as useI18n };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createContext","ParentComponent","createFluentiContext","FluentiConfig","FluentiContext","I18nCtx","I18nProvider","props","ctx","_$createComponent","Provider","value","children","JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","parseTokens","input","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","depth","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","style","DateTime","props","d","_$memo","useI18n","NumberProps","value","style","NumberFormat","props","n","_$memo"],"sources":["../src/context.ts","../src/provider.tsx","../src/use-i18n.ts","../src/compile-time-t.ts","../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import { createSignal, type Accessor } from 'solid-js'\nimport { createDiagnostics, formatDate, formatNumber } from '@fluenti/core'\nimport type { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig } from '@fluenti/core'\nimport { interpolate as coreInterpolate, buildICUMessage, resolveDescriptorId } from '@fluenti/core/internal'\n\n/** Chunk loader for lazy locale loading */\nexport type ChunkLoader = (\n locale: string,\n) => Promise<Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> }>\n\ninterface SplitRuntimeModule {\n __switchLocale?: (locale: string) => Promise<void>\n __preloadLocale?: (locale: string) => Promise<void>\n}\n\nconst SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.solid.v1')\n\nfunction getSplitRuntimeModule(): SplitRuntimeModule | null {\n const runtime = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof runtime === 'object' && runtime !== null\n ? runtime as SplitRuntimeModule\n : null\n}\n\nfunction resolveChunkMessages(\n loaded: Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> },\n): Record<string, CompiledMessage> {\n return typeof loaded === 'object' && loaded !== null && 'default' in loaded\n ? (loaded as { default: Record<string, CompiledMessage> }).default\n : loaded\n}\n\n/** Extended config with lazy locale loading support */\nexport interface FluentiConfig extends FluentiCoreConfig {\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /** Locale-specific fallback chains */\n fallbackChain?: Record<string, Locale[]>\n /** Named date format styles */\n dateFormats?: DateFormatOptions\n /** Named number format styles */\n numberFormats?: NumberFormatOptions\n /** Runtime diagnostics configuration */\n diagnostics?: DiagnosticsConfig\n}\n\n/** Reactive i18n context holding locale signal and translation utilities */\nexport interface FluentiContext {\n /** Reactive accessor for the current locale */\n locale(): Locale\n /** Set the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Translate a message by id with optional interpolation values */\n t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n /** Tagged template form: t`Hello ${name}` */\n t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages(locale: Locale, messages: Messages): void\n /** Return all locale codes that have loaded messages */\n getLocales(): Locale[]\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 /** Format an ICU message string directly (no catalog lookup) */\n format(message: string, values?: Record<string, unknown>): LocalizedString\n /** Whether a locale chunk is currently being loaded */\n isLoading: Accessor<boolean>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Accessor<Set<string>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists for the given or current locale */\n te(key: string, loc?: string): boolean\n /** Get the raw compiled message for a key without interpolation */\n tm(key: string, loc?: string): CompiledMessage | undefined\n}\n\n/**\n * Create a reactive i18n context backed by Solid signals.\n *\n * The returned `t()` reads the internal `locale()` signal, so any\n * Solid computation that calls `t()` will re-run when the locale changes.\n */\nexport function createFluentiContext(config: FluentiCoreConfig | FluentiConfig): FluentiContext {\n const [locale, setLocaleSignal] = createSignal<Locale>(config.locale)\n const [isLoading, setIsLoading] = createSignal(false)\n const loadedLocalesSet = new Set<string>([config.locale])\n const [loadedLocales, setLoadedLocales] = createSignal(new Set(loadedLocalesSet))\n const messages: Record<string, Messages> = { ...config.messages }\n const i18nConfig = config as FluentiConfig\n const diagnostics = i18nConfig.diagnostics ? createDiagnostics(i18nConfig.diagnostics) : undefined\n const lazyLocaleLoading = i18nConfig.lazyLocaleLoading\n ?? (config as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n function lookupCatalog(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const catalog = messages[loc]\n if (!catalog) {\n return undefined\n }\n\n const msg = catalog[id]\n if (msg === undefined) {\n return undefined\n }\n\n if (typeof msg === 'function') {\n return msg(values) as LocalizedString\n }\n\n if (typeof msg === 'string' && values) {\n return coreInterpolate(msg, values, loc) as LocalizedString\n }\n\n return String(msg) as LocalizedString\n }\n\n function lookupWithFallbacks(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const localesToTry: Locale[] = [loc]\n const seen = new Set(localesToTry)\n\n if (config.fallbackLocale && !seen.has(config.fallbackLocale)) {\n localesToTry.push(config.fallbackLocale)\n seen.add(config.fallbackLocale)\n }\n\n const chainLocales = i18nConfig.fallbackChain?.[loc] ?? i18nConfig.fallbackChain?.['*']\n if (chainLocales) {\n for (const chainLocale of chainLocales) {\n if (!seen.has(chainLocale)) {\n localesToTry.push(chainLocale)\n seen.add(chainLocale)\n }\n }\n }\n\n for (const targetLocale of localesToTry) {\n const result = lookupCatalog(id, targetLocale, values)\n if (result !== undefined) {\n if (targetLocale !== loc) {\n diagnostics?.fallbackUsed(loc, targetLocale, id)\n }\n return result\n }\n }\n\n return undefined\n }\n\n function resolveMissing(\n id: string,\n loc: Locale,\n ): LocalizedString | undefined {\n if (!config.missing) {\n return undefined\n }\n\n const result = config.missing(loc, id)\n if (result !== undefined) {\n return result as LocalizedString\n }\n return undefined\n }\n\n function resolveMessage(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString {\n const catalogResult = lookupWithFallbacks(id, loc, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n diagnostics?.missingKey(loc, id)\n\n const missingResult = resolveMissing(id, loc)\n if (missingResult !== undefined) {\n return missingResult\n }\n\n if (id.includes('{')) {\n return coreInterpolate(id, values, loc) as LocalizedString\n }\n\n return id as LocalizedString\n }\n\n function t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n function t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n function t(idOrStrings: string | MessageDescriptor | TemplateStringsArray, ...rest: unknown[]): LocalizedString {\n // Tagged template form: t`Hello ${name}`\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n const strings = idOrStrings as TemplateStringsArray\n const icu = buildICUMessage(strings, rest)\n const values = Object.fromEntries(rest.map((v, i) => [String(i), v]))\n return t(icu, values)\n }\n\n const id = idOrStrings as string | MessageDescriptor\n const values = rest[0] as Record<string, unknown> | undefined\n const currentLocale = locale() // reactive dependency\n if (typeof id === 'object' && id !== null) {\n const messageId = resolveDescriptorId(id)\n if (messageId) {\n const catalogResult = lookupWithFallbacks(messageId, currentLocale, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(messageId, currentLocale)\n if (missingResult !== undefined) {\n return missingResult\n }\n }\n\n if (id.message !== undefined) {\n return coreInterpolate(id.message, values, currentLocale) as LocalizedString\n }\n\n return (messageId ?? '') as LocalizedString\n }\n\n return resolveMessage(id, currentLocale, values)\n }\n\n const loadMessages = (loc: Locale, msgs: Messages): void => {\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...msgs }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n }\n\n const setLocale = async (newLocale: Locale): Promise<void> => {\n if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {\n setLocaleSignal(newLocale)\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n return\n }\n\n setIsLoading(true)\n try {\n const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[newLocale] = { ...messages[newLocale], ...loaded }\n loadedLocalesSet.add(newLocale)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n } finally {\n setIsLoading(false)\n }\n }\n\n const preloadLocale = (loc: string): void => {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader) return\n const splitRuntime = getSplitRuntimeModule()\n i18nConfig.chunkLoader(loc).then(async (loaded) => {\n const resolved = resolveChunkMessages(loaded)\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...resolved }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n }).catch((e: unknown) => {\n console.warn('[fluenti] preload failed:', loc, e)\n })\n }\n\n const getLocales = (): Locale[] => Object.keys(messages)\n\n const d = (value: Date | number, style?: string): LocalizedString =>\n formatDate(value, locale(), style, i18nConfig.dateFormats) as LocalizedString\n\n const n = (value: number, style?: string): LocalizedString =>\n formatNumber(value, locale(), style, i18nConfig.numberFormats) as LocalizedString\n\n const format = (message: string, values?: Record<string, unknown>): LocalizedString => {\n return coreInterpolate(message, values, locale()) as LocalizedString\n }\n\n const te = (key: string, loc?: string): boolean => {\n const msgs = messages[loc ?? locale()]\n return msgs !== undefined && key in msgs\n }\n\n const tm = (key: string, loc?: string): CompiledMessage | undefined => {\n const msgs = messages[loc ?? locale()]\n return msgs ? msgs[key] : undefined\n }\n\n return { locale, setLocale, t, loadMessages, getLocales, d, n, format, isLoading, loadedLocales, preloadLocale, te, tm }\n}\n","import { createContext } from 'solid-js'\nimport type { ParentComponent } from 'solid-js'\nimport { createFluentiContext } from './context'\nimport type { FluentiConfig, FluentiContext } from './context'\n\n/** Solid context object for i18n — used internally by useI18n() */\nexport const I18nCtx = createContext<FluentiContext>()\n\n/**\n * Provide i18n context to the component tree.\n *\n */\nexport const I18nProvider: ParentComponent<FluentiConfig> = (props) => {\n const ctx = createFluentiContext(props)\n return <I18nCtx.Provider value={ctx}>{props.children}</I18nCtx.Provider>\n}\n","import { useContext } from 'solid-js'\nimport { I18nCtx } from './provider'\nimport type { FluentiContext } from './context'\n\n/**\n * Access the i18n context from the nearest `<I18nProvider>`.\n *\n * Throws if no provider is found in the component tree.\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nCtx)\n if (ctx) {\n return ctx\n }\n\n throw new Error(\n 'useI18n() must be used inside an <I18nProvider>.',\n )\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/solid' 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","import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\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 visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.exec(translated)\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 template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return (result.length <= 1 ? result[0] ?? '' : result) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(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 = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\n /** Override auto-generated hash 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 /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string): readonly Token[] {\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\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 /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\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 props.offset,\n )\n\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\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 /** Fallback message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.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([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format style */\n style?: string\n}\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} style=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.style)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format style */\n style?: string\n}\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} style=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.style)}</>\n}\n"],"mappings":";;;;;AAeA,IAAM,IAAoB,OAAO,IAAI,2BAA2B;AAEhE,SAAS,IAAmD;CAC1D,IAAM,IAAW,WAA4C;AAC7D,QAAO,OAAO,KAAY,YAAY,IAClC,IACA;;AAGN,SAAS,EACP,GACiC;AACjC,QAAO,OAAO,KAAW,YAAY,KAAmB,aAAa,IAChE,EAAwD,UACzD;;AAyDN,SAAgB,EAAqB,GAA2D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vB,QAAAQ,QAAUD,EAAED,EAAMJ,OAAOI,EAAMF,MAAM,CAAA;;;;ACFvC,SAAgBS,EAAaC,GAAoB;CAC/C,IAAM,EAAEC,SAAMN,GAAS;AACvB,QAAAO,QAAUD,EAAED,EAAMH,OAAOG,EAAMF,MAAM,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","ParentComponent","createFluentiContext","FluentiConfig","FluentiContext","I18nCtx","I18nProvider","props","ctx","_$createComponent","Provider","value","children","JSX","isNodeLike","value","Node","resolveValue","length","offsetIndices","extractMessage","message","components","visit","node","resolved","undefined","Array","isArray","child","String","nodeType","TEXT_NODE","textContent","DOCUMENT_FRAGMENT_NODE","from","childNodes","idx","inner","push","Element","cloneNode","appendChild","parent","entry","document","createTextNode","reconstruct","translated","combinedRe","result","lastIndex","match","RegExpExecArray","exec","index","slice","Number","isSelfClosing","template","clone","serializeRichForms","keys","T","forms","Partial","Record","messages","key","extracted","Object","entries","includes","Dynamic","children","resolveChildren","createMemo","Component","JSX","useI18n","extractMessage","extractDomMessage","reconstruct","reconstructDomMessage","RichComponent","Element","FluentiTransProps","id","context","comment","tag","message","components","Record","__message","__components","TextToken","type","value","TagToken","name","Token","parseTokens","input","tokens","pos","length","openIdx","indexOf","push","slice","selfCloseMatch","match","openMatch","tagName","contentStart","innerEnd","findClosingTag","innerContent","closingTag","startPos","openTag","closeTag","depth","nextOpen","nextClose","renderTokens","elements","map","token","Comp","undefined","_$createComponent","component","Trans","props","t","resolvedChildren","raw","msg","comps","translated","toArray","extracted","result","Array","isArray","Dynamic","Component","JSX","hashMessage","buildICUPluralMessage","PLURAL_CATEGORIES","PluralCategory","useI18n","reconstruct","serializeRichForms","FluentiPluralProps","value","id","context","comment","offset","zero","Element","one","two","few","many","other","tag","Plural","props","t","resolveProp","val","resolvedValues","Partial","Record","cat","resolved","undefined","messages","components","icuMessage","translated","message","count","result","length","_$createComponent","component","children","Component","JSX","Dynamic","hashMessage","buildICUSelectMessage","normalizeSelectForms","useI18n","reconstruct","serializeRichForms","FluentiSelectProps","value","id","context","comment","other","Element","options","Record","tag","key","SelectComp","props","t","content","forms","undefined","Object","fromEntries","entries","filter","includes","orderedKeys","keys","const","messages","components","normalized","map","translated","message","valueMap","length","_$createComponent","component","children","_$memo","useI18n","DateTimeProps","value","Date","format","FluentiDateTimeProps","DateTime","props","d","_$memo","useI18n","NumberProps","value","format","FluentiNumberFormatProps","NumberFormat","props","n","_$memo"],"sources":["../src/context.ts","../src/provider.tsx","../src/use-i18n.ts","../src/compile-time-t.ts","../src/rich-dom.tsx","../src/trans.tsx","../src/plural.tsx","../src/select.tsx","../src/components/DateTime.tsx","../src/components/NumberFormat.tsx"],"sourcesContent":["import { createSignal, type Accessor } from 'solid-js'\nimport { createDiagnostics, formatDate, formatNumber } from '@fluenti/core'\nimport type { FluentiCoreConfig, Locale, LocalizedString, Messages, CompiledMessage, MessageDescriptor, DateFormatOptions, NumberFormatOptions, DiagnosticsConfig } from '@fluenti/core'\nimport { interpolate as coreInterpolate, buildICUMessage, resolveDescriptorId } from '@fluenti/core/internal'\n\n/** Chunk loader for lazy locale loading */\nexport type ChunkLoader = (\n locale: string,\n) => Promise<Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> }>\n\ninterface SplitRuntimeModule {\n __switchLocale?: (locale: string) => Promise<void>\n __preloadLocale?: (locale: string) => Promise<void>\n}\n\nconst SPLIT_RUNTIME_KEY = Symbol.for('fluenti.runtime.solid.v1')\n\nfunction getSplitRuntimeModule(): SplitRuntimeModule | null {\n const runtime = (globalThis as Record<PropertyKey, unknown>)[SPLIT_RUNTIME_KEY]\n return typeof runtime === 'object' && runtime !== null\n ? runtime as SplitRuntimeModule\n : null\n}\n\nfunction resolveChunkMessages(\n loaded: Record<string, CompiledMessage> | { default: Record<string, CompiledMessage> },\n): Record<string, CompiledMessage> {\n return typeof loaded === 'object' && loaded !== null && 'default' in loaded\n ? (loaded as { default: Record<string, CompiledMessage> }).default\n : loaded\n}\n\n/** Extended config with lazy locale loading support */\nexport interface FluentiConfig extends FluentiCoreConfig {\n /** Async chunk loader for lazy locale loading */\n chunkLoader?: ChunkLoader\n /** Enable lazy locale loading through chunkLoader */\n lazyLocaleLoading?: boolean\n /** Locale-specific fallback chains */\n fallbackChain?: Record<string, Locale[]>\n /** Named date format styles */\n dateFormats?: DateFormatOptions\n /** Named number format styles */\n numberFormats?: NumberFormatOptions\n /** Runtime diagnostics configuration */\n diagnostics?: DiagnosticsConfig\n}\n\n/** Reactive i18n context holding locale signal and translation utilities */\nexport interface FluentiContext {\n /** Reactive accessor for the current locale */\n locale(): Locale\n /** Set the active locale (async when lazy locale loading is enabled) */\n setLocale(locale: Locale): Promise<void>\n /** Translate a message by id with optional interpolation values */\n t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n /** Tagged template form: t`Hello ${name}` */\n t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n /** Merge additional messages into a locale catalog at runtime */\n loadMessages(locale: Locale, messages: Messages): void\n /** Return all locale codes that have loaded messages */\n getLocales(): Locale[]\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 /** Format an ICU message string directly (no catalog lookup) */\n format(message: string, values?: Record<string, unknown>): LocalizedString\n /** Whether a locale chunk is currently being loaded */\n isLoading: Accessor<boolean>\n /** Set of locales whose messages have been loaded */\n loadedLocales: Accessor<Set<string>>\n /** Preload a locale in the background without switching to it */\n preloadLocale(locale: string): void\n /** Check if a translation key exists for the given or current locale */\n te(key: string, loc?: string): boolean\n /** Get the raw compiled message for a key without interpolation */\n tm(key: string, loc?: string): CompiledMessage | undefined\n}\n\n/**\n * Create a reactive i18n context backed by Solid signals.\n *\n * The returned `t()` reads the internal `locale()` signal, so any\n * Solid computation that calls `t()` will re-run when the locale changes.\n */\nexport function createFluentiContext(config: FluentiCoreConfig | FluentiConfig): FluentiContext {\n const [locale, setLocaleSignal] = createSignal<Locale>(config.locale)\n const [isLoading, setIsLoading] = createSignal(false)\n const loadedLocalesSet = new Set<string>([config.locale])\n const [loadedLocales, setLoadedLocales] = createSignal(new Set(loadedLocalesSet))\n const messages: Record<string, Messages> = { ...config.messages }\n const i18nConfig = config as FluentiConfig\n const diagnostics = i18nConfig.diagnostics ? createDiagnostics(i18nConfig.diagnostics) : undefined\n const lazyLocaleLoading = i18nConfig.lazyLocaleLoading\n ?? (config as FluentiConfig & { splitting?: boolean }).splitting\n ?? false\n\n function lookupCatalog(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const catalog = messages[loc]\n if (!catalog) {\n return undefined\n }\n\n const msg = catalog[id]\n if (msg === undefined) {\n return undefined\n }\n\n if (typeof msg === 'function') {\n return msg(values) as LocalizedString\n }\n\n if (typeof msg === 'string' && values) {\n return coreInterpolate(msg, values, loc) as LocalizedString\n }\n\n return String(msg) as LocalizedString\n }\n\n function lookupWithFallbacks(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString | undefined {\n const localesToTry: Locale[] = [loc]\n const seen = new Set(localesToTry)\n\n if (config.fallbackLocale && !seen.has(config.fallbackLocale)) {\n localesToTry.push(config.fallbackLocale)\n seen.add(config.fallbackLocale)\n }\n\n const chainLocales = i18nConfig.fallbackChain?.[loc] ?? i18nConfig.fallbackChain?.['*']\n if (chainLocales) {\n for (const chainLocale of chainLocales) {\n if (!seen.has(chainLocale)) {\n localesToTry.push(chainLocale)\n seen.add(chainLocale)\n }\n }\n }\n\n for (const targetLocale of localesToTry) {\n const result = lookupCatalog(id, targetLocale, values)\n if (result !== undefined) {\n if (targetLocale !== loc) {\n diagnostics?.fallbackUsed(loc, targetLocale, id)\n }\n return result\n }\n }\n\n return undefined\n }\n\n function resolveMissing(\n id: string,\n loc: Locale,\n ): LocalizedString | undefined {\n if (!config.missing) {\n return undefined\n }\n\n try {\n const result = config.missing(loc, id)\n if (result !== undefined) {\n return result as LocalizedString\n }\n } catch {\n // Missing handler threw — fall through to next resolution path\n }\n return undefined\n }\n\n function resolveMessage(\n id: string,\n loc: Locale,\n values?: Record<string, unknown>,\n ): LocalizedString {\n const catalogResult = lookupWithFallbacks(id, loc, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n diagnostics?.missingKey(loc, id)\n\n const missingResult = resolveMissing(id, loc)\n if (missingResult !== undefined) {\n return missingResult\n }\n\n if (id.includes('{')) {\n return coreInterpolate(id, values, loc) as LocalizedString\n }\n\n return id as LocalizedString\n }\n\n function t(strings: TemplateStringsArray, ...exprs: unknown[]): LocalizedString\n function t(id: string | MessageDescriptor, values?: Record<string, unknown>): LocalizedString\n function t(idOrStrings: string | MessageDescriptor | TemplateStringsArray, ...rest: unknown[]): LocalizedString {\n // Tagged template form: t`Hello ${name}`\n if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {\n const strings = idOrStrings as TemplateStringsArray\n const icu = buildICUMessage(strings, rest)\n const values = Object.fromEntries(rest.map((v, i) => [`arg${i}`, v]))\n return resolveMessage(icu, locale(), values)\n }\n\n const id = idOrStrings as string | MessageDescriptor\n const values = rest[0] as Record<string, unknown> | undefined\n const currentLocale = locale() // reactive dependency\n if (typeof id === 'object' && id !== null) {\n const messageId = resolveDescriptorId(id)\n if (messageId) {\n const catalogResult = lookupWithFallbacks(messageId, currentLocale, values)\n if (catalogResult !== undefined) {\n return catalogResult\n }\n\n const missingResult = resolveMissing(messageId, currentLocale)\n if (missingResult !== undefined) {\n return missingResult\n }\n }\n\n if (id.message !== undefined) {\n return coreInterpolate(id.message, values, currentLocale) as LocalizedString\n }\n\n return (messageId ?? '') as LocalizedString\n }\n\n return resolveMessage(id, currentLocale, values)\n }\n\n const loadMessages = (loc: Locale, msgs: Messages): void => {\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...msgs }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n }\n\n let _localeRequestId = 0\n\n const setLocale = async (newLocale: Locale): Promise<void> => {\n if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {\n setLocaleSignal(newLocale)\n return\n }\n\n const splitRuntime = getSplitRuntimeModule()\n\n if (loadedLocalesSet.has(newLocale)) {\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n setLocaleSignal(newLocale)\n return\n }\n\n // Race-condition protection: track request ID\n const thisRequest = ++_localeRequestId\n setIsLoading(true)\n try {\n const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))\n // Always store loaded messages — they may be needed if locale is switched back\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[newLocale] = { ...messages[newLocale], ...loaded }\n loadedLocalesSet.add(newLocale)\n setLoadedLocales(new Set(loadedLocalesSet))\n // Stale request — a newer setLocale call superseded this one; don't switch locale\n if (thisRequest !== _localeRequestId) return\n if (splitRuntime?.__switchLocale) {\n await splitRuntime.__switchLocale(newLocale)\n }\n // Re-check after async __switchLocale — a newer setLocale() may have superseded this one\n if (thisRequest !== _localeRequestId) return\n setLocaleSignal(newLocale)\n } finally {\n if (thisRequest === _localeRequestId) {\n setIsLoading(false)\n }\n }\n }\n\n const _preloadInFlight = new Set<string>()\n\n const preloadLocale = (loc: string): void => {\n if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader || _preloadInFlight.has(loc)) return\n _preloadInFlight.add(loc)\n const splitRuntime = getSplitRuntimeModule()\n i18nConfig.chunkLoader(loc).then(async (loaded) => {\n const resolved = resolveChunkMessages(loaded)\n // Intentional mutation: messages record is locally scoped to this context closure\n messages[loc] = { ...messages[loc], ...resolved }\n loadedLocalesSet.add(loc)\n setLoadedLocales(new Set(loadedLocalesSet))\n if (splitRuntime?.__preloadLocale) {\n await splitRuntime.__preloadLocale(loc)\n }\n }).catch((e: unknown) => {\n console.warn('[fluenti] preload failed:', loc, e)\n }).finally(() => {\n _preloadInFlight.delete(loc)\n })\n }\n\n const getLocales = (): Locale[] => Object.keys(messages)\n\n const d = (value: Date | number, style?: string): LocalizedString =>\n formatDate(value, locale(), style, i18nConfig.dateFormats) as LocalizedString\n\n const n = (value: number, style?: string): LocalizedString =>\n formatNumber(value, locale(), style, i18nConfig.numberFormats) as LocalizedString\n\n const format = (message: string, values?: Record<string, unknown>): LocalizedString => {\n return coreInterpolate(message, values, locale()) as LocalizedString\n }\n\n const te = (key: string, loc?: string): boolean => {\n const msgs = messages[loc ?? locale()]\n return msgs !== undefined && key in msgs\n }\n\n const tm = (key: string, loc?: string): CompiledMessage | undefined => {\n const msgs = messages[loc ?? locale()]\n return msgs ? msgs[key] : undefined\n }\n\n return { locale, setLocale, t, loadMessages, getLocales, d, n, format, isLoading, loadedLocales, preloadLocale, te, tm }\n}\n","import { createContext } from 'solid-js'\nimport type { ParentComponent } from 'solid-js'\nimport { createFluentiContext } from './context'\nimport type { FluentiConfig, FluentiContext } from './context'\n\n/** Solid context object for i18n — used internally by useI18n() */\nexport const I18nCtx = createContext<FluentiContext>()\n\n/**\n * Provide i18n context to the component tree.\n *\n */\nexport const I18nProvider: ParentComponent<FluentiConfig> = (props) => {\n const ctx = createFluentiContext(props)\n return <I18nCtx.Provider value={ctx}>{props.children}</I18nCtx.Provider>\n}\n","import { useContext } from 'solid-js'\nimport { I18nCtx } from './provider'\nimport type { FluentiContext } from './context'\n\n/**\n * Access the i18n context from the nearest `<I18nProvider>`.\n *\n * Throws if no provider is found in the component tree.\n */\nexport function useI18n(): FluentiContext {\n const ctx = useContext(I18nCtx)\n if (ctx) {\n return ctx\n }\n\n throw new Error(\n 'useI18n() must be used inside an <I18nProvider>.',\n )\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/solid' 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","import type { JSX } from 'solid-js'\n\nfunction isNodeLike(value: unknown): value is Node {\n return typeof Node !== 'undefined' && value instanceof Node\n}\n\nfunction resolveValue(value: unknown): unknown {\n if (typeof value === 'function' && !(value as { length?: number }).length) {\n return (value as () => unknown)()\n }\n return value\n}\n\nimport { offsetIndices } from '@fluenti/core/internal'\n\nexport function extractMessage(value: unknown): {\n message: string\n components: Node[]\n} {\n const components: Node[] = []\n let message = ''\n\n function visit(node: unknown): void {\n const resolved = resolveValue(node)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const child of resolved) visit(child)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n message += String(resolved)\n return\n }\n if (!isNodeLike(resolved)) return\n if (resolved.nodeType === Node.TEXT_NODE) {\n message += resolved.textContent ?? ''\n return\n }\n if (resolved.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {\n visit(Array.from(resolved.childNodes))\n return\n }\n\n const idx = components.length\n const inner = extractMessage(Array.from(resolved.childNodes))\n components.push((resolved as Element).cloneNode(false))\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 visit(value)\n return { message, components }\n}\n\nfunction appendChild(parent: Node, child: unknown): void {\n const resolved = resolveValue(child)\n if (resolved === null || resolved === undefined || typeof resolved === 'boolean') return\n if (Array.isArray(resolved)) {\n for (const entry of resolved) appendChild(parent, entry)\n return\n }\n if (typeof resolved === 'string' || typeof resolved === 'number') {\n parent.appendChild(document.createTextNode(String(resolved)))\n return\n }\n if (isNodeLike(resolved)) {\n parent.appendChild(resolved)\n }\n}\n\nexport function reconstruct(\n translated: string,\n components: Node[],\n): JSX.Element {\n const combinedRe = /<(\\d+)(?:\\/>|(>)([\\s\\S]*?)<\\/\\1>)/g\n const result: unknown[] = []\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n combinedRe.lastIndex = 0\n match = combinedRe.exec(translated)\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 template = components[idx]\n\n if (isSelfClosing) {\n if (template) {\n result.push(template.cloneNode(false))\n }\n } else {\n const inner = reconstruct(match[2] !== undefined ? match[3]! : '', components)\n if (template) {\n const clone = template.cloneNode(false)\n appendChild(clone, inner)\n result.push(clone)\n } else {\n result.push(match[3] ?? '')\n }\n }\n\n lastIndex = combinedRe.lastIndex\n match = combinedRe.exec(translated)\n }\n\n if (lastIndex < translated.length) {\n result.push(translated.slice(lastIndex))\n }\n\n return (result.length <= 1 ? result[0] ?? '' : result) as JSX.Element\n}\n\nexport function serializeRichForms<T extends string>(\n keys: readonly T[],\n forms: Partial<Record<T, unknown>> & Record<string, unknown>,\n): {\n messages: Record<string, string>\n components: Node[]\n} {\n const messages: Record<string, string> = {}\n const components: Node[] = []\n\n for (const key of keys) {\n const value = forms[key]\n if (value === undefined) continue\n const extracted = extractMessage(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 = extractMessage(value)\n messages[key] = offsetIndices(extracted.message, components.length)\n components.push(...extracted.components)\n }\n\n return { messages, components }\n}\n\n","import { Dynamic } from 'solid-js/web'\nimport { children as resolveChildren, createMemo } from 'solid-js'\nimport type { Component, JSX } from 'solid-js'\nimport { useI18n } from './use-i18n'\nimport { extractMessage as extractDomMessage, reconstruct as reconstructDomMessage } from './rich-dom'\n\n/** A Solid component that accepts children */\nexport type RichComponent = Component<{ children?: JSX.Element }>\n\n/** Props for the `<Trans>` component */\nexport interface FluentiTransProps {\n /** Override auto-generated hash 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 /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Children — the content to translate (legacy API) */\n children?: JSX.Element\n /** Translated message string with XML-like tags (e.g. `<bold>text</bold>`) */\n message?: string\n /** Map of tag names to Solid components */\n components?: Record<string, RichComponent>\n /** @internal Pre-computed message from build plugin */\n __message?: string\n /** @internal Pre-computed component map from build plugin */\n __components?: Record<string, RichComponent>\n}\n\n/**\n * A token from parsing the message string.\n * Either a plain text segment or a tag with inner content.\n */\ninterface TextToken {\n readonly type: 'text'\n readonly value: string\n}\n\ninterface TagToken {\n readonly type: 'tag'\n readonly name: string\n readonly children: readonly Token[]\n}\n\ntype Token = TextToken | TagToken\n\n/**\n * Parse a message string containing XML-like tags into a token tree.\n *\n * Supports:\n * - Named tags: `<bold>content</bold>`\n * - Self-closing tags: `<br/>`\n * - Nested tags: `<bold>hello <italic>world</italic></bold>`\n */\nfunction parseTokens(input: string): readonly Token[] {\n const tokens: Token[] = []\n let pos = 0\n\n while (pos < input.length) {\n const openIdx = input.indexOf('<', pos)\n\n if (openIdx === -1) {\n // No more tags — rest is plain text\n tokens.push({ type: 'text', value: input.slice(pos) })\n break\n }\n\n // Push any text before this tag\n if (openIdx > pos) {\n tokens.push({ type: 'text', value: input.slice(pos, openIdx) })\n }\n\n // Check for self-closing tag: <tagName/>\n const selfCloseMatch = input.slice(openIdx).match(/^<(\\w+)\\s*\\/>/)\n if (selfCloseMatch) {\n tokens.push({ type: 'tag', name: selfCloseMatch[1]!, children: [] })\n pos = openIdx + selfCloseMatch[0].length\n continue\n }\n\n // Check for opening tag: <tagName>\n const openMatch = input.slice(openIdx).match(/^<(\\w+)>/)\n if (!openMatch) {\n // Not a valid tag — treat '<' as text\n tokens.push({ type: 'text', value: '<' })\n pos = openIdx + 1\n continue\n }\n\n const tagName = openMatch[1]!\n const contentStart = openIdx + openMatch[0].length\n\n // Find the matching closing tag, respecting nesting\n const innerEnd = findClosingTag(input, tagName, contentStart)\n if (innerEnd === -1) {\n // No closing tag found — treat as plain text\n tokens.push({ type: 'text', value: input.slice(openIdx, contentStart) })\n pos = contentStart\n continue\n }\n\n const innerContent = input.slice(contentStart, innerEnd)\n const closingTag = `</${tagName}>`\n tokens.push({\n type: 'tag',\n name: tagName,\n children: parseTokens(innerContent),\n })\n pos = innerEnd + closingTag.length\n }\n\n return tokens\n}\n\n/**\n * Find the position of the matching closing tag, accounting for nesting\n * of the same tag name.\n *\n * Returns the index of the start of the closing tag, or -1 if not found.\n */\nfunction findClosingTag(input: string, tagName: string, startPos: number): number {\n const openTag = `<${tagName}>`\n const closeTag = `</${tagName}>`\n let depth = 1\n let pos = startPos\n\n while (pos < input.length && depth > 0) {\n const nextOpen = input.indexOf(openTag, pos)\n const nextClose = input.indexOf(closeTag, pos)\n\n if (nextClose === -1) return -1\n\n if (nextOpen !== -1 && nextOpen < nextClose) {\n depth++\n pos = nextOpen + openTag.length\n } else {\n depth--\n if (depth === 0) return nextClose\n pos = nextClose + closeTag.length\n }\n }\n\n return -1\n}\n\n/**\n * Render a token tree into Solid JSX elements using the components map.\n */\nfunction renderTokens(\n tokens: readonly Token[],\n components: Record<string, RichComponent>,\n): JSX.Element {\n const elements = tokens.map((token): JSX.Element => {\n if (token.type === 'text') {\n return token.value as unknown as JSX.Element\n }\n\n const Comp = components[token.name]\n if (!Comp) {\n // Unknown component — render inner content as plain text\n return renderTokens(token.children, components)\n }\n\n const innerContent = token.children.length > 0\n ? renderTokens(token.children, components)\n : undefined\n\n return (<Dynamic component={Comp}>{innerContent}</Dynamic>) as JSX.Element\n })\n\n if (elements.length === 1) return elements[0]!\n return (<>{elements}</>) as JSX.Element\n}\n\n/**\n * Render translated content with inline components.\n *\n * Supports two APIs:\n *\n * 1. **message + components** (recommended for rich text):\n * ```tsx\n * <Trans\n * message={t`Welcome to <bold>Fluenti</bold>!`}\n * components={{ bold: (props) => <strong>{props.children}</strong> }}\n * />\n * ```\n *\n * 2. **children** (legacy / simple passthrough):\n * ```tsx\n * <Trans>Click <a href=\"/next\">here</a> to continue</Trans>\n * ```\n */\nexport const Trans: Component<FluentiTransProps> = (props) => {\n const { t } = useI18n()\n const resolvedChildren = resolveChildren(() => props.children)\n // message + components API (including build-time __message/__components)\n // Note: the vite-plugin tagged-template transform wraps Solid expressions in\n // createMemo(), so props.message may be a memo accessor (function) instead of\n // a string. We unwrap it here to handle both cases.\n const message = createMemo(() => {\n const raw = props.__message ?? props.message\n return typeof raw === 'function' ? (raw as () => string)() : raw\n })\n const components = createMemo(() => props.__components ?? props.components)\n\n return (() => {\n const msg = message()\n const comps = components()\n\n if (msg !== undefined && comps) {\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: msg,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const tokens = parseTokens(translated)\n return renderTokens(tokens, comps)\n }\n\n // Fallback: children-only API with runtime extraction/reconstruction\n const children = resolvedChildren.toArray()\n if (children.length === 0) return null\n const extracted = extractDomMessage(children)\n const translated = t({\n ...(props.id !== undefined ? { id: props.id } : {}),\n message: extracted.message,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n })\n const result = extracted.components.length > 0\n ? reconstructDomMessage(translated, extracted.components)\n : translated\n\n if (Array.isArray(result) && result.length > 1) {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }\n\n return result as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { Dynamic } from 'solid-js/web'\nimport type { Component, JSX } from 'solid-js'\nimport { hashMessage, buildICUPluralMessage, PLURAL_CATEGORIES, type PluralCategory } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Plural>` component */\nexport interface FluentiPluralProps {\n /** The numeric value to pluralise */\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 /** Offset from value before selecting form */\n offset?: number\n /** Message for the \"zero\" plural category */\n zero?: string | JSX.Element\n /** Message for the \"one\" plural category */\n one?: string | JSX.Element\n /** Message for the \"two\" plural category */\n two?: string | JSX.Element\n /** Message for the \"few\" plural category */\n few?: string | JSX.Element\n /** Message for the \"many\" plural category */\n many?: string | JSX.Element\n /** Fallback message when no category-specific prop matches */\n other: string | JSX.Element\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n}\n\n/**\n * `<Plural>` component — shorthand for ICU plural patterns.\n *\n * Plural form props (`zero`, `one`, `two`, `few`, `many`, `other`) are treated\n * as source-language messages. The component builds an ICU plural message,\n * looks it up via `t()` in the catalog, and interpolates the translated result.\n *\n * When no catalog translation exists, the component falls back to interpolating\n * the source-language ICU message directly via core's `interpolate`.\n *\n * Rich text is supported via JSX element props:\n * ```tsx\n * <Plural\n * value={count()}\n * zero={<>No <strong>items</strong> left</>}\n * one={<><em>1</em> item remaining</>}\n * other={<><strong>{count()}</strong> items remaining</>}\n * />\n * ```\n *\n * String props still work (backward compatible):\n * ```tsx\n * <Plural value={count()} zero=\"No items\" one=\"# item\" other=\"# items\" />\n * ```\n */\nexport const Plural: Component<FluentiPluralProps> = (props) => {\n const { t } = useI18n()\n\n /** Resolve a category prop value — handles string, accessor function, and JSX */\n function resolveProp(val: string | JSX.Element | undefined): string | JSX.Element | undefined {\n if (typeof val === 'function') return (val as () => string | JSX.Element)()\n return val\n }\n\n return (() => {\n // Resolve all category values (handles Solid accessors from createMemo)\n const resolvedValues: Partial<Record<PluralCategory, string | JSX.Element>> = {}\n for (const cat of PLURAL_CATEGORIES) {\n const resolved = resolveProp(props[cat])\n if (resolved !== undefined) {\n resolvedValues[cat] = resolved\n }\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, resolvedValues)\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 props.offset,\n )\n\n const translated = t(\n {\n id: props.id ?? (props.context === undefined ? icuMessage : hashMessage(icuMessage, props.context)),\n message: icuMessage,\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { count: props.value },\n )\n\n const result = components.length > 0 ? reconstruct(translated, components) : translated\n if (props.tag) {\n return (<Dynamic component={props.tag}>{result}</Dynamic>) as JSX.Element\n }\n return (<>{result}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import type { Component, JSX } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { hashMessage, buildICUSelectMessage, normalizeSelectForms } from '@fluenti/core/internal'\nimport { useI18n } from './use-i18n'\nimport { reconstruct, serializeRichForms } from './rich-dom'\n\n/** Props for the `<Select>` component */\nexport interface FluentiSelectProps {\n /** The value to match against prop keys */\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 /** Fallback message when no key matches */\n other: string | JSX.Element\n /**\n * Named options map. Keys are match values, values are display strings or JSX.\n * Takes precedence over dynamic attrs when both are provided.\n *\n * @example `{ male: 'He', female: 'She' }`\n */\n options?: Record<string, string | JSX.Element>\n /** Wrapper element tag name. Defaults to no wrapper (Fragment). */\n tag?: string\n /** Additional key/message pairs for matching (attrs fallback) */\n [key: string]: unknown\n}\n\n/**\n * Render a message selected by matching `value` against prop keys.\n *\n * Options can be provided via the type-safe `options` prop (recommended)\n * or as direct attrs (convenience). When both are present, `options` takes\n * precedence.\n *\n * Rich text is supported via JSX element values in the `options` prop or\n * as direct JSX element props:\n * ```tsx\n * <Select\n * value={gender()}\n * options={{\n * male: <><strong>He</strong> liked this</>,\n * female: <><strong>She</strong> liked this</>,\n * }}\n * other={<><em>They</em> liked this</>}\n * />\n * ```\n *\n * Falls back to the `other` prop when no key matches.\n */\nexport const SelectComp: Component<FluentiSelectProps> = (props) => {\n const { t } = useI18n()\n\n const content = () => {\n const forms: Record<string, unknown> = props.options !== undefined\n ? { ...props.options, other: props.other }\n : {\n ...Object.fromEntries(\n Object.entries(props).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other', 'tag'].includes(key)),\n ),\n other: props.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([...orderedKeys].map((key) => [key, messages[key] ?? ''])),\n )\n const translated = t(\n {\n id: props.id ?? (props.context === undefined\n ? buildICUSelectMessage(normalized.forms)\n : hashMessage(buildICUSelectMessage(normalized.forms), props.context)),\n message: buildICUSelectMessage(normalized.forms),\n ...(props.context !== undefined ? { context: props.context } : {}),\n ...(props.comment !== undefined ? { comment: props.comment } : {}),\n },\n { value: normalized.valueMap[props.value] ?? 'other' },\n )\n\n return components.length > 0 ? reconstruct(translated, components) : translated\n }\n\n return (() => {\n if (props.tag) {\n return (<Dynamic component={props.tag}>{content()}</Dynamic>) as JSX.Element\n }\n return (<>{content()}</>) as JSX.Element\n }) as unknown as JSX.Element\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface DateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\n/** @alias DateTimeProps */\nexport type FluentiDateTimeProps = DateTimeProps\n\n/**\n * `<DateTime>` — date formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\nexport function DateTime(props: DateTimeProps) {\n const { d } = useI18n()\n return <>{d(props.value, props.format)}</>\n}\n","import { useI18n } from '../use-i18n'\n\nexport interface NumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n/** @alias NumberProps */\nexport type FluentiNumberFormatProps = NumberProps\n\n/**\n * `<NumberFormat>` — number formatting component using Intl APIs.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\nexport function NumberFormat(props: NumberProps) {\n const { n } = useI18n()\n return <>{n(props.value, props.format)}</>\n}\n"],"mappings":";;;;;AAeA,IAAM,IAAoB,OAAO,IAAI,2BAA2B;AAEhE,SAAS,IAAmD;CAC1D,IAAM,IAAW,WAA4C;AAC7D,QAAO,OAAO,KAAY,YAAY,IAClC,IACA;;AAGN,SAAS,EACP,GACiC;AACjC,QAAO,OAAO,KAAW,YAAY,KAAmB,aAAa,IAChE,EAAwD,UACzD;;AAyDN,SAAgB,EAAqB,GAA2D;CAC9F,IAAM,CAAC,GAAQ,KAAmB,EAAqB,EAAO,OAAO,EAC/D,CAAC,GAAW,KAAgB,EAAa,GAAM,EAC/C,IAAmB,IAAI,IAAY,CAAC,EAAO,OAAO,CAAC,EACnD,CAAC,GAAe,KAAoB,EAAa,IAAI,IAAI,EAAiB,CAAC,EAC3E,IAAqC,EAAE,GAAG,EAAO,UAAU,EAC3D,IAAa,GACb,IAAc,EAAW,cAAc,EAAkB,EAAW,YAAY,GAAG,KAAA,GACnF,IAAoB,EAAW,qBAC/B,EAAmD,aACpD;CAEL,SAAS,EACP,GACA,GACA,GAC6B;EAC7B,IAAM,IAAU,EAAS;AACzB,MAAI,CAAC,EACH;EAGF,IAAM,IAAM,EAAQ;AAChB,YAAQ,KAAA,EAYZ,QARI,OAAO,KAAQ,aACV,EAAI,EAAO,GAGhB,OAAO,KAAQ,YAAY,IACtB,EAAgB,GAAK,GAAQ,EAAI,GAGnC,OAAO,EAAI;;CAGpB,SAAS,EACP,GACA,GACA,GAC6B;EAC7B,IAAM,IAAyB,CAAC,EAAI,EAC9B,IAAO,IAAI,IAAI,EAAa;AAElC,EAAI,EAAO,kBAAkB,CAAC,EAAK,IAAI,EAAO,eAAe,KAC3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AC9E,CAAC,EACKmB,IAAahB,EACjB;GACEX,IAAIU,EAAMV,OAAOU,EAAMT,YAAYa,KAAAA,IAC/BrB,EAAsBgC,EAAWZ,MAAM,GACvCrB,EAAYC,EAAsBgC,EAAWZ,MAAM,EAAEH,EAAMT,QAAQ;GACvE2B,SAASnC,EAAsBgC,EAAWZ,MAAM;GAChD,GAAIH,EAAMT,YAAYa,KAAAA,IAAyC,EAAE,GAA/B,EAAEb,SAASS,EAAMT,SAAS;GAC5D,GAAIS,EAAMR,YAAYY,KAAAA,IAAyC,EAAE,GAA/B,EAAEZ,SAASQ,EAAMR,SAAS;GAC7D,EACD,EAAEH,OAAO0B,EAAWI,SAASnB,EAAMX,UAAU,SAC/C,CAAC;AAED,SAAOyB,EAAWM,SAAS,IAAIlC,EAAY+B,GAAYH,EAAW,GAAGG;;AAGvE,eACMjB,EAAMH,MACDwB,EAAExC,GAAO;EAAA,IAACyC,YAAS;AAAA,UAAEtB,EAAMH;;EAAG,IAAA0B,WAAA;AAAA,UAAGrB,GAAS;;EAAA,CAAA,GAE5CsB,EAAItB,EAAO;;;;ACtEtB,SAAgB6B,EAASC,GAAsB;CAC7C,IAAM,EAAEC,SAAMR,GAAS;AACvB,QAAAS,QAAUD,EAAED,EAAML,OAAOK,EAAMH,OAAO,CAAA;;;;ACFxC,SAAgBW,EAAaC,GAAoB;CAC/C,IAAM,EAAEC,SAAMP,GAAS;AACvB,QAAAQ,QAAUD,EAAED,EAAMJ,OAAOI,EAAMH,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluenti/solid",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SolidJS compile-time i18n — Trans/Plural/Select components, I18nProvider, useI18n",
|
|
6
6
|
"homepage": "https://fluenti.dev",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@fluenti/core": "0.3.
|
|
84
|
-
"@fluenti/vite-plugin": "0.3.
|
|
83
|
+
"@fluenti/core": "0.3.4",
|
|
84
|
+
"@fluenti/vite-plugin": "0.3.4"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@solidjs/testing-library": "^0.8",
|
|
@@ -3,19 +3,22 @@ import { useI18n } from '../use-i18n'
|
|
|
3
3
|
export interface DateTimeProps {
|
|
4
4
|
/** Date value to format */
|
|
5
5
|
value: Date | number
|
|
6
|
-
/** Named format
|
|
7
|
-
|
|
6
|
+
/** Named format key defined in dateFormats config */
|
|
7
|
+
format?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** @alias DateTimeProps */
|
|
11
|
+
export type FluentiDateTimeProps = DateTimeProps
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* `<DateTime>` — date formatting component using Intl APIs.
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```tsx
|
|
15
|
-
* <DateTime value={new Date()}
|
|
18
|
+
* <DateTime value={new Date()} format="long" />
|
|
16
19
|
* ```
|
|
17
20
|
*/
|
|
18
21
|
export function DateTime(props: DateTimeProps) {
|
|
19
22
|
const { d } = useI18n()
|
|
20
|
-
return <>{d(props.value, props.
|
|
23
|
+
return <>{d(props.value, props.format)}</>
|
|
21
24
|
}
|
|
@@ -3,19 +3,22 @@ import { useI18n } from '../use-i18n'
|
|
|
3
3
|
export interface NumberProps {
|
|
4
4
|
/** Number value to format */
|
|
5
5
|
value: number
|
|
6
|
-
/** Named format
|
|
7
|
-
|
|
6
|
+
/** Named format key defined in numberFormats config */
|
|
7
|
+
format?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** @alias NumberProps */
|
|
11
|
+
export type FluentiNumberFormatProps = NumberProps
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* `<NumberFormat>` — number formatting component using Intl APIs.
|
|
12
15
|
*
|
|
13
16
|
* @example
|
|
14
17
|
* ```tsx
|
|
15
|
-
* <NumberFormat value={1234.56}
|
|
18
|
+
* <NumberFormat value={1234.56} format="currency" />
|
|
16
19
|
* ```
|
|
17
20
|
*/
|
|
18
21
|
export function NumberFormat(props: NumberProps) {
|
|
19
22
|
const { n } = useI18n()
|
|
20
|
-
return <>{n(props.value, props.
|
|
23
|
+
return <>{n(props.value, props.format)}</>
|
|
21
24
|
}
|
package/src/context.ts
CHANGED
|
@@ -166,9 +166,13 @@ export function createFluentiContext(config: FluentiCoreConfig | FluentiConfig):
|
|
|
166
166
|
return undefined
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
try {
|
|
170
|
+
const result = config.missing(loc, id)
|
|
171
|
+
if (result !== undefined) {
|
|
172
|
+
return result as LocalizedString
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
// Missing handler threw — fall through to next resolution path
|
|
172
176
|
}
|
|
173
177
|
return undefined
|
|
174
178
|
}
|
|
@@ -204,8 +208,8 @@ export function createFluentiContext(config: FluentiCoreConfig | FluentiConfig):
|
|
|
204
208
|
if (Array.isArray(idOrStrings) && 'raw' in idOrStrings) {
|
|
205
209
|
const strings = idOrStrings as TemplateStringsArray
|
|
206
210
|
const icu = buildICUMessage(strings, rest)
|
|
207
|
-
const values = Object.fromEntries(rest.map((v, i) => [
|
|
208
|
-
return
|
|
211
|
+
const values = Object.fromEntries(rest.map((v, i) => [`arg${i}`, v]))
|
|
212
|
+
return resolveMessage(icu, locale(), values)
|
|
209
213
|
}
|
|
210
214
|
|
|
211
215
|
const id = idOrStrings as string | MessageDescriptor
|
|
@@ -242,6 +246,8 @@ export function createFluentiContext(config: FluentiCoreConfig | FluentiConfig):
|
|
|
242
246
|
setLoadedLocales(new Set(loadedLocalesSet))
|
|
243
247
|
}
|
|
244
248
|
|
|
249
|
+
let _localeRequestId = 0
|
|
250
|
+
|
|
245
251
|
const setLocale = async (newLocale: Locale): Promise<void> => {
|
|
246
252
|
if (!lazyLocaleLoading || !i18nConfig.chunkLoader) {
|
|
247
253
|
setLocaleSignal(newLocale)
|
|
@@ -258,24 +264,36 @@ export function createFluentiContext(config: FluentiCoreConfig | FluentiConfig):
|
|
|
258
264
|
return
|
|
259
265
|
}
|
|
260
266
|
|
|
267
|
+
// Race-condition protection: track request ID
|
|
268
|
+
const thisRequest = ++_localeRequestId
|
|
261
269
|
setIsLoading(true)
|
|
262
270
|
try {
|
|
263
271
|
const loaded = resolveChunkMessages(await i18nConfig.chunkLoader(newLocale))
|
|
272
|
+
// Always store loaded messages — they may be needed if locale is switched back
|
|
264
273
|
// Intentional mutation: messages record is locally scoped to this context closure
|
|
265
274
|
messages[newLocale] = { ...messages[newLocale], ...loaded }
|
|
266
275
|
loadedLocalesSet.add(newLocale)
|
|
267
276
|
setLoadedLocales(new Set(loadedLocalesSet))
|
|
277
|
+
// Stale request — a newer setLocale call superseded this one; don't switch locale
|
|
278
|
+
if (thisRequest !== _localeRequestId) return
|
|
268
279
|
if (splitRuntime?.__switchLocale) {
|
|
269
280
|
await splitRuntime.__switchLocale(newLocale)
|
|
270
281
|
}
|
|
282
|
+
// Re-check after async __switchLocale — a newer setLocale() may have superseded this one
|
|
283
|
+
if (thisRequest !== _localeRequestId) return
|
|
271
284
|
setLocaleSignal(newLocale)
|
|
272
285
|
} finally {
|
|
273
|
-
|
|
286
|
+
if (thisRequest === _localeRequestId) {
|
|
287
|
+
setIsLoading(false)
|
|
288
|
+
}
|
|
274
289
|
}
|
|
275
290
|
}
|
|
276
291
|
|
|
292
|
+
const _preloadInFlight = new Set<string>()
|
|
293
|
+
|
|
277
294
|
const preloadLocale = (loc: string): void => {
|
|
278
|
-
if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader) return
|
|
295
|
+
if (!lazyLocaleLoading || loadedLocalesSet.has(loc) || !i18nConfig.chunkLoader || _preloadInFlight.has(loc)) return
|
|
296
|
+
_preloadInFlight.add(loc)
|
|
279
297
|
const splitRuntime = getSplitRuntimeModule()
|
|
280
298
|
i18nConfig.chunkLoader(loc).then(async (loaded) => {
|
|
281
299
|
const resolved = resolveChunkMessages(loaded)
|
|
@@ -288,6 +306,8 @@ export function createFluentiContext(config: FluentiCoreConfig | FluentiConfig):
|
|
|
288
306
|
}
|
|
289
307
|
}).catch((e: unknown) => {
|
|
290
308
|
console.warn('[fluenti] preload failed:', loc, e)
|
|
309
|
+
}).finally(() => {
|
|
310
|
+
_preloadInFlight.delete(loc)
|
|
291
311
|
})
|
|
292
312
|
}
|
|
293
313
|
|
package/src/index.ts
CHANGED
|
@@ -11,4 +11,6 @@ export { SelectComp as Select } from './select'
|
|
|
11
11
|
export type { FluentiSelectProps } from './select'
|
|
12
12
|
export { msg } from './msg'
|
|
13
13
|
export { DateTime } from './components/DateTime'
|
|
14
|
+
export type { DateTimeProps, FluentiDateTimeProps } from './components/DateTime'
|
|
14
15
|
export { NumberFormat } from './components/NumberFormat'
|
|
16
|
+
export type { NumberProps, FluentiNumberFormatProps } from './components/NumberFormat'
|