@jbrowse/core 2.7.1 → 2.7.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.
package/util/index.d.ts CHANGED
@@ -13,23 +13,40 @@ export * from './range';
13
13
  export * from './dedupe';
14
14
  export * from './offscreenCanvasPonyfill';
15
15
  export * from './offscreenCanvasUtils';
16
- export declare const inDevelopment: boolean;
17
- export declare const inProduction: boolean;
18
16
  export declare function useDebounce<T>(value: T, delay: number): T;
19
17
  export declare function useWidthSetter(view: {
20
18
  setWidth: (arg: number) => void;
21
19
  }, padding: string): import("react").RefObject<HTMLDivElement>;
22
20
  export declare function useDebouncedCallback<T>(callback: (...args: T[]) => void, wait?: number): (...args: T[]) => void;
23
- /** find the first node in the hierarchy that matches the given predicate */
21
+ /**
22
+ * find the first node in the hierarchy that matches the given predicate
23
+ */
24
24
  export declare function findParentThat(node: IAnyStateTreeNode, predicate: (thing: IAnyStateTreeNode) => boolean): IAnyStateTreeNode;
25
25
  export declare function springAnimate(fromValue: number, toValue: number, setValue: (value: number) => void, onFinish?: () => void, precision?: number, tension?: number, friction?: number): (() => void)[];
26
+ /**
27
+ * find the first node in the hierarchy that matches the given 'is' typescript
28
+ * type guard predicate
29
+ */
26
30
  export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T>;
27
- /** get the current JBrowse session model, starting at any node in the state tree */
31
+ /**
32
+ * get the current JBrowse session model, starting at any node in the state
33
+ * tree
34
+ */
28
35
  export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel;
29
- /** get the state model of the view in the state tree that contains the given node */
36
+ /**
37
+ * get the state model of the view in the state tree that contains the given
38
+ * node
39
+ */
30
40
  export declare function getContainingView(node: IAnyStateTreeNode): import("./types").AbstractViewModel;
31
- /** get the state model of the view in the state tree that contains the given node */
41
+ /**
42
+ * get the state model of the view in the state tree that contains the given
43
+ * node
44
+ */
32
45
  export declare function getContainingTrack(node: IAnyStateTreeNode): import("./types").AbstractTrackModel;
46
+ /**
47
+ * get the state model of the display in the state tree that contains the given
48
+ * node
49
+ */
33
50
  export declare function getContainingDisplay(node: IAnyStateTreeNode): import("./types").AbstractDisplayModel;
34
51
  /**
35
52
  * Assemble a 1-based "locString" from an interbase genomic location
@@ -159,10 +176,14 @@ export declare function iterMap<T, U>(iter: Iterable<T>, func: (arg: T) => U, si
159
176
  /**
160
177
  * Returns the index of the last element in the array where predicate is true,
161
178
  * and -1 otherwise.
179
+ * Based on https://stackoverflow.com/a/53187807
180
+ *
162
181
  * @param array - The source array to search in
182
+ *
163
183
  * @param predicate - find calls predicate once for each element of the array, in
164
- * descending order, until it finds one where predicate returns true. If such an
165
- * element is found, findLastIndex immediately returns that element index.
184
+ * descending order, until it finds one where predicate returns true.
185
+ *
186
+ * @returns findLastIndex returns element index where predicate is true.
166
187
  * Otherwise, findLastIndex returns -1.
167
188
  */
168
189
  export declare function findLastIndex<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
