@umituz/react-native-ai-generation-content 1.26.2 → 1.26.4
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 +3 -2
- package/src/domains/generation/application/feature-registry.ts +101 -0
- package/src/domains/generation/application/generation-strategy.factory.ts +128 -0
- package/src/domains/generation/domain/feature-config.types.ts +61 -0
- package/src/domains/generation/domain/generation.types.ts +74 -0
- package/src/domains/generation/index.ts +37 -0
- package/src/domains/generation/presentation/useAIGeneration.hook.ts +106 -0
- package/src/domains/wizard/infrastructure/strategies/wizard-strategy.factory.ts +3 -4
- package/src/index.ts +1 -25
- package/src/infrastructure/executors/executor-factory.ts +53 -0
- package/src/infrastructure/executors/image-executor.ts +133 -0
- package/src/infrastructure/executors/video-executor.ts +130 -0
- package/src/features/ai-hug/README.md +0 -438
- package/src/features/ai-hug/domain/index.ts +0 -5
- package/src/features/ai-hug/domain/types/ai-hug.types.ts +0 -25
- package/src/features/ai-hug/domain/types/index.ts +0 -7
- package/src/features/ai-hug/index.ts +0 -19
- package/src/features/ai-hug/presentation/components/AIHugFeature.tsx +0 -77
- package/src/features/ai-hug/presentation/components/index.ts +0 -2
- package/src/features/ai-hug/presentation/hooks/index.ts +0 -9
- package/src/features/ai-hug/presentation/hooks/useAIHugFeature.ts +0 -34
- package/src/features/ai-hug/presentation/index.ts +0 -6
- package/src/features/ai-kiss/README.md +0 -445
- package/src/features/ai-kiss/domain/index.ts +0 -5
- package/src/features/ai-kiss/domain/types/ai-kiss.types.ts +0 -25
- package/src/features/ai-kiss/domain/types/index.ts +0 -7
- package/src/features/ai-kiss/index.ts +0 -19
- package/src/features/ai-kiss/presentation/components/AIKissFeature.tsx +0 -77
- package/src/features/ai-kiss/presentation/components/index.ts +0 -2
- package/src/features/ai-kiss/presentation/hooks/index.ts +0 -9
- package/src/features/ai-kiss/presentation/hooks/useAIKissFeature.ts +0 -34
- package/src/features/ai-kiss/presentation/index.ts +0 -6
- package/src/features/anime-selfie/README.md +0 -396
- package/src/features/anime-selfie/domain/index.ts +0 -5
- package/src/features/anime-selfie/domain/types/anime-selfie.types.ts +0 -52
- package/src/features/anime-selfie/domain/types/index.ts +0 -8
- package/src/features/anime-selfie/index.ts +0 -20
- package/src/features/anime-selfie/presentation/components/AnimeSelfieFeature.tsx +0 -86
- package/src/features/anime-selfie/presentation/components/index.ts +0 -2
- package/src/features/anime-selfie/presentation/hooks/index.ts +0 -9
- package/src/features/anime-selfie/presentation/hooks/useAnimeSelfieFeature.ts +0 -59
- package/src/features/anime-selfie/presentation/index.ts +0 -6
- package/src/features/couple-future/README.md +0 -445
- package/src/features/couple-future/domain/types.ts +0 -63
- package/src/features/couple-future/domain/wizard-config.adapter.ts +0 -76
- package/src/features/couple-future/domain/wizard.types.ts +0 -121
- package/src/features/couple-future/index.ts +0 -83
- package/src/features/couple-future/infrastructure/coupleFeatureRegistry.ts +0 -76
- package/src/features/couple-future/infrastructure/couplePromptEnhancer.ts +0 -100
- package/src/features/couple-future/infrastructure/executor.ts +0 -188
- package/src/features/couple-future/infrastructure/generationUtils.ts +0 -228
- package/src/features/couple-future/presentation/components/ArtStyleSelector.tsx +0 -146
- package/src/features/couple-future/presentation/components/ArtistStyleSelector.tsx +0 -122
- package/src/features/couple-future/presentation/components/CoupleFutureWizard.tsx +0 -239
- package/src/features/couple-future/presentation/components/GeneratingStepContent.tsx +0 -86
- package/src/features/couple-future/presentation/components/RomanticMoodSelector.tsx +0 -147
- package/src/features/couple-future/presentation/components/WardrobeSelector.tsx +0 -141
- package/src/features/couple-future/presentation/components/index.ts +0 -12
- package/src/features/couple-future/presentation/hooks/useCoupleFutureFlow.ts +0 -166
- package/src/features/couple-future/presentation/hooks/useCoupleFutureFlow.types.ts +0 -69
- package/src/features/couple-future/presentation/hooks/useCoupleFutureHandlers.ts +0 -117
- package/src/features/couple-future/presentation/screens/CoupleFeatureScreen.tsx +0 -113
- package/src/features/face-swap/README.md +0 -431
- package/src/features/face-swap/domain/index.ts +0 -5
- package/src/features/face-swap/domain/types/face-swap.types.ts +0 -26
- package/src/features/face-swap/domain/types/index.ts +0 -7
- package/src/features/face-swap/index.ts +0 -19
- package/src/features/face-swap/presentation/components/FaceSwapFeature.tsx +0 -87
- package/src/features/face-swap/presentation/components/index.ts +0 -2
- package/src/features/face-swap/presentation/hooks/index.ts +0 -6
- package/src/features/face-swap/presentation/hooks/useFaceSwapFeature.ts +0 -35
- package/src/features/face-swap/presentation/index.ts +0 -6
- package/src/features/hd-touch-up/README.md +0 -396
- package/src/features/hd-touch-up/domain/index.ts +0 -1
- package/src/features/hd-touch-up/domain/types/hd-touch-up.types.ts +0 -62
- package/src/features/hd-touch-up/domain/types/index.ts +0 -9
- package/src/features/hd-touch-up/index.ts +0 -21
- package/src/features/hd-touch-up/presentation/components/HDTouchUpFeature.tsx +0 -86
- package/src/features/hd-touch-up/presentation/components/index.ts +0 -2
- package/src/features/hd-touch-up/presentation/hooks/index.ts +0 -1
- package/src/features/hd-touch-up/presentation/hooks/useHDTouchUpFeature.ts +0 -23
- package/src/features/hd-touch-up/presentation/index.ts +0 -2
- package/src/features/image-to-image/README.md +0 -459
- package/src/features/image-to-image/domain/index.ts +0 -1
- package/src/features/image-to-image/domain/types/base.types.ts +0 -48
- package/src/features/image-to-image/domain/types/index.ts +0 -1
- package/src/features/image-to-image/domain/types/partials/config.types.ts +0 -37
- package/src/features/image-to-image/domain/types/partials/hook.types.ts +0 -53
- package/src/features/image-to-image/domain/types/partials/metadata.types.ts +0 -32
- package/src/features/image-to-image/domain/types/partials/result.types.ts +0 -44
- package/src/features/image-to-image/domain/types/partials/state.types.ts +0 -34
- package/src/features/image-to-image/domain/types/partials/translation.types.ts +0 -57
- package/src/features/image-to-image/index.ts +0 -2
- package/src/features/image-to-image/presentation/hooks/index.ts +0 -3
- package/src/features/image-to-image/presentation/hooks/useDualImageFeature.ts +0 -204
- package/src/features/image-to-image/presentation/hooks/useImageWithPromptFeature.ts +0 -223
- package/src/features/image-to-image/presentation/hooks/useSingleImageFeature.ts +0 -166
- package/src/features/image-to-image/presentation/index.ts +0 -1
- package/src/features/image-to-video/README.md +0 -414
- package/src/features/image-to-video/domain/constants/animation.constants.ts +0 -47
- package/src/features/image-to-video/domain/constants/duration.constants.ts +0 -13
- package/src/features/image-to-video/domain/constants/form.constants.ts +0 -22
- package/src/features/image-to-video/domain/constants/index.ts +0 -23
- package/src/features/image-to-video/domain/constants/music.constants.ts +0 -53
- package/src/features/image-to-video/domain/index.ts +0 -5
- package/src/features/image-to-video/domain/types/animation.types.ts +0 -20
- package/src/features/image-to-video/domain/types/config.types.ts +0 -56
- package/src/features/image-to-video/domain/types/duration.types.ts +0 -11
- package/src/features/image-to-video/domain/types/form.types.ts +0 -35
- package/src/features/image-to-video/domain/types/image-to-video.types.ts +0 -122
- package/src/features/image-to-video/domain/types/index.ts +0 -39
- package/src/features/image-to-video/domain/types/music.types.ts +0 -21
- package/src/features/image-to-video/index.ts +0 -116
- package/src/features/image-to-video/infrastructure/index.ts +0 -1
- package/src/features/image-to-video/infrastructure/services/image-to-video-executor.ts +0 -154
- package/src/features/image-to-video/infrastructure/services/index.ts +0 -5
- package/src/features/image-to-video/presentation/components/AddMoreCard.tsx +0 -52
- package/src/features/image-to-video/presentation/components/AnimationStyleSelector.tsx +0 -135
- package/src/features/image-to-video/presentation/components/DurationSelector.tsx +0 -110
- package/src/features/image-to-video/presentation/components/EmptyGridState.tsx +0 -69
- package/src/features/image-to-video/presentation/components/GridImageItem.tsx +0 -64
- package/src/features/image-to-video/presentation/components/ImageSelectionGrid.styles.ts +0 -84
- package/src/features/image-to-video/presentation/components/ImageSelectionGrid.tsx +0 -77
- package/src/features/image-to-video/presentation/components/ImageSelectionGrid.types.ts +0 -18
- package/src/features/image-to-video/presentation/components/MusicMoodSelector.tsx +0 -181
- package/src/features/image-to-video/presentation/components/index.ts +0 -30
- package/src/features/image-to-video/presentation/hooks/index.ts +0 -27
- package/src/features/image-to-video/presentation/hooks/useFormState.ts +0 -116
- package/src/features/image-to-video/presentation/hooks/useGeneration.ts +0 -85
- package/src/features/image-to-video/presentation/hooks/useGenerationExecution.ts +0 -143
- package/src/features/image-to-video/presentation/hooks/useImageToVideoFeature.ts +0 -107
- package/src/features/image-to-video/presentation/hooks/useImageToVideoForm.ts +0 -119
- package/src/features/image-to-video/presentation/hooks/useImageToVideoValidation.ts +0 -46
- package/src/features/image-to-video/presentation/index.ts +0 -5
- package/src/features/love-message/domain/constants.ts +0 -162
- package/src/features/love-message/domain/types.ts +0 -58
- package/src/features/love-message/index.ts +0 -37
- package/src/features/love-message/infrastructure/persistence/PartnerProfileRepository.ts +0 -52
- package/src/features/love-message/infrastructure/prompts/messagePromptBuilder.ts +0 -109
- package/src/features/love-message/infrastructure/services/LoveMessageService.ts +0 -35
- package/src/features/love-message/presentation/components/CategoryGrid.tsx +0 -88
- package/src/features/love-message/presentation/components/DetailsInput.tsx +0 -74
- package/src/features/love-message/presentation/components/ExploreHeader.tsx +0 -67
- package/src/features/love-message/presentation/components/FieldInput.tsx +0 -83
- package/src/features/love-message/presentation/components/GeneratorHeader.tsx +0 -88
- package/src/features/love-message/presentation/components/LoveMessageHeroSection.tsx +0 -114
- package/src/features/love-message/presentation/components/MessageListItem.tsx +0 -77
- package/src/features/love-message/presentation/components/MessageResult.tsx +0 -105
- package/src/features/love-message/presentation/components/PartnerInput.tsx +0 -78
- package/src/features/love-message/presentation/components/ProgressDots.tsx +0 -48
- package/src/features/love-message/presentation/components/StepDetails.tsx +0 -23
- package/src/features/love-message/presentation/components/StepPartner.tsx +0 -116
- package/src/features/love-message/presentation/components/StepVibe.tsx +0 -30
- package/src/features/love-message/presentation/components/ToneSelector.tsx +0 -100
- package/src/features/love-message/presentation/components/TrendingSection.tsx +0 -130
- package/src/features/love-message/presentation/components/TypeSelector.tsx +0 -99
- package/src/features/love-message/presentation/hooks/useLoveMessageGenerator.ts +0 -114
- package/src/features/love-message/presentation/hooks/usePartnerProfile.ts +0 -43
- package/src/features/love-message/presentation/navigation/LoveMessageStack.tsx +0 -39
- package/src/features/love-message/presentation/screens/LoveMessageExploreScreen.tsx +0 -53
- package/src/features/love-message/presentation/screens/LoveMessageGeneratorScreen.tsx +0 -169
- package/src/features/love-message/presentation/screens/MessageListScreen.tsx +0 -127
- package/src/features/love-message/presentation/screens/PartnerProfileScreen.tsx +0 -119
- package/src/features/meme-generator/README.md +0 -408
- package/src/features/meme-generator/index.ts +0 -3
- package/src/features/meme-generator/infrastructure/services/MemeGenerationService.ts +0 -87
- package/src/features/meme-generator/presentation/components/MemeGeneratorFeature.tsx +0 -180
- package/src/features/meme-generator/presentation/components/index.ts +0 -2
- package/src/features/meme-generator/presentation/screens/MemeGeneratorScreen.tsx +0 -168
- package/src/features/meme-generator/presentation/screens/index.ts +0 -1
- package/src/features/partner-upload/domain/types.ts +0 -59
- package/src/features/partner-upload/index.ts +0 -30
- package/src/features/partner-upload/presentation/components/PartnerInfoInput.tsx +0 -112
- package/src/features/partner-upload/presentation/components/PhotoTips.tsx +0 -53
- package/src/features/partner-upload/presentation/components/index.ts +0 -4
- package/src/features/partner-upload/presentation/hooks/index.ts +0 -7
- package/src/features/partner-upload/presentation/hooks/usePartnerStep.ts +0 -130
- package/src/features/partner-upload/presentation/screens/PartnerStepScreen.tsx +0 -231
- package/src/features/partner-upload/presentation/screens/index.ts +0 -6
- package/src/features/photo-restoration/README.md +0 -399
- package/src/features/photo-restoration/domain/index.ts +0 -1
- package/src/features/photo-restoration/domain/types/index.ts +0 -9
- package/src/features/photo-restoration/domain/types/photo-restore.types.ts +0 -64
- package/src/features/photo-restoration/index.ts +0 -22
- package/src/features/photo-restoration/presentation/components/PhotoRestoreFeature.tsx +0 -88
- package/src/features/photo-restoration/presentation/components/PhotoRestoreResultView.tsx +0 -86
- package/src/features/photo-restoration/presentation/components/index.ts +0 -4
- package/src/features/photo-restoration/presentation/hooks/index.ts +0 -1
- package/src/features/photo-restoration/presentation/hooks/usePhotoRestoreFeature.ts +0 -23
- package/src/features/photo-restoration/presentation/index.ts +0 -2
- package/src/features/remove-background/README.md +0 -393
- package/src/features/remove-background/domain/index.ts +0 -5
- package/src/features/remove-background/domain/types/index.ts +0 -7
- package/src/features/remove-background/domain/types/remove-background.types.ts +0 -28
- package/src/features/remove-background/index.ts +0 -19
- package/src/features/remove-background/presentation/components/RemoveBackgroundFeature.tsx +0 -86
- package/src/features/remove-background/presentation/components/index.ts +0 -2
- package/src/features/remove-background/presentation/hooks/index.ts +0 -1
- package/src/features/remove-background/presentation/hooks/useRemoveBackgroundFeature.ts +0 -28
- package/src/features/remove-background/presentation/index.ts +0 -6
- package/src/features/remove-object/README.md +0 -405
- package/src/features/remove-object/domain/index.ts +0 -5
- package/src/features/remove-object/domain/types/index.ts +0 -7
- package/src/features/remove-object/domain/types/remove-object.types.ts +0 -54
- package/src/features/remove-object/index.ts +0 -23
- package/src/features/remove-object/presentation/components/RemoveObjectFeature.tsx +0 -136
- package/src/features/remove-object/presentation/components/index.ts +0 -2
- package/src/features/remove-object/presentation/hooks/index.ts +0 -9
- package/src/features/remove-object/presentation/hooks/useRemoveObjectFeature.ts +0 -221
- package/src/features/remove-object/presentation/index.ts +0 -6
- package/src/features/replace-background/README.md +0 -405
- package/src/features/replace-background/domain/types/index.ts +0 -7
- package/src/features/replace-background/domain/types/replace-background.types.ts +0 -33
- package/src/features/replace-background/index.ts +0 -23
- package/src/features/replace-background/presentation/components/ReplaceBackgroundFeature.tsx +0 -105
- package/src/features/replace-background/presentation/components/index.ts +0 -6
- package/src/features/replace-background/presentation/hooks/index.ts +0 -9
- package/src/features/replace-background/presentation/hooks/useReplaceBackgroundFeature.ts +0 -55
- package/src/features/scenarios/domain/types.ts +0 -147
- package/src/features/scenarios/index.ts +0 -64
- package/src/features/scenarios/presentation/components/InspirationChips.tsx +0 -82
- package/src/features/scenarios/presentation/components/MagicPromptHeadline.tsx +0 -79
- package/src/features/scenarios/presentation/components/ScenarioGrid.tsx +0 -224
- package/src/features/scenarios/presentation/components/ScenarioHeader.tsx +0 -55
- package/src/features/scenarios/presentation/components/StyleSelector.tsx +0 -119
- package/src/features/scenarios/presentation/components/index.ts +0 -18
- package/src/features/scenarios/presentation/containers/CategoryNavigationContainer.tsx +0 -178
- package/src/features/scenarios/presentation/screens/HierarchicalScenarioListScreen.tsx +0 -266
- package/src/features/scenarios/presentation/screens/MagicPromptScreen.tsx +0 -242
- package/src/features/scenarios/presentation/screens/MainCategoryScreen.tsx +0 -198
- package/src/features/scenarios/presentation/screens/ScenarioPreviewScreen.tsx +0 -164
- package/src/features/scenarios/presentation/screens/ScenarioSelectorScreen.tsx +0 -66
- package/src/features/scenarios/presentation/screens/SubCategoryScreen.tsx +0 -216
- package/src/features/script-generator/README.md +0 -433
- package/src/features/script-generator/domain/constants/index.ts +0 -10
- package/src/features/script-generator/domain/types/script.types.ts +0 -30
- package/src/features/script-generator/index.ts +0 -5
- package/src/features/script-generator/infrastructure/services/ScriptGenerationService.ts +0 -62
- package/src/features/script-generator/presentation/components/ScriptDisplay.tsx +0 -158
- package/src/features/script-generator/presentation/components/VideoTypeSelector.tsx +0 -102
- package/src/features/script-generator/presentation/components/index.ts +0 -2
- package/src/features/script-generator/presentation/hooks/index.ts +0 -1
- package/src/features/script-generator/presentation/hooks/useScriptGenerator.ts +0 -77
- package/src/features/shared/README.md +0 -311
- package/src/features/shared/dual-image-video/domain/types/dual-image-video.types.ts +0 -88
- package/src/features/shared/dual-image-video/domain/types/index.ts +0 -14
- package/src/features/shared/dual-image-video/index.ts +0 -17
- package/src/features/shared/dual-image-video/presentation/hooks/index.ts +0 -5
- package/src/features/shared/dual-image-video/presentation/hooks/useDualImageVideoFeature.ts +0 -185
- package/src/features/shared/index.ts +0 -6
- package/src/features/text-to-image/README.md +0 -394
- package/src/features/text-to-image/domain/constants/index.ts +0 -8
- package/src/features/text-to-image/domain/constants/options.constants.ts +0 -39
- package/src/features/text-to-image/domain/constants/styles.constants.ts +0 -34
- package/src/features/text-to-image/domain/index.ts +0 -7
- package/src/features/text-to-image/domain/types/config.types.ts +0 -75
- package/src/features/text-to-image/domain/types/form.types.ts +0 -58
- package/src/features/text-to-image/domain/types/index.ts +0 -38
- package/src/features/text-to-image/domain/types/text-to-image.types.ts +0 -58
- package/src/features/text-to-image/index.ts +0 -116
- package/src/features/text-to-image/infrastructure/index.ts +0 -1
- package/src/features/text-to-image/infrastructure/services/index.ts +0 -5
- package/src/features/text-to-image/infrastructure/services/text-to-image-executor.ts +0 -147
- package/src/features/text-to-image/presentation/components/index.ts +0 -30
- package/src/features/text-to-image/presentation/hooks/index.ts +0 -30
- package/src/features/text-to-image/presentation/hooks/useFormState.ts +0 -103
- package/src/features/text-to-image/presentation/hooks/useGeneration.ts +0 -139
- package/src/features/text-to-image/presentation/hooks/useTextToImageFeature.ts +0 -111
- package/src/features/text-to-image/presentation/hooks/useTextToImageForm.ts +0 -58
- package/src/features/text-to-image/presentation/index.ts +0 -7
- package/src/features/text-to-video/README.md +0 -412
- package/src/features/text-to-video/domain/index.ts +0 -1
- package/src/features/text-to-video/domain/types/callback.types.ts +0 -69
- package/src/features/text-to-video/domain/types/component.types.ts +0 -106
- package/src/features/text-to-video/domain/types/config.types.ts +0 -61
- package/src/features/text-to-video/domain/types/index.ts +0 -56
- package/src/features/text-to-video/domain/types/request.types.ts +0 -36
- package/src/features/text-to-video/domain/types/state.types.ts +0 -53
- package/src/features/text-to-video/index.ts +0 -68
- package/src/features/text-to-video/infrastructure/index.ts +0 -1
- package/src/features/text-to-video/infrastructure/services/index.ts +0 -5
- package/src/features/text-to-video/infrastructure/services/text-to-video-executor.ts +0 -141
- package/src/features/text-to-video/presentation/components/FrameSelector.tsx +0 -153
- package/src/features/text-to-video/presentation/components/GenerationTabs.tsx +0 -73
- package/src/features/text-to-video/presentation/components/HeroSection.tsx +0 -61
- package/src/features/text-to-video/presentation/components/HintCarousel.tsx +0 -96
- package/src/features/text-to-video/presentation/components/OptionsPanel.tsx +0 -121
- package/src/features/text-to-video/presentation/components/index.ts +0 -10
- package/src/features/text-to-video/presentation/hooks/index.ts +0 -17
- package/src/features/text-to-video/presentation/hooks/useTextToVideoFeature.ts +0 -225
- package/src/features/text-to-video/presentation/hooks/useTextToVideoForm.ts +0 -134
- package/src/features/text-to-video/presentation/index.ts +0 -7
- package/src/features/text-to-voice/README.md +0 -445
- package/src/features/text-to-voice/domain/index.ts +0 -1
- package/src/features/text-to-voice/domain/types/component.types.ts +0 -91
- package/src/features/text-to-voice/domain/types/config.types.ts +0 -34
- package/src/features/text-to-voice/domain/types/form.types.ts +0 -39
- package/src/features/text-to-voice/domain/types/generation.types.ts +0 -43
- package/src/features/text-to-voice/domain/types/index.ts +0 -38
- package/src/features/text-to-voice/index.ts +0 -53
- package/src/features/text-to-voice/infrastructure/index.ts +0 -1
- package/src/features/text-to-voice/infrastructure/services/index.ts +0 -4
- package/src/features/text-to-voice/infrastructure/services/text-to-voice-executor.ts +0 -103
- package/src/features/text-to-voice/presentation/components/TextToVoiceAudioPlayer.tsx +0 -81
- package/src/features/text-to-voice/presentation/components/index.ts +0 -7
- package/src/features/text-to-voice/presentation/hooks/index.ts +0 -6
- package/src/features/text-to-voice/presentation/hooks/useTextToVoiceForm.ts +0 -91
- package/src/features/text-to-voice/presentation/hooks/useTextToVoiceGeneration.ts +0 -116
- package/src/features/text-to-voice/presentation/index.ts +0 -2
- package/src/features/upscaling/README.md +0 -396
- package/src/features/upscaling/domain/index.ts +0 -1
- package/src/features/upscaling/domain/types/index.ts +0 -1
- package/src/features/upscaling/domain/types/upscale.types.ts +0 -23
- package/src/features/upscaling/index.ts +0 -20
- package/src/features/upscaling/presentation/components/ComparisonSlider.tsx +0 -200
- package/src/features/upscaling/presentation/components/UpscaleFeature.tsx +0 -89
- package/src/features/upscaling/presentation/components/UpscaleResultView.tsx +0 -98
- package/src/features/upscaling/presentation/components/index.ts +0 -6
- package/src/features/upscaling/presentation/hooks/index.ts +0 -1
- package/src/features/upscaling/presentation/hooks/useUpscaleFeature.ts +0 -28
- package/src/features/upscaling/presentation/index.ts +0 -2
- package/src/features/wizard/domain/types.ts +0 -154
- package/src/features/wizard/index.ts +0 -43
- package/src/features/wizard/presentation/components/AIFeatureWizard.tsx +0 -231
- package/src/features/wizard/presentation/components/AIGenerationWizard.tsx +0 -132
- package/src/features/wizard/presentation/hooks/useWizard.ts +0 -120
- package/src/features/wizard/presentation/store/useWizardStore.ts +0 -82
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Feature State Types
|
|
3
|
-
* State interfaces for all image processing features
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Base state for single image features
|
|
8
|
-
*/
|
|
9
|
-
export interface BaseSingleImageState {
|
|
10
|
-
imageUri: string | null;
|
|
11
|
-
processedUrl: string | null;
|
|
12
|
-
isProcessing: boolean;
|
|
13
|
-
progress: number;
|
|
14
|
-
error: string | null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Base state for single image + prompt features
|
|
19
|
-
*/
|
|
20
|
-
export interface BaseImageWithPromptState extends BaseSingleImageState {
|
|
21
|
-
prompt: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Base state for dual image features
|
|
26
|
-
*/
|
|
27
|
-
export interface BaseDualImageState {
|
|
28
|
-
sourceImageUri: string | null;
|
|
29
|
-
targetImageUri: string | null;
|
|
30
|
-
processedUrl: string | null;
|
|
31
|
-
isProcessing: boolean;
|
|
32
|
-
progress: number;
|
|
33
|
-
error: string | null;
|
|
34
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Feature Translation Types
|
|
3
|
-
* Translation interfaces for all image processing features
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Base translations for image features
|
|
8
|
-
*/
|
|
9
|
-
export interface BaseImageTranslations {
|
|
10
|
-
uploadTitle: string;
|
|
11
|
-
uploadSubtitle: string;
|
|
12
|
-
uploadChange: string;
|
|
13
|
-
uploadAnalyzing: string;
|
|
14
|
-
description: string;
|
|
15
|
-
processingText: string;
|
|
16
|
-
processButtonText: string;
|
|
17
|
-
successText: string;
|
|
18
|
-
saveButtonText: string;
|
|
19
|
-
tryAnotherText: string;
|
|
20
|
-
beforeLabel?: string;
|
|
21
|
-
afterLabel?: string;
|
|
22
|
-
compareHint?: string;
|
|
23
|
-
/** Modal title shown during processing */
|
|
24
|
-
modalTitle?: string;
|
|
25
|
-
/** Modal message shown during processing */
|
|
26
|
-
modalMessage?: string;
|
|
27
|
-
/** Modal hint/tip shown during processing */
|
|
28
|
-
modalHint?: string;
|
|
29
|
-
/** "Continue in background" text */
|
|
30
|
-
modalBackgroundHint?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Base translations for dual image features
|
|
35
|
-
*/
|
|
36
|
-
export interface BaseDualImageTranslations {
|
|
37
|
-
sourceUploadTitle: string;
|
|
38
|
-
sourceUploadSubtitle: string;
|
|
39
|
-
targetUploadTitle: string;
|
|
40
|
-
targetUploadSubtitle: string;
|
|
41
|
-
uploadChange: string;
|
|
42
|
-
uploadAnalyzing: string;
|
|
43
|
-
description: string;
|
|
44
|
-
processingText: string;
|
|
45
|
-
processButtonText: string;
|
|
46
|
-
successText: string;
|
|
47
|
-
saveButtonText: string;
|
|
48
|
-
tryAnotherText: string;
|
|
49
|
-
/** Modal title shown during processing */
|
|
50
|
-
modalTitle?: string;
|
|
51
|
-
/** Modal message shown during processing */
|
|
52
|
-
modalMessage?: string;
|
|
53
|
-
/** Modal hint/tip shown during processing */
|
|
54
|
-
modalHint?: string;
|
|
55
|
-
/** "Continue in background" text */
|
|
56
|
-
modalBackgroundHint?: string;
|
|
57
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useDualImageFeature Hook Factory
|
|
3
|
-
* Base hook for dual image processing features (e.g., face-swap)
|
|
4
|
-
* Uses centralized orchestrator for credit/error handling
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useState, useCallback, useRef, useMemo } from "react";
|
|
8
|
-
import { generateUUID } from "@umituz/react-native-design-system";
|
|
9
|
-
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
10
|
-
import {
|
|
11
|
-
useGenerationOrchestrator,
|
|
12
|
-
type GenerationStrategy,
|
|
13
|
-
type AlertMessages,
|
|
14
|
-
} from "../../../../presentation/hooks/generation";
|
|
15
|
-
import type {
|
|
16
|
-
BaseDualImageHookProps,
|
|
17
|
-
BaseDualImageHookReturn,
|
|
18
|
-
DualImageConfig,
|
|
19
|
-
BaseImageResult,
|
|
20
|
-
} from "../../domain/types";
|
|
21
|
-
|
|
22
|
-
export interface DualImageFeatureOptions<TConfig extends DualImageConfig> {
|
|
23
|
-
buildInput?: (
|
|
24
|
-
sourceBase64: string,
|
|
25
|
-
targetBase64: string,
|
|
26
|
-
config: TConfig,
|
|
27
|
-
) => Record<string, unknown>;
|
|
28
|
-
/** Alert messages for error handling */
|
|
29
|
-
alertMessages?: AlertMessages;
|
|
30
|
-
/** User ID for credit operations */
|
|
31
|
-
userId?: string;
|
|
32
|
-
/** Callback when credits are exhausted */
|
|
33
|
-
onCreditsExhausted?: () => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const DEFAULT_ALERT_MESSAGES: AlertMessages = {
|
|
37
|
-
networkError: "No internet connection. Please check your network.",
|
|
38
|
-
policyViolation: "Content not allowed. Please try different images.",
|
|
39
|
-
saveFailed: "Failed to save result. Please try again.",
|
|
40
|
-
creditFailed: "Credit operation failed. Please try again.",
|
|
41
|
-
unknown: "An error occurred. Please try again.",
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
interface DualImageInput {
|
|
45
|
-
sourceImageBase64: string;
|
|
46
|
-
targetImageBase64: string;
|
|
47
|
-
options?: Record<string, unknown>;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function useDualImageFeature<
|
|
51
|
-
TConfig extends DualImageConfig = DualImageConfig,
|
|
52
|
-
TResult extends BaseImageResult = BaseImageResult,
|
|
53
|
-
>(
|
|
54
|
-
props: BaseDualImageHookProps<TConfig>,
|
|
55
|
-
options?: DualImageFeatureOptions<TConfig>,
|
|
56
|
-
): BaseDualImageHookReturn {
|
|
57
|
-
const { config, onSelectSourceImage, onSelectTargetImage, onSaveImage, onBeforeProcess } = props;
|
|
58
|
-
|
|
59
|
-
// Image selection state (separate from orchestrator state)
|
|
60
|
-
const [sourceImageUri, setSourceImageUri] = useState<string | null>(null);
|
|
61
|
-
const [targetImageUri, setTargetImageUri] = useState<string | null>(null);
|
|
62
|
-
const [imageError, setImageError] = useState<string | null>(null);
|
|
63
|
-
const creationIdRef = useRef<string | null>(null);
|
|
64
|
-
|
|
65
|
-
// Create strategy for orchestrator
|
|
66
|
-
const strategy: GenerationStrategy<DualImageInput, string> = useMemo(
|
|
67
|
-
() => ({
|
|
68
|
-
execute: async (input, onProgress) => {
|
|
69
|
-
const executorInput = input.options
|
|
70
|
-
? { ...input.options }
|
|
71
|
-
: { imageBase64: input.sourceImageBase64, targetImageBase64: input.targetImageBase64 };
|
|
72
|
-
|
|
73
|
-
const result = await executeImageFeature(
|
|
74
|
-
config.featureType,
|
|
75
|
-
executorInput,
|
|
76
|
-
{ extractResult: config.extractResult, onProgress },
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
if (!result.success || !result.imageUrl) {
|
|
80
|
-
throw new Error(result.error || "Processing failed");
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Notify completion with creationId
|
|
84
|
-
const creationId = creationIdRef.current;
|
|
85
|
-
if (creationId) {
|
|
86
|
-
config.onProcessingComplete?.({ ...result, creationId } as unknown as TResult);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return result.imageUrl;
|
|
90
|
-
},
|
|
91
|
-
getCreditCost: () => config.creditCost || 1,
|
|
92
|
-
}),
|
|
93
|
-
[config],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
// Use orchestrator for generation
|
|
97
|
-
const orchestrator = useGenerationOrchestrator(strategy, {
|
|
98
|
-
userId: options?.userId,
|
|
99
|
-
alertMessages: options?.alertMessages || DEFAULT_ALERT_MESSAGES,
|
|
100
|
-
onCreditsExhausted: options?.onCreditsExhausted,
|
|
101
|
-
onError: (error) => {
|
|
102
|
-
config.onError?.(error.message, creationIdRef.current ?? undefined);
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const selectSourceImage = useCallback(async () => {
|
|
107
|
-
try {
|
|
108
|
-
const uri = await onSelectSourceImage();
|
|
109
|
-
if (uri) {
|
|
110
|
-
setSourceImageUri(uri);
|
|
111
|
-
setImageError(null);
|
|
112
|
-
config.onSourceImageSelect?.(uri);
|
|
113
|
-
}
|
|
114
|
-
} catch (error) {
|
|
115
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
116
|
-
setImageError(message);
|
|
117
|
-
}
|
|
118
|
-
}, [onSelectSourceImage, config]);
|
|
119
|
-
|
|
120
|
-
const selectTargetImage = useCallback(async () => {
|
|
121
|
-
try {
|
|
122
|
-
const uri = await onSelectTargetImage();
|
|
123
|
-
if (uri) {
|
|
124
|
-
setTargetImageUri(uri);
|
|
125
|
-
setImageError(null);
|
|
126
|
-
config.onTargetImageSelect?.(uri);
|
|
127
|
-
}
|
|
128
|
-
} catch (error) {
|
|
129
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
130
|
-
setImageError(message);
|
|
131
|
-
}
|
|
132
|
-
}, [onSelectTargetImage, config]);
|
|
133
|
-
|
|
134
|
-
const process = useCallback(async () => {
|
|
135
|
-
if (!sourceImageUri || !targetImageUri) return;
|
|
136
|
-
|
|
137
|
-
if (onBeforeProcess) {
|
|
138
|
-
const canProceed = await onBeforeProcess();
|
|
139
|
-
if (!canProceed) return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const creationId = generateUUID();
|
|
143
|
-
creationIdRef.current = creationId;
|
|
144
|
-
|
|
145
|
-
config.onProcessingStart?.({
|
|
146
|
-
creationId,
|
|
147
|
-
sourceImageUri,
|
|
148
|
-
targetImageUri,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
const [sourceBase64, targetBase64] = await Promise.all([
|
|
153
|
-
config.prepareImage(sourceImageUri),
|
|
154
|
-
config.prepareImage(targetImageUri),
|
|
155
|
-
]);
|
|
156
|
-
|
|
157
|
-
const input: DualImageInput = options?.buildInput
|
|
158
|
-
? {
|
|
159
|
-
sourceImageBase64: sourceBase64,
|
|
160
|
-
targetImageBase64: targetBase64,
|
|
161
|
-
options: options.buildInput(sourceBase64, targetBase64, config),
|
|
162
|
-
}
|
|
163
|
-
: { sourceImageBase64: sourceBase64, targetImageBase64: targetBase64 };
|
|
164
|
-
|
|
165
|
-
await orchestrator.generate(input);
|
|
166
|
-
} catch {
|
|
167
|
-
// Error already handled by orchestrator
|
|
168
|
-
}
|
|
169
|
-
}, [sourceImageUri, targetImageUri, config, options, onBeforeProcess, orchestrator]);
|
|
170
|
-
|
|
171
|
-
const save = useCallback(async () => {
|
|
172
|
-
if (!orchestrator.result) return;
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
await onSaveImage(orchestrator.result);
|
|
176
|
-
} catch (error) {
|
|
177
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
178
|
-
setImageError(message);
|
|
179
|
-
}
|
|
180
|
-
}, [orchestrator.result, onSaveImage]);
|
|
181
|
-
|
|
182
|
-
const reset = useCallback(() => {
|
|
183
|
-
setSourceImageUri(null);
|
|
184
|
-
setTargetImageUri(null);
|
|
185
|
-
setImageError(null);
|
|
186
|
-
creationIdRef.current = null;
|
|
187
|
-
orchestrator.reset();
|
|
188
|
-
}, [orchestrator]);
|
|
189
|
-
|
|
190
|
-
// Combine states for backward compatibility
|
|
191
|
-
return {
|
|
192
|
-
sourceImageUri,
|
|
193
|
-
targetImageUri,
|
|
194
|
-
processedUrl: orchestrator.result,
|
|
195
|
-
isProcessing: orchestrator.isGenerating,
|
|
196
|
-
progress: orchestrator.progress,
|
|
197
|
-
error: orchestrator.error?.message || imageError,
|
|
198
|
-
selectSourceImage,
|
|
199
|
-
selectTargetImage,
|
|
200
|
-
process,
|
|
201
|
-
save,
|
|
202
|
-
reset,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useImageWithPromptFeature Hook Factory
|
|
3
|
-
* Base hook for image + prompt processing features (e.g., replace-background)
|
|
4
|
-
* Uses centralized orchestrator for credit/error handling
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useState, useCallback, useRef, useMemo } from "react";
|
|
8
|
-
import { generateUUID } from "@umituz/react-native-design-system";
|
|
9
|
-
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
10
|
-
import {
|
|
11
|
-
useGenerationOrchestrator,
|
|
12
|
-
type GenerationStrategy,
|
|
13
|
-
type AlertMessages,
|
|
14
|
-
} from "../../../../presentation/hooks/generation";
|
|
15
|
-
import type {
|
|
16
|
-
BaseImageWithPromptState,
|
|
17
|
-
SingleImageConfig,
|
|
18
|
-
BaseImageResult,
|
|
19
|
-
} from "../../domain/types";
|
|
20
|
-
|
|
21
|
-
export interface ImageWithPromptConfig<TResult extends BaseImageResult = BaseImageResult>
|
|
22
|
-
extends SingleImageConfig<TResult> {
|
|
23
|
-
defaultPrompt?: string;
|
|
24
|
-
onPromptChange?: (prompt: string) => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ImageWithPromptHookProps<
|
|
28
|
-
TConfig extends ImageWithPromptConfig = ImageWithPromptConfig,
|
|
29
|
-
> {
|
|
30
|
-
config: TConfig;
|
|
31
|
-
onSelectImage: () => Promise<string | null>;
|
|
32
|
-
onSaveImage: (imageUrl: string) => Promise<void>;
|
|
33
|
-
/** Called before processing starts. Return false to cancel. */
|
|
34
|
-
onBeforeProcess?: () => Promise<boolean>;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ImageWithPromptHookReturn extends BaseImageWithPromptState {
|
|
38
|
-
selectImage: () => Promise<void>;
|
|
39
|
-
setPrompt: (prompt: string) => void;
|
|
40
|
-
process: () => Promise<void>;
|
|
41
|
-
save: () => Promise<void>;
|
|
42
|
-
reset: () => void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ImageWithPromptOptions {
|
|
46
|
-
buildInput?: (
|
|
47
|
-
imageBase64: string,
|
|
48
|
-
prompt: string,
|
|
49
|
-
config: ImageWithPromptConfig,
|
|
50
|
-
) => Record<string, unknown>;
|
|
51
|
-
promptRequired?: boolean;
|
|
52
|
-
/** Alert messages for error handling */
|
|
53
|
-
alertMessages?: AlertMessages;
|
|
54
|
-
/** User ID for credit operations */
|
|
55
|
-
userId?: string;
|
|
56
|
-
/** Callback when credits are exhausted */
|
|
57
|
-
onCreditsExhausted?: () => void;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const DEFAULT_ALERT_MESSAGES: AlertMessages = {
|
|
61
|
-
networkError: "No internet connection. Please check your network.",
|
|
62
|
-
policyViolation: "Content not allowed. Please try a different image.",
|
|
63
|
-
saveFailed: "Failed to save result. Please try again.",
|
|
64
|
-
creditFailed: "Credit operation failed. Please try again.",
|
|
65
|
-
unknown: "An error occurred. Please try again.",
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
interface ImageWithPromptInput {
|
|
69
|
-
imageBase64: string;
|
|
70
|
-
prompt: string;
|
|
71
|
-
options?: Record<string, unknown>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function useImageWithPromptFeature<
|
|
75
|
-
TConfig extends ImageWithPromptConfig = ImageWithPromptConfig,
|
|
76
|
-
TResult extends BaseImageResult = BaseImageResult,
|
|
77
|
-
>(
|
|
78
|
-
props: ImageWithPromptHookProps<TConfig>,
|
|
79
|
-
options?: ImageWithPromptOptions,
|
|
80
|
-
): ImageWithPromptHookReturn {
|
|
81
|
-
const { config, onSelectImage, onSaveImage, onBeforeProcess } = props;
|
|
82
|
-
|
|
83
|
-
// Image and prompt state (separate from orchestrator state)
|
|
84
|
-
const [imageUri, setImageUri] = useState<string | null>(null);
|
|
85
|
-
const [prompt, setPromptState] = useState(config.defaultPrompt || "");
|
|
86
|
-
const [imageError, setImageError] = useState<string | null>(null);
|
|
87
|
-
const creationIdRef = useRef<string | null>(null);
|
|
88
|
-
|
|
89
|
-
// Create strategy for orchestrator
|
|
90
|
-
const strategy: GenerationStrategy<ImageWithPromptInput, string> = useMemo(
|
|
91
|
-
() => ({
|
|
92
|
-
execute: async (input, onProgress) => {
|
|
93
|
-
const executorInput = input.options
|
|
94
|
-
? { ...input.options }
|
|
95
|
-
: { imageBase64: input.imageBase64, prompt: input.prompt };
|
|
96
|
-
|
|
97
|
-
const result = await executeImageFeature(
|
|
98
|
-
config.featureType,
|
|
99
|
-
executorInput,
|
|
100
|
-
{ extractResult: config.extractResult, onProgress },
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
if (!result.success || !result.imageUrl) {
|
|
104
|
-
throw new Error(result.error || "Processing failed");
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Notify completion with creationId
|
|
108
|
-
const creationId = creationIdRef.current;
|
|
109
|
-
if (creationId) {
|
|
110
|
-
config.onProcessingComplete?.({ ...result, creationId } as unknown as TResult);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return result.imageUrl;
|
|
114
|
-
},
|
|
115
|
-
getCreditCost: () => config.creditCost || 1,
|
|
116
|
-
}),
|
|
117
|
-
[config],
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
// Use orchestrator for generation
|
|
121
|
-
const orchestrator = useGenerationOrchestrator(strategy, {
|
|
122
|
-
userId: options?.userId,
|
|
123
|
-
alertMessages: options?.alertMessages || DEFAULT_ALERT_MESSAGES,
|
|
124
|
-
onCreditsExhausted: options?.onCreditsExhausted,
|
|
125
|
-
onError: (error) => {
|
|
126
|
-
config.onError?.(error.message, creationIdRef.current ?? undefined);
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const selectImage = useCallback(async () => {
|
|
131
|
-
try {
|
|
132
|
-
const uri = await onSelectImage();
|
|
133
|
-
if (uri) {
|
|
134
|
-
setImageUri(uri);
|
|
135
|
-
setImageError(null);
|
|
136
|
-
config.onImageSelect?.(uri);
|
|
137
|
-
}
|
|
138
|
-
} catch (error) {
|
|
139
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
140
|
-
setImageError(message);
|
|
141
|
-
}
|
|
142
|
-
}, [onSelectImage, config]);
|
|
143
|
-
|
|
144
|
-
const setPrompt = useCallback(
|
|
145
|
-
(newPrompt: string) => {
|
|
146
|
-
setPromptState(newPrompt);
|
|
147
|
-
setImageError(null);
|
|
148
|
-
config.onPromptChange?.(newPrompt);
|
|
149
|
-
},
|
|
150
|
-
[config],
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
const process = useCallback(async () => {
|
|
154
|
-
if (!imageUri) return;
|
|
155
|
-
|
|
156
|
-
if (onBeforeProcess) {
|
|
157
|
-
const canProceed = await onBeforeProcess();
|
|
158
|
-
if (!canProceed) return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (options?.promptRequired && !prompt.trim()) {
|
|
162
|
-
const error = "Prompt is required";
|
|
163
|
-
setImageError(error);
|
|
164
|
-
config.onError?.(error, creationIdRef.current ?? undefined);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const creationId = generateUUID();
|
|
169
|
-
creationIdRef.current = creationId;
|
|
170
|
-
|
|
171
|
-
config.onProcessingStart?.({ creationId, imageUri });
|
|
172
|
-
|
|
173
|
-
try {
|
|
174
|
-
const imageBase64 = await config.prepareImage(imageUri);
|
|
175
|
-
|
|
176
|
-
const input: ImageWithPromptInput = options?.buildInput
|
|
177
|
-
? {
|
|
178
|
-
imageBase64,
|
|
179
|
-
prompt,
|
|
180
|
-
options: options.buildInput(imageBase64, prompt, config),
|
|
181
|
-
}
|
|
182
|
-
: { imageBase64, prompt };
|
|
183
|
-
|
|
184
|
-
await orchestrator.generate(input);
|
|
185
|
-
} catch {
|
|
186
|
-
// Error already handled by orchestrator
|
|
187
|
-
}
|
|
188
|
-
}, [imageUri, prompt, config, options, onBeforeProcess, orchestrator]);
|
|
189
|
-
|
|
190
|
-
const save = useCallback(async () => {
|
|
191
|
-
if (!orchestrator.result) return;
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
await onSaveImage(orchestrator.result);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
197
|
-
setImageError(message);
|
|
198
|
-
}
|
|
199
|
-
}, [orchestrator.result, onSaveImage]);
|
|
200
|
-
|
|
201
|
-
const reset = useCallback(() => {
|
|
202
|
-
setImageUri(null);
|
|
203
|
-
setPromptState(config.defaultPrompt || "");
|
|
204
|
-
setImageError(null);
|
|
205
|
-
creationIdRef.current = null;
|
|
206
|
-
orchestrator.reset();
|
|
207
|
-
}, [config.defaultPrompt, orchestrator]);
|
|
208
|
-
|
|
209
|
-
// Combine states for backward compatibility
|
|
210
|
-
return {
|
|
211
|
-
imageUri,
|
|
212
|
-
prompt,
|
|
213
|
-
processedUrl: orchestrator.result,
|
|
214
|
-
isProcessing: orchestrator.isGenerating,
|
|
215
|
-
progress: orchestrator.progress,
|
|
216
|
-
error: orchestrator.error?.message || imageError,
|
|
217
|
-
selectImage,
|
|
218
|
-
setPrompt,
|
|
219
|
-
process,
|
|
220
|
-
save,
|
|
221
|
-
reset,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useSingleImageFeature Hook Factory
|
|
3
|
-
* Base hook for single image processing features
|
|
4
|
-
* Uses centralized orchestrator for credit/error handling
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { useState, useCallback, useRef, useMemo } from "react";
|
|
8
|
-
import { generateUUID } from "@umituz/react-native-design-system";
|
|
9
|
-
import { executeImageFeature } from "../../../../infrastructure/services";
|
|
10
|
-
import {
|
|
11
|
-
useGenerationOrchestrator,
|
|
12
|
-
type GenerationStrategy,
|
|
13
|
-
type AlertMessages,
|
|
14
|
-
} from "../../../../presentation/hooks/generation";
|
|
15
|
-
import type {
|
|
16
|
-
BaseSingleImageHookProps,
|
|
17
|
-
BaseSingleImageHookReturn,
|
|
18
|
-
SingleImageConfig,
|
|
19
|
-
BaseImageResult,
|
|
20
|
-
} from "../../domain/types";
|
|
21
|
-
|
|
22
|
-
export interface SingleImageFeatureOptions<TConfig = SingleImageConfig> {
|
|
23
|
-
buildInput?: (imageBase64: string, config: TConfig) => Record<string, unknown>;
|
|
24
|
-
/** Alert messages for error handling */
|
|
25
|
-
alertMessages?: AlertMessages;
|
|
26
|
-
/** User ID for credit operations */
|
|
27
|
-
userId?: string;
|
|
28
|
-
/** Callback when credits are exhausted */
|
|
29
|
-
onCreditsExhausted?: () => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const DEFAULT_ALERT_MESSAGES: AlertMessages = {
|
|
33
|
-
networkError: "No internet connection. Please check your network.",
|
|
34
|
-
policyViolation: "Content not allowed. Please try a different image.",
|
|
35
|
-
saveFailed: "Failed to save result. Please try again.",
|
|
36
|
-
creditFailed: "Credit operation failed. Please try again.",
|
|
37
|
-
unknown: "An error occurred. Please try again.",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
interface SingleImageInput {
|
|
41
|
-
imageBase64: string;
|
|
42
|
-
options?: Record<string, unknown>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function useSingleImageFeature<TConfig = SingleImageConfig>(
|
|
46
|
-
props: BaseSingleImageHookProps<TConfig>,
|
|
47
|
-
options?: SingleImageFeatureOptions<TConfig>,
|
|
48
|
-
): BaseSingleImageHookReturn {
|
|
49
|
-
const { config: rawConfig, onSelectImage, onSaveImage, onBeforeProcess } = props;
|
|
50
|
-
|
|
51
|
-
// Cast config to base type for internal usage
|
|
52
|
-
const config = rawConfig as unknown as SingleImageConfig;
|
|
53
|
-
|
|
54
|
-
// Image selection state (separate from orchestrator state)
|
|
55
|
-
const [imageUri, setImageUri] = useState<string | null>(null);
|
|
56
|
-
const [imageError, setImageError] = useState<string | null>(null);
|
|
57
|
-
const creationIdRef = useRef<string | null>(null);
|
|
58
|
-
|
|
59
|
-
// Create strategy for orchestrator
|
|
60
|
-
const strategy: GenerationStrategy<SingleImageInput, string> = useMemo(
|
|
61
|
-
() => ({
|
|
62
|
-
execute: async (input, onProgress) => {
|
|
63
|
-
const result = await executeImageFeature(
|
|
64
|
-
config.featureType,
|
|
65
|
-
input.options ? { imageBase64: input.imageBase64, ...input.options } : { imageBase64: input.imageBase64 },
|
|
66
|
-
{ extractResult: config.extractResult, onProgress },
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
if (!result.success || !result.imageUrl) {
|
|
70
|
-
throw new Error(result.error || "Processing failed");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Notify completion with creationId
|
|
74
|
-
const creationId = creationIdRef.current;
|
|
75
|
-
if (creationId) {
|
|
76
|
-
config.onProcessingComplete?.({ ...result, creationId } as BaseImageResult);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return result.imageUrl;
|
|
80
|
-
},
|
|
81
|
-
getCreditCost: () => config.creditCost || 1,
|
|
82
|
-
}),
|
|
83
|
-
[config],
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Use orchestrator for generation
|
|
87
|
-
const orchestrator = useGenerationOrchestrator(strategy, {
|
|
88
|
-
userId: options?.userId,
|
|
89
|
-
alertMessages: options?.alertMessages || DEFAULT_ALERT_MESSAGES,
|
|
90
|
-
onCreditsExhausted: options?.onCreditsExhausted,
|
|
91
|
-
onError: (error) => {
|
|
92
|
-
config.onError?.(error.message, creationIdRef.current ?? undefined);
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const selectImage = useCallback(async () => {
|
|
97
|
-
try {
|
|
98
|
-
const uri = await onSelectImage();
|
|
99
|
-
if (uri) {
|
|
100
|
-
setImageUri(uri);
|
|
101
|
-
setImageError(null);
|
|
102
|
-
config.onImageSelect?.(uri);
|
|
103
|
-
}
|
|
104
|
-
} catch (error) {
|
|
105
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
106
|
-
setImageError(message);
|
|
107
|
-
}
|
|
108
|
-
}, [onSelectImage, config]);
|
|
109
|
-
|
|
110
|
-
const process = useCallback(async () => {
|
|
111
|
-
if (!imageUri) return;
|
|
112
|
-
|
|
113
|
-
if (onBeforeProcess) {
|
|
114
|
-
const canProceed = await onBeforeProcess();
|
|
115
|
-
if (!canProceed) return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const creationId = generateUUID();
|
|
119
|
-
creationIdRef.current = creationId;
|
|
120
|
-
|
|
121
|
-
config.onProcessingStart?.({ creationId, imageUri });
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const imageBase64 = await config.prepareImage(imageUri);
|
|
125
|
-
|
|
126
|
-
const input: SingleImageInput = options?.buildInput
|
|
127
|
-
? { imageBase64, options: options.buildInput(imageBase64, rawConfig) }
|
|
128
|
-
: { imageBase64 };
|
|
129
|
-
|
|
130
|
-
await orchestrator.generate(input);
|
|
131
|
-
} catch {
|
|
132
|
-
// Error already handled by orchestrator
|
|
133
|
-
}
|
|
134
|
-
}, [imageUri, config, rawConfig, options, onBeforeProcess, orchestrator]);
|
|
135
|
-
|
|
136
|
-
const save = useCallback(async () => {
|
|
137
|
-
if (!orchestrator.result) return;
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
await onSaveImage(orchestrator.result);
|
|
141
|
-
} catch (error) {
|
|
142
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
143
|
-
setImageError(message);
|
|
144
|
-
}
|
|
145
|
-
}, [orchestrator.result, onSaveImage]);
|
|
146
|
-
|
|
147
|
-
const reset = useCallback(() => {
|
|
148
|
-
setImageUri(null);
|
|
149
|
-
setImageError(null);
|
|
150
|
-
creationIdRef.current = null;
|
|
151
|
-
orchestrator.reset();
|
|
152
|
-
}, [orchestrator]);
|
|
153
|
-
|
|
154
|
-
// Combine states for backward compatibility
|
|
155
|
-
return {
|
|
156
|
-
imageUri,
|
|
157
|
-
processedUrl: orchestrator.result,
|
|
158
|
-
isProcessing: orchestrator.isGenerating,
|
|
159
|
-
progress: orchestrator.progress,
|
|
160
|
-
error: orchestrator.error?.message || imageError,
|
|
161
|
-
selectImage,
|
|
162
|
-
process,
|
|
163
|
-
save,
|
|
164
|
-
reset,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./hooks";
|