@moontra/moonui 2.2.7 → 2.3.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/index.d.mts CHANGED
@@ -919,8 +919,9 @@ interface ProComponentWrapperProps {
919
919
  componentName?: string;
920
920
  className?: string;
921
921
  fallback?: React__default.ReactNode;
922
+ requireCLI?: boolean;
922
923
  }
923
- declare function ProComponentWrapper({ children, componentId, componentName, className, fallback }: ProComponentWrapperProps): react_jsx_runtime.JSX.Element;
924
+ declare function ProComponentWrapper({ children, componentId, componentName, className, fallback, requireCLI }: ProComponentWrapperProps): react_jsx_runtime.JSX.Element;
924
925
  declare function ProBadge({ className }: {
925
926
  className?: string;
926
927
  }): react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -919,8 +919,9 @@ interface ProComponentWrapperProps {
919
919
  componentName?: string;
920
920
  className?: string;
921
921
  fallback?: React__default.ReactNode;
922
+ requireCLI?: boolean;
922
923
  }
923
- declare function ProComponentWrapper({ children, componentId, componentName, className, fallback }: ProComponentWrapperProps): react_jsx_runtime.JSX.Element;
924
+ declare function ProComponentWrapper({ children, componentId, componentName, className, fallback, requireCLI }: ProComponentWrapperProps): react_jsx_runtime.JSX.Element;
924
925
  declare function ProBadge({ className }: {
925
926
  className?: string;
926
927
  }): react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -9654,11 +9654,159 @@ function ProComponentWrapper({
9654
9654
  componentId,
9655
9655
  componentName,
9656
9656
  className,
9657
- fallback
9657
+ fallback,
9658
+ requireCLI = true
9658
9659
  }) {
9659
- {
9660
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children });
9660
+ const [authState, setAuthState] = t.useState({
9661
+ isAuthenticated: false,
9662
+ deviceValid: false,
9663
+ hasProAccess: false,
9664
+ loading: true
9665
+ });
9666
+ t.useEffect(() => {
9667
+ const isDevelopment2 = () => {
9668
+ const checks = {
9669
+ nodeEnv: process.env.NODE_ENV === "development",
9670
+ nextPublicEnv: process.env.NEXT_PUBLIC_VERCEL_ENV === "development",
9671
+ localhost: typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")),
9672
+ port: typeof window !== "undefined" && (window.location.port === "3000" || window.location.port === "3001" || window.location.port === "8080"),
9673
+ vercelEnv: !process.env.VERCEL,
9674
+ ciEnv: !process.env.CI,
9675
+ deploymentEnv: !process.env.DEPLOYMENT_ENV
9676
+ };
9677
+ if (process.env.VERCEL || process.env.NETLIFY || process.env.RENDER || process.env.RAILWAY_ENVIRONMENT || process.env.FLY_APP_NAME || process.env.DEPLOYMENT_ENV === "production") {
9678
+ return false;
9679
+ }
9680
+ return checks.nodeEnv && checks.localhost && !checks.vercelEnv && !checks.ciEnv;
9681
+ };
9682
+ if (!isDevelopment2() || !requireCLI) {
9683
+ setAuthState({
9684
+ isAuthenticated: true,
9685
+ deviceValid: true,
9686
+ hasProAccess: true,
9687
+ loading: false
9688
+ });
9689
+ return;
9690
+ }
9691
+ async function checkAuth() {
9692
+ try {
9693
+ const cliToken = localStorage.getItem("moonui_cli_token");
9694
+ const deviceId = localStorage.getItem("moonui_device_id");
9695
+ if (!cliToken || !deviceId) {
9696
+ setAuthState({
9697
+ isAuthenticated: false,
9698
+ deviceValid: false,
9699
+ hasProAccess: false,
9700
+ loading: false
9701
+ });
9702
+ return;
9703
+ }
9704
+ const response = await fetch("/api/device/validate", {
9705
+ method: "POST",
9706
+ headers: {
9707
+ "Authorization": `Bearer ${cliToken}`,
9708
+ "X-Device-ID": deviceId,
9709
+ "Content-Type": "application/json"
9710
+ },
9711
+ body: JSON.stringify({
9712
+ environment: {
9713
+ nodeEnv: process.env.NODE_ENV,
9714
+ hostname: window.location.hostname,
9715
+ port: window.location.port,
9716
+ protocol: window.location.protocol
9717
+ }
9718
+ })
9719
+ });
9720
+ if (response.ok) {
9721
+ const data = await response.json();
9722
+ setAuthState({
9723
+ isAuthenticated: true,
9724
+ deviceValid: data.valid,
9725
+ hasProAccess: data.hasProAccess,
9726
+ loading: false
9727
+ });
9728
+ } else {
9729
+ setAuthState({
9730
+ isAuthenticated: false,
9731
+ deviceValid: false,
9732
+ hasProAccess: false,
9733
+ loading: false
9734
+ });
9735
+ }
9736
+ } catch (error) {
9737
+ setAuthState({
9738
+ isAuthenticated: false,
9739
+ deviceValid: false,
9740
+ hasProAccess: false,
9741
+ loading: false
9742
+ });
9743
+ }
9744
+ }
9745
+ checkAuth();
9746
+ }, [requireCLI]);
9747
+ if (authState.loading) {
9748
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("animate-pulse bg-gray-200 dark:bg-gray-800 rounded-lg h-32", className), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-500", children: "Loading..." }) }) });
9749
+ }
9750
+ const isDevelopment = () => {
9751
+ const checks = {
9752
+ nodeEnv: process.env.NODE_ENV === "development",
9753
+ localhost: typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes(".local")),
9754
+ port: typeof window !== "undefined" && (window.location.port === "3000" || window.location.port === "3001" || window.location.port === "8080")
9755
+ };
9756
+ if (process.env.VERCEL || process.env.NETLIFY || process.env.RENDER || process.env.RAILWAY_ENVIRONMENT || process.env.FLY_APP_NAME) {
9757
+ return false;
9758
+ }
9759
+ return checks.nodeEnv && checks.localhost;
9760
+ };
9761
+ if (isDevelopment() && requireCLI) {
9762
+ if (!authState.isAuthenticated) {
9763
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative", className), children: [
9764
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "blur-sm grayscale-[0.3] opacity-60 pointer-events-none", children: fallback || children }),
9765
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-red-500/10 via-transparent to-orange-500/10 border-2 border-dashed border-red-400/30 rounded-lg flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-3 p-6", children: [
9766
+ /* @__PURE__ */ jsxRuntime.jsxs(Badge, { variant: "destructive", className: "mb-2", children: [
9767
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "w-3 h-3 mr-1" }),
9768
+ "CLI AUTH REQUIRED"
9769
+ ] }),
9770
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-gray-900 dark:text-gray-100", children: "CLI Authentication Required" }),
9771
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400 max-w-xs", children: "Run the following command to authenticate:" }),
9772
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "block bg-black/80 text-green-400 p-2 rounded text-xs", children: "npx moonui auth login" })
9773
+ ] }) })
9774
+ ] });
9775
+ }
9776
+ if (!authState.deviceValid) {
9777
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative", className), children: [
9778
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "blur-sm grayscale-[0.3] opacity-60 pointer-events-none", children: fallback || children }),
9779
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-yellow-500/10 via-transparent to-orange-500/10 border-2 border-dashed border-yellow-400/30 rounded-lg flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-3 p-6", children: [
9780
+ /* @__PURE__ */ jsxRuntime.jsxs(Badge, { variant: "secondary", className: "bg-yellow-500 text-white mb-2", children: [
9781
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Zap, { className: "w-3 h-3 mr-1" }),
9782
+ "DEVICE LIMIT"
9783
+ ] }),
9784
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-gray-900 dark:text-gray-100", children: "Device Limit Exceeded" }),
9785
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400 max-w-xs", children: "This device is not registered or you've reached your device limit" }),
9786
+ /* @__PURE__ */ jsxRuntime.jsx(
9787
+ Button,
9788
+ {
9789
+ size: "sm",
9790
+ className: "bg-gradient-to-r from-yellow-500 to-orange-500",
9791
+ onClick: () => window.open("/dashboard/devices", "_blank"),
9792
+ children: "Manage Devices"
9793
+ }
9794
+ )
9795
+ ] }) })
9796
+ ] });
9797
+ }
9798
+ if (!authState.hasProAccess) {
9799
+ return /* @__PURE__ */ jsxRuntime.jsx(
9800
+ LockedComponent,
9801
+ {
9802
+ componentName: componentName || componentId,
9803
+ className,
9804
+ children: fallback || children
9805
+ }
9806
+ );
9807
+ }
9661
9808
  }
9809
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children });
9662
9810
  }
9663
9811
  function ProBadge({ className }) {
9664
9812
  return /* @__PURE__ */ jsxRuntime.jsxs(