mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-26 11:48:29 +00:00
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
const _global = GameGlobal;
|
|
const adapter = _global.__globalAdapter = {};
|
|
|
|
let inited = false;
|
|
let _callback = null;
|
|
let _wait_worker_t = 0;
|
|
|
|
Object.assign(adapter, {
|
|
init() {
|
|
const { init: initWorker } = require('./worker');
|
|
initWorker(() => {
|
|
inited = true;
|
|
if (CC_USE_WORKER && _callback) {
|
|
console.log("worker waiting time:", Date.now() - _wait_worker_t);
|
|
}
|
|
_callback && _callback();
|
|
_callback = null;
|
|
});
|
|
require('./wrapper/builtin');
|
|
_global.DOMParser = require('../../common/xmldom/dom-parser').DOMParser;
|
|
require('./wrapper/unify');
|
|
require('./wrapper/fs-utils');
|
|
require('../../common/engine/globalAdapter');
|
|
require('./wrapper/systemInfo');
|
|
},
|
|
|
|
adaptEngine() {
|
|
require('./wrapper/error-reporter');
|
|
require('../../common/engine');
|
|
require('./wrapper/engine');
|
|
require('./wrapper/sub-context-adapter');
|
|
},
|
|
|
|
onInited(callback) {
|
|
_wait_worker_t = Date.now();
|
|
if (inited) {
|
|
if (CC_USE_WORKER) {
|
|
console.log("worker waiting time:", Date.now() - _wait_worker_t);
|
|
}
|
|
callback();
|
|
} else {
|
|
_callback = callback;
|
|
}
|
|
},
|
|
});
|