From 7db0605d456559f1ca9447e6fa778559fe50cc95 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sun, 17 Jan 2021 15:28:54 +0000 Subject: fix(op_crates/web): Use WorkerLocation for location in workers (#9084) --- cli/dts/lib.deno.window.d.ts | 72 ++++++++++++++++++++++++++++++++++++++++++++ cli/dts/lib.deno.worker.d.ts | 23 ++++++++++++++ 2 files changed, 95 insertions(+) (limited to 'cli/dts') diff --git a/cli/dts/lib.deno.window.d.ts b/cli/dts/lib.deno.window.d.ts index da1b25565..721c89af2 100644 --- a/cli/dts/lib.deno.window.d.ts +++ b/cli/dts/lib.deno.window.d.ts @@ -49,3 +49,75 @@ declare function confirm(message?: string): boolean; * @param defaultValue */ declare function prompt(message?: string, defaultValue?: string): string | null; + +// TODO(nayeemrmn): Move this to `op_crates/web` where its implementation is. +// The types there must first be split into window, worker and global types. +/** The location (URL) of the object it is linked to. Changes done on it are + * reflected on the object it relates to. Accessible via + * `globalThis.location`. */ +declare class Location { + constructor(); + /** Returns a DOMStringList object listing the origins of the ancestor + * browsing contexts, from the parent browsing context to the top-level + * browsing context. + * + * Always empty in Deno. */ + readonly ancestorOrigins: DOMStringList; + /** Returns the Location object's URL's fragment (includes leading "#" if + * non-empty). + * + * Cannot be set in Deno. */ + hash: string; + /** Returns the Location object's URL's host and port (if different from the + * default port for the scheme). + * + * Cannot be set in Deno. */ + host: string; + /** Returns the Location object's URL's host. + * + * Cannot be set in Deno. */ + hostname: string; + /** Returns the Location object's URL. + * + * Cannot be set in Deno. */ + href: string; + toString(): string; + /** Returns the Location object's URL's origin. */ + readonly origin: string; + /** Returns the Location object's URL's path. + * + * Cannot be set in Deno. */ + pathname: string; + /** Returns the Location object's URL's port. + * + * Cannot be set in Deno. */ + port: string; + /** Returns the Location object's URL's scheme. + * + * Cannot be set in Deno. */ + protocol: string; + /** Returns the Location object's URL's query (includes leading "?" if + * non-empty). + * + * Cannot be set in Deno. */ + search: string; + /** Navigates to the given URL. + * + * Cannot be set in Deno. */ + assign(url: string): void; + /** Reloads the current page. + * + * Disabled in Deno. */ + reload(): void; + /** @deprecated */ + reload(forcedReload: boolean): void; + /** Removes the current page from the session history and navigates to the + * given URL. + * + * Disabled in Deno. */ + replace(url: string): void; +} + +// TODO(nayeemrmn): Move this to `op_crates/web` where its implementation is. +// The types there must first be split into window, worker and global types. +declare var location: Location; diff --git a/cli/dts/lib.deno.worker.d.ts b/cli/dts/lib.deno.worker.d.ts index 74609e8ab..a8f42f336 100644 --- a/cli/dts/lib.deno.worker.d.ts +++ b/cli/dts/lib.deno.worker.d.ts @@ -58,3 +58,26 @@ declare var onerror: declare var close: () => void; declare var name: string; declare var postMessage: (message: any) => void; + +// TODO(nayeemrmn): Move this to `op_crates/web` where its implementation is. +// The types there must first be split into window, worker and global types. +/** The absolute location of the script executed by the Worker. Such an object + * is initialized for each worker and is available via the + * WorkerGlobalScope.location property obtained by calling self.location. */ +declare class WorkerLocation { + constructor(); + readonly hash: string; + readonly host: string; + readonly hostname: string; + readonly href: string; + toString(): string; + readonly origin: string; + readonly pathname: string; + readonly port: string; + readonly protocol: string; + readonly search: string; +} + +// TODO(nayeemrmn): Move this to `op_crates/web` where its implementation is. +// The types there must first be split into window, worker and global types. +declare var location: WorkerLocation; -- cgit v1.2.3