Files
bworld/server/content_worker.ts
T
2026-11-14 12:18:41 -03:00

19 lines
771 B
TypeScript

// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
/// <reference lib="deno.worker" />
// runs the content phase of the mods' scripts for server/load_mods.ts, without permissions like the game's worker,
// since the host that loads mods can read and write files. gets each one's script and answers with what each
// registered, in order
import { type ContentScriptCode, run_content_script } from "@/common/content_scripts.ts";
import { data_url } from "@/common/mod.ts";
self.onmessage = async (event: MessageEvent<ContentScriptCode[]>) => {
const results = [];
for (const { code, ...script } of event.data) {
results.push(await run_content_script({ ...script, url: data_url(code) }));
}
self.postMessage(results);
};