@owlmeans/consent 0.1.18-rc.10 → 0.1.18-rc.11

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 (72) hide show
  1. package/build/consts.d.ts +11 -2
  2. package/build/consts.d.ts.map +1 -1
  3. package/build/consts.js +19 -0
  4. package/build/consts.js.map +1 -1
  5. package/build/gtm/types.d.ts +75 -0
  6. package/build/gtm/types.d.ts.map +1 -0
  7. package/build/gtm/types.js +2 -0
  8. package/build/gtm/types.js.map +1 -0
  9. package/build/gtm.d.ts +5 -70
  10. package/build/gtm.d.ts.map +1 -1
  11. package/build/gtm.js +125 -175
  12. package/build/gtm.js.map +1 -1
  13. package/build/i18n/types.d.ts +11 -0
  14. package/build/i18n/types.d.ts.map +1 -0
  15. package/build/i18n/types.js +2 -0
  16. package/build/i18n/types.js.map +1 -0
  17. package/build/i18n.d.ts +4 -14
  18. package/build/i18n.d.ts.map +1 -1
  19. package/build/i18n.js +12 -27
  20. package/build/i18n.js.map +1 -1
  21. package/build/index.d.ts +7 -2
  22. package/build/index.d.ts.map +1 -1
  23. package/build/index.js +2 -2
  24. package/build/index.js.map +1 -1
  25. package/build/linker/types.d.ts +58 -0
  26. package/build/linker/types.d.ts.map +1 -0
  27. package/build/linker/types.js +2 -0
  28. package/build/linker/types.js.map +1 -0
  29. package/build/linker.d.ts +6 -52
  30. package/build/linker.d.ts.map +1 -1
  31. package/build/linker.js +278 -314
  32. package/build/linker.js.map +1 -1
  33. package/build/plugins/types.d.ts +33 -0
  34. package/build/plugins/types.d.ts.map +1 -0
  35. package/build/plugins/types.js +2 -0
  36. package/build/plugins/types.js.map +1 -0
  37. package/build/plugins.d.ts +5 -28
  38. package/build/plugins.d.ts.map +1 -1
  39. package/build/plugins.js +49 -61
  40. package/build/plugins.js.map +1 -1
  41. package/build/storage/types.d.ts +31 -0
  42. package/build/storage/types.d.ts.map +1 -0
  43. package/build/storage/types.js +2 -0
  44. package/build/storage/types.js.map +1 -0
  45. package/build/storage.d.ts +6 -22
  46. package/build/storage.d.ts.map +1 -1
  47. package/build/storage.js +70 -81
  48. package/build/storage.js.map +1 -1
  49. package/build/store.d.ts +2 -2
  50. package/build/store.d.ts.map +1 -1
  51. package/build/store.js +18 -18
  52. package/build/store.js.map +1 -1
  53. package/build/types.d.ts +6 -3
  54. package/build/types.d.ts.map +1 -1
  55. package/package.json +1 -1
  56. package/src/consts.ts +23 -2
  57. package/src/gtm/types.ts +73 -0
  58. package/src/gtm.ts +142 -188
  59. package/src/i18n/types.ts +11 -0
  60. package/src/i18n.ts +19 -31
  61. package/src/index.ts +7 -5
  62. package/src/linker/types.ts +58 -0
  63. package/src/linker.ts +283 -314
  64. package/src/plugins/types.ts +33 -0
  65. package/src/plugins.ts +56 -63
  66. package/src/storage/types.ts +31 -0
  67. package/src/storage.ts +73 -77
  68. package/src/store.ts +18 -18
  69. package/src/types.ts +4 -3
  70. package/tests/consent.spec.ts +26 -28
  71. package/tests/linker.spec.ts +67 -67
  72. package/tests/tracking.spec.ts +14 -14
package/build/consts.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ConsentCategory } from './types.js';
1
+ import type { ConsentCategory, ConsentLocale } from './types.js';
2
2
  /**
3
3
  * Where a visitor's choice is stored.
4
4
  *
@@ -38,7 +38,16 @@ export declare const CONSENT_MARKETING = "marketing";
38
38
  * language part has to run in an inline `<head>` script, before any bundle exists.
39
39
  */
40
40
  export declare const CONSENT_LANGUAGE_KEY = "owlmeans-lng";
