@overlayed/ads 1.0.1 → 3.0.1
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/index.d.ts +19 -45
- package/dist/index.js +1 -1
- package/package.json +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type DivMapping = {
|
|
3
|
+
divId: string;
|
|
4
|
+
baseDivId: string;
|
|
5
|
+
targeting?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
1
8
|
//#region src/utils.d.ts
|
|
2
|
-
|
|
3
9
|
/**
|
|
4
10
|
* Gets a new script element that when mounted, will load the ads script. You should append this to the document head.
|
|
5
11
|
*
|
|
@@ -32,67 +38,35 @@ declare function getAdsScriptElement({
|
|
|
32
38
|
*/
|
|
33
39
|
declare function getAdsScriptUrl(): string;
|
|
34
40
|
//#endregion
|
|
35
|
-
//#region src/
|
|
41
|
+
//#region src/aditude.d.ts
|
|
36
42
|
/**
|
|
37
|
-
* Sets
|
|
43
|
+
* Sets page-level targeting that is applied to subsequent ad requests.
|
|
38
44
|
*
|
|
39
45
|
* WARNING: You may not pass any user-identifiable data (including names, addresses, or user IDs) in targeting.
|
|
40
46
|
*
|
|
41
|
-
* @param
|
|
42
|
-
* @param value - The value to set.
|
|
47
|
+
* @param targeting - Key-value targeting pairs for the page.
|
|
43
48
|
* @returns void
|
|
44
49
|
*/
|
|
45
|
-
declare function
|
|
50
|
+
declare function setPageTargeting(targeting: Record<string, string>): void;
|
|
46
51
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* WARNING: You may not pass any user-identifiable data (including names, addresses, or user IDs) in targeting.
|
|
52
|
+
* Requests ads for the given div mappings. Call this on initial mount and whenever
|
|
53
|
+
* the page context changes (e.g. route navigation) to refresh ad fills.
|
|
50
54
|
*
|
|
51
|
-
*
|
|
52
|
-
* @returns void
|
|
53
|
-
*/
|
|
54
|
-
declare function setKvs(kvs: Record<string, string>): void;
|
|
55
|
-
/**
|
|
56
|
-
* Sets whether ads are enabled or not
|
|
57
|
-
*
|
|
58
|
-
* @param enabled - Whether ads are enabled or not.
|
|
59
|
-
* @returns void
|
|
60
|
-
*/
|
|
61
|
-
declare function setAdsEnabled(enabled: boolean): void;
|
|
62
|
-
/**
|
|
63
|
-
* Provide a user ID (uid) for targeting. Variadic.
|
|
64
|
-
*
|
|
65
|
-
* Providing a UID significantly improves ad performance. As such, it is optional, but highly recommended.
|
|
66
|
-
*
|
|
67
|
-
* We comply with all privacy regulations and do not store any user-identifiable data. Once passed to RevIQ, the UID is normalized and then hashed; we never store the original value.
|
|
68
|
-
*
|
|
69
|
-
* If the user has opted out of tracking, the UID will not be stored or transmitted. Thus it is safe to call this function regardless of the user’s tracking preferences.
|
|
70
|
-
*
|
|
71
|
-
* @param uid - The user ID to set.
|
|
72
|
-
* @param uid.u - The username.
|
|
73
|
-
* @param uid.e - The email.
|
|
74
|
-
* @param uid.p - The phone.
|
|
75
|
-
* @returns void
|
|
76
|
-
*/
|
|
77
|
-
declare function setUid(uid: {
|
|
78
|
-
u?: string;
|
|
79
|
-
e?: string;
|
|
80
|
-
p?: string;
|
|
81
|
-
}): void;
|
|
82
|
-
/**
|
|
83
|
-
* Shows the consent dialog
|
|
55
|
+
* WARNING: You may not pass any user-identifiable data in per-mapping targeting.
|
|
84
56
|
*
|
|
57
|
+
* @param mappings - Div mappings describing which ad slots to (re)fill and their targeting.
|
|
85
58
|
* @returns void
|
|
86
59
|
*/
|
|
87
|
-
declare function
|
|
60
|
+
declare function refreshAdsViaDivMappings(mappings: DivMapping[]): void;
|
|
88
61
|
//#endregion
|
|
89
62
|
//#region src/index.d.ts
|
|
90
63
|
/**
|
|
91
64
|
* Initializes the Overlayed Ads.
|
|
92
65
|
* Overlayed must have been initialized on the electron side.
|
|
93
66
|
*
|
|
94
|
-
*
|
|
67
|
+
* Sets the `app_id` page targeting. Safe to call before the ads script has loaded —
|
|
68
|
+
* the command is queued and drained once the provider is ready.
|
|
95
69
|
*/
|
|
96
70
|
declare function init(): void;
|
|
97
71
|
//#endregion
|
|
98
|
-
export { getAdsScriptElement, getAdsScriptUrl, init,
|
|
72
|
+
export { type DivMapping, getAdsScriptElement, getAdsScriptUrl, init, refreshAdsViaDivMappings, setPageTargeting };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,...t){console.error(`[Overlayed] ${e}`,...t)}function t(e,...t){console.info(`[Overlayed] ${e}`,...t)}function n(e){globalThis.
|
|
1
|
+
function e(e,...t){console.error(`[Overlayed] ${e}`,...t)}function t(e,...t){console.info(`[Overlayed] ${e}`,...t)}function n(e){globalThis.tude=globalThis.tude||{cmd:[]},globalThis.tude.cmd=globalThis.tude.cmd||[],globalThis.tude.cmd.push(()=>e(globalThis.tude))}function r({onError:e}){try{let t=i(),n=document.createElement(`script`);return n.async=!0,n.src=t,n.onerror=n=>{e(n),console.error(`[Overlayed] Failed to load ads script: ${t}`,n)},n.onload=()=>{console.info(`[Overlayed] Ads script loaded successfully.`)},n}catch(e){console.error(`[Overlayed] Failed to create ads script element: ${String(e)}`);return}}function i(){if(URL.canParse(window.__overlayed.application.siteUrl))return`https://htlbid.com/v3/${new URL(window.__overlayed.application.siteUrl).hostname}/htlbid.js`;throw Error(`Invalid site URL`)}function a(e){n(t=>{t.setPageTargeting(e)})}function o(e){n(t=>{t.refreshAdsViaDivMappings(e)})}function s(){if(!(typeof window>`u`)){if(!window.__overlayed){e(`Failed to initialize ads - could not find overlayed instance`);return}a({app_id:window.__overlayed.application.slug}),t(`Ads initialized!`)}}export{r as getAdsScriptElement,i as getAdsScriptUrl,s as init,o as refreshAdsViaDivMappings,a as setPageTargeting};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlayed/ads",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Overlayed ads",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -30,11 +30,9 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@ark/attest": "^0.
|
|
34
|
-
"happy-dom": "^
|
|
35
|
-
"
|
|
36
|
-
"typescript": "^5.9.3",
|
|
37
|
-
"vitest": "^3.2.4"
|
|
33
|
+
"@ark/attest": "^0.56.0",
|
|
34
|
+
"happy-dom": "^20.9.0",
|
|
35
|
+
"typescript": "^6.0.3"
|
|
38
36
|
},
|
|
39
37
|
"peerDependenciesMeta": {
|
|
40
38
|
"typescript": {
|