polotno-node 2.0.7 → 2.2.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/README.md +91 -6
- package/dist/{client.51dfa0bd.js → client.3517c032.js} +486 -792
- package/dist/client.html +1 -1
- package/index.js +12 -4
- package/instance.js +18 -2
- package/package.json +10 -5
package/dist/client.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<html><head><title>Canvas editor</title><style>body{padding:0;margin:0}</style><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="bp3-dark"> <div id="root"></div> <script src="client.
|
|
1
|
+
<html><head><title>Canvas editor</title><style>body{padding:0;margin:0}</style><meta name="viewport" content="width=device-width, initial-scale=1"></head><body class="bp3-dark"> <div id="root"></div> <script src="client.3517c032.js"></script> </body></html>
|
package/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
let puppeteer = require('puppeteer-core');
|
|
2
|
+
const chrome = require('@sparticuz/chromium');
|
|
3
|
+
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const isMacOs = os.platform() === 'darwin';
|
|
6
|
+
|
|
7
|
+
// load full puppeteer only on macos
|
|
8
|
+
if (isMacOs) {
|
|
9
|
+
puppeteer = require('puppeteer');
|
|
10
|
+
}
|
|
3
11
|
|
|
4
12
|
const { createInstance } = require('./instance');
|
|
5
13
|
|
|
@@ -23,8 +31,8 @@ module.exports.createInstance = async ({
|
|
|
23
31
|
...browserArgs,
|
|
24
32
|
],
|
|
25
33
|
defaultViewport: chrome.defaultViewport,
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
headless: 'new',
|
|
35
|
+
executablePath: isMacOs ? undefined : await chrome.executablePath(),
|
|
28
36
|
ignoreHTTPSErrors: true,
|
|
29
37
|
});
|
|
30
38
|
|
package/instance.js
CHANGED
|
@@ -3,13 +3,20 @@ const DEFAULT_CLIENT = `file:${path.join(__dirname, 'dist', 'client.html')}`;
|
|
|
3
3
|
|
|
4
4
|
module.exports.createPage = async (browser, url) => {
|
|
5
5
|
const page = await browser.newPage();
|
|
6
|
+
// overwrite user agent, so headless check still work with the last puppeteer version
|
|
7
|
+
await page.setUserAgent('Chrome Headless');
|
|
6
8
|
|
|
7
9
|
page.on('console', (msg) => {
|
|
8
|
-
msg.args().forEach((message) => {
|
|
10
|
+
msg.args().forEach(async (message) => {
|
|
9
11
|
// skip style information
|
|
10
12
|
if (message.toString().indexOf('margin') >= 0) {
|
|
11
13
|
return;
|
|
12
14
|
}
|
|
15
|
+
// const val = await arg.jsonValue();
|
|
16
|
+
// const { type, subtype, description } = arg._remoteObject;
|
|
17
|
+
// console.log(
|
|
18
|
+
// `type: ${type}, subtype: ${subtype}, description:\n ${description}`
|
|
19
|
+
// );
|
|
13
20
|
const text = message
|
|
14
21
|
.toString()
|
|
15
22
|
.replace('JSHandle:', '')
|
|
@@ -17,7 +24,9 @@ module.exports.createPage = async (browser, url) => {
|
|
|
17
24
|
console.log(text);
|
|
18
25
|
});
|
|
19
26
|
});
|
|
20
|
-
|
|
27
|
+
page.on('pageerror', (msg) => {
|
|
28
|
+
console.error(msg);
|
|
29
|
+
});
|
|
21
30
|
await page.goto(url);
|
|
22
31
|
return page;
|
|
23
32
|
};
|
|
@@ -88,6 +97,13 @@ module.exports.createInstance = async ({
|
|
|
88
97
|
}
|
|
89
98
|
}, args[1].assetLoadTimeout);
|
|
90
99
|
}
|
|
100
|
+
if (args[1]?.htmlTextRenderEnabled) {
|
|
101
|
+
await page.evaluate(() => {
|
|
102
|
+
if (window.config && window.config.unstable_useHtmlTextRender) {
|
|
103
|
+
window.config.unstable_useHtmlTextRender(true);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
91
107
|
await page.evaluate(() => {
|
|
92
108
|
if (window.config?.onLoadError) {
|
|
93
109
|
window.config.onLoadError((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,19 +15,24 @@
|
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"ava": "^5.
|
|
18
|
+
"ava": "^5.3.1",
|
|
19
|
+
"axios": "^1.4.0",
|
|
20
|
+
"canvas": "^2.11.2",
|
|
21
|
+
"fluent-ffmpeg": "^2.1.2",
|
|
22
|
+
"gifencoder": "^2.0.1",
|
|
19
23
|
"parcel-bundler": "^1.12.4",
|
|
20
24
|
"pixelmatch": "^5.3.0",
|
|
21
25
|
"pngjs": "^7.0.0",
|
|
22
|
-
"polotno": "^1.8
|
|
26
|
+
"polotno": "^1.9.8",
|
|
23
27
|
"react": "^18.2.0",
|
|
24
28
|
"react-dom": "^18.2.0"
|
|
25
29
|
},
|
|
26
30
|
"author": "Anton Lavrenov",
|
|
27
31
|
"license": "MIT",
|
|
28
32
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"puppeteer": "^
|
|
33
|
+
"@sparticuz/chromium": "114.0.0",
|
|
34
|
+
"puppeteer": "^20.7.2",
|
|
35
|
+
"puppeteer-core": "^20.7.2"
|
|
31
36
|
},
|
|
32
37
|
"bugs": {
|
|
33
38
|
"url": "https://github.com/polotno-project/polotno-node/issues"
|