mirror of
https://github.com/zadam/trilium.git
synced 2024-11-17 21:21:40 +08:00
23 lines
No EOL
601 B
JavaScript
23 lines
No EOL
601 B
JavaScript
import ScriptContext from "./script_context.js";
|
|
import server from "./server.js";
|
|
|
|
async function executeBundle(bundle) {
|
|
const apiContext = ScriptContext(bundle.note, bundle.allNotes);
|
|
|
|
return await (function () {
|
|
return eval(`const apiContext = this; (async function() { ${bundle.script}\r\n})()`);
|
|
}.call(apiContext));
|
|
}
|
|
|
|
async function executeStartupBundles() {
|
|
const scriptBundles = await server.get("script/startup");
|
|
|
|
for (const bundle of scriptBundles) {
|
|
await executeBundle(bundle);
|
|
}
|
|
}
|
|
|
|
export default {
|
|
executeBundle,
|
|
executeStartupBundles
|
|
} |