2022-01-20 02:10:16 -05:00
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2020-08-07 10:55:02 -04:00
2021-12-09 17:12:21 -05:00
// deno-lint-ignore-file no-explicit-any no-var
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
2021-09-02 18:28:12 -04:00
* event goes through its target ' s ancestors in reverse tree order , and
* false otherwise . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* 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 . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* event invokes listeners past a ShadowRoot node that is the root of its
* target , and false otherwise . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* invoked . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* cancellation , and false otherwise . * /
2020-08-07 10:55:02 -04:00
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 ,
2021-09-02 18:28:12 -04:00
* AT_TARGET , and BUBBLING_PHASE . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* otherwise . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* relative to the time origin . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* 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 . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* 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 . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* listeners after the current one finishes running and , when dispatched in a
* tree , also prevents event from reaching any other objects . * /
2020-08-07 10:55:02 -04:00
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
2021-09-02 18:28:12 -04:00
* reaching any objects other than the current object . * /
2020-08-07 10:55:02 -04:00
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 ;
}
/ * *
2021-09-02 18:28:12 -04:00
* EventTarget is a DOM interface implemented by objects that can receive events
* and may have listeners for them .
* /
2020-08-07 10:55:02 -04:00
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 .
2021-04-14 16:49:16 -04:00
* 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 . * /
2020-08-07 10:55:02 -04:00
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
2021-04-14 16:49:16 -04:00
* event ' s cancelable attribute value is false or its preventDefault ( ) method
* was not invoked , and false otherwise . * /
2020-08-07 10:55:02 -04:00
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
2021-04-14 16:49:16 -04:00
* type , callback , and options . * /
2020-08-07 10:55:02 -04:00
removeEventListener (
type : string ,
callback : EventListenerOrEventListenerObject | null ,
options? : EventListenerOptions | boolean ,
) : void ;
}
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 .
*
2022-02-22 14:41:59 -05:00
* ` ` `
* console . log ( atob ( "aGVsbG8gd29ybGQ=" ) ) ; // outputs 'hello world'
* ` ` `
2020-08-07 10:55:02 -04:00
* /
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 .
*
2022-02-22 14:41:59 -05:00
* ` ` `
* console . log ( btoa ( "hello world" ) ) ; // outputs "aGVsbG8gd29ybGQ="
* ` ` `
2020-08-07 10:55:02 -04:00
* /
declare function btoa ( s : string ) : string ;
2021-06-05 17:10:07 -04:00
declare interface TextDecoderOptions {
fatal? : boolean ;
ignoreBOM? : boolean ;
}
declare interface TextDecodeOptions {
stream? : boolean ;
}
2021-10-21 02:47:14 -04:00
interface TextDecoder {
2021-04-01 21:12:07 -04:00
/** Returns encoding's name, lowercased. */
2020-08-07 10:55:02 -04:00
readonly encoding : string ;
2021-04-01 21:12:07 -04:00
/** Returns `true` if error mode is "fatal", and `false` otherwise. */
2020-08-07 10:55:02 -04:00
readonly fatal : boolean ;
2021-04-01 21:12:07 -04:00
/** Returns `true` if ignore BOM flag is set, and `false` otherwise. */
2021-10-21 02:47:14 -04:00
readonly ignoreBOM : boolean ;
2021-06-05 17:10:07 -04:00
2021-06-05 21:23:16 -04:00
/** Returns the result of running encoding's decoder. */
2021-06-05 17:10:07 -04:00
decode ( input? : BufferSource , options? : TextDecodeOptions ) : string ;
}
2021-10-21 02:47:14 -04:00
declare var TextDecoder : {
prototype : TextDecoder ;
new ( label? : string , options? : TextDecoderOptions ) : TextDecoder ;
} ;
2021-06-05 17:10:07 -04:00
declare interface TextEncoderEncodeIntoResult {
read : number ;
written : number ;
2021-04-01 21:12:07 -04:00
}
2021-10-21 02:47:14 -04:00
interface TextEncoder {
2021-04-01 21:12:07 -04:00
/** Returns "utf-8". */
2021-06-05 21:23:16 -04:00
readonly encoding : "utf-8" ;
2021-04-01 21:12:07 -04:00
/** Returns the result of running UTF-8's encoder. */
2020-08-07 10:55:02 -04:00
encode ( input? : string ) : Uint8Array ;
2021-06-05 17:10:07 -04:00
encodeInto ( input : string , dest : Uint8Array ) : TextEncoderEncodeIntoResult ;
2020-08-07 10:55:02 -04:00
}
2020-08-19 08:43:20 -04:00
2021-10-21 02:47:14 -04:00
declare var TextEncoder : {
prototype : TextEncoder ;
new ( ) : TextEncoder ;
} ;
interface TextDecoderStream {
2021-06-05 21:23:16 -04:00
/** 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. */
2021-10-21 02:47:14 -04:00
readonly ignoreBOM : boolean ;
2021-06-05 21:23:16 -04:00
readonly readable : ReadableStream < string > ;
readonly writable : WritableStream < BufferSource > ;
readonly [ Symbol . toStringTag ] : string ;
}
2021-10-21 02:47:14 -04:00
declare var TextDecoderStream : {
prototype : TextDecoderStream ;
new ( label? : string , options? : TextDecoderOptions ) : TextDecoderStream ;
} ;
interface TextEncoderStream {
2021-06-05 21:23:16 -04:00
/** Returns "utf-8". */
readonly encoding : "utf-8" ;
readonly readable : ReadableStream < Uint8Array > ;
readonly writable : WritableStream < string > ;
readonly [ Symbol . toStringTag ] : string ;
}
2021-10-21 02:47:14 -04:00
declare var TextEncoderStream : {
prototype : TextEncoderStream ;
new ( ) : TextEncoderStream ;
} ;
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
2021-09-02 18:28:12 -04:00
* signal to any observers that the associated activity is to be aborted . * /
2021-11-11 04:28:06 -05:00
abort ( reason? : any ) : void ;
2020-08-19 08:43:20 -04:00
}
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
2021-09-02 18:28:12 -04:00
* Fetch ) and abort it if required via an AbortController object . * /
2020-08-19 08:43:20 -04:00
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 ,
2021-09-02 18:28:12 -04:00
* and false otherwise . * /
2020-08-19 08:43:20 -04:00
readonly aborted : boolean ;
2022-05-31 20:19:18 -04:00
readonly reason : any ;
2020-08-19 08:43:20 -04:00
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 ;
2021-12-10 09:12:38 -05:00
/ * * T h r o w s t h i s A b o r t S i g n a l ' s a b o r t r e a s o n , i f i t s A b o r t C o n t r o l l e r h a s
* signaled to abort ; otherwise , does nothing . * /
throwIfAborted ( ) : void ;
2020-08-19 08:43:20 -04:00
}
2020-09-25 17:23:35 -04:00
declare var AbortSignal : {
2020-08-19 08:43:20 -04:00
prototype : AbortSignal ;
new ( ) : AbortSignal ;
2021-11-11 04:28:06 -05:00
abort ( reason? : any ) : AbortSignal ;
2022-03-14 15:19:22 -04:00
timeout ( milliseconds : number ) : AbortSignal ;
2020-08-19 08:43:20 -04:00
} ;
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-06-10 09:26:10 -04:00
type BlobPart = BufferSource | Blob | string ;
interface BlobPropertyBag {
type ? : string ;
endings ? : "transparent" | "native" ;
}
/** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */
declare class Blob {
constructor ( blobParts? : BlobPart [ ] , options? : BlobPropertyBag ) ;
readonly size : number ;
readonly type : string ;
arrayBuffer ( ) : Promise < ArrayBuffer > ;
slice ( start? : number , end? : number , contentType? : string ) : Blob ;
stream ( ) : ReadableStream < Uint8Array > ;
text ( ) : Promise < string > ;
}
interface FilePropertyBag extends BlobPropertyBag {
lastModified? : number ;
}
/ * * P r o v i d e s i n f o r m a t i o n a b o u t f i l e s a n d a l l o w s J a v a S c r i p t i n a w e b p a g e t o
* access their content . * /
declare class File extends Blob {
constructor (
fileBits : BlobPart [ ] ,
fileName : string ,
options? : FilePropertyBag ,
) ;
readonly lastModified : number ;
readonly name : string ;
}
2021-06-14 07:51:02 -04:00
interface ReadableStreamReadDoneResult < T > {
done : true ;
value? : T ;
}
interface ReadableStreamReadValueResult < T > {
done : false ;
value : T ;
}
type ReadableStreamReadResult < T > =
| ReadableStreamReadValueResult < T >
| ReadableStreamReadDoneResult < T > ;
interface ReadableStreamDefaultReader < R = any > {
readonly closed : Promise < void > ;
cancel ( reason? : any ) : Promise < void > ;
read ( ) : Promise < ReadableStreamReadResult < R > > ;
releaseLock ( ) : void ;
}
2021-11-05 07:56:28 -04:00
interface ReadableStreamBYOBReadDoneResult < V extends ArrayBufferView > {
2021-11-03 05:47:40 -04:00
done : true ;
2021-11-05 07:56:28 -04:00
value? : V ;
2021-11-03 05:47:40 -04:00
}
2021-11-05 07:56:28 -04:00
interface ReadableStreamBYOBReadValueResult < V extends ArrayBufferView > {
2021-11-03 05:47:40 -04:00
done : false ;
2021-11-05 07:56:28 -04:00
value : V ;
2021-11-03 05:47:40 -04:00
}
2021-11-05 07:56:28 -04:00
type ReadableStreamBYOBReadResult < V extends ArrayBufferView > =
| ReadableStreamBYOBReadDoneResult < V >
| ReadableStreamBYOBReadValueResult < V > ;
2021-11-03 05:47:40 -04:00
interface ReadableStreamBYOBReader {
readonly closed : Promise < void > ;
cancel ( reason? : any ) : Promise < void > ;
2021-11-05 07:56:28 -04:00
read < V extends ArrayBufferView > (
view : V ,
) : Promise < ReadableStreamBYOBReadResult < V > > ;
2021-11-03 05:47:40 -04:00
releaseLock ( ) : void ;
}
interface ReadableStreamBYOBRequest {
readonly view : ArrayBufferView | null ;
respond ( bytesWritten : number ) : void ;
respondWithNewView ( view : ArrayBufferView ) : void ;
}
2021-06-14 07:51:02 -04:00
declare var ReadableStreamDefaultReader : {
prototype : ReadableStreamDefaultReader ;
new < R > ( stream : ReadableStream < R > ) : ReadableStreamDefaultReader < R > ;
} ;
interface ReadableStreamReader < R = any > {
cancel ( ) : Promise < void > ;
read ( ) : Promise < ReadableStreamReadResult < R > > ;
releaseLock ( ) : void ;
}
declare var ReadableStreamReader : {
prototype : ReadableStreamReader ;
new ( ) : ReadableStreamReader ;
} ;
interface ReadableByteStreamControllerCallback {
( controller : ReadableByteStreamController ) : void | PromiseLike < void > ;
}
interface UnderlyingByteSource {
autoAllocateChunkSize? : number ;
cancel? : ReadableStreamErrorCallback ;
pull? : ReadableByteStreamControllerCallback ;
start? : ReadableByteStreamControllerCallback ;
type : "bytes" ;
}
interface UnderlyingSink < W = any > {
abort? : WritableStreamErrorCallback ;
close? : WritableStreamDefaultControllerCloseCallback ;
start? : WritableStreamDefaultControllerStartCallback ;
type ? : undefined ;
write? : WritableStreamDefaultControllerWriteCallback < W > ;
}
interface UnderlyingSource < R = any > {
cancel? : ReadableStreamErrorCallback ;
pull? : ReadableStreamDefaultControllerCallback < R > ;
start? : ReadableStreamDefaultControllerCallback < R > ;
type ? : undefined ;
}
interface ReadableStreamErrorCallback {
( reason : any ) : void | PromiseLike < void > ;
}
interface ReadableStreamDefaultControllerCallback < R > {
( controller : ReadableStreamDefaultController < R > ) : void | PromiseLike < void > ;
}
interface ReadableStreamDefaultController < R = any > {
readonly desiredSize : number | null ;
close ( ) : void ;
enqueue ( chunk : R ) : void ;
error ( error? : any ) : void ;
}
declare var ReadableStreamDefaultController : {
prototype : ReadableStreamDefaultController ;
new ( ) : ReadableStreamDefaultController ;
} ;
interface ReadableByteStreamController {
2021-11-03 05:47:40 -04:00
readonly byobRequest : ReadableStreamBYOBRequest | null ;
2021-06-14 07:51:02 -04:00
readonly desiredSize : number | null ;
close ( ) : void ;
enqueue ( chunk : ArrayBufferView ) : void ;
error ( error? : any ) : void ;
}
declare var ReadableByteStreamController : {
prototype : ReadableByteStreamController ;
new ( ) : ReadableByteStreamController ;
} ;
interface PipeOptions {
preventAbort? : boolean ;
preventCancel? : boolean ;
preventClose? : boolean ;
signal? : AbortSignal ;
}
interface QueuingStrategySizeCallback < T = any > {
( chunk : T ) : number ;
}
interface QueuingStrategy < T = any > {
highWaterMark? : number ;
size? : QueuingStrategySizeCallback < T > ;
}
/ * * T h i s S t r e a m s A P I i n t e r f a c e p r o v i d e s a b u i l t - i n b y t e l e n g t h q u e u i n g s t r a t e g y
* that can be used when constructing streams . * /
2021-10-21 02:47:14 -04:00
interface CountQueuingStrategy extends QueuingStrategy {
2021-06-14 07:51:02 -04:00
highWaterMark : number ;
size ( chunk : any ) : 1 ;
}
2021-10-21 02:47:14 -04:00
declare var CountQueuingStrategy : {
prototype : CountQueuingStrategy ;
new ( options : { highWaterMark : number } ) : CountQueuingStrategy ;
} ;
interface ByteLengthQueuingStrategy extends QueuingStrategy < ArrayBufferView > {
2021-06-14 07:51:02 -04:00
highWaterMark : number ;
size ( chunk : ArrayBufferView ) : number ;
}
2021-10-21 02:47:14 -04:00
declare var ByteLengthQueuingStrategy : {
prototype : ByteLengthQueuingStrategy ;
new ( options : { highWaterMark : number } ) : ByteLengthQueuingStrategy ;
} ;
2021-06-14 07:51:02 -04:00
/ * * T h i s S t r e a m s A P I i n t e r f a c e r e p r e s e n t s a r e a d a b l e s t r e a m o f b y t e d a t a . T h e
* Fetch API offers a concrete instance of a ReadableStream through the body
* property of a Response object . * /
interface ReadableStream < R = any > {
readonly locked : boolean ;
cancel ( reason? : any ) : Promise < void > ;
2021-11-05 07:56:28 -04:00
getReader ( options : { mode : "byob" } ) : ReadableStreamBYOBReader ;
getReader ( options ? : { mode? : undefined } ) : ReadableStreamDefaultReader < R > ;
2021-06-14 07:51:02 -04:00
pipeThrough < T > (
{ writable , readable } : {
writable : WritableStream < R > ;
readable : ReadableStream < T > ;
} ,
options? : PipeOptions ,
) : ReadableStream < T > ;
pipeTo ( dest : WritableStream < R > , options? : PipeOptions ) : Promise < void > ;
tee ( ) : [ ReadableStream < R > , ReadableStream < R > ] ;
[ Symbol . asyncIterator ] ( options ? : {
preventCancel? : boolean ;
} ) : AsyncIterableIterator < R > ;
}
declare var ReadableStream : {
prototype : ReadableStream ;
new (
underlyingSource : UnderlyingByteSource ,
strategy ? : { highWaterMark? : number ; size? : undefined } ,
) : ReadableStream < Uint8Array > ;
new < R = any > (
underlyingSource? : UnderlyingSource < R > ,
strategy? : QueuingStrategy < R > ,
) : ReadableStream < R > ;
} ;
interface WritableStreamDefaultControllerCloseCallback {
( ) : void | PromiseLike < void > ;
}
interface WritableStreamDefaultControllerStartCallback {
( controller : WritableStreamDefaultController ) : void | PromiseLike < void > ;
}
interface WritableStreamDefaultControllerWriteCallback < W > {
( chunk : W , controller : WritableStreamDefaultController ) :
| void
| PromiseLike <
void
> ;
}
interface WritableStreamErrorCallback {
( reason : any ) : void | PromiseLike < void > ;
}
/ * * T h i s S t r e a m s A P I i n t e r f a c e p r o v i d e s a s t a n d a r d a b s t r a c t i o n f o r w r i t i n g
* streaming data to a destination , known as a sink . This object comes with
* built - in backpressure and queuing . * /
interface WritableStream < W = any > {
readonly locked : boolean ;
abort ( reason? : any ) : Promise < void > ;
2022-04-20 18:20:33 -04:00
close ( ) : Promise < void > ;
2021-06-14 07:51:02 -04:00
getWriter ( ) : WritableStreamDefaultWriter < W > ;
}
declare var WritableStream : {
prototype : WritableStream ;
new < W = any > (
underlyingSink? : UnderlyingSink < W > ,
strategy? : QueuingStrategy < W > ,
) : WritableStream < W > ;
} ;
/ * * T h i s S t r e a m s A P I i n t e r f a c e r e p r e s e n t s a c o n t r o l l e r a l l o w i n g c o n t r o l o f a
* WritableStream ' s state . When constructing a WritableStream , the underlying
* sink is given a corresponding WritableStreamDefaultController instance to
* manipulate . * /
interface WritableStreamDefaultController {
2021-11-08 06:54:24 -05:00
signal : AbortSignal ;
2021-06-14 07:51:02 -04:00
error ( error? : any ) : void ;
}
2021-10-21 02:47:14 -04:00
declare var WritableStreamDefaultController : WritableStreamDefaultController ;
2021-06-14 07:51:02 -04:00
/ * * T h i s S t r e a m s A P I i n t e r f a c e i s t h e o b j e c t r e t u r n e d b y
* WritableStream . getWriter ( ) and once created locks the < writer to the
* WritableStream ensuring that no other streams can write to the underlying
* sink . * /
interface WritableStreamDefaultWriter < W = any > {
readonly closed : Promise < void > ;
readonly desiredSize : number | null ;
readonly ready : Promise < void > ;
abort ( reason? : any ) : Promise < void > ;
close ( ) : Promise < void > ;
releaseLock ( ) : void ;
write ( chunk : W ) : Promise < void > ;
}
declare var WritableStreamDefaultWriter : {
prototype : WritableStreamDefaultWriter ;
new ( ) : WritableStreamDefaultWriter ;
} ;
interface TransformStream < I = any , O = any > {
readonly readable : ReadableStream < O > ;
readonly writable : WritableStream < I > ;
}
declare var TransformStream : {
prototype : TransformStream ;
new < I = any , O = any > (
transformer? : Transformer < I , O > ,
writableStrategy? : QueuingStrategy < I > ,
readableStrategy? : QueuingStrategy < O > ,
) : TransformStream < I , O > ;
} ;
interface TransformStreamDefaultController < O = any > {
readonly desiredSize : number | null ;
enqueue ( chunk : O ) : void ;
error ( reason? : any ) : void ;
terminate ( ) : void ;
}
2021-10-21 02:47:14 -04:00
declare var TransformStreamDefaultController : TransformStreamDefaultController ;
2021-06-14 07:51:02 -04:00
interface Transformer < I = any , O = any > {
flush? : TransformStreamDefaultControllerCallback < O > ;
readableType? : undefined ;
start? : TransformStreamDefaultControllerCallback < O > ;
transform? : TransformStreamDefaultControllerTransformCallback < I , O > ;
writableType? : undefined ;
}
interface TransformStreamDefaultControllerCallback < O > {
( controller : TransformStreamDefaultController < O > ) : void | PromiseLike < void > ;
}
interface TransformStreamDefaultControllerTransformCallback < I , O > {
(
chunk : I ,
controller : TransformStreamDefaultController < O > ,
) : void | PromiseLike < void > ;
}
2021-06-21 13:53:52 -04:00
interface MessageEventInit < T = any > extends EventInit {
data? : T ;
origin? : string ;
lastEventId? : string ;
}
declare class MessageEvent < T = any > extends Event {
/ * *
* Returns the data of the message .
* /
readonly data : T ;
/ * *
* Returns the last event ID string , for server - sent events .
* /
readonly lastEventId : string ;
/ * *
2022-06-07 05:25:10 -04:00
* Returns transferred ports .
2021-06-21 13:53:52 -04:00
* /
readonly ports : ReadonlyArray < MessagePort > ;
constructor ( type : string , eventInitDict? : MessageEventInit ) ;
}
type Transferable = ArrayBuffer | MessagePort ;
2021-08-09 04:39:00 -04:00
/ * *
* @deprecated
*
* This type has been renamed to StructuredSerializeOptions . Use that type for
* new code .
* /
type PostMessageOptions = StructuredSerializeOptions ;
interface StructuredSerializeOptions {
2021-06-21 13:53:52 -04:00
transfer? : Transferable [ ] ;
}
/ * * T h e M e s s a g e C h a n n e l i n t e r f a c e o f t h e C h a n n e l M e s s a g i n g A P I a l l o w s u s t o
* create a new message channel and send data through it via its two MessagePort
* properties . * /
declare class MessageChannel {
constructor ( ) ;
readonly port1 : MessagePort ;
readonly port2 : MessagePort ;
}
interface MessagePortEventMap {
"message" : MessageEvent ;
"messageerror" : MessageEvent ;
}
/ * * T h e M e s s a g e P o r t i n t e r f a c e o f t h e C h a n n e l M e s s a g i n g A P I r e p r e s e n t s o n e o f t h e
* two ports of a MessageChannel , allowing messages to be sent from one port and
* listening out for them arriving at the other . * /
declare class MessagePort extends EventTarget {
onmessage : ( ( this : MessagePort , ev : MessageEvent ) = > any ) | null ;
onmessageerror : ( ( this : MessagePort , ev : MessageEvent ) = > any ) | null ;
/ * *
* Disconnects the port , so that it is no longer active .
* /
close ( ) : void ;
/ * *
* Posts a message through the channel . Objects listed in transfer are
* transferred , not just cloned , meaning that they are no longer usable on the
* sending side .
*
* Throws a "DataCloneError" DOMException if transfer contains duplicate
* objects or port , or if message could not be cloned .
* /
postMessage ( message : any , transfer : Transferable [ ] ) : void ;
2021-08-09 04:39:00 -04:00
postMessage ( message : any , options? : StructuredSerializeOptions ) : void ;
2021-06-21 13:53:52 -04:00
/ * *
* Begins dispatching messages received on the port . This is implictly called
* when assiging a value to ` this.onmessage ` .
* /
start ( ) : void ;
addEventListener < K extends keyof MessagePortEventMap > (
type : K ,
listener : ( this : MessagePort , ev : MessagePortEventMap [ K ] ) = > any ,
options? : boolean | AddEventListenerOptions ,
) : void ;
addEventListener (
type : string ,
listener : EventListenerOrEventListenerObject ,
options? : boolean | AddEventListenerOptions ,
) : void ;
removeEventListener < K extends keyof MessagePortEventMap > (
type : K ,
listener : ( this : MessagePort , ev : MessagePortEventMap [ K ] ) = > any ,
options? : boolean | EventListenerOptions ,
) : void ;
removeEventListener (
type : string ,
listener : EventListenerOrEventListenerObject ,
options? : boolean | EventListenerOptions ,
) : void ;
}
2021-08-09 04:39:00 -04:00
2022-02-22 14:41:59 -05:00
/ * *
* Creates a deep copy of a given value using the structured clone algorithm .
*
* Unlike a shallow copy , a deep copy does not hold the same references as the
* source object , meaning its properties can be changed without affecting the
* source . For more details , see
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Glossary/Deep_copy).
*
* Throws a ` DataCloneError ` if any part of the input value is not
* serializable .
*
* @example
* ` ` ` ts
* const object = { x : 0 , y : 1 } ;
*
* const deepCopy = structuredClone ( object ) ;
* deepCopy . x = 1 ;
* console . log ( deepCopy . x , object . x ) ; // 1 0
*
* const shallowCopy = object ;
* shallowCopy . x = 1 ;
* // shallowCopy.x is pointing to the same location in memory as object.x
* console . log ( shallowCopy . x , object . x ) ; // 1 1
* ` ` `
* /
2021-08-09 04:39:00 -04:00
declare function structuredClone (
value : any ,
options? : StructuredSerializeOptions ,
) : any ;
2022-01-24 12:03:06 -05:00
2022-02-22 14:41:59 -05:00
/ * *
* An API for compressing a stream of data .
*
* @example
* ` ` ` ts
* await Deno . stdin . readable
* . pipeThrough ( new CompressionStream ( "gzip" ) )
* . pipeTo ( Deno . stdout . writable ) ;
* ` ` `
* /
2022-01-24 12:03:06 -05:00
declare class CompressionStream {
2022-02-22 14:41:59 -05:00
/ * *
* Creates a new ` CompressionStream ` object which compresses a stream of
* data .
*
* Throws a ` TypeError ` if the format passed to the constructor is not
* supported .
* /
2022-01-24 12:03:06 -05:00
constructor ( format : string ) ;
readonly readable : ReadableStream < Uint8Array > ;
readonly writable : WritableStream < Uint8Array > ;
}
2022-02-22 14:41:59 -05:00
/ * *
* An API for decompressing a stream of data .
*
* @example
* ` ` ` ts
* const input = await Deno . open ( "./file.txt.gz" ) ;
* const output = await Deno . create ( "./file.txt" ) ;
*
* await input . readable
* . pipeThrough ( new DecompressionStream ( "gzip" ) )
* . pipeTo ( output . writable ) ;
* ` ` `
* /
2022-01-24 12:03:06 -05:00
declare class DecompressionStream {
2022-02-22 14:41:59 -05:00
/ * *
* Creates a new ` DecompressionStream ` object which decompresses a stream of
* data .
*
* Throws a ` TypeError ` if the format passed to the constructor is not
* supported .
* /
2022-01-24 12:03:06 -05:00
constructor ( format : string ) ;
readonly readable : ReadableStream < Uint8Array > ;
readonly writable : WritableStream < Uint8Array > ;
}
2022-04-19 04:59:51 -04:00
/ * * D i s p a t c h a n u n c a u g h t e x c e p t i o n . S i m i l a r t o a s y n c h r o n o u s v e r s i o n o f :
* ` ` ` ts
* setTimeout ( ( ) = > { throw error ; } , 0 ) ;
* ` ` `
* The error can not be caught with a ` try/catch ` block . An error event will
* be dispatched to the global scope . You can prevent the error from being
* reported to the console with ` Event.prototype.preventDefault() ` :
* ` ` ` ts
* addEventListener ( "error" , ( event ) = > {
* event . preventDefault ( ) ;
* } ) ;
* reportError ( new Error ( "foo" ) ) ; // Will not be reported.
* ` ` `
* In Deno , this error will terminate the process if not intercepted like above .
* /
declare function reportError (
error : any ,
) : void ;