molstar
Version:
A comprehensive macromolecular library.
37 lines • 1.46 kB
JavaScript
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { __awaiter, __generator } from "tslib";
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Plugin } from './plugin';
import { PluginUIContext } from './context';
import { DefaultPluginUISpec } from './spec';
export function createPlugin(target, spec) {
var ctx = new PluginUIContext(spec || DefaultPluginUISpec());
ctx.init();
ReactDOM.render(React.createElement(Plugin, { plugin: ctx }), target);
return ctx;
}
/** Returns the instance of the plugin after all behaviors have been initialized */
export function createPluginAsync(target, spec) {
return __awaiter(this, void 0, void 0, function () {
var ctx, init;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
ctx = new PluginUIContext(spec || DefaultPluginUISpec());
init = ctx.init();
ReactDOM.render(React.createElement(Plugin, { plugin: ctx }), target);
return [4 /*yield*/, init];
case 1:
_a.sent();
return [2 /*return*/, ctx];
}
});
});
}
//# sourceMappingURL=index.js.map