Skip to content

Commit

Permalink
commonjs && esnext
Browse files Browse the repository at this point in the history
  • Loading branch information
bioinsilico committed Oct 27, 2023
1 parent f351da4 commit 2a39a55
Show file tree
Hide file tree
Showing 31 changed files with 113 additions and 106 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ build
# intellij
.idea
*.iml
/lib/
/tsconfig.tsbuildinfo
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@
"description": "RCSB 1D Feature Viewer",
"main": "build/RcsbFv.js",
"files": [
"build/RcsbFv.js",
"build/*ts",
"build/**/*ts",
"build/**/**/*ts",
"build/**/**/**/*ts",
"lib/",
"build/rcsb-saguaro.js"
],
"scripts": {
"devServer": "webpack-dev-server --config webpack.server.dev.config.js",
"build": "webpack --config ./webpack.config.js",
"buildApp": "npm run build",
"buildApp": "npm run build-tsc && npm run build-commonjs && npm run build",
"buildAll": "npm run buildApp && npm run buildAllDoc",
"buildDoc": "typedoc --excludeExternals --externalPattern \"**/node_modules/**\" ./src/RcsbFv.ts && sed -i '' '/---/d' docs/index.html",
"cpExamples": "ncp examples docs/examples",
"buildAllDoc": "npm run buildDoc && npm run cpExamples",
"packApp": "npm run buildApp && npm pack",
"publishApp": "npm publish --tag development",
"build-tsc": "tsc --incremental",
"build-commonjs": "tsc --build tsconfig.commonjs.json --incremental",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand Down
10 changes: 5 additions & 5 deletions src/RcsbBoard/RcsbBoard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {zoom, ZoomBehavior, ZoomedElementBaseType, zoomIdentity, ZoomTransform} from "d3-zoom";
import {zoom, ZoomBehavior, zoomIdentity, ZoomTransform} from "d3-zoom";

import {
MainGConfInterface,
Expand Down Expand Up @@ -69,7 +69,7 @@ export class RcsbBoard {
private upToDate: boolean = true;
private isIntersecting: boolean = true;

private zoomEventHandler:ZoomBehavior<ZoomedElementBaseType, any> = zoom();
private zoomEventHandler:ZoomBehavior<Element, any> = zoom();

private mouseoverCallBack: Array<()=>void> = new Array<()=> void>();
private mouseoutCallBack: Array<()=>void> = new Array<()=> void>();
Expand Down Expand Up @@ -276,7 +276,7 @@ export class RcsbBoard {

private startTracks(): void{
this.tracks.forEach(track=>{
track.init(this._width, this._xScale);
track.init(this._xScale);
});
this.setBoardHeight();
this.tracks.forEach((track)=> {
Expand All @@ -285,11 +285,11 @@ export class RcsbBoard {

}

private updateBoard(): void{
/*private updateBoard(): void{
this.tracks.forEach((track)=> {
track.update();
})
}
}*/

public reset(): void{
this.tracks = new Array<RcsbDisplayInterface>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {Selection, BaseType, select} from "d3-selection";
import {ScaleLinear} from "d3-scale";
import {RcsbD3Constants} from "../RcsbD3Constants";
import {RcsbFvTrackDataElementInterface} from "../../../RcsbDataManager/RcsbDataManager";
import {LineDecoratorInterface} from "./RcsbD3BlockManager";
import {RcsbScaleInterface} from "../RcsbD3ScaleFactory";

export interface PlotBondInterface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Selection} from "d3-selection";
import {Line} from "d3-shape";
import {RcsbD3Constants} from "../RcsbD3Constants";
import {RcsbFvTrackDataElementInterface} from "../../../RcsbDataManager/RcsbDataManager";
import {ClearAreaInterface} from "./RcsbD3AreaManager";

export interface PlotLineInterface {
points: RcsbFvTrackDataElementInterface[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Selection, BaseType, select} from "d3-selection";
import {ScaleLinear} from "d3-scale";
import {RcsbD3Constants} from "../RcsbD3Constants";
import {RcsbFvTrackDataElementInterface} from "../../../RcsbDataManager/RcsbDataManager";
import {RcsbScaleInterface} from "../RcsbD3ScaleFactory";
Expand Down
6 changes: 3 additions & 3 deletions src/RcsbBoard/RcsbD3/RcsbD3Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class RcsbD3Manager {

private _dom: Selection<HTMLElement | null, any, null, undefined>;
private _svg: Selection<SVGSVGElement, any, null, undefined>;
private _zoomG: Selection<SVGGElement, any, null, undefined>;
private _zoomG: Selection<Element, any, null, undefined>;
private _svgG: Selection<SVGGElement, any, null, undefined>;
private _pane: Selection<SVGRectElement, any, null, undefined>;
private _trackHeightPosition: number = 0;
Expand All @@ -81,7 +81,7 @@ export class RcsbD3Manager {
return this._svgG;
}

zoomG(): Selection<SVGGElement, any, null, undefined> {
zoomG(): Selection<Element, any, null, undefined> {
return this._zoomG;
}

Expand Down Expand Up @@ -119,7 +119,7 @@ export class RcsbD3Manager {
}

addMainG(config: MainGConfInterface): void {
this._zoomG = this._svg.append<SVGGElement>(RcsbD3Constants.G);
this._zoomG = this._svg.append<Element>(RcsbD3Constants.G);
this._svgG = this._zoomG.attr(RcsbD3Constants.CLASS, config.masterClass)
.append<SVGGElement>(RcsbD3Constants.G)
.attr(RcsbD3Constants.CLASS, config.innerClass)
Expand Down
26 changes: 12 additions & 14 deletions src/RcsbBoard/RcsbDisplay/RcsbAbstractDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ import {RcsbTooltipManager} from "../RcsbTooltip/RcsbTooltipManager";
import {EventType} from "../../RcsbFv/RcsbFvContextManager/RcsbFvContextManager";
import {RcsbDisplayInterface} from "./RcsbDisplayInterface";

export abstract class RcsbAbstractDisplay extends RcsbAbstractTrack implements RcsbDisplayInterface{
export abstract class RcsbAbstractDisplay extends RcsbAbstractTrack implements RcsbDisplayInterface {

protected _displayColor: string | RcsbFvColorGradient = "#FF6666";
private elementClickCallBack: (d?:RcsbFvTrackDataElementInterface, e?:MouseEvent)=>void;
private elementEnterCallBack: (d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void;
private elementLeaveCallBack: (d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void;
private highlightEnterElement: (d?:RcsbFvTrackDataElementInterface)=>void;
private highlightLeaveElement: (d?:RcsbFvTrackDataElementInterface)=>void;
private elementClickCallBack: (d:RcsbFvTrackDataElementInterface, e?:MouseEvent)=>void;
private elementEnterCallBack: (d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void;
private elementLeaveCallBack: (d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void;
private highlightEnterElement: (d:RcsbFvTrackDataElementInterface)=>void;
private highlightLeaveElement: (d:RcsbFvTrackDataElementInterface)=>void;
protected includeTooltip: boolean = true;
private readonly boardId: string;
private readonly trackId: string;
protected tooltipManager: RcsbTooltipManager;
protected minRatio: number = 0;
Expand All @@ -33,28 +32,27 @@ export abstract class RcsbAbstractDisplay extends RcsbAbstractTrack implements R

constructor(boardId: string, trackId: string) {
super();
this.boardId = boardId;
this.trackId = trackId;
this.tooltipManager = new RcsbTooltipManager(boardId);
}

setElementClickCallBack(f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void): void{
setElementClickCallBack(f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void): void{
this.elementClickCallBack = f;
}

getElementClickCallBack(): (d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void{
getElementClickCallBack(): (d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void{
return this.elementClickCallBack;
}

setElementEnterCallBack(f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void): void{
setElementEnterCallBack(f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void): void{
this.elementEnterCallBack = f;
}

getElementEnterCallBack(): (d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void{
getElementEnterCallBack(): (d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void{
return this.elementEnterCallBack;
}

setElementLeaveCallBack(f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void): void{
setElementLeaveCallBack(f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void): void{
this.elementLeaveCallBack = f;
}

Expand Down Expand Up @@ -82,7 +80,7 @@ export abstract class RcsbAbstractDisplay extends RcsbAbstractTrack implements R
this.g.selectAll("."+classes.rcsbElement).remove();
}

public setHighlightHoverElement(enter: (d?:RcsbFvTrackDataElementInterface)=>void, leave: (d?:RcsbFvTrackDataElementInterface)=>void){
public setHighlightHoverElement(enter: (d:RcsbFvTrackDataElementInterface)=>void, leave: (d:RcsbFvTrackDataElementInterface)=>void){
this.highlightEnterElement = enter;
this.highlightLeaveElement = leave;
}
Expand Down
6 changes: 2 additions & 4 deletions src/RcsbBoard/RcsbDisplay/RcsbAbstractTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export abstract class RcsbAbstractTrack {
protected contextManager: RcsbFvContextManager;
private _bgColor: string = "#FFFFFF";
private _height: number;
private _width: number;
private _data: RcsbFvTrackData;
protected updateDataOnMove:(d:LocationViewInterface)=>Promise<RcsbFvTrackData>;
protected xScale: RcsbScaleInterface;
Expand All @@ -46,8 +45,7 @@ export abstract class RcsbAbstractTrack {
return this._bgColor;
}

init(width: number, scale:RcsbScaleInterface, compositeFlag?: boolean, compositeHeight?: number): void{
this._width = width;
init(scale:RcsbScaleInterface, compositeFlag?: boolean, compositeHeight?: number): void{
this.xScale = scale;
if(this.g != null) {
this.g.remove();
Expand Down Expand Up @@ -109,7 +107,7 @@ export abstract class RcsbAbstractTrack {
highlightRegion(d:Array<RcsbFvTrackDataElementInterface>|null, options?:{color?:string, rectClass?: string;}): void {
const height: number = this._height;
const xScale: RcsbScaleInterface = this.xScale;
if(typeof(height)==="number" && d!= null ) {
if(d != null ) {
const highlightRegConfig: HighlightRegionInterface = {
trackG: this.g,
height: height,
Expand Down
1 change: 0 additions & 1 deletion src/RcsbBoard/RcsbDisplay/RcsbAreaDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {RcsbLineDisplay} from "./RcsbLineDisplay";
import {area, Area, curveStep, curveCardinal, curveBasis, curveLinear} from "d3-shape";
import {InterpolationTypes} from "../../RcsbFv/RcsbFvConfig/RcsbFvDefaultConfigValues";
import {BaseType, Selection} from "d3-selection";
import {
MoveAreaInterface,
PlotAreaInterface,
Expand Down
6 changes: 3 additions & 3 deletions src/RcsbBoard/RcsbDisplay/RcsbAxisDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {RcsbAbstractDisplay} from "./RcsbAbstractDisplay";
import {Axis, AxisDomain, axisBottom} from "d3-axis";
import {Axis, axisBottom} from "d3-axis";
import {format} from "d3-format";
import classes from "../scss/RcsbBoard.module.scss";
import {RcsbD3Constants} from "../RcsbD3/RcsbD3Constants";

export class RcsbAxisDisplay extends RcsbAbstractDisplay {

private xAxis: Axis<AxisDomain>;
private xAxis: Axis<number>;
private readonly length: number|undefined;

constructor(boardId: string, trackId:string, length?:number) {
Expand All @@ -21,7 +21,7 @@ export class RcsbAxisDisplay extends RcsbAbstractDisplay {

update(){
if(this.xAxis == null) {
this.xAxis = axisBottom<AxisDomain>(this.xScale.getScale());
this.xAxis = axisBottom<number>(this.xScale.getScale());
if(this.length != null && this.length < 9)
this.xAxis.tickValues( Array(this.length).fill(0).map((v,i)=>{return (i+1)}) ).tickFormat(format("d"));
this.g.classed(classes.rcsbAxis, true)
Expand Down
15 changes: 7 additions & 8 deletions src/RcsbBoard/RcsbDisplay/RcsbCompositeDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {RcsbDisplayInterface} from "./RcsbDisplayInterface";
import {ScaleLinear} from "d3-scale";
import {LocationViewInterface} from "../RcsbBoard";
import {RcsbD3Manager} from "../RcsbD3/RcsbD3Manager";
import {
Expand All @@ -23,9 +22,9 @@ export class RcsbCompositeDisplay implements RcsbDisplayInterface{
private _bgColor: string;
private compositeHeight: number;

setElementClickCallBack: (f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementEnterCallBack: (f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementLeaveCallBack: (f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementClickCallBack: (f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementEnterCallBack: (f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementLeaveCallBack: (f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setUpdateDataOnMove: (f:(d:LocationViewInterface)=>Promise<RcsbFvTrackData>)=>void;
setTooltip: (flag: boolean)=>void;
setMinRatio: (ratio: number) => void;
Expand Down Expand Up @@ -68,9 +67,9 @@ export class RcsbCompositeDisplay implements RcsbDisplayInterface{
});
}

init(width: number, scale:RcsbScaleInterface): void{
init(scale:RcsbScaleInterface): void{
this.innerDisplays.forEach((de)=>{
de.display.init(width, scale, true, this.compositeHeight);
de.display.init(scale, true, this.compositeHeight);
});
}

Expand Down Expand Up @@ -114,7 +113,7 @@ export class RcsbCompositeDisplay implements RcsbDisplayInterface{
});
}

setHighlightHoverElement(f: (d?:RcsbFvTrackDataElementInterface)=>void, g: (d?:RcsbFvTrackDataElementInterface)=>void): void{
setHighlightHoverElement(f: (d:RcsbFvTrackDataElementInterface)=>void, g: (d:RcsbFvTrackDataElementInterface)=>void): void{
this.innerDisplays.forEach(de=>{
de.display.setHighlightHoverElement(f,g);
})
Expand Down Expand Up @@ -153,7 +152,7 @@ export class RcsbCompositeDisplay implements RcsbDisplayInterface{
return this._data;
}

highlightRegion(d:Array<RcsbFvTrackDataElementInterface>, options?:{color?:string, rectClass?: string;}): void {
highlightRegion(d:Array<RcsbFvTrackDataElementInterface> | null, options?:{color?:string, rectClass?: string;}): void {
if(this.innerDisplays.length > 0 ){
this.innerDisplays[0].display.highlightRegion(d,options);
}
Expand Down
10 changes: 5 additions & 5 deletions src/RcsbBoard/RcsbDisplay/RcsbDisplayInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface RcsbDisplayInterface {
//RcsbAbstractTrack
height: (h?: number) => number;
trackColor: (c?: string) => string;
init: (width: number, scale:RcsbScaleInterface, compositeFlag?: boolean, compositeHeight?: number) => void;
init: (scale:RcsbScaleInterface, compositeFlag?: boolean, compositeHeight?: number) => void;
data: (d: RcsbFvTrackData | RcsbFvTrackDataMap) => RcsbFvTrackData | RcsbFvTrackDataMap;
setUpdateDataOnMove:( f:(d:LocationViewInterface)=>Promise<RcsbFvTrackData> )=> void;
setBoardHighlight: (f:(d:RcsbFvTrackDataElementInterface, operation:'set'|'add', mode:'select'|'hover', propFlag?: boolean) => void) => void;
Expand All @@ -30,10 +30,10 @@ export interface RcsbDisplayInterface {
update: (compKey?: string) => void;
displayEmpty: () => void;
move: ()=> void;
setElementClickCallBack: (f:(d?:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementEnterCallBack: (f:(d?:RcsbFvTrackDataElementInterface)=>void, e?: MouseEvent)=>void;
setElementLeaveCallBack: (f:(d?:RcsbFvTrackDataElementInterface)=>void, e?: MouseEvent)=>void;
setHighlightHoverElement: (f: (d?:RcsbFvTrackDataElementInterface)=>void, g: (d?:RcsbFvTrackDataElementInterface)=>void)=>void;
setElementClickCallBack: (f:(d:RcsbFvTrackDataElementInterface, e?: MouseEvent)=>void)=>void;
setElementEnterCallBack: (f:(d:RcsbFvTrackDataElementInterface)=>void, e?: MouseEvent)=>void;
setElementLeaveCallBack: (f:(d:RcsbFvTrackDataElementInterface)=>void, e?: MouseEvent)=>void;
setHighlightHoverElement: (f: (d:RcsbFvTrackDataElementInterface)=>void, g: (d:RcsbFvTrackDataElementInterface)=>void)=>void;
setTooltip: (flag: boolean)=>void;
setMinRatio: (ratio: number) => void;
setSelectDataInRange: (flag: boolean) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/RcsbBoard/RcsbDisplay/RcsbLineDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {RcsbAbstractDisplay} from "./RcsbAbstractDisplay";
import {Selection, BaseType, pointer, ContainerElement} from "d3-selection";
import {pointer, ContainerElement} from "d3-selection";
import {
MoveLineInterface,
PlotLineInterface,
Expand Down
1 change: 0 additions & 1 deletion src/RcsbBoard/RcsbDisplay/RcsbVlineDisplay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {RcsbAbstractDisplay} from "./RcsbAbstractDisplay";
import {Selection, BaseType} from "d3-selection";
import {RcsbDisplayInterface} from "./RcsbDisplayInterface";
import {
MoveVlineInterface,
PlotVlineInterface,
Expand Down
5 changes: 0 additions & 5 deletions src/RcsbBoard/RcsbTooltip/RcsbTooltipManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {computePosition, detectOverflow} from "@floating-ui/dom";
export class RcsbTooltipManager {

private readonly boardId: string;
private readonly divHeight:number = 25;

private tooltipDiv: HTMLDivElement;
private tooltipDescriptionDiv: HTMLDivElement;
Expand Down Expand Up @@ -163,10 +162,6 @@ export class RcsbTooltipManager {
this.tooltipDescriptionDiv.style.visibility = "hidden";
}

private static capitalizeFirstLetter(string: string): string {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}

private static bNode(): HTMLSpanElement{
const b:HTMLSpanElement = document.createElement<"span">("span");
b.append(" | ");
Expand Down
1 change: 0 additions & 1 deletion src/RcsbFv/RcsbFv.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import {createRoot, Root} from "react-dom/client";
import {RcsbFvBoard, RcsbFvBoardFullConfigInterface} from "./RcsbFvBoard/RcsbFvBoard";
import {
Expand Down
5 changes: 2 additions & 3 deletions src/RcsbFv/RcsbFvBoard/Components/BoardProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import classes from "../../RcsbFvStyles/RcsbFvRow.module.scss";
import {RcsbFvDefaultConfigValues} from "../../RcsbFvConfig/RcsbFvDefaultConfigValues";
import {RcsbFvBoardConfigInterface, RcsbFvRowConfigInterface} from "../../RcsbFvConfig/RcsbFvConfigInterface";
import {Subscription} from "rxjs";
import {EventType, RcsbFvContextManager, RowReadyInterface} from "../../RcsbFvContextManager/RcsbFvContextManager";
import {RowStatusMap} from "../Utils/RowStatusMap";
import {EventType, RcsbFvContextManager} from "../../RcsbFvContextManager/RcsbFvContextManager";
import {computePosition, detectOverflow} from "@floating-ui/dom";

interface BoardProgressInterface {
Expand Down Expand Up @@ -53,7 +52,7 @@ export class BoardProgress extends React.Component <BoardProgressInterface> {
}

/**Row Track Board Ready Event
* @param rowData
* @param fraction
* */
private rowReady(fraction: number):void{
if(fraction >= 100){
Expand Down
1 change: 1 addition & 0 deletions src/RcsbFv/RcsbFvBoard/RcsbFvBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class RcsbFvBoard extends React.Component <RcsbFvBoardInterface, RcsbFvBo
}

componentWillUnmount(): void {
this.subscription.unsubscribe();
this.props.contextManager.unsubscribeAll();
}

Expand Down
Loading

0 comments on commit 2a39a55

Please sign in to comment.