@imgly/plugin-ai-generation-web 0.1.9 → 0.2.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +270 -426
  3. package/dist/__tests__/ActionRegistry.test.d.ts +1 -0
  4. package/dist/__tests__/compactSeparators.test.d.ts +1 -0
  5. package/dist/__tests__/createConfirmationRenderFunction.test.d.ts +1 -0
  6. package/dist/{generation → assets}/getAssetResultForGenerated.d.ts +1 -1
  7. package/dist/{generation → assets}/getAssetResultForPlaceholder.d.ts +1 -1
  8. package/dist/assets/initializeHistoryAssetLibraryEntry.d.ts +7 -0
  9. package/dist/assets/initializeHistoryAssetSource.d.ts +7 -0
  10. package/dist/assets/initializeHistoryCompositeAssetSource.d.ts +11 -0
  11. package/dist/assets/integrateIntoDefaultAssetLibraryEntry.d.ts +8 -0
  12. package/dist/core/ActionRegistry.d.ts +201 -0
  13. package/dist/core/ProviderRegistry.d.ts +40 -0
  14. package/dist/core/constants.d.ts +1 -0
  15. package/dist/{generation → core}/provider.d.ts +38 -58
  16. package/dist/generation/CallbacksRegistry.d.ts +34 -0
  17. package/dist/generation/createGenerateFunction.d.ts +30 -0
  18. package/dist/generation/handleGenerateFromPanel.d.ts +50 -0
  19. package/dist/generation/handleGenerateFromQuickAction.d.ts +56 -0
  20. package/dist/generation/handleGenerationError.d.ts +2 -3
  21. package/dist/index.d.ts +21 -25
  22. package/dist/index.mjs +9 -6
  23. package/dist/index.mjs.map +4 -4
  24. package/dist/{generation/middleware → middleware}/alwaysOnTopMiddleware.d.ts +1 -1
  25. package/dist/{generation/middleware → middleware}/dryRunMiddleware.d.ts +2 -1
  26. package/dist/{generation/middleware → middleware}/editModeMiddleware.d.ts +1 -1
  27. package/dist/{generation/middleware → middleware}/highlightBlocksMiddleware.d.ts +1 -1
  28. package/dist/middleware/lockEditModeMiddleware.d.ts +17 -0
  29. package/dist/{generation/middleware → middleware}/lockMiddleware.d.ts +1 -1
  30. package/dist/middleware/loggingMiddleware.d.ts +6 -0
  31. package/dist/{generation/middleware → middleware}/middleware.d.ts +1 -1
  32. package/dist/{generation/middleware → middleware}/pendingMiddleware.d.ts +3 -3
  33. package/dist/{generation/middleware → middleware}/rateLimitMiddleware.d.ts +1 -1
  34. package/dist/{generation/middleware → middleware}/uploadMiddleware.d.ts +1 -1
  35. package/dist/{generation/openapi → openapi}/getProperties.d.ts +1 -1
  36. package/dist/{generation/openapi → openapi}/renderProperty.d.ts +3 -3
  37. package/dist/{generation/quickAction/consumeGeneratedResult.d.ts → providers/getApplyCallbacks.d.ts} +13 -8
  38. package/dist/providers/getCanvasMenuComponentId.d.ts +3 -0
  39. package/dist/providers/initializeProvider.d.ts +22 -0
  40. package/dist/providers/initializeProviders.d.ts +38 -0
  41. package/dist/types.d.ts +101 -0
  42. package/dist/{common → ui/common}/renderImageUrlProperty.d.ts +1 -1
  43. package/dist/{common → ui/common}/renderStyleTransferProperty.d.ts +1 -1
  44. package/dist/{generation → ui/components}/renderGenerationComponents.d.ts +6 -5
  45. package/dist/ui/panels/createConfirmationRenderFunction.d.ts +16 -0
  46. package/dist/ui/panels/createPanelRenderFunction.d.ts +9 -0
  47. package/dist/ui/panels/createPanelRenderFunctionFromCustom.d.ts +6 -0
  48. package/dist/ui/panels/createPanelRenderFunctionFromSchema.d.ts +9 -0
  49. package/dist/ui/quickActions/createQuickActionMenuRenderFunction.d.ts +13 -0
  50. package/dist/ui/quickActions/getQuickActionOrder.d.ts +12 -0
  51. package/dist/ui/quickActions/initializeQuickActionComponents.d.ts +15 -0
  52. package/dist/ui/quickActions/types.d.ts +10 -0
  53. package/dist/ui/quickActions/utils.d.ts +7 -0
  54. package/dist/utils/checkAiPluginVersion.d.ts +10 -0
  55. package/dist/utils/compactSeparators.d.ts +7 -0
  56. package/dist/utils/lockSelectionToEditMode.d.ts +12 -0
  57. package/dist/{utils.d.ts → utils/utils.d.ts} +6 -1
  58. package/package.json +2 -2
  59. package/dist/generation/generate.d.ts +0 -16
  60. package/dist/generation/initProvider.d.ts +0 -20
  61. package/dist/generation/middleware/loggingMiddleware.d.ts +0 -4
  62. package/dist/generation/quickAction/common/QuickActionBaseButton.d.ts +0 -11
  63. package/dist/generation/quickAction/common/QuickActionBaseLibrary.d.ts +0 -23
  64. package/dist/generation/quickAction/common/QuickActionBasePrompt.d.ts +0 -13
  65. package/dist/generation/quickAction/common/QuickActionBaseSelect.d.ts +0 -28
  66. package/dist/generation/quickAction/common/QuickActionChangeImage.d.ts +0 -17
  67. package/dist/generation/quickAction/common/QuickActionCombineImages.d.ts +0 -17
  68. package/dist/generation/quickAction/common/QuickActionEditTextStyle.d.ts +0 -17
  69. package/dist/generation/quickAction/common/QuickActionImageVariant.d.ts +0 -17
  70. package/dist/generation/quickAction/common/QuickActionSwapImageBackground.d.ts +0 -17
  71. package/dist/generation/quickAction/generate.d.ts +0 -19
  72. package/dist/generation/quickAction/getQuickActionMenu.d.ts +0 -10
  73. package/dist/generation/quickAction/registerQuickActionMenuComponent.d.ts +0 -12
  74. package/dist/generation/quickAction/types.d.ts +0 -25
  75. package/dist/generation/quickAction/utils.d.ts +0 -13
  76. package/dist/generation/registerPanelInputCustom.d.ts +0 -6
  77. package/dist/generation/registerPanelInputSchema.d.ts +0 -9
  78. package/dist/generation/types.d.ts +0 -79
  79. /package/dist/{generation → assets}/previewUri.d.ts +0 -0
  80. /package/dist/{generation/openapi → openapi}/dereferenceDocument.d.ts +0 -0
  81. /package/dist/{generation/openapi → openapi}/isOpenAPISchema.d.ts +0 -0
  82. /package/dist/{generation/openapi → openapi}/types.d.ts +0 -0
  83. /package/dist/{registerDockComponent.d.ts → ui/components/registerDockComponent.d.ts} +0 -0
  84. /package/dist/{icons.d.ts → ui/icons.d.ts} +0 -0
  85. /package/dist/{generation/quickAction/common → ui/quickActions}/enableImageFill.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { Middleware } from './middleware';