41
- export declare const CONSENT_LOCALES: readonly ['en', 'pl', 'ru', 'be', 'uk', 'es', 'de', 'fr'];
41
+ export declare const CONSENT_LOCALES: readonly ["en", "pl", "ru", "be", "uk", "es", "de", "fr"];
42
+ /**
43
+ * The dialog's copy, in the box.
44
+ *
45
+ * Carried here rather than registered into an i18n framework because one of the three consumers is
46
+ * an Astro site with React islands and no OwlMeans i18n at all — and a consent dialog that renders
47
+ * raw keys is worse than no dialog. An application that HAS translations passes `translate` and
48
+ * overrides every one of these.
49
+ */
50
+ export declare const DEFAULT_CONSENT_MESSAGES: Record<ConsentLocale, Record<string, string>>;
42
51
  /**
43
52
  * The categories every OwlMeans surface starts with.
44
53
  *
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,wBAAwB,CAAA;AAEhD,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,uBAAuB,CAAA;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAA;AAE/C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,eAAO,MAAM,eAAe,YAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAA;AAExF;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,EAAE,eAAe,EAmBvD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAQxE,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,UAAU,CAAA;AAEzC,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAEvC,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,KAAK,CAAA"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAWhE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,wBAAwB,CAAA;AAEhD,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,uBAAuB,CAAA;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAA;AAE/C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,eAAO,MAAM,eAAe,2DAA+F,CAAA;AAE3H;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAElF,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,EAAE,eAAe,EAmBvD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAQxE,CAAA;AAED,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,UAAU,CAAA;AAEzC,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,MAAM,CAAA;AAEvC,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,KAAK,CAAA"}
package/build/consts.js CHANGED
@@ -1,3 +1,11 @@
1
+ import en from './i18n/en.json' with { type: 'json' };
2
+ import pl from './i18n/pl.json' with { type: 'json' };
3
+ import ru from './i18n/ru.json' with { type: 'json' };
4
+ import be from './i18n/be.json' with { type: 'json' };
5
+ import uk from './i18n/uk.json' with { type: 'json' };
6
+ import es from './i18n/es.json' with { type: 'json' };
7
+ import de from './i18n/de.json' with { type: 'json' };
8
+ import fr from './i18n/fr.json' with { type: 'json' };
1
9
  /**
2
10
  * Where a visitor's choice is stored.
3
11
  *
@@ -38,6 +46,17 @@ export const CONSENT_MARKETING = 'marketing';
38
46
  */
39
47
  export const CONSENT_LANGUAGE_KEY = 'owlmeans-lng';
40
48
  export const CONSENT_LOCALES = ['en', 'pl', 'ru', 'be', 'uk', 'es', 'de', 'fr'];
