@moontra/moonui-pro 3.3.0 → 3.3.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/server.mjs CHANGED
@@ -3170,6 +3170,20 @@ function readLicenseTokenServer() {
3170
3170
  if (typeof window !== "undefined") {
3171
3171
  return null;
3172
3172
  }
3173
+ if (process.env.MOONUI_PRO_TOKEN) {
3174
+ try {
3175
+ const tokenString = Buffer.from(process.env.MOONUI_PRO_TOKEN, "base64").toString("utf8");
3176
+ const token2 = JSON.parse(tokenString);
3177
+ if (token2.expiresAt < Date.now()) {
3178
+ console.log("[MoonUI] License token expired, re-validation required");
3179
+ return null;
3180
+ }
3181
+ console.log("[MoonUI] License token loaded successfully from environment variable");
3182
+ return token2;
3183
+ } catch (envError) {
3184
+ console.error("[MoonUI] Failed to parse MOONUI_PRO_TOKEN:", envError);
3185
+ }
3186
+ }
3173
3187
  const fs = __require("fs");
3174
3188
  const path = __require("path");
3175
3189
  const possiblePaths = [
@@ -3178,6 +3192,13 @@ function readLicenseTokenServer() {
3178
3192
  path.join(process.cwd(), "..", "..", ".moonui-license"),
3179
3193
  path.join(__dirname, "..", "..", "..", "..", ".moonui-license")
3180
3194
  ];
3195
+ if (process.env.VERCEL_ARTIFACTS_PATH) {
3196
+ possiblePaths.push(path.join(process.env.VERCEL_ARTIFACTS_PATH, ".moonui-license"));
3197
+ }
3198
+ if (process.env.NETLIFY_BUILD_BASE) {
3199
+ possiblePaths.push(path.join(process.env.NETLIFY_BUILD_BASE, ".moonui-license"));
3200
+ }
3201
+ possiblePaths.push("/tmp/.moonui-license");
3181
3202
  let encryptedData = null;
3182
3203
  let foundPath = null;
3183
3204
  for (const filePath of possiblePaths) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
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",
@@ -58,6 +58,8 @@ async function validateLicense(licenseKey) {
58
58
  source: 'postinstall'
59
59
  });
60
60
 
61
+ console.log('[MoonUI Pro] Sending validation request with data:', postData);
62
+
61
63
  const options = {
62
64
  hostname: 'moonui.dev',
63
65
  port: 443,
@@ -74,25 +76,33 @@ async function validateLicense(licenseKey) {
74
76
  const req = https.request(options, (res) => {
75
77
  let data = '';
76
78
 
79
+ console.log('[MoonUI Pro] Response status code:', res.statusCode);
80
+
77
81
  res.on('data', (chunk) => {
78
82
  data += chunk;
79
83
  });
80
84
 
81
85
  res.on('end', () => {
82
86
  try {
87
+ console.log('[MoonUI Pro] Raw response data:', data);
83
88
  const result = JSON.parse(data);
84
- if (res.statusCode === 200 && result.valid) {
89
+ console.log('[MoonUI Pro] Parsed response:', JSON.stringify(result, null, 2));
90
+
91
+ if (res.statusCode === 200) {
92
+ // Return the full result, don't check result.valid here
85
93
  resolve(result);
86
94
  } else {
87
95
  reject(new Error(result.error || 'License validation failed'));
88
96
  }
89
97
  } catch (error) {
98
+ console.error('[MoonUI Pro] Error parsing response:', error);
90
99
  reject(error);
91
100
  }
92
101
  });
93
102
  });
94
103
 
95
104
  req.on('error', (error) => {
105
+ console.error('[MoonUI Pro] Request error:', error);
96
106
  reject(error);
97
107
  });
98
108
 
@@ -101,15 +111,58 @@ async function validateLicense(licenseKey) {
101
111
  });
102
112
  }
103
113
 
104
- // Save license token to file
114
+ // Save license token to file or environment
105
115
  function saveLicenseToken(token) {
106
116
  try {
117
+ console.log('[MoonUI Pro] Starting to save license token...');
118
+
119
+ // Check if we're in Vercel build environment
120
+ const isVercelBuild = process.env.VERCEL === '1';
121
+ const isNetlifyBuild = process.env.NETLIFY === 'true';
122
+
123
+ if (isVercelBuild || isNetlifyBuild) {
124
+ console.log('[MoonUI Pro] Detected build environment:', isVercelBuild ? 'Vercel' : 'Netlify');
125
+
126
+ // In Vercel/Netlify, we can't write files persistently
127
+ // Instead, we'll set an environment variable that the build can use
128
+ const tokenString = JSON.stringify(token);
129
+ const base64Token = Buffer.from(tokenString).toString('base64');
130
+
131
+ console.log('[MoonUI Pro] Setting MOONUI_PRO_TOKEN environment variable for build...');
132
+ process.env.MOONUI_PRO_TOKEN = base64Token;
133
+
134
+ // Also try to write to a temp location that might be available during build
135
+ try {
136
+ const tempPath = process.env.VERCEL_ARTIFACTS_PATH || process.env.NETLIFY_BUILD_BASE || '/tmp';
137
+ const tempLicenseFile = path.join(tempPath, LICENSE_FILE);
138
+
139
+ // Encrypt token with a deterministic key based on environment
140
+ const encryptionKey = process.env.MOONUI_LICENSE_KEY || 'default-key';
141
+ const encryptedData = encryptToken(token, encryptionKey);
142
+
143
+ fs.writeFileSync(tempLicenseFile, JSON.stringify(encryptedData, null, 2));
144
+ console.log('[MoonUI Pro] Token saved to temporary location:', tempLicenseFile);
145
+ } catch (tempError) {
146
+ console.log('[MoonUI Pro] Could not write to temp location (expected in some environments)');
147
+ }
148
+
149
+ console.log('[MoonUI Pro] ✓ License token stored for build environment');
150
+ return true;
151
+ }
152
+
153
+ // Standard file system approach for local development
107
154
  // Find the project root (where package.json is)
108
155
  let projectRoot = process.cwd();
156
+ console.log('[MoonUI Pro] Initial working directory:', projectRoot);
157
+
109
158
  let attempts = 0;
110
159
 
111
160
  while (attempts < 10) {
112
- if (fs.existsSync(path.join(projectRoot, 'package.json'))) {
161
+ const packageJsonPath = path.join(projectRoot, 'package.json');
162
+ console.log(`[MoonUI Pro] Checking for package.json at: ${packageJsonPath}`);
163
+
164
+ if (fs.existsSync(packageJsonPath)) {
165
+ console.log('[MoonUI Pro] Found package.json at:', projectRoot);
113
166
  break;
114
167
  }
115
168
  projectRoot = path.dirname(projectRoot);
@@ -117,19 +170,44 @@ function saveLicenseToken(token) {
117
170
  }
118
171
 
119
172
  const licenseFilePath = path.join(projectRoot, LICENSE_FILE);
173
+ console.log('[MoonUI Pro] License file path:', licenseFilePath);
120
174
 
121
175
  // Encrypt token with a deterministic key based on environment
122
176
  const encryptionKey = process.env.MOONUI_LICENSE_KEY || 'default-key';
177
+ console.log('[MoonUI Pro] Using encryption key:', encryptionKey.substring(0, 10) + '...');
178
+
123
179
  const encryptedData = encryptToken(token, encryptionKey);
180
+ console.log('[MoonUI Pro] Token encrypted successfully');
124
181
 
125
182
  // Save to file
183
+ console.log('[MoonUI Pro] Writing to file:', licenseFilePath);
126
184
  fs.writeFileSync(licenseFilePath, JSON.stringify(encryptedData, null, 2));
127
185
 
128
- console.log('[MoonUI Pro] License token saved successfully');
129
- return true;
186
+ // Verify file was created
187
+ if (fs.existsSync(licenseFilePath)) {
188
+ const stats = fs.statSync(licenseFilePath);
189
+ console.log('[MoonUI Pro] ✓ License token saved successfully');
190
+ console.log('[MoonUI Pro] File size:', stats.size, 'bytes');
191
+ return true;
192
+ } else {
193
+ console.error('[MoonUI Pro] File was not created despite no errors');
194
+ return false;
195
+ }
130
196
  } catch (error) {
131
197
  console.error('[MoonUI Pro] Failed to save license token:', error.message);
132
- return false;
198
+ console.error('[MoonUI Pro] Full error:', error);
199
+
200
+ // As a fallback, try to set environment variable
201
+ try {
202
+ const tokenString = JSON.stringify(token);
203
+ const base64Token = Buffer.from(tokenString).toString('base64');
204
+ process.env.MOONUI_PRO_TOKEN = base64Token;
205
+ console.log('[MoonUI Pro] Fallback: Set MOONUI_PRO_TOKEN environment variable');
206
+ return true;
207
+ } catch (fallbackError) {
208
+ console.error('[MoonUI Pro] Fallback also failed:', fallbackError);
209
+ return false;
210
+ }
133
211
  }
134
212
  }
135
213
 
@@ -164,23 +242,39 @@ async function main() {
164
242
  // Validate license with API
165
243
  const validationResult = await validateLicense(licenseKey);
166
244
 
167
- if (validationResult.valid && validationResult.hasProAccess) {
245
+ // Debug: Log the full validation result
246
+ console.log('[MoonUI Pro] Validation result:', JSON.stringify(validationResult, null, 2));
247
+
248
+ if (validationResult && validationResult.valid && validationResult.hasProAccess) {
249
+ console.log('[MoonUI Pro] ✓ License is valid and has Pro access');
250
+
168
251
  // Create token with validation result and expiry
169
252
  const token = {
170
253
  valid: true,
171
254
  hasProAccess: validationResult.hasProAccess,
172
- plan: validationResult.plan,
255
+ plan: validationResult.plan || 'pro',
173
256
  expiresAt: Date.now() + CACHE_DURATION,
174
257
  timestamp: Date.now()
175
258
  };
176
259
 
260
+ console.log('[MoonUI Pro] Creating token:', JSON.stringify(token, null, 2));
261
+
177
262
  // Save encrypted token
178
- saveLicenseToken(token);
263
+ const saveResult = saveLicenseToken(token);
179
264
 
180
- console.log('[MoonUI Pro] ✓ License validated successfully');
181
- console.log('[MoonUI Pro] ✓ Pro features enabled');
265
+ if (saveResult) {
266
+ console.log('[MoonUI Pro] ✓ License validated successfully');
267
+ console.log('[MoonUI Pro] ✓ Pro features enabled');
268
+ } else {
269
+ console.log('[MoonUI Pro] ⚠ License valid but failed to save token');
270
+ }
182
271
  } else {
183
- console.log('[MoonUI Pro] License validation failed');
272
+ console.log('[MoonUI Pro] License validation failed or no Pro access');
273
+ console.log('[MoonUI Pro] Validation result:', {
274
+ valid: validationResult?.valid || false,
275
+ hasProAccess: validationResult?.hasProAccess || false,
276
+ plan: validationResult?.plan || 'none'
277
+ });
184
278
  console.log('[MoonUI Pro] Pro features will be disabled');
185
279
  }
186
280
  } catch (error) {