2020-01-24 14:15:01 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-interface, @typescript-eslint/no-explicit-any */
/// <reference no-default-lib="true" />
2020-02-19 00:34:11 -05:00
// TODO: we need to remove this, but Fetch::Response::Body implements Reader
// which requires Deno.EOF, and we shouldn't be leaking that, but https_proxy
// at the least requires the Reader interface on Body, which it shouldn't
/// <reference lib="deno.ns" />
2020-01-24 14:15:01 -05:00
/// <reference lib="esnext" />
2020-01-29 12:54:23 -05:00
// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope
declare interface WindowOrWorkerGlobalScope {
// methods
fetch : typeof __fetch . fetch ;
// properties
2020-01-24 14:15:01 -05:00
File : __domTypes.DomFileConstructor ;
CustomEvent : typeof __customEvent . CustomEvent ;
Event : typeof __event . Event ;
EventTarget : typeof __eventTarget . EventTarget ;
Headers : __domTypes.HeadersConstructor ;
FormData : __domTypes.FormDataConstructor ;
2020-04-03 14:55:23 -04:00
ReadableStream : __domTypes.ReadableStreamConstructor ;
2020-01-24 14:15:01 -05:00
Request : __domTypes.RequestConstructor ;
Response : typeof __fetch . Response ;
2020-01-29 12:54:23 -05:00
location : __domTypes.Location ;
2020-01-24 14:15:01 -05:00
}
2020-02-23 09:40:44 -05:00
// This follows the WebIDL at: https://webassembly.github.io/spec/js-api/
// and: https://webassembly.github.io/spec/web-api/
declare namespace WebAssembly {
interface WebAssemblyInstantiatedSource {
module : Module ;
instance : Instance ;
}
/ * * C o m p i l e s a ` W e b A s s e m b l y . M o d u l e ` f r o m W e b A s s e m b l y b i n a r y c o d e . T h i s
* function is useful if it is necessary to a compile a module before it can
* be instantiated ( otherwise , the ` WebAssembly.instantiate() ` function
* should be used ) . * /
2020-04-08 13:21:04 -04:00
function compile ( bufferSource : BufferSource ) : Promise < Module > ;
2020-02-23 09:40:44 -05:00
/ * * C o m p i l e s a ` W e b A s s e m b l y . M o d u l e ` d i r e c t l y f r o m a s t r e a m e d u n d e r l y i n g
* source . This function is useful if it is necessary to a compile a module
* before it can be instantiated ( otherwise , the
* ` WebAssembly.instantiateStreaming() ` function should be used ) . * /
function compileStreaming (
source : Promise < __domTypes.Response >
) : Promise < Module > ;
/ * * T a k e s t h e W e b A s s e m b l y b i n a r y c o d e , i n t h e f o r m o f a t y p e d a r r a y o r
* ` ArrayBuffer ` , and performs both compilation and instantiation in one step .
* The returned ` Promise ` resolves to both a compiled ` WebAssembly.Module ` and
* its first ` WebAssembly.Instance ` . * /
function instantiate (
2020-04-08 13:21:04 -04:00
bufferSource : BufferSource ,
2020-02-23 09:40:44 -05:00
importObject? : object
) : Promise < WebAssemblyInstantiatedSource > ;
/ * * T a k e s a n a l r e a d y - c o m p i l e d ` W e b A s s e m b l y . M o d u l e ` a n d r e t u r n s a ` P r o m i s e `
* that resolves to an ` Instance ` of that ` Module ` . This overload is useful if
* the ` Module ` has already been compiled . * /
function instantiate (
module : Module ,
importObject? : object
) : Promise < Instance > ;
/ * * C o m p i l e s a n d i n s t a n t i a t e s a W e b A s s e m b l y m o d u l e d i r e c t l y f r o m a s t r e a m e d
* underlying source . This is the most efficient , optimized way to load wasm
* code . * /
function instantiateStreaming (
source : Promise < __domTypes.Response > ,
importObject? : object
) : Promise < WebAssemblyInstantiatedSource > ;
/ * * V a l i d a t e s a g i v e n t y p e d a r r a y o f W e b A s s e m b l y b i n a r y c o d e , r e t u r n i n g
* whether the bytes form a valid wasm module ( ` true ` ) or not ( ` false ` ) . * /
2020-04-08 13:21:04 -04:00
function validate ( bufferSource : BufferSource ) : boolean ;
2020-02-23 09:40:44 -05:00
type ImportExportKind = "function" | "table" | "memory" | "global" ;
interface ModuleExportDescriptor {
name : string ;
kind : ImportExportKind ;
}
interface ModuleImportDescriptor {
module : string ;
name : string ;
kind : ImportExportKind ;
}
class Module {
2020-04-08 13:21:04 -04:00
constructor ( bufferSource : BufferSource ) ;
2020-02-23 09:40:44 -05:00
/ * * G i v e n a ` M o d u l e ` a n d s t r i n g , r e t u r n s a c o p y o f t h e c o n t e n t s o f a l l
* custom sections in the module with the given string name . * /
static customSections (
moduleObject : Module ,
sectionName : string
) : ArrayBuffer ;
/ * * G i v e n a ` M o d u l e ` , r e t u r n s a n a r r a y c o n t a i n i n g d e s c r i p t i o n s o f a l l t h e
* declared exports . * /
static exports ( moduleObject : Module ) : ModuleExportDescriptor [ ] ;
/ * * G i v e n a ` M o d u l e ` , r e t u r n s a n a r r a y c o n t a i n i n g d e s c r i p t i o n s o f a l l t h e
* declared imports . * /
static imports ( moduleObject : Module ) : ModuleImportDescriptor [ ] ;
}
class Instance < T extends object = { [ key : string ] : any } > {
constructor ( module : Module , importObject? : object ) ;
/ * * A n o b j e c t c o n t a i n i n g a s i t s m e m b e r s a l l t h e f u n c t i o n s e x p o r t e d f r o m t h e
* WebAssembly module instance , to allow them to be accessed and used by
* JavaScript . * /
readonly exports : T ;
}
interface MemoryDescriptor {
initial : number ;
maximum? : number ;
}
class Memory {
constructor ( descriptor : MemoryDescriptor ) ;
/** An accessor property that returns the buffer contained in the memory. */
readonly buffer : ArrayBuffer ;
/ * * I n c r e a s e s t h e s i z e o f t h e m e m o r y i n s t a n c e b y a s p e c i f i e d n u m b e r o f
* WebAssembly pages ( each one is 64 KB in size ) . * /
grow ( delta : number ) : number ;
}
type TableKind = "anyfunc" ;
interface TableDescriptor {
element : TableKind ;
initial : number ;
maximum? : number ;
}
class Table {
constructor ( descriptor : TableDescriptor ) ;
/** Returns the length of the table, i.e. the number of elements. */
readonly length : number ;
/** Accessor function — gets the element stored at a given index. */
get ( index : number ) : ( . . . args : any [ ] ) = > any ;
/ * * I n c r e a s e s t h e s i z e o f t h e T a b l e i n s t a n c e b y a s p e c i f i e d n u m b e r o f
* elements . * /
grow ( delta : number ) : number ;
/** Sets an element stored at a given index to a given value. */
set ( index : number , value : ( . . . args : any [ ] ) = > any ) : void ;
}
type ValueType = "i32" | "i64" | "f32" | "f64" ;
interface GlobalDescriptor {
value : ValueType ;
mutable? : boolean ;
}
/ * * R e p r e s e n t s a g l o b a l v a r i a b l e i n s t a n c e , a c c e s s i b l e f r o m b o t h J a v a S c r i p t a n d
* importable / exportable across one or more ` WebAssembly.Module ` instances .
* This allows dynamic linking of multiple modules . * /
class Global {
constructor ( descriptor : GlobalDescriptor , value? : any ) ;
/ * * O l d - s t y l e m e t h o d t h a t r e t u r n s t h e v a l u e c o n t a i n e d i n s i d e t h e g l o b a l
* variable . * /
valueOf ( ) : any ;
/ * * T h e v a l u e c o n t a i n e d i n s i d e t h e g l o b a l v a r i a b l e — t h i s c a n b e u s e d t o
* directly set and get the global ' s value . * /
value : any ;
}
/** Indicates an error during WebAssembly decoding or validation */
class CompileError extends Error {
constructor ( message : string , fileName? : string , lineNumber? : string ) ;
}
/ * * I n d i c a t e s a n e r r o r d u r i n g m o d u l e i n s t a n t i a t i o n ( b e s i d e s t r a p s f r o m t h e
* start function ) . * /
class LinkError extends Error {
constructor ( message : string , fileName? : string , lineNumber? : string ) ;
}
/** Is thrown whenever WebAssembly specifies a trap. */
class RuntimeError extends Error {
constructor ( message : string , fileName? : string , lineNumber? : string ) ;
}
}
2020-01-29 12:54:23 -05:00
declare const fetch : typeof __fetch . fetch ;
2020-04-07 11:12:31 -04:00
/** Sets a timer which executes a function once after the timer expires. */
declare function setTimeout (
cb : ( . . . args : unknown [ ] ) = > void ,
delay? : number ,
. . . args : unknown [ ]
) : number ;
/** Repeatedly calls a function , with a fixed time delay between each call. */
declare function setInterval (
cb : ( . . . args : unknown [ ] ) = > void ,
delay? : number ,
. . . args : unknown [ ]
) : number ;
declare function clearTimeout ( id? : number ) : void ;
declare function clearInterval ( id? : number ) : void ;
declare function queueMicrotask ( func : Function ) : void ;
2020-01-29 12:54:23 -05:00
2020-04-08 13:21:04 -04:00
declare const console : Console ;
2020-01-24 14:15:01 -05:00
declare const File : __domTypes.DomFileConstructor ;
declare const CustomEventInit : typeof __customEvent . CustomEventInit ;
declare const CustomEvent : typeof __customEvent . CustomEvent ;
declare const EventInit : typeof __event . EventInit ;
declare const Event : typeof __event . Event ;
2020-03-05 08:36:13 -05:00
declare const EventListener : __domTypes.EventListener ;
2020-01-24 14:15:01 -05:00
declare const EventTarget : typeof __eventTarget . EventTarget ;
declare const Headers : __domTypes.HeadersConstructor ;
2020-01-29 12:54:23 -05:00
declare const location : __domTypes.Location ;
2020-01-24 14:15:01 -05:00
declare const FormData : __domTypes.FormDataConstructor ;
2020-04-03 14:55:23 -04:00
declare const ReadableStream : __domTypes.ReadableStreamConstructor ;
2020-01-24 14:15:01 -05:00
declare const Request : __domTypes.RequestConstructor ;
declare const Response : typeof __fetch . Response ;
2020-01-29 12:54:23 -05:00
2020-04-08 13:21:04 -04:00
declare function addEventListener (
2020-01-24 14:15:01 -05:00
type : string ,
2020-03-05 08:36:13 -05:00
callback : __domTypes.EventListenerOrEventListenerObject | null ,
2020-01-24 14:15:01 -05:00
options? : boolean | __domTypes . AddEventListenerOptions | undefined
2020-04-08 13:21:04 -04:00
) : void ;
declare function dispatchEvent ( event : __domTypes.Event ) : boolean ;
declare function removeEventListener (
2020-01-24 14:15:01 -05:00
type : string ,
2020-03-05 08:36:13 -05:00
callback : __domTypes.EventListenerOrEventListenerObject | null ,
2020-01-24 14:15:01 -05:00
options? : boolean | __domTypes . EventListenerOptions | undefined
2020-04-08 13:21:04 -04:00
) : void ;
2020-01-24 14:15:01 -05:00
declare type Body = __domTypes . Body ;
declare type File = __domTypes . DomFile ;
declare type CustomEventInit = __domTypes . CustomEventInit ;
declare type CustomEvent = __domTypes . CustomEvent ;
declare type EventInit = __domTypes . EventInit ;
declare type Event = __domTypes . Event ;
declare type EventListener = __domTypes . EventListener ;
declare type EventTarget = __domTypes . EventTarget ;
declare type Headers = __domTypes . Headers ;
declare type FormData = __domTypes . FormData ;
2020-04-03 14:55:23 -04:00
declare type ReadableStream < R = any > = __domTypes . ReadableStream < R > ;
2020-01-24 14:15:01 -05:00
declare type Request = __domTypes . Request ;
declare type Response = __domTypes . Response ;
declare interface ImportMeta {
url : string ;
main : boolean ;
}
declare namespace __domTypes {
export type HeadersInit =
| Headers
| Array < [ string , string ] >
| Record < string , string > ;
type BodyInit =
| Blob
| BufferSource
| FormData
| URLSearchParams
| ReadableStream
| string ;
export type RequestInfo = Request | string ;
type ReferrerPolicy =
| ""
| "no-referrer"
| "no-referrer-when-downgrade"
| "origin-only"
| "origin-when-cross-origin"
| "unsafe-url" ;
export type FormDataEntryValue = DomFile | string ;
export interface DomIterable < K , V > {
keys ( ) : IterableIterator < K > ;
values ( ) : IterableIterator < V > ;
entries ( ) : IterableIterator < [ K , V ] > ;
[ Symbol . iterator ] ( ) : IterableIterator < [ K , V ] > ;
forEach (
callback : ( value : V , key : K , parent : this ) = > void ,
thisArg? : any
) : void ;
}
interface AbortSignalEventMap {
abort : ProgressEvent ;
}
export enum NodeType {
ELEMENT_NODE = 1 ,
TEXT_NODE = 3 ,
2020-03-28 13:03:49 -04:00
DOCUMENT_FRAGMENT_NODE = 11 ,
2020-01-24 14:15:01 -05:00
}
2020-03-05 08:36:13 -05:00
export interface EventListener {
( evt : Event ) : void | Promise < void > ;
}
export interface EventListenerObject {
handleEvent ( evt : Event ) : void | Promise < void > ;
}
export type EventListenerOrEventListenerObject =
| EventListener
| EventListenerObject ;
export interface EventTargetListener {
callback : EventListenerOrEventListenerObject ;
options : AddEventListenerOptions ;
}
2020-03-28 13:03:49 -04:00
export const eventTargetHost : unique symbol ;
export const eventTargetListeners : unique symbol ;
export const eventTargetMode : unique symbol ;
export const eventTargetNodeType : unique symbol ;
2020-01-24 14:15:01 -05:00
export interface EventTarget {
addEventListener (
type : string ,
2020-03-05 08:36:13 -05:00
callback : EventListenerOrEventListenerObject | null ,
2020-01-24 14:15:01 -05:00
options? : boolean | AddEventListenerOptions
) : void ;
dispatchEvent ( event : Event ) : boolean ;
removeEventListener (
type : string ,
2020-03-05 08:36:13 -05:00
callback? : EventListenerOrEventListenerObject | null ,
2020-01-24 14:15:01 -05:00
options? : EventListenerOptions | boolean
) : void ;
}
export interface ProgressEventInit extends EventInit {
lengthComputable? : boolean ;
loaded? : number ;
total? : number ;
}
export interface EventInit {
bubbles? : boolean ;
cancelable? : boolean ;
composed? : boolean ;
}
export interface CustomEventInit extends EventInit {
detail? : any ;
}
export enum EventPhase {
NONE = 0 ,
CAPTURING_PHASE = 1 ,
AT_TARGET = 2 ,
2020-03-28 13:03:49 -04:00
BUBBLING_PHASE = 3 ,
2020-01-24 14:15:01 -05:00
}
export interface EventPath {
item : EventTarget ;
itemInShadowTree : boolean ;
relatedTarget : EventTarget | null ;
rootOfClosedTree : boolean ;
slotInClosedTree : boolean ;
target : EventTarget | null ;
touchTargetList : EventTarget [ ] ;
}
export interface Event {
readonly type : string ;
target : EventTarget | null ;
currentTarget : EventTarget | null ;
composedPath ( ) : EventPath [ ] ;
eventPhase : number ;
stopPropagation ( ) : void ;
stopImmediatePropagation ( ) : void ;
readonly bubbles : boolean ;
readonly cancelable : boolean ;
preventDefault ( ) : void ;
readonly defaultPrevented : boolean ;
readonly composed : boolean ;
isTrusted : boolean ;
readonly timeStamp : Date ;
dispatched : boolean ;
readonly initialized : boolean ;
inPassiveListener : boolean ;
cancelBubble : boolean ;
cancelBubbleImmediately : boolean ;
path : EventPath [ ] ;
relatedTarget : EventTarget | null ;
}
export interface CustomEvent extends Event {
readonly detail : any ;
initCustomEvent (
type : string ,
bubbles? : boolean ,
cancelable? : boolean ,
detail? : any | null
) : void ;
}
export interface DomFile extends Blob {
readonly lastModified : number ;
readonly name : string ;
}
export interface DomFileConstructor {
new (
bits : BlobPart [ ] ,
filename : string ,
options? : FilePropertyBag
) : DomFile ;
prototype : DomFile ;
}
export interface FilePropertyBag extends BlobPropertyBag {
lastModified? : number ;
}
interface ProgressEvent extends Event {
readonly lengthComputable : boolean ;
readonly loaded : number ;
readonly total : number ;
}
export interface EventListenerOptions {
2020-03-10 12:08:58 -04:00
capture? : boolean ;
2020-01-24 14:15:01 -05:00
}
export interface AddEventListenerOptions extends EventListenerOptions {
2020-03-10 12:08:58 -04:00
once? : boolean ;
passive? : boolean ;
2020-01-24 14:15:01 -05:00
}
interface AbortSignal extends EventTarget {
readonly aborted : boolean ;
onabort : ( ( this : AbortSignal , ev : ProgressEvent ) = > any ) | null ;
addEventListener < K extends keyof AbortSignalEventMap > (
type : K ,
listener : ( this : AbortSignal , ev : AbortSignalEventMap [ K ] ) = > any ,
options? : boolean | AddEventListenerOptions
) : void ;
addEventListener (
type : string ,
listener : EventListener ,
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 : EventListener ,
options? : boolean | EventListenerOptions
) : void ;
}
2020-03-28 13:03:49 -04:00
export interface ReadableStreamReadDoneResult < T > {
done : true ;
value? : T ;
}
export interface ReadableStreamReadValueResult < T > {
done : false ;
value : T ;
}
export type ReadableStreamReadResult < T > =
| ReadableStreamReadValueResult < T >
| ReadableStreamReadDoneResult < T > ;
export interface ReadableStreamDefaultReader < R = any > {
readonly closed : Promise < void > ;
cancel ( reason? : any ) : Promise < void > ;
read ( ) : Promise < ReadableStreamReadResult < R > > ;
releaseLock ( ) : void ;
}
export interface PipeOptions {
preventAbort? : boolean ;
preventCancel? : boolean ;
preventClose? : boolean ;
signal? : AbortSignal ;
}
2020-04-03 14:55:23 -04:00
export interface UnderlyingSource < R = any > {
cancel? : ReadableStreamErrorCallback ;
pull? : ReadableStreamDefaultControllerCallback < R > ;
start? : ReadableStreamDefaultControllerCallback < R > ;
type ? : undefined ;
}
export interface ReadableStreamErrorCallback {
( reason : any ) : void | PromiseLike < void > ;
}
export interface ReadableStreamDefaultControllerCallback < R > {
( controller : ReadableStreamDefaultController < R > ) : void | PromiseLike < void > ;
}
export interface ReadableStreamDefaultController < R > {
readonly desiredSize : number ;
enqueue ( chunk? : R ) : void ;
close ( ) : void ;
error ( e? : any ) : void ;
}
2020-03-28 13:03:49 -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 . * /
export interface ReadableStream < R = any > {
2020-01-24 14:15:01 -05:00
readonly locked : boolean ;
2020-03-28 13:03:49 -04:00
cancel ( reason? : any ) : Promise < void > ;
getReader ( options : { mode : "byob" } ) : ReadableStreamBYOBReader ;
getReader ( ) : ReadableStreamDefaultReader < R > ;
/ * d i s a b l e d f o r n o w
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 > ] ;
}
2020-04-03 14:55:23 -04:00
export interface ReadableStreamConstructor < R = any > {
new ( src? : UnderlyingSource < R > ) : ReadableStream < R > ;
prototype : ReadableStream < R > ;
}
2020-03-28 13:03:49 -04:00
export interface ReadableStreamReader < R = any > {
cancel ( reason : any ) : Promise < void > ;
read ( ) : Promise < ReadableStreamReadResult < R > > ;
releaseLock ( ) : void ;
2020-01-24 14:15:01 -05:00
}
2020-03-28 13:03:49 -04:00
export interface ReadableStreamBYOBReader {
readonly closed : Promise < void > ;
cancel ( reason? : any ) : Promise < void > ;
read < T extends ArrayBufferView > (
view : T
) : Promise < ReadableStreamReadResult < T > > ;
releaseLock ( ) : void ;
}
export interface WritableStream < W = any > {
readonly locked : boolean ;
abort ( reason? : any ) : Promise < void > ;
getWriter ( ) : WritableStreamDefaultWriter < W > ;
}
export interface WritableStreamDefaultWriter < W = any > {
readonly closed : Promise < void > ;
readonly desiredSize : number | null ;
readonly ready : Promise < void > ;
abort ( reason? : any ) : Promise < void > ;
close ( ) : Promise < void > ;
2020-01-24 14:15:01 -05:00
releaseLock ( ) : void ;
2020-03-28 13:03:49 -04:00
write ( chunk : W ) : Promise < void > ;
2020-01-24 14:15:01 -05:00
}
export interface FormData extends DomIterable < string , FormDataEntryValue > {
append ( name : string , value : string | Blob , fileName? : string ) : void ;
delete ( name : string ) : void ;
get ( name : string ) : FormDataEntryValue | null ;
getAll ( name : string ) : FormDataEntryValue [ ] ;
has ( name : string ) : boolean ;
set ( name : string , value : string | Blob , fileName? : string ) : void ;
}
export interface FormDataConstructor {
new ( ) : FormData ;
prototype : FormData ;
}
export interface Body {
/** A simple getter used to expose a `ReadableStream` of the body contents. */
2020-03-28 13:03:49 -04:00
readonly body : ReadableStream < Uint8Array > | null ;
2020-01-24 14:15:01 -05:00
/ * * S t o r e s a ` B o o l e a n ` t h a t d e c l a r e s w h e t h e r t h e b o d y h a s b e e n u s e d i n a
* response yet .
* /
readonly bodyUsed : boolean ;
/ * * T a k e s a ` R e s p o n s e ` s t r e a m a n d r e a d s i t t o c o m p l e t i o n . I t r e t u r n s a p r o m i s e
* that resolves with an ` ArrayBuffer ` .
* /
arrayBuffer ( ) : Promise < ArrayBuffer > ;
/ * * T a k e s a ` R e s p o n s e ` s t r e a m a n d r e a d s i t t o c o m p l e t i o n . I t r e t u r n s a p r o m i s e
* that resolves with a ` Blob ` .
* /
blob ( ) : Promise < Blob > ;
/ * * T a k e s a ` R e s p o n s e ` s t r e a m a n d r e a d s i t t o c o m p l e t i o n . I t r e t u r n s a p r o m i s e
* that resolves with a ` FormData ` object .
* /
formData ( ) : Promise < FormData > ;
/ * * T a k e s a ` R e s p o n s e ` s t r e a m a n d r e a d s i t t o c o m p l e t i o n . I t r e t u r n s a p r o m i s e
* that resolves with the result of parsing the body text as JSON .
* /
json ( ) : Promise < any > ;
/ * * T a k e s a ` R e s p o n s e ` s t r e a m a n d r e a d s i t t o c o m p l e t i o n . I t r e t u r n s a p r o m i s e
* that resolves with a ` USVString ` ( text ) .
* /
text ( ) : Promise < string > ;
}
export interface Headers extends DomIterable < string , string > {
/ * * A p p e n d s a n e w v a l u e o n t o a n e x i s t i n g h e a d e r i n s i d e a ` H e a d e r s ` o b j e c t , o r
* adds the header if it does not already exist .
* /
append ( name : string , value : string ) : void ;
/** Deletes a header from a `Headers` object. */
delete ( name : string ) : 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 / v a l u e p a i r s
* contained in this Headers object . The both the key and value of each pairs
* are ByteString objects .
* /
entries ( ) : IterableIterator < [ string , string ] > ;
/ * * R e t u r n s a ` B y t e S t r i n g ` s e q u e n c e o f a l l t h e v a l u e s o f a h e a d e r w i t h i n a
* ` Headers ` object with a given name .
* /
get ( name : string ) : string | null ;
/ * * R e t u r n s a b o o l e a n s t a t i n g w h e t h e r a ` H e a d e r s ` o b j e c t c o n t a i n s a c e r t a i n
* header .
* /
has ( name : string ) : boolean ;
/ * * 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 i n
* this Headers object . The keys are ByteString objects .
* /
keys ( ) : IterableIterator < string > ;
/ * * S e t s a n e w v a l u e f o r a n e x i s t i n g h e a d e r i n s i d e a H e a d e r s o b j e c t , o r a d d s
* the header if it does not already exist .
* /
set ( name : string , value : string ) : 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 v a l u e s c o n t a i n e d i n
* this Headers object . The values are ByteString objects .
* /
values ( ) : IterableIterator < string > ;
forEach (
callbackfn : ( value : string , key : string , parent : this ) = > void ,
thisArg? : any
) : void ;
/ * * T h e S y m b o l . i t e r a t o r w e l l - k n o w n s y m b o l s p e c i f i e s t h e d e f a u l t
* iterator for this Headers object
* /
[ Symbol . iterator ] ( ) : IterableIterator < [ string , string ] > ;
}
export interface HeadersConstructor {
new ( init? : HeadersInit ) : Headers ;
prototype : Headers ;
}
type RequestCache =
| "default"
| "no-store"
| "reload"
| "no-cache"
| "force-cache"
| "only-if-cached" ;
type RequestCredentials = "omit" | "same-origin" | "include" ;
type RequestDestination =
| ""
| "audio"
| "audioworklet"
| "document"
| "embed"
| "font"
| "image"
| "manifest"
| "object"
| "paintworklet"
| "report"
| "script"
| "sharedworker"
| "style"
| "track"
| "video"
| "worker"
| "xslt" ;
type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors" ;
type RequestRedirect = "follow" | "error" | "manual" ;
type ResponseType =
| "basic"
| "cors"
| "default"
| "error"
| "opaque"
| "opaqueredirect" ;
export interface RequestInit {
body? : BodyInit | null ;
cache? : RequestCache ;
credentials? : RequestCredentials ;
headers? : HeadersInit ;
integrity? : string ;
keepalive? : boolean ;
method? : string ;
mode? : RequestMode ;
redirect? : RequestRedirect ;
referrer? : string ;
referrerPolicy? : ReferrerPolicy ;
signal? : AbortSignal | null ;
window ? : any ;
}
export interface ResponseInit {
headers? : HeadersInit ;
status? : number ;
statusText? : string ;
}
export interface RequestConstructor {
new ( input : RequestInfo , init? : RequestInit ) : Request ;
prototype : Request ;
}
export interface Request extends Body {
/ * * R e t u r n s t h e c a c h e m o d e a s s o c i a t e d w i t h r e q u e s t , w h i c h i s a s t r i n g
* indicating how the the request will interact with the browser ' s cache when
* fetching .
* /
readonly cache? : RequestCache ;
/ * * R e t u r n s t h e c r e d e n t i a l s m o d e a s s o c i a t e d w i t h r e q u e s t , w h i c h i s a s t r i n g
* indicating whether credentials will be sent with the request always , never ,
* or only when sent to a same - origin URL .
* /
readonly credentials? : RequestCredentials ;
/ * * R e t u r n s t h e k i n d o f r e s o u r c e r e q u e s t e d b y r e q u e s t , ( e . g . , ` d o c u m e n t ` o r
* ` script ` ) .
* /
readonly destination? : RequestDestination ;
/ * * R e t u r n s a H e a d e r s o b j e c t c o n s i s t i n g o f t h e h e a d e r s a s s o c i a t e d w i t h
* request .
*
* Note that headers added in the network layer by the user agent
* will not be accounted for in this object , ( e . g . , the ` Host ` header ) .
* /
readonly headers : Headers ;
/ * * R e t u r n s r e q u e s t ' s s u b r e s o u r c e i n t e g r i t y m e t a d a t a , w h i c h i s a c r y p t o g r a p h i c
* hash of the resource being fetched . Its value consists of multiple hashes
* separated by whitespace . [ SRI ]
* /
readonly integrity? : string ;
/ * * R e t u r n s a b o o l e a n i n d i c a t i n g w h e t h e r o r n o t r e q u e s t i s f o r a h i s t o r y
* navigation ( a . k . a . back - forward navigation ) .
* /
readonly isHistoryNavigation? : boolean ;
/ * * R e t u r n s a b o o l e a n i n d i c a t i n g w h e t h e r o r n o t r e q u e s t i s f o r a r e l o a d
* navigation .
* /
readonly isReloadNavigation? : boolean ;
/ * * R e t u r n s a b o o l e a n i n d i c a t i n g w h e t h e r o r n o t r e q u e s t c a n o u t l i v e t h e g l o b a l
* in which it was created .
* /
readonly keepalive? : boolean ;
/** Returns request's HTTP method, which is `GET` by default. */
readonly method : string ;
/ * * R e t u r n s t h e m o d e a s s o c i a t e d w i t h r e q u e s t , w h i c h i s a s t r i n g i n d i c a t i n g
* whether the request will use CORS , or will be restricted to same - origin
* URLs .
* /
readonly mode? : RequestMode ;
/ * * R e t u r n s t h e r e d i r e c t m o d e a s s o c i a t e d w i t h r e q u e s t , w h i c h i s a s t r i n g
* indicating how redirects for the request will be handled during fetching .
*
* A request will follow redirects by default .
* /
readonly redirect? : RequestRedirect ;
/ * * R e t u r n s t h e r e f e r r e r o f r e q u e s t . I t s v a l u e c a n b e a s a m e - o r i g i n U R L i f
* explicitly set in init , the empty string to indicate no referrer , and
* ` about:client ` when defaulting to the global ' s default .
*
* This is used during fetching to determine the value of the ` Referer `
* header of the request being made .
* /
readonly referrer? : string ;
/ * * R e t u r n s t h e r e f e r r e r p o l i c y a s s o c i a t e d w i t h r e q u e s t . T h i s i s u s e d d u r i n g
* fetching to compute the value of the request ' s referrer .
* /
readonly referrerPolicy? : ReferrerPolicy ;
/ * * R e t u r n s t h e s i g n a l a s s o c i a t e d w i t h r e q u e s t , w h i c h i s a n A b o r t S i g n a l o b j e c t
* indicating whether or not request has been aborted , and its abort event
* handler .
* /
readonly signal? : AbortSignal ;
/** Returns the URL of request as a string. */
readonly url : string ;
clone ( ) : Request ;
}
export interface Response extends Body {
/** Contains the `Headers` object associated with the response. */
readonly headers : Headers ;
/ * * C o n t a i n s a b o o l e a n s t a t i n g w h e t h e r t h e r e s p o n s e w a s s u c c e s s f u l ( s t a t u s i n
* the range 200 - 299 ) or not .
* /
readonly ok : boolean ;
/ * * I n d i c a t e s w h e t h e r o r n o t t h e r e s p o n s e i s t h e r e s u l t o f a r e d i r e c t ; t h a t
* is , its URL list has more than one entry .
* /
readonly redirected : boolean ;
/** Contains the status code of the response (e.g., `200` for a success). */
readonly status : number ;
/ * * C o n t a i n s t h e s t a t u s m e s s a g e c o r r e s p o n d i n g t o t h e s t a t u s c o d e ( e . g . , ` O K `
* for ` 200 ` ) .
* /
readonly statusText : string ;
readonly trailer : Promise < Headers > ;
/** Contains the type of the response (e.g., `basic`, `cors`). */
readonly type : ResponseType ;
/** Contains the URL of the response. */
readonly url : string ;
/** Creates a clone of a `Response` object. */
clone ( ) : Response ;
}
2020-03-28 13:03:49 -04:00
export interface DOMStringList {
/** Returns the number of strings in strings. */
readonly length : number ;
/** Returns true if strings contains string, and false otherwise. */
contains ( string : string ) : boolean ;
/** Returns the string with index index from strings. */
item ( index : number ) : string | null ;
[ index : number ] : string ;
}
/ * * T h e l o c a t i o n ( U R L ) o f t h e o b j e c t i t i s l i n k e d t o . C h a n g e s d o n e o n i t a r e
* reflected on the object it relates to . Both the Document and Window
* interface have such a linked Location , accessible via Document . location and
* Window . location respectively . * /
2020-01-24 14:15:01 -05:00
export interface Location {
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s a D O M S t r i n g L i s t o b j e c t l i s t i n g t h e o r i g i n s o f t h e a n c e s t o r
* browsing contexts , from the parent browsing context to the top - level
* browsing context . * /
readonly ancestorOrigins : DOMStringList ;
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s f r a g m e n t ( i n c l u d e s l e a d i n g " # " i f
2020-01-24 14:15:01 -05:00
* non - empty ) .
2020-03-28 13:03:49 -04:00
*
2020-01-24 14:15:01 -05:00
* Can be set , to navigate to the same URL with a changed fragment ( ignores
2020-03-28 13:03:49 -04:00
* leading "#" ) . * /
2020-01-24 14:15:01 -05:00
hash : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s h o s t a n d p o r t ( i f d i f f e r e n t f r o m t h e
* default port for the scheme ) .
*
* Can be set , to navigate to the same URL with a changed host and port . * /
2020-01-24 14:15:01 -05:00
host : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s h o s t .
*
* Can be set , to navigate to the same URL with a changed host . * /
2020-01-24 14:15:01 -05:00
hostname : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L .
*
* Can be set , to navigate to the given URL . * /
2020-01-24 14:15:01 -05:00
href : string ;
2020-03-28 13:03:49 -04:00
toString ( ) : string ;
2020-01-24 14:15:01 -05:00
/** Returns the Location object's URL's origin. */
readonly origin : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s p a t h .
*
* Can be set , to navigate to the same URL with a changed path . * /
2020-01-24 14:15:01 -05:00
pathname : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s p o r t .
*
* Can be set , to navigate to the same URL with a changed port . * /
2020-01-24 14:15:01 -05:00
port : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s s c h e m e .
*
* Can be set , to navigate to the same URL with a changed scheme . * /
2020-01-24 14:15:01 -05:00
protocol : string ;
2020-03-28 13:03:49 -04:00
/ * * R e t u r n s t h e L o c a t i o n o b j e c t ' s U R L ' s q u e r y ( i n c l u d e s l e a d i n g " ? " i f
* non - empty ) .
*
* Can be set , to navigate to the same URL with a changed query ( ignores
* leading "?" ) . * /
2020-01-24 14:15:01 -05:00
search : string ;
/ * *
* Navigates to the given URL .
* /
assign ( url : string ) : void ;
/ * *
* Reloads the current page .
* /
reload ( ) : void ;
2020-03-28 13:03:49 -04:00
/ * * R e m o v e s t h e c u r r e n t p a g e f r o m t h e s e s s i o n h i s t o r y a n d n a v i g a t e s t o t h e
* given URL . * /
2020-01-24 14:15:01 -05:00
replace ( url : string ) : void ;
}
}
2020-04-08 13:21:04 -04:00
type BufferSource = ArrayBufferView | ArrayBuffer ;
type BlobPart = BufferSource | Blob | string ;
interface BlobPropertyBag {
type ? : string ;
ending ? : "transparent" | "native" ;
2020-01-24 14:15:01 -05:00
}
2020-04-08 13:21:04 -04:00
/** 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. */
interface Blob {
readonly size : number ;
readonly type : string ;
arrayBuffer ( ) : Promise < ArrayBuffer > ;
slice ( start? : number , end? : number , contentType? : string ) : Blob ;
stream ( ) : ReadableStream ;
text ( ) : Promise < string > ;
}
declare const Blob : {
prototype : Blob ;
new ( blobParts? : BlobPart [ ] , options? : BlobPropertyBag ) : Blob ;
} ;
declare const isConsoleInstance : unique symbol ;
declare class Console {
indentLevel : number ;
[ isConsoleInstance ] : boolean ;
/** Writes the arguments to stdout */
log : ( . . . args : unknown [ ] ) = > void ;
/** Writes the arguments to stdout */
debug : ( . . . args : unknown [ ] ) = > void ;
/** Writes the arguments to stdout */
info : ( . . . args : unknown [ ] ) = > void ;
/** Writes the properties of the supplied `obj` to stdout */
dir : (
obj : unknown ,
options? : Partial < {
showHidden : boolean ;
depth : number ;
colors : boolean ;
indentLevel : number ;
} >
) = > void ;
/ * * F r o m M D N :
* Displays an interactive tree of the descendant elements of
* the specified XML / HTML element . If it is not possible to display
* as an element the JavaScript Object view is shown instead .
* The output is presented as a hierarchical listing of expandable
* nodes that let you see the contents of child nodes .
*
* Since we write to stdout , we can ' t display anything interactive
* we just fall back to ` console.dir ` .
2020-01-24 14:15:01 -05:00
* /
2020-04-08 13:21:04 -04:00
dirxml : (
obj : unknown ,
options? : Partial < {
showHidden : boolean ;
depth : number ;
colors : boolean ;
indentLevel : number ;
} >
) = > void ;
/** Writes the arguments to stdout */
warn : ( . . . args : unknown [ ] ) = > void ;
/** Writes the arguments to stdout */
error : ( . . . args : unknown [ ] ) = > void ;
/ * * W r i t e s a n e r r o r m e s s a g e t o s t d o u t i f t h e a s s e r t i o n i s ` f a l s e ` . I f t h e
* assertion is ` true ` , nothing happens .
*
* ref : https : //console.spec.whatwg.org/#assert
2020-01-24 14:15:01 -05:00
* /
2020-04-08 13:21:04 -04:00
assert : ( condition? : boolean , . . . args : unknown [ ] ) = > void ;
count : ( label? : string ) = > void ;
countReset : ( label? : string ) = > void ;
table : ( data : unknown , properties? : string [ ] | undefined ) = > void ;
time : ( label? : string ) = > void ;
timeLog : ( label? : string , . . . args : unknown [ ] ) = > void ;
timeEnd : ( label? : string ) = > void ;
group : ( . . . label : unknown [ ] ) = > void ;
groupCollapsed : ( . . . label : unknown [ ] ) = > void ;
groupEnd : ( ) = > void ;
clear : ( ) = > void ;
trace : ( . . . args : unknown [ ] ) = > void ;
static [ Symbol . hasInstance ] ( instance : Console ) : boolean ;
2020-01-24 14:15:01 -05:00
}
declare namespace __event {
export const eventAttributes : WeakMap < object , any > ;
export class EventInit implements __domTypes . EventInit {
bubbles : boolean ;
cancelable : boolean ;
composed : boolean ;
constructor ( {
bubbles ,
cancelable ,
2020-03-28 13:03:49 -04:00
composed ,
2020-01-24 14:15:01 -05:00
} ? : {
bubbles? : boolean | undefined ;
cancelable? : boolean | undefined ;
composed? : boolean | undefined ;
} ) ;
}
export class Event implements __domTypes . Event {
isTrusted : boolean ;
private _canceledFlag ;
private _dispatchedFlag ;
private _initializedFlag ;
private _inPassiveListenerFlag ;
private _stopImmediatePropagationFlag ;
private _stopPropagationFlag ;
private _path ;
constructor ( type : string , eventInitDict? : __domTypes.EventInit ) ;
readonly bubbles : boolean ;
cancelBubble : boolean ;
cancelBubbleImmediately : boolean ;
readonly cancelable : boolean ;
readonly composed : boolean ;
currentTarget : __domTypes.EventTarget ;
readonly defaultPrevented : boolean ;
dispatched : boolean ;
eventPhase : number ;
readonly initialized : boolean ;
inPassiveListener : boolean ;
path : __domTypes.EventPath [ ] ;
relatedTarget : __domTypes.EventTarget ;
target : __domTypes.EventTarget ;
readonly timeStamp : Date ;
readonly type : string ;
/ * * R e t u r n s t h e e v e n t ’ s p a t h ( o b j e c t s o n w h i c h l i s t e n e r s w i l l b e
* invoked ) . This does not include nodes in shadow trees if the
* shadow root was created with its ShadowRoot . mode closed .
*
* event . composedPath ( ) ;
* /
composedPath ( ) : __domTypes . EventPath [ ] ;
/ * * C a n c e l s t h e e v e n t ( i f i t i s c a n c e l a b l e ) .
* See https : //dom.spec.whatwg.org/#set-the-canceled-flag
*
* event . preventDefault ( ) ;
* /
preventDefault ( ) : void ;
/ * * S t o p s t h e p r o p a g a t i o n o f e v e n t s f u r t h e r a l o n g i n t h e D O M .
*
* event . stopPropagation ( ) ;
* /
stopPropagation ( ) : void ;
/ * * F o r t h i s p a r t i c u l a r e v e n t , n o o t h e r l i s t e n e r w i l l b e c a l l e d .
* Neither those attached on the same element , nor those attached
* on elements which will be traversed later ( in capture phase ,
* for instance ) .
*
* event . stopImmediatePropagation ( ) ;
* /
stopImmediatePropagation ( ) : void ;
}
}
declare namespace __customEvent {
export const customEventAttributes : WeakMap < object , any > ;
export class CustomEventInit extends __event . EventInit
implements __domTypes . CustomEventInit {
detail : any ;
constructor ( {
bubbles ,
cancelable ,
composed ,
2020-03-28 13:03:49 -04:00
detail ,
2020-01-24 14:15:01 -05:00
} : __domTypes . CustomEventInit ) ;
}
export class CustomEvent extends __event . Event
implements __domTypes . CustomEvent {
constructor ( type : string , customEventInitDict? : __domTypes.CustomEventInit ) ;
readonly detail : any ;
initCustomEvent (
type : string ,
bubbles? : boolean ,
cancelable? : boolean ,
detail? : any
) : void ;
readonly [ Symbol . toStringTag ] : string ;
}
}
declare namespace __eventTarget {
export class EventListenerOptions implements __domTypes . EventListenerOptions {
_capture : boolean ;
constructor ( { capture } ? : { capture? : boolean | undefined } ) ;
readonly capture : boolean ;
}
export class AddEventListenerOptions extends EventListenerOptions
implements __domTypes . AddEventListenerOptions {
_passive : boolean ;
_once : boolean ;
constructor ( {
capture ,
passive ,
2020-03-28 13:03:49 -04:00
once ,
2020-01-24 14:15:01 -05:00
} ? : {
capture? : boolean | undefined ;
passive? : boolean | undefined ;
once? : boolean | undefined ;
} ) ;
readonly passive : boolean ;
readonly once : boolean ;
}
export const eventTargetAssignedSlot : unique symbol ;
export const eventTargetHasActivationBehavior : unique symbol ;
export class EventTarget implements __domTypes . EventTarget {
[ __domTypes . eventTargetHost ] : __domTypes . EventTarget | null ;
[ __domTypes . eventTargetListeners ] : {
[ type in string ] : __domTypes . EventListener [ ] ;
} ;
[ __domTypes . eventTargetMode ] : string ;
[ __domTypes . eventTargetNodeType ] : __domTypes . NodeType ;
private [ eventTargetAssignedSlot ] ;
private [ eventTargetHasActivationBehavior ] ;
addEventListener (
type : string ,
2020-03-05 08:36:13 -05:00
callback : __domTypes.EventListenerOrEventListenerObject | null ,
2020-01-24 14:15:01 -05:00
options? : __domTypes.AddEventListenerOptions | boolean
) : void ;
removeEventListener (
type : string ,
2020-03-05 08:36:13 -05:00
callback : __domTypes.EventListenerOrEventListenerObject | null ,
2020-01-24 14:15:01 -05:00
options? : __domTypes.EventListenerOptions | boolean
) : void ;
dispatchEvent ( event : __domTypes.Event ) : boolean ;
readonly [ Symbol . toStringTag ] : string ;
}
}
declare namespace __fetch {
class Body
2020-03-28 13:03:49 -04:00
implements
__domTypes . Body ,
__domTypes . ReadableStream < Uint8Array > ,
2020-04-07 19:30:51 -04:00
Deno . ReadCloser {
2020-01-24 14:15:01 -05:00
readonly contentType : string ;
bodyUsed : boolean ;
readonly locked : boolean ;
2020-03-28 13:03:49 -04:00
readonly body : __domTypes.ReadableStream < Uint8Array > ;
2020-01-24 14:15:01 -05:00
constructor ( rid : number , contentType : string ) ;
arrayBuffer ( ) : Promise < ArrayBuffer > ;
2020-04-08 13:21:04 -04:00
blob ( ) : Promise < Blob > ;
2020-01-24 14:15:01 -05:00
formData ( ) : Promise < __domTypes.FormData > ;
json ( ) : Promise < any > ;
text ( ) : Promise < string > ;
read ( p : Uint8Array ) : Promise < number | Deno.EOF > ;
close ( ) : void ;
cancel ( ) : Promise < void > ;
2020-03-28 13:03:49 -04:00
getReader ( options : { mode : "byob" } ) : __domTypes . ReadableStreamBYOBReader ;
getReader ( ) : __domTypes . ReadableStreamDefaultReader < Uint8Array > ;
getReader ( ) : __domTypes . ReadableStreamBYOBReader ;
2020-01-24 14:15:01 -05:00
tee ( ) : [ __domTypes . ReadableStream , __domTypes . ReadableStream ] ;
[ Symbol . asyncIterator ] ( ) : AsyncIterableIterator < Uint8Array > ;
}
export class Response implements __domTypes . Response {
readonly url : string ;
readonly status : number ;
statusText : string ;
2020-02-03 09:54:47 -05:00
readonly type : __domTypes . ResponseType ;
2020-01-24 14:15:01 -05:00
readonly redirected : boolean ;
headers : __domTypes.Headers ;
readonly trailer : Promise < __domTypes.Headers > ;
bodyUsed : boolean ;
readonly body : Body ;
constructor (
url : string ,
status : number ,
2020-02-03 09:54:47 -05:00
statusText : string ,
2020-01-24 14:15:01 -05:00
headersList : Array < [ string , string ] > ,
rid : number ,
redirected_ : boolean ,
2020-02-03 09:54:47 -05:00
type_? : null | __domTypes . ResponseType ,
2020-01-24 14:15:01 -05:00
body_? : null | Body
) ;
arrayBuffer ( ) : Promise < ArrayBuffer > ;
2020-04-08 13:21:04 -04:00
blob ( ) : Promise < Blob > ;
2020-01-24 14:15:01 -05:00
formData ( ) : Promise < __domTypes.FormData > ;
json ( ) : Promise < any > ;
text ( ) : Promise < string > ;
readonly ok : boolean ;
clone ( ) : __domTypes . Response ;
2020-02-03 09:54:47 -05:00
redirect ( url : URL | string , status : number ) : __domTypes . Response ;
2020-01-24 14:15:01 -05:00
}
/** Fetch a resource from the network. */
export function fetch (
2020-04-07 17:11:38 -04:00
input : __domTypes.Request | URL | string ,
2020-01-24 14:15:01 -05:00
init? : __domTypes.RequestInit
) : Promise < Response > ;
}
2020-04-07 13:27:37 -04:00
declare function atob ( s : string ) : string ;
/** Creates a base-64 ASCII string from the input string. */
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. */
2020-04-08 13:21:04 -04:00
decode ( input? : BufferSource , options ? : { stream? : false } ) : string ;
2020-04-07 13:27:37 -04:00
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-01-24 14:15:01 -05:00
}
2020-04-07 17:11:38 -04:00
interface URLSearchParams {
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* let searchParams = new URLSearchParams ( ) ;
2020-04-07 17:11:38 -04:00
* searchParams . append ( 'name' , 'first' ) ;
* searchParams . append ( 'name' , 'second' ) ;
* /
append ( name : string , value : string ) : void ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* let searchParams = new URLSearchParams ( [ [ 'name' , 'value' ] ] ) ;
2020-04-07 17:11:38 -04:00
* searchParams . delete ( 'name' ) ;
* /
delete ( name : string ) : void ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
* searchParams . getAll ( 'name' ) ;
* /
getAll ( name : string ) : string [ ] ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
* searchParams . get ( 'name' ) ;
* /
get ( name : string ) : string | null ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
* searchParams . has ( 'name' ) ;
* /
has ( name : string ) : boolean ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
* searchParams . set ( 'name' , 'value' ) ;
* /
set ( name : string , value : string ) : void ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
* searchParams . sort ( ) ;
* /
sort ( ) : void ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* params . forEach ( ( value , key , parent ) = > {
2020-04-07 17:11:38 -04:00
* console . log ( value , key , parent ) ;
* } ) ;
*
* /
forEach (
callbackfn : ( value : string , key : string , parent : this ) = > void ,
thisArg? : any
) : void ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const key of params . keys ( ) ) {
2020-04-07 17:11:38 -04:00
* console . log ( key ) ;
* }
* /
keys ( ) : IterableIterator < string > ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const value of params . values ( ) ) {
2020-04-07 17:11:38 -04:00
* console . log ( value ) ;
* }
* /
values ( ) : IterableIterator < string > ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const [ key , value ] of params . entries ( ) ) {
2020-04-07 17:11:38 -04:00
* console . log ( key , value ) ;
* }
* /
entries ( ) : IterableIterator < [ string , string ] > ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
2020-04-08 10:32:08 -04:00
* const params = new URLSearchParams ( [ [ "a" , "b" ] , [ "c" , "d" ] ] ) ;
* for ( const [ key , value ] of params ) {
2020-04-07 17:11:38 -04:00
* console . log ( key , value ) ;
* }
* /
[ Symbol . iterator ] ( ) : IterableIterator < [ string , string ] > ;
2020-04-08 10:32:08 -04:00
2020-04-07 17:11:38 -04:00
/ * * 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 .
*
* searchParams . toString ( ) ;
* /
toString ( ) : string ;
2020-01-24 14:15:01 -05:00
}
2020-04-07 17:11:38 -04:00
declare const URLSearchParams : {
prototype : URLSearchParams ;
new (
init? : string [ ] [ ] | Record < string , string > | string | URLSearchParams
) : URLSearchParams ;
toString ( ) : string ;
} ;
/** The URL interface represents an object providing static methods used for creating object URLs. */
interface URL {
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 ;
2020-01-24 14:15:01 -05:00
}
2020-04-07 17:11:38 -04:00
declare const URL : {
prototype : URL ;
new ( url : string , base? : string | URL ) : URL ;
createObjectURL ( object : any ) : string ;
revokeObjectURL ( url : string ) : void ;
} ;
2020-04-07 15:03:14 -04:00
declare class Worker {
onerror ? : ( e : Event ) = > void ;
onmessage ? : ( data : any ) = > void ;
onmessageerror ? : ( ) = > void ;
constructor (
specifier : string ,
options ? : {
type ? : "classic" | "module" ;
name? : string ;
}
) ;
postMessage ( data : any ) : void ;
terminate ( ) : void ;
2020-01-24 14:15:01 -05:00
}
2020-04-07 13:27:37 -04:00
declare namespace performance {
/ * * R e t u r n s a c u r r e n t t i m e f r o m D e n o ' s s t a r t i n m i l l i s e c o n d s .
*
* Use the flag -- allow - hrtime return a precise value .
*
* const t = performance . now ( ) ;
* console . log ( ` ${ t } ms since start! ` ) ;
* /
export function now ( ) : number ;
2020-01-24 14:15:01 -05:00
}
/* eslint-enable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-interface, @typescript-eslint/no-explicit-any */