@moontra/moonui-pro 3.4.2 → 3.4.4

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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Next.js Config Plugin for MoonUI Pro
3
+ * Automatically resolves and injects license token at build time
4
+ *
5
+ * Usage in next.config.js:
6
+ *
7
+ * ```js
8
+ * const { withMoonUIProToken } = require('@moontra/moonui-pro/next-config');
9
+ *
10
+ * const nextConfig = {
11
+ * // your config
12
+ * };
13
+ *
14
+ * module.exports = withMoonUIProToken(nextConfig);
15
+ * ```
16
+ */
17
+ interface NextConfig {
18
+ env?: Record<string, string>;
19
+ [key: string]: any;
20
+ }
21
+ /**
22
+ * Next.js config wrapper that auto-resolves MoonUI Pro token
23
+ */
24
+ declare function withMoonUIProToken(nextConfig?: NextConfig): NextConfig;
25
+ /**
26
+ * Async version for webpack plugins (advanced usage)
27
+ */
28
+ declare function resolveTokenAsync(): Promise<string | null>;
29
+
30
+ export { withMoonUIProToken as default, resolveTokenAsync, withMoonUIProToken };
@@ -0,0 +1,218 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+
4
+ /**
5
+ * @moontra/moonui-pro v2.0.9
6
+ * Premium UI components for MoonUI
7
+ * (c) 2025 MoonUI. All rights reserved.
8
+ * @license Commercial - https://moonui.dev/license
9
+ */
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined")
14
+ return require.apply(this, arguments);
15
+ throw new Error('Dynamic require of "' + x + '" is not supported');
16
+ });
17
+ function findExistingToken() {
18
+ if (typeof window !== "undefined") {
19
+ return null;
20
+ }
21
+ const possiblePaths = [
22
+ path.join(process.cwd(), ".moonui-license-token"),
23
+ path.join(process.cwd(), "..", ".moonui-license-token"),
24
+ path.join(process.cwd(), "..", "..", ".moonui-license-token")
25
+ ];
26
+ if (process.env.VERCEL_ARTIFACTS_PATH) {
27
+ possiblePaths.push(path.join(process.env.VERCEL_ARTIFACTS_PATH, ".moonui-license-token"));
28
+ }
29
+ if (process.env.NETLIFY_BUILD_BASE) {
30
+ possiblePaths.push(path.join(process.env.NETLIFY_BUILD_BASE, ".moonui-license-token"));
31
+ }
32
+ possiblePaths.push("/tmp/.moonui-license-token");
33
+ for (const filePath of possiblePaths) {
34
+ if (fs.existsSync(filePath)) {
35
+ try {
36
+ return fs.readFileSync(filePath, "utf8");
37
+ } catch (err) {
38
+ console.error(`[MoonUI Token Generator] Failed to read token from ${filePath}:`, err);
39
+ }
40
+ }
41
+ }
42
+ return null;
43
+ }
44
+ async function generateTokenIfMissing(options = {}) {
45
+ const { silent = false, forceRegenerate = false } = options;
46
+ try {
47
+ if (!forceRegenerate && process.env.MOONUI_PRO_TOKEN) {
48
+ if (!silent) {
49
+ console.log("[MoonUI Token Generator] Token found in environment variable");
50
+ }
51
+ return {
52
+ success: true,
53
+ token: JSON.parse(Buffer.from(process.env.MOONUI_PRO_TOKEN, "base64").toString("utf8")),
54
+ cached: true
55
+ };
56
+ }
57
+ if (!forceRegenerate) {
58
+ const existingToken = findExistingToken();
59
+ if (existingToken) {
60
+ if (!silent) {
61
+ console.log("[MoonUI Token Generator] Token file already exists");
62
+ }
63
+ return {
64
+ success: true,
65
+ token: JSON.parse(Buffer.from(existingToken, "base64").toString("utf8")),
66
+ cached: true
67
+ };
68
+ }
69
+ }
70
+ const licenseKey = process.env.MOONUI_LICENSE_KEY || process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY || process.env.VITE_MOONUI_LICENSE_KEY || process.env.REACT_APP_MOONUI_LICENSE_KEY;
71
+ if (!licenseKey) {
72
+ if (!silent) {
73
+ console.log("[MoonUI Token Generator] No license key found in environment variables");
74
+ }
75
+ return {
76
+ success: false,
77
+ error: "No license key found"
78
+ };
79
+ }
80
+ const postInstallPath = path.join(__dirname, "../../scripts/postinstall.cjs");
81
+ if (!fs.existsSync(postInstallPath)) {
82
+ if (!silent) {
83
+ console.error("[MoonUI Token Generator] PostInstall script not found at:", postInstallPath);
84
+ }
85
+ return {
86
+ success: false,
87
+ error: "PostInstall script not found"
88
+ };
89
+ }
90
+ const postInstall = __require(postInstallPath);
91
+ if (!silent) {
92
+ console.log("[MoonUI Token Generator] Validating license key and generating token...");
93
+ }
94
+ const result = await postInstall.validateAndCreateToken(licenseKey, { silent });
95
+ if (result.success && result.token) {
96
+ const saveSuccess = postInstall.saveLicenseToken(result.token);
97
+ if (saveSuccess) {
98
+ if (!silent) {
99
+ console.log("[MoonUI Token Generator] \u2713 Token generated and saved successfully");
100
+ }
101
+ return {
102
+ success: true,
103
+ token: result.token
104
+ };
105
+ } else {
106
+ if (!silent) {
107
+ console.log("[MoonUI Token Generator] \u26A0 Token generated but failed to save");
108
+ }
109
+ return {
110
+ success: false,
111
+ error: "Failed to save token"
112
+ };
113
+ }
114
+ } else {
115
+ if (!silent) {
116
+ console.log("[MoonUI Token Generator] \u2717 License validation failed:", result.error);
117
+ }
118
+ return {
119
+ success: false,
120
+ error: result.error || "License validation failed"
121
+ };
122
+ }
123
+ } catch (error) {
124
+ if (!silent) {
125
+ console.error("[MoonUI Token Generator] Error:", error.message);
126
+ }
127
+ return {
128
+ success: false,
129
+ error: error.message
130
+ };
131
+ }
132
+ }
133
+ function resolveTokenSync() {
134
+ try {
135
+ if (process.env.MOONUI_PRO_TOKEN) {
136
+ return process.env.MOONUI_PRO_TOKEN;
137
+ }
138
+ const existingToken = findExistingToken();
139
+ if (existingToken) {
140
+ return existingToken;
141
+ }
142
+ return null;
143
+ } catch (error) {
144
+ console.error("[MoonUI Token Generator] Error resolving token:", error);
145
+ return null;
146
+ }
147
+ }
148
+ function getLicenseKeyFromEnv() {
149
+ return process.env.MOONUI_LICENSE_KEY || process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY || process.env.VITE_MOONUI_LICENSE_KEY || process.env.REACT_APP_MOONUI_LICENSE_KEY || null;
150
+ }
151
+
152
+ // src/next-config-plugin.ts
153
+ function withMoonUIProToken(nextConfig = {}) {
154
+ console.log("[MoonUI Next.js Plugin] === INITIALIZING ===");
155
+ let token = resolveTokenSync();
156
+ if (token) {
157
+ console.log("[MoonUI Next.js Plugin] \u2713 Existing token found");
158
+ } else {
159
+ const licenseKey = getLicenseKeyFromEnv();
160
+ if (licenseKey) {
161
+ console.log("[MoonUI Next.js Plugin] License key found, attempting to generate token...");
162
+ const { execSync } = __require("child_process");
163
+ const path2 = __require("path");
164
+ try {
165
+ const postInstallPath = path2.join(__dirname, "../scripts/postinstall.cjs");
166
+ execSync(`node ${postInstallPath}`, {
167
+ env: { ...process.env },
168
+ stdio: "inherit"
169
+ });
170
+ token = resolveTokenSync();
171
+ if (token) {
172
+ console.log("[MoonUI Next.js Plugin] \u2713 Token generated successfully");
173
+ } else {
174
+ console.log("[MoonUI Next.js Plugin] \u26A0 Token generation attempted but token not found");
175
+ }
176
+ } catch (error) {
177
+ console.error("[MoonUI Next.js Plugin] Failed to generate token:", error.message);
178
+ }
179
+ } else {
180
+ console.log("[MoonUI Next.js Plugin] No license key found in environment");
181
+ console.log("[MoonUI Next.js Plugin] Set MOONUI_LICENSE_KEY to enable Pro features");
182
+ }
183
+ }
184
+ const enhancedConfig = {
185
+ ...nextConfig,
186
+ env: {
187
+ ...nextConfig.env,
188
+ NEXT_PUBLIC_MOONUI_PRO_TOKEN: token || ""
189
+ }
190
+ };
191
+ if (token) {
192
+ console.log("[MoonUI Next.js Plugin] \u2713 Token injected into NEXT_PUBLIC_MOONUI_PRO_TOKEN");
193
+ } else {
194
+ console.log("[MoonUI Next.js Plugin] Running without Pro features");
195
+ }
196
+ console.log("[MoonUI Next.js Plugin] === INITIALIZATION COMPLETE ===");
197
+ return enhancedConfig;
198
+ }
199
+ async function resolveTokenAsync() {
200
+ const syncToken = resolveTokenSync();
201
+ if (syncToken) {
202
+ return syncToken;
203
+ }
204
+ const licenseKey = getLicenseKeyFromEnv();
205
+ if (!licenseKey) {
206
+ return null;
207
+ }
208
+ console.log("[MoonUI Next.js Plugin] Generating token asynchronously...");
209
+ const result = await generateTokenIfMissing({ silent: false });
210
+ if (result.success && result.token) {
211
+ const tokenString = JSON.stringify(result.token);
212
+ return Buffer.from(tokenString).toString("base64");
213
+ }
214
+ return null;
215
+ }
216
+ var next_config_plugin_default = withMoonUIProToken;
217
+
218
+ export { next_config_plugin_default as default, resolveTokenAsync, withMoonUIProToken };
package/dist/server.d.ts CHANGED
@@ -118,6 +118,7 @@ interface LicenseToken {
118
118
  declare function readLicenseTokenServer(): LicenseToken | null;
119
119
  /**
120
120
  * Read license token (server-side only)
121
+ * With runtime fallback if token not found
121
122
  */
122
123
  declare function readLicenseToken(): LicenseToken | null;
123
124
  /**
package/dist/server.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
1
3
  import * as crypto from 'crypto';
2
4
  import crypto__default from 'crypto';
3
5
 
@@ -20,9 +22,16 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
20
22
  return require.apply(this, arguments);
21
23
  throw new Error('Dynamic require of "' + x + '" is not supported');
22
24
  });
25
+ var __esm = (fn, res) => function __init() {
26
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
27
+ };
23
28
  var __commonJS = (cb, mod) => function __require2() {
24
29
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
25
30
  };
31
+ var __export = (target, all) => {
32
+ for (var name in all)
33
+ __defProp(target, name, { get: all[name], enumerable: true });
34
+ };
26
35
  var __copyProps = (to, from, except, desc) => {
27
36
  if (from && typeof from === "object" || typeof from === "function") {
28
37
  for (let key of __getOwnPropNames(from))
@@ -39,6 +48,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
48
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
49
  mod
41
50
  ));
51
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
52
 
43
53
  // ../../node_modules/next/dist/compiled/@edge-runtime/cookies/index.js
44
54
  var require_cookies = __commonJS({
@@ -47,7 +57,7 @@ var require_cookies = __commonJS({
47
57
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
48
58
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
49
59
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
50
- var __export = (target, all) => {
60
+ var __export2 = (target, all) => {
51
61
  for (var name in all)
52
62
  __defProp2(target, name, { get: all[name], enumerable: true });
53
63
  };
@@ -59,16 +69,16 @@ var require_cookies = __commonJS({
59
69
  }
60
70
  return to;
61
71
  };
62
- var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
72
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
63
73
  var src_exports = {};
64
- __export(src_exports, {
74
+ __export2(src_exports, {
65
75
  RequestCookies: () => RequestCookies,
66
76
  ResponseCookies: () => ResponseCookies,
67
77
  parseCookie: () => parseCookie,
68
78
  parseSetCookie: () => parseSetCookie,
69
79
  stringifyCookie: () => stringifyCookie
70
80
  });
71
- module.exports = __toCommonJS(src_exports);
81
+ module.exports = __toCommonJS2(src_exports);
72
82
  function stringifyCookie(c) {
73
83
  var _a;
74
84
  const attrs = [
@@ -113,7 +123,7 @@ var require_cookies = __commonJS({
113
123
  expires,
114
124
  httponly,
115
125
  maxage,
116
- path,
126
+ path: path2,
117
127
  samesite,
118
128
  secure,
119
129
  partitioned,
@@ -131,7 +141,7 @@ var require_cookies = __commonJS({
131
141
  ...expires && { expires: new Date(expires) },
132
142
  ...httponly && { httpOnly: true },
133
143
  ...typeof maxage === "string" && { maxAge: Number(maxage) },
134
- path,
144
+ path: path2,
135
145
  ...samesite && { sameSite: parseSameSite(samesite) },
136
146
  ...secure && { secure: true },
137
147
  ...priority && { priority: parsePriority(priority) },
@@ -2960,6 +2970,152 @@ var require_headers3 = __commonJS({
2960
2970
  }
2961
2971
  });
2962
2972
 
2973
+ // src/lib/license-token-generator.ts
2974
+ var license_token_generator_exports = {};
2975
+ __export(license_token_generator_exports, {
2976
+ generateTokenIfMissing: () => generateTokenIfMissing,
2977
+ getLicenseKeyFromEnv: () => getLicenseKeyFromEnv,
2978
+ resolveTokenSync: () => resolveTokenSync
2979
+ });
2980
+ function findExistingToken() {
2981
+ if (typeof window !== "undefined") {
2982
+ return null;
2983
+ }
2984
+ const possiblePaths = [
2985
+ path.join(process.cwd(), ".moonui-license-token"),
2986
+ path.join(process.cwd(), "..", ".moonui-license-token"),
2987
+ path.join(process.cwd(), "..", "..", ".moonui-license-token")
2988
+ ];
2989
+ if (process.env.VERCEL_ARTIFACTS_PATH) {
2990
+ possiblePaths.push(path.join(process.env.VERCEL_ARTIFACTS_PATH, ".moonui-license-token"));
2991
+ }
2992
+ if (process.env.NETLIFY_BUILD_BASE) {
2993
+ possiblePaths.push(path.join(process.env.NETLIFY_BUILD_BASE, ".moonui-license-token"));
2994
+ }
2995
+ possiblePaths.push("/tmp/.moonui-license-token");
2996
+ for (const filePath of possiblePaths) {
2997
+ if (fs.existsSync(filePath)) {
2998
+ try {
2999
+ return fs.readFileSync(filePath, "utf8");
3000
+ } catch (err) {
3001
+ console.error(`[MoonUI Token Generator] Failed to read token from ${filePath}:`, err);
3002
+ }
3003
+ }
3004
+ }
3005
+ return null;
3006
+ }
3007
+ async function generateTokenIfMissing(options = {}) {
3008
+ const { silent = false, forceRegenerate = false } = options;
3009
+ try {
3010
+ if (!forceRegenerate && process.env.MOONUI_PRO_TOKEN) {
3011
+ if (!silent) {
3012
+ console.log("[MoonUI Token Generator] Token found in environment variable");
3013
+ }
3014
+ return {
3015
+ success: true,
3016
+ token: JSON.parse(Buffer.from(process.env.MOONUI_PRO_TOKEN, "base64").toString("utf8")),
3017
+ cached: true
3018
+ };
3019
+ }
3020
+ if (!forceRegenerate) {
3021
+ const existingToken = findExistingToken();
3022
+ if (existingToken) {
3023
+ if (!silent) {
3024
+ console.log("[MoonUI Token Generator] Token file already exists");
3025
+ }
3026
+ return {
3027
+ success: true,
3028
+ token: JSON.parse(Buffer.from(existingToken, "base64").toString("utf8")),
3029
+ cached: true
3030
+ };
3031
+ }
3032
+ }
3033
+ const licenseKey = process.env.MOONUI_LICENSE_KEY || process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY || process.env.VITE_MOONUI_LICENSE_KEY || process.env.REACT_APP_MOONUI_LICENSE_KEY;
3034
+ if (!licenseKey) {
3035
+ if (!silent) {
3036
+ console.log("[MoonUI Token Generator] No license key found in environment variables");
3037
+ }
3038
+ return {
3039
+ success: false,
3040
+ error: "No license key found"
3041
+ };
3042
+ }
3043
+ const postInstallPath = path.join(__dirname, "../../scripts/postinstall.cjs");
3044
+ if (!fs.existsSync(postInstallPath)) {
3045
+ if (!silent) {
3046
+ console.error("[MoonUI Token Generator] PostInstall script not found at:", postInstallPath);
3047
+ }
3048
+ return {
3049
+ success: false,
3050
+ error: "PostInstall script not found"
3051
+ };
3052
+ }
3053
+ const postInstall = __require(postInstallPath);
3054
+ if (!silent) {
3055
+ console.log("[MoonUI Token Generator] Validating license key and generating token...");
3056
+ }
3057
+ const result = await postInstall.validateAndCreateToken(licenseKey, { silent });
3058
+ if (result.success && result.token) {
3059
+ const saveSuccess = postInstall.saveLicenseToken(result.token);
3060
+ if (saveSuccess) {
3061
+ if (!silent) {
3062
+ console.log("[MoonUI Token Generator] \u2713 Token generated and saved successfully");
3063
+ }
3064
+ return {
3065
+ success: true,
3066
+ token: result.token
3067
+ };
3068
+ } else {
3069
+ if (!silent) {
3070
+ console.log("[MoonUI Token Generator] \u26A0 Token generated but failed to save");
3071
+ }
3072
+ return {
3073
+ success: false,
3074
+ error: "Failed to save token"
3075
+ };
3076
+ }
3077
+ } else {
3078
+ if (!silent) {
3079
+ console.log("[MoonUI Token Generator] \u2717 License validation failed:", result.error);
3080
+ }
3081
+ return {
3082
+ success: false,
3083
+ error: result.error || "License validation failed"
3084
+ };
3085
+ }
3086
+ } catch (error) {
3087
+ if (!silent) {
3088
+ console.error("[MoonUI Token Generator] Error:", error.message);
3089
+ }
3090
+ return {
3091
+ success: false,
3092
+ error: error.message
3093
+ };
3094
+ }
3095
+ }
3096
+ function resolveTokenSync() {
3097
+ try {
3098
+ if (process.env.MOONUI_PRO_TOKEN) {
3099
+ return process.env.MOONUI_PRO_TOKEN;
3100
+ }
3101
+ const existingToken = findExistingToken();
3102
+ if (existingToken) {
3103
+ return existingToken;
3104
+ }
3105
+ return null;
3106
+ } catch (error) {
3107
+ console.error("[MoonUI Token Generator] Error resolving token:", error);
3108
+ return null;
3109
+ }
3110
+ }
3111
+ function getLicenseKeyFromEnv() {
3112
+ return process.env.MOONUI_LICENSE_KEY || process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY || process.env.VITE_MOONUI_LICENSE_KEY || process.env.REACT_APP_MOONUI_LICENSE_KEY || null;
3113
+ }
3114
+ var init_license_token_generator = __esm({
3115
+ "src/lib/license-token-generator.ts"() {
3116
+ }
3117
+ });
3118
+
2963
3119
  // src/lib/server-auth.ts
2964
3120
  var import_headers = __toESM(require_headers3(), 1);
2965
3121
 
@@ -3184,27 +3340,27 @@ function readLicenseTokenServer() {
3184
3340
  console.error("[MoonUI] Failed to parse MOONUI_PRO_TOKEN:", envError);
3185
3341
  }
3186
3342
  }
3187
- const fs = __require("fs");
3188
- const path = __require("path");
3343
+ const fs2 = __require("fs");
3344
+ const path2 = __require("path");
3189
3345
  const possiblePaths = [
3190
- path.join(process.cwd(), ".moonui-license"),
3191
- path.join(process.cwd(), "..", ".moonui-license"),
3192
- path.join(process.cwd(), "..", "..", ".moonui-license"),
3193
- path.join(__dirname, "..", "..", "..", "..", ".moonui-license")
3346
+ path2.join(process.cwd(), ".moonui-license"),
3347
+ path2.join(process.cwd(), "..", ".moonui-license"),
3348
+ path2.join(process.cwd(), "..", "..", ".moonui-license"),
3349
+ path2.join(__dirname, "..", "..", "..", "..", ".moonui-license")
3194
3350
  ];
3195
3351
  if (process.env.VERCEL_ARTIFACTS_PATH) {
3196
- possiblePaths.push(path.join(process.env.VERCEL_ARTIFACTS_PATH, ".moonui-license"));
3352
+ possiblePaths.push(path2.join(process.env.VERCEL_ARTIFACTS_PATH, ".moonui-license"));
3197
3353
  }
3198
3354
  if (process.env.NETLIFY_BUILD_BASE) {
3199
- possiblePaths.push(path.join(process.env.NETLIFY_BUILD_BASE, ".moonui-license"));
3355
+ possiblePaths.push(path2.join(process.env.NETLIFY_BUILD_BASE, ".moonui-license"));
3200
3356
  }
3201
3357
  possiblePaths.push("/tmp/.moonui-license");
3202
3358
  let encryptedData = null;
3203
3359
  let foundPath = null;
3204
3360
  for (const filePath of possiblePaths) {
3205
- if (fs.existsSync(filePath)) {
3361
+ if (fs2.existsSync(filePath)) {
3206
3362
  foundPath = filePath;
3207
- const fileContent = fs.readFileSync(filePath, "utf8");
3363
+ const fileContent = fs2.readFileSync(filePath, "utf8");
3208
3364
  encryptedData = JSON.parse(fileContent);
3209
3365
  break;
3210
3366
  }
@@ -3230,8 +3386,51 @@ function readLicenseTokenServer() {
3230
3386
  return null;
3231
3387
  }
3232
3388
  }
3389
+ async function generateTokenAtRuntime() {
3390
+ try {
3391
+ if (typeof window !== "undefined") {
3392
+ return null;
3393
+ }
3394
+ console.log("[MoonUI] Runtime fallback: Attempting to generate token...");
3395
+ const { generateTokenIfMissing: generateTokenIfMissing2 } = (init_license_token_generator(), __toCommonJS(license_token_generator_exports));
3396
+ const result = await generateTokenIfMissing2({ silent: false });
3397
+ if (result.success && result.token) {
3398
+ console.log("[MoonUI] \u2713 Token generated at runtime");
3399
+ return result.token;
3400
+ } else {
3401
+ console.log("[MoonUI] \u2717 Runtime token generation failed:", result.error);
3402
+ return null;
3403
+ }
3404
+ } catch (error) {
3405
+ console.error("[MoonUI] Runtime fallback error:", error.message);
3406
+ return null;
3407
+ }
3408
+ }
3409
+ var runtimeToken = void 0;
3410
+ var runtimeTokenAttempted = false;
3233
3411
  function readLicenseToken() {
3234
- return readLicenseTokenServer();
3412
+ const token = readLicenseTokenServer();
3413
+ if (token) {
3414
+ return token;
3415
+ }
3416
+ if (runtimeTokenAttempted) {
3417
+ return runtimeToken || null;
3418
+ }
3419
+ if (typeof window === "undefined") {
3420
+ console.log("[MoonUI] Token not found, scheduling runtime generation...");
3421
+ generateTokenAtRuntime().then((token2) => {
3422
+ runtimeToken = token2;
3423
+ runtimeTokenAttempted = true;
3424
+ if (token2) {
3425
+ console.log("[MoonUI] \u2713 Runtime token generation completed");
3426
+ }
3427
+ }).catch((error) => {
3428
+ console.error("[MoonUI] Runtime token generation failed:", error);
3429
+ runtimeTokenAttempted = true;
3430
+ runtimeToken = null;
3431
+ });
3432
+ }
3433
+ return null;
3235
3434
  }
3236
3435
  function hasProAccessFromToken() {
3237
3436
  const token = readLicenseToken();
@@ -0,0 +1,38 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * Vite Plugin for MoonUI Pro
5
+ * Automatically resolves and injects license token at build time
6
+ *
7
+ * Usage in vite.config.ts:
8
+ *
9
+ * ```ts
10
+ * import { moonUIProPlugin } from '@moontra/moonui-pro/vite';
11
+ * import { defineConfig } from 'vite';
12
+ *
13
+ * export default defineConfig({
14
+ * plugins: [
15
+ * moonUIProPlugin(),
16
+ * ],
17
+ * });
18
+ * ```
19
+ */
20
+
21
+ interface MoonUIProPluginOptions {
22
+ /**
23
+ * Suppress console logs
24
+ * @default false
25
+ */
26
+ silent?: boolean;
27
+ /**
28
+ * Force token regeneration even if exists
29
+ * @default false
30
+ */
31
+ forceRegenerate?: boolean;
32
+ }
33
+ /**
34
+ * Vite plugin for MoonUI Pro license token management
35
+ */
36
+ declare function moonUIProPlugin(options?: MoonUIProPluginOptions): Plugin;
37
+
38
+ export { moonUIProPlugin as default, moonUIProPlugin };