gosling.js 0.14.0 → 0.16.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 (69) hide show
  1. package/dist/editor/example/json-spec/basic-semantic-zoom.d.ts +3 -0
  2. package/dist/editor/example/json-spec/basic-semantic-zoom.d.ts.map +1 -0
  3. package/dist/editor/example/json-spec/cancer-variant.d.ts +5 -0
  4. package/dist/editor/example/json-spec/cancer-variant.d.ts.map +1 -0
  5. package/dist/editor/example/json-spec/circos.d.ts +5 -0
  6. package/dist/editor/example/json-spec/circos.d.ts.map +1 -0
  7. package/dist/editor/example/json-spec/circular-overview-linear-detail-views.d.ts +3 -0
  8. package/dist/editor/example/json-spec/circular-overview-linear-detail-views.d.ts.map +1 -0
  9. package/dist/editor/example/json-spec/debug.d.ts +3 -0
  10. package/dist/editor/example/json-spec/debug.d.ts.map +1 -0
  11. package/dist/editor/example/json-spec/gene-annotation.d.ts +14 -0
  12. package/dist/editor/example/json-spec/gene-annotation.d.ts.map +1 -0
  13. package/dist/editor/example/json-spec/gene-transcript.d.ts +3 -0
  14. package/dist/editor/example/json-spec/gene-transcript.d.ts.map +1 -0
  15. package/dist/editor/example/json-spec/give.d.ts +3 -0
  16. package/dist/editor/example/json-spec/give.d.ts.map +1 -0
  17. package/dist/editor/example/json-spec/gosling-data.d.ts +17 -0
  18. package/dist/editor/example/json-spec/gosling-data.d.ts.map +1 -0
  19. package/dist/editor/example/json-spec/gremlin.d.ts +3 -0
  20. package/dist/editor/example/json-spec/gremlin.d.ts.map +1 -0
  21. package/dist/editor/example/json-spec/ideograms.d.ts +4 -0
  22. package/dist/editor/example/json-spec/ideograms.d.ts.map +1 -0
  23. package/dist/editor/example/json-spec/index.d.ts +35 -0
  24. package/dist/editor/example/json-spec/index.d.ts.map +1 -0
  25. package/dist/editor/example/json-spec/layout-and-arrangement.d.ts +6 -0
  26. package/dist/editor/example/json-spec/layout-and-arrangement.d.ts.map +1 -0
  27. package/dist/editor/example/json-spec/mark-displacement.d.ts +3 -0
  28. package/dist/editor/example/json-spec/mark-displacement.d.ts.map +1 -0
  29. package/dist/editor/example/json-spec/matrix-hffc6.d.ts +3 -0
  30. package/dist/editor/example/json-spec/matrix-hffc6.d.ts.map +1 -0
  31. package/dist/editor/example/json-spec/matrix.d.ts +4 -0
  32. package/dist/editor/example/json-spec/matrix.d.ts.map +1 -0
  33. package/dist/editor/example/json-spec/mouse-event.d.ts +4 -0
  34. package/dist/editor/example/json-spec/mouse-event.d.ts.map +1 -0
  35. package/dist/editor/example/json-spec/pathogenic.d.ts +4 -0
  36. package/dist/editor/example/json-spec/pathogenic.d.ts.map +1 -0
  37. package/dist/editor/example/json-spec/perf-alignment.d.ts +3 -0
  38. package/dist/editor/example/json-spec/perf-alignment.d.ts.map +1 -0
  39. package/dist/editor/example/json-spec/pileup.d.ts +4 -0
  40. package/dist/editor/example/json-spec/pileup.d.ts.map +1 -0
  41. package/dist/editor/example/json-spec/responsive-alignment.d.ts +24 -0
  42. package/dist/editor/example/json-spec/responsive-alignment.d.ts.map +1 -0
  43. package/dist/editor/example/json-spec/responsive-track-wise-comparison.d.ts +4 -0
  44. package/dist/editor/example/json-spec/responsive-track-wise-comparison.d.ts.map +1 -0
  45. package/dist/editor/example/json-spec/responsive.d.ts +7 -0
  46. package/dist/editor/example/json-spec/responsive.d.ts.map +1 -0
  47. package/dist/editor/example/json-spec/sars-cov-2.d.ts +4 -0
  48. package/dist/editor/example/json-spec/sars-cov-2.d.ts.map +1 -0
  49. package/dist/editor/example/json-spec/semantic-zoom.d.ts +9 -0
  50. package/dist/editor/example/json-spec/semantic-zoom.d.ts.map +1 -0
  51. package/dist/editor/example/json-spec/track-template.d.ts +3 -0
  52. package/dist/editor/example/json-spec/track-template.d.ts.map +1 -0
  53. package/dist/editor/example/json-spec/visual-linking.d.ts +3 -0
  54. package/dist/editor/example/json-spec/visual-linking.d.ts.map +1 -0
  55. package/dist/editor/example/spec/visual-encoding.d.ts +5 -0
  56. package/dist/editor/example/spec/visual-encoding.d.ts.map +1 -0
  57. package/dist/{exported-utils-d4f1abea.js → exported-utils-ac60e3c5.js} +11 -7
  58. package/dist/exported-utils-ac60e3c5.js.map +1 -0
  59. package/dist/gosling.js +75 -52
  60. package/dist/gosling.js.map +1 -1
  61. package/dist/src/core/gosling-component.d.ts +1 -1
  62. package/dist/src/core/gosling-component.d.ts.map +1 -1
  63. package/dist/src/core/gosling-component.test.d.ts +2 -0
  64. package/dist/src/core/gosling-component.test.d.ts.map +1 -0
  65. package/dist/src/core/mark/bar.d.ts.map +1 -1
  66. package/dist/src/tracks/gosling-track/gosling-track.d.ts.map +1 -1
  67. package/dist/utils.js +1 -1
  68. package/package.json +5 -5
  69. package/dist/exported-utils-d4f1abea.js.map +0 -1
