@privacykit/web 0.1.3 → 0.1.4

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.
@@ -0,0 +1,7 @@
1
+ import "./styles.css";
2
+ export type InitPrivacyKitOptions = {
3
+ version?: string;
4
+ cdnBaseUrl?: string;
5
+ loadApi?: boolean;
6
+ };
7
+ export declare function initPrivacyKit(options?: InitPrivacyKitOptions): void;
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ import "./styles.css";
2
+ const DEFAULT_CDN_BASE_URL = "https://cdn.privacykit.eu";
3
+ const DEFAULT_VERSION = "v1";
4
+ function addScript(src, options) {
5
+ if (options?.id && document.getElementById(options.id)) {
6
+ return;
7
+ }
8
+ const script = document.createElement("script");
9
+ if (options?.id)
10
+ script.id = options.id;
11
+ if (options?.type)
12
+ script.type = options.type;
13
+ if (options?.nomodule)
14
+ script.noModule = true;
15
+ script.src = src;
16
+ document.head.appendChild(script);
17
+ }
18
+ export function initPrivacyKit(options = {}) {
19
+ if (typeof document === "undefined") {
20
+ return;
21
+ }
22
+ const cdnBaseUrl = options.cdnBaseUrl ?? DEFAULT_CDN_BASE_URL;
23
+ const version = options.version ?? DEFAULT_VERSION;
24
+ const baseUrl = `${cdnBaseUrl}/${version}`;
25
+ addScript(`${baseUrl}/privacykit.esm.js`, {
26
+ id: "privacykit-components-esm",
27
+ type: "module"
28
+ });
29
+ addScript(`${baseUrl}/privacykit.js`, {
30
+ id: "privacykit-components-nomodule",
31
+ nomodule: true
32
+ });
33
+ if (options.loadApi !== false) {
34
+ addScript(`${baseUrl}/index.esm.js`, {
35
+ id: "privacykit-api-esm",
36
+ type: "module"
37
+ });
38
+ }
39
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@privacykit/web",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Developer-friendly GDPR consent management with real enforcement.",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "author": "PrivacyKit",
14
14
  "license": "MIT",
15
15
  "devDependencies": {
16
- "typescript": "^6.0.3"
16
+ "typescript": "^5.9.0"
17
17
  },
18
18
  "files": [
19
19
  "dist",
@@ -23,7 +23,8 @@
23
23
  ],
24
24
  "scripts": {
25
25
  "sync-types": "cp ../privacykit-sdk/public/privacykit.d.ts ./privacykit.d.ts",
26
- "publish:patch": "npm run sync-types && npm version patch && npm publish",
27
- "publish:minor": "npm run sync-types && npm version minor && npm publish"
26
+ "build": "npx tsc",
27
+ "publish:patch": "npm run sync-types && npm run build && npm version patch && npm publish",
28
+ "publish:minor": "npm run sync-types && npm run build && npm version minor && npm publish"
28
29
  }
29
30
  }