@c15t/scripts 3.0.0-alpha.2 → 3.0.0-alpha.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/AGENTS.md +129 -63
- package/README.md +8 -29
- package/SKILL.md +33 -0
- package/dist/adobe-analytics.js +2 -0
- package/dist/ahrefs-analytics.js +2 -0
- package/dist/amplitude.js +2 -0
- package/dist/clearbit.js +2 -0
- package/dist/cloudflare-web-analytics.js +2 -0
- package/dist/cloudflare-zaraz.js +2 -0
- package/dist/crisp.js +2 -0
- package/dist/databuddy.js +2 -0
- package/dist/e2e-test-utils.js +2 -139
- package/dist/engine/compile.js +2 -89
- package/dist/engine/runtime.js +2 -448
- package/dist/events.js +2 -218
- package/dist/fathom-analytics.js +2 -0
- package/dist/front-chat.js +2 -0
- package/dist/google-tag-manager.js +2 -0
- package/dist/google-tag.js +2 -0
- package/dist/heap.js +2 -0
- package/dist/hightouch.js +2 -0
- package/dist/hotjar.js +2 -0
- package/dist/intercom.js +2 -0
- package/dist/klaviyo.js +2 -0
- package/dist/linkedin-insights.js +2 -0
- package/dist/logrocket.js +2 -0
- package/dist/matomo-analytics.js +2 -0
- package/dist/meta-pixel.js +2 -0
- package/dist/microsoft-clarity.js +2 -0
- package/dist/microsoft-uet.js +2 -0
- package/dist/mixpanel-analytics.js +2 -0
- package/dist/one-dollar-stats.js +2 -0
- package/dist/openai-pixel.js +2 -0
- package/dist/pinterest-tag.js +2 -0
- package/dist/pirsch.js +2 -0
- package/dist/plausible-analytics.js +2 -0
- package/dist/posthog.js +2 -0
- package/dist/promptwatch.js +2 -0
- package/dist/reddit-pixel.js +2 -0
- package/dist/registry.js +2 -422
- package/dist/resolve.js +2 -33
- package/dist/rudderstack.js +2 -0
- package/dist/rybbit-analytics.js +2 -0
- package/dist/segment.js +2 -0
- package/dist/snapchat-pixel.js +2 -0
- package/dist/tiktok-pixel.js +2 -0
- package/dist/types.js +2 -16
- package/dist/umami-analytics.js +2 -0
- package/dist/vendors/_shared/attributes.js +2 -14
- package/dist/vendors/_shared/google-consent.js +2 -27
- package/dist/vendors/_shared/install-builders.js +2 -21
- package/dist/vendors/_shared/required-id.js +2 -0
- package/dist/vendors/_shared/script-url.js +2 -28
- package/dist/vendors/ads-and-pixels/linkedin-insights.js +2 -48
- package/dist/vendors/ads-and-pixels/meta-pixel.js +2 -153
- package/dist/vendors/ads-and-pixels/microsoft-uet.js +2 -110
- package/dist/vendors/ads-and-pixels/openai-pixel.js +2 -88
- package/dist/vendors/ads-and-pixels/pinterest-tag.js +2 -123
- package/dist/vendors/ads-and-pixels/reddit-pixel.js +2 -107
- package/dist/vendors/ads-and-pixels/snapchat-pixel.js +2 -87
- package/dist/vendors/ads-and-pixels/tiktok-pixel.js +2 -89
- package/dist/vendors/ads-and-pixels/x-pixel.js +2 -48
- package/dist/vendors/analytics/adobe-analytics.js +2 -49
- package/dist/vendors/analytics/ahrefs-analytics.js +2 -27
- package/dist/vendors/analytics/amplitude.js +2 -134
- package/dist/vendors/analytics/clearbit.js +2 -28
- package/dist/vendors/analytics/cloudflare-web-analytics.js +2 -32
- package/dist/vendors/analytics/databuddy.js +2 -103
- package/dist/vendors/analytics/fathom-analytics.js +2 -35
- package/dist/vendors/analytics/google-tag.js +2 -78
- package/dist/vendors/analytics/heap.js +2 -134
- package/dist/vendors/analytics/hightouch.js +2 -109
- package/dist/vendors/analytics/hotjar.js +2 -44
- package/dist/vendors/analytics/logrocket.js +2 -58
- package/dist/vendors/analytics/matomo-analytics.js +2 -191
- package/dist/vendors/analytics/microsoft-clarity.js +2 -100
- package/dist/vendors/analytics/mixpanel-analytics.js +2 -93
- package/dist/vendors/analytics/one-dollar-stats.js +2 -30
- package/dist/vendors/analytics/pirsch.js +2 -67
- package/dist/vendors/analytics/plausible-analytics.js +2 -81
- package/dist/vendors/analytics/posthog.js +2 -200
- package/dist/vendors/analytics/promptwatch.js +2 -29
- package/dist/vendors/analytics/rudderstack.js +2 -183
- package/dist/vendors/analytics/rybbit-analytics.js +2 -63
- package/dist/vendors/analytics/segment.js +2 -65
- package/dist/vendors/analytics/umami-analytics.js +2 -39
- package/dist/vendors/analytics/vercel-analytics.js +2 -53
- package/dist/vendors/email-and-sms/klaviyo.js +2 -0
- package/dist/vendors/functional/crisp.js +2 -100
- package/dist/vendors/functional/front-chat.js +2 -64
- package/dist/vendors/functional/intercom.js +2 -45
- package/dist/vendors/tag-managers/cloudflare-zaraz.js +2 -98
- package/dist/vendors/tag-managers/google-tag-manager.js +2 -73
- package/dist/vercel-analytics.js +2 -0
- package/dist/x-pixel.js +2 -0
- package/dist-types/adobe-analytics.d.ts +2 -0
- package/dist-types/ahrefs-analytics.d.ts +2 -0
- package/dist-types/amplitude.d.ts +2 -0
- package/dist-types/clearbit.d.ts +2 -0
- package/dist-types/cloudflare-web-analytics.d.ts +2 -0
- package/dist-types/cloudflare-zaraz.d.ts +2 -0
- package/dist-types/crisp.d.ts +2 -0
- package/dist-types/databuddy.d.ts +2 -0
- package/dist-types/e2e-test-utils.d.ts +2 -0
- package/dist-types/engine/compile.d.ts +2 -3
- package/dist-types/engine/runtime.d.ts +2 -3
- package/dist-types/events.d.ts +2 -46
- package/dist-types/fathom-analytics.d.ts +2 -0
- package/dist-types/front-chat.d.ts +2 -0
- package/dist-types/google-tag-manager.d.ts +2 -0
- package/dist-types/google-tag.d.ts +2 -0
- package/dist-types/heap.d.ts +2 -0
- package/dist-types/hightouch.d.ts +2 -0
- package/dist-types/hotjar.d.ts +2 -0
- package/dist-types/intercom.d.ts +2 -0
- package/dist-types/klaviyo.d.ts +2 -0
- package/dist-types/linkedin-insights.d.ts +2 -0
- package/dist-types/logrocket.d.ts +2 -0
- package/dist-types/matomo-analytics.d.ts +2 -0
- package/dist-types/meta-pixel.d.ts +2 -0
- package/dist-types/microsoft-clarity.d.ts +2 -0
- package/dist-types/microsoft-uet.d.ts +2 -0
- package/dist-types/mixpanel-analytics.d.ts +2 -0
- package/dist-types/one-dollar-stats.d.ts +2 -0
- package/dist-types/openai-pixel.d.ts +2 -0
- package/dist-types/pinterest-tag.d.ts +2 -0
- package/dist-types/pirsch.d.ts +2 -0
- package/dist-types/plausible-analytics.d.ts +2 -0
- package/dist-types/posthog.d.ts +2 -0
- package/dist-types/promptwatch.d.ts +2 -0
- package/dist-types/reddit-pixel.d.ts +2 -0
- package/dist-types/registry.d.ts +2 -485
- package/dist-types/resolve.d.ts +2 -9
- package/dist-types/rudderstack.d.ts +2 -0
- package/dist-types/rybbit-analytics.d.ts +2 -0
- package/dist-types/segment.d.ts +2 -0
- package/dist-types/snapchat-pixel.d.ts +2 -0
- package/dist-types/tiktok-pixel.d.ts +2 -0
- package/dist-types/types.d.ts +2 -314
- package/dist-types/umami-analytics.d.ts +2 -0
- package/dist-types/vendors/_shared/attributes.d.ts +2 -35
- package/dist-types/vendors/_shared/google-consent.d.ts +2 -47
- package/dist-types/vendors/_shared/install-builders.d.ts +2 -30
- package/dist-types/vendors/_shared/required-id.d.ts +2 -0
- package/dist-types/vendors/_shared/script-url.d.ts +2 -75
- package/dist-types/vendors/ads-and-pixels/linkedin-insights.d.ts +2 -92
- package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +2 -289
- package/dist-types/vendors/ads-and-pixels/microsoft-uet.d.ts +2 -105
- package/dist-types/vendors/ads-and-pixels/openai-pixel.d.ts +2 -211
- package/dist-types/vendors/ads-and-pixels/pinterest-tag.d.ts +2 -295
- package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +2 -210
- package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +2 -171
- package/dist-types/vendors/ads-and-pixels/tiktok-pixel.d.ts +2 -106
- package/dist-types/vendors/ads-and-pixels/x-pixel.d.ts +2 -183
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +2 -75
- package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +2 -62
- package/dist-types/vendors/analytics/amplitude.d.ts +2 -234
- package/dist-types/vendors/analytics/clearbit.d.ts +2 -60
- package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +2 -67
- package/dist-types/vendors/analytics/databuddy.d.ts +2 -147
- package/dist-types/vendors/analytics/fathom-analytics.d.ts +2 -90
- package/dist-types/vendors/analytics/google-tag.d.ts +2 -95
- package/dist-types/vendors/analytics/heap.d.ts +2 -316
- package/dist-types/vendors/analytics/hightouch.d.ts +2 -285
- package/dist-types/vendors/analytics/hotjar.d.ts +2 -73
- package/dist-types/vendors/analytics/logrocket.d.ts +2 -101
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +2 -41
- package/dist-types/vendors/analytics/microsoft-clarity.d.ts +2 -97
- package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +2 -113
- package/dist-types/vendors/analytics/one-dollar-stats.d.ts +2 -39
- package/dist-types/vendors/analytics/pirsch.d.ts +2 -96
- package/dist-types/vendors/analytics/plausible-analytics.d.ts +2 -122
- package/dist-types/vendors/analytics/posthog.d.ts +2 -175
- package/dist-types/vendors/analytics/promptwatch.d.ts +2 -36
- package/dist-types/vendors/analytics/rudderstack.d.ts +2 -330
- package/dist-types/vendors/analytics/rybbit-analytics.d.ts +2 -82
- package/dist-types/vendors/analytics/segment.d.ts +2 -164
- package/dist-types/vendors/analytics/umami-analytics.d.ts +2 -93
- package/dist-types/vendors/analytics/vercel-analytics.d.ts +2 -66
- package/dist-types/vendors/email-and-sms/klaviyo.d.ts +2 -0
- package/dist-types/vendors/functional/crisp.d.ts +2 -78
- package/dist-types/vendors/functional/front-chat.d.ts +2 -62
- package/dist-types/vendors/functional/intercom.d.ts +2 -135
- package/dist-types/vendors/tag-managers/cloudflare-zaraz.d.ts +2 -39
- package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +2 -96
- package/dist-types/vercel-analytics.d.ts +2 -0
- package/dist-types/x-pixel.d.ts +2 -0
- package/docs/README.md +129 -63
- package/docs/assets/v3/bottom-bar.png +0 -0
- package/docs/assets/v3/brand-card.png +0 -0
- package/docs/assets/v3/brand-preferences.png +0 -0
- package/docs/assets/v3/choice-wall.png +0 -0
- package/docs/assets/v3/headless-bar-html.png +0 -0
- package/docs/assets/v3/headless-bar-mobile.png +0 -0
- package/docs/assets/v3/headless-bar.png +0 -0
- package/docs/assets/v3/slim-bar.png +0 -0
- package/docs/concepts/choose-your-setup.md +87 -0
- package/docs/concepts/consent-categories.md +84 -0
- package/docs/{guides → concepts}/consent-state.md +71 -101
- package/docs/{guides → concepts}/data-fetching.md +31 -27
- package/docs/concepts/how-consent-works.md +123 -0
- package/docs/concepts/policies.md +71 -0
- package/docs/customization/class-names.md +202 -0
- package/docs/customization/dark-mode.md +157 -0
- package/docs/customization/motion.md +119 -0
- package/docs/customization/overview.md +67 -34
- package/docs/customization/recipes.md +839 -49
- package/docs/customization/slots.md +216 -35
- package/docs/customization/stylesheets.md +147 -0
- package/docs/customization/tailwind.md +842 -0
- package/docs/customization/tokens.md +163 -96
- package/docs/customization/translations.md +61 -3
- package/docs/frameworks/astro/embeds.md +160 -0
- package/docs/frameworks/astro/network-blocker.md +86 -0
- package/docs/frameworks/astro/scripts.md +146 -0
- package/docs/frameworks/html/embeds.md +142 -0
- package/docs/frameworks/html/network-blocker.md +105 -0
- package/docs/frameworks/html/scripts.md +164 -0
- package/docs/frameworks/javascript/scripts.md +119 -0
- package/docs/frameworks/next/embeds.md +90 -0
- package/docs/frameworks/next/network-blocker.md +153 -0
- package/docs/frameworks/next/scripts.md +196 -0
- package/docs/frameworks/nuxt/embeds.md +81 -0
- package/docs/frameworks/nuxt/network-blocker.md +97 -0
- package/docs/frameworks/nuxt/scripts.md +89 -0
- package/docs/frameworks/react/embeds.md +89 -0
- package/docs/frameworks/react/network-blocker.md +140 -0
- package/docs/frameworks/react/scripts.md +115 -0
- package/docs/frameworks/svelte/embeds.md +96 -0
- package/docs/frameworks/svelte/network-blocker.md +141 -0
- package/docs/frameworks/svelte/scripts.md +137 -0
- package/docs/frameworks/sveltekit/embeds.md +103 -0
- package/docs/frameworks/sveltekit/network-blocker.md +149 -0
- package/docs/frameworks/sveltekit/scripts.md +141 -0
- package/docs/frameworks/tanstack-start/embeds.md +96 -0
- package/docs/frameworks/tanstack-start/network-blocker.md +145 -0
- package/docs/frameworks/tanstack-start/scripts.md +103 -0
- package/docs/frameworks/vue/embeds.md +84 -0
- package/docs/frameworks/vue/network-blocker.md +99 -0
- package/docs/frameworks/vue/scripts.md +93 -0
- package/docs/guides/banner-experiments.md +654 -0
- package/docs/guides/troubleshooting.md +120 -47
- package/docs/guides/verify-consent.md +81 -49
- package/docs/integrations/adobe-analytics.md +167 -159
- package/docs/integrations/ahrefs-analytics.md +152 -154
- package/docs/integrations/amplitude.md +162 -156
- package/docs/integrations/building-integrations.md +136 -37
- package/docs/integrations/clearbit.md +154 -154
- package/docs/integrations/cloudflare-web-analytics.md +156 -156
- package/docs/integrations/cloudflare-zaraz.md +209 -261
- package/docs/integrations/crisp.md +164 -158
- package/docs/integrations/databuddy.md +157 -173
- package/docs/integrations/fathom-analytics.md +158 -156
- package/docs/integrations/front-chat.md +167 -167
- package/docs/integrations/google-maps.md +118 -83
- package/docs/integrations/google-tag-manager.md +178 -163
- package/docs/integrations/google-tag.md +163 -160
- package/docs/integrations/heap.md +163 -155
- package/docs/integrations/hightouch.md +161 -157
- package/docs/integrations/hotjar.md +159 -155
- package/docs/integrations/intercom.md +183 -153
- package/docs/integrations/klaviyo.md +486 -0
- package/docs/integrations/linkedin-insights.md +174 -150
- package/docs/integrations/logrocket.md +160 -156
- package/docs/integrations/matomo-analytics.md +188 -178
- package/docs/integrations/meta-pixel.md +188 -150
- package/docs/integrations/microsoft-clarity.md +163 -155
- package/docs/integrations/microsoft-uet.md +148 -154
- package/docs/integrations/mixpanel-analytics.md +155 -160
- package/docs/integrations/one-dollar-stats.md +166 -165
- package/docs/integrations/openai-pixel.md +204 -301
- package/docs/integrations/overview.md +137 -80
- package/docs/integrations/pinterest-tag.md +191 -183
- package/docs/integrations/pirsch.md +169 -159
- package/docs/integrations/plausible-analytics.md +172 -158
- package/docs/integrations/posthog.md +226 -241
- package/docs/integrations/promptwatch.md +154 -154
- package/docs/integrations/reddit-pixel.md +185 -157
- package/docs/integrations/rudderstack.md +201 -186
- package/docs/integrations/rybbit-analytics.md +171 -160
- package/docs/integrations/segment.md +182 -154
- package/docs/integrations/snapchat-pixel.md +186 -156
- package/docs/integrations/tiktok-pixel.md +171 -150
- package/docs/integrations/umami-analytics.md +163 -158
- package/docs/integrations/vercel-analytics.md +166 -157
- package/docs/integrations/x-pixel.md +176 -150
- package/docs/integrations/youtube.md +121 -86
- package/docs/upgrade-v3.md +475 -467
- package/package.json +10 -257
- package/dist-types/__tests__/helpers.d.ts +0 -141
- package/docs/assets/v3/brand-bar.png +0 -0
- package/docs/assets/v3/mobile-card.png +0 -0
- package/docs/assets/v3/preferences.png +0 -0
- package/docs/frameworks/javascript/script-loader.md +0 -100
- package/docs/frameworks/next/script-loader.md +0 -216
- package/docs/frameworks/react/script-loader.md +0 -69
- package/docs/guides/deployment-modes.md +0 -75
- package/docs/guides/shared-consent-controls.md +0 -158
- package/docs/integrations/clear-on-revocation.md +0 -167
- package/docs/integrations/granular-consent.md +0 -210
package/dist/engine/compile.js
CHANGED
|
@@ -1,89 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const PLACEHOLDER_PATTERN = /\{\{(?<capture1>[A-Za-z0-9_]+)\}\}/gu;
|
|
4
|
-
const compile_getConfigValue = function(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
|
-
const compile_stringifyInterpolatedValue = function(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
|
-
const compile_interpolateString = function(template, config) {
|
|
18
|
-
const exactMatch = template.match(EXACT_PLACEHOLDER_PATTERN);
|
|
19
|
-
if (exactMatch) return compile_getConfigValue(config, exactMatch[1]);
|
|
20
|
-
return template.replace(PLACEHOLDER_PATTERN, (_match, key)=>{
|
|
21
|
-
const value = compile_getConfigValue(config, key);
|
|
22
|
-
return compile_stringifyInterpolatedValue(value, key);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
const compile_interpolateValue = function interpolateValue(value, config) {
|
|
26
|
-
if ('string' == typeof value) return compile_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
|
-
const compile_interpolateSteps = function(steps, config) {
|
|
39
|
-
if (!steps) return [];
|
|
40
|
-
return steps.map((step)=>compile_interpolateValue(step, config));
|
|
41
|
-
};
|
|
42
|
-
const compile_extractInstallArtifacts = function(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
|
-
const compile_validateManifestContract = function(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
|
-
const compile_compileManifest = function(manifest, config = {}) {
|
|
62
|
-
compile_validateManifestContract(manifest);
|
|
63
|
-
const bootstrapSteps = compile_interpolateSteps(manifest.bootstrap, config);
|
|
64
|
-
const install = compile_interpolateSteps(manifest.install, config);
|
|
65
|
-
const { loadScript, setupSteps } = compile_extractInstallArtifacts(install);
|
|
66
|
-
return {
|
|
67
|
-
afterLoadSteps: compile_interpolateSteps(manifest.afterLoad, config),
|
|
68
|
-
alwaysLoad: void 0 === manifest.alwaysLoad ? void 0 : compile_interpolateValue(manifest.alwaysLoad, config),
|
|
69
|
-
bootstrapSteps,
|
|
70
|
-
category: compile_interpolateValue(manifest.category, config),
|
|
71
|
-
consentMapping: manifest.consentMapping ? compile_interpolateValue(manifest.consentMapping, config) : void 0,
|
|
72
|
-
consentSignal: manifest.consentSignal,
|
|
73
|
-
consentSignalTarget: 'string' == typeof manifest.consentSignalTarget ? compile_interpolateValue(manifest.consentSignalTarget, config) : manifest.consentSignalTarget,
|
|
74
|
-
kind: manifest.kind,
|
|
75
|
-
loadScript,
|
|
76
|
-
onBeforeLoadDeniedSteps: compile_interpolateSteps(manifest.onBeforeLoadDenied, config),
|
|
77
|
-
onBeforeLoadGrantedSteps: compile_interpolateSteps(manifest.onBeforeLoadGranted, config),
|
|
78
|
-
onConsentChangeSteps: compile_interpolateSteps(manifest.onConsentChange, config),
|
|
79
|
-
onConsentDeniedSteps: compile_interpolateSteps(manifest.onConsentDenied, config),
|
|
80
|
-
onConsentGrantedSteps: compile_interpolateSteps(manifest.onConsentGranted, config),
|
|
81
|
-
onLoadDeniedSteps: compile_interpolateSteps(manifest.onLoadDenied, config),
|
|
82
|
-
onLoadGrantedSteps: compile_interpolateSteps(manifest.onLoadGranted, config),
|
|
83
|
-
persistAfterConsentRevoked: void 0 === manifest.persistAfterConsentRevoked ? void 0 : compile_interpolateValue(manifest.persistAfterConsentRevoked, config),
|
|
84
|
-
schemaVersion: manifest.schemaVersion,
|
|
85
|
-
setupSteps,
|
|
86
|
-
vendor: manifest.vendor
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
export { compile_compileManifest as compileManifest, compile_interpolateValue as interpolateValue };
|
|
1
|
+
/** @deprecated Use @c15t/integrations/engine/compile. Compatibility ends in v4. */
|
|
2
|
+
export * from '@c15t/integrations/engine/compile';
|
package/dist/engine/runtime.js
CHANGED
|
@@ -1,448 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const runtime_isRuntimeValue = function(value) {
|
|
4
|
-
if (null === value || 'object' != typeof value || Array.isArray(value)) return false;
|
|
5
|
-
const candidate = value;
|
|
6
|
-
return candidate.kind === RUNTIME_VALUE_KIND && ('date' === candidate.value || 'timestamp' === candidate.value);
|
|
7
|
-
};
|
|
8
|
-
const runtime_resolveRuntimeValue = function(value) {
|
|
9
|
-
if ('date' === value.value) return new Date();
|
|
10
|
-
return Date.now();
|
|
11
|
-
};
|
|
12
|
-
const runtime_cloneStepValue = function cloneStepValue(value) {
|
|
13
|
-
if (runtime_isRuntimeValue(value)) return runtime_resolveRuntimeValue(value);
|
|
14
|
-
if (value instanceof Date) return new Date(value);
|
|
15
|
-
if (Array.isArray(value)) return value.map((item)=>cloneStepValue(item));
|
|
16
|
-
if (null !== value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).map(([key, nestedValue])=>[
|
|
17
|
-
key,
|
|
18
|
-
cloneStepValue(nestedValue)
|
|
19
|
-
]));
|
|
20
|
-
return value;
|
|
21
|
-
};
|
|
22
|
-
const runtime_isRecord = function(value) {
|
|
23
|
-
return null !== value && 'object' == typeof value && !Array.isArray(value);
|
|
24
|
-
};
|
|
25
|
-
const runtime_getPathTarget = function(root, path) {
|
|
26
|
-
if (0 === path.length) return;
|
|
27
|
-
let target = root;
|
|
28
|
-
for (const segment of path.slice(0, -1)){
|
|
29
|
-
const next = target[segment];
|
|
30
|
-
if (null === next || 'object' != typeof next) return;
|
|
31
|
-
target = next;
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
key: path[path.length - 1],
|
|
35
|
-
target
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const runtime_resolveQueueTarget = function(root, queue, owner) {
|
|
39
|
-
if ('global' in queue && 'string' == typeof queue.global) {
|
|
40
|
-
const queueTarget = root[queue.global];
|
|
41
|
-
return Array.isArray(queueTarget) ? queueTarget : void 0;
|
|
42
|
-
}
|
|
43
|
-
if (!owner) return;
|
|
44
|
-
const queueProperty = queue.property;
|
|
45
|
-
const queueTarget = owner[queueProperty];
|
|
46
|
-
return Array.isArray(queueTarget) ? queueTarget : void 0;
|
|
47
|
-
};
|
|
48
|
-
const runtime_executeStep = function(step) {
|
|
49
|
-
const win = window;
|
|
50
|
-
switch(step.type){
|
|
51
|
-
case 'setGlobal':
|
|
52
|
-
{
|
|
53
|
-
const shouldSet = false !== step.ifUndefined;
|
|
54
|
-
if (shouldSet && void 0 !== win[step.name]) break;
|
|
55
|
-
win[step.name] = runtime_cloneStepValue(step.value);
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
case 'defineQueueFunction':
|
|
59
|
-
{
|
|
60
|
-
const shouldSet = false !== step.ifUndefined;
|
|
61
|
-
if (shouldSet && void 0 !== win[step.name]) break;
|
|
62
|
-
win[step.name] = function() {
|
|
63
|
-
const queueTarget = win[step.queue];
|
|
64
|
-
if (!Array.isArray(queueTarget)) return;
|
|
65
|
-
if ('array' === step.pushStyle) return void queueTarget.push(Array.from(arguments));
|
|
66
|
-
queueTarget.push(arguments);
|
|
67
|
-
};
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
case 'defineStubFunction':
|
|
71
|
-
{
|
|
72
|
-
const shouldSet = false !== step.ifUndefined;
|
|
73
|
-
if (shouldSet && void 0 !== win[step.name]) break;
|
|
74
|
-
const stub = function() {
|
|
75
|
-
const self = win[step.name];
|
|
76
|
-
const dispatcher = self && step.dispatchProperty ? self[step.dispatchProperty] : void 0;
|
|
77
|
-
const runtimeArgs = Array.from(arguments);
|
|
78
|
-
if ('function' == typeof dispatcher) return void dispatcher.apply(self, runtimeArgs);
|
|
79
|
-
const queueTarget = runtime_resolveQueueTarget(win, step.queue, self);
|
|
80
|
-
if (!queueTarget) return;
|
|
81
|
-
if ('array' === step.queueFormat) return void queueTarget.push(runtimeArgs);
|
|
82
|
-
queueTarget.push(arguments);
|
|
83
|
-
};
|
|
84
|
-
win[step.name] = stub;
|
|
85
|
-
const stubRecord = stub;
|
|
86
|
-
if ('property' in step.queue && 'string' == typeof step.queue.property) {
|
|
87
|
-
const queueProperty = step.queue.property;
|
|
88
|
-
if (void 0 === stubRecord[queueProperty]) stubRecord[queueProperty] = [];
|
|
89
|
-
}
|
|
90
|
-
for (const alias of step.aliases ?? [])win[alias] = stub;
|
|
91
|
-
for (const selfReference of step.selfReferences ?? [])stubRecord[selfReference] = stub;
|
|
92
|
-
for (const [key, value] of Object.entries(step.properties ?? {}))stubRecord[key] = runtime_cloneStepValue(value);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case 'callGlobal':
|
|
96
|
-
{
|
|
97
|
-
const target = win[step.global];
|
|
98
|
-
if (!target) break;
|
|
99
|
-
const args = (step.args ?? []).map((arg)=>runtime_cloneStepValue(arg));
|
|
100
|
-
if (step.method) {
|
|
101
|
-
const objectTarget = target;
|
|
102
|
-
const method = objectTarget[step.method];
|
|
103
|
-
if ('function' == typeof method) method.apply(objectTarget, args);
|
|
104
|
-
} else if ('function' == typeof target) target(...args);
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case 'pushToQueue':
|
|
108
|
-
{
|
|
109
|
-
const queueTarget = win[step.queue];
|
|
110
|
-
if (Array.isArray(queueTarget)) queueTarget.push(runtime_cloneStepValue(step.value));
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
case 'setGlobalPath':
|
|
114
|
-
{
|
|
115
|
-
const [rootGlobal] = step.path;
|
|
116
|
-
if (step.ifGlobalIsQueue && (!rootGlobal || !Array.isArray(win[rootGlobal]))) break;
|
|
117
|
-
const pathTarget = runtime_getPathTarget(win, step.path);
|
|
118
|
-
if (!pathTarget) break;
|
|
119
|
-
pathTarget.target[pathTarget.key] = runtime_cloneStepValue(step.value);
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case 'defineQueueMethods':
|
|
123
|
-
{
|
|
124
|
-
const target = win[step.target];
|
|
125
|
-
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
126
|
-
if (!step.queue && !Array.isArray(target)) break;
|
|
127
|
-
const targetRecord = target;
|
|
128
|
-
for (const methodName of step.methods)targetRecord[methodName] = (...args)=>{
|
|
129
|
-
const queueTarget = runtime_resolveQueueTarget(win, step.queue ?? {
|
|
130
|
-
global: step.target
|
|
131
|
-
}, targetRecord);
|
|
132
|
-
if (!queueTarget) return;
|
|
133
|
-
if ('methodCall' === step.queueFormat || 'wrappedMethodCall' === step.queueFormat || 'voidMethodCall' === step.queueFormat) {
|
|
134
|
-
const promise = new Promise((resolve)=>{
|
|
135
|
-
queueTarget.push({
|
|
136
|
-
args,
|
|
137
|
-
name: methodName,
|
|
138
|
-
resolve
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
if ('wrappedMethodCall' === step.queueFormat) return {
|
|
142
|
-
promise
|
|
143
|
-
};
|
|
144
|
-
if ('voidMethodCall' === step.queueFormat) return;
|
|
145
|
-
return promise;
|
|
146
|
-
}
|
|
147
|
-
if ('callback' === step.queueFormat) return void queueTarget.push({
|
|
148
|
-
fn: ()=>{
|
|
149
|
-
const latestTarget = win[step.target];
|
|
150
|
-
if (null === latestTarget || 'object' != typeof latestTarget && 'function' != typeof latestTarget) return;
|
|
151
|
-
const method = latestTarget[methodName];
|
|
152
|
-
if ('function' == typeof method) method.apply(latestTarget, args);
|
|
153
|
-
},
|
|
154
|
-
name: methodName
|
|
155
|
-
});
|
|
156
|
-
queueTarget.push([
|
|
157
|
-
methodName,
|
|
158
|
-
...args
|
|
159
|
-
]);
|
|
160
|
-
};
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
case 'defineQueueClass':
|
|
164
|
-
{
|
|
165
|
-
const target = win[step.target];
|
|
166
|
-
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
167
|
-
const queueProperty = step.queueProperty ?? '_q';
|
|
168
|
-
const QueueClass = function() {
|
|
169
|
-
this[queueProperty] = [];
|
|
170
|
-
};
|
|
171
|
-
const prototype = QueueClass.prototype;
|
|
172
|
-
for (const methodName of step.methods)prototype[methodName] = function(...args) {
|
|
173
|
-
const queueTarget = this[queueProperty];
|
|
174
|
-
if (Array.isArray(queueTarget)) queueTarget.push({
|
|
175
|
-
args,
|
|
176
|
-
name: methodName
|
|
177
|
-
});
|
|
178
|
-
return this;
|
|
179
|
-
};
|
|
180
|
-
target[step.name] = QueueClass;
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
case 'defineGlobalMethods':
|
|
184
|
-
{
|
|
185
|
-
const target = win[step.target];
|
|
186
|
-
if (null === target || 'object' != typeof target && 'function' != typeof target) break;
|
|
187
|
-
if (step.ifGlobalIsQueue && !Array.isArray(target)) break;
|
|
188
|
-
const targetRecord = target;
|
|
189
|
-
for (const method of step.methods)targetRecord[method.name] = 'return' === method.behavior ? ()=>runtime_cloneStepValue(method.value) : ()=>{};
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case 'constructGlobal':
|
|
193
|
-
{
|
|
194
|
-
const Constructor = win[step.constructor];
|
|
195
|
-
if ('function' != typeof Constructor) break;
|
|
196
|
-
const args = (step.args ?? []).map((arg)=>runtime_cloneStepValue(arg));
|
|
197
|
-
if (step.copyAssignedValueToArgProperty) {
|
|
198
|
-
const firstArg = args[0];
|
|
199
|
-
const targetOptions = runtime_isRecord(firstArg) ? firstArg : {};
|
|
200
|
-
targetOptions[step.copyAssignedValueToArgProperty] = win[step.assignTo];
|
|
201
|
-
if (!runtime_isRecord(firstArg)) args.unshift(targetOptions);
|
|
202
|
-
}
|
|
203
|
-
win[step.assignTo] = new Constructor(...args);
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
case 'loadScript':
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
const runtime_executePhaseSteps = function(steps, context) {
|
|
211
|
-
if (0 === steps.length) return;
|
|
212
|
-
emitScriptDebugEvent({
|
|
213
|
-
action: 'phase_start',
|
|
214
|
-
callback: context.callback,
|
|
215
|
-
data: {
|
|
216
|
-
stepCount: steps.length
|
|
217
|
-
},
|
|
218
|
-
elementId: context.elementId,
|
|
219
|
-
hasConsent: context.hasConsent,
|
|
220
|
-
message: `Manifest phase ${context.phase} started`,
|
|
221
|
-
phase: context.phase,
|
|
222
|
-
scope: 'phase',
|
|
223
|
-
scriptId: context.scriptId,
|
|
224
|
-
source: 'manifest-runtime'
|
|
225
|
-
});
|
|
226
|
-
for (const [stepIndex, step] of steps.entries())try {
|
|
227
|
-
runtime_executeStep(step);
|
|
228
|
-
emitScriptDebugEvent({
|
|
229
|
-
action: 'step_executed',
|
|
230
|
-
callback: context.callback,
|
|
231
|
-
elementId: context.elementId,
|
|
232
|
-
hasConsent: context.hasConsent,
|
|
233
|
-
message: `Executed ${step.type}`,
|
|
234
|
-
phase: context.phase,
|
|
235
|
-
scope: 'step',
|
|
236
|
-
scriptId: context.scriptId,
|
|
237
|
-
source: 'manifest-runtime',
|
|
238
|
-
stepIndex,
|
|
239
|
-
stepType: step.type
|
|
240
|
-
});
|
|
241
|
-
} catch (error) {
|
|
242
|
-
emitScriptDebugEvent({
|
|
243
|
-
action: 'step_error',
|
|
244
|
-
callback: context.callback,
|
|
245
|
-
data: {
|
|
246
|
-
error: error instanceof Error ? error.message : 'string' == typeof error ? error : 'Unknown error'
|
|
247
|
-
},
|
|
248
|
-
elementId: context.elementId,
|
|
249
|
-
hasConsent: context.hasConsent,
|
|
250
|
-
message: `Failed to execute ${step.type}`,
|
|
251
|
-
phase: context.phase,
|
|
252
|
-
scope: 'step',
|
|
253
|
-
scriptId: context.scriptId,
|
|
254
|
-
source: 'manifest-runtime',
|
|
255
|
-
stepIndex,
|
|
256
|
-
stepType: step.type
|
|
257
|
-
});
|
|
258
|
-
throw error;
|
|
259
|
-
}
|
|
260
|
-
emitScriptDebugEvent({
|
|
261
|
-
action: 'phase_complete',
|
|
262
|
-
callback: context.callback,
|
|
263
|
-
data: {
|
|
264
|
-
stepCount: steps.length
|
|
265
|
-
},
|
|
266
|
-
elementId: context.elementId,
|
|
267
|
-
hasConsent: context.hasConsent,
|
|
268
|
-
message: `Manifest phase ${context.phase} completed`,
|
|
269
|
-
phase: context.phase,
|
|
270
|
-
scope: 'phase',
|
|
271
|
-
scriptId: context.scriptId,
|
|
272
|
-
source: 'manifest-runtime'
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
const runtime_mapConsentState = function(mapping, consents) {
|
|
276
|
-
const result = {};
|
|
277
|
-
for (const [c15tCategory, vendorTypes] of Object.entries(mapping)){
|
|
278
|
-
const isGranted = consents[c15tCategory];
|
|
279
|
-
for (const vendorType of vendorTypes)result[vendorType] = isGranted ? 'granted' : 'denied';
|
|
280
|
-
}
|
|
281
|
-
return result;
|
|
282
|
-
};
|
|
283
|
-
const runtime_partitionConsentIds = function(mapping, consents) {
|
|
284
|
-
const allowedConsentIds = [];
|
|
285
|
-
const deniedConsentIds = [];
|
|
286
|
-
for (const [c15tCategory, consentIds] of Object.entries(mapping)){
|
|
287
|
-
const isGranted = consents[c15tCategory];
|
|
288
|
-
for (const consentId of consentIds)(isGranted ? allowedConsentIds : deniedConsentIds).push(consentId);
|
|
289
|
-
}
|
|
290
|
-
return {
|
|
291
|
-
allowedConsentIds,
|
|
292
|
-
deniedConsentIds
|
|
293
|
-
};
|
|
294
|
-
};
|
|
295
|
-
const ALL_DENIED = {
|
|
296
|
-
experience: false,
|
|
297
|
-
functionality: false,
|
|
298
|
-
marketing: false,
|
|
299
|
-
measurement: false,
|
|
300
|
-
necessary: true
|
|
301
|
-
};
|
|
302
|
-
const runtime_signalConsents = function(info) {
|
|
303
|
-
return info.vendor?.granted === false ? ALL_DENIED : info.consents;
|
|
304
|
-
};
|
|
305
|
-
const runtime_getConsentSignalSteps = function(resolvedManifest, mode, consents) {
|
|
306
|
-
if (!resolvedManifest.consentMapping || !resolvedManifest.consentSignal) return [];
|
|
307
|
-
switch(resolvedManifest.consentSignal){
|
|
308
|
-
case 'gtag':
|
|
309
|
-
{
|
|
310
|
-
const mapped = runtime_mapConsentState(resolvedManifest.consentMapping, consents);
|
|
311
|
-
return [
|
|
312
|
-
{
|
|
313
|
-
args: [
|
|
314
|
-
'consent',
|
|
315
|
-
mode,
|
|
316
|
-
mapped
|
|
317
|
-
],
|
|
318
|
-
global: resolvedManifest.consentSignalTarget ?? 'gtag',
|
|
319
|
-
type: 'callGlobal'
|
|
320
|
-
}
|
|
321
|
-
];
|
|
322
|
-
}
|
|
323
|
-
case 'rudderstack':
|
|
324
|
-
{
|
|
325
|
-
const partition = runtime_partitionConsentIds(resolvedManifest.consentMapping, consents);
|
|
326
|
-
return [
|
|
327
|
-
{
|
|
328
|
-
args: [
|
|
329
|
-
{
|
|
330
|
-
consentManagement: {
|
|
331
|
-
allowedConsentIds: partition.allowedConsentIds,
|
|
332
|
-
deniedConsentIds: partition.deniedConsentIds,
|
|
333
|
-
enabled: true,
|
|
334
|
-
provider: 'custom'
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
],
|
|
338
|
-
global: resolvedManifest.consentSignalTarget ?? 'rudderanalytics',
|
|
339
|
-
method: 'consent',
|
|
340
|
-
type: 'callGlobal'
|
|
341
|
-
}
|
|
342
|
-
];
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
const runtime_resolvedManifestToScript = function(resolvedManifest) {
|
|
347
|
-
const hasConsentMapping = !!(resolvedManifest.consentMapping && resolvedManifest.consentSignal);
|
|
348
|
-
const hasLoadConsentBranches = !!(resolvedManifest.onLoadGrantedSteps.length > 0 || resolvedManifest.onLoadDeniedSteps.length > 0);
|
|
349
|
-
const hasConsentLifecycle = !!(resolvedManifest.onConsentChangeSteps.length > 0 || resolvedManifest.onConsentGrantedSteps.length > 0 || resolvedManifest.onConsentDeniedSteps.length > 0 || hasConsentMapping);
|
|
350
|
-
const script = {
|
|
351
|
-
alwaysLoad: resolvedManifest.alwaysLoad,
|
|
352
|
-
async: resolvedManifest.loadScript?.async,
|
|
353
|
-
attributes: resolvedManifest.loadScript?.attributes,
|
|
354
|
-
callbackOnly: resolvedManifest.loadScript ? void 0 : true,
|
|
355
|
-
category: resolvedManifest.category,
|
|
356
|
-
defer: resolvedManifest.loadScript?.defer,
|
|
357
|
-
id: resolvedManifest.vendor,
|
|
358
|
-
persistAfterConsentRevoked: resolvedManifest.persistAfterConsentRevoked,
|
|
359
|
-
src: resolvedManifest.loadScript?.src,
|
|
360
|
-
vendor: resolvedManifest.vendor
|
|
361
|
-
};
|
|
362
|
-
if (resolvedManifest.bootstrapSteps.length > 0 || resolvedManifest.setupSteps.length > 0 || resolvedManifest.onBeforeLoadGrantedSteps.length > 0 || resolvedManifest.onBeforeLoadDeniedSteps.length > 0 || hasConsentMapping) script.onBeforeLoad = (info)=>{
|
|
363
|
-
const baseContext = {
|
|
364
|
-
callback: 'onBeforeLoad',
|
|
365
|
-
elementId: info.elementId,
|
|
366
|
-
hasConsent: info.hasConsent,
|
|
367
|
-
scriptId: resolvedManifest.vendor
|
|
368
|
-
};
|
|
369
|
-
runtime_executePhaseSteps(resolvedManifest.bootstrapSteps, {
|
|
370
|
-
...baseContext,
|
|
371
|
-
phase: 'bootstrap'
|
|
372
|
-
});
|
|
373
|
-
runtime_executePhaseSteps(runtime_getConsentSignalSteps(resolvedManifest, 'default', runtime_signalConsents(info)), {
|
|
374
|
-
...baseContext,
|
|
375
|
-
phase: 'consent-default'
|
|
376
|
-
});
|
|
377
|
-
runtime_executePhaseSteps(resolvedManifest.setupSteps, {
|
|
378
|
-
...baseContext,
|
|
379
|
-
phase: 'setup'
|
|
380
|
-
});
|
|
381
|
-
runtime_executePhaseSteps(info.hasConsent ? resolvedManifest.onBeforeLoadGrantedSteps : resolvedManifest.onBeforeLoadDeniedSteps, {
|
|
382
|
-
...baseContext,
|
|
383
|
-
phase: info.hasConsent ? 'onBeforeLoadGranted' : 'onBeforeLoadDenied'
|
|
384
|
-
});
|
|
385
|
-
};
|
|
386
|
-
if (resolvedManifest.afterLoadSteps.length > 0) script.onLoad = (info)=>{
|
|
387
|
-
const baseContext = {
|
|
388
|
-
callback: 'onLoad',
|
|
389
|
-
elementId: info.elementId,
|
|
390
|
-
hasConsent: info.hasConsent,
|
|
391
|
-
scriptId: resolvedManifest.vendor
|
|
392
|
-
};
|
|
393
|
-
runtime_executePhaseSteps(resolvedManifest.afterLoadSteps, {
|
|
394
|
-
...baseContext,
|
|
395
|
-
phase: 'afterLoad'
|
|
396
|
-
});
|
|
397
|
-
if (info.hasConsent && resolvedManifest.onLoadGrantedSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onLoadGrantedSteps, {
|
|
398
|
-
...baseContext,
|
|
399
|
-
phase: 'onLoadGranted'
|
|
400
|
-
});
|
|
401
|
-
else if (!info.hasConsent && resolvedManifest.onLoadDeniedSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onLoadDeniedSteps, {
|
|
402
|
-
...baseContext,
|
|
403
|
-
phase: 'onLoadDenied'
|
|
404
|
-
});
|
|
405
|
-
};
|
|
406
|
-
else if (hasLoadConsentBranches) script.onLoad = (info)=>{
|
|
407
|
-
const baseContext = {
|
|
408
|
-
callback: 'onLoad',
|
|
409
|
-
elementId: info.elementId,
|
|
410
|
-
hasConsent: info.hasConsent,
|
|
411
|
-
scriptId: resolvedManifest.vendor
|
|
412
|
-
};
|
|
413
|
-
if (info.hasConsent && resolvedManifest.onLoadGrantedSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onLoadGrantedSteps, {
|
|
414
|
-
...baseContext,
|
|
415
|
-
phase: 'onLoadGranted'
|
|
416
|
-
});
|
|
417
|
-
else if (!info.hasConsent && resolvedManifest.onLoadDeniedSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onLoadDeniedSteps, {
|
|
418
|
-
...baseContext,
|
|
419
|
-
phase: 'onLoadDenied'
|
|
420
|
-
});
|
|
421
|
-
};
|
|
422
|
-
if (hasConsentLifecycle) script.onConsentChange = (info)=>{
|
|
423
|
-
const baseContext = {
|
|
424
|
-
callback: 'onConsentChange',
|
|
425
|
-
elementId: info.elementId,
|
|
426
|
-
hasConsent: info.hasConsent,
|
|
427
|
-
scriptId: resolvedManifest.vendor
|
|
428
|
-
};
|
|
429
|
-
runtime_executePhaseSteps(runtime_getConsentSignalSteps(resolvedManifest, 'update', runtime_signalConsents(info)), {
|
|
430
|
-
...baseContext,
|
|
431
|
-
phase: 'consent-update'
|
|
432
|
-
});
|
|
433
|
-
if (resolvedManifest.onConsentChangeSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onConsentChangeSteps, {
|
|
434
|
-
...baseContext,
|
|
435
|
-
phase: 'onConsentChange'
|
|
436
|
-
});
|
|
437
|
-
if (info.hasConsent && resolvedManifest.onConsentGrantedSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onConsentGrantedSteps, {
|
|
438
|
-
...baseContext,
|
|
439
|
-
phase: 'onConsentGranted'
|
|
440
|
-
});
|
|
441
|
-
else if (!info.hasConsent && resolvedManifest.onConsentDeniedSteps.length > 0) runtime_executePhaseSteps(resolvedManifest.onConsentDeniedSteps, {
|
|
442
|
-
...baseContext,
|
|
443
|
-
phase: 'onConsentDenied'
|
|
444
|
-
});
|
|
445
|
-
};
|
|
446
|
-
return script;
|
|
447
|
-
};
|
|
448
|
-
export { runtime_resolvedManifestToScript as resolvedManifestToScript };
|
|
1
|
+
/** @deprecated Use @c15t/integrations/engine/runtime. Compatibility ends in v4. */
|
|
2
|
+
export * from '@c15t/integrations/engine/runtime';
|