incajs 0.0.22 → 0.0.23
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/chunks/hooks-N7NnMPKd.js +1 -0
- package/dist/chunks/rendererCore-B3-0H_IR.d.ts +385 -0
- package/dist/chunks/rendererCore-b4ytjgR8.js +1 -0
- package/dist/chunks/rolldown-runtime-DK3Fl9T5.js +1 -0
- package/dist/chunks/window-DD6KfOr9.d.ts +691 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/rendererCore.d.ts +3 -0
- package/dist/rendererCore.js +1 -3
- package/dist/vue-runtime.d.ts +3 -0
- package/dist/vue-runtime.js +1 -2
- package/dist/{vue/createApp.d.mts → vue.d.ts} +6 -4
- package/dist/vue.js +2 -178
- package/package.json +6 -18
- package/dist/callbacks.d.mts +0 -31
- package/dist/chunks/hooks-TbLjfN0c.js +0 -417
- package/dist/chunks/rendererCore-BUNTDvYu.js +0 -110
- package/dist/document.d.mts +0 -11
- package/dist/element/eventHandlers.d.mts +0 -12
- package/dist/element/geometry.d.mts +0 -61
- package/dist/element/handle.d.mts +0 -29
- package/dist/element/lifecycle.d.mts +0 -51
- package/dist/element/scroll.d.mts +0 -42
- package/dist/element/shadowTree.d.mts +0 -64
- package/dist/element/types.d.mts +0 -149
- package/dist/eventTarget.d.mts +0 -11
- package/dist/events.d.mts +0 -105
- package/dist/index.d.mts +0 -6
- package/dist/native.d.mts +0 -46
- package/dist/rendererCore.d.mts +0 -14
- package/dist/targets.d.mts +0 -1
- package/dist/tree.d.mts +0 -157
- package/dist/types.d.mts +0 -454
- package/dist/vue/index.d.mts +0 -2
- package/dist/vue/nodeOps.d.mts +0 -29
- package/dist/vue/patchProp.d.mts +0 -79
- package/dist/vue/runtime.d.mts +0 -2
- package/dist/window.d.mts +0 -13
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
/** The events whose handler property every element has. */
|
|
2
|
+
declare const HANDLER_EVENTS: readonly ["auxclick", "beforeinput", "blur", "change", "click", "contextmenu", "dblclick", "focus", "gotpointercapture", "input", "keydown", "keyup", "lostpointercapture", "mousedown", "mouseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointerenter", "pointerleave", "pointermove", "pointerout", "pointerover", "pointerup", "scroll", "wheel"];
|
|
3
|
+
/** The plain values of a {@link RectLike}, as `toJSON` returns them. */
|
|
4
|
+
interface RectValues {
|
|
5
|
+
readonly x: number;
|
|
6
|
+
readonly y: number;
|
|
7
|
+
readonly width: number;
|
|
8
|
+
readonly height: number;
|
|
9
|
+
readonly top: number;
|
|
10
|
+
readonly left: number;
|
|
11
|
+
readonly right: number;
|
|
12
|
+
readonly bottom: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A rectangle with its position, its size and its four edges. `toJSON()` returns
|
|
16
|
+
* the plain values.
|
|
17
|
+
*/
|
|
18
|
+
interface RectLike extends RectValues {
|
|
19
|
+
toJSON(): RectValues;
|
|
20
|
+
}
|
|
21
|
+
/** The options form of `scrollTo()` and `scrollBy()`. `behavior` is accepted and ignored. */
|
|
22
|
+
interface ScrollOptions {
|
|
23
|
+
/** The horizontal offset. Omit to keep the current one. */
|
|
24
|
+
left?: number;
|
|
25
|
+
/** The vertical offset. Omit to keep the current one. */
|
|
26
|
+
top?: number;
|
|
27
|
+
/** `behavior` is ignored; every scroll applies at once. */
|
|
28
|
+
behavior?: "auto" | "instant" | "smooth";
|
|
29
|
+
}
|
|
30
|
+
/** The options form of `scrollIntoView()`. `behavior` is accepted and ignored. */
|
|
31
|
+
interface ScrollIntoViewOptions {
|
|
32
|
+
/** The vertical alignment. Defaults to `"start"`. */
|
|
33
|
+
block?: ScrollAlignment;
|
|
34
|
+
/** The horizontal alignment. Defaults to `"nearest"`. */
|
|
35
|
+
inline?: ScrollAlignment;
|
|
36
|
+
/** `behavior` is ignored; every scroll applies at once. */
|
|
37
|
+
behavior?: "auto" | "instant" | "smooth";
|
|
38
|
+
}
|
|
39
|
+
/** A function an event handler property holds, called with its target as `this` and the event. */
|
|
40
|
+
type EventHandler<E = IncaEvent, T = IncaElement> = (this: T, event: E) => unknown;
|
|
41
|
+
/**
|
|
42
|
+
* The event handler properties, such as `onclick`, of the events the host dispatches, `focusin` and
|
|
43
|
+
* `focusout` excepted.
|
|
44
|
+
*/
|
|
45
|
+
type EventHandlers<T = IncaElement> = { [K in (typeof HANDLER_EVENTS)[number] as `on${K}`]: EventHandler<IncaEventMap[K], T> | object | null; };
|
|
46
|
+
/**
|
|
47
|
+
* A container node: either a real element or the hidden stand-in that
|
|
48
|
+
* `createCommentNode` makes. It is the only node type that can act as a
|
|
49
|
+
* parent. `parent` and `children` read the node's current position in the
|
|
50
|
+
* tree.
|
|
51
|
+
*
|
|
52
|
+
* After the node is removed, `addEventListener()` and `removeEventListener()`
|
|
53
|
+
* ignore the call, an assignment to a handler property does nothing, and
|
|
54
|
+
* `dispatchEvent()` returns `true`.
|
|
55
|
+
*/
|
|
56
|
+
interface IncaElement extends IncaEventTarget, EventHandlers {
|
|
57
|
+
/**
|
|
58
|
+
* The `id` attribute, or an empty string when it is unset. Assigning sets
|
|
59
|
+
* the attribute to the value as a string. After the node is removed,
|
|
60
|
+
* reading gives an empty string and assigning does nothing.
|
|
61
|
+
*/
|
|
62
|
+
id: string;
|
|
63
|
+
/**
|
|
64
|
+
* `"comment"` for the hidden stand-in `createCommentNode` makes;
|
|
65
|
+
* `"element"` for every other container.
|
|
66
|
+
*/
|
|
67
|
+
readonly kind: "element" | "comment";
|
|
68
|
+
/** The current parent, or `null` if this node isn't attached to the tree. */
|
|
69
|
+
parent: IncaElement | null;
|
|
70
|
+
/** This node's children, in render order. */
|
|
71
|
+
children: IncaNode[];
|
|
72
|
+
/**
|
|
73
|
+
* Focuses this node next frame. The node needs a `tabindex` attribute. A
|
|
74
|
+
* `true` `preventScroll` keeps every scroll container where it is. After
|
|
75
|
+
* the node is removed, the call does nothing.
|
|
76
|
+
*/
|
|
77
|
+
focus(options?: {
|
|
78
|
+
preventScroll?: boolean;
|
|
79
|
+
}): void;
|
|
80
|
+
/** Unfocuses this node next frame, if it is the focused one. */
|
|
81
|
+
blur(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Fires an untrusted `click` at this node. A disabled `button` or `input` and a node
|
|
84
|
+
* whose own click is still running ignore the call. After the node is removed, the call
|
|
85
|
+
* does nothing.
|
|
86
|
+
*/
|
|
87
|
+
click(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Captures the mouse pointer for this node while a button is held. Only `pointerId` 1 exists.
|
|
90
|
+
* @throws DOMException named `NotFoundError` for another `pointerId`
|
|
91
|
+
* @throws DOMException named `InvalidStateError` when the node is outside the mounted tree,
|
|
92
|
+
* also after it is removed
|
|
93
|
+
*/
|
|
94
|
+
setPointerCapture(pointerId: number): void;
|
|
95
|
+
/**
|
|
96
|
+
* Releases the capture this node requested. Does nothing when the node holds none.
|
|
97
|
+
* @throws DOMException named `NotFoundError` for a `pointerId` other than 1
|
|
98
|
+
*/
|
|
99
|
+
releasePointerCapture(pointerId: number): void;
|
|
100
|
+
/**
|
|
101
|
+
* Whether this node requested the capture and has not released it. `false` after the node is
|
|
102
|
+
* removed.
|
|
103
|
+
*/
|
|
104
|
+
hasPointerCapture(pointerId: number): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Whether `other` is this node or one of its descendants in the tree as
|
|
107
|
+
* rendered. `null` and `undefined` give `false`, and any other value that is
|
|
108
|
+
* not a node throws a `TypeError`. After the node is removed, it still answers
|
|
109
|
+
* for the subtree it keeps.
|
|
110
|
+
*/
|
|
111
|
+
contains(other: IncaNode | null): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Assigning sets the `tabindex` attribute to the value's integer part,
|
|
114
|
+
* wrapped to 32 bits. Reading returns the `tabindex` attribute as an
|
|
115
|
+
* integer, or `-1` (`0` for a `button` or an `input`) when it is unset or invalid.
|
|
116
|
+
* After the node is removed, reading gives that default and assigning does
|
|
117
|
+
* nothing.
|
|
118
|
+
*/
|
|
119
|
+
tabIndex: number;
|
|
120
|
+
/**
|
|
121
|
+
* The box this node was drawn at in the last frame, in window logical
|
|
122
|
+
* pixels. A node created in the same task reads all zeros.
|
|
123
|
+
*/
|
|
124
|
+
getBoundingClientRect(): RectLike;
|
|
125
|
+
/** The box width from the last frame, rounded. `0` until a frame draws the node. */
|
|
126
|
+
readonly offsetWidth: number;
|
|
127
|
+
/** The box height from the last frame, rounded. `0` until a frame draws the node. */
|
|
128
|
+
readonly offsetHeight: number;
|
|
129
|
+
/** The box's left edge from the last frame, relative to {@link offsetParent}. Stays fixed while the parent scrolls. */
|
|
130
|
+
readonly offsetLeft: number;
|
|
131
|
+
/** The box's top edge from the last frame, relative to {@link offsetParent}. Stays fixed while the parent scrolls. */
|
|
132
|
+
readonly offsetTop: number;
|
|
133
|
+
/**
|
|
134
|
+
* The parent, when this node and the parent both have a box from the last frame.
|
|
135
|
+
* `null` when either lacks a box or there is no parent.
|
|
136
|
+
*/
|
|
137
|
+
readonly offsetParent: IncaElement | null;
|
|
138
|
+
/** The box width less both borders, rounded, at least `0`. */
|
|
139
|
+
readonly clientWidth: number;
|
|
140
|
+
/** The box height less both borders, rounded, at least `0`. */
|
|
141
|
+
readonly clientHeight: number;
|
|
142
|
+
/** The border width, rounded. */
|
|
143
|
+
readonly clientLeft: number;
|
|
144
|
+
/** The border width, rounded. */
|
|
145
|
+
readonly clientTop: number;
|
|
146
|
+
/** The horizontal scroll offset. Assigning moves it at once, and reads are clamped to the last frame's maximum. */
|
|
147
|
+
scrollLeft: number;
|
|
148
|
+
/** The vertical scroll offset. Assigning moves it at once, and reads are clamped to the last frame's maximum. */
|
|
149
|
+
scrollTop: number;
|
|
150
|
+
/** The content width: {@link clientWidth} plus the largest horizontal offset. */
|
|
151
|
+
readonly scrollWidth: number;
|
|
152
|
+
/** The content height: {@link clientHeight} plus the largest vertical offset. */
|
|
153
|
+
readonly scrollHeight: number;
|
|
154
|
+
/** Sets the offset to `(left, top)`, or to the options object's `left` and `top`. */
|
|
155
|
+
scrollTo(left?: number, top?: number): void;
|
|
156
|
+
scrollTo(options: ScrollOptions): void;
|
|
157
|
+
/** Adds `(left, top)` to the offset, or the options object's `left` and `top`. */
|
|
158
|
+
scrollBy(left?: number, top?: number): void;
|
|
159
|
+
scrollBy(options: ScrollOptions): void;
|
|
160
|
+
/**
|
|
161
|
+
* Scrolls each scroll container around this node so the node shows. `true`
|
|
162
|
+
* or no argument aligns to the start and `false` to the end. An options
|
|
163
|
+
* object sets `block` (default `"start"`) and `inline` (default `"nearest"`);
|
|
164
|
+
* `behavior` is accepted and ignored. After the node is removed, the call
|
|
165
|
+
* does nothing.
|
|
166
|
+
*/
|
|
167
|
+
scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
|
|
168
|
+
/**
|
|
169
|
+
* The `document` export while the node hangs under the mount container,
|
|
170
|
+
* else the topmost node of its subtree, the node itself without a parent.
|
|
171
|
+
*/
|
|
172
|
+
getRootNode(): IncaElement | IncaDocument;
|
|
173
|
+
}
|
|
174
|
+
/** The handle of an `<input>`. */
|
|
175
|
+
interface IncaInputElement extends IncaElement {
|
|
176
|
+
/**
|
|
177
|
+
* The text of the input. Assigning sets the value as a string, and `null` as `""`; line breaks
|
|
178
|
+
* are dropped and a changed text puts the caret at its end. After the node is removed, reading
|
|
179
|
+
* gives `""` and assigning does nothing.
|
|
180
|
+
*/
|
|
181
|
+
value: string;
|
|
182
|
+
}
|
|
183
|
+
/** A text leaf node. */
|
|
184
|
+
interface IncaText {
|
|
185
|
+
/** Discriminates this node within the {@link IncaNode} union. */
|
|
186
|
+
readonly kind: "text";
|
|
187
|
+
/** The current parent, or `null` if this node isn't attached to the tree. */
|
|
188
|
+
parent: IncaElement | null;
|
|
189
|
+
/**
|
|
190
|
+
* The text content, mirroring the value pushed to the native node.
|
|
191
|
+
*/
|
|
192
|
+
text: string;
|
|
193
|
+
}
|
|
194
|
+
/** Any node the shadow tree holds: an element, comment, or text leaf. */
|
|
195
|
+
type IncaNode = IncaElement | IncaText;
|
|
196
|
+
/**
|
|
197
|
+
* Stable handle to a node in the native retained tree, returned by `createNode`
|
|
198
|
+
* and used in every later call that touches that node.
|
|
199
|
+
*/
|
|
200
|
+
type NodeId = number;
|
|
201
|
+
/**
|
|
202
|
+
* Id assigned to one registered event listener. Managed internally by
|
|
203
|
+
* `addEventListener`/`removeEventListener`/`destroyNode`.
|
|
204
|
+
*/
|
|
205
|
+
type CallbackId = number;
|
|
206
|
+
/**
|
|
207
|
+
* A value `setAttribute`/`setStyle` can take. Any other value raises a catchable
|
|
208
|
+
* exception.
|
|
209
|
+
*/
|
|
210
|
+
type AttributeValue = string | number | boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Element kind passed to `createNode`. `"text"` is the only tag with
|
|
213
|
+
* dedicated rendering behavior: it renders its `"value"` attribute followed
|
|
214
|
+
* by its descendants' text. Any other string is a generic styled
|
|
215
|
+
* container; the `string & {}` half of this type keeps `"text"`'s
|
|
216
|
+
* autocomplete while still accepting an arbitrary tag name.
|
|
217
|
+
*/
|
|
218
|
+
type TagName = "text" | (string & {});
|
|
219
|
+
/** Where `scrollIntoView` aligns a node on one axis. */
|
|
220
|
+
type ScrollAlignment = "start" | "center" | "end" | "nearest";
|
|
221
|
+
/** One overflow value; `"auto"` is an alias of `"scroll"`. */
|
|
222
|
+
type Overflow = "visible" | "hidden" | "clip" | "scroll" | "auto";
|
|
223
|
+
/**
|
|
224
|
+
* Style properties, in their snake_case spelling, that `setStyle`'s typed
|
|
225
|
+
* overload checks. A deliberately incomplete, v1 layout/paint vocabulary. The
|
|
226
|
+
* renderer also reads the camelCase and kebab-case spellings. An unrecognized
|
|
227
|
+
* key or a value shape that doesn't parse (e.g. a malformed enum string) is
|
|
228
|
+
* ignored by the renderer, and the host prints a warning line on stderr for
|
|
229
|
+
* it (an empty string `''` prints none).
|
|
230
|
+
*/
|
|
231
|
+
interface StyleProps {
|
|
232
|
+
/** Layout mode for this node's children. `"none"` skips both layout and rendering for the whole subtree. */
|
|
233
|
+
display?: "flex" | "block" | "grid" | "none";
|
|
234
|
+
/** Main-axis direction for a `"flex"` container. */
|
|
235
|
+
flex_direction?: "row" | "column" | "row_reverse" | "column_reverse";
|
|
236
|
+
/** Main-axis alignment of children within this container. */
|
|
237
|
+
justify_content?: "start" | "end" | "center" | "stretch";
|
|
238
|
+
/** Cross-axis alignment of children within this container. */
|
|
239
|
+
align_items?: "start" | "end" | "center" | "stretch";
|
|
240
|
+
/** Uniform spacing, in px (`>= 0`), between children, applied on both axes. */
|
|
241
|
+
gap?: number;
|
|
242
|
+
/** Fixed width in px (`>= 0`), or `"auto"` to size to content. */
|
|
243
|
+
width?: number | "auto";
|
|
244
|
+
/** Fixed height in px (`>= 0`), or `"auto"` to size to content. */
|
|
245
|
+
height?: number | "auto";
|
|
246
|
+
/** Uniform border width in px (`>= 0`), applied to all four sides. */
|
|
247
|
+
border_width?: number;
|
|
248
|
+
/** Fill color, as a hex number (`0xRRGGBB`) or a CSS-style string (`"#rrggbb"`/`"#rgb"`). */
|
|
249
|
+
background?: number | string;
|
|
250
|
+
/** Border color. Accepts the same formats as {@link StyleProps.background}. */
|
|
251
|
+
border_color?: number | string;
|
|
252
|
+
/** Color for this container's own text. Cascades to descendant text leaves, same as {@link StyleProps.text_size}; there's no separate per-leaf text styling. */
|
|
253
|
+
text_color?: number | string;
|
|
254
|
+
/** Uniform corner radius in px (`>= 0`), applied to all four corners. */
|
|
255
|
+
corner_radius?: number;
|
|
256
|
+
/** Font size in px (`>= 0`) for this container's own text. Cascades to descendant text leaves, same as {@link StyleProps.text_color}. */
|
|
257
|
+
text_size?: number;
|
|
258
|
+
/** Overflow on both axes, or `"<x> <y>"` per axis; `"scroll"` (alias `"auto"`) makes the container scroll with the wheel. Overridden per axis by {@link StyleProps.overflow_x}/{@link StyleProps.overflow_y}. */
|
|
259
|
+
overflow?: Overflow | `${Overflow} ${Overflow}`;
|
|
260
|
+
/** Horizontal overflow; wins over {@link StyleProps.overflow}. */
|
|
261
|
+
overflow_x?: Overflow;
|
|
262
|
+
/** Vertical overflow; wins over {@link StyleProps.overflow}. */
|
|
263
|
+
overflow_y?: Overflow;
|
|
264
|
+
/** Inner spacing in px (`>= 0`) on all four sides. Overridden per axis by {@link StyleProps.padding_x}/{@link StyleProps.padding_y} and per side by the `padding_*` side keys. */
|
|
265
|
+
padding?: number;
|
|
266
|
+
/** Horizontal inner spacing in px (`>= 0`); wins over {@link StyleProps.padding}. */
|
|
267
|
+
padding_x?: number;
|
|
268
|
+
/** Vertical inner spacing in px (`>= 0`); wins over {@link StyleProps.padding}. */
|
|
269
|
+
padding_y?: number;
|
|
270
|
+
/** Top inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_y}. */
|
|
271
|
+
padding_top?: number;
|
|
272
|
+
/** Right inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_x}. */
|
|
273
|
+
padding_right?: number;
|
|
274
|
+
/** Bottom inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_y}. */
|
|
275
|
+
padding_bottom?: number;
|
|
276
|
+
/** Left inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_x}. */
|
|
277
|
+
padding_left?: number;
|
|
278
|
+
/** Outer spacing in px (negative allowed) or `"auto"` on all four sides. Overridden per axis by {@link StyleProps.margin_x}/{@link StyleProps.margin_y} and per side by the `margin_*` side keys. */
|
|
279
|
+
margin?: number | "auto";
|
|
280
|
+
/** Horizontal outer spacing; wins over {@link StyleProps.margin}. */
|
|
281
|
+
margin_x?: number | "auto";
|
|
282
|
+
/** Vertical outer spacing; wins over {@link StyleProps.margin}. */
|
|
283
|
+
margin_y?: number | "auto";
|
|
284
|
+
/** Top outer spacing; wins over {@link StyleProps.margin_y}. */
|
|
285
|
+
margin_top?: number | "auto";
|
|
286
|
+
/** Right outer spacing; wins over {@link StyleProps.margin_x}. */
|
|
287
|
+
margin_right?: number | "auto";
|
|
288
|
+
/** Bottom outer spacing; wins over {@link StyleProps.margin_y}. */
|
|
289
|
+
margin_bottom?: number | "auto";
|
|
290
|
+
/** Left outer spacing; wins over {@link StyleProps.margin_x}. */
|
|
291
|
+
margin_left?: number | "auto";
|
|
292
|
+
/** Share (`>= 0`) of the free space in the parent's main axis this node takes. */
|
|
293
|
+
flex_grow?: number;
|
|
294
|
+
/** Share (`>= 0`) of the overflow in the parent's main axis this node gives up. */
|
|
295
|
+
flex_shrink?: number;
|
|
296
|
+
/** Opacity from `0` to `1`, applied to this node and its descendants; values outside are clamped. */
|
|
297
|
+
opacity?: number;
|
|
298
|
+
/** Minimum width in px (`>= 0`), or `"auto"` for the default minimum. */
|
|
299
|
+
min_width?: number | "auto";
|
|
300
|
+
/** Minimum height in px (`>= 0`), or `"auto"` for the default minimum. */
|
|
301
|
+
min_height?: number | "auto";
|
|
302
|
+
/** Maximum width in px (`>= 0`), or `"auto"` for no limit. */
|
|
303
|
+
max_width?: number | "auto";
|
|
304
|
+
/** Maximum height in px (`>= 0`), or `"auto"` for no limit. */
|
|
305
|
+
max_height?: number | "auto";
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* An event built in this runtime with `Event`, `CustomEvent` or another
|
|
309
|
+
* event constructor. The host throws a `TypeError` for any other value.
|
|
310
|
+
*/
|
|
311
|
+
interface EventLike {
|
|
312
|
+
readonly type: string;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* How a listener registered via `addEventListener` takes part in an event.
|
|
316
|
+
*/
|
|
317
|
+
interface ListenerOptions {
|
|
318
|
+
/**
|
|
319
|
+
* Listen while the event travels from `window` down to the target. The default listens while it
|
|
320
|
+
* travels back up.
|
|
321
|
+
*/
|
|
322
|
+
capture?: boolean;
|
|
323
|
+
/** `preventDefault()` calls inside the listener are ignored. */
|
|
324
|
+
passive?: boolean;
|
|
325
|
+
/** The listener is removed before it first runs. */
|
|
326
|
+
once?: boolean;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The listener methods of an object that receives events, such as the
|
|
330
|
+
* `window` and `document` exports and a template `ref`. A registration is identified by the
|
|
331
|
+
* event name, the listener and `capture`. `removeEventListener` takes the
|
|
332
|
+
* same listener that `addEventListener` received.
|
|
333
|
+
*/
|
|
334
|
+
interface IncaEventTarget {
|
|
335
|
+
/**
|
|
336
|
+
* Registers `listener` for `type`. Registering the same listener for the
|
|
337
|
+
* same `type` and `capture` again changes nothing. A `null` listener is
|
|
338
|
+
* ignored.
|
|
339
|
+
* @param type - the event name (e.g. `"keydown"`)
|
|
340
|
+
* @param listener - a function, called with the event's `currentTarget` as
|
|
341
|
+
* `this`, or an object whose `handleEvent` method is called with the object
|
|
342
|
+
* as `this` when the event fires
|
|
343
|
+
* @param options - a {@link ListenerOptions}, or a boolean for `capture`
|
|
344
|
+
*/
|
|
345
|
+
addEventListener<K extends keyof IncaEventMap>(type: K, listener: EventListenerOrObject<IncaEventMap[K], this> | null, options?: boolean | ListenerOptions): void;
|
|
346
|
+
addEventListener<E = IncaEvent>(type: string, listener: EventListenerOrObject<E, this> | null, options?: boolean | ListenerOptions): void;
|
|
347
|
+
/**
|
|
348
|
+
* Drops the registration of `listener` for `type` with the same `capture`.
|
|
349
|
+
* A call that matches no registration changes nothing.
|
|
350
|
+
* @param type - the event name
|
|
351
|
+
* @param listener - the listener that was registered
|
|
352
|
+
* @param options - an object with `capture`, or a boolean for `capture`
|
|
353
|
+
*/
|
|
354
|
+
removeEventListener<K extends keyof IncaEventMap>(type: K, listener: EventListenerOrObject<IncaEventMap[K], this> | null, options?: boolean | Pick<ListenerOptions, "capture">): void;
|
|
355
|
+
removeEventListener<E = IncaEvent>(type: string, listener: EventListenerOrObject<E, this> | null, options?: boolean | Pick<ListenerOptions, "capture">): void;
|
|
356
|
+
/**
|
|
357
|
+
* Dispatches an event built with an event constructor at the target.
|
|
358
|
+
* @param event - the event to dispatch
|
|
359
|
+
* @returns `false` when a listener canceled a cancelable event, else `true`
|
|
360
|
+
* @throws TypeError when `event` is not an event built with an event constructor
|
|
361
|
+
* @throws DOMException named `InvalidStateError` when `event` is being dispatched
|
|
362
|
+
*/
|
|
363
|
+
dispatchEvent(event: EventLike): boolean;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The event target between the elements and `window`.
|
|
367
|
+
*/
|
|
368
|
+
interface IncaDocument extends IncaEventTarget, EventHandlers<IncaDocument> {
|
|
369
|
+
/** The element that has focus, or `null` when no element has focus. */
|
|
370
|
+
readonly activeElement: IncaElement | null;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The event target at the top of every event path.
|
|
374
|
+
*/
|
|
375
|
+
interface IncaWindow extends IncaEventTarget, EventHandlers<IncaWindow> {}
|
|
376
|
+
/**
|
|
377
|
+
* The fields every event carries. {@link IncaEventMap} gives the event type of
|
|
378
|
+
* each name the host dispatches, and a listener for any other name receives
|
|
379
|
+
* this type.
|
|
380
|
+
*
|
|
381
|
+
* See https://incajs.tom96da.com/reference/events for the event names the
|
|
382
|
+
* host dispatches and their fields.
|
|
383
|
+
*/
|
|
384
|
+
interface IncaEvent {
|
|
385
|
+
/** The event's name. */
|
|
386
|
+
readonly type: string;
|
|
387
|
+
/** `0`, the {@link IncaEvent.eventPhase} outside a dispatch. */
|
|
388
|
+
readonly NONE: 0;
|
|
389
|
+
/** `1`, the {@link IncaEvent.eventPhase} on an ancestor while the event travels down. */
|
|
390
|
+
readonly CAPTURING_PHASE: 1;
|
|
391
|
+
/** `2`, the {@link IncaEvent.eventPhase} on the target. */
|
|
392
|
+
readonly AT_TARGET: 2;
|
|
393
|
+
/** `3`, the {@link IncaEvent.eventPhase} on an ancestor while the event travels up. */
|
|
394
|
+
readonly BUBBLING_PHASE: 3;
|
|
395
|
+
/**
|
|
396
|
+
* The element the event is about. It is the deepest element under the pointer for pointer
|
|
397
|
+
* events (the capturing element while the pointer is captured), the nearest common ancestor of
|
|
398
|
+
* the press and the release for `click`, `dblclick` and `auxclick`, and the focused element for
|
|
399
|
+
* key events. With no such element it is the mount container's element. A script dispatch at
|
|
400
|
+
* `document` or `window` gives that object.
|
|
401
|
+
*/
|
|
402
|
+
readonly target: IncaEventTarget;
|
|
403
|
+
/** The same object as {@link IncaEvent.target}. */
|
|
404
|
+
readonly srcElement: IncaEventTarget;
|
|
405
|
+
/**
|
|
406
|
+
* The element, `document` or `window` whose listener is running, and `null` once the
|
|
407
|
+
* event has been handled. A listener function runs with it as `this`.
|
|
408
|
+
*/
|
|
409
|
+
readonly currentTarget: IncaEventTarget | null;
|
|
410
|
+
/**
|
|
411
|
+
* Whether the event travels up from `target`. Fixed per event name for the
|
|
412
|
+
* events the host dispatches.
|
|
413
|
+
*/
|
|
414
|
+
readonly bubbles: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Whether `preventDefault()` can cancel the event. Fixed per event name for
|
|
417
|
+
* the events the host dispatches.
|
|
418
|
+
*/
|
|
419
|
+
readonly cancelable: boolean;
|
|
420
|
+
/** Fixed per event name for the events the host dispatches. */
|
|
421
|
+
readonly composed: boolean;
|
|
422
|
+
/**
|
|
423
|
+
* 1 on the ancestors of `target` while the event travels down, 2 where
|
|
424
|
+
* `currentTarget` is `target`, 3 on the ancestors while it travels up, and 0
|
|
425
|
+
* once the event has been handled.
|
|
426
|
+
*/
|
|
427
|
+
readonly eventPhase: 0 | 1 | 2 | 3;
|
|
428
|
+
/** `true` once a listener called `preventDefault()` on a cancelable event. */
|
|
429
|
+
readonly defaultPrevented: boolean;
|
|
430
|
+
/** `true` for events the host dispatches and `false` for events a script dispatches. */
|
|
431
|
+
readonly isTrusted: boolean;
|
|
432
|
+
/** Milliseconds since the host started. */
|
|
433
|
+
readonly timeStamp: number;
|
|
434
|
+
/** A number that grows with each event and is the same on every node that event reaches. */
|
|
435
|
+
readonly eventId: number;
|
|
436
|
+
/** Assigning `true` while the event is dispatched stops it like `stopPropagation()`. */
|
|
437
|
+
cancelBubble: boolean;
|
|
438
|
+
/** The opposite of `defaultPrevented`. Assigning `false` cancels a cancelable event like `preventDefault()`. */
|
|
439
|
+
returnValue: boolean;
|
|
440
|
+
/** Stops the event from reaching the listeners of later nodes on its path. */
|
|
441
|
+
stopPropagation(): void;
|
|
442
|
+
/** Stops the event from reaching any later listener. */
|
|
443
|
+
stopImmediatePropagation(): void;
|
|
444
|
+
/** Cancels the event when it is cancelable and the listener is not passive. */
|
|
445
|
+
preventDefault(): void;
|
|
446
|
+
/**
|
|
447
|
+
* `target` and its ancestors, then `document` and `window`, and an empty
|
|
448
|
+
* array once the event has been handled.
|
|
449
|
+
*/
|
|
450
|
+
composedPath(): IncaEventTarget[];
|
|
451
|
+
/**
|
|
452
|
+
* Sets the type, `bubbles` and `cancelable` of an event that is not being
|
|
453
|
+
* dispatched, clears its stop and cancel flags and makes it untrusted. While
|
|
454
|
+
* the event is dispatched it does nothing.
|
|
455
|
+
*/
|
|
456
|
+
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* The event object of a mouse, wheel, keyboard, focus, input or composition event.
|
|
460
|
+
*/
|
|
461
|
+
interface IncaUIEvent extends IncaEvent {
|
|
462
|
+
/**
|
|
463
|
+
* On the events the host dispatches, the click count of `mousedown`,
|
|
464
|
+
* `mouseup`, `click`, `dblclick` and `auxclick`, and `0` on the others.
|
|
465
|
+
*/
|
|
466
|
+
readonly detail: number;
|
|
467
|
+
/** Always `null`. */
|
|
468
|
+
readonly view: null;
|
|
469
|
+
/**
|
|
470
|
+
* On the events the host dispatches: for `mousedown`, `mouseup`, `click`,
|
|
471
|
+
* `dblclick`, `auxclick` and `contextmenu`, `button + 1`. For `wheel`, `0`.
|
|
472
|
+
* For the other mouse events, the lowest held button plus 1, or `0` with no
|
|
473
|
+
* button held. For the pointer events, `button + 1`, so `0` when `button` is `-1`. For a
|
|
474
|
+
* keyboard event, `keyCode`. For a focus event, `0`.
|
|
475
|
+
*/
|
|
476
|
+
readonly which: number;
|
|
477
|
+
}
|
|
478
|
+
/** The event object of `focus`, `blur`, `focusin` and `focusout`. */
|
|
479
|
+
interface IncaFocusEvent extends IncaUIEvent {
|
|
480
|
+
/**
|
|
481
|
+
* The element gaining focus for `blur` and `focusout`, the element losing
|
|
482
|
+
* it for `focus` and `focusin`, or `null`.
|
|
483
|
+
*/
|
|
484
|
+
readonly relatedTarget: IncaEventTarget | null;
|
|
485
|
+
}
|
|
486
|
+
/** The event object of the mouse events. */
|
|
487
|
+
interface IncaMouseEvent extends IncaUIEvent {
|
|
488
|
+
readonly screenX: number;
|
|
489
|
+
readonly screenY: number;
|
|
490
|
+
/** The pointer's position in the window. */
|
|
491
|
+
readonly clientX: number;
|
|
492
|
+
/** The pointer's position in the window. */
|
|
493
|
+
readonly clientY: number;
|
|
494
|
+
/** The same as {@link IncaMouseEvent.clientX}. */
|
|
495
|
+
readonly pageX: number;
|
|
496
|
+
/** The same as {@link IncaMouseEvent.clientY}. */
|
|
497
|
+
readonly pageY: number;
|
|
498
|
+
/** The same as {@link IncaMouseEvent.clientX}. */
|
|
499
|
+
readonly x: number;
|
|
500
|
+
/** The same as {@link IncaMouseEvent.clientY}. */
|
|
501
|
+
readonly y: number;
|
|
502
|
+
/** On the events the host dispatches, the pointer's position from the padding edge of `target`. */
|
|
503
|
+
readonly offsetX: number;
|
|
504
|
+
/** On the events the host dispatches, the pointer's position from the padding edge of `target`. */
|
|
505
|
+
readonly offsetY: number;
|
|
506
|
+
/** On the events the host dispatches, the pointer's travel since the previous `mousemove`, and `0` on other events. */
|
|
507
|
+
readonly movementX: number;
|
|
508
|
+
/** On the events the host dispatches, the pointer's travel since the previous `mousemove`, and `0` on other events. */
|
|
509
|
+
readonly movementY: number;
|
|
510
|
+
/**
|
|
511
|
+
* The button the event is about: `0` left, `1` middle, `2` right, `3` back, `4` forward. `-1` on
|
|
512
|
+
* a pointer event that is about no button.
|
|
513
|
+
*/
|
|
514
|
+
readonly button: number;
|
|
515
|
+
/** Every button held, as a bitmask: `1` left, `2` right, `4` middle, `8` back, `16` forward. */
|
|
516
|
+
readonly buttons: number;
|
|
517
|
+
readonly ctrlKey: boolean;
|
|
518
|
+
readonly shiftKey: boolean;
|
|
519
|
+
readonly altKey: boolean;
|
|
520
|
+
readonly metaKey: boolean;
|
|
521
|
+
/**
|
|
522
|
+
* The element the pointer came from for `mouseover` and `mouseenter`, the
|
|
523
|
+
* element it went to for `mouseout` and `mouseleave`, or `null`.
|
|
524
|
+
*/
|
|
525
|
+
readonly relatedTarget: IncaEventTarget | null;
|
|
526
|
+
/**
|
|
527
|
+
* Whether the modifier `key` is held: `"Control"`, `"Shift"`, `"Alt"`,
|
|
528
|
+
* `"Meta"`, or `"Accel"` (Meta on macOS, Control elsewhere). Any other name
|
|
529
|
+
* gives `false`.
|
|
530
|
+
*/
|
|
531
|
+
getModifierState(key: string): boolean;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* The event object of the `pointer*` events, `gotpointercapture`, `lostpointercapture`, `click`,
|
|
535
|
+
* `auxclick` and `contextmenu`.
|
|
536
|
+
*/
|
|
537
|
+
interface IncaPointerEvent extends IncaMouseEvent {
|
|
538
|
+
/**
|
|
539
|
+
* On the events the host dispatches, `1` for the mouse and for the `contextmenu` of a key, and
|
|
540
|
+
* `-1` for the click of a key.
|
|
541
|
+
*/
|
|
542
|
+
readonly pointerId: number;
|
|
543
|
+
readonly width: number;
|
|
544
|
+
readonly height: number;
|
|
545
|
+
/** On the pointer events the host dispatches, `0.5` while a button is held, else `0`. */
|
|
546
|
+
readonly pressure: number;
|
|
547
|
+
/** On the events the host dispatches, `"mouse"`, or `""` for the click of a key. */
|
|
548
|
+
readonly pointerType: string;
|
|
549
|
+
/**
|
|
550
|
+
* On the events the host dispatches, `true` on the pointer events and `false` on `click`,
|
|
551
|
+
* `auxclick` and `contextmenu`.
|
|
552
|
+
*/
|
|
553
|
+
readonly isPrimary: boolean;
|
|
554
|
+
}
|
|
555
|
+
/** The event object of `wheel`. */
|
|
556
|
+
interface IncaWheelEvent extends IncaMouseEvent {
|
|
557
|
+
readonly deltaX: number;
|
|
558
|
+
readonly deltaY: number;
|
|
559
|
+
/** `0` on the events the host dispatches. */
|
|
560
|
+
readonly deltaZ: number;
|
|
561
|
+
/** `0` for pixels, `1` for lines. */
|
|
562
|
+
readonly deltaMode: number;
|
|
563
|
+
readonly DOM_DELTA_PIXEL: 0;
|
|
564
|
+
readonly DOM_DELTA_LINE: 1;
|
|
565
|
+
readonly DOM_DELTA_PAGE: 2;
|
|
566
|
+
}
|
|
567
|
+
/** The event object of `keydown` and `keyup`. */
|
|
568
|
+
interface IncaKeyboardEvent extends IncaUIEvent {
|
|
569
|
+
/** The key's name, such as `"Enter"`, `"F5"` or the typed character. */
|
|
570
|
+
readonly key: string;
|
|
571
|
+
/** `""` on the events the host dispatches. */
|
|
572
|
+
readonly code: string;
|
|
573
|
+
/** `0` on the events the host dispatches. */
|
|
574
|
+
readonly location: number;
|
|
575
|
+
/** Whether the key press is an auto-repeat. */
|
|
576
|
+
readonly repeat: boolean;
|
|
577
|
+
/** Whether an input method composes in the focused `<input>`. */
|
|
578
|
+
readonly isComposing: boolean;
|
|
579
|
+
/** The key's code on a US keyboard layout, and `0` for a key outside it. */
|
|
580
|
+
readonly keyCode: number;
|
|
581
|
+
/** `0` on the events the host dispatches. */
|
|
582
|
+
readonly charCode: number;
|
|
583
|
+
readonly ctrlKey: boolean;
|
|
584
|
+
readonly shiftKey: boolean;
|
|
585
|
+
readonly altKey: boolean;
|
|
586
|
+
readonly metaKey: boolean;
|
|
587
|
+
readonly DOM_KEY_LOCATION_STANDARD: 0;
|
|
588
|
+
readonly DOM_KEY_LOCATION_LEFT: 1;
|
|
589
|
+
readonly DOM_KEY_LOCATION_RIGHT: 2;
|
|
590
|
+
readonly DOM_KEY_LOCATION_NUMPAD: 3;
|
|
591
|
+
/**
|
|
592
|
+
* Whether the modifier `key` is held: `"Control"`, `"Shift"`, `"Alt"`,
|
|
593
|
+
* `"Meta"`, or `"Accel"` (Meta on macOS, Control elsewhere). Any other name
|
|
594
|
+
* gives `false`.
|
|
595
|
+
*/
|
|
596
|
+
getModifierState(key: string): boolean;
|
|
597
|
+
}
|
|
598
|
+
/** The event object of `beforeinput` and `input`. */
|
|
599
|
+
interface IncaInputEvent extends IncaUIEvent {
|
|
600
|
+
/**
|
|
601
|
+
* The inserted text, or `null` for a deletion and a line break. On `input`, `null` for an empty
|
|
602
|
+
* composition text too.
|
|
603
|
+
*/
|
|
604
|
+
readonly data: string | null;
|
|
605
|
+
/**
|
|
606
|
+
* On the events the host dispatches, one of `insertText`, `insertFromPaste`,
|
|
607
|
+
* `insertCompositionText`, `insertLineBreak`, `deleteContentBackward`, `deleteContentForward`
|
|
608
|
+
* and `deleteByCut`.
|
|
609
|
+
*/
|
|
610
|
+
readonly inputType: string;
|
|
611
|
+
/** Whether the edit belongs to a composition. */
|
|
612
|
+
readonly isComposing: boolean;
|
|
613
|
+
/** Always `null`. */
|
|
614
|
+
readonly dataTransfer: null;
|
|
615
|
+
/** Returns a new empty array. */
|
|
616
|
+
getTargetRanges(): [];
|
|
617
|
+
}
|
|
618
|
+
/** The event object of `compositionstart`, `compositionupdate` and `compositionend`. */
|
|
619
|
+
interface IncaCompositionEvent extends IncaUIEvent {
|
|
620
|
+
/** The composed text. For `compositionstart`, the text the composition replaces. */
|
|
621
|
+
readonly data: string;
|
|
622
|
+
}
|
|
623
|
+
/** The event object of each event name the host dispatches. */
|
|
624
|
+
interface IncaEventMap {
|
|
625
|
+
auxclick: IncaPointerEvent;
|
|
626
|
+
beforeinput: IncaInputEvent;
|
|
627
|
+
blur: IncaFocusEvent;
|
|
628
|
+
change: IncaEvent;
|
|
629
|
+
click: IncaPointerEvent;
|
|
630
|
+
compositionend: IncaCompositionEvent;
|
|
631
|
+
compositionstart: IncaCompositionEvent;
|
|
632
|
+
compositionupdate: IncaCompositionEvent;
|
|
633
|
+
contextmenu: IncaPointerEvent;
|
|
634
|
+
dblclick: IncaMouseEvent;
|
|
635
|
+
focus: IncaFocusEvent;
|
|
636
|
+
focusin: IncaFocusEvent;
|
|
637
|
+
focusout: IncaFocusEvent;
|
|
638
|
+
gotpointercapture: IncaPointerEvent;
|
|
639
|
+
input: IncaInputEvent;
|
|
640
|
+
keydown: IncaKeyboardEvent;
|
|
641
|
+
keyup: IncaKeyboardEvent;
|
|
642
|
+
lostpointercapture: IncaPointerEvent;
|
|
643
|
+
mousedown: IncaMouseEvent;
|
|
644
|
+
mouseenter: IncaMouseEvent;
|
|
645
|
+
mouseleave: IncaMouseEvent;
|
|
646
|
+
mousemove: IncaMouseEvent;
|
|
647
|
+
mouseout: IncaMouseEvent;
|
|
648
|
+
mouseover: IncaMouseEvent;
|
|
649
|
+
mouseup: IncaMouseEvent;
|
|
650
|
+
pointerdown: IncaPointerEvent;
|
|
651
|
+
pointerenter: IncaPointerEvent;
|
|
652
|
+
pointerleave: IncaPointerEvent;
|
|
653
|
+
pointermove: IncaPointerEvent;
|
|
654
|
+
pointerout: IncaPointerEvent;
|
|
655
|
+
pointerover: IncaPointerEvent;
|
|
656
|
+
pointerup: IncaPointerEvent;
|
|
657
|
+
scroll: IncaEvent;
|
|
658
|
+
wheel: IncaWheelEvent;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Signature of a callback registered via `addEventListener`. It receives the
|
|
662
|
+
* event, an {@link IncaEvent} unless the parameter declares another type, and
|
|
663
|
+
* runs with the event's `currentTarget`, the target it was registered on, as
|
|
664
|
+
* `this`.
|
|
665
|
+
*/
|
|
666
|
+
type EventListener<E = IncaEvent, T = IncaEventTarget> = (this: T, event: E) => void;
|
|
667
|
+
/**
|
|
668
|
+
* An object whose `handleEvent` method receives the events, called with the
|
|
669
|
+
* object as `this`. It takes the event an {@link EventListener} takes.
|
|
670
|
+
*/
|
|
671
|
+
interface EventListenerObject<E = IncaEvent> {
|
|
672
|
+
handleEvent(event: E): void;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* What `addEventListener` accepts as a listener: an {@link EventListener} or
|
|
676
|
+
* an {@link EventListenerObject}.
|
|
677
|
+
*/
|
|
678
|
+
type EventListenerOrObject<E = IncaEvent, T = IncaEventTarget> = EventListener<E, T> | EventListenerObject<E>;
|
|
679
|
+
/**
|
|
680
|
+
* The event target at the top of the app, after `document`. Every event path
|
|
681
|
+
* ends at it. Bubble listeners on it run for every bubbling event, and capture
|
|
682
|
+
* listeners run for every event dispatched in the app, including events that
|
|
683
|
+
* do not bubble. A key event reaches it through the mount container and
|
|
684
|
+
* `document`. A `wheel` listener is passive unless its options say
|
|
685
|
+
* `passive: false`.
|
|
686
|
+
*
|
|
687
|
+
* It has the listener methods `addEventListener`, `removeEventListener` and
|
|
688
|
+
* `dispatchEvent`, and the event handler properties such as `onkeydown`.
|
|
689
|
+
*/
|
|
690
|
+
declare const window: IncaWindow;
|
|
691
|
+
export { IncaInputElement as A, Overflow as C, EventHandler as D, TagName as E, RectLike as F, RectValues as I, IncaText as M, ScrollIntoViewOptions as N, EventHandlers as O, ScrollOptions as P, NodeId as S, StyleProps as T, IncaPointerEvent as _, EventListener as a, IncaWindow as b, IncaCompositionEvent as c, IncaEventMap as d, IncaEventTarget as f, IncaMouseEvent as g, IncaKeyboardEvent as h, EventLike as i, IncaNode as j, IncaElement as k, IncaDocument as l, IncaInputEvent as m, AttributeValue as n, EventListenerObject as o, IncaFocusEvent as p, CallbackId as r, EventListenerOrObject as s, window as t, IncaEvent as u, IncaUIEvent as v, ScrollAlignment as w, ListenerOptions as x, IncaWheelEvent as y };
|