capacitor-ota 1.0.8 → 1.0.9

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.
@@ -55,7 +55,12 @@ var OtaUpdater = class {
55
55
  try {
56
56
  const { CapacitorUpdater } = await import("@capgo/capacitor-updater");
57
57
  const result = await CapacitorUpdater.notifyAppReady();
58
- if (result?.bundle?.version) this.state.currentVersion = result.bundle.version;
58
+ if (result?.bundle?.version) {
59
+ const bundleVersion = result.bundle.version;
60
+ const nativeVersion = this.config.appVersion;
61
+ if (compareVersions(bundleVersion, nativeVersion) > 0) this.state.currentVersion = bundleVersion;
62
+ else this.state.currentVersion = nativeVersion;
63
+ }
59
64
  } catch {}
60
65
  }
61
66
  async check() {
@@ -74,7 +79,9 @@ var OtaUpdater = class {
74
79
  throw new Error(`HTTP ${response.status}`);
75
80
  }
76
81
  const data = await response.json();
77
- if (compareVersions(data.version, this.state.currentVersion) > 0) {
82
+ const isNewer = compareVersions(data.version, this.state.currentVersion) > 0;
83
+ const isNewerThanNative = compareVersions(data.version, this.config.appVersion) > 0;
84
+ if (isNewer && isNewerThanNative) {
78
85
  this.setState({ newVersion: data.version });
79
86
  this.emit("updateAvailable", {
80
87
  currentVersion: this.state.currentVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-ota",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.mjs",
6
6
  "types": "dist/src/index.d.mts",