@empathyco/x-archetype-utils 2.0.0-alpha.1 → 2.0.0-alpha.11

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # x-archetype-utils
2
2
 
3
- `x-archetype-utils` is a library that provides utilities to ease development. It's used in the [Interface X Archetype](https://github.com/empathyco/x-archetype) project.
3
+ `x-archetype-utils` is a library that provides utilities to ease development. It's used in the [Interface X Archetype](https://github.com/empathyco/x-archetype) project.
4
4
 
5
5
  ## Contributing
6
6
 
@@ -3,12 +3,12 @@
3
3
  const rollupCssInjectorConfig = {
4
4
  replace: {
5
5
  // Replace X CSS injector by our custom one.
6
- 'export default injectCss;': 'export default (css) => window.xCSSInjector.addStyle({ source: css });',
7
- delimiters: ['', '']
6
+ 'export default injectCss': 'export default (css) => window.xCSSInjector.addStyle({ source: css });',
7
+ delimiters: ['', ''],
8
8
  },
9
9
  styles: {
10
- mode: ['inject', (varname) => `window.xCSSInjector.addStyle({ source: ${varname} });`]
11
- }
10
+ mode: ['inject', (varname) => `window.xCSSInjector.addStyle({ source: ${varname} });`],
11
+ },
12
12
  };
13
13
 
14
14
  exports.rollupCssInjectorConfig = rollupCssInjectorConfig;
@@ -8,19 +8,19 @@ const webpackConfig = {
8
8
  {
9
9
  test: /\.ts|js|vue$/,
10
10
  enforce: 'pre',
11
- use: ['source-map-loader']
12
- }
13
- ]
11
+ use: ['source-map-loader'],
12
+ },
13
+ ],
14
14
  },
15
15
  output: {
16
- devtoolModuleFilenameTemplate: ({ resourcePath, hash, query }) => resourcePath.match(/\.vue$/) &&
16
+ devtoolModuleFilenameTemplate: ({ resourcePath, hash, query, }) => resourcePath.match(/\.vue$/) &&
17
17
  !query.match(/type=script/) &&
18
18
  !query.match(/\?rollup-plugin-vue=script.ts/)
19
19
  ? `webpack-generated:///${resourcePath}?${hash}`
20
20
  : `sources://${resourcePath}`,
21
- devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]'
22
- }
23
- }
21
+ devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
22
+ },
23
+ },
24
24
  };
25
25
 
26
26
  exports.webpackConfig = webpackConfig;
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * Instance of the injector that will be used across all the initializations.
5
- */
3
+ /** Singleton instance of the injector that will be used across all the initializations. */
6
4
  let instance = null;
7
5
  /**
8
6
  * Custom CSS injector that allows to inject styles into a host element.
@@ -17,9 +15,10 @@ class CssInjector {
17
15
  * @param setInWindow - Whether to set the injector instance in the window object.
18
16
  */
