@moontra/moonui-pro 2.37.15 → 2.37.16

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/index.d.ts CHANGED
@@ -146,13 +146,32 @@ interface AuthContextType extends AuthState {
146
146
  refreshAuth: () => Promise<void>;
147
147
  clearAuth: () => void;
148
148
  }
149
+ interface MoonUIAuthProviderProps {
150
+ children: ReactNode;
151
+ /**
152
+ * Environment mode - defaults to 'development' if not provided
153
+ * In Next.js: environment={process.env.NODE_ENV}
154
+ * In Vite: environment={import.meta.env.MODE}
155
+ * In CRA: environment={process.env.NODE_ENV}
156
+ */
157
+ environment?: 'development' | 'production' | 'test';
158
+ /**
159
+ * License key for production environments
160
+ * In Next.js: licenseKey={process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY}
161
+ * In Vite: licenseKey={import.meta.env.VITE_MOONUI_LICENSE_KEY}
162
+ * In CRA: licenseKey={process.env.REACT_APP_MOONUI_LICENSE_KEY}
163
+ */
164
+ licenseKey?: string;
165
+ /**
166
+ * Force production mode (useful for testing)
167
+ */
168
+ forceProduction?: boolean;
169
+ }
149
170
  /**
150
171
  * MoonUI Auth Provider - Centralized authentication state
151
172
  * This provider ensures only ONE API call is made for all components
152
173
  */
153
- declare function MoonUIAuthProvider({ children }: {
154
- children: ReactNode;
155
- }): react_jsx_runtime.JSX.Element;
174
+ declare function MoonUIAuthProvider({ children, environment, licenseKey, forceProduction }: MoonUIAuthProviderProps): react_jsx_runtime.JSX.Element;
156
175
  /**
157
176
  * Hook to use auth context
158
177
  * Falls back to direct API call if context is not available
package/dist/index.mjs CHANGED
@@ -2118,7 +2118,12 @@ var AuthContext = createContext(void 0);
2118
2118
  var authPromise = null;
2119
2119
  var lastFetchTime = 0;
2120
2120
  var FETCH_COOLDOWN = 5e3;
2121
- function MoonUIAuthProvider({ children }) {
2121
+ function MoonUIAuthProvider({
2122
+ children,
2123
+ environment = "development",
2124
+ licenseKey,
2125
+ forceProduction = false
2126
+ }) {
2122
2127
  const [state, setState] = useState({
2123
2128
  isLoading: true,
2124
2129
  hasProAccess: false,
@@ -2185,30 +2190,16 @@ function MoonUIAuthProvider({ children }) {
2185
2190
  authPromise = (async () => {
2186
2191
  try {
2187
2192
  lastFetchTime = now;
2188
- let isProduction = false;
2189
- let isDevelopment = true;
2190
- let environmentInfo = {};
2191
- try {
2192
- const envResponse = await fetch("/api/environment", {
2193
- method: "GET",
2194
- cache: "no-store"
2195
- });
2196
- if (envResponse.ok) {
2197
- environmentInfo = await envResponse.json();
2198
- isProduction = environmentInfo.isProduction;
2199
- isDevelopment = environmentInfo.isDevelopment;
2200
- console.log("[MoonUI Auth] Runtime Environment Detection:", {
2201
- ...environmentInfo.debug,
2202
- environment: environmentInfo.environment,
2203
- isProduction,
2204
- isDevelopment
2205
- });
2206
- } else {
2207
- console.warn("[MoonUI Auth] Failed to fetch environment info, falling back to development mode");
2208
- }
2209
- } catch (error) {
2210
- console.warn("[MoonUI Auth] Error fetching environment info:", error);
2211
- }
2193
+ const isProduction = forceProduction || environment === "production";
2194
+ const isDevelopment = !isProduction;
2195
+ const hasLicenseKey = !!licenseKey;
2196
+ console.log("[MoonUI Auth] Environment Detection:", {
2197
+ environment,
2198
+ forceProduction,
2199
+ hasLicenseKey,
2200
+ isProduction,
2201
+ isDevelopment
2202
+ });
2212
2203
  if (isDevelopment) {
2213
2204
  let response;
2214
2205
  const authServerUrl = typeof window !== "undefined" ? process.env.NEXT_PUBLIC_MOONUI_AUTH_SERVER || "http://localhost:7878" : "http://localhost:7878";
@@ -2249,7 +2240,6 @@ function MoonUIAuthProvider({ children }) {
2249
2240
  }
2250
2241
  }
2251
2242
  if (isProduction) {
2252
- const licenseKey = environmentInfo.hasLicenseKey ? process.env.NEXT_PUBLIC_MOONUI_LICENSE_KEY || process.env.MOONUI_LICENSE_KEY || process.env.VITE_MOONUI_LICENSE_KEY || process.env.REACT_APP_MOONUI_LICENSE_KEY || "check-server" : null;
2253
2243
  if (licenseKey) {
2254
2244
  console.log("[MoonUI Auth] Production mode - validating license key...");
2255
2245
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.37.15",
3
+ "version": "2.37.16",
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",