@cesdk/node 1.9.0-preview.3 → 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 */
@@ -1978,6 +2059,7 @@ export declare enum DesignBlockType {
1978
2059
  Page = "//ly.img.ubq/page",
1979
2060
  Image = "//ly.img.ubq/image",
1980
2061
  Video = "//ly.img.ubq/video",
2062
+ VideoFill = "//ly.img.ubq/fill/video",
1981
2063
  Audio = "//ly.img.ubq/audio",
1982
2064
  Text = "//ly.img.ubq/text",
1983
2065
  Sticker = "//ly.img.ubq/sticker",
@@ -2038,6 +2120,28 @@ export declare class EditorAPI {
2038
2120
  * @returns The text cursor's y position in screen space.
2039
2121
  */
2040
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;
2041
2145
  /**
2042
2146
  * Adds a new history state to the stack, if undoable changes were made.
2043
2147
  */
@@ -2062,6 +2166,13 @@ export declare class EditorAPI {
2062
2166
  * @returns True if a redo step is available.
2063
2167
  */
2064
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;
2065
2176
  /**
2066
2177
  * Subscribe to changes to the editor settings.
2067
2178
  * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
@@ -2183,6 +2294,34 @@ export declare class EditorAPI {
2183
2294
  * @returns `Allow` if the scope is allowed, `Deny` if it is disallowed, and `Defer` if it is deferred to the block-level.
2184
2295
  */
2185
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;
2186
2325
  }
2187
2326
 
2188
2327
  /**
@@ -2271,7 +2410,7 @@ declare type Extensions = {
2271
2410
  /**
2272
2411
  * @public
2273
2412
  */
2274
- export declare type FillType = 'Solid' | 'Gradient';
2413
+ export declare type FillType = 'Solid' | 'Gradient' | 'Video';
2275
2414
 
2276
2415
  /** @public */
2277
2416
  declare interface FindAssetsQuery {
@@ -2335,6 +2474,12 @@ declare type Groups = string[];
2335
2474
  */
2336
2475
  declare type HexColorString = string;
2337
2476
 
2477
+ /**
2478
+ * A numerical identifier for a history stack
2479
+ * @public
2480
+ */
2481
+ export declare type HistoryId = number;
2482
+
2338
2483
  /** @public */
2339
2484
  declare type ImageDefinition = Preset & {
2340
2485
  imageURL: string;
@@ -2589,6 +2734,11 @@ export declare class SceneAPI {
2589
2734
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2590
2735
  */
2591
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;
2592
2742
  /**
2593
2743
  * Sets the zoom level of the active scene.
2594
2744
  * Only has an effect if the zoom level is not handled by the UI.
@@ -2621,6 +2771,12 @@ export declare class SceneAPI {
2621
2771
  * @privateRemarks This will currently fire on _all_ changes to camera properties
2622
2772
  */
2623
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;
2624
2780
  /**
2625
2781
  * Converts all values of the current scene into the given design unit.
2626
2782
  * @param designUnit - The new design unit of the scene
@@ -2633,9 +2789,18 @@ export declare class SceneAPI {
2633
2789
  unstable_getDesignUnit(): DesignUnit;
2634
2790
  }
2635
2791
 
2636
- /** @public */
2792
+ /**
2793
+ * The scene layout determines how the layout stack should layout its pages.
2794
+ * @public
2795
+ */
2637
2796
  export declare type SceneLayout = 'Free' | 'VerticalStack' | 'HorizontalStack' | 'DepthStack';
2638
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
+
2639
2804
  /** @public */
2640
2805
  export declare interface Size2 {
2641
2806
  width: number;
@@ -2658,6 +2823,10 @@ export declare interface SpotColor {
2658
2823
  cmykApproximation: CMYKColor;
2659
2824
  }
2660
2825
 
2826
+ declare interface SpotColorLookup {
2827
+ getSpotColorRGBA(name: string): [r: number, g: number, b: number, a: number];
2828
+ }
2829
+
2661
2830
  /** @public */
2662
2831
  export declare type StrokeCornerGeometry = 'Bevel' | 'Miter' | 'Round';
2663
2832