@cesdk/node 1.10.0 → 1.11.0-preview.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
@@ -436,17 +436,13 @@ export declare class BlockAPI {
436
436
  /**
437
437
  * Exports a design block as a video file of the given mime type.
438
438
  * Note: The export will run across multiple iterations of the update loop. In each iteration a frame is scheduled for encoding.
439
- * @param block - The design block to export.
440
- * @param timeOffset - The time offset in seconds of the scene's timeline from which the video will start.
441
- * @param duration - The duration in seconds of the final video.
439
+ * @param handle - The design block element to export. Currently, only the scene block is supported.
442
440
  * @param mimeType - The mime type of the output video file.
443
- * @param resolutionWidth - The target video width in pixel.
444
- * @param resolutionHeight - The target video height in pixel.
445
- * @param framerate - The target framerate in Hz.
446
441
  * @param progressCallback - A callback which reports on the progress of the export. It informs the receiver of the current frame index, which currently gets exported and the total frame count.
442
+ * @param options - The options for exporting the video
447
443
  * @returns A promise that resolves with video blob or is rejected with an error.
448
444
  */
449
- exportVideo(handle: DesignBlockId, timeOffset: number, duration: number, mimeType: MimeType_2 | undefined, resolutionWidth: number, resolutionHeight: number, framerate: number, progressCallback: (numberOfRenderedFrames: number, numberOfEncodedFrames: number, totalNumberOfFrames: number) => void): Promise<Blob>;
445
+ exportVideo(handle: DesignBlockId, mimeType: MimeType_2 | undefined, progressCallback: (numberOfRenderedFrames: number, numberOfEncodedFrames: number, totalNumberOfFrames: number) => void, options: VideoExportOptions): Promise<Blob>;
450
446
  /**
451
447
  * Loads existing blocks from the given string.
452
448
  * The blocks are not attached by default and won't be visible until attached to a page or the scene.
@@ -766,7 +762,7 @@ export declare class BlockAPI {
766
762
  /**
767
763
  * Set a block's mode for its width.
768
764
  * @param id - The block to update.
769
- * @param mode - The width mode: absolute, percent or auto.
765
+ * @param mode - The width mode: Absolute, Percent or Auto.
770
766
  */
771
767
  setWidthMode(id: DesignBlockId, mode: SizeMode): void;
772
768
  /**
@@ -778,7 +774,7 @@ export declare class BlockAPI {
778
774
  /**
779
775
  * Set a block's mode for its height.
780
776
  * @param id - The block to update.
781
- * @param mode - The height mode: absolute, percent or auto.
777
+ * @param mode - The height mode: Absolute, Percent or Auto.
782
778
  */
783
779
  setHeightMode(id: DesignBlockId, mode: SizeMode): void;
784
780
  /**
@@ -1066,14 +1062,14 @@ export declare class BlockAPI {
1066
1062
  * @param property - The name of the property to set.
1067
1063
  * @param value - The enum value as string.
1068
1064
  */
1069
- setEnum(id: DesignBlockId, property: string, value: string): void;
1065
+ setEnum<T extends string = string>(id: DesignBlockId, property: string, value: T): void;
1070
1066
  /**
1071
1067
  * Get the value of an enum property of the given design block.
1072
1068
  * @param id - The block whose property should be queried.
1073
1069
  * @param property - The name of the property to query.
1074
1070
  * @returns The value as string.
1075
1071
  */
1076
- getEnum(id: DesignBlockId, property: string): string;
1072
+ getEnum<T extends string = string>(id: DesignBlockId, property: string): T;
1077
1073
  /**
1078
1074
  * Query if the given block has crop properties.
1079
1075
  * @param id - The block to query.
@@ -1605,6 +1601,69 @@ export declare class BlockAPI {
1605
1601
  * @returns The drop shadow's clipping.
1606
1602
  */
1607
1603
  getDropShadowClip(id: DesignBlockId): boolean;
1604
+ /**
1605
+ * Inserts the given text into the selected range of the text block.
1606
+ * @param block - The text block into which to insert the given text.
1607
+ * @param text - The text which should replace the selected range in the block.
1608
+ * @param from - The start index of the UTF-16 range that should be replaced.
1609
+ * If the value is negative, this will fall back to the start of the entire text range.
1610
+ * @param to - The UTF-16 index after the last grapheme that should be replaced by the inserted text.
1611
+ * If `from` and `to` are negative, a this will fall back to the end of the entire text range, so the entire text will be replaced.
1612
+ * If `to` is negative but `from` is greater than or equal to 0, the text will be inserted at the index defined by `from`.
1613
+ */
1614
+ replaceText(id: DesignBlockId, text: string, from?: number, to?: number): void;
1615
+ /**
1616
+ * Removes selected range of text of the given text block.
1617
+ * @param block - The text block from which the selected text should be removed.
1618
+ * @param from - The start index of the UTF-16 range that should be removed.
1619
+ * If the value is negative, this will fall back to the start of the entire text range.
1620
+ * @param to - The UTF-16 index after the last grapheme that should be removed.
1621
+ * If the value is negative, this will fall back to the end of the entire text range.
1622
+ */
1623
+ removeText(id: DesignBlockId, from?: number, to?: number): void;
1624
+ /**
1625
+ * Changes the color of the text in the selected range to the given color.
1626
+ * @param block - The text block whose color should be changed.
1627
+ * @param color - The new color of the selected text range.
1628
+ * @param from - The start index of the UTF-16 range whose color should be changed.
1629
+ * If the value is negative and the block is currently being edited, this will fall back to the start of the current cursor index / selected grapheme range.
1630
+ * If the value is negative and the block is not being edited, this will fall back to the start of the entire text range.
1631
+ * @param to - The UTF-16 index after the last grapheme whose color should be changed.
1632
+ * If the value is negative and the block is currently being edited, this will fall back to the end of the current cursor index / selected grapheme range.
1633
+ * If the value is negative and the block is not being edited, this will fall back to the end of the entire text range.
1634
+ */
1635
+ setTextColor(id: DesignBlockId, color: RGBAColor | SpotColor, from?: number, to?: number): void;
1636
+ /**
1637
+ * Returns the ordered unique list of colors of the text in the selected range.
1638
+ * @param block - The text block whose colors should be returned.
1639
+ * @param from - The start index of the UTF-16 range whose colors should be returned.
1640
+ * If the value is negative, this will fall back to the start of the entire text range.
1641
+ * @param to - The UTF-16 index after the last grapheme whose colors should be returned.
1642
+ * If the value is negative, this will fall back to the end of the entire text range.
1643
+ */
1644
+ getTextColors(id: DesignBlockId, from?: number, to?: number): Array<RGBAColor | SpotColor>;
1645
+ /**
1646
+ * Returns the ordered unique list of font weights of the text in the selected range.
1647
+ * @param block - The text block whose font weights should be returned.
1648
+ * @param from - The start index of the UTF-16 range whose font weights should be returned.
1649
+ * If the value is negative and the block is currently being edited, this will fall back to the start of the current cursor index / selected grapheme range.
1650
+ * If the value is negative and the block is not being edited, this will fall back to the start of the entire text range.
1651
+ * @param to - The UTF-16 index after the last grapheme whose font weights should be returned.
1652
+ * If the value is negative and the block is currently being edited, this will fall back to the end of the current cursor index / selected grapheme range.
1653
+ * If the value is negative and the block is not being edited, this will fall back to the end of the entire text range.
1654
+ */
1655
+ getTextFontWeights(id: DesignBlockId, from?: number, to?: number): FontWeight[];
1656
+ /**
1657
+ * Returns the ordered unique list of font styles of the text in the selected range.
1658
+ * @param block - The text block whose font styles should be returned.
1659
+ * @param from - The start index of the UTF-16 range whose font weights should be returned.
1660
+ * If the value is negative and the block is currently being edited, this will fall back to the start of the current cursor index / selected grapheme range.
1661
+ * If the value is negative and the block is not being edited, this will fall back to the start of the entire text range.
1662
+ * @param to - The UTF-16 index after the last grapheme whose font styles should be returned.
1663
+ * If the value is negative and the block is currently being edited, this will fall back to the end of the current cursor index / selected grapheme range.
1664
+ * If the value is negative and the block is not being edited, this will fall back to the end of the entire text range.
1665
+ */
1666
+ getTextFontStyles(id: DesignBlockId, from?: number, to?: number): FontStyle[];
1608
1667
  /**
1609
1668
  * Query if the given block has fill color properties.
1610
1669
  * @param id - The block to query.
@@ -2149,15 +2208,15 @@ export { ConfigTypes }
2149
2208
  export declare interface Configuration {
2150
2209
  baseURL: string;
2151
2210
  license?: string;
2152
- role: RoleString;
2153
- featureFlags?: Record<string, string | boolean>;
2211
+ featureFlags?: {
2212
+ [flag: string]: boolean | string;
2213
+ };
2154
2214
  /**
2155
2215
  * @deprecated Extensions have been superseded by AssetSources and should no longer be used.
2156
2216
  */
2157
2217
  extensions: ConfigTypes.Extensions;
2158
2218
  core: ConfigTypes.Core;
2159
2219
  scene: ConfigTypes.Scene;
2160
- page: ConfigTypes.Page;
2161
2220
  assetSources: ConfigTypes.AssetSources;
2162
2221
  presets: ConfigTypes.Presets;
2163
2222
  variables: ConfigTypes.Variables;
@@ -2229,7 +2288,7 @@ declare class CreativeEngine {
2229
2288
  * @param config - An optional configuration object.
2230
2289
  * @returns An engine instance.
2231
2290
  */
2232
- static init(config?: Partial<Configuration>): Promise<CreativeEngine>;
2291
+ static init(config?: Partial<Configuration> & OldConfiguration): Promise<CreativeEngine>;
2233
2292
  }
2234
2293
  export default CreativeEngine;
2235
2294
 
@@ -2262,8 +2321,11 @@ export declare enum DesignBlockType {
2262
2321
  Group = "//ly.img.ubq/group"
2263
2322
  }
2264
2323
 
2265
- /** @public */
2266
- export declare type DesignUnit = 'mm' | 'px' | 'in';
2324
+ /**
2325
+ * The scene layout determines how the layout stack should layout its pages.
2326
+ * @public
2327
+ */
2328
+ export declare type DesignUnit = 'Pixel' | 'Millimeter' | 'Inch';
2267
2329
 
2268
2330
  /**
2269
2331
  * @public
@@ -2276,7 +2338,7 @@ export declare class EditorAPI {
2276
2338
  * @param callback - This function is called at the end of the engine update, if the editor state has changed.
2277
2339
  * @returns A method to unsubscribe.
2278
2340
  */
2279
- onStateChanged(callback: () => void): () => void;
2341
+ onStateChanged: (callback: () => void) => (() => void);
2280
2342
  /**
2281
2343
  * Set the edit mode of the editor.
2282
2344
  * An edit mode defines what type of content can currently be edited by the user.
@@ -2362,13 +2424,13 @@ export declare class EditorAPI {
2362
2424
  * @param callback - This function is called at the end of the engine update, if the undo/redo history has been changed.
2363
2425
  * @returns A method to unsubscribe
2364
2426
  */
2365
- onHistoryUpdated(callback: () => void): () => void;
2427
+ onHistoryUpdated: (callback: () => void) => (() => void);
2366
2428
  /**
2367
2429
  * Subscribe to changes to the editor settings.
2368
2430
  * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
2369
2431
  * @returns A method to unsubscribe.
2370
2432
  */
2371
- onSettingsChanged(callback: () => void): () => void;
2433
+ onSettingsChanged: (callback: () => void) => (() => void);
2372
2434
  /**
2373
2435
  * Set a boolean setting.
2374
2436
  * @param keypath - The settings keypath, e.g. `doubleClickToCropEnabled`
@@ -2536,7 +2598,7 @@ export declare class EventAPI {
2536
2598
  * @param callback - The event callback. Events are bundled and sent at the end of each engine update.
2537
2599
  * @returns A method to unsubscribe.
2538
2600
  */
2539
- subscribe(blocks: DesignBlockId[], callback: (events: BlockEvent[]) => void): () => void;
2601
+ subscribe: (blocks: DesignBlockId[], callback: (events: BlockEvent[]) => void) => (() => void);
2540
2602
  }
