@jbrowse/plugin-legacy-jbrowse 2.6.1 → 2.6.2

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 (97) hide show
  1. package/dist/GuessNCList/index.js +0 -1
  2. package/dist/JBrowse1Connection/configSchema.js +0 -1
  3. package/dist/JBrowse1Connection/index.js +0 -1
  4. package/dist/JBrowse1Connection/jb1ConfigLoad.js +0 -1
  5. package/dist/JBrowse1Connection/jb1ConfigParse.js +0 -1
  6. package/dist/JBrowse1Connection/jb1ToJb2.js +0 -1
  7. package/dist/JBrowse1Connection/model.js +0 -1
  8. package/dist/JBrowse1Connection/types.js +0 -1
  9. package/dist/JBrowse1Connection/util.js +0 -1
  10. package/dist/JBrowse1TextSearchAdapter/HttpMap.js +0 -1
  11. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +0 -1
  12. package/dist/JBrowse1TextSearchAdapter/configSchema.js +0 -1
  13. package/dist/JBrowse1TextSearchAdapter/index.js +0 -1
  14. package/dist/NCListAdapter/NCListAdapter.js +0 -1
  15. package/dist/NCListAdapter/NCListFeature.js +0 -1
  16. package/dist/NCListAdapter/configSchema.js +0 -1
  17. package/dist/NCListAdapter/index.js +0 -1
  18. package/dist/index.js +0 -1
  19. package/esm/GuessNCList/index.js +0 -1
  20. package/esm/JBrowse1Connection/configSchema.js +0 -1
  21. package/esm/JBrowse1Connection/index.js +0 -1
  22. package/esm/JBrowse1Connection/jb1ConfigLoad.js +0 -1
  23. package/esm/JBrowse1Connection/jb1ConfigParse.js +0 -1
  24. package/esm/JBrowse1Connection/jb1ToJb2.js +0 -1
  25. package/esm/JBrowse1Connection/model.js +0 -1
  26. package/esm/JBrowse1Connection/types.js +0 -1
  27. package/esm/JBrowse1Connection/util.js +0 -1
  28. package/esm/JBrowse1TextSearchAdapter/HttpMap.js +0 -1
  29. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js +0 -1
  30. package/esm/JBrowse1TextSearchAdapter/configSchema.js +0 -1
  31. package/esm/JBrowse1TextSearchAdapter/index.js +0 -1
  32. package/esm/NCListAdapter/NCListAdapter.js +0 -1
  33. package/esm/NCListAdapter/NCListFeature.js +0 -1
  34. package/esm/NCListAdapter/configSchema.js +0 -1
  35. package/esm/NCListAdapter/index.js +0 -1
  36. package/esm/index.js +0 -1
  37. package/package.json +3 -4
  38. package/dist/GuessNCList/index.js.map +0 -1
  39. package/dist/JBrowse1Connection/configSchema.js.map +0 -1
  40. package/dist/JBrowse1Connection/index.js.map +0 -1
  41. package/dist/JBrowse1Connection/jb1ConfigLoad.js.map +0 -1
  42. package/dist/JBrowse1Connection/jb1ConfigParse.js.map +0 -1
  43. package/dist/JBrowse1Connection/jb1ToJb2.js.map +0 -1
  44. package/dist/JBrowse1Connection/model.js.map +0 -1
  45. package/dist/JBrowse1Connection/types.js.map +0 -1
  46. package/dist/JBrowse1Connection/util.js.map +0 -1
  47. package/dist/JBrowse1TextSearchAdapter/HttpMap.js.map +0 -1
  48. package/dist/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js.map +0 -1
  49. package/dist/JBrowse1TextSearchAdapter/configSchema.js.map +0 -1
  50. package/dist/JBrowse1TextSearchAdapter/index.js.map +0 -1
  51. package/dist/NCListAdapter/NCListAdapter.js.map +0 -1
  52. package/dist/NCListAdapter/NCListFeature.js.map +0 -1
  53. package/dist/NCListAdapter/configSchema.js.map +0 -1
  54. package/dist/NCListAdapter/index.js.map +0 -1
  55. package/dist/index.js.map +0 -1
  56. package/esm/GuessNCList/index.js.map +0 -1
  57. package/esm/JBrowse1Connection/configSchema.js.map +0 -1
  58. package/esm/JBrowse1Connection/index.js.map +0 -1
  59. package/esm/JBrowse1Connection/jb1ConfigLoad.js.map +0 -1
  60. package/esm/JBrowse1Connection/jb1ConfigParse.js.map +0 -1
  61. package/esm/JBrowse1Connection/jb1ToJb2.js.map +0 -1
  62. package/esm/JBrowse1Connection/model.js.map +0 -1
  63. package/esm/JBrowse1Connection/types.js.map +0 -1
  64. package/esm/JBrowse1Connection/util.js.map +0 -1
  65. package/esm/JBrowse1TextSearchAdapter/HttpMap.js.map +0 -1
  66. package/esm/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.js.map +0 -1
  67. package/esm/JBrowse1TextSearchAdapter/configSchema.js.map +0 -1
  68. package/esm/JBrowse1TextSearchAdapter/index.js.map +0 -1
  69. package/esm/NCListAdapter/NCListAdapter.js.map +0 -1
  70. package/esm/NCListAdapter/NCListFeature.js.map +0 -1
  71. package/esm/NCListAdapter/configSchema.js.map +0 -1
  72. package/esm/NCListAdapter/index.js.map +0 -1
  73. package/esm/index.js.map +0 -1
  74. package/src/GuessNCList/index.ts +0 -27
  75. package/src/JBrowse1Connection/configSchema.ts +0 -42
  76. package/src/JBrowse1Connection/index.ts +0 -20
  77. package/src/JBrowse1Connection/jb1ConfigLoad.ts +0 -342
  78. package/src/JBrowse1Connection/jb1ConfigParse.ts +0 -423
  79. package/src/JBrowse1Connection/jb1ToJb2.ts +0 -529
  80. package/src/JBrowse1Connection/model.tsx +0 -69
  81. package/src/JBrowse1Connection/types.ts +0 -105
  82. package/src/JBrowse1Connection/util.ts +0 -149
  83. package/src/JBrowse1TextSearchAdapter/HttpMap.test.ts +0 -49
  84. package/src/JBrowse1TextSearchAdapter/HttpMap.ts +0 -100
  85. package/src/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.test.ts +0 -101
  86. package/src/JBrowse1TextSearchAdapter/JBrowse1TextSearchAdapter.ts +0 -100
  87. package/src/JBrowse1TextSearchAdapter/configSchema.ts +0 -44
  88. package/src/JBrowse1TextSearchAdapter/index.ts +0 -18
  89. package/src/NCListAdapter/NCListAdapter.test.ts +0 -58
  90. package/src/NCListAdapter/NCListAdapter.ts +0 -92
  91. package/src/NCListAdapter/NCListFeature.ts +0 -94
  92. package/src/NCListAdapter/__snapshots__/NCListAdapter.test.ts.snap +0 -30671
  93. package/src/NCListAdapter/configSchema.ts +0 -32
  94. package/src/NCListAdapter/index.ts +0 -16
  95. package/src/__snapshots__/index.test.ts.snap +0 -16
  96. package/src/index.test.ts +0 -35
  97. package/src/index.ts +0 -17
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAA;AAEzC,OAAO,cAAc,MAAM,iBAAiB,CAAA;AAC5C,OAAO,0BAA0B,MAAM,6BAA6B,CAAA;AACpE,OAAO,mBAAmB,MAAM,sBAAsB,CAAA;AACtD,OAAO,YAAY,MAAM,eAAe,CAAA;AAExC,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,MAAM;IAAvD;;QACE,SAAI,GAAG,qBAAqB,CAAA;IAQ9B,CAAC;IANC,OAAO,CAAC,aAA4B;QAClC,cAAc,CAAC,aAAa,CAAC,CAAA;QAC7B,YAAY,CAAC,aAAa,CAAC,CAAA;QAC3B,0BAA0B,CAAC,aAAa,CAAC,CAAA;QACzC,mBAAmB,CAAC,aAAa,CAAC,CAAA;IACpC,CAAC;CACF"}
@@ -1,27 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import { AdapterGuesser, getFileName } from '@jbrowse/core/util/tracks'
3
- import { FileLocation } from '@jbrowse/core/util/types'
4
-
5
- export default (pluginManager: PluginManager) => {
6
- pluginManager.addToExtensionPoint(
7
- 'Core-guessAdapterForLocation',
8
- (adapterGuesser: AdapterGuesser) => {
9
- return (
10
- file: FileLocation,
11
- index?: FileLocation,
12
- adapterHint?: string,
13
- ) => {
14
- const regexGuess = /trackData.jsonz?$/i
15
- const adapterName = 'NCListAdapter'
16
- const fileName = getFileName(file)
17
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
18
- return {
19
- type: adapterName,
20
- rootUrlTemplate: file,
21
- }
22
- }
23
- return adapterGuesser(file, index, adapterHint)
24
- }
25
- },
26
- )
27
- }
@@ -1,42 +0,0 @@
1
- import { baseConnectionConfig } from '@jbrowse/core/pluggableElementTypes/models'
2
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
3
-
4
- /**
5
- * #config JBrowse1Connection
6
- */
7
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
8
-
9
- const JBrowse1Connection = ConfigurationSchema(
10
- 'JBrowse1Connection',
11
- {
12
- /**
13
- * #slot
14
- */
15
- dataDirLocation: {
16
- type: 'fileLocation',
17
- defaultValue: {
18
- uri: 'http://mysite.com/jbrowse/data/',
19
- locationType: 'UriLocation',
20
- },
21
- description:
22
- 'the location of the JBrowse 1 data directory, often something like http://mysite.com/jbrowse/data/',
23
- },
24
- /**
25
- * #slot
26
- */
27
- assemblyNames: {
28
- description:
29
- 'name of the assembly the connection belongs to, should be a single entry',
30
- type: 'stringArray',
31
- defaultValue: [],
32
- },
33
- },
34
- {
35
- /**
36
- * #baseConfiguration
37
- */
38
- baseConfiguration: baseConnectionConfig,
39
- },
40
- )
41
-
42
- export default JBrowse1Connection
@@ -1,20 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import ConnectionType from '@jbrowse/core/pluggableElementTypes/ConnectionType'
3
-
4
- // locals
5
- import modelFactory from './model'
6
- import configSchema from './configSchema'
7
-
8
- export default (pluginManager: PluginManager) => {
9
- pluginManager.addConnectionType(
10
- () =>
11
- new ConnectionType({
12
- name: 'JBrowse1Connection',
13
- configSchema,
14
- stateModel: modelFactory(pluginManager),
15
- displayName: 'JBrowse 1 Data',
16
- description: 'A JBrowse 1 data directory',
17
- url: '//jbrowse.org/',
18
- }),
19
- )
20
- }
@@ -1,342 +0,0 @@
1
- import { openLocation } from '@jbrowse/core/util/io'
2
- import { parseJB1Json, parseJB1Conf, regularizeConf } from './jb1ConfigParse'
3
- import { clone, deepUpdate, fillTemplate } from './util'
4
- import {
5
- JBLocation,
6
- UriLocation,
7
- LocalPathLocation,
8
- Config,
9
- Track,
10
- Include,
11
- } from './types'
12
-
13
- function isUriLocation(location: JBLocation): location is UriLocation {
14
- return (location as UriLocation).uri !== undefined
15
- }
16
-
17
- function isLocalPathLocation(
18
- location: JBLocation,
19
- ): location is LocalPathLocation {
20
- return (location as LocalPathLocation).localPath !== undefined
21
- }
22
-
23
- export async function fetchJb1(
24
- // eslint-disable-next-line unicorn/no-object-as-default-parameter
25
- dataRoot: JBLocation = { uri: '', locationType: 'UriLocation' },
26
- // eslint-disable-next-line unicorn/no-object-as-default-parameter
27
- baseConfig: Config = {
28
- include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf'],
29
- },
30
- // eslint-disable-next-line unicorn/no-object-as-default-parameter
31
- baseConfigRoot: JBLocation = { uri: '', locationType: 'UriLocation' },
32
- ): Promise<Config> {
33
- const protocol = 'uri' in dataRoot ? 'uri' : 'localPath'
34
- const dataRootReg = JSON.parse(JSON.stringify(dataRoot))
35
- let dataRootLocation = ''
36
- if (isUriLocation(dataRoot)) {
37
- dataRootLocation = dataRoot.uri
38
- }
39
- if (isLocalPathLocation(dataRoot)) {
40
- dataRootLocation = dataRoot.localPath
41
- }
42
- if (dataRootLocation.endsWith('/')) {
43
- dataRootReg[protocol] = dataRootLocation.slice(0, -1)
44
- }
45
- if (
46
- (isUriLocation(baseConfigRoot) && baseConfigRoot.uri) ||
47
- (isLocalPathLocation(baseConfigRoot) && baseConfigRoot.localPath)
48
- ) {
49
- const baseProtocol = 'uri' in baseConfigRoot ? 'uri' : 'localPath'
50
- let baseConfigLocation = ''
51
- if (isUriLocation(baseConfigRoot)) {
52
- baseConfigLocation = baseConfigRoot.uri
53
- }
54
- if (isLocalPathLocation(baseConfigRoot)) {
55
- baseConfigLocation = baseConfigRoot.localPath
56
- }
57
- if (baseConfigLocation.endsWith('/')) {
58
- baseConfigLocation = baseConfigLocation.slice(0, -1)
59
- }
60
- let newConfig: Config = {}
61
- for (const conf of ['jbrowse.conf', 'jbrowse_conf.json']) {
62
- let fetchedConfig = null
63
- try {
64
- // @ts-expect-error
65
- fetchedConfig = await fetchConfigFile({
66
- [baseProtocol]: `${baseConfigLocation}/${conf}`,
67
- })
68
- } catch (error) {
69
- console.error(
70
- `tried to access ${baseConfigLocation}/${conf}, but failed`,
71
- )
72
- }
73
- newConfig = mergeConfigs(newConfig, fetchedConfig) || {}
74
- }
75
- if (dataRootReg[protocol]) {
76
- newConfig.dataRoot = dataRootReg[protocol]
77
- }
78
- return createFinalConfig(newConfig)
79
- }
80
- const newConfig = regularizeConf(baseConfig, window.location.href)
81
- if (dataRootReg[protocol]) {
82
- newConfig.dataRoot = dataRootReg[protocol]
83
- }
84
- return createFinalConfig(newConfig)
85
- }
86
-
87
- export async function createFinalConfig(
88
- baseConfig: Config,
89
- defaults = configDefaults,
90
- ): Promise<Config> {
91
- const configWithDefaults = deepUpdate(clone(defaults), baseConfig)
92
- let finalConfig = await loadIncludes(configWithDefaults)
93
- finalConfig = mergeConfigs(finalConfig, baseConfig) || finalConfig
94
- fillTemplates(finalConfig, finalConfig)
95
- validateConfig(finalConfig)
96
- return finalConfig
97
- }
98
-
99
- export async function fetchConfigFile(location: JBLocation): Promise<Config> {
100
- const result = await openLocation(location).readFile('utf8')
101
- if (isUriLocation(location)) {
102
- return parseJb1(result, location.uri)
103
- }
104
- if (isLocalPathLocation(location)) {
105
- return parseJb1(result, location.localPath)
106
- }
107
- return parseJb1(result)
108
- }
109
-
110
- export function parseJb1(config: string, url = ''): Config {
111
- if (config.trim().startsWith('{')) {
112
- return parseJB1Json(config, url)
113
- }
114
- return parseJB1Conf(config, url)
115
- }
116
-
117
- /**
118
- * Merges config object b into a. Properties in b override those in a.
119
- */
120
- function mergeConfigs(a: Config | null, b: Config | null): Config | null {
121
- if (b === null) {
122
- return null
123
- }
124
-
125
- if (a === null) {
126
- a = {}
127
- }
128
-
129
- for (const prop of Object.keys(b)) {
130
- if (prop === 'tracks' && prop in a) {
131
- const aTracks = a[prop] || []
132
- const bTracks = b[prop] || []
133
- if (Array.isArray(aTracks) && Array.isArray(bTracks)) {
134
- a[prop] = mergeTrackConfigs(aTracks || [], bTracks || [])
135
- } else {
136
- throw new Error(
137
- `Track config has not been properly regularized: ${aTracks} ${bTracks}`,
138
- )
139
- }
140
- } else if (
141
- !noRecursiveMerge(prop) &&
142
- prop in a &&
143
- // @ts-expect-error
144
- typeof b[prop] === 'object' &&
145
- // @ts-expect-error
146
- typeof a[prop] === 'object'
147
- ) {
148
- // @ts-expect-error
149
- a[prop] = deepUpdate(a[prop], b[prop])
150
- } else if (prop === 'dataRoot') {
151
- if (
152
- a[prop] === undefined ||
153
- (a[prop] === 'data' && b[prop] !== undefined)
154
- ) {
155
- a[prop] = b[prop]
156
- }
157
- // @ts-expect-error
158
- } else if (a[prop] === undefined || b[prop] !== undefined) {
159
- // @ts-expect-error
160
- a[prop] = b[prop]
161
- }
162
- }
163
- return a
164
- }
165
-
166
- /**
167
- * Special-case merging of two `tracks` configuration arrays.
168
- */
169
- function mergeTrackConfigs(a: Track[], b: Track[]): Track[] {
170
- if (!b.length) {
171
- return a
172
- }
173
-
174
- // index the tracks in `a` by track label
175
- const aTracks: Record<string, Track> = {}
176
- a.forEach((t, i): void => {
177
- t.index = i
178
- aTracks[t.label] = t
179
- })
180
-
181
- b.forEach((bT): void => {
182
- const aT = aTracks[bT.label]
183
- if (aT) {
184
- mergeConfigs(aT, bT)
185
- } else {
186
- a.push(bT)
187
- }
188
- })
189
-
190
- return a
191
- }
192
-
193
- /**
194
- * Recursively fetch, parse, and merge all the includes in the given config
195
- * object. Calls the callback with the resulting configuration when finished.
196
- * @param inputConfig - Config to load includes into
197
- */
198
- async function loadIncludes(inputConfig: Config): Promise<Config> {
199
- inputConfig = clone(inputConfig)
200
-
201
- async function loadRecur(
202
- config: Config,
203
- upstreamConf: Config,
204
- ): Promise<Config> {
205
- const sourceUrl = config.sourceUrl || config.baseUrl
206
- if (!sourceUrl) {
207
- throw new Error(
208
- `Could not determine source URL: ${JSON.stringify(config)}`,
209
- )
210
- }
211
- const newUpstreamConf = mergeConfigs(clone(upstreamConf), config)
212
- if (!newUpstreamConf) {
213
- throw new Error('Problem merging configs')
214
- }
215
- const includes = fillTemplates(
216
- regularizeIncludes(config.include || []),
217
- newUpstreamConf,
218
- )
219
- delete config.include
220
-
221
- const loads = includes.map(async (include): Promise<Config> => {
222
- include.cacheBuster = inputConfig.cacheBuster
223
- const includedData = await fetchConfigFile({
224
- uri: new URL(include.url, sourceUrl).href,
225
- locationType: 'UriLocation',
226
- })
227
- return loadRecur(includedData, newUpstreamConf)
228
- })
229
- const includedDataObjects = await Promise.all(loads)
230
- includedDataObjects.forEach((includedData): void => {
231
- config = mergeConfigs(config, includedData) || config
232
- })
233
- return config
234
- }
235
-
236
- return loadRecur(inputConfig, {})
237
- }
238
-
239
- function regularizeIncludes(
240
- includes: Include | string | (Include | string)[] | null,
241
- ): Include[] {
242
- if (!includes) {
243
- return []
244
- }
245
-
246
- // coerce include to an array
247
- if (!Array.isArray(includes)) {
248
- includes = [includes]
249
- }
250
-
251
- return includes.map((include): Include => {
252
- // coerce bare strings in the includes to URLs
253
- if (typeof include === 'string') {
254
- include = { url: include }
255
- }
256
-
257
- // set defaults for format and version
258
- if (!('format' in include)) {
259
- include.format = include.url.endsWith('.conf') ? 'conf' : 'JB_json'
260
- }
261
- if (include.format === 'JB_json' && !('version' in include)) {
262
- include.version = 1
263
- }
264
- return include
265
- })
266
- }
267
-
268
- // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unnecessary-type-constraint
269
- function fillTemplates<T extends any>(subconfig: T, config: Config): T {
270
- if (!subconfig) {
271
- return subconfig
272
- }
273
- if (Array.isArray(subconfig)) {
274
- for (let i = 0; i < subconfig.length; i += 1) {
275
- subconfig[i] = fillTemplates(subconfig[i], config)
276
- }
277
- } else if (typeof subconfig === 'object') {
278
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
- const sub = subconfig as Record<string, any>
280
- for (const name of Object.keys(sub)) {
281
- sub[name] = fillTemplates(sub[name], config)
282
- }
283
- } else if (typeof subconfig === 'string') {
284
- // @ts-expect-error
285
- return fillTemplate(subconfig, config)
286
- }
287
-
288
- return subconfig
289
- }
290
-
291
- /**
292
- * list of config properties that should not be recursively merged
293
- * @param propName - name of config property
294
- */
295
- function noRecursiveMerge(propName: string): boolean {
296
- return propName === 'datasets'
297
- }
298
-
299
- const configDefaults = {
300
- tracks: [],
301
-
302
- containerID: 'GenomeBrowser',
303
- dataRoot: 'data',
304
- show_tracklist: true,
305
- show_nav: true,
306
- show_menu: true,
307
- show_overview: true,
308
- show_fullviewlink: true,
309
- update_browser_title: true,
310
- updateBrowserURL: true,
311
-
312
- refSeqs: '{dataRoot}/seq/refSeqs.json',
313
- include: ['jbrowse.conf', 'jbrowse_conf.json'],
314
- nameUrl: '{dataRoot}/names/root.json',
315
-
316
- datasets: {
317
- _DEFAULT_EXAMPLES: true,
318
- volvox: { url: '?data=sample_data/json/volvox', name: 'Volvox Example' },
319
- modencode: {
320
- url: '?data=sample_data/json/modencode',
321
- name: 'MODEncode Example',
322
- },
323
- yeast: { url: '?data=sample_data/json/yeast', name: 'Yeast Example' },
324
- },
325
-
326
- highlightSearchedRegions: false,
327
- highResolutionMode: 'auto',
328
- }
329
-
330
- /**
331
- * Examine the loaded and merged configuration for errors. Throws
332
- * exceptions if it finds anything amiss.
333
- * @returns nothing meaningful
334
- */
335
- function validateConfig(config: Config): void {
336
- if (!config.tracks) {
337
- config.tracks = []
338
- }
339
- if (!config.baseUrl) {
340
- throw new Error('Must provide a `baseUrl` in configuration')
341
- }
342
- }