polotno-node 2.6.1 → 2.6.3

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.
Files changed (3) hide show
  1. package/index.js +2 -2
  2. package/package.json +1 -1
  3. package/video.js +13 -2
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  let puppeteer = require('puppeteer-core');
2
2
  const chrome = require('@sparticuz/chromium');
3
-
4
3
  const os = require('os');
5
4
  const isMacOs = os.platform() === 'darwin';
6
5
  const isWindows = os.platform() === 'win32' || os.platform() === 'win64';
@@ -72,7 +71,8 @@ module.exports.createInstance = async ({
72
71
  // make default protocol timeout bigger
73
72
  // because some clients had issues with it
74
73
  protocolTimeout: 10 * 60 * 1000,
75
- executablePath: isMacOs ? undefined : await chrome.executablePath(),
74
+ executablePath:
75
+ isMacOs || isWindows ? undefined : await chrome.executablePath(),
76
76
  ignoreHTTPSErrors: true,
77
77
  });
78
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polotno-node",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Polotno workflow from NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/video.js CHANGED
@@ -95,15 +95,26 @@ module.exports.jsonToVideo = async function jsonToGifFile(page, json, attrs) {
95
95
  });
96
96
 
97
97
  const fps = 15;
98
+ const timePerFrame = 1000 / fps;
98
99
 
99
100
  // loop through the images and add each to the animation
100
101
  const frames = Math.floor((duration / 1000) * fps);
101
102
  for (let i = 0; i < frames; i++) {
102
- const currentTime = i * 100;
103
+ const currentTime = i * timePerFrame;
103
104
  const dataURL = await page.evaluate(
104
105
  async (json, attrs, currentTime) => {
105
106
  store.setCurrentTime(currentTime + 1);
106
- const url = await store.toDataURL({ ...attrs, pixelRatio: 0.5 });
107
+ const currentPage = store.pages.find((p) => {
108
+ return (
109
+ store.currentTime >= p.startTime &&
110
+ store.currentTime < p.startTime + p.duration
111
+ );
112
+ });
113
+ const url = await store.toDataURL({
114
+ pixelRatio: 0.5,
115
+ ...attrs,
116
+ pageId: currentPage?.id,
117
+ });
107
118
  return url;
108
119
  },
109
120
  json,