@cesdk/node 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
@@ -19,6 +19,7 @@ export declare interface Asset {
19
19
  uri?: string;
20
20
  filename?: string;
21
21
  vectorPath?: string;
22
+ duration?: string;
22
23
  } & Record<string, unknown>;
23
24
  }
24
25
 
@@ -77,6 +78,8 @@ export declare class AssetAPI {
77
78
  canManageAssets(sourceId: string): boolean;
78
79
 
79
80
 
81
+
82
+
80
83
  /**
81
84
  * Apply an asset result to the active scene.
82
85
  * The default behavior will instantiate a block and configure it according to the asset's properties.
@@ -85,12 +88,25 @@ export declare class AssetAPI {
85
88
  * @param assetResult - A single assetResult of a `findAssets` query.
86
89
  */
87
90
  apply(sourceId: string, assetResult: AssetResult): Promise<void>;
91
+ /**
92
+ * Apply an asset result to the given block.
93
+ * @param sourceId - The ID of the asset source.
94
+ * @param assetResult - A single assetResult of a `findAssets` query.
95
+ * @param block - The block the asset should be applied to.
96
+ */
97
+ applyToBlock(sourceId: string, assetResult: AssetResult, block: DesignBlockId): Promise<void>;
88
98
  /**
89
99
  * The default implementation for applying an asset to the scene.
90
100
  * This implementation is used when no `applyAsset` function is provided to `addSource`.
91
101
  * @param assetResult - A single assetResult of a `findAssets` query.
92
102
  */
93
103
  defaultApplyAsset(assetResult: AssetResult): Promise<void>;
104
+ /**
105
+ * The default implementation for applying an asset to an existing block.
106
+ * @param assetResult - A single assetResult of a `findAssets` query.
107
+ * @param block - The block to apply the asset result to.
108
+ */
109
+ defaultApplyAssetToBlock(assetResult: AssetResult, block: DesignBlockId): Promise<void>;
94
110
 
95
111
  }
96
112
 
@@ -190,6 +206,7 @@ declare interface AssetResult_2 {
190
206
  meta?: {
191
207
  uri?: string;
192
208
  filename?: string;
209
+ duration?: string;
193
210
  } & Record<string, unknown>;
194
211
  /** The locale of the label and tags */
195
212
  locale?: string;
@@ -262,6 +279,11 @@ export declare interface AssetSource {
262
279
  * You can override this with custom behavior.
263
280
  */
264
281
  applyAsset?: (asset: AssetResult) => Promise<void>;
282
+ /**
283
+ * Apply the given asset result to the given block.
284
+ * You can override this with custom behavior.
285
+ */
286
+ applyAssetToBlock?: (asset: AssetResult, block: DesignBlockId) => Promise<void>;
265
287
  /**
266
288
  * Adds the given asset to this source. Throws an error if `canManageAssets`
267
289
  * is `false`.
@@ -282,6 +304,12 @@ export declare interface AssetSource {
282
304
  * @returns true if asset was found and removed, and false otherwise
283
305
  */
284
306
  removeAsset?(assetId: string): Promise<boolean>;
307
+ /**
308
+ * Generates a list of supported mime types for this source.
309
+ *
310
+ * @returns a list of the mime types should be supported by this source
311
+ */
312
+ getSupportedMimeTypes?(): string[] | undefined;
285
313
  }
286
314
 
287
315
  /**
@@ -296,6 +324,12 @@ declare interface AssetSource_2 {
296
324
  * You can override this with custom behavior.
297
325
  */
298
326
  applyAsset?: (asset: AssetResult_2) => Promise<void>;
327
+ /**
328
+ * Apply the given asset result to the given block.
329
+ * You can override this with custom behavior.
330
+ */
331
+ applyAssetToBlock?: (asset: AssetResult_2, block: number) => Promise<void>;
332
+
299
333
  /** Return every available group */
300
334
  getGroups?: () => Promise<string[]>;
301
335
  /**
@@ -316,6 +350,13 @@ declare interface AssetSource_2 {
316
350
  name: string;
317
351
  url?: string;
318
352
  };
353
+
354
+ /**
355
+ * Generates a list of supported mime types for this source.
356
+ *
357
+ * @returns a list of the mime types should be supported by this source
358
+ */
359
+ getSupportedMimeTypes?(): string[] | undefined;
319
360
  }
320
361
 
321
362
  /** @public */
