@umituz/react-native-ai-generation-content 1.17.95 → 1.17.97

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.17.95",
3
+ "version": "1.17.97",
4
4
  "description": "Provider-agnostic AI generation orchestration for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -12,3 +12,8 @@ export {
12
12
  OUTPUT_FORMAT_VALUES,
13
13
  DEFAULT_FORM_VALUES,
14
14
  } from "./options.constants";
15
+
16
+ export {
17
+ DEFAULT_TEXT_TO_IMAGE_PROMPTS,
18
+ type ExamplePrompt,
19
+ } from "./prompts.constants";
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Text-to-Image Example Prompts
3
+ * @description Default prompt suggestions for text-to-image generation
4
+ * @note NEVER use emojis in prompts - Imagen API only supports English text
5
+ */
6
+
7
+ export interface ExamplePrompt {
8
+ id: string;
9
+ text: string;
10
+ }
11
+
12
+ export const DEFAULT_TEXT_TO_IMAGE_PROMPTS: readonly ExamplePrompt[] = [
13
+ { id: "sunset", text: "A beautiful sunset over mountains with vibrant colors" },
14
+ { id: "cityscape", text: "Futuristic cityscape at night with neon lights" },
15
+ { id: "forest", text: "Enchanted forest with magical glowing mushrooms" },
16
+ { id: "coffee", text: "Cozy coffee shop interior on a rainy day" },
17
+ { id: "spaceship", text: "Spaceship traveling through colorful nebula" },
18
+ { id: "dragon", text: "Dragon flying over snow-capped mountain peaks" },
19
+ { id: "underwater", text: "Underwater coral reef with tropical fish" },
20
+ { id: "castle", text: "Medieval castle on a cliff during golden hour" },
21
+ ] as const;
@@ -52,6 +52,8 @@ export {
52
52
  IMAGE_SIZE_VALUES,
53
53
  OUTPUT_FORMAT_VALUES,
54
54
  DEFAULT_FORM_VALUES,
55
+ DEFAULT_TEXT_TO_IMAGE_PROMPTS,
56
+ type ExamplePrompt,
55
57
  } from "./domain";
56
58
 
57
59
  // =============================================================================
package/src/index.ts CHANGED
@@ -216,7 +216,6 @@ export type {
216
216
  // Feature utils types
217
217
  ImageSelector,
218
218
  VideoSaver,
219
- CreditChecker,
220
219
  AlertFunction,
221
220
  FeatureUtilsConfig,
222
221
  // Video helpers types
@@ -1,85 +1,74 @@
1
1
  /**
2
2
  * Feature Utilities
3
- * Generic utilities for AI generation features
4
- * App provides implementations via dependency injection
3
+ * Uses ONLY configured app services - no alternatives
5
4
  */
6
5
 
7
- /**
8
- * Image selector function type
9
- */
10
- export type ImageSelector = () => Promise<string | null>;
6
+ import { getAuthService, getCreditService, getPaywallService, isAppServicesConfigured } from "../config/app-services.config";
11
7
 
12
- /**
13
- * Video saver function type
14
- */
15
- export type VideoSaver = (uri: string) => Promise<void>;
8
+ declare const __DEV__: boolean;
16
9
 
17
- /**
18
- * Credit checker function type
19
- */
20
- export type CreditChecker = (cost: number, featureName: string, type: string) => Promise<boolean>;
21
-
22
- /**
23
- * Alert function type
24
- */
10
+ export type ImageSelector = () => Promise<string | null>;
11
+ export type VideoSaver = (uri: string) => Promise<void>;
25
12
  export type AlertFunction = (title: string, message: string) => void;
26
13
 
27
- /**
28
- * Feature utilities configuration
29
- */
30
14
  export interface FeatureUtilsConfig {
31
15
  selectImage: ImageSelector;
32
16
  saveVideo: VideoSaver;
33
- checkCredit: CreditChecker;
34
- showSuccessAlert?: AlertFunction;
35
- showErrorAlert?: AlertFunction;
36
17
  }
37
18
 
38
- /**
39
- * Prepare image from URI (generic passthrough)
40
- */
41
19
  export async function prepareImage(uri: string): Promise<string> {
42
20
  return uri;
43
21
  }
44
22
 
45
- /**
46
- * Create dev callbacks for logging
47
- */
48
23
  export function createDevCallbacks(featureName: string) {
49
24
  return {
50
25
  onSuccess: (result: unknown) => {
51
- if (typeof __DEV__ !== "undefined" && __DEV__) {
52
- // eslint-disable-next-line no-console
53
- console.log(`[${featureName}] Success:`, result);
54
- }
26
+ if (__DEV__) console.log(`[${featureName}] Success:`, result);
55
27
  },
56
28
  onError: (error: unknown) => {
57
- if (typeof __DEV__ !== "undefined" && __DEV__) {
58
- // eslint-disable-next-line no-console
59
- console.error(`[${featureName}] Error:`, error);
60
- }
29
+ if (__DEV__) console.error(`[${featureName}] Error:`, error);
61
30
  },
62
31
  };
63
32
  }
64
33
 
65
34
  /**
66
- * Create feature utils with injected dependencies
35
+ * Credit guard - ONLY uses configured app services
67
36
  */
37
+ async function checkCreditGuard(cost: number, featureName: string): Promise<boolean> {
38
+ if (!isAppServicesConfigured()) {
39
+ throw new Error(`[${featureName}] App services not configured. Call configureAppServices() at startup.`);
40
+ }
41
+
42
+ const authService = getAuthService();
43
+ const creditService = getCreditService();
44
+ const paywallService = getPaywallService();
45
+
46
+ if (!authService.isAuthenticated()) {
47
+ if (__DEV__) console.log(`[${featureName}] Auth required`);
48
+ try {
49
+ authService.requireAuth();
50
+ } catch {
51
+ return false;
52
+ }
53
+ return false;
54
+ }
55
+
56
+ const hasCredits = await creditService.checkCredits(cost);
57
+ if (!hasCredits) {
58
+ if (__DEV__) console.log(`[${featureName}] Insufficient credits`);
59
+ paywallService.showPaywall(cost);
60
+ return false;
61
+ }
62
+
63
+ return true;
64
+ }
65
+
68
66
  export function createFeatureUtils(config: FeatureUtilsConfig) {
69
67
  return {
70
68
  selectImage: config.selectImage,
71
69
  saveVideo: config.saveVideo,
72
- checkCreditGuard: config.checkCredit,
70
+ checkCreditGuard,
73
71
  prepareImage,
74
72
  createDevCallbacks,
75
73
  };
76
74
  }
77
-
78
- /**
79
- * Hook factory for feature utilities
80
- */
81
- export function createUseFeatureUtils(config: FeatureUtilsConfig) {
82
- return function useFeatureUtils() {
83
- return createFeatureUtils(config);
84
- };
85
- }