@c15t/scripts 2.0.0 → 2.1.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 (110) hide show
  1. package/README.md +9 -9
  2. package/dist/e2e-test-utils.cjs +125 -0
  3. package/dist/e2e-test-utils.js +67 -0
  4. package/dist/engine/runtime.cjs +19 -9
  5. package/dist/engine/runtime.js +19 -9
  6. package/dist/registry.cjs +338 -0
  7. package/dist/registry.js +292 -0
  8. package/dist/types.cjs +18 -0
  9. package/dist/types.js +10 -1
  10. package/dist/vendors/_shared/attributes.cjs +51 -0
  11. package/dist/vendors/_shared/attributes.js +14 -0
  12. package/dist/vendors/_shared/google-consent.cjs +64 -0
  13. package/dist/vendors/_shared/google-consent.js +27 -0
  14. package/dist/vendors/_shared/install-builders.cjs +55 -0
  15. package/dist/vendors/_shared/install-builders.js +21 -0
  16. package/dist/vendors/_shared/script-url.cjs +74 -0
  17. package/dist/vendors/_shared/script-url.js +28 -0
  18. package/dist/{linkedin-insights.cjs → vendors/ads-and-pixels/linkedin-insights.cjs} +2 -2
  19. package/dist/{linkedin-insights.js → vendors/ads-and-pixels/linkedin-insights.js} +2 -2
  20. package/dist/vendors/ads-and-pixels/meta-pixel.cjs +202 -0
  21. package/dist/vendors/ads-and-pixels/meta-pixel.js +153 -0
  22. package/dist/{microsoft-uet.cjs → vendors/ads-and-pixels/microsoft-uet.cjs} +31 -14
  23. package/dist/{microsoft-uet.js → vendors/ads-and-pixels/microsoft-uet.js} +31 -14
  24. package/dist/vendors/ads-and-pixels/reddit-pixel.cjs +147 -0
  25. package/dist/vendors/ads-and-pixels/reddit-pixel.js +107 -0
  26. package/dist/vendors/ads-and-pixels/snapchat-pixel.cjs +127 -0
  27. package/dist/vendors/ads-and-pixels/snapchat-pixel.js +87 -0
  28. package/dist/{tiktok-pixel.cjs → vendors/ads-and-pixels/tiktok-pixel.cjs} +2 -2
  29. package/dist/{tiktok-pixel.js → vendors/ads-and-pixels/tiktok-pixel.js} +2 -2
  30. package/dist/{x-pixel.cjs → vendors/ads-and-pixels/x-pixel.cjs} +6 -3
  31. package/dist/{x-pixel.js → vendors/ads-and-pixels/x-pixel.js} +6 -3
  32. package/dist/vendors/analytics/ahrefs-analytics.cjs +64 -0
  33. package/dist/vendors/analytics/ahrefs-analytics.js +27 -0
  34. package/dist/vendors/analytics/cloudflare-web-analytics.cjs +69 -0
  35. package/dist/vendors/analytics/cloudflare-web-analytics.js +32 -0
  36. package/dist/{databuddy.cjs → vendors/analytics/databuddy.cjs} +3 -3
  37. package/dist/{databuddy.js → vendors/analytics/databuddy.js} +3 -3
  38. package/dist/vendors/analytics/fathom-analytics.cjs +72 -0
  39. package/dist/vendors/analytics/fathom-analytics.js +35 -0
  40. package/dist/{google-tag.cjs → vendors/analytics/google-tag.cjs} +7 -28
  41. package/dist/{google-tag.js → vendors/analytics/google-tag.js} +7 -28
  42. package/dist/vendors/analytics/hotjar.cjs +81 -0
  43. package/dist/vendors/analytics/hotjar.js +44 -0
  44. package/dist/vendors/analytics/matomo-analytics.cjs +228 -0
  45. package/dist/vendors/analytics/matomo-analytics.js +191 -0
  46. package/dist/vendors/analytics/microsoft-clarity.cjs +110 -0
  47. package/dist/vendors/analytics/microsoft-clarity.js +73 -0
  48. package/dist/vendors/analytics/mixpanel-analytics.cjs +119 -0
  49. package/dist/vendors/analytics/mixpanel-analytics.js +82 -0
  50. package/dist/vendors/analytics/plausible-analytics.cjs +118 -0
  51. package/dist/vendors/analytics/plausible-analytics.js +81 -0
  52. package/dist/{posthog.cjs → vendors/analytics/posthog.cjs} +69 -6
  53. package/dist/vendors/analytics/posthog.js +163 -0
  54. package/dist/vendors/analytics/promptwatch.cjs +66 -0
  55. package/dist/vendors/analytics/promptwatch.js +29 -0
  56. package/dist/vendors/analytics/rybbit-analytics.cjs +100 -0
  57. package/dist/vendors/analytics/rybbit-analytics.js +63 -0
  58. package/dist/vendors/analytics/segment.cjs +93 -0
  59. package/dist/vendors/analytics/segment.js +56 -0
  60. package/dist/vendors/analytics/umami-analytics.cjs +76 -0
  61. package/dist/vendors/analytics/umami-analytics.js +39 -0
  62. package/dist/vendors/analytics/vercel-analytics.cjs +90 -0
  63. package/dist/vendors/analytics/vercel-analytics.js +53 -0
  64. package/dist/vendors/functional/crisp.cjs +139 -0
  65. package/dist/vendors/functional/crisp.js +102 -0
  66. package/dist/vendors/functional/intercom.cjs +85 -0
  67. package/dist/vendors/functional/intercom.js +45 -0
  68. package/dist/{google-tag-manager.cjs → vendors/tag-managers/google-tag-manager.cjs} +6 -27
  69. package/dist/{google-tag-manager.js → vendors/tag-managers/google-tag-manager.js} +6 -27
  70. package/dist-types/__tests__/helpers.d.ts +141 -0
  71. package/dist-types/engine/runtime.d.ts +1 -1
  72. package/dist-types/registry.d.ts +368 -0
  73. package/dist-types/types.d.ts +13 -0
  74. package/dist-types/vendors/_shared/attributes.d.ts +35 -0
  75. package/dist-types/vendors/_shared/google-consent.d.ts +47 -0
  76. package/dist-types/vendors/_shared/install-builders.d.ts +30 -0
  77. package/dist-types/vendors/_shared/script-url.d.ts +75 -0
  78. package/dist-types/{linkedin-insights.d.ts → vendors/ads-and-pixels/linkedin-insights.d.ts} +22 -9
  79. package/dist-types/vendors/ads-and-pixels/meta-pixel.d.ts +289 -0
  80. package/dist-types/{microsoft-uet.d.ts → vendors/ads-and-pixels/microsoft-uet.d.ts} +21 -10
  81. package/dist-types/vendors/ads-and-pixels/reddit-pixel.d.ts +211 -0
  82. package/dist-types/vendors/ads-and-pixels/snapchat-pixel.d.ts +171 -0
  83. package/dist-types/{tiktok-pixel.d.ts → vendors/ads-and-pixels/tiktok-pixel.d.ts} +20 -5
  84. package/dist-types/{x-pixel.d.ts → vendors/ads-and-pixels/x-pixel.d.ts} +21 -4
  85. package/dist-types/vendors/analytics/ahrefs-analytics.d.ts +62 -0
  86. package/dist-types/vendors/analytics/cloudflare-web-analytics.d.ts +67 -0
  87. package/dist-types/vendors/analytics/fathom-analytics.d.ts +90 -0
  88. package/dist-types/{google-tag.d.ts → vendors/analytics/google-tag.d.ts} +5 -8
  89. package/dist-types/vendors/analytics/hotjar.d.ts +73 -0
  90. package/dist-types/vendors/analytics/matomo-analytics.d.ts +41 -0
  91. package/dist-types/vendors/analytics/microsoft-clarity.d.ts +86 -0
  92. package/dist-types/vendors/analytics/mixpanel-analytics.d.ts +101 -0
  93. package/dist-types/vendors/analytics/plausible-analytics.d.ts +122 -0
  94. package/dist-types/{posthog.d.ts → vendors/analytics/posthog.d.ts} +47 -5
  95. package/dist-types/vendors/analytics/promptwatch.d.ts +36 -0
  96. package/dist-types/vendors/analytics/rybbit-analytics.d.ts +82 -0
  97. package/dist-types/vendors/analytics/segment.d.ts +158 -0
  98. package/dist-types/vendors/analytics/umami-analytics.d.ts +93 -0
  99. package/dist-types/vendors/analytics/vercel-analytics.d.ts +66 -0
  100. package/dist-types/vendors/functional/crisp.d.ts +78 -0
  101. package/dist-types/vendors/functional/intercom.d.ts +135 -0
  102. package/dist-types/{google-tag-manager.d.ts → vendors/tag-managers/google-tag-manager.d.ts} +5 -8
  103. package/package.json +166 -5
  104. package/dist/meta-pixel.cjs +0 -129
  105. package/dist/meta-pixel.js +0 -89
  106. package/dist/posthog.js +0 -100
  107. package/dist-types/engine.test.d.ts +0 -1
  108. package/dist-types/helpers.test.d.ts +0 -1
  109. package/dist-types/meta-pixel.d.ts +0 -185
  110. /package/dist-types/{databuddy.d.ts → vendors/analytics/databuddy.d.ts} +0 -0
