Browse Source

mol-plugin-state: PluginStateSnapshotManager refactor

David Sehnal 5 years ago
parent
commit
62ebd4d8a9

+ 1 - 1
src/mol-plugin-state/animation/built-in.ts

@@ -234,7 +234,7 @@ export const AnimateStateInterpolation = PluginStateAnimation.create({
     initialState: () => ({ }),
     async apply(animState, t, ctx) {
 
-        const snapshots = ctx.plugin.state.snapshots.state.entries;
+        const snapshots = ctx.plugin.managers.snapshot.state.entries;
         if (snapshots.size < 2) return { kind: 'finished' };
 
         // const totalTime = (snapshots.size - 1) * ctx.params.transtionDurationInMs;

+ 0 - 76
src/mol-plugin-state/camera.ts

@@ -1,76 +0,0 @@
-/**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- */
-
-import { Camera } from '../mol-canvas3d/camera';
-import { OrderedMap } from 'immutable';
-import { UUID } from '../mol-util';
-import { StatefulPluginComponent } from './component';
-
-export { CameraSnapshotManager };
-
-class CameraSnapshotManager extends StatefulPluginComponent<{ entries: OrderedMap<string, CameraSnapshotManager.Entry> }> {
-    readonly events = {
-        changed: this.ev()
-    };
-
-    getEntry(id: string) {
-        return this.state.entries.get(id);
-    }
-
-    remove(id: string) {
-        if (!this.state.entries.has(id)) return;
-        this.updateState({ entries: this.state.entries.delete(id) });
-        this.events.changed.next();
-    }
-
-    add(e: CameraSnapshotManager.Entry) {
-        this.updateState({ entries: this.state.entries.set(e.id, e) });
-        this.events.changed.next();
-    }
-
-    clear() {
-        if (this.state.entries.size === 0) return;
-        this.updateState({ entries: OrderedMap<string, CameraSnapshotManager.Entry>() });
-        this.events.changed.next();
-    }
-
-    getStateSnapshot(): CameraSnapshotManager.StateSnapshot {
-        const entries: CameraSnapshotManager.Entry[] = [];
-        this.state.entries.forEach(e => entries.push(e!));
-        return { entries };
-    }
-
-    setStateSnapshot(state: CameraSnapshotManager.StateSnapshot ) {
-        const entries = OrderedMap<string, CameraSnapshotManager.Entry>().asMutable();
-        for (const e of state.entries) {
-            entries.set(e.id, e);
-        }
-        this.updateState({ entries: entries.asImmutable() });
-        this.events.changed.next();
-    }
-
-    constructor() {
-        super({ entries: OrderedMap<string, CameraSnapshotManager.Entry>() });
-    }
-}
-
-namespace CameraSnapshotManager {
-    export interface Entry {
-        id: UUID,
-        timestamp: string,
-        name?: string,
-        description?: string,
-        snapshot: Camera.Snapshot
-    }
-
-    export function Entry(snapshot: Camera.Snapshot, name?: string, description?: string): Entry {
-        return { id: UUID.create22(), timestamp: new Date().toLocaleString(), name, snapshot, description };
-    }
-
-    export interface StateSnapshot {
-        entries: Entry[]
-    }
-}

+ 79 - 5
src/mol-plugin-state/snapshots.ts → src/mol-plugin-state/manager/snapshots.ts

@@ -1,14 +1,19 @@
 /**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  */
 
 import { List } from 'immutable';
-import { UUID } from '../mol-util';
-import { PluginState } from '../mol-plugin/state';
-import { StatefulPluginComponent } from './component';
-import { PluginContext } from '../mol-plugin/context';
+import { UUID } from '../../mol-util';
+import { PluginState } from '../../mol-plugin/state';
+import { StatefulPluginComponent } from '../component';
+import { PluginContext } from '../../mol-plugin/context';
+import { utf8ByteCount, utf8Write } from '../../mol-io/common/utf8';
+import { Asset } from '../../mol-util/assets';
+import { zip } from '../../mol-util/zip/zip';
+import { readFromFile } from '../../mol-util/data-source';
+import { objectForEach } from '../../mol-util/object';
 
 export { PluginStateSnapshotManager };
 
@@ -167,6 +172,75 @@ class PluginStateSnapshotManager extends StatefulPluginComponent<{
         };
     }
 
+    async serialize(type: 'json' | 'zip' = 'json') {
+        const json = JSON.stringify(this.plugin.state.getSnapshot(), null, 2);
+
+        if (type === 'json') {
+            return new Blob([json], {type : 'application/json;charset=utf-8'});
+        } else {
+            const state = new Uint8Array(utf8ByteCount(json));
+            utf8Write(state, 0, json);
+
+            const zipDataObj: { [k: string]: Uint8Array } = {
+                'state.json': state
+            };
+
+            const assets: [UUID, Asset][] = [];
+
+            // TODO: there can be duplicate entries: check for this?
+            for (const { asset, file } of this.plugin.managers.asset.assets) {
+                assets.push([asset.id, asset]);
+                zipDataObj[`assets/${asset.id}`] = new Uint8Array(await file.arrayBuffer());
+            }
+
+            if (assets.length > 0) {
+                const index = JSON.stringify(assets, null, 2);
+                const data = new Uint8Array(utf8ByteCount(index));
+                utf8Write(data, 0, index);
+                zipDataObj['assets.json'] = data;
+            }
+
+            const zipFile = zip(zipDataObj);
+            return new Blob([zipFile], {type : 'application/zip'});
+        }
+    }
+
+    async open(file: File) {
+        try {
+            const fn = file.name.toLowerCase();
+            if (fn.endsWith('json') || fn.endsWith('molj')) {
+                const data = await this.plugin.runTask(readFromFile(file, 'string'));
+                const snapshot = JSON.parse(data);
+                return this.plugin.state.setSnapshot(snapshot);
+            } else {
+                const data = await this.plugin.runTask(readFromFile(file, 'zip'));
+                const assets = Object.create(null);
+
+                objectForEach(data, (v, k) => {
+                    if (k === 'state.json' || k === 'assets.json') return;
+                    const name = k.substring(k.indexOf('/') + 1);
+                    assets[name] = new File([v], name);
+                });
+                const stateFile = new File([data['state.json']], 'state.json');
+                const stateData = await this.plugin.runTask(readFromFile(stateFile, 'string'));
+
+                if (data['assets.json']) {
+                    const file = new File([data['assets.json']], 'assets.json');
+                    const json = JSON.parse(await this.plugin.runTask(readFromFile(file, 'string')));
+
+                    for (const [id, asset] of json) {
+                        this.plugin.managers.asset.set(asset, assets[id]);
+                    }
+                }
+
+                const snapshot = JSON.parse(stateData);
+                return this.plugin.state.setSnapshot(snapshot);
+            }
+        } catch (e) {
+            this.plugin.log.error(`Reading state: ${e}`);
+        }
+    }
+
     private timeoutHandle: any = void 0;
     private next = async () => {
         this.timeoutHandle = void 0;

+ 10 - 10
src/mol-plugin-ui/controls.tsx

@@ -102,7 +102,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
 
     componentDidMount() {
         // TODO: this needs to be diabled when the state is updating!
-        this.subscribe(this.plugin.state.snapshots.events.changed, () => this.forceUpdate());
+        this.subscribe(this.plugin.managers.snapshot.events.changed, () => this.forceUpdate());
         this.subscribe(this.plugin.behaviors.state.isBusy, isBusy => this.setState({ isBusy }));
         this.subscribe(this.plugin.behaviors.state.isAnimating, isBusy => this.setState({ isBusy }));
 
@@ -116,7 +116,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
 
     keyUp = (e: KeyboardEvent) => {
         if (!e.ctrlKey || this.state.isBusy || e.target !== document.body) return;
-        const snapshots = this.plugin.state.snapshots;
+        const snapshots = this.plugin.managers.snapshot;
         if (e.keyCode === 37) { // left
             if (snapshots.state.isPlaying) snapshots.stop();
             this.prev();
@@ -148,23 +148,23 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
     }
 
     prev = () => {
-        const s = this.plugin.state.snapshots;
+        const s = this.plugin.managers.snapshot;
         const id = s.getNextId(s.state.current, -1);
         if (id) this.update(id);
     }
 
     next = () => {
-        const s = this.plugin.state.snapshots;
+        const s = this.plugin.managers.snapshot;
         const id = s.getNextId(s.state.current, 1);
         if (id) this.update(id);
     }
 
     togglePlay = () => {
-        this.plugin.state.snapshots.togglePlay();
+        this.plugin.managers.snapshot.togglePlay();
     }
 
     render() {
-        const snapshots = this.plugin.state.snapshots;
+        const snapshots = this.plugin.managers.snapshot;
         const count = snapshots.state.entries.size;
 
         if (count < 2 || !this.state.show) {
@@ -193,8 +193,8 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty:
     state = { isEmpty: true, isExpanded: false, isBusy: false, isAnimating: false, isPlaying: false };
 
     componentDidMount() {
-        this.subscribe(this.plugin.state.snapshots.events.changed, () => {
-            if (this.plugin.state.snapshots.state.isPlaying) this.setState({ isPlaying: true, isExpanded: false });
+        this.subscribe(this.plugin.managers.snapshot.events.changed, () => {
+            if (this.plugin.managers.snapshot.state.isPlaying) this.setState({ isPlaying: true, isExpanded: false });
             else this.setState({ isPlaying: false });
         });
         this.subscribe(this.plugin.behaviors.state.isBusy, isBusy => {
@@ -209,12 +209,12 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty:
     toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded });
     stop = () => {
         this.plugin.state.animation.stop();
-        this.plugin.state.snapshots.stop();
+        this.plugin.managers.snapshot.stop();
     }
 
     render() {
         // if (!this.state.show) return null;
-        const isPlaying = this.plugin.state.snapshots.state.isPlaying;
+        const isPlaying = this.plugin.managers.snapshot.state.isPlaying;
         if (isPlaying || this.state.isEmpty) return null;
 
         const isAnimating = this.state.isAnimating;

+ 7 - 7
src/mol-plugin-ui/state/snapshots.tsx

@@ -96,7 +96,7 @@ class LocalStateSnapshots extends PluginUIComponent<
             <ParameterControls params={LocalStateSnapshots.Params} values={this.state.params} onEnter={this.add} onChange={p => {
                 const params = { ...this.state.params, [p.name]: p.value };
                 this.setState({ params } as any);
-                this.plugin.state.snapshots.currentGetSnapshotParams = params.options;
+                this.plugin.managers.snapshot.currentGetSnapshotParams = params.options;
             }}/>
 
             <div className='msp-flex-row'>
@@ -109,7 +109,7 @@ class LocalStateSnapshots extends PluginUIComponent<
 
 class LocalStateSnapshotList extends PluginUIComponent<{ }, { }> {
     componentDidMount() {
-        this.subscribe(this.plugin.events.state.snapshots.changed, () => this.forceUpdate());
+        this.subscribe(this.plugin.managers.snapshot.events.changed, () => this.forceUpdate());
     }
 
     apply = (e: React.MouseEvent<HTMLElement>) => {
@@ -139,13 +139,13 @@ class LocalStateSnapshotList extends PluginUIComponent<{ }, { }> {
     replace = (e: React.MouseEvent<HTMLElement>) => {
         const id = e.currentTarget.getAttribute('data-id');
         if (!id) return;
-        PluginCommands.State.Snapshots.Replace(this.plugin, { id, params: this.plugin.state.snapshots.currentGetSnapshotParams });
+        PluginCommands.State.Snapshots.Replace(this.plugin, { id, params: this.plugin.managers.snapshot.currentGetSnapshotParams });
     }
 
     render() {
-        const current = this.plugin.state.snapshots.state.current;
+        const current = this.plugin.managers.snapshot.state.current;
         return <ul style={{ listStyle: 'none' }} className='msp-state-list'>
-            {this.plugin.state.snapshots.state.entries.map(e => <li key={e!.snapshot.id}>
+            {this.plugin.managers.snapshot.state.entries.map(e => <li key={e!.snapshot.id}>
                 <Button data-id={e!.snapshot.id} onClick={this.apply}>
                     <span style={{ fontWeight: e!.snapshot.id === current ? 'bold' : void 0}}>
                         {e!.name || new Date(e!.timestamp).toLocaleString()}</span> <small>
@@ -227,11 +227,11 @@ export class RemoteStateSnapshots extends PluginUIComponent<
         this.setState({ isBusy: true });
         this.plugin.config.set(PluginConfig.State.CurrentServer, this.state.params.options.serverUrl);
 
-        if (this.plugin.state.snapshots.state.entries.size === 0) {
+        if (this.plugin.managers.snapshot.state.entries.size === 0) {
             await PluginCommands.State.Snapshots.Add(this.plugin, {
                 name: this.state.params.name,
                 description: this.state.params.options.description,
-                params: this.plugin.state.snapshots.currentGetSnapshotParams
+                params: this.plugin.managers.snapshot.currentGetSnapshotParams
             });
         }
 

+ 0 - 22
src/mol-plugin/behavior/static/camera.ts

@@ -6,13 +6,11 @@
 
 import { PluginContext } from '../../../mol-plugin/context';
 import { PluginCommands } from '../../commands';
-import { CameraSnapshotManager } from '../../../mol-plugin-state/camera';
 
 export function registerDefault(ctx: PluginContext) {
     Reset(ctx);
     Focus(ctx);
     SetSnapshot(ctx);
-    Snapshots(ctx);
 }
 
 export function Reset(ctx: PluginContext) {
@@ -32,24 +30,4 @@ export function Focus(ctx: PluginContext) {
         ctx.managers.camera.focusSphere({ center, radius }, { durationMs });
         ctx.events.canvas3d.settingsUpdated.next();
     });
-}
-
-export function Snapshots(ctx: PluginContext) {
-    PluginCommands.Camera.Snapshots.Clear.subscribe(ctx, () => {
-        ctx.state.cameraSnapshots.clear();
-    });
-
-    PluginCommands.Camera.Snapshots.Remove.subscribe(ctx, ({ id }) => {
-        ctx.state.cameraSnapshots.remove(id);
-    });
-
-    PluginCommands.Camera.Snapshots.Add.subscribe(ctx, ({ name, description }) => {
-        const entry = CameraSnapshotManager.Entry(ctx.canvas3d!.camera.getSnapshot(), name, description);
-        ctx.state.cameraSnapshots.add(entry);
-    });
-
-    PluginCommands.Camera.Snapshots.Apply.subscribe(ctx, ({ id }) => {
-        const e = ctx.state.cameraSnapshots.getEntry(id);
-        return PluginCommands.Camera.SetSnapshot(ctx, { snapshot: e.snapshot, durationMs: 200 });
-    });
 }

+ 14 - 82
src/mol-plugin/behavior/static/state.ts

@@ -5,22 +5,16 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { utf8ByteCount, utf8Write } from '../../../mol-io/common/utf8';
 import { Structure } from '../../../mol-model/structure';
+import { PluginStateSnapshotManager } from '../../../mol-plugin-state/manager/snapshots';
 import { PluginStateObject as SO } from '../../../mol-plugin-state/objects';
-import { PluginStateSnapshotManager } from '../../../mol-plugin-state/snapshots';
 import { State, StateTransform, StateTree } from '../../../mol-state';
-import { readFromFile } from '../../../mol-util/data-source';
 import { getFormattedTime } from '../../../mol-util/date';
 import { download } from '../../../mol-util/download';
-import { objectForEach } from '../../../mol-util/object';
 import { urlCombine } from '../../../mol-util/url';
-import { zip } from '../../../mol-util/zip/zip';
 import { PluginCommands } from '../../commands';
 import { PluginConfig } from '../../config';
 import { PluginContext } from '../../context';
-import { UUID } from '../../../mol-util';
-import { Asset } from '../../../mol-util/assets';
 
 export function registerDefault(ctx: PluginContext) {
     SyncBehaviors(ctx);
@@ -143,28 +137,28 @@ export function Snapshots(ctx: PluginContext) {
     ctx.config.set(PluginConfig.State.CurrentServer, ctx.config.get(PluginConfig.State.DefaultServer));
 
     PluginCommands.State.Snapshots.Clear.subscribe(ctx, () => {
-        ctx.state.snapshots.clear();
+        ctx.managers.snapshot.clear();
     });
 
     PluginCommands.State.Snapshots.Remove.subscribe(ctx, ({ id }) => {
-        ctx.state.snapshots.remove(id);
+        ctx.managers.snapshot.remove(id);
     });
 
     PluginCommands.State.Snapshots.Add.subscribe(ctx, ({ name, description, params }) => {
         const entry = PluginStateSnapshotManager.Entry(ctx.state.getSnapshot(params), { name, description });
-        ctx.state.snapshots.add(entry);
+        ctx.managers.snapshot.add(entry);
     });
 
     PluginCommands.State.Snapshots.Replace.subscribe(ctx, ({ id, params }) => {
-        ctx.state.snapshots.replace(id, ctx.state.getSnapshot(params));
+        ctx.managers.snapshot.replace(id, ctx.state.getSnapshot(params));
     });
 
     PluginCommands.State.Snapshots.Move.subscribe(ctx, ({ id, dir }) => {
-        ctx.state.snapshots.move(id, dir);
+        ctx.managers.snapshot.move(id, dir);
     });
 
     PluginCommands.State.Snapshots.Apply.subscribe(ctx, ({ id }) => {
-        const snapshot = ctx.state.snapshots.setCurrent(id);
+        const snapshot = ctx.managers.snapshot.setCurrent(id);
         if (!snapshot) return;
         return ctx.state.setSnapshot(snapshot);
     });
@@ -175,84 +169,22 @@ export function Snapshots(ctx: PluginContext) {
             mode: 'cors',
             referrer: 'no-referrer',
             headers: { 'Content-Type': 'application/json; charset=utf-8' },
-            body: JSON.stringify(ctx.state.snapshots.getRemoteSnapshot({ name, description, playOnLoad }))
+            body: JSON.stringify(ctx.managers.snapshot.getRemoteSnapshot({ name, description, playOnLoad }))
         }) as any as Promise<void>;
     });
 
     PluginCommands.State.Snapshots.Fetch.subscribe(ctx, async ({ url }) => {
         const json = await ctx.runTask(ctx.fetch({ url, type: 'json' })); //  fetch(url, { referrer: 'no-referrer' });
-        await ctx.state.snapshots.setRemoteSnapshot(json.data);
+        await ctx.managers.snapshot.setRemoteSnapshot(json.data);
     });
 
     PluginCommands.State.Snapshots.DownloadToFile.subscribe(ctx, async ({ name, type }) => {
-        const json = JSON.stringify(ctx.state.getSnapshot(), null, 2);
-        name = `mol-star_state_${(name || getFormattedTime())}`;
-
-        if (type === 'json') {
-            const blob = new Blob([json], {type : 'application/json;charset=utf-8'});
-            download(blob, `${name}.json`);
-        } else {
-            const state = new Uint8Array(utf8ByteCount(json));
-            utf8Write(state, 0, json);
-
-            const zipDataObj: { [k: string]: Uint8Array } = {
-                'state.json': state
-            };
-
-            const assets: [UUID, Asset][] = [];
-
-            // TODO: there can be duplicate entries: check for this?
-            for (const { asset, file } of ctx.managers.asset.assets) {
-                assets.push([asset.id, asset]);
-                zipDataObj[`assets/${asset.id}`] = new Uint8Array(await file.arrayBuffer());
-            }
-
-            if (assets.length > 0) {
-                const index = JSON.stringify(assets, null, 2);
-                const data = new Uint8Array(utf8ByteCount(index));
-                utf8Write(data, 0, index);
-                zipDataObj['assets.json'] = data;
-            }
-
-            const zipFile = zip(zipDataObj);
-
-            const blob = new Blob([zipFile], {type : 'application/zip'});
-            download(blob, `${name}.zip`);
-        }
+        const filename = `mol-star_state_${(name || getFormattedTime())}.${type === 'json' ? 'molj' : 'molx'}`;
+        const data = await ctx.managers.snapshot.serialize(type);
+        download(data, `${filename}`);
     });
 
-    PluginCommands.State.Snapshots.OpenFile.subscribe(ctx, async ({ file }) => {
-        try {
-            if (file.name.toLowerCase().endsWith('json')) {
-                const data = await ctx.runTask(readFromFile(file, 'string'));
-                const snapshot = JSON.parse(data);
-                return ctx.state.setSnapshot(snapshot);
-            } else {
-                const data = await ctx.runTask(readFromFile(file, 'zip'));
-                const assets = Object.create(null);
-
-                objectForEach(data, (v, k) => {
-                    if (k === 'state.json' || k === 'assets.json') return;
-                    const name = k.substring(k.indexOf('/') + 1);
-                    assets[name] = new File([v], name);
-                });
-                const stateFile = new File([data['state.json']], 'state.json');
-                const stateData = await ctx.runTask(readFromFile(stateFile, 'string'));
-
-                if (data['assets.json']) {
-                    const file = new File([data['assets.json']], 'assets.json');
-                    const json = JSON.parse(await ctx.runTask(readFromFile(file, 'string')));
-
-                    for (const [id, asset] of json) {
-                        ctx.managers.asset.set(asset, assets[id]);
-                    }
-                }
-
-                const snapshot = JSON.parse(stateData);
-                return ctx.state.setSnapshot(snapshot);
-            }
-        } catch (e) {
-            ctx.log.error(`Reading state: ${e}`);
-        }
+    PluginCommands.State.Snapshots.OpenFile.subscribe(ctx, ({ file }) => {
+        return ctx.managers.snapshot.open(file);
     });
 }

+ 1 - 7
src/mol-plugin/commands.ts

@@ -61,13 +61,7 @@ export const PluginCommands = {
     Camera: {
         Reset: PluginCommand<{ durationMs?: number, snapshot?: Partial<Camera.Snapshot> }>(),
         SetSnapshot: PluginCommand<{ snapshot: Partial<Camera.Snapshot>, durationMs?: number }>(),
-        Focus: PluginCommand<{ center: Vec3, radius: number, durationMs?: number }>(),
-        Snapshots: {
-            Add: PluginCommand<{ name?: string, description?: string }>(),
-            Remove: PluginCommand<{ id: string }>(),
-            Apply: PluginCommand<{ id: string }>(),
-            Clear: PluginCommand<{}>(),
-        }
+        Focus: PluginCommand<{ center: Vec3, radius: number, durationMs?: number }>()
     },
     Canvas3D: {
         SetSettings: PluginCommand<{ settings: Partial<Canvas3DProps> | ((old: Canvas3DProps) => Partial<Canvas3DProps> | void) }>(),

+ 3 - 3
src/mol-plugin/context.ts

@@ -54,6 +54,7 @@ import { PluginToastManager } from './util/toast';
 import { ViewportScreenshotHelper } from './util/viewport-screenshot';
 import { PLUGIN_VERSION, PLUGIN_VERSION_DATE } from './version';
 import { AssetManager } from '../mol-util/assets';
+import { PluginStateSnapshotManager } from '../mol-plugin-state/manager/snapshots';
 
 export class PluginContext {
     runTask = <T>(task: Task<T>) => this.tasks.run(task);
@@ -76,9 +77,7 @@ export class PluginContext {
                 created: merge(this.state.data.events.object.created, this.state.behaviors.events.object.created),
                 removed: merge(this.state.data.events.object.removed, this.state.behaviors.events.object.removed),
                 updated: merge(this.state.data.events.object.updated, this.state.behaviors.events.object.updated)
-            },
-            cameraSnapshots: this.state.cameraSnapshots.events,
-            snapshots: this.state.snapshots.events,
+            }
         },
         log: this.ev<LogEntry>(),
         task: this.tasks.events,
@@ -150,6 +149,7 @@ export class PluginContext {
         },
         interactivity: void 0 as any as InteractivityManager,
         camera: new CameraManager(this),
+        snapshot: new PluginStateSnapshotManager(this),
         lociLabels: void 0 as any as LociLabelManager,
         toast: new PluginToastManager(this),
         asset: new AssetManager()

+ 0 - 9
src/mol-plugin/state.ts

@@ -8,8 +8,6 @@ import { State, StateTransform, StateTransformer } from '../mol-state';
 import { PluginStateObject as SO } from '../mol-plugin-state/objects';
 import { Camera } from '../mol-canvas3d/camera';
 import { PluginBehavior } from './behavior';
-import { CameraSnapshotManager } from '../mol-plugin-state/camera';
-import { PluginStateSnapshotManager } from '../mol-plugin-state/snapshots';
 import { RxEventHelper } from '../mol-util/rx-event-helper';
 import { Canvas3DProps } from '../mol-canvas3d/canvas3d';
 import { PluginCommands } from './commands';
@@ -27,8 +25,6 @@ class PluginState {
     readonly data: State;
     readonly behaviors: State;
     readonly animation: PluginAnimationManager;
-    readonly cameraSnapshots = new CameraSnapshotManager();
-    readonly snapshots: PluginStateSnapshotManager;
 
     getSnapshot(params?: PluginState.GetSnapshotParams): PluginState.Snapshot {
         const p = { ...PluginState.DefaultGetSnapshotParams, ...params };
@@ -43,7 +39,6 @@ class PluginState {
                 transitionStyle: p.cameraTranstion.name,
                 transitionDurationInMs: (params && params.cameraTranstion && params.cameraTranstion.name === 'animate') ? params.cameraTranstion.params.durationInMs : undefined
             } : void 0,
-            cameraSnapshots: p.cameraSnapshots ? this.cameraSnapshots.getStateSnapshot() : void 0,
             canvas3d: p.canvas3d ? { props: this.plugin.canvas3d?.props } : void 0,
             interactivity: p.interactivity ? { props: this.plugin.managers.interactivity.props } : void 0,
             structureFocus: this.plugin.managers.structure.focus.getSnapshot(),
@@ -65,7 +60,6 @@ class PluginState {
         if (snapshot.structureFocus) {
             this.plugin.managers.structure.focus.setSnapshot(snapshot.structureFocus);
         }
-        if (snapshot.cameraSnapshots) this.cameraSnapshots.setStateSnapshot(snapshot.cameraSnapshots);
         if (snapshot.animation) {
             this.animation.setSnapshot(snapshot.animation);
         }
@@ -107,12 +101,10 @@ class PluginState {
         this.ev.dispose();
         this.data.dispose();
         this.behaviors.dispose();
-        this.cameraSnapshots.dispose();
         this.animation.dispose();
     }
 
     constructor(private plugin: import('./context').PluginContext) {
-        this.snapshots = new PluginStateSnapshotManager(plugin);
         this.data = State.create(new SO.Root({ }), { runTask: plugin.runTask, globalContext: plugin });
         this.behaviors = State.create(new PluginBehavior.Root({ }), { runTask: plugin.runTask, globalContext: plugin, rootState: { isLocked: true } });
 
@@ -156,7 +148,6 @@ namespace PluginState {
             transitionStyle: CameraTransitionStyle,
             transitionDurationInMs?: number
         },
-        cameraSnapshots?: CameraSnapshotManager.StateSnapshot,
         canvas3d?: {
             props?: Canvas3DProps
         },