|
@@ -62,6 +62,11 @@ import { ViewportScreenshotHelper } from './util/viewport-screenshot';
|
|
import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
|
|
import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
|
|
import { setSaccharideCompIdMapType } from '../mol-model/structure/structure/carbohydrates/constants';
|
|
import { setSaccharideCompIdMapType } from '../mol-model/structure/structure/carbohydrates/constants';
|
|
|
|
|
|
|
|
+export type PluginInitializedState =
|
|
|
|
+ | { kind: 'no' }
|
|
|
|
+ | { kind: 'yes' }
|
|
|
|
+ | { kind: 'error', error: any }
|
|
|
|
+
|
|
export class PluginContext {
|
|
export class PluginContext {
|
|
runTask = <T>(task: Task<T>, params?: { useOverlay?: boolean }) => this.managers.task.run(task, params);
|
|
runTask = <T>(task: Task<T>, params?: { useOverlay?: boolean }) => this.managers.task.run(task, params);
|
|
resolveTask = <T>(object: Task<T> | T | undefined) => {
|
|
resolveTask = <T>(object: Task<T> | T | undefined) => {
|
|
@@ -72,6 +77,8 @@ export class PluginContext {
|
|
|
|
|
|
protected subs: Subscription[] = [];
|
|
protected subs: Subscription[] = [];
|
|
private initCanvas3dPromiseCallbacks: [res: () => void, rej: (err: any) => void] = [() => {}, () => {}];
|
|
private initCanvas3dPromiseCallbacks: [res: () => void, rej: (err: any) => void] = [() => {}, () => {}];
|
|
|
|
+ private _isInitialized = false;
|
|
|
|
+ private initializedPromiseCallbacks: [res: () => void, rej: (err: any) => void] = [() => {}, () => {}];
|
|
|
|
|
|
private disposed = false;
|
|
private disposed = false;
|
|
private canvasContainer: HTMLDivElement | undefined = void 0;
|
|
private canvasContainer: HTMLDivElement | undefined = void 0;
|
|
@@ -115,6 +122,14 @@ export class PluginContext {
|
|
this.initCanvas3dPromiseCallbacks = [res, rej];
|
|
this.initCanvas3dPromiseCallbacks = [res, rej];
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ readonly initialized = new Promise<void>((res, rej) => {
|
|
|
|
+ this.initializedPromiseCallbacks = [res, rej];
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ get isInitialized() {
|
|
|
|
+ return this._isInitialized;
|
|
|
|
+ }
|
|
|
|
+
|
|
readonly canvas3dContext: Canvas3DContext | undefined;
|
|
readonly canvas3dContext: Canvas3DContext | undefined;
|
|
readonly canvas3d: Canvas3D | undefined;
|
|
readonly canvas3d: Canvas3D | undefined;
|
|
readonly layout = new PluginLayout(this);
|
|
readonly layout = new PluginLayout(this);
|
|
@@ -481,24 +496,32 @@ export class PluginContext {
|
|
}
|
|
}
|
|
|
|
|
|
async init() {
|
|
async init() {
|
|
- this.subs.push(this.events.log.subscribe(e => this.log.entries = this.log.entries.push(e)));
|
|
|
|
|
|
+ try {
|
|
|
|
+ this.subs.push(this.events.log.subscribe(e => this.log.entries = this.log.entries.push(e)));
|
|
|
|
|
|
- this.initCustomFormats();
|
|
|
|
- this.initBehaviorEvents();
|
|
|
|
- this.initBuiltInBehavior();
|
|
|
|
|
|
+ this.initCustomFormats();
|
|
|
|
+ this.initBehaviorEvents();
|
|
|
|
+ this.initBuiltInBehavior();
|
|
|
|
|
|
- (this.managers.interactivity as InteractivityManager) = new InteractivityManager(this);
|
|
|
|
- (this.managers.lociLabels as LociLabelManager) = new LociLabelManager(this);
|
|
|
|
- (this.builders.structure as StructureBuilder) = new StructureBuilder(this);
|
|
|
|
|
|
+ (this.managers.interactivity as InteractivityManager) = new InteractivityManager(this);
|
|
|
|
+ (this.managers.lociLabels as LociLabelManager) = new LociLabelManager(this);
|
|
|
|
+ (this.builders.structure as StructureBuilder) = new StructureBuilder(this);
|
|
|
|
|
|
- this.initAnimations();
|
|
|
|
- this.initDataActions();
|
|
|
|
|
|
+ this.initAnimations();
|
|
|
|
+ this.initDataActions();
|
|
|
|
|
|
- await this.initBehaviors();
|
|
|
|
|
|
+ await this.initBehaviors();
|
|
|
|
|
|
- this.log.message(`Mol* Plugin ${PLUGIN_VERSION} [${PLUGIN_VERSION_DATE.toLocaleString()}]`);
|
|
|
|
- if (!isProductionMode) this.log.message(`Development mode enabled`);
|
|
|
|
- if (isDebugMode) this.log.message(`Debug mode enabled`);
|
|
|
|
|
|
+ this.log.message(`Mol* Plugin ${PLUGIN_VERSION} [${PLUGIN_VERSION_DATE.toLocaleString()}]`);
|
|
|
|
+ if (!isProductionMode) this.log.message(`Development mode enabled`);
|
|
|
|
+ if (isDebugMode) this.log.message(`Debug mode enabled`);
|
|
|
|
+
|
|
|
|
+ this._isInitialized = true;
|
|
|
|
+ this.initializedPromiseCallbacks[0]();
|
|
|
|
+ } catch (err) {
|
|
|
|
+ this.initializedPromiseCallbacks[1](err);
|
|
|
|
+ throw err;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
constructor(public spec: PluginSpec) {
|
|
constructor(public spec: PluginSpec) {
|