@moontra/moonui-pro 2.37.18 → 3.0.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/cdn/index.global.js +126 -126
- package/dist/cdn/index.global.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +45 -0
- package/dist/lib/build-time-validator.d.ts +30 -0
- package/dist/lib/build-time-validator.mjs +117 -0
- package/dist/lib/client-token-verifier.d.ts +27 -0
- package/dist/lib/client-token-verifier.mjs +44 -0
- package/package.json +1 -1
- package/plugin/next.js +83 -0
- package/plugin/vite.js +76 -0
package/dist/index.d.ts
CHANGED
|
@@ -376,7 +376,7 @@ declare const MoonUIAvatarFallbackPro: React$1.ForwardRefExoticComponent<Omit<Av
|
|
|
376
376
|
* Dark ve light modda uyumlu, erişilebilir ve çeşitli varyantlar sunar.
|
|
377
377
|
*/
|
|
378
378
|
declare const moonUIBadgeVariantsPro: (props?: ({
|
|
379
|
-
variant?: "primary" | "secondary" | "success" | "warning" | "ghost" | "outline" | "destructive" | "
|
|
379
|
+
variant?: "pro" | "primary" | "secondary" | "success" | "warning" | "ghost" | "outline" | "destructive" | "admin" | null | undefined;
|
|
380
380
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
381
381
|
radius?: "default" | "none" | "sm" | "lg" | null | undefined;
|
|
382
382
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
@@ -4367,7 +4367,7 @@ declare const statusVariants: (props?: ({
|
|
|
4367
4367
|
declare const badgeVariants: (props?: ({
|
|
4368
4368
|
size?: "sm" | "md" | "lg" | "xl" | "2xl" | "xs" | "3xl" | null | undefined;
|
|
4369
4369
|
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | null | undefined;
|
|
4370
|
-
variant?: "lifetime" | "default" | "success" | "warning" | "info" | "destructive" |
|
|
4370
|
+
variant?: "pro" | "lifetime" | "default" | "success" | "warning" | "info" | "destructive" | null | undefined;
|
|
4371
4371
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
4372
4372
|
declare const iconBadgeMap: {
|
|
4373
4373
|
crown: React$1.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React$1.RefAttributes<SVGSVGElement>>;
|
package/dist/index.mjs
CHANGED
|
@@ -2114,6 +2114,34 @@ var AUTH_CONFIG = {
|
|
|
2114
2114
|
session: "x-moonui-session-id"
|
|
2115
2115
|
}
|
|
2116
2116
|
};
|
|
2117
|
+
|
|
2118
|
+
// src/lib/client-token-verifier.ts
|
|
2119
|
+
function verifyBuildToken() {
|
|
2120
|
+
try {
|
|
2121
|
+
const token = process.env.MOONUI_BUILD_TOKEN;
|
|
2122
|
+
if (!token) {
|
|
2123
|
+
console.log("[MoonUI] No build token found");
|
|
2124
|
+
return null;
|
|
2125
|
+
}
|
|
2126
|
+
const decoded = JSON.parse(Buffer.from(token, "base64").toString());
|
|
2127
|
+
const payload = {
|
|
2128
|
+
licenseKey: decoded.licenseKey || "validated",
|
|
2129
|
+
domain: decoded.domain || window.location.hostname,
|
|
2130
|
+
timestamp: decoded.timestamp || Date.now(),
|
|
2131
|
+
expiresAt: decoded.expiresAt || Date.now() + 7 * 24 * 60 * 60 * 1e3,
|
|
2132
|
+
hasProAccess: decoded.hasProAccess !== false,
|
|
2133
|
+
plan: decoded.plan || "pro"
|
|
2134
|
+
};
|
|
2135
|
+
if (payload.expiresAt < Date.now()) {
|
|
2136
|
+
console.warn("[MoonUI] Build token expired, rebuild required");
|
|
2137
|
+
return null;
|
|
2138
|
+
}
|
|
2139
|
+
return payload;
|
|
2140
|
+
} catch (error) {
|
|
2141
|
+
console.error("[MoonUI] Error verifying build token:", error);
|
|
2142
|
+
return null;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2117
2145
|
var AuthContext = createContext(void 0);
|
|
2118
2146
|
var authPromise = null;
|
|
2119
2147
|
var lastFetchTime = 0;
|
|
@@ -2159,6 +2187,23 @@ function MoonUIAuthProvider({ children }) {
|
|
|
2159
2187
|
console.log("[MoonUI Auth] Using ongoing request");
|
|
2160
2188
|
return authPromise;
|
|
2161
2189
|
}
|
|
2190
|
+
const buildToken = verifyBuildToken();
|
|
2191
|
+
if (buildToken && buildToken.hasProAccess) {
|
|
2192
|
+
console.log("[MoonUI Auth] Using build-time token - Pro access granted");
|
|
2193
|
+
const tokenState = {
|
|
2194
|
+
isLoading: false,
|
|
2195
|
+
hasProAccess: true,
|
|
2196
|
+
isAuthenticated: true,
|
|
2197
|
+
subscriptionPlan: buildToken.plan === "lifetime" ? "lifetime" : "free",
|
|
2198
|
+
subscription: {
|
|
2199
|
+
status: "active",
|
|
2200
|
+
plan: buildToken.plan === "lifetime" ? "lifetime" : "free"
|
|
2201
|
+
},
|
|
2202
|
+
isAdmin: false
|
|
2203
|
+
};
|
|
2204
|
+
setState(tokenState);
|
|
2205
|
+
return tokenState;
|
|
2206
|
+
}
|
|
2162
2207
|
if (!forceRefresh2) {
|
|
2163
2208
|
const cached = readValidationFromCookie();
|
|
2164
2209
|
if (cached && cached.valid) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time license validation and token generation
|
|
3
|
+
* This runs during build process, not in browser
|
|
4
|
+
*/
|
|
5
|
+
interface TokenPayload {
|
|
6
|
+
licenseKey: string;
|
|
7
|
+
domain: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
expiresAt: number;
|
|
10
|
+
hasProAccess: boolean;
|
|
11
|
+
plan: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validate license key at build time
|
|
15
|
+
* Makes server-side request to avoid CORS
|
|
16
|
+
*/
|
|
17
|
+
declare function validateLicenseAtBuildTime(licenseKey: string | undefined, domain?: string): Promise<string | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Verify and decrypt token on client-side
|
|
20
|
+
*/
|
|
21
|
+
declare function verifyAndDecryptToken(token: string): TokenPayload | null;
|
|
22
|
+
/**
|
|
23
|
+
* Generate a webpack DefinePlugin config with the token
|
|
24
|
+
*/
|
|
25
|
+
declare function generateWebpackDefineConfig(token: string | null): {
|
|
26
|
+
'process.env.MOONUI_BUILD_TOKEN': string;
|
|
27
|
+
'process.env.MOONUI_BUILD_TIME': string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { generateWebpackDefineConfig, validateLicenseAtBuildTime, verifyAndDecryptToken };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @moontra/moonui-pro v2.0.9
|
|
5
|
+
* Premium UI components for MoonUI
|
|
6
|
+
* (c) 2025 MoonUI. All rights reserved.
|
|
7
|
+
* @license Commercial - https://moonui.dev/license
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var ENCRYPTION_KEY = "moonui-pro-2024-encryption-key-v1";
|
|
11
|
+
var SIGNING_KEY = "moonui-pro-2024-signing-key-v1";
|
|
12
|
+
async function validateLicenseAtBuildTime(licenseKey, domain) {
|
|
13
|
+
if (!licenseKey) {
|
|
14
|
+
console.log("[MoonUI Build] No license key provided");
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
console.log("[MoonUI Build] Validating license key...");
|
|
19
|
+
const validationDomain = domain || process.env.VERCEL_URL || process.env.NEXT_PUBLIC_VERCEL_URL || process.env.DEPLOY_URL || "localhost";
|
|
20
|
+
const response = await fetch("https://moonui.dev/api/v1/license/validate", {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
"X-Build-Time-Validation": "true",
|
|
25
|
+
"User-Agent": "MoonUI-Build-Validator/1.0"
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
licenseKey,
|
|
29
|
+
domain: validationDomain
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
console.error("[MoonUI Build] License validation failed:", response.status);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const data = await response.json();
|
|
37
|
+
if (!data.valid || !data.hasProAccess) {
|
|
38
|
+
console.error("[MoonUI Build] Invalid license or no Pro access");
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
console.log("[MoonUI Build] License validated successfully");
|
|
42
|
+
const payload = {
|
|
43
|
+
licenseKey: licenseKey.substring(0, 8) + "...",
|
|
44
|
+
// Only store partial key
|
|
45
|
+
domain: validationDomain,
|
|
46
|
+
timestamp: Date.now(),
|
|
47
|
+
expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1e3,
|
|
48
|
+
// 7 days
|
|
49
|
+
hasProAccess: data.hasProAccess,
|
|
50
|
+
plan: data.plan || "pro"
|
|
51
|
+
};
|
|
52
|
+
const token = encryptAndSignToken(payload);
|
|
53
|
+
return token;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("[MoonUI Build] Error validating license:", error);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function encryptAndSignToken(payload) {
|
|
60
|
+
const payloadString = JSON.stringify(payload);
|
|
61
|
+
const iv = crypto.randomBytes(16);
|
|
62
|
+
const cipher = crypto.createCipheriv(
|
|
63
|
+
"aes-256-gcm",
|
|
64
|
+
crypto.scryptSync(ENCRYPTION_KEY, "salt", 32),
|
|
65
|
+
iv
|
|
66
|
+
);
|
|
67
|
+
let encrypted = cipher.update(payloadString, "utf8", "hex");
|
|
68
|
+
encrypted += cipher.final("hex");
|
|
69
|
+
const authTag = cipher.getAuthTag();
|
|
70
|
+
const hmac = crypto.createHmac("sha256", SIGNING_KEY);
|
|
71
|
+
hmac.update(encrypted);
|
|
72
|
+
const signature = hmac.digest("hex");
|
|
73
|
+
const token = Buffer.from(JSON.stringify({
|
|
74
|
+
encrypted,
|
|
75
|
+
authTag: authTag.toString("hex"),
|
|
76
|
+
signature,
|
|
77
|
+
iv: iv.toString("hex")
|
|
78
|
+
})).toString("base64");
|
|
79
|
+
return token;
|
|
80
|
+
}
|
|
81
|
+
function verifyAndDecryptToken(token) {
|
|
82
|
+
try {
|
|
83
|
+
const decoded = JSON.parse(Buffer.from(token, "base64").toString());
|
|
84
|
+
const hmac = crypto.createHmac("sha256", SIGNING_KEY);
|
|
85
|
+
hmac.update(decoded.encrypted);
|
|
86
|
+
const expectedSignature = hmac.digest("hex");
|
|
87
|
+
if (decoded.signature !== expectedSignature) {
|
|
88
|
+
console.error("[MoonUI] Invalid token signature");
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const decipher = crypto.createDecipheriv(
|
|
92
|
+
"aes-256-gcm",
|
|
93
|
+
crypto.scryptSync(ENCRYPTION_KEY, "salt", 32),
|
|
94
|
+
Buffer.from(decoded.iv, "hex")
|
|
95
|
+
);
|
|
96
|
+
decipher.setAuthTag(Buffer.from(decoded.authTag, "hex"));
|
|
97
|
+
let decrypted = decipher.update(decoded.encrypted, "hex", "utf8");
|
|
98
|
+
decrypted += decipher.final("utf8");
|
|
99
|
+
const payload = JSON.parse(decrypted);
|
|
100
|
+
if (payload.expiresAt < Date.now()) {
|
|
101
|
+
console.error("[MoonUI] Token expired");
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return payload;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error("[MoonUI] Error verifying token:", error);
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function generateWebpackDefineConfig(token) {
|
|
111
|
+
return {
|
|
112
|
+
"process.env.MOONUI_BUILD_TOKEN": JSON.stringify(token),
|
|
113
|
+
"process.env.MOONUI_BUILD_TIME": JSON.stringify(Date.now())
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { generateWebpackDefineConfig, validateLicenseAtBuildTime, verifyAndDecryptToken };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side token verification
|
|
3
|
+
* This runs in the browser and verifies the build-time generated token
|
|
4
|
+
*/
|
|
5
|
+
interface TokenPayload {
|
|
6
|
+
licenseKey: string;
|
|
7
|
+
domain: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
expiresAt: number;
|
|
10
|
+
hasProAccess: boolean;
|
|
11
|
+
plan: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Simple client-side token verification
|
|
15
|
+
* Note: Real decryption happens server-side, this is just a basic check
|
|
16
|
+
*/
|
|
17
|
+
declare function verifyBuildToken(): TokenPayload | null;
|
|
18
|
+
/**
|
|
19
|
+
* Check if Pro features are enabled
|
|
20
|
+
*/
|
|
21
|
+
declare function hasProAccess(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get subscription plan from token
|
|
24
|
+
*/
|
|
25
|
+
declare function getSubscriptionPlan(): string;
|
|
26
|
+
|
|
27
|
+
export { getSubscriptionPlan, hasProAccess, verifyBuildToken };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @moontra/moonui-pro v2.0.9
|
|
3
|
+
* Premium UI components for MoonUI
|
|
4
|
+
* (c) 2025 MoonUI. All rights reserved.
|
|
5
|
+
* @license Commercial - https://moonui.dev/license
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// src/lib/client-token-verifier.ts
|
|
9
|
+
function verifyBuildToken() {
|
|
10
|
+
try {
|
|
11
|
+
const token = process.env.MOONUI_BUILD_TOKEN;
|
|
12
|
+
if (!token) {
|
|
13
|
+
console.log("[MoonUI] No build token found");
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const decoded = JSON.parse(Buffer.from(token, "base64").toString());
|
|
17
|
+
const payload = {
|
|
18
|
+
licenseKey: decoded.licenseKey || "validated",
|
|
19
|
+
domain: decoded.domain || window.location.hostname,
|
|
20
|
+
timestamp: decoded.timestamp || Date.now(),
|
|
21
|
+
expiresAt: decoded.expiresAt || Date.now() + 7 * 24 * 60 * 60 * 1e3,
|
|
22
|
+
hasProAccess: decoded.hasProAccess !== false,
|
|
23
|
+
plan: decoded.plan || "pro"
|
|
24
|
+
};
|
|
25
|
+
if (payload.expiresAt < Date.now()) {
|
|
26
|
+
console.warn("[MoonUI] Build token expired, rebuild required");
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return payload;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error("[MoonUI] Error verifying build token:", error);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function hasProAccess() {
|
|
36
|
+
const token = verifyBuildToken();
|
|
37
|
+
return token ? token.hasProAccess : false;
|
|
38
|
+
}
|
|
39
|
+
function getSubscriptionPlan() {
|
|
40
|
+
const token = verifyBuildToken();
|
|
41
|
+
return token ? token.plan : "free";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { getSubscriptionPlan, hasProAccess, verifyBuildToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
package/plugin/next.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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;
|