remix-intlayer 9.5.4 → 9.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cjs/format/index.cjs +3 -3
- package/dist/cjs/format/useIntl.cjs +1 -1
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/localeRouting.cjs +1 -1
- package/dist/cjs/middleware.cjs +3 -3
- package/dist/cjs/plugins.cjs +27 -0
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/cjs/useDictionary.cjs +14 -5
- package/dist/cjs/useDictionary.cjs.map +1 -1
- package/dist/cjs/useIntlayer.cjs +14 -5
- package/dist/cjs/useIntlayer.cjs.map +1 -1
- package/dist/cjs/useLocale.cjs.map +1 -1
- package/dist/esm/format/index.mjs +3 -3
- package/dist/esm/format/useIntl.mjs +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/localeRouting.mjs +1 -1
- package/dist/esm/middleware.mjs +3 -3
- package/dist/esm/plugins.mjs +26 -0
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/esm/useDictionary.mjs +15 -6
- package/dist/esm/useDictionary.mjs.map +1 -1
- package/dist/esm/useIntlayer.mjs +15 -6
- package/dist/esm/useIntlayer.mjs.map +1 -1
- package/dist/esm/useLocale.mjs.map +1 -1
- package/dist/types/plugins.d.ts +23 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/useDictionary.d.ts +8 -3
- package/dist/types/useDictionary.d.ts.map +1 -1
- package/dist/types/useIntlayer.d.ts +7 -2
- package/dist/types/useIntlayer.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/cjs/IntlayerProvider.cjs +0 -36
- package/dist/cjs/IntlayerProvider.cjs.map +0 -1
- package/dist/cjs/resolveLocale.cjs +0 -21
- package/dist/cjs/resolveLocale.cjs.map +0 -1
- package/dist/esm/IntlayerProvider.mjs +0 -35
- package/dist/esm/IntlayerProvider.mjs.map +0 -1
- package/dist/esm/resolveLocale.mjs +0 -20
- package/dist/esm/resolveLocale.mjs.map +0 -1
- package/dist/types/IntlayerProvider.d.ts +0 -39
- package/dist/types/IntlayerProvider.d.ts.map +0 -1
- package/dist/types/resolveLocale.d.ts +0 -16
- package/dist/types/resolveLocale.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -188,7 +188,8 @@ Explore our comprehensive documentation to get started with Intlayer and learn h
|
|
|
188
188
|
<li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
|
|
189
189
|
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a></li>
|
|
190
190
|
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React using Compiler</a></li>
|
|
191
|
-
<li><a href="https://intlayer.org/doc/environment/vite-and-react/
|
|
191
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
|
|
192
|
+
<li><a href="https://intlayer.org/doc/environment/remix-3" rel=''>Remix 3</a></li>
|
|
192
193
|
<li><a href="https://intlayer.org/doc/environment/tanstack-start" rel=''>Tanstack start</a>
|
|
193
194
|
<ul>
|
|
194
195
|
<li><a href="https://intlayer.org/doc/environment/tanstack-start/solid" rel=''>Solid</a></li>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_format_useCurrency = require('./useCurrency.cjs');
|
|
2
3
|
const require_format_useUnit = require('./useUnit.cjs');
|
|
3
4
|
const require_format_useDate = require('./useDate.cjs');
|
|
4
|
-
const require_format_useNumber = require('./useNumber.cjs');
|
|
5
|
-
const require_format_useRelativeTime = require('./useRelativeTime.cjs');
|
|
6
5
|
const require_format_useCompact = require('./useCompact.cjs');
|
|
7
6
|
const require_format_useIntl = require('./useIntl.cjs');
|
|
8
7
|
const require_format_useList = require('./useList.cjs');
|
|
8
|
+
const require_format_useNumber = require('./useNumber.cjs');
|
|
9
9
|
const require_format_usePercentage = require('./usePercentage.cjs');
|
|
10
|
-
const
|
|
10
|
+
const require_format_useRelativeTime = require('./useRelativeTime.cjs');
|
|
11
11
|
|
|
12
12
|
exports.useCompact = require_format_useCompact.useCompact;
|
|
13
13
|
exports.useCurrency = require_format_useCurrency.useCurrency;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_requestStorage = require('../requestStorage.cjs');
|
|
3
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
3
|
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
4
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
5
|
|
|
6
6
|
//#region src/format/useIntl.ts
|
|
7
7
|
const { defaultLocale } = _intlayer_config_built.internationalization;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_context = require('./context.cjs');
|
|
3
2
|
const require_localeRouting = require('./localeRouting.cjs');
|
|
3
|
+
const require_context = require('./context.cjs');
|
|
4
4
|
const require_requestStorage = require('./requestStorage.cjs');
|
|
5
|
-
const require_middleware = require('./middleware.cjs');
|
|
6
5
|
const require_useIntlayer = require('./useIntlayer.cjs');
|
|
7
|
-
const
|
|
6
|
+
const require_middleware = require('./middleware.cjs');
|
|
8
7
|
const require_useDictionary = require('./useDictionary.cjs');
|
|
8
|
+
const require_useLocale = require('./useLocale.cjs');
|
|
9
9
|
|
|
10
10
|
exports.INTLAYER_CONTEXT_PROPERTY = require_context.INTLAYER_CONTEXT_PROPERTY;
|
|
11
11
|
exports.Intlayer = require_context.Intlayer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
3
2
|
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
3
|
+
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
4
4
|
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
5
5
|
|
|
6
6
|
//#region src/localeRouting.ts
|
package/dist/cjs/middleware.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_context = require('./context.cjs');
|
|
3
2
|
const require_localeRouting = require('./localeRouting.cjs');
|
|
4
|
-
const
|
|
3
|
+
const require_context = require('./context.cjs');
|
|
5
4
|
const require_requestStorage = require('./requestStorage.cjs');
|
|
5
|
+
const require_persistLocale = require('./persistLocale.cjs');
|
|
6
|
+
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
6
7
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
8
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
8
|
-
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
9
9
|
let _intlayer_engine_build = require("@intlayer/engine/build");
|
|
10
10
|
|
|
11
11
|
//#region src/middleware.ts
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
3
|
+
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
|
+
let vanilla_intlayer = require("vanilla-intlayer");
|
|
5
|
+
|
|
6
|
+
//#region src/plugins.ts
|
|
7
|
+
const pluginsCache = /* @__PURE__ */ new Map();
|
|
8
|
+
/**
|
|
9
|
+
* Returns the plugin array for a locale, memoized so the interpreter's
|
|
10
|
+
* transform cache can key on its identity.
|
|
11
|
+
*/
|
|
12
|
+
const getPlugins = (locale, fallback = true) => {
|
|
13
|
+
const cacheKey = `${locale ?? _intlayer_config_built.internationalization.defaultLocale}_${fallback}`;
|
|
14
|
+
const cached = pluginsCache.get(cacheKey);
|
|
15
|
+
if (cached) return cached;
|
|
16
|
+
const plugins = [
|
|
17
|
+
...(0, _intlayer_core_interpreter.getBasePlugins)(locale, fallback),
|
|
18
|
+
vanilla_intlayer.markdownPlugin,
|
|
19
|
+
vanilla_intlayer.htmlPlugin
|
|
20
|
+
];
|
|
21
|
+
pluginsCache.set(cacheKey, plugins);
|
|
22
|
+
return plugins;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.getPlugins = getPlugins;
|
|
27
|
+
//# sourceMappingURL=plugins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["internationalization","getBasePlugins","markdownPlugin","htmlPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n type DeepTransformContent as DeepTransformContentCore,\n getBasePlugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type Plugins,\n} from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { htmlPlugin, markdownPlugin } from 'vanilla-intlayer';\n\n/**\n * Plugins applied by the hooks of this package.\n *\n * The base interpreter leaves `md()` and `html()` nodes untouched, so they are\n * handed to the string renderers of `vanilla-intlayer`: the node exposes the\n * rendered HTML as `.value` and `.use(components)` to override tags. Plain\n * strings stay primitives — a `remix/ui` child must be a string, not a wrapper.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n vanillaMarkdown: true;\n vanillaHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Returns the plugin array for a locale, memoized so the interpreter's\n * transform cache can key on its identity.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback = true\n): Plugins[] => {\n const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;\n\n const cached = pluginsCache.get(cacheKey);\n if (cached) return cached;\n\n const plugins = [\n ...getBasePlugins(locale, fallback),\n markdownPlugin,\n htmlPlugin,\n ];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;AA+BA,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAW,SACG;CACd,MAAM,WAAW,GAAG,UAAUA,4CAAqB,cAAc,GAAG;CAEpE,MAAM,SAAS,aAAa,IAAI,QAAQ;CACxC,IAAI,QAAQ,OAAO;CAEnB,MAAM,UAAU;EACd,OAAGC,2CAAe,QAAQ,QAAQ;EAClCC;EACAC;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_plugins = require('./plugins.cjs');
|
|
2
3
|
const require_requestStorage = require('./requestStorage.cjs');
|
|
3
4
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
4
5
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
@@ -12,6 +13,10 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
|
12
13
|
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
13
14
|
* over the request locale.
|
|
14
15
|
*
|
|
16
|
+
* `md()` and `html()` nodes render to HTML strings: read `.value`, or call
|
|
17
|
+
* `.use(components)` to override tags, and inject the result with `html.raw`
|
|
18
|
+
* or `innerHTML`.
|
|
19
|
+
*
|
|
15
20
|
* @example
|
|
16
21
|
* ```ts
|
|
17
22
|
* import homeContent from './home.content';
|
|
@@ -22,11 +27,15 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
|
22
27
|
* });
|
|
23
28
|
* ```
|
|
24
29
|
*/
|
|
25
|
-
const useDictionary = (dictionary, localeOrSelector) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
const useDictionary = (dictionary, localeOrSelector) => {
|
|
31
|
+
const argument = (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
32
|
+
localeOrSelector,
|
|
33
|
+
contextLocale: require_requestStorage.getRequestLocale(),
|
|
34
|
+
dictionaryKey: dictionary.key
|
|
35
|
+
});
|
|
36
|
+
const { locale } = (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(argument);
|
|
37
|
+
return (0, _intlayer_core_interpreter.getDictionary)(dictionary, argument, require_plugins.getPlugins(locale));
|
|
38
|
+
};
|
|
30
39
|
|
|
31
40
|
//#endregion
|
|
32
41
|
exports.useDictionary = useDictionary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["resolveDictionaryArgument","getRequestLocale","parseDictionarySelector","getDictionary","getPlugins"],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import {\n parseDictionarySelector,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getDictionary } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\nimport { getRequestLocale } from './requestStorage';\n\n/**\n * Transforms an imported dictionary (or qualified dictionary group) and returns\n * its content for the locale of the request being handled.\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence\n * over the request locale.\n *\n * `md()` and `html()` nodes render to HTML strings: read `.value`, or call\n * `.use(components)` to override tags, and inject the result with `html.raw`\n * or `innerHTML`.\n *\n * @example\n * ```ts\n * import homeContent from './home.content';\n *\n * router.get('/', () => {\n * const { title } = useDictionary(homeContent);\n * return new Response(title);\n * });\n * ```\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const argument = resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: dictionary.key,\n });\n const { locale } = parseDictionarySelector(argument);\n\n return getDictionary<T, A>(\n dictionary,\n argument as A,\n getPlugins(locale)\n ) as DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,iBAMX,YACA,qBAIG;CACH,MAAM,eAAWA,gEAA0B;EACzC;EACA,eAAeC,wCAAiB;EAChC,eAAe,WAAW;CAC5B,CAAC;CACD,MAAM,EAAE,eAAWC,8DAAwB,QAAQ;CAEnD,WAAOC,0CACL,YACA,UACAC,2BAAW,MAAM,CACnB;AAIF"}
|
package/dist/cjs/useIntlayer.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_plugins = require('./plugins.cjs');
|
|
2
3
|
const require_requestStorage = require('./requestStorage.cjs');
|
|
3
4
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
4
5
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
@@ -12,6 +13,10 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
|
12
13
|
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
13
14
|
* over the request locale.
|
|
14
15
|
*
|
|
16
|
+
* `md()` and `html()` nodes render to HTML strings: read `.value`, or call
|
|
17
|
+
* `.use(components)` to override tags, and inject the result with `html.raw`
|
|
18
|
+
* or `innerHTML`.
|
|
19
|
+
*
|
|
15
20
|
* @example
|
|
16
21
|
* ```ts
|
|
17
22
|
* router.get('/', () => {
|
|
@@ -20,11 +25,15 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
|
20
25
|
* });
|
|
21
26
|
* ```
|
|
22
27
|
*/
|
|
23
|
-
const useIntlayer = (key, localeOrSelector) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
const useIntlayer = (key, localeOrSelector) => {
|
|
29
|
+
const argument = (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
30
|
+
localeOrSelector,
|
|
31
|
+
contextLocale: require_requestStorage.getRequestLocale(),
|
|
32
|
+
dictionaryKey: key
|
|
33
|
+
});
|
|
34
|
+
const { locale } = (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(argument);
|
|
35
|
+
return (0, _intlayer_core_interpreter.getIntlayer)(key, argument, require_plugins.getPlugins(locale));
|
|
36
|
+
};
|
|
28
37
|
|
|
29
38
|
//#endregion
|
|
30
39
|
exports.useIntlayer = useIntlayer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["resolveDictionaryArgument","getRequestLocale","parseDictionarySelector","getIntlayer","getPlugins"],"sources":["../../src/useIntlayer.ts"],"sourcesContent":["import {\n parseDictionarySelector,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\nimport { getRequestLocale } from './requestStorage';\n\n/**\n * Picks one dictionary by its key and returns its content for the locale of\n * the request being handled.\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence\n * over the request locale.\n *\n * `md()` and `html()` nodes render to HTML strings: read `.value`, or call\n * `.use(components)` to override tags, and inject the result with `html.raw`\n * or `innerHTML`.\n *\n * @example\n * ```ts\n * router.get('/', () => {\n * const { title } = useIntlayer('home');\n * return new Response(title);\n * });\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const argument = resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: key as string,\n });\n const { locale } = parseDictionarySelector(argument);\n\n return getIntlayer<T, A>(\n key,\n argument as A,\n getPlugins(locale)\n ) as DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,eAIX,KACA,qBAIG;CACH,MAAM,eAAWA,gEAA0B;EACzC;EACA,eAAeC,wCAAiB;EAChC,eAAe;CACjB,CAAC;CACD,MAAM,EAAE,eAAWC,8DAAwB,QAAQ;CAEnD,WAAOC,wCACL,KACA,UACAC,2BAAW,MAAM,CACnB;AAIF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["internationalization","getIntlayerState"],"sources":["../../src/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { getIntlayerState
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["internationalization","getIntlayerState"],"sources":["../../src/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { getIntlayerState } from './requestStorage';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * Returns the locale of the request being handled, with the configured\n * default and available locales.\n *\n * Falls back to the default locale outside of a request, i.e. when the\n * `intlayer()` middleware did not run.\n *\n * @example\n * ```ts\n * router.get('/', () => {\n * const { locale, availableLocales } = useLocale();\n * return Response.json({ locale, availableLocales });\n * });\n * ```\n */\nexport const useLocale = (): UseLocaleResult => {\n const state = getIntlayerState();\n\n return {\n locale: state?.locale ?? (defaultLocale as DeclaredLocales),\n defaultLocale: state?.defaultLocale ?? (defaultLocale as DeclaredLocales),\n availableLocales:\n state?.availableLocales ?? (availableLocales as DeclaredLocales[]),\n };\n};\n"],"mappings":";;;;;AAUA,MAAM,EAAE,eAAe,SAAS,qBAAqBA;;;;;;;;;;;;;;;;AAiBrD,MAAa,kBAAmC;CAC9C,MAAM,QAAQC,wCAAiB;CAE/B,OAAO;EACL,QAAQ,OAAO,UAAW;EAC1B,eAAe,OAAO,iBAAkB;EACxC,kBACE,OAAO,oBAAqB;CAChC;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { useCurrency } from "./useCurrency.mjs";
|
|
1
2
|
import { useUnit } from "./useUnit.mjs";
|
|
2
3
|
import { useDate } from "./useDate.mjs";
|
|
3
|
-
import { useNumber } from "./useNumber.mjs";
|
|
4
|
-
import { useRelativeTime } from "./useRelativeTime.mjs";
|
|
5
4
|
import { useCompact } from "./useCompact.mjs";
|
|
6
5
|
import { useIntl } from "./useIntl.mjs";
|
|
7
6
|
import { useList } from "./useList.mjs";
|
|
7
|
+
import { useNumber } from "./useNumber.mjs";
|
|
8
8
|
import { usePercentage } from "./usePercentage.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { useRelativeTime } from "./useRelativeTime.mjs";
|
|
10
10
|
|
|
11
11
|
export { useCompact, useCurrency, useDate, useIntl, useList, useNumber, usePercentage, useRelativeTime, useUnit };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
|
-
import { internationalization } from "@intlayer/config/built";
|
|
3
2
|
import { bindIntl } from "@intlayer/core/utils";
|
|
3
|
+
import { internationalization } from "@intlayer/config/built";
|
|
4
4
|
|
|
5
5
|
//#region src/format/useIntl.ts
|
|
6
6
|
const { defaultLocale } = internationalization;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { INTLAYER_CONTEXT_PROPERTY, Intlayer } from "./context.mjs";
|
|
2
1
|
import { createLocaleRouting } from "./localeRouting.mjs";
|
|
2
|
+
import { INTLAYER_CONTEXT_PROPERTY, Intlayer } from "./context.mjs";
|
|
3
3
|
import { getIntlayerState } from "./requestStorage.mjs";
|
|
4
|
-
import { intlayer } from "./middleware.mjs";
|
|
5
4
|
import { useIntlayer } from "./useIntlayer.mjs";
|
|
6
|
-
import {
|
|
5
|
+
import { intlayer } from "./middleware.mjs";
|
|
7
6
|
import { useDictionary } from "./useDictionary.mjs";
|
|
7
|
+
import { useLocale } from "./useLocale.mjs";
|
|
8
8
|
|
|
9
9
|
export { INTLAYER_CONTEXT_PROPERTY, Intlayer, createLocaleRouting, getIntlayerState, intlayer, useDictionary, useIntlayer, useLocale };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCanonicalPath, getDomainHostname, getDomainOrigin, getLocaleFromDomain, getRewriteRules, isProxyStorageLocaleEnabled, localeDetector, resolveLocalizedPath, resolveProxyMode } from "@intlayer/core/localization";
|
|
2
1
|
import { ROUTING_MODE } from "@intlayer/config/defaultValues";
|
|
2
|
+
import { getCanonicalPath, getDomainHostname, getDomainOrigin, getLocaleFromDomain, getRewriteRules, isProxyStorageLocaleEnabled, localeDetector, resolveLocalizedPath, resolveProxyMode } from "@intlayer/core/localization";
|
|
3
3
|
import { getCookie, getLocaleFromStorageServer } from "@intlayer/core/utils";
|
|
4
4
|
|
|
5
5
|
//#region src/localeRouting.ts
|
package/dist/esm/middleware.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { INTLAYER_CONTEXT_PROPERTY, Intlayer } from "./context.mjs";
|
|
2
1
|
import { createLocaleRouting } from "./localeRouting.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { INTLAYER_CONTEXT_PROPERTY, Intlayer } from "./context.mjs";
|
|
4
3
|
import { requestStorage } from "./requestStorage.mjs";
|
|
4
|
+
import { withLocaleHeaders, writeLocaleHeaders } from "./persistLocale.mjs";
|
|
5
|
+
import { getLocaleFromRequest } from "@intlayer/core/localization";
|
|
5
6
|
import { internationalization, routing } from "@intlayer/config/built";
|
|
6
7
|
import { getConfiguration } from "@intlayer/config/node";
|
|
7
|
-
import { getLocaleFromRequest } from "@intlayer/core/localization";
|
|
8
8
|
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
9
9
|
|
|
10
10
|
//#region src/middleware.ts
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getBasePlugins } from "@intlayer/core/interpreter";
|
|
2
|
+
import { internationalization } from "@intlayer/config/built";
|
|
3
|
+
import { htmlPlugin, markdownPlugin } from "vanilla-intlayer";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins.ts
|
|
6
|
+
const pluginsCache = /* @__PURE__ */ new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Returns the plugin array for a locale, memoized so the interpreter's
|
|
9
|
+
* transform cache can key on its identity.
|
|
10
|
+
*/
|
|
11
|
+
const getPlugins = (locale, fallback = true) => {
|
|
12
|
+
const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;
|
|
13
|
+
const cached = pluginsCache.get(cacheKey);
|
|
14
|
+
if (cached) return cached;
|
|
15
|
+
const plugins = [
|
|
16
|
+
...getBasePlugins(locale, fallback),
|
|
17
|
+
markdownPlugin,
|
|
18
|
+
htmlPlugin
|
|
19
|
+
];
|
|
20
|
+
pluginsCache.set(cacheKey, plugins);
|
|
21
|
+
return plugins;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getPlugins };
|
|
26
|
+
//# sourceMappingURL=plugins.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n type DeepTransformContent as DeepTransformContentCore,\n getBasePlugins,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n type Plugins,\n} from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { htmlPlugin, markdownPlugin } from 'vanilla-intlayer';\n\n/**\n * Plugins applied by the hooks of this package.\n *\n * The base interpreter leaves `md()` and `html()` nodes untouched, so they are\n * handed to the string renderers of `vanilla-intlayer`: the node exposes the\n * rendered HTML as `.value` and `.use(components)` to override tags. Plain\n * strings stay primitives — a `remix/ui` child must be a string, not a wrapper.\n */\nexport type IInterpreterPluginState = IInterpreterPluginStateCore & {\n vanillaMarkdown: true;\n vanillaHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Returns the plugin array for a locale, memoized so the interpreter's\n * transform cache can key on its identity.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback = true\n): Plugins[] => {\n const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;\n\n const cached = pluginsCache.get(cacheKey);\n if (cached) return cached;\n\n const plugins = [\n ...getBasePlugins(locale, fallback),\n markdownPlugin,\n htmlPlugin,\n ];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;AA+BA,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAW,SACG;CACd,MAAM,WAAW,GAAG,UAAU,qBAAqB,cAAc,GAAG;CAEpE,MAAM,SAAS,aAAa,IAAI,QAAQ;CACxC,IAAI,QAAQ,OAAO;CAEnB,MAAM,UAAU;EACd,GAAG,eAAe,QAAQ,QAAQ;EAClC;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { getPlugins } from "./plugins.mjs";
|
|
1
2
|
import { getRequestLocale } from "./requestStorage.mjs";
|
|
2
|
-
import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
3
|
+
import { parseDictionarySelector, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
3
4
|
import { getDictionary } from "@intlayer/core/interpreter";
|
|
4
5
|
|
|
5
6
|
//#region src/useDictionary.ts
|
|
@@ -11,6 +12,10 @@ import { getDictionary } from "@intlayer/core/interpreter";
|
|
|
11
12
|
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
12
13
|
* over the request locale.
|
|
13
14
|
*
|
|
15
|
+
* `md()` and `html()` nodes render to HTML strings: read `.value`, or call
|
|
16
|
+
* `.use(components)` to override tags, and inject the result with `html.raw`
|
|
17
|
+
* or `innerHTML`.
|
|
18
|
+
*
|
|
14
19
|
* @example
|
|
15
20
|
* ```ts
|
|
16
21
|
* import homeContent from './home.content';
|
|
@@ -21,11 +26,15 @@ import { getDictionary } from "@intlayer/core/interpreter";
|
|
|
21
26
|
* });
|
|
22
27
|
* ```
|
|
23
28
|
*/
|
|
24
|
-
const useDictionary = (dictionary, localeOrSelector) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
const useDictionary = (dictionary, localeOrSelector) => {
|
|
30
|
+
const argument = resolveDictionaryArgument({
|
|
31
|
+
localeOrSelector,
|
|
32
|
+
contextLocale: getRequestLocale(),
|
|
33
|
+
dictionaryKey: dictionary.key
|
|
34
|
+
});
|
|
35
|
+
const { locale } = parseDictionarySelector(argument);
|
|
36
|
+
return getDictionary(dictionary, argument, getPlugins(locale));
|
|
37
|
+
};
|
|
29
38
|
|
|
30
39
|
//#endregion
|
|
31
40
|
export { useDictionary };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../src/useDictionary.ts"],"sourcesContent":["import {\n parseDictionarySelector,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getDictionary } from '@intlayer/core/interpreter';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\nimport { getRequestLocale } from './requestStorage';\n\n/**\n * Transforms an imported dictionary (or qualified dictionary group) and returns\n * its content for the locale of the request being handled.\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence\n * over the request locale.\n *\n * `md()` and `html()` nodes render to HTML strings: read `.value`, or call\n * `.use(components)` to override tags, and inject the result with `html.raw`\n * or `innerHTML`.\n *\n * @example\n * ```ts\n * import homeContent from './home.content';\n *\n * router.get('/', () => {\n * const { title } = useDictionary(homeContent);\n * return new Response(title);\n * });\n * ```\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const argument = resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: dictionary.key,\n });\n const { locale } = parseDictionarySelector(argument);\n\n return getDictionary<T, A>(\n dictionary,\n argument as A,\n getPlugins(locale)\n ) as DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n ExtractSelectorLocale<A>\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,iBAMX,YACA,qBAIG;CACH,MAAM,WAAW,0BAA0B;EACzC;EACA,eAAe,iBAAiB;EAChC,eAAe,WAAW;CAC5B,CAAC;CACD,MAAM,EAAE,WAAW,wBAAwB,QAAQ;CAEnD,OAAO,cACL,YACA,UACA,WAAW,MAAM,CACnB;AAIF"}
|
package/dist/esm/useIntlayer.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { getPlugins } from "./plugins.mjs";
|
|
1
2
|
import { getRequestLocale } from "./requestStorage.mjs";
|
|
2
|
-
import { resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
3
|
+
import { parseDictionarySelector, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
3
4
|
import { getIntlayer } from "@intlayer/core/interpreter";
|
|
4
5
|
|
|
5
6
|
//#region src/useIntlayer.ts
|
|
@@ -11,6 +12,10 @@ import { getIntlayer } from "@intlayer/core/interpreter";
|
|
|
11
12
|
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
12
13
|
* over the request locale.
|
|
13
14
|
*
|
|
15
|
+
* `md()` and `html()` nodes render to HTML strings: read `.value`, or call
|
|
16
|
+
* `.use(components)` to override tags, and inject the result with `html.raw`
|
|
17
|
+
* or `innerHTML`.
|
|
18
|
+
*
|
|
14
19
|
* @example
|
|
15
20
|
* ```ts
|
|
16
21
|
* router.get('/', () => {
|
|
@@ -19,11 +24,15 @@ import { getIntlayer } from "@intlayer/core/interpreter";
|
|
|
19
24
|
* });
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
|
-
const useIntlayer = (key, localeOrSelector) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const useIntlayer = (key, localeOrSelector) => {
|
|
28
|
+
const argument = resolveDictionaryArgument({
|
|
29
|
+
localeOrSelector,
|
|
30
|
+
contextLocale: getRequestLocale(),
|
|
31
|
+
dictionaryKey: key
|
|
32
|
+
});
|
|
33
|
+
const { locale } = parseDictionarySelector(argument);
|
|
34
|
+
return getIntlayer(key, argument, getPlugins(locale));
|
|
35
|
+
};
|
|
27
36
|
|
|
28
37
|
//#endregion
|
|
29
38
|
export { useIntlayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../src/useIntlayer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../src/useIntlayer.ts"],"sourcesContent":["import {\n parseDictionarySelector,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport { getIntlayer } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n DictionarySelectorForKey,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\nimport { getRequestLocale } from './requestStorage';\n\n/**\n * Picks one dictionary by its key and returns its content for the locale of\n * the request being handled.\n *\n * The second argument is either a locale or a selector object\n * (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence\n * over the request locale.\n *\n * `md()` and `html()` nodes render to HTML strings: read `.value`, or call\n * `.use(components)` to override tags, and inject the result with `html.raw`\n * or `innerHTML`.\n *\n * @example\n * ```ts\n * router.get('/', () => {\n * const { title } = useIntlayer('home');\n * return new Response(title);\n * });\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n> => {\n const argument = resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: key as string,\n });\n const { locale } = parseDictionarySelector(argument);\n\n return getIntlayer<T, A>(\n key,\n argument as A,\n getPlugins(locale)\n ) as DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n ExtractSelectorLocale<A>\n >;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,eAIX,KACA,qBAIG;CACH,MAAM,WAAW,0BAA0B;EACzC;EACA,eAAe,iBAAiB;EAChC,eAAe;CACjB,CAAC;CACD,MAAM,EAAE,WAAW,wBAAwB,QAAQ;CAEnD,OAAO,YACL,KACA,UACA,WAAW,MAAM,CACnB;AAIF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../src/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { getIntlayerState
|
|
1
|
+
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../src/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { getIntlayerState } from './requestStorage';\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n};\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * Returns the locale of the request being handled, with the configured\n * default and available locales.\n *\n * Falls back to the default locale outside of a request, i.e. when the\n * `intlayer()` middleware did not run.\n *\n * @example\n * ```ts\n * router.get('/', () => {\n * const { locale, availableLocales } = useLocale();\n * return Response.json({ locale, availableLocales });\n * });\n * ```\n */\nexport const useLocale = (): UseLocaleResult => {\n const state = getIntlayerState();\n\n return {\n locale: state?.locale ?? (defaultLocale as DeclaredLocales),\n defaultLocale: state?.defaultLocale ?? (defaultLocale as DeclaredLocales),\n availableLocales:\n state?.availableLocales ?? (availableLocales as DeclaredLocales[]),\n };\n};\n"],"mappings":";;;;AAUA,MAAM,EAAE,eAAe,SAAS,qBAAqB;;;;;;;;;;;;;;;;AAiBrD,MAAa,kBAAmC;CAC9C,MAAM,QAAQ,iBAAiB;CAE/B,OAAO;EACL,QAAQ,OAAO,UAAW;EAC1B,eAAe,OAAO,iBAAkB;EACxC,kBACE,OAAO,oBAAqB;CAChC;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core/interpreter";
|
|
3
|
+
//#region src/plugins.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Plugins applied by the hooks of this package.
|
|
6
|
+
*
|
|
7
|
+
* The base interpreter leaves `md()` and `html()` nodes untouched, so they are
|
|
8
|
+
* handed to the string renderers of `vanilla-intlayer`: the node exposes the
|
|
9
|
+
* rendered HTML as `.value` and `.use(components)` to override tags. Plain
|
|
10
|
+
* strings stay primitives — a `remix/ui` child must be a string, not a wrapper.
|
|
11
|
+
*/
|
|
12
|
+
export type IInterpreterPluginState = IInterpreterPluginState$1 & {
|
|
13
|
+
vanillaMarkdown: true;
|
|
14
|
+
vanillaHtml: true;
|
|
15
|
+
};
|
|
16
|
+
export type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContent$1<T, IInterpreterPluginState, L>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the plugin array for a locale, memoized so the interpreter's
|
|
19
|
+
* transform cache can key on its identity.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getPlugins: (locale?: LocalesValues, fallback?: boolean) => Plugins[];
|
|
22
|
+
//#endregion
|
|
23
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;;;;YAqBY,0BAA0B;EACpC;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DeepTransformContent } from "./plugins.js";
|
|
2
|
+
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
|
|
3
4
|
//#region src/useDictionary.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Transforms an imported dictionary (or qualified dictionary group) and returns
|
|
@@ -9,6 +10,10 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from
|
|
|
9
10
|
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
10
11
|
* over the request locale.
|
|
11
12
|
*
|
|
13
|
+
* `md()` and `html()` nodes render to HTML strings: read `.value`, or call
|
|
14
|
+
* `.use(components)` to override tags, and inject the result with `html.raw`
|
|
15
|
+
* or `innerHTML`.
|
|
16
|
+
*
|
|
12
17
|
* @example
|
|
13
18
|
* ```ts
|
|
14
19
|
* import homeContent from './home.content';
|
|
@@ -19,6 +24,6 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from
|
|
|
19
24
|
* });
|
|
20
25
|
* ```
|
|
21
26
|
*/
|
|
22
|
-
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) =>
|
|
27
|
+
export declare const useDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelectorForGroup<T> = DeclaredLocales>(dictionary: T, localeOrSelector?: A) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, ExtractSelectorLocale<A>>;
|
|
23
28
|
//#endregion
|
|
24
29
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;qBAyCa,sBACL,UAAU,aAAa,gCACvB,UACF,gBACA,2BAA2B,KAAK,iBAAe,YAEvC,GAAC,mBACM,MAClB,qBACD,kCAAkC,GAAG,IACrC,sBAAsB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeepTransformContent } from "./plugins.js";
|
|
2
|
+
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
3
|
//#region src/useIntlayer.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Picks one dictionary by its key and returns its content for the locale of
|
|
@@ -8,6 +9,10 @@ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValue
|
|
|
8
9
|
* (`{ item }`, `{ variant }`, optionally with `locale`); it takes precedence
|
|
9
10
|
* over the request locale.
|
|
10
11
|
*
|
|
12
|
+
* `md()` and `html()` nodes render to HTML strings: read `.value`, or call
|
|
13
|
+
* `.use(components)` to override tags, and inject the result with `html.raw`
|
|
14
|
+
* or `innerHTML`.
|
|
15
|
+
*
|
|
11
16
|
* @example
|
|
12
17
|
* ```ts
|
|
13
18
|
* router.get('/', () => {
|
|
@@ -16,6 +21,6 @@ import { DeclaredLocales, DictionaryKeys, DictionarySelectorForKey, LocalesValue
|
|
|
16
21
|
* });
|
|
17
22
|
* ```
|
|
18
23
|
*/
|
|
19
|
-
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) =>
|
|
24
|
+
export declare const useIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales>(key: T, localeOrSelector?: A) => DeepTransformContent<DictionaryRegistryResult<T, A>, ExtractSelectorLocale<A>>;
|
|
20
25
|
//#endregion
|
|
21
26
|
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../src/useIntlayer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../src/useIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBAoCa,oBACL,UAAU,sBACV,UAAU,gBAAgB,yBAAyB,KAAK,iBAAe,KAExE,GAAC,mBACa,MAClB,qBACD,yBAAyB,GAAG,IAC5B,sBAAsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remix-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Manage internationalization i18n in a simple way for Remix 3 applications.",
|
|
6
6
|
"keywords": [
|
|
@@ -99,14 +99,14 @@
|
|
|
99
99
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@intlayer/config": "9.5.
|
|
103
|
-
"@intlayer/core": "9.5.
|
|
104
|
-
"@intlayer/engine": "9.5.
|
|
105
|
-
"@intlayer/types": "9.5.
|
|
106
|
-
"vanilla-intlayer": "9.5.
|
|
102
|
+
"@intlayer/config": "9.5.5",
|
|
103
|
+
"@intlayer/core": "9.5.5",
|
|
104
|
+
"@intlayer/engine": "9.5.5",
|
|
105
|
+
"@intlayer/types": "9.5.5",
|
|
106
|
+
"vanilla-intlayer": "9.5.5"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
109
|
+
"@intlayer/dictionaries-entry": "9.5.5",
|
|
110
110
|
"@types/node": "^22",
|
|
111
111
|
"@utils/ts-config": "1.0.4",
|
|
112
112
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
-
|
|
4
|
-
//#region src/IntlayerProvider.ts
|
|
5
|
-
/**
|
|
6
|
-
* Remix UI component that publishes the locale to every descendant component,
|
|
7
|
-
* so the hooks of this package can read it from their `Handle`.
|
|
8
|
-
*
|
|
9
|
-
* Nested providers shadow outer ones, following the Remix UI context rules.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* router.get('/', (context) =>
|
|
14
|
-
* context.render(
|
|
15
|
-
* <IntlayerProvider locale={context.intlayer.locale}>
|
|
16
|
-
* <HomePage />
|
|
17
|
-
* </IntlayerProvider>
|
|
18
|
-
* )
|
|
19
|
-
* );
|
|
20
|
-
*
|
|
21
|
-
* function HomePage(handle: Handle) {
|
|
22
|
-
* const { title } = useIntlayer('home', handle);
|
|
23
|
-
* return () => <h1>{title}</h1>;
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
const IntlayerProvider = (handle) => {
|
|
28
|
-
return () => {
|
|
29
|
-
handle.context.set({ locale: handle.props.locale ?? _intlayer_config_built.internationalization.defaultLocale });
|
|
30
|
-
return handle.props.children;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
exports.IntlayerProvider = IntlayerProvider;
|
|
36
|
-
//# sourceMappingURL=IntlayerProvider.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.cjs","names":["internationalization"],"sources":["../../src/IntlayerProvider.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { Handle, RemixNode } from 'remix/ui';\n\nexport type IntlayerProviderProps = {\n /** Locale to render the subtree with. Defaults to the configured default locale. */\n locale?: LocalesValues;\n children?: RemixNode;\n};\n\n/**\n * Context value published by {@link IntlayerProvider} to its descendants.\n */\nexport type IntlayerProviderContext = {\n locale: DeclaredLocales;\n};\n\n/**\n * Remix UI component that publishes the locale to every descendant component,\n * so the hooks of this package can read it from their `Handle`.\n *\n * Nested providers shadow outer ones, following the Remix UI context rules.\n *\n * @example\n * ```tsx\n * router.get('/', (context) =>\n * context.render(\n * <IntlayerProvider locale={context.intlayer.locale}>\n * <HomePage />\n * </IntlayerProvider>\n * )\n * );\n *\n * function HomePage(handle: Handle) {\n * const { title } = useIntlayer('home', handle);\n * return () => <h1>{title}</h1>;\n * }\n * ```\n */\nexport const IntlayerProvider = (\n handle: Handle<IntlayerProviderProps, IntlayerProviderContext>\n): (() => RemixNode) => {\n // Published from the render function so a later `locale` prop change is\n // visible to the descendants rendered right after.\n return () => {\n handle.context.set({\n locale: (handle.props.locale ??\n internationalization.defaultLocale) as DeclaredLocales,\n });\n\n return handle.props.children;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,oBACX,WACsB;CAGtB,aAAa;EACX,OAAO,QAAQ,IAAI,EACjB,QAAS,OAAO,MAAM,UACpBA,4CAAqB,cACzB,CAAC;EAED,OAAO,OAAO,MAAM;CACtB;AACF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
3
|
-
const require_middleware = require('./middleware.cjs');
|
|
4
|
-
|
|
5
|
-
//#region src/resolveLocale.ts
|
|
6
|
-
/**
|
|
7
|
-
* A component `Handle` carries its context store under `context`, whereas a
|
|
8
|
-
* `RequestContext` exposes `get`/`set` directly.
|
|
9
|
-
*/
|
|
10
|
-
const isHandle = (source) => "context" in source && typeof source.context?.get === "function";
|
|
11
|
-
/**
|
|
12
|
-
* Reads the locale published to the given source, if any.
|
|
13
|
-
*/
|
|
14
|
-
const resolveLocale = (source) => {
|
|
15
|
-
if (isHandle(source)) return source.context.get(require_IntlayerProvider.IntlayerProvider)?.locale;
|
|
16
|
-
return source.get(require_middleware.Intlayer)?.locale;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.resolveLocale = resolveLocale;
|
|
21
|
-
//# sourceMappingURL=resolveLocale.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocale.cjs","names":["IntlayerProvider","Intlayer"],"sources":["../../src/resolveLocale.ts"],"sourcesContent":["import type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport type { RequestContext } from 'remix/router';\nimport type { Handle } from 'remix/ui';\nimport { IntlayerProvider } from './IntlayerProvider';\nimport { Intlayer, type IntlayerState } from './middleware';\n\n/**\n * Where a hook reads the current locale from:\n * - a Remix router `RequestContext`, populated by the `intlayer()` middleware\n * - a Remix UI component `Handle`, populated by an ancestor `IntlayerProvider`\n */\nexport type IntlayerSource = RequestContext<any, any> | Handle<any, any>;\n\n/**\n * A component `Handle` carries its context store under `context`, whereas a\n * `RequestContext` exposes `get`/`set` directly.\n */\nconst isHandle = (source: IntlayerSource): source is Handle<any, any> =>\n 'context' in source &&\n typeof (source as Handle<any, any>).context?.get === 'function';\n\n/**\n * Reads the locale published to the given source, if any.\n */\nexport const resolveLocale = (\n source: IntlayerSource\n): DeclaredLocales | undefined => {\n if (isHandle(source)) {\n return source.context.get(IntlayerProvider)?.locale;\n }\n\n return (source.get(Intlayer) as IntlayerState | undefined)?.locale;\n};\n"],"mappings":";;;;;;;;;AAiBA,MAAM,YAAY,WAChB,aAAa,UACb,OAAQ,OAA4B,SAAS,QAAQ;;;;AAKvD,MAAa,iBACX,WACgC;CAChC,IAAI,SAAS,MAAM,GACjB,OAAO,OAAO,QAAQ,IAAIA,yCAAgB,CAAC,EAAE;CAG/C,OAAQ,OAAO,IAAIC,2BAAQ,CAAC,EAAgC;AAC9D"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { internationalization } from "@intlayer/config/built";
|
|
2
|
-
|
|
3
|
-
//#region src/IntlayerProvider.ts
|
|
4
|
-
/**
|
|
5
|
-
* Remix UI component that publishes the locale to every descendant component,
|
|
6
|
-
* so the hooks of this package can read it from their `Handle`.
|
|
7
|
-
*
|
|
8
|
-
* Nested providers shadow outer ones, following the Remix UI context rules.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* router.get('/', (context) =>
|
|
13
|
-
* context.render(
|
|
14
|
-
* <IntlayerProvider locale={context.intlayer.locale}>
|
|
15
|
-
* <HomePage />
|
|
16
|
-
* </IntlayerProvider>
|
|
17
|
-
* )
|
|
18
|
-
* );
|
|
19
|
-
*
|
|
20
|
-
* function HomePage(handle: Handle) {
|
|
21
|
-
* const { title } = useIntlayer('home', handle);
|
|
22
|
-
* return () => <h1>{title}</h1>;
|
|
23
|
-
* }
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
const IntlayerProvider = (handle) => {
|
|
27
|
-
return () => {
|
|
28
|
-
handle.context.set({ locale: handle.props.locale ?? internationalization.defaultLocale });
|
|
29
|
-
return handle.props.children;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
export { IntlayerProvider };
|
|
35
|
-
//# sourceMappingURL=IntlayerProvider.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.mjs","names":[],"sources":["../../src/IntlayerProvider.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { Handle, RemixNode } from 'remix/ui';\n\nexport type IntlayerProviderProps = {\n /** Locale to render the subtree with. Defaults to the configured default locale. */\n locale?: LocalesValues;\n children?: RemixNode;\n};\n\n/**\n * Context value published by {@link IntlayerProvider} to its descendants.\n */\nexport type IntlayerProviderContext = {\n locale: DeclaredLocales;\n};\n\n/**\n * Remix UI component that publishes the locale to every descendant component,\n * so the hooks of this package can read it from their `Handle`.\n *\n * Nested providers shadow outer ones, following the Remix UI context rules.\n *\n * @example\n * ```tsx\n * router.get('/', (context) =>\n * context.render(\n * <IntlayerProvider locale={context.intlayer.locale}>\n * <HomePage />\n * </IntlayerProvider>\n * )\n * );\n *\n * function HomePage(handle: Handle) {\n * const { title } = useIntlayer('home', handle);\n * return () => <h1>{title}</h1>;\n * }\n * ```\n */\nexport const IntlayerProvider = (\n handle: Handle<IntlayerProviderProps, IntlayerProviderContext>\n): (() => RemixNode) => {\n // Published from the render function so a later `locale` prop change is\n // visible to the descendants rendered right after.\n return () => {\n handle.context.set({\n locale: (handle.props.locale ??\n internationalization.defaultLocale) as DeclaredLocales,\n });\n\n return handle.props.children;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAa,oBACX,WACsB;CAGtB,aAAa;EACX,OAAO,QAAQ,IAAI,EACjB,QAAS,OAAO,MAAM,UACpB,qBAAqB,cACzB,CAAC;EAED,OAAO,OAAO,MAAM;CACtB;AACF"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IntlayerProvider } from "./IntlayerProvider.mjs";
|
|
2
|
-
import { Intlayer } from "./middleware.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/resolveLocale.ts
|
|
5
|
-
/**
|
|
6
|
-
* A component `Handle` carries its context store under `context`, whereas a
|
|
7
|
-
* `RequestContext` exposes `get`/`set` directly.
|
|
8
|
-
*/
|
|
9
|
-
const isHandle = (source) => "context" in source && typeof source.context?.get === "function";
|
|
10
|
-
/**
|
|
11
|
-
* Reads the locale published to the given source, if any.
|
|
12
|
-
*/
|
|
13
|
-
const resolveLocale = (source) => {
|
|
14
|
-
if (isHandle(source)) return source.context.get(IntlayerProvider)?.locale;
|
|
15
|
-
return source.get(Intlayer)?.locale;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { resolveLocale };
|
|
20
|
-
//# sourceMappingURL=resolveLocale.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocale.mjs","names":[],"sources":["../../src/resolveLocale.ts"],"sourcesContent":["import type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport type { RequestContext } from 'remix/router';\nimport type { Handle } from 'remix/ui';\nimport { IntlayerProvider } from './IntlayerProvider';\nimport { Intlayer, type IntlayerState } from './middleware';\n\n/**\n * Where a hook reads the current locale from:\n * - a Remix router `RequestContext`, populated by the `intlayer()` middleware\n * - a Remix UI component `Handle`, populated by an ancestor `IntlayerProvider`\n */\nexport type IntlayerSource = RequestContext<any, any> | Handle<any, any>;\n\n/**\n * A component `Handle` carries its context store under `context`, whereas a\n * `RequestContext` exposes `get`/`set` directly.\n */\nconst isHandle = (source: IntlayerSource): source is Handle<any, any> =>\n 'context' in source &&\n typeof (source as Handle<any, any>).context?.get === 'function';\n\n/**\n * Reads the locale published to the given source, if any.\n */\nexport const resolveLocale = (\n source: IntlayerSource\n): DeclaredLocales | undefined => {\n if (isHandle(source)) {\n return source.context.get(IntlayerProvider)?.locale;\n }\n\n return (source.get(Intlayer) as IntlayerState | undefined)?.locale;\n};\n"],"mappings":";;;;;;;;AAiBA,MAAM,YAAY,WAChB,aAAa,UACb,OAAQ,OAA4B,SAAS,QAAQ;;;;AAKvD,MAAa,iBACX,WACgC;CAChC,IAAI,SAAS,MAAM,GACjB,OAAO,OAAO,QAAQ,IAAI,gBAAgB,CAAC,EAAE;CAG/C,OAAQ,OAAO,IAAI,QAAQ,CAAC,EAAgC;AAC9D"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Handle, RemixNode } from "remix/ui";
|
|
3
|
-
//#region src/IntlayerProvider.d.ts
|
|
4
|
-
export type IntlayerProviderProps = {
|
|
5
|
-
/** Locale to render the subtree with. Defaults to the configured default locale. */
|
|
6
|
-
locale?: LocalesValues;
|
|
7
|
-
children?: RemixNode;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Context value published by {@link IntlayerProvider} to its descendants.
|
|
11
|
-
*/
|
|
12
|
-
export type IntlayerProviderContext = {
|
|
13
|
-
locale: DeclaredLocales;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Remix UI component that publishes the locale to every descendant component,
|
|
17
|
-
* so the hooks of this package can read it from their `Handle`.
|
|
18
|
-
*
|
|
19
|
-
* Nested providers shadow outer ones, following the Remix UI context rules.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* router.get('/', (context) =>
|
|
24
|
-
* context.render(
|
|
25
|
-
* <IntlayerProvider locale={context.intlayer.locale}>
|
|
26
|
-
* <HomePage />
|
|
27
|
-
* </IntlayerProvider>
|
|
28
|
-
* )
|
|
29
|
-
* );
|
|
30
|
-
*
|
|
31
|
-
* function HomePage(handle: Handle) {
|
|
32
|
-
* const { title } = useIntlayer('home', handle);
|
|
33
|
-
* return () => <h1>{title}</h1>;
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const IntlayerProvider: (handle: Handle<IntlayerProviderProps, IntlayerProviderContext>) => (() => RemixNode);
|
|
38
|
-
//#endregion
|
|
39
|
-
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../src/IntlayerProvider.ts"],"mappings":";;;YAOY;;EAEV,SAAS;EACT,WAAW;;;;;YAMD;EACV,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;qBAyBG,mBAAgB,QACnB,OAAO,uBAAuB,oCAC9B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Handle } from "remix/ui";
|
|
3
|
-
import { RequestContext } from "remix/router";
|
|
4
|
-
//#region src/resolveLocale.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Where a hook reads the current locale from:
|
|
7
|
-
* - a Remix router `RequestContext`, populated by the `intlayer()` middleware
|
|
8
|
-
* - a Remix UI component `Handle`, populated by an ancestor `IntlayerProvider`
|
|
9
|
-
*/
|
|
10
|
-
export type IntlayerSource = RequestContext<any, any> | Handle<any, any>;
|
|
11
|
-
/**
|
|
12
|
-
* Reads the locale published to the given source, if any.
|
|
13
|
-
*/
|
|
14
|
-
export declare const resolveLocale: (source: IntlayerSource) => DeclaredLocales | undefined;
|
|
15
|
-
//#endregion
|
|
16
|
-
//# sourceMappingURL=resolveLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocale.d.ts","names":[],"sources":["../../src/resolveLocale.ts"],"mappings":";;;;;;;;;YAWY,iBAAiB,2BAA2B;;;;qBAa3C,gBAAa,QAChB,mBACP"}
|