@cesdk/engine 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
@@ -21,6 +21,7 @@ export declare interface Asset {
21
21
  uri?: string;
22
22
  filename?: string;
23
23
  vectorPath?: string;
24
+ duration?: string;
24
25
  } & Record<string, unknown>;
25
26
  }
26
27
 
@@ -79,6 +80,8 @@ export declare class AssetAPI {
79
80
  canManageAssets(sourceId: string): boolean;
80
81
 
81
82
 
83
+
84
+
82
85
  /**
83
86
  * Apply an asset result to the active scene.
84
87
  * The default behavior will instantiate a block and configure it according to the asset's properties.
@@ -87,12 +90,25 @@ export declare class AssetAPI {
87
90
  * @param assetResult - A single assetResult of a `findAssets` query.
88
91
  */
89
92
  apply(sourceId: string, assetResult: AssetResult): Promise<void>;
93
+ /**
94
+ * Apply an asset result to the given block.
95
+ * @param sourceId - The ID of the asset source.
96
+ * @param assetResult - A single assetResult of a `findAssets` query.
97
+ * @param block - The block the asset should be applied to.
98
+ */
99
+ applyToBlock(sourceId: string, assetResult: AssetResult, block: DesignBlockId): Promise<void>;
90
100
  /**
91
101
  * The default implementation for applying an asset to the scene.
92
102
  * This implementation is used when no `applyAsset` function is provided to `addSource`.
93
103
  * @param assetResult - A single assetResult of a `findAssets` query.
94
104
  */
95
105
  defaultApplyAsset(assetResult: AssetResult): Promise<void>;
106
+ /**
107
+ * The default implementation for applying an asset to an existing block.
108
+ * @param assetResult - A single assetResult of a `findAssets` query.
109
+ * @param block - The block to apply the asset result to.
110
+ */
111
+ defaultApplyAssetToBlock(assetResult: AssetResult, block: DesignBlockId): Promise<void>;
96
112
 
97
113
  }
98
114
 
@@ -192,6 +208,7 @@ declare interface AssetResult_2 {
192
208
  meta?: {
193
209
  uri?: string;
194
210
  filename?: string;
211
+ duration?: string;
195
212
  } & Record<string, unknown>;
196
213
  /** The locale of the label and tags */
197
214
  locale?: string;
@@ -264,6 +281,11 @@ export declare interface AssetSource {
264
281
  * You can override this with custom behavior.
265
282
  */
266
283
  applyAsset?: (asset: AssetResult) => Promise<void>;
284
+ /**
285
+ * Apply the given asset result to the given block.
286
+ * You can override this with custom behavior.
287
+ */
288
+ applyAssetToBlock?: (asset: AssetResult, block: DesignBlockId) => Promise<void>;
267
289
  /**
268
290
  * Adds the given asset to this source. Throws an error if `canManageAssets`
269
291
  * is `false`.
@@ -284,6 +306,12 @@ export declare interface AssetSource {
284
306
  * @returns true if asset was found and removed, and false otherwise
285
307
  */
286
308
  removeAsset?(assetId: string): Promise<boolean>;
309
+ /**
310
+ * Generates a list of supported mime types for this source.
311
+ *
312
+ * @returns a list of the mime types should be supported by this source
313
+ */
314
+ getSupportedMimeTypes?(): string[] | undefined;
287
315
  }
288
316
 
289
317
  /**
@@ -298,6 +326,12 @@ declare interface AssetSource_2 {
298
326
  * You can override this with custom behavior.
299
327
  */
300
328
  applyAsset?: (asset: AssetResult_2) => Promise<void>;
329
+ /**
330
+ * Apply the given asset result to the given block.
331
+ * You can override this with custom behavior.
332
+ */
333
+ applyAssetToBlock?: (asset: AssetResult_2, block: number) => Promise<void>;
334
+
301
335
  /** Return every available group */
302
336
  getGroups?: () => Promise<string[]>;
303
337
  /**
@@ -318,6 +352,13 @@ declare interface AssetSource_2 {
318
352
  name: string;
319
353
  url?: string;
320
354
  };
355
+
356
+ /**
357
+ * Generates a list of supported mime types for this source.
358
+ *
359
+ * @returns a list of the mime types should be supported by this source
360
+ */
361
+ getSupportedMimeTypes?(): string[] | undefined;
321
362
  }
