@silkui/core 0.1.8 → 0.1.10

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/src/index.d.ts CHANGED
@@ -37,7 +37,12 @@ export interface Look {
37
37
  }
38
38
 
39
39
  export type Listener<E extends Event = Event> = ((this: Node, event: E) => void) | { handleEvent(event: E): void };
40
- export type ListenerOptions = boolean | { capture?: boolean; once?: boolean };
40
+ /** What `signal` needs from an `AbortSignal`. */
41
+ export interface ListenerSignal {
42
+ readonly aborted: boolean;
43
+ addEventListener(type: "abort", listener: () => void, options?: { once?: boolean }): void;
44
+ }
45
+ export type ListenerOptions = boolean | { capture?: boolean; once?: boolean; signal?: ListenerSignal };
41
46
 
42
47
  /** Live tokens in a node's class attribute. */
43
48
  export class ClassList implements Iterable<string> {
@@ -74,8 +79,17 @@ export class Node {
74
79
  readonly lastChild: Node | null;
75
80
  readonly nextSibling: Node | null;
76
81
  readonly previousSibling: Node | null;
82
+ /** 1 for an element, 3 for text, 11 for a document fragment, as in the DOM. */
83
+ readonly nodeType: 1 | 3 | 11;
84
+ hasChildNodes(): boolean;
85
+ /** A copy with the same looks and attributes, and with `deep` copies of the children. */
86
+ cloneNode(deep?: boolean): this;
87
+ /** Joins adjacent text children and drops empty ones, in the whole subtree. */
88
+ normalize(): void;
77
89
  /** Whether `other` is this node or inside it. */
78
90
  contains(other: Node | null): boolean;
91
+ /** Puts `node` where `child` is and detaches `child`. */
92
+ replaceChild<T extends Node>(node: Node, child: T): T;
79
93
  /** Inserts `child` before `before`, or last without it. A child already in the tree moves. */
80
94
  insertBefore<T extends Node>(child: T, before?: Node | null): T;
81
95
  appendChild<T extends Node>(child: T): T;
@@ -104,8 +118,44 @@ export class Node {
104
118
  set tabIndex(value: number);
105
119
  set disabled(value: boolean);
106
120
  focus(): void;
121
+ /** As DOM `setPointerCapture`: throws `NotFoundError` for a pointer that is not down. */
122
+ setPointerCapture(pointerId: number): void;
123
+ releasePointerCapture(pointerId: number): void;
124
+ hasPointerCapture(pointerId: number): boolean;
107
125
  scrollTo(x: number, y: number): void;
126
+ scrollTo(options: ScrollToOptions): void;
108
127
  scroll(x: number, y: number): void;
128
+ scroll(options: ScrollToOptions): void;
129
+ scrollBy(x: number, y: number): void;
130
+ scrollBy(options: ScrollToOptions): void;
131
+ /** `true` or nothing aligns to the start, `false` to the end. */
132
+ scrollIntoView(options?: boolean | ScrollIntoViewOptions): void;
133
+ scrollIntoViewIfNeeded(center?: boolean): void;
134
+ /** Layout reads: each lays out first when something changed, as a browser does. */
135
+ getBoundingClientRect(): DOMRect;
136
+ getClientRects(): DOMRect[] & { item(index: number): DOMRect | null };
137
+ readonly clientLeft: number;
138
+ readonly clientTop: number;
139
+ readonly clientWidth: number;
140
+ readonly clientHeight: number;
141
+ readonly scrollWidth: number;
142
+ readonly scrollHeight: number;
143
+ scrollLeft: number;
144
+ scrollTop: number;
145
+ readonly offsetParent: Node | null;
146
+ readonly offsetLeft: number;
147
+ readonly offsetTop: number;
148
+ readonly offsetWidth: number;
149
+ readonly offsetHeight: number;
150
+ /** Whether this node matches CSS `selector`, by the stylesheet matcher. Throws a SyntaxError for an invalid selector. */
151
+ matches(selector: string): boolean;
152
+ webkitMatchesSelector(selector: string): boolean;
153
+ /** This node or its nearest ancestor that matches `selector`. */
154
+ closest(selector: string): Node | null;
155
+ /** The first descendant, in tree order, that matches `selector`. */
156
+ querySelector(selector: string): Node | null;
157
+ /** Every descendant that matches `selector`, in tree order (a static list). */
158
+ querySelectorAll(selector: string): Node[];
109
159
  addEventListener<K extends keyof EventMap>(type: K, listener: Listener<EventMap[K]>, options?: ListenerOptions): void;
110
160
  /** The app's own event types, sent with `dispatchEvent`. */
111
161
  addEventListener(type: string, listener: (event: globalThis.Event) => void, options?: ListenerOptions): void;
@@ -119,17 +169,149 @@ export class Node {
119
169
  export class Text extends Node {
120
170
  constructor(data?: string);
121
171
  data: string;
172
+ nodeValue: string;
122
173
  textContent: string;
174
+ /** In UTF-16 code units. */
175
+ readonly length: number;
176
+ substringData(offset: number, count: number): string;
177
+ appendData(data: string): void;
178
+ insertData(offset: number, data: string): void;
179
+ deleteData(offset: number, count: number): void;
180
+ replaceData(offset: number, count: number, data: string): void;
181
+ /** Splits at `offset`: this keeps the text before it, and a new next sibling the rest. */
182
+ splitText(offset: number): Text;
123
183
  }
124
184
 
125
- /** An editable text field. `value` follows what the user types. */
185
+ /** Nodes held together outside the tree. Inserting it inserts its children and empties it. */
186
+ export class DocumentFragment extends Node {
187
+ constructor();
188
+ }
189
+
190
+ export function createDocumentFragment(): DocumentFragment;
191
+
192
+ /** Two boundary points: a node and an offset (a child index, or UTF-16 units in text). */
193
+ export abstract class AbstractRange {
194
+ readonly startContainer: Node;
195
+ readonly startOffset: number;
196
+ readonly endContainer: Node;
197
+ readonly endOffset: number;
198
+ readonly collapsed: boolean;
199
+ }
200
+
201
+ export interface StaticRangeInit {
202
+ startContainer: Node;
203
+ startOffset: number;
204
+ endContainer: Node;
205
+ endOffset: number;
206
+ }
207
+
208
+ /** A range that does not follow changes to the tree. */
209
+ export class StaticRange extends AbstractRange {
210
+ constructor(init: StaticRangeInit);
211
+ }
212
+
213
+ /** A live range over the app's nodes, as the DOM Standard defines it. */
214
+ export class Range extends AbstractRange {
215
+ static readonly START_TO_START: 0;
216
+ static readonly START_TO_END: 1;
217
+ static readonly END_TO_END: 2;
218
+ static readonly END_TO_START: 3;
219
+ readonly START_TO_START: 0;
220
+ readonly START_TO_END: 1;
221
+ readonly END_TO_END: 2;
222
+ readonly END_TO_START: 3;
223
+ /** Collapsed at the start of the mounted root. */
224
+ constructor();
225
+ readonly commonAncestorContainer: Node;
226
+ setStart(node: Node, offset: number): void;
227
+ setEnd(node: Node, offset: number): void;
228
+ setStartBefore(node: Node): void;
229
+ setStartAfter(node: Node): void;
230
+ setEndBefore(node: Node): void;
231
+ setEndAfter(node: Node): void;
232
+ collapse(toStart?: boolean): void;
233
+ selectNode(node: Node): void;
234
+ selectNodeContents(node: Node): void;
235
+ compareBoundaryPoints(how: 0 | 1 | 2 | 3, sourceRange: Range): -1 | 0 | 1;
236
+ comparePoint(node: Node, offset: number): -1 | 0 | 1;
237
+ isPointInRange(node: Node, offset: number): boolean;
238
+ intersectsNode(node: Node): boolean;
239
+ cloneRange(): Range;
240
+ detach(): void;
241
+ deleteContents(): void;
242
+ extractContents(): DocumentFragment;
243
+ cloneContents(): DocumentFragment;
244
+ insertNode(node: Node): void;
245
+ surroundContents(newParent: Node): void;
246
+ toString(): string;
247
+ getClientRects(): DOMRect[];
248
+ getBoundingClientRect(): DOMRect;
249
+ }
250
+
251
+ /** A new live range, collapsed at the start of the root. */
252
+ export function createRange(): Range;
253
+
254
+ /**
255
+ * The document's selection, which the tree keeps (presses, drags, keys) and scripts can read
256
+ * and change. Its ranges are live, in tree order: one, or one per piece seen when the
257
+ * selection crosses children that layout reorders.
258
+ */
259
+ export class Selection {
260
+ private constructor();
261
+ readonly anchorNode: Node | null;
262
+ readonly anchorOffset: number;
263
+ readonly focusNode: Node | null;
264
+ readonly focusOffset: number;
265
+ readonly isCollapsed: boolean;
266
+ readonly rangeCount: number;
267
+ readonly type: "None" | "Caret" | "Range";
268
+ readonly direction: "forward" | "backward" | "none";
269
+ getRangeAt(index: number): Range;
270
+ addRange(range: Range): void;
271
+ removeRange(range: Range): void;
272
+ removeAllRanges(): void;
273
+ empty(): void;
274
+ collapse(node: Node | null, offset?: number): void;
275
+ setPosition(node: Node | null, offset?: number): void;
276
+ collapseToStart(): void;
277
+ collapseToEnd(): void;
278
+ extend(node: Node, offset?: number): void;
279
+ setBaseAndExtent(anchorNode: Node, anchorOffset: number, focusNode: Node, focusOffset: number): void;
280
+ selectAllChildren(node: Node): void;
281
+ deleteFromDocument(): void;
282
+ containsNode(node: Node, allowPartialContainment?: boolean): boolean;
283
+ getComposedRanges(): StaticRange[];
284
+ /** The selected text as copying gives it. */
285
+ toString(): string;
286
+ }
287
+
288
+ /** The document's selection. Also installed as `globalThis.getSelection`. */
289
+ export function getSelection(): Selection;
290
+
291
+ /**
292
+ * An editable text field. `value` follows what the user types. Selection offsets are UTF-16
293
+ * string indices, as on the web.
294
+ */
126
295
  export class Input extends Node {
127
296
  constructor();
297
+ /** Setting a different value puts the caret at its end. */
128
298
  value: string;
129
- readonly selectionStart: number;
130
- readonly selectionEnd: number;
131
- /** Selects from `anchor` to `focus`, as UTF-8 byte offsets in the value. */
132
- setSelectionRange(anchor: number, focus: number): void;
299
+ selectionStart: number;
300
+ selectionEnd: number;
301
+ selectionDirection: "forward" | "backward" | "none";
302
+ /** Selects `start` to `end`; with `direction` "backward" the caret sits at `start`. */
303
+ setSelectionRange(start: number, end: number, direction?: "forward" | "backward" | "none"): void;
304
+ /** Selects the whole value. */
305
+ select(): void;
306
+ /** Replaces the selection with `replacement`. */
307
+ setRangeText(replacement: string): void;
308
+ /** Replaces `start` to `end` with `replacement` and places the selection by `selectionMode`. */
309
+ setRangeText(
310
+ replacement: string,
311
+ start: number,
312
+ end: number,
313
+ selectionMode?: "select" | "start" | "end" | "preserve",
314
+ ): void;
133
315
  }
134
316
 
135
317
  /** An inline atom of a rich input: a mention or a chip. */
@@ -175,8 +357,6 @@ export class RichInput extends Input {
175
357
  toggleMark(name: string): void;
176
358
  /** Replaces the text from `start` to `end` with `atom`. */
177
359
  insertAtom(start: number, end: number, atom: RichAtom): void;
178
- /** Selects from `anchor` to `focus`, as string indices. */
179
- setSelectionRange(anchor: number, focus: number): void;
180
360
  }
181
361
 
182
362
  /**
@@ -188,6 +368,19 @@ export class Image extends Node {
188
368
  src: string;
189
369
  }
190
370
 
371
+ /**
372
+ * A canvas the application draws with WebGPU, as a `<canvas>`: `width` and `height` are the
373
+ * drawing's size in pixels and `getContext("webgpu")` gives its `GPUCanvasContext` (the types
374
+ * of `@webgpu/types` describe it). Drawing runs on a GPU device of the application's own.
375
+ */
376
+ export class Canvas extends Node {
377
+ constructor();
378
+ width: number;
379
+ height: number;
380
+ getContext(kind: "webgpu"): unknown | null;
381
+ getContext(kind: string): unknown | null;
382
+ }
383
+
191
384
  /** Text inside an `<svg>`. */
192
385
  export class SvgText {
193
386
  constructor(data?: string);
@@ -198,7 +391,10 @@ export class SvgText {
198
391
  destroy(): void;
199
392
  }
200
393
 
201
- /** An element inside an `<svg>` (`path`, `g`, `circle`...): markup its root draws, no node. */
394
+ /**
395
+ * An element inside an `<svg>` (`path`, `g`, `circle`...): markup its root draws, no node.
396
+ * Once the root has drawn, a change to its elements updates them one at a time.
397
+ */
202
398
  export class SvgElement {
203
399
  constructor(tag: string);
204
400
  readonly localName: string;
@@ -212,6 +408,26 @@ export class SvgElement {
212
408
  /** SVG's names, or React's spellings (`strokeWidth`, `xlinkHref`). */
213
409
  setAttribute(name: string, value: unknown): void;
214
410
  removeAttribute(name: string): void;
411
+ setAttributeNS(namespace: string | null, name: string, value: unknown): void;
412
+ getAttributeNS(namespace: string | null, name: string): string | null;
413
+ removeAttributeNS(namespace: string | null, name: string): void;
414
+ /** The `style` attribute as declarations: `element.style.display = "none"`. */
415
+ readonly style: Record<string, string>;
416
+ /**
417
+ * Hears pointer events (`click`, `pointerdown`, `pointerenter`...) on its shapes, as on the
418
+ * web; its `<svg>` turns live so the tree can tell which shape is under the pointer.
419
+ */
420
+ addEventListener<K extends keyof EventMap>(type: K, listener: Listener<EventMap[K]>, options?: ListenerOptions): void;
421
+ addEventListener(type: string, listener: (event: globalThis.Event) => void, options?: ListenerOptions): void;
422
+ removeEventListener<K extends keyof EventMap>(type: K, listener: Listener<EventMap[K]>, options?: ListenerOptions): void;
423
+ removeEventListener(type: string, listener: (event: globalThis.Event) => void, options?: ListenerOptions): void;
424
+ dispatchEvent(event: globalThis.Event): boolean;
425
+ /** The box of its geometry in its own user space: a shape's fill, a group's children. */
426
+ getBBox(): { x: number; y: number; width: number; height: number };
427
+ /** The length of a shape's outline in user units. */
428
+ getTotalLength(): number;
429
+ /** The point `distance` along a shape's outline, clamped to its ends. */
430
+ getPointAtLength(distance: number): { x: number; y: number };
215
431
  insertBefore<T extends SvgElement | SvgText | Text>(child: T, before?: SvgElement | SvgText | Text | null): T;
216
432
  appendChild<T extends SvgElement | SvgText | Text>(child: T): T;
217
433
  append(...children: (SvgElement | SvgText | Text | string)[]): void;
@@ -224,11 +440,16 @@ export class SvgElement {
224
440
  * An inline `<svg>`: one node drawing the markup its `SvgElement` children make, at its CSS
225
441
  * size (else its `width` and `height`, else a square of the font size), with its `color` as
226
442
  * `currentColor`. Class, look, events and ARIA are the node's; `viewBox`, `fill`, `width`
227
- * and the rest are markup.
443
+ * and the rest are markup. After its first draw, changes go to the tree element by element
444
+ * and only the shapes that changed redraw, so scripts can animate it (lottie-web and the like).
228
445
  */
229
446
  export class Svg extends Node {
230
447
  constructor();
231
448
  readonly outerHTML: string;
449
+ setAttributeNS(namespace: string | null, name: string, value: unknown): void;
450
+ getAttributeNS(namespace: string | null, name: string): string | null;
451
+ /** The box of what it draws, in its user space (inside `viewBox`). */
452
+ getBBox(): { x: number; y: number; width: number; height: number };
232
453
  textContent: string;
233
454
  }
234
455
 
@@ -262,6 +483,26 @@ export interface PointerEvent extends ModifierEvent {
262
483
  readonly clientY: number;
263
484
  readonly x: number;
264
485
  readonly y: number;
486
+ /** 1 for the mouse, 2 and up for touches. */
487
+ readonly pointerId: number;
488
+ readonly pointerType: "mouse" | "pen" | "touch";
489
+ readonly isPrimary: boolean;
490
+ /** -1 for `pointermove`, as on the web. */
491
+ readonly button: number;
492
+ readonly buttons: number;
493
+ /** 0.5 while a button is down, 0 otherwise: no host reports pressure yet. */
494
+ readonly pressure: number;
495
+ readonly tangentialPressure: number;
496
+ readonly tiltX: number;
497
+ readonly tiltY: number;
498
+ readonly twist: number;
499
+ readonly altitudeAngle: number;
500
+ readonly azimuthAngle: number;
501
+ readonly width: number;
502
+ readonly height: number;
503
+ /** The event itself for `pointermove` (each host move is its own event), empty otherwise. */
504
+ getCoalescedEvents(): PointerEvent[];
505
+ getPredictedEvents(): PointerEvent[];
265
506
  }
266
507
 
267
508
  /** `pointerdown`, `pointerup` and `click`. */
@@ -271,6 +512,48 @@ export interface PointerButtonEvent extends PointerEvent {
271
512
  readonly detail: number;
272
513
  }
273
514
 
515
+ /** A compatibility mouse event, after the pointer event of a mouse, or before a tap's click. */
516
+ export interface MouseEvent extends ModifierEvent {
517
+ readonly clientX: number;
518
+ readonly clientY: number;
519
+ readonly x: number;
520
+ readonly y: number;
521
+ readonly button: number;
522
+ readonly buttons: number;
523
+ readonly detail: number;
524
+ }
525
+
526
+ /** One finger, as DOM `Touch`. No host reports contact size or force yet. */
527
+ export interface Touch {
528
+ readonly identifier: number;
529
+ /** The node the finger went down on, for as long as it stays down. */
530
+ readonly target: Node;
531
+ readonly clientX: number;
532
+ readonly clientY: number;
533
+ readonly pageX: number;
534
+ readonly pageY: number;
535
+ readonly screenX: number;
536
+ readonly screenY: number;
537
+ readonly radiusX: number;
538
+ readonly radiusY: number;
539
+ readonly rotationAngle: number;
540
+ readonly force: number;
541
+ }
542
+
543
+ export interface TouchList extends ReadonlyArray<Touch> {
544
+ item(index: number): Touch | null;
545
+ }
546
+
547
+ /**
548
+ * As DOM `TouchEvent`, after the finger's pointer event. Preventing `touchstart` or a
549
+ * `touchmove` before the tree pans keeps the gesture: no pan and no click.
550
+ */
551
+ export interface TouchEvent extends ModifierEvent {
552
+ readonly touches: TouchList;
553
+ readonly targetTouches: TouchList;
554
+ readonly changedTouches: TouchList;
555
+ }
556
+
274
557
  export interface WheelEvent extends PointerEvent {
275
558
  readonly deltaX: number;
276
559
  readonly deltaY: number;
@@ -299,6 +582,17 @@ export interface SelectionEvent<T extends Node = Input> extends Event {
299
582
  readonly selectionEnd: number;
300
583
  }
301
584
 
585
+ /** An edit about to change an input (`beforeinput`), as the web's `InputEvent`. Preventing it cancels the edit. */
586
+ export interface BeforeInputEvent<T extends Node = Input> extends Event {
587
+ readonly target: FieldOf<T>;
588
+ readonly inputType: string;
589
+ /** The text the edit inserts. */
590
+ readonly data: string | null;
591
+ readonly dataTransfer: DataTransfer | null;
592
+ readonly isComposing: boolean;
593
+ getTargetRanges(): never[];
594
+ }
595
+
302
596
  export interface ScrollEvent extends Event {
303
597
  readonly scrollLeft: number;
304
598
  readonly scrollTop: number;
@@ -330,6 +624,19 @@ export interface EventMap {
330
624
  pointerenter: PointerEvent;
331
625
  pointerleave: PointerEvent;
332
626
  pointercancel: PointerEvent;
627
+ pointerover: PointerEvent;
628
+ pointerout: PointerEvent;
629
+ touchstart: TouchEvent;
630
+ touchmove: TouchEvent;
631
+ touchend: TouchEvent;
632
+ touchcancel: TouchEvent;
633
+ mousedown: MouseEvent;
634
+ mouseup: MouseEvent;
635
+ mousemove: MouseEvent;
636
+ mouseover: MouseEvent;
637
+ mouseout: MouseEvent;
638
+ mouseenter: MouseEvent;
639
+ mouseleave: MouseEvent;
333
640
  wheel: WheelEvent;
334
641
  keydown: KeyboardEvent;
335
642
  keyup: KeyboardEvent;
@@ -337,6 +644,10 @@ export interface EventMap {
337
644
  blur: Event;
338
645
  input: InputEvent;
339
646
  selectionchange: SelectionEvent;
647
+ copy: ClipboardEvent;
648
+ cut: ClipboardEvent;
649
+ paste: ClipboardEvent;
650
+ beforeinput: BeforeInputEvent;
340
651
  scroll: ScrollEvent;
341
652
  layout: LayoutEvent;
342
653
  gotpointercapture: Event;
@@ -361,6 +672,7 @@ export function createNode(kind: "text"): Text;
361
672
  export function createNode(kind: "input"): Input;
362
673
  export function createNode(kind: "richinput"): RichInput;
363
674
  export function createNode(kind: "image" | "img"): Image;
675
+ export function createNode(kind: "canvas"): Canvas;
364
676
  export function createNode(kind: "svg"): Svg;
365
677
  export function createNode(kind: NodeKind): Node;
366
678
 
@@ -425,14 +737,58 @@ export class DroppedFile {
425
737
  readonly type: string;
426
738
  }
427
739
 
428
- /** What a file drag carries. `files` is filled in `drop`, as on the web. */
740
+ /** A file in a `DataTransfer` that is no file on disk, such as a pasted image: the runtime's `File`. */
741
+ export interface DataFile {
742
+ readonly name: string;
743
+ readonly type: string;
744
+ readonly size: number;
745
+ arrayBuffer(): Promise<ArrayBuffer>;
746
+ text(): Promise<string>;
747
+ }
748
+
749
+ /** One entry of a `DataTransfer`. */
750
+ export interface DataTransferItem {
751
+ readonly kind: "string" | "file";
752
+ readonly type: string;
753
+ getAsString(callback: (value: string) => void): void;
754
+ getAsFile(): DataFile | DroppedFile | null;
755
+ }
756
+
757
+ export interface DataTransferItemList extends Iterable<DataTransferItem> {
758
+ readonly length: number;
759
+ readonly [index: number]: DataTransferItem;
760
+ add(data: string, type: string): DataTransferItem;
761
+ add(file: DataFile | DroppedFile): DataTransferItem;
762
+ remove(index: number): void;
763
+ clear(): void;
764
+ }
765
+
766
+ /**
767
+ * What a copy, cut, paste or file drag carries, as the web's. `new DataTransfer()` is empty
768
+ * and writable; a paste's is read-only, and after its event none can be read.
769
+ */
429
770
  export class DataTransfer {
430
- readonly files: DroppedFile[];
431
- readonly items: { kind: "file"; type: string; getAsFile(): DroppedFile }[];
432
- readonly types: string[];
771
+ constructor();
772
+ readonly files: readonly (DataFile | DroppedFile)[];
773
+ readonly items: DataTransferItemList;
774
+ readonly types: readonly string[];
433
775
  dropEffect: string;
434
776
  effectAllowed: string;
435
777
  getData(format: string): string;
778
+ setData(format: string, data: string): void;
779
+ clearData(format?: string): void;
780
+ setDragImage(image: unknown, x: number, y: number): void;
781
+ }
782
+
783
+ /**
784
+ * A copy, cut or paste at the focused node, as the web's. A `copy` or `cut` listener that sets
785
+ * data on `clipboardData` and prevents the default puts that data on the clipboard; a `paste`
786
+ * listener reads what it holds (`text/plain`, `text/html`, a pasted PNG in `files`), and
787
+ * preventing it keeps the paste out of the input.
788
+ */
789
+ export class ClipboardEvent extends Event {
790
+ constructor(type: string, init?: { bubbles?: boolean; cancelable?: boolean; composed?: boolean; clipboardData?: DataTransfer | null });
791
+ readonly clipboardData: DataTransfer | null;
436
792
  }
437
793
 
438
794
  /** Files dragged from another app over the window (`dragenter`, `dragover`, `dragleave`, `drop`). */
@@ -508,6 +864,30 @@ export interface MemoryUsage {
508
864
  */
509
865
  export function memoryUsage(): MemoryUsage | null;
510
866
 
867
+ /**
868
+ * The values the tree resolved for `node`, read one property at a time: typed and animated
869
+ * properties as they are now, box sizes, margins, padding and border widths as laid out, the
870
+ * rest as cascaded with lengths in pixels. Shorthands, custom properties and pseudo-elements
871
+ * read "". Also installed as `globalThis.getComputedStyle`.
872
+ */
873
+ export function getComputedStyle(node: Node | { node: Node }, pseudo?: string | null): ComputedStyle;
874
+
875
+ /**
876
+ * `CSS.supports`, answered as the tree's `@supports` answers. Also installed as
877
+ * `globalThis.CSS.supports`.
878
+ */
879
+ export function supports(property: string, value: string): boolean;
880
+ export function supports(conditionText: string): boolean;
881
+
882
+ /** What `getComputedStyle` returns: read-only, live, a value per camelCase property name. */
883
+ export type ComputedStyle = {
884
+ getPropertyValue(name: string): string;
885
+ getPropertyPriority(name: string): string;
886
+ item(index: number): string;
887
+ readonly cssText: string;
888
+ readonly length: number;
889
+ } & { readonly [property: string]: string };
890
+
511
891
  /** What the window put on screen over a stretch of time; see `frameStats`. */
512
892
  export interface FrameStats {
513
893
  /** Frames presented. */
@@ -529,3 +909,99 @@ export interface FrameStats {
529
909
  * `null` in a browser build.
530
910
  */
531
911
  export function frameStats(): FrameStats | null;
912
+
913
+ export type ScrollBehavior = "auto" | "instant" | "smooth";
914
+ export type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
915
+
916
+ export interface ScrollToOptions {
917
+ left?: number;
918
+ top?: number;
919
+ /** `auto` follows the node's `scroll-behavior`. */
920
+ behavior?: ScrollBehavior;
921
+ }
922
+
923
+ export interface ScrollIntoViewOptions {
924
+ block?: ScrollLogicalPosition;
925
+ inline?: ScrollLogicalPosition;
926
+ behavior?: ScrollBehavior;
927
+ }
928
+
929
+ /** As `DOMRect` on the web. Also installed as `globalThis.DOMRect` when there is none. */
930
+ export class DOMRect {
931
+ constructor(x?: number, y?: number, width?: number, height?: number);
932
+ x: number;
933
+ y: number;
934
+ width: number;
935
+ height: number;
936
+ readonly left: number;
937
+ readonly top: number;
938
+ readonly right: number;
939
+ readonly bottom: number;
940
+ toJSON(): { x: number; y: number; width: number; height: number; top: number; right: number; bottom: number; left: number };
941
+ }
942
+
943
+ /** The topmost node at window point `x`, `y`. */
944
+ export function elementFromPoint(x: number, y: number): Node | null;
945
+ /** Every node at window point `x`, `y`, topmost first. */
946
+ export function elementsFromPoint(x: number, y: number): Node[];
947
+ /** The text position at window point `x`, `y`, the offset in UTF-16 units. */
948
+ export function caretPositionFromPoint(x: number, y: number): { offsetNode: Node | null; offset: number; getClientRect(): DOMRect } | null;
949
+ /** `Range.getClientRects` for the text from (`startNode`, `startOffset`) to (`endNode`, `endOffset`), offsets in UTF-16 units. */
950
+ export function rangeClientRects(startNode: Node, startOffset: number, endNode: Node, endOffset: number): DOMRect[];
951
+ /** `Range.getBoundingClientRect` for the same range. */
952
+ export function rangeBoundingClientRect(startNode: Node, startOffset: number, endNode: Node, endOffset: number): DOMRect;
953
+
954
+ type Observable = Node | { node: Node };
955
+
956
+ export interface IntersectionObserverInit {
957
+ /** A node, or null for the window. */
958
+ root?: Observable | null;
959
+ rootMargin?: string;
960
+ scrollMargin?: string;
961
+ threshold?: number | number[];
962
+ }
963
+
964
+ export class IntersectionObserverEntry {
965
+ readonly time: number;
966
+ readonly target: Observable;
967
+ readonly isIntersecting: boolean;
968
+ readonly isVisible: boolean;
969
+ readonly intersectionRatio: number;
970
+ readonly boundingClientRect: DOMRect;
971
+ readonly intersectionRect: DOMRect;
972
+ readonly rootBounds: DOMRect | null;
973
+ }
974
+
975
+ /** As on the web. Entries come after a layout or scroll in which a target crossed a threshold. Also installed as `globalThis.IntersectionObserver`. */
976
+ export class IntersectionObserver {
977
+ constructor(callback: (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void, options?: IntersectionObserverInit);
978
+ readonly root: Observable | null;
979
+ readonly rootMargin: string;
980
+ readonly scrollMargin: string;
981
+ readonly thresholds: readonly number[];
982
+ observe(target: Observable): void;
983
+ unobserve(target: Observable): void;
984
+ disconnect(): void;
985
+ takeRecords(): IntersectionObserverEntry[];
986
+ }
987
+
988
+ export interface ResizeObserverSize {
989
+ readonly inlineSize: number;
990
+ readonly blockSize: number;
991
+ }
992
+
993
+ export class ResizeObserverEntry {
994
+ readonly target: Observable;
995
+ readonly contentRect: DOMRect;
996
+ readonly borderBoxSize: readonly ResizeObserverSize[];
997
+ readonly contentBoxSize: readonly ResizeObserverSize[];
998
+ readonly devicePixelContentBoxSize: readonly ResizeObserverSize[];
999
+ }
1000
+
1001
+ /** As on the web. Entries come after a layout that changed an observed box. Also installed as `globalThis.ResizeObserver`. */
1002
+ export class ResizeObserver {
1003
+ constructor(callback: (entries: ResizeObserverEntry[], observer: ResizeObserver) => void);
1004
+ observe(target: Observable, options?: { box?: "content-box" | "border-box" | "device-pixel-content-box" }): void;
1005
+ unobserve(target: Observable): void;
1006
+ disconnect(): void;
1007
+ }