canvasxpress-cli 62.3.1 → 62.4.5
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 +118 -60
- package/cmds/io.js +71 -61
- package/cmds/version.js +2 -2
- package/index.js +9 -10
- package/package.json +1 -1
- package/src/canvasXpress.html +19 -15
- package/src/canvasXpress.js +4 -276
- package/cmds/io-playwright.js +0 -149
- package/src/area.json +0 -66
- package/src/dotplot.png +0 -0
package/cmds/io-playwright.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
const util = require('util');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const ora = require('ora');
|
|
5
|
-
const { chromium } = require('playwright');
|
|
6
|
-
|
|
7
|
-
module.exports = async (obj) => {
|
|
8
|
-
|
|
9
|
-
const dirname = process.argv[1].replace('/bin/canvasxpress', '');
|
|
10
|
-
|
|
11
|
-
const today = new Date().toISOString().replace('-', '').split('T')[0].replace('-', '');
|
|
12
|
-
|
|
13
|
-
const logFile = fs.createWriteStream(('/tmp/io-' + today + '.log'), { flags: 'a' });
|
|
14
|
-
|
|
15
|
-
const logStdout = process.stdout;
|
|
16
|
-
|
|
17
|
-
const html = (obj.input && obj.input.match(/.html$/) ? obj.input : ("file://" + dirname + "/src/canvasXpress.html")) + (obj.debug ? "?cXH" : "");
|
|
18
|
-
|
|
19
|
-
console.log = function () {
|
|
20
|
-
logFile.write(util.format.apply(null, arguments) + '\n');
|
|
21
|
-
logStdout.write(util.format.apply(null, arguments) + '\n');
|
|
22
|
-
}
|
|
23
|
-
console.error = console.log;
|
|
24
|
-
|
|
25
|
-
const spinner = ora().start();
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
|
|
29
|
-
const browser = await chromium.launch({
|
|
30
|
-
headless: obj.debug ? false : true,
|
|
31
|
-
devtools: obj.debug ? true : false,
|
|
32
|
-
args: [
|
|
33
|
-
'--no-sandbox',
|
|
34
|
-
'--disable-setuid-sandbox',
|
|
35
|
-
'--allow-file-access-from-files',
|
|
36
|
-
'--enable-local-file-accesses'
|
|
37
|
-
]
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const context = await browser.newContext({
|
|
41
|
-
viewport: {
|
|
42
|
-
width: 1000,
|
|
43
|
-
height: 1000
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const page = await context.newPage();
|
|
48
|
-
|
|
49
|
-
page.on('console', (consoleObj) => console.log(consoleObj.text()));
|
|
50
|
-
|
|
51
|
-
if (obj.input && !obj.input.match(/^file|^http/)) {
|
|
52
|
-
obj.input = "file://" + path.resolve(obj.input);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const func = function (obj) {
|
|
56
|
-
|
|
57
|
-
if (obj.debug) {
|
|
58
|
-
debugger;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var exec = function (cx, tg) {
|
|
62
|
-
switch (obj.cmd) {
|
|
63
|
-
case 'png':
|
|
64
|
-
cx.print(false, tg + '.png');
|
|
65
|
-
break;
|
|
66
|
-
case 'svg':
|
|
67
|
-
cx.saveSVG(false, tg + '.svg');
|
|
68
|
-
break;
|
|
69
|
-
case 'json':
|
|
70
|
-
cx.save(false, tg + '.json');
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var clbk = function () {
|
|
76
|
-
var cx = CanvasXpress.instances[0];
|
|
77
|
-
var dt = arguments[0];
|
|
78
|
-
if (dt.config) {
|
|
79
|
-
dt.config.isNode = true;
|
|
80
|
-
}
|
|
81
|
-
cx.updateData(dt, false, false, JSON.parse(JSON.stringify(dt.config)));
|
|
82
|
-
console.log(logStr);
|
|
83
|
-
exec(cx, dt.renderTo);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
var cx = CanvasXpress.instances[0];
|
|
87
|
-
|
|
88
|
-
const extFile = obj.input ? obj.input.split(".").pop() : false;
|
|
89
|
-
|
|
90
|
-
const logStr = "Creating " + obj.cmd + " file from " + (obj.input ? obj.input : 'input data') + " (" + obj.output + (obj.target || cx.target) + (extFile == 'html' ? '' : '-1') + "." + obj.cmd + ")";
|
|
91
|
-
|
|
92
|
-
cx.setDimensions(obj.width, obj.height);
|
|
93
|
-
|
|
94
|
-
if (obj.input) {
|
|
95
|
-
try {
|
|
96
|
-
switch (extFile) {
|
|
97
|
-
case 'html':
|
|
98
|
-
console.log(logStr);
|
|
99
|
-
exec(cx, obj.target || cx.target);
|
|
100
|
-
return;
|
|
101
|
-
case 'json':
|
|
102
|
-
case 'csv':
|
|
103
|
-
case 'text':
|
|
104
|
-
case 'png':
|
|
105
|
-
console.log(logStr);
|
|
106
|
-
CanvasXpress.loadRemoteData(obj.target || cx.target, obj.input, obj.config, false, clbk);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
console.error(err);
|
|
111
|
-
}
|
|
112
|
-
} else if (obj.data) {
|
|
113
|
-
try {
|
|
114
|
-
console.log(logStr);
|
|
115
|
-
cx.updateData(obj.data, false, false, obj.config);
|
|
116
|
-
exec(cx, obj.target || cx.target);
|
|
117
|
-
return;
|
|
118
|
-
} catch (err) {
|
|
119
|
-
console.error(err);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const client = await context.newCDPSession(page);
|
|
126
|
-
|
|
127
|
-
await client.send('Page.setDownloadBehavior', {
|
|
128
|
-
behavior: 'allow',
|
|
129
|
-
downloadPath: obj.output
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
await page.goto(html);
|
|
133
|
-
|
|
134
|
-
await page.waitForFunction('typeof (CanvasXpress) !== undefined && CanvasXpress.ready');
|
|
135
|
-
|
|
136
|
-
await page.evaluate(`(${func.toString()})(${JSON.stringify(obj)})`);
|
|
137
|
-
|
|
138
|
-
await setTimeout(() => {
|
|
139
|
-
browser.close();
|
|
140
|
-
spinner.stop();
|
|
141
|
-
}, obj.tmout);
|
|
142
|
-
|
|
143
|
-
} catch (err) {
|
|
144
|
-
|
|
145
|
-
console.error(err);
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
}
|
package/src/area.json
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 41.2,
|
|
3
|
-
"renderTo": "area1",
|
|
4
|
-
"data": {
|
|
5
|
-
"y": {
|
|
6
|
-
"data": [
|
|
7
|
-
[10,100,70,130,60]
|
|
8
|
-
],
|
|
9
|
-
"vars": ["A"],
|
|
10
|
-
"smps": ["S1","S2","S3","S4","S5"]
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"config": {
|
|
14
|
-
"colorScheme": "CanvasXpress",
|
|
15
|
-
"graphOrientation": "vertical",
|
|
16
|
-
"graphType": "Area",
|
|
17
|
-
"lineType": "rect",
|
|
18
|
-
"objectBorderColor": false,
|
|
19
|
-
"showLegend": false,
|
|
20
|
-
"showSampleNames": true,
|
|
21
|
-
"showTransition": false,
|
|
22
|
-
"smpLabelRotate": 90,
|
|
23
|
-
"smpTitle": "time"
|
|
24
|
-
},
|
|
25
|
-
"events": false,
|
|
26
|
-
"info": false,
|
|
27
|
-
"afterRenderInit": false,
|
|
28
|
-
"afterRender": [
|
|
29
|
-
[
|
|
30
|
-
"setDimensions",
|
|
31
|
-
[609,609,true]
|
|
32
|
-
]
|
|
33
|
-
],
|
|
34
|
-
"noValidate": true,
|
|
35
|
-
"factory": {
|
|
36
|
-
"version": 41.2,
|
|
37
|
-
"buildDate": "12-05-2022",
|
|
38
|
-
"client": "MDo6MTo6NDEuMjo6",
|
|
39
|
-
"siteSrc": false,
|
|
40
|
-
"href": "http://localhost:8000/examples/area-1.html",
|
|
41
|
-
"services": "https://www.canvasxpress.org/cgi-bin/services.pl"
|
|
42
|
-
},
|
|
43
|
-
"system": {
|
|
44
|
-
"browser": "Chrome",
|
|
45
|
-
"browserVersion": "107",
|
|
46
|
-
"os": "Mac OS",
|
|
47
|
-
"alt": "⌥",
|
|
48
|
-
"command": "⌘",
|
|
49
|
-
"control": "⌃",
|
|
50
|
-
"shift": "⇧",
|
|
51
|
-
"isNode": false,
|
|
52
|
-
"isHeadless": false,
|
|
53
|
-
"isjQuery": false,
|
|
54
|
-
"isReveal": false,
|
|
55
|
-
"isZoom": false,
|
|
56
|
-
"isIE": false,
|
|
57
|
-
"isInIframe": false,
|
|
58
|
-
"isTouchScreen": 0,
|
|
59
|
-
"isR": false,
|
|
60
|
-
"isHTMLWidgets": false,
|
|
61
|
-
"isShiny": false,
|
|
62
|
-
"isRViewer": false,
|
|
63
|
-
"isRConsole": false,
|
|
64
|
-
"isCxplot": false
|
|
65
|
-
}
|
|
66
|
-
}
|
package/src/dotplot.png
DELETED
|
Binary file
|