@umituz/react-native-ai-fal-provider 2.2.3 → 2.3.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
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Creates a ready-to-use InitModule for app initialization
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { providerRegistry } from '@umituz/react-native-ai-generation-content';
|
|
6
7
|
import { falProvider } from '../infrastructure/services';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -36,15 +37,6 @@ export interface AiProviderInitModuleConfig {
|
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Optional callback called after provider is initialized
|
|
39
|
-
* Use this to register the provider with wizard flow:
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* onInitialized: () => {
|
|
43
|
-
* const { providerRegistry } = require('@umituz/react-native-ai-generation-content');
|
|
44
|
-
* const { registerWithWizard } = require('@umituz/react-native-ai-fal-provider');
|
|
45
|
-
* registerWithWizard(providerRegistry);
|
|
46
|
-
* }
|
|
47
|
-
* ```
|
|
48
40
|
*/
|
|
49
41
|
onInitialized?: () => void;
|
|
50
42
|
}
|
|
@@ -91,11 +83,14 @@ export function createAiProviderInitModule(
|
|
|
91
83
|
}
|
|
92
84
|
|
|
93
85
|
// Initialize FAL provider
|
|
94
|
-
falProvider.initialize({
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
falProvider.initialize({ apiKey });
|
|
87
|
+
|
|
88
|
+
// Register with providerRegistry automatically
|
|
89
|
+
if (!providerRegistry.hasProvider(falProvider.providerId)) {
|
|
90
|
+
providerRegistry.register(falProvider);
|
|
91
|
+
}
|
|
92
|
+
providerRegistry.setActiveProvider(falProvider.providerId);
|
|
97
93
|
|
|
98
|
-
// Call optional callback after initialization
|
|
99
94
|
if (onInitialized) {
|
|
100
95
|
onInitialized();
|
|
101
96
|
}
|
|
@@ -107,3 +102,41 @@ export function createAiProviderInitModule(
|
|
|
107
102
|
},
|
|
108
103
|
};
|
|
109
104
|
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Initializes FAL provider and registers it with providerRegistry in one call.
|
|
108
|
+
* Use this for simple synchronous registration at app startup.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // registerProviders.ts - that's all you need!
|
|
113
|
+
* import { initializeFalProvider } from "@umituz/react-native-ai-fal-provider";
|
|
114
|
+
* import { getFalApiKey } from "@/core/utils/env";
|
|
115
|
+
*
|
|
116
|
+
* export function registerProviders(): void {
|
|
117
|
+
* initializeFalProvider({ apiKey: getFalApiKey() });
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export function initializeFalProvider(config: {
|
|
122
|
+
apiKey: string | undefined;
|
|
123
|
+
}): boolean {
|
|
124
|
+
try {
|
|
125
|
+
const { apiKey } = config;
|
|
126
|
+
|
|
127
|
+
if (!apiKey) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
falProvider.initialize({ apiKey });
|
|
132
|
+
|
|
133
|
+
if (!providerRegistry.hasProvider(falProvider.providerId)) {
|
|
134
|
+
providerRegistry.register(falProvider);
|
|
135
|
+
}
|
|
136
|
+
providerRegistry.setActiveProvider(falProvider.providerId);
|
|
137
|
+
|
|
138
|
+
return true;
|
|
139
|
+
} catch {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -3,28 +3,26 @@
|
|
|
3
3
|
* Use this when your app uses GenericWizardFlow from @umituz/react-native-ai-generation-content
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { providerRegistry } from '@umituz/react-native-ai-generation-content';
|
|
6
7
|
import { falProvider } from '../infrastructure/services';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* Register FAL provider with the wizard flow provider registry
|
|
10
|
+
* Register FAL provider with the wizard flow provider registry.
|
|
11
|
+
* Optionally accepts a custom registry for backward compatibility.
|
|
10
12
|
*
|
|
11
13
|
* @example
|
|
12
14
|
* ```typescript
|
|
13
|
-
* import { providerRegistry } from '@umituz/react-native-ai-generation-content';
|
|
14
15
|
* import { registerWithWizard } from '@umituz/react-native-ai-fal-provider';
|
|
15
16
|
*
|
|
16
|
-
* //
|
|
17
|
-
* registerWithWizard(
|
|
17
|
+
* // No need to import providerRegistry separately anymore
|
|
18
|
+
* registerWithWizard();
|
|
18
19
|
* ```
|
|
19
20
|
*/
|
|
20
|
-
export function registerWithWizard(registry
|
|
21
|
+
export function registerWithWizard(registry?: {
|
|
21
22
|
register: (provider: any) => void;
|
|
22
23
|
setActiveProvider: (id: string) => void;
|
|
23
24
|
}): void {
|
|
24
|
-
registry
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
28
|
-
console.log('[FAL Provider] Registered with wizard flow');
|
|
29
|
-
}
|
|
25
|
+
const reg = registry ?? providerRegistry;
|
|
26
|
+
reg.register(falProvider);
|
|
27
|
+
reg.setActiveProvider('fal');
|
|
30
28
|
}
|