@empathyco/x-archetype-utils 2.0.0-alpha.36 → 2.0.0-alpha.38

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/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@empathyco/x-deep-merge"),h=require("@empathyco/x-utils"),d=require("vue-i18n"),g={replace:{"export default injectCss":"export default (css) => window.xCSSInjector.addStyle({ source: css });",delimiters:["",""]},styles:{mode:["inject",n=>`window.xCSSInjector.addStyle({ source: ${n} });`]}},p={transpileDependencies:["@empathyco/x-components"],configureWebpack:{module:{rules:[{test:/\.ts|js|vue$/,enforce:"pre",use:["source-map-loader"]}]},output:{devtoolModuleFilenameTemplate:({resourcePath:n,hash:e,query:s})=>n.match(/\.vue$/)&&!s.match(/type=script/)&&!s.match(/\?rollup-plugin-vue=script.ts/)?`webpack-generated:///${n}?${e}`:`sources://${n}`,devtoolFallbackModuleFilenameTemplate:"webpack:///[resource-path]?[hash]"}}};let o=null;class a{constructor(e=!0){return this.hosts=new Set,this.stylesToAdopt=[],o instanceof a||(o=this),e&&this.setInWindow(),o}addStyle(e){const s=new CSSStyleSheet;s.replaceSync(e.source),this.stylesToAdopt.push(s),this.hosts.forEach(t=>t.adoptedStyleSheets=this.stylesToAdopt)}setHost(e){this.addHost(e instanceof ShadowRoot?e:document)}addHost(e){this.hosts.add(e),e.adoptedStyleSheets=this.stylesToAdopt}removeHost(e){this.hosts.delete(e)}setInWindow(){typeof window<"u"&&o&&(window.xCSSInjector=o)}isInWindow(){return typeof window>"u"?!1:window.xCSSInjector===o}}const f=new a(typeof window<"u");class c{constructor({locale:e,messages:s,device:t,fallbackLocale:i}){this.locale=e,this.device=t,this.messages=s,this.fallbackLocale=i}static async create(e){const s=new c(e);return s.currentMessages=await s.getCurrentMessages(),s}install(e){this.vueI18n=d.createI18n({legacy:!1,locale:this.locale,silentFallbackWarn:!0,messages:this.currentMessages?{[this.locale]:this.currentMessages}:{},missing:(s,t)=>this.getMessageWithDotsInKey(t)??`[i18n] Key '${t}' is missing for locale: '${this.locale}'`}),e.use(this.vueI18n)}getMessageWithDotsInKey(e){const s=e.split(".").reduce((t,i,l,r)=>h.isObject(t)?t[i]??t[r.slice(l).join(".")]:t,this.currentMessages);return typeof s=="string"?s:null}async setLocale(e){this.locale!==e&&(this.locale=e,await this.changeMessages(),this.vueI18n.global.locale.value=this.locale)}async setDevice(e){this.device!==e&&(this.device=e,await this.changeMessages())}async changeMessages(){this.currentMessages=await this.getCurrentMessages(),this.vueI18n.global.setLocaleMessage(this.locale,this.currentMessages)}async getCurrentMessages(){const e=this.locale in this.messages?this.messages[this.locale]:this.messages[this.fallbackLocale],s=w(e)?(await e()).default:e;return u.deepMerge({},s.base,s[this.device])}}function w(n){return typeof n=="function"}exports.CssInjector=a;exports.I18n=c;exports.cssInjector=f;exports.rollupCssInjectorConfig=g;exports.webpackConfig=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@empathyco/x-utils"),u=require("vue-i18n"),d={replace:{"export default injectCss":"export default (css) => window.xCSSInjector.addStyle({ source: css });",delimiters:["",""]},styles:{mode:["inject",n=>`window.xCSSInjector.addStyle({ source: ${n} });`]}},g={transpileDependencies:["@empathyco/x-components"],configureWebpack:{module:{rules:[{test:/\.ts|js|vue$/,enforce:"pre",use:["source-map-loader"]}]},output:{devtoolModuleFilenameTemplate:({resourcePath:n,hash:e,query:s})=>n.match(/\.vue$/)&&!s.match(/type=script/)&&!s.match(/\?rollup-plugin-vue=script.ts/)?`webpack-generated:///${n}?${e}`:`sources://${n}`,devtoolFallbackModuleFilenameTemplate:"webpack:///[resource-path]?[hash]"}}};let a=null;class o{constructor(e=!0){return this.hosts=new Set,this.stylesToAdopt=[],a instanceof o||(a=this),e&&this.setInWindow(),a}addStyle(e){const s=new CSSStyleSheet;s.replaceSync(e.source),this.stylesToAdopt.push(s),this.hosts.forEach(t=>t.adoptedStyleSheets=this.stylesToAdopt)}setHost(e){this.addHost(e instanceof ShadowRoot?e:document)}addHost(e){this.hosts.add(e),e.adoptedStyleSheets=this.stylesToAdopt}removeHost(e){this.hosts.delete(e)}setInWindow(){typeof window<"u"&&a&&(window.xCSSInjector=a)}isInWindow(){return typeof window>"u"?!1:window.xCSSInjector===a}}const p=new o(typeof window<"u");class c{constructor({locale:e,messages:s,device:t,fallbackLocale:i}){this.locale=e,this.device=t,this.messages=s,this.fallbackLocale=i}static async create(e){const s=new c(e);return s.currentMessages=await s.getCurrentMessages(),s}install(e){this.vueI18n=u.createI18n({legacy:!1,locale:this.locale,silentFallbackWarn:!0,messages:this.currentMessages?{[this.locale]:this.currentMessages}:{},missing:(s,t)=>this.getMessageWithDotsInKey(t)??`[i18n] Key '${t}' is missing for locale: '${this.locale}'`}),e.use(this.vueI18n)}getMessageWithDotsInKey(e){const s=e.split(".").reduce((t,i,r,h)=>l.isObject(t)?t[i]??t[h.slice(r).join(".")]:t,this.currentMessages);return typeof s=="string"?s:null}async setLocale(e){this.locale!==e&&(this.locale=e,await this.changeMessages(),this.vueI18n.global.locale.value=this.locale)}async setDevice(e){this.device!==e&&(this.device=e,await this.changeMessages())}async changeMessages(){this.currentMessages=await this.getCurrentMessages(),this.vueI18n.global.setLocaleMessage(this.locale,this.currentMessages)}async getCurrentMessages(){const e=this.locale in this.messages?this.messages[this.locale]:this.messages[this.fallbackLocale],s=f(e)?(await e()).default:e;return l.deepMerge({},s.base,s[this.device])}}function f(n){return typeof n=="function"}exports.CssInjector=o;exports.I18n=c;exports.cssInjector=p;exports.rollupCssInjectorConfig=d;exports.webpackConfig=g;
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/build/rollup/rollup.config.ts","../src/build/webpack/webpack.config.ts","../src/css-injector/css-injector.ts","../src/i18n/i18n.plugin.ts"],"sourcesContent":["export const rollupCssInjectorConfig = {\n replace: {\n // Replace X CSS injector by our custom one.\n 'export default injectCss':\n 'export default (css) => window.xCSSInjector.addStyle({ source: css });',\n delimiters: ['', ''],\n },\n styles: {\n mode: ['inject', (varname: string) => `window.xCSSInjector.addStyle({ source: ${varname} });`],\n },\n}\n","/**.\n * Self-made interface since Webpack does not provide a type for this object.\n * Https://github.com/webpack/webpack/blob/main/declarations/WebpackOptions.d.ts#L463\n *\n * @internal\n */\ninterface webpackFilenameTemplateInfo {\n identifier: string\n shortIdentifier: string\n resource: string\n resourcePath: string\n absoluteResourcePath: string\n allLoaders: string\n query: string\n moduleId: string\n hash: string\n namespace: string\n}\n\nexport const webpackConfig = {\n transpileDependencies: ['@empathyco/x-components'],\n configureWebpack: {\n module: {\n rules: [\n {\n test: /\\.ts|js|vue$/,\n enforce: 'pre',\n use: ['source-map-loader'],\n },\n ],\n },\n output: {\n devtoolModuleFilenameTemplate: ({\n resourcePath,\n hash,\n query,\n }: webpackFilenameTemplateInfo) =>\n resourcePath.match(/\\.vue$/) &&\n !query.match(/type=script/) &&\n !query.match(/\\?rollup-plugin-vue=script.ts/)\n ? `webpack-generated:///${resourcePath}?${hash}`\n : `sources://${resourcePath}`,\n devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',\n },\n },\n}\n","import type { Style, WindowWithInjector, XCSSInjector } from './css-injector.types'\n\n/** Singleton instance of the injector that will be used across all the initializations. */\nlet instance: CssInjector | null = null\n\n/**\n * Custom CSS injector that allows to inject styles into a host element.\n *\n * @public\n */\nexport class CssInjector implements XCSSInjector {\n protected hosts = new Set<Document | ShadowRoot>()\n protected stylesToAdopt: CSSStyleSheet[] = []\n\n /**\n * Initializes the instance of the injector if it's not already initialized and sets it in the\n * window object if it's required.\n *\n * @param setInWindow - Whether to set the injector instance in the window object.\n */\n public constructor(setInWindow = true) {\n if (!(instance instanceof CssInjector)) {\n // eslint-disable-next-line ts/no-this-alias\n instance = this\n }\n\n if (setInWindow) {\n this.setInWindow()\n }\n\n return instance\n }\n\n /**\n * Adds the style to the host element.\n *\n * @param style - The styles to be added.\n * @param style.source - Styles source.\n */\n addStyle(style: Style): void {\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(style.source)\n this.stylesToAdopt.push(sheet)\n this.hosts.forEach(host => (host.adoptedStyleSheets = this.stylesToAdopt))\n }\n\n /**\n * Sets the host element. Alias of addHost method.\n *\n * @param host - The host element.\n * @deprecated Use addHost instead.\n */\n setHost(host: Element | ShadowRoot): void {\n this.addHost(host instanceof ShadowRoot ? host : document)\n }\n\n /**\n * Adds the element to the hosts set.\n *\n * @param host - The host element.\n */\n addHost(host: Document | ShadowRoot): void {\n this.hosts.add(host)\n host.adoptedStyleSheets = this.stylesToAdopt\n }\n\n /**\n * Removes the element from the hosts set.\n *\n * @param host - The host element to remove.\n */\n removeHost(host: Document | ShadowRoot): void {\n this.hosts.delete(host)\n }\n\n /**\n * Sets the injector instance in the window object.\n */\n setInWindow(): void {\n if (typeof window !== 'undefined' && instance) {\n ;(window as WindowWithInjector).xCSSInjector = instance\n }\n }\n\n /**\n * Checks if the injector instance is in the window object.\n *\n * @returns Whether the injector instance is in the window object.\n */\n isInWindow(): boolean {\n return typeof window === 'undefined'\n ? false\n : (window as WindowWithInjector).xCSSInjector === instance\n }\n}\n\n/**\n * Instance of the injector.\n *\n * @public\n */\nexport const cssInjector = new CssInjector(typeof window !== 'undefined')\n","import type { App } from 'vue'\nimport type { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n'\nimport type {\n AnyMessages,\n Device,\n I18nOptions,\n LoadLazyMessagesByDevice,\n Locale,\n} from './i18n.types'\nimport { deepMerge } from '@empathyco/x-deep-merge'\nimport { isObject } from '@empathyco/x-utils'\nimport { createI18n } from 'vue-i18n'\n\n/**\n * I18n settings manager.\n *\n * @public\n */\nexport class I18n<SomeMessages> {\n public vueI18n!: VueI18n<\n Record<string, unknown>,\n Record<string, unknown>,\n Record<string, unknown>,\n Locale,\n false\n >\n protected locale!: Locale\n protected device!: Device\n protected messages!: Record<Locale, AnyMessages<SomeMessages>>\n protected currentMessages!: LocaleMessageObject\n protected fallbackLocale!: Locale\n\n /**\n * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n * @param options.locale - i18n locale.\n * @param options.messages - i18n messages.\n * @param options.device - i18n device.\n * @param options.fallbackLocale - i18n fallbackLocale.\n */\n public constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>) {\n this.locale = locale\n this.device = device\n this.messages = messages\n this.fallbackLocale = fallbackLocale\n }\n\n /**\n * Creates a new {@link I18n} instance.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n *\n * @returns The new instance.\n */\n static async create<SomeMessages>(\n options: I18nOptions<SomeMessages>,\n ): Promise<I18n<SomeMessages>> {\n const instance = new I18n(options)\n instance.currentMessages = await instance.getCurrentMessages()\n return instance\n }\n\n /**\n * Installs VueI18n plugin.\n *\n * @param vue - The Vue instance.\n */\n install(vue: App): void {\n this.vueI18n = createI18n({\n legacy: false,\n locale: this.locale,\n silentFallbackWarn: true,\n // eslint-disable-next-line ts/no-unsafe-assignment\n messages: this.currentMessages ? ({ [this.locale]: this.currentMessages } as any) : {},\n missing: (_, key: string) => {\n return (\n this.getMessageWithDotsInKey(key) ??\n `[i18n] Key '${key}' is missing for locale: '${this.locale}'`\n )\n },\n })\n vue.use(this.vueI18n)\n }\n\n /**\n * Tries to get a value from the messages object accessing it key by key.\n * When a key fails, takes the remaining key parts and tries to access the message\n * joining them into a single key.\n *\n * @param path - A dot separated key to access the message object.\n * @returns The message corresponding to the provided key, or empty string if it doesn't exist.\n */\n protected getMessageWithDotsInKey(path: string): string | null {\n // TO-DO Support function or array messages\n // eslint-disable-next-line ts/no-unsafe-assignment\n const message = path.split('.').reduce<any>(\n (messages, key, index, pathParts) =>\n // eslint-disable-next-line ts/no-unsafe-return\n isObject(messages)\n ? (messages[key] ?? messages[pathParts.slice(index).join('.')])\n : messages,\n this.currentMessages,\n )\n return typeof message === 'string' ? message : null\n }\n\n /**\n * Sets the new locale and updates the messages accordingly.\n *\n * @param newLocale - The new locale.\n *\n * @returns The new messages.\n */\n async setLocale(newLocale: Locale): Promise<void> {\n if (this.locale !== newLocale) {\n this.locale = newLocale\n\n await this.changeMessages()\n this.vueI18n.global.locale.value = this.locale\n }\n }\n\n /**\n * Sets the new device and updates the messages accordingly.\n *\n * @param newDevice - The new device.\n *\n * @returns The new messages.\n */\n async setDevice(newDevice: Device): Promise<void> {\n if (this.device !== newDevice) {\n this.device = newDevice\n\n await this.changeMessages()\n }\n }\n\n /**\n * Updates the current messages based on the new locale and/or device.\n */\n protected async changeMessages(): Promise<void> {\n this.currentMessages = await this.getCurrentMessages()\n\n this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages)\n }\n\n /**\n * Retrieves the corresponding messages for the set locale and device.\n *\n * @remarks By default, it merges `base` messages with the specific `device` ones. If there are\n * no messages for the current locale, the fallback locale is used instead.\n *\n * @returns The messages for the current locale and device.\n */\n protected async getCurrentMessages(): Promise<LocaleMessageObject> {\n const rawMessages =\n this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale]\n\n const messages = areLazyMessages(rawMessages) ? (await rawMessages()).default : rawMessages\n // eslint-disable-next-line ts/no-unsafe-return\n return deepMerge({}, messages.base, messages[this.device])\n }\n}\n\n/**\n * Type-guard to check if the passed messages should be lazy-loaded.\n *\n * @param messages - The messages to check.\n *\n * @returns True if the messages are lazy or false otherwise.\n */\nfunction areLazyMessages<SomeMessages>(\n messages: AnyMessages<SomeMessages>,\n): messages is LoadLazyMessagesByDevice<SomeMessages> {\n return typeof messages === 'function'\n}\n"],"names":["rollupCssInjectorConfig","varname","webpackConfig","resourcePath","hash","query","instance","CssInjector","setInWindow","style","sheet","host","cssInjector","I18n","locale","messages","device","fallbackLocale","options","vue","createI18n","_","key","path","message","index","pathParts","isObject","newLocale","newDevice","rawMessages","areLazyMessages","deepMerge"],"m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Ef,CAKA,MAAgB,gBAAgC,CAC9C,KAAK,gBAAkB,MAAM,KAAK,mBAAA,EAElC,KAAK,QAAQ,OAAO,iBAAiB,KAAK,OAAQ,KAAK,eAAe,CACxE,CAUA,MAAgB,oBAAmD,CACjE,MAAMC,EACJ,KAAK,UAAU,KAAK,SAAW,KAAK,SAAS,KAAK,MAAM,EAAI,KAAK,SAAS,KAAK,cAAc,EAEzFf,EAAWgB,EAAgBD,CAAW,GAAK,MAAMA,EAAA,GAAe,QAAUA,EAEhF,OAAOE,EAAAA,UAAU,CAAA,EAAIjB,EAAS,KAAMA,EAAS,KAAK,MAAM,CAAC,CAC3D,CACF,CASA,SAASgB,EACPhB,EACoD,CACpD,OAAO,OAAOA,GAAa,UAC7B"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/build/rollup/rollup.config.ts","../src/build/webpack/webpack.config.ts","../src/css-injector/css-injector.ts","../src/i18n/i18n.plugin.ts"],"sourcesContent":["export const rollupCssInjectorConfig = {\n replace: {\n // Replace X CSS injector by our custom one.\n 'export default injectCss':\n 'export default (css) => window.xCSSInjector.addStyle({ source: css });',\n delimiters: ['', ''],\n },\n styles: {\n mode: ['inject', (varname: string) => `window.xCSSInjector.addStyle({ source: ${varname} });`],\n },\n}\n","/**.\n * Self-made interface since Webpack does not provide a type for this object.\n * Https://github.com/webpack/webpack/blob/main/declarations/WebpackOptions.d.ts#L463\n *\n * @internal\n */\ninterface webpackFilenameTemplateInfo {\n identifier: string\n shortIdentifier: string\n resource: string\n resourcePath: string\n absoluteResourcePath: string\n allLoaders: string\n query: string\n moduleId: string\n hash: string\n namespace: string\n}\n\nexport const webpackConfig = {\n transpileDependencies: ['@empathyco/x-components'],\n configureWebpack: {\n module: {\n rules: [\n {\n test: /\\.ts|js|vue$/,\n enforce: 'pre',\n use: ['source-map-loader'],\n },\n ],\n },\n output: {\n devtoolModuleFilenameTemplate: ({\n resourcePath,\n hash,\n query,\n }: webpackFilenameTemplateInfo) =>\n resourcePath.match(/\\.vue$/) &&\n !query.match(/type=script/) &&\n !query.match(/\\?rollup-plugin-vue=script.ts/)\n ? `webpack-generated:///${resourcePath}?${hash}`\n : `sources://${resourcePath}`,\n devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',\n },\n },\n}\n","import type { Style, WindowWithInjector, XCSSInjector } from './css-injector.types'\n\n/** Singleton instance of the injector that will be used across all the initializations. */\nlet instance: CssInjector | null = null\n\n/**\n * Custom CSS injector that allows to inject styles into a host element.\n *\n * @public\n */\nexport class CssInjector implements XCSSInjector {\n protected hosts = new Set<Document | ShadowRoot>()\n protected stylesToAdopt: CSSStyleSheet[] = []\n\n /**\n * Initializes the instance of the injector if it's not already initialized and sets it in the\n * window object if it's required.\n *\n * @param setInWindow - Whether to set the injector instance in the window object.\n */\n public constructor(setInWindow = true) {\n if (!(instance instanceof CssInjector)) {\n // eslint-disable-next-line ts/no-this-alias\n instance = this\n }\n\n if (setInWindow) {\n this.setInWindow()\n }\n\n return instance\n }\n\n /**\n * Adds the style to the host element.\n *\n * @param style - The styles to be added.\n * @param style.source - Styles source.\n */\n addStyle(style: Style): void {\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(style.source)\n this.stylesToAdopt.push(sheet)\n this.hosts.forEach(host => (host.adoptedStyleSheets = this.stylesToAdopt))\n }\n\n /**\n * Sets the host element. Alias of addHost method.\n *\n * @param host - The host element.\n * @deprecated Use addHost instead.\n */\n setHost(host: Element | ShadowRoot): void {\n this.addHost(host instanceof ShadowRoot ? host : document)\n }\n\n /**\n * Adds the element to the hosts set.\n *\n * @param host - The host element.\n */\n addHost(host: Document | ShadowRoot): void {\n this.hosts.add(host)\n host.adoptedStyleSheets = this.stylesToAdopt\n }\n\n /**\n * Removes the element from the hosts set.\n *\n * @param host - The host element to remove.\n */\n removeHost(host: Document | ShadowRoot): void {\n this.hosts.delete(host)\n }\n\n /**\n * Sets the injector instance in the window object.\n */\n setInWindow(): void {\n if (typeof window !== 'undefined' && instance) {\n ;(window as WindowWithInjector).xCSSInjector = instance\n }\n }\n\n /**\n * Checks if the injector instance is in the window object.\n *\n * @returns Whether the injector instance is in the window object.\n */\n isInWindow(): boolean {\n return typeof window === 'undefined'\n ? false\n : (window as WindowWithInjector).xCSSInjector === instance\n }\n}\n\n/**\n * Instance of the injector.\n *\n * @public\n */\nexport const cssInjector = new CssInjector(typeof window !== 'undefined')\n","import type { App } from 'vue'\nimport type { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n'\nimport type {\n AnyMessages,\n Device,\n I18nOptions,\n LoadLazyMessagesByDevice,\n Locale,\n} from './i18n.types'\nimport { deepMerge, isObject } from '@empathyco/x-utils'\nimport { createI18n } from 'vue-i18n'\n\n/**\n * I18n settings manager.\n *\n * @public\n */\nexport class I18n<SomeMessages> {\n public vueI18n!: VueI18n<\n Record<string, unknown>,\n Record<string, unknown>,\n Record<string, unknown>,\n Locale,\n false\n >\n protected locale!: Locale\n protected device!: Device\n protected messages!: Record<Locale, AnyMessages<SomeMessages>>\n protected currentMessages!: LocaleMessageObject\n protected fallbackLocale!: Locale\n\n /**\n * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n * @param options.locale - i18n locale.\n * @param options.messages - i18n messages.\n * @param options.device - i18n device.\n * @param options.fallbackLocale - i18n fallbackLocale.\n */\n public constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>) {\n this.locale = locale\n this.device = device\n this.messages = messages\n this.fallbackLocale = fallbackLocale\n }\n\n /**\n * Creates a new {@link I18n} instance.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n *\n * @returns The new instance.\n */\n static async create<SomeMessages>(\n options: I18nOptions<SomeMessages>,\n ): Promise<I18n<SomeMessages>> {\n const instance = new I18n(options)\n instance.currentMessages = await instance.getCurrentMessages()\n return instance\n }\n\n /**\n * Installs VueI18n plugin.\n *\n * @param vue - The Vue instance.\n */\n install(vue: App): void {\n this.vueI18n = createI18n({\n legacy: false,\n locale: this.locale,\n silentFallbackWarn: true,\n // eslint-disable-next-line ts/no-unsafe-assignment\n messages: this.currentMessages ? ({ [this.locale]: this.currentMessages } as any) : {},\n missing: (_, key: string) => {\n return (\n this.getMessageWithDotsInKey(key) ??\n `[i18n] Key '${key}' is missing for locale: '${this.locale}'`\n )\n },\n })\n vue.use(this.vueI18n)\n }\n\n /**\n * Tries to get a value from the messages object accessing it key by key.\n * When a key fails, takes the remaining key parts and tries to access the message\n * joining them into a single key.\n *\n * @param path - A dot separated key to access the message object.\n * @returns The message corresponding to the provided key, or empty string if it doesn't exist.\n */\n protected getMessageWithDotsInKey(path: string): string | null {\n // TO-DO Support function or array messages\n // eslint-disable-next-line ts/no-unsafe-assignment\n const message = path.split('.').reduce<any>(\n (messages, key, index, pathParts) =>\n // eslint-disable-next-line ts/no-unsafe-return\n isObject(messages)\n ? (messages[key] ?? messages[pathParts.slice(index).join('.')])\n : messages,\n this.currentMessages,\n )\n return typeof message === 'string' ? message : null\n }\n\n /**\n * Sets the new locale and updates the messages accordingly.\n *\n * @param newLocale - The new locale.\n *\n * @returns The new messages.\n */\n async setLocale(newLocale: Locale): Promise<void> {\n if (this.locale !== newLocale) {\n this.locale = newLocale\n\n await this.changeMessages()\n this.vueI18n.global.locale.value = this.locale\n }\n }\n\n /**\n * Sets the new device and updates the messages accordingly.\n *\n * @param newDevice - The new device.\n *\n * @returns The new messages.\n */\n async setDevice(newDevice: Device): Promise<void> {\n if (this.device !== newDevice) {\n this.device = newDevice\n\n await this.changeMessages()\n }\n }\n\n /**\n * Updates the current messages based on the new locale and/or device.\n */\n protected async changeMessages(): Promise<void> {\n this.currentMessages = await this.getCurrentMessages()\n\n this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages)\n }\n\n /**\n * Retrieves the corresponding messages for the set locale and device.\n *\n * @remarks By default, it merges `base` messages with the specific `device` ones. If there are\n * no messages for the current locale, the fallback locale is used instead.\n *\n * @returns The messages for the current locale and device.\n */\n protected async getCurrentMessages(): Promise<LocaleMessageObject> {\n const rawMessages =\n this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale]\n\n const messages = areLazyMessages(rawMessages) ? (await rawMessages()).default : rawMessages\n // eslint-disable-next-line ts/no-unsafe-return\n return deepMerge({}, messages.base, messages[this.device])\n }\n}\n\n/**\n * Type-guard to check if the passed messages should be lazy-loaded.\n *\n * @param messages - The messages to check.\n *\n * @returns True if the messages are lazy or false otherwise.\n */\nfunction areLazyMessages<SomeMessages>(\n messages: AnyMessages<SomeMessages>,\n): messages is LoadLazyMessagesByDevice<SomeMessages> {\n return typeof messages === 'function'\n}\n"],"names":["rollupCssInjectorConfig","varname","webpackConfig","resourcePath","hash","query","instance","CssInjector","setInWindow","style","sheet","host","cssInjector","I18n","locale","messages","device","fallbackLocale","options","vue","createI18n","_","key","path","message","index","pathParts","isObject","newLocale","newDevice","rawMessages","areLazyMessages","deepMerge"],"mappings":"4IAAaA,EAA0B,CACrC,QAAS,CAEP,2BACE,yEACF,WAAY,CAAC,GAAI,EAAE,CAAA,EAErB,OAAQ,CACN,KAAM,CAAC,SAAWC,GAAoB,0CAA0CA,CAAO,MAAM,CAAA,CAEjG,ECSaC,EAAgB,CAC3B,sBAAuB,CAAC,yBAAyB,EACjD,iBAAkB,CAChB,OAAQ,CACN,MAAO,CACL,CACE,KAAM,eACN,QAAS,MACT,IAAK,CAAC,mBAAmB,CAAA,CAC3B,CACF,EAEF,OAAQ,CACN,8BAA+B,CAAC,CAC9B,aAAAC,EACA,KAAAC,EACA,MAAAC,CAAA,IAEAF,EAAa,MAAM,QAAQ,GAC3B,CAACE,EAAM,MAAM,aAAa,GAC1B,CAACA,EAAM,MAAM,+BAA+B,EACxC,wBAAwBF,CAAY,IAAIC,CAAI,GAC5C,aAAaD,CAAY,GAC/B,sCAAuC,mCAAA,CACzC,CAEJ,EC1CA,IAAIG,EAA+B,KAO5B,MAAMC,CAAoC,CAUxC,YAAYC,EAAc,GAAM,CATvC,YAAU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AAG,6BAA6B,KAAK,MAAM,GAE9D,CACD,EACDH,EAAI,IAAI,KAAK,OAAO,CACtB,CAUU,wBAAwBI,EAA6B,CAG7D,MAAMC,EAAUD,EAAK,MAAM,GAAG,EAAE,OAC9B,CAACR,EAAUO,EAAKG,EAAOC,IAErBC,EAAAA,SAASZ,CAAQ,EACZA,EAASO,CAAG,GAAKP,EAASW,EAAU,MAAMD,CAAK,EAAE,KAAK,GAAG,CAAC,EAC3DV,EACN,KAAK,eAAA,EAEP,OAAO,OAAOS,GAAY,SAAWA,EAAU,IACjD,CASA,MAAM,UAAUI,EAAkC,CAC5C,KAAK,SAAWA,IAClB,KAAK,OAASA,EAEd,MAAM,KAAK,eAAA,EACX,KAAK,QAAQ,OAAO,OAAO,MAAQ,KAAK,OAE5C,CASA,MAAM,UAAUC,EAAkC,CAC5C,KAAK,SAAWA,IAClB,KAAK,OAASA,EAEd,MAAM,KAAK,eAAA,EAEf,CAKA,MAAgB,gBAAgC,CAC9C,KAAK,gBAAkB,MAAM,KAAK,mBAAA,EAElC,KAAK,QAAQ,OAAO,iBAAiB,KAAK,OAAQ,KAAK,eAAe,CACxE,CAUA,MAAgB,oBAAmD,CACjE,MAAMC,EACJ,KAAK,UAAU,KAAK,SAAW,KAAK,SAAS,KAAK,MAAM,EAAI,KAAK,SAAS,KAAK,cAAc,EAEzFf,EAAWgB,EAAgBD,CAAW,GAAK,MAAMA,EAAA,GAAe,QAAUA,EAEhF,OAAOE,EAAAA,UAAU,CAAA,EAAIjB,EAAS,KAAMA,EAAS,KAAK,MAAM,CAAC,CAC3D,CACF,CASA,SAASgB,EACPhB,EACoD,CACpD,OAAO,OAAOA,GAAa,UAC7B"}
package/dist/index.es.js CHANGED
@@ -1,7 +1,6 @@
1
- import { deepMerge as h } from "@empathyco/x-deep-merge";
2
- import { isObject as d } from "@empathyco/x-utils";
1
+ import { isObject as h, deepMerge as d } from "@empathyco/x-utils";
3
2
  import { createI18n as u } from "vue-i18n";
4
- const m = {
3
+ const w = {
5
4
  replace: {
6
5
  // Replace X CSS injector by our custom one.
7
6
  "export default injectCss": "export default (css) => window.xCSSInjector.addStyle({ source: css });",
@@ -32,7 +31,7 @@ const m = {
32
31
  }
33
32
  }
34
33
  };
35
- let o = null;
34
+ let i = null;
36
35
  class n {
37
36
  /**
38
37
  * Initializes the instance of the injector if it's not already initialized and sets it in the
@@ -41,7 +40,7 @@ class n {
41
40
  * @param setInWindow - Whether to set the injector instance in the window object.
42
41
  */
43
42
  constructor(e = !0) {
44
- return this.hosts = /* @__PURE__ */ new Set(), this.stylesToAdopt = [], o instanceof n || (o = this), e && this.setInWindow(), o;
43
+ return this.hosts = /* @__PURE__ */ new Set(), this.stylesToAdopt = [], i instanceof n || (i = this), e && this.setInWindow(), i;
45
44
  }
46
45
  /**
47
46
  * Adds the style to the host element.
@@ -82,7 +81,7 @@ class n {
82
81
  * Sets the injector instance in the window object.
83
82
  */
84
83
  setInWindow() {
85
- typeof window < "u" && o && (window.xCSSInjector = o);
84
+ typeof window < "u" && i && (window.xCSSInjector = i);
86
85
  }
87
86
  /**
88
87
  * Checks if the injector instance is in the window object.
@@ -90,10 +89,10 @@ class n {
90
89
  * @returns Whether the injector instance is in the window object.
91
90
  */
92
91
  isInWindow() {
93
- return typeof window > "u" ? !1 : window.xCSSInjector === o;
92
+ return typeof window > "u" ? !1 : window.xCSSInjector === i;
94
93
  }
95
94
  }
96
- const S = new n(typeof window < "u");
95
+ const m = new n(typeof window < "u");
97
96
  class c {
98
97
  /**
99
98
  * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.
@@ -104,8 +103,8 @@ class c {
104
103
  * @param options.device - i18n device.
105
104
  * @param options.fallbackLocale - i18n fallbackLocale.
106
105
  */
107
- constructor({ locale: e, messages: s, device: t, fallbackLocale: i }) {
108
- this.locale = e, this.device = t, this.messages = s, this.fallbackLocale = i;
106
+ constructor({ locale: e, messages: s, device: t, fallbackLocale: o }) {
107
+ this.locale = e, this.device = t, this.messages = s, this.fallbackLocale = o;
109
108
  }
110
109
  /**
111
110
  * Creates a new {@link I18n} instance.
@@ -143,9 +142,9 @@ class c {
143
142
  */
144
143
  getMessageWithDotsInKey(e) {
145
144
  const s = e.split(".").reduce(
146
- (t, i, l, r) => (
145
+ (t, o, l, r) => (
147
146
  // eslint-disable-next-line ts/no-unsafe-return
148
- d(t) ? t[i] ?? t[r.slice(l).join(".")] : t
147
+ h(t) ? t[o] ?? t[r.slice(l).join(".")] : t
149
148
  ),
150
149
  this.currentMessages
151
150
  );
@@ -186,18 +185,18 @@ class c {
186
185
  * @returns The messages for the current locale and device.
187
186
  */
188
187
  async getCurrentMessages() {
189
- const e = this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale], s = p(e) ? (await e()).default : e;
190
- return h({}, s.base, s[this.device]);
188
+ const e = this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale], s = g(e) ? (await e()).default : e;
189
+ return d({}, s.base, s[this.device]);
191
190
  }
192
191
  }
193
- function p(a) {
192
+ function g(a) {
194
193
  return typeof a == "function";
195
194
  }
196
195
  export {
197
196
  n as CssInjector,
198
197
  c as I18n,
199
- S as cssInjector,
200
- m as rollupCssInjectorConfig,
198
+ m as cssInjector,
199
+ w as rollupCssInjectorConfig,
201
200
  y as webpackConfig
202
201
  };
203
202
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/build/rollup/rollup.config.ts","../src/build/webpack/webpack.config.ts","../src/css-injector/css-injector.ts","../src/i18n/i18n.plugin.ts"],"sourcesContent":["export const rollupCssInjectorConfig = {\n replace: {\n // Replace X CSS injector by our custom one.\n 'export default injectCss':\n 'export default (css) => window.xCSSInjector.addStyle({ source: css });',\n delimiters: ['', ''],\n },\n styles: {\n mode: ['inject', (varname: string) => `window.xCSSInjector.addStyle({ source: ${varname} });`],\n },\n}\n","/**.\n * Self-made interface since Webpack does not provide a type for this object.\n * Https://github.com/webpack/webpack/blob/main/declarations/WebpackOptions.d.ts#L463\n *\n * @internal\n */\ninterface webpackFilenameTemplateInfo {\n identifier: string\n shortIdentifier: string\n resource: string\n resourcePath: string\n absoluteResourcePath: string\n allLoaders: string\n query: string\n moduleId: string\n hash: string\n namespace: string\n}\n\nexport const webpackConfig = {\n transpileDependencies: ['@empathyco/x-components'],\n configureWebpack: {\n module: {\n rules: [\n {\n test: /\\.ts|js|vue$/,\n enforce: 'pre',\n use: ['source-map-loader'],\n },\n ],\n },\n output: {\n devtoolModuleFilenameTemplate: ({\n resourcePath,\n hash,\n query,\n }: webpackFilenameTemplateInfo) =>\n resourcePath.match(/\\.vue$/) &&\n !query.match(/type=script/) &&\n !query.match(/\\?rollup-plugin-vue=script.ts/)\n ? `webpack-generated:///${resourcePath}?${hash}`\n : `sources://${resourcePath}`,\n devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',\n },\n },\n}\n","import type { Style, WindowWithInjector, XCSSInjector } from './css-injector.types'\n\n/** Singleton instance of the injector that will be used across all the initializations. */\nlet instance: CssInjector | null = null\n\n/**\n * Custom CSS injector that allows to inject styles into a host element.\n *\n * @public\n */\nexport class CssInjector implements XCSSInjector {\n protected hosts = new Set<Document | ShadowRoot>()\n protected stylesToAdopt: CSSStyleSheet[] = []\n\n /**\n * Initializes the instance of the injector if it's not already initialized and sets it in the\n * window object if it's required.\n *\n * @param setInWindow - Whether to set the injector instance in the window object.\n */\n public constructor(setInWindow = true) {\n if (!(instance instanceof CssInjector)) {\n // eslint-disable-next-line ts/no-this-alias\n instance = this\n }\n\n if (setInWindow) {\n this.setInWindow()\n }\n\n return instance\n }\n\n /**\n * Adds the style to the host element.\n *\n * @param style - The styles to be added.\n * @param style.source - Styles source.\n */\n addStyle(style: Style): void {\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(style.source)\n this.stylesToAdopt.push(sheet)\n this.hosts.forEach(host => (host.adoptedStyleSheets = this.stylesToAdopt))\n }\n\n /**\n * Sets the host element. Alias of addHost method.\n *\n * @param host - The host element.\n * @deprecated Use addHost instead.\n */\n setHost(host: Element | ShadowRoot): void {\n this.addHost(host instanceof ShadowRoot ? host : document)\n }\n\n /**\n * Adds the element to the hosts set.\n *\n * @param host - The host element.\n */\n addHost(host: Document | ShadowRoot): void {\n this.hosts.add(host)\n host.adoptedStyleSheets = this.stylesToAdopt\n }\n\n /**\n * Removes the element from the hosts set.\n *\n * @param host - The host element to remove.\n */\n removeHost(host: Document | ShadowRoot): void {\n this.hosts.delete(host)\n }\n\n /**\n * Sets the injector instance in the window object.\n */\n setInWindow(): void {\n if (typeof window !== 'undefined' && instance) {\n ;(window as WindowWithInjector).xCSSInjector = instance\n }\n }\n\n /**\n * Checks if the injector instance is in the window object.\n *\n * @returns Whether the injector instance is in the window object.\n */\n isInWindow(): boolean {\n return typeof window === 'undefined'\n ? false\n : (window as WindowWithInjector).xCSSInjector === instance\n }\n}\n\n/**\n * Instance of the injector.\n *\n * @public\n */\nexport const cssInjector = new CssInjector(typeof window !== 'undefined')\n","import type { App } from 'vue'\nimport type { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n'\nimport type {\n AnyMessages,\n Device,\n I18nOptions,\n LoadLazyMessagesByDevice,\n Locale,\n} from './i18n.types'\nimport { deepMerge } from '@empathyco/x-deep-merge'\nimport { isObject } from '@empathyco/x-utils'\nimport { createI18n } from 'vue-i18n'\n\n/**\n * I18n settings manager.\n *\n * @public\n */\nexport class I18n<SomeMessages> {\n public vueI18n!: VueI18n<\n Record<string, unknown>,\n Record<string, unknown>,\n Record<string, unknown>,\n Locale,\n false\n >\n protected locale!: Locale\n protected device!: Device\n protected messages!: Record<Locale, AnyMessages<SomeMessages>>\n protected currentMessages!: LocaleMessageObject\n protected fallbackLocale!: Locale\n\n /**\n * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n * @param options.locale - i18n locale.\n * @param options.messages - i18n messages.\n * @param options.device - i18n device.\n * @param options.fallbackLocale - i18n fallbackLocale.\n */\n public constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>) {\n this.locale = locale\n this.device = device\n this.messages = messages\n this.fallbackLocale = fallbackLocale\n }\n\n /**\n * Creates a new {@link I18n} instance.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n *\n * @returns The new instance.\n */\n static async create<SomeMessages>(\n options: I18nOptions<SomeMessages>,\n ): Promise<I18n<SomeMessages>> {\n const instance = new I18n(options)\n instance.currentMessages = await instance.getCurrentMessages()\n return instance\n }\n\n /**\n * Installs VueI18n plugin.\n *\n * @param vue - The Vue instance.\n */\n install(vue: App): void {\n this.vueI18n = createI18n({\n legacy: false,\n locale: this.locale,\n silentFallbackWarn: true,\n // eslint-disable-next-line ts/no-unsafe-assignment\n messages: this.currentMessages ? ({ [this.locale]: this.currentMessages } as any) : {},\n missing: (_, key: string) => {\n return (\n this.getMessageWithDotsInKey(key) ??\n `[i18n] Key '${key}' is missing for locale: '${this.locale}'`\n )\n },\n })\n vue.use(this.vueI18n)\n }\n\n /**\n * Tries to get a value from the messages object accessing it key by key.\n * When a key fails, takes the remaining key parts and tries to access the message\n * joining them into a single key.\n *\n * @param path - A dot separated key to access the message object.\n * @returns The message corresponding to the provided key, or empty string if it doesn't exist.\n */\n protected getMessageWithDotsInKey(path: string): string | null {\n // TO-DO Support function or array messages\n // eslint-disable-next-line ts/no-unsafe-assignment\n const message = path.split('.').reduce<any>(\n (messages, key, index, pathParts) =>\n // eslint-disable-next-line ts/no-unsafe-return\n isObject(messages)\n ? (messages[key] ?? messages[pathParts.slice(index).join('.')])\n : messages,\n this.currentMessages,\n )\n return typeof message === 'string' ? message : null\n }\n\n /**\n * Sets the new locale and updates the messages accordingly.\n *\n * @param newLocale - The new locale.\n *\n * @returns The new messages.\n */\n async setLocale(newLocale: Locale): Promise<void> {\n if (this.locale !== newLocale) {\n this.locale = newLocale\n\n await this.changeMessages()\n this.vueI18n.global.locale.value = this.locale\n }\n }\n\n /**\n * Sets the new device and updates the messages accordingly.\n *\n * @param newDevice - The new device.\n *\n * @returns The new messages.\n */\n async setDevice(newDevice: Device): Promise<void> {\n if (this.device !== newDevice) {\n this.device = newDevice\n\n await this.changeMessages()\n }\n }\n\n /**\n * Updates the current messages based on the new locale and/or device.\n */\n protected async changeMessages(): Promise<void> {\n this.currentMessages = await this.getCurrentMessages()\n\n this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages)\n }\n\n /**\n * Retrieves the corresponding messages for the set locale and device.\n *\n * @remarks By default, it merges `base` messages with the specific `device` ones. If there are\n * no messages for the current locale, the fallback locale is used instead.\n *\n * @returns The messages for the current locale and device.\n */\n protected async getCurrentMessages(): Promise<LocaleMessageObject> {\n const rawMessages =\n this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale]\n\n const messages = areLazyMessages(rawMessages) ? (await rawMessages()).default : rawMessages\n // eslint-disable-next-line ts/no-unsafe-return\n return deepMerge({}, messages.base, messages[this.device])\n }\n}\n\n/**\n * Type-guard to check if the passed messages should be lazy-loaded.\n *\n * @param messages - The messages to check.\n *\n * @returns True if the messages are lazy or false otherwise.\n */\nfunction areLazyMessages<SomeMessages>(\n messages: AnyMessages<SomeMessages>,\n): messages is LoadLazyMessagesByDevice<SomeMessages> {\n return typeof messages === 'function'\n}\n"],"names":["rollupCssInjectorConfig","varname","webpackConfig","resourcePath","hash","query","instance","CssInjector","setInWindow","style","sheet","host","cssInjector","I18n","locale","messages","device","fallbackLocale","options","vue","createI18n","_","key","path","message","index","pathParts","isObject","newLocale","newDevice","rawMessages","areLazyMessages","deepMerge"],"mappings":";;;AAAO,MAAMA,IAA0B;AAAA,EACrC,SAAS;AAAA;AAAA,IAEP,4BACE;AAAA,IACF,YAAY,CAAC,IAAI,EAAE;AAAA,EAAA;AAAA,EAErB,QAAQ;AAAA,IACN,MAAM,CAAC,UAAU,CAACC,MAAoB,0CAA0CA,CAAO,MAAM;AAAA,EAAA;AAEjG,GCSaC,IAAgB;AAAA,E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C7B;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/build/rollup/rollup.config.ts","../src/build/webpack/webpack.config.ts","../src/css-injector/css-injector.ts","../src/i18n/i18n.plugin.ts"],"sourcesContent":["export const rollupCssInjectorConfig = {\n replace: {\n // Replace X CSS injector by our custom one.\n 'export default injectCss':\n 'export default (css) => window.xCSSInjector.addStyle({ source: css });',\n delimiters: ['', ''],\n },\n styles: {\n mode: ['inject', (varname: string) => `window.xCSSInjector.addStyle({ source: ${varname} });`],\n },\n}\n","/**.\n * Self-made interface since Webpack does not provide a type for this object.\n * Https://github.com/webpack/webpack/blob/main/declarations/WebpackOptions.d.ts#L463\n *\n * @internal\n */\ninterface webpackFilenameTemplateInfo {\n identifier: string\n shortIdentifier: string\n resource: string\n resourcePath: string\n absoluteResourcePath: string\n allLoaders: string\n query: string\n moduleId: string\n hash: string\n namespace: string\n}\n\nexport const webpackConfig = {\n transpileDependencies: ['@empathyco/x-components'],\n configureWebpack: {\n module: {\n rules: [\n {\n test: /\\.ts|js|vue$/,\n enforce: 'pre',\n use: ['source-map-loader'],\n },\n ],\n },\n output: {\n devtoolModuleFilenameTemplate: ({\n resourcePath,\n hash,\n query,\n }: webpackFilenameTemplateInfo) =>\n resourcePath.match(/\\.vue$/) &&\n !query.match(/type=script/) &&\n !query.match(/\\?rollup-plugin-vue=script.ts/)\n ? `webpack-generated:///${resourcePath}?${hash}`\n : `sources://${resourcePath}`,\n devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]',\n },\n },\n}\n","import type { Style, WindowWithInjector, XCSSInjector } from './css-injector.types'\n\n/** Singleton instance of the injector that will be used across all the initializations. */\nlet instance: CssInjector | null = null\n\n/**\n * Custom CSS injector that allows to inject styles into a host element.\n *\n * @public\n */\nexport class CssInjector implements XCSSInjector {\n protected hosts = new Set<Document | ShadowRoot>()\n protected stylesToAdopt: CSSStyleSheet[] = []\n\n /**\n * Initializes the instance of the injector if it's not already initialized and sets it in the\n * window object if it's required.\n *\n * @param setInWindow - Whether to set the injector instance in the window object.\n */\n public constructor(setInWindow = true) {\n if (!(instance instanceof CssInjector)) {\n // eslint-disable-next-line ts/no-this-alias\n instance = this\n }\n\n if (setInWindow) {\n this.setInWindow()\n }\n\n return instance\n }\n\n /**\n * Adds the style to the host element.\n *\n * @param style - The styles to be added.\n * @param style.source - Styles source.\n */\n addStyle(style: Style): void {\n const sheet = new CSSStyleSheet()\n sheet.replaceSync(style.source)\n this.stylesToAdopt.push(sheet)\n this.hosts.forEach(host => (host.adoptedStyleSheets = this.stylesToAdopt))\n }\n\n /**\n * Sets the host element. Alias of addHost method.\n *\n * @param host - The host element.\n * @deprecated Use addHost instead.\n */\n setHost(host: Element | ShadowRoot): void {\n this.addHost(host instanceof ShadowRoot ? host : document)\n }\n\n /**\n * Adds the element to the hosts set.\n *\n * @param host - The host element.\n */\n addHost(host: Document | ShadowRoot): void {\n this.hosts.add(host)\n host.adoptedStyleSheets = this.stylesToAdopt\n }\n\n /**\n * Removes the element from the hosts set.\n *\n * @param host - The host element to remove.\n */\n removeHost(host: Document | ShadowRoot): void {\n this.hosts.delete(host)\n }\n\n /**\n * Sets the injector instance in the window object.\n */\n setInWindow(): void {\n if (typeof window !== 'undefined' && instance) {\n ;(window as WindowWithInjector).xCSSInjector = instance\n }\n }\n\n /**\n * Checks if the injector instance is in the window object.\n *\n * @returns Whether the injector instance is in the window object.\n */\n isInWindow(): boolean {\n return typeof window === 'undefined'\n ? false\n : (window as WindowWithInjector).xCSSInjector === instance\n }\n}\n\n/**\n * Instance of the injector.\n *\n * @public\n */\nexport const cssInjector = new CssInjector(typeof window !== 'undefined')\n","import type { App } from 'vue'\nimport type { LocaleMessageObject, I18n as VueI18n } from 'vue-i18n'\nimport type {\n AnyMessages,\n Device,\n I18nOptions,\n LoadLazyMessagesByDevice,\n Locale,\n} from './i18n.types'\nimport { deepMerge, isObject } from '@empathyco/x-utils'\nimport { createI18n } from 'vue-i18n'\n\n/**\n * I18n settings manager.\n *\n * @public\n */\nexport class I18n<SomeMessages> {\n public vueI18n!: VueI18n<\n Record<string, unknown>,\n Record<string, unknown>,\n Record<string, unknown>,\n Locale,\n false\n >\n protected locale!: Locale\n protected device!: Device\n protected messages!: Record<Locale, AnyMessages<SomeMessages>>\n protected currentMessages!: LocaleMessageObject\n protected fallbackLocale!: Locale\n\n /**\n * Constructs a new {@link I18n} instance with the passed {@link I18nOptions | i18n options}.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n * @param options.locale - i18n locale.\n * @param options.messages - i18n messages.\n * @param options.device - i18n device.\n * @param options.fallbackLocale - i18n fallbackLocale.\n */\n public constructor({ locale, messages, device, fallbackLocale }: I18nOptions<SomeMessages>) {\n this.locale = locale\n this.device = device\n this.messages = messages\n this.fallbackLocale = fallbackLocale\n }\n\n /**\n * Creates a new {@link I18n} instance.\n *\n * @param options - The new {@link I18nOptions | i18n options}.\n *\n * @returns The new instance.\n */\n static async create<SomeMessages>(\n options: I18nOptions<SomeMessages>,\n ): Promise<I18n<SomeMessages>> {\n const instance = new I18n(options)\n instance.currentMessages = await instance.getCurrentMessages()\n return instance\n }\n\n /**\n * Installs VueI18n plugin.\n *\n * @param vue - The Vue instance.\n */\n install(vue: App): void {\n this.vueI18n = createI18n({\n legacy: false,\n locale: this.locale,\n silentFallbackWarn: true,\n // eslint-disable-next-line ts/no-unsafe-assignment\n messages: this.currentMessages ? ({ [this.locale]: this.currentMessages } as any) : {},\n missing: (_, key: string) => {\n return (\n this.getMessageWithDotsInKey(key) ??\n `[i18n] Key '${key}' is missing for locale: '${this.locale}'`\n )\n },\n })\n vue.use(this.vueI18n)\n }\n\n /**\n * Tries to get a value from the messages object accessing it key by key.\n * When a key fails, takes the remaining key parts and tries to access the message\n * joining them into a single key.\n *\n * @param path - A dot separated key to access the message object.\n * @returns The message corresponding to the provided key, or empty string if it doesn't exist.\n */\n protected getMessageWithDotsInKey(path: string): string | null {\n // TO-DO Support function or array messages\n // eslint-disable-next-line ts/no-unsafe-assignment\n const message = path.split('.').reduce<any>(\n (messages, key, index, pathParts) =>\n // eslint-disable-next-line ts/no-unsafe-return\n isObject(messages)\n ? (messages[key] ?? messages[pathParts.slice(index).join('.')])\n : messages,\n this.currentMessages,\n )\n return typeof message === 'string' ? message : null\n }\n\n /**\n * Sets the new locale and updates the messages accordingly.\n *\n * @param newLocale - The new locale.\n *\n * @returns The new messages.\n */\n async setLocale(newLocale: Locale): Promise<void> {\n if (this.locale !== newLocale) {\n this.locale = newLocale\n\n await this.changeMessages()\n this.vueI18n.global.locale.value = this.locale\n }\n }\n\n /**\n * Sets the new device and updates the messages accordingly.\n *\n * @param newDevice - The new device.\n *\n * @returns The new messages.\n */\n async setDevice(newDevice: Device): Promise<void> {\n if (this.device !== newDevice) {\n this.device = newDevice\n\n await this.changeMessages()\n }\n }\n\n /**\n * Updates the current messages based on the new locale and/or device.\n */\n protected async changeMessages(): Promise<void> {\n this.currentMessages = await this.getCurrentMessages()\n\n this.vueI18n.global.setLocaleMessage(this.locale, this.currentMessages)\n }\n\n /**\n * Retrieves the corresponding messages for the set locale and device.\n *\n * @remarks By default, it merges `base` messages with the specific `device` ones. If there are\n * no messages for the current locale, the fallback locale is used instead.\n *\n * @returns The messages for the current locale and device.\n */\n protected async getCurrentMessages(): Promise<LocaleMessageObject> {\n const rawMessages =\n this.locale in this.messages ? this.messages[this.locale] : this.messages[this.fallbackLocale]\n\n const messages = areLazyMessages(rawMessages) ? (await rawMessages()).default : rawMessages\n // eslint-disable-next-line ts/no-unsafe-return\n return deepMerge({}, messages.base, messages[this.device])\n }\n}\n\n/**\n * Type-guard to check if the passed messages should be lazy-loaded.\n *\n * @param messages - The messages to check.\n *\n * @returns True if the messages are lazy or false otherwise.\n */\nfunction areLazyMessages<SomeMessages>(\n messages: AnyMessages<SomeMessages>,\n): messages is LoadLazyMessagesByDevice<SomeMessages> {\n return typeof messages === 'function'\n}\n"],"names":["rollupCssInjectorConfig","varname","webpackConfig","resourcePath","hash","query","instance","CssInjector","setInWindow","style","sheet","host","cssInjector","I18n","locale","messages","device","fallbackLocale","options","vue","createI18n","_","key","path","message","index","pathParts","isObject","newLocale","newDevice","rawMessages","areLazyMessages","deepMerge"],"mappings":";;AAAO,MAAMA,IAA0B;AAAA,EACrC,SAAS;AAAA;AAAA,IAEP,4BACE;AAAA,IACF,YAAY,CAAC,IAAI,EAAE;AAAA,EAAA;AAAA,EAErB,QAAQ;AAAA,IACN,MAAM,CAAC,UAAU,CAACC,MAAoB,0CAA0CA,CAAO,MAAM;AAAA,EAAA;AAEjG,GCSaC,IAAgB;AAAA,EAC3B,uBAAuB,CAAC,yBAAyB;AAAA,EACjD,kBAAkB;AAAA,IAChB,QAAQ;AAAA,MACN,OAAO;AAAA,QACL;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,KAAK,CAAC,mBAAmB;AAAA,QAAA;AAAA,MAC3B;AAAA,IACF;AAAA,IAEF,QAAQ;AAAA,MACN,+BAA+B,CAAC;AAAA,QAC9B,cAAAC;AAAA,QACA,MAAAC;AAAA,QACA,OAAAC;AAAA,MAAA,MAEAF,EAAa,MAAM,QAAQ,KAC3B,CAACE,EAAM,MAAM,aAAa,KAC1B,CAACA,EAAM,MAAM,+BAA+B,IACxC,wBAAwBF,CAAY,IAAIC,CAAI,KAC5C,aAAaD,CAAY;AAAA,MAC/B,uCAAuC;AAAA,IAAA;AAAA,EACzC;AAEJ;AC1CA,IAAIG,IAA+B;AAO5B,MAAMC,EAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUxC,YAAYC,IAAc,IAAM;AATvC,gBAAU,4BAAY,IAAA,GACtB,KAAU,gBAAiC,CAAA,GASnCF,aAAoBC,MAExBD,IAAW,OAGTE,KACF,KAAK,YAAA,GAGAF;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,SAASG,GAAoB;AAC3B,UAAMC,IAAQ,IAAI,cAAA;AAClB,IAAAA,EAAM,YAAYD,EAAM,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A;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAgB,qBAAmD;AACjE,UAAMC,IACJ,KAAK,UAAU,KAAK,WAAW,KAAK,SAAS,KAAK,MAAM,IAAI,KAAK,SAAS,KAAK,cAAc,GAEzFf,IAAWgB,EAAgBD,CAAW,KAAK,MAAMA,EAAA,GAAe,UAAUA;AAEhF,WAAOE,EAAU,CAAA,GAAIjB,EAAS,MAAMA,EAAS,KAAK,MAAM,CAAC;AAAA,EAC3D;AACF;AASA,SAASgB,EACPhB,GACoD;AACpD,SAAO,OAAOA,KAAa;AAC7B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empathyco/x-archetype-utils",
3
- "version": "2.0.0-alpha.36",
3
+ "version": "2.0.0-alpha.38",
4
4
  "description": "Utilities for x-archetype",
5
5
  "author": "Empathy Systems Corporation S.L.",
6
6
  "license": "Apache-2.0",
@@ -25,10 +25,8 @@
25
25
  "node": ">=22"
26
26
  },
27
27
  "scripts": {
28
- "prebuild": "rimraf dist ./*.tgz",
28
+ "prebuild": "rm -rf dist *.tgz",
29
29
  "build": "vite build",
30
- "build:cjs": "tsc --project tsconfig.cjs.json",
31
- "build:esm": "tsc --project tsconfig.esm.json",
32
30
  "pack": "pnpm pack",
33
31
  "lint": "eslint --fix",
34
32
  "lint:check": "eslint",
@@ -46,15 +44,13 @@
46
44
  "vue-i18n": "^9.14.5"
47
45
  },
48
46
  "dependencies": {
49
- "@empathyco/x-deep-merge": "2.0.3-alpha.14",
50
- "@empathyco/x-utils": "1.0.3-alpha.15",
47
+ "@empathyco/x-utils": "1.0.3-alpha.16",
51
48
  "vue-i18n": "~9.14.5"
52
49
  },
53
50
  "devDependencies": {
54
51
  "@vitest/coverage-v8": "4.0.18",
55
52
  "@vue/test-utils": "2.4.6",
56
53
  "jsdom": "28.1.0",
57
- "rimraf": "3.0.2",
58
54
  "typescript": "5.9.3",
59
55
  "vite": "6.4.1",
60
56
  "vite-plugin-dts": "4.5.4",
@@ -65,5 +61,5 @@
65
61
  "publishConfig": {
66
62
  "access": "public"
67
63
  },
68
- "gitHead": "01ba0d6d8c302024b26bd78dcba5f324395b264a"
64
+ "gitHead": "0c1112573319f83f46aaf3af2f1700c0e33d817b"
69
65
  }