Fix plugOverrides being broken
This commit is contained in:
parent
8ed3cd0e4a
commit
e0bb1dde79
@ -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!;
|
||||
|
||||
|
@ -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";
|
||||
|
@ -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)
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user