@imgly/plugin-ai-generation-web 0.2.2 → 0.2.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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.4] - 2025-08-07
6
+
7
+ ### New Features
8
+
9
+ - [all] **Provider Label Translations**: Added support for provider label translations
10
+ - [all] **Extended Provider Configuration**: Added support for `history` and `supportedQuickActions` configuration fields in `CommonProviderConfiguration`, allowing customers to:
11
+ - Override provider's default history asset source (`history` field) - can be set to `false` to disable history, `'@imgly/local'` for temporary storage, `'@imgly/indexedDB'` for persistent browser storage, or any custom asset source ID
12
+ - Configure supported quick actions (`supportedQuickActions` field) - can disable quick actions by setting to `false`/`null`, keep defaults with `true`, or override with custom mappings and configurations
13
+ - Both fields are optional and maintain backward compatibility with existing provider configurations
14
+ - [generation-web] **Utility Function**: Added `mergeQuickActionsConfig` utility function for merging provider defaults with user configuration overrides, exported from `@imgly/plugin-ai-generation-web` with comprehensive Jest test coverage
15
+
16
+ ## [0.2.3] - 2025-07-23
17
+
18
+ - [all] **Automatic History Asset Library Entries**: Composite history asset sources now automatically have corresponding asset library entries created with the same IDs (e.g., `ly.img.ai.image-generation.history`)
19
+ - [all] **Provider Selection in Expanded Quick Actions**: When a quick action is expanded, users can now switch between all providers that support that specific quick action, enhancing flexibility in provider selection
20
+ - [all] **Quick Action Can Disable Lock**: Some quick actions can now decide to not lock the block when operating on a block. Examples are `CreateVariant` and `CombineImages`.
21
+ - [image-generation] **Ideogram V3**: Added support for Ideogram V3 provider for image generation, which supports text-to-image and image-to-image generation
22
+
5
23
  ## [0.2.2] - 2025-07-16
6
24
 
7
25
  - [ai-apps] Fix issue with undefined `cesdk` instance
package/README.md CHANGED
@@ -202,9 +202,89 @@ interface CommonProviderConfiguration<I, O extends Output> {
202
202
 
203
203
  // Custom headers to include in all API requests
204
204
  headers?: Record<string, string>;
205
+
206
+ // Override provider's default history asset source
207
+ history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
208
+
209
+ // Configure supported quick actions
210
+ supportedQuickActions?: {
211
+ [quickActionId: string]: Partial<QuickActionSupport<I>> | false | null;
212
+ };
205
213
  }
206
214
  ```
207
215
 
216
+ ### Extended Configuration Options
217
+
218
+ #### History Configuration
219
+
220
+ The `history` field allows you to override the provider's default history storage behavior:
221
+
222
+ ```typescript
223
+ const provider = createMyImageProvider({
224
+ proxyUrl: 'https://proxy.example.com',
225
+
226
+ // Disable history storage entirely
227
+ history: false,
228
+
229
+ // Or use temporary local storage (not persistent)
230
+ // history: '@imgly/local',
231
+
232
+ // Or use persistent browser storage (default for most providers)
233
+ // history: '@imgly/indexedDB',
234
+
235
+ // Or use a custom asset source ID
236
+ // history: 'my-custom-asset-source'
237
+ });
238
+ ```
239
+
240
+ **Available Options:**
241
+ - `false`: Disable history storage entirely
242
+ - `'@imgly/local'`: Use temporary local storage (not persistent across sessions)
243
+ - `'@imgly/indexedDB'`: Use browser IndexedDB storage (persistent across sessions)
244
+ - `string`: Use your own custom asset source ID
245
+
246
+ #### Quick Actions Configuration
247
+
248
+ The `supportedQuickActions` field allows you to customize which quick actions are supported and how they behave:
249
+
250
+ ```typescript
251
+ const provider = createMyImageProvider({
252
+ proxyUrl: 'https://proxy.example.com',
253
+
254
+ // Configure quick actions
255
+ supportedQuickActions: {
256
+ // Remove an unwanted quick action
257
+ 'ly.img.editImage': false,
258
+
259
+ // Override with custom mapping
260
+ 'ly.img.swapBackground': {
261
+ mapInput: (input) => ({
262
+ prompt: input.prompt,
263
+ image_url: input.uri,
264
+ strength: 0.9, // Custom strength
265
+ style: 'REALISTIC' // Force realistic style
266
+ })
267
+ },
268
+
269
+ // Add support for new quick action
270
+ 'ly.img.customAction': {
271
+ mapInput: (input) => ({
272
+ prompt: `Custom prefix: ${input.text}`,
273
+ image_url: input.imageUrl
274
+ })
275
+ }
276
+ }
277
+ });
278
+ ```
279
+
280
+ **Configuration Values:**
281
+ - `false` or `null`: Remove the quick action entirely
282
+ - `true`: Keep the provider's default implementation
283
+ - Object with `mapInput`: Override the quick action with custom input mapping
284
+ - Object with other properties: Override with custom configuration
285
+
286
+ ### Headers Configuration
287
+
208
288
  The `headers` property allows you to include custom HTTP headers in all API requests made by your provider. This is useful for:
209
289
  - Adding custom client identification headers
210
290
  - Including version information
@@ -657,6 +737,91 @@ render: ({ builder, isExpanded, toggleExpand }) => {
657
737
  }
658
738
  ```