@@ -0,0 +1,141 @@
1
+ import type { ConsentState, Script, ScriptCallbackInfo } from 'c15t';
2
+ import { type BuiltInScriptIntegrationKey } from '../registry';
3
+ /**
4
+ * Typed view of `globalThis` used by script helper tests.
5
+ *
6
+ * Additional string-keyed properties model browser and vendor globals created
7
+ * during setup and individual test cases.
8
+ */
9
+ export type TestGlobal = typeof globalThis & Record<string, unknown>;
10
+ /**
11
+ * Snapshot of the script fields asserted by helper tests.
12
+ */
13
+ export interface HelperScriptSnapshot {
14
+ /** Unique script identifier generated by the helper under test. */
15
+ id: string;
16
+ /** Consent category associated with the script integration. */
17
+ category: unknown;
18
+ /** Whether the script should load even before optional consent is granted. */
19
+ alwaysLoad?: boolean;
20
+ /** Whether the script stays loaded after consent for its category is revoked. */
21
+ persistAfterConsentRevoked?: boolean;
22
+ /** Remote script URL emitted by the helper, when applicable. */
23
+ src?: string;
24
+ }
25
+ /**
26
+ * Expected integration metadata and script attributes for a helper assertion.
27
+ */
28
+ export interface ExpectedScriptSnapshot {
29
+ /** Expected `alwaysLoad` flag from the generated helper script. */
30
+ alwaysLoad: boolean | undefined;
31
+ /** Expected consent-revocation persistence flag from the generated script. */
32
+ persistAfterConsentRevoked: boolean | undefined;
33
+ /** Expected remote script URL from the generated helper script. */
34
+ src: string;
35
+ }
36
+ /**
37
+ * Consent state with only required storage enabled.
38
+ *
39
+ * `necessary` keeps essential storage on, `functionality` covers site
40
+ * preferences, `measurement` controls analytics, `marketing` controls
41
+ * advertising-related storage, and `experience` controls personalization.
42
+ */
43
+ export declare const deniedConsentState: ConsentState;
44
+ /**
45
+ * Consent state with required and measurement storage enabled.
46
+ *
47
+ * `necessary` keeps essential storage on, `functionality` covers site
48
+ * preferences, `measurement` controls analytics, `marketing` controls
49
+ * advertising-related storage, and `experience` controls personalization.
50
+ */
51
+ export declare const grantedMeasurementConsentState: ConsentState;
52
+ /**
53
+ * Required callback fields for creating a script lifecycle payload in tests.
54
+ */
55
+ export type CallbackInfoOverrides = Partial<ScriptCallbackInfo> & Pick<ScriptCallbackInfo, 'id'>;
56
+ /**
57
+ * Creates a fully typed callback payload for script lifecycle tests.
58
+ *
59
+ * Defaults model a denied-consent callback for the same DOM element ID as the
60
+ * script ID, while allowing individual tests to override the relevant fields.
61
+ */
62
+ export declare function createCallbackInfo(overrides: CallbackInfoOverrides): ScriptCallbackInfo;
63
+ export type LifecycleCallbackOverrides = Partial<Omit<ScriptCallbackInfo, 'id'>>;
64
+ export declare function runOnBeforeLoad(script: Pick<Script, 'id' | 'onBeforeLoad'>, overrides?: LifecycleCallbackOverrides): void;
65
+ /**
66
+ * Returns a mutable test-friendly reference to the global object.
67
+ *
68
+ * @returns The current global object cast to `TestGlobal`.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const globalRef = getTestGlobal();
73
+ * globalRef.dataLayer = [];
74
+ * ```
75
+ */
76
+ export declare function getTestGlobal(): TestGlobal;
77
+ /**
78
+ * Registers browser-like setup and teardown hooks for script helper tests.
79
+ *
80
+ * Before each test, this installs mocked `window` and `document` globals.
81
+ * After each test, it unstubs globals and removes vendor-specific globals left
82
+ * behind by script execution.
83
+ *
84
+ * @returns Nothing.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * describe('googleTagManager', () => {
89
+ * setupScriptHelperTest();
90
+ * });
91
+ * ```
92
+ */
93
+ export declare function setupScriptHelperTest(): void;
94
+ /**
95
+ * Asserts that a helper-generated script matches registry metadata and
96
+ * expected script fields.
97
+ *
98
+ * @param key - Built-in integration key used to find the registry entry.
99
+ * @param script - Snapshot of the helper-generated script under test.
100
+ * @param expected - Expected script metadata and output for the assertion.
101
+ * @returns Nothing.
102
+ *
103
+ * @remarks
104
+ * If `key` does not match any built-in integration, the assertion fails before
105
+ * the non-null access is used.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * expectScriptMatchesIntegration(
110
+ * 'googleTagManager',
111
+ * googleTagManager({ id: 'GTM-123' }),
112
+ * {
113
+ * alwaysLoad: true,
114
+ * persistAfterConsentRevoked: undefined,
115
+ * src: 'https://www.googletagmanager.com/gtm.js?id=GTM-123',
116
+ * }
117
+ * );
118
+ * ```
119
+ */
120
+ export declare function expectScriptMatchesIntegration(key: BuiltInScriptIntegrationKey, script: HelperScriptSnapshot, expected: ExpectedScriptSnapshot): void;
121
+ /**
122
+ * Converts an array-like value into a plain array.
123
+ *
124
+ * @param value - Array-like input such as `arguments`, a `NodeList`, or a
125
+ * vendor queue entry.
126
+ * @returns A new array containing the indexed values from `value`.
127
+ *
128
+ * @remarks
129
+ * Passing `null` or `undefined` throws because `slice` requires an object-like
130
+ * value.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * function collectArgs(...args: unknown[]) {
135
+ * return toArgumentsArray(args);
136
+ * }
137
+ * ```
138
+ */
139
+ export declare function toArgumentsArray(value: unknown): unknown[];
140
+ export declare function expectGoogleConsentDefault(entry: unknown): void;
141
+ export declare function expectStubCommandQueue(stub: unknown, queueKey: string, commands: unknown[][]): void;
@@ -1,3 +1,3 @@
1
1
  import { type Script } from 'c15t';
