From 09a7d628c57590218b2ac1222028880179c85fbf Mon Sep 17 00:00:00 2001
From: Aniket <30843294+Aniket-Engg@users.noreply.github.com>
Date: Fri, 30 Oct 2020 19:21:24 +0530
Subject: [PATCH] Custom compiler using url (#532)
* package.json removed
* load custom compiler through URL
---
.../app/tabs/compileTab/compilerContainer.js | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js b/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js
index a874880d61..c6d278a9ba 100644
--- a/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js
+++ b/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js
@@ -174,10 +174,13 @@ class CompilerContainer {
render () {
this.compileTabLogic.compiler.event.register('compilerLoaded', (version) => this.setVersionText(version))
- this.fetchAllVersion((allversions, selectedVersion) => {
+ this.fetchAllVersion((allversions, selectedVersion, isURL) => {
this.data.allversions = allversions
- this.data.selectedVersion = selectedVersion
- if (this._view.versionSelector) this._updateVersionSelector()
+ if(isURL) this._updateVersionSelector(selectedVersion)
+ else {
+ this.data.selectedVersion = selectedVersion
+ if (this._view.versionSelector) this._updateVersionSelector()
+ }
})
this._view.warnCompilationSlow = yo``
@@ -407,6 +410,7 @@ class CompilerContainer {
this.data.selectedVersion = customUrl
this._view.versionSelector.appendChild(yo``)
url = customUrl
+ this.queryParams.update({ version: this.data.selectedVersion })
} else if (this.data.selectedVersion === 'builtin') {
let location = window.document.location
location = `${location.protocol}//${location.host}/${location.pathname}`
@@ -449,7 +453,7 @@ class CompilerContainer {
// fetching both normal and wasm builds and creating a [version, baseUrl] map
async fetchAllVersion (callback) {
- let allVersions, selectedVersion, allVersionsWasm
+ let allVersions, selectedVersion, allVersionsWasm, isURL
// fetch normal builds
const binRes = await promisedMiniXhr(`${baseURLBin}/list.json`)
// fetch wasm builds
@@ -463,6 +467,11 @@ class CompilerContainer {
allVersions = JSON.parse(binRes.json).builds.slice().reverse()
selectedVersion = this.data.defaultVersion
if (this.queryParams.get().version) selectedVersion = this.queryParams.get().version
+ // Check if version is a URL and corresponding filename starts with 'soljson'
+ if (selectedVersion.startsWith('https://')) {
+ const urlArr = selectedVersion.split('/')
+ if(urlArr[urlArr.length - 1].startsWith('soljson')) isURL = true
+ }
if (wasmRes.event.type !== 'error') {
allVersionsWasm = JSON.parse(wasmRes.json).builds.slice().reverse()
}
@@ -481,7 +490,7 @@ class CompilerContainer {
}
})
}
- callback(allVersions, selectedVersion)
+ callback(allVersions, selectedVersion, isURL)
}
scheduleCompilation () {
if (!this.config.get('autoCompile')) return