@jbrowse/plugin-legacy-jbrowse 3.7.0 → 4.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/esm/JBrowse1Connection/configSchema.d.ts +3 -3
- package/esm/JBrowse1Connection/get-value.js +1 -1
- package/esm/JBrowse1Connection/index.js +2 -2
- package/esm/JBrowse1Connection/jb1ConfigLoad.d.ts +1 -1
- package/esm/JBrowse1Connection/jb1ConfigLoad.js +2 -2
- package/esm/JBrowse1Connection/jb1ConfigParse.d.ts +1 -1
- package/esm/JBrowse1Connection/jb1ConfigParse.js +12 -10
- package/esm/JBrowse1Connection/jb1ToJb2.d.ts +2 -3
- package/esm/JBrowse1Connection/jb1ToJb2.js +7 -9
- package/esm/JBrowse1Connection/model.d.ts +16 -24
- package/esm/JBrowse1Connection/model.js +8 -14
- package/esm/JBrowse1Connection/util.d.ts +1 -1
- package/esm/JBrowse1Connection/util.js +13 -3
- package/esm/JBrowse1TextSearchAdapter/HttpMap.js +16 -1
- package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +1 -1
- package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +3 -1
- package/esm/JBrowse1TextSearchAdapter/configSchema.d.ts +2 -2
- package/esm/JBrowse1TextSearchAdapter/index.js +2 -2
- package/esm/NCListAdapter/NCListAdapter.d.ts +1 -1
- package/esm/NCListAdapter/NCListAdapter.js +4 -3
- package/esm/NCListAdapter/NCListFeature.js +3 -0
- package/esm/NCListAdapter/configSchema.d.ts +2 -2
- package/esm/NCListAdapter/index.js +2 -2
- package/esm/index.js +5 -8
- package/package.json +25 -32
- package/dist/GuessNCList/index.d.ts +0 -2
- package/dist/GuessNCList/index.js +0 -18
- package/dist/JBrowse1Connection/configSchema.d.ts +0 -27
- package/dist/JBrowse1Connection/configSchema.js +0 -23
- package/dist/JBrowse1Connection/get-value.d.ts +0 -10
- package/dist/JBrowse1Connection/get-value.js +0 -86
- package/dist/JBrowse1Connection/index.d.ts +0 -2
- package/dist/JBrowse1Connection/index.js +0 -19
- package/dist/JBrowse1Connection/jb1ConfigLoad.d.ts +0 -36
- package/dist/JBrowse1Connection/jb1ConfigLoad.js +0 -253
- package/dist/JBrowse1Connection/jb1ConfigParse.d.ts +0 -4
- package/dist/JBrowse1Connection/jb1ConfigParse.js +0 -341
- package/dist/JBrowse1Connection/jb1ToJb2.d.ts +0 -49
- package/dist/JBrowse1Connection/jb1ToJb2.js +0 -408
- package/dist/JBrowse1Connection/model.d.ts +0 -75
- package/dist/JBrowse1Connection/model.js +0 -82
- package/dist/JBrowse1Connection/types.d.ts +0 -91
- package/dist/JBrowse1Connection/types.js +0 -2
- package/dist/JBrowse1Connection/util.d.ts +0 -8
- package/dist/JBrowse1Connection/util.js +0 -86
- package/dist/JBrowse1TextSearchAdapter/HttpMap.d.ts +0 -19
- package/dist/JBrowse1TextSearchAdapter/HttpMap.js +0 -65
- package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +0 -28
- package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +0 -58
- package/dist/JBrowse1TextSearchAdapter/configSchema.d.ts +0 -21
- package/dist/JBrowse1TextSearchAdapter/configSchema.js +0 -24
- package/dist/JBrowse1TextSearchAdapter/index.d.ts +0 -2
- package/dist/JBrowse1TextSearchAdapter/index.js +0 -49
- package/dist/NCListAdapter/NCListAdapter.d.ts +0 -17
- package/dist/NCListAdapter/NCListAdapter.js +0 -48
- package/dist/NCListAdapter/NCListFeature.d.ts +0 -16
- package/dist/NCListAdapter/NCListFeature.js +0 -58
- package/dist/NCListAdapter/configSchema.d.ts +0 -15
- package/dist/NCListAdapter/configSchema.js +0 -21
- package/dist/NCListAdapter/index.d.ts +0 -2
- package/dist/NCListAdapter/index.js +0 -52
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-legacy-jbrowse",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "JBrowse 2 plugin for connecting to and reading JBrowse 1 data",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -15,42 +15,35 @@
|
|
|
15
15
|
"directory": "plugins/legacy-jbrowse"
|
|
16
16
|
},
|
|
17
17
|
"author": "JBrowse Team",
|
|
18
|
-
"
|
|
19
|
-
"srcMain": "src/index.ts",
|
|
20
|
-
"main": "dist/index.js",
|
|
18
|
+
"main": "esm/index.js",
|
|
21
19
|
"files": [
|
|
22
|
-
"dist",
|
|
23
20
|
"esm"
|
|
24
21
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "npm-run-all build:*",
|
|
27
|
-
"test": "cd ../..; jest --passWithNoTests plugins/legacy-jbrowse",
|
|
28
|
-
"prepublishOnly": "yarn test",
|
|
29
|
-
"prepack": "yarn build && yarn useDist",
|
|
30
|
-
"postpack": "yarn useSrc",
|
|
31
|
-
"useDist": "node ../../scripts/useDist.js",
|
|
32
|
-
"useSrc": "node ../../scripts/useSrc.js",
|
|
33
|
-
"prebuild": "npm run clean",
|
|
34
|
-
"build:esm": "tsc --build tsconfig.build.esm.json",
|
|
35
|
-
"build:commonjs": "tsc --build tsconfig.build.commonjs.json",
|
|
36
|
-
"clean": "rimraf dist esm *.tsbuildinfo"
|
|
37
|
-
},
|
|
38
22
|
"dependencies": {
|
|
39
|
-
"@gmod/nclist": "^3.0.
|
|
40
|
-
"@jbrowse/
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"rxjs": "^7.0.0",
|
|
47
|
-
"set-value": "^4.0.1"
|
|
23
|
+
"@gmod/nclist": "^3.0.4",
|
|
24
|
+
"@jbrowse/mobx-state-tree": "^5.5.0",
|
|
25
|
+
"generic-filehandle2": "^2.0.18",
|
|
26
|
+
"mobx": "^6.15.0",
|
|
27
|
+
"rxjs": "^7.8.2",
|
|
28
|
+
"set-value": "^4.1.0",
|
|
29
|
+
"@jbrowse/core": "^4.0.1"
|
|
48
30
|
},
|
|
49
31
|
"publishConfig": {
|
|
50
32
|
"access": "public"
|
|
51
33
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "pnpm run /^build:/",
|
|
37
|
+
"test": "cd ../..; jest --passWithNoTests plugins/legacy-jbrowse",
|
|
38
|
+
"prebuild": "pnpm clean",
|
|
39
|
+
"build:esm": "tsc -p tsconfig.build.esm.json",
|
|
40
|
+
"clean": "rimraf esm *.tsbuildinfo"
|
|
41
|
+
},
|
|
42
|
+
"types": "esm/index.d.ts",
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"types": "./esm/index.d.ts",
|
|
46
|
+
"import": "./esm/index.js"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = GuessNCListF;
|
|
4
|
-
const tracks_1 = require("@jbrowse/core/util/tracks");
|
|
5
|
-
function GuessNCListF(pluginManager) {
|
|
6
|
-
pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
|
|
7
|
-
return (file, index, adapterHint) => {
|
|
8
|
-
const fileName = (0, tracks_1.getFileName)(file);
|
|
9
|
-
return (/trackData.jsonz?$/i.test(fileName) && !adapterHint) ||
|
|
10
|
-
adapterHint === 'NCListAdapter'
|
|
11
|
-
? {
|
|
12
|
-
type: 'NCListAdapter',
|
|
13
|
-
rootUrlTemplate: file,
|
|
14
|
-
}
|
|
15
|
-
: adapterGuesser(file, index, adapterHint);
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
declare const JBrowse1Connection: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
-
dataDirLocation: {
|
|
3
|
-
type: string;
|
|
4
|
-
defaultValue: {
|
|
5
|
-
uri: string;
|
|
6
|
-
locationType: string;
|
|
7
|
-
};
|
|
8
|
-
description: string;
|
|
9
|
-
};
|
|
10
|
-
assemblyNames: {
|
|
11
|
-
description: string;
|
|
12
|
-
type: string;
|
|
13
|
-
defaultValue: never[];
|
|
14
|
-
};
|
|
15
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
16
|
-
name: {
|
|
17
|
-
type: string;
|
|
18
|
-
defaultValue: string;
|
|
19
|
-
description: string;
|
|
20
|
-
};
|
|
21
|
-
assemblyNames: {
|
|
22
|
-
type: string;
|
|
23
|
-
defaultValue: never[];
|
|
24
|
-
description: string;
|
|
25
|
-
};
|
|
26
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "connectionId">>, undefined>>;
|
|
27
|
-
export default JBrowse1Connection;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
|
-
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
5
|
-
function x() { }
|
|
6
|
-
const JBrowse1Connection = (0, configuration_1.ConfigurationSchema)('JBrowse1Connection', {
|
|
7
|
-
dataDirLocation: {
|
|
8
|
-
type: 'fileLocation',
|
|
9
|
-
defaultValue: {
|
|
10
|
-
uri: 'http://mysite.com/jbrowse/data/',
|
|
11
|
-
locationType: 'UriLocation',
|
|
12
|
-
},
|
|
13
|
-
description: 'the location of the JBrowse 1 data directory, often something like http://mysite.com/jbrowse/data/',
|
|
14
|
-
},
|
|
15
|
-
assemblyNames: {
|
|
16
|
-
description: 'name of the assembly the connection belongs to, should be a single entry',
|
|
17
|
-
type: 'stringArray',
|
|
18
|
-
defaultValue: [],
|
|
19
|
-
},
|
|
20
|
-
}, {
|
|
21
|
-
baseConfiguration: models_1.baseConnectionConfig,
|
|
22
|
-
});
|
|
23
|
-
exports.default = JBrowse1Connection;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface Options {
|
|
2
|
-
default?: unknown;
|
|
3
|
-
separator?: string;
|
|
4
|
-
joinChar?: string;
|
|
5
|
-
join?: (segs: string[]) => string;
|
|
6
|
-
split?: (path: string) => string[];
|
|
7
|
-
isValid?: (key: string, target: {}) => boolean;
|
|
8
|
-
}
|
|
9
|
-
declare const getValue: (target: unknown, path: string | number | string[], options?: Options) => unknown;
|
|
10
|
-
export default getValue;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const isObject = v => v !== null && typeof v === 'object';
|
|
4
|
-
const join = (segs, joinChar, options) => {
|
|
5
|
-
if (typeof options.join === 'function') {
|
|
6
|
-
return options.join(segs);
|
|
7
|
-
}
|
|
8
|
-
return segs[0] + joinChar + segs[1];
|
|
9
|
-
};
|
|
10
|
-
const split = (path, splitChar, options) => {
|
|
11
|
-
if (typeof options.split === 'function') {
|
|
12
|
-
return options.split(path);
|
|
13
|
-
}
|
|
14
|
-
return path.split(splitChar);
|
|
15
|
-
};
|
|
16
|
-
const isValid = (key, target = {}, options) => {
|
|
17
|
-
if (typeof (options === null || options === void 0 ? void 0 : options.isValid) === 'function') {
|
|
18
|
-
return options.isValid(key, target);
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
const isValidObject = (v) => {
|
|
23
|
-
return isObject(v) || typeof v === 'function';
|
|
24
|
-
};
|
|
25
|
-
const getValue = (target, path, options = {}) => {
|
|
26
|
-
if (!isObject(options)) {
|
|
27
|
-
options = { default: options };
|
|
28
|
-
}
|
|
29
|
-
if (!isValidObject(target)) {
|
|
30
|
-
return options.default !== undefined ? options.default : target;
|
|
31
|
-
}
|
|
32
|
-
if (typeof path === 'number') {
|
|
33
|
-
path = String(path);
|
|
34
|
-
}
|
|
35
|
-
const pathIsArray = Array.isArray(path);
|
|
36
|
-
const pathIsString = typeof path === 'string';
|
|
37
|
-
const splitChar = options.separator || '.';
|
|
38
|
-
const joinChar = options.joinChar || (typeof splitChar === 'string' ? splitChar : '.');
|
|
39
|
-
if (!pathIsString && !pathIsArray) {
|
|
40
|
-
return target;
|
|
41
|
-
}
|
|
42
|
-
if (target[path] !== undefined) {
|
|
43
|
-
return isValid(path, target, options) ? target[path] : options.default;
|
|
44
|
-
}
|
|
45
|
-
const segs = pathIsArray ? path : split(path, splitChar, options);
|
|
46
|
-
const len = segs.length;
|
|
47
|
-
let idx = 0;
|
|
48
|
-
do {
|
|
49
|
-
let prop = segs[idx];
|
|
50
|
-
if (typeof prop !== 'string') {
|
|
51
|
-
prop = String(prop);
|
|
52
|
-
}
|
|
53
|
-
while (prop.endsWith('\\')) {
|
|
54
|
-
prop = join([prop.slice(0, -1), segs[++idx] || ''], joinChar, options);
|
|
55
|
-
}
|
|
56
|
-
if (target[prop] !== undefined) {
|
|
57
|
-
if (!isValid(prop, target, options)) {
|
|
58
|
-
return options.default;
|
|
59
|
-
}
|
|
60
|
-
target = target[prop];
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
let hasProp = false;
|
|
64
|
-
let n = idx + 1;
|
|
65
|
-
while (n < len) {
|
|
66
|
-
prop = join([prop, segs[n++]], joinChar, options);
|
|
67
|
-
if ((hasProp = target[prop] !== undefined)) {
|
|
68
|
-
if (!isValid(prop, target, options)) {
|
|
69
|
-
return options.default;
|
|
70
|
-
}
|
|
71
|
-
target = target[prop];
|
|
72
|
-
idx = n - 1;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (!hasProp) {
|
|
77
|
-
return options.default;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
} while (++idx < len && isValidObject(target));
|
|
81
|
-
if (idx === len) {
|
|
82
|
-
return target;
|
|
83
|
-
}
|
|
84
|
-
return options.default;
|
|
85
|
-
};
|
|
86
|
-
exports.default = getValue;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = JBrowse1ConnectionF;
|
|
7
|
-
const ConnectionType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/ConnectionType"));
|
|
8
|
-
const configSchema_1 = __importDefault(require("./configSchema"));
|
|
9
|
-
const model_1 = __importDefault(require("./model"));
|
|
10
|
-
function JBrowse1ConnectionF(pluginManager) {
|
|
11
|
-
pluginManager.addConnectionType(() => new ConnectionType_1.default({
|
|
12
|
-
name: 'JBrowse1Connection',
|
|
13
|
-
configSchema: configSchema_1.default,
|
|
14
|
-
stateModel: (0, model_1.default)(pluginManager),
|
|
15
|
-
displayName: 'JBrowse 1 Data',
|
|
16
|
-
description: 'A JBrowse 1 data directory',
|
|
17
|
-
url: '//jbrowse.org/',
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Config, JBLocation } from './types';
|
|
2
|
-
export declare function fetchJb1(dataRoot?: JBLocation, baseConfig?: Config, baseConfigRoot?: JBLocation): Promise<Config>;
|
|
3
|
-
export declare function createFinalConfig(baseConfig: Config, defaults?: {
|
|
4
|
-
tracks: never[];
|
|
5
|
-
containerID: string;
|
|
6
|
-
dataRoot: string;
|
|
7
|
-
show_tracklist: boolean;
|
|
8
|
-
show_nav: boolean;
|
|
9
|
-
show_menu: boolean;
|
|
10
|
-
show_overview: boolean;
|
|
11
|
-
show_fullviewlink: boolean;
|
|
12
|
-
update_browser_title: boolean;
|
|
13
|
-
updateBrowserURL: boolean;
|
|
14
|
-
refSeqs: string;
|
|
15
|
-
include: string[];
|
|
16
|
-
nameUrl: string;
|
|
17
|
-
datasets: {
|
|
18
|
-
_DEFAULT_EXAMPLES: boolean;
|
|
19
|
-
volvox: {
|
|
20
|
-
url: string;
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
modencode: {
|
|
24
|
-
url: string;
|
|
25
|
-
name: string;
|
|
26
|
-
};
|
|
27
|
-
yeast: {
|
|
28
|
-
url: string;
|
|
29
|
-
name: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
highlightSearchedRegions: boolean;
|
|
33
|
-
highResolutionMode: string;
|
|
34
|
-
}): Promise<Config>;
|
|
35
|
-
export declare function fetchConfigFile(location: JBLocation): Promise<Config>;
|
|
36
|
-
export declare function parseJb1(config: string, url?: string): Config;
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchJb1 = fetchJb1;
|
|
4
|
-
exports.createFinalConfig = createFinalConfig;
|
|
5
|
-
exports.fetchConfigFile = fetchConfigFile;
|
|
6
|
-
exports.parseJb1 = parseJb1;
|
|
7
|
-
const io_1 = require("@jbrowse/core/util/io");
|
|
8
|
-
const jb1ConfigParse_1 = require("./jb1ConfigParse");
|
|
9
|
-
const util_1 = require("./util");
|
|
10
|
-
function isUriLocation(location) {
|
|
11
|
-
return location.uri !== undefined;
|
|
12
|
-
}
|
|
13
|
-
function isLocalPathLocation(location) {
|
|
14
|
-
return location.localPath !== undefined;
|
|
15
|
-
}
|
|
16
|
-
async function fetchJb1(dataRoot = { uri: '', locationType: 'UriLocation' }, baseConfig = {
|
|
17
|
-
include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf'],
|
|
18
|
-
}, baseConfigRoot = { uri: '', locationType: 'UriLocation' }) {
|
|
19
|
-
const protocol = 'uri' in dataRoot ? 'uri' : 'localPath';
|
|
20
|
-
const dataRootReg = JSON.parse(JSON.stringify(dataRoot));
|
|
21
|
-
let dataRootLocation = '';
|
|
22
|
-
if (isUriLocation(dataRoot)) {
|
|
23
|
-
dataRootLocation = dataRoot.uri;
|
|
24
|
-
}
|
|
25
|
-
if (isLocalPathLocation(dataRoot)) {
|
|
26
|
-
dataRootLocation = dataRoot.localPath;
|
|
27
|
-
}
|
|
28
|
-
if (dataRootLocation.endsWith('/')) {
|
|
29
|
-
dataRootReg[protocol] = dataRootLocation.slice(0, -1);
|
|
30
|
-
}
|
|
31
|
-
if ((isUriLocation(baseConfigRoot) && baseConfigRoot.uri) ||
|
|
32
|
-
(isLocalPathLocation(baseConfigRoot) && baseConfigRoot.localPath)) {
|
|
33
|
-
const baseProtocol = 'uri' in baseConfigRoot ? 'uri' : 'localPath';
|
|
34
|
-
let baseConfigLocation = '';
|
|
35
|
-
if (isUriLocation(baseConfigRoot)) {
|
|
36
|
-
baseConfigLocation = baseConfigRoot.uri;
|
|
37
|
-
}
|
|
38
|
-
if (isLocalPathLocation(baseConfigRoot)) {
|
|
39
|
-
baseConfigLocation = baseConfigRoot.localPath;
|
|
40
|
-
}
|
|
41
|
-
if (baseConfigLocation.endsWith('/')) {
|
|
42
|
-
baseConfigLocation = baseConfigLocation.slice(0, -1);
|
|
43
|
-
}
|
|
44
|
-
let newConfig = {};
|
|
45
|
-
for (const conf of ['jbrowse.conf', 'jbrowse_conf.json']) {
|
|
46
|
-
let fetchedConfig = null;
|
|
47
|
-
try {
|
|
48
|
-
fetchedConfig = await fetchConfigFile({
|
|
49
|
-
[baseProtocol]: `${baseConfigLocation}/${conf}`,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
console.error(`tried to access ${baseConfigLocation}/${conf}, but failed`);
|
|
54
|
-
}
|
|
55
|
-
newConfig = mergeConfigs(newConfig, fetchedConfig) || {};
|
|
56
|
-
}
|
|
57
|
-
if (dataRootReg[protocol]) {
|
|
58
|
-
newConfig.dataRoot = dataRootReg[protocol];
|
|
59
|
-
}
|
|
60
|
-
return createFinalConfig(newConfig);
|
|
61
|
-
}
|
|
62
|
-
const newConfig = (0, jb1ConfigParse_1.regularizeConf)(baseConfig, window.location.href);
|
|
63
|
-
if (dataRootReg[protocol]) {
|
|
64
|
-
newConfig.dataRoot = dataRootReg[protocol];
|
|
65
|
-
}
|
|
66
|
-
return createFinalConfig(newConfig);
|
|
67
|
-
}
|
|
68
|
-
async function createFinalConfig(baseConfig, defaults = configDefaults) {
|
|
69
|
-
const configWithDefaults = (0, util_1.deepUpdate)(structuredClone(defaults), baseConfig);
|
|
70
|
-
let finalConfig = await loadIncludes(configWithDefaults);
|
|
71
|
-
finalConfig = mergeConfigs(finalConfig, baseConfig) || finalConfig;
|
|
72
|
-
fillTemplates(finalConfig, finalConfig);
|
|
73
|
-
validateConfig(finalConfig);
|
|
74
|
-
return finalConfig;
|
|
75
|
-
}
|
|
76
|
-
async function fetchConfigFile(location) {
|
|
77
|
-
const result = await (0, io_1.openLocation)(location).readFile('utf8');
|
|
78
|
-
if (isUriLocation(location)) {
|
|
79
|
-
return parseJb1(result, location.uri);
|
|
80
|
-
}
|
|
81
|
-
if (isLocalPathLocation(location)) {
|
|
82
|
-
return parseJb1(result, location.localPath);
|
|
83
|
-
}
|
|
84
|
-
return parseJb1(result);
|
|
85
|
-
}
|
|
86
|
-
function parseJb1(config, url = '') {
|
|
87
|
-
if (config.trim().startsWith('{')) {
|
|
88
|
-
return (0, jb1ConfigParse_1.parseJB1Json)(config, url);
|
|
89
|
-
}
|
|
90
|
-
return (0, jb1ConfigParse_1.parseJB1Conf)(config, url);
|
|
91
|
-
}
|
|
92
|
-
function mergeConfigs(a, b) {
|
|
93
|
-
if (b === null) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
if (a === null) {
|
|
97
|
-
a = {};
|
|
98
|
-
}
|
|
99
|
-
for (const prop of Object.keys(b)) {
|
|
100
|
-
if (prop === 'tracks' && prop in a) {
|
|
101
|
-
const aTracks = a[prop] || [];
|
|
102
|
-
const bTracks = b[prop] || [];
|
|
103
|
-
if (Array.isArray(aTracks) && Array.isArray(bTracks)) {
|
|
104
|
-
a[prop] = mergeTrackConfigs(aTracks, bTracks);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
throw new Error(`Track config has not been properly regularized: ${aTracks} ${bTracks}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (!noRecursiveMerge(prop) &&
|
|
111
|
-
prop in a &&
|
|
112
|
-
typeof b[prop] === 'object' &&
|
|
113
|
-
typeof a[prop] === 'object') {
|
|
114
|
-
a[prop] = (0, util_1.deepUpdate)(a[prop], b[prop]);
|
|
115
|
-
}
|
|
116
|
-
else if (prop === 'dataRoot') {
|
|
117
|
-
if (a[prop] === undefined ||
|
|
118
|
-
(a[prop] === 'data' && b[prop] !== undefined)) {
|
|
119
|
-
a[prop] = b[prop];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else if (a[prop] === undefined || b[prop] !== undefined) {
|
|
123
|
-
a[prop] = b[prop];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return a;
|
|
127
|
-
}
|
|
128
|
-
function mergeTrackConfigs(a, b) {
|
|
129
|
-
if (!b.length) {
|
|
130
|
-
return a;
|
|
131
|
-
}
|
|
132
|
-
const aTracks = {};
|
|
133
|
-
for (const [i, t] of a.entries()) {
|
|
134
|
-
t.index = i;
|
|
135
|
-
aTracks[t.label] = t;
|
|
136
|
-
}
|
|
137
|
-
for (const bT of b) {
|
|
138
|
-
const aT = aTracks[bT.label];
|
|
139
|
-
if (aT) {
|
|
140
|
-
mergeConfigs(aT, bT);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
a.push(bT);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return a;
|
|
147
|
-
}
|
|
148
|
-
async function loadIncludes(inputConfig) {
|
|
149
|
-
inputConfig = structuredClone(inputConfig);
|
|
150
|
-
async function loadRecur(config, upstreamConf) {
|
|
151
|
-
const sourceUrl = config.sourceUrl || config.baseUrl;
|
|
152
|
-
if (!sourceUrl) {
|
|
153
|
-
throw new Error(`Could not determine source URL: ${JSON.stringify(config)}`);
|
|
154
|
-
}
|
|
155
|
-
const newUpstreamConf = mergeConfigs(structuredClone(upstreamConf), config);
|
|
156
|
-
if (!newUpstreamConf) {
|
|
157
|
-
throw new Error('Problem merging configs');
|
|
158
|
-
}
|
|
159
|
-
const includes = fillTemplates(regularizeIncludes(config.include || []), newUpstreamConf);
|
|
160
|
-
config.include = undefined;
|
|
161
|
-
const loads = includes.map(async (include) => {
|
|
162
|
-
include.cacheBuster = inputConfig.cacheBuster;
|
|
163
|
-
const includedData = await fetchConfigFile({
|
|
164
|
-
uri: new URL(include.url, sourceUrl).href,
|
|
165
|
-
locationType: 'UriLocation',
|
|
166
|
-
});
|
|
167
|
-
return loadRecur(includedData, newUpstreamConf);
|
|
168
|
-
});
|
|
169
|
-
const includedDataObjects = await Promise.all(loads);
|
|
170
|
-
for (const includedData of includedDataObjects) {
|
|
171
|
-
config = mergeConfigs(config, includedData) || config;
|
|
172
|
-
}
|
|
173
|
-
return config;
|
|
174
|
-
}
|
|
175
|
-
return loadRecur(inputConfig, {});
|
|
176
|
-
}
|
|
177
|
-
function regularizeIncludes(includes) {
|
|
178
|
-
if (!includes) {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
if (!Array.isArray(includes)) {
|
|
182
|
-
includes = [includes];
|
|
183
|
-
}
|
|
184
|
-
return includes.map((include) => {
|
|
185
|
-
if (typeof include === 'string') {
|
|
186
|
-
include = { url: include };
|
|
187
|
-
}
|
|
188
|
-
if (!('format' in include)) {
|
|
189
|
-
include.format = include.url.endsWith('.conf') ? 'conf' : 'JB_json';
|
|
190
|
-
}
|
|
191
|
-
if (include.format === 'JB_json' && !('version' in include)) {
|
|
192
|
-
include.version = 1;
|
|
193
|
-
}
|
|
194
|
-
return include;
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
function fillTemplates(subconfig, config) {
|
|
198
|
-
if (!subconfig) {
|
|
199
|
-
return subconfig;
|
|
200
|
-
}
|
|
201
|
-
if (Array.isArray(subconfig)) {
|
|
202
|
-
for (let i = 0; i < subconfig.length; i += 1) {
|
|
203
|
-
subconfig[i] = fillTemplates(subconfig[i], config);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
else if (typeof subconfig === 'object') {
|
|
207
|
-
const sub = subconfig;
|
|
208
|
-
for (const name of Object.keys(sub)) {
|
|
209
|
-
sub[name] = fillTemplates(sub[name], config);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else if (typeof subconfig === 'string') {
|
|
213
|
-
return (0, util_1.fillTemplate)(subconfig, config);
|
|
214
|
-
}
|
|
215
|
-
return subconfig;
|
|
216
|
-
}
|
|
217
|
-
function noRecursiveMerge(propName) {
|
|
218
|
-
return propName === 'datasets';
|
|
219
|
-
}
|
|
220
|
-
const configDefaults = {
|
|
221
|
-
tracks: [],
|
|
222
|
-
containerID: 'GenomeBrowser',
|
|
223
|
-
dataRoot: 'data',
|
|
224
|
-
show_tracklist: true,
|
|
225
|
-
show_nav: true,
|
|
226
|
-
show_menu: true,
|
|
227
|
-
show_overview: true,
|
|
228
|
-
show_fullviewlink: true,
|
|
229
|
-
update_browser_title: true,
|
|
230
|
-
updateBrowserURL: true,
|
|
231
|
-
refSeqs: '{dataRoot}/seq/refSeqs.json',
|
|
232
|
-
include: ['jbrowse.conf', 'jbrowse_conf.json'],
|
|
233
|
-
nameUrl: '{dataRoot}/names/root.json',
|
|
234
|
-
datasets: {
|
|
235
|
-
_DEFAULT_EXAMPLES: true,
|
|
236
|
-
volvox: { url: '?data=sample_data/json/volvox', name: 'Volvox Example' },
|
|
237
|
-
modencode: {
|
|
238
|
-
url: '?data=sample_data/json/modencode',
|
|
239
|
-
name: 'MODEncode Example',
|
|
240
|
-
},
|
|
241
|
-
yeast: { url: '?data=sample_data/json/yeast', name: 'Yeast Example' },
|
|
242
|
-
},
|
|
243
|
-
highlightSearchedRegions: false,
|
|
244
|
-
highResolutionMode: 'auto',
|
|
245
|
-
};
|
|
246
|
-
function validateConfig(config) {
|
|
247
|
-
if (!config.tracks) {
|
|
248
|
-
config.tracks = [];
|
|
249
|
-
}
|
|
250
|
-
if (!config.baseUrl) {
|
|
251
|
-
throw new Error('Must provide a `baseUrl` in configuration');
|
|
252
|
-
}
|
|
253
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Config } from './types';
|
|
2
|
-
export declare function parseJB1Json(config: Config | string, url: string): Config;
|
|
3
|
-
export declare function parseJB1Conf(config: string, url: string): Config;
|
|
4
|
-
export declare function regularizeConf(conf: Config, url: string): Config;
|