UNPKG

@es-react/react

Version:

Hippy react framework

421 lines (420 loc) 13.8 kB
export type Type = string; export type Props = any; export type Container = number; export type UpdatePayload = any; export interface LayoutableProps { onLayout?: (evt: HippyTypes.LayoutEvent) => void; } export interface ClickableProps { onClick?: () => void; onLongClick?: () => void; } export interface TouchableProps { onTouchDown?: (evt: HippyTypes.TouchEvent) => void; onTouchMove?: (evt: HippyTypes.TouchEvent) => void; onTouchEnd?: (evt: HippyTypes.TouchEvent) => void; onTouchCancel?: (evt: HippyTypes.TouchEvent) => void; } export type NeedToTyped = any; export declare namespace HippyTypes { type __PLATFORM__ = 'ios' | 'android' | null; interface TouchEvent { page_x: number; page_y: number; } interface FocusEvent { focus: boolean; } interface TextInputEvent { text: string; } interface PullingEvent { contentOffset: number; } interface LayoutEvent { x: number | undefined; y: number | undefined; width: number | undefined; height: number | undefined; errMsg?: string | undefined; } interface DOMRect { x: number | undefined; y: number | undefined; top: number | undefined; left: number | undefined; bottom: number | undefined; right: number | undefined; width: number | undefined; height: number | undefined; } interface Transform { perspective?: number; rotate?: string; rotateX?: string; rotateY?: string; rotateZ?: string; scale?: number; scaleX?: number; scaleY?: number; translateX?: number; translateY?: number; skewX?: string; skewY?: string; } type color = string | number; type colors = string[] | number[]; type backgroundColor = string | number; type tintColor = string | number; type tintColors = string[] | number[] | null; type position = 'relative' | 'absolute'; type flexDirection = 'row' | 'column' | 'row-reverse'; type flexWrap = 'nowrap' | 'wrap' | 'wrap-reverse'; type justifyContent = 'start' | 'center' | 'end' | 'flex-start' | 'flex-end' | 'left' | 'right' | 'normal' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch'; type alignItems = 'stretch' | 'center' | 'flex-start' | 'flex-end' | 'baseline'; type alignSelf = 'stretch' | 'center' | 'flex-start' | 'flex-end' | 'baseline'; type overflow = 'hidden' | 'scroll'; interface BaseStyle { color?: color; colors?: colors; collapsable?: false; backgroundColor?: backgroundColor; backgroundImage?: string; backgroundSize?: string; backgroundPosition?: string; width?: number; height?: number; top?: number; left?: number; right?: number; bottom?: number; minWidth?: number; maxWidth?: number; minHeight?: number; maxHeight?: number; margin?: number; marginVertical?: number; marginHorizontal?: number; marginTop?: number; marginBottom?: number; marginLeft?: number; marginRight?: number; padding?: number; paddingVertical?: number; paddingHorizontal?: number; paddingTop?: number; paddingBottom?: number; paddingLeft?: number; paddingRight?: number; borderWidth?: number; borderTopWidth?: number; borderRightWidth?: number; borderBottomWidth?: number; borderLeftWidth?: number; position?: position; flexDirection?: flexDirection; flexWrap?: flexWrap; justifyContent?: justifyContent; alignItems?: alignItems; alignSelf?: alignSelf; overflow?: overflow; flex?: any; flexGrow?: number; flexShrink?: number; flexBasis?: true; zIndex?: number; shadowColor?: string; shadowOffset?: string; shadowOpacity?: number; shadowRadius?: string; tintColor?: tintColor; tintColors?: tintColors; underlineColorAndroid?: string; transform?: Transform[]; collapse?: boolean; } interface Style extends BaseStyle { [props: string]: any; } interface ConsoleModule { log: (...args: any[]) => void; info: (...args: any[]) => void; warn: (...args: any[]) => void; error: (...args: any[]) => void; debug: (...args: any[]) => void; } interface Dimensions { screenPhysicalPixels: { densityDpi?: number; fontScale?: number; height?: number; navigationBarHeight?: number; scale?: number; statusBarHeight?: number; width?: number; }; windowPhysicalPixels: { densityDpi?: number; fontScale?: number; height?: number; navigationBarHeight?: number; scale?: number; statusBarHeight?: number; width?: number; }; } interface Platform { APILevel?: number; Localization?: { country: string; language: string; direction: number; }; OS?: 'android' | 'ios' | 'web' | null; PackageName?: string; VersionName?: string; } interface __HIPPYNATIVEGLOBAL__ { Dimensions: Dimensions; Platform: Platform; } interface __GLOBAL__ { nodeId: number; reactRoots?: Map<number, any>; moduleCallId?: number; moduleCallList?: Object; jsModuleList?: any; animationId?: number; } interface Attributes { [key: string]: any; } interface AnimationStyle { animationId: number; } interface NativeStyle { [key: string]: null | string | number | number[] | AnimationStyle | AnimationStyle[]; } interface NativeNode { id: number; pId: number; name?: string; style?: NativeStyle; tagName?: string; props?: { [key: string]: NeedToTyped; attributes?: Attributes; }; } enum RelativeToRef { BEFORE = -1, AFTER = 1 } interface ReferenceInfo { readonly refId?: number; readonly relativeToRef?: RelativeToRef; } type PrintedNode = { [key: string]: any; } | undefined; type TranslatedNodes = [NativeNode, ReferenceInfo]; interface EventAttribute { name: string; type: number; isCapture: boolean; listener: (...args: any[]) => void; } type EventNode = undefined | { id: number; eventList: EventAttribute[]; }; type AnimationValue = number | { animationId: number | undefined; } | string; type AnimationCallback = () => void; type AnimationDirection = 'left' | 'right' | 'top' | 'bottom' | 'center'; type AnimationMode = 'timing'; type AnimationValueType = 'deg' | 'rad' | 'color' | undefined; type AnimationTimingFunction = 'linear' | 'ease' | 'bezier' | 'in' | 'ease-in' | 'out' | 'ease-out' | 'inOut' | 'ease-in-out' | (string & {}); interface AnimationOptions { startValue?: AnimationValue; toValue?: AnimationValue; duration?: number; mode?: AnimationMode; delay?: number; valueType?: AnimationValueType; direction?: AnimationDirection; timingFunction?: AnimationTimingFunction; repeatCount?: number; animation?: any; inputRange?: any[]; outputRange?: any[]; animationId?: number; } interface Animation extends AnimationOptions { onAnimationStartCallback?: AnimationCallback; onAnimationEndCallback?: AnimationCallback; onAnimationCancelCallback?: AnimationCallback; onAnimationRepeatCallback?: AnimationCallback; onHippyAnimationStart?: Function; onHippyAnimationEnd?: Function; onHippyAnimationCancel?: Function; onHippyAnimationRepeat?: Function; } type AnimationChildren = { animation: Animation; follow: boolean; }[]; type AnimationList = { animationId?: number | undefined; follow?: boolean; }[]; interface AnimationSetOptions { children: AnimationChildren; repeatCount: number | 'loop'; } interface AnimationSet { animationId: number; animationList: AnimationList; onHippyAnimationStart?: Function; onHippyAnimationEnd?: Function; onHippyAnimationCancel?: Function; onHippyAnimationRepeat?: Function; } interface AnimationInstance { getId: () => number; pause: () => void; resume: () => void; start: () => void; destroy: () => void; updateAnimation: (animation: any) => void; addEventListener: (eventName: string, cb: () => void) => void; removeEventListener: (eventName: string) => void; new (config: AnimationOptions): AnimationInstance; } type AnimationSetInstanceOptions = { children: AnimationList; repeatCount: number; }; interface AnimationSetInstance { getId: () => number; pause: () => void; resume: () => void; start: () => void; destroy: () => void; addEventListener: (eventName: string, cb: () => void) => void; removeEventListener: (eventName: string) => void; new (config: AnimationSetInstanceOptions): AnimationSetInstance; } interface AsyncStorage { getAllKeys: () => Promise<string[]>; getItem: (key: string) => Promise<string>; multiGet: (keys: string[]) => Promise<string[]>; multiRemove: (keys: string[]) => Promise<void>; multiSet: (keys: { [key: string]: string | number; }) => Promise<void>; removeItem: (key: string) => Promise<void>; setItem: (key: string, value: string | number) => Promise<void>; } interface Bridge { callNative: (moduleName: string, methodName: string, ...args: any[]) => void; callNativeWithCallbackId: (moduleName: string, methodName: string, ...args: any[]) => number; callNativeWithPromise: <T>(moduleName: string, methodName: string, ...args: any[]) => Promise<T>; removeNativeCallback: (callbackId: number) => void; } interface Sizes { fontScale: number; height: number; scale: number; statusBarHeight: number; width: number; } enum WebSocketReadyState { CONNECTING, OPEN, CLOSING, CLOSED } enum EventPhase { NONE, CAPTURING_PHASE, AT_TARGET, BUBBLING_PHASE } interface DOMEvent { id: number; currentId: number; target?: number | object; currentTarget?: number | object; params?: any; type: string; eventPhase: EventPhase; stopPropagation: () => void; } interface HippyWebSocket { url?: string; protocol?: string; readyState?: WebSocketReadyState; webSocketCallbacks?: { onOpen?: (...args: any[]) => void; onClose?: (...args: any[]) => void; onError?: (...args: any[]) => void; onMessage?: (...args: any[]) => void; }; webSocketCallbackId?: number; webSocketId?: number; } type WebSocket = HippyWebSocket | any; interface HippyConstance { Animation: AnimationInstance; AnimationSet: AnimationSetInstance; SceneBuilder: any; asyncStorage: AsyncStorage; bridge: Bridge; device: { cancelVibrate: () => void; vibrate: (pattern: number, repeatTimes?: number) => void; platform: { Localization: { country: string; language: string; direction: number; } | undefined; OS: Platform; APILevel?: number; }; screen: Sizes; window: Sizes; }; document: { createNode: (rootViewId: number, queue: NativeNode[]) => void; deleteNode: (rootViewId: number, queue: NativeNode[]) => void; endBatch: () => void; flushBatch: (rootViewId: number, queue: NativeNode[]) => void; sendRenderError: (err: Error) => void; startBatch: () => void; updateNode: (rootViewId: number, queue: NativeNode[]) => void; callUIFunction: (id: number, name: string, param: any[], cb: (param: any) => void) => void; }; on: (eventName: string, listener: () => void) => void; off: (eventName: string, listener?: () => void) => void; emit: (eventName: string, ...args: any[]) => void; register: { regist: (appName: string, entryFunc: (...args: any[]) => void) => void; }; } interface HippyGlobal { __GLOBAL__: __GLOBAL__; __HIPPYNATIVEGLOBAL__: __HIPPYNATIVEGLOBAL__; __PLATFORM__: __PLATFORM__; __HIPPYCURDIR__?: string; Hippy: HippyTypes.HippyConstance; WebSocket: WebSocket | any; ConsoleModule: ConsoleModule; HippyDealloc?: () => void; cancelIdleCallback?: (id: ReturnType<typeof setTimeout> | number) => void; dynamicLoad?: (path: string, encode: string, callback: (err: Error) => void) => void; getTurboModule?: (moduleName: string) => Object; } }