@cesdk/engine 1.22.0 → 1.23.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/engine",
3
- "version": "1.22.0",
3
+ "version": "1.23.0-rc.0",
4
4
  "main": "./index.js",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
package/example.js DELETED
@@ -1,68 +0,0 @@
1
- import CreativeEngine, { MimeType } from './index.js';
2
-
3
- window.onload = async () => {
4
- /**
5
- * @type {import('./index.js').Configuration}
6
- */
7
- const config = {
8
- baseURL: '/assets/',
9
- defaultFont: '//ly.img.cesdk.fonts/roboto_regular'
10
- };
11
- const creativeEngine = await initCreativeEngine(config);
12
- window.creativeEngine = creativeEngine;
13
- };
14
-
15
- async function initCreativeEngine(config) {
16
- const width = 1024;
17
- const height = 720;
18
- const canvas = document.createElement('canvas');
19
- canvas.setAttribute('width', String(width * window.devicePixelRatio));
20
- canvas.setAttribute('height', String(height * window.devicePixelRatio));
21
- canvas.style.width = `${width}px`;
22
- canvas.style.height = `${height}px`;
23
- document.getElementById('root').appendChild(canvas);
24
-
25
- const loadButton = document.createElement('input');
26
- loadButton.type = 'file';
27
- loadButton.innerText = 'Load';
28
- loadButton.onchange = async (event) => {
29
- var _a;
30
- const file =
31
- (_a = loadButton.files) === null || _a === void 0 ? void 0 : _a.item(0);
32
- const buffer = await (file === null || file === void 0
33
- ? void 0
34
- : file.arrayBuffer());
35
- const decoder = new TextDecoder('utf-8');
36
- const scene = decoder.decode(buffer);
37
- await creativeEngine.scene.loadFromString(scene);
38
- };
39
- document.getElementById('root').appendChild(loadButton);
40
-
41
- const exportButton = document.createElement('button');
42
- exportButton.innerText = 'Export';
43
- exportButton.onclick = async () => {
44
- const scene = creativeEngine.scene.get();
45
- if (scene == null) {
46
- // eslint-disable-next-line no-console
47
- console.log('Scene is null');
48
- return;
49
- }
50
- const result = await creativeEngine.block.export(scene, MimeType.Png);
51
- const link = document.createElement('a');
52
- link.style.display = 'none';
53
- document.body.appendChild(link);
54
- const blob = new Blob([result], { type: 'image/png' });
55
- const objectURL = URL.createObjectURL(blob);
56
- link.href = objectURL;
57
- link.href = URL.createObjectURL(blob);
58
- link.download = 'export.png';
59
- link.click();
60
- };
61
- document.getElementById('root').appendChild(exportButton);
62
-
63
- /**
64
- * @type {import('./index.js').default}
65
- */
66
- const creativeEngine = await CreativeEngine.init(config, canvas);
67
- return creativeEngine;
68
- }
package/index.html DELETED
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <title>CE.SDK Headless</title>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <meta http-equiv="X-UA-Compatible" content="ie=edge" />
8
- <script src="./example.js" type="module"></script>
9
- </head>
10
-
11
- <body>
12
- <div id="root"></div>
13
- </body>
14
- </html>