@capgo/capacitor-updater 8.43.0 → 8.43.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/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +23 -31
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +1 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +13 -0
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +1 -1
- package/package.json +3 -2
|
@@ -84,7 +84,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
84
84
|
private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
|
|
85
85
|
private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
|
|
86
86
|
|
|
87
|
-
private final String pluginVersion = "8.43.
|
|
87
|
+
private final String pluginVersion = "8.43.2";
|
|
88
88
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
89
89
|
|
|
90
90
|
private SharedPreferences.Editor editor;
|
|
@@ -165,14 +165,6 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
private JSObject mapToJSObject(Map<String, Object> map) {
|
|
169
|
-
JSObject jsObject = new JSObject();
|
|
170
|
-
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
171
|
-
jsObject.put(entry.getKey(), entry.getValue());
|
|
172
|
-
}
|
|
173
|
-
return jsObject;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
168
|
private void persistLastFailedBundle(BundleInfo bundle) {
|
|
177
169
|
if (this.prefs == null) {
|
|
178
170
|
return;
|
|
@@ -264,7 +256,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
264
256
|
public void notifyListeners(final String id, final Map<String, Object> res) {
|
|
265
257
|
if (activity != null) {
|
|
266
258
|
activity.runOnUiThread(() -> {
|
|
267
|
-
CapacitorUpdaterPlugin.this.notifyListeners(id,
|
|
259
|
+
CapacitorUpdaterPlugin.this.notifyListeners(id, InternalUtils.mapToJSObject(res));
|
|
268
260
|
});
|
|
269
261
|
} else {
|
|
270
262
|
logger.warn("notifyListeners: Activity is null, skipping notification for event: " + id);
|
|
@@ -519,7 +511,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
519
511
|
private void sendReadyToJs(final BundleInfo current, final String msg, final boolean isDirectUpdate) {
|
|
520
512
|
logger.info("sendReadyToJs: " + msg);
|
|
521
513
|
final JSObject ret = new JSObject();
|
|
522
|
-
ret.put("bundle", mapToJSObject(current.toJSONMap()));
|
|
514
|
+
ret.put("bundle", InternalUtils.mapToJSObject(current.toJSONMap()));
|
|
523
515
|
ret.put("status", msg);
|
|
524
516
|
|
|
525
517
|
// No need to wait for semaphore anymore since _reload() has already waited
|
|
@@ -862,7 +854,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
862
854
|
final JSObject ret = new JSObject();
|
|
863
855
|
ret.put("percent", percent);
|
|
864
856
|
final BundleInfo bundleInfo = this.implementation.getBundleInfo(id);
|
|
865
|
-
ret.put("bundle", mapToJSObject(bundleInfo.toJSONMap()));
|
|
857
|
+
ret.put("bundle", InternalUtils.mapToJSObject(bundleInfo.toJSONMap()));
|
|
866
858
|
this.notifyListeners("download", ret);
|
|
867
859
|
|
|
868
860
|
if (percent == 100) {
|
|
@@ -1014,7 +1006,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1014
1006
|
DEFAULT_CHANNEL_PREF_KEY,
|
|
1015
1007
|
configDefaultChannel,
|
|
1016
1008
|
(res) -> {
|
|
1017
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1009
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1018
1010
|
if (jsRes.has("error")) {
|
|
1019
1011
|
String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
|
|
1020
1012
|
String errorCode = jsRes.getString("error");
|
|
@@ -1067,7 +1059,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1067
1059
|
DEFAULT_CHANNEL_PREF_KEY,
|
|
1068
1060
|
CapacitorUpdaterPlugin.this.allowSetDefaultChannel,
|
|
1069
1061
|
(res) -> {
|
|
1070
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1062
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1071
1063
|
if (jsRes.has("error")) {
|
|
1072
1064
|
String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
|
|
1073
1065
|
String errorCode = jsRes.getString("error");
|
|
@@ -1115,7 +1107,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1115
1107
|
logger.info("getChannel");
|
|
1116
1108
|
startNewThread(() ->
|
|
1117
1109
|
CapacitorUpdaterPlugin.this.implementation.getChannel((res) -> {
|
|
1118
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1110
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1119
1111
|
if (jsRes.has("error")) {
|
|
1120
1112
|
String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
|
|
1121
1113
|
String errorCode = jsRes.getString("error");
|
|
@@ -1142,7 +1134,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1142
1134
|
logger.info("listChannels");
|
|
1143
1135
|
startNewThread(() ->
|
|
1144
1136
|
CapacitorUpdaterPlugin.this.implementation.listChannels((res) -> {
|
|
1145
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1137
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1146
1138
|
if (jsRes.has("error")) {
|
|
1147
1139
|
String errorMessage = jsRes.has("message") ? jsRes.getString("message") : jsRes.getString("error");
|
|
1148
1140
|
String errorCode = jsRes.getString("error");
|
|
@@ -1192,7 +1184,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1192
1184
|
// Return immediately with a pending status - the actual result will come via listeners
|
|
1193
1185
|
final String id = CapacitorUpdaterPlugin.this.implementation.randomString();
|
|
1194
1186
|
downloaded = new BundleInfo(id, version, BundleStatus.DOWNLOADING, new Date(System.currentTimeMillis()), "");
|
|
1195
|
-
call.resolve(mapToJSObject(downloaded.toJSONMap()));
|
|
1187
|
+
call.resolve(InternalUtils.mapToJSObject(downloaded.toJSONMap()));
|
|
1196
1188
|
return;
|
|
1197
1189
|
} else {
|
|
1198
1190
|
downloaded = CapacitorUpdaterPlugin.this.implementation.download(url, version, sessionKey, checksum);
|
|
@@ -1200,7 +1192,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1200
1192
|
if (downloaded.isErrorStatus()) {
|
|
1201
1193
|
throw new RuntimeException("Download failed: " + downloaded.getStatus());
|
|
1202
1194
|
} else {
|
|
1203
|
-
call.resolve(mapToJSObject(downloaded.toJSONMap()));
|
|
1195
|
+
call.resolve(InternalUtils.mapToJSObject(downloaded.toJSONMap()));
|
|
1204
1196
|
}
|
|
1205
1197
|
} catch (final Exception e) {
|
|
1206
1198
|
logger.error("Failed to download from: " + url + " " + e.getMessage());
|
|
@@ -1374,7 +1366,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1374
1366
|
logger.error("Set next id failed. Bundle " + id + " does not exist.");
|
|
1375
1367
|
call.reject("Set next id failed. Bundle " + id + " does not exist.");
|
|
1376
1368
|
} else {
|
|
1377
|
-
call.resolve(mapToJSObject(this.implementation.getBundleInfo(id).toJSONMap()));
|
|
1369
|
+
call.resolve(InternalUtils.mapToJSObject(this.implementation.getBundleInfo(id).toJSONMap()));
|
|
1378
1370
|
}
|
|
1379
1371
|
} catch (final Exception e) {
|
|
1380
1372
|
logger.error("Could not set next id " + id + " " + e.getMessage());
|
|
@@ -1458,7 +1450,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1458
1450
|
}
|
|
1459
1451
|
this.implementation.setError(bundle);
|
|
1460
1452
|
final JSObject ret = new JSObject();
|
|
1461
|
-
ret.put("bundle", mapToJSObject(this.implementation.getBundleInfo(id).toJSONMap()));
|
|
1453
|
+
ret.put("bundle", InternalUtils.mapToJSObject(this.implementation.getBundleInfo(id).toJSONMap()));
|
|
1462
1454
|
call.resolve(ret);
|
|
1463
1455
|
} catch (final Exception e) {
|
|
1464
1456
|
logger.error("Could not set bundle error for id " + id + " " + e.getMessage());
|
|
@@ -1473,7 +1465,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1473
1465
|
final JSObject ret = new JSObject();
|
|
1474
1466
|
final JSArray values = new JSArray();
|
|
1475
1467
|
for (final BundleInfo bundle : res) {
|
|
1476
|
-
values.put(mapToJSObject(bundle.toJSONMap()));
|
|
1468
|
+
values.put(InternalUtils.mapToJSObject(bundle.toJSONMap()));
|
|
1477
1469
|
}
|
|
1478
1470
|
ret.put("bundles", values);
|
|
1479
1471
|
call.resolve(ret);
|
|
@@ -1488,7 +1480,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1488
1480
|
final String channel = call.getString("channel");
|
|
1489
1481
|
startNewThread(() ->
|
|
1490
1482
|
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, channel, (res) -> {
|
|
1491
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1483
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1492
1484
|
if (jsRes.has("error")) {
|
|
1493
1485
|
String error = jsRes.getString("error");
|
|
1494
1486
|
String errorMessage = jsRes.has("message") ? jsRes.getString("message") : "server did not provide a message";
|
|
@@ -1540,7 +1532,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1540
1532
|
try {
|
|
1541
1533
|
final JSObject ret = new JSObject();
|
|
1542
1534
|
final BundleInfo bundle = this.implementation.getCurrentBundle();
|
|
1543
|
-
ret.put("bundle", mapToJSObject(bundle.toJSONMap()));
|
|
1535
|
+
ret.put("bundle", InternalUtils.mapToJSObject(bundle.toJSONMap()));
|
|
1544
1536
|
ret.put("native", this.currentVersionNative);
|
|
1545
1537
|
call.resolve(ret);
|
|
1546
1538
|
} catch (final Exception e) {
|
|
@@ -1558,7 +1550,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1558
1550
|
return;
|
|
1559
1551
|
}
|
|
1560
1552
|
|
|
1561
|
-
call.resolve(mapToJSObject(bundle.toJSONMap()));
|
|
1553
|
+
call.resolve(InternalUtils.mapToJSObject(bundle.toJSONMap()));
|
|
1562
1554
|
} catch (final Exception e) {
|
|
1563
1555
|
logger.error("Could not get next bundle " + e.getMessage());
|
|
1564
1556
|
call.reject("Could not get next bundle", e);
|
|
@@ -1577,7 +1569,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1577
1569
|
this.persistLastFailedBundle(null);
|
|
1578
1570
|
|
|
1579
1571
|
final JSObject ret = new JSObject();
|
|
1580
|
-
ret.put("bundle", mapToJSObject(bundle.toJSONMap()));
|
|
1572
|
+
ret.put("bundle", InternalUtils.mapToJSObject(bundle.toJSONMap()));
|
|
1581
1573
|
call.resolve(ret);
|
|
1582
1574
|
} catch (final Exception e) {
|
|
1583
1575
|
logger.error("Could not get failed update " + e.getMessage());
|
|
@@ -1596,7 +1588,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1596
1588
|
public void run() {
|
|
1597
1589
|
try {
|
|
1598
1590
|
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, null, (res) -> {
|
|
1599
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1591
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1600
1592
|
if (jsRes.has("error")) {
|
|
1601
1593
|
String error = jsRes.getString("error");
|
|
1602
1594
|
String errorMessage = jsRes.has("message")
|
|
@@ -1638,7 +1630,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1638
1630
|
this.semaphoreDown();
|
|
1639
1631
|
logger.info("semaphoreReady countDown done");
|
|
1640
1632
|
final JSObject ret = new JSObject();
|
|
1641
|
-
ret.put("bundle", mapToJSObject(bundle.toJSONMap()));
|
|
1633
|
+
ret.put("bundle", InternalUtils.mapToJSObject(bundle.toJSONMap()));
|
|
1642
1634
|
call.resolve(ret);
|
|
1643
1635
|
} catch (final Exception e) {
|
|
1644
1636
|
logger.error("Failed to notify app ready state. [Error calling 'notifyAppReady()'] " + e.getMessage());
|
|
@@ -1802,7 +1794,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1802
1794
|
this.notifyListeners(failureEvent, ret);
|
|
1803
1795
|
}
|
|
1804
1796
|
final JSObject ret = new JSObject();
|
|
1805
|
-
ret.put("bundle", mapToJSObject(current.toJSONMap()));
|
|
1797
|
+
ret.put("bundle", InternalUtils.mapToJSObject(current.toJSONMap()));
|
|
1806
1798
|
this.notifyListeners("noNeedUpdate", ret);
|
|
1807
1799
|
this.sendReadyToJs(current, msg, isDirectUpdate);
|
|
1808
1800
|
this.backgroundDownloadTask = null;
|
|
@@ -1848,7 +1840,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1848
1840
|
logger.info("Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
|
|
1849
1841
|
try {
|
|
1850
1842
|
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, null, (res) -> {
|
|
1851
|
-
JSObject jsRes = mapToJSObject(res);
|
|
1843
|
+
JSObject jsRes = InternalUtils.mapToJSObject(res);
|
|
1852
1844
|
final BundleInfo current = CapacitorUpdaterPlugin.this.implementation.getCurrentBundle();
|
|
1853
1845
|
|
|
1854
1846
|
// Handle network errors and other failures first
|
|
@@ -1930,7 +1922,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1930
1922
|
final BundleInfo latest = CapacitorUpdaterPlugin.this.implementation.getBundleInfoByName(latestVersionName);
|
|
1931
1923
|
if (latest != null) {
|
|
1932
1924
|
final JSObject ret = new JSObject();
|
|
1933
|
-
ret.put("bundle", mapToJSObject(latest.toJSONMap()));
|
|
1925
|
+
ret.put("bundle", InternalUtils.mapToJSObject(latest.toJSONMap()));
|
|
1934
1926
|
if (latest.isErrorStatus()) {
|
|
1935
1927
|
logger.error("Latest bundle already exists, and is in error state. Aborting update.");
|
|
1936
1928
|
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
@@ -2119,7 +2111,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
2119
2111
|
logger.error("notifyAppReady was not called, roll back current bundle: " + current.getId());
|
|
2120
2112
|
logger.info("Did you forget to call 'notifyAppReady()' in your Capacitor App code?");
|
|
2121
2113
|
final JSObject ret = new JSObject();
|
|
2122
|
-
ret.put("bundle", mapToJSObject(current.toJSONMap()));
|
|
2114
|
+
ret.put("bundle", InternalUtils.mapToJSObject(current.toJSONMap()));
|
|
2123
2115
|
this.persistLastFailedBundle(current);
|
|
2124
2116
|
this.notifyListeners("updateFailed", ret);
|
|
2125
2117
|
this.implementation.sendStats("update_fail", current.getVersionName());
|
|
@@ -573,7 +573,7 @@ public class CapgoUpdater {
|
|
|
573
573
|
this.notifyDownload(id, 100);
|
|
574
574
|
|
|
575
575
|
final Map<String, Object> ret = new HashMap<>();
|
|
576
|
-
ret.put("bundle", next.toJSONMap());
|
|
576
|
+
ret.put("bundle", InternalUtils.mapToJSObject(next.toJSONMap()));
|
|
577
577
|
logger.info("updateAvailable: " + ret);
|
|
578
578
|
CapgoUpdater.this.notifyListeners("updateAvailable", ret);
|
|
579
579
|
logger.info("setNext: " + setNext);
|
|
@@ -3,9 +3,22 @@ package ee.forgr.capacitor_updater;
|
|
|
3
3
|
import android.content.pm.PackageInfo;
|
|
4
4
|
import android.content.pm.PackageManager;
|
|
5
5
|
import android.os.Build;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import java.util.Map;
|
|
6
8
|
|
|
7
9
|
public class InternalUtils {
|
|
8
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Converts a Map to JSObject for proper bridge serialization.
|
|
13
|
+
*/
|
|
14
|
+
public static JSObject mapToJSObject(Map<String, Object> map) {
|
|
15
|
+
JSObject jsObject = new JSObject();
|
|
16
|
+
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
17
|
+
jsObject.put(entry.getKey(), entry.getValue());
|
|
18
|
+
}
|
|
19
|
+
return jsObject;
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
public static String getPackageName(PackageManager pm, String packageName) {
|
|
10
23
|
try {
|
|
11
24
|
PackageInfo pInfo = getPackageInfoInternal(pm, packageName);
|
|
@@ -73,7 +73,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
73
73
|
CAPPluginMethod(name: "completeFlexibleUpdate", returnType: CAPPluginReturnPromise)
|
|
74
74
|
]
|
|
75
75
|
public var implementation = CapgoUpdater()
|
|
76
|
-
private let pluginVersion: String = "8.43.
|
|
76
|
+
private let pluginVersion: String = "8.43.2"
|
|
77
77
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
78
78
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
79
79
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-updater",
|
|
3
|
-
"version": "8.43.
|
|
3
|
+
"version": "8.43.2",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Live update for capacitor apps",
|
|
6
6
|
"main": "dist/plugin.cjs.js",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
58
58
|
"clean": "rimraf ./dist",
|
|
59
59
|
"watch": "tsc --watch",
|
|
60
|
-
"prepublishOnly": "npm run build"
|
|
60
|
+
"prepublishOnly": "npm run build",
|
|
61
|
+
"check:wiring": "node scripts/check-capacitor-plugin-wiring.mjs"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@capacitor/android": "^8.0.0",
|