@umituz/react-native-ai-generation-content 1.35.7 → 1.35.9
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/domains/creations/presentation/components/CreationCard.tsx +1 -1
- package/src/domains/creations/presentation/screens/CreationsGalleryScreen.tsx +20 -44
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +2 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +2 -1
- package/src/domains/generation/wizard/infrastructure/strategies/wizard-strategy.factory.ts +4 -5
- package/src/domains/generation/wizard/presentation/hooks/useWizardGeneration.ts +10 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.9",
|
|
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",
|
|
@@ -119,7 +119,7 @@ export function CreationCard({
|
|
|
119
119
|
<View style={styles.previewContainer} pointerEvents="box-none">
|
|
120
120
|
<CreationPreview
|
|
121
121
|
uri={previewUrl}
|
|
122
|
-
status={creation.status
|
|
122
|
+
status={creation.status}
|
|
123
123
|
type={creation.type as CreationTypeId}
|
|
124
124
|
/>
|
|
125
125
|
{showBadges && creation.status && (
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { useCreations } from "../hooks/useCreations";
|
|
14
14
|
import { useDeleteCreation } from "../hooks/useDeleteCreation";
|
|
15
15
|
import { useGalleryFilters } from "../hooks/useGalleryFilters";
|
|
16
|
-
import { GalleryHeader, CreationCard, GalleryEmptyStates
|
|
16
|
+
import { GalleryHeader, CreationCard, GalleryEmptyStates } from "../components";
|
|
17
17
|
import { ResultPreviewScreen } from "../../../result-preview/presentation/components/ResultPreviewScreen";
|
|
18
18
|
import { StarRatingPicker } from "../../../result-preview/presentation/components/StarRatingPicker";
|
|
19
19
|
import { useResultActions } from "../../../result-preview/presentation/hooks/useResultActions";
|
|
@@ -33,10 +33,8 @@ interface CreationsGalleryScreenProps {
|
|
|
33
33
|
readonly onEmptyAction?: () => void;
|
|
34
34
|
readonly emptyActionLabel?: string;
|
|
35
35
|
readonly showFilter?: boolean;
|
|
36
|
-
/** Show pending generation jobs
|
|
36
|
+
/** Show pending generation jobs badge in header */
|
|
37
37
|
readonly showPendingJobs?: boolean;
|
|
38
|
-
/** Title for the pending jobs section */
|
|
39
|
-
readonly pendingJobsTitle?: string;
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
export function CreationsGalleryScreen({
|
|
@@ -49,7 +47,6 @@ export function CreationsGalleryScreen({
|
|
|
49
47
|
emptyActionLabel,
|
|
50
48
|
showFilter = config.showFilter ?? true,
|
|
51
49
|
showPendingJobs = true,
|
|
52
|
-
pendingJobsTitle,
|
|
53
50
|
}: CreationsGalleryScreenProps) {
|
|
54
51
|
const tokens = useAppDesignTokens();
|
|
55
52
|
const { share } = useSharing();
|
|
@@ -61,7 +58,7 @@ export function CreationsGalleryScreen({
|
|
|
61
58
|
const { data: creations, isLoading, refetch } = useCreations({ userId, repository });
|
|
62
59
|
|
|
63
60
|
// Background jobs for pending generations
|
|
64
|
-
const { jobs: pendingJobs
|
|
61
|
+
const { jobs: pendingJobs } = usePendingJobs();
|
|
65
62
|
|
|
66
63
|
// Auto-select creation when initialCreationId is provided
|
|
67
64
|
useEffect(() => {
|
|
@@ -190,51 +187,30 @@ export function CreationsGalleryScreen({
|
|
|
190
187
|
/>
|
|
191
188
|
), [handleShareCard, handleDelete, handleFavorite, handleCardPress, getScenarioTitle]);
|
|
192
189
|
|
|
193
|
-
//
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
completed: t("generator.status.completed"),
|
|
199
|
-
failed: t("generator.status.failed"),
|
|
200
|
-
}), [t]);
|
|
190
|
+
// Calculate active pending jobs count once
|
|
191
|
+
const activePendingCount = useMemo(() => {
|
|
192
|
+
if (!showPendingJobs) return 0;
|
|
193
|
+
return pendingJobs.filter((j) => j.status === "processing" || j.status === "queued").length;
|
|
194
|
+
}, [showPendingJobs, pendingJobs]);
|
|
201
195
|
|
|
202
196
|
const renderHeader = useMemo(() => {
|
|
203
|
-
const hasPendingJobs = showPendingJobs && pendingJobs.length > 0;
|
|
204
197
|
const hasCreations = creations && creations.length > 0;
|
|
205
|
-
|
|
206
|
-
if (!hasPendingJobs && !hasCreations && !isLoading) return null;
|
|
198
|
+
if (!hasCreations && !isLoading) return null;
|
|
207
199
|
|
|
208
200
|
return (
|
|
209
|
-
<View>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
)}
|
|
220
|
-
|
|
221
|
-
{/* Gallery Header */}
|
|
222
|
-
{hasCreations && (
|
|
223
|
-
<View style={[styles.header, { backgroundColor: tokens.colors.surface, borderBottomColor: tokens.colors.border }]}>
|
|
224
|
-
<GalleryHeader
|
|
225
|
-
title={t(config.translations.title)}
|
|
226
|
-
count={filters.filtered.length}
|
|
227
|
-
countLabel={t(config.translations.photoCount)}
|
|
228
|
-
showFilter={showFilter}
|
|
229
|
-
filterButtons={filterButtons}
|
|
230
|
-
pendingCount={pendingJobs.filter((j) => j.status === "processing" || j.status === "queued").length}
|
|
231
|
-
pendingLabel={t("creations.processing")}
|
|
232
|
-
/>
|
|
233
|
-
</View>
|
|
234
|
-
)}
|
|
201
|
+
<View style={[styles.header, { backgroundColor: tokens.colors.surface, borderBottomColor: tokens.colors.border }]}>
|
|
202
|
+
<GalleryHeader
|
|
203
|
+
title={t(config.translations.title)}
|
|
204
|
+
count={filters.filtered.length}
|
|
205
|
+
countLabel={t(config.translations.photoCount)}
|
|
206
|
+
showFilter={showFilter}
|
|
207
|
+
filterButtons={filterButtons}
|
|
208
|
+
pendingCount={activePendingCount}
|
|
209
|
+
pendingLabel={t("creations.processing")}
|
|
210
|
+
/>
|
|
235
211
|
</View>
|
|
236
212
|
);
|
|
237
|
-
}, [creations, isLoading, filters.filtered.length, showFilter, filterButtons, t, config, tokens,
|
|
213
|
+
}, [creations, isLoading, filters.filtered.length, showFilter, filterButtons, t, config, tokens, activePendingCount]);
|
|
238
214
|
|
|
239
215
|
const renderEmpty = useMemo(() => (
|
|
240
216
|
<GalleryEmptyStates
|
package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts
CHANGED
|
@@ -264,12 +264,13 @@ export function createImageStrategy(options: CreateImageStrategyOptions): Wizard
|
|
|
264
264
|
uri: imageResult.imageUrl,
|
|
265
265
|
type: scenario.id,
|
|
266
266
|
prompt: input.prompt,
|
|
267
|
+
status: "completed" as const,
|
|
267
268
|
createdAt: new Date(),
|
|
268
269
|
isShared: false,
|
|
269
270
|
isFavorite: false,
|
|
270
271
|
metadata: {
|
|
271
272
|
scenarioId: scenario.id,
|
|
272
|
-
scenarioTitle: scenario.title
|
|
273
|
+
scenarioTitle: scenario.title,
|
|
273
274
|
},
|
|
274
275
|
output: { imageUrl: imageResult.imageUrl },
|
|
275
276
|
};
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts
CHANGED
|
@@ -297,12 +297,13 @@ export function createVideoStrategy(options: CreateVideoStrategyOptions): Wizard
|
|
|
297
297
|
uri: videoResult.videoUrl,
|
|
298
298
|
type: scenario.id,
|
|
299
299
|
prompt: input.prompt,
|
|
300
|
+
status: "completed" as const,
|
|
300
301
|
createdAt: new Date(),
|
|
301
302
|
isShared: false,
|
|
302
303
|
isFavorite: false,
|
|
303
304
|
metadata: {
|
|
304
305
|
scenarioId: scenario.id,
|
|
305
|
-
scenarioTitle: scenario.title
|
|
306
|
+
scenarioTitle: scenario.title,
|
|
306
307
|
},
|
|
307
308
|
output: { videoUrl: videoResult.videoUrl },
|
|
308
309
|
};
|
|
@@ -27,12 +27,12 @@ export interface CreateWizardStrategyOptions {
|
|
|
27
27
|
|
|
28
28
|
export function createWizardStrategy(options: CreateWizardStrategyOptions): WizardStrategy {
|
|
29
29
|
const { scenario, collectionName } = options;
|
|
30
|
-
const outputType = scenario.outputType || "video";
|
|
31
30
|
|
|
32
|
-
if (outputType === "image") {
|
|
31
|
+
if (scenario.outputType === "image") {
|
|
33
32
|
return createImageStrategy({ scenario, collectionName });
|
|
34
33
|
}
|
|
35
34
|
|
|
35
|
+
// Default to video strategy for video outputType or undefined
|
|
36
36
|
return createVideoStrategy({ scenario, collectionName });
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -44,11 +44,10 @@ export async function buildWizardInput(
|
|
|
44
44
|
wizardData: Record<string, unknown>,
|
|
45
45
|
scenario: WizardScenarioData,
|
|
46
46
|
): Promise<unknown> {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (outputType === "image") {
|
|
47
|
+
if (scenario.outputType === "image") {
|
|
50
48
|
return buildImageInput(wizardData, scenario);
|
|
51
49
|
}
|
|
52
50
|
|
|
51
|
+
// Default to video input for video outputType or undefined
|
|
53
52
|
return buildVideoInput(wizardData, scenario);
|
|
54
53
|
}
|
|
@@ -30,7 +30,8 @@ export interface UseWizardGenerationProps {
|
|
|
30
30
|
readonly wizardData: Record<string, unknown>;
|
|
31
31
|
readonly userId?: string;
|
|
32
32
|
readonly isGeneratingStep: boolean;
|
|
33
|
-
|
|
33
|
+
/** Required - alert messages for error states */
|
|
34
|
+
readonly alertMessages: AlertMessages;
|
|
34
35
|
readonly onSuccess?: (result: unknown) => void;
|
|
35
36
|
readonly onError?: (error: string) => void;
|
|
36
37
|
readonly onCreditsExhausted?: () => void;
|
|
@@ -40,8 +41,6 @@ export interface UseWizardGenerationProps {
|
|
|
40
41
|
|
|
41
42
|
export interface UseWizardGenerationReturn {
|
|
42
43
|
readonly isGenerating: boolean;
|
|
43
|
-
/** Current job ID if tracking is enabled */
|
|
44
|
-
readonly currentJobId: string | null;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
export const useWizardGeneration = (
|
|
@@ -69,7 +68,7 @@ export const useWizardGeneration = (
|
|
|
69
68
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
70
69
|
console.log("[useWizardGeneration] Initialized", {
|
|
71
70
|
scenarioId: scenario.id,
|
|
72
|
-
outputType: scenario.outputType
|
|
71
|
+
outputType: scenario.outputType,
|
|
73
72
|
trackAsBackgroundJob,
|
|
74
73
|
});
|
|
75
74
|
}
|
|
@@ -125,13 +124,7 @@ export const useWizardGeneration = (
|
|
|
125
124
|
strategy,
|
|
126
125
|
{
|
|
127
126
|
userId,
|
|
128
|
-
alertMessages
|
|
129
|
-
networkError: "No internet connection",
|
|
130
|
-
policyViolation: "Content policy violation",
|
|
131
|
-
saveFailed: "Failed to save",
|
|
132
|
-
creditFailed: "Failed to deduct credits",
|
|
133
|
-
unknown: "An error occurred",
|
|
134
|
-
},
|
|
127
|
+
alertMessages,
|
|
135
128
|
onCreditsExhausted,
|
|
136
129
|
onSuccess: handleSuccess,
|
|
137
130
|
onError: handleError,
|
|
@@ -158,7 +151,7 @@ export const useWizardGeneration = (
|
|
|
158
151
|
}
|
|
159
152
|
|
|
160
153
|
// Create background job for tracking
|
|
161
|
-
if (trackAsBackgroundJob) {
|
|
154
|
+
if (trackAsBackgroundJob && scenario.outputType) {
|
|
162
155
|
const jobId = `wizard-${scenario.id}-${Date.now()}`;
|
|
163
156
|
currentJobIdRef.current = jobId;
|
|
164
157
|
|
|
@@ -166,10 +159,10 @@ export const useWizardGeneration = (
|
|
|
166
159
|
id: jobId,
|
|
167
160
|
input: {
|
|
168
161
|
scenarioId: scenario.id,
|
|
169
|
-
scenarioTitle: scenario.title
|
|
170
|
-
outputType: scenario.outputType
|
|
162
|
+
scenarioTitle: scenario.title,
|
|
163
|
+
outputType: scenario.outputType,
|
|
171
164
|
},
|
|
172
|
-
type: scenario.outputType
|
|
165
|
+
type: scenario.outputType,
|
|
173
166
|
status: "processing",
|
|
174
167
|
progress: 10,
|
|
175
168
|
});
|
|
@@ -186,7 +179,7 @@ export const useWizardGeneration = (
|
|
|
186
179
|
console.error("[useWizardGeneration] Input build error:", error);
|
|
187
180
|
}
|
|
188
181
|
hasStarted.current = false;
|
|
189
|
-
onError?.(error.message
|
|
182
|
+
onError?.(error.message);
|
|
190
183
|
});
|
|
191
184
|
}
|
|
192
185
|
|
|
@@ -204,8 +197,5 @@ export const useWizardGeneration = (
|
|
|
204
197
|
addJob,
|
|
205
198
|
]);
|
|
206
199
|
|
|
207
|
-
return {
|
|
208
|
-
isGenerating,
|
|
209
|
-
currentJobId: currentJobIdRef.current,
|
|
210
|
-
};
|
|
200
|
+
return { isGenerating };
|
|
211
201
|
};
|