@cesdk/engine 1.7.0-alpha.0 → 1.7.0-alpha.3

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
Binary file
package/index.d.ts CHANGED
@@ -25,34 +25,77 @@ export declare interface Asset {
25
25
  }
26
26
 
27
27
  /**
28
- * API to query for assets.
29
- *
30
- * Could be remote or local.
31
- *
32
- * @typeParam QData - The shape of queries made against this API
33
28
  * @public
34
29
  */
35
- export declare interface AssetAPI<QData extends AssetQueryData> {
36
- /** The unique id of the API */
37
- id: string;
38
- /** Find all asset for the given type and the provided query data. */
39
- findAssets(type: string, queryData?: QData): Promise<AssetsQueryResult>;
40
- /** For a given type return every available group */
41
- getGroups: (type: string) => Promise<string[]>;
42
- /** Return all registered/available types */
43
- getTypes: () => string[];
44
- /** The given type is registered. */
45
- hasType: (type: string) => boolean;
46
- /** Credits for the source/api */
47
- credits?: {
30
+ export declare class AssetAPI {
31
+ #private;
32
+
33
+ /**
34
+ * Adds a custom asset source. Its ID has to be unique.
35
+ * @param source - The asset source.
36
+ */
37
+ addSource(source: AssetSource): void;
38
+ /**
39
+ * Removes an asset source with the given ID.
40
+ * @param id - The ID to refer to the asset source.
41
+ */
42
+ removeSource(id: string): void;
43
+ /**
44
+ * Finds all registered asset sources.
45
+ * @returns A list with the IDs of all registered asset sources.
46
+ */
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
+ /**
54
+ * 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.
57
+ * @param query - All the options to filter the search results by.
58
+ * @returns The search results.
59
+ */
60
+ findAssetsInSource(id: string, type: string, query: AssetQueryData): Promise<AssetsQueryResult>;
61
+ /**
62
+ * Queries the asset source's groups for a certain asset type.
63
+ * @param id - The ID of the asset source.
64
+ * @param type - The asset type to filter by.
65
+ * @returns The asset groups.
66
+ */
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;
81
+ /**
82
+ * Queries the asset source's credits info.
83
+ * @param id - The ID of the asset source.
84
+ * @returns The asset source's credits info consisting of a name and an optional URL.
85
+ */
86
+ getSourceCredits(id: string): {
48
87
  name: string;
49
- url?: string;
50
- };
51
- /** General license for all asset from this source */
52
- license?: {
88
+ url: string | undefined;
89
+ } | undefined;
90
+ /**
91
+ * Queries the asset source's license info.
92
+ * @param id - The ID of the asset source.
93
+ * @returns The asset source's license info consisting of a name and an optional URL.
94
+ */
95
+ getSourceLicense(id: string): {
53
96
  name: string;
54
- url?: string;
55
- };
97
+ url: string | undefined;
98
+ } | undefined;
56
99
  }
57
100
 
58
101
  /**
@@ -81,6 +124,8 @@ export declare interface AssetDefinition extends Asset {
81
124
  export declare interface AssetQueryData {
82
125
  /** A query string used for (fuzzy) searching of labels and tags */
83
126
  query?: string;
127
+ /** The current page queried for paginated views. */
128
+ page: number;
84
129
  /**
85
130
  * Tags are searched with the query parameter, but this search is fuzzy.
86
131
  * If one needs to get assets with exactly the tag (from a tag cloud or filter)
@@ -102,21 +147,6 @@ export declare interface AssetQueryData {
102
147
  perPage: number;
103
148
  }
104
149
 
105
- /**
106
- * The registry of all available assets and sources registered in the engine.
107
- * @public
108
- */
109
- export declare interface AssetRegistry {
110
- /** Returns all sources available in the engine */
111
- getSources(type?: string): AssetSource[];
112
- /** Returns a source with the given id or undefined if not found */
113
- getSource(id: string): AssetSource | undefined;
114
- /** Adds a source to this registry. */
115
- addSource(source: AssetSource): void;
116
- /** Removes a source from this registry. */
117
- removeSource(id: string): void;
118
- }
119
-
120
150
  /**
121
151
  * Single asset result of a query from the engine.
122
152
  * @public
@@ -188,17 +218,52 @@ declare interface AssetResult_2 {
188
218
  };
189
219
  }
190
220
 
221
+ /** @public */
222
+ declare interface AssetResultContext {
223
+ sourceId: string;
224
+ createdByRole: string;
225
+ }
226
+
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
+
191
242
  /**
192
243
  * A source of assets
193
244
  * @public
194
245
  */
195
- export declare interface AssetSource extends AssetAPI<PaginatedAssetQueryData> {
196
- /**
197
- * Can the source add, update and remove assets dynamically? If `false`
198
- * methods like `addAsset` `updateAsset` and `removeAsset` will throw and
199
- * error.
200
- */
201
- canManageAssets?: boolean;
246
+ export declare interface AssetSource {
247
+ /** The unique id of the API */
248
+ id: string;
249
+ /** 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;
257
+ /** Credits for the source/api */
258
+ credits?: {
259
+ name: string;
260
+ url?: string;
261
+ };
262
+ /** General license for all asset from this source */
263
+ license?: {
264
+ name: string;
265
+ url?: string;
266
+ };
202
267
  /**
203
268
  * Indicates if the asset shall be downloaded to handle the raw data instead
204
269
  * of an URL reference. Do this if you do not want to depend on
@@ -211,6 +276,12 @@ export declare interface AssetSource extends AssetAPI<PaginatedAssetQueryData> {
211
276
  * @returns the asset or undefined if no asset with the given id could be found
212
277
  */
213
278
  getAsset(id: string): Promise<AssetResult | undefined>;
279
+ /**
280
+ * Can the source add, update and remove assets dynamically? If `false`
281
+ * methods like `addAsset` `updateAsset` and `removeAsset` will throw an
282
+ * error.
283
+ */
284
+ canManageAssets?: boolean;
214
285
  /**
215
286
  * Adds the given asset to this source. Throws an error if `canManageAssets`
216
287
  * is `false`.
@@ -316,9 +387,10 @@ export declare class BlockAPI {
316
387
  * Performs an internal update to resolve the final layout for the blocks.
317
388
  * @param handle - The design block element to export.
318
389
  * @param mimeType - The mime type of the output file.
390
+ * @param options - The options for exporting the block type
319
391
  * @returns A promise that resolves with the exported image or is rejected with an error.
320
392
  */
321
- export(handle: DesignBlockId, mimeType?: MimeType_2): Promise<Blob>;
393
+ export(handle: DesignBlockId, mimeType?: MimeType_2, options?: ExportOptions): Promise<Blob>;
322
394
 
323
395
  /**
324
396
  * Loads existing blocks from the given string.
@@ -1134,6 +1206,99 @@ export declare class BlockAPI {
1134
1206
  * @deprecated Use `getStrokeWidth`.
1135
1207
  */
1136
1208
  getOutlineWidth(id: DesignBlockId): number;
1209
+ /**
1210
+ * Query if the given block has a drop shadow property.
1211
+ * @param id - The block to query.
1212
+ * @returns True if the block has a drop shadow property.
1213
+ */
1214
+ hasDropShadow(id: DesignBlockId): boolean;
1215
+ /**
1216
+ * Enable or disable the drop shadow of the given design block.
1217
+ * @param id - The block whose drop shadow should be enabled or disabled.
1218
+ * @param enabled - If true, the drop shadow will be enabled.
1219
+ */
1220
+ setDropShadowEnabled(id: DesignBlockId, enabled: boolean): void;
1221
+ /**
1222
+ * Query if the drop shadow of the given design block is enabled.
1223
+ * @param id - The block whose drop shadow state should be queried.
1224
+ * @returns True if the block's drop shadow is enabled.
1225
+ */
1226
+ isDropShadowEnabled(id: DesignBlockId): boolean;
1227
+ /**
1228
+ * Set the drop shadow color of the given design block.
1229
+ * @param id - The block whose drop shadow color should be set.
1230
+ * @param r - The red color component in the range of 0 to 1.
1231
+ * @param g - The green color component in the range of 0 to 1.
1232
+ * @param b - The blue color component in the range of 0 to 1.
1233
+ * @param a - The alpha color component in the range of 0 to 1.
1234
+ */
1235
+ setDropShadowColorRGBA(id: DesignBlockId, r: number, g: number, b: number, a?: number): void;
1236
+ /**
1237
+ * Get the drop shadow color of the given design block.
1238
+ * @param id - The block whose background color should be queried.
1239
+ * @returns The background color.
1240
+ */
1241
+ getDropShadowColorRGBA(id: DesignBlockId): RGBA;
1242
+ /**
1243
+ * Set the drop shadow's X offset of the given design block.
1244
+ * @param id - The block whose drop shadow's X offset should be set.
1245
+ * @param xOffset - The X offset to be set.
1246
+ */
1247
+ setDropShadowXOffset(id: DesignBlockId, xOffset: number): void;
1248
+ /**
1249
+ * Get the drop shadow's X offset of the given design block.
1250
+ * @param id - The block whose drop shadow's X offset should be queried.
1251
+ * @returns The offset.
1252
+ */
1253
+ getDropShadowXOffset(id: DesignBlockId): number;
1254
+ /**
1255
+ * Set the drop shadow's Y offset of the given design block.
1256
+ * @param id - The block whose drop shadow's Y offset should be set.
1257
+ * @param yOffset - The X offset to be set.
1258
+ */
1259
+ setDropShadowYOffset(id: DesignBlockId, yOffset: number): void;
1260
+ /**
1261
+ * Get the drop shadow's Y offset of the given design block.
1262
+ * @param id - The block whose drop shadow's Y offset should be queried.
1263
+ * @returns The offset.
1264
+ */
1265
+ getDropShadowYOffset(id: DesignBlockId): number;
1266
+ /**
1267
+ * Set the drop shadow's blur radius on the X axis of the given design block.
1268
+ * @param id - The block whose drop shadow's blur radius should be set.
1269
+ * @param xBlurRadius - The blur radius to be set.
1270
+ */
1271
+ setDropShadowXBlurRadius(id: DesignBlockId, xBlurRadius: number): void;
1272
+ /**
1273
+ * Get the drop shadow's blur radius on the X axis of the given design block.
1274
+ * @param id - The block whose drop shadow's blur radius should be queried.
1275
+ * @returns The blur radius.
1276
+ */
1277
+ getDropShadowXBlurRadius(id: DesignBlockId): number;
1278
+ /**
1279
+ * Set the drop shadow's blur radius on the Y axis of the given design block.
1280
+ * @param id - The block whose drop shadow's blur radius should be set.
1281
+ * @param yBlurRadius - The blur radius to be set.
1282
+ */
1283
+ setDropShadowYBlurRadius(id: DesignBlockId, yBlurRadius: number): void;
1284
+ /**
1285
+ * Get the drop shadow's blur radius on the Y axis of the given design block.
1286
+ * @param id - The block whose drop shadow's blur radius should be queried.
1287
+ * @returns The blur radius.
1288
+ */
1289
+ getDropShadowYBlurRadius(id: DesignBlockId): number;
1290
+ /**
1291
+ * Set the drop shadow's clipping of the given design block. (Only applies to shapes.)
1292
+ * @param id - The block whose drop shadow's clip should be set.
1293
+ * @param clip - The drop shadow's clip to be set.
1294
+ */
1295
+ setDropShadowClip(id: DesignBlockId, clip: boolean): void;
1296
+ /**
1297
+ * Get the drop shadow's clipping of the given design block.
1298
+ * @param id - The block whose drop shadow's clipping should be queried.
1299
+ * @returns The drop shadow's clipping.
1300
+ */
1301
+ getDropShadowClip(id: DesignBlockId): boolean;
1137
1302
  /**
1138
1303
  * Query if the given block has fill color properties.
1139
1304
  * @param id - The block to query.
@@ -1153,6 +1318,12 @@ export declare class BlockAPI {
1153
1318
  * @returns An empty result on success, an error otherwise.
1154
1319
  */
1155
1320
  setFillEnabled(id: DesignBlockId, enabled: boolean): void;
1321
+ /**
1322
+ * Returns the block containing the fill properties of the given block.
1323
+ * @param id - The block whose fill block should be returned.
1324
+ * @returns The block that currently defines the given block's fill.
1325
+ */
1326
+ getFill(id: DesignBlockId): DesignBlockId;
1156
1327
  /**
1157
1328
  * Set the fill type of the given design block.
1158
1329
  * @param id - The block whose fill type should be set.
@@ -1265,6 +1436,36 @@ export declare class BlockAPI {
1265
1436
  * @returns the gradient's radius, an error otherwise.
1266
1437
  */
1267
1438
  getFillGradientRadius(id: DesignBlockId): number;
1439
+ /**
1440
+ * Set a metadata value of a block identified by a key.
1441
+ * If the key does not exist, yet, it will be added.
1442
+ * @param block - The block whose metadata will be accessed.
1443
+ * @param key - The key used to identify the desired piece of metadata.
1444
+ * @param value - The value to set.
1445
+ */
1446
+ setMetadata(id: DesignBlockId, key: string, value: string): void;
1447
+ /**
1448
+ * Get a metadata value of a block identified by a key.
1449
+ * If the key does not exist, yet, this method will fail.
1450
+ * @param block - The block whose metadata will be accessed.
1451
+ * @param key - The key used to identify the desired piece of metadata.
1452
+ * @returns the value associated with the key.
1453
+ */
1454
+ getMetadata(id: DesignBlockId, key: string): string;
1455
+ /**
1456
+ * Check if the block has metadata associated with the key.
1457
+ * @param block - The block whose metadata will be accessed.
1458
+ * @param key - The key used to identify the desired piece of metadata.
1459
+ * @returns whether the key exists.
1460
+ */
1461
+ hasMetadata(id: DesignBlockId, key: string): boolean;
1462
+ /**
1463
+ * Remove metadata associated with the key from the given block.
1464
+ * If the key does not exist, this method will fail.
1465
+ * @param block - The block whose metadata will be accessed.
1466
+ * @param key - The key used to identify the desired piece of metadata.
1467
+ */
1468
+ removeMetadata(id: DesignBlockId, key: string): void;
1268
1469
  }
1269
1470
 
1270
1471
  /**
@@ -1392,7 +1593,7 @@ declare class CreativeEngine {
1392
1593
  scene: SceneAPI;
1393
1594
  variable: VariableAPI;
1394
1595
  editor: EditorAPI;
1395
-
1596
+ asset: AssetAPI;
1396
1597
  event: EventAPI;
1397
1598
 
1398
1599
  /**
@@ -1485,16 +1686,6 @@ export declare class EditorAPI {
1485
1686
  * @returns The text cursor's y position in screen space.
1486
1687
  */
1487
1688
  getTextCursorPositionInScreenSpaceY(): number;
1488
- /**
1489
- * Sets the zoom level of the scene.
1490
- * @param zoomLevel - The new zoom level.
1491
- */
1492
- setZoomLevel(zoomLevel?: number): void;
1493
- /**
1494
- * Query a camera zoom level.
1495
- * @returns The zoom level of the block's (main) camera.
1496
- */
1497
- getZoomLevel(): number;
1498
1689
  /**
1499
1690
  * Adds a new history state to the stack, if undoable changes were made.
1500
1691
  */
@@ -1598,6 +1789,23 @@ export declare class EditorAPI {
1598
1789
  * @returns The value as string.
1599
1790
  */
1600
1791
  getSettingEnum(keypath: string): string;
1792
+ /**
1793
+ * Sets a custom URI resolver.
1794
+ * This function can be called more than once. Subsequent calls will overwrite previous calls.
1795
+ * To remove a previously set resolver, pass the value `null`.
1796
+ * The given function must return an absolute path with a scheme.
1797
+ * @param resolver - Custom resolution function.
1798
+ */
1799
+ setURIResolver(resolver: (URI: string) => string): void;
1800
+ /**
1801
+ * Resolves the given path.
1802
+ * If a custom resolver has been set with `setURIResolver`, it invokes it with the given path.
1803
+ * Else, it resolves it as relative to the `ubq://basePath` setting.
1804
+ * This performs NO validation of whether a file exists at the specified location.
1805
+ * @param relativePath - A relative path string
1806
+ * @returns The resolved absolute uri or an error if an invalid path was given.
1807
+ */
1808
+ getAbsoluteURI(relativePath: string): string;
1601
1809
  }
1602
1810
 
1603
1811
  /**
@@ -1615,8 +1823,44 @@ export declare class EventAPI {
1615
1823
  subscribe(blocks: DesignBlockId[], callback: (events: BlockEvent[]) => void): () => void;
1616
1824
  }
1617
1825
 
1826
+ /**
1827
+ * @public
1828
+ */
1829
+ export declare type ExportOptions = {
1830
+ /**
1831
+ * The PNG compression level to use, when exporting to PNG.
1832
+ *
1833
+ * Valid values are 0 to 9, higher means smaller, but slower.
1834
+ * Quality is not affected.
1835
+ * Ignored for other encodings.
1836
+ * @defaultValue 5.
1837
+ */
1838
+ pngCompressionLevel?: number;
1839
+ /**
1840
+ * The JPEG quality to use when encoding to JPEG.
1841
+ *
1842
+ * Valid values are (0-1], higher means better quality.
1843
+ * Ignored for other encodings.
1844
+ *
1845
+ * @defaultValue 0.9
1846
+ */
1847
+ jpegQuality?: number;
1848
+ /**
1849
+ * An optional target width used in conjunction with target height.
1850
+ * If used, the block will be rendered large enough, that it fills the target
1851
+ * size entirely while maintaining its aspect ratio.
1852
+ */
1853
+ targetWidth?: number;
1854
+ /**
1855
+ * An optional target height used in conjunction with target width.
1856
+ * If used, the block will be rendered large enough, that it fills the target
1857
+ * size entirely while maintaining its aspect ratio.
1858
+ */
1859
+ targetHeight?: number;
1860
+ };
1861
+
1618
1862
  /** @public */
1619
- declare interface ExportOptions {
1863
+ declare interface ExportOptions_2 {
1620
1864
  jpegQuality: number;
1621
1865
  pngCompressionLevel: number;
1622
1866
  useTargetSize: boolean;
@@ -1645,6 +1889,50 @@ declare type Extensions = {
1645
1889
  */
1646
1890
  export declare type FillType = 'Solid' | 'Gradient';
1647
1891
 
1892
+ declare interface FindAssetResult {
1893
+ id: string;
1894
+ type: string;
1895
+ groups: Vector<string>;
1896
+ thumbUri: string;
1897
+ width: number;
1898
+ height: number;
1899
+ meta: UnorderedMap<string, string>;
1900
+ locale: string;
1901
+ label: string;
1902
+ tags: Vector<string>;
1903
+ context: AssetResultContext;
1904
+ credits: AssetResultCredits;
1905
+ license: AssetResultLicense;
1906
+ utm: AssetResultUtm;
1907
+ }
1908
+
1909
+ declare interface FindAssetsQuery {
1910
+ perPage: number;
1911
+ page: number;
1912
+ query: string;
1913
+ tags: string[];
1914
+ groups: string[];
1915
+ excludeGroups: string[];
1916
+ locale: string;
1917
+ }
1918
+
1919
+ declare interface FindAssetsQueryCpp {
1920
+ perPage: number;
1921
+ page: number;
1922
+ query: string;
1923
+ tags: Vector<string>;
1924
+ groups: Vector<string>;
1925
+ excludeGroups: Vector<string>;
1926
+ locale: string;
1927
+ }
1928
+
1929
+ declare interface FindAssetsResult {
1930
+ assets: Vector<FindAssetResult>;
1931
+ currentPage: number;
1932
+ nextPage: number;
1933
+ total: number;
1934
+ }
1935
+
1648
1936
  /** @public */
1649
1937
  declare interface Flip {
1650
1938
  horizontal: boolean;
@@ -1763,12 +2051,6 @@ declare type PageFormatDefinition = Preset & {
1763
2051
  bleedMargin?: number;
1764
2052
  };
1765
2053
 
1766
- /** @public */
1767
- export declare interface PaginatedAssetQueryData extends AssetQueryData {
1768
- /** The current page queried for paginated views. */
1769
- page: number;
1770
- }
1771
-
1772
2054
  /**
1773
2055
  * - Absolute: Position in absolute design units.
1774
2056
  * - Percent: Position in relation to the block's parent's size in percent, where 1.0 means 100%.
@@ -1951,6 +2233,31 @@ export declare class SceneAPI {
1951
2233
  * @returns A Promise that resolves once the template was applied or rejects if there was an error.
1952
2234
  */
1953
2235
  applyTemplateFromURL(url: string): Promise<void>;
2236
+ /**
2237
+ * Sets the zoom level of the active scene.
2238
+ * Only has an effect if the zoom level is not handled by the UI.
2239
+ *
2240
+ * @param zoomLevel - The new zoom level.
2241
+ */
2242
+ setZoomLevel(zoomLevel?: number): void;
2243
+ /**
2244
+ * Query a camera zoom level of the active scene.
2245
+ * @returns The zoom level of the block's camera.
2246
+ */
2247
+ getZoomLevel(): number;
2248
+ /**
2249
+ * Sets the zoom and focus to show a block.
2250
+ * Only has an effect if the zoom level is not handled by the UI.
2251
+ * Without padding, this results in a tight view on the block.
2252
+ *
2253
+ * @param id - The block that should be focussed on.
2254
+ * @param paddingLeft - Optional padding in screen pixels to the left of the block.
2255
+ * @param paddingTop - Optional padding in screen pixels to the top of the block.
2256
+ * @param paddingRight - Optional padding in screen pixels to the right of the block.
2257
+ * @param paddingBottom - Optional padding in screen pixels to the bottom of the block.
2258
+ * @returns A promise that resolves once the zoom was set or rejects with an error otherwise.
2259
+ */
2260
+ zoomToBlock(id: DesignBlockId, paddingLeft?: number, paddingTop?: number, paddingRight?: number, paddingBottom?: number): Promise<void>;
1954
2261
  /**
1955
2262
  * Converts all values of the current scene into the given design unit.
1956
2263
  * @param designUnit - The new design unit of the scene
@@ -2014,6 +2321,13 @@ declare type TypefaceDefinition = Preset & {
2014
2321
  }[];
2015
2322
  };
2016
2323
 
2324
+ declare interface UnorderedMap<K, V> {
2325
+ size: () => number;
2326
+ get: (key: K) => V;
2327
+ set: (key: K, value: V) => void;
2328
+ keys: () => Vector<K>;
2329
+ }
2330
+
2017
2331
  /**
2018
2332
  * @public
2019
2333
  */