@privacykit/web 1.0.2 → 1.2.1
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/dist/index.js +28 -0
- package/index.d.ts +6 -0
- package/package.json +3 -3
- package/privacykit.d.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -19,6 +19,34 @@ export function initPrivacyKit(options = {}) {
|
|
|
19
19
|
if (typeof document === "undefined") {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
+
if (!window.PrivacyKit) {
|
|
23
|
+
const readyQueue = [];
|
|
24
|
+
const consentChangedQueue = [];
|
|
25
|
+
window.addEventListener('privacykit:ready', () => {
|
|
26
|
+
const pk = window.PrivacyKit;
|
|
27
|
+
for (const cb of consentChangedQueue) {
|
|
28
|
+
pk?.onConsentChanged(cb);
|
|
29
|
+
}
|
|
30
|
+
consentChangedQueue.length = 0;
|
|
31
|
+
for (const cb of readyQueue) {
|
|
32
|
+
cb();
|
|
33
|
+
}
|
|
34
|
+
readyQueue.length = 0;
|
|
35
|
+
}, { once: true });
|
|
36
|
+
window.PrivacyKit = {
|
|
37
|
+
_pk_queue: { readyQueue, consentChangedQueue },
|
|
38
|
+
onReady(cb) {
|
|
39
|
+
readyQueue.push(cb);
|
|
40
|
+
return () => { readyQueue.splice(readyQueue.indexOf(cb), 1); };
|
|
41
|
+
},
|
|
42
|
+
onConsentChanged(cb) {
|
|
43
|
+
consentChangedQueue.push(cb);
|
|
44
|
+
return () => { consentChangedQueue.splice(consentChangedQueue.indexOf(cb), 1); };
|
|
45
|
+
},
|
|
46
|
+
hasConsent: () => false,
|
|
47
|
+
readConsent: () => null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
22
50
|
const cdnBaseUrl = options.cdnBaseUrl ?? DEFAULT_CDN_BASE_URL;
|
|
23
51
|
const version = options.version ?? DEFAULT_VERSION;
|
|
24
52
|
const baseUrl = `${cdnBaseUrl}/${version}`;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privacykit/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Developer-friendly GDPR consent management with real enforcement.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"sync-types": "cp ../privacykit-sdk/public/privacykit.d.ts ./privacykit.d.ts",
|
|
31
31
|
"build": "npx tsc",
|
|
32
|
-
"publish:patch": "npm run
|
|
33
|
-
"publish:minor": "npm run
|
|
32
|
+
"publish:patch": "npm run build && npm login && npm version patch && npm publish",
|
|
33
|
+
"publish:minor": "npm run build && npm login && npm version minor && npm publish"
|
|
34
34
|
}
|
|
35
35
|
}
|
package/privacykit.d.ts
CHANGED
|
@@ -160,6 +160,8 @@ declare global {
|
|
|
160
160
|
dialogPosition: 'left' | 'right';
|
|
161
161
|
/** Whether the dialog is currently open. @default false */
|
|
162
162
|
open: boolean;
|
|
163
|
+
/** Enable Google Consent Mode v2 compatibility layer. When set, PrivacyKit emits GCM v2 consent updates via window.gtag or window.dataLayer on init and whenever consent changes. @default false */
|
|
164
|
+
googleConsentMode: boolean;
|
|
163
165
|
|
|
164
166
|
/** Programmatically open the dialog. */
|
|
165
167
|
openDialog(): Promise<void>;
|
|
@@ -298,6 +300,8 @@ interface ConsentDialogJSXProps {
|
|
|
298
300
|
'dialog-position'?: 'left' | 'right';
|
|
299
301
|
/** Open/close state. */
|
|
300
302
|
'open'?: boolean | '';
|
|
303
|
+
/** Enable Google Consent Mode v2 compatibility layer. */
|
|
304
|
+
'google-consent-mode'?: boolean | '';
|
|
301
305
|
'ref'?: CKRef<HTMLConsentDialogElement>;
|
|
302
306
|
'children'?: unknown;
|
|
303
307
|
/** Inline styles — pass CSS custom properties like `--pk-primary-color` here. */
|