322
363
 
323
364
  /** @public */
@@ -368,18 +409,28 @@ export declare type BlendMode = 'PassThrough' | 'Normal' | 'Darken' | 'Multiply'
368
409
  export declare class Block extends Entity {
369
410
  #private;
370
411
  effects: ReadWriteChannelSync<number[]>;
412
+ blur: ReadWriteChannelSync<number>;
413
+ isBlurEnabled: ReadWriteChannelSync<boolean>;
371
414
  soloPlaybackEnabled: ReadWriteChannelSync<boolean>;
372
415
  trimOffset: ReadWriteChannelSync<number>;
373
416
  trimLength: ReadWriteChannelSync<number>;
374
417
  playing: ReadWriteChannelSync<boolean>;
375
418
  playbackTime: ReadWriteChannelSync<number>;
376
419
  selection: ReadWriteChannelSync<boolean>;
377
- videoMode: ReadWriteChannelSync<boolean>;
420
+ sceneMode: ReadWriteChannelSync<SceneMode>;
378
421
  duration: ReadWriteChannelSync<number>;
422
+ totalSceneDuration: ReadWriteChannelSync<number>;
379
423
  name: ReadWriteChannelSync<string>;
380
- muted: ReadWriteChannelSync<boolean>;
424
+ audioMuted: ReadWriteChannelSync<boolean>;
425
+ videoMuted: ReadWriteChannelSync<boolean>;
381
426
  avResourceTotalDuration: ReadWriteChannelSync<number>;
382
427
  timeOffset: ReadWriteChannelSync<number>;
428
+ cropTranslationX: ReadWriteChannelSync<number>;
429
+ cropTranslationY: ReadWriteChannelSync<number>;
430
+ cropTranslation: ReadWriteChannelSync<Vec2>;
431
+ width: ReadWriteChannelSync<number>;
432
+ height: ReadWriteChannelSync<number>;
433
+ dimensions: ReadWriteChannelSync<Vec2>;
383
434
 
384
435
 
385
436
  }
