@umituz/react-native-ai-generation-content 1.11.0 → 1.11.1
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-generation-content",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@tanstack/react-query": ">=5.0.0",
|
|
34
34
|
"@umituz/react-native-animation": "latest",
|
|
35
35
|
"@umituz/react-native-design-system": "latest",
|
|
36
|
+
"@umituz/react-native-offline": "latest",
|
|
36
37
|
"expo-linear-gradient": ">=15.0.0",
|
|
37
38
|
"react": ">=18.0.0",
|
|
38
39
|
"react-native": ">=0.74.0"
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"@tanstack/react-query": "^5.0.0",
|
|
43
44
|
"@umituz/react-native-animation": "latest",
|
|
44
45
|
"@umituz/react-native-design-system": "latest",
|
|
46
|
+
"@umituz/react-native-offline": "latest",
|
|
45
47
|
"@types/react": "~19.1.10",
|
|
46
48
|
"@types/react-native": "^0.73.0",
|
|
47
49
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
@@ -24,7 +24,6 @@ export interface PhotoGenerationConfig<TInput, TResult, TSaveInput> {
|
|
|
24
24
|
generate: (input: TInput) => Promise<TResult>;
|
|
25
25
|
save?: (result: TResult, input: TInput) => Promise<TSaveInput>;
|
|
26
26
|
checkCredits?: () => Promise<boolean>;
|
|
27
|
-
checkNetwork?: () => Promise<boolean>;
|
|
28
27
|
deductCredits?: () => Promise<void>;
|
|
29
28
|
onSuccess?: (result: TResult) => void;
|
|
30
29
|
onError?: (error: PhotoGenerationError) => void;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { useState, useCallback, useRef } from "react";
|
|
7
|
+
import { useOfflineStore } from "@umituz/react-native-offline";
|
|
7
8
|
import type {
|
|
8
9
|
PhotoGenerationConfig,
|
|
9
10
|
PhotoGenerationState,
|
|
@@ -24,7 +25,6 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = any>(
|
|
|
24
25
|
generate: generateFn,
|
|
25
26
|
save: saveFn,
|
|
26
27
|
checkCredits,
|
|
27
|
-
checkNetwork,
|
|
28
28
|
deductCredits,
|
|
29
29
|
onSuccess,
|
|
30
30
|
onError,
|
|
@@ -40,6 +40,7 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = any>(
|
|
|
40
40
|
|
|
41
41
|
const [status, setStatus] = useState<PhotoGenerationStatus>("idle");
|
|
42
42
|
const isGeneratingRef = useRef(false);
|
|
43
|
+
const offlineStore = useOfflineStore();
|
|
43
44
|
|
|
44
45
|
const createError = useCallback(
|
|
45
46
|
(
|
|
@@ -67,11 +68,9 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = any>(
|
|
|
67
68
|
|
|
68
69
|
try {
|
|
69
70
|
// Check network connectivity
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
throw createError("network_error", "No internet connection");
|
|
74
|
-
}
|
|
71
|
+
const isOnline = offlineStore.getState().isOnline;
|
|
72
|
+
if (!isOnline) {
|
|
73
|
+
throw createError("network_error", "No internet connection");
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
// Check credits
|
|
@@ -149,12 +148,12 @@ export const usePhotoGeneration = <TInput, TResult, TSaveInput = any>(
|
|
|
149
148
|
generateFn,
|
|
150
149
|
saveFn,
|
|
151
150
|
checkCredits,
|
|
152
|
-
checkNetwork,
|
|
153
151
|
deductCredits,
|
|
154
152
|
onSuccess,
|
|
155
153
|
onError,
|
|
156
154
|
onSaveComplete,
|
|
157
155
|
createError,
|
|
156
|
+
offlineStore,
|
|
158
157
|
],
|
|
159
158
|
);
|
|
160
159
|
|