@cesdk/cesdk-js 1.9.0-preview.2 → 1.9.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
@@ -40,6 +40,7 @@ export declare interface Asset {
40
40
  uri?: string;
41
41
  filename?: string;
42
42
  vectorPath?: string;
43
+ duration?: string;
43
44
  } & Record<string, unknown>;
44
45
  }
45
46
 
@@ -98,6 +99,8 @@ export declare class AssetAPI {
98
99
  canManageAssets(sourceId: string): boolean;
99
100
 
100
101
 
102
+
103
+
101
104
  /**
102
105
  * Apply an asset result to the active scene.
103
106
  * The default behavior will instantiate a block and configure it according to the asset's properties.
@@ -106,12 +109,25 @@ export declare class AssetAPI {
106
109
  * @param assetResult - A single assetResult of a `findAssets` query.
107
110
  */
108
111
  apply(sourceId: string, assetResult: AssetResult): Promise<void>;
112
+ /**
113
+ * Apply an asset result to the given block.
114
+ * @param sourceId - The ID of the asset source.
115
+ * @param assetResult - A single assetResult of a `findAssets` query.
116
+ * @param block - The block the asset should be applied to.
117
+ */
118
+ applyToBlock(sourceId: string, assetResult: AssetResult, block: DesignBlockId): Promise<void>;
109
119
  /**
110
120
  * The default implementation for applying an asset to the scene.
111
121
  * This implementation is used when no `applyAsset` function is provided to `addSource`.
112
122
  * @param assetResult - A single assetResult of a `findAssets` query.
113
123
  */
114
124
  defaultApplyAsset(assetResult: AssetResult): Promise<void>;
125
+ /**
126
+ * The default implementation for applying an asset to an existing block.
127
+ * @param assetResult - A single assetResult of a `findAssets` query.
128
+ * @param block - The block to apply the asset result to.
129
+ */
130
+ defaultApplyAssetToBlock(assetResult: AssetResult, block: DesignBlockId): Promise<void>;
115
131
 
116
132
  }
117
133
 
@@ -143,7 +159,13 @@ export declare interface _AssetElement {
143
159
  }
144
160
 
145
161
  /** @public */
146
- declare type AssetLibraryEntries = AssetLibraryEntry[] | ((currentAssetLibraryEntries: AssetLibraryEntry[]) => AssetLibraryEntry[]);
162
+ declare type AssetLibraryEntries = AssetLibraryEntry[] | ((currentAssetLibraryEntries: AssetLibraryEntry[], context: {
163
+ selectedBlocks: {
164
+ id: DesignBlockId;
165
+ blockType: DesignBlockType;
166
+ fillType?: DesignBlockType;
167
+ }[];
168
+ }) => AssetLibraryEntry[]);
147
169
 
148
170
  /** @public */
