@cesdk/node 1.9.2 → 1.10.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -4,21 +4,24 @@
4
4
  */
5
5
  export declare interface Asset {
6
6
  /**
7
- * Is a combination of source id, extension pack id (optional), type and asset id
8
- * e.g. "extension://ly.img.cesdk.images.samples/ly.img.image/sample.1"
7
+ * The unique id of this asset.
9
8
  */
10
9
  id: string;
11
- /** E.g. `ly.img.image` */
12
10
  /** Groups of the asset. */
13
11
  groups?: Groups;
14
- /** URI to a thumbnail of the asset used e.g. in the content library UI */
15
- thumbUri: string;
16
-
17
12
  /** Asset-specific and custom meta information */
18
13
  meta?: {
14
+ /** The mime type of this asset or the data behind the asset's uri. */
15
+ mimeType?: string;
16
+ /** The type id of the design block that should be created from this asset. */
17
+ blockType?: string;
19
18
  uri?: string;
19
+ thumbUri?: string;
20
+ previewUri?: string;
20
21
  filename?: string;
21
22
  vectorPath?: string;
23
+ width?: number;
24
+ height?: number;
22
25
  duration?: string;
23
26
  } & Record<string, unknown>;
24
27
  }
@@ -34,6 +37,16 @@ export declare class AssetAPI {
34
37
  * @param source - The asset source.
35
38
  */
36
39
  addSource(source: AssetSource): void;
40
+ /**
41
+ * Adds a local asset source. Its ID has to be unique.
42
+ * @param source - The asset source.
43
+ * @param supportedMimeTypes - The mime types of assets that are allowed to be added to this local source.
44
+ * @param applyAsset - An optional callback that can be used to override the default behavior of applying a given
45
+ * asset result to the active scene.
46
+ * @param applyAssetToBlock - An optional callback that can be used to override the default behavior of applying
47
+ * an asset result to a given block.
48
+ */
49
+ addLocalSource(id: string, supportedMimeTypes?: string[], applyAsset?: (asset: AssetResult) => Promise<DesignBlockId | undefined>, applyAssetToBlock?: (asset: AssetResult, block: DesignBlockId) => Promise<void>): void;
37
50
  /**
38
51
  * Removes an asset source with the given ID.
39
52
  * @param id - The ID to refer to the asset source.
@@ -57,6 +70,7 @@ export declare class AssetAPI {
57
70
  * @returns The asset groups.
58
71
  */
59
72
  getGroups(id: string): Promise<string[]>;
73
+ getSupportedMimeTypes(sourceId: string): string[];
60
74
  /**
61
75
  * Queries the asset source's credits info.
62
76
  * @param sourceId - The ID of the asset source.
@@ -76,9 +90,18 @@ export declare class AssetAPI {
76
90
  url: string | undefined;
77
91
  } | undefined;
78
92
  canManageAssets(sourceId: string): boolean;
79
-
80
-
81
-
93
+ /**
94
+ * Adds the given asset to a local asset source.
95
+ * @param sourceId - The local asset source ID that the asset should be added to.
96
+ * @param asset - The asset to be added to the asset source.
97
+ */
98
+ addAssetToSource(sourceId: string, asset: AssetDefinition): void;
99
+ /**
100
+ * Removes the specified asset from its local asset source.
101
+ * @param sourceId - The id of the local asset source that currently contains the asset.
102
+ * @param assetId - The id of the asset to be removed.
103
+ */
104
+ removeAssetFromSource(sourceId: string, assetId: string): void;
82
105
 
83
106
  /**
84
107
  * Apply an asset result to the active scene.
@@ -87,7 +110,7 @@ export declare class AssetAPI {
87
110
  * @param sourceId - The ID of the asset source.
88
111
  * @param assetResult - A single assetResult of a `findAssets` query.
89
112
  */
90
- apply(sourceId: string, assetResult: AssetResult): Promise<void>;
113
+ apply(sourceId: string, assetResult: AssetResult): Promise<DesignBlockId | undefined>;
91
114
  /**
92
115
  * Apply an asset result to the given block.
93
116
  * @param sourceId - The ID of the asset source.
@@ -100,7 +123,7 @@ export declare class AssetAPI {
100
123
  * This implementation is used when no `applyAsset` function is provided to `addSource`.
101
124
  * @param assetResult - A single assetResult of a `findAssets` query.
102
125
  */
103
- defaultApplyAsset(assetResult: AssetResult): Promise<void>;
126
+ defaultApplyAsset(assetResult: AssetResult): Promise<DesignBlockId | undefined>;
104
127
  /**
105
128
  * The default implementation for applying an asset to an existing block.
106
129
  * @param assetResult - A single assetResult of a `findAssets` query.
@@ -111,7 +134,7 @@ export declare class AssetAPI {
111
134
  }
112
135
 
113
136
  /**
114
- * Definition of an assets used if an asset is added to an asset source.
137
+ * Definition of an asset used if an asset is added to an asset source.
115
138
  * @public
116
139
  */
117
140
  export declare interface AssetDefinition extends Asset {
@@ -195,13 +218,6 @@ export declare interface AssetResult extends Asset {
195
218
  declare interface AssetResult_2 {
196
219
  /** A unique id of this asset */
197
220
  id: string;
198
- /** URI to a thumbnail of the asset used e.g. in the content library UI */
199
- thumbUri: string;
200
- /** Original size of the asset. */
201
- size: {
202
- width: number;
203
- height: number;
204
- };
205
221
  /** Asset-specific and custom meta information */
206
222
  meta?: {
207
223
  uri?: string;
@@ -269,16 +285,17 @@ export declare interface AssetSource {
269
285
  */
270
286
  getAsset?(id: string): Promise<AssetResult | undefined>;
271
287
  /**
272
- * Can the source add, update and remove assets dynamically? If `false`
273
- * methods like `addAsset` `updateAsset` and `removeAsset` will throw an
288
+ * Can the source add and remove assets dynamically? If `false`
289
+ * methods like `addAsset` and `removeAsset` will throw an
274
290
  * error.
275
291
  */
276
292
  canManageAssets?: boolean;
277
293
  /**
278
294
  * Apply the given asset result to the active scene.
279
295
  * You can override this with custom behavior.
296
+ * @returns the id of a new block if one was created from the asset.
280
297
  */
281
- applyAsset?: (asset: AssetResult) => Promise<void>;
298
+ applyAsset?: (asset: AssetResult) => Promise<DesignBlockId | undefined>;
282
299
  /**
283
300
  * Apply the given asset result to the given block.
284
301
  * You can override this with custom behavior.
@@ -288,22 +305,12 @@ export declare interface AssetSource {
288
305
  * Adds the given asset to this source. Throws an error if `canManageAssets`
289
306
  * is `false`.
290
307
  *
291
- * @returns the id of the added asset
292
- */
293
- addAsset?(asset: AssetDefinition): Promise<string>;
294
- /**
295
- * Updates the asset of this source. Throws an error if `canManageAssets`
296
- * is `false` or no asset with the given id could not be found.
297
- *
298
- * @returns the id of the added asset
299
308
  */
300
- updateAsset?(assetId: string, asset: AssetDefinition): Promise<void>;
309
+ addAsset?(asset: AssetDefinition): void;
301
310
  /**
302
311
  * Removes the given asset from this source.
303
- *
304
- * @returns true if asset was found and removed, and false otherwise
305
312
  */
306
- removeAsset?(assetId: string): Promise<boolean>;
313
+ removeAsset?(assetId: string): void;
307
314
  /**
308
315
  * Generates a list of supported mime types for this source.
309
316
  *
@@ -323,7 +330,7 @@ declare interface AssetSource_2 {
323
330
  * Apply the given asset result to the active scene.
324
331
  * You can override this with custom behavior.
325
332
  */
326
- applyAsset?: (asset: AssetResult_2) => Promise<void>;
333
+ applyAsset?: (asset: AssetResult_2) => Promise<DesignBlockId | undefined>;
327
334
  /**
328
335
  * Apply the given asset result to the given block.
329
336
  * You can override this with custom behavior.
@@ -443,6 +450,7 @@ export declare class BlockAPI {
443
450
  /**
444
451
  * Loads existing blocks from the given string.
445
452
  * The blocks are not attached by default and won't be visible until attached to a page or the scene.
453
+ * The UUID of the loaded blocks is replaced with a new one.
446
454
  * @param content - A string representing the given blocks.
447
455
  * @returns A promise that resolves with a list of handles representing the found blocks or an error.
448
456
  */
@@ -466,13 +474,17 @@ export declare class BlockAPI {
466
474
  * @returns The created fill's handle.
467
475
  */
468
476
  createFill(type: string): DesignBlockId;
469
-
470
477
  /**
471
478
  * Get the type of the given block, fails if the block is invalid.
472
479
  * @param id - The block to query.
473
480
  * @returns The blocks type.
474
481
  */
475
482
  getType(id: DesignBlockId): DesignBlockType;
483
+ /**
484
+ * Selects the given block and deselects all other blocks.
485
+ * @param id - The block to be selected.
486
+ */
487
+ select(id: DesignBlockId): void;
476
488
  /**
477
489
  * Update the selection state of a block.
478
490
  * Fails for invalid blocks.
@@ -634,6 +646,46 @@ export declare class BlockAPI {
634
646
  * @param mode - The y position mode: absolute, percent or undefined.
635
647
  */
636
648
  setPositionYMode(id: DesignBlockId, mode: PositionMode): void;
649
+ /**
650
+ * Update the block's always-on-top property. If true, this blocks's global sorting order is automatically
651
+ * adjusted to be higher than all other siblings
652
+ * without this property. If more than one block is set to be always-on-top, the child order decides which is on top.
653
+ *
654
+ * @param id - the block to update.
655
+ * @param enabled - whether the block shall be always-on-top.
656
+ */
657
+ setAlwaysOnTop(id: DesignBlockId, enabled: boolean): void;
658
+ /**
659
+ * Query a block's always-on-top property.
660
+ *
661
+ * @param id - the block to query.
662
+ * @returns true if the block is set to be always-on-top, false otherwise.
663
+ */
664
+ isAlwaysOnTop(id: DesignBlockId): boolean;
665
+ /**
666
+ * Updates the sorting order of this block and all of its manually created siblings
667
+ * so that the given block has the highest sorting order.
668
+ * @param id - The id of the block to be given the highest sorting order among its siblings.
669
+ */
670
+ bringToFront(id: DesignBlockId): void;
671
+ /**
672
+ * Updates the sorting order of this block and all of its manually created siblings
673
+ * so that the given block has the lowest sorting order.
674
+ * @param id - The id of the block to be given the lowest sorting order among its siblings.
675
+ */
676
+ sendToBack(id: DesignBlockId): void;
677
+ /**
678
+ * Updates the sorting order of this block and all of its superjacent siblings
679
+ * so that the given block has a higher sorting order than the next superjacent sibling.
680
+ * @param id - The id of the block to be given a higher sorting than the next superjacent sibling.
681
+ */
682
+ bringForward(id: DesignBlockId): void;
683
+ /**
684
+ * Updates the sorting order of this block and all of its manually created and subjacent siblings
685
+ * so that the given block will have a lower sorting order than the next subjacent sibling.
686
+ * @param id - The id of the block to be given a lower sorting order than the next subjacent sibling.
687
+ */
688
+ sendBackward(id: DesignBlockId): void;
637
689
  /**
638
690
  * Query a block's rotation in radians.
639
691
  * @param id - The block to query.
@@ -700,12 +752,6 @@ export declare class BlockAPI {
700
752
  * @returns The current mode for the height: absolute, percent or auto.
701
753
  */
702
754
  getHeightMode(id: DesignBlockId): SizeMode;
703
- /**
704
- * Query a block's content fill mode.
705
- * @param id - The block to query.
706
- * @returns The current mode: crop, cover or contain.
707
- */
708
- getContentFillMode(id: DesignBlockId): ContentFillMode;
709
755
  /**
710
756
  * Update a block's width.
711
757
  * @param id - The block to update.
@@ -731,25 +777,45 @@ export declare class BlockAPI {
731
777
  */
732
778
  setHeightMode(id: DesignBlockId, mode: SizeMode): void;
733
779
  /**
734
- * Set a block's content fill mode.
735
- * @param id - The block to update.
736
- * @param mode - The content fill mode mode: crop, cover or contain.
780
+ * Get a block's layout position on the x-axis. The position is only available after an
781
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
782
+ * @param id - The block to query.
783
+ * @returns The layout position on the x-axis.
737
784
  */
738
- setContentFillMode(id: DesignBlockId, mode: ContentFillMode): void;
785
+ getFrameX(id: DesignBlockId): number;
739
786
  /**
740
- * Get a block's layout width. The layout width is only available after an
741
- * internal update loop, which may not happen immediately.
787
+ * Get a block's layout position on the y-axis. The position is only available after an
788
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
789
+ * @param id - The block to query.
790
+ * @returns The layout position on the y-axis.
791
+ */
792
+ getFrameY(id: DesignBlockId): number;
793
+ /**
794
+ * Get a block's layout width. The width is only available after an
795
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
742
796
  * @param id - The block to query.
743
797
  * @returns The layout width.
744
798
  */
745
799
  getFrameWidth(id: DesignBlockId): number;
746
800
  /**
747
- * Get a block's layout height. The layout height is only available after an
748
- * internal update loop, which may not happen immediately.
801
+ * Get a block's layout height. The height is only available after an
802
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
749
803
  * @param id - The block to query.
750
804
  * @returns The layout height.
751
805
  */
752
806
  getFrameHeight(id: DesignBlockId): number;
807
+ /**
808
+ * Set a block's content fill mode.
809
+ * @param id - The block to update.
810
+ * @param mode - The content fill mode mode: crop, cover or contain.
811
+ */
812
+ setContentFillMode(id: DesignBlockId, mode: ContentFillMode): void;
813
+ /**
814
+ * Query a block's content fill mode.
815
+ * @param id - The block to query.
816
+ * @returns The current mode: crop, cover or contain.
817
+ */
818
+ getContentFillMode(id: DesignBlockId): ContentFillMode;
753
819
  /**
754
820
  * Duplicates a block including its children.
755
821
  * @param id - The block to duplicate.
@@ -828,6 +894,12 @@ export declare class BlockAPI {
828
894
  * @returns float The height of the axis-aligned bounding box.
829
895
  */
830
896
  getGlobalBoundingBoxHeight(id: DesignBlockId): number;
897
+ /**
898
+ * Get the position and size of the axis-aligned bounding box for the given blocks in screen space.
899
+ * @param ids - The block to query.
900
+ * @returns The position and size of the bounding box.
901
+ */
902
+ getScreenSpaceBoundingBoxXYWH(ids: DesignBlockId[]): XYWH;
831
903
  /**
832
904
  * Scales the block and all of its children proportionally around the specified
833
905
  * relative anchor point.
@@ -1872,6 +1944,48 @@ export declare class BlockAPI {
1872
1944
  * @returns Whether solo playback is enabled for this block.
1873
1945
  */
1874
1946
  isSoloPlaybackEnabled(id: DesignBlockId): boolean;
1947
+ /**
1948
+ * Returns whether the block supports a playback control.
1949
+ * @param block - The block to query.
1950
+ * @returns Whether the block has playback control.
1951
+ */
1952
+ hasPlaybackControl(id: DesignBlockId): boolean;
1953
+ /**
1954
+ * Set whether the block should start from the beginning again or stop.
1955
+ * @param block - The block or video fill to update.
1956
+ * @param looping - Whether the block should loop to the beginning or stop.
1957
+ */
1958
+ setLooping(id: DesignBlockId, looping: boolean): void;
1959
+ /**
1960
+ * Query whether the block is looping.
1961
+ * @param block - The block to query.
1962
+ * @returns Whether the block is looping.
1963
+ */
1964
+ isLooping(id: DesignBlockId): boolean;
1965
+ /**
1966
+ * Set whether the audio of the block is muted.
1967
+ * @param block - The block or video fill to update.
1968
+ * @param muted - Whether the audio should be muted.
1969
+ */
1970
+ setMuted(id: DesignBlockId, muted: boolean): void;
1971
+ /**
1972
+ * Query whether the block is muted.
1973
+ * @param block - The block to query.
1974
+ * @returns Whether the block is muted.
1975
+ */
1976
+ isMuted(id: DesignBlockId): boolean;
1977
+ /**
1978
+ * Set the audio volume of the given block.
1979
+ * @param block - The block or video fill to update.
1980
+ * @param volume - The desired volume with a range of [0, 1].
1981
+ */
1982
+ setVolume(id: DesignBlockId, volume: number): void;
1983
+ /**
1984
+ * Get the audio volume of the given block.
1985
+ * @param block - The block to query.
1986
+ * @returns The volume with a range of [0, 1].
1987
+ */
1988
+ getVolume(id: DesignBlockId): number;
1875
1989
  /**
1876
1990
  * Begins loading the required audio and video resource for the given video fill or audio block.
1877
1991
  * @param id - The video fill or audio block whose resource should be loaded.
@@ -2278,6 +2392,16 @@ export declare class EditorAPI {
2278
2392
  * @returns The value as string.
2279
2393
  */
2280
2394
  getSettingEnum(keypath: string): string;
2395
+ /**
2396
+ * Get the currently available memory in bytes.
2397
+ * @returns The currently available memory in bytes.
2398
+ */
2399
+ getAvailableMemory(): number;
2400
+ /**
2401
+ * Get the current memory usage of the engine in bytes.
2402
+ * @returns The current memory usage in bytes.
2403
+ */
2404
+ getUsedMemory(): number;
2281
2405
  /**
2282
2406
  * Sets a custom URI resolver.
2283
2407
  * This function can be called more than once. Subsequent calls will overwrite previous calls.
@@ -2558,6 +2682,14 @@ declare type Page = {
2558
2682
  dimOutOfPageAreas?: boolean;
2559
2683
  };
2560
2684
 
2685
+ /** @public */
2686
+ export declare interface PageDuration {
2687
+ pageId: DesignBlockId;
2688
+ duration: number;
2689
+ start: number;
2690
+ end: number;
2691
+ }
2692
+
2561
2693
  /** @public */
2562
2694
  declare type PageFormatDefinition = Preset & {
2563
2695
  width: number;
@@ -2759,6 +2891,11 @@ export declare class SceneAPI {
2759
2891
  * @returns The current mode of the scene.
2760
2892
  */
2761
2893
  getMode(): SceneMode;
2894
+ /**
2895
+ * Get the sorted list of pages in the scene.
2896
+ * @returns The sorted list of pages in the scene.
2897
+ */
2898
+ getPages(): DesignBlockId[];
2762
2899
  /**
2763
2900
  * Sets the zoom level of the active scene.
2764
2901
  * Only has an effect if the zoom level is not handled by the UI.
@@ -2784,6 +2921,47 @@ export declare class SceneAPI {
2784
2921
  * @returns A promise that resolves once the zoom was set or rejects with an error otherwise.
2785
2922
  */
2786
2923
  zoomToBlock(id: DesignBlockId, paddingLeft?: number, paddingTop?: number, paddingRight?: number, paddingBottom?: number): Promise<void>;
2924
+ /**
2925
+ * Continually adjusts the zoom level to fit the width or height of a block's axis-aligned bounding box.
2926
+ * Only has an effect if the zoom level is not handled by the UI.
2927
+ * Without padding, this results in a tight view on the block.
2928
+ * No more than one block per scene can have zoom auto-fit enabled.
2929
+ * Calling `setZoomLevel` or `zoomToBlock` disables the continuous adjustment.
2930
+ *
2931
+ * @param id - The block for which the zoom is adjusted.
2932
+ * @param axis - The block axis for which the zoom is adjusted.
2933
+ * @param paddingBefore - Optional padding in screen pixels before the block.
2934
+ * @param paddingAfter - Optional padding in screen pixels after the block.
2935
+ */
2936
+ enableZoomAutoFit(id: DesignBlockId, axis: 'Horizontal' | 'Vertical', paddingBefore?: number, paddingAfter?: number): void;
2937
+ /**
2938
+ * Continually adjusts the zoom level to fit the width or height of a block's axis-aligned bounding box.
2939
+ * Only has an effect if the zoom level is not handled by the UI.
2940
+ * Without padding, this results in a tight view on the block.
2941
+ * Calling `setZoomLevel` or `zoomToBlock` disables the continuous adjustment.
2942
+ *
2943
+ * @param id - The block for which the zoom is adjusted.
2944
+ * @param axis - The block axis for which the zoom is adjusted.
2945
+ * @param paddingLeft - Optional padding in screen pixels to the left of the block.
2946
+ * @param paddingTop - Optional padding in screen pixels to the top of the block.
2947
+ * @param paddingRight - Optional padding in screen pixels to the right of the block.
2948
+ * @param paddingBottom - Optional padding in screen pixels to the bottom of the block.
2949
+ */
2950
+ enableZoomAutoFit(id: DesignBlockId, axis: 'Both', paddingLeft?: number, paddingTop?: number, paddingRight?: number, paddingBottom?: number): void;
2951
+ /**
2952
+ * Disables any previously set zoom auto-fit.
2953
+ *
2954
+ * @param blockOrScene - The scene or a block in the scene for which to disable a zoom auto-fit.
2955
+ */
2956
+ disableZoomAutoFit(blockOrScene: DesignBlockId): void;
2957
+ /**
2958
+ * Queries whether zoom auto-fit is enabled.
2959
+ *
2960
+ * @param blockOrScene - The scene or a block in the scene for which to disable a zoom auto-fit.
2961
+ * @returns True if the given block has auto-fit set or the scene contains a block for which auto-fit is set, false
2962
+ * otherwise.
2963
+ */
2964
+ isZoomAutoFitEnabled(blockOrScene: DesignBlockId): boolean;
2787
2965
  /**
2788
2966
  * Subscribe to changes to the zoom level.
2789
2967
  * @param callback - This function is called at the end of the engine update, if the zoom level has changed.
@@ -2937,4 +3115,15 @@ export declare interface Vec4 {
2937
3115
  w: number;
2938
3116
  }
2939
3117
 
3118
+ /**
3119
+ * Describes a rectangle on the screen
3120
+ * - `x` and `y` indicate the position
3121
+ * - `w` and `h` indicate the width and height
3122
+ * @public
3123
+ */
3124
+ export declare type XYWH = [x: number, y: number, w: number, h: number];
3125
+
3126
+ /** @public */
3127
+ export declare type ZoomAutoFitAxis = 'Horizontal' | 'Vertical' | 'Both';
3128
+
2940
3129
  export { }