Skip to content

Commit c6a6599

Browse files
committed
fix imports. fix exports. rename app.js
1 parent 60e58d1 commit c6a6599

21 files changed

+109
-98
lines changed

apps/remix-ide/src/app.js apps/remix-ide/src/app.ts

+78-44
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ import { WalkthroughService } from './walkthroughService'
2626

2727
import { OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, FetchAndCompile, CompilerImports, GistHandler } from '@remix-project/core-plugin'
2828

29-
import {Registry} from '@remix-project/remix-lib'
30-
import {ConfigPlugin} from './app/plugins/config'
31-
import {StoragePlugin} from './app/plugins/storage'
32-
import {Layout} from './app/panels/layout'
33-
import {NotificationPlugin} from './app/plugins/notification'
34-
import {Blockchain} from './blockchain/blockchain'
35-
import {MergeVMProvider, LondonVMProvider, BerlinVMProvider, ShanghaiVMProvider, CancunVMProvider} from './app/providers/vm-provider'
36-
import {MainnetForkVMProvider} from './app/providers/mainnet-vm-fork-provider'
37-
import {SepoliaForkVMProvider} from './app/providers/sepolia-vm-fork-provider'
38-
import {GoerliForkVMProvider} from './app/providers/goerli-vm-fork-provider'
39-
import {CustomForkVMProvider} from './app/providers/custom-vm-fork-provider'
40-
import {HardhatProvider} from './app/providers/hardhat-provider'
41-
import {GanacheProvider} from './app/providers/ganache-provider'
42-
import {FoundryProvider} from './app/providers/foundry-provider'
43-
import {ExternalHttpProvider} from './app/providers/external-http-provider'
29+
import { Registry } from '@remix-project/remix-lib'
30+
import { ConfigPlugin } from './app/plugins/config'
31+
import { StoragePlugin } from './app/plugins/storage'
32+
import { Layout } from './app/panels/layout'
33+
import { NotificationPlugin } from './app/plugins/notification'
34+
import { Blockchain } from './blockchain/blockchain'
35+
import { MergeVMProvider, LondonVMProvider, BerlinVMProvider, ShanghaiVMProvider, CancunVMProvider } from './app/providers/vm-provider'
36+
import { MainnetForkVMProvider } from './app/providers/mainnet-vm-fork-provider'
37+
import { SepoliaForkVMProvider } from './app/providers/sepolia-vm-fork-provider'
38+
import { GoerliForkVMProvider } from './app/providers/goerli-vm-fork-provider'
39+
import { CustomForkVMProvider } from './app/providers/custom-vm-fork-provider'
40+
import { HardhatProvider } from './app/providers/hardhat-provider'
41+
import { GanacheProvider } from './app/providers/ganache-provider'
42+
import { FoundryProvider } from './app/providers/foundry-provider'
43+
import { ExternalHttpProvider } from './app/providers/external-http-provider'
4444
import { EnvironmentExplorer } from './app/providers/environment-explorer'
4545
import { FileDecorator } from './app/plugins/file-decorator'
4646
import { CodeFormat } from './app/plugins/code-format'
@@ -58,7 +58,7 @@ import { xtermPlugin } from './app/plugins/electron/xtermPlugin'
5858
import { ripgrepPlugin } from './app/plugins/electron/ripgrepPlugin'
5959
import { compilerLoaderPlugin, compilerLoaderPluginDesktop } from './app/plugins/electron/compilerLoaderPlugin'
6060
import { appUpdaterPlugin } from './app/plugins/electron/appUpdaterPlugin'
61-
import { remixAIDesktopPlugin } from './app/plugins/electron/remixAIDesktopPlugin'
61+
import { remixAIDesktopPlugin } from './app/plugins/electron/remixAIDesktopPlugin'
6262
import { RemixAIPlugin } from './app/plugins/remixAIPlugin'
6363
import { SlitherHandleDesktop } from './app/plugins/electron/slitherPlugin'
6464
import { SlitherHandle } from './app/files/slither-handle'
@@ -72,37 +72,37 @@ import { Matomo } from './app/plugins/matomo'
7272

