@kirby-tools/licensing 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/index.mjs +14 -12
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2,19 +2,19 @@ import { usePanel, useApi } from 'kirbyuse';
2
2
 
3
3
  const TRANSLATIONS = {
4
4
  en: {
5
- "modal.info": "Thanks for purchasing {plugin}! Please enter your email address and order ID to activate your license.",
5
+ "modal.info": "Thanks for purchasing {label}! Please enter your email address and order ID to activate your license.",
6
6
  "modal.help.orderId": '<a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Get your order number</a> from Lemon Squeezy or <a href="mailto:hello@kirby.tools">contact us</a> if you cannot find it.',
7
7
  "activate": "Activate",
8
8
  "activated": "Plugin activated"
9
9
  },
10
10
  de: {
11
- "modal.info": "Dankesch\xF6n f\xFCr den Kauf vom {plugin}! Bitte gib deine E-Mail-Adresse und Bestellnummer ein, um deine Lizenz zu aktivieren.",
11
+ "modal.info": "Dankesch\xF6n f\xFCr den Kauf von {label}! Bitte gib deine E-Mail-Adresse und Bestellnummer ein, um deine Lizenz zu aktivieren.",
12
12
  "modal.help.orderId": 'Rufe die <a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Bestellnummer von Lemon Squeezy ab</a> oder <a href="mailto:hello@kirby.tools">kontaktiere uns</a>, wenn du sie nicht finden kannst.',
13
13
  "activate": "Aktivieren",
14
14
  "activated": "Plugin aktiviert"
15
15
  },
16
16
  fr: {
17
- "modal.info": "Merci d'avoir achet\xE9 {plugin} ! Veuillez saisir votre adresse e-mail et votre num\xE9ro de commande pour activer votre licence.",
17
+ "modal.info": "Merci d'avoir achet\xE9 {label} ! Veuillez saisir votre adresse e-mail et votre num\xE9ro de commande pour activer votre licence.",
18
18
  "modal.help.orderId": 'Obtenez votre num\xE9ro de commande sur <a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Lemon Squeezy</a> ou <a href="mailto:hello@kirby.tools">contactez-nous</a> si vous ne le trouvez pas.',
19
19
  "activate": "Activer",
20
20
  "activated": "Plugin activ\xE9"
@@ -36,13 +36,15 @@ function template(input, values, fallback) {
36
36
  );
37
37
  }
38
38
 
39
+ const LOCALHOST_HOSTNAMES = ["localhost", "127.0.0.1", "[::1]"];
40
+ const LOCAL_DOMAINS = ["local", "test", "ddev.site"];
39
41
  function useLicense({
40
42
  label,
41
43
  apiNamespace
42
44
  }) {
43
45
  const panel = usePanel();
44
46
  const api = useApi();
45
- const isLocalhost = _isLocalhost();
47
+ const isLocalhost = isLocal();
46
48
  const register = async (email, orderId) => {
47
49
  if (!email || !orderId) {
48
50
  throw new Error("Email and order ID are required");
@@ -60,12 +62,12 @@ function useLicense({
60
62
  submitButton: {
61
63
  icon: "check",
62
64
  theme: "love",
63
- text: t("activate", { plugin: label })
65
+ text: t("activate", { label })
64
66
  },
65
67
  fields: {
66
68
  info: {
67
69
  type: "info",
68
- text: t("modal.info", { plugin: label })
70
+ text: t("modal.info", { label })
69
71
  },
70
72
  email: {
71
73
  label: panel.t("email"),
@@ -74,7 +76,7 @@ function useLicense({
74
76
  orderId: {
75
77
  label: "Order ID",
76
78
  type: "text",
77
- help: t("modal.help.orderId", { plugin: label })
79
+ help: t("modal.help.orderId", { label })
78
80
  }
79
81
  }
80
82
  },
@@ -93,7 +95,7 @@ function useLicense({
93
95
  }
94
96
  panel.dialog.close();
95
97
  await panel.view.reload();
96
- panel.notification.success(t("activated"), { plugin: label });
98
+ panel.notification.success(t("activated"), { label });
97
99
  }
98
100
  }
99
101
  });
@@ -103,11 +105,11 @@ function useLicense({
103
105
  openLicenseModal
104
106
  };
105
107
  }
106
- function _isLocalhost() {
108
+ function isLocal() {
107
109
  const { hostname } = window.location;
108
- const isLocalhost = ["localhost", "127.0.0.1", "::1"].includes(hostname);
109
- const isTestDomain = hostname.endsWith(".test");
110
- return isLocalhost || isTestDomain;
110
+ const isLocalhost = LOCALHOST_HOSTNAMES.includes(hostname);
111
+ const isLocalDomain = LOCAL_DOMAINS.some((domain) => hostname.endsWith(`.${domain}`));
112
+ return isLocalhost || isLocalDomain;
111
113
  }
112
114
 
113
115
  export { useLicense };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirby-tools/licensing",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "packageManager": "pnpm@9.3.0",
6
6
  "description": "Shared tooling for licensing in the Panel",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",