/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import { UUID } from 'mol-util'; import { Transform } from './transform'; export { StateObject, StateObjectCell } interface StateObject

{ readonly id: UUID, readonly type: StateObject.Type, readonly props: P, readonly data: D } namespace StateObject { export function factory() { return (type: Type) => create

(type); } export type Type = I export type Ctor = { new(...args: any[]): StateObject, type: any } export function create(type: Type) { return class implements StateObject { static type = type; static is(obj?: StateObject): obj is StateObject { return !!obj && type === obj.type; } id = UUID.create(); type = type; constructor(public props: Props, public data: Data) { } } } } interface StateObjectCell { ref: Transform.Ref, version: string status: StateObjectCell.Status, state: unknown, errorText?: string, obj?: StateObject } namespace StateObjectCell { export type Status = 'ok' | 'error' | 'pending' | 'processing' export interface State { isVisible: boolean, isHidden: boolean, isBound: boolean, isExpanded: boolean } }