Rewrote all plugs using MarkdownTree
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Hook, Manifest } from "../types";
|
||||
import { System } from "../system";
|
||||
import { safeRun } from "../util";
|
||||
import {Hook, Manifest} from "../types";
|
||||
import {System} from "../system";
|
||||
import {safeRun} from "../util";
|
||||
|
||||
// System events:
|
||||
// - plug:load (plugName: string)
|
||||
@@ -16,7 +16,6 @@ export class EventHook implements Hook<EventHookT> {
|
||||
if (!this.system) {
|
||||
throw new Error("Event hook is not initialized");
|
||||
}
|
||||
let promises: Promise<void>[] = [];
|
||||
for (const plug of this.system.loadedPlugs.values()) {
|
||||
for (const [name, functionDef] of Object.entries(
|
||||
plug.manifest!.functions
|
||||
@@ -24,12 +23,11 @@ export class EventHook implements Hook<EventHookT> {
|
||||
if (functionDef.events && functionDef.events.includes(eventName)) {
|
||||
// Only dispatch functions that can run in this environment
|
||||
if (plug.canInvoke(name)) {
|
||||
promises.push(plug.invoke(name, [data]));
|
||||
await plug.invoke(name, [data]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
apply(system: System<EventHookT>): void {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {EventHook} from "../hooks/event";
|
||||
|
||||
export function eventSyscalls(eventHook: EventHook): SysCallMapping {
|
||||
return {
|
||||
"event.dispatch": async(ctx, eventName: string, data: any) => {
|
||||
"event.dispatch": async (ctx, eventName: string, data: any) => {
|
||||
return eventHook.dispatchEvent(eventName, data);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ export function fetchSyscalls(): SysCallMapping {
|
||||
let resp = await fetch(url, init);
|
||||
return resp.json();
|
||||
},
|
||||
"fetch.text": async(ctx, url: RequestInfo, init: RequestInit) => {
|
||||
"fetch.text": async (ctx, url: RequestInfo, init: RequestInit) => {
|
||||
let resp = await fetch(url, init);
|
||||
return resp.text();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user