@hkdigital/lib-core 0.5.14 → 0.5.16
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.
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
getGameWidthOnLandscape,
|
|
6
|
-
getGameWidthOnPortrait
|
|
6
|
+
getGameWidthOnPortrait,
|
|
7
|
+
isIOS,
|
|
8
|
+
isIpadOS,
|
|
9
|
+
getOS,
|
|
10
|
+
getIsMobile
|
|
7
11
|
} from './gamebox.util.js';
|
|
8
12
|
|
|
9
13
|
import ScaledContainer from './ScaledContainer.svelte';
|
|
@@ -127,7 +131,8 @@
|
|
|
127
131
|
}
|
|
128
132
|
} );
|
|
129
133
|
|
|
130
|
-
|
|
134
|
+
// iPad is also considered Apple mobile
|
|
135
|
+
const isAppleMobile = isIOS();
|
|
131
136
|
|
|
132
137
|
let os = $state();
|
|
133
138
|
let isIos = $derived(os === 'iOS');
|
|
@@ -302,10 +307,39 @@
|
|
|
302
307
|
};
|
|
303
308
|
portraitMediaQuery.addEventListener('change', handleOrientationChange);
|
|
304
309
|
|
|
310
|
+
// App visibility detection for iOS debugging
|
|
311
|
+
const handleVisibilityChange = () => {
|
|
312
|
+
if (document.visibilityState === 'visible') {
|
|
313
|
+
// console.log('App became visible:', {
|
|
314
|
+
// 'window.innerWidth': window.innerWidth,
|
|
315
|
+
// 'window.innerHeight': window.innerHeight,
|
|
316
|
+
// 'screen.width': screen.width,
|
|
317
|
+
// 'screen.height': screen.height,
|
|
318
|
+
// 'screen.orientation.angle': screen.orientation.angle,
|
|
319
|
+
// 'screen.orientation.type': screen.orientation.type,
|
|
320
|
+
// 'matchMedia portrait':
|
|
321
|
+
// window.matchMedia('(orientation: portrait)').matches,
|
|
322
|
+
// 'isLandscape': isLandscape,
|
|
323
|
+
// 'gameWidth': gameWidth,
|
|
324
|
+
// 'gameHeight': gameHeight,
|
|
325
|
+
// 'iosWindowWidth': iosWindowWidth,
|
|
326
|
+
// 'iosWindowHeight': iosWindowHeight
|
|
327
|
+
// });
|
|
328
|
+
|
|
329
|
+
// Force iOS dimension update when app becomes visible
|
|
330
|
+
if (isPwa && isAppleMobile) {
|
|
331
|
+
updateIosWidthHeight();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
337
|
+
|
|
305
338
|
show = true;
|
|
306
339
|
|
|
307
340
|
return () => {
|
|
308
341
|
portraitMediaQuery.removeEventListener('change', handleOrientationChange);
|
|
342
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
309
343
|
};
|
|
310
344
|
});
|
|
311
345
|
|
|
@@ -330,35 +364,6 @@
|
|
|
330
364
|
}
|
|
331
365
|
});
|
|
332
366
|
|
|
333
|
-
|
|
334
|
-
function getOS() {
|
|
335
|
-
if (isAppleMobile) {
|
|
336
|
-
return 'iOS';
|
|
337
|
-
} else if (/Android/.test(navigator.userAgent)) {
|
|
338
|
-
return 'Android';
|
|
339
|
-
} else {
|
|
340
|
-
return 'unknown';
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Returns true if a device is a mobile phone (or similar)
|
|
346
|
-
*/
|
|
347
|
-
function getIsMobile() {
|
|
348
|
-
// @ts-ignore
|
|
349
|
-
if (navigator?.userAgentData?.mobile !== undefined) {
|
|
350
|
-
// Supports for mobile flag
|
|
351
|
-
// @ts-ignore
|
|
352
|
-
return navigator.userAgentData.mobile;
|
|
353
|
-
} else if (isAppleMobile) {
|
|
354
|
-
return true;
|
|
355
|
-
} else if (/Android/.test(navigator.userAgent)) {
|
|
356
|
-
return true;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
367
|
/**
|
|
363
368
|
* Returns true if the window is in full screen
|
|
364
369
|
* - Checks if CSS thinks we're in fullscreen mode
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the device is running iOS (iPhone, iPod, or iPad)
|
|
3
|
+
*
|
|
4
|
+
* @returns {boolean} true if iOS device
|
|
5
|
+
*/
|
|
6
|
+
export function isIOS(): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Check if the device is running iPadOS
|
|
9
|
+
*
|
|
10
|
+
* @returns {boolean} true if iPadOS device
|
|
11
|
+
*/
|
|
12
|
+
export function isIpadOS(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Get the operating system of the device
|
|
15
|
+
*
|
|
16
|
+
* @returns {'iOS'|'Android'|'unknown'} operating system
|
|
17
|
+
*/
|
|
18
|
+
export function getOS(): "iOS" | "Android" | "unknown";
|
|
19
|
+
/**
|
|
20
|
+
* Check if the device is a mobile phone or tablet
|
|
21
|
+
*
|
|
22
|
+
* @returns {boolean} true if mobile device
|
|
23
|
+
*/
|
|
24
|
+
export function getIsMobile(): boolean;
|
|
1
25
|
/**
|
|
2
26
|
* Get game width for landscape mode
|
|
3
27
|
*
|
|
@@ -2,6 +2,67 @@ export const ERROR_WINDOW_SIZE_NOT_LANDSCAPE = 'Window size is not landsccape';
|
|
|
2
2
|
|
|
3
3
|
export const ERROR_WINDOW_SIZE_NOT_PORTRAIT = 'Window size is not portrait';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Check if the device is running iOS (iPhone, iPod, or iPad)
|
|
7
|
+
*
|
|
8
|
+
* @returns {boolean} true if iOS device
|
|
9
|
+
*/
|
|
10
|
+
export function isIOS() {
|
|
11
|
+
if (/iPad|iPhone|iPod/.test(navigator.platform)) {
|
|
12
|
+
return true;
|
|
13
|
+
} else {
|
|
14
|
+
return navigator.maxTouchPoints &&
|
|
15
|
+
navigator.maxTouchPoints > 2 &&
|
|
16
|
+
/MacIntel/.test(navigator.platform);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Check if the device is running iPadOS
|
|
22
|
+
*
|
|
23
|
+
* @returns {boolean} true if iPadOS device
|
|
24
|
+
*/
|
|
25
|
+
export function isIpadOS() {
|
|
26
|
+
return navigator.maxTouchPoints &&
|
|
27
|
+
navigator.maxTouchPoints > 2 &&
|
|
28
|
+
/MacIntel/.test(navigator.platform);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the operating system of the device
|
|
33
|
+
*
|
|
34
|
+
* @returns {'iOS'|'Android'|'unknown'} operating system
|
|
35
|
+
*/
|
|
36
|
+
export function getOS() {
|
|
37
|
+
if (isIOS()) {
|
|
38
|
+
return 'iOS';
|
|
39
|
+
} else if (/Android/.test(navigator.userAgent)) {
|
|
40
|
+
return 'Android';
|
|
41
|
+
} else {
|
|
42
|
+
return 'unknown';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Check if the device is a mobile phone or tablet
|
|
48
|
+
*
|
|
49
|
+
* @returns {boolean} true if mobile device
|
|
50
|
+
*/
|
|
51
|
+
export function getIsMobile() {
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
if (navigator?.userAgentData?.mobile !== undefined) {
|
|
54
|
+
// Supports for mobile flag
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return navigator.userAgentData.mobile;
|
|
57
|
+
} else if (isIOS()) {
|
|
58
|
+
return true;
|
|
59
|
+
} else if (/Android/.test(navigator.userAgent)) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
5
66
|
/**
|
|
6
67
|
* Get game width for landscape mode
|
|
7
68
|
*
|