@capawesome/capacitor-live-update 6.5.0 → 6.7.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 +184 -37
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +63 -5
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +98 -3
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +3 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +15 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/FetchLatestBundleOptions.java +24 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetNextBundleOptions.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SyncOptions.java +20 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +41 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetCurrentBundleResult.java +22 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetNextBundleResult.java +22 -0
- package/dist/docs.json +318 -18
- package/dist/esm/definitions.d.ts +159 -14
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +5 -1
- package/dist/esm/web.js +12 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +12 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +12 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +11 -1
- package/ios/Plugin/Classes/Options/FetchLatestBundleOptions.swift +18 -0
- package/ios/Plugin/Classes/Options/SetNextBundleOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/SyncOptions.swift +14 -0
- package/ios/Plugin/Classes/Results/FetchLatestBundle.swift +28 -0
- package/ios/Plugin/Classes/Results/GetCurrentBundleResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetNextBundleResult.swift +16 -0
- package/ios/Plugin/LiveUpdate.swift +55 -6
- package/ios/Plugin/LiveUpdatePlugin.m +5 -1
- package/ios/Plugin/LiveUpdatePlugin.swift +79 -20
- package/package.json +2 -2
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java
CHANGED
|
@@ -8,9 +8,14 @@ import com.getcapacitor.PluginMethod;
|
|
|
8
8
|
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
9
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DeleteBundleOptions;
|
|
10
10
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DownloadBundleOptions;
|
|
11
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.FetchLatestBundleOptions;
|
|
11
12
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetBundleOptions;
|
|
12
13
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetChannelOptions;
|
|
13
14
|
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetCustomIdOptions;
|
|
15
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetNextBundleOptions;
|
|
16
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SyncOptions;
|
|
17
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetCurrentBundleResult;
|
|
18
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetNextBundleResult;
|
|
14
19
|
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.EmptyCallback;
|
|
15
20
|
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.NonEmptyCallback;
|
|
16
21
|
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
@@ -19,7 +24,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
|
19
24
|
public class LiveUpdatePlugin extends Plugin {
|
|
20
25
|
|
|
21
26
|
public static final String TAG = "LiveUpdate";
|
|
22
|
-
public static final String VERSION = "6.
|
|
27
|
+
public static final String VERSION = "6.6.0";
|
|
23
28
|
public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
|
|
24
29
|
public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
|
|
25
30
|
public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
|
|
@@ -86,6 +91,7 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
86
91
|
@PluginMethod
|
|
87
92
|
public void downloadBundle(PluginCall call) {
|
|
88
93
|
try {
|
|
94
|
+
String artifactType = call.getString("artifactType", "zip");
|
|
89
95
|
String bundleId = call.getString("bundleId");
|
|
90
96
|
if (bundleId == null) {
|
|
91
97
|
call.reject(ERROR_BUNDLE_ID_MISSING);
|
|
@@ -98,7 +104,7 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
98
104
|
return;
|
|
99
105
|
}
|
|
100
106
|
|
|
101
|
-
DownloadBundleOptions options = new DownloadBundleOptions(bundleId, checksum, url);
|
|
107
|
+
DownloadBundleOptions options = new DownloadBundleOptions(artifactType, bundleId, checksum, url);
|
|
102
108
|
EmptyCallback callback = new EmptyCallback() {
|
|
103
109
|
@Override
|
|
104
110
|
public void success() {
|
|
@@ -117,6 +123,28 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
117
123
|
}
|
|
118
124
|
}
|
|
119
125
|
|
|
126
|
+
@PluginMethod
|
|
127
|
+
public void fetchLatestBundle(PluginCall call) {
|
|
128
|
+
try {
|
|
129
|
+
FetchLatestBundleOptions options = new FetchLatestBundleOptions(call);
|
|
130
|
+
NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
|
|
131
|
+
@Override
|
|
132
|
+
public void success(Result result) {
|
|
133
|
+
call.resolve(result.toJSObject());
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
public void error(Exception exception) {
|
|
138
|
+
rejectCall(call, exception);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
implementation.fetchLatestBundle(options, callback);
|
|
143
|
+
} catch (Exception exception) {
|
|
144
|
+
rejectCall(call, exception);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
120
148
|
@PluginMethod
|
|
121
149
|
public void getBundle(PluginCall call) {
|
|
122
150
|
try {
|
|
@@ -180,6 +208,28 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
180
208
|
}
|
|
181
209
|
}
|
|
182
210
|
|
|
211
|
+
@PluginMethod
|
|
212
|
+
public void getCurrentBundle(PluginCall call) {
|
|
213
|
+
try {
|
|
214
|
+
NonEmptyCallback<GetCurrentBundleResult> callback = new NonEmptyCallback<>() {
|
|
215
|
+
@Override
|
|
216
|
+
public void success(GetCurrentBundleResult result) {
|
|
217
|
+
call.resolve(result.toJSObject());
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@Override
|
|
221
|
+
public void error(Exception exception) {
|
|
222
|
+
rejectCall(call, exception);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
assert implementation != null;
|
|
227
|
+
implementation.getCurrentBundle(callback);
|
|
228
|
+
} catch (Exception exception) {
|
|
229
|
+
rejectCall(call, exception);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
183
233
|
@PluginMethod
|
|
184
234
|
public void getCustomId(PluginCall call) {
|
|
185
235
|
try {
|
|
@@ -222,6 +272,28 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
222
272
|
}
|
|
223
273
|
}
|
|
224
274
|
|
|
275
|
+
@PluginMethod
|
|
276
|
+
public void getNextBundle(PluginCall call) {
|
|
277
|
+
try {
|
|
278
|
+
NonEmptyCallback<GetNextBundleResult> callback = new NonEmptyCallback<>() {
|
|
279
|
+
@Override
|
|
280
|
+
public void success(GetNextBundleResult result) {
|
|
281
|
+
call.resolve(result.toJSObject());
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
@Override
|
|
285
|
+
public void error(Exception exception) {
|
|
286
|
+
rejectCall(call, exception);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
assert implementation != null;
|
|
291
|
+
implementation.getNextBundle(callback);
|
|
292
|
+
} catch (Exception exception) {
|
|
293
|
+
rejectCall(call, exception);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
225
297
|
@PluginMethod
|
|
226
298
|
public void getVersionCode(PluginCall call) {
|
|
227
299
|
try {
|
|
@@ -374,6 +446,28 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
374
446
|
}
|
|
375
447
|
}
|
|
376
448
|
|
|
449
|
+
@PluginMethod
|
|
450
|
+
public void setNextBundle(PluginCall call) {
|
|
451
|
+
try {
|
|
452
|
+
SetNextBundleOptions options = new SetNextBundleOptions(call);
|
|
453
|
+
EmptyCallback callback = new EmptyCallback() {
|
|
454
|
+
@Override
|
|
455
|
+
public void success() {
|
|
456
|
+
call.resolve();
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
@Override
|
|
460
|
+
public void error(Exception exception) {
|
|
461
|
+
rejectCall(call, exception);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
implementation.setNextBundle(options, callback);
|
|
466
|
+
} catch (Exception exception) {
|
|
467
|
+
rejectCall(call, exception);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
377
471
|
@PluginMethod
|
|
378
472
|
public void sync(PluginCall call) {
|
|
379
473
|
try {
|
|
@@ -389,6 +483,7 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
389
483
|
}
|
|
390
484
|
syncInProgress = true;
|
|
391
485
|
|
|
486
|
+
SyncOptions options = new SyncOptions(call);
|
|
392
487
|
NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
|
|
393
488
|
@Override
|
|
394
489
|
public void success(Result result) {
|
|
@@ -403,7 +498,7 @@ public class LiveUpdatePlugin extends Plugin {
|
|
|
403
498
|
}
|
|
404
499
|
};
|
|
405
500
|
|
|
406
|
-
implementation.sync(callback);
|
|
501
|
+
implementation.sync(options, callback);
|
|
407
502
|
} catch (Exception exception) {
|
|
408
503
|
syncInProgress = false;
|
|
409
504
|
rejectCall(call, exception);
|
|
@@ -30,14 +30,17 @@ public class GetLatestBundleResponse {
|
|
|
30
30
|
this.url = responseJson.optString("url");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
@NonNull
|
|
33
34
|
public ArtifactType getArtifactType() {
|
|
34
35
|
return artifactType;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
@NonNull
|
|
37
39
|
public String getBundleId() {
|
|
38
40
|
return bundleId;
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
@NonNull
|
|
41
44
|
public String getUrl() {
|
|
42
45
|
return url;
|
|
43
46
|
}
|
|
@@ -2,9 +2,13 @@ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.enums.ArtifactType;
|
|
5
6
|
|
|
6
7
|
public class DownloadBundleOptions {
|
|
7
8
|
|
|
9
|
+
@NonNull
|
|
10
|
+
private ArtifactType artifactType;
|
|
11
|
+
|
|
8
12
|
@NonNull
|
|
9
13
|
private String bundleId;
|
|
10
14
|
|
|
@@ -14,12 +18,22 @@ public class DownloadBundleOptions {
|
|
|
14
18
|
@NonNull
|
|
15
19
|
private String url;
|
|
16
20
|
|
|
17
|
-
public DownloadBundleOptions(@NonNull String bundleId, @Nullable String checksum, @NonNull String url) {
|
|
21
|
+
public DownloadBundleOptions(@NonNull String artifactType, @NonNull String bundleId, @Nullable String checksum, @NonNull String url) {
|
|
22
|
+
if (artifactType.equals("manifest")) {
|
|
23
|
+
this.artifactType = ArtifactType.MANIFEST;
|
|
24
|
+
} else {
|
|
25
|
+
this.artifactType = ArtifactType.ZIP;
|
|
26
|
+
}
|
|
18
27
|
this.bundleId = bundleId;
|
|
19
28
|
this.checksum = checksum;
|
|
20
29
|
this.url = url;
|
|
21
30
|
}
|
|
22
31
|
|
|
32
|
+
@NonNull
|
|
33
|
+
public ArtifactType getArtifactType() {
|
|
34
|
+
return artifactType;
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
@NonNull
|
|
24
38
|
public String getBundleId() {
|
|
25
39
|
return bundleId;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
|
|
7
|
+
public class FetchLatestBundleOptions {
|
|
8
|
+
|
|
9
|
+
@Nullable
|
|
10
|
+
private final String channel;
|
|
11
|
+
|
|
12
|
+
public FetchLatestBundleOptions(@NonNull PluginCall call) {
|
|
13
|
+
this.channel = call.getString("channel", null);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public FetchLatestBundleOptions(@Nullable String channel) {
|
|
17
|
+
this.channel = channel;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Nullable
|
|
21
|
+
public String getChannel() {
|
|
22
|
+
return channel;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
|
|
7
|
+
public class SetNextBundleOptions {
|
|
8
|
+
|
|
9
|
+
@Nullable
|
|
10
|
+
private final String bundleId;
|
|
11
|
+
|
|
12
|
+
public SetNextBundleOptions(@NonNull PluginCall call) {
|
|
13
|
+
this.bundleId = call.getString("bundleId");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
public String getBundleId() {
|
|
18
|
+
return bundleId;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.PluginCall;
|
|
6
|
+
|
|
7
|
+
public class SyncOptions {
|
|
8
|
+
|
|
9
|
+
@Nullable
|
|
10
|
+
private final String channel;
|
|
11
|
+
|
|
12
|
+
public SyncOptions(@NonNull PluginCall call) {
|
|
13
|
+
this.channel = call.getString("channel", null);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Nullable
|
|
17
|
+
public String getChannel() {
|
|
18
|
+
return channel;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSObject;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.enums.ArtifactType;
|
|
7
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
8
|
+
import org.json.JSONObject;
|
|
9
|
+
|
|
10
|
+
public class FetchLatestBundleResult implements Result {
|
|
11
|
+
|
|
12
|
+
@Nullable
|
|
13
|
+
private final ArtifactType artifactType;
|
|
14
|
+
|
|
15
|
+
@Nullable
|
|
16
|
+
private final String bundleId;
|
|
17
|
+
|
|
18
|
+
@Nullable
|
|
19
|
+
private final String downloadUrl;
|
|
20
|
+
|
|
21
|
+
public FetchLatestBundleResult(@Nullable ArtifactType artifactType, @Nullable String bundleId, @Nullable String downloadUrl) {
|
|
22
|
+
this.artifactType = artifactType;
|
|
23
|
+
this.bundleId = bundleId;
|
|
24
|
+
this.downloadUrl = downloadUrl;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@NonNull
|
|
28
|
+
public JSObject toJSObject() {
|
|
29
|
+
JSObject result = new JSObject();
|
|
30
|
+
if (artifactType == ArtifactType.MANIFEST) {
|
|
31
|
+
result.put("artifactType", "manifest");
|
|
32
|
+
} else if (artifactType == ArtifactType.ZIP) {
|
|
33
|
+
result.put("artifactType", "zip");
|
|
34
|
+
}
|
|
35
|
+
result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
|
|
36
|
+
if (downloadUrl != null) {
|
|
37
|
+
result.put("downloadUrl", downloadUrl);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
6
|
+
import org.json.JSONObject;
|
|
7
|
+
|
|
8
|
+
public class GetCurrentBundleResult implements Result {
|
|
9
|
+
|
|
10
|
+
@Nullable
|
|
11
|
+
private String bundleId;
|
|
12
|
+
|
|
13
|
+
public GetCurrentBundleResult(@Nullable String bundleId) {
|
|
14
|
+
this.bundleId = bundleId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
6
|
+
import org.json.JSONObject;
|
|
7
|
+
|
|
8
|
+
public class GetNextBundleResult implements Result {
|
|
9
|
+
|
|
10
|
+
@Nullable
|
|
11
|
+
private String bundleId;
|
|
12
|
+
|
|
13
|
+
public GetNextBundleResult(@Nullable String bundleId) {
|
|
14
|
+
this.bundleId = bundleId;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public JSObject toJSObject() {
|
|
18
|
+
JSObject result = new JSObject();
|
|
19
|
+
result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|