@lukso/core 0.1.0-dev.0f1bea5
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/LICENSE +201 -0
- package/README.md +159 -0
- package/dist/chunk-3WGYJTN4.js +19 -0
- package/dist/chunk-3WGYJTN4.js.map +1 -0
- package/dist/chunk-4TNWG4ME.js +106 -0
- package/dist/chunk-4TNWG4ME.js.map +1 -0
- package/dist/chunk-AMRGSLR5.cjs +1 -0
- package/dist/chunk-AMRGSLR5.cjs.map +1 -0
- package/dist/chunk-CC3LFUYY.cjs +19 -0
- package/dist/chunk-CC3LFUYY.cjs.map +1 -0
- package/dist/chunk-DFMMMF62.cjs +1 -0
- package/dist/chunk-DFMMMF62.cjs.map +1 -0
- package/dist/chunk-DKEXQFNE.js +1 -0
- package/dist/chunk-DKEXQFNE.js.map +1 -0
- package/dist/chunk-DKXHVRHM.js +84 -0
- package/dist/chunk-DKXHVRHM.js.map +1 -0
- package/dist/chunk-FR74YPGJ.cjs +87 -0
- package/dist/chunk-FR74YPGJ.cjs.map +1 -0
- package/dist/chunk-LEL6VWU4.js +1 -0
- package/dist/chunk-LEL6VWU4.js.map +1 -0
- package/dist/chunk-MBIRTPNM.cjs +84 -0
- package/dist/chunk-MBIRTPNM.cjs.map +1 -0
- package/dist/chunk-NJQVWIZL.cjs +49 -0
- package/dist/chunk-NJQVWIZL.cjs.map +1 -0
- package/dist/chunk-RM42NG7E.cjs +106 -0
- package/dist/chunk-RM42NG7E.cjs.map +1 -0
- package/dist/chunk-SV4TVR2K.js +87 -0
- package/dist/chunk-SV4TVR2K.js.map +1 -0
- package/dist/chunk-X2QNFZU7.js +49 -0
- package/dist/chunk-X2QNFZU7.js.map +1 -0
- package/dist/index.cjs +37 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/mixins/device.cjs +8 -0
- package/dist/mixins/device.cjs.map +1 -0
- package/dist/mixins/device.d.cts +34 -0
- package/dist/mixins/device.d.ts +34 -0
- package/dist/mixins/device.js +8 -0
- package/dist/mixins/device.js.map +1 -0
- package/dist/mixins/index.cjs +14 -0
- package/dist/mixins/index.cjs.map +1 -0
- package/dist/mixins/index.d.cts +3 -0
- package/dist/mixins/index.d.ts +3 -0
- package/dist/mixins/index.js +14 -0
- package/dist/mixins/index.js.map +1 -0
- package/dist/mixins/intl.cjs +8 -0
- package/dist/mixins/intl.cjs.map +1 -0
- package/dist/mixins/intl.d.cts +37 -0
- package/dist/mixins/intl.d.ts +37 -0
- package/dist/mixins/intl.js +8 -0
- package/dist/mixins/intl.js.map +1 -0
- package/dist/services/device.cjs +7 -0
- package/dist/services/device.cjs.map +1 -0
- package/dist/services/device.d.cts +71 -0
- package/dist/services/device.d.ts +71 -0
- package/dist/services/device.js +7 -0
- package/dist/services/device.js.map +1 -0
- package/dist/services/index.cjs +20 -0
- package/dist/services/index.cjs.map +1 -0
- package/dist/services/index.d.cts +4 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +20 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/intl.cjs +15 -0
- package/dist/services/intl.cjs.map +1 -0
- package/dist/services/intl.d.cts +170 -0
- package/dist/services/intl.d.ts +170 -0
- package/dist/services/intl.js +15 -0
- package/dist/services/intl.js.map +1 -0
- package/dist/utils/index.cjs +11 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +32 -0
- package/dist/utils/index.d.ts +32 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +114 -0
- package/src/index.ts +10 -0
- package/src/mixins/__tests__/device.spec.ts +119 -0
- package/src/mixins/__tests__/intl.spec.ts +198 -0
- package/src/mixins/device.ts +48 -0
- package/src/mixins/index.ts +8 -0
- package/src/mixins/intl.ts +112 -0
- package/src/services/__tests__/device.spec.ts +36 -0
- package/src/services/__tests__/intl.spec.ts +536 -0
- package/src/services/device.ts +121 -0
- package/src/services/index.ts +17 -0
- package/src/services/intl.ts +326 -0
- package/src/utils/__tests__/browserInfo.spec.ts +310 -0
- package/src/utils/__tests__/slug.spec.ts +26 -0
- package/src/utils/browserInfo.ts +102 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/slug.ts +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# @lukso/core
|
|
2
|
+
|
|
3
|
+
Core utilities, services, and mixins for LUKSO web components and applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Device Detection Service** - Detect device type, OS, and browser capabilities
|
|
8
|
+
- **Internationalization (Intl) Service** - Multi-language support with locale-aware formatting
|
|
9
|
+
- **Browser Detection Utility** - Get browser-specific metadata (name, icon, store links)
|
|
10
|
+
- **Utility Functions** - Common text transformation utilities
|
|
11
|
+
- **Reusable Mixins** - Composable mixins for Lit web components
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @lukso/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Services
|
|
20
|
+
|
|
21
|
+
### Device Service
|
|
22
|
+
|
|
23
|
+
Detect device type, OS, and browser:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { deviceService } from '@lukso/core/services/device'
|
|
27
|
+
|
|
28
|
+
const device = deviceService()
|
|
29
|
+
if (device.isMobile) {
|
|
30
|
+
console.log('Mobile device detected')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log({
|
|
34
|
+
os: device.isMacOS ? 'macOS' : device.isWindows ? 'Windows' : 'Unknown',
|
|
35
|
+
browser: device.isSafari ? 'Safari' : device.isChrome ? 'Chrome' : 'Unknown',
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Intl Service
|
|
40
|
+
|
|
41
|
+
Format messages, numbers, and dates:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { createIntlService, setIntlService } from '@lukso/core/services/intl'
|
|
45
|
+
|
|
46
|
+
const intl = createIntlService({
|
|
47
|
+
locale: 'en-US',
|
|
48
|
+
messages: {
|
|
49
|
+
'app.welcome': 'Welcome',
|
|
50
|
+
'app.hello': 'Hello, {name}!',
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
setIntlService(intl)
|
|
54
|
+
|
|
55
|
+
console.log(intl.formatMessage('app.welcome')) // 'Welcome'
|
|
56
|
+
console.log(intl.formatMessage('app.hello', { name: 'John' })) // 'Hello, John!'
|
|
57
|
+
console.log(intl.formatNumber(1234.56)) // '1,234.56'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Utilities
|
|
61
|
+
|
|
62
|
+
### browserInfo
|
|
63
|
+
|
|
64
|
+
Detect browser type and get browser-specific metadata (name, icon, store link):
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { browserInfo, type BrowserInfo } from '@lukso/core/utils'
|
|
68
|
+
import { deviceService } from '@lukso/core/services'
|
|
69
|
+
|
|
70
|
+
const device = deviceService()
|
|
71
|
+
const browser: BrowserInfo = browserInfo(device)
|
|
72
|
+
|
|
73
|
+
console.log(browser.id) // 'chrome', 'firefox', 'safari', 'edge', 'brave', 'opera'
|
|
74
|
+
console.log(browser.name) // 'Chrome', 'Firefox', 'Safari', etc.
|
|
75
|
+
console.log(browser.icon) // 'logo-chrome', 'logo-firefox', etc.
|
|
76
|
+
console.log(browser.storeLink) // URL to browser's extension store for Universal Profile
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The `browserInfo` function is useful for:
|
|
80
|
+
- Showing browser-specific Universal Profile extension installation links
|
|
81
|
+
- Displaying browser icons in UI
|
|
82
|
+
- Determining browser-specific features or limitations
|
|
83
|
+
- Customizing UX based on browser capabilities
|
|
84
|
+
|
|
85
|
+
### slug
|
|
86
|
+
|
|
87
|
+
Convert text to slug format (lowercase with hyphens):
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
import { slug } from '@lukso/core/utils'
|
|
91
|
+
|
|
92
|
+
console.log(slug('Hello World')) // 'hello-world'
|
|
93
|
+
console.log(slug('TEST')) // 'test'
|
|
94
|
+
console.log(slug('some-text')) // 'some-text'
|
|
95
|
+
console.log(slug('')) // ''
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The `slug` function is useful for:
|
|
99
|
+
- Creating URL-friendly identifiers
|
|
100
|
+
- Generating CSS class names
|
|
101
|
+
- Normalizing user input
|
|
102
|
+
|
|
103
|
+
## Mixins
|
|
104
|
+
|
|
105
|
+
### withDeviceService
|
|
106
|
+
|
|
107
|
+
Add device detection to your component:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import { LitElement, html } from 'lit'
|
|
111
|
+
import { customElement } from 'lit/decorators.js'
|
|
112
|
+
import { withDeviceService } from '@lukso/core/mixins'
|
|
113
|
+
|
|
114
|
+
@customElement('my-component')
|
|
115
|
+
export class MyComponent extends withDeviceService(LitElement) {
|
|
116
|
+
render() {
|
|
117
|
+
return html`
|
|
118
|
+
<div>
|
|
119
|
+
Is mobile: ${this.device?.isMobile}
|
|
120
|
+
Is Safari: ${this.device?.isSafari}
|
|
121
|
+
</div>
|
|
122
|
+
`
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### withIntlService
|
|
128
|
+
|
|
129
|
+
Add internationalization to your component:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { LitElement, html } from 'lit'
|
|
133
|
+
import { customElement } from 'lit/decorators.js'
|
|
134
|
+
import { withIntlService } from '@lukso/core/mixins'
|
|
135
|
+
|
|
136
|
+
@customElement('my-component')
|
|
137
|
+
export class MyComponent extends withIntlService(LitElement) {
|
|
138
|
+
render() {
|
|
139
|
+
return html`
|
|
140
|
+
<h1>${this.formatMessage('app.title')}</h1>
|
|
141
|
+
<p>${this.formatMessage('app.welcome')}</p>
|
|
142
|
+
`
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Combining Mixins
|
|
148
|
+
|
|
149
|
+
Use multiple mixins together:
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
class MyComponent extends withIntlService(withDeviceService(LitElement)) {
|
|
153
|
+
// Has both services
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deviceService
|
|
3
|
+
} from "./chunk-X2QNFZU7.js";
|
|
4
|
+
|
|
5
|
+
// src/mixins/device.ts
|
|
6
|
+
function withDeviceService(Base) {
|
|
7
|
+
class Mixin extends Base {
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
super.connectedCallback();
|
|
10
|
+
this.device = deviceService(navigator);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return Mixin;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
withDeviceService
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-3WGYJTN4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/mixins/device.ts"],"sourcesContent":["/**\n * Device Detection Mixin\n *\n * Mixin to add device detection service to a Lit component\n */\n\nimport type { LitElement } from 'lit'\nimport type { DeviceService } from '../services/device.js'\nimport { deviceService, type NavigatorExtended } from '../services/device.js'\n\n/**\n * Mixin to add device detection service to a Lit component\n *\n * Provides a `device` property with device/OS/browser detection capabilities.\n * The device service is initialized in connectedCallback and follows component lifecycle.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with device detection capabilities\n *\n * @example\n * ```typescript\n * import { LitElement } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withDeviceService } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withDeviceService(LitElement) {\n * render() {\n * return html\\`Device is mobile: \\${this.device?.isMobile}\\`;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withDeviceService<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 device: DeviceService | undefined\n\n connectedCallback(): void {\n super.connectedCallback()\n this.device = deviceService(navigator as NavigatorExtended)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"],"mappings":";;;;;AAkCO,SAAS,kBAA+C,MAAc;AAAA,EAE3E,MAAM,cAAe,KAAa;AAAA,IAGhC,oBAA0B;AACxB,YAAM,kBAAkB;AACxB,WAAK,SAAS,cAAc,SAA8B;AAAA,IAC5D;AAAA,EACF;AAGA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// src/services/intl.ts
|
|
2
|
+
import {
|
|
3
|
+
createIntl
|
|
4
|
+
} from "@formatjs/intl";
|
|
5
|
+
import { signal } from "@preact/signals-core";
|
|
6
|
+
var formatNumberDefaultOptions = {
|
|
7
|
+
maximumFractionDigits: 18
|
|
8
|
+
};
|
|
9
|
+
var defaultConfig = {
|
|
10
|
+
locale: "en-US",
|
|
11
|
+
messages: {},
|
|
12
|
+
formats: {}
|
|
13
|
+
};
|
|
14
|
+
var intlService = null;
|
|
15
|
+
function createIntlService(config = defaultConfig) {
|
|
16
|
+
let currentConfig = { ...defaultConfig, ...config };
|
|
17
|
+
let intl = createIntl({ ...currentConfig, defaultLocale: "en-US" });
|
|
18
|
+
const localeChanged = signal(0);
|
|
19
|
+
let fallbackMessages = {};
|
|
20
|
+
return {
|
|
21
|
+
formatMessage: (key, options) => {
|
|
22
|
+
try {
|
|
23
|
+
const result = intl.formatMessage({ id: key }, options);
|
|
24
|
+
if (result && result !== key) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
if (fallbackMessages[key]) {
|
|
28
|
+
return fallbackMessages[key];
|
|
29
|
+
}
|
|
30
|
+
return key;
|
|
31
|
+
} catch {
|
|
32
|
+
return fallbackMessages[key] || key;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
formatNumber: (value, options = {}) => {
|
|
36
|
+
if (value === null || value === void 0) {
|
|
37
|
+
return "0";
|
|
38
|
+
}
|
|
39
|
+
const _value = typeof value === "string" ? Number.parseFloat(value) : value;
|
|
40
|
+
const mergedOptions = {
|
|
41
|
+
...formatNumberDefaultOptions,
|
|
42
|
+
...options
|
|
43
|
+
};
|
|
44
|
+
return intl.formatNumber(_value, mergedOptions) || "";
|
|
45
|
+
},
|
|
46
|
+
formatDate: (date) => {
|
|
47
|
+
return intl.formatDate(date);
|
|
48
|
+
},
|
|
49
|
+
formatTime: (date) => {
|
|
50
|
+
return intl.formatTime(date);
|
|
51
|
+
},
|
|
52
|
+
formatTimestamp: (timestamp, options) => {
|
|
53
|
+
if (!timestamp) return "";
|
|
54
|
+
const time = typeof timestamp === "string" ? Number(timestamp) : timestamp;
|
|
55
|
+
const date = time < 1e10 ? new Date(time * 1e3) : new Date(time);
|
|
56
|
+
if (typeof options === "string") {
|
|
57
|
+
const dateTimeOptions = currentConfig.formats?.date?.[options];
|
|
58
|
+
if (dateTimeOptions) {
|
|
59
|
+
return new Intl.DateTimeFormat(
|
|
60
|
+
currentConfig.locale,
|
|
61
|
+
dateTimeOptions
|
|
62
|
+
).format(date);
|
|
63
|
+
}
|
|
64
|
+
return intl.formatDate(date) || "";
|
|
65
|
+
}
|
|
66
|
+
return intl.formatDate(date, options) || "";
|
|
67
|
+
},
|
|
68
|
+
setLocale: (locale, messages) => {
|
|
69
|
+
currentConfig = {
|
|
70
|
+
...currentConfig,
|
|
71
|
+
locale,
|
|
72
|
+
messages: messages || currentConfig.messages
|
|
73
|
+
};
|
|
74
|
+
intl = createIntl({
|
|
75
|
+
...currentConfig,
|
|
76
|
+
defaultLocale: "en-US"
|
|
77
|
+
});
|
|
78
|
+
localeChanged.value += 1;
|
|
79
|
+
},
|
|
80
|
+
getLocale: () => {
|
|
81
|
+
return currentConfig.locale;
|
|
82
|
+
},
|
|
83
|
+
setFallbackTranslations: (fallbackMessagesInput) => {
|
|
84
|
+
fallbackMessages = fallbackMessagesInput;
|
|
85
|
+
},
|
|
86
|
+
localeChanged
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function setIntlService(service) {
|
|
90
|
+
intlService = service;
|
|
91
|
+
}
|
|
92
|
+
function getIntlService() {
|
|
93
|
+
return intlService;
|
|
94
|
+
}
|
|
95
|
+
function clearIntlService() {
|
|
96
|
+
intlService = null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
defaultConfig,
|
|
101
|
+
createIntlService,
|
|
102
|
+
setIntlService,
|
|
103
|
+
getIntlService,
|
|
104
|
+
clearIntlService
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=chunk-4TNWG4ME.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}\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,6BAA6B;AAAA,EACjC,uBAAuB;AACzB;AA6GO,IAAM,gBAA4B;AAAA,EACvC,QAAQ;AAAA,EACR,UAAU,CAAC;AAAA,EACX,SAAS,CAAC;AACZ;AAKA,IAAI,cAAkC;AA0B/B,SAAS,kBACd,SAAqB,eACR;AACb,MAAI,gBAAgB,EAAE,GAAG,eAAe,GAAG,OAAO;AAClD,MAAI,OAAO,WAAW,EAAE,GAAG,eAAe,eAAe,QAAQ,CAAC;AAClE,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,GAAG;AACzB,iBAAO,iBAAiB,GAAG;AAAA,QAC7B;AAEA,eAAO;AAAA,MACT,QAAQ;AAEN,eAAO,iBAAiB,GAAG,KAAK;AAAA,MAClC;AAAA,IACF;AAAA,IAEA,cAAc,CACZ,OACA,UAA+B,CAAC,MACrB;AACX,UAAI,UAAU,QAAQ,UAAU,QAAW;AACzC,eAAO;AAAA,MACT;AAEA,YAAM,SACJ,OAAO,UAAU,WAAW,OAAO,WAAW,KAAK,IAAI;AAEzD,YAAM,gBAAgB;AAAA,QACpB,GAAG;AAAA,QACH,GAAG;AAAA,MACL;AAEA,aAAO,KAAK,aAAa,QAAkB,aAAa,KAAK;AAAA,IAC/D;AAAA,IAEA,YAAY,CAAC,SAA0C;AACrD,aAAO,KAAK,WAAW,IAAI;AAAA,IAC7B;AAAA,IAEA,YAAY,CAAC,SAA0C;AACrD,aAAO,KAAK,WAAW,IAAI;AAAA,IAC7B;AAAA,IAEA,iBAAiB,CACf,WACA,YACW;AACX,UAAI,CAAC,UAAW,QAAO;AAEvB,YAAM,OAAO,OAAO,cAAc,WAAW,OAAO,SAAS,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-AMRGSLR5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-AMRGSLR5.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-AMRGSLR5.cjs"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkNJQVWIZLcjs = require('./chunk-NJQVWIZL.cjs');
|
|
4
|
+
|
|
5
|
+
// src/mixins/device.ts
|
|
6
|
+
function withDeviceService(Base) {
|
|
7
|
+
class Mixin extends Base {
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
super.connectedCallback();
|
|
10
|
+
this.device = _chunkNJQVWIZLcjs.deviceService.call(void 0, navigator);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return Mixin;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.withDeviceService = withDeviceService;
|
|
19
|
+
//# sourceMappingURL=chunk-CC3LFUYY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-CC3LFUYY.cjs","../src/mixins/device.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;AC8BO,SAAS,iBAAA,CAA+C,IAAA,EAAc;AAAA,EAE3E,MAAM,MAAA,QAAe,KAAa;AAAA,IAGhC,iBAAA,CAAA,EAA0B;AACxB,MAAA,KAAA,CAAM,iBAAA,CAAkB,CAAA;AACxB,MAAA,IAAA,CAAK,OAAA,EAAS,6CAAA,SAA4C,CAAA;AAAA,IAC5D;AAAA,EACF;AAGA,EAAA,OAAO,KAAA;AACT;ADjCA;AACA;AACE;AACF,8CAAC","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-CC3LFUYY.cjs","sourcesContent":[null,"/**\n * Device Detection Mixin\n *\n * Mixin to add device detection service to a Lit component\n */\n\nimport type { LitElement } from 'lit'\nimport type { DeviceService } from '../services/device.js'\nimport { deviceService, type NavigatorExtended } from '../services/device.js'\n\n/**\n * Mixin to add device detection service to a Lit component\n *\n * Provides a `device` property with device/OS/browser detection capabilities.\n * The device service is initialized in connectedCallback and follows component lifecycle.\n *\n * @typeParam T - The Lit component class being extended\n * @returns Extended class with device detection capabilities\n *\n * @example\n * ```typescript\n * import { LitElement } from 'lit';\n * import { customElement } from 'lit/decorators.js';\n * import { withDeviceService } from '@lukso/core/mixins';\n *\n * @customElement('my-component')\n * export class MyComponent extends withDeviceService(LitElement) {\n * render() {\n * return html\\`Device is mobile: \\${this.device?.isMobile}\\`;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function withDeviceService<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 device: DeviceService | undefined\n\n connectedCallback(): void {\n super.connectedCallback()\n this.device = deviceService(navigator as NavigatorExtended)\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Mixin as any\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";//# sourceMappingURL=chunk-DFMMMF62.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-DFMMMF62.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/service-auth-simple/service-auth-simple/packages/core/dist/chunk-DFMMMF62.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-DKEXQFNE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/utils/browserInfo.ts
|
|
2
|
+
var EXTENSION_STORE_LINKS = {
|
|
3
|
+
chrome: "https://chrome.google.com/webstore/detail/universal-profiles-testin/abpickdkkbnbcoepogfhkhennhfhehfn",
|
|
4
|
+
brave: "https://chrome.google.com/webstore/detail/universal-profiles-testin/abpickdkkbnbcoepogfhkhennhfhehfn",
|
|
5
|
+
edge: "https://chrome.google.com/webstore/detail/universal-profiles-testin/abpickdkkbnbcoepogfhkhennhfhehfn",
|
|
6
|
+
opera: "",
|
|
7
|
+
safari: "",
|
|
8
|
+
firefox: ""
|
|
9
|
+
};
|
|
10
|
+
var browserInfo = (deviceService) => {
|
|
11
|
+
const browserInfoDefaults = {
|
|
12
|
+
id: "chrome",
|
|
13
|
+
name: "",
|
|
14
|
+
icon: ""
|
|
15
|
+
};
|
|
16
|
+
const detectBrowser = () => {
|
|
17
|
+
const { isChrome, isBrave, isFirefox, isSafari, isEdge, isOpera } = deviceService;
|
|
18
|
+
if (isBrave) {
|
|
19
|
+
return {
|
|
20
|
+
id: "brave",
|
|
21
|
+
name: "Brave",
|
|
22
|
+
icon: "logo-brave",
|
|
23
|
+
storeLink: EXTENSION_STORE_LINKS.brave
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (isEdge) {
|
|
27
|
+
return {
|
|
28
|
+
id: "edge",
|
|
29
|
+
name: "Edge",
|
|
30
|
+
icon: "logo-edge",
|
|
31
|
+
storeLink: EXTENSION_STORE_LINKS.edge
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (isOpera) {
|
|
35
|
+
return {
|
|
36
|
+
id: "opera",
|
|
37
|
+
name: "Opera",
|
|
38
|
+
icon: "logo-opera",
|
|
39
|
+
storeLink: EXTENSION_STORE_LINKS.opera
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (isChrome) {
|
|
43
|
+
return {
|
|
44
|
+
id: "chrome",
|
|
45
|
+
name: "Chrome",
|
|
46
|
+
icon: "logo-chrome",
|
|
47
|
+
storeLink: EXTENSION_STORE_LINKS.chrome
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (isFirefox) {
|
|
51
|
+
return {
|
|
52
|
+
id: "firefox",
|
|
53
|
+
name: "Firefox",
|
|
54
|
+
icon: "logo-firefox",
|
|
55
|
+
storeLink: EXTENSION_STORE_LINKS.firefox
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (isSafari) {
|
|
59
|
+
return {
|
|
60
|
+
id: "safari",
|
|
61
|
+
name: "Safari",
|
|
62
|
+
icon: "logo-safari",
|
|
63
|
+
storeLink: EXTENSION_STORE_LINKS.safari
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const browserInfo2 = { ...browserInfoDefaults, ...detectBrowser() };
|
|
68
|
+
return browserInfo2;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/utils/slug.ts
|
|
72
|
+
var slug = (value) => {
|
|
73
|
+
if (!value) {
|
|
74
|
+
return "";
|
|
75
|
+
}
|
|
76
|
+
return value.toLowerCase().replace(/\s+/g, "-");
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
EXTENSION_STORE_LINKS,
|
|
81
|
+
browserInfo,
|
|
82
|
+
slug
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=chunk-DKXHVRHM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/browserInfo.ts","../src/utils/slug.ts"],"sourcesContent":["import type { DeviceService } from '../services'\n\nexport type BrowserName =\n | 'chrome'\n | 'safari'\n | 'firefox'\n | 'edge'\n | 'opera'\n | 'brave'\n\nexport type BrowserInfo = {\n id: BrowserName\n name: string\n icon: string\n storeLink: string\n}\n\n// extension store links (all webkit based browsers use chrome web store installation)\nexport const EXTENSION_STORE_LINKS = {\n chrome:\n 'https://chrome.google.com/webstore/detail/universal-profiles-testin/abpickdkkbnbcoepogfhkhennhfhehfn',\n brave:\n 'https://chrome.google.com/webstore/detail/universal-profiles-testin/abpickdkkbnbcoepogfhkhennhfhehfn',\n edge: 'https://chrome.google.com/webstore/detail/universal-profiles-testin/abpickdkkbnbcoepogfhkhennhfhehfn',\n opera: '',\n safari: '',\n firefox: '',\n}\n\n/**\n * Expose browser info to the app\n */\nexport const browserInfo = (deviceService: DeviceService): BrowserInfo => {\n const browserInfoDefaults = {\n id: 'chrome',\n name: '',\n icon: '',\n } as BrowserInfo\n\n const detectBrowser = (): BrowserInfo | undefined => {\n const { isChrome, isBrave, isFirefox, isSafari, isEdge, isOpera } =\n deviceService\n\n if (isBrave) {\n return {\n id: 'brave',\n name: 'Brave',\n icon: 'logo-brave',\n storeLink: EXTENSION_STORE_LINKS.brave,\n }\n }\n\n if (isEdge) {\n return {\n id: 'edge',\n name: 'Edge',\n icon: 'logo-edge',\n storeLink: EXTENSION_STORE_LINKS.edge,\n }\n }\n\n if (isOpera) {\n return {\n id: 'opera',\n name: 'Opera',\n icon: 'logo-opera',\n storeLink: EXTENSION_STORE_LINKS.opera,\n }\n }\n\n if (isChrome) {\n return {\n id: 'chrome',\n name: 'Chrome',\n icon: 'logo-chrome',\n storeLink: EXTENSION_STORE_LINKS.chrome,\n }\n }\n\n if (isFirefox) {\n return {\n id: 'firefox',\n name: 'Firefox',\n icon: 'logo-firefox',\n storeLink: EXTENSION_STORE_LINKS.firefox,\n }\n }\n\n if (isSafari) {\n return {\n id: 'safari',\n name: 'Safari',\n icon: 'logo-safari',\n storeLink: EXTENSION_STORE_LINKS.safari,\n }\n }\n }\n\n const browserInfo = { ...browserInfoDefaults, ...detectBrowser() }\n\n return browserInfo\n}\n","/**\n * Make slug from text\n *\n * @param value\n * @returns\n */\nexport const slug = (value?: string) => {\n if (!value) {\n return ''\n }\n\n return value.toLowerCase().replace(/\\s+/g, '-') // convert spaces to hyphens\n}\n"],"mappings":";AAkBO,IAAM,wBAAwB;AAAA,EACnC,QACE;AAAA,EACF,OACE;AAAA,EACF,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX;AAKO,IAAM,cAAc,CAAC,kBAA8C;AACxE,QAAM,sBAAsB;AAAA,IAC1B,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAEA,QAAM,gBAAgB,MAA+B;AACnD,UAAM,EAAE,UAAU,SAAS,WAAW,UAAU,QAAQ,QAAQ,IAC9D;AAEF,QAAI,SAAS;AACX,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAW,sBAAsB;AAAA,MACnC;AAAA,IACF;AAEA,QAAI,QAAQ;AACV,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAW,sBAAsB;AAAA,MACnC;AAAA,IACF;AAEA,QAAI,SAAS;AACX,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAW,sBAAsB;AAAA,MACnC;AAAA,IACF;AAEA,QAAI,UAAU;AACZ,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAW,sBAAsB;AAAA,MACnC;AAAA,IACF;AAEA,QAAI,WAAW;AACb,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAW,sBAAsB;AAAA,MACnC;AAAA,IACF;AAEA,QAAI,UAAU;AACZ,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,WAAW,sBAAsB;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AAEA,QAAMA,eAAc,EAAE,GAAG,qBAAqB,GAAG,cAAc,EAAE;AAEjE,SAAOA;AACT;;;AC/FO,IAAM,OAAO,CAAC,UAAmB;AACtC,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,YAAY,EAAE,QAAQ,QAAQ,GAAG;AAChD;","names":["browserInfo"]}
|