@umituz/react-native-ai-generation-content 1.17.24 → 1.17.26

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.
Files changed (86) hide show
  1. package/package.json +1 -1
  2. package/src/domain/interfaces/ai-provider.interface.ts +66 -0
  3. package/src/features/ai-hug/domain/types/ai-hug.types.ts +4 -13
  4. package/src/features/ai-hug/domain/types/index.ts +0 -1
  5. package/src/features/ai-hug/index.ts +1 -6
  6. package/src/features/ai-hug/presentation/components/AIHugFeature.tsx +14 -22
  7. package/src/features/ai-hug/presentation/hooks/useAIHugFeature.ts +16 -35
  8. package/src/features/ai-kiss/domain/types/ai-kiss.types.ts +4 -13
  9. package/src/features/ai-kiss/domain/types/index.ts +0 -1
  10. package/src/features/ai-kiss/index.ts +1 -6
  11. package/src/features/ai-kiss/presentation/components/AIKissFeature.tsx +13 -20
  12. package/src/features/ai-kiss/presentation/hooks/useAIKissFeature.ts +16 -35
  13. package/src/features/anime-selfie/domain/types/anime-selfie.types.ts +0 -8
  14. package/src/features/anime-selfie/domain/types/index.ts +0 -1
  15. package/src/features/anime-selfie/index.ts +0 -5
  16. package/src/features/anime-selfie/presentation/components/AnimeSelfieFeature.tsx +0 -3
  17. package/src/features/anime-selfie/presentation/hooks/useAnimeSelfieFeature.ts +9 -27
  18. package/src/features/face-swap/domain/types/face-swap.types.ts +0 -9
  19. package/src/features/face-swap/domain/types/index.ts +0 -1
  20. package/src/features/face-swap/index.ts +0 -5
  21. package/src/features/face-swap/presentation/components/FaceSwapFeature.tsx +0 -3
  22. package/src/features/face-swap/presentation/hooks/useFaceSwapFeature.ts +9 -28
  23. package/src/features/hd-touch-up/domain/types/hd-touch-up.types.ts +0 -8
  24. package/src/features/hd-touch-up/domain/types/index.ts +0 -1
  25. package/src/features/hd-touch-up/index.ts +0 -5
  26. package/src/features/hd-touch-up/presentation/components/HDTouchUpFeature.tsx +0 -3
  27. package/src/features/hd-touch-up/presentation/hooks/useHDTouchUpFeature.ts +9 -26
  28. package/src/features/photo-restoration/domain/types/index.ts +0 -1
  29. package/src/features/photo-restoration/domain/types/photo-restore.types.ts +0 -8
  30. package/src/features/photo-restoration/index.ts +0 -5
  31. package/src/features/photo-restoration/presentation/components/PhotoRestoreFeature.tsx +0 -4
  32. package/src/features/photo-restoration/presentation/hooks/usePhotoRestoreFeature.ts +9 -26
  33. package/src/features/remove-background/domain/types/index.ts +0 -1
  34. package/src/features/remove-background/domain/types/remove-background.types.ts +0 -8
  35. package/src/features/remove-background/index.ts +0 -5
  36. package/src/features/remove-background/presentation/components/RemoveBackgroundFeature.tsx +0 -3
  37. package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +9 -26
  38. package/src/features/remove-object/domain/types/index.ts +0 -1
  39. package/src/features/remove-object/domain/types/remove-object.types.ts +0 -8
  40. package/src/features/remove-object/index.ts +0 -5
  41. package/src/features/remove-object/presentation/components/RemoveObjectFeature.tsx +0 -3
  42. package/src/features/remove-object/presentation/hooks/useRemoveObjectFeature.ts +9 -24
  43. package/src/features/replace-background/domain/types/index.ts +0 -1
  44. package/src/features/replace-background/domain/types/replace-background.types.ts +0 -9
  45. package/src/features/replace-background/index.ts +55 -82
  46. package/src/features/replace-background/infrastructure/constants/prompts.constants.ts +6 -6
  47. package/src/features/replace-background/infrastructure/index.ts +2 -2
  48. package/src/features/replace-background/presentation/components/ReplaceBackgroundFeature.tsx +0 -3
  49. package/src/features/replace-background/presentation/hooks/useReplaceBackgroundFeature.ts +8 -23
  50. package/src/features/upscaling/domain/types/upscale.types.ts +0 -8
  51. package/src/features/upscaling/index.ts +0 -5
  52. package/src/features/upscaling/presentation/components/UpscaleFeature.tsx +0 -4
  53. package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +8 -23
  54. package/src/index.ts +4 -0
  55. package/src/infrastructure/services/image-feature-executor.service.ts +143 -0
  56. package/src/infrastructure/services/index.ts +20 -0
  57. package/src/infrastructure/services/video-feature-executor.service.ts +140 -0
  58. package/src/features/ai-hug/infrastructure/index.ts +0 -5
  59. package/src/features/ai-hug/infrastructure/services/ai-hug-executor.ts +0 -96
  60. package/src/features/ai-hug/infrastructure/services/index.ts +0 -6
  61. package/src/features/ai-kiss/infrastructure/index.ts +0 -5
  62. package/src/features/ai-kiss/infrastructure/services/ai-kiss-executor.ts +0 -96
  63. package/src/features/ai-kiss/infrastructure/services/index.ts +0 -6
  64. package/src/features/anime-selfie/infrastructure/index.ts +0 -5
  65. package/src/features/anime-selfie/infrastructure/services/anime-selfie-executor.ts +0 -95
  66. package/src/features/anime-selfie/infrastructure/services/index.ts +0 -6
  67. package/src/features/face-swap/infrastructure/index.ts +0 -5
  68. package/src/features/face-swap/infrastructure/services/face-swap-executor.ts +0 -96
  69. package/src/features/face-swap/infrastructure/services/index.ts +0 -6
  70. package/src/features/hd-touch-up/infrastructure/index.ts +0 -1
  71. package/src/features/hd-touch-up/infrastructure/services/hd-touch-up-executor.ts +0 -97
  72. package/src/features/hd-touch-up/infrastructure/services/index.ts +0 -2
  73. package/src/features/photo-restoration/infrastructure/index.ts +0 -1
  74. package/src/features/photo-restoration/infrastructure/services/index.ts +0 -2
  75. package/src/features/photo-restoration/infrastructure/services/photo-restore-executor.ts +0 -98
  76. package/src/features/remove-background/infrastructure/index.ts +0 -5
  77. package/src/features/remove-background/infrastructure/services/index.ts +0 -6
  78. package/src/features/remove-background/infrastructure/services/remove-background-executor.ts +0 -95
  79. package/src/features/remove-object/infrastructure/index.ts +0 -5
  80. package/src/features/remove-object/infrastructure/services/index.ts +0 -6
  81. package/src/features/remove-object/infrastructure/services/remove-object-executor.ts +0 -99
  82. package/src/features/replace-background/infrastructure/services/index.ts +0 -6
  83. package/src/features/replace-background/infrastructure/services/replace-background-executor.ts +0 -95
  84. package/src/features/upscaling/infrastructure/index.ts +0 -1
  85. package/src/features/upscaling/infrastructure/services/index.ts +0 -2
  86. package/src/features/upscaling/infrastructure/services/upscale-executor.ts +0 -98
