@privacykit/web 1.2.0 → 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 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
@@ -3,3 +3,9 @@ declare module "*.css";
3
3
  import "./privacykit";
4
4
 
5
5
  export * from './dist/index';
6
+
7
+ declare global {
8
+ interface Window {
9
+ PrivacyKit: PrivacyKitGlobalApi;
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privacykit/web",
3
- "version": "1.2.0",
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 sync-types && npm run build && npm version patch && npm publish",
33
- "publish:minor": "npm run sync-types && npm run build && npm version minor && npm publish"
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
  }