From 33d0b2510452f7dc7d49f276b65dcbb6a5eb02cc Mon Sep 17 00:00:00 2001 From: VincentBel Date: Tue, 28 Mar 2017 22:32:30 +0800 Subject: [PATCH 1/4] add URL typing to webworker URL is also available in workder. --- baselines/dom.generated.d.ts | 20 ++++++++ baselines/webworker.generated.d.ts | 21 ++++++++ inputfiles/addedTypes.json | 80 +++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 95fad6275..531a0f7c9 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -13232,6 +13232,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly top: Window; readonly window: Window; URL: typeof URL; + URLSearchParams: typeof URLSearchParams; Blob: typeof Blob; customElements: CustomElementRegistry; alert(message?: any): void; @@ -13858,6 +13859,25 @@ interface ImageBitmap { close(): void; } +interface URL { + href: string; + readonly origin: string; + protocol: string; + username: string; + password: string; + host: string; + hostname: string; + port: string; + pathname: string; + search: string; + toJSON(): string; +} + +declare var URL: { + prototype: URL; + new (url: string, base?: string): URL; +} + interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index fb9358fc0..31a58f0e0 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -1406,6 +1406,8 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; readonly performance: Performance; readonly self: WorkerGlobalScope; + URL: typeof URL; + URLSearchParams: typeof URLSearchParams; msWriteProfilerMark(profilerMarkName: string): void; createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; @@ -1484,6 +1486,25 @@ interface ImageBitmap { close(): void; } +interface URL { + href: string; + readonly origin: string; + protocol: string; + username: string; + password: string; + host: string; + hostname: string; + port: string; + pathname: string; + search: string; + toJSON(): string; +} + +declare var URL: { + prototype: URL; + new (url: string, base?: string): URL; +} + interface BlobPropertyBag { type?: string; endings?: string; diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index 61209eebc..21be15bdb 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -178,10 +178,67 @@ "name": "multiEntry", "type": "boolean" }, + { + "kind": "interface", + "name": "URL", + "flavor": "Worker", + "constructorSignatures": [ + "new (url: string, base?: string): URL" + ], + "properties": [ + { + "name": "href", + "type": "string" + }, + { + "name": "origin", + "type": "string", + "readonly": true + }, + { + "name": "protocol", + "type": "string" + }, + { + "name": "username", + "type": "string" + }, + { + "name": "password", + "type": "string" + }, + { + "name": "host", + "type": "string" + }, + { + "name": "hostname", + "type": "string" + }, + { + "name": "port", + "type": "string" + }, + { + "name": "pathname", + "type": "string" + }, + { + "name": "search", + "type": "string" + } + ], + "methods": [ + { + "name": "toJSON", + "signatures": ["toJSON(): string"] + } + ] + }, { "kind": "interface", "name": "URLSearchParams", - "flavor": "Web", + "flavor": "All", "constructorSignatures": [ "new (init?: string | URLSearchParams): URLSearchParams" ], @@ -226,6 +283,27 @@ "name": "URL", "type": "typeof URL" }, + { + "kind": "property", + "interface": "WorkerGlobalScope", + "exposeGlobally": false, + "name": "URL", + "type": "typeof URL" + }, + { + "kind": "property", + "interface": "Window", + "exposeGlobally": false, + "name": "URLSearchParams", + "type": "typeof URLSearchParams" + }, + { + "kind": "property", + "interface": "WorkerGlobalScope", + "exposeGlobally": false, + "name": "URLSearchParams", + "type": "typeof URLSearchParams" + }, { "kind": "property", "interface": "Window", From fa253649a04ab0f393ee10a95b6ac1e9b0d0e2e5 Mon Sep 17 00:00:00 2001 From: VincentBel Date: Wed, 29 Mar 2017 10:12:46 +0800 Subject: [PATCH 2/4] add URL and URLSearcParams to `knownWorkerInterfaces.json` --- baselines/dom.generated.d.ts | 19 -------- baselines/webworker.generated.d.ts | 69 +++++++++++++++++++++------ inputfiles/addedTypes.json | 58 ---------------------- inputfiles/knownWorkerInterfaces.json | 4 +- 4 files changed, 57 insertions(+), 93 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 531a0f7c9..8d599758a 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -13859,25 +13859,6 @@ interface ImageBitmap { close(): void; } -interface URL { - href: string; - readonly origin: string; - protocol: string; - username: string; - password: string; - host: string; - hostname: string; - port: string; - pathname: string; - search: string; - toJSON(): string; -} - -declare var URL: { - prototype: URL; - new (url: string, base?: string): URL; -} - interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 31a58f0e0..136b0e9e1 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -1008,6 +1008,29 @@ declare var SyncManager: { new(): SyncManager; } +interface URL { + hash: string; + host: string; + hostname: string; + href: string; + readonly origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + username: string; + readonly searchParams: URLSearchParams; + toString(): string; +} + +declare var URL: { + prototype: URL; + new(url: string, base?: string): URL; + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} + interface WebSocketEventMap { "close": CloseEvent; "error": Event; @@ -1486,23 +1509,39 @@ interface ImageBitmap { close(): void; } -interface URL { - href: string; - readonly origin: string; - protocol: string; - username: string; - password: string; - host: string; - hostname: string; - port: string; - pathname: string; - search: string; - toJSON(): string; +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; } -declare var URL: { - prototype: URL; - new (url: string, base?: string): URL; +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; } interface BlobPropertyBag { diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index 21be15bdb..976cb4967 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -178,67 +178,9 @@ "name": "multiEntry", "type": "boolean" }, - { - "kind": "interface", - "name": "URL", - "flavor": "Worker", - "constructorSignatures": [ - "new (url: string, base?: string): URL" - ], - "properties": [ - { - "name": "href", - "type": "string" - }, - { - "name": "origin", - "type": "string", - "readonly": true - }, - { - "name": "protocol", - "type": "string" - }, - { - "name": "username", - "type": "string" - }, - { - "name": "password", - "type": "string" - }, - { - "name": "host", - "type": "string" - }, - { - "name": "hostname", - "type": "string" - }, - { - "name": "port", - "type": "string" - }, - { - "name": "pathname", - "type": "string" - }, - { - "name": "search", - "type": "string" - } - ], - "methods": [ - { - "name": "toJSON", - "signatures": ["toJSON(): string"] - } - ] - }, { "kind": "interface", "name": "URLSearchParams", - "flavor": "All", "constructorSignatures": [ "new (init?: string | URLSearchParams): URLSearchParams" ], diff --git a/inputfiles/knownWorkerInterfaces.json b/inputfiles/knownWorkerInterfaces.json index a56aea3ed..9cf72f611 100644 --- a/inputfiles/knownWorkerInterfaces.json +++ b/inputfiles/knownWorkerInterfaces.json @@ -91,6 +91,8 @@ "SyncEventInit", "SyncManager", "USVString", + "URL", + "URLSearchParams", "WebSocket", "WindowBase64", "WindowConsole", @@ -98,4 +100,4 @@ "XMLHttpRequest", "XMLHttpRequestEventTarget", "XMLHttpRequestUpload" -] \ No newline at end of file +] From e0f29868110fdcd390248bbffbd3d58350e2c99f Mon Sep 17 00:00:00 2001 From: VincentBel Date: Wed, 29 Mar 2017 10:44:43 +0800 Subject: [PATCH 3/4] don't add `URL` and `URLSearchParams` to WorkerGlobalScope --- baselines/webworker.generated.d.ts | 2 -- inputfiles/addedTypes.json | 14 -------------- 2 files changed, 16 deletions(-) diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 136b0e9e1..006415e18 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -1429,8 +1429,6 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo onerror: (this: WorkerGlobalScope, ev: ErrorEvent) => any; readonly performance: Performance; readonly self: WorkerGlobalScope; - URL: typeof URL; - URLSearchParams: typeof URLSearchParams; msWriteProfilerMark(profilerMarkName: string): void; createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; diff --git a/inputfiles/addedTypes.json b/inputfiles/addedTypes.json index 976cb4967..293035718 100644 --- a/inputfiles/addedTypes.json +++ b/inputfiles/addedTypes.json @@ -225,13 +225,6 @@ "name": "URL", "type": "typeof URL" }, - { - "kind": "property", - "interface": "WorkerGlobalScope", - "exposeGlobally": false, - "name": "URL", - "type": "typeof URL" - }, { "kind": "property", "interface": "Window", @@ -239,13 +232,6 @@ "name": "URLSearchParams", "type": "typeof URLSearchParams" }, - { - "kind": "property", - "interface": "WorkerGlobalScope", - "exposeGlobally": false, - "name": "URLSearchParams", - "type": "typeof URLSearchParams" - }, { "kind": "property", "interface": "Window", From 0fe9b6f0591f4c07174a95f62e98fa146be3a05d Mon Sep 17 00:00:00 2001 From: VincentBel Date: Wed, 29 Mar 2017 14:14:31 +0800 Subject: [PATCH 4/4] add `ObjectURLOptions` to webworker --- baselines/webworker.generated.d.ts | 4 ++++ inputfiles/knownWorkerInterfaces.json | 1 + 2 files changed, 5 insertions(+) diff --git a/baselines/webworker.generated.d.ts b/baselines/webworker.generated.d.ts index 006415e18..0034d0a63 100644 --- a/baselines/webworker.generated.d.ts +++ b/baselines/webworker.generated.d.ts @@ -61,6 +61,10 @@ interface NotificationOptions { icon?: string; } +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + interface PushSubscriptionOptionsInit { userVisibleOnly?: boolean; applicationServerKey?: any; diff --git a/inputfiles/knownWorkerInterfaces.json b/inputfiles/knownWorkerInterfaces.json index 9cf72f611..7e35f48e6 100644 --- a/inputfiles/knownWorkerInterfaces.json +++ b/inputfiles/knownWorkerInterfaces.json @@ -66,6 +66,7 @@ "NotificationEventInit", "NotificationOptions", "NotificationPermissionCallback", + "ObjectURLOptions", "Performance", "PerformanceNavigation", "PerformanceTiming",