@jbrowse/plugin-legacy-jbrowse 3.6.5 → 4.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.
Files changed (62) hide show
  1. package/esm/JBrowse1Connection/configSchema.d.ts +3 -3
  2. package/esm/JBrowse1Connection/get-value.d.ts +10 -0
  3. package/esm/JBrowse1Connection/get-value.js +84 -0
  4. package/esm/JBrowse1Connection/index.js +2 -2
  5. package/esm/JBrowse1Connection/jb1ConfigLoad.d.ts +1 -1
  6. package/esm/JBrowse1Connection/jb1ConfigLoad.js +2 -2
  7. package/esm/JBrowse1Connection/jb1ConfigParse.d.ts +1 -1
  8. package/esm/JBrowse1Connection/jb1ConfigParse.js +12 -10
  9. package/esm/JBrowse1Connection/jb1ToJb2.d.ts +2 -3
  10. package/esm/JBrowse1Connection/jb1ToJb2.js +43 -45
  11. package/esm/JBrowse1Connection/model.d.ts +16 -24
  12. package/esm/JBrowse1Connection/model.js +8 -14
  13. package/esm/JBrowse1Connection/util.d.ts +1 -1
  14. package/esm/JBrowse1Connection/util.js +13 -3
  15. package/esm/JBrowse1TextSearchAdapter/HttpMap.js +16 -1
  16. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +1 -1
  17. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +3 -1
  18. package/esm/JBrowse1TextSearchAdapter/configSchema.d.ts +2 -2
  19. package/esm/JBrowse1TextSearchAdapter/index.js +2 -2
  20. package/esm/NCListAdapter/NCListAdapter.d.ts +1 -1
  21. package/esm/NCListAdapter/NCListAdapter.js +6 -5
  22. package/esm/NCListAdapter/NCListFeature.js +3 -0
  23. package/esm/NCListAdapter/configSchema.d.ts +2 -2
  24. package/esm/NCListAdapter/index.js +2 -2
  25. package/esm/index.js +5 -8
  26. package/package.json +25 -33
  27. package/dist/GuessNCList/index.d.ts +0 -2
  28. package/dist/GuessNCList/index.js +0 -18
  29. package/dist/JBrowse1Connection/configSchema.d.ts +0 -27
  30. package/dist/JBrowse1Connection/configSchema.js +0 -23
  31. package/dist/JBrowse1Connection/index.d.ts +0 -2
  32. package/dist/JBrowse1Connection/index.js +0 -19
  33. package/dist/JBrowse1Connection/jb1ConfigLoad.d.ts +0 -36
  34. package/dist/JBrowse1Connection/jb1ConfigLoad.js +0 -253
  35. package/dist/JBrowse1Connection/jb1ConfigParse.d.ts +0 -4
  36. package/dist/JBrowse1Connection/jb1ConfigParse.js +0 -341
  37. package/dist/JBrowse1Connection/jb1ToJb2.d.ts +0 -49
  38. package/dist/JBrowse1Connection/jb1ToJb2.js +0 -408
  39. package/dist/JBrowse1Connection/model.d.ts +0 -75
  40. package/dist/JBrowse1Connection/model.js +0 -82
  41. package/dist/JBrowse1Connection/types.d.ts +0 -91
  42. package/dist/JBrowse1Connection/types.js +0 -2
  43. package/dist/JBrowse1Connection/util.d.ts +0 -8
  44. package/dist/JBrowse1Connection/util.js +0 -86
  45. package/dist/JBrowse1TextSearchAdapter/HttpMap.d.ts +0 -19
  46. package/dist/JBrowse1TextSearchAdapter/HttpMap.js +0 -65
  47. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.d.ts +0 -28
  48. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +0 -58
  49. package/dist/JBrowse1TextSearchAdapter/configSchema.d.ts +0 -21
  50. package/dist/JBrowse1TextSearchAdapter/configSchema.js +0 -24
  51. package/dist/JBrowse1TextSearchAdapter/index.d.ts +0 -2
  52. package/dist/JBrowse1TextSearchAdapter/index.js +0 -49
  53. package/dist/NCListAdapter/NCListAdapter.d.ts +0 -17
  54. package/dist/NCListAdapter/NCListAdapter.js +0 -48
  55. package/dist/NCListAdapter/NCListFeature.d.ts +0 -16
  56. package/dist/NCListAdapter/NCListFeature.js +0 -58
  57. package/dist/NCListAdapter/configSchema.d.ts +0 -15
  58. package/dist/NCListAdapter/configSchema.js +0 -21
  59. package/dist/NCListAdapter/index.d.ts +0 -2
  60. package/dist/NCListAdapter/index.js +0 -52
  61. package/dist/index.d.ts +0 -6
  62. package/dist/index.js +0 -23
@@ -3,8 +3,10 @@ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter'
3
3
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
4
4
  import { checkStopToken } from '@jbrowse/core/util/stopToken';
5
5
  import { RemoteFile } from 'generic-filehandle2';