149
171
  declare interface AssetLibraryEntry extends AssetLibraryEntryData, AssetLibraryEntryView {
@@ -286,6 +308,7 @@ declare interface AssetResult_2 {
286
308
  meta?: {
287
309
  uri?: string;
288
310
  filename?: string;
311
+ duration?: string;
289
312
  } & Record<string, unknown>;
290
313
  /** The locale of the label and tags */
291
314
  locale?: string;
@@ -358,6 +381,11 @@ export declare interface AssetSource {
358
381
  * You can override this with custom behavior.
359
382
  */
360
383
  applyAsset?: (asset: AssetResult) => Promise<void>;
384
+ /**
385
+ * Apply the given asset result to the given block.
386
+ * You can override this with custom behavior.
387
+ */
388
+ applyAssetToBlock?: (asset: AssetResult, block: DesignBlockId) => Promise<void>;
361
389
  /**
362
390
  * Adds the given asset to this source. Throws an error if `canManageAssets`
363
391
  * is `false`.
@@ -378,6 +406,12 @@ export declare interface AssetSource {
378
406
  * @returns true if asset was found and removed, and false otherwise
379
407
  */
380
408
  removeAsset?(assetId: string): Promise<boolean>;
409
+ /**
410
+ * Generates a list of supported mime types for this source.
411
+ *
412
+ * @returns a list of the mime types should be supported by this source
413
+ */
414
+ getSupportedMimeTypes?(): string[] | undefined;
381
415
  }
382
416
 
383
417
  /**
@@ -392,6 +426,12 @@ declare interface AssetSource_2 {
392
426
  * You can override this with custom behavior.
393
427
  */
394
428
  applyAsset?: (asset: AssetResult_2) => Promise<void>;
429
+ /**
430
+ * Apply the given asset result to the given block.
431
+ * You can override this with custom behavior.
432
+ */
433
+ applyAssetToBlock?: (asset: AssetResult_2, block: number) => Promise<void>;
434
+
395
435
  /** Return every available group */
396
436
  getGroups?: () => Promise<string[]>;
397
437
  /**
@@ -412,6 +452,13 @@ declare interface AssetSource_2 {
412
452
  name: string;
413
453
  url?: string;
414
454
  };
455
+
456
+ /**
457
+ * Generates a list of supported mime types for this source.
458
+ *
459
+ * @returns a list of the mime types should be supported by this source
460
+ */
461
+ getSupportedMimeTypes?(): string[] | undefined;
415
462
  }
416
463
 
417
464
  /** @public */
@@ -549,6 +596,12 @@ export declare class BlockAPI {
549
596
  * @returns An array of block ids.
550
597
  */
551
598
  findAllSelected(): DesignBlockId[];
599
+ /**
600
+ * Subscribe to changes in the current set of selected blocks.
601
+ * @param callback - This function is called at the end of the engine update if the selection has changed.
602
+ * @returns A method to unsubscribe.
603
+ */
604
+ onSelectionChanged(callback: () => void): () => void;
552
605
  /**
553
606
  * Confirms that a given set of blocks can be grouped together.
554
607
  * @param ids - A non-empty array of block ids.
@@ -1012,6 +1065,29 @@ export declare class BlockAPI {
1012
1065
  * @returns A tuple of channels red, green, blue and alpha in the range of 0 to 1.
1013
1066
  */
1014
1067
  getColorRGBA(id: DesignBlockId, property: string): RGBA;
1068
+ /**
1069
+ * Set a color property of the given design block to the given value.
1070
+ * @param id - The block whose property should be set.
1071
+ * @param property - The name of the property to set.
1072
+ * @param name - The name of the spot color.
1073
+ * @param tint - The tint factor in the range of 0 to 1.
1074
+ * @returns An empty result on success, an error otherwise.
1075
+ */
1076
+ setColorSpot(id: DesignBlockId, property: string, name: string, tint?: number): void;
1077
+ /**
1078
+ * Get the spot color name of a color property of the given design block.
1079
+ * @param id - The block whose property should be queried.
1080
+ * @param property - The name of the property to query.
1081
+ * @returns A result holding the name of the spot color or an error.
1082
+ */
1083
+ getColorSpotName(id: DesignBlockId, property: string): string;
1084
+ /**
1085
+ * Get the spot color tint factor of a color property of the given design block.
1086
+ * @param id - The block whose property should be queried.
1087
+ * @param property - The name of the property to query.
1088
+ * @returns A result holding the tint factor of the spot color or an error.
1089
+ */
1090
+ getColorSpotTint(id: DesignBlockId, property: string): number;
1015
1091
  /**
1016
1092
  * Set an enum property of the given design block to the given value.
1017
1093
  * @param id - The block whose property should be set.
@@ -1916,17 +1992,28 @@ export declare class BlockAPI {
1916
1992
  /**
1917
1993
  * Generate a thumbnail for the given video fill.
1918
1994
  * @param id - The video fill.
1919
- * @returns A thumbnail encoded as JPEG with a height of 128px.
1995
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
1996
+ * @returns A thumbnail encoded as JPEG.
1920
1997
  */
1921
- getVideoFillThumbnail(id: DesignBlockId): Promise<Blob>;
1998
+ getVideoFillThumbnail(id: DesignBlockId, thumbnailHeight: number): Promise<Blob>;
1922
1999
  /**
1923
2000
  * Generate a thumbnail atlas for the given video fill.
1924
2001
  * @param id - The video fill.
1925
2002
  * @param numberOfColumns - The number of columns to generate.
1926
2003
  * @param numberOfRows - The number of rows to generate.
2004
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
1927
2005
  * @returns A thumbnail atlas of the video as JPEG.
1928
2006
  */
1929
- getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number): Promise<Blob>;
2007
+ getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
2008
+ /**
2009
+ * Generate a thumbnail atlas for the given page.
2010
+ * @param id - The page.
2011
+ * @param numberOfColumns - The number of columns to generate.
2012
+ * @param numberOfRows - The number of rows to generate.
2013
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the page aspect ratio.
2014
+ * @returns A thumbnail atlas of the composition as JPEG.
2015
+ */
2016
+ getPageThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
1930
2017
  }
