@cesdk/engine 1.7.0-alpha.5 → 1.8.0-alpha.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
@@ -77,6 +77,8 @@ export declare class AssetAPI {
77
77
  url: string | undefined;
78
78
  } | undefined;
79
79
  canManageAssets(sourceId: string): boolean;
80
+
81
+
80
82
  /**
81
83
  * Apply an asset result to the active scene.
82
84
  * The default behavior will instantiate a block and configure it according to the asset's properties.
@@ -85,6 +87,12 @@ export declare class AssetAPI {
85
87
  * @param assetResult - A single assetResult of a `findAssets` query.
86
88
  */
87
89
  apply(sourceId: string, assetResult: AssetResult): Promise<void>;
90
+ /**
91
+ * The default implementation for applying an asset to the scene.
92
+ * This implementation is used when no `applyAsset` function is provided to `addSource`.
93
+ * @param assetResult - A single assetResult of a `findAssets` query.
94
+ */
95
+ defaultApplyAsset(assetResult: AssetResult): Promise<void>;
88
96
  }
89
97
 
90
98
  /**
@@ -221,7 +229,7 @@ export declare interface AssetSource {
221
229
  /** Find all asset for the given type and the provided query data. */
222
230
  findAssets(queryData: AssetQueryData): Promise<AssetsQueryResult>;
223
231
  /** Return every available group */
224
- getGroups: () => Promise<string[]>;
232
+ getGroups?: () => Promise<string[]>;
225
233
  /** Credits for the source/api */
