isomorfeus-preact 10.6.2 → 10.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/preact/version.rb +1 -1
  3. data/node_modules/.package-lock.json +3 -3
  4. data/node_modules/preact/LICENSE +21 -21
  5. data/node_modules/preact/README.md +187 -187
  6. data/node_modules/preact/compat/dist/compat.js +1 -1
  7. data/node_modules/preact/compat/dist/compat.js.map +1 -1
  8. data/node_modules/preact/compat/dist/compat.mjs +1 -1
  9. data/node_modules/preact/compat/dist/compat.module.js +1 -1
  10. data/node_modules/preact/compat/dist/compat.module.js.map +1 -1
  11. data/node_modules/preact/compat/dist/compat.umd.js +1 -1
  12. data/node_modules/preact/compat/dist/compat.umd.js.map +1 -1
  13. data/node_modules/preact/compat/jsx-dev-runtime.js +1 -1
  14. data/node_modules/preact/compat/jsx-dev-runtime.mjs +1 -1
  15. data/node_modules/preact/compat/jsx-runtime.js +1 -1
  16. data/node_modules/preact/compat/jsx-runtime.mjs +1 -1
  17. data/node_modules/preact/compat/package.json +19 -19
  18. data/node_modules/preact/compat/scheduler.js +15 -15
  19. data/node_modules/preact/compat/scheduler.mjs +23 -23
  20. data/node_modules/preact/compat/server.js +15 -15
  21. data/node_modules/preact/compat/server.mjs +4 -4
  22. data/node_modules/preact/compat/src/Children.js +21 -21
  23. data/node_modules/preact/compat/src/PureComponent.js +15 -15
  24. data/node_modules/preact/compat/src/forwardRef.js +51 -51
  25. data/node_modules/preact/compat/src/index.d.ts +141 -141
  26. data/node_modules/preact/compat/src/index.js +187 -187
  27. data/node_modules/preact/compat/src/internal.d.ts +47 -47
  28. data/node_modules/preact/compat/src/memo.js +34 -34
  29. data/node_modules/preact/compat/src/portals.js +80 -80
  30. data/node_modules/preact/compat/src/render.js +230 -226
  31. data/node_modules/preact/compat/src/suspense-list.d.ts +14 -14
  32. data/node_modules/preact/compat/src/suspense-list.js +126 -126
  33. data/node_modules/preact/compat/src/suspense.d.ts +15 -15
  34. data/node_modules/preact/compat/src/suspense.js +270 -270
  35. data/node_modules/preact/compat/src/util.js +28 -28
  36. data/node_modules/preact/compat/test-utils.js +1 -1
  37. data/node_modules/preact/debug/dist/debug.js.map +1 -1
  38. data/node_modules/preact/debug/dist/debug.module.js.map +1 -1
  39. data/node_modules/preact/debug/dist/debug.umd.js.map +1 -1
  40. data/node_modules/preact/debug/package.json +18 -18
  41. data/node_modules/preact/debug/src/check-props.js +54 -54
  42. data/node_modules/preact/debug/src/component-stack.js +146 -146
  43. data/node_modules/preact/debug/src/constants.js +3 -3
  44. data/node_modules/preact/debug/src/debug.js +442 -442
  45. data/node_modules/preact/debug/src/index.js +6 -6
  46. data/node_modules/preact/debug/src/internal.d.ts +82 -82
  47. data/node_modules/preact/debug/src/util.js +11 -11
  48. data/node_modules/preact/devtools/dist/devtools.js +1 -1
  49. data/node_modules/preact/devtools/dist/devtools.js.map +1 -1
  50. data/node_modules/preact/devtools/dist/devtools.mjs +1 -1
  51. data/node_modules/preact/devtools/dist/devtools.module.js +1 -1
  52. data/node_modules/preact/devtools/dist/devtools.module.js.map +1 -1
  53. data/node_modules/preact/devtools/dist/devtools.umd.js +1 -1
  54. data/node_modules/preact/devtools/dist/devtools.umd.js.map +1 -1
  55. data/node_modules/preact/devtools/package.json +16 -16
  56. data/node_modules/preact/devtools/src/devtools.js +10 -10
  57. data/node_modules/preact/devtools/src/index.d.ts +8 -8
  58. data/node_modules/preact/devtools/src/index.js +15 -15
  59. data/node_modules/preact/dist/preact.js.map +1 -1
  60. data/node_modules/preact/dist/preact.min.js.map +1 -1
  61. data/node_modules/preact/dist/preact.module.js.map +1 -1
  62. data/node_modules/preact/dist/preact.umd.js.map +1 -1
  63. data/node_modules/preact/hooks/dist/hooks.js +1 -1
  64. data/node_modules/preact/hooks/dist/hooks.js.map +1 -1
  65. data/node_modules/preact/hooks/dist/hooks.mjs +1 -1
  66. data/node_modules/preact/hooks/dist/hooks.module.js +1 -1
  67. data/node_modules/preact/hooks/dist/hooks.module.js.map +1 -1
  68. data/node_modules/preact/hooks/dist/hooks.umd.js +1 -1
  69. data/node_modules/preact/hooks/dist/hooks.umd.js.map +1 -1
  70. data/node_modules/preact/hooks/package.json +26 -26
  71. data/node_modules/preact/hooks/src/index.d.ts +139 -139
  72. data/node_modules/preact/hooks/src/index.js +388 -387
  73. data/node_modules/preact/hooks/src/internal.d.ts +75 -75
  74. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -1
  75. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -1
  76. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
  77. data/node_modules/preact/jsx-runtime/package.json +19 -19
  78. data/node_modules/preact/jsx-runtime/src/index.d.ts +50 -50
  79. data/node_modules/preact/jsx-runtime/src/index.js +77 -77
  80. data/node_modules/preact/package.json +287 -287
  81. data/node_modules/preact/src/cjs.js +3 -3
  82. data/node_modules/preact/src/clone-element.js +34 -34
  83. data/node_modules/preact/src/component.js +225 -225
  84. data/node_modules/preact/src/constants.js +3 -3
  85. data/node_modules/preact/src/create-context.js +68 -68
  86. data/node_modules/preact/src/create-element.js +98 -98
  87. data/node_modules/preact/src/diff/catch-error.js +38 -38
  88. data/node_modules/preact/src/diff/children.js +335 -335
  89. data/node_modules/preact/src/diff/index.js +516 -516
  90. data/node_modules/preact/src/diff/props.js +158 -158
  91. data/node_modules/preact/src/index.d.ts +310 -310
  92. data/node_modules/preact/src/index.js +13 -13
  93. data/node_modules/preact/src/internal.d.ts +146 -146
  94. data/node_modules/preact/src/jsx.d.ts +1005 -1005
  95. data/node_modules/preact/src/options.js +16 -16
  96. data/node_modules/preact/src/render.js +75 -75
  97. data/node_modules/preact/src/util.js +27 -27
  98. data/node_modules/preact/test-utils/dist/testUtils.js.map +1 -1
  99. data/node_modules/preact/test-utils/dist/testUtils.module.js.map +1 -1
  100. data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +1 -1
  101. data/node_modules/preact/test-utils/package.json +19 -19
  102. data/node_modules/preact/test-utils/src/index.d.ts +3 -3
  103. data/node_modules/preact/test-utils/src/index.js +117 -117
  104. data/package.json +1 -1
  105. metadata +17 -37
  106. data/node_modules/preact/compat/dist/compat.mjs.map +0 -1
  107. data/node_modules/preact/compat/dist/compat.modern.js +0 -2
  108. data/node_modules/preact/compat/dist/compat.modern.js.map +0 -1
  109. data/node_modules/preact/debug/dist/debug.mjs.map +0 -1
  110. data/node_modules/preact/debug/dist/debug.modern.js +0 -2
  111. data/node_modules/preact/debug/dist/debug.modern.js.map +0 -1
  112. data/node_modules/preact/devtools/dist/devtools.mjs.map +0 -1
  113. data/node_modules/preact/devtools/dist/devtools.modern.js +0 -2
  114. data/node_modules/preact/devtools/dist/devtools.modern.js.map +0 -1
  115. data/node_modules/preact/dist/index.d.ts +0 -1295
  116. data/node_modules/preact/dist/preact.mjs.map +0 -1
  117. data/node_modules/preact/hooks/dist/hooks.mjs.map +0 -1
  118. data/node_modules/preact/hooks/dist/hooks.modern.js +0 -2
  119. data/node_modules/preact/hooks/dist/hooks.modern.js.map +0 -1
  120. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs.map +0 -1
  121. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.modern.js +0 -2
  122. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.modern.js.map +0 -1
  123. data/node_modules/preact/test-utils/dist/testUtils.mjs.map +0 -1
  124. data/node_modules/preact/test-utils/dist/testUtils.modern.js +0 -2
  125. data/node_modules/preact/test-utils/dist/testUtils.modern.js.map +0 -1
