visualizer-on-tabs 1.0.2 → 2.0.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 CHANGED
@@ -16,6 +16,15 @@ 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
+ // If true, automatically redirects to the login page if not logged in
26
+ auto: true,
27
+ },
19
28
  // List of default views to load
20
29
  possibleViews: {
21
30
  Home: {
@@ -42,15 +51,17 @@ const config = {
42
51
  // lead to layout issues. Especially in Firefox.
43
52
  // When false, only the selected tab is loaded.
44
53
  loadHidden: false,
45
- // The visualizer configuration object that will be passed to each visualizer instance
46
- visualizerConfig: undefined,
47
- // The version of the visualizer to load. By default it 'auto', which uses
48
- // the version stored in the loaded view.
49
- visualizerVersion: 'auto',
50
- // Options passed to `makeVisualizerPage`, see https://github.com/cheminfo/react-visualizer
51
- // Respectively `fallbackVersion` and `cdn`.
52
- visualizerFallbackVersion: undefined,
53
- visualizerCDN: undefined,
54
+
55
+ // Options passed to makeVisualizerPage
56
+ // See https://github.com/cheminfo/react-visualizer
57
+ visualizer: {
58
+ loadversion: 'exact',
59
+ fallbackVersion: 'latest',
60
+ cdn: 'https://www.lactame.com/visualizer',
61
+ // Can be a URL string or an object
62
+ // Example of config object: https://github.com/NPellet/visualizer/blob/master/src/usr/config/default.json
63
+ config: '',
64
+ },
54
65
  };
55
66
  ```
56
67
 
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 = minimist(process.argv.slice(2));
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
@@ -102,7 +102,7 @@ export default async (options) => {
102
102
  await copyBootstrap(options);
103
103
  await copyContent(options);
104
104
  await Promise.all([
105
- fs.writeFile(confPath, JSON.stringify(options.config)),
105
+ fs.writeFile(confPath, JSON.stringify(options.config ?? {})),
106
106
  addIndex(options),
107
107
  addVisualizer(options),
108
108
  ]);
@@ -156,13 +156,16 @@ async function addIndex(options) {
156
156
  }
157
157
 
158
158
  function addVisualizer(options) {
159
+ const customScripts = options.config.visualizer?.scripts || [];
159
160
  const page = visualizer.makeVisualizerPage({
160
- cdn: options.config.visualizerCDN,
161
- fallbackVersion: options.config.visualizerFallbackVersion,
161
+ // By default we choose the safest option
162
+ loadversion: 'exact',
163
+ ...options.config.visualizer,
162
164
  scripts: [
163
165
  {
164
166
  url: iframeBridge,
165
167
  },
168
+ ...customScripts,
166
169
  ],
167
170
  });
168
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": "1.0.2",
3
+ "version": "2.0.1",
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=1 --config=./dev.json --outDir=./out",
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 ./",
@@ -36,18 +36,17 @@
36
36
  "iframe-bridge": "^3.0.2",
37
37
  "lockr": "^0.8.5",
38
38
  "lodash": "^4.17.23",
39
- "minimist": "^1.2.8",
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": "^3.0.1",
44
- "webpack": "^5.105.1"
42
+ "react-visualizer": "^5.3.0",
43
+ "webpack": "^5.105.2"
45
44
  },
46
45
  "devDependencies": {
47
46
  "eslint": "^9.39.2",
48
47
  "eslint-config-zakodium": "^19.1.0",
49
48
  "prettier": "^3.8.1",
50
- "rimraf": "^6.1.2"
49
+ "rimraf": "^6.1.3"
51
50
  },
52
51
  "volta": {
53
52
  "node": "24.7.0"
@@ -323,10 +323,6 @@ class App extends React.Component {
323
323
  <Visualizer
324
324
  url="visualizer.html"
325
325
  viewURL={view.rewrittenUrl || view.url}
326
- version={
327
- this.visualizerVersion || config.visualizerVersion || 'auto'
328
- }
329
- config={config.visualizerConfig}
330
326
  style={iframeStyle}
331
327
  />
332
328
  );
@@ -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
- if (config.rocLogin.urlAbsolute) {
18
- this.loginUrl = config.rocLogin.urlAbsolute;
19
- } else {
20
- this.loginUrl = `${config.rocLogin.url}/auth/login?continue=${encodeURIComponent(
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() {
@@ -28,16 +24,17 @@ class Login extends React.Component {
28
24
  }
29
25
 
30
26
  async session() {
31
- if (!this.props.config.rocLogin) return;
32
- const login = this.props.config.rocLogin;
33
- const response = await fetch(`${login.url}/auth/session`, {
27
+ const rocLogin = this.props.config.rocLogin;
28
+ if (!rocLogin) return;
29
+ const response = await fetch(`${rocLogin.url}/auth/session`, {
34
30
  credentials: 'include',
35
31
  });
36
32
  if (response.ok) {
37
33
  const body = await response.json();
38
34
  if (
39
- login.auto &&
40
- (!body.authenticated || (login.user && body.username !== login.user))
35
+ rocLogin.auto &&
36
+ (!body.authenticated ||
37
+ (rocLogin.user && body.username !== rocLogin.user))
41
38
  ) {
42
39
  window.location.href = this.loginUrl;
43
40
  }
@@ -1,7 +1,13 @@
1
- import defaultConfig from './default.js';
1
+ import defaultVisualizerConfig from './visualizer.js';
2
2
 
3
3
  export function getConfig(customConfig) {
4
- const config = { ...defaultConfig, ...customConfig };
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(/\/$/, '');
@@ -1,5 +1,5 @@
1
1
  export default {
2
- visualizerConfig: {
2
+ config: {
3
3
  debugLevel: 0,
4
4
  filters: [],
5
5
  modules: {
@@ -1,7 +0,0 @@
1
- const config = '../config.json';
2
-
3
- const defaultConfig = {};
4
-
5
- export function getConfig() {
6
- return config.visualizerConfig || defaultConfig;
7
- }