import { LogMessageCallback, ContentScriptData } from '../../types'; import CodeMirrorControl from '../CodeMirrorControl'; import codeMirrorRequire from './codeMirrorRequire'; let pluginScriptIdCounter = 0; let pluginLoaderCounter = 0; type OnScriptLoadCallback = (exports: any)=> void; type OnPluginRemovedCallback = ()=> void; const contentScriptToId = (contentScript: ContentScriptData) => `${contentScript.pluginId}--${contentScript.contentScriptId}`; export default class PluginLoader { private pluginScriptsContainer: HTMLElement; private loadedContentScriptIds: string[] = []; private pluginRemovalCallbacks: Record = {}; private pluginLoaderId: number; public constructor(private editor: CodeMirrorControl, private logMessage: LogMessageCallback) { this.pluginScriptsContainer = document.createElement('div'); this.pluginScriptsContainer.style.display = 'none'; // For testing this.pluginScriptsContainer.id = 'joplin-plugin-scripts-container'; document.body.appendChild(this.pluginScriptsContainer); // addPlugin works by creating