2
- import type { ResolvedManifest } from '../types';
2
+ import { type ResolvedManifest } from '../types';
3
3
  export declare function resolvedManifestToScript(resolvedManifest: ResolvedManifest): Script;
@@ -0,0 +1,368 @@
1
+ /**
2
+ * High-level product area for a built-in script integration.
3
+ *
4
+ * Used for discovery surfaces such as docs navigation and CLI grouping. This is
5
+ * intentionally separate from a manifest consent category.
6
+ */
7
+ export type IntegrationCategory = 'analytics' | 'ads-and-pixels' | 'functional' | 'tag-manager';
8
+ /**
9
+ * Consent bucket that a built-in integration maps to by default.
10
+ *
11
+ * These values mirror c15t's consent categories without importing core types, so
12
+ * the registry stays safe to consume from docs and CLI code.
13
+ */
14
+ export type IntegrationConsentCategory = 'necessary' | 'functionality' | 'experience' | 'measurement' | 'marketing';
15
+ /**
16
+ * Display metadata for an integration category.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const label = BUILT_IN_INTEGRATION_CATEGORIES[0]?.label;
21
+ * ```
22
+ */
23
+ export interface IntegrationCategoryEntry {
24
+ /** Stable category key used by registry entries. */
25
+ key: IntegrationCategory;
26
+ /** Human-readable label for display surfaces. */
27
+ label: string;
28
+ }
29
+ /**
30
+ * Identity and discovery metadata for a built-in script integration.
31
+ *
32
+ * All fields are required except `hint`, which is optional short help text for
33
+ * picker UIs. Do not add runtime behavior, disclosure metadata, or vendor
34
+ * implementation details here.
35
+ */
36
+ export interface IntegrationRegistryEntry {
37
+ /** Stable key used by tests and generated metadata. */
38
+ key: string;
39
+ /** Script id emitted by the resolved helper. */
40
+ vendor: string;
41
+ /** Human-readable integration name. */
42
+ label: string;
43
+ /** Optional short description for CLI or docs picker UIs. */
44
+ hint?: string;
45
+ /** Docs route slug for this integration. */
46
+ docsSlug: string;
47
+ /** Package subpath, e.g. `meta-pixel` for `@c15t/scripts/meta-pixel`. */
48
+ packageSubpath: string;
49
+ /** Product area used for grouping and discovery. */
50
+ integrationCategory: IntegrationCategory;
51
+ /** Default consent bucket expected from the generated script. */
52
+ consentCategory: IntegrationConsentCategory;
53
+ }
54
+ /**
55
+ * Canonical display list for built-in integration categories.
56
+ *
57
+ * Consumers should use this list for category labels and ordering instead of
58
+ * re-declaring category names.
59
+ */
60
+ export declare const BUILT_IN_INTEGRATION_CATEGORIES: readonly [{
61
+ readonly key: "analytics";
62
+ readonly label: "Analytics";
63
+ }, {
64
+ readonly key: "ads-and-pixels";
65
+ readonly label: "Ads & Pixels";
66
+ }, {
67
+ readonly key: "functional";
68
+ readonly label: "Functional";
69
+ }, {
70
+ readonly key: "tag-manager";
71
+ readonly label: "Tag Managers";
72
+ }];
73
+ /**
74
+ * Canonical identity catalog for built-in `@c15t/scripts` integrations.
75
+ *
76
+ * Adding a new built-in integration should add one row here so docs, tests, and
77
+ * the CLI can discover it from the same source.
78
+ */
79
+ export declare const builtInScriptIntegrations: readonly [{
80
+ readonly key: "googleTagManager";
81
+ readonly vendor: "google-tag-manager";
82
+ readonly label: "Google Tag Manager";
83
+ readonly hint: "GTM container script";
84
+ readonly docsSlug: "google-tag-manager";
85
+ readonly packageSubpath: "google-tag-manager";
86
+ readonly integrationCategory: "tag-manager";
87
+ readonly consentCategory: "necessary";
88
+ }, {
89
+ readonly key: "gtag";
90
+ readonly vendor: "gtag";
91
+ readonly label: "Google Tag (gtag.js)";
92
+ readonly hint: "Google Analytics 4";
93
+ readonly docsSlug: "google-tag";
94
+ readonly packageSubpath: "google-tag";
95
+ readonly integrationCategory: "analytics";
96
+ readonly consentCategory: "measurement";
97
+ }, {
98
+ readonly key: "ahrefsAnalytics";
99
+ readonly vendor: "ahrefs-analytics";
100
+ readonly label: "Ahrefs Analytics";
101
+ readonly hint: "Cookieless web analytics from Ahrefs";
102
+ readonly docsSlug: "ahrefs-analytics";
103
+ readonly packageSubpath: "ahrefs-analytics";
104
+ readonly integrationCategory: "analytics";
105
+ readonly consentCategory: "measurement";
106
+ }, {
107
+ readonly key: "cloudflareWebAnalytics";
108
+ readonly vendor: "cloudflare-web-analytics";
109
+ readonly label: "Cloudflare Web Analytics";
110
+ readonly hint: "Cookieless analytics from Cloudflare";
111
+ readonly docsSlug: "cloudflare-web-analytics";
112
+ readonly packageSubpath: "cloudflare-web-analytics";
113
+ readonly integrationCategory: "analytics";
114
+ readonly consentCategory: "measurement";
115
+ }, {
116
+ readonly key: "microsoft-clarity";
117
+ readonly vendor: "microsoft-clarity";
118
+ readonly label: "Microsoft Clarity";
119
+ readonly hint: "Session replay and heatmaps";
120
+ readonly docsSlug: "microsoft-clarity";
121
+ readonly packageSubpath: "microsoft-clarity";
122
+ readonly integrationCategory: "analytics";
123
+ readonly consentCategory: "measurement";
124
+ }, {
125
+ readonly key: "databuddy";
126
+ readonly vendor: "databuddy";
127
+ readonly label: "Databuddy";
128
+ readonly hint: "Data collection";
129
+ readonly docsSlug: "databuddy";
130
+ readonly packageSubpath: "databuddy";
131
+ readonly integrationCategory: "analytics";
132
+ readonly consentCategory: "measurement";
133
+ }, {
134
+ readonly key: "fathomAnalytics";
135
+ readonly vendor: "fathom-analytics";
136
+ readonly label: "Fathom Analytics";
137
+ readonly hint: "Privacy-friendly cookieless analytics";
138
+ readonly docsSlug: "fathom-analytics";
139
+ readonly packageSubpath: "fathom-analytics";
140
+ readonly integrationCategory: "analytics";
141
+ readonly consentCategory: "measurement";
142
+ }, {
143
+ readonly key: "mixpanelAnalytics";
144
+ readonly vendor: "mixpanel-analytics";
145
+ readonly label: "Mixpanel Analytics";
146
+ readonly hint: "Product analytics and funnels";
147
+ readonly docsSlug: "mixpanel-analytics";
148
+ readonly packageSubpath: "mixpanel-analytics";
149
+ readonly integrationCategory: "analytics";
150
+ readonly consentCategory: "measurement";
151
+ }, {
152
+ readonly key: "hotjar";
153
+ readonly vendor: "hotjar";
154
+ readonly label: "Hotjar";
155
+ readonly hint: "Heatmaps and session recordings";
156
+ readonly docsSlug: "hotjar";
157
+ readonly packageSubpath: "hotjar";
158
+ readonly integrationCategory: "analytics";
159
+ readonly consentCategory: "measurement";
160
+ }, {
161
+ readonly key: "matomoAnalytics";
162
+ readonly vendor: "matomo-analytics";
163
+ readonly label: "Matomo Analytics";
164
+ readonly hint: "Self-hosted privacy analytics";
165
+ readonly docsSlug: "matomo-analytics";
166
+ readonly packageSubpath: "matomo-analytics";
167
+ readonly integrationCategory: "analytics";
168
+ readonly consentCategory: "measurement";
169
+ }, {
170
+ readonly key: "posthog";
171
+ readonly vendor: "posthog";
172
+ readonly label: "PostHog";
173
+ readonly hint: "Product analytics";
174
+ readonly docsSlug: "posthog";
175
+ readonly packageSubpath: "posthog";
176
+ readonly integrationCategory: "analytics";
177
+ readonly consentCategory: "measurement";
178
+ }, {
179
+ readonly key: "promptwatch";
180
+ readonly vendor: "promptwatch";
181
+ readonly label: "Promptwatch";
182
+ readonly hint: "AI traffic analytics";
183
+ readonly docsSlug: "promptwatch";
184
+ readonly packageSubpath: "promptwatch";
185
+ readonly integrationCategory: "analytics";
186
+ readonly consentCategory: "measurement";
187
+ }, {
188
+ readonly key: "segment";
189
+ readonly vendor: "segment";
190
+ readonly label: "Segment";
191
+ readonly hint: "Customer data platform";
192
+ readonly docsSlug: "segment";
193
+ readonly packageSubpath: "segment";
194
+ readonly integrationCategory: "analytics";
195
+ readonly consentCategory: "measurement";
196
+ }, {
197
+ readonly key: "rybbitAnalytics";
198
+ readonly vendor: "rybbit-analytics";
199
+ readonly label: "Rybbit Analytics";
200
+ readonly hint: "Privacy-friendly web analytics";
201
+ readonly docsSlug: "rybbit-analytics";
202
+ readonly packageSubpath: "rybbit-analytics";
203
+ readonly integrationCategory: "analytics";
204
+ readonly consentCategory: "measurement";
205
+ }, {
206
+ readonly key: "plausibleAnalytics";
207
+ readonly vendor: "plausible-analytics";
208
+ readonly label: "Plausible Analytics";
209
+ readonly hint: "Privacy-friendly cookieless analytics";
210
+ readonly docsSlug: "plausible-analytics";
211
+ readonly packageSubpath: "plausible-analytics";
212
+ readonly integrationCategory: "analytics";
213
+ readonly consentCategory: "measurement";
214
+ }, {
215
+ readonly key: "umamiAnalytics";
216
+ readonly vendor: "umami-analytics";
217
+ readonly label: "Umami Analytics";
218
+ readonly hint: "Open-source cookieless analytics";
219
+ readonly docsSlug: "umami-analytics";
220
+ readonly packageSubpath: "umami-analytics";
221
+ readonly integrationCategory: "analytics";
222
+ readonly consentCategory: "measurement";
223
+ }, {
224
+ readonly key: "vercelAnalytics";
225
+ readonly vendor: "vercel-analytics";
226
+ readonly label: "Vercel Analytics";
227
+ readonly hint: "Vercel web analytics";
228
+ readonly docsSlug: "vercel-analytics";
229
+ readonly packageSubpath: "vercel-analytics";
230
+ readonly integrationCategory: "analytics";
231
+ readonly consentCategory: "measurement";
232
+ }, {
233
+ readonly key: "crisp";
234
+ readonly vendor: "crisp";
235
+ readonly label: "Crisp";
236
+ readonly hint: "Live chat widget";
237
+ readonly docsSlug: "crisp";
238
+ readonly packageSubpath: "crisp";
239
+ readonly integrationCategory: "functional";
240
+ readonly consentCategory: "functionality";
241
+ }, {
242
+ readonly key: "intercom";
243
+ readonly vendor: "intercom";
244
+ readonly label: "Intercom";
245
+ readonly hint: "Messenger and live chat widget";
246
+ readonly docsSlug: "intercom";
247
+ readonly packageSubpath: "intercom";
248
+ readonly integrationCategory: "functional";
249
+ readonly consentCategory: "functionality";
250
+ }, {
251
+ readonly key: "metaPixel";
252
+ readonly vendor: "meta-pixel";
253
+ readonly label: "Meta Pixel";
254
+ readonly hint: "Facebook/Instagram tracking";
255
+ readonly docsSlug: "meta-pixel";
256
+ readonly packageSubpath: "meta-pixel";
257
+ readonly integrationCategory: "ads-and-pixels";
258
+ readonly consentCategory: "marketing";
259
+ }, {
260
+ readonly key: "redditPixel";
261
+ readonly vendor: "reddit-pixel";
262
+ readonly label: "Reddit Pixel";
263
+ readonly hint: "Reddit ads tracking";
264
+ readonly docsSlug: "reddit-pixel";
265
+ readonly packageSubpath: "reddit-pixel";
266
+ readonly integrationCategory: "ads-and-pixels";
267
+ readonly consentCategory: "marketing";
268
+ }, {
269
+ readonly key: "tiktokPixel";
270
+ readonly vendor: "tiktok-pixel";
271
+ readonly label: "TikTok Pixel";
272
+ readonly hint: "TikTok ads tracking";
273
+ readonly docsSlug: "tiktok-pixel";
274
+ readonly packageSubpath: "tiktok-pixel";
275
+ readonly integrationCategory: "ads-and-pixels";
276
+ readonly consentCategory: "marketing";
277
+ }, {
278
+ readonly key: "linkedinInsights";
279
+ readonly vendor: "linkedin-insights";
280
+ readonly label: "LinkedIn Insight Tag";
281
+ readonly hint: "LinkedIn conversion tracking";
282
+ readonly docsSlug: "linkedin-insights";
283
+ readonly packageSubpath: "linkedin-insights";
284
+ readonly integrationCategory: "ads-and-pixels";
285
+ readonly consentCategory: "marketing";
286
+ }, {
287
+ readonly key: "microsoftUet";
288
+ readonly vendor: "microsoft-uet";
289
+ readonly label: "Microsoft UET";
290
+ readonly hint: "Bing Ads tracking";
291
+ readonly docsSlug: "microsoft-uet";
292
+ readonly packageSubpath: "microsoft-uet";
293
+ readonly integrationCategory: "ads-and-pixels";
294
+ readonly consentCategory: "marketing";
295
+ }, {
296
+ readonly key: "snapchatPixel";
297
+ readonly vendor: "snapchat-pixel";
298
+ readonly label: "Snapchat Pixel";
299
+ readonly hint: "Snapchat ads tracking";
300
+ readonly docsSlug: "snapchat-pixel";
301
+ readonly packageSubpath: "snapchat-pixel";
302
+ readonly integrationCategory: "ads-and-pixels";
303
+ readonly consentCategory: "marketing";
304
+ }, {
305
+ readonly key: "xPixel";
306
+ readonly vendor: "x-pixel";
307
+ readonly label: "X (Twitter) Pixel";
308
+ readonly hint: "X/Twitter conversion tracking";
309
+ readonly docsSlug: "x-pixel";
310
+ readonly packageSubpath: "x-pixel";
311
+ readonly integrationCategory: "ads-and-pixels";
312
+ readonly consentCategory: "marketing";
313
+ }];
314
+ /**
315
+ * Concrete registry entry type inferred from `builtInScriptIntegrations`.
316
+ */
317
+ export type BuiltInScriptIntegration = (typeof builtInScriptIntegrations)[number];
318
+ /**
319
+ * Union of stable keys for built-in integrations.
320
+ */
321
+ export type BuiltInScriptIntegrationKey = BuiltInScriptIntegration['key'];
322
+ /**
323
+ * Union of public package subpaths for built-in integrations.
324
+ */
325
+ export type BuiltInScriptIntegrationSubpath = BuiltInScriptIntegration['packageSubpath'];
326
+ /**
327
+ * Looks up a built-in integration by its registry key.
328
+ *
329
+ * @param key - Stable integration key.
330
+ * @returns The matching built-in integration entry.
331
+ * @throws `Error("Unknown built-in script integration: <key>")` when the key is
332
+ * not present. Catch this when accepting untrusted or user-provided keys.
333
+ *
334
+ * @example
335
+ * ```ts
336
+ * const integration = getBuiltInScriptIntegration('metaPixel');
337
+ * console.log(integration.packageSubpath); // "meta-pixel"
338
+ * ```
339
+ */
340
+ export declare function getBuiltInScriptIntegration(key: BuiltInScriptIntegrationKey): BuiltInScriptIntegration;
341
+ /**
342
+ * Finds a built-in integration by its public package subpath.
343
+ *
344
+ * @param subpath - Kebab-case subpath such as `google-tag`.
345
+ * @returns The matching integration, or `undefined` when no entry matches.
346
+ *
347
+ * @example
348
+ * ```ts
349
+ * const integration = getBuiltInScriptIntegrationBySubpath('meta-pixel');
350
+ * console.log(integration?.label); // "Meta Pixel"
351
+ * ```
352
+ */
353
+ export declare function getBuiltInScriptIntegrationBySubpath(subpath: string): BuiltInScriptIntegration | undefined;
354
+ /**
355
+ * Finds a built-in integration by the emitted script vendor id.
356
+ *
357
+ * Use this to connect a resolved manifest/script id back to registry metadata.
358
+ *
359
+ * @param vendor - Vendor id emitted as `Script.id`.
360
+ * @returns The matching integration, or `undefined` when no entry matches.
361
+ *
362
+ * @example
363
+ * ```ts
364
+ * const integration = getBuiltInScriptIntegrationByVendor('google-tag-manager');
365
+ * console.log(integration?.label); // "Google Tag Manager"
366
+ * ```
367
+ */
368
+ export declare function getBuiltInScriptIntegrationByVendor(vendor: string): BuiltInScriptIntegration | undefined;
@@ -5,6 +5,19 @@ export declare const vendorManifestContract: {
5
5
  readonly kind: "c15t.vendor-manifest";
6
6
  readonly schemaVersion: 1;
7
7
  };