226
234
  credits?: {
227
235
  name: string;
@@ -243,7 +251,7 @@ export declare interface AssetSource {
243
251
  /**
244
252
  * @returns the asset or undefined if no asset with the given id could be found
245
253
  */
246
- getAsset(id: string): Promise<AssetResult | undefined>;
254
+ getAsset?(id: string): Promise<AssetResult | undefined>;
247
255
  /**
248
256
  * Can the source add, update and remove assets dynamically? If `false`
249
257
  * methods like `addAsset` `updateAsset` and `removeAsset` will throw an
@@ -261,20 +269,20 @@ export declare interface AssetSource {
261
269
  *
262
270
  * @returns the id of the added asset
263
271
  */
264
- addAsset(asset: AssetDefinition): Promise<string>;
272
+ addAsset?(asset: AssetDefinition): Promise<string>;
265
273
  /**
266
274
  * Updates the asset of this source. Throws an error if `canManageAssets`
267
275
  * is `false` or no asset with the given id could not be found.
268
276
  *
269
277
  * @returns the id of the added asset
270
278
  */
271
- updateAsset(assetId: string, asset: AssetDefinition): Promise<void>;
279
+ updateAsset?(assetId: string, asset: AssetDefinition): Promise<void>;
272
280
  /**
273
281
  * Removes the given asset from this source.
274
282
  *
275
283
  * @returns true if asset was found and removed, and false otherwise
276
284
  */
277
- removeAsset(assetId: string): Promise<boolean>;
285
+ removeAsset?(assetId: string): Promise<boolean>;
278
286
  }
279
287
 
280
288
  /**
@@ -289,6 +297,8 @@ declare interface AssetSource_2 {
289
297
  * You can override this with custom behavior.
290
298
  */
291
299
  applyAsset?: (asset: AssetResult_2) => Promise<void>;
300
+ /** Return every available group */
301
+ getGroups?: () => Promise<string[]>;
292
302
  /**
293
303
  * Indicates if the asset shall be downloaded to handle the raw data instead
294
304
  * of an URL reference. Do this if you do not want to depend on
@@ -349,9 +359,6 @@ declare interface AssetsQueryResult_2 {
349
359
  */
350
360
  export declare type BlendMode = 'PassThrough' | 'Normal' | 'Darken' | 'Multiply' | 'ColorBurn' | 'Lighten' | 'Screen' | 'ColorDodge' | 'Overlay' | 'SoftLight' | 'HardLight' | 'Difference' | 'Exclusion' | 'Hue' | 'Saturation' | 'Color' | 'Luminosity';
351
361
 
352
- /** @public */
353
- declare type Block = number;
354
-
355
362
  /**
356
363
  * @public
357
364
  */
@@ -388,6 +395,12 @@ export declare class BlockAPI {
388
395
  * @returns The created blocks handle.
389
396
  */
390
397
  create(type: DesignBlockType): DesignBlockId;
398
+ /**
399
+ * Create a new fill, fails if type is unknown.
400
+ * @param type - The type of the fill object that shall be created.
401
+ * @returns The created fill's handle.
402
+ */
403
+ createFill(type: string): DesignBlockId;
391
404
 
392
405
  /**
393
406
  * Get the type of the given block, fails if the block is invalid.
@@ -592,12 +605,6 @@ export declare class BlockAPI {
592
605
  * @returns true, if the block has a content fill mode.
593
606
  */
594
607
  hasContentFillMode(id: DesignBlockId): boolean;
595
- /**
596
- * Query if the given block shows placeholder content.
597
- * @param id - The block to query.
598
- * @returns true, if the block shows placeholder content.
599
- */
600
- hasPlaceholderContent(id: DesignBlockId): boolean;
601
608
  /**
602
609
  * Query a block's width.
603
610
  * @param id - The block to query.
@@ -894,6 +901,12 @@ export declare class BlockAPI {
894
901
  * @param rotation - The rotation in radians.
895
902
  */
896
903
  setCropRotation(id: DesignBlockId, rotation: number): void;
904
+ /**
905
+ * Set the crop scale ratio of the given design block.
906
+ * @param id - The block whose crop should be set.
907
+ * @param scaleRatio - The crop scale ratio.
908
+ */
909
+ setCropScaleRatio(id: DesignBlockId, scaleRatio: number): void;
897
910
  /**
898
911
  * Set the crop translation in x direction of the given design block.
899
912
  * @param id - The block whose crop should be set.
@@ -930,6 +943,12 @@ export declare class BlockAPI {
930
943
  * @returns The crop rotation.
931
944
  */
932
945
  getCropRotation(id: DesignBlockId): number;
946
+ /**
947
+ * Get the crop scale ratio of the given design block.
948
+ * @param id - The block whose crop scale ratio should be queried.
949
+ * @returns The crop scale ratio.
950
+ */
951
+ getCropScaleRatio(id: DesignBlockId): number;
933
952
  /**
934
953
  * Get the crop translation on the x axis of the given design block.
935
954
  * @param id - The block whose translation should be queried.
@@ -942,6 +961,12 @@ export declare class BlockAPI {
942
961
  * @returns The translation on the y axis.
943
962
  */
944
963
  getCropTranslationY(id: DesignBlockId): number;
964
+ /**
965
+ * Adjust the crop position/scale to at least fill the crop frame.
966
+ * @param id - The block whose crop scale ratio should be queried.
967
+ * @param minScaleRatio - The minimal crop scale ratio to go down to.
968
+ */
969
+ adjustCropToFillFrame(id: DesignBlockId, minScaleRatio: number): number;
945
970
  /**
946
971
  * Query if the given block has an opacity.
947
972
  * @param id - The block to query.
@@ -1013,6 +1038,99 @@ export declare class BlockAPI {
1013
1038
  * @returns True, if fill is enabled.
1014
1039
  */
1015
1040
  isFillColorEnabled(id: DesignBlockId): boolean;
1041
+ /**
1042
+ * Create a new effect block, fails if type is unknown or not a valid effect block type.
1043
+ * @param type - The type id of the effect.
1044
+ * @returns The created effects handle.
1045
+ */
1046
+ createEffect(type: string): DesignBlockId;
1047
+ /**
1048
+ * Queries whether the block supports effects.
1049
+ * @param id - The block to query.
1050
+ * @returns True, if the block can render effects, false otherwise.
1051
+ */
1052
+ hasEffects(id: DesignBlockId): boolean;
1053
+ /**
1054
+ * Get a list of all effects attached to this block
1055
+ * @param id - The block to query.
1056
+ * @returns A list of effects or an error, if the block doesn't support effects.
1057
+ */
1058
+ getEffects(id: DesignBlockId): DesignBlockId[];
1059
+ /**
1060
+ * Inserts an effect at the given index into the list of effects of the given block.
1061
+ * The same effect can appear multiple times in the list and won't be removed if appended again.
1062
+ * @param id - The block to update.
1063
+ * @param effectId - The effect to insert
1064
+ * @param index - The index at which the effect shall be inserted.
1065
+ */
1066
+ insertEffect(id: DesignBlockId, effectId: DesignBlockId, index: number): void;
1067
+ /**
1068
+ * Inserts an effect at the end of the list of effects
1069
+ * The same effect can appear multiple times in the list and won't be removed if appended again.
1070
+ * @param id - The block to append the effect to.
1071
+ * @param effectId - The effect to append.
1072
+ */
1073
+ appendEffect(id: DesignBlockId, effectId: DesignBlockId): void;
1074
+ /**
1075
+ * Removes the effect at the given index.
1076
+ * @param id - The block to remove the effect from.
1077
+ * @param index - The index where the effect is stored.
1078
+ */
1079
+ removeEffect(id: DesignBlockId, index: number): void;
1080
+ /**
1081
+ * Checks whether an 'effect' block may be enabled and disabled.
1082
+ * @param effectId - The 'effect' block to query.
1083
+ * @returns True, if the block supports enabling and disabling, false otherwise.
1084
+ */
1085
+ hasEffectEnabled(effectId: DesignBlockId): boolean;
1086
+ /**
1087
+ * Sets the enabled state of an 'effect' block.
1088
+ * @param effectId - The 'effect' block to update.
1089
+ * @param enabled - The new state.
1090
+ */
1091
+ setEffectEnabled(effectId: DesignBlockId, enabled: boolean): void;
1092
+ /**
1093
+ * Queries whether an 'effect' block is enabled and therefore applies its effect.
1094
+ * @param effectId - The 'effect' block to query.
1095
+ * @returns True, if the effect is enabled. False otherwise.
1096
+ */
1097
+ isEffectEnabled(effectId: DesignBlockId): boolean;
1098
+ /**
1099
+ * Create a new blur, fails if type is unknown or not a valid blur type.
1100
+ * @param type - The type id of the block.
1101
+ * @returns The handle of the newly created blur.
1102
+ */
1103
+ createBlur(type: string): DesignBlockId;
1104
+ /**
1105
+ * Checks whether the block supports blur.
1106
+ * @param id - The block to query.
1107
+ * @returns True, if the block supports blur.
1108
+ */
1109
+ hasBlur(id: DesignBlockId): boolean;
1110
+ /**
1111
+ * Connects `block`'s blur to the given `blur` block.
1112
+ * @param id - The block to update.
1113
+ * @param blurId - A 'blur' block.
1114
+ */
1115
+ setBlur(id: DesignBlockId, blurId: DesignBlockId): void;
1116
+ /**
1117
+ * Get the 'blur' block of the given design block.
1118
+ * @param id - The block to query.
1119
+ * @returns The 'blur' block.
1120
+ */
1121
+ getBlur(id: DesignBlockId): DesignBlockId;
1122
+ /**
1123
+ * Enable or disable the blur of the given design block.
1124
+ * @param id - The block to update.
1125
+ * @param enabled - The new enabled value.
1126
+ */
1127
+ setBlurEnabled(id: DesignBlockId, enabled: boolean): void;
1128
+ /**
1129
+ * Query if blur is enabled for the given block.
1130
+ * @param id - The block to query.
1131
+ * @returns True, if the blur is enabled. False otherwise.
1132
+ */
1133
+ isBlurEnabled(id: DesignBlockId): boolean;
1016
1134
  /**
1017
1135
  * Query if the given block has background color properties.
1018
1136
  * @param id - The block to query.
@@ -1218,51 +1336,51 @@ export declare class BlockAPI {
1218
1336
  /**
1219
1337
  * Set the drop shadow's X offset of the given design block.
1220
1338
  * @param id - The block whose drop shadow's X offset should be set.
1221
- * @param xOffset - The X offset to be set.
1339
+ * @param offsetX - The X offset to be set.
1222
1340
  */
1223
- setDropShadowXOffset(id: DesignBlockId, xOffset: number): void;
1341
+ setDropShadowOffsetX(id: DesignBlockId, offsetX: number): void;
1224
1342
  /**
1225
1343
  * Get the drop shadow's X offset of the given design block.
1226
1344
  * @param id - The block whose drop shadow's X offset should be queried.
1227
1345
  * @returns The offset.
1228
1346
  */
1229
- getDropShadowXOffset(id: DesignBlockId): number;
1347
+ getDropShadowOffsetX(id: DesignBlockId): number;
1230
1348
  /**
1231
1349
  * Set the drop shadow's Y offset of the given design block.
1232
1350
  * @param id - The block whose drop shadow's Y offset should be set.
1233
- * @param yOffset - The X offset to be set.
1351
+ * @param offsetY - The X offset to be set.
1234
1352
  */
1235
- setDropShadowYOffset(id: DesignBlockId, yOffset: number): void;
1353
+ setDropShadowOffsetY(id: DesignBlockId, offsetY: number): void;
1236
1354
  /**
1237
1355
  * Get the drop shadow's Y offset of the given design block.
1238
1356
  * @param id - The block whose drop shadow's Y offset should be queried.
1239
1357
  * @returns The offset.
1240
1358
  */
1241
- getDropShadowYOffset(id: DesignBlockId): number;
1359
+ getDropShadowOffsetY(id: DesignBlockId): number;
1242
1360
  /**
1243
1361
  * Set the drop shadow's blur radius on the X axis of the given design block.
1244
1362
  * @param id - The block whose drop shadow's blur radius should be set.
1245
- * @param xBlurRadius - The blur radius to be set.
1363
+ * @param blurRadiusX - The blur radius to be set.
1246
1364
  */
1247
- setDropShadowXBlurRadius(id: DesignBlockId, xBlurRadius: number): void;
1365
+ setDropShadowBlurRadiusX(id: DesignBlockId, blurRadiusX: number): void;
1248
1366
  /**
1249
1367
  * Get the drop shadow's blur radius on the X axis of the given design block.
1250
1368
  * @param id - The block whose drop shadow's blur radius should be queried.
1251
1369
  * @returns The blur radius.
1252
1370
  */
1253
- getDropShadowXBlurRadius(id: DesignBlockId): number;
1371
+ getDropShadowBlurRadiusX(id: DesignBlockId): number;
1254
1372
  /**
1255
1373
  * Set the drop shadow's blur radius on the Y axis of the given design block.
1256
1374
  * @param id - The block whose drop shadow's blur radius should be set.
1257
- * @param yBlurRadius - The blur radius to be set.
1375
+ * @param blurRadiusY - The blur radius to be set.
1258
1376
  */
1259
- setDropShadowYBlurRadius(id: DesignBlockId, yBlurRadius: number): void;
1377
+ setDropShadowBlurRadiusY(id: DesignBlockId, blurRadiusY: number): void;
1260
1378
  /**
1261
1379
  * Get the drop shadow's blur radius on the Y axis of the given design block.
1262
1380
  * @param id - The block whose drop shadow's blur radius should be queried.
1263
1381
  * @returns The blur radius.
1264
1382
  */
1265
- getDropShadowYBlurRadius(id: DesignBlockId): number;
1383
+ getDropShadowBlurRadiusY(id: DesignBlockId): number;
1266
1384
  /**
1267
1385
  * Set the drop shadow's clipping of the given design block. (Only applies to shapes.)
1268
1386
  * @param id - The block whose drop shadow's clip should be set.
@@ -1300,6 +1418,13 @@ export declare class BlockAPI {
1300
1418
  * @returns The block that currently defines the given block's fill.
1301
1419
  */
1302
1420
  getFill(id: DesignBlockId): DesignBlockId;
1421
+ /**
1422
+ * Sets the block containing the fill properties of the given block.
1423
+ * Note that the previous fill block is not destroyed automatically.
1424
+ * @param id - The block whose fill should be changed.
1425
+ * @param fill - The new fill.
1426
+ */
1427
+ setFill(id: DesignBlockId, fill: DesignBlockId): void;
1303
1428
  /**
1304
1429
  * Set the fill type of the given design block.
1305
1430
  * @param id - The block whose fill type should be set.
@@ -1412,10 +1537,28 @@ export declare class BlockAPI {
1412
1537
  * @returns the gradient's radius, an error otherwise.
1413
1538
  */
1414
1539
  getFillGradientRadius(id: DesignBlockId): number;
1540
+ /**
1541
+ * Enable or disable the placeholder function for a block.
1542
+ * @param id - The block whose placeholder function should be enabled or disabled.
1543
+ * @param enabled - Whether the function should be enabled or disabled.
1544
+ */
1545
+ setPlaceholderEnabled(id: DesignBlockId, enabled: boolean): void;
1546
+ /**
1547
+ * Query whether the placeholder function for a block is enabled.
1548
+ * @param id - The block whose placeholder function state should be queried.
1549
+ * @returns the enabled state of the placeholder function.
1550
+ */
1551
+ isPlaceholderEnabled(id: DesignBlockId): boolean;
1552
+ /**
1553
+ * Query if the given block shows placeholder content.
1554
+ * @param id - The block to query.
1555
+ * @returns true, if the block shows placeholder content.
1556
+ */
1557
+ showsPlaceholderContent(id: DesignBlockId): boolean;
1415
1558
  /**
1416
1559
  * Set a metadata value of a block identified by a key.
1417
1560
  * If the key does not exist, yet, it will be added.
1418
- * @param block - The block whose metadata will be accessed.
1561
+ * @param id - The block whose metadata will be accessed.
1419
1562
  * @param key - The key used to identify the desired piece of metadata.
1420
1563
  * @param value - The value to set.
1421
1564
  */
@@ -1423,14 +1566,14 @@ export declare class BlockAPI {
1423
1566
  /**
1424
1567
  * Get a metadata value of a block identified by a key.
1425
1568
  * If the key does not exist, yet, this method will fail.
1426
- * @param block - The block whose metadata will be accessed.
1569
+ * @param id - The block whose metadata will be accessed.
1427
1570
  * @param key - The key used to identify the desired piece of metadata.
1428
1571
  * @returns the value associated with the key.
1429
1572
  */
1430
1573
  getMetadata(id: DesignBlockId, key: string): string;
1431
1574
  /**
1432
1575
  * Check if the block has metadata associated with the key.
1433
- * @param block - The block whose metadata will be accessed.
1576
+ * @param id - The block whose metadata will be accessed.
1434
1577
  * @param key - The key used to identify the desired piece of metadata.
1435
1578
  * @returns whether the key exists.
1436
1579
  */
@@ -1438,23 +1581,36 @@ export declare class BlockAPI {
1438
1581
  /**
1439
1582
  * Remove metadata associated with the key from the given block.
1440
1583
  * If the key does not exist, this method will fail.
1441
- * @param block - The block whose metadata will be accessed.
1584
+ * @param id - The block whose metadata will be accessed.
1442
1585
  * @param key - The key used to identify the desired piece of metadata.
1443
1586
  */
1444
1587
  removeMetadata(id: DesignBlockId, key: string): void;
1588
+ /**
1589
+ * Enable or disable a scope for a given block.
1590
+ * @param id - The block whose scope should be enabled or disabled.
1591
+ * @param key - The scope to enable or disable.
1592
+ * @param enabled - Whether the scope should be enabled or disabled.
1593
+ */
1594
+ setScopeEnabled(id: DesignBlockId, key: string, enabled: boolean): void;
1595
+ /**
1596
+ * Query whether a scope is enabled for a given block.
1597
+ * @param id - The block whose scope state should be queried.
1598
+ * @param key - The scope to query.
1599
+ * @returns the enabled state of the scope for the given block.
1600
+ */
1601
+ isScopeEnabled(id: DesignBlockId, key: string): boolean;
1602
+ /**
1603
+ * Check if a scope is allowed for a given block.
1604
+ * @param id - The block to check.
1605
+ * @param key - The scope to check.
1606
+ * @returns whether the scope is allowed for the given block.
1607
+ */
1608
+ isAllowedByScope(id: DesignBlockId, key: string): boolean;
1445
1609
  }
1446
1610
 
1447
- /**
1448
- * @public
1449
- */
1450
- export declare type BlockEvent = {
1451
- block: DesignBlockId;
1452
- type: 'Created' | 'Updated' | 'Destroyed';
1453
- };
1454
-
1455
1611
  /** @public */
1456
- declare interface BlockEvent_2 {
1457
- block: Block;
1612
+ export declare interface BlockEvent {
1613
+ block: DesignBlockId;
1458
1614
  type: 'Created' | 'Updated' | 'Destroyed';
1459
1615
  }
1460
1616
 
@@ -1600,6 +1756,19 @@ declare class CreativeEngine {
1600
1756
  }
1601
1757
  export default CreativeEngine;
1602
1758
 
1759
+ /**
1760
+ * Dispatched on the engine canvas when the text input has been blurred.
1761
+ * Call `preventDefault()` to disallow this and refocus the engine text input.
1762
+ * @public
1763
+ */
1764
+ export declare interface CursorEvent extends CustomEvent<string> {
1765
+ readonly type: 'cesdk-cursor';
1766
+ /** Contains the cursor style */
1767
+ readonly detail: string;
1768
+ /** If default is prevented, the Creative Engine won't apply the cursor style to itself. */
1769
+ preventDefault(): void;
1770
+ }
1771
+
1603
1772
  /**
1604
1773
  * A numerical identifier for a design block
1605
1774
  * @public
@@ -1792,6 +1961,13 @@ export declare class EditorAPI {
1792
1961
  * @param resolver - Custom resolution function.
1793
1962
  */
1794
1963
  setURIResolver(resolver: (URI: string) => string): void;
1964
+ /**
1965
+ * This is the default implementation for the URI resolver.
1966
+ * It resolves the given path relative to the `ubq://basePath` setting.
1967
+ * @param relativePath - The relative path that should be resolved.
1968
+ * @returns The resolved absolute URI.
1969
+ */
1970
+ defaultURIResolver(relativePath: string): string;
1795
1971
  /**
1796
1972
  * Resolves the given path.
1797
1973
  * If a custom resolver has been set with `setURIResolver`, it invokes it with the given path.
@@ -1801,6 +1977,18 @@ export declare class EditorAPI {
1801
1977
  * @returns The resolved absolute uri or an error if an invalid path was given.
1802
1978
  */
1803
1979
  getAbsoluteURI(relativePath: string): string;
1980
+ /**
1981
+ * Set a scope to be globally allowed, denied, or deferred to the block-level.
1982
+ * @param key - The scope to set.
1983
+ * @param value - `Allow` will always allow the scope, `Deny` will always deny the scope, and `Defer` will defer to the block-level.
1984
+ */
1985
+ setGlobalScope(key: string, value: 'Allow' | 'Deny' | 'Defer'): void;
1986
+ /**
1987
+ * Query the state of a global scope.
1988
+ * @param key - The scope to query.
1989
+ * @returns `Allow` if the scope is allowed, `Deny` if it is disallowed, and `Defer` if it is deferred to the block-level.
1990
+ */
1991
+ getGlobalScope(key: string): 'Allow' | 'Deny' | 'Defer';
1804
1992
  }
1805
1993
 
1806
1994
  /**
@@ -1852,6 +2040,12 @@ export declare type ExportOptions = {
1852
2040
  * size entirely while maintaining its aspect ratio.
1853
2041
  */
1854
2042
  targetHeight?: number;
2043
+ /**
2044
+ * Export the PDF document with a higher compatibility to different PDF viewers.
2045
+ * Bitmap images and some effects like gradients will be rasterized with the DPI
2046
+ * setting instead of embedding them directly.
2047
+ */
2048
+ exportPdfWithHighCompatibility?: boolean;
1855
2049
  };
1856
2050
 
1857
2051
  /** @public */
@@ -1861,6 +2055,7 @@ declare interface ExportOptions_2 {
1861
2055
  useTargetSize: boolean;
1862
2056
  targetWidth: number;
1863
2057
  targetHeight: number;
2058
+ exportPdfWithHighCompatibility: boolean;
1864
2059
  }
1865
2060
 
1866
2061
  /** @public */
@@ -2011,6 +2206,7 @@ declare type PageFormatDefinition = Preset & {
2011
2206
  unit: DesignUnit;
2012
2207
  dpi?: number;
2013
2208
  bleedMargin?: number;
2209
+ fixedOrientation?: boolean;
2014
2210
  };
2015
2211
 
2016
2212
  /**