@cesdk/engine 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
@@ -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
  /**
@@ -1982,6 +2073,13 @@ export declare interface Configuration {
1982
2073
  * If not configured the fallback font is used.
1983
2074
  */
1984
2075
  defaultFont?: string;
2076
+ /**
2077
+ * By default the engine tries to create a webgl2 context. If this fails it
2078
+ * falls back to trying to create a webgl1 context. If this configuration
2079
+ * option is set to true, it will no longer try to create a webgl2 context
2080
+ * and always create a webgl1 context.
2081
+ */
2082
+ forceWebGL1?: boolean;
1985
2083
  }
1986
2084
 
1987
2085
  /**
@@ -2020,16 +2118,15 @@ declare class CreativeEngine {
2020
2118
  /**
2021
2119
  * Initialize a `CreativeEngine` using the given `canvas` element and an optional config.
2022
2120
  * @param config - An optional configuration object.
2023
- * @param canvas - The canvas to use for drawing. Optional, if no canvas is provided,
2024
- * the engine works with an internal offscreen-canvas.
2025
2121
  * @returns An engine instance.
2026
2122
  */
2027
- static init(config?: Partial<Configuration>): Promise<CreativeEngine & {
2028
- readonly element: HTMLCreativeEngineCanvasElement;
2029
- }>;
2030
- 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
+ } ? {
2031
2126
  readonly element: undefined;
2032
- }>;
2127
+ } : {
2128
+ readonly element: HTMLCreativeEngineCanvasElement;
2129
+ })>;
2033
2130
  }
2034
2131
  export default CreativeEngine;
2035
2132
 
@@ -2062,6 +2159,7 @@ export declare enum DesignBlockType {
2062
2159
  Page = "//ly.img.ubq/page",
2063
2160
  Image = "//ly.img.ubq/image",
2064
2161
  Video = "//ly.img.ubq/video",
2162
+ VideoFill = "//ly.img.ubq/fill/video",
2065
2163
  Audio = "//ly.img.ubq/audio",
2066
2164
  Text = "//ly.img.ubq/text",
2067
2165
  Sticker = "//ly.img.ubq/sticker",
@@ -2122,6 +2220,28 @@ export declare class EditorAPI {
2122
2220
  * @returns The text cursor's y position in screen space.
2123
2221
  */
2124
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;
2125
2245
  /**
2126
2246
  * Adds a new history state to the stack, if undoable changes were made.
2127
2247
  */
@@ -2146,6 +2266,13 @@ export declare class EditorAPI {
2146
2266
  * @returns True if a redo step is available.
2147
2267
  */
2148
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;
2149
2276
  /**
2150
2277
  * Subscribe to changes to the editor settings.
2151
2278
  * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
@@ -2267,6 +2394,34 @@ export declare class EditorAPI {
2267
2394
  * @returns `Allow` if the scope is allowed, `Deny` if it is disallowed, and `Defer` if it is deferred to the block-level.
2268
2395
  */
2269
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;
2270
2425
  }
2271
2426
 
2272
2427
  /**
@@ -2397,7 +2552,7 @@ declare type Extensions = {
2397
2552
  /**
2398
2553
  * @public
2399
2554
  */
2400
- export declare type FillType = 'Solid' | 'Gradient';
2555
+ export declare type FillType = 'Solid' | 'Gradient' | 'Video';
2401
2556
 
2402
2557
  /** @public */
2403
2558
  declare interface FindAssetsQuery {
@@ -2467,6 +2622,12 @@ declare type Handler<T> = (v: T) => void;
2467
2622
  */
2468
2623
  declare type HexColorString = string;
2469
2624
 
2625
+ /**
2626
+ * A numerical identifier for a history stack
2627
+ * @public
2628
+ */
2629
+ export declare type HistoryId = number;
2630
+
2470
2631
  /**
2471
2632
  * A wrapper around a plain canvas
2472
2633
  *
@@ -2729,7 +2890,7 @@ export declare class SceneAPI {
2729
2890
  * Create a new design scene, along with its own camera.
2730
2891
  * @returns The scene's handle.
2731
2892
  */
2732
- create(): DesignBlockId;
2893
+ create(sceneLayout?: SceneLayout): DesignBlockId;
2733
2894
  /**
2734
2895
  * Create a new scene in video mode, along with its own camera and page stack.
2735
2896
  * @returns The scene's handle.
@@ -2744,7 +2905,7 @@ export declare class SceneAPI {
2744
2905
  * @param pixelScaleFactor - The displays pixel scale factor.
2745
2906
  * @returns A promise that resolves with the scene ID on success or rejected with an error otherwise.
2746
2907
  */
2747
- createFromImage(url: string, dpi?: number, pixelScaleFactor?: number): Promise<DesignBlockId>;
2908
+ createFromImage(url: string, dpi?: number, pixelScaleFactor?: number, sceneLayout?: SceneLayout, spacing?: number, spacingInScreenSpace?: boolean): Promise<DesignBlockId>;
2748
2909
  /**
2749
2910
  * Return the currently active scene.
2750
2911
  * @returns The scene or null, if none was created yet.
@@ -2768,6 +2929,11 @@ export declare class SceneAPI {
2768
2929
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2769
2930
  */
2770
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;
2771
2937
  /**
2772
2938
  * Sets the zoom level of the active scene.
2773
2939
  * Only has an effect if the zoom level is not handled by the UI.
@@ -2799,7 +2965,13 @@ export declare class SceneAPI {
2799
2965
  * @returns A method to unsubscribe.
2800
2966
  * @privateRemarks This will currently fire on _all_ changes to camera properties
2801
2967
  */
2802
- onZoomLevelChanged(callback: (zoomLevel: number) => void): () => void;
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;
2803
2975
  /**
2804
2976
  * Converts all values of the current scene into the given design unit.
2805
2977
  * @param designUnit - The new design unit of the scene
@@ -2812,6 +2984,32 @@ export declare class SceneAPI {
2812
2984
  unstable_getDesignUnit(): DesignUnit;
2813
2985
  }
2814
2986
 
2987
+ /**
2988
+ * The scene layout determines how the layout stack should layout its pages.
2989
+ * @public
2990
+ */
2991
+ export declare type SceneLayout = 'Free' | 'VerticalStack' | 'HorizontalStack' | 'DepthStack';
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
+
2815
3013
  /** @public */
2816
3014
  export declare interface Size2 {
2817
3015
  width: number;
@@ -2845,6 +3043,10 @@ export declare interface SpotColor {
2845
3043
  cmykApproximation: CMYKColor;
2846
3044
  }
2847
3045
 
3046
+ declare interface SpotColorLookup {
3047
+ getSpotColorRGBA(name: string): [r: number, g: number, b: number, a: number];
3048
+ }
3049
+
2848
3050
  /** @public */
2849
3051
  export declare type StrokeCornerGeometry = 'Bevel' | 'Miter' | 'Round';
2850
3052
 
@@ -2953,4 +3155,16 @@ export declare interface Vec4 {
2953
3155
  w: number;
2954
3156
  }
2955
3157
 
3158
+ /**
3159
+ * This channel allows to subscribe/update the current zoom level of the camera.
3160
+ * @public
3161
+ */
3162
+ export declare class ZoomLevelChannel implements ReadWriteChannelSync<number> {
3163
+ #private;
3164
+ subscribe: Source<number>;
3165
+
3166
+ update: (zoomLevel: number) => void;
3167
+ value: () => number;
3168
+ }
3169
+
2956
3170
  export { }