mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +00:00
handle proper loading of frame.mjs & frame.css
This commit is contained in:
parent
e4943d9abb
commit
57c4d63275
28
insert/frame.mjs
Normal file
28
insert/frame.mjs
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* notion-enhancer
|
||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||
* (https://notion-enhancer.github.io/) under the MIT license
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
(async () => {
|
||||
const api = await import('./api/index.mjs'),
|
||||
{ fs, registry, web } = api;
|
||||
|
||||
for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
|
||||
for (const sheet of mod.css?.frame || []) {
|
||||
web.loadStylesheet(`repo/${mod._dir}/${sheet}`);
|
||||
}
|
||||
for (let script of mod.js?.frame || []) {
|
||||
script = await import(fs.localPath(`repo/${mod._dir}/${script}`));
|
||||
script.default(api, await registry.db(mod.id));
|
||||
}
|
||||
|
||||
const errors = await registry.errors();
|
||||
if (errors.length) {
|
||||
console.error('[notion-enhancer] registry errors:');
|
||||
console.table(errors);
|
||||
}
|
||||
}
|
||||
})();
|
@ -11,6 +11,16 @@ module.exports = async function (target, __exports, __eval) {
|
||||
const api = require('notion-enhancer/api/index.cjs'),
|
||||
{ registry } = api;
|
||||
|
||||
if (target === 'renderer/index') {
|
||||
document.addEventListener('readystatechange', (event) => {
|
||||
if (document.readyState !== 'complete') return false;
|
||||
const script = document.createElement('script');
|
||||
script.type = 'module';
|
||||
script.src = api.fs.localPath('frame.mjs');
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
}
|
||||
|
||||
if (target === 'renderer/preload') {
|
||||
document.addEventListener('readystatechange', (event) => {
|
||||
if (document.readyState !== 'complete') return false;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4817c105ffd8f8db9663ef5d5ba1f19bd6b95dd0
|
||||
Subproject commit 0298578df4d088dd4ad847b9311c72c8caa7aee8
|
Loading…
Reference in New Issue
Block a user