49
+ /**
50
+ * The dialog's copy, in the box.
51
+ *
52
+ * Carried here rather than registered into an i18n framework because one of the three consumers is
53
+ * an Astro site with React islands and no OwlMeans i18n at all — and a consent dialog that renders
54
+ * raw keys is worse than no dialog. An application that HAS translations passes `translate` and
55
+ * overrides every one of these.
56
+ */
57
+ export const DEFAULT_CONSENT_MESSAGES = {
58
+ en, pl, ru, be, uk, es, de, fr,
59
+ };
41
60
  /**
42
61
  * The categories every OwlMeans surface starts with.
43
62
  *
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAA;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAA;AAEtD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAA;AAE/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAA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AEvC,oGAAoG;AACpG,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA"}
@@ -0,0 +1,75 @@
1
+ import type { ConsentCategory, ConsentOptions, ConsentRecord } from '../types.js';
2
+ /** Google Consent Mode: the queue, the signals a decision implies, and the inline scripts. */
3
+ export interface ConsentModeHelper {
4
+ /**
5
+ * Push onto the tag-manager queue in the shape Google's own snippet uses.
6
+ *
7
+ * `arguments`, not an array literal. Both work with today's Consent API, but `arguments` is what
8
+ * `gtag.js` itself emits, and a page that carries both this and Google's snippet should not have
9
+ * two shapes in one queue.
10
+ */
11
+ gtagConsent: (..._args: unknown[]) => void;
12
+ /** Every signal the configured categories drive, at its pre-consent value. */
13
+ consentDefaults: (categories?: ConsentCategory[]) => Record<string, 'granted' | 'denied'>;
14
+ /** Every signal, at the value this record implies. */
15
+ consentUpdate: (record: ConsentRecord, categories?: ConsentCategory[]) => Record<string, 'granted' | 'denied'>;
16
+ /**
17
+ * Declare what is denied, before any tag can act.
18
+ *
19
+ * Idempotent through a window flag, because the page may carry this call twice — once inline in
20
+ * the document head, once from whatever bundle mounts the dialog — and a second `default` after a
21
+ * tag has loaded is worse than none: it can widen what was already narrowed.
22
+ */
23
+ pushConsentDefaults: (opts?: ConsentOptions) => void;
24
+ /**
25
+ * Apply a decision: globals first, then the signal update, then any per-category events.
26
+ *
27
+ * The order is load-bearing. A tag that fires on the update event reads the globals in the same
28
+ * turn, so writing them afterwards would let the first firing see the previous answer.
29
+ */
30
+ applyConsent: (record: ConsentRecord, opts?: ConsentOptions) => void;
31
+ /**
32
+ * Whether a stored decision grants tracking at all — a signal-bearing category, not merely the
33
+ * required essential one.
34
+ *
35
+ * "Signal-bearing" is what a required category can never be: it exists to gate whether a LOADER
36
+ * runs, and a required category is disclosure, not a question — everyone gets it. Only a category
37
+ * that both is optional and drives at least one Consent Mode signal counts, which is exactly what
38
+ * `googleTagHeadScript`'s `'basic'` mode gates a Google tag behind.
39
+ */
40
+ trackingGranted: (record: ConsentRecord | null, categories?: ConsentCategory[]) => boolean;
41
+ /**
42
+ * The inline script a document stamps ABOVE its tag-manager snippet.
43
+ *
44
+ * It exists because the defaults have to be on the queue before `gtm.js` loads, and a React bundle
45
+ * cannot be: by the time an island mounts, the container has been running for hundreds of
46
+ * milliseconds and has already decided what it may do. Emitting it from the HTML is the only
47
+ * ordering that holds — and it reads the stored record too, so a returning visitor's tags are not
48
+ * denied for the first paint of every page.
49
+ */
50
+ consentBootstrapScript: (opts?: ConsentOptions) => string;
51
+ /**
52
+ * Withhold a loader until a stored or later decision grants tracking.
53
+ *
54
+ * The counterpart to `consentBootstrapScript` for the `'basic'` gated loading mode
55
+ * (`@owlmeans/web-gtm`'s `GOOGLE_TAG_DEFAULT_MODE`): where the bootstrap always declares Consent
56
+ * Mode's defaults so a tag may load cookieless, this withholds the tag itself — the loader string
57
+ * is only ever reached once `trackingGranted` is true, either because a returning visitor's stored
58
+ * record already says so, or because `applyConsent` later dispatches {@link CONSENT_EVENT} with
59
+ * one that does. The listener removes itself on the first passing event, so the loader — which
60
+ * marks its own element and refuses to run twice — is asked to run at most once from here.
61
+ *
62
+ * `loaderExpr` is a complete statement or expression that runs the loader when reached — the
63
+ * self-invoking IIFE string `googleTagHeadScript`'s `gtagScript`/`gtmContainerScript` already
64
+ * produce, embedded here verbatim rather than called. It is placed inline exactly as
65
+ * `consentBootstrapScript`'s own output is: dynamic values (the storage key, the category shape,
66
+ * the event name) are JSON-encoded so nothing configured can break out of a string literal, and
67
+ * escaping the RESULT for HTML (`</script`, `<!--`) is left to whoever composes the final inline
68
+ * script — the same discipline `consentBootstrapScript` follows, and `googleTagHeadScript` already
69
+ * applies to the whole script it stamps.
70
+ */
71
+ consentGateScript: (loaderExpr: string, opts?: ConsentOptions & {
72
+ categories?: ConsentCategory[];
73
+ }) => string;
74
+ }
75
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/gtm/types.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.ts"],"names":[],"mappings":""}
package/build/gtm.d.ts CHANGED
@@ -1,72 +1,7 @@
1
- import type { ConsentCategory, ConsentOptions, ConsentRecord } from './types.js';
2
- /**
3
- * Push onto the tag-manager queue in the shape Google's own snippet uses.
4
- *
5
- * `arguments`, not an array literal. Both work with today's Consent API, but `arguments` is what
6
- * `gtag.js` itself emits, and a page that carries both this and Google's snippet should not have
7
- * two shapes in one queue.
8
- */
9
- export declare function gtagConsent(..._args: unknown[]): void;
10
- /** Every signal the configured categories drive, at its pre-consent value. */
11
- export declare const consentDefaults: (categories?: ConsentCategory[]) => Record<string, 'granted' | 'denied'>;
12
- /** Every signal, at the value this record implies. */
13
- export declare const consentUpdate: (record: ConsentRecord, categories?: ConsentCategory[]) => Record<string, 'granted' | 'denied'>;
14
- /**
15
- * Declare what is denied, before any tag can act.
16
- *
17
- * Idempotent through a window flag, because the page may carry this call twice — once inline in
18
- * the document head, once from whatever bundle mounts the dialog — and a second `default` after a
19
- * tag has loaded is worse than none: it can widen what was already narrowed.
20
- */
21
- export declare const pushConsentDefaults: (opts?: ConsentOptions) => void;
22
- /**
23
- * Apply a decision: globals first, then the signal update, then any per-category events.
24
- *
25
- * The order is load-bearing. A tag that fires on the update event reads the globals in the same
26
- * turn, so writing them afterwards would let the first firing see the previous answer.
27
- */
28
- export declare const applyConsent: (record: ConsentRecord, opts?: ConsentOptions) => void;
29
- /**
30
- * Whether a stored decision grants tracking at all — a signal-bearing category, not merely the
31
- * required essential one.
32
- *
33
- * "Signal-bearing" is what a required category can never be: it exists to gate whether a LOADER
34
- * runs, and a required category is disclosure, not a question — everyone gets it. Only a category
35
- * that both is optional and drives at least one Consent Mode signal counts, which is exactly what
36
- * `googleTagHeadScript`'s `'basic'` mode gates a Google tag behind.
37
- */
38
- export declare const trackingGranted: (record: ConsentRecord | null, categories?: ConsentCategory[]) => boolean;
39
- /**
40
- * The inline script a document stamps ABOVE its tag-manager snippet.
41
- *
42
- * It exists because the defaults have to be on the queue before `gtm.js` loads, and a React bundle
43
- * cannot be: by the time an island mounts, the container has been running for hundreds of
44
- * milliseconds and has already decided what it may do. Emitting it from the HTML is the only
45
- * ordering that holds — and it reads the stored record too, so a returning visitor's tags are not
46
- * denied for the first paint of every page.
47
- */
1
+ import type { ConsentOptions } from './types.js';
2
+ import type { ConsentModeHelper } from './gtm/types.js';
3
+ export declare const createConsentModeHelper: () => ConsentModeHelper;
4
+ export declare const consentModeHelper: ConsentModeHelper;
5
+ /** @deprecated compat:factory-refactor — use `consentModeHelper.consentBootstrapScript(…)` */
48
6
  export declare const consentBootstrapScript: (opts?: ConsentOptions) => string;
