Use distance filter
This commit is contained in:
@@ -44,8 +44,7 @@ return fn["default"].apply(null, arguments);`;
|
||||
|
||||
self.addEventListener("message", (event: { data: WorkerMessage }) => {
|
||||
safeRun(async () => {
|
||||
let messageEvent = event;
|
||||
let data = messageEvent.data;
|
||||
let data = event.data;
|
||||
switch (data.type) {
|
||||
case "load":
|
||||
loadedFunctions.set(data.name!, new Function(wrapScript(data.code!)));
|
||||
|
||||
@@ -27,7 +27,7 @@ export type EndPointDef = {
|
||||
|
||||
export class EndpointHook implements Hook<EndpointHookT> {
|
||||
private app: Express;
|
||||
private prefix: string;
|
||||
readonly prefix: string;
|
||||
|
||||
constructor(app: Express, prefix: string) {
|
||||
this.app = app;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Hook, Manifest } from "../types";
|
||||
import { System } from "../system";
|
||||
import { safeRun } from "../util";
|
||||
|
||||
// System events:
|
||||
// - plug:load (plugName: string)
|
||||
@@ -11,11 +12,11 @@ export type EventHookT = {
|
||||
export class EventHook implements Hook<EventHookT> {
|
||||
private system?: System<EventHookT>;
|
||||
|
||||
async dispatchEvent(eventName: string, data?: any): Promise<any[]> {
|
||||
async dispatchEvent(eventName: string, data?: any): Promise<void> {
|
||||
if (!this.system) {
|
||||
throw new Error("Event hook is not initialized");
|
||||
}
|
||||
let promises: Promise<any>[] = [];
|
||||
let promises: Promise<void>[] = [];
|
||||
for (const plug of this.system.loadedPlugs.values()) {
|
||||
for (const [name, functionDef] of Object.entries(
|
||||
plug.manifest!.functions
|
||||
@@ -28,14 +29,16 @@ export class EventHook implements Hook<EventHookT> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.all(promises);
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
apply(system: System<EventHookT>): void {
|
||||
this.system = system;
|
||||
this.system.on({
|
||||
plugLoaded: (name) => {
|
||||
this.dispatchEvent("plug:load", name);
|
||||
safeRun(async () => {
|
||||
await this.dispatchEvent("plug:load", name);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user