polotno-node 2.7.3 → 2.8.1
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/assets/index-1AcU7sVo.js +243 -0
- package/dist/index.html +1 -1
- package/package.json +9 -9
- package/video-parallel.js +17 -2
- package/dist/assets/index-5QUPlfKu.js +0 -229
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
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-
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-1AcU7sVo.js"></script>
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
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": "^
|
|
23
|
-
"axios": "^1.6.
|
|
22
|
+
"ava": "^6.1.0",
|
|
23
|
+
"axios": "^1.6.5",
|
|
24
24
|
"canvas": "^2.11.2",
|
|
25
|
-
"dotenv": "^16.3.
|
|
25
|
+
"dotenv": "^16.3.2",
|
|
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.
|
|
30
|
+
"polotno": "^2.4.7",
|
|
31
31
|
"react": "^18.2.0",
|
|
32
32
|
"react-dom": "^18.2.0",
|
|
33
|
-
"vite": "^5.0.
|
|
33
|
+
"vite": "^5.0.12"
|
|
34
34
|
},
|
|
35
35
|
"author": "Anton Lavrenov",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@sparticuz/chromium": "119.0.
|
|
39
|
-
"puppeteer": "^21.
|
|
40
|
-
"puppeteer-core": "^21.
|
|
38
|
+
"@sparticuz/chromium": "119.0.2",
|
|
39
|
+
"puppeteer": "^21.7.0",
|
|
40
|
+
"puppeteer-core": "^21.7.0",
|
|
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
|
-
|
|
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);
|