@overlayed/ads 0.2.1 → 1.0.0
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 +35 -1
- package/dist/index.js +1 -1
- package/package.json +15 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
//#region src/utils.d.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets a new script element that when mounted, will load the ads script. You should append this to the document head.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const script = getAdsScriptElement({
|
|
9
|
+
* onError: () => {
|
|
10
|
+
* // Should never happen, but you should have some logging or observability here since it's a critical part of the ads setup
|
|
11
|
+
* }
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* if(script) {
|
|
15
|
+
* document.head.appendChild(script);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @returns The script element or undefined if the ads script could not be created
|
|
20
|
+
*/
|
|
21
|
+
declare function getAdsScriptElement({
|
|
22
|
+
onError
|
|
23
|
+
}: {
|
|
24
|
+
onError: (event: Event | string) => void;
|
|
25
|
+
}): HTMLScriptElement | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the URL of the ads script
|
|
28
|
+
*
|
|
29
|
+
* @throws If the site URL is invalid - this should never happen
|
|
30
|
+
* @throws If the overlayed instance is not ready
|
|
31
|
+
* @returns The URL of the ads script
|
|
32
|
+
*/
|
|
33
|
+
declare function getAdsScriptUrl(): string;
|
|
34
|
+
//#endregion
|
|
1
35
|
//#region src/reviq.d.ts
|
|
2
36
|
/**
|
|
3
37
|
* Sets a key-value pair for optional targeting
|
|
@@ -61,4 +95,4 @@ declare function showConsent(): void;
|
|
|
61
95
|
*/
|
|
62
96
|
declare function init(): void;
|
|
63
97
|
//#endregion
|
|
64
|
-
export { init, setAdsEnabled, setKv, setKvs, setUid, showConsent };
|
|
98
|
+
export { getAdsScriptElement, getAdsScriptUrl, init, setAdsEnabled, setKv, setKvs, setUid, showConsent };
|
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.reviq=globalThis.reviq||[],globalThis.reviq.push(e)}function r(
|
|
1
|
+
function e(e,...t){console.error(`[Overlayed] ${e}`,...t)}function t(e,...t){console.info(`[Overlayed] ${e}`,...t)}function n(e){globalThis.reviq=globalThis.reviq||[],globalThis.reviq.push(e)}function r(){return typeof window>`u`?!1:!(`__overlayed`in window)||!(`__overlayedRuntime`in window)||!window.__overlayed||!window.__overlayedRuntime?(e(`Could not find overlayed instance or runtime - did you import the preload script?`),!1):!0}function i({onError:e}){try{let t=a(),n=document.createElement(`script`);return n.type=`module`,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: ${e}`);return}}function a(){if(URL.canParse(window.__overlayed.application.siteUrl))return`//js.rev.iq/${new URL(window.__overlayed.application.siteUrl).hostname}`;throw Error(`Invalid site URL`)}function o(t,r){if(t===`app_id`){e(`[Overlayed] app_id is a reserved key`);return}n(e=>{e.setKv(t,r)})}function s(e,t){n(n=>{n.setKv(e,t)})}function c(t){if(t.app_id){e(`[Overlayed] app_id is a reserved key`);return}n(e=>{e.setKvs(t)})}function l(e){n(t=>{t.setAdsEnabled(e)})}function u(e){if(!r()||e.u){n(t=>{t.setUid(e)});return}n(t=>{t.setUid({...e,u:window.__overlayedRuntime?.userId})})}function d(){n(e=>{e.showConsent()})}function f(){if(typeof window>`u`)return;if(!window.__overlayed){e(`[Overlayed] Failed to initialize ads - could not find overlayed instance`);return}s(`app_id`,window.__overlayed.application.slug);let n=window.__overlayedRuntime?.userId;n===void 0?e(`[Overlayed] Could not find overlayed runtime - did you import the preload script?`):u({u:n}),t(`[Overlayed] Ads initialized!`)}export{i as getAdsScriptElement,a as getAdsScriptUrl,f as init,l as setAdsEnabled,o as setKv,c as setKvs,u as setUid,d as showConsent};
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlayed/ads",
|
|
3
|
-
"
|
|
4
|
-
"homepage": "https://overlayed.gg",
|
|
5
|
-
"version": "0.2.1",
|
|
3
|
+
"version": "1.0.0",
|
|
6
4
|
"description": "Overlayed ads",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"typescript"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://overlayed.gg",
|
|
7
9
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
10
|
+
"author": "overlayed.gg",
|
|
8
11
|
"repository": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/overlayed-gg/overlayed-typescript"
|
|
11
14
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/**/*"
|
|
14
17
|
],
|
|
15
18
|
"type": "module",
|
|
16
19
|
"main": "./dist/index.js",
|
|
@@ -23,17 +26,9 @@
|
|
|
23
26
|
"default": "./dist/index.js"
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist/**/*"
|
|
28
|
-
],
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"peerDependenciesMeta": {
|
|
33
|
-
"typescript": {
|
|
34
|
-
"optional": true
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
32
|
"devDependencies": {
|
|
38
33
|
"@ark/attest": "^0.49.0",
|
|
39
34
|
"happy-dom": "^19.0.2",
|
|
@@ -41,6 +36,11 @@
|
|
|
41
36
|
"typescript": "^5.9.3",
|
|
42
37
|
"vitest": "^3.2.4"
|
|
43
38
|
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"typescript": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=20.10.0"
|
|
46
46
|
}
|