18 lines
761 B
TypeScript
18 lines
761 B
TypeScript
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
/// <reference lib="deno.worker" />
|
|
|
|
// runs the mods' content 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 { mod, version, code } of event.data) {
|
|
results.push(await run_content_script({ mod, version, url: data_url(code) }));
|
|
}
|
|
self.postMessage(results);
|
|
};
|