This is an automated email from the ASF dual-hosted git repository.
GitToTheHub 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 e28ca69 fix(types): support beforeload listener signature in
TypeScript defs (#1149)
e28ca69 is described below
commit e28ca69acd6700f68c0845b86c16f8dc830b413f
Author: Manuel Beck <[email protected]>
AuthorDate: Mon May 18 16:59:12 2026 +0200
fix(types): support beforeload listener signature in TypeScript defs (#1149)
- add explicit beforeload event typing for
addEventListener/removeEventListener
- keep beforeload separated from generic event overload to avoid overload
mismatch errors
- clarify inline docs about why beforeload uses its own overload
- Fixes https://github.com/apache/cordova-plugin-inappbrowser/issues/1084
- Generated-By: GPT-5.3-Codex
---
types/index.d.ts | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/types/index.d.ts b/types/index.d.ts
index 43db6e3..6c2f95b 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -6,7 +6,7 @@
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
// TypeScript Version: 2.3
-type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message" |
"customscheme";
+type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message" |
"customscheme" | "beforeload";
/**
* The object returned from a call to cordova.InAppBrowser.open.
@@ -37,8 +37,19 @@ interface InAppBrowser {
* 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.
+ *
+ * NOTE: beforeload is intentionally excluded here and modeled with a
dedicated overload because the
+ * callback parameter is of a different type.
*/
- addEventListener(type: channel, callback:
InAppBrowserEventListenerOrEventListenerObject): void;
+ addEventListener(type: Exclude<channel, "beforeload">, callback:
InAppBrowserEventListenerOrEventListenerObject): void;
+ /**
+ * Adds a listener for the beforeload event from the InAppBrowser.
+ * @param type beforeload: event fires when the InAppBrowser decides
whether to load a URL or not.
+ * @param callback the function that executes when the event fires. The
function is
+ * passed an InAppBrowserEvent object and a callback
function that can be
+ * invoked to continue loading with a URL.
+ */
+ addEventListener(type: "beforeload", callback:
InAppBrowserBeforeloadEventListener): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type any custom event that might occur.
@@ -56,8 +67,17 @@ interface InAppBrowser {
* 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.
+ *
+ * NOTE: beforeload is intentionally excluded here and modeled with a
dedicated overload because the
+ * callback parameter is of a different type.
*/
- removeEventListener(type: channel, callback:
InAppBrowserEventListenerOrEventListenerObject): void;
+ removeEventListener(type: Exclude<channel, "beforeload">, callback:
InAppBrowserEventListenerOrEventListenerObject): void;
+ /**
+ * Removes a listener for the beforeload event from the InAppBrowser.
+ * @param type beforeload: event fires when the InAppBrowser decides
whether to load a URL or not.
+ * @param callback the function that executes when the event fires.
+ */
+ removeEventListener(type: "beforeload", callback:
InAppBrowserBeforeloadEventListener): void;
/** Closes the InAppBrowser window. */
close(): void;
/** Hides the InAppBrowser window. Calling this has no effect if the
InAppBrowser was already hidden. */
@@ -89,12 +109,14 @@ type InAppBrowserEventListenerOrEventListenerObject =
InAppBrowserEventListener
type InAppBrowserEventListener = (evt: InAppBrowserEvent) => void;
+type InAppBrowserBeforeloadEventListener = (evt: InAppBrowserEvent, callback:
(url: string) => void) => void;
+
interface InAppBrowserEventListenerObject {
handleEvent(evt: InAppBrowserEvent): void;
}
interface InAppBrowserEvent extends Event {
- /** the eventname, either `loadstart`, `loadstop`, `loaderror`, `exit`,
`message`, or `customscheme`. */
+ /** the eventname, either `loadstart`, `loadstop`, `loaderror`, `exit`,
`message`, `customscheme`, or `beforeload`. */
type: string;
/** the URL that was loaded. */
url: string;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]