@hkdigital/lib-core 0.4.96 → 0.4.98
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.
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
* isLandscape: boolean,
|
|
12
12
|
* isPortrait: boolean,
|
|
13
13
|
* isMobile:boolean,
|
|
14
|
+
* isIos:boolean,
|
|
15
|
+
* isAndroid:boolean,
|
|
14
16
|
* os:'Android'|'iOS',
|
|
15
17
|
* isFullscreen:boolean,
|
|
16
18
|
* isDevMode:boolean,
|
|
@@ -78,6 +80,10 @@
|
|
|
78
80
|
let windowWidth = $state();
|
|
79
81
|
let windowHeight = $state();
|
|
80
82
|
|
|
83
|
+
let debouncedWindowWidth = $state();
|
|
84
|
+
let debouncedWindowHeight = $state();
|
|
85
|
+
let debounceTimer;
|
|
86
|
+
|
|
81
87
|
let gameWidth = $state();
|
|
82
88
|
let gameHeight = $state();
|
|
83
89
|
|
|
@@ -86,22 +92,60 @@
|
|
|
86
92
|
|
|
87
93
|
let isLandscape = $state();
|
|
88
94
|
|
|
95
|
+
const isAppleMobile = /iPhone|iPod/.test(navigator.userAgent);
|
|
96
|
+
|
|
97
|
+
// Debounce window dimensions on iOS to skip intermediate resize events
|
|
98
|
+
let skipNextResize = false;
|
|
99
|
+
let resetTimer;
|
|
100
|
+
|
|
101
|
+
$effect(() => {
|
|
102
|
+
if (isAppleMobile && windowWidth && windowHeight) {
|
|
103
|
+
if (skipNextResize) {
|
|
104
|
+
skipNextResize = false;
|
|
105
|
+
return; // Skip first of the two resize events
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
skipNextResize = true;
|
|
109
|
+
debouncedWindowWidth = windowWidth;
|
|
110
|
+
debouncedWindowHeight = windowHeight;
|
|
111
|
+
|
|
112
|
+
// Reset flag after resize events settle
|
|
113
|
+
clearTimeout(resetTimer);
|
|
114
|
+
resetTimer = setTimeout(() => {
|
|
115
|
+
skipNextResize = false;
|
|
116
|
+
}, 500);
|
|
117
|
+
} else {
|
|
118
|
+
// Non-iOS: use dimensions immediately
|
|
119
|
+
debouncedWindowWidth = windowWidth;
|
|
120
|
+
debouncedWindowHeight = windowHeight;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Update iOS dimensions when debounced window size changes
|
|
125
|
+
$effect(() => {
|
|
126
|
+
if (isPwa && isAppleMobile && debouncedWindowWidth && debouncedWindowHeight) {
|
|
127
|
+
updateIosWidthHeight();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
89
131
|
$effect(() => {
|
|
90
132
|
console.debug('getIsLandscape effect running', {
|
|
91
133
|
isPwa,
|
|
92
134
|
isAppleMobile,
|
|
93
135
|
windowWidth,
|
|
94
136
|
windowHeight,
|
|
137
|
+
debouncedWindowWidth,
|
|
138
|
+
debouncedWindowHeight,
|
|
95
139
|
iosWindowWidth,
|
|
96
140
|
iosWindowHeight
|
|
97
141
|
});
|
|
98
142
|
|
|
99
143
|
if (isPwa && isAppleMobile) {
|
|
100
|
-
// For iOS PWA,
|
|
101
|
-
updateIosWidthHeight();
|
|
144
|
+
// For iOS PWA, use iOS-specific dimensions
|
|
102
145
|
isLandscape = iosWindowWidth > iosWindowHeight;
|
|
103
146
|
} else {
|
|
104
|
-
|
|
147
|
+
// For non-PWA, use debounced window dimensions
|
|
148
|
+
isLandscape = debouncedWindowWidth > debouncedWindowHeight;
|
|
105
149
|
}
|
|
106
150
|
});
|
|
107
151
|
|
|
@@ -156,12 +200,13 @@
|
|
|
156
200
|
|
|
157
201
|
let show = $state(false);
|
|
158
202
|
|
|
159
|
-
const isAppleMobile = /iPhone|iPod/.test(navigator.userAgent);
|
|
160
|
-
|
|
161
203
|
let isPwa = $state(false);
|
|
162
204
|
|
|
163
205
|
let os = $state();
|
|
164
206
|
|
|
207
|
+
let isIos = $derived( os === 'iOS' );
|
|
208
|
+
let isAndroid = $derived( os === 'Android' );
|
|
209
|
+
|
|
165
210
|
let isMobile = $state(false);
|
|
166
211
|
|
|
167
212
|
let isDevMode = $state(false);
|
|
@@ -194,14 +239,6 @@
|
|
|
194
239
|
}
|
|
195
240
|
}
|
|
196
241
|
|
|
197
|
-
function updateOrientation(event) {
|
|
198
|
-
console.debug('*** updateOrientation EVENT FIRED ***', {
|
|
199
|
-
angle: event.target.angle,
|
|
200
|
-
type: event.target.type
|
|
201
|
-
});
|
|
202
|
-
updateIosWidthHeight();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
242
|
onMount(() => {
|
|
206
243
|
supportsFullscreen = document.fullscreenEnabled;
|
|
207
244
|
|
|
@@ -217,13 +254,7 @@
|
|
|
217
254
|
|
|
218
255
|
updateIosWidthHeight();
|
|
219
256
|
|
|
220
|
-
screen.orientation.addEventListener('change', updateOrientation);
|
|
221
|
-
|
|
222
257
|
show = true;
|
|
223
|
-
|
|
224
|
-
return () => {
|
|
225
|
-
screen.orientation.removeEventListener('change', updateOrientation);
|
|
226
|
-
};
|
|
227
258
|
});
|
|
228
259
|
|
|
229
260
|
onMount(() => {
|
|
@@ -242,6 +273,9 @@
|
|
|
242
273
|
} else if (/Android/.test(navigator.userAgent)) {
|
|
243
274
|
return 'Android';
|
|
244
275
|
}
|
|
276
|
+
else {
|
|
277
|
+
return 'unknown';
|
|
278
|
+
}
|
|
245
279
|
}
|
|
246
280
|
|
|
247
281
|
/**
|
|
@@ -372,6 +406,8 @@
|
|
|
372
406
|
isLandscape,
|
|
373
407
|
isPortrait: !isLandscape,
|
|
374
408
|
isMobile,
|
|
409
|
+
isIos,
|
|
410
|
+
isAndroid,
|
|
375
411
|
os,
|
|
376
412
|
isFullscreen,
|
|
377
413
|
isDevMode,
|
|
@@ -387,6 +423,8 @@
|
|
|
387
423
|
isLandscape,
|
|
388
424
|
isPortrait: !isLandscape,
|
|
389
425
|
isMobile,
|
|
426
|
+
isIos,
|
|
427
|
+
isAndroid,
|
|
390
428
|
os,
|
|
391
429
|
isFullscreen,
|
|
392
430
|
isDevMode,
|
|
@@ -402,6 +440,8 @@
|
|
|
402
440
|
isLandscape,
|
|
403
441
|
isPortrait: !isLandscape,
|
|
404
442
|
isMobile,
|
|
443
|
+
isIos,
|
|
444
|
+
isAndroid,
|
|
405
445
|
os,
|
|
406
446
|
isFullscreen,
|
|
407
447
|
isDevMode,
|
|
@@ -416,6 +456,8 @@
|
|
|
416
456
|
isLandscape,
|
|
417
457
|
isPortrait: !isLandscape,
|
|
418
458
|
isMobile,
|
|
459
|
+
isIos,
|
|
460
|
+
isAndroid,
|
|
419
461
|
os,
|
|
420
462
|
isFullscreen,
|
|
421
463
|
isDevMode,
|
|
@@ -431,6 +473,8 @@
|
|
|
431
473
|
isLandscape,
|
|
432
474
|
isPortrait: !isLandscape,
|
|
433
475
|
isMobile,
|
|
476
|
+
isIos,
|
|
477
|
+
isAndroid,
|
|
434
478
|
os,
|
|
435
479
|
isFullscreen,
|
|
436
480
|
isDevMode,
|
|
@@ -446,6 +490,8 @@
|
|
|
446
490
|
isLandscape,
|
|
447
491
|
isPortrait: !isLandscape,
|
|
448
492
|
isMobile,
|
|
493
|
+
isIos,
|
|
494
|
+
isAndroid,
|
|
449
495
|
os,
|
|
450
496
|
isFullscreen,
|
|
451
497
|
isDevMode,
|
|
@@ -500,6 +546,8 @@
|
|
|
500
546
|
isLandscape,
|
|
501
547
|
isPortrait: !isLandscape,
|
|
502
548
|
isMobile,
|
|
549
|
+
isIos,
|
|
550
|
+
isAndroid,
|
|
503
551
|
os,
|
|
504
552
|
isFullscreen,
|
|
505
553
|
isDevMode,
|
|
@@ -541,6 +589,8 @@
|
|
|
541
589
|
isLandscape,
|
|
542
590
|
isPortrait: !isLandscape,
|
|
543
591
|
isMobile,
|
|
592
|
+
isIos,
|
|
593
|
+
isAndroid,
|
|
544
594
|
os,
|
|
545
595
|
isFullscreen,
|
|
546
596
|
isDevMode,
|
|
@@ -575,6 +625,8 @@
|
|
|
575
625
|
isLandscape,
|
|
576
626
|
isPortrait: !isLandscape,
|
|
577
627
|
isMobile,
|
|
628
|
+
isIos,
|
|
629
|
+
isAndroid,
|
|
578
630
|
os,
|
|
579
631
|
isFullscreen,
|
|
580
632
|
isDevMode,
|
|
@@ -616,6 +668,8 @@
|
|
|
616
668
|
isLandscape,
|
|
617
669
|
isPortrait: !isLandscape,
|
|
618
670
|
isMobile,
|
|
671
|
+
isIos,
|
|
672
|
+
isAndroid,
|
|
619
673
|
os,
|
|
620
674
|
isFullscreen,
|
|
621
675
|
isDevMode,
|
|
@@ -39,6 +39,8 @@ declare const GameBox: import("svelte").Component<{
|
|
|
39
39
|
isLandscape: boolean;
|
|
40
40
|
isPortrait: boolean;
|
|
41
41
|
isMobile: boolean;
|
|
42
|
+
isIos: boolean;
|
|
43
|
+
isAndroid: boolean;
|
|
42
44
|
os: "Android" | "iOS";
|
|
43
45
|
isFullscreen: boolean;
|
|
44
46
|
isDevMode: boolean;
|
|
@@ -51,6 +53,8 @@ declare const GameBox: import("svelte").Component<{
|
|
|
51
53
|
isLandscape: boolean;
|
|
52
54
|
isPortrait: boolean;
|
|
53
55
|
isMobile: boolean;
|
|
56
|
+
isIos: boolean;
|
|
57
|
+
isAndroid: boolean;
|
|
54
58
|
os: "Android" | "iOS";
|
|
55
59
|
isFullscreen: boolean;
|
|
56
60
|
isDevMode: boolean;
|
|
@@ -63,6 +67,8 @@ declare const GameBox: import("svelte").Component<{
|
|
|
63
67
|
isLandscape: boolean;
|
|
64
68
|
isPortrait: boolean;
|
|
65
69
|
isMobile: boolean;
|
|
70
|
+
isIos: boolean;
|
|
71
|
+
isAndroid: boolean;
|
|
66
72
|
os: "Android" | "iOS";
|
|
67
73
|
isFullscreen: boolean;
|
|
68
74
|
isDevMode: boolean;
|
|
@@ -75,6 +81,8 @@ declare const GameBox: import("svelte").Component<{
|
|
|
75
81
|
isLandscape: boolean;
|
|
76
82
|
isPortrait: boolean;
|
|
77
83
|
isMobile: boolean;
|
|
84
|
+
isIos: boolean;
|
|
85
|
+
isAndroid: boolean;
|
|
78
86
|
os: "Android" | "iOS";
|
|
79
87
|
isFullscreen: boolean;
|
|
80
88
|
isDevMode: boolean;
|
|
@@ -88,6 +96,8 @@ type SnippetParams = {
|
|
|
88
96
|
isLandscape: boolean;
|
|
89
97
|
isPortrait: boolean;
|
|
90
98
|
isMobile: boolean;
|
|
99
|
+
isIos: boolean;
|
|
100
|
+
isAndroid: boolean;
|
|
91
101
|
os: "Android" | "iOS";
|
|
92
102
|
isFullscreen: boolean;
|
|
93
103
|
isDevMode: boolean;
|