UNPKG

@chief-editor/flow

Version:

Old核心数据流

60 lines (59 loc) 2.42 kB
import { DomNode } from '@co-hooks/dom-node'; import { Emitter } from '@co-hooks/emitter'; import { IWatcherFlags, NestWatcher, WatcherFunc } from '@co-hooks/nest-watcher'; import { FunctionAny } from '@co-hooks/util'; import { INodeType } from '@chief-editor/base'; import { FlowBrickGlobal } from './FlowBrick'; import { FlowTemplate } from './FlowTemplate'; import { FlowContext, FlowContextInfo } from './FlowContext'; export interface IModelOptions { context: FlowContext; name: string; model?: any; parent?: string; disableCache?: boolean; keepWhenReset?: boolean; } export interface IModelEvents { 'model-change': [string[], IWatcherFlags]; } export declare type FlowModelInfo = Record<string, any>; export declare class FlowModel extends Emitter<IModelEvents> { readonly root: DomNode<INodeType>; readonly name: string; private readonly disableCache; private readonly keepWhenReset; private model; private readonly context; private readonly parentModel; private readonly watcher; private readonly templateMap; private readonly brickMap; constructor(options: IModelOptions); getTemplate(id: string): FlowTemplate; unregisterTemplate(creator: string): void; registerTemplate(creator: string, template: FlowTemplate): void; getOwnerContext(): FlowContext; setContext(key: string, value?: unknown): void; setContext(context: FlowContextInfo): void; getContext(key: string, isDirect?: boolean): unknown; getContext(isDirect?: boolean): FlowContextInfo; getBrickById(id: string, modelName?: string): FlowBrickGlobal; getHooks(): { [key: string]: FunctionAny; }; getHook(key: string): FunctionAny | null; registerWatcher(watchKeys: string[], func: WatcherFunc): void; getParentModel(count?: number): FlowModel; getRootModel(): FlowModel; createSubModel(name: string, data: any): FlowModel; updateModel(modelInfo: FlowModelInfo, isSilent?: boolean): void; publishModelChange(keys: string[], flags: IWatcherFlags): void; resetModel(modelInfo: FlowModelInfo, isSilent?: boolean): void; getWatcher(): NestWatcher; getValueByBrick(brick: FlowBrickGlobal, isDirect?: boolean): any; setValueByPath(brick: FlowBrickGlobal, value: any, manual?: boolean, isSilent?: boolean): void; getModelInfo(isDirect?: boolean): any; dispose(): void; private init; }