visualizer-on-tabs 1.0.1 → 2.0.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 +23 -9
- package/bin/build.js +8 -3
- package/main/index.js +7 -10
- package/package.json +13 -14
- package/src/components/App.js +1 -4
- package/src/components/Login.js +3 -7
- package/src/config/config.js +8 -2
- package/src/config/{default.js → visualizer.js} +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,13 @@ Example: https://github.com/cheminfo/cheminfo-server-setup/blob/master/doc/on-ta
|
|
|
16
16
|
const config = {
|
|
17
17
|
// Title of the single page app
|
|
18
18
|
title: 'My app',
|
|
19
|
+
// Roc login configuration. Don't set or set to false to disable login
|
|
20
|
+
rocLogin: {
|
|
21
|
+
// URL of the rest-on-couch server
|
|
22
|
+
url: 'https://demo.scipeaks.com/roc',
|
|
23
|
+
// Redirect after login
|
|
24
|
+
redirect: 'https://demo.scipeaks.com/',
|
|
25
|
+
},
|
|
19
26
|
// List of default views to load
|
|
20
27
|
possibleViews: {
|
|
21
28
|
Home: {
|
|
@@ -42,15 +49,22 @@ const config = {
|
|
|
42
49
|
// lead to layout issues. Especially in Firefox.
|
|
43
50
|
// When false, only the selected tab is loaded.
|
|
44
51
|
loadHidden: false,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
// Options related to https://github.com/cheminfo/react-visualizer
|
|
54
|
+
visualizer: {
|
|
55
|
+
/**
|
|
56
|
+
* Options to generate the visualizer html page
|
|
57
|
+
*/
|
|
58
|
+
loadversion: 'exact',
|
|
59
|
+
fallbackVersion: 'latest',
|
|
60
|
+
cdn: 'https://www.lactame.com/visualizer',
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
* Props passed to the visualizer component
|
|
64
|
+
*/
|
|
65
|
+
// Visualizer config.json
|
|
66
|
+
config: undefined,
|
|
67
|
+
},
|
|
54
68
|
};
|
|
55
69
|
```
|
|
56
70
|
|
package/bin/build.js
CHANGED
|
@@ -5,12 +5,17 @@
|
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import process from 'node:process';
|
|
8
|
-
|
|
9
|
-
import minimist from 'minimist';
|
|
8
|
+
import { parseArgs } from 'node:util';
|
|
10
9
|
|
|
11
10
|
import build from '../main/index.js';
|
|
12
11
|
|
|
13
|
-
const argv =
|
|
12
|
+
const { values: argv } = parseArgs({
|
|
13
|
+
options: {
|
|
14
|
+
outDir: { type: 'string', short: 'o' },
|
|
15
|
+
dev: { type: 'boolean', short: 'D' },
|
|
16
|
+
config: { type: 'string', short: 'c' },
|
|
17
|
+
},
|
|
18
|
+
});
|
|
14
19
|
|
|
15
20
|
if (!argv.outDir) {
|
|
16
21
|
console.log(`CLI args:
|
package/main/index.js
CHANGED
|
@@ -12,10 +12,6 @@ import iframeBridge from './iframe-bridge.js';
|
|
|
12
12
|
|
|
13
13
|
const __dirname = import.meta.dirname;
|
|
14
14
|
|
|
15
|
-
const defaultConfig = {
|
|
16
|
-
title: 'visualizer-on-tabs',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
15
|
async function buildApp(options, outDir, cleanup) {
|
|
20
16
|
const { promise, resolve, reject } = Promise.withResolvers();
|
|
21
17
|
const entries = [{ file: 'app.js' }];
|
|
@@ -97,8 +93,6 @@ async function buildApp(options, outDir, cleanup) {
|
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
export default async (options) => {
|
|
100
|
-
Object.assign(options.config, defaultConfig);
|
|
101
|
-
|
|
102
96
|
const outDir = path.resolve(options.outDir);
|
|
103
97
|
await fs.mkdir(outDir, { recursive: true });
|
|
104
98
|
|
|
@@ -108,7 +102,7 @@ export default async (options) => {
|
|
|
108
102
|
await copyBootstrap(options);
|
|
109
103
|
await copyContent(options);
|
|
110
104
|
await Promise.all([
|
|
111
|
-
fs.writeFile(confPath, JSON.stringify(options.config)),
|
|
105
|
+
fs.writeFile(confPath, JSON.stringify(options.config ?? {})),
|
|
112
106
|
addIndex(options),
|
|
113
107
|
addVisualizer(options),
|
|
114
108
|
]);
|
|
@@ -155,20 +149,23 @@ async function addIndex(options) {
|
|
|
155
149
|
return fs.writeFile(
|
|
156
150
|
path.join(options.outDir, 'index.html'),
|
|
157
151
|
tpl({
|
|
158
|
-
title: options.config.title,
|
|
152
|
+
title: options.config.title || 'visualizer-on-tabs',
|
|
159
153
|
uniqid: Date.now(),
|
|
160
154
|
}),
|
|
161
155
|
);
|
|
162
156
|
}
|
|
163
157
|
|
|
164
158
|
function addVisualizer(options) {
|
|
159
|
+
const customScripts = options.config.visualizer?.scripts || [];
|
|
165
160
|
const page = visualizer.makeVisualizerPage({
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
// By default we choose the safest option
|
|
162
|
+
loadversion: 'exact',
|
|
163
|
+
...options.config.visualizer,
|
|
168
164
|
scripts: [
|
|
169
165
|
{
|
|
170
166
|
url: iframeBridge,
|
|
171
167
|
},
|
|
168
|
+
...customScripts,
|
|
172
169
|
],
|
|
173
170
|
});
|
|
174
171
|
return fs.writeFile(path.join(options.outDir, 'visualizer.html'), page);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visualizer-on-tabs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "visualizer-on-tabs webpack builder",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "npx --no-install visualizer-on-tabs --config=./dev.json --outDir=./out",
|
|
21
|
-
"build:dev": "npx --no-install visualizer-on-tabs --dev
|
|
21
|
+
"build:dev": "npx --no-install visualizer-on-tabs --dev --config=./dev.json --outDir=./out",
|
|
22
22
|
"clean": "rimraf out",
|
|
23
23
|
"eslint": "eslint bin main src",
|
|
24
24
|
"prettier": "prettier --check ./",
|
|
@@ -28,26 +28,25 @@
|
|
|
28
28
|
"test-only": "node --test"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@babel/core": "^7.
|
|
32
|
-
"@babel/preset-env": "^7.
|
|
33
|
-
"@babel/preset-react": "^7.
|
|
31
|
+
"@babel/core": "^7.29.0",
|
|
32
|
+
"@babel/preset-env": "^7.29.0",
|
|
33
|
+
"@babel/preset-react": "^7.28.5",
|
|
34
34
|
"babel-loader": "^10.0.0",
|
|
35
|
-
"bootstrap": "^5.3.
|
|
35
|
+
"bootstrap": "^5.3.8",
|
|
36
36
|
"iframe-bridge": "^3.0.2",
|
|
37
37
|
"lockr": "^0.8.5",
|
|
38
|
-
"lodash": "^4.17.
|
|
39
|
-
"minimist": "^1.2.6",
|
|
38
|
+
"lodash": "^4.17.23",
|
|
40
39
|
"react": "^18.3.1",
|
|
41
40
|
"react-bootstrap": "^3.0.0-beta.3",
|
|
42
41
|
"react-dom": "^18.3.1",
|
|
43
|
-
"react-visualizer": "^
|
|
44
|
-
"webpack": "^5.
|
|
42
|
+
"react-visualizer": "^5.0.0",
|
|
43
|
+
"webpack": "^5.105.2"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"eslint": "^9.
|
|
48
|
-
"eslint-config-zakodium": "^
|
|
49
|
-
"prettier": "^3.
|
|
50
|
-
"rimraf": "^6.
|
|
46
|
+
"eslint": "^9.39.2",
|
|
47
|
+
"eslint-config-zakodium": "^19.1.0",
|
|
48
|
+
"prettier": "^3.8.1",
|
|
49
|
+
"rimraf": "^6.1.3"
|
|
51
50
|
},
|
|
52
51
|
"volta": {
|
|
53
52
|
"node": "24.7.0"
|
package/src/components/App.js
CHANGED
|
@@ -323,10 +323,7 @@ class App extends React.Component {
|
|
|
323
323
|
<Visualizer
|
|
324
324
|
url="visualizer.html"
|
|
325
325
|
viewURL={view.rewrittenUrl || view.url}
|
|
326
|
-
|
|
327
|
-
this.visualizerVersion || config.visualizerVersion || 'auto'
|
|
328
|
-
}
|
|
329
|
-
config={config.visualizerConfig}
|
|
326
|
+
config={config.visualizer.config}
|
|
330
327
|
style={iframeStyle}
|
|
331
328
|
/>
|
|
332
329
|
);
|
package/src/components/Login.js
CHANGED
|
@@ -14,13 +14,9 @@ class Login extends React.Component {
|
|
|
14
14
|
this.logout = this.logout.bind(this);
|
|
15
15
|
if (!config.rocLogin) return;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
this.loginUrl = `${config.rocLogin.url}/auth/login?continue=${
|
|
21
|
-
config.rocLogin.redirect || window.location.href
|
|
22
|
-
}`;
|
|
23
|
-
}
|
|
17
|
+
this.loginUrl = `${config.rocLogin.url}/auth/login?continue=${encodeURIComponent(
|
|
18
|
+
config.rocLogin.redirect || window.location.href,
|
|
19
|
+
)}`;
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
componentDidMount() {
|
package/src/config/config.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import defaultVisualizerConfig from './visualizer.js';
|
|
2
2
|
|
|
3
3
|
export function getConfig(customConfig) {
|
|
4
|
-
const config = {
|
|
4
|
+
const config = {
|
|
5
|
+
...customConfig,
|
|
6
|
+
visualizer: {
|
|
7
|
+
...defaultVisualizerConfig,
|
|
8
|
+
...customConfig?.visualizer,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
5
11
|
if (config.rocLogin && config.rocLogin.url) {
|
|
6
12
|
// Remove trailing slash
|
|
7
13
|
config.rocLogin.url = config.rocLogin.url.replace(/\/$/, '');
|