@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 +1 -1
- package/src/features/text-to-image/domain/constants/index.ts +5 -0
- package/src/features/text-to-image/domain/constants/prompts.constants.ts +21 -0
- package/src/features/text-to-image/index.ts +2 -0
- package/src/index.ts +0 -1
- package/src/infrastructure/utils/feature-utils.ts +38 -49
package/package.json
CHANGED
|
@@ -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;
|
package/src/index.ts
CHANGED
|
@@ -1,85 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Feature Utilities
|
|
3
|
-
*
|
|
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
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
*
|
|
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
|
|
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
|
-
}
|