@c15t/scripts 2.0.0-rc.1 → 2.0.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.
Files changed (59) hide show
  1. package/README.md +3 -3
  2. package/dist/databuddy.cjs +103 -48
  3. package/dist/databuddy.js +99 -47
  4. package/dist/e2e-test-utils.cjs +125 -0
  5. package/dist/e2e-test-utils.js +67 -0
  6. package/dist/engine/compile.cjs +126 -0
  7. package/dist/engine/compile.js +89 -0
  8. package/dist/engine/runtime.cjs +378 -0
  9. package/dist/engine/runtime.js +344 -0
  10. package/dist/google-tag-manager.cjs +78 -86
  11. package/dist/google-tag-manager.js +74 -79
  12. package/dist/google-tag.cjs +86 -37
  13. package/dist/google-tag.js +82 -36
  14. package/dist/linkedin-insights.cjs +51 -33
  15. package/dist/linkedin-insights.js +46 -31
  16. package/dist/meta-pixel.cjs +90 -28
  17. package/dist/meta-pixel.js +86 -27
  18. package/dist/microsoft-uet.cjs +90 -50
  19. package/dist/microsoft-uet.js +86 -49
  20. package/dist/posthog.cjs +100 -51
  21. package/dist/posthog.js +96 -50
  22. package/dist/resolve.cjs +67 -0
  23. package/dist/resolve.js +33 -0
  24. package/dist/tiktok-pixel.cjs +91 -29
  25. package/dist/tiktok-pixel.js +86 -27
  26. package/dist/types.cjs +47 -0
  27. package/dist/types.js +7 -0
  28. package/dist/x-pixel.cjs +48 -14
  29. package/dist/x-pixel.js +43 -12
  30. package/dist-types/databuddy.d.ts +144 -0
  31. package/dist-types/engine/compile.d.ts +3 -0
  32. package/dist-types/engine/runtime.d.ts +3 -0
  33. package/dist-types/google-tag-manager.d.ts +97 -0
  34. package/dist-types/google-tag.d.ts +96 -0
  35. package/dist-types/linkedin-insights.d.ts +79 -0
  36. package/{dist → dist-types}/meta-pixel.d.ts +61 -14
  37. package/dist-types/microsoft-uet.d.ts +94 -0
  38. package/dist-types/posthog.d.ts +112 -0
  39. package/dist-types/resolve.d.ts +9 -0
  40. package/dist-types/tiktok-pixel.d.ts +91 -0
  41. package/dist-types/types.d.ts +259 -0
  42. package/{dist → dist-types}/x-pixel.d.ts +38 -12
  43. package/package.json +9 -8
  44. package/dist/databuddy.d.ts +0 -104
  45. package/dist/databuddy.d.ts.map +0 -1
  46. package/dist/google-tag-manager.d.ts +0 -63
  47. package/dist/google-tag-manager.d.ts.map +0 -1
  48. package/dist/google-tag.d.ts +0 -38
  49. package/dist/google-tag.d.ts.map +0 -1
  50. package/dist/linkedin-insights.d.ts +0 -48
  51. package/dist/linkedin-insights.d.ts.map +0 -1
  52. package/dist/meta-pixel.d.ts.map +0 -1
  53. package/dist/microsoft-uet.d.ts +0 -40
  54. package/dist/microsoft-uet.d.ts.map +0 -1
  55. package/dist/posthog.d.ts +0 -54
  56. package/dist/posthog.d.ts.map +0 -1
  57. package/dist/tiktok-pixel.d.ts +0 -44
  58. package/dist/tiktok-pixel.d.ts.map +0 -1
  59. package/dist/x-pixel.d.ts.map +0 -1