package/util/index.js CHANGED
@@ -17,8 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.isSupportedIndexingAdapter = exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.complement = exports.reverse = exports.revcom = exports.isElectron = exports.stringify = exports.shorten = exports.minmax = exports.renameRegionsIfNeeded = exports.renameRegionIfNeeded = exports.makeAbortableReaction = exports.findLast = exports.findLastIndex = exports.iterMap = exports.bpSpanPx = exports.featureSpanPx = exports.cartesianToPolar = exports.polarToCartesian = exports.degToRad = exports.radToDeg = exports.bpToPx = exports.clamp = exports.compareLocStrings = exports.compareLocs = exports.parseLocString = exports.parseLocStringOneBased = exports.assembleLocStringFast = exports.assembleLocString = exports.getContainingDisplay = exports.getContainingTrack = exports.getContainingView = exports.getSession = exports.findParentThatIs = exports.springAnimate = exports.findParentThat = exports.useDebouncedCallback = exports.useWidthSetter = exports.useDebounce = exports.inProduction = exports.inDevelopment = void 0;
21
- exports.blobToDataURL = exports.stripAlpha = exports.isFeature = exports.SimpleFeature = exports.gatherOverlaps = exports.mergeIntervals = exports.notEmpty = exports.groupBy = exports.avg = exports.sum = exports.min = exports.max = exports.localStorageSetItem = exports.localStorageGetItem = exports.getEnv = exports.measureGridWidth = exports.linkify = exports.coarseStripHTML = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr = void 0;
20
+ exports.toLocale = exports.getBpDisplayStr = exports.isSupportedIndexingAdapter = exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.complement = exports.reverse = exports.revcom = exports.isElectron = exports.stringify = exports.shorten = exports.minmax = exports.renameRegionsIfNeeded = exports.renameRegionIfNeeded = exports.makeAbortableReaction = exports.findLast = exports.findLastIndex = exports.iterMap = exports.bpSpanPx = exports.featureSpanPx = exports.cartesianToPolar = exports.polarToCartesian = exports.degToRad = exports.radToDeg = exports.bpToPx = exports.clamp = exports.compareLocStrings = exports.compareLocs = exports.parseLocString = exports.parseLocStringOneBased = exports.assembleLocStringFast = exports.assembleLocString = exports.getContainingDisplay = exports.getContainingTrack = exports.getContainingView = exports.getSession = exports.findParentThatIs = exports.springAnimate = exports.findParentThat = exports.useDebouncedCallback = exports.useWidthSetter = exports.useDebounce = void 0;
21
+ exports.blobToDataURL = exports.stripAlpha = exports.isFeature = exports.SimpleFeature = exports.gatherOverlaps = exports.mergeIntervals = exports.notEmpty = exports.groupBy = exports.avg = exports.sum = exports.min = exports.max = exports.localStorageSetItem = exports.localStorageGetItem = exports.getEnv = exports.measureGridWidth = exports.linkify = exports.coarseStripHTML = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = void 0;
22
22
  /* eslint-disable @typescript-eslint/no-explicit-any */
23
23
  const react_1 = require("react");
24
24
  const is_object_1 = __importDefault(require("is-object"));
@@ -37,10 +37,6 @@ __exportStar(require("./range"), exports);
37
37
  __exportStar(require("./dedupe"), exports);
38
38
  __exportStar(require("./offscreenCanvasPonyfill"), exports);
39
39
  __exportStar(require("./offscreenCanvasUtils"), exports);
