@silkui/core 0.1.12 → 0.1.13

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
@@ -33,6 +33,11 @@ export interface Look {
33
33
  replace(properties: Style): void;
34
34
  /** A property as the tree got it, in CSS text (`"120px"`). */
35
35
  get(name: keyof Style): string | undefined;
36
+ /** CSSOM's: by CSS name (`background-color`) or custom property (`--accent`). */
37
+ setProperty(name: string, value: string | null, priority?: string): void;
38
+ getPropertyValue(name: string): string;
39
+ removeProperty(name: string): string;
40
+ getPropertyPriority(name: string): string;
36
41
  readonly cssText: string;
37
42
  }
38
43
 
@@ -81,6 +86,8 @@ export class Node {
81
86
  readonly previousSibling: Node | null;
82
87
  /** 1 for an element, 3 for text, 11 for a document fragment, as in the DOM. */
83
88
  readonly nodeType: 1 | 3 | 11;
89
+ /** Whether the node is in the mounted tree. */
90
+ readonly isConnected: boolean;
84
91
  hasChildNodes(): boolean;
85
92
  /** A copy with the same looks and attributes, and with `deep` copies of the children. */
86
93
  cloneNode(deep?: boolean): this;
@@ -369,15 +376,17 @@ export class Image extends Node {
369
376
  }
370
377
 
371
378
  /**
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.
379
+ * A canvas the application draws with WebGPU or Canvas 2D, as a `<canvas>`: `width` and
380
+ * `height` are the drawing's size in pixels, `getContext("webgpu")` gives its
381
+ * `GPUCanvasContext` (the types of `@webgpu/types` describe it) and `getContext("2d")` its
382
+ * `CanvasRenderingContext2D`.
375
383
  */
376
384
  export class Canvas extends Node {
377
385
  constructor();
378
386
  width: number;
379
387
  height: number;
380
388
  getContext(kind: "webgpu"): unknown | null;
389
+ getContext(kind: "2d", options?: { alpha?: boolean }): unknown | null;
381
390
  getContext(kind: string): unknown | null;
382
391
  }
383
392
 
@@ -582,6 +591,16 @@ export interface SelectionEvent<T extends Node = Input> extends Event {
582
591
  readonly selectionEnd: number;
583
592
  }
584
593
 
594
+ /**
595
+ * A request to go back or forward (`navigate`), raised after Alt+Left, Cmd+[ or a mouse back
596
+ * button that nothing prevented. It bubbles from the focused node; the listener that acts
597
+ * stops it.
598
+ */
599
+ export interface NavigateEvent extends Event {
600
+ readonly navigationType: "traverse";
601
+ readonly direction: "back" | "forward";
602
+ }
603
+
585
604
  /** An edit about to change an input (`beforeinput`), as the web's `InputEvent`. Preventing it cancels the edit. */
586
605
  export interface BeforeInputEvent<T extends Node = Input> extends Event {
587
606
  readonly target: FieldOf<T>;
@@ -648,6 +667,9 @@ export interface EventMap {
648
667
  cut: ClipboardEvent;
649
668
  paste: ClipboardEvent;
650
669
  beforeinput: BeforeInputEvent;
670
+ /** A request to close what is on top, raised after an Escape that nothing prevented. */
671
+ closerequest: Event;
672
+ navigate: NavigateEvent;
651
673
  scroll: ScrollEvent;
652
674
  layout: LayoutEvent;
653
675
  gotpointercapture: Event;
@@ -1185,3 +1207,36 @@ export class ResizeObserver {
1185
1207
  unobserve(target: Observable): void;
1186
1208
  disconnect(): void;
1187
1209
  }
1210
+
1211
+ /** Has events that reach the root go on to `targets` (outermost last), each with `_run(event, capture)`, as `@silkui/core/globals` does for `document` and `window`. */
1212
+ export function setOuterTargets(...targets: { _run(event: Event, capture: boolean): void }[]): void;
1213
+
1214
+ export interface MutationObserverInit {
1215
+ childList?: boolean;
1216
+ attributes?: boolean;
1217
+ characterData?: boolean;
1218
+ subtree?: boolean;
1219
+ attributeOldValue?: boolean;
1220
+ characterDataOldValue?: boolean;
1221
+ attributeFilter?: string[];
1222
+ }
1223
+
1224
+ export interface MutationRecord {
1225
+ readonly type: "childList" | "attributes" | "characterData";
1226
+ readonly target: Node;
1227
+ readonly addedNodes: Node[];
1228
+ readonly removedNodes: Node[];
1229
+ readonly previousSibling: Node | null;
1230
+ readonly nextSibling: Node | null;
1231
+ readonly attributeName: string | null;
1232
+ readonly attributeNamespace: null;
1233
+ readonly oldValue: string | null;
1234
+ }
1235
+
1236
+ /** As in the DOM, for the tree's nodes. Records come in one microtask after the mutations. */
1237
+ export class MutationObserver {
1238
+ constructor(callback: (records: MutationRecord[], observer: MutationObserver) => void);
1239
+ observe(target: Node, options?: MutationObserverInit): void;
1240
+ disconnect(): void;
1241
+ takeRecords(): MutationRecord[];
1242
+ }