@meta2d/core
Version:
@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .
127 lines (126 loc) • 3.12 kB
TypeScript
import { Meta2d } from '../core';
import { IValue, Pen } from '../pen';
import { Network } from '../store';
export type EventValue = string | IValue | undefined | null;
export type EventName = 'enter' | 'leave' | 'active' | 'inactive' | 'click' | 'mousedown' | 'mouseup' | 'dblclick' | 'valueUpdate' | 'message' | 'contextmenu' | 'input' | 'change' | 'submit' | 'reset';
export interface Event {
name: EventName;
action: EventAction;
where?: Where;
value?: EventValue;
params?: string;
extend?: any;
fn?: (pen: Pen, params: string, context?: {
meta2d: Meta2d;
eventName: string;
}) => void;
targetType?: string;
network?: Network;
actions?: Event[];
conditions?: TriggerCondition[];
conditionType?: string;
message?: string;
callback?: string;
list?: {
params?: string;
value?: EventValue;
}[];
timeout?: number;
confirm?: string;
confirmTitle?: string;
data?: {
key?: string;
value?: string;
id?: string;
prop?: string;
class?: string;
token?: string;
}[];
}
export declare enum EventAction {
Link = 0,
SetProps = 1,
StartAnimate = 2,
PauseAnimate = 3,
StopAnimate = 4,
JS = 5,//Function
GlobalFn = 6,
Emit = 7,
StartVideo = 8,
PauseVideo = 9,
StopVideo = 10,
SendPropData = 11,
SendVarData = 12,
Navigator = 13,
Dialog = 14,
SendData = 15,//数据源选择
PostMessage = 16,//发送场景数据
PostMessageToParent = 17,//向父窗口发送消息
Message = 18
}
export interface Where {
type?: string | 'comparison';
key?: string;
comparison?: Comparison;
value?: unknown;
fn?: (pen: Pen, context?: {
meta2d: Meta2d;
}) => boolean;
fnJs?: string;
}
/**
* 触发器中的符号
*/
export type Comparison = '=' | '==' | '!=' | '>' | '<' | '>=' | '<=' | '[)' | '![)'
/**
* 属于,类似于 数组的 includes
* .. 属于范围语法,30..50 等价于 介于的 [30, 50]
* [1, 2, 3] 2 // true 1.5 // false
* [1,20,30..50,65] 1 // true 20 // true 30 // true 30.1 // true
*/
| '[]' | '![]';
export interface TriggerCondition {
type?: string;
operator?: Comparison;
valueType?: string;
value?: string;
target?: string;
label?: string;
fnJs?: string;
fn?: (pen: Pen, context?: {
meta2d: Meta2d;
}) => boolean;
key?: string;
source?: string;
}
export interface Trigger {
name?: string;
conditionType?: string;
conditions?: TriggerCondition[];
actions?: Event[];
status?: Trigger[];
}
export interface Bind {
case?: string;
id?: string;
label?: string;
class?: string;
token?: string;
compute_name?: string;
deviceId?: string;
key?: string;
}
export interface RealTime {
label?: string;
key?: string;
type?: string;
keywords?: true;
triggers?: Trigger[];
bind?: Bind;
value?: string;
enableMock?: boolean;
mock?: any;
productId?: string;
deviceId?: string;
propertyId?: string;
}