handlers loaded from remix-url-resolver

yann300-patch-18
aniket-engg 4 years ago committed by Aniket
parent 672a662ab8
commit c8a00057b9
  1. 22
      apps/remix-ide/src/app/compiler/compiler-imports.js
  2. 2
      libs/remix-url-resolver/src/index.ts
  3. 1
      libs/remix-url-resolver/src/resolve.ts

@ -1,6 +1,7 @@
'use strict'
import { Plugin } from '@remixproject/engine'
import * as packageJson from '../../../../../package.json'
import {RemixURLResolver} from '@remix-project/remix-url-resolver'
const remixTests = require('@remix-project/remix-tests')
const globalRegistry = require('../../global/registry')
const addTooltip = require('../ui/tooltip')
@ -79,6 +80,7 @@ module.exports = class CompilerImports extends Plugin {
}
handleHttpCall (url, cleanUrl, cb) {
console.log('Inside ide handleHttpCall')
return request.get(
{
url
@ -136,7 +138,7 @@ module.exports = class CompilerImports extends Plugin {
if (imported) {
return cb(null, imported.content, imported.cleanUrl, imported.type, url)
}
var handlers = this.handlers()
var handlers = new RemixURLResolver().getHandlers()
var found = false
handlers.forEach(function (handler) {
@ -149,18 +151,24 @@ module.exports = class CompilerImports extends Plugin {
found = true
loadingCb('Loading ' + url + ' ...')
handler.handler(match, function (err, content, cleanUrl) {
if (err) {
cb('Unable to import "' + cleanUrl + '": ' + err)
return
}
handler.handle(match).then(function(content) {
self.previouslyHandled[url] = {
content: content,
cleanUrl: cleanUrl,
type: handler.type
}
cb(null, content, cleanUrl, handler.type, url)
})
}).catch(function (error) {
cb('Unable to import "' + cleanUrl + '": ' + error)
return
})
// function (err, content, cleanUrl) {
// if (err) {
// }
// })
}
})
if (found) return

@ -1 +1 @@
export * from './resolve'
export { RemixURLResolver } from './resolve'

@ -42,6 +42,7 @@ export class RemixURLResolver {
* @params cleanURL
*/
async handleHttp(url: string, _: string) {
console.log('Inside libs handleHttpCall')
//eslint-disable-next-line no-useless-catch
try {
const response: AxiosResponse = await axios.get(url)

Loading…
Cancel
Save