@imgly/plugin-ai-generation-web 1.86.0-nightly.20261102 → 1.87.0-nightly.20261104
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/dist/index.d.ts +1990 -35
- package/dist/index.mjs +18 -25
- package/dist/index.mjs.map +1 -7
- package/package.json +8 -8
- package/dist/.tsbuildinfo +0 -1
- package/dist/assets/getAssetResultForGenerated.d.ts +0 -4
- package/dist/assets/getAssetResultForPlaceholder.d.ts +0 -4
- package/dist/assets/initializeHistoryAssetLibraryEntry.d.ts +0 -7
- package/dist/assets/initializeHistoryAssetSource.d.ts +0 -7
- package/dist/assets/initializeHistoryCompositeAssetSource.d.ts +0 -11
- package/dist/assets/integrateIntoDefaultAssetLibraryEntry.d.ts +0 -8
- package/dist/assets/previewUri.d.ts +0 -2
- package/dist/core/ActionRegistry.d.ts +0 -202
- package/dist/core/ProviderRegistry.d.ts +0 -40
- package/dist/core/constants.d.ts +0 -1
- package/dist/core/propertyConfiguration.d.ts +0 -58
- package/dist/core/provider.d.ts +0 -459
- package/dist/gateway/GatewayError.d.ts +0 -98
- package/dist/gateway/createGatewayClient.d.ts +0 -22
- package/dist/gateway/createGatewayProvider.d.ts +0 -24
- package/dist/gateway/gatewayErrorNotification.d.ts +0 -29
- package/dist/gateway/index.d.ts +0 -4
- package/dist/gateway/types.d.ts +0 -236
- package/dist/generation/CallbacksRegistry.d.ts +0 -34
- package/dist/generation/createGenerateFunction.d.ts +0 -47
- package/dist/generation/handleGenerateFromPanel.d.ts +0 -50
- package/dist/generation/handleGenerateFromQuickAction.d.ts +0 -56
- package/dist/generation/handleGenerationError.d.ts +0 -9
- package/dist/middleware/alwaysOnTopMiddleware.d.ts +0 -14
- package/dist/middleware/dryRunMiddleware.d.ts +0 -10
- package/dist/middleware/editModeMiddleware.d.ts +0 -30
- package/dist/middleware/highlightBlocksMiddleware.d.ts +0 -24
- package/dist/middleware/lockEditModeMiddleware.d.ts +0 -17
- package/dist/middleware/lockMiddleware.d.ts +0 -19
- package/dist/middleware/loggingMiddleware.d.ts +0 -6
- package/dist/middleware/middleware.d.ts +0 -28
- package/dist/middleware/pendingMiddleware.d.ts +0 -14
- package/dist/middleware/rateLimitMiddleware.d.ts +0 -53
- package/dist/middleware/uploadMiddleware.d.ts +0 -13
- package/dist/openapi/defaultTranslations.d.ts +0 -12
- package/dist/openapi/dereferenceDocument.d.ts +0 -14
- package/dist/openapi/extractSchemaTranslations.d.ts +0 -11
- package/dist/openapi/getProperties.d.ts +0 -5
- package/dist/openapi/isOpenAPISchema.d.ts +0 -9
- package/dist/openapi/propertyTranslationKeys.d.ts +0 -14
- package/dist/openapi/renderProperty.d.ts +0 -6
- package/dist/openapi/types.d.ts +0 -54
- package/dist/providers/getApplyCallbacks.d.ts +0 -28
- package/dist/providers/getCanvasMenuComponentId.d.ts +0 -3
- package/dist/providers/initializeProvider.d.ts +0 -22
- package/dist/providers/initializeProviders.d.ts +0 -38
- package/dist/types.d.ts +0 -130
- package/dist/ui/common/renderImageUrlProperty.d.ts +0 -45
- package/dist/ui/common/renderStyleTransferProperty.d.ts +0 -47
- package/dist/ui/components/registerDockComponent.d.ts +0 -10
- package/dist/ui/components/renderGenerationComponents.d.ts +0 -16
- package/dist/ui/icons.d.ts +0 -3
- package/dist/ui/panels/createConfirmationRenderFunction.d.ts +0 -16
- package/dist/ui/panels/createPanelRenderFunction.d.ts +0 -9
- package/dist/ui/panels/createPanelRenderFunctionFromCustom.d.ts +0 -6
- package/dist/ui/panels/createPanelRenderFunctionFromSchema.d.ts +0 -9
- package/dist/ui/quickActions/createQuickActionMenuRenderFunction.d.ts +0 -13
- package/dist/ui/quickActions/enableImageFill.d.ts +0 -8
- package/dist/ui/quickActions/getQuickActionOrder.d.ts +0 -12
- package/dist/ui/quickActions/initializeQuickActionComponents.d.ts +0 -15
- package/dist/ui/quickActions/types.d.ts +0 -10
- package/dist/ui/quickActions/utils.d.ts +0 -7
- package/dist/utils/checkAiPluginVersion.d.ts +0 -10
- package/dist/utils/compactSeparators.d.ts +0 -7
- package/dist/utils/lockSelectionToEditMode.d.ts +0 -12
- package/dist/utils/mergeQuickActionsConfig.d.ts +0 -10
- package/dist/utils/propertyContext.d.ts +0 -21
- package/dist/utils/propertyResolver.d.ts +0 -16
- package/dist/utils/translationHelpers.d.ts +0 -42
- package/dist/utils/utils.d.ts +0 -83
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,1991 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import CreativeEditorSDK, { BuilderRenderFunction, BuilderRenderFunctionContext, CreativeEngine, NotificationDuration, SceneMode, Scope } from "@cesdk/cesdk-js";
|
|
2
|
+
import CreativeEngine$1 from "@cesdk/engine";
|
|
3
|
+
declare namespace OpenAPIV3 {
|
|
4
|
+
interface Document<T extends {} = {}> {
|
|
5
|
+
openapi: string;
|
|
6
|
+
info: InfoObject;
|
|
7
|
+
servers?: ServerObject[];
|
|
8
|
+
paths: PathsObject<T>;
|
|
9
|
+
components?: ComponentsObject;
|
|
10
|
+
security?: SecurityRequirementObject[];
|
|
11
|
+
tags?: TagObject[];
|
|
12
|
+
externalDocs?: ExternalDocumentationObject;
|
|
13
|
+
'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
|
|
14
|
+
'x-express-openapi-validation-strict'?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface InfoObject {
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
termsOfService?: string;
|
|
20
|
+
contact?: ContactObject;
|
|
21
|
+
license?: LicenseObject;
|
|
22
|
+
version: string;
|
|
23
|
+
}
|
|
24
|
+
interface ContactObject {
|
|
25
|
+
name?: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
}
|
|
29
|
+
interface LicenseObject {
|
|
30
|
+
name: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
}
|
|
33
|
+
interface ServerObject {
|
|
34
|
+
url: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
variables?: {
|
|
37
|
+
[variable: string]: ServerVariableObject;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface ServerVariableObject {
|
|
41
|
+
enum?: string[];
|
|
42
|
+
default: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
}
|
|
45
|
+
interface PathsObject<T extends {} = {}, P extends {} = {}> {
|
|
46
|
+
[pattern: string]: (PathItemObject<T> & P) | undefined;
|
|
47
|
+
}
|
|
48
|
+
enum HttpMethods {
|
|
49
|
+
GET = "get",
|
|
50
|
+
PUT = "put",
|
|
51
|
+
POST = "post",
|
|
52
|
+
DELETE = "delete",
|
|
53
|
+
OPTIONS = "options",
|
|
54
|
+
HEAD = "head",
|
|
55
|
+
PATCH = "patch",
|
|
56
|
+
TRACE = "trace"
|
|
57
|
+
}
|
|
58
|
+
type PathItemObject<T extends {} = {}> = {
|
|
59
|
+
$ref?: string;
|
|
60
|
+
summary?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
servers?: ServerObject[];
|
|
63
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
64
|
+
} & { [method in HttpMethods]?: OperationObject<T>; };
|
|
65
|
+
type OperationObject<T extends {} = {}> = {
|
|
66
|
+
tags?: string[];
|
|
67
|
+
summary?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
externalDocs?: ExternalDocumentationObject;
|
|
70
|
+
operationId?: string;
|
|
71
|
+
parameters?: (ReferenceObject | ParameterObject)[];
|
|
72
|
+
requestBody?: ReferenceObject | RequestBodyObject;
|
|
73
|
+
responses: ResponsesObject;
|
|
74
|
+
callbacks?: {
|
|
75
|
+
[callback: string]: ReferenceObject | CallbackObject;
|
|
76
|
+
};
|
|
77
|
+
deprecated?: boolean;
|
|
78
|
+
security?: SecurityRequirementObject[];
|
|
79
|
+
servers?: ServerObject[];
|
|
80
|
+
} & T;
|
|
81
|
+
interface ExternalDocumentationObject {
|
|
82
|
+
description?: string;
|
|
83
|
+
url: string;
|
|
84
|
+
}
|
|
85
|
+
interface ParameterObject extends ParameterBaseObject {
|
|
86
|
+
name: string;
|
|
87
|
+
in: string;
|
|
88
|
+
}
|
|
89
|
+
interface HeaderObject extends ParameterBaseObject {}
|
|
90
|
+
interface ParameterBaseObject {
|
|
91
|
+
description?: string;
|
|
92
|
+
required?: boolean;
|
|
93
|
+
deprecated?: boolean;
|
|
94
|
+
allowEmptyValue?: boolean;
|
|
95
|
+
style?: string;
|
|
96
|
+
explode?: boolean;
|
|
97
|
+
allowReserved?: boolean;
|
|
98
|
+
schema?: ReferenceObject | SchemaObject;
|
|
99
|
+
example?: any;
|
|
100
|
+
examples?: {
|
|
101
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
102
|
+
};
|
|
103
|
+
content?: {
|
|
104
|
+
[media: string]: MediaTypeObject;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
|
|
108
|
+
type ArraySchemaObjectType = 'array';
|
|
109
|
+
type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
|
|
110
|
+
interface ArraySchemaObject extends BaseSchemaObject {
|
|
111
|
+
type: ArraySchemaObjectType;
|
|
112
|
+
items: ReferenceObject | SchemaObject;
|
|
113
|
+
}
|
|
114
|
+
interface NonArraySchemaObject extends BaseSchemaObject {
|
|
115
|
+
type?: NonArraySchemaObjectType;
|
|
116
|
+
}
|
|
117
|
+
interface BaseSchemaObject {
|
|
118
|
+
title?: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
format?: string;
|
|
121
|
+
default?: any;
|
|
122
|
+
multipleOf?: number;
|
|
123
|
+
maximum?: number;
|
|
124
|
+
exclusiveMaximum?: boolean;
|
|
125
|
+
minimum?: number;
|
|
126
|
+
exclusiveMinimum?: boolean;
|
|
127
|
+
maxLength?: number;
|
|
128
|
+
minLength?: number;
|
|
129
|
+
pattern?: string;
|
|
130
|
+
additionalProperties?: boolean | ReferenceObject | SchemaObject;
|
|
131
|
+
maxItems?: number;
|
|
132
|
+
minItems?: number;
|
|
133
|
+
uniqueItems?: boolean;
|
|
134
|
+
maxProperties?: number;
|
|
135
|
+
minProperties?: number;
|
|
136
|
+
required?: string[];
|
|
137
|
+
enum?: any[];
|
|
138
|
+
properties?: {
|
|
139
|
+
[name: string]: ReferenceObject | SchemaObject;
|
|
140
|
+
};
|
|
141
|
+
allOf?: (ReferenceObject | SchemaObject)[];
|
|
142
|
+
oneOf?: (ReferenceObject | SchemaObject)[];
|
|
143
|
+
anyOf?: (ReferenceObject | SchemaObject)[];
|
|
144
|
+
not?: ReferenceObject | SchemaObject;
|
|
145
|
+
nullable?: boolean;
|
|
146
|
+
discriminator?: DiscriminatorObject;
|
|
147
|
+
readOnly?: boolean;
|
|
148
|
+
writeOnly?: boolean;
|
|
149
|
+
xml?: XMLObject;
|
|
150
|
+
externalDocs?: ExternalDocumentationObject;
|
|
151
|
+
example?: any;
|
|
152
|
+
deprecated?: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface DiscriminatorObject {
|
|
155
|
+
propertyName: string;
|
|
156
|
+
mapping?: {
|
|
157
|
+
[value: string]: string;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
interface XMLObject {
|
|
161
|
+
name?: string;
|
|
162
|
+
namespace?: string;
|
|
163
|
+
prefix?: string;
|
|
164
|
+
attribute?: boolean;
|
|
165
|
+
wrapped?: boolean;
|
|
166
|
+
}
|
|
167
|
+
interface ReferenceObject {
|
|
168
|
+
$ref: string;
|
|
169
|
+
}
|
|
170
|
+
interface ExampleObject {
|
|
171
|
+
summary?: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
value?: any;
|
|
174
|
+
externalValue?: string;
|
|
175
|
+
}
|
|
176
|
+
interface MediaTypeObject {
|
|
177
|
+
schema?: ReferenceObject | SchemaObject;
|
|
178
|
+
example?: any;
|
|
179
|
+
examples?: {
|
|
180
|
+
[media: string]: ReferenceObject | ExampleObject;
|
|
181
|
+
};
|
|
182
|
+
encoding?: {
|
|
183
|
+
[media: string]: EncodingObject;
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
interface EncodingObject {
|
|
187
|
+
contentType?: string;
|
|
188
|
+
headers?: {
|
|
189
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
190
|
+
};
|
|
191
|
+
style?: string;
|
|
192
|
+
explode?: boolean;
|
|
193
|
+
allowReserved?: boolean;
|
|
194
|
+
}
|
|
195
|
+
interface RequestBodyObject {
|
|
196
|
+
description?: string;
|
|
197
|
+
content: {
|
|
198
|
+
[media: string]: MediaTypeObject;
|
|
199
|
+
};
|
|
200
|
+
required?: boolean;
|
|
201
|
+
}
|
|
202
|
+
interface ResponsesObject {
|
|
203
|
+
[code: string]: ReferenceObject | ResponseObject;
|
|
204
|
+
}
|
|
205
|
+
interface ResponseObject {
|
|
206
|
+
description: string;
|
|
207
|
+
headers?: {
|
|
208
|
+
[header: string]: ReferenceObject | HeaderObject;
|
|
209
|
+
};
|
|
210
|
+
content?: {
|
|
211
|
+
[media: string]: MediaTypeObject;
|
|
212
|
+
};
|
|
213
|
+
links?: {
|
|
214
|
+
[link: string]: ReferenceObject | LinkObject;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
interface LinkObject {
|
|
218
|
+
operationRef?: string;
|
|
219
|
+
operationId?: string;
|
|
220
|
+
parameters?: {
|
|
221
|
+
[parameter: string]: any;
|
|
222
|
+
};
|
|
223
|
+
requestBody?: any;
|
|
224
|
+
description?: string;
|
|
225
|
+
server?: ServerObject;
|
|
226
|
+
}
|
|
227
|
+
interface CallbackObject {
|
|
228
|
+
[url: string]: PathItemObject;
|
|
229
|
+
}
|
|
230
|
+
interface SecurityRequirementObject {
|
|
231
|
+
[name: string]: string[];
|
|
232
|
+
}
|
|
233
|
+
interface ComponentsObject {
|
|
234
|
+
schemas?: {
|
|
235
|
+
[key: string]: ReferenceObject | SchemaObject;
|
|
236
|
+
};
|
|
237
|
+
responses?: {
|
|
238
|
+
[key: string]: ReferenceObject | ResponseObject;
|
|
239
|
+
};
|
|
240
|
+
parameters?: {
|
|
241
|
+
[key: string]: ReferenceObject | ParameterObject;
|
|
242
|
+
};
|
|
243
|
+
examples?: {
|
|
244
|
+
[key: string]: ReferenceObject | ExampleObject;
|
|
245
|
+
};
|
|
246
|
+
requestBodies?: {
|
|
247
|
+
[key: string]: ReferenceObject | RequestBodyObject;
|
|
248
|
+
};
|
|
249
|
+
headers?: {
|
|
250
|
+
[key: string]: ReferenceObject | HeaderObject;
|
|
251
|
+
};
|
|
252
|
+
securitySchemes?: {
|
|
253
|
+
[key: string]: ReferenceObject | SecuritySchemeObject;
|
|
254
|
+
};
|
|
255
|
+
links?: {
|
|
256
|
+
[key: string]: ReferenceObject | LinkObject;
|
|
257
|
+
};
|
|
258
|
+
callbacks?: {
|
|
259
|
+
[key: string]: ReferenceObject | CallbackObject;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
|
|
263
|
+
interface HttpSecurityScheme {
|
|
264
|
+
type: 'http';
|
|
265
|
+
description?: string;
|
|
266
|
+
scheme: string;
|
|
267
|
+
bearerFormat?: string;
|
|
268
|
+
}
|
|
269
|
+
interface ApiKeySecurityScheme {
|
|
270
|
+
type: 'apiKey';
|
|
271
|
+
description?: string;
|
|
272
|
+
name: string;
|
|
273
|
+
in: string;
|
|
274
|
+
}
|
|
275
|
+
interface OAuth2SecurityScheme {
|
|
276
|
+
type: 'oauth2';
|
|
277
|
+
description?: string;
|
|
278
|
+
flows: {
|
|
279
|
+
implicit?: {
|
|
280
|
+
authorizationUrl: string;
|
|
281
|
+
refreshUrl?: string;
|
|
282
|
+
scopes: {
|
|
283
|
+
[scope: string]: string;
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
password?: {
|
|
287
|
+
tokenUrl: string;
|
|
288
|
+
refreshUrl?: string;
|
|
289
|
+
scopes: {
|
|
290
|
+
[scope: string]: string;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
clientCredentials?: {
|
|
294
|
+
tokenUrl: string;
|
|
295
|
+
refreshUrl?: string;
|
|
296
|
+
scopes: {
|
|
297
|
+
[scope: string]: string;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
authorizationCode?: {
|
|
301
|
+
authorizationUrl: string;
|
|
302
|
+
tokenUrl: string;
|
|
303
|
+
refreshUrl?: string;
|
|
304
|
+
scopes: {
|
|
305
|
+
[scope: string]: string;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
interface OpenIdSecurityScheme {
|
|
311
|
+
type: 'openIdConnect';
|
|
312
|
+
description?: string;
|
|
313
|
+
openIdConnectUrl: string;
|
|
314
|
+
}
|
|
315
|
+
interface TagObject {
|
|
316
|
+
name: string;
|
|
317
|
+
description?: string;
|
|
318
|
+
externalDocs?: ExternalDocumentationObject;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
interface Property {
|
|
322
|
+
id: string;
|
|
323
|
+
schema?: OpenAPIV3.SchemaObject;
|
|
324
|
+
}
|
|
325
|
+
type PropertyInputBase = {
|
|
326
|
+
id: string;
|
|
327
|
+
};
|
|
328
|
+
type PropertyInputForString = PropertyInputBase & {
|
|
329
|
+
type: 'string';
|
|
330
|
+
value: string;
|
|
331
|
+
};
|
|
332
|
+
type PropertyInputForBoolean = PropertyInputBase & {
|
|
333
|
+
type: 'boolean';
|
|
334
|
+
value: boolean;
|
|
335
|
+
};
|
|
336
|
+
type PropertyInputForInteger = PropertyInputBase & {
|
|
337
|
+
type: 'integer';
|
|
338
|
+
value: number;
|
|
339
|
+
};
|
|
340
|
+
type PropertyInputForObject = PropertyInputBase & {
|
|
341
|
+
type: 'object';
|
|
342
|
+
value: Record<string, PropertyInput>;
|
|
343
|
+
};
|
|
344
|
+
type PropertyInputForStringArray = PropertyInputBase & {
|
|
345
|
+
type: 'array';
|
|
346
|
+
value: string[];
|
|
347
|
+
};
|
|
348
|
+
type PropertyInput = PropertyInputForString | PropertyInputForBoolean | PropertyInputForInteger | PropertyInputForObject | PropertyInputForStringArray;
|
|
349
|
+
type GetPropertyInput = () => PropertyInput;
|
|
350
|
+
/**
|
|
351
|
+
* Result of the generation with a dispose function to clean up
|
|
352
|
+
*/
|
|
353
|
+
interface DisposableGenerationResult<O extends Output> {
|
|
354
|
+
/**
|
|
355
|
+
* The actual generation result
|
|
356
|
+
*/
|
|
357
|
+
result: GenerationResult<O>;
|
|
358
|
+
/**
|
|
359
|
+
* Function to dispose/clean up resources created during generation
|
|
360
|
+
* This should be called when the generation is cancelled or completely
|
|
361
|
+
* finished including the confirmation of the generation if applicable.
|
|
362
|
+
*/
|
|
363
|
+
dispose: () => Promise<void>;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Define the type for middleware functions
|
|
367
|
+
*/
|
|
368
|
+
type Middleware<I, O extends Output> = (input: I, options: GenerationOptions & {
|
|
369
|
+
/**
|
|
370
|
+
* Adds a disposer function to this generation which is called
|
|
371
|
+
* when the generation is cancelled or completely finished
|
|
372
|
+
* including the confirmation of the generation if applicable.
|
|
373
|
+
*/
|
|
374
|
+
addDisposer: (dispose: () => Promise<void>) => void;
|
|
375
|
+
}, next: (input: I, options: GenerationOptions) => Promise<GenerationResult<O>>) => Promise<GenerationResult<O>>;
|
|
376
|
+
export declare function composeMiddlewares<I, O extends Output>(middlewares: (Middleware<I, O> | false | undefined | null)[]): (baseHandler: (input: I, options: GenerationOptions) => Promise<GenerationResult<O>>) => (input: I, options: GenerationOptions) => Promise<DisposableGenerationResult<O>>;
|
|
377
|
+
interface Provider<K extends OutputKind, I, O extends Output, C = O> {
|
|
378
|
+
/**
|
|
379
|
+
* Defines the kind of the generated asset. Maps to the kind
|
|
380
|
+
* CE.SDK
|
|
381
|
+
*/
|
|
382
|
+
kind: K;
|
|
383
|
+
/**
|
|
384
|
+
* The unique identifier of the provider. Is used to generate other
|
|
385
|
+
* identifiers, like the panel ID or keys for translation.
|
|
386
|
+
*/
|
|
387
|
+
id: string;
|
|
388
|
+
/**
|
|
389
|
+
* The human-readable name of the provider.
|
|
390
|
+
*
|
|
391
|
+
* Can be a string or a function that returns the current best-known name.
|
|
392
|
+
* The function form lets providers resolve the name asynchronously after
|
|
393
|
+
* registration (e.g. once a remote schema has loaded) without blocking
|
|
394
|
+
* `cesdk.addPlugin`. Consumers must call the function each time they
|
|
395
|
+
* render the label so that updates are picked up.
|
|
396
|
+
*/
|
|
397
|
+
name?: string | (() => string);
|
|
398
|
+
/**
|
|
399
|
+
* Provider-specific configuration passed during initialization
|
|
400
|
+
* @internal
|
|
401
|
+
*/
|
|
402
|
+
configuration?: any;
|
|
403
|
+
/**
|
|
404
|
+
* Initialize the provider when the plugin is loaded.
|
|
405
|
+
* Can be used to initialize libraries, and register additional UI components.
|
|
406
|
+
*/
|
|
407
|
+
initialize?: (options: {
|
|
408
|
+
engine: CreativeEngine;
|
|
409
|
+
/**
|
|
410
|
+
* If undefined, this indicates that the plugin was loaded
|
|
411
|
+
* just with the engine and probably without an UI.
|
|
412
|
+
*/
|
|
413
|
+
cesdk?: CreativeEditorSDK;
|
|
414
|
+
}) => Promise<void>;
|
|
415
|
+
/**
|
|
416
|
+
* Defines what inputs are needed for the generation and how
|
|
417
|
+
* to create an UI for them.
|
|
418
|
+
*/
|
|
419
|
+
input: {
|
|
420
|
+
/**
|
|
421
|
+
* Is used to generate panel content for the input.
|
|
422
|
+
*/
|
|
423
|
+
panel?: PanelInput<K, I>;
|
|
424
|
+
/**
|
|
425
|
+
* Defines the input for the generation.
|
|
426
|
+
*/
|
|
427
|
+
quickActions?: QuickActionsInput<I>;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Defines the output of the provider, i.e. the asset gneration.
|
|
431
|
+
*/
|
|
432
|
+
output: {
|
|
433
|
+
/**
|
|
434
|
+
* Can the generation of the output be aborted?
|
|
435
|
+
*/
|
|
436
|
+
abortable?: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Defines if a generated asset should be stored in the history.
|
|
439
|
+
*
|
|
440
|
+
* - false: The generated asset is not stored in the history.
|
|
441
|
+
* - `@imgly/local`: The asset is stored in a local asset source. On reload, the generated assets are gone.
|
|
442
|
+
* - '@imgly/indexedDB': The asset is stored in the browser's indexed db. On reload, the generated assets are still available, but only in the same browser.
|
|
443
|
+
* - string: Any other string is used as the asset source ID. The user has to add the asset source during initialization. This can be used for instance to store generated assets in a outside database.
|
|
444
|
+
*/
|
|
445
|
+
history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
|
|
446
|
+
/**
|
|
447
|
+
* Configure if and what notification is shown after success and error.
|
|
448
|
+
*/
|
|
449
|
+
notification?: {
|
|
450
|
+
/**
|
|
451
|
+
* Configure if and what notification is shown when the asset is generated.
|
|
452
|
+
*/
|
|
453
|
+
success?: {
|
|
454
|
+
/**
|
|
455
|
+
* If true, the notification is shown. If false, the notification is not shown.
|
|
456
|
+
* Can be a function that returns a boolean.
|
|
457
|
+
*/
|
|
458
|
+
show?: boolean | ((context: {
|
|
459
|
+
input: I;
|
|
460
|
+
output: O;
|
|
461
|
+
}) => boolean);
|
|
462
|
+
/**
|
|
463
|
+
* The message that is shown when the asset generation was successful. Can be a i18n key.
|
|
464
|
+
* A function can be used to dynamically generate the message based on the input and output.
|
|
465
|
+
*/
|
|
466
|
+
message?: string | ((context: {
|
|
467
|
+
input: I;
|
|
468
|
+
output: O;
|
|
469
|
+
}) => string);
|
|
470
|
+
/**
|
|
471
|
+
* The action that is shown when the asset generation was successful.
|
|
472
|
+
*/
|
|
473
|
+
action?: {
|
|
474
|
+
label: string | ((context: {
|
|
475
|
+
input: I;
|
|
476
|
+
output: O;
|
|
477
|
+
}) => string);
|
|
478
|
+
onClick: (context: {
|
|
479
|
+
input: I;
|
|
480
|
+
output: O;
|
|
481
|
+
}) => void;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* The duration the notification is shown.
|
|
485
|
+
*/
|
|
486
|
+
duration?: NotificationDuration;
|
|
487
|
+
};
|
|
488
|
+
/**
|
|
489
|
+
* Configure if and what notification is shown when generation failed
|
|
490
|
+
* If not set, a generic error message is shown.
|
|
491
|
+
*/
|
|
492
|
+
error?: {
|
|
493
|
+
show?: boolean | ((context: {
|
|
494
|
+
input?: I;
|
|
495
|
+
error: unknown;
|
|
496
|
+
}) => boolean);
|
|
497
|
+
/**
|
|
498
|
+
* The message that is shown when the asset generation failed. Can be a i18n key.
|
|
499
|
+
* A function can be used to dynamically generate the message based on the input and output.
|
|
500
|
+
*/
|
|
501
|
+
message?: string | ((context: {
|
|
502
|
+
input?: I;
|
|
503
|
+
error: unknown;
|
|
504
|
+
}) => string);
|
|
505
|
+
/**
|
|
506
|
+
* The action that is shown when the asset generation failed.
|
|
507
|
+
*/
|
|
508
|
+
action?: {
|
|
509
|
+
label: string | ((context: {
|
|
510
|
+
input?: I;
|
|
511
|
+
error: unknown;
|
|
512
|
+
}) => string);
|
|
513
|
+
onClick: (context: {
|
|
514
|
+
input?: I;
|
|
515
|
+
error: unknown;
|
|
516
|
+
}) => void;
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* The duration the notification is shown.
|
|
520
|
+
*/
|
|
521
|
+
duration?: NotificationDuration;
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Generate the asset given the input.
|
|
526
|
+
*
|
|
527
|
+
* @returns The generated asset
|
|
528
|
+
*/
|
|
529
|
+
generate: (input: I, options: GenerationOptions) => Promise<GenerationResult<O, C>>;
|
|
530
|
+
/**
|
|
531
|
+
* Short informational text to display below the generation button.
|
|
532
|
+
*/
|
|
533
|
+
generationHintText?: string;
|
|
534
|
+
/**
|
|
535
|
+
* Middlware functions that can be used to hook into the
|
|
536
|
+
* generation process.
|
|
537
|
+
*/
|
|
538
|
+
middleware?: Middleware<I, O>[];
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* The result of the generation function.
|
|
543
|
+
*
|
|
544
|
+
* Is either a promise that is directly returning
|
|
545
|
+
* the result of the generation, or an async generator
|
|
546
|
+
* that streams the result in chunks (C) and finally
|
|
547
|
+
* returns the final result (O).
|
|
548
|
+
*/
|
|
549
|
+
type GenerationResult<O extends Output, C = O> = O | AsyncGenerator<O, C>;
|
|
550
|
+
/**
|
|
551
|
+
* The options for the generation function.
|
|
552
|
+
*/
|
|
553
|
+
type GenerationOptions = {
|
|
554
|
+
/**
|
|
555
|
+
* The block IDs that this generation is operating on.
|
|
556
|
+
* Middleware can use this to target specific blocks.
|
|
557
|
+
* - undefined: Middleware typically fall back to selected blocks
|
|
558
|
+
* - []: Explicitly target no blocks
|
|
559
|
+
* - [1, 2, 3]: Target specific blocks
|
|
560
|
+
*
|
|
561
|
+
* Note: This is passed through to middleware but not required by provider implementations.
|
|
562
|
+
*/
|
|
563
|
+
blockIds?: number[];
|
|
564
|
+
abortSignal?: AbortSignal;
|
|
565
|
+
engine: CreativeEngine;
|
|
566
|
+
cesdk?: CreativeEditorSDK;
|
|
567
|
+
/**
|
|
568
|
+
* Prevents default UI feedback behaviors for this generation.
|
|
569
|
+
*
|
|
570
|
+
* **What gets prevented:**
|
|
571
|
+
* - Error/success notifications
|
|
572
|
+
* - Block error state
|
|
573
|
+
* - Console error logging
|
|
574
|
+
*
|
|
575
|
+
* **What is NOT prevented (always happens):**
|
|
576
|
+
* - Pending → Ready block state transition (loading spinner always stops)
|
|
577
|
+
* - Block validity checks
|
|
578
|
+
* - Middleware execution flow
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```typescript
|
|
582
|
+
* catch (error) {
|
|
583
|
+
* options.preventDefault();
|
|
584
|
+
* myCustomErrorHandler(error);
|
|
585
|
+
* throw error;
|
|
586
|
+
* }
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
preventDefault(): void;
|
|
590
|
+
/**
|
|
591
|
+
* Check if default behaviors have been prevented.
|
|
592
|
+
*
|
|
593
|
+
* @returns `true` if preventDefault() was called
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```typescript
|
|
597
|
+
* if (!options.defaultPrevented()) {
|
|
598
|
+
* // Show default notification
|
|
599
|
+
* }
|
|
600
|
+
* ```
|
|
601
|
+
*
|
|
602
|
+
* @internal
|
|
603
|
+
*/
|
|
604
|
+
defaultPrevented(): boolean;
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* The context a custom property renderer is called with: the panel's builder
|
|
608
|
+
* context, plus what a schema property gets for free — the provider it belongs
|
|
609
|
+
* to and the configuration that may override it.
|
|
610
|
+
*
|
|
611
|
+
* Every extra is optional. A renderer can be called from a panel that has no
|
|
612
|
+
* provider behind it.
|
|
613
|
+
*/
|
|
614
|
+
type CustomPropertyContext = BuilderRenderFunctionContext<any> & {
|
|
615
|
+
provider?: {
|
|
616
|
+
id: string;
|
|
617
|
+
};
|
|
618
|
+
kind?: OutputKind;
|
|
619
|
+
/**
|
|
620
|
+
* The properties the panel renders. A renderer that pairs two properties
|
|
621
|
+
* uses it to tell whether its partner exists, and what its schema allows.
|
|
622
|
+
*/
|
|
623
|
+
properties?: Property[];
|
|
624
|
+
providerConfig?: any;
|
|
625
|
+
config?: any;
|
|
626
|
+
};
|
|
627
|
+
type RenderCustomProperty = {
|
|
628
|
+
[key: string]: (context: CustomPropertyContext, property: Property) => GetPropertyInput;
|
|
629
|
+
};
|
|
630
|
+
type PanelInput<K extends OutputKind, I> = PanelInputCustom<K, I> | PanelInputSchema<K, I>;
|
|
631
|
+
interface PanelInputBase {
|
|
632
|
+
/**
|
|
633
|
+
* Determines the flow of the asset generation.
|
|
634
|
+
*
|
|
635
|
+
* - `placeholder`: When `Generate` is clicked, the asset generation is triggered and a block is created as a placeholder with a loading state. Once the asset is generated, the block is updated with the asset and we add a history entry.
|
|
636
|
+
* - `generation-only`: When `Generate` is clicked, only the asset generation is triggered. No block is created.
|
|
637
|
+
*
|
|
638
|
+
* @default 'generation-only'
|
|
639
|
+
*/
|
|
640
|
+
userFlow?: 'placeholder' | 'generation-only';
|
|
641
|
+
/**
|
|
642
|
+
* If true, the history library is appended to the panel.
|
|
643
|
+
*
|
|
644
|
+
* @default true
|
|
645
|
+
*/
|
|
646
|
+
includeHistoryLibrary?: boolean;
|
|
647
|
+
}
|
|
648
|
+
interface PanelInputSchema<K extends OutputKind, I> extends PanelInputBase {
|
|
649
|
+
type: 'schema';
|
|
650
|
+
/**
|
|
651
|
+
* The OpenAPI document/schema for a service.
|
|
652
|
+
*
|
|
653
|
+
* Can be provided as a static document or a lazy function that returns
|
|
654
|
+
* the document (or a Promise of it) — useful when the schema is fetched
|
|
655
|
+
* from the network only when the panel first opens.
|
|
656
|
+
*/
|
|
657
|
+
document: OpenAPIV3.Document | (() => OpenAPIV3.Document | Promise<OpenAPIV3.Document>);
|
|
658
|
+
/**
|
|
659
|
+
* The reference to the input in the OpenAPI document.
|
|
660
|
+
* This is used to determine the input components for the generation panel.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* `#/components/schemas/GenerationInput`
|
|
664
|
+
*/
|
|
665
|
+
inputReference: string;
|
|
666
|
+
/**
|
|
667
|
+
* The keyword that determines the order of properties. the
|
|
668
|
+
* referenced extension keyword should contain an array of strings
|
|
669
|
+
* representing the properties.
|
|
670
|
+
*/
|
|
671
|
+
orderExtensionKeyword?: string | string[];
|
|
672
|
+
/**
|
|
673
|
+
* Defined the order of the properties in the panel. Takes precedence over
|
|
674
|
+
* the order defined in the schema (also see `orderExtensionKeyword`).
|
|
675
|
+
*
|
|
676
|
+
* If a function is provided, it receives the current order of properties from
|
|
677
|
+
* the schema and can return a new order.
|
|
678
|
+
*/
|
|
679
|
+
order?: string[] | ((order: string[]) => string[]);
|
|
680
|
+
/**
|
|
681
|
+
* Returns the necessary input for the creation of a block.
|
|
682
|
+
*
|
|
683
|
+
*/
|
|
684
|
+
getBlockInput: GetBlockInput<K, I>;
|
|
685
|
+
/**
|
|
686
|
+
* Allows to customize the components for some properties.
|
|
687
|
+
*/
|
|
688
|
+
renderCustomProperty?: RenderCustomProperty;
|
|
689
|
+
}
|
|
690
|
+
interface PanelInputCustom<K extends OutputKind, I> extends PanelInputBase {
|
|
691
|
+
type: 'custom';
|
|
692
|
+
/**
|
|
693
|
+
* Is called to render custom UI components for the generation panel.
|
|
694
|
+
*
|
|
695
|
+
* @returns A function that returns the current input state and the context when called.
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
*
|
|
699
|
+
```ts
|
|
700
|
+
render: ({ builder, state }, options) => {
|
|
701
|
+
const promptState = state('prompt', '');
|
|
702
|
+
builder.PromptInput('prompt', {
|
|
703
|
+
label: 'Prompt',
|
|
704
|
+
...promptState
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
return {
|
|
708
|
+
getInput: () => ({ prompt: promptState.value }),
|
|
709
|
+
getBlockInput: () => ({ image: { width: 1024, height: 1024 } })
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
```
|
|
713
|
+
*/
|
|
714
|
+
render: (context: BuilderRenderFunctionContext<any>, options: {
|
|
715
|
+
cesdk: CreativeEditorSDK;
|
|
716
|
+
isGenerating: boolean;
|
|
717
|
+
}) => {
|
|
718
|
+
getInput: GetInput<I>;
|
|
719
|
+
getBlockInput: GetBlockInput<K, I>;
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Returns the current input state when called.
|
|
724
|
+
* This input is used for the AI generation
|
|
725
|
+
*/
|
|
726
|
+
type GetInput<I> = () => {
|
|
727
|
+
input: I;
|
|
728
|
+
};
|
|
729
|
+
/**
|
|
730
|
+
* Returns the input that is needed to create a block
|
|
731
|
+
* for a given output kind.
|
|
732
|
+
*/
|
|
733
|
+
type GetBlockInput<K extends OutputKind, I> = (input: I) => Promise<GetBlockInputResult<K>>;
|
|
734
|
+
type GetBlockInputResult<K extends OutputKind> = Record<K, InputByKind[K]>;
|
|
735
|
+
/**
|
|
736
|
+
* All possible output kinds.
|
|
737
|
+
*/
|
|
738
|
+
type OutputKind = 'image' | 'video' | 'audio' | 'text' | 'sticker';
|
|
739
|
+
/**
|
|
740
|
+
* Mandatory kind-specific input needed for the generation.
|
|
741
|
+
*/
|
|
742
|
+
type InputByKind = {
|
|
743
|
+
image: {
|
|
744
|
+
label?: string;
|
|
745
|
+
width: number;
|
|
746
|
+
height: number;
|
|
747
|
+
};
|
|
748
|
+
video: {
|
|
749
|
+
label?: string;
|
|
750
|
+
width: number;
|
|
751
|
+
height: number;
|
|
752
|
+
duration: number;
|
|
753
|
+
};
|
|
754
|
+
audio: {
|
|
755
|
+
label?: string;
|
|
756
|
+
thumbnailUrl?: string;
|
|
757
|
+
duration?: number;
|
|
758
|
+
};
|
|
759
|
+
text: {
|
|
760
|
+
label?: string;
|
|
761
|
+
length: number;
|
|
762
|
+
};
|
|
763
|
+
sticker: {
|
|
764
|
+
label?: string;
|
|
765
|
+
width: number;
|
|
766
|
+
height: number;
|
|
767
|
+
};
|
|
768
|
+
};
|
|
769
|
+
/**
|
|
770
|
+
* The generated output of the provider.
|
|
771
|
+
*/
|
|
772
|
+
type Output = ImageOutput | VideoOutput | AudioOutput | TextOutput | StickerOutput;
|
|
773
|
+
type OutputBase<K extends OutputKind> = {
|
|
774
|
+
kind: K;
|
|
775
|
+
};
|
|
776
|
+
interface ImageOutput extends OutputBase<'image'> {
|
|
777
|
+
kind: 'image';
|
|
778
|
+
url: string;
|
|
779
|
+
}
|
|
780
|
+
interface VideoOutput extends OutputBase<'video'> {
|
|
781
|
+
kind: 'video';
|
|
782
|
+
url: string;
|
|
783
|
+
}
|
|
784
|
+
interface AudioOutput extends OutputBase<'audio'> {
|
|
785
|
+
kind: 'audio';
|
|
786
|
+
url: string;
|
|
787
|
+
duration: number;
|
|
788
|
+
thumbnailUrl?: string;
|
|
789
|
+
}
|
|
790
|
+
interface TextOutput extends OutputBase<'text'> {
|
|
791
|
+
kind: 'text';
|
|
792
|
+
text: string;
|
|
793
|
+
}
|
|
794
|
+
interface StickerOutput extends OutputBase<'sticker'> {
|
|
795
|
+
kind: 'sticker';
|
|
796
|
+
url: string;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Support mapping for a specific quick action.
|
|
800
|
+
* Maps quick action input to provider input.
|
|
801
|
+
* Allows `true` or empty object `{}` as shorthand when quick action input is compatible with provider input.
|
|
802
|
+
*/
|
|
803
|
+
type QuickActionSupport<I> = true | {
|
|
804
|
+
/**
|
|
805
|
+
* Map quick action input to provider input.
|
|
806
|
+
* @param quickActionInput The input from the quick action
|
|
807
|
+
* @returns The mapped input for the provider
|
|
808
|
+
*/
|
|
809
|
+
mapInput: (quickActionInput: any) => I;
|
|
810
|
+
} | {
|
|
811
|
+
[key: string]: any;
|
|
812
|
+
};
|
|
813
|
+
type QuickActionsInput<I> = {
|
|
814
|
+
/**
|
|
815
|
+
* Supported global quick actions with input transformations.
|
|
816
|
+
* Key is the quick action ID, value is the transformation mapping.
|
|
817
|
+
*/
|
|
818
|
+
supported?: {
|
|
819
|
+
[quickActionId: string]: QuickActionSupport<I>;
|
|
820
|
+
};
|
|
821
|
+
};
|
|
822
|
+
/**
|
|
823
|
+
* Provides the render functions for an image url property, and for the prompt
|
|
824
|
+
* that refers to it.
|
|
825
|
+
*
|
|
826
|
+
* The image is not a control of its own: it shows inside the prompt, which is
|
|
827
|
+
* the one place a user describes what to generate. So this returns two
|
|
828
|
+
* renderers — the image property contributes only its value, and the prompt
|
|
829
|
+
* property draws the field plus the image row.
|
|
830
|
+
*
|
|
831
|
+
* The row takes as many images as the image property's schema allows: one for
|
|
832
|
+
* a string, `maxItems` for an array. An array without `maxItems` takes one,
|
|
833
|
+
* as the model's own limit is unknown.
|
|
834
|
+
*
|
|
835
|
+
* By default this expects the property key to be `image_url` and the prompt to
|
|
836
|
+
* be `prompt`. Both can be changed in the options.
|
|
837
|
+
*/
|
|
838
|
+
declare function renderImageUrlProperty(provderId: string, options: {
|
|
839
|
+
cesdk: CreativeEditorSDK;
|
|
840
|
+
propertyKey?: string;
|
|
841
|
+
promptPropertyKey?: string;
|
|
842
|
+
defaultUrl?: string;
|
|
843
|
+
}): RenderCustomProperty;
|
|
844
|
+
/**
|
|
845
|
+
* Whether the prompt of a provider's generation panel has room for one more
|
|
846
|
+
* image. False for a provider without an image row.
|
|
847
|
+
*
|
|
848
|
+
* @param cesdk The editor whose panel state holds the images.
|
|
849
|
+
* @param providerId The provider whose prompt would receive the image.
|
|
850
|
+
* @returns Whether `attachImageToPrompt` would attach an image.
|
|
851
|
+
*/
|
|
852
|
+
export declare function canAttachImageToPrompt(cesdk: CreativeEditorSDK, providerId: string): boolean;
|
|
853
|
+
/**
|
|
854
|
+
* Attaches an image to the prompt of a provider's generation panel, beside
|
|
855
|
+
* the images already there, as picking it from the library would.
|
|
856
|
+
*
|
|
857
|
+
* @param cesdk The editor whose panel state holds the images.
|
|
858
|
+
* @param providerId The provider whose prompt receives the image.
|
|
859
|
+
* @param uri The image to attach.
|
|
860
|
+
* @returns Whether the image is attached afterwards. False for a provider
|
|
861
|
+
* without an image row, and for a row with no room left.
|
|
862
|
+
*/
|
|
863
|
+
export declare function attachImageToPrompt(cesdk: CreativeEditorSDK, providerId: string, uri: string): boolean;
|
|
864
|
+
type Style = {
|
|
865
|
+
id: 'none' | (string & {});
|
|
866
|
+
label: string;
|
|
867
|
+
prompt: string;
|
|
868
|
+
thumbUri: string;
|
|
869
|
+
};
|
|
870
|
+
/**
|
|
871
|
+
* Provides render function for a style transfer property that allows
|
|
872
|
+
* to change a style (of an image) from a library.
|
|
873
|
+
*
|
|
874
|
+
* The style will be appended to the prompt property, so the model does
|
|
875
|
+
* not need to support style transfer directly.
|
|
876
|
+
*
|
|
877
|
+
* By default this expects the property key to be `style`. This can be changed with the option
|
|
878
|
+
* `propertyKey`.
|
|
879
|
+
*/
|
|
880
|
+
declare function renderStyleTransferProperty(providerId: string, options: {
|
|
881
|
+
cesdk?: CreativeEditorSDK;
|
|
882
|
+
/**
|
|
883
|
+
* Base URL used for the UI assets used in the plugin.
|
|
884
|
+
*/
|
|
885
|
+
baseURL?: string;
|
|
886
|
+
/**
|
|
887
|
+
* What property key to use for the style property.
|
|
888
|
+
*/
|
|
889
|
+
propertyKey?: string;
|
|
890
|
+
/**
|
|
891
|
+
* What property key to use for the prompt property.
|
|
892
|
+
*/
|
|
893
|
+
propertyKeyForPrompt?: string;
|
|
894
|
+
/**
|
|
895
|
+
* Override the default styles
|
|
896
|
+
*/
|
|
897
|
+
styles?: Style[] | ((defaultStyles: Style[]) => Style[]);
|
|
898
|
+
/**
|
|
899
|
+
* Overrides the default i18n translations for the prompt input.
|
|
900
|
+
*/
|
|
901
|
+
i18n?: {
|
|
902
|
+
prompt?: {
|
|
903
|
+
inputLabel?: string;
|
|
904
|
+
placeholder?: string;
|
|
905
|
+
};
|
|
906
|
+
};
|
|
907
|
+
}): RenderCustomProperty;
|
|
908
|
+
/**
|
|
909
|
+
* Base context provided to all property default functions
|
|
910
|
+
*/
|
|
911
|
+
interface PropertyContext {
|
|
912
|
+
/**
|
|
913
|
+
* Creative Engine instance
|
|
914
|
+
* Always available for engine-level operations
|
|
915
|
+
*/
|
|
916
|
+
engine: CreativeEngine;
|
|
917
|
+
/**
|
|
918
|
+
* Creative Editor SDK instance
|
|
919
|
+
* May be undefined if running headless or without UI
|
|
920
|
+
*/
|
|
921
|
+
cesdk?: CreativeEditorSDK;
|
|
922
|
+
/**
|
|
923
|
+
* Current locale for internationalization
|
|
924
|
+
* Format: ISO 639-1 language code (e.g., 'en', 'de', 'ja')
|
|
925
|
+
* Defaults to 'en' if not available
|
|
926
|
+
*/
|
|
927
|
+
locale: string;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Configuration for a single property
|
|
931
|
+
* @template T - The type of the property value
|
|
932
|
+
* @template C - The context type (defaults to PropertyContext)
|
|
933
|
+
*/
|
|
934
|
+
interface PropertyConfig<T, C extends PropertyContext = PropertyContext> {
|
|
935
|
+
/**
|
|
936
|
+
* Default value for the property
|
|
937
|
+
* Can be a static value or a function that returns the value
|
|
938
|
+
*/
|
|
939
|
+
default?: T | ((context: C) => T);
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Properties configuration for a provider
|
|
943
|
+
* @template I - The input type of the provider
|
|
944
|
+
*/
|
|
945
|
+
type PropertiesConfiguration<I> = { [K in keyof Partial<I>]?: PropertyConfig<I[K]>; };
|
|
946
|
+
/**
|
|
947
|
+
* Utility type for extending property contexts selectively
|
|
948
|
+
* @template I - The input type of the provider
|
|
949
|
+
* @template ContextMap - Map of property names to their extended context types
|
|
950
|
+
*
|
|
951
|
+
* @example
|
|
952
|
+
* ```typescript
|
|
953
|
+
* type MyConfig = ExtendPropertyContexts<MyInput, {
|
|
954
|
+
* style: StyleContext; // style property gets StyleContext
|
|
955
|
+
* // other properties get PropertyContext
|
|
956
|
+
* }>;
|
|
957
|
+
* ```
|
|
958
|
+
*/
|
|
959
|
+
type ExtendPropertyContexts<I, ContextMap extends Partial<Record<keyof I, PropertyContext>>> = { [K in keyof Partial<I>]: K extends keyof ContextMap ? ContextMap[K] extends PropertyContext ? PropertyConfig<I[K], ContextMap[K]> : PropertyConfig<I[K]> : PropertyConfig<I[K]>; };
|
|
960
|
+
/**
|
|
961
|
+
* A common configuration used by the plugins and the provider.
|
|
962
|
+
*/
|
|
963
|
+
interface CommonConfiguration<I, O extends Output> {
|
|
964
|
+
/**
|
|
965
|
+
* Render console logs for debugging purposes.
|
|
966
|
+
*/
|
|
967
|
+
debug?: boolean;
|
|
968
|
+
/**
|
|
969
|
+
* Dry run mode. If set to true, the plugin will not make any API calls.
|
|
970
|
+
*/
|
|
971
|
+
dryRun?: boolean;
|
|
972
|
+
/**
|
|
973
|
+
* Middlewares to add to the provider generation
|
|
974
|
+
*/
|
|
975
|
+
middlewares?: Middleware<I, O>[];
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Configuration to set provider and models for image generation.
|
|
979
|
+
*/
|
|
980
|
+
interface CommonPluginConfiguration<K extends OutputKind, I, O extends Output> extends CommonConfiguration<I, O> {
|
|
981
|
+
/**
|
|
982
|
+
* Base URL used for the UI assets used in the plugin.
|
|
983
|
+
*
|
|
984
|
+
* By default, we load the assets from the IMG.LY CDN. You can copy the assets.
|
|
985
|
+
* from the `/assets` folder to your own server and set the base URL to your server.
|
|
986
|
+
*/
|
|
987
|
+
baseURL?: string;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Returns a provider for a given cesdk instance.
|
|
991
|
+
*/
|
|
992
|
+
type GetProvider<K extends OutputKind> = ({ cesdk }: {
|
|
993
|
+
cesdk: CreativeEditorSDK;
|
|
994
|
+
}) => Promise<Provider<K, any, any>>;
|
|
995
|
+
/**
|
|
996
|
+
* Common provider configuration that all providers should provide.
|
|
997
|
+
*/
|
|
998
|
+
interface CommonProviderConfiguration<I, O extends Output> extends CommonConfiguration<I, O> {
|
|
999
|
+
/**
|
|
1000
|
+
* The proxy URL to use for the provider.
|
|
1001
|
+
*/
|
|
1002
|
+
proxyUrl: string;
|
|
1003
|
+
/**
|
|
1004
|
+
* Headers that shall be sent with the request of the provider.
|
|
1005
|
+
*/
|
|
1006
|
+
headers?: Record<string, string>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Middlewares to add to the provider generation
|
|
1009
|
+
* @deprecated Use `middlewares` instead.
|
|
1010
|
+
*/
|
|
1011
|
+
middleware?: Middleware<I, O>[];
|
|
1012
|
+
/**
|
|
1013
|
+
* Override provider's default history asset source that is used to show the generation history
|
|
1014
|
+
*
|
|
1015
|
+
* - false: Disable history storage
|
|
1016
|
+
* - '@imgly/local': Use temporary local storage (not persistent)
|
|
1017
|
+
* - '@imgly/indexedDB': Use browser storage that is persistent across sessions in the same browser
|
|
1018
|
+
* - string: Use your own custom asset source ID
|
|
1019
|
+
*/
|
|
1020
|
+
history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
|
|
1021
|
+
/**
|
|
1022
|
+
* Configure supported quick actions
|
|
1023
|
+
* - Set to false/null to disable a quick action
|
|
1024
|
+
* - Partial<QuickActionSupport<I>> to override the default configuration
|
|
1025
|
+
*/
|
|
1026
|
+
supportedQuickActions?: {
|
|
1027
|
+
[quickActionId: string]: Partial<QuickActionSupport<I>> | false | null;
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Configure property behavior and defaults
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```typescript
|
|
1033
|
+
* {
|
|
1034
|
+
* properties: {
|
|
1035
|
+
* style: { default: 'realistic_image' },
|
|
1036
|
+
* prompt: { default: (ctx) => ctx.locale === 'de' ? 'Erstelle...' : 'Create...' }
|
|
1037
|
+
* }
|
|
1038
|
+
* }
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
properties?: PropertiesConfiguration<I>;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Internal configuration interface for provider initialization.
|
|
1045
|
+
* This extends the public CommonPluginConfiguration with required provider field.
|
|
1046
|
+
*/
|
|
1047
|
+
interface InternalPluginConfiguration<K extends OutputKind, I, O extends Output> extends CommonConfiguration<I, O> {
|
|
1048
|
+
/**
|
|
1049
|
+
* The provider to use for generation.
|
|
1050
|
+
*/
|
|
1051
|
+
provider: Provider<K, I, O>;
|
|
1052
|
+
/**
|
|
1053
|
+
* The panel input schema to use for the provider.
|
|
1054
|
+
*/
|
|
1055
|
+
panelInput?: PanelInput<K, I>;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Options for UI interactions
|
|
1059
|
+
*/
|
|
1060
|
+
type UIOptions = {
|
|
1061
|
+
cesdk: CreativeEditorSDK;
|
|
1062
|
+
engine: CreativeEngine;
|
|
1063
|
+
historyAssetSourceId?: string;
|
|
1064
|
+
historyAssetLibraryEntryId?: string;
|
|
1065
|
+
};
|
|
1066
|
+
/**
|
|
1067
|
+
* Build the base property context from available sources
|
|
1068
|
+
*/
|
|
1069
|
+
export declare function buildPropertyContext(engine: CreativeEngine, cesdk?: CreativeEditorSDK): PropertyContext;
|
|
1070
|
+
/**
|
|
1071
|
+
* Context cache for performance optimization
|
|
1072
|
+
*/
|
|
1073
|
+
export declare class PropertyContextCache {
|
|
1074
|
+
private cache;
|
|
1075
|
+
/**
|
|
1076
|
+
* Get cached context or build new one
|
|
1077
|
+
*/
|
|
1078
|
+
getContext(engine: CreativeEngine, cesdk?: CreativeEditorSDK): PropertyContext;
|
|
1079
|
+
/**
|
|
1080
|
+
* Clear the cache (e.g., when locale changes)
|
|
1081
|
+
*/
|
|
1082
|
+
clear(): void;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Resolve the default value for a property
|
|
1086
|
+
* @template T - The property value type
|
|
1087
|
+
* @template C - The context type
|
|
1088
|
+
*/
|
|
1089
|
+
export declare function resolvePropertyDefault<T, C extends PropertyContext = PropertyContext>(propertyId: string, propertyConfig: PropertyConfig<T, C> | undefined, context: C, schemaDefault?: T, fallback?: T): T | undefined;
|
|
1090
|
+
/**
|
|
1091
|
+
* Batch resolve multiple property defaults
|
|
1092
|
+
*/
|
|
1093
|
+
export declare function resolvePropertyDefaults<I, C extends PropertyContext = PropertyContext>(properties: Array<{
|
|
1094
|
+
id: keyof I;
|
|
1095
|
+
config?: PropertyConfig<I[keyof I], C>;
|
|
1096
|
+
schemaDefault?: I[keyof I];
|
|
1097
|
+
fallback?: I[keyof I];
|
|
1098
|
+
}>, context: C): Partial<I>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Integrates the asset sources into the default asset library entry for the
|
|
1101
|
+
* given kind.
|
|
1102
|
+
*/
|
|
1103
|
+
declare function integrateIntoDefaultAssetLibraryEntry<K extends OutputKind>(kind: K, historAssetSourceIds: string[], cesdk: CreativeEditorSDK): string | undefined;
|
|
1104
|
+
type ResultSuccess<O> = {
|
|
1105
|
+
status: 'success';
|
|
1106
|
+
type: 'async';
|
|
1107
|
+
output: AsyncGenerator<O>;
|
|
1108
|
+
middlewareOptions?: GenerationOptions;
|
|
1109
|
+
} | {
|
|
1110
|
+
status: 'success';
|
|
1111
|
+
type: 'sync';
|
|
1112
|
+
output: O;
|
|
1113
|
+
middlewareOptions?: GenerationOptions;
|
|
1114
|
+
};
|
|
1115
|
+
type Result<O> = ResultSuccess<O> | {
|
|
1116
|
+
status: 'error';
|
|
1117
|
+
message: string;
|
|
1118
|
+
/**
|
|
1119
|
+
* The value that was thrown, preserved so consumers can inspect it
|
|
1120
|
+
* instead of pattern-matching `message`. Gateway failures carry a
|
|
1121
|
+
* `GatewayError` here — narrow it with `isGatewayError`.
|
|
1122
|
+
*/
|
|
1123
|
+
error?: unknown;
|
|
1124
|
+
middlewareOptions?: GenerationOptions;
|
|
1125
|
+
} | {
|
|
1126
|
+
status: 'aborted';
|
|
1127
|
+
middlewareOptions?: GenerationOptions;
|
|
1128
|
+
};
|
|
1129
|
+
type Generate<I, O extends Output> = (input: I, options?: {
|
|
1130
|
+
/**
|
|
1131
|
+
* The block IDs that this generation is operating on.
|
|
1132
|
+
* - undefined: Middleware will fall back to selected blocks
|
|
1133
|
+
* - []: Explicitly target no blocks
|
|
1134
|
+
* - [1, 2, 3]: Target specific blocks (e.g., placeholder block)
|
|
1135
|
+
*/
|
|
1136
|
+
blockIds?: number[];
|
|
1137
|
+
abortSignal?: AbortSignal;
|
|
1138
|
+
middlewares?: Middleware<I, O>[];
|
|
1139
|
+
debug?: boolean;
|
|
1140
|
+
dryRun?: boolean;
|
|
1141
|
+
}) => Promise<Result<O>>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Base properties shared by all action definitions.
|
|
1144
|
+
*/
|
|
1145
|
+
interface BaseActionDefinition {
|
|
1146
|
+
/** Unique identifier for the action */
|
|
1147
|
+
id: string;
|
|
1148
|
+
/** Human-readable label for the action (fallback when labelKey is not available) */
|
|
1149
|
+
label?: string;
|
|
1150
|
+
/** Translation key for the label (preferred for i18n support) */
|
|
1151
|
+
labelKey?: string;
|
|
1152
|
+
/** Detailed description of what the action does */
|
|
1153
|
+
description?: string;
|
|
1154
|
+
/** Optional metadata for additional information */
|
|
1155
|
+
meta?: Record<string, any>;
|
|
1156
|
+
/** The scene mode for which this action is only applicable */
|
|
1157
|
+
sceneMode?: SceneMode;
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Definition for a plugin action - a global action that can be invoked from apps, command palettes, etc.
|
|
1161
|
+
*/
|
|
1162
|
+
interface PluginActionDefinition extends BaseActionDefinition {
|
|
1163
|
+
/** Action type discriminator */
|
|
1164
|
+
type: 'plugin';
|
|
1165
|
+
/** ID of the plugin that registered this action */
|
|
1166
|
+
pluginId: string;
|
|
1167
|
+
/** Function to execute the action */
|
|
1168
|
+
execute: () => void;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Render context for quick actions with generation capability.
|
|
1172
|
+
*/
|
|
1173
|
+
interface QuickActionRenderContext<Q = Record<string, any>> {
|
|
1174
|
+
/** Toggle between collapsed and expanded state */
|
|
1175
|
+
toggleExpand: () => void;
|
|
1176
|
+
/** Whether the quick action is currently expanded */
|
|
1177
|
+
isExpanded: boolean;
|
|
1178
|
+
/** Close the entire quick action popover */
|
|
1179
|
+
close: () => void;
|
|
1180
|
+
/** Generate output using the quick action input */
|
|
1181
|
+
generate: (input: Q, options?: {
|
|
1182
|
+
blockIds?: number[];
|
|
1183
|
+
}) => Promise<Result<Output>>;
|
|
1184
|
+
/** The ID of the provider used for this quick action */
|
|
1185
|
+
providerId: string;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Definition for a quick action - a context-sensitive action that operates on selected blocks.
|
|
1189
|
+
*/
|
|
1190
|
+
interface QuickActionDefinition<Q extends Record<string, any>> extends BaseActionDefinition {
|
|
1191
|
+
/** Action type discriminator */
|
|
1192
|
+
type: 'quick';
|
|
1193
|
+
/** The kind of block this action operates on */
|
|
1194
|
+
kind: OutputKind;
|
|
1195
|
+
/**
|
|
1196
|
+
* Defines if the quick action is enabled or not by using the
|
|
1197
|
+
* feature api.
|
|
1198
|
+
*/
|
|
1199
|
+
enable: boolean | ((context: {
|
|
1200
|
+
engine: CreativeEngine;
|
|
1201
|
+
}) => boolean);
|
|
1202
|
+
/**
|
|
1203
|
+
* Define the necessary scopes for this quick action.
|
|
1204
|
+
*/
|
|
1205
|
+
scopes?: Scope[];
|
|
1206
|
+
/**
|
|
1207
|
+
* Overrides the defaults for this quick action.
|
|
1208
|
+
*/
|
|
1209
|
+
defaults?: {
|
|
1210
|
+
/** Should the generation be directly applied or does it need confirmation */
|
|
1211
|
+
confirmation?: boolean;
|
|
1212
|
+
/** Whether the block should be locked */
|
|
1213
|
+
lock?: boolean;
|
|
1214
|
+
};
|
|
1215
|
+
/** Render function for the quick action UI */
|
|
1216
|
+
render: (context: BuilderRenderFunctionContext<any> & QuickActionRenderContext<Q>) => void;
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Union type of all supported action definitions.
|
|
1220
|
+
*/
|
|
1221
|
+
type ActionDefinition = PluginActionDefinition | QuickActionDefinition<Record<string, any>>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Event types for ActionRegistry subscriptions.
|
|
1224
|
+
*/
|
|
1225
|
+
type ActionRegistryEventType = 'registered' | 'unregistered';
|
|
1226
|
+
/**
|
|
1227
|
+
* Callback function for ActionRegistry subscriptions.
|
|
1228
|
+
*/
|
|
1229
|
+
type ActionRegistrySubscriberCallback = (action: ActionDefinition, event: ActionRegistryEventType) => void;
|
|
1230
|
+
/**
|
|
1231
|
+
* Filters for querying and subscribing to specific types of actions.
|
|
1232
|
+
* Used by both getBy() and subscribeBy() methods.
|
|
1233
|
+
*/
|
|
1234
|
+
interface ActionRegistryFilters {
|
|
1235
|
+
/** Filter by action type */
|
|
1236
|
+
type?: ActionDefinition['type'];
|
|
1237
|
+
/** Filter by plugin ID */
|
|
1238
|
+
pluginId?: string;
|
|
1239
|
+
/** Filter by action ID */
|
|
1240
|
+
id?: string;
|
|
1241
|
+
/** Filter by kind (only applicable for quick actions) */
|
|
1242
|
+
kind?: OutputKind;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Global registry for managing plugin actions and quick actions.
|
|
1246
|
+
* Uses singleton pattern to ensure a single source of truth across the application.
|
|
1247
|
+
*/
|
|
1248
|
+
export declare class ActionRegistry {
|
|
1249
|
+
/** Map storing all registered actions by their ID */
|
|
1250
|
+
private actions;
|
|
1251
|
+
/** Map storing subscribers with their filters (null = subscribe to all) */
|
|
1252
|
+
private subscribers;
|
|
1253
|
+
private constructor();
|
|
1254
|
+
/**
|
|
1255
|
+
* Gets the singleton instance of the ActionRegistry.
|
|
1256
|
+
* Uses global object storage to ensure singleton across different bundle contexts.
|
|
1257
|
+
* @returns The ActionRegistry instance
|
|
1258
|
+
*/
|
|
1259
|
+
static get(): ActionRegistry;
|
|
1260
|
+
/**
|
|
1261
|
+
* Registers an action in the registry.
|
|
1262
|
+
* @param action The action definition to register
|
|
1263
|
+
* @returns A disposer function that unregisters the action when called
|
|
1264
|
+
*/
|
|
1265
|
+
register(action: ActionDefinition): () => void;
|
|
1266
|
+
/**
|
|
1267
|
+
* Gets all registered actions.
|
|
1268
|
+
* @returns Array of all action definitions
|
|
1269
|
+
*/
|
|
1270
|
+
getAll(): ActionDefinition[];
|
|
1271
|
+
/**
|
|
1272
|
+
* Gets actions matching the specified filters with full type safety.
|
|
1273
|
+
* @param filters Object containing optional filters for type, pluginId, and id
|
|
1274
|
+
* @returns Array of matching actions, typed based on the type filter
|
|
1275
|
+
* @example
|
|
1276
|
+
* // Get all plugin actions
|
|
1277
|
+
* registry.getBy({ type: 'plugin' }) // Returns PluginActionDefinition[]
|
|
1278
|
+
*
|
|
1279
|
+
* // Get all actions from a specific plugin
|
|
1280
|
+
* registry.getBy({ pluginId: 'ai-image-generation' }) // Returns ActionDefinition[]
|
|
1281
|
+
*
|
|
1282
|
+
* // Get specific action by ID
|
|
1283
|
+
* registry.getBy({ id: 'generate-image' }) // Returns ActionDefinition[]
|
|
1284
|
+
*
|
|
1285
|
+
* // Combine filters
|
|
1286
|
+
* registry.getBy({ type: 'quick', pluginId: 'ai-text' }) // Returns QuickActionDefinition[]
|
|
1287
|
+
*
|
|
1288
|
+
* // Filter quick actions by kind
|
|
1289
|
+
* registry.getBy({ type: 'quick', kind: 'image' }) // Returns QuickActionDefinition[]
|
|
1290
|
+
*/
|
|
1291
|
+
getBy<T extends ActionDefinition['type'] | undefined = undefined>(filters: {
|
|
1292
|
+
/** Filter by action type */
|
|
1293
|
+
type?: T;
|
|
1294
|
+
/** Filter by plugin ID */
|
|
1295
|
+
pluginId?: string;
|
|
1296
|
+
/** Filter by action ID */
|
|
1297
|
+
id?: string;
|
|
1298
|
+
/** Filter by kind (only applicable for quick actions) */
|
|
1299
|
+
kind?: OutputKind;
|
|
1300
|
+
}): T extends ActionDefinition['type'] ? Extract<ActionDefinition, {
|
|
1301
|
+
type: T;
|
|
1302
|
+
}>[] : ActionDefinition[];
|
|
1303
|
+
/**
|
|
1304
|
+
* Subscribes to all registry events (register/unregister).
|
|
1305
|
+
* @param callback Function to call when any action is registered or unregistered
|
|
1306
|
+
* @returns Unsubscribe function
|
|
1307
|
+
*/
|
|
1308
|
+
subscribe(callback: ActionRegistrySubscriberCallback): () => void;
|
|
1309
|
+
/**
|
|
1310
|
+
* Subscribes to registry events for actions matching the specified filters.
|
|
1311
|
+
* @param filters Filters to match actions against
|
|
1312
|
+
* @param callback Function to call when matching actions are registered or unregistered
|
|
1313
|
+
* @returns Unsubscribe function
|
|
1314
|
+
* @example
|
|
1315
|
+
* // Subscribe to plugin actions only
|
|
1316
|
+
* registry.subscribeBy({ type: 'plugin' }, (action, event) => {
|
|
1317
|
+
* console.log(`Plugin action ${action.id} was ${event}`);
|
|
1318
|
+
* });
|
|
1319
|
+
*
|
|
1320
|
+
* // Subscribe to actions from specific plugin
|
|
1321
|
+
* registry.subscribeBy({ pluginId: 'ai-image' }, (action, event) => {
|
|
1322
|
+
* updateUIForPlugin(action, event);
|
|
1323
|
+
* });
|
|
1324
|
+
*/
|
|
1325
|
+
subscribeBy(filters: ActionRegistryFilters, callback: ActionRegistrySubscriberCallback): () => void;
|
|
1326
|
+
/**
|
|
1327
|
+
* Notifies all relevant subscribers about an action event.
|
|
1328
|
+
* @param action The action that was registered or unregistered
|
|
1329
|
+
* @param event The type of event that occurred
|
|
1330
|
+
*/
|
|
1331
|
+
private notifySubscribers;
|
|
1332
|
+
/**
|
|
1333
|
+
* Checks if an action matches the given filters.
|
|
1334
|
+
* Used by both getBy() and subscribeBy() methods.
|
|
1335
|
+
* @param action The action to check
|
|
1336
|
+
* @param filters The filters to match against
|
|
1337
|
+
* @returns True if the action matches all filters
|
|
1338
|
+
*/
|
|
1339
|
+
private matchesFilters;
|
|
1340
|
+
}
|
|
1341
|
+
type ProviderInitializationResult<K extends OutputKind, I, O extends Output> = {
|
|
1342
|
+
provider: Provider<K, I, O>;
|
|
1343
|
+
panel: {
|
|
1344
|
+
builderRenderFunction?: BuilderRenderFunction;
|
|
1345
|
+
};
|
|
1346
|
+
history: {
|
|
1347
|
+
assetSourceId?: string;
|
|
1348
|
+
assetLibraryEntryId?: string;
|
|
1349
|
+
};
|
|
1350
|
+
generate: Generate<I, O>;
|
|
1351
|
+
};
|
|
1352
|
+
/**
|
|
1353
|
+
* Initializes a provider with the given configuration and options.
|
|
1354
|
+
*/
|
|
1355
|
+
declare function initializeProvider<K extends OutputKind, I, O extends Output>(_kind: K, provider: Provider<K, I, O>, options: {
|
|
1356
|
+
cesdk: CreativeEditorSDK;
|
|
1357
|
+
}, config: CommonPluginConfiguration<K, I, O>): Promise<ProviderInitializationResult<K, I, O>>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Global registry for managing AI generation providers across all plugins.
|
|
1360
|
+
* Uses singleton pattern to ensure cross-plugin provider discovery.
|
|
1361
|
+
*/
|
|
1362
|
+
export declare class ProviderRegistry {
|
|
1363
|
+
/** Map storing all registered providers by their ID */
|
|
1364
|
+
private providers;
|
|
1365
|
+
private constructor();
|
|
1366
|
+
/**
|
|
1367
|
+
* Gets the singleton instance of the ProviderRegistry.
|
|
1368
|
+
* Uses global object storage to ensure singleton across different bundle contexts.
|
|
1369
|
+
* @returns The ProviderRegistry instance
|
|
1370
|
+
*/
|
|
1371
|
+
static get(): ProviderRegistry;
|
|
1372
|
+
/**
|
|
1373
|
+
* Registers a provider in the registry.
|
|
1374
|
+
* @param providerInitializationResult The provider to register
|
|
1375
|
+
* @returns A disposer function that unregisters the provider when called
|
|
1376
|
+
*/
|
|
1377
|
+
register(providerInitializationResult: ProviderInitializationResult<any, any, any>): () => void;
|
|
1378
|
+
/**
|
|
1379
|
+
* Gets all registered providers.
|
|
1380
|
+
* @returns Array of all provider instances
|
|
1381
|
+
*/
|
|
1382
|
+
getAll(): ProviderInitializationResult<any, any, any>[];
|
|
1383
|
+
/**
|
|
1384
|
+
* Gets a provider by its ID.
|
|
1385
|
+
* @param id The provider ID to look up
|
|
1386
|
+
* @returns The provider instance or undefined if not found
|
|
1387
|
+
*/
|
|
1388
|
+
getById(id: string): ProviderInitializationResult<any, any, any> | undefined;
|
|
1389
|
+
/**
|
|
1390
|
+
* Gets all providers of a specific kind.
|
|
1391
|
+
* @param kind The output kind to filter by
|
|
1392
|
+
* @returns Array of providers matching the specified kind
|
|
1393
|
+
*/
|
|
1394
|
+
getByKind<K extends OutputKind>(kind: K): ProviderInitializationResult<K, any, any>[];
|
|
1395
|
+
}
|
|
1396
|
+
declare function loggingMiddleware<I, O extends Output>({ enable }: {
|
|
1397
|
+
enable: boolean | undefined;
|
|
1398
|
+
}): Middleware<I, O>;
|
|
1399
|
+
/**
|
|
1400
|
+
* Middleware to upload the output of a generation process.
|
|
1401
|
+
*
|
|
1402
|
+
* Sometimes it is not possible to use the result of a provider or
|
|
1403
|
+
* not even allowed to use it directly. This middleware allows you to upload
|
|
1404
|
+
* the result of a generation process to a server or a cloud storage.
|
|
1405
|
+
*
|
|
1406
|
+
* @param upload The function to upload the output. It should return a promise
|
|
1407
|
+
*/
|
|
1408
|
+
declare function uploadMiddleware<I, O extends Output>(upload: (output: O) => Promise<O>): Middleware<I, O>;
|
|
1409
|
+
/**
|
|
1410
|
+
* Merge quick actions configuration by combining provider defaults with user configuration overrides
|
|
1411
|
+
*
|
|
1412
|
+
* @param providerDefaults - The default quick actions from the provider
|
|
1413
|
+
* @param userConfig - The user's configuration overrides
|
|
1414
|
+
* @returns Merged quick actions configuration
|
|
1415
|
+
*/
|
|
1416
|
+
export declare function mergeQuickActionsConfig<T extends Record<string, any>>(providerDefaults: T, userConfig?: {
|
|
1417
|
+
[quickActionId: string]: any | false | null;
|
|
1418
|
+
}): T;
|
|
1419
|
+
interface RateLimitOptions<I> {
|
|
1420
|
+
/**
|
|
1421
|
+
* Maximum number of requests allowed in the time window
|
|
1422
|
+
*/
|
|
1423
|
+
maxRequests: number;
|
|
1424
|
+
/**
|
|
1425
|
+
* Time window in milliseconds
|
|
1426
|
+
*/
|
|
1427
|
+
timeWindowMs: number;
|
|
1428
|
+
/**
|
|
1429
|
+
* Optional key function or string to create different rate limits for different inputs
|
|
1430
|
+
* - If not provided, all requests share the same 'global' rate limit
|
|
1431
|
+
* - If a string is provided, that string is used as a static key
|
|
1432
|
+
* - If a function is provided, it generates a key based on input and options
|
|
1433
|
+
*/
|
|
1434
|
+
keyFn?: string | ((input: I, options: GenerationOptions) => string);
|
|
1435
|
+
/**
|
|
1436
|
+
* Callback function that is called when rate limit is exceeded
|
|
1437
|
+
* Return value determines if the operation should be rejected (throw error) or allowed
|
|
1438
|
+
* If true is returned, the operation will proceed despite exceeding the rate limit
|
|
1439
|
+
* If false or undefined is returned, the operation will be rejected with a default error
|
|
1440
|
+
*/
|
|
1441
|
+
onRateLimitExceeded?: (input: I, options: GenerationOptions, rateLimitInfo: {
|
|
1442
|
+
key: string;
|
|
1443
|
+
currentCount: number;
|
|
1444
|
+
maxRequests: number;
|
|
1445
|
+
timeWindowMs: number;
|
|
1446
|
+
remainingTimeMs: number;
|
|
1447
|
+
}) => boolean | Promise<boolean> | void;
|
|
1448
|
+
/**
|
|
1449
|
+
* Optional database name for the IndexedDB store
|
|
1450
|
+
* If not provided, a default name will be used
|
|
1451
|
+
*/
|
|
1452
|
+
dbName?: string;
|
|
1453
|
+
/**
|
|
1454
|
+
* Disable the rate limit middleware
|
|
1455
|
+
*/
|
|
1456
|
+
disable?: boolean | (() => boolean);
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Middleware that implements rate limiting for AI generation requests
|
|
1460
|
+
* Uses IndexedDB for storage when available, with in-memory fallback
|
|
1461
|
+
* Each middleware instance has its own isolated set of rate limits
|
|
1462
|
+
*/
|
|
1463
|
+
declare function rateLimitMiddleware<I, O extends Output>(middlewareOptions: RateLimitOptions<I>): Middleware<I, O>;
|
|
1464
|
+
/**
|
|
1465
|
+
* Returns a consistent panel ID for a provider ID
|
|
1466
|
+
*/
|
|
1467
|
+
export declare function getPanelId(providerId: string): string;
|
|
1468
|
+
/**
|
|
1469
|
+
* Gets the duration of a video from a URL
|
|
1470
|
+
* @param url - The URL of the video
|
|
1471
|
+
* @returns A promise that resolves to the duration of the video in seconds
|
|
1472
|
+
*/
|
|
1473
|
+
export declare function getDurationForVideo(url: string): Promise<number>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Gets a thumbnail image from a video URL
|
|
1476
|
+
* @param url - The URL of the video
|
|
1477
|
+
* @param seekTime - Time in seconds to capture the thumbnail (default: 0)
|
|
1478
|
+
* @param format - Image format for the thumbnail (default: 'image/jpeg')
|
|
1479
|
+
* @param quality - Image quality between 0 and 1 (default: 0.8)
|
|
1480
|
+
* @returns A promise that resolves to the thumbnail data URL
|
|
1481
|
+
*/
|
|
1482
|
+
export declare function getThumbnailForVideo(url: string, seekTime?: number, format?: string, quality?: number): Promise<string>;
|
|
1483
|
+
/**
|
|
1484
|
+
* Converts an ID string to a human-readable label
|
|
1485
|
+
* @param id - The ID string to convert
|
|
1486
|
+
* @returns A human-readable label derived from the ID
|
|
1487
|
+
*
|
|
1488
|
+
* Examples:
|
|
1489
|
+
* - snake_case_id → Snake Case Id
|
|
1490
|
+
* - kebab-case-id → Kebab Case Id
|
|
1491
|
+
* - camelCaseId → Camel Case Id
|
|
1492
|
+
* - PascalCaseId → Pascal Case Id
|
|
1493
|
+
*/
|
|
1494
|
+
export declare function getLabelFromId(id: string): string;
|
|
1495
|
+
/**
|
|
1496
|
+
* Type guard to check if a value is an AsyncGenerator rather than a Promise
|
|
1497
|
+
*
|
|
1498
|
+
* @param value - Value of type Promise<O> | AsyncGenerator<O, C>
|
|
1499
|
+
* @returns Boolean indicating if the value is an AsyncGenerator
|
|
1500
|
+
*/
|
|
1501
|
+
export declare function isAsyncGenerator<O extends Output, C>(value: GenerationResult<O, C>): value is AsyncGenerator<O, C>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Adds an icon set to the CreativeEditorSDK UI only once. Marks
|
|
1504
|
+
* it as added in the global state to prevent multiple additions.
|
|
1505
|
+
*/
|
|
1506
|
+
export declare function addIconSetOnce(cesdk: CreativeEditorSDK, id: string, icons: string): void;
|
|
1507
|
+
/**
|
|
1508
|
+
* Normalizes a base URL to ensure it has exactly one trailing slash.
|
|
1509
|
+
*
|
|
1510
|
+
* @param url - The base URL to normalize
|
|
1511
|
+
* @returns The normalized URL with exactly one trailing slash
|
|
1512
|
+
*
|
|
1513
|
+
* @example
|
|
1514
|
+
* normalizeBaseURL('https://example.com') // 'https://example.com/'
|
|
1515
|
+
* normalizeBaseURL('https://example.com/') // 'https://example.com/'
|
|
1516
|
+
* normalizeBaseURL('https://example.com//') // 'https://example.com/'
|
|
1517
|
+
*/
|
|
1518
|
+
export declare function normalizeBaseURL(url: string): string;
|
|
1519
|
+
/**
|
|
1520
|
+
* Checks if the current AI plugin version matches the shared version across all AI plugins.
|
|
1521
|
+
* Issues a console warning if versions don't match.
|
|
1522
|
+
*
|
|
1523
|
+
* @param cesdk - The CreativeEditorSDK instance
|
|
1524
|
+
* @param pluginId - The ID of the current plugin
|
|
1525
|
+
* @param currentVersion - The version of the current plugin
|
|
1526
|
+
*/
|
|
1527
|
+
export declare function checkAiPluginVersion(cesdk: CreativeEditorSDK, pluginId: string, currentVersion: string): void;
|
|
1528
|
+
/**
|
|
1529
|
+
* Registers a dock component for AI generation that opens
|
|
1530
|
+
* the AI generation panel and closes any other AI panels.
|
|
1531
|
+
*/
|
|
1532
|
+
declare function registerDockComponent(options: {
|
|
1533
|
+
cesdk: CreativeEditorSDK;
|
|
1534
|
+
panelId: string;
|
|
1535
|
+
}): void;
|
|
1536
|
+
/**
|
|
1537
|
+
* Enable function for a single image fill block selected.
|
|
1538
|
+
*/
|
|
1539
|
+
declare function enableImageFill(): ({ engine }: {
|
|
1540
|
+
engine: CreativeEngine$1;
|
|
1541
|
+
}) => boolean;
|
|
1542
|
+
export declare function isGeneratingStateKey(providerId: string): string;
|
|
1543
|
+
export declare function abortGenerationStateKey(providerId: string): string;
|
|
1544
|
+
type ProvidersInitializationResult<K extends OutputKind, I, O extends Output> = {
|
|
1545
|
+
/**
|
|
1546
|
+
* Combined panel render function for all providers.
|
|
1547
|
+
*/
|
|
1548
|
+
panel: {
|
|
1549
|
+
builderRenderFunction?: BuilderRenderFunction;
|
|
1550
|
+
};
|
|
1551
|
+
/**
|
|
1552
|
+
* Combined history asset source and library entry IDs for the providers.
|
|
1553
|
+
*/
|
|
1554
|
+
history?: {
|
|
1555
|
+
assetSourceId?: string;
|
|
1556
|
+
assetLibraryEntryId?: string;
|
|
1557
|
+
};
|
|
1558
|
+
/**
|
|
1559
|
+
* All individual initialization results of the providers, i.e.
|
|
1560
|
+
* the result of `initializeProvider` for every provider.
|
|
1561
|
+
*/
|
|
1562
|
+
providerInitializationResults: ProviderInitializationResult<K, I, O>[];
|
|
1563
|
+
};
|
|
1564
|
+
/**
|
|
1565
|
+
* Initializes the given providers for the specified output kind.
|
|
1566
|
+
*
|
|
1567
|
+
* - It will create a combined render function for all providers
|
|
1568
|
+
* that can be used in a panel
|
|
1569
|
+
*
|
|
1570
|
+
*/
|
|
1571
|
+
declare function initializeProviders<K extends OutputKind, I, O extends Output>(kind: K, providers: {
|
|
1572
|
+
fromText: Provider<K, I, O>[];
|
|
1573
|
+
fromImage: Provider<K, I, O>[];
|
|
1574
|
+
} | Provider<K, I, O>[], options: {
|
|
1575
|
+
cesdk: CreativeEditorSDK;
|
|
1576
|
+
}, config: CommonPluginConfiguration<K, I, O>): Promise<ProvidersInitializationResult<K, I, O>>;
|
|
1577
|
+
declare function initializeQuickActionComponents<K extends OutputKind, I, O extends Output>(context: {
|
|
1578
|
+
kind: K;
|
|
1579
|
+
providerInitializationResults: ProviderInitializationResult<K, I, O>[];
|
|
1580
|
+
cesdk: CreativeEditorSDK;
|
|
1581
|
+
engine: CreativeEngine;
|
|
1582
|
+
debug?: boolean;
|
|
1583
|
+
dryRun?: boolean;
|
|
1584
|
+
defaultOrder?: string[];
|
|
1585
|
+
}): Promise<{
|
|
1586
|
+
renderFunction: BuilderRenderFunction<any>;
|
|
1587
|
+
}>;
|
|
1588
|
+
/**
|
|
1589
|
+
* Extracts translations from OpenAPI schema properties and sets them via cesdk.i18n
|
|
1590
|
+
* This includes:
|
|
1591
|
+
* - Schema property titles as `ly.img.plugin-ai-${kind}-generation-web.${provider.id}.defaults.property.${property.id}`
|
|
1592
|
+
* - Enum value labels as `ly.img.plugin-ai-${kind}-generation-web.${provider.id}.defaults.property.${property.id}.${valueId}`
|
|
1593
|
+
* - AnyOf enum value labels with the same pattern
|
|
1594
|
+
*/
|
|
1595
|
+
export declare function extractAndSetSchemaTranslations<K extends OutputKind, I, O extends Output>(properties: Property[], provider: Provider<K, I, O>, options: UIOptions, kind: K): void;
|
|
1596
|
+
export declare const AI_EDIT_MODE = "ly.img.ai.editMode";
|
|
1597
|
+
export declare const AI_METADATA_KEY = "ly.img.ai.metadata";
|
|
1598
|
+
interface GatewayClient {
|
|
1599
|
+
fetchSchema: (modelId: string) => Promise<GatewaySchemaResult>;
|
|
1600
|
+
upload: (data: Blob, contentType: string) => Promise<GatewayUploadResult>;
|
|
1601
|
+
/**
|
|
1602
|
+
* URL-based generation (image, video, audio).
|
|
1603
|
+
* Waits for `generation.completed` and returns the output URL.
|
|
1604
|
+
*/
|
|
1605
|
+
generate: (modelId: string, input: Record<string, unknown>, options: {
|
|
1606
|
+
abortSignal?: AbortSignal;
|
|
1607
|
+
outputFilter?: (output: GatewaySSEOutput) => boolean;
|
|
1608
|
+
}) => Promise<string>;
|
|
1609
|
+
/**
|
|
1610
|
+
* Streaming text generation.
|
|
1611
|
+
* Yields accumulated text on each `generation.delta` event.
|
|
1612
|
+
* Returns the final accumulated text on `generation.completed`.
|
|
1613
|
+
*/
|
|
1614
|
+
generateStream: (modelId: string, input: Record<string, unknown>, options: {
|
|
1615
|
+
abortSignal?: AbortSignal;
|
|
1616
|
+
}) => AsyncGenerator<string, string>;
|
|
1617
|
+
}
|
|
1618
|
+
export declare function createGatewayClient(gatewayUrl: string, getToken: () => Promise<string>, headers?: Record<string, string>, tokenCacheTTLMs?: number): GatewayClient;
|
|
1619
|
+
interface GatewayProviderConfiguration {
|
|
1620
|
+
/**
|
|
1621
|
+
* Base URL of the gateway service.
|
|
1622
|
+
*
|
|
1623
|
+
* @default 'https://gateway.img.ly'
|
|
1624
|
+
*/
|
|
1625
|
+
gatewayUrl?: string;
|
|
1626
|
+
/**
|
|
1627
|
+
* Human-readable display name for this model. Overrides the name
|
|
1628
|
+
* returned by the gateway schema. When omitted, the provider uses
|
|
1629
|
+
* `schema.name` once the schema resolves, falling back to `modelId`
|
|
1630
|
+
* in the brief window before the schema is available.
|
|
1631
|
+
*/
|
|
1632
|
+
modelName?: string;
|
|
1633
|
+
/**
|
|
1634
|
+
* The action ID used to retrieve an auth token via `cesdk.ui.actions.run()`.
|
|
1635
|
+
* The registered action should return a token string.
|
|
1636
|
+
*
|
|
1637
|
+
* @default 'ly.img.ai.getToken'
|
|
1638
|
+
*/
|
|
1639
|
+
tokenActionId?: string;
|
|
1640
|
+
/**
|
|
1641
|
+
* Additional headers to send with gateway requests.
|
|
1642
|
+
*/
|
|
1643
|
+
headers?: Record<string, string>;
|
|
1644
|
+
/**
|
|
1645
|
+
* History storage strategy for generated assets.
|
|
1646
|
+
*
|
|
1647
|
+
* @default '@imgly/indexedDB'
|
|
1648
|
+
*/
|
|
1649
|
+
history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
|
|
1650
|
+
/**
|
|
1651
|
+
* Called when an error occurs during schema loading or provider initialization.
|
|
1652
|
+
* Generation errors are handled separately via middleware.
|
|
1653
|
+
*/
|
|
1654
|
+
onError?: (error: Error) => void;
|
|
1655
|
+
/**
|
|
1656
|
+
* Middlewares to add to the provider generation. Middlewares run around the
|
|
1657
|
+
* base `generate` call and can observe/modify input, retry on failure, add
|
|
1658
|
+
* logging, rate limiting, etc.
|
|
1659
|
+
*/
|
|
1660
|
+
middlewares?: Middleware<any, any>[];
|
|
1661
|
+
/**
|
|
1662
|
+
* How long (in milliseconds) to cache auth tokens before re-fetching.
|
|
1663
|
+
* Concurrent requests while a fetch is in-flight share the same call.
|
|
1664
|
+
*
|
|
1665
|
+
* @default 300000 (5 minutes)
|
|
1666
|
+
*/
|
|
1667
|
+
tokenCacheTTL?: number;
|
|
1668
|
+
/**
|
|
1669
|
+
* Override or disable individual quick actions on top of the provider's
|
|
1670
|
+
* capability-derived defaults.
|
|
1671
|
+
*
|
|
1672
|
+
* - Set a quick-action ID to `false` (or `null`) to disable it for this provider.
|
|
1673
|
+
* - Set it to an object with `mapInput` to override how the quick action's
|
|
1674
|
+
* input is mapped to the provider's input.
|
|
1675
|
+
*
|
|
1676
|
+
* @example
|
|
1677
|
+
* ```ts
|
|
1678
|
+
* ImageGatewayProvider('fal-ai/some-model', {
|
|
1679
|
+
* gatewayUrl,
|
|
1680
|
+
* supportedQuickActions: {
|
|
1681
|
+
* 'ly.img.editImage': false, // disable
|
|
1682
|
+
* 'ly.img.swapBackground': { // override mapping
|
|
1683
|
+
* mapInput: (input) => ({ prompt: input.prompt, image_urls: [input.uri] })
|
|
1684
|
+
* }
|
|
1685
|
+
* }
|
|
1686
|
+
* })
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
supportedQuickActions?: {
|
|
1690
|
+
[quickActionId: string]: {
|
|
1691
|
+
mapInput: (input: any) => GatewayInput;
|
|
1692
|
+
} | {
|
|
1693
|
+
[key: string]: any;
|
|
1694
|
+
} | true | false | null;
|
|
1695
|
+
};
|
|
1696
|
+
/**
|
|
1697
|
+
* Enable debug logging.
|
|
1698
|
+
*/
|
|
1699
|
+
debug?: boolean;
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Return type for the gateway token action.
|
|
1703
|
+
*
|
|
1704
|
+
* - Return a **string** for short-lived credentials (JWT, Clerk token, session token).
|
|
1705
|
+
* - Return `{ dangerouslyExposeApiKey: string }` if you intentionally want to use
|
|
1706
|
+
* a raw API key. This exposes the key to anyone with browser DevTools access.
|
|
1707
|
+
*/
|
|
1708
|
+
type GatewayTokenActionResult = string | {
|
|
1709
|
+
dangerouslyExposeApiKey: string;
|
|
1710
|
+
};
|
|
1711
|
+
type GatewayInput = Record<string, any>;
|
|
1712
|
+
interface GatewayProviderOptions<K extends OutputKind, O extends Output> {
|
|
1713
|
+
/** The output kind (e.g., 'image', 'video', 'audio', 'text'). */
|
|
1714
|
+
kind: K;
|
|
1715
|
+
/**
|
|
1716
|
+
* Called once when the provider initializes (e.g., to register icons).
|
|
1717
|
+
*/
|
|
1718
|
+
onInitialize?: (cesdk: CreativeEditorSDK) => void;
|
|
1719
|
+
/**
|
|
1720
|
+
* Called after the schema resolves. Return a `renderCustomProperty` map
|
|
1721
|
+
* to customize how specific schema properties are rendered in the panel.
|
|
1722
|
+
*
|
|
1723
|
+
* Only called when a schema-driven panel is used (i.e., `createOutput` is provided).
|
|
1724
|
+
*/
|
|
1725
|
+
onSchemaReady?: (context: {
|
|
1726
|
+
schema: GatewaySchemaResult;
|
|
1727
|
+
providerId: string;
|
|
1728
|
+
cesdk: CreativeEditorSDK;
|
|
1729
|
+
}) => RenderCustomProperty | undefined;
|
|
1730
|
+
/**
|
|
1731
|
+
* Preprocess input before generation (e.g., upload local blob: URLs).
|
|
1732
|
+
* If omitted, input is forwarded to the gateway as-is.
|
|
1733
|
+
*/
|
|
1734
|
+
processInput?: (input: GatewayInput, client: GatewayClient, cesdk: CreativeEditorSDK) => Promise<GatewayInput>;
|
|
1735
|
+
/**
|
|
1736
|
+
* Construct the typed output from a generated URL.
|
|
1737
|
+
* Used for URL-based outputs (image, video, audio).
|
|
1738
|
+
*
|
|
1739
|
+
* When provided, a schema-driven panel is set up and `getBlockInput` is required.
|
|
1740
|
+
* Mutually exclusive with `createStreamOutput`.
|
|
1741
|
+
*/
|
|
1742
|
+
createOutput?: (url: string) => O | Promise<O>;
|
|
1743
|
+
/**
|
|
1744
|
+
* Construct the typed output from accumulated streamed text.
|
|
1745
|
+
* Used for streaming outputs (text).
|
|
1746
|
+
*
|
|
1747
|
+
* When provided, no schema panel is created — use `quickActions` for input.
|
|
1748
|
+
* Mutually exclusive with `createOutput`.
|
|
1749
|
+
*/
|
|
1750
|
+
createStreamOutput?: (accumulatedText: string) => O;
|
|
1751
|
+
/**
|
|
1752
|
+
* Extract block input from user input (for placeholder creation).
|
|
1753
|
+
* Required when `createOutput` is provided (panel mode).
|
|
1754
|
+
*/
|
|
1755
|
+
getBlockInput?: (input: GatewayInput) => Promise<Record<K, any>>;
|
|
1756
|
+
/**
|
|
1757
|
+
* Filter the SSE output array to find the relevant result.
|
|
1758
|
+
* If omitted, the first output entry is used.
|
|
1759
|
+
* Only used in URL mode (`createOutput`).
|
|
1760
|
+
*/
|
|
1761
|
+
outputFilter?: (output: GatewaySSEOutput) => boolean;
|
|
1762
|
+
/**
|
|
1763
|
+
* Returns the default quick actions for this model based on its schema
|
|
1764
|
+
* (specifically `schema.capability`). Called once after the schema
|
|
1765
|
+
* resolves; the result is merged with any `supportedQuickActions`
|
|
1766
|
+
* overrides from the provider configuration.
|
|
1767
|
+
*
|
|
1768
|
+
* Return `undefined` when the model has no quick actions (e.g. a pure
|
|
1769
|
+
* text2image model).
|
|
1770
|
+
*/
|
|
1771
|
+
resolveQuickActions?: (context: {
|
|
1772
|
+
schema: GatewaySchemaResult;
|
|
1773
|
+
providerId: string;
|
|
1774
|
+
cesdk: CreativeEditorSDK;
|
|
1775
|
+
}) => QuickActionsInput<GatewayInput> | undefined;
|
|
1776
|
+
/**
|
|
1777
|
+
* Unconditional quick actions for this provider. Used by content types
|
|
1778
|
+
* with a single capability (e.g., text generation where every model
|
|
1779
|
+
* accepts the same chat-style input). Mutually exclusive with
|
|
1780
|
+
* `resolveQuickActions`.
|
|
1781
|
+
*/
|
|
1782
|
+
quickActions?: QuickActionsInput<GatewayInput>;
|
|
1783
|
+
/**
|
|
1784
|
+
* Panel user flow.
|
|
1785
|
+
* @default 'placeholder'
|
|
1786
|
+
*/
|
|
1787
|
+
userFlow?: 'placeholder' | 'generation-only';
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Known gateway capabilities. Unknown string values are allowed for
|
|
1791
|
+
* forward compatibility with capabilities added on the server side
|
|
1792
|
+
* before the client is updated.
|
|
1793
|
+
*/
|
|
1794
|
+
type GatewayCapability = 'text2text' | 'text2image' | 'image2image' | 'text2video' | 'image2video' | 'text2speech' | (string & {});
|
|
1795
|
+
interface GatewaySchemaResult {
|
|
1796
|
+
model: string;
|
|
1797
|
+
name?: string;
|
|
1798
|
+
type: string;
|
|
1799
|
+
/**
|
|
1800
|
+
* The model's capability (e.g., 'image2image'). Used by the gateway
|
|
1801
|
+
* providers to decide which default quick actions to offer.
|
|
1802
|
+
*/
|
|
1803
|
+
capability: GatewayCapability;
|
|
1804
|
+
input_schema: {
|
|
1805
|
+
type: 'object';
|
|
1806
|
+
required: string[];
|
|
1807
|
+
properties: Record<string, unknown>;
|
|
1808
|
+
'x-property-order'?: string[];
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
interface GatewaySSEOutput {
|
|
1812
|
+
type: string;
|
|
1813
|
+
url: string;
|
|
1814
|
+
content_type: string;
|
|
1815
|
+
}
|
|
1816
|
+
interface GatewaySSECompletedData {
|
|
1817
|
+
request_id: string;
|
|
1818
|
+
status: 'completed';
|
|
1819
|
+
output: GatewaySSEOutput[];
|
|
1820
|
+
}
|
|
1821
|
+
interface GatewaySSEFailedData {
|
|
1822
|
+
request_id: string;
|
|
1823
|
+
status: 'failed';
|
|
1824
|
+
error: {
|
|
1825
|
+
message: string;
|
|
1826
|
+
/**
|
|
1827
|
+
* Same catalog as the HTTP error envelope. Optional because the gateway does
|
|
1828
|
+
* not put it on every failed event yet — without it the client can report
|
|
1829
|
+
* that the generation failed, but not why.
|
|
1830
|
+
*/
|
|
1831
|
+
code?: string;
|
|
1832
|
+
/** Upstream model provider, for provider-originated failures. */
|
|
1833
|
+
provider?: string;
|
|
1834
|
+
/** Status the upstream provider returned. */
|
|
1835
|
+
upstream_status?: number;
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
interface GatewaySSEDeltaData {
|
|
1839
|
+
contentType: 'text' | 'tool_call';
|
|
1840
|
+
data: string;
|
|
1841
|
+
request_id: string;
|
|
1842
|
+
}
|
|
1843
|
+
interface GatewayUploadResult {
|
|
1844
|
+
id: string;
|
|
1845
|
+
upload_url: string;
|
|
1846
|
+
asset_url: string;
|
|
1847
|
+
expires_in: number;
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Creates a provider that talks to the IMG.LY gateway.
|
|
1851
|
+
*
|
|
1852
|
+
* This is the generic, content-type-agnostic factory. Content-type-specific
|
|
1853
|
+
* behavior (icons, input preprocessing, output filtering, block dimensions)
|
|
1854
|
+
* is injected via `GatewayProviderOptions`.
|
|
1855
|
+
*
|
|
1856
|
+
* The schema is fetched lazily in the background — the provider registers
|
|
1857
|
+
* immediately without blocking on the network request.
|
|
1858
|
+
*
|
|
1859
|
+
* Providers sharing the same `cesdk` instance and gateway URL automatically
|
|
1860
|
+
* share a single HTTP client and token cache.
|
|
1861
|
+
*
|
|
1862
|
+
* @param modelId - The model identifier (e.g., 'fal-ai/flux/dev')
|
|
1863
|
+
* @param config - Gateway connection configuration
|
|
1864
|
+
* @param options - Content-type-specific behavior
|
|
1865
|
+
*/
|
|
1866
|
+
export declare function createGatewayProvider<K extends OutputKind, O extends Output>(modelId: string, config: GatewayProviderConfiguration, options: GatewayProviderOptions<K, O>): (context: {
|
|
1867
|
+
cesdk: CreativeEditorSDK;
|
|
1868
|
+
}) => Promise<Provider<K, GatewayInput, O>>;
|
|
1869
|
+
/**
|
|
1870
|
+
* Typed representation of a failed IMG.LY gateway request.
|
|
1871
|
+
*
|
|
1872
|
+
* The gateway answers every failure with a single JSON envelope:
|
|
1873
|
+
*
|
|
1874
|
+
* ```json
|
|
1875
|
+
* { "error": { "code": "insufficient_credits", "message": "Insufficient credits" } }
|
|
1876
|
+
* ```
|
|
1877
|
+
*
|
|
1878
|
+
* Provider-originated failures add two more fields:
|
|
1879
|
+
*
|
|
1880
|
+
* ```json
|
|
1881
|
+
* { "error": { "code": "upstream_error", "message": "Rate limit exceeded",
|
|
1882
|
+
* "provider": "fal.ai", "upstream_status": 429 } }
|
|
1883
|
+
* ```
|
|
1884
|
+
*
|
|
1885
|
+
* This module turns that envelope into an `Error` subclass so callers can branch
|
|
1886
|
+
* on `code` instead of pattern-matching a message string.
|
|
1887
|
+
*/
|
|
1888
|
+
/**
|
|
1889
|
+
* Machine-readable failure reason reported by the gateway.
|
|
1890
|
+
*
|
|
1891
|
+
* The listed members mirror the gateway's own error catalog, but the type stays
|
|
1892
|
+
* open on purpose: the gateway may introduce codes before this package is
|
|
1893
|
+
* updated, and a closed union would silently mistype them.
|
|
1894
|
+
*
|
|
1895
|
+
* Two members are client-side sentinels rather than gateway codes: `'unknown'`
|
|
1896
|
+
* when no code could be determined (unparseable body, non-gateway origin such as
|
|
1897
|
+
* the presigned upload URL), and `'network_error'` when the request never
|
|
1898
|
+
* produced a readable response at all.
|
|
1899
|
+
*/
|
|
1900
|
+
type GatewayErrorCode = 'network_error' | 'insufficient_credits' | 'unauthorized' | 'provider_not_authorized' | 'invalid_request' | 'invalid_model_id' | 'validation_error' | 'provider_not_supported' | 'model_not_found' | 'provider_unavailable' | 'upstream_error' | 'generation_failed' | 'timeout' | 'internal_error' | 'service_error' | 'unknown' | (string & {});
|
|
1901
|
+
/** Which gateway interaction failed. */
|
|
1902
|
+
type GatewayOperation = 'schema' | 'upload' | 'generate';
|
|
1903
|
+
interface GatewayErrorInit {
|
|
1904
|
+
code: GatewayErrorCode;
|
|
1905
|
+
status: number;
|
|
1906
|
+
operation: GatewayOperation;
|
|
1907
|
+
/** Message reported by the gateway, used to build the developer-facing text. */
|
|
1908
|
+
detail?: string;
|
|
1909
|
+
provider?: string;
|
|
1910
|
+
upstreamStatus?: number;
|
|
1911
|
+
requestId?: string;
|
|
1912
|
+
}
|
|
1913
|
+
export declare class GatewayError extends Error {
|
|
1914
|
+
/** Machine-readable failure reason. Prefer this over parsing `message`. */
|
|
1915
|
+
readonly code: GatewayErrorCode;
|
|
1916
|
+
/**
|
|
1917
|
+
* HTTP status of the failed response. `0` when there is no status: a failure
|
|
1918
|
+
* reported inside an already-open SSE stream, or a request that never reached
|
|
1919
|
+
* the gateway (`network_error`).
|
|
1920
|
+
*/
|
|
1921
|
+
readonly status: number;
|
|
1922
|
+
/** Which gateway interaction failed. */
|
|
1923
|
+
readonly operation: GatewayOperation;
|
|
1924
|
+
/** Upstream model provider, present only for `upstream_error`. */
|
|
1925
|
+
readonly provider?: string;
|
|
1926
|
+
/** Status the upstream provider returned, present only for `upstream_error`. */
|
|
1927
|
+
readonly upstreamStatus?: number;
|
|
1928
|
+
/**
|
|
1929
|
+
* Gateway request id. Include this when reporting a problem to support.
|
|
1930
|
+
*
|
|
1931
|
+
* Only present when the gateway makes it reachable: `x-request-id` is not a
|
|
1932
|
+
* CORS-safelisted response header, so a cross-origin gateway must send
|
|
1933
|
+
* `Access-Control-Expose-Headers: x-request-id` for the header to be readable
|
|
1934
|
+
* — otherwise the id has to travel in the error body as `request_id`.
|
|
1935
|
+
*/
|
|
1936
|
+
readonly requestId?: string;
|
|
1937
|
+
constructor(init: GatewayErrorInit);
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Narrows an unknown thrown value to a `GatewayError`.
|
|
1941
|
+
*
|
|
1942
|
+
* Uses a structural check rather than `instanceof` so it keeps working when the
|
|
1943
|
+
* plugin packages are bundled separately and end up with distinct copies of this
|
|
1944
|
+
* module.
|
|
1945
|
+
*/
|
|
1946
|
+
export declare function isGatewayError(error: unknown): error is GatewayError;
|
|
1947
|
+
type TranslationDefinition = Partial<Record<string, Partial<Record<string, string>>>>;
|
|
1948
|
+
/**
|
|
1949
|
+
* Sets default translations only for keys that don't already exist.
|
|
1950
|
+
*
|
|
1951
|
+
* This allows integrators to set custom translations BEFORE plugins load,
|
|
1952
|
+
* and the plugins won't override those custom values with their defaults.
|
|
1953
|
+
*
|
|
1954
|
+
* @param cesdk - The CE.SDK instance
|
|
1955
|
+
* @param definition - The translations to set (same format as setTranslations)
|
|
1956
|
+
*
|
|
1957
|
+
* @example
|
|
1958
|
+
* ```ts
|
|
1959
|
+
* // Integrator sets custom translation BEFORE plugin loads
|
|
1960
|
+
* cesdk.i18n.setTranslations({ en: { 'my.key': 'Custom Value' } });
|
|
1961
|
+
*
|
|
1962
|
+
* // Plugin uses setDefaultTranslations - won't override 'my.key'
|
|
1963
|
+
* setDefaultTranslations(cesdk, { en: { 'my.key': 'Default Value', 'other.key': 'Other' } });
|
|
1964
|
+
*
|
|
1965
|
+
* // Result: 'my.key' = 'Custom Value', 'other.key' = 'Other'
|
|
1966
|
+
* ```
|
|
1967
|
+
*/
|
|
1968
|
+
export declare function setDefaultTranslations(cesdk: CreativeEditorSDK, definition: TranslationDefinition): void;
|
|
1969
|
+
/**
|
|
1970
|
+
* Creates a translation callback function for AI asset sources
|
|
1971
|
+
* @param cesdk - The CE.SDK instance
|
|
1972
|
+
* @param modelKey - The model/provider key (e.g., 'fal-ai/recraft-v3')
|
|
1973
|
+
* @param propertyName - The property name (e.g., 'style', 'aspect_ratio')
|
|
1974
|
+
* @param pluginType - The plugin type (e.g., 'image', 'video', 'sticker')
|
|
1975
|
+
* @returns A translation callback function for use with CustomAssetSource
|
|
1976
|
+
*/
|
|
1977
|
+
export declare function createTranslationCallback(cesdk: CreativeEditorSDK, modelKey: string, propertyName?: string, pluginType?: string): (assetId: string, fallbackLabel: string, locale: string) => string;
|
|
1978
|
+
/**
|
|
1979
|
+
* Build translation keys array for AI plugin property values
|
|
1980
|
+
* @param modelKey - The model/provider key
|
|
1981
|
+
* @param propertyName - The property name
|
|
1982
|
+
* @param value - The property value
|
|
1983
|
+
* @param pluginType - The plugin type (image, video, sticker, etc.)
|
|
1984
|
+
* @returns Array of translation keys in fallback order
|
|
1985
|
+
*/
|
|
1986
|
+
export declare function buildTranslationKeys(modelKey: string, propertyName: string, value: string, pluginType?: string): string[];
|
|
3
1987
|
declare const CommonProperties: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export { CommonProperties,
|
|
8
|
-
export { type default as Provider, type ImageOutput, type VideoOutput, type TextOutput, type AudioOutput, type StickerOutput, type Output, type OutputKind, type PanelInputSchema, type RenderCustomProperty, type GetBlockInput, type GetBlockInputResult, type GetInput, type QuickActionsInput } from './core/provider';
|
|
9
|
-
export { type GetPropertyInput, type Property } from './openapi/types';
|
|
10
|
-
export { type GetProvider, type CommonProviderConfiguration, type CommonPluginConfiguration, type CommonConfiguration, type InternalPluginConfiguration } from './types';
|
|
11
|
-
export type { PropertyContext, PropertyConfig, PropertiesConfiguration, ExtendPropertyContexts } from './core/propertyConfiguration';
|
|
12
|
-
export { buildPropertyContext, PropertyContextCache } from './utils/propertyContext';
|
|
13
|
-
export { resolvePropertyDefault, resolvePropertyDefaults } from './utils/propertyResolver';
|
|
14
|
-
export { default as integrateIntoDefaultAssetLibraryEntry } from './assets/integrateIntoDefaultAssetLibraryEntry';
|
|
15
|
-
export { ActionRegistry, type BaseActionDefinition, type PluginActionDefinition, type QuickActionDefinition, type ActionDefinition, type ActionRegistryEventType, type ActionRegistrySubscriberCallback, type ActionRegistryFilters } from './core/ActionRegistry';
|
|
16
|
-
export { ProviderRegistry } from './core/ProviderRegistry';
|
|
17
|
-
export { composeMiddlewares, type Middleware } from './middleware/middleware';
|
|
18
|
-
export { default as loggingMiddleware } from './middleware/loggingMiddleware';
|
|
19
|
-
export { default as uploadMiddleware } from './middleware/uploadMiddleware';
|
|
20
|
-
export { mergeQuickActionsConfig } from './utils/mergeQuickActionsConfig';
|
|
21
|
-
export { default as rateLimitMiddleware, type RateLimitOptions } from './middleware/rateLimitMiddleware';
|
|
22
|
-
export { getPanelId, getDurationForVideo, getThumbnailForVideo, getLabelFromId, isAsyncGenerator, addIconSetOnce, normalizeBaseURL } from './utils/utils';
|
|
23
|
-
export { checkAiPluginVersion } from './utils/checkAiPluginVersion';
|
|
24
|
-
export { default as registerDockComponent } from './ui/components/registerDockComponent';
|
|
25
|
-
export { default as enableQuickActionForImageFill } from './ui/quickActions/enableImageFill';
|
|
26
|
-
export { isGeneratingStateKey, abortGenerationStateKey } from './ui/components/renderGenerationComponents';
|
|
27
|
-
export { default as initializeProviders } from './providers/initializeProviders';
|
|
28
|
-
export { default as initializeProvider } from './providers/initializeProvider';
|
|
29
|
-
export { default as initializeQuickActionComponents } from './ui/quickActions/initializeQuickActionComponents';
|
|
30
|
-
export { extractAndSetSchemaTranslations } from './openapi/extractSchemaTranslations';
|
|
31
|
-
export { AI_EDIT_MODE, AI_METADATA_KEY } from './ui/quickActions/utils';
|
|
32
|
-
export { createGatewayProvider } from './gateway/createGatewayProvider';
|
|
33
|
-
export { createGatewayClient, type GatewayClient } from './gateway/createGatewayClient';
|
|
34
|
-
export { GatewayError, isGatewayError, type GatewayErrorCode, type GatewayOperation } from './gateway/GatewayError';
|
|
35
|
-
export type { GatewayProviderConfiguration, GatewayProviderOptions, GatewayInput, GatewaySchemaResult, GatewaySSEOutput, GatewaySSECompletedData, GatewaySSEDeltaData, GatewaySSEFailedData, GatewayUploadResult, GatewayTokenActionResult } from './gateway/types';
|
|
36
|
-
export { setDefaultTranslations, createTranslationCallback, buildTranslationKeys } from './utils/translationHelpers';
|
|
1988
|
+
ImageUrl: typeof renderImageUrlProperty;
|
|
1989
|
+
StyleTransfer: typeof renderStyleTransferProperty;
|
|
1990
|
+
};
|
|
1991
|
+
export { type ActionDefinition, type ActionRegistryEventType, type ActionRegistryFilters, type ActionRegistrySubscriberCallback, type AudioOutput, type BaseActionDefinition, type CommonConfiguration, type CommonPluginConfiguration, CommonProperties, type CommonProviderConfiguration, type ExtendPropertyContexts, type GatewayClient, type GatewayErrorCode, type GatewayInput, type GatewayOperation, type GatewayProviderConfiguration, type GatewayProviderOptions, type GatewaySSECompletedData, type GatewaySSEDeltaData, type GatewaySSEFailedData, type GatewaySSEOutput, type GatewaySchemaResult, type GatewayTokenActionResult, type GatewayUploadResult, type GetBlockInput, type GetBlockInputResult, type GetInput, type GetPropertyInput, type GetProvider, type ImageOutput, type InternalPluginConfiguration, type Middleware, type Output, type OutputKind, type PanelInputSchema, type PluginActionDefinition, type PropertiesConfiguration, type Property, type PropertyConfig, type PropertyContext, type Provider, type QuickActionDefinition, type QuickActionsInput, type RateLimitOptions, type RenderCustomProperty, type StickerOutput, type TextOutput, type VideoOutput, enableImageFill as enableQuickActionForImageFill, initializeProvider, initializeProviders, initializeQuickActionComponents, integrateIntoDefaultAssetLibraryEntry, loggingMiddleware, rateLimitMiddleware, registerDockComponent, uploadMiddleware };
|