@adhese/sdk 0.21.0 → 0.21.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @adhese/sdk
2
2
 
3
+ ## 0.21.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1feb9ff: Fix types not being published
8
+
3
9
  ## 0.21.0
4
10
 
5
11
  ### Minor Changes
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const name = "@adhese/sdk";
4
- const version = "0.21.0";
4
+ const version = "0.21.1";
5
5
  exports.name = name;
6
6
  exports.version = version;
7
7
  //# sourceMappingURL=package.json.cjs.map
@@ -0,0 +1,662 @@
1
+ import * as _adhese_sdk_shared from '@adhese/sdk-shared';
2
+ import { createAsyncHook, createPassiveHook, Ref, Merge, MaybeRef, UrlString, EventManager } from '@adhese/sdk-shared';
3
+ import * as _adhese_sdk_shared_validators from '@adhese/sdk-shared/validators';
4
+ import { TypeOf, ZodType } from '@adhese/sdk-shared/validators';
5
+
6
+ type RenderMode = 'iframe' | 'inline' | 'none';
7
+ type AdheseSlotHooks = {
8
+ /**
9
+ * Hook that is called when the format of the slot changes.
10
+ */
11
+ onBeforeRender: ReturnType<typeof createAsyncHook<AdheseAd>>[1];
12
+ /**
13
+ * Hook that is called when the slot is rendered.
14
+ */
15
+ onRender: ReturnType<typeof createPassiveHook<AdheseAd>>[1];
16
+ /**
17
+ * Hook that is called before the slot is requested from the server.
18
+ */
19
+ onBeforeRequest: ReturnType<typeof createAsyncHook<AdheseAd | null>>[1];
20
+ /**
21
+ * Hook that is called when the slot is requested from the server.
22
+ */
23
+ onRequest: ReturnType<typeof createAsyncHook<AdheseAd>>[1];
24
+ /**
25
+ * Hook that is called when the slot is initialized.
26
+ */
27
+ onInit: ReturnType<typeof createPassiveHook>[1];
28
+ /**
29
+ * Hook that is called when the slot is disposed.
30
+ */
31
+ onDispose: ReturnType<typeof createPassiveHook>[1];
32
+ };
33
+ type AdheseSlotOptions = {
34
+ /**
35
+ * 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
36
+ * string, it is used as the format code. If the format is an array, the format code is determined by the query
37
+ * detector.
38
+ */
39
+ format: string | ReadonlyArray<{
40
+ format: string;
41
+ query: string;
42
+ }>;
43
+ /**
44
+ * Type of the slot. On its own has no effect, but can be used by plugins to create different behavior for different
45
+ * types of slots.
46
+ */
47
+ type?: string;
48
+ /**
49
+ * If we have multiple slots with the same format, we can use this to differentiate between them.
50
+ */
51
+ slot?: string;
52
+ /**
53
+ * The element that contains the slot. Used to find the correct element on the page to render the ad in.
54
+ */
55
+ containingElement?: string | HTMLElement;
56
+ /**
57
+ * The parameters that are used to render the ad.
58
+ */
59
+ parameters?: Record<string, ReadonlyArray<string> | string>;
60
+ /**
61
+ * The Adhese context
62
+ */
63
+ context: AdheseContext;
64
+ /**
65
+ * The render mode of the slot.
66
+ *
67
+ * - `iframe`: The ad will be rendered in an iframe.
68
+ * - `inline`: The ad will be rendered in the containing element.
69
+ *
70
+ * @default 'iframe'
71
+ */
72
+ renderMode?: RenderMode;
73
+ /**
74
+ * Specific options for the slot that may be used my plugins
75
+ */
76
+ pluginOptions?: Record<string, unknown>;
77
+ /**
78
+ * Special callback that is run when the slot is initialized. It passes the slot context ref object and a special
79
+ * plugin object that contains a set of hooks you can use to hook into different moments of the slots lifecycle.
80
+ */
81
+ setup?(context: Ref<AdheseSlotContext | null>, hooks: AdheseSlotHooks): void;
82
+ } & ({
83
+ /**
84
+ * If the slot should be lazy loaded. This means that the ad will only be requested when the slot is in the viewport.
85
+ * If `true`, the slot will handle the request itself and render the ad.
86
+ */
87
+ lazyLoading: true;
88
+ lazyLoadingOptions?: {
89
+ /**
90
+ * The root margin of the intersection observer. This is used to determine when the slot is in the viewport.
91
+ */
92
+ rootMargin?: string;
93
+ };
94
+ } | {
95
+ lazyLoading?: false;
96
+ lazyLoadingOptions?: never;
97
+ });
98
+ type BaseAdheseSlot = Merge<Omit<AdheseSlotOptions, 'onDispose' | 'context' | 'onFormatChange' | 'format'>, AdheseSlotHooks & {
99
+ /**
100
+ * Type of the slot. On its own has no effect, but can be used by plugins to create different behavior for different
101
+ * types of slots.
102
+ */
103
+ type?: string;
104
+ /**
105
+ * The name of the slot. This is used to identify the slot in the Adhese instance.
106
+ *
107
+ * The name is generated based on the location, format, and slot of the slot.
108
+ */
109
+ name: string;
110
+ /**
111
+ * The format code of the slot. Used to find the correct element on the page to render the ad in.
112
+ *
113
+ * If the format is a string, it is used as the format code. If the format is an array, the format code is determined
114
+ * by the query detector.
115
+ *
116
+ * When you change the format, the slot will request a new ad from the API automatically.
117
+ */
118
+ format: string;
119
+ /**
120
+ * The location of the slot. This is the location that is used to determine the current page URL.
121
+ */
122
+ location: string;
123
+ /**
124
+ * The parameters that are used to render the ad.
125
+ */
126
+ parameters: Map<string, ReadonlyArray<string> | string>;
127
+ /**
128
+ * Whether the viewability tracking pixel has been fired.
129
+ */
130
+ readonly isViewabilityTracked: boolean;
131
+ /**
132
+ * Whether the impression tracking pixel has been fired.
133
+ */
134
+ readonly isImpressionTracked: boolean;
135
+ /**
136
+ * The state of the slot is currently in.
137
+ *
138
+ * - `initializing`: The slot is initializing.
139
+ * - `initialized`: The slot is initialized.
140
+ * - `loading`: The slot is loading data from the API
141
+ * - `loaded`: The slot has loaded data from the API and is ready to render
142
+ * - `empty`: The slot has loaded data from the API but the response was empty
143
+ * - `rendering`: The slot is rendering the ad
144
+ * - `rendered`: The slot has rendered the ad
145
+ * - `error`: The slot has encountered an error
146
+ */
147
+ status: 'initializing' | 'initialized' | 'loading' | 'loaded' | 'empty' | 'rendering' | 'rendered' | 'error';
148
+ /**
149
+ * Is the slot disposed.
150
+ */
151
+ isDisposed: boolean;
152
+ /**
153
+ * The element that contains the slot.
154
+ */
155
+ element: HTMLElement | null;
156
+ /**
157
+ * Unique identifier of the slot. ID is generated on initialization and will never change.
158
+ */
159
+ id: string;
160
+ /**
161
+ * Slot related data fetched from the API.
162
+ */
163
+ data: AdheseAd | null;
164
+ /**
165
+ * Options slot was created with
166
+ */
167
+ options: Omit<AdheseSlotOptions, 'context'>;
168
+ /**
169
+ * Renders the slot in the containing element. If no data is provided, new data will be requested from the API.
170
+ */
171
+ render(data?: AdheseAd): Promise<HTMLElement | null>;
172
+ /**
173
+ * Requests a new ad from the API and returns the ad object.
174
+ */
175
+ request(): Promise<AdheseAd | null>;
176
+ /**
177
+ * Remove the HTML element contents from the dom.
178
+ */
179
+ cleanElement(): void;
180
+ /**
181
+ * Removes the slot from the DOM and cleans up the slot instance.
182
+ */
183
+ dispose(): void;
184
+ }>;
185
+ type AdheseSlotContext = BaseAdheseSlot;
186
+ type ReadonlyProps$1 = 'type' | 'name' | 'format' | 'location' | 'status' | 'isDisposed' | 'element' | 'id';
187
+ type AdheseSlot = Omit<BaseAdheseSlot, ReadonlyProps$1> & Readonly<Pick<BaseAdheseSlot, ReadonlyProps$1>>;
188
+
189
+ type AdheseSlotManager = {
190
+ /**
191
+ * Returns all slots that are currently registered and rendered.
192
+ */
193
+ getAll(): ReadonlyArray<AdheseSlot>;
194
+ /**
195
+ * Adds a new slot to the Adhese instance and renders it.
196
+ */
197
+ add(slot: Omit<AdheseSlotOptions, 'context'>): Readonly<AdheseSlot>;
198
+ /**
199
+ * Finds all slots in the DOM and adds them to the Adhese instance.
200
+ */
201
+ findDomSlots(): Promise<ReadonlyArray<AdheseSlot>>;
202
+ /**
203
+ * Returns the slot with the given name.
204
+ */
205
+ get(name: string): AdheseSlot | undefined;
206
+ /**
207
+ * Removes all slots from the Adhese instance and cleans up the slot manager.
208
+ */
209
+ dispose(): void;
210
+ };
211
+ type SlotManagerOptions = {
212
+ /**
213
+ * List of initial slots to add to the slot manager.
214
+ */
215
+ initialSlots?: ReadonlyArray<Merge<Omit<AdheseSlotOptions, 'containingElement' | 'context' | 'lazy'>, {
216
+ containingElement: string;
217
+ }>>;
218
+ context: AdheseContext;
219
+ };
220
+
221
+ declare const baseSchema: _adhese_sdk_shared_validators.ZodObject<{
222
+ adDuration: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, number | undefined, string>>;
223
+ adFormat: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
224
+ adType: _adhese_sdk_shared_validators.ZodString;
225
+ additionalCreativeTracker: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
226
+ additionalViewableTracker: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
227
+ adspaceEnd: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, Date | undefined, string>>;
228
+ adspaceId: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
229
+ adspaceKey: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
230
+ adspaceStart: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, Date | undefined, string>>;
231
+ advertiserId: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
232
+ altText: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
233
+ auctionable: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodBoolean, _adhese_sdk_shared_validators.ZodLiteral<"">]>>;
234
+ body: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodString, Record<string, unknown> | readonly unknown[], string>, _adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodString, string, string>]>]>, string | Record<string, unknown> | readonly unknown[] | undefined, string>>;
235
+ clickTag: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
236
+ comment: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
237
+ creativeName: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
238
+ deliveryGroupId: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
239
+ deliveryMultiples: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
240
+ ext: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
241
+ extension: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodObject<{
242
+ mediaType: _adhese_sdk_shared_validators.ZodString;
243
+ prebid: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodUnknown>;
244
+ }, "strip", _adhese_sdk_shared_validators.ZodTypeAny, {
245
+ mediaType: string;
246
+ prebid?: unknown;
247
+ }, {
248
+ mediaType: string;
249
+ prebid?: unknown;
250
+ }>>;
251
+ height: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, number | undefined, string>>;
252
+ id: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
253
+ impressionCounter: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
254
+ libId: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
255
+ orderId: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
256
+ orderName: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
257
+ orderProperty: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
258
+ origin: _adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodLiteral<"JERLICIA">, _adhese_sdk_shared_validators.ZodLiteral<"DALE">]>;
259
+ originData: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodUnknown>;
260
+ originInstance: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
261
+ poolPath: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
262
+ preview: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodBoolean, _adhese_sdk_shared_validators.ZodLiteral<"">]>>;
263
+ priority: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, number | undefined, string>>;
264
+ sfSrc: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
265
+ share: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodString>;
266
+ slotID: _adhese_sdk_shared_validators.ZodString;
267
+ slotName: _adhese_sdk_shared_validators.ZodString;
268
+ swfSrc: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
269
+ tag: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodString, Record<string, unknown> | readonly unknown[], string>, _adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodString, string, string>]>]>, string | Record<string, unknown> | readonly unknown[] | undefined, string>>;
270
+ tagUrl: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
271
+ timeStamp: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, Date | undefined, string>>;
272
+ trackedImpressionCounter: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
273
+ tracker: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
274
+ trackingUrl: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
275
+ url: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
276
+ viewableImpressionCounter: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, URL | undefined, string>>;
277
+ width: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">]>, number | undefined, string>>;
278
+ widthLarge: _adhese_sdk_shared_validators.ZodOptional<_adhese_sdk_shared_validators.ZodEffects<_adhese_sdk_shared_validators.ZodUnion<[_adhese_sdk_shared_validators.ZodString, _adhese_sdk_shared_validators.ZodLiteral<"">, _adhese_sdk_shared_validators.ZodNumber]>, string | undefined, string | number>>;
279
+ }, "strip", _adhese_sdk_shared_validators.ZodTypeAny, {
280
+ adType: string;
281
+ origin: "JERLICIA" | "DALE";
282
+ slotID: string;
283
+ slotName: string;
284
+ adDuration?: number | undefined;
285
+ adFormat?: string | undefined;
286
+ additionalCreativeTracker?: URL | undefined;
287
+ additionalViewableTracker?: string | undefined;
288
+ adspaceEnd?: Date | undefined;
289
+ adspaceId?: string | undefined;
290
+ adspaceKey?: string | undefined;
291
+ adspaceStart?: Date | undefined;
292
+ advertiserId?: string | undefined;
293
+ altText?: string | undefined;
294
+ auctionable?: boolean | "" | undefined;
295
+ body?: string | Record<string, unknown> | readonly unknown[] | undefined;
296
+ clickTag?: URL | undefined;
297
+ comment?: string | undefined;
298
+ creativeName?: string | undefined;
299
+ deliveryGroupId?: string | undefined;
300
+ deliveryMultiples?: string | undefined;
301
+ ext?: string | undefined;
302
+ extension?: {
303
+ mediaType: string;
304
+ prebid?: unknown;
305
+ } | undefined;
306
+ height?: number | undefined;
307
+ id?: string | undefined;
308
+ impressionCounter?: URL | undefined;
309
+ libId?: string | undefined;
310
+ orderId?: string | undefined;
311
+ orderName?: string | undefined;
312
+ orderProperty?: string | undefined;
313
+ originData?: unknown;
314
+ originInstance?: string | undefined;
315
+ poolPath?: URL | undefined;
316
+ preview?: boolean | "" | undefined;
317
+ priority?: number | undefined;
318
+ sfSrc?: URL | undefined;
319
+ share?: string | undefined;
320
+ swfSrc?: URL | undefined;
321
+ tag?: string | Record<string, unknown> | readonly unknown[] | undefined;
322
+ tagUrl?: URL | undefined;
323
+ timeStamp?: Date | undefined;
324
+ trackedImpressionCounter?: URL | undefined;
325
+ tracker?: URL | undefined;
326
+ trackingUrl?: URL | undefined;
327
+ url?: URL | undefined;
328
+ viewableImpressionCounter?: URL | undefined;
329
+ width?: number | undefined;
330
+ widthLarge?: string | undefined;
331
+ }, {
332
+ adType: string;
333
+ origin: "JERLICIA" | "DALE";
334
+ slotID: string;
335
+ slotName: string;
336
+ adDuration?: string | undefined;
337
+ adFormat?: string | undefined;
338
+ additionalCreativeTracker?: string | undefined;
339
+ additionalViewableTracker?: string | undefined;
340
+ adspaceEnd?: string | undefined;
341
+ adspaceId?: string | undefined;
342
+ adspaceKey?: string | undefined;
343
+ adspaceStart?: string | undefined;
344
+ advertiserId?: string | undefined;
345
+ altText?: string | undefined;
346
+ auctionable?: boolean | "" | undefined;
347
+ body?: string | undefined;
348
+ clickTag?: string | undefined;
349
+ comment?: string | undefined;
350
+ creativeName?: string | undefined;
351
+ deliveryGroupId?: string | undefined;
352
+ deliveryMultiples?: string | undefined;
353
+ ext?: string | undefined;
354
+ extension?: {
355
+ mediaType: string;
356
+ prebid?: unknown;
357
+ } | undefined;
358
+ height?: string | undefined;
359
+ id?: string | undefined;
360
+ impressionCounter?: string | undefined;
361
+ libId?: string | undefined;
362
+ orderId?: string | undefined;
363
+ orderName?: string | undefined;
364
+ orderProperty?: string | undefined;
365
+ originData?: unknown;
366
+ originInstance?: string | undefined;
367
+ poolPath?: string | undefined;
368
+ preview?: boolean | "" | undefined;
369
+ priority?: string | undefined;
370
+ sfSrc?: string | undefined;
371
+ share?: string | undefined;
372
+ swfSrc?: string | undefined;
373
+ tag?: string | undefined;
374
+ tagUrl?: string | undefined;
375
+ timeStamp?: string | undefined;
376
+ trackedImpressionCounter?: string | undefined;
377
+ tracker?: string | undefined;
378
+ trackingUrl?: string | undefined;
379
+ url?: string | undefined;
380
+ viewableImpressionCounter?: string | undefined;
381
+ width?: string | undefined;
382
+ widthLarge?: string | number | undefined;
383
+ }>;
384
+ type AdResponse = (TypeOf<typeof baseSchema> & {
385
+ additionalCreatives?: ReadonlyArray<AdResponse> | string;
386
+ });
387
+ declare const adResponseSchema: ZodType<AdResponse>;
388
+ type PreParsedAd = TypeOf<typeof adResponseSchema> & {
389
+ additionalCreatives?: ReadonlyArray<PreParsedAd> | string;
390
+ };
391
+ type AdheseAd<T = string | Record<string, unknown> | ReadonlyArray<unknown>> = Omit<PreParsedAd, 'tag'> & {
392
+ tag: T | string;
393
+ };
394
+
395
+ type AdRequestOptions = {
396
+ /**
397
+ * Slot you want to fetch the ad for
398
+ */
399
+ slot: {
400
+ name: MaybeRef<string>;
401
+ parameters: Map<string, ReadonlyArray<string> | string>;
402
+ };
403
+ context: AdheseContext;
404
+ };
405
+ type AdMultiRequestOptions = Omit<AdRequestOptions, 'slot'> & {
406
+ slots: ReadonlyArray<AdRequestOptions['slot']>;
407
+ };
408
+
409
+ declare const logger: _adhese_sdk_shared.Logger<"error" | "trace" | "debug" | "info" | "warn">;
410
+
411
+ declare function createGlobalHooks(): {
412
+ runOnInit: (arg: void) => void;
413
+ onInit: (callback: (arg: void) => void | Promise<void>) => () => void;
414
+ runOnDispose: (arg: void) => void;
415
+ onDispose: (callback: (arg: void) => void | Promise<void>) => () => void;
416
+ runOnRequest: (arg: AdMultiRequestOptions) => Promise<AdMultiRequestOptions>;
417
+ onRequest: (callback: (arg: AdMultiRequestOptions) => void | AdMultiRequestOptions | Promise<void | AdMultiRequestOptions>) => () => void;
418
+ runOnResponse: (arg: readonly AdheseAd[]) => Promise<readonly AdheseAd[]>;
419
+ onResponse: (callback: (arg: readonly AdheseAd[]) => void | readonly AdheseAd[] | Promise<void | readonly AdheseAd[]>) => () => void;
420
+ runOnSlotCreate: (arg: AdheseSlotOptions) => AdheseSlotOptions;
421
+ onSlotCreate: (callback: (arg: AdheseSlotOptions) => void | Promise<void> | AdheseSlotOptions) => () => void;
422
+ clearAll: () => void;
423
+ };
424
+
425
+ type AdhesePluginInformation = {
426
+ index: number;
427
+ version: string;
428
+ hooks: ReturnType<typeof createGlobalHooks>;
429
+ };
430
+ type AdhesePlugin<T extends {
431
+ name: string;
432
+ } & Record<string, unknown> = {
433
+ name: string;
434
+ } & Record<string, unknown>> = (context: AdheseContext, plugin: AdhesePluginInformation) => T;
435
+ type BaseOptions = {
436
+ /**
437
+ * The Adhese account name.
438
+ */
439
+ account: string;
440
+ /**
441
+ * 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
442
+ * the connection.
443
+ *
444
+ * @default 'https://ads-{{account}}.adhese.com'
445
+ */
446
+ host?: UrlString;
447
+ /**
448
+ * 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
449
+ * the connection.
450
+ *
451
+ * @default 'https://pool-{{account}}.adhese.com'
452
+ */
453
+ poolHost?: UrlString;
454
+ /**
455
+ * The page location. This is used to determine the current page location identifier.
456
+ */
457
+ location?: string;
458
+ /**
459
+ * The requestAds type to use for the Adhese API requests. This can be either `GET` or `POST`. `POST` is the default
460
+ * and offers the most options. `GET` is more limited as it needs pass its data as search parameters but can be used
461
+ * in environments where `POST` requests are not allowed.
462
+ *
463
+ * @default 'POST'
464
+ */
465
+ requestType?: 'GET' | 'POST';
466
+ /**
467
+ * Enable debug logging.
468
+ *
469
+ * @default false
470
+ */
471
+ debug?: boolean;
472
+ /**
473
+ * Find all slots in the DOM and add them to the Adhese instance during initialization.
474
+ *
475
+ * @default false
476
+ */
477
+ findDomSlotsOnLoad?: boolean;
478
+ /**
479
+ * Additional parameters to send with each request. Make sure that the keys of a parameter only contain `2` characters.
480
+ */
481
+ parameters?: Record<string, ReadonlyArray<string> | string>;
482
+ /**
483
+ * The consent type to use for the Adhese API requests. This can be either `true` or `false`. `false` is the default and
484
+ * will send all consent data to the Adhese API. `false` will send no consent data to the Adhese API.
485
+ *
486
+ * @default false
487
+ */
488
+ consent?: boolean;
489
+ /**
490
+ * Will log the `document.referrer` to the Adhese API in a BASE64 string with the `re` parameter.
491
+ *
492
+ * @default true
493
+ */
494
+ logReferrer?: boolean;
495
+ /**
496
+ * Will log the `window.location.href` to the Adhese API in a BASE64 string with the `ur` parameter.
497
+ *
498
+ * @default true
499
+ */
500
+ logUrl?: boolean;
501
+ /**
502
+ * If `true`, ads will be rendered immediately after they are fetched from the API. If `false`, ads will only be
503
+ * rendered when the slot is in the viewport.
504
+ *
505
+ * @default false
506
+ */
507
+ eagerRendering?: boolean;
508
+ /**
509
+ * The query detector options for the Adhese instance.
510
+ */
511
+ queries?: Record<string, string>;
512
+ } & ({
513
+ viewabilityTracking?: true;
514
+ /**
515
+ * Options for the viewability tracking of the ads. If `true` or `undefined`, the default viewability tracking options will be used.
516
+ *
517
+ * @default true
518
+ */
519
+ viewabilityTrackingOptions?: {
520
+ /**
521
+ * Fraction of the ad that needs to be in the viewport for the ad to be considered viewable.
522
+ *
523
+ * @default 0.2
524
+ */
525
+ threshold?: number;
526
+ /**
527
+ * The duration the ad needs to be in the viewport for the ad to be considered viewable in milliseconds.
528
+ *
529
+ * @default 1000
530
+ */
531
+ duration?: number;
532
+ /**
533
+ * The margin around the viewport where the ad is considered viewable.
534
+ *
535
+ * @default '0px'
536
+ */
537
+ rootMargin?: string;
538
+ };
539
+ } | {
540
+ viewabilityTracking?: false;
541
+ viewabilityTrackingOptions?: never;
542
+ }) & Pick<SlotManagerOptions, 'initialSlots'>;
543
+ type AdheseOptions<T extends ReadonlyArray<AdhesePlugin> = []> = BaseOptions & {
544
+ /**
545
+ * The plugins that are used for the Adhese instance.
546
+ */
547
+ plugins?: T['length'] extends 0 ? ReadonlyArray<AdhesePlugin> : T;
548
+ };
549
+ type MergedOptions = Merge<BaseOptions, Required<Pick<BaseOptions, 'host' | 'poolHost' | 'location' | 'requestType' | 'debug' | 'initialSlots' | 'findDomSlotsOnLoad' | 'consent' | 'logUrl' | 'logReferrer' | 'eagerRendering' | 'viewabilityTracking'>>>;
550
+ type AdheseEvents = {
551
+ locationChange: string;
552
+ consentChange: boolean;
553
+ addSlot: AdheseSlot;
554
+ removeSlot: AdheseSlot;
555
+ responseReceived: ReadonlyArray<AdheseAd>;
556
+ requestAd: AdMultiRequestOptions;
557
+ requestError: Error;
558
+ previewReceived: ReadonlyArray<AdheseAd>;
559
+ parametersChange: Map<string, ReadonlyArray<string> | string>;
560
+ debugChange: boolean;
561
+ };
562
+ type BaseAdhese = {
563
+ /**
564
+ * The slots that are in the Adhese instance.
565
+ */
566
+ slots: Map<string, AdheseSlot>;
567
+ /**
568
+ * The page location. This is used to determine the current page location identifier.
569
+ */
570
+ location: string;
571
+ /**
572
+ * The consent type to use for the Adhese API requests. This can be either `true` or `false`. `false` is the default and
573
+ * will send all consent data to the Adhese API. `false` will send no consent data to the Adhese API.
574
+ */
575
+ consent: boolean;
576
+ /**
577
+ * String that is generated by either the binary consent passed with `consent` property or the value passed by the TCF
578
+ * API. If consent is `true` the string will be `all` otherwise it will be `none`. If the consent is coming from TCF
579
+ * the string will be the TCF string.
580
+ */
581
+ consentString?: string;
582
+ /**
583
+ * The logger instance that is used for multi level console logging
584
+ */
585
+ logger: typeof logger;
586
+ /**
587
+ * Debug mode of the Adhese instance. When set to true will log verbose logs to the console and will load the Devtools.
588
+ */
589
+ debug: boolean;
590
+ /**
591
+ * The parameters that are used for all ads.
592
+ */
593
+ parameters: Map<string, ReadonlyArray<string> | string>;
594
+ /**
595
+ * The event manager for the Adhese instance.
596
+ */
597
+ events: EventManager<AdheseEvents>;
598
+ /**
599
+ * Options passed to the Adhese instance.
600
+ */
601
+ options: Readonly<MergedOptions>;
602
+ /**
603
+ * Is the instance disposed
604
+ */
605
+ isDisposed: boolean;
606
+ /**
607
+ * Active media query device
608
+ */
609
+ device: string;
610
+ /**
611
+ * Get a slot by name.
612
+ * @param name The name of the slot.
613
+ */
614
+ get(name: string): AdheseSlot | undefined;
615
+ /**
616
+ * Get all slots in the Adhese instance.
617
+ */
618
+ getAll(): ReadonlyArray<AdheseSlot>;
619
+ /**
620
+ * Adds a new slot to the Adhese instance and renders it.
621
+ */
622
+ addSlot(slot: Omit<AdheseSlotOptions, 'location' | 'context'>): Readonly<AdheseSlot>;
623
+ /**
624
+ * Finds all slots in the DOM and adds them to the Adhese instance.
625
+ */
626
+ findDomSlots(): Promise<ReadonlyArray<AdheseSlot>>;
627
+ /**
628
+ * Removes all slots from the Adhese instance and cleans up the Adhese instance.
629
+ *
630
+ * After calling this method, the Adhese instance is no longer usable.
631
+ */
632
+ dispose(): void;
633
+ };
634
+ type ExtractFromTupleWithNameKey<T extends string, U extends Record<string, unknown>> = U extends {
635
+ name: T;
636
+ } ? U : never;
637
+ type Plugins<T extends ReadonlyArray<AdhesePlugin> = [], U extends {
638
+ name: string;
639
+ } = ReturnType<Required<AdheseOptions<T>>['plugins'][number]>> = {
640
+ [K in U['name']]: Omit<ExtractFromTupleWithNameKey<K, U>, 'name'>;
641
+ };
642
+ type ReadonlyProps = 'options' | 'isDisposed' | 'logger' | 'events' | 'get' | 'getAll' | 'addSlot' | 'findDomSlots' | 'dispose' | 'slots' | 'device' | 'consentString';
643
+ type Adhese<T extends ReadonlyArray<AdhesePlugin> = []> = Omit<BaseAdhese, ReadonlyProps> & Readonly<Pick<BaseAdhese, ReadonlyProps>> & {
644
+ plugins: Plugins<T>;
645
+ };
646
+ type AdheseContextState = Omit<BaseAdhese, 'options'> & {
647
+ readonly options: MergedOptions;
648
+ hooks: ReturnType<typeof createGlobalHooks>;
649
+ };
650
+ type NonPartialProps = 'options' | 'logger' | 'events' | 'isDisposed' | 'location' | 'consent' | 'debug' | 'parameters' | 'slots' | 'hooks';
651
+ type AdheseContext = Omit<Partial<AdheseContextState>, NonPartialProps> & Pick<AdheseContextState, NonPartialProps>;
652
+
653
+ /**
654
+ * Creates an Adhese instance. This instance is your main entry point to the Adhese API.
655
+ *
656
+ * @param options {AdheseOptions} The options to create the Adhese instance with. See the {@link AdheseOptions} type for more information.
657
+ *
658
+ * @return Adhese The Adhese instance.
659
+ */
660
+ declare function createAdhese<T extends ReadonlyArray<AdhesePlugin>>(options: AdheseOptions<T>): Adhese<T>;
661
+
662
+ export { type AdRequestOptions, type Adhese, type AdheseAd, type AdheseContext, type AdheseOptions, type AdhesePlugin, type AdhesePluginInformation, type AdheseSlot, type AdheseSlotContext, type AdheseSlotHooks, type AdheseSlotManager, type AdheseSlotOptions, createAdhese };
@@ -1,5 +1,5 @@
1
1
  const name = "@adhese/sdk";
2
- const version = "0.21.0";
2
+ const version = "0.21.1";
3
3
  export {
4
4
  name,
5
5
  version
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adhese/sdk",
3
3
  "type": "module",
4
- "version": "0.21.0",
4
+ "version": "0.21.1",
5
5
  "description": "Adhese SDK",
6
6
  "license": "GPL-3.0",
7
7
  "repository": {