@betarena/ad-engine 0.3.1 → 0.3.3
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/dist/index.js +14 -14
- package/package.json +2 -2
- package/src/lib/Advert-Engine-Widget.svelte +45 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betarena/ad-engine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Betarena ad-engine widget",
|
|
6
6
|
"keywords": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"vite": "5.1.6"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@betarena/scores-lib": "4.
|
|
91
|
+
"@betarena/scores-lib": "4.14.11",
|
|
92
92
|
"@fontsource/roboto": "5.0.12",
|
|
93
93
|
"chalk": "5.3.0",
|
|
94
94
|
"colorthief": "2.6.0",
|
|
@@ -106,7 +106,14 @@
|
|
|
106
106
|
* @description
|
|
107
107
|
* 📝 Condition for testing
|
|
108
108
|
*/
|
|
109
|
-
isStandalone = true
|
|
109
|
+
isStandalone = true,
|
|
110
|
+
/**
|
|
111
|
+
* @description
|
|
112
|
+
* 📝 Signal from the host that the current page is an article page.
|
|
113
|
+
* Zone 1 body-mounted ads (slider/popup) must only inject when this is `true`.
|
|
114
|
+
* Defaults to `false` so the widget fails closed on non-article pages.
|
|
115
|
+
*/
|
|
116
|
+
isArticlePage: boolean = false
|
|
110
117
|
;
|
|
111
118
|
|
|
112
119
|
// Retained as a supported public prop for API compatibility.
|
|
@@ -587,7 +594,7 @@
|
|
|
587
594
|
// │ |: (not from DOM-filtered targetZoneIds) so global placements inject correctly
|
|
588
595
|
// │ |: even when no zone-1 element exists in the DOM.
|
|
589
596
|
// ╰─────
|
|
590
|
-
if (includesGlobalZone && (authorId || authorArticleTagIds.length > 0))
|
|
597
|
+
if (includesGlobalZone && isArticlePage && (authorId || authorArticleTagIds.length > 0))
|
|
591
598
|
{
|
|
592
599
|
// ╭─────
|
|
593
600
|
// │ NOTE:
|
|
@@ -764,7 +771,7 @@
|
|
|
764
771
|
// │ |: Inject STANDARD SLIDER adverts in 'document.body'
|
|
765
772
|
// │ |: Guard with `includesGlobalZone` to avoid body injections on scoped refreshes.
|
|
766
773
|
// ╰─────
|
|
767
|
-
else if (includesGlobalZone)
|
|
774
|
+
else if (includesGlobalZone && isArticlePage)
|
|
768
775
|
{
|
|
769
776
|
// [🐞]
|
|
770
777
|
logger
|
|
@@ -777,11 +784,25 @@
|
|
|
777
784
|
|
|
778
785
|
// ╭─────
|
|
779
786
|
// │ NOTE:
|
|
780
|
-
// │ |: Loop over creative data and inject adverts
|
|
787
|
+
// │ |: Loop over creative data and inject adverts.
|
|
788
|
+
// │ |: Build a Set of creative IDs that belong to zone 1 so we only
|
|
789
|
+
// │ |: inject zone-1-specific creatives rather than all slider-type creatives.
|
|
781
790
|
// ╰─────
|
|
782
|
-
|
|
791
|
+
const
|
|
792
|
+
zone1CampaignIds
|
|
793
|
+
= mapZoneIdToCampaignId.get(1) ?? [],
|
|
794
|
+
zone1CreativeIds
|
|
795
|
+
= new Set
|
|
796
|
+
(
|
|
797
|
+
zone1CampaignIds
|
|
798
|
+
.flatMap(campaignId => mapCampaignIdToCreativeId.get(campaignId) ?? [])
|
|
799
|
+
)
|
|
800
|
+
;
|
|
801
|
+
|
|
802
|
+
for (const [creativeId, adData] of mapCreative)
|
|
783
803
|
{
|
|
784
804
|
if (adData.type != 1) continue;
|
|
805
|
+
if (!zone1CreativeIds.has(creativeId)) continue;
|
|
785
806
|
|
|
786
807
|
listAdWidgetElements.push
|
|
787
808
|
(
|
|
@@ -886,6 +907,25 @@
|
|
|
886
907
|
targetZoneIds = targetZoneIds.filter(id => opts.zoneIds!.includes(id));
|
|
887
908
|
;
|
|
888
909
|
|
|
910
|
+
// ╭─────
|
|
911
|
+
// │ NOTE:
|
|
912
|
+
// │ |: Zone 1 (global slider/popup) has no DOM element and will never appear
|
|
913
|
+
// │ |: in the DOM scan. On article pages it must still be requested so the
|
|
914
|
+
// │ |: backend returns zone-1 campaigns/creatives.
|
|
915
|
+
// │ |: Zone 1 placement has empty authors/tags — it is globally available on
|
|
916
|
+
// │ |: article pages; creative-level targeting handles device/country/author filtering.
|
|
917
|
+
// │ |: Respect scoped refreshes: only add zone 1 if the caller's scope includes it.
|
|
918
|
+
// ╰─────
|
|
919
|
+
const
|
|
920
|
+
shouldRequestZone1
|
|
921
|
+
= isArticlePage
|
|
922
|
+
&& (!opts?.zoneIds || opts.zoneIds.length === 0 || opts.zoneIds.includes(1))
|
|
923
|
+
;
|
|
924
|
+
|
|
925
|
+
if (shouldRequestZone1 && !targetZoneIds.includes(1))
|
|
926
|
+
targetZoneIds.push(1);
|
|
927
|
+
;
|
|
928
|
+
|
|
889
929
|
// ╭─────
|
|
890
930
|
// │ NOTE:
|
|
891
931
|
// │ |: Only tear down previously injected global/body components when the
|