@intlayer/core 8.6.1 → 8.6.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/localization/getLocalizedUrl.cjs +3 -2
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs +14 -9
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +2 -1
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs +3 -3
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/rewriteUtils.cjs +6 -3
- package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
- package/dist/cjs/localization/validatePrefix.cjs +6 -0
- package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +19 -18
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/cjs/utils/parseYaml.cjs +76 -159
- package/dist/cjs/utils/parseYaml.cjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +3 -2
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getPathWithoutLocale.mjs +14 -9
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +2 -1
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/esm/localization/localeResolver.mjs +3 -3
- package/dist/esm/localization/localeResolver.mjs.map +1 -1
- package/dist/esm/localization/rewriteUtils.mjs +6 -3
- package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
- package/dist/esm/localization/validatePrefix.mjs +5 -0
- package/dist/esm/localization/validatePrefix.mjs.map +1 -1
- package/dist/esm/utils/localeStorage.mjs +19 -18
- package/dist/esm/utils/localeStorage.mjs.map +1 -1
- package/dist/esm/utils/parseYaml.mjs +76 -159
- package/dist/esm/utils/parseYaml.mjs.map +1 -1
- package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
- package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -1
- package/dist/types/localization/getPrefix.d.ts.map +1 -1
- package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
- package/dist/types/localization/validatePrefix.d.ts.map +1 -1
- package/dist/types/utils/localeStorage.d.ts.map +1 -1
- package/dist/types/utils/parseYaml.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeResolver.mjs","names":[],"sources":["../../../src/localization/localeResolver.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {
|
|
1
|
+
{"version":3,"file":"localeResolver.mjs","names":[],"sources":["../../../src/localization/localeResolver.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Resolves the most specific locale from a user-provided list,\n * or falls back to the default locale if no match is found.\n */\nexport const localeResolver = (\n selectedLocale: LocalesValues | LocalesValues[],\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n defaultLocale: LocalesValues = configuration?.internationalization\n ?.defaultLocale\n): Locale => {\n // Ensure we can handle both a single locale or an array of locales uniformly\n const requestedLocales = [selectedLocale].flat();\n\n // Simple helper to normalize locale strings (e.g. \"en-US\" => \"en-us\")\n const normalize = (locale: string): string => locale.trim().toLowerCase();\n\n try {\n // Check each requested locale in order\n for (const requested of requestedLocales) {\n const normalizedRequested = normalize(requested);\n\n // Attempt exact match\n const exactMatch = locales.find(\n (locale) => normalize(locale) === normalizedRequested\n );\n if (exactMatch) {\n return exactMatch as Locale;\n }\n\n // Attempt partial match on language subtag\n // e.g. if requested is \"en-US\" and not found,\n // see if \"en\" is available among locales\n const [requestedLang] = normalizedRequested.split('-');\n const partialMatch = locales.find(\n (locale) => normalize(locale).split('-')[0] === requestedLang\n );\n if (partialMatch) {\n return partialMatch as Locale;\n }\n }\n } catch {\n // If anything unexpected happened, fall back to default\n }\n\n // If no match was found, return the default\n return defaultLocale as Locale;\n};\n"],"mappings":";;;;;;;AAQA,MAAa,kBACX,gBACA,UAA2B,eAAe,sBAAsB,SAChE,gBAA+B,eAAe,sBAC1C,kBACO;CAEX,MAAM,mBAAmB,CAAC,eAAe,CAAC,MAAM;CAGhD,MAAM,aAAa,WAA2B,OAAO,MAAM,CAAC,aAAa;AAEzE,KAAI;AAEF,OAAK,MAAM,aAAa,kBAAkB;GACxC,MAAM,sBAAsB,UAAU,UAAU;GAGhD,MAAM,aAAa,QAAQ,MACxB,WAAW,UAAU,OAAO,KAAK,oBACnC;AACD,OAAI,WACF,QAAO;GAMT,MAAM,CAAC,iBAAiB,oBAAoB,MAAM,IAAI;GACtD,MAAM,eAAe,QAAQ,MAC1B,WAAW,UAAU,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,cACjD;AACD,OAAI,aACF,QAAO;;SAGL;AAKR,QAAO"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { TREE_SHAKE_REWRITE } from "@intlayer/config/envVars";
|
|
2
|
+
|
|
1
3
|
//#region src/localization/rewriteUtils.ts
|
|
2
4
|
/**
|
|
3
5
|
* Normalizes legacy Record format or extracts specialized rules from RewriteObject.
|
|
4
6
|
*/
|
|
5
7
|
const getRewriteRules = (rewrite, context = "url") => {
|
|
6
|
-
if (!rewrite) return void 0;
|
|
8
|
+
if (!rewrite || TREE_SHAKE_REWRITE) return void 0;
|
|
7
9
|
if ("url" in rewrite) return rewrite[context];
|
|
8
10
|
return { rules: Object.entries(rewrite).map(([canonical, localized]) => ({
|
|
9
11
|
canonical: canonical.startsWith("/") ? canonical.replace(/\[([^\]]+)\]/g, ":$1") : `/${canonical.replace(/\[([^\]]+)\]/g, ":$1")}`,
|
|
@@ -44,7 +46,7 @@ const extractParams = (url, pattern) => {
|
|
|
44
46
|
* If locale is provided, only check for that locale. Otherwise, check for all locales.
|
|
45
47
|
*/
|
|
46
48
|
const getCanonicalPath = (localizedPath, locale, rewriteRules) => {
|
|
47
|
-
if (!rewriteRules) return localizedPath;
|
|
49
|
+
if (!rewriteRules || TREE_SHAKE_REWRITE) return localizedPath;
|
|
48
50
|
for (const rule of rewriteRules.rules) {
|
|
49
51
|
const { canonical, localized } = rule;
|
|
50
52
|
const localesToCheck = locale ? [locale] : Object.keys(localized);
|
|
@@ -61,7 +63,7 @@ const getCanonicalPath = (localizedPath, locale, rewriteRules) => {
|
|
|
61
63
|
* Given a canonical path (e.g., "/products/123"), finds the localized URL pattern (e.g., "/produits/123").
|
|
62
64
|
*/
|
|
63
65
|
const getLocalizedPath = (canonicalPath, locale, rewriteRules) => {
|
|
64
|
-
if (!rewriteRules) return {
|
|
66
|
+
if (!rewriteRules || TREE_SHAKE_REWRITE) return {
|
|
65
67
|
path: canonicalPath,
|
|
66
68
|
isRewritten: false
|
|
67
69
|
};
|
|
@@ -94,6 +96,7 @@ const getInternalPath = (canonicalPath, locale) => {
|
|
|
94
96
|
* Given a current pathname and locale, returns the pretty localized path if a rewrite rule exists and the path is not already localized.
|
|
95
97
|
*/
|
|
96
98
|
const getRewritePath = (pathname, locale, rewrite) => {
|
|
99
|
+
if (TREE_SHAKE_REWRITE) return void 0;
|
|
97
100
|
const rules = getRewriteRules(rewrite, "url");
|
|
98
101
|
if (!rules) return void 0;
|
|
99
102
|
const { path: localizedPath, isRewritten } = getLocalizedPath(getCanonicalPath(pathname, void 0, rules), locale, rules);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewriteUtils.mjs","names":[],"sources":["../../../src/localization/rewriteUtils.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n RewriteObject,\n RewriteRules,\n RoutingConfig,\n} from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport type LocalizedPathResult = {\n path: string;\n isRewritten: boolean;\n};\n\n/**\n * Normalizes legacy Record format or extracts specialized rules from RewriteObject.\n */\nexport const getRewriteRules = (\n rewrite: RoutingConfig['rewrite'],\n context: keyof RewriteObject = 'url'\n): RewriteRules | undefined => {\n if (!rewrite) return undefined;\n\n if ('url' in rewrite) {\n return (rewrite as RewriteObject)[context];\n }\n\n // Normalize legacy format\n return {\n rules: Object.entries(rewrite).map(([canonical, localized]) => ({\n // Normalize canonical path\n canonical: canonical.startsWith('/')\n ? canonical.replace(/\\[([^\\]]+)\\]/g, ':$1')\n : `/${canonical.replace(/\\[([^\\]]+)\\]/g, ':$1')}`,\n\n // Normalize localized path\n localized: Object.fromEntries(\n Object.entries(localized).map(([locale, pattern]) => {\n const normalizedPattern = pattern?.startsWith('/')\n ? pattern.replace(/\\[([^\\]]+)\\]/g, ':$1')\n : `/${(pattern || '').replace(/\\[([^\\]]+)\\]/g, ':$1')}`;\n return [locale, normalizedPattern];\n })\n ),\n })),\n };\n};\n\n/**\n * Converts normalized pattern to Regex.\n * Internal syntax supports:\n * - :param -> ([^/]+) (one segment)\n * - :param* -> (.*) (zero or more segments)\n * - :param+ -> (.+) (one or more segments)\n * - :param? -> ([^/]*) (zero or one segment)\n */\nconst patternToRegex = (pattern: string) => {\n const regexString = pattern\n .replace(/\\//g, '\\\\/') // Escape slashes\n .replace(/\\\\\\/:(?:[^/\\\\*+?]+)\\*/g, '(?:\\\\/(.*))?') // /:param*\n .replace(/\\\\\\/:(?:[^/\\\\*+?]+)\\?/g, '(?:\\\\/([^\\\\/]+))?') // /:param?\n .replace(/:([^/\\\\*+?]+)\\*/g, '(.*)') // :param* (if no leading slash)\n .replace(/:([^/\\\\*+?]+)\\?/g, '([^\\\\/]*)') // :param? (if no leading slash)\n .replace(/:([^/\\\\*+?]+)\\+/g, '(.+)') // :param+\n .replace(/:([^/\\\\*+?]+)/g, '([^\\\\/]+)'); // :param\n\n return new RegExp(`^${regexString}$`);\n};\n\n/**\n * Replaces route parameters in a path with provided values.\n */\nconst fillPath = (pattern: string, params: string[]) => {\n let index = 0;\n return (\n pattern\n .replace(/:([^/\\\\*+?]+)[*+?]?/g, () => params[index++] ?? '')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '') || '/'\n );\n};\n\n/**\n * Extract values from a URL based on a pattern.\n */\nconst extractParams = (url: string, pattern: string): string[] | null => {\n const regex = patternToRegex(pattern);\n const match = url.match(regex);\n return match ? match.slice(1) : null;\n};\n\n/**\n * Given a localized URL (e.g., \"/produits/123\"), finds the canonical internal path (e.g., \"/products/123\").\n * If locale is provided, only check for that locale. Otherwise, check for all locales.\n */\nexport const getCanonicalPath = (\n localizedPath: string,\n locale?: Locale,\n rewriteRules?: RewriteRules\n): string => {\n if (!rewriteRules) return localizedPath;\n\n for (const rule of rewriteRules.rules) {\n const { canonical, localized } = rule;\n const localesToCheck = locale ? [locale] : Object.keys(localized);\n\n for (const loc of localesToCheck) {\n const localizedPattern = localized[loc as keyof typeof localized];\n\n if (!localizedPattern) continue;\n\n const params = extractParams(localizedPath, localizedPattern);\n\n if (params) {\n return fillPath(canonical, params);\n }\n }\n }\n\n return localizedPath;\n};\n\n/**\n * Given a canonical path (e.g., \"/products/123\"), finds the localized URL pattern (e.g., \"/produits/123\").\n */\nexport const getLocalizedPath = (\n canonicalPath: string,\n locale: LocalesValues,\n rewriteRules?: RewriteRules\n): LocalizedPathResult => {\n if (!rewriteRules)
|
|
1
|
+
{"version":3,"file":"rewriteUtils.mjs","names":[],"sources":["../../../src/localization/rewriteUtils.ts"],"sourcesContent":["import { TREE_SHAKE_REWRITE } from '@intlayer/config/envVars';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type {\n RewriteObject,\n RewriteRules,\n RoutingConfig,\n} from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport type LocalizedPathResult = {\n path: string;\n isRewritten: boolean;\n};\n\n/**\n * Normalizes legacy Record format or extracts specialized rules from RewriteObject.\n */\nexport const getRewriteRules = (\n rewrite: RoutingConfig['rewrite'],\n context: keyof RewriteObject = 'url'\n): RewriteRules | undefined => {\n if (!rewrite || TREE_SHAKE_REWRITE) return undefined;\n\n if ('url' in rewrite) {\n return (rewrite as RewriteObject)[context];\n }\n\n // Normalize legacy format\n return {\n rules: Object.entries(rewrite).map(([canonical, localized]) => ({\n // Normalize canonical path\n canonical: canonical.startsWith('/')\n ? canonical.replace(/\\[([^\\]]+)\\]/g, ':$1')\n : `/${canonical.replace(/\\[([^\\]]+)\\]/g, ':$1')}`,\n\n // Normalize localized path\n localized: Object.fromEntries(\n Object.entries(localized).map(([locale, pattern]) => {\n const normalizedPattern = pattern?.startsWith('/')\n ? pattern.replace(/\\[([^\\]]+)\\]/g, ':$1')\n : `/${(pattern || '').replace(/\\[([^\\]]+)\\]/g, ':$1')}`;\n return [locale, normalizedPattern];\n })\n ),\n })),\n };\n};\n\n/**\n * Converts normalized pattern to Regex.\n * Internal syntax supports:\n * - :param -> ([^/]+) (one segment)\n * - :param* -> (.*) (zero or more segments)\n * - :param+ -> (.+) (one or more segments)\n * - :param? -> ([^/]*) (zero or one segment)\n */\nconst patternToRegex = (pattern: string) => {\n const regexString = pattern\n .replace(/\\//g, '\\\\/') // Escape slashes\n .replace(/\\\\\\/:(?:[^/\\\\*+?]+)\\*/g, '(?:\\\\/(.*))?') // /:param*\n .replace(/\\\\\\/:(?:[^/\\\\*+?]+)\\?/g, '(?:\\\\/([^\\\\/]+))?') // /:param?\n .replace(/:([^/\\\\*+?]+)\\*/g, '(.*)') // :param* (if no leading slash)\n .replace(/:([^/\\\\*+?]+)\\?/g, '([^\\\\/]*)') // :param? (if no leading slash)\n .replace(/:([^/\\\\*+?]+)\\+/g, '(.+)') // :param+\n .replace(/:([^/\\\\*+?]+)/g, '([^\\\\/]+)'); // :param\n\n return new RegExp(`^${regexString}$`);\n};\n\n/**\n * Replaces route parameters in a path with provided values.\n */\nconst fillPath = (pattern: string, params: string[]) => {\n let index = 0;\n return (\n pattern\n .replace(/:([^/\\\\*+?]+)[*+?]?/g, () => params[index++] ?? '')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '') || '/'\n );\n};\n\n/**\n * Extract values from a URL based on a pattern.\n */\nconst extractParams = (url: string, pattern: string): string[] | null => {\n const regex = patternToRegex(pattern);\n const match = url.match(regex);\n return match ? match.slice(1) : null;\n};\n\n/**\n * Given a localized URL (e.g., \"/produits/123\"), finds the canonical internal path (e.g., \"/products/123\").\n * If locale is provided, only check for that locale. Otherwise, check for all locales.\n */\nexport const getCanonicalPath = (\n localizedPath: string,\n locale?: Locale,\n rewriteRules?: RewriteRules\n): string => {\n if (!rewriteRules || TREE_SHAKE_REWRITE) return localizedPath;\n\n for (const rule of rewriteRules.rules) {\n const { canonical, localized } = rule;\n const localesToCheck = locale ? [locale] : Object.keys(localized);\n\n for (const loc of localesToCheck) {\n const localizedPattern = localized[loc as keyof typeof localized];\n\n if (!localizedPattern) continue;\n\n const params = extractParams(localizedPath, localizedPattern);\n\n if (params) {\n return fillPath(canonical, params);\n }\n }\n }\n\n return localizedPath;\n};\n\n/**\n * Given a canonical path (e.g., \"/products/123\"), finds the localized URL pattern (e.g., \"/produits/123\").\n */\nexport const getLocalizedPath = (\n canonicalPath: string,\n locale: LocalesValues,\n rewriteRules?: RewriteRules\n): LocalizedPathResult => {\n if (!rewriteRules || TREE_SHAKE_REWRITE)\n return { path: canonicalPath, isRewritten: false };\n\n for (const rule of rewriteRules.rules) {\n const { canonical, localized } = rule;\n\n // Check if the input path matches a configured canonical pattern\n const params = extractParams(canonicalPath, canonical);\n\n if (params) {\n const targetPattern = localized[locale as keyof typeof localized];\n\n if (targetPattern) {\n return {\n path: fillPath(targetPattern, params),\n isRewritten: true,\n };\n }\n }\n }\n\n return { path: canonicalPath, isRewritten: false };\n};\n\n/**\n * Returns the internal path for a given canonical path and locale.\n * Ensures the locale prefix is present exactly once.\n */\nexport const getInternalPath = (\n canonicalPath: string,\n locale: Locale\n): string => {\n const pathWithLeadingSlash = canonicalPath.startsWith('/')\n ? canonicalPath\n : `/${canonicalPath}`;\n\n if (\n pathWithLeadingSlash.startsWith(`/${locale}/`) ||\n pathWithLeadingSlash === `/${locale}`\n ) {\n return pathWithLeadingSlash;\n }\n\n return `/${locale}${pathWithLeadingSlash === '/' ? '' : pathWithLeadingSlash}`;\n};\n\n/**\n * Given a current pathname and locale, returns the pretty localized path if a rewrite rule exists and the path is not already localized.\n */\nexport const getRewritePath = (\n pathname: string,\n locale: Locale,\n rewrite?: RoutingConfig['rewrite']\n): string | undefined => {\n if (TREE_SHAKE_REWRITE) return undefined;\n const rules = getRewriteRules(rewrite, 'url');\n if (!rules) return undefined;\n\n // Identify canonical path (relative to root, no locale prefix expected in 'url' context)\n const canonicalPath = getCanonicalPath(pathname, undefined, rules);\n\n // Get the localized path for the current locale\n const { path: localizedPath, isRewritten } = getLocalizedPath(\n canonicalPath,\n locale,\n rules\n );\n\n if (isRewritten && localizedPath !== pathname) {\n return localizedPath;\n }\n\n return undefined;\n};\n"],"mappings":";;;;;;AAiBA,MAAa,mBACX,SACA,UAA+B,UACF;AAC7B,KAAI,CAAC,WAAW,mBAAoB,QAAO;AAE3C,KAAI,SAAS,QACX,QAAQ,QAA0B;AAIpC,QAAO,EACL,OAAO,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,WAAW,gBAAgB;EAE9D,WAAW,UAAU,WAAW,IAAI,GAChC,UAAU,QAAQ,iBAAiB,MAAM,GACzC,IAAI,UAAU,QAAQ,iBAAiB,MAAM;EAGjD,WAAW,OAAO,YAChB,OAAO,QAAQ,UAAU,CAAC,KAAK,CAAC,QAAQ,aAAa;AAInD,UAAO,CAAC,QAHkB,SAAS,WAAW,IAAI,GAC9C,QAAQ,QAAQ,iBAAiB,MAAM,GACvC,KAAK,WAAW,IAAI,QAAQ,iBAAiB,MAAM,GACrB;IAClC,CACH;EACF,EAAE,EACJ;;;;;;;;;;AAWH,MAAM,kBAAkB,YAAoB;CAC1C,MAAM,cAAc,QACjB,QAAQ,OAAO,MAAM,CACrB,QAAQ,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rC,aAAa;IACd;;;AAKP,QAAO;EAAE,MAAM;EAAe,aAAa;EAAO;;;;;;AAOpD,MAAa,mBACX,eACA,WACW;CACX,MAAM,uBAAuB,cAAc,WAAW,IAAI,GACtD,gBACA,IAAI;AAER,KACE,qBAAqB,WAAW,IAAI,OAAO,GAAG,IAC9C,yBAAyB,IAAI,SAE7B,QAAO;AAGT,QAAO,IAAI,SAAS,yBAAyB,MAAM,KAAK;;;;;AAM1D,MAAa,kBACX,UACA,QACA,YACuB;AACvB,KAAI,mBAAoB,QAAO;CAC/B,MAAM,QAAQ,gBAAgB,SAAS,MAAM;AAC7C,KAAI,CAAC,MAAO,QAAO;CAMnB,MAAM,EAAE,MAAM,eAAe,gBAAgB,iBAHvB,iBAAiB,UAAU,QAAW,MAAM,EAKhE,QACA,MACD;AAED,KAAI,eAAe,kBAAkB,SACnC,QAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getPrefix, resolveRoutingConfig } from "./getPrefix.mjs";
|
|
2
|
+
import { TREE_SHAKE_NO_PREFIX, TREE_SHAKE_SEARCH_PARAMS } from "@intlayer/config/envVars";
|
|
2
3
|
|
|
3
4
|
//#region src/localization/validatePrefix.ts
|
|
4
5
|
/**
|
|
@@ -25,6 +26,10 @@ import { getPrefix, resolveRoutingConfig } from "./getPrefix.mjs";
|
|
|
25
26
|
*/
|
|
26
27
|
const validatePrefix = (locale, options) => {
|
|
27
28
|
const { defaultLocale, mode, locales } = resolveRoutingConfig(options);
|
|
29
|
+
if (!TREE_SHAKE_NO_PREFIX && mode === "no-prefix" || !TREE_SHAKE_SEARCH_PARAMS && mode === "search-params") return {
|
|
30
|
+
isValid: true,
|
|
31
|
+
localePrefix: void 0
|
|
32
|
+
};
|
|
28
33
|
const { localePrefix } = getPrefix(locale || defaultLocale, {
|
|
29
34
|
mode,
|
|
30
35
|
locales,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validatePrefix.mjs","names":[],"sources":["../../../src/localization/validatePrefix.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n getPrefix,\n type RoutingOptions,\n resolveRoutingConfig,\n} from './getPrefix';\n\nexport type ValidatePrefixResult = {\n isValid: boolean;\n localePrefix: string | undefined;\n};\n\n/**\n * Checks whether a given locale is valid based on the configured locales.\n *\n * @param locale - The locale value to validate. Can be `undefined` or `null`.\n * @param options - Optional configuration to override default settings.\n * @param options.locales - Array of valid locales. Defaults to the configured internationalization locales.\n * @param options.defaultLocale - The default locale to use as fallback. Defaults to the configured default locale.\n * @param options.mode - The routing mode (`'prefix'`, `'prefix-all'`, or `'no-prefix'`). Defaults to the configured routing mode.\n * @returns An object containing the validation result and the locale prefix.\n *\n * @example\n * // Check if 'en' is a valid locale\n * const { isValid, localePrefix } = validatePrefix('en');\n *\n * @example\n * // Check with custom options\n * const { isValid, localePrefix } = validatePrefix('fr', {\n * locales: ['en', 'fr', 'es'],\n * defaultLocale: 'en',\n * mode: 'prefix-all',\n * });\n */\nexport const validatePrefix = (\n locale: LocalesValues | undefined | null,\n options?: RoutingOptions\n): ValidatePrefixResult => {\n const { defaultLocale, mode, locales } = resolveRoutingConfig(options);\n\n const { localePrefix } = getPrefix(locale || defaultLocale, {\n mode,\n locales,\n defaultLocale,\n });\n\n if (localePrefix === locale && locale === undefined) {\n return { isValid: true, localePrefix: undefined };\n }\n\n const isValid = locales.some((localeEl) => localeEl === locale);\n\n return { isValid, localePrefix };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"validatePrefix.mjs","names":[],"sources":["../../../src/localization/validatePrefix.ts"],"sourcesContent":["import {\n TREE_SHAKE_NO_PREFIX,\n TREE_SHAKE_SEARCH_PARAMS,\n} from '@intlayer/config/envVars';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n getPrefix,\n type RoutingOptions,\n resolveRoutingConfig,\n} from './getPrefix';\n\nexport type ValidatePrefixResult = {\n isValid: boolean;\n localePrefix: string | undefined;\n};\n\n/**\n * Checks whether a given locale is valid based on the configured locales.\n *\n * @param locale - The locale value to validate. Can be `undefined` or `null`.\n * @param options - Optional configuration to override default settings.\n * @param options.locales - Array of valid locales. Defaults to the configured internationalization locales.\n * @param options.defaultLocale - The default locale to use as fallback. Defaults to the configured default locale.\n * @param options.mode - The routing mode (`'prefix'`, `'prefix-all'`, or `'no-prefix'`). Defaults to the configured routing mode.\n * @returns An object containing the validation result and the locale prefix.\n *\n * @example\n * // Check if 'en' is a valid locale\n * const { isValid, localePrefix } = validatePrefix('en');\n *\n * @example\n * // Check with custom options\n * const { isValid, localePrefix } = validatePrefix('fr', {\n * locales: ['en', 'fr', 'es'],\n * defaultLocale: 'en',\n * mode: 'prefix-all',\n * });\n */\nexport const validatePrefix = (\n locale: LocalesValues | undefined | null,\n options?: RoutingOptions\n): ValidatePrefixResult => {\n const { defaultLocale, mode, locales } = resolveRoutingConfig(options);\n\n if (\n (!TREE_SHAKE_NO_PREFIX && mode === 'no-prefix') ||\n (!TREE_SHAKE_SEARCH_PARAMS && mode === 'search-params')\n ) {\n return { isValid: true, localePrefix: undefined };\n }\n\n const { localePrefix } = getPrefix(locale || defaultLocale, {\n mode,\n locales,\n defaultLocale,\n });\n\n if (localePrefix === locale && locale === undefined) {\n return { isValid: true, localePrefix: undefined };\n }\n\n const isValid = locales.some((localeEl) => localeEl === locale);\n\n return { isValid, localePrefix };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAa,kBACX,QACA,YACyB;CACzB,MAAM,EAAE,eAAe,MAAM,YAAY,qBAAqB,QAAQ;AAEtE,KACG,CAAC,wBAAwB,SAAS,eAClC,CAAC,4BAA4B,SAAS,gBAEvC,QAAO;EAAE,SAAS;EAAM,cAAc;EAAW;CAGnD,MAAM,EAAE,iBAAiB,UAAU,UAAU,eAAe;EAC1D;EACA;EACA;EACD,CAAC;AAEF,KAAI,iBAAiB,UAAU,WAAW,OACxC,QAAO;EAAE,SAAS;EAAM,cAAc;EAAW;AAKnD,QAAO;EAAE,SAFO,QAAQ,MAAM,aAAa,aAAa,OAAO;EAE7C;EAAc"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCookie } from "./getCookie.mjs";
|
|
2
2
|
import configuration from "@intlayer/config/built";
|
|
3
|
+
import { TREE_SHAKE_STORAGE_COOKIES, TREE_SHAKE_STORAGE_HEADERS, TREE_SHAKE_STORAGE_LOCAL_STORAGE, TREE_SHAKE_STORAGE_SESSION_STORAGE } from "@intlayer/config/envVars";
|
|
3
4
|
|
|
4
5
|
//#region src/utils/localeStorage.ts
|
|
5
6
|
const buildCookieString = (name, value, attributes) => {
|
|
@@ -22,15 +23,15 @@ const getLocaleFromStorageClient = (options) => {
|
|
|
22
23
|
const storageAttributes = routing.storage;
|
|
23
24
|
if (options?.isCookieEnabled === false) return void 0;
|
|
24
25
|
const isValidLocale = (value) => !!value && locales.includes(value);
|
|
25
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) try {
|
|
26
|
+
if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < storageAttributes.cookies.length; i++) try {
|
|
26
27
|
const value = options?.getCookie?.(storageAttributes.cookies[i].name);
|
|
27
28
|
if (isValidLocale(value)) return value;
|
|
28
29
|
} catch {}
|
|
29
|
-
for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
|
|
30
|
+
if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
|
|
30
31
|
const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
|
|
31
32
|
if (isValidLocale(value)) return value;
|
|
32
33
|
} catch {}
|
|
33
|
-
for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
|
|
34
|
+
if (!TREE_SHAKE_STORAGE_SESSION_STORAGE) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
|
|
34
35
|
const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
|
|
35
36
|
if (isValidLocale(value)) return value;
|
|
36
37
|
} catch {}
|
|
@@ -44,7 +45,7 @@ const setLocaleInStorageClient = (locale, options) => {
|
|
|
44
45
|
const { routing } = configuration;
|
|
45
46
|
const storageAttributes = routing.storage;
|
|
46
47
|
if (options?.isCookieEnabled === false) return;
|
|
47
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
48
|
+
if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
48
49
|
const { name, attributes } = storageAttributes.cookies[i];
|
|
49
50
|
try {
|
|
50
51
|
if (options?.setCookieStore) options.setCookieStore(name, locale, {
|
|
@@ -57,7 +58,7 @@ const setLocaleInStorageClient = (locale, options) => {
|
|
|
57
58
|
} catch {}
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
|
-
if (options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
|
|
61
|
+
if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
|
|
61
62
|
const { name } = storageAttributes.localStorage[i];
|
|
62
63
|
try {
|
|
63
64
|
if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
|
|
@@ -66,7 +67,7 @@ const setLocaleInStorageClient = (locale, options) => {
|
|
|
66
67
|
options.setLocaleStorage(name, locale);
|
|
67
68
|
} catch {}
|
|
68
69
|
}
|
|
69
|
-
if (options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
70
|
+
if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
70
71
|
const { name } = storageAttributes.sessionStorage[i];
|
|
71
72
|
try {
|
|
72
73
|
if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
|
|
@@ -103,11 +104,11 @@ const getLocaleFromStorageServer = (options) => {
|
|
|
103
104
|
const storageAttributes = routing.storage;
|
|
104
105
|
if (options?.isCookieEnabled === false) return void 0;
|
|
105
106
|
const isValidLocale = (value) => !!value && locales.includes(value);
|
|
106
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) try {
|
|
107
|
+
if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < storageAttributes.cookies.length; i++) try {
|
|
107
108
|
const value = options?.getCookie?.(storageAttributes.cookies[i].name);
|
|
108
109
|
if (isValidLocale(value)) return value;
|
|
109
110
|
} catch {}
|
|
110
|
-
for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
111
|
+
if (!TREE_SHAKE_STORAGE_HEADERS) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
111
112
|
const value = options?.getHeader?.(storageAttributes.headers[i].name);
|
|
112
113
|
if (isValidLocale(value)) return value;
|
|
113
114
|
} catch {}
|
|
@@ -120,7 +121,7 @@ const setLocaleInStorageServer = (locale, options) => {
|
|
|
120
121
|
const { routing } = configuration;
|
|
121
122
|
const storageAttributes = routing.storage;
|
|
122
123
|
if (options?.isCookieEnabled === false) return;
|
|
123
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
124
|
+
if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
124
125
|
const { name, attributes } = storageAttributes.cookies[i];
|
|
125
126
|
try {
|
|
126
127
|
if (options?.setCookieStore) options.setCookieStore(name, locale, {
|
|
@@ -133,7 +134,7 @@ const setLocaleInStorageServer = (locale, options) => {
|
|
|
133
134
|
} catch {}
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
|
-
if (options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
137
|
+
if (!TREE_SHAKE_STORAGE_HEADERS && options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
137
138
|
options.setHeader(storageAttributes.headers[i].name, locale);
|
|
138
139
|
} catch {}
|
|
139
140
|
};
|
|
@@ -178,19 +179,19 @@ const getLocaleFromStorage = (options) => {
|
|
|
178
179
|
} catch {}
|
|
179
180
|
return getCookie(name);
|
|
180
181
|
};
|
|
181
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
182
|
+
if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
182
183
|
const value = readCookie(storageAttributes.cookies[i].name);
|
|
183
184
|
if (isValidLocale(value)) return value;
|
|
184
185
|
}
|
|
185
|
-
for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
|
|
186
|
+
if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
|
|
186
187
|
const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
|
|
187
188
|
if (isValidLocale(value)) return value;
|
|
188
189
|
} catch {}
|
|
189
|
-
for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
|
|
190
|
+
if (!TREE_SHAKE_STORAGE_SESSION_STORAGE) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
|
|
190
191
|
const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
|
|
191
192
|
if (isValidLocale(value)) return value;
|
|
192
193
|
} catch {}
|
|
193
|
-
for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
194
|
+
if (!TREE_SHAKE_STORAGE_HEADERS) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
194
195
|
const value = options?.getHeader?.(storageAttributes.headers[i].name);
|
|
195
196
|
if (isValidLocale(value)) return value;
|
|
196
197
|
} catch {}
|
|
@@ -206,7 +207,7 @@ const setLocaleInStorage = (locale, options) => {
|
|
|
206
207
|
const { routing } = configuration;
|
|
207
208
|
const storageAttributes = routing.storage;
|
|
208
209
|
if (options?.isCookieEnabled === false) return;
|
|
209
|
-
for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
210
|
+
if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < storageAttributes.cookies.length; i++) {
|
|
210
211
|
const { name, attributes } = storageAttributes.cookies[i];
|
|
211
212
|
try {
|
|
212
213
|
if (options?.setCookieStore) options.setCookieStore(name, locale, {
|
|
@@ -219,7 +220,7 @@ const setLocaleInStorage = (locale, options) => {
|
|
|
219
220
|
} catch {}
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
|
-
if (options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
|
|
223
|
+
if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
|
|
223
224
|
const { name } = storageAttributes.localStorage[i];
|
|
224
225
|
try {
|
|
225
226
|
if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
|
|
@@ -228,7 +229,7 @@ const setLocaleInStorage = (locale, options) => {
|
|
|
228
229
|
options.setLocaleStorage(name, locale);
|
|
229
230
|
} catch {}
|
|
230
231
|
}
|
|
231
|
-
if (options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
232
|
+
if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
|
|
232
233
|
const { name } = storageAttributes.sessionStorage[i];
|
|
233
234
|
try {
|
|
234
235
|
if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
|
|
@@ -237,7 +238,7 @@ const setLocaleInStorage = (locale, options) => {
|
|
|
237
238
|
options.setSessionStorage(name, locale);
|
|
238
239
|
} catch {}
|
|
239
240
|
}
|
|
240
|
-
if (options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
241
|
+
if (!TREE_SHAKE_STORAGE_HEADERS && options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
|
|
241
242
|
options.setHeader(storageAttributes.headers[i].name, locale);
|
|
242
243
|
} catch {}
|
|
243
244
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getCookie } from './getCookie';\n\n// ============================================================================\n// Shared types\n// ============================================================================\n\nexport type CookieBuildAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n /** Expiry as milliseconds since epoch (Date.getTime()) or number of days */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Shared helpers\n// ============================================================================\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\n// ============================================================================\n// Client-specific types and functions\n// (cookies via browser APIs, localStorage, sessionStorage — no headers)\n// ============================================================================\n\nexport type LocaleStorageClientOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n};\n\n/**\n * Retrieves the locale from browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not read from headers — use `getLocaleFromStorageServer` for that.\n */\nexport const getLocaleFromStorageClient = (\n options: LocaleStorageClientOptions\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n storageAttributes.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n storageAttributes.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not write to headers — use `setLocaleInStorageServer` for that.\n */\nexport const setLocaleInStorageClient = (\n locale: LocalesValues,\n options?: LocaleStorageClientOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Client-side locale storage utility.\n * Handles cookies (browser), localStorage and sessionStorage.\n * Does not access headers.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageClient(localeStorageOptions);\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageClient = (options: LocaleStorageClientOptions) => ({\n getLocale: () => getLocaleFromStorageClient(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageClient(locale, options),\n});\n\n// ============================================================================\n// Server-specific types and functions\n// (cookies via injected getter/setter, headers — no localStorage/sessionStorage)\n// ============================================================================\n\nexport type LocaleStorageServerOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from server-side storage mechanisms (cookies, headers).\n * Does not access localStorage or sessionStorage.\n * No browser cookie fallback — the caller must provide `getCookie`.\n */\nexport const getLocaleFromStorageServer = (\n options: LocaleStorageServerOptions\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n const value = options?.getHeader?.(storageAttributes.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in server-side storage mechanisms (cookies, headers).\n * Does not write to localStorage or sessionStorage.\n */\nexport const setLocaleInStorageServer = (\n locale: LocalesValues,\n options?: LocaleStorageServerOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n options.setHeader(storageAttributes.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Server-side locale storage utility.\n * Handles cookies (via injected getter/setter) and headers.\n * Does not access localStorage or sessionStorage.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageServer({\n * getCookie: (name) => req.cookies[name],\n * setCookieStore: (name, value, attrs) => res.cookie(name, value, attrs),\n * getHeader: (name) => req.headers[name],\n * setHeader: (name, value) => res.setHeader(name, value),\n * });\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageServer = (options: LocaleStorageServerOptions) => ({\n getLocale: () => getLocaleFromStorageServer(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageServer(locale, options),\n});\n\n// ============================================================================\n// Deprecated: combined LocaleStorage\n// Use LocaleStorageClient or LocaleStorageServer instead\n// ============================================================================\n\n/**\n * @deprecated Use {@link LocaleStorageClientOptions} or {@link LocaleStorageServerOptions} instead.\n */\nexport type LocaleStorageOptions = LocaleStorageClientOptions &\n LocaleStorageServerOptions;\n\n/**\n * Retrieves the locale from all storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link getLocaleFromStorageClient} (browser) or\n * {@link getLocaleFromStorageServer} (server) instead.\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n const readCookie = (name: string): string | undefined => {\n try {\n const fromOption = options?.getCookie?.(name);\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n // Browser fallback kept for backward compatibility\n return getCookie(name);\n };\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const value = readCookie(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n storageAttributes.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n storageAttributes.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n const value = options?.getHeader?.(storageAttributes.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in all configured storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link setLocaleInStorageClient} (browser) or\n * {@link setLocaleInStorageServer} (server) instead.\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n options.setHeader(storageAttributes.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in storage based on configuration.\n *\n * @deprecated Use {@link LocaleStorageClient} (browser) or\n * {@link LocaleStorageServer} (server) instead.\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":";;;;AAwBA,MAAM,qBACJ,MACA,OACA,eACW;CAEX,MAAM,QAAkB,CAAC,GAAG,KAAK,GADZ,mBAAmB,MAAM,GACK;AAEnD,KAAI,WAAW,KAAM,OAAM,KAAK,QAAQ,WAAW,OAAO;AAC1D,KAAI,WAAW,OAAQ,OAAM,KAAK,UAAU,WAAW,SAAS;AAChE,KAAI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K,IAAI,IAAI,GAAG,IAAI,kBAAkB,aAAa,QAAQ,KAAK;EAC9D,MAAM,EAAE,SAAS,kBAAkB,aAAa;AAChD,MAAI;AACF,OAAI,EAAE,SAAS,aAAa,SAAS,SAAS,kBAC5C;QAAI,QAAQ,iBAAiB,KAAK,CAAE;;AAEtC,WAAQ,iBAAiB,MAAM,OAAO;UAChC;;AAIZ,KAAI,SAAS,kBACX,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,eAAe,QAAQ,KAAK;EAChE,MAAM,EAAE,SAAS,kBAAkB,eAAe;AAClD,MAAI;AACF,OAAI,EAAE,SAAS,aAAa,SAAS,SAAS,mBAC5C;QAAI,QAAQ,kBAAkB,KAAK,CAAE;;AAEvC,WAAQ,kBAAkB,MAAM,OAAO;UACjC;;AAIZ,KAAI,SAAS,UACX,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,QAAQ,QAAQ,IACpD,KAAI;AACF,UAAQ,UAAU,kBAAkB,QAAQ,GAAG,MAAM,OAAO;SACtD;;;;;;;;AAWd,MAAa,iBAAiB,aAAmC;CAC/D,iBAAiB,qBAAqB,QAAQ;CAC9C,YAAY,WAA0B,mBAAmB,QAAQ,QAAQ;CAC1E"}
|
|
1
|
+
{"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n TREE_SHAKE_STORAGE_COOKIES,\n TREE_SHAKE_STORAGE_HEADERS,\n TREE_SHAKE_STORAGE_LOCAL_STORAGE,\n TREE_SHAKE_STORAGE_SESSION_STORAGE,\n} from '@intlayer/config/envVars';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getCookie } from './getCookie';\n\n// ============================================================================\n// Shared types\n// ============================================================================\n\nexport type CookieBuildAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n /** Expiry as milliseconds since epoch (Date.getTime()) or number of days */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Shared helpers\n// ============================================================================\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\n// ============================================================================\n// Client-specific types and functions\n// (cookies via browser APIs, localStorage, sessionStorage — no headers)\n// ============================================================================\n\nexport type LocaleStorageClientOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n};\n\n/**\n * Retrieves the locale from browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not read from headers — use `getLocaleFromStorageServer` for that.\n */\nexport const getLocaleFromStorageClient = (\n options: LocaleStorageClientOptions\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n storageAttributes.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n storageAttributes.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not write to headers — use `setLocaleInStorageServer` for that.\n */\nexport const setLocaleInStorageClient = (\n locale: LocalesValues,\n options?: LocaleStorageClientOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Client-side locale storage utility.\n * Handles cookies (browser), localStorage and sessionStorage.\n * Does not access headers.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageClient(localeStorageOptions);\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageClient = (options: LocaleStorageClientOptions) => ({\n getLocale: () => getLocaleFromStorageClient(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageClient(locale, options),\n});\n\n// ============================================================================\n// Server-specific types and functions\n// (cookies via injected getter/setter, headers — no localStorage/sessionStorage)\n// ============================================================================\n\nexport type LocaleStorageServerOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from server-side storage mechanisms (cookies, headers).\n * Does not access localStorage or sessionStorage.\n * No browser cookie fallback — the caller must provide `getCookie`.\n */\nexport const getLocaleFromStorageServer = (\n options: LocaleStorageServerOptions\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n const value = options?.getHeader?.(storageAttributes.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in server-side storage mechanisms (cookies, headers).\n * Does not write to localStorage or sessionStorage.\n */\nexport const setLocaleInStorageServer = (\n locale: LocalesValues,\n options?: LocaleStorageServerOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n options.setHeader(storageAttributes.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Server-side locale storage utility.\n * Handles cookies (via injected getter/setter) and headers.\n * Does not access localStorage or sessionStorage.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageServer({\n * getCookie: (name) => req.cookies[name],\n * setCookieStore: (name, value, attrs) => res.cookie(name, value, attrs),\n * getHeader: (name) => req.headers[name],\n * setHeader: (name, value) => res.setHeader(name, value),\n * });\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageServer = (options: LocaleStorageServerOptions) => ({\n getLocale: () => getLocaleFromStorageServer(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageServer(locale, options),\n});\n\n// ============================================================================\n// Deprecated: combined LocaleStorage\n// Use LocaleStorageClient or LocaleStorageServer instead\n// ============================================================================\n\n/**\n * @deprecated Use {@link LocaleStorageClientOptions} or {@link LocaleStorageServerOptions} instead.\n */\nexport type LocaleStorageOptions = LocaleStorageClientOptions &\n LocaleStorageServerOptions;\n\n/**\n * Retrieves the locale from all storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link getLocaleFromStorageClient} (browser) or\n * {@link getLocaleFromStorageServer} (server) instead.\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n const readCookie = (name: string): string | undefined => {\n try {\n const fromOption = options?.getCookie?.(name);\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n // Browser fallback kept for backward compatibility\n return getCookie(name);\n };\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const value = readCookie(storageAttributes.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n storageAttributes.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n storageAttributes.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n const value = options?.getHeader?.(storageAttributes.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in all configured storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link setLocaleInStorageClient} (browser) or\n * {@link setLocaleInStorageServer} (server) instead.\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n const { routing } = configuration;\n const storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n try {\n options.setHeader(storageAttributes.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in storage based on configuration.\n *\n * @deprecated Use {@link LocaleStorageClient} (browser) or\n * {@link LocaleStorageServer} (server) instead.\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":";;;;;AA8BA,MAAM,qBACJ,MACA,OACA,eACW;CAEX,MAAM,QAAkB,CAAC,GAAG,KAAK,GADZ,mBAAmB,MAAM,GACK;AAEnD,KAAI,WAAW,KAAM,OAAM,KAAK,QAAQ,WAAW,OAAO;AAC1D,KAAI,WAAW,OAAQ,OAAM,KAAK,UAAU,WAAW,SAAS;AAChE,KAAI,WAAW,mBAAmB,KAChC,OAAM,KAAK,WAAW,WAAW,QAAQ,aAAa,GAAG;AAC3D,KAAI,WAAW,OAAQ,OAAM,KAAK,SAAS;AAC3C,KAAI,WAAW,SAAU,OAAM,KAAK,YAAY,WAAW,WAAW;AACtE,QAAO,MAAM,KAAK,KAAK;;;;;;;AA6BzB,MAAa,8BACX,YACuB;CACvB,MAAM,EAAE,SAAS,yBAAyB;CAC1C,MAAM,EAAE,YAAY;CACpB,MAAM,oBAAoB,QAAQ;AAElC,KAAI,SAAS,oBAAoB,MAAO,QAAO;CAE/C,MAAM,iBAAiB,UACrB,CAAC,CAAC,SAAS,QAAQ,SAAS,MAAgB;AAE9C,KAAI,CAAC,2BACH,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,QAAQ,QAAQ,IACpD,KAAI;EACF,MAAM,QAAQ,SAAS,YAAY,kBAAkB,QAAQ,GAAG,KAAK;AACrE,MAAI,cAAc,MAAM,CAAE,QAAO;SAC3B;AAIZ,KAAI,CAAC,iCACH,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,aAAa,QAAQ,IACzD,KAAI;EACF,MAAM,QAAQ,SAAS,mBACrB,kBAAkB,aAAa,GAAG,KACnC;AACD,MAAI,cAAc,MAAM,CAAE,QAAO;SAC3B;AAIZ,KAAI,CAAC,mCACH,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,eA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