@c15t/scripts 3.0.0-alpha.1 → 3.0.0-alpha.2

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 (73) hide show
  1. package/AGENTS.md +4 -0
  2. package/README.md +3 -3
  3. package/dist/e2e-test-utils.js +5 -3
  4. package/dist/events.js +218 -0
  5. package/dist/registry.js +30 -0
  6. package/dist/vendors/ads-and-pixels/pinterest-tag.js +123 -0
  7. package/dist/vendors/analytics/google-tag.js +14 -2
  8. package/dist/vendors/analytics/one-dollar-stats.js +30 -0
  9. package/dist/vendors/analytics/segment.js +10 -1
  10. package/dist/vendors/functional/front-chat.js +64 -0
  11. package/dist/vendors/tag-managers/google-tag-manager.js +17 -3
  12. package/dist-types/events.d.ts +46 -0
  13. package/dist-types/registry.d.ts +27 -0
  14. package/dist-types/vendors/ads-and-pixels/pinterest-tag.d.ts +295 -0
  15. package/dist-types/vendors/analytics/google-tag.d.ts +3 -1
  16. package/dist-types/vendors/analytics/one-dollar-stats.d.ts +39 -0
  17. package/dist-types/vendors/analytics/segment.d.ts +7 -1
  18. package/dist-types/vendors/functional/front-chat.d.ts +62 -0
  19. package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +3 -1
  20. package/docs/README.md +4 -0
  21. package/docs/customization/overview.md +4 -3
  22. package/docs/customization/recipes.md +4 -2
  23. package/docs/customization/tokens.md +66 -3
  24. package/docs/frameworks/javascript/script-loader.md +6 -0
  25. package/docs/frameworks/next/script-loader.md +18 -12
  26. package/docs/frameworks/react/script-loader.md +6 -0
  27. package/docs/guides/consent-state.md +327 -0
  28. package/docs/guides/shared-consent-controls.md +158 -0
  29. package/docs/integrations/adobe-analytics.md +1 -1
  30. package/docs/integrations/ahrefs-analytics.md +1 -1
  31. package/docs/integrations/amplitude.md +1 -1
  32. package/docs/integrations/clearbit.md +1 -1
  33. package/docs/integrations/cloudflare-web-analytics.md +1 -1
  34. package/docs/integrations/cloudflare-zaraz.md +1 -1
  35. package/docs/integrations/crisp.md +1 -1
  36. package/docs/integrations/databuddy.md +1 -1
  37. package/docs/integrations/fathom-analytics.md +1 -1
  38. package/docs/integrations/front-chat.md +322 -0
  39. package/docs/integrations/google-maps.md +1 -1
  40. package/docs/integrations/google-tag-manager.md +1 -1
  41. package/docs/integrations/google-tag.md +1 -1
  42. package/docs/integrations/granular-consent.md +3 -1
  43. package/docs/integrations/heap.md +1 -1
  44. package/docs/integrations/hightouch.md +1 -1
  45. package/docs/integrations/hotjar.md +1 -1
  46. package/docs/integrations/intercom.md +1 -1
  47. package/docs/integrations/linkedin-insights.md +1 -1
  48. package/docs/integrations/logrocket.md +1 -1
  49. package/docs/integrations/matomo-analytics.md +1 -1
  50. package/docs/integrations/meta-pixel.md +1 -1
  51. package/docs/integrations/microsoft-clarity.md +1 -1
  52. package/docs/integrations/microsoft-uet.md +1 -1
  53. package/docs/integrations/mixpanel-analytics.md +1 -1
  54. package/docs/integrations/one-dollar-stats.md +305 -0
  55. package/docs/integrations/openai-pixel.md +1 -1
  56. package/docs/integrations/overview.md +17 -14
  57. package/docs/integrations/pinterest-tag.md +321 -0
  58. package/docs/integrations/pirsch.md +1 -1
  59. package/docs/integrations/plausible-analytics.md +1 -1
  60. package/docs/integrations/posthog.md +1 -1
  61. package/docs/integrations/promptwatch.md +1 -1
  62. package/docs/integrations/reddit-pixel.md +1 -1
  63. package/docs/integrations/rudderstack.md +1 -1
  64. package/docs/integrations/rybbit-analytics.md +1 -1
  65. package/docs/integrations/segment.md +1 -1
  66. package/docs/integrations/snapchat-pixel.md +1 -1
  67. package/docs/integrations/tiktok-pixel.md +1 -1
  68. package/docs/integrations/umami-analytics.md +1 -1
  69. package/docs/integrations/vercel-analytics.md +1 -1
  70. package/docs/integrations/x-pixel.md +1 -1
  71. package/docs/integrations/youtube.md +1 -1
  72. package/docs/upgrade-v3.md +129 -1
  73. package/package.json +25 -2
