@betarena/ad-engine 0.0.59 → 0.0.60
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betarena/ad-engine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Betarena ad-engine widget",
|
|
6
6
|
"keywords": [
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"eslint": "8.51.0",
|
|
54
54
|
"eslint-config-prettier": "8.8.0",
|
|
55
55
|
"eslint-plugin-svelte": "2.34.0",
|
|
56
|
-
"json5": "2.2.3",
|
|
57
56
|
"sass": "1.72.0",
|
|
58
57
|
"svelte": "4.2.12",
|
|
59
58
|
"svelte-check": "3.6.6",
|
|
@@ -64,6 +63,7 @@
|
|
|
64
63
|
"dependencies": {
|
|
65
64
|
"@betarena/scores-lib": "1.11.0-alpha.17",
|
|
66
65
|
"@fontsource/roboto": "5.0.12",
|
|
66
|
+
"colorthief": "2.6.0",
|
|
67
67
|
"svelte-preprocess": "5.1.3"
|
|
68
68
|
},
|
|
69
69
|
"main": "./dist/index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
import { betarenaEndpoint } from './constants/instance.js';
|
|
44
44
|
import { storeAdmin } from './store/admin.js';
|
|
45
45
|
import { postMod } from './utils/fetch.js';
|
|
46
|
+
import { getImageBgColor } from './utils/npm.colorthief.js';
|
|
46
47
|
|
|
47
48
|
import type { AdsCreativeMain } from '@betarena/scores-lib/types/_AUTO-HASURA_.js';
|
|
48
49
|
|
|
@@ -198,6 +199,12 @@
|
|
|
198
199
|
(
|
|
199
200
|
() =>
|
|
200
201
|
{
|
|
202
|
+
getImageBgColor
|
|
203
|
+
(
|
|
204
|
+
objectAdverData.data?.media ?? '',
|
|
205
|
+
'--betarena-ad-engine-interscroller-advert-background-image-'
|
|
206
|
+
);
|
|
207
|
+
|
|
201
208
|
injectBetarenaInterscrollerAd();
|
|
202
209
|
|
|
203
210
|
storeAdmin.updateData
|
|
@@ -237,6 +244,7 @@
|
|
|
237
244
|
right: 0px;
|
|
238
245
|
width: 100vw;
|
|
239
246
|
max-width: 100vw;
|
|
247
|
+
background-color: var(--betarena-ad-engine-interscroller-advert-background-image-);
|
|
240
248
|
"
|
|
241
249
|
>
|
|
242
250
|
<h2 class="info-box">
|
|
@@ -283,7 +291,6 @@
|
|
|
283
291
|
<div
|
|
284
292
|
style=
|
|
285
293
|
"
|
|
286
|
-
background: url({objectAdverData.data?.media});
|
|
287
294
|
height: 100vh;
|
|
288
295
|
width: 100vw;
|
|
289
296
|
background-repeat: no-repeat;
|
|
@@ -317,59 +324,67 @@
|
|
|
317
324
|
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
318
325
|
*/
|
|
319
326
|
|
|
320
|
-
.info-box
|
|
321
|
-
{
|
|
322
|
-
color: var(--colors-text-text-primary-900, #fbfbfb);
|
|
323
|
-
text-align: center;
|
|
324
|
-
font-family: Roboto;
|
|
325
|
-
font-size: 12px !important;
|
|
326
|
-
font-style: normal;
|
|
327
|
-
font-weight: 700 !important;
|
|
328
|
-
line-height: 38px !important; /* 190% */
|
|
329
|
-
text-transform: uppercase;
|
|
330
|
-
width: 100%;
|
|
331
|
-
margin: 0 !important;
|
|
332
|
-
z-index: 1;
|
|
333
|
-
background: var(--colors-background-bg-secondary, #313131);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
327
|
.interscroller-wrapper
|
|
337
328
|
{
|
|
329
|
+
/* 📌 position */
|
|
338
330
|
position: relative !important;
|
|
339
331
|
cursor: pointer !important;
|
|
340
|
-
background: #ffffff !important;
|
|
341
332
|
z-index: 10000000 !important;
|
|
333
|
+
/* 🛝 layout */
|
|
342
334
|
flex-direction: column;
|
|
343
335
|
justify-content: space-between;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.interscroller-bg-wrapper
|
|
347
|
-
{
|
|
348
|
-
position: absolute !important;
|
|
349
|
-
width: 100% !important;
|
|
350
|
-
left: 0 !important;
|
|
351
|
-
}
|
|
352
336
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
337
|
+
.info-box
|
|
338
|
+
{
|
|
339
|
+
/* 📌 position */
|
|
340
|
+
z-index: 1;
|
|
341
|
+
/* 🎨 style */
|
|
342
|
+
color: var(--colors-text-text-primary-900, #fbfbfb);
|
|
343
|
+
text-align: center;
|
|
344
|
+
font-family: Roboto;
|
|
345
|
+
font-size: 12px !important;
|
|
346
|
+
font-style: normal;
|
|
347
|
+
font-weight: 700 !important;
|
|
348
|
+
line-height: 38px !important; /* 190% */
|
|
349
|
+
text-transform: uppercase;
|
|
350
|
+
width: 100%;
|
|
351
|
+
margin: 0 !important;
|
|
352
|
+
background: var(--colors-background-bg-secondary, #313131);
|
|
353
|
+
}
|
|
362
354
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
355
|
+
.interscroller-bg-wrapper
|
|
356
|
+
{
|
|
357
|
+
/* 📌 position */
|
|
358
|
+
position: absolute !important;
|
|
359
|
+
left: 0 !important;
|
|
360
|
+
/* 🎨 style */
|
|
361
|
+
width: 100% !important;
|
|
362
|
+
|
|
363
|
+
.interscroller-bg
|
|
364
|
+
{
|
|
365
|
+
/* 📌 position */
|
|
366
|
+
position: fixed !important;
|
|
367
|
+
top: 30px;
|
|
368
|
+
/* 🎨 style */
|
|
369
|
+
height: 100% !important;
|
|
370
|
+
backface-visibility: hidden !important;
|
|
371
|
+
-webkit-backface-visibility: hidden !important;
|
|
372
|
+
border: 0 !important;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.ad_image
|
|
376
|
+
{
|
|
377
|
+
/* 🎨 style */
|
|
378
|
+
width: 100% !important;
|
|
379
|
+
height: 100% !important;
|
|
380
|
+
max-width: 100vw !important;
|
|
381
|
+
max-height: 100% !important;
|
|
382
|
+
touch-action: manipulation;
|
|
383
|
+
user-select: none;
|
|
384
|
+
-webkit-user-drag: none;
|
|
385
|
+
-webkit-touch-callout: none;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
373
388
|
}
|
|
374
389
|
|
|
375
390
|
/*
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// ╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
2
|
+
// │ 📌 High Order Component Overview │
|
|
3
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
4
|
+
// │ ➤ Internal Svelte Code Format :|: V.8.0 │
|
|
5
|
+
// │ ➤ Status :|: 🔒 LOCKED │
|
|
6
|
+
// │ ➤ Author(s) :|: @migbash │
|
|
7
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
8
|
+
// │ 📝 Description │
|
|
9
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
10
|
+
// │ Main Scores Color Thief Logic │
|
|
11
|
+
// ╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
12
|
+
|
|
13
|
+
// #region ➤ 📦 Package Imports
|
|
14
|
+
|
|
15
|
+
// @ts-expect-error :: 📌 Importing the colorthief package for Types Is missing.
|
|
16
|
+
import ColorThief from 'colorthief/dist/color-thief.mjs';
|
|
17
|
+
|
|
18
|
+
// #endregion ➤ 📦 Package Imports
|
|
19
|
+
|
|
20
|
+
const colorThief = new ColorThief();
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @author
|
|
24
|
+
* @migbash
|
|
25
|
+
* @summary
|
|
26
|
+
* 🟦 HELPER
|
|
27
|
+
* @description
|
|
28
|
+
* 📝 Convert RGB to Hexidecimal
|
|
29
|
+
* @param { number } r
|
|
30
|
+
* ❗️ **REQUIRED** : Red Value
|
|
31
|
+
* @param { number } g
|
|
32
|
+
* ❗️ **REQUIRED** : Green Value
|
|
33
|
+
* @param { number } b
|
|
34
|
+
* ❗️ **REQUIRED** : Blue Value
|
|
35
|
+
* @return { string }
|
|
36
|
+
* 📤 Hexidecimal Value for target RGB input.
|
|
37
|
+
*/
|
|
38
|
+
export const rgbToHex = (
|
|
39
|
+
r: number,
|
|
40
|
+
g: number,
|
|
41
|
+
b: number
|
|
42
|
+
): string =>
|
|
43
|
+
{
|
|
44
|
+
return '#' + [r, g, b]
|
|
45
|
+
.map
|
|
46
|
+
(
|
|
47
|
+
(
|
|
48
|
+
x
|
|
49
|
+
) =>
|
|
50
|
+
{
|
|
51
|
+
const
|
|
52
|
+
/**
|
|
53
|
+
* @description
|
|
54
|
+
* 📝 Convert the number to HEX
|
|
55
|
+
*/
|
|
56
|
+
hex = x.toString(16)
|
|
57
|
+
;
|
|
58
|
+
return hex.length === 1
|
|
59
|
+
? `0${hex}`
|
|
60
|
+
: hex
|
|
61
|
+
;
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
.join('')
|
|
65
|
+
;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @author
|
|
70
|
+
* @migbash
|
|
71
|
+
* @summary
|
|
72
|
+
* 🟦 HELPER
|
|
73
|
+
* @description
|
|
74
|
+
* 📝 Get the image background color
|
|
75
|
+
* @param { string } strImageUrl
|
|
76
|
+
* ❗️ **REQUIRED** : The image URL
|
|
77
|
+
* @param { string } strImageColorVariable
|
|
78
|
+
* ❗️ **REQUIRED** : The image variable
|
|
79
|
+
* @return { void }
|
|
80
|
+
*/
|
|
81
|
+
export function getImageBgColor
|
|
82
|
+
(
|
|
83
|
+
strImageUrl: string,
|
|
84
|
+
strImageColorVariable: string
|
|
85
|
+
): void
|
|
86
|
+
{
|
|
87
|
+
if (!strImageUrl) return;
|
|
88
|
+
|
|
89
|
+
try
|
|
90
|
+
{
|
|
91
|
+
const
|
|
92
|
+
/**
|
|
93
|
+
* @description
|
|
94
|
+
* 📝 Create a new image instance
|
|
95
|
+
*/
|
|
96
|
+
img = new Image()
|
|
97
|
+
;
|
|
98
|
+
|
|
99
|
+
// ╭─────
|
|
100
|
+
// │ NOTE:
|
|
101
|
+
// │ |: Listen, event to wait for the image to load
|
|
102
|
+
// ╰─────
|
|
103
|
+
img.addEventListener
|
|
104
|
+
(
|
|
105
|
+
'load',
|
|
106
|
+
() =>
|
|
107
|
+
{
|
|
108
|
+
const
|
|
109
|
+
/**
|
|
110
|
+
* @description
|
|
111
|
+
* 📝 Get the color values from the image
|
|
112
|
+
*/
|
|
113
|
+
colorValues
|
|
114
|
+
= colorThief.getColor(img) as [number, number, number],
|
|
115
|
+
/**
|
|
116
|
+
* @description
|
|
117
|
+
* 📝 Convert the color values to HEX
|
|
118
|
+
*/
|
|
119
|
+
hexColor
|
|
120
|
+
= rgbToHex
|
|
121
|
+
(
|
|
122
|
+
colorValues[0],
|
|
123
|
+
colorValues[1],
|
|
124
|
+
colorValues[2]
|
|
125
|
+
),
|
|
126
|
+
/**
|
|
127
|
+
* @description
|
|
128
|
+
* 📝 Pass this values as a `CSS :root` variable, accessible to all the website,
|
|
129
|
+
*/
|
|
130
|
+
doc = document.documentElement
|
|
131
|
+
;
|
|
132
|
+
|
|
133
|
+
doc.style.setProperty
|
|
134
|
+
(
|
|
135
|
+
strImageColorVariable,
|
|
136
|
+
hexColor
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const
|
|
142
|
+
// [ℹ] declaring the image paramaters & CORS by-pass
|
|
143
|
+
imageURL = 'https://corsproxy.io/?' + encodeURIComponent(strImageUrl)
|
|
144
|
+
;
|
|
145
|
+
|
|
146
|
+
img.crossOrigin = 'anonymous';
|
|
147
|
+
img.src = imageURL;
|
|
148
|
+
}
|
|
149
|
+
catch (e)
|
|
150
|
+
{
|
|
151
|
+
// eslint-disable-next-line no-console
|
|
152
|
+
console.error
|
|
153
|
+
(
|
|
154
|
+
'-- getImageBgColor() ERR --',
|
|
155
|
+
e
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return;
|
|
160
|
+
}
|