@@ -463,6 +514,12 @@ export declare class BlockAPI {
463
514
  * @returns An array of block ids.
464
515
  */
465
516
  findAllSelected(): DesignBlockId[];
517
+ /**
518
+ * Subscribe to changes in the current set of selected blocks.
519
+ * @param callback - This function is called at the end of the engine update if the selection has changed.
520
+ * @returns A method to unsubscribe.
521
+ */
522
+ onSelectionChanged(callback: () => void): () => void;
466
523
  /**
467
524
  * Confirms that a given set of blocks can be grouped together.
468
525
  * @param ids - A non-empty array of block ids.
@@ -926,6 +983,29 @@ export declare class BlockAPI {
926
983
  * @returns A tuple of channels red, green, blue and alpha in the range of 0 to 1.
927
984
  */
928
985
  getColorRGBA(id: DesignBlockId, property: string): RGBA;
986
+ /**
987
+ * Set a color property of the given design block to the given value.
988
+ * @param id - The block whose property should be set.
989
+ * @param property - The name of the property to set.
990
+ * @param name - The name of the spot color.
991
+ * @param tint - The tint factor in the range of 0 to 1.
992
+ * @returns An empty result on success, an error otherwise.
993
+ */
994
+ setColorSpot(id: DesignBlockId, property: string, name: string, tint?: number): void;
995
+ /**
996
+ * Get the spot color name of a color property of the given design block.
997
+ * @param id - The block whose property should be queried.
998
+ * @param property - The name of the property to query.
999
+ * @returns A result holding the name of the spot color or an error.
1000
+ */
1001
+ getColorSpotName(id: DesignBlockId, property: string): string;
1002
+ /**
1003
+ * Get the spot color tint factor of a color property of the given design block.
1004
+ * @param id - The block whose property should be queried.
1005
+ * @param property - The name of the property to query.
1006
+ * @returns A result holding the tint factor of the spot color or an error.
1007
+ */
1008
+ getColorSpotTint(id: DesignBlockId, property: string): number;
929
1009
  /**
930
1010
  * Set an enum property of the given design block to the given value.
931
1011
  * @param id - The block whose property should be set.
@@ -1830,17 +1910,28 @@ export declare class BlockAPI {
1830
1910
  /**
1831
1911
  * Generate a thumbnail for the given video fill.
1832
1912
  * @param id - The video fill.
1833
- * @returns A thumbnail encoded as JPEG with a height of 128px.
1913
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
1914
+ * @returns A thumbnail encoded as JPEG.
1834
1915
  */
1835
- getVideoFillThumbnail(id: DesignBlockId): Promise<Blob>;
1916
+ getVideoFillThumbnail(id: DesignBlockId, thumbnailHeight: number): Promise<Blob>;
1836
1917
  /**
1837
1918
  * Generate a thumbnail atlas for the given video fill.
1838
1919
  * @param id - The video fill.
1839
1920
  * @param numberOfColumns - The number of columns to generate.
1840
1921
  * @param numberOfRows - The number of rows to generate.
1922
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
1841
1923
  * @returns A thumbnail atlas of the video as JPEG.
1842
1924
  */
1843
- getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number): Promise<Blob>;
1925
+ getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
1926
+ /**
1927
+ * Generate a thumbnail atlas for the given page.
1928
+ * @param id - The page.
1929
+ * @param numberOfColumns - The number of columns to generate.
1930
+ * @param numberOfRows - The number of rows to generate.
1931
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the page aspect ratio.
1932
+ * @returns A thumbnail atlas of the composition as JPEG.
1933
+ */
1934
+ getPageThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
1844
1935
  }
1845
1936
 
1846
1937
  /**
@@ -2027,16 +2118,15 @@ declare class CreativeEngine {
2027
2118
  /**
2028
2119
  * Initialize a `CreativeEngine` using the given `canvas` element and an optional config.
2029
2120
  * @param config - An optional configuration object.
2030
- * @param canvas - The canvas to use for drawing. Optional, if no canvas is provided,
2031
- * the engine works with an internal offscreen-canvas.
2032
2121
  * @returns An engine instance.
2033
2122
  */
2034
- static init(config?: Partial<Configuration>): Promise<CreativeEngine & {
2035
- readonly element: HTMLCreativeEngineCanvasElement;
2036
- }>;
2037
- static init(config: Partial<Configuration> | undefined, canvas: HTMLCanvasElement | OffscreenCanvas): Promise<CreativeEngine & {
2123
+ static init<C extends Partial<Configuration>>(config?: C): Promise<CreativeEngine & (C extends {
2124
+ readonly canvas: any;
2125
+ } ? {
2038
2126
  readonly element: undefined;
2039
- }>;
2127
+ } : {
2128
+ readonly element: HTMLCreativeEngineCanvasElement;
2129
+ })>;
2040
2130
  }
2041
2131
  export default CreativeEngine;
2042
2132
 
