@capgo/capacitor-updater 4.0.0-alpha.1 → 4.0.0-alpha.10
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 +33 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +15 -17
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +33 -8
- package/dist/docs.json +106 -1
- package/dist/esm/definitions.d.ts +26 -3
- package/dist/esm/web.d.ts +2 -1
- package/dist/esm/web.js +7 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +7 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +7 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorUpdater.swift +35 -14
- package/ios/Plugin/CapacitorUpdaterPlugin.m +1 -0
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +31 -24
- package/ios/Plugin/ObjectPreferences.swift +1 -57
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,7 @@ Capacitor Updator works by unzipping a compiled app bundle to the native device
|
|
|
127
127
|
* [`current()`](#current)
|
|
128
128
|
* [`reload()`](#reload)
|
|
129
129
|
* [`setDelay(...)`](#setdelay)
|
|
130
|
+
* [`getLatest(...)`](#getlatest)
|
|
130
131
|
* [`addListener('download', ...)`](#addlistenerdownload)
|
|
131
132
|
* [`addListener('downloadComplete', ...)`](#addlistenerdownloadcomplete)
|
|
132
133
|
* [`addListener('majorAvailable', ...)`](#addlistenermajoravailable)
|
|
@@ -285,6 +286,27 @@ Set delay to skip updates in the next time the app goes into the background
|
|
|
285
286
|
| ------------- | -------------------------------- |
|
|
286
287
|
| **`options`** | <code>{ delay: boolean; }</code> |
|
|
287
288
|
|
|
289
|
+
**Since:** 4.0.0
|
|
290
|
+
|
|
291
|
+
--------------------
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
### getLatest(...)
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
getLatest(options: { delay: boolean; }) => Promise<latestVersion>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Get Latest version available from update Url
|
|
301
|
+
|
|
302
|
+
| Param | Type |
|
|
303
|
+
| ------------- | -------------------------------- |
|
|
304
|
+
| **`options`** | <code>{ delay: boolean; }</code> |
|
|
305
|
+
|
|
306
|
+
**Returns:** <code>Promise<<a href="#latestversion">latestVersion</a>></code>
|
|
307
|
+
|
|
308
|
+
**Since:** 4.0.0
|
|
309
|
+
|
|
288
310
|
--------------------
|
|
289
311
|
|
|
290
312
|
|
|
@@ -445,6 +467,17 @@ removeAllListeners() => Promise<void>
|
|
|
445
467
|
| **`status`** | <code><a href="#bundlestatus">BundleStatus</a></code> |
|
|
446
468
|
|
|
447
469
|
|
|
470
|
+
#### latestVersion
|
|
471
|
+
|
|
472
|
+
| Prop | Type | Description | Since |
|
|
473
|
+
| ------------- | -------------------- | ----------------------- | ----- |
|
|
474
|
+
| **`version`** | <code>string</code> | Res of getLatest method | 4.0.0 |
|
|
475
|
+
| **`major`** | <code>boolean</code> | | |
|
|
476
|
+
| **`message`** | <code>string</code> | | |
|
|
477
|
+
| **`old`** | <code>string</code> | | |
|
|
478
|
+
| **`url`** | <code>string</code> | | |
|
|
479
|
+
|
|
480
|
+
|
|
448
481
|
#### PluginListenerHandle
|
|
449
482
|
|
|
450
483
|
| Prop | Type |
|
|
@@ -46,7 +46,7 @@ public class CapacitorUpdater {
|
|
|
46
46
|
private static final String bundleDirectory = "versions";
|
|
47
47
|
|
|
48
48
|
public static final String TAG = "Capacitor-updater";
|
|
49
|
-
public static final String pluginVersion = "4.0.0-alpha.
|
|
49
|
+
public static final String pluginVersion = "4.0.0-alpha.10";
|
|
50
50
|
|
|
51
51
|
public SharedPreferences.Editor editor;
|
|
52
52
|
public SharedPreferences prefs;
|
|
@@ -255,7 +255,7 @@ public class CapacitorUpdater {
|
|
|
255
255
|
return true;
|
|
256
256
|
}
|
|
257
257
|
Log.e(TAG, "Directory not removed: " + bundle.getPath());
|
|
258
|
-
this.sendStats("delete", deleted);
|
|
258
|
+
this.sendStats("delete", deleted.getVersionName());
|
|
259
259
|
return false;
|
|
260
260
|
}
|
|
261
261
|
|
|
@@ -263,11 +263,11 @@ public class CapacitorUpdater {
|
|
|
263
263
|
return new File(this.documentsDir, bundleDirectory + "/" + id);
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
private boolean bundleExists(final
|
|
266
|
+
private boolean bundleExists(final String id) {
|
|
267
|
+
final File bundle = this.getBundleDirectory(id);
|
|
267
268
|
if(bundle == null || !bundle.exists()) {
|
|
268
269
|
return false;
|
|
269
270
|
}
|
|
270
|
-
|
|
271
271
|
return new File(bundle.getPath(), "/index.html").exists();
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -277,17 +277,17 @@ public class CapacitorUpdater {
|
|
|
277
277
|
|
|
278
278
|
public Boolean set(final String id) {
|
|
279
279
|
|
|
280
|
-
final BundleInfo
|
|
280
|
+
final BundleInfo newBundle = this.getBundleInfo(id);
|
|
281
281
|
final File bundle = this.getBundleDirectory(id);
|
|
282
282
|
|
|
283
|
-
Log.i(TAG, "Setting next active bundle: " +
|
|
284
|
-
if (this.bundleExists(
|
|
283
|
+
Log.i(TAG, "Setting next active bundle: " + id);
|
|
284
|
+
if (this.bundleExists(id)) {
|
|
285
285
|
this.setCurrentBundle(bundle);
|
|
286
286
|
this.setBundleStatus(id, BundleStatus.PENDING);
|
|
287
|
-
this.sendStats("set",
|
|
287
|
+
this.sendStats("set", newBundle.getVersionName());
|
|
288
288
|
return true;
|
|
289
289
|
}
|
|
290
|
-
this.sendStats("set_fail",
|
|
290
|
+
this.sendStats("set_fail", newBundle.getVersionName());
|
|
291
291
|
return false;
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -309,7 +309,7 @@ public class CapacitorUpdater {
|
|
|
309
309
|
this.setFallbackVersion(null);
|
|
310
310
|
this.setNextVersion(null);
|
|
311
311
|
if(!internal) {
|
|
312
|
-
this.sendStats("reset", this.getCurrentBundle());
|
|
312
|
+
this.sendStats("reset", this.getCurrentBundle().getVersionName());
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
|
|
@@ -356,7 +356,7 @@ public class CapacitorUpdater {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
public void sendStats(final String action, final
|
|
359
|
+
public void sendStats(final String action, final String versionName) {
|
|
360
360
|
String statsUrl = this.statsUrl;
|
|
361
361
|
if (statsUrl == null || "".equals(statsUrl) || statsUrl.length() == 0) { return; }
|
|
362
362
|
try {
|
|
@@ -367,7 +367,7 @@ public class CapacitorUpdater {
|
|
|
367
367
|
json.put("version_build", this.versionBuild);
|
|
368
368
|
json.put("version_code", this.versionCode);
|
|
369
369
|
json.put("version_os", this.versionOs);
|
|
370
|
-
json.put("version_name",
|
|
370
|
+
json.put("version_name", versionName);
|
|
371
371
|
json.put("plugin_version", pluginVersion);
|
|
372
372
|
json.put("action", action);
|
|
373
373
|
|
|
@@ -379,13 +379,13 @@ public class CapacitorUpdater {
|
|
|
379
379
|
new Response.Listener<JSONObject>() {
|
|
380
380
|
@Override
|
|
381
381
|
public void onResponse(JSONObject response) {
|
|
382
|
-
Log.i(TAG, "Stats send for \"" + action + "\", version " +
|
|
382
|
+
Log.i(TAG, "Stats send for \"" + action + "\", version " + versionName);
|
|
383
383
|
}
|
|
384
384
|
},
|
|
385
385
|
new Response.ErrorListener(){
|
|
386
386
|
@Override
|
|
387
387
|
public void onErrorResponse(VolleyError error) {
|
|
388
|
-
Log.i(TAG, "Stats send for \"" + action + "\", version " +
|
|
388
|
+
Log.i(TAG, "Stats send for \"" + action + "\", version " + versionName);
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
391
|
this.requestQueue.add(request);
|
|
@@ -515,11 +515,9 @@ public class CapacitorUpdater {
|
|
|
515
515
|
if (next == null) {
|
|
516
516
|
this.editor.remove(NEXT_VERSION);
|
|
517
517
|
} else {
|
|
518
|
-
|
|
519
|
-
if (!this.bundleExists(bundle)) {
|
|
518
|
+
if (!this.bundleExists(next)) {
|
|
520
519
|
return false;
|
|
521
520
|
}
|
|
522
|
-
|
|
523
521
|
this.editor.putString(NEXT_VERSION, next);
|
|
524
522
|
this.setBundleStatus(next, BundleStatus.PENDING);
|
|
525
523
|
}
|
|
@@ -28,11 +28,12 @@ import io.github.g00fy2.versioncompare.Version;
|
|
|
28
28
|
import org.json.JSONException;
|
|
29
29
|
|
|
30
30
|
import java.io.IOException;
|
|
31
|
+
import java.util.Iterator;
|
|
31
32
|
import java.util.List;
|
|
32
33
|
|
|
33
34
|
@CapacitorPlugin(name = "CapacitorUpdater")
|
|
34
35
|
public class CapacitorUpdaterPlugin extends Plugin implements Application.ActivityLifecycleCallbacks {
|
|
35
|
-
private static final String
|
|
36
|
+
private static final String updateUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/updates";
|
|
36
37
|
private static final String statsUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/stats";
|
|
37
38
|
private static final String DELAY_UPDATE = "delayUpdate";
|
|
38
39
|
|
|
@@ -44,7 +45,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
44
45
|
private Boolean autoDeleteFailed = true;
|
|
45
46
|
private Boolean autoDeletePrevious = true;
|
|
46
47
|
private Boolean autoUpdate = false;
|
|
47
|
-
private String
|
|
48
|
+
private String updateUrl = "";
|
|
48
49
|
private Version currentVersionNative;
|
|
49
50
|
private Boolean resetWhenUpdate = true;
|
|
50
51
|
|
|
@@ -87,7 +88,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
87
88
|
|
|
88
89
|
this.autoDeleteFailed = this.getConfig().getBoolean("autoDeleteFailed", true);
|
|
89
90
|
this.autoDeletePrevious = this.getConfig().getBoolean("autoDeletePrevious", true);
|
|
90
|
-
this.
|
|
91
|
+
this.updateUrl = this.getConfig().getString("updateUrl", updateUrlDefault);
|
|
91
92
|
this.autoUpdate = this.getConfig().getBoolean("autoUpdate", false);
|
|
92
93
|
this.appReadyTimeout = this.getConfig().getInt("appReadyTimeout", 10000);
|
|
93
94
|
this.resetWhenUpdate = this.getConfig().getBoolean("resetWhenUpdate", true);
|
|
@@ -133,7 +134,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
133
134
|
try {
|
|
134
135
|
final JSObject ret = new JSObject();
|
|
135
136
|
ret.put("percent", percent);
|
|
136
|
-
|
|
137
|
+
JSObject bundle = this.implementation.getBundleInfo(id).toJSON();
|
|
137
138
|
ret.put("bundle", bundle);
|
|
138
139
|
this.notifyListeners("download", ret);
|
|
139
140
|
if (percent == 100) {
|
|
@@ -296,6 +297,30 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
|
|
300
|
+
@PluginMethod
|
|
301
|
+
public void getLatest(final PluginCall call) {
|
|
302
|
+
new Thread(new Runnable(){
|
|
303
|
+
@Override
|
|
304
|
+
public void run() {
|
|
305
|
+
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, (res) -> {
|
|
306
|
+
final JSObject ret = new JSObject();
|
|
307
|
+
Iterator<String> keys = res.keys();
|
|
308
|
+
while(keys.hasNext()) {
|
|
309
|
+
String key = keys.next();
|
|
310
|
+
if (res.has(key)) {
|
|
311
|
+
try {
|
|
312
|
+
ret.put(key, res.get(key));
|
|
313
|
+
} catch (JSONException e) {
|
|
314
|
+
e.printStackTrace();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
call.resolve(ret);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
299
324
|
private boolean _reset(final Boolean toLastSuccessful) {
|
|
300
325
|
final BundleInfo fallback = this.implementation.getFallbackVersion();
|
|
301
326
|
this.implementation.reset();
|
|
@@ -383,7 +408,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
383
408
|
}
|
|
384
409
|
|
|
385
410
|
private Boolean _isAutoUpdateEnabled() {
|
|
386
|
-
return CapacitorUpdaterPlugin.this.autoUpdate && !"".equals(CapacitorUpdaterPlugin.this.
|
|
411
|
+
return CapacitorUpdaterPlugin.this.autoUpdate && !"".equals(CapacitorUpdaterPlugin.this.updateUrl);
|
|
387
412
|
}
|
|
388
413
|
|
|
389
414
|
@PluginMethod
|
|
@@ -417,8 +442,8 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
417
442
|
@Override
|
|
418
443
|
public void run() {
|
|
419
444
|
|
|
420
|
-
Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.
|
|
421
|
-
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.
|
|
445
|
+
Log.i(CapacitorUpdater.TAG, "Check for update via: " + CapacitorUpdaterPlugin.this.updateUrl);
|
|
446
|
+
CapacitorUpdaterPlugin.this.implementation.getLatest(CapacitorUpdaterPlugin.this.updateUrl, (res) -> {
|
|
422
447
|
try {
|
|
423
448
|
if (res.has("message")) {
|
|
424
449
|
Log.i(CapacitorUpdater.TAG, "message: " + res.get("message"));
|
|
@@ -523,7 +548,7 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
|
|
|
523
548
|
final JSObject ret = new JSObject();
|
|
524
549
|
ret.put("bundle", current);
|
|
525
550
|
this.notifyListeners("updateFailed", ret);
|
|
526
|
-
this.implementation.sendStats("
|
|
551
|
+
this.implementation.sendStats("update_fail", current.getVersionName());
|
|
527
552
|
if (!fallback.isBuiltin() && !fallback.equals(current)) {
|
|
528
553
|
final Boolean res = this.implementation.set(fallback);
|
|
529
554
|
if (res && this._reload()) {
|
package/dist/docs.json
CHANGED
|
@@ -259,12 +259,47 @@
|
|
|
259
259
|
{
|
|
260
260
|
"name": "throws",
|
|
261
261
|
"text": "An error if the something went wrong"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": "since",
|
|
265
|
+
"text": "4.0.0"
|
|
262
266
|
}
|
|
263
267
|
],
|
|
264
268
|
"docs": "Set delay to skip updates in the next time the app goes into the background",
|
|
265
269
|
"complexTypes": [],
|
|
266
270
|
"slug": "setdelay"
|
|
267
271
|
},
|
|
272
|
+
{
|
|
273
|
+
"name": "getLatest",
|
|
274
|
+
"signature": "(options: { delay: boolean; }) => Promise<latestVersion>",
|
|
275
|
+
"parameters": [
|
|
276
|
+
{
|
|
277
|
+
"name": "options",
|
|
278
|
+
"docs": "",
|
|
279
|
+
"type": "{ delay: boolean; }"
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
"returns": "Promise<latestVersion>",
|
|
283
|
+
"tags": [
|
|
284
|
+
{
|
|
285
|
+
"name": "returns",
|
|
286
|
+
"text": "an Promise resolved when url is loaded"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"name": "throws",
|
|
290
|
+
"text": "An error if the something went wrong"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "since",
|
|
294
|
+
"text": "4.0.0"
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
"docs": "Get Latest version available from update Url",
|
|
298
|
+
"complexTypes": [
|
|
299
|
+
"latestVersion"
|
|
300
|
+
],
|
|
301
|
+
"slug": "getlatest"
|
|
302
|
+
},
|
|
268
303
|
{
|
|
269
304
|
"name": "addListener",
|
|
270
305
|
"signature": "(eventName: 'download', listenerFunc: DownloadChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle",
|
|
@@ -480,6 +515,7 @@
|
|
|
480
515
|
"MajorAvailableEvent",
|
|
481
516
|
"DownloadCompleteEvent",
|
|
482
517
|
"UpdateFailedEvent",
|
|
518
|
+
"latestVersion",
|
|
483
519
|
"BundleInfo",
|
|
484
520
|
"BundleStatus",
|
|
485
521
|
"DownloadChangeListener",
|
|
@@ -534,6 +570,71 @@
|
|
|
534
570
|
"MajorAvailableEvent",
|
|
535
571
|
"DownloadCompleteEvent",
|
|
536
572
|
"UpdateFailedEvent",
|
|
573
|
+
"latestVersion",
|
|
574
|
+
"BundleStatus",
|
|
575
|
+
"DownloadChangeListener",
|
|
576
|
+
"DownloadCompleteListener",
|
|
577
|
+
"MajorAvailableListener",
|
|
578
|
+
"UpdateFailedListener",
|
|
579
|
+
"CapacitorUpdaterPlugin"
|
|
580
|
+
]
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
"name": "latestVersion",
|
|
584
|
+
"slug": "latestversion",
|
|
585
|
+
"docs": "",
|
|
586
|
+
"tags": [],
|
|
587
|
+
"methods": [],
|
|
588
|
+
"properties": [
|
|
589
|
+
{
|
|
590
|
+
"name": "version",
|
|
591
|
+
"tags": [
|
|
592
|
+
{
|
|
593
|
+
"text": "4.0.0",
|
|
594
|
+
"name": "since"
|
|
595
|
+
}
|
|
596
|
+
],
|
|
597
|
+
"docs": "Res of getLatest method",
|
|
598
|
+
"complexTypes": [],
|
|
599
|
+
"type": "string"
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
"name": "major",
|
|
603
|
+
"tags": [],
|
|
604
|
+
"docs": "",
|
|
605
|
+
"complexTypes": [],
|
|
606
|
+
"type": "boolean | undefined"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"name": "message",
|
|
610
|
+
"tags": [],
|
|
611
|
+
"docs": "",
|
|
612
|
+
"complexTypes": [],
|
|
613
|
+
"type": "string | undefined"
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"name": "old",
|
|
617
|
+
"tags": [],
|
|
618
|
+
"docs": "",
|
|
619
|
+
"complexTypes": [],
|
|
620
|
+
"type": "string | undefined"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"name": "url",
|
|
624
|
+
"tags": [],
|
|
625
|
+
"docs": "",
|
|
626
|
+
"complexTypes": [],
|
|
627
|
+
"type": "string | undefined"
|
|
628
|
+
}
|
|
629
|
+
],
|
|
630
|
+
"importObject": [
|
|
631
|
+
"PluginListenerHandle",
|
|
632
|
+
"\"@capacitor/cli\"",
|
|
633
|
+
"DownloadEvent",
|
|
634
|
+
"MajorAvailableEvent",
|
|
635
|
+
"DownloadCompleteEvent",
|
|
636
|
+
"UpdateFailedEvent",
|
|
637
|
+
"BundleInfo",
|
|
537
638
|
"BundleStatus",
|
|
538
639
|
"DownloadChangeListener",
|
|
539
640
|
"DownloadCompleteListener",
|
|
@@ -605,6 +706,7 @@
|
|
|
605
706
|
"MajorAvailableEvent",
|
|
606
707
|
"DownloadCompleteEvent",
|
|
607
708
|
"UpdateFailedEvent",
|
|
709
|
+
"latestVersion",
|
|
608
710
|
"BundleInfo",
|
|
609
711
|
"BundleStatus",
|
|
610
712
|
"DownloadChangeListener",
|
|
@@ -642,6 +744,7 @@
|
|
|
642
744
|
"DownloadEvent",
|
|
643
745
|
"MajorAvailableEvent",
|
|
644
746
|
"UpdateFailedEvent",
|
|
747
|
+
"latestVersion",
|
|
645
748
|
"BundleInfo",
|
|
646
749
|
"BundleStatus",
|
|
647
750
|
"DownloadChangeListener",
|
|
@@ -677,6 +780,7 @@
|
|
|
677
780
|
"DownloadEvent",
|
|
678
781
|
"DownloadCompleteEvent",
|
|
679
782
|
"UpdateFailedEvent",
|
|
783
|
+
"latestVersion",
|
|
680
784
|
"BundleInfo",
|
|
681
785
|
"BundleStatus",
|
|
682
786
|
"DownloadChangeListener",
|
|
@@ -714,6 +818,7 @@
|
|
|
714
818
|
"DownloadEvent",
|
|
715
819
|
"MajorAvailableEvent",
|
|
716
820
|
"DownloadCompleteEvent",
|
|
821
|
+
"latestVersion",
|
|
717
822
|
"BundleInfo",
|
|
718
823
|
"BundleStatus",
|
|
719
824
|
"DownloadChangeListener",
|
|
@@ -872,7 +977,7 @@
|
|
|
872
977
|
"type": "boolean | undefined"
|
|
873
978
|
},
|
|
874
979
|
{
|
|
875
|
-
"name": "
|
|
980
|
+
"name": "updateUrl",
|
|
876
981
|
"tags": [
|
|
877
982
|
{
|
|
878
983
|
"text": "https://capgo.app/api/auto_update",
|
|
@@ -49,7 +49,7 @@ declare module '@capacitor/cli' {
|
|
|
49
49
|
* @default https://capgo.app/api/auto_update
|
|
50
50
|
* @example https://example.com/api/auto_update
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
updateUrl?: string;
|
|
53
53
|
/**
|
|
54
54
|
* Automatically delete previous downloaded bundles when a newer native app version is installed to the device.
|
|
55
55
|
*
|
|
@@ -104,6 +104,18 @@ export interface UpdateFailedEvent {
|
|
|
104
104
|
*/
|
|
105
105
|
bundle: BundleInfo;
|
|
106
106
|
}
|
|
107
|
+
export interface latestVersion {
|
|
108
|
+
/**
|
|
109
|
+
* Res of getLatest method
|
|
110
|
+
*
|
|
111
|
+
* @since 4.0.0
|
|
112
|
+
*/
|
|
113
|
+
version: string;
|
|
114
|
+
major?: boolean;
|
|
115
|
+
message?: string;
|
|
116
|
+
old?: string;
|
|
117
|
+
url?: string;
|
|
118
|
+
}
|
|
107
119
|
export interface BundleInfo {
|
|
108
120
|
id: string;
|
|
109
121
|
version: string;
|
|
@@ -119,7 +131,7 @@ export interface CapacitorUpdaterPlugin {
|
|
|
119
131
|
/**
|
|
120
132
|
* Notify Capacitor Updater that the current bundle is working (a rollback will occur of this method is not called on every app launch)
|
|
121
133
|
*
|
|
122
|
-
* @returns {Promise<
|
|
134
|
+
* @returns {Promise<BundleInfo>} an Promise resolved directly
|
|
123
135
|
* @throws An error if the something went wrong
|
|
124
136
|
*/
|
|
125
137
|
notifyAppReady(): Promise<BundleInfo>;
|
|
@@ -187,7 +199,7 @@ export interface CapacitorUpdaterPlugin {
|
|
|
187
199
|
/**
|
|
188
200
|
* Get the current bundle, if none are set it returns `builtin`, currentNative is the original bundle installed on the device
|
|
189
201
|
*
|
|
190
|
-
* @returns {Promise<{
|
|
202
|
+
* @returns {Promise<{ bundle: BundleInfo, native: string }>} an Promise with the current bundle info
|
|
191
203
|
* @throws An error if the something went wrong
|
|
192
204
|
*/
|
|
193
205
|
current(): Promise<{
|
|
@@ -206,10 +218,21 @@ export interface CapacitorUpdaterPlugin {
|
|
|
206
218
|
*
|
|
207
219
|
* @returns {Promise<void>} an Promise resolved directly
|
|
208
220
|
* @throws An error if the something went wrong
|
|
221
|
+
* @since 4.0.0
|
|
209
222
|
*/
|
|
210
223
|
setDelay(options: {
|
|
211
224
|
delay: boolean;
|
|
212
225
|
}): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Get Latest version available from update Url
|
|
228
|
+
*
|
|
229
|
+
* @returns {Promise<latestVersion>} an Promise resolved when url is loaded
|
|
230
|
+
* @throws An error if the something went wrong
|
|
231
|
+
* @since 4.0.0
|
|
232
|
+
*/
|
|
233
|
+
getLatest(options: {
|
|
234
|
+
delay: boolean;
|
|
235
|
+
}): Promise<latestVersion>;
|
|
213
236
|
/**
|
|
214
237
|
* Listen for download event in the App, let you know when the download is started, loading and finished
|
|
215
238
|
*
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import type { CapacitorUpdaterPlugin, BundleInfo } from './definitions';
|
|
2
|
+
import type { CapacitorUpdaterPlugin, BundleInfo, latestVersion } from './definitions';
|
|
3
3
|
export declare class CapacitorUpdaterWeb extends WebPlugin implements CapacitorUpdaterPlugin {
|
|
4
4
|
download(options: {
|
|
5
5
|
url: string;
|
|
@@ -34,6 +34,7 @@ export declare class CapacitorUpdaterWeb extends WebPlugin implements CapacitorU
|
|
|
34
34
|
native: string;
|
|
35
35
|
}>;
|
|
36
36
|
reload(): Promise<void>;
|
|
37
|
+
getLatest(): Promise<latestVersion>;
|
|
37
38
|
notifyAppReady(): Promise<BundleInfo>;
|
|
38
39
|
setDelay(options: {
|
|
39
40
|
delay: boolean;
|
package/dist/esm/web.js
CHANGED
|
@@ -43,6 +43,13 @@ export class CapacitorUpdaterWeb extends WebPlugin {
|
|
|
43
43
|
console.warn('Cannot reload current bundle in web');
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
+
async getLatest() {
|
|
47
|
+
console.warn('Cannot getLatest current bundle in web');
|
|
48
|
+
return {
|
|
49
|
+
version: "0.0.0",
|
|
50
|
+
message: "Cannot getLatest current bundle in web",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
46
53
|
async notifyAppReady() {
|
|
47
54
|
console.warn('Cannot notify App Ready in web');
|
|
48
55
|
return BUNDLE_BUILTIN;
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,cAAc,GAAe,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,0BAA0B,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;AAE7H,MAAM,OAAO,mBACX,SAAQ,SAAS;IAEjB,KAAK,CAAC,QAAQ,CAAC,OAA0C;QACvD,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,OAAO,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,OAAuB;QAC/B,OAAO,CAAC,IAAI,CAAC,iCAAiC,EAAE,OAAO,CAAC,CAAC;QACzD,OAAO;IACT,CAAC;IACD,KAAK,CAAC,KA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,CAAC,OAAwC;QAClD,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IACD,KAAK,CAAC,OAAO;QACX,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACrD,CAAC;IACD,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IACD,KAAK,CAAC,SAAS;QACb,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,OAAO;YACL,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,wCAAwC;SAClD,CAAA;IACH,CAAC;IACD,KAAK,CAAC,cAAc;QAClB,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC/C,OAAO,cAAc,CAAC;IACxB,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,OAA2B;QACxC,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;QAC7D,OAAO;IACT,CAAC;CACF"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -52,6 +52,13 @@ class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
|
52
52
|
console.warn('Cannot reload current bundle in web');
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
+
async getLatest() {
|
|
56
|
+
console.warn('Cannot getLatest current bundle in web');
|
|
57
|
+
return {
|
|
58
|
+
version: "0.0.0",
|
|
59
|
+
message: "Cannot getLatest current bundle in web",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
55
62
|
async notifyAppReady() {
|
|
56
63
|
console.warn('Cannot notify App Ready in web');
|
|
57
64
|
return BUNDLE_BUILTIN;
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then(m => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = { status: 'success', version: '', downloaded: '1970-01-01T00:00:00.000Z', id: 'builtin' };\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getId() {\n console.warn('Cannot get ID in web');\n return { id: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setDelay(options) {\n console.warn('Cannot setDelay delay update in web', options);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACrE,CAAC;;ACFD,M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M,IAAI,GAAG;AACjB,QAAQ,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;AACnD,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/B,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;AAC7D,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;AACzD,QAAQ,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC3D,KAAK;AACL,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;AAC5D,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AACvD,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;AACrE,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then(m => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = { status: 'success', version: '', downloaded: '1970-01-01T00:00:00.000Z', id: 'builtin' };\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getId() {\n console.warn('Cannot get ID in web');\n return { id: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: \"0.0.0\",\n message: \"Cannot getLatest current bundle in web\",\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setDelay(options) {\n console.warn('Cannot setDelay delay update in web', options);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;AAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACrE,CAAC;;ACFD,MAAM,cAAc,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,0BAA0B,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;AAC1G,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,IAAI,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C,CAAC;AAC7D,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;AACzD,QAAQ,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC3D,KAAK;AACL,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;AAC5D,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,MAAM,SAAS,GAAG;AACtB,QAAQ,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;AAC/D,QAAQ,OAAO;AACf,YAAY,OAAO,EAAE,OAAO;AAC5B,YAAY,OAAO,EAAE,wCAAwC;AAC7D,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AACvD,QAAQ,OAAO,cAAc,CAAC;AAC9B,KAAK;AACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;AACrE,QAAQ,OAAO;AACf,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -49,6 +49,13 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
49
49
|
console.warn('Cannot reload current bundle in web');
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
+
async getLatest() {
|
|
53
|
+
console.warn('Cannot getLatest current bundle in web');
|
|
54
|
+
return {
|
|
55
|
+
version: "0.0.0",
|
|
56
|
+
message: "Cannot getLatest current bundle in web",
|
|
57
|
+
};
|
|
58
|
+
}
|
|
52
59
|
async notifyAppReady() {
|
|
53
60
|
console.warn('Cannot notify App Ready in web');
|
|
54
61
|
return BUNDLE_BUILTIN;
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then(m => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = { status: 'success', version: '', downloaded: '1970-01-01T00:00:00.000Z', id: 'builtin' };\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getId() {\n console.warn('Cannot get ID in web');\n return { id: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setDelay(options) {\n console.warn('Cannot setDelay delay update in web', options);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI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B,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IACnD,QAAQ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/B,KAAK;IACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAK;IACL,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACzD,QAAQ,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC3D,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IAC5D,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACvD,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;IACrE,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then(m => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = { status: 'success', version: '', downloaded: '1970-01-01T00:00:00.000Z', id: 'builtin' };\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getId() {\n console.warn('Cannot get ID in web');\n return { id: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: \"0.0.0\",\n message: \"Cannot getLatest current bundle in web\",\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return BUNDLE_BUILTIN;\n }\n async setDelay(options) {\n console.warn('Cannot setDelay delay update in web', options);\n return;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACrE,CAAC;;ICFD,MAAM,cAAc,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,0BAA0B,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAC1G,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,QA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QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAK;IACL,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IACzD,QAAQ,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC3D,KAAK;IACL,IAAI,MAAM,MAAM,GAAG;IACnB,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IAC5D,QAAQ,OAAO;IACf,KAAK;IACL,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IAC/D,QAAQ,OAAO;IACf,YAAY,OAAO,EAAE,OAAO;IAC5B,YAAY,OAAO,EAAE,wCAAwC;IAC7D,SAAS,CAAC;IACV,KAAK;IACL,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;IACvD,QAAQ,OAAO,cAAc,CAAC;IAC9B,KAAK;IACL,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,EAAE,OAAO,CAAC,CAAC;IACrE,QAAQ,OAAO;IACf,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -27,6 +27,20 @@ public class AppVersion: NSObject {
|
|
|
27
27
|
var message: String?
|
|
28
28
|
var major: Bool?
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
extension AppVersion {
|
|
32
|
+
func toDict() -> [String:Any] {
|
|
33
|
+
var dict = [String:Any]()
|
|
34
|
+
let otherSelf = Mirror(reflecting: self)
|
|
35
|
+
for child in otherSelf.children {
|
|
36
|
+
if let key = child.label {
|
|
37
|
+
dict[key] = child.value
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return dict
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
extension OperatingSystemVersion {
|
|
31
45
|
func getFullVersion(separator: String = ".") -> String {
|
|
32
46
|
return "\(majorVersion)\(separator)\(minorVersion)\(separator)\(patchVersion)"
|
|
@@ -134,7 +148,7 @@ extension CustomError: LocalizedError {
|
|
|
134
148
|
|
|
135
149
|
public let TAG = "✨ Capacitor-updater:";
|
|
136
150
|
public let CAP_SERVER_PATH = "serverBasePath"
|
|
137
|
-
public let pluginVersion = "4.0.0-alpha.
|
|
151
|
+
public let pluginVersion = "4.0.0-alpha.10"
|
|
138
152
|
public var statsUrl = ""
|
|
139
153
|
public var appId = ""
|
|
140
154
|
public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
|
@@ -332,7 +346,7 @@ extension CustomError: LocalizedError {
|
|
|
332
346
|
return false
|
|
333
347
|
}
|
|
334
348
|
self.removeBundleInfo(id: id)
|
|
335
|
-
self.sendStats(action: "delete",
|
|
349
|
+
self.sendStats(action: "delete", versionName: deleted.getVersionName())
|
|
336
350
|
return true
|
|
337
351
|
}
|
|
338
352
|
|
|
@@ -344,21 +358,28 @@ extension CustomError: LocalizedError {
|
|
|
344
358
|
return self.set(id: bundle.getId());
|
|
345
359
|
}
|
|
346
360
|
|
|
347
|
-
|
|
361
|
+
private func bundleExists(id: String) -> Bool {
|
|
348
362
|
let destHot = self.getPathHot(id: id)
|
|
349
363
|
let destHotPersist = self.getPathPersist(id: id)
|
|
350
364
|
let indexHot = destHot.appendingPathComponent("index.html")
|
|
351
365
|
let indexPersist = destHotPersist.appendingPathComponent("index.html")
|
|
352
|
-
let
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
366
|
+
let url: URL = self.getBundleDirectory(id: id)
|
|
367
|
+
if(url.isDirectory && destHotPersist.isDirectory && indexHot.exist && indexPersist.exist) {
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
public func set(id: String) -> Bool {
|
|
374
|
+
let newBundle: BundleInfo = self.getBundleInfo(id: id)
|
|
375
|
+
if (bundleExists(id: id)) {
|
|
376
|
+
let url: URL = self.getBundleDirectory(id: id)
|
|
377
|
+
self.setCurrentBundle(bundle: String(url.path.suffix(10)))
|
|
357
378
|
self.setBundleStatus(id: id, status: BundleStatus.PENDING)
|
|
358
|
-
sendStats(action: "set",
|
|
379
|
+
sendStats(action: "set", versionName: newBundle.getVersionName())
|
|
359
380
|
return true
|
|
360
381
|
}
|
|
361
|
-
sendStats(action: "set_fail",
|
|
382
|
+
sendStats(action: "set_fail", versionName: newBundle.getVersionName())
|
|
362
383
|
return false
|
|
363
384
|
}
|
|
364
385
|
|
|
@@ -380,7 +401,7 @@ extension CustomError: LocalizedError {
|
|
|
380
401
|
let _ = self.setNextVersion(next: Optional<String>.none)
|
|
381
402
|
UserDefaults.standard.synchronize()
|
|
382
403
|
if(!isInternal) {
|
|
383
|
-
sendStats(action: "reset",
|
|
404
|
+
sendStats(action: "reset", versionName: self.getCurrentBundle().getVersionName())
|
|
384
405
|
}
|
|
385
406
|
}
|
|
386
407
|
|
|
@@ -393,13 +414,13 @@ extension CustomError: LocalizedError {
|
|
|
393
414
|
self.setBundleStatus(id: bundle.getId(), status: BundleStatus.ERROR);
|
|
394
415
|
}
|
|
395
416
|
|
|
396
|
-
func sendStats(action: String,
|
|
417
|
+
func sendStats(action: String, versionName: String) {
|
|
397
418
|
if (statsUrl == "") { return }
|
|
398
419
|
let parameters: [String: String] = [
|
|
399
420
|
"platform": "ios",
|
|
400
421
|
"action": action,
|
|
401
422
|
"device_id": self.deviceID,
|
|
402
|
-
"version_name":
|
|
423
|
+
"version_name": versionName,
|
|
403
424
|
"version_build": self.versionBuild,
|
|
404
425
|
"version_code": self.versionCode,
|
|
405
426
|
"version_os": self.versionOs,
|
|
@@ -409,7 +430,7 @@ extension CustomError: LocalizedError {
|
|
|
409
430
|
|
|
410
431
|
DispatchQueue.global(qos: .background).async {
|
|
411
432
|
let _ = AF.request(self.statsUrl, method: .post,parameters: parameters, encoder: JSONParameterEncoder.default)
|
|
412
|
-
print("\(self.TAG) Stats send for \(action), version \(
|
|
433
|
+
print("\(self.TAG) Stats send for \(action), version \(versionName)")
|
|
413
434
|
}
|
|
414
435
|
}
|
|
415
436
|
|
|
@@ -13,6 +13,7 @@ CAP_PLUGIN(CapacitorUpdaterPlugin, "CapacitorUpdater",
|
|
|
13
13
|
CAP_PLUGIN_METHOD(reload, CAPPluginReturnPromise);
|
|
14
14
|
CAP_PLUGIN_METHOD(notifyAppReady, CAPPluginReturnPromise);
|
|
15
15
|
CAP_PLUGIN_METHOD(setDelay, CAPPluginReturnPromise);
|
|
16
|
+
CAP_PLUGIN_METHOD(getLatest, CAPPluginReturnPromise);
|
|
16
17
|
CAP_PLUGIN_METHOD(getId, CAPPluginReturnPromise);
|
|
17
18
|
CAP_PLUGIN_METHOD(getPluginVersion, CAPPluginReturnPromise);
|
|
18
19
|
CAP_PLUGIN_METHOD(next, CAPPluginReturnPromise);
|
|
@@ -9,10 +9,10 @@ import Version
|
|
|
9
9
|
@objc(CapacitorUpdaterPlugin)
|
|
10
10
|
public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
11
11
|
private var implementation = CapacitorUpdater()
|
|
12
|
-
static let
|
|
12
|
+
static let updateUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/updates"
|
|
13
13
|
static let statsUrlDefault = "https://xvwzpoazmxkqosrdewyv.functions.supabase.co/stats"
|
|
14
14
|
static let DELAY_UPDATE = "delayUpdate"
|
|
15
|
-
private var
|
|
15
|
+
private var updateUrl = ""
|
|
16
16
|
private var statsUrl = ""
|
|
17
17
|
private var currentVersionNative: Version = "0.0.0"
|
|
18
18
|
private var autoUpdate = false
|
|
@@ -30,7 +30,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
30
30
|
}
|
|
31
31
|
autoDeleteFailed = getConfigValue("autoDeleteFailed") as? Bool ?? false
|
|
32
32
|
autoDeletePrevious = getConfigValue("autoDeletePrevious") as? Bool ?? false
|
|
33
|
-
|
|
33
|
+
updateUrl = getConfigValue("updateUrl") as? String ?? CapacitorUpdaterPlugin.updateUrlDefault
|
|
34
34
|
autoUpdate = getConfigValue("autoUpdate") as? Bool ?? false
|
|
35
35
|
appReadyTimeout = getConfigValue("appReadyTimeout") as? Int ?? 10000
|
|
36
36
|
resetWhenUpdate = getConfigValue("resetWhenUpdate") as? Bool ?? true
|
|
@@ -60,7 +60,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
60
60
|
print("\(self.implementation.TAG) Cannot get version native \(currentVersionNative)")
|
|
61
61
|
}
|
|
62
62
|
if (LatestVersionNative != "0.0.0" && currentVersionNative.major > LatestVersionNative.major) {
|
|
63
|
-
_ = self._reset(
|
|
63
|
+
_ = self._reset(toLastSuccessful: false)
|
|
64
64
|
UserDefaults.standard.set("", forKey: "LatestVersionAutoUpdate")
|
|
65
65
|
UserDefaults.standard.set("", forKey: "LatestVersionNameAutoUpdate")
|
|
66
66
|
let res = implementation.list()
|
|
@@ -188,18 +188,21 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
188
188
|
])
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
@objc func
|
|
191
|
+
@objc func getLatest(_ call: CAPPluginCall) {
|
|
192
|
+
let res = self.implementation.getLatest(url: URL(string: self.updateUrl)!)
|
|
193
|
+
call.resolve((res?.toDict())!)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@objc func _reset(toLastSuccessful: Bool) -> Bool {
|
|
192
197
|
guard let bridge = self.bridge else { return false }
|
|
198
|
+
|
|
193
199
|
if let vc = bridge.viewController as? CAPBridgeViewController {
|
|
194
|
-
self.implementation.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if(toAutoUpdate && LatestVersionAutoUpdate != "" && LatestVersionNameAutoUpdate != "") {
|
|
199
|
-
let res = implementation.set(id: LatestVersionNameAutoUpdate)
|
|
200
|
-
return res && self._reload()
|
|
200
|
+
let fallback: BundleInfo = self.implementation.getFallbackVersion()
|
|
201
|
+
if (toLastSuccessful && !fallback.isBuiltin()) {
|
|
202
|
+
print("\(self.implementation.TAG) Resetting to: \(fallback.toString())")
|
|
203
|
+
return self.implementation.set(bundle: fallback) && self._reload()
|
|
201
204
|
}
|
|
202
|
-
implementation.reset()
|
|
205
|
+
self.implementation.reset()
|
|
203
206
|
vc.setServerBasePath(path: "")
|
|
204
207
|
DispatchQueue.main.async {
|
|
205
208
|
vc.loadView()
|
|
@@ -212,8 +215,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
212
215
|
}
|
|
213
216
|
|
|
214
217
|
@objc func reset(_ call: CAPPluginCall) {
|
|
215
|
-
let
|
|
216
|
-
if (self._reset(
|
|
218
|
+
let toLastSuccessful = call.getBool("toLastSuccessful") ?? false
|
|
219
|
+
if (self._reset(toLastSuccessful: toLastSuccessful)) {
|
|
217
220
|
return call.resolve()
|
|
218
221
|
}
|
|
219
222
|
call.reject("\(self.implementation.TAG) Reset failed")
|
|
@@ -245,7 +248,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
245
248
|
}
|
|
246
249
|
|
|
247
250
|
private func _isAutoUpdateEnabled() -> Bool {
|
|
248
|
-
return self.autoUpdate && self.
|
|
251
|
+
return self.autoUpdate && self.updateUrl != ""
|
|
249
252
|
}
|
|
250
253
|
|
|
251
254
|
@objc func isAutoUpdateEnabled(_ call: CAPPluginCall) {
|
|
@@ -274,7 +277,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
274
277
|
if(BundleStatus.SUCCESS.localizedString != current.getStatus()) {
|
|
275
278
|
print("\(self.implementation.TAG) notifyAppReady was not called, roll back current bundle: \(current.toString())")
|
|
276
279
|
self.implementation.rollback(bundle: current)
|
|
277
|
-
let res = self._reset(
|
|
280
|
+
let res = self._reset(toLastSuccessful: true)
|
|
278
281
|
if (!res) {
|
|
279
282
|
return
|
|
280
283
|
}
|
|
@@ -287,20 +290,24 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
287
290
|
@objc func appMovedToForeground() {
|
|
288
291
|
if (self._isAutoUpdateEnabled()) {
|
|
289
292
|
DispatchQueue.global(qos: .background).async {
|
|
290
|
-
print("\(self.implementation.TAG) Check for update via \(self.
|
|
291
|
-
let url = URL(string: self.
|
|
293
|
+
print("\(self.implementation.TAG) Check for update via \(self.updateUrl)")
|
|
294
|
+
let url = URL(string: self.updateUrl)!
|
|
292
295
|
let res = self.implementation.getLatest(url: url)
|
|
293
296
|
if (res == nil) {
|
|
294
|
-
print("\(self.implementation.TAG) No result found in \(self.
|
|
297
|
+
print("\(self.implementation.TAG) No result found in \(self.updateUrl)")
|
|
295
298
|
return
|
|
296
299
|
}
|
|
297
|
-
|
|
298
|
-
print("\(self.implementation.TAG)
|
|
300
|
+
if ((res?.message) != nil) {
|
|
301
|
+
print("\(self.implementation.TAG) message \(res!.message ?? "")")
|
|
299
302
|
if (res?.major == true) {
|
|
300
303
|
self.notifyListeners("majorAvailable", data: ["version": res?.version ?? "0.0.0"])
|
|
301
304
|
}
|
|
302
305
|
return
|
|
303
306
|
}
|
|
307
|
+
guard let downloadUrl = URL(string: res?.url ?? "") else {
|
|
308
|
+
print("\(self.implementation.TAG) Error no url or wrong format")
|
|
309
|
+
return
|
|
310
|
+
}
|
|
304
311
|
let current = self.implementation.getCurrentBundle()
|
|
305
312
|
let latestVersionName = res?.version
|
|
306
313
|
if (latestVersionName != nil && latestVersionName != "" && current.getVersionName() != latestVersionName) {
|
|
@@ -374,7 +381,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
374
381
|
self.notifyListeners("updateFailed", data: [
|
|
375
382
|
"bundle": current.toJSON()
|
|
376
383
|
])
|
|
377
|
-
self.implementation.sendStats(action: "
|
|
384
|
+
self.implementation.sendStats(action: "fail_update", versionName: current.getVersionName())
|
|
378
385
|
if (!fallback.isBuiltin() && !(fallback == current)) {
|
|
379
386
|
let res = self.implementation.set(bundle: fallback)
|
|
380
387
|
if (res && self._reload()) {
|
|
@@ -383,7 +390,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
|
|
|
383
390
|
print("\(self.implementation.TAG) Revert to bundle: \(fallback.toString()) Failed!")
|
|
384
391
|
}
|
|
385
392
|
} else {
|
|
386
|
-
if (self._reset(
|
|
393
|
+
if (self._reset(toLastSuccessful: false)) {
|
|
387
394
|
print("\(self.implementation.TAG) Reverted to 'builtin' bundle.")
|
|
388
395
|
}
|
|
389
396
|
}
|
|
@@ -38,60 +38,4 @@ extension UserDefaults: ObjectSavable {
|
|
|
38
38
|
throw ObjectSavableError.unableToDecode
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
//// MARK: - Methods
|
|
45
|
-
//public extension UserDefaults {
|
|
46
|
-
// /// SwifterSwift: get object from UserDefaults by using subscript.
|
|
47
|
-
// ///
|
|
48
|
-
// /// - Parameter key: key in the current user's defaults database.
|
|
49
|
-
// subscript(key: String) -> Any? {
|
|
50
|
-
// get {
|
|
51
|
-
// return object(forKey: key)
|
|
52
|
-
// }
|
|
53
|
-
// set {
|
|
54
|
-
// set(newValue, forKey: key)
|
|
55
|
-
// }
|
|
56
|
-
// }
|
|
57
|
-
//
|
|
58
|
-
// /// SwifterSwift: Float from UserDefaults.
|
|
59
|
-
// ///
|
|
60
|
-
// /// - Parameter key: key to find float for.
|
|
61
|
-
// /// - Returns: Float object for key (if exists).
|
|
62
|
-
// func float(forKey key: String) -> Float? {
|
|
63
|
-
// return object(forKey: key) as? Float
|
|
64
|
-
// }
|
|
65
|
-
//
|
|
66
|
-
// /// SwifterSwift: Date from UserDefaults.
|
|
67
|
-
// ///
|
|
68
|
-
// /// - Parameter key: key to find date for.
|
|
69
|
-
// /// - Returns: Date object for key (if exists).
|
|
70
|
-
// func date(forKey key: String) -> Date? {
|
|
71
|
-
// return object(forKey: key) as? Date
|
|
72
|
-
// }
|
|
73
|
-
//
|
|
74
|
-
// /// SwifterSwift: Retrieves a Codable object from UserDefaults.
|
|
75
|
-
// ///
|
|
76
|
-
// /// - Parameters:
|
|
77
|
-
// /// - type: Class that conforms to the Codable protocol.
|
|
78
|
-
// /// - key: Identifier of the object.
|
|
79
|
-
// /// - decoder: Custom JSONDecoder instance. Defaults to `JSONDecoder()`.
|
|
80
|
-
// /// - Returns: Codable object for key (if exists).
|
|
81
|
-
// func object<T: Codable>(_ type: T.Type, with key: String, usingDecoder decoder: JSONDecoder = JSONDecoder()) -> T? {
|
|
82
|
-
// guard let data = value(forKey: key) as? Data else { return nil }
|
|
83
|
-
// return try? decoder.decode(type.self, from: data)
|
|
84
|
-
// }
|
|
85
|
-
//
|
|
86
|
-
// /// SwifterSwift: Allows storing of Codable objects to UserDefaults.
|
|
87
|
-
// ///
|
|
88
|
-
// /// - Parameters:
|
|
89
|
-
// /// - object: Codable object to store.
|
|
90
|
-
// /// - key: Identifier of the object.
|
|
91
|
-
// /// - encoder: Custom JSONEncoder instance. Defaults to `JSONEncoder()`.
|
|
92
|
-
// func set<T: Codable>(object: T, forKey key: String, usingEncoder encoder: JSONEncoder = JSONEncoder()) {
|
|
93
|
-
// let data = try? encoder.encode(object)
|
|
94
|
-
// set(data, forKey: key)
|
|
95
|
-
// }
|
|
96
|
-
//}
|
|
97
|
-
//
|
|
41
|
+
}
|