@folklore/ads 0.0.37 → 0.0.39
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/cjs.js +30 -16
- package/dist/es.js +30 -16
- package/package.json +2 -2
package/dist/cjs.js
CHANGED
|
@@ -192,6 +192,13 @@ class AdSlot extends EventEmitter__default["default"] {
|
|
|
192
192
|
setRefreshDisabled() {
|
|
193
193
|
this.refreshDisabled = true;
|
|
194
194
|
}
|
|
195
|
+
setTargeting(targeting) {
|
|
196
|
+
if (this.adSlot !== null) {
|
|
197
|
+
this.adSlot.updateTargetingFromMap(targeting);
|
|
198
|
+
} else {
|
|
199
|
+
this.options.targeting = targeting;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
195
202
|
destroy() {
|
|
196
203
|
if (this.destroyed) {
|
|
197
204
|
return;
|
|
@@ -367,7 +374,7 @@ class AdsManager extends EventEmitter__default["default"] {
|
|
|
367
374
|
}
|
|
368
375
|
if (!disableSingleRequest) {
|
|
369
376
|
debug('Enable single request');
|
|
370
|
-
googletag.pubads().
|
|
377
|
+
googletag.pubads().enableSingleRequest();
|
|
371
378
|
}
|
|
372
379
|
if (personnalizedAdsDisabled) {
|
|
373
380
|
debug('Disable personalized ads');
|
|
@@ -745,25 +752,27 @@ function AdsProvider(_ref) {
|
|
|
745
752
|
onResize.cancel();
|
|
746
753
|
};
|
|
747
754
|
}, [ads, resizeDebounceDelay, refreshOnResize]);
|
|
755
|
+
const slotsWithSizeMapping = React.useMemo(() => Object.keys(slots || {}).reduce((map, key) => ({
|
|
756
|
+
...map,
|
|
757
|
+
[key]: {
|
|
758
|
+
...slots[key],
|
|
759
|
+
sizeMapping: getSizeMappingFromSlot(slots[key], viewports)
|
|
760
|
+
}
|
|
761
|
+
}), {}), []);
|
|
762
|
+
const finalSlotsPath = React.useMemo(() => defaultSlotPath !== null ? {
|
|
763
|
+
default: defaultSlotPath,
|
|
764
|
+
...slotsPath
|
|
765
|
+
} : {
|
|
766
|
+
...slotsPath
|
|
767
|
+
}, [defaultSlotPath, slotsPath]);
|
|
748
768
|
const value = React.useMemo(() => ({
|
|
749
769
|
ready,
|
|
750
770
|
ads,
|
|
751
771
|
viewports,
|
|
752
|
-
slots:
|
|
753
|
-
|
|
754
|
-
[key]: {
|
|
755
|
-
...slots[key],
|
|
756
|
-
sizeMapping: getSizeMappingFromSlot(slots[key], viewports)
|
|
757
|
-
}
|
|
758
|
-
}), {}),
|
|
759
|
-
slotsPath: defaultSlotPath !== null ? {
|
|
760
|
-
default: defaultSlotPath,
|
|
761
|
-
...slotsPath
|
|
762
|
-
} : {
|
|
763
|
-
...slotsPath
|
|
764
|
-
},
|
|
772
|
+
slots: slotsWithSizeMapping,
|
|
773
|
+
slotsPath: finalSlotsPath,
|
|
765
774
|
trackingDisabled: disableTracking
|
|
766
|
-
}), [ready, ads, viewports,
|
|
775
|
+
}), [ready, ads, viewports, slotsWithSizeMapping, finalSlotsPath, disableTracking]);
|
|
767
776
|
return /*#__PURE__*/jsxRuntime.jsx(AdsContext.Provider, {
|
|
768
777
|
value: value,
|
|
769
778
|
children: children
|
|
@@ -878,7 +887,12 @@ function useAd(path, size) {
|
|
|
878
887
|
// adsManager.defineSlot(currentSlot.current);
|
|
879
888
|
// }
|
|
880
889
|
return currentSlot.current;
|
|
881
|
-
}, [adsManager, path, disabled, size, sizeMapping,
|
|
890
|
+
}, [adsManager, path, disabled, size, sizeMapping, alwaysRender, categoryExclusions]);
|
|
891
|
+
React.useEffect(() => {
|
|
892
|
+
if (currentSlot.current !== null) {
|
|
893
|
+
currentSlot.current.setTargeting(targeting);
|
|
894
|
+
}
|
|
895
|
+
}, [targeting]);
|
|
882
896
|
|
|
883
897
|
// Set visibility
|
|
884
898
|
React.useEffect(() => {
|
package/dist/es.js
CHANGED
|
@@ -174,6 +174,13 @@ class AdSlot extends EventEmitter {
|
|
|
174
174
|
setRefreshDisabled() {
|
|
175
175
|
this.refreshDisabled = true;
|
|
176
176
|
}
|
|
177
|
+
setTargeting(targeting) {
|
|
178
|
+
if (this.adSlot !== null) {
|
|
179
|
+
this.adSlot.updateTargetingFromMap(targeting);
|
|
180
|
+
} else {
|
|
181
|
+
this.options.targeting = targeting;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
177
184
|
destroy() {
|
|
178
185
|
if (this.destroyed) {
|
|
179
186
|
return;
|
|
@@ -349,7 +356,7 @@ class AdsManager extends EventEmitter {
|
|
|
349
356
|
}
|
|
350
357
|
if (!disableSingleRequest) {
|
|
351
358
|
debug('Enable single request');
|
|
352
|
-
googletag.pubads().
|
|
359
|
+
googletag.pubads().enableSingleRequest();
|
|
353
360
|
}
|
|
354
361
|
if (personnalizedAdsDisabled) {
|
|
355
362
|
debug('Disable personalized ads');
|
|
@@ -727,25 +734,27 @@ function AdsProvider(_ref) {
|
|
|
727
734
|
onResize.cancel();
|
|
728
735
|
};
|
|
729
736
|
}, [ads, resizeDebounceDelay, refreshOnResize]);
|
|
737
|
+
const slotsWithSizeMapping = useMemo(() => Object.keys(slots || {}).reduce((map, key) => ({
|
|
738
|
+
...map,
|
|
739
|
+
[key]: {
|
|
740
|
+
...slots[key],
|
|
741
|
+
sizeMapping: getSizeMappingFromSlot(slots[key], viewports)
|
|
742
|
+
}
|
|
743
|
+
}), {}), []);
|
|
744
|
+
const finalSlotsPath = useMemo(() => defaultSlotPath !== null ? {
|
|
745
|
+
default: defaultSlotPath,
|
|
746
|
+
...slotsPath
|
|
747
|
+
} : {
|
|
748
|
+
...slotsPath
|
|
749
|
+
}, [defaultSlotPath, slotsPath]);
|
|
730
750
|
const value = useMemo(() => ({
|
|
731
751
|
ready,
|
|
732
752
|
ads,
|
|
733
753
|
viewports,
|
|
734
|
-
slots:
|
|
735
|
-
|
|
736
|
-
[key]: {
|
|
737
|
-
...slots[key],
|
|
738
|
-
sizeMapping: getSizeMappingFromSlot(slots[key], viewports)
|
|
739
|
-
}
|
|
740
|
-
}), {}),
|
|
741
|
-
slotsPath: defaultSlotPath !== null ? {
|
|
742
|
-
default: defaultSlotPath,
|
|
743
|
-
...slotsPath
|
|
744
|
-
} : {
|
|
745
|
-
...slotsPath
|
|
746
|
-
},
|
|
754
|
+
slots: slotsWithSizeMapping,
|
|
755
|
+
slotsPath: finalSlotsPath,
|
|
747
756
|
trackingDisabled: disableTracking
|
|
748
|
-
}), [ready, ads, viewports,
|
|
757
|
+
}), [ready, ads, viewports, slotsWithSizeMapping, finalSlotsPath, disableTracking]);
|
|
749
758
|
return /*#__PURE__*/jsx(AdsContext.Provider, {
|
|
750
759
|
value: value,
|
|
751
760
|
children: children
|
|
@@ -860,7 +869,12 @@ function useAd(path, size) {
|
|
|
860
869
|
// adsManager.defineSlot(currentSlot.current);
|
|
861
870
|
// }
|
|
862
871
|
return currentSlot.current;
|
|
863
|
-
}, [adsManager, path, disabled, size, sizeMapping,
|
|
872
|
+
}, [adsManager, path, disabled, size, sizeMapping, alwaysRender, categoryExclusions]);
|
|
873
|
+
useEffect(() => {
|
|
874
|
+
if (currentSlot.current !== null) {
|
|
875
|
+
currentSlot.current.setTargeting(targeting);
|
|
876
|
+
}
|
|
877
|
+
}, [targeting]);
|
|
864
878
|
|
|
865
879
|
// Set visibility
|
|
866
880
|
useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/ads",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "Ads library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "6a3484815046ba47850ba5d71e5eee9afe4adeb4",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@folklore/hooks": "^0.0.44",
|
|
56
56
|
"@folklore/tracking": "^0.0.23",
|