From 7287947a5533e4c784debfc2bac645fc78a65915 Mon Sep 17 00:00:00 2001 From: David Sehnal <david.sehnal@gmail.com> Date: Tue, 3 Mar 2020 13:46:34 +0100 Subject: [PATCH] added mol-plugin-state, refactored PluginCommand --- README.md | 1 + src/apps/basic-wrapper/helpers.ts | 6 +- src/apps/basic-wrapper/index.ts | 40 ++--- src/apps/basic-wrapper/superposition.ts | 8 +- src/apps/demos/lighting/index.ts | 16 +- src/apps/state-docs/index.ts | 2 +- src/apps/viewer/extensions/cellpack/model.ts | 6 +- src/apps/viewer/extensions/cellpack/state.ts | 2 +- src/apps/viewer/index.ts | 6 +- src/examples/proteopedia-wrapper/index.ts | 46 +++--- .../state => mol-plugin-state}/actions.ts | 0 .../actions/data-format.ts | 12 +- .../actions/shape.ts | 8 +- .../actions/structure.ts | 14 +- .../actions/volume.ts | 14 +- .../animation/built-in.ts | 16 +- .../animation/helpers.ts | 8 +- .../animation/manager.ts | 6 +- .../animation/model.ts | 4 +- .../state => mol-plugin-state}/camera.ts | 6 +- .../manager/base.ts | 6 +- .../manager/data.ts | 8 +- .../manager/data/actions.ts | 2 +- .../manager/data/formats.ts | 4 +- .../manager/data/provider.ts | 8 +- .../manager/data/sources.ts | 0 .../manager/structure.ts | 0 .../manager/structure/components.ts | 0 .../manager/structure/model.ts | 0 .../manager/structure/representations.ts | 0 .../manager/structure/selection.ts | 0 .../manager/structure/volume.ts | 0 .../state => mol-plugin-state}/objects.ts | 38 ++--- .../representation/model.ts | 18 +- .../representation/structure.ts | 18 +- .../representation/structure/preset.ts | 6 +- .../representation/structure/provider.ts | 10 +- .../state => mol-plugin-state}/snapshots.ts | 8 +- .../state => mol-plugin-state}/transforms.ts | 0 .../transforms/data.ts | 20 +-- .../transforms/helpers.ts | 10 +- .../transforms/misc.ts | 6 +- .../transforms/model.ts | 48 +++--- .../transforms/representation.ts | 58 +++---- .../transforms/volume.ts | 14 +- src/mol-plugin-ui/camera.tsx | 10 +- src/mol-plugin-ui/controls.tsx | 18 +- src/mol-plugin-ui/left-panel.tsx | 10 +- src/mol-plugin-ui/sequence.tsx | 2 +- src/mol-plugin-ui/state/apply-action.tsx | 4 +- src/mol-plugin-ui/state/snapshots.tsx | 26 +-- src/mol-plugin-ui/state/tree.tsx | 18 +- .../structure/representation.tsx | 2 +- src/mol-plugin-ui/structure/selection.tsx | 4 +- src/mol-plugin-ui/toast.tsx | 2 +- src/mol-plugin-ui/viewport.tsx | 14 +- .../viewport/simple-settings.tsx | 4 +- src/mol-plugin/behavior/behavior.ts | 2 +- src/mol-plugin/behavior/dynamic/camera.ts | 4 +- .../custom-props/computed/interactions.ts | 2 +- .../custom-props/computed/valence-model.ts | 2 +- .../custom-props/rcsb/assembly-symmetry.ts | 2 +- .../behavior/dynamic/representation.ts | 2 +- .../structure-representation-interaction.ts | 12 +- .../dynamic/volume-streaming/behavior.ts | 6 +- .../dynamic/volume-streaming/model.ts | 2 +- .../dynamic/volume-streaming/transformers.ts | 4 +- src/mol-plugin/behavior/static/camera.ts | 6 +- src/mol-plugin/behavior/static/misc.ts | 2 +- .../behavior/static/representation.ts | 2 +- src/mol-plugin/behavior/static/state.ts | 6 +- src/mol-plugin/command.ts | 155 +++++++++++------- src/mol-plugin/command/base.ts | 112 ------------- src/mol-plugin/commands.ts | 72 ++++++++ src/mol-plugin/context.ts | 33 ++-- src/mol-plugin/index.ts | 8 +- src/mol-plugin/layout.ts | 2 +- src/mol-plugin/spec.ts | 4 +- src/mol-plugin/state.ts | 16 +- src/mol-plugin/util/interactivity.ts | 2 +- .../util/structure-complex-helper.ts | 8 +- .../util/structure-element-selection.ts | 2 +- src/mol-plugin/util/structure-measurement.ts | 14 +- .../util/structure-overpaint-helper.ts | 4 +- src/mol-plugin/util/structure-query.ts | 2 +- .../util/structure-representation-helper.ts | 6 +- .../util/structure-selection-helper.ts | 4 +- .../util/substructure-parent-helper.ts | 2 +- src/mol-plugin/{state => util}/toast.ts | 2 +- src/mol-plugin/util/viewport-screenshot.ts | 2 +- src/mol-plugin/version.ts | 4 +- 91 files changed, 551 insertions(+), 574 deletions(-) rename src/{mol-plugin/state => mol-plugin-state}/actions.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/actions/data-format.ts (94%) rename src/{mol-plugin/state => mol-plugin-state}/actions/shape.ts (84%) rename src/{mol-plugin/state => mol-plugin-state}/actions/structure.ts (98%) rename src/{mol-plugin/state => mol-plugin-state}/actions/volume.ts (96%) rename src/{mol-plugin/state => mol-plugin-state}/animation/built-in.ts (93%) rename src/{mol-plugin/state => mol-plugin-state}/animation/helpers.ts (81%) rename src/{mol-plugin/state => mol-plugin-state}/animation/manager.ts (97%) rename src/{mol-plugin/state => mol-plugin-state}/animation/model.ts (92%) rename src/{mol-plugin/state => mol-plugin-state}/camera.ts (93%) rename src/{mol-plugin/state => mol-plugin-state}/manager/base.ts (86%) rename src/{mol-plugin/state => mol-plugin-state}/manager/data.ts (92%) rename src/{mol-plugin/state => mol-plugin-state}/manager/data/actions.ts (91%) rename src/{mol-plugin/state => mol-plugin-state}/manager/data/formats.ts (93%) rename src/{mol-plugin/state => mol-plugin-state}/manager/data/provider.ts (91%) rename src/{mol-plugin/state => mol-plugin-state}/manager/data/sources.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/manager/structure.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/manager/structure/components.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/manager/structure/model.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/manager/structure/representations.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/manager/structure/selection.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/manager/structure/volume.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/objects.ts (84%) rename src/{mol-plugin/state => mol-plugin-state}/representation/model.ts (92%) rename src/{mol-plugin/state => mol-plugin-state}/representation/structure.ts (91%) rename src/{mol-plugin/state => mol-plugin-state}/representation/structure/preset.ts (97%) rename src/{mol-plugin/state => mol-plugin-state}/representation/structure/provider.ts (77%) rename src/{mol-plugin/state => mol-plugin-state}/snapshots.ts (97%) rename src/{mol-plugin/state => mol-plugin-state}/transforms.ts (100%) rename src/{mol-plugin/state => mol-plugin-state}/transforms/data.ts (95%) rename src/{mol-plugin/state => mol-plugin-state}/transforms/helpers.ts (81%) rename src/{mol-plugin/state => mol-plugin-state}/transforms/misc.ts (83%) rename src/{mol-plugin/state => mol-plugin-state}/transforms/model.ts (95%) rename src/{mol-plugin/state => mol-plugin-state}/transforms/representation.ts (95%) rename src/{mol-plugin/state => mol-plugin-state}/transforms/volume.ts (88%) delete mode 100644 src/mol-plugin/command/base.ts create mode 100644 src/mol-plugin/commands.ts rename src/mol-plugin/{state => util}/toast.ts (98%) diff --git a/README.md b/README.md index 966b03ca7..9514503e0 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ The core of Mol* currently consists of these modules (see under `src/`): - `mol-state` State representation tree with state saving and automatic updates. - `mol-app` Components for builduing UIs. - `mol-plugin` Allow to define modular Mol* plugin instances utilizing `mol-state` and `mol-canvas3d`. +- `mol-plugin-state` State transformations, builders, and managers. - `mol-plugin-ui` React based user interface for the Mol* plugin. Some components of the UI are usable outside the main plugin and can be integrated to 3rd party solutions. - `mol-util` Useful things that do not fit elsewhere. diff --git a/src/apps/basic-wrapper/helpers.ts b/src/apps/basic-wrapper/helpers.ts index c26cb3eb4..7da9dbac5 100644 --- a/src/apps/basic-wrapper/helpers.ts +++ b/src/apps/basic-wrapper/helpers.ts @@ -6,9 +6,9 @@ import { Mat4, Vec3 } from '../../mol-math/linear-algebra'; import { PluginContext } from '../../mol-plugin/context'; -import { PluginStateObject as PSO } from '../../mol-plugin/state/objects'; -import { StateTransforms } from '../../mol-plugin/state/transforms'; -import { StructureRepresentation3DHelpers } from '../../mol-plugin/state/transforms/representation'; +import { PluginStateObject as PSO } from '../../mol-plugin-state/objects'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; +import { StructureRepresentation3DHelpers } from '../../mol-plugin-state/transforms/representation'; import { MolScriptBuilder as MS } from '../../mol-script/language/builder'; import { StateBuilder } from '../../mol-state'; import Expression from '../../mol-script/language/expression'; diff --git a/src/apps/basic-wrapper/index.ts b/src/apps/basic-wrapper/index.ts index 1d77c47c9..317f37bb0 100644 --- a/src/apps/basic-wrapper/index.ts +++ b/src/apps/basic-wrapper/index.ts @@ -7,12 +7,12 @@ import { createPlugin, DefaultPluginSpec } from '../../mol-plugin'; import './index.html' import { PluginContext } from '../../mol-plugin/context'; -import { PluginCommands } from '../../mol-plugin/command'; -import { StateTransforms } from '../../mol-plugin/state/transforms'; -import { StructureRepresentation3DHelpers } from '../../mol-plugin/state/transforms/representation'; +import { PluginCommands } from '../../mol-plugin/commands'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; +import { StructureRepresentation3DHelpers } from '../../mol-plugin-state/transforms/representation'; import { Color } from '../../mol-util/color'; -import { PluginStateObject as PSO, PluginStateObject } from '../../mol-plugin/state/objects'; -import { AnimateModelIndex } from '../../mol-plugin/state/animation/built-in'; +import { PluginStateObject as PSO, PluginStateObject } from '../../mol-plugin-state/objects'; +import { AnimateModelIndex } from '../../mol-plugin-state/animation/built-in'; import { StateBuilder, StateTransform } from '../../mol-state'; import { StripedResidues } from './coloring'; import { StaticSuperpositionTestData, buildStaticSuperposition, dynamicSuperpositionTest } from './superposition'; @@ -103,7 +103,7 @@ class BasicWrapper { let tree: StateBuilder.Root; if (loadType === 'full') { - await PluginCommands.State.RemoveObject.dispatch(this.plugin, { state, ref: state.tree.root.ref }); + await PluginCommands.State.RemoveObject(this.plugin, { state, ref: state.tree.root.ref }); tree = state.build(); this.visual(this.parse(this.download(tree.toRoot(), url), format, assemblyId)); } else { @@ -118,14 +118,14 @@ class BasicWrapper { tree.to('asm').update(StateTransforms.Model.StructureFromModel, p => ({ ...p, ...props })); } - await PluginCommands.State.Update.dispatch(this.plugin, { state: this.plugin.state.dataState, tree }); + await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree }); this.loadedParams = { url, format, assemblyId }; - PluginCommands.Camera.Reset.dispatch(this.plugin, { }); + PluginCommands.Camera.Reset(this.plugin, { }); } setBackground(color: number) { const renderer = this.plugin.canvas3d!.props.renderer; - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { renderer: { ...renderer, backgroundColor: Color(color) } } }); + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { renderer: { ...renderer, backgroundColor: Color(color) } } }); } toggleSpin() { @@ -133,8 +133,8 @@ class BasicWrapper { const trackball = this.plugin.canvas3d.props.trackball; const spinning = trackball.spin; - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { trackball: { ...trackball, spin: !trackball.spin } } }); - if (!spinning) PluginCommands.Camera.Reset.dispatch(this.plugin, { }); + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { trackball: { ...trackball, spin: !trackball.spin } } }); + if (!spinning) PluginCommands.Camera.Reset(this.plugin, { }); } animate = { @@ -160,7 +160,7 @@ class BasicWrapper { tree.to(v).update(old => ({ ...old, colorTheme })); } - await PluginCommands.State.Update.dispatch(this.plugin, { state, tree }); + await PluginCommands.State.Update(this.plugin, { state, tree }); } } @@ -184,34 +184,34 @@ class BasicWrapper { staticSuperposition: async () => { const state = this.plugin.state.dataState; const tree = buildStaticSuperposition(this.plugin, StaticSuperpositionTestData); - await PluginCommands.State.RemoveObject.dispatch(this.plugin, { state, ref: StateTransform.RootRef }); - await PluginCommands.State.Update.dispatch(this.plugin, { state, tree }); + await PluginCommands.State.RemoveObject(this.plugin, { state, ref: StateTransform.RootRef }); + await PluginCommands.State.Update(this.plugin, { state, tree }); }, dynamicSuperposition: async () => { - await PluginCommands.State.RemoveObject.dispatch(this.plugin, { state: this.plugin.state.dataState, ref: StateTransform.RootRef }); + await PluginCommands.State.RemoveObject(this.plugin, { state: this.plugin.state.dataState, ref: StateTransform.RootRef }); await dynamicSuperpositionTest(this.plugin, ['1tqn', '2hhb', '4hhb'], 'HEM'); }, toggleValidationTooltip: async () => { const state = this.plugin.state.behaviorState; const tree = state.build().to(PDBeStructureQualityReport.id).update(PDBeStructureQualityReport, p => ({ ...p, showTooltip: !p.showTooltip })); - await PluginCommands.State.Update.dispatch(this.plugin, { state, tree }); + await PluginCommands.State.Update(this.plugin, { state, tree }); }, showToasts: () => { - PluginCommands.Toast.Show.dispatch(this.plugin, { + PluginCommands.Toast.Show(this.plugin, { title: 'Toast 1', message: 'This is an example text, timeout 3s', key: 'toast-1', timeoutMs: 3000 }); - PluginCommands.Toast.Show.dispatch(this.plugin, { + PluginCommands.Toast.Show(this.plugin, { title: 'Toast 2', message: CustomToastMessage, key: 'toast-2' }); }, hideToasts: () => { - PluginCommands.Toast.Hide.dispatch(this.plugin, { key: 'toast-1' }); - PluginCommands.Toast.Hide.dispatch(this.plugin, { key: 'toast-2' }); + PluginCommands.Toast.Hide(this.plugin, { key: 'toast-1' }); + PluginCommands.Toast.Hide(this.plugin, { key: 'toast-2' }); } } } diff --git a/src/apps/basic-wrapper/superposition.ts b/src/apps/basic-wrapper/superposition.ts index 13e487af0..d7483ae06 100644 --- a/src/apps/basic-wrapper/superposition.ts +++ b/src/apps/basic-wrapper/superposition.ts @@ -9,9 +9,9 @@ import { PluginContext } from '../../mol-plugin/context'; import { Mat4 } from '../../mol-math/linear-algebra'; import { StateHelper } from './helpers'; -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import { StateSelection, StateBuilder } from '../../mol-state'; -import { PluginStateObject as PSO } from '../../mol-plugin/state/objects'; +import { PluginStateObject as PSO } from '../../mol-plugin-state/objects'; import { MolScriptBuilder as MS } from '../../mol-script/language/builder'; import { compile } from '../../mol-script/runtime/query/compiler'; import { StructureSelection, QueryContext } from '../../mol-model/structure'; @@ -71,7 +71,7 @@ export async function dynamicSuperpositionTest(ctx: PluginContext, src: string[] StateHelper.getModel(StateHelper.download(structures, `https://www.ebi.ac.uk/pdbe/static/entry/${s}_updated.cif`), 'cif')); } - await PluginCommands.State.Update.dispatch(ctx, { state, tree: structures }); + await PluginCommands.State.Update(ctx, { state, tree: structures }); const pivot = MS.struct.filter.first([ MS.struct.generator.atomGroups({ @@ -99,7 +99,7 @@ export async function dynamicSuperpositionTest(ctx: PluginContext, src: string[] pivot, rest); } - await PluginCommands.State.Update.dispatch(ctx, { state, tree: visuals }); + await PluginCommands.State.Update(ctx, { state, tree: visuals }); } function siteVisual(ctx: PluginContext, b: StateBuilder.To<PSO.Molecule.Structure>, pivot: Expression, rest: Expression) { diff --git a/src/apps/demos/lighting/index.ts b/src/apps/demos/lighting/index.ts index dab86f463..51c74e24a 100644 --- a/src/apps/demos/lighting/index.ts +++ b/src/apps/demos/lighting/index.ts @@ -7,10 +7,10 @@ import { createPlugin, DefaultPluginSpec } from '../../../mol-plugin'; import './index.html' import { PluginContext } from '../../../mol-plugin/context'; -import { PluginCommands } from '../../../mol-plugin/command'; -import { StateTransforms } from '../../../mol-plugin/state/transforms'; -import { StructureRepresentation3DHelpers } from '../../../mol-plugin/state/transforms/representation'; -import { PluginStateObject as PSO } from '../../../mol-plugin/state/objects'; +import { PluginCommands } from '../../../mol-plugin/commands'; +import { StateTransforms } from '../../../mol-plugin-state/transforms'; +import { StructureRepresentation3DHelpers } from '../../../mol-plugin-state/transforms/representation'; +import { PluginStateObject as PSO } from '../../../mol-plugin-state/objects'; import { StateBuilder } from '../../../mol-state'; import { Canvas3DProps } from '../../../mol-canvas3d/canvas3d'; require('mol-plugin-ui/skin/light.scss') @@ -94,7 +94,7 @@ class LightingDemo { setPreset(preset: Canvas3DPreset) { const props = getPreset(preset) - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { ...props, multiSample: { ...this.plugin.canvas3d!.props.multiSample, @@ -155,7 +155,7 @@ class LightingDemo { let tree: StateBuilder.Root; if (loadType === 'full') { - await PluginCommands.State.RemoveObject.dispatch(this.plugin, { state, ref: state.tree.root.ref }); + await PluginCommands.State.RemoveObject(this.plugin, { state, ref: state.tree.root.ref }); tree = state.build(); this.visual(this.parse(this.download(tree.toRoot(), url), format, assemblyId)); } else { @@ -169,9 +169,9 @@ class LightingDemo { tree.to('asm').update(StateTransforms.Model.StructureFromModel, p => ({ ...p, ...props })); } - await PluginCommands.State.Update.dispatch(this.plugin, { state: this.plugin.state.dataState, tree }); + await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree }); this.loadedParams = { url, format, assemblyId }; - PluginCommands.Camera.Reset.dispatch(this.plugin, { }); + PluginCommands.Camera.Reset(this.plugin, { }); } } diff --git a/src/apps/state-docs/index.ts b/src/apps/state-docs/index.ts index 833acf0b7..49289aab4 100644 --- a/src/apps/state-docs/index.ts +++ b/src/apps/state-docs/index.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import * as _ from '../../mol-plugin/state/transforms' +import * as _ from '../../mol-plugin-state/transforms' import { StateTransformer, StateObject } from '../../mol-state'; import { StringBuilder } from '../../mol-util'; import * as fs from 'fs'; diff --git a/src/apps/viewer/extensions/cellpack/model.ts b/src/apps/viewer/extensions/cellpack/model.ts index bae20822d..93c6b5de3 100644 --- a/src/apps/viewer/extensions/cellpack/model.ts +++ b/src/apps/viewer/extensions/cellpack/model.ts @@ -6,7 +6,7 @@ import { StateAction } from '../../../../mol-state'; import { PluginContext } from '../../../../mol-plugin/context'; -import { PluginStateObject as PSO } from '../../../../mol-plugin/state/objects'; +import { PluginStateObject as PSO } from '../../../../mol-plugin-state/objects'; import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; import { Ingredient, CellPacking, Cell } from './data'; import { getFromPdb, getFromCellPackDB } from './util'; @@ -16,8 +16,8 @@ import { trajectoryFromPDB } from '../../../../mol-model-formats/structure/pdb'; import { Mat4, Vec3, Quat } from '../../../../mol-math/linear-algebra'; import { SymmetryOperator } from '../../../../mol-math/geometry'; import { Task } from '../../../../mol-task'; -import { StructureRepresentation3DHelpers } from '../../../../mol-plugin/state/transforms/representation'; -import { StateTransforms } from '../../../../mol-plugin/state/transforms'; +import { StructureRepresentation3DHelpers } from '../../../../mol-plugin-state/transforms/representation'; +import { StateTransforms } from '../../../../mol-plugin-state/transforms'; import { distinctColors } from '../../../../mol-util/color/distinct'; import { ModelIndexColorThemeProvider } from '../../../../mol-theme/color/model-index'; import { Hcl } from '../../../../mol-util/color/spaces/hcl'; diff --git a/src/apps/viewer/extensions/cellpack/state.ts b/src/apps/viewer/extensions/cellpack/state.ts index 61ae4062b..fb17293ca 100644 --- a/src/apps/viewer/extensions/cellpack/state.ts +++ b/src/apps/viewer/extensions/cellpack/state.ts @@ -4,7 +4,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginStateObject as PSO, PluginStateTransform } from '../../../../mol-plugin/state/objects'; +import { PluginStateObject as PSO, PluginStateTransform } from '../../../../mol-plugin-state/objects'; import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; import { Task } from '../../../../mol-task'; import { CellPack as _CellPack, Cell, CellPacking } from './data'; diff --git a/src/apps/viewer/index.ts b/src/apps/viewer/index.ts index a4b56faad..554df9dc0 100644 --- a/src/apps/viewer/index.ts +++ b/src/apps/viewer/index.ts @@ -10,11 +10,11 @@ import { createPlugin, DefaultPluginSpec } from '../../mol-plugin'; import './index.html' import './favicon.ico' import { PluginContext } from '../../mol-plugin/context'; -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import { PluginSpec } from '../../mol-plugin/spec'; import { LoadCellPackModel } from './extensions/cellpack/model'; import { StructureFromCellpack } from './extensions/cellpack/state'; -import { DownloadStructure } from '../../mol-plugin/state/actions/structure'; +import { DownloadStructure } from '../../mol-plugin-state/actions/structure'; require('mol-plugin-ui/skin/light.scss') function getParam(name: string, regex: string): string { @@ -60,7 +60,7 @@ async function trySetSnapshot(ctx: PluginContext) { const url = snapshotId ? `https://webchem.ncbr.muni.cz/molstar-state/get/${snapshotId}` : snapshotUrl; - await PluginCommands.State.Snapshots.Fetch.dispatch(ctx, { url }) + await PluginCommands.State.Snapshots.Fetch(ctx, { url }) } catch (e) { ctx.log.error('Failed to load snapshot.'); console.warn('Failed to load snapshot', e); diff --git a/src/examples/proteopedia-wrapper/index.ts b/src/examples/proteopedia-wrapper/index.ts index 2ecd40ac6..cd9fbfa7f 100644 --- a/src/examples/proteopedia-wrapper/index.ts +++ b/src/examples/proteopedia-wrapper/index.ts @@ -8,12 +8,12 @@ import * as ReactDOM from 'react-dom'; import { createPlugin, DefaultPluginSpec } from '../../mol-plugin'; import './index.html' import { PluginContext } from '../../mol-plugin/context'; -import { PluginCommands } from '../../mol-plugin/command'; -import { StateTransforms } from '../../mol-plugin/state/transforms'; -import { StructureRepresentation3DHelpers } from '../../mol-plugin/state/transforms/representation'; +import { PluginCommands } from '../../mol-plugin/commands'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; +import { StructureRepresentation3DHelpers } from '../../mol-plugin-state/transforms/representation'; import { Color } from '../../mol-util/color'; -import { PluginStateObject as PSO, PluginStateObject } from '../../mol-plugin/state/objects'; -import { AnimateModelIndex } from '../../mol-plugin/state/animation/built-in'; +import { PluginStateObject as PSO, PluginStateObject } from '../../mol-plugin-state/objects'; +import { AnimateModelIndex } from '../../mol-plugin-state/animation/built-in'; import { StateBuilder, StateObject, StateSelection } from '../../mol-state'; import { EvolutionaryConservation } from './annotation'; import { LoadParams, SupportedFormats, RepresentationStyle, ModelInfo, StateElements } from './helpers'; @@ -192,7 +192,7 @@ class MolStarProteopediaWrapper { } private applyState(tree: StateBuilder) { - return PluginCommands.State.Update.dispatch(this.plugin, { state: this.plugin.state.dataState, tree }); + return PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree }); } private loadedParams: LoadParams = { url: '', format: 'cif', assemblyId: '' }; @@ -208,7 +208,7 @@ class MolStarProteopediaWrapper { } if (loadType === 'full') { - await PluginCommands.State.RemoveObject.dispatch(this.plugin, { state, ref: state.tree.root.ref }); + await PluginCommands.State.RemoveObject(this.plugin, { state, ref: state.tree.root.ref }); const modelTree = this.model(this.download(state.build().toRoot(), url), format); await this.applyState(modelTree); const info = await this.doInfo(true); @@ -232,32 +232,32 @@ class MolStarProteopediaWrapper { await this.updateStyle(representationStyle); this.loadedParams = { url, format, assemblyId }; - Scheduler.setImmediate(() => PluginCommands.Camera.Reset.dispatch(this.plugin, { })); + Scheduler.setImmediate(() => PluginCommands.Camera.Reset(this.plugin, { })); } async updateStyle(style?: RepresentationStyle, partial?: boolean) { const tree = this.visual(style, partial); if (!tree) return; - await PluginCommands.State.Update.dispatch(this.plugin, { state: this.plugin.state.dataState, tree }); + await PluginCommands.State.Update(this.plugin, { state: this.plugin.state.dataState, tree }); } setBackground(color: number) { if (!this.plugin.canvas3d) return; const renderer = this.plugin.canvas3d.props.renderer; - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { renderer: { ...renderer, backgroundColor: Color(color) } } }); + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { renderer: { ...renderer, backgroundColor: Color(color) } } }); } toggleSpin() { if (!this.plugin.canvas3d) return; const trackball = this.plugin.canvas3d.props.trackball; const spinning = trackball.spin; - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { trackball: { ...trackball, spin: !trackball.spin } } }); - if (!spinning) PluginCommands.Camera.Reset.dispatch(this.plugin, { }); + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { trackball: { ...trackball, spin: !trackball.spin } } }); + if (!spinning) PluginCommands.Camera.Reset(this.plugin, { }); } viewport = { setSettings: (settings?: Canvas3DProps) => { - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: settings || DefaultCanvas3DParams }); } @@ -265,10 +265,10 @@ class MolStarProteopediaWrapper { camera = { toggleSpin: () => this.toggleSpin(), - resetPosition: () => PluginCommands.Camera.Reset.dispatch(this.plugin, { }), + resetPosition: () => PluginCommands.Camera.Reset(this.plugin, { }), // setClip: (options?: { distance?: number, near?: number, far?: number }) => { // if (!options) { - // PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { + // PluginCommands.Canvas3D.SetSettings(this.plugin, { // settings: { // cameraClipDistance: DefaultCanvas3DParams.cameraClipDistance, // clip: DefaultCanvas3DParams.clip @@ -281,7 +281,7 @@ class MolStarProteopediaWrapper { // const props = this.plugin.canvas3d.props; // const clipNear = typeof options.near === 'undefined' ? props.clip[0] : options.near; // const clipFar = typeof options.far === 'undefined' ? props.clip[1] : options.far; - // PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { + // PluginCommands.Canvas3D.SetSettings(this.plugin, { // settings: { cameraClipDistance: options.distance, clip: [clipNear, clipFar] } // }); // } @@ -320,7 +320,7 @@ class MolStarProteopediaWrapper { tree.to(StateElements.HetVisual).update(StateTransforms.Representation.StructureRepresentation3D, old => ({ ...old, colorTheme })); } - await PluginCommands.State.Update.dispatch(this.plugin, { state, tree }); + await PluginCommands.State.Update(this.plugin, { state, tree }); } } @@ -340,7 +340,7 @@ class MolStarProteopediaWrapper { remove: () => { const r = this.state.select(StateSelection.Generators.ofTransformer(CreateVolumeStreamingInfo))[0]; if (!r) return; - PluginCommands.State.RemoveObject.dispatch(this.plugin, { state: this.state, ref: r.transform.ref }); + PluginCommands.State.RemoveObject(this.plugin, { state: this.state, ref: r.transform.ref }); if (this.experimentalDataElement) { ReactDOM.unmountComponentAtNode(this.experimentalDataElement); this.experimentalDataElement = void 0; @@ -351,12 +351,12 @@ class MolStarProteopediaWrapper { hetGroups = { reset: () => { const update = this.state.build().delete(StateElements.HetGroupFocusGroup); - PluginCommands.State.Update.dispatch(this.plugin, { state: this.state, tree: update }); - PluginCommands.Camera.Reset.dispatch(this.plugin, { }); + PluginCommands.State.Update(this.plugin, { state: this.state, tree: update }); + PluginCommands.Camera.Reset(this.plugin, { }); }, focusFirst: async (compId: string) => { if (!this.state.transforms.has(StateElements.Assembly)) return; - await PluginCommands.Camera.Reset.dispatch(this.plugin, { }); + await PluginCommands.Camera.Reset(this.plugin, { }); // const asm = (this.state.select(StateElements.Assembly)[0].obj as PluginStateObject.Molecule.Structure).data; @@ -389,7 +389,7 @@ class MolStarProteopediaWrapper { // } // }); - await PluginCommands.State.Update.dispatch(this.plugin, { state: this.state, tree: update }); + await PluginCommands.State.Update(this.plugin, { state: this.state, tree: update }); const focus = (this.state.select(StateElements.HetGroupFocus)[0].obj as PluginStateObject.Molecule.Structure).data; const sphere = focus.boundary.sphere; @@ -399,7 +399,7 @@ class MolStarProteopediaWrapper { // Vec3.scaleAndAdd(position, sphere.center, position, sphere.radius); const radius = Math.max(sphere.radius, 5) const snapshot = this.plugin.canvas3d!.camera.getFocus(sphere.center, radius, radius); - PluginCommands.Camera.SetSnapshot.dispatch(this.plugin, { snapshot, durationMs: 250 }); + PluginCommands.Camera.SetSnapshot(this.plugin, { snapshot, durationMs: 250 }); } } diff --git a/src/mol-plugin/state/actions.ts b/src/mol-plugin-state/actions.ts similarity index 100% rename from src/mol-plugin/state/actions.ts rename to src/mol-plugin-state/actions.ts diff --git a/src/mol-plugin/state/actions/data-format.ts b/src/mol-plugin-state/actions/data-format.ts similarity index 94% rename from src/mol-plugin/state/actions/data-format.ts rename to src/mol-plugin-state/actions/data-format.ts index a759f94eb..d10dd0984 100644 --- a/src/mol-plugin/state/actions/data-format.ts +++ b/src/mol-plugin-state/actions/data-format.ts @@ -4,16 +4,16 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginContext } from '../../../mol-plugin/context'; -import { State, StateBuilder, StateAction } from '../../../mol-state'; -import { Task } from '../../../mol-task'; -import { FileInfo, getFileInfo } from '../../../mol-util/file-info'; +import { PluginContext } from '../../mol-plugin/context'; +import { State, StateBuilder, StateAction } from '../../mol-state'; +import { Task } from '../../mol-task'; +import { FileInfo, getFileInfo } from '../../mol-util/file-info'; import { PluginStateObject } from '../objects'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { Ccp4Provider, Dsn6Provider, DscifProvider } from './volume'; import { StateTransforms } from '../transforms'; import { MmcifProvider, PdbProvider, GroProvider, Provider3dg, DcdProvider, PsfProvider } from './structure'; -import msgpackDecode from '../../../mol-io/common/msgpack/decode' +import msgpackDecode from '../../mol-io/common/msgpack/decode' import { PlyProvider } from './shape'; export class DataFormatRegistry<D extends PluginStateObject.Data.Binary | PluginStateObject.Data.String> { diff --git a/src/mol-plugin/state/actions/shape.ts b/src/mol-plugin-state/actions/shape.ts similarity index 84% rename from src/mol-plugin/state/actions/shape.ts rename to src/mol-plugin-state/actions/shape.ts index 799b27176..ba8802301 100644 --- a/src/mol-plugin/state/actions/shape.ts +++ b/src/mol-plugin-state/actions/shape.ts @@ -4,10 +4,10 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginContext } from '../../../mol-plugin/context'; -import { State, StateBuilder } from '../../../mol-state'; -import { Task } from '../../../mol-task'; -import { FileInfo } from '../../../mol-util/file-info'; +import { PluginContext } from '../../mol-plugin/context'; +import { State, StateBuilder } from '../../mol-state'; +import { Task } from '../../mol-task'; +import { FileInfo } from '../../mol-util/file-info'; import { PluginStateObject } from '../objects'; import { StateTransforms } from '../transforms'; import { DataFormatProvider, DataFormatBuilderOptions } from './data-format'; diff --git a/src/mol-plugin/state/actions/structure.ts b/src/mol-plugin-state/actions/structure.ts similarity index 98% rename from src/mol-plugin/state/actions/structure.ts rename to src/mol-plugin-state/actions/structure.ts index 91c7a56c8..e53e1fb0c 100644 --- a/src/mol-plugin/state/actions/structure.ts +++ b/src/mol-plugin-state/actions/structure.ts @@ -5,18 +5,18 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginContext } from '../../../mol-plugin/context'; -import { StateAction, StateBuilder, StateSelection, StateTransformer, State } from '../../../mol-state'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { PluginContext } from '../../mol-plugin/context'; +import { StateAction, StateBuilder, StateSelection, StateTransformer, State } from '../../mol-state'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { PluginStateObject } from '../objects'; import { StateTransforms } from '../transforms'; import { Download, ParsePsf } from '../transforms/data'; import { CustomModelProperties, StructureSelectionFromExpression, CustomStructureProperties, CoordinatesFromDcd, TrajectoryFromModelAndCoordinates, TopologyFromPsf } from '../transforms/model'; import { DataFormatProvider, guessCifVariant, DataFormatBuilderOptions } from './data-format'; -import { FileInfo } from '../../../mol-util/file-info'; -import { Task } from '../../../mol-task'; -import { StructureElement } from '../../../mol-model/structure'; -import { createDefaultStructureComplex } from '../../util/structure-complex-helper'; +import { FileInfo } from '../../mol-util/file-info'; +import { Task } from '../../mol-task'; +import { StructureElement } from '../../mol-model/structure'; +import { createDefaultStructureComplex } from '../../mol-plugin/util/structure-complex-helper'; import { ModelStructureRepresentation } from '../representation/model'; export const MmcifProvider: DataFormatProvider<any> = { diff --git a/src/mol-plugin/state/actions/volume.ts b/src/mol-plugin-state/actions/volume.ts similarity index 96% rename from src/mol-plugin/state/actions/volume.ts rename to src/mol-plugin-state/actions/volume.ts index f8e4ed329..9179c1bf4 100644 --- a/src/mol-plugin/state/actions/volume.ts +++ b/src/mol-plugin-state/actions/volume.ts @@ -5,13 +5,13 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { VolumeIsoValue } from '../../../mol-model/volume'; -import { PluginContext } from '../../../mol-plugin/context'; -import { State, StateAction, StateBuilder, StateTransformer } from '../../../mol-state'; -import { Task } from '../../../mol-task'; -import { ColorNames } from '../../../mol-util/color/names'; -import { FileInfo, getFileInfo } from '../../../mol-util/file-info'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { VolumeIsoValue } from '../../mol-model/volume'; +import { PluginContext } from '../../mol-plugin/context'; +import { State, StateAction, StateBuilder, StateTransformer } from '../../mol-state'; +import { Task } from '../../mol-task'; +import { ColorNames } from '../../mol-util/color/names'; +import { FileInfo, getFileInfo } from '../../mol-util/file-info'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { PluginStateObject } from '../objects'; import { StateTransforms } from '../transforms'; import { Download } from '../transforms/data'; diff --git a/src/mol-plugin/state/animation/built-in.ts b/src/mol-plugin-state/animation/built-in.ts similarity index 93% rename from src/mol-plugin/state/animation/built-in.ts rename to src/mol-plugin-state/animation/built-in.ts index 13009ea6a..3ed50d480 100644 --- a/src/mol-plugin/state/animation/built-in.ts +++ b/src/mol-plugin-state/animation/built-in.ts @@ -7,10 +7,10 @@ import { PluginStateAnimation } from './model'; import { PluginStateObject } from '../objects'; import { StateTransforms } from '../transforms'; -import { StateSelection, StateTransform } from '../../../mol-state'; -import { PluginCommands } from '../../../mol-plugin/command'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { PluginContext } from '../../../mol-plugin/context'; +import { StateSelection, StateTransform } from '../../mol-state'; +import { PluginCommands } from '../../mol-plugin/commands'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; +import { PluginContext } from '../../mol-plugin/context'; export const AnimateModelIndex = PluginStateAnimation.create({ name: 'built-in.animate-model-index', @@ -79,7 +79,7 @@ export const AnimateModelIndex = PluginStateAnimation.create({ }); } - await PluginCommands.State.Update.dispatch(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); if (allSingles || (params.mode.name === 'once' && isEnd)) return { kind: 'finished' }; if (params.mode.name === 'palindrome') return { kind: 'next', state: { palindromeDirections } }; @@ -159,7 +159,7 @@ export const AnimateAssemblyUnwind = PluginStateAnimation.create({ update.to(m).update({ t: newTime }); } - await PluginCommands.State.Update.dispatch(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); if (finished) return { kind: 'finished' }; return { kind: 'next', state: { t: newTime } }; @@ -219,7 +219,7 @@ export const AnimateUnitsExplode = PluginStateAnimation.create({ update.to(m).update({ t: newTime }); } - await PluginCommands.State.Update.dispatch(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); return { kind: 'next', state: { t: newTime } }; } @@ -269,7 +269,7 @@ export const AnimateStateInterpolation = PluginStateAnimation.create({ } } - await PluginCommands.State.Update.dispatch(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(ctx.plugin, { state, tree: update, options: { doNotLogTiming: true } }); return { kind: 'next', state: { } }; } diff --git a/src/mol-plugin/state/animation/helpers.ts b/src/mol-plugin-state/animation/helpers.ts similarity index 81% rename from src/mol-plugin/state/animation/helpers.ts rename to src/mol-plugin-state/animation/helpers.ts index 7d0a51bdc..700eef0f7 100644 --- a/src/mol-plugin/state/animation/helpers.ts +++ b/src/mol-plugin-state/animation/helpers.ts @@ -4,10 +4,10 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { SymmetryOperator } from '../../../mol-math/geometry'; -import { Mat4, Vec3 } from '../../../mol-math/linear-algebra'; -import { Structure } from '../../../mol-model/structure'; -import { StructureUnitTransforms } from '../../../mol-model/structure/structure/util/unit-transforms'; +import { SymmetryOperator } from '../../mol-math/geometry'; +import { Mat4, Vec3 } from '../../mol-math/linear-algebra'; +import { Structure } from '../../mol-model/structure'; +import { StructureUnitTransforms } from '../../mol-model/structure/structure/util/unit-transforms'; const _unwindMatrix = Mat4.zero(); export function unwindStructureAssembly(structure: Structure, unitTransforms: StructureUnitTransforms, t: number) { diff --git a/src/mol-plugin/state/animation/manager.ts b/src/mol-plugin-state/animation/manager.ts similarity index 97% rename from src/mol-plugin/state/animation/manager.ts rename to src/mol-plugin-state/animation/manager.ts index 2b73af3ed..6cb6a39cf 100644 --- a/src/mol-plugin/state/animation/manager.ts +++ b/src/mol-plugin-state/animation/manager.ts @@ -4,10 +4,10 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginComponent } from '../../../mol-plugin/component'; -import { PluginContext } from '../../../mol-plugin/context'; +import { PluginComponent } from '../../mol-plugin/component'; +import { PluginContext } from '../../mol-plugin/context'; import { PluginStateAnimation } from './model'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; export { PluginAnimationManager } diff --git a/src/mol-plugin/state/animation/model.ts b/src/mol-plugin-state/animation/model.ts similarity index 92% rename from src/mol-plugin/state/animation/model.ts rename to src/mol-plugin-state/animation/model.ts index 20e6f422f..a1e2c3664 100644 --- a/src/mol-plugin/state/animation/model.ts +++ b/src/mol-plugin-state/animation/model.ts @@ -4,8 +4,8 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { PluginContext } from '../../../mol-plugin/context'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; +import { PluginContext } from '../../mol-plugin/context'; export { PluginStateAnimation } diff --git a/src/mol-plugin/state/camera.ts b/src/mol-plugin-state/camera.ts similarity index 93% rename from src/mol-plugin/state/camera.ts rename to src/mol-plugin-state/camera.ts index ef5792d83..03789beb3 100644 --- a/src/mol-plugin/state/camera.ts +++ b/src/mol-plugin-state/camera.ts @@ -4,10 +4,10 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Camera } from '../../mol-canvas3d/camera'; +import { Camera } from '../mol-canvas3d/camera'; import { OrderedMap } from 'immutable'; -import { UUID } from '../../mol-util'; -import { PluginComponent } from '../../mol-plugin/component'; +import { UUID } from '../mol-util'; +import { PluginComponent } from '../mol-plugin/component'; export { CameraSnapshotManager } diff --git a/src/mol-plugin/state/manager/base.ts b/src/mol-plugin-state/manager/base.ts similarity index 86% rename from src/mol-plugin/state/manager/base.ts rename to src/mol-plugin-state/manager/base.ts index c3433c3b0..c432b23c3 100644 --- a/src/mol-plugin/state/manager/base.ts +++ b/src/mol-plugin-state/manager/base.ts @@ -6,9 +6,9 @@ // TODO: primites -import { StateObject, State, StateObjectCell, StateBuilder, StateTransformer, StateTransform } from '../../../mol-state'; -import { RuntimeContext } from '../../../mol-task'; -import { PluginContext } from '../../context'; +import { StateObject, State, StateObjectCell, StateBuilder, StateTransformer, StateTransform } from '../../mol-state'; +import { RuntimeContext } from '../../mol-task'; +import { PluginContext } from '../../mol-plugin/context'; export { StateAction, BuilderAction } diff --git a/src/mol-plugin/state/manager/data.ts b/src/mol-plugin-state/manager/data.ts similarity index 92% rename from src/mol-plugin/state/manager/data.ts rename to src/mol-plugin-state/manager/data.ts index 4241ec1dc..65edae912 100644 --- a/src/mol-plugin/state/manager/data.ts +++ b/src/mol-plugin-state/manager/data.ts @@ -4,13 +4,13 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { StateTransformer, StateTransform, StateObjectSelector, StateObjectCell } from '../../../mol-state'; -import { PluginContext } from '../../context'; +import { StateTransformer, StateTransform, StateObjectSelector, StateObjectCell } from '../../mol-state'; +import { PluginContext } from '../../mol-plugin/context'; import { Download, ReadFile } from '../transforms/data'; -import { getFileInfo } from '../../../mol-util/file-info'; +import { getFileInfo } from '../../mol-util/file-info'; import { DataFormatProvider } from './data/provider'; import { BuiltInDataFormats } from './data/formats'; -import { objectForEach } from '../../../mol-util/object'; +import { objectForEach } from '../../mol-util/object'; export class DataManager { readonly formats: DataFormatProvider[] = []; diff --git a/src/mol-plugin/state/manager/data/actions.ts b/src/mol-plugin-state/manager/data/actions.ts similarity index 91% rename from src/mol-plugin/state/manager/data/actions.ts rename to src/mol-plugin-state/manager/data/actions.ts index 0c036e4a6..684eea626 100644 --- a/src/mol-plugin/state/manager/data/actions.ts +++ b/src/mol-plugin-state/manager/data/actions.ts @@ -5,7 +5,7 @@ */ import { BuilderAction } from '../base'; -import { StateTransformer } from '../../../../mol-state'; +import { StateTransformer } from '../../../mol-state'; import { Download as DownloadData, ReadFile } from '../../transforms/data'; export const Download = BuilderAction((builder, params: StateTransformer.Params<DownloadData>, { options }) => { diff --git a/src/mol-plugin/state/manager/data/formats.ts b/src/mol-plugin-state/manager/data/formats.ts similarity index 93% rename from src/mol-plugin/state/manager/data/formats.ts rename to src/mol-plugin-state/manager/data/formats.ts index 22f3adf7b..e26e747db 100644 --- a/src/mol-plugin/state/manager/data/formats.ts +++ b/src/mol-plugin-state/manager/data/formats.ts @@ -5,8 +5,8 @@ */ import { DataFormatProvider } from './provider'; -import { PluginContext } from '../../../context'; -import { FileInfo } from '../../../../mol-util/file-info'; +import { PluginContext } from '../../../mol-plugin/context'; +import { FileInfo } from '../../../mol-util/file-info'; import { StateTransforms } from '../../transforms'; export const MmcifFormatProvider = DataFormatProvider({ diff --git a/src/mol-plugin/state/manager/data/provider.ts b/src/mol-plugin-state/manager/data/provider.ts similarity index 91% rename from src/mol-plugin/state/manager/data/provider.ts rename to src/mol-plugin-state/manager/data/provider.ts index 788583f36..442744bc2 100644 --- a/src/mol-plugin/state/manager/data/provider.ts +++ b/src/mol-plugin-state/manager/data/provider.ts @@ -4,11 +4,11 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginContext } from '../../../context'; -import { State, StateObjectCell } from '../../../../mol-state'; -import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; +import { PluginContext } from '../../../mol-plugin/context'; +import { State, StateObjectCell } from '../../../mol-state'; +import { ParamDefinition as PD } from '../../../mol-util/param-definition'; import { PluginStateObject } from '../../objects'; -import { FileInfo } from '../../../../mol-util/file-info'; +import { FileInfo } from '../../../mol-util/file-info'; export { DataFormatProvider } diff --git a/src/mol-plugin/state/manager/data/sources.ts b/src/mol-plugin-state/manager/data/sources.ts similarity index 100% rename from src/mol-plugin/state/manager/data/sources.ts rename to src/mol-plugin-state/manager/data/sources.ts diff --git a/src/mol-plugin/state/manager/structure.ts b/src/mol-plugin-state/manager/structure.ts similarity index 100% rename from src/mol-plugin/state/manager/structure.ts rename to src/mol-plugin-state/manager/structure.ts diff --git a/src/mol-plugin/state/manager/structure/components.ts b/src/mol-plugin-state/manager/structure/components.ts similarity index 100% rename from src/mol-plugin/state/manager/structure/components.ts rename to src/mol-plugin-state/manager/structure/components.ts diff --git a/src/mol-plugin/state/manager/structure/model.ts b/src/mol-plugin-state/manager/structure/model.ts similarity index 100% rename from src/mol-plugin/state/manager/structure/model.ts rename to src/mol-plugin-state/manager/structure/model.ts diff --git a/src/mol-plugin/state/manager/structure/representations.ts b/src/mol-plugin-state/manager/structure/representations.ts similarity index 100% rename from src/mol-plugin/state/manager/structure/representations.ts rename to src/mol-plugin-state/manager/structure/representations.ts diff --git a/src/mol-plugin/state/manager/structure/selection.ts b/src/mol-plugin-state/manager/structure/selection.ts similarity index 100% rename from src/mol-plugin/state/manager/structure/selection.ts rename to src/mol-plugin-state/manager/structure/selection.ts diff --git a/src/mol-plugin/state/manager/structure/volume.ts b/src/mol-plugin-state/manager/structure/volume.ts similarity index 100% rename from src/mol-plugin/state/manager/structure/volume.ts rename to src/mol-plugin-state/manager/structure/volume.ts diff --git a/src/mol-plugin/state/objects.ts b/src/mol-plugin-state/objects.ts similarity index 84% rename from src/mol-plugin/state/objects.ts rename to src/mol-plugin-state/objects.ts index 64e305f28..c537ced7e 100644 --- a/src/mol-plugin/state/objects.ts +++ b/src/mol-plugin-state/objects.ts @@ -5,25 +5,25 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { CifFile } from '../../mol-io/reader/cif'; -import { PlyFile } from '../../mol-io/reader/ply/schema'; -import { Coordinates as _Coordinates } from '../../mol-model/structure'; -import { Topology as _Topology } from '../../mol-model/structure'; -import { Model as _Model, Structure as _Structure, StructureElement } from '../../mol-model/structure'; -import { VolumeData } from '../../mol-model/volume'; -import { PluginBehavior } from '../../mol-plugin/behavior/behavior'; -import { Representation } from '../../mol-repr/representation'; -import { StructureRepresentation, StructureRepresentationState } from '../../mol-repr/structure/representation'; -import { VolumeRepresentation } from '../../mol-repr/volume/representation'; -import { StateObject, StateTransformer } from '../../mol-state'; -import { Ccp4File } from '../../mol-io/reader/ccp4/schema'; -import { Dsn6File } from '../../mol-io/reader/dsn6/schema'; -import { ShapeRepresentation } from '../../mol-repr/shape/representation'; -import { Shape as _Shape } from '../../mol-model/shape'; -import { ShapeProvider } from '../../mol-model/shape/provider'; -import { File3DG } from '../../mol-io/reader/3dg/parser'; -import { DcdFile } from '../../mol-io/reader/dcd/parser'; -import { PsfFile } from '../../mol-io/reader/psf/parser'; +import { CifFile } from '../mol-io/reader/cif'; +import { PlyFile } from '../mol-io/reader/ply/schema'; +import { Coordinates as _Coordinates } from '../mol-model/structure'; +import { Topology as _Topology } from '../mol-model/structure'; +import { Model as _Model, Structure as _Structure, StructureElement } from '../mol-model/structure'; +import { VolumeData } from '../mol-model/volume'; +import { PluginBehavior } from '../mol-plugin/behavior/behavior'; +import { Representation } from '../mol-repr/representation'; +import { StructureRepresentation, StructureRepresentationState } from '../mol-repr/structure/representation'; +import { VolumeRepresentation } from '../mol-repr/volume/representation'; +import { StateObject, StateTransformer } from '../mol-state'; +import { Ccp4File } from '../mol-io/reader/ccp4/schema'; +import { Dsn6File } from '../mol-io/reader/dsn6/schema'; +import { ShapeRepresentation } from '../mol-repr/shape/representation'; +import { Shape as _Shape } from '../mol-model/shape'; +import { ShapeProvider } from '../mol-model/shape/provider'; +import { File3DG } from '../mol-io/reader/3dg/parser'; +import { DcdFile } from '../mol-io/reader/dcd/parser'; +import { PsfFile } from '../mol-io/reader/psf/parser'; export type TypeClass = 'root' | 'data' | 'prop' diff --git a/src/mol-plugin/state/representation/model.ts b/src/mol-plugin-state/representation/model.ts similarity index 92% rename from src/mol-plugin/state/representation/model.ts rename to src/mol-plugin-state/representation/model.ts index fee6cbda0..cbcda309a 100644 --- a/src/mol-plugin/state/representation/model.ts +++ b/src/mol-plugin-state/representation/model.ts @@ -5,16 +5,16 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { Model, Structure, StructureSymmetry } from '../../../mol-model/structure'; -import { stringToWords } from '../../../mol-util/string'; -import { SpacegroupCell, Spacegroup } from '../../../mol-math/geometry'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { Vec3 } from '../../../mol-math/linear-algebra'; -import { RuntimeContext } from '../../../mol-task'; -import { PluginContext } from '../../context'; -import { Assembly, Symmetry } from '../../../mol-model/structure/model/properties/symmetry'; +import { Model, Structure, StructureSymmetry } from '../../mol-model/structure'; +import { stringToWords } from '../../mol-util/string'; +import { SpacegroupCell, Spacegroup } from '../../mol-math/geometry'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; +import { Vec3 } from '../../mol-math/linear-algebra'; +import { RuntimeContext } from '../../mol-task'; +import { PluginContext } from '../../mol-plugin/context'; +import { Assembly, Symmetry } from '../../mol-model/structure/model/properties/symmetry'; import { PluginStateObject as SO } from '../objects'; -import { ModelSymmetry } from '../../../mol-model-formats/structure/property/symmetry'; +import { ModelSymmetry } from '../../mol-model-formats/structure/property/symmetry'; export namespace ModelStructureRepresentation { export function getParams(model?: Model, defaultValue?: 'deposited' | 'assembly' | 'symmetry' | 'symmetry-mates' | 'symmetry-assembly') { diff --git a/src/mol-plugin/state/representation/structure.ts b/src/mol-plugin-state/representation/structure.ts similarity index 91% rename from src/mol-plugin/state/representation/structure.ts rename to src/mol-plugin-state/representation/structure.ts index 4a7f28e75..0f3b755b2 100644 --- a/src/mol-plugin/state/representation/structure.ts +++ b/src/mol-plugin-state/representation/structure.ts @@ -4,17 +4,17 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { arrayFind } from '../../../mol-data/util'; -import { Structure } from '../../../mol-model/structure'; -import { StateTransform, StateTree, StateSelection } from '../../../mol-state'; -import { Task } from '../../../mol-task'; -import { isProductionMode } from '../../../mol-util/debug'; -import { objectForEach } from '../../../mol-util/object'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { PluginContext } from '../../context'; +import { arrayFind } from '../../mol-data/util'; +import { Structure } from '../../mol-model/structure'; +import { StateTransform, StateTree, StateSelection } from '../../mol-state'; +import { Task } from '../../mol-task'; +import { isProductionMode } from '../../mol-util/debug'; +import { objectForEach } from '../../mol-util/object'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; +import { PluginContext } from '../../mol-plugin/context'; import { PresetStructureReprentations } from './structure/preset'; import { StructureRepresentationProvider, RepresentationProviderTags } from './structure/provider'; -import { UniqueArray } from '../../../mol-data/generic'; +import { UniqueArray } from '../../mol-data/generic'; // TODO: support quality // TODO: support ignore hydrogens diff --git a/src/mol-plugin/state/representation/structure/preset.ts b/src/mol-plugin-state/representation/structure/preset.ts similarity index 97% rename from src/mol-plugin/state/representation/structure/preset.ts rename to src/mol-plugin-state/representation/structure/preset.ts index f9bebdd26..6e6cc4a3f 100644 --- a/src/mol-plugin/state/representation/structure/preset.ts +++ b/src/mol-plugin-state/representation/structure/preset.ts @@ -7,10 +7,10 @@ import { StateTransforms } from '../../transforms'; import { StructureComplexElementTypes } from '../../transforms/model'; import { StructureRepresentation3DHelpers } from '../../transforms/representation'; -import { StructureSelectionQueries as Q } from '../../../util/structure-selection-helper'; -import { BuiltInStructureRepresentations } from '../../../../mol-repr/structure/registry'; +import { StructureSelectionQueries as Q } from '../../../mol-plugin/util/structure-selection-helper'; +import { BuiltInStructureRepresentations } from '../../../mol-repr/structure/registry'; import { StructureRepresentationProvider, RepresentationProviderTags } from './provider'; -import { StateBuilder } from '../../../../mol-state'; +import { StateBuilder } from '../../../mol-state'; import { PluginStateObject } from '../../objects'; const auto = StructureRepresentationProvider({ diff --git a/src/mol-plugin/state/representation/structure/provider.ts b/src/mol-plugin-state/representation/structure/provider.ts similarity index 77% rename from src/mol-plugin/state/representation/structure/provider.ts rename to src/mol-plugin-state/representation/structure/provider.ts index 7b480f873..68fadcff8 100644 --- a/src/mol-plugin/state/representation/structure/provider.ts +++ b/src/mol-plugin-state/representation/structure/provider.ts @@ -4,11 +4,11 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginContext } from '../../../context'; -import { State, StateObjectCell } from '../../../../mol-state'; -import { RuntimeContext } from '../../../../mol-task'; -import { Structure } from '../../../../mol-model/structure'; -import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; +import { PluginContext } from '../../../mol-plugin/context'; +import { State, StateObjectCell } from '../../../mol-state'; +import { RuntimeContext } from '../../../mol-task'; +import { Structure } from '../../../mol-model/structure'; +import { ParamDefinition as PD } from '../../../mol-util/param-definition'; import { PluginStateObject } from '../../objects'; export interface StructureRepresentationProvider<P = any, S = {}> { diff --git a/src/mol-plugin/state/snapshots.ts b/src/mol-plugin-state/snapshots.ts similarity index 97% rename from src/mol-plugin/state/snapshots.ts rename to src/mol-plugin-state/snapshots.ts index cf3ed0ec8..78e8aa43e 100644 --- a/src/mol-plugin/state/snapshots.ts +++ b/src/mol-plugin-state/snapshots.ts @@ -5,10 +5,10 @@ */ import { List } from 'immutable'; -import { UUID } from '../../mol-util'; -import { PluginState } from '../state'; -import { PluginComponent } from '../../mol-plugin/component'; -import { PluginContext } from '../../mol-plugin/context'; +import { UUID } from '../mol-util'; +import { PluginState } from '../mol-plugin/state'; +import { PluginComponent } from '../mol-plugin/component'; +import { PluginContext } from '../mol-plugin/context'; export { PluginStateSnapshotManager } diff --git a/src/mol-plugin/state/transforms.ts b/src/mol-plugin-state/transforms.ts similarity index 100% rename from src/mol-plugin/state/transforms.ts rename to src/mol-plugin-state/transforms.ts diff --git a/src/mol-plugin/state/transforms/data.ts b/src/mol-plugin-state/transforms/data.ts similarity index 95% rename from src/mol-plugin/state/transforms/data.ts rename to src/mol-plugin-state/transforms/data.ts index 0d1d19dad..8c2866c7b 100644 --- a/src/mol-plugin/state/transforms/data.ts +++ b/src/mol-plugin-state/transforms/data.ts @@ -7,16 +7,16 @@ import { PluginStateTransform } from '../objects'; import { PluginStateObject as SO } from '../objects'; -import { Task } from '../../../mol-task'; -import { CIF } from '../../../mol-io/reader/cif' -import { PluginContext } from '../../../mol-plugin/context'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; -import { StateTransformer } from '../../../mol-state'; -import { readFromFile, ajaxGetMany } from '../../../mol-util/data-source'; -import * as CCP4 from '../../../mol-io/reader/ccp4/parser' -import * as DSN6 from '../../../mol-io/reader/dsn6/parser' -import * as PLY from '../../../mol-io/reader/ply/parser' -import { parsePsf } from '../../../mol-io/reader/psf/parser'; +import { Task } from '../../mol-task'; +import { CIF } from '../../mol-io/reader/cif' +import { PluginContext } from '../../mol-plugin/context'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; +import { StateTransformer } from '../../mol-state'; +import { readFromFile, ajaxGetMany } from '../../mol-util/data-source'; +import * as CCP4 from '../../mol-io/reader/ccp4/parser' +import * as DSN6 from '../../mol-io/reader/dsn6/parser' +import * as PLY from '../../mol-io/reader/ply/parser' +import { parsePsf } from '../../mol-io/reader/psf/parser'; export { Download } type Download = typeof Download diff --git a/src/mol-plugin/state/transforms/helpers.ts b/src/mol-plugin-state/transforms/helpers.ts similarity index 81% rename from src/mol-plugin/state/transforms/helpers.ts rename to src/mol-plugin-state/transforms/helpers.ts index 91c2a804a..f2732fd75 100644 --- a/src/mol-plugin/state/transforms/helpers.ts +++ b/src/mol-plugin-state/transforms/helpers.ts @@ -5,11 +5,11 @@ */ import { PluginStateObject } from '../objects'; -import { DistanceData } from '../../../mol-repr/shape/loci/distance'; -import { LabelData } from '../../../mol-repr/shape/loci/label'; -import { OrientationData } from '../../../mol-repr/shape/loci/orientation'; -import { AngleData } from '../../../mol-repr/shape/loci/angle'; -import { DihedralData } from '../../../mol-repr/shape/loci/dihedral'; +import { DistanceData } from '../../mol-repr/shape/loci/distance'; +import { LabelData } from '../../mol-repr/shape/loci/label'; +import { OrientationData } from '../../mol-repr/shape/loci/orientation'; +import { AngleData } from '../../mol-repr/shape/loci/angle'; +import { DihedralData } from '../../mol-repr/shape/loci/dihedral'; export function getDistanceDataFromStructureSelections(s: ReadonlyArray<PluginStateObject.Molecule.Structure.SelectionEntry>): DistanceData { const lociA = s[0].loci diff --git a/src/mol-plugin/state/transforms/misc.ts b/src/mol-plugin-state/transforms/misc.ts similarity index 83% rename from src/mol-plugin/state/transforms/misc.ts rename to src/mol-plugin-state/transforms/misc.ts index c5b72fcf4..9fcb4ef7a 100644 --- a/src/mol-plugin/state/transforms/misc.ts +++ b/src/mol-plugin-state/transforms/misc.ts @@ -4,9 +4,9 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { StateTransformer } from '../../../mol-state'; -import { shallowEqualObjects } from '../../../mol-util'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { StateTransformer } from '../../mol-state'; +import { shallowEqualObjects } from '../../mol-util'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { PluginStateObject as SO, PluginStateTransform } from '../objects'; export { CreateGroup }; diff --git a/src/mol-plugin/state/transforms/model.ts b/src/mol-plugin-state/transforms/model.ts similarity index 95% rename from src/mol-plugin/state/transforms/model.ts rename to src/mol-plugin-state/transforms/model.ts index bb25ec0f9..2d30fde12 100644 --- a/src/mol-plugin/state/transforms/model.ts +++ b/src/mol-plugin-state/transforms/model.ts @@ -5,32 +5,32 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { parsePDB } from '../../../mol-io/reader/pdb/parser'; -import { Vec3, Mat4, Quat } from '../../../mol-math/linear-algebra'; -import { trajectoryFromMmCIF } from '../../../mol-model-formats/structure/mmcif'; -import { trajectoryFromPDB } from '../../../mol-model-formats/structure/pdb'; -import { Model, Queries, QueryContext, Structure, StructureQuery, StructureSelection as Sel, StructureElement, Coordinates, Topology } from '../../../mol-model/structure'; -import { PluginContext } from '../../../mol-plugin/context'; -import { MolScriptBuilder } from '../../../mol-script/language/builder'; -import Expression from '../../../mol-script/language/expression'; -import { StateObject, StateTransformer } from '../../../mol-state'; -import { RuntimeContext, Task } from '../../../mol-task'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { parsePDB } from '../../mol-io/reader/pdb/parser'; +import { Vec3, Mat4, Quat } from '../../mol-math/linear-algebra'; +import { trajectoryFromMmCIF } from '../../mol-model-formats/structure/mmcif'; +import { trajectoryFromPDB } from '../../mol-model-formats/structure/pdb'; +import { Model, Queries, QueryContext, Structure, StructureQuery, StructureSelection as Sel, StructureElement, Coordinates, Topology } from '../../mol-model/structure'; +import { PluginContext } from '../../mol-plugin/context'; +import { MolScriptBuilder } from '../../mol-script/language/builder'; +import Expression from '../../mol-script/language/expression'; +import { StateObject, StateTransformer } from '../../mol-state'; +import { RuntimeContext, Task } from '../../mol-task'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { PluginStateObject as SO, PluginStateTransform } from '../objects'; -import { trajectoryFromGRO } from '../../../mol-model-formats/structure/gro'; -import { parseGRO } from '../../../mol-io/reader/gro/parser'; -import { shapeFromPly } from '../../../mol-model-formats/shape/ply'; -import { SymmetryOperator } from '../../../mol-math/geometry'; -import { Script } from '../../../mol-script/script'; -import { parse3DG } from '../../../mol-io/reader/3dg/parser'; -import { trajectoryFrom3DG } from '../../../mol-model-formats/structure/3dg'; -import { StructureSelectionQueries } from '../../util/structure-selection-helper'; -import { StructureQueryHelper } from '../../util/structure-query'; +import { trajectoryFromGRO } from '../../mol-model-formats/structure/gro'; +import { parseGRO } from '../../mol-io/reader/gro/parser'; +import { shapeFromPly } from '../../mol-model-formats/shape/ply'; +import { SymmetryOperator } from '../../mol-math/geometry'; +import { Script } from '../../mol-script/script'; +import { parse3DG } from '../../mol-io/reader/3dg/parser'; +import { trajectoryFrom3DG } from '../../mol-model-formats/structure/3dg'; +import { StructureSelectionQueries } from '../../mol-plugin/util/structure-selection-helper'; +import { StructureQueryHelper } from '../../mol-plugin/util/structure-query'; import { ModelStructureRepresentation } from '../representation/model'; -import { parseDcd } from '../../../mol-io/reader/dcd/parser'; -import { coordinatesFromDcd } from '../../../mol-model-formats/structure/dcd'; -import { topologyFromPsf } from '../../../mol-model-formats/structure/psf'; -import { deepEqual } from '../../../mol-util'; +import { parseDcd } from '../../mol-io/reader/dcd/parser'; +import { coordinatesFromDcd } from '../../mol-model-formats/structure/dcd'; +import { topologyFromPsf } from '../../mol-model-formats/structure/psf'; +import { deepEqual } from '../../mol-util'; export { CoordinatesFromDcd }; export { TopologyFromPsf }; diff --git a/src/mol-plugin/state/transforms/representation.ts b/src/mol-plugin-state/transforms/representation.ts similarity index 95% rename from src/mol-plugin/state/transforms/representation.ts rename to src/mol-plugin-state/transforms/representation.ts index 263060eaa..2db719667 100644 --- a/src/mol-plugin/state/transforms/representation.ts +++ b/src/mol-plugin-state/transforms/representation.ts @@ -5,38 +5,38 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { Structure, StructureElement } from '../../../mol-model/structure'; -import { VolumeData, VolumeIsoValue } from '../../../mol-model/volume'; -import { PluginContext } from '../../../mol-plugin/context'; -import { RepresentationProvider } from '../../../mol-repr/representation'; -import { BuiltInStructureRepresentationsName } from '../../../mol-repr/structure/registry'; -import { StructureParams } from '../../../mol-repr/structure/representation'; -import { BuiltInVolumeRepresentationsName } from '../../../mol-repr/volume/registry'; -import { VolumeParams } from '../../../mol-repr/volume/representation'; -import { StateTransformer, StateObject } from '../../../mol-state'; -import { Task } from '../../../mol-task'; -import { BuiltInColorThemeName, ColorTheme, BuiltInColorThemes } from '../../../mol-theme/color'; -import { BuiltInSizeThemeName, SizeTheme } from '../../../mol-theme/size'; -import { Theme, ThemeRegistryContext } from '../../../mol-theme/theme'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { Structure, StructureElement } from '../../mol-model/structure'; +import { VolumeData, VolumeIsoValue } from '../../mol-model/volume'; +import { PluginContext } from '../../mol-plugin/context'; +import { RepresentationProvider } from '../../mol-repr/representation'; +import { BuiltInStructureRepresentationsName } from '../../mol-repr/structure/registry'; +import { StructureParams } from '../../mol-repr/structure/representation'; +import { BuiltInVolumeRepresentationsName } from '../../mol-repr/volume/registry'; +import { VolumeParams } from '../../mol-repr/volume/representation'; +import { StateTransformer, StateObject } from '../../mol-state'; +import { Task } from '../../mol-task'; +import { BuiltInColorThemeName, ColorTheme, BuiltInColorThemes } from '../../mol-theme/color'; +import { BuiltInSizeThemeName, SizeTheme } from '../../mol-theme/size'; +import { Theme, ThemeRegistryContext } from '../../mol-theme/theme'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { PluginStateObject as SO, PluginStateTransform } from '../objects'; -import { ColorNames } from '../../../mol-util/color/names'; -import { ShapeRepresentation } from '../../../mol-repr/shape/representation'; -import { StructureUnitTransforms } from '../../../mol-model/structure/structure/util/unit-transforms'; +import { ColorNames } from '../../mol-util/color/names'; +import { ShapeRepresentation } from '../../mol-repr/shape/representation'; +import { StructureUnitTransforms } from '../../mol-model/structure/structure/util/unit-transforms'; import { unwindStructureAssembly, explodeStructure } from '../animation/helpers'; -import { Color } from '../../../mol-util/color'; -import { Overpaint } from '../../../mol-theme/overpaint'; -import { Transparency } from '../../../mol-theme/transparency'; -import { BaseGeometry } from '../../../mol-geo/geometry/base'; -import { Script } from '../../../mol-script/script'; -import { getUnitcellRepresentation, UnitcellParams } from '../../util/model-unitcell'; -import { DistanceParams, DistanceRepresentation } from '../../../mol-repr/shape/loci/distance'; +import { Color } from '../../mol-util/color'; +import { Overpaint } from '../../mol-theme/overpaint'; +import { Transparency } from '../../mol-theme/transparency'; +import { BaseGeometry } from '../../mol-geo/geometry/base'; +import { Script } from '../../mol-script/script'; +import { getUnitcellRepresentation, UnitcellParams } from '../../mol-plugin/util/model-unitcell'; +import { DistanceParams, DistanceRepresentation } from '../../mol-repr/shape/loci/distance'; import { getDistanceDataFromStructureSelections, getLabelDataFromStructureSelections, getOrientationDataFromStructureSelections, getAngleDataFromStructureSelections, getDihedralDataFromStructureSelections } from './helpers'; -import { LabelParams, LabelRepresentation } from '../../../mol-repr/shape/loci/label'; -import { OrientationRepresentation, OrientationParams } from '../../../mol-repr/shape/loci/orientation'; -import { AngleParams, AngleRepresentation } from '../../../mol-repr/shape/loci/angle'; -import { DihedralParams, DihedralRepresentation } from '../../../mol-repr/shape/loci/dihedral'; -import { ModelSymmetry } from '../../../mol-model-formats/structure/property/symmetry'; +import { LabelParams, LabelRepresentation } from '../../mol-repr/shape/loci/label'; +import { OrientationRepresentation, OrientationParams } from '../../mol-repr/shape/loci/orientation'; +import { AngleParams, AngleRepresentation } from '../../mol-repr/shape/loci/angle'; +import { DihedralParams, DihedralRepresentation } from '../../mol-repr/shape/loci/dihedral'; +import { ModelSymmetry } from '../../mol-model-formats/structure/property/symmetry'; export { StructureRepresentation3D } export { StructureRepresentation3DHelpers } diff --git a/src/mol-plugin/state/transforms/volume.ts b/src/mol-plugin-state/transforms/volume.ts similarity index 88% rename from src/mol-plugin/state/transforms/volume.ts rename to src/mol-plugin-state/transforms/volume.ts index 351d7ff37..f63aa54d3 100644 --- a/src/mol-plugin/state/transforms/volume.ts +++ b/src/mol-plugin-state/transforms/volume.ts @@ -5,13 +5,13 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { CIF } from '../../../mol-io/reader/cif'; -import { Vec3 } from '../../../mol-math/linear-algebra'; -import { volumeFromCcp4 } from '../../../mol-model-formats/volume/ccp4'; -import { volumeFromDensityServerData } from '../../../mol-model-formats/volume/density-server'; -import { volumeFromDsn6 } from '../../../mol-model-formats/volume/dsn6'; -import { Task } from '../../../mol-task'; -import { ParamDefinition as PD } from '../../../mol-util/param-definition'; +import { CIF } from '../../mol-io/reader/cif'; +import { Vec3 } from '../../mol-math/linear-algebra'; +import { volumeFromCcp4 } from '../../mol-model-formats/volume/ccp4'; +import { volumeFromDensityServerData } from '../../mol-model-formats/volume/density-server'; +import { volumeFromDsn6 } from '../../mol-model-formats/volume/dsn6'; +import { Task } from '../../mol-task'; +import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { PluginStateObject as SO, PluginStateTransform } from '../objects'; export { VolumeFromCcp4 }; diff --git a/src/mol-plugin-ui/camera.tsx b/src/mol-plugin-ui/camera.tsx index e1b9a0a85..e41f9819e 100644 --- a/src/mol-plugin-ui/camera.tsx +++ b/src/mol-plugin-ui/camera.tsx @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginCommands } from '../mol-plugin/command'; +import { PluginCommands } from '../mol-plugin/commands'; import * as React from 'react'; import { PluginUIComponent } from './base'; import { ParamDefinition as PD } from '../mol-util/param-definition'; @@ -29,12 +29,12 @@ class CameraSnapshotControls extends PluginUIComponent<{ }, { name: string, desc state = PD.getDefaultValues(CameraSnapshotControls.Params); add = () => { - PluginCommands.Camera.Snapshots.Add.dispatch(this.plugin, this.state); + PluginCommands.Camera.Snapshots.Add(this.plugin, this.state); this.setState({ name: '', description: '' }) } clear = () => { - PluginCommands.Camera.Snapshots.Clear.dispatch(this.plugin, {}); + PluginCommands.Camera.Snapshots.Clear(this.plugin, {}); } render() { @@ -55,12 +55,12 @@ class CameraSnapshotList extends PluginUIComponent<{ }, { }> { } apply(id: string) { - return () => PluginCommands.Camera.Snapshots.Apply.dispatch(this.plugin, { id }); + return () => PluginCommands.Camera.Snapshots.Apply(this.plugin, { id }); } remove(id: string) { return () => { - PluginCommands.Camera.Snapshots.Remove.dispatch(this.plugin, { id }); + PluginCommands.Camera.Snapshots.Remove(this.plugin, { id }); } } diff --git a/src/mol-plugin-ui/controls.tsx b/src/mol-plugin-ui/controls.tsx index 147b9c8d2..2e27e3dfe 100644 --- a/src/mol-plugin-ui/controls.tsx +++ b/src/mol-plugin-ui/controls.tsx @@ -6,15 +6,15 @@ */ import * as React from 'react'; -import { PluginCommands } from '../mol-plugin/command'; -import { UpdateTrajectory } from '../mol-plugin/state/actions/structure'; +import { PluginCommands } from '../mol-plugin/commands'; +import { UpdateTrajectory } from '../mol-plugin-state/actions/structure'; import { PluginUIComponent } from './base'; import { LociLabelEntry } from '../mol-plugin/util/loci-label-manager'; import { IconButton, Icon } from './controls/common'; -import { PluginStateObject } from '../mol-plugin/state/objects'; -import { StateTransforms } from '../mol-plugin/state/transforms'; +import { PluginStateObject } from '../mol-plugin-state/objects'; +import { StateTransforms } from '../mol-plugin-state/transforms'; import { StateTransformer } from '../mol-state'; -import { ModelFromTrajectory } from '../mol-plugin/state/transforms/model'; +import { ModelFromTrajectory } from '../mol-plugin-state/transforms/model'; import { AnimationControls } from './state/animation'; import { StructureRepresentationControls } from './structure/representation'; import { StructureSelectionControls } from './structure/selection'; @@ -62,17 +62,17 @@ export class TrajectoryViewportControls extends PluginUIComponent<{}, { show: bo this.subscribe(this.plugin.behaviors.state.isAnimating, this.update); } - reset = () => PluginCommands.State.ApplyAction.dispatch(this.plugin, { + reset = () => PluginCommands.State.ApplyAction(this.plugin, { state: this.plugin.state.dataState, action: UpdateTrajectory.create({ action: 'reset' }) }); - prev = () => PluginCommands.State.ApplyAction.dispatch(this.plugin, { + prev = () => PluginCommands.State.ApplyAction(this.plugin, { state: this.plugin.state.dataState, action: UpdateTrajectory.create({ action: 'advance', by: -1 }) }); - next = () => PluginCommands.State.ApplyAction.dispatch(this.plugin, { + next = () => PluginCommands.State.ApplyAction(this.plugin, { state: this.plugin.state.dataState, action: UpdateTrajectory.create({ action: 'advance', by: 1 }) }); @@ -146,7 +146,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus async update(id: string) { this.setState({ isBusy: true }); - await PluginCommands.State.Snapshots.Apply.dispatch(this.plugin, { id }); + await PluginCommands.State.Snapshots.Apply(this.plugin, { id }); this.setState({ isBusy: false }); } diff --git a/src/mol-plugin-ui/left-panel.tsx b/src/mol-plugin-ui/left-panel.tsx index 25a962f15..9a4dd3dee 100644 --- a/src/mol-plugin-ui/left-panel.tsx +++ b/src/mol-plugin-ui/left-panel.tsx @@ -10,7 +10,7 @@ import { StateTree } from './state/tree'; import { IconButton, SectionHeader } from './controls/common'; import { StateObjectActions } from './state/actions'; import { StateTransform } from '../mol-state'; -import { PluginCommands } from '../mol-plugin/command'; +import { PluginCommands } from '../mol-plugin/commands'; import { ParameterControls } from './controls/parameters'; import { Canvas3DParams } from '../mol-canvas3d/canvas3d'; import { ParamDefinition as PD } from '../mol-util/param-definition'; @@ -35,7 +35,7 @@ export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTab set = (tab: LeftPanelTabName) => { if (this.state.tab === tab) { this.setState({ tab: 'none' }, () => this.plugin.behaviors.layout.leftPanelTabName.next('none')); - PluginCommands.Layout.Update.dispatch(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: 'collapsed' } } }); + PluginCommands.Layout.Update(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: 'collapsed' } } }); return; } @@ -46,7 +46,7 @@ export class LeftPanelControls extends PluginUIComponent<{}, { tab: LeftPanelTab this.setState({ tab }, () => this.plugin.behaviors.layout.leftPanelTabName.next(tab)); if (this.plugin.layout.state.regionState.left !== 'full') { - PluginCommands.Layout.Update.dispatch(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: 'full' } } }); + PluginCommands.Layout.Update(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: 'full' } } }); } } @@ -121,7 +121,7 @@ class DataIcon extends PluginUIComponent<{ set: (tab: LeftPanelTabName) => void class FullSettings extends PluginUIComponent { private setSettings = (p: { param: PD.Base<any>, name: string, value: any }) => { - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { [p.name]: p.value } }); + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { [p.name]: p.value } }); } componentDidMount() { @@ -159,7 +159,7 @@ export class RemoveAllButton extends PluginUIComponent<{ }> { remove = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.RemoveObject.dispatch(this.plugin, { state: this.plugin.state.dataState, ref: StateTransform.RootRef }); + PluginCommands.State.RemoveObject(this.plugin, { state: this.plugin.state.dataState, ref: StateTransform.RootRef }); } render() { diff --git a/src/mol-plugin-ui/sequence.tsx b/src/mol-plugin-ui/sequence.tsx index f89f119ee..43ad47c02 100644 --- a/src/mol-plugin-ui/sequence.tsx +++ b/src/mol-plugin-ui/sequence.tsx @@ -7,7 +7,7 @@ import * as React from 'react' import { PluginUIComponent } from './base'; -import { PluginStateObject as PSO } from '../mol-plugin/state/objects'; +import { PluginStateObject as PSO } from '../mol-plugin-state/objects'; import { Sequence } from './sequence/sequence'; import { Structure, StructureElement, StructureProperties as SP, Unit } from '../mol-model/structure'; import { SequenceWrapper } from './sequence/wrapper'; diff --git a/src/mol-plugin-ui/state/apply-action.tsx b/src/mol-plugin-ui/state/apply-action.tsx index d95015060..f11496425 100644 --- a/src/mol-plugin-ui/state/apply-action.tsx +++ b/src/mol-plugin-ui/state/apply-action.tsx @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import { PluginContext } from '../../mol-plugin/context'; import { State, StateTransform, StateAction } from '../../mol-state'; import { memoizeLatest } from '../../mol-util/memoize'; @@ -35,7 +35,7 @@ namespace ApplyActionControl { class ApplyActionControl extends TransformControlBase<ApplyActionControl.Props, ApplyActionControl.ComponentState> { applyAction() { - return PluginCommands.State.ApplyAction.dispatch(this.plugin, { + return PluginCommands.State.ApplyAction(this.plugin, { state: this.props.state, action: this.props.action.create(this.state.params), ref: this.props.nodeRef diff --git a/src/mol-plugin-ui/state/snapshots.tsx b/src/mol-plugin-ui/state/snapshots.tsx index 6a0e3693f..19fa456dd 100644 --- a/src/mol-plugin-ui/state/snapshots.tsx +++ b/src/mol-plugin-ui/state/snapshots.tsx @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import * as React from 'react'; import { PluginUIComponent, PurePluginUIComponent } from '../base'; import { shallowEqualObjects } from '../../mol-util'; @@ -19,13 +19,13 @@ import { PluginConfig } from '../../mol-plugin/config'; export class StateSnapshots extends PluginUIComponent<{ }> { downloadToFile = () => { - PluginCommands.State.Snapshots.DownloadToFile.dispatch(this.plugin, { }); + PluginCommands.State.Snapshots.DownloadToFile(this.plugin, { }); } open = (e: React.ChangeEvent<HTMLInputElement>) => { if (!e.target.files || !e.target.files![0]) return; - PluginCommands.State.Snapshots.OpenFile.dispatch(this.plugin, { file: e.target.files![0] }); + PluginCommands.State.Snapshots.OpenFile(this.plugin, { file: e.target.files![0] }); } render() { @@ -60,7 +60,7 @@ class LocalStateSnapshots extends PluginUIComponent< }; add = () => { - PluginCommands.State.Snapshots.Add.dispatch(this.plugin, { + PluginCommands.State.Snapshots.Add(this.plugin, { name: this.state.params.name, description: this.state.params.options.description, params: this.state.params.options @@ -77,7 +77,7 @@ class LocalStateSnapshots extends PluginUIComponent< } clear = () => { - PluginCommands.State.Snapshots.Clear.dispatch(this.plugin, {}); + PluginCommands.State.Snapshots.Clear(this.plugin, {}); } shouldComponentUpdate(nextProps: any, nextState: any) { @@ -111,31 +111,31 @@ class LocalStateSnapshotList extends PluginUIComponent<{ }, { }> { apply = (e: React.MouseEvent<HTMLElement>) => { const id = e.currentTarget.getAttribute('data-id'); if (!id) return; - PluginCommands.State.Snapshots.Apply.dispatch(this.plugin, { id }); + PluginCommands.State.Snapshots.Apply(this.plugin, { id }); } remove = (e: React.MouseEvent<HTMLElement>) => { const id = e.currentTarget.getAttribute('data-id'); if (!id) return; - PluginCommands.State.Snapshots.Remove.dispatch(this.plugin, { id }); + PluginCommands.State.Snapshots.Remove(this.plugin, { id }); } moveUp = (e: React.MouseEvent<HTMLElement>) => { const id = e.currentTarget.getAttribute('data-id'); if (!id) return; - PluginCommands.State.Snapshots.Move.dispatch(this.plugin, { id, dir: -1 }); + PluginCommands.State.Snapshots.Move(this.plugin, { id, dir: -1 }); } moveDown = (e: React.MouseEvent<HTMLElement>) => { const id = e.currentTarget.getAttribute('data-id'); if (!id) return; - PluginCommands.State.Snapshots.Move.dispatch(this.plugin, { id, dir: 1 }); + PluginCommands.State.Snapshots.Move(this.plugin, { id, dir: 1 }); } replace = (e: React.MouseEvent<HTMLElement>) => { const id = e.currentTarget.getAttribute('data-id'); if (!id) return; - PluginCommands.State.Snapshots.Replace.dispatch(this.plugin, { id, params: this.plugin.state.snapshots.currentGetSnapshotParams }); + PluginCommands.State.Snapshots.Replace(this.plugin, { id, params: this.plugin.state.snapshots.currentGetSnapshotParams }); } render() { @@ -224,14 +224,14 @@ export class RemoteStateSnapshots extends PluginUIComponent< this.plugin.config.set(PluginConfig.State.CurrentServer, this.state.params.options.serverUrl); if (this.plugin.state.snapshots.state.entries.size === 0) { - await PluginCommands.State.Snapshots.Add.dispatch(this.plugin, { + await PluginCommands.State.Snapshots.Add(this.plugin, { name: this.state.params.name, description: this.state.params.options.description, params: this.plugin.state.snapshots.currentGetSnapshotParams }); } - await PluginCommands.State.Snapshots.Upload.dispatch(this.plugin, { + await PluginCommands.State.Snapshots.Upload(this.plugin, { name: this.state.params.name, description: this.state.params.options.description, playOnLoad: this.state.params.options.playOnLoad, @@ -250,7 +250,7 @@ export class RemoteStateSnapshots extends PluginUIComponent< this.setState({ isBusy: true }); try { - await PluginCommands.State.Snapshots.Fetch.dispatch(this.plugin, { url: entry.url }); + await PluginCommands.State.Snapshots.Fetch(this.plugin, { url: entry.url }); } finally { this.setState({ isBusy: false }); } diff --git a/src/mol-plugin-ui/state/tree.tsx b/src/mol-plugin-ui/state/tree.tsx index 90ddb4335..ea2cd2712 100644 --- a/src/mol-plugin-ui/state/tree.tsx +++ b/src/mol-plugin-ui/state/tree.tsx @@ -5,9 +5,9 @@ */ import * as React from 'react'; -import { PluginStateObject } from '../../mol-plugin/state/objects'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; import { State, StateObject, StateTransform, StateObjectCell } from '../../mol-state' -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import { PluginUIComponent, _Props, _State } from '../base'; import { Icon } from '../controls/common'; @@ -165,41 +165,41 @@ class StateTreeNodeLabel extends PluginUIComponent< setCurrent = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); e.currentTarget.blur(); - PluginCommands.State.SetCurrentObject.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref }); + PluginCommands.State.SetCurrentObject(this.plugin, { state: this.props.cell.parent, ref: this.ref }); } setCurrentRoot = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); e.currentTarget.blur(); - PluginCommands.State.SetCurrentObject.dispatch(this.plugin, { state: this.props.cell.parent, ref: StateTransform.RootRef }); + PluginCommands.State.SetCurrentObject(this.plugin, { state: this.props.cell.parent, ref: StateTransform.RootRef }); } remove = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.RemoveObject.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref, removeParentGhosts: true }); + PluginCommands.State.RemoveObject(this.plugin, { state: this.props.cell.parent, ref: this.ref, removeParentGhosts: true }); } toggleVisible = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.ToggleVisibility.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref }); + PluginCommands.State.ToggleVisibility(this.plugin, { state: this.props.cell.parent, ref: this.ref }); e.currentTarget.blur(); } toggleExpanded = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.ToggleExpanded.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref }); + PluginCommands.State.ToggleExpanded(this.plugin, { state: this.props.cell.parent, ref: this.ref }); e.currentTarget.blur(); } highlight = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.Highlight.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref }); + PluginCommands.State.Highlight(this.plugin, { state: this.props.cell.parent, ref: this.ref }); e.currentTarget.blur(); } clearHighlight = (e: React.MouseEvent<HTMLElement>) => { e.preventDefault(); - PluginCommands.State.ClearHighlight.dispatch(this.plugin, { state: this.props.cell.parent, ref: this.ref }); + PluginCommands.State.ClearHighlight(this.plugin, { state: this.props.cell.parent, ref: this.ref }); e.currentTarget.blur(); } diff --git a/src/mol-plugin-ui/structure/representation.tsx b/src/mol-plugin-ui/structure/representation.tsx index bef7495ba..558f7c1f5 100644 --- a/src/mol-plugin-ui/structure/representation.tsx +++ b/src/mol-plugin-ui/structure/representation.tsx @@ -15,7 +15,7 @@ import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { VisualQuality, VisualQualityOptions } from '../../mol-geo/geometry/base'; import { CollapsableControls } from '../base'; import { StateSelection, StateObject } from '../../mol-state'; -import { PluginStateObject } from '../../mol-plugin/state/objects'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; import { ColorOptions } from '../controls/color'; interface BaseStructureRepresentationControlsState { diff --git a/src/mol-plugin-ui/structure/selection.tsx b/src/mol-plugin-ui/structure/selection.tsx index f7e380a84..76225830a 100644 --- a/src/mol-plugin-ui/structure/selection.tsx +++ b/src/mol-plugin-ui/structure/selection.tsx @@ -8,7 +8,7 @@ import * as React from 'react'; import { CollapsableControls, CollapsableState } from '../base'; import { StructureSelectionQuery, SelectionModifier, StructureSelectionQueryList } from '../../mol-plugin/util/structure-selection-helper'; -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { Interactivity } from '../../mol-plugin/util/interactivity'; import { ParameterControls } from '../controls/parameters'; @@ -107,7 +107,7 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS setProps = (p: { param: PD.Base<any>, name: string, value: any }) => { if (p.name === 'granularity') { - PluginCommands.Interactivity.SetProps.dispatch(this.plugin, { props: { granularity: p.value } }); + PluginCommands.Interactivity.SetProps(this.plugin, { props: { granularity: p.value } }); } } diff --git a/src/mol-plugin-ui/toast.tsx b/src/mol-plugin-ui/toast.tsx index ff5384d0f..b212603af 100644 --- a/src/mol-plugin-ui/toast.tsx +++ b/src/mol-plugin-ui/toast.tsx @@ -8,7 +8,7 @@ import * as React from 'react'; import { PluginUIComponent } from './base'; -import { PluginToastManager } from '../mol-plugin/state/toast'; +import { PluginToastManager } from '../mol-plugin/util/toast'; import { IconButton } from './controls/common'; class ToastEntry extends PluginUIComponent<{ entry: PluginToastManager.Entry }> { diff --git a/src/mol-plugin-ui/viewport.tsx b/src/mol-plugin-ui/viewport.tsx index a4bb8ee2c..eb61eebb4 100644 --- a/src/mol-plugin-ui/viewport.tsx +++ b/src/mol-plugin-ui/viewport.tsx @@ -7,7 +7,7 @@ import * as React from 'react'; import { resizeCanvas } from '../mol-canvas3d/util'; -import { PluginCommands } from '../mol-plugin/command'; +import { PluginCommands } from '../mol-plugin/commands'; import { ParamDefinition as PD } from '../mol-util/param-definition'; import { PluginUIComponent } from './base'; import { ControlGroup, IconButton } from './controls/common'; @@ -31,7 +31,7 @@ export class ViewportControls extends PluginUIComponent<ViewportControlsProps, V state = { ...this.allCollapsedState } as ViewportControlsState; resetCamera = () => { - PluginCommands.Camera.Reset.dispatch(this.plugin, {}); + PluginCommands.Camera.Reset(this.plugin, {}); } private toggle(panel: keyof ViewportControlsState) { @@ -45,23 +45,23 @@ export class ViewportControls extends PluginUIComponent<ViewportControlsProps, V toggleScreenshotExpanded = this.toggle('isScreenshotExpanded'); toggleControls = () => { - PluginCommands.Layout.Update.dispatch(this.plugin, { state: { showControls: !this.plugin.layout.state.showControls } }); + PluginCommands.Layout.Update(this.plugin, { state: { showControls: !this.plugin.layout.state.showControls } }); } toggleExpanded = () => { - PluginCommands.Layout.Update.dispatch(this.plugin, { state: { isExpanded: !this.plugin.layout.state.isExpanded } }); + PluginCommands.Layout.Update(this.plugin, { state: { isExpanded: !this.plugin.layout.state.isExpanded } }); } setSettings = (p: { param: PD.Base<any>, name: string, value: any }) => { - PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: { [p.name]: p.value } }); + PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: { [p.name]: p.value } }); } setLayout = (p: { param: PD.Base<any>, name: string, value: any }) => { - PluginCommands.Layout.Update.dispatch(this.plugin, { state: { [p.name]: p.value } }); + PluginCommands.Layout.Update(this.plugin, { state: { [p.name]: p.value } }); } setInteractivityProps = (p: { param: PD.Base<any>, name: string, value: any }) => { - PluginCommands.Interactivity.SetProps.dispatch(this.plugin, { props: { [p.name]: p.value } }); + PluginCommands.Interactivity.SetProps(this.plugin, { props: { [p.name]: p.value } }); } screenshot = () => { diff --git a/src/mol-plugin-ui/viewport/simple-settings.tsx b/src/mol-plugin-ui/viewport/simple-settings.tsx index 11c6b703f..e25a9e30c 100644 --- a/src/mol-plugin-ui/viewport/simple-settings.tsx +++ b/src/mol-plugin-ui/viewport/simple-settings.tsx @@ -7,7 +7,7 @@ import * as React from 'react'; import { Canvas3DParams } from '../../mol-canvas3d/canvas3d'; -import { PluginCommands } from '../../mol-plugin/command'; +import { PluginCommands } from '../../mol-plugin/commands'; import { ColorNames } from '../../mol-util/color/names'; import { ParameterMappingControl } from '../controls/parameters'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; @@ -97,6 +97,6 @@ const SimpleSettingsMapping = ParamMapping({ t.cameraClipFar = s.clipFar; }, apply(settings, ctx) { - return PluginCommands.Canvas3D.SetSettings.dispatch(ctx, { settings }); + return PluginCommands.Canvas3D.SetSettings(ctx, { settings }); } }) \ No newline at end of file diff --git a/src/mol-plugin/behavior/behavior.ts b/src/mol-plugin/behavior/behavior.ts index 34e088366..7313f5680 100644 --- a/src/mol-plugin/behavior/behavior.ts +++ b/src/mol-plugin/behavior/behavior.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginStateTransform, PluginStateObject } from '../state/objects'; +import { PluginStateTransform, PluginStateObject } from '../../mol-plugin-state/objects'; import { StateTransformer, StateTransform } from '../../mol-state'; import { Task } from '../../mol-task'; import { PluginContext } from '../../mol-plugin/context'; diff --git a/src/mol-plugin/behavior/dynamic/camera.ts b/src/mol-plugin/behavior/dynamic/camera.ts index ecf921484..5ae44bebd 100644 --- a/src/mol-plugin/behavior/dynamic/camera.ts +++ b/src/mol-plugin/behavior/dynamic/camera.ts @@ -10,7 +10,7 @@ import { ParamDefinition as PD } from '../../../mol-util/param-definition'; import { PluginBehavior } from '../behavior'; import { ButtonsType, ModifiersKeys } from '../../../mol-util/input/input-observer'; import { Binding } from '../../../mol-util/binding'; -import { PluginCommands } from '../../command'; +import { PluginCommands } from '../../commands'; const B = ButtonsType const M = ModifiersKeys @@ -42,7 +42,7 @@ export const FocusLoci = PluginBehavior.create<FocusLociProps>({ if (Binding.match(this.params.bindings.clickCenterFocus, button, modifiers)) { const loci = Loci.normalize(current.loci, this.ctx.interactivity.props.granularity) if (Loci.isEmpty(loci)) { - PluginCommands.Camera.Reset.dispatch(this.ctx, { }) + PluginCommands.Camera.Reset(this.ctx, { }) } else { const sphere = Loci.getBoundingSphere(loci); if (sphere) { diff --git a/src/mol-plugin/behavior/dynamic/custom-props/computed/interactions.ts b/src/mol-plugin/behavior/dynamic/custom-props/computed/interactions.ts index 58f9290c2..94b648cf3 100644 --- a/src/mol-plugin/behavior/dynamic/custom-props/computed/interactions.ts +++ b/src/mol-plugin/behavior/dynamic/custom-props/computed/interactions.ts @@ -9,7 +9,7 @@ import { ParamDefinition as PD } from '../../../../../mol-util/param-definition' import { InteractionsProvider } from '../../../../../mol-model-props/computed/interactions'; import { Structure } from '../../../../../mol-model/structure'; import { StateSelection } from '../../../../../mol-state'; -import { PluginStateObject } from '../../../../state/objects'; +import { PluginStateObject } from '../../../../../mol-plugin-state/objects'; import StructureElement from '../../../../../mol-model/structure/structure/element'; import { OrderedSet } from '../../../../../mol-data/int'; import { featureGroupLabel, featureTypeLabel } from '../../../../../mol-model-props/computed/interactions/common'; diff --git a/src/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.ts b/src/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.ts index 129c3d688..8b83454d2 100644 --- a/src/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.ts +++ b/src/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.ts @@ -8,7 +8,7 @@ import { PluginBehavior } from '../../../behavior'; import { ParamDefinition as PD } from '../../../../../mol-util/param-definition'; import { ValenceModelProvider } from '../../../../../mol-model-props/computed/valence-model'; import { Loci } from '../../../../../mol-model/loci'; -import { PluginStateObject } from '../../../../state/objects'; +import { PluginStateObject } from '../../../../../mol-plugin-state/objects'; import { StateSelection } from '../../../../../mol-state'; import { Structure, StructureElement } from '../../../../../mol-model/structure'; import { OrderedSet } from '../../../../../mol-data/int'; diff --git a/src/mol-plugin/behavior/dynamic/custom-props/rcsb/assembly-symmetry.ts b/src/mol-plugin/behavior/dynamic/custom-props/rcsb/assembly-symmetry.ts index 32aeba1bd..dd666747d 100644 --- a/src/mol-plugin/behavior/dynamic/custom-props/rcsb/assembly-symmetry.ts +++ b/src/mol-plugin/behavior/dynamic/custom-props/rcsb/assembly-symmetry.ts @@ -9,7 +9,7 @@ import { AssemblySymmetryProvider, AssemblySymmetry, getSymmetrySelectParam } fr import { PluginBehavior } from '../../../behavior'; import { AssemblySymmetryParams, AssemblySymmetryRepresentation } from '../../../../../mol-model-props/rcsb/representations/assembly-symmetry'; import { AssemblySymmetryClusterColorThemeProvider } from '../../../../../mol-model-props/rcsb/themes/assembly-symmetry-cluster'; -import { PluginStateTransform, PluginStateObject } from '../../../../state/objects'; +import { PluginStateTransform, PluginStateObject } from '../../../../../mol-plugin-state/objects'; import { Task } from '../../../../../mol-task'; import { PluginContext } from '../../../../context'; import { StateTransformer, StateAction, StateObject } from '../../../../../mol-state'; diff --git a/src/mol-plugin/behavior/dynamic/representation.ts b/src/mol-plugin/behavior/dynamic/representation.ts index e945aeab6..13ba8e91f 100644 --- a/src/mol-plugin/behavior/dynamic/representation.ts +++ b/src/mol-plugin/behavior/dynamic/representation.ts @@ -7,7 +7,7 @@ import { MarkerAction } from '../../../mol-util/marker-action'; import { PluginContext } from '../../../mol-plugin/context'; -import { PluginStateObject as SO } from '../../state/objects'; +import { PluginStateObject as SO } from '../../../mol-plugin-state/objects'; import { lociLabel } from '../../../mol-theme/label'; import { PluginBehavior } from '../behavior'; import { Interactivity } from '../../util/interactivity'; diff --git a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts b/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts index 06be51d4d..943371c78 100644 --- a/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts +++ b/src/mol-plugin/behavior/dynamic/selection/structure-representation-interaction.ts @@ -7,10 +7,10 @@ import { Structure, StructureElement, Bond } from '../../../../mol-model/structure'; import { PluginBehavior } from '../../../../mol-plugin/behavior'; -import { PluginCommands } from '../../../../mol-plugin/command'; -import { PluginStateObject } from '../../../../mol-plugin/state/objects'; -import { StateTransforms } from '../../../../mol-plugin/state/transforms'; -import { StructureRepresentation3DHelpers } from '../../../../mol-plugin/state/transforms/representation'; +import { PluginCommands } from '../../../commands'; +import { PluginStateObject } from '../../../../mol-plugin-state/objects'; +import { StateTransforms } from '../../../../mol-plugin-state/transforms'; +import { StructureRepresentation3DHelpers } from '../../../../mol-plugin-state/transforms/representation'; import { BuiltInStructureRepresentations } from '../../../../mol-repr/structure/registry'; import { MolScriptBuilder as MS } from '../../../../mol-script/language/builder'; import { StateObjectCell, StateSelection, StateTransform } from '../../../../mol-state'; @@ -129,7 +129,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W if (surr) update.to(surr).update(StateTransforms.Model.StructureSelectionFromExpression, old => ({ ...old, expression })); } - PluginCommands.State.Update.dispatch(this.plugin, { state, tree: update, options: { doNotLogTiming: true, doNotUpdateCurrent: true } }); + PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotLogTiming: true, doNotUpdateCurrent: true } }); } register(ref: string): void { @@ -197,7 +197,7 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W builder.to(refs[Tags.ResidueSel]!).update(StateTransforms.Model.StructureSelectionFromBundle, old => ({ ...old, bundle: residueBundle })); builder.to(refs[Tags.SurrSel]!).update(StateTransforms.Model.StructureSelectionFromExpression, old => ({ ...old, expression: surroundings })); - PluginCommands.State.Update.dispatch(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } }); + PluginCommands.State.Update(this.plugin, { state, tree: builder, options: { doNotLogTiming: true, doNotUpdateCurrent: true } }); } }); } diff --git a/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts b/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts index 85e873d15..2723efd65 100644 --- a/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts +++ b/src/mol-plugin/behavior/dynamic/volume-streaming/behavior.ts @@ -6,7 +6,7 @@ */ import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; -import { PluginStateObject } from '../../../state/objects'; +import { PluginStateObject } from '../../../../mol-plugin-state/objects'; import { VolumeIsoValue, VolumeData } from '../../../../mol-model/volume'; import { createIsoValueParam } from '../../../../mol-repr/volume/isosurface'; import { VolumeServerHeader, VolumeServerInfo } from './model'; @@ -18,7 +18,7 @@ import { LRUCache } from '../../../../mol-util/lru-cache'; import { urlCombine } from '../../../../mol-util/url'; import { CIF } from '../../../../mol-io/reader/cif'; import { volumeFromDensityServerData } from '../../../../mol-model-formats/volume/density-server'; -import { PluginCommands } from '../../../command'; +import { PluginCommands } from '../../../commands'; import { StateSelection } from '../../../../mol-state'; import { Representation } from '../../../../mol-repr/representation'; import { ButtonsType, ModifiersKeys } from '../../../../mol-util/input/input-observer'; @@ -222,7 +222,7 @@ export namespace VolumeStreaming { }; const update = state.build().to(this.ref).update(newParams); - PluginCommands.State.Update.dispatch(this.plugin, { state, tree: update, options: { doNotUpdateCurrent: true } }); + PluginCommands.State.Update(this.plugin, { state, tree: update, options: { doNotUpdateCurrent: true } }); } private getStructureRoot() { diff --git a/src/mol-plugin/behavior/dynamic/volume-streaming/model.ts b/src/mol-plugin/behavior/dynamic/volume-streaming/model.ts index 71a0fac83..59f47b153 100644 --- a/src/mol-plugin/behavior/dynamic/volume-streaming/model.ts +++ b/src/mol-plugin/behavior/dynamic/volume-streaming/model.ts @@ -5,7 +5,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginStateObject } from '../../../state/objects'; +import { PluginStateObject } from '../../../../mol-plugin-state/objects'; import { VolumeIsoValue } from '../../../../mol-model/volume'; import { Structure } from '../../../../mol-model/structure'; diff --git a/src/mol-plugin/behavior/dynamic/volume-streaming/transformers.ts b/src/mol-plugin/behavior/dynamic/volume-streaming/transformers.ts index 20441c88b..8119c4481 100644 --- a/src/mol-plugin/behavior/dynamic/volume-streaming/transformers.ts +++ b/src/mol-plugin/behavior/dynamic/volume-streaming/transformers.ts @@ -5,7 +5,7 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginStateObject as SO, PluginStateTransform } from '../../../state/objects'; +import { PluginStateObject as SO, PluginStateTransform } from '../../../../mol-plugin-state/objects'; import { VolumeServerInfo, VolumeServerHeader } from './model'; import { ParamDefinition as PD } from '../../../../mol-util/param-definition'; import { Task } from '../../../../mol-task'; @@ -16,7 +16,7 @@ import { VolumeIsoValue } from '../../../../mol-model/volume'; import { StateAction, StateObject, StateTransformer } from '../../../../mol-state'; import { getStreamingMethod, getIds, getContourLevel, getEmdbIds } from './util'; import { VolumeStreaming } from './behavior'; -import { VolumeRepresentation3DHelpers } from '../../../../mol-plugin/state/transforms/representation'; +import { VolumeRepresentation3DHelpers } from '../../../../mol-plugin-state/transforms/representation'; import { BuiltInVolumeRepresentations } from '../../../../mol-repr/volume/registry'; import { Theme } from '../../../../mol-theme/theme'; import { Box3D } from '../../../../mol-math/geometry'; diff --git a/src/mol-plugin/behavior/static/camera.ts b/src/mol-plugin/behavior/static/camera.ts index dbe81f4af..755df696f 100644 --- a/src/mol-plugin/behavior/static/camera.ts +++ b/src/mol-plugin/behavior/static/camera.ts @@ -5,8 +5,8 @@ */ import { PluginContext } from '../../../mol-plugin/context'; -import { PluginCommands } from '../../../mol-plugin/command'; -import { CameraSnapshotManager } from '../../../mol-plugin/state/camera'; +import { PluginCommands } from '../../commands'; +import { CameraSnapshotManager } from '../../../mol-plugin-state/camera'; export function registerDefault(ctx: PluginContext) { Reset(ctx); @@ -42,6 +42,6 @@ export function Snapshots(ctx: PluginContext) { PluginCommands.Camera.Snapshots.Apply.subscribe(ctx, ({ id }) => { const e = ctx.state.cameraSnapshots.getEntry(id); - return PluginCommands.Camera.SetSnapshot.dispatch(ctx, { snapshot: e.snapshot, durationMs: 200 }); + return PluginCommands.Camera.SetSnapshot(ctx, { snapshot: e.snapshot, durationMs: 200 }); }); } \ No newline at end of file diff --git a/src/mol-plugin/behavior/static/misc.ts b/src/mol-plugin/behavior/static/misc.ts index a04765107..15c017f56 100644 --- a/src/mol-plugin/behavior/static/misc.ts +++ b/src/mol-plugin/behavior/static/misc.ts @@ -6,7 +6,7 @@ */ import { PluginContext } from '../../../mol-plugin/context'; -import { PluginCommands } from '../../../mol-plugin/command'; +import { PluginCommands } from '../../commands'; export function registerDefault(ctx: PluginContext) { Canvas3DSetSettings(ctx); diff --git a/src/mol-plugin/behavior/static/representation.ts b/src/mol-plugin/behavior/static/representation.ts index 4bc083eda..5b5a68b98 100644 --- a/src/mol-plugin/behavior/static/representation.ts +++ b/src/mol-plugin/behavior/static/representation.ts @@ -4,7 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { PluginStateObject as SO } from '../../state/objects'; +import { PluginStateObject as SO } from '../../../mol-plugin-state/objects'; import { PluginContext } from '../../../mol-plugin/context'; import { Representation } from '../../../mol-repr/representation'; import { StateObjectCell } from '../../../mol-state'; diff --git a/src/mol-plugin/behavior/static/state.ts b/src/mol-plugin/behavior/static/state.ts index bf97de40a..c90d51aa2 100644 --- a/src/mol-plugin/behavior/static/state.ts +++ b/src/mol-plugin/behavior/static/state.ts @@ -5,11 +5,11 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginCommands } from '../../command'; +import { PluginCommands } from '../../commands'; import { PluginContext } from '../../context'; import { StateTree, StateTransform, State } from '../../../mol-state'; -import { PluginStateSnapshotManager } from '../../../mol-plugin/state/snapshots'; -import { PluginStateObject as SO } from '../../state/objects'; +import { PluginStateSnapshotManager } from '../../../mol-plugin-state/snapshots'; +import { PluginStateObject as SO } from '../../../mol-plugin-state/objects'; import { getFormattedTime } from '../../../mol-util/date'; import { readFromFile } from '../../../mol-util/data-source'; import { download } from '../../../mol-util/download'; diff --git a/src/mol-plugin/command.ts b/src/mol-plugin/command.ts index e4e8e8532..dbc514a85 100644 --- a/src/mol-plugin/command.ts +++ b/src/mol-plugin/command.ts @@ -4,71 +4,100 @@ * @author David Sehnal <david.sehnal@gmail.com> */ -import { Camera } from '../mol-canvas3d/camera'; -import { PluginCommand } from './command/base'; -import { StateTransform, State, StateAction } from '../mol-state'; -import { Canvas3DProps } from '../mol-canvas3d/canvas3d'; -import { PluginLayoutStateProps } from './layout'; -import { StructureElement } from '../mol-model/structure'; -import { PluginState } from './state'; -import { Interactivity } from './util/interactivity'; -import { PluginToast } from './state/toast'; - -export * from './command/base'; - -export const PluginCommands = { - State: { - SetCurrentObject: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), - ApplyAction: PluginCommand<{ state: State, action: StateAction.Instance, ref?: StateTransform.Ref }>(), - Update: PluginCommand<{ state: State, tree: State.Tree | State.Builder, options?: Partial<State.UpdateOptions> }>(), - - RemoveObject: PluginCommand<{ state: State, ref: StateTransform.Ref, removeParentGhosts?: boolean }>(), - - ToggleExpanded: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), - ToggleVisibility: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), - Highlight: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), - ClearHighlight: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), - - Snapshots: { - Add: PluginCommand<{ name?: string, description?: string, params?: PluginState.GetSnapshotParams }>(), - Replace: PluginCommand<{ id: string, params?: PluginState.GetSnapshotParams }>(), - Move: PluginCommand<{ id: string, dir: -1 | 1 }>(), - Remove: PluginCommand<{ id: string }>(), - Apply: PluginCommand<{ id: string }>(), - Clear: PluginCommand<{}>(), - - Upload: PluginCommand<{ name?: string, description?: string, playOnLoad?: boolean, serverUrl: string }>(), - Fetch: PluginCommand<{ url: string }>(), - - DownloadToFile: PluginCommand<{ name?: string }>(), - OpenFile: PluginCommand<{ file: File }>(), +import { PluginContext } from './context'; +import { UUID } from '../mol-util'; + +export { PluginCommand, PluginCommandManager } + +interface PluginCommand<T = unknown> { + (ctx: PluginContext, params?: T): Promise<void>, + readonly id: UUID, + subscribe(ctx: PluginContext, action: PluginCommand.Action<T>): PluginCommand.Subscription +} + +function PluginCommand<T>(): PluginCommand<T> { + const ret: PluginCommand<T> = ((ctx, params) => ctx.commands.dispatch(ret, params || {} as any)) as PluginCommand<T>; + ret.subscribe = (ctx, action) => ctx.commands.subscribe(ret, action); + (ret.id as UUID) = UUID.create22(); + + return ret; +} + +namespace PluginCommand { + export type Id = string & { '@type': 'plugin-command-id' } + + export interface Subscription { + unsubscribe(): void + } + + export type Action<T> = (params: T) => unknown | Promise<unknown> +} + +type Instance = { cmd: PluginCommand<any>, params: any, resolve: () => void, reject: (e: any) => void } +class PluginCommandManager { + private subs = new Map<string, PluginCommand.Action<any>[]>(); + private disposing = false; + + subscribe<T>(cmd: PluginCommand<T>, action: PluginCommand.Action<T>): PluginCommand.Subscription { + let actions = this.subs.get(cmd.id); + if (!actions) { + actions = []; + this.subs.set(cmd.id, actions); + } + actions.push(action); + + return { + unsubscribe: () => { + const actions = this.subs.get(cmd.id); + if (!actions) return; + const idx = actions.indexOf(action); + if (idx < 0) return; + for (let i = idx + 1; i < actions.length; i++) { + actions[i - 1] = actions[i]; + } + actions.pop(); + } } - }, - Interactivity: { - SetProps: PluginCommand<{ props: Partial<Interactivity.Props> }>(), - Structure: { - Highlight: PluginCommand<{ loci: StructureElement.Loci, isOff?: boolean }>(), - Select: PluginCommand<{ loci: StructureElement.Loci, isOff?: boolean }>() + } + + + /** Resolves after all actions have completed */ + dispatch<T>(cmd: PluginCommand<T>, params: T) { + return new Promise<void>((resolve, reject) => { + if (this.disposing) { + reject('disposed'); + return; + } + + const actions = this.subs.get(cmd.id); + if (!actions) { + resolve(); + return; + } + + this.resolve({ cmd, params, resolve, reject }); + }); + } + + dispose() { + this.subs.clear(); + } + + private async resolve(instance: Instance) { + const actions = this.subs.get(instance.cmd.id); + if (!actions) { + instance.resolve(); + return; } - }, - Layout: { - Update: PluginCommand<{ state: Partial<PluginLayoutStateProps> }>() - }, - Toast: { - Show: PluginCommand<PluginToast>(), - Hide: PluginCommand<{ key: string }>() - }, - Camera: { - Reset: PluginCommand<{ durationMs?: number, snapshot?: Partial<Camera.Snapshot> }>(), - SetSnapshot: PluginCommand<{ snapshot: Partial<Camera.Snapshot>, durationMs?: number }>(), - Snapshots: { - Add: PluginCommand<{ name?: string, description?: string }>(), - Remove: PluginCommand<{ id: string }>(), - Apply: PluginCommand<{ id: string }>(), - Clear: PluginCommand<{}>(), + + try { + // TODO: should actions be called "asynchronously" ("setImmediate") instead? + for (const a of actions) { + await a(instance.params); + } + instance.resolve(); + } catch (e) { + instance.reject(e); } - }, - Canvas3D: { - SetSettings: PluginCommand<{ settings: Partial<Canvas3DProps> }>() } } \ No newline at end of file diff --git a/src/mol-plugin/command/base.ts b/src/mol-plugin/command/base.ts deleted file mode 100644 index d1c77074b..000000000 --- a/src/mol-plugin/command/base.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author David Sehnal <david.sehnal@gmail.com> - */ - -import { PluginContext } from '../context'; -import { UUID } from '../../mol-util'; - -export { PluginCommand } - -interface PluginCommand<T = unknown> { - readonly id: UUID, - dispatch(ctx: PluginContext, params: T): Promise<void>, - subscribe(ctx: PluginContext, action: PluginCommand.Action<T>): PluginCommand.Subscription -} - -/** namespace.id must a globally unique identifier */ -function PluginCommand<T>(): PluginCommand<T> { - return new Impl(); -} - -class Impl<T> implements PluginCommand<T> { - dispatch(ctx: PluginContext, params: T): Promise<void> { - return ctx.commands.dispatch(this, params); - } - subscribe(ctx: PluginContext, action: PluginCommand.Action<T>): PluginCommand.Subscription { - return ctx.commands.subscribe(this, action); - } - id = UUID.create22(); - constructor() { - } -} - -namespace PluginCommand { - export type Id = string & { '@type': 'plugin-command-id' } - - export interface Subscription { - unsubscribe(): void - } - - export type Action<T> = (params: T) => unknown | Promise<unknown> - type Instance = { cmd: PluginCommand<any>, params: any, resolve: () => void, reject: (e: any) => void } - - export class Manager { - private subs = new Map<string, Action<any>[]>(); - private disposing = false; - - subscribe<T>(cmd: PluginCommand<T>, action: Action<T>): Subscription { - let actions = this.subs.get(cmd.id); - if (!actions) { - actions = []; - this.subs.set(cmd.id, actions); - } - actions.push(action); - - return { - unsubscribe: () => { - const actions = this.subs.get(cmd.id); - if (!actions) return; - const idx = actions.indexOf(action); - if (idx < 0) return; - for (let i = idx + 1; i < actions.length; i++) { - actions[i - 1] = actions[i]; - } - actions.pop(); - } - } - } - - - /** Resolves after all actions have completed */ - dispatch<T>(cmd: PluginCommand<T>, params: T) { - return new Promise<void>((resolve, reject) => { - if (this.disposing) { - reject('disposed'); - return; - } - - const actions = this.subs.get(cmd.id); - if (!actions) { - resolve(); - return; - } - - this.resolve({ cmd, params, resolve, reject }); - }); - } - - dispose() { - this.subs.clear(); - } - - private async resolve(instance: Instance) { - const actions = this.subs.get(instance.cmd.id); - if (!actions) { - instance.resolve(); - return; - } - - try { - // TODO: should actions be called "asynchronously" ("setImmediate") instead? - for (const a of actions) { - await a(instance.params); - } - instance.resolve(); - } catch (e) { - instance.reject(e); - } - } - } -} \ No newline at end of file diff --git a/src/mol-plugin/commands.ts b/src/mol-plugin/commands.ts new file mode 100644 index 000000000..46808e15f --- /dev/null +++ b/src/mol-plugin/commands.ts @@ -0,0 +1,72 @@ +/** + * 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 { PluginCommand } from './command'; +import { StateTransform, State, StateAction } from '../mol-state'; +import { Canvas3DProps } from '../mol-canvas3d/canvas3d'; +import { PluginLayoutStateProps } from './layout'; +import { StructureElement } from '../mol-model/structure'; +import { PluginState } from './state'; +import { Interactivity } from './util/interactivity'; +import { PluginToast } from './util/toast'; + +export const PluginCommands = { + State: { + SetCurrentObject: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), + ApplyAction: PluginCommand<{ state: State, action: StateAction.Instance, ref?: StateTransform.Ref }>(), + Update: PluginCommand<{ state: State, tree: State.Tree | State.Builder, options?: Partial<State.UpdateOptions> }>(), + + RemoveObject: PluginCommand<{ state: State, ref: StateTransform.Ref, removeParentGhosts?: boolean }>(), + + ToggleExpanded: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), + ToggleVisibility: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), + Highlight: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), + ClearHighlight: PluginCommand<{ state: State, ref: StateTransform.Ref }>(), + + Snapshots: { + Add: PluginCommand<{ name?: string, description?: string, params?: PluginState.GetSnapshotParams }>(), + Replace: PluginCommand<{ id: string, params?: PluginState.GetSnapshotParams }>(), + Move: PluginCommand<{ id: string, dir: -1 | 1 }>(), + Remove: PluginCommand<{ id: string }>(), + Apply: PluginCommand<{ id: string }>(), + Clear: PluginCommand<{}>(), + + Upload: PluginCommand<{ name?: string, description?: string, playOnLoad?: boolean, serverUrl: string }>(), + Fetch: PluginCommand<{ url: string }>(), + + DownloadToFile: PluginCommand<{ name?: string }>(), + OpenFile: PluginCommand<{ file: File }>(), + } + }, + Interactivity: { + SetProps: PluginCommand<{ props: Partial<Interactivity.Props> }>(), + Structure: { + Highlight: PluginCommand<{ loci: StructureElement.Loci, isOff?: boolean }>(), + Select: PluginCommand<{ loci: StructureElement.Loci, isOff?: boolean }>() + } + }, + Layout: { + Update: PluginCommand<{ state: Partial<PluginLayoutStateProps> }>() + }, + Toast: { + Show: PluginCommand<PluginToast>(), + Hide: PluginCommand<{ key: string }>() + }, + Camera: { + Reset: PluginCommand<{ durationMs?: number, snapshot?: Partial<Camera.Snapshot> }>(), + SetSnapshot: PluginCommand<{ snapshot: Partial<Camera.Snapshot>, durationMs?: number }>(), + Snapshots: { + Add: PluginCommand<{ name?: string, description?: string }>(), + Remove: PluginCommand<{ id: string }>(), + Apply: PluginCommand<{ id: string }>(), + Clear: PluginCommand<{}>(), + } + }, + Canvas3D: { + SetSettings: PluginCommand<{ settings: Partial<Canvas3DProps> }>() + } +} \ No newline at end of file diff --git a/src/mol-plugin/context.ts b/src/mol-plugin/context.ts index 802a6ad2c..7a4c479b3 100644 --- a/src/mol-plugin/context.ts +++ b/src/mol-plugin/context.ts @@ -21,11 +21,12 @@ import { RxEventHelper } from '../mol-util/rx-event-helper'; import { merge } from 'rxjs'; import { BuiltInPluginBehaviors } from './behavior'; import { PluginBehavior } from './behavior/behavior'; -import { PluginCommand, PluginCommands } from './command'; +import { PluginCommands } from './commands'; +import { PluginCommandManager } from './command'; import { PluginLayout, LeftPanelTabName } from './layout'; import { PluginSpec } from './spec'; import { PluginState } from './state'; -import { DataFormatRegistry } from './state/actions/data-format'; +import { DataFormatRegistry } from '../mol-plugin-state/actions/data-format'; import { StateTransformParameters } from '../mol-plugin-ui/state/common'; import { LociLabelEntry, LociLabelManager } from './util/loci-label-manager'; import { TaskManager } from './util/task-manager'; @@ -39,30 +40,20 @@ import { Interactivity } from './util/interactivity'; import { StructureRepresentationHelper } from './util/structure-representation-helper'; import { StructureSelectionHelper } from './util/structure-selection-helper'; import { StructureOverpaintHelper } from './util/structure-overpaint-helper'; -import { PluginToastManager } from './state/toast'; +import { PluginToastManager } from './util/toast'; import { StructureMeasurementManager } from './util/structure-measurement'; import { ViewportScreenshotHelper } from './util/viewport-screenshot'; -import { StructureRepresentationManager } from './state/representation/structure'; -import { DataManager } from './state/manager/data'; +import { StructureRepresentationManager } from '../mol-plugin-state/representation/structure'; import { CustomProperty } from '../mol-model-props/common/custom-property'; import { PluginConfigManager } from './config'; -interface Log { - entries: List<LogEntry> - readonly entry: (e: LogEntry) => void - readonly error: (msg: string) => void - readonly message: (msg: string) => void - readonly info: (msg: string) => void - readonly warn: (msg: string) => void -} - export class PluginContext { private disposed = false; private ev = RxEventHelper.create(); private tasks = new TaskManager(); readonly state = new PluginState(this); - readonly commands = new PluginCommand.Manager(); + readonly commands = new PluginCommandManager(); readonly events = { state: { @@ -137,10 +128,6 @@ export class PluginContext { readonly customStructureProperties = new CustomProperty.Registry<Structure>(); readonly customParamEditors = new Map<string, StateTransformParameters.Class>(); - readonly managers = { - data: new DataManager(this), - } as const; - readonly helpers = { measurement: new StructureMeasurementManager(this), structureSelectionManager: new StructureElementSelectionManager(this), @@ -166,7 +153,7 @@ export class PluginContext { this.events.canvas3d.initialized.next() this.events.canvas3d.initialized.isStopped = true // TODO is this a good way? const renderer = this.canvas3d!.props.renderer; - PluginCommands.Canvas3D.SetSettings.dispatch(this, { settings: { renderer: { ...renderer, backgroundColor: Color(0xFCFBF9) } } }); + PluginCommands.Canvas3D.SetSettings(this, { settings: { renderer: { ...renderer, backgroundColor: Color(0xFCFBF9) } } }); this.canvas3d!.animate(); (this.helpers.viewportScreenshot as ViewportScreenshotHelper) = new ViewportScreenshotHelper(this); return true; @@ -177,7 +164,7 @@ export class PluginContext { } } - readonly log: Log = { + readonly log = { entries: List<LogEntry>(), entry: (e: LogEntry) => this.events.log.next(e), error: (msg: string) => this.events.log.next(LogEntry.error(msg)), @@ -218,12 +205,12 @@ export class PluginContext { applyTransform(state: State, a: StateTransform.Ref, transformer: StateTransformer, params: any) { const tree = state.build().to(a).apply(transformer, params); - return PluginCommands.State.Update.dispatch(this, { state, tree }); + return PluginCommands.State.Update(this, { state, tree }); } updateTransform(state: State, a: StateTransform.Ref, params: any) { const tree = state.build().to(a).update(params); - return PluginCommands.State.Update.dispatch(this, { state, tree }); + return PluginCommands.State.Update(this, { state, tree }); } private initBehaviorEvents() { diff --git a/src/mol-plugin/index.ts b/src/mol-plugin/index.ts index 16fcadc04..18ab0aa31 100644 --- a/src/mol-plugin/index.ts +++ b/src/mol-plugin/index.ts @@ -10,13 +10,13 @@ import { Plugin } from '../mol-plugin-ui/plugin' import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { PluginSpec } from './spec'; -import { StateTransforms } from './state/transforms'; +import { StateTransforms } from '../mol-plugin-state/transforms'; import { PluginBehaviors } from './behavior'; -import { AnimateModelIndex, AnimateAssemblyUnwind, AnimateUnitsExplode, AnimateStateInterpolation } from './state/animation/built-in'; -import { StateActions } from './state/actions'; +import { AnimateModelIndex, AnimateAssemblyUnwind, AnimateUnitsExplode, AnimateStateInterpolation } from '../mol-plugin-state/animation/built-in'; +import { StateActions } from '../mol-plugin-state/actions'; import { InitVolumeStreaming, BoxifyVolumeStreaming, CreateVolumeStreamingBehavior } from './behavior/dynamic/volume-streaming/transformers'; import { StructureRepresentationInteraction } from './behavior/dynamic/selection/structure-representation-interaction'; -import { TransformStructureConformation } from './state/actions/structure'; +import { TransformStructureConformation } from '../mol-plugin-state/actions/structure'; import { VolumeStreamingCustomControls } from '../mol-plugin-ui/custom/volume'; import { PluginConfig } from './config'; diff --git a/src/mol-plugin/layout.ts b/src/mol-plugin/layout.ts index 40475230b..1d9ac326a 100644 --- a/src/mol-plugin/layout.ts +++ b/src/mol-plugin/layout.ts @@ -8,7 +8,7 @@ import { ParamDefinition as PD } from '../mol-util/param-definition'; import { PluginComponent } from './component'; import { PluginContext } from './context'; -import { PluginCommands } from './command'; +import { PluginCommands } from './commands'; const regionStateOptions = [ ['full', 'Full'] as const, diff --git a/src/mol-plugin/spec.ts b/src/mol-plugin/spec.ts index c3c11f44d..9ecda229b 100644 --- a/src/mol-plugin/spec.ts +++ b/src/mol-plugin/spec.ts @@ -8,7 +8,7 @@ import { StateTransformer, StateAction } from '../mol-state'; import { StateTransformParameters } from '../mol-plugin-ui/state/common'; import { PluginLayoutStateProps } from './layout'; -import { PluginStateAnimation } from './state/animation/model'; +import { PluginStateAnimation } from '../mol-plugin-state/animation/model'; import { ParamDefinition as PD } from '../mol-util/param-definition'; import { PluginConfigItem } from './config'; @@ -25,7 +25,7 @@ interface PluginSpec { viewport?: React.ComponentClass }, components?: { - remoteState?: 'none' | 'default' // TODO: props for server etc + remoteState?: 'none' | 'default' }, config?: Map<PluginConfigItem, unknown> } diff --git a/src/mol-plugin/state.ts b/src/mol-plugin/state.ts index 96c5706aa..5f3904217 100644 --- a/src/mol-plugin/state.ts +++ b/src/mol-plugin/state.ts @@ -5,15 +5,15 @@ */ import { State } from '../mol-state'; -import { PluginStateObject as SO } from './state/objects'; +import { PluginStateObject as SO } from '../mol-plugin-state/objects'; import { Camera } from '../mol-canvas3d/camera'; import { PluginBehavior } from './behavior'; -import { CameraSnapshotManager } from './state/camera'; -import { PluginStateSnapshotManager } from './state/snapshots'; +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 './command'; -import { PluginAnimationManager } from './state/animation/manager'; +import { PluginCommands } from './commands'; +import { PluginAnimationManager } from '../mol-plugin-state/animation/manager'; import { ParamDefinition as PD } from '../mol-util/param-definition'; import { UUID } from '../mol-util'; import { Interactivity } from './util/interactivity'; @@ -69,17 +69,17 @@ class PluginState { if (snapshot.behaviour) await this.plugin.runTask(this.behaviorState.setSnapshot(snapshot.behaviour)); if (snapshot.data) await this.plugin.runTask(this.dataState.setSnapshot(snapshot.data)); if (snapshot.canvas3d) { - if (snapshot.canvas3d.props) await PluginCommands.Canvas3D.SetSettings.dispatch(this.plugin, { settings: snapshot.canvas3d.props }); + if (snapshot.canvas3d.props) await PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: snapshot.canvas3d.props }); } if (snapshot.interactivity) { - if (snapshot.interactivity.props) await PluginCommands.Interactivity.SetProps.dispatch(this.plugin, { props: snapshot.interactivity.props }); + if (snapshot.interactivity.props) await PluginCommands.Interactivity.SetProps(this.plugin, { props: snapshot.interactivity.props }); } if (snapshot.cameraSnapshots) this.cameraSnapshots.setStateSnapshot(snapshot.cameraSnapshots); if (snapshot.animation) { this.animation.setSnapshot(snapshot.animation); } if (snapshot.camera) { - PluginCommands.Camera.SetSnapshot.dispatch(this.plugin, { + PluginCommands.Camera.SetSnapshot(this.plugin, { snapshot: snapshot.camera.current, durationMs: snapshot.camera.transitionStyle === 'animate' ? snapshot.camera.transitionDurationInMs diff --git a/src/mol-plugin/util/interactivity.ts b/src/mol-plugin/util/interactivity.ts index 072a0933a..4c41ed4aa 100644 --- a/src/mol-plugin/util/interactivity.ts +++ b/src/mol-plugin/util/interactivity.ts @@ -14,7 +14,7 @@ import { StructureElementSelectionManager } from './structure-element-selection' import { PluginContext } from '../context'; import { Structure } from '../../mol-model/structure'; import { ParamDefinition as PD } from '../../mol-util/param-definition'; -import { PluginCommands } from '../command'; +import { PluginCommands } from '../commands'; export { Interactivity } diff --git a/src/mol-plugin/util/structure-complex-helper.ts b/src/mol-plugin/util/structure-complex-helper.ts index af783510d..b7db54f0b 100644 --- a/src/mol-plugin/util/structure-complex-helper.ts +++ b/src/mol-plugin/util/structure-complex-helper.ts @@ -6,10 +6,10 @@ import { PluginContext } from '../context'; import { StateBuilder } from '../../mol-state'; -import { PluginStateObject } from '../state/objects'; -import { StateTransforms } from '../state/transforms'; -import { StructureRepresentation3DHelpers } from '../state/transforms/representation'; -import { StructureComplexElementTypes } from '../state/transforms/model'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; +import { StructureRepresentation3DHelpers } from '../../mol-plugin-state/transforms/representation'; +import { StructureComplexElementTypes } from '../../mol-plugin-state/transforms/model'; export function createDefaultStructureComplex( ctx: PluginContext, root: StateBuilder.To<PluginStateObject.Molecule.Structure> diff --git a/src/mol-plugin/util/structure-element-selection.ts b/src/mol-plugin/util/structure-element-selection.ts index a41da0c2b..1aca068d0 100644 --- a/src/mol-plugin/util/structure-element-selection.ts +++ b/src/mol-plugin/util/structure-element-selection.ts @@ -10,7 +10,7 @@ import { EmptyLoci, Loci } from '../../mol-model/loci'; import { Structure, StructureElement } from '../../mol-model/structure'; import { StateObject } from '../../mol-state'; import { PluginContext } from '../context'; -import { PluginStateObject } from '../state/objects'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; import { structureElementStatsLabel } from '../../mol-theme/label'; import { Vec3 } from '../../mol-math/linear-algebra'; import { BoundaryHelper } from '../../mol-math/geometry/boundary-helper'; diff --git a/src/mol-plugin/util/structure-measurement.ts b/src/mol-plugin/util/structure-measurement.ts index 389602992..c8ee5865a 100644 --- a/src/mol-plugin/util/structure-measurement.ts +++ b/src/mol-plugin/util/structure-measurement.ts @@ -7,8 +7,8 @@ import { StructureElement } from '../../mol-model/structure'; import { PluginContext } from '../context'; import { StateSelection, StateTransform } from '../../mol-state'; -import { StateTransforms } from '../state/transforms'; -import { PluginCommands } from '../command'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; +import { PluginCommands } from '../commands'; import { arraySetAdd } from '../../mol-util/array'; export { StructureMeasurementManager } @@ -47,7 +47,7 @@ class StructureMeasurementManager { .apply(StateTransforms.Representation.StructureSelectionsDistance3D) const state = this.context.state.dataState; - await PluginCommands.State.Update.dispatch(this.context, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(this.context, { state, tree: update, options: { doNotLogTiming: true } }); } async addAngle(a: StructureElement.Loci, b: StructureElement.Loci, c: StructureElement.Loci) { @@ -75,7 +75,7 @@ class StructureMeasurementManager { .apply(StateTransforms.Representation.StructureSelectionsAngle3D) const state = this.context.state.dataState; - await PluginCommands.State.Update.dispatch(this.context, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(this.context, { state, tree: update, options: { doNotLogTiming: true } }); } async addDihedral(a: StructureElement.Loci, b: StructureElement.Loci, c: StructureElement.Loci, d: StructureElement.Loci) { @@ -106,7 +106,7 @@ class StructureMeasurementManager { .apply(StateTransforms.Representation.StructureSelectionsDihedral3D) const state = this.context.state.dataState; - await PluginCommands.State.Update.dispatch(this.context, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(this.context, { state, tree: update, options: { doNotLogTiming: true } }); } async addLabel(a: StructureElement.Loci) { @@ -128,7 +128,7 @@ class StructureMeasurementManager { .apply(StateTransforms.Representation.StructureSelectionsLabel3D) const state = this.context.state.dataState; - await PluginCommands.State.Update.dispatch(this.context, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(this.context, { state, tree: update, options: { doNotLogTiming: true } }); } async addOrientation(a: StructureElement.Loci) { @@ -150,7 +150,7 @@ class StructureMeasurementManager { .apply(StateTransforms.Representation.StructureSelectionsOrientation3D) const state = this.context.state.dataState; - await PluginCommands.State.Update.dispatch(this.context, { state, tree: update, options: { doNotLogTiming: true } }); + await PluginCommands.State.Update(this.context, { state, tree: update, options: { doNotLogTiming: true } }); } constructor(private context: PluginContext) { diff --git a/src/mol-plugin/util/structure-overpaint-helper.ts b/src/mol-plugin/util/structure-overpaint-helper.ts index 5a2b2da67..12e3da838 100644 --- a/src/mol-plugin/util/structure-overpaint-helper.ts +++ b/src/mol-plugin/util/structure-overpaint-helper.ts @@ -4,8 +4,8 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginStateObject } from '../../mol-plugin/state/objects'; -import { StateTransforms } from '../../mol-plugin/state/transforms'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; import { StateSelection, StateObjectCell, StateTransform, StateBuilder } from '../../mol-state'; import { Structure, StructureElement, StructureSelection, QueryContext } from '../../mol-model/structure'; import { PluginContext } from '../context'; diff --git a/src/mol-plugin/util/structure-query.ts b/src/mol-plugin/util/structure-query.ts index aef4d1fb7..374b8cddd 100644 --- a/src/mol-plugin/util/structure-query.ts +++ b/src/mol-plugin/util/structure-query.ts @@ -8,7 +8,7 @@ import Expression from '../../mol-script/language/expression'; import { QueryFn, Structure, StructureSelection as Sel, QueryContext } from '../../mol-model/structure'; import { Script } from '../../mol-script/script'; import { compile } from '../../mol-script/runtime/query/compiler'; -import { PluginStateObject as SO } from '../state/objects'; +import { PluginStateObject as SO } from '../../mol-plugin-state/objects'; export { StructureQueryHelper } namespace StructureQueryHelper { diff --git a/src/mol-plugin/util/structure-representation-helper.ts b/src/mol-plugin/util/structure-representation-helper.ts index 241d632bd..a688844d1 100644 --- a/src/mol-plugin/util/structure-representation-helper.ts +++ b/src/mol-plugin/util/structure-representation-helper.ts @@ -4,12 +4,12 @@ * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -import { PluginStateObject as PSO } from '../../mol-plugin/state/objects'; -import { StateTransforms } from '../../mol-plugin/state/transforms'; +import { PluginStateObject as PSO } from '../../mol-plugin-state/objects'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; import { StateTransformer, StateSelection, StateObjectCell, StateTransform, StateBuilder } from '../../mol-state'; import { StructureElement, Structure, StructureSelection, QueryContext } from '../../mol-model/structure'; import { PluginContext } from '../context'; -import { StructureRepresentation3DHelpers } from '../state/transforms/representation'; +import { StructureRepresentation3DHelpers } from '../../mol-plugin-state/transforms/representation'; import Expression from '../../mol-script/language/expression'; import { compile } from '../../mol-script/runtime/query/compiler'; import { VisualQuality } from '../../mol-geo/geometry/base'; diff --git a/src/mol-plugin/util/structure-selection-helper.ts b/src/mol-plugin/util/structure-selection-helper.ts index 377c6507a..0a4c41b9f 100644 --- a/src/mol-plugin/util/structure-selection-helper.ts +++ b/src/mol-plugin/util/structure-selection-helper.ts @@ -7,14 +7,14 @@ import { MolScriptBuilder as MS } from '../../mol-script/language/builder'; import { StateSelection, StateBuilder } from '../../mol-state'; -import { PluginStateObject } from '../state/objects'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; import { QueryContext, StructureSelection, StructureQuery, StructureElement, Structure } from '../../mol-model/structure'; import { compile } from '../../mol-script/runtime/query/compiler'; import { Loci } from '../../mol-model/loci'; import { PluginContext } from '../context'; import Expression from '../../mol-script/language/expression'; import { BondType, ProteinBackboneAtoms, NucleicBackboneAtoms, SecondaryStructureType } from '../../mol-model/structure/model/types'; -import { StateTransforms } from '../state/transforms'; +import { StateTransforms } from '../../mol-plugin-state/transforms'; import { SetUtils } from '../../mol-util/set'; import { ValidationReport, ValidationReportProvider } from '../../mol-model-props/rcsb/validation-report'; import { CustomProperty } from '../../mol-model-props/common/custom-property'; diff --git a/src/mol-plugin/util/substructure-parent-helper.ts b/src/mol-plugin/util/substructure-parent-helper.ts index 29f7c8e3e..58bcc806c 100644 --- a/src/mol-plugin/util/substructure-parent-helper.ts +++ b/src/mol-plugin/util/substructure-parent-helper.ts @@ -7,7 +7,7 @@ import { Structure } from '../../mol-model/structure'; import { State, StateObject, StateSelection, StateObjectCell } from '../../mol-state'; import { PluginContext } from '../context'; -import { PluginStateObject } from '../state/objects'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; export { SubstructureParentHelper }; diff --git a/src/mol-plugin/state/toast.ts b/src/mol-plugin/util/toast.ts similarity index 98% rename from src/mol-plugin/state/toast.ts rename to src/mol-plugin/util/toast.ts index c810a2686..e5ba670f4 100644 --- a/src/mol-plugin/state/toast.ts +++ b/src/mol-plugin/util/toast.ts @@ -9,7 +9,7 @@ import { PluginComponent } from '../component'; import { OrderedMap } from 'immutable'; import { PluginContext } from '../context'; -import { PluginCommands } from '../command'; +import { PluginCommands } from '../commands'; export interface PluginToast { title: string, diff --git a/src/mol-plugin/util/viewport-screenshot.ts b/src/mol-plugin/util/viewport-screenshot.ts index eae9094d3..ce22ed216 100644 --- a/src/mol-plugin/util/viewport-screenshot.ts +++ b/src/mol-plugin/util/viewport-screenshot.ts @@ -8,7 +8,7 @@ import { PluginContext } from '../context'; import { ImagePass } from '../../mol-canvas3d/passes/image'; import { StateSelection } from '../../mol-state'; -import { PluginStateObject } from '../state/objects'; +import { PluginStateObject } from '../../mol-plugin-state/objects'; import { Task, RuntimeContext } from '../../mol-task'; import { canvasToBlob } from '../../mol-canvas3d/util'; import { download } from '../../mol-util/download'; diff --git a/src/mol-plugin/version.ts b/src/mol-plugin/version.ts index fe3cfb827..195d85027 100644 --- a/src/mol-plugin/version.ts +++ b/src/mol-plugin/version.ts @@ -1,11 +1,11 @@ /** - * Copyright (c) 2018-2019 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> * @author Alexander Rose <alexander.rose@weirdbyte.de> */ -export const PLUGIN_VERSION = '0.5.0'; +export const PLUGIN_VERSION = '0.5.5'; /** unix time stamp, to be filled in at bundle build time */ declare const __PLUGIN_VERSION_TIMESTAMP__: number export const PLUGIN_VERSION_TIMESTAMP = __PLUGIN_VERSION_TIMESTAMP__; -- GitLab