@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.
Files changed (274) hide show
  1. package/AGENTS.md +88 -0
  2. package/README.md +136 -0
  3. package/SKILL.md +14 -0
  4. package/dist/actions/focus-trap.d.ts +8 -0
  5. package/dist/actions/focus-trap.js +23 -0
  6. package/dist/actions/portal.d.ts +8 -0
  7. package/dist/actions/portal.js +39 -0
  8. package/dist/actions/scroll-lock.d.ts +8 -0
  9. package/dist/actions/scroll-lock.js +23 -0
  10. package/dist/components/action-button.svelte +119 -0
  11. package/dist/components/action-button.svelte.d.ts +18 -0
  12. package/dist/components/branding.svelte +139 -0
  13. package/dist/components/branding.svelte.d.ts +13 -0
  14. package/dist/components/consent-dev-tools.svelte +58 -0
  15. package/dist/components/consent-dev-tools.svelte.d.ts +4 -0
  16. package/dist/components/frame.svelte +95 -0
  17. package/dist/components/frame.svelte.d.ts +12 -0
  18. package/dist/components/iab-panel.svelte +542 -0
  19. package/dist/components/iab-panel.svelte.d.ts +16 -0
  20. package/dist/components/iab-prompt.svelte +304 -0
  21. package/dist/components/iab-prompt.svelte.d.ts +14 -0
  22. package/dist/components/iab-purpose-item.svelte +511 -0
  23. package/dist/components/iab-purpose-item.svelte.d.ts +26 -0
  24. package/dist/components/iab-stack-item.svelte +146 -0
  25. package/dist/components/iab-stack-item.svelte.d.ts +19 -0
  26. package/dist/components/iab-vendor-list.svelte +900 -0
  27. package/dist/components/iab-vendor-list.svelte.d.ts +19 -0
  28. package/dist/components/icons/c15-t-icon-only.svelte +27 -0
  29. package/dist/components/icons/c15-t-icon-only.svelte.d.ts +9 -0
  30. package/dist/components/icons/chevron-down-icon.svelte +30 -0
  31. package/dist/components/icons/chevron-down-icon.svelte.d.ts +10 -0
  32. package/dist/components/icons/chevron-right-icon.svelte +36 -0
  33. package/dist/components/icons/chevron-right-icon.svelte.d.ts +12 -0
  34. package/dist/components/icons/close-icon.svelte +40 -0
  35. package/dist/components/icons/close-icon.svelte.d.ts +10 -0
  36. package/dist/components/icons/consent-icon-only.svelte +36 -0
  37. package/dist/components/icons/consent-icon-only.svelte.d.ts +9 -0
  38. package/dist/components/icons/external-link-icon.svelte +30 -0
  39. package/dist/components/icons/external-link-icon.svelte.d.ts +8 -0
  40. package/dist/components/icons/globe-icon.svelte +39 -0
  41. package/dist/components/icons/globe-icon.svelte.d.ts +9 -0
  42. package/dist/components/icons/info-icon.svelte +42 -0
  43. package/dist/components/icons/info-icon.svelte.d.ts +9 -0
  44. package/dist/components/icons/inth-logo.svelte +38 -0
  45. package/dist/components/icons/inth-logo.svelte.d.ts +9 -0
  46. package/dist/components/icons/layers-icon.svelte +25 -0
  47. package/dist/components/icons/layers-icon.svelte.d.ts +8 -0
  48. package/dist/components/icons/legitimate-interest-icon.svelte +29 -0
  49. package/dist/components/icons/legitimate-interest-icon.svelte.d.ts +10 -0
  50. package/dist/components/icons/lock-icon.svelte +31 -0
  51. package/dist/components/icons/lock-icon.svelte.d.ts +8 -0
  52. package/dist/components/icons/search-icon.svelte +33 -0
  53. package/dist/components/icons/search-icon.svelte.d.ts +8 -0
  54. package/dist/components/inline-legal-links.svelte +95 -0
  55. package/dist/components/inline-legal-links.svelte.d.ts +10 -0
  56. package/dist/components/manager-provider.svelte +459 -0
  57. package/dist/components/manager-provider.svelte.d.ts +27 -0
  58. package/dist/components/overlay.svelte +79 -0
  59. package/dist/components/overlay.svelte.d.ts +7 -0
  60. package/dist/components/panel-link.svelte +33 -0
  61. package/dist/components/panel-link.svelte.d.ts +10 -0
  62. package/dist/components/panel-trigger.svelte +237 -0
  63. package/dist/components/panel-trigger.svelte.d.ts +16 -0
  64. package/dist/components/panel.svelte +258 -0
  65. package/dist/components/panel.svelte.d.ts +22 -0
  66. package/dist/components/policy-actions-renderer.svelte +79 -0
  67. package/dist/components/policy-actions-renderer.svelte.d.ts +19 -0
  68. package/dist/components/preferences.svelte +320 -0
  69. package/dist/components/preferences.svelte.d.ts +8 -0
  70. package/dist/components/prompt.svelte +514 -0
  71. package/dist/components/prompt.svelte.d.ts +43 -0
  72. package/dist/context.svelte.d.ts +125 -0
  73. package/dist/context.svelte.js +354 -0
  74. package/dist/devtools-options.d.ts +7 -0
  75. package/dist/devtools-options.js +1 -0
  76. package/dist/devtools.d.ts +9 -0
  77. package/dist/devtools.js +7 -0
  78. package/dist/headless.d.ts +10 -0
  79. package/dist/headless.js +7 -0
  80. package/dist/iab/styles.css +11 -0
  81. package/dist/iab-loader.d.ts +30 -0
  82. package/dist/iab-loader.js +33 -0
  83. package/dist/iab-translations.d.ts +84 -0
  84. package/dist/iab-translations.js +45 -0
  85. package/dist/iab-types.d.ts +62 -0
  86. package/dist/iab-types.js +43 -0
  87. package/dist/index.d.ts +28 -0
  88. package/dist/index.js +21 -0
  89. package/dist/kit/app.d.ts +35 -0
  90. package/dist/kit/handle.d.ts +34 -0
  91. package/dist/kit/handle.js +87 -0
  92. package/dist/kit/index.d.ts +30 -0
  93. package/dist/kit/index.js +5 -0
  94. package/dist/kit/load-consent.d.ts +57 -0
  95. package/dist/kit/load-consent.js +144 -0
  96. package/dist/kit/routes.d.ts +46 -0
  97. package/dist/kit/routes.js +203 -0
  98. package/dist/kit/types.d.ts +56 -0
  99. package/dist/kit/types.js +1 -0
  100. package/dist/primitives/accordion/accordion-item-content.svelte +35 -0
  101. package/dist/primitives/accordion/accordion-item-content.svelte.d.ts +9 -0
  102. package/dist/primitives/accordion/accordion-item-trigger.svelte +54 -0
  103. package/dist/primitives/accordion/accordion-item-trigger.svelte.d.ts +10 -0
  104. package/dist/primitives/accordion/accordion-item.svelte +61 -0
  105. package/dist/primitives/accordion/accordion-item.svelte.d.ts +11 -0
  106. package/dist/primitives/accordion/accordion-root.svelte +61 -0
  107. package/dist/primitives/accordion/accordion-root.svelte.d.ts +13 -0
  108. package/dist/primitives/accordion/context.d.ts +18 -0
  109. package/dist/primitives/accordion/context.js +23 -0
  110. package/dist/primitives/accordion/index.d.ts +29 -0
  111. package/dist/primitives/accordion/index.js +11 -0
  112. package/dist/primitives/collapsible/collapsible-content.svelte +36 -0
  113. package/dist/primitives/collapsible/collapsible-content.svelte.d.ts +9 -0
  114. package/dist/primitives/collapsible/collapsible-indicator.svelte +29 -0
  115. package/dist/primitives/collapsible/collapsible-indicator.svelte.d.ts +9 -0
  116. package/dist/primitives/collapsible/collapsible-root.svelte +70 -0
  117. package/dist/primitives/collapsible/collapsible-root.svelte.d.ts +11 -0
  118. package/dist/primitives/collapsible/collapsible-trigger.svelte +52 -0
  119. package/dist/primitives/collapsible/collapsible-trigger.svelte.d.ts +10 -0
  120. package/dist/primitives/collapsible/context.d.ts +10 -0
  121. package/dist/primitives/collapsible/context.js +12 -0
  122. package/dist/primitives/collapsible/index.d.ts +26 -0
  123. package/dist/primitives/collapsible/index.js +11 -0
  124. package/dist/primitives/dialog/context.d.ts +14 -0
  125. package/dist/primitives/dialog/context.js +12 -0
  126. package/dist/primitives/dialog/dialog-backdrop.svelte +39 -0
  127. package/dist/primitives/dialog/dialog-backdrop.svelte.d.ts +7 -0
  128. package/dist/primitives/dialog/dialog-close-trigger.svelte +48 -0
  129. package/dist/primitives/dialog/dialog-close-trigger.svelte.d.ts +11 -0
  130. package/dist/primitives/dialog/dialog-content.svelte +81 -0
  131. package/dist/primitives/dialog/dialog-content.svelte.d.ts +9 -0
  132. package/dist/primitives/dialog/dialog-description.svelte +28 -0
  133. package/dist/primitives/dialog/dialog-description.svelte.d.ts +9 -0
  134. package/dist/primitives/dialog/dialog-positioner.svelte +33 -0
  135. package/dist/primitives/dialog/dialog-positioner.svelte.d.ts +9 -0
  136. package/dist/primitives/dialog/dialog-root.svelte +117 -0
  137. package/dist/primitives/dialog/dialog-root.svelte.d.ts +14 -0
  138. package/dist/primitives/dialog/dialog-title.svelte +28 -0
  139. package/dist/primitives/dialog/dialog-title.svelte.d.ts +9 -0
  140. package/dist/primitives/dialog/index.d.ts +50 -0
  141. package/dist/primitives/dialog/index.js +19 -0
  142. package/dist/primitives/index.d.ts +7 -0
  143. package/dist/primitives/index.js +7 -0
  144. package/dist/primitives/portal/index.d.ts +4 -0
  145. package/dist/primitives/portal/index.js +2 -0
  146. package/dist/primitives/portal/portal.svelte +23 -0
  147. package/dist/primitives/portal/portal.svelte.d.ts +9 -0
  148. package/dist/primitives/preference-item/context.d.ts +11 -0
  149. package/dist/primitives/preference-item/context.js +12 -0
  150. package/dist/primitives/preference-item/index.d.ts +54 -0
  151. package/dist/primitives/preference-item/index.js +21 -0
  152. package/dist/primitives/preference-item/preference-item-auxiliary.svelte +33 -0
  153. package/dist/primitives/preference-item/preference-item-auxiliary.svelte.d.ts +9 -0
  154. package/dist/primitives/preference-item/preference-item-content.svelte +68 -0
  155. package/dist/primitives/preference-item/preference-item-content.svelte.d.ts +14 -0
  156. package/dist/primitives/preference-item/preference-item-control.svelte +33 -0
  157. package/dist/primitives/preference-item/preference-item-control.svelte.d.ts +9 -0
  158. package/dist/primitives/preference-item/preference-item-header.svelte +33 -0
  159. package/dist/primitives/preference-item/preference-item-header.svelte.d.ts +9 -0
  160. package/dist/primitives/preference-item/preference-item-leading.svelte +33 -0
  161. package/dist/primitives/preference-item/preference-item-leading.svelte.d.ts +9 -0
  162. package/dist/primitives/preference-item/preference-item-meta.svelte +33 -0
  163. package/dist/primitives/preference-item/preference-item-meta.svelte.d.ts +9 -0
  164. package/dist/primitives/preference-item/preference-item-root.svelte +82 -0
  165. package/dist/primitives/preference-item/preference-item-root.svelte.d.ts +12 -0
  166. package/dist/primitives/preference-item/preference-item-title.svelte +33 -0
  167. package/dist/primitives/preference-item/preference-item-title.svelte.d.ts +9 -0
  168. package/dist/primitives/preference-item/preference-item-trigger.svelte +62 -0
  169. package/dist/primitives/preference-item/preference-item-trigger.svelte.d.ts +10 -0
  170. package/dist/primitives/switch/context.d.ts +7 -0
  171. package/dist/primitives/switch/context.js +12 -0
  172. package/dist/primitives/switch/index.d.ts +25 -0
  173. package/dist/primitives/switch/index.js +11 -0
  174. package/dist/primitives/switch/switch-control.svelte +21 -0
  175. package/dist/primitives/switch/switch-control.svelte.d.ts +9 -0
  176. package/dist/primitives/switch/switch-hidden-input.svelte +31 -0
  177. package/dist/primitives/switch/switch-hidden-input.svelte.d.ts +8 -0
  178. package/dist/primitives/switch/switch-root.svelte +86 -0
  179. package/dist/primitives/switch/switch-root.svelte.d.ts +12 -0
  180. package/dist/primitives/switch/switch-thumb.svelte +14 -0
  181. package/dist/primitives/switch/switch-thumb.svelte.d.ts +7 -0
  182. package/dist/primitives/tabs/context.d.ts +11 -0
  183. package/dist/primitives/tabs/context.js +12 -0
  184. package/dist/primitives/tabs/index.d.ts +32 -0
  185. package/dist/primitives/tabs/index.js +11 -0
  186. package/dist/primitives/tabs/tabs-content.svelte +45 -0
  187. package/dist/primitives/tabs/tabs-content.svelte.d.ts +11 -0
  188. package/dist/primitives/tabs/tabs-list.svelte +38 -0
  189. package/dist/primitives/tabs/tabs-list.svelte.d.ts +10 -0
  190. package/dist/primitives/tabs/tabs-root.svelte +67 -0
  191. package/dist/primitives/tabs/tabs-root.svelte.d.ts +14 -0
  192. package/dist/primitives/tabs/tabs-trigger.svelte +108 -0
  193. package/dist/primitives/tabs/tabs-trigger.svelte.d.ts +11 -0
  194. package/dist/server/headers.d.ts +13 -0
  195. package/dist/server/headers.js +37 -0
  196. package/dist/server/index.d.ts +8 -0
  197. package/dist/server/index.js +116 -0
  198. package/dist/server/normalize-url.d.ts +23 -0
  199. package/dist/server/normalize-url.js +46 -0
  200. package/dist/server/types.d.ts +25 -0
  201. package/dist/server/types.js +1 -0
  202. package/dist/styles.css +10 -0
  203. package/dist/transports/offline.d.ts +14 -0
  204. package/dist/transports/offline.js +22 -0
  205. package/dist/types.d.ts +70 -0
  206. package/dist/types.js +1 -0
  207. package/dist/use-banner-visibility.svelte.d.ts +25 -0
  208. package/dist/use-banner-visibility.svelte.js +108 -0
  209. package/dist/utils.d.ts +25 -0
  210. package/dist/utils.js +32 -0
  211. package/dist/version.d.ts +1 -0
  212. package/dist/version.js +2 -0
  213. package/docs/README.md +88 -0
  214. package/docs/assets/v3/brand-bar.png +0 -0
  215. package/docs/assets/v3/brand-card.png +0 -0
  216. package/docs/assets/v3/choice-wall.png +0 -0
  217. package/docs/assets/v3/mobile-card.png +0 -0
  218. package/docs/assets/v3/preferences.png +0 -0
  219. package/docs/customization/overview.md +45 -0
  220. package/docs/customization/recipes.md +79 -0
  221. package/docs/customization/slots.md +55 -0
  222. package/docs/customization/tokens.md +76 -0
  223. package/docs/customization/translations.md +49 -0
  224. package/docs/frameworks/svelte/quickstart.md +133 -0
  225. package/docs/frameworks/sveltekit/quickstart.md +144 -0
  226. package/docs/guides/consent-state.md +60 -0
  227. package/docs/guides/data-fetching.md +163 -0
  228. package/docs/guides/deployment-modes.md +63 -0
  229. package/docs/guides/troubleshooting.md +68 -0
  230. package/docs/guides/verify-consent.md +62 -0
  231. package/docs/integrations/adobe-analytics.md +294 -0
  232. package/docs/integrations/ahrefs-analytics.md +291 -0
  233. package/docs/integrations/amplitude.md +292 -0
  234. package/docs/integrations/building-integrations.md +47 -0
  235. package/docs/integrations/clearbit.md +291 -0
  236. package/docs/integrations/cloudflare-web-analytics.md +292 -0
  237. package/docs/integrations/crisp.md +294 -0
  238. package/docs/integrations/databuddy.md +311 -0
  239. package/docs/integrations/fathom-analytics.md +293 -0
  240. package/docs/integrations/google-maps.md +384 -0
  241. package/docs/integrations/google-tag-manager.md +306 -0
  242. package/docs/integrations/google-tag.md +305 -0
  243. package/docs/integrations/heap.md +292 -0
  244. package/docs/integrations/hightouch.md +293 -0
  245. package/docs/integrations/hotjar.md +292 -0
  246. package/docs/integrations/intercom.md +285 -0
  247. package/docs/integrations/linkedin-insights.md +291 -0
  248. package/docs/integrations/logrocket.md +293 -0
  249. package/docs/integrations/matomo-analytics.md +316 -0
  250. package/docs/integrations/meta-pixel.md +285 -0
  251. package/docs/integrations/microsoft-clarity.md +292 -0
  252. package/docs/integrations/microsoft-uet.md +291 -0
  253. package/docs/integrations/mixpanel-analytics.md +295 -0
  254. package/docs/integrations/openai-pixel.md +441 -0
  255. package/docs/integrations/overview.md +111 -0
  256. package/docs/integrations/pirsch.md +295 -0
  257. package/docs/integrations/plausible-analytics.md +295 -0
  258. package/docs/integrations/posthog.md +397 -0
  259. package/docs/integrations/promptwatch.md +291 -0
  260. package/docs/integrations/reddit-pixel.md +294 -0
  261. package/docs/integrations/rudderstack.md +328 -0
  262. package/docs/integrations/rybbit-analytics.md +296 -0
  263. package/docs/integrations/segment.md +292 -0
  264. package/docs/integrations/snapchat-pixel.md +293 -0
  265. package/docs/integrations/tiktok-pixel.md +291 -0
  266. package/docs/integrations/umami-analytics.md +295 -0
  267. package/docs/integrations/vercel-analytics.md +293 -0
  268. package/docs/integrations/x-pixel.md +291 -0
  269. package/docs/integrations/youtube.md +405 -0
  270. package/docs/upgrade-v3.md +334 -0
  271. package/iab/styles.css +1 -0
  272. package/package.json +153 -0
  273. package/readme.json +36 -0
  274. package/styles.css +1 -0
