@umituz/react-native-ai-generation-content 1.83.97 → 1.83.99
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/generation/domain/generation.types.ts +2 -0
- package/src/domains/generation/infrastructure/executors/image-executor.ts +6 -5
- package/src/domains/generation/infrastructure/executors/text-to-image-executor.ts +5 -4
- package/src/domains/generation/infrastructure/executors/video-executor.ts +5 -4
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts +6 -3
- package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts +2 -1
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts +12 -6
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +3 -2
- package/src/domains/generation/wizard/presentation/hooks/wizard-generation.types.ts +2 -0
- package/src/domains/scenarios/domain/Scenario.ts +2 -0
- package/src/domains/scenarios/domain/scenario.types.ts +2 -0
- package/src/exports/infrastructure.ts +1 -1
- package/src/infrastructure/services/index.ts +1 -0
- package/src/infrastructure/services/provider-resolver.ts +44 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.83.
|
|
3
|
+
"version": "1.83.99",
|
|
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",
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
export interface GenerationOptions {
|
|
11
11
|
timeoutMs?: number;
|
|
12
12
|
onProgress?: (progress: number) => void;
|
|
13
|
+
/** AI provider to use (e.g. "fal", "pruna"). Falls back to active provider. */
|
|
14
|
+
providerId?: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
// ============================================================================
|
|
@@ -10,9 +10,9 @@ import type {
|
|
|
10
10
|
GenerationOptions,
|
|
11
11
|
} from "../../domain/generation.types";
|
|
12
12
|
import type { GenerationResult } from "../../../../domain/entities/generation.types";
|
|
13
|
-
import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
|
|
14
13
|
import { env } from "../../../../infrastructure/config/env.config";
|
|
15
14
|
import { addGenerationLogs, addGenerationLog, startGenerationLogSession } from "../../../../infrastructure/services/generation-log-store";
|
|
15
|
+
import { resolveProvider } from "../../../../infrastructure/services/provider-resolver";
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
export class ImageExecutor
|
|
@@ -27,6 +27,8 @@ export class ImageExecutor
|
|
|
27
27
|
const startTime = Date.now();
|
|
28
28
|
const sid = startGenerationLogSession();
|
|
29
29
|
|
|
30
|
+
let provider: ReturnType<typeof resolveProvider> | undefined;
|
|
31
|
+
|
|
30
32
|
try {
|
|
31
33
|
const totalImageSize = input.imageUrls?.reduce((sum, url) => sum + url.length, 0) ?? 0;
|
|
32
34
|
addGenerationLog(sid, TAG, 'Starting generation', 'info', {
|
|
@@ -36,9 +38,9 @@ export class ImageExecutor
|
|
|
36
38
|
promptLength: input.prompt?.length || 0,
|
|
37
39
|
});
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
provider = resolveProvider(options?.providerId);
|
|
43
|
+
} catch {
|
|
42
44
|
addGenerationLog(sid, TAG, 'Provider not initialized!', 'error');
|
|
43
45
|
return { success: false, error: "AI provider not initialized" };
|
|
44
46
|
}
|
|
@@ -83,7 +85,6 @@ export class ImageExecutor
|
|
|
83
85
|
return { success: true, data: { imageUrl } };
|
|
84
86
|
} catch (error) {
|
|
85
87
|
// Collect provider logs even on failure — no providerSessionId available in catch
|
|
86
|
-
const provider = providerRegistry.getActiveProvider();
|
|
87
88
|
if (provider) {
|
|
88
89
|
const providerLogs = provider.endLogSession?.() ?? [];
|
|
89
90
|
addGenerationLogs(sid, providerLogs);
|
|
@@ -8,9 +8,9 @@ import type {
|
|
|
8
8
|
GenerationOptions,
|
|
9
9
|
} from "../../domain/generation.types";
|
|
10
10
|
import type { GenerationResult } from "../../../../domain/entities/generation.types";
|
|
11
|
-
import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
|
|
12
11
|
import type { TextToImageInput, TextToImageOutput } from "./text-to-image-executor.types";
|
|
13
12
|
import { buildModelInput, extractResult } from "./text-to-image-executor.helpers";
|
|
13
|
+
import { resolveProvider } from "../../../../infrastructure/services/provider-resolver";
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
export class TextToImageExecutor
|
|
@@ -31,9 +31,10 @@ export class TextToImageExecutor
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
let provider;
|
|
35
|
+
try {
|
|
36
|
+
provider = resolveProvider(options?.providerId);
|
|
37
|
+
} catch {
|
|
37
38
|
return { success: false, error: "AI provider not initialized" };
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -10,8 +10,8 @@ import type {
|
|
|
10
10
|
GenerationOptions,
|
|
11
11
|
} from "../../domain/generation.types";
|
|
12
12
|
import type { GenerationResult } from "../../../../domain/entities/generation.types";
|
|
13
|
-
import { providerRegistry } from "../../../../infrastructure/services/provider-registry.service";
|
|
14
13
|
import { env } from "../../../../infrastructure/config/env.config";
|
|
14
|
+
import { resolveProvider } from "../../../../infrastructure/services/provider-resolver";
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
export class VideoExecutor
|
|
@@ -32,9 +32,10 @@ export class VideoExecutor
|
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
let provider;
|
|
36
|
+
try {
|
|
37
|
+
provider = resolveProvider(options?.providerId);
|
|
38
|
+
} catch {
|
|
38
39
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
39
40
|
console.error("[VideoExecutor] Provider not initialized");
|
|
40
41
|
}
|
package/src/domains/generation/wizard/infrastructure/strategies/image-generation.executor.ts
CHANGED
|
@@ -27,14 +27,17 @@ export async function executeImageGeneration(
|
|
|
27
27
|
input: WizardImageInput,
|
|
28
28
|
model: string,
|
|
29
29
|
onProgress?: (progress: number) => void,
|
|
30
|
+
providerId?: string,
|
|
30
31
|
): Promise<ExecutionResult> {
|
|
31
32
|
const TAG = 'ImageExecutor';
|
|
32
33
|
const startTime = Date.now();
|
|
33
34
|
const sid = startGenerationLogSession();
|
|
34
|
-
const {
|
|
35
|
+
const { resolveProvider } = await import("../../../../../infrastructure/services/provider-resolver");
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
let provider;
|
|
38
|
+
try {
|
|
39
|
+
provider = resolveProvider(providerId);
|
|
40
|
+
} catch {
|
|
38
41
|
addGenerationLog(sid, TAG, 'Provider not initialized!', 'error');
|
|
39
42
|
return { success: false, error: "AI provider not initialized", logSessionId: sid };
|
|
40
43
|
}
|
package/src/domains/generation/wizard/infrastructure/strategies/image-generation.strategy.ts
CHANGED
|
@@ -84,11 +84,12 @@ export function createImageStrategy(options: CreateImageStrategyOptions): Wizard
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
const model = scenario.model;
|
|
87
|
+
const providerId = scenario.providerId;
|
|
87
88
|
|
|
88
89
|
return {
|
|
89
90
|
execute: async (input: unknown) => {
|
|
90
91
|
const imageInput = input as WizardImageInput;
|
|
91
|
-
const result = await executeImageGeneration(imageInput, model);
|
|
92
|
+
const result = await executeImageGeneration(imageInput, model, undefined, providerId);
|
|
92
93
|
|
|
93
94
|
if (!result.success || !result.imageUrl) {
|
|
94
95
|
const error = new Error(result.error || "Image generation failed");
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.executor.ts
CHANGED
|
@@ -62,11 +62,14 @@ export async function executeVideoGeneration(
|
|
|
62
62
|
model: string,
|
|
63
63
|
onProgress?: (status: string) => void,
|
|
64
64
|
modelConfig?: VideoModelConfig,
|
|
65
|
+
providerId?: string,
|
|
65
66
|
): Promise<ExecutionResult> {
|
|
66
|
-
const {
|
|
67
|
+
const { resolveProvider } = await import("../../../../../infrastructure/services/provider-resolver");
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
let provider;
|
|
70
|
+
try {
|
|
71
|
+
provider = resolveProvider(providerId);
|
|
72
|
+
} catch {
|
|
70
73
|
const error = createGenerationError(
|
|
71
74
|
GenerationErrorType.VALIDATION,
|
|
72
75
|
"AI provider is not initialized. Please check your configuration."
|
|
@@ -124,11 +127,14 @@ export async function submitVideoGenerationToQueue(
|
|
|
124
127
|
input: WizardVideoInput,
|
|
125
128
|
model: string,
|
|
126
129
|
modelConfig?: VideoModelConfig,
|
|
130
|
+
providerId?: string,
|
|
127
131
|
): Promise<SubmissionResult> {
|
|
128
|
-
const {
|
|
132
|
+
const { resolveProvider } = await import("../../../../../infrastructure/services/provider-resolver");
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
let provider;
|
|
135
|
+
try {
|
|
136
|
+
provider = resolveProvider(providerId);
|
|
137
|
+
} catch {
|
|
132
138
|
const error = createGenerationError(
|
|
133
139
|
GenerationErrorType.VALIDATION,
|
|
134
140
|
"AI provider is not initialized. Please check your configuration."
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts
CHANGED
|
@@ -73,12 +73,13 @@ export function createVideoStrategy(options: CreateVideoStrategyOptions): Wizard
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const model = scenario.model;
|
|
76
|
+
const providerId = scenario.providerId;
|
|
76
77
|
|
|
77
78
|
return {
|
|
78
79
|
execute: async (input: unknown) => {
|
|
79
80
|
const videoInput = validateWizardVideoInput(input);
|
|
80
81
|
|
|
81
|
-
const result = await executeVideoGeneration(videoInput, model, undefined, modelConfig);
|
|
82
|
+
const result = await executeVideoGeneration(videoInput, model, undefined, modelConfig, providerId);
|
|
82
83
|
|
|
83
84
|
if (!result.success || !result.videoUrl) {
|
|
84
85
|
throw new Error(result.error || "Video generation failed");
|
|
@@ -90,7 +91,7 @@ export function createVideoStrategy(options: CreateVideoStrategyOptions): Wizard
|
|
|
90
91
|
submitToQueue: async (input: unknown) => {
|
|
91
92
|
const videoInput = validateWizardVideoInput(input);
|
|
92
93
|
|
|
93
|
-
const result = await submitVideoGenerationToQueue(videoInput, model, modelConfig);
|
|
94
|
+
const result = await submitVideoGenerationToQueue(videoInput, model, modelConfig, providerId);
|
|
94
95
|
|
|
95
96
|
return {
|
|
96
97
|
success: result.success,
|
|
@@ -16,6 +16,8 @@ export interface WizardScenarioData {
|
|
|
16
16
|
/** Input type - determines required photo count. Default: "single" */
|
|
17
17
|
readonly inputType?: ScenarioInputType;
|
|
18
18
|
readonly model?: string;
|
|
19
|
+
/** AI provider to use (e.g. "fal", "pruna"). Falls back to active provider. */
|
|
20
|
+
readonly providerId?: string;
|
|
19
21
|
readonly title?: string;
|
|
20
22
|
readonly description?: string;
|
|
21
23
|
/** Video feature type - set by main app to control generation mode */
|
|
@@ -33,6 +33,8 @@ export interface Scenario {
|
|
|
33
33
|
outputType?: ScenarioOutputType;
|
|
34
34
|
inputType?: ScenarioInputType;
|
|
35
35
|
model?: string;
|
|
36
|
+
/** AI provider to use for this scenario (e.g. "fal", "pruna"). Falls back to active provider. */
|
|
37
|
+
providerId?: string;
|
|
36
38
|
enabled?: boolean;
|
|
37
39
|
generatingMessages?: GeneratingMessages;
|
|
38
40
|
}
|
|
@@ -18,5 +18,7 @@ export interface ScenarioData {
|
|
|
18
18
|
readonly requiresPhoto?: boolean;
|
|
19
19
|
readonly hidden?: boolean;
|
|
20
20
|
readonly inputType?: ScenarioInputType;
|
|
21
|
+
/** AI provider to use for this scenario (e.g. "fal", "pruna"). Falls back to active provider. */
|
|
22
|
+
readonly providerId?: string;
|
|
21
23
|
readonly [key: string]: unknown;
|
|
22
24
|
}
|
|
@@ -15,7 +15,7 @@ export {
|
|
|
15
15
|
|
|
16
16
|
// Services
|
|
17
17
|
export {
|
|
18
|
-
providerRegistry, generationOrchestrator,
|
|
18
|
+
providerRegistry, resolveProvider, generationOrchestrator,
|
|
19
19
|
executeImageFeature, hasImageFeatureSupport, executeVideoFeature, hasVideoFeatureSupport,
|
|
20
20
|
submitVideoFeatureToQueue, executeMultiImageGeneration,
|
|
21
21
|
} from "../infrastructure/services";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
export { providerRegistry } from "./provider-registry.service";
|
|
6
|
+
export { resolveProvider } from "./provider-resolver";
|
|
6
7
|
export { generationOrchestrator } from "./generation-orchestrator.service";
|
|
7
8
|
export type { OrchestratorConfig } from "./generation-orchestrator.service";
|
|
8
9
|
export {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Resolver
|
|
3
|
+
* Resolves the correct AI provider based on providerId.
|
|
4
|
+
* Falls back to the active provider when no providerId is specified.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { IAIProvider } from "../../domain/interfaces";
|
|
8
|
+
import { providerRegistry } from "./provider-registry.service";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolve an AI provider by ID, falling back to the active provider.
|
|
12
|
+
*
|
|
13
|
+
* @param providerId - Explicit provider ID (e.g. "fal", "pruna"). When given,
|
|
14
|
+
* the matching registered provider is returned. When omitted or when the
|
|
15
|
+
* specified provider is not available, the registry's active provider is used.
|
|
16
|
+
* @throws Error if no usable provider is found.
|
|
17
|
+
*/
|
|
18
|
+
export function resolveProvider(providerId?: string): IAIProvider {
|
|
19
|
+
// 1. Try explicit provider
|
|
20
|
+
if (providerId) {
|
|
21
|
+
const provider = providerRegistry.getProvider(providerId);
|
|
22
|
+
if (provider?.isInitialized()) {
|
|
23
|
+
return provider;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
27
|
+
console.warn(
|
|
28
|
+
`[ProviderResolver] Provider "${providerId}" not available, falling back to active provider`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 2. Fallback to active provider
|
|
34
|
+
const active = providerRegistry.getActiveProvider();
|
|
35
|
+
if (active?.isInitialized()) {
|
|
36
|
+
return active;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
throw new Error(
|
|
40
|
+
providerId
|
|
41
|
+
? `AI provider "${providerId}" is not registered or initialized, and no active fallback is available`
|
|
42
|
+
: "No AI provider is initialized. Call initializeProvider() first.",
|
|
43
|
+
);
|
|
44
|
+
}
|