Fix plugOverrides being broken

This commit is contained in:
Zef Hemel
2023-12-12 14:15:46 +01:00
parent 8ed3cd0e4a
commit e0bb1dde79
4 changed files with 21 additions and 24 deletions
+1 -11
View File
@@ -1,8 +1,7 @@
import { Hook, Manifest } from "./types.ts";
import { Hook } from "./types.ts";
import { EventEmitter } from "./event.ts";
import type { SandboxFactory } from "./sandbox.ts";
import { Plug } from "./plug.ts";
import { deepObjectMerge } from "$sb/lib/json.ts";
import { InMemoryManifestCache, ManifestCache } from "./manifest_cache.ts";
export interface SysCallMapping {
@@ -112,21 +111,12 @@ export class System<HookT> extends EventEmitter<SystemEvents<HookT>> {
name: string,
hash: number,
sandboxFactory: SandboxFactory<HookT>,
// Mapping plug name -> manifest overrides
manifestOverrides?: Record<string, Partial<Manifest<HookT>>>,
): Promise<Plug<HookT>> {
const plug = new Plug(this, workerUrl, name, hash, sandboxFactory);
// Wait for worker to boot, and pass back its manifest
await plug.ready;
if (manifestOverrides && manifestOverrides[plug.manifest!.name]) {
plug.manifest = deepObjectMerge(
plug.manifest,
manifestOverrides[plug.manifest!.name],
);
// console.log("New manifest", plug.manifest);
}
// and there it is!
const manifest = plug.manifest!;