19
17
  constructor(setInWindow = true) {
20
- this.stylesQueue = [];
18
+ this.hosts = new Set();
19
+ this.stylesToAdopt = [];
21
20
  if (!(instance instanceof CssInjector)) {
22
- // eslint-disable-next-line @typescript-eslint/no-this-alias
21
+ // eslint-disable-next-line ts/no-this-alias
23
22
  instance = this;
24
23
  }
25
24
  if (setInWindow) {
@@ -28,28 +27,42 @@ class CssInjector {
28
27
  return instance;
29
28
  }
30
29
  /**
31
- * Adds the styles to the host element.
30
+ * Adds the style to the host element.
32
31
  *
33
- * @param styles - The styles to be added.
32
+ * @param style - The styles to be added.
33
+ * @param style.source - Styles source.
34
34
  */
35
- addStyle(styles) {
36
- this.stylesQueue.push(styles.source);
37
- if (this.host) {
38
- this.stylesQueue.forEach(styles => {
39
- const styleTag = document.createElement('style');
40
- styleTag.textContent = styles;
41
- this.host.appendChild(styleTag);
42
- });
43
- this.stylesQueue = [];
44
- }
35
+ addStyle(style) {
36
+ const sheet = new CSSStyleSheet();
37
+ sheet.replaceSync(style.source);
38
+ this.stylesToAdopt.push(sheet);
39
+ this.hosts.forEach(host => (host.adoptedStyleSheets = this.stylesToAdopt));
45
40
  }
46
41
  /**
47
- * Sets the host element.
42
+ * Sets the host element. Alias of addHost method.
48
43
  *
49
44
  * @param host - The host element.
45
+ * @deprecated Use addHost instead.
50
46
  */
51
47
  setHost(host) {
52
- this.host = host;
48
+ this.addHost(host instanceof ShadowRoot ? host : document);
49
+ }
50
+ /**
51
+ * Adds the element to the hosts set.
52
+ *
53
+ * @param host - The host element.
54
+ */
55
+ addHost(host) {
56
+ this.hosts.add(host);
57
+ host.adoptedStyleSheets = this.stylesToAdopt;
58
+ }
59
+ /**
60
+ * Removes the element from the hosts set.
61
+ *
62
+ * @param host - The host element to remove.
63
+ */
64
+ removeHost(host) {
65
+ this.hosts.delete(host);
53
66
  }
54
67
  /**
55
68
  * Sets the injector instance in the window object.
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var xDeepMerge = require('@empathyco/x-deep-merge');
3
4
  var xUtils = require('@empathyco/x-utils');
4
5
  var vueI18n = require('vue-i18n');
5
- var xDeepMerge = require('@empathyco/x-deep-merge');
6
6
 
7
7
  /**
8
8
  * I18n settings manager.
@@ -14,6 +14,10 @@ class I18n {
14
14
  * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.
15
15
  *
16
16
  * @param options - The new {@link I18nOptions | i18n options}.
17
+ * @param options.locale - i18n locale.
18
+ * @param options.messages - i18n messages.
19
+ * @param options.device - i18n device.
20
+ * @param options.fallbackLocale - i18n fallbackLocale.
17
21
  */
18
22
  constructor({ locale, messages, device, fallbackLocale }) {
19
23
  this.locale = locale;
@@ -40,15 +44,16 @@ class I18n {
40
44
  */
41
45
  install(vue) {
42
46
  this.vueI18n = vueI18n.createI18n({
47
+ legacy: false,
43
48
  locale: this.locale,
44
49
  silentFallbackWarn: true,
50
+ // eslint-disable-next-line ts/no-unsafe-assignment
45
51
  messages: this.currentMessages ? { [this.locale]: this.currentMessages } : {},
46
52
  missing: (_, key) => {
47
53
  var _a;
48
54
  return ((_a = this.getMessageWithDotsInKey(key)) !== null && _a !== void 0 ? _a : `[i18n] Key '${key}' is missing for locale: '${this.locale}'`);
49
- }
55
+ },
50
56
  });
51
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
52
57
  vue.use(this.vueI18n);
53
58
  }
54
59
  /**
@@ -61,12 +66,12 @@ class I18n {
61
66
  */
62
67
  getMessageWithDotsInKey(path) {
63
68
  // TO-DO Support function or array messages
64
- const message = path
65
- .split('.')
66
- .reduce((messages, key, index, pathParts) => {
69
+ // eslint-disable-next-line ts/no-unsafe-assignment
70
+ const message = path.split('.').reduce((messages, key, index, pathParts) => {
67
71
  var _a;
72
+ // eslint-disable-next-line ts/no-unsafe-return
68
73
  return xUtils.isObject(messages)
69
- ? (_a = messages[key]) !== null && _a !== void 0 ? _a : messages[pathParts.slice(index).join('.')]
74
+ ? ((_a = messages[key]) !== null && _a !== void 0 ? _a : messages[pathParts.slice(index).join('.')])
70
75
  : messages;
71
76
  }, this.currentMessages);
72
77
  return typeof message === 'string' ? message : null;
@@ -82,7 +87,7 @@ class I18n {
82
87
  if (this.locale !== newLocale) {
83
88
  this.locale = newLocale;
84
89
  await this.changeMessages();
85
- this.vueI18n.global.locale = this.locale;
90
+ this.vueI18n.global.locale.value = this.locale;
86
91
  }
87
92
  }
88
93
  /**
@@ -103,7 +108,6 @@ class I18n {
103
108
  */
104
109
  async changeMessages() {
105
110
  this.currentMessages = await this.getCurrentMessages();
106
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
107
111
  this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages);
108
112
  }
109
113
  /**
@@ -115,11 +119,9 @@ class I18n {
115
119
  * @returns The messages for the current locale and device.
116
120
  */
117
121
  async getCurrentMessages() {
118
- const rawMessages = this.locale in this.messages
119
- ? this.messages[this.locale]
120
- : this.messages[this.fallbackLocale];
122
+ const rawMessages = this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale];
121
123
  const messages = areLazyMessages(rawMessages) ? (await rawMessages()).default : rawMessages;
122
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
124
+ // eslint-disable-next-line ts/no-unsafe-return
123
125
  return xDeepMerge.deepMerge({}, messages.base, messages[this.device]);
124
126
  }
125
127
  }
package/dist/cjs/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var i18n_plugin = require('./i18n/i18n.plugin.js');
4
- var webpack_config = require('./build/webpack/webpack.config.js');
5
3
  var rollup_config = require('./build/rollup/rollup.config.js');
4
+ var webpack_config = require('./build/webpack/webpack.config.js');
6
5
  var cssInjector = require('./css-injector/css-injector.js');
6
+ var i18n_plugin = require('./i18n/i18n.plugin.js');
7
7
 
8
8
 
9
9
 
10
- exports.I18n = i18n_plugin.I18n;
11
- exports.webpackConfig = webpack_config.webpackConfig;
12
10
  exports.rollupCssInjectorConfig = rollup_config.rollupCssInjectorConfig;
11
+ exports.webpackConfig = webpack_config.webpackConfig;
13
12
  exports.CssInjector = cssInjector.CssInjector;
14
13
  exports.cssInjector = cssInjector.cssInjector;
14
+ exports.I18n = i18n_plugin.I18n;
@@ -1,12 +1,12 @@
1
1
  const rollupCssInjectorConfig = {
2
2
  replace: {
3
3
  // Replace X CSS injector by our custom one.
4
- 'export default injectCss;': 'export default (css) => window.xCSSInjector.addStyle({ source: css });',
5
- delimiters: ['', '']
4
+ 'export default injectCss': 'export default (css) => window.xCSSInjector.addStyle({ source: css });',
5
+ delimiters: ['', ''],
6
6
  },
7
7
  styles: {
8
- mode: ['inject', (varname) => `window.xCSSInjector.addStyle({ source: ${varname} });`]
9
- }
8
+ mode: ['inject', (varname) => `window.xCSSInjector.addStyle({ source: ${varname} });`],
9
+ },
10
10
  };
11
11
 
12
12
  export { rollupCssInjectorConfig };
@@ -6,19 +6,19 @@ const webpackConfig = {
6
6
  {
7
7
  test: /\.ts|js|vue$/,
8
8
  enforce: 'pre',
9
- use: ['source-map-loader']
10
- }
11
- ]
9
+ use: ['source-map-loader'],
10
+ },
11
+ ],
12
12
  },