7373
import { TemplatesSelectionPlugin } from './app/plugins/templates-selection/templates-selection-plugin'
7474

75-
const isElectron = require('is-electron')
75+
import isElectron from 'is-electron'
7676

77-
const remixLib = require('@remix-project/remix-lib')
77+
import * as remixLib from '@remix-project/remix-lib'
7878

7979
import { QueryParams } from '@remix-project/remix-lib'
8080
import { SearchPlugin } from './app/tabs/search'
8181
import { ScriptRunnerUIPlugin } from './app/tabs/script-runner-ui'
8282
import { ElectronProvider } from './app/files/electronProvider'
8383

8484
const Storage = remixLib.Storage
85-
const RemixDProvider = require('./app/files/remixDProvider')
86-
const Config = require('./config')
85+
import RemixDProvider from './app/files/remixDProvider'
86+
import Config from './config'
8787

88-
const FileManager = require('./app/files/fileManager')
88+
import FileManager from './app/files/fileManager'
8989
import FileProvider from "./app/files/fileProvider"
9090
import { appPlatformTypes } from '@remix-ui/app'
9191

92-
const DGitProvider = require('./app/files/dgitProvider')
93-
const WorkspaceFileProvider = require('./app/files/workspaceFileProvider')
92+
import DGitProvider from './app/files/dgitProvider'
93+
import WorkspaceFileProvider from './app/files/workspaceFileProvider'
9494

95-
const PluginManagerComponent = require('./app/components/plugin-manager-component')
95+
import PluginManagerComponent from './app/components/plugin-manager-component'
9696

97-
const CompileTab = require('./app/tabs/compile-tab')
98-
const SettingsTab = require('./app/tabs/settings-tab')
99-
const AnalysisTab = require('./app/tabs/analysis-tab')
100-
const { DebuggerTab } = require('./app/tabs/debugger-tab')
101-
const TestTab = require('./app/tabs/test-tab')
102-
const FilePanel = require('./app/panels/file-panel')
103-
const Editor = require('./app/editor/editor')
104-
const Terminal = require('./app/panels/terminal')
105-
const { TabProxy } = require('./app/panels/tab-proxy.js')
97+
import CompileTab from './app/tabs/compile-tab'
98+
import SettingsTab from './app/tabs/settings-tab'
99+
import AnalysisTab from './app/tabs/analysis-tab'
100+
import DebuggerTab from './app/tabs/debugger-tab'
101+
import TestTab from './app/tabs/test-tab'
102+
import Filepanel from './app/panels/file-panel'
103+
import Editor from './app/editor/editor'
104+
import Terminal from './app/panels/terminal'
105+
import TabProxy from './app/panels/tab-proxy.js'
106106

107107
const _paq = (window._paq = window._paq || [])
108108

@@ -115,16 +115,49 @@ export class platformApi {
115115
}
116116
}
117117

118+
type Components = {
119+
filesProviders: {
120+
browser?: any
121+
localhost?: any
122+
workspace?: any
123+
electron?: any
124+
}
125+
}
126+
118127
class AppComponent {
128+
appManager: RemixAppManager
129+
queryParams: QueryParams
130+
private _components: Components
131+
panels: any
132+
workspace: any
133+
engine: RemixEngine
134+
matomoConfAlreadySet: any
135+
matomoCurrentSetting: any
136+
showMatomo: boolean
137+
walkthroughService: WalkthroughService
138+
platform: 'desktop' | 'web'
139+
gistHandler: GistHandler
140+
themeModule: ThemeModule
141+
localeModule: LocaleModule
142+
notification: NotificationPlugin
143+
layout: Layout
144+
mainview: any
145+
menuicons: VerticalIcons
146+
sidePanel: SidePanel
147+
hiddenPanel: HiddenPanel
148+
pinnedPanel: PinnedPanel
149+
popupPanel: PopupPanel
150+
statusBar: StatusBar
151+
settings: SettingsTab
119152
constructor() {
120153
const PlatFormAPi = new platformApi()
121154
Registry.getInstance().put({
122155
api: PlatFormAPi,
123156
name: 'platform'
124157
})
125-
this.appManager = new RemixAppManager({})
158+
this.appManager = new RemixAppManager()
126159
this.queryParams = new QueryParams()
127-
this._components = {}
160+
this._components = {} as Components
128161
// setup storage
129162
const configStorage = new Storage('config-v0.8:')
130163

@@ -161,7 +194,6 @@ class AppComponent {
161194
name: 'fileproviders'
162195
})
163196

164-
165197
}
166198

