@aptpod/data-viz-visual-parts-sdk
Version:
Visual Parts SDK for VM2M Data Visualizer
45 lines • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dispatcher = void 0;
const namespace_1 = require("../namespace");
const window_1 = require("../window");
const plugin_1 = require("../plugin");
const script_loader_1 = require("./script-loader");
/** @internal */
class Dispatcher {
constructor() {
this.dispose = () => {
this.scriptLoader.dispose();
this.plugins.length = 0;
};
this.load = async ({ scriptURL, }) => {
const loadedRes = await this.scriptLoader.load(scriptURL);
if (!loadedRes) {
return {
succeed: false,
error: new Error('load error'),
};
}
const pluginsKey = namespace_1.createPluginsKey();
const plugins = parsePlugins(window_1.getValue(pluginsKey));
this.plugins = plugins;
return {
succeed: true,
data: undefined,
};
};
this.getPlugins = () => {
return this.plugins;
};
this.scriptLoader = new script_loader_1.ScriptLoader();
this.plugins = [];
}
}
exports.Dispatcher = Dispatcher;
const parsePlugins = (plugins) => {
if (plugin_1.validate(plugins)) {
return plugins;
}
return [];
};
//# sourceMappingURL=index.js.map