Don't put assets in the manifest cache

pull/599/head
Zef Hemel 2023-12-09 18:08:46 +01:00
parent b355acb476
commit 573eca3676
3 changed files with 12 additions and 7 deletions

View File

@ -23,7 +23,7 @@ export class KVPrimitivesManifestCache<T> implements ManifestCache<T> {
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;
}

View File

@ -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<HookT> {
readonly runtimeEnv?: string;
@ -36,9 +36,6 @@ export class Plug<HookT> {
.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 || [];
},

View File

@ -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<HookT> = (plug: Plug<HookT>) => Sandbox<HookT>;
@ -43,8 +44,15 @@ export class Sandbox<HookT> {
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);