@moontra/moonui-pro 3.0.0 → 3.1.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/plugin/next.js DELETED
@@ -1,83 +0,0 @@
1
- /**
2
- * MoonUI Pro Next.js Plugin
3
- * Automatically validates license at build time and injects token
4
- */
5
-
6
- const { validateLicenseAtBuildTime, generateWebpackDefineConfig } = require('../dist/build-time-validator');
7
- const webpack = require('webpack');
8
-
9
- // Cache the token to avoid multiple validations
10
- let cachedToken = null;
11
- let isValidating = false;
12
-
13
- module.exports = function withMoonUI(nextConfig = {}) {
14
- return {
15
- ...nextConfig,
16
- webpack: (config, options) => {
17
- // Only run in production builds
18
- if (!options.dev && !isValidating) {
19
- isValidating = true;
20
-
21
- // Get license key from environment
22
- const licenseKey = process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY ||
23
- process.env.MOONUI_LICENSE_KEY ||
24
- process.env.MOONUI_PRO_LICENSE;
25
-
26
- if (licenseKey) {
27
- console.log('[MoonUI] Starting build-time license validation...');
28
-
29
- // Validate license and generate token
30
- const tokenPromise = validateLicenseAtBuildTime(licenseKey)
31
- .then(token => {
32
- if (token) {
33
- cachedToken = token;
34
- console.log('[MoonUI] License validated successfully, token generated');
35
-
36
- // Add DefinePlugin to inject token
37
- const defineConfig = generateWebpackDefineConfig(token);
38
- config.plugins.push(
39
- new webpack.DefinePlugin(defineConfig)
40
- );
41
- } else {
42
- console.warn('[MoonUI] License validation failed, Pro features disabled');
43
- }
44
- })
45
- .catch(error => {
46
- console.error('[MoonUI] Error during license validation:', error);
47
- })
48
- .finally(() => {
49
- isValidating = false;
50
- });
51
-
52
- // Make build wait for validation
53
- if (options.isServer) {
54
- config.plugins.push({
55
- apply: (compiler) => {
56
- compiler.hooks.beforeCompile.tapPromise('MoonUILicensePlugin', async () => {
57
- await tokenPromise;
58
- });
59
- }
60
- });
61
- }
62
- } else {
63
- console.log('[MoonUI] No license key found, Pro features disabled');
64
- console.log('[MoonUI] Set NEXT_PUBLIC_MOONUI_LICENSE_KEY to enable Pro features');
65
- }
66
- }
67
-
68
- // Call user's webpack config if exists
69
- if (typeof nextConfig.webpack === 'function') {
70
- return nextConfig.webpack(config, options);
71
- }
72
-
73
- return config;
74
- },
75
-
76
- // Preserve other Next.js configurations
77
- env: {
78
- ...nextConfig.env,
79
- // Add build info
80
- MOONUI_BUILD_VERSION: require('../package.json').version,
81
- },
82
- };
83
- };
package/plugin/vite.js DELETED
@@ -1,76 +0,0 @@
1
- /**
2
- * MoonUI Pro Vite Plugin
3
- * Automatically validates license at build time and injects token
4
- */
5
-
6
- const { validateLicenseAtBuildTime } = require('../dist/build-time-validator');
7
-
8
- let cachedToken = null;
9
-
10
- module.exports = function moonuiVitePlugin() {
11
- return {
12
- name: 'moonui-license-validator',
13
-
14
- async config(config, { command }) {
15
- // Only run in production builds
16
- if (command === 'build') {
17
- // Get license key from environment
18
- const licenseKey = process.env.VITE_MOONUI_LICENSE_KEY ||
19
- process.env.MOONUI_LICENSE_KEY ||
20
- process.env.MOONUI_PRO_LICENSE;
21
-
22
- if (licenseKey) {
23
- console.log('[MoonUI] Starting build-time license validation...');
24
-
25
- try {
26
- // Validate license and generate token
27
- const token = await validateLicenseAtBuildTime(licenseKey);
28
-
29
- if (token) {
30
- cachedToken = token;
31
- console.log('[MoonUI] License validated successfully, token generated');
32
-
33
- // Add token to define config
34
- return {
35
- define: {
36
- ...config.define,
37
- 'process.env.MOONUI_BUILD_TOKEN': JSON.stringify(token),
38
- 'process.env.MOONUI_BUILD_TIME': JSON.stringify(Date.now()),
39
- }
40
- };
41
- } else {
42
- console.warn('[MoonUI] License validation failed, Pro features disabled');
43
- }
44
- } catch (error) {
45
- console.error('[MoonUI] Error during license validation:', error);
46
- }
47
- } else {
48
- console.log('[MoonUI] No license key found, Pro features disabled');
49
- console.log('[MoonUI] Set VITE_MOONUI_LICENSE_KEY to enable Pro features');
50
- }
51
- }
52
-
53
- return {};
54
- },
55
-
56
- // Transform hook to inject token for development
57
- transform(code, id) {
58
- if (id.includes('moonui-pro') && cachedToken) {
59
- // Inject token into moonui-pro modules during development
60
- return {
61
- code: `
62
- if (!process.env.MOONUI_BUILD_TOKEN) {
63
- process.env.MOONUI_BUILD_TOKEN = ${JSON.stringify(cachedToken)};
64
- }
65
- ${code}
66
- `,
67
- map: null
68
- };
69
- }
70
- return null;
71
- }
72
- };
73
- };
74
-
75
- // ES module export for Vite
76
- module.exports.default = module.exports;