polotno-node 2.7.2 → 2.8.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/dist/index.html CHANGED
@@ -8,10 +8,9 @@
8
8
  }
9
9
  </style>
10
10
  <meta name="viewport" content="width=device-width, initial-scale=1" />
11
- <script type="module" crossorigin src="./assets/index-db239b7c.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-0WRjmZSh.js"></script>
12
12
  </head>
13
13
  <body>
14
14
  <div id="root"></div>
15
-
16
15
  </body>
17
16
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno-node",
3
- "version": "2.7.2",
3
+ "version": "2.8.0",
4
4
  "description": "Polotno workflow from NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,25 +19,25 @@
19
19
  "browserslist": "> 0.5%, last 2 versions, not dead",
20
20
  "devDependencies": {
21
21
  "-": "^0.0.1",
22
- "ava": "^5.3.1",
23
- "axios": "^1.5.1",
22
+ "ava": "^6.0.1",
23
+ "axios": "^1.6.3",
24
24
  "canvas": "^2.11.2",
25
25
  "dotenv": "^16.3.1",
26
26
  "fluent-ffmpeg": "^2.1.2",
27
27
  "gifencoder": "^2.0.1",
28
28
  "pixelmatch": "^5.3.0",
29
29
  "pngjs": "^7.0.0",
30
- "polotno": "^2.1.1",
30
+ "polotno": "^2.4.1",
31
31
  "react": "^18.2.0",
32
32
  "react-dom": "^18.2.0",
33
- "vite": "^4.5.0"
33
+ "vite": "^5.0.10"
34
34
  },
35
35
  "author": "Anton Lavrenov",
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@sparticuz/chromium": "118.0.0",
39
- "puppeteer": "^20.9.0",
40
- "puppeteer-core": "^20.9.0",
38
+ "@sparticuz/chromium": "119.0.2",
39
+ "puppeteer": "^21.6.1",
40
+ "puppeteer-core": "^21.6.1",
41
41
  "tmp": "^0.2.1"
42
42
  },
43
43
  "bugs": {
package/video-parallel.js CHANGED
@@ -25,7 +25,6 @@ const downloadVideo = async (url, destination) => {
25
25
  // 2. Convert it into webm format
26
26
 
27
27
  const convertToWebM = (input, output) => {
28
- console.log(input, output);
29
28
  return new Promise((resolve, reject) => {
30
29
  ffmpeg(input)
31
30
  .outputOptions(['-c:v libvpx', '-crf 30', '-b:v 1000k'])
@@ -66,6 +65,14 @@ const videoToDataURL = async (url) => {
66
65
  return dataUrl;
67
66
  };
68
67
 
68
+ const urlCache = {};
69
+ const cachedVideoToDataURL = async (url) => {
70
+ if (!urlCache[url]) {
71
+ urlCache[url] = videoToDataURL(url);
72
+ }
73
+ return urlCache[url];
74
+ };
75
+
69
76
  function printProgress(progress) {
70
77
  process.stdout.clearLine(0);
71
78
  process.stdout.cursorTo(0);
@@ -79,14 +86,22 @@ module.exports.jsonToVideo = async function jsonToVideo(
79
86
  ) {
80
87
  const tempFolder = tmp.dirSync();
81
88
 
89
+ const videoEls = [];
90
+
82
91
  for (const page of json.pages) {
83
92
  for (const el of page.children) {
84
93
  if (el.type === 'video') {
85
- el.src = await videoToDataURL(el.src);
94
+ videoEls.push(el);
86
95
  }
87
96
  }
88
97
  }
89
98
 
99
+ await Promise.all(
100
+ videoEls.map(async (el) => {
101
+ el.src = await cachedVideoToDataURL(el.src);
102
+ })
103
+ );
104
+
90
105
  const duration = json.pages.reduce((acc, page) => {
91
106
  return acc + page.duration;
92
107
  }, 0);