diff --git a/plugos/system.ts b/plugos/system.ts index 1c41b42..0203e8c 100644 --- a/plugos/system.ts +++ b/plugos/system.ts @@ -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 extends EventEmitter> { name: string, hash: number, sandboxFactory: SandboxFactory, - // Mapping plug name -> manifest overrides - manifestOverrides?: Record>>, ): Promise> { 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!; diff --git a/server/server_system.ts b/server/server_system.ts index 5242e1f..9dd771e 100644 --- a/server/server_system.ts +++ b/server/server_system.ts @@ -6,7 +6,6 @@ import { EventedSpacePrimitives } from "../common/spaces/evented_space_primitive import { PlugSpacePrimitives } from "../common/spaces/plug_space_primitives.ts"; import { createSandbox } from "../plugos/environments/webworker_sandbox.ts"; import { CronHook } from "../plugos/hooks/cron.ts"; -import { EndpointHook } from "../plugos/hooks/endpoint.ts"; import { EventHook } from "../plugos/hooks/event.ts"; import { MQHook } from "../plugos/hooks/mq.ts"; import assetSyscalls from "../plugos/syscalls/asset.ts"; @@ -19,7 +18,6 @@ import { markdownSyscalls } from "../common/syscalls/markdown.ts"; import { spaceSyscalls } from "./syscalls/space.ts"; import { systemSyscalls } from "../web/syscalls/system.ts"; import { yamlSyscalls } from "../common/syscalls/yaml.ts"; -import { Application } from "./deps.ts"; import { sandboxFetchSyscalls } from "../plugos/syscalls/fetch.ts"; import { shellSyscalls } from "../plugos/syscalls/shell.deno.ts"; import { SpacePrimitives } from "../common/spaces/space_primitives.ts"; diff --git a/web/client.ts b/web/client.ts index 29a4dea..47c7c7c 100644 --- a/web/client.ts +++ b/web/client.ts @@ -818,6 +818,10 @@ export class Client { doc.text, doc.meta.perm === "ro", ); + this.ui.viewDispatch({ + type: "page-loaded", + meta: doc.meta, + }); editorView.setState(editorState); if (editorView.contentDOM) { this.tweakEditorDOM(editorView.contentDOM); @@ -825,11 +829,6 @@ export class Client { const stateRestored = this.openPages.restoreState(pageName); this.space.watchPage(pageName); - this.ui.viewDispatch({ - type: "page-loaded", - meta: doc.meta, - }); - // Note: these events are dispatched asynchronously deliberately (not waiting for results) if (loadingDifferentPage) { this.eventHook.dispatchEvent("editor:pageLoaded", pageName, previousPage) diff --git a/web/client_system.ts b/web/client_system.ts index 3d43c0a..a7c61a4 100644 --- a/web/client_system.ts +++ b/web/client_system.ts @@ -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(