@cesdk/cesdk-js 1.13.1 → 1.14.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
@@ -85,6 +85,11 @@ export declare class AssetAPI {
85
85
  * @returns The asset groups.
86
86
  */
87
87
  getGroups(id: string): Promise<string[]>;
88
+ /**
89
+ * Queries the list of supported mime types of the specified asset source.
90
+ * An empty result means that all mime types are supported.
91
+ * @param sourceId - The ID of the asset source.
92
+ */
88
93
  getSupportedMimeTypes(sourceId: string): string[];
89
94
  /**
90
95
  * Queries the asset source's credits info.
@@ -595,6 +600,12 @@ export declare class BlockAPI {
595
600
  * @returns A method to unsubscribe.
596
601
  */
597
602
  onSelectionChanged(callback: () => void): () => void;
603
+ /**
604
+ * Subscribe to block click events.
605
+ * @param callback - This function is called at the end of the engine update if a block has been clicked.
606
+ * @returns A method to unsubscribe.
607
+ */
608
+ onClicked(callback: (id: DesignBlockId) => void): () => void;
598
609
  /**
599
610
  * Confirms that a given set of blocks can be grouped together.
600
611
  * @param ids - A non-empty array of block ids.
@@ -662,6 +673,32 @@ export declare class BlockAPI {
662
673
  * @returns A list of block ids.
663
674
  */
664
675
  findAllPlaceholders(): DesignBlockId[];
676
+ /**
677
+ * Create a new shape, fails if type is unknown.
678
+ * @param type - The type of the shape object that shall be created.
679
+ * @returns The created shape's handle.
680
+ */
681
+ createShape(type: string): DesignBlockId;
682
+ /**
683
+ * Query if the given block has a shape property.
684
+ * @param id - The block to query.
685
+ * @returns true, if the block has a shape property, an error otherwise.
686
+ */
687
+ hasShape(id: DesignBlockId): boolean;
688
+ /**
689
+ * Returns the block containing the shape properties of the given block.
690
+ * @param id - The block whose shape block should be returned.
691
+ * @returns The block that currently defines the given block's shape.
692
+ */
693
+ getShape(id: DesignBlockId): DesignBlockId;
694
+ /**
695
+ * Sets the block containing the shape properties of the given block.
696
+ * Note that the previous shape block is not destroyed automatically.
697
+ * The new shape is disconnected from its previously attached block.
698
+ * @param id - The block whose shape should be changed.
699
+ * @param fill - The new shape.
700
+ */
701
+ setShape(id: DesignBlockId, shape: DesignBlockId): void;
665
702
  /**
666
703
  * Query a block's visibility.
667
704
  * @param id - The block to query.
@@ -1241,6 +1278,8 @@ export declare class BlockAPI {
1241
1278
  setCropRotation(id: DesignBlockId, rotation: number): void;
1242
1279
  /**
1243
1280
  * Set the crop scale ratio of the given design block.
1281
+ * This will uniformly scale the content up or down. The center of the
1282
+ * scale operation is the center of the crop frame.
1244
1283
  * @param id - The block whose crop should be set.
1245
1284
  * @param scaleRatio - The crop scale ratio.
1246
1285
  */
@@ -2054,6 +2093,24 @@ export declare class BlockAPI {
2054
2093
  * @returns the enabled state of the placeholder function.
2055
2094
  */
2056
2095
  isPlaceholderEnabled(id: DesignBlockId): boolean;
2096
+ /**
2097
+ * Checks whether the block supports placeholder behavior.
2098
+ * @param block - The block to query.
2099
+ * @returns True, if the block supports placeholder behavior.
2100
+ */
2101
+ hasPlaceholderBehavior(id: DesignBlockId): boolean;
2102
+ /**
2103
+ * Enable or disable the placeholder behavior for a block.
2104
+ * @param id - The block whose placeholder behavior should be enabled or disabled.
2105
+ * @param enabled - Whether the placeholder behavior should be enabled or disabled.
2106
+ */
2107
+ setPlaceholderBehaviorEnabled(id: DesignBlockId, enabled: boolean): void;
2108
+ /**
2109
+ * Query whether the placeholder behavior for a block is enabled.
2110
+ * @param id - The block whose placeholder behavior state should be queried.
2111
+ * @returns the enabled state of the placeholder behavior.
2112
+ */
2113
+ isPlaceholderBehaviorEnabled(id: DesignBlockId): boolean;
2057
2114
  /**
2058
2115
  * Query if the given block shows placeholder content.
2059
2116
  * @param id - The block to query.
@@ -2332,11 +2389,36 @@ export declare class BlockAPI {
2332
2389
  * @returns The video or audio file duration
2333
2390
  */
2334
2391
  getAVResourceTotalDuration(id: DesignBlockId): number;
2392
+ /**
2393
+ * Get the video width in pixels of the video resource that is attached to the given block.
2394
+ * @param block - The video fill.
2395
+ * @returns The video width in pixels or an error.
2396
+ */
2397
+ getVideoWidth(id: DesignBlockId): number;
2398
+ /**
2399
+ * Get the video height in pixels of the video resource that is attached to the given block.
2400
+ * @param block - The video fill.
2401
+ * @returns The video height in pixels or an error.
2402
+ */
2403
+ getVideoHeight(id: DesignBlockId): number;
2404
+ /**
2405
+ * Generate a sequence of thumbnails for the given video fill or page.
2406
+ * Note: there can only be one thumbnail generation request in progress for a given block.
2407
+ * @param id - The video fill or page.
2408
+ * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
2409
+ * @param timeBegin - The time in seconds at which the thumbnail sequence should start.
2410
+ * @param timeEnd - The time in seconds at which the thumbnail sequence should end.
2411
+ * @param numberOfFrames - The number of frames to generate.
2412
+ * @param onFrame - Gets passed the frame index and RGBA image data.
2413
+ * @returns A method that will cancel any thumbnail generation request in progress for this block.
2414
+ */
2415
+ generateVideoThumbnailSequence(id: DesignBlockId, thumbnailHeight: number, timeBegin: number, timeEnd: number, numberOfFrames: number, onFrame: (frameIndex: number, result: ImageData | Error) => void): () => void;
2335
2416
  /**
2336
2417
  * Generate a thumbnail for the given video fill.
2337
2418
  * @param id - The video fill.
2338
2419
  * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
2339
2420
  * @returns A thumbnail encoded as JPEG.
2421
+ * @deprecated Use `generateVideoThumbnailSequence` instead.
2340
2422
  */
2341
2423
  getVideoFillThumbnail(id: DesignBlockId, thumbnailHeight: number): Promise<Blob>;
2342
2424
  /**
@@ -2346,6 +2428,7 @@ export declare class BlockAPI {
2346
2428
  * @param numberOfRows - The number of rows to generate.
2347
2429
  * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the video aspect ratio.
2348
2430
  * @returns A thumbnail atlas of the video as JPEG.
2431
+ * @deprecated Use `generateVideoThumbnailSequence` instead.
2349
2432
  */
2350
2433
  getVideoFillThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
2351
2434
  /**
@@ -2355,6 +2438,7 @@ export declare class BlockAPI {
2355
2438
  * @param numberOfRows - The number of rows to generate.
2356
2439
  * @param thumbnailHeight - The height of a thumbnail. The width will be calculated from the page aspect ratio.
2357
2440
  * @returns A thumbnail atlas of the composition as JPEG.
2441
+ * @deprecated Use `generateVideoThumbnailSequence` instead.
2358
2442
  */
2359
2443
  getPageThumbnailAtlas(id: DesignBlockId, numberOfColumns: number, numberOfRows: number, thumbnailHeight: number): Promise<Blob>;
2360
2444
  }
@@ -2461,6 +2545,7 @@ declare namespace ConfigTypes {
2461
2545
  Scale,
2462
2546
  I18n,
2463
2547
  A11y,
2548
+ UploadCallbackContext,
2464
2549
  OnUploadCallback,
2465
2550
  OnUploadOptions,
2466
2551
  Callbacks,
@@ -2504,6 +2589,7 @@ export declare type CreateConfiguration = Partial<_RequiredCreateConfiguratioan>
2504
2589
  declare class CreativeEditorSDK {
2505
2590
  #private;
2506
2591
  engine: CreativeEngine;
2592
+ ui: UserInterfaceAPI;
2507
2593
  /**
2508
2594
  * Convenience function that registers a set of asset sources containing our
2509
2595
  * example assets. These are
@@ -2642,7 +2728,7 @@ declare class CreativeEditorSDK {
2642
2728
  setTranslations(definition: {
2643
2729
  [locale: string]: object;
2644
2730
  }): void;
2645
- unstable_switchPage(pageId: number): void;
2731
+ unstable_switchPage(pageId: number): Promise<void>;
2646
2732
  unstable_getPages(): Promise<number[]>;
2647
2733
  unstable_getActivePage(): Promise<number>;
2648
2734
  unstable_onActivePageChanged(callback: (id: number) => void): () => void;
@@ -2841,7 +2927,7 @@ export declare enum DesignBlockType {
2841
2927
  }
2842
2928
 
2843
2929
  /**
2844
- * The scene layout determines how the layout stack should layout its pages.
2930
+ * The unit type in which the page values (size, distances, etc.) are defined.
2845
2931
  * @public
2846
2932
  */
2847
2933
  export declare type DesignUnit = 'Pixel' | 'Millimeter' | 'Inch';
@@ -3698,7 +3784,7 @@ declare type OffscreenCanvas_2 = {
3698
3784
  export { OffscreenCanvas_2 as OffscreenCanvas }
3699
3785
 
3700
3786
  /** @public */
3701
- declare type OnUploadCallback = (file: File, onProgress: (progress: number) => void) => Promise<AssetDefinition>;
3787
+ declare type OnUploadCallback = (file: File, onProgress: (progress: number) => void, context?: UploadCallbackContext) => Promise<AssetDefinition>;
3702
3788
 
3703
3789
  /** @public */
3704
3790
  declare type OnUploadOptions = {
@@ -4224,6 +4310,12 @@ declare interface UIOptionsPerDesignUnit {
4224
4310
  */
4225
4311
  declare type UnsubscribeFn = () => void;
4226
4312
 
4313
+ /** @public */
4314
+ declare interface UploadCallbackContext {
4315
+ sourceId: string;
4316
+ group?: string;
4317
+ }
4318
+
4227
4319
  /** @public */
4228
4320
  export declare interface UserInterface {
4229
4321
  baseURL?: string;
@@ -4241,6 +4333,59 @@ export declare interface UserInterface {
4241
4333
  };
4242
4334
  }
4243
4335
 
4336
+ /**
4337
+ * A public interface for controlling the UI of the Creative Editor SDK
4338
+ *
4339
+ * @public
4340
+ */
4341
+ declare class UserInterfaceAPI {
4342
+ #private;
4343
+ /**
4344
+ * Opens a panel with the given id if and only if it exists, is not open and
4345
+ * currently registered (known to the UI). Otherwise the method does nothing
4346
+ * and is a noop.
4347
+ *
4348
+ * Available panel ids beside custom panel ids:
4349
+ * - `//ly.img.panel/inspector`
4350
+ * opening the inspector panel for the current selected block
4351
+ * - `//ly.img.panel/assetLibrary.replace`
4352
+ * opening the library with asset to replace the currently selected block.
4353
+ * Beware that the library might show nothing depending on how it configured.
4354
+ *
4355
+ * @param panelId - The id of the panel to open.
4356
+ */
4357
+ openPanel(panelId: string): void;
4358
+ /**
4359
+ * Closes a panel with the given id if and only if it exists and is open.
4360
+ * Otherwise the method does nothing and is a noop.
4361
+ *
4362
+ * Available panel ids beside custom panel ids:
4363
+ * - `//ly.img.panel/inspector`
4364
+ * closing the inspector panel for the current selected block
4365
+ * - `//ly.img.panel/assetLibrary`
4366
+ * closing the currently open library
4367
+ * - `//ly.img.panel/assetLibrary.replace`
4368
+ * closing the library with asset to replace the currently selected block.
4369
+ *
4370
+ * @param panelId - The id of the panel to close.
4371
+ */
4372
+ closePanel(panelId: string): void;
4373
+ /**
4374
+ * Returns `true` if and only if a panel with the given id is open.
4375
+ *
4376
+ * Available panel ids beside custom panel ids:
4377
+ * - `//ly.img.panel/inspector`
4378
+ * inspector panel for the current selected block
4379
+ * - `//ly.img.panel/assetLibrary`
4380
+ * the asset library
4381
+ * - `//ly.img.panel/assetLibrary.replace`
4382
+ * closing the library with asset to replace the currently selected block.
4383
+ *
4384
+ * @param panelId - The id of a panel that might be open
4385
+ */
4386
+ isPanelOpen(panelId: string): boolean;
4387
+ }
4388
+
4244
4389
  /** @public */
4245
4390
  declare interface UserInterfaceAssetLibrary extends UserInterfaceElement {
4246
4391
  position?: PanelPosition;
@@ -4273,6 +4418,7 @@ declare namespace UserInterfaceElements {
4273
4418
  UserInterfaceInspectorBlockImage,
4274
4419
  UserInterfaceInspectorBlockVideoFill,
4275
4420
  UserInterfaceInspectorBlockRectShape,
4421
+ UserInterfaceInspectorBlockDesign,
4276
4422
  UserInterfaceInspectorBlockShape,
4277
4423
  UserInterfaceInspector,
4278
4424
  UserInterfaceSettings,
@@ -4343,6 +4489,15 @@ declare interface UserInterfaceInspector extends UserInterfaceElement {
4343
4489
  declare interface UserInterfaceInspectorBlock {
4344
4490
  }
4345
4491
 
4492
+ /** @public */
4493
+ declare interface UserInterfaceInspectorBlockDesign extends UserInterfaceInspectorBlock {
4494
+ crop?: UserInterfaceElement | boolean;
4495
+ filters?: UserInterfaceElement | boolean;
4496
+ adjustments?: UserInterfaceElement | boolean;
4497
+ effects?: UserInterfaceElement | boolean;
4498
+ blur?: UserInterfaceElement | boolean;
4499
+ }
4500
+
4346
4501
  /** @public */
4347
4502
  declare interface UserInterfaceInspectorBlockImage extends UserInterfaceInspectorBlock {
4348
4503
  crop?: UserInterfaceElement | boolean;
@@ -4391,6 +4546,7 @@ declare interface UserInterfaceInspectorBlocks {
4391
4546
  '//ly.img.ubq/shapes/ellipse'?: UserInterfaceInspectorBlockShape;
4392
4547
  '//ly.img.ubq/text'?: UserInterfaceInspectorBlockText;
4393
4548
  '//ly.img.ubq/page'?: UserInterfaceInspectorBlockPage;
4549
+ '//ly.img.ubq/design'?: UserInterfaceInspectorBlockDesign;
4394
4550
  }
4395
4551
 
4396
4552
  /** @public */
@@ -4542,7 +4698,10 @@ declare enum ViewStyle {
4542
4698
  */
4543
4699
  export declare type XYWH = [x: number, y: number, w: number, h: number];
4544
4700
 
4545
- /** @public */
4701
+ /**
4702
+ * The axis(es) for which to auto-fit.
4703
+ * @public
4704
+ */
4546
4705
  export declare type ZoomAutoFitAxis = 'Horizontal' | 'Vertical' | 'Both';
4547
4706
 
4548
4707
  export { }
package/index.html CHANGED
@@ -14,115 +14,116 @@
14
14
  .ubq-public {
15
15
  /* Override CSS variables for a custom theme */
16
16
  }</style><script defer="defer" src="cesdk.umd.js"></script><link href="assets/ui/stylesheets/cesdk.css" rel="stylesheet"><link href="assets/ui/stylesheets/cesdk-themes.css" rel="stylesheet"></head><body><div id="root"></div><script>window.onload = function () {
17
- var href = window.location.href.split('?');
18
- var config = {
19
- locale: 'en',
20
- baseURL: "assets/",
21
- role: 'Creator', // 'Creator', 'Adopter', 'Viewer'
22
- callbacks: {
23
- onSave: handleSave,
24
- onLoad: handleLoad,
25
- onExport: handleExport,
26
- onUnsupportedBrowser: () => {
27
- console.error('Unsupported Browser Detected');
28
- },
29
- log: (msg, level) => {
30
- console.log(msg)
31
- },
32
- },
33
- ui: {
34
- elements: {
17
+ var href = window.location.href.split('?');
18
+ var config = {
19
+ locale: 'en',
20
+ baseURL: 'assets/',
21
+ role: 'Creator', // 'Creator', 'Adopter', 'Viewer'
22
+ callbacks: {
23
+ onSave: handleSave,
24
+ onLoad: handleLoad,
25
+ onExport: handleExport,
26
+ onUnsupportedBrowser: () => {
27
+ console.error('Unsupported Browser Detected');
28
+ }
29
+ },
30
+ ui: {
31
+ elements: {
35
32
  view: 'default',
36
- panels: {
37
- settings: true
38
- },
39
- navigation: {
40
- action: {
41
- close: true,
42
- back: true,
43
- save: true,
44
- load: true,
45
- export: true,
46
- }
47
- }
33
+ panels: {
34
+ settings: true
48
35
  },
49
- },
50
- defaultFont: '//ly.img.cesdk.fonts/roboto_regular'
51
- };
52
-
53
-
54
- CreativeEditorSDK.create(
55
- document.getElementById('root'),
56
- config
57
- ).then(async (instance) => {
58
- await Promise.all([
59
- instance.addDefaultAssetSources(),
60
- instance.addDemoAssetSources()
61
- ]);
62
- await instance.createEmptyScene();
63
- });
64
- }
65
-
66
- var handleExport = function (blobs) {
67
- const blob = blobs[0];
68
- const element = document.createElement('a');
69
- element.setAttribute('href', window.URL.createObjectURL(blob));
70
- element.setAttribute('download', `cesdk-${new Date().toISOString()}.png`);
71
-
72
- element.style.display = 'none';
73
- document.body.appendChild(element);
74
-
75
- element.click();
76
-
77
- document.body.removeChild(element);
78
- }
79
-
80
- var handleSave = function (scene) {
81
- const element = document.createElement('a');
82
- const base64Data = btoa(unescape(encodeURIComponent(scene)));
83
- element.setAttribute(
84
- 'href',
85
- `data:application/octet-stream;base64,${base64Data}`
86
- );
87
- element.setAttribute('download', `cesdk-${new Date().toISOString()}.scene`);
88
-
89
- element.style.display = 'none';
90
- document.body.appendChild(element);
91
-
92
- element.click();
93
-
94
- document.body.removeChild(element);
95
- };
96
-
97
- var handleLoad = (function () {
98
- const element = document.createElement('input');
99
- element.setAttribute('type', 'file');
100
- element.setAttribute('accept', '.scene');
101
-
102
- element.style.display = 'none';
103
- document.body.appendChild(element);
104
-
105
- return () => {
106
- return new Promise((resolve, reject) => {
107
- element.onchange = (e) => {
108
- const file = e.target.files[0];
109
- if (file === undefined) {
110
- reject(new Error('No files selected'));
111
- } else {
112
- const reader = new FileReader();
113
- reader.readAsText(file, 'UTF-8');
114
-
115
- reader.onload = (readerEvent) => {
116
- const scene = readerEvent.target.result;
117
- resolve(scene);
118
- };
36
+ navigation: {
37
+ action: {
38
+ close: true,
39
+ back: true,
40
+ save: true,
41
+ load: true,
42
+ export: true
119
43
  }
44
+ }
45
+ }
46
+ },
47
+ defaultFont: '//ly.img.cesdk.fonts/roboto_regular'
48
+ };
120
49
 
121
- element.onchange = null;
122
- element.value = '';
123
- };
124
-
125
- element.click();
126
- });
50
+ CreativeEditorSDK.create(document.getElementById('root'), config).then(
51
+ async (instance) => {
52
+ await Promise.all([
53
+ instance.addDefaultAssetSources(),
54
+ instance.addDemoAssetSources()
55
+ ]);
56
+ await instance.createDesignScene();
127
57
  }
128
- })();</script></body></html>
58
+ );
59
+ };
60
+
61
+ var handleExport = function (blobs) {
62
+ const blob = blobs[0];
63
+ const element = document.createElement('a');
64
+ element.setAttribute('href', window.URL.createObjectURL(blob));
65
+ element.setAttribute(
66
+ 'download',
67
+ `cesdk-${new Date().toISOString()}.png`
68
+ );
69
+
70
+ element.style.display = 'none';
71
+ document.body.appendChild(element);
72
+
73
+ element.click();
74
+
75
+ document.body.removeChild(element);
76
+ };
77
+
78
+ var handleSave = function (scene) {
79
+ const element = document.createElement('a');
80
+ const base64Data = btoa(unescape(encodeURIComponent(scene)));
81
+ element.setAttribute(
82
+ 'href',
83
+ `data:application/octet-stream;base64,${base64Data}`
84
+ );
85
+ element.setAttribute(
86
+ 'download',
87
+ `cesdk-${new Date().toISOString()}.scene`
88
+ );
89
+
90
+ element.style.display = 'none';
91
+ document.body.appendChild(element);
92
+
93
+ element.click();
94
+
95
+ document.body.removeChild(element);
96
+ };
97
+
98
+ var handleLoad = (function () {
99
+ const element = document.createElement('input');
100
+ element.setAttribute('type', 'file');
101
+ element.setAttribute('accept', '.scene');
102
+
103
+ element.style.display = 'none';
104
+ document.body.appendChild(element);
105
+
106
+ return () => {
107
+ return new Promise((resolve, reject) => {
108
+ element.onchange = (e) => {
109
+ const file = e.target.files[0];
110
+ if (file === undefined) {
111
+ reject(new Error('No files selected'));
112
+ } else {
113
+ const reader = new FileReader();
114
+ reader.readAsText(file, 'UTF-8');
115
+
116
+ reader.onload = (readerEvent) => {
117
+ const scene = readerEvent.target.result;
118
+ resolve(scene);
119
+ };
120
+ }
121
+
122
+ element.onchange = null;
123
+ element.value = '';
124
+ };
125
+
126
+ element.click();
127
+ });
128
+ };
129
+ })();</script></body></html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/cesdk-js",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "main": "./cesdk.umd.js",
5
5
  "types": "./index.d.ts",
6
6
  "homepage": "https://www.img.ly",