package/dist/gosling.js CHANGED
@@ -34,7 +34,7 @@ import "bezier-js";
34
34
  import { scaleLinear, scaleSequential, scaleOrdinal, scaleBand } from "d3-scale";
35
35
  import { sampleSize, isEqual, uniqBy, cloneDeepWith } from "lodash-es";
36
36
  import { interpolateViridis } from "d3-scale-chromatic";
37
- import { A as Ajv, I as IsChannelDeep, r as resolveSuperposedTracks, t as traverseTracks, a as IsTemplateTrack, g as getTextStyle, c as computeChromSizes, b as cartesianToPolar, u as uuid, R as RADIAN_GAP, v as valueToRadian, p as pointsToDegree, d as commonjsGlobal, e as RemoteFile, f as IsOneOfFilter, h as IsRangeFilter, i as IsIncludeFilter, j as getChannelKeysByAggregateFnc, k as getChannelKeysByType, s as sanitizeChrName, l as filterUsingGenoPos, m as IsDataDeepTileset, n as IsDomainChr, o as IsDomainInterval, q as IsDomainChrInterval, S as SUPPORTED_CHANNELS, w as insertItemToArray, x as getAutoCompleteId, y as IsChannelValue, z as getValueUsingChannel, B as rectProperty, C as pointProperty, D as barProperty, E as IsStackedChannel, F as IsDomainArray, P as PREDEFINED_COLOR_STR_MAP, G as IsRangeArray, H as Is2DTrack, J as isTabularDataFetcher, K as drawPreEmbellishment, L as drawMark, M as drawPostEmbellishment, N as getRelativeGenomicPosition, O as hasDataTransform, Q as IsXAxis, T as IsMouseEventsDeep, U as colorToHex, V as flatArrayToPairArray, W as DEWFAULT_TITLE_PADDING_ON_TOP_AND_BOTTOM, X as traverseTracksAndViews, Y as traverseViewArrangements, Z as DEFAULT_VIEW_SPACING, _ as DEFAULT_INNER_RADIUS_PROP, $ as IsDummyTrack, a0 as IsOverlaidTrack, a1 as IsYAxis, a2 as DEFAULT_CIRCULAR_VIEW_PADDING, a3 as IsDataDeep, a4 as IsHiGlassMatrix, a5 as getHiGlassColorRange, a6 as DEFAULT_TEXT_STYLE, a7 as overrideDataTemplates, a8 as traverseToFixSpecDownstream, a9 as GenomicPositionHelper, aa as isObject } from "./exported-utils-d4f1abea.js";
37
+ import { A as Ajv, I as IsChannelDeep, r as resolveSuperposedTracks, t as traverseTracks, a as IsTemplateTrack, g as getTextStyle, c as computeChromSizes, b as cartesianToPolar, u as uuid, R as RADIAN_GAP, v as valueToRadian, p as pointsToDegree, d as commonjsGlobal, e as RemoteFile, f as IsOneOfFilter, h as IsRangeFilter, i as IsIncludeFilter, j as getChannelKeysByAggregateFnc, k as getChannelKeysByType, s as sanitizeChrName, l as filterUsingGenoPos, m as IsDataDeepTileset, n as IsDomainChr, o as IsDomainInterval, q as IsDomainChrInterval, S as SUPPORTED_CHANNELS, w as insertItemToArray, x as getAutoCompleteId, y as IsChannelValue, z as getValueUsingChannel, B as rectProperty, C as pointProperty, D as barProperty, E as IsStackedChannel, F as IsDomainArray, P as PREDEFINED_COLOR_STR_MAP, G as IsRangeArray, H as Is2DTrack, J as isTabularDataFetcher, K as drawPreEmbellishment, L as drawMark, M as drawPostEmbellishment, N as getRelativeGenomicPosition, O as hasDataTransform, Q as IsXAxis, T as IsMouseEventsDeep, U as colorToHex, V as flatArrayToPairArray, W as DEWFAULT_TITLE_PADDING_ON_TOP_AND_BOTTOM, X as traverseTracksAndViews, Y as traverseViewArrangements, Z as DEFAULT_VIEW_SPACING, _ as DEFAULT_INNER_RADIUS_PROP, $ as IsDummyTrack, a0 as IsOverlaidTrack, a1 as IsYAxis, a2 as DEFAULT_CIRCULAR_VIEW_PADDING, a3 as IsDataDeep, a4 as IsHiGlassMatrix, a5 as getHiGlassColorRange, a6 as DEFAULT_TEXT_STYLE, a7 as overrideDataTemplates, a8 as traverseToFixSpecDownstream, a9 as GenomicPositionHelper, aa as isObject } from "./exported-utils-ac60e3c5.js";
38
38
  import higlassRegister from "higlass-register";
