polotno-node 2.9.12 → 2.9.14
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,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-CYctL5I1.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.9.
|
|
3
|
+
"version": "2.9.14",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"gifencoder": "^2.0.1",
|
|
27
27
|
"pixelmatch": "^5.3.0",
|
|
28
28
|
"pngjs": "^7.0.0",
|
|
29
|
-
"polotno": "^2.5.
|
|
29
|
+
"polotno": "^2.5.3",
|
|
30
30
|
"react": "^18.3.1",
|
|
31
31
|
"react-dom": "^18.3.1",
|
|
32
32
|
"vite": "^5.2.11"
|
package/video-parallel.js
CHANGED
|
@@ -50,12 +50,14 @@ const fileToDataUrl = (filename) => {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const videoToDataURL = async (url, tempFolder) => {
|
|
53
|
+
console.log('Downloading video: ' + url.slice(0, 50) + '...');
|
|
53
54
|
const filename = Math.random().toString(36).substring(7);
|
|
54
55
|
const destination = path.join(tempFolder.name, filename + '.mp4');
|
|
55
56
|
await downloadVideo(url, destination);
|
|
56
57
|
const webmFile = destination.replace('.mp4', '.webm');
|
|
57
58
|
await convertToWebM(destination, webmFile);
|
|
58
59
|
const dataURL = await fileToDataUrl(webmFile);
|
|
60
|
+
console.log('Downloading video finished: ' + url.slice(0, 50) + '...');
|
|
59
61
|
return {
|
|
60
62
|
dataURL,
|
|
61
63
|
file: webmFile,
|
|
@@ -70,10 +72,6 @@ const cachedVideoToDataURL = async (url, tempFolder) => {
|
|
|
70
72
|
return urlCache[url];
|
|
71
73
|
};
|
|
72
74
|
|
|
73
|
-
function printProgress(progress) {
|
|
74
|
-
console.log('Rendering frame: ' + progress + '%');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
75
|
module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
78
76
|
const tempFolder = tmp.dirSync();
|
|
79
77
|
|
|
@@ -169,6 +167,7 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
|
169
167
|
}
|
|
170
168
|
});
|
|
171
169
|
}
|
|
170
|
+
const startTime = Date.now();
|
|
172
171
|
const dataURL = await page.evaluate(
|
|
173
172
|
async (json, attrs, currentTime) => {
|
|
174
173
|
store.setCurrentTime(currentTime);
|
|
@@ -180,6 +179,7 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
|
180
179
|
});
|
|
181
180
|
const url = await store.toDataURL({
|
|
182
181
|
...attrs,
|
|
182
|
+
_skipTimeout: true,
|
|
183
183
|
pageId: currentPage?.id,
|
|
184
184
|
});
|
|
185
185
|
return url;
|
|
@@ -195,8 +195,9 @@ module.exports.jsonToVideo = async function jsonToVideo(inst, json, attrs) {
|
|
|
195
195
|
);
|
|
196
196
|
finishedFramesNumber += 1;
|
|
197
197
|
if (attrs.onProgress) {
|
|
198
|
+
const frameTime = Date.now() - startTime;
|
|
198
199
|
const progress = finishedFramesNumber / framesNumber;
|
|
199
|
-
attrs.onProgress(progress);
|
|
200
|
+
attrs.onProgress(progress, frameTime);
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
await page.close();
|