@cesdk/engine 1.7.0-alpha.4 → 1.7.0-alpha.5

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/index.d.ts ADDED
@@ -0,0 +1,2360 @@
1
+ /// <reference types="offscreencanvas" />
2
+
3
+ /**
4
+ * Generic asset information
5
+ * @public
6
+ */
7
+ export declare interface Asset {
8
+ /**
9
+ * Is a combination of source id, extension pack id (optional), type and asset id
10
+ * e.g. "extension://ly.img.cesdk.images.samples/ly.img.image/sample.1"
11
+ */
12
+ id: string;
13
+ /** E.g. `ly.img.image` */
14
+ /** Groups of the asset. */
15
+ groups?: Groups;
16
+ /** URI to a thumbnail of the asset used e.g. in the content library UI */
17
+ thumbUri: string;
18
+
19
+ /** Asset-specific and custom meta information */
20
+ meta?: {
21
+ uri?: string;
22
+ filename?: string;
23
+ vectorPath?: string;
24
+ } & Record<string, unknown>;
25
+ }
26
+
27
+ /**
28
+ * @public
29
+ */
30
+ export declare class AssetAPI {
31
+ #private;
32
+
33
+ /**
34
+ * Adds a custom asset source. Its ID has to be unique.
35
+ * @param source - The asset source.
36
+ */
37
+ addSource(source: AssetSource): void;
38
+ /**
39
+ * Removes an asset source with the given ID.
40
+ * @param id - The ID to refer to the asset source.
41
+ */
42
+ removeSource(id: string): void;
43
+ /**
44
+ * Finds all registered asset sources.
45
+ * @returns A list with the IDs of all registered asset sources.
46
+ */
47
+ findAllSources(): string[];
48
+ /**
49
+ * Finds assets of a given type in a specific asset source.
50
+ * @param sourceId - The ID of the asset source.
51
+ * @param query - All the options to filter the search results by.
52
+ * @returns The search results.
53
+ */
54
+ findAssets(sourceId: string, query: AssetQueryData): Promise<AssetsQueryResult>;
55
+ /**
56
+ * Queries the asset source's groups for a certain asset type.
57
+ * @param id - The ID of the asset source.
58
+ * @returns The asset groups.
59
+ */
60
+ getGroups(id: string): Promise<string[]>;
61
+ /**
62
+ * Queries the asset source's credits info.
63
+ * @param sourceId - The ID of the asset source.
64
+ * @returns The asset source's credits info consisting of a name and an optional URL.
65
+ */
66
+ getCredits(sourceId: string): {
67
+ name: string;
68
+ url: string | undefined;
69
+ } | undefined;
70
+ /**
71
+ * Queries the asset source's license info.
72
+ * @param sourceId - The ID of the asset source.
73
+ * @returns The asset source's license info consisting of a name and an optional URL.
74
+ */
75
+ getLicense(sourceId: string): {
76
+ name: string;
77
+ url: string | undefined;
78
+ } | undefined;
79
+ canManageAssets(sourceId: string): boolean;
80
+ /**
81
+ * Apply an asset result to the active scene.
82
+ * The default behavior will instantiate a block and configure it according to the asset's properties.
83
+ * Note that this can be overridden by providing an `applyAsset` function when adding the asset source.
84
+ * @param sourceId - The ID of the asset source.
85
+ * @param assetResult - A single assetResult of a `findAssets` query.
86
+ */
87
+ apply(sourceId: string, assetResult: AssetResult): Promise<void>;
88
+ }
89
+
90
+ /**
91
+ * Definition of an assets used if an asset is added to an asset source.
92
+ * @public
93
+ */
94
+ export declare interface AssetDefinition extends Asset {
95
+ /**
96
+ * Label used to display in aria-label and as a tooltip.
97
+ * Will be also searched in a query and should be localized
98
+ */
99
+ label?: Record<Locale, string>;
100
+ /**
101
+ * Tags for this asset. Can be used for filtering, but is also useful for
102
+ * free-text search. Since the label is searched as well as used for tooltips
103
+ * you do not want to overdo it, but still add things which are searched.
104
+ * Thus, it should be localized similar to the `label`.
105
+ */
106
+ tags?: Record<Locale, string[]>;
107
+ }
108
+
109
+ /**
110
+ * Defines a request for querying assets
111
+ * @public
112
+ */
113
+ export declare interface AssetQueryData {
114
+ /** A query string used for (fuzzy) searching of labels and tags */
115
+ query?: string;
116
+ /** The current page queried for paginated views. */
117
+ page: number;
118
+ /**
119
+ * Tags are searched with the query parameter, but this search is fuzzy.
120
+ * If one needs to get assets with exactly the tag (from a tag cloud or filter)
121
+ * this query parameter should be used.
122
+ */
123
+ tags?: string | string[];
124
+ /** Query only these groups */
125
+ groups?: Groups;
126
+ /** Filter out assets with this groups */
127
+ excludeGroups?: Groups;
128
+ /** Choose the locale of the labels and tags for localized search and filtering */
129
+ locale?: Locale;
130
+ /**
131
+ * The number of results queried. How many assets shall be returned regardless
132
+ * of the total number of assets available.
133
+ *
134
+ * Together with `page` this can be used for pagination.
135
+ */
136
+ perPage: number;
137
+ }
138
+
139
+ /**
140
+ * Single asset result of a query from the engine.
141
+ * @public
142
+ */
143
+ export declare interface AssetResult extends Asset {
144
+ /** The locale of the label and tags */
145
+ locale?: Locale;
146
+ /** The label of the result. Used for description and tooltips. */
147
+ label?: string;
148
+ /** The tags of this asset. Used for filtering and free-text searching. */
149
+ tags?: string[];
150
+
151
+ /** Credits for the artist of the asset */
152
+ credits?: {
153
+ name: string;
154
+ url?: string;
155
+ };
156
+ /** License for this asset. Overwrites the source license if present */
157
+ license?: {
158
+ name: string;
159
+ url?: string;
160
+ };
161
+ /** UTM parameters for the links inside the credits */
162
+ utm?: {
163
+ source?: string;
164
+ medium?: string;
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Single asset result of a query from the engine.
170
+ * @public
171
+ */
172
+ declare interface AssetResult_2 {
173
+ /** A unique id of this asset */
174
+ id: string;
175
+ /** URI to a thumbnail of the asset used e.g. in the content library UI */
176
+ thumbUri: string;
177
+ /** Original size of the asset. */
178
+ size: {
179
+ width: number;
180
+ height: number;
181
+ };
182
+ /** Asset-specific and custom meta information */
183
+ meta?: {
184
+ uri?: string;
185
+ filename?: string;
186
+ } & Record<string, unknown>;
187
+ /** The locale of the label and tags */
188
+ locale?: string;
189
+ /** The label of the result. Used for description and tooltips. */
190
+ label?: string;
191
+ /** The tags of this asset. Used for filtering and free-text searching. */
192
+ tags?: string[];
193
+ context: {
194
+ sourceId: string;
195
+ };
196
+ /** Credits for the artist of the asset */
197
+ credits?: {
198
+ name: string;
199
+ url?: string;
200
+ };
201
+ /** License for this asset. Overwrites the source license if present */
202
+ license?: {
203
+ name: string;
204
+ url?: string;
205
+ };
206
+ }
207
+
208
+ /** @public */
209
+ declare interface AssetResultContext {
210
+ sourceId: string;
211
+ createdByRole: string;
212
+ }
213
+
214
+ /**
215
+ * A source of assets
216
+ * @public
217
+ */
218
+ export declare interface AssetSource {
219
+ /** The unique id of the API */
220
+ id: string;
221
+ /** Find all asset for the given type and the provided query data. */
222
+ findAssets(queryData: AssetQueryData): Promise<AssetsQueryResult>;
223
+ /** Return every available group */
224
+ getGroups: () => Promise<string[]>;
225
+ /** Credits for the source/api */
226
+ credits?: {
227
+ name: string;
228
+ url?: string;
229
+ };
230
+ /** General license for all asset from this source */
231
+ license?: {
232
+ name: string;
233
+ url?: string;
234
+ };
235
+ /**
236
+ * Indicates if the asset shall be downloaded to handle the raw data instead
237
+ * of an URL reference. Do this if you do not want to depend on
238
+ * a service after adding the asset to the scene. If this is your own API
239
+ * with your own service, you do not need to set this and avoid downloading /
240
+ * re-uploading the assets.
241
+ */
242
+ downloadAssets?: (asset: AssetResult) => Promise<Blob>;
243
+ /**
244
+ * @returns the asset or undefined if no asset with the given id could be found
245
+ */
246
+ getAsset(id: string): Promise<AssetResult | undefined>;
247
+ /**
248
+ * Can the source add, update and remove assets dynamically? If `false`
249
+ * methods like `addAsset` `updateAsset` and `removeAsset` will throw an
250
+ * error.
251
+ */
252
+ canManageAssets?: boolean;
253
+ /**
254
+ * Apply the given asset result to the active scene.
255
+ * You can override this with custom behavior.
256
+ */
257
+ applyAsset?: (asset: AssetResult) => Promise<void>;
258
+ /**
259
+ * Adds the given asset to this source. Throws an error if `canManageAssets`
260
+ * is `false`.
261
+ *
262
+ * @returns the id of the added asset
263
+ */
264
+ addAsset(asset: AssetDefinition): Promise<string>;
265
+ /**
266
+ * Updates the asset of this source. Throws an error if `canManageAssets`
267
+ * is `false` or no asset with the given id could not be found.
268
+ *
269
+ * @returns the id of the added asset
270
+ */
271
+ updateAsset(assetId: string, asset: AssetDefinition): Promise<void>;
272
+ /**
273
+ * Removes the given asset from this source.
274
+ *
275
+ * @returns true if asset was found and removed, and false otherwise
276
+ */
277
+ removeAsset(assetId: string): Promise<boolean>;
278
+ }
279
+
280
+ /**
281
+ * API to query for assets
282
+ * @public
283
+ */
284
+ declare interface AssetSource_2 {
285
+ /** Find all asset for the given type and the provided query data. */
286
+ findAssets(queryData?: QueryData): Promise<AssetsQueryResult_2 | undefined>;
287
+ /**
288
+ * Apply the given asset result to the active scene.
289
+ * You can override this with custom behavior.
290
+ */
291
+ applyAsset?: (asset: AssetResult_2) => Promise<void>;
292
+ /**
293
+ * Indicates if the asset shall be downloaded to handle the raw data instead
294
+ * of an URL reference. Do this if you do not want to depend on
295
+ * a service after adding the asset to the scene. If this is your own API
296
+ * with your own service, you do not need to set this and avoid downloading /
297
+ * re-uploading the assets.
298
+ */
299
+ downloadAssets?: (asset: AssetResult_2) => Promise<Blob>;
300
+ /** Credits for the source/api */
301
+ credits?: {
302
+ name: string;
303
+ url?: string;
304
+ };
305
+ /** General license for all asset from this source */
306
+ license?: {
307
+ name: string;
308
+ url?: string;
309
+ };
310
+ }
311
+
312
+ /** @public */
313
+ declare type AssetSources = {
314
+ [id: string]: AssetSource_2;
315
+ };
316
+
317
+ /**
318
+ * Return type of a `findAssets` query.
319
+ * @public
320
+ */
321
+ export declare interface AssetsQueryResult {
322
+ /** The assets in the requested page */
323
+ assets: AssetResult[];
324
+ /** The current, requested page */
325
+ currentPage: number;
326
+ /** The next page to query if it exists */
327
+ nextPage?: number;
328
+ /** How many assets are there in total for the current query regardless of the page */
329
+ total: number;
330
+ }
331
+
332
+ /**
333
+ * Return type of a `findAssets` query.
334
+ * @public
335
+ */
336
+ declare interface AssetsQueryResult_2 {
337
+ /** The assets in the requested page */
338
+ assets: AssetResult_2[];
339
+ /** The current, requested page */
340
+ currentPage: number;
341
+ /** The next page to query if it exists */
342
+ nextPage?: number;
343
+ /** How many assets are there in total for the current query regardless of the page */
344
+ total: number;
345
+ }
346
+
347
+ /**
348
+ * @public
349
+ */
350
+ export declare type BlendMode = 'PassThrough' | 'Normal' | 'Darken' | 'Multiply' | 'ColorBurn' | 'Lighten' | 'Screen' | 'ColorDodge' | 'Overlay' | 'SoftLight' | 'HardLight' | 'Difference' | 'Exclusion' | 'Hue' | 'Saturation' | 'Color' | 'Luminosity';
351
+
352
+ /** @public */
353
+ declare type Block = number;
354
+
355
+ /**
356
+ * @public
357
+ */
358
+ export declare class BlockAPI {
359
+ #private;
360
+
361
+ /**
362
+ * Exports a design block element as a file of the given mime type.
363
+ * Performs an internal update to resolve the final layout for the blocks.
364
+ * @param handle - The design block element to export.
365
+ * @param mimeType - The mime type of the output file.
366
+ * @param options - The options for exporting the block type
367
+ * @returns A promise that resolves with the exported image or is rejected with an error.
368
+ */
369
+ export(handle: DesignBlockId, mimeType?: MimeType_2, options?: ExportOptions): Promise<Blob>;
370
+
371
+ /**
372
+ * Loads existing blocks from the given string.
373
+ * The blocks are not attached by default and won't be visible until attached to a page or the scene.
374
+ * @param content - A string representing the given blocks.
375
+ * @returns A promise that resolves with a list of handles representing the found blocks or an error.
376
+ */
377
+ loadFromString(content: string): Promise<DesignBlockId[]>;
378
+ /**
379
+ * Saves the given blocks into a string. If given the root of a block hierarchy, e.g. a
380
+ * page with multiple children, the entire hierarchy is saved.
381
+ * @param blocks - The blocks to save
382
+ * @returns A promise that resolves to a string representing the blocks or an error.
383
+ */
384
+ saveToString(blocks: DesignBlockId[]): Promise<string>;
385
+ /**
386
+ * Create a new block, fails if type is unknown.
387
+ * @param type - The type of the block that shall be created.
388
+ * @returns The created blocks handle.
389
+ */
390
+ create(type: DesignBlockType): DesignBlockId;
391
+
392
+ /**
393
+ * Get the type of the given block, fails if the block is invalid.
394
+ * @param id - The block to query.
395
+ * @returns The blocks type.
396
+ */
397
+ getType(id: DesignBlockId): DesignBlockType;
398
+ /**
399
+ * Update the selection state of a block.
400
+ * Fails for invalid blocks.
401
+ * @param id - The block to query.
402
+ * @param selected - Whether or not the block should be selected.
403
+ */
404
+ setSelected(id: DesignBlockId, selected: boolean): void;
405
+ /**
406
+ * Get the selected state of a block.
407
+ * @param id - The block to query.
408
+ * @returns True if the block is selected, false otherwise.
409
+ */
410
+ isSelected(id: DesignBlockId): boolean;
411
+ /**
412
+ * Get all currently selected blocks.
413
+ * @returns An array of block ids.
414
+ */
415
+ findAllSelected(): DesignBlockId[];
416
+ /**
417
+ * Confirms that a given set of blocks can be grouped together.
418
+ * @param ids - A non-empty array of block ids.
419
+ * @returns Whether the blocks can be grouped together.
420
+ */
421
+ isGroupable(ids: DesignBlockId[]): boolean;
422
+ /**
423
+ * Group blocks together.
424
+ * @param ids - A non-empty array of block ids.
425
+ * @returns The block id of the created group.
426
+ */
427
+ group(ids: DesignBlockId[]): DesignBlockId;
428
+ /**
429
+ * Ungroups a group.
430
+ * @param id - The group id from a previous call to `group`.
431
+ */
432
+ ungroup(id: DesignBlockId): void;
433
+ /**
434
+ * Changes selection from selected group to a block within that group.
435
+ * Nothing happens if `group` is not a group.
436
+ * @param id - The group id from a previous call to `group`.
437
+ */
438
+ enterGroup(id: DesignBlockId): void;
439
+ /**
440
+ * Changes selection from a group's selected block to that group.
441
+ * Nothing happens if the `id` is not part of a group.
442
+ * @param id - A block id.
443
+ */
444
+ exitGroup(id: DesignBlockId): void;
445
+ /**
446
+ * Update a block's name.
447
+ * @param id - The block to update.
448
+ * @param name - The name to set.
449
+ */
450
+ setName(id: DesignBlockId, name: string): void;
451
+ /**
452
+ * Get a block's name.
453
+ * @param id - The block to update.
454
+ */
455
+ getName(id: DesignBlockId): string;
456
+ /**
457
+ * Finds all blocks with the given name.
458
+ * @param name - The name to search for.
459
+ * @returns A list of block ids.
460
+ */
461
+ findByName(name: string): DesignBlockId[];
462
+ /**
463
+ * Finds all blocks with the given type.
464
+ * @param type - The type to search for.
465
+ * @returns A list of block ids.
466
+ */
467
+ findByType(type: DesignBlockType): DesignBlockId[];
468
+ /**
469
+ * Return all blocks currently known to the engine.
470
+ * @returns A list of block ids.
471
+ */
472
+ findAll(): DesignBlockId[];
473
+ /**
474
+ * Return all placeholder blocks in the current scene.
475
+ * @returns A list of block ids.
476
+ */
477
+ findAllPlaceholders(): DesignBlockId[];
478
+ /**
479
+ * Query a block's visibility.
480
+ * @param id - The block to query.
481
+ * @returns True if visible, false otherwise.
482
+ */
483
+ isVisible(id: DesignBlockId): boolean;
484
+ /**
485
+ * Update a block's visibility.
486
+ * @param id - The block to update.
487
+ * @param visible - Whether the block shall be visible.
488
+ */
489
+ setVisible(id: DesignBlockId, visible: boolean): void;
490
+ /**
491
+ * Query a block's clipped state. If true, the block should clip
492
+ * its contents to its frame.
493
+ * @param id - The block to query.
494
+ * @returns True if clipped, false otherwise.
495
+ */
496
+ isClipped(id: DesignBlockId): boolean;
497
+ /**
498
+ * Update a block's clipped state.
499
+ * @param id - The block to update.
500
+ * @param clipped - Whether the block should clips its contents to its frame.
501
+ */
502
+ setClipped(id: DesignBlockId, clipped: boolean): void;
503
+ /**
504
+ * Query a block's x position.
505
+ * @param id - The block to query.
506
+ * @returns The value of the x position.
507
+ */
508
+ getPositionX(id: DesignBlockId): number;
509
+ /**
510
+ * Query a block's mode for its x position.
511
+ * @param id - The block to query.
512
+ * @returns The current mode for the x position: absolute, percent or undefined.
513
+ */
514
+ getPositionXMode(id: DesignBlockId): PositionMode;
515
+ /**
516
+ * Query a block's y position.
517
+ * @param id - The block to query.
518
+ * @returns The value of the y position.
519
+ */
520
+ getPositionY(id: DesignBlockId): number;
521
+ /**
522
+ * Query a block's mode for its y position.
523
+ * @param id - The block to query.
524
+ * @returns The current mode for the y position: absolute, percent or undefined.
525
+ */
526
+ getPositionYMode(id: DesignBlockId): PositionMode;
527
+ /**
528
+ * Update a block's x position.
529
+ * The position refers to the block's local space, relative to its parent with the origin at the top left.
530
+ * @param id - The block to update.
531
+ * @param value - The value of the x position.
532
+ */
533
+ setPositionX(id: DesignBlockId, value: number): void;
534
+ /**
535
+ * Set a block's mode for its x position.
536
+ * @param id - The block to update.
537
+ * @param mode - The x position mode: absolute, percent or undefined.
538
+ */
539
+ setPositionXMode(id: DesignBlockId, mode: PositionMode): void;
540
+ /**
541
+ * Update a block's y position.
542
+ * The position refers to the block's local space, relative to its parent with the origin at the top left.
543
+ * @param id - The block to update.
544
+ * @param value - The value of the y position.
545
+ */
546
+ setPositionY(id: DesignBlockId, value: number): void;
547
+ /**
548
+ * Set a block's mode for its y position.
549
+ * @param id - The block to update.
550
+ * @param mode - The y position mode: absolute, percent or undefined.
551
+ */
552
+ setPositionYMode(id: DesignBlockId, mode: PositionMode): void;
553
+ /**
554
+ * Query a block's rotation in radians.
555
+ * @param id - The block to query.
556
+ * @returns The block's rotation around its center in radians.
557
+ */
558
+ getRotation(id: DesignBlockId): number;
559
+ /**
560
+ * Update a block's rotation.
561
+ * @param id - The block to update.
562
+ * @param radians - The new rotation in radians. Rotation is applied around the block's center.
563
+ */
564
+ setRotation(id: DesignBlockId, radians: number): void;
565
+ /**
566
+ * Query a block's horizontal flip state.
567
+ * @param id - The block to query.
568
+ * @returns A boolean indicating for whether the block is flipped in the queried direction
569
+ */
570
+ getFlipHorizontal(id: DesignBlockId): boolean;
571
+ /**
572
+ * Query a block's vertical flip state.
573
+ * @param id - The block to query.
574
+ * @returns A boolean indicating for whether the block is flipped in the queried direction
575
+ */
576
+ getFlipVertical(id: DesignBlockId): boolean;
577
+ /**
578
+ * Update a block's horizontal flip.
579
+ * @param id - The block to update.
580
+ * @param flip - If the flip should be enabled.
581
+ */
582
+ setFlipHorizontal(id: DesignBlockId, flip: boolean): void;
583
+ /**
584
+ * Update a block's vertical flip.
585
+ * @param id - The block to update.
586
+ * @param flip - If the flip should be enabled.
587
+ */
588
+ setFlipVertical(id: DesignBlockId, flip: boolean): void;
589
+ /**
590
+ * Query if the given block has a content fill mode.
591
+ * @param id - The block to query.
592
+ * @returns true, if the block has a content fill mode.
593
+ */
594
+ hasContentFillMode(id: DesignBlockId): boolean;
595
+ /**
596
+ * Query if the given block shows placeholder content.
597
+ * @param id - The block to query.
598
+ * @returns true, if the block shows placeholder content.
599
+ */
600
+ hasPlaceholderContent(id: DesignBlockId): boolean;
601
+ /**
602
+ * Query a block's width.
603
+ * @param id - The block to query.
604
+ * @returns The value of the block's width.
605
+ */
606
+ getWidth(id: DesignBlockId): number;
607
+ /**
608
+ * Query a block's mode for its width.
609
+ * @param id - The block to query.
610
+ * @returns The current mode for the width: absolute, percent or auto.
611
+ */
612
+ getWidthMode(id: DesignBlockId): SizeMode;
613
+ /**
614
+ * Query a block's height.
615
+ * @param id - The block to query.
616
+ * @returns The value of the block's height.
617
+ */
618
+ getHeight(id: DesignBlockId): number;
619
+ /**
620
+ * Query a block's mode for its height.
621
+ * @param id - The block to query.
622
+ * @returns The current mode for the height: absolute, percent or auto.
623
+ */
624
+ getHeightMode(id: DesignBlockId): SizeMode;
625
+ /**
626
+ * Query a block's content fill mode.
627
+ * @param id - The block to query.
628
+ * @returns The current mode: crop, cover or contain.
629
+ */
630
+ getContentFillMode(id: DesignBlockId): ContentFillMode;
631
+ /**
632
+ * Update a block's width.
633
+ * @param id - The block to update.
634
+ * @param value - The new width of the block.
635
+ */
636
+ setWidth(id: DesignBlockId, value: number): void;
637
+ /**
638
+ * Set a block's mode for its width.
639
+ * @param id - The block to update.
640
+ * @param mode - The width mode: absolute, percent or auto.
641
+ */
642
+ setWidthMode(id: DesignBlockId, mode: SizeMode): void;
643
+ /**
644
+ * Update a block's height.
645
+ * @param id - The block to update.
646
+ * @param value - The new height of the block.
647
+ */
648
+ setHeight(id: DesignBlockId, value: number): void;
649
+ /**
650
+ * Set a block's mode for its height.
651
+ * @param id - The block to update.
652
+ * @param mode - The height mode: absolute, percent or auto.
653
+ */
654
+ setHeightMode(id: DesignBlockId, mode: SizeMode): void;
655
+ /**
656
+ * Set a block's content fill mode.
657
+ * @param id - The block to update.
658
+ * @param mode - The content fill mode mode: crop, cover or contain.
659
+ */
660
+ setContentFillMode(id: DesignBlockId, mode: ContentFillMode): void;
661
+ /**
662
+ * Get a block's layout width. The layout width is only available after an
663
+ * internal update loop, which may not happen immediately.
664
+ * @param id - The block to query.
665
+ * @returns The layout width.
666
+ */
667
+ getFrameWidth(id: DesignBlockId): number;
668
+ /**
669
+ * Get a block's layout height. The layout height is only available after an
670
+ * internal update loop, which may not happen immediately.
671
+ * @param id - The block to query.
672
+ * @returns The layout height.
673
+ */
674
+ getFrameHeight(id: DesignBlockId): number;
675
+ /**
676
+ * Duplicates a block including its children.
677
+ * @param id - The block to duplicate.
678
+ * @returns The handle of the duplicate.
679
+ */
680
+ duplicate(id: DesignBlockId): DesignBlockId;
681
+ /**
682
+ * Destroys a block.
683
+ * @param id - The block to destroy.
684
+ */
685
+ destroy(id: DesignBlockId): void;
686
+ /**
687
+ * Check if a block is valid. A block becomes invalid once it has been destroyed.
688
+ * @param id - The block to query.
689
+ * @returns True, if the block is valid.
690
+ */
691
+ isValid(id: DesignBlockId): boolean;
692
+ /**
693
+ * Query a block's parent.
694
+ * @param id - The block to query.
695
+ * @returns The parent's handle or null if the block has no parent.
696
+ */
697
+ getParent(id: DesignBlockId): DesignBlockId | null;
698
+ /**
699
+ * Get all children of the given block. Children
700
+ * are sorted in their rendering order: Last child is rendered
701
+ * in front of other children.
702
+ * @param id - The block to query.
703
+ * @returns A list of block ids.
704
+ */
705
+ getChildren(id: DesignBlockId): DesignBlockId[];
706
+ /**
707
+ * Insert a new or existing child at a certain position in the parent's children.
708
+ * @param parent - The block whose children should be updated.
709
+ * @param child - The child to insert. Can be an existing child of `parent`.
710
+ * @param index - The index to insert or move to.
711
+ */
712
+ insertChild(parent: DesignBlockId, child: DesignBlockId, index: number): void;
713
+ /**
714
+ * Appends a new or existing child to a block's children.
715
+ * @param parent - The block whose children should be updated.
716
+ * @param child - The child to insert. Can be an existing child of `parent`.
717
+ */
718
+ appendChild(parent: DesignBlockId, child: DesignBlockId): void;
719
+ /** Checks whether the given block references any variables. Doesn't check the block's children.
720
+ *
721
+ * @param id - The block to inspect.
722
+ * @returns true if the block references variables and false otherwise.
723
+ */
724
+ referencesAnyVariables(id: DesignBlockId): boolean;
725
+ /**
726
+ * Get the x position of the block's axis-aligned bounding box in the scene's global coordinate space.
727
+ * The scene's global coordinate space has its origin at the top left.
728
+ * @param id - The block whose bounding box should be calculated.
729
+ * @returns float The x coordinate of the position of the axis-aligned bounding box.
730
+ */
731
+ getGlobalBoundingBoxX(id: DesignBlockId): number;
732
+ /**
733
+ * Get the y position of the block's axis-aligned bounding box in the scene's global coordinate space.
734
+ * The scene's global coordinate space has its origin at the top left.
735
+ * @param id - The block whose bounding box should be calculated.
736
+ * @returns float The y coordinate of the position of the axis-aligned bounding box.
737
+ */
738
+ getGlobalBoundingBoxY(id: DesignBlockId): number;
739
+ /**
740
+ * Get the width of the block's axis-aligned bounding box in the scene's global coordinate space.
741
+ * The scene's global coordinate space has its origin at the top left.
742
+ * @param id - The block whose bounding box should be calculated.
743
+ * @returns float The width of the axis-aligned bounding box.
744
+ */
745
+ getGlobalBoundingBoxWidth(id: DesignBlockId): number;
746
+ /**
747
+ * Get the height of the block's axis-aligned bounding box in the scene's global coordinate space.
748
+ * The scene's global coordinate space has its origin at the top left.
749
+ * @param id - The block whose bounding box should be calculated.
750
+ * @returns float The height of the axis-aligned bounding box.
751
+ */
752
+ getGlobalBoundingBoxHeight(id: DesignBlockId): number;
753
+ /**
754
+ * Scales the block and all of its children proportionally around the specified
755
+ * relative anchor point.
756
+ *
757
+ * This updates the position, size and style properties (e.g. stroke width) of
758
+ * the block and its children.
759
+ *
760
+ * @param id - The block that should be scaled.
761
+ * @param scale - The scale factor to be applied to the current properties of the block.
762
+ * @param anchorX - The relative position along the width of the block around which the
763
+ * scaling should occur. (0 = left edge, 0.5 = center, 1 = right edge)
764
+ * @param anchorY - The relative position along the height of the block around which the
765
+ * scaling should occur. (0 = top edge, 0.5 = center, 1 = bottom edge)
766
+ */
767
+ scale(id: DesignBlockId, scale: number, anchorX?: number, anchorY?: number): void;
768
+ /**
769
+ * Get all available properties of a block.
770
+ * @param id - The block whose properties should be queried.
771
+ * @returns A list of the property names.
772
+ */
773
+ findAllProperties(id: DesignBlockId): string[];
774
+ /**
775
+ * Get the type of a property given its name.
776
+ * @param property - The name of the property whose type should be queried.
777
+ * @returns The property type.
778
+ */
779
+ getPropertyType(property: string): PropertyType;
780
+ /**
781
+ * Get all the possible values of an enum given an enum property.
782
+ * @param enumProperty - The name of the property whose enum values should be queried.
783
+ * @returns A list of the enum value names as string.
784
+ */
785
+ getEnumValues<T = string>(enumProperty: string): T[];
786
+ /**
787
+ * Set a bool property of the given design block to the given value.
788
+ * @param id - The block whose property should be set.
789
+ * @param property - The name of the property to set.
790
+ * @param value - The value to set.
791
+ */
792
+ setBool(id: DesignBlockId, property: string, value: boolean): void;
793
+ /**
794
+ * Get the value of a bool property of the given design block.
795
+ * @param id - The block whose property should be queried.
796
+ * @param property - The name of the property to query.
797
+ * @returns The value of the property.
798
+ */
799
+ getBool(id: DesignBlockId, property: string): boolean;
800
+ /**
801
+ * Set an int property of the given design block to the given value.
802
+ * @param id - The block whose property should be set.
803
+ * @param property - The name of the property to set.
804
+ * @param value - The value to set.
805
+ */
806
+ setInt(id: DesignBlockId, property: string, value: number): void;
807
+ /**
808
+ * Get the value of an int property of the given design block.
809
+ * @param id - The block whose property should be queried.
810
+ * @param property - The name of the property to query.
811
+ * @returns The value of the property.
812
+ */
813
+ getInt(id: DesignBlockId, property: string): number;
814
+ /**
815
+ * Set a float property of the given design block to the given value.
816
+ * @param id - The block whose property should be set.
817
+ * @param property - The name of the property to set.
818
+ * @param value - The value to set.
819
+ */
820
+ setFloat(id: DesignBlockId, property: string, value: number): void;
821
+ /**
822
+ * Get the value of a float property of the given design block.
823
+ * @param id - The block whose property should be queried.
824
+ * @param property - The name of the property to query.
825
+ * @returns The value of the property.
826
+ */
827
+ getFloat(id: DesignBlockId, property: string): number;
828
+ /**
829
+ * Set a string property of the given design block to the given value.
830
+ * @param id - The block whose property should be set.
831
+ * @param property - The name of the property to set.
832
+ * @param value - The value to set.
833
+ */
834
+ setString(id: DesignBlockId, property: string, value: string): void;
835
+ /**
836
+ * Get the value of a string property of the given design block.
837
+ * @param id - The block whose property should be queried.
838
+ * @param property - The name of the property to query.
839
+ * @returns The value of the property.
840
+ */
841
+ getString(id: DesignBlockId, property: string): string;
842
+ /**
843
+ * Set a color property of the given design block to the given value.
844
+ * @param id - The block whose property should be set.
845
+ * @param property - The name of the property to set.
846
+ * @param r - The red color component in the range of 0 to 1.
847
+ * @param g - The green color component in the range of 0 to 1.
848
+ * @param b - The blue color component in the range of 0 to 1.
849
+ * @param a - The alpha color component in the range of 0 to 1.
850
+ */
851
+ setColorRGBA(id: DesignBlockId, property: string, r: number, g: number, b: number, a?: number): void;
852
+ /**
853
+ * Get the value of a string property of the given design block.
854
+ * @param id - The block whose property should be queried.
855
+ * @param property - The name of the property to query.
856
+ * @returns A tuple of channels red, green, blue and alpha in the range of 0 to 1.
857
+ */
858
+ getColorRGBA(id: DesignBlockId, property: string): RGBA;
859
+ /**
860
+ * Set an enum property of the given design block to the given value.
861
+ * @param id - The block whose property should be set.
862
+ * @param property - The name of the property to set.
863
+ * @param value - The enum value as string.
864
+ */
865
+ setEnum(id: DesignBlockId, property: string, value: string): void;
866
+ /**
867
+ * Get the value of an enum property of the given design block.
868
+ * @param id - The block whose property should be queried.
869
+ * @param property - The name of the property to query.
870
+ * @returns The value as string.
871
+ */
872
+ getEnum(id: DesignBlockId, property: string): string;
873
+ /**
874
+ * Query if the given block has crop properties.
875
+ * @param id - The block to query.
876
+ * @returns true, if the block has crop properties.
877
+ */
878
+ hasCrop(id: DesignBlockId): boolean;
879
+ /**
880
+ * Set the crop scale in x direction of the given design block.
881
+ * @param id - The block whose crop should be set.
882
+ * @param scaleX - The scale in x direction.
883
+ */
884
+ setCropScaleX(id: DesignBlockId, scaleX: number): void;
885
+ /**
886
+ * Set the crop scale in y direction of the given design block.
887
+ * @param id - The block whose crop should be set.
888
+ * @param scaleY - The scale in y direction.
889
+ */
890
+ setCropScaleY(id: DesignBlockId, scaleY: number): void;
891
+ /**
892
+ * Set the crop rotation of the given design block.
893
+ * @param id - The block whose crop should be set.
894
+ * @param rotation - The rotation in radians.
895
+ */
896
+ setCropRotation(id: DesignBlockId, rotation: number): void;
897
+ /**
898
+ * Set the crop translation in x direction of the given design block.
899
+ * @param id - The block whose crop should be set.
900
+ * @param translationY - The translation in y direction.
901
+ */
902
+ setCropTranslationX(id: DesignBlockId, translationX: number): void;
903
+ /**
904
+ * Set the crop translation in y direction of the given design block.
905
+ * @param id - The block whose crop should be set.
906
+ * @param translationY - The translation in y direction.
907
+ */
908
+ setCropTranslationY(id: DesignBlockId, translationY: number): void;
909
+ /**
910
+ * Resets the manually set crop of the given design block.
911
+ * The block's content fill mode is set to 'cover'.
912
+ * @param id - The block whose crop should be reset.
913
+ */
914
+ resetCrop(id: DesignBlockId): void;
915
+ /**
916
+ * Get the crop scale on the x axis of the given design block.
917
+ * @param id - The block whose scale should be queried.
918
+ * @returns The scale on the x axis.
919
+ */
920
+ getCropScaleX(id: DesignBlockId): number;
921
+ /**
922
+ * Get the crop scale on the y axis of the given design block.
923
+ * @param id - The block whose scale should be queried.
924
+ * @returns The scale on the y axis.
925
+ */
926
+ getCropScaleY(id: DesignBlockId): number;
927
+ /**
928
+ * Get the crop rotation of the given design block.
929
+ * @param id - The block whose crop rotation should be queried.
930
+ * @returns The crop rotation.
931
+ */
932
+ getCropRotation(id: DesignBlockId): number;
933
+ /**
934
+ * Get the crop translation on the x axis of the given design block.
935
+ * @param id - The block whose translation should be queried.
936
+ * @returns The translation on the x axis.
937
+ */
938
+ getCropTranslationX(id: DesignBlockId): number;
939
+ /**
940
+ * Get the crop translation on the y axis of the given design block.
941
+ * @param id - The block whose translation should be queried.
942
+ * @returns The translation on the y axis.
943
+ */
944
+ getCropTranslationY(id: DesignBlockId): number;
945
+ /**
946
+ * Query if the given block has an opacity.
947
+ * @param id - The block to query.
948
+ * @returns true, if the block has an opacity.
949
+ */
950
+ hasOpacity(id: DesignBlockId): boolean;
951
+ /**
952
+ * Set the opacity of the given design block.
953
+ * @param id - The block whose opacity should be set.
954
+ * @param opacity - The opacity to be set. The valid range is 0 to 1.
955
+ */
956
+ setOpacity(id: DesignBlockId, opacity: number): void;
957
+ /**
958
+ * Get the opacity of the given design block.
959
+ * @param id - The block whose opacity should be queried.
960
+ * @returns The opacity.
961
+ */
962
+ getOpacity(id: DesignBlockId): number;
963
+ /**
964
+ * Query if the given block has a blend mode.
965
+ * @param id - The block to query.
966
+ * @returns true, if the block has a blend mode.
967
+ */
968
+ hasBlendMode(id: DesignBlockId): boolean;
969
+ /**
970
+ * Set the blend mode of the given design block.
971
+ * @param id - The block whose blend mode should be set.
972
+ * @param blendMode - The blend mode to be set.
973
+ * @returns
974
+ */
975
+ setBlendMode(id: DesignBlockId, blendMode: BlendMode): void;
976
+ /**
977
+ * Get the blend mode of the given design block.
978
+ * @param id - The block whose blend mode should be queried.
979
+ * @returns The blend mode.
980
+ */
981
+ getBlendMode(id: DesignBlockId): BlendMode;
982
+ /**
983
+ * Query if the given block has fill color properties.
984
+ * @param id - The block to query.
985
+ * @returns true, if the block has fill color properties.
986
+ */
987
+ hasFillColor(id: DesignBlockId): boolean;
988
+ /**
989
+ * Set the fill color of the given design block.
990
+ * @param id - The block whose fill color should be set.
991
+ * @param color - The fill color to be set, a tuple of
992
+ * @param r - The red color component in the range of 0 to 1.
993
+ * @param g - The green color component in the range of 0 to 1.
994
+ * @param b - The blue color component in the range of 0 to 1.
995
+ * @param a - The alpha color component in the range of 0 to 1.
996
+ */
997
+ setFillColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
998
+ /**
999
+ * Get the fill color of the given design block.
1000
+ * @param id - The block whose fill color should be queried.
1001
+ * @returns The fill color.
1002
+ */
1003
+ getFillColorRGBA(id: DesignBlockId): RGBA;
1004
+ /**
1005
+ * Enable or disable the fill of the given design block.
1006
+ * @param id - The block whose fill should be enabled or disabled.
1007
+ * @param enabled - If true, the fill will be enabled.
1008
+ */
1009
+ setFillColorEnabled(id: DesignBlockId, enabled: boolean): void;
1010
+ /**
1011
+ * Query if the fill of the given design block is enabled.
1012
+ * @param id - The block whose fill state should be queried.
1013
+ * @returns True, if fill is enabled.
1014
+ */
1015
+ isFillColorEnabled(id: DesignBlockId): boolean;
1016
+ /**
1017
+ * Query if the given block has background color properties.
1018
+ * @param id - The block to query.
1019
+ * @returns true, if the block has background color properties.
1020
+ */
1021
+ hasBackgroundColor(id: DesignBlockId): boolean;
1022
+ /**
1023
+ * Set the background color of the given design block.
1024
+ * @param id - The block whose background color should be set.
1025
+ * @param color - The background color to be set, a tuple of
1026
+ * @param r - The red color component in the range of 0 to 1.
1027
+ * @param g - The green color component in the range of 0 to 1.
1028
+ * @param b - The blue color component in the range of 0 to 1.
1029
+ * @param a - The alpha color component in the range of 0 to 1.
1030
+ */
1031
+ setBackgroundColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1032
+ /**
1033
+ * Get the background color of the given design block.
1034
+ * @param id - The block whose background color should be queried.
1035
+ * @returns The background color.
1036
+ */
1037
+ getBackgroundColorRGBA(id: DesignBlockId): RGBA;
1038
+ /**
1039
+ * Enable or disable the background of the given design block.
1040
+ * @param id - The block whose background should be enabled or disabled.
1041
+ * @param enabled - If true, the background will be enabled.
1042
+ */
1043
+ setBackgroundColorEnabled(id: DesignBlockId, enabled: boolean): void;
1044
+ /**
1045
+ * Query if the background of the given design block is enabled.
1046
+ * @param id - The block whose background state should be queried.
1047
+ * @returns True, if background is enabled.
1048
+ */
1049
+ isBackgroundColorEnabled(id: DesignBlockId): boolean;
1050
+ /**
1051
+ * Query if the given block has a stroke property.
1052
+ * @param id - The block to query.
1053
+ * @returns True if the block has a stroke property.
1054
+ */
1055
+ hasStroke(id: DesignBlockId): boolean;
1056
+ /**
1057
+ * Enable or disable the stroke of the given design block.
1058
+ * @param id - The block whose stroke should be enabled or disabled.
1059
+ * @param enabled - If true, the stroke will be enabled.
1060
+ */
1061
+ setStrokeEnabled(id: DesignBlockId, enabled: boolean): void;
1062
+ /**
1063
+ * Query if the stroke of the given design block is enabled.
1064
+ * @param id - The block whose stroke state should be queried.
1065
+ * @returns True if the block's stroke is enabled.
1066
+ */
1067
+ isStrokeEnabled(id: DesignBlockId): boolean;
1068
+ /**
1069
+ * Set the stroke color of the given design block.
1070
+ * @param id - The block whose stroke color should be set.
1071
+ * @param r - The red color component in the range of 0 to 1.
1072
+ * @param g - The green color component in the range of 0 to 1.
1073
+ * @param b - The blue color component in the range of 0 to 1.
1074
+ * @param a - The alpha color component in the range of 0 to 1.
1075
+ */
1076
+ setStrokeColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1077
+ /**
1078
+ * Get the stroke color of the given design block.
1079
+ * @param id - The block whose background color should be queried.
1080
+ * @returns The background color.
1081
+ */
1082
+ getStrokeColorRGBA(id: DesignBlockId): RGBA;
1083
+ /**
1084
+ * Set the stroke width of the given design block.
1085
+ * @param id - The block whose stroke width should be set.
1086
+ * @param width - The stroke width to be set.
1087
+ */
1088
+ setStrokeWidth(id: DesignBlockId, width: number): void;
1089
+ /**
1090
+ * Get the stroke width of the given design block.
1091
+ * @param id - The block whose stroke width should be queried.
1092
+ * @returns The stroke's width.
1093
+ */
1094
+ getStrokeWidth(id: DesignBlockId): number;
1095
+ /**
1096
+ * Set the stroke style of the given design block.
1097
+ * @param id - The block whose stroke style should be set.
1098
+ * @param style - The stroke style to be set.
1099
+ */
1100
+ setStrokeStyle(id: DesignBlockId, style: StrokeStyle): void;
1101
+ /**
1102
+ * Get the stroke style of the given design block.
1103
+ * @param id - The block whose stroke style should be queried.
1104
+ * @returns The stroke's style.
1105
+ */
1106
+ getStrokeStyle(id: DesignBlockId): StrokeStyle;
1107
+ /**
1108
+ * Set the stroke position of the given design block.
1109
+ * @param id - The block whose stroke position should be set.
1110
+ * @param position - The stroke position to be set.
1111
+ */
1112
+ setStrokePosition(id: DesignBlockId, position: StrokePosition): void;
1113
+ /**
1114
+ * Get the stroke position of the given design block.
1115
+ * @param id - The block whose stroke position should be queried.
1116
+ * @returns The stroke position.
1117
+ */
1118
+ getStrokePosition(id: DesignBlockId): StrokePosition;
1119
+ /**
1120
+ * Set the stroke corner geometry of the given design block.
1121
+ * @param id - The block whose stroke join geometry should be set.
1122
+ * @param cornerGeometry - The stroke join geometry to be set.
1123
+ */
1124
+ setStrokeCornerGeometry(id: DesignBlockId, cornerGeometry: StrokeCornerGeometry): void;
1125
+ /**
1126
+ * Get the stroke corner geometry of the given design block.
1127
+ * @param id - The block whose stroke join geometry should be queried.
1128
+ * @returns The stroke join geometry.
1129
+ */
1130
+ getStrokeCornerGeometry(id: DesignBlockId): StrokeCornerGeometry;
1131
+ /**
1132
+ * Query if the given block has outline properties.
1133
+ * @param id - The block to query.
1134
+ * @returns true, if the block has outline properties.
1135
+ * @deprecated Use `hasStroke`.
1136
+ */
1137
+ hasOutline(id: DesignBlockId): boolean;
1138
+ /**
1139
+ * Set the outline color of the given design block.
1140
+ * @param id - The block whose outline color should be set.
1141
+ * @param color - The outline color to be set, a tuple of
1142
+ * @param r - The red color component in the range of 0 to 1.
1143
+ * @param g - The green color component in the range of 0 to 1.
1144
+ * @param b - The blue color component in the range of 0 to 1.
1145
+ * @param a - The alpha color component in the range of 0 to 1.
1146
+ * @deprecated Use `setStrokeColorRGBA`.
1147
+ */
1148
+ setOutlineColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1149
+ /**
1150
+ * Get the outline color of the given design block.
1151
+ * @param id - The block whose outline color should be queried.
1152
+ * @returns The outline color.
1153
+ * @deprecated Use `getStrokeColorRGBA`.
1154
+ */
1155
+ getOutlineColorRGBA(id: DesignBlockId): RGBA;
1156
+ /**
1157
+ * Enable or disable the outline of the given design block.
1158
+ * @param id - The block whose outline should be enabled or disabled.
1159
+ * @param enabled - If true, the outline will be enabled.
1160
+ * @deprecated Use `setStrokeEnabled`.
1161
+ */
1162
+ setOutlineEnabled(id: DesignBlockId, enabled: boolean): void;
1163
+ /**
1164
+ * Query if the outline of the given design block is enabled.
1165
+ * @param id - The block whose outline state should be queried.
1166
+ * @returns True, if outline is enabled.
1167
+ * @deprecated Use `isStrokeEnabled`.
1168
+ */
1169
+ isOutlineEnabled(id: DesignBlockId): boolean;
1170
+ /**
1171
+ * Set the outline width of the given design block.
1172
+ * @param id - The block whose outline width should be set.
1173
+ * @param width - The outline width to be set.
1174
+ * @deprecated Use `setStrokeWidth`.
1175
+ */
1176
+ setOutlineWidth(id: DesignBlockId, width: number): void;
1177
+ /**
1178
+ * Get the outline width of the given design block.
1179
+ * @param id - The block whose outline width should be queried.
1180
+ * @returns The outline width.
1181
+ * @deprecated Use the Stroke function
1182
+ * @deprecated Use `getStrokeWidth`.
1183
+ */
1184
+ getOutlineWidth(id: DesignBlockId): number;
1185
+ /**
1186
+ * Query if the given block has a drop shadow property.
1187
+ * @param id - The block to query.
1188
+ * @returns True if the block has a drop shadow property.
1189
+ */
1190
+ hasDropShadow(id: DesignBlockId): boolean;
1191
+ /**
1192
+ * Enable or disable the drop shadow of the given design block.
1193
+ * @param id - The block whose drop shadow should be enabled or disabled.
1194
+ * @param enabled - If true, the drop shadow will be enabled.
1195
+ */
1196
+ setDropShadowEnabled(id: DesignBlockId, enabled: boolean): void;
1197
+ /**
1198
+ * Query if the drop shadow of the given design block is enabled.
1199
+ * @param id - The block whose drop shadow state should be queried.
1200
+ * @returns True if the block's drop shadow is enabled.
1201
+ */
1202
+ isDropShadowEnabled(id: DesignBlockId): boolean;
1203
+ /**
1204
+ * Set the drop shadow color of the given design block.
1205
+ * @param id - The block whose drop shadow color should be set.
1206
+ * @param r - The red color component in the range of 0 to 1.
1207
+ * @param g - The green color component in the range of 0 to 1.
1208
+ * @param b - The blue color component in the range of 0 to 1.
1209
+ * @param a - The alpha color component in the range of 0 to 1.
1210
+ */
1211
+ setDropShadowColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1212
+ /**
1213
+ * Get the drop shadow color of the given design block.
1214
+ * @param id - The block whose background color should be queried.
1215
+ * @returns The background color.
1216
+ */
1217
+ getDropShadowColorRGBA(id: DesignBlockId): RGBA;
1218
+ /**
1219
+ * Set the drop shadow's X offset of the given design block.
1220
+ * @param id - The block whose drop shadow's X offset should be set.
1221
+ * @param xOffset - The X offset to be set.
1222
+ */
1223
+ setDropShadowXOffset(id: DesignBlockId, xOffset: number): void;
1224
+ /**
1225
+ * Get the drop shadow's X offset of the given design block.
1226
+ * @param id - The block whose drop shadow's X offset should be queried.
1227
+ * @returns The offset.
1228
+ */
1229
+ getDropShadowXOffset(id: DesignBlockId): number;
1230
+ /**
1231
+ * Set the drop shadow's Y offset of the given design block.
1232
+ * @param id - The block whose drop shadow's Y offset should be set.
1233
+ * @param yOffset - The X offset to be set.
1234
+ */
1235
+ setDropShadowYOffset(id: DesignBlockId, yOffset: number): void;
1236
+ /**
1237
+ * Get the drop shadow's Y offset of the given design block.
1238
+ * @param id - The block whose drop shadow's Y offset should be queried.
1239
+ * @returns The offset.
1240
+ */
1241
+ getDropShadowYOffset(id: DesignBlockId): number;
1242
+ /**
1243
+ * Set the drop shadow's blur radius on the X axis of the given design block.
1244
+ * @param id - The block whose drop shadow's blur radius should be set.
1245
+ * @param xBlurRadius - The blur radius to be set.
1246
+ */
1247
+ setDropShadowXBlurRadius(id: DesignBlockId, xBlurRadius: number): void;
1248
+ /**
1249
+ * Get the drop shadow's blur radius on the X axis of the given design block.
1250
+ * @param id - The block whose drop shadow's blur radius should be queried.
1251
+ * @returns The blur radius.
1252
+ */
1253
+ getDropShadowXBlurRadius(id: DesignBlockId): number;
1254
+ /**
1255
+ * Set the drop shadow's blur radius on the Y axis of the given design block.
1256
+ * @param id - The block whose drop shadow's blur radius should be set.
1257
+ * @param yBlurRadius - The blur radius to be set.
1258
+ */
1259
+ setDropShadowYBlurRadius(id: DesignBlockId, yBlurRadius: number): void;
1260
+ /**
1261
+ * Get the drop shadow's blur radius on the Y axis of the given design block.
1262
+ * @param id - The block whose drop shadow's blur radius should be queried.
1263
+ * @returns The blur radius.
1264
+ */
1265
+ getDropShadowYBlurRadius(id: DesignBlockId): number;
1266
+ /**
1267
+ * Set the drop shadow's clipping of the given design block. (Only applies to shapes.)
1268
+ * @param id - The block whose drop shadow's clip should be set.
1269
+ * @param clip - The drop shadow's clip to be set.
1270
+ */
1271
+ setDropShadowClip(id: DesignBlockId, clip: boolean): void;
1272
+ /**
1273
+ * Get the drop shadow's clipping of the given design block.
1274
+ * @param id - The block whose drop shadow's clipping should be queried.
1275
+ * @returns The drop shadow's clipping.
1276
+ */
1277
+ getDropShadowClip(id: DesignBlockId): boolean;
1278
+ /**
1279
+ * Query if the given block has fill color properties.
1280
+ * @param id - The block to query.
1281
+ * @returns true, if the block has fill color properties, an error otherwise.
1282
+ */
1283
+ hasFill(id: DesignBlockId): boolean;
1284
+ /**
1285
+ * Query if the fill of the given design block is enabled.
1286
+ * @param id - The block whose fill state should be queried.
1287
+ * @returns A result holding the fill state or an error.
1288
+ */
1289
+ isFillEnabled(id: DesignBlockId): boolean;
1290
+ /**
1291
+ * Enable or disable the fill of the given design block.
1292
+ * @param id - The block whose fill should be enabled or disabled.
1293
+ * @param enabled - If true, the fill will be enabled.
1294
+ * @returns An empty result on success, an error otherwise.
1295
+ */
1296
+ setFillEnabled(id: DesignBlockId, enabled: boolean): void;
1297
+ /**
1298
+ * Returns the block containing the fill properties of the given block.
1299
+ * @param id - The block whose fill block should be returned.
1300
+ * @returns The block that currently defines the given block's fill.
1301
+ */
1302
+ getFill(id: DesignBlockId): DesignBlockId;
1303
+ /**
1304
+ * Set the fill type of the given design block.
1305
+ * @param id - The block whose fill type should be set.
1306
+ * @param type - The fill type to set.
1307
+ * @returns An empty result on success, an error otherwise.
1308
+ */
1309
+ setFillType(id: DesignBlockId, fillType: FillType): void;
1310
+ /**
1311
+ * Get the fill type of the given design block.
1312
+ * @param id - The block whose fill type should be queried.
1313
+ * @returns The block's fill type or an error.
1314
+ */
1315
+ getFillType(id: DesignBlockId): FillType;
1316
+ /**
1317
+ * Set the fill color of the given design block.
1318
+ * @param id - The block whose fill color should be set.
1319
+ * @param r - The red color component in the range of 0 to 1.
1320
+ * @param g - The green color component in the range of 0 to 1.
1321
+ * @param b - The blue color component in the range of 0 to 1.
1322
+ * @param a - The alpha color component in the range of 0 to 1.
1323
+ * @returns An empty result on success, an error otherwise.
1324
+ */
1325
+ setFillSolidColor(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1326
+ /**
1327
+ * Get the fill color of the given design block.
1328
+ * @param id - The block whose fill color should be queried.
1329
+ * @returns A result holding the fill color or an error.
1330
+ */
1331
+ getFillSolidColor(id: DesignBlockId): RGBA;
1332
+ /**
1333
+ * Set the gradient type of the given design block.
1334
+ * @param id - The block whose gradient type should be set.
1335
+ * @param type - The gradient type.
1336
+ * @returns An empty result on success, an error otherwise.
1337
+ */
1338
+ setFillGradientType(id: DesignBlockId, gradientType: GradientType): void;
1339
+ /**
1340
+ * Get the gradient type of the given design block.
1341
+ * @param id - The block whose gradient type should be queried.
1342
+ * @returns The gradient type.
1343
+ */
1344
+ getFillGradientType(id: DesignBlockId): GradientType;
1345
+ /**
1346
+ * Add a gradient color stop on a design block.
1347
+ * @param id - The block on which a gradient color stop should be added.
1348
+ * @param stop - Where to add a color stop in the range 0 to 1.
1349
+ * @param r - The red color component in the range of 0 to 1.
1350
+ * @param g - The green color component in the range of 0 to 1.
1351
+ * @param b - The blue color component in the range of 0 to 1.
1352
+ * @param a - The alpha color component in the range of 0 to 1.
1353
+ * @returns An empty result on success, an error otherwise.
1354
+ */
1355
+ addFillGradientColorStop(id: DesignBlockId, stop: number, r: number, g: number, b: number, a?: number): void;
1356
+ /**
1357
+ * Remove a previously gradient color stop on a design block.
1358
+ * @param id - The block from which to remove the gradient color stop.
1359
+ * @param stop - The stop's position.
1360
+ * @returns An empty result on success, an error otherwise.
1361
+ */
1362
+ removeFillGradientColorStop(id: DesignBlockId, stop: number): void;
1363
+ /**
1364
+ * Get the gradient fill color stops of the given design block.
1365
+ * @param id - The block whose gradient color stop should be queried.
1366
+ * @returns All of the design block's gradient color stops.
1367
+ */
1368
+ getFillGradientColorStops(id: DesignBlockId): GradientstopRGBA[];
1369
+ /**
1370
+ * Set the gradient fill color stops of the given design block, overwriting previously set color stops.
1371
+ * @param id - The block whose gradient color stop should be set.
1372
+ * @param stops - The gradient color stops to set.
1373
+ * @returns An empty result on success, an error otherwise.
1374
+ */
1375
+ setFillGradientColorStops(id: DesignBlockId, stops: GradientstopRGBA[]): void;
1376
+ /**
1377
+ * Set the position of a gradient's control point.
1378
+ * Note that Different gradient types of different control points.
1379
+ * @param id - The block whose gradient control point should be set.
1380
+ * @param gradientControlPointType - The type of control point.
1381
+ * @param x - The horizontal component of the control point.
1382
+ * @param y - The vertical component of the control point.
1383
+ * @returns true if the control point was set, an error otherwise.
1384
+ */
1385
+ setFillGradientControlPoint(id: DesignBlockId, gradientControlPointType: GradientControlPointType, x: number, y: number): boolean;
1386
+ /**
1387
+ * Get the horizontal component of a gradient's control point.
1388
+ * @param id - The block whose gradient control point should be queried.
1389
+ * @param gradientControlPointType - The type of control point.
1390
+ * @returns The horizontal component of the control point, an error otherwise.
1391
+ */
1392
+ getFillGradientControlPointX(id: DesignBlockId, gradientControlPointType: GradientControlPointType): number;
1393
+ /**
1394
+ * Get the vertical component of a gradient's control point.
1395
+ * @param id - The block whose gradient control point should be queried.
1396
+ * @param gradientControlPointType - The type of control point.
1397
+ * @returns The vertical component of the control point, an error otherwise.
1398
+ */
1399
+ getFillGradientControlPointY(id: DesignBlockId, gradientControlPointType: GradientControlPointType): number;
1400
+ /**
1401
+ * Set a gradient's radius.
1402
+ * Note that Not all gradients have a radius.
1403
+ * @param id - The block whose gradient radius should be set.
1404
+ * @param radius - The gradient's radius.
1405
+ * @returns true if the control point was set, an error otherwise.
1406
+ */
1407
+ setFillGradientRadius(id: DesignBlockId, radius: number): boolean;
1408
+ /**
1409
+ * Get a gradient's radius.
1410
+ * Note that Not all gradients have a radius.
1411
+ * @param id - The block whose gradient radius should be queried.
1412
+ * @returns the gradient's radius, an error otherwise.
1413
+ */
1414
+ getFillGradientRadius(id: DesignBlockId): number;
1415
+ /**
1416
+ * Set a metadata value of a block identified by a key.
1417
+ * If the key does not exist, yet, it will be added.
1418
+ * @param block - The block whose metadata will be accessed.
1419
+ * @param key - The key used to identify the desired piece of metadata.
1420
+ * @param value - The value to set.
1421
+ */
1422
+ setMetadata(id: DesignBlockId, key: string, value: string): void;
1423
+ /**
1424
+ * Get a metadata value of a block identified by a key.
1425
+ * If the key does not exist, yet, this method will fail.
1426
+ * @param block - The block whose metadata will be accessed.
1427
+ * @param key - The key used to identify the desired piece of metadata.
1428
+ * @returns the value associated with the key.
1429
+ */
1430
+ getMetadata(id: DesignBlockId, key: string): string;
1431
+ /**
1432
+ * Check if the block has metadata associated with the key.
1433
+ * @param block - The block whose metadata will be accessed.
1434
+ * @param key - The key used to identify the desired piece of metadata.
1435
+ * @returns whether the key exists.
1436
+ */
1437
+ hasMetadata(id: DesignBlockId, key: string): boolean;
1438
+ /**
1439
+ * Remove metadata associated with the key from the given block.
1440
+ * If the key does not exist, this method will fail.
1441
+ * @param block - The block whose metadata will be accessed.
1442
+ * @param key - The key used to identify the desired piece of metadata.
1443
+ */
1444
+ removeMetadata(id: DesignBlockId, key: string): void;
1445
+ }
1446
+
1447
+ /**
1448
+ * @public
1449
+ */
1450
+ export declare type BlockEvent = {
1451
+ block: DesignBlockId;
1452
+ type: 'Created' | 'Updated' | 'Destroyed';
1453
+ };
1454
+
1455
+ /** @public */
1456
+ declare interface BlockEvent_2 {
1457
+ block: Block;
1458
+ type: 'Created' | 'Updated' | 'Destroyed';
1459
+ }
1460
+
1461
+ /**
1462
+ * Dispatched on the engine canvas when the text input has been blurred.
1463
+ * Call `preventDefault()` to disallow this and refocus the engine text input.
1464
+ * @public
1465
+ */
1466
+ export declare interface BlurEvent extends CustomEvent<EventTarget | null> {
1467
+ readonly type: 'cesdk-blur';
1468
+ /** Contains the element that has received focus during the blur, or null */
1469
+ readonly detail: EventTarget | null;
1470
+ /** Force focus back to the engine input */
1471
+ preventDefault(): void;
1472
+ }
1473
+
1474
+ /** @public */
1475
+ declare type Callbacks = {
1476
+ log?: Logger;
1477
+ };
1478
+
1479
+ /**
1480
+ * All components between 0 and 1
1481
+ * @public
1482
+ */
1483
+ export declare interface CMYKColor {
1484
+ c: number;
1485
+ m: number;
1486
+ y: number;
1487
+ k: number;
1488
+ }
1489
+
1490
+ /**
1491
+ * A color definition for the custom color palette.
1492
+ * The RGB and CMYK components must all be specified in the range [0-1].
1493
+ * @public
1494
+ */
1495
+ declare type Color_2 = HexColorString | RGBColor | RGBAColor | SpotColor;
1496
+
1497
+ /** @public */
1498
+ declare type ColorDefinition = Preset & {
1499
+ value: Color_2;
1500
+ };
1501
+
1502
+ /** @public */
1503
+ declare type ColorPaletteDefinition = Preset & {
1504
+ entries: Color_2[];
1505
+ };
1506
+
1507
+ declare namespace ConfigTypes {
1508
+ export {
1509
+ HexColorString,
1510
+ Color_2 as Color,
1511
+ AssetSources,
1512
+ AssetSource_2 as AssetSource,
1513
+ AssetResult_2 as AssetResult,
1514
+ AssetsQueryResult_2 as AssetsQueryResult,
1515
+ QueryData,
1516
+ Preset,
1517
+ VariableDefinition,
1518
+ ColorDefinition,
1519
+ ColorPaletteDefinition,
1520
+ PageFormatDefinition,
1521
+ TemplateDefinition,
1522
+ TypefaceDefinition,
1523
+ ImageDefinition,
1524
+ Presets,
1525
+ Variables,
1526
+ Core,
1527
+ Extensions,
1528
+ Scene,
1529
+ Page,
1530
+ Callbacks
1531
+ }
1532
+ }
1533
+ export { ConfigTypes }
1534
+
1535
+ /** @public */
1536
+ export declare interface Configuration {
1537
+ baseURL: string;
1538
+ license?: string;
1539
+ role: RoleString;
1540
+ featureFlags?: Record<string, string | boolean>;
1541
+ extensions: ConfigTypes.Extensions;
1542
+ core: ConfigTypes.Core;
1543
+ scene: ConfigTypes.Scene;
1544
+ page: ConfigTypes.Page;
1545
+ assetSources: ConfigTypes.AssetSources;
1546
+ presets: ConfigTypes.Presets;
1547
+ variables: ConfigTypes.Variables;
1548
+ callbacks: ConfigTypes.Callbacks;
1549
+ /**
1550
+ * The default font used by a text added to the scene. Needs to be the id of
1551
+ * the font from a extension pack including namespace, e.g.
1552
+ *
1553
+ * '//ly.img.cesdk.fonts/roboto_regular'
1554
+ *
1555
+ * If not configured the fallback font is used.
1556
+ */
1557
+ defaultFont?: string;
1558
+ }
1559
+
1560
+ /**
1561
+ * - Crop: Manual crop.
1562
+ * - Cover: Automatically cover the entire frame.
1563
+ * - Contain: Automatically contain content inside frame.
1564
+ *
1565
+ * @public
1566
+ */
1567
+ export declare type ContentFillMode = 'Crop' | 'Cover' | 'Contain';
1568
+
1569
+ /** @public */
1570
+ declare type Core = {
1571
+ baseURL: string;
1572
+ };
1573
+
1574
+ /**
1575
+ * A headless implementation that just initializes & exposes the Document API
1576
+ *
1577
+ * @public
1578
+ */
1579
+ declare class CreativeEngine {
1580
+ #private;
1581
+ asset: AssetAPI;
1582
+ block: BlockAPI;
1583
+ editor: EditorAPI;
1584
+ event: EventAPI;
1585
+ scene: SceneAPI;
1586
+ variable: VariableAPI;
1587
+
1588
+ /**
1589
+ * Dispose the engine.
1590
+ */
1591
+ dispose(): void;
1592
+ /**
1593
+ * Initialize a `CreativeEngine` using the given `canvas` element and an optional config.
1594
+ * @param config - A configuration object.
1595
+ * @param canvas - The canvas to use for drawing. Optional, if no canvas is provided,
1596
+ * the engine works with an internal offscreen-canvas.
1597
+ * @returns An engine instance.
1598
+ */
1599
+ static init(config?: Partial<Configuration>, canvas?: HTMLCanvasElement | OffscreenCanvas): Promise<CreativeEngine>;
1600
+ }
1601
+ export default CreativeEngine;
1602
+
1603
+ /**
1604
+ * A numerical identifier for a design block
1605
+ * @public
1606
+ */
1607
+ export declare type DesignBlockId = number;
1608
+
1609
+ /**
1610
+ * @public
1611
+ */
1612
+ export declare enum DesignBlockType {
1613
+ Scene = "//ly.img.ubq/scene",
1614
+ Stack = "//ly.img.ubq/stack",
1615
+ Camera = "//ly.img.ubq/camera",
1616
+ Page = "//ly.img.ubq/page",
1617
+ Image = "//ly.img.ubq/image",
1618
+ Video = "//ly.img.ubq/video",
1619
+ Text = "//ly.img.ubq/text",
1620
+ Sticker = "//ly.img.ubq/sticker",
1621
+ VectorPath = "//ly.img.ubq/vector_path",
1622
+ RectShape = "//ly.img.ubq/shapes/rect",
1623
+ LineShape = "//ly.img.ubq/shapes/line",
1624
+ StarShape = "//ly.img.ubq/shapes/star",
1625
+ PolygonShape = "//ly.img.ubq/shapes/polygon",
1626
+ EllipseShape = "//ly.img.ubq/shapes/ellipse",
1627
+ Group = "//ly.img.ubq/group"
1628
+ }
1629
+
1630
+ /** @public */
1631
+ export declare type DesignUnit = 'mm' | 'px' | 'in';
1632
+
1633
+ /**
1634
+ * @public
1635
+ */
1636
+ export declare class EditorAPI {
1637
+ #private;
1638
+
1639
+ /**
1640
+ * Subscribe to changes to the editor state.
1641
+ * @param callback - This function is called at the end of the engine update, if the editor state has changed.
1642
+ * @returns A method to unsubscribe.
1643
+ */
1644
+ onStateChanged(callback: () => void): () => void;
1645
+ /**
1646
+ * Set the edit mode of the editor.
1647
+ * An edit mode defines what type of content can currently be edited by the user.
1648
+ * Hint: the initial edit mode is "Transform".
1649
+ * @param mode - "Transform", "Crop", "Text", or a custom value.
1650
+ */
1651
+ setEditMode(mode: 'Transform' | 'Crop' | 'Text' | string): void;
1652
+ /**
1653
+ * Get the current edit mode of the editor.
1654
+ * An edit mode defines what type of content can currently be edited by the user.
1655
+ * @returns "Transform", "Crop", "Text", or a custom value.
1656
+ */
1657
+ getEditMode(): 'Transform' | 'Crop' | 'Text' | string;
1658
+ /**
1659
+ * Get the type of cursor that should be displayed by the application.
1660
+ * @returns The cursor type.
1661
+ */
1662
+ getCursorType(): 'Arrow' | 'Move' | 'MoveNotPermitted' | 'Resize' | 'Rotate' | 'Text';
1663
+ /**
1664
+ * Get the rotation with which to render the mouse cursor.
1665
+ * @returns The angle in radians.
1666
+ */
1667
+ getCursorRotation(): number;
1668
+ /**
1669
+ * Get the current text cursor's x position in screen space.
1670
+ * @returns The text cursor's x position in screen space.
1671
+ */
1672
+ getTextCursorPositionInScreenSpaceX(): number;
1673
+ /**
1674
+ * Get the current text cursor's y position in screen space.
1675
+ * @returns The text cursor's y position in screen space.
1676
+ */
1677
+ getTextCursorPositionInScreenSpaceY(): number;
1678
+ /**
1679
+ * Adds a new history state to the stack, if undoable changes were made.
1680
+ */
1681
+ addUndoStep(): void;
1682
+ /**
1683
+ * Undo one step in the history if an undo step is available.
1684
+ */
1685
+ undo(): void;
1686
+ /**
1687
+ * Redo one step in the history if a redo step is available.
1688
+ */
1689
+ redo(): void;
1690
+ /**
1691
+ * If an undo step is available.
1692
+ *
1693
+ * @returns True if an undo step is available.
1694
+ */
1695
+ canUndo(): boolean;
1696
+ /**
1697
+ * If a redo step is available.
1698
+ *
1699
+ * @returns True if a redo step is available.
1700
+ */
1701
+ canRedo(): boolean;
1702
+ /**
1703
+ * Subscribe to changes to the editor settings.
1704
+ * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
1705
+ * @returns A method to unsubscribe.
1706
+ */
1707
+ onSettingsChanged(callback: () => void): () => void;
1708
+ /**
1709
+ * Set a boolean setting.
1710
+ * @param keypath - The settings keypath, e.g. `ubq://doubleClickToCropEnabled`
1711
+ * @param value - The value to set.
1712
+ * @throws An error, if the keypath is invalid.
1713
+ */
1714
+ setSettingBool(keypath: string, value: boolean): void;
1715
+ /**
1716
+ * Get a boolean setting.
1717
+ * @param keypath - The settings keypath, e.g. `ubq://doubleClickToCropEnabled`
1718
+ * @throws An error, if the keypath is invalid.
1719
+ */
1720
+ getSettingBool(keypath: string): boolean;
1721
+ /**
1722
+ * Set an integer setting.
1723
+ * @param keypath - The settings keypath.
1724
+ * @param value - The value to set.
1725
+ * @throws An error, if the keypath is invalid.
1726
+ */
1727
+ setSettingInt(keypath: string, value: number): void;
1728
+ /**
1729
+ * Get an integer setting.
1730
+ * @param keypath - The settings keypath.
1731
+ * @throws An error, if the keypath is invalid.
1732
+ */
1733
+ getSettingInt(keypath: string): number;
1734
+ /**
1735
+ * Set a float setting.
1736
+ * @param keypath - The settings keypath, e.g. `ubq://positionSnappingThreshold`
1737
+ * @param value - The value to set.
1738
+ * @throws An error, if the keypath is invalid.
1739
+ */
1740
+ setSettingFloat(keypath: string, value: number): void;
1741
+ /**
1742
+ * Get a float setting.
1743
+ * @param keypath - The settings keypath, e.g. `ubq://positionSnappingThreshold`
1744
+ * @throws An error, if the keypath is invalid.
1745
+ */
1746
+ getSettingFloat(keypath: string): number;
1747
+ /**
1748
+ * Set a string setting.
1749
+ * @param keypath - The settings keypath, e.g. `ubq://license`
1750
+ * @param value - The value to set.
1751
+ * @throws An error, if the keypath is invalid.
1752
+ */
1753
+ setSettingString(keypath: string, value: string): void;
1754
+ /**
1755
+ * Get a string setting.
1756
+ * @param keypath - The settings keypath, e.g. `ubq://license`
1757
+ * @throws An error, if the keypath is invalid.
1758
+ */
1759
+ getSettingString(keypath: string): string;
1760
+ /**
1761
+ * Set a color setting.
1762
+ * @param keypath - The settings keypath, e.g. `ubq://highlightColor`.
1763
+ * @param r - The red color component in the range of 0 to 1.
1764
+ * @param g - The green color component in the range of 0 to 1.
1765
+ * @param b - The blue color component in the range of 0 to 1.
1766
+ * @param a - The alpha color component in the range of 0 to 1.
1767
+ */
1768
+ setSettingColorRGBA(keypath: string, r: number, g: number, b: number, a?: number): void;
1769
+ /**
1770
+ * Get a color setting.
1771
+ * @param keypath - The settings keypath, e.g. `ubq://highlightColor`.
1772
+ * @returns A tuple of channels red, green, blue and alpha in the range of 0 to 1.
1773
+ */
1774
+ getSettingColorRGBA(keypath: string): RGBA;
1775
+ /**
1776
+ * Set an enum setting.
1777
+ * @param keypath - The settings keypath, e.g. `ubq://role`.
1778
+ * @param value - The enum value as string.
1779
+ */
1780
+ setSettingEnum(keypath: string, value: string): void;
1781
+ /**
1782
+ * Get an enum setting.
1783
+ * @param keypath - The settings keypath, e.g. `ubq://role`.
1784
+ * @returns The value as string.
1785
+ */
1786
+ getSettingEnum(keypath: string): string;
1787
+ /**
1788
+ * Sets a custom URI resolver.
1789
+ * This function can be called more than once. Subsequent calls will overwrite previous calls.
1790
+ * To remove a previously set resolver, pass the value `null`.
1791
+ * The given function must return an absolute path with a scheme.
1792
+ * @param resolver - Custom resolution function.
1793
+ */
1794
+ setURIResolver(resolver: (URI: string) => string): void;
1795
+ /**
1796
+ * Resolves the given path.
1797
+ * If a custom resolver has been set with `setURIResolver`, it invokes it with the given path.
1798
+ * Else, it resolves it as relative to the `ubq://basePath` setting.
1799
+ * This performs NO validation of whether a file exists at the specified location.
1800
+ * @param relativePath - A relative path string
1801
+ * @returns The resolved absolute uri or an error if an invalid path was given.
1802
+ */
1803
+ getAbsoluteURI(relativePath: string): string;
1804
+ }
1805
+
1806
+ /**
1807
+ * @public
1808
+ */
1809
+ export declare class EventAPI {
1810
+ #private;
1811
+
1812
+ /**
1813
+ * Subscribe to block life-cycle events.
1814
+ * @param blocks - A list of blocks to filter events by. If the list is empty, events for every block are sent.
1815
+ * @param callback - The event callback. Events are bundled and sent at the end of each engine update.
1816
+ * @returns A method to unsubscribe.
1817
+ */
1818
+ subscribe(blocks: DesignBlockId[], callback: (events: BlockEvent[]) => void): () => void;
1819
+ }
1820
+
1821
+ /**
1822
+ * @public
1823
+ */
1824
+ export declare type ExportOptions = {
1825
+ /**
1826
+ * The PNG compression level to use, when exporting to PNG.
1827
+ *
1828
+ * Valid values are 0 to 9, higher means smaller, but slower.
1829
+ * Quality is not affected.
1830
+ * Ignored for other encodings.
1831
+ * @defaultValue 5.
1832
+ */
1833
+ pngCompressionLevel?: number;
1834
+ /**
1835
+ * The JPEG quality to use when encoding to JPEG.
1836
+ *
1837
+ * Valid values are (0-1], higher means better quality.
1838
+ * Ignored for other encodings.
1839
+ *
1840
+ * @defaultValue 0.9
1841
+ */
1842
+ jpegQuality?: number;
1843
+ /**
1844
+ * An optional target width used in conjunction with target height.
1845
+ * If used, the block will be rendered large enough, that it fills the target
1846
+ * size entirely while maintaining its aspect ratio.
1847
+ */
1848
+ targetWidth?: number;
1849
+ /**
1850
+ * An optional target height used in conjunction with target width.
1851
+ * If used, the block will be rendered large enough, that it fills the target
1852
+ * size entirely while maintaining its aspect ratio.
1853
+ */
1854
+ targetHeight?: number;
1855
+ };
1856
+
1857
+ /** @public */
1858
+ declare interface ExportOptions_2 {
1859
+ jpegQuality: number;
1860
+ pngCompressionLevel: number;
1861
+ useTargetSize: boolean;
1862
+ targetWidth: number;
1863
+ targetHeight: number;
1864
+ }
1865
+
1866
+ /** @public */
1867
+ declare interface ExportVideoOptions {
1868
+ h264Profile: number;
1869
+ h264Level: number;
1870
+ framerate: number;
1871
+ useTargetSize: boolean;
1872
+ targetWidth: number;
1873
+ targetHeight: number;
1874
+ }
1875
+
1876
+ /** @public */
1877
+ declare type Extensions = {
1878
+ baseURL: string;
1879
+ entries: string[];
1880
+ };
1881
+
1882
+ /**
1883
+ * @public
1884
+ */
1885
+ export declare type FillType = 'Solid' | 'Gradient';
1886
+
1887
+ /** @public */
1888
+ declare interface FindAssetsQuery {
1889
+ perPage: number;
1890
+ page: number;
1891
+ query: string;
1892
+ tags: string[];
1893
+ groups: string[];
1894
+ excludeGroups: string[];
1895
+ locale: string;
1896
+ }
1897
+
1898
+ /** @public */
1899
+ declare interface Flip {
1900
+ horizontal: boolean;
1901
+ vertical: boolean;
1902
+ }
1903
+
1904
+ /** @public */
1905
+ export declare type FontStyle = 'normal' | 'italic';
1906
+
1907
+ /** @public */
1908
+ export declare type FontWeight = 'thin' | 'extraLight' | 'Light' | 'normal' | 'medium' | 'semiBold' | 'bold' | 'extraBold' | 'heavy';
1909
+
1910
+ /**
1911
+ * @public
1912
+ */
1913
+ export declare type GradientControlPointType = 'Start' | 'End' | 'Center';
1914
+
1915
+ /**
1916
+ * @public
1917
+ */
1918
+ export declare type GradientstopRGBA = [
1919
+ stop: number,
1920
+ r: number,
1921
+ g: number,
1922
+ b: number,
1923
+ a: number
1924
+ ];
1925
+
1926
+ /**
1927
+ * @public
1928
+ */
1929
+ export declare type GradientType = 'Linear' | 'Radial' | 'Conical';
1930
+
1931
+ /**
1932
+ * An asset can be member of multiple groups. Groups have a semantic meaning
1933
+ * used to build and group UIs exploring the assets, e.g.sections in the
1934
+ * content library, or for things like topics in Unsplash for instance.
1935
+ *
1936
+ * Tags in comparison have are more loosely hold meaning used for extended
1937
+ * searching/filtering.
1938
+ * @public
1939
+ */
1940
+ declare type Groups = string[];
1941
+
1942
+ /**
1943
+ * A hexadecimal color value (RGB or RGBA) that starts with a '#'
1944
+ * @example #6686FF or #6686FFFF
1945
+ * @public
1946
+ */
1947
+ declare type HexColorString = string;
1948
+
1949
+ /** @public */
1950
+ declare type ImageDefinition = Preset & {
1951
+ imageURL: string;
1952
+ thumbnailURL?: string;
1953
+ width: number;
1954
+ height: number;
1955
+ levelOfDetail?: {
1956
+ [lod: number]: string;
1957
+ };
1958
+ };
1959
+
1960
+ /**
1961
+ * e.g. `en`, `de`, etc.
1962
+ * @public
1963
+ */
1964
+ declare type Locale = string;
1965
+
1966
+ /** @public */
1967
+ export declare type Logger = (message: string, level: LogLevel) => void;
1968
+
1969
+ /** @public */
1970
+ export declare enum LogLevel {
1971
+ Info = "Info",
1972
+ Warning = "Warning",
1973
+ Error = "Error"
1974
+ }
1975
+
1976
+ /** @public */
1977
+ declare enum MimeType_2 {
1978
+ Png = "image/png",
1979
+ Jpeg = "image/jpeg",
1980
+ Tga = "image/x-tga",
1981
+ Mp4 = "video/mp4",
1982
+ Binary = "application/octet-stream",
1983
+ Pdf = "application/pdf",
1984
+ Zip = "application/zip"
1985
+ }
1986
+ export { MimeType_2 as MimeType }
1987
+
1988
+ /** @public */
1989
+ declare type Page = {
1990
+ title: {
1991
+ /**
1992
+ * Whether newly created pages should show a title.
1993
+ */
1994
+ show?: boolean;
1995
+ /**
1996
+ * The font file to use to render the page titles.
1997
+ */
1998
+ fontFileUri?: string;
1999
+ };
2000
+ /**
2001
+ * Whether the opacity of the region outside of all
2002
+ * pages should be reduced.
2003
+ */
2004
+ dimOutOfPageAreas?: boolean;
2005
+ };
2006
+
2007
+ /** @public */
2008
+ declare type PageFormatDefinition = Preset & {
2009
+ width: number;
2010
+ height: number;
2011
+ unit: DesignUnit;
2012
+ dpi?: number;
2013
+ bleedMargin?: number;
2014
+ };
2015
+
2016
+ /**
2017
+ * - Absolute: Position in absolute design units.
2018
+ * - Percent: Position in relation to the block's parent's size in percent, where 1.0 means 100%.
2019
+ * - Auto: Position is automatically determined
2020
+ *
2021
+ * @public
2022
+ */
2023
+ export declare type PositionMode = 'Absolute' | 'Percent' | 'Auto';
2024
+
2025
+ /** @public */
2026
+ declare type Preset = {
2027
+ meta?: {
2028
+ default?: boolean;
2029
+ library?: string;
2030
+ categories?: string[];
2031
+ };
2032
+ };
2033
+
2034
+ /** @public */
2035
+ declare type Presets = {
2036
+ colors?: {
2037
+ [id: string]: ColorDefinition;
2038
+ };
2039
+ typefaces?: {
2040
+ [id: string]: TypefaceDefinition;
2041
+ };
2042
+ images?: {
2043
+ [id: string]: ImageDefinition;
2044
+ };
2045
+ pageFormats?: {
2046
+ [id: string]: PageFormatDefinition;
2047
+ };
2048
+ colorPalettes?: {
2049
+ [id: string]: ColorPaletteDefinition;
2050
+ };
2051
+ templates?: {
2052
+ [id: string]: TemplateDefinition;
2053
+ };
2054
+ };
2055
+
2056
+ /** @public */
2057
+ export declare type PropertyType = 'Bool' | 'Int' | 'Float' | 'String' | 'Color' | 'Enum' | 'Struct';
2058
+
2059
+ /** @public */
2060
+ declare interface QueryData {
2061
+ /** A query string used for (fuzzy) searching of labels and tags */
2062
+ query?: string;
2063
+ /**
2064
+ * The number of results queried. How many assets shall be returned regardless
2065
+ * of the total number of assets available.
2066
+ *
2067
+ * Together with `page` this can be used for pagination.
2068
+ */
2069
+ perPage: number;
2070
+ /** The current page queried for paginated views. */
2071
+ page: number;
2072
+ }
2073
+
2074
+ /**
2075
+ * Dispatched on the engine canvas right before the engine will refocus its text
2076
+ * input after a blur. Call `preventDefault()` to prevent the refocusing.
2077
+ * @public
2078
+ */
2079
+ export declare interface RefocusEvent extends CustomEvent<EventTarget | null> {
2080
+ readonly type: 'cesdk-refocus';
2081
+ /** Contains the element that has received focus during the blur, or null */
2082
+ readonly detail: EventTarget | null;
2083
+ /** Prevent refocusing the engine input */
2084
+ preventDefault(): void;
2085
+ }
2086
+
2087
+ /**
2088
+ * @public
2089
+ */
2090
+ export declare type RGBA = [r: number, g: number, b: number, a: number];
2091
+
2092
+ /**
2093
+ * All components between 0 and 1
2094
+ * @public
2095
+ */
2096
+ export declare interface RGBAColor {
2097
+ r: number;
2098
+ g: number;
2099
+ b: number;
2100
+ a: number;
2101
+ }
2102
+
2103
+ /**
2104
+ * All components between 0 and 1
2105
+ * @public
2106
+ */
2107
+ export declare interface RGBColor {
2108
+ r: number;
2109
+ g: number;
2110
+ b: number;
2111
+ }
2112
+
2113
+ /** @public */
2114
+ export declare type RoleString = 'Creator' | 'Adopter' | 'Viewer' | 'Presenter';
2115
+
2116
+ /**
2117
+ * Export Settings
2118
+ * @public
2119
+ */
2120
+ declare type Scene = {
2121
+ maskSpotColor?: SpotColor;
2122
+ /**
2123
+ * The DPI value to use when exporting and when converting between pixels and inches or millimeter units.
2124
+ * (In the CESDK, this value is synonymous with PPI).
2125
+ *
2126
+ * This is only relevant for new scenes that are created in the editor. Loaded scenes will use the
2127
+ * value stored in their serialization file.
2128
+ */
2129
+ dpi: number;
2130
+ /**
2131
+ * A scale factor that is applied to the final export resolution.
2132
+ *
2133
+ * This is only relevant for new scenes that are created in the editor. Loaded scenes will use the
2134
+ * value stored in their serialization file.
2135
+ */
2136
+ pixelScaleFactor: number;
2137
+ };
2138
+
2139
+ /**
2140
+ * @public
2141
+ */
2142
+ export declare class SceneAPI {
2143
+ #private;
2144
+
2145
+ /**
2146
+ * Load the contents of a scene file.
2147
+ * @param sceneContent - The scene file contents, a base64 string.
2148
+ * @returns A handle to the loaded scene.
2149
+ */
2150
+ loadFromString(sceneContent: string): Promise<DesignBlockId>;
2151
+ /**
2152
+ * Load a scene from the URL to the scene file.
2153
+ * The scene file will be fetched asynchronously by the engine. This requires continuous `render`
2154
+ * calls on this engines instance.
2155
+ * @param url - The URL of the scene file.
2156
+ * @returns scene A promise that resolves once the scene was loaded or rejects with an error otherwise.
2157
+ */
2158
+ loadFromURL(url: string): Promise<DesignBlockId>;
2159
+ /**
2160
+ * Serializes the current scene into a string. Selection is discarded.
2161
+ * @returns A promise that resolves with a string on success or an error on failure.
2162
+ */
2163
+ saveToString(): Promise<string>;
2164
+ /**
2165
+ * Saves the current scene and all of its referenced assets into an archive.
2166
+ * The archive contains all assets, that were accessible when this function was called.
2167
+ * Blocks in the archived scene reference assets relative from to the location of the scene
2168
+ * file. These references are resolved when loading such a scene via `loadSceneFromURL`.
2169
+ *
2170
+ * @returns A promise that resolves with a Blob on success or an error on failure.
2171
+ */
2172
+ saveToArchive(): Promise<Blob>;
2173
+ /**
2174
+ * Create a new scene, along with its own camera.
2175
+ * @returns The scenes handle.
2176
+ */
2177
+ create(): DesignBlockId;
2178
+ /**
2179
+ * Loads the given image and creates a scene with a single page showing the image.
2180
+ * Fetching the image may take an arbitrary amount of time, so the scene isn't immediately
2181
+ * available.
2182
+ * @param url - The image URL.
2183
+ * @param dpi - The scenes DPI.
2184
+ * @param pixelScaleFactor - The displays pixel scale factor.
2185
+ * @returns A promise that resolves with the scene ID on success or rejected with an error otherwise.
2186
+ */
2187
+ createFromImage(url: string, dpi?: number, pixelScaleFactor?: number): Promise<DesignBlockId>;
2188
+ /**
2189
+ * Return the currently active scene.
2190
+ * @returns The scene or null, if none was created yet.
2191
+ */
2192
+ get(): DesignBlockId | null;
2193
+ /**
2194
+ * Applies the contents of the given template scene to the currently loaded scene.
2195
+ * This loads the template scene while keeping the design unit and page dimensions
2196
+ * of the current scene. Page contents remain centered when the pages are resized
2197
+ * to fit the new dimensions.
2198
+ * @param content - The template scene file contents, a base64 string.
2199
+ * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2200
+ */
2201
+ applyTemplateFromString(content: string): Promise<void>;
2202
+ /**
2203
+ * Applies the contents of the given template scene to the currently loaded scene.
2204
+ * This loads the template scene while keeping the design unit and page dimensions
2205
+ * of the current scene. Page contents remain centered when the pages are resized
2206
+ * to fit the new dimensions.
2207
+ * @param url - The url to the template scene file.
2208
+ * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2209
+ */
2210
+ applyTemplateFromURL(url: string): Promise<void>;
2211
+ /**
2212
+ * Sets the zoom level of the active scene.
2213
+ * Only has an effect if the zoom level is not handled by the UI.
2214
+ *
2215
+ * @param zoomLevel - The new zoom level.
2216
+ */
2217
+ setZoomLevel(zoomLevel?: number): void;
2218
+ /**
2219
+ * Query a camera zoom level of the active scene.
2220
+ * @returns The zoom level of the block's camera.
2221
+ */
2222
+ getZoomLevel(): number;
2223
+ /**
2224
+ * Sets the zoom and focus to show a block.
2225
+ * Only has an effect if the zoom level is not handled by the UI.
2226
+ * Without padding, this results in a tight view on the block.
2227
+ *
2228
+ * @param id - The block that should be focused on.
2229
+ * @param paddingLeft - Optional padding in screen pixels to the left of the block.
2230
+ * @param paddingTop - Optional padding in screen pixels to the top of the block.
2231
+ * @param paddingRight - Optional padding in screen pixels to the right of the block.
2232
+ * @param paddingBottom - Optional padding in screen pixels to the bottom of the block.
2233
+ * @returns A promise that resolves once the zoom was set or rejects with an error otherwise.
2234
+ */
2235
+ zoomToBlock(id: DesignBlockId, paddingLeft?: number, paddingTop?: number, paddingRight?: number, paddingBottom?: number): Promise<void>;
2236
+ /**
2237
+ * Converts all values of the current scene into the given design unit.
2238
+ * @param designUnit - The new design unit of the scene
2239
+ */
2240
+ unstable_setDesignUnit(designUnit: DesignUnit): void;
2241
+ /**
2242
+ * Returns the design unit of the current scene.
2243
+ * @returns The current design unit.
2244
+ */
2245
+ unstable_getDesignUnit(): DesignUnit;
2246
+ }
2247
+
2248
+ /** @public */
2249
+ export declare interface Size2 {
2250
+ width: number;
2251
+ height: number;
2252
+ }
2253
+
2254
+ /**
2255
+ * - Absolute: Size in absolute design units.
2256
+ * - Percent: Size in relation to the block's parent's size in percent, where 1.0 means 100%.
2257
+ * - Auto: Size is automatically determined
2258
+ *
2259
+ * @public
2260
+ */
2261
+ export declare type SizeMode = 'Absolute' | 'Percent' | 'Auto';
2262
+
2263
+ /** @public */
2264
+ export declare interface SpotColor {
2265
+ name: string;
2266
+ rgbApproximation: RGBAColor;
2267
+ cmykApproximation: CMYKColor;
2268
+ }
2269
+
2270
+ /** @public */
2271
+ export declare type StrokeCornerGeometry = 'Bevel' | 'Miter' | 'Round';
2272
+
2273
+ /** @public */
2274
+ export declare type StrokePosition = 'Center' | 'Inner' | 'Outer';
2275
+
2276
+ /** @public */
2277
+ export declare type StrokeStyle = 'Dashed' | 'DashedRound' | 'Dotted' | 'LongDashed' | 'LongDashedRound' | 'Solid';
2278
+
2279
+ /** @public */
2280
+ declare type Subscription = number;
2281
+
2282
+ /** @public */
2283
+ declare type TemplateDefinition = Preset & {
2284
+ label: string;
2285
+ scene: string | URL | (() => Promise<string>);
2286
+ thumbnailURL?: string | URL;
2287
+ };
2288
+
2289
+ /** @public */
2290
+ declare type TypefaceDefinition = Preset & {
2291
+ family: string;
2292
+ fonts: {
2293
+ fontURL: string;
2294
+ weight: FontWeight;
2295
+ style: FontStyle;
2296
+ }[];
2297
+ };
2298
+
2299
+ /**
2300
+ * @public
2301
+ */
2302
+ export declare class VariableAPI {
2303
+ #private;
2304
+
2305
+ /**
2306
+ * Get all text variables currently stored in the engine.
2307
+ * @returns Return a list of variable names
2308
+ */
2309
+ findAll(): string[];
2310
+ /**
2311
+ * Set a text variable.
2312
+ * @param key - The variable's key.
2313
+ * @param value - The text to replace the variable with.
2314
+ */
2315
+ setString(key: string, value: string): void;
2316
+ /**
2317
+ * Set a text variable.
2318
+ * @param key - The variable's key.
2319
+ * @returns The text value of the variable.
2320
+ */
2321
+ getString(key: string): string;
2322
+ /**
2323
+ * Destroy a text variable.
2324
+ * @param key - The variable's key.
2325
+ */
2326
+ remove(key: string): void;
2327
+ }
2328
+
2329
+ /** @public */
2330
+ declare type VariableDefinition = Preset & {
2331
+ value: string | number;
2332
+ };
2333
+
2334
+ /** @public */
2335
+ declare type Variables = {
2336
+ [id: string]: VariableDefinition;
2337
+ };
2338
+
2339
+ /** @public */
2340
+ export declare interface Vec2 {
2341
+ x: number;
2342
+ y: number;
2343
+ }
2344
+
2345
+ /** @public */
2346
+ export declare interface Vec3 {
2347
+ x: number;
2348
+ y: number;
2349
+ z: number;
2350
+ }
2351
+
2352
+ /** @public */
2353
+ export declare interface Vec4 {
2354
+ x: number;
2355
+ y: number;
2356
+ z: number;
2357
+ w: number;
2358
+ }
2359
+
2360
+ export { }