40
- exports.inDevelopment = typeof process === 'object' &&
41
- process.env &&
42
- process.env.NODE_ENV === 'development';
43
- exports.inProduction = !exports.inDevelopment;
44
40
  function useDebounce(value, delay) {
45
41
  const [debouncedValue, setDebouncedValue] = (0, react_1.useState)(value);
46
42
  (0, react_1.useEffect)(() => {
@@ -78,7 +74,8 @@ function useDebouncedCallback(callback, wait = 400) {
78
74
  clearTimeout(timeout.current);
79
75
  }
80
76
  }
81
- // make sure our timeout gets cleared if our consuming component gets unmounted
77
+ // make sure our timeout gets cleared if our consuming component gets
78
+ // unmounted
82
79
  (0, react_1.useEffect)(() => cleanup, []);
83
80
  return function debouncedCallback(...args) {
84
81
  // capture latest args
@@ -94,7 +91,9 @@ function useDebouncedCallback(callback, wait = 400) {
94
91
  };
95
92
  }
96
93
  exports.useDebouncedCallback = useDebouncedCallback;
97
- /** find the first node in the hierarchy that matches the given predicate */
94
+ /**
95
+ * find the first node in the hierarchy that matches the given predicate
96
+ */
98
97
  function findParentThat(node, predicate) {
99
98
  if (!(0, mobx_state_tree_1.hasParent)(node)) {
100
99
  throw new Error('node does not have parent');
@@ -161,12 +160,18 @@ function springAnimate(fromValue, toValue, setValue, onFinish = () => { }, preci
161
160
  ];
162
161
  }
163
162
  exports.springAnimate = springAnimate;
164
- // find the first node in the hierarchy that matches the given 'is' typescript type guard predicate
163
+ /**
164
+ * find the first node in the hierarchy that matches the given 'is' typescript
165
+ * type guard predicate
166
+ */
165
167
  function findParentThatIs(node, predicate) {
166
168
  return findParentThat(node, predicate);
167
169
  }
168
170
  exports.findParentThatIs = findParentThatIs;
169
- /** get the current JBrowse session model, starting at any node in the state tree */
171
+ /**
172
+ * get the current JBrowse session model, starting at any node in the state
173
+ * tree
174
+ */
170
175
  function getSession(node) {
171
176
  try {
172
177
  return findParentThatIs(node, types_1.isSessionModel);
@@ -176,7 +181,10 @@ function getSession(node) {
176
181
  }
177
182
  }
178
183
  exports.getSession = getSession;
179
- /** get the state model of the view in the state tree that contains the given node */
184
+ /**
185
+ * get the state model of the view in the state tree that contains the given
186
+ * node
187
+ */
180
188
  function getContainingView(node) {
181
189
  try {
182
190
  return findParentThatIs(node, types_1.isViewModel);
@@ -186,7 +194,10 @@ function getContainingView(node) {
186
194
  }
187
195
  }
188
196
  exports.getContainingView = getContainingView;
189
- /** get the state model of the view in the state tree that contains the given node */
197
+ /**
198
+ * get the state model of the view in the state tree that contains the given
199
+ * node
200
+ */
190
201
  function getContainingTrack(node) {
191
202
  try {
192
203
  return findParentThatIs(node, types_1.isTrackModel);
@@ -196,6 +207,10 @@ function getContainingTrack(node) {
196
207
  }
197
208
  }
198
209
  exports.getContainingTrack = getContainingTrack;
210
+ /**
211
+ * get the state model of the display in the state tree that contains the given
212
+ * node
213
+ */
199
214
  function getContainingDisplay(node) {
200
215
  try {
201
216
  return findParentThatIs(node, types_1.isDisplayModel);
@@ -516,14 +531,17 @@ function iterMap(iter, func, sizeHint) {
516
531
  return results;
517
532
  }
518
533
  exports.iterMap = iterMap;
519
- // https://stackoverflow.com/a/53187807
520
534
  /**
521
535
  * Returns the index of the last element in the array where predicate is true,
522
536
  * and -1 otherwise.
537
+ * Based on https://stackoverflow.com/a/53187807
538
+ *
523
539
  * @param array - The source array to search in
540
+ *
524
541
  * @param predicate - find calls predicate once for each element of the array, in
525
- * descending order, until it finds one where predicate returns true. If such an
526
- * element is found, findLastIndex immediately returns that element index.
542
+ * descending order, until it finds one where predicate returns true.
543
+ *
544
+ * @returns findLastIndex returns element index where predicate is true.
527
545
  * Otherwise, findLastIndex returns -1.
528
546
  */
529
547
  function findLastIndex(array, predicate) {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const __1 = require("..");
4
3
  class SceneGraph {
5
4
  /**
6
5
  * note: all coordinates are inter-base or inter-pixel coordinates
@@ -14,18 +13,6 @@ class SceneGraph {
14
13
  this.width = width;
15
14
  this.height = height;
16
15
  this.data = data;
17
- if (__1.inDevelopment &&
18
- (typeof name !== 'string' ||
19
- typeof left !== 'number' ||
20
- Number.isNaN(left) ||
21
- typeof top !== 'number' ||
22
- Number.isNaN(top) ||
23
- typeof width !== 'number' ||
24
- Number.isNaN(width) ||
25
- typeof height !== 'number' ||
26
- Number.isNaN(height))) {
27
- throw new TypeError('invalid SceneGraph arguments');
28
- }
29
16
  this.children = new Map();
30
17
  this.absoluteCache = { dirty: true };
31
18
  }
@@ -52,6 +52,8 @@ export interface AbstractSessionModel extends AbstractViewContainer {
52
52
  selection?: unknown;
53
53
  focusedViewId?: string;
54
54
  themeName?: string;
55
+ hovered: unknown;
56
+ setHovered: (arg: unknown) => void;
55
57
  setFocusedViewId?: (id: string) => void;
56
58
  allThemes?: () => Record<string, ThemeOptions | undefined>;
57
59
  setSelection: (feature: Feature) => void;
@@ -117,9 +119,9 @@ export interface Widget {
117
119
  export interface SessionWithWidgets extends AbstractSessionModel {
118
120
  minimized: boolean;
119
121
  visibleWidget?: Widget;
120
- widgets: Map<string, Widget>;
122
+ widgets: Map<string | number, Widget>;
121
123
  hideAllWidgets: () => void;
122
- activeWidgets: Map<string, Widget>;
124
+ activeWidgets: Map<string | number, Widget>;
123
125
  addWidget(typeName: string, id: string, initialState?: Record<string, unknown>, configuration?: {
124
126
  type: string;
125
127
  }): Widget;