@dark-engine/platform-desktop
Version:
Dark renderer to desktop platforms like Windows, Linux, macOS via Nodegui and Qt
53 lines (52 loc) • 1.98 kB
TypeScript
import { QWidget } from '@nodegui/nodegui';
import { NodeType } from '@dark-engine/core';
import type { QElement, WidgetProps } from '../shared';
declare class NativeElement {
type: NodeType;
parentElement: TagNativeElement;
constructor(type: NodeType);
getText(): string;
}
declare class TagNativeElement<T extends QElement = QElement> extends NativeElement {
name: string;
attrs: Record<string, AttributeValue>;
children: Array<NativeElement>;
private nativeView;
private eventListeners;
constructor(name: string);
getNativeView(): T;
appendChild(element: NativeElement): void;
insertBefore(element: NativeElement, siblingElement: NativeElement): void;
removeChild(element: NativeElement): void;
getAttribute(name: string): AttributeValue;
setAttribute(name: string, value: AttributeValue): void;
removeAttribute(name: string): void;
updateText(): void;
getText(): string;
addEventListener(eventName: string, handler: Function): void;
removeEventListener(eventName: string): void;
}
declare class TextNativeElement extends NativeElement {
private _value;
constructor(text: string);
get value(): string;
set value(value: string);
getText(): string;
}
declare class CommentNativeElement extends NativeElement {
private _value;
constructor(text: string);
get value(): string;
set value(value: string);
getText(): string;
}
type Setter<T = WidgetProps> = Partial<
Record<T extends WidgetProps ? keyof WidgetProps : string, (widget: QWidget, value: AttributeValue) => void>
>;
declare function createAttrSetter<T>(
setter: Setter<T>,
): (element: TagNativeElement, name: string, value: AttributeValue) => void;
export type AttributeValue = string | number | boolean | object;
export declare const INITIAL_ATTR_VALUE = '_INITIAL_ATTR_VALUE';
export type PlainNativeElement = TextNativeElement | CommentNativeElement;
export { NativeElement, TagNativeElement, TextNativeElement, CommentNativeElement, createAttrSetter };