@umituz/react-native-ai-generation-content 1.11.5 → 1.12.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/package.json +1 -1
- package/src/index.ts +3 -3
- package/src/infrastructure/wrappers/index.ts +5 -5
- package/src/infrastructure/wrappers/{simple-generation.wrapper.ts → synchronous-generation.wrapper.ts} +8 -7
- package/src/presentation/components/GenerationProgressBar.tsx +3 -3
- package/src/presentation/components/GenerationProgressContent.tsx +8 -8
- package/src/presentation/components/PendingJobCard.tsx +7 -7
- package/src/presentation/components/PendingJobCardActions.tsx +4 -4
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -149,14 +149,14 @@ export {
|
|
|
149
149
|
getSupportedLanguages,
|
|
150
150
|
getLanguageName,
|
|
151
151
|
ModerationWrapper,
|
|
152
|
-
|
|
152
|
+
generateSynchronously,
|
|
153
153
|
} from "./infrastructure/wrappers";
|
|
154
154
|
|
|
155
155
|
export type {
|
|
156
156
|
ModerationResult,
|
|
157
157
|
ModerationConfig,
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
SynchronousGenerationInput,
|
|
159
|
+
SynchronousGenerationConfig,
|
|
160
160
|
} from "./infrastructure/wrappers";
|
|
161
161
|
|
|
162
162
|
// =============================================================================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generation Wrappers
|
|
3
|
-
* High-level API wrappers for
|
|
3
|
+
* High-level API wrappers for generation orchestration
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export {
|
|
@@ -12,8 +12,8 @@ export {
|
|
|
12
12
|
export { ModerationWrapper } from "./moderation.wrapper";
|
|
13
13
|
export type { ModerationResult, ModerationConfig } from "./moderation.wrapper";
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { generateSynchronously } from "./synchronous-generation.wrapper";
|
|
16
16
|
export type {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from "./
|
|
17
|
+
SynchronousGenerationInput,
|
|
18
|
+
SynchronousGenerationConfig,
|
|
19
|
+
} from "./synchronous-generation.wrapper";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Synchronous Generation Wrapper
|
|
3
|
+
* Direct API execution for text/image generation (wait for result)
|
|
4
|
+
* For background job execution, use async generation instead
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
7
|
import type { GenerationResult } from "../../domain/entities";
|
|
7
8
|
import { enhancePromptWithLanguage } from "./language.wrapper";
|
|
8
9
|
import { ModerationWrapper } from "./moderation.wrapper";
|
|
9
10
|
|
|
10
|
-
export interface
|
|
11
|
+
export interface SynchronousGenerationInput {
|
|
11
12
|
prompt: string;
|
|
12
13
|
userId?: string;
|
|
13
14
|
type?: string;
|
|
@@ -15,15 +16,15 @@ export interface SimpleGenerationInput {
|
|
|
15
16
|
metadata?: Record<string, any>;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export interface
|
|
19
|
+
export interface SynchronousGenerationConfig<T = any> {
|
|
19
20
|
checkCredits?: (userId: string, type: string) => Promise<boolean>;
|
|
20
21
|
deductCredits?: (userId: string, type: string) => Promise<void>;
|
|
21
22
|
execute: (prompt: string, metadata?: Record<string, any>) => Promise<T>;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export async function
|
|
25
|
-
input:
|
|
26
|
-
config:
|
|
25
|
+
export async function generateSynchronously<T = string>(
|
|
26
|
+
input: SynchronousGenerationInput,
|
|
27
|
+
config: SynchronousGenerationConfig<T>,
|
|
27
28
|
): Promise<GenerationResult<T>> {
|
|
28
29
|
// Check user ID if required
|
|
29
30
|
if (config.checkCredits && !input.userId) {
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import { View, StyleSheet
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
7
|
+
import { AtomicText, View, StyleSheet } from "react-native";
|
|
8
|
+
import { AtomicText, useAppDesignTokens } AtomicText } from "@umituz/react-native-design-system";
|
|
9
9
|
|
|
10
10
|
export interface GenerationProgressBarProps {
|
|
11
11
|
progress: number;
|
|
@@ -48,7 +48,7 @@ export const GenerationProgressBar: React.FC<GenerationProgressBarProps> = ({
|
|
|
48
48
|
]}
|
|
49
49
|
>
|
|
50
50
|
{Math.round(clampedProgress)}%
|
|
51
|
-
</
|
|
51
|
+
</AtomicText>
|
|
52
52
|
</View>
|
|
53
53
|
);
|
|
54
54
|
};
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
9
|
-
import { GenerationProgressBar } from "./GenerationProgressBar";
|
|
7
|
+
import { AtomicText, View, TouchableOpacity, StyleSheet } from "react-native";
|
|
8
|
+
import { AtomicText, useAppDesignTokens } AtomicText } from "@umituz/react-native-design-system";
|
|
9
|
+
import { AtomicText, GenerationProgressBar } from "./GenerationProgressBar";
|
|
10
10
|
|
|
11
11
|
export interface GenerationProgressContentProps {
|
|
12
12
|
progress: number;
|
|
@@ -45,13 +45,13 @@ export const GenerationProgressContent: React.FC<
|
|
|
45
45
|
return (
|
|
46
46
|
<View style={[styles.modal, { backgroundColor: activeBgColor }]}>
|
|
47
47
|
{title && (
|
|
48
|
-
<
|
|
48
|
+
<AtomicText type="bodyMedium" style={[styles.title, { color: activeTextColor }]}>{title}</AtomicText>
|
|
49
49
|
)}
|
|
50
50
|
|
|
51
51
|
{message && (
|
|
52
|
-
<
|
|
52
|
+
<AtomicText type="bodyMedium" style={[styles.message, { color: activeTextColor }]}>
|
|
53
53
|
{message}
|
|
54
|
-
</
|
|
54
|
+
</AtomicText>
|
|
55
55
|
)}
|
|
56
56
|
|
|
57
57
|
<GenerationProgressBar
|
|
@@ -62,7 +62,7 @@ export const GenerationProgressContent: React.FC<
|
|
|
62
62
|
/>
|
|
63
63
|
|
|
64
64
|
{hint && (
|
|
65
|
-
<
|
|
65
|
+
<AtomicText type="bodyMedium" style={[styles.hint, { color: activeTextColor }]}>{hint}</AtomicText>
|
|
66
66
|
)}
|
|
67
67
|
|
|
68
68
|
{onDismiss && (
|
|
@@ -73,7 +73,7 @@ export const GenerationProgressContent: React.FC<
|
|
|
73
73
|
]}
|
|
74
74
|
onPress={onDismiss}
|
|
75
75
|
>
|
|
76
|
-
<
|
|
76
|
+
<AtomicText type="bodyMedium" style={styles.dismissText}>{dismissLabel || "OK"}</AtomicText>
|
|
77
77
|
</TouchableOpacity>
|
|
78
78
|
)}
|
|
79
79
|
</View>
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
7
|
+
import { AtomicText, View, ActivityIndicator, StyleSheet } from "react-native";
|
|
8
|
+
import { AtomicText, useAppDesignTokens } AtomicText } from "@umituz/react-native-design-system";
|
|
9
9
|
import type { BackgroundJob } from "../../domain/entities/job.types";
|
|
10
|
-
import { PendingJobProgressBar } from "./PendingJobProgressBar";
|
|
11
|
-
import { PendingJobCardActions } from "./PendingJobCardActions";
|
|
10
|
+
import { AtomicText, PendingJobProgressBar } from "./PendingJobProgressBar";
|
|
11
|
+
import { AtomicText, PendingJobCardActions } from "./PendingJobCardActions";
|
|
12
12
|
|
|
13
13
|
export interface StatusLabels {
|
|
14
14
|
readonly queued?: string;
|
|
@@ -106,10 +106,10 @@ export function PendingJobCard<TInput = unknown, TResult = unknown>({
|
|
|
106
106
|
)}
|
|
107
107
|
<View style={styles.content}>
|
|
108
108
|
<View>
|
|
109
|
-
{typeLabel && <
|
|
110
|
-
<
|
|
109
|
+
{typeLabel && <AtomicText type="bodyMedium" style={styles.typeText}>{typeLabel}</AtomicText>}
|
|
110
|
+
<AtomicText type="bodyMedium" style={styles.statusText} numberOfLines={1}>
|
|
111
111
|
{statusText}
|
|
112
|
-
</
|
|
112
|
+
</AtomicText>
|
|
113
113
|
{!isFailed && <PendingJobProgressBar progress={job.progress} />}
|
|
114
114
|
</View>
|
|
115
115
|
{renderActions ? (
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import React from "react";
|
|
7
|
-
import { View, TouchableOpacity,
|
|
8
|
-
import { useAppDesignTokens } from "@umituz/react-native-design-system";
|
|
7
|
+
import { AtomicText, View, TouchableOpacity, StyleSheet } from "react-native";
|
|
8
|
+
import { AtomicText, useAppDesignTokens } AtomicText } from "@umituz/react-native-design-system";
|
|
9
9
|
|
|
10
10
|
export interface PendingJobCardActionsProps {
|
|
11
11
|
id: string;
|
|
@@ -57,7 +57,7 @@ export const PendingJobCardActions: React.FC<PendingJobCardActionsProps> = ({
|
|
|
57
57
|
style={styles.actionButton}
|
|
58
58
|
onPress={() => onRetry(id)}
|
|
59
59
|
>
|
|
60
|
-
<
|
|
60
|
+
<AtomicText type="bodyMedium" style={styles.text}>↻</AtomicText>
|
|
61
61
|
</TouchableOpacity>
|
|
62
62
|
)}
|
|
63
63
|
{onCancel && (
|
|
@@ -65,7 +65,7 @@ export const PendingJobCardActions: React.FC<PendingJobCardActionsProps> = ({
|
|
|
65
65
|
style={styles.actionButton}
|
|
66
66
|
onPress={() => onCancel(id)}
|
|
67
67
|
>
|
|
68
|
-
<
|
|
68
|
+
<AtomicText type="bodyMedium" style={styles.errorText}>✕</AtomicText>
|
|
69
69
|
</TouchableOpacity>
|
|
70
70
|
)}
|
|
71
71
|
</View>
|