summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/fetch/lib.deno_fetch.d.ts85
1 files changed, 85 insertions, 0 deletions
diff --git a/ext/fetch/lib.deno_fetch.d.ts b/ext/fetch/lib.deno_fetch.d.ts
index 472436371..40b41b430 100644
--- a/ext/fetch/lib.deno_fetch.d.ts
+++ b/ext/fetch/lib.deno_fetch.d.ts
@@ -405,3 +405,88 @@ declare function fetch(
input: URL | Request | string,
init?: RequestInit,
): Promise<Response>;
+
+/**
+ * @category Fetch API
+ */
+declare interface EventSourceInit {
+ withCredentials?: boolean;
+}
+
+/**
+ * @category Fetch API
+ */
+declare interface EventSourceEventMap {
+ "error": Event;
+ "message": MessageEvent;
+ "open": Event;
+}
+
+/**
+ * @category Fetch API
+ */
+declare interface EventSource extends EventTarget {
+ onerror: ((this: EventSource, ev: Event) => any) | null;
+ onmessage: ((this: EventSource, ev: MessageEvent) => any) | null;
+ onopen: ((this: EventSource, ev: Event) => any) | null;
+ /**
+ * Returns the state of this EventSource object's connection. It can have the values described below.
+ */
+ readonly readyState: number;
+ /**
+ * Returns the URL providing the event stream.
+ */
+ readonly url: string;
+ /**
+ * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
+ */
+ readonly withCredentials: boolean;
+ /**
+ * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
+ */
+ close(): void;
+ readonly CONNECTING: 0;
+ readonly OPEN: 1;
+ readonly CLOSED: 2;
+ addEventListener<K extends keyof EventSourceEventMap>(
+ type: K,
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
+ options?: boolean | AddEventListenerOptions,
+ ): void;
+ addEventListener(
+ type: string,
+ listener: (this: EventSource, event: MessageEvent) => any,
+ options?: boolean | AddEventListenerOptions,
+ ): void;
+ addEventListener(
+ type: string,
+ listener: EventListenerOrEventListenerObject,
+ options?: boolean | AddEventListenerOptions,
+ ): void;
+ removeEventListener<K extends keyof EventSourceEventMap>(
+ type: K,
+ listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,
+ options?: boolean | EventListenerOptions,
+ ): void;
+ removeEventListener(
+ type: string,
+ listener: (this: EventSource, event: MessageEvent) => any,
+ options?: boolean | EventListenerOptions,
+ ): void;
+ removeEventListener(
+ type: string,
+ listener: EventListenerOrEventListenerObject,
+ options?: boolean | EventListenerOptions,
+ ): void;
+}
+
+/**
+ * @category Fetch API
+ */
+declare var EventSource: {
+ prototype: EventSource;
+ new (url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
+ readonly CONNECTING: 0;
+ readonly OPEN: 1;
+ readonly CLOSED: 2;
+};