@@ -0,0 +1,89 @@
1
+ import { VENDOR_MANIFEST_KIND, VENDOR_MANIFEST_SCHEMA_VERSION } from "../types.js";
2
+ const EXACT_PLACEHOLDER_PATTERN = /^\{\{([A-Za-z0-9_]+)\}\}$/;
3
+ const PLACEHOLDER_PATTERN = /\{\{([A-Za-z0-9_]+)\}\}/g;
4
+ function getConfigValue(config, key) {
5
+ if (!(key in config)) throw new Error(`Missing manifest interpolation value for '${key}'.`);
6
+ const value = config[key];
7
+ if ('function' == typeof value) throw new Error(`Manifest interpolation value for '${key}' must be serializable.`);
8
+ return value;
9
+ }
10
+ function stringifyInterpolatedValue(value, key) {
11
+ if (void 0 === value) throw new Error(`Missing manifest interpolation value for '${key}'.`);
12
+ if ('string' == typeof value) return value;
13
+ if (null === value) return 'null';
14
+ if ('object' == typeof value) return JSON.stringify(value);
15
+ return String(value);
16
+ }
17
+ function interpolateString(template, config) {
18
+ const exactMatch = template.match(EXACT_PLACEHOLDER_PATTERN);
19
+ if (exactMatch) return getConfigValue(config, exactMatch[1]);
20
+ return template.replace(PLACEHOLDER_PATTERN, (_match, key)=>{
21
+ const value = getConfigValue(config, key);
22
+ return stringifyInterpolatedValue(value, key);
23
+ });
24
+ }
25
+ function interpolateValue(value, config) {
26
+ if ('string' == typeof value) return interpolateString(value, config);
27
+ if (Array.isArray(value)) return value.map((item)=>interpolateValue(item, config));
28
+ if (null !== value && 'object' == typeof value) {
29
+ const result = {};
30
+ for (const [key, nestedValue] of Object.entries(value)){
31
+ const interpolated = interpolateValue(nestedValue, config);
32
+ if (void 0 !== interpolated) result[key] = interpolated;
33
+ }
34
+ return result;
35
+ }
36
+ return value;
37
+ }
38
+ function interpolateSteps(steps, config) {
39
+ if (!steps) return [];
40
+ return steps.map((step)=>interpolateValue(step, config));
41
+ }
42
+ function extractInstallArtifacts(install) {
43
+ const loadScriptSteps = install.filter((step)=>'loadScript' === step.type);
44
+ if (loadScriptSteps.length > 1) throw new Error('Vendor manifests may only declare a single loadScript step in install.');
45
+ if (1 === loadScriptSteps.length) {
46
+ const loadScript = loadScriptSteps[0];
47
+ if ('string' != typeof loadScript.src || 0 === loadScript.src.trim().length) throw new Error('loadScript steps must include a non-empty src after manifest interpolation.');
48
+ return {
49
+ loadScript,
50
+ setupSteps: install.filter((step)=>'loadScript' !== step.type)
51
+ };
52
+ }
53
+ return {
54
+ setupSteps: install
55
+ };
56
+ }
57
+ function validateManifestContract(manifest) {
58
+ if (manifest.kind !== VENDOR_MANIFEST_KIND) throw new Error(`Unsupported manifest kind '${String(manifest.kind)}'. Expected '${VENDOR_MANIFEST_KIND}'.`);
59
+ if (manifest.schemaVersion !== VENDOR_MANIFEST_SCHEMA_VERSION) throw new Error(`Unsupported manifest schema version '${String(manifest.schemaVersion)}'. Expected '${VENDOR_MANIFEST_SCHEMA_VERSION}'.`);
60
+ }
61
+ function compileManifest(manifest, config = {}) {
62
+ validateManifestContract(manifest);
63
+ const bootstrapSteps = interpolateSteps(manifest.bootstrap, config);
64
+ const install = interpolateSteps(manifest.install, config);
65
+ const { loadScript, setupSteps } = extractInstallArtifacts(install);
66
+ return {
67
+ kind: manifest.kind,
68
+ schemaVersion: manifest.schemaVersion,
69
+ vendor: manifest.vendor,
70
+ category: interpolateValue(manifest.category, config),
71
+ alwaysLoad: void 0 === manifest.alwaysLoad ? void 0 : interpolateValue(manifest.alwaysLoad, config),
72
+ persistAfterConsentRevoked: void 0 === manifest.persistAfterConsentRevoked ? void 0 : interpolateValue(manifest.persistAfterConsentRevoked, config),
73
+ bootstrapSteps,
74
+ setupSteps,
75
+ loadScript,
76
+ afterLoadSteps: interpolateSteps(manifest.afterLoad, config),
77
+ onBeforeLoadGrantedSteps: interpolateSteps(manifest.onBeforeLoadGranted, config),
78
+ onBeforeLoadDeniedSteps: interpolateSteps(manifest.onBeforeLoadDenied, config),
79
+ onLoadGrantedSteps: interpolateSteps(manifest.onLoadGranted, config),
80
+ onLoadDeniedSteps: interpolateSteps(manifest.onLoadDenied, config),
81
+ onConsentChangeSteps: interpolateSteps(manifest.onConsentChange, config),
82
+ onConsentGrantedSteps: interpolateSteps(manifest.onConsentGranted, config),
83
+ onConsentDeniedSteps: interpolateSteps(manifest.onConsentDenied, config),
84
+ consentMapping: manifest.consentMapping ? interpolateValue(manifest.consentMapping, config) : void 0,
85
+ consentSignal: manifest.consentSignal,
86
+ consentSignalTarget: 'string' == typeof manifest.consentSignalTarget ? interpolateValue(manifest.consentSignalTarget, config) : manifest.consentSignalTarget
87
+ };
88
+ }
89
+ export { compileManifest, interpolateValue };
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ resolvedManifestToScript: ()=>resolvedManifestToScript
28
+ });
29
+ const external_c15t_namespaceObject = require("c15t");
30
+ function cloneStepValue(value) {
31
+ if (value instanceof Date) return new Date(value);
32
+ if (Array.isArray(value)) return value.map((item)=>cloneStepValue(item));
33
+ if (null !== value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).map(([key, nestedValue])=>[
34
+ key,
35
+ cloneStepValue(nestedValue)
36
+ ]));
37
+ return value;
38
+ }
39
+ function isRecord(value) {
40
+ return null !== value && 'object' == typeof value && !Array.isArray(value);
41
+ }
42
+ function getPathTarget(root, path) {
43
+ if (0 === path.length) return;
44
+ let target = root;
45
+ for (const segment of path.slice(0, -1)){
46
+ const next = target[segment];
47
+ if (null === next || 'object' != typeof next) return;
48
+ target = next;
49
+ }
50
+ return {
51
+ target,
52
+ key: path[path.length - 1]
53
+ };
54
+ }
55
+ function resolveQueueTarget(root, queue, owner) {
56
+ if ('global' in queue && 'string' == typeof queue.global) {
57
+ const queueTarget = root[queue.global];
58
+ return Array.isArray(queueTarget) ? queueTarget : void 0;
59
+ }
60
+ if (!owner) return;
61
+ const queueProperty = queue.property;
62
+ const queueTarget = owner[queueProperty];
63
+ return Array.isArray(queueTarget) ? queueTarget : void 0;
64
+ }
65
+ function executeStep(step) {
66
+ const win = window;
67
+ switch(step.type){
68
+ case 'setGlobal':
69
+ {
70
+ const shouldSet = false !== step.ifUndefined;
71
+ if (shouldSet && void 0 !== win[step.name]) break;
72
+ win[step.name] = cloneStepValue(step.value);
73
+ break;
74
+ }
75
+ case 'defineQueueFunction':
76
+ {
77
+ const shouldSet = false !== step.ifUndefined;
78
+ if (shouldSet && void 0 !== win[step.name]) break;
79
+ win[step.name] = function() {
80
+ const queueTarget = win[step.queue];
81
+ if (!Array.isArray(queueTarget)) return;
82
+ if ('array' === step.pushStyle) return void queueTarget.push(Array.from(arguments));
83
+ queueTarget.push(arguments);
84
+ };
85
+ break;
86
+ }
87
+ case 'defineStubFunction':
88
+ {
89
+ const shouldSet = false !== step.ifUndefined;
90
+ if (shouldSet && void 0 !== win[step.name]) break;
91
+ const stub = function() {
92
+ const self = win[step.name];
93
+ const dispatcher = self && step.dispatchProperty ? self[step.dispatchProperty] : void 0;
94
+ const runtimeArgs = Array.from(arguments);
95
+ if ('function' == typeof dispatcher) return void dispatcher.apply(self, runtimeArgs);
96
+ const queueTarget = resolveQueueTarget(win, step.queue, self);
97
+ if (!queueTarget) return;
98
+ if ('array' === step.queueFormat) return void queueTarget.push(runtimeArgs);
99
+ queueTarget.push(arguments);
100
+ };
101
+ win[step.name] = stub;
102
+ const stubRecord = stub;
103
+ if ('property' in step.queue && 'string' == typeof step.queue.property) {
104
+ const queueProperty = step.queue.property;
105
+ if (void 0 === stubRecord[queueProperty]) stubRecord[queueProperty] = [];
106
+ }
107
+ for (const alias of step.aliases ?? [])win[alias] = stub;
108
+ for (const selfReference of step.selfReferences ?? [])stubRecord[selfReference] = stub;
109
+ for (const [key, value] of Object.entries(step.properties ?? {}))stubRecord[key] = cloneStepValue(value);
110
+ break;
111
+ }
112
+ case 'callGlobal':
113
+ {
114
+ const target = win[step.global];
115
+ if (!target) break;
116
+ const args = (step.args ?? []).map((arg)=>cloneStepValue(arg));
117
+ if (step.method) {
118
+ const objectTarget = target;
119
+ const method = objectTarget[step.method];
120
+ if ('function' == typeof method) method.apply(objectTarget, args);
121
+ } else if ('function' == typeof target) target(...args);
122
+ break;
123
+ }
124
+ case 'pushToQueue':
125
+ {
126
+ const queueTarget = win[step.queue];
127
+ if (Array.isArray(queueTarget)) queueTarget.push(cloneStepValue(step.value));
128
+ break;
129
+ }
130
+ case 'setGlobalPath':
131
+ {
132
+ const pathTarget = getPathTarget(win, step.path);
133
+ if (!pathTarget) break;
134
+ pathTarget.target[pathTarget.key] = cloneStepValue(step.value);
135
+ break;
136
+ }
137
+ case 'defineQueueMethods':
138
+ {
139
+ const target = win[step.target];
140
+ if (null === target || 'object' != typeof target && 'function' != typeof target) break;
141
+ const targetRecord = target;
142
+ for (const methodName of step.methods)targetRecord[methodName] = (...args)=>{
143
+ const queueTarget = resolveQueueTarget(win, step.queue ?? {
144
+ global: step.target
145
+ }, targetRecord);
146
+ if (!queueTarget) return;
147
+ queueTarget.push([
148
+ methodName,
149
+ ...args
150
+ ]);
151
+ };
152
+ break;
153
+ }
154
+ case 'defineGlobalMethods':
155
+ {
156
+ const target = win[step.target];
157
+ if (null === target || 'object' != typeof target && 'function' != typeof target) break;
158
+ const targetRecord = target;
159
+ for (const method of step.methods)targetRecord[method.name] = 'return' === method.behavior ? ()=>cloneStepValue(method.value) : ()=>{};
160
+ break;
161
+ }
162
+ case 'constructGlobal':
163
+ {
164
+ const Constructor = win[step.constructor];
165
+ if ('function' != typeof Constructor) break;
166
+ const args = (step.args ?? []).map((arg)=>cloneStepValue(arg));
167
+ if (step.copyAssignedValueToArgProperty) {
168
+ const firstArg = args[0];
169
+ const targetOptions = isRecord(firstArg) ? firstArg : {};
170
+ targetOptions[step.copyAssignedValueToArgProperty] = win[step.assignTo];
171
+ if (!isRecord(firstArg)) args.unshift(targetOptions);
172
+ }
173
+ win[step.assignTo] = new Constructor(...args);
174
+ break;
175
+ }
176
+ case 'loadScript':
177
+ break;
178
+ }
179
+ }
180
+ function executePhaseSteps(steps, context) {
181
+ if (0 === steps.length) return;
182
+ (0, external_c15t_namespaceObject.emitScriptDebugEvent)({
183
+ source: 'manifest-runtime',
184
+ scope: 'phase',
185
+ action: 'phase_start',
186
+ message: `Manifest phase ${context.phase} started`,
187
+ scriptId: context.scriptId,
188
+ elementId: context.elementId,
189
+ hasConsent: context.hasConsent,
190
+ callback: context.callback,
191
+ phase: context.phase,
192
+ data: {
193
+ stepCount: steps.length
194
+ }
195
+ });
196
+ for (const [stepIndex, step] of steps.entries())try {
197
+ executeStep(step);
198
+ (0, external_c15t_namespaceObject.emitScriptDebugEvent)({
199
+ source: 'manifest-runtime',
200
+ scope: 'step',
201
+ action: 'step_executed',
202
+ message: `Executed ${step.type}`,
203
+ scriptId: context.scriptId,
204
+ elementId: context.elementId,
205
+ hasConsent: context.hasConsent,
206
+ callback: context.callback,
207
+ phase: context.phase,
208
+ stepType: step.type,
209
+ stepIndex
210
+ });
211
+ } catch (error) {
212
+ (0, external_c15t_namespaceObject.emitScriptDebugEvent)({
213
+ source: 'manifest-runtime',
214
+ scope: 'step',
215
+ action: 'step_error',
216
+ message: `Failed to execute ${step.type}`,
217
+ scriptId: context.scriptId,
218
+ elementId: context.elementId,
219
+ hasConsent: context.hasConsent,
220
+ callback: context.callback,
221
+ phase: context.phase,
222
+ stepType: step.type,
223
+ stepIndex,
224
+ data: {
225
+ error: error instanceof Error ? error.message : 'string' == typeof error ? error : 'Unknown error'
226
+ }
227
+ });
228
+ throw error;
229
+ }
230
+ (0, external_c15t_namespaceObject.emitScriptDebugEvent)({
231
+ source: 'manifest-runtime',
232
+ scope: 'phase',
233
+ action: 'phase_complete',
234
+ message: `Manifest phase ${context.phase} completed`,
235
+ scriptId: context.scriptId,
236
+ elementId: context.elementId,
237
+ hasConsent: context.hasConsent,
238
+ callback: context.callback,
239
+ phase: context.phase,
240
+ data: {
241
+ stepCount: steps.length
242
+ }
243
+ });
244
+ }
245
+ function mapConsentState(mapping, consents) {
246
+ const result = {};
247
+ for (const [c15tCategory, vendorTypes] of Object.entries(mapping)){
248
+ const isGranted = consents[c15tCategory];
249
+ for (const vendorType of vendorTypes)result[vendorType] = isGranted ? 'granted' : 'denied';
250
+ }
251
+ return result;
252
+ }
253
+ function getConsentSignalSteps(resolvedManifest, mode, consents) {
254
+ if (!resolvedManifest.consentMapping || !resolvedManifest.consentSignal) return [];
255
+ const mapped = mapConsentState(resolvedManifest.consentMapping, consents);
256
+ switch(resolvedManifest.consentSignal){
257
+ case 'gtag':
258
+ return [
259
+ {
260
+ type: 'callGlobal',
261
+ global: resolvedManifest.consentSignalTarget ?? 'gtag',
262
+ args: [
263
+ 'consent',
264
+ mode,
265
+ mapped
266
+ ]
267
+ }
268
+ ];
269
+ }
270
+ }
271
+ function resolvedManifestToScript(resolvedManifest) {
272
+ const hasConsentMapping = !!(resolvedManifest.consentMapping && resolvedManifest.consentSignal);
273
+ const hasLoadConsentBranches = !!(resolvedManifest.onLoadGrantedSteps.length > 0 || resolvedManifest.onLoadDeniedSteps.length > 0);
274
+ const hasConsentLifecycle = !!(resolvedManifest.onConsentChangeSteps.length > 0 || resolvedManifest.onConsentGrantedSteps.length > 0 || resolvedManifest.onConsentDeniedSteps.length > 0 || hasConsentMapping);
275
+ const script = {
276
+ id: resolvedManifest.vendor,
277
+ category: resolvedManifest.category,
278
+ alwaysLoad: resolvedManifest.alwaysLoad,
279
+ persistAfterConsentRevoked: resolvedManifest.persistAfterConsentRevoked,
280
+ callbackOnly: resolvedManifest.loadScript ? void 0 : true,
281
+ src: resolvedManifest.loadScript?.src,
282
+ async: resolvedManifest.loadScript?.async,
283
+ defer: resolvedManifest.loadScript?.defer,
284
+ attributes: resolvedManifest.loadScript?.attributes
285
+ };
286
+ if (resolvedManifest.bootstrapSteps.length > 0 || resolvedManifest.setupSteps.length > 0 || resolvedManifest.onBeforeLoadGrantedSteps.length > 0 || resolvedManifest.onBeforeLoadDeniedSteps.length > 0 || hasConsentMapping) script.onBeforeLoad = (info)=>{
287
+ const baseContext = {
288
+ scriptId: resolvedManifest.vendor,
289
+ elementId: info.elementId,
290
+ hasConsent: info.hasConsent,
291
+ callback: 'onBeforeLoad'
292
+ };
293
+ executePhaseSteps(resolvedManifest.bootstrapSteps, {
294
+ ...baseContext,
295
+ phase: 'bootstrap'
296
+ });
297
+ executePhaseSteps(getConsentSignalSteps(resolvedManifest, 'default', info.consents), {
298
+ ...baseContext,
299
+ phase: 'consent-default'
300
+ });
301
+ executePhaseSteps(resolvedManifest.setupSteps, {
302
+ ...baseContext,
303
+ phase: 'setup'
304
+ });
305
+ executePhaseSteps(info.hasConsent ? resolvedManifest.onBeforeLoadGrantedSteps : resolvedManifest.onBeforeLoadDeniedSteps, {
306
+ ...baseContext,
307
+ phase: info.hasConsent ? 'onBeforeLoadGranted' : 'onBeforeLoadDenied'
308
+ });
309
+ };
310
+ if (resolvedManifest.afterLoadSteps.length > 0) script.onLoad = (info)=>{
311
+ const baseContext = {
312
+ scriptId: resolvedManifest.vendor,
313
+ elementId: info.elementId,
314
+ hasConsent: info.hasConsent,
315
+ callback: 'onLoad'
316
+ };
317
+ executePhaseSteps(resolvedManifest.afterLoadSteps, {
318
+ ...baseContext,
319
+ phase: 'afterLoad'
320
+ });
321
+ if (info.hasConsent && resolvedManifest.onLoadGrantedSteps.length > 0) executePhaseSteps(resolvedManifest.onLoadGrantedSteps, {
322
+ ...baseContext,
323
+ phase: 'onLoadGranted'
324
+ });
325
+ else if (!info.hasConsent && resolvedManifest.onLoadDeniedSteps.length > 0) executePhaseSteps(resolvedManifest.onLoadDeniedSteps, {
326
+ ...baseContext,
327
+ phase: 'onLoadDenied'
328
+ });
329
+ };
330
+ else if (hasLoadConsentBranches) script.onLoad = (info)=>{
331
+ const baseContext = {
332
+ scriptId: resolvedManifest.vendor,
333
+ elementId: info.elementId,
334
+ hasConsent: info.hasConsent,
335
+ callback: 'onLoad'
336
+ };
337
+ if (info.hasConsent && resolvedManifest.onLoadGrantedSteps.length > 0) executePhaseSteps(resolvedManifest.onLoadGrantedSteps, {
338
+ ...baseContext,
339
+ phase: 'onLoadGranted'
340
+ });
341
+ else if (!info.hasConsent && resolvedManifest.onLoadDeniedSteps.length > 0) executePhaseSteps(resolvedManifest.onLoadDeniedSteps, {
342
+ ...baseContext,
343
+ phase: 'onLoadDenied'
344
+ });
345
+ };
346
+ if (hasConsentLifecycle) script.onConsentChange = (info)=>{
347
+ const baseContext = {
348
+ scriptId: resolvedManifest.vendor,
349
+ elementId: info.elementId,
350
+ hasConsent: info.hasConsent,
351
+ callback: 'onConsentChange'
352
+ };
353
+ executePhaseSteps(getConsentSignalSteps(resolvedManifest, 'update', info.consents), {
354
+ ...baseContext,
355
+ phase: 'consent-update'
356
+ });
357
+ if (resolvedManifest.onConsentChangeSteps.length > 0) executePhaseSteps(resolvedManifest.onConsentChangeSteps, {
358
+ ...baseContext,
359
+ phase: 'onConsentChange'
360
+ });
361
+ if (info.hasConsent && resolvedManifest.onConsentGrantedSteps.length > 0) executePhaseSteps(resolvedManifest.onConsentGrantedSteps, {
362
+ ...baseContext,
363
+ phase: 'onConsentGranted'
364
+ });
365
+ else if (!info.hasConsent && resolvedManifest.onConsentDeniedSteps.length > 0) executePhaseSteps(resolvedManifest.onConsentDeniedSteps, {
366
+ ...baseContext,
367
+ phase: 'onConsentDenied'
368
+ });
369
+ };
370
+ return script;
371
+ }
372
+ exports.resolvedManifestToScript = __webpack_exports__.resolvedManifestToScript;
373
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
374
+ "resolvedManifestToScript"
375
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
376
+ Object.defineProperty(exports, '__esModule', {
377
+ value: true
378
+ });