@capgo/capacitor-webview-version-checker 8.0.0 → 8.2.0
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 +88 -17
- package/android/build.gradle +1 -1
- package/android/src/main/java/app/capgo/webviewversionchecker/GeneratedVersionShareData.java +28 -0
- package/android/src/main/java/app/capgo/webviewversionchecker/WebviewVersionCheckerPlugin.java +533 -34
- package/dist/docs.json +28 -0
- package/dist/esm/definitions.d.ts +104 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/generated-version-share.d.ts +9 -0
- package/dist/esm/generated-version-share.js +106 -0
- package/dist/esm/generated-version-share.js.map +1 -0
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +86 -10
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +190 -10
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +190 -10
- package/dist/plugin.js.map +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<h2><a href="https://capgo.app/consulting/?ref=plugin_webview_version_checker"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
Capacitor plugin
|
|
9
|
+
Capacitor plugin for checking whether the app WebView engine is up to date, emitting realtime status events, and optionally showing a native update prompt that redirects users to the proper update destination.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -17,7 +17,45 @@ bunx cap sync
|
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Main use case: Browserslist-style compatibility checks by default.
|
|
21
|
+
|
|
22
|
+
The plugin uses this strategy out of the box, even if you do not add any plugin options:
|
|
23
|
+
- `minimumDeviceSharePercent` defaults to `3`
|
|
24
|
+
- version-share data comes from a built-in dataset generated at build time from caniuse
|
|
25
|
+
- no runtime version-share URL call is required for the default flow
|
|
26
|
+
|
|
27
|
+
Default setup (no plugin settings):
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import type { CapacitorConfig } from '@capacitor/cli';
|
|
31
|
+
|
|
32
|
+
const config: CapacitorConfig = {
|
|
33
|
+
plugins: {
|
|
34
|
+
WebviewVersionChecker: {},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default config;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Simple config-only setup with native prompt:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import type { CapacitorConfig } from '@capacitor/cli';
|
|
45
|
+
|
|
46
|
+
const config: CapacitorConfig = {
|
|
47
|
+
plugins: {
|
|
48
|
+
WebviewVersionChecker: {
|
|
49
|
+
autoPromptOnOutdated: true,
|
|
50
|
+
autoPromptDismissible: false,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default config;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Advanced mode with custom threshold and custom dataset:
|
|
21
59
|
|
|
22
60
|
```ts
|
|
23
61
|
import type { CapacitorConfig } from '@capacitor/cli';
|
|
@@ -26,8 +64,14 @@ const config: CapacitorConfig = {
|
|
|
26
64
|
plugins: {
|
|
27
65
|
WebviewVersionChecker: {
|
|
28
66
|
autoCheckOnLoad: true,
|
|
29
|
-
autoCheckOnResume: true,
|
|
30
67
|
autoPromptOnOutdated: true,
|
|
68
|
+
minimumDeviceSharePercent: 3,
|
|
69
|
+
versionShareByMajor: {
|
|
70
|
+
'137': 58.2,
|
|
71
|
+
'136': 21.3,
|
|
72
|
+
'135': 4.6,
|
|
73
|
+
'134': 2.1,
|
|
74
|
+
},
|
|
31
75
|
},
|
|
32
76
|
},
|
|
33
77
|
};
|
|
@@ -35,6 +79,27 @@ const config: CapacitorConfig = {
|
|
|
35
79
|
export default config;
|
|
36
80
|
```
|
|
37
81
|
|
|
82
|
+
What this means:
|
|
83
|
+
- `minimumDeviceSharePercent: 3` means "consider a version compatible only if that major version still represents at least 3% of devices in my dataset".
|
|
84
|
+
- `versionShareByMajor` is your own dataset map where:
|
|
85
|
+
- key = major version (for example `137`)
|
|
86
|
+
- value = share percent (`0..100`)
|
|
87
|
+
- If you do not provide `versionShareByMajor`, the plugin uses its built-in generated dataset.
|
|
88
|
+
|
|
89
|
+
You can provide share data in two ways:
|
|
90
|
+
- Inline with `versionShareByMajor` (as shown above)
|
|
91
|
+
- Remote with `versionShareApiUrl` returning one of these shapes:
|
|
92
|
+
- `{ "versionShareByMajor": { "137": 54.2, "136": 23.8 } }`
|
|
93
|
+
- `{ "shareByMajor": { "137": 54.2, "136": 23.8 } }`
|
|
94
|
+
- `{ "versions": [{ "major": 137, "share": 54.2 }, { "version": "136.0.0.0", "percent": 23.8 }] }`
|
|
95
|
+
|
|
96
|
+
If you set `versionShareApiUrl`, the plugin fetches that URL at runtime and uses it as override.
|
|
97
|
+
|
|
98
|
+
Evaluation order:
|
|
99
|
+
1. Browserslist-style threshold mode (`minimumDeviceSharePercent` + share dataset) is used first. By default this is `3%` with the built-in generated dataset.
|
|
100
|
+
2. Else the plugin compares against `latestVersion` / `latestVersionApiUrl`.
|
|
101
|
+
3. Else it falls back to `minimumMajorVersion`.
|
|
102
|
+
|
|
38
103
|
Advanced usage with JavaScript (manual check, listeners, custom prompt):
|
|
39
104
|
|
|
40
105
|
```ts
|
|
@@ -49,6 +114,7 @@ const status = await WebviewVersionChecker.check({
|
|
|
49
114
|
'https://versionhistory.googleapis.com/v1/chrome/platforms/android/channels/stable/versions?page_size=1',
|
|
50
115
|
minimumMajorVersion: 124,
|
|
51
116
|
showPromptOnOutdated: true,
|
|
117
|
+
autoPromptDismissible: false,
|
|
52
118
|
promptTitle: 'Update WebView',
|
|
53
119
|
promptMessage: 'Your WebView is outdated. Please update to continue safely.',
|
|
54
120
|
promptUpdateButtonText: 'Update now',
|
|
@@ -86,6 +152,7 @@ export default config;
|
|
|
86
152
|
- With `server.errorPath`, users are redirected to a static error page (hard block UX) instead of seeing a native modal in your normal app flow.
|
|
87
153
|
- Without `server.errorPath`, Capacitor only logs the issue, but does not provide a native update prompt + store deep link UX.
|
|
88
154
|
- This plugin gives soft enforcement: users can still open/use the app, get a native update modal, and you decide whether to require update later.
|
|
155
|
+
- Main use case: this plugin brings Browserslist-style compatibility logic to Android WebView (for example, "support versions still used by at least 3% of devices"), while keeping your app usable.
|
|
89
156
|
|
|
90
157
|
## Android Provider Handling
|
|
91
158
|
|
|
@@ -273,20 +340,24 @@ Fired when the state resolves to `outdated`.
|
|
|
273
340
|
|
|
274
341
|
Snapshot of the currently detected WebView status.
|
|
275
342
|
|
|
276
|
-
| Prop
|
|
277
|
-
|
|
|
278
|
-
| **`platform`**
|
|
279
|
-
| **`state`**
|
|
280
|
-
| **`isLatest`**
|
|
281
|
-
| **`checkedAt`**
|
|
282
|
-
| **`reason`**
|
|
283
|
-
| **`currentVersion`**
|
|
284
|
-
| **`currentMajorVersion`**
|
|
285
|
-
| **`latestVersion`**
|
|
286
|
-
| **`latestMajorVersion`**
|
|
287
|
-
| **`
|
|
288
|
-
| **`
|
|
289
|
-
| **`
|
|
343
|
+
| Prop | Type | Description |
|
|
344
|
+
| -------------------------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
345
|
+
| **`platform`** | <code><a href="#webviewplatform">WebViewPlatform</a></code> | Native platform that generated the status. |
|
|
346
|
+
| **`state`** | <code><a href="#webviewversionstate">WebViewVersionState</a></code> | Resolved version state. |
|
|
347
|
+
| **`isLatest`** | <code>boolean</code> | Convenience boolean equivalent to `state === 'latest'`. |
|
|
348
|
+
| **`checkedAt`** | <code>string</code> | ISO-8601 timestamp of the check. |
|
|
349
|
+
| **`reason`** | <code>string</code> | Human-readable explanation for the reported state. |
|
|
350
|
+
| **`currentVersion`** | <code>string</code> | Current WebView (or iOS system WebKit) version string. |
|
|
351
|
+
| **`currentMajorVersion`** | <code>number</code> | Current detected major version (if parseable). |
|
|
352
|
+
| **`latestVersion`** | <code>string</code> | Resolved latest version used for comparison. |
|
|
353
|
+
| **`latestMajorVersion`** | <code>number</code> | Resolved latest major version (if parseable). |
|
|
354
|
+
| **`currentVersionSharePercent`** | <code>number</code> | Device-share percentage for the installed WebView major version. Present only when a version-share dataset is available and includes the current major version. |
|
|
355
|
+
| **`minimumDeviceSharePercent`** | <code>number</code> | Configured threshold used by compatibility-threshold mode. Present only when `minimumDeviceSharePercent` was requested for that check. |
|
|
356
|
+
| **`versionShareSource`** | <code>string</code> | Source used for version-share data. Values: - `versionShareByMajor` (inline dataset) - `versionShareApiUrl` (remote dataset) - `generatedVersionShareByMajor` (built-in dataset generated at build time) |
|
|
357
|
+
| **`deviceShareError`** | <code>string</code> | Diagnostic message for compatibility-threshold mode. Present when `minimumDeviceSharePercent` was requested but the threshold check could not be fully evaluated. |
|
|
358
|
+
| **`providerPackage`** | <code>string</code> | Android package name of the active WebView provider. |
|
|
359
|
+
| **`updateUrl`** | <code>string</code> | URL that should be opened to update when outdated. |
|
|
360
|
+
| **`source`** | <code>string</code> | Internal source identifier for the check implementation. |
|
|
290
361
|
|
|
291
362
|
|
|
292
363
|
#### CheckWebViewOptions
|
package/android/build.gradle
CHANGED
|
@@ -31,7 +31,7 @@ android {
|
|
|
31
31
|
buildTypes {
|
|
32
32
|
release {
|
|
33
33
|
minifyEnabled false
|
|
34
|
-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
lintOptions {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package app.capgo.webviewversionchecker;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONObject;
|
|
4
|
+
|
|
5
|
+
final class GeneratedVersionShareData {
|
|
6
|
+
|
|
7
|
+
private static final String GENERATED_AT = "2026-02-22T16:25:02.516Z";
|
|
8
|
+
private static final String DATA_SOURCE = "generatedVersionShareByMajor";
|
|
9
|
+
private static final String JSON_DATA = "{\"4\":0.000092,\"39\":0.004796,\"40\":0.004796,\"41\":0.009592,\"42\":0.004796,\"43\":0.004796,\"44\":0.004796,\"45\":0.009592,\"46\":0.004796,\"47\":0.009592,\"48\":0.014388,\"49\":0.014388,\"50\":0.009592,\"51\":0.009592,\"52\":0.014388,\"53\":0.009592,\"54\":0.004796,\"55\":0.009592,\"56\":0.009592,\"57\":0.009592,\"58\":0.009592,\"59\":0.009592,\"60\":0.014388,\"61\":0.004796,\"62\":0.009592,\"63\":0.009592,\"64\":0.009592,\"65\":0.004796,\"66\":0.02398,\"67\":0.009592,\"68\":0.009592,\"69\":0.033572,\"70\":0.009592,\"75\":0.004796,\"77\":0.004796,\"79\":0.067144,\"80\":0.009592,\"81\":0.009592,\"83\":0.043164,\"85\":0.004796,\"86\":0.009592,\"87\":0.028776,\"88\":0.004796,\"91\":0.019184,\"92\":0.014388,\"93\":0.009592,\"97\":0.009592,\"98\":0.04796,\"99\":0.043164,\"101\":0.014388,\"102\":0.009592,\"103\":0.26378,\"104\":0.230208,\"105\":0.273372,\"106\":0.206228,\"107\":0.230208,\"108\":0.230208,\"109\":0.786544,\"110\":0.235004,\"111\":0.292556,\"112\":2.71454,\"113\":0.004796,\"114\":0.062348,\"115\":0.02398,\"116\":0.446028,\"117\":0.282964,\"118\":0.052756,\"119\":0.038368,\"120\":0.31174,\"121\":0.04796,\"122\":0.091124,\"123\":0.062348,\"124\":0.230208,\"125\":0.244596,\"126\":0.052756,\"127\":0.052756,\"128\":0.076736,\"129\":0.067144,\"130\":0.09592,\"131\":0.709808,\"132\":0.139084,\"133\":0.52756,\"134\":0.067144,\"135\":0.067144,\"136\":0.09592,\"137\":0.062348,\"138\":0.235004,\"139\":3.34761,\"140\":0.177452,\"141\":0.398068,\"142\":1.29972,\"143\":10.4121,\"144\":3.76486,\"145\":41.8835}";
|
|
10
|
+
|
|
11
|
+
private GeneratedVersionShareData() {}
|
|
12
|
+
|
|
13
|
+
static JSONObject getDefaultVersionShareByMajor() {
|
|
14
|
+
try {
|
|
15
|
+
return new JSONObject(JSON_DATA);
|
|
16
|
+
} catch (Exception ignored) {
|
|
17
|
+
return new JSONObject();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static String getDataSource() {
|
|
22
|
+
return DATA_SOURCE;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static String getGeneratedAt() {
|
|
26
|
+
return GENERATED_AT;
|
|
27
|
+
}
|
|
28
|
+
}
|