@@ -437,6 +478,12 @@ export declare class BlockAPI {
437
478
  * @returns An array of block ids.
438
479
  */
439
480
  findAllSelected(): DesignBlockId[];
481
+ /**
482
+ * Subscribe to changes in the current set of selected blocks.
483
+ * @param callback - This function is called at the end of the engine update if the selection has changed.
484
+ * @returns A method to unsubscribe.
485
+ */
486
+ onSelectionChanged(callback: () => void): () => void;
440
487
  /**
441
488
  * Confirms that a given set of blocks can be grouped together.
442
489
  * @param ids - A non-empty array of block ids.
@@ -900,6 +947,29 @@ export declare class BlockAPI {
900
947
  * @returns A tuple of channels red, green, blue and alpha in the range of 0 to 1.
901
948
  */
902
949
  getColorRGBA(id: DesignBlockId, property: string): RGBA;
950
+ /**
951
+ * Set a color property of the given design block to the given value.
952
+ * @param id - The block whose property should be set.
953
+ * @param property - The name of the property to set.
954
+ * @param name - The name of the spot color.
955
+ * @param tint - The tint factor in the range of 0 to 1.
956
+ * @returns An empty result on success, an error otherwise.
957
+ */
958
+ setColorSpot(id: DesignBlockId, property: string, name: string, tint?: number): void;
959
+ /**
960
+ * Get the spot color name of a color property of the given design block.
961
+ * @param id - The block whose property should be queried.
962
+ * @param property - The name of the property to query.
963
+ * @returns A result holding the name of the spot color or an error.
964
+ */
965
+ getColorSpotName(id: DesignBlockId, property: string): string;
966
+ /**
967
+ * Get the spot color tint factor of a color property of the given design block.
968
+ * @param id - The block whose property should be queried.
969
+ * @param property - The name of the property to query.
970
+ * @returns A result holding the tint factor of the spot color or an error.
971
+ */
972
+ getColorSpotTint(id: DesignBlockId, property: string): number;
903
973
  /**
904
974
  * Set an enum property of the given design block to the given value.
905
975
  * @param id - The block whose property should be set.
@@ -1804,17 +1874,28 @@ export declare class BlockAPI {
1804
1874
  /**
1805
1875
  * Generate a thumbnail for the given video fill.
1806
1876
  * @param id - The video fill.
1807
- * @returns A thumbnail encoded as JPEG with a height of 128px.
1877
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
1878
+ * @returns A thumbnail encoded as JPEG.
1808
1879
  */
1809
- getVideoFillThumbnail(id: DesignBlockId): Promise<Blob>;
1880
+ getVideoFillThumbnail(id: DesignBlockId, thumbnailHeight: number): Promise<Blob>;
1810
1881
  /**
1811
1882
  * Generate a thumbnail atlas for the given video fill.
1812
1883
  * @param id - The video fill.
1813
1884
  * @param numberOfColumns - The number of columns to generate.
1814
1885
  * @param numberOfRows - The number of rows to generate.
1886
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
1815
1887
  * @returns A thumbnail atlas of the video as JPEG.
1816
1888
  */
1817
- getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number): Promise<Blob>;
1889
+ getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
1890
+ /**
1891
+ * Generate a thumbnail atlas for the given page.
1892
+ * @param id - The page.
1893
+ * @param numberOfColumns - The number of columns to generate.
1894
+ * @param numberOfRows - The number of rows to generate.
1895
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the page aspect ratio.
1896
+ * @returns A thumbnail atlas of the composition as JPEG.
1897
+ */
1898
+ getPageThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
1818
1899
  }
1819
1900
 
1820
1901
  /** @public */
@@ -1907,6 +1988,13 @@ export declare interface Configuration {
1907
1988
  * If not configured the fallback font is used.
1908
1989
  */
1909
1990
  defaultFont?: string;
1991
+ /**
1992
+ * By default the engine tries to create a webgl2 context. If this fails it
1993
+ * falls back to trying to create a webgl1 context. If this configuration
1994
+ * option is set to true, it will no longer try to create a webgl2 context
1995
+ * and always create a webgl1 context.
1996
+ */
1997
+ forceWebGL1?: boolean;
1910
1998
  }
1911
1999
 
