polotno-node 2.1.0 → 2.2.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/README.md +69 -6
- package/dist/assets/index-ae105516.js +370 -0
- package/dist/index.html +17 -0
- package/index.js +3 -2
- package/instance.js +17 -2
- package/package.json +10 -9
- package/dist/client.7c21efff.js +0 -3934
- package/dist/client.html +0 -1
package/dist/index.html
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Canvas editor</title>
|
|
4
|
+
<style>
|
|
5
|
+
body {
|
|
6
|
+
padding: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-ae105516.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
<body class="bp3-dark">
|
|
14
|
+
<div id="root"></div>
|
|
15
|
+
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
package/index.js
CHANGED
|
@@ -3,9 +3,10 @@ const chrome = require('@sparticuz/chromium');
|
|
|
3
3
|
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const isMacOs = os.platform() === 'darwin';
|
|
6
|
+
const isWindows = os.platform() === 'win32' || os.platform() === 'win64';
|
|
6
7
|
|
|
7
|
-
// load full puppeteer
|
|
8
|
-
if (isMacOs) {
|
|
8
|
+
// load full puppeteer on non linux platforms
|
|
9
|
+
if (isMacOs || isWindows) {
|
|
9
10
|
puppeteer = require('puppeteer');
|
|
10
11
|
}
|
|
11
12
|
|
package/instance.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const DEFAULT_CLIENT = `file:${path.join(__dirname, 'dist', '
|
|
2
|
+
const DEFAULT_CLIENT = `file:${path.join(__dirname, 'dist', 'index.html')}`;
|
|
3
3
|
|
|
4
4
|
module.exports.createPage = async (browser, url) => {
|
|
5
5
|
const page = await browser.newPage();
|
|
@@ -7,11 +7,16 @@ module.exports.createPage = async (browser, url) => {
|
|
|
7
7
|
await page.setUserAgent('Chrome Headless');
|
|
8
8
|
|
|
9
9
|
page.on('console', (msg) => {
|
|
10
|
-
msg.args().forEach((message) => {
|
|
10
|
+
msg.args().forEach(async (message) => {
|
|
11
11
|
// skip style information
|
|
12
12
|
if (message.toString().indexOf('margin') >= 0) {
|
|
13
13
|
return;
|
|
14
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
|
+
// );
|
|
15
20
|
const text = message
|
|
16
21
|
.toString()
|
|
17
22
|
.replace('JSHandle:', '')
|
|
@@ -19,6 +24,9 @@ module.exports.createPage = async (browser, url) => {
|
|
|
19
24
|
console.log(text);
|
|
20
25
|
});
|
|
21
26
|
});
|
|
27
|
+
page.on('pageerror', (msg) => {
|
|
28
|
+
console.error(msg);
|
|
29
|
+
});
|
|
22
30
|
await page.goto(url);
|
|
23
31
|
return page;
|
|
24
32
|
};
|
|
@@ -89,6 +97,13 @@ module.exports.createInstance = async ({
|
|
|
89
97
|
}
|
|
90
98
|
}, args[1].assetLoadTimeout);
|
|
91
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
|
+
}
|
|
92
107
|
await page.evaluate(() => {
|
|
93
108
|
if (window.config?.onLoadError) {
|
|
94
109
|
window.config.onLoadError((error) => {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "ava",
|
|
8
|
-
"build": "rm -rf ./dist &&
|
|
8
|
+
"build": "rm -rf ./dist && npx vite build ./client/ --base=./ --outDir ../dist",
|
|
9
9
|
"dev": "parcel ./client.html"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
@@ -14,25 +14,26 @@
|
|
|
14
14
|
"instance.js",
|
|
15
15
|
"README.md"
|
|
16
16
|
],
|
|
17
|
+
"browserslist": "> 0.5%, last 2 versions, not dead",
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"ava": "^5.3.
|
|
19
|
+
"ava": "^5.3.1",
|
|
19
20
|
"axios": "^1.4.0",
|
|
20
21
|
"canvas": "^2.11.2",
|
|
21
22
|
"fluent-ffmpeg": "^2.1.2",
|
|
22
23
|
"gifencoder": "^2.0.1",
|
|
23
|
-
"parcel-bundler": "^1.12.4",
|
|
24
24
|
"pixelmatch": "^5.3.0",
|
|
25
25
|
"pngjs": "^7.0.0",
|
|
26
|
-
"polotno": "^1.9.
|
|
26
|
+
"polotno": "^1.9.8",
|
|
27
27
|
"react": "^18.2.0",
|
|
28
|
-
"react-dom": "^18.2.0"
|
|
28
|
+
"react-dom": "^18.2.0",
|
|
29
|
+
"vite": "^4.3.9"
|
|
29
30
|
},
|
|
30
31
|
"author": "Anton Lavrenov",
|
|
31
32
|
"license": "MIT",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@sparticuz/chromium": "
|
|
34
|
-
"puppeteer": "^20.
|
|
35
|
-
"puppeteer-core": "^20.
|
|
34
|
+
"@sparticuz/chromium": "114.0.0",
|
|
35
|
+
"puppeteer": "^20.7.2",
|
|
36
|
+
"puppeteer-core": "^20.7.2"
|
|
36
37
|
},
|
|
37
38
|
"bugs": {
|
|
38
39
|
"url": "https://github.com/polotno-project/polotno-node/issues"
|