Commit c8a00057 authored by aniket-engg's avatar aniket-engg Committed by Aniket

handlers loaded from remix-url-resolver

parent 672a662a
'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
......
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment