From 5bb73c111dbc39320ce071c8c2aebf92ad88e99a Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 21 Oct 2022 17:06:14 +0200 Subject: [PATCH] Parallel plug loading on the server --- plugs/core/cloud.ts | 1 - server/http_server.ts | 11 ++++------- web/editor.tsx | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/plugs/core/cloud.ts b/plugs/core/cloud.ts index a6ae632..9a03d62 100644 --- a/plugs/core/cloud.ts +++ b/plugs/core/cloud.ts @@ -41,7 +41,6 @@ export async function readFileCloud( text, `${pagePrefix}${originalUrl.split("/")[0]}/`, ); - console.log("Got this", text); return { data: encoding === "string" ? text : base64EncodedDataUrl( "text/markdown", diff --git a/server/http_server.ts b/server/http_server.ts index b48ae97..1186215 100644 --- a/server/http_server.ts +++ b/server/http_server.ts @@ -1,4 +1,4 @@ -import { Application, etag, path, Router } from "./deps.ts"; +import { Application, path, Router } from "./deps.ts"; import { Manifest, SilverBulletHooks } from "../common/manifest.ts"; import { loadMarkdownExtensions } from "../common/markdown_ext.ts"; import buildMarkdown from "../common/parser.ts"; @@ -175,13 +175,10 @@ export class HttpServer { const allPlugs = await this.space.listPlugs(); console.log("Loading plugs", allPlugs); - for (const plugName of allPlugs) { + await Promise.all((await this.space.listPlugs()).map(async (plugName) => { const { data } = await this.space.readAttachment(plugName, "string"); - await this.system.load( - JSON.parse(data as string), - createSandbox, - ); - } + await this.system.load(JSON.parse(data as string), createSandbox); + })); this.rebuildMdExtensions(); const corePlug = this.system.loadedPlugs.get("core"); diff --git a/web/editor.tsx b/web/editor.tsx index b9f52fb..dc838d3 100644 --- a/web/editor.tsx +++ b/web/editor.tsx @@ -42,7 +42,7 @@ import { Space } from "../common/spaces/space.ts"; import { markdownSyscalls } from "../common/syscalls/markdown.ts"; import { FilterOption, PageMeta } from "../common/types.ts"; import { safeRun, throttle } from "../common/util.ts"; -import { createSandbox as createIFrameSandbox } from "../plugos/environments/webworker_sandbox.ts"; +import { createSandbox } from "../plugos/environments/webworker_sandbox.ts"; import { EventHook } from "../plugos/hooks/event.ts"; import { eventSyscalls } from "../plugos/syscalls/event.ts"; import sandboxSyscalls from "../plugos/syscalls/sandbox.ts"; @@ -530,7 +530,7 @@ export class Editor { console.log("(Re)loading plugs"); await Promise.all((await this.space.listPlugs()).map(async (plugName) => { const { data } = await this.space.readAttachment(plugName, "string"); - await this.system.load(JSON.parse(data as string), createIFrameSandbox); + await this.system.load(JSON.parse(data as string), createSandbox); })); this.rebuildEditorState(); await this.dispatchAppEvent("plugs:loaded");