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
+16 -6
View File
@@ -38,10 +38,8 @@ import { languageSyscalls } from "../common/syscalls/language.ts";
import { handlebarsSyscalls } from "../common/syscalls/handlebars.ts";
import { codeWidgetSyscalls } from "./syscalls/code_widget.ts";
import { clientCodeWidgetSyscalls } from "./syscalls/client_code_widget.ts";
import {
InMemoryManifestCache,
KVPrimitivesManifestCache,
} from "../plugos/manifest_cache.ts";
import { KVPrimitivesManifestCache } from "../plugos/manifest_cache.ts";
import { deepObjectMerge } from "$sb/lib/json.ts";
const plugNameExtractRegex = /\/(.+)\.plug\.js$/;
@@ -106,6 +104,20 @@ export class ClientSystem {
this.slashCommandHook = new SlashCommandHook(this.client);
this.system.addHook(this.slashCommandHook);
this.system.on({
plugLoaded: (plug) => {
// Apply plug overrides
const manifestOverrides = this.client.settings.plugOverrides;
if (manifestOverrides && manifestOverrides[plug.manifest!.name]) {
plug.manifest = deepObjectMerge(
plug.manifest,
manifestOverrides[plug.manifest!.name],
);
console.log("New manifest", plug.manifest);
}
},
});
this.eventHook.addLocalListener(
"file:changed",
async (path: string, _selfUpdate, _oldHash, newHash) => {
@@ -118,7 +130,6 @@ export class ClientSystem {
plugName,
newHash,
createSandbox,
this.client.settings.plugOverrides,
);
if ((plug.manifest! as Manifest).syntax) {
// If there are syntax extensions, rebuild the markdown parser immediately
@@ -204,7 +215,6 @@ export class ClientSystem {
plugName,
plugMeta.lastModified,
createSandbox,
this.client.settings.plugOverrides,
);
} catch (e: any) {
console.error(