167199
async run() {
@@ -184,7 +216,7 @@ class AppComponent {
184216
this.matomoConfAlreadySet = Registry.getInstance().get('config').api.exists('settings/matomo-analytics')
185217
this.matomoCurrentSetting = Registry.getInstance().get('config').api.get('settings/matomo-analytics')
186218

187-
let electronTracking = window.electronAPI ? await window.electronAPI.canTrackMatomo() : false
219+
const electronTracking = (window as any).electronAPI ? await (window as any).electronAPI.canTrackMatomo() : false
188220

189221
const lastMatomoCheck = window.localStorage.getItem('matomo-analytics-consent')
190222
const sixMonthsAgo = new Date();
@@ -193,11 +225,11 @@ class AppComponent {
193225
const e2eforceMatomoToShow = window.localStorage.getItem('showMatomo') && window.localStorage.getItem('showMatomo') === 'true'
194226
const contextShouldShowMatomo = matomoDomains[window.location.hostname] || e2eforceMatomoToShow || electronTracking
195227
const shouldRenewConsent = this.matomoCurrentSetting === false && (!lastMatomoCheck || new Date(Number(lastMatomoCheck)) < sixMonthsAgo) // it is set to false for more than 6 months.
196-
this.showMatomo = contextShouldShowMatomo && (!this.matomoConfAlreadySet || shouldRenewConsent)
228+
this.showMatomo = contextShouldShowMatomo && (!this.matomoConfAlreadySet || shouldRenewConsent)
197229

198230
if (this.showMatomo && shouldRenewConsent) {
199231
_paq.push(['trackEvent', 'Matomo', 'refreshMatomoPermissions']);
200-
}
232+
}
201233

202234
this.walkthroughService = new WalkthroughService(appManager)
203235

@@ -387,7 +419,7 @@ class AppComponent {
387419
ganacheProvider,
388420
foundryProvider,
389421
externalHttpProvider,
390-
environmentExplorer,
422+
environmentExplorer,
391423
this.walkthroughService,
392424
search,
393425
solidityumlgen,
@@ -456,10 +488,10 @@ class AppComponent {
456488
this.popupPanel = new PopupPanel()
457489

458490
const pluginManagerComponent = new PluginManagerComponent(appManager, this.engine)
459-
const filePanel = new FilePanel(appManager, contentImport)
491+
const filePanel = new Filepanel(appManager, contentImport)
460492
this.statusBar = new StatusBar(filePanel, this.menuicons)
461493
const landingPage = new LandingPage(appManager, this.menuicons, fileManager, filePanel, contentImport)
462-
this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor, appManager)
494+
this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor)//, appManager)
463495

464496
this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel])
465497