6
- import NCListFeature from './NCListFeature';
6
+ import NCListFeature from "./NCListFeature.js";
7
7
  export default class NCListAdapter extends BaseFeatureDataAdapter {
8
+ nclist;
9
+ configRefNames;
8
10
  constructor(config, getSubAdapter, pluginManager) {
9
11
  super(config, getSubAdapter, pluginManager);
10
12
  const refNames = this.getConf('refNames');
@@ -13,9 +15,9 @@ export default class NCListAdapter extends BaseFeatureDataAdapter {
13
15
  this.nclist = new NCListStore({
14
16
  baseUrl: '',
15
17
  urlTemplate: rootUrlTemplate.uri,
16
- readFile: (url) => new RemoteFile(String(rootUrlTemplate.baseUri
18
+ readFile: (url) => new RemoteFile(rootUrlTemplate.baseUri
17
19
  ? new URL(url, rootUrlTemplate.baseUri).toString()
18
- : url)).readFile(),
20
+ : url).readFile(),
19
21
  });
20
22
  }
21
23
  getFeatures(region, opts = {}) {
@@ -32,9 +34,8 @@ export default class NCListAdapter extends BaseFeatureDataAdapter {
32
34
  return new NCListFeature(ncFeature, undefined, `${this.id}-${ncFeature.id()}`);
33
35
  }
34
36
  async hasDataForRefName(refName) {
35
- var _a;
36
37
  const root = await this.nclist.getDataRoot(refName);
37
- return !!((_a = root === null || root === void 0 ? void 0 : root.stats) === null || _a === void 0 ? void 0 : _a.featureCount);
38
+ return !!root?.stats?.featureCount;
38
39
  }
39
40
  async getRefNames() {
40
41
  return this.configRefNames || [];
@@ -1,6 +1,9 @@
1
1
  const jb2ToJb1 = { refName: 'seq_id' };
2
2
  const jb1ToJb2 = { seq_id: 'refName' };
3
3
  export default class NCListFeature {
4
+ ncFeature;
5
+ parentHandle;
6
+ uniqueId;
4
7
  constructor(ncFeature, parent, id) {
5
8
  this.ncFeature = ncFeature;
6
9
  this.uniqueId = id || ncFeature.id();
@@ -1,4 +1,4 @@
1
- declare const NCListAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
1
+ declare const NCListAdapter: import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaType<{
2
2
  rootUrlTemplate: {
3
3
  type: string;
4
4
  defaultValue: {
@@ -11,5 +11,5 @@ declare const NCListAdapter: import("@jbrowse/core/configuration/configurationSc
11
11
  defaultValue: never[];
12
12
  description: string;
13
13
  };
14
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
14
+ }, import("node_modules/@jbrowse/core/src/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
15
15
  export default NCListAdapter;
@@ -1,5 +1,5 @@
1
1
  import { AdapterType } from '@jbrowse/core/pluggableElementTypes';
2
- import configSchema from './configSchema';
2
+ import configSchema from "./configSchema.js";
3
3
  export default function NCListAdapterF(pluginManager) {
4
4
  pluginManager.addAdapterType(() => new AdapterType({
5
5
  name: 'NCListAdapter',
@@ -8,6 +8,6 @@ export default function NCListAdapterF(pluginManager) {
8
8
  adapterMetadata: {
9
9
  category: 'Uncommon',
10
10
  },
11
- getAdapterClass: () => import('./NCListAdapter').then(r => r.default),
11
+ getAdapterClass: () => import("./NCListAdapter.js").then(r => r.default),
12
12
  }));
13
13
  }
package/esm/index.js CHANGED
@@ -1,13 +1,10 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import GuessNCListF from './GuessNCList';
3
- import JBrowse1ConnectionF from './JBrowse1Connection';
4
- import JBrowse1TextSearchAdapterF from './JBrowse1TextSearchAdapter';
5
- import NCListAdapterF from './NCListAdapter';
2
+ import GuessNCListF from "./GuessNCList/index.js";
3
+ import JBrowse1ConnectionF from "./JBrowse1Connection/index.js";
4
+ import JBrowse1TextSearchAdapterF from "./JBrowse1TextSearchAdapter/index.js";
5
+ import NCListAdapterF from "./NCListAdapter/index.js";
6
6
  export default class LegacyJBrowsePlugin extends Plugin {
7
- constructor() {
8
- super(...arguments);
9
- this.name = 'LegacyJBrowsePlugin';
10
- }
7
+ name = 'LegacyJBrowsePlugin';
11
8
  install(pluginManager) {
12
9
  NCListAdapterF(pluginManager);
13
10
  GuessNCListF(pluginManager);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-legacy-jbrowse",
3
- "version": "3.6.5",
3
+ "version": "4.0.0",
4
4
  "description": "JBrowse 2 plugin for connecting to and reading JBrowse 1 data",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -15,43 +15,35 @@
15
15
  "directory": "plugins/legacy-jbrowse"
16
16
  },
17
17
  "author": "JBrowse Team",
18
- "distMain": "dist/index.js",
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.0",
40
- "@jbrowse/core": "^3.6.5",
41
- "crc": "^4.0.0",
42
- "generic-filehandle2": "^2.0.1",
43
- "get-value": "^3.0.0",
44
- "mobx": "^6.0.0",
45
- "mobx-react": "^9.0.0",
46
- "mobx-state-tree": "^5.0.0",
47
- "rxjs": "^7.0.0",
48
- "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.0"
49
30
  },
50
31
  "publishConfig": {
51
32
  "access": "public"
52
33
  },
53
- "distModule": "esm/index.js",
54
- "srcModule": "src/index.ts",
55
- "module": "esm/index.js",
56
- "gitHead": "354d0a87b757b4d84f824b47507662f6f3a1693f"
57
- }
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,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function GuessNCListF(pluginManager: PluginManager): void;
@@ -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,2 +0,0 @@
1
- import type PluginManager from '@jbrowse/core/PluginManager';
2
- export default function JBrowse1ConnectionF(pluginManager: PluginManager): void;
@@ -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;