@schibsted/niche-ads
Advanced tools
Comparing version 4.1.0 to 5.0.0
@@ -1,7 +0,4 @@ | ||
import AdContext from './AdContext'; | ||
import { AdContextProvider } from './AdContext'; | ||
import { fireImpressionTrackers } from './utils/appnexus'; | ||
import usePlacement from './usePlacement'; | ||
import useLoadAds from './useLoadAds'; | ||
import useClearPlacements from './useClearPlacements'; | ||
import { fireImpressionTrackers } from './utils/appnexus'; | ||
export { AdContext, AdContextProvider, usePlacement, useLoadAds, useClearPlacements, fireImpressionTrackers }; | ||
import Ads from './Ads'; | ||
export { Ads, usePlacement, fireImpressionTrackers }; |
@@ -1,6 +0,4 @@ | ||
import AdContext, { AdContextProvider } from './AdContext'; | ||
import { fireImpressionTrackers } from './utils/appnexus'; | ||
import usePlacement from './usePlacement'; | ||
import useLoadAds from './useLoadAds'; | ||
import useClearPlacements from './useClearPlacements'; | ||
export { AdContext, AdContextProvider, usePlacement, useLoadAds, useClearPlacements, fireImpressionTrackers }; | ||
import Ads from './Ads'; | ||
export { Ads, usePlacement, fireImpressionTrackers }; |
@@ -0,2 +1,5 @@ | ||
import type Ads from './Ads'; | ||
import type { PlacementConfig } from './types'; | ||
import { type Placement } from './types'; | ||
declare const usePlacement: (adsInstance: Ads, targetId: string) => (PlacementConfig | Placement | (() => void))[]; | ||
export default usePlacement; | ||
declare function usePlacement(targetId: any): any; |
@@ -1,7 +0,4 @@ | ||
import { useContext, useEffect, useMemo, useState } from 'react'; | ||
import { useEffect, useMemo, useState } from 'react'; | ||
import { showTag } from './utils/appnexus'; | ||
import AdContext from './AdContext'; | ||
import useEvent from './useEvent'; | ||
const usePlacement = (targetId) => { | ||
const { adsEventTarget } = useContext(AdContext); | ||
const usePlacement = (adsInstance, targetId) => { | ||
const [placement, setPlacement] = useState(); | ||
@@ -18,15 +15,19 @@ const [placementConfig, setPlacementConfig] = useState(); | ||
}; | ||
adsEventTarget.addEventListener(targetId, listener); | ||
adsEventTarget.dispatchEvent(new CustomEvent('resend', { detail: targetId })); | ||
const data = adsInstance.getPlacement(targetId); | ||
listener(new CustomEvent(targetId, { detail: data })); | ||
adsInstance.eventTarget.addEventListener(targetId, listener); | ||
return () => { | ||
adsEventTarget.removeEventListener(targetId, listener); | ||
adsInstance.eventTarget.removeEventListener(targetId, listener); | ||
}; | ||
}, [adsEventTarget, targetId]); | ||
const showAd = useEvent(() => { | ||
if (placement === null || placement === void 0 ? void 0 : placement.targetId) { | ||
showTag(placement.targetId); | ||
} | ||
}); | ||
return useMemo(() => [placement, showAd, placementConfig], [placement, placementConfig, showAd]); | ||
}, [adsInstance, targetId]); | ||
return useMemo(() => [ | ||
placement, | ||
() => { | ||
if (placement === null || placement === void 0 ? void 0 : placement.targetId) { | ||
showTag(placement.targetId); | ||
} | ||
}, | ||
placementConfig, | ||
], [placement, placementConfig]); | ||
}; | ||
export default usePlacement; |
@@ -10,3 +10,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { saveToLocalStorageWithExpiration, getFromLocalStorageWithExpiration } from './localStorage'; | ||
import { saveToLocalStorageWithExpiration, getFromLocalStorageWithExpiration, } from '@schibsted/niche-utils/lib/localStorage'; | ||
const CLIENT_ID = 'H3IYO2A4LD43YPFZIJLN'; | ||
@@ -13,0 +13,0 @@ const LOCAL_STORAGE_KEY = 'glimrTags'; |
@@ -0,2 +1,2 @@ | ||
declare function splitEvery<T>(chunkSize: number, array: T[]): T[][]; | ||
export default splitEvery; | ||
declare function splitEvery(chunkSize: any, array: any): any[]; |
function splitEvery(chunkSize, array) { | ||
return new Array(Math.ceil(array.length / chunkSize)) | ||
.fill() | ||
.fill(0) | ||
.map((_, i) => array.slice(i * chunkSize, i * chunkSize + chunkSize)); | ||
} | ||
export default splitEvery; |
{ | ||
"name": "@schibsted/niche-ads", | ||
"version": "4.1.0", | ||
"version": "5.0.0", | ||
"description": "Package containing ads logic reappearing across our projects", | ||
@@ -22,8 +22,2 @@ "main": "lib/index.js", | ||
}, | ||
"devDependencies": { | ||
"eslint-plugin-jsx-a11y": "^6.7.1", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-plugin-react": "^7.32.2", | ||
"eslint-plugin-react-hooks": "^4.6.0" | ||
}, | ||
"peerDependencies": { | ||
@@ -33,6 +27,6 @@ "react": ">= 16.8.1" | ||
"dependencies": { | ||
"@schibsted/niche-utils": "^0.1.0", | ||
"@schibsted/niche-utils": "^0.1.1", | ||
"glimr-sdk": "^3.3.3" | ||
}, | ||
"gitHead": "f59461556030b3d9fa02f11eea523e6da05a59c7" | ||
"gitHead": "bfedafe9f39182f0b90b6df9a1e7fd0eb6f3c070" | ||
} |
@@ -19,3 +19,3 @@ # Niche ads | ||
```bash | ||
npm run transpile:watch | ||
npm run dev | ||
``` | ||
@@ -22,0 +22,0 @@ |
@@ -1,2 +0,5 @@ | ||
import { saveToLocalStorageWithExpiration, getFromLocalStorageWithExpiration } from './localStorage'; | ||
import { | ||
saveToLocalStorageWithExpiration, | ||
getFromLocalStorageWithExpiration, | ||
} from '@schibsted/niche-utils/lib/localStorage'; | ||
@@ -3,0 +6,0 @@ const CLIENT_ID = 'H3IYO2A4LD43YPFZIJLN'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
1160
56372
29
1