1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-26 08:11:17 +02:00

Merge branch 'master' into release-4.0

This commit is contained in:
Kushagra Gour
2018-10-26 11:38:39 +05:30
31 changed files with 216 additions and 273 deletions

View File

@@ -461,6 +461,21 @@ export function getFilenameFromUrl(url) {
return url.match(/\/([^/]*)$/)[1];
}
export function prettify(content, type = 'js') {
const d = deferred();
const worker = new Worker(
chrome.extension
? chrome.extension.getURL('lib/prettier-worker.js')
: `${BASE_PATH}/lib/prettier-worker.js`
);
worker.postMessage({ content, type });
worker.addEventListener('message', e => {
d.resolve(e.data);
worker.terminate();
});
return d.promise;
}
if (window.IS_EXTENSION) {
document.body.classList.add('is-extension');
} else {