@adhese/sdk 1.0.4 → 1.1.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,24 @@
1
1
  # @adhese/sdk
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 180e82a: Fix issue where `mobile` would be passed as a param instead of the required `phone`, which would result in that the server would not return any ads
8
+
9
+ ## 1.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 112e224: Add `width` and `height` option to overwrite slot sizing
14
+
15
+ **NOTE**: Only applies when `renderMode` is `iframe` or `undefined`
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [112e224]
20
+ - @adhese/sdk-shared@1.1.0
21
+
3
22
  ## 1.0.4
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -65,22 +65,22 @@ Example HTML:
65
65
  ## Options
66
66
  The `createAdhese` function accepts the following options:
67
67
 
68
- | Option | Type | Default | Description |
69
- |-----------------------|---------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
70
- | `account`<sup>*</sup> | `string` | - | Your Adhese account ID |
71
- | `host` | `string` | <code>'https://ads-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese API host |
72
- | `poolHost` | `string` | <code>'https://pool-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese pool host |
73
- | `location` | `string` | `window.location.pathname` | The page location. This is used to determine the current page location identifier. |
74
- | `requestType` | `'GET'` or `'POST'` | `'POST'` | The requestAds type to use for the Adhese API requests. This can be either `GET` or `POST`. `POST` is the default and offers the most options. `GET` is more limited as it needs pass its data as search parameters but can be used in environments where `POST` requests are not allowed. |
75
- | `debug` | `boolean` | `false` | Enable debug mode |
76
- | `findDomSlotsOnLoad` | `boolean` | `false` | Automatically find slots on the page and load them |
77
- | `parameters` | ``Record<string, string, Array<string>>`` | `{}` | Additional parameters to send with each request. Make sure that the keys of a parameter only contain `2` characters. |
78
- | `consent` | `boolean` | `false` | User consent for tracking |
79
- | `initialSlots` | `Array<Slot>` | `[]` | Slots to fetch before the DOM is ready |
80
- | `logReferrer` | `boolean` | `true` | Will log the `document.referrer` to the Adhese API in a `BASE64` string with the `re` parameter. |
81
- | `logUrl` | `boolean` | `true` | Will log the `location.href` to the Adhese API in a `BASE64` string with the `ur` parameter. |'
82
- | `eagerRendering` | `boolean` | `false` | Will render the ad as soon as it is fetched. In general it is recommended to keep this `false` for better performance. |
83
- | `queries` | `Record<string, string>` | `{mobile: '(max-width: 768px) and (pointer: coarse)',tablet: '(min-width: 769px) and (max-width: 1024px) and (pointer: coarse)',desktop: '(min-width: 1025px) and (pointer: fine)',}` | Will be used to determine the device type and screen size. The matching query key will be passed in the `dt` and `br` parameter. |
84
- | `plugins` | `ReadonlyArray<(context: AdheseContext) => void>` | `[]` | The plugins that are used for the Adhese instance. These plugins are called with the Adhese context and run during the initialization of the Adhese instance. |
68
+ | Option | Type | Default | Description |
69
+ |-----------------------|---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
70
+ | `account`<sup>*</sup> | `string` | - | Your Adhese account ID |
71
+ | `host` | `string` | <code>'https://ads-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese API host |
72
+ | `poolHost` | `string` | <code>'https://pool-<span v-pre>{{account}}</span>.adhese.com'</code> | The Adhese pool host |
73
+ | `location` | `string` | `window.location.pathname` | The page location. This is used to determine the current page location identifier. |
74
+ | `requestType` | `'GET'` or `'POST'` | `'POST'` | The requestAds type to use for the Adhese API requests. This can be either `GET` or `POST`. `POST` is the default and offers the most options. `GET` is more limited as it needs pass its data as search parameters but can be used in environments where `POST` requests are not allowed. |
75
+ | `debug` | `boolean` | `false` | Enable debug mode |
76
+ | `findDomSlotsOnLoad` | `boolean` | `false` | Automatically find slots on the page and load them |
77
+ | `parameters` | ``Record<string, string, Array<string>>`` | `{}` | Additional parameters to send with each request. Make sure that the keys of a parameter only contain `2` characters. |
78
+ | `consent` | `boolean` | `false` | User consent for tracking |
79
+ | `initialSlots` | `Array<Slot>` | `[]` | Slots to fetch before the DOM is ready |
80
+ | `logReferrer` | `boolean` | `true` | Will log the `document.referrer` to the Adhese API in a `BASE64` string with the `re` parameter. |
81
+ | `logUrl` | `boolean` | `true` | Will log the `location.href` to the Adhese API in a `BASE64` string with the `ur` parameter. |'
82
+ | `eagerRendering` | `boolean` | `false` | Will render the ad as soon as it is fetched. In general it is recommended to keep this `false` for better performance. |
83
+ | `queries` | `Record<string, string>` | `{phone: '(max-width: 768px) and (pointer: coarse)',tablet: '(min-width: 769px) and (max-width: 1024px) and (pointer: coarse)',desktop: '(min-width: 1025px) and (pointer: fine)',}` | Will be used to determine the device type and screen size. The matching query key will be passed in the `dt` and `br` parameter. |
84
+ | `plugins` | `ReadonlyArray<(context: AdheseContext) => void>` | `[]` | The plugins that are used for the Adhese instance. These plugins are called with the Adhese context and run during the initialization of the Adhese instance. |
85
85
 
86
86
  \* Required
