@kirby-tools/licensing 0.1.12 → 0.2.0

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.d.mts CHANGED
@@ -1,8 +1,12 @@
1
1
  import { Ref, ComponentPublicInstance } from 'vue';
2
2
 
3
+ type MaybeRef<T = any> = T | Ref<T>;
4
+ type LicenseKey = string;
3
5
  interface License {
6
+ licenseKey: LicenseKey;
4
7
  [key: string]: string;
5
8
  }
9
+
6
10
  interface LicenseOptions {
7
11
  label: string;
8
12
  apiNamespace: string;
@@ -14,9 +18,9 @@ declare function useLicense({ label, apiNamespace, }: LicenseOptions): {
14
18
  isLocalhost: boolean;
15
19
  assertActivationIntegrity: ({ templateRef, license }: {
16
20
  templateRef: Ref<ComponentPublicInstance | null | undefined>;
17
- license: boolean | string | License;
18
- }) => Promise<boolean>;
21
+ license: MaybeRef<boolean | string | License>;
22
+ }) => Promise<void>;
19
23
  openLicenseModal: () => Promise<LicenseModalResult>;
20
24
  };
21
25
 
22
- export { useLicense };
26
+ export { type License, type LicenseKey, useLicense };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import { Ref, ComponentPublicInstance } from 'vue';
2
2
 
3
+ type MaybeRef<T = any> = T | Ref<T>;
4
+ type LicenseKey = string;
3
5
  interface License {
6
+ licenseKey: LicenseKey;
4
7
  [key: string]: string;
5
8
  }
9
+
6
10
  interface LicenseOptions {
7
11
  label: string;
8
12
  apiNamespace: string;
@@ -14,9 +18,9 @@ declare function useLicense({ label, apiNamespace, }: LicenseOptions): {
14
18
  isLocalhost: boolean;
15
19
  assertActivationIntegrity: ({ templateRef, license }: {
16
20
  templateRef: Ref<ComponentPublicInstance | null | undefined>;
17
- license: boolean | string | License;
18
- }) => Promise<boolean>;
21
+ license: MaybeRef<boolean | string | License>;
22
+ }) => Promise<void>;
19
23
  openLicenseModal: () => Promise<LicenseModalResult>;
20
24
  };
21
25
 
22
- export { useLicense };
26
+ export { type License, type LicenseKey, useLicense };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { usePanel, useApi, nextTick } from 'kirbyuse';
1
+ import { usePanel, useApi, unref, nextTick } from 'kirbyuse';
2
2
 
3
3
  const TRANSLATIONS = {
4
4
  en: {
@@ -116,22 +116,22 @@ function useLicense({
116
116
  }
117
117
  isRegistered = true;
118
118
  panel.dialog.close();
119
- panel.notification.success(t("activated"), { label });
119
+ panel.notification.success(t("activated"));
120
120
  }
121
121
  }
122
122
  });
123
123
  });
124
124
  };
125
125
  const assertActivationIntegrity = async ({ templateRef, license }) => {
126
- if (license !== false) {
127
- return true;
126
+ const _license = unref(license);
127
+ if (_license !== false) {
128
+ return;
128
129
  }
129
130
  await nextTick();
130
- if (!templateRef.value) {
131
- panel.notification.error("Are you trying to hide the activation buttons? Please buy a license.");
132
- return false;
131
+ if (!templateRef.value?.$el || window.getComputedStyle(templateRef.value.$el).display === "none" || window.getComputedStyle(templateRef.value.$el).visibility === "hidden") {
132
+ const message = "Are you trying to hide the activation buttons? Please buy a license.";
133
+ throw new Error(message);
133
134
  }
134
- return true;
135
135
  };
136
136
  return {
137
137
  isLocalhost,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirby-tools/licensing",
3
3
  "type": "module",
4
- "version": "0.1.12",
4
+ "version": "0.2.0",
5
5
  "packageManager": "pnpm@9.4.0",
6
6
  "description": "Shared tooling for licensing in the Panel",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",
@@ -32,7 +32,7 @@
32
32
  "release": "bumpp"
33
33
  },
34
34
  "dependencies": {
35
- "kirbyuse": "^0.4.1",
35
+ "kirbyuse": "^0.7.0",
36
36
  "vue": "^2.7.16"
37
37
  },
38
38
  "devDependencies": {