@c15t/scripts 3.0.0-alpha.0 → 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.
- package/AGENTS.md +7 -0
- package/README.md +4 -3
- package/dist/e2e-test-utils.js +5 -3
- package/dist/engine/runtime.js +14 -3
- package/dist/events.js +218 -0
- package/dist/registry.js +40 -0
- package/dist/vendors/ads-and-pixels/pinterest-tag.js +123 -0
- package/dist/vendors/analytics/google-tag.js +14 -2
- package/dist/vendors/analytics/microsoft-clarity.js +4 -1
- package/dist/vendors/analytics/one-dollar-stats.js +30 -0
- package/dist/vendors/analytics/segment.js +10 -1
- package/dist/vendors/functional/front-chat.js +64 -0
- package/dist/vendors/tag-managers/cloudflare-zaraz.js +98 -0
- package/dist/vendors/tag-managers/google-tag-manager.js +17 -3
- package/dist-types/__tests__/helpers.d.ts +2 -2
- package/dist-types/engine/compile.d.ts +1 -1
- package/dist-types/engine/runtime.d.ts +1 -1
- package/dist-types/events.d.ts +46 -0
- package/dist-types/registry.d.ts +36 -0
- package/dist-types/resolve.d.ts +1 -1
- package/dist-types/vendors/_shared/install-builders.d.ts +1 -1
- package/dist-types/vendors/ads-and-pixels/pinterest-tag.d.ts +295 -0
- package/dist-types/vendors/analytics/adobe-analytics.d.ts +1 -1
- package/dist-types/vendors/analytics/google-tag.d.ts +3 -1
- package/dist-types/vendors/analytics/matomo-analytics.d.ts +1 -1
- package/dist-types/vendors/analytics/one-dollar-stats.d.ts +39 -0
- package/dist-types/vendors/analytics/segment.d.ts +7 -1
- package/dist-types/vendors/functional/front-chat.d.ts +62 -0
- package/dist-types/vendors/tag-managers/cloudflare-zaraz.d.ts +39 -0
- package/dist-types/vendors/tag-managers/google-tag-manager.d.ts +3 -1
- package/docs/README.md +7 -0
- package/docs/customization/overview.md +4 -3
- package/docs/customization/recipes.md +4 -2
- package/docs/customization/tokens.md +66 -3
- package/docs/frameworks/javascript/script-loader.md +53 -0
- package/docs/frameworks/next/script-loader.md +60 -12
- package/docs/frameworks/react/script-loader.md +14 -0
- package/docs/guides/consent-state.md +327 -0
- package/docs/guides/deployment-modes.md +12 -0
- package/docs/guides/shared-consent-controls.md +158 -0
- package/docs/integrations/adobe-analytics.md +1 -1
- package/docs/integrations/ahrefs-analytics.md +1 -1
- package/docs/integrations/amplitude.md +1 -1
- package/docs/integrations/building-integrations.md +5 -0
- package/docs/integrations/clear-on-revocation.md +167 -0
- package/docs/integrations/clearbit.md +1 -1
- package/docs/integrations/cloudflare-web-analytics.md +1 -1
- package/docs/integrations/cloudflare-zaraz.md +399 -0
- package/docs/integrations/crisp.md +1 -1
- package/docs/integrations/databuddy.md +1 -1
- package/docs/integrations/fathom-analytics.md +1 -1
- package/docs/integrations/front-chat.md +322 -0
- package/docs/integrations/google-maps.md +21 -21
- package/docs/integrations/google-tag-manager.md +1 -1
- package/docs/integrations/google-tag.md +1 -1
- package/docs/integrations/granular-consent.md +210 -0
- package/docs/integrations/heap.md +1 -1
- package/docs/integrations/hightouch.md +1 -1
- package/docs/integrations/hotjar.md +1 -1
- package/docs/integrations/intercom.md +1 -1
- package/docs/integrations/linkedin-insights.md +1 -1
- package/docs/integrations/logrocket.md +1 -1
- package/docs/integrations/matomo-analytics.md +1 -1
- package/docs/integrations/meta-pixel.md +1 -1
- package/docs/integrations/microsoft-clarity.md +1 -1
- package/docs/integrations/microsoft-uet.md +1 -1
- package/docs/integrations/mixpanel-analytics.md +1 -1
- package/docs/integrations/one-dollar-stats.md +305 -0
- package/docs/integrations/openai-pixel.md +1 -1
- package/docs/integrations/overview.md +22 -18
- package/docs/integrations/pinterest-tag.md +321 -0
- package/docs/integrations/pirsch.md +1 -1
- package/docs/integrations/plausible-analytics.md +1 -1
- package/docs/integrations/posthog.md +1 -1
- package/docs/integrations/promptwatch.md +1 -1
- package/docs/integrations/reddit-pixel.md +1 -1
- package/docs/integrations/rudderstack.md +1 -1
- package/docs/integrations/rybbit-analytics.md +1 -1
- package/docs/integrations/segment.md +1 -1
- package/docs/integrations/snapchat-pixel.md +1 -1
- package/docs/integrations/tiktok-pixel.md +1 -1
- package/docs/integrations/umami-analytics.md +1 -1
- package/docs/integrations/vercel-analytics.md +1 -1
- package/docs/integrations/x-pixel.md +1 -1
- package/docs/integrations/youtube.md +27 -22
- package/docs/upgrade-v3.md +176 -1
- package/package.json +30 -2
- package/readme.json +0 -19
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Front Chat
|
|
3
|
+
description: Load the Front Chat widget with functionality permission, forward
|
|
4
|
+
CSP nonces and clear the session on revocation.
|
|
5
|
+
group: integrations
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Configure Front Chat
|
|
9
|
+
|
|
10
|
+
Copy the `chatId` from the widget snippet in your Front Chat channel's
|
|
11
|
+
**Installation** tab. The helper loads Front's SDK once functionality permission
|
|
12
|
+
is granted, then calls `FrontChat('init')` with your chat ID.
|
|
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 { frontChat } from '@c15t/scripts/front-chat';
|
|
23
|
+
|
|
24
|
+
export const scripts = [frontChat({ chatId: 'YOUR_FRONT_CHAT_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
|
+
## Options
|
|
276
|
+
|
|
277
|
+
| Option | Behavior |
|
|
278
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
279
|
+
| `chatId` | Required public chat ID. An empty value throws. |
|
|
280
|
+
| `useDefaultLauncher` | Shows Front's launcher. Defaults to `true`. With `false`, open the widget from your own launcher through Front's [SDK](https://dev.frontapp.com/docs/chat-sdk-reference). |
|
|
281
|
+
| `nonce` | CSP nonce for the loader and Front's generated scripts. A loader-level nonce from your provider is forwarded too. |
|
|
282
|
+
| `scriptSrc` | Defaults to `https://chat-assets.frontapp.com/v1/chat.bundle.js`. A proxy here does not proxy the widget's other requests. |
|
|
283
|
+
|
|
284
|
+
Front creates more resources for the widget. Follow Front's
|
|
285
|
+
[CSP instructions](https://help.front.com/en/articles/2049) for the rest of the
|
|
286
|
+
policy.
|
|
287
|
+
|
|
288
|
+
## Consent behavior
|
|
289
|
+
|
|
290
|
+
The widget waits for functionality permission. When a visitor revokes it, c15t
|
|
291
|
+
reloads the page, which removes the running widget. Keep
|
|
292
|
+
`reloadOnConsentRevoked` enabled: removing the loader cannot stop a widget that
|
|
293
|
+
already initialized.
|
|
294
|
+
|
|
295
|
+
To also clear the visitor's Front session, call `shutdownFrontChat()` from
|
|
296
|
+
`onBeforeConsentRevocationReload`:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
import { shutdownFrontChat } from '@c15t/scripts/front-chat';
|
|
300
|
+
|
|
301
|
+
const callbacks = {
|
|
302
|
+
onBeforeConsentRevocationReload: ({ preferences }) => {
|
|
303
|
+
if (!preferences.functionality) {
|
|
304
|
+
shutdownFrontChat();
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
It sends Front's `shutdown` command with `clearSession: true` when the SDK has
|
|
311
|
+
loaded. Front returns no completion signal, so the reload does not wait for the
|
|
312
|
+
session to clear.
|
|
313
|
+
|
|
314
|
+
## Verify the integration
|
|
315
|
+
|
|
316
|
+
Reject functionality permission and confirm the loader is absent. Grant it and
|
|
317
|
+
confirm the widget opens and connects to your Front inbox. Then revoke it and
|
|
318
|
+
confirm the page reloads without the widget. Keep another support contact
|
|
319
|
+
available while chat is blocked.
|
|
320
|
+
|
|
321
|
+
Removing a script cannot undo requests that already ran. Follow the
|
|
322
|
+
[consent verification guide](../guides/verify-consent.md).
|
|
@@ -32,12 +32,12 @@ Render this component inside your existing consent boundary or provider.
|
|
|
32
32
|
```tsx title="src/consent-embed.tsx"
|
|
33
33
|
'use client';
|
|
34
34
|
|
|
35
|
-
import {
|
|
35
|
+
import { ConsentGate } from 'c15t/next';
|
|
36
36
|
import { embedCategory, embedURL, embedTitle, embedAspectRatio } from './embed-config';
|
|
37
37
|
|
|
38
38
|
export function ConsentEmbed() {
|
|
39
39
|
return (
|
|
40
|
-
<
|
|
40
|
+
<ConsentGate category={embedCategory}>
|
|
41
41
|
<iframe
|
|
42
42
|
src={embedURL}
|
|
43
43
|
title={embedTitle}
|
|
@@ -45,12 +45,12 @@ export function ConsentEmbed() {
|
|
|
45
45
|
allowFullScreen
|
|
46
46
|
style={{ width: '100%', aspectRatio: embedAspectRatio, minHeight: 200, border: 0 }}
|
|
47
47
|
/>
|
|
48
|
-
</
|
|
48
|
+
</ConsentGate>
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
`
|
|
53
|
+
`ConsentGate` keeps the iframe absent while permission is denied and removes it
|
|
54
54
|
on revocation. Keep your existing consent styles and preferences dialog.
|
|
55
55
|
|
|
56
56
|
**TanStack Start**
|
|
@@ -58,12 +58,12 @@ on revocation. Keep your existing consent styles and preferences dialog.
|
|
|
58
58
|
Render this component inside your existing consent boundary or provider.
|
|
59
59
|
|
|
60
60
|
```tsx title="src/consent-embed.tsx"
|
|
61
|
-
import {
|
|
61
|
+
import { ConsentGate } from 'c15t/tanstack-start';
|
|
62
62
|
import { embedCategory, embedURL, embedTitle, embedAspectRatio } from './embed-config';
|
|
63
63
|
|
|
64
64
|
export function ConsentEmbed() {
|
|
65
65
|
return (
|
|
66
|
-
<
|
|
66
|
+
<ConsentGate category={embedCategory}>
|
|
67
67
|
<iframe
|
|
68
68
|
src={embedURL}
|
|
69
69
|
title={embedTitle}
|
|
@@ -71,12 +71,12 @@ export function ConsentEmbed() {
|
|
|
71
71
|
allowFullScreen
|
|
72
72
|
style={{ width: '100%', aspectRatio: embedAspectRatio, minHeight: 200, border: 0 }}
|
|
73
73
|
/>
|
|
74
|
-
</
|
|
74
|
+
</ConsentGate>
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
`
|
|
79
|
+
`ConsentGate` keeps the iframe absent while permission is denied and removes it
|
|
80
80
|
on revocation. Keep your existing consent styles and preferences dialog.
|
|
81
81
|
|
|
82
82
|
**React**
|
|
@@ -84,12 +84,12 @@ on revocation. Keep your existing consent styles and preferences dialog.
|
|
|
84
84
|
Render this component inside your existing consent boundary or provider.
|
|
85
85
|
|
|
86
86
|
```tsx title="src/consent-embed.tsx"
|
|
87
|
-
import {
|
|
87
|
+
import { ConsentGate } from 'c15t/react';
|
|
88
88
|
import { embedCategory, embedURL, embedTitle, embedAspectRatio } from './embed-config';
|
|
89
89
|
|
|
90
90
|
export function ConsentEmbed() {
|
|
91
91
|
return (
|
|
92
|
-
<
|
|
92
|
+
<ConsentGate category={embedCategory}>
|
|
93
93
|
<iframe
|
|
94
94
|
src={embedURL}
|
|
95
95
|
title={embedTitle}
|
|
@@ -97,12 +97,12 @@ export function ConsentEmbed() {
|
|
|
97
97
|
allowFullScreen
|
|
98
98
|
style={{ width: '100%', aspectRatio: embedAspectRatio, minHeight: 200, border: 0 }}
|
|
99
99
|
/>
|
|
100
|
-
</
|
|
100
|
+
</ConsentGate>
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
`
|
|
105
|
+
`ConsentGate` keeps the iframe absent while permission is denied and removes it
|
|
106
106
|
on revocation. Keep your existing consent styles and preferences dialog.
|
|
107
107
|
|
|
108
108
|
**Nuxt**
|
|
@@ -175,7 +175,7 @@ Add this component to pages using your consent-enabled base layout:
|
|
|
175
175
|
<c15t-consent-embed style="display: block"></c15t-consent-embed>
|
|
176
176
|
|
|
177
177
|
<script>
|
|
178
|
-
import { getConsentClient } from '
|
|
178
|
+
import { getConsentClient } from 'c15t/astro/client';
|
|
179
179
|
import { mountConsentEmbed } from '../consent-embed';
|
|
180
180
|
|
|
181
181
|
class ConsentEmbed extends HTMLElement {
|
|
@@ -222,11 +222,11 @@ The provider from your quickstart supplies its consent state.
|
|
|
222
222
|
|
|
223
223
|
```svelte title="src/ConsentEmbed.svelte"
|
|
224
224
|
<script lang="ts">
|
|
225
|
-
import {
|
|
225
|
+
import { ConsentGate } from '@c15t/svelte';
|
|
226
226
|
import { embedCategory, embedURL, embedTitle, embedAspectRatio } from './embed-config';
|
|
227
227
|
</script>
|
|
228
228
|
|
|
229
|
-
<
|
|
229
|
+
<ConsentGate category={embedCategory}>
|
|
230
230
|
<iframe
|
|
231
231
|
src={embedURL}
|
|
232
232
|
title={embedTitle}
|
|
@@ -237,10 +237,10 @@ The provider from your quickstart supplies its consent state.
|
|
|
237
237
|
style:min-height="200px"
|
|
238
238
|
style:border="0"
|
|
239
239
|
></iframe>
|
|
240
|
-
</
|
|
240
|
+
</ConsentGate>
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
The Svelte `
|
|
243
|
+
The Svelte `ConsentGate` waits until the browser is mounted and the category is
|
|
244
244
|
allowed. Its default placeholder opens preferences. Revocation removes the
|
|
245
245
|
iframe.
|
|
246
246
|
|
|
@@ -251,11 +251,11 @@ Keep the SvelteKit root provider and its server prefetch unchanged.
|
|
|
251
251
|
|
|
252
252
|
```svelte title="src/lib/ConsentEmbed.svelte"
|
|
253
253
|
<script lang="ts">
|
|
254
|
-
import {
|
|
254
|
+
import { ConsentGate } from '@c15t/svelte';
|
|
255
255
|
import { embedCategory, embedURL, embedTitle, embedAspectRatio } from '../embed-config';
|
|
256
256
|
</script>
|
|
257
257
|
|
|
258
|
-
<
|
|
258
|
+
<ConsentGate category={embedCategory}>
|
|
259
259
|
<iframe
|
|
260
260
|
src={embedURL}
|
|
261
261
|
title={embedTitle}
|
|
@@ -266,10 +266,10 @@ Keep the SvelteKit root provider and its server prefetch unchanged.
|
|
|
266
266
|
style:min-height="200px"
|
|
267
267
|
style:border="0"
|
|
268
268
|
></iframe>
|
|
269
|
-
</
|
|
269
|
+
</ConsentGate>
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
-
The Svelte `
|
|
272
|
+
The Svelte `ConsentGate` waits until the browser is mounted and the category is
|
|
273
273
|
allowed. Its default placeholder opens preferences. Revocation removes the
|
|
274
274
|
iframe.
|
|
275
275
|
|
|
@@ -196,7 +196,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
196
196
|
Export the scripts from that module:
|
|
197
197
|
|
|
198
198
|
```ts title="src/c15t.client.ts"
|
|
199
|
-
import type { C15tClientOptionsExtension } from '
|
|
199
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
200
200
|
import { scripts } from './consent-scripts';
|
|
201
201
|
|
|
202
202
|
export default { scripts } satisfies C15tClientOptionsExtension;
|
|
@@ -198,7 +198,7 @@ clientEntrypoint: fileURLToPath(new URL('./src/c15t.client.ts', import.meta.url)
|
|
|
198
198
|
Export the scripts from that module:
|
|
199
199
|
|
|
200
200
|
```ts title="src/c15t.client.ts"
|
|
201
|
-
import type { C15tClientOptionsExtension } from '
|
|
201
|
+
import type { C15tClientOptionsExtension } from 'c15t/astro';
|
|
202
202
|
import { scripts } from './consent-scripts';
|
|
203
203
|
|
|
204
204
|
export default { scripts } satisfies C15tClientOptionsExtension;
|