@cesdk/cesdk-js 1.4.0-alpha.2 → 1.4.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.
Files changed (30) hide show
  1. package/BlockAPI.d.ts +214 -53
  2. package/PropertyAPI.d.ts +395 -0
  3. package/SceneAPI.d.ts +1 -1
  4. package/VariableAPI.d.ts +10 -4
  5. package/api.d.ts +3 -0
  6. package/assets/core/cesdk.data +0 -0
  7. package/assets/core/cesdk.wasm +0 -0
  8. package/assets/extensions/ly.img.cesdk.stickers.emoji/images/emoji_happyface.svg +1 -1
  9. package/assets/extensions/ly.img.cesdk.stickers.emoji/images/emoji_lips.svg +1 -1
  10. package/assets/extensions/ly.img.cesdk.stickers.emoji/images/emoji_sunglasses.svg +1 -1
  11. package/assets/extensions/ly.img.cesdk.stickers.emoji/images/emoji_unicorn.svg +1 -1
  12. package/assets/extensions/ly.img.cesdk.stickers.emoji/images/emoji_zany.svg +1 -1
  13. package/assets/extensions/ly.img.cesdk.stickers.hand/images/hand_ok.svg +1 -1
  14. package/assets/i18n/de.json +682 -1409
  15. package/assets/i18n/en.json +758 -1473
  16. package/assets/templates/cesdk_collage_1.scene +1 -1
  17. package/assets/templates/cesdk_instagram_photo_1.scene +1 -1
  18. package/assets/templates/cesdk_instagram_story_1.scene +1 -1
  19. package/assets/templates/cesdk_postcard_1.scene +1 -1
  20. package/assets/templates/cesdk_postcard_2.scene +1 -1
  21. package/assets/templates/cesdk_poster_1.scene +1 -1
  22. package/assets/templates/cesdk_presentation_1.scene +1 -1
  23. package/assets/ui/stylesheets/cesdk-themes.css +1 -1
  24. package/assets/ui/stylesheets/cesdk.css +32 -26
  25. package/cesdk-engine.umd.d.ts +10 -3
  26. package/cesdk-engine.umd.js +1 -1
  27. package/cesdk.umd.js +1 -1
  28. package/package.json +1 -1
  29. package/types.d.ts +163 -8
  30. package/assets/ui/stylesheets/cesdk-engine.css +0 -42
package/BlockAPI.d.ts CHANGED
@@ -1,29 +1,66 @@
1
1
  type Vec2 = { x: number; y: number };
2
- type DesignElementId = number;
3
- type DesignElementType = string;
4
- type MimeType = 'image/png' | 'image/jpeg';
5
- type Size = number; // | 'auto';
2
+ type DesignBlockId = number;
3
+ type DesignBlockType = string;
4
+ type MimeType =
5
+ | 'image/png'
6
+ | 'image/jpeg'
7
+ | 'image/x-tga'
8
+ | 'application/octet-stream';
6
9
  type Size2 = {
7
- width: Size;
8
- height: Size;
10
+ width: number;
11
+ height: number;
9
12
  };
10
13
 
