Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions crates/js/lib/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ export interface AdUnit {
bids?: Bid[];
}

/** Minimal shape of a server-side auction slot injected into `window.tsjs.adSlots`. */
export interface AuctionSlot {
id: string;
gam_unit_path: string;
div_id: string;
formats: Array<[number, number]>;
targeting?: Record<string, string>;
}

/** Bid targeting data from the server-side auction, injected into `window.tsjs.bids`. */
export interface AuctionBidData {
hb_pb?: string;
hb_bidder?: string;
hb_adid?: string;
hb_cache_host?: string;
hb_cache_path?: string;
nurl?: string;
burl?: string;
/** Raw creative markup. Only present when `[debug] inject_adm_for_testing = true`. */
adm?: string;
}

export interface TsjsApi {
version: string;
que: Array<() => void>;
Expand All @@ -41,4 +63,20 @@ export interface TsjsApi {
error(...args: unknown[]): void;
debug(...args: unknown[]): void;
};

// ── Server-side auction runtime (populated by TS edge injection) ──────────
/** Ad slot definitions injected at <head> open. */
adSlots?: AuctionSlot[];
/** Winning bid targeting data injected before </body>. */
bids?: Record<string, AuctionBidData>;
/** Initialises GPT slots with server-side bid targeting and calls refresh(). */
adInit?: () => void;
/** GPT slot objects TS defined — used to destroy stale slots on SPA navigation. */
prevGptSlots?: unknown[];
/** Guards one-time-per-page enableSingleRequest/enableServices calls. */
servicesEnabled?: boolean;
/** Maps actualDivId → slotId for slotRenderEnded billing lookup. */
divToSlotId?: Record<string, string>;
/** Guards SPA pushState hook installation. */
spaHookInstalled?: boolean;
}
Loading
Loading