@cesdk/cesdk-js 1.9.1 → 1.10.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -25,21 +25,24 @@ export declare class API {
25
25
  */
26
26
  export declare interface Asset {
27
27
  /**
28
- * Is a combination of source id, extension pack id (optional), type and asset id
29
- * e.g. "extension://ly.img.cesdk.images.samples/ly.img.image/sample.1"
28
+ * The unique id of this asset.
30
29
  */
31
30
  id: string;
32
- /** E.g. `ly.img.image` */
33
31
  /** Groups of the asset. */
34
32
  groups?: Groups;
35
- /** URI to a thumbnail of the asset used e.g. in the content library UI */
36
- thumbUri: string;
37
-
38
33
  /** Asset-specific and custom meta information */
39
34
  meta?: {
35
+ /** The mime type of this asset or the data behind the asset's uri. */
36
+ mimeType?: string;
37
+ /** The type id of the design block that should be created from this asset. */
38
+ blockType?: string;
40
39
  uri?: string;
40
+ thumbUri?: string;
41
+ previewUri?: string;
41
42
  filename?: string;
42
43
  vectorPath?: string;
44
+ width?: number;
45
+ height?: number;
43
46
  duration?: string;
44
47
  } & Record<string, unknown>;
45
48
  }
@@ -55,6 +58,16 @@ export declare class AssetAPI {
55
58
  * @param source - The asset source.
56
59
  */
57
60
  addSource(source: AssetSource): void;
61
+ /**
62
+ * Adds a local asset source. Its ID has to be unique.
63
+ * @param source - The asset source.
64
+ * @param supportedMimeTypes - The mime types of assets that are allowed to be added to this local source.
65
+ * @param applyAsset - An optional callback that can be used to override the default behavior of applying a given
66
+ * asset result to the active scene.
67
+ * @param applyAssetToBlock - An optional callback that can be used to override the default behavior of applying
68
+ * an asset result to a given block.
69
+ */
70
+ addLocalSource(id: string, supportedMimeTypes?: string[], applyAsset?: (asset: AssetResult) => Promise<DesignBlockId | undefined>, applyAssetToBlock?: (asset: AssetResult, block: DesignBlockId) => Promise<void>): void;
58
71
  /**
59
72
  * Removes an asset source with the given ID.
60
73
  * @param id - The ID to refer to the asset source.
@@ -78,6 +91,7 @@ export declare class AssetAPI {
78
91
  * @returns The asset groups.
79
92
  */
80
93
  getGroups(id: string): Promise<string[]>;
94
+ getSupportedMimeTypes(sourceId: string): string[];
81
95
  /**
82
96
  * Queries the asset source's credits info.
83
97
  * @param sourceId - The ID of the asset source.
@@ -97,8 +111,18 @@ export declare class AssetAPI {
97
111
  url: string | undefined;
98
112
  } | undefined;
99
113
  canManageAssets(sourceId: string): boolean;
100
-
101
-
114
+ /**
115
+ * Adds the given asset to a local asset source.
116
+ * @param sourceId - The local asset source ID that the asset should be added to.
117
+ * @param asset - The asset to be added to the asset source.
118
+ */
119
+ addAssetToSource(sourceId: string, asset: AssetDefinition): void;
120
+ /**
121
+ * Removes the specified asset from its local asset source.
122
+ * @param sourceId - The id of the local asset source that currently contains the asset.
123
+ * @param assetId - The id of the asset to be removed.
124
+ */
125
+ removeAssetFromSource(sourceId: string, assetId: string): void;
102
126
 
103
127
 
104
128
  /**
@@ -108,7 +132,7 @@ export declare class AssetAPI {
108
132
  * @param sourceId - The ID of the asset source.
109
133
  * @param assetResult - A single assetResult of a `findAssets` query.
110
134
  */
111
- apply(sourceId: string, assetResult: AssetResult): Promise<void>;
135
+ apply(sourceId: string, assetResult: AssetResult): Promise<DesignBlockId | undefined>;
112
136
  /**
113
137
  * Apply an asset result to the given block.
114
138
  * @param sourceId - The ID of the asset source.
@@ -121,7 +145,7 @@ export declare class AssetAPI {
121
145
  * This implementation is used when no `applyAsset` function is provided to `addSource`.
122
146
  * @param assetResult - A single assetResult of a `findAssets` query.
123
147
  */
124
- defaultApplyAsset(assetResult: AssetResult): Promise<void>;
148
+ defaultApplyAsset(assetResult: AssetResult): Promise<DesignBlockId | undefined>;
125
149
  /**
126
150
  * The default implementation for applying an asset to an existing block.
127
151
  * @param assetResult - A single assetResult of a `findAssets` query.
@@ -132,7 +156,7 @@ export declare class AssetAPI {
132
156
  }
133
157
 
134
158
  /**
135
- * Definition of an assets used if an asset is added to an asset source.
159
+ * Definition of an asset used if an asset is added to an asset source.
136
160
  * @public
137
161
  */
138
162
  export declare interface AssetDefinition extends Asset {
@@ -150,14 +174,6 @@ export declare interface AssetDefinition extends Asset {
150
174
  tags?: Record<Locale, string[]>;
151
175
  }
152
176
 
153
- /** @public */
154
- export declare interface _AssetElement {
155
- id: string;
156
- name: string;
157
- uri: string;
158
- thumbUri: string;
159
- }
160
-
161
177
  /** @public */
162
178
  declare type AssetLibraryEntries = AssetLibraryEntry[] | ((currentAssetLibraryEntries: AssetLibraryEntry[], context: {
163
179
  selectedBlocks: {
@@ -297,13 +313,6 @@ export declare interface AssetResult extends Asset {
297
313
  declare interface AssetResult_2 {
298
314
  /** A unique id of this asset */
299
315
  id: string;
300
- /** URI to a thumbnail of the asset used e.g. in the content library UI */
301
- thumbUri: string;
302
- /** Original size of the asset. */
303
- size: {
304
- width: number;
305
- height: number;
306
- };
307
316
  /** Asset-specific and custom meta information */
308
317
  meta?: {
309
318
  uri?: string;
@@ -371,16 +380,17 @@ export declare interface AssetSource {
371
380
  */
372
381
  getAsset?(id: string): Promise<AssetResult | undefined>;
373
382
  /**
374
- * Can the source add, update and remove assets dynamically? If `false`
375
- * methods like `addAsset` `updateAsset` and `removeAsset` will throw an
383
+ * Can the source add and remove assets dynamically? If `false`
384
+ * methods like `addAsset` and `removeAsset` will throw an
376
385
  * error.
377
386
  */
378
387
  canManageAssets?: boolean;
379
388
  /**
380
389
  * Apply the given asset result to the active scene.
381
390
  * You can override this with custom behavior.
391
+ * @returns the id of a new block if one was created from the asset.
382
392
  */
383
- applyAsset?: (asset: AssetResult) => Promise<void>;
393
+ applyAsset?: (asset: AssetResult) => Promise<DesignBlockId | undefined>;
384
394
  /**
385
395
  * Apply the given asset result to the given block.
386
396
  * You can override this with custom behavior.
@@ -390,16 +400,8 @@ export declare interface AssetSource {
390
400
  * Adds the given asset to this source. Throws an error if `canManageAssets`
391
401
  * is `false`.
392
402
  *
393
- * @returns the id of the added asset
394
403
  */
395
- addAsset?(asset: AssetDefinition): Promise<string>;
396
- /**
397
- * Updates the asset of this source. Throws an error if `canManageAssets`
398
- * is `false` or no asset with the given id could not be found.
399
- *
400
- * @returns the id of the added asset
401
- */
402
- updateAsset?(assetId: string, asset: AssetDefinition): Promise<void>;
404
+ addAsset?(asset: AssetDefinition): void;
403
405
  /**
404
406
  * Removes the given asset from this source.
405
407
  *
@@ -425,7 +427,7 @@ declare interface AssetSource_2 {
425
427
  * Apply the given asset result to the active scene.
426
428
  * You can override this with custom behavior.
427
429
  */
428
- applyAsset?: (asset: AssetResult_2) => Promise<void>;
430
+ applyAsset?: (asset: AssetResult_2) => Promise<DesignBlockId | undefined>;
429
431
  /**
430
432
  * Apply the given asset result to the given block.
431
433
  * You can override this with custom behavior.
@@ -561,6 +563,7 @@ export declare class BlockAPI {
561
563
  /**
562
564
  * Loads existing blocks from the given string.
563
565
  * The blocks are not attached by default and won't be visible until attached to a page or the scene.
566
+ * The UUID of the loaded blocks is replaced with a new one.
564
567
  * @param content - A string representing the given blocks.
565
568
  * @returns A promise that resolves with a list of handles representing the found blocks or an error.
566
569
  */
@@ -584,13 +587,17 @@ export declare class BlockAPI {
584
587
  * @returns The created fill's handle.
585
588
  */
586
589
  createFill(type: string): DesignBlockId;
587
-
588
590
  /**
589
591
  * Get the type of the given block, fails if the block is invalid.
590
592
  * @param id - The block to query.
591
593
  * @returns The blocks type.
592
594
  */
593
595
  getType(id: DesignBlockId): DesignBlockType;
596
+ /**
597
+ * Selects the given block and deselects all other blocks.
598
+ * @param id - The block to be selected.
599
+ */
600
+ select(id: DesignBlockId): void;
594
601
  /**
595
602
  * Update the selection state of a block.
596
603
  * Fails for invalid blocks.
@@ -855,15 +862,29 @@ export declare class BlockAPI {
855
862
  */
856
863
  setContentFillMode(id: DesignBlockId, mode: ContentFillMode): void;
857
864
  /**
858
- * Get a block's layout width. The layout width is only available after an
859
- * internal update loop, which may not happen immediately.
865
+ * Get a block's layout position on the x-axis. The position is only available after an
866
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
867
+ * @param id - The block to query.
868
+ * @returns The layout position on the x-axis.
869
+ */
870
+ getFrameX(id: DesignBlockId): number;
871
+ /**
872
+ * Get a block's layout position on the y-axis. The position is only available after an
873
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
874
+ * @param id - The block to query.
875
+ * @returns The layout position on the y-axis.
876
+ */
877
+ getFrameY(id: DesignBlockId): number;
878
+ /**
879
+ * Get a block's layout width. The width is only available after an
880
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
860
881
  * @param id - The block to query.
861
882
  * @returns The layout width.
862
883
  */
863
884
  getFrameWidth(id: DesignBlockId): number;
864
885
  /**
865
- * Get a block's layout height. The layout height is only available after an
866
- * internal update loop, which may not happen immediately.
886
+ * Get a block's layout height. The height is only available after an
887
+ * internal update loop which only occurs if the `features/implicitUpdatesEnabled` setting is set.
867
888
  * @param id - The block to query.
868
889
  * @returns The layout height.
869
890
  */
@@ -1990,6 +2011,48 @@ export declare class BlockAPI {
1990
2011
  * @returns Whether solo playback is enabled for this block.
1991
2012
  */
1992
2013
  isSoloPlaybackEnabled(id: DesignBlockId): boolean;
2014
+ /**
2015
+ * Returns whether the block supports a playback control.
2016
+ * @param block - The block to query.
2017
+ * @returns Whether the block has playback control.
2018
+ */
2019
+ hasPlaybackControl(id: DesignBlockId): boolean;
2020
+ /**
2021
+ * Set whether the block should start from the beginning again or stop.
2022
+ * @param block - The block or video fill to update.
2023
+ * @param looping - Whether the block should loop to the beginning or stop.
2024
+ */
2025
+ setLooping(id: DesignBlockId, looping: boolean): void;
2026
+ /**
2027
+ * Query whether the block is looping.
2028
+ * @param block - The block to query.
2029
+ * @returns Whether the block is looping.
2030
+ */
2031
+ isLooping(id: DesignBlockId): boolean;
2032
+ /**
2033
+ * Set whether the audio of the block is muted.
2034
+ * @param block - The block or video fill to update.
2035
+ * @param muted - Whether the audio should be muted.
2036
+ */
2037
+ setMuted(id: DesignBlockId, muted: boolean): void;
2038
+ /**
2039
+ * Query whether the block is muted.
2040
+ * @param block - The block to query.
2041
+ * @returns Whether the block is muted.
2042
+ */
2043
+ isMuted(id: DesignBlockId): boolean;
2044
+ /**
2045
+ * Set the audio volume of the given block.
2046
+ * @param block - The block or video fill to update.
2047
+ * @param volume - The desired volume with a range of [0, 1].
2048
+ */
2049
+ setVolume(id: DesignBlockId, volume: number): void;
2050
+ /**
2051
+ * Get the audio volume of the given block.
2052
+ * @param block - The block to query.
2053
+ * @returns The volume with a range of [0, 1].
2054
+ */
2055
+ getVolume(id: DesignBlockId): number;
1993
2056
  /**
1994
2057
  * Begins loading the required audio and video resource for the given video fill or audio block.
1995
2058
  * @param id - The video fill or audio block whose resource should be loaded.
@@ -2088,9 +2151,6 @@ declare namespace ConfigTypes {
2088
2151
  _RequiredConfiguration as Configuration,
2089
2152
  Theme,
2090
2153
  Scale,
2091
- PartialImageElement,
2092
- PartialVideoElement,
2093
- PartialAudioElement,
2094
2154
  I18n,
2095
2155
  A11y,
2096
2156
  OnUploadCallback,
@@ -2186,16 +2246,6 @@ declare class CreativeEditorSDK {
2186
2246
  setVariableDefinitions(definitions: {
2187
2247
  [id: string]: _EngineConfigTypes.VariableDefinition;
2188
2248
  }): Promise<void>;
2189
- /**
2190
- * Adds an image definition which can be used in the image library.
2191
- *
2192
- * @param definitions - image definitions
2193
- *
2194
- * @returns a resolved promise if all images were add successfully
2195
- */
2196
- setImageDefinitions(definitions: {
2197
- [id: string]: _EngineConfigTypes.ImageDefinition;
2198
- }): Promise<void[]>;
2199
2249
  /**
2200
2250
  * Adds translations to be used by the editor.
2201
2251
  *
@@ -2469,6 +2519,16 @@ export declare class EditorAPI {
2469
2519
  * @returns The value as string.
2470
2520
  */
2471
2521
  getSettingEnum(keypath: string): string;
2522
+ /**
2523
+ * Get the currently available memory in bytes.
2524
+ * @returns The currently available memory in bytes.
2525
+ */
2526
+ getAvailableMemory(): number;
2527
+ /**
2528
+ * Get the current memory usage of the engine in bytes.
2529
+ * @returns The current memory usage in bytes.
2530
+ */
2531
+ getUsedMemory(): number;
2472
2532
  /**
2473
2533
  * Sets a custom URI resolver.
2474
2534
  * This function can be called more than once. Subsequent calls will overwrite previous calls.
@@ -2796,15 +2856,6 @@ declare type ImageDefinition = Preset & {
2796
2856
  };
2797
2857
  };
2798
2858
 
2799
- /** @public */
2800
- export declare interface _ImageElement extends _AssetElement {
2801
- previewUri?: string;
2802
- size: {
2803
- width: number;
2804
- height: number;
2805
- };
2806
- }
2807
-
2808
2859
  /**
2809
2860
  * e.g. `en`, `de`, etc.
2810
2861
  * @public
@@ -2840,7 +2891,7 @@ declare enum NavigationPosition {
2840
2891
  }
2841
2892
 
2842
2893
  /** @public */
2843
- declare type OnUploadCallback = (file: File, onProgress: (progress: number) => void) => Promise<PartialImageElement | PartialVideoElement | PartialAudioElement>;
2894
+ declare type OnUploadCallback = (file: File, onProgress: (progress: number) => void) => Promise<AssetDefinition>;
2844
2895
 
2845
2896
  /** @public */
2846
2897
  declare type OnUploadOptions = {
@@ -2888,15 +2939,6 @@ declare enum PanelPosition {
2888
2939
  Right = "right"
2889
2940
  }
2890
2941
 
2891
- /** @public */
2892
- declare type PartialAudioElement = Optional<AudioElement, 'duration'>;
2893
-
2894
- /** @public */
2895
- declare type PartialImageElement = Optional<_ImageElement, 'size'>;
2896
-
2897
- /** @public */
2898
- declare type PartialVideoElement = Optional<VideoElement, 'size' | 'duration'>;
2899
-
2900
2942
  /**
2901
2943
  * - Absolute: Position in absolute design units.
2902
2944
  * - Percent: Position in relation to the block's parent's size in percent, where 1.0 means 100%.
@@ -3106,6 +3148,11 @@ export declare class SceneAPI {
3106
3148
  * @returns The current mode of the scene.
3107
3149
  */
3108
3150
  getMode(): SceneMode;
3151
+ /**
3152
+ * Get the sorted list of pages in the scene.
3153
+ * @returns The sorted list of pages in the scene.
3154
+ */
3155
+ getPages(): DesignBlockId[];
3109
3156
  /**
3110
3157
  * Sets the zoom level of the active scene.
3111
3158
  * Only has an effect if the zoom level is not handled by the UI.
@@ -3288,6 +3335,8 @@ declare namespace UserInterfaceElements {
3288
3335
  UserInterfaceInspectorBlockPage,
3289
3336
  UserInterfaceInspectorBlockText,
3290
3337
  UserInterfaceInspectorBlockImage,
3338
+ UserInterfaceInspectorBlockVideoFill,
3339
+ UserInterfaceInspectorBlockRectShape,
3291
3340
  UserInterfaceInspector,
3292
3341
  UserInterfaceSettings,
3293
3342
  UserInterfaceAssetLibrary,
@@ -3373,12 +3422,22 @@ declare interface UserInterfaceInspectorBlockPage extends UserInterfaceInspector
3373
3422
  manage?: UserInterfaceElement | boolean;
3374
3423
  }
3375
3424
 
3425
+ /** @public */
3426
+ declare interface UserInterfaceInspectorBlockRectShape extends UserInterfaceInspectorBlock {
3427
+ filters?: UserInterfaceElement | boolean;
3428
+ adjustments?: UserInterfaceElement | boolean;
3429
+ effects?: UserInterfaceElement | boolean;
3430
+ blur?: UserInterfaceElement | boolean;
3431
+ }
3432
+
3376
3433
  /** @public */
3377
3434
  declare interface UserInterfaceInspectorBlocks {
3378
3435
  opacity?: UserInterfaceElement | boolean;
3379
3436
  transform?: UserInterfaceElement | boolean;
3380
3437
  trim?: UserInterfaceElement | boolean;
3381
3438
  '//ly.img.ubq/image'?: UserInterfaceInspectorBlockImage;
3439
+ '//ly.img.ubq/fill/video': UserInterfaceInspectorBlockVideoFill;
3440
+ '//ly.img.ubq/shapes/rect': UserInterfaceInspectorBlockRectShape;
3382
3441
  '//ly.img.ubq/text'?: UserInterfaceInspectorBlockText;
3383
3442
  '//ly.img.ubq/page'?: UserInterfaceInspectorBlockPage;
3384
3443
  }
@@ -3389,6 +3448,15 @@ declare interface UserInterfaceInspectorBlockText extends UserInterfaceInspector
3389
3448
  color?: UserInterfaceElement | boolean;
3390
3449
  }
3391
3450
 
3451
+ /** @public */
3452
+ declare interface UserInterfaceInspectorBlockVideoFill extends UserInterfaceInspectorBlock {
3453
+ crop?: UserInterfaceElement | boolean;
3454
+ filters?: UserInterfaceElement | boolean;
3455
+ adjustments?: UserInterfaceElement | boolean;
3456
+ effects?: UserInterfaceElement | boolean;
3457
+ blur?: UserInterfaceElement | boolean;
3458
+ }
3459
+
3392
3460
  /** @public */
3393
3461
  declare interface UserInterfaceNavigation extends UserInterfaceElement {
3394
3462
  position?: NavigationPosition;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/cesdk-js",
3
- "version": "1.9.1",
3
+ "version": "1.10.0-preview.0",
4
4
  "main": "./cesdk.umd.js",
5
5
  "types": "./index.d.ts",
6
6
  "homepage": "https://www.img.ly",