@@ -0,0 +1,321 @@
1
+ ---
2
+ title: Pinterest Tag
3
+ description: Configure the Pinterest Tag with c15t v3, track typed events and
4
+ verify marketing permission, revocation and reload.
5
+ group: integrations
6
+ ---
7
+
8
+ ## Configure Pinterest Tag
9
+
10
+ Use the numeric tag ID from Pinterest Ads Manager. The helper recreates
11
+ Pinterest's base code: it defines the `pintrk` queue, queues `load`,
12
+ `setconsent(true)` and a page visit, then loads `core.js`.
13
+
14
+ | Package manager | Command |
15
+ | :-------------- | :-------------------------- |
16
+ | npm | `npm install @c15t/scripts` |
17
+ | pnpm | `pnpm add @c15t/scripts` |
18
+ | yarn | `yarn add @c15t/scripts` |
19
+ | bun | `bun add @c15t/scripts` |
20
+
21
+ ```ts title="src/consent-scripts.ts"
22
+ import { pinterestTag } from '@c15t/scripts/pinterest-tag';
23
+
24
+ export const scripts = [pinterestTag({ tagId: 'YOUR_TAG_ID' })];
25
+ ```
26
+
27
+ ## Register the scripts
28
+
29
+ Complete your [framework quickstart](https://c15t.com/docs/frameworks) first. Keep its Inth
30
+ endpoint, policy, styles and consent UI. Remove the vendor's original script,
31
+ SDK initializer or tag-manager entry so c15t owns loading once.
32
+
33
+ The `scripts` export in `src/consent-scripts.ts` is a configuration, not an
34
+ initializer. Add it to your existing consent owner using the registration point
35
+ below. These are partial edits to that owner, not additional providers.
36
+
37
+ **Next.js**
38
+
39
+ Import the configuration into the client boundary from your router guide:
40
+
41
+ ```ts
42
+ import { ConsentRoot } from 'c15t/next';
43
+ import { scripts } from './consent-scripts';
44
+ ```
45
+
46
+ Keep the server-resolved `state` and shared `consentConfig` from your
47
+ router guide. Its manifest, init and save URLs stay in effect. Add
48
+ `scripts` as a top-level prop on the existing root:
49
+
50
+ ```tsx
51
+ <ConsentRoot state={state} config={consentConfig} scripts={scripts}>
52
+ {children}
53
+ </ConsentRoot>
54
+ ```
55
+
56
+ For a Pages Router or static-export setup using `ConsentProvider`, add
57
+ `scripts` to its existing `options` instead. Keep the router-specific setup
58
+ from [Next.js script loading](../frameworks/next/script-loader.md).
59
+
60
+ **TanStack Start**
61
+
62
+ In your existing root route component, import the scripts alongside
63
+ `ConsentRoot`. Keep the server loader from the [TanStack Start quickstart](https://c15t.com/docs/frameworks/tanstack-start/quickstart).
64
+
65
+ ```tsx
66
+ import { Outlet } from '@tanstack/react-router';
67
+ import { ConsentRoot } from 'c15t/tanstack-start';
68
+ import { scripts } from '../consent-scripts';
69
+
70
+ function Root() {
71
+ const state = Route.useLoaderData();
72
+ return (
73
+ <ConsentRoot state={state} backendURL={backendURL} initRoute={false} scripts={scripts}>
74
+ <Outlet />
75
+ {/* Keep your consent banner, dialog and preferences link here. */}
76
+ </ConsentRoot>
77
+ );
78
+ }
79
+ ```
80
+
81
+ This edits the existing route. `Route` and `backendURL` come from its setup;
82
+ keep the document shell and head components if they are part of your root.
83
+ `initRoute={false}` keeps the quickstart's direct-backend initialization.
84
+ If your app mounts a consent server route, retain its existing `initRoute`
85
+ instead. Do not return script callbacks from a server function or route loader.
86
+
87
+ **React**
88
+
89
+ Import the scripts into your existing provider component:
90
+
91
+ ```ts
92
+ import { ConsentProvider } from 'c15t/react';
93
+ import { scripts } from './consent-scripts';
94
+ ```
95
+
96
+ Keep the existing options and add `scripts`:
97
+
98
+ ```tsx
99
+ <ConsentProvider options={{ ...consentOptions, scripts }}>
100
+ {children}
101
+ </ConsentProvider>
102
+ ```
103
+
104
+ Here `consentOptions` is your existing configuration, including
105
+ `mode: hosted({ url: backendURL })`. Keep the banner, dialog and preferences
106
+ link inside the provider. See [React script loading](../frameworks/react/script-loader.md).
107
+
108
+ **Nuxt**
109
+
110
+ Attach one loader from the root `app.vue`, after the Nuxt module has
111
+ started its browser runtime. This keeps vendor callbacks in application code rather
112
+ than serialized `nuxt.config.ts` runtime configuration.
113
+
114
+ ```vue title="app/app.vue"
115
+ <script setup lang="ts">
116
+ import { onUnmounted } from 'vue';
117
+ import { createScriptLoader } from 'c15t/modules/script-loader';
118
+ import { scripts } from '../src/consent-scripts';
119
+
120
+ const nuxtApp = useNuxtApp();
121
+ const kernel = useConsentKernel();
122
+ let loader: ReturnType<typeof createScriptLoader> | undefined;
123
+
124
+ const removeMountedHook = nuxtApp.hook('app:mounted', () => {
125
+ loader = createScriptLoader({ kernel, scripts });
126
+ });
127
+ onUnmounted(() => {
128
+ removeMountedHook();
129
+ loader?.dispose();
130
+ });
131
+ </script>
132
+
133
+ <template>
134
+ <ConsentRoot />
135
+ <NuxtPage />
136
+ </template>
137
+ ```
138
+
139
+ Merge the setup code into your root and retain its footer and preferences
140
+ link. `useConsentKernel` is auto-imported by the c15t Nuxt module. Adjust the
141
+ relative script import if your `app.vue` is at the project root. This loader
142
+ waits until the module has applied browser persistence and privacy signals,
143
+ then reads the current snapshot and observes future changes. Do not also register these scripts
144
+ in another loader. See the [Nuxt quickstart](https://c15t.com/docs/frameworks/nuxt/quickstart).
145
+
146
+ **Vue**
147
+
148
+ Use the kernel already provided by the Vue plugin. Merge this setup into
149
+ `App.vue`, whose lifetime covers the application:
150
+
151
+ ```vue title="src/App.vue"
152
+ <script setup lang="ts">
153
+ import { onMounted, onUnmounted } from 'vue';
154
+ import { createScriptLoader } from 'c15t/modules/script-loader';
155
+ import { useConsentKernel } from 'c15t/vue/vue-plugin';
156
+ import ConsentRoot from 'c15t/vue/consent-root';
157
+ import { scripts } from './consent-scripts';
158
+
159
+ const kernel = useConsentKernel();
160
+ let loader: ReturnType<typeof createScriptLoader> | undefined;
161
+
162
+ onMounted(() => {
163
+ loader = createScriptLoader({ kernel, scripts });
164
+ });
165
+ onUnmounted(() => loader?.dispose());
166
+ </script>
167
+
168
+ <template>
169
+ <ConsentRoot />
170
+ <main>Your application</main>
171
+ </template>
172
+ ```
173
+
174
+ Keep your existing page content and preferences link. The plugin still owns
175
+ the kernel and persistence; this component owns only the vendor loader.
176
+ Do not register the same scripts in plugin configuration as well. See the
177
+ [Vue quickstart](https://c15t.com/docs/frameworks/vue/quickstart).
178
+
179
+ **Astro**
180
+
181
+ Point the existing Astro integration at a client module. Keep its `mode`,
182
+ `ui` and framework integration from the [Astro quickstart](https://c15t.com/docs/frameworks/astro/quickstart).
183
+ Import `fileURLToPath` in your Astro configuration:
184
+
185
+ ```js title="astro.config.mjs"
186
+ import { fileURLToPath } from 'node:url';
187
+ ```
188
+
189
+ Add this option to the existing `c15t({ ... })` call. Resolve the path from
190
+ the configuration file because Astro injects the import into a virtual module:
191
+
192
+ ```js
193
+ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)),
194
+ ```
195
+
196
+ Export the scripts from that module:
197
+
198
+ ```ts title="src/c15t.client.ts"
199
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
200
+ import { scripts } from './consent-scripts';
201
+
202
+ export default { scripts } satisfies C15tClientOptionsExtension;
203
+ ```
204
+
205
+ The integration passes this extension to its shared browser runtime. Vendor
206
+ helpers contain callbacks, so do not put them in the serialized `scripts`
207
+ option in `astro.config.mjs`. Keep one runtime across consent islands and
208
+ `ClientRouter` navigation.
209
+
210
+ **Svelte**
211
+
212
+ Import the scripts in the component that owns your existing provider and
213
+ pass them as a top-level prop:
214
+
215
+ ```svelte title="src/App.svelte"
216
+ <script lang="ts">
217
+ import { ConsentManagerProvider, hosted } from '@c15t/svelte';
218
+ import { scripts } from './consent-scripts';
219
+
220
+ const backendURL = import.meta.env.VITE_C15T_BACKEND_URL;
221
+ if (!backendURL) throw new Error('Set VITE_C15T_BACKEND_URL');
222
+ const mode = hosted({ url: backendURL });
223
+ </script>
224
+
225
+ <ConsentManagerProvider {mode} {scripts}>
226
+ <!-- Keep your application, consent UI and preferences link here. -->
227
+ </ConsentManagerProvider>
228
+ ```
229
+
230
+ Retain the styles and consent UI from the [Svelte quickstart](https://c15t.com/docs/frameworks/svelte/quickstart).
231
+ The provider owns the loader and disposes it on unmount.
232
+
233
+ **SvelteKit**
234
+
235
+ Add the scripts to the existing root layout provider. Keep the server load
236
+ and its serializable prefetch data from the [SvelteKit quickstart](https://c15t.com/docs/frameworks/sveltekit/quickstart).
237
+
238
+ ```svelte title="src/routes/+layout.svelte"
239
+ <script lang="ts">
240
+ import { ConsentManagerProvider, hosted } from '@c15t/svelte';
241
+ import { scripts } from '../consent-scripts';
242
+
243
+ let { children, data } = $props();
244
+ const mode = hosted({ url: data.backendURL });
245
+ </script>
246
+
247
+ <ConsentManagerProvider {mode} {scripts} prefetch={data.prefetch}>
248
+ {@render children()}
249
+ <!-- Keep your consent UI and preferences link here. -->
250
+ </ConsentManagerProvider>
251
+ ```
252
+
253
+ Import vendor helpers in the layout component, not in `+layout.server.ts`.
254
+ For static hosting, keep your browser-only `mode` setup and omit request
255
+ prefetch; the `scripts` prop stays the same. If you pass an externally owned
256
+ `runtime` to the provider, register scripts when creating that runtime instead.
257
+
258
+ **JavaScript**
259
+
260
+ Attach the loader to your existing kernel before calling
261
+ `kernel.commands.init()`:
262
+
263
+ ```ts
264
+ import { createScriptLoader } from 'c15t/modules/script-loader';
265
+ import { scripts } from './consent-scripts';
266
+
267
+ const loader = createScriptLoader({ kernel, scripts });
268
+ ```
269
+
270
+ Call `loader.dispose()` when that application instance is destroyed.
271
+ `kernel` is the hosted kernel from your quickstart. A provider-owned kernel
272
+ already has a loader; do not attach a second one. See
273
+ [JavaScript script loading](../frameworks/javascript/script-loader.md).
274
+
275
+ Pinterest's `<noscript>` image fallback is not emitted. It fires without
276
+ JavaScript, so c15t cannot gate it.
277
+
278
+ ## Options
279
+
280
+ | Option | Behavior |
281
+ | ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
282
+ | `tagId` | Required Pinterest Tag ID. |
283
+ | `loadOptions` | Third argument to `pintrk('load')`, such as `em` for enhanced match. Pass user data only with the permission it needs. |
284
+ | `trackPageVisit` | Queues `pintrk('page')` during setup. Defaults to `true`. |
285
+ | `scriptUrl` | Defaults to `https://s.pinimg.com/ct/core.js`. |
286
+
287
+ ## Track events
288
+
289
+ `pinterestTagEvent()` sends a typed `pintrk('track')` call. It covers Pinterest's
290
+ 20 event types and accepts user-defined names, which Pinterest uses for audience
291
+ targeting only. Put product details in `line_items`.
292
+
293
+ ```ts
294
+ import { pinterestTagEvent } from '@c15t/scripts/pinterest-tag';
295
+
296
+ pinterestTagEvent('checkout', {
297
+ currency: 'USD',
298
+ event_id: 'order-123',
299
+ line_items: [{ product_id: '1414', product_price: 99.99, product_quantity: 1 }],
300
+ order_id: 'order-123',
301
+ value: 99.99,
302
+ });
303
+ ```
304
+
305
+ Set `event_id` to deduplicate against the Conversions API. An optional third
306
+ argument receives Pinterest's `(didInit, error)` result. The helper does nothing
307
+ until the tag has loaded, and it checks API availability, not consent.
308
+
309
+ ## Consent behavior
310
+
311
+ The first load waits for marketing permission. On revocation the helper keeps
312
+ the tag and calls `pintrk('setconsent', false)`, which Pinterest documents as
313
+ stopping events and clearing its first-party cookies. c15t then reloads the page.
314
+ A later grant calls `setconsent(true)`.
315
+
316
+ ## Verify the integration
317
+
318
+ Use a fresh session with an opt-in policy and confirm `core.js` is absent. Grant
319
+ `marketing` and check the page visit in Pinterest's Tag Helper. Revoke it and
320
+ confirm the page reloads and no further events are sent. Follow the
321
+ [consent verification guide](../guides/verify-consent.md).
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -206,7 +206,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
206
206
  Export the scripts from that module:
207
207
 
208
208
  ```ts title="src/c15t.client.ts"
209
- import type { C15tClientOptionsExtension } from '@c15t/astro';
209
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
210
210
  import { scripts } from './consent-scripts';
211
211
 
212
212
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -203,7 +203,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
203
203
  Export the scripts from that module:
204
204
 
205
205
  ```ts title="src/c15t.client.ts"
206
- import type { C15tClientOptionsExtension } from '@c15t/astro';
206
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
207
207
  import { scripts } from './consent-scripts';
208
208
 
209
209
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -194,7 +194,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
194
194
  Export the scripts from that module:
195
195
 
196
196
  ```ts title="src/c15t.client.ts"
197
- import type { C15tClientOptionsExtension } from '@c15t/astro';
197
+ import type { C15tClientOptionsExtension } from 'c15t/astro';
198
198
  import { scripts } from './consent-scripts';
199
199
 
200
200
  export default { scripts } satisfies C15tClientOptionsExtension;
@@ -176,7 +176,7 @@ Add this component to pages using your consent-enabled base layout:
176
176
  <c15t-consent-embed style="display: block"></c15t-consent-embed>
177
177
 
178
178
  <script>
179
- import { getConsentClient } from '@c15t/astro/client';
179
+ import { getConsentClient } from 'c15t/astro/client';
180
180
  import { mountConsentEmbed } from '../consent-embed';
181
181
 
182
182
  class ConsentEmbed extends HTMLElement {
@@ -87,6 +87,115 @@ be true before a visitor acts. A notice dismissal updates `noticeDismissal` and
87
87
  does not record consent. Global Privacy Control updates privacy signals and
88
88
  configured opt-out directives without turning a browser signal into a choice.
89
89
 
90
+ ## Replace `useConsentManager()`
91
+
92
+ `useConsentManager()` is gone from `c15t/react`, `c15t/next`,
93
+ `c15t/tanstack-start` and their `/headless` entries. It subscribed to the whole
94
+ consent snapshot, so every component that called it re-rendered on every
95
+ change, including changes to categories it never read. Call one hook per field
96
+ instead; each re-renders only when its own value changes.
97
+
98
+ Before, in v2 and earlier v3 alphas:
99
+
100
+ ```tsx title="components/marketing-banner.tsx"
101
+ import { useConsentManager } from 'c15t/react';
102
+
103
+ export function MarketingBanner() {
104
+ const { activeUI, has, saveConsents } = useConsentManager();
105
+ if (activeUI !== 'banner' || has('marketing')) {
106
+ return null;
107
+ }
108
+ return <button type="button" onClick={() => void saveConsents('all')}>Accept</button>;
109
+ }
110
+ ```
111
+
112
+ After:
113
+
114
+ ```tsx title="components/marketing-banner.tsx"
115
+ import { useActiveUI, useConsent } from 'c15t/react';
116
+ import { useHeadlessConsentUI } from 'c15t/react/headless';
117
+
118
+ export function MarketingBanner() {
119
+ const activeUI = useActiveUI();
120
+ const marketing = useConsent('marketing');
121
+ const { performAction } = useHeadlessConsentUI();
122
+ if (activeUI !== 'banner' || marketing) {
123
+ return null;
124
+ }
125
+ return <button type="button" onClick={() => void performAction('accept')}>Accept</button>;
126
+ }
127
+ ```
128
+
129
+ Import hooks from the same entry you used for `useConsentManager()`:
130
+ `c15t/next` and `c15t/next/headless` in Next.js, `c15t/tanstack-start` and
131
+ `c15t/tanstack-start/headless` in TanStack Start.
132
+
133
+ | `useConsentManager()` field | v3 replacement |
134
+ | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
135
+ | `activeUI` | `useActiveUI()`. It returns `null` before the kernel picks a surface; the old field reported `'none'`. |
136
+ | `setActiveUI(ui)` | `useSetActiveUI()` |
137
+ | `has(category)` | `useConsent(category)`, one call per category at the top of the component |
138
+ | `consents` | `useConsents()` |
139
+ | `effectivePermissions` | `useEffectivePermissions()` |
140
+ | `explicitChoice` | `useExplicitChoice()` |
141
+ | `promptRequirement` | `usePromptRequirement()` |
142
+ | `noticeDismissal` | `useNoticeDismissal()` |
143
+ | `privacySignals` | `usePrivacySignals()` |
144
+ | `optOutDirectives` | `useOptOutDirectives()` |
145
+ | `restrictions` | `useRestrictions()` |
146
+ | `resolution` | `usePolicyResolution()` |
147
+ | `policyRule` | `usePolicyRule()` |
148
+ | `policyCategories` | `usePolicyCategories()`. The old list started with `'necessary'`; this one does not. |
149
+ | `policyScopeMode` | `usePolicyScopeMode()` |
150
+ | `policyBanner` | `usePromptPresentation()` |
151
+ | `policyDialog` | `usePreferencesPresentation()` |
152
+ | `model` | `useModel()`. It returns `null` while no policy matches; the old field reported `'opt-in'`. |
153
+ | `branding` | `useBranding()`. It returns `null` when unset; the old field reported `'c15t'`. |
154
+ | `iab` | `useIABSnapshot()` |
155
+ | `vendors` | `useDeclaredVendors()` |
156
+ | `vendorChoice` | `useVendorChoice()` |
157
+ | `getDisplayedVendors(category)` | `useDeclaredVendors()`, filtered to vendors whose category condition names the category |
158
+ | `subscribeToConsentChanges(listener)` | `useSubscribeToConsentChanges()`, or the provider's `onPermissionsChanged` callback |
159
+ | `updateConsentCategories(categories)` | `useRegisterConsentCategories()` |
160
+ | `translationConfig` | `useTranslations()` for the active strings |
161
+ | `selectedConsents`, `selectedConsentTypes` | `useConsentDraft().values` |
162
+ | `setSelectedConsent(name, value)` | `useConsentDraft().set(name, value)` |
163
+ | `selectedVendors` | `useConsentDraft().vendors`, or `useVendorDraft().vendors` |
164
+ | `setSelectedVendor(id, granted)` | `useConsentDraft().setVendor(id, granted)` |
165
+ | `resetDraft()` | `useConsentDraft().reset()` |
166
+ | `draftIsStale` | `useConsentDraft().isStale` |
167
+ | `consentCategories`, `consentTypes`, `getDisplayedConsents()` | `useConsentDraft().displayedCategories`, with labels from `useTranslations().consentTypes` |
168
+ | `saveConsents('all')` | `useHeadlessConsentUI().performAction('accept')` |
169
+ | `saveConsents('necessary')` | `useHeadlessConsentUI().performAction('reject')` |
170
+ | `saveConsents('custom')` | `useHeadlessConsentUI().performAction('save')` |
171
+ | `manager` | Nothing. It was always `null` in v3. |
172
+
173
+ The old hook kept one private draft per component, shared by its selection and
174
+ its save. `useConsentDraft()` and `useHeadlessConsentUI()` read the nearest
175
+ `ConsentDraftProvider` instead. When one component stages choices and another
176
+ saves them, or one component calls both hooks, render them inside the same
177
+ `ConsentDraftProvider`; without one, each hook keeps its own draft and a custom
178
+ save commits nothing you staged. `ConsentWidget` already provides one.
179
+
180
+ `useHeadlessConsentUI()` saves the way the stock buttons do: it closes the
181
+ surface after a successful save and refuses a draft that the policy made stale.
182
+ `useSaveConsents()` calls the kernel directly and does neither.
183
+
184
+ The CLI rewrites the common destructuring forms for you:
185
+
186
+ ```bash
187
+ c15t codemods use-consent-manager-to-hooks --dry-run --json
188
+ ```
189
+
190
+ It replaces each field that has a one-hook equivalent, turns `has('marketing')`
191
+ calls with a literal category into `useConsent('marketing')`, and maps
192
+ `saveConsents('all' | 'necessary' | 'custom')` calls to
193
+ `useHeadlessConsentUI().saveCustomPreferences()`. Fields it cannot rewrite stay
194
+ on a `useConsentManager()` call under a `TODO(c15t v3)` comment that names the
195
+ replacement, so the build fails at each place that needs manual work. It also
196
+ marks components that now need a shared `ConsentDraftProvider`. Review the
197
+ result, then run it without `--dry-run`.
198
+
90
199
  ## Replace choice callbacks
91
200
 
92
201
  ```tsx
@@ -191,7 +300,7 @@ Notice acknowledgement uses `common.acknowledge`, falling back to
191
300
 
192
301
  ```astro
193
302
  ---
194
- import ConsentBanner from '@c15t/astro/components/consent-banner.astro';
303
+ import ConsentBanner from 'c15t/astro/components/consent-banner.astro';
195
304
  ---
196
305
 
197
306
  <ConsentBanner dismissButtonText="Got it" />
@@ -277,6 +386,25 @@ translation keys, `--frame-*` CSS custom properties and
277
386
  `data-testid="frame-placeholder"`, so custom copy, styles and tests continue
278
387
  to apply.
279
388
 
389
+ ## Split dialog and widget entries are deferred
390
+
391
+ `c15t/react/consent-dialog` and `c15t/react/consent-widget` (and their
392
+ `@c15t/react/*` equivalents) now export the same deferred `ConsentDialog` and
393
+ `ConsentWidget` as `c15t/react`. The dialog's code loads when it first opens
394
+ instead of with every page. `<ConsentDialog />`, `<ConsentWidget />` and the
395
+ `ConsentDialog.<Part>` properties need no change.
396
+
397
+ The two entries no longer export the individual parts. Import those from the
398
+ component entries, which keep the old, eagerly bundled exports:
399
+
400
+ | Before | After |
401
+ | --------------------------------------------------------------- | -------------------------------------------------------------------------- |
402
+ | `import { Card, Header } from 'c15t/react/consent-dialog'` | `import { Card, Header } from 'c15t/react/components/consent-dialog'` |
403
+ | `import { Accordion, Switch } from 'c15t/react/consent-widget'` | `import { Accordion, Switch } from 'c15t/react/components/consent-widget'` |
404
+
405
+ To keep the dialog in the first load so its first open needs no download,
406
+ import `ConsentDialog` from `c15t/react/components/consent-dialog`.
407
+
280
408
  ## Next.js RSC banner removal
281
409
 
282
410
  The `@c15t/nextjs/rsc` entry (`c15t/next/rsc`) and its `RscConsentBanner`,