14
+ export enum PositionMode {
15
+ /** Position in absolute design units. */
16
+ Absolute = 'Absolute',
17
+ /** Position in relation to the block's parent's size in percent, where 1.0 means 100%. */
18
+ Percent = 'Percent',
19
+ /** Position is automatically determined. */
20
+ Undefined = 'Auto'
21
+ }
22
+
23
+ export enum SizeMode {
24
+ /** Size in absolute design units. */
25
+ Absolute = 'Absolute',
26
+ /** Size in relation to the block's parent's size in percent, where 1.0 means 100%. */
27
+ Percent = 'Percent',
28
+ /** Size is determined by the block's content. */
29
+ Auto = 'Auto'
30
+ }
31
+
11
32
  export default class BlockAPI {
12
33
  /**
13
34
  * Exports a design block element as a file of the given mime type.
14
35
  * Performs an internal update to resolve the final layout for the blocks.
15
36
  * @param handle The design block element to export.
16
- * @param mimeType The mime type of the output file.
37
+ * @param mimeType The mime type of the output file. Defaults to 'image/png'
17
38
  * @returns A promise that resolves with the exported image or is rejected with an error.
18
39
  */
19
- export(handle: DesignElementId, mimeType: MimeType): Promise<Blob>;
40
+ export(handle: DesignBlockId, mimeType?: MimeType): Promise<Blob>;
41
+
42
+ /**
43
+ * Loads existing blocks from the given string.
44
+ * The blocks are not attached by default and won't be visible until attached to a page or the scene.
45
+ * @param content A string representing the given blocks.
46
+ * @returns A promise that resolves with a list of handles representing the found blocks or an error.
47
+ */
48
+ loadFromString(content: string): Promise<DesignBlockId[]>;
49
+
50
+ /**
51
+ * Saves the given blocks into a string. If given the root of a block hierarchy, e.g. a
52
+ * page with multiple children, the entire hierarchy is saved.
53
+ * @param blocks
54
+ * @returns A promise that resolves to a string representing the blocks or an error.
55
+ */
56
+ saveToString(blocks: DesignBlockId[]): Promise<string>;
20
57
 
21
58
  /**
22
59
  * Create a new block, fails if type is unknown.
23
60
  * @param type The type of the block that shall be created.
24
61
  * @returns The created blocks handle.
25
62
  */
26
- create(type: DesignElementType): DesignElementId;
63
+ create(type: DesignBlockType): DesignBlockId;
27
64
 
28
65
  /**
29
66
 
@@ -31,7 +68,7 @@ export default class BlockAPI {
31
68
  * @param id The block to query.
32
69
  * @returns The blocks type.
33
70
  */
34
- getType(id: DesignElementId): DesignElementType;
71
+ getType(id: DesignBlockId): DesignBlockType;
35
72
 
36
73
  /**
37
74
  * Update the selection state of a block.
@@ -39,53 +76,60 @@ export default class BlockAPI {
39
76
  * @param id The block to query.
40
77
  * @param selected Whether or not the block should be selected.
41
78
  */
42
- setSelected(id: DesignElementId, selected: boolean): void;
79
+ setSelected(id: DesignBlockId, selected: boolean): void;
43
80
 
44
81
  /**
45
82
  * Get the selected state of a block.
46
83
  * @param id The block to query.
47
84
  * @returns True if the block is selected, false otherwise.
48
85
  */
49
- isSelected(id: DesignElementId): boolean;
86
+ isSelected(id: DesignBlockId): boolean;
50
87
 
51
88
  /**
52
89
  * Get all currently selected blocks.
53
90
  * @returns An array of block ids.
54
91
  */
55
- findAllSelected(): DesignElementId[];
92
+ findAllSelected(): DesignBlockId[];
93
+
94
+ /** Checks whether the given block references any variables. Doesn't check the blocks children.
95
+ *
96
+ * @param block The block to inspect.
97
+ * @return true if the block references variables and false otherwise.
98
+ */
99
+ referencesAnyVariables(id: DesignBlockId): boolean;
56
100
 
57
101
  /**
58
102
  * Update a block's name.
59
103
  * @param id The block to update.
60
104
  * @param name The name to set.
61
105
  */
62
- setName(id: DesignElementId, name: string): void;
106
+ setName(id: DesignBlockId, name: string): void;
63
107
 
64
108
  /**
65
109
  * Get a block's name.
66
110
  * @param id The block to update.
67
111
  */
68
- getName(id: DesignElementId): string;
112
+ getName(id: DesignBlockId): string;
69
113
 
70
114
  /**
71
115
  * Finds all blocks with the given name.
72
116
  * @param name The name to search for.
73
117
  * @returns A list of block ids.
74
118
  */
75
- findByName(name: string): DesignElementId[];
119
+ findByName(name: string): DesignBlockId[];
76
120
 
77
121
  /**
78
122
  * Finds all blocks with the given type.
79
123
  * @param type The type to search for.
80
124
  * @returns A list of block ids.
81
125
  */
82
- findByType(type: DesignElementType): DesignElementId[];
126
+ findByType(type: DesignBlockType): DesignBlockId[];
83
127
 
84
128
  /**
85
129
  * Return all blocks currently known to the engine.
86
130
  * @returns A list of block ids.
87
131
  */
88
- findAll(): /* filterSpec?: unknown */ DesignElementId[];
132
+ findAll(): /* filterSpec?: unknown */ DesignBlockId[];
89
133
 
90
134
  // Element
91
135
 
@@ -94,113 +138,202 @@ export default class BlockAPI {
94
138
  * @param id The block to query.
95
139
  * @returns True if visible, false otherwise.
96
140
  */
97
- isVisible(id: DesignElementId): boolean;
141
+ isVisible(id: DesignBlockId): boolean;
98
142
 
99
143
  /**
100
144
  * Update a block's visibility.
101
145
  * @param id The block to update.
102
146
  * @param visible Whether the block shall be visible.
103
147
  */
104
- setVisible(id: DesignElementId, visible: boolean): void;
148
+ setVisible(id: DesignBlockId, visible: boolean): void;
149
+
150
+ /**
151
+ * Query a block's x position.
152
+ * @param id The block to query.
153
+ * @returns The value of the x position.
154
+ */
155
+ getPositionX(id: DesignBlockId): number;
156
+
157
+ /**
158
+ * Query a block's mode for its x position.
159
+ * @param id The block to query.
160
+ * @returns The current mode for the x position: absolute, percent or undefined.
161
+ */
162
+ getPositionXMode(id: DesignBlockId): PositionMode;
163
+
164
+ /**
165
+ * Query a block's y position.
166
+ * @param id The block to query.
167
+ * @returns The value of the y position.
168
+ */
169
+ getPositionY(id: DesignBlockId): number;
105
170
 
106
171
  /**
107
- * Query a block's absolute position in design units.
172
+ * Query a block's mode for its y position.
108
173
  * @param id The block to query.
109
- * @returns
174
+ * @returns The current mode for the y position: absolute, percent or undefined.
110
175
  */
111
- getPosition(id: DesignElementId): Vec2;
176
+ getPositionYMode(id: DesignBlockId): PositionMode;
112
177
 
113
178
  /**
114
- * Update a block's absolute position.
179
+ * Update a block's x position.
115
180
  * @param id The block to update.
116
- * @param { x, y } pos The new position in design units.
181
+ * @param value The value of the x position.
117
182
  */
118
- setPosition(id: DesignElementId, { x, y }: Vec2): void;
183
+ setPositionX(id: DesignBlockId, value: number): void;
184
+
185
+ /**
186
+ * Set a block's mode for its x position.
187
+ * @param id The block to update.
188
+ * @param mode The x position mode: absolute, percent or undefined.
189
+ */
190
+ setPositionXMode(id: DesignBlockId, mode: PositionMode): void;
191
+
192
+ /**
193
+ * Update a block's y position.
194
+ * @param id The block to update.
195
+ * @param value The value of the y position.
196
+ */
197
+ setPositionY(id: DesignBlockId, value: number): void;
198
+
199
+ /**
200
+ * Set a block's mode for its y position.
201
+ * @param id The block to update.
202
+ * @param mode The y position mode: absolute, percent or undefined.
203
+ */
204
+ setPositionYMode(id: DesignBlockId, mode: PositionMode): void;
119
205
 
120
206
  /**
121
207
  * Query a block's rotation in radians.
122
208
  * @param id The block to query.
123
209
  * @returns The block's rotation around its center in radians.
124
210
  */
125
- getRotation(id: DesignElementId): number;
211
+ getRotation(id: DesignBlockId): number;
126
212
 
127
213
  /**
128
214
  * Update a block's rotation.
129
215
  * @param id The block to update.
130
216
  * @param radians The new rotation in radians. Rotation is applied around the block's center.
131
217
  */
132
- setRotation(id: DesignElementId, radians: number): void;
218
+ setRotation(id: DesignBlockId, radians: number): void;
133
219
 
134
220
  /**
135
221
  * Query a block's horizontal flip state.
136
222
  * @param id The block to query.
137
223
  * @returns A boolean indicating for whether the block is flipped in the queried direction
138
224
  */
139
- getFlipHorizontal(id: DesignElementId): boolean;
225
+ getFlipHorizontal(id: DesignBlockId): boolean;
140
226
 
141
227
  /**
142
228
  * Query a block's vertical flip state.
143
229
  * @param id The block to query.
144
230
  * @returns A boolean indicating for whether the block is flipped in the queried direction
145
231
  */
146
- getFlipVertical(id: DesignElementId): boolean;
232
+ getFlipVertical(id: DesignBlockId): boolean;
147
233
 
148
234
  /**
149
235
  * Update a block's horizontal flip.
150
236
  * @param id The block to update.
151
237
  * @param horizontal Whether the block should be flipped along its x-axis.
152
- * @returns
153
238
  */
154
- setFlipHorizontal(id: DesignElementId, flip: boolean): void;
239
+ setFlipHorizontal(id: DesignBlockId, flip: boolean): void;
155
240
 
156
241
  /**
157
242
  * Update a block's vertical flip.
158
243
  * @param id The block to update.
159
244
  * @param vertical Whether the block should be flipped along its y-axis.
160
- * @returns
161
245
  */
162
- setFlipVertical(id: DesignElementId, flip: boolean): void;
246
+ setFlipVertical(id: DesignBlockId, flip: boolean): void;
247
+
248
+ /**
249
+ * Query a block's width.
250
+ * @param id The block to query.
251
+ * @returns The value of the block's width.
252
+ */
253
+ getWidth(id: DesignBlockId): number;
254
+
255
+ /**
256
+ * Query a block's mode for its width.
257
+ * @param id The block to query.
258
+ * @returns The current mode for the width: absolute, percent or auto.
259
+ */
260
+ getWidthMode(id: DesignBlockId): SizeMode;
261
+
262
+ /**
263
+ * Query a block's height.
264
+ * @param id The block to query.
265
+ * @returns The value of the block's height.
266
+ */
267
+ getHeight(id: DesignBlockId): number;
163
268
 
164
269
  /**
165
- * Query a block's absolute size in design units.
270
+ * Query a block's mode for its height.
166
271
  * @param id The block to query.
167
- * @returns A `Size2` object.
272
+ * @returns The current mode for the height: absolute, percent or auto.
273
+ */
274
+ getHeightMode(id: DesignBlockId): SizeMode;
275
+
276
+ /**
277
+ * Update a block's width.
278
+ * @param id The block to update.
279
+ * @param value The new width of the block.
280
+ */
281
+ setWidth(id: DesignBlockId, value: number): void;
282
+
283
+ /**
284
+ * Set a block's mode for its width.
285
+ * @param id The block to update.
286
+ * @param mode The width mode: absolute, percent or auto.
287
+ */
288
+ setWidthMode(id: DesignBlockId, mode: SizeMode): void;
289
+
290
+ /**
291
+ * Update a block's height.
292
+ * @param id The block to update.
293
+ * @param value The new height of the block.
168
294
  */
169
- getSize(id: DesignElementId): Size2;
295
+ setHeight(id: DesignBlockId, value: number): void;
170
296
 
171
297
  /**
172
- * Update a block's absolute size in design units.
298
+ * Set a block's mode for its height.
173
299
  * @param id The block to update.
174
- * @param size A size object defining width and height.
300
+ * @param mode The height mode: absolute, percent or auto.
301
+ */
302
+ setHeightMode(id: DesignBlockId, mode: SizeMode): void;
303
+
304
+ /**
305
+ * Get a block's layouted width. Requires an `engine.render()` beforehand.
306
+ * @param id The block to query.
307
+ * @returns The layouted width.
175
308
  */
176
- setSize(id: DesignElementId, size: Size2): void;
309
+ getFrameWidth(id: DesignBlockId): number;
177
310
 
178
311
  /**
179
- * Get a block's layouted size. Requires an `engine.render()` beforehand.
312
+ * Get a block's layouted height. Requires an `engine.render()` beforehand.
180
313
  * @param id The block to query.
181
- * @returns A `Size2` object holding the size.
314
+ * @returns The layouted height.
182
315
  */
183
- getFrameSize(id: DesignElementId): Size2;
316
+ getFrameHeight(id: DesignBlockId): number;
184
317
 
185
318
  /**
186
319
  * Duplicates a block including its children.
187
320
  * @param id The block to duplicate.
188
321
  * @returns The handle of the duplicate.
189
322
  */
190
- duplicate(id: DesignElementId): DesignElementId;
323
+ duplicate(id: DesignBlockId): DesignBlockId;
191
324
 
192
325
  /**
193
326
  * Destroys a block.
194
327
  * @param id The block to destroy.
195
328
  */
196
- destroy(id: DesignElementId): void;
329
+ destroy(id: DesignBlockId): void;
197
330
 
198
331
  /**
199
332
  * Query a block's parent.
200
333
  * @param id The block to query.
201
334
  * @returns The parent's handle.
202
335
  */
203
- getParent(id: DesignElementId): DesignElementId;
336
+ getParent(id: DesignBlockId): DesignBlockId;
204
337
 
205
338
  /**
206
339
  * Get all children of the given block. Children
@@ -209,7 +342,7 @@ export default class BlockAPI {
209
342
  * @param id The block to query.
210
343
  * @returns A list of block ids.
211
344
  */
212
- getChildren(id: DesignElementId): DesignElementId[];
345
+ getChildren(id: DesignBlockId): DesignBlockId[];
213
346
 
214
347
  /**
215
348
  * Insert a new or existing child at a certain position in the parent's children.
@@ -217,16 +350,44 @@ export default class BlockAPI {
217
350
  * @param child The child to insert. Can be an existing child of `parent`.
218
351
  * @param index The index to insert or move to.
219
352
  */
220
- insertChild(
221
- parent: DesignElementId,
222
- child: DesignElementId,
223
- index: number
224
- ): void;
353
+ insertChild(parent: DesignBlockId, child: DesignBlockId, index: number): void;
225
354
 
226
355
  /**
227
356
  * Appends a new or existing child to a block's children.
228
357
  * @param parent The block whose children should be updated.
229
358
  * @param child The child to insert. Can be an existing child of `parent`.
230
359
  */
231
- appendChild(parent: DesignElementId, child: DesignElementId): void;
360
+ appendChild(parent: DesignBlockId, child: DesignBlockId): void;
361
+
362
+ /**
363
+ * Get the x position of the block's axis-aligned bounding box in the scene's global coordinate space.
364
+ * The scene's global coordinate space has its position at the top left.
365
+ * @param id The block whose bounding box should be calculated.
366
+ * @return UBQResult<float> The x coordinate of the position of the axis-aligned bounding box.
367
+ */
368
+ getGlobalBoundingBoxX(id: DesignBlockId): number;
369
+
370
+ /**
371
+ * Get the y position of the block's axis-aligned bounding box in the scene's global coordinate space.
372
+ * The scene's global coordinate space has its position at the top left.
373
+ * @param id The block whose bounding box should be calculated.
374
+ * @return UBQResult<float> The y coordinate of the position of the axis-aligned bounding box.
375
+ */
376
+ getGlobalBoundingBoxY(id: DesignBlockId): number;
377
+
378
+ /**
379
+ * Get the width of the block's axis-aligned bounding box in the scene's global coordinate space.
380
+ * The scene's global coordinate space has its position at the top left.
381
+ * @param id The block whose bounding box should be calculated.
382
+ * @return UBQResult<float> The width of the axis-aligned bounding box.
383
+ */
384
+ getGlobalBoundingBoxWidth(id: DesignBlockId): number;
385
+
386
+ /**
387
+ * Get the height of the block's axis-aligned bounding box in the scene's global coordinate space.
388
+ * The scene's global coordinate space has its position at the top left.
389
+ * @param id The block whose bounding box should be calculated.
390
+ * @return UBQResult<float> The height of the axis-aligned bounding box.
391
+ */
392
+ getGlobalBoundingBoxHeight(id: DesignBlockId): number;
232
393
  }