nuxt-ui-elements-pro 0.1.0 → 0.1.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/module.d.mts CHANGED
@@ -7,6 +7,11 @@ interface ModuleOptions {
7
7
  * @default 'UE'
8
8
  */
9
9
  prefix?: string;
10
+ /**
11
+ * License key for production builds
12
+ * Can also be set via NUXT_UI_ELEMENTS_PRO_KEY env variable
13
+ */
14
+ license?: string;
10
15
  }
11
16
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
17
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ui-elements-pro",
3
3
  "configKey": "uiElementsPro",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,5 +1,6 @@
1
- import { addTemplate, defineNuxtModule, createResolver, addImportsDir, addComponentsDir } from '@nuxt/kit';
1
+ import { addTemplate, useLogger, defineNuxtModule, createResolver, addImportsDir, addComponentsDir } from '@nuxt/kit';
2
2
  import { kebabCase } from 'scule';
3
+ import { ofetch } from 'ofetch';
3
4
 
4
5
  const eventCalendar = (options) => ({
5
6
  slots: {
@@ -143,19 +144,64 @@ function addTemplates(options, _nuxt) {
143
144
  templates.forEach((template) => addTemplate(template));
144
145
  }
145
146
 
147
+ async function validateLicense(opts) {
148
+ if (!opts.key) {
149
+ throw new Error(
150
+ `Missing \`${opts.env}\` license key.
151
+ Purchase a license to build your app for production.`
152
+ );
153
+ }
154
+ try {
155
+ await ofetch(opts.url, {
156
+ method: "POST",
157
+ headers: {
158
+ Authorization: `key ${opts.key}`
159
+ }
160
+ });
161
+ } catch (error) {
162
+ if (error.status && Math.round(error.status / 100) === 4) {
163
+ throw new Error(
164
+ `Invalid \`${opts.env}\` license key.
165
+ Purchase a license to build your app for production.`
166
+ );
167
+ }
168
+ throw new Error("Cannot validate license: " + error);
169
+ }
170
+ }
171
+
172
+ const logger = useLogger("nuxt-ui-elements-pro");
173
+ const LICENSE_ENV = "NUXT_UI_ELEMENTS_PRO_KEY";
174
+ const LICENSE_URL = "https://api.example.com/verify";
146
175
  const module$1 = defineNuxtModule({
147
176
  meta: {
148
177
  name: "nuxt-ui-elements-pro",
149
178
  configKey: "uiElementsPro"
150
179
  },
151
180
  defaults: {
152
- prefix: "UE"
181
+ prefix: "UE",
182
+ license: ""
153
183
  },
154
184
  moduleDependencies: {
155
185
  "nuxt-ui-elements": {}
156
186
  },
157
187
  setup(options, nuxt) {
158
188
  const resolver = createResolver(import.meta.url);
189
+ const key = process.env[LICENSE_ENV] || options.license;
190
+ if (nuxt.options.dev || nuxt.options._prepare || nuxt.options.test) {
191
+ if (nuxt.options.dev && !key) {
192
+ logger.box(
193
+ `nuxt-ui-elements-pro
194
+
195
+ Missing \`${LICENSE_ENV}\` env variable.
196
+
197
+ Add it to your \`.env\` file to build for production.`
198
+ );
199
+ }
200
+ } else {
201
+ nuxt.hook("build:before", async () => {
202
+ await validateLicense({ key, env: LICENSE_ENV, url: LICENSE_URL });
203
+ });
204
+ }
159
205
  const uiOptions = nuxt.options.ui;
160
206
  const themeColors = uiOptions?.theme?.colors || ["primary", "secondary", "success", "info", "warning", "error"];
161
207
  const optionsWithTheme = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-elements-pro",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Pro components for nuxt-ui-elements",
5
5
  "license": "UNLICENSED",
6
6
  "files": [
@@ -40,6 +40,7 @@
40
40
  "@internationalized/date": "3.11.0",
41
41
  "@nuxt/kit": "4.3.1",
42
42
  "nuxt-ui-elements": "0.1.39",
43
+ "ofetch": "^1.5.1",
43
44
  "scule": "1.3.0",
44
45
  "tailwind-variants": "3.2.2"
45
46
  },