Skip to content

Add HTML webappapi types #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
691 changes: 247 additions & 444 deletions baselines/dom.generated.d.ts

Large diffs are not rendered by default.

51 changes: 32 additions & 19 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,12 +827,11 @@ interface ErrorEvent extends Event {
readonly filename: string;
readonly lineno: number;
readonly message: string;
initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void;
}

declare var ErrorEvent: {
prototype: ErrorEvent;
new(typeArg: string, eventInitDict?: ErrorEventInit): ErrorEvent;
new(type: string, eventInitDict?: ErrorEventInit): ErrorEvent;
};

interface Event {
Expand Down Expand Up @@ -2404,6 +2403,21 @@ interface WindowConsole {
readonly console: Console;
}

interface WindowOrWorkerGlobalScope {
readonly caches: CacheStorage;
readonly indexedDB: IDBFactory;
readonly origin: string;
readonly performance: Performance;
atob(data: string): string;
btoa(data: string): string;
clearInterval(handle?: number): void;
clearTimeout(handle?: number): void;
createImageBitmap(image: ImageBitmapSource): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number): Promise<ImageBitmap>;
setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
}

interface WorkerEventMap extends AbstractWorkerEventMap {
"message": MessageEvent;
}
Expand All @@ -2427,15 +2441,13 @@ interface WorkerGlobalScopeEventMap {
"error": ErrorEvent;
}

interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch {
interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, GlobalFetch, WindowOrWorkerGlobalScope {
readonly caches: CacheStorage;
readonly isSecureContext: boolean;
readonly location: WorkerLocation;
onerror: ((this: WorkerGlobalScope, ev: ErrorEvent) => any) | null;
readonly performance: Performance;
readonly self: WorkerGlobalScope;
createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
msWriteProfilerMark(profilerMarkName: string): void;
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
Expand Down Expand Up @@ -2479,13 +2491,7 @@ interface WorkerUtils extends WindowBase64 {
readonly indexedDB: IDBFactory;
readonly msIndexedDB: IDBFactory;
readonly navigator: WorkerNavigator;
clearImmediate(handle: number): void;
clearInterval(handle: number): void;
clearTimeout(handle: number): void;
importScripts(...urls: string[]): void;
setImmediate(handler: any, ...args: any[]): number;
setInterval(handler: any, timeout?: any, ...args: any[]): number;
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}

interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap {
Expand Down Expand Up @@ -2659,24 +2665,28 @@ declare var location: WorkerLocation;
declare var onerror: ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any) | null;
declare var performance: Performance;
declare var self: WorkerGlobalScope;
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function msWriteProfilerMark(profilerMarkName: string): void;
declare function dispatchEvent(evt: Event): boolean;
declare var indexedDB: IDBFactory;
declare var msIndexedDB: IDBFactory;
declare var navigator: WorkerNavigator;
declare function clearImmediate(handle: number): void;
declare function clearInterval(handle: number): void;
declare function clearTimeout(handle: number): void;
declare function importScripts(...urls: string[]): void;
declare function setImmediate(handler: any, ...args: any[]): number;
declare function setInterval(handler: any, timeout?: any, ...args: any[]): number;
declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number;
declare function atob(encodedString: string): string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can be removed now

declare function btoa(rawString: string): string;
declare var console: Console;
declare function fetch(input?: Request | string, init?: RequestInit): Promise<Response>;
declare var caches: CacheStorage;
declare var indexedDB: IDBFactory;
declare var origin: string;
declare var performance: Performance;
declare function atob(data: string): string;
declare function btoa(data: string): string;
declare function clearInterval(handle?: number): void;
declare function clearTimeout(handle?: number): void;
declare function createImageBitmap(image: ImageBitmapSource): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number): Promise<ImageBitmap>;
declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
declare function addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
declare function removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
Expand All @@ -2686,7 +2696,10 @@ type HeadersInit = Headers | string[][] | Record<string, string>;
type BodyInit = Blob | BufferSource | FormData | URLSearchParams | ReadableStream | string;
type RequestInfo = Request | string;
type DOMHighResTimeStamp = number;
type CanvasImageSource = ImageBitmap;
type MessageEventSource = MessagePort | ServiceWorker;
type ImageBitmapSource = CanvasImageSource | Blob | ImageData;
type TimerHandler = string | Function;
type PerformanceEntryList = PerformanceEntry[];
type PushMessageDataInit = BufferSource | string;
type VibratePattern = number | number[];
Expand Down
41 changes: 16 additions & 25 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"mixins": {
"mixin": {
"GlobalEventHandlers": {
"events": {
"event": [
{
"name": "cancel",
"type": "Event"
}
]
}
},
"HTMLHyperlinkElementUtils": {
"name": "HTMLHyperlinkElementUtils",
"properties": {
Expand Down Expand Up @@ -334,17 +344,6 @@
},
"Window": {
"name": "Window",
"methods": {
"method": {
"createImageBitmap": {
"name": "createImageBitmap",
"override-signatures": [
"createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>",
"createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>"
]
}
}
},
"properties": {
"property": {
"URL": {
Expand All @@ -369,20 +368,6 @@
}
}
},
"WorkerGlobalScope": {
"name": "WorkerGlobalScope",
"methods": {
"method": {
"createImageBitmap": {
"name": "createImageBitmap",
"override-signatures": [
"createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise<ImageBitmap>",
"createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>"
]
}
}
}
},
"URLSearchParams": {
"name": "URLSearchParams",
"constructor": {
Expand Down Expand Up @@ -1091,6 +1076,9 @@
},
"no-interface-object": "1"
},
"SVGElement": {
"implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"]
},
"Text": {
"name": "Text",
"properties": {
Expand Down Expand Up @@ -1832,6 +1820,9 @@
},
"no-interface-object": "1"
},
"HTMLElement": {
"implements": ["GlobalEventHandlers", "DocumentAndElementEventHandlers"]
},
"HTMLAnchorElement": {
"element": [
{
Expand Down
5 changes: 5 additions & 0 deletions inputfiles/idl/HTML - Web application APIs.commentmap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"origin": "Returns the global object's origin, serialized as string.",
"btoa": "Takes the input data, in the form of a Unicode string containing only characters in the range\nU+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and\nconverts it to its base64 representation, which it returns.\nThrows an \"InvalidCharacterError\" DOMException\nexception if the input string contains any out-of-range characters.",
"atob": "Takes the input data, in the form of a Unicode string containing base64-encoded binary data,\ndecodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each\nrepresenting a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary\ndata.\nThrows an \"InvalidCharacterError\" DOMException if the\ninput string is not valid base64 data."
}
151 changes: 151 additions & 0 deletions inputfiles/idl/HTML - Web application APIs.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
[Constructor(DOMString type, optional ErrorEventInit eventInitDict), Exposed=(Window,Worker)]
interface ErrorEvent : Event {
readonly attribute DOMString message;
readonly attribute USVString filename;
readonly attribute unsigned long lineno;
readonly attribute unsigned long colno;
readonly attribute any error;
};

dictionary ErrorEventInit : EventInit {
DOMString message = "";
USVString filename = "";
unsigned long lineno = 0;
unsigned long colno = 0;
any error = null;
};

[Constructor(DOMString type, PromiseRejectionEventInit eventInitDict), Exposed=(Window,Worker)]
interface PromiseRejectionEvent : Event {
readonly attribute Promise<any> promise;
readonly attribute any reason;
};

dictionary PromiseRejectionEventInit : EventInit {
required Promise<any> promise;
any reason;
};

[TreatNonObjectAsNull]
callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;

[TreatNonObjectAsNull]
callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long colno, optional any error);
typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;

[TreatNonObjectAsNull]
callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event);
typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler;

interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
attribute EventHandler onauxclick;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler onclose;
attribute EventHandler oncontextmenu;
attribute EventHandler oncuechange;
attribute EventHandler ondblclick;
attribute EventHandler ondrag;
attribute EventHandler ondragend;
attribute EventHandler ondragenter;
attribute EventHandler ondragexit;
attribute EventHandler ondragleave;
attribute EventHandler ondragover;
attribute EventHandler ondragstart;
attribute EventHandler ondrop;
attribute EventHandler ondurationchange;
attribute EventHandler onemptied;
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
attribute EventHandler onkeypress;
attribute EventHandler onkeyup;
attribute EventHandler onload;
attribute EventHandler onloadeddata;
attribute EventHandler onloadedmetadata;
attribute EventHandler onloadend;
attribute EventHandler onloadstart;
attribute EventHandler onmousedown;
[LenientThis] attribute EventHandler onmouseenter;
[LenientThis] attribute EventHandler onmouseleave;
attribute EventHandler onmousemove;
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
attribute EventHandler onwheel;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
attribute EventHandler onprogress;
attribute EventHandler onratechange;
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
attribute EventHandler ontimeupdate;
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
};

interface mixin WindowEventHandlers {
attribute EventHandler onafterprint;
attribute EventHandler onbeforeprint;
attribute OnBeforeUnloadEventHandler onbeforeunload;
attribute EventHandler onhashchange;
attribute EventHandler onlanguagechange;
attribute EventHandler onmessage;
attribute EventHandler onmessageerror;
attribute EventHandler onoffline;
attribute EventHandler ononline;
attribute EventHandler onpagehide;
attribute EventHandler onpageshow;
attribute EventHandler onpopstate;
attribute EventHandler onrejectionhandled;
attribute EventHandler onstorage;
attribute EventHandler onunhandledrejection;
attribute EventHandler onunload;
};

interface mixin DocumentAndElementEventHandlers {
attribute EventHandler oncopy;
attribute EventHandler oncut;
attribute EventHandler onpaste;
};

typedef (DOMString or Function) TimerHandler;

interface mixin WindowOrWorkerGlobalScope {
[Replaceable] readonly attribute USVString origin;

// base64 utility methods
DOMString btoa(DOMString data);
ByteString atob(DOMString data);

// timers
long setTimeout(TimerHandler handler, optional long timeout = 0, any... arguments);
void clearTimeout(optional long handle = 0);
long setInterval(TimerHandler handler, optional long timeout = 0, any... arguments);
void clearInterval(optional long handle = 0);

// ImageBitmap
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);
};
Window includes WindowOrWorkerGlobalScope;
WorkerGlobalScope includes WindowOrWorkerGlobalScope;
4 changes: 4 additions & 0 deletions inputfiles/idlSources.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
"url": "https://html.spec.whatwg.org/multipage/input.html",
"title": "HTML - The input element"
},
{
"url": "https://html.spec.whatwg.org/multipage/webappapis.html",
"title": "HTML - Web application APIs"
},
{
"url": "https://html.spec.whatwg.org/multipage/webstorage.html",
"title": "HTML - Web storage"
Expand Down
Loading