@cesdk/engine 1.7.0-alpha.2 → 1.7.0-alpha.5

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.
Binary file
package/index.d.ts CHANGED
@@ -11,7 +11,6 @@ export declare interface Asset {
11
11
  */
12
12
  id: string;
13
13
  /** E.g. `ly.img.image` */
14
- type: string;
15
14
  /** Groups of the asset. */
16
15
  groups?: Groups;
17
16
  /** URI to a thumbnail of the asset used e.g. in the content library UI */
@@ -21,6 +20,7 @@ export declare interface Asset {
21
20
  meta?: {
22
21
  uri?: string;
23
22
  filename?: string;
23
+ vectorPath?: string;
24
24
  } & Record<string, unknown>;
25
25
  }
26
26
 
@@ -45,57 +45,46 @@ export declare class AssetAPI {
45
45
  * @returns A list with the IDs of all registered asset sources.
46
46
  */
47
47
  findAllSources(): string[];
48
- /**
49
- * Finds all asset sources which support the given asset type.
50
- * @returns A list of the IDs of the supported asset sources.
51
- */
52
- findSourcesByType(type: string): string[];
53
48
  /**
54
49
  * Finds assets of a given type in a specific asset source.
55
- * @param id - The ID of the asset source.
56
- * @param type - The asset type to look for.
50
+ * @param sourceId - The ID of the asset source.
57
51
  * @param query - All the options to filter the search results by.
58
52
  * @returns The search results.
59
53
  */
60
- findAssetsInSource(id: string, type: string, query: AssetQueryData): Promise<AssetsQueryResult>;
54
+ findAssets(sourceId: string, query: AssetQueryData): Promise<AssetsQueryResult>;
61
55
  /**
62
56
  * Queries the asset source's groups for a certain asset type.
63
57
  * @param id - The ID of the asset source.
64
- * @param type - The asset type to filter by.
65
58
  * @returns The asset groups.
66
59
  */
67
- getGroupsInSource(id: string, type: string): Promise<string[]>;
68
- /**
69
- * Queries the asset source's supported asset types.
70
- * @param id - The ID of the asset source.
71
- * @returns A list of the asset source's supported types.
72
- */
73
- getTypesInSource(id: string): string[];
74
- /**
75
- * Checks whether the asset source supports the given asset type.
76
- * @param id - The ID of the asset source.
77
- * @param type - The asset type to check.
78
- * @returns A boolean indicating whether the type is supported.
79
- */
80
- hasTypeInSource(id: string, type: string): boolean;
60
+ getGroups(id: string): Promise<string[]>;
81
61
  /**
82
62
  * Queries the asset source's credits info.
83
- * @param id - The ID of the asset source.
63
+ * @param sourceId - The ID of the asset source.
84
64
  * @returns The asset source's credits info consisting of a name and an optional URL.
85
65
  */
86
- getSourceCredits(id: string): {
66
+ getCredits(sourceId: string): {
87
67
  name: string;
88
68
  url: string | undefined;
89
69
  } | undefined;
90
70
  /**
91
71
  * Queries the asset source's license info.
92
- * @param id - The ID of the asset source.
72
+ * @param sourceId - The ID of the asset source.
93
73
  * @returns The asset source's license info consisting of a name and an optional URL.
94
74
  */
95
- getSourceLicense(id: string): {
75
+ getLicense(sourceId: string): {
96
76
  name: string;
97
77
  url: string | undefined;
98
78
  } | undefined;
79
+ canManageAssets(sourceId: string): boolean;
80
+ /**
81
+ * Apply an asset result to the active scene.
82
+ * The default behavior will instantiate a block and configure it according to the asset's properties.
83
+ * Note that this can be overridden by providing an `applyAsset` function when adding the asset source.
84
+ * @param sourceId - The ID of the asset source.
85
+ * @param assetResult - A single assetResult of a `findAssets` query.
86
+ */
87
+ apply(sourceId: string, assetResult: AssetResult): Promise<void>;
99
88
  }
100
89
 
101
90
  /**
@@ -183,8 +172,6 @@ export declare interface AssetResult extends Asset {
183
172
  declare interface AssetResult_2 {
184
173
  /** A unique id of this asset */
185
174
  id: string;
186
- /** E.g. `ly.img.image` */
187
- type: string;
188
175
  /** URI to a thumbnail of the asset used e.g. in the content library UI */
189
176
  thumbUri: string;
190
177
  /** Original size of the asset. */
@@ -224,21 +211,6 @@ declare interface AssetResultContext {
224
211
  createdByRole: string;
225
212
  }
226
213
 
227
- declare interface AssetResultCredits {
228
- name: string;
229
- url: string;
230
- }
231
-
232
- declare interface AssetResultLicense {
233
- name: string;
234
- url: string;
235
- }
236
-
237
- declare interface AssetResultUtm {
238
- source: string;
239
- medium: string;
240
- }
241
-
242
214
  /**
243
215
  * A source of assets
244
216
  * @public
@@ -247,13 +219,9 @@ export declare interface AssetSource {
247
219
  /** The unique id of the API */
248
220
  id: string;
249
221
  /** Find all asset for the given type and the provided query data. */
250
- findAssets(type: string, queryData: AssetQueryData): Promise<AssetsQueryResult>;
251
- /** For a given type return every available group */
252
- getGroups: (type: string) => Promise<string[]>;
253
- /** Return all registered/available types */
254
- getTypes: () => string[];
255
- /** The given type is registered. */
256
- hasType: (type: string) => boolean;
222
+ findAssets(queryData: AssetQueryData): Promise<AssetsQueryResult>;
223
+ /** Return every available group */
224
+ getGroups: () => Promise<string[]>;
257
225
  /** Credits for the source/api */
258
226
  credits?: {
259
227
  name: string;
@@ -282,13 +250,18 @@ export declare interface AssetSource {
282
250
  * error.
283
251
  */
284
252
  canManageAssets?: boolean;
253
+ /**
254
+ * Apply the given asset result to the active scene.
255
+ * You can override this with custom behavior.
256
+ */
257
+ applyAsset?: (asset: AssetResult) => Promise<void>;
285
258
  /**
286
259
  * Adds the given asset to this source. Throws an error if `canManageAssets`
287
260
  * is `false`.
288
261
  *
289
262
  * @returns the id of the added asset
290
263
  */
291
- addAsset(type: string, asset: AssetDefinition): Promise<string>;
264
+ addAsset(asset: AssetDefinition): Promise<string>;
292
265
  /**
293
266
  * Updates the asset of this source. Throws an error if `canManageAssets`
294
267
  * is `false` or no asset with the given id could not be found.
@@ -309,10 +282,13 @@ export declare interface AssetSource {
309
282
  * @public
310
283
  */
311
284
  declare interface AssetSource_2 {
312
- /** The asset types returned by this source. Will default to ['ly.img.image']. */
313
- types?: string[];
314
285
  /** Find all asset for the given type and the provided query data. */
315
- findAssets(type: string, queryData?: QueryData): Promise<AssetsQueryResult_2 | undefined>;
286
+ findAssets(queryData?: QueryData): Promise<AssetsQueryResult_2 | undefined>;
287
+ /**
288
+ * Apply the given asset result to the active scene.
289
+ * You can override this with custom behavior.
290
+ */
291
+ applyAsset?: (asset: AssetResult_2) => Promise<void>;
316
292
  /**
317
293
  * Indicates if the asset shall be downloaded to handle the raw data instead
318
294
  * of an URL reference. Do this if you do not want to depend on
@@ -1206,6 +1182,99 @@ export declare class BlockAPI {
1206
1182
  * @deprecated Use `getStrokeWidth`.
1207
1183
  */
1208
1184
  getOutlineWidth(id: DesignBlockId): number;
1185
+ /**
1186
+ * Query if the given block has a drop shadow property.
1187
+ * @param id - The block to query.
1188
+ * @returns True if the block has a drop shadow property.
1189
+ */
1190
+ hasDropShadow(id: DesignBlockId): boolean;
1191
+ /**
1192
+ * Enable or disable the drop shadow of the given design block.
1193
+ * @param id - The block whose drop shadow should be enabled or disabled.
1194
+ * @param enabled - If true, the drop shadow will be enabled.
1195
+ */
1196
+ setDropShadowEnabled(id: DesignBlockId, enabled: boolean): void;
1197
+ /**
1198
+ * Query if the drop shadow of the given design block is enabled.
1199
+ * @param id - The block whose drop shadow state should be queried.
1200
+ * @returns True if the block's drop shadow is enabled.
1201
+ */
1202
+ isDropShadowEnabled(id: DesignBlockId): boolean;
1203
+ /**
1204
+ * Set the drop shadow color of the given design block.
1205
+ * @param id - The block whose drop shadow color should be set.
1206
+ * @param r - The red color component in the range of 0 to 1.
1207
+ * @param g - The green color component in the range of 0 to 1.
1208
+ * @param b - The blue color component in the range of 0 to 1.
1209
+ * @param a - The alpha color component in the range of 0 to 1.
1210
+ */
1211
+ setDropShadowColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1212
+ /**
1213
+ * Get the drop shadow color of the given design block.
1214
+ * @param id - The block whose background color should be queried.
1215
+ * @returns The background color.
1216
+ */
1217
+ getDropShadowColorRGBA(id: DesignBlockId): RGBA;
1218
+ /**
1219
+ * Set the drop shadow's X offset of the given design block.
1220
+ * @param id - The block whose drop shadow's X offset should be set.
1221
+ * @param xOffset - The X offset to be set.
1222
+ */
1223
+ setDropShadowXOffset(id: DesignBlockId, xOffset: number): void;
1224
+ /**
1225
+ * Get the drop shadow's X offset of the given design block.
1226
+ * @param id - The block whose drop shadow's X offset should be queried.
1227
+ * @returns The offset.
1228
+ */
1229
+ getDropShadowXOffset(id: DesignBlockId): number;
1230
+ /**
1231
+ * Set the drop shadow's Y offset of the given design block.
1232
+ * @param id - The block whose drop shadow's Y offset should be set.
1233
+ * @param yOffset - The X offset to be set.
1234
+ */
1235
+ setDropShadowYOffset(id: DesignBlockId, yOffset: number): void;
1236
+ /**
1237
+ * Get the drop shadow's Y offset of the given design block.
1238
+ * @param id - The block whose drop shadow's Y offset should be queried.
1239
+ * @returns The offset.
1240
+ */
1241
+ getDropShadowYOffset(id: DesignBlockId): number;
1242
+ /**
1243
+ * Set the drop shadow's blur radius on the X axis of the given design block.
1244
+ * @param id - The block whose drop shadow's blur radius should be set.
1245
+ * @param xBlurRadius - The blur radius to be set.
1246
+ */
1247
+ setDropShadowXBlurRadius(id: DesignBlockId, xBlurRadius: number): void;
1248
+ /**
1249
+ * Get the drop shadow's blur radius on the X axis of the given design block.
1250
+ * @param id - The block whose drop shadow's blur radius should be queried.
1251
+ * @returns The blur radius.
1252
+ */
1253
+ getDropShadowXBlurRadius(id: DesignBlockId): number;
1254
+ /**
1255
+ * Set the drop shadow's blur radius on the Y axis of the given design block.
1256
+ * @param id - The block whose drop shadow's blur radius should be set.
1257
+ * @param yBlurRadius - The blur radius to be set.
1258
+ */
1259
+ setDropShadowYBlurRadius(id: DesignBlockId, yBlurRadius: number): void;
1260
+ /**
1261
+ * Get the drop shadow's blur radius on the Y axis of the given design block.
1262
+ * @param id - The block whose drop shadow's blur radius should be queried.
1263
+ * @returns The blur radius.
1264
+ */
1265
+ getDropShadowYBlurRadius(id: DesignBlockId): number;
1266
+ /**
1267
+ * Set the drop shadow's clipping of the given design block. (Only applies to shapes.)
1268
+ * @param id - The block whose drop shadow's clip should be set.
1269
+ * @param clip - The drop shadow's clip to be set.
1270
+ */
1271
+ setDropShadowClip(id: DesignBlockId, clip: boolean): void;
1272
+ /**
1273
+ * Get the drop shadow's clipping of the given design block.
1274
+ * @param id - The block whose drop shadow's clipping should be queried.
1275
+ * @returns The drop shadow's clipping.
1276
+ */
1277
+ getDropShadowClip(id: DesignBlockId): boolean;
1209
1278
  /**
1210
1279
  * Query if the given block has fill color properties.
1211
1280
  * @param id - The block to query.
@@ -1225,6 +1294,12 @@ export declare class BlockAPI {
1225
1294
  * @returns An empty result on success, an error otherwise.
1226
1295
  */
1227
1296
  setFillEnabled(id: DesignBlockId, enabled: boolean): void;
1297
+ /**
1298
+ * Returns the block containing the fill properties of the given block.
1299
+ * @param id - The block whose fill block should be returned.
1300
+ * @returns The block that currently defines the given block's fill.
1301
+ */
1302
+ getFill(id: DesignBlockId): DesignBlockId;
1228
1303
  /**
1229
1304
  * Set the fill type of the given design block.
1230
1305
  * @param id - The block whose fill type should be set.
@@ -1337,6 +1412,36 @@ export declare class BlockAPI {
1337
1412
  * @returns the gradient's radius, an error otherwise.
1338
1413
  */
1339
1414
  getFillGradientRadius(id: DesignBlockId): number;
1415
+ /**
1416
+ * Set a metadata value of a block identified by a key.
1417
+ * If the key does not exist, yet, it will be added.
1418
+ * @param block - The block whose metadata will be accessed.
1419
+ * @param key - The key used to identify the desired piece of metadata.
1420
+ * @param value - The value to set.
1421
+ */
1422
+ setMetadata(id: DesignBlockId, key: string, value: string): void;
1423
+ /**
1424
+ * Get a metadata value of a block identified by a key.
1425
+ * If the key does not exist, yet, this method will fail.
1426
+ * @param block - The block whose metadata will be accessed.
1427
+ * @param key - The key used to identify the desired piece of metadata.
1428
+ * @returns the value associated with the key.
1429
+ */
1430
+ getMetadata(id: DesignBlockId, key: string): string;
1431
+ /**
1432
+ * Check if the block has metadata associated with the key.
1433
+ * @param block - The block whose metadata will be accessed.
1434
+ * @param key - The key used to identify the desired piece of metadata.
1435
+ * @returns whether the key exists.
1436
+ */
1437
+ hasMetadata(id: DesignBlockId, key: string): boolean;
1438
+ /**
1439
+ * Remove metadata associated with the key from the given block.
1440
+ * If the key does not exist, this method will fail.
1441
+ * @param block - The block whose metadata will be accessed.
1442
+ * @param key - The key used to identify the desired piece of metadata.
1443
+ */
1444
+ removeMetadata(id: DesignBlockId, key: string): void;
1340
1445
  }
1341
1446
 
1342
1447
  /**
@@ -1353,6 +1458,19 @@ declare interface BlockEvent_2 {
1353
1458
  type: 'Created' | 'Updated' | 'Destroyed';
1354
1459
  }
1355
1460
 
1461
+ /**
1462
+ * Dispatched on the engine canvas when the text input has been blurred.
1463
+ * Call `preventDefault()` to disallow this and refocus the engine text input.
1464
+ * @public
1465
+ */
1466
+ export declare interface BlurEvent extends CustomEvent<EventTarget | null> {
1467
+ readonly type: 'cesdk-blur';
1468
+ /** Contains the element that has received focus during the blur, or null */
1469
+ readonly detail: EventTarget | null;
1470
+ /** Force focus back to the engine input */
1471
+ preventDefault(): void;
1472
+ }
1473
+
1356
1474
  /** @public */
1357
1475
  declare type Callbacks = {
1358
1476
  log?: Logger;
@@ -1460,12 +1578,12 @@ declare type Core = {
1460
1578
  */
1461
1579
  declare class CreativeEngine {
1462
1580
  #private;
1581
+ asset: AssetAPI;
1463
1582
  block: BlockAPI;
1464
- scene: SceneAPI;
1465
- variable: VariableAPI;
1466
1583
  editor: EditorAPI;
1467
- asset: AssetAPI;
1468
1584
  event: EventAPI;
1585
+ scene: SceneAPI;
1586
+ variable: VariableAPI;
1469
1587
 
1470
1588
  /**
1471
1589
  * Dispose the engine.
@@ -1557,16 +1675,6 @@ export declare class EditorAPI {
1557
1675
  * @returns The text cursor's y position in screen space.
1558
1676
  */
1559
1677
  getTextCursorPositionInScreenSpaceY(): number;
1560
- /**
1561
- * Sets the zoom level of the scene.
1562
- * @param zoomLevel - The new zoom level.
1563
- */
1564
- setZoomLevel(zoomLevel?: number): void;
1565
- /**
1566
- * Query a camera zoom level.
1567
- * @returns The zoom level of the block's (main) camera.
1568
- */
1569
- getZoomLevel(): number;
1570
1678
  /**
1571
1679
  * Adds a new history state to the stack, if undoable changes were made.
1572
1680
  */
@@ -1591,6 +1699,12 @@ export declare class EditorAPI {
1591
1699
  * @returns True if a redo step is available.
1592
1700
  */
1593
1701
  canRedo(): boolean;
1702
+ /**
1703
+ * Subscribe to changes to the editor settings.
1704
+ * @param callback - This function is called at the end of the engine update, if the editor settings have changed.
1705
+ * @returns A method to unsubscribe.
1706
+ */
1707
+ onSettingsChanged(callback: () => void): () => void;
1594
1708
  /**
1595
1709
  * Set a boolean setting.
1596
1710
  * @param keypath - The settings keypath, e.g. `ubq://doubleClickToCropEnabled`
@@ -1770,23 +1884,7 @@ declare type Extensions = {
1770
1884
  */
1771
1885
  export declare type FillType = 'Solid' | 'Gradient';
1772
1886
 
1773
- declare interface FindAssetResult {
1774
- id: string;
1775
- type: string;
1776
- groups: Vector<string>;
1777
- thumbUri: string;
1778
- width: number;
1779
- height: number;
1780
- meta: UnorderedMap<string, string>;
1781
- locale: string;
1782
- label: string;
1783
- tags: Vector<string>;
1784
- context: AssetResultContext;
1785
- credits: AssetResultCredits;
1786
- license: AssetResultLicense;
1787
- utm: AssetResultUtm;
1788
- }
1789
-
1887
+ /** @public */
1790
1888
  declare interface FindAssetsQuery {
1791
1889
  perPage: number;
1792
1890
  page: number;
@@ -1797,23 +1895,6 @@ declare interface FindAssetsQuery {
1797
1895
  locale: string;
1798
1896
  }
1799
1897
 
1800
- declare interface FindAssetsQueryCpp {
1801
- perPage: number;
1802
- page: number;
1803
- query: string;
1804
- tags: Vector<string>;
1805
- groups: Vector<string>;
1806
- excludeGroups: Vector<string>;
1807
- locale: string;
1808
- }
1809
-
1810
- declare interface FindAssetsResult {
1811
- assets: Vector<FindAssetResult>;
1812
- currentPage: number;
1813
- nextPage: number;
1814
- total: number;
1815
- }
1816
-
1817
1898
  /** @public */
1818
1899
  declare interface Flip {
1819
1900
  horizontal: boolean;
@@ -1990,6 +2071,19 @@ declare interface QueryData {
1990
2071
  page: number;
1991
2072
  }
1992
2073
 
2074
+ /**
2075
+ * Dispatched on the engine canvas right before the engine will refocus its text
2076
+ * input after a blur. Call `preventDefault()` to prevent the refocusing.
2077
+ * @public
2078
+ */
2079
+ export declare interface RefocusEvent extends CustomEvent<EventTarget | null> {
2080
+ readonly type: 'cesdk-refocus';
2081
+ /** Contains the element that has received focus during the blur, or null */
2082
+ readonly detail: EventTarget | null;
2083
+ /** Prevent refocusing the engine input */
2084
+ preventDefault(): void;
2085
+ }
2086
+
1993
2087
  /**
1994
2088
  * @public
1995
2089
  */
@@ -2114,6 +2208,31 @@ export declare class SceneAPI {
2114
2208
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
2115
2209
  */
2116
2210
  applyTemplateFromURL(url: string): Promise<void>;
2211
+ /**
2212
+ * Sets the zoom level of the active scene.
2213
+ * Only has an effect if the zoom level is not handled by the UI.
2214
+ *
2215
+ * @param zoomLevel - The new zoom level.
2216
+ */
2217
+ setZoomLevel(zoomLevel?: number): void;
2218
+ /**
2219
+ * Query a camera zoom level of the active scene.
2220
+ * @returns The zoom level of the block's camera.
2221
+ */
2222
+ getZoomLevel(): number;
2223
+ /**
2224
+ * Sets the zoom and focus to show a block.
2225
+ * Only has an effect if the zoom level is not handled by the UI.
2226
+ * Without padding, this results in a tight view on the block.
2227
+ *
2228
+ * @param id - The block that should be focused on.
2229
+ * @param paddingLeft - Optional padding in screen pixels to the left of the block.
2230
+ * @param paddingTop - Optional padding in screen pixels to the top of the block.
2231
+ * @param paddingRight - Optional padding in screen pixels to the right of the block.
2232
+ * @param paddingBottom - Optional padding in screen pixels to the bottom of the block.
2233
+ * @returns A promise that resolves once the zoom was set or rejects with an error otherwise.
2234
+ */
2235
+ zoomToBlock(id: DesignBlockId, paddingLeft?: number, paddingTop?: number, paddingRight?: number, paddingBottom?: number): Promise<void>;
2117
2236
  /**
2118
2237
  * Converts all values of the current scene into the given design unit.
2119
2238
  * @param designUnit - The new design unit of the scene
@@ -2177,13 +2296,6 @@ declare type TypefaceDefinition = Preset & {
2177
2296
  }[];
2178
2297
  };
2179
2298
 
2180
- declare interface UnorderedMap<K, V> {
2181
- size: () => number;
2182
- get: (key: K) => V;
2183
- set: (key: K, value: V) => void;
2184
- keys: () => Vector<K>;
2185
- }
2186
-
2187
2299
  /**
2188
2300
  * @public
2189
2301
  */