@@ -2069,6 +2159,7 @@ export declare enum DesignBlockType {
2069
2159
  Page = "//ly.img.ubq/page",
2070
2160
  Image = "//ly.img.ubq/image",
2071
2161
  Video = "//ly.img.ubq/video",
2162
+ VideoFill = "//ly.img.ubq/fill/video",
2072
2163
  Audio = "//ly.img.ubq/audio",
2073
2164
  Text = "//ly.img.ubq/text",
2074
2165
  Sticker = "//ly.img.ubq/sticker",
@@ -2129,6 +2220,28 @@ export declare class EditorAPI {
2129
2220
  * @returns The text cursor's y position in screen space.
2130
2221
  */
2131
2222
  getTextCursorPositionInScreenSpaceY(): number;
2223
+ /**
2224
+ * Create a history which consists of an undo/redo stack for editing operations.
2225
+ * There can be multiple. But only one can be active at a time.
2226
+ * @returns The handle of the created history.
2227
+ */
2228
+ createHistory(): HistoryId;
2229
+ /**
2230
+ * Destroy the given history, throws an error if the handle doesn't refer to a history.
2231
+ * @param history - The history to destroy.
2232
+ */
2233
+ destroyHistory(history: HistoryId): void;
2234
+ /**
2235
+ * Mark the given history as active, throws an error if the handle doesn't refer to a history.
2236
+ * All other histories get cleared from the active state. Undo/redo operations only apply to the active history.
2237
+ * @param history - The history to make active.
2238
+ */
2239
+ setActiveHistory(history: HistoryId): void;
2240
+ /**
2241
+ * Get the handle to the currently active history. If there's none it will be created.
2242
+ * @returns History - The handle of the active history.
2243
+ */
2244
+ getActiveHistory(): HistoryId;
2132
2245
  /**
2133
2246
  * Adds a new history state to the stack, if undoable changes were made.
2134
2247
  */
@@ -2153,6 +2266,13 @@ export declare class EditorAPI {
2153
2266
  * @returns True if a redo step is available.
2154
2267
  */
2155
2268
  canRedo(): boolean;
2269
+ /**
2270
+ * Subscribe to changes to the undo/redo history.
2271
+ *
2272
+ * @param callback - This function is called at the end of the engine update, if the undo/redo history has been changed.
2273
+ * @returns A method to unsubscribe
2274
+ */
2275
+ onHistoryUpdated(callback: () => void): () => void;
2156
2276
  /**
2157
2277
  * Subscribe to changes to the editor settings.
2158
2278
  * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
@@ -2274,6 +2394,34 @@ export declare class EditorAPI {
2274
2394
  * @returns `Allow` if the scope is allowed, `Deny` if it is disallowed, and `Defer` if it is deferred to the block-level.
2275
2395
  */
2276
2396
  getGlobalScope(key: string): 'Allow' | 'Deny' | 'Defer';
2397
+ /**
2398
+ * Queries the names of currently set spot colors previously set with `setSpotColorRGB`.
2399
+ * @returns The names of set spot colors.
2400
+ */
2401
+ findAllSpotColors(): string[];
2402
+ /**
2403
+ * Queries the RGB representation set for a spot color.
2404
+ * If the value of the queried spot color has not been set yet, returns the default RGB representation (of magenta).
2405
+ * The alpha value is always 1.0.
2406
+ * @param name - The name of a spot color.
2407
+ * @returns A result holding a float array of the four color components.
2408
+ */
2409
+ getSpotColorRGBA(name: string): RGBA;
2410
+ /**
2411
+ * Sets the RGB representation of a spot color.
2412
+ * Use this function to both create a new spot color or update an existing spot color.
2413
+ * @param name - The name of a spot color.
2414
+ * @param r - The red color component in the range of 0 to 1.
2415
+ * @param g - The green color component in the range of 0 to 1.
2416
+ * @param b - The blue color component in the range of 0 to 1.
2417
+ */
2418
+ setSpotColorRGB(name: string, r: number, g: number, b: number): void;
2419
+ /**
2420
+ * Removes a spot color from the list of set spot colors.
2421
+ * @param name - The name of a spot color.
2422
+ * @returns An empty result on success, an error otherwise.
2423
+ */
2424
+ removeSpotColor(name: string): void;
2277
2425
  }
2278
2426
 
2279
2427
  /**
@@ -2404,7 +2552,7 @@ declare type Extensions = {
2404
2552
  /**
2405
2553
  * @public
2406
2554
  */
2407
- export declare type FillType = 'Solid' | 'Gradient';
2555
+ export declare type FillType = 'Solid' | 'Gradient' | 'Video';
2408
2556
 
2409
2557
  /** @public */
2410
2558
  declare interface FindAssetsQuery {
@@ -2474,6 +2622,12 @@ declare type Handler<T> = (v: T) => void;
2474
2622
  */
2475
2623
  declare type HexColorString = string;
2476
2624
 
2625
+ /**
2626
+ * A numerical identifier for a history stack
2627
+ * @public
2628
+ */
2629
+ export declare type HistoryId = number;
2630
+
2477
2631
  /**
2478
2632
  * A wrapper around a plain canvas
2479
2633
  *
@@ -2775,6 +2929,11 @@ export declare class SceneAPI {
2775
2929
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2776
2930
  */
2777
2931
  applyTemplateFromURL(url: string): Promise<void>;
2932
+ /**
2933
+ * Get the current scene mode.
2934
+ * @returns The current mode of the scene.
2935
+ */
2936
+ getMode(): SceneMode;
2778
2937
  /**
2779
2938
  * Sets the zoom level of the active scene.
2780
2939
  * Only has an effect if the zoom level is not handled by the UI.
@@ -2807,6 +2966,12 @@ export declare class SceneAPI {
2807
2966
  * @privateRemarks This will currently fire on _all_ changes to camera properties
2808
2967
  */
2809
2968
  onZoomLevelChanged(callback: () => void): () => void;
2969
+ /**
2970
+ * Subscribe to changes to the active scene rendered by the engine.
2971
+ * @param callback - This function is called at the end of the engine update, if the active scene has changed.
2972
+ * @returns A method to unsubscribe.
2973
+ */
2974
+ onActiveChanged(callback: () => void): () => void;
2810
2975
  /**
2811
2976
  * Converts all values of the current scene into the given design unit.
2812
2977
  * @param designUnit - The new design unit of the scene
@@ -2819,9 +2984,32 @@ export declare class SceneAPI {
2819
2984
  unstable_getDesignUnit(): DesignUnit;
2820
2985
  }
2821
2986
 
2822
- /** @public */
2987
+ /**
2988
+ * The scene layout determines how the layout stack should layout its pages.
2989
+ * @public
2990
+ */
2823
2991
  export declare type SceneLayout = 'Free' | 'VerticalStack' | 'HorizontalStack' | 'DepthStack';
2824
2992
 
2993
+ /**
2994
+ * The mode of the scene defines how the editor and playback should behave.
2995
+ * @public
2996
+ */
2997
+ export declare type SceneMode = 'Design' | 'Video';
2998
+
2999
+ /**
3000
+ * This channel allows to subscribe/update the selected design blocks.
3001
+ * @public
3002
+ */
3003
+ export declare class SelectionChannel implements ReadWriteChannelSync<number[]> {
3004
+ #private;
3005
+ subscribe: Source<number[]>;
3006
+
3007
+ private deselectAll;
3008
+ private selectAll;
3009
+ update: (selectedDesignElements: number[]) => void;
3010
+ value: () => number[];
3011
+ }
3012
+
2825
3013
  /** @public */
2826
3014
  export declare interface Size2 {
2827
3015
  width: number;
@@ -2855,6 +3043,10 @@ export declare interface SpotColor {
2855
3043
  cmykApproximation: CMYKColor;
2856
3044
  }
2857
3045
 
3046
+ declare interface SpotColorLookup {
3047
+ getSpotColorRGBA(name: string): [r: number, g: number, b: number, a: number];
3048
+ }
3049
+
2858
3050
  /** @public */
2859
3051
  export declare type StrokeCornerGeometry = 'Bevel' | 'Miter' | 'Round';
2860
3052