@jbrowse/core 2.3.2 → 2.3.4

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/PluginLoader.d.ts CHANGED
@@ -40,24 +40,23 @@ export interface PluginRecord {
40
40
  export interface LoadedPlugin {
41
41
  default: PluginConstructor;
42
42
  }
43
- export declare function getWindowPath(windowHref: string): string;
44
43
  export default class PluginLoader {
45
44
  definitions: PluginDefinition[];
46
- fetchESM?: (url: string) => Promise<unknown>;
45
+ fetchESM?: (url: string) => Promise<LoadedPlugin>;
47
46
  fetchCJS?: (url: string) => Promise<LoadedPlugin>;
48
47
  constructor(defs?: PluginDefinition[], args?: {
49
- fetchESM?: (url: string) => Promise<unknown>;
48
+ fetchESM?: (url: string) => Promise<LoadedPlugin>;
50
49
  fetchCJS?: (url: string) => Promise<LoadedPlugin>;
51
50
  });
52
51
  loadScript(scriptUrl: string): Promise<void>;
53
- loadCJSPlugin(def: CJSPluginDefinition, windowHref: string): Promise<LoadedPlugin>;
54
- loadESMPlugin(def: ESMPluginDefinition, windowHref: string): Promise<LoadedPlugin>;
55
- loadUMDPlugin(def: UMDPluginDefinition | LegacyUMDPluginDefinition, windowHref: string): Promise<{
52
+ loadCJSPlugin(def: CJSPluginDefinition, baseUri?: string): Promise<LoadedPlugin>;
53
+ loadESMPlugin(def: ESMPluginDefinition, baseUri?: string): Promise<LoadedPlugin>;
54
+ loadUMDPlugin(def: UMDPluginDefinition | LegacyUMDPluginDefinition, baseUri?: string): Promise<{
56
55
  default: PluginConstructor;
57
56
  }>;
58
- loadPlugin(def: PluginDefinition, windowHref: string): Promise<PluginConstructor>;
57
+ loadPlugin(def: PluginDefinition, baseUri?: string): Promise<PluginConstructor>;
59
58
  installGlobalReExports(target: WindowOrWorkerGlobalScope): void;
60
- load(windowHref?: string): Promise<{
59
+ load(baseUri?: string): Promise<{
61
60
  plugin: PluginConstructor;
62
61
  definition: PluginDefinition;
63
62
  }[]>;
package/PluginLoader.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWindowPath = exports.isCJSPluginDefinition = exports.isESMPluginDefinition = exports.isUMDPluginDefinition = void 0;
6
+ exports.isCJSPluginDefinition = exports.isESMPluginDefinition = exports.isUMDPluginDefinition = void 0;
7
7
  const load_script2_1 = __importDefault(require("load-script2"));
8
8
  const ReExports_1 = __importDefault(require("./ReExports"));
9
9
  const util_1 = require("./util");
@@ -23,10 +23,6 @@ function isCJSPluginDefinition(def) {
23
23
  return def.cjsUrl !== undefined;
24
24
  }
25
25
  exports.isCJSPluginDefinition = isCJSPluginDefinition;
26
- function getWindowPath(windowHref) {
27
- return window.location.href + windowHref;
28
- }
29
- exports.getWindowPath = getWindowPath;
30
26
  function getGlobalObject() {
31
27
  // Based on window-or-global
32
28
  // https://github.com/purposeindustries/window-or-global/blob/322abc71de0010c9e5d9d0729df40959e1ef8775/lib/index.js
@@ -60,8 +56,8 @@ class PluginLoader {
60
56
  }
61
57
  throw new Error('cannot figure out how to load external JS scripts in this environment');
62
58
  }
63
- async loadCJSPlugin(def, windowHref) {
64
- const parsedUrl = new URL(def.cjsUrl, windowHref);
59
+ async loadCJSPlugin(def, baseUri) {
60
+ const parsedUrl = new URL(def.cjsUrl, baseUri);
65
61
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
66
62
  throw new Error(`Cannot load plugins using protocol "${parsedUrl.protocol}"`);
67
63
  }
@@ -70,25 +66,27 @@ class PluginLoader {
70
66
  }
71
67
  return this.fetchCJS(parsedUrl.href);
72
68
  }
73
- async loadESMPlugin(def, windowHref) {
74
- var _a;
69
+ async loadESMPlugin(def, baseUri) {
75
70
  const parsedUrl = 'esmUrl' in def
76
- ? new URL(def.esmUrl, windowHref)
71
+ ? new URL(def.esmUrl, baseUri)
77
72
  : new URL(def.esmLoc.uri, def.esmLoc.baseUri);
78
73
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
79
74
  throw new Error(`cannot load plugins using protocol "${parsedUrl.protocol}"`);
80
75
  }
81
- const plugin = (await ((_a = this.fetchESM) === null || _a === void 0 ? void 0 : _a.call(this, parsedUrl.href)));
76
+ if (!this.fetchESM) {
77
+ throw new Error(`No ESM fetcher installed`);
78
+ }
79
+ const plugin = await this.fetchESM(parsedUrl.href);
82
80
  if (!plugin) {
83
81
  throw new Error(`Could not load ESM plugin: ${parsedUrl}`);
84
82
  }
85
83
  return plugin;
86
84
  }
87
- async loadUMDPlugin(def, windowHref) {
85
+ async loadUMDPlugin(def, baseUri) {
88
86
  const parsedUrl = 'url' in def
89
- ? new URL(def.url, windowHref)
87
+ ? new URL(def.url, baseUri)
90
88
  : 'umdUrl' in def
91
- ? new URL(def.umdUrl, windowHref)
89
+ ? new URL(def.umdUrl, baseUri)
92
90
  : new URL(def.umdLoc.uri, def.umdLoc.baseUri);
93
91
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
94
92
  throw new Error(`cannot load plugins using protocol "${parsedUrl.protocol}"`);
@@ -104,16 +102,16 @@ class PluginLoader {
104
102
  }
105
103
  return plugin;
106
104
  }
107
- async loadPlugin(def, windowHref) {
105
+ async loadPlugin(def, baseUri) {
108
106
  let plugin;
109
107
  if (util_1.isElectron && isCJSPluginDefinition(def)) {
110
- plugin = await this.loadCJSPlugin(def, windowHref);
108
+ plugin = await this.loadCJSPlugin(def, baseUri);
111
109
  }
112
110
  else if (isESMPluginDefinition(def)) {
113
- plugin = await this.loadESMPlugin(def, windowHref);
111
+ plugin = await this.loadESMPlugin(def, baseUri);
114
112
  }
115
113
  else if (isUMDPluginDefinition(def)) {
116
- plugin = await this.loadUMDPlugin(def, windowHref);
114
+ plugin = await this.loadUMDPlugin(def, baseUri);
117
115
  }
118
116
  else if (!util_1.isElectron && isCJSPluginDefinition(def)) {
119
117
  throw new Error(`CommonJS plugin found, but not in a NodeJS environment: ${JSON.stringify(def)}`);
@@ -129,9 +127,9 @@ class PluginLoader {
129
127
  return [moduleName, module];
130
128
  }));
131
129
  }
132
- async load(windowHref = '') {
130
+ async load(baseUri) {
133
131
  return Promise.all(this.definitions.map(async (definition) => ({
134
- plugin: await this.loadPlugin(definition, windowHref),
132
+ plugin: await this.loadPlugin(definition, baseUri),
135
133
  definition,
136
134
  })));
137
135
  }
package/PluginManager.js CHANGED
@@ -258,7 +258,7 @@ class PluginManager {
258
258
  .filter(t => (0, mobx_state_tree_1.isType)(t) && (0, mobx_state_tree_1.isModelType)(t));
259
259
  // try to smooth over the case when no types are registered, mostly
260
260
  // encountered in tests
261
- if (pluggableTypes.length === 0) {
261
+ if (pluggableTypes.length === 0 && typeof jest === 'undefined') {
262
262
  console.warn(`No pluggable types found matching ('${groupName}','${fieldName}')`);
263
263
  return fallback;
264
264
  }
@@ -96,6 +96,7 @@ export declare abstract class BaseFeatureDataAdapter extends BaseAdapter {
96
96
  * Currently this just calls getFeatureInRegion for each region. Adapters that
97
97
  * are frequently called on multiple regions simultaneously may want to
98
98
  * implement a more efficient custom version of this method.
99
+ *
99
100
  * @param regions - Regions
100
101
  * @param opts - Feature adapter options
101
102
  * @returns Observable of Feature objects in the regions
@@ -7,6 +7,7 @@ exports.isTextSearchAdapter = exports.isRefNameAliasAdapter = exports.isFeatureA
7
7
  const rxjs_1 = require("rxjs");
8
8
  const operators_1 = require("rxjs/operators");
9
9
  const mobx_state_tree_1 = require("mobx-state-tree");
10
+ // locals
10
11
  const rxjs_2 = require("../util/rxjs");
11
12
  const util_1 = require("../util");
12
13
  const configuration_1 = require("../configuration");
@@ -95,6 +96,7 @@ class BaseFeatureDataAdapter extends BaseAdapter {
95
96
  * Currently this just calls getFeatureInRegion for each region. Adapters that
96
97
  * are frequently called on multiple regions simultaneously may want to
97
98
  * implement a more efficient custom version of this method.
99
+ *
98
100
  * @param regions - Regions
99
101
  * @param opts - Feature adapter options
100
102
  * @returns Observable of Feature objects in the regions
@@ -122,12 +124,12 @@ class BaseFeatureDataAdapter extends BaseAdapter {
122
124
  return (0, stats_1.blankStats)();
123
125
  }
124
126
  const feats = await Promise.all(regions.map(region => this.getRegionStats(region, opts)));
125
- const scoreMax = feats.map(a => a.scoreMax).reduce((a, b) => Math.max(a, b));
126
- const scoreMin = feats.map(a => a.scoreMin).reduce((a, b) => Math.min(a, b));
127
- const scoreSum = feats.reduce((a, b) => a + b.scoreSum, 0);
128
- const scoreSumSquares = feats.reduce((a, b) => a + b.scoreSumSquares, 0);
129
- const featureCount = feats.reduce((a, b) => a + b.featureCount, 0);
130
- const basesCovered = feats.reduce((a, b) => a + b.basesCovered, 0);
127
+ const scoreMax = (0, util_1.max)(feats.map(a => a.scoreMax));
128
+ const scoreMin = (0, util_1.min)(feats.map(a => a.scoreMin));
129
+ const scoreSum = (0, util_1.sum)(feats.map(a => a.scoreSum));
130
+ const scoreSumSquares = (0, util_1.sum)(feats.map(a => a.scoreSumSquares));
131
+ const featureCount = (0, util_1.sum)(feats.map(a => a.featureCount));
132
+ const basesCovered = (0, util_1.sum)(feats.map(a => a.basesCovered));
131
133
  return (0, stats_1.rectifyStats)({
132
134
  scoreMin,
133
135
  scoreMax,
@@ -151,9 +153,7 @@ class BaseFeatureDataAdapter extends BaseAdapter {
151
153
  start: Math.max(0, Math.round(sampleCenter - length / 2)),
152
154
  end: Math.min(Math.round(sampleCenter + length / 2), end),
153
155
  };
154
- const features = await this.getFeatures(query, opts)
155
- .pipe((0, operators_1.toArray)())
156
- .toPromise();
156
+ const features = await (0, rxjs_1.firstValueFrom)(this.getFeatures(query, opts).pipe((0, operators_1.toArray)()));
157
157
  return maybeRecordStats(length, { featureDensity: features.length / length }, features.length, expansionTime);
158
158
  };
159
159
  const maybeRecordStats = async (interval, stats, statsSampleFeatures, expansionTime) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/core",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "JBrowse 2 core libraries used by plugins",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -30,6 +30,7 @@
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.17.9",
32
32
  "@mui/icons-material": "^5.0.1",
33
+ "@types/clone": "^2.0.0",
33
34
  "abortable-promise-cache": "^1.5.0",
34
35
  "canvas-sequencer": "^3.1.0",
35
36
  "canvas2svg": "^1.0.16",
@@ -66,12 +67,12 @@
66
67
  "prop-types": "^15.0.0",
67
68
  "react": ">=16.8.0",
68
69
  "react-dom": ">=16.8.0",
69
- "rxjs": "^6.0.0",
70
+ "rxjs": "^7.0.0",
70
71
  "tss-react": "^4.0.0"
71
72
  },
72
73
  "publishConfig": {
73
74
  "access": "public",
74
75
  "directory": "dist"
75
76
  },
76
- "gitHead": "467d973535bb7b2664e9f66311fb0dc21c1ce5ba"
77
+ "gitHead": "98ae48be91ee2371e1b2768a907b4997995e9915"
77
78
  }
@@ -8,6 +8,7 @@ const operators_1 = require("rxjs/operators");
8
8
  const ServerSideRendererType_1 = __importDefault(require("./ServerSideRendererType"));
9
9
  const dataAdapterCache_1 = require("../../data_adapters/dataAdapterCache");
10
10
  const util_1 = require("../../util");
11
+ const rxjs_1 = require("rxjs");
11
12
  class ComparativeServerSideRenderer extends ServerSideRendererType_1.default {
12
13
  /**
13
14
  * directly modifies the render arguments to prepare
@@ -78,10 +79,9 @@ class ComparativeServerSideRenderer extends ServerSideRendererType_1.default {
78
79
  return requestRegion;
79
80
  });
80
81
  // note that getFeaturesInMultipleRegions does not do glyph expansion
81
- const res = await dataAdapter
82
+ const res = await (0, rxjs_1.firstValueFrom)(dataAdapter
82
83
  .getFeaturesInMultipleRegions(requestRegions, renderArgs)
83
- .pipe((0, operators_1.filter)(f => this.featurePassesFilters(renderArgs, f)), (0, operators_1.toArray)())
84
- .toPromise();
84
+ .pipe((0, operators_1.filter)(f => this.featurePassesFilters(renderArgs, f)), (0, operators_1.toArray)()));
85
85
  // dedupe needed xref https://github.com/GMOD/jbrowse-components/pull/3404/
86
86
  return (0, util_1.dedupe)(res, f => f.id());
87
87
  }
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const operators_1 = require("rxjs/operators");
7
7
  const clone_1 = __importDefault(require("clone"));
8
+ const rxjs_1 = require("rxjs");
9
+ // locals
8
10
  const util_1 = require("../../util");
9
11
  const simpleFeature_1 = __importDefault(require("../../util/simpleFeature"));
10
12
  const dataAdapterCache_1 = require("../../data_adapters/dataAdapterCache");
@@ -106,7 +108,7 @@ class FeatureRendererType extends ServerSideRendererType_1.default {
106
108
  const featureObservable = requestRegions.length === 1
107
109
  ? dataAdapter.getFeatures(this.getExpandedRegion(region, renderArgs), renderArgs)
108
110
  : dataAdapter.getFeaturesInMultipleRegions(requestRegions, renderArgs);
109
- const feats = await featureObservable.pipe((0, operators_1.toArray)()).toPromise();
111
+ const feats = await (0, rxjs_1.firstValueFrom)(featureObservable.pipe((0, operators_1.toArray)()));
110
112
  (0, util_1.checkAbortSignal)(signal);
111
113
  return new Map(feats
112
114
  .filter(feat => this.featurePassesFilters(renderArgs, feat))
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
7
7
  const operators_1 = require("rxjs/operators");
8
+ const rxjs_1 = require("rxjs");
9
+ // locals
8
10
  const dataAdapterCache_1 = require("../../data_adapters/dataAdapterCache");
9
11
  const RpcMethodType_1 = __importDefault(require("../../pluggableElementTypes/RpcMethodType"));
10
12
  const BaseAdapter_1 = require("../../data_adapters/BaseAdapter");
@@ -37,7 +39,7 @@ class CoreGetFeatures extends RpcMethodType_1.default {
37
39
  ...opts,
38
40
  signal,
39
41
  });
40
- const r = await ret.pipe((0, operators_1.toArray)()).toPromise();
42
+ const r = await (0, rxjs_1.firstValueFrom)(ret.pipe((0, operators_1.toArray)()));
41
43
  return r.map(f => f.toJSON());
42
44
  }
43
45
  }