@@ -1,95 +0,0 @@
1
- /**
2
- * Anime Selfie Executor
3
- * Provider-agnostic anime selfie execution using active AI provider
4
- * Model and input format are provided via options from app level
5
- */
6
-
7
- import { providerRegistry } from "../../../../infrastructure/services";
8
- import { cleanBase64 } from "../../../../infrastructure/utils";
9
- import type {
10
- AnimeSelfieRequest,
11
- AnimeSelfieResult,
12
- AnimeSelfieInputBuilder,
13
- AnimeSelfieResultExtractor,
14
- } from "../../domain/types";
15
-
16
- declare const __DEV__: boolean;
17
-
18
- export interface ExecuteAnimeSelfieOptions {
19
- model: string;
20
- buildInput: AnimeSelfieInputBuilder;
21
- extractResult?: AnimeSelfieResultExtractor;
22
- onProgress?: (progress: number) => void;
23
- }
24
-
25
- function defaultExtractResult(result: unknown): string | undefined {
26
- if (typeof result !== "object" || result === null) return undefined;
27
-
28
- const r = result as Record<string, unknown>;
29
-
30
- if (typeof r.image === "string") return r.image;
31
- if (Array.isArray(r.images) && r.images[0]?.url) return r.images[0].url;
32
-
33
- return undefined;
34
- }
35
-
36
- export async function executeAnimeSelfie(
37
- request: AnimeSelfieRequest,
38
- options: ExecuteAnimeSelfieOptions,
39
- ): Promise<AnimeSelfieResult> {
40
- const provider = providerRegistry.getActiveProvider();
41
-
42
- if (!provider) {
43
- return { success: false, error: "No AI provider configured" };
44
- }
45
-
46
- if (!provider.isInitialized()) {
47
- return { success: false, error: "AI provider not initialized" };
48
- }
49
-
50
- if (!request.imageBase64) {
51
- return { success: false, error: "Image base64 is required" };
52
- }
53
-
54
- const { model, buildInput, extractResult, onProgress } = options;
55
-
56
- if (__DEV__) {
57
- // eslint-disable-next-line no-console
58
- console.log(`[AnimeSelfie] Provider: ${provider.providerId}, Model: ${model}`);
59
- }
60
-
61
- try {
62
- onProgress?.(10);
63
-
64
- const base64 = cleanBase64(request.imageBase64);
65
- onProgress?.(30);
66
-
67
- const input = buildInput(base64, request.options);
68
- onProgress?.(40);
69
-
70
- const result = await provider.run(model, input);
71
- onProgress?.(90);
72
-
73
- const extractor = extractResult || defaultExtractResult;
74
- const imageUrl = extractor(result);
75
- onProgress?.(100);
76
-
77
- if (!imageUrl) {
78
- return { success: false, error: "No image in response" };
79
- }
80
-
81
- return { success: true, imageUrl };
82
- } catch (error) {
83
- const message = error instanceof Error ? error.message : String(error);
84
- if (__DEV__) {
85
- // eslint-disable-next-line no-console
86
- console.error("[AnimeSelfie] Error:", message);
87
- }
88
- return { success: false, error: message };
89
- }
90
- }
91
-
92
- export function hasAnimeSelfieSupport(): boolean {
93
- const provider = providerRegistry.getActiveProvider();
94
- return provider !== null && provider.isInitialized();
95
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Anime Selfie Infrastructure Services Index
3
- */
4
-
5
- export { executeAnimeSelfie, hasAnimeSelfieSupport } from "./anime-selfie-executor";
6
- export type { ExecuteAnimeSelfieOptions } from "./anime-selfie-executor";
@@ -1,5 +0,0 @@
1
- /**
2
- * Face Swap Infrastructure Index
3
- */
4
-
5
- export * from "./services";
@@ -1,96 +0,0 @@
1
- /**
2
- * Face Swap Executor
3
- * Provider-agnostic face swap execution using active AI provider
4
- * Model and input format are provided via options from app level
5
- */
6
-
7
- import { providerRegistry } from "../../../../infrastructure/services";
8
- import { cleanBase64 } from "../../../../infrastructure/utils";
9
- import type {
10
- FaceSwapRequest,
11
- FaceSwapResult,
12
- FaceSwapInputBuilder,
13
- FaceSwapResultExtractor,
14
- } from "../../domain/types";
15
-
16
- declare const __DEV__: boolean;
17
-
18
- export interface ExecuteFaceSwapOptions {
19
- model: string;
20
- buildInput: FaceSwapInputBuilder;
21
- extractResult?: FaceSwapResultExtractor;
22
- onProgress?: (progress: number) => void;
23
- }
24
-
25
- function defaultExtractResult(result: unknown): string | undefined {
26
- if (typeof result !== "object" || result === null) return undefined;
27
-
28
- const r = result as Record<string, unknown>;
29
-
30
- if (typeof r.image === "string") return r.image;
31
- if (Array.isArray(r.images) && r.images[0]?.url) return r.images[0].url;
32
-
33
- return undefined;
34
- }
35
-
36
- export async function executeFaceSwap(
37
- request: FaceSwapRequest,
38
- options: ExecuteFaceSwapOptions,
39
- ): Promise<FaceSwapResult> {
40
- const provider = providerRegistry.getActiveProvider();
41
-
42
- if (!provider) {
43
- return { success: false, error: "No AI provider configured" };
44
- }
45
-
46
- if (!provider.isInitialized()) {
47
- return { success: false, error: "AI provider not initialized" };
48
- }
49
-
50
- if (!request.sourceImageBase64 || !request.targetImageBase64) {
51
- return { success: false, error: "Both source and target image base64 are required" };
52
- }
53
-
54
- const { model, buildInput, extractResult, onProgress } = options;
55
-
56
- if (__DEV__) {
57
- // eslint-disable-next-line no-console
58
- console.log(`[FaceSwap] Provider: ${provider.providerId}, Model: ${model}`);
59
- }
60
-
61
- try {
62
- onProgress?.(10);
63
-
64
- const sourceBase64 = cleanBase64(request.sourceImageBase64);
65
- const targetBase64 = cleanBase64(request.targetImageBase64);
66
- onProgress?.(30);
67
-
68
- const input = buildInput(sourceBase64, targetBase64, request.options);
69
- onProgress?.(40);
70
-
71
- const result = await provider.run(model, input);
72
- onProgress?.(90);
73
-
74
- const extractor = extractResult || defaultExtractResult;
75
- const imageUrl = extractor(result);
76
- onProgress?.(100);
77
-
78
- if (!imageUrl) {
79
- return { success: false, error: "No image in response" };
80
- }
81
-
82
- return { success: true, imageUrl };
83
- } catch (error) {
84
- const message = error instanceof Error ? error.message : String(error);
85
- if (__DEV__) {
86
- // eslint-disable-next-line no-console
87
- console.error("[FaceSwap] Error:", message);
88
- }
89
- return { success: false, error: message };
90
- }
91
- }
92
-
93
- export function hasFaceSwapSupport(): boolean {
94
- const provider = providerRegistry.getActiveProvider();
95
- return provider !== null && provider.isInitialized();
96
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Face Swap Infrastructure Services Index
3
- */
4
-
5
- export { executeFaceSwap, hasFaceSwapSupport } from "./face-swap-executor";
6
- export type { ExecuteFaceSwapOptions } from "./face-swap-executor";
@@ -1 +0,0 @@
1
- export * from "./services";
@@ -1,97 +0,0 @@
1
- /**
2
- * HD Touch Up Executor
3
- * Executes HD enhancement using the configured provider
4
- */
5
-
6
- import { providerRegistry } from "../../../../infrastructure/services";
7
- import type {
8
- HDTouchUpRequest,
9
- HDTouchUpResult,
10
- HDTouchUpInputBuilder,
11
- HDTouchUpResultExtractor,
12
- } from "../../domain/types";
13
-
14
- declare const __DEV__: boolean;
15
-
16
- export interface ExecuteHDTouchUpOptions {
17
- model: string;
18
- buildInput: HDTouchUpInputBuilder;
19
- extractResult?: HDTouchUpResultExtractor;
20
- onProgress?: (progress: number) => void;
21
- }
22
-
23
- export async function executeHDTouchUp(
24
- request: HDTouchUpRequest,
25
- options: ExecuteHDTouchUpOptions,
26
- ): Promise<HDTouchUpResult> {
27
- const { model, buildInput, extractResult, onProgress } = options;
28
-
29
- try {
30
- const provider = providerRegistry.getActiveProvider();
31
- if (!provider) {
32
- return {
33
- success: false,
34
- error: "No AI provider configured",
35
- };
36
- }
37
-
38
- if (__DEV__) {
39
- // eslint-disable-next-line no-console
40
- console.log("[HDTouchUp] Starting HD enhancement with model:", model);
41
- }
42
-
43
- onProgress?.(10);
44
-
45
- const imageBase64 = request.imageBase64;
46
- if (!imageBase64) {
47
- return {
48
- success: false,
49
- error: "Image base64 is required",
50
- };
51
- }
52
-
53
- const input = buildInput(imageBase64, request.options);
54
-
55
- onProgress?.(30);
56
-
57
- const result = await provider.run(model, input);
58
-
59
- onProgress?.(80);
60
-
61
- const imageUrl = extractResult
62
- ? extractResult(result)
63
- : (result as { imageUrl?: string })?.imageUrl ||
64
- (result as { image?: string })?.image ||
65
- (result as { output?: string })?.output;
66
-
67
- onProgress?.(100);
68
-
69
- if (imageUrl) {
70
- return {
71
- success: true,
72
- imageUrl,
73
- requestId: (result as { requestId?: string })?.requestId,
74
- };
75
- }
76
-
77
- return {
78
- success: false,
79
- error: "No image URL in response",
80
- };
81
- } catch (error) {
82
- const message = error instanceof Error ? error.message : String(error);
83
- if (__DEV__) {
84
- // eslint-disable-next-line no-console
85
- console.error("[HDTouchUp] Error:", message);
86
- }
87
- return {
88
- success: false,
89
- error: message,
90
- };
91
- }
92
- }
93
-
94
- export function hasHDTouchUpSupport(): boolean {
95
- const provider = providerRegistry.getActiveProvider();
96
- return !!provider;
97
- }
@@ -1,2 +0,0 @@
1
- export { executeHDTouchUp, hasHDTouchUpSupport } from "./hd-touch-up-executor";
2
- export type { ExecuteHDTouchUpOptions } from "./hd-touch-up-executor";
@@ -1 +0,0 @@
1
- export * from "./services";
@@ -1,2 +0,0 @@
1
- export { executePhotoRestore, hasPhotoRestoreSupport } from "./photo-restore-executor";
2
- export type { ExecutePhotoRestoreOptions } from "./photo-restore-executor";
@@ -1,98 +0,0 @@
1
- /**
2
- * Photo Restore Executor
3
- * Provider-agnostic photo restore execution using active AI provider
4
- * Model and input format are provided via options from app level
5
- *
6
- * Note: imageBase64 must be provided in the request. Image URI to base64
7
- * conversion should be handled at the app level before calling this executor.
8
- */
9
-
10
- import { providerRegistry } from "../../../../infrastructure/services";
11
- import { cleanBase64 } from "../../../../infrastructure/utils";
12
- import type {
13
- PhotoRestoreRequest,
14
- PhotoRestoreResult,
15
- PhotoRestoreInputBuilder,
16
- PhotoRestoreResultExtractor,
17
- } from "../../domain/types";
18
-
19
- declare const __DEV__: boolean;
20
-
21
- export interface ExecutePhotoRestoreOptions {
22
- model: string;
23
- buildInput: PhotoRestoreInputBuilder;
24
- extractResult?: PhotoRestoreResultExtractor;
25
- onProgress?: (progress: number) => void;
26
- }
27
-
28
- function defaultExtractResult(result: unknown): string | undefined {
29
- if (typeof result !== "object" || result === null) return undefined;
30
-
31
- const r = result as Record<string, unknown>;
32
-
33
- if (typeof r.image === "string") return r.image;
34
- if (Array.isArray(r.images) && r.images[0]?.url) return r.images[0].url;
35
-
36
- return undefined;
37
- }
38
-
39
- export async function executePhotoRestore(
40
- request: PhotoRestoreRequest,
41
- options: ExecutePhotoRestoreOptions,
42
- ): Promise<PhotoRestoreResult> {
43
- const provider = providerRegistry.getActiveProvider();
44
-
45
- if (!provider) {
46
- return { success: false, error: "No AI provider configured" };
47
- }
48
-
49
- if (!provider.isInitialized()) {
50
- return { success: false, error: "AI provider not initialized" };
51
- }
52
-
53
- if (!request.imageBase64) {
54
- return { success: false, error: "Image base64 is required" };
55
- }
56
-
57
- const { model, buildInput, extractResult, onProgress } = options;
58
-
59
- if (__DEV__) {
60
- // eslint-disable-next-line no-console
61
- console.log(`[PhotoRestore] Provider: ${provider.providerId}, Model: ${model}`);
62
- }
63
-
64
- try {
65
- onProgress?.(10);
66
-
67
- const base64 = cleanBase64(request.imageBase64);
68
- onProgress?.(30);
69
-
70
- const input = buildInput(base64, request.options);
71
- onProgress?.(40);
72
-
73
- const result = await provider.run(model, input);
74
- onProgress?.(90);
75
-
76
- const extractor = extractResult || defaultExtractResult;
77
- const imageUrl = extractor(result);
78
- onProgress?.(100);
79
-
80
- if (!imageUrl) {
81
- return { success: false, error: "No image in response" };
82
- }
83
-
84
- return { success: true, imageUrl };
85
- } catch (error) {
86
- const message = error instanceof Error ? error.message : String(error);
87
- if (__DEV__) {
88
- // eslint-disable-next-line no-console
89
- console.error("[PhotoRestore] Error:", message);
90
- }
91
- return { success: false, error: message };
92
- }
93
- }
94
-
95
- export function hasPhotoRestoreSupport(): boolean {
96
- const provider = providerRegistry.getActiveProvider();
97
- return provider !== null && provider.isInitialized();
98
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Remove Background Infrastructure Index
3
- */
4
-
5
- export * from "./services";
@@ -1,6 +0,0 @@
1
- /**
2
- * Remove Background Infrastructure Services Index
3
- */
4
-
5
- export { executeRemoveBackground, hasRemoveBackgroundSupport } from "./remove-background-executor";
6
- export type { ExecuteRemoveBackgroundOptions } from "./remove-background-executor";
@@ -1,95 +0,0 @@
1
- /**
2
- * Remove Background Executor
3
- * Provider-agnostic background removal execution using active AI provider
4
- * Model and input format are provided via options from app level
5
- */
6
-
7
- import { providerRegistry } from "../../../../infrastructure/services";
8
- import { cleanBase64 } from "../../../../infrastructure/utils";
9
- import type {
10
- RemoveBackgroundRequest,
11
- RemoveBackgroundResult,
12
- RemoveBackgroundInputBuilder,
13
- RemoveBackgroundResultExtractor,
14
- } from "../../domain/types";
15
-
16
- declare const __DEV__: boolean;
17
-
18
- export interface ExecuteRemoveBackgroundOptions {
19
- model: string;
20
- buildInput: RemoveBackgroundInputBuilder;
21
- extractResult?: RemoveBackgroundResultExtractor;
22
- onProgress?: (progress: number) => void;
23
- }
24
-
25
- function defaultExtractResult(result: unknown): string | undefined {
26
- if (typeof result !== "object" || result === null) return undefined;
27
-
28
- const r = result as Record<string, unknown>;
29
-
30
- if (typeof r.image === "string") return r.image;
31
- if (Array.isArray(r.images) && r.images[0]?.url) return r.images[0].url;
32
-
33
- return undefined;
34
- }
35
-
36
- export async function executeRemoveBackground(
37
- request: RemoveBackgroundRequest,
38
- options: ExecuteRemoveBackgroundOptions,
39
- ): Promise<RemoveBackgroundResult> {
40
- const provider = providerRegistry.getActiveProvider();
41
-
42
- if (!provider) {
43
- return { success: false, error: "No AI provider configured" };
44
- }
45
-
46
- if (!provider.isInitialized()) {
47
- return { success: false, error: "AI provider not initialized" };
48
- }
49
-
50
- if (!request.imageBase64) {
51
- return { success: false, error: "Image base64 is required" };
52
- }
53
-
54
- const { model, buildInput, extractResult, onProgress } = options;
55
-
56
- if (__DEV__) {
57
- // eslint-disable-next-line no-console
58
- console.log(`[RemoveBackground] Provider: ${provider.providerId}, Model: ${model}`);
59
- }
60
-
61
- try {
62
- onProgress?.(10);
63
-
64
- const base64 = cleanBase64(request.imageBase64);
65
- onProgress?.(30);
66
-
67
- const input = buildInput(base64, request.options);
68
- onProgress?.(40);
69
-
70
- const result = await provider.run(model, input);
71
- onProgress?.(90);
72
-
73
- const extractor = extractResult || defaultExtractResult;
74
- const imageUrl = extractor(result);
75
- onProgress?.(100);
76
-
77
- if (!imageUrl) {
78
- return { success: false, error: "No image in response" };
79
- }
80
-
81
- return { success: true, imageUrl };
82
- } catch (error) {
83
- const message = error instanceof Error ? error.message : String(error);
84
- if (__DEV__) {
85
- // eslint-disable-next-line no-console
86
- console.error("[RemoveBackground] Error:", message);
87
- }
88
- return { success: false, error: message };
89
- }
90
- }
91
-
92
- export function hasRemoveBackgroundSupport(): boolean {
93
- const provider = providerRegistry.getActiveProvider();
94
- return provider !== null && provider.isInitialized();
95
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Remove Object Infrastructure Index
3
- */
4
-
5
- export * from "./services";
@@ -1,6 +0,0 @@
1
- /**
2
- * Remove Object Infrastructure Services Index
3
- */
4
-
5
- export { executeRemoveObject, hasRemoveObjectSupport } from "./remove-object-executor";
6
- export type { ExecuteRemoveObjectOptions } from "./remove-object-executor";
@@ -1,99 +0,0 @@
1
- /**
2
- * Remove Object Executor
3
- * Provider-agnostic object removal execution using active AI provider
4
- * Model and input format are provided via options from app level
5
- */
6
-
7
- import { providerRegistry } from "../../../../infrastructure/services";
8
- import { cleanBase64 } from "../../../../infrastructure/utils";
9
- import type {
10
- RemoveObjectRequest,
11
- RemoveObjectResult,
12
- RemoveObjectInputBuilder,
13
- RemoveObjectResultExtractor,
14
- } from "../../domain/types";
15
-
16
- declare const __DEV__: boolean;
17
-
18
- export interface ExecuteRemoveObjectOptions {
19
- model: string;
20
- buildInput: RemoveObjectInputBuilder;
21
- extractResult?: RemoveObjectResultExtractor;
22
- onProgress?: (progress: number) => void;
23
- }
24
-
25
- function defaultExtractResult(result: unknown): string | undefined {
26
- if (typeof result !== "object" || result === null) return undefined;
27
-
28
- const r = result as Record<string, unknown>;
29
-
30
- if (typeof r.image === "string") return r.image;
31
- if (Array.isArray(r.images) && r.images[0]?.url) return r.images[0].url;
32
-
33
- return undefined;
34
- }
35
-
36
- export async function executeRemoveObject(
37
- request: RemoveObjectRequest,
38
- options: ExecuteRemoveObjectOptions,
39
- ): Promise<RemoveObjectResult> {
40
- const provider = providerRegistry.getActiveProvider();
41
-
42
- if (!provider) {
43
- return { success: false, error: "No AI provider configured" };
44
- }
45
-
46
- if (!provider.isInitialized()) {
47
- return { success: false, error: "AI provider not initialized" };
48
- }
49
-
50
- if (!request.imageBase64) {
51
- return { success: false, error: "Image base64 is required" };
52
- }
53
-
54
- const { model, buildInput, extractResult, onProgress } = options;
55
-
56
- if (__DEV__) {
57
- // eslint-disable-next-line no-console
58
- console.log(`[RemoveObject] Provider: ${provider.providerId}, Model: ${model}`);
59
- }
60
-
61
- try {
62
- onProgress?.(10);
63
-
64
- const base64 = cleanBase64(request.imageBase64);
65
- onProgress?.(30);
66
-
67
- const input = buildInput(base64, {
68
- maskBase64: request.maskBase64,
69
- prompt: request.prompt,
70
- ...request.options,
71
- });
72
- onProgress?.(40);
73
-
74
- const result = await provider.run(model, input);
75
- onProgress?.(90);
76
-
77
- const extractor = extractResult || defaultExtractResult;
78
- const imageUrl = extractor(result);
79
- onProgress?.(100);
80
-
81
- if (!imageUrl) {
82
- return { success: false, error: "No image in response" };
83
- }
84
-
85
- return { success: true, imageUrl };
86
- } catch (error) {
87
- const message = error instanceof Error ? error.message : String(error);
88
- if (__DEV__) {
89
- // eslint-disable-next-line no-console
90
- console.error("[RemoveObject] Error:", message);
91
- }
92
- return { success: false, error: message };
93
- }
94
- }
95
-
96
- export function hasRemoveObjectSupport(): boolean {
97
- const provider = providerRegistry.getActiveProvider();
98
- return provider !== null && provider.isInitialized();
99
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Background Infrastructure Services Index
3
- */
4
-
5
- export { executeReplaceBackground, hasReplaceBackgroundSupport } from "./replace-background-executor";
6
- export type { ExecuteReplaceBackgroundOptions } from "./replace-background-executor";