@tilli-pro/cookieconsent-plugin 0.7.50 → 0.7.52

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 (40) hide show
  1. package/.cache/tsbuildinfo.json +1 -1
  2. package/dist/config/gui-options/scripts/cookiePrefsButtonDragObserver.d.ts +2 -1
  3. package/dist/config/gui-options/scripts/cookiePrefsButtonDragObserver.d.ts.map +1 -1
  4. package/dist/config/gui-options/scripts/cookiePrefsButtonDragObserver.js +2 -6
  5. package/dist/config/gui-options/scripts/injectManageCookiePrefsButton.d.ts +3 -4
  6. package/dist/config/gui-options/scripts/injectManageCookiePrefsButton.d.ts.map +1 -1
  7. package/dist/config/gui-options/scripts/injectManageCookiePrefsButton.js +6 -9
  8. package/dist/config/gui-options/scripts/showPreferences.mjs.d.ts +3 -0
  9. package/dist/config/gui-options/scripts/showPreferences.mjs.d.ts.map +1 -0
  10. package/dist/config/gui-options/scripts/showPreferences.mjs.js +6 -0
  11. package/dist/config/gui-options/scripts/showPreferences.node.d.ts +2 -0
  12. package/dist/config/gui-options/scripts/showPreferences.node.d.ts.map +1 -0
  13. package/dist/config/gui-options/scripts/showPreferences.node.js +1 -0
  14. package/dist/init/brf.js +2 -1
  15. package/dist/init/nudge-website.js +2 -1
  16. package/dist/init/nudge.js +2 -1
  17. package/dist/init/tilli-pay-website.js +2 -1
  18. package/dist/init/tilli-pay.js +2 -1
  19. package/dist/init/tilli-website.js +2 -1
  20. package/dist/init/tilliX.js +2 -1
  21. package/dist/init/utils.d.ts +2 -1
  22. package/dist/init/utils.d.ts.map +1 -1
  23. package/dist/init/utils.js +2 -2
  24. package/dist/react-components/hooks/useCookieConsent.d.ts.map +1 -1
  25. package/dist/react-components/hooks/useCookieConsent.js +2 -1
  26. package/package.json +1 -1
  27. package/src/config/gui-options/scripts/cookiePrefsButtonDragObserver.ts +3 -6
  28. package/src/config/gui-options/scripts/injectManageCookiePrefsButton.ts +9 -19
  29. package/src/config/gui-options/scripts/showPreferences.d.ts +5 -0
  30. package/src/config/gui-options/scripts/showPreferences.mjs.ts +18 -0
  31. package/src/config/gui-options/scripts/showPreferences.node.ts +1 -0
  32. package/src/init/brf.ts +2 -1
  33. package/src/init/nudge-website.ts +2 -1
  34. package/src/init/nudge.ts +2 -1
  35. package/src/init/tilli-pay-website.ts +2 -1
  36. package/src/init/tilli-pay.ts +2 -1
  37. package/src/init/tilli-website.ts +2 -1
  38. package/src/init/tilliX.ts +2 -1
  39. package/src/init/utils.ts +3 -1
  40. package/src/react-components/hooks/useCookieConsent.ts +2 -1
@@ -1,3 +1,4 @@
1
+ import type { ShowPreferencesFn } from "./showPreferences.d";
1
2
  /**
2
3
  * attach a MutationObserver the **first time** the user hovers over–
3
4
  * enabling a limited "drag up" functionality for the floating button.
@@ -14,7 +15,7 @@ export type HTMLDivElementWithDragObserver = HTMLDivElement & {
14
15
  _startY?: number | null;
15
16
  };
16
17
  /** determine whether the user "tapped" or "dragged" (open prefs if "tapped") */
17
- export declare const ontouchend: HTMLDivElementWithDragObserver["ontouchend"];
18
+ export declare const ontouchend: (this: HTMLDivElementWithDragObserver, e: TouchEvent, showPreferences: ShowPreferencesFn) => void;
18
19
  /** store the touch start coordinates */
19
20
  export declare const ontouchstart: HTMLDivElementWithDragObserver["ontouchstart"];
