Add: background worker

This commit is contained in:
eight 2018-09-25 21:09:40 +08:00
parent ffb13bf1db
commit 41ac66a137

View File

@ -4,11 +4,14 @@ global handleCssTransitionBug detectSloppyRegexps
global openEditor global openEditor
global styleViaAPI global styleViaAPI
global loadScript global loadScript
global usercss global usercss workerUtil
*/ */
'use strict'; 'use strict';
var backgroundWorker = workerUtil.createWorker('/background/background-worker.js'); // eslint-disable-next-line no-var
var backgroundWorker = workerUtil.createWorker({
url: '/background/background-worker.js'
});
window.API_METHODS = Object.assign(window.API_METHODS || {}, { window.API_METHODS = Object.assign(window.API_METHODS || {}, {
@ -21,7 +24,7 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, {
return download(msg.url, msg); return download(msg.url, msg);
}, },
parseCss({code}) { parseCss({code}) {
return usercss.invokeWorker({action: 'parse', code}); return backgroundWorker.parseMozFormat({code});
}, },
getPrefs: prefs.getAll, getPrefs: prefs.getAll,
healthCheck: () => dbExec().then(() => true), healthCheck: () => dbExec().then(() => true),