@adhese/sdk 0.11.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +75 -182
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +52 -125
- package/dist/index.js +75 -182
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -58,7 +58,7 @@ function createSafeFrame({
|
|
|
58
58
|
}
|
|
59
59
|
const name = "@adhese/sdk";
|
|
60
60
|
const type = "module";
|
|
61
|
-
const version = "0.
|
|
61
|
+
const version = "0.13.0";
|
|
62
62
|
const description = "Adhese SDK";
|
|
63
63
|
const license = "GPL-3.0";
|
|
64
64
|
const repository = {
|
|
@@ -88,10 +88,10 @@ const scripts = {
|
|
|
88
88
|
prepareRelease: "npm run build"
|
|
89
89
|
};
|
|
90
90
|
const dependencies = {
|
|
91
|
-
"@adhese/sdk-shared": "^0.
|
|
91
|
+
"@adhese/sdk-shared": "^0.2.0",
|
|
92
92
|
"@vue/runtime-core": "^3.4.21",
|
|
93
93
|
remeda: "^1.61.0",
|
|
94
|
-
zod: "^3.23.
|
|
94
|
+
zod: "^3.23.5"
|
|
95
95
|
};
|
|
96
96
|
const packageJson = {
|
|
97
97
|
name,
|
|
@@ -223,17 +223,6 @@ function createSyncHook(name2, {
|
|
|
223
223
|
};
|
|
224
224
|
return [run, (callback) => add(callback, { name: name2, onAdd })];
|
|
225
225
|
}
|
|
226
|
-
function createPassiveHook(name2, {
|
|
227
|
-
onRun,
|
|
228
|
-
onAdd
|
|
229
|
-
} = {}) {
|
|
230
|
-
hookMap.set(name2, /* @__PURE__ */ new Set());
|
|
231
|
-
function run(arg) {
|
|
232
|
-
Promise.allSettled(Array.from(hookMap.get(name2) ?? []).map((callback) => callback(arg))).catch(console.trace);
|
|
233
|
-
onRun == null ? void 0 : onRun(hookMap.get(name2));
|
|
234
|
-
}
|
|
235
|
-
return [run, (callback) => add(callback, { name: name2, onAdd })];
|
|
236
|
-
}
|
|
237
226
|
function isCallbackAsync(callback) {
|
|
238
227
|
return callback.constructor.name === "AsyncFunction";
|
|
239
228
|
}
|
|
@@ -269,77 +258,7 @@ const [runOnInit, onInit] = createSyncHook("onInit", {
|
|
|
269
258
|
runOnInit();
|
|
270
259
|
}
|
|
271
260
|
});
|
|
272
|
-
const
|
|
273
|
-
function createLogger({
|
|
274
|
-
scope,
|
|
275
|
-
logLevels = defaultLogLevels,
|
|
276
|
-
minLogLevelThreshold = logLevels[2]
|
|
277
|
-
}) {
|
|
278
|
-
const logs = /* @__PURE__ */ new Set();
|
|
279
|
-
let currentMinLogLevelThreshold = minLogLevelThreshold;
|
|
280
|
-
const events = sdkShared.createEventManager();
|
|
281
|
-
const logFunctions = Object.fromEntries(logLevels.map((level, index) => {
|
|
282
|
-
const logFunction = (message, attributes) => {
|
|
283
|
-
logs.add({
|
|
284
|
-
scope,
|
|
285
|
-
level,
|
|
286
|
-
message,
|
|
287
|
-
attributes,
|
|
288
|
-
timestamp: Date.now(),
|
|
289
|
-
id: sdkShared.uniqueId()
|
|
290
|
-
});
|
|
291
|
-
events.log.dispatch({
|
|
292
|
-
scope,
|
|
293
|
-
level,
|
|
294
|
-
message,
|
|
295
|
-
attributes,
|
|
296
|
-
timestamp: Date.now(),
|
|
297
|
-
id: sdkShared.uniqueId()
|
|
298
|
-
});
|
|
299
|
-
if (index >= logLevels.indexOf(currentMinLogLevelThreshold)) {
|
|
300
|
-
if (["warn", "error", "trace"].includes(level)) {
|
|
301
|
-
console[level](...[
|
|
302
|
-
`%c${scope}`,
|
|
303
|
-
"color: red; font-weight: bold;",
|
|
304
|
-
message,
|
|
305
|
-
attributes
|
|
306
|
-
].filter(Boolean));
|
|
307
|
-
} else {
|
|
308
|
-
console.log(...[
|
|
309
|
-
`%c${scope} %c${level.toUpperCase()}`,
|
|
310
|
-
"color: red; font-weight: bold;",
|
|
311
|
-
"font-weight: bold;",
|
|
312
|
-
message,
|
|
313
|
-
attributes
|
|
314
|
-
].filter(Boolean));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
return [level, logFunction];
|
|
319
|
-
}));
|
|
320
|
-
return {
|
|
321
|
-
...logFunctions,
|
|
322
|
-
scope,
|
|
323
|
-
events,
|
|
324
|
-
setMinLogLevelThreshold(level) {
|
|
325
|
-
currentMinLogLevelThreshold = level;
|
|
326
|
-
},
|
|
327
|
-
resetMinLogLevelThreshold() {
|
|
328
|
-
currentMinLogLevelThreshold = minLogLevelThreshold;
|
|
329
|
-
},
|
|
330
|
-
getMinLogLevelThreshold() {
|
|
331
|
-
return currentMinLogLevelThreshold;
|
|
332
|
-
},
|
|
333
|
-
getLogs() {
|
|
334
|
-
return Array.from(logs);
|
|
335
|
-
},
|
|
336
|
-
resetLogs() {
|
|
337
|
-
events.reset.dispatch();
|
|
338
|
-
logs.clear();
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
const logger = createLogger({
|
|
261
|
+
const logger = sdkShared.createLogger({
|
|
343
262
|
scope: "Adhese SDK"
|
|
344
263
|
});
|
|
345
264
|
const [runOnRequest, onRequest] = createAsyncHook("onRequest");
|
|
@@ -541,7 +460,7 @@ function getPreviewObjects() {
|
|
|
541
460
|
return previewObjects;
|
|
542
461
|
}
|
|
543
462
|
function requestWithPost({
|
|
544
|
-
context
|
|
463
|
+
context,
|
|
545
464
|
...options
|
|
546
465
|
}) {
|
|
547
466
|
const payload = {
|
|
@@ -550,9 +469,9 @@ function requestWithPost({
|
|
|
550
469
|
slotname: runtimeCore.toValue(slot.name),
|
|
551
470
|
parameters: parseParameters(slot.parameters)
|
|
552
471
|
})),
|
|
553
|
-
parameters: parameters && parseParameters(parameters)
|
|
472
|
+
parameters: context.parameters && parseParameters(context.parameters)
|
|
554
473
|
};
|
|
555
|
-
return fetch(`${new URL(host).href}json`, {
|
|
474
|
+
return fetch(`${new URL(context.options.host).href}json`, {
|
|
556
475
|
method: "POST",
|
|
557
476
|
body: JSON.stringify(payload),
|
|
558
477
|
headers: {
|
|
@@ -594,12 +513,12 @@ const debouncedRequestAds = remeda.debounce(async (context) => {
|
|
|
594
513
|
slots: Array.from(batch.values()).map(({ options }) => options.slot),
|
|
595
514
|
context
|
|
596
515
|
});
|
|
597
|
-
for (const { options, resolve
|
|
516
|
+
for (const { options, resolve } of batch.values()) {
|
|
598
517
|
const ad = ads.find(({ slotName }) => runtimeCore.toValue(slotName) === runtimeCore.toValue(options.slot.name));
|
|
599
518
|
if (ad)
|
|
600
519
|
resolve(ad);
|
|
601
520
|
else
|
|
602
|
-
|
|
521
|
+
resolve(null);
|
|
603
522
|
}
|
|
604
523
|
batch.clear();
|
|
605
524
|
return ads;
|
|
@@ -609,8 +528,8 @@ const debouncedRequestAds = remeda.debounce(async (context) => {
|
|
|
609
528
|
});
|
|
610
529
|
async function requestAd(options) {
|
|
611
530
|
const promise = new Promise(
|
|
612
|
-
(resolve
|
|
613
|
-
batch.set(runtimeCore.toValue(options.slot.name), { options, resolve
|
|
531
|
+
(resolve) => {
|
|
532
|
+
batch.set(runtimeCore.toValue(options.slot.name), { options, resolve });
|
|
614
533
|
}
|
|
615
534
|
);
|
|
616
535
|
await debouncedRequestAds.call(options.context);
|
|
@@ -621,7 +540,7 @@ async function requestAds(requestOptions) {
|
|
|
621
540
|
const options = await runOnRequest(requestOptions);
|
|
622
541
|
const { context } = options;
|
|
623
542
|
try {
|
|
624
|
-
(_a = context.events) == null ? void 0 : _a.requestAd.dispatch({
|
|
543
|
+
(_a = context == null ? void 0 : context.events) == null ? void 0 : _a.requestAd.dispatch({
|
|
625
544
|
...options,
|
|
626
545
|
context
|
|
627
546
|
});
|
|
@@ -652,13 +571,12 @@ async function requestAds(requestOptions) {
|
|
|
652
571
|
return mergedResult;
|
|
653
572
|
} catch (error) {
|
|
654
573
|
logger.error(String(error));
|
|
655
|
-
(_e = context.events) == null ? void 0 : _e.requestError.dispatch(error);
|
|
574
|
+
(_e = context == null ? void 0 : context.events) == null ? void 0 : _e.requestError.dispatch(error);
|
|
656
575
|
throw error;
|
|
657
576
|
}
|
|
658
577
|
}
|
|
659
578
|
const [runOnRender, onRender] = createAsyncHook("onRender");
|
|
660
579
|
const [runOnSlotCreate, onSlotCreate] = createSyncHook("onSlotCreate");
|
|
661
|
-
const [runOnViewabilityChanged, onViewabilityChanged] = createPassiveHook("onViewabilityChanged");
|
|
662
580
|
function useViewabilityObserver({ context, ad, name: name2, element }) {
|
|
663
581
|
let timeoutId = null;
|
|
664
582
|
const {
|
|
@@ -802,16 +720,14 @@ function createSlot(slotOptions) {
|
|
|
802
720
|
var _a, _b;
|
|
803
721
|
if ((!newAd || oldAd && remeda.isDeepEqual(newAd, oldAd)) && isRendered.value)
|
|
804
722
|
return;
|
|
805
|
-
if (newIsInViewport
|
|
723
|
+
if (newIsInViewport)
|
|
806
724
|
await render(newAd ?? void 0);
|
|
807
725
|
(_b = context.events) == null ? void 0 : _b.changeSlots.dispatch(Array.from(((_a = context.getAll) == null ? void 0 : _a.call(context)) ?? []));
|
|
808
726
|
});
|
|
809
727
|
runtimeCore.watch(isInViewport, (value) => {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
});
|
|
814
|
-
}, { immediate: true });
|
|
728
|
+
var _a;
|
|
729
|
+
(_a = options.onViewabilityChanged) == null ? void 0 : _a.call(options, value);
|
|
730
|
+
});
|
|
815
731
|
const [
|
|
816
732
|
isViewabilityTracked,
|
|
817
733
|
disposeViewabilityObserver
|
|
@@ -831,7 +747,11 @@ function createSlot(slotOptions) {
|
|
|
831
747
|
},
|
|
832
748
|
context
|
|
833
749
|
});
|
|
834
|
-
|
|
750
|
+
if (response) {
|
|
751
|
+
ad.value = response;
|
|
752
|
+
if (!originalAd.value)
|
|
753
|
+
originalAd.value = response;
|
|
754
|
+
}
|
|
835
755
|
return response;
|
|
836
756
|
}
|
|
837
757
|
async function render(adToRender) {
|
|
@@ -839,8 +759,11 @@ function createSlot(slotOptions) {
|
|
|
839
759
|
await sdkShared.waitForDomLoad();
|
|
840
760
|
await waitOnInit;
|
|
841
761
|
let renderAd = adToRender ?? ad.value ?? originalAd.value ?? await requestAd$1();
|
|
842
|
-
if (renderAd)
|
|
843
|
-
|
|
762
|
+
if (!renderAd) {
|
|
763
|
+
logger.debug(`No ad to render for slot ${name2.value}`);
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
renderAd = ((_a = options.onBeforeRender) == null ? void 0 : _a.call(options, renderAd)) ?? renderAd;
|
|
844
767
|
renderAd = await runOnRender(renderAd);
|
|
845
768
|
if (!element.value) {
|
|
846
769
|
const error = `Could not create slot for format ${format.value}. No element found.`;
|
|
@@ -889,8 +812,13 @@ function createSlot(slotOptions) {
|
|
|
889
812
|
queryDetector == null ? void 0 : queryDetector.dispose();
|
|
890
813
|
scope.stop();
|
|
891
814
|
}
|
|
815
|
+
onInit(async () => {
|
|
816
|
+
if (options.lazyLoading)
|
|
817
|
+
return;
|
|
818
|
+
ad.value = await requestAd$1();
|
|
819
|
+
});
|
|
892
820
|
return {
|
|
893
|
-
location: context.location,
|
|
821
|
+
location: context.location ?? "",
|
|
894
822
|
lazyLoading: options.lazyLoading ?? false,
|
|
895
823
|
slot,
|
|
896
824
|
parameters,
|
|
@@ -901,6 +829,7 @@ function createSlot(slotOptions) {
|
|
|
901
829
|
isImpressionTracked,
|
|
902
830
|
render,
|
|
903
831
|
getElement,
|
|
832
|
+
request: requestAd$1,
|
|
904
833
|
dispose
|
|
905
834
|
};
|
|
906
835
|
});
|
|
@@ -960,6 +889,10 @@ function createSlotManager({
|
|
|
960
889
|
slot.dispose();
|
|
961
890
|
throw new Error(`Slot with the name: ${slot.name.value} already exists. Create a new slot with a different format, slot, or the location.`);
|
|
962
891
|
}
|
|
892
|
+
const disposeSlotWatch = runtimeCore.watch(slot.name, (newName, previousName) => {
|
|
893
|
+
slots.set(newName, slot);
|
|
894
|
+
slots.delete(previousName);
|
|
895
|
+
});
|
|
963
896
|
function onDispose2() {
|
|
964
897
|
var _a2;
|
|
965
898
|
slots.delete(slot.name.value);
|
|
@@ -968,12 +901,9 @@ function createSlotManager({
|
|
|
968
901
|
slots: Array.from(slots)
|
|
969
902
|
});
|
|
970
903
|
(_a2 = context.events) == null ? void 0 : _a2.removeSlot.dispatch(slot);
|
|
904
|
+
disposeSlotWatch();
|
|
971
905
|
}
|
|
972
906
|
slots.set(slot.name.value, slot);
|
|
973
|
-
runtimeCore.watch(slot.name, (newName, previousName) => {
|
|
974
|
-
slots.set(newName, slot);
|
|
975
|
-
slots.delete(previousName);
|
|
976
|
-
});
|
|
977
907
|
logger.debug("Slot added", {
|
|
978
908
|
slot,
|
|
979
909
|
slots: Array.from(slots.values())
|
|
@@ -1087,7 +1017,14 @@ function createAdhese(options) {
|
|
|
1087
1017
|
debug: mergedOptions.debug,
|
|
1088
1018
|
options: mergedOptions,
|
|
1089
1019
|
logger,
|
|
1090
|
-
isDisposed: false
|
|
1020
|
+
isDisposed: false,
|
|
1021
|
+
parameters: /* @__PURE__ */ new Map(),
|
|
1022
|
+
events: sdkShared.createEventManager(),
|
|
1023
|
+
dispose,
|
|
1024
|
+
findDomSlots: findDomSlots2,
|
|
1025
|
+
getAll,
|
|
1026
|
+
get,
|
|
1027
|
+
addSlot
|
|
1091
1028
|
});
|
|
1092
1029
|
for (const [index, plugin] of mergedOptions.plugins.entries()) {
|
|
1093
1030
|
plugin(context, {
|
|
@@ -1098,8 +1035,7 @@ function createAdhese(options) {
|
|
|
1098
1035
|
onRender,
|
|
1099
1036
|
onRequest,
|
|
1100
1037
|
onResponse,
|
|
1101
|
-
onSlotCreate
|
|
1102
|
-
onViewabilityChanged
|
|
1038
|
+
onSlotCreate
|
|
1103
1039
|
});
|
|
1104
1040
|
}
|
|
1105
1041
|
context.events = sdkShared.createEventManager();
|
|
@@ -1107,52 +1043,39 @@ function createAdhese(options) {
|
|
|
1107
1043
|
renderFile: `${mergedOptions.poolHost}/sf/r.html`,
|
|
1108
1044
|
context
|
|
1109
1045
|
}) : void 0;
|
|
1110
|
-
|
|
1111
|
-
return context.location;
|
|
1112
|
-
}
|
|
1113
|
-
function setLocation(newLocation) {
|
|
1046
|
+
runtimeCore.watch(() => context.location, (newLocation) => {
|
|
1114
1047
|
var _a;
|
|
1115
|
-
context.location = newLocation;
|
|
1116
1048
|
(_a = context.events) == null ? void 0 : _a.locationChange.dispatch(newLocation);
|
|
1117
|
-
}
|
|
1049
|
+
});
|
|
1118
1050
|
const queryDetector = createQueryDetector({
|
|
1119
1051
|
onChange: onQueryChange,
|
|
1120
1052
|
queries: mergedOptions.queries
|
|
1121
1053
|
});
|
|
1122
1054
|
context.parameters = createParameters(mergedOptions, queryDetector);
|
|
1123
1055
|
runtimeCore.watch(
|
|
1124
|
-
context.parameters,
|
|
1125
|
-
|
|
1056
|
+
() => context.parameters,
|
|
1057
|
+
(newParameters) => {
|
|
1058
|
+
var _a;
|
|
1059
|
+
(_a = context.events) == null ? void 0 : _a.parametersChange.dispatch(newParameters);
|
|
1060
|
+
},
|
|
1126
1061
|
{
|
|
1127
|
-
deep: true
|
|
1128
|
-
immediate: true
|
|
1062
|
+
deep: true
|
|
1129
1063
|
}
|
|
1130
1064
|
);
|
|
1131
|
-
function onParametersChange() {
|
|
1132
|
-
var _a;
|
|
1133
|
-
if (context.parameters)
|
|
1134
|
-
(_a = context.events) == null ? void 0 : _a.parametersChange.dispatch(context.parameters);
|
|
1135
|
-
}
|
|
1136
|
-
const debouncedFetchAllUnrenderedSlots = remeda.debounce(fetchAllUnrenderedSlots, {
|
|
1137
|
-
waitMs: 100,
|
|
1138
|
-
timing: "both"
|
|
1139
|
-
});
|
|
1140
1065
|
async function onQueryChange() {
|
|
1141
1066
|
var _a, _b;
|
|
1142
1067
|
const query = queryDetector.getQuery();
|
|
1143
1068
|
(_a = context.parameters) == null ? void 0 : _a.set("dt", query);
|
|
1144
1069
|
(_b = context.parameters) == null ? void 0 : _b.set("br", query);
|
|
1145
|
-
await
|
|
1146
|
-
}
|
|
1147
|
-
function getConsent() {
|
|
1148
|
-
return context.consent;
|
|
1070
|
+
await fetchAllUnrenderedSlots();
|
|
1149
1071
|
}
|
|
1150
|
-
|
|
1072
|
+
runtimeCore.watch(() => context.consent, (newConsent) => {
|
|
1151
1073
|
var _a, _b;
|
|
1152
1074
|
(_a = context.parameters) == null ? void 0 : _a.set("tl", newConsent ? "all" : "none");
|
|
1153
|
-
context.consent = newConsent;
|
|
1154
1075
|
(_b = context.events) == null ? void 0 : _b.consentChange.dispatch(newConsent);
|
|
1155
|
-
}
|
|
1076
|
+
}, {
|
|
1077
|
+
immediate: true
|
|
1078
|
+
});
|
|
1156
1079
|
const slotManager = createSlotManager({
|
|
1157
1080
|
initialSlots: mergedOptions.initialSlots,
|
|
1158
1081
|
context
|
|
@@ -1166,30 +1089,20 @@ function createAdhese(options) {
|
|
|
1166
1089
|
}
|
|
1167
1090
|
context.get = get;
|
|
1168
1091
|
function addSlot(slotOptions) {
|
|
1169
|
-
|
|
1170
|
-
debouncedFetchAllUnrenderedSlots.call().catch(logger.error);
|
|
1171
|
-
return newSlot;
|
|
1092
|
+
return slotManager.add(slotOptions);
|
|
1172
1093
|
}
|
|
1173
1094
|
context.addSlot = addSlot;
|
|
1174
1095
|
async function findDomSlots2() {
|
|
1175
1096
|
const domSlots = (await slotManager.findDomSlots() ?? []).filter((slot) => !slot.lazyLoading);
|
|
1176
1097
|
if (domSlots.length <= 0)
|
|
1177
1098
|
return [];
|
|
1178
|
-
|
|
1179
|
-
slot,
|
|
1180
|
-
context
|
|
1181
|
-
})));
|
|
1182
|
-
for (const ad of ads) {
|
|
1183
|
-
const slot = slotManager.get(ad.slotName);
|
|
1184
|
-
if (slot)
|
|
1185
|
-
slot.ad.value = ad;
|
|
1186
|
-
}
|
|
1099
|
+
await fetchAllUnrenderedSlots();
|
|
1187
1100
|
return domSlots;
|
|
1188
1101
|
}
|
|
1189
|
-
|
|
1102
|
+
context.findDomSlots = findDomSlots2;
|
|
1103
|
+
runtimeCore.watch(() => context.debug, async (newDebug) => {
|
|
1190
1104
|
var _a, _b;
|
|
1191
|
-
|
|
1192
|
-
if (context.debug) {
|
|
1105
|
+
if (newDebug) {
|
|
1193
1106
|
logger.setMinLogLevelThreshold("debug");
|
|
1194
1107
|
logger.debug("Debug mode enabled");
|
|
1195
1108
|
(_a = context.events) == null ? void 0 : _a.debugChange.dispatch(true);
|
|
@@ -1198,21 +1111,14 @@ function createAdhese(options) {
|
|
|
1198
1111
|
logger.setMinLogLevelThreshold("info");
|
|
1199
1112
|
(_b = context.events) == null ? void 0 : _b.debugChange.dispatch(false);
|
|
1200
1113
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1114
|
+
}, {
|
|
1115
|
+
immediate: true
|
|
1116
|
+
});
|
|
1203
1117
|
async function fetchAllUnrenderedSlots() {
|
|
1204
1118
|
const slots = (slotManager.getAll() ?? []).filter((slot) => !slot.lazyLoading && !slot.ad.value);
|
|
1205
1119
|
if (slots.length === 0)
|
|
1206
1120
|
return;
|
|
1207
|
-
|
|
1208
|
-
slot,
|
|
1209
|
-
context
|
|
1210
|
-
})));
|
|
1211
|
-
for (const ad of ads) {
|
|
1212
|
-
const slot = slotManager.get(ad.slotName);
|
|
1213
|
-
if (slot)
|
|
1214
|
-
slot.ad.value = ad;
|
|
1215
|
-
}
|
|
1121
|
+
await Promise.allSettled(slots.map((slot) => slot.request()));
|
|
1216
1122
|
}
|
|
1217
1123
|
const disposeOnTcfConsentChange = onTcfConsentChange(async (data) => {
|
|
1218
1124
|
var _a, _b;
|
|
@@ -1223,7 +1129,7 @@ function createAdhese(options) {
|
|
|
1223
1129
|
});
|
|
1224
1130
|
(_a = context.parameters) == null ? void 0 : _a.set("xt", data.tcString);
|
|
1225
1131
|
(_b = context.parameters) == null ? void 0 : _b.delete("tl");
|
|
1226
|
-
await
|
|
1132
|
+
await fetchAllUnrenderedSlots();
|
|
1227
1133
|
});
|
|
1228
1134
|
function dispose() {
|
|
1229
1135
|
var _a, _b;
|
|
@@ -1240,34 +1146,21 @@ function createAdhese(options) {
|
|
|
1240
1146
|
clearAllHooks();
|
|
1241
1147
|
scope.stop();
|
|
1242
1148
|
}
|
|
1149
|
+
context.dispose = dispose;
|
|
1243
1150
|
onInit(async () => {
|
|
1244
1151
|
var _a;
|
|
1152
|
+
await sdkShared.awaitTimeout(0);
|
|
1245
1153
|
if ((slotManager.getAll().length ?? 0) > 0)
|
|
1246
1154
|
await fetchAllUnrenderedSlots().catch(logger.error);
|
|
1247
1155
|
if (mergedOptions.findDomSlotsOnLoad)
|
|
1248
|
-
await
|
|
1156
|
+
await (context == null ? void 0 : context.findDomSlots());
|
|
1249
1157
|
if (mergedOptions.debug || window.location.search.includes("adhese_debug=true") || isPreviewMode())
|
|
1250
1158
|
(_a = context.events) == null ? void 0 : _a.debugChange.dispatch(true);
|
|
1251
1159
|
if (!scope.active)
|
|
1252
1160
|
dispose();
|
|
1253
1161
|
});
|
|
1254
1162
|
runOnInit();
|
|
1255
|
-
return
|
|
1256
|
-
parameters: context.parameters,
|
|
1257
|
-
events: context.events,
|
|
1258
|
-
getLocation,
|
|
1259
|
-
setLocation,
|
|
1260
|
-
getConsent,
|
|
1261
|
-
setConsent,
|
|
1262
|
-
addSlot,
|
|
1263
|
-
findDomSlots: findDomSlots2,
|
|
1264
|
-
dispose,
|
|
1265
|
-
toggleDebug,
|
|
1266
|
-
get: slotManager.get,
|
|
1267
|
-
getAll: slotManager.getAll,
|
|
1268
|
-
context,
|
|
1269
|
-
options: mergedOptions
|
|
1270
|
-
};
|
|
1163
|
+
return context;
|
|
1271
1164
|
});
|
|
1272
1165
|
}
|
|
1273
1166
|
exports.createAdhese = createAdhese;
|