@swan-io/shared-business 13.10.0 → 13.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/shared-business",
3
- "version": "13.10.0",
3
+ "version": "13.10.1",
4
4
  "engines": {
5
5
  "node": ">22.12.0"
6
6
  },
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "peerDependencies": {
28
- "@swan-io/lake": "13.10.0"
28
+ "@swan-io/lake": "13.10.1"
29
29
  },
30
30
  "dependencies": {
31
31
  "@formatjs/intl": "^4.1.2",
@@ -50,6 +50,6 @@
50
50
  "@types/react-dom": "^19.2.3",
51
51
  "@types/react-native": "^0.72.8",
52
52
  "type-fest": "^5.4.3",
53
- "@swan-io/lake": "13.10.0"
53
+ "@swan-io/lake": "13.10.1"
54
54
  }
55
55
  }
@@ -11,9 +11,19 @@ export const getLanguagesHelpers = (languages) => {
11
11
  const isSupportedLanguage = (language) => (supportedLanguages !== null && supportedLanguages !== void 0 ? supportedLanguages : []).includes(language);
12
12
  const getFirstSupportedLanguage = (languages) => { var _a; return (_a = languages.find(isSupportedLanguage)) !== null && _a !== void 0 ? _a : LANGUAGE_FALLBACK; };
13
13
  const getPreferredLanguage = () => {
14
- var _a;
14
+ // @deprecated temporary keeping localStorage and migrating to cookie
15
+ const language = localStorage.getItem(PREFERRED_LANGUAGE_KEY);
16
+ if (language) {
17
+ localStorage.removeItem(PREFERRED_LANGUAGE_KEY);
18
+ const domain = "." + window.location.hostname.split(".").slice(-2).join(".");
19
+ document.cookie = `${PREFERRED_LANGUAGE_KEY}=${language}; path=/; max-age=31536000; SameSite=Lax; Secure; domain=${domain}`;
20
+ return language;
21
+ }
15
22
  try {
16
- return (_a = localStorage.getItem(PREFERRED_LANGUAGE_KEY)) !== null && _a !== void 0 ? _a : undefined;
23
+ const match = document.cookie
24
+ .split("; ")
25
+ .find(row => row.startsWith(PREFERRED_LANGUAGE_KEY + "="));
26
+ return match === null || match === void 0 ? void 0 : match.split("=")[1];
17
27
  }
18
28
  catch {
19
29
  return;
@@ -23,7 +33,8 @@ export const getLanguagesHelpers = (languages) => {
23
33
  getFirstSupportedLanguage,
24
34
  setPreferredLanguage: (language) => {
25
35
  try {
26
- localStorage.setItem(PREFERRED_LANGUAGE_KEY, language);
36
+ const domain = "." + window.location.hostname.split(".").slice(-2).join(".");
37
+ document.cookie = `${PREFERRED_LANGUAGE_KEY}=${language}; path=/; max-age=31536000; SameSite=Lax; Secure; domain=${domain}`;
27
38
  const url = new URL(window.location.href);
28
39
  url.searchParams.delete("lang");
29
40
  window.location.replace(url.toString());