@intlayer/core 8.6.5 → 8.6.7

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.
@@ -36,19 +36,18 @@ const buildCookieString = (name, value, attributes) => {
36
36
  */
37
37
  const getLocaleFromStorageClient = (options) => {
38
38
  const { locales } = _intlayer_config_built.internationalization;
39
- const storageAttributes = _intlayer_config_built.routing.storage;
40
39
  if (options?.isCookieEnabled === false) return void 0;
41
40
  const isValidLocale = (value) => !!value && locales.includes(value);
42
- if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < (storageAttributes.cookies ?? []).length; i++) try {
43
- const value = options?.getCookie?.(storageAttributes.cookies[i].name);
41
+ if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < (_intlayer_config_built.routing.storage.cookies ?? []).length; i++) try {
42
+ const value = options?.getCookie?.(_intlayer_config_built.routing.storage.cookies[i].name);
44
43
  if (isValidLocale(value)) return value;
45
44
  } catch {}
46
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) for (let i = 0; i < (storageAttributes.localStorage ?? []).length; i++) try {
47
- const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
45
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) for (let i = 0; i < (_intlayer_config_built.routing.storage.localStorage ?? []).length; i++) try {
46
+ const value = options?.getLocaleStorage?.(_intlayer_config_built.routing.storage.localStorage[i].name);
48
47
  if (isValidLocale(value)) return value;
49
48
  } catch {}
50
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
51
- const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
49
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && _intlayer_config_built.routing.storage.sessionStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.sessionStorage.length; i++) try {
50
+ const value = options?.getSessionStorage?.(_intlayer_config_built.routing.storage.sessionStorage[i].name);
52
51
  if (isValidLocale(value)) return value;
53
52
  } catch {}
54
53
  };
