@umituz/react-native-ai-generation-content 1.81.2 → 1.81.4
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/wizard/infrastructure/utils/credit-value-extractors.ts +27 -0
- package/src/domains/generation/wizard/presentation/components/WizardFlowContent.tsx +21 -20
- package/src/domains/generation/wizard/presentation/hooks/videoQueuePoller.ts +0 -1
- package/src/infrastructure/services/provider-registry.service.ts +1 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.81.
|
|
3
|
+
"version": "1.81.4",
|
|
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",
|
|
@@ -63,3 +63,30 @@ export function extractResolution(value: unknown): string | undefined {
|
|
|
63
63
|
}
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Extract default duration from wizard feature config
|
|
69
|
+
* Finds the duration selection step and resolves its default option value
|
|
70
|
+
*/
|
|
71
|
+
export function getConfigDefaultDuration(steps: readonly Record<string, unknown>[]): number | undefined {
|
|
72
|
+
const step = steps.find((s) => s.selectionType === "duration");
|
|
73
|
+
if (!step?.defaultValue || !step.options || !Array.isArray(step.options)) return undefined;
|
|
74
|
+
|
|
75
|
+
const defaultId = typeof step.defaultValue === "string" ? step.defaultValue : String(step.defaultValue);
|
|
76
|
+
const options = step.options as readonly { id: string; value: unknown }[];
|
|
77
|
+
const option = options.find((o) => o.id === defaultId);
|
|
78
|
+
if (option) {
|
|
79
|
+
return typeof option.value === "number" ? option.value : extractDuration(option.value);
|
|
80
|
+
}
|
|
81
|
+
return extractDuration(defaultId);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Extract default resolution from wizard feature config
|
|
86
|
+
* Finds the resolution selection step and returns its default value
|
|
87
|
+
*/
|
|
88
|
+
export function getConfigDefaultResolution(steps: readonly Record<string, unknown>[]): string | undefined {
|
|
89
|
+
const step = steps.find((s) => s.selectionType === "resolution");
|
|
90
|
+
if (!step?.defaultValue) return undefined;
|
|
91
|
+
return typeof step.defaultValue === "string" ? step.defaultValue : undefined;
|
|
92
|
+
}
|
|
@@ -16,7 +16,7 @@ import type { Creation } from "../../../../creations/domain/entities/Creation";
|
|
|
16
16
|
import { createCreationsRepository } from "../../../../creations";
|
|
17
17
|
import { useResultActions } from "../../../../result-preview/presentation/hooks/useResultActions";
|
|
18
18
|
import { useWizardFlowHandlers } from "../hooks/useWizardFlowHandlers";
|
|
19
|
-
import { extractDuration, extractResolution } from "../../infrastructure/utils/credit-value-extractors";
|
|
19
|
+
import { extractDuration, extractResolution, getConfigDefaultDuration, getConfigDefaultResolution } from "../../infrastructure/utils/credit-value-extractors";
|
|
20
20
|
import { WizardStepRenderer } from "./WizardStepRenderer";
|
|
21
21
|
import { StarRatingPicker } from "../../../../result-preview/presentation/components/StarRatingPicker";
|
|
22
22
|
import type { CreditCalculatorFn } from "../../domain/types/credit-calculation.types";
|
|
@@ -83,22 +83,22 @@ export const WizardFlowContent: React.FC<WizardFlowContentProps> = (props) => {
|
|
|
83
83
|
const prevStepIdRef = useRef<string | undefined>(undefined);
|
|
84
84
|
const repository = useMemo(() => createCreationsRepository("creations"), []);
|
|
85
85
|
|
|
86
|
-
const flowSteps = useMemo<StepDefinition[]>(
|
|
87
|
-
(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
includeResult: !skipResultStep,
|
|
92
|
-
}),
|
|
93
|
-
[featureConfig, skipResultStep],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
97
|
-
console.log("[WizardFlowContent] flowSteps built", {
|
|
98
|
-
totalSteps: flowSteps.length,
|
|
99
|
-
steps: flowSteps.map((s, i) => `${i}: ${s.id} (${s.type})`),
|
|
86
|
+
const flowSteps = useMemo<StepDefinition[]>(() => {
|
|
87
|
+
const steps = buildFlowStepsFromWizard(featureConfig, {
|
|
88
|
+
includePreview: true,
|
|
89
|
+
includeGenerating: true,
|
|
90
|
+
includeResult: !skipResultStep,
|
|
100
91
|
});
|
|
101
|
-
|
|
92
|
+
|
|
93
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
94
|
+
console.log("[WizardFlowContent] flowSteps built", {
|
|
95
|
+
totalSteps: steps.length,
|
|
96
|
+
steps: steps.map((s, i) => `${i}: ${s.id} (${s.type})`),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return steps;
|
|
101
|
+
}, [featureConfig, skipResultStep]);
|
|
102
102
|
|
|
103
103
|
const flow = useFlow({ steps: flowSteps, initialStepIndex: 0 });
|
|
104
104
|
const {
|
|
@@ -138,9 +138,10 @@ export const WizardFlowContent: React.FC<WizardFlowContentProps> = (props) => {
|
|
|
138
138
|
const outputType = validatedScenario.outputType as "video" | "image";
|
|
139
139
|
const hasImageInput = validatedScenario.inputType !== "text";
|
|
140
140
|
|
|
141
|
-
// Extract
|
|
142
|
-
|
|
143
|
-
const
|
|
141
|
+
// Extract from customData, fall back to step defaults from wizard config
|
|
142
|
+
// This ensures accurate credit display even before user confirms a selection
|
|
143
|
+
const duration = extractDuration(customData.duration) ?? getConfigDefaultDuration(featureConfig.steps as unknown as Record<string, unknown>[]);
|
|
144
|
+
const resolution = extractResolution(customData.resolution) ?? getConfigDefaultResolution(featureConfig.steps as unknown as Record<string, unknown>[]);
|
|
144
145
|
|
|
145
146
|
// Call app's calculator
|
|
146
147
|
const result = calculateCredits({
|
|
@@ -152,7 +153,7 @@ export const WizardFlowContent: React.FC<WizardFlowContentProps> = (props) => {
|
|
|
152
153
|
|
|
153
154
|
// If result is 0 (incomplete selections), use static initial cost
|
|
154
155
|
return result > 0 ? result : creditCost;
|
|
155
|
-
}, [customData, validatedScenario.outputType, validatedScenario.inputType, calculateCredits, creditCost]);
|
|
156
|
+
}, [customData, featureConfig.steps, validatedScenario.outputType, validatedScenario.inputType, calculateCredits, creditCost]);
|
|
156
157
|
|
|
157
158
|
const handlers = useWizardFlowHandlers({
|
|
158
159
|
currentStepIndex,
|
|
@@ -66,7 +66,6 @@ export const pollQueueStatus = async (params: PollParams): Promise<void> => {
|
|
|
66
66
|
|
|
67
67
|
try {
|
|
68
68
|
const status = await provider.getJobStatus(model, requestId);
|
|
69
|
-
if (__DEV__) console.log("[VideoQueueGeneration] Poll:", status.status);
|
|
70
69
|
|
|
71
70
|
// Reset consecutive errors on successful poll
|
|
72
71
|
consecutiveErrorsRef.current = 0;
|
|
@@ -49,13 +49,6 @@ class ProviderRegistry {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
getActiveProvider(): IAIProvider | null {
|
|
52
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
53
|
-
console.log("[ProviderRegistry] getActiveProvider() called", {
|
|
54
|
-
activeProviderId: this.activeProviderId,
|
|
55
|
-
registeredProviders: Array.from(this.providers.keys()),
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
52
|
if (!this.activeProviderId) {
|
|
60
53
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
61
54
|
console.warn("[ProviderRegistry] No active provider set!");
|
|
@@ -63,16 +56,7 @@ class ProviderRegistry {
|
|
|
63
56
|
return null;
|
|
64
57
|
}
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
69
|
-
console.log("[ProviderRegistry] getActiveProvider() returning", {
|
|
70
|
-
providerId: provider?.providerId,
|
|
71
|
-
isInitialized: provider?.isInitialized(),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return provider;
|
|
59
|
+
return this.providers.get(this.activeProviderId) ?? null;
|
|
76
60
|
}
|
|
77
61
|
|
|
78
62
|
getProvider(providerId: string): IAIProvider | null {
|