@betarena/ad-engine 0.3.1 → 0.3.2

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.3.1",
3
+ "version": "0.3.2",
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.1.0",
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
- for (const [, adData] of mapCreative)
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
  (