diff --git a/plugos/manifest_cache.ts b/plugos/manifest_cache.ts index 4099d47f..d287ff39 100644 --- a/plugos/manifest_cache.ts +++ b/plugos/manifest_cache.ts @@ -23,7 +23,7 @@ export class KVPrimitivesManifestCache implements ManifestCache { const manifest = plug.sandbox.manifest!; await this.kv.batchSet([{ key: [this.manifestPrefix, plug.name], - value: { manifest, hash }, + value: { manifest: { ...manifest, assets: undefined }, hash }, }]); return manifest; } diff --git a/plugos/plug.ts b/plugos/plug.ts index df2e1248..4a25e859 100644 --- a/plugos/plug.ts +++ b/plugos/plug.ts @@ -1,7 +1,7 @@ import { Manifest } from "./types.ts"; import { Sandbox } from "./sandbox.ts"; import { System } from "./system.ts"; -import { AssetBundle, AssetJson } from "./asset_bundle/bundle.ts"; +import { AssetBundle } from "./asset_bundle/bundle.ts"; export class Plug { readonly runtimeEnv?: string; @@ -36,9 +36,6 @@ export class Plug { .then( (manifest) => { this.manifest = manifest; - this.assets = new AssetBundle( - manifest.assets ? manifest.assets as AssetJson : {}, - ); // TODO: These need to be explicitly granted, not just taken this.grantedPermissions = manifest.requiredPermissions || []; }, diff --git a/plugos/sandbox.ts b/plugos/sandbox.ts index e5cf0582..b73c3d23 100644 --- a/plugos/sandbox.ts +++ b/plugos/sandbox.ts @@ -1,6 +1,7 @@ import { Manifest } from "./types.ts"; import { ControllerMessage, WorkerMessage } from "./protocol.ts"; import { Plug } from "./plug.ts"; +import { AssetBundle, AssetJson } from "./asset_bundle/bundle.ts"; export type SandboxFactory = (plug: Plug) => Sandbox; @@ -43,8 +44,15 @@ export class Sandbox { this.worker!.onmessage = (ev) => { if (ev.data.type === "manifest") { this.manifest = ev.data.manifest; - resolve(); - return; + // Set manifest in the plug + this.plug.manifest = this.manifest; + + // Set assets in the plug + this.plug.assets = new AssetBundle( + this.manifest?.assets ? this.manifest.assets as AssetJson : {}, + ); + + return resolve(); } this.onMessage(ev.data);