@datagrok/helm 2.1.33 → 2.2.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.
- package/.eslintrc.json +1 -1
- package/CHANGELOG.md +23 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +6 -6
- package/src/cell-renderer.ts +17 -153
- package/src/helm-helper.ts +9 -10
- package/src/helm-monomer-placer.ts +18 -66
- package/src/helm-web-editor.ts +5 -2
- package/src/package-test.ts +1 -0
- package/src/package-utils.ts +17 -0
- package/src/package.ts +75 -25
- package/src/tests/helm-service-tests.ts +97 -0
- package/src/tests/properties-widget-tests.ts +4 -2
- package/src/tests/renderers-tests.ts +97 -22
- package/src/types/dojo.ts +3 -0
- package/src/utils/dummy-monomer.ts +69 -0
- package/src/utils/get-hovered.ts +115 -0
- package/src/utils/helm-grid-cell-renderer.ts +201 -0
- package/src/utils/helm-service.ts +157 -0
- package/src/utils/index.ts +7 -7
- package/webpack.config.js +7 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import * as grok from 'datagrok-api/grok';
|
|
2
|
+
import * as DG from 'datagrok-api/dg';
|
|
3
|
+
import * as ui from 'datagrok-api/ui';
|
|
4
|
+
|
|
5
|
+
import * as JSDraw2 from 'JSDraw2';
|
|
6
|
+
import wu from 'wu';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
CellRendererBackAsyncBase, RenderServiceBase
|
|
10
|
+
} from '@datagrok-libraries/bio/src/utils/cell-renderer-async-base';
|
|
11
|
+
import {HelmAux, HelmProps} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
12
|
+
|
|
13
|
+
import {ISeqMonomer} from '../helm-monomer-placer';
|
|
14
|
+
import {getHoveredMonomerFromEditorMol} from './get-hovered';
|
|
15
|
+
import {_getHelmService} from '../package-utils';
|
|
16
|
+
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
17
|
+
import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
|
|
18
|
+
import {getGridCellRendererBack} from '@datagrok-libraries/bio/src/utils/cell-renderer-back-base';
|
|
19
|
+
import {IMonomerLib} from '@datagrok-libraries/bio/src/types/index';
|
|
20
|
+
|
|
21
|
+
import {_package, getMonomerLib} from '../package';
|
|
22
|
+
|
|
23
|
+
class WrapLogger implements ILogger {
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly base: ILogger
|
|
26
|
+
) {}
|
|
27
|
+
|
|
28
|
+
error(message: any, params?: object | undefined, stackTrace?: string | undefined): void {
|
|
29
|
+
this.base.error(message, params, stackTrace);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
warning(message: string, params?: object | undefined): void {
|
|
33
|
+
this.base.warning(message, params);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
info(message: string, params?: object | undefined): void {
|
|
37
|
+
// this.base.info(message, params);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
debug(message: string, params?: object | undefined): void {
|
|
41
|
+
// this.base.debug(message, params);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProps, HelmAux> {
|
|
46
|
+
private _auxList: (HelmAux | null)[];
|
|
47
|
+
private readonly monomerLib: IMonomerLib;
|
|
48
|
+
|
|
49
|
+
constructor(
|
|
50
|
+
gridCol: DG.GridColumn | null,
|
|
51
|
+
tableCol: DG.Column<string>,
|
|
52
|
+
) {
|
|
53
|
+
super(gridCol, tableCol, new WrapLogger(_package.logger) /* _package.logger */, true);
|
|
54
|
+
this.monomerLib = getMonomerLib();
|
|
55
|
+
this.subs.push(this.monomerLib.onChanged.subscribe(this.monomerLibOnChanged.bind(this)));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected override reset(): void {
|
|
59
|
+
super.reset();
|
|
60
|
+
this._auxList = new Array<HelmAux | null>(this.tableCol.length).fill(null);
|
|
61
|
+
if (this.gridCol && this.gridCol.dart) this.gridCol.grid?.invalidate();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected override getRenderService(): RenderServiceBase<HelmProps, HelmAux> {
|
|
65
|
+
return _getHelmService();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected override getRenderTaskProps(
|
|
69
|
+
gridCell: DG.GridCell, backColor: number, width: number, height: number,
|
|
70
|
+
): HelmProps {
|
|
71
|
+
return new HelmProps(gridCell.cell.value, backColor, width, height);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
protected override storeAux(gridCell: DG.GridCell, aux: HelmAux): void {
|
|
75
|
+
if (gridCell.tableRowIndex !== null)
|
|
76
|
+
this._auxList[gridCell.tableRowIndex] = aux;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Renders cell from image data (cache), returns true to update the cell by service.
|
|
80
|
+
* @param gridCellBounds {DG.Rect} Grid cell bounds
|
|
81
|
+
*/
|
|
82
|
+
protected override renderCellImageData(
|
|
83
|
+
gridCtx: CanvasRenderingContext2D, gridCellBounds: DG.Rect, gridCell: DG.GridCell, cellImageData: ImageData,
|
|
84
|
+
): boolean {
|
|
85
|
+
const dpr = window.devicePixelRatio;
|
|
86
|
+
if (gridCell.tableRowIndex === null) return false;
|
|
87
|
+
const aux = this._auxList[gridCell.tableRowIndex];
|
|
88
|
+
if (!aux) return true;
|
|
89
|
+
|
|
90
|
+
// Draw cell image data to scale it with drawImage() while transform()
|
|
91
|
+
const cellCanvas = ui.canvas(cellImageData.width, cellImageData.height);
|
|
92
|
+
const cellCtx = cellCanvas.getContext('2d')!;
|
|
93
|
+
cellCtx.putImageData(cellImageData, 0, 0);
|
|
94
|
+
|
|
95
|
+
// Get bbox canvas
|
|
96
|
+
const bBoxImageData = cellCtx.getImageData(aux.bBox.x, aux.bBox.y, aux.bBox.width, aux.bBox.height);
|
|
97
|
+
const bBoxCanvas = ui.canvas(aux.bBox.width, aux.bBox.height);
|
|
98
|
+
const bBoxCtx = bBoxCanvas.getContext('2d')!;
|
|
99
|
+
bBoxCtx.putImageData(bBoxImageData, 0, 0);
|
|
100
|
+
|
|
101
|
+
const fitCanvasWidth = gridCellBounds.width * dpr - 2;
|
|
102
|
+
const fitCanvasHeight = gridCellBounds.height * dpr - 2;
|
|
103
|
+
|
|
104
|
+
const bBoxRatio = Math.max(aux.bBox.width / aux.cBox.width, aux.bBox.height / aux.cBox.height);
|
|
105
|
+
const bBoxFullWidth = aux.bBox.width / bBoxRatio;
|
|
106
|
+
const bBoxFullHeight = aux.bBox.height / bBoxRatio;
|
|
107
|
+
|
|
108
|
+
const fitScale = Math.min(fitCanvasWidth / bBoxFullWidth, fitCanvasHeight / bBoxFullHeight);
|
|
109
|
+
|
|
110
|
+
// Relative shift of bbox center to cbox center
|
|
111
|
+
const bBoxShiftHR = (aux.bBox.left + aux.bBox.width / 2 - aux.cBox.width / 2) / aux.cBox.width;
|
|
112
|
+
const bBoxShiftVR = (aux.bBox.top + aux.bBox.height / 2 - aux.cBox.height / 2) / aux.cBox.height;
|
|
113
|
+
|
|
114
|
+
const bBoxFitLeft = fitCanvasWidth / 2 - bBoxCanvas.width * fitScale * (1 - 2 * bBoxShiftHR) / 2;
|
|
115
|
+
const bBoxFitTop = fitCanvasHeight / 2 - bBoxCanvas.height * fitScale * (1 - 2 * bBoxShiftVR) / 2;
|
|
116
|
+
|
|
117
|
+
const fitCanvas = ui.canvas(fitCanvasWidth, fitCanvasHeight);
|
|
118
|
+
const fitCtx = fitCanvas.getContext('2d')!;
|
|
119
|
+
// fitCtx.fillStyle = '#FFFFA0';
|
|
120
|
+
// fitCtx.fillRect(0, 0, fitCanvasWidth, fitCanvasHeight);
|
|
121
|
+
fitCtx.transform(fitScale, 0, 0, fitScale, bBoxFitLeft, bBoxFitTop);
|
|
122
|
+
fitCtx.drawImage(bBoxCanvas, 0, 0); // draw with scale transform
|
|
123
|
+
|
|
124
|
+
const fitCanvasData = fitCtx.getImageData(0, 0, fitCanvasWidth, fitCanvasHeight);
|
|
125
|
+
this.renderOnGrid(gridCtx, gridCellBounds, gridCell, fitCanvasData);
|
|
126
|
+
return true; // request rendering
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
onMouseMove(gridCell: DG.GridCell, e: MouseEvent): void {
|
|
130
|
+
if (gridCell.tableRowIndex === null) return;
|
|
131
|
+
const aux = this._auxList[gridCell.tableRowIndex];
|
|
132
|
+
if (!aux) return;
|
|
133
|
+
|
|
134
|
+
const logPrefix = `${this.toLog()}.onMouseMove()`;
|
|
135
|
+
const dpr = window.devicePixelRatio;
|
|
136
|
+
|
|
137
|
+
/** {@link gridCell}.bounds */ const gcb = gridCell.bounds;
|
|
138
|
+
const argsX = (e.offsetX - gcb.x) * dpr;
|
|
139
|
+
const argsY = (e.offsetY - gcb.y) * dpr;
|
|
140
|
+
|
|
141
|
+
const editorMol: JSDraw2.IEditorMol | null = aux.mol;
|
|
142
|
+
if (!editorMol) {
|
|
143
|
+
this.logger.warning(`${logPrefix}, editorMol of the cell not found.`);
|
|
144
|
+
return; // The gridCell is not rendered yet
|
|
145
|
+
}
|
|
146
|
+
const seqMonomer: ISeqMonomer | null = getHoveredMonomerFromEditorMol(argsX, argsY, gridCell, editorMol);
|
|
147
|
+
|
|
148
|
+
if (seqMonomer) {
|
|
149
|
+
const tooltipEl = this.monomerLib.getTooltip(seqMonomer.polymerType, seqMonomer.symbol);
|
|
150
|
+
ui.tooltip.show(tooltipEl, e.x + 16, e.y + 16);
|
|
151
|
+
} else {
|
|
152
|
+
// Tooltip for missing monomers
|
|
153
|
+
ui.tooltip.hide();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// -- Handle events --
|
|
158
|
+
private monomerLibOnChanged(_value: any): void {
|
|
159
|
+
this.reset();
|
|
160
|
+
this.invalidateGrid();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static getOrCreate(gridCell: DG.GridCell): HelmGridCellRendererBack {
|
|
164
|
+
const [gridCol, tableCol, temp] =
|
|
165
|
+
getGridCellRendererBack<string, HelmGridCellRendererBack>(gridCell);
|
|
166
|
+
|
|
167
|
+
let res: HelmGridCellRendererBack = temp['rendererBack'];
|
|
168
|
+
if (!res) res = temp['rendererBack'] = new HelmGridCellRendererBack(gridCol, tableCol);
|
|
169
|
+
return res;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export class HelmGridCellRenderer extends DG.GridCellRenderer {
|
|
174
|
+
get name() { return 'helm'; }
|
|
175
|
+
|
|
176
|
+
get cellType() { return 'helm'; }
|
|
177
|
+
|
|
178
|
+
get defaultWidth(): number | null { return 400; }
|
|
179
|
+
|
|
180
|
+
get defaultHeight(): number | null { return 100; }
|
|
181
|
+
|
|
182
|
+
override onMouseMove(gridCell: DG.GridCell, e: MouseEvent) {
|
|
183
|
+
const logPrefix = `Helm: HelmGridCellRenderer.onMouseMove()`;
|
|
184
|
+
try {
|
|
185
|
+
HelmGridCellRendererBack.getOrCreate(gridCell).onMouseMove(gridCell, e);
|
|
186
|
+
} catch (err: any) {
|
|
187
|
+
const [errMsg, errStack] = errInfo(err);
|
|
188
|
+
_package.logger.error(errMsg, undefined, errStack);
|
|
189
|
+
} finally {
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
override render(
|
|
196
|
+
g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number,
|
|
197
|
+
gridCell: DG.GridCell, cellStyle: DG.GridCellStyle
|
|
198
|
+
): void {
|
|
199
|
+
HelmGridCellRendererBack.getOrCreate(gridCell).render(g, x, y, w, h, gridCell, cellStyle);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as grok from 'datagrok-api/grok';
|
|
2
|
+
import * as ui from 'datagrok-api/ui';
|
|
3
|
+
import * as DG from 'datagrok-api/dg';
|
|
4
|
+
|
|
5
|
+
import * as org from 'org';
|
|
6
|
+
import * as scil from 'scil';
|
|
7
|
+
import * as JSDraw2 from 'JSDraw2';
|
|
8
|
+
|
|
9
|
+
import $ from 'cash-dom';
|
|
10
|
+
import {Subject, Unsubscribable} from 'rxjs';
|
|
11
|
+
|
|
12
|
+
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
13
|
+
import {HelmAux, HelmProps, HelmServiceBase} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
14
|
+
import {RenderTask} from '@datagrok-libraries/bio/src/utils/cell-renderer-async-base';
|
|
15
|
+
import {svgToImage} from '@datagrok-libraries/utils/src/svg';
|
|
16
|
+
|
|
17
|
+
import {_package} from '../package';
|
|
18
|
+
import {DummyWebEditorMonomer} from './dummy-monomer';
|
|
19
|
+
|
|
20
|
+
export class HelmService extends HelmServiceBase {
|
|
21
|
+
private readonly hostDiv: HTMLDivElement;
|
|
22
|
+
|
|
23
|
+
private editor: JSDraw2.Editor | null = null;
|
|
24
|
+
private image: HTMLImageElement | null = null;
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super(_package.logger);
|
|
28
|
+
|
|
29
|
+
this.hostDiv = ui.box();
|
|
30
|
+
// this.hostDiv.style.display = 'none'; // Disables drawing at all
|
|
31
|
+
this.hostDiv.style.position = 'absolute';
|
|
32
|
+
this.hostDiv.style.left = '0px';
|
|
33
|
+
this.hostDiv.style.right = '0px';
|
|
34
|
+
this.hostDiv.style.width = '0px';
|
|
35
|
+
this.hostDiv.style.height = '0px';
|
|
36
|
+
this.hostDiv.style.visibility = 'hidden';
|
|
37
|
+
document.body.appendChild(this.hostDiv);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected override toLog(): string {
|
|
41
|
+
return `Helm: ${super.toLog()}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected override async requestRender(
|
|
45
|
+
key: keyof any | undefined, task: RenderTask<HelmProps, HelmAux>, renderHandler: (aux: HelmAux) => void
|
|
46
|
+
): Promise<[Unsubscribable, number, () => void]> {
|
|
47
|
+
const logPrefix = `${this.toLog()}.requestRender()`;
|
|
48
|
+
this.logger.debug(`${logPrefix}, start, ` + `key: ${key?.toString()}`);
|
|
49
|
+
const emptyCanvasHash: number = 0;
|
|
50
|
+
|
|
51
|
+
if (!this.editor) {
|
|
52
|
+
this.editor = new JSDraw2.Editor(this.hostDiv,
|
|
53
|
+
{width: task.props.width, height: task.props.height, skin: 'w8', viewonly: true});
|
|
54
|
+
}
|
|
55
|
+
const lST = window.performance.now();
|
|
56
|
+
this.editor.options.width = task.props.width;
|
|
57
|
+
this.editor.options.height = task.props.height;
|
|
58
|
+
this.editor.resize(task.props.width, task.props.height);
|
|
59
|
+
const helmStr = task.props.helm;
|
|
60
|
+
let hasMissing: boolean = false;
|
|
61
|
+
if (helmStr) {
|
|
62
|
+
const monomers = org.helm.webeditor.Monomers;
|
|
63
|
+
const originalGetMonomer = monomers.getMonomer;
|
|
64
|
+
const originalAlert = scil.Utils.alert;
|
|
65
|
+
try {
|
|
66
|
+
org.helm.webeditor.Monomers.getMonomer = (a: org.helm.IAtom | string, name: string): org.helm.IAtom | null => {
|
|
67
|
+
let resAtom: any = originalGetMonomer.bind(monomers)(a, name);
|
|
68
|
+
|
|
69
|
+
if (!resAtom) {
|
|
70
|
+
// Input logic
|
|
71
|
+
if (a == null && name == null)
|
|
72
|
+
return null;
|
|
73
|
+
|
|
74
|
+
let s: string;
|
|
75
|
+
let biotype: string;
|
|
76
|
+
if (name == null) {
|
|
77
|
+
biotype = (a as org.helm.IAtom).biotype();
|
|
78
|
+
s = (a as org.helm.IAtom).elem;
|
|
79
|
+
} else {
|
|
80
|
+
biotype = a as string;
|
|
81
|
+
s = org.helm.webeditor.IO.trimBracket(name);
|
|
82
|
+
}
|
|
83
|
+
resAtom = new DummyWebEditorMonomer(biotype, s);
|
|
84
|
+
//hasMissing = true;
|
|
85
|
+
}
|
|
86
|
+
return resAtom;
|
|
87
|
+
};
|
|
88
|
+
// Preventing alert message box for missing monomers with compressed Scilligence.JSDraw2.Lite.js
|
|
89
|
+
scil.Utils.alert = (s: string): void => {
|
|
90
|
+
this.logger.warning(`${logPrefix}, scil.Utils.alert() s = 's'.`);
|
|
91
|
+
};
|
|
92
|
+
this.logger.debug(`${logPrefix}, editor.setData( '${helmStr}' )`);
|
|
93
|
+
this.editor.setData(helmStr, 'helm');
|
|
94
|
+
} finally {
|
|
95
|
+
monomers.getMonomer = originalGetMonomer;
|
|
96
|
+
scil.Utils.alert = originalAlert;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!helmStr || hasMissing)
|
|
100
|
+
this.editor.reset();
|
|
101
|
+
|
|
102
|
+
const bBox = (this.editor.div.children[0] as SVGSVGElement).getBBox();
|
|
103
|
+
const aux: HelmAux = {
|
|
104
|
+
mol: this.editor.m.clone(false),
|
|
105
|
+
bBox: new DG.Rect(bBox.x, bBox.y, bBox.width + 2, bBox.height + 2) /* adjust for clipping right/bottom */,
|
|
106
|
+
cBox: new DG.Rect(0, 0, task.props.width, task.props.height),
|
|
107
|
+
};
|
|
108
|
+
const lET = window.performance.now();
|
|
109
|
+
|
|
110
|
+
const svgEl = $(this.hostDiv).find('svg').get(0) as unknown as SVGSVGElement;
|
|
111
|
+
const dpr = window.devicePixelRatio;
|
|
112
|
+
|
|
113
|
+
const rST = window.performance.now();
|
|
114
|
+
const renderHandlerInt = (): void => {
|
|
115
|
+
const rET: number = window.performance.now();
|
|
116
|
+
this.logger.debug(`${logPrefix}.renderHandlerInt(), ` +
|
|
117
|
+
`key: ${key?.toString()}, ` +
|
|
118
|
+
`load: ${lET - lST} ms,\n ` + `renderET: ${rET - rST} ms, ` +
|
|
119
|
+
`emptyCanvasHash: ${emptyCanvasHash}`);
|
|
120
|
+
renderHandler(aux);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const renderEvent = new Subject();
|
|
124
|
+
const renderSub = renderEvent.subscribe(() => {
|
|
125
|
+
const logPrefixInt = `${logPrefix} on renderEvent`;
|
|
126
|
+
this.logger.debug(`${logPrefixInt}`);
|
|
127
|
+
});
|
|
128
|
+
const trigger = (): void => {
|
|
129
|
+
svgToImage(svgEl, dpr).then((imageEl) => {
|
|
130
|
+
this.image = imageEl;
|
|
131
|
+
renderHandlerInt(); // calls onRendered()
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
this.logger.debug(`${logPrefix}, end, ` + `key: ${key?.toString()}`);
|
|
135
|
+
return [renderSub, -1, trigger];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
protected onRendered(
|
|
139
|
+
key: keyof any | undefined, task: RenderTask<HelmProps, HelmAux>, emptyCanvasHash: number, aux: HelmAux
|
|
140
|
+
): boolean {
|
|
141
|
+
const dpr = window.devicePixelRatio;
|
|
142
|
+
const canvas = ui.canvas(task.props.width, task.props.height);
|
|
143
|
+
try {
|
|
144
|
+
const g = canvas.getContext('2d');
|
|
145
|
+
if (!this.image || !g) return false;
|
|
146
|
+
// g.fillStyle = '#C0C0FF';
|
|
147
|
+
// g.fillRect(0, 0, canvas.width, canvas.height);
|
|
148
|
+
g.drawImage(this.image, 0, 0);
|
|
149
|
+
task.onAfterRender(canvas, aux);
|
|
150
|
+
} finally {
|
|
151
|
+
canvas.remove();
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async reset(): Promise<void> { }
|
|
157
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
|
|
3
|
+
import * as scil from 'scil';
|
|
4
|
+
import * as org from 'org';
|
|
5
|
+
|
|
6
|
+
import {_package} from '../package';
|
|
7
|
+
|
|
3
8
|
import {
|
|
4
9
|
RGROUP_CAP_GROUP_NAME,
|
|
5
10
|
RGROUP_CAP_GROUP_SMILES,
|
|
@@ -39,7 +44,6 @@ export function parseHelm(s: string): string[] {
|
|
|
39
44
|
const sections = split(s, '$');
|
|
40
45
|
s = sections[0];
|
|
41
46
|
const monomers = [];
|
|
42
|
-
//@ts-ignore
|
|
43
47
|
if (!scil.Utils.isNullOrEmpty(s)) {
|
|
44
48
|
const seqs = split(s, '|');
|
|
45
49
|
for (let i = 0; i < seqs.length; ++i) {
|
|
@@ -88,13 +92,11 @@ export function parseHelm(s: string): string[] {
|
|
|
88
92
|
// * used in org.helm.webeditor / scil.helm.Monomers / org.helm.webeditor.Monomers .
|
|
89
93
|
// */
|
|
90
94
|
// export function findMonomers(helmString: string) {
|
|
91
|
-
// //@ts-ignore
|
|
92
95
|
// const types: string[] = Object.keys(org.helm.webeditor.monomerTypeList());
|
|
93
96
|
// const monomerNameList: any[] = [];
|
|
94
97
|
// const monomerNameI: number = 0;
|
|
95
98
|
// const weMonomers = org.helm.webeditor.Monomers;
|
|
96
99
|
// for (let typeI = 0; typeI < types.length; typeI++) {
|
|
97
|
-
// //@ts-ignore
|
|
98
100
|
// const ofTypeMonomers: {} = weMonomers.getMonomerSet(types[typeI]) ?? {};
|
|
99
101
|
// Object.keys(ofTypeMonomers).forEach((key) => {
|
|
100
102
|
// const monomer: any = ofTypeMonomers[key];
|
|
@@ -112,9 +114,9 @@ export function findMonomers(monomerSymbolList: string[]): Set<string> {
|
|
|
112
114
|
const monomers: any = [];
|
|
113
115
|
const monomerNames: any = [];
|
|
114
116
|
for (let i = 0; i < types.length; i++) {
|
|
115
|
-
|
|
117
|
+
// @ts-ignore
|
|
116
118
|
// eslint-disable-next-line new-cap
|
|
117
|
-
monomers.push(new
|
|
119
|
+
monomers.push(new org.helm.webeditor.Monomers.getMonomerSet(types[i]));
|
|
118
120
|
Object.keys(monomers[i]).forEach((k) => {
|
|
119
121
|
monomerNames.push(monomers[i][k].id);
|
|
120
122
|
});
|
|
@@ -210,7 +212,6 @@ function detachAnnotation(s: string) {
|
|
|
210
212
|
|
|
211
213
|
function _detachAppendix(s: string, c: string) {
|
|
212
214
|
let tag = null;
|
|
213
|
-
//@ts-ignore
|
|
214
215
|
if (scil.Utils.endswith(s, c)) {
|
|
215
216
|
let p = s.length - 1;
|
|
216
217
|
while (p > 0) {
|
|
@@ -230,7 +231,6 @@ function _detachAppendix(s: string, c: string) {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
function unescape(s: string) {
|
|
233
|
-
//@ts-ignore
|
|
234
234
|
if (scil.Utils.isNullOrEmpty(s))
|
|
235
235
|
return s;
|
|
236
236
|
|
package/webpack.config.js
CHANGED
|
@@ -2,6 +2,9 @@ const path = require('path');
|
|
|
2
2
|
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
|
+
cache: {
|
|
6
|
+
type: 'filesystem',
|
|
7
|
+
},
|
|
5
8
|
mode: 'development',
|
|
6
9
|
entry: {
|
|
7
10
|
package: './src/package.ts',
|
|
@@ -36,6 +39,10 @@ module.exports = {
|
|
|
36
39
|
'cash-dom': '$',
|
|
37
40
|
'dayjs': 'dayjs',
|
|
38
41
|
'wu': 'wu',
|
|
42
|
+
'scil': 'scil',
|
|
43
|
+
'org': 'org',
|
|
44
|
+
'dojo': 'dojo',
|
|
45
|
+
'JSDraw2': 'JSDraw2',
|
|
39
46
|
},
|
|
40
47
|
output: {
|
|
41
48
|
filename: '[name].js',
|