39
39
  import { TextTrack } from "higlass-text";
40
40
  import RBush from "rbush";
@@ -52,7 +52,7 @@ import require$$0 from "react-dom";
52
52
  import { HiGlassComponent } from "higlass";
53
53
  import { ResizeSensor } from "css-element-queries";
54
54
  const name = "gosling.js";
55
- const version = "0.14.0";
55
+ const version = "0.16.0";
56
56
  const $ref$2 = "#/definitions/GoslingSpec";
57
57
  const $schema$2 = "http://json-schema.org/draft-07/schema#";
58
58
  const definitions$2 = {
@@ -23764,7 +23764,7 @@ class GoslingTrackModel {
23764
23764
  this.theme = theme != null ? theme : getTheme();
23765
23765
  this.dataAggregated = data;
23766
23766
  this.specOriginal = spec;
23767
- this.specComplete = structuredClone(spec);
23767
+ this.specComplete = JSON.parse(JSON.stringify(spec));
23768
23768
  this.channelScales = {};
23769
23769
  this.mouseEventModel = new MouseEventModel();
23770
23770
  const validity = this.validateSpec();
@@ -24432,7 +24432,7 @@ const config$1 = {
24432
24432
  }
24433
24433
  };
24434
24434
  const factory$1 = (HGC, context, options) => {
24435
- var _assembly2, _processedTileInfo, _mouseDownX, _mouseDownY, _isRangeBrushActivated, _gBrush, _loadingTextStyleObj, _loadingTextBg, _loadingText, _tilesToId, tilesToId_fn, _binsPerTile, binsPerTile_get, _generateTabularData, generateTabularData_fn, _onMouseDown, onMouseDown_fn, _onMouseMove, onMouseMove_fn, _onMouseUp, onMouseUp_fn, _onMouseOut, onMouseOut_fn, _getElementsWithinMouse, getElementsWithinMouse_fn, _publishTrackEvents, publishTrackEvents_fn, _onRangeBrush, onRangeBrush_fn, _highlightMarks, highlightMarks_fn, _publishOnNewTrack, publishOnNewTrack_fn, _hasStretchableGraphics, hasStretchableGraphics_fn, _isTooStretched, isTooStretched_fn;
24435
+ var _assembly2, _processedTileInfo, _mouseDownX, _mouseDownY, _isRangeBrushActivated, _gBrush, _loadingTextStyleObj, _loadingTextBg, _loadingText, _processedTileMap, _tilesToId, tilesToId_fn, _binsPerTile, binsPerTile_get, _generateTabularData, generateTabularData_fn, _onMouseDown, onMouseDown_fn, _onMouseMove, onMouseMove_fn, _onMouseUp, onMouseUp_fn, _onMouseOut, onMouseOut_fn, _getElementsWithinMouse, getElementsWithinMouse_fn, _publishTrackEvents, publishTrackEvents_fn, _onRangeBrush, onRangeBrush_fn, _highlightMarks, highlightMarks_fn, _publishOnNewTrack, publishOnNewTrack_fn, _hasStretchableGraphics, hasStretchableGraphics_fn, _isTooStretched, isTooStretched_fn;
24436
24436
  const { tileProxy } = HGC.services;
24437
24437
  const { BarTrack } = HGC.tracks;
24438
24438
  const loadingTextStyle = getTextStyle({ color: "black", size: 12 });
@@ -24523,6 +24523,8 @@ const factory$1 = (HGC, context, options) => {
24523
24523
  __privateAdd(this, _loadingText, new HGC.libraries.PIXI.Text("", loadingTextStyle));
24524
24524
  __publicField(this, "prevVisibleAndFetchedTiles");
24525
24525
  __publicField(this, "resolvedTracks");
24526
+ // This is used to persist processed tile data across draw() calls.
24527
+ __privateAdd(this, _processedTileMap, /* @__PURE__ */ new WeakMap());
24526
24528
  __publicField(this, "hideMousePosition");
24527
24529
  context.dataFetcher.track = this;
24528
24530
  __privateSet(this, _processedTileInfo, {});
@@ -24679,6 +24681,7 @@ const factory$1 = (HGC, context, options) => {
24679
24681
  this.getResolvedTracks(true);
24680
24682
  this.clearMouseEventData();
24681
24683
  this.textsBeingUsed = 0;
24684
+ __privateSet(this, _processedTileMap, /* @__PURE__ */ new WeakMap());
24682
24685
  this.processAllTiles(true);
24683
24686
  this.draw();
24684
24687
  this.forceDraw();
@@ -24764,7 +24767,7 @@ const factory$1 = (HGC, context, options) => {
24764
24767
  setMask(position, dimensions) {
24765
24768
  this.pMask.clear();
24766
24769
  this.pMask.beginFill();
24767
- if (this.options.spec.layout === "circular") {
24770
+ if (this.options.spec.layout === "circular" && this.options.spec.overlayOnPreviousTrack) {
24768
24771
  const [x, y] = this.position;
24769
24772
  const [width, height] = this.dimensions;
24770
24773
  const cx = x + width / 2;
@@ -24790,6 +24793,9 @@ const factory$1 = (HGC, context, options) => {
24790
24793
  var _a, _b;
24791
24794
  this.tileSize = (_b = (_a = this.tilesetInfo) == null ? void 0 : _a.tile_size) != null ? _b : 1024;
24792
24795
  const tiles = this.visibleAndFetchedTiles();
24796
+ if (tiles.every((tile) => __privateGet(this, _processedTileMap).get(tile) !== void 0)) {
24797
+ return;
24798
+ }
24793
24799
  tiles.forEach((tile) => __privateMethod(this, _generateTabularData, generateTabularData_fn).call(this, tile, force));
24794
24800
  this.combineAllTilesIfNeeded();
24795
24801
  const models = tiles.flatMap((tile) => this.transformDataAndCreateModels(tile));
@@ -24798,6 +24804,9 @@ const factory$1 = (HGC, context, options) => {
24798
24804
  if (flatTileData.length !== 0) {
24799
24805
  this.options.siblingIds.forEach((id) => publish("rawData", { id, data: flatTileData }));
24800
24806
  }
24807
+ tiles.forEach((tile) => {
24808
+ __privateGet(this, _processedTileMap).set(tile, true);
24809
+ });
24801
24810
  }
24802
24811
  /**
24803
24812
  * This is currently for testing the new way of rendering visual elements. Called by this.draw()
@@ -25076,7 +25085,7 @@ const factory$1 = (HGC, context, options) => {
25076
25085
  } catch (e) {
25077
25086
  }
25078
25087
  const [trackWidth, trackHeight] = this.dimensions;
25079
- const axisSize = IsXAxis(resolvedSpec) ? HIGLASS_AXIS_SIZE : 0;
25088
+ const axisSize = IsXAxis(resolvedSpec) && this.options.spec.layout === "linear" ? HIGLASS_AXIS_SIZE : 0;
25080
25089
  const [w, h] = [trackWidth, trackHeight + axisSize];
25081
25090
  const circularFactor = Math.min(w, h) / Math.min(resolvedSpec.width, resolvedSpec.height);
25082
25091
  if (resolvedSpec.innerRadius) {
@@ -25248,6 +25257,7 @@ const factory$1 = (HGC, context, options) => {
25248
25257
  _loadingTextStyleObj = new WeakMap();
25249
25258
  _loadingTextBg = new WeakMap();
25250
25259
  _loadingText = new WeakMap();
25260
+ _processedTileMap = new WeakMap();
25251
25261
  _tilesToId = new WeakSet();
25252
25262
  tilesToId_fn = function(xTiles, yTiles, zoomLevel) {
25253
25263
  if (!yTiles) {
@@ -26535,6 +26545,7 @@ const DELAY_FOR_CONTAINER_RESIZE_BEFORE_RERENDER = 300;
26535
26545
  const GoslingComponent = forwardRef((props, ref) => {
26536
26546
  var _a, _b, _c;
26537
26547
  const [viewConfig, setViewConfig] = useState();
26548
+ const [isInitialRender, setIsInitialRender] = useState(true);
26538
26549
  const [size, setSize] = useState({ width: 200, height: 200 });
26539
26550
  const wrapperSize = useRef();
26540
26551
  const wrapperParentSize = useRef();
@@ -26563,51 +26574,55 @@ const GoslingComponent = forwardRef((props, ref) => {
26563
26574
  },
26564
26575
  [viewConfig, theme]
26565
26576
  );
26566
- const compile$1 = useCallback(() => {
26567
- if (props.spec) {
26568
- const valid = validateGoslingSpec(props.spec);
26569
- if (valid.state === "error") {
26570
- console.warn("Gosling spec is not valid. Please refer to the console message.");
26571
- return;
26577
+ const compile$1 = useCallback(
26578
+ (altSpec) => {
26579
+ const spec = altSpec != null ? altSpec : props.spec;
26580
+ if (spec) {
26581
+ const valid = validateGoslingSpec(spec);
26582
+ if (valid.state === "error") {
26583
+ console.warn("Gosling spec is not valid. Please refer to the console message.");
26584
+ return;
26585
+ }
26586
+ compile(
26587
+ spec,
26588
+ (newHiGlassSpec, newSize, newGoslingSpec, newTracksAndViews, newIdTable) => {
26589
+ var _a2, _b2;
26590
+ if (prevSpec.current && isEqual(omitDeep(prevSpec.current, ["linkingId"]), omitDeep(newGoslingSpec, ["linkingId"]))) {
26591
+ return;
26592
+ }
26593
+ (_a2 = props.compiled) == null ? void 0 : _a2.call(props, spec, newHiGlassSpec, { _processedSpec: newGoslingSpec });
26594
+ setSize(newSize);
26595
+ const isMountedOnce = typeof viewConfig !== "undefined";
26596
+ if (((_b2 = props.experimental) == null ? void 0 : _b2.reactive) && isMountedOnce) {
26597
+ setTimeout(() => {
26598
+ var _a3, _b3;
26599
+ preverseZoomStatus(
26600
+ newHiGlassSpec,
26601
+ (_a3 = hgRef.current) == null ? void 0 : _a3.api.getViewConfig()
26602
+ );
26603
+ (_b3 = hgRef.current) == null ? void 0 : _b3.api.setViewConfig(newHiGlassSpec);
26604
+ }, DELAY_FOR_CONTAINER_RESIZE_BEFORE_RERENDER);
26605
+ } else {
26606
+ setViewConfig(newHiGlassSpec);
26607
+ }
26608
+ publishOnNewView(newTracksAndViews);
26609
+ prevSpec.current = newGoslingSpec;
26610
+ tracksAndViews.current = newTracksAndViews;
26611
+ idTable.current = newIdTable;
26612
+ },
26613
+ [...GoslingTemplates],
26614
+ // TODO: allow user definitions
26615
+ theme,
26616
+ {
26617
+ containerSize: wrapperSize.current,
26618
+ containerParentSize: wrapperParentSize.current
26619
+ },
26620
+ props.urlToFetchOptions
26621
+ );
26572
26622
  }
26573
- compile(
26574
- props.spec,
26575
- (newHiGlassSpec, newSize, newGoslingSpec, newTracksAndViews, newIdTable) => {
26576
- var _a2, _b2;
26577
- if (prevSpec.current && isEqual(omitDeep(prevSpec.current, ["linkingId"]), omitDeep(newGoslingSpec, ["linkingId"]))) {
26578
- return;
26579
- }
26580
- (_a2 = props.compiled) == null ? void 0 : _a2.call(props, props.spec, newHiGlassSpec, { _processedSpec: newGoslingSpec });
26581
- setSize(newSize);
26582
- const isMountedOnce = typeof viewConfig !== "undefined";
26583
- if (((_b2 = props.experimental) == null ? void 0 : _b2.reactive) && isMountedOnce) {
26584
- setTimeout(() => {
26585
- var _a3, _b3;
26586
- preverseZoomStatus(
26587
- newHiGlassSpec,
26588
- (_a3 = hgRef.current) == null ? void 0 : _a3.api.getViewConfig()
26589
- );
26590
- (_b3 = hgRef.current) == null ? void 0 : _b3.api.setViewConfig(newHiGlassSpec);
26591
- }, DELAY_FOR_CONTAINER_RESIZE_BEFORE_RERENDER);
26592
- } else {
26593
- setViewConfig(newHiGlassSpec);
26594
- }
26595
- publishOnNewView(newTracksAndViews);
26596
- prevSpec.current = newGoslingSpec;
26597
- tracksAndViews.current = newTracksAndViews;
26598
- idTable.current = newIdTable;
26599
- },
26600
- [...GoslingTemplates],
26601
- // TODO: allow user definitions
26602
- theme,
26603
- {
26604
- containerSize: wrapperSize.current,
26605
- containerParentSize: wrapperParentSize.current
26606
- },
26607
- props.urlToFetchOptions
26608
- );
26609
- }
26610
- }, [props.spec, theme]);
26623
+ },
26624
+ [props.spec, theme]
26625
+ );
26611
26626
  useEffect(() => {
26612
26627
  var _a2;
26613
26628
  if (!((_a2 = props.spec) == null ? void 0 : _a2.responsiveSize))
@@ -26636,8 +26651,16 @@ const GoslingComponent = forwardRef((props, ref) => {
26636
26651
  };
26637
26652
  });
26638
26653
  useEffect(() => {
26639
- compile$1();
26640
- }, [props.spec, theme]);
26654
+ if (isInitialRender) {
26655
+ compile$1({
26656
+ title: " ",
26657
+ tracks: [{}]
26658
+ });
26659
+ setIsInitialRender(false);
26660
+ } else {
26661
+ compile$1();
26662
+ }
26663
+ }, [props.spec, theme, isInitialRender]);
26641
26664
  const responsiveHeight = typeof ((_b = props.spec) == null ? void 0 : _b.responsiveSize) !== "object" ? (_c = props.spec) == null ? void 0 : _c.responsiveSize : props.spec.responsiveSize.height;
26642
26665
  const higlassComponent = useMemo(
26643
26666
  () => {