1912
2000
  /**
@@ -1971,6 +2059,7 @@ export declare enum DesignBlockType {
1971
2059
  Page = "//ly.img.ubq/page",
1972
2060
  Image = "//ly.img.ubq/image",
1973
2061
  Video = "//ly.img.ubq/video",
2062
+ VideoFill = "//ly.img.ubq/fill/video",
1974
2063
  Audio = "//ly.img.ubq/audio",
1975
2064
  Text = "//ly.img.ubq/text",
1976
2065
  Sticker = "//ly.img.ubq/sticker",
@@ -2031,6 +2120,28 @@ export declare class EditorAPI {
2031
2120
  * @returns The text cursor's y position in screen space.
2032
2121
  */
2033
2122
  getTextCursorPositionInScreenSpaceY(): number;
2123
+ /**
2124
+ * Create a history which consists of an undo/redo stack for editing operations.
2125
+ * There can be multiple. But only one can be active at a time.
2126
+ * @returns The handle of the created history.
2127
+ */
2128
+ createHistory(): HistoryId;
2129
+ /**
2130
+ * Destroy the given history, throws an error if the handle doesn't refer to a history.
2131
+ * @param history - The history to destroy.
2132
+ */
2133
+ destroyHistory(history: HistoryId): void;
2134
+ /**
2135
+ * Mark the given history as active, throws an error if the handle doesn't refer to a history.
2136
+ * All other histories get cleared from the active state. Undo/redo operations only apply to the active history.
2137
+ * @param history - The history to make active.
2138
+ */
2139
+ setActiveHistory(history: HistoryId): void;
2140
+ /**
2141
+ * Get the handle to the currently active history. If there's none it will be created.
2142
+ * @returns History - The handle of the active history.
2143
+ */
2144
+ getActiveHistory(): HistoryId;
2034
2145
  /**
2035
2146
  * Adds a new history state to the stack, if undoable changes were made.
2036
2147
  */
@@ -2055,6 +2166,13 @@ export declare class EditorAPI {
2055
2166
  * @returns True if a redo step is available.
2056
2167
  */
2057
2168
  canRedo(): boolean;
2169
+ /**
2170
+ * Subscribe to changes to the undo/redo history.
2171
+ *
2172
+ * @param callback - This function is called at the end of the engine update, if the undo/redo history has been changed.
2173
+ * @returns A method to unsubscribe
2174
+ */
2175
+ onHistoryUpdated(callback: () => void): () => void;
2058
2176
  /**
2059
2177
  * Subscribe to changes to the editor settings.
2060
2178
  * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
@@ -2176,6 +2294,34 @@ export declare class EditorAPI {
2176
2294
  * @returns `Allow` if the scope is allowed, `Deny` if it is disallowed, and `Defer` if it is deferred to the block-level.
2177
2295
  */
2178
2296
  getGlobalScope(key: string): 'Allow' | 'Deny' | 'Defer';
2297
+ /**
2298
+ * Queries the names of currently set spot colors previously set with `setSpotColorRGB`.
2299
+ * @returns The names of set spot colors.
2300
+ */
2301
+ findAllSpotColors(): string[];
2302
+ /**
2303
+ * Queries the RGB representation set for a spot color.
2304
+ * If the value of the queried spot color has not been set yet, returns the default RGB representation (of magenta).
2305
+ * The alpha value is always 1.0.
2306
+ * @param name - The name of a spot color.
2307
+ * @returns A result holding a float array of the four color components.
2308
+ */
2309
+ getSpotColorRGBA(name: string): RGBA;
2310
+ /**
2311
+ * Sets the RGB representation of a spot color.
2312
+ * Use this function to both create a new spot color or update an existing spot color.
2313
+ * @param name - The name of a spot color.
2314
+ * @param r - The red color component in the range of 0 to 1.
2315
+ * @param g - The green color component in the range of 0 to 1.
2316
+ * @param b - The blue color component in the range of 0 to 1.
2317
+ */
2318
+ setSpotColorRGB(name: string, r: number, g: number, b: number): void;
2319
+ /**
2320
+ * Removes a spot color from the list of set spot colors.
2321
+ * @param name - The name of a spot color.
2322
+ * @returns An empty result on success, an error otherwise.
2323
+ */
2324
+ removeSpotColor(name: string): void;
2179
2325
  }
2180
2326
 
2181
2327
  /**
@@ -2264,7 +2410,7 @@ declare type Extensions = {
2264
2410
  /**
2265
2411
  * @public
2266
2412
  */
2267
- export declare type FillType = 'Solid' | 'Gradient';
2413
+ export declare type FillType = 'Solid' | 'Gradient' | 'Video';
2268
2414
 
