@umituz/react-native-ai-generation-content 1.26.60 → 1.26.61
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.26.
|
|
3
|
+
"version": "1.26.61",
|
|
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",
|
|
@@ -75,8 +75,8 @@ export const useGenerationOrchestrator = <TInput, TResult>(
|
|
|
75
75
|
// Wrap credit hook to match expected interface
|
|
76
76
|
const defaultCredits = {
|
|
77
77
|
checkCredits: creditHook.checkCredits,
|
|
78
|
-
deductCredit: async (amount: number) => {
|
|
79
|
-
|
|
78
|
+
deductCredit: async (amount: number): Promise<boolean> => {
|
|
79
|
+
return creditHook.deductCredit(amount);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
|
|
@@ -216,7 +216,16 @@ export const useGenerationOrchestrator = <TInput, TResult>(
|
|
|
216
216
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
217
217
|
console.log("[Orchestrator] 💳 Deducting credit:", creditCost);
|
|
218
218
|
}
|
|
219
|
-
await deductCredit(creditCost);
|
|
219
|
+
const creditDeducted = await deductCredit(creditCost);
|
|
220
|
+
if (!creditDeducted) {
|
|
221
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
222
|
+
console.log("[Orchestrator] ❌ Credit deduction failed");
|
|
223
|
+
}
|
|
224
|
+
throw createGenerationError("credits", "Failed to deduct credits");
|
|
225
|
+
}
|
|
226
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
227
|
+
console.log("[Orchestrator] ✅ Credit deducted successfully");
|
|
228
|
+
}
|
|
220
229
|
|
|
221
230
|
// Success
|
|
222
231
|
if (isMountedRef.current) {
|
|
@@ -65,8 +65,8 @@ export interface ModerationCallbacks {
|
|
|
65
65
|
export interface CreditCallbacks {
|
|
66
66
|
/** Check if user can afford the cost */
|
|
67
67
|
checkCredits: (cost: number) => Promise<boolean>;
|
|
68
|
-
/** Deduct credits after successful generation */
|
|
69
|
-
deductCredits: (cost: number) => Promise<
|
|
68
|
+
/** Deduct credits after successful generation - returns true if successful */
|
|
69
|
+
deductCredits: (cost: number) => Promise<boolean>;
|
|
70
70
|
/** Called when credits are exhausted */
|
|
71
71
|
onCreditsExhausted?: () => void;
|
|
72
72
|
}
|