@adhese/sdk 1.0.1 → 1.0.3

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,18 @@
1
1
  # @adhese/sdk
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 43a682c: Revert accidental change of Promise.allSettled to Promise.all which can cause issuess when a request fails
8
+ - 5393373: Add fallback legacy d.ts file for older ts version with very limited types
9
+
10
+ ## 1.0.2
11
+
12
+ ### Patch Changes
13
+
14
+ - ce4a2c0: Fix fetching of initialSlots and dom slots on init not being handled properly causing issues with debug mode not being recognized when set in the URL or when in preview mode
15
+
3
16
  ## 1.0.1
4
17
 
5
18
  ### Patch Changes
package/dist/cjs/main.cjs CHANGED
@@ -27,7 +27,6 @@ function createAdhese(options) {
27
27
  viewabilityTracking: true,
28
28
  ...options
29
29
  };
30
- main_utils.setupLogging(mergedOptions);
31
30
  const hooks$1 = hooks.createGlobalHooks();
32
31
  const context = sdkShared.reactive({
33
32
  location: mergedOptions.location,
@@ -101,14 +100,14 @@ function createAdhese(options) {
101
100
  }
102
101
  context.dispose = dispose;
103
102
  hooks$1.onInit(async () => {
104
- var _a2;
105
103
  await sdkShared.awaitTimeout(0);
106
104
  if ((slotManager$1.getAll().length ?? 0) > 0)
107
105
  await main_utils.fetchAllUnrenderedSlots(context.getAll()).catch(logger.logger.error);
108
106
  if (mergedOptions.findDomSlotsOnLoad)
109
107
  await (context == null ? void 0 : context.findDomSlots());
110
- if (mergedOptions.debug || window.location.search.includes("adhese_debug=true") || main_utils.isPreviewMode())
111
- (_a2 = context.events) == null ? void 0 : _a2.debugChange.dispatch(true);
108
+ logger.logger.debug("Created Adhese SDK instance", {
109
+ mergedOptions
110
+ });
112
111
  if (!scope.active)
113
112
  dispose();
114
113
  });
@@ -1 +1 @@
1
- {"version":3,"file":"main.cjs","sources":["../../src/main.ts"],"sourcesContent":["import { awaitTimeout, createEventManager, effectScope, omit, reactive, watch } from '@adhese/sdk-shared';\nimport { version } from '../package.json';\nimport { createSlotManager } from './slotManager/slotManager';\nimport { useConsent } from './consent/consent';\nimport { fetchAllUnrenderedSlots, isPreviewMode, setupLogging } from './main.utils';\nimport type {\n Adhese,\n AdheseContextStateWithPlugins,\n AdheseOptions,\n AdhesePlugin,\n MergedOptions,\n} from './main.types';\nimport { logger } from './logger/logger';\nimport { useMainDebugMode, useMainParameters, useMainQueryDetector } from './main.composables';\nimport { createGlobalHooks } from './hooks';\n\nimport type { AdheseSlot, AdheseSlotOptions } from './slot/slot.types';\n\n/**\n * Creates an Adhese instance. This instance is your main entry point to the Adhese API.\n *\n * @param options {AdheseOptions} The options to create the Adhese instance with. See the {@link AdheseOptions} type for more information.\n *\n * @return Adhese The Adhese instance.\n */\nexport function createAdhese<T extends ReadonlyArray<AdhesePlugin>>(options: AdheseOptions<T>): Adhese<T> {\n const scope = effectScope();\n\n return scope.run(() => {\n const mergedOptions: MergedOptions = {\n host: `https://ads-${options.account}.adhese.com`,\n poolHost: `https://pool-${options.account}.adhese.com`,\n location: 'homepage',\n requestType: 'POST',\n debug: false,\n initialSlots: [],\n findDomSlotsOnLoad: false,\n consent: false,\n logReferrer: true,\n logUrl: true,\n eagerRendering: false,\n viewabilityTracking: true,\n ...options,\n };\n setupLogging(mergedOptions);\n\n const hooks = createGlobalHooks();\n\n const context = reactive<AdheseContextStateWithPlugins<T>>({\n location: mergedOptions.location,\n consent: mergedOptions.consent,\n debug: mergedOptions.debug,\n options: mergedOptions,\n logger,\n isDisposed: false,\n parameters: new Map(),\n events: createEventManager(),\n slots: new Map(),\n device: 'unknown',\n hooks,\n plugins: {},\n dispose,\n findDomSlots,\n getAll,\n get,\n addSlot,\n });\n\n for (const [index, plugin] of options.plugins?.entries() ?? []) {\n const data = plugin(context, {\n index,\n version,\n hooks,\n });\n\n const name = data.name as keyof typeof context.plugins;\n context.plugins[name] = omit(data, ['name']) as typeof context.plugins[typeof name];\n }\n\n watch(() => context.location, (newLocation) => {\n context.events?.locationChange.dispatch(newLocation);\n });\n\n useMainParameters(context, mergedOptions);\n\n const slotManager = createSlotManager({\n initialSlots: mergedOptions.initialSlots,\n context,\n });\n\n function getAll(): ReadonlyArray<AdheseSlot> {\n return slotManager.getAll() ?? [];\n }\n context.getAll = getAll;\n\n function get(name: string): AdheseSlot | undefined {\n return slotManager.get(name);\n }\n context.get = get;\n\n function addSlot(slotOptions: AdheseSlotOptions): Readonly<AdheseSlot> {\n return slotManager.add(slotOptions);\n }\n context.addSlot = addSlot;\n\n async function findDomSlots(): Promise<ReadonlyArray<AdheseSlot>> {\n const domSlots = (await slotManager.findDomSlots() ?? []).filter(slot => !slot.lazyLoading);\n\n if (domSlots.length <= 0)\n return [];\n\n await fetchAllUnrenderedSlots(context.getAll());\n\n return domSlots;\n }\n context.findDomSlots = findDomSlots;\n\n useMainDebugMode(context);\n\n useMainQueryDetector(mergedOptions, context);\n\n useConsent(context);\n\n function dispose(): void {\n context.isDisposed = true;\n\n slotManager.dispose();\n context.parameters?.clear();\n context.events?.dispose();\n\n hooks.runOnDispose();\n hooks.clearAll();\n\n scope.stop();\n }\n context.dispose = dispose;\n\n hooks.onInit(async () => {\n await awaitTimeout(0);\n\n if ((slotManager.getAll().length ?? 0) > 0)\n await fetchAllUnrenderedSlots(context.getAll()).catch(logger.error);\n\n if (mergedOptions.findDomSlotsOnLoad)\n await context?.findDomSlots();\n\n if (mergedOptions.debug || window.location.search.includes('adhese_debug=true') || isPreviewMode())\n context.events?.debugChange.dispatch(true);\n\n if (!scope.active)\n dispose();\n });\n\n hooks.runOnInit();\n\n return context as Adhese<T>;\n })!;\n}\n"],"names":["effectScope","setupLogging","hooks","createGlobalHooks","reactive","logger","createEventManager","version","omit","watch","_a","useMainParameters","slotManager","createSlotManager","fetchAllUnrenderedSlots","useMainDebugMode","useMainQueryDetector","useConsent","awaitTimeout","isPreviewMode"],"mappings":";;;;;;;;;;AAyBO,SAAS,aAAo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AA,gBAAAA,IAAQ,YAAY,SAAS;AAEvC,UAAI,CAAC,MAAM;AACD;IAAA,CACX;AAEDR,YAAM,UAAU;AAET,WAAA;AAAA,EAAA,CACR;AACH;;"}
1
+ {"version":3,"file":"main.cjs","sources":["../../src/main.ts"],"sourcesContent":["import { awaitTimeout, createEventManager, effectScope, omit, reactive, watch } from '@adhese/sdk-shared';\nimport { version } from '../package.json';\nimport { createSlotManager } from './slotManager/slotManager';\nimport { useConsent } from './consent/consent';\nimport { fetchAllUnrenderedSlots } from './main.utils';\nimport type {\n Adhese,\n AdheseContextStateWithPlugins,\n AdheseOptions,\n AdhesePlugin,\n MergedOptions,\n} from './main.types';\nimport { logger } from './logger/logger';\nimport { useMainDebugMode, useMainParameters, useMainQueryDetector } from './main.composables';\nimport { createGlobalHooks } from './hooks';\n\nimport type { AdheseSlot, AdheseSlotOptions } from './slot/slot.types';\n\n/**\n * Creates an Adhese instance. This instance is your main entry point to the Adhese API.\n *\n * @param options {AdheseOptions} The options to create the Adhese instance with. See the {@link AdheseOptions} type for more information.\n *\n * @return Adhese The Adhese instance.\n */\nexport function createAdhese<T extends ReadonlyArray<AdhesePlugin>>(options: AdheseOptions<T>): Adhese<T> {\n const scope = effectScope();\n\n return scope.run(() => {\n const mergedOptions: MergedOptions = {\n host: `https://ads-${options.account}.adhese.com`,\n poolHost: `https://pool-${options.account}.adhese.com`,\n location: 'homepage',\n requestType: 'POST',\n debug: false,\n initialSlots: [],\n findDomSlotsOnLoad: false,\n consent: false,\n logReferrer: true,\n logUrl: true,\n eagerRendering: false,\n viewabilityTracking: true,\n ...options,\n };\n\n const hooks = createGlobalHooks();\n\n const context = reactive<AdheseContextStateWithPlugins<T>>({\n location: mergedOptions.location,\n consent: mergedOptions.consent,\n debug: mergedOptions.debug,\n options: mergedOptions,\n logger,\n isDisposed: false,\n parameters: new Map(),\n events: createEventManager(),\n slots: new Map(),\n device: 'unknown',\n hooks,\n plugins: {},\n dispose,\n findDomSlots,\n getAll,\n get,\n addSlot,\n });\n\n for (const [index, plugin] of options.plugins?.entries() ?? []) {\n const data = plugin(context, {\n index,\n version,\n hooks,\n });\n\n const name = data.name as keyof typeof context.plugins;\n context.plugins[name] = omit(data, ['name']) as typeof context.plugins[typeof name];\n }\n\n watch(() => context.location, (newLocation) => {\n context.events?.locationChange.dispatch(newLocation);\n });\n\n useMainParameters(context, mergedOptions);\n\n const slotManager = createSlotManager({\n initialSlots: mergedOptions.initialSlots,\n context,\n });\n\n function getAll(): ReadonlyArray<AdheseSlot> {\n return slotManager.getAll() ?? [];\n }\n context.getAll = getAll;\n\n function get(name: string): AdheseSlot | undefined {\n return slotManager.get(name);\n }\n context.get = get;\n\n function addSlot(slotOptions: AdheseSlotOptions): Readonly<AdheseSlot> {\n return slotManager.add(slotOptions);\n }\n context.addSlot = addSlot;\n\n async function findDomSlots(): Promise<ReadonlyArray<AdheseSlot>> {\n const domSlots = (await slotManager.findDomSlots() ?? []).filter(slot => !slot.lazyLoading);\n\n if (domSlots.length <= 0)\n return [];\n\n await fetchAllUnrenderedSlots(context.getAll());\n\n return domSlots;\n }\n context.findDomSlots = findDomSlots;\n\n useMainDebugMode(context);\n\n useMainQueryDetector(mergedOptions, context);\n\n useConsent(context);\n\n function dispose(): void {\n context.isDisposed = true;\n\n slotManager.dispose();\n context.parameters?.clear();\n context.events?.dispose();\n\n hooks.runOnDispose();\n hooks.clearAll();\n\n scope.stop();\n }\n context.dispose = dispose;\n\n hooks.onInit(async () => {\n await awaitTimeout(0);\n\n if ((slotManager.getAll().length ?? 0) > 0)\n await fetchAllUnrenderedSlots(context.getAll()).catch(logger.error);\n\n if (mergedOptions.findDomSlotsOnLoad)\n await context?.findDomSlots();\n\n logger.debug('Created Adhese SDK instance', {\n mergedOptions,\n });\n\n if (!scope.active)\n dispose();\n });\n\n hooks.runOnInit();\n\n return context as Adhese<T>;\n })!;\n}\n"],"names":["effectScope","hooks","createGlobalHooks","reactive","logger","createEventManager","version","omit","watch","_a","useMainParameters","slotManager","createSlotManager","fetchAllUnrenderedSlots","useMainDebugMode","useMainQueryDetector","useConsent","awaitTimeout"],"mappings":";;;;;;;;;;AAyBO,SAAS,aAAoD,SAAsC;AACxG,QAAM,QAAQA,UAAAA;AAEP,SAAA,MAAM,IAAI,MAAM;;AACrB,UAAM,gBAA+B;AAAA,MACnC,MAAM,eAAe,QAAQ,OAAO;AAAA,MACpC,UAAU,gBAAgB,QAAQ,OAAO;AAAA,MACzC,UAAU;AAAA,MACV,aAAa;AAAA,MACb,OAAO;AAAA,MACP,cAAc,CAAC;AAAA,MACf,oBAAoB;AAAA,MACpB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,GAAG;AAAA,IAAA;AAGL,UAAMC,UAAQC,MAAAA;AAEd,UAAM,UAAUC,UAAAA,SAA2C;AAAA,MACzD,UAAU,cAAc;AAAA,MACxB,SAAS,cAAc;AAAA,MACvB,OAAO,cAAc;AAAA,MACrB,SAAS;AAAA,MAAA,QACTC,OAAA;AAAA,MACA,YAAY;AAAA,MACZ,gCAAgB,IAAI;AAAA,MACpB,QAAQC,UAAAA,mBAAmB;AAAA,MAC3B,2BAAW,IAAI;AAAA,MACf,QAAQ;AAAA,MAAA,OACRJ;AAAAA,MACA,SAAS,CAAC;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAEU,eAAA,CAAC,OAAO,MAAM,OAAK,aAAQ,YAAR,mBAAiB,cAAa,IAAI;AACxD,YAAA,OAAO,OAAO,SAAS;AAAA,QAC3B;AAAA,QAAA,SACAK,SAAA;AAAA,QAAA,OACAL;AAAAA,MAAA,CACD;AAED,YAAM,OAAO,KAAK;AAClB,cAAQ,QAAQ,IAAI,IAAIM,eAAK,MAAM,CAAC,MAAM,CAAC;AAAA,IAC7C;AAEAC,cAAAA,MAAM,MAAM,QAAQ,UAAU,CAAC,gBAAgB;;AACr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,MAAM,+BAA+B;AAAA,QAC1C;AAAA,MAAA,CACD;AAED,UAAI,CAAC,MAAM;AACD;IAAA,CACX;AAEDH,YAAM,UAAU;AAET,WAAA;AAAA,EAAA,CACR;AACH;;"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const sdkShared = require("@adhese/sdk-shared");
4
4
  const queryDetector = require("./queryDetector/queryDetector.cjs");
5
+ const main_utils = require("./main.utils.cjs");
5
6
  function useMainQueryDetector(mergedOptions, context) {
6
7
  const [device] = queryDetector.useQueryDetector(context, mergedOptions.queries);
7
8
  sdkShared.watch(device, async (newDevice) => {
@@ -13,6 +14,9 @@ function useMainQueryDetector(mergedOptions, context) {
13
14
  }, { immediate: true });
14
15
  }
15
16
  function useMainDebugMode(context) {
17
+ if (window.location.search.includes("adhese_debug=true") || main_utils.isPreviewMode()) {
18
+ context.debug = true;
19
+ }
16
20
  sdkShared.watch(() => context.debug, async (newDebug) => {
17
21
  var _a, _b;
18
22
  if (newDebug) {
@@ -1 +1 @@
1
- {"version":3,"file":"main.composables.cjs","sources":["../../src/main.composables.ts"],"sourcesContent":["import { watch } from '@adhese/sdk-shared';\nimport type { AdheseContextState, MergedOptions } from './main.types';\nimport { useQueryDetector } from './queryDetector/queryDetector';\n\nexport function useMainQueryDetector(mergedOptions: MergedOptions, context: AdheseContextState): void {\n const [device] = useQueryDetector(context, mergedOptions.queries);\n watch(device, async (newDevice) => {\n context.device = newDevice;\n\n context.parameters?.set('dt', newDevice);\n context.parameters?.set('br', newDevice);\n\n await Promise.allSettled(context.getAll().map(slot => slot.request()));\n }, { immediate: true });\n}\n\nexport function useMainDebugMode(context: AdheseContextState): void {\n watch(() => context.debug, async (newDebug) => {\n if (newDebug) {\n context.logger.setMinLogLevelThreshold('debug');\n context.logger.debug('Debug mode enabled');\n context.events?.debugChange.dispatch(true);\n }\n else {\n context.logger.debug('Debug mode disabled');\n context.logger.setMinLogLevelThreshold('info');\n context.events?.debugChange.dispatch(false);\n }\n }, {\n immediate: true,\n });\n\n context.hooks.onDispose(() => {\n context.logger.resetLogs();\n context.logger.info('Adhese instance disposed');\n });\n}\n\nexport function useMainParameters(context: AdheseContextState, options: MergedOptions): void {\n const parameters = new Map<string, string | ReadonlyArray<string>>();\n\n if (options.logReferrer)\n parameters.set('re', btoa(document.referrer));\n\n if (options.logUrl)\n parameters.set('ur', btoa(window.location.href));\n\n for (const [key, value] of Object.entries({\n ...options.parameters ?? {},\n rn: Math.round(Math.random() * 10_000).toString(),\n }))\n parameters.set(key, value);\n\n context.parameters = parameters;\n\n watch(\n () => context.parameters,\n (newParameters) => {\n context.events?.parametersChange.dispatch(newParameters);\n },\n {\n deep: true,\n },\n );\n}\n"],"names":["useQueryDetector","watch"],"mappings":";;;;AAIgB,SAAA,qBAAqB,eAA8B,SAAmC;AACpG,QAAM,CAAC,MAAM,IAAIA,cAAAA,iBAAiB,SAAS,cAAc,OAAO;AAC1DC,kBAAA,QAAQ,OAAO,cAAc;;AACjC,YAAQ,SAAS;AAET,kBAAA,eAAA,mBAAY,IAAI,MAAM;AACtB,kBAAA,eAAA,mBAAY,IAAI,MAAM;AAExB,UAAA,QAAQ,WAAW,QAAQ,OAAO,EAAE,IAAI,CAAQ,SAAA,KAAK,QAAQ,CAAC,CAAC;AAAA,EAAA,GACpE,EAAE,WAAW,KAAA,CAAM;AACxB;AAEO,SAAS,iBAAiB,SAAmC;AAClEA,YAAAA,MAAM,MAAM,QAAQ,OAAO,OAAO,aAAa;;AAC7C,QAAI,UAAU;AACJ,cAAA,OAAO,wBAAwB,OAAO;AACtC,cAAA,OAAO,MAAM,oBAAoB;AACjC,oBAAA,WAAA,mBAAQ,YAAY,SAAS;AAAA,IAAI,OAEtC;AACK,cAAA,OAAO,MAAM,qBAAqB;AAClC,cAAA,OAAO,wBAAwB,MAAM;AACrC,oBAAA,WAAA,mBAAQ,YAAY,SAAS;AAAA,IACvC;AAAA,EAAA,GACC;AAAA,IACD,WAAW;AAAA,EAAA,CACZ;AAEO,UAAA,MAAM,UAAU,MAAM;AAC5B,YAAQ,OAAO;AACP,YAAA,OAAO,KAAK,0BAA0B;AAAA,EAAA,CAC/C;AACH;AAEgB,SAAA,kBAAkB,SAA6B,SAA8B;AACrF,QAAA,iCAAiB;AAEvB,MAAI,QAAQ;AACV,eAAW,IAAI,MAAM,KAAK,SAAS,QAAQ,CAAC;AAE9C,MAAI,QAAQ;AACV,eAAW,IAAI,MAAM,KAAK,OAAO,SAAS,IAAI,CAAC;AAEjD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,QAAQ,cAAc,CAAC;AAAA,IAC1B,IAAI,KAAK,MAAM,KAAK,WAAW,GAAM,EAAE,SAAS;AAAA,EAAA,CACjD;AACY,eAAA,IAAI,KAAK,KAAK;AAE3B,UAAQ,aAAa;AAErBA,YAAA;AAAA,IACE,MAAM,QAAQ;AAAA,IACd,CAAC,kBAAkB;;AACT,oBAAA,WAAA,mBAAQ,iBAAiB,SAAS;AAAA,IAC5C;AAAA,IACA;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"main.composables.cjs","sources":["../../src/main.composables.ts"],"sourcesContent":["import { watch } from '@adhese/sdk-shared';\nimport type { AdheseContextState, MergedOptions } from './main.types';\nimport { useQueryDetector } from './queryDetector/queryDetector';\nimport { isPreviewMode } from './main.utils';\n\nexport function useMainQueryDetector(mergedOptions: MergedOptions, context: AdheseContextState): void {\n const [device] = useQueryDetector(context, mergedOptions.queries);\n watch(device, async (newDevice) => {\n context.device = newDevice;\n\n context.parameters?.set('dt', newDevice);\n context.parameters?.set('br', newDevice);\n\n await Promise.allSettled(context.getAll().map(slot => slot.request()));\n }, { immediate: true });\n}\n\nexport function useMainDebugMode(context: AdheseContextState): void {\n if (window.location.search.includes('adhese_debug=true') || isPreviewMode()) {\n context.debug = true;\n }\n\n watch(() => context.debug, async (newDebug) => {\n if (newDebug) {\n context.logger.setMinLogLevelThreshold('debug');\n context.logger.debug('Debug mode enabled');\n context.events?.debugChange.dispatch(true);\n }\n else {\n context.logger.debug('Debug mode disabled');\n context.logger.setMinLogLevelThreshold('info');\n context.events?.debugChange.dispatch(false);\n }\n }, {\n immediate: true,\n });\n\n context.hooks.onDispose(() => {\n context.logger.resetLogs();\n context.logger.info('Adhese instance disposed');\n });\n}\n\nexport function useMainParameters(context: AdheseContextState, options: MergedOptions): void {\n const parameters = new Map<string, string | ReadonlyArray<string>>();\n\n if (options.logReferrer)\n parameters.set('re', btoa(document.referrer));\n\n if (options.logUrl)\n parameters.set('ur', btoa(window.location.href));\n\n for (const [key, value] of Object.entries({\n ...options.parameters ?? {},\n rn: Math.round(Math.random() * 10_000).toString(),\n }))\n parameters.set(key, value);\n\n context.parameters = parameters;\n\n watch(\n () => context.parameters,\n (newParameters) => {\n context.events?.parametersChange.dispatch(newParameters);\n },\n {\n deep: true,\n },\n );\n}\n"],"names":["useQueryDetector","watch","isPreviewMode"],"mappings":";;;;;AAKgB,SAAA,qBAAqB,eAA8B,SAAmC;AACpG,QAAM,CAAC,MAAM,IAAIA,cAAAA,iBAAiB,SAAS,cAAc,OAAO;AAC1DC,kBAAA,QAAQ,OAAO,cAAc;;AACjC,YAAQ,SAAS;AAET,kBAAA,eAAA,mBAAY,IAAI,MAAM;AACtB,kBAAA,eAAA,mBAAY,IAAI,MAAM;AAExB,UAAA,QAAQ,WAAW,QAAQ,OAAO,EAAE,IAAI,CAAQ,SAAA,KAAK,QAAQ,CAAC,CAAC;AAAA,EAAA,GACpE,EAAE,WAAW,KAAA,CAAM;AACxB;AAEO,SAAS,iBAAiB,SAAmC;AAClE,MAAI,OAAO,SAAS,OAAO,SAAS,mBAAmB,KAAKC,WAAAA,iBAAiB;AAC3E,YAAQ,QAAQ;AAAA,EAClB;AAEAD,YAAAA,MAAM,MAAM,QAAQ,OAAO,OAAO,aAAa;;AAC7C,QAAI,UAAU;AACJ,cAAA,OAAO,wBAAwB,OAAO;AACtC,cAAA,OAAO,MAAM,oBAAoB;AACjC,oBAAA,WAAA,mBAAQ,YAAY,SAAS;AAAA,IAAI,OAEtC;AACK,cAAA,OAAO,MAAM,qBAAqB;AAClC,cAAA,OAAO,wBAAwB,MAAM;AACrC,oBAAA,WAAA,mBAAQ,YAAY,SAAS;AAAA,IACvC;AAAA,EAAA,GACC;AAAA,IACD,WAAW;AAAA,EAAA,CACZ;AAEO,UAAA,MAAM,UAAU,MAAM;AAC5B,YAAQ,OAAO;AACP,YAAA,OAAO,KAAK,0BAA0B;AAAA,EAAA,CAC/C;AACH;AAEgB,SAAA,kBAAkB,SAA6B,SAA8B;AACrF,QAAA,iCAAiB;AAEvB,MAAI,QAAQ;AACV,eAAW,IAAI,MAAM,KAAK,SAAS,QAAQ,CAAC;AAE9C,MAAI,QAAQ;AACV,eAAW,IAAI,MAAM,KAAK,OAAO,SAAS,IAAI,CAAC;AAEjD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,QAAQ,cAAc,CAAC;AAAA,IAC1B,IAAI,KAAK,MAAM,KAAK,WAAW,GAAM,EAAE,SAAS;AAAA,EAAA,CACjD;AACY,eAAA,IAAI,KAAK,KAAK;AAE3B,UAAQ,aAAa;AAErBA,YAAA;AAAA,IACE,MAAM,QAAQ;AAAA,IACd,CAAC,kBAAkB;;AACT,oBAAA,WAAA,mBAAQ,iBAAiB,SAAS;AAAA,IAC5C;AAAA,IACA;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EAAA;AAEJ;;;;"}
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const logger = require("./logger/logger.cjs");
4
- function setupLogging(mergedOptions) {
5
- if (mergedOptions.debug || window.location.search.includes("adhese_debug=true")) {
6
- logger.logger.setMinLogLevelThreshold("debug");
7
- logger.logger.debug("Debug logging enabled");
8
- }
9
- logger.logger.debug("Created Adhese SDK instance", {
10
- mergedOptions
11
- });
12
- }
13
4
  function isPreviewMode() {
14
5
  return window.location.search.includes("adhesePreviewCreativeId");
15
6
  }
@@ -17,9 +8,13 @@ async function fetchAllUnrenderedSlots(slots) {
17
8
  const filteredSlots = slots.filter((slot) => !slot.lazyLoading && !slot.data);
18
9
  if (filteredSlots.length === 0)
19
10
  return;
20
- await Promise.allSettled(filteredSlots.map((slot) => slot.request()));
11
+ const results = await Promise.allSettled(filteredSlots.map((slot) => slot.request));
12
+ for (const [index, result] of results.entries()) {
13
+ if (result.status === "rejected") {
14
+ logger.logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);
15
+ }
16
+ }
21
17
  }
22
18
  exports.fetchAllUnrenderedSlots = fetchAllUnrenderedSlots;
23
19
  exports.isPreviewMode = isPreviewMode;
24
- exports.setupLogging = setupLogging;
25
20
  //# sourceMappingURL=main.utils.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.utils.cjs","sources":["../../src/main.utils.ts"],"sourcesContent":["import { logger } from './logger/logger';\n\nimport type { AdheseContext } from './main.types';\nimport type { AdheseSlot } from './slot/slot.types';\n\n/**\n * Sets up logging based on the provided options. If debug is enabled, the log level threshold is set to debug.\n */\nexport function setupLogging(mergedOptions: AdheseContext['options']): void {\n if (mergedOptions.debug || window.location.search.includes('adhese_debug=true')) {\n logger.setMinLogLevelThreshold('debug');\n logger.debug('Debug logging enabled');\n }\n\n logger.debug('Created Adhese SDK instance', {\n mergedOptions,\n });\n}\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n await Promise.allSettled(filteredSlots.map(slot => slot.request()));\n}\n"],"names":["logger"],"mappings":";;;AAQO,SAAS,aAAa,eAA+C;AAC1E,MAAI,cAAc,SAAS,OAAO,SAAS,OAAO,SAAS,mBAAmB,GAAG;AAC/EA,kBAAO,wBAAwB,OAAO;AACtCA,kBAAO,MAAM,uBAAuB;AAAA,EACtC;AAEAA,SAAA,OAAO,MAAM,+BAA+B;AAAA,IAC1C;AAAA,EAAA,CACD;AACH;AAKO,SAAS,gBAAyB;AACvC,SAAO,OAAO,SAAS,OAAO,SAAS,yBAAyB;AAClE;AAEA,eAAsB,wBAAwB,OAAiD;AACvF,QAAA,gBAAgB,MAAM,OAAO,CAAA,SAAQ,CAAC,KAAK,eAAe,CAAC,KAAK,IAAI;AAE1E,MAAI,cAAc,WAAW;AAC3B;AAEI,QAAA,QAAQ,WAAW,cAAc,IAAI,UAAQ,KAAK,QAAS,CAAA,CAAC;AACpE;;;;"}
1
+ {"version":3,"file":"main.utils.cjs","sources":["../../src/main.utils.ts"],"sourcesContent":["import type { AdheseSlot } from './slot/slot.types';\nimport { logger } from './logger/logger';\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n const results = await Promise.allSettled(filteredSlots.map(slot => slot.request));\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'rejected') {\n logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);\n }\n }\n}\n"],"names":["logger"],"mappings":";;;AAMO,SAAS,gBAAyB;AACvC,SAAO,OAAO,SAAS,OAAO,SAAS,yBAAyB;AAClE;AAEA,eAAsB,wBAAwB,OAAiD;AACvF,QAAA,gBAAgB,MAAM,OAAO,CAAA,SAAQ,CAAC,KAAK,eAAe,CAAC,KAAK,IAAI;AAE1E,MAAI,cAAc,WAAW;AAC3B;AAEI,QAAA,UAAU,MAAM,QAAQ,WAAW,cAAc,IAAI,CAAA,SAAQ,KAAK,OAAO,CAAC;AAEhF,aAAW,CAAC,OAAO,MAAM,KAAK,QAAQ,WAAW;AAC3C,QAAA,OAAO,WAAW,YAAY;AACzBA,aAAAA,OAAA,MAAM,sCAAsC,cAAc,KAAK,EAAE,IAAI,IAAI,OAAO,MAAM;AAAA,IAC/F;AAAA,EACF;AACF;;;"}
@@ -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.1";
4
+ const version = "1.0.3";
5
5
  exports.name = name;
6
6
  exports.version = version;
7
7
  //# sourceMappingURL=package.json.cjs.map
@@ -0,0 +1 @@
1
+ declare function createAdhese(options: any): any;
@@ -1,5 +1,6 @@
1
1
  import { watch } from "@adhese/sdk-shared";
2
2
  import { useQueryDetector } from "./queryDetector/queryDetector.js";
3
+ import { isPreviewMode } from "./main.utils.js";
3
4
  function useMainQueryDetector(mergedOptions, context) {
4
5
  const [device] = useQueryDetector(context, mergedOptions.queries);
5
6
  watch(device, async (newDevice) => {
@@ -11,6 +12,9 @@ function useMainQueryDetector(mergedOptions, context) {
11
12
  }, { immediate: true });
12
13
  }
13
14
  function useMainDebugMode(context) {
15
+ if (window.location.search.includes("adhese_debug=true") || isPreviewMode()) {
16
+ context.debug = true;
17
+ }
14
18
  watch(() => context.debug, async (newDebug) => {
15
19
  var _a, _b;
16
20
  if (newDebug) {
@@ -1 +1 @@
1
- {"version":3,"file":"main.composables.js","sources":["../src/main.composables.ts"],"sourcesContent":["import { watch } from '@adhese/sdk-shared';\nimport type { AdheseContextState, MergedOptions } from './main.types';\nimport { useQueryDetector } from './queryDetector/queryDetector';\n\nexport function useMainQueryDetector(mergedOptions: MergedOptions, context: AdheseContextState): void {\n const [device] = useQueryDetector(context, mergedOptions.queries);\n watch(device, async (newDevice) => {\n context.device = newDevice;\n\n context.parameters?.set('dt', newDevice);\n context.parameters?.set('br', newDevice);\n\n await Promise.allSettled(context.getAll().map(slot => slot.request()));\n }, { immediate: true });\n}\n\nexport function useMainDebugMode(context: AdheseContextState): void {\n watch(() => context.debug, async (newDebug) => {\n if (newDebug) {\n context.logger.setMinLogLevelThreshold('debug');\n context.logger.debug('Debug mode enabled');\n context.events?.debugChange.dispatch(true);\n }\n else {\n context.logger.debug('Debug mode disabled');\n context.logger.setMinLogLevelThreshold('info');\n context.events?.debugChange.dispatch(false);\n }\n }, {\n immediate: true,\n });\n\n context.hooks.onDispose(() => {\n context.logger.resetLogs();\n context.logger.info('Adhese instance disposed');\n });\n}\n\nexport function useMainParameters(context: AdheseContextState, options: MergedOptions): void {\n const parameters = new Map<string, string | ReadonlyArray<string>>();\n\n if (options.logReferrer)\n parameters.set('re', btoa(document.referrer));\n\n if (options.logUrl)\n parameters.set('ur', btoa(window.location.href));\n\n for (const [key, value] of Object.entries({\n ...options.parameters ?? {},\n rn: Math.round(Math.random() * 10_000).toString(),\n }))\n parameters.set(key, value);\n\n context.parameters = parameters;\n\n watch(\n () => context.parameters,\n (newParameters) => {\n context.events?.parametersChange.dispatch(newParameters);\n },\n {\n deep: true,\n },\n );\n}\n"],"names":[],"mappings":";;AAIgB,SAAA,qBAAqB,eAA8B,SAAmC;AACpG,QAAM,CAAC,MAAM,IAAI,iBAAiB,SAAS,cAAc,OAAO;AAC1D,QAAA,QAAQ,OAAO,cAAc;;AACjC,YAAQ,SAAS;AAET,kBAAA,eAAA,mBAAY,IAAI,MAAM;AACtB,kBAAA,eAAA,mBAAY,IAAI,MAAM;AAExB,UAAA,QAAQ,WAAW,QAAQ,OAAO,EAAE,IAAI,CAAQ,SAAA,KAAK,QAAQ,CAAC,CAAC;AAAA,EAAA,GACpE,EAAE,WAAW,KAAA,CAAM;AACxB;AAEO,SAAS,iBAAiB,SAAmC;AAClE,QAAM,MAAM,QAAQ,OAAO,OAAO,aAAa;;AAC7C,QAAI,UAAU;AACJ,cAAA,OAAO,wBAAwB,OAAO;AACtC,cAAA,OAAO,MAAM,oBAAoB;AACjC,oBAAA,WAAA,mBAAQ,YAAY,SAAS;AAAA,IAAI,OAEtC;AACK,cAAA,OAAO,MAAM,qBAAqB;AAClC,cAAA,OAAO,wBAAwB,MAAM;AACrC,oBAAA,WAAA,mBAAQ,YAAY,SAAS;AAAA,IACvC;AAAA,EAAA,GACC;AAAA,IACD,WAAW;AAAA,EAAA,CACZ;AAEO,UAAA,MAAM,UAAU,MAAM;AAC5B,YAAQ,OAAO;AACP,YAAA,OAAO,KAAK,0BAA0B;AAAA,EAAA,CAC/C;AACH;AAEgB,SAAA,kBAAkB,SAA6B,SAA8B;AACrF,QAAA,iCAAiB;AAEvB,MAAI,QAAQ;AACV,eAAW,IAAI,MAAM,KAAK,SAAS,QAAQ,CAAC;AAE9C,MAAI,QAAQ;AACV,eAAW,IAAI,MAAM,KAAK,OAAO,SAAS,IAAI,CAAC;AAEjD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ;AAAA,IACxC,GAAG,QAAQ,cAAc,CAAC;AAAA,IAC1B,IAAI,KAAK,MAAM,KAAK,WAAW,GAAM,EAAE,SAAS;AAAA,EAAA,CACjD;AACY,eAAA,IAAI,KAAK,KAAK;AAE3B,UAAQ,aAAa;AAErB;AAAA,IACE,MAAM,QAAQ;AAAA,IACd,CAAC,kBAAkB;;AACT,oBAAA,WAAA,mBAAQ,iBAAiB,SAAS;AAAA,IAC5C;AAAA,IACA;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"main.composables.js","sources":["../src/main.composables.ts"],"sourcesContent":["import { watch } from '@adhese/sdk-shared';\nimport type { AdheseContextState, MergedOptions } from './main.types';\nimport { useQueryDetector } from './queryDetector/queryDetector';\nimport { isPreviewMode } from './main.utils';\n\nexport function useMainQueryDetector(mergedOptions: MergedOptions, context: AdheseContextState): void {\n const [device] = useQueryDetector(context, mergedOptions.queries);\n watch(device, async (newDevice) => {\n context.device = newDevice;\n\n context.parameters?.set('dt', newDevice);\n context.parameters?.set('br', newDevice);\n\n await Promise.allSettled(context.getAll().map(slot => slot.request()));\n }, { immediate: true });\n}\n\nexport function useMainDebugMode(context: AdheseContextState): void {\n if (window.location.search.includes('adhese_debug=true') || isPreviewMode()) {\n context.debug = true;\n }\n\n watch(() => context.debug, async (newDebug) => {\n if (newDebug) {\n context.logger.setMinLogLevelThreshold('debug');\n context.logger.debug('Debug mode enabled');\n context.events?.debugChange.dispatch(true);\n }\n else {\n context.logger.debug('Debug mode disabled');\n context.logger.setMinLogLevelThreshold('info');\n context.events?.debugChange.dispatch(false);\n }\n }, {\n immediate: true,\n });\n\n context.hooks.onDispose(() => {\n context.logger.resetLogs();\n context.logger.info('Adhese instance disposed');\n });\n}\n\nexport function useMainParameters(context: AdheseContextState, options: MergedOptions): void {\n const parameters = new Map<string, string | ReadonlyArray<string>>();\n\n if (options.logReferrer)\n parameters.set('re', btoa(document.referrer));\n\n if (options.logUrl)\n parameters.set('ur', btoa(window.location.href));\n\n for (const [key, value] of Object.entries({\n ...options.parameters ?? {},\n rn: Math.round(Math.random() * 10_000).toString(),\n }))\n parameters.set(key, value);\n\n context.parameters = parameters;\n\n watch(\n () => context.parameters,\n (newParameters) => {\n context.events?.parametersChange.dispatch(newParameters);\n },\n {\n deep: true,\n },\n );\n}\n"],"names":[],"mappings":";;;AAKgB,SAAA,qBAAqB,eAA8B,SAAmC;AACpG,QAAM,CAAC,MAAM,IAAI,iBAAiB,SAAS,cAAc,OAAO;AAC1D,QAAA,QAAQ,OAAO,cAAc;;AACjC,YAAQ,SAAS;AAET,kBAAA,eAAA,mBAAY,IAAI,MAAM;AACtB,kBAAA,eAAA,mBAAY,IAAI,MAAM;AAExB,UAAA,QAAQ,WAAW,QAAQ,OAAO,EAAE,IAAI,CAAQ,SAAA,KAAK,QAAQ,CAAC,CAAC;AAAA,EAAA,GACpE,EAAE,WAAW,KAAA,CAAM;AACxB;AAEO,SAAS,i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2
  import { version } from "./package.json.js";
3
3
  import { createSlotManager } from "./slotManager/slotManager.js";
4
4
  import { useConsent } from "./consent/consent.js";
5
- import { setupLogging, fetchAllUnrenderedSlots, isPreviewMode } from "./main.utils.js";
5
+ import { fetchAllUnrenderedSlots } from "./main.utils.js";
6
6
  import { logger } from "./logger/logger.js";
7
7
  import { useMainParameters, useMainDebugMode, useMainQueryDetector } from "./main.composables.js";
8
8
  import { createGlobalHooks } from "./hooks.js";
@@ -25,7 +25,6 @@ function createAdhese(options) {
25
25
  viewabilityTracking: true,
26
26
  ...options
27
27
  };
28
- setupLogging(mergedOptions);
29
28
  const hooks = createGlobalHooks();
30
29
  const context = reactive({
31
30
  location: mergedOptions.location,
@@ -99,14 +98,14 @@ function createAdhese(options) {
99
98
  }
100
99
  context.dispose = dispose;
101
100
  hooks.onInit(async () => {
102
- var _a2;
103
101
  await awaitTimeout(0);
104
102
  if ((slotManager.getAll().length ?? 0) > 0)
105
103
  await fetchAllUnrenderedSlots(context.getAll()).catch(logger.error);
106
104
  if (mergedOptions.findDomSlotsOnLoad)
107
105
  await (context == null ? void 0 : context.findDomSlots());
108
- if (mergedOptions.debug || window.location.search.includes("adhese_debug=true") || isPreviewMode())
109
- (_a2 = context.events) == null ? void 0 : _a2.debugChange.dispatch(true);
106
+ logger.debug("Created Adhese SDK instance", {
107
+ mergedOptions
108
+ });
110
109
  if (!scope.active)
111
110
  dispose();
112
111
  });
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":["../src/main.ts"],"sourcesContent":["import { awaitTimeout, createEventManager, effectScope, omit, reactive, watch } from '@adhese/sdk-shared';\nimport { version } from '../package.json';\nimport { createSlotManager } from './slotManager/slotManager';\nimport { useConsent } from './consent/consent';\nimport { fetchAllUnrenderedSlots, isPreviewMode, setupLogging } from './main.utils';\nimport type {\n Adhese,\n AdheseContextStateWithPlugins,\n AdheseOptions,\n AdhesePlugin,\n MergedOptions,\n} from './main.types';\nimport { logger } from './logger/logger';\nimport { useMainDebugMode, useMainParameters, useMainQueryDetector } from './main.composables';\nimport { createGlobalHooks } from './hooks';\n\nimport type { AdheseSlot, AdheseSlotOptions } from './slot/slot.types';\n\n/**\n * Creates an Adhese instance. This instance is your main entry point to the Adhese API.\n *\n * @param options {AdheseOptions} The options to create the Adhese instance with. See the {@link AdheseOptions} type for more information.\n *\n * @return Adhese The Adhese instance.\n */\nexport function createAdhese<T extends ReadonlyArray<AdhesePlugin>>(options: AdheseOptions<T>): Adhese<T> {\n const scope = effectScope();\n\n return scope.run(() => {\n const mergedOptions: MergedOptions = {\n host: `https://ads-${options.account}.adhese.com`,\n poolHost: `https://pool-${options.account}.adhese.com`,\n location: 'homepage',\n requestType: 'POST',\n debug: false,\n initialSlots: [],\n findDomSlotsOnLoad: false,\n consent: false,\n logReferrer: true,\n logUrl: true,\n eagerRendering: false,\n viewabilityTracking: true,\n ...options,\n };\n setupLogging(mergedOptions);\n\n const hooks = createGlobalHooks();\n\n const context = reactive<AdheseContextStateWithPlugins<T>>({\n location: mergedOptions.location,\n consent: mergedOptions.consent,\n debug: mergedOptions.debug,\n options: mergedOptions,\n logger,\n isDisposed: false,\n parameters: new Map(),\n events: createEventManager(),\n slots: new Map(),\n device: 'unknown',\n hooks,\n plugins: {},\n dispose,\n findDomSlots,\n getAll,\n get,\n addSlot,\n });\n\n for (const [index, plugin] of options.plugins?.entries() ?? []) {\n const data = plugin(context, {\n index,\n version,\n hooks,\n });\n\n const name = data.name as keyof typeof context.plugins;\n context.plugins[name] = omit(data, ['name']) as typeof context.plugins[typeof name];\n }\n\n watch(() => context.location, (newLocation) => {\n context.events?.locationChange.dispatch(newLocation);\n });\n\n useMainParameters(context, mergedOptions);\n\n const slotManager = createSlotManager({\n initialSlots: mergedOptions.initialSlots,\n context,\n });\n\n function getAll(): ReadonlyArray<AdheseSlot> {\n return slotManager.getAll() ?? [];\n }\n context.getAll = getAll;\n\n function get(name: string): AdheseSlot | undefined {\n return slotManager.get(name);\n }\n context.get = get;\n\n function addSlot(slotOptions: AdheseSlotOptions): Readonly<AdheseSlot> {\n return slotManager.add(slotOptions);\n }\n context.addSlot = addSlot;\n\n async function findDomSlots(): Promise<ReadonlyArray<AdheseSlot>> {\n const domSlots = (await slotManager.findDomSlots() ?? []).filter(slot => !slot.lazyLoading);\n\n if (domSlots.length <= 0)\n return [];\n\n await fetchAllUnrenderedSlots(context.getAll());\n\n return domSlots;\n }\n context.findDomSlots = findDomSlots;\n\n useMainDebugMode(context);\n\n useMainQueryDetector(mergedOptions, context);\n\n useConsent(context);\n\n function dispose(): void {\n context.isDisposed = true;\n\n slotManager.dispose();\n context.parameters?.clear();\n context.events?.dispose();\n\n hooks.runOnDispose();\n hooks.clearAll();\n\n scope.stop();\n }\n context.dispose = dispose;\n\n hooks.onInit(async () => {\n await awaitTimeout(0);\n\n if ((slotManager.getAll().length ?? 0) > 0)\n await fetchAllUnrenderedSlots(context.getAll()).catch(logger.error);\n\n if (mergedOptions.findDomSlotsOnLoad)\n await context?.findDomSlots();\n\n if (mergedOptions.debug || window.location.search.includes('adhese_debug=true') || isPreviewMode())\n context.events?.debugChange.dispatch(true);\n\n if (!scope.active)\n dispose();\n });\n\n hooks.runOnInit();\n\n return context as Adhese<T>;\n })!;\n}\n"],"names":["_a"],"mappings":";;;;;;;;AAyBO,SAAS,aAAoD,SAAsC;AACxG,QAAM,QAAQ;AAEP,SAAA,MAAM,IAAI,MAAM;;AACrB,UAAM,gBAA+B;AAAA,MACnC,MAAM,eAAe,QAAQ,OAAO;AAAA,MACpC,UAAU,gBAAgB,QAAQ,OAAO;AAAA,MACzC,UAAU;AAAA,MACV,aAAa;AAAA,MACb,OAAO;AAAA,MACP,cAAc,CAAC;AAAA,MACf,oBAAoB;AAAA,MACpB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,GAAG;AAAA,IAAA;AAEL,iBAAa,aAAa;AAE1B,U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eAAO;AAEH,YAAA,wBAAwB,QAAQ,OAAA,CAAQ;AAEvC,aAAA;AAAA,IACT;AACA,YAAQ,eAAe;AAEvB,qBAAiB,OAAO;AAExB,yBAAqB,eAAe,OAAO;AAE3C,eAAW,OAAO;AAElB,aAAS,UAAgB;;AACvB,cAAQ,aAAa;AAErB,kBAAY,QAAQ;AACpB,OAAAA,MAAA,QAAQ,eAAR,gBAAAA,IAAoB;AACpB,oBAAQ,WAAR,mBAAgB;AAEhB,YAAM,aAAa;AACnB,YAAM,SAAS;AAEf,YAAM,KAAK;AAAA,IACb;AACA,YAAQ,UAAU;AAElB,UAAM,OAAO,YAAY;;AACvB,YAAM,aAAa,CAAC;AAEpB,WAAK,YAAY,OAAS,EAAA,UAAU,KAAK;AACvC,cAAM,wBAAwB,QAAQ,OAAA,CAAQ,EAAE,MAAM,OAAO,KAAK;AAEpE,UAAI,cAAc;AAChB,eAAM,mCAAS;AAEb,UAAA,cAAc,SAAS,OAAO,SAAS,OAAO,SAAS,mBAAmB,KAAK,cAAc;AACvF,SAAAA,MAAA,QAAA,WAAA,gBAAAA,IAAQ,YAAY,SAAS;AAEvC,UAAI,CAAC,MAAM;AACD;IAAA,CACX;AAED,UAAM,UAAU;AAET,WAAA;AAAA,EAAA,CACR;AACH;"}
1
+ {"version":3,"file":"main.js","sources":["../src/main.ts"],"sourcesContent":["import { awaitTimeout, createEventManager, effectScope, omit, reactive, watch } from '@adhese/sdk-shared';\nimport { version } from '../package.json';\nimport { createSlotManager } from './slotManager/slotManager';\nimport { useConsent } from './consent/consent';\nimport { fetchAllUnrenderedSlots } from './main.utils';\nimport type {\n Adhese,\n AdheseContextStateWithPlugins,\n AdheseOptions,\n AdhesePlugin,\n MergedOptions,\n} from './main.types';\nimport { logger } from './logger/logger';\nimport { useMainDebugMode, useMainParameters, useMainQueryDetector } from './main.composables';\nimport { createGlobalHooks } from './hooks';\n\nimport type { AdheseSlot, AdheseSlotOptions } from './slot/slot.types';\n\n/**\n * Creates an Adhese instance. This instance is your main entry point to the Adhese API.\n *\n * @param options {AdheseOptions} The options to create the Adhese instance with. See the {@link AdheseOptions} type for more information.\n *\n * @return Adhese The Adhese instance.\n */\nexport function createAdhese<T extends ReadonlyArray<AdhesePlugin>>(options: AdheseOptions<T>): Adhese<T> {\n const scope = effectScope();\n\n return scope.run(() => {\n const mergedOptions: MergedOptions = {\n host: `https://ads-${options.account}.adhese.com`,\n poolHost: `https://pool-${options.account}.adhese.com`,\n location: 'homepage',\n requestType: 'POST',\n debug: false,\n initialSlots: [],\n findDomSlotsOnLoad: false,\n consent: false,\n logReferrer: true,\n logUrl: true,\n eagerRendering: false,\n viewabilityTracking: true,\n ...options,\n };\n\n const hooks = createGlobalHooks();\n\n const context = reactive<AdheseContextStateWithPlugins<T>>({\n location: mergedOptions.location,\n consent: mergedOptions.consent,\n debug: mergedOptions.debug,\n options: mergedOptions,\n logger,\n isDisposed: false,\n parameters: new Map(),\n events: createEventManager(),\n slots: new Map(),\n device: 'unknown',\n hooks,\n plugins: {},\n dispose,\n findDomSlots,\n getAll,\n get,\n addSlot,\n });\n\n for (const [index, plugin] of options.plugins?.entries() ?? []) {\n const data = plugin(context, {\n index,\n version,\n hooks,\n });\n\n const name = data.name as keyof typeof context.plugins;\n context.plugins[name] = omit(data, ['name']) as typeof context.plugins[typeof name];\n }\n\n watch(() => context.location, (newLocation) => {\n context.events?.locationChange.dispatch(newLocation);\n });\n\n useMainParameters(context, mergedOptions);\n\n const slotManager = createSlotManager({\n initialSlots: mergedOptions.initialSlots,\n context,\n });\n\n function getAll(): ReadonlyArray<AdheseSlot> {\n return slotManager.getAll() ?? [];\n }\n context.getAll = getAll;\n\n function get(name: string): AdheseSlot | undefined {\n return slotManager.get(name);\n }\n context.get = get;\n\n function addSlot(slotOptions: AdheseSlotOptions): Readonly<AdheseSlot> {\n return slotManager.add(slotOptions);\n }\n context.addSlot = addSlot;\n\n async function findDomSlots(): Promise<ReadonlyArray<AdheseSlot>> {\n const domSlots = (await slotManager.findDomSlots() ?? []).filter(slot => !slot.lazyLoading);\n\n if (domSlots.length <= 0)\n return [];\n\n await fetchAllUnrenderedSlots(context.getAll());\n\n return domSlots;\n }\n context.findDomSlots = findDomSlots;\n\n useMainDebugMode(context);\n\n useMainQueryDetector(mergedOptions, context);\n\n useConsent(context);\n\n function dispose(): void {\n context.isDisposed = true;\n\n slotManager.dispose();\n context.parameters?.clear();\n context.events?.dispose();\n\n hooks.runOnDispose();\n hooks.clearAll();\n\n scope.stop();\n }\n context.dispose = dispose;\n\n hooks.onInit(async () => {\n await awaitTimeout(0);\n\n if ((slotManager.getAll().length ?? 0) > 0)\n await fetchAllUnrenderedSlots(context.getAll()).catch(logger.error);\n\n if (mergedOptions.findDomSlotsOnLoad)\n await context?.findDomSlots();\n\n logger.debug('Created Adhese SDK instance', {\n mergedOptions,\n });\n\n if (!scope.active)\n dispose();\n });\n\n hooks.runOnInit();\n\n return context as Adhese<T>;\n })!;\n}\n"],"names":["_a"],"mappings":";;;;;;;;AAyBO,SAAS,aAAoD,SAAsC;AACxG,QAAM,QAAQ;AAEP,SAAA,MAAM,IAAI,MAAM;;AACrB,UAAM,gBAA+B;AAAA,MACnC,MAAM,eAAe,QAAQ,OAAO;AAAA,MACpC,UAAU,gBAAgB,QAAQ,OAAO;AAAA,MACzC,UAAU;AAAA,MACV,aAAa;AAAA,MACb,OAAO;AAAA,MACP,cAAc,CAAC;AAAA,MACf,oBAAoB;AAAA,MACpB,SAAS;AAAA,MACT,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,GAAG;AAAA,IAAA;AAGL,UAAM,QAAQ;AAEd,UAAM,UAAU,SAA2C;AAAA,MACzD,UAAU,cAAc;AAAA,MACxB,SAAS,cAAc;AAAA,MACvB,OAAO,cAAc;AAAA,MACrB,SAAS;AAAA,MACT;AAAA,MACA,YAAY;AAAA,MACZ,gCAAgB,IAAI;AAAA,MACpB,QAAQ,mBAAmB;A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AAQ;AACpB,OAAAA,MAAA,QAAQ,eAAR,gBAAAA,IAAoB;AACpB,oBAAQ,WAAR,mBAAgB;AAEhB,YAAM,aAAa;AACnB,YAAM,SAAS;AAEf,YAAM,KAAK;AAAA,IACb;AACA,YAAQ,UAAU;AAElB,UAAM,OAAO,YAAY;AACvB,YAAM,aAAa,CAAC;AAEpB,WAAK,YAAY,OAAS,EAAA,UAAU,KAAK;AACvC,cAAM,wBAAwB,QAAQ,OAAA,CAAQ,EAAE,MAAM,OAAO,KAAK;AAEpE,UAAI,cAAc;AAChB,eAAM,mCAAS;AAEjB,aAAO,MAAM,+BAA+B;AAAA,QAC1C;AAAA,MAAA,CACD;AAED,UAAI,CAAC,MAAM;AACD;IAAA,CACX;AAED,UAAM,UAAU;AAET,WAAA;AAAA,EAAA,CACR;AACH;"}
@@ -1,13 +1,4 @@
1
1
  import { logger } from "./logger/logger.js";
2
- function setupLogging(mergedOptions) {
3
- if (mergedOptions.debug || window.location.search.includes("adhese_debug=true")) {
4
- logger.setMinLogLevelThreshold("debug");
5
- logger.debug("Debug logging enabled");
6
- }
7
- logger.debug("Created Adhese SDK instance", {
8
- mergedOptions
9
- });
10
- }
11
2
  function isPreviewMode() {
12
3
  return window.location.search.includes("adhesePreviewCreativeId");
13
4
  }
@@ -15,11 +6,15 @@ async function fetchAllUnrenderedSlots(slots) {
15
6
  const filteredSlots = slots.filter((slot) => !slot.lazyLoading && !slot.data);
16
7
  if (filteredSlots.length === 0)
17
8
  return;
18
- await Promise.allSettled(filteredSlots.map((slot) => slot.request()));
9
+ const results = await Promise.allSettled(filteredSlots.map((slot) => slot.request));
10
+ for (const [index, result] of results.entries()) {
11
+ if (result.status === "rejected") {
12
+ logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);
13
+ }
14
+ }
19
15
  }
20
16
  export {
21
17
  fetchAllUnrenderedSlots,
22
- isPreviewMode,
23
- setupLogging
18
+ isPreviewMode
24
19
  };
25
20
  //# sourceMappingURL=main.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.utils.js","sources":["../src/main.utils.ts"],"sourcesContent":["import { logger } from './logger/logger';\n\nimport type { AdheseContext } from './main.types';\nimport type { AdheseSlot } from './slot/slot.types';\n\n/**\n * Sets up logging based on the provided options. If debug is enabled, the log level threshold is set to debug.\n */\nexport function setupLogging(mergedOptions: AdheseContext['options']): void {\n if (mergedOptions.debug || window.location.search.includes('adhese_debug=true')) {\n logger.setMinLogLevelThreshold('debug');\n logger.debug('Debug logging enabled');\n }\n\n logger.debug('Created Adhese SDK instance', {\n mergedOptions,\n });\n}\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n await Promise.allSettled(filteredSlots.map(slot => slot.request()));\n}\n"],"names":[],"mappings":";AAQO,SAAS,aAAa,eAA+C;AAC1E,MAAI,cAAc,SAAS,OAAO,SAAS,OAAO,SAAS,mBAAmB,GAAG;AAC/E,WAAO,wBAAwB,OAAO;AACtC,WAAO,MAAM,uBAAuB;AAAA,EACtC;AAEA,SAAO,MAAM,+BAA+B;AAAA,IAC1C;AAAA,EAAA,CACD;AACH;AAKO,SAAS,gBAAyB;AACvC,SAAO,OAAO,SAAS,OAAO,SAAS,yBAAyB;AAClE;AAEA,eAAsB,wBAAwB,OAAiD;AACvF,QAAA,gBAAgB,MAAM,OAAO,CAAA,SAAQ,CAAC,KAAK,eAAe,CAAC,KAAK,IAAI;AAE1E,MAAI,cAAc,WAAW;AAC3B;AAEI,QAAA,QAAQ,WAAW,cAAc,IAAI,UAAQ,KAAK,QAAS,CAAA,CAAC;AACpE;"}
1
+ {"version":3,"file":"main.utils.js","sources":["../src/main.utils.ts"],"sourcesContent":["import type { AdheseSlot } from './slot/slot.types';\nimport { logger } from './logger/logger';\n\n/**\n * Checks if the current page is in preview mode.\n */\nexport function isPreviewMode(): boolean {\n return window.location.search.includes('adhesePreviewCreativeId');\n}\n\nexport async function fetchAllUnrenderedSlots(slots: ReadonlyArray<AdheseSlot>): Promise<void> {\n const filteredSlots = slots.filter(slot => !slot.lazyLoading && !slot.data);\n\n if (filteredSlots.length === 0)\n return;\n\n const results = await Promise.allSettled(filteredSlots.map(slot => slot.request));\n\n for (const [index, result] of results.entries()) {\n if (result.status === 'rejected') {\n logger.error(`Failed to fetch slot data for slot ${filteredSlots[index].name}`, result.reason);\n }\n }\n}\n"],"names":[],"mappings":";AAMO,SAAS,gBAAyB;AACvC,SAAO,OAAO,SAAS,OAAO,SAAS,yBAAyB;AAClE;AAEA,eAAsB,wBAAwB,OAAiD;AACvF,QAAA,gBAAgB,MAAM,OAAO,CAAA,SAAQ,CAAC,KAAK,eAAe,CAAC,KAAK,IAAI;AAE1E,MAAI,cAAc,WAAW;AAC3B;AAEI,QAAA,UAAU,MAAM,QAAQ,WAAW,cAAc,IAAI,CAAA,SAAQ,KAAK,OAAO,CAAC;AAEhF,aAAW,CAAC,OAAO,MAAM,KAAK,QAAQ,WAAW;AAC3C,QAAA,OAAO,WAAW,YAAY;AACzB,aAAA,MAAM,sCAAsC,cAAc,KAAK,EAAE,IAAI,IAAI,OAAO,MAAM;AAAA,IAC/F;AAAA,EACF;AACF;"}
@@ -1,5 +1,5 @@
1
1
  const name = "@adhese/sdk";
2
- const version = "1.0.1";
2
+ const version = "1.0.3";
3
3
  export {
4
4
  name,
5
5
  version
package/package.json CHANGED
@@ -1,16 +1,31 @@
1
1
  {
2
2
  "name": "@adhese/sdk",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "description": "Adhese SDK",
6
6
  "license": "GPL-3.0",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/adhese/sdk_typescript.git"
10
10
  },
11
+ "exports": [
12
+ {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs",
16
+ "types@<5.1": "./dist/legacy.d.ts"
17
+ }
18
+ ],
11
19
  "main": "./dist/index.cjs",
12
20
  "module": "./dist/index.js",
13
21
  "types": "./dist/index.d.ts",
22
+ "typesVersions": {
23
+ "<5.1": {
24
+ "*": [
25
+ "./dist/legacy.d.ts"
26
+ ]
27
+ }
28
+ },
14
29
  "files": [
15
30
  "CHANGELOG.md",
16
31
  "LICENSE",