@capawesome/capacitor-live-update 7.2.1 → 7.3.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 +78 -26
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +165 -35
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +23 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +52 -13
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePreferences.java +17 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/NextBundleSetEvent.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SyncOptions.java +4 -0
- package/dist/docs.json +109 -1
- package/dist/esm/definitions.d.ts +65 -2
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/Classes/Events/NextBundleSetEvent.swift +16 -0
- package/ios/Plugin/Classes/Options/SyncOptions.swift +4 -0
- package/ios/Plugin/LiveUpdate.swift +101 -0
- package/ios/Plugin/LiveUpdateConfig.swift +2 -0
- package/ios/Plugin/LiveUpdateHttpClient.swift +5 -3
- package/ios/Plugin/LiveUpdatePlugin.swift +29 -11
- package/ios/Plugin/LiveUpdatePreferences.swift +14 -0
- package/package.json +1 -1
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.liveupdate;
|
|
2
2
|
|
|
3
|
+
import android.webkit.WebView;
|
|
3
4
|
import androidx.annotation.NonNull;
|
|
4
5
|
import androidx.annotation.Nullable;
|
|
5
6
|
import com.getcapacitor.JSObject;
|
|
@@ -7,8 +8,10 @@ import com.getcapacitor.Logger;
|
|
|
7
8
|
import com.getcapacitor.Plugin;
|
|
8
9
|
import com.getcapacitor.PluginCall;
|
|
9
10
|
import com.getcapacitor.PluginMethod;
|
|
11
|
+
import com.getcapacitor.WebViewListener;
|
|
10
12
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
11
13
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.events.DownloadBundleProgressEvent;
|
|
14
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.classes.events.NextBundleSetEvent;
|
|
12
15
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DeleteBundleOptions;
|
|
13
16
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DownloadBundleOptions;
|
|
14
17
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.FetchLatestBundleOptions;
|
|
@@ -26,7 +29,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
|
26
29
|
public class LiveUpdatePlugin extends Plugin {
|
|
27
30
|
|
|
28
31
|
public static final String TAG = "LiveUpdate";
|
|
29
|
-
public static final String VERSION = "7.
|
|
32
|
+
public static final String VERSION = "7.3.0";
|
|
30
33
|
public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
|
|
31
34
|
public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
|
|
32
35
|
public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
|
|
@@ -45,8 +48,7 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
45
48
|
public static final String ERROR_SYNC_IN_PROGRESS = "Sync is already in progress.";
|
|
46
49
|
public static final String ERROR_UNKNOWN_ERROR = "An unknown error has occurred.";
|
|
47
50
|
public static final String EVENT_DOWNLOAD_BUNDLE_PROGRESS = "downloadBundleProgress";
|
|
48
|
-
|
|
49
|
-
private boolean syncInProgress = false;
|
|
51
|
+
public static final String EVENT_NEXT_BUNDLE_SET = "nextBundleSet";
|
|
50
52
|
|
|
51
53
|
@Nullable
|
|
52
54
|
private LiveUpdateConfig config;
|
|
@@ -54,6 +56,8 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
54
56
|
@Nullable
|
|
55
57
|
private LiveUpdate implementation;
|
|
56
58
|
|
|
59
|
+
private boolean webViewListenerRegistered = false;
|
|
60
|
+
|
|
57
61
|
public void load() {
|
|
58
62
|
try {
|
|
59
63
|
config = getLiveUpdateConfig();
|
|
@@ -63,6 +67,36 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
70
|
+
@Override
|
|
71
|
+
protected void handleOnResume() {
|
|
72
|
+
super.handleOnResume();
|
|
73
|
+
try {
|
|
74
|
+
// Notify the implementation that the app has resumed
|
|
75
|
+
if (implementation != null) {
|
|
76
|
+
implementation.handleOnResume();
|
|
77
|
+
}
|
|
78
|
+
// Register WebView listener to trigger auto-update when page is loaded
|
|
79
|
+
// Important: For some reason, the listener CANNOT be registered in the load() method
|
|
80
|
+
// or constructor, it MUST be done here in onResume().
|
|
81
|
+
if (!webViewListenerRegistered) {
|
|
82
|
+
webViewListenerRegistered = true;
|
|
83
|
+
getBridge()
|
|
84
|
+
.addWebViewListener(
|
|
85
|
+
new WebViewListener() {
|
|
86
|
+
@Override
|
|
87
|
+
public void onPageLoaded(WebView webView) {
|
|
88
|
+
if (implementation != null) {
|
|
89
|
+
implementation.handleOnPageLoaded();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
} catch (Exception exception) {
|
|
96
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
66
100
|
@PluginMethod
|
|
67
101
|
public void deleteBundle(PluginCall call) {
|
|
68
102
|
try {
|
|
@@ -130,6 +164,12 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
130
164
|
@PluginMethod
|
|
131
165
|
public void fetchLatestBundle(PluginCall call) {
|
|
132
166
|
try {
|
|
167
|
+
String appId = config.getAppId();
|
|
168
|
+
if (appId == null || appId.isEmpty()) {
|
|
169
|
+
call.reject(ERROR_APP_ID_MISSING);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
133
173
|
FetchLatestBundleOptions options = new FetchLatestBundleOptions(call);
|
|
134
174
|
NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
|
|
135
175
|
@Override
|
|
@@ -438,35 +478,26 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
438
478
|
public void sync(PluginCall call) {
|
|
439
479
|
try {
|
|
440
480
|
String appId = config.getAppId();
|
|
441
|
-
if (appId == null) {
|
|
481
|
+
if (appId == null || appId.isEmpty()) {
|
|
442
482
|
call.reject(ERROR_APP_ID_MISSING);
|
|
443
483
|
return;
|
|
444
484
|
}
|
|
445
485
|
|
|
446
|
-
if (syncInProgress) {
|
|
447
|
-
call.reject(ERROR_SYNC_IN_PROGRESS);
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
syncInProgress = true;
|
|
451
|
-
|
|
452
486
|
SyncOptions options = new SyncOptions(call);
|
|
453
487
|
NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
|
|
454
488
|
@Override
|
|
455
489
|
public void success(Result result) {
|
|
456
|
-
syncInProgress = false;
|
|
457
490
|
resolveCall(call, result.toJSObject());
|
|
458
491
|
}
|
|
459
492
|
|
|
460
493
|
@Override
|
|
461
494
|
public void error(Exception exception) {
|
|
462
|
-
syncInProgress = false;
|
|
463
495
|
rejectCall(call, exception);
|
|
464
496
|
}
|
|
465
497
|
};
|
|
466
498
|
|
|
467
499
|
implementation.sync(options, callback);
|
|
468
500
|
} catch (Exception exception) {
|
|
469
|
-
syncInProgress = false;
|
|
470
501
|
rejectCall(call, exception);
|
|
471
502
|
}
|
|
472
503
|
}
|
|
@@ -475,13 +506,21 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
475
506
|
notifyListeners(EVENT_DOWNLOAD_BUNDLE_PROGRESS, event.toJSObject(), false);
|
|
476
507
|
}
|
|
477
508
|
|
|
509
|
+
public void notifyNextBundleSetListeners(@NonNull NextBundleSetEvent event) {
|
|
510
|
+
notifyListeners(EVENT_NEXT_BUNDLE_SET, event.toJSObject(), false);
|
|
511
|
+
}
|
|
512
|
+
|
|
478
513
|
private LiveUpdateConfig getLiveUpdateConfig() {
|
|
479
514
|
LiveUpdateConfig config = new LiveUpdateConfig();
|
|
480
515
|
|
|
481
516
|
String appId = getConfig().getString("appId", config.getAppId());
|
|
482
517
|
config.setAppId(appId);
|
|
518
|
+
boolean autoBlockRolledBackBundles = getConfig().getBoolean("autoBlockRolledBackBundles", config.getAutoBlockRolledBackBundles());
|
|
519
|
+
config.setAutoBlockRolledBackBundles(autoBlockRolledBackBundles);
|
|
483
520
|
boolean autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.getAutoDeleteBundles());
|
|
484
521
|
config.setAutoDeleteBundles(autoDeleteBundles);
|
|
522
|
+
String autoUpdateStrategy = getConfig().getString("autoUpdateStrategy", config.getAutoUpdateStrategy());
|
|
523
|
+
config.setAutoUpdateStrategy(autoUpdateStrategy);
|
|
485
524
|
String defaultChannel = getConfig().getString("defaultChannel", config.getDefaultChannel());
|
|
486
525
|
config.setDefaultChannel(defaultChannel);
|
|
487
526
|
int httpTimeout = getConfig().getInt("httpTimeout", config.getHttpTimeout());
|
|
@@ -15,6 +15,7 @@ public class LiveUpdatePreferences {
|
|
|
15
15
|
@NonNull
|
|
16
16
|
private final SharedPreferences.Editor settingsEditor;
|
|
17
17
|
|
|
18
|
+
private final String blockedBundleIdsKey = "blockedBundleIds"; // DO NOT CHANGE
|
|
18
19
|
private final String channelKey = "channel"; // DO NOT CHANGE
|
|
19
20
|
private final String deviceIdKey = "deviceId"; // DO NOT CHANGE
|
|
20
21
|
private final String customIdKey = "customId"; // DO NOT CHANGE
|
|
@@ -55,6 +56,22 @@ public class LiveUpdatePreferences {
|
|
|
55
56
|
.getString(previousBundleIdKey, null);
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
@Nullable
|
|
60
|
+
public String getBlockedBundleIds() {
|
|
61
|
+
return context
|
|
62
|
+
.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE)
|
|
63
|
+
.getString(blockedBundleIdsKey, null);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void setBlockedBundleIds(@Nullable String blockedBundleIds) {
|
|
67
|
+
if (blockedBundleIds == null) {
|
|
68
|
+
settingsEditor.remove(blockedBundleIdsKey);
|
|
69
|
+
} else {
|
|
70
|
+
settingsEditor.putString(blockedBundleIdsKey, blockedBundleIds);
|
|
71
|
+
}
|
|
72
|
+
settingsEditor.apply();
|
|
73
|
+
}
|
|
74
|
+
|
|
58
75
|
public void setChannel(@Nullable String channel) {
|
|
59
76
|
if (channel == null) {
|
|
60
77
|
settingsEditor.remove(channelKey);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.events;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import org.json.JSONObject;
|
|
6
|
+
|
|
7
|
+
public class NextBundleSetEvent {
|
|
8
|
+
|
|
9
|
+
@Nullable
|
|
10
|
+
private final String bundleId;
|
|
11
|
+
|
|
12
|
+
public NextBundleSetEvent(@Nullable String bundleId) {
|
|
13
|
+
this.bundleId = bundleId;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
public String getBundleId() {
|
|
18
|
+
return bundleId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public JSObject toJSObject() {
|
|
22
|
+
JSObject result = new JSObject();
|
|
23
|
+
result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -380,6 +380,35 @@
|
|
|
380
380
|
],
|
|
381
381
|
"slug": "addlistenerdownloadbundleprogress-"
|
|
382
382
|
},
|
|
383
|
+
{
|
|
384
|
+
"name": "addListener",
|
|
385
|
+
"signature": "(eventName: 'nextBundleSet', listenerFunc: NextBundleSetListener) => Promise<PluginListenerHandle>",
|
|
386
|
+
"parameters": [
|
|
387
|
+
{
|
|
388
|
+
"name": "eventName",
|
|
389
|
+
"docs": "",
|
|
390
|
+
"type": "'nextBundleSet'"
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
"name": "listenerFunc",
|
|
394
|
+
"docs": "",
|
|
395
|
+
"type": "NextBundleSetListener"
|
|
396
|
+
}
|
|
397
|
+
],
|
|
398
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
399
|
+
"tags": [
|
|
400
|
+
{
|
|
401
|
+
"name": "since",
|
|
402
|
+
"text": "7.3.0"
|
|
403
|
+
}
|
|
404
|
+
],
|
|
405
|
+
"docs": "Listen for when a bundle is set as the next bundle.\n\nThis event is triggered whenever a bundle is set to be used on the next app restart,\neither through automatic updates or manual calls to `setNextBundle()`.\n\nOnly available on Android and iOS.",
|
|
406
|
+
"complexTypes": [
|
|
407
|
+
"PluginListenerHandle",
|
|
408
|
+
"NextBundleSetListener"
|
|
409
|
+
],
|
|
410
|
+
"slug": "addlistenernextbundleset-"
|
|
411
|
+
},
|
|
383
412
|
{
|
|
384
413
|
"name": "removeAllListeners",
|
|
385
414
|
"signature": "() => Promise<void>",
|
|
@@ -1123,6 +1152,36 @@
|
|
|
1123
1152
|
"type": "number"
|
|
1124
1153
|
}
|
|
1125
1154
|
]
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"name": "NextBundleSetEvent",
|
|
1158
|
+
"slug": "nextbundlesetevent",
|
|
1159
|
+
"docs": "Event that is triggered when a bundle is set as the next bundle.",
|
|
1160
|
+
"tags": [
|
|
1161
|
+
{
|
|
1162
|
+
"text": "7.3.0",
|
|
1163
|
+
"name": "since"
|
|
1164
|
+
}
|
|
1165
|
+
],
|
|
1166
|
+
"methods": [],
|
|
1167
|
+
"properties": [
|
|
1168
|
+
{
|
|
1169
|
+
"name": "bundleId",
|
|
1170
|
+
"tags": [
|
|
1171
|
+
{
|
|
1172
|
+
"text": "7.3.0",
|
|
1173
|
+
"name": "since"
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
"text": "'1.0.0'",
|
|
1177
|
+
"name": "example"
|
|
1178
|
+
}
|
|
1179
|
+
],
|
|
1180
|
+
"docs": "The unique identifier of the bundle that is set as the next bundle.\n\nIf `null`, the default bundle will be used.",
|
|
1181
|
+
"complexTypes": [],
|
|
1182
|
+
"type": "string | null"
|
|
1183
|
+
}
|
|
1184
|
+
]
|
|
1126
1185
|
}
|
|
1127
1186
|
],
|
|
1128
1187
|
"enums": [],
|
|
@@ -1139,6 +1198,19 @@
|
|
|
1139
1198
|
]
|
|
1140
1199
|
}
|
|
1141
1200
|
]
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
"name": "NextBundleSetListener",
|
|
1204
|
+
"slug": "nextbundlesetlistener",
|
|
1205
|
+
"docs": "Listener for when a bundle is set as the next bundle.",
|
|
1206
|
+
"types": [
|
|
1207
|
+
{
|
|
1208
|
+
"text": "(event: NextBundleSetEvent): void",
|
|
1209
|
+
"complexTypes": [
|
|
1210
|
+
"NextBundleSetEvent"
|
|
1211
|
+
]
|
|
1212
|
+
}
|
|
1213
|
+
]
|
|
1142
1214
|
}
|
|
1143
1215
|
],
|
|
1144
1216
|
"pluginConfigs": [
|
|
@@ -1162,6 +1234,22 @@
|
|
|
1162
1234
|
"complexTypes": [],
|
|
1163
1235
|
"type": "string | undefined"
|
|
1164
1236
|
},
|
|
1237
|
+
{
|
|
1238
|
+
"name": "autoBlockRolledBackBundles",
|
|
1239
|
+
"tags": [
|
|
1240
|
+
{
|
|
1241
|
+
"text": "7.3.0",
|
|
1242
|
+
"name": "since"
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
"text": "false",
|
|
1246
|
+
"name": "default"
|
|
1247
|
+
}
|
|
1248
|
+
],
|
|
1249
|
+
"docs": "Whether or not to automatically block bundles that have been rolled back.\n\nWhen enabled, the plugin will automatically block bundles that caused a rollback\n(up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked.\nBlocked bundles will be skipped in future sync operations.\n\n**Attention**: This option has no effect if `readyTimeout` is set to `0`.\n\nOnly available on Android and iOS.",
|
|
1250
|
+
"complexTypes": [],
|
|
1251
|
+
"type": "boolean | undefined"
|
|
1252
|
+
},
|
|
1165
1253
|
{
|
|
1166
1254
|
"name": "autoDeleteBundles",
|
|
1167
1255
|
"tags": [
|
|
@@ -1178,6 +1266,26 @@
|
|
|
1178
1266
|
"complexTypes": [],
|
|
1179
1267
|
"type": "boolean | undefined"
|
|
1180
1268
|
},
|
|
1269
|
+
{
|
|
1270
|
+
"name": "autoUpdateStrategy",
|
|
1271
|
+
"tags": [
|
|
1272
|
+
{
|
|
1273
|
+
"text": "7.3.0",
|
|
1274
|
+
"name": "since"
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
"text": "'none'",
|
|
1278
|
+
"name": "default"
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
"text": "'background'",
|
|
1282
|
+
"name": "example"
|
|
1283
|
+
}
|
|
1284
|
+
],
|
|
1285
|
+
"docs": "The auto-update strategy for live updates.\n\n- `none`: Live updates will not be applied automatically.\n- `background`: Live updates will be automatically downloaded\nand applied in the background at app startup and when the app resumes\n(if the last check was more than 15 minutes ago).\n\nOnly available on Android and iOS.",
|
|
1286
|
+
"complexTypes": [],
|
|
1287
|
+
"type": "'none' | 'background' | undefined"
|
|
1288
|
+
},
|
|
1181
1289
|
{
|
|
1182
1290
|
"name": "defaultChannel",
|
|
1183
1291
|
"tags": [
|
|
@@ -1242,7 +1350,7 @@
|
|
|
1242
1350
|
"name": "example"
|
|
1243
1351
|
}
|
|
1244
1352
|
],
|
|
1245
|
-
"docs": "The timeout in milliseconds to wait for the app to be ready\nbefore resetting to the default bundle.\n\nIt is strongly **recommended** to configure this option
|
|
1353
|
+
"docs": "The timeout in milliseconds to wait for the app to be ready\nbefore resetting to the default bundle.\n\nIt is strongly **recommended** to configure this option (e.g. `10000` ms)\nso that the plugin can roll back to the default bundle in case of problems.\nIf configured, the plugin will wait for the app to call the `ready()`\nmethod before resetting to the default bundle.\n\nSet to `0` to disable the timeout.",
|
|
1246
1354
|
"complexTypes": [],
|
|
1247
1355
|
"type": "number | undefined"
|
|
1248
1356
|
},
|
|
@@ -12,6 +12,21 @@ declare module '@capacitor/cli' {
|
|
|
12
12
|
* @example '6e351b4f-69a7-415e-a057-4567df7ffe94'
|
|
13
13
|
*/
|
|
14
14
|
appId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether or not to automatically block bundles that have been rolled back.
|
|
17
|
+
*
|
|
18
|
+
* When enabled, the plugin will automatically block bundles that caused a rollback
|
|
19
|
+
* (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked.
|
|
20
|
+
* Blocked bundles will be skipped in future sync operations.
|
|
21
|
+
*
|
|
22
|
+
* **Attention**: This option has no effect if `readyTimeout` is set to `0`.
|
|
23
|
+
*
|
|
24
|
+
* Only available on Android and iOS.
|
|
25
|
+
*
|
|
26
|
+
* @since 7.3.0
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
autoBlockRolledBackBundles?: boolean;
|
|
15
30
|
/**
|
|
16
31
|
* Whether or not to automatically delete unused bundles.
|
|
17
32
|
*
|
|
@@ -21,6 +36,21 @@ declare module '@capacitor/cli' {
|
|
|
21
36
|
* @default false
|
|
22
37
|
*/
|
|
23
38
|
autoDeleteBundles?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The auto-update strategy for live updates.
|
|
41
|
+
*
|
|
42
|
+
* - `none`: Live updates will not be applied automatically.
|
|
43
|
+
* - `background`: Live updates will be automatically downloaded
|
|
44
|
+
* and applied in the background at app startup and when the app resumes
|
|
45
|
+
* (if the last check was more than 15 minutes ago).
|
|
46
|
+
*
|
|
47
|
+
* Only available on Android and iOS.
|
|
48
|
+
*
|
|
49
|
+
* @since 7.3.0
|
|
50
|
+
* @default 'none'
|
|
51
|
+
* @example 'background'
|
|
52
|
+
*/
|
|
53
|
+
autoUpdateStrategy?: 'none' | 'background';
|
|
24
54
|
/**
|
|
25
55
|
* The default channel of the app.
|
|
26
56
|
*
|
|
@@ -48,8 +78,8 @@ declare module '@capacitor/cli' {
|
|
|
48
78
|
* The timeout in milliseconds to wait for the app to be ready
|
|
49
79
|
* before resetting to the default bundle.
|
|
50
80
|
*
|
|
51
|
-
* It is strongly **recommended** to configure this option
|
|
52
|
-
* the plugin can roll back to the default bundle in case of problems.
|
|
81
|
+
* It is strongly **recommended** to configure this option (e.g. `10000` ms)
|
|
82
|
+
* so that the plugin can roll back to the default bundle in case of problems.
|
|
53
83
|
* If configured, the plugin will wait for the app to call the `ready()`
|
|
54
84
|
* method before resetting to the default bundle.
|
|
55
85
|
*
|
|
@@ -242,6 +272,17 @@ export interface LiveUpdatePlugin {
|
|
|
242
272
|
* @since 7.0.0
|
|
243
273
|
*/
|
|
244
274
|
addListener(eventName: 'downloadBundleProgress', listenerFunc: DownloadBundleProgressListener): Promise<PluginListenerHandle>;
|
|
275
|
+
/**
|
|
276
|
+
* Listen for when a bundle is set as the next bundle.
|
|
277
|
+
*
|
|
278
|
+
* This event is triggered whenever a bundle is set to be used on the next app restart,
|
|
279
|
+
* either through automatic updates or manual calls to `setNextBundle()`.
|
|
280
|
+
*
|
|
281
|
+
* Only available on Android and iOS.
|
|
282
|
+
*
|
|
283
|
+
* @since 7.3.0
|
|
284
|
+
*/
|
|
285
|
+
addListener(eventName: 'nextBundleSet', listenerFunc: NextBundleSetListener): Promise<PluginListenerHandle>;
|
|
245
286
|
/**
|
|
246
287
|
* Remove all listeners for this plugin.
|
|
247
288
|
*
|
|
@@ -647,3 +688,25 @@ export interface DownloadBundleProgressEvent {
|
|
|
647
688
|
*/
|
|
648
689
|
totalBytes: number;
|
|
649
690
|
}
|
|
691
|
+
/**
|
|
692
|
+
* Listener for when a bundle is set as the next bundle.
|
|
693
|
+
*
|
|
694
|
+
* @since 7.3.0
|
|
695
|
+
*/
|
|
696
|
+
export declare type NextBundleSetListener = (event: NextBundleSetEvent) => void;
|
|
697
|
+
/**
|
|
698
|
+
* Event that is triggered when a bundle is set as the next bundle.
|
|
699
|
+
*
|
|
700
|
+
* @since 7.3.0
|
|
701
|
+
*/
|
|
702
|
+
export interface NextBundleSetEvent {
|
|
703
|
+
/**
|
|
704
|
+
* The unique identifier of the bundle that is set as the next bundle.
|
|
705
|
+
*
|
|
706
|
+
* If `null`, the default bundle will be used.
|
|
707
|
+
*
|
|
708
|
+
* @since 7.3.0
|
|
709
|
+
* @example '1.0.0'
|
|
710
|
+
*/
|
|
711
|
+
bundleId: string | null;
|
|
712
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n LiveUpdate?: {\n /**\n * The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * This is **NOT** the same as the app identifier (e.g. `com.example.app`).\n * This is a unique identifier generated by Capawesome Cloud (e.g. `6e351b4f-69a7-415e-a057-4567df7ffe94`).\n *\n * @since 5.0.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId?: string;\n /**\n * Whether or not to automatically delete unused bundles.\n *\n * When enabled, the plugin will automatically delete unused bundles after calling `ready()`.\n *\n * @since 5.0.0\n * @default false\n */\n autoDeleteBundles?: boolean;\n /**\n * The default channel of the app.\n *\n * @since 6.3.0\n * @example 'production'\n */\n defaultChannel?: string;\n /**\n * The timeout in milliseconds for HTTP requests.\n *\n * @since 6.4.0\n * @default 60000\n */\n httpTimeout?: number;\n /**\n * The public key to verify the integrity of the bundle.\n *\n * The public key must be a PEM-encoded RSA public key.\n *\n * @since 6.1.0\n * @example '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----'\n */\n publicKey?: string;\n /**\n * The timeout in milliseconds to wait for the app to be ready\n * before resetting to the default bundle.\n *\n * It is strongly **recommended** to configure this option so that\n * the plugin can roll back to the default bundle in case of problems.\n * If configured, the plugin will wait for the app to call the `ready()`\n * method before resetting to the default bundle.\n *\n * Set to `0` to disable the timeout.\n *\n * @since 5.0.0\n * @default 0\n * @example 10000\n */\n readyTimeout?: number;\n /**\n * The API domain of the [Capawesome Cloud](https://cloud.capawesome.io) server **without** scheme or path.\n *\n * @since 7.0.0\n * @default 'api.cloud.capawesome.io'\n * @example 'api.cloud.capawesome.eu'\n */\n serverDomain?: string;\n };\n }\n}\n\nexport interface LiveUpdatePlugin {\n /**\n * Delete a bundle from the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n deleteBundle(options: DeleteBundleOptions): Promise<void>;\n /**\n * Download a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n downloadBundle(options: DownloadBundleOptions): Promise<void>;\n /**\n * Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Only available on Android and iOS.\n *\n * @since 6.6.0\n */\n fetchLatestBundle(\n options?: FetchLatestBundleOptions,\n ): Promise<FetchLatestBundleResult>;\n /**\n * Get all identifiers of bundles that have been downloaded.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel that is used for the update.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the bundle identifier of the current bundle.\n * The current bundle is the bundle that is currently used by the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getCurrentBundle(): Promise<GetCurrentBundleResult>;\n /**\n * Get the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the unique device identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Get the bundle identifier of the next bundle.\n * The next bundle is the bundle that will be used after calling `reload()`\n * or restarting the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getNextBundle(): Promise<GetNextBundleResult>;\n /**\n * Get the version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionCode(): Promise<GetVersionCodeResult>;\n /**\n * Get the version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionName(): Promise<GetVersionNameResult>;\n /**\n * Notify the plugin that the app is ready to use and no rollback is needed.\n *\n * **Attention**: This method should be called as soon as the app is ready to use\n * to prevent the app from being reset to the default bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n ready(): Promise<ReadyResult>;\n /**\n * Reload the app to apply the new bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reload(): Promise<void>;\n /**\n * Reset the app to the default bundle.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reset(): Promise<void>;\n /**\n * Set the channel to use for the update.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setChannel(options: SetChannelOptions): Promise<void>;\n /**\n * Set the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n /**\n * Set the next bundle to use for the app.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n setNextBundle(options: SetNextBundleOptions): Promise<void>;\n /**\n * Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n sync(options?: SyncOptions): Promise<SyncResult>;\n /**\n * Listen for the download progress of a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 7.0.0\n */\n addListener(\n eventName: 'downloadBundleProgress',\n listenerFunc: DownloadBundleProgressListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 7.2.0\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface DeleteBundleOptions {\n /**\n * The unique identifier of the bundle to delete.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\nexport interface DownloadBundleOptions {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.6.0\n * @default 'zip'\n * @example 'manifest'\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the bundle.\n *\n * **Attention**: The value `public` is reserved and cannot be used as a bundle identifier.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the self-hosted bundle as a SHA-256 hash\n * in base64 format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * The signature of the self-hosted bundle as a signed SHA-256 hash\n * in base64 format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n signature?: string;\n /**\n * The URL of the bundle to download.\n *\n * For the `zip` artifact type, the URL must point to a ZIP file.\n * For the `manifest` artifact type, the URL serves as the base URL\n * to download the individual files. For example, if the URL is\n * `https://example.com/download`, the plugin will download the file\n * with the href `index.html` from `https://example.com/download?href=index.html`.\n *\n * To **verify the integrity** of the file, the server should return\n * a `X-Checksum` header with the SHA-256 hash in base64 format.\n *\n * To **verify the signature** of the file, the server should return\n * a `X-Signature` header with the signed SHA-256 hash in base64 format.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: string;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface FetchLatestBundleOptions {\n /**\n * The name of the channel where the latest bundle is fetched from.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 6.6.0\n */\nexport interface FetchLatestBundleResult {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.7.0\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the latest bundle.\n *\n * If `null`, no bundle is available.\n *\n * @since 6.6.0\n */\n bundleId: string | null;\n /**\n * The checksum of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the checksum will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * Custom properties that are associated with the latest bundle.\n *\n * @since 7.0.0\n * @example { \"key\": \"value\" }\n */\n customProperties?: { [key: string]: string };\n /**\n * The URL of the latest bundle to download.\n * Pass this URL to the `downloadBundle(...)` method to download the bundle.\n *\n * @since 6.7.0\n */\n downloadUrl?: string;\n /**\n * The signature of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the signature will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n signature?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundleResult {\n /**\n * The unique identifier of the active bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundlesResult {\n /**\n * An array of unique identifiers of all available bundles.\n *\n * @since 5.0.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetChannelResult {\n /**\n * The channel name.\n *\n * If `null`, the app is using the default channel.\n *\n * @since 5.0.0\n * @example 'production'\n */\n channel: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetCurrentBundleResult {\n /**\n * The unique identifier of the current bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetDeviceIdResult {\n /**\n * The unique identifier of the device.\n *\n * On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used.\n * The value of this property is the same for apps that come from the same vendor running on the same device.\n *\n * @since 5.0.0\n *\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n deviceId: string;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetNextBundleResult {\n /**\n * The unique identifier of the next bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionCodeResult {\n /**\n * The version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1\"\n */\n versionCode: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionNameResult {\n /**\n * The version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1.0.0\"\n */\n versionName: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetCustomIdResult {\n /**\n * The custom identifier of the device.\n *\n * If `null`, no custom identifier is set.\n *\n * @since 5.0.0\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n customId: string | null;\n}\n\n/**\n * @since 7.0.0\n */\nexport interface ReadyResult {\n /**\n * The identifier of the previous bundle used.\n *\n * If `null`, the default bundle was used.\n *\n * @since 7.0.0\n */\n previousBundleId: string | null;\n /**\n * The identifier of the current bundle used.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 7.0.0\n */\n currentBundleId: string | null;\n /**\n * Whether or not the app was reset to the default bundle.\n *\n * @since 7.0.0\n */\n rollback: boolean;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetChannelOptions {\n /**\n * The channel name.\n *\n * Set `null` to remove the channel.\n *\n * @since 5.0.0\n */\n channel: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetCustomIdOptions {\n /**\n * The custom identifier of the device.\n *\n * Set `null` to remove the custom identifier.\n *\n * @since 5.0.0\n */\n customId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SetNextBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * Set `null` to use the default bundle (same as calling `reset()`).\n *\n * @since 6.7.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SyncOptions {\n /**\n * The name of the channel where the latest bundle is fetched from.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SyncResult {\n /**\n * The identifier of the next bundle to use.\n *\n * If `null`, the app is up-to-date and no new bundle is available.\n *\n * @since 5.0.0\n */\n nextBundleId: string | null;\n}\n\n/**\n * Listener for the download progress of a bundle.\n *\n * @since 7.0.0\n */\nexport type DownloadBundleProgressListener = (\n event: DownloadBundleProgressEvent,\n) => void;\n\n/**\n * Event that is triggered when the download progress of a bundle changes.\n *\n * @since 7.0.0\n */\nexport interface DownloadBundleProgressEvent {\n /**\n * The unique identifier of the bundle that is being downloaded.\n *\n * @since 7.0.0\n */\n bundleId: string;\n /**\n * The number of bytes that have been downloaded.\n *\n * @since 7.0.0\n */\n downloadedBytes: number;\n /**\n * The progress of the download in percent as a value between `0` and `1`.\n *\n * @since 7.0.0\n * @example 0.5\n */\n progress: number;\n /**\n * The total number of bytes to download.\n *\n * @since 7.0.0\n */\n totalBytes: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n LiveUpdate?: {\n /**\n * The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * This is **NOT** the same as the app identifier (e.g. `com.example.app`).\n * This is a unique identifier generated by Capawesome Cloud (e.g. `6e351b4f-69a7-415e-a057-4567df7ffe94`).\n *\n * @since 5.0.0\n * @example '6e351b4f-69a7-415e-a057-4567df7ffe94'\n */\n appId?: string;\n /**\n * Whether or not to automatically block bundles that have been rolled back.\n *\n * When enabled, the plugin will automatically block bundles that caused a rollback\n * (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked.\n * Blocked bundles will be skipped in future sync operations.\n *\n * **Attention**: This option has no effect if `readyTimeout` is set to `0`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n * @default false\n */\n autoBlockRolledBackBundles?: boolean;\n /**\n * Whether or not to automatically delete unused bundles.\n *\n * When enabled, the plugin will automatically delete unused bundles after calling `ready()`.\n *\n * @since 5.0.0\n * @default false\n */\n autoDeleteBundles?: boolean;\n /**\n * The auto-update strategy for live updates.\n *\n * - `none`: Live updates will not be applied automatically.\n * - `background`: Live updates will be automatically downloaded\n * and applied in the background at app startup and when the app resumes\n * (if the last check was more than 15 minutes ago).\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n * @default 'none'\n * @example 'background'\n */\n autoUpdateStrategy?: 'none' | 'background';\n /**\n * The default channel of the app.\n *\n * @since 6.3.0\n * @example 'production'\n */\n defaultChannel?: string;\n /**\n * The timeout in milliseconds for HTTP requests.\n *\n * @since 6.4.0\n * @default 60000\n */\n httpTimeout?: number;\n /**\n * The public key to verify the integrity of the bundle.\n *\n * The public key must be a PEM-encoded RSA public key.\n *\n * @since 6.1.0\n * @example '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----'\n */\n publicKey?: string;\n /**\n * The timeout in milliseconds to wait for the app to be ready\n * before resetting to the default bundle.\n *\n * It is strongly **recommended** to configure this option (e.g. `10000` ms)\n * so that the plugin can roll back to the default bundle in case of problems.\n * If configured, the plugin will wait for the app to call the `ready()`\n * method before resetting to the default bundle.\n *\n * Set to `0` to disable the timeout.\n *\n * @since 5.0.0\n * @default 0\n * @example 10000\n */\n readyTimeout?: number;\n /**\n * The API domain of the [Capawesome Cloud](https://cloud.capawesome.io) server **without** scheme or path.\n *\n * @since 7.0.0\n * @default 'api.cloud.capawesome.io'\n * @example 'api.cloud.capawesome.eu'\n */\n serverDomain?: string;\n };\n }\n}\n\nexport interface LiveUpdatePlugin {\n /**\n * Delete a bundle from the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n deleteBundle(options: DeleteBundleOptions): Promise<void>;\n /**\n * Download a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n downloadBundle(options: DownloadBundleOptions): Promise<void>;\n /**\n * Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Only available on Android and iOS.\n *\n * @since 6.6.0\n */\n fetchLatestBundle(\n options?: FetchLatestBundleOptions,\n ): Promise<FetchLatestBundleResult>;\n /**\n * Get all identifiers of bundles that have been downloaded.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel that is used for the update.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the bundle identifier of the current bundle.\n * The current bundle is the bundle that is currently used by the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getCurrentBundle(): Promise<GetCurrentBundleResult>;\n /**\n * Get the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the unique device identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Get the bundle identifier of the next bundle.\n * The next bundle is the bundle that will be used after calling `reload()`\n * or restarting the app.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n getNextBundle(): Promise<GetNextBundleResult>;\n /**\n * Get the version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionCode(): Promise<GetVersionCodeResult>;\n /**\n * Get the version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getVersionName(): Promise<GetVersionNameResult>;\n /**\n * Notify the plugin that the app is ready to use and no rollback is needed.\n *\n * **Attention**: This method should be called as soon as the app is ready to use\n * to prevent the app from being reset to the default bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n ready(): Promise<ReadyResult>;\n /**\n * Reload the app to apply the new bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reload(): Promise<void>;\n /**\n * Reset the app to the default bundle.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n reset(): Promise<void>;\n /**\n * Set the channel to use for the update.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setChannel(options: SetChannelOptions): Promise<void>;\n /**\n * Set the custom identifier of the device.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n /**\n * Set the next bundle to use for the app.\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 6.7.0\n */\n setNextBundle(options: SetNextBundleOptions): Promise<void>;\n /**\n * Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).\n *\n * Call `reload()` or restart the app to apply the changes.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n sync(options?: SyncOptions): Promise<SyncResult>;\n /**\n * Listen for the download progress of a bundle.\n *\n * Only available on Android and iOS.\n *\n * @since 7.0.0\n */\n addListener(\n eventName: 'downloadBundleProgress',\n listenerFunc: DownloadBundleProgressListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Listen for when a bundle is set as the next bundle.\n *\n * This event is triggered whenever a bundle is set to be used on the next app restart,\n * either through automatic updates or manual calls to `setNextBundle()`.\n *\n * Only available on Android and iOS.\n *\n * @since 7.3.0\n */\n addListener(\n eventName: 'nextBundleSet',\n listenerFunc: NextBundleSetListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 7.2.0\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface DeleteBundleOptions {\n /**\n * The unique identifier of the bundle to delete.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\nexport interface DownloadBundleOptions {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.6.0\n * @default 'zip'\n * @example 'manifest'\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the bundle.\n *\n * **Attention**: The value `public` is reserved and cannot be used as a bundle identifier.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the self-hosted bundle as a SHA-256 hash\n * in base64 format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * The signature of the self-hosted bundle as a signed SHA-256 hash\n * in base64 format to verify the integrity of the bundle.\n *\n * **Attention**: Only supported for the `zip` artifact type.\n *\n * @since 7.1.0\n */\n signature?: string;\n /**\n * The URL of the bundle to download.\n *\n * For the `zip` artifact type, the URL must point to a ZIP file.\n * For the `manifest` artifact type, the URL serves as the base URL\n * to download the individual files. For example, if the URL is\n * `https://example.com/download`, the plugin will download the file\n * with the href `index.html` from `https://example.com/download?href=index.html`.\n *\n * To **verify the integrity** of the file, the server should return\n * a `X-Checksum` header with the SHA-256 hash in base64 format.\n *\n * To **verify the signature** of the file, the server should return\n * a `X-Signature` header with the signed SHA-256 hash in base64 format.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: string;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface FetchLatestBundleOptions {\n /**\n * The name of the channel where the latest bundle is fetched from.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 6.6.0\n */\nexport interface FetchLatestBundleResult {\n /**\n * The artifact type of the bundle.\n *\n * @since 6.7.0\n */\n artifactType?: 'manifest' | 'zip';\n /**\n * The unique identifier of the latest bundle.\n *\n * If `null`, no bundle is available.\n *\n * @since 6.6.0\n */\n bundleId: string | null;\n /**\n * The checksum of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the checksum will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n checksum?: string;\n /**\n * Custom properties that are associated with the latest bundle.\n *\n * @since 7.0.0\n * @example { \"key\": \"value\" }\n */\n customProperties?: { [key: string]: string };\n /**\n * The URL of the latest bundle to download.\n * Pass this URL to the `downloadBundle(...)` method to download the bundle.\n *\n * @since 6.7.0\n */\n downloadUrl?: string;\n /**\n * The signature of the latest bundle if the bundle is self-hosted.\n *\n * If the bundle is hosted on Capawesome Cloud, the signature will be\n * returned as response header when downloading the bundle.\n *\n * @since 7.1.0\n */\n signature?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundleResult {\n /**\n * The unique identifier of the active bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetBundlesResult {\n /**\n * An array of unique identifiers of all available bundles.\n *\n * @since 5.0.0\n */\n bundleIds: string[];\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetChannelResult {\n /**\n * The channel name.\n *\n * If `null`, the app is using the default channel.\n *\n * @since 5.0.0\n * @example 'production'\n */\n channel: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetCurrentBundleResult {\n /**\n * The unique identifier of the current bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetDeviceIdResult {\n /**\n * The unique identifier of the device.\n *\n * On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used.\n * The value of this property is the same for apps that come from the same vendor running on the same device.\n *\n * @since 5.0.0\n *\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n deviceId: string;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface GetNextBundleResult {\n /**\n * The unique identifier of the next bundle.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 6.7.0\n */\n bundleId: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionCodeResult {\n /**\n * The version code of the app.\n *\n * On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1\"\n */\n versionCode: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetVersionNameResult {\n /**\n * The version name of the app.\n *\n * On **Android**, this is the `versionName` from the `android/app/build.gradle` file.\n * On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.\n *\n * @since 5.0.0\n * @example \"1.0.0\"\n */\n versionName: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface GetCustomIdResult {\n /**\n * The custom identifier of the device.\n *\n * If `null`, no custom identifier is set.\n *\n * @since 5.0.0\n * @example '50d2a548-80b7-4dad-adc7-97c0e79d8a89'\n */\n customId: string | null;\n}\n\n/**\n * @since 7.0.0\n */\nexport interface ReadyResult {\n /**\n * The identifier of the previous bundle used.\n *\n * If `null`, the default bundle was used.\n *\n * @since 7.0.0\n */\n previousBundleId: string | null;\n /**\n * The identifier of the current bundle used.\n *\n * If `null`, the default bundle is being used.\n *\n * @since 7.0.0\n */\n currentBundleId: string | null;\n /**\n * Whether or not the app was reset to the default bundle.\n *\n * @since 7.0.0\n */\n rollback: boolean;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetChannelOptions {\n /**\n * The channel name.\n *\n * Set `null` to remove the channel.\n *\n * @since 5.0.0\n */\n channel: string | null;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SetCustomIdOptions {\n /**\n * The custom identifier of the device.\n *\n * Set `null` to remove the custom identifier.\n *\n * @since 5.0.0\n */\n customId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SetNextBundleOptions {\n /**\n * The unique identifier of the bundle to use.\n *\n * Set `null` to use the default bundle (same as calling `reset()`).\n *\n * @since 6.7.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n\n/**\n * @since 6.7.0\n */\nexport interface SyncOptions {\n /**\n * The name of the channel where the latest bundle is fetched from.\n *\n * @since 6.7.0\n */\n channel?: string;\n}\n\n/**\n * @since 5.0.0\n */\nexport interface SyncResult {\n /**\n * The identifier of the next bundle to use.\n *\n * If `null`, the app is up-to-date and no new bundle is available.\n *\n * @since 5.0.0\n */\n nextBundleId: string | null;\n}\n\n/**\n * Listener for the download progress of a bundle.\n *\n * @since 7.0.0\n */\nexport type DownloadBundleProgressListener = (\n event: DownloadBundleProgressEvent,\n) => void;\n\n/**\n * Event that is triggered when the download progress of a bundle changes.\n *\n * @since 7.0.0\n */\nexport interface DownloadBundleProgressEvent {\n /**\n * The unique identifier of the bundle that is being downloaded.\n *\n * @since 7.0.0\n */\n bundleId: string;\n /**\n * The number of bytes that have been downloaded.\n *\n * @since 7.0.0\n */\n downloadedBytes: number;\n /**\n * The progress of the download in percent as a value between `0` and `1`.\n *\n * @since 7.0.0\n * @example 0.5\n */\n progress: number;\n /**\n * The total number of bytes to download.\n *\n * @since 7.0.0\n */\n totalBytes: number;\n}\n\n/**\n * Listener for when a bundle is set as the next bundle.\n *\n * @since 7.3.0\n */\nexport type NextBundleSetListener = (event: NextBundleSetEvent) => void;\n\n/**\n * Event that is triggered when a bundle is set as the next bundle.\n *\n * @since 7.3.0\n */\nexport interface NextBundleSetEvent {\n /**\n * The unique identifier of the bundle that is set as the next bundle.\n *\n * If `null`, the default bundle will be used.\n *\n * @since 7.3.0\n * @example '1.0.0'\n */\n bundleId: string | null;\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc public class NextBundleSetEvent: NSObject {
|
|
5
|
+
let bundleId: String?
|
|
6
|
+
|
|
7
|
+
init(bundleId: String?) {
|
|
8
|
+
self.bundleId = bundleId
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public func toJSObject() -> JSObject {
|
|
12
|
+
var result = JSObject()
|
|
13
|
+
result["bundleId"] = bundleId == nil ? NSNull() : bundleId
|
|
14
|
+
return result
|
|
15
|
+
}
|
|
16
|
+
}
|