cookiecraft 1.0.6 → 1.0.8
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/README.md +171 -304
- package/dist/cookiecraft.css +1 -1
- package/dist/cookiecraft.esm.js +224 -137
- package/dist/cookiecraft.esm.js.map +1 -1
- package/dist/cookiecraft.js +224 -137
- package/dist/cookiecraft.js.map +1 -1
- package/dist/cookiecraft.min.js +1 -1
- package/dist/cookiecraft.min.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types/blocking/CategoryManager.d.ts +1 -0
- package/dist/types/core/ConsentManager.d.ts +1 -1
- package/dist/types/core/CookieConsent.d.ts +5 -4
- package/dist/types/core/EventEmitter.d.ts +3 -2
- package/dist/types/integrations/GTMConsentMode.d.ts +0 -6
- package/dist/types/types/index.d.ts +3 -7
- package/dist/types/ui/Banner.d.ts +6 -0
- package/dist/types/ui/PreferenceCenter.d.ts +1 -0
- package/package.json +1 -1
package/dist/stats.html
CHANGED
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"cookiecraft.js","children":[{"name":"src","children":[{"name":"core","children":[{"uid":"
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"cookiecraft.js","children":[{"name":"src","children":[{"name":"core","children":[{"uid":"b11ae7b6-1","name":"StorageManager.ts"},{"uid":"b11ae7b6-3","name":"ConsentManager.ts"},{"uid":"b11ae7b6-5","name":"EventEmitter.ts"},{"uid":"b11ae7b6-27","name":"CookieConsent.ts"}]},{"name":"blocking","children":[{"uid":"b11ae7b6-7","name":"ScriptBlocker.ts"},{"uid":"b11ae7b6-9","name":"CategoryManager.ts"}]},{"name":"utils","children":[{"uid":"b11ae7b6-11","name":"sanitize.ts"},{"uid":"b11ae7b6-13","name":"color.ts"},{"uid":"b11ae7b6-25","name":"cookies.ts"}]},{"name":"ui","children":[{"uid":"b11ae7b6-15","name":"Banner.ts"},{"uid":"b11ae7b6-17","name":"PreferenceCenter.ts"},{"uid":"b11ae7b6-19","name":"FloatingWidget.ts"}]},{"name":"integrations","children":[{"uid":"b11ae7b6-21","name":"GTMConsentMode.ts"},{"uid":"b11ae7b6-23","name":"DataLayerManager.ts"}]},{"uid":"b11ae7b6-29","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"b11ae7b6-1":{"renderedLength":3867,"gzipLength":973,"brotliLength":831,"metaUid":"b11ae7b6-0"},"b11ae7b6-3":{"renderedLength":2405,"gzipLength":704,"brotliLength":586,"metaUid":"b11ae7b6-2"},"b11ae7b6-5":{"renderedLength":1409,"gzipLength":401,"brotliLength":356,"metaUid":"b11ae7b6-4"},"b11ae7b6-7":{"renderedLength":6794,"gzipLength":1782,"brotliLength":1519,"metaUid":"b11ae7b6-6"},"b11ae7b6-9":{"renderedLength":2455,"gzipLength":771,"brotliLength":633,"metaUid":"b11ae7b6-8"},"b11ae7b6-11":{"renderedLength":1701,"gzipLength":665,"brotliLength":555,"metaUid":"b11ae7b6-10"},"b11ae7b6-13":{"renderedLength":2139,"gzipLength":773,"brotliLength":647,"metaUid":"b11ae7b6-12"},"b11ae7b6-15":{"renderedLength":9391,"gzipLength":2204,"brotliLength":1823,"metaUid":"b11ae7b6-14"},"b11ae7b6-17":{"renderedLength":9383,"gzipLength":2368,"brotliLength":1971,"metaUid":"b11ae7b6-16"},"b11ae7b6-19":{"renderedLength":5694,"gzipLength":2003,"brotliLength":1642,"metaUid":"b11ae7b6-18"},"b11ae7b6-21":{"renderedLength":2682,"gzipLength":745,"brotliLength":663,"metaUid":"b11ae7b6-20"},"b11ae7b6-23":{"renderedLength":1237,"gzipLength":483,"brotliLength":391,"metaUid":"b11ae7b6-22"},"b11ae7b6-25":{"renderedLength":3548,"gzipLength":1157,"brotliLength":954,"metaUid":"b11ae7b6-24"},"b11ae7b6-27":{"renderedLength":10206,"gzipLength":2134,"brotliLength":1795,"metaUid":"b11ae7b6-26"},"b11ae7b6-29":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"b11ae7b6-28"}},"nodeMetas":{"b11ae7b6-0":{"id":"/src/core/StorageManager.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-1"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"},{"uid":"b11ae7b6-2"}]},"b11ae7b6-2":{"id":"/src/core/ConsentManager.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-3"},"imported":[{"uid":"b11ae7b6-0"}],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-4":{"id":"/src/core/EventEmitter.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-5"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-6":{"id":"/src/blocking/ScriptBlocker.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-7"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-8":{"id":"/src/blocking/CategoryManager.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-9"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-10":{"id":"/src/utils/sanitize.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-11"},"imported":[],"importedBy":[{"uid":"b11ae7b6-14"},{"uid":"b11ae7b6-16"},{"uid":"b11ae7b6-18"}]},"b11ae7b6-12":{"id":"/src/utils/color.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-13"},"imported":[],"importedBy":[{"uid":"b11ae7b6-14"},{"uid":"b11ae7b6-16"},{"uid":"b11ae7b6-18"}]},"b11ae7b6-14":{"id":"/src/ui/Banner.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-15"},"imported":[{"uid":"b11ae7b6-10"},{"uid":"b11ae7b6-12"}],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-16":{"id":"/src/ui/PreferenceCenter.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-17"},"imported":[{"uid":"b11ae7b6-10"},{"uid":"b11ae7b6-12"}],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-18":{"id":"/src/ui/FloatingWidget.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-19"},"imported":[{"uid":"b11ae7b6-10"},{"uid":"b11ae7b6-12"}],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-20":{"id":"/src/integrations/GTMConsentMode.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-21"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-22":{"id":"/src/integrations/DataLayerManager.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-23"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-24":{"id":"/src/utils/cookies.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-25"},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-26":{"id":"/src/core/CookieConsent.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-27"},"imported":[{"uid":"b11ae7b6-2"},{"uid":"b11ae7b6-0"},{"uid":"b11ae7b6-4"},{"uid":"b11ae7b6-6"},{"uid":"b11ae7b6-8"},{"uid":"b11ae7b6-14"},{"uid":"b11ae7b6-16"},{"uid":"b11ae7b6-18"},{"uid":"b11ae7b6-20"},{"uid":"b11ae7b6-22"},{"uid":"b11ae7b6-24"},{"uid":"b11ae7b6-30"},{"uid":"b11ae7b6-31"},{"uid":"b11ae7b6-32"},{"uid":"b11ae7b6-33"}],"importedBy":[{"uid":"b11ae7b6-28"}]},"b11ae7b6-28":{"id":"/src/index.ts","moduleParts":{"cookiecraft.js":"b11ae7b6-29"},"imported":[{"uid":"b11ae7b6-26"}],"importedBy":[],"isEntry":true},"b11ae7b6-30":{"id":"/src/styles/banner.css","moduleParts":{},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-31":{"id":"/src/styles/animations.css","moduleParts":{},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-32":{"id":"/src/styles/preferences.css","moduleParts":{},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]},"b11ae7b6-33":{"id":"/src/styles/widget.css","moduleParts":{},"imported":[],"importedBy":[{"uid":"b11ae7b6-26"}]}},"env":{"rollup":"4.55.1"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|
|
@@ -19,6 +19,7 @@ export declare class CategoryManager {
|
|
|
19
19
|
isAllowed(category: string, consent: ConsentCategories): boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Initialize default URL patterns for common tracking services
|
|
22
|
+
* Note: GTM is NOT auto-categorized — it should be managed via GTM Consent Mode v2
|
|
22
23
|
*/
|
|
23
24
|
private initializeDefaultPatterns;
|
|
24
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CookieConsent - Main orchestrator class
|
|
3
3
|
*/
|
|
4
|
-
import { ConsentConfig, ConsentCategories } from '../types';
|
|
4
|
+
import { ConsentConfig, ConsentCategories, ConsentRecord, ConsentEvent, EventCallback } from '../types';
|
|
5
5
|
import '../styles/banner.css';
|
|
6
6
|
import '../styles/animations.css';
|
|
7
7
|
import '../styles/preferences.css';
|
|
@@ -16,6 +16,7 @@ export declare class CookieConsent {
|
|
|
16
16
|
private preferenceCenter;
|
|
17
17
|
private floatingWidget;
|
|
18
18
|
private gtmIntegration;
|
|
19
|
+
private hideTimeout;
|
|
19
20
|
constructor(config: ConsentConfig);
|
|
20
21
|
/**
|
|
21
22
|
* Initialize the cookie consent system
|
|
@@ -40,7 +41,7 @@ export declare class CookieConsent {
|
|
|
40
41
|
/**
|
|
41
42
|
* Get current consent
|
|
42
43
|
*/
|
|
43
|
-
getConsent():
|
|
44
|
+
getConsent(): ConsentRecord | null;
|
|
44
45
|
/**
|
|
45
46
|
* Reset consent (clear stored data and show banner)
|
|
46
47
|
*/
|
|
@@ -48,11 +49,11 @@ export declare class CookieConsent {
|
|
|
48
49
|
/**
|
|
49
50
|
* Register event handler
|
|
50
51
|
*/
|
|
51
|
-
on(event:
|
|
52
|
+
on(event: ConsentEvent, callback: EventCallback): void;
|
|
52
53
|
/**
|
|
53
54
|
* Unregister event handler
|
|
54
55
|
*/
|
|
55
|
-
off(event:
|
|
56
|
+
off(event: ConsentEvent, callback: EventCallback): void;
|
|
56
57
|
/**
|
|
57
58
|
* Destroy and cleanup all UI elements
|
|
58
59
|
*/
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EventEmitter - Simple pub/sub pattern for internal and external events
|
|
3
3
|
*/
|
|
4
|
+
import { EventCallback } from '../types';
|
|
4
5
|
export declare class EventEmitter {
|
|
5
6
|
private events;
|
|
6
7
|
/**
|
|
7
8
|
* Register an event handler
|
|
8
9
|
*/
|
|
9
|
-
on(event: string, callback:
|
|
10
|
+
on(event: string, callback: EventCallback): void;
|
|
10
11
|
/**
|
|
11
12
|
* Unregister an event handler
|
|
12
13
|
*/
|
|
13
|
-
off(event: string, callback:
|
|
14
|
+
off(event: string, callback: EventCallback): void;
|
|
14
15
|
/**
|
|
15
16
|
* Emit an event with optional data
|
|
16
17
|
*/
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* GTMConsentMode - Full integration with Google Consent Mode v2
|
|
3
|
-
*
|
|
4
|
-
* Implements all required signals:
|
|
5
|
-
* - ad_storage, ad_user_data, ad_personalization, analytics_storage (core GCM v2)
|
|
6
|
-
* - functionality_storage, personalization_storage, security_storage (non-core)
|
|
7
|
-
* - wait_for_update, url_passthrough, ads_data_redaction (advanced features)
|
|
8
3
|
*/
|
|
9
4
|
import { ConsentCategories, ConsentConfig } from '../types';
|
|
10
5
|
import { DataLayerManager } from './DataLayerManager';
|
|
@@ -19,7 +14,6 @@ export declare class GTMConsentMode {
|
|
|
19
14
|
setDefaultConsent(): void;
|
|
20
15
|
/**
|
|
21
16
|
* Update consent state based on user choices
|
|
22
|
-
* Called both on new consent and on page load for returning visitors
|
|
23
17
|
*/
|
|
24
18
|
updateConsent(categories: ConsentCategories): void;
|
|
25
19
|
/**
|
|
@@ -6,6 +6,7 @@ export interface ConsentCategories {
|
|
|
6
6
|
analytics: boolean;
|
|
7
7
|
marketing: boolean;
|
|
8
8
|
preferences?: boolean;
|
|
9
|
+
[key: string]: boolean | undefined;
|
|
9
10
|
}
|
|
10
11
|
export interface CategoryConfig {
|
|
11
12
|
enabled: boolean;
|
|
@@ -35,12 +36,7 @@ export interface ConsentConfig {
|
|
|
35
36
|
mode: 'opt-in' | 'opt-out';
|
|
36
37
|
autoShow: boolean;
|
|
37
38
|
revision: number;
|
|
38
|
-
categories:
|
|
39
|
-
necessary: CategoryConfig;
|
|
40
|
-
analytics: CategoryConfig;
|
|
41
|
-
marketing: CategoryConfig;
|
|
42
|
-
preferences?: CategoryConfig;
|
|
43
|
-
};
|
|
39
|
+
categories: Record<string, CategoryConfig>;
|
|
44
40
|
theme?: 'light' | 'dark' | 'auto';
|
|
45
41
|
position?: 'bottom' | 'top' | 'center' | 'bottom-left' | 'bottom-right';
|
|
46
42
|
layout?: 'bar' | 'box' | 'floating';
|
|
@@ -67,7 +63,6 @@ export interface ConsentRecord {
|
|
|
67
63
|
version: number;
|
|
68
64
|
timestamp: string;
|
|
69
65
|
categories: ConsentCategories;
|
|
70
|
-
userAgent: string;
|
|
71
66
|
expiresAt: string;
|
|
72
67
|
}
|
|
73
68
|
export interface GTMConsent {
|
|
@@ -80,6 +75,7 @@ export interface GTMConsent {
|
|
|
80
75
|
personalization_storage: 'granted' | 'denied';
|
|
81
76
|
security_storage: 'granted' | 'denied';
|
|
82
77
|
}
|
|
78
|
+
export type EventCallback = (...args: any[]) => void;
|
|
83
79
|
export type ConsentEvent = 'consent:init' | 'consent:show' | 'consent:hide' | 'consent:accept' | 'consent:reject' | 'consent:update' | 'consent:load' | 'consent:expire' | 'preferences:show' | 'preferences:hide' | 'script:activated';
|
|
84
80
|
declare global {
|
|
85
81
|
interface Window {
|
|
@@ -7,6 +7,8 @@ export declare class Banner {
|
|
|
7
7
|
private config;
|
|
8
8
|
private element;
|
|
9
9
|
private eventEmitter;
|
|
10
|
+
private hideTimeout;
|
|
11
|
+
private previousActiveElement;
|
|
10
12
|
constructor(config: ConsentConfig, eventEmitter: EventEmitter);
|
|
11
13
|
/**
|
|
12
14
|
* Show the banner
|
|
@@ -40,6 +42,10 @@ export declare class Banner {
|
|
|
40
42
|
* Handle customize action
|
|
41
43
|
*/
|
|
42
44
|
private handleCustomize;
|
|
45
|
+
/**
|
|
46
|
+
* Trap focus within banner (when disablePageInteraction is true)
|
|
47
|
+
*/
|
|
48
|
+
private trapFocus;
|
|
43
49
|
/**
|
|
44
50
|
* Generate description HTML with privacy policy link
|
|
45
51
|
*/
|
|
@@ -8,6 +8,7 @@ export declare class PreferenceCenter {
|
|
|
8
8
|
private element;
|
|
9
9
|
private eventEmitter;
|
|
10
10
|
private currentConsent;
|
|
11
|
+
private previousActiveElement;
|
|
11
12
|
constructor(config: ConsentConfig, eventEmitter: EventEmitter, currentConsent: ConsentCategories);
|
|
12
13
|
/**
|
|
13
14
|
* Show the preference center
|