@umituz/react-native-ai-fal-provider 1.0.92 → 1.0.93

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-fal-provider",
3
- "version": "1.0.92",
3
+ "version": "1.0.93",
4
4
  "description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -36,6 +36,12 @@ interface ActiveRequest<T = unknown> {
36
36
  model: string;
37
37
  }
38
38
 
39
+ /**
40
+ * Module-level state for Promise Deduplication
41
+ * Persists across hot reloads (module cache is preserved)
42
+ */
43
+ let activeRequest: ActiveRequest | null = null;
44
+
39
45
  export class FalProvider implements IAIProvider {
40
46
  readonly providerId = "fal";
41
47
  readonly providerName = "FAL AI";
@@ -45,7 +51,6 @@ export class FalProvider implements IAIProvider {
45
51
  private costTracker: CostTracker | null = null;
46
52
  private videoFeatureModels: Record<string, string> = {};
47
53
  private imageFeatureModels: Record<string, string> = {};
48
- private activeRequest: ActiveRequest | null = null;
49
54
 
50
55
  initialize(config: AIProviderConfig): void {
51
56
  this.apiKey = config.apiKey;
@@ -138,11 +143,11 @@ export class FalProvider implements IAIProvider {
138
143
  ): Promise<T> {
139
144
  this.validateInit();
140
145
 
141
- if (this.activeRequest) {
146
+ if (activeRequest) {
142
147
  if (typeof __DEV__ !== "undefined" && __DEV__) {
143
- console.log(`[FalProvider] Returning existing promise for ${this.activeRequest.model}`);
148
+ console.log(`[FalProvider] Returning existing promise for ${activeRequest.model}`);
144
149
  }
145
- return this.activeRequest.promise as Promise<T>;
150
+ return activeRequest.promise as Promise<T>;
146
151
  }
147
152
 
148
153
  const abortController = new AbortController();
@@ -156,8 +161,8 @@ export class FalProvider implements IAIProvider {
156
161
  return result;
157
162
  });
158
163
 
159
- this.activeRequest = { promise, abortController, model };
160
- promise.finally(() => { this.activeRequest = null; });
164
+ activeRequest = { promise, abortController, model };
165
+ promise.finally(() => { activeRequest = null; });
161
166
 
162
167
  return promise;
163
168
  }
@@ -183,17 +188,17 @@ export class FalProvider implements IAIProvider {
183
188
  }
184
189
 
185
190
  cancelCurrentRequest(): void {
186
- if (this.activeRequest) {
191
+ if (activeRequest) {
187
192
  if (typeof __DEV__ !== "undefined" && __DEV__) {
188
193
  console.log("[FalProvider] Cancelling current request");
189
194
  }
190
- this.activeRequest.abortController.abort();
191
- this.activeRequest = null;
195
+ activeRequest.abortController.abort();
196
+ activeRequest = null;
192
197
  }
193
198
  }
194
199
 
195
200
  hasRunningRequest(): boolean {
196
- return this.activeRequest !== null;
201
+ return activeRequest !== null;
197
202
  }
198
203
 
199
204
  getImageFeatureModel(feature: ImageFeatureType): string {