This is an automated email from the ASF dual-hosted git repository.
janpio pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
The following commit(s) were added to refs/heads/master by this push:
new a0c267f CB-12941: update typings (#267)
a0c267f is described below
commit a0c267fe36be9a97c974f73b9d2160eca54b9828
Author: Tim Brust <[email protected]>
AuthorDate: Tue Oct 2 11:49:11 2018 +0200
CB-12941: update typings (#267)
### Platforms affected
n/a - development with TypeScript
### What does this PR do?
Updates the typings to match the latest published version on
DefinitelyTyped.
See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17192 and
https://stackoverflow.com/q/42095516/1902598
### What testing has been done on this change?
Project compiles again ;)
### Checklist
- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html)
in the JIRA database
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform
affected.
- n/a: Added automated test coverage as appropriate for this change.
fixes #300
---
types/index.d.ts | 168 +++++++++----------------------------------------------
1 file changed, 25 insertions(+), 143 deletions(-)
diff --git a/types/index.d.ts b/types/index.d.ts
index ea3d3ad..3bac670 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -2,9 +2,11 @@
// Project: https://github.com/apache/cordova-plugin-inappbrowser
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-//
+//
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
+// TypeScript Version: 2.3
+type channel = "loadstart" | "loadstop" | "loaderror" | "exit";
interface Window {
/**
@@ -15,33 +17,6 @@ interface Window {
* The options string must not contain any blank space,
and each feature's
* name/value pairs must be separated by a comma. Feature
names are case insensitive.
*/
- open(url: string, target?: "_self", options?: string): InAppBrowser;
- /**
- * Opens a URL in a new InAppBrowser instance, the current browser
instance, or the system browser.
- * @param url The URL to load.
- * @param target The target in which to load the URL, an optional
parameter that defaults to _self.
- * @param options Options for the InAppBrowser. Optional, defaulting to:
location=yes.
- * The options string must not contain any blank space,
and each feature's
- * name/value pairs must be separated by a comma. Feature
names are case insensitive.
- */
- open(url: string, target?: "_blank", options?: string): InAppBrowser;
- /**
- * Opens a URL in a new InAppBrowser instance, the current browser
instance, or the system browser.
- * @param url The URL to load.
- * @param target The target in which to load the URL, an optional
parameter that defaults to _self.
- * @param options Options for the InAppBrowser. Optional, defaulting to:
location=yes.
- * The options string must not contain any blank space,
and each feature's
- * name/value pairs must be separated by a comma. Feature
names are case insensitive.
- */
- open(url: string, target?: "_system", options?: string): InAppBrowser;
- /**
- * Opens a URL in a new InAppBrowser instance, the current browser
instance, or the system browser.
- * @param url The URL to load.
- * @param target The target in which to load the URL, an optional
parameter that defaults to _self.
- * @param options Options for the InAppBrowser. Optional, defaulting to:
location=yes.
- * The options string must not contain any blank space,
and each feature's
- * name/value pairs must be separated by a comma. Feature
names are case insensitive.
- */
open(url: string, target?: string, options?: string, replace?: boolean):
InAppBrowser;
}
@@ -50,66 +25,21 @@ interface Window {
* NOTE: The InAppBrowser window behaves like a standard web browser, and
can't access Cordova APIs.
*/
interface InAppBrowser extends Window {
- onloadstart: (type: InAppBrowserEvent) => void;
- onloadstop: (type: InAppBrowserEvent) => void;
- onloaderror: (type: InAppBrowserEvent) => void;
- onexit: (type: InAppBrowserEvent) => void;
+ onloadstart(type: Event): void;
+ onloadstop(type: InAppBrowserEvent): void;
+ onloaderror(type: InAppBrowserEvent): void;
+ onexit(type: InAppBrowserEvent): void;
// addEventListener overloads
/**
* Adds a listener for an event from the InAppBrowser.
- * @param type the event to listen for
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an InAppBrowserEvent object as a parameter.
- */
- addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent)
=> void): void;
- /**
- * Adds a listener for an event from the InAppBrowser.
- * @param type the event to listen for
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an InAppBrowserEvent object as a parameter.
- */
- addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) =>
void): void;
- /**
- * Adds a listener for an event from the InAppBrowser.
- * @param type the event to listen for
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an InAppBrowserEvent object as a parameter.
- */
- addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent)
=> void): void;
- /**
- * Adds a listener for an event from the InAppBrowser.
- * @param type the event to listen for
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
+ * @param type loadstart: event fires when the InAppBrowser starts to
load a URL.
* loadstop: event fires when the InAppBrowser finishes
loading a URL.
* loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is
closed.
* @param callback the function that executes when the event fires. The
function is
* passed an InAppBrowserEvent object as a parameter.
*/
- addEventListener(type: "exit", callback: (event: InAppBrowserEvent) =>
void): void;
- /**
- * Adds a listener for an event from the InAppBrowser.
- * @param type the event to listen for
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an Event object as a parameter.
- */
- addEventListener(type: string, callback: (event: Event) => void): void;
+ addEventListener(type: channel, callback:
InAppBrowserEventListenerOrEventListenerObject): void;
// removeEventListener overloads
/**
* Removes a listener for an event from the InAppBrowser.
@@ -121,51 +51,7 @@ interface InAppBrowser extends Window {
* @param callback the function that executes when the event fires. The
function is
* passed an InAppBrowserEvent object as a parameter.
*/
- removeEventListener(type: "loadstart", callback: (event:
InAppBrowserEvent) => void): void;
- /**
- * Removes a listener for an event from the InAppBrowser.
- * @param type The event to stop listening for.
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an InAppBrowserEvent object as a parameter.
- */
- removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent)
=> void): void;
- /**
- * Removes a listener for an event from the InAppBrowser.
- * @param type The event to stop listening for.
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an InAppBrowserEvent object as a parameter.
- */
- removeEventListener(type: "loaderror", callback: (event:
InAppBrowserEvent) => void): void;
- /**
- * Removes a listener for an event from the InAppBrowser.
- * @param type The event to stop listening for.
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an InAppBrowserEvent object as a parameter.
- */
- removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) =>
void): void;
- /**
- * Removes a listener for an event from the InAppBrowser.
- * @param type The event to stop listening for.
- * loadstart: event fires when the InAppBrowser starts to
load a URL.
- * loadstop: event fires when the InAppBrowser finishes
loading a URL.
- * loaderror: event fires when the InAppBrowser
encounters an error when loading a URL.
- * exit: event fires when the InAppBrowser window is
closed.
- * @param callback the function that executes when the event fires. The
function is
- * passed an Event object as a parameter.
- */
- removeEventListener(type: string, callback: (event: Event) => void): void;
+ removeEventListener(type: channel, callback:
InAppBrowserEventListenerOrEventListenerObject): void;
/** Closes the InAppBrowser window. */
close(): void;
/** Hides the InAppBrowser window. Calling this has no effect if the
InAppBrowser was already hidden. */
@@ -184,29 +70,21 @@ interface InAppBrowser extends Window {
* For multi-line scripts, this is the return value of
the last statement,
* or the last expression evaluated.
*/
- executeScript(script: { code: string }, callback: (result: any) => void):
void;
- /**
- * Injects JavaScript code into the InAppBrowser window.
- * @param script Details of the script to run, specifying either a file
or code key.
- * @param callback The function that executes after the JavaScript code
is injected.
- * If the injected script is of type code, the callback
executes with
- * a single parameter, which is the return value of the
script, wrapped in an Array.
- * For multi-line scripts, this is the return value of
the last statement,
- * or the last expression evaluated.
- */
- executeScript(script: { file: string }, callback: (result: any) => void):
void;
- /**
- * Injects CSS into the InAppBrowser window.
- * @param css Details of the script to run, specifying either a file
or code key.
- * @param callback The function that executes after the CSS is injected.
- */
- insertCSS(css: { code: string }, callback: () => void): void;
+ executeScript(script: { code: string } | { file: string }, callback:
(result: any) => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file
or code key.
* @param callback The function that executes after the CSS is injected.
*/
- insertCSS(css: { file: string }, callback: () => void): void;
+ insertCSS(css: { code: string } | { file: string }, callback: () => void):
void;
+}
+
+type InAppBrowserEventListenerOrEventListenerObject =
InAppBrowserEventListener | InAppBrowserEventListenerObject;
+
+type InAppBrowserEventListener = (evt: InAppBrowserEvent) => void;
+
+interface InAppBrowserEventListenerObject {
+ handleEvent(evt: InAppBrowserEvent): void;
}
interface InAppBrowserEvent extends Event {
@@ -218,4 +96,8 @@ interface InAppBrowserEvent extends Event {
code: number;
/** the error message, only in the case of loaderror. */
message: string;
-}
\ No newline at end of file
+}
+
+interface Cordova {
+ InAppBrowser: InAppBrowser;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]