659
739
 
740
+ ## Customizing Labels and Text
741
+
742
+ You can customize all labels and text in the AI generation interface using the translation system. This allows you to provide better labels for your users in any language.
743
+
744
+ ### Translation Priority
745
+
746
+ The system checks for translations in this order (highest to lowest priority):
747
+
748
+ 1. **Provider & Kind-specific**: `ly.img.plugin-ai-${kind}-generation-web.${provider}.property.${field}` - Override labels for a specific AI provider and generation type
749
+ 2. **Generic**: `ly.img.plugin-ai-generation-web.property.${field}` - Override labels for all AI plugins
750
+
751
+ Where `${kind}` can be:
752
+ - `image` for image generation plugins
753
+ - `video` for video generation plugins
754
+ - `audio` for audio generation plugins
755
+ - `text` for text generation plugins
756
+
757
+ ### Basic Example
758
+
759
+ ```typescript
760
+ // Customize labels for your AI generation interface
761
+ cesdk.i18n.setTranslations({
762
+ en: {
763
+ // Generic labels (applies to ALL AI plugins)
764
+ 'ly.img.plugin-ai-generation-web.property.prompt': 'Describe what you want to create',
765
+ 'ly.img.plugin-ai-generation-web.property.image_size': 'Image Dimensions',
766
+ 'ly.img.plugin-ai-generation-web.property.duration': 'Video Length',
767
+
768
+ // Provider-specific for images (highest priority)
769
+ 'ly.img.plugin-ai-image-generation-web.fal-ai/recraft-v3.property.prompt': 'Describe your Recraft image',
770
+ 'ly.img.plugin-ai-image-generation-web.fal-ai/recraft-v3.property.image_size': 'Canvas Size',
771
+
772
+ // Provider-specific for videos (highest priority)
773
+ 'ly.img.plugin-ai-video-generation-web.fal-ai/veo3.property.prompt': 'Describe your video scene',
774
+ 'ly.img.plugin-ai-video-generation-web.fal-ai/veo3.property.duration': 'Video Duration'
775
+ }
776
+ });
777
+ ```
778
+
779
+ ### Dropdown Options
780
+
781
+ For dropdown menus, add the option value to the translation key:
782
+
783
+ ```typescript
784
+ cesdk.i18n.setTranslations({
785
+ en: {
786
+ // Image generation dropdown options
787
+ 'ly.img.plugin-ai-image-generation-web.fal-ai/recraft-v3.property.image_size.square_hd': 'Square HD (1024×1024)',
788
+ 'ly.img.plugin-ai-image-generation-web.fal-ai/recraft-v3.property.image_size.portrait_4_3': 'Portrait 4:3 (768×1024)',
789
+
790
+ // Video generation dropdown options
791
+ 'ly.img.plugin-ai-video-generation-web.fal-ai/veo3.property.duration.5': '5 seconds',
792
+ 'ly.img.plugin-ai-video-generation-web.fal-ai/veo3.property.duration.10': '10 seconds'
793
+ }
794
+ });
795
+ ```
796
+
797
+ ### QuickAction Translations
798
+
799
+ QuickActions (like "Edit Image", "Style Transfer", etc.) use their own translation keys:
800
+
801
+ ```typescript
802
+ cesdk.i18n.setTranslations({
803
+ en: {
804
+ // Image generation QuickActions
805
+ 'ly.img.plugin-ai-image-generation-web.quickAction.editImage': 'Edit Image...',
806
+ 'ly.img.plugin-ai-image-generation-web.quickAction.editImage.prompt': 'Edit Image...',
807
+ 'ly.img.plugin-ai-image-generation-web.quickAction.editImage.apply': 'Change',
808
+
809
+ // Text generation QuickActions
810
+ 'ly.img.plugin-ai-text-generation-web.quickAction.improve': 'Improve Text',
811
+ 'ly.img.plugin-ai-text-generation-web.quickAction.translate': 'Translate Text',
812
+
813
+ // Video generation QuickActions
814
+ 'ly.img.plugin-ai-video-generation-web.quickAction.createVideo': 'Create Video'
815
+ }
816
+ });
817
+ ```
818
+
819
+ **QuickAction Translation Structure:**
820
+ - Base key (e.g., `.quickAction.editImage`): Button text when QuickAction is collapsed
821
+ - `.prompt`: Label for input field when expanded
822
+ - `.prompt.placeholder`: Placeholder text for input field
823
+ - `.apply`: Text for action/submit button
824
+
660
825
  ## Using Your Provider