8
+ export declare const RUNTIME_VALUE_KIND = "c15t.runtime-value";
9
+ export interface RuntimeValue {
10
+ kind: typeof RUNTIME_VALUE_KIND;
11
+ value: 'date' | 'timestamp';
12
+ }
13
+ export declare const runtimeDateValue: {
14
+ readonly kind: "c15t.runtime-value";
15
+ readonly value: "date";
16
+ };
17
+ export declare const runtimeTimestampValue: {
18
+ readonly kind: "c15t.runtime-value";
19
+ readonly value: "timestamp";
20
+ };
8
21
  export interface ManifestContract {
9
22
  kind: typeof VENDOR_MANIFEST_KIND;
10
23
  schemaVersion: typeof VENDOR_MANIFEST_SCHEMA_VERSION;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Converts an optional boolean into a string suitable for a script `data-*`
3
+ * attribute.
4
+ *
5
+ * @param value - Optional boolean value from a vendor option.
6
+ * @returns `'true'` or `'false'` when a boolean is provided, otherwise
7
+ * `undefined` so the manifest compiler can omit the attribute.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * booleanDataAttribute(true); // 'true'
12
+ * booleanDataAttribute(false); // 'false'
13
+ * booleanDataAttribute(undefined); // undefined
14
+ * ```
15
+ */
16
+ export declare function booleanDataAttribute(value: boolean | undefined): string | undefined;
17
+ /**
18
+ * Converts a string or string list into a script `data-*` attribute value.
19
+ *
20
+ * Arrays are JSON-serialized so values containing commas can be round-tripped
21
+ * with `JSON.parse` by consumers that read the attribute.
22
+ *
23
+ * @param value - Optional string value or string list from a vendor option.
24
+ * @returns The original string, a JSON-serialized array, or `undefined` so the
25
+ * manifest compiler can omit the attribute.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * listDataAttribute('example.com'); // 'example.com'
30
+ * listDataAttribute(['a.com', 'b.com']); // '["a.com","b.com"]'
31
+ * listDataAttribute([]); // undefined
32
+ * listDataAttribute(undefined); // undefined
33
+ * ```
34
+ */
35
+ export declare function listDataAttribute(value: string[] | string | undefined): string | undefined;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Default c15t consent category mapping for Google Consent Mode v2.
3
+ *
4
+ * @remarks
5
+ * Shared by direct gtag.js and Google Tag Manager integrations so both emit the
6
+ * same Google storage consent defaults unless a caller provides an override.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const manifest = {
11
+ * consentMapping: GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING,
12
+ * };
13
+ * ```
14
+ */
15
+ export declare const GOOGLE_CONSENT_MODE_V2_DEFAULT_MAPPING: Record<string, string[]>;
16
+ /**
17
+ * Applies an optional Google consent mapping override to a manifest.
18
+ *
19
+ * @param manifest - Vendor manifest that already contains the default consent
20
+ * mapping.
21
+ * @param consentMapping - Optional caller-provided mapping from c15t consent
22
+ * categories to Google consent types.
23
+ * @returns The original manifest when no override is provided, or a shallow
24
+ * copy with the override mapping when one is provided.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const customMapping: Record<string, string[]> = {
29
+ * marketing: ['ad_storage'],
30
+ * };
31
+ * const mapped = withOptionalConsentMapping<TManifest>(
32
+ * manifest,
33
+ * customMapping
34
+ * );
35
+ * ```
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const unchanged = withOptionalConsentMapping<TManifest>(
40
+ * manifest,
41
+ * undefined
42
+ * );
43
+ * ```
44
+ */
45
+ export declare function withOptionalConsentMapping<TManifest extends {
46
+ consentMapping?: Record<string, string[]>;
47
+ }>(manifest: TManifest, consentMapping: Record<string, string[]> | undefined): TManifest;
@@ -0,0 +1,30 @@
1
+ import type { VendorManifest } from '../../types';
2
+ /**
3
+ * Optional tracking call inserted between the vendor init call and script load.
4
+ */
5
+ interface QueuePixelInstallStep {
6
+ /** Arguments passed to the vendor queue function. */
7
+ args: unknown[];
8
+ }
9
+ /**
10
+ * Options for building the common pixel install sequence.
11
+ */
12
+ export interface BuildQueuePixelInstallOptions {
13
+ /** Global queue function to call, for example `rdt` or `snaptr`. */
14
+ global: string;
15
+ /** Arguments for the required initialization call. */
16
+ initArgs: unknown[];
17
+ /** Optional tracking command queued immediately after initialization. */
18
+ trackStep?: QueuePixelInstallStep;
19
+ /** Manifest interpolation token used for the final loader script URL. */
20
+ scriptPlaceholder?: string;
21
+ }
22
+ /**
23
+ * Builds the common queue-pixel install sequence used by advertising pixels.
24
+ *
25
+ * @param options - Queue pixel install options.
26
+ * @returns Manifest install steps containing the required init call, an
27
+ * optional tracking call, and an async `loadScript` step.
28
+ */
29
+ export declare function buildQueuePixelInstall({ global, initArgs, trackStep, scriptPlaceholder, }: BuildQueuePixelInstallOptions): VendorManifest['install'];
30
+ export {};