49
- /**
50
- * Withhold a loader until a stored or later decision grants tracking.
51
- *
52
- * The counterpart to `consentBootstrapScript` for the `'basic'` gated loading mode
53
- * (`@owlmeans/web-gtm`'s `GOOGLE_TAG_DEFAULT_MODE`): where the bootstrap always declares Consent
54
- * Mode's defaults so a tag may load cookieless, this withholds the tag itself — the loader string
55
- * is only ever reached once `trackingGranted` is true, either because a returning visitor's stored
56
- * record already says so, or because `applyConsent` later dispatches {@link CONSENT_EVENT} with
57
- * one that does. The listener removes itself on the first passing event, so the loader — which
58
- * marks its own element and refuses to run twice — is asked to run at most once from here.
59
- *
60
- * `loaderExpr` is a complete statement or expression that runs the loader when reached — the
61
- * self-invoking IIFE string `googleTagHeadScript`'s `gtagScript`/`gtmContainerScript` already
62
- * produce, embedded here verbatim rather than called. It is placed inline exactly as
63
- * `consentBootstrapScript`'s own output is: dynamic values (the storage key, the category shape,
64
- * the event name) are JSON-encoded so nothing configured can break out of a string literal, and
65
- * escaping the RESULT for HTML (`</script`, `<!--`) is left to whoever composes the final inline
66
- * script — the same discipline `consentBootstrapScript` follows, and `googleTagHeadScript` already
67
- * applies to the whole script it stamps.
68
- */
69
- export declare const consentGateScript: (loaderExpr: string, opts?: ConsentOptions & {
70
- categories?: ConsentCategory[];
71
- }) => string;
72
7
  //# sourceMappingURL=gtm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":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iB,mBAA4B,CAAA;AAE1D,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,UAAW,cAAc,KAAG,MAAwD,CAAA"}
package/build/gtm.js CHANGED
@@ -1,182 +1,132 @@
1
1
  import { CONSENT_EVENT, CONSENT_KEY, CONSENT_SETUP_FLAG, CONSENT_SIGNAL_DEFAULTS, DEFAULT_CONSENT_CATEGORIES, } from './consts.js';