13
13
  output: {
14
- devtoolModuleFilenameTemplate: ({ resourcePath, hash, query }) => resourcePath.match(/\.vue$/) &&
14
+ devtoolModuleFilenameTemplate: ({ resourcePath, hash, query, }) => resourcePath.match(/\.vue$/) &&
15
15
  !query.match(/type=script/) &&
16
16
  !query.match(/\?rollup-plugin-vue=script.ts/)
17
17
  ? `webpack-generated:///${resourcePath}?${hash}`
18
18
  : `sources://${resourcePath}`,
19
- devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]'
20
- }
21
- }
19
+ devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',
20
+ },
21
+ },
22
22
  };
23
23
 
24
24
  export { webpackConfig };
@@ -1,6 +1,4 @@
1
- /**
2
- * Instance of the injector that will be used across all the initializations.
3
- */
1
+ /** Singleton instance of the injector that will be used across all the initializations. */
4
2
  let instance = null;
5
3
  /**
6
4
  * Custom CSS injector that allows to inject styles into a host element.
@@ -15,9 +13,10 @@ class CssInjector {
15
13
  * @param setInWindow - Whether to set the injector instance in the window object.
16
14
  */
17
15
  constructor(setInWindow = true) {
18
- this.stylesQueue = [];
16
+ this.hosts = new Set();
17
+ this.stylesToAdopt = [];
19
18
  if (!(instance instanceof CssInjector)) {
20
- // eslint-disable-next-line @typescript-eslint/no-this-alias
19
+ // eslint-disable-next-line ts/no-this-alias
21
20
  instance = this;
22
21
  }
23
22
  if (setInWindow) {
@@ -26,28 +25,42 @@ class CssInjector {
26
25
  return instance;
27
26
  }
28
27
  /**
29
- * Adds the styles to the host element.
28
+ * Adds the style to the host element.
30
29
  *
31
- * @param styles - The styles to be added.
30
+ * @param style - The styles to be added.
31
+ * @param style.source - Styles source.
32
32
  */
33
- addStyle(styles) {
34
- this.stylesQueue.push(styles.source);
35
- if (this.host) {
36
- this.stylesQueue.forEach(styles => {
37
- const styleTag = document.createElement('style');
38
- styleTag.textContent = styles;
39
- this.host.appendChild(styleTag);
40
- });
41
- this.stylesQueue = [];
42
- }
33
+ addStyle(style) {
34
+ const sheet = new CSSStyleSheet();
35
+ sheet.replaceSync(style.source);
36
+ this.stylesToAdopt.push(sheet);
37
+ this.hosts.forEach(host => (host.adoptedStyleSheets = this.stylesToAdopt));
43
38
  }
44
39
  /**
45
- * Sets the host element.
40
+ * Sets the host element. Alias of addHost method.
46
41
  *
47
42
  * @param host - The host element.
43
+ * @deprecated Use addHost instead.
48
44
  */
49
45
  setHost(host) {
50
- this.host = host;
46
+ this.addHost(host instanceof ShadowRoot ? host : document);
47
+ }
48
+ /**
49
+ * Adds the element to the hosts set.
50
+ *
51
+ * @param host - The host element.
52
+ */
53
+ addHost(host) {
54
+ this.hosts.add(host);
55
+ host.adoptedStyleSheets = this.stylesToAdopt;
56
+ }
57
+ /**
58
+ * Removes the element from the hosts set.
59
+ *
60
+ * @param host - The host element to remove.
61
+ */
62
+ removeHost(host) {
63
+ this.hosts.delete(host);
51
64
  }
52
65
  /**
53
66
  * Sets the injector instance in the window object.
@@ -1,6 +1,6 @@
1
+ import { deepMerge } from '@empathyco/x-deep-merge';
1
2
  import { isObject } from '@empathyco/x-utils';
2
3
  import { createI18n } from 'vue-i18n';
3
- import { deepMerge } from '@empathyco/x-deep-merge';
4
4
 
5
5
  /**
6
6
  * I18n settings manager.
@@ -12,6 +12,10 @@ class I18n {
12
12
  * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.
13
13
  *
14
14
  * @param options - The new {@link I18nOptions | i18n options}.
15
+ * @param options.locale - i18n locale.
16
+ * @param options.messages - i18n messages.
17
+ * @param options.device - i18n device.
18
+ * @param options.fallbackLocale - i18n fallbackLocale.
15
19
  */
16
20
  constructor({ locale, messages, device, fallbackLocale }) {
17
21
  this.locale = locale;
@@ -38,15 +42,16 @@ class I18n {
38
42
  */
39
43
  install(vue) {
40
44
  this.vueI18n = createI18n({
45
+ legacy: false,
41
46
  locale: this.locale,
42
47
  silentFallbackWarn: true,
48
+ // eslint-disable-next-line ts/no-unsafe-assignment
43
49
  messages: this.currentMessages ? { [this.locale]: this.currentMessages } : {},
44
50
  missing: (_, key) => {
45
51
  var _a;
46
52
  return ((_a = this.getMessageWithDotsInKey(key)) !== null && _a !== void 0 ? _a : `[i18n] Key '${key}' is missing for locale: '${this.locale}'`);
47
- }
53
+ },
48
54
  });
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
50
55
  vue.use(this.vueI18n);
51
56
  }
52
57
  /**
@@ -59,12 +64,12 @@ class I18n {
59
64
  */
60
65
  getMessageWithDotsInKey(path) {
61
66
  // TO-DO Support function or array messages
62
- const message = path
63
- .split('.')
64
- .reduce((messages, key, index, pathParts) => {
67
+ // eslint-disable-next-line ts/no-unsafe-assignment
68
+ const message = path.split('.').reduce((messages, key, index, pathParts) => {
65
69
  var _a;
70
+ // eslint-disable-next-line ts/no-unsafe-return
66
71
  return isObject(messages)
67
- ? (_a = messages[key]) !== null && _a !== void 0 ? _a : messages[pathParts.slice(index).join('.')]
72
+ ? ((_a = messages[key]) !== null && _a !== void 0 ? _a : messages[pathParts.slice(index).join('.')])
68
73
  : messages;
69
74
  }, this.currentMessages);
70
75
  return typeof message === 'string' ? message : null;
@@ -80,7 +85,7 @@ class I18n {
80
85
  if (this.locale !== newLocale) {
81
86
  this.locale = newLocale;
82
87
  await this.changeMessages();
83
- this.vueI18n.global.locale = this.locale;
88
+ this.vueI18n.global.locale.value = this.locale;
84
89
  }
85
90
  }
86
91
  /**
@@ -101,7 +106,6 @@ class I18n {
101
106
  */
102
107
  async changeMessages() {
103
108
  this.currentMessages = await this.getCurrentMessages();
104
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
105
109
  this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages);
106
110
  }
107
111
  /**
@@ -113,11 +117,9 @@ class I18n {
113
117
  * @returns The messages for the current locale and device.
114
118
  */
115
119
  async getCurrentMessages() {
116
- const rawMessages = this.locale in this.messages
117
- ? this.messages[this.locale]
118
- : this.messages[this.fallbackLocale];
120
+ const rawMessages = this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale];
119
121
  const messages = areLazyMessages(rawMessages) ? (await rawMessages()).default : rawMessages;
120
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
122
+ // eslint-disable-next-line ts/no-unsafe-return
121
123
  return deepMerge({}, messages.base, messages[this.device]);
122
124
  }
123
125
  }
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { I18n } from './i18n/i18n.plugin.js';
2
- export { webpackConfig } from './build/webpack/webpack.config.js';
3
1
  export { rollupCssInjectorConfig } from './build/rollup/rollup.config.js';
2
+ export { webpackConfig } from './build/webpack/webpack.config.js';
4
3
  export { CssInjector, cssInjector } from './css-injector/css-injector.js';
4
+ export { I18n } from './i18n/i18n.plugin.js';
@@ -1,6 +1,6 @@
1
1
  export declare const rollupCssInjectorConfig: {
2
2
  replace: {
3
- 'export default injectCss;': string;
3
+ 'export default injectCss': string;
4
4
  delimiters: string[];
5
5
  };
6
6
  styles: {
@@ -27,7 +27,7 @@ export declare const webpackConfig: {
27
27
  }[];
28
28
  };
29
29
  output: {
30
- devtoolModuleFilenameTemplate: ({ resourcePath, hash, query }: webpackFilenameTemplateInfo) => string;
30
+ devtoolModuleFilenameTemplate: ({ resourcePath, hash, query, }: webpackFilenameTemplateInfo) => string;
31
31
  devtoolFallbackModuleFilenameTemplate: string;
32
32
  };
33
33
  };
@@ -1,12 +1,12 @@
1
- import { XCSSInjector } from './css-injector.types';
1
+ import type { Style, XCSSInjector } from './css-injector.types';
2
2
  /**
3
3
  * Custom CSS injector that allows to inject styles into a host element.
4
4
  *
5
5
  * @public
6
6
  */
7
7
  export declare class CssInjector implements XCSSInjector {
8
- protected host: Element | ShadowRoot;
9
- protected stylesQueue: string[];
8
+ protected hosts: Set<ShadowRoot | Document>;
9
+ protected stylesToAdopt: CSSStyleSheet[];
10
10
  /**
11
11
  * Initializes the instance of the injector if it's not already initialized and sets it in the
12
12
  * window object if it's required.
@@ -15,19 +15,31 @@ export declare class CssInjector implements XCSSInjector {
15
15
  */
16
16
  constructor(setInWindow?: boolean);
17
17
  /**
18
- * Adds the styles to the host element.
18
+ * Adds the style to the host element.
19
19
  *
20
- * @param styles - The styles to be added.
20
+ * @param style - The styles to be added.
21
+ * @param style.source - Styles source.
21
22
  */
22
- addStyle(styles: {
23
- source: string;
24
- }): void;
23
+ addStyle(style: Style): void;
25
24
  /**
26
- * Sets the host element.
25
+ * Sets the host element. Alias of addHost method.
27
26
  *
28
27
  * @param host - The host element.
28
+ * @deprecated Use addHost instead.
29
29
  */
30
30
  setHost(host: Element | ShadowRoot): void;
31
+ /**
32
+ * Adds the element to the hosts set.
33
+ *
34
+ * @param host - The host element.
35
+ */
36
+ addHost(host: Document | ShadowRoot): void;
37
+ /**
38
+ * Removes the element from the hosts set.
39
+ *
40
+ * @param host - The host element to remove.
41
+ */
42
+ removeHost(host: Document | ShadowRoot): void;
31
43
  /**
32
44
  * Sets the injector instance in the window object.
33
45
  */
@@ -1,10 +1,17 @@
1
+ /** The style payload interface. */
2
+ export interface Style {
3
+ /** Css source. */
4
+ source: string;
5
+ }
1
6
  export interface XCSSInjector {
2
7
  /** Function that will add the styles to the host. */
3
- addStyle: (styles: {
4
- source: string;
5
- }) => void;
6
- /** Function setting the host for the injector. */
8
+ addStyle: (style: Style) => void;
9
+ /** @deprecated Use addHost method. */
7
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;
8
15
  /** Set injector instance in the window object. */
9
16
  setInWindow: () => void;
10
17
  /** Check if the instance is set in the window object. */
@@ -1,13 +1,13 @@
1
- import { App } from 'vue';
2
- import { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n';
3
- import { AnyMessages, Device, I18nOptions, Locale } from './i18n.types';
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
4
  /**
5
5
  * I18n settings manager.
6
6
  *
7
7
  * @public
8
8
  */
9
9
  export declare class I18n<SomeMessages> {
10
- vueI18n: VueI18n;
10
+ vueI18n: VueI18n<Record<string, unknown>, Record<string, unknown>, Record<string, unknown>, Locale, false>;
11
11
  protected locale: Locale;
12
12
  protected device: Device;
13
13
  protected messages: Record<Locale, AnyMessages<SomeMessages>>;
@@ -17,6 +17,10 @@ export declare class I18n<SomeMessages> {
17
17
  * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.
18
18
  *
19
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.
20
24
  */
21
25
  constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>);
22
26
  /**
@@ -1,5 +1,5 @@
1
- import { DeepPartial } from '@empathyco/x-utils';
2
- import { I18n as VueI18n } from 'vue-i18n';
1
+ import type { DeepPartial } from '@empathyco/x-utils';
2
+ import type { I18n as VueI18n } from 'vue-i18n';
3
3
  /** Supported locales. */
4
4
  export type Locale = string;
5
5
  /** Supported devices. */
@@ -1,6 +1,6 @@
1
- export * from './i18n/i18n.plugin';
2
- export * from './i18n/i18n.types';
3
- export * from './build/webpack/webpack.config';
4
1
  export * from './build/rollup/rollup.config';
2
+ export * from './build/webpack/webpack.config';
5
3
  export * from './css-injector/css-injector';
6
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,10 +1,15 @@
1
1
  {
2
2
  "name": "@empathyco/x-archetype-utils",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.11",
4
4
  "description": "Utilities for x-archetype",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://github.com/empathyco/x/tree/main/packages/x-archetype-utils#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/empathyco/x.git",
11
+ "directory": "packages/x-archetype-utils"
12
+ },
8
13
  "keywords": [
9
14
  "utils",
10
15
  "x",
@@ -16,13 +21,8 @@
16
21
  "files": [
17
22
  "dist"
18
23
  ],
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/empathyco/x.git",
22
- "directory": "packages/x-archetype-utils"
23
- },
24
24
  "engines": {
25
- "node": ">=18"
25
+ "node": ">=22"
26
26
  },
27
27
  "scripts": {
28
28
  "prebuild": "rimraf dist ./*.tgz",
@@ -30,37 +30,41 @@
30
30
  "build:cjs": "tsc --project tsconfig.cjs.json",
31
31
  "build:esm": "tsc --project tsconfig.esm.json",
32
32
  "postbuild": "pnpm pack",
33
- "lint": "eslint . --ext .ts",
33
+ "lint": "eslint --fix",
34
+ "lint:check": "eslint",
35
+ "lint:inspect": "eslint --inspect-config .",
36
+ "format": "prettier --write .",
37
+ "format:check": "prettier --check .",
34
38
  "test": "jest",
35
39
  "test:unit": "jest",
36
40
  "prepublishOnly": "pnpm run build"
37
41
  },
42
+ "peerDependencies": {
43
+ "vue": "^3.4.31",
44
+ "vue-i18n": "^9.14.0"
45
+ },
38
46
  "dependencies": {
39
- "@empathyco/x-deep-merge": "^2.0.3-alpha.1",
40
- "@empathyco/x-utils": "^1.0.3-alpha.1",
47
+ "@empathyco/x-deep-merge": "^2.0.3-alpha.4",
48
+ "@empathyco/x-utils": "^1.0.3-alpha.3",
41
49
  "tslib": "~2.6.0",
42
50
  "vue-i18n": "~9.14.0"
43
51
  },
44
52
  "devDependencies": {
45
- "@types/jest": "~27.5.0",
46
- "@types/node": "~18.19.0",
47
- "@vue/test-utils": "~2.4.6",
48
- "jest": "~27.5.0",
49
- "rimraf": "~3.0.2",
50
- "rollup": "~4.9.1",
51
- "rollup-plugin-copy": "~3.5.0",
52
- "rollup-plugin-delete": "~2.0.0",
53
- "rollup-plugin-typescript2": "~0.36.0",
54
- "ts-jest": "~27.1.0",
55
- "typescript": "~4.9.4",
56
- "vue": "~3.4.31"
57
- },
58
- "peerDependencies": {
59
- "vue": "^3.4.31",
60
- "vue-i18n": "^9.14.0"
53
+ "@types/jest": "27.5.0",
54
+ "@types/node": "22.15.29",
55
+ "@vue/test-utils": "2.4.6",
56
+ "jest": "27.5.0",
57
+ "rimraf": "3.0.2",
58
+ "rollup": "4.9.1",
59
+ "rollup-plugin-copy": "3.5.0",
60
+ "rollup-plugin-delete": "2.0.0",
61
+ "rollup-plugin-typescript2": "0.36.0",
62
+ "ts-jest": "27.1.0",
63
+ "typescript": "4.9.4",
64
+ "vue": "3.4.31"
61
65
  },
62
66
  "publishConfig": {
63
67
  "access": "public"
64
68
  },
65
- "gitHead": "701cfef5b869a46966240c38bcaa53c56e9db1aa"
69
+ "gitHead": "f83636f1f0d97adc64aa473a9bbd03034cdddb6e"
66
70
  }