@betarena/ad-engine 0.0.59 → 0.0.61
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.61",
|
|
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,9 +291,9 @@
|
|
|
283
291
|
<div
|
|
284
292
|
style=
|
|
285
293
|
"
|
|
286
|
-
background: url({objectAdverData.data?.media});
|
|
287
294
|
height: 100vh;
|
|
288
295
|
width: 100vw;
|
|
296
|
+
background: url({objectAdverData.data?.media});
|
|
289
297
|
background-repeat: no-repeat;
|
|
290
298
|
background-size: contain;
|
|
291
299
|
"
|
|
@@ -317,59 +325,67 @@
|
|
|
317
325
|
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
318
326
|
*/
|
|
319
327
|
|
|
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
328
|
.interscroller-wrapper
|
|
337
329
|
{
|
|
330
|
+
/* 📌 position */
|
|
338
331
|
position: relative !important;
|
|
339
332
|
cursor: pointer !important;
|
|
340
|
-
background: #ffffff !important;
|
|
341
333
|
z-index: 10000000 !important;
|
|
334
|
+
/* 🛝 layout */
|
|
342
335
|
flex-direction: column;
|
|
343
336
|
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
337
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
338
|
+
.info-box
|
|
339
|
+
{
|
|
340
|
+
/* 📌 position */
|
|
341
|
+
z-index: 1;
|
|
342
|
+
/* 🎨 style */
|
|
343
|
+
color: var(--colors-text-text-primary-900, #fbfbfb);
|
|
344
|
+
text-align: center;
|
|
345
|
+
font-family: Roboto;
|
|
346
|
+
font-size: 12px !important;
|
|
347
|
+
font-style: normal;
|
|
348
|
+
font-weight: 700 !important;
|
|
349
|
+
line-height: 38px !important; /* 190% */
|
|
350
|
+
text-transform: uppercase;
|
|
351
|
+
width: 100%;
|
|
352
|
+
margin: 0 !important;
|
|
353
|
+
background: var(--colors-background-bg-secondary, #313131);
|
|
354
|
+
}
|
|
362
355
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
356
|
+
.interscroller-bg-wrapper
|
|
357
|
+
{
|
|
358
|
+
/* 📌 position */
|
|
359
|
+
position: absolute !important;
|
|
360
|
+
left: 0 !important;
|
|
361
|
+
/* 🎨 style */
|
|
362
|
+
width: 100% !important;
|
|
363
|
+
|
|
364
|
+
.interscroller-bg
|
|
365
|
+
{
|
|
366
|
+
/* 📌 position */
|
|
367
|
+
position: fixed !important;
|
|
368
|
+
top: 30px;
|
|
369
|
+
/* 🎨 style */
|
|
370
|
+
height: 100% !important;
|
|
371
|
+
backface-visibility: hidden !important;
|
|
372
|
+
-webkit-backface-visibility: hidden !important;
|
|
373
|
+
border: 0 !important;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.ad_image
|
|
377
|
+
{
|
|
378
|
+
/* 🎨 style */
|
|
379
|
+
width: 100% !important;
|
|
380
|
+
height: 100% !important;
|
|
381
|
+
max-width: 100vw !important;
|
|
382
|
+
max-height: 100% !important;
|
|
383
|
+
touch-action: manipulation;
|
|
384
|
+
user-select: none;
|
|
385
|
+
-webkit-user-drag: none;
|
|
386
|
+
-webkit-touch-callout: none;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
373
389
|
}
|
|
374
390
|
|
|
375
391
|
/*
|
|
@@ -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
|
+
}
|