2
- import { consentLinkerScript } from './linker.js';
3
- const global = () => typeof window !== 'undefined' ? window : null;
4
- /**
5
- * Push onto the tag-manager queue in the shape Google's own snippet uses.
6
- *
7
- * `arguments`, not an array literal. Both work with today's Consent API, but `arguments` is what
8
- * `gtag.js` itself emits, and a page that carries both this and Google's snippet should not have
9
- * two shapes in one queue.
10
- */
11
- export function gtagConsent(..._args) {
12
- const win = global();
13
- if (win == null) {
14
- return;
15
- }
16
- win.dataLayer = win.dataLayer ?? [];
17
- // `arguments`, not `_args`. The rest parameter is only here to type the call sites; what goes on
18
- // the queue must be the arguments object itself.
19
- // eslint-disable-next-line prefer-rest-params
20
- win.dataLayer.push(arguments);
21
- }
22
- const categoriesOf = (opts) => opts?.categories ?? DEFAULT_CONSENT_CATEGORIES;
23
- /** Every signal the configured categories drive, at its pre-consent value. */
24
- export const consentDefaults = (categories) => {
25
- const used = new Set((categories ?? DEFAULT_CONSENT_CATEGORIES)
26
- .flatMap(category => category.signals ?? []));
27
- return Object.fromEntries(Object.entries(CONSENT_SIGNAL_DEFAULTS)
28
- .filter(([signal]) => used.has(signal)));
29
- };
30
- /** Every signal, at the value this record implies. */
31
- export const consentUpdate = (record, categories) => {
32
- const update = {};
33
- for (const category of categories ?? DEFAULT_CONSENT_CATEGORIES) {
34
- const granted = category.required === true || record[category.key] === true;
35
- for (const signal of category.signals ?? []) {
36
- // A signal named by two categories is granted only when every one of them is.
37
- update[signal] = granted && update[signal] !== 'denied' ? 'granted' : 'denied';
2
+ import { consentLinkHelper } from './linker.js';
3
+ export const createConsentModeHelper = () => {
4
+ const global = () => typeof window !== 'undefined' ? window : null;
5
+ // A `function`, not an arrow: what goes on the queue is its own `arguments` object.
6
+ function gtagConsent(..._args) {
7
+ const win = global();
8
+ if (win == null) {
9
+ return;
38
10
  }
11
+ win.dataLayer = win.dataLayer ?? [];
12
+ // `arguments`, not `_args`. The rest parameter is only here to type the call sites; what goes on
13
+ // the queue must be the arguments object itself.
14
+ // eslint-disable-next-line prefer-rest-params
15
+ win.dataLayer.push(arguments);
39
16
  }
40
- return update;
41
- };
42
- /**
43
- * Declare what is denied, before any tag can act.
44
- *
45
- * Idempotent through a window flag, because the page may carry this call twice — once inline in
46
- * the document head, once from whatever bundle mounts the dialog — and a second `default` after a
47
- * tag has loaded is worse than none: it can widen what was already narrowed.
48
- */
49
- export const pushConsentDefaults = (opts) => {
50
- const win = global();
51
- if (win == null || opts?.silent === true || win[CONSENT_SETUP_FLAG] === true) {
52
- return;
53
- }
54
- gtagConsent('consent', 'default', consentDefaults(categoriesOf(opts)));
55
- win[CONSENT_SETUP_FLAG] = true;
56
- };
57
- /**
58
- * Apply a decision: globals first, then the signal update, then any per-category events.
59
- *
60
- * The order is load-bearing. A tag that fires on the update event reads the globals in the same
61
- * turn, so writing them afterwards would let the first firing see the previous answer.
62
- */
63
- export const applyConsent = (record, opts) => {
64
- const win = global();
65
- if (win == null || opts?.silent === true) {
66
- return;
67
- }
68
- const categories = categoriesOf(opts);
69
- for (const category of categories) {
70
- if (category.globalVar != null) {
71
- win[category.globalVar] = category.required === true || record[category.key] === true;
17
+ const categoriesOf = (opts) => opts?.categories ?? DEFAULT_CONSENT_CATEGORIES;
18
+ const consentDefaults = (categories) => {
19
+ const used = new Set((categories ?? DEFAULT_CONSENT_CATEGORIES)
20
+ .flatMap(category => category.signals ?? []));
21
+ return Object.fromEntries(Object.entries(CONSENT_SIGNAL_DEFAULTS)
22
+ .filter(([signal]) => used.has(signal)));
23
+ };
24
+ const consentUpdate = (record, categories) => {
25
+ const update = {};
26
+ for (const category of categories ?? DEFAULT_CONSENT_CATEGORIES) {
27
+ const granted = category.required === true || record[category.key] === true;
28
+ for (const signal of category.signals ?? []) {
29
+ // A signal named by two categories is granted only when every one of them is.
30
+ update[signal] = granted && update[signal] !== 'denied' ? 'granted' : 'denied';
31
+ }
72
32
  }
73
- }
74
- gtagConsent('consent', 'update', consentUpdate(record, categories));
75
- for (const category of categories) {
76
- if (category.event != null && (category.required === true || record[category.key] === true)) {
77
- win.dataLayer = win.dataLayer ?? [];
78
- win.dataLayer.push({ event: category.event });
33
+ return update;
34
+ };
35
+ const pushConsentDefaults = (opts) => {
36
+ const win = global();
37
+ if (win == null || opts?.silent === true || win[CONSENT_SETUP_FLAG] === true) {
38
+ return;
79
39
  }
80
- }
81
- // A gate script (`consentGateScript`) that already decided NOT to load, because nothing was
82
- // granted at the time it ran, has no other way to hear this. Consent Mode itself speaks only on
83
- // `dataLayer`, which a tag that never loaded is not listening to.
84
- if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function'
85
- && typeof CustomEvent === 'function') {
86
- window.dispatchEvent(new CustomEvent(CONSENT_EVENT, { detail: { record } }));
87
- }
88
- };
89
- /**
90
- * Whether a stored decision grants tracking at all — a signal-bearing category, not merely the
91
- * required essential one.
92
- *
93
- * "Signal-bearing" is what a required category can never be: it exists to gate whether a LOADER
94
- * runs, and a required category is disclosure, not a question — everyone gets it. Only a category
95
- * that both is optional and drives at least one Consent Mode signal counts, which is exactly what
96
- * `googleTagHeadScript`'s `'basic'` mode gates a Google tag behind.
97
- */
98
- export const trackingGranted = (record, categories = DEFAULT_CONSENT_CATEGORIES) => record != null && categories.some(category => !category.required && (category.signals?.length ?? 0) > 0 && record[category.key] === true);
99
- /**
100
- * The inline script a document stamps ABOVE its tag-manager snippet.
101
- *
102
- * It exists because the defaults have to be on the queue before `gtm.js` loads, and a React bundle
103
- * cannot be: by the time an island mounts, the container has been running for hundreds of
104
- * milliseconds and has already decided what it may do. Emitting it from the HTML is the only
105
- * ordering that holds — and it reads the stored record too, so a returning visitor's tags are not
106
- * denied for the first paint of every page.
107
- */
108
- export const consentBootstrapScript = (opts) => {
109
- const defaults = JSON.stringify(consentDefaults(categoriesOf(opts)));
110
- const categories = JSON.stringify(categoriesOf(opts).map(category => ({
111
- key: category.key,
112
- required: category.required === true,
113
- signals: category.signals ?? [],
114
- globalVar: category.globalVar ?? null,
115
- })));
116
- const storageKey = JSON.stringify(opts?.storageKey ?? CONSENT_KEY);
117
- const flag = JSON.stringify(CONSENT_SETUP_FLAG);
118
- // Right after the default is pushed and before EITHER storage read below (this one, and the
119
- // `consentGateScript` that is concatenated after this whole IIFE) — an adopted decision must
120
- // already be in storage by the time anything reads it, so `gtm.js`'s own `page_view` never sees
121
- // the parameter and a granted decision loads the tag on arrival. A page with no `opts.linker`
122
- // gets an empty string here, unchanged from before this existed.
123
- const linker = opts?.linker != null ? `${consentLinkerScript(opts)};` : '';
124
- return `(function(w,d){` +
125
- `w.dataLayer=w.dataLayer||[];function g(){w.dataLayer.push(arguments)}` +
126
- `if(w[${flag}])return;g('consent','default',${defaults});w[${flag}]=true;` +
127
- linker +
128
- `var raw=null;try{raw=w.localStorage.getItem(${storageKey})}catch(e){}` +
129
- `if(!raw){var p=('; '+d.cookie).split('; '+${storageKey}+'=');` +
130
- `if(p.length===2){raw=p.pop().split(';').shift()}}` +
131
- `if(!raw)return;var r;try{r=JSON.parse(raw)}catch(e){return}` +
132
- `var cs=${categories},u={};` +
133
- `for(var i=0;i<cs.length;i++){var c=cs[i];var ok=c.required||r[c.key]===true;` +
134
- `if(c.globalVar){w[c.globalVar]=ok}` +
135
- `for(var j=0;j<c.signals.length;j++){var s=c.signals[j];` +
136
- `u[s]=ok&&u[s]!=='denied'?'granted':'denied'}}` +
137
- `g('consent','update',u)})(window,document)`;
138
- };
139
- /**
140
- * Withhold a loader until a stored or later decision grants tracking.
141
- *
142
- * The counterpart to `consentBootstrapScript` for the `'basic'` gated loading mode
143
- * (`@owlmeans/web-gtm`'s `GOOGLE_TAG_DEFAULT_MODE`): where the bootstrap always declares Consent
144
- * Mode's defaults so a tag may load cookieless, this withholds the tag itself — the loader string
145
- * is only ever reached once `trackingGranted` is true, either because a returning visitor's stored
146
- * record already says so, or because `applyConsent` later dispatches {@link CONSENT_EVENT} with
147
- * one that does. The listener removes itself on the first passing event, so the loader — which
148
- * marks its own element and refuses to run twice — is asked to run at most once from here.
149
- *
150
- * `loaderExpr` is a complete statement or expression that runs the loader when reached — the
151
- * self-invoking IIFE string `googleTagHeadScript`'s `gtagScript`/`gtmContainerScript` already
152
- * produce, embedded here verbatim rather than called. It is placed inline exactly as
153
- * `consentBootstrapScript`'s own output is: dynamic values (the storage key, the category shape,
154
- * the event name) are JSON-encoded so nothing configured can break out of a string literal, and
155
- * escaping the RESULT for HTML (`</script`, `<!--`) is left to whoever composes the final inline
156
- * script — the same discipline `consentBootstrapScript` follows, and `googleTagHeadScript` already
157
- * applies to the whole script it stamps.
158
- */
159
- export const consentGateScript = (loaderExpr, opts) => {
160
- const gate = JSON.stringify(categoriesOf(opts).map(category => ({
161
- key: category.key,
162
- required: category.required === true,
163
- hasSignal: (category.signals ?? []).length > 0,
164
- })));
165
- const storageKey = JSON.stringify(opts?.storageKey ?? CONSENT_KEY);
166
- const event = JSON.stringify(CONSENT_EVENT);
167
- return `(function(w,d){` +
168
- `function ok(r){if(!r)return false;var cs=${gate};` +
169
- `for(var i=0;i<cs.length;i++){var c=cs[i];` +
170
- `if(!c.required&&c.hasSignal&&r[c.key]===true)return true}return false}` +
171
- `function load(){${loaderExpr}}` +
172
- `var raw=null;try{raw=w.localStorage.getItem(${storageKey})}catch(e){}` +
173
- `if(!raw){var p=('; '+d.cookie).split('; '+${storageKey}+'=');` +
174
- `if(p.length===2){raw=p.pop().split(';').shift()}}` +
175
- `var r=null;if(raw){try{r=JSON.parse(raw)}catch(e){r=null}}` +
176
- `if(ok(r)){load();return}` +
177
- `function h(ev){if(ok(ev&&ev.detail&&ev.detail.record)){` +
178
- `w.removeEventListener(${event},h);load()}}` +
179
- `w.addEventListener(${event},h)` +
180
- `})(window,document)`;
40
+ gtagConsent('consent', 'default', consentDefaults(categoriesOf(opts)));
41
+ win[CONSENT_SETUP_FLAG] = true;
42
+ };
43
+ const applyConsent = (record, opts) => {
44
+ const win = global();
45
+ if (win == null || opts?.silent === true) {
46
+ return;
47
+ }
48
+ const categories = categoriesOf(opts);
49
+ for (const category of categories) {
50
+ if (category.globalVar != null) {
51
+ win[category.globalVar] = category.required === true || record[category.key] === true;
52
+ }
53
+ }
54
+ gtagConsent('consent', 'update', consentUpdate(record, categories));
55
+ for (const category of categories) {
56
+ if (category.event != null && (category.required === true || record[category.key] === true)) {
57
+ win.dataLayer = win.dataLayer ?? [];
58
+ win.dataLayer.push({ event: category.event });
59
+ }
60
+ }
61
+ // A gate script (`consentGateScript`) that already decided NOT to load, because nothing was
62
+ // granted at the time it ran, has no other way to hear this. Consent Mode itself speaks only on
63
+ // `dataLayer`, which a tag that never loaded is not listening to.
64
+ if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function'
65
+ && typeof CustomEvent === 'function') {
66
+ window.dispatchEvent(new CustomEvent(CONSENT_EVENT, { detail: { record } }));
67
+ }
68
+ };
69
+ const trackingGranted = (record, categories = DEFAULT_CONSENT_CATEGORIES) => record != null && categories.some(category => !category.required && (category.signals?.length ?? 0) > 0 && record[category.key] === true);
70
+ const consentBootstrapScript = (opts) => {
71
+ const defaults = JSON.stringify(consentDefaults(categoriesOf(opts)));
72
+ const categories = JSON.stringify(categoriesOf(opts).map(category => ({
73
+ key: category.key,
74
+ required: category.required === true,
75
+ signals: category.signals ?? [],
76
+ globalVar: category.globalVar ?? null,
77
+ })));
78
+ const storageKey = JSON.stringify(opts?.storageKey ?? CONSENT_KEY);
79
+ const flag = JSON.stringify(CONSENT_SETUP_FLAG);
80
+ // Right after the default is pushed and before EITHER storage read below (this one, and the
81
+ // `consentGateScript` that is concatenated after this whole IIFE) — an adopted decision must
82
+ // already be in storage by the time anything reads it, so `gtm.js`'s own `page_view` never sees
83
+ // the parameter and a granted decision loads the tag on arrival. A page with no `opts.linker`
84
+ // gets an empty string here, unchanged from before this existed.
85
+ const linker = opts?.linker != null ? `${consentLinkHelper.consentLinkerScript(opts)};` : '';
86
+ return `(function(w,d){` +
87
+ `w.dataLayer=w.dataLayer||[];function g(){w.dataLayer.push(arguments)}` +
88
+ `if(w[${flag}])return;g('consent','default',${defaults});w[${flag}]=true;` +
89
+ linker +
90
+ `var raw=null;try{raw=w.localStorage.getItem(${storageKey})}catch(e){}` +
91
+ `if(!raw){var p=('; '+d.cookie).split('; '+${storageKey}+'=');` +
92
+ `if(p.length===2){raw=p.pop().split(';').shift()}}` +
93
+ `if(!raw)return;var r;try{r=JSON.parse(raw)}catch(e){return}` +
94
+ `var cs=${categories},u={};` +
95
+ `for(var i=0;i<cs.length;i++){var c=cs[i];var ok=c.required||r[c.key]===true;` +
96
+ `if(c.globalVar){w[c.globalVar]=ok}` +
97
+ `for(var j=0;j<c.signals.length;j++){var s=c.signals[j];` +
98
+ `u[s]=ok&&u[s]!=='denied'?'granted':'denied'}}` +
99
+ `g('consent','update',u)})(window,document)`;
100
+ };
101
+ const consentGateScript = (loaderExpr, opts) => {
102
+ const gate = JSON.stringify(categoriesOf(opts).map(category => ({
103
+ key: category.key,
104
+ required: category.required === true,
105
+ hasSignal: (category.signals ?? []).length > 0,
106
+ })));
107
+ const storageKey = JSON.stringify(opts?.storageKey ?? CONSENT_KEY);
108
+ const event = JSON.stringify(CONSENT_EVENT);
109
+ return `(function(w,d){` +
110
+ `function ok(r){if(!r)return false;var cs=${gate};` +
111
+ `for(var i=0;i<cs.length;i++){var c=cs[i];` +
112
+ `if(!c.required&&c.hasSignal&&r[c.key]===true)return true}return false}` +
113
+ `function load(){${loaderExpr}}` +
114
+ `var raw=null;try{raw=w.localStorage.getItem(${storageKey})}catch(e){}` +
115
+ `if(!raw){var p=('; '+d.cookie).split('; '+${storageKey}+'=');` +
116
+ `if(p.length===2){raw=p.pop().split(';').shift()}}` +
117
+ `var r=null;if(raw){try{r=JSON.parse(raw)}catch(e){r=null}}` +
118
+ `if(ok(r)){load();return}` +
119
+ `function h(ev){if(ok(ev&&ev.detail&&ev.detail.record)){` +
120
+ `w.removeEventListener(${event},h);load()}}` +
121
+ `w.addEventListener(${event},h)` +
122
+ `})(window,document)`;
123
+ };
124
+ return {
125
+ gtagConsent, consentDefaults, consentUpdate, pushConsentDefaults, applyConsent, trackingGranted,
126
+ consentBootstrapScript, consentGateScript,
127
+ };
181
128
  };
129
+ export const consentModeHelper = createConsentModeHelper();
130
+ /** @deprecated compat:factory-refactor — use `consentModeHelper.consentBootstrapScript(…)` */
131
+ export const consentBootstrapScript = (opts) => consentModeHelper.consentBootstrapScript(opts);
182
132
  //# sourceMappingURL=gtm.js.map
package/build/gtm.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"gtm.js","sourceRoot":"","sources":["../src/gtm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,EACvE,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAIjD,MAAM,MAAM,GAAG,GAAyB,EAAE,CACxC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAkC,CAAC,CAAC,CAAC,IAAI,CAAA;AAE3E;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,KAAgB;IAC7C,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IACpB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAM;IACR,CAAC;IACD,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,EAAE,CAAA;IACnC,iGAAiG;IACjG,iDAAiD;IACjD,8CAA8C;IAC9C,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,YAAY,GAA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YACtB,4CAA4C,IAAI,GAAG;YACnD,2CAA2C;YAC3C,wEAAwE;YACxE,mBAAmB,UAAU,GAAG;YAChC,+CAA+C,UAAU,cAAc;YACvE,6CAA6C,UAAU,QAAQ;YAC/D,mDAAmD;YACnD,4DAA4D;YAC5D,0BAA0B;YAC1B,yDAAyD;YACzD,yBAAyB,KAAK,cAAc;YAC5C,sBAAsB,KAAK,KAAK;YAChC,qBAAqB,CAAA;IACzB,CAAC,CAAA;IAED,OAAO;QACL,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe;QAC/F,sBAAsB,EAAE,iBAAiB;KAC1C,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,EAAE,CAAA;AAE1D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,IAAqB,EAAU,EAAE,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { ConsentLocale } from '../types.js';
2
+ /** The dialog's built-in copy: the locale it is read in, the house translate shape, placeholders. */
3
+ export interface ConsentI18nHelper {
4
+ /** A locale reduced to one the built-in copy carries — its base tag, else `en`. */
5
+ normalizeLocale: (locale?: string) => ConsentLocale;
6
+ /** `(key, defaultValue) => string`, the house shape, backed by the built-in bundle. */
7
+ defaultConsentTranslate: (locale?: string) => (key: string, defaultValue: string) => string;
8
+ /** Substitute `{{name}}` placeholders. Enough for the two the policy page needs. */
9
+ interpolate: (text: string, values: Record<string, string | number>) => string;
10
+ }
11
+ //# sourceMappingURL=types.d.ts.map