/** * Ad size configuration */ declare const ALLOWED_AD_SIZES: readonly [{ readonly width: 300; readonly height: 250; }, { readonly width: 320; readonly height: 50; }, { readonly width: 320; readonly height: 100; }]; type Size = (typeof ALLOWED_AD_SIZES)[number]; /** * Ad placement types - predefined or custom string */ type Placement = 'internal' | 'popup' | 'sidepanel' | 'content_script'; /** * Options for requesting an ad */ interface AdOptions { /** Placement identifier for the ad slot */ placement: Placement; /** Dimensions of the ad */ size: Size; /** Optional content categories for targeting */ categories?: string[]; /** Additional custom parameters */ [key: string]: any; } /** * Result returned from createAd() */ interface AdResult { /** Ready-to-append div element containing ad HTML */ element: HTMLDivElement; /** Unique impression ID for tracking */ impressionId: string; /** Optional click-through URL */ clickUrl?: string; } /** * SDK initialization configuration */ interface SDKConfig { /** Your PlayaYield API key */ apiKey: string; /** Base API URL (defaults to https://api.yourplatform.com) */ baseUrl?: string; /** * Enable verbose SDK logging to the console. * Defaults to false. Set to true during development to see detailed logs. * * You can also toggle logging at runtime without changing code by running * this in the extension's DevTools console: * localStorage.setItem('playayield:debug', 'true') */ debug?: boolean; } /** * Message types for chrome.runtime communication */ declare enum MessageType { AD_REQUEST = "AD_REQUEST", TRACK_EVENT = "TRACK_EVENT", TRACK_AVAILABLE = "TRACK_AVAILABLE", GET_CONFIG = "GET_CONFIG", PING = "PING", GET_SESSION_DATA = "GET_SESSION_DATA", UPDATE_SESSION_IMPRESSION = "UPDATE_SESSION_IMPRESSION", STOP_REFRESHABLE_AD = "STOP_REFRESHABLE_AD" } /** * Custom error types */ interface ManagedRefreshableAdOptions extends AdOptions { /** Container element or CSS selector where ad should be appended */ container: HTMLElement | string; } /** * Result returned from createManagedRefreshableAd() */ interface ManagedRefreshableAdResult { /** Stop refreshing and cleanup */ stop: () => void; /** Check if still active */ isActive: () => boolean; } /** * Initialize PlayaYield SDK in the background service worker * This sets up the message handler and stores your configuration globally * * Call this once in your background service worker with your API key and settings. * Content scripts and popups can then use createAd() without needing to initialize. * * @param config SDK configuration including API key * @throws {ConfigError} If configuration is invalid * * @example * ```ts * // background.ts * import { initializePlayaYield } from '@playanext/playa-yield-sdk'; * * initializePlayaYield({ * apiKey: 'your-api-key' * }); * ``` */ declare function initializePlayaYield(config: SDKConfig): void; /** * @playanext/playa-yield-sdk - Chrome Extension Ad Monetization SDK * Manifest V3 compliant ad SDK for Chrome extensions */ /** * Request and create an ad element * Returns a ready-to-append div element containing the ad HTML * * No initialization needed in content scripts - just call this function! * Make sure initializePlayaYield() is called in your background script. * * @param options Ad request options * @returns Promise resolving to AdResult with div element and metadata * @throws {ConfigError} If SDK not initialized in background * @throws {NetworkError} If ad request fails * * @example * ```ts * import { createAd } from '@playanext/playa-yield-sdk'; * * const { element, impressionId } = await createAd({ * placement: 'internal', * size: { width: 300, height: 250 }, * categories: ['tech', 'gaming'] * }); * * document.getElementById('ad-slot')!.appendChild(element); * ``` */ declare function createAd(options: AdOptions): Promise; /** * Create a fully managed refreshable ad * * The SDK handles: * - Appending the ad to your container * - Auto-cleanup when the container is removed from DOM * - All refresh logic internally * * @param options Configuration including container element or CSS selector * @returns Simple control object with stop() method * * @example * ```ts * // Simplest usage - just provide container * await createManagedRefreshableAd({ * container: '#ad-slot', * placement: 'sidepanel', * size: { width: 300, height: 250 } * }); * * // Or with element reference * await createManagedRefreshableAd({ * container: document.getElementById('ad-slot'), * placement: 'sidepanel', * size: { width: 300, height: 250 } * }); * ``` */ declare function createManagedRefreshableAd(options: ManagedRefreshableAdOptions): Promise; export { ALLOWED_AD_SIZES, type AdOptions, type AdResult, type ManagedRefreshableAdOptions, type ManagedRefreshableAdResult, MessageType, type Placement, type SDKConfig, type Size, createAd, createManagedRefreshableAd, initializePlayaYield };