uuidIndex.register

This commit is contained in:
tophf 2022-01-28 16:03:02 +03:00
parent 4cc367587d
commit 6cda84df66
2 changed files with 11 additions and 5 deletions

View File

@ -12,11 +12,20 @@
uuidIndex
*/
const uuidIndex = new Map();
const bgReady = {};
bgReady.styles = new Promise(r => (bgReady._resolveStyles = r));
bgReady.all = new Promise(r => (bgReady._resolveAll = r));
const uuidIndex = Object.assign(new Map(), {
custom: {},
customize(obj, setter) {
Object.defineProperty(uuidIndex.custom, obj.id, {
get: () => obj,
set: setter,
});
},
});
function addAPI(methods) {
for (const [key, val] of Object.entries(methods)) {
const old = API[key];

View File

@ -73,10 +73,7 @@ const styleMan = (() => {
_id: `${chrome.runtime.id}-${INJ_ORDER}`,
_rev: 0,
};
uuidIndex.custom = Object.defineProperty({}, INJ_ORDER, {
get: () => orderWrap,
set: setOrder,
});
uuidIndex.customize(orderWrap, setOrder);
/** @type {Promise|boolean} will be `true` to avoid wasting a microtask tick on each `await` */
let ready = init();