UNPKG

egreact

Version:

A react render for egret 一个为 egret 而生的 react 渲染器

103 lines (102 loc) 2.98 kB
import { CONSTANTS } from './constants'; export declare type ExtensionObj = { [key: string]: any; [key: symbol]: any; }; export declare type EventInfo = { type: string; name: string; once: boolean; capture: boolean; priority: number; keys: string[]; }; export declare type PropResetter = void | ((removed: boolean) => void); export declare type PropSetter<P, I = Instance> = (args: { newValue: P; oldValue: P | typeof CONSTANTS.PROP_MOUNT; instance: I; target: ExtensionObj; targetKey: string; keys: string[]; [key: string]: any; }) => PropResetter; export declare type EventSet<P, I = Instance, T = P> = (args: { newValue: P; oldValue: P | typeof CONSTANTS.PROP_MOUNT; instance: I; target: T; targetKey: string; keys: string[]; eInfo: EventInfo; [key: string]: any; }) => PropResetter; export declare type PropSetterParameters<P, I = Instance> = Parameters<PropSetter<P, I>>[0]; export declare type DiffHandler<T> = (np: T, op: T) => boolean; export declare type IPropsHandlers = { [key: string]: PropSetter<Instance>; } & { [key: `${typeof CONSTANTS.CUSTOM_DIFF_PREFIX}${string}`]: DiffHandler<unknown>; } & { __Class: new (...args: any[]) => any; __detach?: (instance: Instance) => void; args?: (...args: any[]) => any; }; export interface IContainer { addChild: (child: any, childInstance?: any) => void; removeChild: (child: any, childInstance?: any) => void; addChildAt: (child: any, index: number, childInstance?: any) => void; getChildIndex: (child: any, childInstance?: any) => number; removeChildren?: () => void; attach?: () => void; } export interface ICustomClass { __target?: any; } export interface IPropInterface { __Class: new (...args: any) => any; __setter: PropSetter<any, any>; __diff: DiffHandler<any>; } import { Fiber } from 'react-reconciler'; export interface IRenderInfo { type: string; root: Instance<egret.DisplayObjectContainer>; fiber: Fiber; instance: Instance; primitive: boolean; container: boolean; args: boolean; noUsePool: boolean; mountedApplyProps: boolean; parent?: Instance<IContainer>; attach?: string; targetInfo?: [any, string, any]; propsHandlers: IPropsHandlers; memoizedDefault: { [key: string]: any; }; memoizedProps: { [key: string]: any; }; memoizedResetter: { [key: string]: (removed: boolean) => void; }; } export declare type Instance<I = ExtensionObj> = I & ICustomClass & { [CONSTANTS.INFO_KEY]: IRenderInfo; __target?: any; }; export declare type IElementProps = { args?: any; attach?: string; mountedApplyProps?: boolean; [x: string]: any; }; export declare type Changes = [key: string, value: unknown, isEvent: boolean, keys: string[]]; export declare type DiffSet = { memoized: { [key: string]: any; }; changes: Changes[]; };