@betarena/ad-engine 0.0.51 → 0.0.55
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 +0 -47
- package/package.json +12 -10
- package/src/App.svelte +15 -1
- package/src/index.js +0 -0
- package/src/index.ts +17 -4
- package/src/lib/Advert-Engine-Widget.svelte +417 -79
- package/src/lib/Advert-InterScroller-Child.svelte +428 -0
- package/src/lib/_store.ts +0 -0
- package/src/lib/utils/debug.ts +49 -0
- package/src/lib/utils/device.ts +43 -3
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
3
|
+
│ 📌 High Order Component Overview │
|
|
4
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
5
|
+
│ ➤ Internal Svelte Code Format :|: V.8.0 │
|
|
6
|
+
│ ➤ Status :|: 🔒 LOCKED │
|
|
7
|
+
│ ➤ Author(s) :|: @migbash │
|
|
8
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
9
|
+
│ 📝 Description │
|
|
10
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
11
|
+
│ Betarena Ad-Engine Component - Interscroller │
|
|
12
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<!--
|
|
16
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
17
|
+
│ 🟦 Svelte Component JS/TS │
|
|
18
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
19
|
+
│ ➤ HINT: │ Access snippets for '<script> [..] </script>' those found in │
|
|
20
|
+
│ │ '.vscode/snippets.code-snippets' via intellisense using 'doc' │
|
|
21
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
|
|
26
|
+
// #region ➤ 📦 Package Imports
|
|
27
|
+
|
|
28
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
29
|
+
// │ NOTE: │
|
|
30
|
+
// │ Please add inside 'this' region the 'imports' that are required │
|
|
31
|
+
// │ by 'this' .svelte file is ran. │
|
|
32
|
+
// │ IMPORTANT │
|
|
33
|
+
// │ Please, structure the imports as follows: │
|
|
34
|
+
// │ 1. svelte/sveltekit imports │
|
|
35
|
+
// │ 2. project-internal files and logic │
|
|
36
|
+
// │ 3. component import(s) │
|
|
37
|
+
// │ 4. assets import(s) │
|
|
38
|
+
// │ 5. type(s) imports(s) │
|
|
39
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
40
|
+
|
|
41
|
+
import { onMount } from 'svelte';
|
|
42
|
+
|
|
43
|
+
import { betarenaEndpoint } from './constants/instance.js';
|
|
44
|
+
import { storeAdmin } from './store/admin.js';
|
|
45
|
+
import { postMod } from './utils/fetch.js';
|
|
46
|
+
|
|
47
|
+
import type { AdsCreativeMain } from '@betarena/scores-lib/types/_AUTO-HASURA_.js';
|
|
48
|
+
|
|
49
|
+
// #endregion ➤ 📦 Package Imports
|
|
50
|
+
|
|
51
|
+
// #region ➤ 📌 VARIABLES
|
|
52
|
+
|
|
53
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
54
|
+
// │ NOTE: │
|
|
55
|
+
// │ Please add inside 'this' region the 'variables' that are to be │
|
|
56
|
+
// │ and are expected to be used by 'this' .svelte file / component. │
|
|
57
|
+
// │ IMPORTANT │
|
|
58
|
+
// │ Please, structure the imports as follows: │
|
|
59
|
+
// │ 1. export const / let [..] │
|
|
60
|
+
// │ 2. const [..] │
|
|
61
|
+
// │ 3. let [..] │
|
|
62
|
+
// │ 4. $: [..] │
|
|
63
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
64
|
+
|
|
65
|
+
export let
|
|
66
|
+
/**
|
|
67
|
+
* @description
|
|
68
|
+
* 📝
|
|
69
|
+
*/
|
|
70
|
+
listStrInsertAfter: [number, string] | undefined = [-1, 'p'],
|
|
71
|
+
/**
|
|
72
|
+
* @augments AdsCreativeMain
|
|
73
|
+
*/
|
|
74
|
+
objectAdverData: AdsCreativeMain,
|
|
75
|
+
/**
|
|
76
|
+
* @description
|
|
77
|
+
* 📝
|
|
78
|
+
*/
|
|
79
|
+
instanceNode: Element
|
|
80
|
+
;
|
|
81
|
+
|
|
82
|
+
let
|
|
83
|
+
/**
|
|
84
|
+
* @description
|
|
85
|
+
* 📝
|
|
86
|
+
*/
|
|
87
|
+
instanceAdvertInterscroller: HTMLDivElement
|
|
88
|
+
;
|
|
89
|
+
|
|
90
|
+
// #endregion ➤ 📌 VARIABLES
|
|
91
|
+
|
|
92
|
+
// #region ➤ 🛠️ METHODS
|
|
93
|
+
|
|
94
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
95
|
+
// │ NOTE: │
|
|
96
|
+
// │ Please add inside 'this' region the 'methods' that are to be │
|
|
97
|
+
// │ and are expected to be used by 'this' .svelte file / component. │
|
|
98
|
+
// │ IMPORTANT │
|
|
99
|
+
// │ Please, structure the imports as follows: │
|
|
100
|
+
// │ 1. function (..) │
|
|
101
|
+
// │ 2. async function (..) │
|
|
102
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @author
|
|
106
|
+
* @ivanzob
|
|
107
|
+
* @summary
|
|
108
|
+
* 🟦 HELPER
|
|
109
|
+
* @description
|
|
110
|
+
* 📝 Inject Advert data
|
|
111
|
+
* @return { void }
|
|
112
|
+
*/
|
|
113
|
+
function injectBetarenaInterscrollerAd
|
|
114
|
+
(
|
|
115
|
+
): void
|
|
116
|
+
{
|
|
117
|
+
if (!instanceNode) return;
|
|
118
|
+
|
|
119
|
+
const
|
|
120
|
+
// ╭─────
|
|
121
|
+
// │ NOTE: |:| Destructuring listStrInsertAfter
|
|
122
|
+
// ╰─────
|
|
123
|
+
[
|
|
124
|
+
count,
|
|
125
|
+
n
|
|
126
|
+
] = listStrInsertAfter ?? [-1, 'p'],
|
|
127
|
+
/**
|
|
128
|
+
* @description
|
|
129
|
+
* 📝
|
|
130
|
+
*/
|
|
131
|
+
insertAfterNodes
|
|
132
|
+
= instanceNode.querySelectorAll(n)
|
|
133
|
+
;
|
|
134
|
+
|
|
135
|
+
if (!insertAfterNodes.length)
|
|
136
|
+
return;
|
|
137
|
+
;
|
|
138
|
+
|
|
139
|
+
let
|
|
140
|
+
/**
|
|
141
|
+
* @description
|
|
142
|
+
*/
|
|
143
|
+
afterNode
|
|
144
|
+
;
|
|
145
|
+
|
|
146
|
+
if (count >= 0)
|
|
147
|
+
afterNode = insertAfterNodes[count];
|
|
148
|
+
else if (count === -1)
|
|
149
|
+
if (insertAfterNodes.length > 2)
|
|
150
|
+
afterNode
|
|
151
|
+
= insertAfterNodes
|
|
152
|
+
[
|
|
153
|
+
Math.floor
|
|
154
|
+
(
|
|
155
|
+
Math.random() * (insertAfterNodes.length - 2)
|
|
156
|
+
) + 1
|
|
157
|
+
]
|
|
158
|
+
;
|
|
159
|
+
else
|
|
160
|
+
afterNode = insertAfterNodes[0];
|
|
161
|
+
;
|
|
162
|
+
|
|
163
|
+
if (!afterNode) return;
|
|
164
|
+
|
|
165
|
+
const
|
|
166
|
+
/**
|
|
167
|
+
* @description
|
|
168
|
+
* 📝
|
|
169
|
+
*/
|
|
170
|
+
pos
|
|
171
|
+
= instanceNode.getBoundingClientRect()
|
|
172
|
+
;
|
|
173
|
+
|
|
174
|
+
instanceAdvertInterscroller.style.display = 'flex';
|
|
175
|
+
instanceAdvertInterscroller.style.left = `${-pos.left}px`;
|
|
176
|
+
|
|
177
|
+
afterNode.insertAdjacentElement
|
|
178
|
+
(
|
|
179
|
+
'afterend',
|
|
180
|
+
instanceAdvertInterscroller
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
setTimeout
|
|
184
|
+
(
|
|
185
|
+
() =>
|
|
186
|
+
{
|
|
187
|
+
window.addEventListener('scroll', handleScroll);
|
|
188
|
+
return;
|
|
189
|
+
},
|
|
190
|
+
1000
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @author
|
|
198
|
+
* @ivanzob
|
|
199
|
+
* @summary
|
|
200
|
+
* 🟦 HELPER
|
|
201
|
+
* @description
|
|
202
|
+
* 📝 Handle Scroll Listener
|
|
203
|
+
* @returns { void }
|
|
204
|
+
*/
|
|
205
|
+
function handleScroll
|
|
206
|
+
(
|
|
207
|
+
): void
|
|
208
|
+
{
|
|
209
|
+
if (!instanceAdvertInterscroller) return;
|
|
210
|
+
|
|
211
|
+
if (instanceAdvertInterscroller.getBoundingClientRect().bottom < 0)
|
|
212
|
+
{
|
|
213
|
+
instanceAdvertInterscroller.style.display = 'none';
|
|
214
|
+
window.removeEventListener
|
|
215
|
+
(
|
|
216
|
+
'scroll',
|
|
217
|
+
handleScroll
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// #endregion ➤ 🛠️ METHODS
|
|
225
|
+
|
|
226
|
+
// #region ➤ 🔄 LIFECYCLE [SVELTE]
|
|
227
|
+
|
|
228
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
229
|
+
// │ NOTE: │
|
|
230
|
+
// │ Please add inside 'this' region the 'logic' that should run │
|
|
231
|
+
// │ immediately and as part of the 'lifecycle' of svelteJs, │
|
|
232
|
+
// │ as soon as 'this' .svelte file is ran. │
|
|
233
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
234
|
+
|
|
235
|
+
onMount
|
|
236
|
+
(
|
|
237
|
+
() =>
|
|
238
|
+
{
|
|
239
|
+
injectBetarenaInterscrollerAd();
|
|
240
|
+
|
|
241
|
+
storeAdmin.updateData
|
|
242
|
+
(
|
|
243
|
+
[
|
|
244
|
+
['numberOfAdvertsActive', null]
|
|
245
|
+
]
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
// #endregion ➤ 🔄 LIFECYCLE [SVELTE]
|
|
253
|
+
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<!--
|
|
257
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
258
|
+
│ 💠 Svelte Component HTML │
|
|
259
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
260
|
+
│ ➤ HINT: │ Use 'Ctrl + Space' to autocomplete global class=styles, dynamically │
|
|
261
|
+
│ │ imported from './static/app.css' │
|
|
262
|
+
│ ➤ HINT: │ access custom Betarena Scores VScode Snippets by typing emmet-like │
|
|
263
|
+
│ │ abbrev. │
|
|
264
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
265
|
+
-->
|
|
266
|
+
|
|
267
|
+
<div
|
|
268
|
+
id="inter-outer"
|
|
269
|
+
bind:this={instanceAdvertInterscroller}
|
|
270
|
+
class="interscroller-wrapper"
|
|
271
|
+
style=
|
|
272
|
+
"
|
|
273
|
+
display: none;
|
|
274
|
+
height: 100vh;
|
|
275
|
+
right: 0px;
|
|
276
|
+
width: 100vw;
|
|
277
|
+
"
|
|
278
|
+
>
|
|
279
|
+
<h2 class="info-box">
|
|
280
|
+
Advertisement
|
|
281
|
+
</h2>
|
|
282
|
+
|
|
283
|
+
<div
|
|
284
|
+
id="intscdiv"
|
|
285
|
+
class="interscroller-bg-wrapper"
|
|
286
|
+
style="height: 100%; right: 0px; clip: rect(0px 100vw 100vh 0px); width: 100vw;"
|
|
287
|
+
>
|
|
288
|
+
<div
|
|
289
|
+
id="nxtads"
|
|
290
|
+
class=
|
|
291
|
+
"
|
|
292
|
+
interscroller-bg
|
|
293
|
+
"
|
|
294
|
+
style=
|
|
295
|
+
"
|
|
296
|
+
height: 100%;
|
|
297
|
+
width: 100%;
|
|
298
|
+
padding: 0px;
|
|
299
|
+
overflow: hidden;
|
|
300
|
+
text-align: center;
|
|
301
|
+
"
|
|
302
|
+
>
|
|
303
|
+
<div
|
|
304
|
+
style=
|
|
305
|
+
"
|
|
306
|
+
margin: 0px auto;
|
|
307
|
+
width: 100%;
|
|
308
|
+
height: 100%;
|
|
309
|
+
"
|
|
310
|
+
>
|
|
311
|
+
<a
|
|
312
|
+
target="_blank"
|
|
313
|
+
on:click=
|
|
314
|
+
{
|
|
315
|
+
() =>
|
|
316
|
+
{
|
|
317
|
+
postMod
|
|
318
|
+
(
|
|
319
|
+
`${betarenaEndpoint}/ad/update/click`,
|
|
320
|
+
{
|
|
321
|
+
creativeId: objectAdverData.id
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
href={objectAdverData.data?.cta_link}
|
|
327
|
+
>
|
|
328
|
+
<img
|
|
329
|
+
alt="ad_image"
|
|
330
|
+
class="ad_image"
|
|
331
|
+
src={objectAdverData.data?.media}
|
|
332
|
+
width="100%"
|
|
333
|
+
height="100%"
|
|
334
|
+
/>
|
|
335
|
+
</a>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<h2 class="info-box">
|
|
341
|
+
Scroll to continue
|
|
342
|
+
</h2>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
<!--
|
|
346
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
347
|
+
│ 🌊 Svelte Component CSS/SCSS │
|
|
348
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
349
|
+
│ ➤ HINT: │ auto-fill/auto-complete iniside <style> for var() │
|
|
350
|
+
│ │ values by typing/CTRL+SPACE │
|
|
351
|
+
│ ➤ HINT: │ access custom Betarena Scores CSS VScode Snippets by typing 'style...' │
|
|
352
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
353
|
+
-->
|
|
354
|
+
|
|
355
|
+
<style lang="scss">
|
|
356
|
+
|
|
357
|
+
/*
|
|
358
|
+
╭──────────────────────────────────────────────────────────────────────────────╮
|
|
359
|
+
│ 📲 MOBILE-FIRST │
|
|
360
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
.info-box
|
|
364
|
+
{
|
|
365
|
+
color: var(--colors-text-text-primary-900, #fbfbfb);
|
|
366
|
+
text-align: center;
|
|
367
|
+
font-family: Roboto;
|
|
368
|
+
font-size: 12px !important;
|
|
369
|
+
font-style: normal;
|
|
370
|
+
font-weight: 700 !important;
|
|
371
|
+
line-height: 38px !important; /* 190% */
|
|
372
|
+
text-transform: uppercase;
|
|
373
|
+
width: 100%;
|
|
374
|
+
margin: 0 !important;
|
|
375
|
+
z-index: 1;
|
|
376
|
+
background: var(--colors-background-bg-primary-solid, #313131);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.interscroller-wrapper
|
|
380
|
+
{
|
|
381
|
+
position: relative !important;
|
|
382
|
+
cursor: pointer !important;
|
|
383
|
+
background: #ffffff !important;
|
|
384
|
+
z-index: 10000000 !important;
|
|
385
|
+
flex-direction: column;
|
|
386
|
+
justify-content: space-between;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.interscroller-bg-wrapper
|
|
390
|
+
{
|
|
391
|
+
position: absolute !important;
|
|
392
|
+
width: 100% !important;
|
|
393
|
+
left: 0 !important;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.interscroller-bg
|
|
397
|
+
{
|
|
398
|
+
position: fixed !important;
|
|
399
|
+
height: 100% !important;
|
|
400
|
+
top: 0;
|
|
401
|
+
backface-visibility: hidden !important;
|
|
402
|
+
-webkit-backface-visibility: hidden !important;
|
|
403
|
+
border: 0 !important;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.ad_image
|
|
407
|
+
{
|
|
408
|
+
width: 100% !important;
|
|
409
|
+
height: 100% !important;
|
|
410
|
+
max-width: 100% !important;
|
|
411
|
+
max-height: 100% !important;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/*
|
|
415
|
+
╭──────────────────────────────────────────────────────────────────────────────╮
|
|
416
|
+
│ ⚡️ RESPONSIVNESS │
|
|
417
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
@media (min-width: 768px)
|
|
421
|
+
{
|
|
422
|
+
.info-box
|
|
423
|
+
{
|
|
424
|
+
font-size: 20px !important;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
</style>
|
package/src/lib/_store.ts
CHANGED
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// ╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
2
|
+
// │ 📌 High Order Overview │
|
|
3
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
4
|
+
// │ ➤ Code Format // V.8.0 │
|
|
5
|
+
// │ ➤ Status // 🔒 LOCKED │
|
|
6
|
+
// │ ➤ Author(s) // @migbash │
|
|
7
|
+
// │ ➤ Maintainer(s) // @migbash │
|
|
8
|
+
// │ ➤ Created on // 05-12-2024 │
|
|
9
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
10
|
+
// │ 📝 Description │
|
|
11
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
12
|
+
// │ BETARENA (Module)
|
|
13
|
+
// │ |: Debug Logic
|
|
14
|
+
// ╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
15
|
+
|
|
16
|
+
/* eslint-disable new-cap */
|
|
17
|
+
|
|
18
|
+
// #region 📦 Package]
|
|
19
|
+
|
|
20
|
+
import chalk from 'chalk';
|
|
21
|
+
|
|
22
|
+
// #endregion ➤ 📦 Package Imports
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @author
|
|
26
|
+
* @migbash
|
|
27
|
+
* @summary
|
|
28
|
+
* [🐞]
|
|
29
|
+
* @description
|
|
30
|
+
* 📝 Custom `console.log(..)` wrapper for general logging.
|
|
31
|
+
* @param { string[] } listMsg
|
|
32
|
+
* 💠 **[required]** The message.
|
|
33
|
+
* @return { void }
|
|
34
|
+
*/
|
|
35
|
+
export function logger
|
|
36
|
+
(
|
|
37
|
+
listMsg: string[]
|
|
38
|
+
): void
|
|
39
|
+
{
|
|
40
|
+
// [🐞]
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log(chalk.hex('#FF7F50')('📦 [ad-engine] :: ─────────────────────────'));
|
|
43
|
+
for (const message of listMsg)
|
|
44
|
+
// [🐞]
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.log(chalk.hex('#FF7F50')(`📦 [ad-engine] :: ${message}`));
|
|
47
|
+
;
|
|
48
|
+
return;
|
|
49
|
+
}
|
package/src/lib/utils/device.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
// ╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
2
|
+
// │ 📌 High Order Overview │
|
|
3
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
4
|
+
// │ ➤ Code Format // V.8.0 │
|
|
5
|
+
// │ ➤ Status // 🔒 LOCKED │
|
|
6
|
+
// │ ➤ Author(s) // @migbash │
|
|
7
|
+
// │ ➤ Maintainer(s) // @migbash │
|
|
8
|
+
// │ ➤ Created on // <date-created> │
|
|
9
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
10
|
+
// │ 📝 Description │
|
|
11
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
12
|
+
// │ BETARENA (Module)
|
|
13
|
+
// │ |: Device Logic
|
|
14
|
+
// ╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
15
|
+
|
|
16
|
+
// #region ➤ 📦 Package Imports
|
|
17
|
+
|
|
18
|
+
import { logger } from './debug.js';
|
|
19
|
+
|
|
20
|
+
// #endregion ➤ 📦 Package Imports
|
|
21
|
+
|
|
1
22
|
/**
|
|
2
23
|
* @author
|
|
3
24
|
* @migbash
|
|
@@ -27,11 +48,30 @@ export function detectDeviceType
|
|
|
27
48
|
isUserAgentTablet = /tablet|ipad/.test(userAgentObject)
|
|
28
49
|
;
|
|
29
50
|
|
|
51
|
+
let
|
|
52
|
+
/**
|
|
53
|
+
* @description
|
|
54
|
+
* 📝 Type of device
|
|
55
|
+
*/
|
|
56
|
+
strDeviceType = 'desktop'
|
|
57
|
+
;
|
|
58
|
+
|
|
30
59
|
if (isUserAgentMobile)
|
|
31
|
-
|
|
60
|
+
strDeviceType = 'mobile';
|
|
32
61
|
else if (isUserAgentTablet)
|
|
33
|
-
|
|
62
|
+
strDeviceType = 'tablet';
|
|
34
63
|
else
|
|
35
|
-
|
|
64
|
+
strDeviceType = 'desktop';
|
|
36
65
|
;
|
|
66
|
+
|
|
67
|
+
// [🐞]
|
|
68
|
+
logger
|
|
69
|
+
(
|
|
70
|
+
[
|
|
71
|
+
`🔹 [var] ➤ strDeviceType ${JSON.stringify(strDeviceType)}`,
|
|
72
|
+
'🚏 checkpoint ➤ detectDeviceType(..) // END'
|
|
73
|
+
]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return strDeviceType;
|
|
37
77
|
}
|