@folklore/ads 0.0.110 → 0.0.111
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 +88 -111
- package/dist/es.js +88 -111
- package/package.json +6 -6
package/dist/cjs.js
CHANGED
|
@@ -70,28 +70,21 @@ function getSortedViewports(viewports) {
|
|
|
70
70
|
})), [viewport => viewport.size[0]]).reverse();
|
|
71
71
|
}
|
|
72
72
|
function buildSizeMappingFromViewports(sizeMapping, viewports) {
|
|
73
|
-
return isObject(sizeMapping) && !isArray(sizeMapping) ? getSortedViewports(viewports).reduce((newSizeMapping,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} = _ref;
|
|
78
|
-
return typeof sizeMapping[name] !== 'undefined' ? [...newSizeMapping, [viewPortSize, sizeMapping[name]]] : newSizeMapping;
|
|
79
|
-
}, []) : sizeMapping;
|
|
73
|
+
return isObject(sizeMapping) && !isArray(sizeMapping) ? getSortedViewports(viewports).reduce((newSizeMapping, {
|
|
74
|
+
name,
|
|
75
|
+
size: viewPortSize
|
|
76
|
+
}) => typeof sizeMapping[name] !== 'undefined' ? [...newSizeMapping, [viewPortSize, sizeMapping[name]]] : newSizeMapping, []) : sizeMapping;
|
|
80
77
|
}
|
|
81
78
|
function buildSizeMappingFromSizes(sizes, viewports) {
|
|
82
|
-
return getSortedViewports(viewports).map(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} = _ref2;
|
|
87
|
-
return [viewPortSize, sizes.filter(size => sizeFitsInViewport(size, name === 'default' ? [300, 300] : viewPortSize))];
|
|
88
|
-
});
|
|
79
|
+
return getSortedViewports(viewports).map(({
|
|
80
|
+
name,
|
|
81
|
+
size: viewPortSize
|
|
82
|
+
}) => [viewPortSize, sizes.filter(size => sizeFitsInViewport(size, name === 'default' ? [300, 300] : viewPortSize))]);
|
|
89
83
|
}
|
|
90
|
-
function getSizeMappingFromSlot(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} = _ref3;
|
|
84
|
+
function getSizeMappingFromSlot({
|
|
85
|
+
size: allSizes = [],
|
|
86
|
+
sizeMapping = null
|
|
87
|
+
}, viewports) {
|
|
95
88
|
if (sizeMapping === true) {
|
|
96
89
|
return buildSizeMappingFromSizes(allSizes, viewports);
|
|
97
90
|
}
|
|
@@ -116,8 +109,7 @@ function getSizeFromSizeMapping(sizeMapping) {
|
|
|
116
109
|
}
|
|
117
110
|
|
|
118
111
|
class AdSlot extends EventEmitter {
|
|
119
|
-
constructor(id, path, size) {
|
|
120
|
-
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
112
|
+
constructor(id, path, size, opts = {}) {
|
|
121
113
|
super();
|
|
122
114
|
this.options = {
|
|
123
115
|
sizeMapping: null,
|
|
@@ -345,8 +337,7 @@ class AdsManager extends EventEmitter {
|
|
|
345
337
|
[index.id]: [item.slug]
|
|
346
338
|
} : null;
|
|
347
339
|
}
|
|
348
|
-
constructor() {
|
|
349
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
340
|
+
constructor(opts = {}) {
|
|
350
341
|
super();
|
|
351
342
|
this.options = {
|
|
352
343
|
disabled: false,
|
|
@@ -514,8 +505,7 @@ class AdsManager extends EventEmitter {
|
|
|
514
505
|
googletag.pubads().setRequestNonPersonalizedAds(disablePersonnalizedAds ? 1 : 0);
|
|
515
506
|
});
|
|
516
507
|
}
|
|
517
|
-
createSlot(path, size) {
|
|
518
|
-
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
508
|
+
createSlot(path, size, opts = {}) {
|
|
519
509
|
const {
|
|
520
510
|
id: providedId = null
|
|
521
511
|
} = opts;
|
|
@@ -692,27 +682,26 @@ const AdsContext = /*#__PURE__*/React.createContext({
|
|
|
692
682
|
ready: false
|
|
693
683
|
});
|
|
694
684
|
const useAdsContext = () => React.useContext(AdsContext);
|
|
695
|
-
function AdsProvider(
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
} = _ref;
|
|
685
|
+
function AdsProvider({
|
|
686
|
+
children,
|
|
687
|
+
defaultSlotPath = null,
|
|
688
|
+
slotsPath = null,
|
|
689
|
+
disableSingleRequest = false,
|
|
690
|
+
disableVideoAds = false,
|
|
691
|
+
disableLazyLoad = false,
|
|
692
|
+
autoInit = true,
|
|
693
|
+
resizeDebounceDelay = 500,
|
|
694
|
+
refreshOnResize = false,
|
|
695
|
+
mobileScaling = 1.0,
|
|
696
|
+
renderMarginPercent = 100,
|
|
697
|
+
fetchMarginPercent = 300,
|
|
698
|
+
viewport = null,
|
|
699
|
+
viewports: viewports$1 = viewports,
|
|
700
|
+
slots: slots$1 = slots,
|
|
701
|
+
richAdComponents = null,
|
|
702
|
+
disabled = false,
|
|
703
|
+
disableTracking = false
|
|
704
|
+
}) {
|
|
716
705
|
const [ready, setReady] = React.useState(false);
|
|
717
706
|
const adsRef = React.useRef(null);
|
|
718
707
|
const ads = React.useMemo(() => {
|
|
@@ -810,12 +799,11 @@ const defaultTargeting = {
|
|
|
810
799
|
};
|
|
811
800
|
const AdsTargetingContext = /*#__PURE__*/React.createContext(defaultTargeting);
|
|
812
801
|
const useAdsTargeting = () => React.useContext(AdsTargetingContext);
|
|
813
|
-
function AdsTargetingProvider(
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
} = _ref;
|
|
802
|
+
function AdsTargetingProvider({
|
|
803
|
+
children,
|
|
804
|
+
targeting = defaultTargeting,
|
|
805
|
+
replace = false
|
|
806
|
+
}) {
|
|
819
807
|
const previousTargeting = useAdsTargeting();
|
|
820
808
|
const mergedTargeting = React.useMemo(() => replace ? targeting : {
|
|
821
809
|
...previousTargeting,
|
|
@@ -828,11 +816,10 @@ function AdsTargetingProvider(_ref) {
|
|
|
828
816
|
}
|
|
829
817
|
|
|
830
818
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
831
|
-
function RichAd(
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
} = _ref;
|
|
819
|
+
function RichAd({
|
|
820
|
+
richAd,
|
|
821
|
+
...props
|
|
822
|
+
}) {
|
|
836
823
|
const {
|
|
837
824
|
type = null,
|
|
838
825
|
...richAdProps
|
|
@@ -849,9 +836,7 @@ function RichAd(_ref) {
|
|
|
849
836
|
|
|
850
837
|
function useAdsTracking() {
|
|
851
838
|
const tracking$1 = tracking.useTracking() || null;
|
|
852
|
-
const trackEvent = React.useCallback(
|
|
853
|
-
let slot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
854
|
-
let renderEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
839
|
+
const trackEvent = React.useCallback((action, slot = null, renderEvent = null) => {
|
|
855
840
|
if (tracking$1 !== null && typeof tracking$1.trackAd !== 'undefined') {
|
|
856
841
|
tracking$1.trackAd(action, slot, renderEvent);
|
|
857
842
|
}
|
|
@@ -859,21 +844,20 @@ function useAdsTracking() {
|
|
|
859
844
|
return trackEvent;
|
|
860
845
|
}
|
|
861
846
|
|
|
862
|
-
function useAd(path, size
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
847
|
+
function useAd(path, size, {
|
|
848
|
+
id,
|
|
849
|
+
sizeMapping = null,
|
|
850
|
+
viewport = null,
|
|
851
|
+
targeting = null,
|
|
852
|
+
categoryExclusions = null,
|
|
853
|
+
refreshInterval = null,
|
|
854
|
+
alwaysRender = false,
|
|
855
|
+
onRender = null,
|
|
856
|
+
onDestroy = null,
|
|
857
|
+
disabled = false,
|
|
858
|
+
disableTracking = false,
|
|
859
|
+
rootMargin = '300px'
|
|
860
|
+
} = {}) {
|
|
877
861
|
const {
|
|
878
862
|
ads: adsManager,
|
|
879
863
|
viewports,
|
|
@@ -881,9 +865,7 @@ function useAd(path, size) {
|
|
|
881
865
|
trackingDisabled: globalTrackingDisabled = false
|
|
882
866
|
} = useAdsContext();
|
|
883
867
|
const trackAd = useAdsTracking();
|
|
884
|
-
const track = React.useCallback(
|
|
885
|
-
let slot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
886
|
-
let renderEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
868
|
+
const track = React.useCallback((action, slot = null, renderEvent = null) => {
|
|
887
869
|
if (!disableTracking && !globalTrackingDisabled) {
|
|
888
870
|
trackAd(action, slot, renderEvent);
|
|
889
871
|
}
|
|
@@ -893,7 +875,7 @@ function useAd(path, size) {
|
|
|
893
875
|
const {
|
|
894
876
|
ref: refObserver,
|
|
895
877
|
entry: {
|
|
896
|
-
isIntersecting
|
|
878
|
+
isIntersecting = false
|
|
897
879
|
}
|
|
898
880
|
} = hooks.useIntersectionObserver({
|
|
899
881
|
rootMargin,
|
|
@@ -923,10 +905,7 @@ function useAd(path, size) {
|
|
|
923
905
|
adsManager.destroySlot(currentSlot);
|
|
924
906
|
}
|
|
925
907
|
const viewportSize = viewport !== null ? viewports[viewport] || null : null;
|
|
926
|
-
const [, viewportFixedSize = null] = sizeMapping !== null && viewportSize !== null ? sizeMapping.find(
|
|
927
|
-
let [itViewport] = _ref;
|
|
928
|
-
return itViewport.join('x') === viewportSize.join('x');
|
|
929
|
-
}) || [] : [];
|
|
908
|
+
const [, viewportFixedSize = null] = sizeMapping !== null && viewportSize !== null ? sizeMapping.find(([itViewport]) => itViewport.join('x') === viewportSize.join('x')) || [] : [];
|
|
930
909
|
const newSlot = path !== null && !disabled ? adsManager.createSlot(path, viewportFixedSize || size, {
|
|
931
910
|
id,
|
|
932
911
|
visible: isVisible,
|
|
@@ -1073,8 +1052,7 @@ function parseRichAd(data) {
|
|
|
1073
1052
|
} catch (e) {}
|
|
1074
1053
|
return richAd;
|
|
1075
1054
|
}
|
|
1076
|
-
function useRichAd(containerRef, id) {
|
|
1077
|
-
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1055
|
+
function useRichAd(containerRef, id, opts = {}) {
|
|
1078
1056
|
const [richAd, setRichAd] = React.useState(null);
|
|
1079
1057
|
const {
|
|
1080
1058
|
onRichAd = null
|
|
@@ -1112,32 +1090,31 @@ function useRichAd(containerRef, id) {
|
|
|
1112
1090
|
}
|
|
1113
1091
|
|
|
1114
1092
|
/* eslint-disable react/require-default-props */
|
|
1115
|
-
function Ad(
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
} = _ref;
|
|
1093
|
+
function Ad({
|
|
1094
|
+
slot: slotName,
|
|
1095
|
+
path: providedPath = null,
|
|
1096
|
+
size: providedSize = null,
|
|
1097
|
+
sizeMapping: providedSizeMapping = null,
|
|
1098
|
+
viewport: providedViewport = null,
|
|
1099
|
+
targeting: providedTargeting = null,
|
|
1100
|
+
refreshInterval: providedRefreshInterval = null,
|
|
1101
|
+
alwaysRender = true,
|
|
1102
|
+
disabled: providedDisabled = false,
|
|
1103
|
+
disableTracking = false,
|
|
1104
|
+
shouldKeepSize = false,
|
|
1105
|
+
withoutStyle = false,
|
|
1106
|
+
withoutMinimumSize = false,
|
|
1107
|
+
withReactId = false,
|
|
1108
|
+
className = null,
|
|
1109
|
+
emptyClassName = null,
|
|
1110
|
+
adClassName = null,
|
|
1111
|
+
richAdClassName = null,
|
|
1112
|
+
richAdIframeClassName = null,
|
|
1113
|
+
onRender = null,
|
|
1114
|
+
onDestroy = null,
|
|
1115
|
+
onRichAd = null,
|
|
1116
|
+
slotRef = null
|
|
1117
|
+
}) {
|
|
1141
1118
|
const {
|
|
1142
1119
|
slots = null,
|
|
1143
1120
|
slotsPath = null,
|
package/dist/es.js
CHANGED
|
@@ -68,28 +68,21 @@ function getSortedViewports(viewports) {
|
|
|
68
68
|
})), [viewport => viewport.size[0]]).reverse();
|
|
69
69
|
}
|
|
70
70
|
function buildSizeMappingFromViewports(sizeMapping, viewports) {
|
|
71
|
-
return isObject(sizeMapping) && !isArray(sizeMapping) ? getSortedViewports(viewports).reduce((newSizeMapping,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} = _ref;
|
|
76
|
-
return typeof sizeMapping[name] !== 'undefined' ? [...newSizeMapping, [viewPortSize, sizeMapping[name]]] : newSizeMapping;
|
|
77
|
-
}, []) : sizeMapping;
|
|
71
|
+
return isObject(sizeMapping) && !isArray(sizeMapping) ? getSortedViewports(viewports).reduce((newSizeMapping, {
|
|
72
|
+
name,
|
|
73
|
+
size: viewPortSize
|
|
74
|
+
}) => typeof sizeMapping[name] !== 'undefined' ? [...newSizeMapping, [viewPortSize, sizeMapping[name]]] : newSizeMapping, []) : sizeMapping;
|
|
78
75
|
}
|
|
79
76
|
function buildSizeMappingFromSizes(sizes, viewports) {
|
|
80
|
-
return getSortedViewports(viewports).map(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} = _ref2;
|
|
85
|
-
return [viewPortSize, sizes.filter(size => sizeFitsInViewport(size, name === 'default' ? [300, 300] : viewPortSize))];
|
|
86
|
-
});
|
|
77
|
+
return getSortedViewports(viewports).map(({
|
|
78
|
+
name,
|
|
79
|
+
size: viewPortSize
|
|
80
|
+
}) => [viewPortSize, sizes.filter(size => sizeFitsInViewport(size, name === 'default' ? [300, 300] : viewPortSize))]);
|
|
87
81
|
}
|
|
88
|
-
function getSizeMappingFromSlot(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} = _ref3;
|
|
82
|
+
function getSizeMappingFromSlot({
|
|
83
|
+
size: allSizes = [],
|
|
84
|
+
sizeMapping = null
|
|
85
|
+
}, viewports) {
|
|
93
86
|
if (sizeMapping === true) {
|
|
94
87
|
return buildSizeMappingFromSizes(allSizes, viewports);
|
|
95
88
|
}
|
|
@@ -114,8 +107,7 @@ function getSizeFromSizeMapping(sizeMapping) {
|
|
|
114
107
|
}
|
|
115
108
|
|
|
116
109
|
class AdSlot extends EventEmitter {
|
|
117
|
-
constructor(id, path, size) {
|
|
118
|
-
let opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
110
|
+
constructor(id, path, size, opts = {}) {
|
|
119
111
|
super();
|
|
120
112
|
this.options = {
|
|
121
113
|
sizeMapping: null,
|
|
@@ -343,8 +335,7 @@ class AdsManager extends EventEmitter {
|
|
|
343
335
|
[index.id]: [item.slug]
|
|
344
336
|
} : null;
|
|
345
337
|
}
|
|
346
|
-
constructor() {
|
|
347
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
338
|
+
constructor(opts = {}) {
|
|
348
339
|
super();
|
|
349
340
|
this.options = {
|
|
350
341
|
disabled: false,
|
|
@@ -512,8 +503,7 @@ class AdsManager extends EventEmitter {
|
|
|
512
503
|
googletag.pubads().setRequestNonPersonalizedAds(disablePersonnalizedAds ? 1 : 0);
|
|
513
504
|
});
|
|
514
505
|
}
|
|
515
|
-
createSlot(path, size) {
|
|
516
|
-
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
506
|
+
createSlot(path, size, opts = {}) {
|
|
517
507
|
const {
|
|
518
508
|
id: providedId = null
|
|
519
509
|
} = opts;
|
|
@@ -690,27 +680,26 @@ const AdsContext = /*#__PURE__*/React.createContext({
|
|
|
690
680
|
ready: false
|
|
691
681
|
});
|
|
692
682
|
const useAdsContext = () => useContext(AdsContext);
|
|
693
|
-
function AdsProvider(
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
} = _ref;
|
|
683
|
+
function AdsProvider({
|
|
684
|
+
children,
|
|
685
|
+
defaultSlotPath = null,
|
|
686
|
+
slotsPath = null,
|
|
687
|
+
disableSingleRequest = false,
|
|
688
|
+
disableVideoAds = false,
|
|
689
|
+
disableLazyLoad = false,
|
|
690
|
+
autoInit = true,
|
|
691
|
+
resizeDebounceDelay = 500,
|
|
692
|
+
refreshOnResize = false,
|
|
693
|
+
mobileScaling = 1.0,
|
|
694
|
+
renderMarginPercent = 100,
|
|
695
|
+
fetchMarginPercent = 300,
|
|
696
|
+
viewport = null,
|
|
697
|
+
viewports: viewports$1 = viewports,
|
|
698
|
+
slots: slots$1 = slots,
|
|
699
|
+
richAdComponents = null,
|
|
700
|
+
disabled = false,
|
|
701
|
+
disableTracking = false
|
|
702
|
+
}) {
|
|
714
703
|
const [ready, setReady] = useState(false);
|
|
715
704
|
const adsRef = useRef(null);
|
|
716
705
|
const ads = useMemo(() => {
|
|
@@ -808,12 +797,11 @@ const defaultTargeting = {
|
|
|
808
797
|
};
|
|
809
798
|
const AdsTargetingContext = /*#__PURE__*/createContext(defaultTargeting);
|
|
810
799
|
const useAdsTargeting = () => useContext(AdsTargetingContext);
|
|
811
|
-
function AdsTargetingProvider(
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
} = _ref;
|
|
800
|
+
function AdsTargetingProvider({
|
|
801
|
+
children,
|
|
802
|
+
targeting = defaultTargeting,
|
|
803
|
+
replace = false
|
|
804
|
+
}) {
|
|
817
805
|
const previousTargeting = useAdsTargeting();
|
|
818
806
|
const mergedTargeting = useMemo(() => replace ? targeting : {
|
|
819
807
|
...previousTargeting,
|
|
@@ -826,11 +814,10 @@ function AdsTargetingProvider(_ref) {
|
|
|
826
814
|
}
|
|
827
815
|
|
|
828
816
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
829
|
-
function RichAd(
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
} = _ref;
|
|
817
|
+
function RichAd({
|
|
818
|
+
richAd,
|
|
819
|
+
...props
|
|
820
|
+
}) {
|
|
834
821
|
const {
|
|
835
822
|
type = null,
|
|
836
823
|
...richAdProps
|
|
@@ -847,9 +834,7 @@ function RichAd(_ref) {
|
|
|
847
834
|
|
|
848
835
|
function useAdsTracking() {
|
|
849
836
|
const tracking = useTracking() || null;
|
|
850
|
-
const trackEvent = useCallback(
|
|
851
|
-
let slot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
852
|
-
let renderEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
837
|
+
const trackEvent = useCallback((action, slot = null, renderEvent = null) => {
|
|
853
838
|
if (tracking !== null && typeof tracking.trackAd !== 'undefined') {
|
|
854
839
|
tracking.trackAd(action, slot, renderEvent);
|
|
855
840
|
}
|
|
@@ -857,21 +842,20 @@ function useAdsTracking() {
|
|
|
857
842
|
return trackEvent;
|
|
858
843
|
}
|
|
859
844
|
|
|
860
|
-
function useAd(path, size
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
845
|
+
function useAd(path, size, {
|
|
846
|
+
id,
|
|
847
|
+
sizeMapping = null,
|
|
848
|
+
viewport = null,
|
|
849
|
+
targeting = null,
|
|
850
|
+
categoryExclusions = null,
|
|
851
|
+
refreshInterval = null,
|
|
852
|
+
alwaysRender = false,
|
|
853
|
+
onRender = null,
|
|
854
|
+
onDestroy = null,
|
|
855
|
+
disabled = false,
|
|
856
|
+
disableTracking = false,
|
|
857
|
+
rootMargin = '300px'
|
|
858
|
+
} = {}) {
|
|
875
859
|
const {
|
|
876
860
|
ads: adsManager,
|
|
877
861
|
viewports,
|
|
@@ -879,9 +863,7 @@ function useAd(path, size) {
|
|
|
879
863
|
trackingDisabled: globalTrackingDisabled = false
|
|
880
864
|
} = useAdsContext();
|
|
881
865
|
const trackAd = useAdsTracking();
|
|
882
|
-
const track = useCallback(
|
|
883
|
-
let slot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
884
|
-
let renderEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
866
|
+
const track = useCallback((action, slot = null, renderEvent = null) => {
|
|
885
867
|
if (!disableTracking && !globalTrackingDisabled) {
|
|
886
868
|
trackAd(action, slot, renderEvent);
|
|
887
869
|
}
|
|
@@ -891,7 +873,7 @@ function useAd(path, size) {
|
|
|
891
873
|
const {
|
|
892
874
|
ref: refObserver,
|
|
893
875
|
entry: {
|
|
894
|
-
isIntersecting
|
|
876
|
+
isIntersecting = false
|
|
895
877
|
}
|
|
896
878
|
} = useIntersectionObserver({
|
|
897
879
|
rootMargin,
|
|
@@ -921,10 +903,7 @@ function useAd(path, size) {
|
|
|
921
903
|
adsManager.destroySlot(currentSlot);
|
|
922
904
|
}
|
|
923
905
|
const viewportSize = viewport !== null ? viewports[viewport] || null : null;
|
|
924
|
-
const [, viewportFixedSize = null] = sizeMapping !== null && viewportSize !== null ? sizeMapping.find(
|
|
925
|
-
let [itViewport] = _ref;
|
|
926
|
-
return itViewport.join('x') === viewportSize.join('x');
|
|
927
|
-
}) || [] : [];
|
|
906
|
+
const [, viewportFixedSize = null] = sizeMapping !== null && viewportSize !== null ? sizeMapping.find(([itViewport]) => itViewport.join('x') === viewportSize.join('x')) || [] : [];
|
|
928
907
|
const newSlot = path !== null && !disabled ? adsManager.createSlot(path, viewportFixedSize || size, {
|
|
929
908
|
id,
|
|
930
909
|
visible: isVisible,
|
|
@@ -1071,8 +1050,7 @@ function parseRichAd(data) {
|
|
|
1071
1050
|
} catch (e) {}
|
|
1072
1051
|
return richAd;
|
|
1073
1052
|
}
|
|
1074
|
-
function useRichAd(containerRef, id) {
|
|
1075
|
-
let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1053
|
+
function useRichAd(containerRef, id, opts = {}) {
|
|
1076
1054
|
const [richAd, setRichAd] = useState(null);
|
|
1077
1055
|
const {
|
|
1078
1056
|
onRichAd = null
|
|
@@ -1110,32 +1088,31 @@ function useRichAd(containerRef, id) {
|
|
|
1110
1088
|
}
|
|
1111
1089
|
|
|
1112
1090
|
/* eslint-disable react/require-default-props */
|
|
1113
|
-
function Ad(
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
} = _ref;
|
|
1091
|
+
function Ad({
|
|
1092
|
+
slot: slotName,
|
|
1093
|
+
path: providedPath = null,
|
|
1094
|
+
size: providedSize = null,
|
|
1095
|
+
sizeMapping: providedSizeMapping = null,
|
|
1096
|
+
viewport: providedViewport = null,
|
|
1097
|
+
targeting: providedTargeting = null,
|
|
1098
|
+
refreshInterval: providedRefreshInterval = null,
|
|
1099
|
+
alwaysRender = true,
|
|
1100
|
+
disabled: providedDisabled = false,
|
|
1101
|
+
disableTracking = false,
|
|
1102
|
+
shouldKeepSize = false,
|
|
1103
|
+
withoutStyle = false,
|
|
1104
|
+
withoutMinimumSize = false,
|
|
1105
|
+
withReactId = false,
|
|
1106
|
+
className = null,
|
|
1107
|
+
emptyClassName = null,
|
|
1108
|
+
adClassName = null,
|
|
1109
|
+
richAdClassName = null,
|
|
1110
|
+
richAdIframeClassName = null,
|
|
1111
|
+
onRender = null,
|
|
1112
|
+
onDestroy = null,
|
|
1113
|
+
onRichAd = null,
|
|
1114
|
+
slotRef = null
|
|
1115
|
+
}) {
|
|
1139
1116
|
const {
|
|
1140
1117
|
slots = null,
|
|
1141
1118
|
slotsPath = null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/ads",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.111",
|
|
4
4
|
"description": "Ads library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"clean": "rm -rf dist && rm -rf types",
|
|
39
39
|
"build:types": "tsc --p tsconfig.json",
|
|
40
40
|
"build": "npm run build:types && rollup --bundleConfigAsCjs --config ../../rollup.config.js",
|
|
41
|
-
"
|
|
41
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"prop-types": "^15.7.2",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "a04cfaacb364f3b35307d65d8778b078dace4491",
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@folklore/hooks": "^0.0.
|
|
59
|
-
"@folklore/tracking": "^0.0.
|
|
60
|
-
"@folklore/utils": "^0.1.
|
|
58
|
+
"@folklore/hooks": "^0.0.74",
|
|
59
|
+
"@folklore/tracking": "^0.0.30",
|
|
60
|
+
"@folklore/utils": "^0.1.4",
|
|
61
61
|
"classnames": "^2.5.1",
|
|
62
62
|
"debug": "^4.3.4",
|
|
63
63
|
"lodash": "^4.17.21",
|