@betarena/ad-engine 0.0.23 → 0.0.24

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.23",
3
+ "version": "0.0.24",
4
4
  "private": false,
5
5
  "description": "Betarena ad-engine widget",
6
6
  "keywords": [
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "scripts": {
33
33
  "build": "vite build",
34
- "start": "vite build",
35
- "vite|:|dev": "vite",
36
- "vite|:|dev|:|1-click": "npm run 'npm|:|link|:|@betarena/scores-lib' && npm ls --link --global & npm run 'vite|:|dev'",
34
+ "start": "node dist/index.js",
35
+ "vite|:|dev": "vite --host",
36
+ "vite|:|dev|:|1-click": "npm run 'npm|:|link|:|@betarena/scores-lib' && npm ls --link --global & npm run 'sass|:|watch' & npm run 'vite|:|dev'",
37
37
  "vite|:|preview": "vite preview",
38
38
  "svelte-check": "svelte-check --tsconfig ./tsconfig.json",
39
39
  "run|:|script-package": "npx tsx misc/package.ts",
@@ -41,27 +41,28 @@
41
41
  "npm|:|link|:|@betarena/scores-lib": "npm link @betarena/scores-lib",
42
42
  "npm|:|link": "npm link",
43
43
  "npm|:|bump+publish": "npm version patch && npm publish",
44
- "sass|:|watch": "sass --watch static/app.scss static/app.css"
44
+ "sass|:|watch": "sass --watch src/style/app.scss src/style/app.css"
45
45
  },
46
46
  "devDependencies": {
47
+ "@sveltejs/vite-plugin-svelte": "3.0.2",
48
+ "@tsconfig/svelte": "5.0.2",
47
49
  "@typescript-eslint/eslint-plugin": "5.59.1",
48
50
  "@typescript-eslint/parser": "5.59.1",
49
51
  "eslint": "8.51.0",
50
52
  "eslint-config-prettier": "8.8.0",
51
53
  "eslint-plugin-svelte": "2.34.0",
52
- "@sveltejs/vite-plugin-svelte": "3.0.2",
53
- "@tsconfig/svelte": "5.0.2",
54
+ "json5": "2.2.3",
55
+ "sass": "1.72.0",
54
56
  "svelte": "4.2.12",
55
- "typescript": "5.2.2",
56
- "tslib": "2.6.2",
57
- "vite": "5.1.6",
58
57
  "svelte-check": "3.6.6",
59
- "json5": "2.2.3",
60
- "sass": "1.72.0"
58
+ "tslib": "2.6.2",
59
+ "typescript": "5.2.2",
60
+ "vite": "5.1.6"
61
61
  },
62
62
  "dependencies": {
63
63
  "@betarena/scores-lib": "1.11.0-alpha.15",
64
- "@fontsource/roboto": "5.0.12"
64
+ "@fontsource/roboto": "5.0.12",
65
+ "svelte-preprocess": "5.1.3"
65
66
  },
66
67
  "main": "./dist/index.js",
67
68
  "svelte": "./src/index.js",
package/src/App.svelte ADDED
@@ -0,0 +1,44 @@
1
+ <!--
2
+ ╭──────────────────────────────────────────────────────────────────────────────────╮
3
+ │ 🟦 Svelte Component JS/TS │
4
+ ┣──────────────────────────────────────────────────────────────────────────────────┫
5
+ │ ➤ HINT: │ Access snippets for '<script> [..] </script>' those found in │
6
+ │ │ '.vscode/snippets.code-snippets' via intellisense using 'doc' │
7
+ ╰──────────────────────────────────────────────────────────────────────────────────╯
8
+ -->
9
+
10
+ <script lang="ts">
11
+
12
+ // #region ➤ 📦 Package Imports
13
+
14
+ // ╭────────────────────────────────────────────────────────────────────────╮
15
+ // │ NOTE: │
16
+ // │ Please add inside 'this' region the 'imports' that are required │
17
+ // │ by 'this' .svelte file is ran. │
18
+ // │ IMPORTANT │
19
+ // │ Please, structure the imports as follows: │
20
+ // │ 1. svelte/sveltekit imports │
21
+ // │ 2. project-internal files and logic │
22
+ // │ 3. component import(s) │
23
+ // │ 4. assets import(s) │
24
+ // │ 5. type(s) imports(s) │
25
+ // ╰────────────────────────────────────────────────────────────────────────╯
26
+
27
+ import AdvertEngineWidget from "./lib/Advert-Engine-Widget.svelte";
28
+
29
+ // #endregion ➤ 📦 Package Imports
30
+
31
+ </script>
32
+
33
+ <!--
34
+ ╭──────────────────────────────────────────────────────────────────────────────────╮
35
+ │ 💠 Svelte Component HTML │
36
+ ┣──────────────────────────────────────────────────────────────────────────────────┫
37
+ │ ➤ HINT: │ Use 'Ctrl + Space' to autocomplete global class=styles, dynamically │
38
+ │ │ imported from './static/app.css' │
39
+ │ ➤ HINT: │ access custom Betarena Scores VScode Snippets by typing emmet-like │
40
+ │ │ abbrev. │
41
+ ╰──────────────────────────────────────────────────────────────────────────────────╯
42
+ -->
43
+
44
+ <AdvertEngineWidget />
package/src/index.ts ADDED
@@ -0,0 +1,29 @@
1
+ import AdvertEngineWidget from './lib/Advert-Engine-Widget.svelte'
2
+
3
+ let
4
+ /**
5
+ * @description
6
+ */
7
+ app
8
+ ;
9
+
10
+ // ╭─────
11
+ // │ CHECK |:| running on 'browser'
12
+ // ╰─────
13
+ if (typeof document !== 'undefined')
14
+ app
15
+ = new AdvertEngineWidget
16
+ (
17
+ {
18
+ target: document.body,
19
+ props:
20
+ {
21
+ // authorId: 1
22
+ authorArticleTagIds: [1]
23
+ }
24
+ }
25
+ )
26
+ ;
27
+ ;
28
+
29
+ export default app;
@@ -8,7 +8,7 @@
8
8
  ┣──────────────────────────────────────────────────────────────────────────────────┫
9
9
  │ 📝 Description │
10
10
  ┣──────────────────────────────────────────────────────────────────────────────────┫
11
- │ Betarena Ad-Engine Component
11
+ │ Betarena Ad-Engine Component (Entrypoint)
12
12
  ╰──────────────────────────────────────────────────────────────────────────────────╯
13
13
  -->
14
14
 
@@ -40,6 +40,8 @@
40
40
 
41
41
  import { onMount } from 'svelte';
42
42
 
43
+ import '@fontsource/roboto';
44
+
43
45
  import { betarenaEndpoint } from './constants/instance.js';
44
46
  import { betarenaAdEngineStore } from './_store.js';
45
47
  import { postMod } from './utils/fetch.js';
@@ -50,11 +52,12 @@
50
52
  import WidgetAdvertSlide from './Advert-Slide-Child.svelte';
51
53
  import WidgetAdGeneral from './Advert-General-Child.svelte';
52
54
 
53
- import '@fontsource/roboto';
55
+ import '../style/app.scss';
54
56
 
55
- // import type { IAdsRequestBody, IAdsResponseBody } from '@betarena/scores-lib/types/ad-engine/index.js';
56
- // import type { GeoJsResponse } from './types/geojs.js';
57
- // import type { AdsCreativeMain } from '@betarena/scores-lib/types/_AUTO-HASURA_.js';
57
+ import type { IAdsRequestBody, IAdsResponseBody } from '@betarena/scores-lib/types/ad-engine/index.js';
58
+ import type { GeoJsResponse } from './types/geojs.js';
59
+ import type { AdsCreativeMain } from '@betarena/scores-lib/types/_AUTO-HASURA_.js';
60
+ import DevInfoBox from './misc/admin/Dev-Info-Box.svelte';
58
61
 
59
62
  // #endregion ➤ 📦 Package Imports
60
63
 
@@ -103,12 +106,12 @@
103
106
  let
104
107
  /**
105
108
  * @description
106
- * 📝 Device type detected
109
+ * 📝 device type detected
107
110
  */
108
111
  deviceType: IDeviceType = 'desktop',
109
112
  /**
110
113
  * @description
111
- * 📝 Geo-Location response
114
+ * 📝 geo-location response
112
115
  */
113
116
  geoLocation: GeoJsResponse | null = null,
114
117
  /**
@@ -481,30 +484,42 @@
481
484
  ╰──────────────────────────────────────────────────────────────────────────────────╯
482
485
  -->
483
486
 
484
- <!--
485
- ╭─────
486
- │ ➤ Testing [🐞]
487
- ╰─────
488
- -->
489
- <div>
490
- <p>
491
- Device Type: {deviceType}
492
- </p>
493
- <p>
494
- {geoLocation?.country_code}
495
- </p>
496
- </div>
497
-
498
- <!--
499
- <div
500
- data-betarena-zone-id=1
501
- >
502
- </div>
503
-
504
- <hr>
505
-
506
- <div
507
- data-betarena-zone-id=2
508
- >
509
- </div>
510
- -->
487
+ {#if import.meta.env.DEV}
488
+ <!--
489
+ ╭─────
490
+ │ [🐞]
491
+ │ ➤ Testing Configuration(s)
492
+ ╰─────
493
+ -->
494
+ <DevInfoBox>
495
+ <p>
496
+ Device Type :|: {deviceType}
497
+ </p>
498
+ <p>
499
+ Geo-Location :|: {geoLocation?.country_code}
500
+ </p>
501
+ <p>
502
+ Number of Adverts Detected :|: {betarenaAdsInjectMap.size}
503
+ </p>
504
+ </DevInfoBox>
505
+
506
+ <!--
507
+ ╭─────
508
+ │ [🐞]
509
+ │ ➤ Testing Advert(s)
510
+ ╰─────
511
+ -->
512
+ <!--
513
+ <div
514
+ data-betarena-zone-id=1
515
+ >
516
+ </div>
517
+
518
+ <hr>
519
+
520
+ <div
521
+ data-betarena-zone-id=2
522
+ >
523
+ </div>
524
+ -->
525
+ {/if}
@@ -8,7 +8,7 @@
8
8
  ┣──────────────────────────────────────────────────────────────────────────────────┫
9
9
  │ 📝 Description │
10
10
  ┣──────────────────────────────────────────────────────────────────────────────────┫
11
- │ Betarena Ad-Engine Component
11
+ │ Betarena Ad-Engine Component |:| Standard Advert (X1)
12
12
  ╰──────────────────────────────────────────────────────────────────────────────────╯
13
13
  -->
14
14
 
@@ -90,15 +90,6 @@
90
90
  ╰──────────────────────────────────────────────────────────────────────────────────╯
91
91
  -->
92
92
 
93
- <p
94
- style=
95
- "
96
- color: violet;
97
- "
98
- >
99
- General Advert Sample is Triggered
100
- </p>
101
-
102
93
  <div
103
94
  id={CNAME}
104
95
  in:fly={{ y: 500, duration: 500 }}
@@ -163,8 +154,12 @@
163
154
  <a
164
155
  href={adData.data?.cta_link}
165
156
  target="_blank"
166
- rel="noopener
167
- noreferrer">
157
+ rel=
158
+ "
159
+ noopener
160
+ noreferrer
161
+ "
162
+ >
168
163
  <button
169
164
  >
170
165
  {adData.data?.cta_title ?? 'Recieve Bonus'}
@@ -174,9 +169,9 @@
174
169
  alt='icon-arrow'
175
170
  title='icon-arrow'
176
171
  loading='lazy'
177
- style=
172
+ class=
178
173
  "
179
- margin-left: 10px;
174
+ m-l-10
180
175
  "
181
176
  />
182
177
  </button>
@@ -208,30 +203,9 @@
208
203
  {
209
204
  /* 🎨 style */
210
205
  overflow: hidden;
211
- border-radius: 40px 40px 0px 0px;
206
+ border-radius: 10px 10px 10px 10px;
212
207
  background-color: #383838;
213
208
 
214
- a
215
- {
216
- text-decoration: none !important;
217
- color: inherit;
218
- display: flex;
219
- }
220
-
221
- button
222
- {
223
- /* 🎨 style */
224
- outline: none !important;
225
- border: none !important;
226
- opacity: 1;
227
- cursor: pointer;
228
- transition: all 0.3s ease;
229
- align-items: center;
230
- white-space: nowrap;
231
- display: flex;
232
- justify-content: center;
233
- }
234
-
235
209
  p
236
210
  {
237
211
  /* 🎨 style */
@@ -257,19 +231,14 @@
257
231
  div#main-box
258
232
  {
259
233
  /* 🎨 style */
260
- text-align: center;
261
234
  padding: 20px 20px 35px 20px;
262
235
 
263
236
  p
264
237
  {
265
- /* 🎨 style */
266
- margin: 0;
267
- margin-bottom: 25px;
268
-
269
238
  &#title
270
239
  {
271
240
  /* 🎨 style */
272
- color: #FFFFFF;
241
+ color: var(--white);
273
242
  }
274
243
  }
275
244
 
@@ -281,7 +250,7 @@
281
250
  width: 100%;
282
251
  padding: 10px;
283
252
  background: radial-gradient(97.9% 290.93% at 11.52% 99.71%, #2E6514 0%, #66BE3C 100%) /* warning: gradient uses a rotation that is not supported by CSS and may not behave as expected */;
284
- color: #FFFFFF;
253
+ color: var(--white);
285
254
  }
286
255
  }
287
256
  }
@@ -8,7 +8,7 @@
8
8
  ┣──────────────────────────────────────────────────────────────────────────────────┫
9
9
  │ 📝 Description │
10
10
  ┣──────────────────────────────────────────────────────────────────────────────────┫
11
- │ Betarena Ad-Engine Component
11
+ │ Betarena Ad-Engine Component |:| Slider Advert (X1)
12
12
  ╰──────────────────────────────────────────────────────────────────────────────────╯
13
13
  -->
14
14
 
@@ -41,9 +41,11 @@
41
41
  import { onMount } from 'svelte';
42
42
  import { fly } from 'svelte/transition';
43
43
 
44
+ import { betarenaAdEngineStore } from './_store.js';
45
+ import { storeAdmin } from './store/admin.js';
46
+
44
47
  import iconClose from './assets/icon-close.svg';
45
48
  import iconArrow from './assets/icon-external-link.svg';
46
- import { betarenaAdEngineStore } from './_store.js';
47
49
 
48
50
  import type { AdsCreativeMain } from '@betarena/scores-lib/types/_AUTO-HASURA_.js';
49
51
 
@@ -75,19 +77,33 @@
75
77
  * @description
76
78
  * 📣 `this` component **main** `id` and `data-testid` prefix.
77
79
  */ // eslint-disable-next-line no-unused-vars
78
- CNAME = 'global⮕widget⮕betarenaAdEngine⮕main'
80
+ CNAME = 'global⮕widget⮕betarenaAdEngine⮕main',
81
+ /**
82
+ * @description
83
+ * 📝 number of `milliseconds` for advert show
84
+ * @example
85
+ * => 10000 (10 seconds)
86
+ */
87
+ timeoutForAdvertShow = 0, // 10000
88
+ /**
89
+ * @description
90
+ * 📝 number of `milliseconds` for advert close action show
91
+ * @example
92
+ * => 15000 (15 seconds)
93
+ */
94
+ timeoutForAdvertCloseAction = 0 // 15000
79
95
  ;
80
96
 
81
97
  let
82
98
  /**
83
99
  * @description
84
- * 📝
100
+ * 📝 wether advert can be shown
85
101
  */
86
102
  isAdvertShown: boolean = false,
87
103
  /**
88
104
  * @description
89
- * 📝
90
- */
105
+ * 📝 wether advert (close button) can be shown
106
+ */
91
107
  isAdvertCloseBtnShown: boolean = false
92
108
  ;
93
109
 
@@ -108,27 +124,42 @@
108
124
  (
109
125
  () =>
110
126
  {
111
- setTimeout
112
- (
113
- () =>
114
- {
115
- isAdvertShown = true;
116
- return;
117
- },
118
- // 10000
119
- 0
120
- );
121
-
122
- setTimeout
123
- (
124
- () =>
125
- {
126
- isAdvertCloseBtnShown = true;
127
- return;
128
- },
129
- // 15000
130
- 0
131
- );
127
+ if (!isBetarenaAdShownForToday)
128
+ {
129
+ // ╭─────
130
+ // │ NOTE: |:| Advert timeour start
131
+ // ╰─────
132
+ setTimeout
133
+ (
134
+ () =>
135
+ {
136
+ isAdvertShown = true;
137
+
138
+ // ╭─────
139
+ // │ NOTE: |:| Advert timeout (close action) start
140
+ // ╰─────
141
+ setTimeout
142
+ (
143
+ () =>
144
+ {
145
+ isAdvertCloseBtnShown = true;
146
+ return;
147
+ },
148
+ timeoutForAdvertCloseAction
149
+ );
150
+
151
+ return;
152
+ },
153
+ timeoutForAdvertShow
154
+ );
155
+
156
+ storeAdmin.updateData
157
+ (
158
+ [
159
+ ['numberOfAdvertsActive', null]
160
+ ]
161
+ );
162
+ }
132
163
 
133
164
  return;
134
165
  }
@@ -149,15 +180,6 @@
149
180
  ╰──────────────────────────────────────────────────────────────────────────────────╯
150
181
  -->
151
182
 
152
- <p
153
- style=
154
- "
155
- color: blueviolet;
156
- "
157
- >
158
- Global Advert Sample is Triggered
159
- </p>
160
-
161
183
  {#if isAdvertShown && !isBetarenaAdShownForToday}
162
184
  <div
163
185
  id={CNAME}
@@ -177,6 +199,10 @@
177
199
  alt='icon-close'
178
200
  title='icon-close'
179
201
  loading='lazy'
202
+ class=
203
+ "
204
+ cursor-pointer
205
+ "
180
206
  on:click=
181
207
  {
182
208
  () =>
@@ -199,18 +225,19 @@
199
225
  ╰─────
200
226
  -->
201
227
  {#if ((adData.type == 1 || adData.type == 4) && adData.data?.media)}
202
- <iframe
228
+ <!-- <iframe
203
229
  width=250
204
230
  height=250
205
231
  src={adData.data?.media}
206
- />
207
- <!--
232
+ /> -->
208
233
  <video
234
+ id="banner"
209
235
  width=250
210
236
  height=250
211
237
  src={adData.data?.media}
238
+ controls={false}
239
+ autoplay={true}
212
240
  />
213
- -->
214
241
 
215
242
  {:else if (adData.type == 2)}
216
243
  <img
@@ -239,8 +266,16 @@
239
266
  -->
240
267
  <p
241
268
  id="title"
269
+ class=
270
+ "
271
+ s-20
272
+ w-600
273
+ m-0
274
+ m-b-20
275
+ text-center
276
+ "
242
277
  >
243
- {adData.data?.title}
278
+ {@html adData.data?.title}
244
279
  </p>
245
280
 
246
281
  <!--
@@ -259,17 +294,27 @@
259
294
  >
260
295
  <button
261
296
  >
262
- {adData.data?.cta_title ?? 'Recieve Bonus'}
297
+ <span
298
+ class=
299
+ "
300
+ s-18
301
+ w-500
302
+ "
303
+ >
304
+ {adData.data?.cta_title ?? 'Recieve Bonus'}
305
+ </span>
263
306
  <img
264
307
  id=''
265
308
  src={iconArrow}
266
309
  alt='icon-arrow'
267
310
  title='icon-arrow'
268
311
  loading='lazy'
269
- style=
312
+ class=
270
313
  "
271
- margin-left: 10px;
314
+ m-l-10
272
315
  "
316
+ width="12"
317
+ height="12"
273
318
  />
274
319
  </button>
275
320
  </a>
@@ -308,27 +353,7 @@
308
353
  /* 🎨 style */
309
354
  overflow: hidden;
310
355
  border-radius: 40px 40px 0px 0px;
311
- background-color: #383838;
312
-
313
- button
314
- {
315
- /* 🎨 style */
316
- outline: none !important;
317
- border: none !important;
318
- opacity: 1;
319
- cursor: pointer;
320
- transition: all 0.3s ease;
321
- align-items: center;
322
- white-space: nowrap;
323
- display: flex;
324
- justify-content: center;
325
- }
326
-
327
- p
328
- {
329
- /* 🎨 style */
330
- font-family: "Roboto";
331
- }
356
+ background-color: var(--dark-theme-1-4-shade);
332
357
 
333
358
  img
334
359
  {
@@ -338,6 +363,7 @@
338
363
  position: absolute;
339
364
  top: 10px;
340
365
  right: 10px;
366
+ z-index: 1;
341
367
  }
342
368
 
343
369
  &#banner
@@ -352,24 +378,27 @@
352
378
  {
353
379
  /* 🎨 style */
354
380
  width: 100%;
381
+ object-fit: cover;
382
+ }
383
+
384
+ video
385
+ {
386
+ /* 🎨 style */
387
+ width: 100%;
388
+ object-fit: cover;
355
389
  }
356
390
 
357
391
  div#main-box
358
392
  {
359
393
  /* 🎨 style */
360
- text-align: center;
361
394
  padding: 20px 20px 35px 20px;
362
395
 
363
396
  p
364
397
  {
365
- /* 🎨 style */
366
- margin: 0;
367
- margin-bottom: 25px;
368
-
369
398
  &#title
370
399
  {
371
400
  /* 🎨 style */
372
- color: #FFFFFF;
401
+ color: var(--white);
373
402
  }
374
403
  }
375
404
 
@@ -381,7 +410,16 @@
381
410
  width: 100%;
382
411
  padding: 10px;
383
412
  background: radial-gradient(97.9% 290.93% at 11.52% 99.71%, #2E6514 0%, #66BE3C 100%) /* warning: gradient uses a rotation that is not supported by CSS and may not behave as expected */;
384
- color: #FFFFFF;
413
+ color: var(--white);
414
+ }
415
+ }
416
+
417
+ :global
418
+ {
419
+ span.custom-betarena-advert-x1
420
+ {
421
+ /* 🎨 style */
422
+ color: var(--primary) !important;
385
423
  }
386
424
  }
387
425
  }