Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
1d6ae33b
Commit
1d6ae33b
authored
Dec 29, 2020
by
aniket-engg
Committed by
Aniket
Jan 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean code from compiler-imports
parent
91352d0e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
54 deletions
+1
-54
compiler-imports.js
apps/remix-ide/src/app/compiler/compiler-imports.js
+1
-54
No files found.
apps/remix-ide/src/app/compiler/compiler-imports.js
View file @
1d6ae33b
...
@@ -6,9 +6,7 @@ const remixTests = require('@remix-project/remix-tests')
...
@@ -6,9 +6,7 @@ const remixTests = require('@remix-project/remix-tests')
const
globalRegistry
=
require
(
'../../global/registry'
)
const
globalRegistry
=
require
(
'../../global/registry'
)
const
addTooltip
=
require
(
'../ui/tooltip'
)
const
addTooltip
=
require
(
'../ui/tooltip'
)
const
async
=
require
(
'async'
)
const
async
=
require
(
'async'
)
var
swarmgw
=
require
(
'swarmgw'
)()
var
resolver
=
require
(
'@resolver-engine/imports'
).
ImportsEngine
()
var
resolver
=
require
(
'@resolver-engine/imports'
).
ImportsEngine
()
var
request
=
require
(
'request'
)
const
profile
=
{
const
profile
=
{
name
:
'contentImport'
,
name
:
'contentImport'
,
...
@@ -27,52 +25,6 @@ module.exports = class CompilerImports extends Plugin {
...
@@ -27,52 +25,6 @@ module.exports = class CompilerImports extends Plugin {
this
.
previouslyHandled
=
{}
// cache import so we don't make the request at each compilation.
this
.
previouslyHandled
=
{}
// cache import so we don't make the request at each compilation.
}
}
handleSwarmImport
(
url
,
cleanUrl
,
cb
)
{
swarmgw
.
get
(
url
,
function
(
err
,
content
)
{
cb
(
err
,
content
,
cleanUrl
)
})
}
handleIPFS
(
url
,
cb
)
{
// replace ipfs:// with /ipfs/
url
=
url
.
replace
(
/^ipfs:
\/\/?
/
,
'ipfs/'
)
return
request
.
get
(
{
url
:
'https://ipfsgw.komputing.org/'
+
url
},
(
err
,
r
,
data
)
=>
{
if
(
err
)
{
return
cb
(
err
||
'Unknown transport error'
)
}
cb
(
null
,
data
,
url
)
})
}
handleHttpCall
(
url
,
cleanUrl
,
cb
)
{
console
.
log
(
'Inside ide handleHttpCall'
)
return
request
.
get
(
{
url
},
(
err
,
r
,
data
)
=>
{
if
(
err
)
{
return
cb
(
err
||
'Unknown transport error'
)
}
cb
(
null
,
data
,
cleanUrl
)
})
}
handlers
()
{
return
[
{
type
:
'github'
,
match
:
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleGithubCall
(
match
[
3
],
match
[
4
],
cb
)
}
},
{
type
:
'http'
,
match
:
/^
(
http
?
:
\/\/?(
.*
))
$/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleHttpCall
(
match
[
1
],
match
[
2
],
cb
)
}
},
{
type
:
'https'
,
match
:
/^
(
https
?
:
\/\/?(
.*
))
$/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleHttpCall
(
match
[
1
],
match
[
2
],
cb
)
}
},
{
type
:
'swarm'
,
match
:
/^
(
bzz-raw
?
:
\/\/?(
.*
))
$/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleSwarmImport
(
match
[
1
],
match
[
2
],
cb
)
}
},
{
type
:
'ipfs'
,
match
:
/^
(
ipfs:
\/\/?
.+
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleIPFS
(
match
[
1
],
cb
)
}
}
]
}
isRelativeImport
(
url
)
{
isRelativeImport
(
url
)
{
return
/^
([^/]
+
)
/
.
exec
(
url
)
return
/^
([^/]
+
)
/
.
exec
(
url
)
}
}
...
@@ -109,17 +61,12 @@ module.exports = class CompilerImports extends Plugin {
...
@@ -109,17 +61,12 @@ module.exports = class CompilerImports extends Plugin {
return
cb
(
null
,
imported
.
content
,
imported
.
cleanUrl
,
imported
.
type
,
url
)
return
cb
(
null
,
imported
.
content
,
imported
.
cleanUrl
,
imported
.
type
,
url
)
}
}
var
handlers
=
this
.
urlResolver
.
getHandlers
()
var
handlers
=
this
.
urlResolver
.
getHandlers
()
var
found
=
false
var
found
=
false
handlers
.
forEach
(
function
(
handler
)
{
handlers
.
forEach
(
function
(
handler
)
{
if
(
found
)
{
if
(
found
)
return
return
}
var
match
=
handler
.
match
(
url
)
var
match
=
handler
.
match
(
url
)
if
(
match
)
{
if
(
match
)
{
found
=
true
found
=
true
loadingCb
(
'Loading '
+
url
+
' ...'
)
loadingCb
(
'Loading '
+
url
+
' ...'
)
handler
.
handle
(
match
).
then
(
function
(
result
)
{
handler
.
handle
(
match
).
then
(
function
(
result
)
{
const
{
content
,
cleanUrl
}
=
result
const
{
content
,
cleanUrl
}
=
result
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment