2021-01-11 12:13:41 -05:00
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
2020-08-07 10:55:02 -04:00
2020-11-03 10:19:29 -05:00
// deno-lint-ignore-file no-explicit-any
2020-08-19 08:43:20 -04:00
2020-08-07 10:55:02 -04:00
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
declare class DOMException extends Error {
constructor ( message? : string , name? : string ) ;
readonly name : string ;
readonly message : string ;
2021-01-09 01:27:46 -05:00
readonly code : number ;
2020-08-07 10:55:02 -04:00
}
interface EventInit {
bubbles? : boolean ;
cancelable? : boolean ;
composed? : boolean ;
}
/** An event which takes place in the DOM. */
declare class Event {
constructor ( type : string , eventInitDict? : EventInit ) ;
/ * * R e t u r n s t r u e o r f a l s e d e p e n d i n g o n h o w e v e n t w a s i n i t i a l i z e d . T r u e i f
* event goes through its target ' s ancestors in reverse tree order , and
* false otherwise . * /
readonly bubbles : boolean ;
cancelBubble : boolean ;
/ * * R e t u r n s t r u e o r f a l s e d e p e n d i n g o n h o w e v e n t w a s i n i t i a l i z e d . I t s r e t u r n
* value does not always carry meaning , but true can indicate that part of the
* operation during which event was dispatched , can be canceled by invoking
* the preventDefault ( ) method . * /
readonly cancelable : boolean ;
/ * * R e t u r n s t r u e o r f a l s e d e p e n d i n g o n h o w e v e n t w a s i n i t i a l i z e d . T r u e i f
* event invokes listeners past a ShadowRoot node that is the root of its
* target , and false otherwise . * /
readonly composed : boolean ;
/ * * R e t u r n s t h e o b j e c t w h o s e e v e n t l i s t e n e r ' s c a l l b a c k i s c u r r e n t l y b e i n g
* invoked . * /
readonly currentTarget : EventTarget | null ;
/ * * R e t u r n s t r u e i f p r e v e n t D e f a u l t ( ) w a s i n v o k e d s u c c e s s f u l l y t o i n d i c a t e
* cancellation , and false otherwise . * /
readonly defaultPrevented : boolean ;
/ * * R e t u r n s t h e e v e n t ' s p h a s e , w h i c h i s o n e o f N O N E , C A P T U R I N G _ P H A S E ,
* AT_TARGET , and BUBBLING_PHASE . * /
readonly eventPhase : number ;
/ * * R e t u r n s t r u e i f e v e n t w a s d i s p a t c h e d b y t h e u s e r a g e n t , a n d f a l s e
* otherwise . * /
readonly isTrusted : boolean ;
/** Returns the object to which event is dispatched (its target). */
readonly target : EventTarget | null ;
/ * * R e t u r n s t h e e v e n t ' s t i m e s t a m p a s t h e n u m b e r o f m i l l i s e c o n d s m e a s u r e d
* relative to the time origin . * /
readonly timeStamp : number ;
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
readonly type : string ;
/ * * R e t u r n s t h e i n v o c a t i o n t a r g e t o b j e c t s o f e v e n t ' s p a t h ( o b j e c t s o n w h i c h
* listeners will be invoked ) , except for any nodes in shadow trees of which
* the shadow root 's mode is "closed" that are not reachable from event' s
* currentTarget . * /
composedPath ( ) : EventTarget [ ] ;
/ * * I f i n v o k e d w h e n t h e c a n c e l a b l e a t t r i b u t e v a l u e i s t r u e , a n d w h i l e
* 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 ;
/ * * I n v o k i n g t h i s m e t h o d p r e v e n t s e v e n t f r o m r e a c h i n g a n y r e g i s t e r e d e v e n t
* listeners after the current one finishes running and , when dispatched in a
* tree , also prevents event from reaching any other objects . * /
stopImmediatePropagation ( ) : void ;
/ * * W h e n d i s p a t c h e d i n a t r e e , i n v o k i n g t h i s m e t h o d p r e v e n t s e v e n t f r o m
* reaching any objects other than the current object . * /
stopPropagation ( ) : void ;
readonly AT_TARGET : number ;
readonly BUBBLING_PHASE : number ;
readonly CAPTURING_PHASE : number ;
readonly NONE : number ;
static readonly AT_TARGET : number ;
static readonly BUBBLING_PHASE : number ;
static readonly CAPTURING_PHASE : number ;
static readonly NONE : number ;
}
/ * *
* EventTarget is a DOM interface implemented by objects that can receive events
* and may have listeners for them .
* /
declare class EventTarget {
/ * * A p p e n d s a n e v e n t l i s t e n e r f o r e v e n t s w h o s e t y p e a t t r i b u t e v a l u e i s t y p e .
* The callback argument sets the callback that will be invoked when the event
* is dispatched .
*
* The options argument sets listener - specific options . For compatibility this
* can be a boolean , in which case the method behaves exactly as if the value
* was specified as options ' s capture .
*
* When set to true , options ' s capture prevents callback from being invoked
* when the event ' s eventPhase attribute value is BUBBLING_PHASE . When false
* ( or not present ) , callback will not be invoked when event ' s eventPhase
* attribute value is CAPTURING_PHASE . Either way , callback will be invoked if
* event ' s eventPhase attribute value is AT_TARGET .
*
* When set to true , options ' s passive indicates that the callback will not
* cancel the event by invoking preventDefault ( ) . This is used to enable
* performance optimizations described in § 2.8 Observing event listeners .
*
* When set to true , options ' s once indicates that the callback will only be
* invoked once after which the event listener will be removed .
*
* The event listener is appended to target ' s event listener list and is not
* appended if it has the same type , callback , and capture . * /
addEventListener (
type : string ,
listener : EventListenerOrEventListenerObject | null ,
options? : boolean | AddEventListenerOptions ,
) : void ;
/ * * D i s p a t c h e s a s y n t h e t i c e v e n t e v e n t t o t a r g e t a n d r e t u r n s t r u e i f e i t h e r
* event ' s cancelable attribute value is false or its preventDefault ( ) method
* was not invoked , and false otherwise . * /
dispatchEvent ( event : Event ) : boolean ;
/ * * R e m o v e s t h e e v e n t l i s t e n e r i n t a r g e t ' s e v e n t l i s t e n e r l i s t w i t h t h e s a m e
* type , callback , and options . * /
removeEventListener (
type : string ,
callback : EventListenerOrEventListenerObject | null ,
options? : EventListenerOptions | boolean ,
) : void ;
[ Symbol . toStringTag ] : string ;
}
interface EventListener {
( evt : Event ) : void | Promise < void > ;
}
interface EventListenerObject {
handleEvent ( evt : Event ) : void | Promise < void > ;
}
declare type EventListenerOrEventListenerObject =
| EventListener
| EventListenerObject ;
interface AddEventListenerOptions extends EventListenerOptions {
once? : boolean ;
passive? : boolean ;
}
interface EventListenerOptions {
capture? : boolean ;
}
2020-12-26 12:15:30 -05:00
interface ProgressEventInit extends EventInit {
lengthComputable? : boolean ;
loaded? : number ;
total? : number ;
}
/ * * E v e n t s m e a s u r i n g p r o g r e s s o f a n u n d e r l y i n g p r o c e s s , l i k e a n H T T P r e q u e s t
* ( for an XMLHttpRequest , or the loading of the underlying resource of an
* < img > , < audio > , < video > , < style > or < link > ) . * /
declare class ProgressEvent < T extends EventTarget = EventTarget > extends Event {
constructor ( type : string , eventInitDict? : ProgressEventInit ) ;
readonly lengthComputable : boolean ;
readonly loaded : number ;
readonly target : T | null ;
readonly total : number ;
}
2020-08-07 10:55:02 -04:00
/ * * D e c o d e s a s t r i n g o f d a t a w h i c h h a s b e e n e n c o d e d u s i n g b a s e - 6 4 e n c o d i n g .
*
* console . log ( atob ( "aGVsbG8gd29ybGQ=" ) ) ; // outputs 'hello world'
* /
declare function atob ( s : string ) : string ;
/ * * C r e a t e s a b a s e - 6 4 A S C I I e n c o d e d s t r i n g f r o m t h e i n p u t s t r i n g .
*
* console . log ( btoa ( "hello world" ) ) ; // outputs "aGVsbG8gd29ybGQ="
* /
declare function btoa ( s : string ) : string ;
declare class TextDecoder {
/** Returns encoding's name, lowercased. */
readonly encoding : string ;
/** Returns `true` if error mode is "fatal", and `false` otherwise. */
readonly fatal : boolean ;
/** Returns `true` if ignore BOM flag is set, and `false` otherwise. */
readonly ignoreBOM = false ;
constructor (
label? : string ,
options ? : { fatal? : boolean ; ignoreBOM? : boolean } ,
) ;
/** Returns the result of running encoding's decoder. */
decode ( input? : BufferSource , options ? : { stream? : false } ) : string ;
readonly [ Symbol . toStringTag ] : string ;
}
declare class TextEncoder {
/** Returns "utf-8". */
readonly encoding = "utf-8" ;
/** Returns the result of running UTF-8's encoder. */
encode ( input? : string ) : Uint8Array ;
encodeInto (
input : string ,
dest : Uint8Array ,
) : { read : number ; written : number } ;
readonly [ Symbol . toStringTag ] : string ;
}
2020-08-19 08:43:20 -04:00
/ * * A c o n t r o l l e r o b j e c t t h a t a l l o w s y o u t o a b o r t o n e o r m o r e D O M r e q u e s t s a s a n d
* when desired . * /
declare class AbortController {
/** Returns the AbortSignal object associated with this object. */
readonly signal : AbortSignal ;
/ * * I n v o k i n g t h i s m e t h o d w i l l s e t t h i s o b j e c t ' s A b o r t S i g n a l ' s a b o r t e d f l a g a n d
* signal to any observers that the associated activity is to be aborted . * /
abort ( ) : void ;
}
interface AbortSignalEventMap {
abort : Event ;
}
/ * * A s i g n a l o b j e c t t h a t a l l o w s y o u t o c o m m u n i c a t e w i t h a D O M r e q u e s t ( s u c h a s a
* Fetch ) and abort it if required via an AbortController object . * /
interface AbortSignal extends EventTarget {
/ * * R e t u r n s t r u e i f t h i s A b o r t S i g n a l ' s A b o r t C o n t r o l l e r h a s s i g n a l e d t o a b o r t ,
* and false otherwise . * /
readonly aborted : boolean ;
onabort : ( ( this : AbortSignal , ev : Event ) = > any ) | null ;
addEventListener < K extends keyof AbortSignalEventMap > (
type : K ,
listener : ( this : AbortSignal , ev : AbortSignalEventMap [ K ] ) = > any ,
options? : boolean | AddEventListenerOptions ,
) : void ;
addEventListener (
type : string ,
listener : EventListenerOrEventListenerObject ,
options? : boolean | AddEventListenerOptions ,
) : void ;
removeEventListener < K extends keyof AbortSignalEventMap > (
type : K ,
listener : ( this : AbortSignal , ev : AbortSignalEventMap [ K ] ) = > any ,
options? : boolean | EventListenerOptions ,
) : void ;
removeEventListener (
type : string ,
listener : EventListenerOrEventListenerObject ,
options? : boolean | EventListenerOptions ,
) : void ;
}
2020-09-25 17:23:35 -04:00
declare var AbortSignal : {
2020-08-19 08:43:20 -04:00
prototype : AbortSignal ;
new ( ) : AbortSignal ;
} ;
2020-09-18 10:01:50 -04:00
interface FileReaderEventMap {
"abort" : ProgressEvent < FileReader > ;
"error" : ProgressEvent < FileReader > ;
"load" : ProgressEvent < FileReader > ;
"loadend" : ProgressEvent < FileReader > ;
"loadstart" : ProgressEvent < FileReader > ;
"progress" : ProgressEvent < FileReader > ;
}
/** Lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read. */
interface FileReader extends EventTarget {
readonly error : DOMException | null ;
onabort : ( ( this : FileReader , ev : ProgressEvent < FileReader > ) = > any ) | null ;
onerror : ( ( this : FileReader , ev : ProgressEvent < FileReader > ) = > any ) | null ;
onload : ( ( this : FileReader , ev : ProgressEvent < FileReader > ) = > any ) | null ;
onloadend : ( ( this : FileReader , ev : ProgressEvent < FileReader > ) = > any ) | null ;
onloadstart :
| ( ( this : FileReader , ev : ProgressEvent < FileReader > ) = > any )
| null ;
onprogress : ( ( this : FileReader , ev : ProgressEvent < FileReader > ) = > any ) | null ;
readonly readyState : number ;
readonly result : string | ArrayBuffer | null ;
abort ( ) : void ;
readAsArrayBuffer ( blob : Blob ) : void ;
readAsBinaryString ( blob : Blob ) : void ;
readAsDataURL ( blob : Blob ) : void ;
readAsText ( blob : Blob , encoding? : string ) : void ;
readonly DONE : number ;
readonly EMPTY : number ;
readonly LOADING : number ;
addEventListener < K extends keyof FileReaderEventMap > (
type : K ,
listener : ( this : FileReader , ev : FileReaderEventMap [ K ] ) = > any ,
options? : boolean | AddEventListenerOptions ,
) : void ;
addEventListener (
type : string ,
listener : EventListenerOrEventListenerObject ,
options? : boolean | AddEventListenerOptions ,
) : void ;
removeEventListener < K extends keyof FileReaderEventMap > (
type : K ,
listener : ( this : FileReader , ev : FileReaderEventMap [ K ] ) = > any ,
options? : boolean | EventListenerOptions ,
) : void ;
removeEventListener (
type : string ,
listener : EventListenerOrEventListenerObject ,
options? : boolean | EventListenerOptions ,
) : void ;
}
declare var FileReader : {
prototype : FileReader ;
new ( ) : FileReader ;
readonly DONE : number ;
readonly EMPTY : number ;
readonly LOADING : number ;
} ;