@@ -0,0 +1,43 @@
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 { processGVLForDialog, resolveIABBannerSummary, } from '@c15t/iab/headless';
17
+ export { resolveIABDialogDisplayModel } from '@c15t/iab/headless';
18
+ /**
19
+ * Process raw GVL data into UI-friendly format.
20
+ *
21
+ * @param gvl - The Global Vendor List.
22
+ * @param customVendors - Publisher-declared non-IAB vendors.
23
+ * @returns The processed purposes, stacks, features and vendors.
24
+ */
25
+ export const processGVLData = function processGVLData(gvl, customVendors = []) {
26
+ return processGVLForDialog({ customVendors, gvl });
27
+ };
28
+ /**
29
+ * Compute display items for the IAB consent banner.
30
+ *
31
+ * @param gvl - The Global Vendor List.
32
+ * @param maxItems - How many items to list before collapsing the rest.
33
+ * Defaults to the cap the shared model applies, so the four banners list
34
+ * the same number of items unless a caller asks otherwise.
35
+ * @returns The item names to list, and how many were left out.
36
+ */
37
+ export const getIABBannerDisplayItems = function getIABBannerDisplayItems(gvl, maxItems) {
38
+ const summary = resolveIABBannerSummary({ gvl }, { maxItems });
39
+ return {
40
+ displayed: summary.displayItems,
41
+ remainingCount: summary.remainingCount,
42
+ };
43
+ };
@@ -0,0 +1,28 @@
1
+ export { custom, defaultTranslationConfig, detectBrowserLanguage, hosted, mergeTranslationConfigs, prepareTranslationConfig, } from '@c15t/core';
2
+ export type { AllConsentNames, ConsentType, I18nConfig, LegalLinks, Translations, ConsentKernel, ConsentSnapshot, ConsentState, GlobalVendorList, InitResponse, KernelActiveUI, KernelBranding, KernelConfig, KernelEvent, KernelIABState, KernelModel, KernelOverrides, KernelTranslations, KernelTransport, KernelUser, LocationResponse, NonIABVendor, PolicyScopeMode, HostedModeOptions, ProviderTransportContext, ProviderTransportFactory, ProviderTransportKind, SavePayload, SaveResult, TranslationsResponse, } from '@c15t/core';
3
+ export { createConsentRuntime } from '@c15t/core/runtime';
4
+ export type { ConsentRuntime, ConsentRuntimeIABFactory, ConsentRuntimeIABHandle, ConsentRuntimeOptions, } from '@c15t/core/runtime';
5
+ export * from '@c15t/ui/primitives';
6
+ export * from '@c15t/ui/styles/primitives';
7
+ export type { ColorTokens, ComponentSlots, MotionTokens, RadiusTokens, ShadowTokens, SlotStyle, SpacingTokens, Theme, TypographyTokens, } from '@c15t/ui/theme';
8
+ export { focusTrap } from './actions/focus-trap';
9
+ export { portal } from './actions/portal';
10
+ export { scrollLock } from './actions/scroll-lock';
11
+ export { default as ConsentBanner } from './components/prompt.svelte';
12
+ export { default as ConsentButton } from './components/action-button.svelte';
13
+ export { default as ConsentDialog } from './components/panel.svelte';
14
+ export { default as ConsentDialogLink } from './components/panel-link.svelte';
15
+ export { default as ConsentDialogTrigger } from './components/panel-trigger.svelte';
16
+ export { default as ConsentManagerProvider } from './components/manager-provider.svelte';
17
+ export { default as ConsentWidget } from './components/preferences.svelte';
18
+ export { default as Frame } from './components/frame.svelte';
19
+ export { default as IABConsentBanner } from './components/iab-prompt.svelte';
20
+ export { default as IABConsentDialog } from './components/iab-panel.svelte';
21
+ export { getConsentKernel, getConsentManager, getHeadlessConsent, getIAB, getSnapshot, type HeadlessConsentSurfaceState, type SvelteIABState, } from './context.svelte';
22
+ export { Accordion, Collapsible, Dialog, Portal, PreferenceItem, Switch, Tabs, } from './primitives';
23
+ export type { ConsentManagerOptions, ConsentProviderCallbacks, ProviderIABOptions, SvelteUIOptions, UseNetworkBlockerOptions, UsePersistenceOptions, UseScriptLoaderOptions, } from './types';
24
+ export type { OfflineModeOptions } from './transports/offline';
25
+ export { offline } from './transports/offline';
26
+ export type { ConsentManagerState, ConsentDraftState } from './context.svelte';
27
+ export { resolveConsentPresentation } from '@c15t/core';
28
+ export type { ConsentPresentation, PresentationAction, ResolvedConsentPresentation, } from '@c15t/core';
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ export { custom, defaultTranslationConfig, detectBrowserLanguage, hosted, mergeTranslationConfigs, prepareTranslationConfig, } from '@c15t/core';
2
+ export { createConsentRuntime } from '@c15t/core/runtime';
3
+ export * from '@c15t/ui/primitives';
4
+ export * from '@c15t/ui/styles/primitives';
5
+ export { focusTrap } from './actions/focus-trap';
6
+ export { portal } from './actions/portal';
7
+ export { scrollLock } from './actions/scroll-lock';
8
+ export { default as ConsentBanner } from './components/prompt.svelte';
9
+ export { default as ConsentButton } from './components/action-button.svelte';
10
+ export { default as ConsentDialog } from './components/panel.svelte';
11
+ export { default as ConsentDialogLink } from './components/panel-link.svelte';
12
+ export { default as ConsentDialogTrigger } from './components/panel-trigger.svelte';
13
+ export { default as ConsentManagerProvider } from './components/manager-provider.svelte';
14
+ export { default as ConsentWidget } from './components/preferences.svelte';
15
+ export { default as Frame } from './components/frame.svelte';
16
+ export { default as IABConsentBanner } from './components/iab-prompt.svelte';
17
+ export { default as IABConsentDialog } from './components/iab-panel.svelte';
18
+ export { getConsentKernel, getConsentManager, getHeadlessConsent, getIAB, getSnapshot, } from './context.svelte';
19
+ export { Accordion, Collapsible, Dialog, Portal, PreferenceItem, Switch, Tabs, } from './primitives';
20
+ export { offline } from './transports/offline';
21
+ export { resolveConsentPresentation } from '@c15t/core';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Ambient `App.Locals` augmentation for apps that install `c15tHandle`.
3
+ *
4
+ * Reference it once from `src/app.d.ts`:
5
+ *
6
+ * ```ts
7
+ * /// <reference types="@c15t/svelte/kit/locals" />
8
+ * ```
9
+ *
10
+ * Prefer the explicit form if you already own an `App.Locals` block:
11
+ *
12
+ * ```ts
13
+ * import type { C15tLocals } from '@c15t/svelte/kit';
14
+ *
15
+ * declare global {
16
+ * namespace App {
17
+ * interface Locals {
18
+ * c15t: C15tLocals;
19
+ * }
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ import type { C15tLocals } from './types';
25
+
26
+ declare global {
27
+ namespace App {
28
+ interface Locals {
29
+ /** Consent context resolved once per request by `c15tHandle`. */
30
+ c15t: C15tLocals;
31
+ }
32
+ }
33
+ }
34
+
35
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { Handle } from '@sveltejs/kit';
2
+ import type { ConsentRequestOptions } from './types';
3
+ /** Options for {@link c15tHandle}. */
4
+ export type C15tHandleOptions = ConsentRequestOptions;
5
+ /**
6
+ * Creates the c15t SvelteKit handle.
7
+ *
8
+ * Register it in `src/hooks.server.ts`, alone or composed with `sequence()`:
9
+ *
10
+ * ```ts
11
+ * import { c15tHandle } from '@c15t/svelte/kit';
12
+ * import { sequence } from '@sveltejs/kit/hooks';
13
+ *
14
+ * export const handle = sequence(c15tHandle(), myOtherHandle);
15
+ * ```
16
+ *
17
+ * Augment `App.Locals` so `event.locals.c15t` is typed:
18
+ *
19
+ * ```ts
20
+ * import type { C15tLocals } from '@c15t/svelte/kit';
21
+ *
22
+ * declare global {
23
+ * namespace App {
24
+ * interface Locals {
25
+ * c15t: C15tLocals;
26
+ * }
27
+ * }
28
+ * }
29
+ * ```
30
+ *
31
+ * @param options - Cookie name and geo/language overrides.
32
+ * @returns A `Handle` that populates `event.locals.c15t`.
33
+ */
34
+ export declare const c15tHandle: (options?: C15tHandleOptions) => Handle;
@@ -0,0 +1,87 @@
1
+ import { extractConsentRequestInputs } from '@c15t/schema/types';
2
+ import { readInitialConsentConfig } from '../server';
3
+ /**
4
+ * Rewrites the resolved inputs back onto the request as the canonical
5
+ * `x-c15t-*` / `sec-gpc` headers, so anything downstream that reads raw
6
+ * headers (a proxied backend call, a nested handle) sees one normalized
7
+ * shape instead of whichever CDN header happened to carry it.
8
+ *
9
+ * Request headers are immutable in some runtimes. When the write is refused
10
+ * the normalized values are still on `event.locals.c15t.inputs`, which is
11
+ * what every helper in this package reads, so the request continues.
12
+ */
13
+ const normalizeRequestHeaders = function normalizeRequestHeaders(headers, inputs) {
14
+ try {
15
+ if (inputs.country) {
16
+ headers.set('x-c15t-country', inputs.country);
17
+ }
18
+ if (inputs.region) {
19
+ headers.set('x-c15t-region', inputs.region);
20
+ }
21
+ if (inputs.language) {
22
+ // The resolved language, not the browser's list: a downstream
23
+ // route re-reads `accept-language`, and an `options.language`
24
+ // override has to reach it too.
25
+ headers.set('accept-language', inputs.language);
26
+ }
27
+ if (inputs.gpc !== undefined) {
28
+ headers.set('sec-gpc', inputs.gpc ? '1' : '0');
29
+ }
30
+ }
31
+ catch {
32
+ // Immutable headers — locals still carry the normalized inputs.
33
+ }
34
+ };
35
+ /**
36
+ * Creates the c15t SvelteKit handle.
37
+ *
38
+ * Register it in `src/hooks.server.ts`, alone or composed with `sequence()`:
39
+ *
40
+ * ```ts
41
+ * import { c15tHandle } from '@c15t/svelte/kit';
42
+ * import { sequence } from '@sveltejs/kit/hooks';
43
+ *
44
+ * export const handle = sequence(c15tHandle(), myOtherHandle);
45
+ * ```
46
+ *
47
+ * Augment `App.Locals` so `event.locals.c15t` is typed:
48
+ *
49
+ * ```ts
50
+ * import type { C15tLocals } from '@c15t/svelte/kit';
51
+ *
52
+ * declare global {
53
+ * namespace App {
54
+ * interface Locals {
55
+ * c15t: C15tLocals;
56
+ * }
57
+ * }
58
+ * }
59
+ * ```
60
+ *
61
+ * @param options - Cookie name and geo/language overrides.
62
+ * @returns A `Handle` that populates `event.locals.c15t`.
63
+ */
64
+ export const c15tHandle = function c15tHandle(options = {}) {
65
+ return async ({ event, resolve }) => {
66
+ const { headers } = event.request;
67
+ const inputs = extractConsentRequestInputs(headers, {
68
+ country: options.country,
69
+ language: options.language,
70
+ region: options.region,
71
+ });
72
+ normalizeRequestHeaders(headers, inputs);
73
+ const config = await readInitialConsentConfig({
74
+ cookieName: options.cookieName,
75
+ country: inputs.country,
76
+ headers,
77
+ language: inputs.language,
78
+ region: inputs.region,
79
+ });
80
+ const locals = { config, inputs };
81
+ if (options.cookieName !== undefined) {
82
+ locals.cookieName = options.cookieName;
83
+ }
84
+ event.locals.c15t = locals;
85
+ return resolve(event);
86
+ };
87
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `@c15t/svelte/kit` — the SvelteKit server layer.
3
+ *
4
+ * Server-only. Importing this from a component that runs in the browser will
5
+ * pull `@c15t/translations/all` and the manifest resolver into the client
6
+ * bundle; keep it to `hooks.server.ts`, `+*.server.ts`, and `+server.ts`.
7
+ *
8
+ * ```ts
9
+ * // src/hooks.server.ts
10
+ * export const handle = c15tHandle();
11
+ *
12
+ * // src/routes/api/c15t/[...path]/+server.ts
13
+ * export const { GET } = createSvelteKitConsentRouteHandlers({ backendURL });
14
+ *
15
+ * // src/routes/+layout.server.ts
16
+ * export const load = async (event) => ({
17
+ * prefetch: await loadConsent(event, { initRoute: '/api/c15t' }),
18
+ * });
19
+ * ```
20
+ */
21
+ export type { C15tHandleOptions } from './handle';
22
+ export { c15tHandle } from './handle';
23
+ export type { LoadConsentOptions } from './load-consent';
24
+ export { loadConsent } from './load-consent';
25
+ export type { SvelteKitConsentRouteOptions } from './routes';
26
+ export { createSvelteKitConsentRouteHandlers } from './routes';
27
+ export type { C15tLocals, ConsentManifestOptions, ConsentRequestInputs, ConsentRequestOptions, } from './types';
28
+ export type { KernelConfig } from '@c15t/core';
29
+ export { custom, hosted } from '@c15t/core';
30
+ export { offline } from '../transports/offline';
@@ -0,0 +1,5 @@
1
+ export { c15tHandle } from './handle';
2
+ export { loadConsent } from './load-consent';
3
+ export { createSvelteKitConsentRouteHandlers } from './routes';
4
+ export { custom, hosted } from '@c15t/core';
5
+ export { offline } from '../transports/offline';
@@ -0,0 +1,57 @@
1
+ import type { KernelConfig } from '@c15t/core';
2
+ import type { RequestEvent } from '@sveltejs/kit';
3
+ import type { ConsentRequestOptions } from './types';
4
+ /** Options for {@link loadConsent}. */
5
+ export interface LoadConsentOptions extends ConsentRequestOptions {
6
+ /**
7
+ * Hosted mode: the c15t backend base URL, absolute or origin-relative.
8
+ * `loadConsent` calls its `/init` directly.
9
+ */
10
+ backendURL?: string;
11
+ /**
12
+ * Manifest mode: the same-origin init route installed with
13
+ * {@link createSvelteKitConsentRouteHandlers}, e.g. `/api/c15t`.
14
+ * Takes precedence over `backendURL`.
15
+ *
16
+ * Fetched through `event.fetch`, so the request never leaves the process
17
+ * and SvelteKit forwards the page's cookies and headers for you.
18
+ */
19
+ initRoute?: string;
20
+ /** Extra request headers to forward upstream in hosted mode. */
21
+ forwardHeaders?: string[];
22
+ /** Fetch implementation for hosted mode. Defaults to `event.fetch`. */
23
+ fetch?: typeof globalThis.fetch;
24
+ }
25
+ /**
26
+ * Loads the consent prefetch for a request.
27
+ *
28
+ * ```ts
29
+ * // src/routes/+layout.server.ts
30
+ * import { loadConsent } from '@c15t/svelte/kit';
31
+ *
32
+ * export const load = async (event) => ({
33
+ * prefetch: await loadConsent(event, { initRoute: '/api/c15t' }),
34
+ * });
35
+ * ```
36
+ *
37
+ * Then pass it straight through:
38
+ *
39
+ * ```svelte
40
+ * <ConsentManagerProvider prefetch={data.prefetch} mode={hosted({ url: '/api/c15t' })}>
41
+ * ```
42
+ *
43
+ * Modes:
44
+ * - `initRoute` — manifest mode. Resolves against the same-origin init route
45
+ * in-process via `event.fetch`.
46
+ * - `backendURL` — hosted mode. Calls the backend's `/init` directly.
47
+ * - Neither — cookie and request context only. The client still initializes;
48
+ * the server just has nothing extra to seed.
49
+ *
50
+ * Never throws: a failed upstream call degrades to the cookie-only config
51
+ * rather than taking the page down with it.
52
+ *
53
+ * @param event - The SvelteKit request event from `load`.
54
+ * @param options - Mode selection, cookie name, and geo/language overrides.
55
+ * @returns A serializable `KernelConfig` for the provider's `prefetch` prop.
56
+ */
57
+ export declare const loadConsent: (event: RequestEvent, options?: LoadConsentOptions) => Promise<KernelConfig>;
@@ -0,0 +1,144 @@
1
+ import { deferInitGvl, c15tProtocolHeaders, mergeInitOutputIntoKernelConfig, } from '@c15t/core';
2
+ /**
3
+ * `loadConsent` — the `+layout.server.ts` half of the SvelteKit layer.
4
+ *
5
+ * Returns a plain, serializable `KernelConfig` to hand the provider as
6
+ * `prefetch`. With a prefetch in hand the kernel resolves the policy on the
7
+ * server, so the banner is in the first HTML instead of appearing a frame
8
+ * after hydration.
9
+ */
10
+ import { readProducerPolicyContract } from '@c15t/core/transports';
11
+ import { extractConsentRequestInputs, headersToRecord, } from '@c15t/schema/types';
12
+ import { prefetchInitialConsent, readInitialConsentConfig } from '../server';
13
+ const readLocals = function readLocals(event) {
14
+ return event.locals.c15t;
15
+ };
16
+ /**
17
+ * Resolves the base config and request inputs: whatever {@link c15tHandle}
18
+ * already computed for this request, or a fresh cookie + header read when the
19
+ * handle is not installed.
20
+ *
21
+ * Per-call inputs beat the handle's. A route that passes `country` is naming
22
+ * the country for that page, and silently keeping the handle's would render
23
+ * one jurisdiction and forward another.
24
+ */
25
+ const resolveBase = async function resolveBase(event, options) {
26
+ const overridesPerCall = options.cookieName !== undefined ||
27
+ options.country !== undefined ||
28
+ options.language !== undefined ||
29
+ options.region !== undefined;
30
+ const locals = readLocals(event);
31
+ // The handle's cookie name is part of the request context, not an
32
+ // override: a per-call `country` must not silently move the read back
33
+ // to the default `c15t` key and lose the persisted consent.
34
+ const cookieName = options.cookieName ?? locals?.cookieName;
35
+ if (locals && !overridesPerCall) {
36
+ return { ...locals, cookieName };
37
+ }
38
+ const inputs = extractConsentRequestInputs(event.request.headers, {
39
+ country: options.country,
40
+ language: options.language,
41
+ region: options.region,
42
+ });
43
+ const config = await readInitialConsentConfig({
44
+ cookieName,
45
+ country: inputs.country,
46
+ headers: event.request.headers,
47
+ language: inputs.language,
48
+ region: inputs.region,
49
+ });
50
+ return { config, cookieName, inputs };
51
+ };
52
+ /**
53
+ * Request headers for the same-origin init call.
54
+ *
55
+ * `event.fetch` only inherits `cookie` and `authorization`, so the geo,
56
+ * language and GPC context has to be restated explicitly — otherwise the init
57
+ * route resolves a different policy than the page did, and hydration corrects
58
+ * a banner the server already painted.
59
+ */
60
+ const initRequestHeaders = function initRequestHeaders(inputs) {
61
+ const headers = { ...c15tProtocolHeaders };
62
+ if (inputs.country) {
63
+ headers['x-c15t-country'] = inputs.country;
64
+ }
65
+ if (inputs.region) {
66
+ headers['x-c15t-region'] = inputs.region;
67
+ }
68
+ if (inputs.language) {
69
+ headers['accept-language'] = inputs.language;
70
+ }
71
+ if (inputs.gpc !== undefined) {
72
+ headers['sec-gpc'] = inputs.gpc ? '1' : '0';
73
+ }
74
+ return headers;
75
+ };
76
+ /**
77
+ * Loads the consent prefetch for a request.
78
+ *
79
+ * ```ts
80
+ * // src/routes/+layout.server.ts
81
+ * import { loadConsent } from '@c15t/svelte/kit';
82
+ *
83
+ * export const load = async (event) => ({
84
+ * prefetch: await loadConsent(event, { initRoute: '/api/c15t' }),
85
+ * });
86
+ * ```
87
+ *
88
+ * Then pass it straight through:
89
+ *
90
+ * ```svelte
91
+ * <ConsentManagerProvider prefetch={data.prefetch} mode={hosted({ url: '/api/c15t' })}>
92
+ * ```
93
+ *
94
+ * Modes:
95
+ * - `initRoute` — manifest mode. Resolves against the same-origin init route
96
+ * in-process via `event.fetch`.
97
+ * - `backendURL` — hosted mode. Calls the backend's `/init` directly.
98
+ * - Neither — cookie and request context only. The client still initializes;
99
+ * the server just has nothing extra to seed.
100
+ *
101
+ * Never throws: a failed upstream call degrades to the cookie-only config
102
+ * rather than taking the page down with it.
103
+ *
104
+ * @param event - The SvelteKit request event from `load`.
105
+ * @param options - Mode selection, cookie name, and geo/language overrides.
106
+ * @returns A serializable `KernelConfig` for the provider's `prefetch` prop.
107
+ */
108
+ export const loadConsent = async function loadConsent(event, options = {}) {
109
+ const { config, inputs, cookieName } = await resolveBase(event, options);
110
+ if (options.initRoute) {
111
+ const forwarded = initRequestHeaders(inputs);
112
+ try {
113
+ const response = await event.fetch(options.initRoute, {
114
+ headers: forwarded,
115
+ });
116
+ if (!response.ok) {
117
+ return config;
118
+ }
119
+ const payload = (await response.json());
120
+ return mergeInitOutputIntoKernelConfig(config, deferInitGvl(payload, options.initRoute, 'init', forwarded), {
121
+ ...headersToRecord(event.request.headers),
122
+ ...forwarded,
123
+ }, { producerContract: readProducerPolicyContract(response.headers) });
124
+ }
125
+ catch {
126
+ // Fail soft: the client re-runs init on hydration.
127
+ return config;
128
+ }
129
+ }
130
+ if (options.backendURL) {
131
+ return prefetchInitialConsent({
132
+ backendURL: options.backendURL,
133
+ cookieName,
134
+ country: inputs.country,
135
+ fetch: options.fetch,
136
+ forwardHeaders: options.forwardHeaders,
137
+ frameworkFetch: event.fetch,
138
+ headers: event.request.headers,
139
+ language: inputs.language,
140
+ region: inputs.region,
141
+ });
142
+ }
143
+ return config;
144
+ };
@@ -0,0 +1,46 @@
1
+ import type { ConsentManifestGVLReference, GlobalVendorList } from '@c15t/schema/types';
2
+ import type { RequestEvent, RequestHandler } from '@sveltejs/kit';
3
+ import type { ConsentManifestOptions } from './types';
4
+ /**
5
+ * Hands a promise to the `waitUntil` a SvelteKit adapter exposes on
6
+ * `event.platform.context` (Cloudflare Workers and Pages, Vercel edge), so a
7
+ * background refresh outlives the response on runtimes that would cancel
8
+ * it. A no-op where the adapter provides none.
9
+ */
10
+ export declare const waitUntilFromEvent: (revalidation: Promise<void>, event: RequestEvent) => void;
11
+ /** Options for {@link createSvelteKitConsentRouteHandlers}. */
12
+ export interface SvelteKitConsentRouteOptions extends ConsentManifestOptions {
13
+ /**
14
+ * Fetches the Global Vendor List when the resolved policy is IAB.
15
+ * Defaults to a plain `GET` of the manifest's GVL reference.
16
+ */
17
+ fetchGvl?: (input: {
18
+ reference: ConsentManifestGVLReference;
19
+ language: string;
20
+ fetch: typeof globalThis.fetch;
21
+ }) => Promise<GlobalVendorList | null>;
22
+ }
23
+ /**
24
+ * Creates the SvelteKit request handlers for manifest mode.
25
+ *
26
+ * Two shapes are supported. A single catch-all route:
27
+ *
28
+ * ```ts
29
+ * // src/routes/api/c15t/[...path]/+server.ts
30
+ * import { createSvelteKitConsentRouteHandlers } from '@c15t/svelte/kit';
31
+ *
32
+ * export const { GET } = createSvelteKitConsentRouteHandlers({
33
+ * backendURL: process.env.C15T_BACKEND_URL,
34
+ * });
35
+ * ```
36
+ *
37
+ * …or one file per route, using `init` and `manifest` directly.
38
+ *
39
+ * @param options - Manifest source, fetch implementation, GVL fetcher.
40
+ * @returns `init`, `manifest`, and a `GET` that dispatches between them.
41
+ */
42
+ export declare const createSvelteKitConsentRouteHandlers: (options?: SvelteKitConsentRouteOptions) => {
43
+ GET: RequestHandler;
44
+ init: RequestHandler;
45
+ manifest: RequestHandler;
46
+ };