@modos189/nativescript-webview-x-gecko 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -45,15 +45,14 @@ _Available in both `@modos189/nativescript-webview-x` and `@modos189/nativescrip
45
45
 
46
46
  ### Static properties
47
47
 
48
- | Static property | Type | Description |
49
- | --- | --- | --- |
50
- | `userAgentTransform` | `((defaultUA: string \| null) => string \| null) \| null` | Set once at app startup before any `WebViewX` is created. Applied automatically during native view initialization, before the first URL loads. `defaultUA` is the platform default UA string on Android system WebView, `null` on iOS/GeckoView (unavailable synchronously). Return the desired UA string, or `null` to leave the platform default unchanged. |
48
+ _None._
51
49
 
52
50
  ### Properties
53
51
 
54
52
  | Property | Type | Description |
55
53
  | --- | --- | --- |
56
54
  | `src` | `string` | URL to load (data-binding supported) |
55
+ | `userAgent` | `string` | Set a custom User-Agent string |
57
56
  | `debugMode` | `boolean` | Enable remote WebView debugging |
58
57
  | `supportPopups` | `boolean` | Open `window.open()` / `target="_blank"` links in a native popup. Default: `true` |
59
58
 
@@ -61,13 +60,16 @@ _Available in both `@modos189/nativescript-webview-x` and `@modos189/nativescrip
61
60
 
62
61
  | Method | Returns | Description |
63
62
  | --- | --- | --- |
64
- | `getUserAgentOverride()` | `string \| null` | Return the active UA override, or `null` if none is set (platform default is used) |
65
- | `setUserAgentOverride(ua: string \| null)` | `void` | Set a custom UA string for this instance; pass `null` or empty string to clear the override and restore the platform default. Applies to subsequent navigations |
63
+ | `getTitle()` | `Promise<string | undefined>` | Return the current page title |
66
64
 
67
65
  ### Events
68
66
 
69
67
  | Event | Description |
70
68
  | --- | --- |
69
+ | `loadStarted` | Navigation started. `args.url` contains the target URL |
70
+ | `loadFinished` | Navigation finished. `args.error` is set on failure |
71
+ | `loadProgress` | Android: page load progress. `args.progress` is 0–100 |
72
+ | `titleChanged` | Page title changed. `args.title` contains the new title |
71
73
  | `popupNavigate` | Android: fired on each navigation inside a popup; set `args.cancel = true` to intercept and dismiss the popup (e.g. capture OAuth redirect). `args.url` contains the target URL. |
72
74
 
73
75
 
package/common.d.ts CHANGED
@@ -1 +1,24 @@
1
- export {};
1
+ import { EventData } from '@nativescript/core';
2
+ export declare const LOAD_STARTED_EVENT = "loadStarted";
3
+ export declare const LOAD_FINISHED_EVENT = "loadFinished";
4
+ export declare const LOAD_PROGRESS_EVENT = "loadProgress";
5
+ export declare const TITLE_CHANGED_EVENT = "titleChanged";
6
+ export interface LoadStartedEventData extends EventData {
7
+ eventName: typeof LOAD_STARTED_EVENT;
8
+ url: string;
9
+ }
10
+ export interface LoadFinishedEventData extends EventData {
11
+ eventName: typeof LOAD_FINISHED_EVENT;
12
+ url: string;
13
+ error?: string;
14
+ }
15
+ export interface LoadProgressEventData extends EventData {
16
+ eventName: typeof LOAD_PROGRESS_EVENT;
17
+ url: string;
18
+ progress: number;
19
+ }
20
+ export interface TitleChangedEventData extends EventData {
21
+ eventName: typeof TITLE_CHANGED_EVENT;
22
+ url: string;
23
+ title: string;
24
+ }
package/common.js CHANGED
@@ -1,2 +1,5 @@
1
- export {};
1
+ export const LOAD_STARTED_EVENT = 'loadStarted';
2
+ export const LOAD_FINISHED_EVENT = 'loadFinished';
3
+ export const LOAD_PROGRESS_EVENT = 'loadProgress';
4
+ export const TITLE_CHANGED_EVENT = 'titleChanged';
2
5
  //# sourceMappingURL=common.js.map