20
21
  //# sourceMappingURL=cookiePrefsButtonDragObserver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookiePrefsButtonDragObserver.d.ts","sourceRoot":"","sources":["../../../../src/config/gui-options/scripts/cookiePrefsButtonDragObserver.ts"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;yBAuHG,OAAO,SAAS,OAAO,eAAe,cAAc,CAAC,OAAO,SAAS,IAAI,GAC3E,cAAc,GACd,aAAa,CAAC;AAxHlB,wBAwHoB;AAEpB,MAAM,MAAM,8BAA8B,GAAG,cAAc,GAAG;IAC5D,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,UAAU,EA0BlB,8BAA8B,CAAC,YAAY,CAAC,CAAC;AAElD,wCAAwC;AACxC,eAAO,MAAM,YAAY,EAOpB,8BAA8B,CAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"cookiePrefsButtonDragObserver.d.ts","sourceRoot":"","sources":["../../../../src/config/gui-options/scripts/cookiePrefsButtonDragObserver.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;GAQG;yBAuHG,OAAO,SAAS,OAAO,eAAe,cAAc,CAAC,OAAO,SAAS,IAAI,GAC3E,cAAc,GACd,aAAa,CAAC;AAxHlB,wBAwHoB;AAEpB,MAAM,MAAM,8BAA8B,GAAG,cAAc,GAAG;IAC5D,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,UAAU,SACf,8BAA8B,KACjC,UAAU,mBACI,iBAAiB,KACjC,IAuBF,CAAA;AAED,wCAAwC;AACxC,eAAO,MAAM,YAAY,EAOpB,8BAA8B,CAAC,cAAc,CAAC,CAAC"}
@@ -1,9 +1,5 @@
1
1
  "use client";
2
2
  import { buttonId } from "../html-components/ManageCookiePrefsButton";
3
- // import { showPreferences } from "./injectManageCookiePrefsButton";
4
- const showPreferences = () => {
5
- console.debug("showPreferences");
6
- };
7
3
  /**
8
4
  * attach a MutationObserver the **first time** the user hovers over–
9
5
  * enabling a limited "drag up" functionality for the floating button.
@@ -119,7 +115,7 @@ export default (function (e) {
119
115
  attachDragEvents(button);
120
116
  });
121
117
  /** determine whether the user "tapped" or "dragged" (open prefs if "tapped") */
