diff --git a/plugos/environments/deno_sandbox.ts b/plugos/environments/deno_sandbox.ts index 1ca49d3..b10b19d 100644 --- a/plugos/environments/deno_sandbox.ts +++ b/plugos/environments/deno_sandbox.ts @@ -30,7 +30,7 @@ class DenoWorkerWrapper implements WorkerLike { } } -export function sanboxFactory( +export function sandboxFactory( assetBundle: AssetBundle, ): (plug: Plug) => Sandbox { return (plug: Plug) => { diff --git a/plugos/hooks/endpoint.test.ts b/plugos/hooks/endpoint.test.ts index 35e7f2f..92be540 100644 --- a/plugos/hooks/endpoint.test.ts +++ b/plugos/hooks/endpoint.test.ts @@ -1,4 +1,4 @@ -import { createSandbox } from "../environments/deno_sandbox.ts"; +import { sandboxFactory } from "../environments/deno_sandbox.ts"; import { Manifest } from "../types.ts"; import { EndpointHook, EndpointHookT } from "./endpoint.ts"; import { System } from "../system.ts"; @@ -6,7 +6,11 @@ import { System } from "../system.ts"; import { Application } from "../../server/deps.ts"; import { assertEquals } from "../../test_deps.ts"; +import assetBundle from "../../dist/asset_bundle.json" assert { type: "json" }; +import { AssetBundle } from "../asset_bundle_reader.ts"; + Deno.test("Run a plugos endpoint server", async () => { + const createSandbox = sandboxFactory(assetBundle as AssetBundle); let system = new System("server"); let plug = await system.load( { diff --git a/plugos/runtime.test.ts b/plugos/runtime.test.ts index f99dc8a..a735ecc 100644 --- a/plugos/runtime.test.ts +++ b/plugos/runtime.test.ts @@ -1,4 +1,4 @@ -import { createSandbox } from "./environments/deno_sandbox.ts"; +import { sandboxFactory } from "./environments/deno_sandbox.ts"; import { System } from "./system.ts"; import { @@ -6,7 +6,10 @@ import { assertEquals, } from "https://deno.land/std@0.158.0/testing/asserts.ts"; +import assetBundle from "../dist/asset_bundle.json" assert { type: "json" }; Deno.test("Run a deno sandbox", async () => { + const createSandbox = sandboxFactory(assetBundle as AssetBundle); + const system = new System("server"); system.registerSyscalls([], { addNumbers: (_ctx, a, b) => { @@ -122,9 +125,12 @@ Deno.test("Run a deno sandbox", async () => { import { bundle as plugOsBundle } from "./bin/plugos-bundle.ts"; import { esbuild } from "./compile.ts"; +import { AssetBundle } from "./asset_bundle_reader.ts"; const __dirname = new URL(".", import.meta.url).pathname; Deno.test("Preload dependencies", async () => { + const createSandbox = sandboxFactory(assetBundle as AssetBundle); + const globalModules = await plugOsBundle( `${__dirname}../plugs/global.plug.yaml`, ); diff --git a/plugos/syscalls/store.deno.test.ts b/plugos/syscalls/store.deno.test.ts index 97b44ca..2293fdc 100644 --- a/plugos/syscalls/store.deno.test.ts +++ b/plugos/syscalls/store.deno.test.ts @@ -1,10 +1,14 @@ import { assertEquals } from "../../test_deps.ts"; import { SQLite } from "../../server/deps.ts"; -import { createSandbox } from "../environments/deno_sandbox.ts"; +import { sandboxFactory } from "../environments/deno_sandbox.ts"; import { System } from "../system.ts"; import { ensureTable, storeSyscalls } from "./store.deno.ts"; +import assetBundle from "../../dist/asset_bundle.json" assert { type: "json" }; +import { AssetBundle } from "../asset_bundle_reader.ts"; + Deno.test("Test store", async () => { + const createSandbox = sandboxFactory(assetBundle as AssetBundle); const db = new SQLite(":memory:"); await ensureTable(db, "test_table"); const system = new System("server"); diff --git a/server/http_server.ts b/server/http_server.ts index 8cff734..08c138a 100644 --- a/server/http_server.ts +++ b/server/http_server.ts @@ -14,7 +14,7 @@ import { Space } from "../common/spaces/space.ts"; import { SpacePrimitives } from "../common/spaces/space_primitives.ts"; import { markdownSyscalls } from "../common/syscalls/markdown.ts"; import { parseYamlSettings } from "../common/util.ts"; -import { sanboxFactory } from "../plugos/environments/deno_sandbox.ts"; +import { sandboxFactory } from "../plugos/environments/deno_sandbox.ts"; import { EndpointHook } from "../plugos/hooks/endpoint.ts"; import { EventHook } from "../plugos/hooks/event.ts"; import { DenoCronHook } from "../plugos/hooks/cron.deno.ts"; @@ -177,7 +177,7 @@ export class HttpServer { const { data } = await this.space.readAttachment(plugName, "string"); await this.system.load( JSON.parse(data as string), - sanboxFactory(this.assetBundle), + sandboxFactory(this.assetBundle), ); } this.rebuildMdExtensions();