diff --git a/src/util/_handleIframe_preprocessor.js b/src/util/_handleIframe_preprocessor.js deleted file mode 100644 index ae01633..0000000 --- a/src/util/_handleIframe_preprocessor.js +++ /dev/null @@ -1,58 +0,0 @@ -const Loader = require('./Loader') - -const wrapProcessor = (preprocessor, path, handle) => async data => { - let ext = $fs.utils.getExt(path), - processed = await preprocessor(data, path).catch(console.error), - blob = new Blob([ processed ], { type: le._get.ext.mime[ext] }) - - handle( URL.createObjectURL(blob) ) -} - -const handleIframe = async (iframe, path = '/') => { - const convert = (tag, from, to, preprocessor) => { - let elements = iframe.contentDocument.querySelectorAll(tag) - - for(let element of elements) { - let original = element.getAttribute(from) - - if(!original) - continue - - let handle = url => { - element[to] = url - } - - $bundle.for(path).open(original, preprocessor ? 'String' : 'URL') - .then(preprocessor ? wrapProcessor(preprocessor, path, handle) : handle) - } - } - - convert('script', 'lsrc', 'src') - convert('img', 'lsrc', 'src') - convert('link', 'lhref', 'href', async (stylesheet, path) => { - let matches = stylesheet.matchAll(/url\(("(.+?)"|'(.+?)'|(.+?))\)/g), - fromIndex = 0, - out = [] - - console.log(matches) - - for(let match of matches) { - let bundle = $bundle.for( $fs.utils.getFolderPath(path) ) - - console.log(bundle.access(match[2])) - - out.concat([ - stylesheet.slice(fromIndex, match.index), - 'url("' + await bundle.open(match[2], 'URL') + '")' - ]) - - fromIndex = match.index + match[0].length - } - - console.log(out, fromIndex) - - return out.join('') - }) -} - -module.exports = handleIframe \ No newline at end of file