@@ -514,7 +546,7 @@ class AppComponent {
514546

515547
async activate() {
516548
const queryParams = new QueryParams()
517-
const params = queryParams.get()
549+
const params: any = queryParams.get()
518550

519551
try {
520552
this.engine.register(await this.appManager.registeredPlugins())
@@ -610,10 +642,11 @@ class AppComponent {
610642
}
611643

612644
if (params.call) {
613-
const callDetails = params.call.split('//')
645+
const callDetails: any = params.call.split('//')
614646
if (callDetails.length > 1) {
615647
this.appManager.call('notification', 'toast', `initiating ${callDetails[0]} and calling "${callDetails[1]}" ...`)
616648
// @todo(remove the timeout when activatePlugin is on 0.3.0)
649+
//@ts-ignore
617650
await this.appManager.call(...callDetails).catch(console.error)
618651
}
619652
}
@@ -629,6 +662,7 @@ class AppComponent {
629662

630663
// @todo(remove the timeout when activatePlugin is on 0.3.0)
631664
try {
665+
//@ts-ignore
632666
await this.appManager.call(...callDetails)
633667
} catch (e) {
634668
console.error(e)

apps/remix-ide/src/app/components/main-panel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const profile = {
1515
export class MainPanel extends AbstractPanel {
1616
element: HTMLDivElement
1717
dispatch: React.Dispatch<any> = () => {}
18-
constructor(config) {
18+
constructor(config = null) {
1919
super(profile)
2020
this.element = document.createElement('div')
2121
this.element.setAttribute('data-id', 'mainPanelPluginsContainer')

apps/remix-ide/src/app/components/plugin-manager-component.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const profile = {
1919
maintainedBy: "Remix"
2020
}
2121

22-
class PluginManagerComponent extends ViewPlugin {
22+
export default class PluginManagerComponent extends ViewPlugin {
2323
constructor (appManager, engine) {
2424
super(profile)
2525
this.appManager = appManager

apps/remix-ide/src/app/components/popup-panel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class PopupPanel extends AbstractPanel {
2424
dispatch: React.Dispatch<any> = () => { }
2525
appStateDispatch: React.Dispatch<AppAction> = () => { }
2626

27-
constructor(config) {
27+
constructor(config = null) {
2828
super(profile)
2929
this.event = new EventEmitter()
3030
}

apps/remix-ide/src/app/editor/editor.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const profile = {
1616
methods: ['highlight', 'discardHighlight', 'clearAnnotations', 'addLineText', 'discardLineTexts', 'addAnnotation', 'gotoLine', 'revealRange', 'getCursorPosition', 'open', 'addModel','addErrorMarker', 'clearErrorMarkers', 'getText', 'getPositionAt', 'openReadOnly'],
1717
}
1818

19-
class Editor extends Plugin {
19+
export default class Editor extends Plugin {
2020
constructor () {
2121
super(profile)
2222

@@ -90,7 +90,7 @@ class Editor extends Plugin {
9090
}
9191

9292
render () {
93-
return <div ref={(element)=>{
93+
return <div ref={(element)=>{
9494
this.ref = element
9595
this.ref.currentContent = () => this.currentContent() // used by e2e test
9696
this.ref.setCurrentContent = (value) => {
@@ -102,7 +102,7 @@ class Editor extends Plugin {
102102
this.ref.gotoLine = (line, column) => this.gotoLine(line, column || 0)
103103
this.ref.getCursorPosition = () => this.getCursorPosition()
104104
this.ref.addDecoration = (marker, filePath, typeOfDecoration) => this.addDecoration(marker, filePath, typeOfDecoration)
105-
this.ref.clearDecorationsByPlugin = (filePath, plugin, typeOfDecoration) => this.clearDecorationsByPlugin(filePath, plugin, typeOfDecoration)
105+
this.ref.clearDecorationsByPlugin = (filePath, plugin, typeOfDecoration) => this.clearDecorationsByPlugin(filePath, plugin, typeOfDecoration)
106106
this.ref.keepDecorationsFor = (name, typeOfDecoration) => this.keepDecorationsFor(name, typeOfDecoration)
107107
}} id='editorView'>
108108
<PluginViewWrapper plugin={this} />
@@ -249,7 +249,7 @@ class Editor extends Plugin {
249249
*/
250250
async _createSession (path, content, mode, readOnly) {
251251
if (!this.activated) return
252-
252+
253253
this.emit('addModel', content, mode, path, readOnly || this.readOnlySessions[path])
254254
return {
255255
path,
@@ -548,7 +548,7 @@ class Editor extends Plugin {
548548
decoration.from = from
549549

550550
const { currentDecorations, registeredDecorations } = this.api.addDecoration(decoration, path, typeOfDecoration)
551-
if (!this.registeredDecorations[typeOfDecoration][filePath]) this.registeredDecorations[typeOfDecoration][filePath] = []
551+
if (!this.registeredDecorations[typeOfDecoration][filePath]) this.registeredDecorations[typeOfDecoration][filePath] = []
552552
this.registeredDecorations[typeOfDecoration][filePath].push(...registeredDecorations)
553553
if (!this.currentDecorations[typeOfDecoration][filePath]) this.currentDecorations[typeOfDecoration][filePath] = []
554554
this.currentDecorations[typeOfDecoration][filePath].push(...currentDecorations)
@@ -601,5 +601,3 @@ class Editor extends Plugin {
601601
return this.api.getPositionAt(offset)
602602
}
603603
}
604-
605-
module.exports = Editor

apps/remix-ide/src/app/files/dgitProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const profile: LibraryProfile = {
2828
, 'getGitHubUser', 'remotebranches', 'remotecommits', 'repositories', 'getCommitChanges', 'compareBranches'],
2929
kind: 'file-system'
3030
}
31-
class DGitProvider extends Plugin<any, CustomRemixApi> {
31+
export default class DGitProvider extends Plugin<any, CustomRemixApi> {
3232
constructor() {
3333
super(profile)
3434
}

apps/remix-ide/src/app/files/fileManager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const errorMsg = {
4040
const createError = (err) => {
4141
return new Error(`${errorMsg[err.code]} ${err.message || ''}`)
4242
}
43-
class FileManager extends Plugin {
43+
export default class FileManager extends Plugin {
4444
mode: string
4545
openedFiles: any
4646
editor: any

apps/remix-ide/src/app/files/remixDProvider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22
import FileProvider from "./fileProvider"
33

4-
module.exports = class RemixDProvider extends FileProvider {
4+
export default class RemixDProvider extends FileProvider {
55
constructor (appManager) {
66
super('localhost')
77
this._appManager = appManager

apps/remix-ide/src/app/files/workspaceFileProvider.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const EventManager = require('events')
44
import FileProvider from "./fileProvider"
55

6-
class WorkspaceFileProvider extends FileProvider {
6+
export default class WorkspaceFileProvider extends FileProvider {
77
constructor () {
88
super('')
99
this.workspacesPath = '.workspaces'
@@ -18,10 +18,10 @@ class WorkspaceFileProvider extends FileProvider {
1818
})
1919
}).catch((e) => {
2020
console.log(e)
21-
})
21+
})
2222
} catch (e) {
2323
// we don't need to log error if this throws an error
24-
}
24+
}
2525
}
2626

2727
setWorkspace (workspace) {

apps/remix-ide/src/app/panels/file-panel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const profile = {
5555
version: packageJson.version,
5656
maintainedBy: 'Remix'
5757
}
58-
module.exports = class Filepanel extends ViewPlugin {
58+
export default class Filepanel extends ViewPlugin {
5959
constructor(appManager, contentImport) {
6060
super(profile)
6161
this.registry = Registry.getInstance()

apps/remix-ide/src/app/panels/layout.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const profile: Profile = {
1212
interface panelState {
1313
active: boolean
1414
plugin: Plugin
15-
minimized: boolean
15+
minimized?: boolean
1616
}
1717
interface panels {
1818
tabs: panelState

apps/remix-ide/src/app/panels/tab-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const profile = {
1010
kind: 'other'
1111
}
1212

13-
export class TabProxy extends Plugin {
13+
export default class TabProxy extends Plugin {
1414
constructor (fileManager, editor) {
1515
super(profile)
1616
this.event = new EventEmitter()

0 commit comments

Comments
 (0)