@lukso/core 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/{chunk-CUDG6NPH.cjs → chunk-6VE73XQH.cjs} +4 -2
- package/dist/chunk-6VE73XQH.cjs.map +1 -0
- package/dist/{chunk-FR74YPGJ.cjs → chunk-7CRBSMQ7.cjs} +9 -11
- package/dist/chunk-7CRBSMQ7.cjs.map +1 -0
- package/dist/{chunk-LQIOVPBE.js → chunk-H3LA56KM.js} +4 -2
- package/dist/{chunk-LQIOVPBE.js.map → chunk-H3LA56KM.js.map} +1 -1
- package/dist/{chunk-4TNWG4ME.js → chunk-HTK4HH4J.js} +11 -4
- package/dist/chunk-HTK4HH4J.js.map +1 -0
- package/dist/{chunk-RM42NG7E.cjs → chunk-IDQ6WJY5.cjs} +11 -4
- package/dist/chunk-IDQ6WJY5.cjs.map +1 -0
- package/dist/{chunk-SV4TVR2K.js → chunk-K5NPHWCG.js} +4 -6
- package/dist/chunk-K5NPHWCG.js.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +3 -3
- package/dist/mixins/index.cjs +4 -4
- package/dist/mixins/index.js +3 -3
- package/dist/mixins/intl.cjs +3 -3
- package/dist/mixins/intl.js +2 -2
- package/dist/mixins/theme.cjs +2 -2
- package/dist/mixins/theme.js +1 -1
- package/dist/services/index.cjs +2 -2
- package/dist/services/index.js +1 -1
- package/dist/services/intl.cjs +2 -2
- package/dist/services/intl.d.cts +9 -0
- package/dist/services/intl.d.ts +9 -0
- package/dist/services/intl.js +1 -1
- package/package.json +5 -3
- package/src/mixins/intl.ts +1 -1
- package/src/mixins/theme.ts +3 -1
- package/src/services/intl.ts +18 -1
- package/translations/de_DE.json +14 -0
- package/translations/en_US.json +16 -0
- package/dist/chunk-4TNWG4ME.js.map +0 -1
- package/dist/chunk-CUDG6NPH.cjs.map +0 -1
- package/dist/chunk-FR74YPGJ.cjs.map +0 -1
- package/dist/chunk-RM42NG7E.cjs.map +0 -1
- package/dist/chunk-SV4TVR2K.js.map +0 -1
package/README.md
CHANGED
|
@@ -58,8 +58,21 @@ setIntlService(intl)
|
|
|
58
58
|
console.log(intl.formatMessage('app.welcome')) // 'Welcome'
|
|
59
59
|
console.log(intl.formatMessage('app.hello', { name: 'John' })) // 'Hello, John!'
|
|
60
60
|
console.log(intl.formatNumber(1234.56)) // '1,234.56'
|
|
61
|
+
|
|
62
|
+
// Enable warnings for missing translations (useful for debugging)
|
|
63
|
+
const intlWithWarnings = createIntlService({
|
|
64
|
+
locale: 'en-US',
|
|
65
|
+
messages: {
|
|
66
|
+
'app.welcome': 'Welcome',
|
|
67
|
+
},
|
|
68
|
+
onError: (err) => {
|
|
69
|
+
console.error('Translation error:', err)
|
|
70
|
+
},
|
|
71
|
+
})
|
|
61
72
|
```
|
|
62
73
|
|
|
74
|
+
> **Note:** By default, missing translation warnings are suppressed since translations are optional. To enable warnings during development, pass a custom `onError` handler.
|
|
75
|
+
|
|
63
76
|
### Utility functions
|
|
64
77
|
|
|
65
78
|
#### browserInfo
|
|
@@ -86,12 +86,14 @@ function withTheme(Base) {
|
|
|
86
86
|
return this.themeRoot;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
* Update the host element's class based on isDark state
|
|
89
|
+
* Update the host element's and theme root's class based on isDark state
|
|
90
90
|
*/
|
|
91
91
|
updateHostClass() {
|
|
92
92
|
if (this.isDark) {
|
|
93
|
+
this.classList.add("dark");
|
|
93
94
|
this.themeRoot.classList.add("dark");
|
|
94
95
|
} else {
|
|
96
|
+
this.classList.remove("dark");
|
|
95
97
|
this.themeRoot.classList.remove("dark");
|
|
96
98
|
}
|
|
97
99
|
}
|
|
@@ -108,4 +110,4 @@ function withTheme(Base) {
|
|
|
108
110
|
|
|
109
111
|
|
|
110
112
|
exports.withTheme = withTheme;
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-6VE73XQH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-6VE73XQH.cjs","../src/mixins/theme.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACGA,iDAAgC;AAsCzB,SAAS,SAAA,CAAuC,IAAA,EAAc;AAAA,EAEnE,MAAM,MAAA,QAAe,KAAa;AAAA,IAAlC,WAAA,CAAA,EAAA;AAAA,MAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAKE,MAAA,IAAA,CAAA,MAAA,EAAe,OAAA;AAMf,MAAA,IAAA,CAAU,OAAA,EAAS,KAAA;AAOnB,MAAA,IAAA,CAAQ,eAAA,EAAwC,IAAA;AAgEhD;AAAA;AAAA;AAAA;AAAA;AAAA,MAAA,IAAA,CAAQ,uBAAA,EAAyB,CAAC,KAAA,EAAA,GAAqC;AACrE,QAAA,IAAA,CAAK,OAAA,EAAS,KAAA,CAAM,OAAA;AAAA,MACtB,CAAA;AAAA,IAAA;AAAA,IAhEA,iBAAA,CAAA,EAA0B;AACxB,MAAA,KAAA,CAAM,iBAAA,CAAkB,CAAA;AACxB,MAAA,IAAA,CAAK,WAAA,CAAY,CAAA;AACjB,MAAA,IAAA,CAAK,eAAA,CAAgB,CAAA;AAGrB,MAAA,GAAA,CAAI,IAAA,CAAK,MAAA,IAAU,MAAA,EAAQ;AACzB,QAAA,IAAA,CAAK,eAAA,EAAiB,MAAA,CAAO,UAAA,CAAW,8BAA8B,CAAA;AACtE,QAAA,IAAA,CAAK,cAAA,CAAe,gBAAA;AAAA,UAClB,QAAA;AAAA,UACA,IAAA,CAAK;AAAA,QACP,CAAA;AAAA,MACF;AAAA,IACF;AAAA,IAEA,oBAAA,CAAA,EAA6B;AAC3B,MAAA,KAAA,CAAM,oBAAA,CAAqB,CAAA;AAE3B,MAAA,GAAA,CAAI,IAAA,CAAK,cAAA,EAAgB;AACvB,QAAA,IAA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/core/dist/chunk-6VE73XQH.cjs","sourcesContent":[null,"/**\n * Theme Mixin\n *\n * Mixin to add theme detection and management to a Lit component\n */\n\nimport type { LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nexport type Theme = 'light' | 'dark' | 'auto'\n\n/**\n * Mixin to add theme management to a Lit component\n *\n * Provides a `theme` property and `isDark` state that automatically handles:\n * - Manual theme selection ('light' or 'dark')\n * - Auto theme detection based on system preferences\n * - Reactive updates when system theme changes\n * - Automatically wraps all rendered content in a themed div with 'dark' class when dark mode is active\n *\n * All content rendered by the component will be inside a theme-root div that receives the dark class.\n * Components can use render() normally - no changes needed.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with theme management capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withTheme } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withTheme(LitElement) {\n * render() {\n * return html`\n * <div class=\"text-neutral-20 dark:text-neutral-100\">\n * Current theme: ${this.theme}\n * </div>\n * `;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withTheme<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n /**\n * Theme mode: 'light', 'dark', or 'auto' (follows system preference)\n */\n @property({ type: String, reflect: true })\n theme: Theme = 'light'\n\n /**\n * Computed state indicating if dark mode is active\n */\n @state()\n protected isDark = false\n\n /**\n * The theme root element that wraps all rendered content and receives the dark class\n */\n private themeRoot!: HTMLDivElement\n\n private mediaQueryList: MediaQueryList | null = null\n\n connectedCallback(): void {\n super.connectedCallback()\n this.updateTheme()\n this.updateHostClass()\n\n // Listen for system theme changes when in 'auto' mode\n if (this.theme === 'auto') {\n this.mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n if (this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n updated(changedProperties: Map<string, any>): void {\n super.updated(changedProperties)\n\n // Handle theme changes\n if (changedProperties.has('theme')) {\n this.updateTheme()\n\n // Update media query listener when theme mode changes\n if (this.theme === 'auto' && !this.mediaQueryList) {\n this.mediaQueryList = window.matchMedia(\n '(prefers-color-scheme: dark)'\n )\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n } else if (this.theme !== 'auto' && this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n this.mediaQueryList = null\n }\n }\n\n // Update host class when isDark changes\n if (changedProperties.has('isDark')) {\n this.updateHostClass()\n }\n }\n\n /**\n * Handle system theme changes\n *\n * @param event - Media query list event\n */\n private handleMediaQueryChange = (event: MediaQueryListEvent): void => {\n this.isDark = event.matches\n }\n\n /**\n * Update isDark state based on theme property\n */\n protected updateTheme(): void {\n if (this.theme === 'auto') {\n this.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n } else {\n this.isDark = this.theme === 'dark'\n }\n }\n\n /**\n * Create the render root with a themed wrapper div\n */\n createRenderRoot(): Element | ShadowRoot {\n const root = super.createRenderRoot()\n\n this.themeRoot = document.createElement('div')\n this.themeRoot.setAttribute('data-theme-root', '')\n\n root.appendChild(this.themeRoot)\n return this.themeRoot\n }\n\n /**\n * Update the host element's and theme root's class based on isDark state\n */\n private updateHostClass(): void {\n if (this.isDark) {\n this.classList.add('dark')\n this.themeRoot.classList.add('dark')\n } else {\n this.classList.remove('dark')\n this.themeRoot.classList.remove('dark')\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"]}
|
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkIDQ6WJY5cjs = require('./chunk-IDQ6WJY5.cjs');
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
var _signalscore = require('@preact/signals-core');
|
|
10
|
-
|
|
11
|
-
// ../translations/en_US.json
|
|
8
|
+
// translations/en_US.json
|
|
12
9
|
var en_US_default = {
|
|
13
10
|
connect_modal_try_again: "Try again",
|
|
14
11
|
connect_modal_title: "Let\u2019s log you in",
|
|
@@ -27,6 +24,7 @@ var en_US_default = {
|
|
|
27
24
|
};
|
|
28
25
|
|
|
29
26
|
// src/mixins/intl.ts
|
|
27
|
+
var _signalscore = require('@preact/signals-core');
|
|
30
28
|
function withIntlService(Base) {
|
|
31
29
|
class Mixin extends Base {
|
|
32
30
|
constructor() {
|
|
@@ -35,7 +33,7 @@ function withIntlService(Base) {
|
|
|
35
33
|
}
|
|
36
34
|
connectedCallback() {
|
|
37
35
|
super.connectedCallback();
|
|
38
|
-
let intl =
|
|
36
|
+
let intl = _chunkIDQ6WJY5cjs.getIntlService.call(void 0, );
|
|
39
37
|
if (!intl) {
|
|
40
38
|
intl = _nullishCoalesce(this.setupLocalIntl(), () => ( null));
|
|
41
39
|
}
|
|
@@ -58,12 +56,12 @@ function withIntlService(Base) {
|
|
|
58
56
|
* Subclasses can override this to customize initialization
|
|
59
57
|
*/
|
|
60
58
|
setupLocalIntl() {
|
|
61
|
-
const intlService =
|
|
62
|
-
Object.assign(
|
|
59
|
+
const intlService = _chunkIDQ6WJY5cjs.createIntlService.call(void 0,
|
|
60
|
+
Object.assign(_chunkIDQ6WJY5cjs.defaultConfig, {
|
|
63
61
|
messages: en_US_default
|
|
64
62
|
})
|
|
65
63
|
);
|
|
66
|
-
|
|
64
|
+
_chunkIDQ6WJY5cjs.setIntlService.call(void 0, intlService);
|
|
67
65
|
return intlService;
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
@@ -74,7 +72,7 @@ function withIntlService(Base) {
|
|
|
74
72
|
console.warn("No translation key provided to formatMessage");
|
|
75
73
|
return "";
|
|
76
74
|
}
|
|
77
|
-
const intl =
|
|
75
|
+
const intl = _chunkIDQ6WJY5cjs.getIntlService.call(void 0, );
|
|
78
76
|
return _nullishCoalesce(_optionalChain([intl, 'optionalAccess', _5 => _5.formatMessage, 'call', _6 => _6(key, options)]), () => ( key));
|
|
79
77
|
}
|
|
80
78
|
}
|
|
@@ -84,4 +82,4 @@ function withIntlService(Base) {
|
|
|
84
82
|
|
|
85
83
|
|
|
86
84
|
exports.withIntlService = withIntlService;
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-7CRBSMQ7.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-7CRBSMQ7.cjs","../translations/en_US.json","../src/mixins/intl.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACPA,IAAA,cAAA,EAAA;AAAA,EACE,uBAAA,EAA2B,WAAA;AAAA,EAC3B,mBAAA,EAAuB,uBAAA;AAAA,EACvB,2BAAA,EAA+B,gBAAA;AAAA,EAC/B,iCAAA,EAAqC,wEAAA;AAAA,EACrC,8BAAA,EAAkC,gBAAA;AAAA,EAClC,qBAAA,EAAyB,gCAAA;AAAA,EACzB,gBAAA,EAAoB,IAAA;AAAA,EACpB,uBAAA,EAA2B,WAAA;AAAA,EAC3B,4BAAA,EAAgC,mBAAA;AAAA,EAChC,uBAAA,EAA2B,qBAAA;AAAA,EAC3B,yBAAA,EAA6B,oCAAA;AAAA,EAC7B,kCAAA,EAAsC,oBAAA;AAAA,EACtC,6CAAA,EAAiD,mBAAA;AAAA,EACjD,uCAAA,EAA2C;AAC7C,CAAA;ADSA;AACA;AElBA,mDAAuB;AAqChB,SAAS,eAAA,CAA6C,IAAA,EAAc;AAAA,EAEzE,MAAM,MAAA,QAAe,KAAa;AAAA,IAAlC,WAAA,CAAA,EAAA;AAAA,MA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AA,OAAA,CAAQ,IAAA,CAAK,8CAA8C,CAAA;AAC3D,QAAA,OAAO,EAAA;AAAA,MACT;AAEA,MAAA,MAAM,KAAA,EAAO,8CAAA,CAAe;AAC5B,MAAA,wCAAO,IAAA,6BAAM,aAAA,mBAAc,GAAA,EAAK,OAAO,GAAA,UAAK,KAAA;AAAA,IAC9C;AAAA,EACF;AAGA,EAAA,OAAO,KAAA;AACT;AF/BA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-7CRBSMQ7.cjs","sourcesContent":[null,"{\n \"connect_modal_try_again\": \"Try again\",\n \"connect_modal_title\": \"Let’s log you in\",\n \"connect_modal_qr_code_title\": \"Scan to log in\",\n \"connect_modal_qr_code_description\": \"Scan the below QR code with the Universal Profile mobile app to log in\",\n \"connect_modal_other_connectors\": \"Connect Wallet\",\n \"connect_modal_or_info\": \"Log in with a different wallet\",\n \"connect_modal_or\": \"Or\",\n \"connect_modal_installed\": \"INSTALLED\",\n \"connect_modal_failed_to_load\": \"Failed to load...\",\n \"connect_modal_eoa_title\": \"Connect your Wallet\",\n \"connect_modal_description\": \"Log in with your Universal Profile\",\n \"connect_modal_connectors_up_mobile\": \"Mobile Application\",\n \"connect_modal_connectors_up_browser_extension\": \"Browser Extension\",\n \"connect_modal_connectors_passkey_wallet\": \"Passkey Wallet\"\n}","/**\n * Internationalization Mixin\n *\n * Mixin to add internationalization service to a Lit component\n */\n\nimport englishTranslations from '@lukso/core/translations/en_US.json'\nimport { effect } from '@preact/signals-core'\nimport type { LitElement } from 'lit'\nimport {\n createIntlService,\n defaultConfig,\n getIntlService,\n type IntlService,\n setIntlService,\n} from '../services/intl.js'\n\n/**\n * Mixin to add internationalization service to a Lit component\n *\n * Provides access to the global intl service with reactive locale changes.\n * Automatically subscribes to locale changes and triggers re-renders.\n *\n * The component will use the global intl service if available, or create a local one.\n * This follows the singleton pattern for the global service while allowing flexibility.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with intl service capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withIntlService } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withIntlService(LitElement) {\n * render() {\n * return html\\`<p>\\${this.formatMessage('app.welcome')}</p>\\`;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withIntlService<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n protected unsubscribeIntl: (() => void) | undefined = undefined\n\n connectedCallback(): void {\n super.connectedCallback()\n\n // Subscribe to intl changes via signal\n let intl: IntlService | null = getIntlService()\n\n // When no intl is provided by host app we initialize our own\n if (!intl) {\n intl = this.setupLocalIntl() ?? null\n }\n\n if (intl) {\n this.unsubscribeIntl = effect(() => {\n // Access the signal to track changes\n intl?.localeChanged.value\n this.requestUpdate()\n })\n }\n\n // Set fallback for missing translations\n intl?.setFallbackTranslations(englishTranslations as any)\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n // Unsubscribe from intl changes\n if (typeof this.unsubscribeIntl === 'function') {\n this.unsubscribeIntl()\n }\n }\n\n /**\n * Setup a local intl service with default configuration\n * Subclasses can override this to customize initialization\n */\n protected setupLocalIntl(): IntlService | undefined {\n const intlService = createIntlService(\n Object.assign(defaultConfig, {\n messages: englishTranslations,\n })\n )\n setIntlService(intlService)\n return intlService\n }\n\n /**\n * Format message using the intl service\n */\n formatMessage(key?: string, options?: Record<string, string>): string {\n if (!key) {\n console.warn('No translation key provided to formatMessage')\n return ''\n }\n\n const intl = getIntlService()\n return intl?.formatMessage(key, options) ?? key\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"]}
|
|
@@ -86,12 +86,14 @@ function withTheme(Base) {
|
|
|
86
86
|
return this.themeRoot;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
* Update the host element's class based on isDark state
|
|
89
|
+
* Update the host element's and theme root's class based on isDark state
|
|
90
90
|
*/
|
|
91
91
|
updateHostClass() {
|
|
92
92
|
if (this.isDark) {
|
|
93
|
+
this.classList.add("dark");
|
|
93
94
|
this.themeRoot.classList.add("dark");
|
|
94
95
|
} else {
|
|
96
|
+
this.classList.remove("dark");
|
|
95
97
|
this.themeRoot.classList.remove("dark");
|
|
96
98
|
}
|
|
97
99
|
}
|
|
@@ -108,4 +110,4 @@ function withTheme(Base) {
|
|
|
108
110
|
export {
|
|
109
111
|
withTheme
|
|
110
112
|
};
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-H3LA56KM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mixins/theme.ts"],"sourcesContent":["/**\n * Theme Mixin\n *\n * Mixin to add theme detection and management to a Lit component\n */\n\nimport type { LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nexport type Theme = 'light' | 'dark' | 'auto'\n\n/**\n * Mixin to add theme management to a Lit component\n *\n * Provides a `theme` property and `isDark` state that automatically handles:\n * - Manual theme selection ('light' or 'dark')\n * - Auto theme detection based on system preferences\n * - Reactive updates when system theme changes\n * - Automatically wraps all rendered content in a themed div with 'dark' class when dark mode is active\n *\n * All content rendered by the component will be inside a theme-root div that receives the dark class.\n * Components can use render() normally - no changes needed.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with theme management capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withTheme } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withTheme(LitElement) {\n * render() {\n * return html`\n * <div class=\"text-neutral-20 dark:text-neutral-100\">\n * Current theme: ${this.theme}\n * </div>\n * `;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withTheme<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n /**\n * Theme mode: 'light', 'dark', or 'auto' (follows system preference)\n */\n @property({ type: String, reflect: true })\n theme: Theme = 'light'\n\n /**\n * Computed state indicating if dark mode is active\n */\n @state()\n protected isDark = false\n\n /**\n * The theme root element that wraps all rendered content and receives the dark class\n */\n private themeRoot!: HTMLDivElement\n\n private mediaQueryList: MediaQueryList | null = null\n\n connectedCallback(): void {\n super.connectedCallback()\n this.updateTheme()\n this.updateHostClass()\n\n // Listen for system theme changes when in 'auto' mode\n if (this.theme === 'auto') {\n this.mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n if (this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n updated(changedProperties: Map<string, any>): void {\n super.updated(changedProperties)\n\n // Handle theme changes\n if (changedProperties.has('theme')) {\n this.updateTheme()\n\n // Update media query listener when theme mode changes\n if (this.theme === 'auto' && !this.mediaQueryList) {\n this.mediaQueryList = window.matchMedia(\n '(prefers-color-scheme: dark)'\n )\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n } else if (this.theme !== 'auto' && this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n this.mediaQueryList = null\n }\n }\n\n // Update host class when isDark changes\n if (changedProperties.has('isDark')) {\n this.updateHostClass()\n }\n }\n\n /**\n * Handle system theme changes\n *\n * @param event - Media query list event\n */\n private handleMediaQueryChange = (event: MediaQueryListEvent): void => {\n this.isDark = event.matches\n }\n\n /**\n * Update isDark state based on theme property\n */\n protected updateTheme(): void {\n if (this.theme === 'auto') {\n this.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n } else {\n this.isDark = this.theme === 'dark'\n }\n }\n\n /**\n * Create the render root with a themed wrapper div\n */\n createRenderRoot(): Element | ShadowRoot {\n const root = super.createRenderRoot()\n\n this.themeRoot = document.createElement('div')\n this.themeRoot.setAttribute('data-theme-root', '')\n\n root.appendChild(this.themeRoot)\n return this.themeRoot\n }\n\n /**\n * Update the host element's class based on isDark state\n */\n private updateHostClass(): void {\n if (this.isDark) {\n this.themeRoot.classList.add('dark')\n } else {\n this.themeRoot.classList.remove('dark')\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"],"mappings":";;;;;AAOA,SAAS,UAAU,aAAa;AAsCzB,SAAS,UAAuC,MAAc;AAAA,EAEnE,MAAM,cAAe,KAAa;AAAA,IAAlC;AAAA;AAKE,mBAAe;AAMf,WAAU,SAAS;AAOnB,WAAQ,iBAAwC;AAgEhD;AAAA;AAAA;AAAA;AAAA;AAAA,WAAQ,yBAAyB,CAAC,UAAqC;AACrE,aAAK,SAAS,MAAM;AAAA,MACtB;AAAA;AAAA,IAhEA,oBAA0B;AACxB,YAAM,kBAAkB;AACxB,WAAK,YAAY;AACjB,WAAK,gBAAgB;AAGrB,UAAI,KAAK,UAAU,QAAQ;AACzB,aAAK,iBAAiB,OAAO,WAAW,8BAA8B;AACtE,aAAK,eAAe;AAAA,UAClB;AAAA,UACA,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,uBAA6B;AAC3B,YAAM,qBAAqB;AAE3B,UAAI,KAAK,gBAAgB;AACvB,aAAK,eAAe;AAAA,UAClB;AAAA,UACA,KAAK;AAAA,QACP;AAAA,MACF;AAAA,IACF;AAAA,IAEA,QAAQ,mBAA2C;AACjD,YAAM,QAAQ,iBAAiB;AAG/B,UAAI,kBAAkB,IAAI,OAAO,GAAG;AAClC,aAAK,YAAY;AAGjB,YAAI,KAAK,UAAU,UAAU,CAAC,KAAK,gBAAgB;AACjD,eAAK,iBAAiB,OAAO;AAAA,YAC3B;AAAA,UACF;AACA,eAAK,eAAe;AAAA,YAClB;AAAA,YACA,KAAK;AAAA,UACP;AAAA,QACF,WAAW,KAAK,UAAU,UAAU,KAAK,gBAAgB;AACvD,eAAK,eAAe;AAAA,YAClB;AAAA,YACA,KAAK;AAAA,UACP;AACA,eAAK,iBAAiB;AAAA,QACxB;AAAA,MACF;AAGA,UAAI,kBAAkB,IAAI,QAAQ,GAAG;AACnC,aAAK,gBAAgB;AAAA,MACvB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAcU,cAAoB;AAC5B,UAAI,KAAK,UAAU,QAAQ;AACzB,aAAK,SAAS,OAAO,WAAW,8BAA8B,EAAE;AAAA,MAClE,OAAO;AACL,aAAK,SAAS,KAAK,UAAU;AAAA,MAC/B;AAAA,IACF;AAAA;AAAA;AAAA;AAAA,IAKA,mBAAyC;AACvC,YAAM,OAAO,MAAM,iBAAiB;AAEpC,WAAK,YAAY,SAAS,cAAc,KAAK;AAC7C,WAAK,UAAU,aAAa,mBAAmB,EAAE;AAEjD,WAAK,YAAY,KAAK,SAAS;AAC/B,aAAO,KAAK;AAAA,IACd;AAAA;AAAA;AAAA;AAAA,IAKQ,kBAAwB;AAC9B,UAAI,KAAK,QAAQ;AACf,aAAK,UAAU,UAAU,IAAI,MAAM;AAAA,MACrC,OAAO;AACL,aAAK,UAAU,UAAU,OAAO,MAAM;AAAA,MACxC;AAAA,IACF;AAAA,EACF;
|
|
1
|
+
{"version":3,"sources":["../src/mixins/theme.ts"],"sourcesContent":["/**\n * Theme Mixin\n *\n * Mixin to add theme detection and management to a Lit component\n */\n\nimport type { LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nexport type Theme = 'light' | 'dark' | 'auto'\n\n/**\n * Mixin to add theme management to a Lit component\n *\n * Provides a `theme` property and `isDark` state that automatically handles:\n * - Manual theme selection ('light' or 'dark')\n * - Auto theme detection based on system preferences\n * - Reactive updates when system theme changes\n * - Automatically wraps all rendered content in a themed div with 'dark' class when dark mode is active\n *\n * All content rendered by the component will be inside a theme-root div that receives the dark class.\n * Components can use render() normally - no changes needed.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with theme management capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withTheme } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withTheme(LitElement) {\n * render() {\n * return html`\n * <div class=\"text-neutral-20 dark:text-neutral-100\">\n * Current theme: ${this.theme}\n * </div>\n * `;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withTheme<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n /**\n * Theme mode: 'light', 'dark', or 'auto' (follows system preference)\n */\n @property({ type: String, reflect: true })\n theme: Theme = 'light'\n\n /**\n * Computed state indicating if dark mode is active\n */\n @state()\n protected isDark = false\n\n /**\n * The theme root element that wraps all rendered content and receives the dark class\n */\n private themeRoot!: HTMLDivElement\n\n private mediaQueryList: MediaQueryList | null = null\n\n connectedCallback(): void {\n super.connectedCallback()\n this.updateTheme()\n this.updateHostClass()\n\n // Listen for system theme changes when in 'auto' mode\n if (this.theme === 'auto') {\n this.mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n if (this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n updated(changedProperties: Map<string, any>): void {\n super.updated(changedProperties)\n\n // Handle theme changes\n if (changedProperties.has('theme')) {\n this.updateTheme()\n\n // Update media query listener when theme mode changes\n if (this.theme === 'auto' && !this.mediaQueryList) {\n this.mediaQueryList = window.matchMedia(\n '(prefers-color-scheme: dark)'\n )\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n } else if (this.theme !== 'auto' && this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n this.mediaQueryList = null\n }\n }\n\n // Update host class when isDark changes\n if (changedProperties.has('isDark')) {\n this.updateHostClass()\n }\n }\n\n /**\n * Handle system theme changes\n *\n * @param event - Media query list event\n */\n private handleMediaQueryChange = (event: MediaQueryListEvent): void => {\n this.isDark = event.matches\n }\n\n /**\n * Update isDark state based on theme property\n */\n protected updateTheme(): void {\n if (this.theme === 'auto') {\n this.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n } else {\n this.isDark = this.theme === 'dark'\n }\n }\n\n /**\n * Create the render root with a themed wrapper div\n */\n createRenderRoot(): Element | ShadowRoot {\n const root = super.createRenderRoot()\n\n this.themeRoot = document.createElement('div')\n this.themeRoot.setAttribute('data-theme-root', '')\n\n root.appendChild(this.themeRoot)\n return this.themeRoot\n }\n\n /**\n * Update the host element's and theme root's class based on isDark state\n */\n private updateHostClass(): void {\n if (this.isDark) {\n this.classList.add('dark')\n this.themeRoot.classList.add('dark')\n } else {\n this.classList.remove('dark')\n this.themeRoot.classList.remove('dark')\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"],"mappings":";;;;;AAOA,SAAS,UAAU,aAAa;AAsCzB,SAAS,UAAuC,MAAc;AAAA,EAEnE,MAAM,cAAe,KAAa;AAAA,IAAlC;AAAA;AAKE,mBAAe;AAMf,WAAU,SAAS;AAOnB,WAAQ,iBAAwC;AAgEhD;AAAA;AAAA;AAAA;AAAA;AAAA,WAAQ,yBAAyB,CAAC,UAAqC;AACrE,aAAK,SAAS,MAAM;AAAA,MACtB;AAAA;AAAA,IAhEA,oBAA0B;AACxB,YAAM,kBAAkB;AACxB,WAAK,YAAY;AACjB,WAAK,gBAAgB;AAGrB,UAAI,KAAK,UAAU,QAAQ;AACzB,aAAK,iBAAiB,OAAO,WAAW,8BAA8B;AACtE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AU,UAAU,IAAI,MAAM;AAAA,MACrC,OAAO;AACL,aAAK,UAAU,OAAO,MAAM;AAC5B,aAAK,UAAU,UAAU,OAAO,MAAM;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AArHE;AAAA,IADC,SAAS,EAAE,MAAM,QAAQ,SAAS,KAAK,CAAC;AAAA,KAJrC,MAKJ;AAMU;AAAA,IADT,MAAM;AAAA,KAVH,MAWM;AAkHZ,SAAO;AACT;","names":[]}
|
|
@@ -9,12 +9,18 @@ var formatNumberDefaultOptions = {
|
|
|
9
9
|
var defaultConfig = {
|
|
10
10
|
locale: "en-US",
|
|
11
11
|
messages: {},
|
|
12
|
-
formats: {}
|
|
12
|
+
formats: {},
|
|
13
|
+
onError: () => {
|
|
14
|
+
}
|
|
13
15
|
};
|
|
14
16
|
var intlService = null;
|
|
15
17
|
function createIntlService(config = defaultConfig) {
|
|
16
18
|
let currentConfig = { ...defaultConfig, ...config };
|
|
17
|
-
let intl = createIntl({
|
|
19
|
+
let intl = createIntl({
|
|
20
|
+
...currentConfig,
|
|
21
|
+
defaultLocale: "en-US",
|
|
22
|
+
onError: currentConfig.onError || defaultConfig.onError
|
|
23
|
+
});
|
|
18
24
|
const localeChanged = signal(0);
|
|
19
25
|
let fallbackMessages = {};
|
|
20
26
|
return {
|
|
@@ -73,7 +79,8 @@ function createIntlService(config = defaultConfig) {
|
|
|
73
79
|
};
|
|
74
80
|
intl = createIntl({
|
|
75
81
|
...currentConfig,
|
|
76
|
-
defaultLocale: "en-US"
|
|
82
|
+
defaultLocale: "en-US",
|
|
83
|
+
onError: currentConfig.onError || defaultConfig.onError
|
|
77
84
|
});
|
|
78
85
|
localeChanged.value += 1;
|
|
79
86
|
},
|
|
@@ -103,4 +110,4 @@ export {
|
|
|
103
110
|
getIntlService,
|
|
104
111
|
clearIntlService
|
|
105
112
|
};
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-HTK4HH4J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/intl.ts"],"sourcesContent":["/**\n * Internationalization Service\n *\n * Provides locale-aware formatting for messages, numbers, dates, and times.\n */\n\nimport {\n createIntl,\n type FormatNumberOptions,\n type IntlConfig,\n} from '@formatjs/intl'\nimport { signal } from '@preact/signals-core'\n\n/**\n * Translation messages object type\n * Maps translation keys to their corresponding string values\n */\nexport type IntlMessages = Record<string, string>\n\n/**\n * Default format number options\n * @see https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/types/number.ts\n */\nconst formatNumberDefaultOptions = {\n maximumFractionDigits: 18,\n}\n\n/**\n * Intl service interface\n */\nexport interface IntlService {\n /**\n * Translate a string based on the key\n *\n * @param key - translation key\n * @param options - optional options for formatMessage (for variable interpolation)\n * @returns - translated string\n */\n formatMessage: (key: string, options?: Record<string, string>) => string\n\n /**\n * Number formatting based on the locale\n *\n * @param value - number to format\n * @param options - options for formatNumber\n * @returns - formatted number\n */\n formatNumber: (\n value: number | string | bigint,\n options?: FormatNumberOptions\n ) => string\n\n /**\n * Date formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted date\n */\n formatDate: (date?: string | number | Date) => string | undefined\n\n /**\n * Time formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted time\n */\n formatTime: (date?: string | number | Date) => string | undefined\n\n /**\n * Timestamp formatting based on the locale\n *\n * @param timestamp - UNIX timestamp in seconds or milliseconds\n * @param options - formatting options (predefined format name or custom Intl.DateTimeFormat options)\n * @returns - formatted date & time string\n *\n * @example\n * ```typescript\n * const intl = getIntlService();\n *\n * // Use predefined shortDateTime format\n * intl.formatTimestamp(1733251200, 'shortDateTime'); // \"Wed, Dec 3, 2025, 16:07\"\n *\n * // Use custom format options\n * intl.formatTimestamp(1733251200, { year: '2-digit', month: '2-digit', day: '2-digit' });\n * // \"12/03/25\"\n *\n * // No options (basic format)\n * intl.formatTimestamp(1733251200);\n * ```\n */\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ) => string\n\n /**\n * Change the locale and optionally update messages\n *\n * @param locale - new locale code (e.g., 'en-US', 'de-DE')\n * @param messages - optional new messages object for the locale\n */\n setLocale: (locale: string, messages?: IntlMessages) => void\n\n /**\n * Get the current locale\n *\n * @returns - current locale code (e.g., 'en-US', 'de-DE')\n */\n getLocale: () => string\n\n /**\n * Set fallback translations to use when a translation key is missing\n * Useful when the host app's intl service doesn't have all translations\n *\n * @param fallbackMessages - translations to use as fallback\n *\n * @example\n * ```typescript\n * // After intl service is initialized by host app\n * intl.setFallbackTranslations(defaultMessages);\n * ```\n */\n setFallbackTranslations: (fallbackMessages: IntlMessages) => void\n\n /**\n * Signal that tracks locale changes\n * Use this signal to reactively update UI when locale changes\n */\n localeChanged: { value: number }\n}\n\n/**\n * Default configuration for intl\n */\nexport const defaultConfig: IntlConfig = {\n locale: 'en-US',\n messages: {},\n formats: {},\n onError: () => {\n // Silent by default since translations are optional\n },\n}\n\n/**\n * Global intl service instance\n */\nlet intlService: IntlService | null = null\n\n/**\n * Create a new intl service instance\n *\n * @param config - intl configuration with locale and messages\n * @returns IntlService instance with formatting methods\n *\n * @example\n * ```typescript\n * import { createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService({\n * locale: 'en-US',\n * messages: customMessages,\n * });\n *\n * // Enable warnings for missing translations (useful for debugging)\n * const intlWithWarnings = createIntlService({\n * locale: 'en-US',\n * messages: customMessages,\n * onError: (err) => {\n * console.error('Translation error:', err);\n * },\n * });\n *\n * const translated = intl.formatMessage('app.title');\n * const formatted = intl.formatNumber(1234.56);\n * const currentLocale = intl.getLocale(); // 'en-US'\n *\n * // Change locale\n * intl.setLocale('de-DE', germanMessages);\n * console.log(intl.getLocale()); // 'de-DE'\n * ```\n */\nexport function createIntlService(\n config: IntlConfig = defaultConfig\n): IntlService {\n let currentConfig = { ...defaultConfig, ...config }\n let intl = createIntl({\n ...currentConfig,\n defaultLocale: 'en-US',\n onError: currentConfig.onError || defaultConfig.onError,\n })\n const localeChanged = signal(0)\n let fallbackMessages: IntlMessages = {}\n\n return {\n formatMessage: (key: string, options?: Record<string, string>): string => {\n try {\n const result = intl.formatMessage({ id: key }, options)\n\n if (result && result !== key) {\n return result\n }\n\n // If no translation found, check fallback\n if (fallbackMessages[key]) {\n return fallbackMessages[key]\n }\n\n return key\n } catch {\n // On error, try fallback\n return fallbackMessages[key] || key\n }\n },\n\n formatNumber: (\n value: number | string | bigint,\n options: FormatNumberOptions = {}\n ): string => {\n if (value === null || value === undefined) {\n return '0'\n }\n\n const _value =\n typeof value === 'string' ? Number.parseFloat(value) : value\n\n const mergedOptions = {\n ...formatNumberDefaultOptions,\n ...options,\n }\n\n return intl.formatNumber(_value as number, mergedOptions) || ''\n },\n\n formatDate: (date?: string | number | Date): string => {\n return intl.formatDate(date)\n },\n\n formatTime: (date?: string | number | Date): string => {\n return intl.formatTime(date)\n },\n\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ): string => {\n if (!timestamp) return ''\n\n const time = typeof timestamp === 'string' ? Number(timestamp) : timestamp\n const date =\n time < 10_000_000_000\n ? new Date(time * 1000) // seconds\n : new Date(time) // milliseconds\n\n // Handle predefined format\n if (typeof options === 'string') {\n const dateTimeOptions = currentConfig.formats?.date?.[\n options\n ] as Intl.DateTimeFormatOptions\n\n if (dateTimeOptions) {\n return new Intl.DateTimeFormat(\n currentConfig.locale,\n dateTimeOptions\n ).format(date)\n }\n\n // Fallback to default format if predefined format not found\n return intl.formatDate(date) || ''\n }\n\n // For normal @formatjs/intl options\n return intl.formatDate(date, options) || ''\n },\n\n setLocale: (locale: string, messages?: IntlMessages): void => {\n currentConfig = {\n ...currentConfig,\n locale,\n messages: messages || currentConfig.messages,\n }\n intl = createIntl({\n ...currentConfig,\n defaultLocale: 'en-US',\n onError: currentConfig.onError || defaultConfig.onError,\n })\n localeChanged.value += 1\n },\n\n getLocale: (): string => {\n return currentConfig.locale\n },\n\n setFallbackTranslations: (fallbackMessagesInput: IntlMessages): void => {\n fallbackMessages = fallbackMessagesInput\n },\n\n localeChanged,\n }\n}\n\n/**\n * Set the global intl service\n * Call this once from your app initialization\n *\n * @param service - IntlService instance\n *\n * @example\n * ```typescript\n * import { setIntlService, createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService(config);\n * setIntlService(intl);\n * ```\n */\nexport function setIntlService(service: IntlService): void {\n intlService = service\n}\n\n/**\n * Get the current global intl service\n * Returns null if no service has been set\n *\n * @example\n * ```typescript\n * import { getIntlService } from '@lukso/core/services/intl';\n *\n * const intl = getIntlService();\n * if (intl) {\n * console.log(intl.getLocale());\n * }\n * ```\n */\nexport function getIntlService(): IntlService | null {\n return intlService\n}\n\n/**\n * Clear the global intl service\n * Useful for testing or cleanup\n */\nexport function clearIntlService(): void {\n intlService = null\n}\n"],"mappings":";AAMA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,cAAc;AAYvB,IAAM,6BAA6B;AAAA,EACjC,uBAAuB;AACzB;AA6GO,IAAM,gBAA4B;AAAA,EACvC,QAAQ;AAAA,EACR,UAAU,CAAC;AAAA,EACX,SAAS,CAAC;AAAA,EACV,SAAS,MAAM;AAAA,EAEf;AACF;AAKA,IAAI,cAAkC;AAmC/B,SAAS,kBACd,SAAqB,eACR;AACb,MAAI,gBAAgB,EAAE,GAAG,eAAe,GAAG,OAAO;AAClD,MAAI,OAAO,WAAW;AAAA,IACpB,GAAG;AAAA,IACH,eAAe;AAAA,IACf,SAAS,cAAc,WAAW,cAAc;AAAA,EAClD,CAAC;AACD,QAAM,gBAAgB,OAAO,CAAC;AAC9B,MAAI,mBAAiC,CAAC;AAEtC,SAAO;AAAA,IACL,eAAe,CAAC,KAAa,YAA6C;AACxE,UAAI;AACF,cAAM,SAAS,KAAK,cAAc,EAAE,IAAI,IAAI,GAAG,OAAO;AAEtD,YAAI,UAAU,WAAW,KAAK;AAC5B,iBAAO;AAAA,QACT;AAGA,YAAI,iBAAiB,GAAG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eAAe;AAAA,QACf,SAAS,cAAc,WAAW,cAAc;AAAA,MAClD,CAAC;AACD,oBAAc,SAAS;AAAA,IACzB;AAAA,IAEA,WAAW,MAAc;AACvB,aAAO,cAAc;AAAA,IACvB;AAAA,IAEA,yBAAyB,CAAC,0BAA8C;AACtE,yBAAmB;AAAA,IACrB;AAAA,IAEA;AAAA,EACF;AACF;AAgBO,SAAS,eAAe,SAA4B;AACzD,gBAAc;AAChB;AAgBO,SAAS,iBAAqC;AACnD,SAAO;AACT;AAMO,SAAS,mBAAyB;AACvC,gBAAc;AAChB;","names":[]}
|
|
@@ -9,12 +9,18 @@ var formatNumberDefaultOptions = {
|
|
|
9
9
|
var defaultConfig = {
|
|
10
10
|
locale: "en-US",
|
|
11
11
|
messages: {},
|
|
12
|
-
formats: {}
|
|
12
|
+
formats: {},
|
|
13
|
+
onError: () => {
|
|
14
|
+
}
|
|
13
15
|
};
|
|
14
16
|
var intlService = null;
|
|
15
17
|
function createIntlService(config = defaultConfig) {
|
|
16
18
|
let currentConfig = { ...defaultConfig, ...config };
|
|
17
|
-
let intl = _intl.createIntl.call(void 0, {
|
|
19
|
+
let intl = _intl.createIntl.call(void 0, {
|
|
20
|
+
...currentConfig,
|
|
21
|
+
defaultLocale: "en-US",
|
|
22
|
+
onError: currentConfig.onError || defaultConfig.onError
|
|
23
|
+
});
|
|
18
24
|
const localeChanged = _signalscore.signal.call(void 0, 0);
|
|
19
25
|
let fallbackMessages = {};
|
|
20
26
|
return {
|
|
@@ -73,7 +79,8 @@ function createIntlService(config = defaultConfig) {
|
|
|
73
79
|
};
|
|
74
80
|
intl = _intl.createIntl.call(void 0, {
|
|
75
81
|
...currentConfig,
|
|
76
|
-
defaultLocale: "en-US"
|
|
82
|
+
defaultLocale: "en-US",
|
|
83
|
+
onError: currentConfig.onError || defaultConfig.onError
|
|
77
84
|
});
|
|
78
85
|
localeChanged.value += 1;
|
|
79
86
|
},
|
|
@@ -103,4 +110,4 @@ function clearIntlService() {
|
|
|
103
110
|
|
|
104
111
|
|
|
105
112
|
exports.defaultConfig = defaultConfig; exports.createIntlService = createIntlService; exports.setIntlService = setIntlService; exports.getIntlService = getIntlService; exports.clearIntlService = clearIntlService;
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-IDQ6WJY5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-IDQ6WJY5.cjs","../src/services/intl.ts"],"names":[],"mappings":"AAAA;ACMA;AACE;AAAA,sCAGK;AACP,mDAAuB;AAYvB,IAAM,2BAAA,EAA6B;AAAA,EACjC,qBAAA,EAAuB;AACzB,CAAA;AA6GO,IAAM,cAAA,EAA4B;AAAA,EACvC,MAAA,EAAQ,OAAA;AAAA,EACR,QAAA,EAAU,CAAC,CAAA;AAAA,EACX,OAAA,EAAS,CAAC,CAAA;AAAA,EACV,OAAA,EAAS,CAAA,EAAA,GAAM;AAAA,EAEf;AACF,CAAA;AAKA,IAAI,YAAA,EAAkC,IAAA;AAmC/B,SAAS,iBAAA,CACd,OAAA,EAAqB,aAAA,EACR;AACb,EAAA,IAAI,cAAA,EAAgB,EAAE,GAAG,aAAA,EAAe,GAAG,OAAO,CAAA;AAClD,EAAA,IAAI,KAAA,EAAO,8BAAA;AAAW,IACpB,GAAG,aAAA;AAAA,IACH,aAAA,EAAe,OAAA;AAAA,IACf,OAAA,EAAS,aAAA,CAAc,QAAA,GAAW,aAAA,CAAc;AAAA,EAClD,CAAC,CAAA;AACD,EAAA,MAAM,cAAA,EAAgB,iCAAA,CAAQ,CAAA;AAC9B,EAAA,IAAI,iBAAA,EAAiC,CAAC,CAAA;AAEtC,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,CAAC,GAAA,EAAa,OAAA,EAAA,GAA6C;AACxE,MAAA,IAAI;AACF,QAAA,MAAM,OAAA,EAAS,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA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B,CAAA;AAAA,IAEA,uBAAA,EAAyB,CAAC,qBAAA,EAAA,GAA8C;AACtE,MAAA,iBAAA,EAAmB,qBAAA;AAAA,IACrB,CAAA;AAAA,IAEA;AAAA,EACF,CAAA;AACF;AAgBO,SAAS,cAAA,CAAe,OAAA,EAA4B;AACzD,EAAA,YAAA,EAAc,OAAA;AAChB;AAgBO,SAAS,cAAA,CAAA,EAAqC;AACnD,EAAA,OAAO,WAAA;AACT;AAMO,SAAS,gBAAA,CAAA,EAAyB;AACvC,EAAA,YAAA,EAAc,IAAA;AAChB;AD9OA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,oNAAC","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-IDQ6WJY5.cjs","sourcesContent":[null,"/**\n * Internationalization Service\n *\n * Provides locale-aware formatting for messages, numbers, dates, and times.\n */\n\nimport {\n createIntl,\n type FormatNumberOptions,\n type IntlConfig,\n} from '@formatjs/intl'\nimport { signal } from '@preact/signals-core'\n\n/**\n * Translation messages object type\n * Maps translation keys to their corresponding string values\n */\nexport type IntlMessages = Record<string, string>\n\n/**\n * Default format number options\n * @see https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/types/number.ts\n */\nconst formatNumberDefaultOptions = {\n maximumFractionDigits: 18,\n}\n\n/**\n * Intl service interface\n */\nexport interface IntlService {\n /**\n * Translate a string based on the key\n *\n * @param key - translation key\n * @param options - optional options for formatMessage (for variable interpolation)\n * @returns - translated string\n */\n formatMessage: (key: string, options?: Record<string, string>) => string\n\n /**\n * Number formatting based on the locale\n *\n * @param value - number to format\n * @param options - options for formatNumber\n * @returns - formatted number\n */\n formatNumber: (\n value: number | string | bigint,\n options?: FormatNumberOptions\n ) => string\n\n /**\n * Date formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted date\n */\n formatDate: (date?: string | number | Date) => string | undefined\n\n /**\n * Time formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted time\n */\n formatTime: (date?: string | number | Date) => string | undefined\n\n /**\n * Timestamp formatting based on the locale\n *\n * @param timestamp - UNIX timestamp in seconds or milliseconds\n * @param options - formatting options (predefined format name or custom Intl.DateTimeFormat options)\n * @returns - formatted date & time string\n *\n * @example\n * ```typescript\n * const intl = getIntlService();\n *\n * // Use predefined shortDateTime format\n * intl.formatTimestamp(1733251200, 'shortDateTime'); // \"Wed, Dec 3, 2025, 16:07\"\n *\n * // Use custom format options\n * intl.formatTimestamp(1733251200, { year: '2-digit', month: '2-digit', day: '2-digit' });\n * // \"12/03/25\"\n *\n * // No options (basic format)\n * intl.formatTimestamp(1733251200);\n * ```\n */\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ) => string\n\n /**\n * Change the locale and optionally update messages\n *\n * @param locale - new locale code (e.g., 'en-US', 'de-DE')\n * @param messages - optional new messages object for the locale\n */\n setLocale: (locale: string, messages?: IntlMessages) => void\n\n /**\n * Get the current locale\n *\n * @returns - current locale code (e.g., 'en-US', 'de-DE')\n */\n getLocale: () => string\n\n /**\n * Set fallback translations to use when a translation key is missing\n * Useful when the host app's intl service doesn't have all translations\n *\n * @param fallbackMessages - translations to use as fallback\n *\n * @example\n * ```typescript\n * // After intl service is initialized by host app\n * intl.setFallbackTranslations(defaultMessages);\n * ```\n */\n setFallbackTranslations: (fallbackMessages: IntlMessages) => void\n\n /**\n * Signal that tracks locale changes\n * Use this signal to reactively update UI when locale changes\n */\n localeChanged: { value: number }\n}\n\n/**\n * Default configuration for intl\n */\nexport const defaultConfig: IntlConfig = {\n locale: 'en-US',\n messages: {},\n formats: {},\n onError: () => {\n // Silent by default since translations are optional\n },\n}\n\n/**\n * Global intl service instance\n */\nlet intlService: IntlService | null = null\n\n/**\n * Create a new intl service instance\n *\n * @param config - intl configuration with locale and messages\n * @returns IntlService instance with formatting methods\n *\n * @example\n * ```typescript\n * import { createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService({\n * locale: 'en-US',\n * messages: customMessages,\n * });\n *\n * // Enable warnings for missing translations (useful for debugging)\n * const intlWithWarnings = createIntlService({\n * locale: 'en-US',\n * messages: customMessages,\n * onError: (err) => {\n * console.error('Translation error:', err);\n * },\n * });\n *\n * const translated = intl.formatMessage('app.title');\n * const formatted = intl.formatNumber(1234.56);\n * const currentLocale = intl.getLocale(); // 'en-US'\n *\n * // Change locale\n * intl.setLocale('de-DE', germanMessages);\n * console.log(intl.getLocale()); // 'de-DE'\n * ```\n */\nexport function createIntlService(\n config: IntlConfig = defaultConfig\n): IntlService {\n let currentConfig = { ...defaultConfig, ...config }\n let intl = createIntl({\n ...currentConfig,\n defaultLocale: 'en-US',\n onError: currentConfig.onError || defaultConfig.onError,\n })\n const localeChanged = signal(0)\n let fallbackMessages: IntlMessages = {}\n\n return {\n formatMessage: (key: string, options?: Record<string, string>): string => {\n try {\n const result = intl.formatMessage({ id: key }, options)\n\n if (result && result !== key) {\n return result\n }\n\n // If no translation found, check fallback\n if (fallbackMessages[key]) {\n return fallbackMessages[key]\n }\n\n return key\n } catch {\n // On error, try fallback\n return fallbackMessages[key] || key\n }\n },\n\n formatNumber: (\n value: number | string | bigint,\n options: FormatNumberOptions = {}\n ): string => {\n if (value === null || value === undefined) {\n return '0'\n }\n\n const _value =\n typeof value === 'string' ? Number.parseFloat(value) : value\n\n const mergedOptions = {\n ...formatNumberDefaultOptions,\n ...options,\n }\n\n return intl.formatNumber(_value as number, mergedOptions) || ''\n },\n\n formatDate: (date?: string | number | Date): string => {\n return intl.formatDate(date)\n },\n\n formatTime: (date?: string | number | Date): string => {\n return intl.formatTime(date)\n },\n\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ): string => {\n if (!timestamp) return ''\n\n const time = typeof timestamp === 'string' ? Number(timestamp) : timestamp\n const date =\n time < 10_000_000_000\n ? new Date(time * 1000) // seconds\n : new Date(time) // milliseconds\n\n // Handle predefined format\n if (typeof options === 'string') {\n const dateTimeOptions = currentConfig.formats?.date?.[\n options\n ] as Intl.DateTimeFormatOptions\n\n if (dateTimeOptions) {\n return new Intl.DateTimeFormat(\n currentConfig.locale,\n dateTimeOptions\n ).format(date)\n }\n\n // Fallback to default format if predefined format not found\n return intl.formatDate(date) || ''\n }\n\n // For normal @formatjs/intl options\n return intl.formatDate(date, options) || ''\n },\n\n setLocale: (locale: string, messages?: IntlMessages): void => {\n currentConfig = {\n ...currentConfig,\n locale,\n messages: messages || currentConfig.messages,\n }\n intl = createIntl({\n ...currentConfig,\n defaultLocale: 'en-US',\n onError: currentConfig.onError || defaultConfig.onError,\n })\n localeChanged.value += 1\n },\n\n getLocale: (): string => {\n return currentConfig.locale\n },\n\n setFallbackTranslations: (fallbackMessagesInput: IntlMessages): void => {\n fallbackMessages = fallbackMessagesInput\n },\n\n localeChanged,\n }\n}\n\n/**\n * Set the global intl service\n * Call this once from your app initialization\n *\n * @param service - IntlService instance\n *\n * @example\n * ```typescript\n * import { setIntlService, createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService(config);\n * setIntlService(intl);\n * ```\n */\nexport function setIntlService(service: IntlService): void {\n intlService = service\n}\n\n/**\n * Get the current global intl service\n * Returns null if no service has been set\n *\n * @example\n * ```typescript\n * import { getIntlService } from '@lukso/core/services/intl';\n *\n * const intl = getIntlService();\n * if (intl) {\n * console.log(intl.getLocale());\n * }\n * ```\n */\nexport function getIntlService(): IntlService | null {\n return intlService\n}\n\n/**\n * Clear the global intl service\n * Useful for testing or cleanup\n */\nexport function clearIntlService(): void {\n intlService = null\n}\n"]}
|
|
@@ -3,12 +3,9 @@ import {
|
|
|
3
3
|
defaultConfig,
|
|
4
4
|
getIntlService,
|
|
5
5
|
setIntlService
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HTK4HH4J.js";
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
import { effect } from "@preact/signals-core";
|
|
10
|
-
|
|
11
|
-
// ../translations/en_US.json
|
|
8
|
+
// translations/en_US.json
|
|
12
9
|
var en_US_default = {
|
|
13
10
|
connect_modal_try_again: "Try again",
|
|
14
11
|
connect_modal_title: "Let\u2019s log you in",
|
|
@@ -27,6 +24,7 @@ var en_US_default = {
|
|
|
27
24
|
};
|
|
28
25
|
|
|
29
26
|
// src/mixins/intl.ts
|
|
27
|
+
import { effect } from "@preact/signals-core";
|
|
30
28
|
function withIntlService(Base) {
|
|
31
29
|
class Mixin extends Base {
|
|
32
30
|
constructor() {
|
|
@@ -84,4 +82,4 @@ function withIntlService(Base) {
|
|
|
84
82
|
export {
|
|
85
83
|
withIntlService
|
|
86
84
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
85
|
+
//# sourceMappingURL=chunk-K5NPHWCG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../translations/en_US.json","../src/mixins/intl.ts"],"sourcesContent":["{\n \"connect_modal_try_again\": \"Try again\",\n \"connect_modal_title\": \"Let’s log you in\",\n \"connect_modal_qr_code_title\": \"Scan to log in\",\n \"connect_modal_qr_code_description\": \"Scan the below QR code with the Universal Profile mobile app to log in\",\n \"connect_modal_other_connectors\": \"Connect Wallet\",\n \"connect_modal_or_info\": \"Log in with a different wallet\",\n \"connect_modal_or\": \"Or\",\n \"connect_modal_installed\": \"INSTALLED\",\n \"connect_modal_failed_to_load\": \"Failed to load...\",\n \"connect_modal_eoa_title\": \"Connect your Wallet\",\n \"connect_modal_description\": \"Log in with your Universal Profile\",\n \"connect_modal_connectors_up_mobile\": \"Mobile Application\",\n \"connect_modal_connectors_up_browser_extension\": \"Browser Extension\",\n \"connect_modal_connectors_passkey_wallet\": \"Passkey Wallet\"\n}","/**\n * Internationalization Mixin\n *\n * Mixin to add internationalization service to a Lit component\n */\n\nimport englishTranslations from '@lukso/core/translations/en_US.json'\nimport { effect } from '@preact/signals-core'\nimport type { LitElement } from 'lit'\nimport {\n createIntlService,\n defaultConfig,\n getIntlService,\n type IntlService,\n setIntlService,\n} from '../services/intl.js'\n\n/**\n * Mixin to add internationalization service to a Lit component\n *\n * Provides access to the global intl service with reactive locale changes.\n * Automatically subscribes to locale changes and triggers re-renders.\n *\n * The component will use the global intl service if available, or create a local one.\n * This follows the singleton pattern for the global service while allowing flexibility.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with intl service capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withIntlService } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withIntlService(LitElement) {\n * render() {\n * return html\\`<p>\\${this.formatMessage('app.welcome')}</p>\\`;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withIntlService<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n protected unsubscribeIntl: (() => void) | undefined = undefined\n\n connectedCallback(): void {\n super.connectedCallback()\n\n // Subscribe to intl changes via signal\n let intl: IntlService | null = getIntlService()\n\n // When no intl is provided by host app we initialize our own\n if (!intl) {\n intl = this.setupLocalIntl() ?? null\n }\n\n if (intl) {\n this.unsubscribeIntl = effect(() => {\n // Access the signal to track changes\n intl?.localeChanged.value\n this.requestUpdate()\n })\n }\n\n // Set fallback for missing translations\n intl?.setFallbackTranslations(englishTranslations as any)\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n // Unsubscribe from intl changes\n if (typeof this.unsubscribeIntl === 'function') {\n this.unsubscribeIntl()\n }\n }\n\n /**\n * Setup a local intl service with default configuration\n * Subclasses can override this to customize initialization\n */\n protected setupLocalIntl(): IntlService | undefined {\n const intlService = createIntlService(\n Object.assign(defaultConfig, {\n messages: englishTranslations,\n })\n )\n setIntlService(intlService)\n return intlService\n }\n\n /**\n * Format message using the intl service\n */\n formatMessage(key?: string, options?: Record<string, string>): string {\n if (!key) {\n console.warn('No translation key provided to formatMessage')\n return ''\n }\n\n const intl = getIntlService()\n return intl?.formatMessage(key,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AA,MACT;AAEA,YAAM,OAAO,eAAe;AAC5B,aAAO,MAAM,cAAc,KAAK,OAAO,KAAK;AAAA,IAC9C;AAAA,EACF;AAGA,SAAO;AACT;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -23,17 +23,17 @@ require('./chunk-DWXFDFMM.cjs');
|
|
|
23
23
|
var _chunkCC3LFUYYcjs = require('./chunk-CC3LFUYY.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
var
|
|
26
|
+
var _chunk7CRBSMQ7cjs = require('./chunk-7CRBSMQ7.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _chunkIDQ6WJY5cjs = require('./chunk-IDQ6WJY5.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunk6VE73XQHcjs = require('./chunk-6VE73XQH.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
var _chunkNJQVWIZLcjs = require('./chunk-NJQVWIZL.cjs');
|
|
@@ -60,5 +60,5 @@ require('./chunk-ZBDE64SD.cjs');
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
exports.EXTENSION_STORE_LINKS = _chunkQU6NUTY6cjs.EXTENSION_STORE_LINKS; exports.GRAPHQL_ENDPOINT_MAINNET = _chunkLUT5BHYLcjs.GRAPHQL_ENDPOINT_MAINNET; exports.GRAPHQL_ENDPOINT_TESTNET = _chunkLUT5BHYLcjs.GRAPHQL_ENDPOINT_TESTNET; exports.LUKSO_CHAINS_BY_ID = _chunkMCNNULYXcjs.LUKSO_CHAINS_BY_ID; exports.SUPPORTED_NETWORK_IDS = _chunkLUT5BHYLcjs.SUPPORTED_NETWORK_IDS; exports.UrlConverter = _chunkQU6NUTY6cjs.UrlConverter; exports.UrlResolver = _chunkQU6NUTY6cjs.UrlResolver; exports.browserInfo = _chunkQU6NUTY6cjs.browserInfo; exports.clearIntlService =
|
|
63
|
+
exports.EXTENSION_STORE_LINKS = _chunkQU6NUTY6cjs.EXTENSION_STORE_LINKS; exports.GRAPHQL_ENDPOINT_MAINNET = _chunkLUT5BHYLcjs.GRAPHQL_ENDPOINT_MAINNET; exports.GRAPHQL_ENDPOINT_TESTNET = _chunkLUT5BHYLcjs.GRAPHQL_ENDPOINT_TESTNET; exports.LUKSO_CHAINS_BY_ID = _chunkMCNNULYXcjs.LUKSO_CHAINS_BY_ID; exports.SUPPORTED_NETWORK_IDS = _chunkLUT5BHYLcjs.SUPPORTED_NETWORK_IDS; exports.UrlConverter = _chunkQU6NUTY6cjs.UrlConverter; exports.UrlResolver = _chunkQU6NUTY6cjs.UrlResolver; exports.browserInfo = _chunkQU6NUTY6cjs.browserInfo; exports.clearIntlService = _chunkIDQ6WJY5cjs.clearIntlService; exports.createIntlService = _chunkIDQ6WJY5cjs.createIntlService; exports.defaultConfig = _chunkIDQ6WJY5cjs.defaultConfig; exports.deviceService = _chunkNJQVWIZLcjs.deviceService; exports.getChainById = _chunkMCNNULYXcjs.getChainById; exports.getIntlService = _chunkIDQ6WJY5cjs.getIntlService; exports.luksoMainnet = _chunkMCNNULYXcjs.luksoMainnet; exports.luksoTestnet = _chunkMCNNULYXcjs.luksoTestnet; exports.setIntlService = _chunkIDQ6WJY5cjs.setIntlService; exports.slug = _chunkQU6NUTY6cjs.slug; exports.withDeviceService = _chunkCC3LFUYYcjs.withDeviceService; exports.withIntlService = _chunk7CRBSMQ7cjs.withIntlService; exports.withTheme = _chunk6VE73XQHcjs.withTheme;
|
|
64
64
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -23,17 +23,17 @@ import {
|
|
|
23
23
|
} from "./chunk-3WGYJTN4.js";
|
|
24
24
|
import {
|
|
25
25
|
withIntlService
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-K5NPHWCG.js";
|
|
27
27
|
import {
|
|
28
28
|
clearIntlService,
|
|
29
29
|
createIntlService,
|
|
30
30
|
defaultConfig,
|
|
31
31
|
getIntlService,
|
|
32
32
|
setIntlService
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-HTK4HH4J.js";
|
|
34
34
|
import {
|
|
35
35
|
withTheme
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-H3LA56KM.js";
|
|
37
37
|
import {
|
|
38
38
|
deviceService
|
|
39
39
|
} from "./chunk-X2QNFZU7.js";
|
package/dist/mixins/index.cjs
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
var _chunkCC3LFUYYcjs = require('../chunk-CC3LFUYY.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../chunk-
|
|
7
|
+
var _chunk7CRBSMQ7cjs = require('../chunk-7CRBSMQ7.cjs');
|
|
8
|
+
require('../chunk-IDQ6WJY5.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk6VE73XQHcjs = require('../chunk-6VE73XQH.cjs');
|
|
12
12
|
require('../chunk-NJQVWIZL.cjs');
|
|
13
13
|
require('../chunk-ZBDE64SD.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
exports.withDeviceService = _chunkCC3LFUYYcjs.withDeviceService; exports.withIntlService =
|
|
18
|
+
exports.withDeviceService = _chunkCC3LFUYYcjs.withDeviceService; exports.withIntlService = _chunk7CRBSMQ7cjs.withIntlService; exports.withTheme = _chunk6VE73XQHcjs.withTheme;
|
|
19
19
|
//# sourceMappingURL=index.cjs.map
|
package/dist/mixins/index.js
CHANGED
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "../chunk-3WGYJTN4.js";
|
|
5
5
|
import {
|
|
6
6
|
withIntlService
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-K5NPHWCG.js";
|
|
8
|
+
import "../chunk-HTK4HH4J.js";
|
|
9
9
|
import {
|
|
10
10
|
withTheme
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-H3LA56KM.js";
|
|
12
12
|
import "../chunk-X2QNFZU7.js";
|
|
13
13
|
import "../chunk-EUXUH3YW.js";
|
|
14
14
|
export {
|
package/dist/mixins/intl.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var _chunk7CRBSMQ7cjs = require('../chunk-7CRBSMQ7.cjs');
|
|
4
|
+
require('../chunk-IDQ6WJY5.cjs');
|
|
5
5
|
require('../chunk-ZBDE64SD.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.withIntlService =
|
|
8
|
+
exports.withIntlService = _chunk7CRBSMQ7cjs.withIntlService;
|
|
9
9
|
//# sourceMappingURL=intl.cjs.map
|
package/dist/mixins/intl.js
CHANGED
package/dist/mixins/theme.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk6VE73XQHcjs = require('../chunk-6VE73XQH.cjs');
|
|
4
4
|
require('../chunk-ZBDE64SD.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
exports.withTheme =
|
|
7
|
+
exports.withTheme = _chunk6VE73XQHcjs.withTheme;
|
|
8
8
|
//# sourceMappingURL=theme.cjs.map
|
package/dist/mixins/theme.js
CHANGED
package/dist/services/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkIDQ6WJY5cjs = require('../chunk-IDQ6WJY5.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkNJQVWIZLcjs = require('../chunk-NJQVWIZL.cjs');
|
|
@@ -17,5 +17,5 @@ require('../chunk-ZBDE64SD.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
exports.clearIntlService =
|
|
20
|
+
exports.clearIntlService = _chunkIDQ6WJY5cjs.clearIntlService; exports.createIntlService = _chunkIDQ6WJY5cjs.createIntlService; exports.defaultConfig = _chunkIDQ6WJY5cjs.defaultConfig; exports.deviceService = _chunkNJQVWIZLcjs.deviceService; exports.getIntlService = _chunkIDQ6WJY5cjs.getIntlService; exports.setIntlService = _chunkIDQ6WJY5cjs.setIntlService;
|
|
21
21
|
//# sourceMappingURL=index.cjs.map
|
package/dist/services/index.js
CHANGED
package/dist/services/intl.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkIDQ6WJY5cjs = require('../chunk-IDQ6WJY5.cjs');
|
|
8
8
|
require('../chunk-ZBDE64SD.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
@@ -12,5 +12,5 @@ require('../chunk-ZBDE64SD.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.clearIntlService =
|
|
15
|
+
exports.clearIntlService = _chunkIDQ6WJY5cjs.clearIntlService; exports.createIntlService = _chunkIDQ6WJY5cjs.createIntlService; exports.defaultConfig = _chunkIDQ6WJY5cjs.defaultConfig; exports.getIntlService = _chunkIDQ6WJY5cjs.getIntlService; exports.setIntlService = _chunkIDQ6WJY5cjs.setIntlService;
|
|
16
16
|
//# sourceMappingURL=intl.cjs.map
|
package/dist/services/intl.d.cts
CHANGED
|
@@ -121,6 +121,15 @@ declare const defaultConfig: IntlConfig;
|
|
|
121
121
|
* messages: customMessages,
|
|
122
122
|
* });
|
|
123
123
|
*
|
|
124
|
+
* // Enable warnings for missing translations (useful for debugging)
|
|
125
|
+
* const intlWithWarnings = createIntlService({
|
|
126
|
+
* locale: 'en-US',
|
|
127
|
+
* messages: customMessages,
|
|
128
|
+
* onError: (err) => {
|
|
129
|
+
* console.error('Translation error:', err);
|
|
130
|
+
* },
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
124
133
|
* const translated = intl.formatMessage('app.title');
|
|
125
134
|
* const formatted = intl.formatNumber(1234.56);
|
|
126
135
|
* const currentLocale = intl.getLocale(); // 'en-US'
|
package/dist/services/intl.d.ts
CHANGED
|
@@ -121,6 +121,15 @@ declare const defaultConfig: IntlConfig;
|
|
|
121
121
|
* messages: customMessages,
|
|
122
122
|
* });
|
|
123
123
|
*
|
|
124
|
+
* // Enable warnings for missing translations (useful for debugging)
|
|
125
|
+
* const intlWithWarnings = createIntlService({
|
|
126
|
+
* locale: 'en-US',
|
|
127
|
+
* messages: customMessages,
|
|
128
|
+
* onError: (err) => {
|
|
129
|
+
* console.error('Translation error:', err);
|
|
130
|
+
* },
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
124
133
|
* const translated = intl.formatMessage('app.title');
|
|
125
134
|
* const formatted = intl.formatNumber(1234.56);
|
|
126
135
|
* const currentLocale = intl.getLocale(); // 'en-US'
|
package/dist/services/intl.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukso/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Core utilities, services, and mixins for LUKSO web components and applications",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -61,12 +61,14 @@
|
|
|
61
61
|
"types": "./dist/utils/index.d.ts",
|
|
62
62
|
"import": "./dist/utils/index.js",
|
|
63
63
|
"require": "./dist/utils/index.cjs"
|
|
64
|
-
}
|
|
64
|
+
},
|
|
65
|
+
"./translations/*.json": "./translations/*.json"
|
|
65
66
|
},
|
|
66
67
|
"files": [
|
|
67
68
|
"dist",
|
|
68
69
|
"src",
|
|
69
|
-
"README.md"
|
|
70
|
+
"README.md",
|
|
71
|
+
"translations"
|
|
70
72
|
],
|
|
71
73
|
"keywords": [
|
|
72
74
|
"lukso",
|
package/src/mixins/intl.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Mixin to add internationalization service to a Lit component
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import englishTranslations from '@lukso/core/translations/en_US.json'
|
|
7
8
|
import { effect } from '@preact/signals-core'
|
|
8
9
|
import type { LitElement } from 'lit'
|
|
9
|
-
import englishTranslations from '../../../translations/en_US.json'
|
|
10
10
|
import {
|
|
11
11
|
createIntlService,
|
|
12
12
|
defaultConfig,
|
package/src/mixins/theme.ts
CHANGED
|
@@ -156,12 +156,14 @@ export function withTheme<T extends typeof LitElement>(Base: T): any {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
* Update the host element's class based on isDark state
|
|
159
|
+
* Update the host element's and theme root's class based on isDark state
|
|
160
160
|
*/
|
|
161
161
|
private updateHostClass(): void {
|
|
162
162
|
if (this.isDark) {
|
|
163
|
+
this.classList.add('dark')
|
|
163
164
|
this.themeRoot.classList.add('dark')
|
|
164
165
|
} else {
|
|
166
|
+
this.classList.remove('dark')
|
|
165
167
|
this.themeRoot.classList.remove('dark')
|
|
166
168
|
}
|
|
167
169
|
}
|
package/src/services/intl.ts
CHANGED
|
@@ -136,6 +136,9 @@ export const defaultConfig: IntlConfig = {
|
|
|
136
136
|
locale: 'en-US',
|
|
137
137
|
messages: {},
|
|
138
138
|
formats: {},
|
|
139
|
+
onError: () => {
|
|
140
|
+
// Silent by default since translations are optional
|
|
141
|
+
},
|
|
139
142
|
}
|
|
140
143
|
|
|
141
144
|
/**
|
|
@@ -158,6 +161,15 @@ let intlService: IntlService | null = null
|
|
|
158
161
|
* messages: customMessages,
|
|
159
162
|
* });
|
|
160
163
|
*
|
|
164
|
+
* // Enable warnings for missing translations (useful for debugging)
|
|
165
|
+
* const intlWithWarnings = createIntlService({
|
|
166
|
+
* locale: 'en-US',
|
|
167
|
+
* messages: customMessages,
|
|
168
|
+
* onError: (err) => {
|
|
169
|
+
* console.error('Translation error:', err);
|
|
170
|
+
* },
|
|
171
|
+
* });
|
|
172
|
+
*
|
|
161
173
|
* const translated = intl.formatMessage('app.title');
|
|
162
174
|
* const formatted = intl.formatNumber(1234.56);
|
|
163
175
|
* const currentLocale = intl.getLocale(); // 'en-US'
|
|
@@ -171,7 +183,11 @@ export function createIntlService(
|
|
|
171
183
|
config: IntlConfig = defaultConfig
|
|
172
184
|
): IntlService {
|
|
173
185
|
let currentConfig = { ...defaultConfig, ...config }
|
|
174
|
-
let intl = createIntl({
|
|
186
|
+
let intl = createIntl({
|
|
187
|
+
...currentConfig,
|
|
188
|
+
defaultLocale: 'en-US',
|
|
189
|
+
onError: currentConfig.onError || defaultConfig.onError,
|
|
190
|
+
})
|
|
175
191
|
const localeChanged = signal(0)
|
|
176
192
|
let fallbackMessages: IntlMessages = {}
|
|
177
193
|
|
|
@@ -265,6 +281,7 @@ export function createIntlService(
|
|
|
265
281
|
intl = createIntl({
|
|
266
282
|
...currentConfig,
|
|
267
283
|
defaultLocale: 'en-US',
|
|
284
|
+
onError: currentConfig.onError || defaultConfig.onError,
|
|
268
285
|
})
|
|
269
286
|
localeChanged.value += 1
|
|
270
287
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connect_modal_try_again": "Versuchen Sie es erneut",
|
|
3
|
+
"connect_modal_title": "Wir melden Sie an",
|
|
4
|
+
"connect_modal_qr_code_title": "Scannen Sie den Scanner, um sich anzumelden.",
|
|
5
|
+
"connect_modal_other_connectors": "Connect Wallet",
|
|
6
|
+
"connect_modal_or_info": "Melden Sie sich mit einer anderen Wallet an",
|
|
7
|
+
"connect_modal_or": "Oder",
|
|
8
|
+
"connect_modal_installed": "INSTALLIERT",
|
|
9
|
+
"connect_modal_failed_to_load": "Fehler beim Laden...",
|
|
10
|
+
"connect_modal_eoa_title": "Verbinden Sie Ihre Wallet",
|
|
11
|
+
"connect_modal_description": "Melden Sie sich mit Ihrem Universalprofil an.",
|
|
12
|
+
"connect_modal_connectors_up_mobile": "Mobile Anwendung",
|
|
13
|
+
"connect_modal_connectors_passkey_wallet": "Erstellen Sie eine Passkey-Wallet"
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connect_modal_try_again": "Try again",
|
|
3
|
+
"connect_modal_title": "Let’s log you in",
|
|
4
|
+
"connect_modal_qr_code_title": "Scan to log in",
|
|
5
|
+
"connect_modal_qr_code_description": "Scan the below QR code with the Universal Profile mobile app to log in",
|
|
6
|
+
"connect_modal_other_connectors": "Connect Wallet",
|
|
7
|
+
"connect_modal_or_info": "Log in with a different wallet",
|
|
8
|
+
"connect_modal_or": "Or",
|
|
9
|
+
"connect_modal_installed": "INSTALLED",
|
|
10
|
+
"connect_modal_failed_to_load": "Failed to load...",
|
|
11
|
+
"connect_modal_eoa_title": "Connect your Wallet",
|
|
12
|
+
"connect_modal_description": "Log in with your Universal Profile",
|
|
13
|
+
"connect_modal_connectors_up_mobile": "Mobile Application",
|
|
14
|
+
"connect_modal_connectors_up_browser_extension": "Browser Extension",
|
|
15
|
+
"connect_modal_connectors_passkey_wallet": "Passkey Wallet"
|
|
16
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/intl.ts"],"sourcesContent":["/**\n * Internationalization Service\n *\n * Provides locale-aware formatting for messages, numbers, dates, and times.\n */\n\nimport {\n createIntl,\n type FormatNumberOptions,\n type IntlConfig,\n} from '@formatjs/intl'\nimport { signal } from '@preact/signals-core'\n\n/**\n * Translation messages object type\n * Maps translation keys to their corresponding string values\n */\nexport type IntlMessages = Record<string, string>\n\n/**\n * Default format number options\n * @see https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/types/number.ts\n */\nconst formatNumberDefaultOptions = {\n maximumFractionDigits: 18,\n}\n\n/**\n * Intl service interface\n */\nexport interface IntlService {\n /**\n * Translate a string based on the key\n *\n * @param key - translation key\n * @param options - optional options for formatMessage (for variable interpolation)\n * @returns - translated string\n */\n formatMessage: (key: string, options?: Record<string, string>) => string\n\n /**\n * Number formatting based on the locale\n *\n * @param value - number to format\n * @param options - options for formatNumber\n * @returns - formatted number\n */\n formatNumber: (\n value: number | string | bigint,\n options?: FormatNumberOptions\n ) => string\n\n /**\n * Date formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted date\n */\n formatDate: (date?: string | number | Date) => string | undefined\n\n /**\n * Time formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted time\n */\n formatTime: (date?: string | number | Date) => string | undefined\n\n /**\n * Timestamp formatting based on the locale\n *\n * @param timestamp - UNIX timestamp in seconds or milliseconds\n * @param options - formatting options (predefined format name or custom Intl.DateTimeFormat options)\n * @returns - formatted date & time string\n *\n * @example\n * ```typescript\n * const intl = getIntlService();\n *\n * // Use predefined shortDateTime format\n * intl.formatTimestamp(1733251200, 'shortDateTime'); // \"Wed, Dec 3, 2025, 16:07\"\n *\n * // Use custom format options\n * intl.formatTimestamp(1733251200, { year: '2-digit', month: '2-digit', day: '2-digit' });\n * // \"12/03/25\"\n *\n * // No options (basic format)\n * intl.formatTimestamp(1733251200);\n * ```\n */\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ) => string\n\n /**\n * Change the locale and optionally update messages\n *\n * @param locale - new locale code (e.g., 'en-US', 'de-DE')\n * @param messages - optional new messages object for the locale\n */\n setLocale: (locale: string, messages?: IntlMessages) => void\n\n /**\n * Get the current locale\n *\n * @returns - current locale code (e.g., 'en-US', 'de-DE')\n */\n getLocale: () => string\n\n /**\n * Set fallback translations to use when a translation key is missing\n * Useful when the host app's intl service doesn't have all translations\n *\n * @param fallbackMessages - translations to use as fallback\n *\n * @example\n * ```typescript\n * // After intl service is initialized by host app\n * intl.setFallbackTranslations(defaultMessages);\n * ```\n */\n setFallbackTranslations: (fallbackMessages: IntlMessages) => void\n\n /**\n * Signal that tracks locale changes\n * Use this signal to reactively update UI when locale changes\n */\n localeChanged: { value: number }\n}\n\n/**\n * Default configuration for intl\n */\nexport const defaultConfig: IntlConfig = {\n locale: 'en-US',\n messages: {},\n formats: {},\n}\n\n/**\n * Global intl service instance\n */\nlet intlService: IntlService | null = null\n\n/**\n * Create a new intl service instance\n *\n * @param config - intl configuration with locale and messages\n * @returns IntlService instance with formatting methods\n *\n * @example\n * ```typescript\n * import { createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService({\n * locale: 'en-US',\n * messages: customMessages,\n * });\n *\n * const translated = intl.formatMessage('app.title');\n * const formatted = intl.formatNumber(1234.56);\n * const currentLocale = intl.getLocale(); // 'en-US'\n *\n * // Change locale\n * intl.setLocale('de-DE', germanMessages);\n * console.log(intl.getLocale()); // 'de-DE'\n * ```\n */\nexport function createIntlService(\n config: IntlConfig = defaultConfig\n): IntlService {\n let currentConfig = { ...defaultConfig, ...config }\n let intl = createIntl({ ...currentConfig, defaultLocale: 'en-US' })\n const localeChanged = signal(0)\n let fallbackMessages: IntlMessages = {}\n\n return {\n formatMessage: (key: string, options?: Record<string, string>): string => {\n try {\n const result = intl.formatMessage({ id: key }, options)\n\n if (result && result !== key) {\n return result\n }\n\n // If no translation found, check fallback\n if (fallbackMessages[key]) {\n return fallbackMessages[key]\n }\n\n return key\n } catch {\n // On error, try fallback\n return fallbackMessages[key] || key\n }\n },\n\n formatNumber: (\n value: number | string | bigint,\n options: FormatNumberOptions = {}\n ): string => {\n if (value === null || value === undefined) {\n return '0'\n }\n\n const _value =\n typeof value === 'string' ? Number.parseFloat(value) : value\n\n const mergedOptions = {\n ...formatNumberDefaultOptions,\n ...options,\n }\n\n return intl.formatNumber(_value as number, mergedOptions) || ''\n },\n\n formatDate: (date?: string | number | Date): string => {\n return intl.formatDate(date)\n },\n\n formatTime: (date?: string | number | Date): string => {\n return intl.formatTime(date)\n },\n\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ): string => {\n if (!timestamp) return ''\n\n const time = typeof timestamp === 'string' ? Number(timestamp) : timestamp\n const date =\n time < 10_000_000_000\n ? new Date(time * 1000) // seconds\n : new Date(time) // milliseconds\n\n // Handle predefined format\n if (typeof options === 'string') {\n const dateTimeOptions = currentConfig.formats?.date?.[\n options\n ] as Intl.DateTimeFormatOptions\n\n if (dateTimeOptions) {\n return new Intl.DateTimeFormat(\n currentConfig.locale,\n dateTimeOptions\n ).format(date)\n }\n\n // Fallback to default format if predefined format not found\n return intl.formatDate(date) || ''\n }\n\n // For normal @formatjs/intl options\n return intl.formatDate(date, options) || ''\n },\n\n setLocale: (locale: string, messages?: IntlMessages): void => {\n currentConfig = {\n ...currentConfig,\n locale,\n messages: messages || currentConfig.messages,\n }\n intl = createIntl({\n ...currentConfig,\n defaultLocale: 'en-US',\n })\n localeChanged.value += 1\n },\n\n getLocale: (): string => {\n return currentConfig.locale\n },\n\n setFallbackTranslations: (fallbackMessagesInput: IntlMessages): void => {\n fallbackMessages = fallbackMessagesInput\n },\n\n localeChanged,\n }\n}\n\n/**\n * Set the global intl service\n * Call this once from your app initialization\n *\n * @param service - IntlService instance\n *\n * @example\n * ```typescript\n * import { setIntlService, createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService(config);\n * setIntlService(intl);\n * ```\n */\nexport function setIntlService(service: IntlService): void {\n intlService = service\n}\n\n/**\n * Get the current global intl service\n * Returns null if no service has been set\n *\n * @example\n * ```typescript\n * import { getIntlService } from '@lukso/core/services/intl';\n *\n * const intl = getIntlService();\n * if (intl) {\n * console.log(intl.getLocale());\n * }\n * ```\n */\nexport function getIntlService(): IntlService | null {\n return intlService\n}\n\n/**\n * Clear the global intl service\n * Useful for testing or cleanup\n */\nexport function clearIntlService(): void {\n intlService = null\n}\n"],"mappings":";AAMA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,cAAc;AAYvB,IAAM,6B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AAS,IAAI;AACjE,YAAM,OACJ,OAAO,OACH,IAAI,KAAK,OAAO,GAAI,IACpB,IAAI,KAAK,IAAI;AAGnB,UAAI,OAAO,YAAY,UAAU;AAC/B,cAAM,kBAAkB,cAAc,SAAS,OAC7C,OACF;AAEA,YAAI,iBAAiB;AACnB,iBAAO,IAAI,KAAK;AAAA,YACd,cAAc;AAAA,YACd;AAAA,UACF,EAAE,OAAO,IAAI;AAAA,QACf;AAGA,eAAO,KAAK,WAAW,IAAI,KAAK;AAAA,MAClC;AAGA,aAAO,KAAK,WAAW,MAAM,OAAO,KAAK;AAAA,IAC3C;AAAA,IAEA,WAAW,CAAC,QAAgB,aAAkC;AAC5D,sBAAgB;AAAA,QACd,GAAG;AAAA,QACH;AAAA,QACA,UAAU,YAAY,cAAc;AAAA,MACtC;AACA,aAAO,WAAW;AAAA,QAChB,GAAG;AAAA,QACH,eAAe;AAAA,MACjB,CAAC;AACD,oBAAc,SAAS;AAAA,IACzB;AAAA,IAEA,WAAW,MAAc;AACvB,aAAO,cAAc;AAAA,IACvB;AAAA,IAEA,yBAAyB,CAAC,0BAA8C;AACtE,yBAAmB;AAAA,IACrB;AAAA,IAEA;AAAA,EACF;AACF;AAgBO,SAAS,eAAe,SAA4B;AACzD,gBAAc;AAChB;AAgBO,SAAS,iBAAqC;AACnD,SAAO;AACT;AAMO,SAAS,mBAAyB;AACvC,gBAAc;AAChB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-CUDG6NPH.cjs","../src/mixins/theme.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACGA,iDAAgC;AAsCzB,SAAS,SAAA,CAAuC,IAAA,EAAc;AAAA,EAEnE,MAAM,MAAA,QAAe,KAAa;AAAA,IAAlC,WAAA,CAAA,EAAA;AAAA,MAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAKE,MAAA,I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,IAAA,CAAK,SAAS,CAAA;AAC/B,MAAA,OAAO,IAAA,CAAK,SAAA;AAAA,IACd;AAAA;AAAA;AAAA;AAAA,IAKQ,eAAA,CAAA,EAAwB;AAC9B,MAAA,GAAA,CAAI,IAAA,CAAK,MAAA,EAAQ;AACf,QAAA,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,GAAA,CAAI,MAAM,CAAA;AAAA,MACrC,EAAA,KAAO;AACL,QAAA,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,MAAA,CAAO,MAAM,CAAA;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAnHE,EAAA,+CAAA;AAAA,IADC,oCAAA,EAAW,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAC;AAAA,EAAA,CAAA,EAJrC,KAAA,CAKJ,SAAA,EAAA,OAAA,EAAA,CAAA,CAAA;AAMU,EAAA,+CAAA;AAAA,IADT,iCAAA;AAAM,EAAA,CAAA,EAVH,KAAA,CAWM,SAAA,EAAA,QAAA,EAAA,CAAA,CAAA;AAgHZ,EAAA,OAAO,KAAA;AACT;ADjEA;AACA;AACE;AACF,8BAAC","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-CUDG6NPH.cjs","sourcesContent":[null,"/**\n * Theme Mixin\n *\n * Mixin to add theme detection and management to a Lit component\n */\n\nimport type { LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nexport type Theme = 'light' | 'dark' | 'auto'\n\n/**\n * Mixin to add theme management to a Lit component\n *\n * Provides a `theme` property and `isDark` state that automatically handles:\n * - Manual theme selection ('light' or 'dark')\n * - Auto theme detection based on system preferences\n * - Reactive updates when system theme changes\n * - Automatically wraps all rendered content in a themed div with 'dark' class when dark mode is active\n *\n * All content rendered by the component will be inside a theme-root div that receives the dark class.\n * Components can use render() normally - no changes needed.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with theme management capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withTheme } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withTheme(LitElement) {\n * render() {\n * return html`\n * <div class=\"text-neutral-20 dark:text-neutral-100\">\n * Current theme: ${this.theme}\n * </div>\n * `;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withTheme<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n /**\n * Theme mode: 'light', 'dark', or 'auto' (follows system preference)\n */\n @property({ type: String, reflect: true })\n theme: Theme = 'light'\n\n /**\n * Computed state indicating if dark mode is active\n */\n @state()\n protected isDark = false\n\n /**\n * The theme root element that wraps all rendered content and receives the dark class\n */\n private themeRoot!: HTMLDivElement\n\n private mediaQueryList: MediaQueryList | null = null\n\n connectedCallback(): void {\n super.connectedCallback()\n this.updateTheme()\n this.updateHostClass()\n\n // Listen for system theme changes when in 'auto' mode\n if (this.theme === 'auto') {\n this.mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)')\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n if (this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n }\n }\n\n updated(changedProperties: Map<string, any>): void {\n super.updated(changedProperties)\n\n // Handle theme changes\n if (changedProperties.has('theme')) {\n this.updateTheme()\n\n // Update media query listener when theme mode changes\n if (this.theme === 'auto' && !this.mediaQueryList) {\n this.mediaQueryList = window.matchMedia(\n '(prefers-color-scheme: dark)'\n )\n this.mediaQueryList.addEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n } else if (this.theme !== 'auto' && this.mediaQueryList) {\n this.mediaQueryList.removeEventListener(\n 'change',\n this.handleMediaQueryChange\n )\n this.mediaQueryList = null\n }\n }\n\n // Update host class when isDark changes\n if (changedProperties.has('isDark')) {\n this.updateHostClass()\n }\n }\n\n /**\n * Handle system theme changes\n *\n * @param event - Media query list event\n */\n private handleMediaQueryChange = (event: MediaQueryListEvent): void => {\n this.isDark = event.matches\n }\n\n /**\n * Update isDark state based on theme property\n */\n protected updateTheme(): void {\n if (this.theme === 'auto') {\n this.isDark = window.matchMedia('(prefers-color-scheme: dark)').matches\n } else {\n this.isDark = this.theme === 'dark'\n }\n }\n\n /**\n * Create the render root with a themed wrapper div\n */\n createRenderRoot(): Element | ShadowRoot {\n const root = super.createRenderRoot()\n\n this.themeRoot = document.createElement('div')\n this.themeRoot.setAttribute('data-theme-root', '')\n\n root.appendChild(this.themeRoot)\n return this.themeRoot\n }\n\n /**\n * Update the host element's class based on isDark state\n */\n private updateHostClass(): void {\n if (this.isDark) {\n this.themeRoot.classList.add('dark')\n } else {\n this.themeRoot.classList.remove('dark')\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-FR74YPGJ.cjs","../src/mixins/intl.ts","../../translations/en_US.json"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACDA,mDAAuB;ADGvB;AACA;AEVA,IAAA,cAAA,EAAA;AAAA,EACE,uBAAA,EAA2B,WAAA;AAAA,EAC3B,mBAAA,EAAuB,uBAAA;AAAA,EACvB,2BAAA,EAA+B,gBAAA;AAAA,EAC/B,iCAAA,EAAqC,wEAAA;AAAA,EACrC,8BAAA,EAAkC,gBAAA;AAAA,EAClC,qBAAA,EAAyB,gCAAA;AAAA,EACzB,gBAAA,EAAoB,IAAA;AAAA,EACpB,uBAAA,EAA2B,WAAA;AAAA,EAC3B,4BAAA,EAAgC,mBAAA;AAAA,EAChC,uBAAA,EAA2B,qBAAA;AAAA,EAC3B,yBAAA,EAA6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AAAA,UAC3B,QAAA,EAAU;AAAA,QACZ,CAAC;AAAA,MACH,CAAA;AACA,MAAA,8CAAA,WAA0B,CAAA;AAC1B,MAAA,OAAO,WAAA;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,aAAA,CAAc,GAAA,EAAc,OAAA,EAA0C;AACpE,MAAA,GAAA,CAAI,CAAC,GAAA,EAAK;AACR,QAAA,OAAA,CAAQ,IAAA,CAAK,8CAA8C,CAAA;AAC3D,QAAA,OAAO,EAAA;AAAA,MACT;AAEA,MAAA,MAAM,KAAA,EAAO,8CAAA,CAAe;AAC5B,MAAA,wCAAO,IAAA,6BAAM,aAAA,mBAAc,GAAA,EAAK,OAAO,GAAA,UAAK,KAAA;AAAA,IAC9C;AAAA,EACF;AAGA,EAAA,OAAO,KAAA;AACT;AD7BA;AACA;AACE;AACF,0CAAC","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-FR74YPGJ.cjs","sourcesContent":[null,"/**\n * Internationalization Mixin\n *\n * Mixin to add internationalization service to a Lit component\n */\n\nimport { effect } from '@preact/signals-core'\nimport type { LitElement } from 'lit'\nimport englishTranslations from '../../../translations/en_US.json'\nimport {\n createIntlService,\n defaultConfig,\n getIntlService,\n type IntlService,\n setIntlService,\n} from '../services/intl.js'\n\n/**\n * Mixin to add internationalization service to a Lit component\n *\n * Provides access to the global intl service with reactive locale changes.\n * Automatically subscribes to locale changes and triggers re-renders.\n *\n * The component will use the global intl service if available, or create a local one.\n * This follows the singleton pattern for the global service while allowing flexibility.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with intl service capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withIntlService } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withIntlService(LitElement) {\n * render() {\n * return html\\`<p>\\${this.formatMessage('app.welcome')}</p>\\`;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withIntlService<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n protected unsubscribeIntl: (() => void) | undefined = undefined\n\n connectedCallback(): void {\n super.connectedCallback()\n\n // Subscribe to intl changes via signal\n let intl: IntlService | null = getIntlService()\n\n // When no intl is provided by host app we initialize our own\n if (!intl) {\n intl = this.setupLocalIntl() ?? null\n }\n\n if (intl) {\n this.unsubscribeIntl = effect(() => {\n // Access the signal to track changes\n intl?.localeChanged.value\n this.requestUpdate()\n })\n }\n\n // Set fallback for missing translations\n intl?.setFallbackTranslations(englishTranslations as any)\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n // Unsubscribe from intl changes\n if (typeof this.unsubscribeIntl === 'function') {\n this.unsubscribeIntl()\n }\n }\n\n /**\n * Setup a local intl service with default configuration\n * Subclasses can override this to customize initialization\n */\n protected setupLocalIntl(): IntlService | undefined {\n const intlService = createIntlService(\n Object.assign(defaultConfig, {\n messages: englishTranslations,\n })\n )\n setIntlService(intlService)\n return intlService\n }\n\n /**\n * Format message using the intl service\n */\n formatMessage(key?: string, options?: Record<string, string>): string {\n if (!key) {\n console.warn('No translation key provided to formatMessage')\n return ''\n }\n\n const intl = getIntlService()\n return intl?.formatMessage(key, options) ?? key\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n","{\n \"connect_modal_try_again\": \"Try again\",\n \"connect_modal_title\": \"Let’s log you in\",\n \"connect_modal_qr_code_title\": \"Scan to log in\",\n \"connect_modal_qr_code_description\": \"Scan the below QR code with the Universal Profile mobile app to log in\",\n \"connect_modal_other_connectors\": \"Connect Wallet\",\n \"connect_modal_or_info\": \"Log in with a different wallet\",\n \"connect_modal_or\": \"Or\",\n \"connect_modal_installed\": \"INSTALLED\",\n \"connect_modal_failed_to_load\": \"Failed to load...\",\n \"connect_modal_eoa_title\": \"Connect your Wallet\",\n \"connect_modal_description\": \"Log in with your Universal Profile\",\n \"connect_modal_connectors_up_mobile\": \"Mobile Application\",\n \"connect_modal_connectors_up_browser_extension\": \"Browser Extension\",\n \"connect_modal_connectors_passkey_wallet\": \"Passkey Wallet\"\n}"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-RM42NG7E.cjs","../src/services/intl.ts"],"names":[],"mappings":"AAAA;ACMA;AACE;AAAA,sCAGK;AACP,mDAAuB;AAYvB,IAAM,2BAAA,EAA6B;AAAA,EACjC,qBAAA,EAAuB;AACzB,CAAA;AA6GO,IAAM,cAAA,EAA4B;AAAA,EACvC,MAAA,EAAQ,OAAA;AAAA,EACR,QAAA,EAAU,CAAC,CAAA;AAAA,EACX,OAAA,EAAS,CAAC;AACZ,CAAA;AAKA,IAAI,YAAA,EAAkC,IAAA;AA0B/B,SAAS,iBAAA,CACd,OAAA,EAAqB,aAAA,EACR;AACb,EAAA,IAAI,cAAA,EAAgB,EAAE,GAAG,aAAA,EAAe,GAAG,OAAO,CAAA;AAClD,EAAA,IAAI,KAAA,EAAO,8BAAA,EAAa,GAAG,aAAA,EAAe,aAAA,EAAe,QAAQ,CAAC,CAAA;AAClE,EAAA,MAAM,cAAA,EAAgB,iCAAA,CAAQ,CAAA;AAC9B,EAAA,IAAI,iBAAA,EAAiC,CAAC,CAAA;AAEtC,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,CAAC,GAAA,EAAa,OAAA,EAAA,GAA6C;AACxE,MAAA,IAAI;AACF,QAAA,MAAM,OAAA,EAAS,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,IAAI,CAAA,EAAG,OAAO,CAAA;AAEtD,QAAA,GAAA,CAAI,OAAA,GAAU,OAAA,IAAW,GAAA,EAAK;AAC5B,UAAA,OAAO,MAAA;AAAA,QACT;AAGA,QAAA,GAAA,CAAI,gBAAA,CAAiB,GAAG,CAAA,EAAG;AACzB,UAA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OAAO,WAAA;AACT;AAMO,SAAS,gBAAA,CAAA,EAAyB;AACvC,EAAA,YAAA,EAAc,IAAA;AAChB;ADpOA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,oNAAC","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-RM42NG7E.cjs","sourcesContent":[null,"/**\n * Internationalization Service\n *\n * Provides locale-aware formatting for messages, numbers, dates, and times.\n */\n\nimport {\n createIntl,\n type FormatNumberOptions,\n type IntlConfig,\n} from '@formatjs/intl'\nimport { signal } from '@preact/signals-core'\n\n/**\n * Translation messages object type\n * Maps translation keys to their corresponding string values\n */\nexport type IntlMessages = Record<string, string>\n\n/**\n * Default format number options\n * @see https://github.com/formatjs/formatjs/blob/main/packages/ecma402-abstract/types/number.ts\n */\nconst formatNumberDefaultOptions = {\n maximumFractionDigits: 18,\n}\n\n/**\n * Intl service interface\n */\nexport interface IntlService {\n /**\n * Translate a string based on the key\n *\n * @param key - translation key\n * @param options - optional options for formatMessage (for variable interpolation)\n * @returns - translated string\n */\n formatMessage: (key: string, options?: Record<string, string>) => string\n\n /**\n * Number formatting based on the locale\n *\n * @param value - number to format\n * @param options - options for formatNumber\n * @returns - formatted number\n */\n formatNumber: (\n value: number | string | bigint,\n options?: FormatNumberOptions\n ) => string\n\n /**\n * Date formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted date\n */\n formatDate: (date?: string | number | Date) => string | undefined\n\n /**\n * Time formatting based on the locale\n *\n * @param date - date to format\n * @returns - formatted time\n */\n formatTime: (date?: string | number | Date) => string | undefined\n\n /**\n * Timestamp formatting based on the locale\n *\n * @param timestamp - UNIX timestamp in seconds or milliseconds\n * @param options - formatting options (predefined format name or custom Intl.DateTimeFormat options)\n * @returns - formatted date & time string\n *\n * @example\n * ```typescript\n * const intl = getIntlService();\n *\n * // Use predefined shortDateTime format\n * intl.formatTimestamp(1733251200, 'shortDateTime'); // \"Wed, Dec 3, 2025, 16:07\"\n *\n * // Use custom format options\n * intl.formatTimestamp(1733251200, { year: '2-digit', month: '2-digit', day: '2-digit' });\n * // \"12/03/25\"\n *\n * // No options (basic format)\n * intl.formatTimestamp(1733251200);\n * ```\n */\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ) => string\n\n /**\n * Change the locale and optionally update messages\n *\n * @param locale - new locale code (e.g., 'en-US', 'de-DE')\n * @param messages - optional new messages object for the locale\n */\n setLocale: (locale: string, messages?: IntlMessages) => void\n\n /**\n * Get the current locale\n *\n * @returns - current locale code (e.g., 'en-US', 'de-DE')\n */\n getLocale: () => string\n\n /**\n * Set fallback translations to use when a translation key is missing\n * Useful when the host app's intl service doesn't have all translations\n *\n * @param fallbackMessages - translations to use as fallback\n *\n * @example\n * ```typescript\n * // After intl service is initialized by host app\n * intl.setFallbackTranslations(defaultMessages);\n * ```\n */\n setFallbackTranslations: (fallbackMessages: IntlMessages) => void\n\n /**\n * Signal that tracks locale changes\n * Use this signal to reactively update UI when locale changes\n */\n localeChanged: { value: number }\n}\n\n/**\n * Default configuration for intl\n */\nexport const defaultConfig: IntlConfig = {\n locale: 'en-US',\n messages: {},\n formats: {},\n}\n\n/**\n * Global intl service instance\n */\nlet intlService: IntlService | null = null\n\n/**\n * Create a new intl service instance\n *\n * @param config - intl configuration with locale and messages\n * @returns IntlService instance with formatting methods\n *\n * @example\n * ```typescript\n * import { createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService({\n * locale: 'en-US',\n * messages: customMessages,\n * });\n *\n * const translated = intl.formatMessage('app.title');\n * const formatted = intl.formatNumber(1234.56);\n * const currentLocale = intl.getLocale(); // 'en-US'\n *\n * // Change locale\n * intl.setLocale('de-DE', germanMessages);\n * console.log(intl.getLocale()); // 'de-DE'\n * ```\n */\nexport function createIntlService(\n config: IntlConfig = defaultConfig\n): IntlService {\n let currentConfig = { ...defaultConfig, ...config }\n let intl = createIntl({ ...currentConfig, defaultLocale: 'en-US' })\n const localeChanged = signal(0)\n let fallbackMessages: IntlMessages = {}\n\n return {\n formatMessage: (key: string, options?: Record<string, string>): string => {\n try {\n const result = intl.formatMessage({ id: key }, options)\n\n if (result && result !== key) {\n return result\n }\n\n // If no translation found, check fallback\n if (fallbackMessages[key]) {\n return fallbackMessages[key]\n }\n\n return key\n } catch {\n // On error, try fallback\n return fallbackMessages[key] || key\n }\n },\n\n formatNumber: (\n value: number | string | bigint,\n options: FormatNumberOptions = {}\n ): string => {\n if (value === null || value === undefined) {\n return '0'\n }\n\n const _value =\n typeof value === 'string' ? Number.parseFloat(value) : value\n\n const mergedOptions = {\n ...formatNumberDefaultOptions,\n ...options,\n }\n\n return intl.formatNumber(_value as number, mergedOptions) || ''\n },\n\n formatDate: (date?: string | number | Date): string => {\n return intl.formatDate(date)\n },\n\n formatTime: (date?: string | number | Date): string => {\n return intl.formatTime(date)\n },\n\n formatTimestamp: (\n timestamp?: number | string,\n options?: Intl.DateTimeFormatOptions | string\n ): string => {\n if (!timestamp) return ''\n\n const time = typeof timestamp === 'string' ? Number(timestamp) : timestamp\n const date =\n time < 10_000_000_000\n ? new Date(time * 1000) // seconds\n : new Date(time) // milliseconds\n\n // Handle predefined format\n if (typeof options === 'string') {\n const dateTimeOptions = currentConfig.formats?.date?.[\n options\n ] as Intl.DateTimeFormatOptions\n\n if (dateTimeOptions) {\n return new Intl.DateTimeFormat(\n currentConfig.locale,\n dateTimeOptions\n ).format(date)\n }\n\n // Fallback to default format if predefined format not found\n return intl.formatDate(date) || ''\n }\n\n // For normal @formatjs/intl options\n return intl.formatDate(date, options) || ''\n },\n\n setLocale: (locale: string, messages?: IntlMessages): void => {\n currentConfig = {\n ...currentConfig,\n locale,\n messages: messages || currentConfig.messages,\n }\n intl = createIntl({\n ...currentConfig,\n defaultLocale: 'en-US',\n })\n localeChanged.value += 1\n },\n\n getLocale: (): string => {\n return currentConfig.locale\n },\n\n setFallbackTranslations: (fallbackMessagesInput: IntlMessages): void => {\n fallbackMessages = fallbackMessagesInput\n },\n\n localeChanged,\n }\n}\n\n/**\n * Set the global intl service\n * Call this once from your app initialization\n *\n * @param service - IntlService instance\n *\n * @example\n * ```typescript\n * import { setIntlService, createIntlService } from '@lukso/core/services/intl';\n *\n * const intl = createIntlService(config);\n * setIntlService(intl);\n * ```\n */\nexport function setIntlService(service: IntlService): void {\n intlService = service\n}\n\n/**\n * Get the current global intl service\n * Returns null if no service has been set\n *\n * @example\n * ```typescript\n * import { getIntlService } from '@lukso/core/services/intl';\n *\n * const intl = getIntlService();\n * if (intl) {\n * console.log(intl.getLocale());\n * }\n * ```\n */\nexport function getIntlService(): IntlService | null {\n return intlService\n}\n\n/**\n * Clear the global intl service\n * Useful for testing or cleanup\n */\nexport function clearIntlService(): void {\n intlService = null\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mixins/intl.ts","../../translations/en_US.json"],"sourcesContent":["/**\n * Internationalization Mixin\n *\n * Mixin to add internationalization service to a Lit component\n */\n\nimport { effect } from '@preact/signals-core'\nimport type { LitElement } from 'lit'\nimport englishTranslations from '../../../translations/en_US.json'\nimport {\n createIntlService,\n defaultConfig,\n getIntlService,\n type IntlService,\n setIntlService,\n} from '../services/intl.js'\n\n/**\n * Mixin to add internationalization service to a Lit component\n *\n * Provides access to the global intl service with reactive locale changes.\n * Automatically subscribes to locale changes and triggers re-renders.\n *\n * The component will use the global intl service if available, or create a local one.\n * This follows the singleton pattern for the global service while allowing flexibility.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with intl service capabilities\n *\n * @example\n * ```typescript\n * import { LitElement, html } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withIntlService } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withIntlService(LitElement) {\n * render() {\n * return html\\`<p>\\${this.formatMessage('app.welcome')}</p>\\`;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withIntlService<T extends typeof LitElement>(Base: T): any {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n class Mixin extends (Base as any) {\n protected unsubscribeIntl: (() => void) | undefined = undefined\n\n connectedCallback(): void {\n super.connectedCallback()\n\n // Subscribe to intl changes via signal\n let intl: IntlService | null = getIntlService()\n\n // When no intl is provided by host app we initialize our own\n if (!intl) {\n intl = this.setupLocalIntl() ?? null\n }\n\n if (intl) {\n this.unsubscribeIntl = effect(() => {\n // Access the signal to track changes\n intl?.localeChanged.value\n this.requestUpdate()\n })\n }\n\n // Set fallback for missing translations\n intl?.setFallbackTranslations(englishTranslations as any)\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback()\n\n // Unsubscribe from intl changes\n if (typeof this.unsubscribeIntl === 'function') {\n this.unsubscribeIntl()\n }\n }\n\n /**\n * Setup a local intl service with default configuration\n * Subclasses can override this to customize initialization\n */\n protected setupLocalIntl(): IntlService | undefined {\n const intlService = createIntlService(\n Object.assign(defaultConfig, {\n messages: englishTranslations,\n })\n )\n setIntlService(intlService)\n return intlService\n }\n\n /**\n * Format message using the intl service\n */\n formatMessage(key?: string, options?: Record<string, string>): string {\n if (!key) {\n console.warn('No translation key provided to formatMessage')\n return ''\n }\n\n const intl = getIntlService()\n return intl?.formatMessage(key, options) ?? key\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n","{\n \"connect_modal_try_again\": \"Try again\",\n \"connect_modal_title\": \"Let’s log you in\",\n \"connect_modal_qr_code_title\": \"Scan to log in\",\n \"connect_modal_qr_code_description\": \"Scan the below QR code with the Universal Profile mobile app to log in\",\n \"connect_modal_other_connectors\": \"Connect Wallet\",\n \"connect_modal_or_info\": \"Log in with a different wallet\",\n \"connect_modal_or\": \"Or\",\n \"connect_modal_installed\": \"INSTALLED\",\n \"connect_modal_failed_to_load\": \"Failed to load...\",\n \"connect_modal_eoa_title\": \"Connect your Wallet\",\n \"connect_modal_description\": \"Log in with your Universal Profile\",\n \"connect_modal_connectors_up_mobile\": \"Mobile Application\",\n \"connect_modal_connectors_up_browser_extension\": \"Browser Extension\",\n \"connect_modal_connectors_passkey_wallet\": \"Passkey Wallet\"\n}"],"mappings":";;;;;;;;AAMA,SAAS,cAAc;;;ACNvB;AAAA,EACE,yBAA2B;AAAA,EAC3B,qBAAuB;AAAA,EACvB,6BAA+B;AAAA,EAC/B,mCAAqC;AAAA,EACrC,gCAAkC;AAAA,EAClC,uBAAyB;AAAA,EACzB,kBAAoB;AAAA,EACpB,yBAA2B;AAAA,EAC3B,8BAAgC;AAAA,EAChC,yBAA2B;AAAA,EAC3B,2BAA6B;AAAA,EAC7B,oCAAsC;AAAA,EACtC,+CAAiD;AAAA,EACjD,yCAA2C;AAC7C;;;AD6BO,SAAS,gBAA6C,MAAc;AAAA,EAEzE,MAAM,cAAe,KAAa;AAAA,IAAlC;AAAA;AACE,WAAU,kBAA4C;AAAA;AAAA,IAEtD,oBAA0B;AACxB,YAAM,kBAAkB;AAGxB,UAAI,OAA2B,eAAe;AAG9C,UAAI,CAAC,MAAM;AACT,eAAO,KAAK,eAAe,KAAK;AAAA,MAClC;AAEA,UAAI,MAAM;AACR,aAAK,kBAAkB,OAAO,MAAM;AAElC,gBAAM,cAAc;AACpB,eAAK,cAAc;AAAA,QACrB,CAAC;AAAA,MACH;AAGA,YAAM,wBAAwB,aAA0B;AAAA,IAC1D;AAAA,IAEA,uBAA6B;AAC3B,YAAM,qBAAqB;AAG3B,UAAI,OAAO,KAAK,oBAAoB,YAAY;AAC9C,aAAK,gBAAgB;AAAA,MACvB;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA,IAMU,iBAA0C;AAClD,YAAM,cAAc;AAAA,QAClB,OAAO,OAAO,eAAe;AAAA,UAC3B,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AACA,qBAAe,WAAW;AAC1B,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA,IAKA,cAAc,KAAc,SAA0C;AACpE,UAAI,CAAC,KAAK;AACR,gBAAQ,KAAK,8C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