From 027181a7b249849b5afaacbd3d433f26d29676bb Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Wed, 23 Oct 2024 16:52:41 +0200 Subject: [PATCH] reload runner --- .../src/app/components/hidden-panel.tsx | 7 +++++ apps/remix-ide/src/app/components/panel.ts | 2 ++ .../src/app/tabs/script-runner-ui.tsx | 30 +++++++++++++------ apps/remix-ide/src/assets/img/ts-logo.svg | 1 + apps/remix-ide/src/remixEngine.js | 2 +- .../scriptrunner/src/lib/script-runner-ui.tsx | 24 ++++++++++++--- 6 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 apps/remix-ide/src/assets/img/ts-logo.svg diff --git a/apps/remix-ide/src/app/components/hidden-panel.tsx b/apps/remix-ide/src/app/components/hidden-panel.tsx index 27993313c0..fc492475ba 100644 --- a/apps/remix-ide/src/app/components/hidden-panel.tsx +++ b/apps/remix-ide/src/app/components/hidden-panel.tsx @@ -23,11 +23,18 @@ export class HiddenPanel extends AbstractPanel { } addView(profile: any, view: any): void { + console.log('addView', profile, view) super.removeView(profile) + this.renderComponent() super.addView(profile, view) this.renderComponent() } + removeView(profile: any): void { + super.removeView(profile) + this.renderComponent() + } + updateComponent(state: any) { return } plugins={state.plugins} /> } diff --git a/apps/remix-ide/src/app/components/panel.ts b/apps/remix-ide/src/app/components/panel.ts index bf80f3614d..fa025ca175 100644 --- a/apps/remix-ide/src/app/components/panel.ts +++ b/apps/remix-ide/src/app/components/panel.ts @@ -23,6 +23,8 @@ export class AbstractPanel extends HostPlugin { } addView (profile, view) { + console.log('addView', profile, view) + console.log('this', this.plugins) if (this.plugins[profile.name]) throw new Error(`Plugin ${profile.name} already rendered`) this.plugins[profile.name] = { profile: profile, diff --git a/apps/remix-ide/src/app/tabs/script-runner-ui.tsx b/apps/remix-ide/src/app/tabs/script-runner-ui.tsx index 2064b2de8c..ebac652b33 100644 --- a/apps/remix-ide/src/app/tabs/script-runner-ui.tsx +++ b/apps/remix-ide/src/app/tabs/script-runner-ui.tsx @@ -15,7 +15,7 @@ const profile = { displayName: 'Script configuration', methods: ['execute'], events: ['log', 'info', 'warn', 'error'], - icon: 'assets/img/settings.webp', + icon: 'assets/img/ts-logo.svg', description: 'Set up a script runner', kind: '', location: 'sidePanel', @@ -122,13 +122,12 @@ export class ScriptRunnerUIPlugin extends ViewPlugin { } async selectScriptRunner(config: ProjectConfiguration) { - console.log('selectScriptRunner', config) - await this.loadScriptRunner(config) - await this.saveCustomConfig(this.customConfig) + if (await this.loadScriptRunner(config)) + await this.saveCustomConfig(this.customConfig) } async loadScriptRunner(config: ProjectConfiguration): Promise { - console.log('loadScriptRunner', config) + //console.log('loadScriptRunner', config) const profile: Profile = await this.plugin.call('manager', 'getProfile', 'scriptRunner') this.scriptRunnerProfileName = profile.name const testPluginName = localStorage.getItem('test-plugin-name') @@ -144,13 +143,14 @@ export class ScriptRunnerUIPlugin extends ViewPlugin { url = `${baseUrl}?template=${config.name}×tamp=${Date.now()}` } } - console.log('loadScriptRunner', profile) + //console.log('loadScriptRunner', profile) const newProfile: IframeProfile = { ...profile, name: profile.name + config.name, location: 'hiddenPanel', url: url } + console.log('loadScriptRunner', newProfile) let result = null try { @@ -161,7 +161,7 @@ export class ScriptRunnerUIPlugin extends ViewPlugin { await this.engine.register(plugin) } await this.plugin.call('manager', 'activatePlugin', newProfile.name) - + console.log('activate done', newProfile.name) this.activeConfig = config this.on(newProfile.name, 'log', this.log.bind(this)) this.on(newProfile.name, 'info', this.info.bind(this)) @@ -172,13 +172,22 @@ export class ScriptRunnerUIPlugin extends ViewPlugin { this.setErrorStatus(config.name, false, '') result = true } catch (e) { - - this.engine.remove(newProfile.name) + console.log('Error loading script runner: ', newProfile.name, e) + const iframe = document.getElementById(`plugin-${newProfile.name}`); + if (iframe) { + console.log('remove iframe', iframe) + await this.call('hiddenPanel', 'removeView', newProfile) + } + console.log('deactivate', (this.engine as any)) + delete (this.engine as any).manager.profiles[newProfile.name] + delete (this.engine as any).plugins[newProfile.name] console.log('is registered', newProfile.name, this.engine.isRegistered(newProfile.name)) console.log('Error loading script runner: ', newProfile.name, e) + console.log('REMOVE', newProfile.name) this.setErrorStatus(config.name, true, e) result = false } + console.log('ENGINE', this.engine) this.setIsLoading(config.name, false) this.renderComponent() return result @@ -186,6 +195,7 @@ export class ScriptRunnerUIPlugin extends ViewPlugin { } async execute(script: string, filePath: string) { + console.log(this.engine) console.log('is registered', `${this.scriptRunnerProfileName}${this.activeConfig.name}`, this.engine.isRegistered(`${this.scriptRunnerProfileName}${this.activeConfig.name}`)) if (!this.scriptRunnerProfileName || !this.engine.isRegistered(`${this.scriptRunnerProfileName}${this.activeConfig.name}`)) { if (!await this.loadScriptRunner(this.activeConfig)) { @@ -195,10 +205,12 @@ export class ScriptRunnerUIPlugin extends ViewPlugin { } console.log('execute', this.activeConfig) try { + this.setIsLoading(this.activeConfig.name, true) await this.call(`${this.scriptRunnerProfileName}${this.activeConfig.name}`, 'execute', script, filePath) } catch (e) { console.error('Error executing script', e) } + this.setIsLoading(this.activeConfig.name, false) } diff --git a/apps/remix-ide/src/assets/img/ts-logo.svg b/apps/remix-ide/src/assets/img/ts-logo.svg new file mode 100644 index 0000000000..dc26789c4b --- /dev/null +++ b/apps/remix-ide/src/assets/img/ts-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/remix-ide/src/remixEngine.js b/apps/remix-ide/src/remixEngine.js index f8bd8d6641..97ef962d48 100644 --- a/apps/remix-ide/src/remixEngine.js +++ b/apps/remix-ide/src/remixEngine.js @@ -29,7 +29,7 @@ export class RemixEngine extends Engine { if (name === 'solcoder') return { queueTimeout: 60000 * 2 } if (name === 'cookbookdev') return { queueTimeout: 60000 * 3 } if (name === 'contentImport') return { queueTimeout: 60000 * 3 } - + if (name === 'scriptRunnerBridge') return { queueTimeout: 2000 } return { queueTimeout: 10000 } } diff --git a/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx b/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx index 40877b1716..e953b93e4e 100644 --- a/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx +++ b/libs/remix-ui/scriptrunner/src/lib/script-runner-ui.tsx @@ -3,7 +3,7 @@ import { Accordion, Card, Button } from "react-bootstrap"; import axios from "axios"; import { customScriptRunnerConfig, Dependency, ProjectConfiguration } from "../types"; import { FormattedMessage } from "react-intl"; -import { faCheck, faExclamationCircle, faToggleOn } from "@fortawesome/free-solid-svg-icons"; +import { faAngleDown, faAngleRight, faCaretDown, faCaretRight, faCheck, faChevronLeft, faChevronUp, faExclamationCircle, faRedoAlt, faToggleOn } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Profile } from "@remixproject/plugin-utils"; import { IframeProfile, ViewProfile } from "@remixproject/engine-web"; @@ -29,13 +29,18 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => { const { loadScriptRunner, configurations, activeConfig, enableCustomScriptRunner } = props; const [activeKey, setActiveKey] = useState('default'); + useEffect(() => { + }, [activeKey]) + if (!configurations) { return
Loading...
; } + + return (
- + {configurations.filter((config) => config.publish).map((config: ProjectConfiguration, index) => (
@@ -44,8 +49,14 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => { overflowX: 'hidden', textOverflow: 'ellipsis' }} + onClick={() => setActiveKey(activeKey === config.name ? '' : config.name)} > -
{config.title || config.name}
+
+ {activeKey === config.name ? + : + } +
{config.title || config.name}
+
{config.isLoading &&
@@ -55,8 +66,13 @@ export const ScriptRunnerUI = (props: ScriptRunnerUIProps) => { +
} - {!config.isLoading && + {!config.isLoading && config.errorStatus && config.error && +
loadScriptRunner(config)} className="pointer px-2"> + +
} + {!config.isLoading && !config.errorStatus && !config.error &&
loadScriptRunner(config)} className="pointer px-2"> {activeConfig && activeConfig.name !== config.name ? :