@@ -15,21 +15,17 @@ export declare namespace dk {
15
15
class WebViewBridgeInterface extends java . lang . Object {
16
16
public owner ?: WebViewExt ;
17
17
18
- emitEventToNativeScript ( eventName : string , data : string ) : void ;
18
+ public emitEventToNativeScript ( eventName : string , data : string ) : void ;
19
19
}
20
20
}
21
21
}
22
22
}
23
- export interface AndroidWebViewClient extends android . webkit . WebViewClient {
24
- owner ?: WebViewExt ;
25
- }
26
-
27
- export interface AndroidWebView extends android . webkit . WebView {
28
- client ?: AndroidWebViewClient ;
29
- bridgeInterface ?: dk . nota . webviewinterface . WebViewBridgeInterface ;
30
- }
31
23
32
24
const extToMimeType = new Map < string , string > ( [
25
+ [ 'html' , 'text/html' ] ,
26
+ [ 'htm' , 'text/html' ] ,
27
+ [ 'xhtml' , 'text/html' ] ,
28
+ [ 'xhtm' , 'text/html' ] ,
33
29
[ 'css' , 'text/css' ] ,
34
30
[ 'gif' , 'image/gif' ] ,
35
31
[ 'jpeg' , 'image/jpeg' ] ,
@@ -51,6 +47,15 @@ const extToBinaryEncoding = new Set<string>([
51
47
] ) ;
52
48
53
49
//#region android_native_classes
50
+ export interface AndroidWebViewClient extends android . webkit . WebViewClient {
51
+ owner ?: WebViewExt ;
52
+ }
53
+
54
+ export interface AndroidWebView extends android . webkit . WebView {
55
+ client ?: AndroidWebViewClient ;
56
+ bridgeInterface ?: dk . nota . webviewinterface . WebViewBridgeInterface ;
57
+ }
58
+
54
59
let WebViewExtClient : new ( ) => AndroidWebViewClient ;
55
60
let WebViewBridgeInterface : new ( ) => dk . nota . webviewinterface . WebViewBridgeInterface ;
56
61
function initializeWebViewClient ( ) : void {
@@ -181,7 +186,7 @@ function initializeWebViewClient(): void {
181
186
}
182
187
183
188
owner . writeTrace ( `WebViewClientClass.onPageFinished("${ url } ")` ) ;
184
- owner . _onLoadFinished ( url ) ;
189
+ owner . _onLoadFinished ( url ) . catch ( ( ) => void 0 ) ;
185
190
}
186
191
187
192
public onReceivedError ( ) {
@@ -201,21 +206,24 @@ function initializeWebViewClient(): void {
201
206
return ;
202
207
}
203
208
204
- owner . writeTrace ( `WebViewClientClass.onReceivedError(${ error . getErrorCode ( ) } , ${ error . getDescription ( ) } , ${ error . getUrl && error . getUrl ( ) } )` ) ;
209
+ let url = error . getUrl && error . getUrl ( ) ;
210
+ if ( ! url && typeof request === 'object' ) {
211
+ url = request . getUrl ( ) . toString ( ) ;
212
+ }
205
213
206
- owner . _onLoadFinished ( error . getUrl && error . getUrl ( ) , ` ${ error . getDescription ( ) } ( ${ error . getErrorCode ( ) } )`) ;
214
+ owner . writeTrace ( `WebViewClientClass.onReceivedErrorAPI23( ${ error . getErrorCode ( ) } , ${ error . getDescription ( ) } , ${ url } )`) ;
207
215
216
+ owner . _onLoadFinished ( url , `${ error . getDescription ( ) } (${ error . getErrorCode ( ) } )` ) . catch ( ( ) => void 0 ) ;
208
217
}
209
218
210
219
private onReceivedErrorBeforeAPI23 ( view : android . webkit . WebView , errorCode : number , description : string , failingUrl : string ) {
211
220
super . onReceivedError ( view , errorCode , description , failingUrl ) ;
212
221
213
222
const owner = this . owner ;
214
223
if ( owner ) {
215
- owner . writeTrace ( `WebViewClientClass.onReceivedError (${ errorCode } , "${ description } ", "${ failingUrl } ")` ) ;
216
- owner . _onLoadFinished ( failingUrl , `${ description } (${ errorCode } )` ) ;
224
+ owner . writeTrace ( `WebViewClientClass.onReceivedErrorBeforeAPI23 (${ errorCode } , "${ description } ", "${ failingUrl } ")` ) ;
225
+ owner . _onLoadFinished ( failingUrl , `${ description } (${ errorCode } )` ) . catch ( ( ) => void 0 ) ;
217
226
}
218
-
219
227
}
220
228
}
221
229
@@ -229,7 +237,7 @@ function initializeWebViewClient(): void {
229
237
return global . __native ( this ) ;
230
238
}
231
239
232
- emitEventToNativeScript ( eventName : string , data : string ) {
240
+ public emitEventToNativeScript ( eventName : string , data : string ) {
233
241
const owner = this . owner ;
234
242
if ( ! owner ) {
235
243
return ;
0 commit comments