1 | import * as preact from './index';
|
2 |
|
3 | export enum HookType {
|
4 | useState = 1,
|
5 | useReducer = 2,
|
6 | useEffect = 3,
|
7 | useLayoutEffect = 4,
|
8 | useRef = 5,
|
9 | useImperativeHandle = 6,
|
10 | useMemo = 7,
|
11 | useCallback = 8,
|
12 | useContext = 9,
|
13 | useErrorBoundary = 10,
|
14 |
|
15 | useDebugvalue = 11
|
16 | }
|
17 |
|
18 | export interface Options extends preact.Options {
|
19 |
|
20 | _root?(
|
21 | vnode: preact.ComponentChild,
|
22 | parent: Element | Document | ShadowRoot | DocumentFragment
|
23 | ): void;
|
24 |
|
25 | _diff?(vnode: VNode): void;
|
26 |
|
27 | _commit?(vnode: VNode, commitQueue: Component[]): void;
|
28 |
|
29 | _render?(vnode: VNode): void;
|
30 |
|
31 | _hook?(component: Component, index: number, type: HookType): void;
|
32 |
|
33 | _skipEffects?: boolean;
|
34 |
|
35 | _catchError(error: any, vnode: VNode, oldVNode: VNode | undefined): void;
|
36 | }
|
37 |
|
38 | export interface FunctionalComponent<P = {}>
|
39 | extends preact.FunctionComponent<P> {
|
40 |
|
41 |
|
42 | getDerivedStateFromProps?: undefined;
|
43 | }
|
44 |
|
45 |
|
46 | export type ComponentFactory<P> =
|
47 | | preact.ComponentClass<P>
|
48 | | FunctionalComponent<P>;
|
49 |
|
50 | export interface PreactElement extends HTMLElement {
|
51 | _children?: VNode<any> | null;
|
52 |
|
53 | _listeners: Record<string, (e: Event) => void>;
|
54 |
|
55 |
|
56 | ownerSVGElement?: SVGElement | null;
|
57 |
|
58 |
|
59 |
|
60 | data?: string | number;
|
61 | }
|
62 |
|
63 | export interface VNode<P = {}> extends preact.VNode<P> {
|
64 |
|
65 | type: string | ComponentFactory<P>;
|
66 | props: P & { children: preact.ComponentChildren };
|
67 | _children: Array<VNode<any>> | null;
|
68 | _parent: VNode | null;
|
69 | _depth: number | null;
|
70 | |
71 |
|
72 |
|
73 | _dom: PreactElement | Text | null;
|
74 | |
75 |
|
76 |
|
77 | _nextDom: PreactElement | Text | null;
|
78 | _component: Component | null;
|
79 | constructor: undefined;
|
80 | _original?: VNode | null;
|
81 | }
|
82 |
|
83 | export interface Component<P = {}, S = {}> extends preact.Component<P, S> {
|
84 |
|
85 | constructor: preact.ComponentType<P>;
|
86 | state: S; // Override Component["state"] to not be readonly for internal use, specifically Hooks
|
87 | base?: PreactElement;
|
88 |
|
89 | _dirty: boolean;
|
90 | _force?: boolean;
|
91 | _renderCallbacks: Array<() => void>; // Only class components
|
92 | _globalContext?: any;
|
93 | _vnode?: VNode<P> | null;
|
94 | _nextState?: S | null; // Only class components
|
95 | /** Only used in the devtools to later dirty check if state has changed */
|
96 | _prevState?: S | null;
|
97 | /**
|
98 | * Pointer to the parent dom node. This is only needed for top-level Fragment
|
99 | * components or array returns.
|
100 | */
|
101 | _parentDom?: PreactElement | null;
|
102 | // Always read, set only when handling error
|
103 | _processingException?: Component<any, any> | null;
|
104 | // Always read, set only when handling error. This is used to indicate at diffTime to set _processingException
|
105 | _pendingError?: Component<any, any> | null;
|
106 | }
|
107 |
|
108 | export interface PreactContext extends preact.Context<any> {
|
109 | _id: string;
|
110 | _defaultValue: any;
|
111 | }
|