@umituz/react-native-ai-generation-content 1.12.2 → 1.12.3
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 +5 -1
- package/src/domains/prompts/domain/entities/AIPromptTemplate.ts +48 -0
- package/src/domains/prompts/domain/entities/BackgroundRemovalConfig.ts +86 -0
- package/src/domains/prompts/domain/entities/ColorizationConfig.ts +101 -0
- package/src/domains/prompts/domain/entities/FaceSwapConfig.ts +54 -0
- package/src/domains/prompts/domain/entities/FuturePredictionConfig.ts +93 -0
- package/src/domains/prompts/domain/entities/GeneratedPrompt.ts +32 -0
- package/src/domains/prompts/domain/entities/ImageEnhancementConfig.ts +93 -0
- package/src/domains/prompts/domain/entities/PhotoRestorationConfig.ts +64 -0
- package/src/domains/prompts/domain/entities/StyleTransferConfig.ts +80 -0
- package/src/domains/prompts/domain/entities/TextGenerationConfig.ts +100 -0
- package/src/domains/prompts/domain/entities/types.ts +27 -0
- package/src/domains/prompts/domain/entities/value-objects.ts +33 -0
- package/src/domains/prompts/domain/repositories/IAIPromptServices.ts +106 -0
- package/src/domains/prompts/domain/repositories/IPromptHistoryRepository.ts +10 -0
- package/src/domains/prompts/domain/repositories/ITemplateRepository.ts +11 -0
- package/src/domains/prompts/index.ts +318 -0
- package/src/domains/prompts/infrastructure/repositories/PromptHistoryRepository.ts +85 -0
- package/src/domains/prompts/infrastructure/repositories/TemplateRepository.ts +77 -0
- package/src/domains/prompts/infrastructure/services/BackgroundRemovalService.ts +209 -0
- package/src/domains/prompts/infrastructure/services/ColorizationService.ts +232 -0
- package/src/domains/prompts/infrastructure/services/FaceSwapService.ts +198 -0
- package/src/domains/prompts/infrastructure/services/FuturePredictionService.ts +176 -0
- package/src/domains/prompts/infrastructure/services/ImageEnhancementService.ts +181 -0
- package/src/domains/prompts/infrastructure/services/PhotoRestorationService.ts +160 -0
- package/src/domains/prompts/infrastructure/services/PromptGenerationService.ts +59 -0
- package/src/domains/prompts/infrastructure/services/StyleTransferService.ts +194 -0
- package/src/domains/prompts/infrastructure/services/TextGenerationService.ts +241 -0
- package/src/domains/prompts/presentation/hooks/useAIServices.ts +213 -0
- package/src/domains/prompts/presentation/hooks/useAsyncState.ts +56 -0
- package/src/domains/prompts/presentation/hooks/useFaceSwap.ts +100 -0
- package/src/domains/prompts/presentation/hooks/useImageEnhancement.ts +100 -0
- package/src/domains/prompts/presentation/hooks/usePhotoRestoration.ts +100 -0
- package/src/domains/prompts/presentation/hooks/usePromptGeneration.ts +144 -0
- package/src/domains/prompts/presentation/hooks/useStyleTransfer.ts +125 -0
- package/src/domains/prompts/presentation/hooks/useTemplateRepository.ts +113 -0
- package/src/domains/prompts/presentation/theme/theme.ts +16 -0
- package/src/domains/prompts/presentation/theme/types.ts +82 -0
- package/src/domains/prompts/presentation/theme/utils.ts +24 -0
- package/src/index.ts +6 -0
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.3",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts",
|
|
9
|
+
"./prompts": "./src/domains/prompts/index.ts"
|
|
10
|
+
},
|
|
7
11
|
"files": [
|
|
8
12
|
"src"
|
|
9
13
|
],
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AIPromptCategory } from './types';
|
|
2
|
+
import type { AIPromptVariable, AIPromptSafety, AIPromptVersion } from './value-objects';
|
|
3
|
+
import { createPromptVersion, formatVersion } from './value-objects';
|
|
4
|
+
|
|
5
|
+
export interface AIPromptTemplate {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
readonly category: AIPromptCategory;
|
|
10
|
+
readonly template: string;
|
|
11
|
+
readonly variables: readonly AIPromptVariable[];
|
|
12
|
+
readonly safety: AIPromptSafety;
|
|
13
|
+
readonly version: AIPromptVersion;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CreateAIPromptTemplateParams {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
category: AIPromptCategory;
|
|
21
|
+
template: string;
|
|
22
|
+
variables?: AIPromptVariable[];
|
|
23
|
+
safety: AIPromptSafety;
|
|
24
|
+
version: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const createAIPromptTemplate = (
|
|
28
|
+
params: CreateAIPromptTemplateParams
|
|
29
|
+
): AIPromptTemplate => ({
|
|
30
|
+
id: params.id,
|
|
31
|
+
name: params.name,
|
|
32
|
+
description: params.description,
|
|
33
|
+
category: params.category,
|
|
34
|
+
template: params.template,
|
|
35
|
+
variables: params.variables || [],
|
|
36
|
+
safety: params.safety,
|
|
37
|
+
version: createPromptVersion(params.version),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const updateTemplateVersion = (
|
|
41
|
+
template: AIPromptTemplate,
|
|
42
|
+
newVersion: string
|
|
43
|
+
): AIPromptTemplate => ({
|
|
44
|
+
...template,
|
|
45
|
+
version: createPromptVersion(newVersion),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const getTemplateString = (template: AIPromptTemplate): string => formatVersion(template.version);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
|
|
3
|
+
export interface BackgroundRemovalConfig {
|
|
4
|
+
precision: 'fast' | 'accurate' | 'ultra-accurate';
|
|
5
|
+
edgeRefinement: boolean;
|
|
6
|
+
preserveHair: boolean;
|
|
7
|
+
outputFormat: 'png' | 'webp' | 'transparent';
|
|
8
|
+
addNewBackground?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface BackgroundRemovalTemplate {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly description: string;
|
|
15
|
+
readonly basePrompt: string;
|
|
16
|
+
readonly variables: BackgroundRemovalVariable[];
|
|
17
|
+
readonly processing: BackgroundRemovalSettings;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface BackgroundRemovalVariable {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
required: boolean;
|
|
24
|
+
options?: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BackgroundRemovalSettings {
|
|
28
|
+
supportedFormats: string[];
|
|
29
|
+
maxResolution: number;
|
|
30
|
+
processingTimes: Record<string, number>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface BackgroundRemovalResult {
|
|
34
|
+
template: AIPromptTemplate;
|
|
35
|
+
config: BackgroundRemovalConfig;
|
|
36
|
+
estimatedProcessingTime: number;
|
|
37
|
+
qualityScore: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface DetectedObject {
|
|
41
|
+
type: string;
|
|
42
|
+
confidence: number;
|
|
43
|
+
boundingBox: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const validateBackgroundRemovalConfig = (config: BackgroundRemovalConfig): boolean => {
|
|
52
|
+
return !!(
|
|
53
|
+
config.precision &&
|
|
54
|
+
config.outputFormat &&
|
|
55
|
+
['png', 'webp', 'transparent'].includes(config.outputFormat)
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const createBackgroundRemovalVariable = (
|
|
60
|
+
name: string,
|
|
61
|
+
description: string,
|
|
62
|
+
required: boolean = true,
|
|
63
|
+
options?: string[]
|
|
64
|
+
): BackgroundRemovalVariable => ({
|
|
65
|
+
name,
|
|
66
|
+
description,
|
|
67
|
+
required,
|
|
68
|
+
options,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const getProcessingTime = (precision: BackgroundRemovalConfig['precision']): number => {
|
|
72
|
+
switch (precision) {
|
|
73
|
+
case 'fast': return 2;
|
|
74
|
+
case 'accurate': return 5;
|
|
75
|
+
case 'ultra-accurate': return 10;
|
|
76
|
+
default: return 5;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const getQualityScore = (config: BackgroundRemovalConfig): number => {
|
|
81
|
+
let score = config.edgeRefinement ? 0.9 : 0.7;
|
|
82
|
+
if (config.preserveHair) score += 0.05;
|
|
83
|
+
if (config.precision === 'ultra-accurate') score += 0.15;
|
|
84
|
+
if (config.precision === 'accurate') score += 0.1;
|
|
85
|
+
return Math.min(score, 1.0);
|
|
86
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
|
|
3
|
+
export interface ColorizationConfig {
|
|
4
|
+
targetType: 'black-and-white' | 'sepia' | 'faded' | 'damaged';
|
|
5
|
+
colorMode: 'realistic' | 'vibrant' | 'artistic' | 'vintage';
|
|
6
|
+
preserveOriginal: boolean;
|
|
7
|
+
adjustLighting: boolean;
|
|
8
|
+
skinTonePreservation: boolean;
|
|
9
|
+
era?: '1920s' | '1940s' | '1960s' | '1980s' | 'victorian';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ColorizationTemplate {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly basePrompt: string;
|
|
17
|
+
readonly variables: ColorizationVariable[];
|
|
18
|
+
readonly colorization: ColorizationSettings;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ColorizationVariable {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
options?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ColorizationSettings {
|
|
29
|
+
supportedModes: string[];
|
|
30
|
+
eraPresets: Record<string, string>;
|
|
31
|
+
skinToneAdjustments: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ColorizationResult {
|
|
35
|
+
template: AIPromptTemplate;
|
|
36
|
+
config: ColorizationConfig;
|
|
37
|
+
qualityScore: number;
|
|
38
|
+
colorPalette?: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const validateColorizationConfig = (config: ColorizationConfig): boolean => {
|
|
42
|
+
return !!(
|
|
43
|
+
config.targetType &&
|
|
44
|
+
config.colorMode &&
|
|
45
|
+
['realistic', 'vibrant', 'artistic', 'vintage'].includes(config.colorMode)
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const createColorizationVariable = (
|
|
50
|
+
name: string,
|
|
51
|
+
description: string,
|
|
52
|
+
required: boolean = true,
|
|
53
|
+
options?: string[]
|
|
54
|
+
): ColorizationVariable => ({
|
|
55
|
+
name,
|
|
56
|
+
description,
|
|
57
|
+
required,
|
|
58
|
+
options,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const getColorizationQuality = (config: ColorizationConfig): number => {
|
|
62
|
+
let quality = 0.8;
|
|
63
|
+
|
|
64
|
+
if (config.preserveOriginal) quality += 0.1;
|
|
65
|
+
if (config.skinTonePreservation) quality += 0.05;
|
|
66
|
+
if (config.colorMode === 'realistic') quality += 0.1;
|
|
67
|
+
if (config.targetType === 'black-and-white') quality += 0.05;
|
|
68
|
+
|
|
69
|
+
return Math.min(quality, 1.0);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const getEraDescription = (era?: string): string => {
|
|
73
|
+
switch (era) {
|
|
74
|
+
case '1920s': return '1920s vintage aesthetic with soft colors';
|
|
75
|
+
case '1940s': return '1940s wartime color palette';
|
|
76
|
+
case '1960s': return '1960s vibrant, saturated colors';
|
|
77
|
+
case '1980s': return '1980s neon and pastel tones';
|
|
78
|
+
case 'victorian': return 'Victorian era muted, elegant colors';
|
|
79
|
+
default: return 'Historically appropriate color palette';
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const getSuggestedColorPalette = (
|
|
84
|
+
targetType: ColorizationConfig['targetType'],
|
|
85
|
+
colorMode: ColorizationConfig['colorMode']
|
|
86
|
+
): string[] => {
|
|
87
|
+
switch (targetType) {
|
|
88
|
+
case 'black-and-white':
|
|
89
|
+
return colorMode === 'vibrant'
|
|
90
|
+
? ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7']
|
|
91
|
+
: ['#2C3E50', '#34495E', '#7F8C8D', '#95A5A6', '#BDC3C7'];
|
|
92
|
+
case 'sepia':
|
|
93
|
+
return ['#8B7355', '#A0826D', '#BC9A6A', '#D2B48C', '#DEB887'];
|
|
94
|
+
case 'faded':
|
|
95
|
+
return ['#E27D60', '#41B3A3', '#85DCBA', '#C1E1DC', '#E8DDCB'];
|
|
96
|
+
case 'damaged':
|
|
97
|
+
return ['#C9302C', '#F0AD4E', '#5BC0DE', '#5CB85C'];
|
|
98
|
+
default:
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
import type { GeneratedPrompt } from './GeneratedPrompt';
|
|
3
|
+
|
|
4
|
+
export interface FaceSwapConfig {
|
|
5
|
+
preserveIdentity: boolean;
|
|
6
|
+
allowHairStyle: boolean;
|
|
7
|
+
allowAccessories: boolean;
|
|
8
|
+
allowExpression: boolean;
|
|
9
|
+
environment?: string;
|
|
10
|
+
styleName: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FaceSwapTemplate {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly basePrompt: string;
|
|
18
|
+
readonly variables: FaceSwapTemplateVariable[];
|
|
19
|
+
readonly safety: FaceSwapSafety;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FaceSwapTemplateVariable {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
required: boolean;
|
|
26
|
+
options?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface FaceSwapSafety {
|
|
30
|
+
contentFilter: boolean;
|
|
31
|
+
identityPreservation: boolean;
|
|
32
|
+
adultContentFilter: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FaceSwapGenerationResult {
|
|
36
|
+
template: AIPromptTemplate;
|
|
37
|
+
prompt: GeneratedPrompt;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const validateFaceSwapConfig = (config: FaceSwapConfig): boolean => {
|
|
41
|
+
return !!(config.styleName && config.styleName.trim().length > 0);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const createFaceSwapVariable = (
|
|
45
|
+
name: string,
|
|
46
|
+
description: string,
|
|
47
|
+
required: boolean = true,
|
|
48
|
+
options?: string[]
|
|
49
|
+
): FaceSwapTemplateVariable => ({
|
|
50
|
+
name,
|
|
51
|
+
description,
|
|
52
|
+
required,
|
|
53
|
+
options,
|
|
54
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AIPromptVariable } from './value-objects';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Future Prediction Configuration
|
|
5
|
+
* Generic configuration for generating future scenarios/visualizations
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface FuturePredictionSettings {
|
|
9
|
+
readonly scenarioType: string; // e.g. 'lifestyle', 'career', 'family', 'adventure'
|
|
10
|
+
readonly outputType: FuturePredictionOutputType;
|
|
11
|
+
readonly personCount: 1 | 2;
|
|
12
|
+
readonly includeDate: boolean;
|
|
13
|
+
readonly language: string;
|
|
14
|
+
readonly tone?: string; // e.g. 'romantic', 'professional', 'funny', 'dramatic'
|
|
15
|
+
readonly subjectRole?: string; // e.g. 'couple', 'best friends', 'business partners', 'parents'
|
|
16
|
+
readonly year?: number; // Optional specific year for prediction
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type FuturePredictionOutputType = 'image' | 'story' | 'both';
|
|
20
|
+
|
|
21
|
+
export interface FuturePredictionConfig {
|
|
22
|
+
readonly scenarioId: string;
|
|
23
|
+
readonly scenarioTitle: string;
|
|
24
|
+
readonly promptModifier: string;
|
|
25
|
+
readonly subjectA: string;
|
|
26
|
+
readonly subjectB?: string;
|
|
27
|
+
readonly settings: FuturePredictionSettings;
|
|
28
|
+
readonly customPrompt?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface FuturePredictionTemplate {
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly imagePrompt: string;
|
|
36
|
+
readonly storyPrompt: string;
|
|
37
|
+
readonly variables: readonly FuturePredictionVariable[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface FuturePredictionVariable extends AIPromptVariable {
|
|
41
|
+
readonly category: 'subject' | 'scenario' | 'output';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface FuturePredictionResult {
|
|
45
|
+
readonly imagePrompt: string;
|
|
46
|
+
readonly storyPrompt: string;
|
|
47
|
+
readonly metadata: FuturePredictionMetadata;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface FuturePredictionMetadata {
|
|
51
|
+
readonly scenarioId: string;
|
|
52
|
+
readonly personCount: number;
|
|
53
|
+
readonly language: string;
|
|
54
|
+
readonly generatedAt: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const validateFuturePredictionConfig = (
|
|
58
|
+
config: FuturePredictionConfig
|
|
59
|
+
): boolean => {
|
|
60
|
+
if (!config.scenarioId || typeof config.scenarioId !== 'string') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (!config.subjectA || typeof config.subjectA !== 'string') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (!config.settings) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const createFuturePredictionVariable = (
|
|
73
|
+
name: string,
|
|
74
|
+
type: 'string' | 'number' | 'boolean',
|
|
75
|
+
description: string,
|
|
76
|
+
category: 'subject' | 'scenario' | 'output',
|
|
77
|
+
required: boolean = true,
|
|
78
|
+
defaultValue?: string | number | boolean
|
|
79
|
+
): FuturePredictionVariable => ({
|
|
80
|
+
name,
|
|
81
|
+
type,
|
|
82
|
+
description,
|
|
83
|
+
category,
|
|
84
|
+
required,
|
|
85
|
+
defaultValue,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const getFutureYear = (): number => {
|
|
89
|
+
const currentYear = new Date().getFullYear();
|
|
90
|
+
// Typical future predictions are 1-50 years ahead
|
|
91
|
+
const offset = 1 + Math.floor(Math.random() * 50);
|
|
92
|
+
return currentYear + offset;
|
|
93
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
|
|
3
|
+
export interface GeneratedPrompt {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly templateId: string;
|
|
6
|
+
readonly generatedText: string;
|
|
7
|
+
readonly variables: Record<string, unknown>;
|
|
8
|
+
readonly timestamp: Date;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CreateGeneratedPromptParams {
|
|
12
|
+
templateId: string;
|
|
13
|
+
generatedText: string;
|
|
14
|
+
variables: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const createGeneratedPrompt = (
|
|
18
|
+
params: CreateGeneratedPromptParams
|
|
19
|
+
): GeneratedPrompt => ({
|
|
20
|
+
id: `prompt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
21
|
+
templateId: params.templateId,
|
|
22
|
+
generatedText: params.generatedText,
|
|
23
|
+
variables: params.variables,
|
|
24
|
+
timestamp: new Date(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const isPromptRecent = (prompt: GeneratedPrompt, hours: number = 24): boolean => {
|
|
28
|
+
const now = new Date();
|
|
29
|
+
const promptTime = new Date(prompt.timestamp);
|
|
30
|
+
const diffInHours = (now.getTime() - promptTime.getTime()) / (1000 * 60 * 60);
|
|
31
|
+
return diffInHours <= hours;
|
|
32
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
|
|
3
|
+
export interface ImageEnhancementConfig {
|
|
4
|
+
enhancementType: 'brightness' | 'contrast' | 'saturation' | 'sharpness' | 'all';
|
|
5
|
+
intensity: number;
|
|
6
|
+
preserveNatural: boolean;
|
|
7
|
+
autoAdjust: boolean;
|
|
8
|
+
targetStyle: 'natural' | 'vivid' | 'dramatic' | 'professional';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ImageEnhancementTemplate {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly description: string;
|
|
15
|
+
readonly basePrompt: string;
|
|
16
|
+
readonly variables: ImageEnhancementVariable[];
|
|
17
|
+
readonly enhancement: EnhancementSettings;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ImageEnhancementVariable {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
required: boolean;
|
|
24
|
+
type: 'number' | 'select';
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
options?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface EnhancementSettings {
|
|
31
|
+
brightnessRange: [number, number];
|
|
32
|
+
contrastRange: [number, number];
|
|
33
|
+
saturationRange: [number, number];
|
|
34
|
+
sharpnessRange: [number, number];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ImageEnhancementResult {
|
|
38
|
+
template: AIPromptTemplate;
|
|
39
|
+
config: ImageEnhancementConfig;
|
|
40
|
+
adjustments: EnhancementAdjustments;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface EnhancementAdjustments {
|
|
44
|
+
brightness: number;
|
|
45
|
+
contrast: number;
|
|
46
|
+
saturation: number;
|
|
47
|
+
sharpness: number;
|
|
48
|
+
overall: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const validateImageEnhancementConfig = (config: ImageEnhancementConfig): boolean => {
|
|
52
|
+
return !!(
|
|
53
|
+
config.enhancementType &&
|
|
54
|
+
config.intensity >= 0 &&
|
|
55
|
+
config.intensity <= 1 &&
|
|
56
|
+
config.targetStyle
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const createImageEnhancementVariable = (
|
|
61
|
+
name: string,
|
|
62
|
+
description: string,
|
|
63
|
+
type: ImageEnhancementVariable['type'] = 'select',
|
|
64
|
+
required: boolean = true,
|
|
65
|
+
options?: string[]
|
|
66
|
+
): ImageEnhancementVariable => ({
|
|
67
|
+
name,
|
|
68
|
+
description,
|
|
69
|
+
type,
|
|
70
|
+
required,
|
|
71
|
+
options,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const calculateAdjustments = (
|
|
75
|
+
config: ImageEnhancementConfig
|
|
76
|
+
): EnhancementAdjustments => {
|
|
77
|
+
const baseIntensity = config.intensity;
|
|
78
|
+
const multiplier = config.targetStyle === 'dramatic' ? 1.5 :
|
|
79
|
+
config.targetStyle === 'vivid' ? 1.2 :
|
|
80
|
+
config.targetStyle === 'professional' ? 0.8 : 1;
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
brightness: config.enhancementType === 'brightness' || config.enhancementType === 'all'
|
|
84
|
+
? baseIntensity * multiplier : 0,
|
|
85
|
+
contrast: config.enhancementType === 'contrast' || config.enhancementType === 'all'
|
|
86
|
+
? baseIntensity * multiplier : 0,
|
|
87
|
+
saturation: config.enhancementType === 'saturation' || config.enhancementType === 'all'
|
|
88
|
+
? baseIntensity * multiplier : 0,
|
|
89
|
+
sharpness: config.enhancementType === 'sharpness' || config.enhancementType === 'all'
|
|
90
|
+
? baseIntensity * multiplier : 0,
|
|
91
|
+
overall: baseIntensity * multiplier,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
|
|
3
|
+
export interface PhotoRestorationConfig {
|
|
4
|
+
severity: 'minor' | 'moderate' | 'severe';
|
|
5
|
+
preserveOriginal: boolean;
|
|
6
|
+
enhanceColors: boolean;
|
|
7
|
+
removeNoise: boolean;
|
|
8
|
+
fixBlur: boolean;
|
|
9
|
+
restoreDetails: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface PhotoRestorationTemplate {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly basePrompt: string;
|
|
17
|
+
readonly variables: PhotoRestorationVariable[];
|
|
18
|
+
readonly quality: PhotoRestorationQuality;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PhotoRestorationVariable {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
options?: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PhotoRestorationQuality {
|
|
29
|
+
detailLevel: number;
|
|
30
|
+
noiseReduction: number;
|
|
31
|
+
colorAccuracy: number;
|
|
32
|
+
sharpness: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface PhotoRestorationResult {
|
|
36
|
+
template: AIPromptTemplate;
|
|
37
|
+
config: PhotoRestorationConfig;
|
|
38
|
+
estimatedQuality: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const validatePhotoRestorationConfig = (config: PhotoRestorationConfig): boolean => {
|
|
42
|
+
return !!(config.severity && config.severity.trim().length > 0);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const createPhotoRestorationVariable = (
|
|
46
|
+
name: string,
|
|
47
|
+
description: string,
|
|
48
|
+
required: boolean = true,
|
|
49
|
+
options?: string[]
|
|
50
|
+
): PhotoRestorationVariable => ({
|
|
51
|
+
name,
|
|
52
|
+
description,
|
|
53
|
+
required,
|
|
54
|
+
options,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const getQualityLevel = (severity: PhotoRestorationConfig['severity']): number => {
|
|
58
|
+
switch (severity) {
|
|
59
|
+
case 'minor': return 0.7;
|
|
60
|
+
case 'moderate': return 0.5;
|
|
61
|
+
case 'severe': return 0.3;
|
|
62
|
+
default: return 0.5;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AIPromptTemplate } from './AIPromptTemplate';
|
|
2
|
+
|
|
3
|
+
export interface StyleTransferConfig {
|
|
4
|
+
targetStyle: string;
|
|
5
|
+
preserveContent: boolean;
|
|
6
|
+
styleStrength: number;
|
|
7
|
+
artisticMode: 'photorealistic' | 'artistic' | 'abstract' | 'cartoon';
|
|
8
|
+
maintainColors: boolean;
|
|
9
|
+
adaptToSubject: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface StyleTransferTemplate {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description: string;
|
|
16
|
+
readonly basePrompt: string;
|
|
17
|
+
readonly variables: StyleTransferVariable[];
|
|
18
|
+
readonly style: StyleTransferSettings;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface StyleTransferVariable {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
options?: string[];
|
|
26
|
+
type: 'string' | 'select';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface StyleTransferSettings {
|
|
30
|
+
supportedStyles: string[];
|
|
31
|
+
maxStyleStrength: number;
|
|
32
|
+
preserveContentLevels: number[];
|
|
33
|
+
qualityPresets: Record<string, number>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface StyleTransferResult {
|
|
37
|
+
template: AIPromptTemplate;
|
|
38
|
+
config: StyleTransferConfig;
|
|
39
|
+
appliedStyle: string;
|
|
40
|
+
expectedQuality: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const validateStyleTransferConfig = (config: StyleTransferConfig): boolean => {
|
|
44
|
+
return !!(
|
|
45
|
+
config.targetStyle &&
|
|
46
|
+
config.targetStyle.trim().length > 0 &&
|
|
47
|
+
config.styleStrength >= 0 &&
|
|
48
|
+
config.styleStrength <= 1 &&
|
|
49
|
+
config.artisticMode
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const createStyleTransferVariable = (
|
|
54
|
+
name: string,
|
|
55
|
+
description: string,
|
|
56
|
+
required: boolean = true,
|
|
57
|
+
options?: string[]
|
|
58
|
+
): StyleTransferVariable => ({
|
|
59
|
+
name,
|
|
60
|
+
description,
|
|
61
|
+
required,
|
|
62
|
+
options,
|
|
63
|
+
type: 'string',
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const getStyleStrengthValue = (strength: number): string => {
|
|
67
|
+
if (strength <= 0.3) return 'subtle';
|
|
68
|
+
if (strength <= 0.6) return 'moderate';
|
|
69
|
+
return 'strong';
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const getArtisticModeDescription = (mode: StyleTransferConfig['artisticMode']): string => {
|
|
73
|
+
switch (mode) {
|
|
74
|
+
case 'photorealistic': return 'Maintain realistic appearance while applying style';
|
|
75
|
+
case 'artistic': return 'Apply artistic interpretation with creative freedom';
|
|
76
|
+
case 'abstract': return 'Transform into abstract artistic representation';
|
|
77
|
+
case 'cartoon': return 'Convert to cartoon/animated style';
|
|
78
|
+
default: return 'Apply selected artistic style';
|
|
79
|
+
}
|
|
80
|
+
};
|