spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import { StateAction } from 'mol-state/action';
  7. import { Transformer } from 'mol-state';
  8. import { StateTransformParameters } from './ui/state/common';
  9. import { PluginLayoutStateProps } from './layout';
  10. export { PluginSpec }
  11. interface PluginSpec {
  12. actions: PluginSpec.Action[],
  13. behaviors: PluginSpec.Behavior[],
  14. initialLayout?: PluginLayoutStateProps
  15. }
  16. namespace PluginSpec {
  17. export interface Action {
  18. action: StateAction | Transformer,
  19. customControl?: StateTransformParameters.Class,
  20. autoUpdate?: boolean
  21. }
  22. export function Action(action: StateAction | Transformer, params?: { customControl?: StateTransformParameters.Class, autoUpdate?: boolean }): Action {
  23. return { action, customControl: params && params.customControl, autoUpdate: params && params.autoUpdate };
  24. }
  25. export interface Behavior {
  26. transformer: Transformer,
  27. defaultParams?: any
  28. }
  29. export function Behavior<T extends Transformer>(transformer: T, defaultParams?: Transformer.Params<T>): Behavior {
  30. return { transformer, defaultParams };
  31. }
  32. }