@c15t/svelte 3.0.0-alpha.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/AGENTS.md +88 -0
- package/README.md +136 -0
- package/SKILL.md +14 -0
- package/dist/actions/focus-trap.d.ts +8 -0
- package/dist/actions/focus-trap.js +23 -0
- package/dist/actions/portal.d.ts +8 -0
- package/dist/actions/portal.js +39 -0
- package/dist/actions/scroll-lock.d.ts +8 -0
- package/dist/actions/scroll-lock.js +23 -0
- package/dist/components/action-button.svelte +119 -0
- package/dist/components/action-button.svelte.d.ts +18 -0
- package/dist/components/branding.svelte +139 -0
- package/dist/components/branding.svelte.d.ts +13 -0
- package/dist/components/consent-dev-tools.svelte +58 -0
- package/dist/components/consent-dev-tools.svelte.d.ts +4 -0
- package/dist/components/frame.svelte +95 -0
- package/dist/components/frame.svelte.d.ts +12 -0
- package/dist/components/iab-panel.svelte +542 -0
- package/dist/components/iab-panel.svelte.d.ts +16 -0
- package/dist/components/iab-prompt.svelte +304 -0
- package/dist/components/iab-prompt.svelte.d.ts +14 -0
- package/dist/components/iab-purpose-item.svelte +511 -0
- package/dist/components/iab-purpose-item.svelte.d.ts +26 -0
- package/dist/components/iab-stack-item.svelte +146 -0
- package/dist/components/iab-stack-item.svelte.d.ts +19 -0
- package/dist/components/iab-vendor-list.svelte +900 -0
- package/dist/components/iab-vendor-list.svelte.d.ts +19 -0
- package/dist/components/icons/c15-t-icon-only.svelte +27 -0
- package/dist/components/icons/c15-t-icon-only.svelte.d.ts +9 -0
- package/dist/components/icons/chevron-down-icon.svelte +30 -0
- package/dist/components/icons/chevron-down-icon.svelte.d.ts +10 -0
- package/dist/components/icons/chevron-right-icon.svelte +36 -0
- package/dist/components/icons/chevron-right-icon.svelte.d.ts +12 -0
- package/dist/components/icons/close-icon.svelte +40 -0
- package/dist/components/icons/close-icon.svelte.d.ts +10 -0
- package/dist/components/icons/consent-icon-only.svelte +36 -0
- package/dist/components/icons/consent-icon-only.svelte.d.ts +9 -0
- package/dist/components/icons/external-link-icon.svelte +30 -0
- package/dist/components/icons/external-link-icon.svelte.d.ts +8 -0
- package/dist/components/icons/globe-icon.svelte +39 -0
- package/dist/components/icons/globe-icon.svelte.d.ts +9 -0
- package/dist/components/icons/info-icon.svelte +42 -0
- package/dist/components/icons/info-icon.svelte.d.ts +9 -0
- package/dist/components/icons/inth-logo.svelte +38 -0
- package/dist/components/icons/inth-logo.svelte.d.ts +9 -0
- package/dist/components/icons/layers-icon.svelte +25 -0
- package/dist/components/icons/layers-icon.svelte.d.ts +8 -0
- package/dist/components/icons/legitimate-interest-icon.svelte +29 -0
- package/dist/components/icons/legitimate-interest-icon.svelte.d.ts +10 -0
- package/dist/components/icons/lock-icon.svelte +31 -0
- package/dist/components/icons/lock-icon.svelte.d.ts +8 -0
- package/dist/components/icons/search-icon.svelte +33 -0
- package/dist/components/icons/search-icon.svelte.d.ts +8 -0
- package/dist/components/inline-legal-links.svelte +95 -0
- package/dist/components/inline-legal-links.svelte.d.ts +10 -0
- package/dist/components/manager-provider.svelte +459 -0
- package/dist/components/manager-provider.svelte.d.ts +27 -0
- package/dist/components/overlay.svelte +79 -0
- package/dist/components/overlay.svelte.d.ts +7 -0
- package/dist/components/panel-link.svelte +33 -0
- package/dist/components/panel-link.svelte.d.ts +10 -0
- package/dist/components/panel-trigger.svelte +237 -0
- package/dist/components/panel-trigger.svelte.d.ts +16 -0
- package/dist/components/panel.svelte +258 -0
- package/dist/components/panel.svelte.d.ts +22 -0
- package/dist/components/policy-actions-renderer.svelte +79 -0
- package/dist/components/policy-actions-renderer.svelte.d.ts +19 -0
- package/dist/components/preferences.svelte +320 -0
- package/dist/components/preferences.svelte.d.ts +8 -0
- package/dist/components/prompt.svelte +514 -0
- package/dist/components/prompt.svelte.d.ts +43 -0
- package/dist/context.svelte.d.ts +125 -0
- package/dist/context.svelte.js +354 -0
- package/dist/devtools-options.d.ts +7 -0
- package/dist/devtools-options.js +1 -0
- package/dist/devtools.d.ts +9 -0
- package/dist/devtools.js +7 -0
- package/dist/headless.d.ts +10 -0
- package/dist/headless.js +7 -0
- package/dist/iab/styles.css +11 -0
- package/dist/iab-loader.d.ts +30 -0
- package/dist/iab-loader.js +33 -0
- package/dist/iab-translations.d.ts +84 -0
- package/dist/iab-translations.js +45 -0
- package/dist/iab-types.d.ts +62 -0
- package/dist/iab-types.js +43 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +21 -0
- package/dist/kit/app.d.ts +35 -0
- package/dist/kit/handle.d.ts +34 -0
- package/dist/kit/handle.js +87 -0
- package/dist/kit/index.d.ts +30 -0
- package/dist/kit/index.js +5 -0
- package/dist/kit/load-consent.d.ts +57 -0
- package/dist/kit/load-consent.js +144 -0
- package/dist/kit/routes.d.ts +46 -0
- package/dist/kit/routes.js +203 -0
- package/dist/kit/types.d.ts +56 -0
- package/dist/kit/types.js +1 -0
- package/dist/primitives/accordion/accordion-item-content.svelte +35 -0
- package/dist/primitives/accordion/accordion-item-content.svelte.d.ts +9 -0
- package/dist/primitives/accordion/accordion-item-trigger.svelte +54 -0
- package/dist/primitives/accordion/accordion-item-trigger.svelte.d.ts +10 -0
- package/dist/primitives/accordion/accordion-item.svelte +61 -0
- package/dist/primitives/accordion/accordion-item.svelte.d.ts +11 -0
- package/dist/primitives/accordion/accordion-root.svelte +61 -0
- package/dist/primitives/accordion/accordion-root.svelte.d.ts +13 -0
- package/dist/primitives/accordion/context.d.ts +18 -0
- package/dist/primitives/accordion/context.js +23 -0
- package/dist/primitives/accordion/index.d.ts +29 -0
- package/dist/primitives/accordion/index.js +11 -0
- package/dist/primitives/collapsible/collapsible-content.svelte +36 -0
- package/dist/primitives/collapsible/collapsible-content.svelte.d.ts +9 -0
- package/dist/primitives/collapsible/collapsible-indicator.svelte +29 -0
- package/dist/primitives/collapsible/collapsible-indicator.svelte.d.ts +9 -0
- package/dist/primitives/collapsible/collapsible-root.svelte +70 -0
- package/dist/primitives/collapsible/collapsible-root.svelte.d.ts +11 -0
- package/dist/primitives/collapsible/collapsible-trigger.svelte +52 -0
- package/dist/primitives/collapsible/collapsible-trigger.svelte.d.ts +10 -0
- package/dist/primitives/collapsible/context.d.ts +10 -0
- package/dist/primitives/collapsible/context.js +12 -0
- package/dist/primitives/collapsible/index.d.ts +26 -0
- package/dist/primitives/collapsible/index.js +11 -0
- package/dist/primitives/dialog/context.d.ts +14 -0
- package/dist/primitives/dialog/context.js +12 -0
- package/dist/primitives/dialog/dialog-backdrop.svelte +39 -0
- package/dist/primitives/dialog/dialog-backdrop.svelte.d.ts +7 -0
- package/dist/primitives/dialog/dialog-close-trigger.svelte +48 -0
- package/dist/primitives/dialog/dialog-close-trigger.svelte.d.ts +11 -0
- package/dist/primitives/dialog/dialog-content.svelte +81 -0
- package/dist/primitives/dialog/dialog-content.svelte.d.ts +9 -0
- package/dist/primitives/dialog/dialog-description.svelte +28 -0
- package/dist/primitives/dialog/dialog-description.svelte.d.ts +9 -0
- package/dist/primitives/dialog/dialog-positioner.svelte +33 -0
- package/dist/primitives/dialog/dialog-positioner.svelte.d.ts +9 -0
- package/dist/primitives/dialog/dialog-root.svelte +117 -0
- package/dist/primitives/dialog/dialog-root.svelte.d.ts +14 -0
- package/dist/primitives/dialog/dialog-title.svelte +28 -0
- package/dist/primitives/dialog/dialog-title.svelte.d.ts +9 -0
- package/dist/primitives/dialog/index.d.ts +50 -0
- package/dist/primitives/dialog/index.js +19 -0
- package/dist/primitives/index.d.ts +7 -0
- package/dist/primitives/index.js +7 -0
- package/dist/primitives/portal/index.d.ts +4 -0
- package/dist/primitives/portal/index.js +2 -0
- package/dist/primitives/portal/portal.svelte +23 -0
- package/dist/primitives/portal/portal.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/context.d.ts +11 -0
- package/dist/primitives/preference-item/context.js +12 -0
- package/dist/primitives/preference-item/index.d.ts +54 -0
- package/dist/primitives/preference-item/index.js +21 -0
- package/dist/primitives/preference-item/preference-item-auxiliary.svelte +33 -0
- package/dist/primitives/preference-item/preference-item-auxiliary.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/preference-item-content.svelte +68 -0
- package/dist/primitives/preference-item/preference-item-content.svelte.d.ts +14 -0
- package/dist/primitives/preference-item/preference-item-control.svelte +33 -0
- package/dist/primitives/preference-item/preference-item-control.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/preference-item-header.svelte +33 -0
- package/dist/primitives/preference-item/preference-item-header.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/preference-item-leading.svelte +33 -0
- package/dist/primitives/preference-item/preference-item-leading.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/preference-item-meta.svelte +33 -0
- package/dist/primitives/preference-item/preference-item-meta.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/preference-item-root.svelte +82 -0
- package/dist/primitives/preference-item/preference-item-root.svelte.d.ts +12 -0
- package/dist/primitives/preference-item/preference-item-title.svelte +33 -0
- package/dist/primitives/preference-item/preference-item-title.svelte.d.ts +9 -0
- package/dist/primitives/preference-item/preference-item-trigger.svelte +62 -0
- package/dist/primitives/preference-item/preference-item-trigger.svelte.d.ts +10 -0
- package/dist/primitives/switch/context.d.ts +7 -0
- package/dist/primitives/switch/context.js +12 -0
- package/dist/primitives/switch/index.d.ts +25 -0
- package/dist/primitives/switch/index.js +11 -0
- package/dist/primitives/switch/switch-control.svelte +21 -0
- package/dist/primitives/switch/switch-control.svelte.d.ts +9 -0
- package/dist/primitives/switch/switch-hidden-input.svelte +31 -0
- package/dist/primitives/switch/switch-hidden-input.svelte.d.ts +8 -0
- package/dist/primitives/switch/switch-root.svelte +86 -0
- package/dist/primitives/switch/switch-root.svelte.d.ts +12 -0
- package/dist/primitives/switch/switch-thumb.svelte +14 -0
- package/dist/primitives/switch/switch-thumb.svelte.d.ts +7 -0
- package/dist/primitives/tabs/context.d.ts +11 -0
- package/dist/primitives/tabs/context.js +12 -0
- package/dist/primitives/tabs/index.d.ts +32 -0
- package/dist/primitives/tabs/index.js +11 -0
- package/dist/primitives/tabs/tabs-content.svelte +45 -0
- package/dist/primitives/tabs/tabs-content.svelte.d.ts +11 -0
- package/dist/primitives/tabs/tabs-list.svelte +38 -0
- package/dist/primitives/tabs/tabs-list.svelte.d.ts +10 -0
- package/dist/primitives/tabs/tabs-root.svelte +67 -0
- package/dist/primitives/tabs/tabs-root.svelte.d.ts +14 -0
- package/dist/primitives/tabs/tabs-trigger.svelte +108 -0
- package/dist/primitives/tabs/tabs-trigger.svelte.d.ts +11 -0
- package/dist/server/headers.d.ts +13 -0
- package/dist/server/headers.js +37 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +116 -0
- package/dist/server/normalize-url.d.ts +23 -0
- package/dist/server/normalize-url.js +46 -0
- package/dist/server/types.d.ts +25 -0
- package/dist/server/types.js +1 -0
- package/dist/styles.css +10 -0
- package/dist/transports/offline.d.ts +14 -0
- package/dist/transports/offline.js +22 -0
- package/dist/types.d.ts +70 -0
- package/dist/types.js +1 -0
- package/dist/use-banner-visibility.svelte.d.ts +25 -0
- package/dist/use-banner-visibility.svelte.js +108 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.js +32 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/docs/README.md +88 -0
- package/docs/assets/v3/brand-bar.png +0 -0
- package/docs/assets/v3/brand-card.png +0 -0
- package/docs/assets/v3/choice-wall.png +0 -0
- package/docs/assets/v3/mobile-card.png +0 -0
- package/docs/assets/v3/preferences.png +0 -0
- package/docs/customization/overview.md +45 -0
- package/docs/customization/recipes.md +79 -0
- package/docs/customization/slots.md +55 -0
- package/docs/customization/tokens.md +76 -0
- package/docs/customization/translations.md +49 -0
- package/docs/frameworks/svelte/quickstart.md +133 -0
- package/docs/frameworks/sveltekit/quickstart.md +144 -0
- package/docs/guides/consent-state.md +60 -0
- package/docs/guides/data-fetching.md +163 -0
- package/docs/guides/deployment-modes.md +63 -0
- package/docs/guides/troubleshooting.md +68 -0
- package/docs/guides/verify-consent.md +62 -0
- package/docs/integrations/adobe-analytics.md +294 -0
- package/docs/integrations/ahrefs-analytics.md +291 -0
- package/docs/integrations/amplitude.md +292 -0
- package/docs/integrations/building-integrations.md +47 -0
- package/docs/integrations/clearbit.md +291 -0
- package/docs/integrations/cloudflare-web-analytics.md +292 -0
- package/docs/integrations/crisp.md +294 -0
- package/docs/integrations/databuddy.md +311 -0
- package/docs/integrations/fathom-analytics.md +293 -0
- package/docs/integrations/google-maps.md +384 -0
- package/docs/integrations/google-tag-manager.md +306 -0
- package/docs/integrations/google-tag.md +305 -0
- package/docs/integrations/heap.md +292 -0
- package/docs/integrations/hightouch.md +293 -0
- package/docs/integrations/hotjar.md +292 -0
- package/docs/integrations/intercom.md +285 -0
- package/docs/integrations/linkedin-insights.md +291 -0
- package/docs/integrations/logrocket.md +293 -0
- package/docs/integrations/matomo-analytics.md +316 -0
- package/docs/integrations/meta-pixel.md +285 -0
- package/docs/integrations/microsoft-clarity.md +292 -0
- package/docs/integrations/microsoft-uet.md +291 -0
- package/docs/integrations/mixpanel-analytics.md +295 -0
- package/docs/integrations/openai-pixel.md +441 -0
- package/docs/integrations/overview.md +111 -0
- package/docs/integrations/pirsch.md +295 -0
- package/docs/integrations/plausible-analytics.md +295 -0
- package/docs/integrations/posthog.md +397 -0
- package/docs/integrations/promptwatch.md +291 -0
- package/docs/integrations/reddit-pixel.md +294 -0
- package/docs/integrations/rudderstack.md +328 -0
- package/docs/integrations/rybbit-analytics.md +296 -0
- package/docs/integrations/segment.md +292 -0
- package/docs/integrations/snapchat-pixel.md +293 -0
- package/docs/integrations/tiktok-pixel.md +291 -0
- package/docs/integrations/umami-analytics.md +295 -0
- package/docs/integrations/vercel-analytics.md +293 -0
- package/docs/integrations/x-pixel.md +291 -0
- package/docs/integrations/youtube.md +405 -0
- package/docs/upgrade-v3.md +334 -0
- package/iab/styles.css +1 -0
- package/package.json +153 -0
- package/readme.json +36 -0
- package/styles.css +1 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { allConsentNames, consentTypes as defaultConsentTypes, defaultTranslationConfig, has as evaluateHas, resolveConsentPresentation, } from '@c15t/core';
|
|
2
|
+
import { getContext, setContext } from 'svelte';
|
|
3
|
+
const CONSENT_CONTEXT_KEY = Symbol('c15t-v3-consent');
|
|
4
|
+
const THEME_CONTEXT_KEY = Symbol('c15t-v3-theme');
|
|
5
|
+
const toTranslationConfig = function toTranslationConfig(snapshot) {
|
|
6
|
+
const resolved = snapshot.translations;
|
|
7
|
+
if (!resolved) {
|
|
8
|
+
return defaultTranslationConfig;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
...defaultTranslationConfig,
|
|
12
|
+
defaultLanguage: resolved.language,
|
|
13
|
+
translations: {
|
|
14
|
+
...defaultTranslationConfig.translations,
|
|
15
|
+
[resolved.language]: resolved.translations,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const toActiveUI = function toActiveUI(ui) {
|
|
20
|
+
return (ui ?? 'none');
|
|
21
|
+
};
|
|
22
|
+
const displayedConsentTypes = function displayedConsentTypes(categories) {
|
|
23
|
+
const allowed = categories.length > 0
|
|
24
|
+
? new Set(categories)
|
|
25
|
+
: new Set(allConsentNames);
|
|
26
|
+
return defaultConsentTypes
|
|
27
|
+
.filter((type) => allowed.has(type.name))
|
|
28
|
+
.map((type) => ({ ...type, display: true }));
|
|
29
|
+
};
|
|
30
|
+
const createConsentState = function createConsentState(kernel, options) {
|
|
31
|
+
const getSnapshotLocal = options.getSnapshot;
|
|
32
|
+
let actionSequence = 0;
|
|
33
|
+
// oxlint-disable-next-line sort-keys -- Preserve declaration order, interface shape, and public compatibility.
|
|
34
|
+
const controller = {
|
|
35
|
+
get activeUI() {
|
|
36
|
+
return toActiveUI(getSnapshotLocal().activeUI);
|
|
37
|
+
},
|
|
38
|
+
get branding() {
|
|
39
|
+
return getSnapshotLocal().branding ?? 'c15t';
|
|
40
|
+
},
|
|
41
|
+
get consentCategories() {
|
|
42
|
+
const configured = options.getConsentCategories();
|
|
43
|
+
const { scope } = getSnapshotLocal().policyRule;
|
|
44
|
+
return [
|
|
45
|
+
...new Set([
|
|
46
|
+
'necessary',
|
|
47
|
+
...(configured.length === 0
|
|
48
|
+
? scope
|
|
49
|
+
: configured.filter((name) => scope.some((category) => category === name))),
|
|
50
|
+
]),
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
get draft() {
|
|
54
|
+
return options.getDraft();
|
|
55
|
+
},
|
|
56
|
+
get presentation() {
|
|
57
|
+
return options.getPresentation();
|
|
58
|
+
},
|
|
59
|
+
// -- Controller-owned state (computed from snapshot + provider options) --
|
|
60
|
+
get consentTypes() {
|
|
61
|
+
return displayedConsentTypes(controller.consentCategories);
|
|
62
|
+
},
|
|
63
|
+
// -- Methods --------------------------------------------------------------
|
|
64
|
+
getDisplayedConsents() {
|
|
65
|
+
return displayedConsentTypes(controller.consentCategories);
|
|
66
|
+
},
|
|
67
|
+
has(condition) {
|
|
68
|
+
const snapshot = getSnapshotLocal();
|
|
69
|
+
return evaluateHas(condition, snapshot.effectivePermissions);
|
|
70
|
+
},
|
|
71
|
+
dismissNotice() {
|
|
72
|
+
return kernel.commands.dismissNotice();
|
|
73
|
+
},
|
|
74
|
+
get iab() {
|
|
75
|
+
return options.getIAB();
|
|
76
|
+
},
|
|
77
|
+
get legalLinks() {
|
|
78
|
+
return options.getLegalLinks();
|
|
79
|
+
},
|
|
80
|
+
get location() {
|
|
81
|
+
return getSnapshotLocal().location;
|
|
82
|
+
},
|
|
83
|
+
get manager() {
|
|
84
|
+
return null;
|
|
85
|
+
},
|
|
86
|
+
get model() {
|
|
87
|
+
return getSnapshotLocal().iab?.enabled
|
|
88
|
+
? 'iab'
|
|
89
|
+
: getSnapshotLocal().policyRule.model;
|
|
90
|
+
},
|
|
91
|
+
get hasPolicy() {
|
|
92
|
+
return getSnapshotLocal().resolution.status === 'matched';
|
|
93
|
+
},
|
|
94
|
+
get hasConsentUi() {
|
|
95
|
+
const snapshot = getSnapshotLocal();
|
|
96
|
+
return (snapshot.resolution.status === 'matched' &&
|
|
97
|
+
(snapshot.policyRule.prompt !== 'none' ||
|
|
98
|
+
snapshot.policyRule.rights.length > 0));
|
|
99
|
+
},
|
|
100
|
+
// -- Snapshot passthrough (was previously served by a Proxy) -------------
|
|
101
|
+
get explicitChoice() {
|
|
102
|
+
return getSnapshotLocal().explicitChoice;
|
|
103
|
+
},
|
|
104
|
+
get effectivePermissions() {
|
|
105
|
+
return getSnapshotLocal().effectivePermissions;
|
|
106
|
+
},
|
|
107
|
+
get promptRequirement() {
|
|
108
|
+
return getSnapshotLocal().promptRequirement;
|
|
109
|
+
},
|
|
110
|
+
get noticeDismissal() {
|
|
111
|
+
return getSnapshotLocal().noticeDismissal;
|
|
112
|
+
},
|
|
113
|
+
get privacySignals() {
|
|
114
|
+
return getSnapshotLocal().privacySignals;
|
|
115
|
+
},
|
|
116
|
+
get optOutDirectives() {
|
|
117
|
+
return getSnapshotLocal().optOutDirectives;
|
|
118
|
+
},
|
|
119
|
+
get resolution() {
|
|
120
|
+
return getSnapshotLocal().resolution;
|
|
121
|
+
},
|
|
122
|
+
get policyRule() {
|
|
123
|
+
return getSnapshotLocal().policyRule;
|
|
124
|
+
},
|
|
125
|
+
get restrictions() {
|
|
126
|
+
return getSnapshotLocal().restrictions;
|
|
127
|
+
},
|
|
128
|
+
get nextDeadline() {
|
|
129
|
+
return getSnapshotLocal().nextDeadline;
|
|
130
|
+
},
|
|
131
|
+
get subject() {
|
|
132
|
+
return getSnapshotLocal().subject;
|
|
133
|
+
},
|
|
134
|
+
get evaluatedAt() {
|
|
135
|
+
return getSnapshotLocal().evaluatedAt;
|
|
136
|
+
},
|
|
137
|
+
get evaluationPolicy() {
|
|
138
|
+
return getSnapshotLocal().evaluationPolicy;
|
|
139
|
+
},
|
|
140
|
+
get overrides() {
|
|
141
|
+
return getSnapshotLocal().overrides;
|
|
142
|
+
},
|
|
143
|
+
get policyPending() {
|
|
144
|
+
return getSnapshotLocal().policyPending;
|
|
145
|
+
},
|
|
146
|
+
get revision() {
|
|
147
|
+
return getSnapshotLocal().revision;
|
|
148
|
+
},
|
|
149
|
+
async saveConsents(type) {
|
|
150
|
+
actionSequence += 1;
|
|
151
|
+
const sequence = actionSequence;
|
|
152
|
+
const preserveDialog = kernel.getSnapshot().activeUI === 'dialog';
|
|
153
|
+
const save = async () => {
|
|
154
|
+
if (type === 'custom') {
|
|
155
|
+
await options.getDraft().save(controller.consentCategories);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const result = await kernel.commands.save(type === 'all' ? 'all' : 'none', {
|
|
159
|
+
categories: controller.consentCategories,
|
|
160
|
+
});
|
|
161
|
+
if (!result.ok) {
|
|
162
|
+
throw new Error('Unable to save preferences.');
|
|
163
|
+
}
|
|
164
|
+
if (sequence === actionSequence) {
|
|
165
|
+
options.getDraft().reset();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
// The local receipt commits synchronously, before the transport settles.
|
|
169
|
+
// Restore the open dialog now so loading and failure never hide its draft.
|
|
170
|
+
const pending = save();
|
|
171
|
+
if (preserveDialog && sequence === actionSequence) {
|
|
172
|
+
kernel.set.activeUI('dialog');
|
|
173
|
+
}
|
|
174
|
+
const unsubscribe = kernel.subscribe((next) => {
|
|
175
|
+
if (preserveDialog &&
|
|
176
|
+
next.activeUI !== 'dialog' &&
|
|
177
|
+
sequence === actionSequence) {
|
|
178
|
+
actionSequence += 1;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
try {
|
|
182
|
+
await pending;
|
|
183
|
+
if (sequence !== actionSequence || !preserveDialog) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const current = kernel.getSnapshot();
|
|
187
|
+
kernel.set.activeUI(current.policyPending ||
|
|
188
|
+
current.resolution.status === 'failed' ||
|
|
189
|
+
current.promptRequirement.kind === 'none'
|
|
190
|
+
? 'none'
|
|
191
|
+
: 'banner');
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
unsubscribe();
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
get selectedConsents() {
|
|
198
|
+
return options.getDraft().values;
|
|
199
|
+
},
|
|
200
|
+
get selectedConsentTypes() {
|
|
201
|
+
return options.getDraft().values;
|
|
202
|
+
},
|
|
203
|
+
setActiveUI(ui) {
|
|
204
|
+
actionSequence += 1;
|
|
205
|
+
kernel.set.activeUI(ui);
|
|
206
|
+
},
|
|
207
|
+
setConsent(name, value) {
|
|
208
|
+
options.getDraft().set(name, value);
|
|
209
|
+
},
|
|
210
|
+
setLanguage(code) {
|
|
211
|
+
kernel.set.language(code);
|
|
212
|
+
void kernel.commands.init();
|
|
213
|
+
},
|
|
214
|
+
setSelectedConsent(name, value) {
|
|
215
|
+
options.getDraft().set(name, value);
|
|
216
|
+
},
|
|
217
|
+
subscribeToConsentChanges(listener) {
|
|
218
|
+
return kernel.subscribe((snapshot) => listener(snapshot.effectivePermissions));
|
|
219
|
+
},
|
|
220
|
+
get translationConfig() {
|
|
221
|
+
return toTranslationConfig(getSnapshotLocal());
|
|
222
|
+
},
|
|
223
|
+
get translations() {
|
|
224
|
+
return getSnapshotLocal().translations;
|
|
225
|
+
},
|
|
226
|
+
get user() {
|
|
227
|
+
return getSnapshotLocal().user;
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
return controller;
|
|
231
|
+
};
|
|
232
|
+
export const setConsentContext = function setConsentContext(kernel, options) {
|
|
233
|
+
const consentState = createConsentState(kernel, options);
|
|
234
|
+
setContext(CONSENT_CONTEXT_KEY, {
|
|
235
|
+
clearRecords: () => {
|
|
236
|
+
if (options.clearRecords) {
|
|
237
|
+
options.clearRecords();
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
kernel.hydrate({
|
|
241
|
+
choice: null,
|
|
242
|
+
noticeDismissal: null,
|
|
243
|
+
optOutDirectives: [],
|
|
244
|
+
subject: null,
|
|
245
|
+
});
|
|
246
|
+
kernel.events.emit({ type: 'records:cleared' });
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
kernel,
|
|
250
|
+
get manager() {
|
|
251
|
+
return kernel;
|
|
252
|
+
},
|
|
253
|
+
get snapshot() {
|
|
254
|
+
return options.getSnapshot();
|
|
255
|
+
},
|
|
256
|
+
get state() {
|
|
257
|
+
return consentState;
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
export const getConsentContext = function getConsentContext() {
|
|
262
|
+
const context = getContext(CONSENT_CONTEXT_KEY);
|
|
263
|
+
if (!context) {
|
|
264
|
+
throw new Error('c15t: no v3 consent context. Wrap your app with <ConsentManagerProvider options={...}> from @c15t/svelte.');
|
|
265
|
+
}
|
|
266
|
+
return context;
|
|
267
|
+
};
|
|
268
|
+
export const getConsentKernel = function getConsentKernel() {
|
|
269
|
+
return getConsentContext().kernel;
|
|
270
|
+
};
|
|
271
|
+
export const getSnapshot = function getSnapshot() {
|
|
272
|
+
return getConsentContext().snapshot;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Returns the reactive consent manager controller for the current component.
|
|
276
|
+
*
|
|
277
|
+
* Exposes both readable state (`consents`, `activeUI`, `model`, …) and
|
|
278
|
+
* mutators (`setConsent`, `saveConsents`, `setActiveUI`, `setLanguage`, …).
|
|
279
|
+
* This is the primary API for reading and writing consent from inside your
|
|
280
|
+
* own components — equivalent to React's `useConsentManager()`.
|
|
281
|
+
*
|
|
282
|
+
* Must be called inside a component tree wrapped in `<ConsentManagerProvider>`.
|
|
283
|
+
*/
|
|
284
|
+
export const getConsentManager = function getConsentManager() {
|
|
285
|
+
return getConsentContext().state;
|
|
286
|
+
};
|
|
287
|
+
const resolveHeadlessSurface = (consent, surface) => ({
|
|
288
|
+
...resolveConsentPresentation({
|
|
289
|
+
policy: consent.policyRule,
|
|
290
|
+
presentation: consent.presentation,
|
|
291
|
+
surface: surface === 'banner' ? 'prompt' : 'preferences',
|
|
292
|
+
}),
|
|
293
|
+
isVisible: consent.activeUI === surface,
|
|
294
|
+
});
|
|
295
|
+
export const getHeadlessConsent = function getHeadlessConsent() {
|
|
296
|
+
const consent = getConsentManager();
|
|
297
|
+
return {
|
|
298
|
+
get activeUI() {
|
|
299
|
+
return consent.activeUI;
|
|
300
|
+
},
|
|
301
|
+
get banner() {
|
|
302
|
+
return resolveHeadlessSurface(consent, 'banner');
|
|
303
|
+
},
|
|
304
|
+
closeUI() {
|
|
305
|
+
consent.setActiveUI('none');
|
|
306
|
+
},
|
|
307
|
+
get dialog() {
|
|
308
|
+
return resolveHeadlessSurface(consent, 'dialog');
|
|
309
|
+
},
|
|
310
|
+
openBanner() {
|
|
311
|
+
consent.setActiveUI('banner');
|
|
312
|
+
},
|
|
313
|
+
openDialog() {
|
|
314
|
+
consent.setActiveUI('dialog');
|
|
315
|
+
},
|
|
316
|
+
async performAction(action) {
|
|
317
|
+
if (action === 'dismiss') {
|
|
318
|
+
await consent.dismissNotice();
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (action === 'save') {
|
|
322
|
+
await consent.saveConsents('custom');
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (action === 'accept') {
|
|
326
|
+
await consent.saveConsents('all');
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (action === 'reject') {
|
|
330
|
+
await consent.saveConsents('necessary');
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
consent.setActiveUI('dialog');
|
|
334
|
+
},
|
|
335
|
+
async saveCustomPreferences() {
|
|
336
|
+
await consent.saveConsents('custom');
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
export const getIAB = function getIAB() {
|
|
341
|
+
return getConsentContext().state.iab;
|
|
342
|
+
};
|
|
343
|
+
export const setThemeContext = function setThemeContext(value) {
|
|
344
|
+
setContext(THEME_CONTEXT_KEY, value);
|
|
345
|
+
};
|
|
346
|
+
export const getThemeContext = function getThemeContext() {
|
|
347
|
+
return (getContext(THEME_CONTEXT_KEY) ?? {
|
|
348
|
+
colorScheme: 'system',
|
|
349
|
+
disableAnimation: false,
|
|
350
|
+
noStyle: false,
|
|
351
|
+
scrollLock: undefined,
|
|
352
|
+
trapFocus: undefined,
|
|
353
|
+
});
|
|
354
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DevToolsOptions } from '@c15t/dev-tools';
|
|
2
|
+
/** Props for the kernel-bound Svelte DevTools adapter. */
|
|
3
|
+
export type ConsentDevToolsProps = Omit<DevToolsOptions, 'container' | 'kernel'>;
|
|
4
|
+
/** Backward-compatible props name for the ConsentDevTools component. */
|
|
5
|
+
export type C15TDevToolsProps = ConsentDevToolsProps;
|
|
6
|
+
/** Compatible props name for the DevTools component alias. */
|
|
7
|
+
export type DevToolsProps = ConsentDevToolsProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ConsentDevTools from './components/consent-dev-tools.svelte';
|
|
2
|
+
/** Compatible short name for {@link ConsentDevTools}. */
|
|
3
|
+
declare const DevTools: import("svelte").Component<import("./devtools-options").ConsentDevToolsProps, {}, "">;
|
|
4
|
+
/** Backward-compatible name for {@link ConsentDevTools}. */
|
|
5
|
+
declare const C15TDevTools: import("svelte").Component<import("./devtools-options").ConsentDevToolsProps, {}, "">;
|
|
6
|
+
export { C15TDevTools, ConsentDevTools, DevTools };
|
|
7
|
+
export default ConsentDevTools;
|
|
8
|
+
export type { DevToolsInstance, DevToolsOptions, DevToolsPosition, DevToolsTab, } from '@c15t/dev-tools';
|
|
9
|
+
export type { C15TDevToolsProps, ConsentDevToolsProps, DevToolsProps, } from './devtools-options';
|
package/dist/devtools.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import ConsentDevTools from './components/consent-dev-tools.svelte';
|
|
2
|
+
/** Compatible short name for {@link ConsentDevTools}. */
|
|
3
|
+
const DevTools = ConsentDevTools;
|
|
4
|
+
/** Backward-compatible name for {@link ConsentDevTools}. */
|
|
5
|
+
const C15TDevTools = ConsentDevTools;
|
|
6
|
+
export { C15TDevTools, ConsentDevTools, DevTools };
|
|
7
|
+
export default ConsentDevTools;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { AllConsentNames } from '@c15t/core';
|
|
2
|
+
export type { ConsentState, KernelActiveUI, KernelConfig } from '@c15t/core';
|
|
3
|
+
export { focusTrap } from './actions/focus-trap';
|
|
4
|
+
export { portal } from './actions/portal';
|
|
5
|
+
export { scrollLock } from './actions/scroll-lock';
|
|
6
|
+
export { default as InlineLegalLinks } from './components/inline-legal-links.svelte';
|
|
7
|
+
export { getConsentKernel, getConsentManager, getHeadlessConsent, getIAB, getSnapshot, type HeadlessConsentSurfaceState, type SvelteIABState, } from './context.svelte';
|
|
8
|
+
export { getIABTranslations, type IABTranslations } from './iab-translations';
|
|
9
|
+
export { getIABBannerDisplayItems, type ProcessedFeature, type ProcessedGVLData, type ProcessedPurpose, type ProcessedSpecialFeature, type ProcessedStack, type ProcessedVendor, processGVLData, type VendorId, } from './iab-types';
|
|
10
|
+
export type { ConsentManagerOptions } from './types';
|
package/dist/headless.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { focusTrap } from './actions/focus-trap';
|
|
2
|
+
export { portal } from './actions/portal';
|
|
3
|
+
export { scrollLock } from './actions/scroll-lock';
|
|
4
|
+
export { default as InlineLegalLinks } from './components/inline-legal-links.svelte';
|
|
5
|
+
export { getConsentKernel, getConsentManager, getHeadlessConsent, getIAB, getSnapshot, } from './context.svelte';
|
|
6
|
+
export { getIABTranslations } from './iab-translations';
|
|
7
|
+
export { getIABBannerDisplayItems, processGVLData, } from './iab-types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @c15t/svelte — IAB TCF component styles.
|
|
3
|
+
*
|
|
4
|
+
* Import this stylesheet in addition to `@c15t/svelte/styles.css`
|
|
5
|
+
* when using the prebuilt IAB consent UI.
|
|
6
|
+
*
|
|
7
|
+
* Usage (src/app.css):
|
|
8
|
+
* @import "@c15t/svelte/styles.css";
|
|
9
|
+
* @import "@c15t/svelte/iab/styles.css";
|
|
10
|
+
*/
|
|
11
|
+
@import '@c15t/ui/iab/styles.css';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package's lazy IAB factory.
|
|
3
|
+
*
|
|
4
|
+
* `<ConsentManagerProvider>` is imported by every app, IAB or not, so it
|
|
5
|
+
* cannot import `@c15t/iab` statically — that put the CMP API and the
|
|
6
|
+
* `__tcfapi` bridge in the layout chunk of apps that never turn IAB on
|
|
7
|
+
* (3.3 KB gzipped on the SvelteKit bench, with the TC-string encoder
|
|
8
|
+
* behind its own dynamic import inside `@c15t/iab`). The runtime calls
|
|
9
|
+
* `createIAB` synchronously, so the deferral happens here:
|
|
10
|
+
* {@link lazyCreateIAB} hands back a handle immediately and forwards to
|
|
11
|
+
* the real one once the dynamic import resolves.
|
|
12
|
+
*
|
|
13
|
+
* Surfaces that render against the handle wait for {@link whenIABReady}
|
|
14
|
+
* first, so they never read methods that have not arrived.
|
|
15
|
+
*/
|
|
16
|
+
import type { ProviderIABOptions } from './types';
|
|
17
|
+
/** The `createIAB` the provider hands the runtime. */
|
|
18
|
+
export declare const lazyCreateIAB: import("@c15t/core/runtime").ConsentRuntimeIABFactory;
|
|
19
|
+
/** Resolves once every pending `@c15t/iab` load has settled. */
|
|
20
|
+
export declare const whenIABReady: () => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Whether IAB is configured for this provider.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors the runtime's own check, so the provider only wires the loader
|
|
25
|
+
* for apps that will actually mount a CMP.
|
|
26
|
+
*
|
|
27
|
+
* @param iab - The provider's `iab` option.
|
|
28
|
+
* @returns `true` when the runtime would mount the TCF addon.
|
|
29
|
+
*/
|
|
30
|
+
export declare const isIABConfigured: (iab: ProviderIABOptions | undefined) => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The package's lazy IAB factory.
|
|
3
|
+
*
|
|
4
|
+
* `<ConsentManagerProvider>` is imported by every app, IAB or not, so it
|
|
5
|
+
* cannot import `@c15t/iab` statically — that put the CMP API and the
|
|
6
|
+
* `__tcfapi` bridge in the layout chunk of apps that never turn IAB on
|
|
7
|
+
* (3.3 KB gzipped on the SvelteKit bench, with the TC-string encoder
|
|
8
|
+
* behind its own dynamic import inside `@c15t/iab`). The runtime calls
|
|
9
|
+
* `createIAB` synchronously, so the deferral happens here:
|
|
10
|
+
* {@link lazyCreateIAB} hands back a handle immediately and forwards to
|
|
11
|
+
* the real one once the dynamic import resolves.
|
|
12
|
+
*
|
|
13
|
+
* Surfaces that render against the handle wait for {@link whenIABReady}
|
|
14
|
+
* first, so they never read methods that have not arrived.
|
|
15
|
+
*/
|
|
16
|
+
import { createLazyIABFactory } from '@c15t/core/runtime';
|
|
17
|
+
const factory = createLazyIABFactory(() => import('@c15t/iab'));
|
|
18
|
+
/** The `createIAB` the provider hands the runtime. */
|
|
19
|
+
export const lazyCreateIAB = factory.create;
|
|
20
|
+
/** Resolves once every pending `@c15t/iab` load has settled. */
|
|
21
|
+
export const whenIABReady = factory.whenReady;
|
|
22
|
+
/**
|
|
23
|
+
* Whether IAB is configured for this provider.
|
|
24
|
+
*
|
|
25
|
+
* Mirrors the runtime's own check, so the provider only wires the loader
|
|
26
|
+
* for apps that will actually mount a CMP.
|
|
27
|
+
*
|
|
28
|
+
* @param iab - The provider's `iab` option.
|
|
29
|
+
* @returns `true` when the runtime would mount the TCF addon.
|
|
30
|
+
*/
|
|
31
|
+
export const isIABConfigured = function isIABConfigured(iab) {
|
|
32
|
+
return Boolean(iab) && iab.enabled !== false;
|
|
33
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { TranslationConfig } from '@c15t/core';
|
|
2
|
+
/**
|
|
3
|
+
* IAB translations interface.
|
|
4
|
+
* Matches the structure in @c15t/translations.
|
|
5
|
+
*/
|
|
6
|
+
export interface IABTranslations {
|
|
7
|
+
banner: {
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
partnersLink: string;
|
|
11
|
+
andMore: string;
|
|
12
|
+
legitimateInterestNotice: string;
|
|
13
|
+
scopeServiceSpecific: string;
|
|
14
|
+
scopeGroup: string;
|
|
15
|
+
};
|
|
16
|
+
common: {
|
|
17
|
+
acceptAll: string;
|
|
18
|
+
rejectAll: string;
|
|
19
|
+
customize: string;
|
|
20
|
+
saveSettings: string;
|
|
21
|
+
loading: string;
|
|
22
|
+
showingSelectedVendor: string;
|
|
23
|
+
clearSelection: string;
|
|
24
|
+
customPartner: string;
|
|
25
|
+
};
|
|
26
|
+
preferenceCenter: {
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
tabs: {
|
|
30
|
+
purposes: string;
|
|
31
|
+
vendors: string;
|
|
32
|
+
};
|
|
33
|
+
purposeItem: {
|
|
34
|
+
partners: string;
|
|
35
|
+
vendorsUseLegitimateInterest: string;
|
|
36
|
+
examples: string;
|
|
37
|
+
partnersUsingPurpose: string;
|
|
38
|
+
withYourPermission: string;
|
|
39
|
+
legitimateInterest: string;
|
|
40
|
+
objectButton: string;
|
|
41
|
+
objected: string;
|
|
42
|
+
rightToObject: string;
|
|
43
|
+
};
|
|
44
|
+
specialPurposes: {
|
|
45
|
+
title: string;
|
|
46
|
+
tooltip: string;
|
|
47
|
+
};
|
|
48
|
+
vendorList: {
|
|
49
|
+
search: string;
|
|
50
|
+
showingCount: string;
|
|
51
|
+
iabVendorsHeading: string;
|
|
52
|
+
iabVendorsNotice: string;
|
|
53
|
+
customVendorsHeading: string;
|
|
54
|
+
customVendorsNotice: string;
|
|
55
|
+
purposes: string;
|
|
56
|
+
specialPurposes: string;
|
|
57
|
+
specialFeatures: string;
|
|
58
|
+
features: string;
|
|
59
|
+
dataCategories: string;
|
|
60
|
+
usesCookies: string;
|
|
61
|
+
nonCookieAccess: string;
|
|
62
|
+
maxAge: string;
|
|
63
|
+
maxAgeRefreshes: string;
|
|
64
|
+
retention: string;
|
|
65
|
+
retainedDays: string;
|
|
66
|
+
legitimateInterest: string;
|
|
67
|
+
privacyPolicy: string;
|
|
68
|
+
storageDisclosure: string;
|
|
69
|
+
requiredNotice: string;
|
|
70
|
+
noVendorsFound: string;
|
|
71
|
+
partnerCount: string;
|
|
72
|
+
partnerSingular: string;
|
|
73
|
+
partnerPlural: string;
|
|
74
|
+
};
|
|
75
|
+
footer: {
|
|
76
|
+
consentStorage: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get IAB translations with fallback to defaults.
|
|
82
|
+
* Svelte equivalent of the React `useIABTranslations` hook.
|
|
83
|
+
*/
|
|
84
|
+
export declare const getIABTranslations: (translationConfig?: TranslationConfig) => IABTranslations;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defaultTranslationConfig } from '@c15t/core';
|
|
2
|
+
import { resolveTranslations } from '@c15t/ui/utils';
|
|
3
|
+
// oxlint-disable-next-line typescript/no-non-null-assertion -- enTranslations is guaranteed to exist in defaultTranslationConfig
|
|
4
|
+
const DEFAULT_IAB_TRANSLATIONS = defaultTranslationConfig.translations.en
|
|
5
|
+
.iab;
|
|
6
|
+
/**
|
|
7
|
+
* Deep merge helper for IAB translations.
|
|
8
|
+
*/
|
|
9
|
+
const deepMerge = function deepMerge(defaults, overrides) {
|
|
10
|
+
if (!overrides) {
|
|
11
|
+
return defaults;
|
|
12
|
+
}
|
|
13
|
+
const result = { ...defaults };
|
|
14
|
+
for (const key of Object.keys(defaults)) {
|
|
15
|
+
const defaultValue = defaults[key];
|
|
16
|
+
const overrideValue = overrides[key];
|
|
17
|
+
if (overrideValue !== undefined &&
|
|
18
|
+
typeof defaultValue === 'object' &&
|
|
19
|
+
defaultValue !== null &&
|
|
20
|
+
typeof overrideValue === 'object' &&
|
|
21
|
+
overrideValue !== null &&
|
|
22
|
+
!Array.isArray(defaultValue)) {
|
|
23
|
+
result[key] = deepMerge(defaultValue, overrideValue);
|
|
24
|
+
}
|
|
25
|
+
else if (overrideValue !== undefined) {
|
|
26
|
+
result[key] = overrideValue;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Get IAB translations with fallback to defaults.
|
|
33
|
+
* Svelte equivalent of the React `useIABTranslations` hook.
|
|
34
|
+
*/
|
|
35
|
+
export const getIABTranslations = function getIABTranslations(translationConfig) {
|
|
36
|
+
const translations = resolveTranslations(translationConfig ?? {}, defaultTranslationConfig);
|
|
37
|
+
if (!translations.iab) {
|
|
38
|
+
return DEFAULT_IAB_TRANSLATIONS;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
banner: deepMerge(DEFAULT_IAB_TRANSLATIONS.banner, translations.iab.banner),
|
|
42
|
+
common: deepMerge(DEFAULT_IAB_TRANSLATIONS.common, translations.iab.common),
|
|
43
|
+
preferenceCenter: deepMerge(DEFAULT_IAB_TRANSLATIONS.preferenceCenter, translations.iab.preferenceCenter),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Svelte adapter's view of the shared IAB display model.
|
|
3
|
+
*
|
|
4
|
+
* The derivation itself — which purposes a stack absorbs, which rows a
|
|
5
|
+
* preference centre lists, what each row's test-id is — lives in
|
|
6
|
+
* `@c15t/iab/headless` so React, Svelte, Vue and the Astro server render
|
|
7
|
+
* cannot drift apart. This module is the thin naming layer that was left
|
|
8
|
+
* behind: the local type aliases the components already import, and two
|
|
9
|
+
* wrappers keeping the argument shapes they already call with.
|
|
10
|
+
*
|
|
11
|
+
* `@c15t/iab/headless` is pure derivation with no TCF encoder behind it,
|
|
12
|
+
* so importing it here does not pull the CMP API into an app that never
|
|
13
|
+
* mounts an IAB surface — the components that import this module are
|
|
14
|
+
* themselves only reachable from `<IABConsentBanner>`/`<IABConsentDialog>`.
|
|
15
|
+
*/
|
|
16
|
+
import type { GlobalVendorList } from '@c15t/core';
|
|
17
|
+
import type { HeadlessIABDialogData, HeadlessIABProcessedFeature, HeadlessIABProcessedPurpose, HeadlessIABProcessedSpecialFeature, HeadlessIABProcessedStack, HeadlessIABProcessedVendor, HeadlessIABVendorId } from '@c15t/iab/headless';
|
|
18
|
+
export type VendorId = HeadlessIABVendorId;
|
|
19
|
+
export type ProcessedVendor = HeadlessIABProcessedVendor;
|
|
20
|
+
export type ProcessedPurpose = HeadlessIABProcessedPurpose;
|
|
21
|
+
export type ProcessedSpecialFeature = HeadlessIABProcessedSpecialFeature;
|
|
22
|
+
export type ProcessedFeature = HeadlessIABProcessedFeature;
|
|
23
|
+
export type ProcessedStack = HeadlessIABProcessedStack;
|
|
24
|
+
export type { HeadlessIABDialogDisplayModel as IABDisplayModel, HeadlessIABDisplayConsentRow as IABDisplayConsentRow, HeadlessIABDisplayRow as IABDisplayRow, HeadlessIABDisplayStackRow as IABDisplayStackRow, } from '@c15t/iab/headless';
|
|
25
|
+
export { resolveIABDialogDisplayModel } from '@c15t/iab/headless';
|
|
26
|
+
/** Custom vendor not registered with IAB. */
|
|
27
|
+
export interface NonIABVendor {
|
|
28
|
+
id: string | number;
|
|
29
|
+
name: string;
|
|
30
|
+
privacyPolicyUrl: string;
|
|
31
|
+
purposes: number[];
|
|
32
|
+
legIntPurposes?: number[];
|
|
33
|
+
specialFeatures?: number[];
|
|
34
|
+
features?: number[];
|
|
35
|
+
dataCategories?: number[];
|
|
36
|
+
usesCookies?: boolean;
|
|
37
|
+
usesNonCookieAccess?: boolean;
|
|
38
|
+
cookieMaxAgeSeconds?: number;
|
|
39
|
+
}
|
|
40
|
+
/** Result of processing GVL data into UI-friendly format. */
|
|
41
|
+
export type ProcessedGVLData = HeadlessIABDialogData;
|
|
42
|
+
/**
|
|
43
|
+
* Process raw GVL data into UI-friendly format.
|
|
44
|
+
*
|
|
45
|
+
* @param gvl - The Global Vendor List.
|
|
46
|
+
* @param customVendors - Publisher-declared non-IAB vendors.
|
|
47
|
+
* @returns The processed purposes, stacks, features and vendors.
|
|
48
|
+
*/
|
|
49
|
+
export declare const processGVLData: (gvl: GlobalVendorList, customVendors?: NonIABVendor[]) => ProcessedGVLData;
|
|
50
|
+
/**
|
|
51
|
+
* Compute display items for the IAB consent banner.
|
|
52
|
+
*
|
|
53
|
+
* @param gvl - The Global Vendor List.
|
|
54
|
+
* @param maxItems - How many items to list before collapsing the rest.
|
|
55
|
+
* Defaults to the cap the shared model applies, so the four banners list
|
|
56
|
+
* the same number of items unless a caller asks otherwise.
|
|
57
|
+
* @returns The item names to list, and how many were left out.
|
|
58
|
+
*/
|
|
59
|
+
export declare const getIABBannerDisplayItems: (gvl: GlobalVendorList, maxItems?: number) => {
|
|
60
|
+
displayed: string[];
|
|
61
|
+
remainingCount: number;
|
|
62
|
+
};
|