Don't put assets in the manifest cache
parent
b355acb476
commit
573eca3676
|
@ -23,7 +23,7 @@ export class KVPrimitivesManifestCache<T> implements ManifestCache<T> {
|
||||||
const manifest = plug.sandbox.manifest!;
|
const manifest = plug.sandbox.manifest!;
|
||||||
await this.kv.batchSet([{
|
await this.kv.batchSet([{
|
||||||
key: [this.manifestPrefix, plug.name],
|
key: [this.manifestPrefix, plug.name],
|
||||||
value: { manifest, hash },
|
value: { manifest: { ...manifest, assets: undefined }, hash },
|
||||||
}]);
|
}]);
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Manifest } from "./types.ts";
|
import { Manifest } from "./types.ts";
|
||||||
import { Sandbox } from "./sandbox.ts";
|
import { Sandbox } from "./sandbox.ts";
|
||||||
import { System } from "./system.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> {
|
export class Plug<HookT> {
|
||||||
readonly runtimeEnv?: string;
|
readonly runtimeEnv?: string;
|
||||||
|
@ -36,9 +36,6 @@ export class Plug<HookT> {
|
||||||
.then(
|
.then(
|
||||||
(manifest) => {
|
(manifest) => {
|
||||||
this.manifest = manifest;
|
this.manifest = manifest;
|
||||||
this.assets = new AssetBundle(
|
|
||||||
manifest.assets ? manifest.assets as AssetJson : {},
|
|
||||||
);
|
|
||||||
// TODO: These need to be explicitly granted, not just taken
|
// TODO: These need to be explicitly granted, not just taken
|
||||||
this.grantedPermissions = manifest.requiredPermissions || [];
|
this.grantedPermissions = manifest.requiredPermissions || [];
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Manifest } from "./types.ts";
|
import { Manifest } from "./types.ts";
|
||||||
import { ControllerMessage, WorkerMessage } from "./protocol.ts";
|
import { ControllerMessage, WorkerMessage } from "./protocol.ts";
|
||||||
import { Plug } from "./plug.ts";
|
import { Plug } from "./plug.ts";
|
||||||
|
import { AssetBundle, AssetJson } from "./asset_bundle/bundle.ts";
|
||||||
|
|
||||||
export type SandboxFactory<HookT> = (plug: Plug<HookT>) => Sandbox<HookT>;
|
export type SandboxFactory<HookT> = (plug: Plug<HookT>) => Sandbox<HookT>;
|
||||||
|
|
||||||
|
@ -43,8 +44,15 @@ export class Sandbox<HookT> {
|
||||||
this.worker!.onmessage = (ev) => {
|
this.worker!.onmessage = (ev) => {
|
||||||
if (ev.data.type === "manifest") {
|
if (ev.data.type === "manifest") {
|
||||||
this.manifest = ev.data.manifest;
|
this.manifest = ev.data.manifest;
|
||||||
resolve();
|
// Set manifest in the plug
|
||||||
return;
|
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);
|
this.onMessage(ev.data);
|
||||||
|
|
Loading…
Reference in New Issue