@folklore/ads 0.0.20 → 0.0.22
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 +17 -7
- package/dist/es.js +17 -7
- package/package.json +2 -2
package/dist/cjs.js
CHANGED
|
@@ -733,20 +733,28 @@ const useAdsTargeting = () => React.useContext(AdsTargetingContext);
|
|
|
733
733
|
const propTypes$1 = {
|
|
734
734
|
children: PropTypes__default["default"].node.isRequired,
|
|
735
735
|
// eslint-disable-next-line react/forbid-prop-types
|
|
736
|
-
targeting: PropTypes__default["default"].object
|
|
736
|
+
targeting: PropTypes__default["default"].object,
|
|
737
|
+
replace: PropTypes__default["default"].bool
|
|
737
738
|
};
|
|
738
739
|
const defaultProps$1 = {
|
|
739
740
|
targeting: {
|
|
740
741
|
domain: typeof window !== 'undefined' ? `${window.location.protocol}//${window.location.host}` : null
|
|
741
|
-
}
|
|
742
|
+
},
|
|
743
|
+
replace: false
|
|
742
744
|
};
|
|
743
745
|
function AdsTargetingProvider(_ref) {
|
|
744
746
|
let {
|
|
745
747
|
children,
|
|
746
|
-
targeting
|
|
748
|
+
targeting,
|
|
749
|
+
replace
|
|
747
750
|
} = _ref;
|
|
751
|
+
const previousTargeting = useAdsTargeting();
|
|
752
|
+
const mergedTargeting = React.useMemo(() => replace ? targeting : {
|
|
753
|
+
...previousTargeting,
|
|
754
|
+
...targeting
|
|
755
|
+
}, [replace, previousTargeting, targeting]);
|
|
748
756
|
return /*#__PURE__*/jsxRuntime.jsx(AdsTargetingContext.Provider, {
|
|
749
|
-
value:
|
|
757
|
+
value: mergedTargeting,
|
|
750
758
|
children: children
|
|
751
759
|
});
|
|
752
760
|
}
|
|
@@ -980,11 +988,13 @@ function Ad(_ref) {
|
|
|
980
988
|
|
|
981
989
|
// Targeting
|
|
982
990
|
const contextTargeting = useAdsTargeting();
|
|
983
|
-
const allTargeting = React.useMemo(() =>
|
|
984
|
-
|
|
991
|
+
const allTargeting = React.useMemo(() => ({
|
|
992
|
+
...(slotName !== null ? {
|
|
993
|
+
slot: slotName
|
|
994
|
+
} : null),
|
|
985
995
|
...contextTargeting,
|
|
986
996
|
...targeting
|
|
987
|
-
}
|
|
997
|
+
}), [contextTargeting, targeting, slotName]);
|
|
988
998
|
const finalAdTargeting = React.useMemo(() => {
|
|
989
999
|
const {
|
|
990
1000
|
refreshAds = null,
|
package/dist/es.js
CHANGED
|
@@ -715,20 +715,28 @@ const useAdsTargeting = () => useContext(AdsTargetingContext);
|
|
|
715
715
|
const propTypes$1 = {
|
|
716
716
|
children: PropTypes.node.isRequired,
|
|
717
717
|
// eslint-disable-next-line react/forbid-prop-types
|
|
718
|
-
targeting: PropTypes.object
|
|
718
|
+
targeting: PropTypes.object,
|
|
719
|
+
replace: PropTypes.bool
|
|
719
720
|
};
|
|
720
721
|
const defaultProps$1 = {
|
|
721
722
|
targeting: {
|
|
722
723
|
domain: typeof window !== 'undefined' ? `${window.location.protocol}//${window.location.host}` : null
|
|
723
|
-
}
|
|
724
|
+
},
|
|
725
|
+
replace: false
|
|
724
726
|
};
|
|
725
727
|
function AdsTargetingProvider(_ref) {
|
|
726
728
|
let {
|
|
727
729
|
children,
|
|
728
|
-
targeting
|
|
730
|
+
targeting,
|
|
731
|
+
replace
|
|
729
732
|
} = _ref;
|
|
733
|
+
const previousTargeting = useAdsTargeting();
|
|
734
|
+
const mergedTargeting = useMemo(() => replace ? targeting : {
|
|
735
|
+
...previousTargeting,
|
|
736
|
+
...targeting
|
|
737
|
+
}, [replace, previousTargeting, targeting]);
|
|
730
738
|
return /*#__PURE__*/jsx(AdsTargetingContext.Provider, {
|
|
731
|
-
value:
|
|
739
|
+
value: mergedTargeting,
|
|
732
740
|
children: children
|
|
733
741
|
});
|
|
734
742
|
}
|
|
@@ -962,11 +970,13 @@ function Ad(_ref) {
|
|
|
962
970
|
|
|
963
971
|
// Targeting
|
|
964
972
|
const contextTargeting = useAdsTargeting();
|
|
965
|
-
const allTargeting = useMemo(() =>
|
|
966
|
-
|
|
973
|
+
const allTargeting = useMemo(() => ({
|
|
974
|
+
...(slotName !== null ? {
|
|
975
|
+
slot: slotName
|
|
976
|
+
} : null),
|
|
967
977
|
...contextTargeting,
|
|
968
978
|
...targeting
|
|
969
|
-
}
|
|
979
|
+
}), [contextTargeting, targeting, slotName]);
|
|
970
980
|
const finalAdTargeting = useMemo(() => {
|
|
971
981
|
const {
|
|
972
982
|
refreshAds = null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/ads",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
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": "6582d1723398b40a05f58eb46e34589c8cbe7471",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@folklore/hooks": "^0.0.42",
|
|
56
56
|
"@folklore/tracking": "^0.0.16",
|