@moontra/moonui-pro 2.21.1 → 2.21.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +91 -11
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -12620,19 +12620,99 @@ var NavigationMenuIndicator2 = React67.forwardRef(({ className, ...props }, ref)
12620
12620
  }
12621
12621
  ));
12622
12622
  NavigationMenuIndicator2.displayName = Indicator3.displayName;
12623
-
12624
- // src/hooks/use-subscription.ts
12623
+ var CACHE_KEY = "moonui_license_cache";
12624
+ var CACHE_DURATION = 24 * 60 * 60 * 1e3;
12625
+ var OFFLINE_GRACE_PERIOD = 7 * 24 * 60 * 60 * 1e3;
12625
12626
  function useSubscription() {
12627
+ const [isLoading, setIsLoading] = useState(true);
12628
+ const [hasProAccess, setHasProAccess] = useState(true);
12629
+ const [isAuthenticated, setIsAuthenticated] = useState(true);
12630
+ useEffect(() => {
12631
+ const checkLicense = async () => {
12632
+ try {
12633
+ const cached = localStorage.getItem(CACHE_KEY);
12634
+ if (cached) {
12635
+ const cacheData = JSON.parse(cached);
12636
+ const now = Date.now();
12637
+ if (now - cacheData.timestamp < CACHE_DURATION) {
12638
+ setHasProAccess(cacheData.valid && cacheData.hasLifetimeAccess);
12639
+ setIsAuthenticated(cacheData.valid);
12640
+ setIsLoading(false);
12641
+ return;
12642
+ }
12643
+ if (now - cacheData.timestamp < OFFLINE_GRACE_PERIOD) {
12644
+ validateLicense().catch(() => {
12645
+ setHasProAccess(cacheData.valid && cacheData.hasLifetimeAccess);
12646
+ setIsAuthenticated(cacheData.valid);
12647
+ });
12648
+ setIsLoading(false);
12649
+ return;
12650
+ }
12651
+ }
12652
+ await validateLicense();
12653
+ } catch (error) {
12654
+ console.error("License check error:", error);
12655
+ setHasProAccess(true);
12656
+ setIsAuthenticated(true);
12657
+ } finally {
12658
+ setIsLoading(false);
12659
+ }
12660
+ };
12661
+ checkLicense();
12662
+ }, []);
12663
+ const validateLicense = async () => {
12664
+ const token = process.env.NEXT_PUBLIC_MOONUI_AUTH_TOKEN || localStorage.getItem("moonui_auth_token");
12665
+ if (!token) {
12666
+ setHasProAccess(true);
12667
+ setIsAuthenticated(true);
12668
+ return;
12669
+ }
12670
+ try {
12671
+ const response = await fetch("https://moonui.dev/api/auth/validate", {
12672
+ headers: {
12673
+ "Authorization": `Bearer ${token}`
12674
+ }
12675
+ });
12676
+ if (response.ok) {
12677
+ const data = await response.json();
12678
+ const cacheData = {
12679
+ valid: data.valid,
12680
+ hasLifetimeAccess: data.user?.hasLifetimeAccess || false,
12681
+ timestamp: Date.now(),
12682
+ cacheUntil: data.cacheUntil ? new Date(data.cacheUntil).getTime() : void 0
12683
+ };
12684
+ localStorage.setItem(CACHE_KEY, JSON.stringify(cacheData));
12685
+ setHasProAccess(data.valid && (data.user?.hasLifetimeAccess || data.user?.features?.includes("pro_components")));
12686
+ setIsAuthenticated(data.valid);
12687
+ } else {
12688
+ localStorage.removeItem(CACHE_KEY);
12689
+ setHasProAccess(false);
12690
+ setIsAuthenticated(false);
12691
+ }
12692
+ } catch (error) {
12693
+ const cached = localStorage.getItem(CACHE_KEY);
12694
+ if (cached) {
12695
+ const cacheData = JSON.parse(cached);
12696
+ const now = Date.now();
12697
+ if (now - cacheData.timestamp < OFFLINE_GRACE_PERIOD) {
12698
+ setHasProAccess(cacheData.valid && cacheData.hasLifetimeAccess);
12699
+ setIsAuthenticated(cacheData.valid);
12700
+ return;
12701
+ }
12702
+ }
12703
+ setHasProAccess(false);
12704
+ setIsAuthenticated(false);
12705
+ }
12706
+ };
12626
12707
  return {
12627
- isLoading: false,
12628
- isAuthenticated: true,
12708
+ isLoading,
12709
+ isAuthenticated,
12629
12710
  isAdmin: false,
12630
- hasProAccess: true,
12631
- // Pro package kullanıcıları varsayılan olarak pro erişime sahip
12632
- subscriptionPlan: "pro",
12711
+ hasProAccess,
12712
+ subscriptionPlan: hasProAccess ? "lifetime" : "free",
12633
12713
  subscription: {
12634
- status: "active",
12635
- plan: "pro"
12714
+ status: hasProAccess ? "active" : "inactive",
12715
+ plan: hasProAccess ? "lifetime" : "free"
12636
12716
  }
12637
12717
  };
12638
12718
  }
@@ -35530,7 +35610,7 @@ function markPasteRule(config) {
35530
35610
  }
35531
35611
 
35532
35612
  // ../../node_modules/@tiptap/react/dist/index.js
35533
- var import_react23 = __toESM(require_react(), 1);
35613
+ var import_react24 = __toESM(require_react(), 1);
35534
35614
  var mergeRefs = (...refs) => {
35535
35615
  return (node) => {
35536
35616
  refs.forEach((ref) => {
@@ -35749,7 +35829,7 @@ function useEditorState(options) {
35749
35829
  editorStateManager.getSnapshot,
35750
35830
  editorStateManager.getServerSnapshot,
35751
35831
  options.selector,
35752
- (_a2 = options.equalityFn) != null ? _a2 : import_react23.default
35832
+ (_a2 = options.equalityFn) != null ? _a2 : import_react24.default
35753
35833
  );
35754
35834
  useIsomorphicLayoutEffect(() => {
35755
35835
  return editorStateManager.watch(options.editor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.21.1",
3
+ "version": "2.21.2",
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",