polotno-node 2.6.7 → 2.6.8
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-1a4d47fd.js → index-a7c43fcd.js} +53 -53
- package/dist/index.html +1 -1
- package/package.json +5 -5
- package/video.js +18 -4
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-a7c43fcd.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.6.
|
|
3
|
+
"version": "2.6.8",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"gifencoder": "^2.0.1",
|
|
27
27
|
"pixelmatch": "^5.3.0",
|
|
28
28
|
"pngjs": "^7.0.0",
|
|
29
|
-
"polotno": "^2.0.
|
|
29
|
+
"polotno": "^2.0.5",
|
|
30
30
|
"react": "^18.2.0",
|
|
31
31
|
"react-dom": "^18.2.0",
|
|
32
|
-
"vite": "^4.
|
|
32
|
+
"vite": "^4.5.0"
|
|
33
33
|
},
|
|
34
34
|
"author": "Anton Lavrenov",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@sparticuz/chromium": "117.0.0",
|
|
38
|
-
"puppeteer": "^21.
|
|
39
|
-
"puppeteer-core": "^21.
|
|
38
|
+
"puppeteer": "^21.4.0",
|
|
39
|
+
"puppeteer-core": "^21.4.0"
|
|
40
40
|
},
|
|
41
41
|
"bugs": {
|
|
42
42
|
"url": "https://github.com/polotno-project/polotno-node/issues"
|
package/video.js
CHANGED
|
@@ -63,7 +63,7 @@ const videoToDataURL = async (url) => {
|
|
|
63
63
|
function printProgress(progress) {
|
|
64
64
|
process.stdout.clearLine(0);
|
|
65
65
|
process.stdout.cursorTo(0);
|
|
66
|
-
process.stdout.write(progress + '%');
|
|
66
|
+
process.stdout.write('Rendering frame: ' + progress + '%');
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
module.exports.jsonToVideo = async function jsonToGifFile(page, json, attrs) {
|
|
@@ -85,6 +85,9 @@ module.exports.jsonToVideo = async function jsonToGifFile(page, json, attrs) {
|
|
|
85
85
|
async (json, attrs) => {
|
|
86
86
|
store.loadJSON(json);
|
|
87
87
|
await store.waitLoading();
|
|
88
|
+
// TODO: we need to active all pages first
|
|
89
|
+
// disable text fit, as it is already should be processed
|
|
90
|
+
window.config.unstable_setTextOverflow('resize');
|
|
88
91
|
},
|
|
89
92
|
json,
|
|
90
93
|
attrs || {}
|
|
@@ -100,10 +103,19 @@ module.exports.jsonToVideo = async function jsonToGifFile(page, json, attrs) {
|
|
|
100
103
|
// loop through the images and add each to the animation
|
|
101
104
|
const frames = Math.floor((duration / 1000) * fps);
|
|
102
105
|
for (let i = 0; i < frames; i++) {
|
|
103
|
-
|
|
106
|
+
let currentTime = i * timePerFrame;
|
|
107
|
+
if (i === 0) {
|
|
108
|
+
// offset the very first frame to enable animation start
|
|
109
|
+
currentTime = 1;
|
|
110
|
+
}
|
|
111
|
+
if (i === frames - 1) {
|
|
112
|
+
// offset the very last frame to enable animation end
|
|
113
|
+
currentTime = duration - 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
const dataURL = await page.evaluate(
|
|
105
117
|
async (json, attrs, currentTime) => {
|
|
106
|
-
store.setCurrentTime(currentTime
|
|
118
|
+
store.setCurrentTime(currentTime);
|
|
107
119
|
const currentPage = store.pages.find((p) => {
|
|
108
120
|
return (
|
|
109
121
|
store.currentTime >= p.startTime &&
|
|
@@ -121,12 +133,14 @@ module.exports.jsonToVideo = async function jsonToGifFile(page, json, attrs) {
|
|
|
121
133
|
attrs || {},
|
|
122
134
|
currentTime
|
|
123
135
|
);
|
|
124
|
-
const progress = ((i / frames) * 100).toFixed(1);
|
|
136
|
+
const progress = ((i / (frames - 1)) * 100).toFixed(1);
|
|
125
137
|
printProgress(progress);
|
|
126
138
|
fs.mkdirSync('./tmp', { recursive: true });
|
|
127
139
|
fs.writeFileSync(`./tmp/${i}.png`, dataURL.split(',')[1], 'base64');
|
|
128
140
|
}
|
|
129
141
|
|
|
142
|
+
console.log('\nRendering video');
|
|
143
|
+
|
|
130
144
|
await new Promise((resolve, reject) => {
|
|
131
145
|
ffmpeg()
|
|
132
146
|
.input(`./tmp/%d.png`) // Make sure your images are named with numbers, e.g. 1.jpg, 2.jpg, etc.
|