canvasxpress-cli 63.1.1 → 63.3.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/cmds/help.js +7 -8
- package/cmds/io.js +34 -35
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/canvasXpress.css +1282 -1346
- package/src/canvasXpress.js +4 -4
package/cmds/help.js
CHANGED
|
@@ -22,7 +22,7 @@ const menus = {
|
|
|
22
22
|
--graph, -g ........ [optional] graph name
|
|
23
23
|
--number, -n ....... [optional] number for the graph
|
|
24
24
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
25
|
-
{default}
|
|
25
|
+
{default} 2500
|
|
26
26
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
27
27
|
|
|
28
28
|
Examples:
|
|
@@ -46,7 +46,7 @@ const menus = {
|
|
|
46
46
|
--data, -d ......... [optional - required] json string with the data for CanvasXpress
|
|
47
47
|
--config, -c ....... [optional] json string with configuration for CanvasXpress
|
|
48
48
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
49
|
-
{default}
|
|
49
|
+
{default} 2500
|
|
50
50
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
51
51
|
|
|
52
52
|
Examples:
|
|
@@ -68,7 +68,7 @@ const menus = {
|
|
|
68
68
|
--output, -o ....... [optional] directory path to save image
|
|
69
69
|
{default} './'
|
|
70
70
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
71
|
-
{default}
|
|
71
|
+
{default} 2500
|
|
72
72
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
73
73
|
|
|
74
74
|
Examples:
|
|
@@ -92,10 +92,9 @@ const menus = {
|
|
|
92
92
|
--height, -y ....... [optional] integer for image height
|
|
93
93
|
{default} 800
|
|
94
94
|
--data, -d ......... [optional - required] json string with the data for CanvasXpress
|
|
95
|
-
--config, -c ....... [optional] json string with configuration for CanvasXpress
|
|
96
|
-
{default} 500
|
|
95
|
+
--config, -c ....... [optional] json string with configuration for CanvasXpress
|
|
97
96
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
98
|
-
{default}
|
|
97
|
+
{default} 2500
|
|
99
98
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
100
99
|
|
|
101
100
|
Examples:
|
|
@@ -124,7 +123,7 @@ const menus = {
|
|
|
124
123
|
--data, -d ......... [optional - required] json string with the data for CanvasXpress
|
|
125
124
|
--config, -c ....... [optional] json string with configuration for CanvasXpress
|
|
126
125
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
127
|
-
{default}
|
|
126
|
+
{default} 2500
|
|
128
127
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
129
128
|
|
|
130
129
|
Examples:
|
|
@@ -153,7 +152,7 @@ const menus = {
|
|
|
153
152
|
--data, -d ......... [optional - required] json string with the data for CanvasXpress
|
|
154
153
|
--config, -c ....... [optional] json string with configuration for CanvasXpress
|
|
155
154
|
--timeout, -t ...... [optional] timeout in millisecods to close browser
|
|
156
|
-
{default}
|
|
155
|
+
{default} 2500
|
|
157
156
|
--browser, -b ...... [optional] boolean to do not run headless and pause for debugging
|
|
158
157
|
|
|
159
158
|
Examples:
|
package/cmds/io.js
CHANGED
|
@@ -2,7 +2,7 @@ const util = require('util');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const ora = require('ora');
|
|
5
|
-
const
|
|
5
|
+
const { chromium } = require('playwright');
|
|
6
6
|
|
|
7
7
|
module.exports = async (obj) => {
|
|
8
8
|
|
|
@@ -30,39 +30,31 @@ module.exports = async (obj) => {
|
|
|
30
30
|
|
|
31
31
|
try {
|
|
32
32
|
|
|
33
|
-
const browser = await
|
|
33
|
+
const browser = await chromium.launch({
|
|
34
34
|
headless: obj.debug ? false : true,
|
|
35
35
|
devtools: obj.debug ? true : false,
|
|
36
|
-
executablePath: puppeteer.executablePath(),
|
|
37
|
-
defaultViewport: {
|
|
38
|
-
width: 1000,
|
|
39
|
-
height: 1000
|
|
40
|
-
},
|
|
41
36
|
args: ['--no-sandbox',
|
|
42
37
|
'--allow-file-access-from-files',
|
|
43
38
|
'--enable-local-file-accesses']
|
|
44
39
|
});
|
|
45
40
|
|
|
46
|
-
const
|
|
41
|
+
const context = await browser.newContext({
|
|
42
|
+
viewport: { width: 1000, height: 1000 }
|
|
43
|
+
});
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
//page.on("console", (consoleObj) => console.log(consoleObj.text()));
|
|
45
|
+
const page = await context.newPage();
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
47
|
+
const downloadDir = path.resolve(obj.output);
|
|
48
|
+
const downloads = [];
|
|
49
|
+
page.on('download', (dl) => {
|
|
50
|
+
downloads.push(dl.saveAs(path.join(downloadDir, dl.suggestedFilename())));
|
|
56
51
|
});
|
|
57
52
|
|
|
58
|
-
/*
|
|
59
|
-
// Print only logs
|
|
60
53
|
page.on('console', consoleObj => {
|
|
61
|
-
if (consoleObj.type()
|
|
62
|
-
|
|
54
|
+
if (consoleObj.type() !== 'warning') {
|
|
55
|
+
console.log(consoleObj.text());
|
|
63
56
|
}
|
|
64
57
|
});
|
|
65
|
-
*/
|
|
66
58
|
|
|
67
59
|
if (obj.input && !obj.input.match(/^file|^http/)) {
|
|
68
60
|
obj.input = "file://" + path.resolve(obj.input);
|
|
@@ -107,7 +99,7 @@ module.exports = async (obj) => {
|
|
|
107
99
|
cx.dataURL = obj.input;
|
|
108
100
|
cx.remoteTransitionEffect = 'none';
|
|
109
101
|
cx.getDataFromURLOrString(obj.target || cx.target, obj.config, false, false, clbk);
|
|
110
|
-
} else {
|
|
102
|
+
} else {
|
|
111
103
|
console.log("Creating " + (obj.cmd == 'csv' ? 'png' : obj.cmd) + " file from " + (obj.input ? obj.input : 'input data') + " (" + obj.output + (obj.target || cx.target) + "." + obj.cmd + ")");
|
|
112
104
|
exec(cx, obj.target || cx.target);
|
|
113
105
|
}
|
|
@@ -128,25 +120,32 @@ module.exports = async (obj) => {
|
|
|
128
120
|
}
|
|
129
121
|
}
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
123
|
+
const targetUrl = obj.input
|
|
124
|
+
? (obj.cmd == 'csv' ? defhtml : obj.cmd == 'reproduce' ? obj.input + '?showTransition=false' : obj.input)
|
|
125
|
+
: defhtml;
|
|
135
126
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
await page.goto(defhtml);
|
|
140
|
-
}
|
|
127
|
+
await page.goto(targetUrl, { waitUntil: 'networkidle' });
|
|
128
|
+
|
|
129
|
+
await page.waitForFunction(() => typeof CanvasXpress !== 'undefined');
|
|
141
130
|
|
|
142
|
-
|
|
131
|
+
// Create a CX instance if one doesn't already exist (onReady in template
|
|
132
|
+
// has a circular dependency that prevents auto-instantiation in headless)
|
|
133
|
+
await page.evaluate(() => {
|
|
134
|
+
if (!CanvasXpress.instances || CanvasXpress.instances.length === 0) {
|
|
135
|
+
new CanvasXpress("cX", {y:{vars:["V"],smps:["S"],data:[[0]]}}, {});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
await page.waitForFunction(() => CanvasXpress.ready);
|
|
143
139
|
|
|
144
140
|
await page.evaluate(`(${func.toString()})(${JSON.stringify(obj)})`);
|
|
145
141
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
const delay = obj.cmd == 'csv' || obj.cmd == 'reproduce' ? obj.tmout + 2500 : obj.tmout;
|
|
143
|
+
await page.waitForTimeout(delay);
|
|
144
|
+
|
|
145
|
+
await Promise.all(downloads);
|
|
146
|
+
|
|
147
|
+
await browser.close();
|
|
148
|
+
spinner.stop();
|
|
150
149
|
|
|
151
150
|
} catch (err) {
|
|
152
151
|
|
package/index.js
CHANGED