@umituz/react-native-ai-generation-content 1.83.62 → 1.83.64

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-generation-content",
3
- "version": "1.83.62",
3
+ "version": "1.83.64",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * AI Feature Gate Hook
3
- * Handles: Auth → Credits → Paywall → Execute
3
+ * Handles: Offline → Auth → Credits → Paywall → Execute
4
+ *
5
+ * Uses `hasFirebaseUser` for auth check — anonymous users (autoAnonymousSignIn)
6
+ * pass the gate and go straight to credit/subscription checks.
7
+ * Auth modal is only shown if there is NO Firebase user at all.
4
8
  */
5
9
 
6
10
  import { useCallback, useMemo } from "react";
@@ -17,33 +21,20 @@ import type {
17
21
  AIFeatureGateReturn,
18
22
  } from "../types/access-control.types";
19
23
 
24
+ declare const __DEV__: boolean;
20
25
 
21
26
  const handlePromiseResult = (
22
27
  result: void | Promise<void>,
23
28
  onSuccess?: () => void,
24
29
  onError?: (error: Error) => void,
25
30
  ): void => {
26
- if (typeof __DEV__ !== "undefined" && __DEV__) {
27
- console.log("[AIFeatureGate] handlePromiseResult - isPromise:", result instanceof Promise);
28
- }
29
31
  if (result instanceof Promise) {
30
32
  result
31
- .then(() => {
32
- if (typeof __DEV__ !== "undefined" && __DEV__) {
33
- console.log("[AIFeatureGate] Promise resolved, calling onSuccess");
34
- }
35
- onSuccess?.();
36
- })
33
+ .then(() => onSuccess?.())
37
34
  .catch((err) => {
38
- if (typeof __DEV__ !== "undefined" && __DEV__) {
39
- console.log("[AIFeatureGate] Promise rejected:", err);
40
- }
41
35
  onError?.(err instanceof Error ? err : new Error(String(err)));
42
36
  });
43
37
  } else {
44
- if (typeof __DEV__ !== "undefined" && __DEV__) {
45
- console.log("[AIFeatureGate] Sync result, calling onSuccess");
46
- }
47
38
  onSuccess?.();
48
39
  }
49
40
  };
@@ -77,8 +68,8 @@ export function useAIFeatureGate(options: AIFeatureGateOptions): AIFeatureGateRe
77
68
 
78
69
  const requireFeature = useCallback(
79
70
  (action: () => void | Promise<void>): boolean => {
80
- if (typeof __DEV__ !== "undefined" && __DEV__) {
81
- console.log("[AIFeatureGate] requireFeature called:", {
71
+ if (__DEV__) {
72
+ console.log("[AIFeatureGate] requireFeature:", {
82
73
  isOffline,
83
74
  hasFirebaseUser,
84
75
  isCreditsLoaded,
@@ -90,7 +81,7 @@ export function useAIFeatureGate(options: AIFeatureGateOptions): AIFeatureGateRe
90
81
  }
91
82
 
92
83
  if (isOffline) {
93
- if (typeof __DEV__ !== "undefined" && __DEV__) {
84
+ if (__DEV__) {
94
85
  console.log("[AIFeatureGate] BLOCKED: User is offline");
95
86
  }
96
87
  onNetworkError?.();
@@ -98,26 +89,19 @@ export function useAIFeatureGate(options: AIFeatureGateOptions): AIFeatureGateRe
98
89
  }
99
90
 
100
91
  if (hasFirebaseUser && !isCreditsLoaded && isCreditsLoading) {
101
- if (typeof __DEV__ !== "undefined" && __DEV__) {
92
+ if (__DEV__) {
102
93
  console.log("[AIFeatureGate] WAITING: Credits still loading");
103
94
  }
104
95
  return false;
105
96
  }
106
97
 
107
- if (typeof __DEV__ !== "undefined" && __DEV__) {
108
- console.log("[AIFeatureGate] Calling requireFeatureFromPackage");
109
- }
110
-
111
98
  const executed = requireFeatureFromPackage(() => {
112
- if (typeof __DEV__ !== "undefined" && __DEV__) {
113
- console.log("[AIFeatureGate] Inside requireFeatureFromPackage callback - executing action");
114
- }
115
99
  handlePromiseResult(action(), onSuccess, onError);
116
100
  });
117
101
 
118
102
  return executed;
119
103
  },
120
- [isOffline, hasFirebaseUser, isCreditsLoaded, isPremium, creditBalance, creditCost, hasCredits, onNetworkError, requireFeatureFromPackage, onSuccess, onError],
104
+ [isOffline, hasFirebaseUser, isCreditsLoaded, isCreditsLoading, isPremium, creditBalance, creditCost, hasCredits, onNetworkError, requireFeatureFromPackage, onSuccess, onError],
121
105
  );
122
106
 
123
107
  return {
@@ -125,7 +109,7 @@ export function useAIFeatureGate(options: AIFeatureGateOptions): AIFeatureGateRe
125
109
  canAccess,
126
110
  isCheckingAccess: isCreditsLoading,
127
111
  hasCredits,
128
- isAuthenticated: hasFirebaseUser,
112
+ hasFirebaseUser,
129
113
  isPremium,
130
114
  creditBalance,
131
115
  isOffline,
@@ -54,9 +54,9 @@ export interface AIFeatureGateReturn {
54
54
  hasCredits: boolean;
55
55
 
56
56
  /**
57
- * Whether user is authenticated (not anonymous)
57
+ * Whether user has a Firebase account (including anonymous users via autoAnonymousSignIn)
58
58
  */
59
- isAuthenticated: boolean;
59
+ hasFirebaseUser: boolean;
60
60
 
61
61
  /**
62
62
  * Whether user has premium subscription