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 ;
} ;
2021-01-28 15:37:21 -05:00
declare class URLSearchParams {
constructor (
init? : string [ ] [ ] | Record < string , string > | string | URLSearchParams ,
) ;
static toString ( ) : string ;
/ * * A p p e n d s a s p e c i f i e d k e y / v a l u e p a i r a s a n e w s e a r c h p a r a m e t e r .
*
* ` ` ` ts
* let searchParams = new URLSearchParams ( ) ;
* searchParams . append ( 'name' , 'first' ) ;
* searchParams . append ( 'name' , 'second' ) ;
* ` ` `
* /
append ( name : string , value : string ) : void ;
/ * * D e l e t e s t h e g i v e n s e a r c h p a r a m e t e r a n d i t s a s s o c i a t e d v a l u e ,
* from the list of all search parameters .
*
* ` ` ` ts
* let searchParams = new URLSearchParams ( [ [ 'name' , 'value' ] ] ) ;
* searchParams . delete ( 'name' ) ;
* ` ` `
* /
delete ( name : string ) : void ;
/ * * R e t u r n s a l l t h e v a l u e s a s s o c i a t e d w i t h a g i v e n s e a r c h p a r a m e t e r
* as an array .
*
* ` ` ` ts
* searchParams . getAll ( 'name' ) ;
* ` ` `
* /
getAll ( name : string ) : string [ ] ;
/ * * R e t u r n s t h e f i r s t v a l u e a s s o c i a t e d t o t h e g i v e n s e a r c h p a r a m e t e r .
*
* ` ` ` ts
* searchParams . get ( 'name' ) ;
* ` ` `
* /
get ( name : string ) : string | null ;
/ * * R e t u r n s a B o o l e a n t h a t i n d i c a t e s w h e t h e r a p a r a m e t e r w i t h t h e
* specified name exists .
*
* ` ` ` ts
* searchParams . has ( 'name' ) ;
* ` ` `
* /
has ( name : string ) : boolean ;
/ * * S e t s t h e v a l u e a s s o c i a t e d w i t h a g i v e n s e a r c h p a r a m e t e r t o t h e
* given value . If there were several matching values , this method
* deletes the others . If the search parameter doesn ' t exist , this
* method creates it .
*
* ` ` ` ts
* searchParams . set ( 'name' , 'value' ) ;
* ` ` `
* /
set ( name : string , value : string ) : void ;
/ * * S o r t a l l k e y / v a l u e p a i r s c o n t a i n e d i n t h i s o b j e c t i n p l a c e a n d
* return undefined . The sort order is according to Unicode code
* points of the keys .
*
* ` ` ` ts
* searchParams . sort ( ) ;
* ` ` `
* /
sort ( ) : void ;
/ * * C a l l s a f u n c t i o n f o r e a c h e l e m e n t c o n t a i n e d i n t h i s o b j e c t i n
* place and return undefined . Optionally accepts an object to use
* as this when executing callback as second argument .
*
* ` ` ` ts
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* params . forEach ( ( value , key , parent ) = > {
* console . log ( value , key , parent ) ;
* } ) ;
* ` ` `
*
* /
forEach (
callbackfn : ( value : string , key : string , parent : this ) = > void ,
thisArg? : any ,
) : void ;
/ * * R e t u r n s a n i t e r a t o r a l l o w i n g t o g o t h r o u g h a l l k e y s c o n t a i n e d
* in this object .
*
* ` ` ` ts
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const key of params . keys ( ) ) {
* console . log ( key ) ;
* }
* ` ` `
* /
keys ( ) : IterableIterator < string > ;
/ * * R e t u r n s a n i t e r a t o r a l l o w i n g t o g o t h r o u g h a l l v a l u e s c o n t a i n e d
* in this object .
*
* ` ` ` ts
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const value of params . values ( ) ) {
* console . log ( value ) ;
* }
* ` ` `
* /
values ( ) : IterableIterator < string > ;
/ * * R e t u r n s a n i t e r a t o r a l l o w i n g t o g o t h r o u g h a l l k e y / v a l u e
* pairs contained in this object .
*
* ` ` ` ts
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const [ key , value ] of params . entries ( ) ) {
* console . log ( key , value ) ;
* }
* ` ` `
* /
entries ( ) : IterableIterator < [ string , string ] > ;
/ * * R e t u r n s a n i t e r a t o r a l l o w i n g t o g o t h r o u g h a l l k e y / v a l u e
* pairs contained in this object .
*
* ` ` ` ts
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const [ key , value ] of params ) {
* console . log ( key , value ) ;
* }
* ` ` `
* /
[ Symbol . iterator ] ( ) : IterableIterator < [ string , string ] > ;
/ * * R e t u r n s a q u e r y s t r i n g s u i t a b l e f o r u s e i n a U R L .
*
* ` ` ` ts
* searchParams . toString ( ) ;
* ` ` `
* /
toString ( ) : string ;
}
/** The URL interface represents an object providing static methods used for creating object URLs. */
declare class URL {
constructor ( url : string , base? : string | URL ) ;
createObjectURL ( object : any ) : string ;
revokeObjectURL ( url : string ) : void ;
hash : string ;
host : string ;
hostname : string ;
href : string ;
toString ( ) : string ;
readonly origin : string ;
password : string ;
pathname : string ;
port : string ;
protocol : string ;
search : string ;
readonly searchParams : URLSearchParams ;
username : string ;
toJSON ( ) : string ;
}