@imgly/plugin-ai-image-generation-web 0.1.0-rc.0
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/CHANGELOG.md +6 -0
- package/LICENSE.md +17 -0
- package/README.md +219 -0
- package/dist/constants.d.ts +1 -0
- package/dist/fal-ai/GeminiFlashEdit.d.ts +17 -0
- package/dist/fal-ai/GeminiFlashEditQuickActions.d.ts +13 -0
- package/dist/fal-ai/RecraftV3.constants.d.ts +23 -0
- package/dist/fal-ai/RecraftV3.d.ts +17 -0
- package/dist/fal-ai/createImageProvider.d.ts +34 -0
- package/dist/fal-ai/index.d.ts +7 -0
- package/dist/fal-ai/index.mjs +169 -0
- package/dist/fal-ai/index.mjs.map +7 -0
- package/dist/fal-ai/utils.d.ts +8 -0
- package/dist/iconSprite.d.ts +3 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +99 -0
- package/dist/index.mjs.map +7 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/types.d.ts +35 -0
- package/package.json +80 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
GNU Affero General Public License
|
|
3
|
+
=================================
|
|
4
|
+
|
|
5
|
+
_Version 3, 19 November 2007_
|
|
6
|
+
_Copyright © 2007 Free Software Foundation, Inc. <<http://fsf.org/>>_
|
|
7
|
+
|
|
8
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
9
|
+
of this license document, but changing it is not allowed.
|
|
10
|
+
|
|
11
|
+
## Preamble
|
|
12
|
+
|
|
13
|
+
The GNU Affero General Public License is a free, copyleft license for
|
|
14
|
+
software and other kinds of works, specifically designed to ensure
|
|
15
|
+
cooperation with the community in the case of network server software.
|
|
16
|
+
|
|
17
|
+
[Full license text omitted for brevity]
|
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# IMG.LY AI Image Generation for Web
|
|
2
|
+
|
|
3
|
+
A plugin for integrating AI image generation capabilities into CreativeEditor SDK.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `@imgly/plugin-ai-image-generation-web` package enables users to generate and modify images using AI directly within CreativeEditor SDK. This shipped provider leverages the [fal.ai](https://fal.ai) platform to provide high-quality image generation from text-to-image and image-to-image transformations.
|
|
8
|
+
|
|
9
|
+
Features include:
|
|
10
|
+
- Text-to-image generation
|
|
11
|
+
- Image-to-image transformations
|
|
12
|
+
- Multiple style options (realistic, illustration, vector)
|
|
13
|
+
- Various size presets and custom dimensions
|
|
14
|
+
- Automatic history tracking
|
|
15
|
+
- Canvas menu quick actions
|
|
16
|
+
- Seamless integration with CreativeEditor SDK
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @imgly/plugin-ai-image-generation-web
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Basic Configuration
|
|
27
|
+
|
|
28
|
+
To use the plugin, import it and configure it with your preferred providers:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
32
|
+
import ImageGeneration from '@imgly/plugin-ai-image-generation-web';
|
|
33
|
+
import FalAiImage from '@imgly/plugin-ai-image-generation-web/fal-ai';
|
|
34
|
+
|
|
35
|
+
// Initialize CreativeEditor SDK
|
|
36
|
+
CreativeEditorSDK.create(domElement, {
|
|
37
|
+
license: 'your-license-key',
|
|
38
|
+
// Other configuration options...
|
|
39
|
+
}).then(async (cesdk) => {
|
|
40
|
+
// Add the image generation plugin
|
|
41
|
+
cesdk.addPlugin(
|
|
42
|
+
ImageGeneration({
|
|
43
|
+
// Text-to-image provider
|
|
44
|
+
text2image: FalAiImage.RecraftV3({
|
|
45
|
+
proxyUrl: 'https://your-fal-ai-proxy.example.com'
|
|
46
|
+
}),
|
|
47
|
+
|
|
48
|
+
// Image-to-image provider (optional)
|
|
49
|
+
image2image: FalAiImage.GeminiFlashEdit({
|
|
50
|
+
proxyUrl: 'https://your-fal-ai-proxy.example.com'
|
|
51
|
+
}),
|
|
52
|
+
|
|
53
|
+
// Optional configuration
|
|
54
|
+
debug: false,
|
|
55
|
+
dryRun: false
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Providers
|
|
62
|
+
|
|
63
|
+
The plugin comes with two pre-configured providers for fal.ai models:
|
|
64
|
+
|
|
65
|
+
#### 1. RecraftV3 (Text-to-Image)
|
|
66
|
+
|
|
67
|
+
A versatile text-to-image model that generates images based on text prompts:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
text2image: FalAiImage.RecraftV3({
|
|
71
|
+
proxyUrl: 'https://your-fal-ai-proxy.example.com'
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Key features:
|
|
76
|
+
- Multiple style options (realistic, illustration, vector)
|
|
77
|
+
- Various image size presets
|
|
78
|
+
- Custom dimensions support
|
|
79
|
+
- Adjustable quality settings
|
|
80
|
+
|
|
81
|
+
#### 2. GeminiFlashEdit (Image-to-Image)
|
|
82
|
+
|
|
83
|
+
An image modification model that transforms existing images:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
image2image: FalAiImage.GeminiFlashEdit({
|
|
87
|
+
proxyUrl: 'https://your-fal-ai-proxy.example.com'
|
|
88
|
+
})
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Key features:
|
|
92
|
+
- Transform existing images with text prompts
|
|
93
|
+
- Available directly through canvas quick actions
|
|
94
|
+
- Maintains original image dimensions
|
|
95
|
+
|
|
96
|
+
### Configuration Options
|
|
97
|
+
|
|
98
|
+
The plugin accepts the following configuration options:
|
|
99
|
+
|
|
100
|
+
| Option | Type | Description | Default |
|
|
101
|
+
|--------|------|-------------|---------|
|
|
102
|
+
| `text2image` | Provider | Provider for text-to-image generation | undefined |
|
|
103
|
+
| `image2image` | Provider | Provider for image-to-image transformation | undefined |
|
|
104
|
+
| `debug` | boolean | Enable debug logging | false |
|
|
105
|
+
| `dryRun` | boolean | Simulate generation without API calls | false |
|
|
106
|
+
| `middleware` | Function | Custom middleware for the generation process | undefined |
|
|
107
|
+
|
|
108
|
+
### Using a Proxy
|
|
109
|
+
|
|
110
|
+
For security reasons, it's recommended to use a proxy server to handle API requests to fal.ai. The proxy URL is required when configuring providers:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
text2image: FalAiImage.RecraftV3({
|
|
114
|
+
proxyUrl: 'https://your-fal-ai-proxy.example.com'
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You'll need to implement a proxy server that forwards requests to fal.ai and handles authentication.
|
|
119
|
+
|
|
120
|
+
## API Reference
|
|
121
|
+
|
|
122
|
+
### Main Plugin
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
ImageGeneration(options: PluginConfiguration): EditorPlugin
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Creates and returns a plugin that can be added to CreativeEditor SDK.
|
|
129
|
+
|
|
130
|
+
### Plugin Configuration
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
interface PluginConfiguration {
|
|
134
|
+
// Provider for text-to-image generation
|
|
135
|
+
text2image?: AiImageProvider;
|
|
136
|
+
|
|
137
|
+
// Provider for image-to-image generation
|
|
138
|
+
image2image?: AiImageProvider;
|
|
139
|
+
|
|
140
|
+
// Enable debug logging
|
|
141
|
+
debug?: boolean;
|
|
142
|
+
|
|
143
|
+
// Skip actual API calls for testing
|
|
144
|
+
dryRun?: boolean;
|
|
145
|
+
|
|
146
|
+
// Extend the generation process
|
|
147
|
+
middleware?: GenerationMiddleware;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Fal.ai Providers
|
|
152
|
+
|
|
153
|
+
#### RecraftV3
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
FalAiImage.RecraftV3(config: {
|
|
157
|
+
proxyUrl: string;
|
|
158
|
+
debug?: boolean;
|
|
159
|
+
})
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### GeminiFlashEdit
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
FalAiImage.GeminiFlashEdit(config: {
|
|
166
|
+
proxyUrl: string;
|
|
167
|
+
debug?: boolean;
|
|
168
|
+
})
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## UI Integration
|
|
172
|
+
|
|
173
|
+
The plugin automatically registers the following UI components:
|
|
174
|
+
|
|
175
|
+
1. **Generation Panel**: A sidebar panel for text-to-image generation
|
|
176
|
+
2. **Quick Actions**: Canvas menu items for image-to-image transformations
|
|
177
|
+
3. **History Library**: Displays previously generated images
|
|
178
|
+
4. **Dock Component**: A button in the dock area to open the image generation panel
|
|
179
|
+
|
|
180
|
+
### Panel IDs
|
|
181
|
+
|
|
182
|
+
- Main panel: `ly.img.ai/image-generation`
|
|
183
|
+
- Canvas quick actions: `ly.img.ai.image.canvasMenu`
|
|
184
|
+
- Provider-specific panels:
|
|
185
|
+
- RecraftV3: `ly.img.ai/fal-ai/recraft-v3`
|
|
186
|
+
- GeminiFlashEdit: `ly.img.ai/fal-ai/gemini-flash-edit`
|
|
187
|
+
|
|
188
|
+
### Asset History
|
|
189
|
+
|
|
190
|
+
Generated images are automatically stored in asset sources with the following IDs:
|
|
191
|
+
- RecraftV3: `fal-ai/recraft-v3.history`
|
|
192
|
+
- GeminiFlashEdit: `fal-ai/gemini-flash-edit.history`
|
|
193
|
+
|
|
194
|
+
### Dock Integration
|
|
195
|
+
|
|
196
|
+
The plugin automatically registers a dock component with a sparkle icon that opens the image generation panel. To customize the component's position in the dock, use the `setDockOrder` method:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
// Add the AI Image component to the beginning of the dock
|
|
200
|
+
cesdk.ui.setDockOrder([
|
|
201
|
+
'ly.img.ai/image-generation.dock',
|
|
202
|
+
...cesdk.ui.getDockOrder()
|
|
203
|
+
]);
|
|
204
|
+
|
|
205
|
+
// Or add it at a specific position
|
|
206
|
+
const currentOrder = cesdk.ui.getDockOrder();
|
|
207
|
+
currentOrder.splice(2, 0, 'ly.img.ai/image-generation.dock');
|
|
208
|
+
cesdk.ui.setDockOrder(currentOrder);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Related Packages
|
|
212
|
+
|
|
213
|
+
- [@imgly/plugin-ai-generation-web](https://github.com/imgly/plugin-ai-generation-web) - Core utilities for AI generation
|
|
214
|
+
- [@imgly/plugin-ai-video-generation-web](https://github.com/imgly/plugin-ai-video-generation-web) - AI video generation
|
|
215
|
+
- [@imgly/plugin-ai-audio-generation-web](https://github.com/imgly/plugin-ai-audio-generation-web) - AI audio generation
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
This plugin is part of the IMG.LY plugin ecosystem for CreativeEditor SDK. Please refer to the license terms in the package.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_ID = "@imgly/plugin-ai-image-generation-web";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ImageOutput, type Provider } from '@imgly/plugin-ai-generation-web';
|
|
2
|
+
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
3
|
+
type GeminiFlashEditInput = {
|
|
4
|
+
prompt: string;
|
|
5
|
+
image_url: string;
|
|
6
|
+
};
|
|
7
|
+
type ProviderConfiguration = {
|
|
8
|
+
proxyUrl: string;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function GeminiFlashEdit(config: {
|
|
12
|
+
proxyUrl: string;
|
|
13
|
+
}): (context: {
|
|
14
|
+
cesdk: CreativeEditorSDK;
|
|
15
|
+
}) => Promise<Provider<'image', GeminiFlashEditInput, ImageOutput>>;
|
|
16
|
+
declare function getProvider(cesdk: CreativeEditorSDK, config: ProviderConfiguration): Provider<'image', GeminiFlashEditInput, ImageOutput>;
|
|
17
|
+
export default getProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QuickAction } from '@imgly/plugin-ai-generation-web';
|
|
2
|
+
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
3
|
+
type GeminiFlashEditInput = {
|
|
4
|
+
prompt: string;
|
|
5
|
+
image_url: string;
|
|
6
|
+
blockId?: number;
|
|
7
|
+
};
|
|
8
|
+
type GeminiFlashEditOutput = {
|
|
9
|
+
kind: 'image';
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function createGeminiFlashEditQuickActions(cesdk: CreativeEditorSDK): QuickAction<GeminiFlashEditInput, GeminiFlashEditOutput>[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RecraftV3Input } from '@fal-ai/client/endpoints';
|
|
2
|
+
export declare function getImageDimensions(id: string): {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
};
|
|
6
|
+
export type StyleId = Extract<RecraftV3Input['style'], string>;
|
|
7
|
+
export declare const STYLES_IMAGE: {
|
|
8
|
+
id: StyleId;
|
|
9
|
+
label: string;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const STYLE_IMAGE_DEFAULT: {
|
|
12
|
+
id: StyleId;
|
|
13
|
+
label: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const STYLES_VECTOR: {
|
|
16
|
+
id: StyleId;
|
|
17
|
+
label: string;
|
|
18
|
+
}[];
|
|
19
|
+
export declare const STYLE_VECTOR_DEFAULT: {
|
|
20
|
+
id: StyleId;
|
|
21
|
+
label: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function getStyleThumbnail(id: StyleId): string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Provider } from '@imgly/plugin-ai-generation-web';
|
|
2
|
+
import { type RecraftV3Input } from '@fal-ai/client/endpoints';
|
|
3
|
+
import CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
4
|
+
type RecraftV3Output = {
|
|
5
|
+
kind: 'image';
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
export type StyleId = Extract<RecraftV3Input['style'], string>;
|
|
9
|
+
type ProviderConfiguration = {
|
|
10
|
+
proxyUrl: string;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function RecraftV3(config: ProviderConfiguration): (context: {
|
|
14
|
+
cesdk: CreativeEditorSDK;
|
|
15
|
+
}) => Promise<Provider<'image', RecraftV3Input, RecraftV3Output>>;
|
|
16
|
+
declare function getProvider(cesdk: CreativeEditorSDK, config: ProviderConfiguration): Provider<'image', RecraftV3Input, RecraftV3Output>;
|
|
17
|
+
export default getProvider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type OpenAPIV3 } from 'openapi-types';
|
|
2
|
+
import CreativeEditorSDK, { CreativeEngine } from '@cesdk/cesdk-js';
|
|
3
|
+
import { ImageOutput, RenderCustomProperty, GetBlockInput, Provider, QuickAction } from '@imgly/plugin-ai-generation-web';
|
|
4
|
+
type ImageProviderConfiguration = {
|
|
5
|
+
proxyUrl: string;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a base provider from schema. This should work out of the box
|
|
10
|
+
* but may be rough around the edges and should/can be further customized.
|
|
11
|
+
*/
|
|
12
|
+
declare function createImageProvider<I extends Record<string, any>>(options: {
|
|
13
|
+
modelKey: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
schema: OpenAPIV3.Document;
|
|
16
|
+
inputReference: string;
|
|
17
|
+
useFlow?: 'placeholder' | 'generation-only';
|
|
18
|
+
initialize?: (context: {
|
|
19
|
+
cesdk?: CreativeEditorSDK;
|
|
20
|
+
engine: CreativeEngine;
|
|
21
|
+
}) => void;
|
|
22
|
+
renderCustomProperty?: RenderCustomProperty;
|
|
23
|
+
quickActions?: QuickAction<I, ImageOutput>[];
|
|
24
|
+
getBlockInput?: GetBlockInput<'image', I>;
|
|
25
|
+
getImageSize?: (input: I) => {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
cesdk?: CreativeEditorSDK;
|
|
30
|
+
}, config: ImageProviderConfiguration): Provider<'image', I, {
|
|
31
|
+
kind: 'image';
|
|
32
|
+
url: string;
|
|
33
|
+
}>;
|
|
34
|
+
export default createImageProvider;
|