@umituz/react-native-ai-generation-content 1.82.4 → 1.82.5
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/hooks/useProcessingJobsPoller.ts +27 -2
- package/src/domains/generation/wizard/infrastructure/utils/creation-persistence.types.ts +1 -0
- package/src/domains/generation/wizard/infrastructure/utils/creation-update-operations.ts +2 -1
- package/src/domains/generation/wizard/presentation/hooks/generation-result.utils.ts +6 -1
- package/src/domains/generation/wizard/presentation/hooks/useVideoQueueGeneration.ts +1 -0
- package/src/presentation/hooks/generation/orchestrator.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.82.
|
|
3
|
+
"version": "1.82.5",
|
|
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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { useEffect, useRef, useMemo } from "react";
|
|
9
9
|
import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
|
|
10
10
|
import { QUEUE_STATUS, CREATION_STATUS } from "../../../../domain/constants/queue-status.constants";
|
|
11
|
-
import { DEFAULT_POLL_INTERVAL_MS } from "../../../../infrastructure/constants/polling.constants";
|
|
11
|
+
import { DEFAULT_POLL_INTERVAL_MS, DEFAULT_MAX_POLL_TIME_MS } from "../../../../infrastructure/constants/polling.constants";
|
|
12
12
|
import {
|
|
13
13
|
extractResultUrl,
|
|
14
14
|
type GenerationResult,
|
|
@@ -76,6 +76,26 @@ export function useProcessingJobsPoller(
|
|
|
76
76
|
if (pollingRef.current.has(creation.id)) return;
|
|
77
77
|
pollingRef.current.add(creation.id);
|
|
78
78
|
|
|
79
|
+
// Stale detection: if creation is older than max poll time, mark as failed
|
|
80
|
+
const ageMs = Date.now() - creation.createdAt.getTime();
|
|
81
|
+
if (ageMs > DEFAULT_MAX_POLL_TIME_MS) {
|
|
82
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
83
|
+
console.log("[ProcessingJobsPoller] Stale job detected, marking as failed:", creation.id, { ageMs });
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await repository.update(userId, creation.id, {
|
|
87
|
+
status: CREATION_STATUS.FAILED,
|
|
88
|
+
metadata: { error: "Generation timed out" },
|
|
89
|
+
});
|
|
90
|
+
} catch (e) {
|
|
91
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
92
|
+
console.error("[ProcessingJobsPoller] Failed to mark stale job:", e);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
pollingRef.current.delete(creation.id);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
79
99
|
const provider = providerRegistry.getActiveProvider();
|
|
80
100
|
if (!provider || !provider.isInitialized()) {
|
|
81
101
|
pollingRef.current.delete(creation.id);
|
|
@@ -114,10 +134,15 @@ export function useProcessingJobsPoller(
|
|
|
114
134
|
return;
|
|
115
135
|
}
|
|
116
136
|
|
|
137
|
+
const output: Record<string, string | undefined> = {};
|
|
138
|
+
if (urls.imageUrl) output.imageUrl = urls.imageUrl;
|
|
139
|
+
if (urls.videoUrl) output.videoUrl = urls.videoUrl;
|
|
140
|
+
if (urls.thumbnailUrl) output.thumbnailUrl = urls.thumbnailUrl;
|
|
141
|
+
|
|
117
142
|
await repository.update(userId, creation.id, {
|
|
118
143
|
status: CREATION_STATUS.COMPLETED,
|
|
119
144
|
uri,
|
|
120
|
-
output
|
|
145
|
+
output,
|
|
121
146
|
});
|
|
122
147
|
} else if (status.status === QUEUE_STATUS.FAILED) {
|
|
123
148
|
if (typeof __DEV__ !== "undefined" && __DEV__) console.log("[ProcessingJobsPoller] Failed:", creation.id);
|
|
@@ -17,9 +17,10 @@ export async function updateToCompleted(
|
|
|
17
17
|
creationId: string,
|
|
18
18
|
data: CompletedCreationData
|
|
19
19
|
): Promise<void> {
|
|
20
|
-
const output: { imageUrl?: string; videoUrl?: string } = {};
|
|
20
|
+
const output: { imageUrl?: string; videoUrl?: string; thumbnailUrl?: string } = {};
|
|
21
21
|
if (data.imageUrl) output.imageUrl = data.imageUrl;
|
|
22
22
|
if (data.videoUrl) output.videoUrl = data.videoUrl;
|
|
23
|
+
if (data.thumbnailUrl) output.thumbnailUrl = data.thumbnailUrl;
|
|
23
24
|
|
|
24
25
|
await repository.update(userId, creationId, {
|
|
25
26
|
uri: data.uri,
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Provider-agnostic utilities for extracting generation results
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { extractThumbnailUrl } from "../../../../../infrastructure/utils/url-extractor/thumbnail-extractor";
|
|
7
|
+
|
|
6
8
|
export interface GenerationErrorDetail {
|
|
7
9
|
msg?: string;
|
|
8
10
|
type?: string;
|
|
@@ -22,6 +24,7 @@ export interface GenerationResult {
|
|
|
22
24
|
export interface GenerationUrls {
|
|
23
25
|
imageUrl?: string;
|
|
24
26
|
videoUrl?: string;
|
|
27
|
+
thumbnailUrl?: string;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
@@ -59,8 +62,10 @@ function checkForErrors(result: GenerationResult): void {
|
|
|
59
62
|
export function extractResultUrl(result: GenerationResult): GenerationUrls {
|
|
60
63
|
checkForErrors(result);
|
|
61
64
|
|
|
65
|
+
const thumbnailUrl = extractThumbnailUrl(result);
|
|
66
|
+
|
|
62
67
|
if (result.video?.url && typeof result.video.url === "string") {
|
|
63
|
-
return { videoUrl: result.video.url };
|
|
68
|
+
return { videoUrl: result.video.url, thumbnailUrl };
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
if (typeof result.output === "string" && result.output.length > 0 && result.output.startsWith("http")) {
|
|
@@ -81,6 +81,7 @@ export function useVideoQueueGeneration(props: UseVideoQueueGenerationProps): Us
|
|
|
81
81
|
uri,
|
|
82
82
|
imageUrl: urls.imageUrl,
|
|
83
83
|
videoUrl: urls.videoUrl,
|
|
84
|
+
thumbnailUrl: urls.thumbnailUrl,
|
|
84
85
|
});
|
|
85
86
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
86
87
|
console.log("[VideoQueue] ✅ Updated completion status in Firestore");
|
|
@@ -25,10 +25,6 @@ export const useGenerationOrchestrator = <TInput, TResult>(
|
|
|
25
25
|
): UseGenerationOrchestratorReturn<TInput, TResult> => {
|
|
26
26
|
const { userId, alertMessages, onSuccess, onError, moderation, lifecycle } = config;
|
|
27
27
|
|
|
28
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
29
|
-
console.log("[Orchestrator] Hook initialized:", { userId });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
const [state, setState] = useState<GenerationState<TResult>>(INITIAL_STATE);
|
|
33
29
|
const isGeneratingRef = useRef(false);
|
|
34
30
|
const isMountedRef = useRef(true);
|