661
826
 
662
827
  Once you've created your provider, you need to initialize it with CreativeEditor SDK and integrate it into the UI.
@@ -700,12 +865,12 @@ function setupMyProvider(cesdk) {
700
865
  When a provider is initialized, it automatically registers panels with specific IDs:
701
866
 
702
867
  ```
703
- ly.img.ai.{provider-id}
868
+ ly.img.plugin-ai-{kind}-generation-web.{provider-id}
704
869
  ```
705
870
 
706
871
  For example:
707
- - A provider with ID `my-image-provider` registers a panel with ID `ly.img.ai.my-image-provider`
708
- - A provider with ID `fal-ai/recraft-v3` registers a panel with ID `ly.img.ai.fal-ai/recraft-v3`
872
+ - A provider with ID `my-image-provider` for images registers a panel with ID `ly.img.plugin-ai-image-generation-web.my-image-provider`
873
+ - A provider with ID `fal-ai/recraft-v3` for images registers a panel with ID `ly.img.plugin-ai-image-generation-web.fal-ai/recraft-v3`
709
874
 
710
875
  You can programmatically get a panel ID using the `getPanelId` function:
711
876
 
@@ -724,14 +889,14 @@ cesdk.ui.openPanel(panelId);
724
889
  Quick actions are automatically registered in canvas menus with these IDs:
725
890
 
726
891
  ```
727
- ly.img.ai.{kind}.canvasMenu
892
+ ly.img.plugin-ai-{kind}-generation-web.canvasMenu
728
893
  ```
729
894
 
730
895
  For example:
731
- - Image quick actions: `ly.img.ai.image.canvasMenu`
732
- - Video quick actions: `ly.img.ai.video.canvasMenu`
733
- - Audio quick actions: `ly.img.ai.audio.canvasMenu`
734
- - Text quick actions: `ly.img.ai.text.canvasMenu`
896
+ - Image quick actions: `ly.img.plugin-ai-image-generation-web.canvasMenu`
897
+ - Video quick actions: `ly.img.plugin-ai-video-generation-web.canvasMenu`
898
+ - Audio quick actions: `ly.img.plugin-ai-audio-generation-web.canvasMenu`
899
+ - Text quick actions: `ly.img.plugin-ai-text-generation-web.canvasMenu`
735
900
 
736
901
  ### Using with Existing AI Generation Plugins
737
902
 
@@ -777,8 +942,8 @@ CreativeEditorSDK.create(domElement, {
777
942
 
778
943
  // Add quick action menus to canvas
779
944
  cesdk.ui.setCanvasMenuOrder([
780
- 'ly.img.ai.image.canvasMenu',
781
- 'ly.img.ai.video.canvasMenu',
945
+ 'ly.img.plugin-ai-image-generation-web.canvasMenu',
946
+ 'ly.img.plugin-ai-video-generation-web.canvasMenu',
782
947
  ...cesdk.ui.getCanvasMenuOrder()
783
948
  ]);
784
949
  });
@@ -904,9 +1069,44 @@ export { initializeProvider, initializeProviders } from './providers/';
904
1069
  export { loggingMiddleware, rateLimitMiddleware, uploadMiddleware } from './middleware/';
905
1070
 
906
1071
  // Utilities
907
- export { getPanelId, enableQuickActionForImageFill } from './utils/';
1072
+ export { getPanelId, enableQuickActionForImageFill, mergeQuickActionsConfig } from './utils/';
908
1073
  ```
909
1074
 
1075
+ ### Initialization Functions
1076
+
1077
+ #### initializeProviders
1078
+
1079
+ The `initializeProviders` function is used to initialize multiple providers at once. It creates a composite history asset source and library entry for all providers of the same kind.
1080
+
1081
+ ```typescript
1082
+ const result = await initializeProviders(
1083
+ providers,
1084
+ { engine, cesdk },
1085
+ config
1086
+ );
1087
+
1088
+ // Return value structure:
1089
+ {
1090
+ panel: {
1091
+ builderRenderFunction: Function // UI builder function for provider selection
1092
+ },
1093
+ history: {
1094
+ assetSourceId: string, // ID of the composite history asset source
1095
+ assetLibraryEntryId: string // ID of the automatically created asset library entry
1096
+ },
1097
+ providerInitializationResults: Array<{
1098
+ provider: Provider,
1099
+ result: ProviderInitializationResult
1100
+ }>
1101
+ }
1102
+ ```
1103
+
1104
+ **Key Points:**
1105
+ - Creates a composite history asset source with ID format: `ly.img.plugin-ai-{kind}-generation-web.history`
1106
+ - Automatically creates an asset library entry with the same ID as the asset source
1107
+ - The library entry is configured with appropriate settings (sortBy: insertedAt descending, canRemove: true, etc.)
1108
+ - Returns both the asset source ID and library entry ID for reference
1109
+
910
1110
  ### Common Types
911
1111
 
912
1112
  ```typescript
@@ -916,6 +1116,10 @@ interface CommonProviderConfiguration<I, O extends Output> {
916
1116
  debug?: boolean;
917
1117
  middleware?: Middleware<I, O>[];
918
1118
  headers?: Record<string, string>;
1119
+ history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
1120
+ supportedQuickActions?: {
1121
+ [quickActionId: string]: Partial<QuickActionSupport<I>> | false | null;
1122
+ };
919
1123
  }
920
1124
 
921
1125
  // Quick action definition
@@ -928,3 +1132,7 @@ interface QuickActionDefinition<Q extends Record<string, any>> {
928
1132
  render: (context: QuickActionRenderContext<Q>) => void;
929
1133
  }
930
1134
  ```
1135
+
1136
+ ## Translations
1137
+
1138
+ For customization and localization, see the [translations.json](https://github.com/imgly/plugins/tree/main/packages/plugin-ai-generation-web/translations.json) file which contains base translation keys that can be overridden for all AI plugins.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export { ProviderRegistry } from './core/ProviderRegistry';
14
14
  export { composeMiddlewares, type Middleware } from './middleware/middleware';
15
15
  export { default as loggingMiddleware } from './middleware/loggingMiddleware';
16
16
  export { default as uploadMiddleware } from './middleware/uploadMiddleware';
17
+ export { mergeQuickActionsConfig } from './utils/mergeQuickActionsConfig';
17
18
  export { default as rateLimitMiddleware, type RateLimitOptions } from './middleware/rateLimitMiddleware';
18
19
  export { getPanelId, getDurationForVideo, getThumbnailForVideo, getLabelFromId, isAsyncGenerator, addIconSetOnce } from './utils/utils';
19
20
  export { checkAiPluginVersion } from './utils/checkAiPluginVersion';
@@ -23,4 +24,5 @@ export { isGeneratingStateKey, abortGenerationStateKey } from './ui/components/r
23
24
  export { default as initializeProviders } from './providers/initializeProviders';
24
25
  export { default as initializeProvider } from './providers/initializeProvider';
25
26
  export { default as initializeQuickActionComponents } from './ui/quickActions/initializeQuickActionComponents';
27
+ export { extractAndSetSchemaTranslations } from './openapi/extractSchemaTranslations';
26
28
  export { AI_EDIT_MODE, AI_METADATA_KEY } from './ui/quickActions/utils';