remix-intlayer 9.5.9 → 9.5.10
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/plugins.cjs +1 -1
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/useDictionary.cjs +3 -3
- package/dist/cjs/useDictionary.cjs.map +1 -1
- package/dist/cjs/useIntlayer.cjs +3 -3
- package/dist/cjs/useIntlayer.cjs.map +1 -1
- package/dist/esm/plugins.mjs +2 -2
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/useDictionary.mjs +3 -3
- package/dist/esm/useDictionary.mjs.map +1 -1
- package/dist/esm/useIntlayer.mjs +3 -3
- package/dist/esm/useIntlayer.mjs.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -17,7 +17,7 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
17
17
|
...(0, _intlayer_core_interpreter.getBasePlugins)(locale, fallback),
|
|
18
18
|
vanilla_intlayer.markdownPlugin,
|
|
19
19
|
vanilla_intlayer.htmlPlugin
|
|
20
|
-
];
|
|
20
|
+
].filter((plugin) => plugin !== _intlayer_core_interpreter.fallbackPlugin);
|
|
21
21
|
pluginsCache.set(cacheKey, plugins);
|
|
22
22
|
return plugins;
|
|
23
23
|
};
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +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":";;;;;;
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["internationalization","getBasePlugins","markdownPlugin","htmlPlugin","fallbackPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n type DeepTransformContent as DeepTransformContentCore,\n fallbackPlugin,\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 ].filter(\n // Plugins disabled at build time never match: skip them on every node\n (plugin) => plugin !== fallbackPlugin\n );\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;AAgCA,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,CAAC,CAAC,QAEC,WAAW,WAAWC,yCACzB;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -28,12 +28,12 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
const useDictionary = (dictionary, localeOrSelector) => {
|
|
31
|
-
const argument = (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
31
|
+
const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
32
32
|
localeOrSelector,
|
|
33
33
|
contextLocale: require_requestStorage.getRequestLocale(),
|
|
34
34
|
dictionaryKey: dictionary.key
|
|
35
|
-
});
|
|
36
|
-
const
|
|
35
|
+
}) : localeOrSelector ?? require_requestStorage.getRequestLocale();
|
|
36
|
+
const locale = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(argument).locale : argument;
|
|
37
37
|
return (0, _intlayer_core_interpreter.getDictionary)(dictionary, argument, require_plugins.getPlugins(locale));
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the selector resolution is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? getRequestLocale());\n const locale =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector(argument).locale\n : (argument as LocalesValues | undefined);\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;CAGH,MAAM,WACJ,QAAQ,IAAI,iCAAiC,cACzCA,gEAA0B;EACxB;EACA,eAAeC,wCAAiB;EAChC,eAAe,WAAW;CAC5B,CAAC,IACA,oBAAoBA,wCAAiB;CAC5C,MAAM,SACJ,QAAQ,IAAI,iCAAiC,cACzCC,8DAAwB,QAAQ,CAAC,CAAC,SACjC;CAEP,WAAOC,0CACL,YACA,UACAC,2BAAW,MAAM,CACnB;AAIF"}
|
package/dist/cjs/useIntlayer.cjs
CHANGED
|
@@ -26,12 +26,12 @@ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
const useIntlayer = (key, localeOrSelector) => {
|
|
29
|
-
const argument = (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
29
|
+
const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
|
|
30
30
|
localeOrSelector,
|
|
31
31
|
contextLocale: require_requestStorage.getRequestLocale(),
|
|
32
32
|
dictionaryKey: key
|
|
33
|
-
});
|
|
34
|
-
const
|
|
33
|
+
}) : localeOrSelector ?? require_requestStorage.getRequestLocale();
|
|
34
|
+
const locale = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)(argument).locale : argument;
|
|
35
35
|
return (0, _intlayer_core_interpreter.getIntlayer)(key, argument, require_plugins.getPlugins(locale));
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the selector resolution is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: key as string,\n })\n : (localeOrSelector ?? getRequestLocale());\n const locale =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector(argument).locale\n : (argument as LocalesValues | undefined);\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;CAGH,MAAM,WACJ,QAAQ,IAAI,iCAAiC,cACzCA,gEAA0B;EACxB;EACA,eAAeC,wCAAiB;EAChC,eAAe;CACjB,CAAC,IACA,oBAAoBA,wCAAiB;CAC5C,MAAM,SACJ,QAAQ,IAAI,iCAAiC,cACzCC,8DAAwB,QAAQ,CAAC,CAAC,SACjC;CAEP,WAAOC,wCACL,KACA,UACAC,2BAAW,MAAM,CACnB;AAIF"}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { internationalization } from "@intlayer/config/built";
|
|
2
|
-
import { getBasePlugins } from "@intlayer/core/interpreter";
|
|
2
|
+
import { fallbackPlugin, getBasePlugins } from "@intlayer/core/interpreter";
|
|
3
3
|
import { htmlPlugin, markdownPlugin } from "vanilla-intlayer";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins.ts
|
|
@@ -16,7 +16,7 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
16
16
|
...getBasePlugins(locale, fallback),
|
|
17
17
|
markdownPlugin,
|
|
18
18
|
htmlPlugin
|
|
19
|
-
];
|
|
19
|
+
].filter((plugin) => plugin !== fallbackPlugin);
|
|
20
20
|
pluginsCache.set(cacheKey, plugins);
|
|
21
21
|
return plugins;
|
|
22
22
|
};
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +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":";;;;;
|
|
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 fallbackPlugin,\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 ].filter(\n // Plugins disabled at build time never match: skip them on every node\n (plugin) => plugin !== fallbackPlugin\n );\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;AAgCA,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,CAAC,CAAC,QAEC,WAAW,WAAW,cACzB;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -27,12 +27,12 @@ import { getDictionary } from "@intlayer/core/interpreter";
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
const useDictionary = (dictionary, localeOrSelector) => {
|
|
30
|
-
const argument = resolveDictionaryArgument({
|
|
30
|
+
const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? resolveDictionaryArgument({
|
|
31
31
|
localeOrSelector,
|
|
32
32
|
contextLocale: getRequestLocale(),
|
|
33
33
|
dictionaryKey: dictionary.key
|
|
34
|
-
});
|
|
35
|
-
const
|
|
34
|
+
}) : localeOrSelector ?? getRequestLocale();
|
|
35
|
+
const locale = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(argument).locale : argument;
|
|
36
36
|
return getDictionary(dictionary, argument, getPlugins(locale));
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the selector resolution is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? getRequestLocale());\n const locale =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector(argument).locale\n : (argument as LocalesValues | undefined);\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;CAGH,MAAM,WACJ,QAAQ,IAAI,iCAAiC,UACzC,0BAA0B;EACxB;EACA,eAAe,iBAAiB;EAChC,eAAe,WAAW;CAC5B,CAAC,IACA,oBAAoB,iBAAiB;CAC5C,MAAM,SACJ,QAAQ,IAAI,iCAAiC,UACzC,wBAAwB,QAAQ,CAAC,CAAC,SACjC;CAEP,OAAO,cACL,YACA,UACA,WAAW,MAAM,CACnB;AAIF"}
|
package/dist/esm/useIntlayer.mjs
CHANGED
|
@@ -25,12 +25,12 @@ import { getIntlayer } from "@intlayer/core/interpreter";
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
const useIntlayer = (key, localeOrSelector) => {
|
|
28
|
-
const argument = resolveDictionaryArgument({
|
|
28
|
+
const argument = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? resolveDictionaryArgument({
|
|
29
29
|
localeOrSelector,
|
|
30
30
|
contextLocale: getRequestLocale(),
|
|
31
31
|
dictionaryKey: key
|
|
32
|
-
});
|
|
33
|
-
const
|
|
32
|
+
}) : localeOrSelector ?? getRequestLocale();
|
|
33
|
+
const locale = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? parseDictionarySelector(argument).locale : argument;
|
|
34
34
|
return getIntlayer(key, argument, getPlugins(locale));
|
|
35
35
|
};
|
|
36
36
|
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the selector resolution is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: getRequestLocale(),\n dictionaryKey: key as string,\n })\n : (localeOrSelector ?? getRequestLocale());\n const locale =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector(argument).locale\n : (argument as LocalesValues | undefined);\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;CAGH,MAAM,WACJ,QAAQ,IAAI,iCAAiC,UACzC,0BAA0B;EACxB;EACA,eAAe,iBAAiB;EAChC,eAAe;CACjB,CAAC,IACA,oBAAoB,iBAAiB;CAC5C,MAAM,SACJ,QAAQ,IAAI,iCAAiC,UACzC,wBAAwB,QAAQ,CAAC,CAAC,SACjC;CAEP,OAAO,YACL,KACA,UACA,WAAW,MAAM,CACnB;AAIF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;;;;YAsBY,0BAA0B;EACpC;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remix-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.10",
|
|
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.10",
|
|
103
|
+
"@intlayer/core": "9.5.10",
|
|
104
|
+
"@intlayer/engine": "9.5.10",
|
|
105
|
+
"@intlayer/types": "9.5.10",
|
|
106
|
+
"vanilla-intlayer": "9.5.10"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
109
|
+
"@intlayer/dictionaries-entry": "9.5.10",
|
|
110
110
|
"@types/node": "^22",
|
|
111
111
|
"@utils/ts-config": "1.0.4",
|
|
112
112
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"rimraf": "6.1.3",
|
|
116
116
|
"tsdown": "0.23.0",
|
|
117
117
|
"typescript": "7.0.2",
|
|
118
|
-
"vitest": "5.0.
|
|
118
|
+
"vitest": "5.0.2"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"remix": ">=3.0.0-rc.0"
|