@@ -1,310 +1,310 @@
1
- export as namespace preact;
2
-
3
- import { JSXInternal } from './jsx';
4
-
5
- export import JSX = JSXInternal;
6
-
7
- //
8
- // Preact Virtual DOM
9
- // -----------------------------------
10
-
11
- export interface VNode<P = {}> {
12
- type: ComponentType<P> | string;
13
- props: P & { children: ComponentChildren };
14
- key: Key;
15
- /**
16
- * ref is not guaranteed by React.ReactElement, for compatibility reasons
17
- * with popular react libs we define it as optional too
18
- */
19
- ref?: Ref<any> | null;
20
- /**
21
- * The time this `vnode` started rendering. Will only be set when
22
- * the devtools are attached.
23
- * Default value: `0`
24
- */
25
- startTime?: number;
26
- /**
27
- * The time that the rendering of this `vnode` was completed. Will only be
28
- * set when the devtools are attached.
29
- * Default value: `-1`
30
- */
31
- endTime?: number;
32
- }
33
-
34
- //
35
- // Preact Component interface
36
- // -----------------------------------
37
-
38
- export type Key = string | number | any;
39
-
40
- export type RefObject<T> = { current: T | null };
41
- export type RefCallback<T> = (instance: T | null) => void;
42
- export type Ref<T> = RefObject<T> | RefCallback<T>;
43
-
44
- export type ComponentChild =
45
- | VNode<any>
46
- | object
47
- | string
48
- | number
49
- | bigint
50
- | boolean
51
- | null
52
- | undefined;
53
- export type ComponentChildren = ComponentChild[] | ComponentChild;
54
-
55
- export interface Attributes {
56
- key?: Key;
57
- jsx?: boolean;
58
- }
59
-
60
- export interface ClassAttributes<T> extends Attributes {
61
- ref?: Ref<T>;
62
- }
63
-
64
- export interface PreactDOMAttributes {
65
- children?: ComponentChildren;
66
- dangerouslySetInnerHTML?: {
67
- __html: string;
68
- };
69
- }
70
-
71
- export type RenderableProps<P, RefType = any> = P &
72
- Readonly<Attributes & { children?: ComponentChildren; ref?: Ref<RefType> }>;
73
-
74
- export type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
75
- export type ComponentFactory<P = {}> = ComponentType<P>;
76
-
77
- export type ComponentProps<
78
- C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
79
- > = C extends ComponentType<infer P>
80
- ? P
81
- : C extends keyof JSXInternal.IntrinsicElements
82
- ? JSXInternal.IntrinsicElements[C]
83
- : never;
84
-
85
- export interface FunctionComponent<P = {}> {
86
- (props: RenderableProps<P>, context?: any): VNode<any> | null;
87
- displayName?: string;
88
- defaultProps?: Partial<P>;
89
- }
90
- export interface FunctionalComponent<P = {}> extends FunctionComponent<P> {}
91
-
92
- export interface ComponentClass<P = {}, S = {}> {
93
- new (props: P, context?: any): Component<P, S>;
94
- displayName?: string;
95
- defaultProps?: Partial<P>;
96
- contextType?: Context<any>;
97
- getDerivedStateFromProps?(
98
- props: Readonly<P>,
99
- state: Readonly<S>
100
- ): Partial<S> | null;
101
- getDerivedStateFromError?(error: any): Partial<S> | null;
102
- }
103
- export interface ComponentConstructor<P = {}, S = {}>
104
- extends ComponentClass<P, S> {}
105
-
106
- // Type alias for a component instance considered generally, whether stateless or stateful.
107
- export type AnyComponent<P = {}, S = {}> =
108
- | FunctionComponent<P>
109
- | Component<P, S>;
110
-
111
- export interface Component<P = {}, S = {}> {
112
- componentWillMount?(): void;
113
- componentDidMount?(): void;
114
- componentWillUnmount?(): void;
115
- getChildContext?(): object;
116
- componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
117
- shouldComponentUpdate?(
118
- nextProps: Readonly<P>,
119
- nextState: Readonly<S>,
120
- nextContext: any
121
- ): boolean;
122
- componentWillUpdate?(
123
- nextProps: Readonly<P>,
124
- nextState: Readonly<S>,
125
- nextContext: any
126
- ): void;
127
- getSnapshotBeforeUpdate?(oldProps: Readonly<P>, oldState: Readonly<S>): any;
128
- componentDidUpdate?(
129
- previousProps: Readonly<P>,
130
- previousState: Readonly<S>,
131
- snapshot: any
132
- ): void;
133
- componentDidCatch?(error: any, errorInfo: any): void;
134
- }
135
-
136
- export abstract class Component<P, S> {
137
- constructor(props?: P, context?: any);
138
-
139
- static displayName?: string;
140
- static defaultProps?: any;
141
- static contextType?: Context<any>;
142
-
143
- // Static members cannot reference class type parameters. This is not
144
- // supported in TypeScript. Reusing the same type arguments from `Component`
145
- // will lead to an impossible state where one cannot satisfy the type
146
- // constraint under no circumstances, see #1356.In general type arguments
147
- // seem to be a bit buggy and not supported well at the time of this
148
- // writing with TS 3.3.3333.
149
- static getDerivedStateFromProps?(
150
- props: Readonly<object>,
151
- state: Readonly<object>
152
- ): object | null;
153
- static getDerivedStateFromError?(error: any): object | null;
154
-
155
- state: Readonly<S>;
156
- props: RenderableProps<P>;
157
- context: any;
158
- base?: Element | Text;
159
-
160
- // From https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e836acc75a78cf0655b5dfdbe81d69fdd4d8a252/types/react/index.d.ts#L402
161
- // // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
162
- // // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
163
- setState<K extends keyof S>(
164
- state:
165
- | ((
166
- prevState: Readonly<S>,
167
- props: Readonly<P>
168
- ) => Pick<S, K> | Partial<S> | null)
169
- | (Pick<S, K> | Partial<S> | null),
170
- callback?: () => void
171
- ): void;
172
-
173
- forceUpdate(callback?: () => void): void;
174
-
175
- abstract render(
176
- props?: RenderableProps<P>,
177
- state?: Readonly<S>,
178
- context?: any
179
- ): ComponentChild;
180
- }
181
-
182
- //
183
- // Preact createElement
184
- // -----------------------------------
185
-
186
- export function createElement(
187
- type: string,
188
- props:
189
- | (JSXInternal.HTMLAttributes &
190
- JSXInternal.SVGAttributes &
191
- Record<string, any>)
192
- | null,
193
- ...children: ComponentChildren[]
194
- ): VNode<any>;
195
- export function createElement<P>(
196
- type: ComponentType<P>,
197
- props: (Attributes & P) | null,
198
- ...children: ComponentChildren[]
199
- ): VNode<any>;
200
- export namespace createElement {
201
- export import JSX = JSXInternal;
202
- }
203
-
204
- export function h(
205
- type: string,
206
- props:
207
- | (JSXInternal.HTMLAttributes &
208
- JSXInternal.SVGAttributes &
209
- Record<string, any>)
210
- | null,
211
- ...children: ComponentChildren[]
212
- ): VNode<any>;
213
- export function h<P>(
214
- type: ComponentType<P>,
215
- props: (Attributes & P) | null,
216
- ...children: ComponentChildren[]
217
- ): VNode<any>;
218
- export namespace h {
219
- export import JSX = JSXInternal;
220
- }
221
-
222
- //
223
- // Preact render
224
- // -----------------------------------
225
-
226
- export function render(
227
- vnode: ComponentChild,
228
- parent: Element | Document | ShadowRoot | DocumentFragment,
229
- replaceNode?: Element | Text
230
- ): void;
231
- export function hydrate(
232
- vnode: ComponentChild,
233
- parent: Element | Document | ShadowRoot | DocumentFragment
234
- ): void;
235
- export function cloneElement(
236
- vnode: VNode<any>,
237
- props?: any,
238
- ...children: ComponentChildren[]
239
- ): VNode<any>;
240
- export function cloneElement<P>(
241
- vnode: VNode<P>,
242
- props?: any,
243
- ...children: ComponentChildren[]
244
- ): VNode<P>;
245
-
246
- //
247
- // Preact Built-in Components
248
- // -----------------------------------
249
-
250
- // TODO: Revisit what the public type of this is...
251
- export const Fragment: ComponentClass<{}, {}>;
252
-
253
- //
254
- // Preact options
255
- // -----------------------------------
256
-
257
- /**
258
- * Global options for preact
259
- */
260
- export interface Options {
261
- /** Attach a hook that is invoked whenever a VNode is created. */
262
- vnode?(vnode: VNode): void;
263
- /** Attach a hook that is invoked immediately before a vnode is unmounted. */
264
- unmount?(vnode: VNode): void;
265
- /** Attach a hook that is invoked after a vnode has rendered. */
266
- diffed?(vnode: VNode): void;
267
- event?(e: Event): any;
268
- requestAnimationFrame?(callback: () => void): void;
269
- debounceRendering?(cb: () => void): void;
270
- useDebugValue?(value: string | number): void;
271
- _addHookName?(name: string | number): void;
272
- __suspenseDidResolve?(vnode: VNode, cb: () => void): void;
273
- // __canSuspenseResolve?(vnode: VNode, cb: () => void): void;
274
- }
275
-
276
- export const options: Options;
277
-
278
- //
279
- // Preact helpers
280
- // -----------------------------------
281
- export function createRef<T = any>(): RefObject<T>;
282
- export function toChildArray(
283
- children: ComponentChildren
284
- ): Array<VNode | string | number>;
285
- export function isValidElement(vnode: any): vnode is VNode;
286
-
287
- //
288
- // Context
289
- // -----------------------------------
290
- export interface Consumer<T>
291
- extends FunctionComponent<{
292
- children: (value: T) => ComponentChildren;
293
- }> {}
294
- export interface PreactConsumer<T> extends Consumer<T> {}
295
-
296
- export interface Provider<T>
297
- extends FunctionComponent<{
298
- value: T;
299
- children: ComponentChildren;
300
- }> {}
301
- export interface PreactProvider<T> extends Provider<T> {}
302
-
303
- export interface Context<T> {
304
- Consumer: Consumer<T>;
305
- Provider: Provider<T>;
306
- displayName?: string;
307
- }
308
- export interface PreactContext<T> extends Context<T> {}
309
-
310
- export function createContext<T>(defaultValue: T): Context<T>;
1
+ export as namespace preact;
2
+
3
+ import { JSXInternal } from './jsx';
4
+
5
+ export import JSX = JSXInternal;
6
+
7
+ //
8
+ // Preact Virtual DOM
9
+ // -----------------------------------
10
+
11
+ export interface VNode<P = {}> {
12
+ type: ComponentType<P> | string;
13
+ props: P & { children: ComponentChildren };
14
+ key: Key;
15
+ /**
16
+ * ref is not guaranteed by React.ReactElement, for compatibility reasons
17
+ * with popular react libs we define it as optional too
18
+ */
19
+ ref?: Ref<any> | null;
20
+ /**
21
+ * The time this `vnode` started rendering. Will only be set when
22
+ * the devtools are attached.
23
+ * Default value: `0`
24
+ */
25
+ startTime?: number;
26
+ /**
27
+ * The time that the rendering of this `vnode` was completed. Will only be
28
+ * set when the devtools are attached.
29
+ * Default value: `-1`
30
+ */
31
+ endTime?: number;
32
+ }
33
+
34
+ //
35
+ // Preact Component interface
36
+ // -----------------------------------
37
+
38
+ export type Key = string | number | any;
39
+
40
+ export type RefObject<T> = { current: T | null };
41
+ export type RefCallback<T> = (instance: T | null) => void;
42
+ export type Ref<T> = RefObject<T> | RefCallback<T>;
43
+
44
+ export type ComponentChild =
45
+ | VNode<any>
46
+ | object
47
+ | string
48
+ | number
49
+ | bigint
50
+ | boolean
51
+ | null
52
+ | undefined;
53
+ export type ComponentChildren = ComponentChild[] | ComponentChild;
54
+
55
+ export interface Attributes {
56
+ key?: Key;
57
+ jsx?: boolean;
58
+ }
59
+
60
+ export interface ClassAttributes<T> extends Attributes {
61
+ ref?: Ref<T>;
62
+ }
63
+
64
+ export interface PreactDOMAttributes {
65
+ children?: ComponentChildren;
66
+ dangerouslySetInnerHTML?: {
67
+ __html: string;
68
+ };
69
+ }
70
+
71
+ export type RenderableProps<P, RefType = any> = P &
72
+ Readonly<Attributes & { children?: ComponentChildren; ref?: Ref<RefType> }>;
73
+
74
+ export type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
75
+ export type ComponentFactory<P = {}> = ComponentType<P>;
76
+
77
+ export type ComponentProps<
78
+ C extends ComponentType<any> | keyof JSXInternal.IntrinsicElements
79
+ > = C extends ComponentType<infer P>
80
+ ? P
81
+ : C extends keyof JSXInternal.IntrinsicElements
82
+ ? JSXInternal.IntrinsicElements[C]
83
+ : never;
84
+
85
+ export interface FunctionComponent<P = {}> {
86
+ (props: RenderableProps<P>, context?: any): VNode<any> | null;
87
+ displayName?: string;
88
+ defaultProps?: Partial<P>;
89
+ }
90
+ export interface FunctionalComponent<P = {}> extends FunctionComponent<P> {}
91
+
92
+ export interface ComponentClass<P = {}, S = {}> {
93
+ new (props: P, context?: any): Component<P, S>;
94
+ displayName?: string;
95
+ defaultProps?: Partial<P>;
96
+ contextType?: Context<any>;
97
+ getDerivedStateFromProps?(
98
+ props: Readonly<P>,
99
+ state: Readonly<S>
100
+ ): Partial<S> | null;
101
+ getDerivedStateFromError?(error: any): Partial<S> | null;
102
+ }
103
+ export interface ComponentConstructor<P = {}, S = {}>
104
+ extends ComponentClass<P, S> {}
105
+
106
+ // Type alias for a component instance considered generally, whether stateless or stateful.
107
+ export type AnyComponent<P = {}, S = {}> =
108
+ | FunctionComponent<P>
109
+ | Component<P, S>;
110
+
111
+ export interface Component<P = {}, S = {}> {
112
+ componentWillMount?(): void;
113
+ componentDidMount?(): void;
114
+ componentWillUnmount?(): void;
115
+ getChildContext?(): object;
116
+ componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
117
+ shouldComponentUpdate?(
118
+ nextProps: Readonly<P>,
119
+ nextState: Readonly<S>,
120
+ nextContext: any
121
+ ): boolean;
122
+ componentWillUpdate?(
123
+ nextProps: Readonly<P>,
124
+ nextState: Readonly<S>,
125
+ nextContext: any
126
+ ): void;
127
+ getSnapshotBeforeUpdate?(oldProps: Readonly<P>, oldState: Readonly<S>): any;
128
+ componentDidUpdate?(
129
+ previousProps: Readonly<P>,
130
+ previousState: Readonly<S>,
131
+ snapshot: any
132
+ ): void;
133
+ componentDidCatch?(error: any, errorInfo: any): void;
134
+ }
135
+
136
+ export abstract class Component<P, S> {
137
+ constructor(props?: P, context?: any);
138
+
139
+ static displayName?: string;
140
+ static defaultProps?: any;
141
+ static contextType?: Context<any>;
142
+
143
+ // Static members cannot reference class type parameters. This is not
144
+ // supported in TypeScript. Reusing the same type arguments from `Component`
145
+ // will lead to an impossible state where one cannot satisfy the type
146
+ // constraint under no circumstances, see #1356.In general type arguments
147
+ // seem to be a bit buggy and not supported well at the time of this
148
+ // writing with TS 3.3.3333.
149
+ static getDerivedStateFromProps?(
150
+ props: Readonly<object>,
151
+ state: Readonly<object>
152
+ ): object | null;
153
+ static getDerivedStateFromError?(error: any): object | null;
154
+
155
+ state: Readonly<S>;
156
+ props: RenderableProps<P>;
157
+ context: any;
158
+ base?: Element | Text;
159
+
160
+ // From https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e836acc75a78cf0655b5dfdbe81d69fdd4d8a252/types/react/index.d.ts#L402
161
+ // // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
162
+ // // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
163
+ setState<K extends keyof S>(
164
+ state:
165
+ | ((
166
+ prevState: Readonly<S>,
167
+ props: Readonly<P>
168
+ ) => Pick<S, K> | Partial<S> | null)
169
+ | (Pick<S, K> | Partial<S> | null),
170
+ callback?: () => void
171
+ ): void;
172
+
173
+ forceUpdate(callback?: () => void): void;
174
+
175
+ abstract render(
176
+ props?: RenderableProps<P>,
177
+ state?: Readonly<S>,
178
+ context?: any
179
+ ): ComponentChild;
180
+ }
181
+
182
+ //
183
+ // Preact createElement
184
+ // -----------------------------------
185
+
186
+ export function createElement(
187
+ type: string,
188
+ props:
189
+ | (JSXInternal.HTMLAttributes &
190
+ JSXInternal.SVGAttributes &
191
+ Record<string, any>)
192
+ | null,
193
+ ...children: ComponentChildren[]
194
+ ): VNode<any>;
195
+ export function createElement<P>(
196
+ type: ComponentType<P>,
197
+ props: (Attributes & P) | null,
198
+ ...children: ComponentChildren[]
199
+ ): VNode<any>;
200
+ export namespace createElement {
201
+ export import JSX = JSXInternal;
202
+ }
203
+
204
+ export function h(
205
+ type: string,
206
+ props:
207
+ | (JSXInternal.HTMLAttributes &
208
+ JSXInternal.SVGAttributes &
209
+ Record<string, any>)
210
+ | null,
211
+ ...children: ComponentChildren[]
212
+ ): VNode<any>;
213
+ export function h<P>(
214
+ type: ComponentType<P>,
215
+ props: (Attributes & P) | null,
216
+ ...children: ComponentChildren[]
217
+ ): VNode<any>;
218
+ export namespace h {
219
+ export import JSX = JSXInternal;
220
+ }
221
+
222
+ //
223
+ // Preact render
224
+ // -----------------------------------
225
+
226
+ export function render(
227
+ vnode: ComponentChild,
228
+ parent: Element | Document | ShadowRoot | DocumentFragment,
229
+ replaceNode?: Element | Text
230
+ ): void;
231
+ export function hydrate(
232
+ vnode: ComponentChild,
233
+ parent: Element | Document | ShadowRoot | DocumentFragment
234
+ ): void;
235
+ export function cloneElement(
236
+ vnode: VNode<any>,
237
+ props?: any,
238
+ ...children: ComponentChildren[]
239
+ ): VNode<any>;
240
+ export function cloneElement<P>(
241
+ vnode: VNode<P>,
242
+ props?: any,
243
+ ...children: ComponentChildren[]
244
+ ): VNode<P>;
245
+
246
+ //
247
+ // Preact Built-in Components
248
+ // -----------------------------------
249
+
250
+ // TODO: Revisit what the public type of this is...
251
+ export const Fragment: ComponentClass<{}, {}>;
252
+
253
+ //
254
+ // Preact options
255
+ // -----------------------------------
256
+
257
+ /**
258
+ * Global options for preact
259
+ */
260
+ export interface Options {
261
+ /** Attach a hook that is invoked whenever a VNode is created. */
262
+ vnode?(vnode: VNode): void;
263
+ /** Attach a hook that is invoked immediately before a vnode is unmounted. */
264
+ unmount?(vnode: VNode): void;
265
+ /** Attach a hook that is invoked after a vnode has rendered. */
266
+ diffed?(vnode: VNode): void;
267
+ event?(e: Event): any;
268
+ requestAnimationFrame?(callback: () => void): void;
269
+ debounceRendering?(cb: () => void): void;
270
+ useDebugValue?(value: string | number): void;
271
+ _addHookName?(name: string | number): void;
272
+ __suspenseDidResolve?(vnode: VNode, cb: () => void): void;
273
+ // __canSuspenseResolve?(vnode: VNode, cb: () => void): void;
274
+ }
275
+
276
+ export const options: Options;
277
+
278
+ //
279
+ // Preact helpers
280
+ // -----------------------------------
281
+ export function createRef<T = any>(): RefObject<T>;
282
+ export function toChildArray(
283
+ children: ComponentChildren
284
+ ): Array<VNode | string | number>;
285
+ export function isValidElement(vnode: any): vnode is VNode;
286
+
287
+ //
288
+ // Context
289
+ // -----------------------------------
290
+ export interface Consumer<T>
291
+ extends FunctionComponent<{
292
+ children: (value: T) => ComponentChildren;
293
+ }> {}
294
+ export interface PreactConsumer<T> extends Consumer<T> {}
295
+
296
+ export interface Provider<T>
297
+ extends FunctionComponent<{
298
+ value: T;
299
+ children: ComponentChildren;
300
+ }> {}
301
+ export interface PreactProvider<T> extends Provider<T> {}
302
+
303
+ export interface Context<T> {
304
+ Consumer: Consumer<T>;
305
+ Provider: Provider<T>;
306
+ displayName?: string;
307
+ }
308
+ export interface PreactContext<T> extends Context<T> {}
309
+
310
+ export function createContext<T>(defaultValue: T): Context<T>;
@@ -1,13 +1,13 @@
1
- export { render, hydrate } from './render';
2
- export {
3
- createElement,
4
- createElement as h,
5
- Fragment,
6
- createRef,
7
- isValidElement
8
- } from './create-element';
9
- export { Component } from './component';
10
- export { cloneElement } from './clone-element';
11
- export { createContext } from './create-context';
12
- export { toChildArray } from './diff/children';
13
- export { default as options } from './options';
1
+ export { render, hydrate } from './render';
2
+ export {
3
+ createElement,
4
+ createElement as h,
5
+ Fragment,
6
+ createRef,
7
+ isValidElement
8
+ } from './create-element';
9
+ export { Component } from './component';
10
+ export { cloneElement } from './clone-element';
11
+ export { createContext } from './create-context';
12
+ export { toChildArray } from './diff/children';
13
+ export { default as options } from './options';