@@ -58,10 +57,9 @@ const getLocaleFromStorageClient = (options) => {
58
57
  * Does not write to headers — use `setLocaleInStorageServer` for that.
59
58
  */
60
59
  const setLocaleInStorageClient = (locale, options) => {
61
- const storageAttributes = _intlayer_config_built.routing.storage;
62
60
  if (options?.isCookieEnabled === false) return;
63
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
64
- const { name, attributes } = storageAttributes.cookies[i];
61
+ if (!TREE_SHAKE_STORAGE_COOKIES && _intlayer_config_built.routing.storage.cookies) for (let i = 0; i < _intlayer_config_built.routing.storage.cookies.length; i++) {
62
+ const { name, attributes } = _intlayer_config_built.routing.storage.cookies[i];
65
63
  try {
66
64
  if (options?.setCookieStore) options.setCookieStore(name, locale, {
67
65
  ...attributes,
@@ -73,8 +71,8 @@ const setLocaleInStorageClient = (locale, options) => {
73
71
  } catch {}
74
72
  }
75
73
  }
76
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && storageAttributes.localStorage && options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
77
- const { name } = storageAttributes.localStorage[i];
74
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && _intlayer_config_built.routing.storage.localStorage && options?.setLocaleStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.localStorage.length; i++) {
75
+ const { name } = _intlayer_config_built.routing.storage.localStorage[i];
78
76
  try {
79
77
  if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
80
78
  if (options.getLocaleStorage(name)) continue;
@@ -82,8 +80,8 @@ const setLocaleInStorageClient = (locale, options) => {
82
80
  options.setLocaleStorage(name, locale);
83
81
  } catch {}
84
82
  }
85
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage && options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
86
- const { name } = storageAttributes.sessionStorage[i];
83
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && _intlayer_config_built.routing.storage.sessionStorage && options?.setSessionStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.sessionStorage.length; i++) {
84
+ const { name } = _intlayer_config_built.routing.storage.sessionStorage[i];
87
85
  try {
88
86
  if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
89
87
  if (options.getSessionStorage(name)) continue;
@@ -115,15 +113,14 @@ const LocaleStorageClient = (options) => ({
115
113
  */
116
114
  const getLocaleFromStorageServer = (options) => {
117
115
  const { locales } = _intlayer_config_built.internationalization;
118
- const storageAttributes = _intlayer_config_built.routing.storage;
119
116
  if (options?.isCookieEnabled === false) return void 0;
120
117
  const isValidLocale = (value) => !!value && locales.includes(value);
121
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) try {
122
- const value = options?.getCookie?.(storageAttributes.cookies[i].name);
118
+ if (!TREE_SHAKE_STORAGE_COOKIES && _intlayer_config_built.routing.storage.cookies) for (let i = 0; i < _intlayer_config_built.routing.storage.cookies.length; i++) try {
119
+ const value = options?.getCookie?.(_intlayer_config_built.routing.storage.cookies[i].name);
123
120
  if (isValidLocale(value)) return value;
124
121
  } catch {}
125
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers) for (let i = 0; i < storageAttributes.headers.length; i++) try {
126
- const value = options?.getHeader?.(storageAttributes.headers[i].name);
122
+ if (!TREE_SHAKE_STORAGE_HEADERS && _intlayer_config_built.routing.storage.headers) for (let i = 0; i < _intlayer_config_built.routing.storage.headers.length; i++) try {
123
+ const value = options?.getHeader?.(_intlayer_config_built.routing.storage.headers[i].name);
127
124
  if (isValidLocale(value)) return value;
128
125
  } catch {}
129
126
  };
@@ -132,10 +129,9 @@ const getLocaleFromStorageServer = (options) => {
132
129
  * Does not write to localStorage or sessionStorage.
133
130
  */
134
131
  const setLocaleInStorageServer = (locale, options) => {
135
- const storageAttributes = _intlayer_config_built.routing.storage;
136
132
  if (options?.isCookieEnabled === false) return;
137
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
138
- const { name, attributes } = storageAttributes.cookies[i];
133
+ if (!TREE_SHAKE_STORAGE_COOKIES && _intlayer_config_built.routing.storage.cookies) for (let i = 0; i < _intlayer_config_built.routing.storage.cookies.length; i++) {
134
+ const { name, attributes } = _intlayer_config_built.routing.storage.cookies[i];
139
135
  try {
140
136
  if (options?.setCookieStore) options.setCookieStore(name, locale, {
141
137
  ...attributes,
@@ -147,8 +143,8 @@ const setLocaleInStorageServer = (locale, options) => {
147
143
  } catch {}
148
144
  }
149
145
  }
150
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers && options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
151
- options.setHeader(storageAttributes.headers[i].name, locale);
146
+ if (!TREE_SHAKE_STORAGE_HEADERS && _intlayer_config_built.routing.storage.headers && options?.setHeader) for (let i = 0; i < _intlayer_config_built.routing.storage.headers.length; i++) try {
147
+ options.setHeader(_intlayer_config_built.routing.storage.headers[i].name, locale);
152
148
  } catch {}
153
149
  };
154
150
  /**
@@ -181,7 +177,6 @@ const LocaleStorageServer = (options) => ({
181
177
  */
182
178
  const getLocaleFromStorage = (options) => {
183
179
  const { locales } = _intlayer_config_built.internationalization;
184
- const storageAttributes = _intlayer_config_built.routing.storage;
185
180
  if (options?.isCookieEnabled === false) return void 0;
186
181
  const isValidLocale = (value) => !!value && locales.includes(value);
187
182
  const readCookie = (name) => {
@@ -191,20 +186,20 @@ const getLocaleFromStorage = (options) => {
191
186
  } catch {}
192
187
  return require_utils_getCookie.getCookie(name);
193
188
  };
194
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
195
- const value = readCookie(storageAttributes.cookies[i].name);
189
+ if (!TREE_SHAKE_STORAGE_COOKIES && _intlayer_config_built.routing.storage.cookies) for (let i = 0; i < _intlayer_config_built.routing.storage.cookies.length; i++) {
190
+ const value = readCookie(_intlayer_config_built.routing.storage.cookies[i].name);
196
191
  if (isValidLocale(value)) return value;
197
192
  }
198
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && storageAttributes.localStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
199
- const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
193
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && _intlayer_config_built.routing.storage.localStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.localStorage.length; i++) try {
194
+ const value = options?.getLocaleStorage?.(_intlayer_config_built.routing.storage.localStorage[i].name);
200
195
  if (isValidLocale(value)) return value;
201
196
  } catch {}
202
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
203
- const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
197
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && _intlayer_config_built.routing.storage.sessionStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.sessionStorage.length; i++) try {
198
+ const value = options?.getSessionStorage?.(_intlayer_config_built.routing.storage.sessionStorage[i].name);
204
199
  if (isValidLocale(value)) return value;
205
200
  } catch {}
206
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers) for (let i = 0; i < storageAttributes.headers.length; i++) try {
207
- const value = options?.getHeader?.(storageAttributes.headers[i].name);
201
+ if (!TREE_SHAKE_STORAGE_HEADERS && _intlayer_config_built.routing.storage.headers) for (let i = 0; i < _intlayer_config_built.routing.storage.headers.length; i++) try {
202
+ const value = options?.getHeader?.(_intlayer_config_built.routing.storage.headers[i].name);
208
203
  if (isValidLocale(value)) return value;
209
204
  } catch {}
210
205
  };
@@ -216,10 +211,9 @@ const getLocaleFromStorage = (options) => {
216
211
  * {@link setLocaleInStorageServer} (server) instead.
217
212
  */
218
213
  const setLocaleInStorage = (locale, options) => {
219
- const storageAttributes = _intlayer_config_built.routing.storage;
220
214
  if (options?.isCookieEnabled === false) return;
221
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
222
- const { name, attributes } = storageAttributes.cookies[i];
215
+ if (!TREE_SHAKE_STORAGE_COOKIES && _intlayer_config_built.routing.storage.cookies) for (let i = 0; i < _intlayer_config_built.routing.storage.cookies.length; i++) {
216
+ const { name, attributes } = _intlayer_config_built.routing.storage.cookies[i];
223
217
  try {
224
218
  if (options?.setCookieStore) options.setCookieStore(name, locale, {
225
219
  ...attributes,
@@ -231,8 +225,8 @@ const setLocaleInStorage = (locale, options) => {
231
225
  } catch {}
232
226
  }
233
227
  }
234
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && storageAttributes.localStorage && options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
235
- const { name } = storageAttributes.localStorage[i];
228
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && _intlayer_config_built.routing.storage.localStorage && options?.setLocaleStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.localStorage.length; i++) {
229
+ const { name } = _intlayer_config_built.routing.storage.localStorage[i];
236
230
  try {
237
231
  if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
238
232
  if (options.getLocaleStorage(name)) continue;
@@ -240,8 +234,8 @@ const setLocaleInStorage = (locale, options) => {
240
234
  options.setLocaleStorage(name, locale);
241
235
  } catch {}
242
236
  }
243
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage && options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
244
- const { name } = storageAttributes.sessionStorage[i];
237
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && _intlayer_config_built.routing.storage.sessionStorage && options?.setSessionStorage) for (let i = 0; i < _intlayer_config_built.routing.storage.sessionStorage.length; i++) {
238
+ const { name } = _intlayer_config_built.routing.storage.sessionStorage[i];
245
239
  try {
246
240
  if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
247
241
  if (options.getSessionStorage(name)) continue;
@@ -249,8 +243,8 @@ const setLocaleInStorage = (locale, options) => {
249
243
  options.setSessionStorage(name, locale);
250
244
  } catch {}
251
245
  }
252
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers && options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
253
- options.setHeader(storageAttributes.headers[i].name, locale);
246
+ if (!TREE_SHAKE_STORAGE_HEADERS && _intlayer_config_built.routing.storage.headers && options?.setHeader) for (let i = 0; i < _intlayer_config_built.routing.storage.headers.length; i++) try {
247
+ options.setHeader(_intlayer_config_built.routing.storage.headers[i].name, locale);
254
248
  } catch {}
255
249
  };
256
250
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"localeStorage.cjs","names":["internationalization","routing","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } 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// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_COOKIES =\n process.env['INTLAYER_ROUTING_STORAGE_COOKIES'] === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_LOCALSTORAGE'] === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE'] === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_HEADERS =\n process.env['INTLAYER_ROUTING_STORAGE_HEADERS'] === 'false';\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 { 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 && storageAttributes.sessionStorage) {\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 storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n storageAttributes.localStorage &&\n options?.setLocaleStorage\n ) {\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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n storageAttributes.sessionStorage &&\n options?.setSessionStorage\n ) {\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 { 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 && storageAttributes.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 && storageAttributes.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 storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n storageAttributes.headers &&\n options?.setHeader\n ) {\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 { 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 && storageAttributes.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 && storageAttributes.localStorage) {\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 && storageAttributes.sessionStorage) {\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 && storageAttributes.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 storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n storageAttributes.localStorage &&\n options?.setLocaleStorage\n ) {\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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n storageAttributes.sessionStorage &&\n options?.setSessionStorage\n ) {\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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n storageAttributes.headers &&\n options?.setHeader\n ) {\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":";;;;;;;;;AAaA,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,mCACJ,QAAQ,IAAI,6CAA6C;;;;AAK3D,MAAM,qCACJ,QAAQ,IAAI,+CAA+C;;;;AAK7D,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;AAoBtD,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,E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,gBACX,SAAQ,gBACN,MACA,kBAAkB,MAAM,QAAQ,WAAW,CAC5C;WAEG;;;AAKd,KACE,CAAC,oCACD,kBAAkB,gBAClB,SAAS,iBAET,MAAK,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,KACE,CAAC,sCACD,kBAAkB,kBAClB,SAAS,kBAET,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,KACE,CAAC,8BACD,kBAAkB,WAClB,SAAS,UAET,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.cjs","names":["internationalization","routing","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } 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// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_COOKIES =\n process.env['INTLAYER_ROUTING_STORAGE_COOKIES'] === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_LOCALSTORAGE'] === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE'] === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_HEADERS =\n process.env['INTLAYER_ROUTING_STORAGE_HEADERS'] === 'false';\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 { locales } = internationalization;\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 < (routing.storage.cookies ?? []).length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.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 < (routing.storage.localStorage ?? []).length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage![i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.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 if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.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 { locales } = internationalization;\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 && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.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 if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n\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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.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 { locales } = internationalization;\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 && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const value = readCookie(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.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 if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.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":";;;;;;;;;AAaA,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,mCACJ,QAAQ,IAAI,6CAA6C;;;;AAK3D,MAAM,qCACJ,QAAQ,IAAI,+CAA+C;;;;AAK7D,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;AAoBtD,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,G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MAAM,OAAO;SACpD;;;;;;;;AAWd,MAAa,iBAAiB,aAAmC;CAC/D,iBAAiB,qBAAqB,QAAQ;CAC9C,YAAY,WAA0B,mBAAmB,QAAQ,QAAQ;CAC1E"}
@@ -34,19 +34,18 @@ const buildCookieString = (name, value, attributes) => {
34
34
  */
35
35
  const getLocaleFromStorageClient = (options) => {
36
36
  const { locales } = internationalization;
37
- const storageAttributes = routing.storage;
38
37
  if (options?.isCookieEnabled === false) return void 0;
39
38
  const isValidLocale = (value) => !!value && locales.includes(value);
40
- if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < (storageAttributes.cookies ?? []).length; i++) try {
41
- const value = options?.getCookie?.(storageAttributes.cookies[i].name);
39
+ if (!TREE_SHAKE_STORAGE_COOKIES) for (let i = 0; i < (routing.storage.cookies ?? []).length; i++) try {
40
+ const value = options?.getCookie?.(routing.storage.cookies[i].name);
42
41
  if (isValidLocale(value)) return value;
43
42
  } catch {}
44
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) for (let i = 0; i < (storageAttributes.localStorage ?? []).length; i++) try {
45
- const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
43
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) for (let i = 0; i < (routing.storage.localStorage ?? []).length; i++) try {
44
+ const value = options?.getLocaleStorage?.(routing.storage.localStorage[i].name);
46
45
  if (isValidLocale(value)) return value;
47
46
  } catch {}
48
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
49
- const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
47
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) for (let i = 0; i < routing.storage.sessionStorage.length; i++) try {
48
+ const value = options?.getSessionStorage?.(routing.storage.sessionStorage[i].name);
50
49
  if (isValidLocale(value)) return value;
51
50
  } catch {}
52
51
  };
@@ -56,10 +55,9 @@ const getLocaleFromStorageClient = (options) => {
56
55
  * Does not write to headers — use `setLocaleInStorageServer` for that.
57
56
  */
58
57
  const setLocaleInStorageClient = (locale, options) => {
59
- const storageAttributes = routing.storage;
60
58
  if (options?.isCookieEnabled === false) return;
61
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
62
- const { name, attributes } = storageAttributes.cookies[i];
59
+ if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) for (let i = 0; i < routing.storage.cookies.length; i++) {
60
+ const { name, attributes } = routing.storage.cookies[i];
63
61
  try {
64
62
  if (options?.setCookieStore) options.setCookieStore(name, locale, {
65
63
  ...attributes,
@@ -71,8 +69,8 @@ const setLocaleInStorageClient = (locale, options) => {
71
69
  } catch {}
72
70
  }
73
71
  }
74
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && storageAttributes.localStorage && options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
75
- const { name } = storageAttributes.localStorage[i];
72
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage && options?.setLocaleStorage) for (let i = 0; i < routing.storage.localStorage.length; i++) {
73
+ const { name } = routing.storage.localStorage[i];
76
74
  try {
77
75
  if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
78
76
  if (options.getLocaleStorage(name)) continue;
@@ -80,8 +78,8 @@ const setLocaleInStorageClient = (locale, options) => {
80
78
  options.setLocaleStorage(name, locale);
81
79
  } catch {}
82
80
  }
83
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage && options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
84
- const { name } = storageAttributes.sessionStorage[i];
81
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage && options?.setSessionStorage) for (let i = 0; i < routing.storage.sessionStorage.length; i++) {
82
+ const { name } = routing.storage.sessionStorage[i];
85
83
  try {
86
84
  if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
87
85
  if (options.getSessionStorage(name)) continue;
@@ -113,15 +111,14 @@ const LocaleStorageClient = (options) => ({
113
111
  */
114
112
  const getLocaleFromStorageServer = (options) => {
115
113
  const { locales } = internationalization;
116
- const storageAttributes = routing.storage;
117
114
  if (options?.isCookieEnabled === false) return void 0;
118
115
  const isValidLocale = (value) => !!value && locales.includes(value);
119
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) try {
120
- const value = options?.getCookie?.(storageAttributes.cookies[i].name);
116
+ if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) for (let i = 0; i < routing.storage.cookies.length; i++) try {
117
+ const value = options?.getCookie?.(routing.storage.cookies[i].name);
121
118
  if (isValidLocale(value)) return value;
122
119
  } catch {}
123
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers) for (let i = 0; i < storageAttributes.headers.length; i++) try {
124
- const value = options?.getHeader?.(storageAttributes.headers[i].name);
120
+ if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) for (let i = 0; i < routing.storage.headers.length; i++) try {
121
+ const value = options?.getHeader?.(routing.storage.headers[i].name);
125
122
  if (isValidLocale(value)) return value;
126
123
  } catch {}
127
124
  };
@@ -130,10 +127,9 @@ const getLocaleFromStorageServer = (options) => {
130
127
  * Does not write to localStorage or sessionStorage.
131
128
  */
132
129
  const setLocaleInStorageServer = (locale, options) => {
133
- const storageAttributes = routing.storage;
134
130
  if (options?.isCookieEnabled === false) return;
135
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
136
- const { name, attributes } = storageAttributes.cookies[i];
131
+ if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) for (let i = 0; i < routing.storage.cookies.length; i++) {
132
+ const { name, attributes } = routing.storage.cookies[i];
137
133
  try {
138
134
  if (options?.setCookieStore) options.setCookieStore(name, locale, {
139
135
  ...attributes,
@@ -145,8 +141,8 @@ const setLocaleInStorageServer = (locale, options) => {
145
141
  } catch {}
146
142
  }
147
143
  }
148
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers && options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
149
- options.setHeader(storageAttributes.headers[i].name, locale);
144
+ if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers && options?.setHeader) for (let i = 0; i < routing.storage.headers.length; i++) try {
145
+ options.setHeader(routing.storage.headers[i].name, locale);
150
146
  } catch {}
151
147
  };
152
148
  /**
@@ -179,7 +175,6 @@ const LocaleStorageServer = (options) => ({
179
175
  */
180
176
  const getLocaleFromStorage = (options) => {
181
177
  const { locales } = internationalization;
182
- const storageAttributes = routing.storage;
183
178
  if (options?.isCookieEnabled === false) return void 0;
184
179
  const isValidLocale = (value) => !!value && locales.includes(value);
185
180
  const readCookie = (name) => {
@@ -189,20 +184,20 @@ const getLocaleFromStorage = (options) => {
189
184
  } catch {}
190
185
  return getCookie(name);
191
186
  };
192
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
193
- const value = readCookie(storageAttributes.cookies[i].name);
187
+ if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) for (let i = 0; i < routing.storage.cookies.length; i++) {
188
+ const value = readCookie(routing.storage.cookies[i].name);
194
189
  if (isValidLocale(value)) return value;
195
190
  }
196
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && storageAttributes.localStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) try {
197
- const value = options?.getLocaleStorage?.(storageAttributes.localStorage[i].name);
191
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage) for (let i = 0; i < routing.storage.localStorage.length; i++) try {
192
+ const value = options?.getLocaleStorage?.(routing.storage.localStorage[i].name);
198
193
  if (isValidLocale(value)) return value;
199
194
  } catch {}
200
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) try {
201
- const value = options?.getSessionStorage?.(storageAttributes.sessionStorage[i].name);
195
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) for (let i = 0; i < routing.storage.sessionStorage.length; i++) try {
196
+ const value = options?.getSessionStorage?.(routing.storage.sessionStorage[i].name);
202
197
  if (isValidLocale(value)) return value;
203
198
  } catch {}
204
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers) for (let i = 0; i < storageAttributes.headers.length; i++) try {
205
- const value = options?.getHeader?.(storageAttributes.headers[i].name);
199
+ if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) for (let i = 0; i < routing.storage.headers.length; i++) try {
200
+ const value = options?.getHeader?.(routing.storage.headers[i].name);
206
201
  if (isValidLocale(value)) return value;
207
202
  } catch {}
208
203
  };
@@ -214,10 +209,9 @@ const getLocaleFromStorage = (options) => {
214
209
  * {@link setLocaleInStorageServer} (server) instead.
215
210
  */
216
211
  const setLocaleInStorage = (locale, options) => {
217
- const storageAttributes = routing.storage;
218
212
  if (options?.isCookieEnabled === false) return;
219
- if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) for (let i = 0; i < storageAttributes.cookies.length; i++) {
220
- const { name, attributes } = storageAttributes.cookies[i];
213
+ if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) for (let i = 0; i < routing.storage.cookies.length; i++) {
214
+ const { name, attributes } = routing.storage.cookies[i];
221
215
  try {
222
216
  if (options?.setCookieStore) options.setCookieStore(name, locale, {
223
217
  ...attributes,
@@ -229,8 +223,8 @@ const setLocaleInStorage = (locale, options) => {
229
223
  } catch {}
230
224
  }
231
225
  }
232
- if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && storageAttributes.localStorage && options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
233
- const { name } = storageAttributes.localStorage[i];
226
+ if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage && options?.setLocaleStorage) for (let i = 0; i < routing.storage.localStorage.length; i++) {
227
+ const { name } = routing.storage.localStorage[i];
234
228
  try {
235
229
  if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
236
230
  if (options.getLocaleStorage(name)) continue;
@@ -238,8 +232,8 @@ const setLocaleInStorage = (locale, options) => {
238
232
  options.setLocaleStorage(name, locale);
239
233
  } catch {}
240
234
  }
241
- if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && storageAttributes.sessionStorage && options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
242
- const { name } = storageAttributes.sessionStorage[i];
235
+ if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage && options?.setSessionStorage) for (let i = 0; i < routing.storage.sessionStorage.length; i++) {
236
+ const { name } = routing.storage.sessionStorage[i];
243
237
  try {
244
238
  if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
245
239
  if (options.getSessionStorage(name)) continue;
@@ -247,8 +241,8 @@ const setLocaleInStorage = (locale, options) => {
247
241
  options.setSessionStorage(name, locale);
248
242
  } catch {}
249
243
  }
250
- if (!TREE_SHAKE_STORAGE_HEADERS && storageAttributes.headers && options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) try {
251
- options.setHeader(storageAttributes.headers[i].name, locale);
244
+ if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers && options?.setHeader) for (let i = 0; i < routing.storage.headers.length; i++) try {
245
+ options.setHeader(routing.storage.headers[i].name, locale);
252
246
  } catch {}
253
247
  };
254
248
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } 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// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_COOKIES =\n process.env['INTLAYER_ROUTING_STORAGE_COOKIES'] === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_LOCALSTORAGE'] === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE'] === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_HEADERS =\n process.env['INTLAYER_ROUTING_STORAGE_HEADERS'] === 'false';\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 { 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 && storageAttributes.sessionStorage) {\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 storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n storageAttributes.localStorage &&\n options?.setLocaleStorage\n ) {\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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n storageAttributes.sessionStorage &&\n options?.setSessionStorage\n ) {\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 { 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 && storageAttributes.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 && storageAttributes.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 storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.cookies) {\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n storageAttributes.headers &&\n options?.setHeader\n ) {\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 { 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 && storageAttributes.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 && storageAttributes.localStorage) {\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 && storageAttributes.sessionStorage) {\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 && storageAttributes.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 storageAttributes = routing.storage;\n\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && storageAttributes.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n storageAttributes.localStorage &&\n options?.setLocaleStorage\n ) {\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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n storageAttributes.sessionStorage &&\n options?.setSessionStorage\n ) {\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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n storageAttributes.headers &&\n options?.setHeader\n ) {\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":";;;;;;;AAaA,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,mCACJ,QAAQ,IAAI,6CAA6C;;;;AAK3D,MAAM,qCACJ,QAAQ,IAAI,+CAA+C;;;;AAK7D,MA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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 { internationalization, routing } 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// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_COOKIES =\n process.env['INTLAYER_ROUTING_STORAGE_COOKIES'] === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_LOCALSTORAGE'] === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE'] === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_HEADERS =\n process.env['INTLAYER_ROUTING_STORAGE_HEADERS'] === 'false';\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 { locales } = internationalization;\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 < (routing.storage.cookies ?? []).length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.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 < (routing.storage.localStorage ?? []).length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage![i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.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 if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.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 { locales } = internationalization;\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 && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.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 if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n\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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.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 { locales } = internationalization;\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 && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const value = readCookie(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.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 if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.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 (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.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":";;;;;;;AA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;;;;AAjDZ;;cA4Ha,mBAAA,GAAuB,OAAA,EAAS,0BAAA;;sBAEvB,aAAA;AAAA;AAAA,KASV,0BAAA;EACV,SAAA;EACA,eAAA;EACA,cAAA,IACE,IAAA,UACA,KAAA,UACA,MAAA,EAAQ,qBAAA;EAEV,eAAA,IAAmB,IAAA,UAAc,MAAA;EACjC,SAAA,IAAa,IAAA;EACb,SAAA,IAAa,IAAA;EACb,SAAA,IAAa,IAAA,UAAc,KAAA;AAAA;;;;;AAtB7B;cA8Ba,0BAAA,GACX,OAAA,EAAS,0BAAA,KACR,MAAA;;;;;cA+BU,wBAAA,GACX,MAAA,EAAQ,aAAA,EACR,OAAA,GAAU,0BAAA;;;;;;;;;;;AAtDZ;;;;;;;cAmHa,mBAAA,GAAuB,OAAA,EAAS,0BAAA;;sBAEvB,aAAA;AAAA;;;;KAYV,oBAAA,GAAuB,0BAAA,GACjC,0BAAA;;;;;;;;cASW,oBAAA,GACX,OAAA,EAAS,IAAA,CACP,oBAAA,gGAOD,MAAA;AAjIH;;;;;;;AAAA,cAgMa,kBAAA,GACX,MAAA,EAAQ,aAAA,EACR,OAAA,GAAU,oBAAA;;AAjKZ;;;;;cAkPa,aAAA,GAAiB,OAAA,EAAS,oBAAA;;sBAEjB,aAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "8.6.5",
3
+ "version": "8.6.7",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -168,11 +168,11 @@
168
168
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
169
169
  },
170
170
  "dependencies": {
171
- "@intlayer/api": "8.6.5",
172
- "@intlayer/config": "8.6.5",
173
- "@intlayer/dictionaries-entry": "8.6.5",
174
- "@intlayer/types": "8.6.5",
175
- "@intlayer/unmerged-dictionaries-entry": "8.6.5",
171
+ "@intlayer/api": "8.6.7",
172
+ "@intlayer/config": "8.6.7",
173
+ "@intlayer/dictionaries-entry": "8.6.7",
174
+ "@intlayer/types": "8.6.7",
175
+ "@intlayer/unmerged-dictionaries-entry": "8.6.7",
176
176
  "defu": "6.1.4"
177
177
  },
178
178
  "devDependencies": {