@imgly/plugin-ai-apps-web 0.2.16 → 1.68.0-rc.1

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/README.md CHANGED
@@ -1,581 +1,9 @@
1
- # IMG.LY AI Apps for Web
1
+ # @imgly/plugin-ai-apps-web
2
2
 
3
- A plugin for orchestrating all AI generation capabilities in CreativeEditor SDK.
3
+ AI apps orchestration plugin for the CE.SDK editor
4
4
 
5
- ## Overview
6
-
7
- The `@imgly/plugin-ai-apps-web` package provides a unified interface for accessing and organizing all AI generation features within the CreativeEditor SDK. It combines image, video, audio, and text generation capabilities into a single cohesive user experience.
8
-
9
- ### Key Features
10
-
11
- - **Unified AI Experience**: Centralized access to all AI generation capabilities
12
- - **AI Dock Component**: Single entry point for all AI features with loading indicators
13
- - **Smart Provider Management**: Automatically organizes providers based on editor mode
14
- - **Integrated History**: Seamless integration with asset libraries for generated content
15
- - **Mode-Aware Interface**: Different UI layouts for Design and Video modes
16
- - **Cross-Plugin Support**: Works with all IMG.LY AI generation plugins
17
-
18
- ## Installation
19
-
20
- ```bash
21
- npm install @imgly/plugin-ai-apps-web
22
- ```
23
-
24
- ## Basic Usage
25
-
26
- To use the plugin, import it and configure it with your preferred providers:
27
-
28
- ```typescript
29
- import CreativeEditorSDK from '@cesdk/cesdk-js';
30
- import AiApps from '@imgly/plugin-ai-apps-web';
31
-
32
- // Import providers from individual AI generation packages
33
- import { AnthropicProvider } from '@imgly/plugin-ai-text-generation-web/anthropic';
34
- import FalAiImage from '@imgly/plugin-ai-image-generation-web/fal-ai';
35
- import FalAiVideo from '@imgly/plugin-ai-video-generation-web/fal-ai';
36
- import ElevenLabs from '@imgly/plugin-ai-audio-generation-web/elevenlabs';
37
- import FalAiSticker from '@imgly/plugin-ai-sticker-generation-web/fal-ai';
38
-
39
- // Initialize CreativeEditor SDK
40
- CreativeEditorSDK.create(domElement, {
41
- license: 'your-license-key'
42
- // Other configuration options...
43
- }).then(async (cesdk) => {
44
- // Add the AI Apps plugin
45
- cesdk.addPlugin(
46
- AiApps({
47
- providers: {
48
- // Text generation
49
- text2text: AnthropicProvider({
50
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
51
- }),
52
-
53
- // Image generation
54
- text2image: FalAiImage.RecraftV3({
55
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
56
- }),
57
- image2image: FalAiImage.GeminiFlashEdit({
58
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
59
- }),
60
-
61
- // Video generation (used in video mode)
62
- text2video: FalAiVideo.MinimaxVideo01Live({
63
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
64
- }),
65
- image2video: FalAiVideo.MinimaxVideo01LiveImageToVideo({
66
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
67
- }),
68
-
69
- // Audio generation (used in video mode)
70
- text2speech: ElevenLabs.MonolingualV1({
71
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
72
- }),
73
- text2sound: ElevenLabs.SoundEffects({
74
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
75
- }),
76
-
77
- // Sticker generation
78
- text2sticker: FalAiSticker.Recraft20b({
79
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
80
- })
81
- }
82
- })
83
- );
84
-
85
- // Position the AI dock button in the dock order
86
- cesdk.ui.setDockOrder(['ly.img.ai.apps.dock', ...cesdk.ui.getDockOrder()]);
87
- });
88
- ```
89
-
90
- ## Configuration Options
91
-
92
- The plugin accepts the following configuration options:
93
-
94
- | Option | Type | Description |
95
- | ----------- | ----------- | --------------------------------------------- |
96
- | `providers` | `Providers` | Object containing all AI providers to be used |
97
- | `debug` | `boolean` | Print debug messages |
98
-
99
- ### Providers Configuration
100
-
101
- The `providers` object can include the following provider functions:
102
-
103
- | Provider | Type | Description |
104
- | ------------- | ------------------- | -------------------------------------------------------- |
105
- | `text2text` | `Provider<'text'>` | Provider for text generation and transformation |
106
- | `text2image` | `Provider<'image'>` | Provider for text-to-image generation |
107
- | `image2image` | `Provider<'image'>` | Provider for image-to-image transformation |
108
- | `text2video` | `Provider<'video'>` | Provider for text-to-video generation (video mode only) |
109
- | `image2video` | `Provider<'video'>` | Provider for image-to-video generation (video mode only) |
110
- | `text2speech` | `Provider<'audio'>` | Provider for text-to-speech generation (video mode only) |
111
- | `text2sound` | `Provider<'audio'>` | Provider for sound effects generation (video mode only) |
112
- | `text2sticker` | `Provider<'sticker'>` | Provider for sticker generation |
113
-
114
- ### Provider Selection Strategy
115
-
116
- The plugin intelligently selects which providers to use based on the current editor mode:
117
-
118
- #### Design Mode
119
- - **Uses**: `text2text`, `text2image`, `image2image`, `text2sticker`
120
- - **Focus**: Image, text, and sticker generation for design workflows
121
- - **UI**: Shows AI apps cards for different generation types
122
-
123
- #### Video Mode
124
- - **Uses**: All providers including `text2video`, `image2video`, `text2speech`, `text2sound`, `text2sticker`
125
- - **Focus**: Comprehensive media generation for video production
126
- - **UI**: Shows AI apps cards for different generation types
127
-
128
- ## Advanced Configuration
129
-
130
- ### Multiple Providers per Type
131
-
132
- You can configure multiple providers for the same generation type by passing an array. When multiple providers are configured, a selection box will be rendered in the AI app interface allowing users to choose between different providers:
133
-
134
- ```typescript
135
- import FalAiImage from '@imgly/plugin-ai-image-generation-web/fal-ai';
136
- import OpenAiImage from '@imgly/plugin-ai-image-generation-web/open-ai';
137
-
138
- cesdk.addPlugin(
139
- AiApps({
140
- providers: {
141
- // Multiple image providers - selection box will be shown
142
- text2image: [
143
- FalAiImage.RecraftV3({
144
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
145
- }),
146
- FalAiImage.Recraft20b({
147
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
148
- }),
149
- OpenAiImage.GptImage1.Text2Image({
150
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
151
- })
152
- ],
153
-
154
- // Other providers...
155
- }
156
- })
157
- );
158
- ```
159
-
160
- ### Custom Headers and Configuration
161
-
162
- Pass custom headers and configuration to providers:
163
-
164
- ```typescript
165
- cesdk.addPlugin(
166
- AiApps({
167
- providers: {
168
- text2image: FalAiImage.RecraftV3({
169
- proxyUrl: 'http://your-proxy-server.com/api/proxy',
170
- headers: {
171
- 'x-client-version': '1.0.0',
172
- 'x-request-source': 'cesdk-plugin',
173
- 'x-user-id': 'user-123'
174
- },
175
- debug: true
176
- })
177
- },
178
- debug: true
179
- })
180
- );
181
- ```
182
-
183
- ### Property Configuration
184
-
185
- Providers support configuring default values for their properties. These defaults can be static or dynamic based on context:
186
-
187
- ```typescript
188
- cesdk.addPlugin(
189
- AiApps({
190
- providers: {
191
- text2image: FalAiImage.RecraftV3({
192
- proxyUrl: 'http://your-proxy-server.com/api/proxy',
193
- properties: {
194
- // Static default
195
- image_size: { default: 'square_hd' },
196
-
197
- // Dynamic default based on locale
198
- style: {
199
- default: (context) => {
200
- return context.locale === 'ja' ? 'anime' : 'realistic';
201
- }
202
- }
203
- }
204
- })
205
- }
206
- })
207
- );
208
- ```
209
-
210
- ## UI Integration
211
-
212
- The plugin adds the following UI components to CreativeEditor SDK:
213
-
214
- ### AI Dock Button
215
-
216
- The main entry point for all AI features, accessible from the dock:
217
-
218
- - **ID**: `ly.img.ai.apps.dock`
219
- - **Functionality**: Opens AI generation interface
220
- - **Loading States**: Shows progress indicators during generation
221
- - **Mode Awareness**: Adapts interface based on current editor mode
222
-
223
- ### AI Apps Menu
224
-
225
- The plugin shows a card-based interface for different AI capabilities:
226
-
227
- - **Generate Image**: Access to image generation providers
228
- - **Generate Video**: Access to video generation providers
229
- - **Generate Audio**: Access to audio generation providers
230
- - **Edit Text**: Access to text generation providers
231
-
232
- ### Dock Integration
233
-
234
- To position the AI dock button in your editor's dock, use the `setDockOrder` method:
235
-
236
- ```typescript
237
- // Add the AI dock component to the beginning of the dock
238
- cesdk.ui.setDockOrder(['ly.img.ai.apps.dock', ...cesdk.ui.getDockOrder()]);
239
-
240
- // Or add it at a specific position
241
- const currentOrder = cesdk.ui.getDockOrder();
242
- currentOrder.splice(2, 0, 'ly.img.ai.apps.dock');
243
- cesdk.ui.setDockOrder(currentOrder);
244
- ```
245
-
246
- ## Asset History Integration
247
-
248
- The plugin automatically integrates generated assets into the appropriate asset libraries. For each generation type, both a history asset source and a corresponding asset library entry are automatically created with the same ID:
249
-
250
- - **Image Generation History**: `ly.img.ai.image-generation.history`
251
- - **Video Generation History**: `ly.img.ai.video-generation.history`
252
- - **Audio Generation History**: `ly.img.ai.audio-generation.history`
253
- - **Sticker Generation History**: `ly.img.ai.sticker-generation.history`
254
-
255
- These asset library entries are automatically configured with:
256
- - Sorted by insertion date (newest first)
257
- - Square grid item height
258
- - Cover background type
259
- - Removable items
260
-
261
- ### Integrating with Default Asset Libraries
262
-
263
- To add these history sources to CE.SDK's default asset library entries, use the following approach:
264
-
265
- ```typescript
266
- // Add AI image history to the default image asset library
267
- const imageEntry = cesdk.ui.getAssetLibraryEntry('ly.img.image');
268
- if (imageEntry != null) {
269
- cesdk.ui.updateAssetLibraryEntry('ly.img.image', {
270
- sourceIds: [...imageEntry.sourceIds, 'ly.img.ai.image-generation.history']
271
- });
272
- }
273
-
274
- // Add AI video history to the default video asset library
275
- const videoEntry = cesdk.ui.getAssetLibraryEntry('ly.img.video');
276
- if (videoEntry != null) {
277
- cesdk.ui.updateAssetLibraryEntry('ly.img.video', {
278
- sourceIds: [...videoEntry.sourceIds, 'ly.img.ai.video-generation.history']
279
- });
280
- }
281
-
282
- // Add AI audio history to the default audio asset library
283
- const audioEntry = cesdk.ui.getAssetLibraryEntry('ly.img.audio');
284
- if (audioEntry != null) {
285
- cesdk.ui.updateAssetLibraryEntry('ly.img.audio', {
286
- sourceIds: [...audioEntry.sourceIds, 'ly.img.ai.audio-generation.history']
287
- });
288
- }
289
-
290
- // Add AI sticker history to the default sticker asset library
291
- const stickerEntry = instance.ui.getAssetLibraryEntry('ly.img.sticker');
292
- if (stickerEntry != null) {
293
- instance.ui.updateAssetLibraryEntry('ly.img.sticker', {
294
- sourceIds: [...stickerEntry.sourceIds, 'ly.img.ai.sticker-generation.history']
295
- });
296
- }
297
- ```
298
-
299
- This integration creates a seamless experience where users can easily find and reuse their AI-generated assets alongside other content.
300
-
301
- ## Quick Actions Integration
302
-
303
- The plugin automatically integrates with the quick actions system, providing context-sensitive AI operations directly in the canvas menu. You need to specify the children with the quick action order:
304
-
305
- ```typescript
306
- // Quick actions are automatically registered and will appear in canvas menus
307
- cesdk.ui.setCanvasMenuOrder([
308
- {
309
- id: 'ly.img.ai.text.canvasMenu',
310
- children: [
311
- 'ly.img.improve',
312
- 'ly.img.fix',
313
- 'ly.img.shorter',
314
- 'ly.img.longer',
315
- 'ly.img.separator',
316
- 'ly.img.changeTone',
317
- 'ly.img.translate',
318
- 'ly.img.separator',
319
- 'ly.img.changeTextTo'
320
- ]
321
- },
322
- {
323
- id: 'ly.img.ai.image.canvasMenu',
324
- children: [
325
- 'ly.img.styleTransfer',
326
- 'ly.img.artistTransfer',
327
- 'ly.img.separator',
328
- 'ly.img.editImage',
329
- 'ly.img.swapBackground',
330
- 'ly.img.createVariant',
331
- 'ly.img.combineImages',
332
- 'ly.img.separator',
333
- 'ly.img.remixPage',
334
- 'ly.img.separator',
335
- 'ly.img.createVideo'
336
- ]
337
- },
338
- ...cesdk.ui.getCanvasMenuOrder()
339
- ]);
340
- ```
341
-
342
- Quick actions provide:
343
- - **Context-aware operations**: Work with currently selected blocks
344
- - **One-click transformations**: Apply AI operations without opening panels
345
- - **Cross-plugin functionality**: Actions from one plugin can work with providers from another
346
-
347
- ## Error Handling and Debugging
348
-
349
- ### Debug Mode
350
-
351
- Enable debug mode to get detailed logging information:
352
-
353
- ```typescript
354
- cesdk.addPlugin(
355
- AiApps({
356
- providers: {
357
- text2image: FalAiImage.RecraftV3({
358
- proxyUrl: 'http://your-proxy-server.com/api/proxy',
359
- debug: true // Provider-level debugging
360
- })
361
- },
362
- debug: true // Plugin-level debugging
363
- })
364
- );
365
- ```
366
-
367
- ### Common Issues and Solutions
368
-
369
- #### Provider Not Loading
370
- - **Check proxy URLs**: Ensure all proxy URLs are correctly configured and accessible
371
- - **Verify licenses**: Make sure your CreativeEditor SDK license includes AI features
372
- - **Check browser console**: Look for network errors or API issues
373
-
374
- #### Quick Actions Not Appearing
375
- - **Verify canvas menu order**: Ensure quick action menus are added to canvas menu order with proper children configuration
376
- - **Check provider support**: Verify that providers declare support for the quick actions
377
- - **Scope permissions**: Ensure blocks have the required scopes for quick actions
378
-
379
- #### Generation Failures
380
- - **API connectivity**: Check that your proxy endpoints are working
381
- - **Rate limiting**: Verify you're not exceeding API rate limits
382
- - **Input validation**: Ensure inputs meet provider requirements
383
-
384
- ## Plugin Architecture
385
-
386
- ### How It Works
387
-
388
- The AI Apps plugin acts as an orchestrator that:
389
-
390
- 1. **Initializes Providers**: Sets up all configured AI providers
391
- 2. **Manages UI**: Creates appropriate interface based on editor mode
392
- 3. **Coordinates Actions**: Integrates quick actions across different plugins
393
- 4. **Handles Assets**: Manages generated content and asset library integration
394
-
395
- ### Provider Lifecycle
396
-
397
- 1. **Registration**: Providers are registered with the global ProviderRegistry
398
- 2. **Initialization**: Provider `initialize` methods are called
399
- 3. **UI Setup**: Panels and quick actions are registered
400
- 4. **Event Handling**: The plugin coordinates between providers and UI
401
-
402
- ## TypeScript Support
403
-
404
- The plugin is fully typed with TypeScript, providing excellent development experience:
405
-
406
- ```typescript
407
- import AiApps, { Providers } from '@imgly/plugin-ai-apps-web';
408
-
409
- // Strongly typed provider configuration
410
- const providers: Providers = {
411
- text2image: FalAiImage.RecraftV3({
412
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
413
- }),
414
- // TypeScript will enforce correct provider types
415
- };
416
-
417
- cesdk.addPlugin(AiApps({ providers }));
418
- ```
419
-
420
- ## Related Packages
421
-
422
- This plugin works with the following IMG.LY AI generation packages:
423
-
424
- - **[@imgly/plugin-ai-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-generation-web)** - Core utilities for AI generation
425
- - **[@imgly/plugin-ai-image-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-image-generation-web)** - AI image generation
426
- - **[@imgly/plugin-ai-video-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-video-generation-web)** - AI video generation
427
- - **[@imgly/plugin-ai-audio-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-audio-generation-web)** - AI audio generation
428
- - **[@imgly/plugin-ai-text-generation-web](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-text-generation-web)** - AI text generation
429
-
430
- ## Examples
431
-
432
- ### Simple Setup for Design Mode
433
-
434
- ```typescript
435
- import CreativeEditorSDK from '@cesdk/cesdk-js';
436
- import AiApps from '@imgly/plugin-ai-apps-web';
437
- import FalAiImage from '@imgly/plugin-ai-image-generation-web/fal-ai';
438
-
439
- CreativeEditorSDK.create(domElement, {
440
- license: 'your-license-key'
441
- }).then(async (cesdk) => {
442
- cesdk.addPlugin(
443
- AiApps({
444
- providers: {
445
- text2image: FalAiImage.RecraftV3({
446
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
447
- })
448
- }
449
- })
450
- );
451
-
452
- cesdk.ui.setDockOrder(['ly.img.ai.apps.dock', ...cesdk.ui.getDockOrder()]);
453
- });
454
- ```
455
-
456
- ### Complete Setup for Video Mode
457
-
458
- ```typescript
459
- import CreativeEditorSDK from '@cesdk/cesdk-js';
460
- import AiApps from '@imgly/plugin-ai-apps-web';
461
- import FalAiImage from '@imgly/plugin-ai-image-generation-web/fal-ai';
462
- import FalAiVideo from '@imgly/plugin-ai-video-generation-web/fal-ai';
463
- import ElevenLabs from '@imgly/plugin-ai-audio-generation-web/elevenlabs';
464
- import { AnthropicProvider } from '@imgly/plugin-ai-text-generation-web/anthropic';
465
-
466
- CreativeEditorSDK.create(domElement, {
467
- license: 'your-license-key',
468
- ui: {
469
- elements: {
470
- panels: {
471
- settings: true
472
- }
473
- }
474
- }
475
- }).then(async (cesdk) => {
476
- cesdk.addPlugin(
477
- AiApps({
478
- providers: {
479
- text2text: AnthropicProvider({
480
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
481
- }),
482
- text2image: FalAiImage.RecraftV3({
483
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
484
- }),
485
- image2image: FalAiImage.GeminiFlashEdit({
486
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
487
- }),
488
- text2video: FalAiVideo.MinimaxVideo01Live({
489
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
490
- }),
491
- image2video: FalAiVideo.MinimaxVideo01LiveImageToVideo({
492
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
493
- }),
494
- text2speech: ElevenLabs.MonolingualV1({
495
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
496
- }),
497
- text2sound: ElevenLabs.SoundEffects({
498
- proxyUrl: 'http://your-proxy-server.com/api/proxy'
499
- })
500
- }
501
- })
502
- );
503
-
504
- // Setup dock and canvas menus
505
- cesdk.ui.setDockOrder(['ly.img.ai.apps.dock', ...cesdk.ui.getDockOrder()]);
506
- cesdk.ui.setCanvasMenuOrder([
507
- {
508
- id: 'ly.img.ai.text.canvasMenu',
509
- children: [
510
- 'ly.img.improve',
511
- 'ly.img.fix',
512
- 'ly.img.shorter',
513
- 'ly.img.longer',
514
- 'ly.img.separator',
515
- 'ly.img.changeTone',
516
- 'ly.img.translate',
517
- 'ly.img.separator',
518
- 'ly.img.changeTextTo'
519
- ]
520
- },
521
- {
522
- id: 'ly.img.ai.image.canvasMenu',
523
- children: [
524
- 'ly.img.styleTransfer',
525
- 'ly.img.artistTransfer',
526
- 'ly.img.separator',
527
- 'ly.img.editImage',
528
- 'ly.img.swapBackground',
529
- 'ly.img.createVariant',
530
- 'ly.img.combineImages',
531
- 'ly.img.separator',
532
- 'ly.img.remixPage',
533
- 'ly.img.separator',
534
- 'ly.img.createVideo'
535
- ]
536
- },
537
- ...cesdk.ui.getCanvasMenuOrder()
538
- ]);
539
- });
540
- ```
541
-
542
- ## Internationalization (i18n)
543
-
544
- The AI Apps plugin supports full internationalization. To customize translations, set them **before** adding the plugin:
545
-
546
- ```typescript
547
- CreativeEditorSDK.create(domElement, {
548
- license: 'your-license-key',
549
- locale: 'de'
550
- }).then(async (cesdk) => {
551
- // Set custom translations BEFORE adding plugins
552
- cesdk.i18n.setTranslations({
553
- en: {
554
- '@imgly/plugin-ai-image-generation-web.action.label': 'Create Image',
555
- 'panel.ly.img.ai.apps': 'AI Tools'
556
- },
557
- de: {
558
- '@imgly/plugin-ai-image-generation-web.action.label': 'Bild erstellen',
559
- 'panel.ly.img.ai.apps': 'KI-Werkzeuge'
560
- }
561
- });
562
-
563
- // Now add the plugins - they won't override your custom translations
564
- await cesdk.addPlugin(AiApps({ providers: { /* ... */ } }));
565
- });
566
- ```
567
-
568
- For detailed documentation on the translation system, including all available translation keys and utilities, see the [Internationalization section](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-generation-web#internationalization-i18n) in the core AI generation package.
569
-
570
- ### Translation Files
571
-
572
- - [AI Apps translations](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-apps-web/translations.json) - AI Apps panel labels
573
- - [Base translations](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-generation-web/translations.json) - Core translation keys
574
- - [Image generation translations](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-image-generation-web/translations.json) - Image generation interfaces
575
- - [Video generation translations](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-video-generation-web/translations.json) - Video generation interfaces
576
- - [Text generation translations](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-text-generation-web/translations.json) - Text generation interfaces
577
- - [Audio generation translations](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-audio-generation-web/translations.json) - Audio generation interfaces
5
+ For documentation, visit: https://img.ly/docs/cesdk
578
6
 
579
7
  ## License
580
8
 
581
- This plugin is part of the IMG.LY plugin ecosystem for CreativeEditor SDK. Please refer to the license terms in the package.
9
+ This plugin is part of the IMG.LY plugin ecosystem for CreativeEditor SDK.