2541
2603
 
2542
2604
  /**
@@ -2708,7 +2770,38 @@ declare enum MimeType_2 {
2708
2770
  }
2709
2771
  export { MimeType_2 as MimeType }
2710
2772
 
2711
- /** @public */
2773
+ /**
2774
+ * Contains configuration keys that have been removed from the actual
2775
+ * configuration, but are still supported publicly
2776
+ * @public
2777
+ */
2778
+ export declare interface OldConfiguration {
2779
+ /**
2780
+ * @deprecated This config key has been removed.
2781
+ * You can configure a role via `setSettingEnum('role', role)` in the
2782
+ * EditorAPI.
2783
+ */
2784
+ role?: RoleString;
2785
+ /**
2786
+ * @deprecated This config key has been removed completely.
2787
+ * The settings that were configured here can be set via the
2788
+ * following EditorAPI settings:
2789
+ * - `setSettingBool('page/title/show', show)`
2790
+ * - `setSettingString('page/title/fontFileUri', uri)`
2791
+ * - `setSettingBool('page/title/dimOutOfPageAreas', dim)`
2792
+ */
2793
+ page?: Page;
2794
+ }
2795
+
2796
+ /**
2797
+ * @deprecated This type definition has been removed
2798
+ * The settings that were configured here can be set via the
2799
+ * following EditorAPI settings:
2800
+ * - `setSettingBool('page/title/show', show)`
2801
+ * - `setSettingString('page/title/fontFileUri', uri)`
2802
+ * - `setSettingBool('page/title/dimOutOfPageAreas', dim)`
2803
+ * @public
2804
+ */
2712
2805
  declare type Page = {
2713
2806
  title: {
2714
2807
  /**
@@ -2739,7 +2832,7 @@ export declare interface PageDuration {
2739
2832
  declare type PageFormatDefinition = Preset & {
2740
2833
  width: number;
2741
2834
  height: number;
2742
- unit: DesignUnit;
2835
+ unit: 'px' | 'mm' | 'in';
2743
2836
  fixedOrientation?: boolean;
2744
2837
  };
2745
2838
 
@@ -2898,11 +2991,19 @@ export declare class SceneAPI {
2898
2991
  * Fetching the image may take an arbitrary amount of time, so the scene isn't immediately
2899
2992
  * available.
2900
2993
  * @param url - The image URL.
2901
- * @param dpi - The scenes DPI.
2902
- * @param pixelScaleFactor - The displays pixel scale factor.
2994
+ * @param dpi - The scene's DPI.
2995
+ * @param pixelScaleFactor - The display's pixel scale factor.
2903
2996
  * @returns A promise that resolves with the scene ID on success or rejected with an error otherwise.
2904
2997
  */
2905
2998
  createFromImage(url: string, dpi?: number, pixelScaleFactor?: number, sceneLayout?: SceneLayout, spacing?: number, spacingInScreenSpace?: boolean): Promise<DesignBlockId>;
2999
+ /**
3000
+ * Loads the given video and creates a scene with a single page showing the video.
3001
+ * Fetching the video may take an arbitrary amount of time, so the scene isn't immediately
3002
+ * available.
3003
+ * @param url - The video URL.
3004
+ * @returns A promise that resolves with the scene ID on success or rejected with an error otherwise.
3005
+ */
3006
+ createFromVideo(url: string): Promise<DesignBlockId>;
2906
3007
  /**
2907
3008
  * Return the currently active scene.
2908
3009
  * @returns The scene or null, if none was created yet.
@@ -2931,6 +3032,16 @@ export declare class SceneAPI {
2931
3032
  * @returns The current mode of the scene.
2932
3033
  */
2933
3034
  getMode(): SceneMode;
3035
+ /**
3036
+ * Converts all values of the current scene into the given design unit.
3037
+ * @param designUnit - The new design unit of the scene
3038
+ */
3039
+ setDesignUnit(designUnit: DesignUnit): void;
3040
+ /**
3041
+ * Returns the design unit of the current scene.
3042
+ * @returns The current design unit.
3043
+ */
3044
+ getDesignUnit(): DesignUnit;
2934
3045
  /**
2935
3046
  * Get the sorted list of pages in the scene.
2936
3047
  * @returns The sorted list of pages in the scene.
@@ -3008,23 +3119,13 @@ export declare class SceneAPI {
3008
3119
  * @returns A method to unsubscribe.
3009
3120
  * @privateRemarks This will currently fire on _all_ changes to camera properties
3010
3121
  */
3011
- onZoomLevelChanged(callback: () => void): () => void;
3122
+ onZoomLevelChanged: (callback: () => void) => (() => void);
3012
3123
  /**
3013
3124
  * Subscribe to changes to the active scene rendered by the engine.
3014
3125
  * @param callback - This function is called at the end of the engine update, if the active scene has changed.
3015
3126
  * @returns A method to unsubscribe.
3016
3127
  */
3017
- onActiveChanged(callback: () => void): () => void;
3018
- /**
3019
- * Converts all values of the current scene into the given design unit.
3020
- * @param designUnit - The new design unit of the scene
3021
- */
3022
- unstable_setDesignUnit(designUnit: DesignUnit): void;
3023
- /**
3024
- * Returns the design unit of the current scene.
3025
- * @returns The current design unit.
3026
- */
3027
- unstable_getDesignUnit(): DesignUnit;
3128
+ onActiveChanged: (callback: () => void) => (() => void);
3028
3129
  }
3029
3130
 
3030
3131
  /**
@@ -3076,8 +3177,6 @@ export declare type SizeMode = 'Absolute' | 'Percent' | 'Auto';
3076
3177
  /** @public */
3077
3178
  export declare interface SpotColor {
3078
3179
  name: string;
3079
- rgbApproximation: RGBAColor;
3080
- cmykApproximation: CMYKColor;
3081
3180
  }
3082
3181
 
3083
3182
  declare interface SpotColorLookup {
@@ -3174,6 +3273,56 @@ export declare interface Vec4 {
3174
3273
  w: number;
3175
3274
  }
3176
3275
 
3276
+ /**
3277
+ * @public
3278
+ */
3279
+ export declare type VideoExportOptions = {
3280
+ /**
3281
+ * Determines the encoder feature set and in turn the quality, size and speed of the encoding process.
3282
+ *
3283
+ * @defaultValue 77 (Main)
3284
+ */
3285
+ h264Profile?: number;
3286
+ /**
3287
+ * Controls the H.264 encoding level. This relates to parameters used by the encoder such as bit rate,
3288
+ * timings and motion vectors. Defined by the spec are levels 1.0 up to 6.2. To arrive at an integer value,
3289
+ * the level is multiplied by ten. E.g. to get level 5.2, pass a value of 52.
3290
+ *
3291
+ * @defaultValue 52
3292
+ */
3293
+ h264Level?: number;
3294
+ /**
3295
+ * The time offset in seconds of the scene's timeline from which the video will start.
3296
+ *
3297
+ * @defaultValue 0
3298
+ */
3299
+ timeOffset?: number;
3300
+ /**
3301
+ * The duration in seconds of the final video.
3302
+ *
3303
+ * @defaultValue The duration of the scene.
3304
+ */
3305
+ duration?: number;
3306
+ /**
3307
+ * The target framerate of the exported video in Hz.
3308
+ *
3309
+ * @defaultValue 30
3310
+ */
3311
+ framerate?: number;
3312
+ /**
3313
+ * An optional target width used in conjunction with target height.
3314
+ * If used, the block will be rendered large enough, that it fills the target
3315
+ * size entirely while maintaining its aspect ratio.
3316
+ */
3317
+ targetWidth?: number;
3318
+ /**
3319
+ * An optional target height used in conjunction with target width.
3320
+ * If used, the block will be rendered large enough, that it fills the target
3321
+ * size entirely while maintaining its aspect ratio.
3322
+ */
3323
+ targetHeight?: number;
3324
+ };
3325
+
3177
3326
  /**
3178
3327
  * Describes a rectangle on the screen
3179
3328
  * - `x` and `y` indicate the position