@intlayer/use-intl 9.0.0-canary.2 → 9.0.0-canary.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{react → client}/IntlProvider.cjs +1 -1
- package/dist/cjs/client/IntlProvider.cjs.map +1 -0
- package/dist/cjs/{react → client}/helpers.cjs +1 -1
- package/dist/cjs/client/helpers.cjs.map +1 -0
- package/dist/cjs/client/index.cjs +27 -0
- package/dist/cjs/client/index.cjs.map +1 -0
- package/dist/cjs/{react → client}/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/{react → client}/useTranslations.cjs +1 -1
- package/dist/cjs/client/useTranslations.cjs.map +1 -0
- package/dist/cjs/core/initializeConfig.cjs.map +1 -1
- package/dist/cjs/index.cjs +14 -14
- package/dist/esm/{react → client}/IntlProvider.mjs +1 -1
- package/dist/esm/client/IntlProvider.mjs.map +1 -0
- package/dist/esm/{react → client}/helpers.mjs +1 -1
- package/dist/esm/client/helpers.mjs.map +1 -0
- package/dist/esm/{react → client}/index.mjs +3 -3
- package/dist/esm/client/index.mjs.map +1 -0
- package/dist/esm/{react → client}/useLocale.mjs +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/{react → client}/useTranslations.mjs +2 -2
- package/dist/esm/client/useTranslations.mjs.map +1 -0
- package/dist/esm/core/createFormatter.mjs.map +1 -1
- package/dist/esm/core/createTranslator.mjs.map +1 -1
- package/dist/esm/core/errors.mjs.map +1 -1
- package/dist/esm/core/hasLocale.mjs.map +1 -1
- package/dist/esm/core/initializeConfig.mjs.map +1 -1
- package/dist/esm/index.mjs +8 -7
- package/dist/esm/plugin/index.mjs +3 -36
- package/dist/esm/plugin/index.mjs.map +1 -1
- package/dist/esm/shared/intlFormatter.mjs.map +1 -1
- package/dist/esm/shared/namespaceTranslator.mjs +56 -35
- package/dist/esm/shared/namespaceTranslator.mjs.map +1 -1
- package/dist/esm/useDictionary.mjs +10 -15
- package/dist/esm/useDictionary.mjs.map +1 -1
- package/dist/esm/useDictionaryDynamic.mjs +7 -15
- package/dist/esm/useDictionaryDynamic.mjs.map +1 -1
- package/dist/types/{react → client}/IntlProvider.d.ts +4 -4
- package/dist/types/client/IntlProvider.d.ts.map +1 -0
- package/dist/types/{react → client}/helpers.d.ts +1 -2
- package/dist/types/client/helpers.d.ts.map +1 -0
- package/dist/types/{react → client}/index.d.ts +3 -4
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/{react → client}/useLocale.d.ts +1 -2
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/{react → client}/useTranslations.d.ts +5 -5
- package/dist/types/client/useTranslations.d.ts.map +1 -0
- package/dist/types/core/createFormatter.d.ts +0 -1
- package/dist/types/core/createFormatter.d.ts.map +1 -1
- package/dist/types/core/createTranslator.d.ts +9 -7
- package/dist/types/core/createTranslator.d.ts.map +1 -1
- package/dist/types/core/errors.d.ts.map +1 -1
- package/dist/types/core/hasLocale.d.ts +0 -1
- package/dist/types/core/hasLocale.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/initializeConfig.d.ts +0 -1
- package/dist/types/core/initializeConfig.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +1 -1
- package/dist/types/index.d.ts +11 -8
- package/dist/types/plugin/index.d.ts +0 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/shared/intlFormatter.d.ts +0 -1
- package/dist/types/shared/intlFormatter.d.ts.map +1 -1
- package/dist/types/shared/namespaceTranslator.d.ts +33 -12
- package/dist/types/shared/namespaceTranslator.d.ts.map +1 -1
- package/dist/types/shared/translateFunctionTypes.d.ts +53 -8
- package/dist/types/shared/translateFunctionTypes.d.ts.map +1 -1
- package/dist/types/useDictionary.d.ts +15 -6
- package/dist/types/useDictionary.d.ts.map +1 -1
- package/dist/types/useDictionaryDynamic.d.ts +12 -7
- package/dist/types/useDictionaryDynamic.d.ts.map +1 -1
- package/package.json +18 -22
- package/dist/cjs/react/IntlProvider.cjs.map +0 -1
- package/dist/cjs/react/helpers.cjs.map +0 -1
- package/dist/cjs/react/index.cjs +0 -27
- package/dist/cjs/react/index.cjs.map +0 -1
- package/dist/cjs/react/useLocale.cjs.map +0 -1
- package/dist/cjs/react/useTranslations.cjs.map +0 -1
- package/dist/esm/react/IntlProvider.mjs.map +0 -1
- package/dist/esm/react/helpers.mjs.map +0 -1
- package/dist/esm/react/index.mjs.map +0 -1
- package/dist/esm/react/useLocale.mjs.map +0 -1
- package/dist/esm/react/useTranslations.mjs.map +0 -1
- package/dist/types/react/IntlProvider.d.ts.map +0 -1
- package/dist/types/react/helpers.d.ts.map +0 -1
- package/dist/types/react/index.d.ts.map +0 -1
- package/dist/types/react/useLocale.d.ts.map +0 -1
- package/dist/types/react/useTranslations.d.ts.map +0 -1
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScopedTranslateFunction, TranslateFunction } from "./shared/translateFunctionTypes.js";
|
|
2
|
+
import { DictionaryKeys } from "@intlayer/types/module_augmentation";
|
|
2
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
|
-
|
|
4
4
|
//#region src/useDictionary.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Overload set for {@link useDictionary}: without a prefix the translator is
|
|
7
|
+
* typed against the dictionary's dot-paths; with a prefix the keys are
|
|
8
|
+
* relative dot-paths under that scope.
|
|
9
|
+
*/
|
|
10
|
+
type UseDictionary = {
|
|
11
|
+
<T extends Dictionary>(dictionary: T): TranslateFunction<T['key'] & DictionaryKeys>;
|
|
12
|
+
<T extends Dictionary, Prefix extends string>(dictionary: T, namespacePrefix: Prefix): ScopedTranslateFunction<T['key'] & DictionaryKeys, Prefix>;
|
|
13
|
+
};
|
|
5
14
|
/**
|
|
6
15
|
* Dictionary-accepting variant of `useTranslations`.
|
|
7
16
|
*
|
|
@@ -10,14 +19,14 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
10
19
|
* JSON at build time and passes it directly here. This enables tree-shaking of
|
|
11
20
|
* unused locale content.
|
|
12
21
|
*
|
|
22
|
+
* The returned translator matches `useTranslations` exactly (ICU messages,
|
|
23
|
+
* `has`, `raw`, `rich`, `markup`).
|
|
24
|
+
*
|
|
13
25
|
* @example (generated by the plugin, not written manually)
|
|
14
26
|
* import _abc from '.intlayer/dictionaries/about.json' with { type: 'json' };
|
|
15
27
|
* const t = useDictionary(_abc);
|
|
16
28
|
*/
|
|
17
|
-
declare const useDictionary:
|
|
18
|
-
has: <P extends ValidDotPathsFor<string>>(lookup: P) => boolean;
|
|
19
|
-
raw: <P extends ValidDotPathsFor<string>>(lookup: P) => unknown;
|
|
20
|
-
};
|
|
29
|
+
declare const useDictionary: UseDictionary;
|
|
21
30
|
//#endregion
|
|
22
31
|
export { useDictionary };
|
|
23
32
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../src/useDictionary.ts"],"mappings":";;;;;;;;;KAuBK;GACF,UAAU,YACT,YAAY,IACX,kBAAkB,WAAW;GAC/B,UAAU,YAAY,uBACrB,YAAY,GACZ,iBAAiB,SAChB,wBAAwB,WAAW,gBAAgB;;;;;;;;;;;;;;;;;cAkB3C,eAYP"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ScopedTranslateFunction, TranslateFunction } from "./shared/translateFunctionTypes.js";
|
|
2
|
+
import { DictionaryKeys, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
3
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
-
|
|
5
4
|
//#region src/useDictionaryDynamic.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Overload set for {@link useDictionaryDynamic}: without a prefix the
|
|
7
|
+
* translator is typed against the dictionary's dot-paths; with a prefix the
|
|
8
|
+
* keys are relative dot-paths under that scope.
|
|
9
|
+
*/
|
|
10
|
+
type UseDictionaryDynamic = {
|
|
11
|
+
<T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K): TranslateFunction<K>;
|
|
12
|
+
<T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: K, namespacePrefix: Prefix): ScopedTranslateFunction<K, Prefix>;
|
|
13
|
+
};
|
|
6
14
|
/**
|
|
7
15
|
* Dynamic dictionary-accepting variant of `useTranslations`.
|
|
8
16
|
*
|
|
9
17
|
* Counterpart to {@link useDictionary} for dictionaries imported lazily per
|
|
10
18
|
* locale. Used internally by the build-time optimization.
|
|
11
19
|
*/
|
|
12
|
-
declare const useDictionaryDynamic:
|
|
13
|
-
has: <P extends ValidDotPathsFor<string>>(lookup: P) => boolean;
|
|
14
|
-
raw: <P extends ValidDotPathsFor<string>>(lookup: P) => unknown;
|
|
15
|
-
};
|
|
20
|
+
declare const useDictionaryDynamic: UseDictionaryDynamic;
|
|
16
21
|
//#endregion
|
|
17
22
|
export { useDictionaryDynamic };
|
|
18
23
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../src/useDictionaryDynamic.ts"],"mappings":";;;;;;;;;KAwBK;GACF,UAAU,YAAY,UAAU,gBAC/B,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,IACJ,kBAAkB;GACpB,UAAU,YAAY,UAAU,gBAAgB,uBAC/C,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,iBAAiB,SAChB,wBAAwB,GAAG;;;;;;;;cASnB,sBAgBP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/use-intl",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "use-intl API adapter for intlayer — useTranslations, useLocale, useFormatter, IntlProvider, createTranslator backed by react-intlayer",
|
|
6
6
|
"keywords": [
|
|
@@ -35,27 +35,23 @@
|
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
37
37
|
"types": "./dist/types/index.d.ts",
|
|
38
|
-
"require": "./dist/cjs/index.cjs",
|
|
39
38
|
"import": "./dist/esm/index.mjs"
|
|
40
39
|
},
|
|
41
40
|
"./core": {
|
|
42
41
|
"types": "./dist/types/core/index.d.ts",
|
|
43
|
-
"require": "./dist/cjs/core/index.cjs",
|
|
44
42
|
"import": "./dist/esm/core/index.mjs"
|
|
45
43
|
},
|
|
46
44
|
"./react": {
|
|
47
|
-
"types": "./dist/types/
|
|
48
|
-
"
|
|
49
|
-
"import": "./dist/esm/react/index.mjs"
|
|
45
|
+
"types": "./dist/types/client/index.d.ts",
|
|
46
|
+
"import": "./dist/esm/client/index.mjs"
|
|
50
47
|
},
|
|
51
48
|
"./plugin": {
|
|
52
49
|
"types": "./dist/types/plugin/index.d.ts",
|
|
53
|
-
"require": "./dist/cjs/plugin/index.cjs",
|
|
54
50
|
"import": "./dist/esm/plugin/index.mjs"
|
|
55
51
|
},
|
|
56
52
|
"./package.json": "./package.json"
|
|
57
53
|
},
|
|
58
|
-
"main": "dist/
|
|
54
|
+
"main": "dist/esm/index.mjs",
|
|
59
55
|
"module": "dist/esm/index.mjs",
|
|
60
56
|
"types": "dist/types/index.d.ts",
|
|
61
57
|
"typesVersions": {
|
|
@@ -64,7 +60,7 @@
|
|
|
64
60
|
"./dist/types/core/index.d.ts"
|
|
65
61
|
],
|
|
66
62
|
"react": [
|
|
67
|
-
"./dist/types/
|
|
63
|
+
"./dist/types/client/index.d.ts"
|
|
68
64
|
],
|
|
69
65
|
"plugin": [
|
|
70
66
|
"./dist/types/plugin/index.d.ts"
|
|
@@ -93,26 +89,26 @@
|
|
|
93
89
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
94
90
|
},
|
|
95
91
|
"dependencies": {
|
|
96
|
-
"@intlayer/
|
|
97
|
-
"@intlayer/
|
|
98
|
-
"@intlayer/
|
|
99
|
-
"@intlayer/
|
|
100
|
-
"@intlayer/types": "9.0.0-canary.
|
|
101
|
-
"react-intlayer": "9.0.0-canary.
|
|
102
|
-
"vite-intlayer": "9.0.0-canary.
|
|
92
|
+
"@intlayer/config": "9.0.0-canary.21",
|
|
93
|
+
"@intlayer/core": "9.0.0-canary.21",
|
|
94
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.21",
|
|
95
|
+
"@intlayer/engine": "9.0.0-canary.21",
|
|
96
|
+
"@intlayer/types": "9.0.0-canary.21",
|
|
97
|
+
"react-intlayer": "9.0.0-canary.21",
|
|
98
|
+
"vite-intlayer": "9.0.0-canary.21"
|
|
103
99
|
},
|
|
104
100
|
"devDependencies": {
|
|
105
|
-
"@types/node": "
|
|
101
|
+
"@types/node": "26.1.1",
|
|
106
102
|
"@types/react": "19.2.17",
|
|
107
103
|
"@utils/ts-config": "1.0.4",
|
|
108
104
|
"@utils/ts-config-types": "1.0.4",
|
|
109
105
|
"@utils/tsdown-config": "1.0.4",
|
|
110
|
-
"use-intl": "4.13.0",
|
|
111
106
|
"rimraf": "6.1.3",
|
|
112
|
-
"tsdown": "0.
|
|
113
|
-
"typescript": "
|
|
114
|
-
"
|
|
115
|
-
"
|
|
107
|
+
"tsdown": "0.22.12",
|
|
108
|
+
"typescript": "7.0.2",
|
|
109
|
+
"use-intl": "4.13.2",
|
|
110
|
+
"vite": "8.1.5",
|
|
111
|
+
"vitest": "4.1.10"
|
|
116
112
|
},
|
|
117
113
|
"peerDependencies": {
|
|
118
114
|
"react": ">=16.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.cjs","names":["CYAN","IntlayerProvider"],"sources":["../../../src/react/IntlProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from 'react-intlayer';\nimport type { ComponentProps } from 'react';\nimport type { IntlProvider as _IntlProvider } from 'use-intl';\n\n/**\n * Drop-in for use-intl's `IntlProvider`.\n *\n * Wraps Intlayer's `IntlayerProvider`, seeding the client locale from the\n * `locale` prop. `messages`, `formats`, `now`, `timeZone`, `onError`, and\n * `getMessageFallback` are accepted for API compatibility but have no effect —\n * Intlayer uses its own compiled dictionaries.\n */\nexport const IntlProvider: typeof _IntlProvider = ({\n locale,\n children,\n messages: _messages,\n formats: _formats,\n now: _now,\n timeZone: _timeZone,\n onError: _onError,\n getMessageFallback: _getMessageFallback,\n}) => {\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('IntlProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n // `key={locale}` re-seeds the client locale context when the locale changes,\n // so consumers re-render in the new language.\n return (\n <IntlayerProvider\n key={String(locale)}\n locale={locale as LocalesValues}\n >\n {children}\n </IntlayerProvider>\n );\n};\n\n/**\n * Props accepted by {@link IntlProvider}. `messages` is deprecated — Intlayer\n * loads content from compiled dictionaries automatically.\n */\nexport type IntlProviderProps = Omit<\n ComponentProps<typeof _IntlProvider>,\n 'messages' | 'locale'\n> & {\n /**\n * @deprecated has no use case with intlayer. Messages are loaded\n * automatically under the hood for bundle optimization reason.\n */\n messages?: never;\n /** The active locale. */\n locale: LocalesValues;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAsC,EACjD,QACA,UACA,UAAU,WACV,SAAS,UACT,KAAK,MACL,UAAU,WACV,SAAS,UACT,oBAAoB,0BAChB;AACJ,KACE,QAAQ,IAAI,aAAa,iBACzB,OAAO,cAAc,YAGrB,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,gBAAgBA,6BAAK,CAAC,+HACnC;AAKH,QACE,2CAACC,iCAAD;EAEU;EAEP;EACgB,EAJZ,OAAO,OAAO,CAIF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","names":["CYAN","buildIntlFormatter"],"sources":["../../../src/react/helpers.ts"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { useLocale as useLocaleIntlayer } from 'react-intlayer';\nimport type {\n useFormatter as _useFormatter,\n useMessages as _useMessages,\n useNow as _useNow,\n useTimeZone as _useTimeZone,\n} from 'use-intl';\nimport { buildIntlFormatter } from '../shared/intlFormatter';\n\n/**\n * Drop-in for use-intl's `useNow`.\n * Returns the current `Date`. The `updateInterval` option is ignored.\n */\nexport const useNow: typeof _useNow = () => new Date();\n\n/**\n * Drop-in for use-intl's `useTimeZone`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const useTimeZone: typeof _useTimeZone = () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone;\n\n/**\n * Drop-in for use-intl's `useMessages`.\n *\n * @deprecated useMessages has no use case with intlayer.\n * Messages are loaded automatically under the hood.\n * @returns An empty object.\n */\nexport const useMessages: typeof _useMessages = () => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('useMessages', CYAN)} has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n return {} as ReturnType<typeof _useMessages>;\n};\n\n/**\n * Drop-in for use-intl's `useFormatter`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs:\n * `dateTime`, `number`, `dateTimeRange`, `relativeTime`, `list`, and\n * `displayName`.\n */\nexport const useFormatter: typeof _useFormatter = () => {\n const { locale } = useLocaleIntlayer();\n return buildIntlFormatter((locale as string) ?? 'en');\n};\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAa,+BAA+B,IAAI,MAAM;;;;;AAMtD,MAAa,oBACX,KAAK,gBAAgB,CAAC,iBAAiB,CAAC;;;;;;;;AAS1C,MAAa,oBAAyC;AACpD,KAAI,QAAQ,IAAI,aAAa,cAE3B,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,eAAeA,6BAAK,CAAC,iHAClC;AAGH,QAAO,EAAE;;;;;;;;AASX,MAAa,qBAA2C;CACtD,MAAM,EAAE,0CAA8B;AACtC,QAAOC,gDAAoB,UAAqB,KAAK"}
|
package/dist/cjs/react/index.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_useDictionaryDynamic = require('../useDictionaryDynamic.cjs');
|
|
3
|
-
const require_react_IntlProvider = require('./IntlProvider.cjs');
|
|
4
|
-
const require_react_helpers = require('./helpers.cjs');
|
|
5
|
-
const require_react_useLocale = require('./useLocale.cjs');
|
|
6
|
-
const require_react_useTranslations = require('./useTranslations.cjs');
|
|
7
|
-
const require_useDictionary = require('../useDictionary.cjs');
|
|
8
|
-
|
|
9
|
-
//#region src/react/index.ts
|
|
10
|
-
/**
|
|
11
|
-
* @internal Private use-intl export, kept so aliased `_useExtracted` imports
|
|
12
|
-
* resolve. Not part of the supported public surface.
|
|
13
|
-
*/
|
|
14
|
-
const _useExtracted = () => ({});
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
exports.IntlProvider = require_react_IntlProvider.IntlProvider;
|
|
18
|
-
exports._useExtracted = _useExtracted;
|
|
19
|
-
exports.useDictionary = require_useDictionary.useDictionary;
|
|
20
|
-
exports.useDictionaryDynamic = require_useDictionaryDynamic.useDictionaryDynamic;
|
|
21
|
-
exports.useFormatter = require_react_helpers.useFormatter;
|
|
22
|
-
exports.useLocale = require_react_useLocale.useLocale;
|
|
23
|
-
exports.useMessages = require_react_helpers.useMessages;
|
|
24
|
-
exports.useNow = require_react_helpers.useNow;
|
|
25
|
-
exports.useTimeZone = require_react_helpers.useTimeZone;
|
|
26
|
-
exports.useTranslations = require_react_useTranslations.useTranslations;
|
|
27
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/react/index.ts"],"sourcesContent":["export { IntlProvider, type IntlProviderProps } from './IntlProvider';\nexport { useFormatter, useMessages, useNow, useTimeZone } from './helpers';\nexport { useLocale } from './useLocale';\nexport { useTranslations } from './useTranslations';\nexport { useDictionary } from '../useDictionary';\nexport { useDictionaryDynamic } from '../useDictionaryDynamic';\n\n/**\n * @internal Private use-intl export, kept so aliased `_useExtracted` imports\n * resolve. Not part of the supported public surface.\n */\nexport const _useExtracted = (): Record<string, never> => ({});\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,uBAA8C,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/react/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { useLocale as useLocaleIntlayer } from 'react-intlayer';\nimport type { useLocale as _useLocale } from 'use-intl';\n\n/**\n * Drop-in for use-intl's `useLocale`.\n *\n * Returns the active locale string from Intlayer's client context.\n */\nexport const useLocale: typeof _useLocale = () => {\n const { locale } = useLocaleIntlayer();\n return locale as ReturnType<typeof _useLocale>;\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,kBAAqC;CAChD,MAAM,EAAE,0CAA8B;AACtC,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.cjs","names":["IntlayerClientContext","createNamespaceTranslator"],"sources":["../../../src/react/useTranslations.ts"],"sourcesContent":["'use client';\n\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerClientContext } from 'react-intlayer';\nimport { useContext, useMemo } from 'react';\nimport { createNamespaceTranslator } from '../shared/namespaceTranslator';\nimport type {\n LooseTranslateFunction,\n TranslateFunction,\n} from '../shared/translateFunctionTypes';\n\n/**\n * Overload set for {@link useTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching use-intl's scoped-namespace behaviour.\n * 3. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n */\ntype UseTranslations = {\n <N extends DictionaryKeys>(namespace: N): TranslateFunction<N>;\n (namespace: `${string}.${string}`): LooseTranslateFunction;\n (): LooseTranslateFunction;\n};\n\n/**\n * Drop-in for use-intl's `useTranslations`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * @example\n * ```tsx\n * const t = useTranslations('about');\n * t('counter.label'); // ✓ typed\n * t('items', { count: 3 }); // ICU plural\n *\n * // Scoped to a nested object (use-intl idiom)\n * const t = useTranslations('about.counter');\n * t('label'); // resolves about → counter.label\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const useTranslations = ((namespace?: string) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => createNamespaceTranslator(currentLocale as LocalesValues, namespace),\n [currentLocale, namespace]\n );\n}) as UseTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,oBAAoB,cAAuB;CACtD,MAAM,EAAE,QAAQ,wCAA6BA,qCAAsB,IAAI,EAAE;AAEzE,iCACQC,6DAA0B,eAAgC,UAAU,EAC1E,CAAC,eAAe,UAAU,CAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.mjs","names":[],"sources":["../../../src/react/IntlProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from 'react-intlayer';\nimport type { ComponentProps } from 'react';\nimport type { IntlProvider as _IntlProvider } from 'use-intl';\n\n/**\n * Drop-in for use-intl's `IntlProvider`.\n *\n * Wraps Intlayer's `IntlayerProvider`, seeding the client locale from the\n * `locale` prop. `messages`, `formats`, `now`, `timeZone`, `onError`, and\n * `getMessageFallback` are accepted for API compatibility but have no effect —\n * Intlayer uses its own compiled dictionaries.\n */\nexport const IntlProvider: typeof _IntlProvider = ({\n locale,\n children,\n messages: _messages,\n formats: _formats,\n now: _now,\n timeZone: _timeZone,\n onError: _onError,\n getMessageFallback: _getMessageFallback,\n}) => {\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('IntlProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n // `key={locale}` re-seeds the client locale context when the locale changes,\n // so consumers re-render in the new language.\n return (\n <IntlayerProvider\n key={String(locale)}\n locale={locale as LocalesValues}\n >\n {children}\n </IntlayerProvider>\n );\n};\n\n/**\n * Props accepted by {@link IntlProvider}. `messages` is deprecated — Intlayer\n * loads content from compiled dictionaries automatically.\n */\nexport type IntlProviderProps = Omit<\n ComponentProps<typeof _IntlProvider>,\n 'messages' | 'locale'\n> & {\n /**\n * @deprecated has no use case with intlayer. Messages are loaded\n * automatically under the hood for bundle optimization reason.\n */\n messages?: never;\n /** The active locale. */\n locale: LocalesValues;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAa,gBAAsC,EACjD,QACA,UACA,UAAU,WACV,SAAS,UACT,KAAK,MACL,UAAU,WACV,SAAS,UACT,oBAAoB,0BAChB;AACJ,KAEE,OAAO,cAAc,YAGrB,CADkB,aAAa,EAAE,KAAK,CAC7B,CACP,GAAG,SAAS,gBAAgB,KAAK,CAAC,+HACnC;AAKH,QACE,oBAAC,kBAAD;EAEU;EAEP;EACgB,EAJZ,OAAO,OAAO,CAIF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":["useLocaleIntlayer"],"sources":["../../../src/react/helpers.ts"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { useLocale as useLocaleIntlayer } from 'react-intlayer';\nimport type {\n useFormatter as _useFormatter,\n useMessages as _useMessages,\n useNow as _useNow,\n useTimeZone as _useTimeZone,\n} from 'use-intl';\nimport { buildIntlFormatter } from '../shared/intlFormatter';\n\n/**\n * Drop-in for use-intl's `useNow`.\n * Returns the current `Date`. The `updateInterval` option is ignored.\n */\nexport const useNow: typeof _useNow = () => new Date();\n\n/**\n * Drop-in for use-intl's `useTimeZone`.\n * Returns the system time zone resolved from `Intl.DateTimeFormat`.\n */\nexport const useTimeZone: typeof _useTimeZone = () =>\n Intl.DateTimeFormat().resolvedOptions().timeZone;\n\n/**\n * Drop-in for use-intl's `useMessages`.\n *\n * @deprecated useMessages has no use case with intlayer.\n * Messages are loaded automatically under the hood.\n * @returns An empty object.\n */\nexport const useMessages: typeof _useMessages = () => {\n if (process.env.NODE_ENV === 'development') {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('useMessages', CYAN)} has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n return {} as ReturnType<typeof _useMessages>;\n};\n\n/**\n * Drop-in for use-intl's `useFormatter`.\n * Returns locale-aware formatters backed by the native `Intl.*` APIs:\n * `dateTime`, `number`, `dateTimeRange`, `relativeTime`, `list`, and\n * `displayName`.\n */\nexport const useFormatter: typeof _useFormatter = () => {\n const { locale } = useLocaleIntlayer();\n return buildIntlFormatter((locale as string) ?? 'en');\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAa,+BAA+B,IAAI,MAAM;;;;;AAMtD,MAAa,oBACX,KAAK,gBAAgB,CAAC,iBAAiB,CAAC;;;;;;;;AAS1C,MAAa,oBAAyC;AAGlD,CADkB,aAAa,EAAE,KAAK,CAC7B,CACP,GAAG,SAAS,eAAe,KAAK,CAAC,iHAClC;AAGH,QAAO,EAAE;;;;;;;;AASX,MAAa,qBAA2C;CACtD,MAAM,EAAE,WAAWA,WAAmB;AACtC,QAAO,mBAAoB,UAAqB,KAAK"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/react/index.ts"],"sourcesContent":["export { IntlProvider, type IntlProviderProps } from './IntlProvider';\nexport { useFormatter, useMessages, useNow, useTimeZone } from './helpers';\nexport { useLocale } from './useLocale';\nexport { useTranslations } from './useTranslations';\nexport { useDictionary } from '../useDictionary';\nexport { useDictionaryDynamic } from '../useDictionaryDynamic';\n\n/**\n * @internal Private use-intl export, kept so aliased `_useExtracted` imports\n * resolve. Not part of the supported public surface.\n */\nexport const _useExtracted = (): Record<string, never> => ({});\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,uBAA8C,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":["useLocaleIntlayer"],"sources":["../../../src/react/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { useLocale as useLocaleIntlayer } from 'react-intlayer';\nimport type { useLocale as _useLocale } from 'use-intl';\n\n/**\n * Drop-in for use-intl's `useLocale`.\n *\n * Returns the active locale string from Intlayer's client context.\n */\nexport const useLocale: typeof _useLocale = () => {\n const { locale } = useLocaleIntlayer();\n return locale as ReturnType<typeof _useLocale>;\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,kBAAqC;CAChD,MAAM,EAAE,WAAWA,aAAmB;AACtC,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.mjs","names":[],"sources":["../../../src/react/useTranslations.ts"],"sourcesContent":["'use client';\n\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { IntlayerClientContext } from 'react-intlayer';\nimport { useContext, useMemo } from 'react';\nimport { createNamespaceTranslator } from '../shared/namespaceTranslator';\nimport type {\n LooseTranslateFunction,\n TranslateFunction,\n} from '../shared/translateFunctionTypes';\n\n/**\n * Overload set for {@link useTranslations}:\n *\n * 1. A bare dictionary key → fully-typed `t()` (autocompleted dot-paths).\n * 2. A nested namespace `'dictionary.sub.scope'` → `t()` accepts relative\n * `string` paths, matching use-intl's scoped-namespace behaviour.\n * 3. No namespace → root scope; the first segment of each key designates\n * the dictionary (`t('about.title')`).\n */\ntype UseTranslations = {\n <N extends DictionaryKeys>(namespace: N): TranslateFunction<N>;\n (namespace: `${string}.${string}`): LooseTranslateFunction;\n (): LooseTranslateFunction;\n};\n\n/**\n * Drop-in for use-intl's `useTranslations`.\n *\n * Messages support ICU MessageFormat syntax: simple arguments (`{name}`),\n * plural (`{count, plural, one {…} other {…}}`, `#`), select, and formatted\n * arguments (`{value, number}`). Rich text is available through `t.rich()`\n * and `t.markup()`.\n *\n * @example\n * ```tsx\n * const t = useTranslations('about');\n * t('counter.label'); // ✓ typed\n * t('items', { count: 3 }); // ICU plural\n *\n * // Scoped to a nested object (use-intl idiom)\n * const t = useTranslations('about.counter');\n * t('label'); // resolves about → counter.label\n *\n * // Rich text\n * t.rich('terms', { link: (chunks) => <a href=\"/terms\">{chunks}</a> });\n * ```\n */\nexport const useTranslations = ((namespace?: string) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => createNamespaceTranslator(currentLocale as LocalesValues, namespace),\n [currentLocale, namespace]\n );\n}) as UseTranslations;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,oBAAoB,cAAuB;CACtD,MAAM,EAAE,QAAQ,kBAAkB,WAAW,sBAAsB,IAAI,EAAE;AAEzE,QAAO,cACC,0BAA0B,eAAgC,UAAU,EAC1E,CAAC,eAAe,UAAU,CAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlProvider.d.ts","names":[],"sources":["../../../src/react/IntlProvider.tsx"],"mappings":";;;;;;;AAkBA;;;;;AAoCA;cApCa,YAAA,SAAqB,cAAA;;;;;KAoCtB,iBAAA,GAAoB,IAAA,CAC9B,cAAA,QAAsB,cAAA;EASD;;;;EAFrB,QAAA;EAEA,MAAA,EAAQ,aAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/react/helpers.ts"],"mappings":";;;;;AAkBA;;cAAa,MAAA,SAAe,QAAA;;;AAM5B;;cAAa,WAAA,SAAoB,aAAA;;;AAUjC;;;;;cAAa,WAAA,SAAoB,aAAA;;;;;;;cAiBpB,YAAA,SAAqB,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/react/index.ts"],"mappings":";;;;;;;;;;AAWA;;cAAa,aAAA,QAAoB,MAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/react/useLocale.ts"],"mappings":";;;;;AAUA;;;cAAa,SAAA,SAAkB,WAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.d.ts","names":[],"sources":["../../../src/react/useTranslations.ts"],"mappings":";;;;;;AAY0C;;;;;;;KAWrC,eAAA;EAAA,WACQ,cAAA,EAAgB,SAAA,EAAW,CAAA,GAAI,iBAAA,CAAkB,CAAA;EAAA,CAC3D,SAAA,0BAAmC,sBAAA;EAAA,IAChC,sBAAA;AAAA;;;;;;;;;;;AAyBN;;;;;;;;;;;;cAAa,eAAA,EAOP,eAAA"}
|