@tilli-pro/cookieconsent-plugin 0.2.1 → 0.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/tsbuildinfo.json +1 -1
- package/dist/_types.d.ts +3 -0
- package/dist/_types.d.ts.map +1 -0
- package/dist/_types.js +1 -0
- package/dist/_utils.d.ts +10 -0
- package/dist/_utils.d.ts.map +1 -0
- package/dist/_utils.js +31 -0
- package/dist/config/gui-options/scripts/cookiePrefsButtonDragObserver.d.ts.map +1 -1
- package/dist/config/gui-options/scripts/cookiePrefsButtonDragObserver.js +1 -1
- package/dist/config/gui-options/scripts/injectManageCookiePrefsButton.d.ts +2 -0
- package/dist/config/gui-options/scripts/injectManageCookiePrefsButton.d.ts.map +1 -1
- package/dist/config/gui-options/scripts/injectManageCookiePrefsButton.js +4 -1
- package/dist/config/index.d.ts +26 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +5 -1
- package/dist/config/translations/de/index.d.ts +5 -0
- package/dist/config/translations/de/index.d.ts.map +1 -1
- package/dist/config/translations/de/index.js +5 -0
- package/dist/config/translations/en/index.d.ts +5 -0
- package/dist/config/translations/en/index.d.ts.map +1 -1
- package/dist/config/translations/en/index.js +5 -0
- package/dist/config/translations/es/index.d.ts +5 -0
- package/dist/config/translations/es/index.d.ts.map +1 -1
- package/dist/config/translations/es/index.js +5 -0
- package/dist/config/translations/fr/index.d.ts +5 -0
- package/dist/config/translations/fr/index.d.ts.map +1 -1
- package/dist/config/translations/fr/index.js +5 -0
- package/dist/config/translations/index.d.ts +25 -0
- package/dist/config/translations/index.d.ts.map +1 -1
- package/dist/config/translations/it/index.d.ts +5 -0
- package/dist/config/translations/it/index.d.ts.map +1 -1
- package/dist/config/translations/it/index.js +5 -0
- package/dist/init/brf.d.ts +2 -0
- package/dist/init/brf.d.ts.map +1 -0
- package/dist/init/brf.js +65 -0
- package/dist/init/tilli-website.d.ts +2 -0
- package/dist/init/tilli-website.d.ts.map +1 -0
- package/dist/init/tilli-website.js +24 -0
- package/dist/init/utils.d.ts +5 -0
- package/dist/init/utils.d.ts.map +1 -0
- package/dist/init/utils.js +39 -0
- package/dist/init/website.d.ts +2 -0
- package/dist/init/website.d.ts.map +1 -0
- package/dist/init/website.js +73 -0
- package/dist/init.d.ts +15 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +76 -3
- package/dist/react-components/CookieConsentInit.client.d.ts.map +1 -1
- package/dist/react-components/CookieConsentInit.client.js +2 -23
- package/dist/react-components/CookieConsentInit.server.d.ts +2 -2
- package/dist/react-components/CookieConsentInit.server.d.ts.map +1 -1
- package/dist/react-components/CookieConsentInit.server.js +2 -2
- package/dist/react-components/hooks/useCookieConsent.d.ts +4 -0
- package/dist/react-components/hooks/useCookieConsent.d.ts.map +1 -0
- package/dist/react-components/hooks/useCookieConsent.js +17 -0
- package/dist/styles/index.d.ts +8 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/index.js +6 -0
- package/package.json +1 -1
- package/scripts/postbuild/inject-plugin.ts +66 -18
- package/src/{react-components/_utils.ts → _utils.ts} +2 -2
- package/src/config/gui-options/scripts/cookiePrefsButtonDragObserver.ts +2 -1
- package/src/config/gui-options/scripts/injectManageCookiePrefsButton.ts +13 -1
- package/src/config/index.ts +14 -1
- package/src/config/translations/de/index.ts +7 -0
- package/src/config/translations/en/index.ts +7 -0
- package/src/config/translations/es/index.ts +7 -0
- package/src/config/translations/fr/index.ts +7 -0
- package/src/config/translations/it/index.ts +7 -0
- package/src/init/brf.ts +78 -0
- package/src/init/tilli-website.ts +37 -0
- package/src/init/utils.ts +66 -0
- package/src/init.ts +102 -3
- package/src/react-components/CookieConsentInit.client.tsx +2 -27
- package/src/react-components/CookieConsentInit.server.tsx +2 -2
- package/src/react-components/hooks/useCookieConsent.ts +30 -0
- package/src/styles/index.ts +6 -0
- package/src/styles/tenants/freeman.css +63 -0
- package/src/styles/tenants/frontier.css +71 -0
- /package/{src/react-components → dist}/styles/tenants/freeman.css +0 -0
- /package/{src/react-components → dist}/styles/tenants/frontier.css +0 -0
- /package/src/{react-components/_types.ts → _types.ts} +0 -0
package/dist/init.d.ts
CHANGED
@@ -1,2 +1,16 @@
|
|
1
|
-
import "https://
|
1
|
+
import "https://cdn.jsdelivr.net/gh/tilli-pro/cookieconsent@0f888b603ba1077d94776af62d2bfb7247e5ffe4/dist/cookieconsent.umd.js";
|
2
|
+
import type * as _CookieConsent from "@tilli-pro/cookieconsent";
|
3
|
+
import type { CookieConsentConfig } from "@tilli-pro/cookieconsent";
|
4
|
+
import { cookieConsentTheme } from "./_utils";
|
5
|
+
declare namespace CookieConsent {
|
6
|
+
const run: typeof _CookieConsent.run;
|
7
|
+
}
|
8
|
+
declare global {
|
9
|
+
interface Window {
|
10
|
+
cookieConsentTheme: typeof cookieConsentTheme;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
export declare const makeRemotePluginURL: (path: string) => string;
|
14
|
+
export declare const run: (config?: CookieConsentConfig) => ReturnType<typeof CookieConsent.run>;
|
15
|
+
export {};
|
2
16
|
//# sourceMappingURL=init.d.ts.map
|
package/dist/init.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,wHAAwH,CAAC;AAEhI,OAAO,KAAK,KAAK,cAAc,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAK9C,OAAO,WAAQ,aAAa,CAAC;IAC3B,MAAM,GAAG,EAAE,OAAO,cAAc,CAAC,GAAG,CAAC;CACtC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,kBAAkB,EAAE,OAAO,kBAAkB,CAAC;KAC/C;CACF;AAQD,eAAO,MAAM,mBAAmB,SAAU,MAAM,WACf,CAAC;AAkDlC,eAAO,MAAM,GAAG,YACN,mBAAmB,KAC1B,UAAU,CAAC,OAAO,aAAa,CAAC,GAAG,CAAoC,CAAC"}
|
package/dist/init.js
CHANGED
@@ -1,3 +1,76 @@
|
|
1
|
-
import "https://
|
2
|
-
import
|
3
|
-
|
1
|
+
import "https://cdn.jsdelivr.net/gh/tilli-pro/cookieconsent@0f888b603ba1077d94776af62d2bfb7247e5ffe4/dist/cookieconsent.umd.js";
|
2
|
+
import { cookieConsentTheme } from "./_utils";
|
3
|
+
import _config from "./config";
|
4
|
+
import styles from "./styles";
|
5
|
+
const GIT_SHA = "5d10d218837ca7ecd0362b35a3333eaf07efe92d";
|
6
|
+
const GIT_REPO = "tilli-pro/cookieconsent";
|
7
|
+
const GIT_CDN_BASE_URL = "https://cdn.jsdelivr.net/gh";
|
8
|
+
const GIT_CDN_URL = `${GIT_CDN_BASE_URL}/${GIT_REPO}@${GIT_SHA}`;
|
9
|
+
const GIT_DIST_URL = `${GIT_CDN_URL}/dist`;
|
10
|
+
const makeRemoteURL = (path) => `${GIT_DIST_URL}/${path}`;
|
11
|
+
export const makeRemotePluginURL = (path) => makeRemoteURL(`plugin/${path}`);
|
12
|
+
const CC_CSS_URL = makeRemoteURL("cookieconsent.css");
|
13
|
+
const getFilenameWithPathFromRemoteURL = (url) => {
|
14
|
+
const urlObj = new URL(url);
|
15
|
+
const path = urlObj.pathname;
|
16
|
+
const file = path.split("/").pop();
|
17
|
+
return file;
|
18
|
+
};
|
19
|
+
function loadCSS(url) {
|
20
|
+
if (document.querySelector(`link[href*="${getFilenameWithPathFromRemoteURL(url)}"]`)) {
|
21
|
+
// console.debug(`CSS already loaded: ${url}`);
|
22
|
+
return; // prevent duplication
|
23
|
+
}
|
24
|
+
const link = document.createElement("link");
|
25
|
+
Object.assign(link, {
|
26
|
+
rel: "stylesheet",
|
27
|
+
type: "text/css",
|
28
|
+
href: url,
|
29
|
+
});
|
30
|
+
document.head.appendChild(link);
|
31
|
+
}
|
32
|
+
function loadNestedPluginCSS(basePath, obj) {
|
33
|
+
for (const [key, value] of Object.entries(obj))
|
34
|
+
if (typeof value === "string") {
|
35
|
+
const url = makeRemotePluginURL(`${basePath}/${value}`);
|
36
|
+
// console.debug(`Loading plugin CSS from ${url}`);
|
37
|
+
loadCSS(url);
|
38
|
+
}
|
39
|
+
else if (value && typeof value === "object") {
|
40
|
+
// console.debug(`Loading nested plugin CSS from ${basePath}/${key}`);
|
41
|
+
loadNestedPluginCSS(`${basePath}/${key}`, value);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
async function always() {
|
45
|
+
loadCSS(CC_CSS_URL);
|
46
|
+
loadNestedPluginCSS("styles", styles); // TODO: make dynamic (only import dependent styles - aka if a certain `init` config is specified)
|
47
|
+
window.cookieConsentTheme = cookieConsentTheme; // used to fetch the correct classname to apply a specified theme | THIS SHOULD BE INJECTED INTO THE <HTML> TAG!!! // TODO: auto-inject (?)
|
48
|
+
}
|
49
|
+
void always();
|
50
|
+
export const run = async (config = _config) => await CookieConsent.run(config);
|
51
|
+
// ⚠️ NOTE: DISABLED THIS ENTRY MODULE SINCE ALL INITS SHOULD BE USING A SPECIFICALLY-CONFIGURED ENTRY MODULE INSTEAD (e.g. `init/brf.ts`, `init/tilli-website.ts`) !!!
|
52
|
+
// function isEntryModule(): boolean {
|
53
|
+
// if (typeof document === "undefined") return false;
|
54
|
+
// try {
|
55
|
+
// const currentModuleUrl = new URL(import.meta.url, document.baseURI).href;
|
56
|
+
// const scripts = Array.from(
|
57
|
+
// document.querySelectorAll('script[type="module"]'),
|
58
|
+
// );
|
59
|
+
// return scripts.some((script) => {
|
60
|
+
// const src = script.getAttribute("src");
|
61
|
+
// if (!src) return false;
|
62
|
+
// return new URL(src, document.baseURI).href === currentModuleUrl;
|
63
|
+
// });
|
64
|
+
// } catch (err) {
|
65
|
+
// console.error("Error checking module entry:", err);
|
66
|
+
// return false;
|
67
|
+
// }
|
68
|
+
// }
|
69
|
+
// if (isEntryModule()) {
|
70
|
+
// // console.debug(
|
71
|
+
// // { config: _config },
|
72
|
+
// // "Initializing Cookie Consent (entry module)...",
|
73
|
+
// // );
|
74
|
+
// const init = makeInitFn(run, _config);
|
75
|
+
// void init();
|
76
|
+
// }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CookieConsentInit.client.d.ts","sourceRoot":"","sources":["../../src/react-components/CookieConsentInit.client.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"CookieConsentInit.client.d.ts","sourceRoot":"","sources":["../../src/react-components/CookieConsentInit.client.tsx"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,iBAAiB,SAIxC"}
|
@@ -1,27 +1,6 @@
|
|
1
1
|
"use client";
|
2
|
-
import
|
3
|
-
import { run } from "@tilli-pro/cookieconsent";
|
4
|
-
import { COOKIE_CONSENT_ENABLED } from "../_consts";
|
5
|
-
import config from "../config";
|
6
|
-
import { injectReactRemoveScrollToggle } from "../config/gui-options/scripts/forceDisableReactRemoveScroll";
|
7
|
-
import injectManageCookiePrefsButton from "../config/gui-options/scripts/injectManageCookiePrefsButton";
|
2
|
+
import useCookieConsent from "./hooks/useCookieConsent";
|
8
3
|
export default function CookieConsentInit() {
|
9
|
-
|
10
|
-
if (!COOKIE_CONSENT_ENABLED)
|
11
|
-
return;
|
12
|
-
void (async () => {
|
13
|
-
/** inject the cookie-consent banner (pop-up) */
|
14
|
-
await run(config);
|
15
|
-
/** ...then, inject the floating cookie consent "manage preferences" icon button into the DOM (floats @ the bottom right) */
|
16
|
-
injectManageCookiePrefsButton();
|
17
|
-
/** ...and, force-disable "react-remove-scroll" -- only upon opening up the "manage preferences" dialog
|
18
|
-
*
|
19
|
-
* > this handles the edge case where there's a shadcn (radix-ui) dialog open
|
20
|
-
* underneath the cookie banner's "manage preferences" dialog, which prevents
|
21
|
-
* the user from scrolling within the manage prefs dialog
|
22
|
-
*/
|
23
|
-
injectReactRemoveScrollToggle();
|
24
|
-
})();
|
25
|
-
}, []);
|
4
|
+
useCookieConsent();
|
26
5
|
return null;
|
27
6
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import "server-only";
|
2
2
|
import "@tilli-pro/cookieconsent/dist/cookieconsent.css";
|
3
|
-
import "
|
4
|
-
import "
|
3
|
+
import "../styles/tenants/freeman.css";
|
4
|
+
import "../styles/tenants/frontier.css";
|
5
5
|
/** we use a server component to handle dynamic injection of the script all together
|
6
6
|
* > basically, there's no need to inject the client-side cookie-consent script if it's not in scope */
|
7
7
|
export default function CookieConsentInit(): import("react/jsx-runtime").JSX.Element | null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CookieConsentInit.server.d.ts","sourceRoot":"","sources":["../../src/react-components/CookieConsentInit.server.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAKrB,OAAO,iDAAiD,CAAC;AACzD,OAAO,
|
1
|
+
{"version":3,"file":"CookieConsentInit.server.d.ts","sourceRoot":"","sources":["../../src/react-components/CookieConsentInit.server.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAKrB,OAAO,iDAAiD,CAAC;AACzD,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AAExC;uGACuG;AACvG,MAAM,CAAC,OAAO,UAAU,iBAAiB,mDAExC"}
|
@@ -3,8 +3,8 @@ import "server-only";
|
|
3
3
|
import { COOKIE_CONSENT_ENABLED } from "../_consts";
|
4
4
|
import CookieConsentInitClient from "./CookieConsentInit.client";
|
5
5
|
import "@tilli-pro/cookieconsent/dist/cookieconsent.css";
|
6
|
-
import "
|
7
|
-
import "
|
6
|
+
import "../styles/tenants/freeman.css";
|
7
|
+
import "../styles/tenants/frontier.css";
|
8
8
|
/** we use a server component to handle dynamic injection of the script all together
|
9
9
|
* > basically, there's no need to inject the client-side cookie-consent script if it's not in scope */
|
10
10
|
export default function CookieConsentInit() {
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useCookieConsent.d.ts","sourceRoot":"","sources":["../../../src/react-components/hooks/useCookieConsent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,cAAc,MAAM,0BAA0B,CAAC;AAYhE,eAAO,MAAM,GAAG,2BAIoC,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,gBAAgB,SAOvC"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use client";
|
2
|
+
import { useEffect } from "react";
|
3
|
+
import { COOKIE_CONSENT_ENABLED } from "../../_consts";
|
4
|
+
import config from "../../config";
|
5
|
+
import { makeInitFn } from "../../init/utils";
|
6
|
+
export const run = typeof CookieConsent !== "undefined" &&
|
7
|
+
typeof CookieConsent.run === "function"
|
8
|
+
? CookieConsent.run
|
9
|
+
: (await import("@tilli-pro/cookieconsent")).run;
|
10
|
+
export default function useCookieConsent() {
|
11
|
+
useEffect(() => {
|
12
|
+
if (!COOKIE_CONSENT_ENABLED)
|
13
|
+
return;
|
14
|
+
const init = makeInitFn(run, config);
|
15
|
+
void init();
|
16
|
+
}, []);
|
17
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/styles/index.ts"],"names":[],"mappings":";;;;;;AAAA,wBAKW"}
|
package/package.json
CHANGED
@@ -7,7 +7,15 @@ const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = path.dirname(__filename);
|
8
8
|
|
9
9
|
const sourceDir = path.resolve(__dirname, "..", "..", "dist");
|
10
|
-
const destDir = path.resolve(__dirname, "..", "..", "..", "dist", "plugin");
|
10
|
+
const destDir = path.resolve(__dirname, "..", "..", "..", "dist", "plugin");
|
11
|
+
const backupDestDir = path.resolve(
|
12
|
+
__dirname,
|
13
|
+
"..",
|
14
|
+
"..",
|
15
|
+
"..",
|
16
|
+
"dist",
|
17
|
+
"plugin.old",
|
18
|
+
);
|
11
19
|
|
12
20
|
function injectPlugin(src: string, dest: string): void {
|
13
21
|
try {
|
@@ -42,7 +50,10 @@ function injectPlugin(src: string, dest: string): void {
|
|
42
50
|
try {
|
43
51
|
fs.copyFileSync(srcPath, destPath);
|
44
52
|
} catch (err) {
|
45
|
-
console.error(
|
53
|
+
console.error(
|
54
|
+
`Failed to copy file from ${srcPath} to ${destPath}:`,
|
55
|
+
err,
|
56
|
+
);
|
46
57
|
}
|
47
58
|
}
|
48
59
|
}
|
@@ -53,16 +64,20 @@ function transformImportPaths(filePath: string): void {
|
|
53
64
|
try {
|
54
65
|
let code = fs.readFileSync(filePath, "utf8");
|
55
66
|
code = code.replace(
|
56
|
-
/(import\s
|
67
|
+
/(import\s+(?:.*?\s+from\s+)?["'])(\.{1,2}\/[^"']+)(["'])/g,
|
57
68
|
(match, prefix, importPath, suffix) => {
|
69
|
+
/** skip if import path already has a .js or .css extension */
|
70
|
+
if (importPath.endsWith(".js") || importPath.endsWith(".css"))
|
71
|
+
return match;
|
72
|
+
|
58
73
|
const absolutePath = path.resolve(path.dirname(filePath), importPath);
|
59
|
-
if (fs.existsSync(absolutePath + ".js"))
|
74
|
+
if (fs.existsSync(absolutePath + ".js"))
|
60
75
|
return `${prefix}${importPath}.js${suffix}`;
|
61
|
-
|
76
|
+
else if (fs.existsSync(path.join(absolutePath, "index.js")))
|
62
77
|
return `${prefix}${importPath}/index.js${suffix}`;
|
63
|
-
|
78
|
+
|
64
79
|
return match;
|
65
|
-
}
|
80
|
+
},
|
66
81
|
);
|
67
82
|
fs.writeFileSync(filePath, code, "utf8");
|
68
83
|
} catch (err) {
|
@@ -80,24 +95,57 @@ function processDirectoryForTransform(dir: string): void {
|
|
80
95
|
}
|
81
96
|
for (const entry of entries) {
|
82
97
|
const fullPath = path.join(dir, entry.name);
|
83
|
-
if (entry.isDirectory())
|
84
|
-
|
85
|
-
} else if (entry.isFile() && path.extname(entry.name) === ".js") {
|
98
|
+
if (entry.isDirectory()) processDirectoryForTransform(fullPath);
|
99
|
+
else if (entry.isFile() && path.extname(entry.name) === ".js")
|
86
100
|
transformImportPaths(fullPath);
|
87
|
-
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
/** backup */
|
105
|
+
let backupExists = false;
|
106
|
+
if (fs.existsSync(destDir)) {
|
107
|
+
try {
|
108
|
+
if (fs.existsSync(backupDestDir))
|
109
|
+
fs.rmSync(backupDestDir, { recursive: true, force: true });
|
110
|
+
fs.renameSync(destDir, backupDestDir);
|
111
|
+
backupExists = true;
|
112
|
+
console.log(`Existing destination directory renamed to ${backupDestDir}`);
|
113
|
+
} catch (err) {
|
114
|
+
console.error("Failed to backup existing destination directory:", err);
|
115
|
+
process.exit(1);
|
88
116
|
}
|
89
117
|
}
|
90
118
|
|
91
119
|
try {
|
92
120
|
injectPlugin(sourceDir, destDir);
|
93
121
|
console.log(`Plugin files copied from ${sourceDir} to ${destDir}`);
|
94
|
-
} catch (err) {
|
95
|
-
console.error("Error during plugin injection:", err);
|
96
|
-
}
|
97
122
|
|
98
|
-
try {
|
99
123
|
processDirectoryForTransform(destDir);
|
100
|
-
console.log(
|
124
|
+
console.log(
|
125
|
+
"Import paths in JS files have been transformed to include explicit file extensions.",
|
126
|
+
);
|
127
|
+
|
128
|
+
if (backupExists) {
|
129
|
+
fs.rmSync(backupDestDir, { recursive: true, force: true });
|
130
|
+
console.log(`Backup directory ${backupDestDir} deleted successfully.`);
|
131
|
+
}
|
101
132
|
} catch (err) {
|
102
|
-
console.error("Error during
|
103
|
-
|
133
|
+
console.error("Error during plugin injection or transformation:", err);
|
134
|
+
|
135
|
+
/** attempt to restore from backup */
|
136
|
+
if (backupExists) {
|
137
|
+
try {
|
138
|
+
if (fs.existsSync(destDir))
|
139
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
140
|
+
|
141
|
+
fs.renameSync(backupDestDir, destDir);
|
142
|
+
console.log(
|
143
|
+
`Restored backup directory from ${backupDestDir} to ${destDir}.`,
|
144
|
+
);
|
145
|
+
} catch (restoreErr) {
|
146
|
+
console.error("Failed to restore backup directory:", restoreErr);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
process.exit(1);
|
151
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { Language, Locale } from "
|
1
|
+
import type { Language, Locale } from "./config/translations/types";
|
2
2
|
import type { TenantRefId, Theme } from "./_types";
|
3
|
-
import { COOKIE_CONSENT_TEST_SEARCH_PARAM_KEY_PREFIX } from "
|
3
|
+
import { COOKIE_CONSENT_TEST_SEARCH_PARAM_KEY_PREFIX } from "./_consts";
|
4
4
|
|
5
5
|
type SupportedTenantThemes = Partial<Record<TenantRefId, Theme[]>>;
|
6
6
|
const SUPPORTED_TENANT_THEMES = {
|
@@ -1,8 +1,9 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import
|
3
|
+
import type * as _CookieConsent from "@tilli-pro/cookieconsent";
|
4
4
|
|
5
5
|
import { buttonId } from "../html-components/ManageCookiePrefsButton";
|
6
|
+
import { showPreferences } from "./injectManageCookiePrefsButton";
|
6
7
|
|
7
8
|
/**
|
8
9
|
* attach a MutationObserver the **first time** the user hovers over–
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
|
3
|
-
import
|
3
|
+
import type * as _CookieConsent from "@tilli-pro/cookieconsent";
|
4
4
|
|
5
5
|
import type { HTMLDivElementWithDragObserver } from "./cookiePrefsButtonDragObserver";
|
6
6
|
import ManageCookiePrefsButton, {
|
@@ -11,6 +11,18 @@ import cookiePrefsButtonDragObserver, {
|
|
11
11
|
ontouchstart,
|
12
12
|
} from "./cookiePrefsButtonDragObserver";
|
13
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;
|
25
|
+
|
14
26
|
/** injects the floating cookie consent "manage preferences" icon button into the DOM */
|
15
27
|
const inject = (): HTMLDivElement => {
|
16
28
|
const container = document.body.appendChild(
|
package/src/config/index.ts
CHANGED
@@ -5,11 +5,24 @@ import categories from "./categories";
|
|
5
5
|
import guiOptions from "./gui-options";
|
6
6
|
import translations from "./translations";
|
7
7
|
|
8
|
+
/** polyfill for pure JS support */
|
9
|
+
declare const process: {
|
10
|
+
env: {
|
11
|
+
NODE_ENV?: "development" | "production";
|
12
|
+
};
|
13
|
+
} | undefined;
|
14
|
+
|
15
|
+
const isProduction =
|
16
|
+
(typeof process !== "undefined" &&
|
17
|
+
typeof process.env !== "undefined" &&
|
18
|
+
typeof process.env.NODE_ENV === "string" &&
|
19
|
+
process.env.NODE_ENV === "production") || true;
|
20
|
+
|
8
21
|
export default {
|
9
22
|
revision: REVISION,
|
10
23
|
guiOptions,
|
11
24
|
categories,
|
12
25
|
language: { default: "en", autoDetect: "browser", translations },
|
13
26
|
cookie: { name: COOKIE_PREFERENCES_COOKIE_NAME },
|
14
|
-
hideFromBots:
|
27
|
+
hideFromBots: isProduction, // disabled in local dev to enable ui-testing (via Playwright)
|
15
28
|
} satisfies CookieConsentConfig;
|
@@ -93,6 +93,13 @@ export default {
|
|
93
93
|
},
|
94
94
|
},
|
95
95
|
|
96
|
+
{
|
97
|
+
title: "Marketing-Cookies",
|
98
|
+
description:
|
99
|
+
"Diese Cookies werden verwendet, um Werbung bereitzustellen, die für Ihre Interessen relevant ist. Sie können Ihr Surfverhalten auf verschiedenen Websites verfolgen und Werbetreibenden helfen, personalisierte Anzeigen anzuzeigen.",
|
100
|
+
linkedCategory: "marketing",
|
101
|
+
},
|
102
|
+
|
96
103
|
{
|
97
104
|
title: "Weitere Informationen",
|
98
105
|
description:
|
@@ -93,6 +93,13 @@ export default {
|
|
93
93
|
},
|
94
94
|
},
|
95
95
|
|
96
|
+
{
|
97
|
+
title: "Marketing cookies",
|
98
|
+
description:
|
99
|
+
"These cookies are used to deliver advertisements that are relevant to your interests. They may track your browsing behaviors across different sites and help advertisers serve more personalized ads.",
|
100
|
+
linkedCategory: "marketing",
|
101
|
+
},
|
102
|
+
|
96
103
|
{
|
97
104
|
title: "More information",
|
98
105
|
description:
|
@@ -93,6 +93,13 @@ export default {
|
|
93
93
|
},
|
94
94
|
},
|
95
95
|
|
96
|
+
{
|
97
|
+
title: "Cookies de marketing",
|
98
|
+
description:
|
99
|
+
"Estas cookies se utilizan para mostrar anuncios relevantes según tus intereses. Pueden rastrear tu comportamiento de navegación en diferentes sitios y ayudar a los anunciantes a ofrecer anuncios más personalizados.",
|
100
|
+
linkedCategory: "marketing",
|
101
|
+
},
|
102
|
+
|
96
103
|
{
|
97
104
|
title: "Más información",
|
98
105
|
description:
|
@@ -93,6 +93,13 @@ export default {
|
|
93
93
|
},
|
94
94
|
},
|
95
95
|
|
96
|
+
{
|
97
|
+
title: "Cookies de marketing",
|
98
|
+
description:
|
99
|
+
"Ces cookies sont utilisés pour diffuser des publicités correspondant à vos centres d’intérêt. Ils peuvent suivre vos comportements de navigation sur différents sites et aider les annonceurs à proposer des annonces plus personnalisées.",
|
100
|
+
linkedCategory: "marketing",
|
101
|
+
},
|
102
|
+
|
96
103
|
{
|
97
104
|
title: "Plus d'informations",
|
98
105
|
description:
|
@@ -93,6 +93,13 @@ export default {
|
|
93
93
|
},
|
94
94
|
},
|
95
95
|
|
96
|
+
{
|
97
|
+
title: "Cookie di marketing",
|
98
|
+
description:
|
99
|
+
"Questi cookie vengono utilizzati per offrire pubblicità pertinenti ai tuoi interessi. Possono tracciare i tuoi comportamenti di navigazione su diversi siti e aiutare gli inserzionisti a servire annunci più personalizzati.",
|
100
|
+
linkedCategory: "marketing",
|
101
|
+
},
|
102
|
+
|
96
103
|
{
|
97
104
|
title: "Ulteriori informazioni",
|
98
105
|
description:
|
package/src/init/brf.ts
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
import type { CookieConsentConfig } from "@tilli-pro/cookieconsent";
|
2
|
+
|
3
|
+
import _config from "../config";
|
4
|
+
import { LABELS } from "../config/categories/labels";
|
5
|
+
import cookies from "../config/cookies";
|
6
|
+
import { run } from "../init";
|
7
|
+
import {
|
8
|
+
makeInitFn,
|
9
|
+
stripInvalidLinkedCategoriesFromTranslations,
|
10
|
+
} from "./utils";
|
11
|
+
|
12
|
+
// TODO: auto-detect detect language
|
13
|
+
const __LANGUAGE__ = "en"; // "English" ("English")
|
14
|
+
|
15
|
+
const categories: CookieConsentConfig["categories"] = {
|
16
|
+
necessary: {
|
17
|
+
enabled: true, // "necessary" category is always enabled.
|
18
|
+
readOnly: true,
|
19
|
+
services: {
|
20
|
+
/** tilliX (BRF) */
|
21
|
+
tilliX: {
|
22
|
+
label: LABELS.en.necessary.tilliX,
|
23
|
+
cookies: [...cookies.necessary.brf(__LANGUAGE__)],
|
24
|
+
},
|
25
|
+
},
|
26
|
+
},
|
27
|
+
functional: {
|
28
|
+
services: {
|
29
|
+
/** tilliX (BRF) */
|
30
|
+
tilliX: {
|
31
|
+
label: LABELS.en.functional.tilliX,
|
32
|
+
cookies: [...cookies.functional.brf(__LANGUAGE__)],
|
33
|
+
},
|
34
|
+
},
|
35
|
+
autoClear: {
|
36
|
+
cookies: [
|
37
|
+
{
|
38
|
+
name: /^(tx-theme)/, // tilliX theme (-> "light" | "dark")
|
39
|
+
},
|
40
|
+
],
|
41
|
+
},
|
42
|
+
},
|
43
|
+
analytics: {
|
44
|
+
services: {
|
45
|
+
/** Datadog (RUM) */
|
46
|
+
datadog: {
|
47
|
+
label: LABELS.en.analytics.datadog,
|
48
|
+
cookies: [...cookies.analytics.datadog(__LANGUAGE__)],
|
49
|
+
},
|
50
|
+
},
|
51
|
+
autoClear: {
|
52
|
+
cookies: [
|
53
|
+
{
|
54
|
+
name: /^(_tilli_analytics_dd_)/, // Datadog (RUM)
|
55
|
+
},
|
56
|
+
],
|
57
|
+
},
|
58
|
+
},
|
59
|
+
};
|
60
|
+
|
61
|
+
// TODO: DRY further w/ `./tilli-website.ts`
|
62
|
+
const language: CookieConsentConfig["language"] = {
|
63
|
+
..._config.language,
|
64
|
+
translations: stripInvalidLinkedCategoriesFromTranslations(
|
65
|
+
_config.language.translations,
|
66
|
+
categories,
|
67
|
+
),
|
68
|
+
};
|
69
|
+
|
70
|
+
const config: CookieConsentConfig = {
|
71
|
+
..._config,
|
72
|
+
categories,
|
73
|
+
language,
|
74
|
+
};
|
75
|
+
|
76
|
+
// console.debug({ config }, "Initializing Cookie Consent (BRF)...");
|
77
|
+
const init = makeInitFn(run, config);
|
78
|
+
void init();
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import type { CookieConsentConfig } from "@tilli-pro/cookieconsent";
|
2
|
+
|
3
|
+
import _config from "../config";
|
4
|
+
import { run } from "../init";
|
5
|
+
import {
|
6
|
+
makeInitFn,
|
7
|
+
stripInvalidLinkedCategoriesFromTranslations,
|
8
|
+
} from "./utils";
|
9
|
+
|
10
|
+
const categories: CookieConsentConfig["categories"] = {
|
11
|
+
necessary: {
|
12
|
+
enabled: true, // "necessary" category is always enabled.
|
13
|
+
readOnly: true,
|
14
|
+
},
|
15
|
+
analytics: {},
|
16
|
+
marketing: {},
|
17
|
+
};
|
18
|
+
|
19
|
+
// TODO: DRY further w/ `./brf.ts`
|
20
|
+
const language: CookieConsentConfig["language"] = {
|
21
|
+
..._config.language,
|
22
|
+
translations: stripInvalidLinkedCategoriesFromTranslations(
|
23
|
+
_config.language.translations,
|
24
|
+
categories,
|
25
|
+
true, // clear cookie tables // FIXME: refactor this to actually just use the proper cookie table accoring to the categories var
|
26
|
+
),
|
27
|
+
};
|
28
|
+
|
29
|
+
const config: CookieConsentConfig = {
|
30
|
+
..._config,
|
31
|
+
categories,
|
32
|
+
language,
|
33
|
+
};
|
34
|
+
|
35
|
+
// console.debug({ config }, "Initializing Cookie Consent (tilli Website)...");
|
36
|
+
const init = makeInitFn(run, config);
|
37
|
+
void init();
|