@fluenti/react 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/Number-DfzWPfIE.js +142 -0
- package/dist/Number-DfzWPfIE.js.map +1 -0
- package/dist/Number-JCugssFE.cjs +2 -0
- package/dist/Number-JCugssFE.cjs.map +1 -0
- package/dist/components-entry.cjs +1 -1
- package/dist/components-entry.cjs.map +1 -1
- package/dist/components-entry.js +63 -84
- package/dist/components-entry.js.map +1 -1
- package/dist/icu-rich-BlDjwT5Z.cjs +2 -0
- package/dist/icu-rich-BlDjwT5Z.cjs.map +1 -0
- package/dist/{icu-rich-ChVWsA7C.js → icu-rich-C6B9ns4t.js} +7 -4
- package/dist/icu-rich-C6B9ns4t.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +77 -77
- package/dist/react/src/compile-time-t.d.ts.map +1 -0
- package/dist/react/src/components/DateTime.d.ts.map +1 -0
- package/dist/react/src/components/Number.d.ts.map +1 -0
- package/dist/react/src/components/Plural.d.ts.map +1 -0
- package/dist/react/src/components/Select.d.ts.map +1 -0
- package/dist/{components → react/src/components}/Trans.d.ts +1 -1
- package/dist/react/src/components/Trans.d.ts.map +1 -0
- package/dist/react/src/components/compiled.d.ts +46 -0
- package/dist/react/src/components/compiled.d.ts.map +1 -0
- package/dist/{components → react/src/components}/icu-rich.d.ts +1 -1
- package/dist/react/src/components/icu-rich.d.ts.map +1 -0
- package/dist/react/src/components/plain.d.ts +9 -0
- package/dist/react/src/components/plain.d.ts.map +1 -0
- package/dist/{components → react/src/components}/plural-core.d.ts +2 -2
- package/dist/react/src/components/plural-core.d.ts.map +1 -0
- package/dist/{components → react/src/components}/trans-core.d.ts +1 -1
- package/dist/react/src/components/trans-core.d.ts.map +1 -0
- package/dist/{components-entry.d.ts → react/src/components-entry.d.ts} +1 -1
- package/dist/react/src/components-entry.d.ts.map +1 -0
- package/dist/react/src/context.d.ts.map +1 -0
- package/dist/react/src/create-fluenti.d.ts.map +1 -0
- package/dist/react/src/global-registry.d.ts.map +1 -0
- package/dist/react/src/hooks/__useI18n.d.ts.map +1 -0
- package/dist/react/src/hooks/useI18n.d.ts.map +1 -0
- package/dist/{index.d.ts → react/src/index.d.ts} +7 -2
- package/dist/react/src/index.d.ts.map +1 -0
- package/dist/react/src/msg.d.ts.map +1 -0
- package/dist/react/src/provider.d.ts.map +1 -0
- package/dist/react/src/react-runtime.d.ts.map +1 -0
- package/dist/{server.d.ts → react/src/server.d.ts} +2 -2
- package/dist/react/src/server.d.ts.map +1 -0
- package/dist/{types.d.ts → react/src/types.d.ts} +1 -1
- package/dist/react/src/types.d.ts.map +1 -0
- package/dist/react/src/vite-plugin.d.ts.map +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/vite-plugin.cjs +1 -1
- package/dist/vite-plugin.cjs.map +1 -1
- package/dist/vite-plugin.js +1 -1
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +18 -18
- package/dist/compile-time-t.d.ts.map +0 -1
- package/dist/components/DateTime.d.ts.map +0 -1
- package/dist/components/Number.d.ts.map +0 -1
- package/dist/components/Plural.d.ts.map +0 -1
- package/dist/components/Select.d.ts.map +0 -1
- package/dist/components/Trans.d.ts.map +0 -1
- package/dist/components/icu-rich.d.ts.map +0 -1
- package/dist/components/plural-core.d.ts.map +0 -1
- package/dist/components/trans-core.d.ts.map +0 -1
- package/dist/components-entry.d.ts.map +0 -1
- package/dist/context-DVbvrSE8.cjs +0 -2
- package/dist/context-DVbvrSE8.cjs.map +0 -1
- package/dist/context-DVudCV1o.js +0 -7
- package/dist/context-DVudCV1o.js.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/create-fluenti.d.ts.map +0 -1
- package/dist/global-registry.d.ts.map +0 -1
- package/dist/hooks/__useI18n.d.ts.map +0 -1
- package/dist/hooks/useI18n.d.ts.map +0 -1
- package/dist/icu-rich-ChVWsA7C.js.map +0 -1
- package/dist/icu-rich-CotMVC_x.cjs +0 -2
- package/dist/icu-rich-CotMVC_x.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/msg.d.ts.map +0 -1
- package/dist/provider.d.ts.map +0 -1
- package/dist/react-runtime.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/vite-plugin.d.ts.map +0 -1
- /package/dist/{compile-time-t.d.ts → react/src/compile-time-t.d.ts} +0 -0
- /package/dist/{components → react/src/components}/DateTime.d.ts +0 -0
- /package/dist/{components → react/src/components}/Number.d.ts +0 -0
- /package/dist/{components → react/src/components}/Plural.d.ts +0 -0
- /package/dist/{components → react/src/components}/Select.d.ts +0 -0
- /package/dist/{context.d.ts → react/src/context.d.ts} +0 -0
- /package/dist/{create-fluenti.d.ts → react/src/create-fluenti.d.ts} +0 -0
- /package/dist/{global-registry.d.ts → react/src/global-registry.d.ts} +0 -0
- /package/dist/{hooks → react/src/hooks}/__useI18n.d.ts +0 -0
- /package/dist/{hooks → react/src/hooks}/useI18n.d.ts +0 -0
- /package/dist/{msg.d.ts → react/src/msg.d.ts} +0 -0
- /package/dist/{provider.d.ts → react/src/provider.d.ts} +0 -0
- /package/dist/{react-runtime.d.ts → react/src/react-runtime.d.ts} +0 -0
- /package/dist/{vite-plugin.d.ts → react/src/vite-plugin.d.ts} +0 -0
|
@@ -4,11 +4,16 @@ export { I18nProvider } from './provider';
|
|
|
4
4
|
export { I18nContext } from './context';
|
|
5
5
|
export { useI18n, useLocale } from './hooks/useI18n';
|
|
6
6
|
export { t } from './compile-time-t';
|
|
7
|
-
export {
|
|
8
|
-
export type { FluentiContext, I18nProviderProps, Messages, AllMessages, MessageDescriptor, CompileTimeMessageDescriptor, CompileTimeT, Locale, DateFormatOptions, NumberFormatOptions, } from './types';
|
|
7
|
+
export { Trans } from './components/Trans';
|
|
9
8
|
export type { FluentiTransProps } from './components/Trans';
|
|
9
|
+
export { Plural } from './components/Plural';
|
|
10
10
|
export type { FluentiPluralProps } from './components/Plural';
|
|
11
|
+
export { Select } from './components/Select';
|
|
11
12
|
export type { FluentiSelectProps } from './components/Select';
|
|
13
|
+
export { DateTime } from './components/DateTime';
|
|
12
14
|
export type { FluentiDateTimeProps } from './components/DateTime';
|
|
15
|
+
export { NumberFormat } from './components/Number';
|
|
13
16
|
export type { NumberFormatProps, FluentiNumberFormatProps } from './components/Number';
|
|
17
|
+
export { msg } from './msg';
|
|
18
|
+
export type { FluentiContext, I18nProviderProps, Messages, AllMessages, MessageDescriptor, CompileTimeMessageDescriptor, CompileTimeT, Locale, DateFormatOptions, NumberFormatOptions, } from './types';
|
|
14
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGtE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAGvC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AAGpC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAGtF,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAG3B,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,4BAA4B,EAC5B,YAAY,EACZ,MAAM,EACN,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msg.d.ts","sourceRoot":"","sources":["../../../src/msg.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAkB,MAAM,SAAS,CAAA;AAiCnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,oBAAoB,2CAMvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-runtime.d.ts","sourceRoot":"","sources":["../../../src/react-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,eAAO,MAAM,qBAAqB,EAAE,gBAUlC,CAAA"}
|
|
@@ -48,12 +48,12 @@ export interface ServerI18nConfig {
|
|
|
48
48
|
* Custom interpolation function for ICU MessageFormat parsing.
|
|
49
49
|
*
|
|
50
50
|
* By default, the runtime uses a lightweight `{key}` replacer.
|
|
51
|
-
* Pass the full `interpolate` from `@fluenti/core` for runtime
|
|
51
|
+
* Pass the full `interpolate` from `@fluenti/core/runtime` for runtime
|
|
52
52
|
* ICU MessageFormat parsing (plurals, selects, nested arguments).
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```ts
|
|
56
|
-
* import { interpolate } from '@fluenti/core'
|
|
56
|
+
* import { interpolate } from '@fluenti/core/runtime'
|
|
57
57
|
* createServerI18n({ interpolate, ... })
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAA2B,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAMlF,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG;QAAE,OAAO,EAAE,QAAQ,CAAA;KAAE,CAAC,CAAA;IAC3E,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,aAAa,CAAC,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,wCAAwC;IACxC,aAAa,CAAC,EAAE,MAAM,CAA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W,UAAU;IACzB;;;;;OAKG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAEnC;;;;;;;;;;OAUG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,uBAAuB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAEpE;;;;;;;;OAQG;IACH,KAAK,EAAE,oBAAoB,CAAA;IAE3B;;;;;;;OAOG;IACH,MAAM,EAAE,qBAAqB,CAAA;IAE7B;;;;;;;OAOG;IACH,MAAM,EAAE,qBAAqB,CAAA;IAE7B;;;;;;;OAOG;IACH,QAAQ,EAAE,uBAAuB,CAAA;IAEjC;;;;;;;OAOG;IACH,YAAY,EAAE,qBAAqB,CAAA;IAEnC;;;OAGG;IACH,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAEtD;;;OAGG;IACH,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAA;IAE3E;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,uBAAuB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CACtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CA2RrE"}
|
|
@@ -54,7 +54,7 @@ export interface I18nProviderProps {
|
|
|
54
54
|
diagnostics?: DiagnosticsConfig;
|
|
55
55
|
/**
|
|
56
56
|
* Custom message interpolation function.
|
|
57
|
-
* Pass `interpolate` from `@fluenti/core/
|
|
57
|
+
* Pass `interpolate` from `@fluenti/core/runtime` for full ICU support at runtime.
|
|
58
58
|
*/
|
|
59
59
|
interpolate?: (message: string, values: Record<string, unknown> | undefined, locale: string, formatters?: Record<string, unknown>) => string;
|
|
60
60
|
/** App content */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EACV,MAAM,EACN,eAAe,EACf,QAAQ,EACR,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,4BAA4B,EAC5B,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,eAAe,CAAA;AAEtB,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,CAAC,EAAE;QACD,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CAAA;QACnF,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,eAAe,CAAA;KACtE,CAAA;IACD,iDAAiD;IACjD,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,eAAe,CAAA;IAC5D,mDAAmD;IACnD,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,eAAe,CAAA;IACrD,gEAAgE;IAChE,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,eAAe,CAAA;IAC9E,iEAAiE;IACjE,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC1D,wDAAwD;IACxD,UAAU,EAAE,MAAM,MAAM,EAAE,CAAA;IAC1B,qBAAqB;IACrB,MAAM,EAAE,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AAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;IAC5I,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,kBAAkB,EAAE,eAAe,CAAA;CACtD;AAED,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAA;AAEpD,YAAY,EACV,MAAM,EACN,eAAe,EACf,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,4BAA4B,EAC5B,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACpB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../../../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,YAAY,EAAE,oBAAoB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAM7E"}
|
package/dist/server.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./icu-rich-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./icu-rich-BlDjwT5Z.cjs`);let t=require(`react`),n=require(`@fluenti/core`),r=require(`@fluenti/core/runtime`),i=require(`@fluenti/core/ssr`);function a(i){let a=(0,t.cache)(()=>({locale:null,instance:null})),o=(0,t.cache)(()=>new Map),s=null,c=0,l=0;function u(e){a().locale=e,c++,s=null}async function d(e){let t=o(),n=t.get(e);if(n)return n;let r=await i.loadMessages(e),a=typeof r==`object`&&r&&`default`in r?r.default:r;return t.set(e,a),a}async function f(){let e=a();!e.locale&&i.resolveLocale&&(e.locale=await i.resolveLocale());let t=e.locale;if(!t)throw Error(`[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), or provide a resolveLocale function in createServerI18n config to auto-detect locale in Server Actions and other contexts where the layout does not run.`);if(e.instance&&e.instance.locale===t)return e.instance;let r={};r[t]=await d(t),i.fallbackLocale&&i.fallbackLocale!==t&&(r[i.fallbackLocale]=await d(i.fallbackLocale));let o={locale:t,messages:r};return i.fallbackLocale!==void 0&&(o.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(o.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(o.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(o.numberFormats=i.numberFormats),i.missing!==void 0&&(o.missing=i.missing),i.interpolate!==void 0&&(o.interpolate=i.interpolate),e.instance=(0,n.createFluentiCore)(o),s=e.instance,l=c,e.instance}async function p({children:n,id:i,context:a,comment:o,render:s}){let c=await f(),{message:l,components:u}=e.r(n),d=i??(0,r.hashMessage)(l,a),p=e.i(c.t({id:d,message:l,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}}),u);return(0,t.createElement)(t.Fragment,null,s?s(p):p)}async function m({value:n,id:i,context:a,comment:o,zero:s,one:c,two:l,few:u,many:d,other:p,offset:m}){let h=await f(),{messages:g,components:_}=e.n(r.PLURAL_CATEGORIES,{zero:s,one:c,two:l,few:u,many:d,other:p}),v=(0,r.buildICUPluralMessage)({...g.zero!==void 0&&{zero:g.zero},...g.one!==void 0&&{one:g.one},...g.two!==void 0&&{two:g.two},...g.few!==void 0&&{few:g.few},...g.many!==void 0&&{many:g.many},other:g.other??``},m);return(0,t.createElement)(t.Fragment,null,e.t({id:i??(a===void 0?v:(0,r.hashMessage)(v,a)),message:v,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}},{count:n},(e,t)=>h.t(e,t),_))}async function h({value:n,id:i,context:a,comment:o,other:s,options:c,...l}){let u=await f(),d=c===void 0?{...Object.fromEntries(Object.entries(l).filter(([e])=>![`value`,`id`,`context`,`comment`,`options`,`other`].includes(e))),other:s}:{...c,other:s},p=[...Object.keys(d).filter(e=>e!==`other`),`other`],{messages:m,components:h}=e.n(p,d),g=(0,r.normalizeSelectForms)(Object.fromEntries([...p].map(e=>[e,m[e]??``]))),_=(0,r.buildICUSelectMessage)(g.forms);return(0,t.createElement)(t.Fragment,null,e.t({id:i??(a===void 0?_:(0,r.hashMessage)(_,a)),message:_,...a===void 0?{}:{context:a},...o===void 0?{}:{comment:o}},{value:g.valueMap[n]??`other`},(e,t)=>u.t(e,t),h))}async function g({value:e,format:n}){return(0,t.createElement)(t.Fragment,null,(await f()).d(e,n))}async function _({value:e,format:n}){return(0,t.createElement)(t.Fragment,null,(await f()).n(e,n))}function v(){let e=a();if(e.instance)return e.instance;if(s&&l===c)return s;let t=e.locale??i.fallbackLocale??`en`,r=o(),u={},d=r.get(t);if(d&&(u[t]=d),i.fallbackLocale&&i.fallbackLocale!==t){let e=r.get(i.fallbackLocale);e&&(u[i.fallbackLocale]=e)}let f={locale:t,messages:u};return i.fallbackLocale!==void 0&&(f.fallbackLocale=i.fallbackLocale),i.fallbackChain!==void 0&&(f.fallbackChain=i.fallbackChain),i.dateFormats!==void 0&&(f.dateFormats=i.dateFormats),i.numberFormats!==void 0&&(f.numberFormats=i.numberFormats),i.missing!==void 0&&(f.missing=i.missing),i.interpolate!==void 0&&(f.interpolate=i.interpolate),e.instance=(0,n.createFluentiCore)(f),e.instance}async function y(e,t){let n=await f();return(await d(t??n.locale))[e]!==void 0}async function b(e,t){let n=await f();return(await d(t??n.locale))[e]}return{setLocale:u,getI18n:f,__getSyncInstance:v,te:y,tm:b,Trans:p,Plural:m,Select:h,DateTime:g,NumberFormat:_}}exports.createServerI18n=a,Object.defineProperty(exports,`detectLocale`,{enumerable:!0,get:function(){return i.detectLocale}}),Object.defineProperty(exports,`getDirection`,{enumerable:!0,get:function(){return n.getDirection}}),Object.defineProperty(exports,`getHydratedLocale`,{enumerable:!0,get:function(){return i.getHydratedLocale}}),Object.defineProperty(exports,`getSSRLocaleScript`,{enumerable:!0,get:function(){return i.getSSRLocaleScript}}),Object.defineProperty(exports,`isRTL`,{enumerable:!0,get:function(){return n.isRTL}});
|
|
2
2
|
//# sourceMappingURL=server.cjs.map
|
package/dist/server.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { cache } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull,\n FluentiCoreConfigFull,\n Locale,\n Messages,\n DateFormatOptions,\n NumberFormatOptions,\n} from '@fluenti/core'\nimport { hashMessage as hashSyntheticMessage } from '@fluenti/core/internal'\nimport { createElement, Fragment, type ReactNode, type ReactElement } from 'react'\nimport { hashMessage, extractMessage, reconstruct } from './components/trans-core'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './components/plural-core'\nimport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './components/icu-rich'\n\n// Re-export SSR utilities from core for convenience\nexport { detectLocale, getSSRLocaleScript, getHydratedLocale } from '@fluenti/core/ssr'\nexport type { DetectLocaleOptions } from '@fluenti/core/ssr'\nexport { isRTL, getDirection } from '@fluenti/core'\n\n/**\n * Configuration for `createServerI18n`.\n */\nexport interface ServerI18nConfig {\n /** Load messages for a given locale. Called once per locale per request. */\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string\n /**\n * Auto-resolve locale when `setLocale()` was not called.\n *\n * This is the fallback for contexts where the layout doesn't run — most\n * notably **Server Actions** (`'use server'`), which are independent\n * requests that skip the layout tree entirely.\n *\n * Common patterns:\n * - Read from a cookie (Next.js: `cookies().get('locale')`)\n * - Read from a request header set by middleware\n * - Query the database for the authenticated user's preference\n *\n * If omitted and `setLocale()` was not called, `getI18n()` will throw.\n *\n * @example\n * ```ts\n * resolveLocale: async () => {\n * const { cookies } = await import('next/headers')\n * return (await cookies()).get('locale')?.value ?? 'en'\n * }\n * ```\n */\n resolveLocale?: () => string | Promise<string>\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, Locale[]>\n /** Custom date format styles */\n dateFormats?: DateFormatOptions\n /** Custom number format styles */\n numberFormats?: NumberFormatOptions\n /** Handler for missing translation keys */\n missing?: (locale: Locale, id: string) => string | undefined\n /**\n * Custom interpolation function for ICU MessageFormat parsing.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core` for runtime\n * ICU MessageFormat parsing (plurals, selects, nested arguments).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core'\n * createServerI18n({ interpolate, ... })\n * ```\n */\n interpolate?: FluentiCoreConfigFull['interpolate']\n}\n\n// ─── Server Component Props ──────────────────────────────────────────────────\n\nexport interface ServerTransProps {\n /** Source text with embedded components */\n children: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n}\n\nexport interface ServerPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\nexport interface ServerSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}\n\nexport interface ServerDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\nexport interface ServerNumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n// ─── Server Component Types ──────────────────────────────────────────────────\n\ntype ServerTransComponent = (props: ServerTransProps) => Promise<ReactElement>\ntype ServerPluralComponent = (props: ServerPluralProps) => Promise<ReactElement>\ntype ServerSelectComponent = (props: ServerSelectProps) => Promise<ReactElement>\ntype ServerDateTimeComponent = (props: ServerDateTimeProps) => Promise<ReactElement>\ntype ServerNumberComponent = (props: ServerNumberProps) => Promise<ReactElement>\n\n/**\n * The object returned by `createServerI18n`.\n */\nexport interface ServerI18n {\n /**\n * Set the locale for the current server request.\n * Call this once in your root layout or page before any `getI18n()` calls.\n *\n * Uses `React.cache()` — scoped to the current request automatically.\n */\n setLocale: (locale: string) => void\n\n /**\n * Get a fully configured i18n instance for the current request.\n * Messages are loaded lazily and cached per-request.\n *\n * @example\n * ```tsx\n * // In any Server Component\n * const { t, d, n, locale } = await getI18n()\n * return <h1>{t('welcome')}</h1>\n * ```\n */\n getI18n: () => Promise<FluentiCoreInstanceFull & { locale: string }>\n\n /**\n * `<Trans>` for React Server Components.\n * Async component — automatically resolves the i18n instance.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * ```\n */\n Trans: ServerTransComponent\n\n /**\n * `<Plural>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Plural value={count} one=\"# item\" other=\"# items\" />\n * ```\n */\n Plural: ServerPluralComponent\n\n /**\n * `<Select>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Select value={gender} male=\"He liked this\" other=\"They liked this\" />\n * ```\n */\n Select: ServerSelectComponent\n\n /**\n * `<DateTime>` for React Server Components.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\n DateTime: ServerDateTimeComponent\n\n /**\n * `<NumberFormat>` for React Server Components.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\n NumberFormat: ServerNumberComponent\n\n /**\n * Check if a translation key exists in the catalog.\n * Optionally check a specific locale instead of the current one.\n */\n te: (key: string, locale?: string) => Promise<boolean>\n\n /**\n * Get the raw compiled message without interpolation.\n * Optionally look up in a specific locale instead of the current one.\n */\n tm: (key: string, locale?: string) => Promise<Messages[string] | undefined>\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used internally by @fluenti/next webpack loader.\n * @internal\n */\n __getSyncInstance: () => FluentiCoreInstanceFull & { locale: string }\n}\n\n/**\n * Create server-side i18n utilities for React Server Components.\n *\n * Uses `React.cache()` to share state within a single server request\n * without React Context (which is unavailable in Server Components).\n *\n * @example\n * ```ts\n * // lib/i18n.server.ts — define once\n * import { createServerI18n } from '@fluenti/react/server'\n *\n * export const { setLocale, getI18n, Trans, Plural, Select, DateTime, NumberFormat } = createServerI18n({\n * loadMessages: (locale) => import(`../messages/${locale}.json`),\n * fallbackLocale: 'en',\n * })\n * ```\n *\n * ```tsx\n * // app/[locale]/layout.tsx — set locale once\n * import { setLocale } from '@/lib/i18n.server'\n *\n * export default async function Layout({ params, children }) {\n * const { locale } = await params\n * setLocale(locale)\n * return <html lang={locale}><body>{children}</body></html>\n * }\n * ```\n *\n * ```tsx\n * // app/[locale]/page.tsx — use Trans, Plural, etc. directly\n * import { Trans, Plural, Select } from '@/lib/i18n.server'\n *\n * export default async function Page() {\n * return (\n * <div>\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * <Plural value={5} one=\"# item\" other=\"# items\" />\n * <Select value=\"male\" male=\"He liked this\" other=\"They liked this\" />\n * </div>\n * )\n * }\n * ```\n */\nexport function createServerI18n(config: ServerI18nConfig): ServerI18n {\n // Request-scoped store using React.cache()\n // Each server request gets its own isolated state\n const getRequestStore = cache((): {\n locale: string | null\n instance: (FluentiCoreInstanceFull & { locale: string }) | null\n } => ({\n locale: null,\n instance: null,\n }))\n\n // Cache loaded messages per-request to avoid redundant imports\n const getMessageCache = cache((): Map<string, Messages> => new Map())\n\n // Module-level fallback for server actions where React.cache()\n // may not share state with the page render.\n let _lastInstance: (FluentiCoreInstanceFull & { locale: string }) | null = null\n let _requestId = 0\n let _lastRequestId = 0\n\n function setLocale(locale: string): void {\n getRequestStore().locale = locale\n _requestId++\n _lastInstance = null\n }\n\n async function loadLocaleMessages(locale: string): Promise<Messages> {\n const messageCache = getMessageCache()\n const cached = messageCache.get(locale)\n if (cached) return cached\n\n const raw = await config.loadMessages(locale)\n const messages: Messages =\n typeof raw === 'object' && raw !== null && 'default' in raw\n ? (raw as { default: Messages }).default\n : (raw as Messages)\n\n messageCache.set(locale, messages)\n return messages\n }\n\n async function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }> {\n const store = getRequestStore()\n\n // If setLocale() was never called (e.g. Server Action — independent request\n // that skips the layout), try the resolveLocale fallback.\n if (!store.locale && config.resolveLocale) {\n store.locale = await config.resolveLocale()\n }\n\n const locale = store.locale\n\n if (!locale) {\n throw new Error(\n '[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), ' +\n 'or provide a resolveLocale function in createServerI18n config to auto-detect locale ' +\n 'in Server Actions and other contexts where the layout does not run.',\n )\n }\n\n // Return cached instance if locale hasn't changed\n if (store.instance && store.instance.locale === locale) {\n return store.instance\n }\n\n // Load messages for current locale (and fallback if configured)\n const allMessages: Record<string, Messages> = {}\n allMessages[locale] = await loadLocaleMessages(locale)\n\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n allMessages[config.fallbackLocale] = await loadLocaleMessages(config.fallbackLocale)\n }\n\n const fluentConfig: FluentiCoreConfigFull = {\n locale,\n messages: allMessages,\n }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n _lastInstance = store.instance\n _lastRequestId = _requestId\n return store.instance\n }\n\n // ─── Async Server Components ─────────────────────────────────────────────\n\n async function Trans({ children, id, context, comment, render }: ServerTransProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const { message, components } = extractMessage(children)\n const messageId = id ?? hashMessage(message, context)\n const translated = i18n.t({\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n })\n const result = reconstruct(translated, components)\n return createElement(Fragment, null, render ? render(result) : result)\n }\n\n async function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n }: ServerPluralProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function Select({\n value,\n id,\n context,\n comment,\n other,\n options,\n ...cases\n }: ServerSelectProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: normalized.valueMap[value] ?? 'other' },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function DateTime({ value, format }: ServerDateTimeProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.d(value, format))\n }\n\n async function NumberFormat({ value, format }: ServerNumberProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.n(value, format))\n }\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used by @fluenti/next webpack loader for t`` in RSC.\n *\n * Falls back to creating a minimal instance from the message cache when the\n * React.cache() request store hasn't been populated yet — this handles\n * Suspense boundaries and streamed components where React.cache() state\n * may not propagate from the layout render into streamed children.\n * @internal\n */\n function __getSyncInstance(): FluentiCoreInstanceFull & { locale: string } {\n const store = getRequestStore()\n if (store.instance) {\n return store.instance\n }\n\n // Module-level fallback for server actions where React.cache()\n // may not share state across different call contexts.\n // Only use within the same request (tracked by _requestId).\n if (_lastInstance && _lastRequestId === _requestId) {\n return _lastInstance\n }\n\n // Final fallback: create instance synchronously with the default locale.\n // This handles Suspense boundaries and streamed components where\n // the React.cache store may not have been populated yet.\n const locale = store.locale ?? config.fallbackLocale ?? 'en'\n const messageCache = getMessageCache()\n const messages: Record<string, Messages> = {}\n const cached = messageCache.get(locale)\n if (cached) messages[locale] = cached\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n const fallback = messageCache.get(config.fallbackLocale)\n if (fallback) messages[config.fallbackLocale] = fallback\n }\n\n const fluentConfig: FluentiCoreConfigFull = { locale, messages }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n return store.instance\n }\n\n /**\n * Check if a translation key exists in the catalog for the given (or current) locale.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function te(key: string, locale?: string): Promise<boolean> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key] !== undefined\n }\n\n /**\n * Get the raw compiled message for the given key without interpolation.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function tm(key: string, locale?: string): Promise<Messages[string] | undefined> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key]\n }\n\n return { setLocale, getI18n, __getSyncInstance, te, tm, Trans, Plural, Select, Date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AG,EAAa,EAAwD,CACrF,IAAM,EAAO,MAAM,GAAS,CAG5B,OADa,MAAM,EADE,GAAU,EAAK,OACe,EACvC,GAGd,MAAO,CAAE,YAAW,UAAS,oBAAmB,KAAI,KAAI,QAAO,SAAQ,SAAQ,WAAU,eAAc"}
|
|
1
|
+
{"version":3,"file":"server.cjs","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { cache } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull,\n FluentiCoreConfigFull,\n Locale,\n Messages,\n DateFormatOptions,\n NumberFormatOptions,\n} from '@fluenti/core'\nimport { hashMessage as hashSyntheticMessage } from '@fluenti/core/runtime'\nimport { createElement, Fragment, type ReactNode, type ReactElement } from 'react'\nimport { hashMessage, extractMessage, reconstruct } from './components/trans-core'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './components/plural-core'\nimport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './components/icu-rich'\n\n// Re-export SSR utilities from core for convenience\nexport { detectLocale, getSSRLocaleScript, getHydratedLocale } from '@fluenti/core/ssr'\nexport type { DetectLocaleOptions } from '@fluenti/core/ssr'\nexport { isRTL, getDirection } from '@fluenti/core'\n\n/**\n * Configuration for `createServerI18n`.\n */\nexport interface ServerI18nConfig {\n /** Load messages for a given locale. Called once per locale per request. */\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string\n /**\n * Auto-resolve locale when `setLocale()` was not called.\n *\n * This is the fallback for contexts where the layout doesn't run — most\n * notably **Server Actions** (`'use server'`), which are independent\n * requests that skip the layout tree entirely.\n *\n * Common patterns:\n * - Read from a cookie (Next.js: `cookies().get('locale')`)\n * - Read from a request header set by middleware\n * - Query the database for the authenticated user's preference\n *\n * If omitted and `setLocale()` was not called, `getI18n()` will throw.\n *\n * @example\n * ```ts\n * resolveLocale: async () => {\n * const { cookies } = await import('next/headers')\n * return (await cookies()).get('locale')?.value ?? 'en'\n * }\n * ```\n */\n resolveLocale?: () => string | Promise<string>\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, Locale[]>\n /** Custom date format styles */\n dateFormats?: DateFormatOptions\n /** Custom number format styles */\n numberFormats?: NumberFormatOptions\n /** Handler for missing translation keys */\n missing?: (locale: Locale, id: string) => string | undefined\n /**\n * Custom interpolation function for ICU MessageFormat parsing.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/runtime` for runtime\n * ICU MessageFormat parsing (plurals, selects, nested arguments).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/runtime'\n * createServerI18n({ interpolate, ... })\n * ```\n */\n interpolate?: FluentiCoreConfigFull['interpolate']\n}\n\n// ─── Server Component Props ──────────────────────────────────────────────────\n\nexport interface ServerTransProps {\n /** Source text with embedded components */\n children: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n}\n\nexport interface ServerPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\nexport interface ServerSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}\n\nexport interface ServerDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\nexport interface ServerNumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n// ─── Server Component Types ──────────────────────────────────────────────────\n\ntype ServerTransComponent = (props: ServerTransProps) => Promise<ReactElement>\ntype ServerPluralComponent = (props: ServerPluralProps) => Promise<ReactElement>\ntype ServerSelectComponent = (props: ServerSelectProps) => Promise<ReactElement>\ntype ServerDateTimeComponent = (props: ServerDateTimeProps) => Promise<ReactElement>\ntype ServerNumberComponent = (props: ServerNumberProps) => Promise<ReactElement>\n\n/**\n * The object returned by `createServerI18n`.\n */\nexport interface ServerI18n {\n /**\n * Set the locale for the current server request.\n * Call this once in your root layout or page before any `getI18n()` calls.\n *\n * Uses `React.cache()` — scoped to the current request automatically.\n */\n setLocale: (locale: string) => void\n\n /**\n * Get a fully configured i18n instance for the current request.\n * Messages are loaded lazily and cached per-request.\n *\n * @example\n * ```tsx\n * // In any Server Component\n * const { t, d, n, locale } = await getI18n()\n * return <h1>{t('welcome')}</h1>\n * ```\n */\n getI18n: () => Promise<FluentiCoreInstanceFull & { locale: string }>\n\n /**\n * `<Trans>` for React Server Components.\n * Async component — automatically resolves the i18n instance.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * ```\n */\n Trans: ServerTransComponent\n\n /**\n * `<Plural>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Plural value={count} one=\"# item\" other=\"# items\" />\n * ```\n */\n Plural: ServerPluralComponent\n\n /**\n * `<Select>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Select value={gender} male=\"He liked this\" other=\"They liked this\" />\n * ```\n */\n Select: ServerSelectComponent\n\n /**\n * `<DateTime>` for React Server Components.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\n DateTime: ServerDateTimeComponent\n\n /**\n * `<NumberFormat>` for React Server Components.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\n NumberFormat: ServerNumberComponent\n\n /**\n * Check if a translation key exists in the catalog.\n * Optionally check a specific locale instead of the current one.\n */\n te: (key: string, locale?: string) => Promise<boolean>\n\n /**\n * Get the raw compiled message without interpolation.\n * Optionally look up in a specific locale instead of the current one.\n */\n tm: (key: string, locale?: string) => Promise<Messages[string] | undefined>\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used internally by @fluenti/next webpack loader.\n * @internal\n */\n __getSyncInstance: () => FluentiCoreInstanceFull & { locale: string }\n}\n\n/**\n * Create server-side i18n utilities for React Server Components.\n *\n * Uses `React.cache()` to share state within a single server request\n * without React Context (which is unavailable in Server Components).\n *\n * @example\n * ```ts\n * // lib/i18n.server.ts — define once\n * import { createServerI18n } from '@fluenti/react/server'\n *\n * export const { setLocale, getI18n, Trans, Plural, Select, DateTime, NumberFormat } = createServerI18n({\n * loadMessages: (locale) => import(`../messages/${locale}.json`),\n * fallbackLocale: 'en',\n * })\n * ```\n *\n * ```tsx\n * // app/[locale]/layout.tsx — set locale once\n * import { setLocale } from '@/lib/i18n.server'\n *\n * export default async function Layout({ params, children }) {\n * const { locale } = await params\n * setLocale(locale)\n * return <html lang={locale}><body>{children}</body></html>\n * }\n * ```\n *\n * ```tsx\n * // app/[locale]/page.tsx — use Trans, Plural, etc. directly\n * import { Trans, Plural, Select } from '@/lib/i18n.server'\n *\n * export default async function Page() {\n * return (\n * <div>\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * <Plural value={5} one=\"# item\" other=\"# items\" />\n * <Select value=\"male\" male=\"He liked this\" other=\"They liked this\" />\n * </div>\n * )\n * }\n * ```\n */\nexport function createServerI18n(config: ServerI18nConfig): ServerI18n {\n // Request-scoped store using React.cache()\n // Each server request gets its own isolated state\n const getRequestStore = cache((): {\n locale: string | null\n instance: (FluentiCoreInstanceFull & { locale: string }) | null\n } => ({\n locale: null,\n instance: null,\n }))\n\n // Cache loaded messages per-request to avoid redundant imports\n const getMessageCache = cache((): Map<string, Messages> => new Map())\n\n // Module-level fallback for server actions where React.cache()\n // may not share state with the page render.\n let _lastInstance: (FluentiCoreInstanceFull & { locale: string }) | null = null\n let _requestId = 0\n let _lastRequestId = 0\n\n function setLocale(locale: string): void {\n getRequestStore().locale = locale\n _requestId++\n _lastInstance = null\n }\n\n async function loadLocaleMessages(locale: string): Promise<Messages> {\n const messageCache = getMessageCache()\n const cached = messageCache.get(locale)\n if (cached) return cached\n\n const raw = await config.loadMessages(locale)\n const messages: Messages =\n typeof raw === 'object' && raw !== null && 'default' in raw\n ? (raw as { default: Messages }).default\n : (raw as Messages)\n\n messageCache.set(locale, messages)\n return messages\n }\n\n async function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }> {\n const store = getRequestStore()\n\n // If setLocale() was never called (e.g. Server Action — independent request\n // that skips the layout), try the resolveLocale fallback.\n if (!store.locale && config.resolveLocale) {\n store.locale = await config.resolveLocale()\n }\n\n const locale = store.locale\n\n if (!locale) {\n throw new Error(\n '[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), ' +\n 'or provide a resolveLocale function in createServerI18n config to auto-detect locale ' +\n 'in Server Actions and other contexts where the layout does not run.',\n )\n }\n\n // Return cached instance if locale hasn't changed\n if (store.instance && store.instance.locale === locale) {\n return store.instance\n }\n\n // Load messages for current locale (and fallback if configured)\n const allMessages: Record<string, Messages> = {}\n allMessages[locale] = await loadLocaleMessages(locale)\n\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n allMessages[config.fallbackLocale] = await loadLocaleMessages(config.fallbackLocale)\n }\n\n const fluentConfig: FluentiCoreConfigFull = {\n locale,\n messages: allMessages,\n }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n _lastInstance = store.instance\n _lastRequestId = _requestId\n return store.instance\n }\n\n // ─── Async Server Components ─────────────────────────────────────────────\n\n async function Trans({ children, id, context, comment, render }: ServerTransProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const { message, components } = extractMessage(children)\n const messageId = id ?? hashMessage(message, context)\n const translated = i18n.t({\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n })\n const result = reconstruct(translated, components)\n return createElement(Fragment, null, render ? render(result) : result)\n }\n\n async function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n }: ServerPluralProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function Select({\n value,\n id,\n context,\n comment,\n other,\n options,\n ...cases\n }: ServerSelectProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: normalized.valueMap[value] ?? 'other' },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function DateTime({ value, format }: ServerDateTimeProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.d(value, format))\n }\n\n async function NumberFormat({ value, format }: ServerNumberProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.n(value, format))\n }\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used by @fluenti/next webpack loader for t`` in RSC.\n *\n * Falls back to creating a minimal instance from the message cache when the\n * React.cache() request store hasn't been populated yet — this handles\n * Suspense boundaries and streamed components where React.cache() state\n * may not propagate from the layout render into streamed children.\n * @internal\n */\n function __getSyncInstance(): FluentiCoreInstanceFull & { locale: string } {\n const store = getRequestStore()\n if (store.instance) {\n return store.instance\n }\n\n // Module-level fallback for server actions where React.cache()\n // may not share state across different call contexts.\n // Only use within the same request (tracked by _requestId).\n if (_lastInstance && _lastRequestId === _requestId) {\n return _lastInstance\n }\n\n // Final fallback: create instance synchronously with the default locale.\n // This handles Suspense boundaries and streamed components where\n // the React.cache store may not have been populated yet.\n const locale = store.locale ?? config.fallbackLocale ?? 'en'\n const messageCache = getMessageCache()\n const messages: Record<string, Messages> = {}\n const cached = messageCache.get(locale)\n if (cached) messages[locale] = cached\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n const fallback = messageCache.get(config.fallbackLocale)\n if (fallback) messages[config.fallbackLocale] = fallback\n }\n\n const fluentConfig: FluentiCoreConfigFull = { locale, messages }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n return store.instance\n }\n\n /**\n * Check if a translation key exists in the catalog for the given (or current) locale.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function te(key: string, locale?: string): Promise<boolean> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key] !== undefined\n }\n\n /**\n * Get the raw compiled message for the given key without interpolation.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function tm(key: string, locale?: string): Promise<Messages[string] | undefined> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key]\n }\n\n return { setLocale, getI18n, __getSyncInstance, te, tm, Trans, Plural, Select, DateTime, NumberFormat }\n}\n"],"mappings":"kOAsSA,SAAgB,EAAiB,EAAsC,CAGrE,IAAM,GAAA,EAAA,EAAA,YAGA,CACJ,OAAQ,KACR,SAAU,KACX,EAAE,CAGG,GAAA,EAAA,EAAA,WAAqD,IAAI,IAAM,CAIjE,EAAuE,KACvE,EAAa,EACb,EAAiB,E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,7 @@
|
|
|
1
|
-
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./icu-rich-
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./icu-rich-C6B9ns4t.js";
|
|
2
2
|
import { Fragment as l, cache as u, createElement as d } from "react";
|
|
3
3
|
import { createFluentiCore as f, getDirection as p, isRTL as m } from "@fluenti/core";
|
|
4
|
-
import { hashMessage as h } from "@fluenti/core/
|
|
4
|
+
import { hashMessage as h } from "@fluenti/core/runtime";
|
|
5
5
|
import { detectLocale as g, getHydratedLocale as _, getSSRLocaleScript as v } from "@fluenti/core/ssr";
|
|
6
6
|
//#region src/server.ts
|
|
7
7
|
function y(p) {
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { cache } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull,\n FluentiCoreConfigFull,\n Locale,\n Messages,\n DateFormatOptions,\n NumberFormatOptions,\n} from '@fluenti/core'\nimport { hashMessage as hashSyntheticMessage } from '@fluenti/core/internal'\nimport { createElement, Fragment, type ReactNode, type ReactElement } from 'react'\nimport { hashMessage, extractMessage, reconstruct } from './components/trans-core'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './components/plural-core'\nimport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './components/icu-rich'\n\n// Re-export SSR utilities from core for convenience\nexport { detectLocale, getSSRLocaleScript, getHydratedLocale } from '@fluenti/core/ssr'\nexport type { DetectLocaleOptions } from '@fluenti/core/ssr'\nexport { isRTL, getDirection } from '@fluenti/core'\n\n/**\n * Configuration for `createServerI18n`.\n */\nexport interface ServerI18nConfig {\n /** Load messages for a given locale. Called once per locale per request. */\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string\n /**\n * Auto-resolve locale when `setLocale()` was not called.\n *\n * This is the fallback for contexts where the layout doesn't run — most\n * notably **Server Actions** (`'use server'`), which are independent\n * requests that skip the layout tree entirely.\n *\n * Common patterns:\n * - Read from a cookie (Next.js: `cookies().get('locale')`)\n * - Read from a request header set by middleware\n * - Query the database for the authenticated user's preference\n *\n * If omitted and `setLocale()` was not called, `getI18n()` will throw.\n *\n * @example\n * ```ts\n * resolveLocale: async () => {\n * const { cookies } = await import('next/headers')\n * return (await cookies()).get('locale')?.value ?? 'en'\n * }\n * ```\n */\n resolveLocale?: () => string | Promise<string>\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, Locale[]>\n /** Custom date format styles */\n dateFormats?: DateFormatOptions\n /** Custom number format styles */\n numberFormats?: NumberFormatOptions\n /** Handler for missing translation keys */\n missing?: (locale: Locale, id: string) => string | undefined\n /**\n * Custom interpolation function for ICU MessageFormat parsing.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core` for runtime\n * ICU MessageFormat parsing (plurals, selects, nested arguments).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core'\n * createServerI18n({ interpolate, ... })\n * ```\n */\n interpolate?: FluentiCoreConfigFull['interpolate']\n}\n\n// ─── Server Component Props ──────────────────────────────────────────────────\n\nexport interface ServerTransProps {\n /** Source text with embedded components */\n children: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n}\n\nexport interface ServerPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\nexport interface ServerSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}\n\nexport interface ServerDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\nexport interface ServerNumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n// ─── Server Component Types ──────────────────────────────────────────────────\n\ntype ServerTransComponent = (props: ServerTransProps) => Promise<ReactElement>\ntype ServerPluralComponent = (props: ServerPluralProps) => Promise<ReactElement>\ntype ServerSelectComponent = (props: ServerSelectProps) => Promise<ReactElement>\ntype ServerDateTimeComponent = (props: ServerDateTimeProps) => Promise<ReactElement>\ntype ServerNumberComponent = (props: ServerNumberProps) => Promise<ReactElement>\n\n/**\n * The object returned by `createServerI18n`.\n */\nexport interface ServerI18n {\n /**\n * Set the locale for the current server request.\n * Call this once in your root layout or page before any `getI18n()` calls.\n *\n * Uses `React.cache()` — scoped to the current request automatically.\n */\n setLocale: (locale: string) => void\n\n /**\n * Get a fully configured i18n instance for the current request.\n * Messages are loaded lazily and cached per-request.\n *\n * @example\n * ```tsx\n * // In any Server Component\n * const { t, d, n, locale } = await getI18n()\n * return <h1>{t('welcome')}</h1>\n * ```\n */\n getI18n: () => Promise<FluentiCoreInstanceFull & { locale: string }>\n\n /**\n * `<Trans>` for React Server Components.\n * Async component — automatically resolves the i18n instance.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * ```\n */\n Trans: ServerTransComponent\n\n /**\n * `<Plural>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Plural value={count} one=\"# item\" other=\"# items\" />\n * ```\n */\n Plural: ServerPluralComponent\n\n /**\n * `<Select>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Select value={gender} male=\"He liked this\" other=\"They liked this\" />\n * ```\n */\n Select: ServerSelectComponent\n\n /**\n * `<DateTime>` for React Server Components.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\n DateTime: ServerDateTimeComponent\n\n /**\n * `<NumberFormat>` for React Server Components.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\n NumberFormat: ServerNumberComponent\n\n /**\n * Check if a translation key exists in the catalog.\n * Optionally check a specific locale instead of the current one.\n */\n te: (key: string, locale?: string) => Promise<boolean>\n\n /**\n * Get the raw compiled message without interpolation.\n * Optionally look up in a specific locale instead of the current one.\n */\n tm: (key: string, locale?: string) => Promise<Messages[string] | undefined>\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used internally by @fluenti/next webpack loader.\n * @internal\n */\n __getSyncInstance: () => FluentiCoreInstanceFull & { locale: string }\n}\n\n/**\n * Create server-side i18n utilities for React Server Components.\n *\n * Uses `React.cache()` to share state within a single server request\n * without React Context (which is unavailable in Server Components).\n *\n * @example\n * ```ts\n * // lib/i18n.server.ts — define once\n * import { createServerI18n } from '@fluenti/react/server'\n *\n * export const { setLocale, getI18n, Trans, Plural, Select, DateTime, NumberFormat } = createServerI18n({\n * loadMessages: (locale) => import(`../messages/${locale}.json`),\n * fallbackLocale: 'en',\n * })\n * ```\n *\n * ```tsx\n * // app/[locale]/layout.tsx — set locale once\n * import { setLocale } from '@/lib/i18n.server'\n *\n * export default async function Layout({ params, children }) {\n * const { locale } = await params\n * setLocale(locale)\n * return <html lang={locale}><body>{children}</body></html>\n * }\n * ```\n *\n * ```tsx\n * // app/[locale]/page.tsx — use Trans, Plural, etc. directly\n * import { Trans, Plural, Select } from '@/lib/i18n.server'\n *\n * export default async function Page() {\n * return (\n * <div>\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * <Plural value={5} one=\"# item\" other=\"# items\" />\n * <Select value=\"male\" male=\"He liked this\" other=\"They liked this\" />\n * </div>\n * )\n * }\n * ```\n */\nexport function createServerI18n(config: ServerI18nConfig): ServerI18n {\n // Request-scoped store using React.cache()\n // Each server request gets its own isolated state\n const getRequestStore = cache((): {\n locale: string | null\n instance: (FluentiCoreInstanceFull & { locale: string }) | null\n } => ({\n locale: null,\n instance: null,\n }))\n\n // Cache loaded messages per-request to avoid redundant imports\n const getMessageCache = cache((): Map<string, Messages> => new Map())\n\n // Module-level fallback for server actions where React.cache()\n // may not share state with the page render.\n let _lastInstance: (FluentiCoreInstanceFull & { locale: string }) | null = null\n let _requestId = 0\n let _lastRequestId = 0\n\n function setLocale(locale: string): void {\n getRequestStore().locale = locale\n _requestId++\n _lastInstance = null\n }\n\n async function loadLocaleMessages(locale: string): Promise<Messages> {\n const messageCache = getMessageCache()\n const cached = messageCache.get(locale)\n if (cached) return cached\n\n const raw = await config.loadMessages(locale)\n const messages: Messages =\n typeof raw === 'object' && raw !== null && 'default' in raw\n ? (raw as { default: Messages }).default\n : (raw as Messages)\n\n messageCache.set(locale, messages)\n return messages\n }\n\n async function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }> {\n const store = getRequestStore()\n\n // If setLocale() was never called (e.g. Server Action — independent request\n // that skips the layout), try the resolveLocale fallback.\n if (!store.locale && config.resolveLocale) {\n store.locale = await config.resolveLocale()\n }\n\n const locale = store.locale\n\n if (!locale) {\n throw new Error(\n '[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), ' +\n 'or provide a resolveLocale function in createServerI18n config to auto-detect locale ' +\n 'in Server Actions and other contexts where the layout does not run.',\n )\n }\n\n // Return cached instance if locale hasn't changed\n if (store.instance && store.instance.locale === locale) {\n return store.instance\n }\n\n // Load messages for current locale (and fallback if configured)\n const allMessages: Record<string, Messages> = {}\n allMessages[locale] = await loadLocaleMessages(locale)\n\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n allMessages[config.fallbackLocale] = await loadLocaleMessages(config.fallbackLocale)\n }\n\n const fluentConfig: FluentiCoreConfigFull = {\n locale,\n messages: allMessages,\n }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n _lastInstance = store.instance\n _lastRequestId = _requestId\n return store.instance\n }\n\n // ─── Async Server Components ─────────────────────────────────────────────\n\n async function Trans({ children, id, context, comment, render }: ServerTransProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const { message, components } = extractMessage(children)\n const messageId = id ?? hashMessage(message, context)\n const translated = i18n.t({\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n })\n const result = reconstruct(translated, components)\n return createElement(Fragment, null, render ? render(result) : result)\n }\n\n async function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n }: ServerPluralProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function Select({\n value,\n id,\n context,\n comment,\n other,\n options,\n ...cases\n }: ServerSelectProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: normalized.valueMap[value] ?? 'other' },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function DateTime({ value, format }: ServerDateTimeProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.d(value, format))\n }\n\n async function NumberFormat({ value, format }: ServerNumberProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.n(value, format))\n }\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used by @fluenti/next webpack loader for t`` in RSC.\n *\n * Falls back to creating a minimal instance from the message cache when the\n * React.cache() request store hasn't been populated yet — this handles\n * Suspense boundaries and streamed components where React.cache() state\n * may not propagate from the layout render into streamed children.\n * @internal\n */\n function __getSyncInstance(): FluentiCoreInstanceFull & { locale: string } {\n const store = getRequestStore()\n if (store.instance) {\n return store.instance\n }\n\n // Module-level fallback for server actions where React.cache()\n // may not share state across different call contexts.\n // Only use within the same request (tracked by _requestId).\n if (_lastInstance && _lastRequestId === _requestId) {\n return _lastInstance\n }\n\n // Final fallback: create instance synchronously with the default locale.\n // This handles Suspense boundaries and streamed components where\n // the React.cache store may not have been populated yet.\n const locale = store.locale ?? config.fallbackLocale ?? 'en'\n const messageCache = getMessageCache()\n const messages: Record<string, Messages> = {}\n const cached = messageCache.get(locale)\n if (cached) messages[locale] = cached\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n const fallback = messageCache.get(config.fallbackLocale)\n if (fallback) messages[config.fallbackLocale] = fallback\n }\n\n const fluentConfig: FluentiCoreConfigFull = { locale, messages }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n return store.instance\n }\n\n /**\n * Check if a translation key exists in the catalog for the given (or current) locale.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function te(key: string, locale?: string): Promise<boolean> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key] !== undefined\n }\n\n /**\n * Get the raw compiled message for the given key without interpolation.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function tm(key: string, locale?: string): Promise<Messages[string] | undefined> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key]\n }\n\n return { setLocale, getI18n, __getSyncInstance, te, tm, Trans, Plural, Select, DateTime, NumberFormat }\n}\n"],"mappings":";;;;;;AAsSA,SAAgB,EAAiB,GAAsC;CAGrE,IAAM,IAAkB,SAGlB;EACJ,QAAQ;EACR,UAAU;EACX,EAAE,EAGG,IAAkB,wBAAmC,IAAI,KAAK,CAAC,EAIjE,IAAuE,MACvE,IAAa,GACb,IAAiB;CAErB,SAAS,EAAU,GAAsB;AAGvC,EAFA,GAAiB,CAAC,SAAS,GAC3B,KACA,IAAgB;;CAGlB,eAAe,EAAmB,GAAmC;EACnE,IAAM,IAAe,GAAiB,EAChC,IAAS,EAAa,IAAI,EAAO;AACvC,MAAI,EAAQ,QAAO;EAEnB,IAAM,IAAM,MAAM,EAAO,aAAa,EAAO,EACvC,IACJ,OAAO,KAAQ,YAAY,KAAgB,aAAa,IACnD,EAA8B,UAC9B;AAGP,SADA,EAAa,IAAI,GAAQ,EAAS,EAC3B;;CAGT,eAAe,IAAiE;EAC9E,IAAM,IAAQ,GAAiB;AAI/B,EAAI,CAAC,EAAM,UAAU,EAAO,kBAC1B,EAAM,SAAS,MAAM,EAAO,eAAe;EAG7C,IAAM,IAAS,EAAM;AAErB,MAAI,CAAC,EACH,OAAU,MACR,kPAGD;AAIH,MAAI,EAAM,YAAY,EAAM,SAAS,WAAW,EAC9C,QAAO,EAAM;EAIf,IAAM,IAAwC,EAAE;AAGhD,EAFA,EAAY,KAAU,MAAM,EAAmB,EAAO,EAElD,EAAO,kBAAkB,EAAO,mBAAmB,MACrD,EAAY,EAAO,kBAAkB,MAAM,EAAmB,EAAO,eAAe;EAGtF,IAAM,IAAsC;GAC1C;GACA,UAAU;GACX;AAWD,SAVI,EAAO,mBAAmB,KAAA,MAAW,EAAa,iBAAiB,EAAO,iBAC1E,EAAO,kBAAkB,KAAA,MAAW,EAAa,gBAAgB,EAAO,gBACxE,EAAO,gBAAgB,KAAA,MAAW,EA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AO;EAAE;EAAW;EAAS;EAAmB;EAAI;EAAI;EAAO;EAAQ;EAAQ;EAAU;EAAc"}
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../src/server.ts"],"sourcesContent":["import { cache } from 'react'\nimport { createFluentiCore } from '@fluenti/core'\nimport type {\n FluentiCoreInstanceFull,\n FluentiCoreConfigFull,\n Locale,\n Messages,\n DateFormatOptions,\n NumberFormatOptions,\n} from '@fluenti/core'\nimport { hashMessage as hashSyntheticMessage } from '@fluenti/core/runtime'\nimport { createElement, Fragment, type ReactNode, type ReactElement } from 'react'\nimport { hashMessage, extractMessage, reconstruct } from './components/trans-core'\nimport { PLURAL_CATEGORIES, type PluralCategory } from './components/plural-core'\nimport { buildICUPluralMessage, buildICUSelectMessage, normalizeSelectForms, renderRichTranslation, serializeRichForms } from './components/icu-rich'\n\n// Re-export SSR utilities from core for convenience\nexport { detectLocale, getSSRLocaleScript, getHydratedLocale } from '@fluenti/core/ssr'\nexport type { DetectLocaleOptions } from '@fluenti/core/ssr'\nexport { isRTL, getDirection } from '@fluenti/core'\n\n/**\n * Configuration for `createServerI18n`.\n */\nexport interface ServerI18nConfig {\n /** Load messages for a given locale. Called once per locale per request. */\n loadMessages: (locale: string) => Promise<Messages | { default: Messages }>\n /** Fallback locale when a translation is missing */\n fallbackLocale?: string\n /**\n * Auto-resolve locale when `setLocale()` was not called.\n *\n * This is the fallback for contexts where the layout doesn't run — most\n * notably **Server Actions** (`'use server'`), which are independent\n * requests that skip the layout tree entirely.\n *\n * Common patterns:\n * - Read from a cookie (Next.js: `cookies().get('locale')`)\n * - Read from a request header set by middleware\n * - Query the database for the authenticated user's preference\n *\n * If omitted and `setLocale()` was not called, `getI18n()` will throw.\n *\n * @example\n * ```ts\n * resolveLocale: async () => {\n * const { cookies } = await import('next/headers')\n * return (await cookies()).get('locale')?.value ?? 'en'\n * }\n * ```\n */\n resolveLocale?: () => string | Promise<string>\n /** Custom fallback chains per locale */\n fallbackChain?: Record<string, Locale[]>\n /** Custom date format styles */\n dateFormats?: DateFormatOptions\n /** Custom number format styles */\n numberFormats?: NumberFormatOptions\n /** Handler for missing translation keys */\n missing?: (locale: Locale, id: string) => string | undefined\n /**\n * Custom interpolation function for ICU MessageFormat parsing.\n *\n * By default, the runtime uses a lightweight `{key}` replacer.\n * Pass the full `interpolate` from `@fluenti/core/runtime` for runtime\n * ICU MessageFormat parsing (plurals, selects, nested arguments).\n *\n * @example\n * ```ts\n * import { interpolate } from '@fluenti/core/runtime'\n * createServerI18n({ interpolate, ... })\n * ```\n */\n interpolate?: FluentiCoreConfigFull['interpolate']\n}\n\n// ─── Server Component Props ──────────────────────────────────────────────────\n\nexport interface ServerTransProps {\n /** Source text with embedded components */\n children: ReactNode\n /** Override auto-generated hash ID */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Context comment for translators */\n comment?: string\n /** Custom render wrapper */\n render?: (translation: ReactNode) => ReactNode\n}\n\nexport interface ServerPluralProps {\n /** The count value */\n value: number\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Text for zero (if language supports) */\n zero?: ReactNode\n /** Singular form. `#` replaced with value */\n one?: ReactNode\n /** Dual form (Arabic, etc.) */\n two?: ReactNode\n /** Few form (Slavic languages, etc.) */\n few?: ReactNode\n /** Many form */\n many?: ReactNode\n /** Default plural form */\n other: ReactNode\n /** Offset from value before selecting form */\n offset?: number\n}\n\nexport interface ServerSelectProps {\n /** The selector value */\n value: string\n /** Override the auto-generated synthetic ICU message id */\n id?: string\n /** Message context used for identity and translator disambiguation */\n context?: string\n /** Translator-facing note preserved in extraction catalogs */\n comment?: string\n /** Default case */\n other: ReactNode\n /** Type-safe named options. Takes precedence over direct case props. */\n options?: Record<string, ReactNode>\n /** Named cases — any string key maps to a ReactNode */\n [key: string]: ReactNode | Record<string, ReactNode> | string | undefined\n}\n\nexport interface ServerDateTimeProps {\n /** Date value to format */\n value: Date | number\n /** Named format key defined in dateFormats config */\n format?: string\n}\n\nexport interface ServerNumberProps {\n /** Number value to format */\n value: number\n /** Named format key defined in numberFormats config */\n format?: string\n}\n\n// ─── Server Component Types ──────────────────────────────────────────────────\n\ntype ServerTransComponent = (props: ServerTransProps) => Promise<ReactElement>\ntype ServerPluralComponent = (props: ServerPluralProps) => Promise<ReactElement>\ntype ServerSelectComponent = (props: ServerSelectProps) => Promise<ReactElement>\ntype ServerDateTimeComponent = (props: ServerDateTimeProps) => Promise<ReactElement>\ntype ServerNumberComponent = (props: ServerNumberProps) => Promise<ReactElement>\n\n/**\n * The object returned by `createServerI18n`.\n */\nexport interface ServerI18n {\n /**\n * Set the locale for the current server request.\n * Call this once in your root layout or page before any `getI18n()` calls.\n *\n * Uses `React.cache()` — scoped to the current request automatically.\n */\n setLocale: (locale: string) => void\n\n /**\n * Get a fully configured i18n instance for the current request.\n * Messages are loaded lazily and cached per-request.\n *\n * @example\n * ```tsx\n * // In any Server Component\n * const { t, d, n, locale } = await getI18n()\n * return <h1>{t('welcome')}</h1>\n * ```\n */\n getI18n: () => Promise<FluentiCoreInstanceFull & { locale: string }>\n\n /**\n * `<Trans>` for React Server Components.\n * Async component — automatically resolves the i18n instance.\n *\n * @example\n * ```tsx\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * ```\n */\n Trans: ServerTransComponent\n\n /**\n * `<Plural>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Plural value={count} one=\"# item\" other=\"# items\" />\n * ```\n */\n Plural: ServerPluralComponent\n\n /**\n * `<Select>` for React Server Components.\n *\n * @example\n * ```tsx\n * <Select value={gender} male=\"He liked this\" other=\"They liked this\" />\n * ```\n */\n Select: ServerSelectComponent\n\n /**\n * `<DateTime>` for React Server Components.\n *\n * @example\n * ```tsx\n * <DateTime value={new Date()} format=\"long\" />\n * ```\n */\n DateTime: ServerDateTimeComponent\n\n /**\n * `<NumberFormat>` for React Server Components.\n *\n * @example\n * ```tsx\n * <NumberFormat value={1234.56} format=\"currency\" />\n * ```\n */\n NumberFormat: ServerNumberComponent\n\n /**\n * Check if a translation key exists in the catalog.\n * Optionally check a specific locale instead of the current one.\n */\n te: (key: string, locale?: string) => Promise<boolean>\n\n /**\n * Get the raw compiled message without interpolation.\n * Optionally look up in a specific locale instead of the current one.\n */\n tm: (key: string, locale?: string) => Promise<Messages[string] | undefined>\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used internally by @fluenti/next webpack loader.\n * @internal\n */\n __getSyncInstance: () => FluentiCoreInstanceFull & { locale: string }\n}\n\n/**\n * Create server-side i18n utilities for React Server Components.\n *\n * Uses `React.cache()` to share state within a single server request\n * without React Context (which is unavailable in Server Components).\n *\n * @example\n * ```ts\n * // lib/i18n.server.ts — define once\n * import { createServerI18n } from '@fluenti/react/server'\n *\n * export const { setLocale, getI18n, Trans, Plural, Select, DateTime, NumberFormat } = createServerI18n({\n * loadMessages: (locale) => import(`../messages/${locale}.json`),\n * fallbackLocale: 'en',\n * })\n * ```\n *\n * ```tsx\n * // app/[locale]/layout.tsx — set locale once\n * import { setLocale } from '@/lib/i18n.server'\n *\n * export default async function Layout({ params, children }) {\n * const { locale } = await params\n * setLocale(locale)\n * return <html lang={locale}><body>{children}</body></html>\n * }\n * ```\n *\n * ```tsx\n * // app/[locale]/page.tsx — use Trans, Plural, etc. directly\n * import { Trans, Plural, Select } from '@/lib/i18n.server'\n *\n * export default async function Page() {\n * return (\n * <div>\n * <Trans>Read the <a href=\"/docs\">documentation</a>.</Trans>\n * <Plural value={5} one=\"# item\" other=\"# items\" />\n * <Select value=\"male\" male=\"He liked this\" other=\"They liked this\" />\n * </div>\n * )\n * }\n * ```\n */\nexport function createServerI18n(config: ServerI18nConfig): ServerI18n {\n // Request-scoped store using React.cache()\n // Each server request gets its own isolated state\n const getRequestStore = cache((): {\n locale: string | null\n instance: (FluentiCoreInstanceFull & { locale: string }) | null\n } => ({\n locale: null,\n instance: null,\n }))\n\n // Cache loaded messages per-request to avoid redundant imports\n const getMessageCache = cache((): Map<string, Messages> => new Map())\n\n // Module-level fallback for server actions where React.cache()\n // may not share state with the page render.\n let _lastInstance: (FluentiCoreInstanceFull & { locale: string }) | null = null\n let _requestId = 0\n let _lastRequestId = 0\n\n function setLocale(locale: string): void {\n getRequestStore().locale = locale\n _requestId++\n _lastInstance = null\n }\n\n async function loadLocaleMessages(locale: string): Promise<Messages> {\n const messageCache = getMessageCache()\n const cached = messageCache.get(locale)\n if (cached) return cached\n\n const raw = await config.loadMessages(locale)\n const messages: Messages =\n typeof raw === 'object' && raw !== null && 'default' in raw\n ? (raw as { default: Messages }).default\n : (raw as Messages)\n\n messageCache.set(locale, messages)\n return messages\n }\n\n async function getI18n(): Promise<FluentiCoreInstanceFull & { locale: string }> {\n const store = getRequestStore()\n\n // If setLocale() was never called (e.g. Server Action — independent request\n // that skips the layout), try the resolveLocale fallback.\n if (!store.locale && config.resolveLocale) {\n store.locale = await config.resolveLocale()\n }\n\n const locale = store.locale\n\n if (!locale) {\n throw new Error(\n '[fluenti] No locale set. Call setLocale(locale) in your layout before using getI18n(), ' +\n 'or provide a resolveLocale function in createServerI18n config to auto-detect locale ' +\n 'in Server Actions and other contexts where the layout does not run.',\n )\n }\n\n // Return cached instance if locale hasn't changed\n if (store.instance && store.instance.locale === locale) {\n return store.instance\n }\n\n // Load messages for current locale (and fallback if configured)\n const allMessages: Record<string, Messages> = {}\n allMessages[locale] = await loadLocaleMessages(locale)\n\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n allMessages[config.fallbackLocale] = await loadLocaleMessages(config.fallbackLocale)\n }\n\n const fluentConfig: FluentiCoreConfigFull = {\n locale,\n messages: allMessages,\n }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n _lastInstance = store.instance\n _lastRequestId = _requestId\n return store.instance\n }\n\n // ─── Async Server Components ─────────────────────────────────────────────\n\n async function Trans({ children, id, context, comment, render }: ServerTransProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const { message, components } = extractMessage(children)\n const messageId = id ?? hashMessage(message, context)\n const translated = i18n.t({\n id: messageId,\n message,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n })\n const result = reconstruct(translated, components)\n return createElement(Fragment, null, render ? render(result) : result)\n }\n\n async function Plural({\n value,\n id,\n context,\n comment,\n zero,\n one,\n two,\n few,\n many,\n other,\n offset,\n }: ServerPluralProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<PluralCategory, ReactNode | undefined> = {\n zero,\n one,\n two,\n few,\n many,\n other,\n }\n const { messages, components } = serializeRichForms(PLURAL_CATEGORIES, forms)\n const icuMessage = buildICUPluralMessage(\n {\n ...(messages.zero !== undefined && { zero: messages.zero }),\n ...(messages.one !== undefined && { one: messages.one }),\n ...(messages.two !== undefined && { two: messages.two }),\n ...(messages.few !== undefined && { few: messages.few }),\n ...(messages.many !== undefined && { many: messages.many }),\n other: messages.other ?? '',\n },\n offset,\n )\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { count: value },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function Select({\n value,\n id,\n context,\n comment,\n other,\n options,\n ...cases\n }: ServerSelectProps): Promise<ReactElement> {\n const i18n = await getI18n()\n const forms: Record<string, ReactNode | undefined> = options === undefined\n ? {\n ...Object.fromEntries(\n Object.entries(cases).filter(([key]) => !['value', 'id', 'context', 'comment', 'options', 'other'].includes(key)),\n ),\n other,\n }\n : {\n ...options,\n other,\n }\n\n const orderedKeys = [...Object.keys(forms).filter(key => key !== 'other'), 'other'] as const\n const { messages, components } = serializeRichForms(orderedKeys, forms)\n const normalized = normalizeSelectForms(\n Object.fromEntries(\n [...orderedKeys].map((key) => [key, messages[key] ?? '']),\n ),\n )\n const icuMessage = buildICUSelectMessage(normalized.forms)\n\n const result = renderRichTranslation(\n {\n id: id ?? (context === undefined ? icuMessage : hashSyntheticMessage(icuMessage, context)),\n message: icuMessage,\n ...(context !== undefined ? { context } : {}),\n ...(comment !== undefined ? { comment } : {}),\n },\n { value: normalized.valueMap[value] ?? 'other' },\n (descriptor, values) => i18n.t(descriptor, values),\n components,\n )\n\n return createElement(Fragment, null, result)\n }\n\n async function DateTime({ value, format }: ServerDateTimeProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.d(value, format))\n }\n\n async function NumberFormat({ value, format }: ServerNumberProps): Promise<ReactElement> {\n const i18n = await getI18n()\n return createElement(Fragment, null, i18n.n(value, format))\n }\n\n /**\n * Synchronous accessor for the cached i18n instance.\n * Used by @fluenti/next webpack loader for t`` in RSC.\n *\n * Falls back to creating a minimal instance from the message cache when the\n * React.cache() request store hasn't been populated yet — this handles\n * Suspense boundaries and streamed components where React.cache() state\n * may not propagate from the layout render into streamed children.\n * @internal\n */\n function __getSyncInstance(): FluentiCoreInstanceFull & { locale: string } {\n const store = getRequestStore()\n if (store.instance) {\n return store.instance\n }\n\n // Module-level fallback for server actions where React.cache()\n // may not share state across different call contexts.\n // Only use within the same request (tracked by _requestId).\n if (_lastInstance && _lastRequestId === _requestId) {\n return _lastInstance\n }\n\n // Final fallback: create instance synchronously with the default locale.\n // This handles Suspense boundaries and streamed components where\n // the React.cache store may not have been populated yet.\n const locale = store.locale ?? config.fallbackLocale ?? 'en'\n const messageCache = getMessageCache()\n const messages: Record<string, Messages> = {}\n const cached = messageCache.get(locale)\n if (cached) messages[locale] = cached\n if (config.fallbackLocale && config.fallbackLocale !== locale) {\n const fallback = messageCache.get(config.fallbackLocale)\n if (fallback) messages[config.fallbackLocale] = fallback\n }\n\n const fluentConfig: FluentiCoreConfigFull = { locale, messages }\n if (config.fallbackLocale !== undefined) fluentConfig.fallbackLocale = config.fallbackLocale\n if (config.fallbackChain !== undefined) fluentConfig.fallbackChain = config.fallbackChain\n if (config.dateFormats !== undefined) fluentConfig.dateFormats = config.dateFormats\n if (config.numberFormats !== undefined) fluentConfig.numberFormats = config.numberFormats\n if (config.missing !== undefined) fluentConfig.missing = config.missing\n if (config.interpolate !== undefined) fluentConfig.interpolate = config.interpolate\n\n store.instance = createFluentiCore(fluentConfig)\n return store.instance\n }\n\n /**\n * Check if a translation key exists in the catalog for the given (or current) locale.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function te(key: string, locale?: string): Promise<boolean> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key] !== undefined\n }\n\n /**\n * Get the raw compiled message for the given key without interpolation.\n * Async because it needs to ensure messages are loaded via getI18n().\n */\n async function tm(key: string, locale?: string): Promise<Messages[string] | undefined> {\n const i18n = await getI18n()\n const targetLocale = locale ?? i18n.locale\n const msgs = await loadLocaleMessages(targetLocale)\n return msgs[key]\n }\n\n return { setLocale, getI18n, __getSyncInstance, te, tm, Trans, Plural, Select, DateTime, NumberFormat }\n}\n"],"mappings":";;;;;;AAsSA,SAAgB,EAAiB,GAAsC;CAGrE,IAAM,IAAkB,SAGlB;EACJ,QAAQ;EACR,UAAU;EACX,EAAE,EAGG,IAAkB,wBAAmC,IAAI,KAAK,CAAC,EAIjE,IAAuE,MACvE,IAAa,GACb,IAAiB;CAErB,SAAS,EAAU,GAAsB;AAGvC,EAFA,GAAiB,CAAC,SAAS,GAC3B,KACA,IAAgB;;CAGlB,eAAe,EAAmB,GAAmC;EACnE,IA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C,IAAS,EAAa,IAAI,EAAO;AAEvC,MADI,MAAQ,EAAS,KAAU,IAC3B,EAAO,kBAAkB,EAAO,mBAAmB,GAAQ;GAC7D,IAAM,IAAW,EAAa,IAAI,EAAO,eAAe;AACxD,GAAI,MAAU,EAAS,EAAO,kBAAkB;;EAGlD,IAAM,IAAsC;GAAE;GAAQ;GAAU;AAShE,SARI,EAAO,mBAAmB,KAAA,MAAW,EAAa,iBAAiB,EAAO,iBAC1E,EAAO,kBAAkB,KAAA,MAAW,EAAa,gBAAgB,EAAO,gBACxE,EAAO,gBAAgB,KAAA,MAAW,EAAa,cAAc,EAAO,cACpE,EAAO,kBAAkB,KAAA,MAAW,EAAa,gBAAgB,EAAO,gBACxE,EAAO,YAAY,KAAA,MAAW,EAAa,UAAU,EAAO,UAC5D,EAAO,gBAAgB,KAAA,MAAW,EAAa,cAAc,EAAO,cAExE,EAAM,WAAW,EAAkB,EAAa,EACzC,EAAM;;CAOf,eAAe,EAAG,GAAa,GAAmC;EAChE,IAAM,IAAO,MAAM,GAAS;AAG5B,UADa,MAAM,EADE,KAAU,EAAK,OACe,EACvC,OAAS,KAAA;;CAOvB,eAAe,EAAG,GAAa,GAAwD;EACrF,IAAM,IAAO,MAAM,GAAS;AAG5B,UADa,MAAM,EADE,KAAU,EAAK,OACe,EACvC;;AAGd,QAAO;EAAE;EAAW;EAAS;EAAmB;EAAI;EAAI;EAAO;EAAQ;EAAQ;EAAU;EAAc"}
|
package/dist/vite-plugin.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require(`@fluenti/vite-plugin`);var t=(0,e.createRuntimeGenerator)({imports:``,catalogInit:`const __catalog = { ...__defaultMsgs }`,localeInit:e=>`let __currentLocale =
|
|
1
|
+
let e=require(`@fluenti/vite-plugin`);var t=(0,e.createRuntimeGenerator)({imports:``,catalogInit:`const __catalog = { ...__defaultMsgs }`,localeInit:e=>`let __currentLocale = ${JSON.stringify(e)}`,loadingInit:`let __loading = false`,catalogUpdate:e=>`Object.assign(__catalog, ${e})`,localeUpdate:e=>`__currentLocale = ${e}`,loadingUpdate:e=>`__loading = ${e}`,localeRead:`__currentLocale`,runtimeKey:`fluenti.runtime.react.v1`});function n(n){return(0,e.createFluentiPlugins)({...n?.config===void 0?{}:{config:n.config},framework:`react`},[],t)}module.exports=n;
|
|
2
2
|
//# sourceMappingURL=vite-plugin.cjs.map
|
package/dist/vite-plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.cjs","names":[],"sources":["../src/react-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const reactRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: '',\n catalogInit: 'const __catalog = { ...__defaultMsgs }',\n localeInit: (defaultLocale) => `let __currentLocale =
|
|
1
|
+
{"version":3,"file":"vite-plugin.cjs","names":[],"sources":["../src/react-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const reactRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: '',\n catalogInit: 'const __catalog = { ...__defaultMsgs }',\n localeInit: (defaultLocale) => `let __currentLocale = ${JSON.stringify(defaultLocale)}`,\n loadingInit: 'let __loading = false',\n catalogUpdate: (msgs) => `Object.assign(__catalog, ${msgs})`,\n localeUpdate: (locale) => `__currentLocale = ${locale}`,\n loadingUpdate: (value) => `__loading = ${value}`,\n localeRead: '__currentLocale',\n runtimeKey: 'fluenti.runtime.react.v1',\n})\n","import type { Plugin } from 'vite'\nimport type { FluentiPluginOptions } from '@fluenti/vite-plugin'\nimport { createFluentiPlugins } from '@fluenti/vite-plugin'\nimport { reactRuntimeGenerator } from './react-runtime'\n\nexport type { FluentiPluginOptions as FluentiReactOptions } from '@fluenti/vite-plugin'\n\n/**\n * Fluenti React Vite plugin.\n *\n * @example Minimal — no fluenti.config.ts needed\n * ```ts\n * // vite.config.ts\n * import fluentiReact from '@fluenti/react/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fluentiReact({ config: { locales: ['en', 'ja'] } })],\n * })\n * ```\n *\n * @example With fluenti.config.ts (for advanced options)\n * ```ts\n * export default defineConfig({\n * plugins: [fluentiReact()], // auto-reads fluenti.config.ts\n * })\n * ```\n */\nexport default function fluentiReact(options?: FluentiPluginOptions): Plugin[] {\n return createFluentiPlugins(\n { ...(options?.config !== undefined ? { config: options.config } : {}), framework: 'react' },\n [],\n reactRuntimeGenerator,\n )\n}\n"],"mappings":"sCAGA,IAAa,GAAA,EAAA,EAAA,wBAAiE,CAC5E,QAAS,GACT,YAAa,yCACb,WAAa,GAAkB,yBAAyB,KAAK,UAAU,EAAc,GACrF,YAAa,wBACb,cAAgB,GAAS,4BAA4B,EAAK,GAC1D,aAAe,GAAW,qBAAqB,IAC/C,cAAgB,GAAU,eAAe,IACzC,WAAY,kBACZ,WAAY,2BACb,CAAC,CCcF,SAAwB,EAAa,EAA0C,CAC7E,OAAA,EAAA,EAAA,sBACE,CAAE,GAAI,GAAS,SAAW,IAAA,GAAyC,EAAE,CAA/B,CAAE,OAAQ,EAAQ,OAAQ,CAAQ,UAAW,QAAS,CAC5F,EAAE,CACF,EACD"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createFluentiPlugins as e, createRuntimeGenerator as t } from "@fluenti
|
|
|
3
3
|
var n = t({
|
|
4
4
|
imports: "",
|
|
5
5
|
catalogInit: "const __catalog = { ...__defaultMsgs }",
|
|
6
|
-
localeInit: (e) => `let __currentLocale =
|
|
6
|
+
localeInit: (e) => `let __currentLocale = ${JSON.stringify(e)}`,
|
|
7
7
|
loadingInit: "let __loading = false",
|
|
8
8
|
catalogUpdate: (e) => `Object.assign(__catalog, ${e})`,
|
|
9
9
|
localeUpdate: (e) => `__currentLocale = ${e}`,
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.js","names":[],"sources":["../src/react-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const reactRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: '',\n catalogInit: 'const __catalog = { ...__defaultMsgs }',\n localeInit: (defaultLocale) => `let __currentLocale =
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","names":[],"sources":["../src/react-runtime.ts","../src/vite-plugin.ts"],"sourcesContent":["import { createRuntimeGenerator } from '@fluenti/vite-plugin'\nimport type { RuntimeGenerator } from '@fluenti/vite-plugin'\n\nexport const reactRuntimeGenerator: RuntimeGenerator = createRuntimeGenerator({\n imports: '',\n catalogInit: 'const __catalog = { ...__defaultMsgs }',\n localeInit: (defaultLocale) => `let __currentLocale = ${JSON.stringify(defaultLocale)}`,\n loadingInit: 'let __loading = false',\n catalogUpdate: (msgs) => `Object.assign(__catalog, ${msgs})`,\n localeUpdate: (locale) => `__currentLocale = ${locale}`,\n loadingUpdate: (value) => `__loading = ${value}`,\n localeRead: '__currentLocale',\n runtimeKey: 'fluenti.runtime.react.v1',\n})\n","import type { Plugin } from 'vite'\nimport type { FluentiPluginOptions } from '@fluenti/vite-plugin'\nimport { createFluentiPlugins } from '@fluenti/vite-plugin'\nimport { reactRuntimeGenerator } from './react-runtime'\n\nexport type { FluentiPluginOptions as FluentiReactOptions } from '@fluenti/vite-plugin'\n\n/**\n * Fluenti React Vite plugin.\n *\n * @example Minimal — no fluenti.config.ts needed\n * ```ts\n * // vite.config.ts\n * import fluentiReact from '@fluenti/react/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fluentiReact({ config: { locales: ['en', 'ja'] } })],\n * })\n * ```\n *\n * @example With fluenti.config.ts (for advanced options)\n * ```ts\n * export default defineConfig({\n * plugins: [fluentiReact()], // auto-reads fluenti.config.ts\n * })\n * ```\n */\nexport default function fluentiReact(options?: FluentiPluginOptions): Plugin[] {\n return createFluentiPlugins(\n { ...(options?.config !== undefined ? { config: options.config } : {}), framework: 'react' },\n [],\n reactRuntimeGenerator,\n )\n}\n"],"mappings":";;AAGA,IAAa,IAA0C,EAAuB;CAC5E,SAAS;CACT,aAAa;CACb,aAAa,MAAkB,yBAAyB,KAAK,UAAU,EAAc;CACrF,aAAa;CACb,gBAAgB,MAAS,4BAA4B,EAAK;CAC1D,eAAe,MAAW,qBAAqB;CAC/C,gBAAgB,MAAU,eAAe;CACzC,YAAY;CACZ,YAAY;CACb,CAAC;;;ACcF,SAAwB,EAAa,GAA0C;AAC7E,QAAO,EACL;EAAE,GAAI,GAAS,WAAW,KAAA,IAAyC,EAAE,GAA/B,EAAE,QAAQ,EAAQ,QAAQ;EAAQ,WAAW;EAAS,EAC5F,EAAE,EACF,EACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluenti/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React bindings for Fluenti — I18nProvider, useI18n, Trans/Plural/Select components",
|
|
6
6
|
"homepage": "https://fluenti.dev",
|
|
@@ -32,45 +32,45 @@
|
|
|
32
32
|
],
|
|
33
33
|
"main": "./dist/index.cjs",
|
|
34
34
|
"module": "./dist/index.js",
|
|
35
|
-
"types": "./dist/index.d.ts",
|
|
35
|
+
"types": "./dist/react/src/index.d.ts",
|
|
36
36
|
"exports": {
|
|
37
37
|
".": {
|
|
38
38
|
"import": {
|
|
39
|
-
"types": "./dist/index.d.ts",
|
|
39
|
+
"types": "./dist/react/src/index.d.ts",
|
|
40
40
|
"default": "./dist/index.js"
|
|
41
41
|
},
|
|
42
42
|
"require": {
|
|
43
|
-
"types": "./dist/index.d.ts",
|
|
43
|
+
"types": "./dist/react/src/index.d.ts",
|
|
44
44
|
"default": "./dist/index.cjs"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
47
|
+
"./server": {
|
|
48
48
|
"import": {
|
|
49
|
-
"types": "./dist/
|
|
50
|
-
"default": "./dist/
|
|
49
|
+
"types": "./dist/react/src/server.d.ts",
|
|
50
|
+
"default": "./dist/server.js"
|
|
51
51
|
},
|
|
52
52
|
"require": {
|
|
53
|
-
"types": "./dist/
|
|
54
|
-
"default": "./dist/
|
|
53
|
+
"types": "./dist/react/src/server.d.ts",
|
|
54
|
+
"default": "./dist/server.cjs"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
"./
|
|
57
|
+
"./components": {
|
|
58
58
|
"import": {
|
|
59
|
-
"types": "./dist/
|
|
60
|
-
"default": "./dist/
|
|
59
|
+
"types": "./dist/react/src/components-entry.d.ts",
|
|
60
|
+
"default": "./dist/components-entry.js"
|
|
61
61
|
},
|
|
62
62
|
"require": {
|
|
63
|
-
"types": "./dist/
|
|
64
|
-
"default": "./dist/
|
|
63
|
+
"types": "./dist/react/src/components-entry.d.ts",
|
|
64
|
+
"default": "./dist/components-entry.cjs"
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"./vite-plugin": {
|
|
68
68
|
"import": {
|
|
69
|
-
"types": "./dist/vite-plugin.d.ts",
|
|
69
|
+
"types": "./dist/react/src/vite-plugin.d.ts",
|
|
70
70
|
"default": "./dist/vite-plugin.js"
|
|
71
71
|
},
|
|
72
72
|
"require": {
|
|
73
|
-
"types": "./dist/vite-plugin.d.ts",
|
|
73
|
+
"types": "./dist/react/src/vite-plugin.d.ts",
|
|
74
74
|
"default": "./dist/vite-plugin.cjs"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@fluenti/core": "0.
|
|
93
|
-
"@fluenti/vite-plugin": "0.
|
|
92
|
+
"@fluenti/core": "0.6.1",
|
|
93
|
+
"@fluenti/vite-plugin": "0.6.1"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"typescript": "^5.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile-time-t.d.ts","sourceRoot":"","sources":["../src/compile-time-t.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,eAAO,MAAM,CAAC,EAAE,YAME,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.d.ts","sourceRoot":"","sources":["../../src/components/DateTime.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,4DAMnB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../src/components/Number.tsx"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,+BAA+B;AAC/B,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAA;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,yDAMvB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Plural.d.ts","sourceRoot":"","sources":["../../src/components/Plural.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAMxD,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,KAA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S,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAA;CACrG;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,0DA0CjB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Trans.d.ts","sourceRoot":"","sources":["../../src/components/Trans.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAId,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,SAAS,CAAA;IACnB,sCAAsC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wFAAwF;IACxF,GAAG,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAA;IACvC,4BAA4B;IAC5B,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,SAAS,CAAA;IAC9C,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,YAAY,EAAE,CAAA;CAC9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,yDA0ChB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icu-rich.d.ts","sourceRoot":"","sources":["../../src/components/icu-rich.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,K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wBAAwB,CAAA;AAE/E;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,cAAc,CAKhB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAKzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trans-core.d.ts","sourceRoot":"","sources":["../../src/components/trans-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,WAAW,EAAiB,MAAM,wBAAwB,CAAA;AAEnE,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,GAAG;IACnD,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,YAAY,EAAE,CAAA;CAC3B,CA4BA;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,YAAY,EAAE,GACzB,SAAS,CAmDX"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-entry.d.ts","sourceRoot":"","sources":["../src/components-entry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,YAAY,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAGtF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-DVbvrSE8.cjs","names":[],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react'\nimport type { FluentiContext } from './types'\n\nexport const I18nContext = createContext<FluentiContext | null>(null)\n"],"mappings":"AAGA,IAAa,GAAA,mBAAA,eAAmD,KAAK"}
|
package/dist/context-DVudCV1o.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-DVudCV1o.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'react'\nimport type { FluentiContext } from './types'\n\nexport const I18nContext = createContext<FluentiContext | null>(null)\n"],"mappings":";;AAGA,IAAa,IAAc,EAAqC,KAAK"}
|
package/dist/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,eAAO,MAAM,WAAW,gDAA6C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-fluenti.d.ts","sourceRoot":"","sources":["../src/create-fluenti.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uBAAuB,IAAI,sBAAsB,EACjD,eAAe,EACf,MAAM,EACN,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EAClB,MAAM,eAAe,CAAA;AAEtB;;GAEG;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