@dreamsengine/dreams-ad-engine 0.1.6 → 0.2.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/package.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "name": "@dreamsengine/dreams-ad-engine",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/dreams-ad-engine.js",
7
7
  "module": "./dist/dreams-ad-engine.js",
8
+ "types": "./types/main.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/main.d.ts",
12
+ "import": "./dist/dreams-ad-engine.js",
13
+ "default": "./dist/dreams-ad-engine.js"
14
+ },
15
+ "./dist/*": "./dist/*"
16
+ },
8
17
  "description": "A component to render Google Ads",
9
18
  "files": [
10
19
  "dist",
20
+ "types",
11
21
  "CHANGELOG.md"
12
22
  ],
13
23
  "scripts": {
@@ -0,0 +1,20 @@
1
+ import type { DreamsAdMapping } from "../dreamsAdEngine/types/interfaces";
2
+ import type { AdConfigInit, LazyLoadConfig, SlotConfig } from "./config.types";
3
+ export declare class DreamsAdConfig {
4
+ private static instance;
5
+ static init(config: AdConfigInit): void;
6
+ static isInitialized(): boolean;
7
+ static getNetworkId(): string;
8
+ static getSitePrefix(): string;
9
+ static getPubId(): string | undefined;
10
+ static getBidTimeout(): number;
11
+ static getDefaultLazyLoad(): LazyLoadConfig;
12
+ static getSlot(slotName: string): SlotConfig | undefined;
13
+ static getSlotMapping(slotName: string): DreamsAdMapping[];
14
+ static getSlotSizing(slotName: string): number[][];
15
+ static getSlotPosition(slotName: string): string;
16
+ static buildAdUnit(slotName: string): string;
17
+ static registerSlot(name: string, config: SlotConfig): void;
18
+ static reset(): void;
19
+ private static assertInitialized;
20
+ }
@@ -0,0 +1,22 @@
1
+ import type { DreamsAdMapping } from "../dreamsAdEngine/types/interfaces";
2
+ export interface LazyLoadConfig {
3
+ fetchMarginPercent: number;
4
+ renderMarginPercent: number;
5
+ mobileScaling: number;
6
+ }
7
+ export interface SlotConfig {
8
+ mapping: DreamsAdMapping[];
9
+ sizing: number[][];
10
+ position?: "top" | "box" | "footer" | "interstitial";
11
+ }
12
+ export interface AdConfigInit {
13
+ networkId: string;
14
+ sitePrefix: string;
15
+ pubId?: string;
16
+ bidTimeout?: number;
17
+ defaultLazyLoad?: LazyLoadConfig;
18
+ slots?: Record<string, SlotConfig>;
19
+ }
20
+ export interface AdConfigData extends Required<Omit<AdConfigInit, "slots">> {
21
+ slots: Record<string, SlotConfig>;
22
+ }
@@ -0,0 +1,2 @@
1
+ import type { SlotConfig } from "./config.types";
2
+ export declare const DEFAULT_SLOTS: Record<string, SlotConfig>;
@@ -0,0 +1,3 @@
1
+ export { DreamsAdConfig } from "./config.provider";
2
+ export { DEFAULT_SLOTS } from "./default-mappings";
3
+ export type { AdConfigInit, LazyLoadConfig, SlotConfig, } from "./config.types";
@@ -0,0 +1,37 @@
1
+ import { LitElement } from "lit";
2
+ import type { TemplateResult } from "lit/html.js";
3
+ import "../types/interfaces";
4
+ import { DreamsAdMapping, DreamsAdTargeting } from "../types/interfaces";
5
+ export declare class DreamsAdComponent extends LitElement {
6
+ #private;
7
+ static styles: import("lit").CSSResult;
8
+ static initialized: boolean;
9
+ static old_url: string;
10
+ static initialized_aps: boolean;
11
+ networkId: string;
12
+ adUnit: string;
13
+ divId: string;
14
+ slot: string;
15
+ mapping: DreamsAdMapping[];
16
+ sizing: number[][];
17
+ targeting: DreamsAdTargeting[];
18
+ autoTargeting: boolean;
19
+ private resolvedTargeting;
20
+ setCentering: boolean;
21
+ enableLazyLoad: boolean;
22
+ configLazyLoad: {
23
+ fetchMarginPercent: number;
24
+ renderMarginPercent: number;
25
+ mobileScaling: number;
26
+ };
27
+ refresh: boolean;
28
+ enableTitle: boolean;
29
+ apstag: boolean;
30
+ pubId: string;
31
+ bidTimeout: number;
32
+ title: string;
33
+ adLoaded: boolean;
34
+ connectedCallback(): void;
35
+ firstUpdated(): Promise<void>;
36
+ protected render(): TemplateResult;
37
+ }
@@ -0,0 +1 @@
1
+ export * from './components/ad.component';
@@ -0,0 +1,50 @@
1
+ export interface Googletag {
2
+ cmd: Array<() => void>;
3
+ pubads: () => PubAdsService;
4
+ defineSlot: (adUnitPath: string, size: Array<number> | Array<Array<number>>, divId: string) => Slot;
5
+ display: (divId: string) => void;
6
+ enableServices: () => void;
7
+ sizeMapping: () => SizeMappingArray;
8
+ destroySlots: (slots?: Slot[]) => void;
9
+ }
10
+ export interface DreamsAdMapping {
11
+ viewport: [number, number];
12
+ sizing: [number, number][];
13
+ }
14
+ export interface DreamsAdTargeting {
15
+ key: string;
16
+ value: string;
17
+ }
18
+ interface SizeMappingArray {
19
+ addSize(viewportSize: [number, number], slotSize: [number, number][]): SizeMappingArray;
20
+ build(): SizeMappingArray[];
21
+ }
22
+ interface LazyLoadObject {
23
+ fetchMarginPercent: number;
24
+ renderMarginPercent: number;
25
+ mobileScaling: number;
26
+ }
27
+ interface PubAdsService {
28
+ disableInitialLoad: () => void;
29
+ enableSingleRequest: () => void;
30
+ refresh: (slots?: Slot[]) => void;
31
+ addService: (service: ServiceType) => Slot;
32
+ addEventListener: (eventType: string, handler: (event: any) => void) => void;
33
+ setCentering: (centerAds: boolean) => void;
34
+ enableLazyLoad: (config: LazyLoadObject) => void;
35
+ }
36
+ interface Slot {
37
+ setTargeting: (key: string, value: string) => Slot;
38
+ addService: (service: ServiceType) => Slot;
39
+ defineSizeMapping(sizeMapping: SizeMappingArray[]): Slot;
40
+ }
41
+ type ServiceType = PubAdsService;
42
+ declare global {
43
+ interface Window {
44
+ googletag: Googletag;
45
+ dreamsSlotsToUpdate: Slot[];
46
+ dreamsAllSlots: Slot[];
47
+ apstag: any;
48
+ }
49
+ }
50
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from "./dreamsAdEngine/";
2
+ export * from "./targeting/";
3
+ export * from "./config/";
@@ -0,0 +1,2 @@
1
+ export { DreamsTargetingService } from "./targeting.service";
2
+ export type { DFPContext, TargetingOptions, TargetingResult, } from "./targeting.types";
@@ -0,0 +1,12 @@
1
+ import type { DreamsAdTargeting } from "../dreamsAdEngine/types/interfaces";
2
+ import type { DFPContext, TargetingOptions, TargetingResult } from "./targeting.types";
3
+ export declare class DreamsTargetingService {
4
+ private static cache;
5
+ private static cacheUrl;
6
+ private static pendingPromise;
7
+ static getTargeting(options?: TargetingOptions): Promise<TargetingResult>;
8
+ private static pollForContext;
9
+ static buildFromContext(ctx: DFPContext, options?: TargetingOptions): DreamsAdTargeting[];
10
+ static clearCache(): void;
11
+ static getTargetingSync(): DreamsAdTargeting[] | null;
12
+ }
@@ -0,0 +1,29 @@
1
+ import type { DreamsAdTargeting } from "../dreamsAdEngine/types/interfaces";
2
+ export interface TargetingOptions {
3
+ contextKey?: string;
4
+ maxRetries?: number;
5
+ retryInterval?: number;
6
+ includeUrl?: boolean;
7
+ customSegmentFn?: string;
8
+ }
9
+ export interface DFPContext {
10
+ postId?: string;
11
+ catId?: string;
12
+ tagId?: string;
13
+ typeId?: string;
14
+ taxId?: string;
15
+ dataSection?: {
16
+ catName?: string;
17
+ author?: string;
18
+ };
19
+ }
20
+ export interface TargetingResult {
21
+ targeting: DreamsAdTargeting[];
22
+ source: "cache" | "context" | "timeout";
23
+ }
24
+ declare global {
25
+ interface Window {
26
+ dfp?: Record<string, DFPContext>;
27
+ _rl_gen_sg?: () => string;
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ export * from "./features/";
package/dist/index.html DELETED
@@ -1,62 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Dreams Ad Engine</title>
8
- <script
9
- async
10
- id="gads-js"
11
- src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"
12
- defer
13
- ></script>
14
- <script
15
- async
16
- id="apstag-js"
17
- src="https://c.amazon-adsystem.com/aax2/apstag.js"
18
- defer
19
- ></script>
20
- <script type="module" crossorigin src="./dreams-ad-engine.js"></script>
21
- </head>
22
- <body>
23
- <!-- apstag
24
- pubId="1d96f569-faca-48fb-8e78-c679f28ea4a2" -->
25
- <dreams-ad-engine
26
- networkId="270959339"
27
- adUnit="fco-is-t-02"
28
- mapping='[{"viewport":[320,0],"sizing":[[300,250],[320,50]]},{"viewport":[760,0],"sizing":[[728,90]]},{"viewport":[970,0],"sizing":[[970,90],[728,90],[728,90]]}]'
29
- sizing="[[300,250],[320,50],[728,90],[970,90]]"
30
- minHeight="600"
31
- apstag
32
- pubId="1d96f569-faca-48fb-8e78-c679f28ea4a2"
33
- targeting='[{"key":"url","value": "/"},{"key":"catName","value":"Home"}]'
34
- >
35
- </dreams-ad-engine>
36
- <dreams-ad-engine
37
- networkId="270959339"
38
- adUnit="fco-is-t-03"
39
- mapping='[{"viewport":[320,0],"sizing":[[300,250],[320,50]]},{"viewport":[760,0],"sizing":[[728,90]]},{"viewport":[970,0],"sizing":[[970,90],[728,90],[728,90]]}]'
40
- sizing="[[300,250],[320,50],[728,90],[970,90]]"
41
- apstag
42
- pubId="1d96f569-faca-48fb-8e78-c679f28ea4a2"
43
- >
44
- </dreams-ad-engine>
45
- <dreams-ad-engine
46
- networkId="270959339"
47
- adUnit="fco-is-t-04"
48
- mapping='[{"viewport":[320,0],"sizing":[[300,250],[320,50]]},{"viewport":[760,0],"sizing":[[728,90]]},{"viewport":[970,0],"sizing":[[970,90],[728,90],[728,90]]}]'
49
- sizing="[[300,250],[320,50],[728,90],[970,90]]"
50
- >
51
- </dreams-ad-engine>
52
- <dreams-ad-engine
53
- networkId="270959339"
54
- adUnit="fco-is-b-01"
55
- mapping='[{"viewport":[320,0],"sizing":[[300,250],[300,600]]}]'
56
- sizing="[[300,250],[300,600]]"
57
- enableTitle="false"
58
- minHeight="600"
59
- >
60
- </dreams-ad-engine>
61
- </body>
62
- </html>