UNPKG

native-canvas

Version:

A canvas library allows for a HTML canvas to run natively on NodeJs, without a WebBrowser

527 lines (526 loc) 22.1 kB
import { SdlContext2d } from '../sdl-context/sdl-context-2d'; import { EventEmitter } from 'events'; import { NativeWindow } from '../../../window/native-window'; import { WindowOptions } from '../../../window/window-options'; export declare class SdlWindow extends EventEmitter implements NativeWindow { private readonly options; private _windowPtr; private windowSurface; private _hasMouseEnteredWindow; private _lastMouseEvent; private _lastKeyboardEvent; private _context; private _internalCanvas; private _canvas; private _size; private _Blob; private _URL; private _URLSearchParams; private readonly _applicationCache; private readonly _caches; private readonly _clientInformation; private readonly _closed; private readonly _console; private readonly _crypto; private _customElements; private _defaultStatus; private _devicePixelRatio; private _doNotTrack; private _document; private _event; private _external; private _frameElement; private _frames; private _history; private _indexedDB; private _innerHeight; private _innerWidth; private _isSecureContext; private _length; private _localStorage; private _location; private _locationbar; private _menubar; private _msContentScript; private _name; private _navigator; private _offscreenBuffering; private _onabort; private _onafterprint; private _onanimationcancel; private _onanimationend; private _onanimationiteration; private _onanimationstart; private _onauxclick; private _onbeforeprint; private _onbeforeunload; private _onblur; private _oncancel; private _oncanplay; private _oncanplaythrough; private _onchange; private _onclick; private _onclose; private _oncompassneedscalibration; private _oncontextmenu; private _oncuechange; private _ondblclick; private _ondevicelight; private _ondevicemotion; private _ondeviceorientation; private _ondrag; private _ondragend; private _ondragenter; private _ondragexit; private _ondragleave; private _ondragover; private _ondragstart; private _ondrop; private _ondurationchange; private _onemptied; private _onended; private _onerror; private _onfocus; private _ongotpointercapture; private _onhashchange; private _oninput; private _oninvalid; private _onkeydown; private _onkeypress; private _onkeyup; private _onlanguagechange; private _onload; private _onloadeddata; private _onloadedmetadata; private _onloadend; private _onloadstart; private _onlostpointercapture; private _onmessage; private _onmessageerror; private _onmousedown; private _onmouseenter; private _onmouseleave; private _onmousemove; private _onmouseout; private _onmouseover; private _onmouseup; private _onmousewheel; private _onmsgesturechange; private _onmsgesturedoubletap; private _onmsgestureend; private _onmsgesturehold; private _onmsgesturestart; private _onmsgesturetap; private _onmsinertiastart; private _onmspointercancel; private _onmspointerdown; private _onmspointerenter; private _onmspointerleave; private _onmspointermove; private _onmspointerout; private _onmspointerover; private _onmspointerup; private _onoffline; private _ononline; private _onorientationchange; private _onpagehide; private _onpageshow; private _onpause; private _onplay; private _onplaying; private _onpointercancel; private _onpointerdown; private _onpointerenter; private _onpointerleave; private _onpointermove; private _onpointerout; private _onpointerover; private _onpointerup; private _onpopstate; private _onprogress; private _onratechange; private _onreadystatechange; private _onrejectionhandled; private _onreset; private _onresize; private _onscroll; private _onsecuritypolicyviolation; private _onseeked; private _onseeking; private _onselect; private _onstalled; private _onstorage; private _onsubmit; private _onsuspend; private _ontimeupdate; private _ontoggle; private _ontouchcancel; private _ontouchend; private _ontouchmove; private _ontouchstart; private _ontransitioncancel; private _ontransitionend; private _ontransitionrun; private _ontransitionstart; private _onunhandledrejection; private _onunload; private _onvolumechange; private _onvrdisplayactivate; private _onvrdisplayblur; private _onvrdisplayconnect; private _onvrdisplaydeactivate; private _onvrdisplaydisconnect; private _onvrdisplayfocus; private _onvrdisplaypointerrestricted; private _onvrdisplaypointerunrestricted; private _onvrdisplaypresentchange; private _onwaiting; private _onwheel; private _opener; private _orientation; private _origin; private _outerHeight; private _outerWidth; private _pageXOffset; private _pageYOffset; private _parent; private _performance; private _personalbar; private _screen; private _screenLeft; private _screenTop; private _screenX; private _screenY; private _scrollX; private _scrollY; private _scrollbars; private _self; private _sessionStorage; private _speechSynthesis; private _status; private _statusbar; private _styleMedia; private _toolbar; private _top; private _window; constructor(options: WindowOptions); disableFullScreen(): void; enableFullScreen(): void; windowImplementation(): any; stopPropagation(event: any): void; stopImmediatePropagation(event: any): void; preventDefault(event: any): void; addEventListener<K extends keyof WindowEventHandlersEventMap>(type: K, listener: (this: WindowEventHandlers, ev: WindowEventHandlersEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; alert(message?: any): void; atob(encodedString: string): string; blur(): void; btoa(rawString: string): string; cancelAnimationFrame(handle: number): void; captureEvents(): void; clearInterval(handle?: number): void; clearTimeout(handle?: number): void; confirm(message?: string): boolean; createImageBitmap(image: ImageBitmapSource, sx?: number, sy?: number, sw?: number, sh?: number): Promise<ImageBitmap>; departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; dispatchEvent(event: Event): boolean; fetch(input: RequestInfo, init?: RequestInit): Promise<Response>; getComputedStyle(elt: Element, pseudoElt?: string | null): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string | null): CSSRuleList; getSelection(): Selection; matchMedia(query: string): MediaQueryList; moveBy(x: number, y: number): void; moveTo(x: number, y: number): void; msWriteProfilerMark(profilerMarkName: string): void; open(url?: string, target?: string, features?: string, replace?: boolean): Window | null; postMessage(message: any, targetOrigin: string, transfer?: Transferable[]): void; print(): void; prompt(message?: string, _default?: string): string | null; queueMicrotask(callback: Function): void; releaseEvents(): void; removeEventListener<K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void; requestAnimationFrame(callback: FrameRequestCallback): number; resizeBy(x: number, y: number): void; resizeTo(x: number, y: number): void; scroll(options?: ScrollToOptions): void; scroll(x: number, y: number): void; scrollBy(options?: ScrollToOptions): void; scrollBy(x: number, y: number): void; scrollTo(options?: ScrollToOptions): void; scrollTo(x: number, y: number): void; setInterval(handler: TimerHandler, timeout?: number, ...args: any[]): number; setTimeout(handler: TimerHandler, timeout?: number, ...args: any[]): number; stop(): void; webkitCancelAnimationFrame(handle: number): void; webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; canvasWidth: number; private configureCanvasSize; canvasHeight: number; canvasY: number; canvasX: number; getCanvas(): HTMLCanvasElement; renderFrame(ms: number): void; private init; initCanvasColors(): void; private initWindowEvents; private initKeyEvents; private initDragAndDropEvents; private initMouseEvents; private decorateMouseEvent; private initEvents; private initContextSize; private initSize; private triggerWindowSizeChange; grab(): void; focus(): void; close(): void; destroy(): void; restore(): void; center(): void; setModal(win: SdlWindow): void; maximize: any; minimize: any; fullScreen: boolean; bounds: { x: number; y: number; w: number; h: number; }; size: { w: number; h: number; }; minimumSize: any; maximumSize: any; resizable: boolean; closable: any; position: any; title: string; border: boolean; readonly bordersSize: { top: number; right: number; bottom: number; left: number; }; show: boolean; readonly id: number; windowPtr: any; hasMouseEnteredWindow: boolean; lastMouseEvent: MouseEvent; lastKeyboardEvent: KeyboardEvent; context: SdlContext2d; internalCanvas: HTMLCanvasElement; Blob: { prototype: Blob; new (blobParts?: any[], options?: BlobPropertyBag): Blob; }; URL: { prototype: URL; new (url: string, base?: (string | URL)): URL; createObjectURL(object: any): string; revokeObjectURL(url: string): void; }; URLSearchParams: { prototype: URLSearchParams; new (init?: (string[][] | Record<string, string> | string | URLSearchParams)): URLSearchParams; }; customElements: CustomElementRegistry; defaultStatus: string; location: Location; name: string; offscreenBuffering: string | boolean; onabort: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; onafterprint: ((this: WindowEventHandlers, ev: Event) => any) | null; onanimationcancel: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; onanimationend: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; onanimationiteration: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; onanimationstart: ((this: GlobalEventHandlers, ev: AnimationEvent) => any) | null; onauxclick: ((this: GlobalEventHandlers, ev: Event) => any) | null; onbeforeprint: ((this: WindowEventHandlers, ev: Event) => any) | null; onbeforeunload: ((this: WindowEventHandlers, ev: BeforeUnloadEvent) => any) | null; onblur: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; oncancel: ((this: GlobalEventHandlers, ev: Event) => any) | null; oncanplay: ((this: GlobalEventHandlers, ev: Event) => any) | null; oncanplaythrough: ((this: GlobalEventHandlers, ev: Event) => any) | null; onchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; onclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onclose: ((this: GlobalEventHandlers, ev: Event) => any) | null; oncompassneedscalibration: ((this: Window, ev: Event) => any) | null; oncontextmenu: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; oncuechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; ondblclick: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; ondevicelight: ((this: Window, ev: DeviceLightEvent) => any) | null; ondevicemotion: ((this: Window, ev: DeviceMotionEvent) => any) | null; ondeviceorientation: ((this: Window, ev: DeviceOrientationEvent) => any) | null; ondrag: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondragend: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondragenter: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondragexit: ((this: GlobalEventHandlers, ev: Event) => any) | null; ondragleave: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondragover: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondragstart: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondrop: ((this: GlobalEventHandlers, ev: DragEvent) => any) | null; ondurationchange: ((this: GlobalEventHandlers, ev: Event) => any) | null; onemptied: ((this: GlobalEventHandlers, ev: Event) => any) | null; onended: ((this: GlobalEventHandlers, ev: Event) => any) | null; onerror: ErrorEventHandler; onfocus: ((this: GlobalEventHandlers, ev: FocusEvent) => any) | null; ongotpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onhashchange: ((this: WindowEventHandlers, ev: HashChangeEvent) => any) | null; oninput: ((this: GlobalEventHandlers, ev: Event) => any) | null; oninvalid: ((this: GlobalEventHandlers, ev: Event) => any) | null; onkeydown: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; onkeypress: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; onkeyup: ((this: GlobalEventHandlers, ev: KeyboardEvent) => any) | null; onlanguagechange: ((this: WindowEventHandlers, ev: Event) => any) | null; onload: ((this: GlobalEventHandlers, ev: Event) => any) | null; onloadeddata: ((this: GlobalEventHandlers, ev: Event) => any) | null; onloadedmetadata: ((this: GlobalEventHandlers, ev: Event) => any) | null; onloadend: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null; onloadstart: ((this: GlobalEventHandlers, ev: Event) => any) | null; onlostpointercapture: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onmessage: ((this: WindowEventHandlers, ev: MessageEvent) => any) | null; onmessageerror: ((this: WindowEventHandlers, ev: MessageEvent) => any) | null; onmousedown: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmouseenter: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmouseleave: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmousemove: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmouseout: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmouseover: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmouseup: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null; onmousewheel: ((this: Window, ev: Event) => any) | null; onmsgesturechange: ((this: Window, ev: Event) => any) | null; onmsgesturedoubletap: ((this: Window, ev: Event) => any) | null; onmsgestureend: ((this: Window, ev: Event) => any) | null; onmsgesturehold: ((this: Window, ev: Event) => any) | null; onmsgesturestart: ((this: Window, ev: Event) => any) | null; onmsgesturetap: ((this: Window, ev: Event) => any) | null; onmsinertiastart: ((this: Window, ev: Event) => any) | null; onmspointercancel: ((this: Window, ev: Event) => any) | null; onmspointerdown: ((this: Window, ev: Event) => any) | null; onmspointerenter: ((this: Window, ev: Event) => any) | null; onmspointerleave: ((this: Window, ev: Event) => any) | null; onmspointermove: ((this: Window, ev: Event) => any) | null; onmspointerout: ((this: Window, ev: Event) => any) | null; onmspointerover: ((this: Window, ev: Event) => any) | null; onmspointerup: ((this: Window, ev: Event) => any) | null; onoffline: ((this: WindowEventHandlers, ev: Event) => any) | null; ononline: ((this: WindowEventHandlers, ev: Event) => any) | null; onorientationchange: ((this: Window, ev: Event) => any) | null; onpagehide: ((this: WindowEventHandlers, ev: PageTransitionEvent) => any) | null; onpageshow: ((this: WindowEventHandlers, ev: PageTransitionEvent) => any) | null; onpause: ((this: GlobalEventHandlers, ev: Event) => any) | null; onplay: ((this: GlobalEventHandlers, ev: Event) => any) | null; onplaying: ((this: GlobalEventHandlers, ev: Event) => any) | null; onpointercancel: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointerdown: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointerenter: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointerleave: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointermove: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointerout: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointerover: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpointerup: ((this: GlobalEventHandlers, ev: PointerEvent) => any) | null; onpopstate: ((this: WindowEventHandlers, ev: PopStateEvent) => any) | null; onprogress: ((this: GlobalEventHandlers, ev: ProgressEvent) => any) | null; onratechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; onreadystatechange: ((this: Window, ev: ProgressEvent) => any) | null; onrejectionhandled: ((this: WindowEventHandlers, ev: Event) => any) | null; onreset: ((this: GlobalEventHandlers, ev: Event) => any) | null; onresize: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; onscroll: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; onsecuritypolicyviolation: ((this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any) | null; onseeked: ((this: GlobalEventHandlers, ev: Event) => any) | null; onseeking: ((this: GlobalEventHandlers, ev: Event) => any) | null; onselect: ((this: GlobalEventHandlers, ev: UIEvent) => any) | null; onstalled: ((this: GlobalEventHandlers, ev: Event) => any) | null; onstorage: ((this: WindowEventHandlers, ev: StorageEvent) => any) | null; onsubmit: ((this: GlobalEventHandlers, ev: Event) => any) | null; onsuspend: ((this: GlobalEventHandlers, ev: Event) => any) | null; ontimeupdate: ((this: GlobalEventHandlers, ev: Event) => any) | null; ontoggle: ((this: GlobalEventHandlers, ev: Event) => any) | null; ontouchcancel: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; ontouchend: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; ontouchmove: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; ontouchstart: ((this: GlobalEventHandlers, ev: TouchEvent) => any) | null; ontransitioncancel: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; ontransitionend: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; ontransitionrun: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; ontransitionstart: ((this: GlobalEventHandlers, ev: TransitionEvent) => any) | null; onunhandledrejection: ((this: WindowEventHandlers, ev: PromiseRejectionEvent) => any) | null; onunload: ((this: WindowEventHandlers, ev: Event) => any) | null; onvolumechange: ((this: GlobalEventHandlers, ev: Event) => any) | null; onvrdisplayactivate: ((this: Window, ev: Event) => any) | null; onvrdisplayblur: ((this: Window, ev: Event) => any) | null; onvrdisplayconnect: ((this: Window, ev: Event) => any) | null; onvrdisplaydeactivate: ((this: Window, ev: Event) => any) | null; onvrdisplaydisconnect: ((this: Window, ev: Event) => any) | null; onvrdisplayfocus: ((this: Window, ev: Event) => any) | null; onvrdisplaypointerrestricted: ((this: Window, ev: Event) => any) | null; onvrdisplaypointerunrestricted: ((this: Window, ev: Event) => any) | null; onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null; onwaiting: ((this: GlobalEventHandlers, ev: Event) => any) | null; onwheel: ((this: GlobalEventHandlers, ev: WheelEvent) => any) | null; opener: any; status: string; canvas: HTMLCanvasElement; createImage(src: string): Promise<HTMLImageElement>; loadImage(src: string): Promise<HTMLImageElement>; newCanvas(window?: (NativeWindow | string), windowOptions?: WindowOptions): HTMLCanvasElement; private createCanvas; private initCanvasSize; readonly applicationCache: ApplicationCache; readonly caches: CacheStorage; readonly clientInformation: Navigator; readonly closed: boolean; readonly console: Console; readonly crypto: Crypto; devicePixelRatio: number; doNotTrack: string; document: Document; event: Event | undefined; external: External; frameElement: Element; frames: Window; history: History; indexedDB: IDBFactory; innerHeight: number; innerWidth: number; isSecureContext: boolean; length: number; localStorage: Storage; locationbar: BarProp; menubar: BarProp; msContentScript: ExtensionScriptApis; navigator: Navigator; orientation: string | number; origin: string; outerHeight: number; outerWidth: number; pageXOffset: number; pageYOffset: number; parent: Window; performance: Performance; personalbar: BarProp; screen: Screen; screenLeft: number; screenTop: number; screenX: number; screenY: number; scrollX: number; scrollY: number; scrollbars: BarProp; self: Window; sessionStorage: Storage; speechSynthesis: SpeechSynthesis; statusbar: BarProp; styleMedia: StyleMedia; toolbar: BarProp; top: Window; window: Window; static windowDefaults(): WindowOptions; static alert(message: string): void; static confirm(message: string): boolean; }