1931
2018
 
1932
2019
  /** @public */
@@ -1989,6 +2076,8 @@ declare namespace ConfigTypes {
1989
2076
  Theme,
1990
2077
  Scale,
1991
2078
  PartialImageElement,
2079
+ PartialVideoElement,
2080
+ PartialAudioElement,
1992
2081
  I18n,
1993
2082
  A11y,
1994
2083
  OnUploadCallback,
@@ -2052,19 +2141,19 @@ declare class CreativeEditorSDK {
2052
2141
  * @deprecated Use `loadFromString` instead.
2053
2142
  * @param scene - A string starting with UBQ1 and containing the encoded scene.
2054
2143
  */
2055
- load(scene: string): Promise<void>;
2144
+ load(scene: string): Promise<number>;
2056
2145
  /**
2057
2146
  * Load an encoded scene from the provided string.
2058
2147
  * @param scene - A string starting with UBQ1 and containing the encoded scene.
2059
2148
  * @returns a promise which resolves if the scene was successfully loaded.
2060
2149
  */
2061
- loadFromString(scene: string): Promise<void>;
2150
+ loadFromString(scene: string): Promise<number>;
2062
2151
  /**
2063
2152
  * Load the scene stored in the file at the given URL.
2064
2153
  * @param url - The url to fetch to acquire the scene string.
2065
2154
  * @returns a promise which resolves if the scene was successfully loaded.
2066
2155
  */
2067
- loadFromURL(url: string): Promise<void>;
2156
+ loadFromURL(url: string): Promise<number>;
2068
2157
  /**
2069
2158
  * Save and return a scene as a base64 encoded string.
2070
2159
  *
@@ -2161,6 +2250,7 @@ export declare enum DesignBlockType {
2161
2250
  Page = "//ly.img.ubq/page",
2162
2251
  Image = "//ly.img.ubq/image",
2163
2252
  Video = "//ly.img.ubq/video",
2253
+ VideoFill = "//ly.img.ubq/fill/video",
2164
2254
  Audio = "//ly.img.ubq/audio",
2165
2255
  Text = "//ly.img.ubq/text",
2166
2256
  Sticker = "//ly.img.ubq/sticker",
@@ -2228,6 +2318,28 @@ export declare class EditorAPI {
2228
2318
  * @returns The text cursor's y position in screen space.
2229
2319
  */
2230
2320
  getTextCursorPositionInScreenSpaceY(): number;
2321
+ /**
2322
+ * Create a history which consists of an undo/redo stack for editing operations.
2323
+ * There can be multiple. But only one can be active at a time.
2324
+ * @returns The handle of the created history.
2325
+ */
2326
+ createHistory(): HistoryId;
2327
+ /**
2328
+ * Destroy the given history, throws an error if the handle doesn't refer to a history.
2329
+ * @param history - The history to destroy.
2330
+ */
2331
+ destroyHistory(history: HistoryId): void;
2332
+ /**
2333
+ * Mark the given history as active, throws an error if the handle doesn't refer to a history.
2334
+ * All other histories get cleared from the active state. Undo/redo operations only apply to the active history.
2335
+ * @param history - The history to make active.
2336
+ */
2337
+ setActiveHistory(history: HistoryId): void;
2338
+ /**
2339
+ * Get the handle to the currently active history. If there's none it will be created.
2340
+ * @returns History - The handle of the active history.
2341
+ */
2342
+ getActiveHistory(): HistoryId;
2231
2343
  /**
2232
2344
  * Adds a new history state to the stack, if undoable changes were made.
2233
2345
  */
@@ -2252,6 +2364,13 @@ export declare class EditorAPI {
2252
2364
  * @returns True if a redo step is available.
2253
2365
  */
2254
2366
  canRedo(): boolean;
2367
+ /**
2368
+ * Subscribe to changes to the undo/redo history.
2369
+ *
2370
+ * @param callback - This function is called at the end of the engine update, if the undo/redo history has been changed.
2371
+ * @returns A method to unsubscribe
2372
+ */
2373
+ onHistoryUpdated(callback: () => void): () => void;
2255
2374
  /**
2256
2375
  * Subscribe to changes to the editor settings.
2257
2376
  * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
@@ -2373,6 +2492,34 @@ export declare class EditorAPI {
2373
2492
  * @returns `Allow` if the scope is allowed, `Deny` if it is disallowed, and `Defer` if it is deferred to the block-level.
2374
2493
  */
2375
2494
  getGlobalScope(key: string): 'Allow' | 'Deny' | 'Defer';
2495
+ /**
2496
+ * Queries the names of currently set spot colors previously set with `setSpotColorRGB`.
2497
+ * @returns The names of set spot colors.
2498
+ */
2499
+ findAllSpotColors(): string[];
2500
+ /**
2501
+ * Queries the RGB representation set for a spot color.
2502
+ * If the value of the queried spot color has not been set yet, returns the default RGB representation (of magenta).
2503
+ * The alpha value is always 1.0.
2504
+ * @param name - The name of a spot color.
2505
+ * @returns A result holding a float array of the four color components.
2506
+ */
2507
+ getSpotColorRGBA(name: string): RGBA;
2508
+ /**
2509
+ * Sets the RGB representation of a spot color.
2510
+ * Use this function to both create a new spot color or update an existing spot color.
2511
+ * @param name - The name of a spot color.
2512
+ * @param r - The red color component in the range of 0 to 1.
2513
+ * @param g - The green color component in the range of 0 to 1.
2514
+ * @param b - The blue color component in the range of 0 to 1.
2515
+ */
2516
+ setSpotColorRGB(name: string, r: number, g: number, b: number): void;
2517
+ /**
2518
+ * Removes a spot color from the list of set spot colors.
2519
+ * @param name - The name of a spot color.
2520
+ * @returns An empty result on success, an error otherwise.
2521
+ */
2522
+ removeSpotColor(name: string): void;
2376
2523
  }
2377
2524
 
2378
2525
  declare namespace _EngineConfigTypes {
@@ -2426,6 +2573,13 @@ export declare interface _EngineConfiguration {
2426
2573
  * If not configured the fallback font is used.
2427
2574
  */
2428
2575
  defaultFont?: string;
2576
+ /**
2577
+ * By default the engine tries to create a webgl2 context. If this fails it
2578
+ * falls back to trying to create a webgl1 context. If this configuration
2579
+ * option is set to true, it will no longer try to create a webgl2 context
2580
+ * and always create a webgl1 context.
2581
+ */
2582
+ forceWebGL1?: boolean;
2429
2583
  }
2430
2584
 
2431
2585
  /**
@@ -2525,7 +2679,7 @@ declare type Extensions = {
2525
2679
  /**
2526
2680
  * @public
2527
2681
  */
2528
- export declare type FillType = 'Solid' | 'Gradient';
2682
+ export declare type FillType = 'Solid' | 'Gradient' | 'Video';
2529
2683
 
2530
2684
  /** @public */
2531
2685
  declare interface FindAssetsQuery {
@@ -2598,6 +2752,12 @@ declare type Groups = string[];
2598
2752
  */
2599
2753
  declare type HexColorString = string;
2600
2754
 
2755
+ /**
2756
+ * A numerical identifier for a history stack
2757
+ * @public
2758
+ */
2759
+ export declare type HistoryId = number;
2760
+
2601
2761
  /**
2602
2762
  * I18n Settings
2603
2763
  * Note: this will append keys and not override keys
@@ -2660,11 +2820,11 @@ declare enum NavigationPosition {
2660
2820
  }
2661
2821
 
2662
2822
  /** @public */
2663
- declare type OnUploadCallback = (file: File, onProgress: (progress: number) => void) => Promise<PartialImageElement>;
2823
+ declare type OnUploadCallback = (file: File, onProgress: (progress: number) => void) => Promise<PartialImageElement | PartialVideoElement | PartialAudioElement>;
2664
2824
 
2665
2825
  /** @public */
2666
2826
  declare type OnUploadOptions = {
2667
- supportedMimeTypes: string[];
2827
+ supportedMimeTypes?: string[];
2668
2828
  };
2669
2829
 
2670
2830
  /**
@@ -2708,9 +2868,15 @@ declare enum PanelPosition {
2708
2868
  Right = "right"
2709
2869
  }
2710
2870
 
2871
+ /** @public */
2872
+ declare type PartialAudioElement = Optional<AudioElement, 'duration'>;
2873
+
2711
2874
  /** @public */
2712
2875
  declare type PartialImageElement = Optional<_ImageElement, 'size'>;
2713
2876
 
2877
+ /** @public */
2878
+ declare type PartialVideoElement = Optional<VideoElement, 'size' | 'duration'>;
2879
+
2714
2880
  /**
2715
2881
  * - Absolute: Position in absolute design units.
2716
2882
  * - Percent: Position in relation to the block's parent's size in percent, where 1.0 means 100%.
@@ -2771,6 +2937,7 @@ declare interface QueryData {
2771
2937
 
2772
2938
  /** @public */
2773
2939
  export declare interface _RequiredConfiguration extends _EngineConfiguration {
2940
+ initialSceneMode?: SceneMode;
2774
2941
  initialSceneString?: string;
2775
2942
  initialSceneURL?: string;
2776
2943
  initialImageURL?: string;
@@ -2875,7 +3042,7 @@ export declare class SceneAPI {
2875
3042
  * Create a new design scene, along with its own camera.
2876
3043
  * @returns The scene's handle.
2877
3044
  */
2878
- create(): DesignBlockId;
3045
+ create(sceneLayout?: SceneLayout): DesignBlockId;
2879
3046
  /**
2880
3047
  * Create a new scene in video mode, along with its own camera and page stack.
2881
3048
  * @returns The scene's handle.
@@ -2890,7 +3057,7 @@ export declare class SceneAPI {
2890
3057
  * @param pixelScaleFactor - The displays pixel scale factor.
2891
3058
  * @returns A promise that resolves with the scene ID on success or rejected with an error otherwise.
2892
3059
  */
2893
- createFromImage(url: string, dpi?: number, pixelScaleFactor?: number): Promise<DesignBlockId>;
3060
+ createFromImage(url: string, dpi?: number, pixelScaleFactor?: number, sceneLayout?: SceneLayout, spacing?: number, spacingInScreenSpace?: boolean): Promise<DesignBlockId>;
2894
3061
  /**
2895
3062
  * Return the currently active scene.
2896
3063
  * @returns The scene or null, if none was created yet.
@@ -2914,6 +3081,11 @@ export declare class SceneAPI {
2914
3081
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2915
3082
  */
2916
3083
  applyTemplateFromURL(url: string): Promise<void>;
3084
+ /**
3085
+ * Get the current scene mode.
3086
+ * @returns The current mode of the scene.
3087
+ */
3088
+ getMode(): SceneMode;
2917
3089
  /**
2918
3090
  * Sets the zoom level of the active scene.
2919
3091
  * Only has an effect if the zoom level is not handled by the UI.
@@ -2945,7 +3117,13 @@ export declare class SceneAPI {
2945
3117
  * @returns A method to unsubscribe.
2946
3118
  * @privateRemarks This will currently fire on _all_ changes to camera properties
2947
3119
  */
2948
- onZoomLevelChanged(callback: (zoomLevel: number) => void): () => void;
3120
+ onZoomLevelChanged(callback: () => void): () => void;
3121
+ /**
3122
+ * Subscribe to changes to the active scene rendered by the engine.
3123
+ * @param callback - This function is called at the end of the engine update, if the active scene has changed.
3124
+ * @returns A method to unsubscribe.
3125
+ */
3126
+ onActiveChanged(callback: () => void): () => void;
2949
3127
  /**
2950
3128
  * Converts all values of the current scene into the given design unit.
2951
3129
  * @param designUnit - The new design unit of the scene
@@ -2958,6 +3136,18 @@ export declare class SceneAPI {
2958
3136
  unstable_getDesignUnit(): DesignUnit;
2959
3137
  }
2960
3138
 
3139
+ /**
3140
+ * The scene layout determines how the layout stack should layout its pages.
3141
+ * @public
3142
+ */
3143
+ export declare type SceneLayout = 'Free' | 'VerticalStack' | 'HorizontalStack' | 'DepthStack';
3144
+
3145
+ /**
3146
+ * The mode of the scene defines how the editor and playback should behave.
3147
+ * @public
3148
+ */
3149
+ export declare type SceneMode = 'Design' | 'Video';
3150
+
2961
3151
  /**
2962
3152
  * - Absolute: Size in absolute design units.
2963
3153
  * - Percent: Size in relation to the block's parent's size in percent, where 1.0 means 100%.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/cesdk-js",
3
- "version": "1.9.0-preview.2",
3
+ "version": "1.9.0",
4
4
  "main": "./cesdk.umd.js",
5
5
  "types": "./index.d.ts",
6
6
  "homepage": "https://www.img.ly",