remix-intlayer 9.7.0 → 9.7.2
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/context.cjs +1 -2
- package/dist/cjs/format/index.cjs +9 -9
- package/dist/cjs/format/useCompact.cjs +2 -3
- package/dist/cjs/format/useCurrency.cjs +2 -3
- package/dist/cjs/format/useDate.cjs +2 -3
- package/dist/cjs/format/useIntl.cjs +2 -3
- package/dist/cjs/format/useList.cjs +2 -3
- package/dist/cjs/format/useNumber.cjs +2 -3
- package/dist/cjs/format/usePercentage.cjs +2 -3
- package/dist/cjs/format/useRelativeTime.cjs +2 -3
- package/dist/cjs/format/useUnit.cjs +2 -3
- package/dist/cjs/html/index.cjs +5 -5
- package/dist/cjs/index.cjs +7 -7
- package/dist/cjs/localeRouting.cjs +3 -4
- package/dist/cjs/markdown/index.cjs +7 -7
- package/dist/cjs/middleware.cjs +6 -7
- package/dist/cjs/persistLocale.cjs +1 -2
- package/dist/cjs/plugins.cjs +2 -3
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/requestStorage.cjs +2 -3
- package/dist/cjs/useDictionary.cjs +3 -4
- package/dist/cjs/useDictionary.cjs.map +1 -1
- package/dist/cjs/useIntlayer.cjs +3 -4
- package/dist/cjs/useLocale.cjs +2 -3
- package/dist/esm/context.mjs +1 -2
- package/dist/esm/format/index.mjs +5 -5
- package/dist/esm/format/useCompact.mjs +1 -2
- package/dist/esm/format/useCurrency.mjs +1 -2
- package/dist/esm/format/useDate.mjs +1 -2
- package/dist/esm/format/useIntl.mjs +1 -2
- package/dist/esm/format/useList.mjs +1 -2
- package/dist/esm/format/useNumber.mjs +1 -2
- package/dist/esm/format/usePercentage.mjs +1 -2
- package/dist/esm/format/useRelativeTime.mjs +1 -2
- package/dist/esm/format/useUnit.mjs +1 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/localeRouting.mjs +3 -4
- package/dist/esm/middleware.mjs +3 -4
- package/dist/esm/persistLocale.mjs +1 -2
- package/dist/esm/plugins.mjs +2 -3
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/requestStorage.mjs +1 -2
- package/dist/esm/useDictionary.mjs +2 -3
- package/dist/esm/useDictionary.mjs.map +1 -1
- package/dist/esm/useIntlayer.mjs +2 -3
- package/dist/esm/useLocale.mjs +1 -2
- package/dist/types/context.d.ts +0 -2
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +0 -2
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +0 -2
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts +0 -2
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useIntl.d.ts +0 -2
- package/dist/types/format/useIntl.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +0 -2
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +0 -2
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +0 -2
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +0 -2
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +0 -2
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/localeRouting.d.ts +0 -2
- package/dist/types/localeRouting.d.ts.map +1 -1
- package/dist/types/middleware.d.ts +0 -2
- package/dist/types/middleware.d.ts.map +1 -1
- package/dist/types/persistLocale.d.ts +0 -2
- package/dist/types/persistLocale.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +1 -3
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/requestStorage.d.ts +1 -3
- package/dist/types/requestStorage.d.ts.map +1 -1
- package/dist/types/useDictionary.d.ts +0 -2
- package/dist/types/useDictionary.d.ts.map +1 -1
- package/dist/types/useIntlayer.d.ts +0 -2
- package/dist/types/useIntlayer.d.ts.map +1 -1
- package/dist/types/useLocale.d.ts +0 -2
- package/dist/types/useLocale.d.ts.map +1 -1
- package/package.json +47 -47
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { number } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useNumber.ts
|
|
5
5
|
/**
|
|
6
6
|
* Remix hook that provides a localized number formatter bound to the request locale.
|
|
7
7
|
*/
|
|
@@ -13,6 +13,5 @@ const useNumber = () => {
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
export { useNumber };
|
|
18
17
|
//# sourceMappingURL=useNumber.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { percentage } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/usePercentage.ts
|
|
5
5
|
const usePercentage = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => percentage(args[0], {
|
|
@@ -10,6 +10,5 @@ const usePercentage = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { usePercentage };
|
|
15
14
|
//# sourceMappingURL=usePercentage.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { relativeTime } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useRelativeTime.ts
|
|
5
5
|
const useRelativeTime = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => relativeTime(args[0], args[1], {
|
|
@@ -10,6 +10,5 @@ const useRelativeTime = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useRelativeTime };
|
|
15
14
|
//# sourceMappingURL=useRelativeTime.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getRequestLocale } from "../requestStorage.mjs";
|
|
2
2
|
import { units } from "@intlayer/core/formatters";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/format/useUnit.ts
|
|
5
5
|
const useUnit = () => {
|
|
6
6
|
const locale = getRequestLocale();
|
|
7
7
|
return (...args) => units(args[0], {
|
|
@@ -10,6 +10,5 @@ const useUnit = () => {
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { useUnit };
|
|
15
14
|
//# sourceMappingURL=useUnit.mjs.map
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { INTLAYER_CONTEXT_PROPERTY, Intlayer } from "./context.mjs";
|
|
2
2
|
import { createLocaleRouting } from "./localeRouting.mjs";
|
|
3
|
-
import { getIntlayerState } from "./requestStorage.mjs";
|
|
4
3
|
import { intlayer } from "./middleware.mjs";
|
|
4
|
+
import { getIntlayerState } from "./requestStorage.mjs";
|
|
5
|
+
import { useDictionary } from "./useDictionary.mjs";
|
|
5
6
|
import { useIntlayer } from "./useIntlayer.mjs";
|
|
6
7
|
import { useLocale } from "./useLocale.mjs";
|
|
7
|
-
import { useDictionary } from "./useDictionary.mjs";
|
|
8
8
|
|
|
9
9
|
export { INTLAYER_CONTEXT_PROPERTY, Intlayer, createLocaleRouting, getIntlayerState, intlayer, useDictionary, useIntlayer, useLocale };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getCookie, getLocaleFromStorageServer } from "@intlayer/core/utils";
|
|
2
|
-
import { getCanonicalPath, getDomainHostname, getDomainOrigin, getLocaleFromDomain, getRewriteRules, isProxyStorageLocaleEnabled, localeDetector, resolveLocalizedPath, resolveProxyMode } from "@intlayer/core/localization";
|
|
3
1
|
import { ROUTING_MODE } from "@intlayer/config/defaultValues";
|
|
2
|
+
import { getCanonicalPath, getDomainHostname, getDomainOrigin, getLocaleFromDomain, getRewriteRules, isProxyStorageLocaleEnabled, localeDetector, resolveLocalizedPath, resolveProxyMode } from "@intlayer/core/localization";
|
|
3
|
+
import { getCookie, getLocaleFromStorageServer } from "@intlayer/core/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/localeRouting.ts
|
|
6
6
|
/** Matches a pathname ending with a file extension (`/logo.svg`). */
|
|
7
7
|
const STATIC_ASSET_PATTERN = /\.[a-zA-Z0-9]+$/;
|
|
8
8
|
const PASS = { kind: "pass" };
|
|
@@ -205,6 +205,5 @@ const createLocaleRouting = (configuration, options = {}) => {
|
|
|
205
205
|
};
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
//#endregion
|
|
209
208
|
export { createLocaleRouting };
|
|
210
209
|
//# sourceMappingURL=localeRouting.mjs.map
|
package/dist/esm/middleware.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { INTLAYER_CONTEXT_PROPERTY, Intlayer } from "./context.mjs";
|
|
2
|
-
import { withLocaleHeaders, writeLocaleHeaders } from "./persistLocale.mjs";
|
|
3
2
|
import { createLocaleRouting } from "./localeRouting.mjs";
|
|
3
|
+
import { withLocaleHeaders, writeLocaleHeaders } from "./persistLocale.mjs";
|
|
4
4
|
import { requestStorage } from "./requestStorage.mjs";
|
|
5
5
|
import { internationalization, routing } from "@intlayer/config/built";
|
|
6
|
-
import { getConfiguration } from "@intlayer/config/node";
|
|
7
6
|
import { getLocaleFromRequest } from "@intlayer/core/localization";
|
|
7
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
8
8
|
import { prepareIntlayerServer } from "@intlayer/engine/build";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/middleware.ts
|
|
11
11
|
/**
|
|
12
12
|
* Builds the redirect response of a locale-routing decision.
|
|
13
13
|
*
|
|
@@ -86,6 +86,5 @@ const intlayer = (options = {}) => {
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
//#endregion
|
|
90
89
|
export { intlayer };
|
|
91
90
|
//# sourceMappingURL=middleware.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setLocaleInStorageServer } from "@intlayer/core/utils";
|
|
2
2
|
import { SetCookie } from "remix/headers";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/persistLocale.ts
|
|
5
5
|
/**
|
|
6
6
|
* Serializes a locale cookie as a `Set-Cookie` header value.
|
|
7
7
|
*/
|
|
@@ -44,6 +44,5 @@ const withLocaleHeaders = (response, locale) => {
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
//#endregion
|
|
48
47
|
export { withLocaleHeaders, writeLocaleHeaders };
|
|
49
48
|
//# sourceMappingURL=persistLocale.mjs.map
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { internationalization } from "@intlayer/config/built";
|
|
2
1
|
import { fallbackPlugin, getBasePlugins } from "@intlayer/core/interpreter";
|
|
2
|
+
import { internationalization } from "@intlayer/config/built";
|
|
3
3
|
import { htmlPlugin, markdownPlugin } from "vanilla-intlayer";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/plugins.ts
|
|
6
6
|
const pluginsCache = /* @__PURE__ */ new Map();
|
|
7
7
|
/**
|
|
8
8
|
* Returns the plugin array for a locale, memoized so the interpreter's
|
|
@@ -21,6 +21,5 @@ const getPlugins = (locale, fallback = true) => {
|
|
|
21
21
|
return plugins;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
//#endregion
|
|
25
24
|
export { getPlugins };
|
|
26
25
|
//# sourceMappingURL=plugins.mjs.map
|
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 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/
|
|
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/component` 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"}
|
|
@@ -2,7 +2,7 @@ import { Intlayer } from "./context.mjs";
|
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import { registerAmbientLocaleResolver } from "@intlayer/core/interpreter";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/requestStorage.ts
|
|
6
6
|
/**
|
|
7
7
|
* Request context of the request being handled, made available to every
|
|
8
8
|
* function running inside the `intlayer()` middleware scope — route handlers,
|
|
@@ -19,6 +19,5 @@ const getIntlayerState = () => requestStorage.getStore()?.get(Intlayer);
|
|
|
19
19
|
const getRequestLocale = () => getIntlayerState()?.locale;
|
|
20
20
|
registerAmbientLocaleResolver(getRequestLocale);
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
export { getIntlayerState, getRequestLocale, requestStorage };
|
|
24
23
|
//# sourceMappingURL=requestStorage.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getRequestLocale } from "./requestStorage.mjs";
|
|
2
1
|
import { getPlugins } from "./plugins.mjs";
|
|
2
|
+
import { getRequestLocale } from "./requestStorage.mjs";
|
|
3
3
|
import { getDictionary } from "@intlayer/core/interpreter";
|
|
4
4
|
import { parseDictionarySelector, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useDictionary.ts
|
|
7
7
|
/**
|
|
8
8
|
* Transforms an imported dictionary (or qualified dictionary group) and returns
|
|
9
9
|
* its content for the locale of the request being handled.
|
|
@@ -36,6 +36,5 @@ const useDictionary = (dictionary, localeOrSelector) => {
|
|
|
36
36
|
return getDictionary(dictionary, argument, getPlugins(locale));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
export { useDictionary };
|
|
41
40
|
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -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
|
|
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 LocalesValues | DictionarySelectorForGroup<T> =\n 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,iBAKX,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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getRequestLocale } from "./requestStorage.mjs";
|
|
2
1
|
import { getPlugins } from "./plugins.mjs";
|
|
2
|
+
import { getRequestLocale } from "./requestStorage.mjs";
|
|
3
3
|
import { getIntlayer } from "@intlayer/core/interpreter";
|
|
4
4
|
import { parseDictionarySelector, resolveDictionaryArgument } from "@intlayer/core/dictionaryManipulator";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useIntlayer.ts
|
|
7
7
|
/**
|
|
8
8
|
* Picks one dictionary by its key and returns its content for the locale of
|
|
9
9
|
* the request being handled.
|
|
@@ -34,6 +34,5 @@ const useIntlayer = (key, localeOrSelector) => {
|
|
|
34
34
|
return getIntlayer(key, argument, getPlugins(locale));
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
//#endregion
|
|
38
37
|
export { useIntlayer };
|
|
39
38
|
//# sourceMappingURL=useIntlayer.mjs.map
|
package/dist/esm/useLocale.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getIntlayerState } from "./requestStorage.mjs";
|
|
2
2
|
import { internationalization } from "@intlayer/config/built";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useLocale.ts
|
|
5
5
|
const { defaultLocale, locales: availableLocales } = internationalization;
|
|
6
6
|
/**
|
|
7
7
|
* Returns the locale of the request being handled, with the configured
|
|
@@ -27,6 +27,5 @@ const useLocale = () => {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
//#endregion
|
|
31
30
|
export { useLocale };
|
|
32
31
|
//# sourceMappingURL=useLocale.mjs.map
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
|
-
//#region src/context.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Intlayer state attached to the Remix `RequestContext` by the {@link intlayer} middleware.
|
|
5
4
|
*/
|
|
@@ -27,5 +26,4 @@ export declare const Intlayer: {
|
|
|
27
26
|
* so `context.intlayer` mirrors `context.get(Intlayer)`.
|
|
28
27
|
*/
|
|
29
28
|
export declare const INTLAYER_CONTEXT_PROPERTY = "intlayer";
|
|
30
|
-
//#endregion
|
|
31
29
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","names":[],"sources":["../../src/context.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../../src/context.ts"],"mappings":";;;;YAMY;;EAEV,QAAQ;;EAER,eAAe;;EAEf,kBAAkB;;;;;;;;;;qBAWP;EAAY,eAAe;;;;;;qBAO3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../src/format/useCompact.ts"],"mappings":";qBAGa,sBAAU,MAGJ,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../src/format/useCurrency.ts"],"mappings":";qBAGa,uBAAW,MAGL,kBAAkB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { date } from "@intlayer/core/formatters";
|
|
2
|
-
//#region src/format/useDate.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Remix hook that provides a localized date/time formatter bound to the request locale.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useDate: () => (...args: Parameters<typeof date>) => string;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=useDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.d.ts","names":[],"sources":["../../../src/format/useDate.ts"],"mappings":";;;;qBAMa,mBAAO,MAGD,kBAAkB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { WrappedIntl } from "@intlayer/core/utils";
|
|
3
|
-
//#region src/format/useIntl.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Remix hook that provides a locale-bound `Intl` object.
|
|
6
5
|
*
|
|
@@ -12,5 +11,4 @@ export declare const useIntl: (locale?: LocalesValues) => {
|
|
|
12
11
|
intl: WrappedIntl;
|
|
13
12
|
subscribe: (callback: (intl: WrappedIntl) => void) => () => void;
|
|
14
13
|
};
|
|
15
|
-
//#endregion
|
|
16
14
|
//# sourceMappingURL=useIntl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/format/useIntl.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.d.ts","names":[],"sources":["../../../src/format/useIntl.ts"],"mappings":";;;;;;;;;qBAWa,UAAO,SACT;EAET,MAAM;EACN,YAAY,WAAW,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../src/format/useList.ts"],"mappings":";qBAGa,mBAAO,MAGD,kBAAkB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { number } from "@intlayer/core/formatters";
|
|
2
|
-
//#region src/format/useNumber.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Remix hook that provides a localized number formatter bound to the request locale.
|
|
5
4
|
*/
|
|
6
5
|
export declare const useNumber: () => (...args: Parameters<typeof number>) => string;
|
|
7
|
-
//#endregion
|
|
8
6
|
//# sourceMappingURL=useNumber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../src/format/useNumber.ts"],"mappings":";;;;qBAMa,qBAAS,MAGH,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../src/format/usePercentage.ts"],"mappings":";qBAGa,yBAAa,MAGP,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"mappings":";qBAGa,2BAAe,MAGT,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../src/format/useUnit.ts"],"mappings":";qBAGa,mBAAO,MAGD,kBAAkB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Locale } from "@intlayer/types/allLocales";
|
|
2
2
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
|
-
//#region src/localeRouting.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The part of an incoming request the locale routing is decided from.
|
|
6
5
|
*/
|
|
@@ -71,5 +70,4 @@ export type LocaleRoutingConfiguration = Pick<IntlayerConfig, 'internationalizat
|
|
|
71
70
|
* ```
|
|
72
71
|
*/
|
|
73
72
|
export declare const createLocaleRouting: (configuration: LocaleRoutingConfiguration, options?: LocaleRoutingOptions) => ((request: LocaleRoutingRequest) => LocaleRoutingAction);
|
|
74
|
-
//#endregion
|
|
75
73
|
//# sourceMappingURL=localeRouting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeRouting.d.ts","names":[],"sources":["../../src/localeRouting.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeRouting.d.ts","names":[],"sources":["../../src/localeRouting.ts"],"mappings":";;;;;YAmBY;EACV,KAAK;EACL,SAAS;;;;;;;;;;;;;YAcC;EACN;;EACA;EAAiB;EAAc,SAAS;;EAExC;EACA;EACA;EACA,gBAAgB;;YAGV;;;;;;;;;EASV;;;;EAIA,UAAU,SAAS;;YAGT,6BAA6B,KACvC;;;;;;;;;;;;;;;;;;;;;;;;qBA0DW,sBAAmB,eACf,4BAA0B,UAChC,2BACN,SAAS,yBAAyB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { INTLAYER_CONTEXT_PROPERTY, Intlayer, IntlayerState } from "./context.js";
|
|
2
2
|
import { LocaleRoutingOptions } from "./localeRouting.js";
|
|
3
3
|
import { Middleware } from "remix/router";
|
|
4
|
-
//#region src/middleware.d.ts
|
|
5
4
|
export type IntlayerMiddlewareOptions = LocaleRoutingOptions;
|
|
6
5
|
/**
|
|
7
6
|
* Remix 3 router middleware handling the internationalization layer:
|
|
@@ -45,5 +44,4 @@ export declare const intlayer: (options?: IntlayerMiddlewareOptions) => Middlewa
|
|
|
45
44
|
value: IntlayerState;
|
|
46
45
|
property: typeof INTLAYER_CONTEXT_PROPERTY;
|
|
47
46
|
}>;
|
|
48
|
-
//#endregion
|
|
49
47
|
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../src/middleware.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","names":[],"sources":["../../src/middleware.ts"],"mappings":";;;YAoBY,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyD3B,WAAQ,UACV,8BACR;EACD,YAAY;EACZ,OAAO;EACP,iBAAiB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Locale } from "@intlayer/types/allLocales";
|
|
2
|
-
//#region src/persistLocale.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Writes the locale into the storage headers configured in `routing.storage`
|
|
5
4
|
* (custom header, and the cookie when `includeCookie` is set).
|
|
@@ -12,5 +11,4 @@ export declare const writeLocaleHeaders: (headers: Headers, locale: Locale, { in
|
|
|
12
11
|
* are immutable (`Response.redirect`, `Response.error`) is re-created.
|
|
13
12
|
*/
|
|
14
13
|
export declare const withLocaleHeaders: (response: Response, locale: Locale) => Response;
|
|
15
|
-
//#endregion
|
|
16
14
|
//# sourceMappingURL=persistLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistLocale.d.ts","names":[],"sources":["../../src/persistLocale.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"persistLocale.d.ts","names":[],"sources":["../../src/persistLocale.ts"],"mappings":";;;;;qBAoCa,qBAAkB,SACpB,SAAO,QACR,UAAM;EACe;;;;;;qBAclB,oBAAiB,UAClB,UAAQ,QACV,WACP"}
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
2
|
import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core/interpreter";
|
|
3
|
-
//#region src/plugins.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Plugins applied by the hooks of this package.
|
|
6
5
|
*
|
|
7
6
|
* The base interpreter leaves `md()` and `html()` nodes untouched, so they are
|
|
8
7
|
* handed to the string renderers of `vanilla-intlayer`: the node exposes the
|
|
9
8
|
* rendered HTML as `.value` and `.use(components)` to override tags. Plain
|
|
10
|
-
* strings stay primitives — a `remix/
|
|
9
|
+
* strings stay primitives — a `remix/component` child must be a string, not a wrapper.
|
|
11
10
|
*/
|
|
12
11
|
export type IInterpreterPluginState = IInterpreterPluginState$1 & {
|
|
13
12
|
vanillaMarkdown: true;
|
|
@@ -19,5 +18,4 @@ export type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> =
|
|
|
19
18
|
* transform cache can key on its identity.
|
|
20
19
|
*/
|
|
21
20
|
export declare const getPlugins: (locale?: LocalesValues, fallback?: boolean) => Plugins[];
|
|
22
|
-
//#endregion
|
|
23
21
|
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":["IInterpreterPluginStateCore","DeepTransformContentCore"],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;;;YAsBY,0BAA0BA;EACpC;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxBC,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { IntlayerState } from "./context.js";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
3
4
|
import { RequestContext } from "remix/router";
|
|
4
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
|
-
//#region src/requestStorage.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Request context of the request being handled, made available to every
|
|
8
7
|
* function running inside the `intlayer()` middleware scope — route handlers,
|
|
@@ -17,5 +16,4 @@ export declare const getIntlayerState: () => IntlayerState | undefined;
|
|
|
17
16
|
* Returns the locale of the request being handled, if any.
|
|
18
17
|
*/
|
|
19
18
|
export declare const getRequestLocale: () => DeclaredLocales | undefined;
|
|
20
|
-
//#endregion
|
|
21
19
|
//# sourceMappingURL=requestStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestStorage.d.ts","names":[],"sources":["../../src/requestStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestStorage.d.ts","names":[],"sources":["../../src/requestStorage.ts"],"mappings":";;;;;;;;;qBAWa,gBAAc,kBAAA;;;;qBAKd,wBAAuB;;;;qBAMvB,wBAAuB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DeepTransformContent } from "./plugins.js";
|
|
2
2
|
import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
3
|
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
|
|
4
|
-
//#region src/useDictionary.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Transforms an imported dictionary (or qualified dictionary group) and returns
|
|
7
6
|
* its content for the locale of the request being handled.
|
|
@@ -25,5 +24,4 @@ import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup, Resol
|
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
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>>;
|
|
28
|
-
//#endregion
|
|
29
27
|
//# 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,UAAU,gBAAgB,2BAA2B,KACzD,iBAAe,YAEL,GAAC,mBACM,MAClB,qBACD,kCAAkC,GAAG,IACrC,sBAAsB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DeepTransformContent } from "./plugins.js";
|
|
2
2
|
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
-
//#region src/useIntlayer.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Picks one dictionary by its key and returns its content for the locale of
|
|
6
5
|
* the request being handled.
|
|
@@ -22,5 +21,4 @@ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, DictionarySe
|
|
|
22
21
|
* ```
|
|
23
22
|
*/
|
|
24
23
|
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>>;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# 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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
|
-
//#region src/useLocale.d.ts
|
|
3
2
|
export type UseLocaleResult = {
|
|
4
3
|
locale: DeclaredLocales;
|
|
5
4
|
defaultLocale: DeclaredLocales;
|
|
@@ -21,5 +20,4 @@ export type UseLocaleResult = {
|
|
|
21
20
|
* ```
|
|
22
21
|
*/
|
|
23
22
|
export declare const useLocale: () => UseLocaleResult;
|
|
24
|
-
//#endregion
|
|
25
23
|
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../src/useLocale.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../src/useLocale.ts"],"mappings":";YAIY;EACV,QAAQ;EACR,eAAe;EACf,kBAAkB;;;;;;;;;;;;;;;;;qBAoBP,iBAAgB"}
|