@hkdigital/lib-core 0.5.17 → 0.5.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/info.d.ts +26 -0
- package/dist/app/info.js +33 -0
- package/dist/app/typedef.d.ts +4 -0
- package/dist/app/typedef.js +8 -0
- package/dist/browser/info/device.d.ts +67 -0
- package/dist/browser/info/device.js +183 -0
- package/dist/browser/info/display.d.ts +73 -0
- package/dist/browser/info/display.js +109 -0
- package/dist/browser/info/engine.d.ts +39 -0
- package/dist/browser/info/engine.js +64 -0
- package/dist/browser/info/language.d.ts +18 -0
- package/dist/browser/info/language.js +23 -0
- package/dist/browser/info/system.d.ts +47 -0
- package/dist/browser/info/system.js +102 -0
- package/dist/browser/info/timezone.d.ts +20 -0
- package/dist/browser/info/timezone.js +25 -0
- package/dist/browser/info.d.ts +81 -0
- package/dist/browser/info.js +185 -0
- package/dist/browser/typedef.d.ts +31 -0
- package/dist/browser/typedef.js +38 -0
- package/dist/ui/components/game-box/GameBox.svelte +37 -90
- package/dist/ui/components/game-box/GameBox.svelte.d.ts +4 -70
- package/dist/ui/components/game-box/gamebox.util.d.ts +0 -24
- package/dist/ui/components/game-box/gamebox.util.js +0 -61
- package/dist/ui/components/game-box/typedef.d.ts +16 -0
- package/dist/ui/components/game-box/typedef.js +23 -0
- package/dist/ui/components/typedef.d.ts +1 -0
- package/dist/ui/components/typedef.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./typedef.js').AppInfo} AppInfo
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get application information
|
|
6
|
+
*
|
|
7
|
+
* @returns {AppInfo} app info
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const appInfo = getAppInfo();
|
|
11
|
+
* // { appVersion: '1.2.3', buildTimestamp: '2025-01-15T10:30:00Z' }
|
|
12
|
+
*/
|
|
13
|
+
export function getAppInfo(): AppInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Application version from environment variables
|
|
16
|
+
*
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
export const appVersion: string;
|
|
20
|
+
/**
|
|
21
|
+
* Build timestamp from environment variables
|
|
22
|
+
*
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
export const buildTimestamp: string;
|
|
26
|
+
export type AppInfo = import("./typedef.js").AppInfo;
|
package/dist/app/info.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application version from environment variables
|
|
3
|
+
*
|
|
4
|
+
* @type {string}
|
|
5
|
+
*/
|
|
6
|
+
export const appVersion = import.meta.env.VITE_APP_VERSION || '0.0.0';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Build timestamp from environment variables
|
|
10
|
+
*
|
|
11
|
+
* @type {string}
|
|
12
|
+
*/
|
|
13
|
+
export const buildTimestamp = import.meta.env.VITE_BUILD_TIMESTAMP ?? '';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('./typedef.js').AppInfo} AppInfo
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get application information
|
|
21
|
+
*
|
|
22
|
+
* @returns {AppInfo} app info
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const appInfo = getAppInfo();
|
|
26
|
+
* // { appVersion: '1.2.3', buildTimestamp: '2025-01-15T10:30:00Z' }
|
|
27
|
+
*/
|
|
28
|
+
export function getAppInfo() {
|
|
29
|
+
return {
|
|
30
|
+
appVersion,
|
|
31
|
+
buildTimestamp
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the device is Apple mobile (iPhone, iPod, or iPad)
|
|
3
|
+
*
|
|
4
|
+
* @returns {boolean} true if Apple mobile device
|
|
5
|
+
*/
|
|
6
|
+
export function getIsAppleMobile(): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Check if the device is Android mobile (phone or tablet)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Android phone: true
|
|
12
|
+
* // Android tablet: true
|
|
13
|
+
* // Android TV: false
|
|
14
|
+
* // Desktop, iOS: false
|
|
15
|
+
*
|
|
16
|
+
* @returns {boolean} true if Android mobile device
|
|
17
|
+
*/
|
|
18
|
+
export function getIsAndroidMobile(): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the device is running iPadOS
|
|
21
|
+
*
|
|
22
|
+
* @returns {boolean} true if iPadOS device
|
|
23
|
+
*/
|
|
24
|
+
export function getIsIpadOS(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if the device is a tablet
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // iPad, Android tablets: true
|
|
30
|
+
* // iPhone, Android phones, Desktop: false
|
|
31
|
+
*
|
|
32
|
+
* @returns {boolean} true if tablet device
|
|
33
|
+
*/
|
|
34
|
+
export function getIsTablet(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the device is a phone (not tablet)
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // iPhone, Android phones: true
|
|
40
|
+
* // iPad, tablets, Desktop: false
|
|
41
|
+
*
|
|
42
|
+
* @returns {boolean} true if phone device
|
|
43
|
+
*/
|
|
44
|
+
export function getIsPhone(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Check if the device is a mobile phone or tablet
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // iPhone, iPad: true
|
|
50
|
+
* // Android phone, Android tablet: true
|
|
51
|
+
* // Android TV, Desktop: false
|
|
52
|
+
*
|
|
53
|
+
* @returns {boolean} true if mobile device
|
|
54
|
+
*/
|
|
55
|
+
export function getIsMobile(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get device type
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // iPhone, Android phone: 'phone'
|
|
61
|
+
* // iPad, Android tablet: 'tablet'
|
|
62
|
+
* // Android TV: 'tv'
|
|
63
|
+
* // Desktop/laptop: 'desktop'
|
|
64
|
+
*
|
|
65
|
+
* @returns {'phone'|'tablet'|'tv'|'desktop'} device type
|
|
66
|
+
*/
|
|
67
|
+
export function getDeviceType(): "phone" | "tablet" | "tv" | "desktop";
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Check if the device is Apple mobile (iPhone, iPod, or iPad)
|
|
4
|
+
*
|
|
5
|
+
* @returns {boolean} true if Apple mobile device
|
|
6
|
+
*/
|
|
7
|
+
export function getIsAppleMobile() {
|
|
8
|
+
if (/iPad|iPhone|iPod/.test(navigator.platform)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return getIsIpadOS();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Check if the device is Android mobile (phone or tablet)
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Android phone: true
|
|
20
|
+
* // Android tablet: true
|
|
21
|
+
* // Android TV: false
|
|
22
|
+
* // Desktop, iOS: false
|
|
23
|
+
*
|
|
24
|
+
* @returns {boolean} true if Android mobile device
|
|
25
|
+
*/
|
|
26
|
+
export function getIsAndroidMobile() {
|
|
27
|
+
const ua = navigator.userAgent;
|
|
28
|
+
|
|
29
|
+
// Check for Android
|
|
30
|
+
if (!/Android/.test(ua)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Exclude Android TV and other non-mobile Android devices
|
|
35
|
+
if (/TV|SmartTV|BRAVIA/.test(ua)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Check if the device is running iPadOS
|
|
44
|
+
*
|
|
45
|
+
* @returns {boolean} true if iPadOS device
|
|
46
|
+
*/
|
|
47
|
+
export function getIsIpadOS() {
|
|
48
|
+
return (
|
|
49
|
+
navigator.maxTouchPoints > 2 &&
|
|
50
|
+
/MacIntel/.test(navigator.platform)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Check if the device is a tablet
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // iPad, Android tablets: true
|
|
59
|
+
* // iPhone, Android phones, Desktop: false
|
|
60
|
+
*
|
|
61
|
+
* @returns {boolean} true if tablet device
|
|
62
|
+
*/
|
|
63
|
+
export function getIsTablet() {
|
|
64
|
+
// Must have touch support
|
|
65
|
+
if (!navigator.maxTouchPoints || navigator.maxTouchPoints === 0) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const ua = navigator.userAgent;
|
|
70
|
+
|
|
71
|
+
// iPad or iPadOS
|
|
72
|
+
if (getIsIpadOS()) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// iPad with older iOS versions
|
|
77
|
+
if (/iPad/.test(navigator.platform)) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Android tablets typically don't have "Mobile" in UA
|
|
82
|
+
if (/Android/.test(ua) && !/Mobile/.test(ua)) {
|
|
83
|
+
// Exclude Android TV
|
|
84
|
+
if (/TV|SmartTV|BRAVIA/.test(ua)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Check if the device is a phone (not tablet)
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* // iPhone, Android phones: true
|
|
98
|
+
* // iPad, tablets, Desktop: false
|
|
99
|
+
*
|
|
100
|
+
* @returns {boolean} true if phone device
|
|
101
|
+
*/
|
|
102
|
+
export function getIsPhone() {
|
|
103
|
+
// Must have touch support
|
|
104
|
+
if (!navigator.maxTouchPoints || navigator.maxTouchPoints === 0) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const ua = navigator.userAgent;
|
|
109
|
+
|
|
110
|
+
// iPhone or iPod (not iPad)
|
|
111
|
+
if (/iPhone|iPod/.test(navigator.platform)) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Android with "Mobile" marker (phones have this, tablets don't)
|
|
116
|
+
if (/Android/.test(ua) && /Mobile/.test(ua)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Check if the device is a mobile phone or tablet
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // iPhone, iPad: true
|
|
128
|
+
* // Android phone, Android tablet: true
|
|
129
|
+
* // Android TV, Desktop: false
|
|
130
|
+
*
|
|
131
|
+
* @returns {boolean} true if mobile device
|
|
132
|
+
*/
|
|
133
|
+
export function getIsMobile() {
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
if (navigator?.userAgentData?.mobile !== undefined) {
|
|
136
|
+
// Modern API - most reliable
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
return navigator.userAgentData.mobile;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (getIsAppleMobile()) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (getIsAndroidMobile()) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Get device type
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* // iPhone, Android phone: 'phone'
|
|
157
|
+
* // iPad, Android tablet: 'tablet'
|
|
158
|
+
* // Android TV: 'tv'
|
|
159
|
+
* // Desktop/laptop: 'desktop'
|
|
160
|
+
*
|
|
161
|
+
* @returns {'phone'|'tablet'|'tv'|'desktop'} device type
|
|
162
|
+
*/
|
|
163
|
+
export function getDeviceType() {
|
|
164
|
+
const ua = navigator.userAgent;
|
|
165
|
+
|
|
166
|
+
// Check for TV first
|
|
167
|
+
if (/TV|SmartTV|BRAVIA/.test(ua)) {
|
|
168
|
+
return 'tv';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Check for tablet (requires touch)
|
|
172
|
+
if (getIsTablet()) {
|
|
173
|
+
return 'tablet';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Check for phone (requires touch)
|
|
177
|
+
if (getIsPhone()) {
|
|
178
|
+
return 'phone';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Default to desktop
|
|
182
|
+
return 'desktop';
|
|
183
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the app is running as a PWA
|
|
3
|
+
*
|
|
4
|
+
* @returns {boolean} true if running as PWA
|
|
5
|
+
*/
|
|
6
|
+
export function getIsPwa(): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Check if window is in fullscreen mode
|
|
9
|
+
*
|
|
10
|
+
* @returns {boolean} true if fullscreen
|
|
11
|
+
*/
|
|
12
|
+
export function getIsFullscreen(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Get screen dimensions (physical screen size)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Desktop: {width: 1920, height: 1080}
|
|
18
|
+
* // iPhone 14: {width: 390, height: 844}
|
|
19
|
+
* // iPad Pro: {width: 1024, height: 1366}
|
|
20
|
+
*
|
|
21
|
+
* @returns {{width: number, height: number}} screen dimensions
|
|
22
|
+
*/
|
|
23
|
+
export function getScreenSize(): {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get viewport dimensions (visible browser area)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Full screen: {width: 1920, height: 1080}
|
|
32
|
+
* // Windowed: {width: 1200, height: 800}
|
|
33
|
+
* // Mobile with address bar: {width: 390, height: 750}
|
|
34
|
+
*
|
|
35
|
+
* @returns {{width: number, height: number}} viewport dimensions
|
|
36
|
+
*/
|
|
37
|
+
export function getViewportSize(): {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Get screen orientation
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Phone held upright: 'portrait'
|
|
46
|
+
* // Phone rotated: 'landscape'
|
|
47
|
+
* // Desktop: 'landscape'
|
|
48
|
+
*
|
|
49
|
+
* @returns {'portrait'|'landscape'} screen orientation
|
|
50
|
+
*/
|
|
51
|
+
export function getOrientation(): "portrait" | "landscape";
|
|
52
|
+
/**
|
|
53
|
+
* Get device pixel ratio (retina displays have higher values)
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Standard display: 1
|
|
57
|
+
* // Retina/High-DPI: 2 or 3
|
|
58
|
+
* // iPhone 14 Pro: 3
|
|
59
|
+
*
|
|
60
|
+
* @returns {number} device pixel ratio
|
|
61
|
+
*/
|
|
62
|
+
export function getDevicePixelRatio(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Check if device has touch support
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Mobile phones/tablets: true
|
|
68
|
+
* // Desktop with touch screen: true
|
|
69
|
+
* // Desktop without touch: false
|
|
70
|
+
*
|
|
71
|
+
* @returns {boolean} true if touch is supported
|
|
72
|
+
*/
|
|
73
|
+
export function hasTouchSupport(): boolean;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the app is running as a PWA
|
|
3
|
+
*
|
|
4
|
+
* @returns {boolean} true if running as PWA
|
|
5
|
+
*/
|
|
6
|
+
export function getIsPwa() {
|
|
7
|
+
return window.matchMedia(
|
|
8
|
+
'(display-mode: fullscreen) or (display-mode: standalone)'
|
|
9
|
+
).matches;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check if window is in fullscreen mode
|
|
14
|
+
*
|
|
15
|
+
* @returns {boolean} true if fullscreen
|
|
16
|
+
*/
|
|
17
|
+
export function getIsFullscreen() {
|
|
18
|
+
if (getIsPwa()) {
|
|
19
|
+
return true;
|
|
20
|
+
} else if (document.fullscreenElement) {
|
|
21
|
+
// Safari
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get screen dimensions (physical screen size)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Desktop: {width: 1920, height: 1080}
|
|
33
|
+
* // iPhone 14: {width: 390, height: 844}
|
|
34
|
+
* // iPad Pro: {width: 1024, height: 1366}
|
|
35
|
+
*
|
|
36
|
+
* @returns {{width: number, height: number}} screen dimensions
|
|
37
|
+
*/
|
|
38
|
+
export function getScreenSize() {
|
|
39
|
+
return {
|
|
40
|
+
width: window.screen.width,
|
|
41
|
+
height: window.screen.height
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get viewport dimensions (visible browser area)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // Full screen: {width: 1920, height: 1080}
|
|
50
|
+
* // Windowed: {width: 1200, height: 800}
|
|
51
|
+
* // Mobile with address bar: {width: 390, height: 750}
|
|
52
|
+
*
|
|
53
|
+
* @returns {{width: number, height: number}} viewport dimensions
|
|
54
|
+
*/
|
|
55
|
+
export function getViewportSize() {
|
|
56
|
+
return {
|
|
57
|
+
width: window.innerWidth,
|
|
58
|
+
height: window.innerHeight
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get screen orientation
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Phone held upright: 'portrait'
|
|
67
|
+
* // Phone rotated: 'landscape'
|
|
68
|
+
* // Desktop: 'landscape'
|
|
69
|
+
*
|
|
70
|
+
* @returns {'portrait'|'landscape'} screen orientation
|
|
71
|
+
*/
|
|
72
|
+
export function getOrientation() {
|
|
73
|
+
return window.matchMedia('(orientation: portrait)').matches
|
|
74
|
+
? 'portrait'
|
|
75
|
+
: 'landscape';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get device pixel ratio (retina displays have higher values)
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Standard display: 1
|
|
83
|
+
* // Retina/High-DPI: 2 or 3
|
|
84
|
+
* // iPhone 14 Pro: 3
|
|
85
|
+
*
|
|
86
|
+
* @returns {number} device pixel ratio
|
|
87
|
+
*/
|
|
88
|
+
export function getDevicePixelRatio() {
|
|
89
|
+
return window.devicePixelRatio || 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Check if device has touch support
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* // Mobile phones/tablets: true
|
|
97
|
+
* // Desktop with touch screen: true
|
|
98
|
+
* // Desktop without touch: false
|
|
99
|
+
*
|
|
100
|
+
* @returns {boolean} true if touch is supported
|
|
101
|
+
*/
|
|
102
|
+
export function hasTouchSupport() {
|
|
103
|
+
return (
|
|
104
|
+
'ontouchstart' in window ||
|
|
105
|
+
navigator.maxTouchPoints > 0 ||
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
navigator.msMaxTouchPoints > 0
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get browser rendering engine
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // Firefox: 'gecko'
|
|
6
|
+
* // Chrome, Edge, Brave, Vivaldi, Arc: 'blink'
|
|
7
|
+
* // Safari: 'webkit'
|
|
8
|
+
*
|
|
9
|
+
* @returns {'blink'|'gecko'|'webkit'|'unknown'} browser engine
|
|
10
|
+
*/
|
|
11
|
+
export function getBrowserEngine(): "blink" | "gecko" | "webkit" | "unknown";
|
|
12
|
+
/**
|
|
13
|
+
* Get simplified browser name
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // 'Firefox', 'Edge', 'Safari', 'Chromium' (Chrome/Brave/Vivaldi/Arc)
|
|
17
|
+
*
|
|
18
|
+
* @returns {string} browser name
|
|
19
|
+
*/
|
|
20
|
+
export function getBrowserName(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get browser vendor
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // 'Google Inc.', 'Apple Computer, Inc.', ''
|
|
26
|
+
*
|
|
27
|
+
* @returns {string} browser vendor
|
|
28
|
+
*/
|
|
29
|
+
export function getVendor(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get user agent string
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...'
|
|
35
|
+
* // 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)...'
|
|
36
|
+
*
|
|
37
|
+
* @returns {string} user agent
|
|
38
|
+
*/
|
|
39
|
+
export function getUserAgent(): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get browser rendering engine
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // Firefox: 'gecko'
|
|
6
|
+
* // Chrome, Edge, Brave, Vivaldi, Arc: 'blink'
|
|
7
|
+
* // Safari: 'webkit'
|
|
8
|
+
*
|
|
9
|
+
* @returns {'blink'|'gecko'|'webkit'|'unknown'} browser engine
|
|
10
|
+
*/
|
|
11
|
+
export function getBrowserEngine() {
|
|
12
|
+
const ua = navigator.userAgent;
|
|
13
|
+
|
|
14
|
+
if (ua.includes('Firefox/')) return 'gecko';
|
|
15
|
+
if (ua.includes('Edg/')) return 'blink';
|
|
16
|
+
if (ua.includes('Chrome/')) return 'blink';
|
|
17
|
+
if (ua.includes('Safari/') && !ua.includes('Chrome/')) return 'webkit';
|
|
18
|
+
|
|
19
|
+
return 'unknown';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get simplified browser name
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // 'Firefox', 'Edge', 'Safari', 'Chromium' (Chrome/Brave/Vivaldi/Arc)
|
|
27
|
+
*
|
|
28
|
+
* @returns {string} browser name
|
|
29
|
+
*/
|
|
30
|
+
export function getBrowserName() {
|
|
31
|
+
const ua = navigator.userAgent;
|
|
32
|
+
|
|
33
|
+
if (ua.includes('Firefox/')) return 'Firefox';
|
|
34
|
+
if (ua.includes('Edg/')) return 'Edge';
|
|
35
|
+
if (ua.includes('Safari/') && !ua.includes('Chrome/')) return 'Safari';
|
|
36
|
+
if (ua.includes('Chrome/')) return 'Chromium';
|
|
37
|
+
|
|
38
|
+
return 'Unknown';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get browser vendor
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // 'Google Inc.', 'Apple Computer, Inc.', ''
|
|
46
|
+
*
|
|
47
|
+
* @returns {string} browser vendor
|
|
48
|
+
*/
|
|
49
|
+
export function getVendor() {
|
|
50
|
+
return navigator.vendor || '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get user agent string
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...'
|
|
58
|
+
* // 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)...'
|
|
59
|
+
*
|
|
60
|
+
* @returns {string} user agent
|
|
61
|
+
*/
|
|
62
|
+
export function getUserAgent() {
|
|
63
|
+
return navigator.userAgent;
|
|
64
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get browser language
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // 'en-US', 'nl-NL', 'fr-FR', 'de-DE'
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} browser language code
|
|
8
|
+
*/
|
|
9
|
+
export function getLanguage(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Get all preferred languages
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // ['en-US', 'en', 'nl-NL']
|
|
15
|
+
*
|
|
16
|
+
* @returns {string[]} array of language codes
|
|
17
|
+
*/
|
|
18
|
+
export function getLanguages(): string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get browser language
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // 'en-US', 'nl-NL', 'fr-FR', 'de-DE'
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} browser language code
|
|
8
|
+
*/
|
|
9
|
+
export function getLanguage() {
|
|
10
|
+
return navigator.language || 'en';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get all preferred languages
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // ['en-US', 'en', 'nl-NL']
|
|
18
|
+
*
|
|
19
|
+
* @returns {string[]} array of language codes
|
|
20
|
+
*/
|
|
21
|
+
export function getLanguages() {
|
|
22
|
+
return navigator.languages || [navigator.language || 'en'];
|
|
23
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get simplified platform identifier
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // 'macos', 'windows', 'linux', 'ios', 'android', 'unknown'
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} platform identifier
|
|
8
|
+
*/
|
|
9
|
+
export function getPlatform(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Get raw platform string from navigator
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // 'MacIntel', 'Win32', 'Linux x86_64', 'iPhone', 'iPad'
|
|
15
|
+
*
|
|
16
|
+
* @returns {string} raw platform identifier
|
|
17
|
+
*/
|
|
18
|
+
export function getPlatformRaw(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get number of CPU cores (logical processors)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Desktop: 8, 16, 24
|
|
24
|
+
* // Mobile: 4, 6, 8
|
|
25
|
+
* // Older devices: 2
|
|
26
|
+
*
|
|
27
|
+
* @returns {number} number of logical processors
|
|
28
|
+
*/
|
|
29
|
+
export function getCpuCores(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Check if device is online
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // true (connected), false (offline)
|
|
35
|
+
*
|
|
36
|
+
* @returns {boolean} true if online
|
|
37
|
+
*/
|
|
38
|
+
export function isOnline(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get connection type if available (experimental API)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // '4g', '3g', 'slow-2g', 'wifi', null
|
|
44
|
+
*
|
|
45
|
+
* @returns {string|null} connection type or null
|
|
46
|
+
*/
|
|
47
|
+
export function getConnectionType(): string | null;
|