@@ -70,6 +70,18 @@ type AdheseSlotOptions = {
70
70
  * @default 'iframe'
71
71
  */
72
72
  renderMode?: RenderMode;
73
+ /**
74
+ * Overwrite the width of the slot. If not provided, the width will be determined by the ad response
75
+ *
76
+ * Will be ignored if `renderMode` is set to `inline` or `none`
77
+ */
78
+ width?: number | string;
79
+ /**
80
+ * Overwrite the height of the slot. If not provided, the height will be determined by the ad response
81
+ *
82
+ * Will be ignored if `renderMode` is set to `inline` or `none`
83
+ */
84
+ height?: number | string;
73
85
  /**
74
86
  * Specific options for the slot that may be used my plugins
75
87
  */
@@ -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 = "1.0.4";
4
+ const version = "1.1.1";
5
5
  exports.name = name;
6
6
  exports.version = version;
7
7
  //# sourceMappingURL=package.json.cjs.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const sdkShared = require("@adhese/sdk-shared");
4
4
  function useQueryDetector(context, queries = {
5
- mobile: "(max-width: 768px)",
5
+ phone: "(max-width: 768px)",
6
6
  tablet: "(min-width: 769px) and (max-width: 1024px)",
7
7
  desktop: "(min-width: 1025px)"
8
8
  }) {
@@ -1 +1 @@
1
- {"version":3,"file":"queryDetector.cjs","sources":["../../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n mobile: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":["ref","debounce","computed"],"mappings":";;;AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAASA,UAAA,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiBC,UAAAA,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAACC,UAAS,SAAA,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;;"}
1
+ {"version":3,"file":"queryDetector.cjs","sources":["../../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n phone: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":["ref","debounce","computed"],"mappings":";;;AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAASA,UAAA,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiBC,UAAAA,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAACC,UAAS,SAAA,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;;"}
@@ -152,7 +152,10 @@ function createSlot(slotOptions) {
152
152
  status.value = "error";
153
153
  throw new Error(error);
154
154
  }
155
- renderFunctions[renderMode](renderAd, element.value);
155
+ renderFunctions[renderMode]({
156
+ ...renderAd,
157
+ ...sdkShared.pick(options, ["width", "height"])
158
+ }, element.value);
156
159
  if (renderAd.impressionCounter && !impressionTrackingPixelElement.value)
157
160
  impressionTrackingPixelElement.value = sdkShared.addTrackingPixel(renderAd.impressionCounter);
158
161
  isImpressionTracked.value = true;
@@ -1 +1 @@
1
- {"version":3,"file":"slot.cjs","sources":["../../../src/slot/slot.ts"],"sourcesContent":["import {\n type Ref,\n type RenderOptions,\n type UnwrapRef,\n addTrackingPixel,\n computed,\n doNothing,\n effectScope,\n generateName,\n isDeepEqual,\n omit,\n reactive,\n ref,\n renderIframe,\n renderInline,\n uniqueId,\n waitForDomLoad,\n watch,\n} from '@adhese/sdk-shared';\nimport type { AdheseAd } from '@adhese/sdk';\nimport { requestAd as extRequestAd } from '../requestAds/requestAds';\nimport { logger } from '../logger/logger';\nimport { useQueryDetector } from '../queryDetector/queryDetector';\nimport type { AdheseSlot, AdheseSlotContext, AdheseSlotOptions, RenderMode } from './slot.types';\nimport {\n useDomLoaded,\n useRenderIntersectionObserver,\n useSlotHooks,\n useViewabilityObserver,\n} from './slot.composables';\n\nconst renderFunctions: Record<RenderMode, (ad: RenderOptions, element: HTMLElement) => void> = {\n iframe: renderIframe,\n inline: renderInline,\n none: doNothing,\n};\n\nconst defaultOptions = {\n renderMode: 'iframe',\n type: 'normal',\n} satisfies Partial<AdheseSlotOptions>;\n\n/**\n * Create a new slot instance. This slot instance can be used to request and render ads.\n *\n * @param slotOptions {AdheseSlotOptions} The options to create the slot with.\n *\n * @return AdheseSlot The created slot instance.\n */\nexport function createSlot(slotOptions: AdheseSlotOptions): AdheseSlot {\n const scope = effectScope();\n\n return scope.run(() => {\n const slotContext = ref<AdheseSlotContext | null>(null);\n const options = slotOptions.context.hooks.runOnSlotCreate({\n ...defaultOptions,\n ...slotOptions,\n });\n\n const {\n containingElement,\n slot,\n context,\n pluginOptions,\n renderMode = 'iframe',\n type = 'normal',\n } = options;\n\n const id = uniqueId();\n const {\n runOnBeforeRender,\n runOnRender,\n runOnBeforeRequest,\n runOnRequest,\n runOnInit,\n runOnDispose,\n ...hooks\n } = useSlotHooks(options, slotContext);\n\n const isDisposed = ref(false);\n const parameters = reactive(new Map(Object.entries(options.parameters ?? {})));\n\n const [device, disposeQueryDetector] = useQueryDetector(context, typeof options.format === 'string'\n ? {\n [options.format]: '(min-width: 0px)',\n }\n : Object.fromEntries(options.format.map(item => [item.format, item.query])));\n\n const format = computed(() => typeof options.format === 'string' ? options.format : device.value);\n\n const data = ref<AdheseAd | null>(null) as Ref<AdheseAd | null>;\n const originalData = ref(data.value) as Ref<AdheseAd | null>;\n const name = computed(() => generateName(options.context.location, format.value, options.slot));\n\n watch(name, async (newName, oldName) => {\n if (newName === oldName)\n return;\n\n const newAd = await slotContext.value?.request();\n\n if (!newAd)\n return;\n\n slotContext.value?.cleanElement();\n\n data.value = newAd;\n originalData.value = newAd;\n });\n\n const isDomLoaded = useDomLoaded(context);\n\n const element = computed(() => {\n if (!(typeof options.containingElement === 'string' || !options.containingElement))\n return options.containingElement;\n\n if (!isDomLoaded.value || slotContext.value?.isDisposed)\n return null;\n\n return document.querySelector<HTMLElement>(`.adunit[data-format=\"${format.value}\"]#${options.containingElement}${options.slot ? `[data-slot=\"${options.slot}\"]` : ''}`);\n },\n );\n\n const isInViewport = useRenderIntersectionObserver({\n options,\n element,\n hooks,\n });\n\n const status = ref<UnwrapRef<AdheseSlot>['status']>('initializing');\n\n watch([data, isInViewport], async ([newData, newIsInViewport], [oldData]) => {\n if ((!newData || (oldData && isDeepEqual(newData, oldData))) && status.value === 'rendered')\n return;\n\n if (newIsInViewport)\n await slotContext.value?.render(newData ?? undefined);\n });\n\n hooks.onDispose(() => {\n disposeQueryDetector();\n });\n\n const isViewabilityTracked = useViewabilityObserver({\n context,\n slotContext,\n hooks,\n onTracked(trackingPixel) {\n if (slotContext.value?.data?.viewableImpressionCounter) {\n trackingPixel.value = addTrackingPixel(slotContext.value?.data?.viewableImpressionCounter);\n\n context.logger.debug(`Viewability tracking pixel fired for ${slotContext.value?.name}`);\n }\n },\n });\n\n const impressionTrackingPixelElement = ref<HTMLImageElement | null>(null);\n const isImpressionTracked = ref(false);\n hooks.onDispose(() => {\n if (impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value.remove();\n });\n\n async function request(): Promise<AdheseAd | null> {\n if (options.lazyLoading && !isInViewport.value)\n return null;\n\n status.value = 'loading';\n\n let response = await runOnBeforeRequest(null);\n\n if (!response) {\n response = await extRequestAd({\n slot: {\n name: name.value,\n parameters,\n },\n context,\n });\n }\n\n if (response)\n response = await runOnRequest(response);\n\n data.value = response;\n\n if (!originalData.value)\n originalData.value = response;\n\n status.value = response ? 'loaded' : 'empty';\n\n if (!response)\n cleanElement();\n\n return response;\n }\n\n async function render(adToRender?: AdheseAd): Promise<HTMLElement | null> {\n status.value = 'rendering';\n\n await waitForDomLoad();\n\n let renderAd = adToRender ?? data.value ?? originalData.value ?? await request();\n\n renderAd = renderAd && await runOnBeforeRender(renderAd);\n\n if (!renderAd) {\n status.value = 'empty';\n logger.debug(`No ad to render for slot ${name.value}`);\n\n return null;\n }\n\n if (!element.value) {\n const error = `Could not create slot for format ${format.value}. No element found.`;\n logger.error(error, options);\n throw new Error(error);\n }\n\n if (context.debug)\n element.value.style.position = 'relative';\n\n if (typeof renderAd?.tag !== 'string') {\n const error = `Could not render slot for slot ${name.value}. A valid tag doesn't exist or is not HTML string.`;\n logger.error(error, options);\n\n status.value = 'error';\n throw new Error(error);\n }\n\n renderFunctions[renderMode](renderAd as RenderOptions, element.value);\n\n if (renderAd.impressionCounter && !impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value = addTrackingPixel(renderAd.impressionCounter);\n\n isImpressionTracked.value = true;\n\n logger.debug(`Slot rendered ${name.value}`, {\n renderedElement: element,\n location: context.location,\n format,\n containingElement,\n });\n\n status.value = 'rendered';\n\n runOnRender(renderAd);\n\n return element.value;\n }\n\n function cleanElement(): void {\n if (!element.value)\n return;\n\n element.value.innerHTML = '';\n element.value.style.position = '';\n element.value.style.width = '';\n element.value.style.height = '';\n\n data.value = null;\n originalData.value = null;\n }\n\n function dispose(): void {\n cleanElement();\n\n data.value = null;\n\n runOnDispose();\n\n isDisposed.value = true;\n\n scope.stop();\n }\n\n const state = reactive({\n location: context.location ?? '',\n lazyLoading: options.lazyLoading ?? false,\n type,\n slot,\n parameters,\n format,\n name,\n data,\n isViewabilityTracked,\n isImpressionTracked,\n status,\n element,\n isDisposed,\n id,\n pluginOptions,\n isVisible: isInViewport,\n render,\n request,\n dispose,\n cleanElement,\n options: omit(options, ['context']),\n ...hooks,\n });\n\n watch(state, (newState) => {\n slotContext.value = newState;\n }, {\n deep: true,\n immediate: true,\n });\n\n context.hooks.onInit(async () => {\n status.value = 'initialized';\n\n runOnInit();\n\n if (options.lazyLoading)\n return;\n\n data.value = await slotContext.value?.request() ?? null;\n });\n\n return state;\n })!;\n}\n"],"names":["renderIframe","renderInline","doNothing","effectScope","ref","uniqueId","useSlotHooks","reactive","useQueryDetector","computed","generateName","watch","useDomLoaded","useRenderIntersectionObserver","isDeepEqual","useViewabilityObserver","addTrackingPixel","extRequestAd","waitForDomLoad","logger","omit"],"mappings":";;;;;;;AA+BA,MAAM,kBAAyF;AAAA,EAC7F,QAAQA,UAAA;AAAA,EACR,QAAQC,UAAA;AAAA,EACR,MAAMC,UAAA;AACR;AAEA,MAAM,iBAAiB;AAAA,EACrB,YAAY;AAAA,EACZ,MAAM;AACR;AASO,SAAS,WAAW,aAA4C;AACrE,QAAM,QAAQC,UAAAA;AAEP,SAAA,MAAM,IAAI,MAAM;AACf,UAAA,cAAcC,cAA8B,IAAI;AACtD,UAAM,UAAU,YAAY,QAAQ,MAAM,gBAAgB;AAAA,MACxD,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAEK,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AA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ent":["import {\n type Ref,\n type RenderOptions,\n type UnwrapRef,\n addTrackingPixel,\n computed,\n doNothing,\n effectScope,\n generateName,\n isDeepEqual,\n omit,\n pick,\n reactive,\n ref,\n renderIframe,\n renderInline,\n uniqueId,\n waitForDomLoad,\n watch,\n} from '@adhese/sdk-shared';\nimport type { AdheseAd } from '@adhese/sdk';\nimport { requestAd as extRequestAd } from '../requestAds/requestAds';\nimport { logger } from '../logger/logger';\nimport { useQueryDetector } from '../queryDetector/queryDetector';\nimport type { AdheseSlot, AdheseSlotContext, AdheseSlotOptions, RenderMode } from './slot.types';\nimport {\n useDomLoaded,\n useRenderIntersectionObserver,\n useSlotHooks,\n useViewabilityObserver,\n} from './slot.composables';\n\nconst renderFunctions: Record<RenderMode, (ad: RenderOptions, element: HTMLElement) => void> = {\n iframe: renderIframe,\n inline: renderInline,\n none: doNothing,\n};\n\nconst defaultOptions = {\n renderMode: 'iframe',\n type: 'normal',\n} satisfies Partial<AdheseSlotOptions>;\n\n/**\n * Create a new slot instance. This slot instance can be used to request and render ads.\n *\n * @param slotOptions {AdheseSlotOptions} The options to create the slot with.\n *\n * @return AdheseSlot The created slot instance.\n */\nexport function createSlot(slotOptions: AdheseSlotOptions): AdheseSlot {\n const scope = effectScope();\n\n return scope.run(() => {\n const slotContext = ref<AdheseSlotContext | null>(null);\n const options = slotOptions.context.hooks.runOnSlotCreate({\n ...defaultOptions,\n ...slotOptions,\n });\n\n const {\n containingElement,\n slot,\n context,\n pluginOptions,\n renderMode = 'iframe',\n type = 'normal',\n } = options;\n\n const id = uniqueId();\n const {\n runOnBeforeRender,\n runOnRender,\n runOnBeforeRequest,\n runOnRequest,\n runOnInit,\n runOnDispose,\n ...hooks\n } = useSlotHooks(options, slotContext);\n\n const isDisposed = ref(false);\n const parameters = reactive(new Map(Object.entries(options.parameters ?? {})));\n\n const [device, disposeQueryDetector] = useQueryDetector(context, typeof options.format === 'string'\n ? {\n [options.format]: '(min-width: 0px)',\n }\n : Object.fromEntries(options.format.map(item => [item.format, item.query])));\n\n const format = computed(() => typeof options.format === 'string' ? options.format : device.value);\n\n const data = ref<AdheseAd | null>(null) as Ref<AdheseAd | null>;\n const originalData = ref(data.value) as Ref<AdheseAd | null>;\n const name = computed(() => generateName(options.context.location, format.value, options.slot));\n\n watch(name, async (newName, oldName) => {\n if (newName === oldName)\n return;\n\n const newAd = await slotContext.value?.request();\n\n if (!newAd)\n return;\n\n slotContext.value?.cleanElement();\n\n data.value = newAd;\n originalData.value = newAd;\n });\n\n const isDomLoaded = useDomLoaded(context);\n\n const element = computed(() => {\n if (!(typeof options.containingElement === 'string' || !options.containingElement))\n return options.containingElement;\n\n if (!isDomLoaded.value || slotContext.value?.isDisposed)\n return null;\n\n return document.querySelector<HTMLElement>(`.adunit[data-format=\"${format.value}\"]#${options.containingElement}${options.slot ? `[data-slot=\"${options.slot}\"]` : ''}`);\n },\n );\n\n const isInViewport = useRenderIntersectionObserver({\n options,\n element,\n hooks,\n });\n\n const status = ref<UnwrapRef<AdheseSlot>['status']>('initializing');\n\n watch([data, isInViewport], async ([newData, newIsInViewport], [oldData]) => {\n if ((!newData || (oldData && isDeepEqual(newData, oldData))) && status.value === 'rendered')\n return;\n\n if (newIsInViewport)\n await slotContext.value?.render(newData ?? undefined);\n });\n\n hooks.onDispose(() => {\n disposeQueryDetector();\n });\n\n const isViewabilityTracked = useViewabilityObserver({\n context,\n slotContext,\n hooks,\n onTracked(trackingPixel) {\n if (slotContext.value?.data?.viewableImpressionCounter) {\n trackingPixel.value = addTrackingPixel(slotContext.value?.data?.viewableImpressionCounter);\n\n context.logger.debug(`Viewability tracking pixel fired for ${slotContext.value?.name}`);\n }\n },\n });\n\n const impressionTrackingPixelElement = ref<HTMLImageElement | null>(null);\n const isImpressionTracked = ref(false);\n hooks.onDispose(() => {\n if (impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value.remove();\n });\n\n async function request(): Promise<AdheseAd | null> {\n if (options.lazyLoading && !isInViewport.value)\n return null;\n\n status.value = 'loading';\n\n let response = await runOnBeforeRequest(null);\n\n if (!response) {\n response = await extRequestAd({\n slot: {\n name: name.value,\n parameters,\n },\n context,\n });\n }\n\n if (response)\n response = await runOnRequest(response);\n\n data.value = response;\n\n if (!originalData.value)\n originalData.value = response;\n\n status.value = response ? 'loaded' : 'empty';\n\n if (!response)\n cleanElement();\n\n return response;\n }\n\n async function render(adToRender?: AdheseAd): Promise<HTMLElement | null> {\n status.value = 'rendering';\n\n await waitForDomLoad();\n\n let renderAd = adToRender ?? data.value ?? originalData.value ?? await request();\n\n renderAd = renderAd && await runOnBeforeRender(renderAd);\n\n if (!renderAd) {\n status.value = 'empty';\n logger.debug(`No ad to render for slot ${name.value}`);\n\n return null;\n }\n\n if (!element.value) {\n const error = `Could not create slot for format ${format.value}. No element found.`;\n logger.error(error, options);\n throw new Error(error);\n }\n\n if (context.debug)\n element.value.style.position = 'relative';\n\n if (typeof renderAd?.tag !== 'string') {\n const error = `Could not render slot for slot ${name.value}. A valid tag doesn't exist or is not HTML string.`;\n logger.error(error, options);\n\n status.value = 'error';\n throw new Error(error);\n }\n\n renderFunctions[renderMode]({\n ...renderAd,\n ...pick(options, ['width', 'height']),\n } as RenderOptions, element.value);\n\n if (renderAd.impressionCounter && !impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value = addTrackingPixel(renderAd.impressionCounter);\n\n isImpressionTracked.value = true;\n\n logger.debug(`Slot rendered ${name.value}`, {\n renderedElement: element,\n location: context.location,\n format,\n containingElement,\n });\n\n status.value = 'rendered';\n\n runOnRender(renderAd);\n\n return element.value;\n }\n\n function cleanElement(): void {\n if (!element.value)\n return;\n\n element.value.innerHTML = '';\n element.value.style.position = '';\n element.value.style.width = '';\n element.value.style.height = '';\n\n data.value = null;\n originalData.value = null;\n }\n\n function dispose(): void {\n cleanElement();\n\n data.value = null;\n\n runOnDispose();\n\n isDisposed.value = true;\n\n scope.stop();\n }\n\n const state = reactive({\n location: context.location ?? '',\n lazyLoading: options.lazyLoading ?? false,\n type,\n slot,\n parameters,\n format,\n name,\n data,\n isViewabilityTracked,\n isImpressionTracked,\n status,\n element,\n isDisposed,\n id,\n pluginOptions,\n isVisible: isInViewport,\n render,\n request,\n dispose,\n cleanElement,\n options: omit(options, ['context']),\n ...hooks,\n });\n\n watch(state, (newState) => {\n slotContext.value = newState;\n }, {\n deep: true,\n immediate: true,\n });\n\n context.hooks.onInit(async () => {\n status.value = 'initialized';\n\n runOnInit();\n\n if (options.lazyLoading)\n return;\n\n data.value = await slotContext.value?.request() ?? null;\n });\n\n return state;\n })!;\n}\n"],"names":["renderIframe","renderInline","doNothing","effectScope","ref","uniqueId","useSlotHooks","reactive","useQueryDetector","computed","generateName","watch","useDomLoaded","useRenderIntersectionObserver","isDeepEqual","useViewabilityObserver","addTrackingPixel","extRequestAd","waitForDomLoad","logger","pick","omit"],"mappings":";;;;;;;AAgCA,MAAM,kBAAyF;AAAA,EAC7F,QAAQA,UAAA;AAAA,EACR,QAAQC,UAAA;AAAA,EACR,MAAMC,UAAA;AACR;AAEA,MAAM,iBAAiB;AAAA,EACrB,YAAY;AAAA,EACZ,MAAM;AACR;AASO,SAAS,WAAW,aAA4C;AACrE,QAAM,QAAQC,UAAAA;AAEP,SAAA,MAAM,IAAI,MAAM;AACf,UAAA,cAAcC,cAA8B,IAAI;AACtD,UAAM,UAAU,YAAY,QAAQ,MAAM,gBAAgB;AAAA,MACxD,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAEK,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb,OAAO;AAAA,IACL,IAAA;AAEJ,UAAM,KAAKC,UAAAA;AACL,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,IACDC,iBAAa,aAAA,SAAS,WAAW;AAE/B,UAAA,aAAaF,cAAI,KAAK;AACtB,UAAA,aAAaG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B;AAC5B,UAAI,CAAC,QAAQ;AACX;AAEF,cAAQ,MAAM,YAAY;AAClB,cAAA,MAAM,MAAM,WAAW;AACvB,cAAA,MAAM,MAAM,QAAQ;AACpB,cAAA,MAAM,MAAM,SAAS;AAE7B,WAAK,QAAQ;AACb,mBAAa,QAAQ;AAAA,IACvB;AAEA,aAAS,UAAgB;AACV;AAEb,WAAK,QAAQ;AAEA;AAEb,iBAAW,QAAQ;AAEnB,YAAM,KAAK;AAAA,IACb;AAEA,UAAM,QAAQZ,UAAAA,SAAS;AAAA,MACrB,UAAU,QAAQ,YAAY;AAAA,MAC9B,aAAa,QAAQ,eAAe;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAASc,UAAA,KAAK,SAAS,CAAC,SAAS,CAAC;AAAA,MAClC,GAAG;AAAA,IAAA,CACJ;AAEKV,oBAAA,OAAO,CAAC,aAAa;AACzB,kBAAY,QAAQ;AAAA,IAAA,GACnB;AAAA,MACD,MAAM;AAAA,MACN,WAAW;AAAA,IAAA,CACZ;AAEO,YAAA,MAAM,OAAO,YAAY;;AAC/B,aAAO,QAAQ;AAEL;AAEV,UAAI,QAAQ;AACV;AAEF,WAAK,QAAQ,QAAM,iBAAY,UAAZ,mBAAmB,cAAa;AAAA,IAAA,CACpD;AAEM,WAAA;AAAA,EAAA,CACR;AACH;;"}
@@ -1,5 +1,5 @@
1
1
  const name = "@adhese/sdk";
2
- const version = "1.0.4";
2
+ const version = "1.1.1";
3
3
  export {
4
4
  name,
5
5
  version
@@ -1,6 +1,6 @@
1
1
  import { ref, debounce, computed } from "@adhese/sdk-shared";
2
2
  function useQueryDetector(context, queries = {
3
- mobile: "(max-width: 768px)",
3
+ phone: "(max-width: 768px)",
4
4
  tablet: "(min-width: 769px) and (max-width: 1024px)",
5
5
  desktop: "(min-width: 1025px)"
6
6
  }) {
@@ -1 +1 @@
1
- {"version":3,"file":"queryDetector.js","sources":["../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n mobile: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":[],"mappings":";AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAAS,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiB,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAAC,SAAS,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"queryDetector.js","sources":["../../src/queryDetector/queryDetector.ts"],"sourcesContent":["import { type ComputedRef, computed, debounce, ref } from '@adhese/sdk-shared';\nimport type { AdheseContext } from '@adhese/sdk';\n\n/**\n * Create a query detector that will match a list of media queries and keeps track of the current matching query\n */\nexport function useQueryDetector(context: AdheseContext, queries: Record<string, string> = {\n phone: '(max-width: 768px)',\n tablet: '(min-width: 769px) and (max-width: 1024px)',\n desktop: '(min-width: 1025px)',\n}): [ComputedRef<string>, () => void] {\n const entries = Object.entries(queries);\n\n const active = ref(getQuery(entries));\n const queryList = entries.map(([, query]) => window.matchMedia(query));\n\n const handleOnChange = debounce((): void => {\n active.value = getQuery(entries);\n }, {\n waitMs: 50,\n });\n\n context.hooks.onInit(() => {\n for (const query of queryList)\n query.addEventListener('change', handleOnChange.call);\n\n handleOnChange.call();\n });\n\n function dispose(): void {\n for (const query of queryList)\n query.removeEventListener('change', handleOnChange.call);\n }\n\n context.hooks.onDispose(dispose);\n\n return [computed(() => active.value), dispose];\n}\n\nfunction getQuery(entries: ReadonlyArray<[string, string]>): string {\n for (const [device, query] of entries) {\n if (window.matchMedia(query).matches)\n return device;\n }\n\n return 'unknown';\n}\n"],"names":[],"mappings":";AAMgB,SAAA,iBAAiB,SAAwB,UAAkC;AAAA,EACzF,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX,GAAsC;AAC9B,QAAA,UAAU,OAAO,QAAQ,OAAO;AAEtC,QAAM,SAAS,IAAI,SAAS,OAAO,CAAC;AAC9B,QAAA,YAAY,QAAQ,IAAI,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,WAAW,KAAK,CAAC;AAE/D,QAAA,iBAAiB,SAAS,MAAY;AACnC,WAAA,QAAQ,SAAS,OAAO;AAAA,EAAA,GAC9B;AAAA,IACD,QAAQ;AAAA,EAAA,CACT;AAEO,UAAA,MAAM,OAAO,MAAM;AACzB,eAAW,SAAS;AACZ,YAAA,iBAAiB,UAAU,eAAe,IAAI;AAEtD,mBAAe,KAAK;AAAA,EAAA,CACrB;AAED,WAAS,UAAgB;AACvB,eAAW,SAAS;AACZ,YAAA,oBAAoB,UAAU,eAAe,IAAI;AAAA,EAC3D;AAEQ,UAAA,MAAM,UAAU,OAAO;AAE/B,SAAO,CAAC,SAAS,MAAM,OAAO,KAAK,GAAG,OAAO;AAC/C;AAEA,SAAS,SAAS,SAAkD;AAClE,aAAW,CAAC,QAAQ,KAAK,KAAK,SAAS;AACjC,QAAA,OAAO,WAAW,KAAK,EAAE;AACpB,aAAA;AAAA,EACX;AAEO,SAAA;AACT;"}
package/dist/slot/slot.js CHANGED
@@ -1,4 +1,4 @@
1
- import { effectScope, ref, uniqueId, reactive, computed, generateName, watch, isDeepEqual, omit, addTrackingPixel, waitForDomLoad, renderIframe, renderInline, doNothing } from "@adhese/sdk-shared";
1
+ import { effectScope, ref, uniqueId, reactive, computed, generateName, watch, isDeepEqual, omit, addTrackingPixel, waitForDomLoad, pick, renderIframe, renderInline, doNothing } from "@adhese/sdk-shared";
2
2
  import { requestAd } from "../requestAds/requestAds.js";
3
3
  import { logger } from "../logger/logger.js";
4
4
  import { useQueryDetector } from "../queryDetector/queryDetector.js";
@@ -150,7 +150,10 @@ function createSlot(slotOptions) {
150
150
  status.value = "error";
151
151
  throw new Error(error);
152
152
  }
153
- renderFunctions[renderMode](renderAd, element.value);
153
+ renderFunctions[renderMode]({
154
+ ...renderAd,
155
+ ...pick(options, ["width", "height"])
156
+ }, element.value);
154
157
  if (renderAd.impressionCounter && !impressionTrackingPixelElement.value)
155
158
  impressionTrackingPixelElement.value = addTrackingPixel(renderAd.impressionCounter);
156
159
  isImpressionTracked.value = true;
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","sources":["../../src/slot/slot.ts"],"sourcesContent":["import {\n type Ref,\n type RenderOptions,\n type UnwrapRef,\n addTrackingPixel,\n computed,\n doNothing,\n effectScope,\n generateName,\n isDeepEqual,\n omit,\n reactive,\n ref,\n renderIframe,\n renderInline,\n uniqueId,\n waitForDomLoad,\n watch,\n} from '@adhese/sdk-shared';\nimport type { AdheseAd } from '@adhese/sdk';\nimport { requestAd as extRequestAd } from '../requestAds/requestAds';\nimport { logger } from '../logger/logger';\nimport { useQueryDetector } from '../queryDetector/queryDetector';\nimport type { AdheseSlot, AdheseSlotContext, AdheseSlotOptions, RenderMode } from './slot.types';\nimport {\n useDomLoaded,\n useRenderIntersectionObserver,\n useSlotHooks,\n useViewabilityObserver,\n} from './slot.composables';\n\nconst renderFunctions: Record<RenderMode, (ad: RenderOptions, element: HTMLElement) => void> = {\n iframe: renderIframe,\n inline: renderInline,\n none: doNothing,\n};\n\nconst defaultOptions = {\n renderMode: 'iframe',\n type: 'normal',\n} satisfies Partial<AdheseSlotOptions>;\n\n/**\n * Create a new slot instance. This slot instance can be used to request and render ads.\n *\n * @param slotOptions {AdheseSlotOptions} The options to create the slot with.\n *\n * @return AdheseSlot The created slot instance.\n */\nexport function createSlot(slotOptions: AdheseSlotOptions): AdheseSlot {\n const scope = effectScope();\n\n return scope.run(() => {\n const slotContext = ref<AdheseSlotContext | null>(null);\n const options = slotOptions.context.hooks.runOnSlotCreate({\n ...defaultOptions,\n ...slotOptions,\n });\n\n const {\n containingElement,\n slot,\n context,\n pluginOptions,\n renderMode = 'iframe',\n type = 'normal',\n } = options;\n\n const id = uniqueId();\n const {\n runOnBeforeRender,\n runOnRender,\n runOnBeforeRequest,\n runOnRequest,\n runOnInit,\n runOnDispose,\n ...hooks\n } = useSlotHooks(options, slotContext);\n\n const isDisposed = ref(false);\n const parameters = reactive(new Map(Object.entries(options.parameters ?? {})));\n\n const [device, disposeQueryDetector] = useQueryDetector(context, typeof options.format === 'string'\n ? {\n [options.format]: '(min-width: 0px)',\n }\n : Object.fromEntries(options.format.map(item => [item.format, item.query])));\n\n const format = computed(() => typeof options.format === 'string' ? options.format : device.value);\n\n const data = ref<AdheseAd | null>(null) as Ref<AdheseAd | null>;\n const originalData = ref(data.value) as Ref<AdheseAd | null>;\n const name = computed(() => generateName(options.context.location, format.value, options.slot));\n\n watch(name, async (newName, oldName) => {\n if (newName === oldName)\n return;\n\n const newAd = await slotContext.value?.request();\n\n if (!newAd)\n return;\n\n slotContext.value?.cleanElement();\n\n data.value = newAd;\n originalData.value = newAd;\n });\n\n const isDomLoaded = useDomLoaded(context);\n\n const element = computed(() => {\n if (!(typeof options.containingElement === 'string' || !options.containingElement))\n return options.containingElement;\n\n if (!isDomLoaded.value || slotContext.value?.isDisposed)\n return null;\n\n return document.querySelector<HTMLElement>(`.adunit[data-format=\"${format.value}\"]#${options.containingElement}${options.slot ? `[data-slot=\"${options.slot}\"]` : ''}`);\n },\n );\n\n const isInViewport = useRenderIntersectionObserver({\n options,\n element,\n hooks,\n });\n\n const status = ref<UnwrapRef<AdheseSlot>['status']>('initializing');\n\n watch([data, isInViewport], async ([newData, newIsInViewport], [oldData]) => {\n if ((!newData || (oldData && isDeepEqual(newData, oldData))) && status.value === 'rendered')\n return;\n\n if (newIsInViewport)\n await slotContext.value?.render(newData ?? undefined);\n });\n\n hooks.onDispose(() => {\n disposeQueryDetector();\n });\n\n const isViewabilityTracked = useViewabilityObserver({\n context,\n slotContext,\n hooks,\n onTracked(trackingPixel) {\n if (slotContext.value?.data?.viewableImpressionCounter) {\n trackingPixel.value = addTrackingPixel(slotContext.value?.data?.viewableImpressionCounter);\n\n context.logger.debug(`Viewability tracking pixel fired for ${slotContext.value?.name}`);\n }\n },\n });\n\n const impressionTrackingPixelElement = ref<HTMLImageElement | null>(null);\n const isImpressionTracked = ref(false);\n hooks.onDispose(() => {\n if (impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value.remove();\n });\n\n async function request(): Promise<AdheseAd | null> {\n if (options.lazyLoading && !isInViewport.value)\n return null;\n\n status.value = 'loading';\n\n let response = await runOnBeforeRequest(null);\n\n if (!response) {\n response = await extRequestAd({\n slot: {\n name: name.value,\n parameters,\n },\n context,\n });\n }\n\n if (response)\n response = await runOnRequest(response);\n\n data.value = response;\n\n if (!originalData.value)\n originalData.value = response;\n\n status.value = response ? 'loaded' : 'empty';\n\n if (!response)\n cleanElement();\n\n return response;\n }\n\n async function render(adToRender?: AdheseAd): Promise<HTMLElement | null> {\n status.value = 'rendering';\n\n await waitForDomLoad();\n\n let renderAd = adToRender ?? data.value ?? originalData.value ?? await request();\n\n renderAd = renderAd && await runOnBeforeRender(renderAd);\n\n if (!renderAd) {\n status.value = 'empty';\n logger.debug(`No ad to render for slot ${name.value}`);\n\n return null;\n }\n\n if (!element.value) {\n const error = `Could not create slot for format ${format.value}. No element found.`;\n logger.error(error, options);\n throw new Error(error);\n }\n\n if (context.debug)\n element.value.style.position = 'relative';\n\n if (typeof renderAd?.tag !== 'string') {\n const error = `Could not render slot for slot ${name.value}. A valid tag doesn't exist or is not HTML string.`;\n logger.error(error, options);\n\n status.value = 'error';\n throw new Error(error);\n }\n\n renderFunctions[renderMode](renderAd as RenderOptions, element.value);\n\n if (renderAd.impressionCounter && !impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value = addTrackingPixel(renderAd.impressionCounter);\n\n isImpressionTracked.value = true;\n\n logger.debug(`Slot rendered ${name.value}`, {\n renderedElement: element,\n location: context.location,\n format,\n containingElement,\n });\n\n status.value = 'rendered';\n\n runOnRender(renderAd);\n\n return element.value;\n }\n\n function cleanElement(): void {\n if (!element.value)\n return;\n\n element.value.innerHTML = '';\n element.value.style.position = '';\n element.value.style.width = '';\n element.value.style.height = '';\n\n data.value = null;\n originalData.value = null;\n }\n\n function dispose(): void {\n cleanElement();\n\n data.value = null;\n\n runOnDispose();\n\n isDisposed.value = true;\n\n scope.stop();\n }\n\n const state = reactive({\n location: context.location ?? '',\n lazyLoading: options.lazyLoading ?? false,\n type,\n slot,\n parameters,\n format,\n name,\n data,\n isViewabilityTracked,\n isImpressionTracked,\n status,\n element,\n isDisposed,\n id,\n pluginOptions,\n isVisible: isInViewport,\n render,\n request,\n dispose,\n cleanElement,\n options: omit(options, ['context']),\n ...hooks,\n });\n\n watch(state, (newState) => {\n slotContext.value = newState;\n }, {\n deep: true,\n immediate: true,\n });\n\n context.hooks.onInit(async () => {\n status.value = 'initialized';\n\n runOnInit();\n\n if (options.lazyLoading)\n return;\n\n data.value = await slotContext.value?.request() ?? null;\n });\n\n return state;\n })!;\n}\n"],"names":["extRequestAd"],"mappings":";;;;;AA+BA,MAAM,kBAAyF;AAAA,EAC7F,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AACR;AAEA,MAAM,iBAAiB;AAAA,EACrB,YAAY;AAAA,EACZ,MAAM;AACR;AASO,SAAS,WAAW,aAA4C;AACrE,QAAM,QAAQ;AAEP,SAAA,MAAM,IAAI,MAAM;AACf,UAAA,cAAc,IAA8B,IAAI;AACtD,UAAM,UAAU,YAAY,QAAQ,MAAM,gBAAgB;AAAA,MACxD,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAEK,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb,OAAO;AAAA,IACL,IAAA;AAEJ,UAAM,KAAK;AACL,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA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AAM,MAAM,SAAS;AAE7B,WAAK,QAAQ;AACb,mBAAa,QAAQ;AAAA,IACvB;AAEA,aAAS,UAAgB;AACV;AAEb,WAAK,QAAQ;AAEA;AAEb,iBAAW,QAAQ;AAEnB,YAAM,KAAK;AAAA,IACb;AAEA,UAAM,QAAQ,SAAS;AAAA,MACrB,UAAU,QAAQ,YAAY;AAAA,MAC9B,aAAa,QAAQ,eAAe;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,KAAK,SAAS,CAAC,SAAS,CAAC;AAAA,MAClC,GAAG;AAAA,IAAA,CACJ;AAEK,UAAA,OAAO,CAAC,aAAa;AACzB,kBAAY,QAAQ;AAAA,IAAA,GACnB;AAAA,MACD,MAAM;AAAA,MACN,WAAW;AAAA,IAAA,CACZ;AAEO,YAAA,MAAM,OAAO,YAAY;;AAC/B,aAAO,QAAQ;AAEL;AAEV,UAAI,QAAQ;AACV;AAEF,WAAK,QAAQ,QAAM,iBAAY,UAAZ,mBAAmB,cAAa;AAAA,IAAA,CACpD;AAEM,WAAA;AAAA,EAAA,CACR;AACH;"}
1
+ {"version":3,"file":"slot.js","sources":["../../src/slot/slot.ts"],"sourcesContent":["import {\n type Ref,\n type RenderOptions,\n type UnwrapRef,\n addTrackingPixel,\n computed,\n doNothing,\n effectScope,\n generateName,\n isDeepEqual,\n omit,\n pick,\n reactive,\n ref,\n renderIframe,\n renderInline,\n uniqueId,\n waitForDomLoad,\n watch,\n} from '@adhese/sdk-shared';\nimport type { AdheseAd } from '@adhese/sdk';\nimport { requestAd as extRequestAd } from '../requestAds/requestAds';\nimport { logger } from '../logger/logger';\nimport { useQueryDetector } from '../queryDetector/queryDetector';\nimport type { AdheseSlot, AdheseSlotContext, AdheseSlotOptions, RenderMode } from './slot.types';\nimport {\n useDomLoaded,\n useRenderIntersectionObserver,\n useSlotHooks,\n useViewabilityObserver,\n} from './slot.composables';\n\nconst renderFunctions: Record<RenderMode, (ad: RenderOptions, element: HTMLElement) => void> = {\n iframe: renderIframe,\n inline: renderInline,\n none: doNothing,\n};\n\nconst defaultOptions = {\n renderMode: 'iframe',\n type: 'normal',\n} satisfies Partial<AdheseSlotOptions>;\n\n/**\n * Create a new slot instance. This slot instance can be used to request and render ads.\n *\n * @param slotOptions {AdheseSlotOptions} The options to create the slot with.\n *\n * @return AdheseSlot The created slot instance.\n */\nexport function createSlot(slotOptions: AdheseSlotOptions): AdheseSlot {\n const scope = effectScope();\n\n return scope.run(() => {\n const slotContext = ref<AdheseSlotContext | null>(null);\n const options = slotOptions.context.hooks.runOnSlotCreate({\n ...defaultOptions,\n ...slotOptions,\n });\n\n const {\n containingElement,\n slot,\n context,\n pluginOptions,\n renderMode = 'iframe',\n type = 'normal',\n } = options;\n\n const id = uniqueId();\n const {\n runOnBeforeRender,\n runOnRender,\n runOnBeforeRequest,\n runOnRequest,\n runOnInit,\n runOnDispose,\n ...hooks\n } = useSlotHooks(options, slotContext);\n\n const isDisposed = ref(false);\n const parameters = reactive(new Map(Object.entries(options.parameters ?? {})));\n\n const [device, disposeQueryDetector] = useQueryDetector(context, typeof options.format === 'string'\n ? {\n [options.format]: '(min-width: 0px)',\n }\n : Object.fromEntries(options.format.map(item => [item.format, item.query])));\n\n const format = computed(() => typeof options.format === 'string' ? options.format : device.value);\n\n const data = ref<AdheseAd | null>(null) as Ref<AdheseAd | null>;\n const originalData = ref(data.value) as Ref<AdheseAd | null>;\n const name = computed(() => generateName(options.context.location, format.value, options.slot));\n\n watch(name, async (newName, oldName) => {\n if (newName === oldName)\n return;\n\n const newAd = await slotContext.value?.request();\n\n if (!newAd)\n return;\n\n slotContext.value?.cleanElement();\n\n data.value = newAd;\n originalData.value = newAd;\n });\n\n const isDomLoaded = useDomLoaded(context);\n\n const element = computed(() => {\n if (!(typeof options.containingElement === 'string' || !options.containingElement))\n return options.containingElement;\n\n if (!isDomLoaded.value || slotContext.value?.isDisposed)\n return null;\n\n return document.querySelector<HTMLElement>(`.adunit[data-format=\"${format.value}\"]#${options.containingElement}${options.slot ? `[data-slot=\"${options.slot}\"]` : ''}`);\n },\n );\n\n const isInViewport = useRenderIntersectionObserver({\n options,\n element,\n hooks,\n });\n\n const status = ref<UnwrapRef<AdheseSlot>['status']>('initializing');\n\n watch([data, isInViewport], async ([newData, newIsInViewport], [oldData]) => {\n if ((!newData || (oldData && isDeepEqual(newData, oldData))) && status.value === 'rendered')\n return;\n\n if (newIsInViewport)\n await slotContext.value?.render(newData ?? undefined);\n });\n\n hooks.onDispose(() => {\n disposeQueryDetector();\n });\n\n const isViewabilityTracked = useViewabilityObserver({\n context,\n slotContext,\n hooks,\n onTracked(trackingPixel) {\n if (slotContext.value?.data?.viewableImpressionCounter) {\n trackingPixel.value = addTrackingPixel(slotContext.value?.data?.viewableImpressionCounter);\n\n context.logger.debug(`Viewability tracking pixel fired for ${slotContext.value?.name}`);\n }\n },\n });\n\n const impressionTrackingPixelElement = ref<HTMLImageElement | null>(null);\n const isImpressionTracked = ref(false);\n hooks.onDispose(() => {\n if (impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value.remove();\n });\n\n async function request(): Promise<AdheseAd | null> {\n if (options.lazyLoading && !isInViewport.value)\n return null;\n\n status.value = 'loading';\n\n let response = await runOnBeforeRequest(null);\n\n if (!response) {\n response = await extRequestAd({\n slot: {\n name: name.value,\n parameters,\n },\n context,\n });\n }\n\n if (response)\n response = await runOnRequest(response);\n\n data.value = response;\n\n if (!originalData.value)\n originalData.value = response;\n\n status.value = response ? 'loaded' : 'empty';\n\n if (!response)\n cleanElement();\n\n return response;\n }\n\n async function render(adToRender?: AdheseAd): Promise<HTMLElement | null> {\n status.value = 'rendering';\n\n await waitForDomLoad();\n\n let renderAd = adToRender ?? data.value ?? originalData.value ?? await request();\n\n renderAd = renderAd && await runOnBeforeRender(renderAd);\n\n if (!renderAd) {\n status.value = 'empty';\n logger.debug(`No ad to render for slot ${name.value}`);\n\n return null;\n }\n\n if (!element.value) {\n const error = `Could not create slot for format ${format.value}. No element found.`;\n logger.error(error, options);\n throw new Error(error);\n }\n\n if (context.debug)\n element.value.style.position = 'relative';\n\n if (typeof renderAd?.tag !== 'string') {\n const error = `Could not render slot for slot ${name.value}. A valid tag doesn't exist or is not HTML string.`;\n logger.error(error, options);\n\n status.value = 'error';\n throw new Error(error);\n }\n\n renderFunctions[renderMode]({\n ...renderAd,\n ...pick(options, ['width', 'height']),\n } as RenderOptions, element.value);\n\n if (renderAd.impressionCounter && !impressionTrackingPixelElement.value)\n impressionTrackingPixelElement.value = addTrackingPixel(renderAd.impressionCounter);\n\n isImpressionTracked.value = true;\n\n logger.debug(`Slot rendered ${name.value}`, {\n renderedElement: element,\n location: context.location,\n format,\n containingElement,\n });\n\n status.value = 'rendered';\n\n runOnRender(renderAd);\n\n return element.value;\n }\n\n function cleanElement(): void {\n if (!element.value)\n return;\n\n element.value.innerHTML = '';\n element.value.style.position = '';\n element.value.style.width = '';\n element.value.style.height = '';\n\n data.value = null;\n originalData.value = null;\n }\n\n function dispose(): void {\n cleanElement();\n\n data.value = null;\n\n runOnDispose();\n\n isDisposed.value = true;\n\n scope.stop();\n }\n\n const state = reactive({\n location: context.location ?? '',\n lazyLoading: options.lazyLoading ?? false,\n type,\n slot,\n parameters,\n format,\n name,\n data,\n isViewabilityTracked,\n isImpressionTracked,\n status,\n element,\n isDisposed,\n id,\n pluginOptions,\n isVisible: isInViewport,\n render,\n request,\n dispose,\n cleanElement,\n options: omit(options, ['context']),\n ...hooks,\n });\n\n watch(state, (newState) => {\n slotContext.value = newState;\n }, {\n deep: true,\n immediate: true,\n });\n\n context.hooks.onInit(async () => {\n status.value = 'initialized';\n\n runOnInit();\n\n if (options.lazyLoading)\n return;\n\n data.value = await slotContext.value?.request() ?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OAAO,CAAC,aAAa;AACzB,kBAAY,QAAQ;AAAA,IAAA,GACnB;AAAA,MACD,MAAM;AAAA,MACN,WAAW;AAAA,IAAA,CACZ;AAEO,YAAA,MAAM,OAAO,YAAY;;AAC/B,aAAO,QAAQ;AAEL;AAEV,UAAI,QAAQ;AACV;AAEF,WAAK,QAAQ,QAAM,iBAAY,UAAZ,mBAAmB,cAAa;AAAA,IAAA,CACpD;AAEM,WAAA;AAAA,EAAA,CACR;AACH;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adhese/sdk",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.1.1",
5
5
  "description": "Adhese SDK",
6
6
  "license": "GPL-3.0",
7
7
  "repository": {
@@ -47,6 +47,6 @@
47
47
  "prepareRelease": "npm run build"
48
48
  },
49
49
  "dependencies": {
50
- "@adhese/sdk-shared": "^1.0.0"
50
+ "@adhese/sdk-shared": "^1.1.0"
51
51
  }
52
52
  }