rask-ui 0.20.4 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.js +11 -0
- package/dist/createComputed.d.ts +4 -0
- package/dist/createComputed.d.ts.map +1 -0
- package/dist/createComputed.js +69 -0
- package/dist/createEffect.d.ts +2 -0
- package/dist/createEffect.d.ts.map +1 -0
- package/dist/createEffect.js +29 -0
- package/dist/createRouter.d.ts +8 -0
- package/dist/createRouter.d.ts.map +1 -0
- package/dist/createRouter.js +27 -0
- package/dist/createState.d.ts +2 -0
- package/dist/createState.d.ts.map +1 -1
- package/dist/createState.js +40 -5
- package/dist/createTask.d.ts +31 -0
- package/dist/createTask.d.ts.map +1 -0
- package/dist/createTask.js +79 -0
- package/dist/createView.d.ts +18 -44
- package/dist/createView.d.ts.map +1 -1
- package/dist/createView.js +57 -48
- package/dist/error.d.ts +3 -14
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +14 -15
- package/dist/jsx.d.ts +10 -256
- package/dist/patchInferno.d.ts +6 -0
- package/dist/patchInferno.d.ts.map +1 -0
- package/dist/patchInferno.js +53 -0
- package/dist/scheduler.d.ts +4 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +107 -0
- package/dist/tests/batch.test.d.ts +2 -0
- package/dist/tests/batch.test.d.ts.map +1 -0
- package/dist/tests/batch.test.js +244 -0
- package/dist/tests/createComputed.test.d.ts +2 -0
- package/dist/tests/createComputed.test.d.ts.map +1 -0
- package/dist/tests/createComputed.test.js +257 -0
- package/dist/tests/createContext.test.d.ts +2 -0
- package/dist/tests/createContext.test.d.ts.map +1 -0
- package/dist/tests/createContext.test.js +136 -0
- package/dist/tests/createEffect.test.d.ts +2 -0
- package/dist/tests/createEffect.test.d.ts.map +1 -0
- package/dist/tests/createEffect.test.js +467 -0
- package/dist/tests/createState.test.d.ts.map +1 -0
- package/dist/tests/createState.test.js +144 -0
- package/dist/tests/createTask.test.d.ts +2 -0
- package/dist/tests/createTask.test.d.ts.map +1 -0
- package/dist/tests/createTask.test.js +322 -0
- package/dist/tests/createView.test.d.ts.map +1 -0
- package/dist/{createView.test.js → tests/createView.test.js} +40 -40
- package/dist/tests/error.test.d.ts +2 -0
- package/dist/tests/error.test.d.ts.map +1 -0
- package/dist/tests/error.test.js +168 -0
- package/dist/tests/observation.test.d.ts.map +1 -0
- package/dist/tests/observation.test.js +341 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useComputed.d.ts +5 -0
- package/dist/useComputed.d.ts.map +1 -0
- package/dist/useComputed.js +69 -0
- package/dist/useQuery.d.ts +25 -0
- package/dist/useQuery.d.ts.map +1 -0
- package/dist/useQuery.js +25 -0
- package/dist/useSuspendAsync.d.ts +18 -0
- package/dist/useSuspendAsync.d.ts.map +1 -0
- package/dist/useSuspendAsync.js +37 -0
- package/dist/useTask.d.ts +25 -0
- package/dist/useTask.d.ts.map +1 -0
- package/dist/useTask.js +70 -0
- package/package.json +1 -1
- package/swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm +0 -0
- package/dist/asyncState.d.ts +0 -16
- package/dist/asyncState.d.ts.map +0 -1
- package/dist/asyncState.js +0 -24
- package/dist/context.d.ts +0 -5
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -29
- package/dist/createAsync.test.d.ts +0 -2
- package/dist/createAsync.test.d.ts.map +0 -1
- package/dist/createAsync.test.js +0 -110
- package/dist/createMutation.test.d.ts +0 -2
- package/dist/createMutation.test.d.ts.map +0 -1
- package/dist/createMutation.test.js +0 -168
- package/dist/createQuery.test.d.ts +0 -2
- package/dist/createQuery.test.d.ts.map +0 -1
- package/dist/createQuery.test.js +0 -156
- package/dist/createRef.d.ts +0 -6
- package/dist/createRef.d.ts.map +0 -1
- package/dist/createRef.js +0 -8
- package/dist/createState.test.d.ts.map +0 -1
- package/dist/createState.test.js +0 -111
- package/dist/createView.test.d.ts.map +0 -1
- package/dist/observation.test.d.ts.map +0 -1
- package/dist/observation.test.js +0 -150
- package/dist/suspense.d.ts +0 -25
- package/dist/suspense.d.ts.map +0 -1
- package/dist/suspense.js +0 -97
- package/dist/test-setup.d.ts +0 -16
- package/dist/test-setup.d.ts.map +0 -1
- package/dist/test-setup.js +0 -40
- package/dist/test.d.ts +0 -2
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -24
- /package/dist/{createState.test.d.ts → tests/createState.test.d.ts} +0 -0
- /package/dist/{createView.test.d.ts → tests/createView.test.d.ts} +0 -0
- /package/dist/{observation.test.d.ts → tests/observation.test.d.ts} +0 -0
package/dist/error.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
state = { error: null };
|
|
11
|
-
render() {
|
|
12
|
-
if (this.state.error) {
|
|
13
|
-
return this.props.error(this.state.error);
|
|
14
|
-
}
|
|
15
|
-
return this.props.children;
|
|
1
|
+
import { useState } from "./useState";
|
|
2
|
+
import { createContext, useInjectContext } from "./createContext";
|
|
3
|
+
import { getCurrentComponent } from "./component";
|
|
4
|
+
export const CatchErrorContext = createContext();
|
|
5
|
+
export function useCatchError() {
|
|
6
|
+
const currentComponent = getCurrentComponent();
|
|
7
|
+
if (!currentComponent || currentComponent.isRendering) {
|
|
8
|
+
throw new Error("Only use the useCatchError hook in setup");
|
|
16
9
|
}
|
|
10
|
+
const inject = useInjectContext(CatchErrorContext);
|
|
11
|
+
const state = useState({
|
|
12
|
+
error: null,
|
|
13
|
+
});
|
|
14
|
+
inject((error) => (state.error = error));
|
|
15
|
+
return state;
|
|
17
16
|
}
|
package/dist/jsx.d.ts
CHANGED
|
@@ -1,257 +1,11 @@
|
|
|
1
1
|
// JSX type definitions
|
|
2
|
-
//
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface ElementChildrenAttribute {
|
|
13
|
-
children: {};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface IntrinsicAttributes {
|
|
17
|
-
key?: any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// CSS Properties
|
|
21
|
-
export type CSSProperties = {
|
|
22
|
-
[key: string]: string | number | undefined;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Common HTML Attributes
|
|
26
|
-
export interface HTMLAttributes<T = HTMLElement> {
|
|
27
|
-
ref?: Ref<T> | ((element: T | null) => void);
|
|
28
|
-
id?: string;
|
|
29
|
-
class?: string | Record<string, boolean>;
|
|
30
|
-
style?: string | CSSProperties;
|
|
31
|
-
title?: string;
|
|
32
|
-
role?: string;
|
|
33
|
-
tabIndex?: number;
|
|
34
|
-
|
|
35
|
-
onClick?: (event: MouseEvent) => void;
|
|
36
|
-
onDblClick?: (event: MouseEvent) => void;
|
|
37
|
-
onChange?: (event: Event) => void;
|
|
38
|
-
onInput?: (event: Event) => void;
|
|
39
|
-
onSubmit?: (event: Event) => void;
|
|
40
|
-
onFocus?: (event: FocusEvent) => void;
|
|
41
|
-
onBlur?: (event: FocusEvent) => void;
|
|
42
|
-
onKeyDown?: (event: KeyboardEvent) => void;
|
|
43
|
-
onKeyUp?: (event: KeyboardEvent) => void;
|
|
44
|
-
onKeyPress?: (event: KeyboardEvent) => void;
|
|
45
|
-
onMouseDown?: (event: MouseEvent) => void;
|
|
46
|
-
onMouseUp?: (event: MouseEvent) => void;
|
|
47
|
-
onMouseEnter?: (event: MouseEvent) => void;
|
|
48
|
-
onMouseLeave?: (event: MouseEvent) => void;
|
|
49
|
-
onMouseMove?: (event: MouseEvent) => void;
|
|
50
|
-
onMouseOver?: (event: MouseEvent) => void;
|
|
51
|
-
onMouseOut?: (event: MouseEvent) => void;
|
|
52
|
-
onWheel?: (event: WheelEvent) => void;
|
|
53
|
-
onScroll?: (event: Event) => void;
|
|
54
|
-
onTouchStart?: (event: TouchEvent) => void;
|
|
55
|
-
onTouchEnd?: (event: TouchEvent) => void;
|
|
56
|
-
onTouchMove?: (event: TouchEvent) => void;
|
|
57
|
-
onTouchCancel?: (event: TouchEvent) => void;
|
|
58
|
-
|
|
59
|
-
[key: `aria-${string}`]: string | boolean | number | undefined;
|
|
60
|
-
[key: `data-${string}`]: string | boolean | number | undefined;
|
|
61
|
-
|
|
62
|
-
children?: any;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface AnchorHTMLAttributes<T = HTMLAnchorElement>
|
|
66
|
-
extends HTMLAttributes<T> {
|
|
67
|
-
href?: string;
|
|
68
|
-
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
69
|
-
rel?: string;
|
|
70
|
-
download?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface ButtonHTMLAttributes<T = HTMLButtonElement>
|
|
74
|
-
extends HTMLAttributes<T> {
|
|
75
|
-
type?: "button" | "submit" | "reset";
|
|
76
|
-
disabled?: boolean;
|
|
77
|
-
name?: string;
|
|
78
|
-
value?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface FormHTMLAttributes<T = HTMLFormElement>
|
|
82
|
-
extends HTMLAttributes<T> {
|
|
83
|
-
action?: string;
|
|
84
|
-
method?: "get" | "post";
|
|
85
|
-
enctype?: string;
|
|
86
|
-
target?: string;
|
|
87
|
-
noValidate?: boolean;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface InputHTMLAttributes<T = HTMLInputElement>
|
|
91
|
-
extends HTMLAttributes<T> {
|
|
92
|
-
type?:
|
|
93
|
-
| "button"
|
|
94
|
-
| "checkbox"
|
|
95
|
-
| "color"
|
|
96
|
-
| "date"
|
|
97
|
-
| "datetime-local"
|
|
98
|
-
| "email"
|
|
99
|
-
| "file"
|
|
100
|
-
| "hidden"
|
|
101
|
-
| "image"
|
|
102
|
-
| "month"
|
|
103
|
-
| "number"
|
|
104
|
-
| "password"
|
|
105
|
-
| "radio"
|
|
106
|
-
| "range"
|
|
107
|
-
| "reset"
|
|
108
|
-
| "search"
|
|
109
|
-
| "submit"
|
|
110
|
-
| "tel"
|
|
111
|
-
| "text"
|
|
112
|
-
| "time"
|
|
113
|
-
| "url"
|
|
114
|
-
| "week";
|
|
115
|
-
value?: string | number;
|
|
116
|
-
defaultValue?: string | number;
|
|
117
|
-
placeholder?: string;
|
|
118
|
-
disabled?: boolean;
|
|
119
|
-
required?: boolean;
|
|
120
|
-
readOnly?: boolean;
|
|
121
|
-
name?: string;
|
|
122
|
-
checked?: boolean;
|
|
123
|
-
defaultChecked?: boolean;
|
|
124
|
-
min?: string | number;
|
|
125
|
-
max?: string | number;
|
|
126
|
-
step?: string | number;
|
|
127
|
-
pattern?: string;
|
|
128
|
-
accept?: string;
|
|
129
|
-
multiple?: boolean;
|
|
130
|
-
autoComplete?: string;
|
|
131
|
-
autoFocus?: boolean;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface LabelHTMLAttributes<T = HTMLLabelElement>
|
|
135
|
-
extends HTMLAttributes<T> {
|
|
136
|
-
htmlFor?: string;
|
|
137
|
-
for?: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface SelectHTMLAttributes<T = HTMLSelectElement>
|
|
141
|
-
extends HTMLAttributes<T> {
|
|
142
|
-
value?: string | string[];
|
|
143
|
-
defaultValue?: string | string[];
|
|
144
|
-
disabled?: boolean;
|
|
145
|
-
required?: boolean;
|
|
146
|
-
name?: string;
|
|
147
|
-
multiple?: boolean;
|
|
148
|
-
size?: number;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface OptionHTMLAttributes<T = HTMLOptionElement>
|
|
152
|
-
extends HTMLAttributes<T> {
|
|
153
|
-
value?: string | number;
|
|
154
|
-
selected?: boolean;
|
|
155
|
-
disabled?: boolean;
|
|
156
|
-
label?: string;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface TextareaHTMLAttributes<T = HTMLTextAreaElement>
|
|
160
|
-
extends HTMLAttributes<T> {
|
|
161
|
-
value?: string;
|
|
162
|
-
defaultValue?: string;
|
|
163
|
-
placeholder?: string;
|
|
164
|
-
disabled?: boolean;
|
|
165
|
-
required?: boolean;
|
|
166
|
-
readOnly?: boolean;
|
|
167
|
-
name?: string;
|
|
168
|
-
rows?: number;
|
|
169
|
-
cols?: number;
|
|
170
|
-
maxLength?: number;
|
|
171
|
-
wrap?: "soft" | "hard";
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface FieldsetHTMLAttributes<T = HTMLFieldSetElement>
|
|
175
|
-
extends HTMLAttributes<T> {
|
|
176
|
-
disabled?: boolean;
|
|
177
|
-
name?: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export interface ImgHTMLAttributes<T = HTMLImageElement>
|
|
181
|
-
extends HTMLAttributes<T> {
|
|
182
|
-
src?: string;
|
|
183
|
-
alt?: string;
|
|
184
|
-
width?: number | string;
|
|
185
|
-
height?: number | string;
|
|
186
|
-
loading?: "eager" | "lazy";
|
|
187
|
-
crossOrigin?: "anonymous" | "use-credentials";
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface SVGAttributes<T = SVGElement> extends HTMLAttributes<T> {
|
|
191
|
-
xmlns?: string;
|
|
192
|
-
viewBox?: string;
|
|
193
|
-
width?: number | string;
|
|
194
|
-
height?: number | string;
|
|
195
|
-
fill?: string;
|
|
196
|
-
stroke?: string;
|
|
197
|
-
strokeWidth?: number | string;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Intrinsic Elements
|
|
201
|
-
export interface IntrinsicElements {
|
|
202
|
-
a: AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
203
|
-
abbr: HTMLAttributes<HTMLElement>;
|
|
204
|
-
address: HTMLAttributes<HTMLElement>;
|
|
205
|
-
article: HTMLAttributes<HTMLElement>;
|
|
206
|
-
aside: HTMLAttributes<HTMLElement>;
|
|
207
|
-
b: HTMLAttributes<HTMLElement>;
|
|
208
|
-
blockquote: HTMLAttributes<HTMLQuoteElement>;
|
|
209
|
-
body: HTMLAttributes<HTMLBodyElement>;
|
|
210
|
-
br: HTMLAttributes<HTMLBRElement>;
|
|
211
|
-
button: ButtonHTMLAttributes<HTMLButtonElement>;
|
|
212
|
-
canvas: HTMLAttributes<HTMLCanvasElement>;
|
|
213
|
-
code: HTMLAttributes<HTMLElement>;
|
|
214
|
-
div: HTMLAttributes<HTMLDivElement>;
|
|
215
|
-
em: HTMLAttributes<HTMLElement>;
|
|
216
|
-
fieldset: FieldsetHTMLAttributes<HTMLFieldSetElement>;
|
|
217
|
-
footer: HTMLAttributes<HTMLElement>;
|
|
218
|
-
form: FormHTMLAttributes<HTMLFormElement>;
|
|
219
|
-
h1: HTMLAttributes<HTMLHeadingElement>;
|
|
220
|
-
h2: HTMLAttributes<HTMLHeadingElement>;
|
|
221
|
-
h3: HTMLAttributes<HTMLHeadingElement>;
|
|
222
|
-
h4: HTMLAttributes<HTMLHeadingElement>;
|
|
223
|
-
h5: HTMLAttributes<HTMLHeadingElement>;
|
|
224
|
-
h6: HTMLAttributes<HTMLHeadingElement>;
|
|
225
|
-
head: HTMLAttributes<HTMLHeadElement>;
|
|
226
|
-
header: HTMLAttributes<HTMLElement>;
|
|
227
|
-
hr: HTMLAttributes<HTMLHRElement>;
|
|
228
|
-
html: HTMLAttributes<HTMLHtmlElement>;
|
|
229
|
-
i: HTMLAttributes<HTMLElement>;
|
|
230
|
-
img: ImgHTMLAttributes<HTMLImageElement>;
|
|
231
|
-
input: InputHTMLAttributes<HTMLInputElement>;
|
|
232
|
-
label: LabelHTMLAttributes<HTMLLabelElement>;
|
|
233
|
-
legend: HTMLAttributes<HTMLLegendElement>;
|
|
234
|
-
li: HTMLAttributes<HTMLLIElement>;
|
|
235
|
-
main: HTMLAttributes<HTMLElement>;
|
|
236
|
-
nav: HTMLAttributes<HTMLElement>;
|
|
237
|
-
ol: HTMLAttributes<HTMLOListElement>;
|
|
238
|
-
option: OptionHTMLAttributes<HTMLOptionElement>;
|
|
239
|
-
p: HTMLAttributes<HTMLParagraphElement>;
|
|
240
|
-
pre: HTMLAttributes<HTMLPreElement>;
|
|
241
|
-
section: HTMLAttributes<HTMLElement>;
|
|
242
|
-
select: SelectHTMLAttributes<HTMLSelectElement>;
|
|
243
|
-
small: HTMLAttributes<HTMLElement>;
|
|
244
|
-
span: HTMLAttributes<HTMLSpanElement>;
|
|
245
|
-
strong: HTMLAttributes<HTMLElement>;
|
|
246
|
-
style: HTMLAttributes<HTMLStyleElement>;
|
|
247
|
-
textarea: TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
248
|
-
ul: HTMLAttributes<HTMLUListElement>;
|
|
249
|
-
|
|
250
|
-
// SVG
|
|
251
|
-
svg: SVGAttributes<SVGSVGElement>;
|
|
252
|
-
circle: SVGAttributes<SVGCircleElement>;
|
|
253
|
-
line: SVGAttributes<SVGLineElement>;
|
|
254
|
-
path: SVGAttributes<SVGPathElement>;
|
|
255
|
-
rect: SVGAttributes<SVGRectElement>;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
2
|
+
// Re-export Inferno's comprehensive JSX types
|
|
3
|
+
import 'inferno';
|
|
4
|
+
|
|
5
|
+
// Re-export useful Inferno types for convenience
|
|
6
|
+
export type {
|
|
7
|
+
InfernoNode,
|
|
8
|
+
InfernoChild,
|
|
9
|
+
Component,
|
|
10
|
+
ComponentType,
|
|
11
|
+
} from 'inferno';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Temporarily patches document.addEventListener during render to capture
|
|
3
|
+
* and wrap Inferno's delegated event listeners with syncBatch
|
|
4
|
+
*/
|
|
5
|
+
export declare function patchInfernoEventHandling(renderFn: () => void): void;
|
|
6
|
+
//# sourceMappingURL=patchInferno.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patchInferno.d.ts","sourceRoot":"","sources":["../src/patchInferno.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,IAAI,QA0D7D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { syncBatch } from "./batch";
|
|
2
|
+
/**
|
|
3
|
+
* Temporarily patches document.addEventListener during render to capture
|
|
4
|
+
* and wrap Inferno's delegated event listeners with syncBatch
|
|
5
|
+
*/
|
|
6
|
+
export function patchInfernoEventHandling(renderFn) {
|
|
7
|
+
const originalAddEventListener = document.addEventListener.bind(document);
|
|
8
|
+
const patchedEvents = new Set();
|
|
9
|
+
// Inferno's delegated events
|
|
10
|
+
const INFERNO_EVENTS = [
|
|
11
|
+
"click",
|
|
12
|
+
"dblclick",
|
|
13
|
+
"focusin",
|
|
14
|
+
"focusout",
|
|
15
|
+
"keydown",
|
|
16
|
+
"keypress",
|
|
17
|
+
"keyup",
|
|
18
|
+
"mousedown",
|
|
19
|
+
"mousemove",
|
|
20
|
+
"mouseup",
|
|
21
|
+
"touchend",
|
|
22
|
+
"touchmove",
|
|
23
|
+
"touchstart",
|
|
24
|
+
"change",
|
|
25
|
+
"input",
|
|
26
|
+
"submit",
|
|
27
|
+
];
|
|
28
|
+
// Temporarily replace addEventListener
|
|
29
|
+
document.addEventListener = function (type, listener, options) {
|
|
30
|
+
// Only wrap Inferno's delegated event listeners
|
|
31
|
+
if (INFERNO_EVENTS.includes(type) &&
|
|
32
|
+
typeof listener === "function" &&
|
|
33
|
+
!patchedEvents.has(type)) {
|
|
34
|
+
patchedEvents.add(type);
|
|
35
|
+
const wrappedListener = function (event) {
|
|
36
|
+
syncBatch(() => {
|
|
37
|
+
listener.call(this, event);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
return originalAddEventListener(type, wrappedListener, options);
|
|
41
|
+
}
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
return originalAddEventListener(type, listener, options);
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
// Call render - Inferno will synchronously attach its listeners
|
|
47
|
+
renderFn();
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
// Restore original addEventListener
|
|
51
|
+
document.addEventListener = originalAddEventListener;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,SAExB;AAeD,wBAAgB,uBAAuB,SAWtC;AAmED,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,WAAoB,cAoBjE"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
let depth = 0; // batching scope nesting
|
|
2
|
+
let dirty = false; // has any state update been enqueued?
|
|
3
|
+
let scheduled = false; // async flush scheduled?
|
|
4
|
+
export function markDirty() {
|
|
5
|
+
dirty = true;
|
|
6
|
+
}
|
|
7
|
+
function performWork() {
|
|
8
|
+
// TODO: call your Inferno render/commit once.
|
|
9
|
+
// infernoRender(vnode, container);
|
|
10
|
+
}
|
|
11
|
+
function flushNow() {
|
|
12
|
+
scheduled = false;
|
|
13
|
+
if (!dirty)
|
|
14
|
+
return;
|
|
15
|
+
dirty = false;
|
|
16
|
+
performWork();
|
|
17
|
+
}
|
|
18
|
+
// Called by setters after enqueueing their state change
|
|
19
|
+
export function enqueueUpdateFromSetter() {
|
|
20
|
+
dirty = true;
|
|
21
|
+
if (depth > 0) {
|
|
22
|
+
// We're inside a batched input event; we'll flush on exit (same frame).
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!scheduled) {
|
|
26
|
+
scheduled = true;
|
|
27
|
+
queueMicrotask(flushNow); // one flush per task
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Batch-scope control used by the global capture listeners
|
|
31
|
+
function enter() {
|
|
32
|
+
depth++;
|
|
33
|
+
}
|
|
34
|
+
function exit() {
|
|
35
|
+
if (--depth === 0) {
|
|
36
|
+
// End of the event propagation; commit now (before next paint).
|
|
37
|
+
flushNow();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// eventBatching.ts
|
|
41
|
+
const INTERACTIVE_EVENTS = [
|
|
42
|
+
// Pointer + mouse
|
|
43
|
+
"click",
|
|
44
|
+
"dblclick",
|
|
45
|
+
"contextmenu",
|
|
46
|
+
"mousedown",
|
|
47
|
+
"mouseup",
|
|
48
|
+
"mousemove",
|
|
49
|
+
"pointerdown",
|
|
50
|
+
"pointerup",
|
|
51
|
+
"pointermove",
|
|
52
|
+
"touchstart",
|
|
53
|
+
"touchmove",
|
|
54
|
+
"touchend",
|
|
55
|
+
"touchcancel",
|
|
56
|
+
"dragstart",
|
|
57
|
+
"drag",
|
|
58
|
+
"dragend",
|
|
59
|
+
"dragenter",
|
|
60
|
+
"dragleave",
|
|
61
|
+
"dragover",
|
|
62
|
+
"drop",
|
|
63
|
+
"wheel",
|
|
64
|
+
// Keyboard
|
|
65
|
+
"keydown",
|
|
66
|
+
"keypress",
|
|
67
|
+
"keyup",
|
|
68
|
+
// Focus & input
|
|
69
|
+
"focus",
|
|
70
|
+
"blur",
|
|
71
|
+
"focusin",
|
|
72
|
+
"focusout",
|
|
73
|
+
"input",
|
|
74
|
+
"beforeinput",
|
|
75
|
+
"change",
|
|
76
|
+
"compositionstart",
|
|
77
|
+
"compositionupdate",
|
|
78
|
+
"compositionend",
|
|
79
|
+
// Forms
|
|
80
|
+
"submit",
|
|
81
|
+
"reset",
|
|
82
|
+
// Selection / clipboard
|
|
83
|
+
"select",
|
|
84
|
+
"selectionchange",
|
|
85
|
+
"copy",
|
|
86
|
+
"cut",
|
|
87
|
+
"paste",
|
|
88
|
+
];
|
|
89
|
+
export function installGlobalBatching(target = window) {
|
|
90
|
+
const handlers = [];
|
|
91
|
+
INTERACTIVE_EVENTS.forEach((type) => {
|
|
92
|
+
const onCapture = () => {
|
|
93
|
+
enter();
|
|
94
|
+
// Close the scope after all handlers (capture→target→bubble) have run.
|
|
95
|
+
queueMicrotask(exit);
|
|
96
|
+
};
|
|
97
|
+
target.addEventListener(type, onCapture, { capture: true });
|
|
98
|
+
handlers.push([onCapture, { capture: true }]);
|
|
99
|
+
});
|
|
100
|
+
// Return a disposer so you can remove on unmount
|
|
101
|
+
return () => {
|
|
102
|
+
INTERACTIVE_EVENTS.forEach((type, i) => {
|
|
103
|
+
const [fn, opts] = handlers[i];
|
|
104
|
+
target.removeEventListener(type, fn, opts);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.test.d.ts","sourceRoot":"","sources":["../../src/tests/batch.test.ts"],"names":[],"mappings":""}
|