@adhese/sdk-devtools 0.4.0 → 0.5.0

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,5 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement } from 'react';
3
+ import { ComputedRef, Ref, MaybeRef } from '@vue/runtime-core';
3
4
  import * as zod from 'zod';
4
5
  import { TypeOf, ZodType } from 'zod';
5
6
 
@@ -64,7 +65,7 @@ type SlotManager = {
64
65
  /**
65
66
  * Adds a new slot to the Adhese instance and renders it.
66
67
  */
67
- add(slot: Omit<AdheseSlotOptions, 'context'>): Promise<Readonly<AdheseSlot>>;
68
+ add(slot: Omit<AdheseSlotOptions, 'context'>): Readonly<AdheseSlot>;
68
69
  /**
69
70
  * Finds all slots in the DOM and adds them to the Adhese instance.
70
71
  */
@@ -101,7 +102,7 @@ declare const baseSchema: zod.ZodObject<{
101
102
  advertiserId: zod.ZodOptional<zod.ZodString>;
102
103
  altText: zod.ZodOptional<zod.ZodString>;
103
104
  auctionable: zod.ZodOptional<zod.ZodUnion<[zod.ZodBoolean, zod.ZodLiteral<"">]>>;
104
- body: zod.ZodOptional<zod.ZodString>;
105
+ 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>>;
105
106
  clickTag: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
106
107
  comment: zod.ZodOptional<zod.ZodString>;
107
108
  creativeName: zod.ZodOptional<zod.ZodString>;
@@ -118,7 +119,7 @@ declare const baseSchema: zod.ZodObject<{
118
119
  mediaType: string;
119
120
  prebid?: unknown;
120
121
  }>>;
121
- height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
122
+ height: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">, zod.ZodNumber]>, string | undefined, string | number>>;
122
123
  id: zod.ZodOptional<zod.ZodString>;
123
124
  impressionCounter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
124
125
  libId: zod.ZodOptional<zod.ZodString>;
@@ -135,7 +136,7 @@ declare const baseSchema: zod.ZodObject<{
135
136
  slotID: zod.ZodString;
136
137
  slotName: zod.ZodString;
137
138
  swfSrc: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
138
- tag: zod.ZodOptional<zod.ZodString>;
139
+ 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>>;
139
140
  tagUrl: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
140
141
  timeStamp: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, Date | undefined, string>>;
141
142
  trackedImpressionCounter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
@@ -143,8 +144,8 @@ declare const baseSchema: zod.ZodObject<{
143
144
  trackingUrl: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
144
145
  url: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
145
146
  viewableImpressionCounter: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, URL | undefined, string>>;
146
- width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
147
- widthLarge: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">]>, number | undefined, string>>;
147
+ width: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">, zod.ZodNumber]>, string | undefined, string | number>>;
148
+ widthLarge: zod.ZodOptional<zod.ZodEffects<zod.ZodUnion<[zod.ZodString, zod.ZodLiteral<"">, zod.ZodNumber]>, string | undefined, string | number>>;
148
149
  }, "strip", zod.ZodTypeAny, {
149
150
  adType: string;
150
151
  origin: "JERLICIA" | "DALE";
@@ -161,7 +162,7 @@ declare const baseSchema: zod.ZodObject<{
161
162
  advertiserId?: string | undefined;
162
163
  altText?: string | undefined;
163
164
  auctionable?: boolean | "" | undefined;
164
- body?: string | undefined;
165
+ body?: string | Record<string, unknown> | readonly unknown[] | undefined;
165
166
  clickTag?: URL | undefined;
166
167
  comment?: string | undefined;
167
168
  creativeName?: string | undefined;
@@ -172,7 +173,7 @@ declare const baseSchema: zod.ZodObject<{
172
173
  mediaType: string;
173
174
  prebid?: unknown;
174
175
  } | undefined;
175
- height?: number | undefined;
176
+ height?: string | undefined;
176
177
  id?: string | undefined;
177
178
  impressionCounter?: URL | undefined;
178
179
  libId?: string | undefined;
@@ -186,7 +187,7 @@ declare const baseSchema: zod.ZodObject<{
186
187
  priority?: number | undefined;
187
188
  share?: string | undefined;
188
189
  swfSrc?: URL | undefined;
189
- tag?: string | undefined;
190
+ tag?: string | Record<string, unknown> | readonly unknown[] | undefined;
190
191
  tagUrl?: URL | undefined;
191
192
  timeStamp?: Date | undefined;
192
193
  trackedImpressionCounter?: URL | undefined;
@@ -194,8 +195,8 @@ declare const baseSchema: zod.ZodObject<{
194
195
  trackingUrl?: URL | undefined;
195
196
  url?: URL | undefined;
196
197
  viewableImpressionCounter?: URL | undefined;
197
- width?: number | undefined;
198
- widthLarge?: number | undefined;
198
+ width?: string | undefined;
199
+ widthLarge?: string | undefined;
199
200
  }, {
200
201
  adType: string;
201
202
  origin: "JERLICIA" | "DALE";
@@ -223,7 +224,7 @@ declare const baseSchema: zod.ZodObject<{
223
224
  mediaType: string;
224
225
  prebid?: unknown;
225
226
  } | undefined;
226
- height?: string | undefined;
227
+ height?: string | number | undefined;
227
228
  id?: string | undefined;
228
229
  impressionCounter?: string | undefined;
229
230
  libId?: string | undefined;
@@ -245,8 +246,8 @@ declare const baseSchema: zod.ZodObject<{
245
246
  trackingUrl?: string | undefined;
246
247
  url?: string | undefined;
247
248
  viewableImpressionCounter?: string | undefined;
248
- width?: string | undefined;
249
- widthLarge?: string | undefined;
249
+ width?: string | number | undefined;
250
+ widthLarge?: string | number | undefined;
250
251
  }>;
251
252
  type AdResponse = (TypeOf<typeof baseSchema> & {
252
253
  additionalCreatives?: ReadonlyArray<AdResponse> | string;
@@ -255,8 +256,8 @@ declare const adResponseSchema: ZodType<AdResponse>;
255
256
  type PreParsedAd = TypeOf<typeof adResponseSchema> & {
256
257
  additionalCreatives?: ReadonlyArray<PreParsedAd> | string;
257
258
  };
258
- type Ad = Omit<PreParsedAd, 'tag'> & {
259
- tag: string;
259
+ type Ad<T = string | Record<string, unknown> | ReadonlyArray<unknown>> = Omit<PreParsedAd, 'tag'> & {
260
+ tag: T;
260
261
  };
261
262
 
262
263
  type RenderMode = 'iframe' | 'inline';
@@ -303,6 +304,15 @@ type AdheseSlotOptions = {
303
304
  * Callback that is called when the format of the slot changes.
304
305
  */
305
306
  onNameChange?(newName: string, oldName: string): void;
307
+ /**
308
+ * Callback that is called when the slot is rendered.
309
+ */
310
+ onRender?(element: HTMLElement): void;
311
+ /**
312
+ * Callback that is called before the ad is rendered. This can be used to modify the ad before it is rendered.
313
+ * Particularly useful for rendering ads with custom HTML if the ad tag contains a JSON object.
314
+ */
315
+ onBeforeRender?(ad: Ad): Ad | void;
306
316
  } & ({
307
317
  /**
308
318
  * If the slot should be lazy loaded. This means that the ad will only be requested when the slot is in the viewport.
@@ -321,49 +331,48 @@ type AdheseSlotOptions = {
321
331
  });
322
332
  type AdheseSlot = Merge<Omit<AdheseSlotOptions, 'onDispose' | 'context' | 'onFormatChange' | 'format'>, {
323
333
  /**
324
- * The location of the slot. This is the location that is used to determine the current page URL.
325
- */
326
- location: string;
327
- /**
328
- * The parameters that are used to render the ad.
329
- */
330
- parameters: Map<string, ReadonlyArray<string> | string>;
331
- /**
332
- * Renders the slot in the containing element. If no ad is provided, a new ad will be requested from the API.
334
+ * The name of the slot. This is used to identify the slot in the Adhese instance.
335
+ *
336
+ * The name is generated based on the location, format, and slot of the slot.
333
337
  */
334
- render(ad?: Ad): Promise<HTMLElement>;
338
+ name: ComputedRef<string>;
335
339
  /**
336
- * Returns the rendered element.
340
+ * The format code of the slot. Used to find the correct element on the page to render the ad in.
341
+ *
342
+ * If the format is a string, it is used as the format code. If the format is an array, the format code is determined
343
+ * by the query detector.
344
+ *
345
+ * When you change the format, the slot will request a new ad from the API automatically.
337
346
  */
338
- getElement(): HTMLElement | null;
347
+ format: Ref<string>;
339
348
  /**
340
- * Returns the name of the slot.
349
+ * The location of the slot. This is the location that is used to determine the current page URL.
341
350
  */
342
- getName(): string;
351
+ location: string;
343
352
  /**
344
- * Returns the ad that is to be rendered in the slot or is currently rendered in the slot.
353
+ * The parameters that are used to render the ad.
345
354
  */
346
- getAd(): Ad | null;
355
+ parameters: Map<string, ReadonlyArray<string> | string>;
347
356
  /**
348
- * Sets the ad that is to be rendered in the slot. If the slot is in the viewport, the ad will be rendered immediately.
357
+ * Whether the viewability tracking pixel has been fired.
349
358
  */
350
- setAd(ad: Ad): Promise<void>;
359
+ isViewabilityTracked: ComputedRef<boolean>;
351
360
  /**
352
- * Returns whether the viewability tracking pixel has been fired.
361
+ * Whether the impression tracking pixel has been fired.
353
362
  */
354
- isViewabilityTracked(): boolean;
363
+ isImpressionTracked: ComputedRef<boolean>;
355
364
  /**
356
- * Returns whether the impression tracking pixel has been fired.
365
+ * Ad object that is fetched from the API.
357
366
  */
358
- isImpressionTracked(): boolean;
367
+ ad: Ref<Ad | null>;
359
368
  /**
360
- * Sets the format of the slot. This is used to change the format of the slot after it has been created.
369
+ * Renders the slot in the containing element. If no ad is provided, a new ad will be requested from the API.
361
370
  */
362
- setFormat(format: string): Promise<void>;
371
+ render(ad?: Ad): Promise<HTMLElement>;
363
372
  /**
364
- * Returns the format of the slot.
373
+ * Returns the rendered element.
365
374
  */
366
- getFormat(): string;
375
+ getElement(): HTMLElement | null;
367
376
  /**
368
377
  * Removes the slot from the DOM and cleans up the slot instance.
369
378
  */
@@ -374,41 +383,13 @@ type AdRequestOptions = {
374
383
  /**
375
384
  * List of slots you want to fetch the ad for
376
385
  */
377
- slots: ReadonlyArray<Pick<AdheseSlot, 'getName' | 'parameters'>>;
378
- /**
379
- * Host that you want to fetch the ads from
380
- */
381
- host: UrlString;
382
- /**
383
- * The Adhese account name.
384
- */
385
- account: string;
386
- /**
387
- * Request method to use for the requestAds
388
- *
389
- * @default 'POST'
390
- */
391
- method?: 'GET' | 'POST' | 'get' | 'post';
392
- /**
393
- * The parameters that are used for all ads.
394
- */
395
- parameters?: Map<string, ReadonlyArray<string> | string>;
396
- context: Partial<Adhese>;
386
+ slots: ReadonlyArray<{
387
+ name: MaybeRef<string>;
388
+ parameters: Map<string, ReadonlyArray<string> | string>;
389
+ }>;
390
+ context: AdheseContext;
397
391
  };
398
392
 
399
- declare class MapWithEvents<T, U> extends Map<T, U> {
400
- private readonly listeners;
401
- addEventListener(listener: () => void): void;
402
- removeEventListener(listener: () => void): void;
403
- set(key: T, value: U): this;
404
- clear(): void;
405
- delete(key: T): boolean;
406
- /**
407
- * Remove all listeners and clear the map.
408
- */
409
- dispose(): void;
410
- }
411
-
412
393
  /**
413
394
  * A log entry saved by the logger
414
395
  */
@@ -602,7 +583,7 @@ type Adhese = Omit<AdheseOptions, 'location' | 'parameters' | 'consent'> & Merge
602
583
  /**
603
584
  * The parameters that are used for all ads.
604
585
  */
605
- parameters: MapWithEvents<string, ReadonlyArray<string> | string>;
586
+ parameters: Map<string, ReadonlyArray<string> | string>;
606
587
  /**
607
588
  * The event manager for the Adhese instance.
608
589
  */
package/dist/style.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- ! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com
2
+ ! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com
3
3
  *//*
4
4
  1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
5
5
  2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
@@ -179,6 +179,7 @@ textarea {
179
179
  font-size: 100%; /* 1 */
180
180
  font-weight: inherit; /* 1 */
181
181
  line-height: inherit; /* 1 */
182
+ letter-spacing: inherit; /* 1 */
182
183
  color: inherit; /* 1 */
183
184
  margin: 0; /* 2 */
184
185
  padding: 0; /* 3 */
@@ -199,9 +200,9 @@ select {
199
200
  */
200
201
 
201
202
  button,
202
- [type='button'],
203
- [type='reset'],
204
- [type='submit'] {
203
+ input:where([type='button']),
204
+ input:where([type='reset']),
205
+ input:where([type='submit']) {
205
206
  -webkit-appearance: button; /* 1 */
206
207
  background-color: transparent; /* 2 */
207
208
  background-image: none; /* 2 */
@@ -480,6 +481,10 @@ video {
480
481
  --tw-backdrop-opacity: ;
481
482
  --tw-backdrop-saturate: ;
482
483
  --tw-backdrop-sepia: ;
484
+ --tw-contain-size: ;
485
+ --tw-contain-layout: ;
486
+ --tw-contain-paint: ;
487
+ --tw-contain-style: ;
483
488
  }
484
489
 
485
490
  ::backdrop {
@@ -530,6 +535,10 @@ video {
530
535
  --tw-backdrop-opacity: ;
531
536
  --tw-backdrop-saturate: ;
532
537
  --tw-backdrop-sepia: ;
538
+ --tw-contain-size: ;
539
+ --tw-contain-layout: ;
540
+ --tw-contain-paint: ;
541
+ --tw-contain-style: ;
533
542
  }
534
543
  .sr-only {
535
544
  position: absolute;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adhese/sdk-devtools",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "description": "Adhese SDK Devtools",
6
6
  "license": "GPL-3.0",
7
7
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "tailwindcss-animate": "^1.0.7"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/react": "^18.2.71",
44
- "@types/react-dom": "^18.2.22"
43
+ "@types/react": "^18.2.74",
44
+ "@types/react-dom": "^18.2.23"
45
45
  }
46
46
  }