@empathyco/x-archetype-utils 2.0.0-alpha.14 → 2.0.0-alpha.16

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.
@@ -1,22 +1,22 @@
1
- /** The style payload interface. */
2
- export interface Style {
3
- /** Css source. */
4
- source: string;
5
- }
6
- export interface XCSSInjector {
7
- /** Function that will add the styles to the host. */
8
- addStyle: (style: Style) => void;
9
- /** @deprecated Use addHost method. */
10
- setHost: (el: Element | ShadowRoot) => void;
11
- /** Adds the element to the hosts set. */
12
- addHost: (el: Document | ShadowRoot) => void;
13
- /** Removes the element from the hosts set. */
14
- removeHost: (el: Document | ShadowRoot) => void;
15
- /** Set injector instance in the window object. */
16
- setInWindow: () => void;
17
- /** Check if the instance is set in the window object. */
18
- isInWindow: () => boolean;
19
- }
20
- export type WindowWithInjector = Window & {
21
- xCSSInjector?: XCSSInjector;
22
- };
1
+ /** The style payload interface. */
2
+ export interface Style {
3
+ /** Css source. */
4
+ source: string;
5
+ }
6
+ export interface XCSSInjector {
7
+ /** Function that will add the styles to the host. */
8
+ addStyle: (style: Style) => void;
9
+ /** @deprecated Use addHost method. */
10
+ setHost: (el: Element | ShadowRoot) => void;
11
+ /** Adds the element to the hosts set. */
12
+ addHost: (el: Document | ShadowRoot) => void;
13
+ /** Removes the element from the hosts set. */
14
+ removeHost: (el: Document | ShadowRoot) => void;
15
+ /** Set injector instance in the window object. */
16
+ setInWindow: () => void;
17
+ /** Check if the instance is set in the window object. */
18
+ isInWindow: () => boolean;
19
+ }
20
+ export type WindowWithInjector = Window & {
21
+ xCSSInjector?: XCSSInjector;
22
+ };
@@ -1,78 +1,78 @@
1
- import type { App } from 'vue';
2
- import type { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n';
3
- import type { AnyMessages, Device, I18nOptions, Locale } from './i18n.types';
4
- /**
5
- * I18n settings manager.
6
- *
7
- * @public
8
- */
9
- export declare class I18n<SomeMessages> {
10
- vueI18n: VueI18n<Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, Locale, false>;
11
- protected locale: Locale;
12
- protected device: Device;
13
- protected messages: Record<Locale, AnyMessages<SomeMessages>>;
14
- protected currentMessages: LocaleMessageObject;
15
- protected fallbackLocale: Locale;
16
- /**
17
- * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.
18
- *
19
- * @param options - The new {@link I18nOptions | i18n options}.
20
- * @param options.locale - i18n locale.
21
- * @param options.messages - i18n messages.
22
- * @param options.device - i18n device.
23
- * @param options.fallbackLocale - i18n fallbackLocale.
24
- */
25
- constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>);
26
- /**
27
- * Creates a new {@link I18n} instance.
28
- *
29
- * @param options - The new {@link I18nOptions | i18n options}.
30
- *
31
- * @returns The new instance.
32
- */
33
- static create<SomeMessages>(options: I18nOptions<SomeMessages>): Promise<I18n<SomeMessages>>;
34
- /**
35
- * Installs VueI18n plugin.
36
- *
37
- * @param vue - The Vue instance.
38
- */
39
- install(vue: App): void;
40
- /**
41
- * Tries to get a value from the messages object accessing it key by key.
42
- * When a key fails, takes the remaining key parts and tries to access the message
43
- * joining them into a single key.
44
- *
45
- * @param path - A dot separated key to access the message object.
46
- * @returns The message corresponding to the provided key, or empty string if it doesn't exist.
47
- */
48
- protected getMessageWithDotsInKey(path: string): string | null;
49
- /**
50
- * Sets the new locale and updates the messages accordingly.
51
- *
52
- * @param newLocale - The new locale.
53
- *
54
- * @returns The new messages.
55
- */
56
- setLocale(newLocale: Locale): Promise<void>;
57
- /**
58
- * Sets the new device and updates the messages accordingly.
59
- *
60
- * @param newDevice - The new device.
61
- *
62
- * @returns The new messages.
63
- */
64
- setDevice(newDevice: Device): Promise<void>;
65
- /**
66
- * Updates the current messages based on the new locale and/or device.
67
- */
68
- protected changeMessages(): Promise<void>;
69
- /**
70
- * Retrieves the corresponding messages for the set locale and device.
71
- *
72
- * @remarks By default, it merges `base` messages with the specific `device` ones. If there are
73
- * no messages for the current locale, the fallback locale is used instead.
74
- *
75
- * @returns The messages for the current locale and device.
76
- */
77
- protected getCurrentMessages(): Promise<LocaleMessageObject>;
78
- }
1
+ import type { App } from 'vue';
2
+ import type { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n';
3
+ import type { AnyMessages, Device, I18nOptions, Locale } from './i18n.types';
4
+ /**
5
+ * I18n settings manager.
6
+ *
7
+ * @public
8
+ */
9
+ export declare class I18n<SomeMessages> {
10
+ vueI18n: VueI18n<Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, Locale, false>;
11
+ protected locale: Locale;
12
+ protected device: Device;
13
+ protected messages: Record<Locale, AnyMessages<SomeMessages>>;
14
+ protected currentMessages: LocaleMessageObject;
15
+ protected fallbackLocale: Locale;
16
+ /**
17
+ * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.
18
+ *
19
+ * @param options - The new {@link I18nOptions | i18n options}.
20
+ * @param options.locale - i18n locale.
21
+ * @param options.messages - i18n messages.
22
+ * @param options.device - i18n device.
23
+ * @param options.fallbackLocale - i18n fallbackLocale.
24
+ */
25
+ constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>);
26
+ /**
27
+ * Creates a new {@link I18n} instance.
28
+ *
29
+ * @param options - The new {@link I18nOptions | i18n options}.
30
+ *
31
+ * @returns The new instance.
32
+ */
33
+ static create<SomeMessages>(options: I18nOptions<SomeMessages>): Promise<I18n<SomeMessages>>;
34
+ /**
35
+ * Installs VueI18n plugin.
36
+ *
37
+ * @param vue - The Vue instance.
38
+ */
39
+ install(vue: App): void;
40
+ /**
41
+ * Tries to get a value from the messages object accessing it key by key.
42
+ * When a key fails, takes the remaining key parts and tries to access the message
43
+ * joining them into a single key.
44
+ *
45
+ * @param path - A dot separated key to access the message object.
46
+ * @returns The message corresponding to the provided key, or empty string if it doesn't exist.
47
+ */
48
+ protected getMessageWithDotsInKey(path: string): string | null;
49
+ /**
50
+ * Sets the new locale and updates the messages accordingly.
51
+ *
52
+ * @param newLocale - The new locale.
53
+ *
54
+ * @returns The new messages.
55
+ */
56
+ setLocale(newLocale: Locale): Promise<void>;
57
+ /**
58
+ * Sets the new device and updates the messages accordingly.
59
+ *
60
+ * @param newDevice - The new device.
61
+ *
62
+ * @returns The new messages.
63
+ */
64
+ setDevice(newDevice: Device): Promise<void>;
65
+ /**
66
+ * Updates the current messages based on the new locale and/or device.
67
+ */
68
+ protected changeMessages(): Promise<void>;
69
+ /**
70
+ * Retrieves the corresponding messages for the set locale and device.
71
+ *
72
+ * @remarks By default, it merges `base` messages with the specific `device` ones. If there are
73
+ * no messages for the current locale, the fallback locale is used instead.
74
+ *
75
+ * @returns The messages for the current locale and device.
76
+ */
77
+ protected getCurrentMessages(): Promise<LocaleMessageObject>;
78
+ }
@@ -1,53 +1,53 @@
1
- import type { DeepPartial } from '@empathyco/x-utils';
2
- import type { I18n as VueI18n } from 'vue-i18n';
3
- /** Supported locales. */
4
- export type Locale = string;
5
- /** Supported devices. */
6
- export type Device = string;
7
- /** Union type containing both eager and lazy messages. */
8
- export type AnyMessages<SomeMessages> = MessagesByDevice<SomeMessages> | LoadLazyMessagesByDevice<SomeMessages>;
9
- /** A function that loads on demand the messages for a specific locale. */
10
- export type LoadLazyMessagesByDevice<SomeMessages> = () => Promise<{
11
- default: MessagesByDevice<SomeMessages>;
12
- }>;
13
- /**
14
- * An object containing a base property with all the existing messages and the overridden ones for
15
- * each device.
16
- */
17
- export interface MessagesByDevice<SomeMessages> {
18
- base: SomeMessages;
19
- [device: Device]: DeepPartial<SomeMessages>;
20
- }
21
- /**
22
- * I18n settings.
23
- */
24
- export interface I18nOptions<SomeMessages> {
25
- /** The initial messages. */
26
- messages: Record<Locale, AnyMessages<SomeMessages>>;
27
- /** The initial device. */
28
- device: Device;
29
- /** The locale to fall back if no matching locale is available. */
30
- fallbackLocale: Locale;
31
- /** The initial locale. */
32
- locale: Locale;
33
- }
34
- /**
35
- * The VueI18n instance that should be passed to the root Vue instance and some runtime utility
36
- * functions.
37
- */
38
- export interface I18nAPI {
39
- /** The Vue I18n instance that should be passed to the root Vue component. */
40
- readonly vueI18n: Readonly<VueI18n>;
41
- /**
42
- * Sets the new locale.
43
- *
44
- * @param newLocale - The new locale.
45
- */
46
- setLocale: (newLocale: Locale) => Promise<void>;
47
- /**
48
- * Sets the new device.
49
- *
50
- * @param newDevice - The new device.
51
- */
52
- setDevice: (newDevice: Device) => Promise<void>;
53
- }
1
+ import type { DeepPartial } from '@empathyco/x-utils';
2
+ import type { I18n as VueI18n } from 'vue-i18n';
3
+ /** Supported locales. */
4
+ export type Locale = string;
5
+ /** Supported devices. */
6
+ export type Device = string;
7
+ /** Union type containing both eager and lazy messages. */
8
+ export type AnyMessages<SomeMessages> = MessagesByDevice<SomeMessages> | LoadLazyMessagesByDevice<SomeMessages>;
9
+ /** A function that loads on demand the messages for a specific locale. */
10
+ export type LoadLazyMessagesByDevice<SomeMessages> = () => Promise<{
11
+ default: MessagesByDevice<SomeMessages>;
12
+ }>;
13
+ /**
14
+ * An object containing a base property with all the existing messages and the overridden ones for
15
+ * each device.
16
+ */
17
+ export interface MessagesByDevice<SomeMessages> {
18
+ base: SomeMessages;
19
+ [device: Device]: DeepPartial<SomeMessages>;
20
+ }
21
+ /**
22
+ * I18n settings.
23
+ */
24
+ export interface I18nOptions<SomeMessages> {
25
+ /** The initial messages. */
26
+ messages: Record<Locale, AnyMessages<SomeMessages>>;
27
+ /** The initial device. */
28
+ device: Device;
29
+ /** The locale to fall back if no matching locale is available. */
30
+ fallbackLocale: Locale;
31
+ /** The initial locale. */
32
+ locale: Locale;
33
+ }
34
+ /**
35
+ * The VueI18n instance that should be passed to the root Vue instance and some runtime utility
36
+ * functions.
37
+ */
38
+ export interface I18nAPI {
39
+ /** The Vue I18n instance that should be passed to the root Vue component. */
40
+ readonly vueI18n: Readonly<VueI18n>;
41
+ /**
42
+ * Sets the new locale.
43
+ *
44
+ * @param newLocale - The new locale.
45
+ */
46
+ setLocale: (newLocale: Locale) => Promise<void>;
47
+ /**
48
+ * Sets the new device.
49
+ *
50
+ * @param newDevice - The new device.
51
+ */
52
+ setDevice: (newDevice: Device) => Promise<void>;
53
+ }
@@ -1,6 +1,6 @@
1
- export * from './build/rollup/rollup.config';
2
- export * from './build/webpack/webpack.config';
3
- export * from './css-injector/css-injector';
4
- export * from './css-injector/css-injector.types';
5
- export * from './i18n/i18n.plugin';
6
- export * from './i18n/i18n.types';
1
+ export * from './build/rollup/rollup.config';
2
+ export * from './build/webpack/webpack.config';
3
+ export * from './css-injector/css-injector';
4
+ export * from './css-injector/css-injector.types';
5
+ export * from './i18n/i18n.plugin';
6
+ export * from './i18n/i18n.types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-archetype-utils",
3
- "version": "2.0.0-alpha.14",
3
+ "version": "2.0.0-alpha.16",
4
4
  "description": "Utilities for x-archetype",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -44,27 +44,27 @@