122
- export const ontouchend = function ontouchend(e) {
118
+ export const ontouchend = function ontouchend(e, showPreferences) {
123
119
  const touch = e.changedTouches[0];
124
120
  const { clientX: endX, clientY: endY } = touch ?? {};
125
121
  if (!endX || !endY)
@@ -137,7 +133,7 @@ export const ontouchend = function ontouchend(e) {
137
133
  /** reset coordinates to avoid future issues */
138
134
  this._startX = null;
139
135
  this._startY = null;
140
- };
136
+ }; // as HTMLDivElementWithDragObserver["ontouchend"]; // disabled since we added `showPreferences` as a param
141
137
  /** store the touch start coordinates */
142
138
  export const ontouchstart = function ontouchstart(e) {
143
139
  const touch = e.touches[0];
@@ -1,8 +1,7 @@
1
- import type * as _CookieConsent from "@tilli-pro/cookieconsent";
2
- export declare const showPreferences: typeof _CookieConsent.showPreferences;
1
+ import type { ShowPreferencesFn } from "./showPreferences.d";
3
2
  /** injects the floating cookie consent "manage preferences" icon button into the DOM */
4
- declare const inject: () => HTMLDivElement;
3
+ declare const inject: (showPreferences: ShowPreferencesFn) => HTMLDivElement;
5
4
  /** entry point */
6
- export declare function injectManageCookiePrefsButton(): ReturnType<typeof inject>;
5
+ export declare function injectManageCookiePrefsButton(showPreferences: ShowPreferencesFn): ReturnType<typeof inject>;
7
6
  export {};
8
7
  //# sourceMappingURL=injectManageCookiePrefsButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectManageCookiePrefsButton.d.ts","sourceRoot":"","sources":["../../../../src/config/gui-options/scripts/injectManageCookiePrefsButton.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,cAAc,MAAM,0BAA0B,CAAC;AAiBhE,eAAO,MAAM,eAAe,uCAIoC,CAAC;AAEjE,wFAAwF;AACxF,QAAA,MAAM,MAAM,QAAO,cAkBlB,CAAC;AAEF,kBAAkB;AAClB,wBAAgB,6BAA6B,IAAI,UAAU,CAAC,OAAO,MAAM,CAAC,CAiBzE"}
1
+ {"version":3,"file":"injectManageCookiePrefsButton.d.ts","sourceRoot":"","sources":["../../../../src/config/gui-options/scripts/injectManageCookiePrefsButton.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,wFAAwF;AACxF,QAAA,MAAM,MAAM,oBAAqB,iBAAiB,KAAG,cAkBpD,CAAC;AAEF,kBAAkB;AAClB,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,iBAAiB,GACjC,UAAU,CAAC,OAAO,MAAM,CAAC,CAkB3B"}
@@ -1,19 +1,15 @@
1
1
  "use client";
2
2
  import ManageCookiePrefsButton, { containerId, } from "../html-components/ManageCookiePrefsButton";
3
3
  import cookiePrefsButtonDragObserver, { ontouchend, ontouchstart, } from "./cookiePrefsButtonDragObserver";
4
- export const showPreferences = typeof CookieConsent !== "undefined" &&
5
- typeof CookieConsent.showPreferences === "function"
6
- ? CookieConsent.showPreferences
7
- : (await import("@tilli-pro/cookieconsent")).showPreferences;
8
4
  /** injects the floating cookie consent "manage preferences" icon button into the DOM */
9
- const inject = () => {
5
+ const inject = (showPreferences) => {
10
6
  const container = document.body.appendChild(Object.assign(document.createElement("div"), {
11
7
  id: containerId,
12
8
  innerHTML: ManageCookiePrefsButton( /* TODO: __LANGUAGE__ */),
13
9
  onclick: showPreferences /** prefer over `data-cc="show-preferencesModal"` -- @see https://cookieconsent.orestbida.com/reference/api-reference.html#showpreferences */,
14
10
  onmouseover: cookiePrefsButtonDragObserver,
15
11
  // [mobile (touch) support]
16
- ontouchend,
12
+ ontouchend: (e) => ontouchend?.call(container, e, showPreferences),
17
13
  ontouchstart,
18
14
  }));
19
15
  /** load drag observer upon DOM injection (unfortunate fix to prevent the need for 2x "ontouchstart" events) */
@@ -21,7 +17,7 @@ const inject = () => {
21
17
  return container;
22
18
  };
23
19
  /** entry point */
24
- export function injectManageCookiePrefsButton() {
20
+ export function injectManageCookiePrefsButton(showPreferences) {
25
21
  return ((container) => {
26
22
  /** observe the DOM (to handle the case where the injected manage prefs button somehow gets removed) */
27
23
  new MutationObserver(() => {
@@ -30,8 +26,9 @@ export function injectManageCookiePrefsButton() {
30
26
  if (alreadyInjected)
31
27
  return;
32
28
  /** if the container is no longer in <body>, re-inject */
33
- container = inject();
29
+ container = inject(showPreferences);
34
30
  }).observe(document.body, { childList: true, subtree: true });
35
31
  return container;
36
- })(document.getElementById(containerId) ?? inject());
32
+ })(document.getElementById(containerId) ??
33
+ inject(showPreferences));
37
34
  }
@@ -0,0 +1,3 @@
1
+ import type * as _CookieConsent from "@tilli-pro/cookieconsent";
2
+ export declare const showPreferences: typeof _CookieConsent.showPreferences;
3
+ //# sourceMappingURL=showPreferences.mjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"showPreferences.mjs.d.ts","sourceRoot":"","sources":["../../../../src/config/gui-options/scripts/showPreferences.mjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,cAAc,MAAM,0BAA0B,CAAC;AAShE,eAAO,MAAM,eAAe,uCAQc,CAAC"}
@@ -0,0 +1,6 @@
1
+ export const showPreferences = typeof CookieConsent !== "undefined" &&
2
+ typeof CookieConsent.showPreferences === "function"
3
+ ? CookieConsent.showPreferences
4
+ : (() => {
5
+ console.error("Attempted to open cookie preferences modal, but the cookie consent plugin is not available at this time.");
6
+ })();
@@ -0,0 +1,2 @@
1
+ export { showPreferences } from "@tilli-pro/cookieconsent";
2
+ //# sourceMappingURL=showPreferences.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"showPreferences.node.d.ts","sourceRoot":"","sources":["../../../../src/config/gui-options/scripts/showPreferences.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export { showPreferences } from "@tilli-pro/cookieconsent";
package/dist/init/brf.js CHANGED
@@ -3,6 +3,7 @@ import { LABELS } from "../config/categories/labels";
3
3
  import cookies from "../config/cookies";
4
4
  import { run } from "../init";
5
5
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
6
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
6
7
  // TODO: auto-detect detect language
7
8
  const __LANGUAGE__ = "en"; // "English" ("English")
8
9
  const categories = {
@@ -61,5 +62,5 @@ const config = {
61
62
  language,
62
63
  };
63
64
  // console.debug({ config }, "Initializing Cookie Consent (BRF)...");
64
- const init = makeInitFn(run, config);
65
+ const init = makeInitFn(run, config, showPreferences);
65
66
  void init();
@@ -1,6 +1,7 @@
1
1
  import _config from "../config";
2
2
  import { run } from "../init";
3
3
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
4
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
4
5
  const categories = {
5
6
  necessary: {
6
7
  enabled: true, // "necessary" category is always enabled.
@@ -120,5 +121,5 @@ const config = {
120
121
  language,
121
122
  };
122
123
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
123
- const init = makeInitFn(run, config);
124
+ const init = makeInitFn(run, config, showPreferences);
124
125
  void init();
@@ -1,6 +1,7 @@
1
1
  import _config from "../config";
2
2
  import { run } from "../init";
3
3
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
4
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
4
5
  const categories = {
5
6
  necessary: {
6
7
  enabled: true, // "necessary" category is always enabled.
@@ -28,5 +29,5 @@ const config = {
28
29
  language,
29
30
  };
30
31
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
31
- const init = makeInitFn(run, config);
32
+ const init = makeInitFn(run, config, showPreferences);
32
33
  void init();
@@ -1,6 +1,7 @@
1
1
  import _config from "../config";
2
2
  import { run } from "../init";
3
3
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
4
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
4
5
  // TODO: migrate from monay.com to tillipay.com
5
6
  const categories = {
6
7
  necessary: {
@@ -200,5 +201,5 @@ const config = {
200
201
  language,
201
202
  };
202
203
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
203
- const init = makeInitFn(run, config);
204
+ const init = makeInitFn(run, config, showPreferences);
204
205
  void init();
@@ -1,6 +1,7 @@
1
1
  import _config from "../config";
2
2
  import { run } from "../init";
3
3
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
4
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
4
5
  const categories = {
5
6
  necessary: {
6
7
  enabled: true, // "necessary" category is always enabled.
@@ -18,5 +19,5 @@ const config = {
18
19
  language,
19
20
  };
20
21
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
21
- const init = makeInitFn(run, config);
22
+ const init = makeInitFn(run, config, showPreferences);
22
23
  void init();
@@ -1,6 +1,7 @@
1
1
  import _config from "../config";
2
2
  import { run } from "../init";
3
3
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
4
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
4
5
  const categories = {
5
6
  necessary: {
6
7
  enabled: true, // "necessary" category is always enabled.
@@ -206,5 +207,5 @@ const config = {
206
207
  language,
207
208
  };
208
209
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
209
- const init = makeInitFn(run, config);
210
+ const init = makeInitFn(run, config, showPreferences);
210
211
  void init();
@@ -1,6 +1,7 @@
1
1
  import _config from "../config";
2
2
  import { run } from "../init";
3
3
  import { makeInitFn, stripInvalidLinkedCategoriesFromTranslations, } from "./utils";
4
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
4
5
  const categories = {
5
6
  necessary: {
6
7
  enabled: true, // "necessary" category is always enabled.
@@ -20,5 +21,5 @@ const config = {
20
21
  language,
21
22
  };
22
23
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
23
- const init = makeInitFn(run, config);
24
+ const init = makeInitFn(run, config, showPreferences);
24
25
  void init();
@@ -1,5 +1,6 @@
1
1
  import type { CookieConsentConfig } from "@tilli-pro/cookieconsent";
2
2
  import type * as CookieConsent from "@tilli-pro/cookieconsent";
3
- export declare const makeInitFn: (initFn: typeof CookieConsent.run, config: CookieConsentConfig) => () => Promise<void>;
3
+ import type { ShowPreferencesFn } from "../config/gui-options/scripts/showPreferences.d";
4
+ export declare const makeInitFn: (initFn: typeof CookieConsent.run, config: CookieConsentConfig, showPreferences: ShowPreferencesFn) => () => Promise<void>;
4
5
  export declare const stripInvalidLinkedCategoriesFromTranslations: (translations: CookieConsentConfig["language"]["translations"], categories: CookieConsentConfig["categories"], alsoClearCookieTables?: boolean) => CookieConsentConfig["language"]["translations"];
5
6
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/init/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAK/D,eAAO,MAAM,UAAU,WACb,OAAO,aAAa,CAAC,GAAG,UACxB,mBAAmB,wBAiB5B,CAAC;AAEF,eAAO,MAAM,4CAA4C,iBACzC,mBAAmB,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,cACjD,mBAAmB,CAAC,YAAY,CAAC,0BACtB,OAAO,KAC7B,mBAAmB,CAAC,UAAU,CAAC,CAAC,cAAc,CAkC9C,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/init/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,KAAK,aAAa,MAAM,0BAA0B,CAAC;AAI/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAEzF,eAAO,MAAM,UAAU,WACb,OAAO,aAAa,CAAC,GAAG,UACxB,mBAAmB,mBACV,iBAAiB,wBAiBnC,CAAC;AAEF,eAAO,MAAM,4CAA4C,iBACzC,mBAAmB,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,cACjD,mBAAmB,CAAC,YAAY,CAAC,0BACtB,OAAO,KAC7B,mBAAmB,CAAC,UAAU,CAAC,CAAC,cAAc,CAkC9C,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { injectReactRemoveScrollToggle } from "../config/gui-options/scripts/forceDisableReactRemoveScroll";
2
2
  import { injectManageCookiePrefsButton } from "../config/gui-options/scripts/injectManageCookiePrefsButton";
3
- export const makeInitFn = (initFn, config) => {
3
+ export const makeInitFn = (initFn, config, showPreferences) => {
4
4
  return async () => {
5
5
  /** inject the cookie-consent banner (pop-up) */
6
6
  await initFn(config);
7
7
  /** ...then, inject the floating cookie consent "manage preferences" icon button into the DOM (floats @ the bottom right) */
8
- injectManageCookiePrefsButton();
8
+ injectManageCookiePrefsButton(showPreferences);
9
9
  /** ...and, force-disable "react-remove-scroll" -- only upon opening up the "manage preferences" dialog
10
10
  *
11
11
  * > this handles the edge case where there's a shadcn (radix-ui) dialog open
@@ -1 +1 @@
1
- {"version":3,"file":"useCookieConsent.d.ts","sourceRoot":"","sources":["../../../src/react-components/hooks/useCookieConsent.ts"],"names":[],"mappings":"AAUA,wBAAgB,gBAAgB,SAO/B"}
1
+ {"version":3,"file":"useCookieConsent.d.ts","sourceRoot":"","sources":["../../../src/react-components/hooks/useCookieConsent.ts"],"names":[],"mappings":"AAWA,wBAAgB,gBAAgB,SAO/B"}
@@ -4,11 +4,12 @@ import { run } from "@tilli-pro/cookieconsent";
4
4
  import { COOKIE_CONSENT_ENABLED } from "../../_consts";
5
5
  import config from "../../config";
6
6
  import { makeInitFn } from "../../init/utils";
7
+ import { showPreferences } from "../../config/gui-options/scripts/showPreferences.node";
7
8
  export function useCookieConsent() {
8
9
  useEffect(() => {
9
10
  if (!COOKIE_CONSENT_ENABLED)
10
11
  return;
11
- const init = makeInitFn(run, config);
12
+ const init = makeInitFn(run, config, showPreferences);
12
13
  void init();
13
14
  }, []);
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tilli-pro/cookieconsent-plugin",
3
- "version": "0.7.50",
3
+ "version": "0.7.52",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -3,11 +3,7 @@
3
3
  import type * as _CookieConsent from "@tilli-pro/cookieconsent";
4
4
 
5
5
  import { buttonId } from "../html-components/ManageCookiePrefsButton";
6
- // import { showPreferences } from "./injectManageCookiePrefsButton";
7
-
8
- const showPreferences = () => {
9
- console.debug("showPreferences");
10
- };
6
+ import type { ShowPreferencesFn } from "./showPreferences.d";
11
7
 
12
8
  /**
13
9
  * attach a MutationObserver the **first time** the user hovers over–
@@ -149,6 +145,7 @@ export type HTMLDivElementWithDragObserver = HTMLDivElement & {
149
145
  export const ontouchend = function ontouchend(
150
146
  this: HTMLDivElementWithDragObserver,
151
147
  e: TouchEvent,
148
+ showPreferences: ShowPreferencesFn,
152
149
  ): void {
153
150
  const touch = e.changedTouches[0];
154
151
  const { clientX: endX, clientY: endY } = touch ?? {};
@@ -172,7 +169,7 @@ export const ontouchend = function ontouchend(
172
169
  /** reset coordinates to avoid future issues */
173
170
  this._startX = null;
174
171
  this._startY = null;
175
- } as HTMLDivElementWithDragObserver["ontouchend"];
172
+ } // as HTMLDivElementWithDragObserver["ontouchend"]; // disabled since we added `showPreferences` as a param
176
173
 
177
174
  /** store the touch start coordinates */
178
175
  export const ontouchstart = function ontouchstart(
@@ -1,7 +1,5 @@
1
1
  "use client";
2
2
 
3
- import type * as _CookieConsent from "@tilli-pro/cookieconsent";
4
-
5
3
  import type { HTMLDivElementWithDragObserver } from "./cookiePrefsButtonDragObserver";
6
4
  import ManageCookiePrefsButton, {
7
5
  containerId,
@@ -10,21 +8,10 @@ import cookiePrefsButtonDragObserver, {
10
8
  ontouchend,
11
9
  ontouchstart,
12
10
  } from "./cookiePrefsButtonDragObserver";
13
-
14
- declare const CookieConsent:
15
- | {
16
- showPreferences?: typeof _CookieConsent.showPreferences;
17
- }
18
- | undefined;
19
-
20
- export const showPreferences =
21
- typeof CookieConsent !== "undefined" &&
22
- typeof CookieConsent.showPreferences === "function"
23
- ? CookieConsent.showPreferences
24
- : (await import("@tilli-pro/cookieconsent")).showPreferences;
11
+ import type { ShowPreferencesFn } from "./showPreferences.d";
25
12
 
26
13
  /** injects the floating cookie consent "manage preferences" icon button into the DOM */
27
- const inject = (): HTMLDivElement => {
14
+ const inject = (showPreferences: ShowPreferencesFn): HTMLDivElement => {
28
15
  const container = document.body.appendChild(
29
16
  Object.assign(document.createElement("div"), {
30
17
  id: containerId,
@@ -33,7 +20,7 @@ const inject = (): HTMLDivElement => {
33
20
  showPreferences /** prefer over `data-cc="show-preferencesModal"` -- @see https://cookieconsent.orestbida.com/reference/api-reference.html#showpreferences */,
34
21
  onmouseover: cookiePrefsButtonDragObserver,
35
22
  // [mobile (touch) support]
36
- ontouchend,
23
+ ontouchend: (e) => ontouchend?.call(container, e, showPreferences),
37
24
  ontouchstart,
38
25
  } satisfies Partial<HTMLDivElement>),
39
26
  ) as HTMLDivElementWithDragObserver;
@@ -45,7 +32,9 @@ const inject = (): HTMLDivElement => {
45
32
  };
46
33
 
47
34
  /** entry point */
48
- export function injectManageCookiePrefsButton(): ReturnType<typeof inject> {
35
+ export function injectManageCookiePrefsButton(
36
+ showPreferences: ShowPreferencesFn,
37
+ ): ReturnType<typeof inject> {
49
38
  return ((container) => {
50
39
  /** observe the DOM (to handle the case where the injected manage prefs button somehow gets removed) */
51
40
  new MutationObserver(() => {
@@ -55,11 +44,12 @@ export function injectManageCookiePrefsButton(): ReturnType<typeof inject> {
55
44
  if (alreadyInjected) return;
56
45
 
57
46
  /** if the container is no longer in <body>, re-inject */
58
- container = inject();
47
+ container = inject(showPreferences);
59
48
  }).observe(document.body, { childList: true, subtree: true });
60
49
 
61
50
  return container;
62
51
  })(
63
- (document.getElementById(containerId) as HTMLDivElement | null) ?? inject(),
52
+ (document.getElementById(containerId) as HTMLDivElement | null) ??
53
+ inject(showPreferences),
64
54
  );
65
55
  }
@@ -0,0 +1,5 @@
1
+ import type CookieConsent from "@tilli-pro/cookieconsent";
2
+
3
+ export type ShowPreferencesFn = NonNullable<
4
+ NonNullable<typeof CookieConsent>["showPreferences"]
5
+ >;
@@ -0,0 +1,18 @@
1
+ import type * as _CookieConsent from "@tilli-pro/cookieconsent";
2
+ import type { ShowPreferencesFn } from "./showPreferences.d";
3
+
4
+ declare const CookieConsent:
5
+ | {
6
+ showPreferences?: typeof _CookieConsent.showPreferences;
7
+ }
8
+ | undefined;
9
+
10
+ export const showPreferences =
11
+ typeof CookieConsent !== "undefined" &&
12
+ typeof CookieConsent.showPreferences === "function"
13
+ ? CookieConsent.showPreferences
14
+ : (() => {
15
+ console.error(
16
+ "Attempted to open cookie preferences modal, but the cookie consent plugin is not available at this time.",
17
+ );
18
+ })() as unknown as ShowPreferencesFn;
@@ -0,0 +1 @@
1
+ export { showPreferences } from "@tilli-pro/cookieconsent";
package/src/init/brf.ts CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  makeInitFn,
9
9
  stripInvalidLinkedCategoriesFromTranslations,
10
10
  } from "./utils";
11
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
11
12
 
12
13
  // TODO: auto-detect detect language
13
14
  const __LANGUAGE__ = "en"; // "English" ("English")
@@ -74,5 +75,5 @@ const config: CookieConsentConfig = {
74
75
  };
75
76
 
76
77
  // console.debug({ config }, "Initializing Cookie Consent (BRF)...");
77
- const init = makeInitFn(run, config);
78
+ const init = makeInitFn(run, config, showPreferences);
78
79
  void init();
@@ -6,6 +6,7 @@ import {
6
6
  makeInitFn,
7
7
  stripInvalidLinkedCategoriesFromTranslations,
8
8
  } from "./utils";
9
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
9
10
 
10
11
  const categories: CookieConsentConfig["categories"] = {
11
12
  necessary: {
@@ -136,5 +137,5 @@ const config: CookieConsentConfig = {
136
137
  };
137
138
 
138
139
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
139
- const init = makeInitFn(run, config);
140
+ const init = makeInitFn(run, config, showPreferences);
140
141
  void init();
package/src/init/nudge.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  makeInitFn,
7
7
  stripInvalidLinkedCategoriesFromTranslations,
8
8
  } from "./utils";
9
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
9
10
 
10
11
  const categories: CookieConsentConfig["categories"] = {
11
12
  necessary: {
@@ -41,5 +42,5 @@ const config: CookieConsentConfig = {
41
42
  };
42
43
 
43
44
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
44
- const init = makeInitFn(run, config);
45
+ const init = makeInitFn(run, config, showPreferences);
45
46
  void init();
@@ -6,6 +6,7 @@ import {
6
6
  makeInitFn,
7
7
  stripInvalidLinkedCategoriesFromTranslations,
8
8
  } from "./utils";
9
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
9
10
 
10
11
  // TODO: migrate from monay.com to tillipay.com
11
12
 
@@ -217,5 +218,5 @@ const config: CookieConsentConfig = {
217
218
  };
218
219
 
219
220
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
220
- const init = makeInitFn(run, config);
221
+ const init = makeInitFn(run, config, showPreferences);
221
222
  void init();
@@ -6,6 +6,7 @@ import {
6
6
  makeInitFn,
7
7
  stripInvalidLinkedCategoriesFromTranslations,
8
8
  } from "./utils";
9
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
9
10
 
10
11
  const categories: CookieConsentConfig["categories"] = {
11
12
  necessary: {
@@ -31,5 +32,5 @@ const config: CookieConsentConfig = {
31
32
  };
32
33
 
33
34
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
34
- const init = makeInitFn(run, config);
35
+ const init = makeInitFn(run, config, showPreferences);
35
36
  void init();
@@ -6,6 +6,7 @@ import {
6
6
  makeInitFn,
7
7
  stripInvalidLinkedCategoriesFromTranslations,
8
8
  } from "./utils";
9
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
9
10
 
10
11
  const categories: CookieConsentConfig["categories"] = {
11
12
  necessary: {
@@ -223,5 +224,5 @@ const config: CookieConsentConfig = {
223
224
  };
224
225
 
225
226
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
226
- const init = makeInitFn(run, config);
227
+ const init = makeInitFn(run, config, showPreferences);
227
228
  void init();
@@ -6,6 +6,7 @@ import {
6
6
  makeInitFn,
7
7
  stripInvalidLinkedCategoriesFromTranslations,
8
8
  } from "./utils";
9
+ import { showPreferences } from "../config/gui-options/scripts/showPreferences.mjs";
9
10
 
10
11
  const categories: CookieConsentConfig["categories"] = {
11
12
  necessary: {
@@ -33,5 +34,5 @@ const config: CookieConsentConfig = {
33
34
  };
34
35
 
35
36
  // console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
36
- const init = makeInitFn(run, config);
37
+ const init = makeInitFn(run, config, showPreferences);
37
38
  void init();
package/src/init/utils.ts CHANGED
@@ -3,17 +3,19 @@ import type * as CookieConsent from "@tilli-pro/cookieconsent";
3
3
 
4
4
  import { injectReactRemoveScrollToggle } from "../config/gui-options/scripts/forceDisableReactRemoveScroll";
5
5
  import { injectManageCookiePrefsButton } from "../config/gui-options/scripts/injectManageCookiePrefsButton";
6
+ import type { ShowPreferencesFn } from "../config/gui-options/scripts/showPreferences.d";
6
7
 
7
8
  export const makeInitFn = (
8
9
  initFn: typeof CookieConsent.run,
9
10
  config: CookieConsentConfig,
11
+ showPreferences: ShowPreferencesFn,
10
12
  ) => {
11
13
  return async () => {
12
14
  /** inject the cookie-consent banner (pop-up) */
13
15
  await initFn(config);
14
16
 
15
17
  /** ...then, inject the floating cookie consent "manage preferences" icon button into the DOM (floats @ the bottom right) */
16
- injectManageCookiePrefsButton();
18
+ injectManageCookiePrefsButton(showPreferences);
17
19
 
18
20
  /** ...and, force-disable "react-remove-scroll" -- only upon opening up the "manage preferences" dialog
19
21
  *
@@ -7,12 +7,13 @@ import { run } from "@tilli-pro/cookieconsent";
7
7
  import { COOKIE_CONSENT_ENABLED } from "../../_consts";
8
8
  import config from "../../config";
9
9
  import { makeInitFn } from "../../init/utils";
10
+ import { showPreferences } from "../../config/gui-options/scripts/showPreferences.node";
10
11
 
11
12
  export function useCookieConsent() {
12
13
  useEffect(() => {
13
14
  if (!COOKIE_CONSENT_ENABLED) return;
14
15
 
15
- const init = makeInitFn(run, config);
16
+ const init = makeInitFn(run, config, showPreferences);
16
17
  void init();
17
18
  }, []);
18
19
  }