@folklore/ads
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -195,2 +195,9 @@ 'use strict'; | ||
} | ||
setTargeting(targeting) { | ||
if (this.adSlot !== null) { | ||
this.adSlot.updateTargetingFromMap(targeting); | ||
} else { | ||
this.options.targeting = targeting; | ||
} | ||
} | ||
destroy() { | ||
@@ -749,2 +756,15 @@ if (this.destroyed) { | ||
}, [ads, resizeDebounceDelay, refreshOnResize]); | ||
const slotsWithSizeMapping = React.useMemo(() => Object.keys(slots || {}).reduce((map, key) => ({ | ||
...map, | ||
[key]: { | ||
...slots[key], | ||
sizeMapping: getSizeMappingFromSlot(slots[key], viewports) | ||
} | ||
}), {}), []); | ||
const finalSlotsPath = React.useMemo(() => defaultSlotPath !== null ? { | ||
default: defaultSlotPath, | ||
...slotsPath | ||
} : { | ||
...slotsPath | ||
}, [defaultSlotPath, slotsPath]); | ||
const value = React.useMemo(() => ({ | ||
@@ -754,17 +774,6 @@ ready, | ||
viewports, | ||
slots: Object.keys(slots || {}).reduce((map, key) => ({ | ||
...map, | ||
[key]: { | ||
...slots[key], | ||
sizeMapping: getSizeMappingFromSlot(slots[key], viewports) | ||
} | ||
}), {}), | ||
slotsPath: defaultSlotPath !== null ? { | ||
default: defaultSlotPath, | ||
...slotsPath | ||
} : { | ||
...slotsPath | ||
}, | ||
slots: slotsWithSizeMapping, | ||
slotsPath: finalSlotsPath, | ||
trackingDisabled: disableTracking | ||
}), [ready, ads, viewports, slots, slotsPath, defaultSlotPath, disableTracking, disabled]); | ||
}), [ready, ads, viewports, slotsWithSizeMapping, finalSlotsPath, disableTracking]); | ||
return /*#__PURE__*/jsxRuntime.jsx(AdsContext.Provider, { | ||
@@ -884,3 +893,8 @@ value: value, | ||
return currentSlot.current; | ||
}, [adsManager, path, disabled, size, sizeMapping, targeting, alwaysRender, categoryExclusions]); | ||
}, [adsManager, path, disabled, size, sizeMapping, alwaysRender, categoryExclusions]); | ||
React.useEffect(() => { | ||
if (currentSlot.current !== null) { | ||
currentSlot.current.setTargeting(targeting); | ||
} | ||
}, [targeting]); | ||
@@ -887,0 +901,0 @@ // Set visibility |
@@ -177,2 +177,9 @@ import PropTypes from 'prop-types'; | ||
} | ||
setTargeting(targeting) { | ||
if (this.adSlot !== null) { | ||
this.adSlot.updateTargetingFromMap(targeting); | ||
} else { | ||
this.options.targeting = targeting; | ||
} | ||
} | ||
destroy() { | ||
@@ -731,2 +738,15 @@ if (this.destroyed) { | ||
}, [ads, resizeDebounceDelay, refreshOnResize]); | ||
const slotsWithSizeMapping = useMemo(() => Object.keys(slots || {}).reduce((map, key) => ({ | ||
...map, | ||
[key]: { | ||
...slots[key], | ||
sizeMapping: getSizeMappingFromSlot(slots[key], viewports) | ||
} | ||
}), {}), []); | ||
const finalSlotsPath = useMemo(() => defaultSlotPath !== null ? { | ||
default: defaultSlotPath, | ||
...slotsPath | ||
} : { | ||
...slotsPath | ||
}, [defaultSlotPath, slotsPath]); | ||
const value = useMemo(() => ({ | ||
@@ -736,17 +756,6 @@ ready, | ||
viewports, | ||
slots: Object.keys(slots || {}).reduce((map, key) => ({ | ||
...map, | ||
[key]: { | ||
...slots[key], | ||
sizeMapping: getSizeMappingFromSlot(slots[key], viewports) | ||
} | ||
}), {}), | ||
slotsPath: defaultSlotPath !== null ? { | ||
default: defaultSlotPath, | ||
...slotsPath | ||
} : { | ||
...slotsPath | ||
}, | ||
slots: slotsWithSizeMapping, | ||
slotsPath: finalSlotsPath, | ||
trackingDisabled: disableTracking | ||
}), [ready, ads, viewports, slots, slotsPath, defaultSlotPath, disableTracking, disabled]); | ||
}), [ready, ads, viewports, slotsWithSizeMapping, finalSlotsPath, disableTracking]); | ||
return /*#__PURE__*/jsx(AdsContext.Provider, { | ||
@@ -866,3 +875,8 @@ value: value, | ||
return currentSlot.current; | ||
}, [adsManager, path, disabled, size, sizeMapping, targeting, alwaysRender, categoryExclusions]); | ||
}, [adsManager, path, disabled, size, sizeMapping, alwaysRender, categoryExclusions]); | ||
useEffect(() => { | ||
if (currentSlot.current !== null) { | ||
currentSlot.current.setTargeting(targeting); | ||
} | ||
}, [targeting]); | ||
@@ -869,0 +883,0 @@ // Set visibility |
{ | ||
"name": "@folklore/ads", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"description": "Ads library", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "39bba0091b4efb93b8636ae5c2eea5e46b350b90", | ||
"gitHead": "6a3484815046ba47850ba5d71e5eee9afe4adeb4", | ||
"dependencies": { | ||
@@ -56,0 +56,0 @@ "@folklore/hooks": "^0.0.44", |
73228
2327