44
44
  "vue-i18n": "^9.14.4"
45
45
  },
46
46
  "dependencies": {
47
- "@empathyco/x-deep-merge": "^2.0.3-alpha.6",
48
- "@empathyco/x-utils": "^1.0.3-alpha.5",
47
+ "@empathyco/x-deep-merge": "^2.0.3-alpha.8",
48
+ "@empathyco/x-utils": "^1.0.3-alpha.6",
49
49
  "tslib": "~2.8.1",
50
50
  "vue-i18n": "~9.14.4"
51
51
  },
52
52
  "devDependencies": {
53
- "@types/jest": "27.5.0",
53
+ "@types/jest": "29.5.14",
54
54
  "@types/node": "22.15.29",
55
55
  "@vue/test-utils": "2.4.6",
56
- "jest": "27.5.0",
56
+ "jest": "29.7.0",
57
57
  "rimraf": "3.0.2",
58
58
  "rollup": "4.9.1",
59
59
  "rollup-plugin-copy": "3.5.0",
60
60
  "rollup-plugin-delete": "2.0.0",
61
61
  "rollup-plugin-typescript2": "0.36.0",
62
- "ts-jest": "27.1.0",
63
- "typescript": "4.9.4",
62
+ "ts-jest": "29.4.0",
63
+ "typescript": "5.8.3",
64
64
  "vue": "3.4.31"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "gitHead": "ba130cbae5c60280bc46d2946941c12f3af051ba"
69
+ "gitHead": "9aed796ace02864bd0a7feb81c150ce579c73353"
70
70
  }