package/common.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../packages/webview-x-gecko/common.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../packages/webview-x-gecko/common.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC"}
@@ -1,19 +1,32 @@
1
1
  import { View, Property } from '@nativescript/core';
2
+ export * from './common';
2
3
  export declare const srcProperty: Property<WebViewX, string>;
3
4
  export declare const debugModeProperty: Property<WebViewX, boolean>;
4
5
  export declare const supportPopupsProperty: Property<WebViewX, boolean>;
6
+ export declare const userAgentProperty: Property<WebViewX, string>;
5
7
  export declare class WebViewX extends View {
6
- static userAgentTransform: ((defaultUA: string | null) => string | null) | null;
7
8
  static get popupNavigateEvent(): string;
9
+ static get loadStartedEvent(): string;
10
+ static get loadFinishedEvent(): string;
11
+ static get loadProgressEvent(): string;
12
+ static get titleChangedEvent(): string;
8
13
  nativeViewProtected: org.mozilla.geckoview.GeckoView;
9
14
  private _session;
10
15
  private _popupHelper;
16
+ _currentUrl: string;
17
+ _currentTitle: string;
18
+ _tempSuspendSrcLoading: boolean;
11
19
  src: string;
12
20
  debugMode: boolean;
13
21
  supportPopups: boolean;
22
+ userAgent: string;
14
23
  _onPopupNavigate(url: string): boolean;
24
+ _onLoadStarted(url: string): void;
25
+ _onLoadFinished(url: string, error?: string): void;
26
+ _loadProgress(progress: number): void;
27
+ _titleChanged(title: string): void;
28
+ /** Returns the current page title (cached from GeckoDelegates.ContentDelegate.onTitleChange). */
29
+ getTitle(): Promise<string | undefined>;
15
30
  createNativeView(): org.mozilla.geckoview.GeckoView;
16
31
  disposeNativeView(): void;
17
- getUserAgentOverride(): string | null;
18
- setUserAgentOverride(ua: string | null): void;
19
32
  }
package/index.android.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { Application, View, Property, booleanConverter } from '@nativescript/core';
2
+ import { LOAD_STARTED_EVENT, LOAD_FINISHED_EVENT, LOAD_PROGRESS_EVENT, TITLE_CHANGED_EVENT } from './common';
3
+ export * from './common';
2
4
  const POPUP_NAVIGATE_EVENT = 'popupNavigate';
3
5
  // Explicit type annotation required to break circular inference with [xProperty.setNative]
