-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsciter.d.ts
2396 lines (2196 loc) · 93 KB
/
sciter.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//| Sciter.d.ts v0.24.2
//| https://github.com/MustafaHi/sciter-vscode
interface Behaviors
{
frame: frame;
"frame-set": {state: array};
history: history;
from: form;
select: select;
calender: calender
textarea: textarea;
edit: edit;
masked: masked;
plaintext: plaintext;
richtext: richtext;
vlist: virtualList;
scrollbar: scrollbar;
lottie: lottie;
video: video;
}
interface frame
{
/** Initiates loading of the document from the URL.
* calls `newdocument/complete` events */
loadFile(path: string): boolean;
/** Initiates loading of the document from the html string or bytes.
* calls `newdocument/complete` events */
loadHtml(html: string|ArrayBuffer, baseURL?: string): boolean;
/** Clear the content of the frame by loading empty document in it. */
loadEmpty(): void;
/** Save document to the file in UTF-8 encoding. */
saveFile(path: string): boolean;
/** Save document into ArrayBuffer as sequence of UTF-8 encoded bytes. */
saveBytes(): ArrayBuffer;
readonly document: Document;
/** Get/Set key/value map of media variables used by the document. */
mediaVars: object;
/** URL of document loaded into the frame. */
url: string;
}
interface history
{
/** Goes back in navigational stack, returns true if navigation was successful. */
back(): boolean;
/** Goes forward in navigational stack, returns true if navigation was successful. */
forward(): boolean;
/** Depth of history in backward direction. */
readonly length: number;
/** Depth of history in forward direction. */
readonly forwardLength: number;
}
interface form
{
/** Submits content of the form if its action attribute is defined on the form. */
submit(): void;
/** Resets input elements to their initial values. */
reset(): void;
}
interface select
{
/** Shows popup list of options */
showPopup(): void;
/** Closes popup list of options if it is open */
hidePopup(): void;
/** Reference to DOM element that holds `<option>` list. */
options: Element;
}
interface virtualList
{
navigateTo(target: number|"start"|"end"|"pagenext"|"pageprior"|"itemnext"|"itemprior"): void;
/** scroll to given record number. By default it performs animated scroll.
Returns DOM element representing the record. */
advanceTo(target: number): Element;
/** Get of first visible item in the buffer. */
readonly firstVisibleItem: Element;
/** Get of last visible item in the buffer. */
readonly lastVisibleItem: Element;
readonly firstBufferIndex: number;
readonly lastBufferIndex: number;
readonly itemsTotal: number;
itemsBefore: number;
itemsAfter: number;
}
interface textarea
{
/** Index of first selected character. */
readonly selectionStart: number;
/** Index of last select character+1/ */
readonly selectionEnd: number;
/** selected text or empty sting if there is no selection or selection is collapsed. */
readonly selectionText: string;
selectAll(): void;
selectRange(start: number, end: number): void;
appendText(text: string): boolean;
/** Replace select text with given text. */
insertText(text: string): boolean;
/** Remove selected text. */
removeText(): boolean;
}
interface scrollbar
{
/** Sets values of scrollbar element - position, min, max,
* page - reflects to size of scrollbar slider,
* step - increment value of on arrow buttons clicks. */
values(position:number, min:number, max:number, page:number, step:number): void;
readonly max: number;
readonly min: number;
/** Page value, size of scrollbar's slider. */
readonly page: number;
/** Defines position increment/decrement of clicks on arrow buttons. */
readonly step: number;
/** Current slider position. */
position: number;
}
interface calender
{
/** Gets/Sets current view mode. */
mode: "days"|"months"|"years"|"century";
/** Decrements the value by 1 or a specified number.
* Depends of current mode it will advance either day or month or year or decade. */
stepDown(steps?: number): void;
/** Increments the value by 1 or by a specified number.
* Depends of current mode it will advance either day or month or year or decade. */
stepUp(steps?: number): void;
}
interface edit
{
readonly selectionStart, readonly selectionEnd: number;
/** Returns selected text or empty string if there is no selection. */
readonly selectionText: string;
/** Select whole content. */
selectAll(): void;
/** selects text between start (included)
* and end (excluded) position. If start and end are omitted - removes selection. */
selectRange(start?: number, end?: number): void;
/** Remove selected text. */
removeText(): void;
/** Insert text at caret position, if selection is not empty removes selected text before insertion. */
insertText(text: string): void;
/** Appends the text at the end of existing text. */
appendText(text: string): void;
}
interface masked
{
/** This property allows to define structure of masked input "manually" and with more control.
* Mask definition is an array of strings (rendered as static separators) and objects.
* Each object defines editable regions and may have following fields: */
mask: string|array;
type: "integer"|"text"|"enum";
/** Defines length of the region in characters */
width: number;
/** Defines CSS class of generated span element */
class: string;
min, max, step: number;
/** If true then this `type:integer` field is prefixed by zeros */
"leading-zero": boolean;
/** Defines list of enumerable cases for `type:enum`
* this region allows to input only those predefined cases. */
items: enum;
/** Defines filter of allowed characters in this `type:text` field. */
filter: string;
}
/** Provides playback of Lottie animations. It parses Adobe After Effects
* animations exported as json with Bodymovin and renders them natively inside the Sciter.
* [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-lottie.md) */
interface lottie
{
/** Reports playback status. If true animation is playing at the moment. */
readonly playing: boolean;
/** float, speed multiplier, 1.0 by default. */
speed: number;
loop: boolean;
/** Current frame in range [0..frames). */
frame: number;
/** Total number of frames in animation. */
readonly frames: number;
/** Current animation position, number in range 0.0 .. 1.0 */
position: number;
/** Total duration of full animation loop as defined by animation designer. */
readonly duration: number;
/** Array (list) of marker definitions.
* Each definition is an array (tuple): [tagName:string, startFrame: integer, endFrame: integer]. */
readonly markers: array;
/** Load (potentially asynchronously) animation from JSON file at URL. */
load(url: string): boolean;
/** Start playback. If first/last frame is provided will play only frames in the range. */
play(firstFrame?: number, lastFrame: number): boolean;
/** Stop (pause) animation. */
stop(): boolean;
/** Update animation properties dynamically at runtime. */
update(keyPath: string, propName: string, value: Color|number): boolean;
}
interface plaintext
{
/** Get/Set text line at given index */
children: string[];
/** String content, lines seperated by \r\n */
content: string|string[];
readonly lines: number;
readonly selectionStart: [lineNumber: number, linePosition: number];
readonly selectionEnd : [lineNumber: number, linePosition: number];
readonly selectionText: string;
/** Load Content from URL */
load(url: string): boolean;
/** Save Content to URL(file path) */
save(url: string): boolean;
/** Select text range; */
selectRange(startLine: number, startPosition: number, endLine: number, endPosition: number): void;
/** Select all text; */
selectAll(): boolean;
/** Append line/s at the end of the text; */
appendLine(text: string|string[]): boolean;
/** Inserts line/s at line index; */
insertLine(index: number, text: string|string[]): boolean;
/** Remove line/s starting from index */
removeLine(index: number, count?: number): boolean;
/** Performs transactional (undoable) content update.
* [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-richtext.md#richtextupdatemutatorfunctiontctx-bool) */
update(mutator: (context: Transaction) => {}): boolean;
}
interface richtext
{
/** Get/Set url of loaded document. */
url: string;
/** Load Content from URL */
load(url: string): boolean;
/** loads content from bytes or string (html source) into the editor;
* url is used to resolve relative URLs (if any). */
load(html: string|ArrayBuffer, url?: string): boolean;
/** Save Content to URL(file path) */
save(url: string): boolean;
/** Clear the content by loading empty document in it. */
loadEmpty(): boolean;
/** Set content to the html at given selection. */
sourceToContent(html: string, url: string, selectionStart: number, selectionEnd: number): boolean;
/** Return content and selection as an array. */
contentToSource(): [html: string, url: string, selectionStart: number, selectionEnd: number];
/** Performs transactional (undoable) content update.
* [Documentation](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/docs/md/behaviors/behavior-richtext.md#richtextupdatemutatorfunctiontctx-bool) */
update(mutator: (context: Transaction) => {}): boolean;
}
interface Transaction
{
/** Add or change value of one attribute. */
setAttribute(el: Element, name: string, value: string): void;
/** Remove one attribute. */
removeAttribute(el: Element, name: string): void;
/** Change tag of the element. */
setTag(el: Element, name: string): void;
/** Change node text. */
setText(node: Node, text: string): void;
/** splits node at offset position until the parent element.
* Similar to pressing ENTER in the middle of paragraph -
* text node and p[aragraph] element will be split to two paragraphs; */
split(node: Node, offset: number, parentEl: Element): [node: Node, offset: number];
/** Wrap the range into element. */
wrap(startNode: Node, startOffset: number, endNote: Node, endOffset: number, tag: string): void;
/** Remove the element and add it content to parent element. */
unwrap(el: Element): void;
/** Same as `Element.execCommand()` but all mutations will go into this transaction. */
execCommand(command: string, params?: object|string): boolean;
/** Insert text at given node/offset position. */
insertText(at: Node|number, text: string): [node: Node, offset: number];
/** Insert HTML at given node/offset position, return list of nodes inserted; */
insertHTML(at: Node|number, html: string): Node[];
/** Insert node at given node/offset position. */
insertNode(at: Node|number, html: string): [node: Node, offset: number];
/** Delete current selected range (if any). */
deleteSelection(): [node: Node, offset: number];
deleteRange(startNode: Node, startOffset: number, endNote: Node, endOffset: number): void;
/** Delete given node or element. */
deleteNode(node: Node): void;
}
interface video
{
/** Report playback status. If true then video is playing at the moment. */
readonly isPlaying: boolean;
/** If video playback has reached the end of the movie. */
readonly isEnded: boolean;
/** Duration in seconds of the movie. If duration is not available it returns 0. */
readonly duration: number;
/** Reports natural width and height of video frame of the movie. */
readonly height, readonly width: number;
/** Reports video box rectangle in pixels relative to the content box of the element.
* Note if sizing attribute is "cover" then either x or y can be negative. */
readonly renderingBox: [x, y, width, height];
/** float (0.0...1.0). Current volume level of audio track.
* 1.0 correspond to 0db, 0.0 (mute) -100db. */
audioVolume: number;
/** float ( -1.0 ... +1.0 ). Current stereo balance. */
audioBalance: number;
/** float, Get/Set current playback position, in seconds. */
position: number;
/** Loads video file into the player. use `play()` to start. */
load(url: string): boolean;
/** Stops video playback and unloads the movie. */
unload(): void;
/** Start playback at current `position` */
play(): void;
stop(): void;
}
interface Document extends Element {
/** Return image associated with provided arbitrary url, or assign one if image is provided too.
* This method also allow you to use the image in CSS by it URL.
*/
bindImage(url: string, image?: Image): Image;
/** Returns absolute path of provided relative path using the document URL as a base. */
url(relpath ?: string): string;
/** Subscribe to any DOM event */
on(event: keyof typeof eventType, selector?: string, handler: eventFunction): void;
on(event: keyof typeof domEvent, handler: eventFunction): void;
/* NATIVE */
body: Element;
head: Element;
/** Root(html) element */
documentElement: Element;
/** document loading state - `complete` | `interactive` */
readyState: 'complete' | 'interactive';
createElement(tag: string): Element;
createTextNode(): Node;
createComment(): Comment;
createDocumentFragment();
createNodeIterator(root: string, whatToShow?: string, filter?: string): NodeIterator;
}
declare var Document: {
new(): Document;
};
declare var document: Document;
enum domEvent {
parsed,
ready,
DOMContentLoaded,
complete,
close,
unload,
beforeunload,
closerequest
}
interface Element extends Node, Behaviors {
/** Get element matching the css selector */
$(query: string): Element;
/** Get array of elements matching the css selector */
$$(query: string): array<Element>;
/** Select parent element that match the query */
$p(query: string): Element;
/** Owner element selector, useful to get owner of menu */
$o(query: string): Element;
/** Check element match the selector */
$is(query: string): boolean;
/** Posts a function or event to event queue. */
post(eventOrHandler: function(this: Element, ...any) | Event, avoidDuplicates?: boolean): boolean;
/** Fire event asynchronously, `Event.target` will be set to this element,
* use `dispatchEvent` for sync method
* @return `false` if event is canceled with `Event.preventDefault()`.
*/
postEvent(event: Event, avoidDuplicates?: boolean): boolean;
/** jQuery style event subscription:
@param event `^name` for handling events in capturing phase
@param query subscribe to all children that match the css selector otherwise this element
@param handler `Function(Event, Element)` - `this` is set to the element the handler is attached to
*/
on(event: keyof typeof eventType, query: string, handler: eventFunction): Element;
on(event: keyof typeof eventType, handler: eventFunction): Element;
off(eventOrHandler: keyof typeof eventType|string|Function): Element;
/** jQuery style event subscription to application wide events:
* The element gets unsubscribed automatically when it is disconnected from DOM
@param event `^name` for handling events in capturing phase
@param handler `Function(Event, Element)` - `this` is set to the element the handler is attached to
*/
onGlobalEvent(event: string, handler: function(this: Element, ...any)): Element;
/** Unsubscribe this element from particular event, if no argument is provided unsubscribe from all events */
offGlobalEvent(eventOrHandler?: string | function(this: Element, ...any)): Element;
/** Starts timer on element.
* If the element already has a timer with the same callback, it first gets removed and timer is restarted.
* This allows to implement effective throttling (debounce).
* @param callback `this` is set to the element, `return true` to repeat. */
timer(milliseconds: number, callback: function(this: Element, ...any): void|boolean): boolean;
/** Removes content of the element, makes it empty. */
clear(): boolean;
/** Interaction with native behaviors attached to the element. */
xcall(name: string, ...args): any
/** Removes the element and moves its content in place in the DOM. */
unwrapElement(): boolean;
/** Wraps range of nodes from start to end into wrap element - opposite action to `unwrapElement()` */
wrapNodes(start: Node, end: Node, wrap: Element);
/** Reports state and allowance of particular command. The method accepts the same parameters as the `Element.execCommand()`. */
checkCommand(command: string, params?: object|string): 1|2;
/** Execute undoable behavior specific commands. */
execCommand(command: string, params?: object|string): boolean;
/** Immediate mode drawing "ports".
* Functions assigned to these properties will be called when the element is rendered on screen
* so they can draw anything on top (or below) of default HTML/CSS rendering. */
paintBackground: function(Graphics);
/** Immediate mode drawing "ports".
* Functions assigned to these properties will be called when the element is rendered on screen
* so they can draw anything on top (or below) of default HTML/CSS rendering. */
paintForeground: function(Graphics);
/** Immediate mode drawing "ports".
* Functions assigned to these properties will be called when the element is rendered on screen
* so they can draw anything on top (or below) of default HTML/CSS rendering. */
paintContent: function(Graphics);
/** Immediate mode drawing "ports".
* Functions assigned to these properties will be called when the element is rendered on screen
* so they can draw anything on top (or below) of default HTML/CSS rendering. */
paintOutline: function(Graphics);
/** Schedules re-paint of the element. This will trigger `Element.paintXXXX` calls. */
requestPaint(): void;
/** Force repaint immediately */
flushPaint(): void;
/** Shows the popup element or VNode (JSX) in out-of-canvas popup window on desktop. */
popup(popup: Element | VNode, params?: popupParams): void;
/** Show this element as out-of-canvas popup window on desktop.
* @param referencePoint `1-9`, see keyboard numpad for the meaning.
*/
popupAt(x: number, y: number, referencePoint?: number): void;
/** The method offers "manual" animation support.
* `function(progress: 0.0...1.0)`: true | false
* Sciter will call handler with animation frame rate passing current progress value.
* return false to stop animation. */
animate(handler: Function, params: animateParams): void;
/** Make the element "airborn" - to be replaced outside of host window */
takeOff(params: takeoffParams): void;
/** Append element as last child */
append(JSX: JSX): void;
/** Insert element as the first child */
prepend(JSX: JSX): void;
/** Replace content by element */
content(JSX: JSX): void;
/** patches content of the element by JSX using rules of React[or].
* If second parameter is true the function patches only children but not element itself. */
patch(JSX: JSX, onlyChildren?: true): void;
/** Patch properties and enqueue rendering */
componentUpdate(object?: object): Element;
/** Return collapsed range (caret position) at point x/y.
* x/a are local coordinates - relative to origin of element's inner box. */
rangeFromPoint(x: number, y: number): Range | null;
toString(): string;
/* NATIVE */
/** Get element matching the css selector */
querySelector(query: string): Element;
/** Get array of elements matching the css selector */
querySelectorAll(query: string): Element[];
getElementById(id: string): Element;
getElementsByClassName(className: string): Element[];
getElementsByTagName(tag: string): Element[];
getElementsByName(name: string): Element[];
/** Find the closest parent element matching the query selector */
closest(query: string): Element | null;
/** Check element match the selector */
matches(query: string): boolean;
firstElementChild: Element;
lastElementChild: Element;
nextElementSibling: Element;
previousElementSibling: Element;
childElementCount: number;
children: Element[];
childElement(index: number): Element;
readonly ownerDocument: Document;
appendChild(node: Node);
removeChild(node: Node);
insertBefore(node: Node, refNode: Node);
insertAfter(node: Node, refNode: Node);
replaceChild(newNode: Node, refNode: Node);
insertAdjacentHTML(where: InsertPosition, html: string): void;
swapWith(element: Element);
style: Style;
/** Runtime flags and state on element.
* Most of Element.State reflect so called CSS pseudo-classes (flags):
* `element:visited { color: red; }`
*/
state: State;
/** Represents current selection on elements that supports selection:
` <htmlarea>` - WYSIWYG HTML editor;
`<plaintext>` - Plain text multiline editor;
any other element with `[selectable]` attribute set; */
selection: Selection;
disabled: boolean;
readonly: boolean;
checked: boolean;
src: string;
readonly attributes: string[];
hasAttribute(name: string): boolean;
getAttribute(name: string): string;
getAttributeNames(): string[];
setAttribute(name: string, value: string|number|undefined): void;
removeAttribute(name: string): void;
attributes: string[]|number[];
classList: {
add(...name: string[]): void;
remove(...name: string[]): void;
toggle(name: string, state?: boolean): boolean;
contains(name: string): boolean;
length: number;
readonly entries(): string[];
}
/** Returns a drawing context of the canvas, instance of Graphics object. */
getContext(type: '2d'): Graphics;
id: string;
name: string;
tagName: string;
tag: string;
className: string;
elementIndex: number;
innerHTML: string;
outerHTML: string;
innerText: string;
value: any;
scrollBy(x: number, y: number): void;
scrollBy(options: {
left?: number;
top?: number;
behavior?: "instant" | "smooth";
}): void;
scrollTo(x: number, y: number): void;
scrollTo(options: {
left?: number;
top?: number;
behavior?: "instant" | "smooth";
}): void;
scrollIntoView(toTop?: true): void;
scrollIntoView(options: {
block?: "start" | "nearest";
behavior?: "instant" | "smooth";
}): void;
readonly clientLeft: number;
readonly clientTop : number;
readonly clientWidth: number;
readonly clientHeight: number;
readonly scrollLeft: number;
readonly scrollTop : number;
readonly scrollRight: number;
readonly scrollWidth: number;
readonly scrollHeight: number;
getBoundingClientRect(): DOMRect;
click(): void;
focus(): void;
/** Call handler each time the event is fired */
addEventListener(name: string, handler: eventFunction, flags?: object): void;
removeEventListener(name: string, handler: Function): void;
/** Fire event synchronously, `Event.target` will be set to this element,
* use `postEvent` for async method
* @return `false` if event is canceled with `Event.preventDefault()`.
*/
dispatchEvent(event: Event, avoidDuplicates?: boolean): boolean;
// EventTarget
ready(event: Event, element: Element): void;
onclick(event: Event, element: Element): void;
onchange(event: Event, element: Element): void;
onkeydown(event: Event, element: Element): void;
onwheel(event: Event, element: Element): void;
}
declare var Element: {
new(): Element;
}
type InsertPosition = "beforebegin" | "afterbegin" | "beforeend" | "afterend";
interface popupParams {
/** 1..9, reference point on anchor border box (see keyboard numpad for the meaning) */
anchorAt?: number;
/** 1..9, reference point on popup's margin box. */
popupAt?: number;
x?: number;
y?: number;
}
interface animateParams {
duration?: number,
ease?: "linear" | "ease" | "ease-in" | "ease-in-out" | "ease-out" | "quad-in" | "quad-out" | "quad-in-out" | "cubic-in" | "cubic-out" | "cubic-in-out" | "quart-in" | "quart-out" | "quart-in-out" | "quint-in" | "quint-out" | "quint-in-out" | "sine-in" | "sine-out" | "sine-in-out" | "expo-in" | "expo-out" | "expo-in-out" | "circ-in" | "circ-out" | "circ-in-out" | "elastic-in" | "elastic-out" | "elastic-in-out" | "back-in" | "back-out" | "back-in-out" | "x-back-in" | "x-back-out" | "x-back-in-out" | "xx-back-in" | "xx-back-out" | "xx-back-in-out" | "bounce-in" | "bounce-out" | "bounce-in-out";
effect?: "blend" | "blend-atop" | "slide-top" | "slide-bottom" | "slide-left" | "slide-right" | "slide-over-top" | "slide-over-bottom" | "slide-over-left" | "slide-over-right" | "remove-top" | "remove-bottom" | "remove-left" | "remove-right" | "scroll-top" | "scroll-bottom" | "scroll-left" | "scroll-right";
/** Times per second the function is called */
FPS?: number;
}
interface takeoffParams {
x?: number;
y?: number;
width?: number;
height?: number;
relativeTo?: "screen" | "document" | "window" | "parent" | "self";
window?: "attached" | "detached" | "popup";
}
interface DOMRect {
readonly bottom: number;
readonly height: number;
readonly left: number;
readonly right: number;
readonly top: number;
readonly width: number;
readonly x: number;
readonly y: number;
}
declare var DOMRect: {
new(x?: number, y?: number, width?: number, height?: number): DOMRect;
fromRect(other?: DOMRect): DOMRect;
};
interface Selection
{
/** `true` if selection is collapsed to one position (anchor === focus) */
readonly isCollapsed: boolean;
/** Nearest container element that encloses as anchor as focus positions */
readonly commonAncestorContainer: Element;
readonly anchorNode: Node;
readonly anchorOffset: number;
/** Caret position */
readonly focusNode: Node;
readonly focusOffset: number;
readonly rangeCount: number;
readonly type: "Caret" | "Selection" | "Element" | "TableCells";
/** Collapse selection to current focus (caret) position. */
collapse(): void;
/** Collapse selection to anchor or focus (the last in the DOM). */
collapseToEnd(): void;
/** Collapse selection to anchor or focus (the first in the DOM). */
collapseToStart(): void;
/** `true` if the selection contains the node. */
containsNode(node: Node): boolean;
/** Remove selection (but not its content). */
empty(): void;
/** Set focus (caret) position without changing anchor position. */
extend(node: Node, offset: number): void;
getRangeAt(index: number): Range;
selectNodeContent(node: Node): void;
setBaseAndExtent(anchorNode: Node, anchorOffset: number, focusNode: Node, focusOffset: number): void;
/** Return selected text. */
toString(): string;
}
/** Runtime flags and state on element.
* Most of Element.State reflect so called CSS pseudo-classes (flags):
* `element:visited { color: red; }`*/
interface State
{
/** Computes current min and max widths of the element content. */
contentWidth(): [minWidth: number, maxWidth: number];
/** Computes current height of the element content with it given width. */
contentHeight(width: number): number;
/** Set/remove mouse capture(forward mouse event)
* `true` - captures mouse events by the element and its sub elements.
* `false` - remove capture if the element owns capture now.
* `"strict"` - mouse events will be delivered to the element only. */
capture(state: boolean|"strict"): boolean;
/** Report geometry of the window.
* @param property value type to return.
* @param metric value in relation to.
* @param relativeTo offset x/y are relative to.
* @param asPpx return coordinates in screen pixels otherwise DIPs.
*/
box(property: "xywh"|"rect"|"position"|"dimension", metric: keyof typeof boxMetric, relativeTo?: keyof typeof boxRelativeTo, asPpx?: boolean): number[];
box(property: keyof typeof boxProperties, metric: keyof typeof boxMetric, relativeTo?: keyof typeof boxRelativeTo, asPpx?: boolean): number;
/** Parses length string as CSS length units or percentage and then converts them to CSS pixels.
* Perecentage values are computed against element dimensions (inner box). */
pixelsIn(length: string, orientation?: "horizontal" | "vertical"): number | undefined;
/** Maps local element coordinates to window coordinates.
* This method accounts affine 2D transformation the element and its parents may have. */
mapLocalToWindow(x: number, y: number): [x: number, y: number];
/** Maps point on window to local coordinates of particular element.
* This method accounts affine 2D transformation the element and its parents may have. */
mapWindowToLocal(x: number, y: number): [x: number, y: number];
focus: boolean;
readonly ownsfocus: boolean;
link: boolean;
visited: boolean;
hover: boolean;
selected: boolean;
current: boolean;
checked: boolean;
disabled: boolean;
readonly: boolean;
expanded: boolean;
collapsed: boolean;
invalid: boolean;
animating: boolean;
focusable: boolean;
anchor: boolean;
popup: boolean;
ownspopup: boolean;
tabfocus: boolean;
empty: boolean;
busy: boolean;
dragover: boolean;
dragsource: boolean;
droptarget: boolean;
moving: boolean;
copying: boolean;
pressed: boolean;
ready: boolean;
active: boolean;
/** `False` will prevent reconciliation of element's content by Reactor */
reactive: boolean;
/** Runtime value of native behavior attached to the element. Actual for input elements. */
value: any;
/** Reports visibility status of the element,
* if `0` then the element is visible in full, otherwise combination of these flags:
* `0x1` - left side of border box is clipped out (invisible).
* `0x2` - top side is clipped.
* `0x4` - right side is clipped.
* `0x8` - bottom side is clipped.
* `0xf` - the element is completely clipped out - invisible. */
occluded: number;
/** `True` if this is a root document of the window */
readonly windowroot: boolean;
/** Layout manager used by the element at the moment. */
readonly flow: "default" | "vertical" | "horizontal" | "horizontal-wrap" | "vertical-wrap" | "grid" | "table" | "table-fixed" | "table-row" | "table-body" | "columns" | "stack" | "text" | "null" | "image" | "svg" | "svg-child" | "";
readonly visible: boolean;
}
enum boxProperties { "xywh", "rect", "position", "dimension", "left", "right", "top", "bottom", "width", "height" }
enum boxMetric { "inner", "border", "padding", "margin", "client", "caret", "icon" }
enum boxRelativeTo { "element", "screen", "window", "document", "parent", "container", "self" }
interface Style {
getPropertyValue(name: string): string;
setProperty(name: string, value: string|length, important?: boolean): void;
removeProperty(name: string): void;
colorOf(name: string): Color | null;
pixelsOf(name: string): number | null;
imageOf(name: string): Image | null;
/** Get/Set CSS variables applied to the element
* @return `{name: value...}`
*/
variables(variables?: object): object;
setCursor(cursor: Image|null, x: number, y: number): void;
behavior: string;
aspect: string;
prototype: string;
size: string;
flow: string;
fontRenderingMode: "sub-pixel" | "snap-pixel";
imageRendering: "auto" | "inherit" | "default" | "crispy-edges" | "pixelated" | "optimize-quality" | "optimize-speed";
contextMenu: string;
hitMargin: string;
content: string;
scrollManner: string;
verticalScrollbar: string;
horizontalScrollbar: string;
textOverflow: string;
popupPosition: string;
font: string;
fontSize: length;
height: length;
width: length;
color: string;
background: string;
backgroundColor: string;
backgroundImage: string;
foreground: string;
foregroundColor: string;
foregroundImage: string;
[name: string]: string|length;
}
/** An event which takes place in the DOM. */
interface Event {
/** True if event goes through its target's ancestors in reverse tree order, and false otherwise. */
readonly bubbles: boolean;
cancelBubble: boolean;
/** Can be canceled by invoking the preventDefault() method. */
readonly cancelable: boolean;
/** True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */
readonly composed: boolean;
/** Returns the Element whose event listener's callback is currently being invoked. */
readonly currentTarget: Element | null;
/** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */
readonly defaultPrevented: boolean;
/** Returns the event's phase, which is one of `NONE`, `CAPTURING_PHASE`, `AT_TARGET`, and `BUBBLING_PHASE`. */
readonly eventPhase: "NONE"|"CAPTURING_PHASE"|"AT_TARGET"|"BUBBLING_PHASE";
/** Returns true if event was dispatched by the user agent, and false otherwise. */
readonly isTrusted: boolean;
readonly srcElement: Element | null;
/** The element to which event is dispatched (its target). */
readonly target: Element | null;
/** The secondary element which is lossing or gaining focus from/to `target` */
readonly relatedTarget: Element | null;
/** Type of event, e.g. "click", "hashchange", or "submit". */
readonly type: string;
/** If invoked when the cancelable attribute value is true,
* and while executing a listener for the event with passive set to false,
* signals to the operation that caused event to be dispatched that it needs to be canceled. */
preventDefault(): void;
/** Invoking this method prevents event from reaching any registered event listeners
* after the current one finishes running and, when dispatched in a tree,
* also prevents event from reaching any other objects. */
stopImmediatePropagation(): void;
/** When dispatched in a tree, invoking this method prevents event
* from reaching any objects other than the current object. */
stopPropagation(): void;
/** String representation of keyCode "KeyA", "F1", "Enter"... */
readonly code: string;
/** keyCode list at [include/sciter-x-key-codes.h](https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/include/sciter-x-key-codes.h) */
readonly keyCode: number;
/** Platform's native key code, e.g, wParam in WM_KEYDOWN on Windows. */
readonly platformKeyCode: string;
readonly AT_TARGET: number;
readonly BUBBLING_PHASE: number;
readonly CAPTURING_PHASE: number;
readonly NONE: number;
data, details: any;
readonly altKey: boolean;
readonly ctrlKey: boolean;
/** `command` key on OSX, `win` on Windows */
readonly metaKey: boolean;
readonly shiftKey: boolean;
readonly button: number;
readonly buttons: number;
readonly clientX: number;
readonly clientY: number;
readonly screenX: number;
readonly screenY: number;
readonly windowX: number;
readonly windowY: number;
readonly deltaX: number;
readonly deltaY: number;
/** `0` - `deltaX/Y` are pixels coming from touch devices,
* `1` - `deltaX/Y` are in "lines" (a.k.a. mouse wheel "ticks"). */
readonly deltaMode: number;
/** Coordinates relative to `currentTarget` - the element this event handler is attached to. */
readonly x: number;
/** Coordinates relative to `currentTarget` - the element this event handler is attached to. */
readonly y: number;
/** Used in some events to indicate auxiliary "source" element. */
readonly source: Element;
/** Mouse event is on `foreground-image`, return Element containing the image */
readonly isOnIcon: Element;
/** Returns pressed status of the key. */
keyState(key: string): boolean;
}
declare var Event: {
new(type: string, options?: EventOptions): Event;
readonly AT_TARGET: number;
readonly BUBBLING_PHASE: number;
readonly CAPTURING_PHASE: number;
readonly NONE: number;
};
interface EventOptions {
/** True if event goes through its target's ancestors in reverse tree order, and false otherwise. */
bubbles?: boolean;
/** Can be canceled by invoking the preventDefault() method. */
cancelable?: boolean;
/** True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */
composed?: boolean;
/** Property passed to event listener. `evt.data/details` */
data?,details?: any;
}
type eventFunction = function(Event, Element): void;
enum eventType {
ready,
complete,
click,
input,
change,
press,
changing,
submit,
reset,
expand,
collapse,
statechange,
visualstatechange,
disabledstatechange,
readonlystatechange,
contextmenu,
contextmenusetup,
animationend,
animationstart,
animationloop,
transitionend,
transitionstart,
mediachange,
contentchange,
inputlangchange,
pastehtml,
pastetext,
pasteimage,
popuprequest,
popupready,
popupdismissing,
popupdismissed,
tooltiprequest,
focus,
focusin,
focusout,
blue,
mouseMove,
mouseLeave,
mouseIdle,
mousetick,
mousedown,
mouseup,
mousewheel,
mousedragrequest,
dblclick,
doubleclick,
tripleclick,
keydown,
keyup,
keypress,
compostionstart,
compositionend,
scroll,
scrollanimationstart,
scrollanimationend,
sizechange,
visibilitychange,
load,
error,
drag,
dragenter,
dragleave,
drop,
dragaccept,
dropcancel,
willacceptdrop,
play,
ended,
videocoordinate,
videoframeready,
}
/** Call function after x time
* @return Timeout ID for `clearTimeout(ID)`
*/
declare function setTimeout(cb: Function, milliseconds: number): number;
/** Cancel `setTimeout` function by it returned ID */
declare function clearTimeout(tID: number): void;