@datagrok/helm 2.3.3 → 2.3.4
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/CHANGELOG.md +8 -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 +1 -1
- package/src/package-utils.ts +94 -111
- package/src/package.ts +7 -6
- package/src/tests/helm-input-tests.ts +31 -20
package/package.json
CHANGED
package/src/package-utils.ts
CHANGED
|
@@ -30,7 +30,7 @@ declare const org: OrgHelmModule;
|
|
|
30
30
|
type DojoConfigWindowType = {
|
|
31
31
|
dojoConfig: {
|
|
32
32
|
packages?: (string | { name: string, location: string })[],
|
|
33
|
-
deps?: string[], callback: Function, has?: any, parseOnLoad?: boolean, async?: boolean | string
|
|
33
|
+
deps?: string[], callback: Function, has?: any, parseOnLoad?: boolean, async?: boolean | string, locale?: string,
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
type HelmWindowType = {
|
|
@@ -54,97 +54,85 @@ export async function initHelmLoadAndPatchDojo(): Promise<void> {
|
|
|
54
54
|
await delay(2000);
|
|
55
55
|
const requireBackup = window.require;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const dojoRequire = window.require;
|
|
86
|
-
const cmp = dojoRequire == requireBackup;
|
|
87
|
-
try {
|
|
57
|
+
// dojo.window','dojo.io.script','dojo.io.iframe','dojo.dom','dojox.gfx','dojox.gfx.svg','dojox.gfx.shape','dojox.charting'
|
|
58
|
+
const dojoTargetList: { name: string, checker: () => boolean }[] = [
|
|
59
|
+
{name: 'dojo.window', checker: () => !!dojo?.window},
|
|
60
|
+
{name: 'dojo.ready', checker: () => !!dojo?.ready},
|
|
61
|
+
{name: 'dojo.io.script', checker: () => !!dojo?.io?.script},
|
|
62
|
+
{name: 'dojo.io.iframe', checker: () => !!dojo?.io?.iframe},
|
|
63
|
+
// {name: 'dojo.dom', checker: () => !!dojo?.dom},
|
|
64
|
+
{name: 'dojox.gfx', checker: () => !!dojox?.gfx},
|
|
65
|
+
{name: 'dojox.gfx.svg', checker: () => !!dojox?.gfx?.svg},
|
|
66
|
+
{name: 'dojox.gfx.createSurface', checker: () => !!dojox?.gfx?.createSurface},
|
|
67
|
+
{name: 'dojox.gfx.shape', checker: () => !!dojox?.gfx?.shape},
|
|
68
|
+
{name: 'dojox.storage.Provider', checker: () => !!dojox?.storage?.Provider},
|
|
69
|
+
{name: 'dojox.storage.LocalStorageProvider', checker: () => !!dojox?.storage?.LocalStorageProvider},
|
|
70
|
+
// {name: 'dojox.charting', checker: () => !!dojox.charting},
|
|
71
|
+
// {name: 'dojox.charting.themes.Claro', checker: () => !!dojox.charting?.themes?.Claro},
|
|
72
|
+
// {name: 'dojox.charting.themes.Wetland', checker: () => !!dojox.charting?.themes?.Wetland},
|
|
73
|
+
// {name: 'dojox.charting.plot2d.Base', checker: () => !!dojox.charting?.plot2d?.Base},
|
|
74
|
+
// {name: 'dojox.charting.Series', checker: () => !!dojox?.charting?.Series},
|
|
75
|
+
// {name: 'dojox.charting.Chart2D', checker: () => !!dojox?.charting?.Chart2D},
|
|
76
|
+
];
|
|
77
|
+
/** Gets list ofd modules not ready yet */
|
|
78
|
+
const getDojoNotReadyList = (): string[] => {
|
|
79
|
+
return dojoTargetList.filter((dt) => !dt.checker()).map((dt) => dt.name);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await timeout(async () => {
|
|
84
|
+
|
|
88
85
|
await new Promise<void>((resolve, reject) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
window.dojoConfig = {
|
|
87
|
+
callback: () => { resolve(); },
|
|
88
|
+
parseOnLoad: true,
|
|
89
|
+
async: false,
|
|
90
|
+
locale: 'en-us', // to limit dijit/nls file set
|
|
91
|
+
};
|
|
92
|
+
// Load dojo without package/sources section for the settings dojoConfig to take effect
|
|
93
|
+
DG.Utils.loadJsCss([
|
|
94
|
+
// 'https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js.uncompressed.js',
|
|
95
|
+
`${_package.webRoot}/vendor/dojo-1.10.10/dojo/dojo.js.uncompressed.js`,
|
|
96
|
+
]).then(() => {});
|
|
98
97
|
});
|
|
99
|
-
} finally {
|
|
100
|
-
window.require = function(...args: any[]) {
|
|
101
|
-
_package.logger.debug(`${logPrefix}, window.require( ${JSON.stringify(args)} )`);
|
|
102
|
-
dojoRequire(...args);
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
98
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// // {module: 'dojox.storage.LocalStorageProvider', checker: () => !!dojox?.storage?.LocalStorageProvider},
|
|
128
|
-
];
|
|
129
|
-
for (const dojoTarget of dojoTargetList) {
|
|
130
|
-
try { if (dojoTarget.module) dojo.require(dojoTarget.module); } catch (err: any) {
|
|
131
|
-
_package.logger.error(err.message);
|
|
99
|
+
const dojoRequire = window.require;
|
|
100
|
+
const cmp = dojoRequire == requireBackup;
|
|
101
|
+
try {
|
|
102
|
+
await new Promise<void>((resolve, reject) => {
|
|
103
|
+
dojoRequire(['dojo/window', 'dojo/dom', 'dojo/io/script', 'dojo/io/iframe',
|
|
104
|
+
'dojox/gfx', 'dojox/gfx/svg', 'dojox/gfx/shape',
|
|
105
|
+
'dojox/storage/Provider', 'dojox/storage/LocalStorageProvider',
|
|
106
|
+
'dijit/_base', 'dijit/Tooltip', 'dijit/form/_FormValueWidget',
|
|
107
|
+
'dijit/form/DropDownButton', 'dijit/layout/AccordionContainer', 'dijit/form/ComboButton',
|
|
108
|
+
'dijit/layout/StackController', 'dijit/layout/StackContainer',
|
|
109
|
+
],
|
|
110
|
+
(...args: any[]) => {
|
|
111
|
+
resolve();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
} finally {
|
|
115
|
+
// TODO: Check interference with NGL
|
|
116
|
+
window.require = function(...args: any[]) {
|
|
117
|
+
_package.logger.debug(`${logPrefix}, window.require( ${JSON.stringify(args)} )`);
|
|
118
|
+
dojoRequire(...args);
|
|
119
|
+
};
|
|
132
120
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
_package.logger.
|
|
147
|
-
}
|
|
121
|
+
|
|
122
|
+
/** List of dojo modules not ready yet */ let dojoNotReadyList: string[];
|
|
123
|
+
while ((dojoNotReadyList = getDojoNotReadyList()).length > 0) {
|
|
124
|
+
const dojoProgress = dojoTargetList.length - dojoNotReadyList.length;
|
|
125
|
+
pi.update(Math.round(100 * dojoProgress / dojoTargetList.length),
|
|
126
|
+
`Loading Helm Web Editor ${dojoProgress}/${dojoTargetList.length}`);
|
|
127
|
+
_package.logger.debug(`${logPrefix}, dojo loading ... ${dojoNotReadyList.map((m) => `'${m}'`).join(',')} ...`);
|
|
128
|
+
await delay(100);
|
|
129
|
+
}
|
|
130
|
+
_package.logger.debug(`${logPrefix}, dojo ready all modules`);
|
|
131
|
+
}, 60000, 'timeout dojox.gfx.svg');
|
|
132
|
+
} catch (err: any) {
|
|
133
|
+
const dojoNotReadyList = getDojoNotReadyList();
|
|
134
|
+
_package.logger.error(`${logPrefix}, dojo not ready ${dojoNotReadyList.map((m) => `'${m}'`).join(',')} ...`);
|
|
135
|
+
}
|
|
148
136
|
|
|
149
137
|
_package.logger.debug(`${logPrefix}, patch window.dojox.gfx.svg.Text.prototype.getTextWidth`);
|
|
150
138
|
// @ts-ignore
|
|
@@ -204,13 +192,9 @@ export class HelmPackage extends DG.Package {
|
|
|
204
192
|
this.helmHelper = new HelmHelper(this.logger);
|
|
205
193
|
}
|
|
206
194
|
|
|
207
|
-
setLibHelper(libHelper: IMonomerLibHelper) {
|
|
208
|
-
this.libHelper = libHelper;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
195
|
// -- Init --
|
|
212
196
|
/** Loads Dojo and HelmWebEditor, waits for init, patches */
|
|
213
|
-
async
|
|
197
|
+
async initHELMWebEditor(): Promise<void> {
|
|
214
198
|
const logPrefix: string = 'Helm: Package.initDojo()';
|
|
215
199
|
|
|
216
200
|
_package.logger.debug(`${logPrefix}, dependence loading …`);
|
|
@@ -235,12 +219,6 @@ export class HelmPackage extends DG.Package {
|
|
|
235
219
|
_package.logger.debug(`${logPrefix}, dependence loaded, ET: ${(t2 - t1)} ms`);
|
|
236
220
|
}
|
|
237
221
|
|
|
238
|
-
async getMonomerLib(): Promise<IMonomerLib> {
|
|
239
|
-
const libHelper = await getMonomerLibHelper();
|
|
240
|
-
_package.setLibHelper(libHelper);
|
|
241
|
-
return libHelper.getBioLib();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
222
|
public initHelmPatchScilAlert(): void {
|
|
245
223
|
const logPrefix: string = 'Helm: initHelmPatchScilAlert()';
|
|
246
224
|
this.alertOriginal = scil.Utils.alert;
|
|
@@ -300,21 +278,26 @@ export class HelmPackage extends DG.Package {
|
|
|
300
278
|
|
|
301
279
|
// -- MonomerLib --
|
|
302
280
|
|
|
303
|
-
private _monomerLib: IMonomerLib;
|
|
304
281
|
public get monomerLib(): IMonomerLib {
|
|
305
|
-
if (!this.
|
|
306
|
-
throw new Error(`Helm: _package.
|
|
307
|
-
return this.
|
|
282
|
+
if (!this.libHelper)
|
|
283
|
+
throw new Error(`Helm: _package.libHelper is not initialized yet`);
|
|
284
|
+
return this.libHelper.getBioLib();
|
|
308
285
|
}
|
|
309
286
|
|
|
310
287
|
private _monomerLibSub: Unsubscribable;
|
|
311
288
|
|
|
312
|
-
|
|
313
|
-
if (!!this.
|
|
314
|
-
throw new Error(`Helm: _package.
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
289
|
+
async initMonomerLibHelper(): Promise<void> {
|
|
290
|
+
if (!!this.libHelper)
|
|
291
|
+
throw new Error(`Helm: _package.libHelper is initialized already`);
|
|
292
|
+
|
|
293
|
+
this.libHelper = await getMonomerLibHelper();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Requires both Bio & HELMWebEditor initialized */
|
|
297
|
+
async initMonomerLib(): Promise<void> {
|
|
298
|
+
const lib = this.monomerLib;
|
|
299
|
+
rewriteLibraries(lib); // initHelm()
|
|
300
|
+
this._monomerLibSub = lib.onChanged
|
|
318
301
|
.subscribe(this.monomerLibOnChangedHandler.bind(this));
|
|
319
302
|
|
|
320
303
|
this.initHelmPatchPistoia();
|
|
@@ -323,7 +306,7 @@ export class HelmPackage extends DG.Package {
|
|
|
323
306
|
monomerLibOnChangedHandler(): void {
|
|
324
307
|
const logPrefix = `Helm: _package.monomerLibOnChangedHandler()`;
|
|
325
308
|
try {
|
|
326
|
-
const libSummary = this.monomerLib
|
|
309
|
+
const libSummary = this.monomerLib.getSummaryObj();
|
|
327
310
|
const isLibEmpty = Object.keys(libSummary).length == 0;
|
|
328
311
|
const libSummaryLog = isLibEmpty ? 'empty' : Object.entries(libSummary)
|
|
329
312
|
.map(([pt, count]) => `${pt}: ${count}`)
|
|
@@ -337,7 +320,7 @@ export class HelmPackage extends DG.Package {
|
|
|
337
320
|
grok.shell.info(libMsg);
|
|
338
321
|
|
|
339
322
|
_package.logger.debug(`${logPrefix}, org,helm.webeditor.Monomers updating ...`);
|
|
340
|
-
rewriteLibraries(this.
|
|
323
|
+
rewriteLibraries(this.monomerLib); // initHelm() monomerLib.onChanged()
|
|
341
324
|
_package.logger.debug(`${logPrefix}, end, org.helm.webeditor.Monomers completed`);
|
|
342
325
|
} catch (err: any) {
|
|
343
326
|
const errMsg = errorToConsole(err);
|
package/src/package.ts
CHANGED
|
@@ -28,7 +28,7 @@ import {getRS} from './utils/get-monomer-dummy';
|
|
|
28
28
|
import {buildWebEditorApp} from './helm-web-editor';
|
|
29
29
|
import {JSDraw2HelmModule, OrgHelmModule, ScilModule} from './types';
|
|
30
30
|
|
|
31
|
-
export const _package = new HelmPackage({debug: true}/**/);
|
|
31
|
+
export const _package = new HelmPackage(/*{debug: true}/**/);
|
|
32
32
|
|
|
33
33
|
let monomerLib: IMonomerLib | null = null;
|
|
34
34
|
|
|
@@ -51,13 +51,14 @@ export async function initHelm(): Promise<void> {
|
|
|
51
51
|
_package.logger.debug(`${logPrefix}, start`);
|
|
52
52
|
|
|
53
53
|
try {
|
|
54
|
-
|
|
55
|
-
_package.
|
|
56
|
-
_package.
|
|
57
|
-
])
|
|
54
|
+
await Promise.all([
|
|
55
|
+
_package.initHELMWebEditor(),
|
|
56
|
+
_package.initMonomerLibHelper(),
|
|
57
|
+
]).then(() => {
|
|
58
|
+
_package.initMonomerLib();
|
|
59
|
+
});
|
|
58
60
|
|
|
59
61
|
_package.logger.debug(`${logPrefix}, then(), lib loaded`);
|
|
60
|
-
_package.initMonomerLib(lib);
|
|
61
62
|
} catch (err: any) {
|
|
62
63
|
const [errMsg, errStack] = errInfo(err);
|
|
63
64
|
// const errMsg: string = err instanceof Error ? err.message : !!err ? err.toString() : 'Exception \'undefined\'';
|
|
@@ -4,7 +4,7 @@ import * as DG from 'datagrok-api/dg';
|
|
|
4
4
|
|
|
5
5
|
import $ from 'cash-dom';
|
|
6
6
|
|
|
7
|
-
import {after, before, category, delay, expect, test,
|
|
7
|
+
import {after, before, category, delay, expect, test, testEvent} from '@datagrok-libraries/utils/src/test';
|
|
8
8
|
import {IHelmHelper, getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
9
9
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
10
10
|
import {
|
|
@@ -61,26 +61,37 @@ async function _testTooltipOnHelmInput(): Promise<void> {
|
|
|
61
61
|
const helmValue = 'PEPTIDE1{[meY].A.G.T}$$$$';
|
|
62
62
|
const helmInput = (await ui.input.helmAsync('Macromolecule')) as HelmInput;
|
|
63
63
|
helmInput.stringValue = helmValue;
|
|
64
|
+
// Show dialog to the right of the TestManager test tree
|
|
65
|
+
// to prevent interfering mousemove position for tooltip.
|
|
66
|
+
const tmBcr = grok.shell.v ? grok.shell.v.root.getBoundingClientRect() : null;
|
|
64
67
|
const dlg = ui.dialog('Helm Input Test')
|
|
65
68
|
.add(helmInput)
|
|
66
|
-
.show();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
.show({...(tmBcr ? {x: tmBcr.right + 20, y: tmBcr.top + 20} : {})});
|
|
70
|
+
try {
|
|
71
|
+
const dialogInputEl = $(dlg.root)
|
|
72
|
+
.find('div.d4-dialog-contents > div.ui-input-helm > div.ui-input-editor').get(0);
|
|
73
|
+
expect(helmInput.getInput(), dialogInputEl);
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
const mon = {i: 0, elem: 'meY'};
|
|
76
|
+
const a = helmInput.value.atoms[mon.i];
|
|
77
|
+
const iEl = helmInput.getInput();
|
|
78
|
+
const iBcr = iEl.getBoundingClientRect();
|
|
79
|
+
const ev = new MouseEvent('mousemove', {
|
|
80
|
+
cancelable: true, bubbles: true, view: window, button: 0,
|
|
81
|
+
clientX: iBcr.left + a.p.x, clientY: iBcr.top + a.p.y
|
|
82
|
+
});
|
|
83
|
+
await testEvent(ui.tooltip.onTooltipShown, () => { /* tooltip shown*/ },
|
|
84
|
+
() => {
|
|
85
|
+
iEl.dispatchEvent(ev);
|
|
86
|
+
// do not await after event dispatch before test tooltip content
|
|
87
|
+
// await leads to tooltip changed (with TestManager tree node tooltip)
|
|
88
|
+
}, 100, 'timeout await ui.tooltip.onTooltipShown');
|
|
89
|
+
const tooltipEl = $(document).find('body > div.d4-tooltip').get(0) as HTMLElement;
|
|
90
|
+
const elemDiv = $(tooltipEl).find('div > div.d4-flex-row.ui-div > div:nth-child(1)').get(0);
|
|
91
|
+
expect(tooltipEl.style.display != 'none', true);
|
|
92
|
+
expect(elemDiv?.innerText, mon.elem);
|
|
93
|
+
} finally {
|
|
94
|
+
await delay(50);
|
|
95
|
+
ui.tooltip.hide();
|
|
96
|
+
}
|
|
86
97
|
}
|