4
6
  export const srcProperty = new Property({
@@ -15,15 +17,33 @@ export const supportPopupsProperty = new Property({
15
17
  defaultValue: true,
16
18
  valueConverter: booleanConverter,
17
19
  });
20
+ export const userAgentProperty = new Property({
21
+ name: 'userAgent',
22
+ });
18
23
  export class WebViewX extends View {
19
24
  constructor() {
20
25
  super(...arguments);
21
26
  this._session = null;
22
27
  this._popupHelper = null;
28
+ this._currentUrl = '';
29
+ this._currentTitle = '';
30
+ this._tempSuspendSrcLoading = false;
23
31
  }
24
32
  static get popupNavigateEvent() {
25
33
  return POPUP_NAVIGATE_EVENT;
26
34
  }
35
+ static get loadStartedEvent() {
36
+ return LOAD_STARTED_EVENT;
37
+ }
38
+ static get loadFinishedEvent() {
39
+ return LOAD_FINISHED_EVENT;
40
+ }
41
+ static get loadProgressEvent() {
42
+ return LOAD_PROGRESS_EVENT;
43
+ }
44
+ static get titleChangedEvent() {
45
+ return TITLE_CHANGED_EVENT;
46
+ }
27
47
  _onPopupNavigate(url) {
28
48
  const args = {
29
49
  eventName: POPUP_NAVIGATE_EVENT,
@@ -33,17 +53,56 @@ export class WebViewX extends View {
33
53
  this.notify(args);
34
54
  return args.cancel === true;
35
55
  }
56
+ _onLoadStarted(url) {
57
+ this._currentUrl = url;
58
+ this._currentTitle = ''; // reset stale title on each new navigation
59
+ this.notify({
60
+ eventName: LOAD_STARTED_EVENT,
61
+ object: this,
62
+ url,
63
+ });
64
+ }
65
+ _onLoadFinished(url, error) {
66
+ if (!error) {
67
+ try {
68
+ this._tempSuspendSrcLoading = true;
69
+ this.src = url;
70
+ }
71
+ finally {
72
+ this._tempSuspendSrcLoading = false;
73
+ }
74
+ }
75
+ this.notify({
76
+ eventName: LOAD_FINISHED_EVENT,
77
+ object: this,
78
+ url,
79
+ error,
80
+ });
81
+ }
82
+ _loadProgress(progress) {
83
+ this.notify({
84
+ eventName: LOAD_PROGRESS_EVENT,
85
+ object: this,
86
+ url: this._currentUrl,
87
+ progress,
88
+ });
89
+ }
90
+ _titleChanged(title) {
91
+ this._currentTitle = title;
92
+ this.notify({
93
+ eventName: TITLE_CHANGED_EVENT,
94
+ object: this,
95
+ url: this._currentUrl,
96
+ title,
97
+ });
98
+ }
99
+ /** Returns the current page title (cached from GeckoDelegates.ContentDelegate.onTitleChange). */
100
+ async getTitle() {
101
+ return this._currentTitle || undefined;
102
+ }
36
103
  createNativeView() {
37
104
  const runtime = com.modos189.webviewxgecko.GeckoPopupHelper.getRuntime(Application.android.context);
38
105
  const session = new org.mozilla.geckoview.GeckoSession();
39
- if (WebViewX.userAgentTransform) {
40
- const newUA = WebViewX.userAgentTransform(null);
41
- if (newUA !== null) {
42
- session.getSettings().setUserAgentOverride(newUA);
43
- }
44
- }
45
- // GeckoPopupHelper sets the NavigationDelegate and manages popup windows.
46
- // this._context is the Activity context — required for Dialog creation.
47
106
  this._popupHelper = new com.modos189.webviewxgecko.GeckoPopupHelper(session, this._context, true);
48
107
  const interceptor = new com.modos189.webviewxgecko.GeckoPopupHelper.PopupUrlInterceptor({
49
108
  shouldHandleExternally: (url) => {
@@ -51,6 +110,16 @@ export class WebViewX extends View {
51
110
  },
52
111
  });
53
112
  this._popupHelper.setUrlInterceptor(interceptor);
113
+ // GeckoDelegates are Java wrappers - NativeScript cannot proxy GeckoView interfaces directly
114
+ // (Java 8 default methods + @UiThread annotations break the runtime DEX factory).
115
+ session.setProgressDelegate(new com.modos189.webviewxgecko.GeckoDelegates.ProgressDelegate(new com.modos189.webviewxgecko.GeckoDelegates.ProgressListener({
116
+ onPageStart: (url) => this._onLoadStarted(url),
117
+ onPageStop: (success) => this._onLoadFinished(this._currentUrl, success ? undefined : 'load-failed'),
118
+ onProgressChange: (progress) => this._loadProgress(progress),
119
+ })));
120
+ session.setContentDelegate(new com.modos189.webviewxgecko.GeckoDelegates.ContentDelegate(new com.modos189.webviewxgecko.GeckoDelegates.ContentListener({
121
+ onTitleChange: (title) => this._titleChanged(title),
122
+ })));
54
123
  session.open(runtime);
55
124
  this._session = session;
56
125
  const geckoView = new org.mozilla.geckoview.GeckoView(this._context);
@@ -60,12 +129,16 @@ export class WebViewX extends View {
60
129
  disposeNativeView() {
61
130
  this._popupHelper = null;
62
131
  if (this._session) {
132
+ this._session.setProgressDelegate(null);
133
+ this._session.setContentDelegate(null);
63
134
  this._session.close();
64
135
  this._session = null;
65
136
  }
66
137
  super.disposeNativeView();
67
138
  }
68
139
  [srcProperty.setNative](value) {
140
+ if (this._tempSuspendSrcLoading)
141
+ return;
69
142
  if (value && this._session) {
70
143
  this._session.loadUri(value);
71
144
  }
@@ -73,18 +146,15 @@ export class WebViewX extends View {
73
146
  [debugModeProperty.setNative](value) {
74
147
  com.modos189.webviewxgecko.GeckoPopupHelper.setRemoteDebuggingEnabled(!!value);
75
148
  }
76
- getUserAgentOverride() {
77
- return this._session?.getSettings().getUserAgentOverride() ?? null;
78
- }
79
- setUserAgentOverride(ua) {
80
- this._session?.getSettings().setUserAgentOverride(ua || null);
81
- }
82
149
  [supportPopupsProperty.setNative](value) {
83
150
  this._popupHelper?.setSupportPopups(!!value);
84
151
  }
152
+ [userAgentProperty.setNative](value) {
153
+ this._session?.getSettings().setUserAgentOverride(value || null);
154
+ }
85
155
  }
86
- WebViewX.userAgentTransform = null;
87
156
  srcProperty.register(WebViewX);
88
157
  debugModeProperty.register(WebViewX);
89
158
  supportPopupsProperty.register(WebViewX);
159
+ userAgentProperty.register(WebViewX);
90
160
  //# sourceMappingURL=index.android.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.android.js","sourceRoot":"","sources":["../../../packages/webview-x-gecko/index.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEnF,MAAM,oBAAoB,GAAG,eAAe,CAAC;AAE7C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GAA+B,IAAI,QAAQ,CAAmB;IACpF,IAAI,EAAE,KAAK;IACX,YAAY,EAAE,EAAE;CACjB,CAAC,CAAC;AAEH,M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CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjF,CAAC;IAED,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,KAAc;QAC9C,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,KAAa;QACxC,IAAI,CAAC,QAAgB,EAAE,WAAW,EAAE,CAAC,oBAAoB,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IAC5E,CAAC;CACF;AAED,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC/B,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACrC,qBAAqB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC"}
package/index.d.ts CHANGED
@@ -5,12 +5,27 @@ export declare const srcProperty: Property<WebViewX, string>;
5
5
  export declare const debugModeProperty: Property<WebViewX, boolean>;
6
6
  export declare const supportPopupsProperty: Property<WebViewX, boolean>;
7
7
 
8
+ export * from './common';
9
+ import { LoadStartedEventData, LoadFinishedEventData, LoadProgressEventData, TitleChangedEventData } from './common';
10
+
8
11
  export declare class WebViewX extends View {
9
- static userAgentTransform: ((defaultUA: string | null) => string | null) | null;
10
12
  static readonly popupNavigateEvent: string;
13
+ static readonly loadStartedEvent: string;
14
+ static readonly loadFinishedEvent: string;
15
+ static readonly loadProgressEvent: string;
16
+ static readonly titleChangedEvent: string;
17
+
11
18
  src: string;
12
19
  debugMode: boolean;
13
20
  supportPopups: boolean;
14
- getUserAgentOverride(): string | null;
15
- setUserAgentOverride(ua: string | null): void;
21
+ userAgent: string;
22
+
23
+ on(event: 'loadStarted', callback: (args: LoadStartedEventData) => void, thisArg?: any): void;
24
+ on(event: 'loadFinished', callback: (args: LoadFinishedEventData) => void, thisArg?: any): void;
25
+ on(event: 'loadProgress', callback: (args: LoadProgressEventData) => void, thisArg?: any): void;
26
+ on(event: 'titleChanged', callback: (args: TitleChangedEventData) => void, thisArg?: any): void;
27
+ on(event: string, callback: (args: any) => void, thisArg?: any): void;
28
+
29
+ /** Returns the current page title (last value received from the engine). */
30
+ getTitle(): Promise<string | undefined>;
16
31
  }
package/index.ios.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  export * from '@nativescript-community/ui-webview/index.ios';
2
2
  import { AWebView } from '@nativescript-community/ui-webview/index.ios';
3
3
  export declare class WebViewX extends AWebView {
4
- static userAgentTransform: ((defaultUA: string | null) => string | null) | null;
5
- initNativeView(): void;
6
- getUserAgentOverride(): string | null;
7
- setUserAgentOverride(ua: string | null): void;
8
4
  }
package/index.ios.js CHANGED
@@ -1,23 +1,5 @@
1
1
  export * from '@nativescript-community/ui-webview/index.ios';
2
2
  import { AWebView } from '@nativescript-community/ui-webview/index.ios';
3
3
  export class WebViewX extends AWebView {
4
- initNativeView() {
5
- super.initNativeView();
6
- if (WebViewX.userAgentTransform) {
7
- const newUA = WebViewX.userAgentTransform(null);
8
- if (newUA !== null && this.nativeViewProtected) {
9
- this.nativeViewProtected.customUserAgent = newUA;
10
- }
11
- }
12
- }
13
- getUserAgentOverride() {
14
- return this.nativeViewProtected?.customUserAgent ?? null;
15
- }
16
- setUserAgentOverride(ua) {
17
- if (this.nativeViewProtected) {
18
- this.nativeViewProtected.customUserAgent = ua || null;
19
- }
20
- }
21
4
  }
22
- WebViewX.userAgentTransform = null;
23
5
  //# sourceMappingURL=index.ios.js.map
package/index.ios.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.ios.js","sourceRoot":"","sources":["../../../packages/webview-x-gecko/index.ios.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAC;AAExE,MAAM,OAAO,QAAS,SAAQ,QAAQ;IAGpC,cAAc;QACZ,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,QAAQ,CAAC,kBAAkB,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAChD,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC/C,IAAI,CAAC,mBAAmB,CAAC,eAAe,GAAG,KAAK,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,mBAAmB,EAAE,eAAe,IAAI,IAAI,CAAC;IAC3D,CAAC;IAED,oBAAoB,CAAC,EAAiB;QACpC,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,IAAI,CAAC,mBAAmB,CAAC,eAAe,GAAG,EAAE,IAAI,IAAI,CAAC;QACxD,CAAC;IACH,CAAC;;AApBM,2BAAkB,GAAyD,IAAI,CAAC"}
1
+ {"version":3,"file":"index.ios.js","sourceRoot":"","sources":["../../../packages/webview-x-gecko/index.ios.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,8CAA8C,CAAC;AAExE,MAAM,OAAO,QAAS,SAAQ,QAAQ;CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modos189/nativescript-webview-x-gecko",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Add a plugin description",
5
5
  "main": "index",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,59 @@
1
+ package com.modos189.webviewxgecko;
2
+
3
+ import org.mozilla.geckoview.GeckoSession;
4
+
5
+ /**
6
+ * NativeScript cannot generate runtime DEX proxies for GeckoView interfaces directly
7
+ * (Java 8 default methods + @UiThread annotations break the DEX factory).
8
+ * Each delegate accepts a simple custom listener that NativeScript can proxy instead.
9
+ */
10
+ public class GeckoDelegates {
11
+
12
+ public interface ProgressListener {
13
+ void onPageStart(String url);
14
+ void onPageStop(boolean success);
15
+ void onProgressChange(int progress);
16
+ }
17
+
18
+ public interface ContentListener {
19
+ void onTitleChange(String title);
20
+ }
21
+
22
+ public static class ProgressDelegate implements GeckoSession.ProgressDelegate {
23
+ private final ProgressListener listener;
24
+
25
+ public ProgressDelegate(ProgressListener listener) {
26
+ this.listener = listener;
27
+ }
28
+
29
+ @Override
30
+ public void onPageStart(GeckoSession session, String url) {
31
+ if (listener != null) listener.onPageStart(url != null ? url : "");
32
+ }
33
+
34
+ @Override
35
+ public void onPageStop(GeckoSession session, boolean success) {
36
+ if (listener != null) listener.onPageStop(success);
37
+ }
38
+
39
+ @Override
40
+ public void onProgressChange(GeckoSession session, int progress) {
41
+ if (listener != null) listener.onProgressChange(progress);
42
+ }
43
+ }
44
+
45
+ public static class ContentDelegate implements GeckoSession.ContentDelegate {
46
+ private final ContentListener listener;
47
+
48
+ public ContentDelegate(ContentListener listener) {
49
+ this.listener = listener;
50
+ }
51
+
52
+ @Override
53
+ public void onTitleChange(GeckoSession session, String title) {
54
+ if (listener != null && title != null && !title.isEmpty()) {
55
+ listener.onTitleChange(title);
56
+ }
57
+ }
58
+ }
59
+ }