@leyyo/localization 1.1.1 → 1.1.3

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.
Files changed (128) hide show
  1. package/README.md +3 -3
  2. package/dist/base/base-localization.handler.d.ts +1 -1
  3. package/dist/base/base-localization.handler.js +18 -12
  4. package/dist/base/index.d.ts +2 -2
  5. package/dist/base/index.js +2 -19
  6. package/dist/base/index.types.js +1 -3
  7. package/dist/config/index.d.ts +2 -2
  8. package/dist/config/index.js +2 -19
  9. package/dist/config/index.types.d.ts +3 -5
  10. package/dist/config/index.types.js +1 -3
  11. package/dist/config/localization.config.d.ts +1 -1
  12. package/dist/config/localization.config.js +33 -21
  13. package/dist/country/country.handler.d.ts +1 -1
  14. package/dist/country/country.handler.js +13 -23
  15. package/dist/country/country.map.d.ts +2 -2
  16. package/dist/country/country.map.js +252 -256
  17. package/dist/country/index.d.ts +2 -3
  18. package/dist/country/index.js +2 -20
  19. package/dist/country/index.types.d.ts +2 -3
  20. package/dist/country/index.types.js +1 -3
  21. package/dist/exchange/exchange.handler.d.ts +1 -1
  22. package/dist/exchange/exchange.handler.js +14 -25
  23. package/dist/exchange/exchange.map.d.ts +2 -2
  24. package/dist/exchange/exchange.map.js +36 -9
  25. package/dist/exchange/index.d.ts +2 -3
  26. package/dist/exchange/index.js +2 -20
  27. package/dist/exchange/index.types.d.ts +2 -3
  28. package/dist/exchange/index.types.js +1 -3
  29. package/dist/index.d.ts +11 -7
  30. package/dist/index.foretell.d.ts +1 -0
  31. package/dist/index.foretell.js +19 -0
  32. package/dist/index.js +11 -24
  33. package/dist/index.loader.d.ts +1 -0
  34. package/dist/index.loader.js +13 -0
  35. package/dist/internal.d.ts +1 -1
  36. package/dist/internal.js +2 -5
  37. package/dist/language/index.d.ts +2 -3
  38. package/dist/language/index.js +2 -20
  39. package/dist/language/index.types.d.ts +2 -2
  40. package/dist/language/index.types.js +1 -3
  41. package/dist/language/language.handler.d.ts +1 -11
  42. package/dist/language/language.handler.js +13 -21
  43. package/dist/language/language.map.d.ts +2 -2
  44. package/dist/language/language.map.js +185 -189
  45. package/dist/literal/browser-type.d.ts +7 -0
  46. package/dist/literal/browser-type.js +2 -0
  47. package/dist/{country → literal}/country-code.d.ts +1 -1
  48. package/dist/literal/country-code.js +257 -0
  49. package/dist/literal/cpu-architecture.d.ts +7 -0
  50. package/dist/literal/cpu-architecture.js +20 -0
  51. package/dist/literal/device-type.d.ts +7 -0
  52. package/dist/literal/device-type.js +11 -0
  53. package/dist/literal/engine-type.d.ts +7 -0
  54. package/dist/literal/engine-type.js +23 -0
  55. package/dist/{exchange → literal}/exchange-code.d.ts +1 -1
  56. package/dist/literal/exchange-code.js +157 -0
  57. package/dist/literal/index.d.ts +9 -0
  58. package/dist/literal/index.js +9 -0
  59. package/dist/{language → literal}/language-code.d.ts +1 -1
  60. package/dist/literal/language-code.js +187 -0
  61. package/dist/{locale → literal}/locale-code.d.ts +1 -1
  62. package/dist/literal/locale-code.js +199 -0
  63. package/dist/{timezone → literal}/timezone-code.d.ts +1 -1
  64. package/dist/literal/timezone-code.js +605 -0
  65. package/dist/locale/index.d.ts +2 -3
  66. package/dist/locale/index.js +2 -20
  67. package/dist/locale/index.types.d.ts +2 -4
  68. package/dist/locale/index.types.js +1 -3
  69. package/dist/locale/locale.handler.d.ts +1 -17
  70. package/dist/locale/locale.handler.js +17 -28
  71. package/dist/locale/locale.map.d.ts +2 -2
  72. package/dist/locale/locale.map.js +84 -88
  73. package/dist/parser/index.d.ts +2 -2
  74. package/dist/parser/index.js +2 -19
  75. package/dist/parser/index.types.d.ts +4 -24
  76. package/dist/parser/index.types.js +1 -3
  77. package/dist/parser/localization.parser.d.ts +1 -1
  78. package/dist/parser/localization.parser.js +112 -111
  79. package/dist/timezone/index.d.ts +2 -3
  80. package/dist/timezone/index.js +2 -20
  81. package/dist/timezone/index.types.d.ts +2 -3
  82. package/dist/timezone/index.types.js +1 -3
  83. package/dist/timezone/timezone.handler.d.ts +1 -1
  84. package/dist/timezone/timezone.handler.js +21 -24
  85. package/dist/timezone/timezone.map.d.ts +2 -2
  86. package/dist/timezone/timezone.map.js +603 -607
  87. package/package.json +23 -23
  88. package/dist/base/base-localization.handler.js.map +0 -1
  89. package/dist/base/index.js.map +0 -1
  90. package/dist/base/index.types.js.map +0 -1
  91. package/dist/config/index.js.map +0 -1
  92. package/dist/config/index.types.js.map +0 -1
  93. package/dist/config/localization.config.js.map +0 -1
  94. package/dist/country/country-code.js +0 -19
  95. package/dist/country/country-code.js.map +0 -1
  96. package/dist/country/country.handler.js.map +0 -1
  97. package/dist/country/country.map.js.map +0 -1
  98. package/dist/country/index.js.map +0 -1
  99. package/dist/country/index.types.js.map +0 -1
  100. package/dist/exchange/exchange-code.js +0 -23
  101. package/dist/exchange/exchange-code.js.map +0 -1
  102. package/dist/exchange/exchange.handler.js.map +0 -1
  103. package/dist/exchange/exchange.map.js.map +0 -1
  104. package/dist/exchange/index.js.map +0 -1
  105. package/dist/exchange/index.types.js.map +0 -1
  106. package/dist/index.js.map +0 -1
  107. package/dist/internal.js.map +0 -1
  108. package/dist/language/index.js.map +0 -1
  109. package/dist/language/index.types.js.map +0 -1
  110. package/dist/language/language-code.js +0 -33
  111. package/dist/language/language-code.js.map +0 -1
  112. package/dist/language/language.handler.js.map +0 -1
  113. package/dist/language/language.map.js.map +0 -1
  114. package/dist/locale/index.js.map +0 -1
  115. package/dist/locale/index.types.js.map +0 -1
  116. package/dist/locale/locale-code.js +0 -25
  117. package/dist/locale/locale-code.js.map +0 -1
  118. package/dist/locale/locale.handler.js.map +0 -1
  119. package/dist/locale/locale.map.js.map +0 -1
  120. package/dist/parser/index.js.map +0 -1
  121. package/dist/parser/index.types.js.map +0 -1
  122. package/dist/parser/localization.parser.js.map +0 -1
  123. package/dist/timezone/index.js.map +0 -1
  124. package/dist/timezone/index.types.js.map +0 -1
  125. package/dist/timezone/timezone-code.js +0 -109
  126. package/dist/timezone/timezone-code.js.map +0 -1
  127. package/dist/timezone/timezone.handler.js.map +0 -1
  128. package/dist/timezone/timezone.map.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Leyyo: Localization Common
