@jbrowse/core 2.6.2 → 2.7.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 (104) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.d.ts +0 -9
  2. package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.js +2 -3
  3. package/BaseFeatureWidget/BaseFeatureDetail/Attributes.d.ts +1 -3
  4. package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.d.ts +0 -9
  5. package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.js +2 -3
  6. package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.d.ts +0 -9
  7. package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.js +11 -6
  8. package/BaseFeatureWidget/BaseFeatureDetail/FieldName.d.ts +0 -9
  9. package/BaseFeatureWidget/BaseFeatureDetail/FieldName.js +2 -3
  10. package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.d.ts +0 -9
  11. package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.js +2 -3
  12. package/BaseFeatureWidget/BaseFeatureDetail/UriField.d.ts +0 -9
  13. package/BaseFeatureWidget/BaseFeatureDetail/UriField.js +2 -3
  14. package/BaseFeatureWidget/BaseFeatureDetail/index.d.ts +2 -11
  15. package/BaseFeatureWidget/BaseFeatureDetail/index.js +5 -4
  16. package/BaseFeatureWidget/SequenceFeatureDetails/ProteinSequence.d.ts +1 -3
  17. package/BaseFeatureWidget/SequenceFeatureDetails/SequencePanel.js +1 -1
  18. package/BaseFeatureWidget/util.js +0 -4
  19. package/PluginManager.d.ts +9 -17
  20. package/ReExports/modules.d.ts +5 -5
  21. package/ReExports/modules.js +24 -18
  22. package/TextSearch/TextSearchManager.d.ts +1 -1
  23. package/assemblyManager/assembly.d.ts +2 -0
  24. package/assemblyManager/assembly.js +9 -4
  25. package/assemblyManager/assemblyManager.d.ts +123 -111
  26. package/assemblyManager/assemblyManager.js +1 -1
  27. package/configuration/configurationSchema.js +2 -2
  28. package/configuration/configurationSlot.js +3 -6
  29. package/data_adapters/BaseAdapter/index.d.ts +1 -3
  30. package/data_adapters/dataAdapterCache.js +2 -2
  31. package/package.json +5 -6
  32. package/pluggableElementTypes/AdapterType.d.ts +2 -2
  33. package/pluggableElementTypes/RpcMethodType.js +2 -3
  34. package/pluggableElementTypes/models/BaseTrackModel.d.ts +5 -5
  35. package/pluggableElementTypes/models/BaseTrackModel.js +1 -16
  36. package/pluggableElementTypes/models/InternetAccountModel.d.ts +2 -2
  37. package/pluggableElementTypes/models/InternetAccountModel.js +2 -2
  38. package/pluggableElementTypes/renderers/BoxRendererType.d.ts +1 -3
  39. package/pluggableElementTypes/renderers/CircularChordRendererType.d.ts +3 -0
  40. package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.d.ts +7 -3
  41. package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.js +45 -2
  42. package/pluggableElementTypes/renderers/ServerSideRenderedContent.d.ts +2 -2
  43. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +49 -12
  44. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +2 -2
  45. package/rpc/RpcManager.d.ts +2 -2
  46. package/rpc/WebWorkerRpcDriver.js +6 -3
  47. package/rpc/methods/CoreGetFeatureDensityStats.js +0 -1
  48. package/rpc/methods/CoreGetFeatureDetails.js +0 -1
  49. package/rpc/methods/CoreGetFeatures.js +0 -1
  50. package/rpc/methods/CoreRender.js +0 -1
  51. package/rpc/remoteAbortSignals.d.ts +2 -2
  52. package/tsconfig.build.tsbuildinfo +1 -1
  53. package/ui/ColorPicker.js +3 -6
  54. package/ui/Dialog.d.ts +2 -2
  55. package/ui/Dialog.js +2 -1
  56. package/ui/DropDownMenu.d.ts +3 -4
  57. package/ui/DropDownMenu.js +8 -12
  58. package/ui/EditableTypography.js +7 -5
  59. package/ui/FactoryResetDialog.d.ts +3 -4
  60. package/ui/FactoryResetDialog.js +3 -2
  61. package/ui/FileSelector/FileSelector.d.ts +2 -2
  62. package/ui/FileSelector/FileSelector.js +2 -1
  63. package/ui/FileSelector/LocalFileChooser.d.ts +2 -2
  64. package/ui/FileSelector/LocalFileChooser.js +4 -3
  65. package/ui/FileSelector/UrlChooser.d.ts +5 -5
  66. package/ui/FileSelector/UrlChooser.js +2 -2
  67. package/ui/Menu.js +1 -1
  68. package/ui/ResizeBar.d.ts +0 -4
  69. package/ui/ResizeBar.js +12 -31
  70. package/ui/ResizeHandle.d.ts +3 -2
  71. package/ui/ResizeHandle.js +10 -7
  72. package/ui/ReturnToImportFormDialog.d.ts +4 -5
  73. package/ui/ReturnToImportFormDialog.js +3 -3
  74. package/ui/SanitizedHTML.d.ts +0 -1
  75. package/ui/SanitizedHTML.js +0 -2
  76. package/ui/Snackbar.d.ts +2 -2
  77. package/ui/Snackbar.js +2 -1
  78. package/ui/Tooltip.d.ts +4 -7
  79. package/ui/Tooltip.js +3 -3
  80. package/ui/theme.d.ts +1 -3
  81. package/ui/theme.js +2 -2
  82. package/ui/useResizeBar.d.ts +5 -0
  83. package/ui/useResizeBar.js +22 -0
  84. package/util/Base1DUtils.js +0 -1
  85. package/util/blockTypes.d.ts +1 -9
  86. package/util/blockTypes.js +5 -21
  87. package/util/calculateDynamicBlocks.js +3 -2
  88. package/util/calculateStaticBlocks.js +3 -4
  89. package/util/colord.d.ts +1 -0
  90. package/util/colord.js +13 -0
  91. package/util/dedupe.js +1 -2
  92. package/util/index.d.ts +13 -16
  93. package/util/index.js +17 -10
  94. package/util/io/RemoteFileWithRangeCache.js +3 -3
  95. package/util/layouts/GranularRectLayout.js +1 -2
  96. package/util/map-obj.d.ts +1 -1
  97. package/util/nanoid.d.ts +5 -0
  98. package/util/nanoid.js +73 -0
  99. package/util/offscreenCanvasPonyfill.js +1 -2
  100. package/util/offscreenCanvasUtils.js +1 -0
  101. package/util/tracks.d.ts +2 -6
  102. package/util/types/index.d.ts +38 -10
  103. package/util/types/index.js +19 -1
  104. package/util/types/mst.js +2 -2
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InterRegionPaddingBlock = exports.ElidedBlock = exports.ContentBlock = exports.BaseBlock = exports.BlockSet = void 0;
4
+ const _1 = require(".");
4
5
  class BlockSet {
5
6
  constructor(blocks = []) {
6
7
  this.blocks = blocks;
@@ -34,15 +35,14 @@ class BlockSet {
34
35
  }
35
36
  get totalWidthPx() {
36
37
  return this.blocks.length > 0
37
- ? this.blocks.map(blocks => blocks.widthPx).reduce((a, b) => a + b)
38
+ ? (0, _1.sum)(this.blocks.map(blocks => blocks.widthPx))
38
39
  : 0;
39
40
  }
40
41
  get totalWidthPxWithoutBorders() {
41
42
  return this.blocks.length > 0
42
- ? this.blocks
43
+ ? (0, _1.sum)(this.blocks
43
44
  .filter(block => block.variant !== 'boundary')
44
- .map(blocks => blocks.widthPx)
45
- .reduce((a, b) => a + b)
45
+ .map(blocks => blocks.widthPx))
46
46
  : 0;
47
47
  }
48
48
  get offsetPx() {
@@ -52,9 +52,7 @@ class BlockSet {
52
52
  return this.blocks.filter(block => block instanceof ContentBlock);
53
53
  }
54
54
  get totalBp() {
55
- return this.contentBlocks
56
- .map(block => block.end - block.start)
57
- .reduce((a, b) => a + b, 0);
55
+ return (0, _1.sum)(this.contentBlocks.map(block => block.end - block.start));
58
56
  }
59
57
  }
60
58
  exports.BlockSet = BlockSet;
@@ -73,20 +71,6 @@ class BaseBlock {
73
71
  this.key = data.key;
74
72
  this.offsetPx = data.offsetPx;
75
73
  }
76
- /**
77
- * rename the reference sequence of this block and return a new one
78
- *
79
- * @param refName -
80
- * @returns either a new block with a renamed reference sequence,
81
- * or the same block, if the ref name is not actually different
82
- */
83
- renameReference(refName) {
84
- if (this.refName && refName !== this.refName) {
85
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
- return new this.constructor({ ...this, refName });
87
- }
88
- return this;
89
- }
90
74
  toRegion() {
91
75
  return {
92
76
  refName: this.refName,
@@ -32,7 +32,8 @@ function calculateDynamicBlocks(model, padding = true, elision = true) {
32
32
  let displayedRegionLeftPx = 0;
33
33
  const windowLeftPx = offsetPx;
34
34
  const windowRightPx = windowLeftPx + width;
35
- displayedRegions.forEach((region, regionNumber) => {
35
+ for (let regionNumber = 0; regionNumber < displayedRegions.length; regionNumber++) {
36
+ const region = displayedRegions[regionNumber];
36
37
  const { assemblyName, refName, start: regionStart, end: regionEnd, reversed, } = region;
37
38
  const displayedRegionRightPx = displayedRegionLeftPx + (regionEnd - regionStart) / bpPerPx;
38
39
  const regionWidthPx = (regionEnd - regionStart) / bpPerPx;
@@ -115,7 +116,7 @@ function calculateDynamicBlocks(model, padding = true, elision = true) {
115
116
  }
116
117
  }
117
118
  displayedRegionLeftPx += (regionEnd - regionStart) / bpPerPx;
118
- });
119
+ }
119
120
  return blocks;
120
121
  }
121
122
  exports.default = calculateDynamicBlocks;
@@ -12,9 +12,8 @@ function calculateStaticBlocks(model, padding = true, elision = true, extra = 0,
12
12
  // for each displayed region
13
13
  let regionBpOffset = 0;
14
14
  const blocks = new blockTypes_1.BlockSet();
15
- displayedRegions.forEach((region, regionNumber) => {
16
- // find the block numbers of the left and right window sides,
17
- // clamp those to the region range, and then make blocks for that range
15
+ for (let regionNumber = 0; regionNumber < displayedRegions.length; regionNumber++) {
16
+ const region = displayedRegions[regionNumber];
18
17
  const { assemblyName, refName, start: regionStart, end: regionEnd, reversed, } = region;
19
18
  const regionBlockCount = Math.ceil((regionEnd - regionStart) / blockSizeBp);
20
19
  const parentRegion = (0, mobx_state_tree_1.isStateTreeNode)(region) ? (0, mobx_state_tree_1.getSnapshot)(region) : region;
@@ -99,7 +98,7 @@ function calculateStaticBlocks(model, padding = true, elision = true, extra = 0,
99
98
  }
100
99
  }
101
100
  regionBpOffset += regionEnd - regionStart;
102
- });
101
+ }
103
102
  return blocks;
104
103
  }
105
104
  exports.default = calculateStaticBlocks;
@@ -0,0 +1 @@
1
+ export { Colord, colord } from 'colord';
package/util/colord.js ADDED
@@ -0,0 +1,13 @@
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.colord = exports.Colord = void 0;
7
+ const colord_1 = require("colord");
8
+ const mix_1 = __importDefault(require("colord/plugins/mix"));
9
+ const names_1 = __importDefault(require("colord/plugins/names"));
10
+ (0, colord_1.extend)([mix_1.default, names_1.default]);
11
+ var colord_2 = require("colord");
12
+ Object.defineProperty(exports, "Colord", { enumerable: true, get: function () { return colord_2.Colord; } });
13
+ Object.defineProperty(exports, "colord", { enumerable: true, get: function () { return colord_2.colord; } });
package/util/dedupe.js CHANGED
@@ -5,8 +5,7 @@ exports.dedupe = void 0;
5
5
  function dedupe(list, hasher = JSON.stringify) {
6
6
  const clone = [];
7
7
  const lookup = new Set();
8
- for (let i = 0; i < list.length; i++) {
9
- const entry = list[i];
8
+ for (const entry of list) {
10
9
  const hashed = hasher(entry);
11
10
  if (!lookup.has(hashed)) {
12
11
  clone.push(entry);
package/util/index.d.ts CHANGED
@@ -23,14 +23,14 @@ export declare function useDebouncedCallback<T>(callback: (...args: T[]) => void
23
23
  /** find the first node in the hierarchy that matches the given predicate */
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
- export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T> & IAnyStateTreeNode;
26
+ export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T>;
27
27
  /** get the current JBrowse session model, starting at any node in the state tree */
28
- export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel & IAnyStateTreeNode;
28
+ export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel;
29
29
  /** get the state model of the view in the state tree that contains the given node */
30
- export declare function getContainingView(node: IAnyStateTreeNode): import("./types").AbstractViewModel & IAnyStateTreeNode;
30
+ export declare function getContainingView(node: IAnyStateTreeNode): import("./types").AbstractViewModel;
31
31
  /** get the state model of the view in the state tree that contains the given node */
32
- export declare function getContainingTrack(node: IAnyStateTreeNode): import("./types").AbstractTrackModel & IAnyStateTreeNode;
33
- export declare function getContainingDisplay(node: IAnyStateTreeNode): import("./types").AbstractDisplayModel & IAnyStateTreeNode;
32
+ export declare function getContainingTrack(node: IAnyStateTreeNode): import("./types").AbstractTrackModel;
33
+ export declare function getContainingDisplay(node: IAnyStateTreeNode): import("./types").AbstractDisplayModel;
34
34
  /**
35
35
  * Assemble a 1-based "locString" from an interbase genomic location
36
36
  * @param region - Region
@@ -165,8 +165,8 @@ export declare function iterMap<T, U>(iter: Iterable<T>, func: (arg: T) => U, si
165
165
  * element is found, findLastIndex immediately returns that element index.
166
166
  * Otherwise, findLastIndex returns -1.
167
167
  */
168
- export declare function findLastIndex<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): number;
169
- export declare function findLast<T>(array: Array<T>, predicate: (value: T, index: number, obj: T[]) => boolean): T | undefined;
168
+ export declare function findLastIndex<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
169
+ export declare function findLast<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): T | undefined;
170
170
  /**
171
171
  * makes a mobx reaction with the given functions, that calls actions on the
172
172
  * model for each stage of execution, and to abort the reaction function when
@@ -287,9 +287,7 @@ export declare const defaultCodonTable: {
287
287
  * take CodonTable above and generate larger codon table that includes all
288
288
  * permutations of upper and lower case nucleotides
289
289
  */
290
- export declare function generateCodonTable(table: any): {
291
- [key: string]: string;
292
- };
290
+ export declare function generateCodonTable(table: any): Record<string, string>;
293
291
  export declare function updateStatus<U>(msg: string, cb: (arg: string) => void, fn: () => U | Promise<U>): Promise<U>;
294
292
  export declare function hashCode(str: string): number;
295
293
  export declare function objectHash(obj: Record<string, any>): string;
@@ -303,7 +301,7 @@ interface Block {
303
301
  export declare function bytesForRegions(regions: Region[], index: {
304
302
  blocksForRange: (ref: string, start: number, end: number) => Promise<Block[]>;
305
303
  }): Promise<number>;
306
- export type ViewSnap = {
304
+ export interface ViewSnap {
307
305
  bpPerPx: number;
308
306
  interRegionPaddingWidth: number;
309
307
  minimumBlockWidth: number;
@@ -320,8 +318,8 @@ export type ViewSnap = {
320
318
  reversed: boolean;
321
319
  assemblyName: string;
322
320
  })[];
323
- };
324
- export declare function supportedIndexingAdapters(type: string): boolean;
321
+ }
322
+ export declare function isSupportedIndexingAdapter(type: string): boolean;
325
323
  export declare function getBpDisplayStr(totalBp: number): string;
326
324
  export declare function toLocale(n: number): string;
327
325
  export declare function getTickDisplayStr(totalBp: number, bpPerPx: number): string;
@@ -357,9 +355,7 @@ export declare function max(arr: number[], init?: number): number;
357
355
  export declare function min(arr: number[], init?: number): number;
358
356
  export declare function sum(arr: number[]): number;
359
357
  export declare function avg(arr: number[]): number;
360
- export declare function groupBy<T>(array: T[], predicate: (v: T) => string): {
361
- [key: string]: T[];
362
- };
358
+ export declare function groupBy<T>(array: T[], predicate: (v: T) => string): Record<string, T[]>;
363
359
  export declare function notEmpty<T>(value: T | null | undefined): value is T;
364
360
  export declare function mergeIntervals<T extends {
365
361
  start: number;
@@ -372,3 +368,4 @@ interface BasicFeature {
372
368
  }
373
369
  export declare function gatherOverlaps(regions: BasicFeature[]): BasicFeature[];
374
370
  export { default as SimpleFeature, type Feature, type SimpleFeatureSerialized, isFeature, } from './simpleFeature';
371
+ export declare function stripAlpha(str: string): string;
package/util/index.js CHANGED
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.blobToDataURL = 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.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.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr = exports.supportedIndexingAdapters = void 0;
21
+ 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.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr = exports.isSupportedIndexingAdapter = 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"));
@@ -27,7 +27,9 @@ const mobx_1 = require("mobx");
27
27
  const types_1 = require("./types");
28
28
  const aborting_1 = require("./aborting");
29
29
  const types_2 = require("./types");
30
+ // has to be the full path and not the relative path to get the jest mock
30
31
  const useMeasure_1 = __importDefault(require("@jbrowse/core/util/useMeasure"));
32
+ const colord_1 = require("./colord");
31
33
  __exportStar(require("./types"), exports);
32
34
  __exportStar(require("./aborting"), exports);
33
35
  __exportStar(require("./when"), exports);
@@ -905,7 +907,7 @@ async function bytesForRegions(regions, index) {
905
907
  exports.bytesForRegions = bytesForRegions;
906
908
  // supported adapter types by text indexer
907
909
  // ensure that this matches the method found in @jbrowse/text-indexing/util
908
- function supportedIndexingAdapters(type) {
910
+ function isSupportedIndexingAdapter(type) {
909
911
  return [
910
912
  'Gff3TabixAdapter',
911
913
  'VcfTabixAdapter',
@@ -913,7 +915,7 @@ function supportedIndexingAdapters(type) {
913
915
  'VcfAdapter',
914
916
  ].includes(type);
915
917
  }
916
- exports.supportedIndexingAdapters = supportedIndexingAdapters;
918
+ exports.isSupportedIndexingAdapter = isSupportedIndexingAdapter;
917
919
  function getBpDisplayStr(totalBp) {
918
920
  let str;
919
921
  if (Math.floor(totalBp / 1000000) > 0) {
@@ -939,6 +941,7 @@ function getTickDisplayStr(totalBp, bpPerPx) {
939
941
  }
940
942
  exports.getTickDisplayStr = getTickDisplayStr;
941
943
  function getViewParams(model, exportSVG) {
944
+ // @ts-expect-error
942
945
  const { dynamicBlocks, staticBlocks, offsetPx } = getContainingView(model);
943
946
  const b = (dynamicBlocks === null || dynamicBlocks === void 0 ? void 0 : dynamicBlocks.contentBlocks[0]) || {};
944
947
  const staticblock = (staticBlocks === null || staticBlocks === void 0 ? void 0 : staticBlocks.contentBlocks[0]) || {};
@@ -1037,24 +1040,24 @@ function localStorageSetItem(str, item) {
1037
1040
  exports.localStorageSetItem = localStorageSetItem;
1038
1041
  function max(arr, init = -Infinity) {
1039
1042
  let max = init;
1040
- for (let i = 0; i < arr.length; i++) {
1041
- max = arr[i] > max ? arr[i] : max;
1043
+ for (const entry of arr) {
1044
+ max = entry > max ? entry : max;
1042
1045
  }
1043
1046
  return max;
1044
1047
  }
1045
1048
  exports.max = max;
1046
1049
  function min(arr, init = Infinity) {
1047
1050
  let min = init;
1048
- for (let i = 0; i < arr.length; i++) {
1049
- min = arr[i] < min ? arr[i] : min;
1051
+ for (const entry of arr) {
1052
+ min = entry < min ? entry : min;
1050
1053
  }
1051
1054
  return min;
1052
1055
  }
1053
1056
  exports.min = min;
1054
1057
  function sum(arr) {
1055
1058
  let sum = 0;
1056
- for (let i = 0; i < arr.length; i++) {
1057
- sum += arr[i];
1059
+ for (const entry of arr) {
1060
+ sum += entry;
1058
1061
  }
1059
1062
  return sum;
1060
1063
  }
@@ -1091,7 +1094,6 @@ function mergeIntervals(intervals, w = 5000) {
1091
1094
  // start from the next interval and merge if needed
1092
1095
  for (let i = 1; i < intervals.length; i++) {
1093
1096
  // get the top element
1094
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1095
1097
  top = stack.at(-1);
1096
1098
  // if the current interval doesn't overlap with the
1097
1099
  // stack top element, push it to the stack
@@ -1123,3 +1125,8 @@ exports.gatherOverlaps = gatherOverlaps;
1123
1125
  var simpleFeature_1 = require("./simpleFeature");
1124
1126
  Object.defineProperty(exports, "SimpleFeature", { enumerable: true, get: function () { return __importDefault(simpleFeature_1).default; } });
1125
1127
  Object.defineProperty(exports, "isFeature", { enumerable: true, get: function () { return simpleFeature_1.isFeature; } });
1128
+ function stripAlpha(str) {
1129
+ const c = (0, colord_1.colord)(str);
1130
+ return c.alpha(1).toHex();
1131
+ }
1132
+ exports.stripAlpha = stripAlpha;
@@ -15,7 +15,7 @@ function binaryRangeFetch(url, start, end, options = {}) {
15
15
  const globalRangeCache = new http_range_fetcher_1.HttpRangeFetcher({
16
16
  fetch: binaryRangeFetch,
17
17
  size: 500 * 1024 ** 2,
18
- chunkSize: 128 * 124,
18
+ chunkSize: 128 * 1024,
19
19
  maxFetchSize: 100 * 1024 ** 2,
20
20
  minimumTTL: 24 * 60 * 60 * 1000, // 1 day
21
21
  });
@@ -29,7 +29,7 @@ class RemoteFileWithRangeCache extends generic_filehandle_1.RemoteFile {
29
29
  fetchers[String(url)] = this.fetchBinaryRange.bind(this);
30
30
  }
31
31
  // if it is a range request, route it through the range cache
32
- const requestHeaders = init && init.headers;
32
+ const requestHeaders = init === null || init === void 0 ? void 0 : init.headers;
33
33
  let range;
34
34
  if (requestHeaders) {
35
35
  if (requestHeaders instanceof Headers) {
@@ -53,7 +53,7 @@ class RemoteFileWithRangeCache extends generic_filehandle_1.RemoteFile {
53
53
  const s = Number.parseInt(start, 10);
54
54
  const e = Number.parseInt(end, 10);
55
55
  const response = (await globalRangeCache.getRange(url, s, e - s + 1, {
56
- signal: init && init.signal,
56
+ signal: init === null || init === void 0 ? void 0 : init.signal,
57
57
  }));
58
58
  const { headers } = response;
59
59
  return new Response(response.buffer, { status: 206, headers });
@@ -332,8 +332,7 @@ class GranularRectLayout {
332
332
  const pLeft = Math.floor(left / this.pitchX);
333
333
  const pRight = Math.floor(right / this.pitchX);
334
334
  const { bitmap } = this;
335
- for (let y = 0; y < bitmap.length; y += 1) {
336
- const row = bitmap[y];
335
+ for (const row of bitmap) {
337
336
  if (row) {
338
337
  row.discardRange(pLeft, pRight);
339
338
  }
package/util/map-obj.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  type Obj = Record<string, unknown>;
2
- export default function map(object: Obj, mapper: (val: unknown) => void, isSeen?: WeakSet<object>): void;
2
+ export default function map(object: Obj, mapper: (val: unknown) => void, isSeen?: WeakSet<WeakKey>): void;
3
3
  export {};
@@ -0,0 +1,5 @@
1
+ export const urlAlphabet: "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2
+ export function random(bytes: any): Uint8Array;
3
+ export function customRandom(alphabet: any, defaultSize: any, getRandom: any): (size?: any) => string;
4
+ export function customAlphabet(alphabet: any, size?: number): (size?: any) => string;
5
+ export function nanoid(size?: number): string;
package/util/nanoid.js ADDED
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ // This file replaces `index.js` in bundlers like webpack or Rollup,
3
+ // according to `browser` config in `package.json`.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.nanoid = exports.customAlphabet = exports.customRandom = exports.random = exports.urlAlphabet = void 0;
6
+ // This alphabet uses `A-Za-z0-9_-` symbols.
7
+ // The order of characters is optimized for better gzip and brotli compression.
8
+ // Same as in non-secure/index.js
9
+ exports.urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
10
+ let random = bytes => crypto.getRandomValues(new Uint8Array(bytes));
11
+ exports.random = random;
12
+ let customRandom = (alphabet, defaultSize, getRandom) => {
13
+ // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
14
+ // values closer to the alphabet size. The bitmask calculates the closest
15
+ // `2^31 - 1` number, which exceeds the alphabet size.
16
+ // For example, the bitmask for the alphabet size 30 is 31 (00011111).
17
+ // `Math.clz32` is not used, because it is not available in browsers.
18
+ let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1;
19
+ // Though, the bitmask solution is not perfect since the bytes exceeding
20
+ // the alphabet size are refused. Therefore, to reliably generate the ID,
21
+ // the random bytes redundancy has to be satisfied.
22
+ // Note: every hardware random generator call is performance expensive,
23
+ // because the system call for entropy collection takes a lot of time.
24
+ // So, to avoid additional system calls, extra bytes are requested in advance.
25
+ // Next, a step determines how many random bytes to generate.
26
+ // The number of random bytes gets decided upon the ID size, mask,
27
+ // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
28
+ // according to benchmarks).
29
+ // `-~f => Math.ceil(f)` if f is a float
30
+ // `-~i => i + 1` if i is an integer
31
+ let step = -~((1.6 * mask * defaultSize) / alphabet.length);
32
+ return (size = defaultSize) => {
33
+ let id = '';
34
+ while (true) {
35
+ let bytes = getRandom(step);
36
+ // A compact alternative for `for (var i = 0; i < step; i++)`.
37
+ let j = step;
38
+ while (j--) {
39
+ // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
40
+ id += alphabet[bytes[j] & mask] || '';
41
+ if (id.length === size)
42
+ return id;
43
+ }
44
+ }
45
+ };
46
+ };
47
+ exports.customRandom = customRandom;
48
+ let customAlphabet = (alphabet, size = 21) => (0, exports.customRandom)(alphabet, size, exports.random);
49
+ exports.customAlphabet = customAlphabet;
50
+ let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
51
+ // It is incorrect to use bytes exceeding the alphabet size.
52
+ // The following mask reduces the random byte in the 0-255 value
53
+ // range to the 0-63 value range. Therefore, adding hacks, such
54
+ // as empty string fallback or magic numbers, is unnecessary because
55
+ // the bitmask trims bytes down to the alphabet size.
56
+ byte &= 63;
57
+ if (byte < 36) {
58
+ // `0-9a-z`
59
+ id += byte.toString(36);
60
+ }
61
+ else if (byte < 62) {
62
+ // `A-Z`
63
+ id += (byte - 26).toString(36).toUpperCase();
64
+ }
65
+ else if (byte > 62) {
66
+ id += '-';
67
+ }
68
+ else {
69
+ id += '_';
70
+ }
71
+ return id;
72
+ }, '');
73
+ exports.nanoid = nanoid;
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable react-refresh/only-export-components */
2
3
  // This file is a ponyfill for the HTML5 OffscreenCanvas API.
3
4
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
5
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -25,9 +26,7 @@ const weHave = {
25
26
  };
26
27
  if (weHave.realOffscreenCanvas) {
27
28
  exports.createCanvas = (width, height) => new OffscreenCanvas(width, height);
28
- // eslint-disable-next-line no-restricted-globals
29
29
  exports.createImageBitmap = window.createImageBitmap || self.createImageBitmap;
30
- // eslint-disable-next-line no-restricted-globals
31
30
  exports.ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
32
31
  }
33
32
  else if (weHave.node) {
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ReactRendering = exports.getSerializedSvg = exports.renderToAbstractCanvas = void 0;
30
+ /* eslint-disable react-refresh/only-export-components */
30
31
  const react_1 = __importDefault(require("react"));
31
32
  const canvas_sequencer_1 = require("canvas-sequencer");
32
33
  // locals
package/util/tracks.d.ts CHANGED
@@ -16,12 +16,8 @@ export declare function getParentRenderProps(node: IAnyStateTreeNode): any;
16
16
  export declare const UNKNOWN = "UNKNOWN";
17
17
  export declare const UNSUPPORTED = "UNSUPPORTED";
18
18
  export declare function getBlob(id: string): File;
19
- export declare function getBlobMap(): {
20
- [key: string]: File;
21
- };
22
- export declare function setBlobMap(map: {
23
- [key: string]: File;
24
- }): void;
19
+ export declare function getBlobMap(): Record<string, File>;
20
+ export declare function setBlobMap(map: Record<string, File>): void;
25
21
  export declare function storeBlobLocation(location: PreFileLocation): import("./types").PreUriLocation | import("./types").PreLocalPathLocation | {
26
22
  name: string;
27
23
  blobId: string;
@@ -8,6 +8,7 @@ import { NoAssemblyRegion as MUNoAssemblyRegion, Region as MUIRegion, LocalPathL
8
8
  import RpcManager from '../../rpc/RpcManager';
9
9
  import { Feature } from '../simpleFeature';
10
10
  import { BaseInternetAccountModel } from '../../pluggableElementTypes/models';
11
+ import { ThemeOptions } from '@mui/material';
11
12
  export * from './util';
12
13
  /** abstract type for a model that contains multiple views */
13
14
  export interface AbstractViewContainer extends IStateTreeNode<IType<any, unknown, any>> {
@@ -42,16 +43,25 @@ export interface JBrowsePlugin {
42
43
  export type DialogComponentType = React.LazyExoticComponent<React.FC<any>> | React.FC<any>;
43
44
  /** minimum interface that all session state models must implement */
44
45
  export interface AbstractSessionModel extends AbstractViewContainer {
46
+ jbrowse: IAnyStateTreeNode;
45
47
  drawerPosition?: string;
46
- setSelection(feature: Feature): void;
47
- clearSelection(): void;
48
48
  configuration: AnyConfigurationModel;
49
49
  rpcManager: RpcManager;
50
50
  assemblyNames: string[];
51
51
  assemblies: AnyConfigurationModel[];
52
52
  selection?: unknown;
53
- duplicateCurrentSession?(): void;
54
- notify(message: string, level?: NotificationLevel, action?: SnackAction): void;
53
+ focusedViewId?: string;
54
+ themeName?: string;
55
+ setFocusedViewId?: (id: string) => void;
56
+ allThemes?: () => Record<string, ThemeOptions | undefined>;
57
+ setSelection: (feature: Feature) => void;
58
+ setSession?: (arg: {
59
+ name: string;
60
+ [key: string]: unknown;
61
+ }) => void;
62
+ clearSelection: () => void;
63
+ duplicateCurrentSession?: () => void;
64
+ notify: (message: string, level?: NotificationLevel, action?: SnackAction) => void;
55
65
  assemblyManager: AssemblyManager;
56
66
  version: string;
57
67
  getTrackActionMenuItems?: Function;
@@ -60,13 +70,19 @@ export interface AbstractSessionModel extends AbstractViewContainer {
60
70
  textSearchManager?: TextSearchManager;
61
71
  connections: AnyConfigurationModel[];
62
72
  deleteConnection?: Function;
73
+ temporaryAssemblies?: unknown[];
74
+ addTemporaryAssembly?: (arg: Record<string, unknown>) => void;
75
+ removeTemporaryAssembly?: (arg: string) => void;
63
76
  sessionConnections?: AnyConfigurationModel[];
77
+ sessionTracks?: AnyConfigurationModel[];
64
78
  connectionInstances?: {
65
79
  name: string;
66
80
  tracks: AnyConfigurationModel[];
67
81
  configuration: AnyConfigurationModel;
68
82
  }[];
69
83
  makeConnection?: Function;
84
+ breakConnection?: Function;
85
+ prepareToBreakConnection?: (arg: AnyConfigurationModel) => any;
70
86
  adminMode?: boolean;
71
87
  showWidget?: Function;
72
88
  addWidget?: Function;
@@ -88,6 +104,11 @@ export interface SessionWithConfigEditing extends AbstractSessionModel {
88
104
  addTrackConf(configuration: AnyConfigurationModel | SnapshotIn<AnyConfigurationModel>): void;
89
105
  }
90
106
  export declare function isSessionWithAddTracks(thing: unknown): thing is SessionWithConfigEditing;
107
+ /** abstract interface for a session allows adding tracks */
108
+ export interface SessionWithShareURL extends AbstractSessionModel {
109
+ shareURL: string;
110
+ }
111
+ export declare function isSessionWithShareURL(thing: unknown): thing is SessionWithShareURL;
91
112
  export interface Widget {
92
113
  type: string;
93
114
  id: string;
@@ -134,6 +155,11 @@ export interface SelectionContainer extends AbstractSessionModel {
134
155
  setSelection(thing: unknown): void;
135
156
  }
136
157
  export declare function isSelectionContainer(thing: unknown): thing is SelectionContainer;
158
+ /** abstract interface for a session allows applying focus to views and widgets */
159
+ export interface SessionWithFocusedViewAndDrawerWidgets extends SessionWithDrawerWidgets {
160
+ focusedViewId: string | undefined;
161
+ setFocusedViewId(id: string): void;
162
+ }
137
163
  /** minimum interface that all view state models must implement */
138
164
  export interface AbstractViewModel {
139
165
  id: string;
@@ -211,6 +237,8 @@ export interface LocalPathLocation extends SnapshotIn<typeof MULocalPathLocation
211
237
  export interface UriLocation extends SnapshotIn<typeof MUUriLocation> {
212
238
  }
213
239
  export declare function isUriLocation(location: unknown): location is UriLocation;
240
+ export declare function isLocalPathLocation(location: unknown): location is LocalPathLocation;
241
+ export declare function isBlobLocation(location: unknown): location is BlobLocation;
214
242
  export declare class AuthNeededError extends Error {
215
243
  message: string;
216
244
  url: string;
@@ -226,14 +254,14 @@ export declare function isRetryException(exception: Error): boolean;
226
254
  export interface BlobLocation extends SnapshotIn<typeof MUBlobLocation> {
227
255
  }
228
256
  export type FileLocation = LocalPathLocation | UriLocation | BlobLocation;
229
- export type PreUriLocation = {
257
+ export interface PreUriLocation {
230
258
  uri: string;
231
- };
232
- export type PreLocalPathLocation = {
259
+ }
260
+ export interface PreLocalPathLocation {
233
261
  localPath: string;
234
- };
235
- export type PreBlobLocation = {
262
+ }
263
+ export interface PreBlobLocation {
236
264
  blob: File;
237
- };
265
+ }
238
266
  export type PreFileLocation = PreUriLocation | PreLocalPathLocation | PreBlobLocation;
239
267
  export { type default as TextSearchManager } from '../../TextSearch/TextSearchManager';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isRetryException = exports.isAuthNeededException = exports.RetryError = exports.AuthNeededError = exports.isUriLocation = exports.isAbstractMenuManager = exports.isRootModelWithInternetAccounts = exports.isAppRootModel = exports.isTrackViewModel = exports.isDisplayModel = exports.isTrackModel = exports.isViewModel = exports.isSelectionContainer = exports.isSessionWithSessionPlugins = exports.isSessionModelWithConnectionEditing = exports.isSessionModelWithConnections = exports.isSessionModelWithWidgets = exports.isSessionWithAddTracks = exports.isSessionModelWithConfigEditing = exports.isSessionModel = exports.isViewContainer = void 0;
17
+ exports.isRetryException = exports.isAuthNeededException = exports.RetryError = exports.AuthNeededError = exports.isBlobLocation = exports.isLocalPathLocation = exports.isUriLocation = exports.isAbstractMenuManager = exports.isRootModelWithInternetAccounts = exports.isAppRootModel = exports.isTrackViewModel = exports.isDisplayModel = exports.isTrackModel = exports.isViewModel = exports.isSelectionContainer = exports.isSessionWithSessionPlugins = exports.isSessionModelWithConnectionEditing = exports.isSessionModelWithConnections = exports.isSessionModelWithWidgets = exports.isSessionWithShareURL = exports.isSessionWithAddTracks = exports.isSessionModelWithConfigEditing = exports.isSessionModel = exports.isViewContainer = void 0;
18
18
  const mobx_state_tree_1 = require("mobx-state-tree");
19
19
  __exportStar(require("./util"), exports);
20
20
  function isViewContainer(thing) {
@@ -41,6 +41,10 @@ function isSessionWithAddTracks(thing) {
41
41
  isSessionModel(thing) && 'addTrackConf' in thing && !thing.disableAddTracks);
42
42
  }
43
43
  exports.isSessionWithAddTracks = isSessionWithAddTracks;
44
+ function isSessionWithShareURL(thing) {
45
+ return isSessionModel(thing) && 'shareURL' in thing && !!thing.shareURL;
46
+ }
47
+ exports.isSessionWithShareURL = isSessionWithShareURL;
44
48
  function isSessionModelWithWidgets(thing) {
45
49
  return isSessionModel(thing) && 'widgets' in thing;
46
50
  }
@@ -122,6 +126,20 @@ function isUriLocation(location) {
122
126
  !!location.uri);
123
127
  }
124
128
  exports.isUriLocation = isUriLocation;
129
+ function isLocalPathLocation(location) {
130
+ return (typeof location === 'object' &&
131
+ location !== null &&
132
+ 'localPath' in location &&
133
+ !!location.localPath);
134
+ }
135
+ exports.isLocalPathLocation = isLocalPathLocation;
136
+ function isBlobLocation(location) {
137
+ return (typeof location === 'object' &&
138
+ location !== null &&
139
+ 'blobId' in location &&
140
+ !!location.blobId);
141
+ }
142
+ exports.isBlobLocation = isBlobLocation;
125
143
  class AuthNeededError extends Error {
126
144
  constructor(message, url) {
127
145
  super(message);
package/util/types/mst.js CHANGED
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FileLocation = exports.UriLocation = exports.UriLocationRaw = exports.BlobLocation = exports.LocalPathLocation = exports.Region = exports.NoAssemblyRegion = exports.PropTypes = exports.ElementId = void 0;
7
- const shortid_1 = __importDefault(require("shortid"));
8
7
  const mobx_state_tree_1 = require("mobx-state-tree");
9
8
  const prop_types_1 = __importDefault(require("prop-types"));
10
9
  const mobx_react_1 = require("mobx-react");
11
- exports.ElementId = mobx_state_tree_1.types.optional(mobx_state_tree_1.types.identifier, shortid_1.default.generate);
10
+ const nanoid_1 = require("../nanoid");
11
+ exports.ElementId = mobx_state_tree_1.types.optional(mobx_state_tree_1.types.identifier, () => (0, nanoid_1.nanoid)());
12
12
  // PropTypes that are useful when working with instances of these in react components
13
13
  exports.PropTypes = {
14
14
  Region: prop_types_1.default.shape({