@adhese/sdk-devtools 0.6.5 → 0.7.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 CHANGED
@@ -1,713 +1,12 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
- import * as zod from 'zod';
4
- import { TypeOf, ZodType } from 'zod';
5
- import { ComputedRef, Ref, MaybeRef } from '@vue/runtime-core';
6
-
7
- /**
8
- * Merge two types together. The resulting type will have all properties of both types, but if a property is present in
9
- * both types, the type of the second type will be used.
10
- */
11
- type Merge<T, U> = Omit<T, keyof U> & U;
12
-
13
- /**
14
- * Type that represents a URL string that starts with `http://` or `https://`.
15
- */
16
- type UrlString = `https://${string}.${string}` | `http://${string}.${string}`;
17
-
18
- type Event<T> = {
19
- /**
20
- * The listeners for this event. This is a set of functions that will be called when the event is dispatched.
21
- */
22
- listeners: Set<(data: T) => void | Promise<void>>;
23
- /**
24
- * Dispatches the event to all listeners. This is a synchronous operation.
25
- * @param data
26
- */
27
- dispatch(data: T): void;
28
- /**
29
- * Dispatches the event to all listeners. This is an asynchronous operation.
30
- * @param data
31
- */
32
- dispatchAsync(data: T): Promise<void>;
33
- /**
34
- * Adds a listener to the event.
35
- * @param listener
36
- */
37
- addListener(listener: (data: T) => void | Promise<void>): void;
38
- /**
39
- * Removes a listener from the event.
40
- * @param listener
41
- */
42
- removeListener(listener: (data: T) => void | Promise<void>): void;
43
- };
44
- type EventManagerGroup<Events extends Record<string, unknown>> = {
45
- [Key in keyof Events]: Readonly<Event<Events[Key]>>;
46
- };
47
- type EventManager<Events extends Record<string, unknown>> = {
48
- /**
49
- * Disposes of all listeners and clears the event manager. After calling this method, the event manager is no longer usable.
50
- */
51
- dispose(): void;
52
- } & EventManagerGroup<Events>;
53
- /**
54
- * Creates a new event manager with the given event names.
55
- *
56
- * @typeParam Events The events that the event manager will handle and their data types.
57
- */
58
- declare function createEventManager<Events extends Record<Name, unknown>, Name extends Readonly<string | number | symbol> = keyof Events>(): EventManager<Events>;
59
-
60
- declare class Config {
61
- auto?: boolean;
62
- debug?: boolean;
63
- renderFile?: string;
64
- cdn?: string;
65
- msgFile?: string;
66
- root?: string;
67
- to?: number;
68
- constructor(options?: {
69
- auto?: boolean;
70
- debug?: boolean;
71
- renderFile?: string;
72
- cdn?: string;
73
- msgFile?: string;
74
- root?: string;
75
- to?: number;
76
- });
77
- }
78
- declare class Position {
79
- html: string;
80
- id: string;
81
- src: string;
82
- meta?: Record<string, unknown>;
83
- config?: Record<string, unknown>;
84
- constructor(config: {
85
- id: string;
86
- src?: string;
87
- html: string;
88
- config?: PosConfig;
89
- });
90
- }
91
- declare class PosConfig {
92
- id: string;
93
- dest: string;
94
- constructor(posIDorObj: string | {
95
- bg?: string;
96
- css?: string;
97
- dest?: string;
98
- h?: number;
99
- id?: string;
100
- size?: string;
101
- tgt?: string;
102
- w?: number;
103
- z?: number;
104
- supports?: Record<string, unknown>;
105
- }, destID?: string, baseConf?: {
106
- bg?: string;
107
- css?: string;
108
- dest?: string;
109
- h?: number;
110
- id?: string;
111
- size?: string;
112
- tgt?: string;
113
- w?: number;
114
- z?: number;
115
- supports?: Record<string, unknown>;
116
- });
117
- }
118
-
119
- type SafeFrame = {
120
- config: Config;
121
- addPosition(positions: Ad, element: HTMLElement): Position;
122
- render(position: Position): Promise<void>;
123
- dispose(): void;
124
- };
125
-
126
- type SlotManager = {
127
- /**
128
- * Returns all slots that are currently registered and rendered.
129
- */
130
- getAll(): ReadonlyArray<AdheseSlot>;
131
- /**
132
- * Adds a new slot to the Adhese instance and renders it.
133
- */
134
- add(slot: Omit<AdheseSlotOptions, 'context'>): Readonly<AdheseSlot>;
135
- /**
136
- * Finds all slots in the DOM and adds them to the Adhese instance.
137
- */
138
- findDomSlots(): Promise<ReadonlyArray<AdheseSlot>>;
139
- /**
140
- * Returns the slot with the given name.
141
- */
142
- get(name: string): AdheseSlot | undefined;
143
- /**
144
- * Removes all slots from the Adhese instance and cleans up the slot manager.
145
- */
146
- dispose(): void;
147
- };
148
- type SlotManagerOptions = {
149
- /**
150
- * List of initial slots to add to the slot manager.
151
- */
152
- initialSlots?: ReadonlyArray<Merge<Omit<AdheseSlotOptions, 'containingElement' | 'context' | 'lazy'>, {
153
- containingElement: string;
154
- }>>;
155
- context: AdheseContext;
156
- };
157
-
158
- declare const baseSchema: zod.ZodObject<{
159
- adDuration: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
160
- adFormat: zod.ZodOptional<zod.ZodString>;
161
- adType: zod.ZodString;
162
- additionalCreativeTracker: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
163
- additionalViewableTracker: zod.ZodOptional<zod.ZodString>;
164
- adspaceEnd: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, Date | undefined, string>>;
165
- adspaceId: zod.ZodOptional<zod.ZodString>;
166
- adspaceKey: zod.ZodOptional<zod.ZodString>;
167
- adspaceStart: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, Date | undefined, string>>;
168
- advertiserId: zod.ZodOptional<zod.ZodString>;
169
- altText: zod.ZodOptional<zod.ZodString>;
170
- auctionable: zod.ZodOptional<zod.ZodUnion<[zod.ZodBoolean, zod.ZodLiteral<"">]>>;
171
- body: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodUnion<[zod.ZodEffects<zod.ZodString, Record<string, unknown> | readonly unknown[], string>, zod.ZodEffects<zod.ZodString, string, string>]>]>, string | Record<string, unknown> | readonly unknown[] | undefined, string>>;
172
- clickTag: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
173
- comment: zod.ZodOptional<zod.ZodString>;
174
- creativeName: zod.ZodOptional<zod.ZodString>;
175
- deliveryGroupId: zod.ZodOptional<zod.ZodString>;
176
- deliveryMultiples: zod.ZodOptional<zod.ZodString>;
177
- ext: zod.ZodOptional<zod.ZodString>;
178
- extension: zod.ZodOptional<zod.ZodObject<{
179
- mediaType: zod.ZodString;
180
- prebid: zod.ZodOptional<zod.ZodUnknown>;
181
- }, "strip", zod.ZodTypeAny, {
182
- mediaType: string;
183
- prebid?: unknown;
184
- }, {
185
- mediaType: string;
186
- prebid?: unknown;
187
- }>>;
188
- height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
189
- id: zod.ZodString;
190
- impressionCounter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
191
- libId: zod.ZodOptional<zod.ZodString>;
192
- orderId: zod.ZodOptional<zod.ZodString>;
193
- orderName: zod.ZodOptional<zod.ZodString>;
194
- orderProperty: zod.ZodOptional<zod.ZodString>;
195
- origin: zod.ZodUnion<[zod.ZodLiteral<"JERLICIA">, zod.ZodLiteral<"DALE">]>;
196
- originData: zod.ZodOptional<zod.ZodUnknown>;
197
- originInstance: zod.ZodOptional<zod.ZodString>;
198
- poolPath: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
199
- preview: zod.ZodOptional<zod.ZodUnion<[zod.ZodBoolean, zod.ZodLiteral<"">]>>;
200
- priority: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
201
- sfSrc: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
202
- share: zod.ZodOptional<zod.ZodString>;
203
- slotID: zod.ZodString;
204
- slotName: zod.ZodString;
205
- swfSrc: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
206
- tag: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodUnion<[zod.ZodEffects<zod.ZodString, Record<string, unknown> | readonly unknown[], string>, zod.ZodEffects<zod.ZodString, string, string>]>]>, string | Record<string, unknown> | readonly unknown[] | undefined, string>>;
207
- tagUrl: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
208
- timeStamp: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, Date | undefined, string>>;
209
- trackedImpressionCounter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
210
- tracker: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
211
- trackingUrl: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
212
- url: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
213
- viewableImpressionCounter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
214
- width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
215
- widthLarge: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">, zod.ZodNumber]>, string | undefined, string | number>>;
216
- }, "strip", zod.ZodTypeAny, {
217
- adType: string;
218
- id: string;
219
- origin: "JERLICIA" | "DALE";
220
- slotID: string;
221
- slotName: string;
222
- adDuration?: number | undefined;
223
- adFormat?: string | undefined;
224
- additionalCreativeTracker?: URL | undefined;
225
- additionalViewableTracker?: string | undefined;
226
- adspaceEnd?: Date | undefined;
227
- adspaceId?: string | undefined;
228
- adspaceKey?: string | undefined;
229
- adspaceStart?: Date | undefined;
230
- advertiserId?: string | undefined;
231
- altText?: string | undefined;
232
- auctionable?: boolean | "" | undefined;
233
- body?: string | Record<string, unknown> | readonly unknown[] | undefined;
234
- clickTag?: URL | undefined;
235
- comment?: string | undefined;
236
- creativeName?: string | undefined;
237
- deliveryGroupId?: string | undefined;
238
- deliveryMultiples?: string | undefined;
239
- ext?: string | undefined;
240
- extension?: {
241
- mediaType: string;
242
- prebid?: unknown;
243
- } | undefined;
244
- height?: number | undefined;
245
- impressionCounter?: URL | undefined;
246
- libId?: string | undefined;
247
- orderId?: string | undefined;
248
- orderName?: string | undefined;
249
- orderProperty?: string | undefined;
250
- originData?: unknown;
251
- originInstance?: string | undefined;
252
- poolPath?: URL | undefined;
253
- preview?: boolean | "" | undefined;
254
- priority?: number | undefined;
255
- sfSrc?: URL | undefined;
256
- share?: string | undefined;
257
- swfSrc?: URL | undefined;
258
- tag?: string | Record<string, unknown> | readonly unknown[] | undefined;
259
- tagUrl?: URL | undefined;
260
- timeStamp?: Date | undefined;
261
- trackedImpressionCounter?: URL | undefined;
262
- tracker?: URL | undefined;
263
- trackingUrl?: URL | undefined;
264
- url?: URL | undefined;
265
- viewableImpressionCounter?: URL | undefined;
266
- width?: number | undefined;
267
- widthLarge?: string | undefined;
268
- }, {
269
- adType: string;
270
- id: string;
271
- origin: "JERLICIA" | "DALE";
272
- slotID: string;
273
- slotName: string;
274
- adDuration?: string | undefined;
275
- adFormat?: string | undefined;
276
- additionalCreativeTracker?: string | undefined;
277
- additionalViewableTracker?: string | undefined;
278
- adspaceEnd?: string | undefined;
279
- adspaceId?: string | undefined;
280
- adspaceKey?: string | undefined;
281
- adspaceStart?: string | undefined;
282
- advertiserId?: string | undefined;
283
- altText?: string | undefined;
284
- auctionable?: boolean | "" | undefined;
285
- body?: string | undefined;
286
- clickTag?: string | undefined;
287
- comment?: string | undefined;
288
- creativeName?: string | undefined;
289
- deliveryGroupId?: string | undefined;
290
- deliveryMultiples?: string | undefined;
291
- ext?: string | undefined;
292
- extension?: {
293
- mediaType: string;
294
- prebid?: unknown;
295
- } | undefined;
296
- height?: string | undefined;
297
- impressionCounter?: string | undefined;
298
- libId?: string | undefined;
299
- orderId?: string | undefined;
300
- orderName?: string | undefined;
301
- orderProperty?: string | undefined;
302
- originData?: unknown;
303
- originInstance?: string | undefined;
304
- poolPath?: string | undefined;
305
- preview?: boolean | "" | undefined;
306
- priority?: string | undefined;
307
- sfSrc?: string | undefined;
308
- share?: string | undefined;
309
- swfSrc?: string | undefined;
310
- tag?: string | undefined;
311
- tagUrl?: string | undefined;
312
- timeStamp?: string | undefined;
313
- trackedImpressionCounter?: string | undefined;
314
- tracker?: string | undefined;
315
- trackingUrl?: string | undefined;
316
- url?: string | undefined;
317
- viewableImpressionCounter?: string | undefined;
318
- width?: string | undefined;
319
- widthLarge?: string | number | undefined;
320
- }>;
321
- type AdResponse = (TypeOf<typeof baseSchema> & {
322
- additionalCreatives?: ReadonlyArray<AdResponse> | string;
323
- });
324
- declare const adResponseSchema: ZodType<AdResponse>;
325
- type PreParsedAd = TypeOf<typeof adResponseSchema> & {
326
- additionalCreatives?: ReadonlyArray<PreParsedAd> | string;
327
- };
328
- type Ad<T = string | Record<string, unknown> | ReadonlyArray<unknown>> = Omit<PreParsedAd, 'tag'> & {
329
- tag: T | string;
330
- };
331
-
332
- type RenderMode = 'iframe' | 'inline';
333
- type AdheseSlotOptions = {
334
- /**
335
- * The format code of the slot. Used to find the correct element on the page to render the ad in. If the format is a
336
- * string, it is used as the format code. If the format is an array, the format code is determined by the query
337
- * detector.
338
- */
339
- format: string | ReadonlyArray<{
340
- format: string;
341
- query: string;
342
- }>;
343
- /**
344
- * If we have multiple slots with the same format, we can use this to differentiate between them.
345
- */
346
- slot?: string;
347
- /**
348
- * The element that contains the slot. Used to find the correct element on the page to render the ad in.
349
- */
350
- containingElement?: string | HTMLElement;
351
- /**
352
- * The parameters that are used to render the ad.
353
- */
354
- parameters?: Record<string, ReadonlyArray<string> | string>;
355
- /**
356
- * The Adhese context
357
- */
358
- context: AdheseContext;
359
- /**
360
- * The render mode of the slot.
361
- *
362
- * - `iframe`: The ad will be rendered in an iframe.
363
- * - `inline`: The ad will be rendered in the containing element.
364
- *
365
- * @default 'iframe'
366
- */
367
- renderMode?: RenderMode;
368
- /**
369
- * Callback that is called when the slot is disposed.
370
- */
371
- onDispose?(): void;
372
- /**
373
- * Callback that is called when the format of the slot changes.
374
- */
375
- onNameChange?(newName: string, oldName: string): void;
376
- /**
377
- * Callback that is called when the slot is rendered.
378
- */
379
- onRender?(element: HTMLElement): void;
380
- /**
381
- * Callback that is called before the ad is rendered. This can be used to modify the ad before it is rendered.
382
- * Particularly useful for rendering ads with custom HTML if the ad tag contains a JSON object.
383
- */
384
- onBeforeRender?(ad: Ad): Ad | void;
385
- } & ({
386
- /**
387
- * If the slot should be lazy loaded. This means that the ad will only be requested when the slot is in the viewport.
388
- * If `true`, the slot will handle the request itself and render the ad.
389
- */
390
- lazyLoading: true;
391
- lazyLoadingOptions?: {
392
- /**
393
- * The root margin of the intersection observer. This is used to determine when the slot is in the viewport.
394
- */
395
- rootMargin?: string;
396
- };
397
- } | {
398
- lazyLoading?: false;
399
- lazyLoadingOptions?: never;
400
- });
401
- type AdheseSlot = Merge<Omit<AdheseSlotOptions, 'onDispose' | 'context' | 'onFormatChange' | 'format'>, {
402
- /**
403
- * The name of the slot. This is used to identify the slot in the Adhese instance.
404
- *
405
- * The name is generated based on the location, format, and slot of the slot.
406
- */
407
- name: ComputedRef<string>;
408
- /**
409
- * The format code of the slot. Used to find the correct element on the page to render the ad in.
410
- *
411
- * If the format is a string, it is used as the format code. If the format is an array, the format code is determined
412
- * by the query detector.
413
- *
414
- * When you change the format, the slot will request a new ad from the API automatically.
415
- */
416
- format: Ref<string>;
417
- /**
418
- * The location of the slot. This is the location that is used to determine the current page URL.
419
- */
420
- location: string;
421
- /**
422
- * The parameters that are used to render the ad.
423
- */
424
- parameters: Map<string, ReadonlyArray<string> | string>;
425
- /**
426
- * Whether the viewability tracking pixel has been fired.
427
- */
428
- isViewabilityTracked: ComputedRef<boolean>;
429
- /**
430
- * Whether the impression tracking pixel has been fired.
431
- */
432
- isImpressionTracked: ComputedRef<boolean>;
433
- /**
434
- * Ad object that is fetched from the API.
435
- */
436
- ad: Ref<Ad | null>;
437
- /**
438
- * Renders the slot in the containing element. If no ad is provided, a new ad will be requested from the API.
439
- */
440
- render(ad?: Ad): Promise<HTMLElement>;
441
- /**
442
- * Returns the rendered element.
443
- */
444
- getElement(): HTMLElement | null;
445
- /**
446
- * Removes the slot from the DOM and cleans up the slot instance.
447
- */
448
- dispose(): void;
449
- }>;
450
-
451
- type AdRequestOptions = {
452
- /**
453
- * List of slots you want to fetch the ad for
454
- */
455
- slots: ReadonlyArray<{
456
- name: MaybeRef<string>;
457
- parameters: Map<string, ReadonlyArray<string> | string>;
458
- }>;
459
- context: AdheseContext;
460
- };
461
-
462
- /**
463
- * A log entry saved by the logger
464
- */
465
- type Log<T extends string> = {
466
- /**
467
- * The scope of the logger that created this log entry
468
- */
469
- scope: string;
470
- /**
471
- * The log level of this log entry
472
- */
473
- level: T;
474
- /**
475
- * The message of this log entry
476
- */
477
- message: string;
478
- /**
479
- * The attributes of this log entry
480
- */
481
- attributes?: unknown;
482
- /**
483
- * The timestamp of this log entry
484
- */
485
- timestamp: number;
486
- id: string;
487
- };
488
- type LogFunction = (message: string, attributes?: unknown) => void;
489
- type Logger<T extends string> = {
490
- [key in T]: LogFunction;
491
- } & {
492
- /**
493
- * The scope of the logger
494
- */
495
- readonly scope: string;
496
- /**
497
- * The event manager of the logger
498
- */
499
- events: ReturnType<typeof createEventManager<{
500
- log: Log<T>;
501
- reset: void;
502
- }>>;
503
- /**
504
- * Set the minimum log level threshold
505
- */
506
- setMinLogLevelThreshold(level: T): void;
507
- /**
508
- * Reset the minimum log level threshold to the default value
509
- */
510
- resetMinLogLevelThreshold(): void;
511
- /**
512
- * Get the current minimum log level threshold
513
- */
514
- getMinLogLevelThreshold(): T;
515
- /**
516
- * Get the logs that were created by this logger
517
- */
518
- getLogs(): ReadonlyArray<Log<T>>;
519
- /**
520
- * Reset the logs that were created by this logger
521
- */
522
- resetLogs(): void;
523
- };
524
-
525
- declare const logger: Logger<"debug" | "error" | "trace" | "info" | "warn">;
526
-
527
- type AdheseOptions = {
528
- /**
529
- * The Adhese account name.
530
- */
531
- account: string;
532
- /**
533
- * The url that is used to connect to the Adhese ad server. Pass a custom URL if you want to use your own domain for
534
- * the connection.
535
- *
536
- * @default 'https://ads-{{account}}.adhese.com'
537
- */
538
- host?: UrlString;
539
- /**
540
- * The url that is used to connect to the Adhese pool server. Pass a custom URL if you want to use your own domain for
541
- * the connection.
542
- *
543
- * @default 'https://pool-{{account}}.adhese.com'
544
- */
545
- poolHost?: UrlString;
546
- /**
547
- * The page location. This is used to determine the current page location identifier.
548
- *
549
- * @default location.pathname
550
- */
551
- location?: string;
552
- /**
553
- * The requestAds type to use for the Adhese API requests. This can be either `GET` or `POST`. `POST` is the default
554
- * and offers the most options. `GET` is more limited as it needs pass its data as search parameters but can be used
555
- * in environments where `POST` requests are not allowed.
556
- *
557
- * @default 'POST'
558
- */
559
- requestType?: 'GET' | 'POST';
560
- /**
561
- * Enable debug logging.
562
- *
563
- * @default false
564
- */
565
- debug?: boolean;
566
- /**
567
- * Find all slots in the DOM and add them to the Adhese instance during initialization.
568
- *
569
- * @default false
570
- */
571
- findDomSlotsOnLoad?: boolean;
572
- /**
573
- * Additional parameters to send with each request. Make sure that the keys of a parameter only contain `2` characters.
574
- */
575
- parameters?: Record<string, ReadonlyArray<string> | string>;
576
- /**
577
- * The consent type to use for the Adhese API requests. This can be either `true` or `false`. `false` is the default and
578
- * will send all consent data to the Adhese API. `false` will send no consent data to the Adhese API.
579
- *
580
- * @default false
581
- */
582
- consent?: boolean;
583
- /**
584
- * Will log the `document.referrer` to the Adhese API in a BASE64 string with the `re` parameter.
585
- *
586
- * @default true
587
- */
588
- logReferrer?: boolean;
589
- /**
590
- * Will log the `window.location.href` to the Adhese API in a BASE64 string with the `ur` parameter.
591
- *
592
- * @default true
593
- */
594
- logUrl?: boolean;
595
- /**
596
- * If `true`, ads will be rendered immediately after they are fetched from the API. If `false`, ads will only be
597
- * rendered when the slot is in the viewport.
598
- *
599
- * @default false
600
- */
601
- eagerRendering?: boolean;
602
- /**
603
- * The query detector options for the Adhese instance.
604
- */
605
- queries?: Record<string, string>;
606
- safeFrame?: boolean;
607
- } & ({
608
- viewabilityTracking?: true;
609
- /**
610
- * Options for the viewability tracking of the ads. If `true` or `undefined`, the default viewability tracking options will be used.
611
- *
612
- * @default true
613
- */
614
- viewabilityTrackingOptions?: {
615
- /**
616
- * Fraction of the ad that needs to be in the viewport for the ad to be considered viewable.
617
- *
618
- * @default 0.2
619
- */
620
- threshold?: number;
621
- /**
622
- * The duration the ad needs to be in the viewport for the ad to be considered viewable in milliseconds.
623
- *
624
- * @default 1000
625
- */
626
- duration?: number;
627
- /**
628
- * The margin around the viewport where the ad is considered viewable.
629
- *
630
- * @default '0px'
631
- */
632
- rootMargin?: string;
633
- };
634
- } | {
635
- viewabilityTracking?: false;
636
- viewabilityTrackingOptions?: never;
637
- }) & Pick<SlotManagerOptions, 'initialSlots'>;
638
- type MergedOptions = Merge<AdheseOptions, Required<Pick<AdheseOptions, 'host' | 'poolHost' | 'location' | 'requestType' | 'debug' | 'initialSlots' | 'findDomSlotsOnLoad' | 'consent' | 'logUrl' | 'logReferrer' | 'eagerRendering' | 'viewabilityTracking'>>>;
639
- type AdheseEvents = {
640
- locationChange: string;
641
- consentChange: boolean;
642
- addSlot: AdheseSlot;
643
- removeSlot: AdheseSlot;
644
- changeSlots: ReadonlyArray<AdheseSlot>;
645
- responseReceived: ReadonlyArray<Ad>;
646
- requestAd: AdRequestOptions;
647
- requestError: Error;
648
- previewReceived: ReadonlyArray<Ad>;
649
- parametersChange: Map<string, ReadonlyArray<string> | string>;
650
- debugChange: boolean;
651
- };
652
- type Adhese = Omit<AdheseOptions, 'location' | 'parameters' | 'consent'> & Merge<SlotManager, {
653
- /**
654
- * The parameters that are used for all ads.
655
- */
656
- parameters: Map<string, ReadonlyArray<string> | string>;
657
- /**
658
- * The event manager for the Adhese instance.
659
- */
660
- events: EventManager<AdheseEvents>;
661
- context: AdheseContext;
662
- /**
663
- * Returns the current page location.
664
- */
665
- getLocation(): string;
666
- /**
667
- * Sets the current page location.
668
- */
669
- setLocation(location: string): void;
670
- /**
671
- * Returns the current consent type.
672
- */
673
- getConsent(): boolean;
674
- /**
675
- * Sets the current consent type.
676
- */
677
- setConsent(consent: boolean): void;
678
- /**
679
- * Adds a new slot to the Adhese instance and renders it.
680
- */
681
- addSlot(slot: Omit<AdheseSlotOptions, 'location' | 'context'>): Promise<Readonly<AdheseSlot>>;
682
- /**
683
- * Finds all slots in the DOM and adds them to the Adhese instance.
684
- */
685
- findDomSlots(): Promise<ReadonlyArray<AdheseSlot>>;
686
- /**
687
- * Removes all slots from the Adhese instance and cleans up the Adhese instance.
688
- *
689
- * After calling this method, the Adhese instance is no longer usable.
690
- */
691
- dispose(): void;
692
- /**
693
- * Toggles the debug mode of the Adhese instance.
694
- */
695
- toggleDebug(): Promise<boolean>;
696
- }>;
697
- type AdheseContext = Partial<Pick<Adhese, 'events' | 'getAll' | 'get' | 'parameters'>> & {
698
- location: string;
699
- consent: boolean;
700
- options: Readonly<MergedOptions>;
701
- logger: typeof logger;
702
- debug: boolean;
703
- safeFrame?: SafeFrame;
704
- };
3
+ import { AdheseContext, AdhesePlugin } from '@adhese/sdk';
705
4
 
706
5
  declare function Devtools$1({ adheseContext }: {
707
6
  adheseContext: AdheseContext;
708
7
  }): ReactElement;
709
8
 
710
- declare function createDevtools(context: AdheseContext): Promise<() => void>;
9
+ declare const createDevtools: AdhesePlugin;
711
10
  declare const Devtools: react.LazyExoticComponent<typeof Devtools$1>;
712
11
 
713
12
  export { Devtools, createDevtools };