1
+ # Leyyo: Localization
2
2
  Common library for Leyyo framework
3
3
 
4
4
  ## Import
5
- - `npm i @leyyo/localization-common`
5
+ - `npm i @leyyo/localization`
6
6
 
7
7
  ## Usage (Runtime)
8
8
 
@@ -12,7 +12,7 @@ Common library for Leyyo framework
12
12
  > @see [ISO 3166](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
13
13
  >
14
14
  ```typescript
15
- import {countryHandler} from "@leyyo/localization-common";
15
+ import {countryHandler} from "@leyyo/localization";
16
16
 
17
17
  /*
18
18
  * Country exists
@@ -1,4 +1,4 @@
1
- import type { BaseLocalizationHandlerLike, BaseLocalizationHandlerRaw, BaseLocalizationHandlerView } from "./index.types";
1
+ import { BaseLocalizationHandlerLike, BaseLocalizationHandlerRaw, BaseLocalizationHandlerView } from "./index.types.js";
2
2
  /** @inheritDoc */
3
3
  export declare abstract class BaseLocalizationHandler<E extends string, W extends BaseLocalizationHandlerView<E>, R extends BaseLocalizationHandlerRaw> implements BaseLocalizationHandlerLike<E, W, R> {
4
4
  /**
@@ -1,35 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseLocalizationHandler = void 0;
4
1
  /** @inheritDoc */
5
- class BaseLocalizationHandler {
2
+ export class BaseLocalizationHandler {
3
+ /**
4
+ * Raw records which is loaded from corresponding map file
5
+ * */
6
+ _raw;
7
+ /** @inheritDoc */
8
+ codes;
6
9
  /** @inheritDoc */
7
10
  has(code) {
8
- if (typeof code !== 'string') {
11
+ if (typeof code !== "string") {
9
12
  return false;
10
13
  }
11
14
  return this._raw[code] !== undefined;
12
15
  }
13
16
  /** @inheritDoc */
14
17
  getRaw(code) {
15
- if (typeof code !== 'string') {
18
+ if (typeof code !== "string") {
16
19
  return undefined;
17
20
  }
18
21
  return this._raw[code];
19
22
  }
20
23
  /** @inheritDoc */
21
24
  getName(code) {
22
- var _a, _b;
23
- return (_b = (_a = this.getRaw(code)) === null || _a === void 0 ? void 0 : _a.n) !== null && _b !== void 0 ? _b : code;
25
+ if (typeof code !== "string") {
26
+ return undefined;
27
+ }
28
+ return this.getRaw(code)?.n ?? code;
24
29
  }
25
30
  /** @inheritDoc */
26
31
  getAll() {
27
- return this.codes.map(code => this.get(code));
32
+ return this.codes.map((code) => this.get(code));
28
33
  }
29
34
  /** @inheritDoc */
30
35
  getSelected(...codes) {
31
- return codes.filter(code => this.codes.includes(code)).map(code => this.get(code));
36
+ return codes
37
+ .filter((code) => typeof code === "string")
38
+ .filter((code) => this.codes.includes(code))
39
+ .map((code) => this.get(code));
32
40
  }
33
41
  }
34
- exports.BaseLocalizationHandler = BaseLocalizationHandler;
35
- //# sourceMappingURL=base-localization.handler.js.map
@@ -1,2 +1,2 @@
1
- export * from './index.types';
2
- export * from './base-localization.handler';
1
+ export * from "./index.types.js";
2
+ export * from "./base-localization.handler.js";
@@ -1,19 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./base-localization.handler"), exports);
19
- //# sourceMappingURL=index.js.map
1
+ export * from "./index.types.js";
2
+ export * from "./base-localization.handler.js";
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.types.js.map
1
+ export {};
@@ -1,2 +1,2 @@
1
- export * from './index.types';
2
- export * from './localization.config';
1
+ export * from "./index.types.js";
2
+ export * from "./localization.config.js";
@@ -1,19 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./localization.config"), exports);
19
- //# sourceMappingURL=index.js.map
1
+ export * from "./index.types.js";
2
+ export * from "./localization.config.js";
@@ -1,7 +1,5 @@
1
- import type { BuilderAny } from "@leyyo/builder/dist/types";
2
- import { LocaleCode } from "../locale";
3
- import { LanguageCode } from "../language";
4
- import { CountryCode } from "../country";
1
+ import { BuilderAny } from "@leyyo/builder";
2
+ import { CountryCode, LanguageCode, LocaleCode } from "../literal/index.js";
5
3
  export interface LocalizationConfigLike {
6
4
  readonly authorizationKeys: string[];
7
5
  readonly applicationKeys: string[];
@@ -19,4 +17,4 @@ export interface LocalizationConfigLike {
19
17
  export type ReplacerLike<T extends string, V> = {
20
18
  [K in T]?: V;
21
19
  };
22
- export type LocalizationConfigOmit = Omit<LocalizationConfigLike, 'builder'>;
20
+ export type LocalizationConfigOmit = Omit<LocalizationConfigLike, "builder">;
@@ -1,3 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.types.js.map
1
+ export {};
@@ -1,2 +1,2 @@
1
- import type { LocalizationConfigLike } from "./index.types";
1
+ import { LocalizationConfigLike } from "./index.types.js";
2
2
  export declare const localizationConfig: LocalizationConfigLike;
@@ -1,27 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localizationConfig = void 0;
4
- const builder_1 = require("@leyyo/builder");
1
+ import { Builder } from "@leyyo/builder";
5
2
  class LocalizationConfig {
6
- constructor() {
7
- this.authorizationKeys = ['authorization', 'api-key'];
8
- this.applicationKeys = ['application', 'x-application'];
9
- this.correlationKeys = ['x-correlation', 'x-correlation-id'];
10
- this.refererKeys = ['x-fwd-referer', 'x-fwd-referrer', 'x-referer', 'x-referrer', 'referer', 'referrer'];
11
- this.userAgentKeys = ['x-fwd-user-agent', 'x-user-agent', 'user-agent'];
12
- this.acceptLanguageKeys = ['x-fwd-accept-language', 'x-accept-language', 'accept-language'];
13
- this.ipAddressKeys = ['x-real-ip', 'x-client-ip', 'fastly-client-ip', 'true-client-ip', 'cf-connecting-ip', 'x-cluster-client-ip', 'x-forwarded-for'];
14
- this.applicationDelimiter = ':';
15
- this.countryReplacer = {};
16
- this.languageReplacer = {};
17
- this.localeReplacer = {};
18
- }
3
+ authorizationKeys = ["authorization", "api-key"];
4
+ applicationKeys = ["application", "x-application"];
5
+ correlationKeys = ["x-correlation", "x-correlation-id"];
6
+ refererKeys = [
7
+ "x-fwd-referer",
8
+ "x-fwd-referrer",
9
+ "x-referer",
10
+ "x-referrer",
11
+ "referer",
12
+ "referrer",
13
+ ];
14
+ userAgentKeys = ["x-fwd-user-agent", "x-user-agent", "user-agent"];
15
+ acceptLanguageKeys = [
16
+ "x-fwd-accept-language",
17
+ "x-accept-language",
18
+ "accept-language",
19
+ ];
20
+ ipAddressKeys = [
21
+ "x-real-ip",
22
+ "x-client-ip",
23
+ "fastly-client-ip",
24
+ "true-client-ip",
25
+ "cf-connecting-ip",
26
+ "x-cluster-client-ip",
27
+ "x-forwarded-for",
28
+ ];
29
+ applicationDelimiter = ":";
30
+ countryReplacer = {};
31
+ languageReplacer = {};
32
+ localeReplacer = {};
19
33
  builder() {
20
- return builder_1.Builder.build(this)
21
- .$setItem((key, value) => {
34
+ return Builder.build(this).$setItem((key, value) => {
22
35
  this[key] = value;
23
36
  });
24
37
  }
25
38
  }
26
- exports.localizationConfig = new LocalizationConfig();
27
- //# sourceMappingURL=localization.config.js.map
39
+ export const localizationConfig = new LocalizationConfig();
@@ -1,2 +1,2 @@
1
- import type { CountryHandlerLike } from "./index.types";
1
+ import { CountryHandlerLike } from "./index.types.js";
2
2
  export declare const countryHandler: CountryHandlerLike;
@@ -1,31 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.countryHandler = void 0;
4
- const country_code_1 = require("./country-code");
5
- const country_map_1 = require("./country.map");
6
- const base_1 = require("../base");
1
+ import { CountryCodeItems } from "../literal/index.js";
2
+ import { countryMap } from "./country.map.js";
3
+ import { BaseLocalizationHandler } from "../base/index.js";
7
4
  /** @inheritDoc */
8
- class CountryHandler extends base_1.BaseLocalizationHandler {
9
- constructor() {
10
- super(...arguments);
11
- /** @inheritDoc */
12
- this._raw = country_map_1.countryMap;
13
- /** @inheritDoc */
14
- this.codes = country_code_1.CountryCodeItems;
15
- }
5
+ class CountryHandler extends BaseLocalizationHandler {
6
+ /** @inheritDoc */
7
+ _raw = countryMap;
8
+ /** @inheritDoc */
9
+ codes = CountryCodeItems;
16
10
  /** @inheritDoc */
17
11
  getAlpha3(code) {
18
- var _a;
19
- return (_a = this.getRaw(code)) === null || _a === void 0 ? void 0 : _a.y;
12
+ return this.getRaw(code)?.y;
20
13
  }
21
14
  /** @inheritDoc */
22
15
  getLanguages(code) {
23
- var _a;
24
- return (_a = this.getRaw(code).l) !== null && _a !== void 0 ? _a : [];
16
+ return this.getRaw(code).l ?? [];
25
17
  }
26
18
  /** @inheritDoc */
27
19
  findByLanguage(languageCode) {
28
- if (typeof languageCode !== 'string') {
20
+ if (typeof languageCode !== "string") {
29
21
  return [];
30
22
  }
31
23
  const result = [];
@@ -38,14 +30,12 @@ class CountryHandler extends base_1.BaseLocalizationHandler {
38
30
  }
39
31
  /** @inheritDoc */
40
32
  get(code) {
41
- var _a;
42
33
  const item = this.getRaw(code);
43
34
  if (!item) {
44
35
  return { code, name: code, alpha3: undefined, languages: [] };
45
36
  }
46
- return { code, name: item.n, alpha3: item.y, languages: (_a = item.l) !== null && _a !== void 0 ? _a : [] };
37
+ return { code, name: item.n, alpha3: item.y, languages: item.l ?? [] };
47
38
  }
48
39
  }
49
40
  // noinspection JSUnusedGlobalSymbols
50
- exports.countryHandler = new CountryHandler();
51
- //# sourceMappingURL=country.handler.js.map
41
+ export const countryHandler = new CountryHandler();
@@ -1,3 +1,3 @@
1
- import type { CountryCode } from "./country-code";
2
- import type { CountryRaw } from "./index.types";
1
+ import { CountryCode } from "../literal/index.js";
2
+ import { CountryRaw } from "./index.types.js";
3
3
  export declare const countryMap: Record<CountryCode, CountryRaw>;