Skip to content

Commit

Permalink
better constant definitions for Websocket, EventSource, and FileReader (
Browse files Browse the repository at this point in the history
#1443)

Co-authored-by: saschanaz <saschanaz@users.noreply.github.com>
  • Loading branch information
k-yle and saschanaz committed Dec 7, 2022
1 parent e6ccc40 commit d056787
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 80 deletions.
40 changes: 20 additions & 20 deletions baselines/dom.generated.d.ts
Expand Up @@ -5275,9 +5275,9 @@ interface EventSource extends EventTarget {
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 CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
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;
Expand All @@ -5289,9 +5289,9 @@ interface EventSource extends EventTarget {
declare var EventSource: {
prototype: EventSource;
new(url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */
Expand Down Expand Up @@ -5386,9 +5386,9 @@ interface FileReader extends EventTarget {
readAsBinaryString(blob: Blob): void;
readAsDataURL(blob: Blob): void;
readAsText(blob: Blob, encoding?: string): void;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
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;
Expand All @@ -5398,9 +5398,9 @@ interface FileReader extends EventTarget {
declare var FileReader: {
prototype: FileReader;
new(): FileReader;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
};

interface FileSystem {
Expand Down Expand Up @@ -16857,10 +16857,10 @@ interface WebSocket extends EventTarget {
close(code?: number, reason?: string): void;
/** Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. */
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -16870,10 +16870,10 @@ interface WebSocket extends EventTarget {
declare var WebSocket: {
prototype: WebSocket;
new(url: string | URL, protocols?: string | string[]): WebSocket;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** Events that occur due to the user moving a mouse wheel or similar input device. */
Expand Down
40 changes: 20 additions & 20 deletions baselines/serviceworker.generated.d.ts
Expand Up @@ -1493,9 +1493,9 @@ interface EventSource extends EventTarget {
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 CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
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;
Expand All @@ -1507,9 +1507,9 @@ interface EventSource extends EventTarget {
declare var EventSource: {
prototype: EventSource;
new(url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */
Expand Down Expand Up @@ -1629,9 +1629,9 @@ interface FileReader extends EventTarget {
readAsBinaryString(blob: Blob): void;
readAsDataURL(blob: Blob): void;
readAsText(blob: Blob, encoding?: string): void;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
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;
Expand All @@ -1641,9 +1641,9 @@ interface FileReader extends EventTarget {
declare var FileReader: {
prototype: FileReader;
new(): FileReader;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
};

/** Available only in secure contexts. */
Expand Down Expand Up @@ -5330,10 +5330,10 @@ interface WebSocket extends EventTarget {
close(code?: number, reason?: string): void;
/** Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. */
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -5343,10 +5343,10 @@ interface WebSocket extends EventTarget {
declare var WebSocket: {
prototype: WebSocket;
new(url: string | URL, protocols?: string | string[]): WebSocket;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** This ServiceWorker API interface represents the scope of a service worker client that is a document in a browser context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources. */
Expand Down
40 changes: 20 additions & 20 deletions baselines/sharedworker.generated.d.ts
Expand Up @@ -1437,9 +1437,9 @@ interface EventSource extends EventTarget {
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 CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
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;
Expand All @@ -1451,9 +1451,9 @@ interface EventSource extends EventTarget {
declare var EventSource: {
prototype: EventSource;
new(url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */
Expand Down Expand Up @@ -1534,9 +1534,9 @@ interface FileReader extends EventTarget {
readAsBinaryString(blob: Blob): void;
readAsDataURL(blob: Blob): void;
readAsText(blob: Blob, encoding?: string): void;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
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;
Expand All @@ -1546,9 +1546,9 @@ interface FileReader extends EventTarget {
declare var FileReader: {
prototype: FileReader;
new(): FileReader;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
};

/** Allows to read File or Blob objects in a synchronous way. */
Expand Down Expand Up @@ -5194,10 +5194,10 @@ interface WebSocket extends EventTarget {
close(code?: number, reason?: string): void;
/** Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. */
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -5207,10 +5207,10 @@ interface WebSocket extends EventTarget {
declare var WebSocket: {
prototype: WebSocket;
new(url: string | URL, protocols?: string | string[]): WebSocket;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

interface WindowOrWorkerGlobalScope {
Expand Down
40 changes: 20 additions & 20 deletions baselines/webworker.generated.d.ts
Expand Up @@ -1558,9 +1558,9 @@ interface EventSource extends EventTarget {
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 CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
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;
Expand All @@ -1572,9 +1572,9 @@ interface EventSource extends EventTarget {
declare var EventSource: {
prototype: EventSource;
new(url: string | URL, eventSourceInitDict?: EventSourceInit): EventSource;
readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. */
Expand Down Expand Up @@ -1694,9 +1694,9 @@ interface FileReader extends EventTarget {
readAsBinaryString(blob: Blob): void;
readAsDataURL(blob: Blob): void;
readAsText(blob: Blob, encoding?: string): void;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
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;
Expand All @@ -1706,9 +1706,9 @@ interface FileReader extends EventTarget {
declare var FileReader: {
prototype: FileReader;
new(): FileReader;
readonly DONE: number;
readonly EMPTY: number;
readonly LOADING: number;
readonly DONE: 2;
readonly EMPTY: 0;
readonly LOADING: 1;
};

/** Allows to read File or Blob objects in a synchronous way. */
Expand Down Expand Up @@ -5484,10 +5484,10 @@ interface WebSocket extends EventTarget {
close(code?: number, reason?: string): void;
/** Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView. */
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -5497,10 +5497,10 @@ interface WebSocket extends EventTarget {
declare var WebSocket: {
prototype: WebSocket;
new(url: string | URL, protocols?: string | string[]): WebSocket;
readonly CLOSED: number;
readonly CLOSING: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSED: 3;
readonly CLOSING: 2;
readonly CONNECTING: 0;
readonly OPEN: 1;
};

/** This ServiceWorker API interface represents the scope of a service worker client that is a document in a browser context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources. */
Expand Down
44 changes: 44 additions & 0 deletions inputfiles/overridingTypes.jsonc
Expand Up @@ -1801,6 +1801,37 @@
"type": "MessageEvent"
}
]
},
"constants": {
"constant": {
"CONNECTING": {
"overrideType": "0"
},
"OPEN": {
"overrideType": "1"
},
"CLOSING": {
"overrideType": "2"
},
"CLOSED": {
"overrideType": "3"
}
}
}
},
"EventSource": {
"constants": {
"constant": {
"CONNECTING": {
"overrideType": "0"
},
"OPEN": {
"overrideType": "1"
},
"CLOSED": {
"overrideType": "2"
}
}
}
},
"HTMLTableRowElement": {
Expand Down Expand Up @@ -1880,6 +1911,19 @@
}
},
"FileReader": {
"constants": {
"constant": {
"EMPTY": {
"overrideType": "0"
},
"LOADING": {
"overrideType": "1"
},
"DONE": {
"overrideType": "2"
}
}
},
"events": {
"event": [
{
Expand Down

0 comments on commit d056787

Please sign in to comment.