2
- import { Output } from '../provider';
2
+ import { Output } from '../core/provider';
3
3
  /**
4
4
  * Sets the blocks to a pending state while the middleware is running.
5
5
  */
@@ -1,6 +1,7 @@
1
- import { type Output, type OutputKind, type GetBlockInputResult } from '../provider';
1
+ import { type Output, type OutputKind, type GetBlockInputResult } from '../core/provider';
2
2
  import { Middleware } from './middleware';
3
3
  interface DryRunOptions<K extends OutputKind> {
4
+ enable?: boolean;
4
5
  kind: K;
5
6
  blockInputs?: GetBlockInputResult<K>;
6
7
  blockIds?: number[];
@@ -1,5 +1,5 @@
1
1
  import { Middleware } from './middleware';
2
- import { Output } from '../provider';
2
+ import { Output } from '../core/provider';
3
3
  /**
4
4
  * For a given edit mode and block ids, this middleware will
5
5
  * ensure that as long as these blocks are selected, the edit mode is
@@ -1,5 +1,5 @@
1
1
  import { Middleware } from './middleware';
2
- import { Output } from '../provider';
2
+ import { Output } from '../core/provider';
3
3
  /**
4
4
  * Highlights the blocks while the middleware is running.
5
5
  *
@@ -0,0 +1,17 @@
1
+ import { Middleware } from './middleware';
2
+ import { Output } from '../core/provider';
3
+ /**
4
+ * For a given edit mode and block ids, this middleware will
5
+ * ensure that as long as these blocks are selected, the edit mode is
6
+ * set to the given edit mode and cannot be changed.
7
+ *
8
+ * The use-case is to show only the generation canvas menu during
9
+ * the generation process.
10
+ */
11
+ declare function lockEditModeMiddleware<I, O extends Output>({ editMode }: {
12
+ /**
13
+ * The edit mode to lock the selection to.
14
+ */
15
+ editMode: string;
16
+ }): Middleware<I, O>;
17
+ export default lockEditModeMiddleware;
@@ -1,5 +1,5 @@
1
1
  import { Middleware } from './middleware';
2
- import { Output } from '../provider';
2
+ import { Output } from '../core/provider';
3
3
  /**
4
4
  * Highlights the blocks while the middleware is running.
5
5
  */
@@ -0,0 +1,6 @@
1
+ import { Output } from '../core/provider';
2
+ import { Middleware } from './middleware';
3
+ declare function loggingMiddleware<I, O extends Output>({ enable }: {
4
+ enable: boolean | undefined;
5
+ }): Middleware<I, O>;
6
+ export default loggingMiddleware;
@@ -1,4 +1,4 @@
1
- import { GenerationOptions, GenerationResult, Output } from '../provider';
1
+ import { GenerationOptions, GenerationResult, Output } from '../core/provider';
2
2
  /**
3
3
  * Result of the generation with a dispose function to clean up
4
4
  */
@@ -1,14 +1,14 @@
1
1
  import { Middleware } from './middleware';
2
- import { Output } from '../provider';
2
+ import { Output } from '../core/provider';
3
3
  /**
4
4
  * Sets the blocks to a pending state while the middleware is running.
5
5
  */
6
- declare function pendingMiddleware<I, O extends Output>({ pending }: {
6
+ declare function pendingMiddleware<I, O extends Output>({ enable }: {
7
7
  /**
8
8
  * Should the blocks be set to a pending state?
9
9
  *
10
10
  * @default true
11
11
  */
12
- pending?: boolean;
12
+ enable?: boolean;
13
13
  }): Middleware<I, O>;
14
14
  export default pendingMiddleware;
@@ -1,4 +1,4 @@
1
- import { GenerationOptions, Output } from '../provider';
1
+ import { GenerationOptions, Output } from '../core/provider';
2
2
  import { Middleware } from './middleware';
3
3
  export interface RateLimitOptions<I> {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Output } from '../provider';
1
+ import { Output } from '../core/provider';
2
2
  import { Middleware } from './middleware';
3
3
  /**
4
4
  * Middleware to upload the output of a generation process.
@@ -1,5 +1,5 @@
1
1
  import { OpenAPIV3 } from 'openapi-types';
2
- import { OutputKind, PanelInputSchema } from '../provider';
2
+ import { OutputKind, PanelInputSchema } from '../core/provider';
3
3
  import { Property } from './types';
4
4
  declare function getProperties<K extends OutputKind, I>(inputSchema: OpenAPIV3.SchemaObject, panelInput: PanelInputSchema<K, I>): Property[];
5
5
  export default getProperties;
@@ -1,6 +1,6 @@
1
1
  import { BuilderRenderFunctionContext } from '@cesdk/cesdk-js';
2
2
  import { GetPropertyInput, Property } from './types';
3
- import Provider, { Output, OutputKind, PanelInputSchema } from '../provider';
4
- import { InitProviderConfiguration, UIOptions } from '../types';
5
- declare function renderProperty<K extends OutputKind, I, O extends Output>(context: BuilderRenderFunctionContext<any>, property: Property, provider: Provider<K, I, O>, panelInput: PanelInputSchema<K, I>, options: UIOptions, config: InitProviderConfiguration): GetPropertyInput | undefined;
3
+ import Provider, { Output, OutputKind, PanelInputSchema } from '../core/provider';
4
+ import { UIOptions, CommonConfiguration } from '../types';
5
+ declare function renderProperty<K extends OutputKind, I, O extends Output>(context: BuilderRenderFunctionContext<any>, property: Property, provider: Provider<K, I, O>, panelInput: PanelInputSchema<K, I>, options: UIOptions, config: CommonConfiguration<I, O>): GetPropertyInput | undefined;
6
6
  export default renderProperty;
@@ -1,14 +1,19 @@
1
1
  import type CreativeEditorSDK from '@cesdk/cesdk-js';
2
- import { GenerationResult, type Output, type OutputKind } from '../provider';
3
- import { ApplyCallbacks } from './types';
4
- type ConsumeGeneratedResultOptions = {
2
+ import { type Output, type OutputKind } from '../core/provider';
3
+ import { ResultSuccess } from '../generation/createGenerateFunction';
4
+ export type ApplyCallbacks = {
5
+ onBefore: () => void;
6
+ onAfter: () => void;
7
+ onCancel: () => void;
8
+ onApply: () => void;
9
+ };
10
+ type GetApplyCallbacksOptions = {
5
11
  kind: OutputKind;
6
12
  blockIds: number[];
7
13
  cesdk: CreativeEditorSDK;
8
- abortSignal: AbortSignal;
14
+ abortSignal?: AbortSignal;
9
15
  };
10
- type ReturnValue<O extends Output> = {
11
- consumedGenerationResult: O;
16
+ type ReturnValue = {
12
17
  applyCallbacks: ApplyCallbacks;
13
18
  };
14
19
  /**
@@ -19,5 +24,5 @@ type ReturnValue<O extends Output> = {
19
24
  * is streamed to the text block, while the image generation is applied to the fill
20
25
  * block with a source set and the same crop applied.
21
26
  */
22
- declare function consumeGeneratedResult<O extends Output>(result: GenerationResult<O>, options: ConsumeGeneratedResultOptions): Promise<ReturnValue<O>>;
23
- export default consumeGeneratedResult;
27
+ declare function getApplyCallbacks<O extends Output>(result: ResultSuccess<O>, options: GetApplyCallbacksOptions): Promise<ReturnValue>;
28
+ export default getApplyCallbacks;
@@ -0,0 +1,3 @@
1
+ import { OutputKind } from '../core/provider';
2
+ declare function getQuickActionCanvasMenuComponentId<K extends OutputKind>(kind: K): string;
3
+ export default getQuickActionCanvasMenuComponentId;
@@ -0,0 +1,22 @@
1
+ import CreativeEditorSDK, { BuilderRenderFunction } from '@cesdk/cesdk-js';
2
+ import Provider, { Output, OutputKind } from '../core/provider';
3
+ import { CommonPluginConfiguration } from '../types';
4
+ import { type Generate } from '../generation/createGenerateFunction';
5
+ export type ProviderInitializationResult<K extends OutputKind, I, O extends Output> = {
6
+ provider: Provider<K, I, O>;
7
+ panel: {
8
+ builderRenderFunction?: BuilderRenderFunction;
9
+ };
10
+ history: {
11
+ assetSourceId?: string;
12
+ assetLibraryEntryId?: string;
13
+ };
14
+ generate: Generate<I, O>;
15
+ };
16
+ /**
17
+ * Initializes a provider with the given configuration and options.
18
+ */
19
+ declare function initializeProvider<K extends OutputKind, I, O extends Output>(_kind: K, provider: Provider<K, I, O>, options: {
20
+ cesdk: CreativeEditorSDK;
21
+ }, config: CommonPluginConfiguration<K, I, O>): Promise<ProviderInitializationResult<K, I, O>>;
22
+ export default initializeProvider;
@@ -0,0 +1,38 @@
1
+ import CreativeEditorSDK, { BuilderRenderFunction } from '@cesdk/cesdk-js';
2
+ import Provider, { Output, OutputKind } from '../core/provider';
3
+ import { ProviderInitializationResult } from './initializeProvider';
4
+ import { CommonPluginConfiguration } from '../types';
5
+ export type ProvidersInitializationResult<K extends OutputKind, I, O extends Output> = {
6
+ /**
7
+ * Combined panel render function for all providers.
8
+ */
9
+ panel: {
10
+ builderRenderFunction?: BuilderRenderFunction;
11
+ };
12
+ /**
13
+ * Combined history asset source and library entry IDs for the providers.
14
+ */
15
+ history?: {
16
+ assetSourceId?: string;
17
+ assetLibraryEntryId?: string;
18
+ };
19
+ /**
20
+ * All individual initialization results of the providers, i.e.
21
+ * the result of `initializeProvider` for every provider.
22
+ */
23
+ providerInitializationResults: ProviderInitializationResult<K, I, O>[];
24
+ };
25
+ /**
26
+ * Initializes the given providers for the specified output kind.
27
+ *
28
+ * - It will create a combined render function for all providers
29
+ * that can be used in a panel
30
+ *
31
+ */
32
+ declare function initializeProviders<K extends OutputKind, I, O extends Output>(kind: K, providers: {
33
+ fromText: Provider<K, I, O>[];
34
+ fromImage: Provider<K, I, O>[];
35
+ } | Provider<K, I, O>[], options: {
36
+ cesdk: CreativeEditorSDK;
37
+ }, config: CommonPluginConfiguration<K, I, O>): Promise<ProvidersInitializationResult<K, I, O>>;
38
+ export default initializeProviders;
@@ -0,0 +1,101 @@
1
+ import type CreativeEditorSDK from '@cesdk/cesdk-js';
2
+ import { type CreativeEngine } from '@cesdk/cesdk-js';
3
+ import type Provider from './core/provider';
4
+ import { Output, OutputKind, PanelInput } from './core/provider';
5
+ import { Middleware } from './middleware/middleware';
6
+ /**
7
+ * A common configuration used by the plugins and the provider.
8
+ */
9
+ export interface CommonConfiguration<I, O extends Output> {
10
+ /**
11
+ * Render console logs for debugging purposes.
12
+ */
13
+ debug?: boolean;
14
+ /**
15
+ * Dry run mode. If set to true, the plugin will not make any API calls.
16
+ */
17
+ dryRun?: boolean;
18
+ /**
19
+ * Middlewares to add to the provider generation
20
+ */
21
+ middlewares?: Middleware<I, O>[];
22
+ }
23
+ /**
24
+ * Configuration to set provider and models for image generation.
25
+ */
26
+ export interface CommonPluginConfiguration<K extends OutputKind, I, O extends Output> extends CommonConfiguration<I, O> {
27
+ /**
28
+ * Base URL used for the UI assets used in the plugin.
29
+ *
30
+ * By default, we load the assets from the IMG.LY CDN. You can copy the assets.
31
+ * from the `/assets` folder to your own server and set the base URL to your server.
32
+ */
33
+ baseURL?: string;
34
+ }
35
+ /**
36
+ * Returns a provider for a given cesdk instance.
37
+ */
38
+ export type GetProvider<K extends OutputKind> = ({ cesdk }: {
39
+ cesdk: CreativeEditorSDK;
40
+ }) => Promise<Provider<K, any, any>>;
41
+ /**
42
+ * Common provider configuration that all providers should provide.
43
+ */
44
+ export interface CommonProviderConfiguration<I, O extends Output> extends CommonConfiguration<I, O> {
45
+ /**
46
+ * The proxy URL to use for the provider.
47
+ */
48
+ proxyUrl: string;
49
+ /**
50
+ * Headers that shall be sent with the request of the provider.
51
+ */
52
+ headers?: Record<string, string>;
53
+ /**
54
+ * Middlewares to add to the provider generation
55
+ * @deprecated Use `middlewares` instead.
56
+ */
57
+ middleware?: Middleware<I, O>[];
58
+ }
59
+ /**
60
+ * Internal configuration interface for provider initialization.
61
+ * This extends the public CommonPluginConfiguration with required provider field.
62
+ */
63
+ export interface InternalPluginConfiguration<K extends OutputKind, I, O extends Output> extends CommonConfiguration<I, O> {
64
+ /**
65
+ * The provider to use for generation.
66
+ */
67
+ provider: Provider<K, I, O>;
68
+ /**
69
+ * The panel input schema to use for the provider.
70
+ */
71
+ panelInput?: PanelInput<K, I>;
72
+ }
73
+ /**
74
+ * Context for provider initialization, including the provider, panel input schema,
75
+ * options, and configuration.
76
+ */
77
+ export type InitializationContext<K extends OutputKind, I, O extends Output, P extends PanelInput<K, I> = PanelInput<K, I>> = {
78
+ provider: Provider<K, I, O>;
79
+ panelInput?: P;
80
+ options: UIOptions;
81
+ config: InternalPluginConfiguration<K, I, O>;
82
+ };
83
+ /**
84
+ * Options for UI interactions
85
+ */
86
+ export type UIOptions = {
87
+ cesdk: CreativeEditorSDK;
88
+ engine: CreativeEngine;
89
+ historyAssetSourceId?: string;
90
+ historyAssetLibraryEntryId?: string;
91
+ i18n?: {
92
+ prompt?: string;
93
+ };
94
+ };
95
+ /**
96
+ * Basic context for provider initialization
97
+ */
98
+ export type Options = {
99
+ cesdk?: CreativeEditorSDK;
100
+ engine: CreativeEngine;
101
+ };
@@ -1,5 +1,5 @@
1
1
  import CreativeEditorSDK from '@cesdk/cesdk-js';
2
- import { RenderCustomProperty } from '../generation/provider';
2
+ import { RenderCustomProperty } from '../../core/provider';
3
3
  /**
4
4
  * Provides render function for a image url property that allows
5
5
  * to select an image from the library with a MediaPreview
@@ -1,5 +1,5 @@
1
1
  import CreativeEditorSDK from '@cesdk/cesdk-js';
2
- import { RenderCustomProperty } from '../generation/provider';
2
+ import { RenderCustomProperty } from '../../core/provider';
3
3
  type Style = {
4
4
  id: 'none' | (string & {});
5
5
  label: string;
@@ -1,15 +1,16 @@
1
1
  import { type BuilderRenderFunctionContext } from '@cesdk/cesdk-js';
2
- import type Provider from './provider';
3
- import { type GetInput, type OutputKind, type Output, type GetBlockInput } from './provider';
4
- import { InitProviderConfiguration, UIOptions } from './types';
2
+ import type Provider from '../../core/provider';
3
+ import { type GetInput, type OutputKind, type Output, type GetBlockInput } from '../../core/provider';
4
+ import { UIOptions, CommonConfiguration } from '../../types';
5
+ import { Generate } from '../../generation/createGenerateFunction';
5
6
  export declare function isGeneratingStateKey(providerId: string): string;
6
7
  export declare function abortGenerationStateKey(providerId: string): string;
7
8
  /**
8
9
  * Renders the generation UI components and sets up event handlers
9
10
  */
10
- declare function renderGenerationComponents<K extends OutputKind, I, O extends Output>(context: BuilderRenderFunctionContext<any>, provider: Provider<K, I, O>, getInput: GetInput<I>, getBlockInput: GetBlockInput<K, I>, options: UIOptions & {
11
+ declare function renderGenerationComponents<K extends OutputKind, I, O extends Output>(context: BuilderRenderFunctionContext<any>, provider: Provider<K, I, O>, generate: Generate<I, O>, getInput: GetInput<I>, getBlockInput: GetBlockInput<K, I>, options: UIOptions & {
11
12
  createPlaceholderBlock?: boolean;
12
13
  includeHistoryLibrary?: boolean;
13
14
  requiredInputs?: string[];
14
- }, config: InitProviderConfiguration): void;
15
+ }, config: CommonConfiguration<I, O>): void;
15
16
  export default renderGenerationComponents;
@@ -0,0 +1,16 @@
1
+ import CreativeEditorSDK, { BuilderRenderFunction } from '@cesdk/cesdk-js';
2
+ import { OutputKind } from '../../core/provider';
3
+ import { Callbacks } from '../../generation/CallbacksRegistry';
4
+ /**
5
+ * Creates a render function for the AI inference confirmation component.
6
+ *
7
+ * It will render 'cancel', 'before', 'after', and 'apply' buttons once the
8
+ * inference is done. Until then a loading spinner is shown with a cancel button.
9
+ *
10
+ * The callbacks are provided by the payload from the context.
11
+ */
12
+ declare function createConfirmationRenderFunction<K extends OutputKind>(context: {
13
+ kind: K;
14
+ cesdk: CreativeEditorSDK;
15
+ }): Promise<BuilderRenderFunction<Callbacks>>;
16
+ export default createConfirmationRenderFunction;
@@ -0,0 +1,9 @@
1
+ import { BuilderRenderFunction } from '@cesdk/cesdk-js';
2
+ import { Output, OutputKind } from '../../core/provider';
3
+ import { InitializationContext } from '../../types';
4
+ import { Generate } from '../../generation/createGenerateFunction';
5
+ /**
6
+ * Creates a panel render function based on the provided context, i.e. on the provider.
7
+ */
8
+ declare function createPanelRenderFunction<K extends OutputKind, I, O extends Output>(context: InitializationContext<K, I, O>, generate: Generate<I, O>): Promise<BuilderRenderFunction<any> | undefined>;
9
+ export default createPanelRenderFunction;
@@ -0,0 +1,6 @@
1
+ import { BuilderRenderFunction } from '@cesdk/cesdk-js';
2
+ import { OutputKind, PanelInputCustom, type Output } from '../../core/provider';
3
+ import { InitializationContext } from '../../types';
4
+ import { Generate } from '../../generation/createGenerateFunction';
5
+ declare function createPanelRenderFunctionFromCustom<K extends OutputKind, I, O extends Output>({ options, provider, panelInput, config }: InitializationContext<K, I, O, PanelInputCustom<K, I>>, generate: Generate<I, O>): Promise<BuilderRenderFunction<any> | undefined>;
6
+ export default createPanelRenderFunctionFromCustom;
@@ -0,0 +1,9 @@
1
+ import { BuilderRenderFunction } from '@cesdk/cesdk-js';
2
+ import { OutputKind, PanelInputSchema, type Output } from '../../core/provider';
3
+ import { InitializationContext } from '../../types';
4
+ import { Generate } from '../../generation/createGenerateFunction';
5
+ /**
6
+ * Creates a panel render function based on the schema definition in the provider.
7
+ */
8
+ declare function createPanelRenderFunctionFromSchema<K extends OutputKind, I, O extends Output>({ options, provider, panelInput, config }: InitializationContext<K, I, O, PanelInputSchema<K, I>>, generate: Generate<I, O>): Promise<BuilderRenderFunction<any> | undefined>;
9
+ export default createPanelRenderFunctionFromSchema;
@@ -0,0 +1,13 @@
1
+ import CreativeEditorSDK, { BuilderRenderFunction, CreativeEngine } from '@cesdk/cesdk-js';
2
+ import { Output, OutputKind } from '../../core/provider';
3
+ import { ProviderInitializationResult } from '../../providers/initializeProvider';
4
+ declare function createQuickActionMenuRenderFunction<K extends OutputKind, I, O extends Output>(context: {
5
+ kind: K;
6
+ providerInitializationResults: ProviderInitializationResult<K, I, O>[];
7
+ cesdk: CreativeEditorSDK;
8
+ engine: CreativeEngine;
9
+ debug?: boolean;
10
+ dryRun?: boolean;
11
+ defaultOrder?: string[];
12
+ }): Promise<BuilderRenderFunction<any>>;
13
+ export default createQuickActionMenuRenderFunction;
@@ -0,0 +1,12 @@
1
+ import CreativeEditorSDK, { ComponentPayload } from '@cesdk/cesdk-js';
2
+ import { OutputKind } from '../../core/provider';
3
+ /**
4
+ * Returns the current order of quick actions for a particular kind.
5
+ */
6
+ declare function getQuickActionOrder<K extends OutputKind>(context: {
7
+ kind: K;
8
+ cesdk: CreativeEditorSDK;
9
+ payload?: ComponentPayload;
10
+ defaultOrder?: string[];
11
+ }): string[];
12
+ export default getQuickActionOrder;
@@ -0,0 +1,15 @@
1
+ import CreativeEditorSDK, { BuilderRenderFunction, CreativeEngine } from '@cesdk/cesdk-js';
2
+ import { Output, OutputKind } from '../../core/provider';
3
+ import { ProviderInitializationResult } from '../../providers/initializeProvider';
4
+ declare function initializeQuickActionComponents<K extends OutputKind, I, O extends Output>(context: {
5
+ kind: K;
6
+ providerInitializationResults: ProviderInitializationResult<K, I, O>[];
7
+ cesdk: CreativeEditorSDK;
8
+ engine: CreativeEngine;
9
+ debug?: boolean;
10
+ dryRun?: boolean;
11
+ defaultOrder?: string[];
12
+ }): Promise<{
13
+ renderFunction: BuilderRenderFunction<any>;
14
+ }>;
15
+ export default initializeQuickActionComponents;
@@ -0,0 +1,10 @@
1
+ export type InferenceStatus = 'processing' | 'confirmation';
2
+ export type InferenceProcessingMetadata = {
3
+ status: 'processing';
4
+ quickActionId: string;
5
+ };
6
+ export type InferenceConfirmationMetadata = {
7
+ status: 'confirmation';
8
+ quickActionId: string;
9
+ };
10
+ export type InferenceMetadata = InferenceProcessingMetadata | InferenceConfirmationMetadata;
@@ -0,0 +1,7 @@
1
+ export declare const AI_EDIT_MODE = "ly.img.ai.editMode";
2
+ export declare const AI_METADATA_KEY = "ly.img.ai.metadata";
3
+ export declare const AI_CONFIRMATION_COMPONENT_ID = "ly.img.ai.confirmation.canvasMenu";
4
+ export declare function getFeatureIdForQuickAction(options: {
5
+ quickActionId: string;
6
+ quickActionMenuId: string;
7
+ }): string;
@@ -0,0 +1,10 @@
1
+ import type CreativeEditorSDK from '@cesdk/cesdk-js';
2
+ /**
3
+ * Checks if the current AI plugin version matches the shared version across all AI plugins.
4
+ * Issues a console warning if versions don't match.
5
+ *
6
+ * @param cesdk - The CreativeEditorSDK instance
7
+ * @param pluginId - The ID of the current plugin
8
+ * @param currentVersion - The version of the current plugin
9
+ */
10
+ export declare function checkAiPluginVersion(cesdk: CreativeEditorSDK, pluginId: string, currentVersion: string): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * For the given array that contains strings `ly.img.separator` and other items,
3
+ * this function will remove all leading and trailing separators,
4
+ * as well as any consecutive separators in between.
5
+ */
6
+ declare function compactSeparators<T>(quickActions: (T | 'ly.img.separator')[]): (T | 'ly.img.separator')[];
7
+ export default compactSeparators;
@@ -0,0 +1,12 @@
1
+ import { CreativeEngine } from '@cesdk/cesdk-js';
2
+ /**
3
+ * Locks the selection to the given block ids with the given edit mode.
4
+ *
5
+ * @returns A function to unlock the selection. Will set the edit mode back to what it was before the lock.
6
+ */
7
+ declare function lockSelectionToEditMode(options: {
8
+ engine: CreativeEngine;
9
+ blockIdsToLock: number[];
10
+ editModeToLockTo: string;
11
+ }): () => void;
12
+ export default lockSelectionToEditMode;
@@ -1,5 +1,5 @@
1
1
  import CreativeEditorSDK, { AssetResult } from '@cesdk/cesdk-js';
2
- import { GenerationResult, Output } from './generation/provider';
2
+ import { GenerationResult, Output } from '../core/provider';
3
3
  export declare const AI_PANEL_ID_PREFIX = "ly.img.ai";
4
4
  /**
5
5
  * Adding asset to the scene.
@@ -64,3 +64,8 @@ export declare function getLabelFromId(id: string): string;
64
64
  */
65
65
  export declare function isAsyncGenerator<O extends Output, C>(value: GenerationResult<O, C>): value is AsyncGenerator<O, C>;
66
66
  export declare function isAbortError(error: unknown): error is Error;
67
+ /**
68
+ * Adds an icon set to the CreativeEditorSDK UI only once. Marks
69
+ * it as added in the global state to prevent multiple additions.
70
+ */
71
+ export declare function addIconSetOnce(cesdk: CreativeEditorSDK, id: string, icons: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imgly/plugin-ai-generation-web",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "AI generation plugin for the CE.SDK editor",
5
5
  "keywords": ["CE.SDK", "plugin", "AI", "ai generation"],
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "test:watch": "jest --watch",
39
39
  "test:coverage": "jest --coverage",
40
40
  "dev": "pnpm --filter \"${npm_package_name}^...\" --parallel run dev:wait && node scripts/watch.mjs",
41
- "dev:wait": "pnpm exec wait-on ./dist/index.mjs ./dist/index.d.ts --window 250 --timeout 30000",
41
+ "dev:wait": "pnpm exec wait-on ./dist/index.mjs ./dist/index.d.ts --window 250 --timeout 60000",
42
42
  "check:all": "concurrently -n lint,type,pretty \"pnpm run check:lint\" \"pnpm run check:types\" \"pnpm run check:pretty\"",
43
43
  "check:lint": "eslint --max-warnings 0 './src/**/*.{ts,tsx}'",
44
44
  "check:pretty": "prettier --list-different './src/**/*.{ts,tsx}'",
@@ -1,16 +0,0 @@
1
- import type Provider from './provider';
2
- import { type GetInput, type GetBlockInput, OutputKind, type Output } from './provider';
3
- import { InitProviderConfiguration, UIOptions } from './types';
4
- type Result<O> = {
5
- status: 'success';
6
- output: O;
7
- } | {
8
- status: 'aborted';
9
- };
10
- /**
11
- * Generate content using the provider with the given input
12
- */
13
- declare function generate<K extends OutputKind, I, O extends Output>(kind: K, getInput: GetInput<I>, getBlockInput: GetBlockInput<K, I>, provider: Provider<K, I, O>, options: UIOptions & {
14
- createPlaceholderBlock?: boolean;
15
- }, config: InitProviderConfiguration, abortSignal: AbortSignal): Promise<Result<O>>;
16
- export default generate;
@@ -1,20 +0,0 @@
1
- import type Provider from './provider';
2
- import { OutputKind, type Output } from './provider';
3
- import { InitProviderConfiguration, Options } from './types';
4
- import { BuilderRenderFunction } from '@cesdk/cesdk-js';
5
- type RenderBuilderFunctions = {
6
- panel?: BuilderRenderFunction<any>;
7
- };
8
- /**
9
- * Initialize the provider. Based on the given options and configuration
10
- * it will register panels and components that is used to render
11
- * the provider in the UI.
12
- *
13
- * @param provider The provider to initialize.
14
- * @param options The options to use for the provider.
15
- * @param config The configuration to use for the provider.
16
- */
17
- declare function initProvider<K extends OutputKind, I, O extends Output>(provider: Provider<K, I, O>, options: Options, config: InitProviderConfiguration): Promise<{
18
- renderBuilderFunctions?: RenderBuilderFunctions;
19
- }>;
20
- export default initProvider;
@@ -1,4 +0,0 @@
1
- import { Output } from '../provider';
2
- import { Middleware } from './middleware';
3
- declare function loggingMiddleware<I, O extends Output>(): Middleware<I, O>;
4
- export default loggingMiddleware;
@@ -1,11 +0,0 @@
1
- import { ButtonOptions } from '@cesdk/cesdk-js';
2
- import { Output, QuickAction, QuickActionContext } from '../../provider';
3
- /**
4
- * Quick action base for quick actions to open a panel.
5
- */
6
- declare function QuickActionBaseButton<I, O extends Output>(options: {
7
- buttonOptions?: ButtonOptions;
8
- quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;
9
- onClick: (context: QuickActionContext<I, O>) => Promise<void>;
10
- }): QuickAction<I, O>;
11
- export default QuickActionBaseButton;
@@ -1,23 +0,0 @@
1
- import CreativeEditorSDK, { AssetResult, ButtonOptions } from '@cesdk/cesdk-js';
2
- import { Output, QuickAction, QuickActionContext } from '../../provider';
3
- /**
4
- * Quick action base for quick actions that require a selection of items
5
- * from a library.
6
- */
7
- declare function QuickActionBaseLibrary<I, O extends Output>(options: {
8
- cesdk: CreativeEditorSDK;
9
- entries: string[];
10
- buttonOptions?: ButtonOptions;
11
- quickAction: Omit<QuickAction<I, O>, 'render' | 'renderExpanded'>;
12
- mapInput?: (input: {
13
- assetResult: AssetResult;
14
- uri: string;
15
- blockId: number;
16
- }) => I;
17
- onApply?: (options: {
18
- assetResult: AssetResult;
19
- uri: string;
20
- blockId: number;
21
- }, context: QuickActionContext<I, O>) => Promise<O>;
22
- }): QuickAction<I, O>;
23
- export default QuickActionBaseLibrary;