2269
2415
  /** @public */
2270
2416
  declare interface FindAssetsQuery {
@@ -2328,6 +2474,12 @@ declare type Groups = string[];
2328
2474
  */
2329
2475
  declare type HexColorString = string;
2330
2476
 
2477
+ /**
2478
+ * A numerical identifier for a history stack
2479
+ * @public
2480
+ */
2481
+ export declare type HistoryId = number;
2482
+
2331
2483
  /** @public */
2332
2484
  declare type ImageDefinition = Preset & {
2333
2485
  imageURL: string;
@@ -2543,7 +2695,7 @@ export declare class SceneAPI {
2543
2695
  * Create a new design scene, along with its own camera.
2544
2696
  * @returns The scene's handle.
2545
2697
  */
2546
- create(): DesignBlockId;
2698
+ create(sceneLayout?: SceneLayout): DesignBlockId;
2547
2699
  /**
2548
2700
  * Create a new scene in video mode, along with its own camera and page stack.
2549
2701
  * @returns The scene's handle.
@@ -2558,7 +2710,7 @@ export declare class SceneAPI {
2558
2710
  * @param pixelScaleFactor - The displays pixel scale factor.
2559
2711
  * @returns A promise that resolves with the scene ID on success or rejected with an error otherwise.
2560
2712
  */
2561
- createFromImage(url: string, dpi?: number, pixelScaleFactor?: number): Promise<DesignBlockId>;
2713
+ createFromImage(url: string, dpi?: number, pixelScaleFactor?: number, sceneLayout?: SceneLayout, spacing?: number, spacingInScreenSpace?: boolean): Promise<DesignBlockId>;
2562
2714
  /**
2563
2715
  * Return the currently active scene.
2564
2716
  * @returns The scene or null, if none was created yet.
@@ -2582,6 +2734,11 @@ export declare class SceneAPI {
2582
2734
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2583
2735
  */
2584
2736
  applyTemplateFromURL(url: string): Promise<void>;
2737
+ /**
2738
+ * Get the current scene mode.
2739
+ * @returns The current mode of the scene.
2740
+ */
2741
+ getMode(): SceneMode;
2585
2742
  /**
2586
2743
  * Sets the zoom level of the active scene.
2587
2744
  * Only has an effect if the zoom level is not handled by the UI.
@@ -2613,7 +2770,13 @@ export declare class SceneAPI {
2613
2770
  * @returns A method to unsubscribe.
2614
2771
  * @privateRemarks This will currently fire on _all_ changes to camera properties
2615
2772
  */
2616
- onZoomLevelChanged(callback: (zoomLevel: number) => void): () => void;
2773
+ onZoomLevelChanged(callback: () => void): () => void;
2774
+ /**
2775
+ * Subscribe to changes to the active scene rendered by the engine.
2776
+ * @param callback - This function is called at the end of the engine update, if the active scene has changed.
2777
+ * @returns A method to unsubscribe.
2778
+ */
2779
+ onActiveChanged(callback: () => void): () => void;
2617
2780
  /**
2618
2781
  * Converts all values of the current scene into the given design unit.
2619
2782
  * @param designUnit - The new design unit of the scene
@@ -2626,6 +2789,18 @@ export declare class SceneAPI {
2626
2789
  unstable_getDesignUnit(): DesignUnit;
2627
2790
  }
2628
2791
 
2792
+ /**
2793
+ * The scene layout determines how the layout stack should layout its pages.
2794
+ * @public
2795
+ */
2796
+ export declare type SceneLayout = 'Free' | 'VerticalStack' | 'HorizontalStack' | 'DepthStack';
2797
+
2798
+ /**
2799
+ * The mode of the scene defines how the editor and playback should behave.
2800
+ * @public
2801
+ */
2802
+ export declare type SceneMode = 'Design' | 'Video';
2803
+
2629
2804
  /** @public */
2630
2805
  export declare interface Size2 {
2631
2806
  width: number;
@@ -2648,6 +2823,10 @@ export declare interface SpotColor {
2648
2823
  cmykApproximation: CMYKColor;
2649
2824
  }
2650
2825
 
2826
+ declare interface SpotColorLookup {
2827
+ getSpotColorRGBA(name: string): [r: number, g: number, b: number, a: number];
2828
+ }
2829
+
2651
2830
  /** @public */
2652
2831
  export declare type StrokeCornerGeometry = 'Bevel' | 'Miter' | 'Round';
2653
2832