@silkui/core 0.1.11 → 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/README.md +17 -2
- package/package.json +1 -1
- package/src/globals.d.ts +4 -2
- package/src/globals.js +607 -21
- package/src/index.d.ts +148 -3
- package/src/index.js +980 -22
- package/src/indexeddb.js +975 -0
- package/src/location.js +198 -0
- package/src/storage.js +146 -0
- package/src/worker.js +136 -0
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
|
|
373
|
-
* drawing's size in pixels
|
|
374
|
-
* of `@webgpu/types` describe it)
|
|
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;
|
|
@@ -849,6 +871,96 @@ export function removeTray(): void;
|
|
|
849
871
|
* elsewhere) is pressed, whichever app has focus. Resolves to whether the system took it.
|
|
850
872
|
*/
|
|
851
873
|
export function registerShortcut(accelerator: string, callback: () => void): Promise<boolean>;
|
|
874
|
+
|
|
875
|
+
/** An event of a {@link WebView}; its other members depend on `type`. */
|
|
876
|
+
export class WebViewEvent {
|
|
877
|
+
readonly type: string;
|
|
878
|
+
readonly url?: string;
|
|
879
|
+
readonly title?: string;
|
|
880
|
+
readonly ok?: boolean;
|
|
881
|
+
readonly error?: string;
|
|
882
|
+
readonly progress?: number;
|
|
883
|
+
readonly canGoBack?: boolean;
|
|
884
|
+
readonly canGoForward?: boolean;
|
|
885
|
+
readonly request?: number;
|
|
886
|
+
readonly userInitiated?: boolean;
|
|
887
|
+
readonly focused?: boolean;
|
|
888
|
+
readonly level?: "debug" | "log" | "info" | "warning" | "error";
|
|
889
|
+
readonly message?: string;
|
|
890
|
+
readonly command?: string;
|
|
891
|
+
readonly reason?: string;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
export interface WebViewOptions {
|
|
895
|
+
url?: string;
|
|
896
|
+
/** A name keeps cookies and storage between runs; empty forgets them when the view closes. */
|
|
897
|
+
profile?: string;
|
|
898
|
+
/** Lets Web Inspector attach (default true). */
|
|
899
|
+
inspectable?: boolean;
|
|
900
|
+
/** Every main frame navigation waits for `answerNavigation`. */
|
|
901
|
+
askBeforeNavigating?: boolean;
|
|
902
|
+
/** The node's background shows until the page paints. */
|
|
903
|
+
transparent?: boolean;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
export interface WebViewScreenshot {
|
|
907
|
+
width: number;
|
|
908
|
+
height: number;
|
|
909
|
+
/** RGBA, rows top first, device pixels. */
|
|
910
|
+
data: Uint8Array;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/** A real browser page shown over a node (WKWebView on macOS). */
|
|
914
|
+
export class WebView {
|
|
915
|
+
readonly id: number;
|
|
916
|
+
readonly node: Node;
|
|
917
|
+
readonly opened: Promise<boolean>;
|
|
918
|
+
url: string;
|
|
919
|
+
title: string;
|
|
920
|
+
favicon: string;
|
|
921
|
+
loading: boolean;
|
|
922
|
+
progress: number;
|
|
923
|
+
canGoBack: boolean;
|
|
924
|
+
canGoForward: boolean;
|
|
925
|
+
focused: boolean;
|
|
926
|
+
addEventListener(type: string, listener: (event: WebViewEvent) => void): void;
|
|
927
|
+
removeEventListener(type: string, listener: (event: WebViewEvent) => void): void;
|
|
928
|
+
navigate(url: string): void;
|
|
929
|
+
loadHtml(html: string, baseUrl?: string): void;
|
|
930
|
+
back(): void;
|
|
931
|
+
forward(): void;
|
|
932
|
+
reload(): void;
|
|
933
|
+
hardReload(): void;
|
|
934
|
+
stop(): void;
|
|
935
|
+
setZoom(factor: number): void;
|
|
936
|
+
focus(): void;
|
|
937
|
+
openDevTools(): void;
|
|
938
|
+
setAudioMuted(muted: boolean): void;
|
|
939
|
+
setColorScheme(scheme: "system" | "light" | "dark"): void;
|
|
940
|
+
setShown(shown: boolean): void;
|
|
941
|
+
evaluate(script: string): Promise<unknown>;
|
|
942
|
+
snapshot(): Promise<string>;
|
|
943
|
+
screenshot(): Promise<WebViewScreenshot>;
|
|
944
|
+
clickElement(ref: string): Promise<void>;
|
|
945
|
+
fillElement(ref: string, text: string): Promise<void>;
|
|
946
|
+
clickAt(x: number, y: number, options?: { button?: number; clickCount?: number; modifiers?: number }): void;
|
|
947
|
+
movePointer(x: number, y: number, options?: { modifiers?: number }): void;
|
|
948
|
+
scroll(x: number, y: number, deltaX: number, deltaY: number, options?: { modifiers?: number }): void;
|
|
949
|
+
typeText(text: string): void;
|
|
950
|
+
pressKey(key: string, modifiers?: number): void;
|
|
951
|
+
answerNavigation(request: number, allow: boolean): void;
|
|
952
|
+
findInPage(text: string, options?: { forward?: boolean; newSession?: boolean }): Promise<{ matches: number; activeMatchOrdinal: number }>;
|
|
953
|
+
stopFindInPage(): void;
|
|
954
|
+
close(): void;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/** Shows a web view over `node`; the page covers its border box and follows it. */
|
|
958
|
+
export function createWebView(node: Node, options?: WebViewOptions): WebView;
|
|
959
|
+
|
|
960
|
+
/** Clears what the pages of a profile stored: cookies and site storage, the cache, or both. */
|
|
961
|
+
export function clearWebViewData(options?: { profile?: string; cookies?: boolean; cache?: boolean }): Promise<void>;
|
|
962
|
+
|
|
963
|
+
export function quit(code?: number): void;
|
|
852
964
|
export function unregisterShortcut(accelerator: string): void;
|
|
853
965
|
|
|
854
966
|
/** An item of `setApplicationMenu` or `showContextMenu`, as Electron's menu templates. */
|
|
@@ -1095,3 +1207,36 @@ export class ResizeObserver {
|
|
|
1095
1207
|
unobserve(target: Observable): void;
|
|
1096
1208
|
disconnect(): void;
|
|
1097
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
|
+
}
|