@capawesome/capacitor-live-update 6.2.0-dev.0a2a6a5.1722676620 → 6.2.0-dev.4ebc29c.1723183892

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 CHANGED
@@ -69,6 +69,7 @@ We recommend to declare [`CA92.1`](https://developer.apple.com/documentation/bun
69
69
  | ----------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
70
70
  | **`appId`** | <code>string</code> | The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud). | | 5.0.0 |
71
71
  | **`autoDeleteBundles`** | <code>boolean</code> | Whether or not to automatically delete unused bundles. When enabled, the plugin will automatically delete unused bundles after calling `ready()`. | <code>false</code> | 5.0.0 |
72
+ | **`defaultChannel`** | <code>string</code> | The default channel of the app. | | 6.3.0 |
72
73
  | **`enabled`** | <code>boolean</code> | Whether or not the plugin is enabled. | <code>true</code> | 5.0.0 |
73
74
  | **`location`** | <code>'us' \| 'eu'</code> | The location of the server to use when using [Capawesome Cloud](https://capawesome.io/cloud). | <code>'us'</code> | 6.2.0 |
74
75
  | **`publicKey`** | <code>string</code> | The public key to verify the integrity of the bundle. The public key must be a PEM-encoded RSA public key. | | 6.1.0 |
@@ -85,6 +86,7 @@ In `capacitor.config.json`:
85
86
  "LiveUpdate": {
86
87
  "appId": '4100e356-e851-47fe-9d3c-b411eb325a99',
87
88
  "autoDeleteBundles": undefined,
89
+ "defaultChannel": 'production',
88
90
  "enabled": undefined,
89
91
  "location": 'eu',
90
92
  "publicKey": '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----',
@@ -107,6 +109,7 @@ const config: CapacitorConfig = {
107
109
  LiveUpdate: {
108
110
  appId: '4100e356-e851-47fe-9d3c-b411eb325a99',
109
111
  autoDeleteBundles: undefined,
112
+ defaultChannel: 'production',
110
113
  enabled: undefined,
111
114
  location: 'eu',
112
115
  publicKey: '-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDodf1SD0OOn6hIlDuKBza0Ed0OqtwyVJwiyjmE9BJaZ7y8ZUfcF+SKmd0l2cDPM45XIg2tAFux5n29uoKyHwSt+6tCi5CJA5Z1/1eZruRRqABLonV77KS3HUtvOgqRLDnKSV89dYZkM++NwmzOPgIF422mvc+VukcVOBfc8/AHQIDAQAB-----END PUBLIC KEY-----',
@@ -401,7 +404,7 @@ Only available on Android and iOS.
401
404
  ### ready()
402
405
 
403
406
  ```typescript
404
- ready() => Promise<ReadyResult>
407
+ ready() => Promise<void>
405
408
  ```
406
409
 
407
410
  Notify the plugin that the app is ready to use and no rollback is needed.
@@ -411,8 +414,6 @@ to prevent the app from being reset to the default bundle.
411
414
 
412
415
  Only available on Android and iOS.
413
416
 
414
- **Returns:** <code>Promise&lt;<a href="#readyresult">ReadyResult</a>&gt;</code>
415
-
416
417
  **Since:** 5.0.0
417
418
 
418
419
  --------------------
@@ -596,15 +597,6 @@ Only available on Android and iOS.
596
597
  | **`versionName`** | <code>string</code> | The version name of the app. On **Android**, this is the `versionName` from the `android/app/build.gradle` file. On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file. | 5.0.0 |
597
598
 
598
599
 
599
- #### ReadyResult
600
-
601
- | Prop | Type | Description | Since |
602
- | ---------------------- | --------------------------- | --------------------------------------------------------------------------------------- | ----- |
603
- | **`previousBundleId`** | <code>string \| null</code> | The identifier of the previous bundle used. If `null`, the default bundle was used. | 7.0.0 |
604
- | **`currentBundleId`** | <code>string \| null</code> | The identifier of the current bundle used. If `null`, the default bundle is being used. | 7.0.0 |
605
- | **`rollback`** | <code>boolean</code> | Whether or not the app was reset to the default bundle. | 7.0.0 |
606
-
607
-
608
600
  #### SetBundleOptions
609
601
 
610
602
  | Prop | Type | Description | Since |
@@ -9,7 +9,6 @@ import android.os.Handler;
9
9
  import android.util.Base64;
10
10
  import androidx.annotation.NonNull;
11
11
  import androidx.annotation.Nullable;
12
- import com.getcapacitor.Bridge;
13
12
  import com.getcapacitor.Logger;
14
13
  import com.getcapacitor.plugin.WebView;
15
14
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.api.GetLatestBundleResponse;
@@ -25,7 +24,6 @@ import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetCustomIdR
25
24
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetDeviceIdResult;
26
25
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetVersionCodeResult;
27
26
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetVersionNameResult;
28
- import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.ReadyResult;
29
27
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.SyncResult;
30
28
  import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.EmptyCallback;
31
29
  import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.NonEmptyCallback;
@@ -56,11 +54,11 @@ import org.json.JSONObject;
56
54
 
57
55
  public class LiveUpdate {
58
56
 
59
- public static final String DEFAULT_WEB_ASSET_DIR = Bridge.DEFAULT_WEB_ASSET_DIR;
60
-
61
57
  @NonNull
62
58
  private final LiveUpdateConfig config;
63
59
 
60
+ private final String defaultWebAssetDir;
61
+
64
62
  @NonNull
65
63
  private final LiveUpdatePlugin plugin;
66
64
 
@@ -73,10 +71,9 @@ public class LiveUpdate {
73
71
  private final String bundlesDirectory = "_capacitor_live_update_bundles";
74
72
  private final Handler rollbackHandler = new Handler();
75
73
 
76
- private boolean rollbackPerformed = false;
77
-
78
74
  public LiveUpdate(@NonNull LiveUpdateConfig config, @NonNull LiveUpdatePlugin plugin) throws PackageManager.NameNotFoundException {
79
75
  this.config = config;
76
+ this.defaultWebAssetDir = plugin.getBridge().DEFAULT_WEB_ASSET_DIR;
80
77
  this.plugin = plugin;
81
78
  this.preferences = new LiveUpdatePreferences(plugin.getContext());
82
79
  this.webViewSettingsEditor = plugin.getContext().getSharedPreferences(WebView.WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE).edit();
@@ -122,6 +119,9 @@ public class LiveUpdate {
122
119
 
123
120
  public void getBundle(@NonNull NonEmptyCallback callback) {
124
121
  String bundleId = getCurrentBundleId();
122
+ if (bundleId.equals(defaultWebAssetDir)) {
123
+ bundleId = null;
124
+ }
125
125
  GetBundleResult result = new GetBundleResult(bundleId);
126
126
  callback.success(result);
127
127
  }
@@ -133,7 +133,7 @@ public class LiveUpdate {
133
133
  }
134
134
 
135
135
  public void getChannel(@NonNull NonEmptyCallback callback) {
136
- String channel = preferences.getChannel();
136
+ String channel = getChannel();
137
137
  GetChannelResult result = new GetChannelResult(channel);
138
138
  callback.success(result);
139
139
  }
@@ -162,18 +162,12 @@ public class LiveUpdate {
162
162
  callback.success(result);
163
163
  }
164
164
 
165
- public void ready(@NonNull NonEmptyCallback callback) {
165
+ public void ready() {
166
166
  Logger.debug(LiveUpdatePlugin.TAG, "App is ready.");
167
167
  stopRollbackTimer();
168
168
  if (config.getAutoDeleteBundles()) {
169
169
  deleteUnusedBundles();
170
170
  }
171
- String currentBundleId = getCurrentBundleId();
172
- String previousBundleId = getPreviousBundleId();
173
- ReadyResult result = new ReadyResult(currentBundleId, previousBundleId, rollbackPerformed);
174
- callback.success(result);
175
- setPreviousBundleId(currentBundleId);
176
- rollbackPerformed = false;
177
171
  }
178
172
 
179
173
  public void reload() {
@@ -493,7 +487,7 @@ public class LiveUpdate {
493
487
  .addQueryParameter("appVersionCode", getVersionCode())
494
488
  .addQueryParameter("appVersionName", getVersionName())
495
489
  .addQueryParameter("bundleId", getCurrentBundleId())
496
- .addQueryParameter("channelName", preferences.getChannel())
490
+ .addQueryParameter("channelName", getChannel())
497
491
  .addQueryParameter("customId", preferences.getCustomId())
498
492
  .addQueryParameter("deviceId", getDeviceId())
499
493
  .addQueryParameter("osVersion", String.valueOf(Build.VERSION.SDK_INT))
@@ -536,14 +530,6 @@ public class LiveUpdate {
536
530
  );
537
531
  }
538
532
 
539
- private String getVersionCode() throws PackageManager.NameNotFoundException {
540
- return String.valueOf(getPackageInfo().versionCode);
541
- }
542
-
543
- private String getVersionName() throws PackageManager.NameNotFoundException {
544
- return getPackageInfo().versionName;
545
- }
546
-
547
533
  private String[] getBundleIds() {
548
534
  File bundlesDirectory = buildBundlesDirectory();
549
535
  File[] bundles = bundlesDirectory.listFiles();
@@ -559,13 +545,25 @@ public class LiveUpdate {
559
545
  return bundleIds;
560
546
  }
561
547
 
548
+ @Nullable
549
+ private String getChannel() {
550
+ String channel = null;
551
+ if (config.getDefaultChannel() != null) {
552
+ channel = config.getDefaultChannel();
553
+ }
554
+ if (preferences.getChannel() != null) {
555
+ channel = preferences.getChannel();
556
+ }
557
+ return channel;
558
+ }
559
+
562
560
  /**
563
561
  * @return The current bundle ID (`public` for the built-in bundle).
564
562
  */
565
563
  private String getCurrentBundleId() {
566
564
  String currentPath = getCurrentCapacitorServerPath();
567
- if (currentPath.equals(DEFAULT_WEB_ASSET_DIR)) {
568
- return DEFAULT_WEB_ASSET_DIR;
565
+ if (currentPath.equals(defaultWebAssetDir)) {
566
+ return defaultWebAssetDir;
569
567
  }
570
568
  return new File(currentPath).getName();
571
569
  }
@@ -593,8 +591,8 @@ public class LiveUpdate {
593
591
  @NonNull
594
592
  private String getNextBundleId() {
595
593
  String nextPath = getNextCapacitorServerPath();
596
- if (nextPath.equals(DEFAULT_WEB_ASSET_DIR)) {
597
- return DEFAULT_WEB_ASSET_DIR;
594
+ if (nextPath.equals(defaultWebAssetDir)) {
595
+ return defaultWebAssetDir;
598
596
  }
599
597
  return new File(nextPath).getName();
600
598
  }
@@ -607,12 +605,15 @@ public class LiveUpdate {
607
605
  return plugin
608
606
  .getContext()
609
607
  .getSharedPreferences(WebView.WEBVIEW_PREFS_NAME, Activity.MODE_PRIVATE)
610
- .getString(WebView.CAP_SERVER_PATH, DEFAULT_WEB_ASSET_DIR);
608
+ .getString(WebView.CAP_SERVER_PATH, defaultWebAssetDir);
611
609
  }
612
610
 
613
- @Nullable
614
- private String getPreviousBundleId() {
615
- return preferences.getPreviousBundleId();
611
+ private String getVersionCode() throws PackageManager.NameNotFoundException {
612
+ return String.valueOf(getPackageInfo().versionCode);
613
+ }
614
+
615
+ private String getVersionName() throws PackageManager.NameNotFoundException {
616
+ return getPackageInfo().versionName;
616
617
  }
617
618
 
618
619
  private boolean hasBundle(@NonNull String bundleId) {
@@ -627,10 +628,7 @@ public class LiveUpdate {
627
628
  }
628
629
 
629
630
  private void rollback() {
630
- rollbackPerformed = true;
631
- String currentBundleId = getCurrentBundleId();
632
- setPreviousBundleId(currentBundleId);
633
- if (currentBundleId.equals(DEFAULT_WEB_ASSET_DIR)) {
631
+ if (getCurrentBundleId() == defaultWebAssetDir) {
634
632
  Logger.debug(LiveUpdatePlugin.TAG, "App is not ready. Default bundle is already in use.");
635
633
  return;
636
634
  }
@@ -670,7 +668,7 @@ public class LiveUpdate {
670
668
  }
671
669
 
672
670
  private void setCurrentCapacitorServerPath(@NonNull String path) {
673
- if (path.equals(DEFAULT_WEB_ASSET_DIR)) {
671
+ if (path.equals(defaultWebAssetDir)) {
674
672
  this.plugin.getBridge().setServerAssetPath(path);
675
673
  } else {
676
674
  this.plugin.getBridge().setServerBasePath(path);
@@ -679,7 +677,7 @@ public class LiveUpdate {
679
677
  }
680
678
 
681
679
  private void setCurrentCapacitorServerPathToDefaultWebAssetDir() {
682
- setCurrentCapacitorServerPath(DEFAULT_WEB_ASSET_DIR);
680
+ setCurrentCapacitorServerPath(defaultWebAssetDir);
683
681
  }
684
682
 
685
683
  private void setNextBundle(@NonNull String bundleId) {
@@ -693,11 +691,7 @@ public class LiveUpdate {
693
691
  }
694
692
 
695
693
  private void setNextCapacitorServerPathToDefaultWebAssetDir() {
696
- setNextCapacitorServerPath(DEFAULT_WEB_ASSET_DIR);
697
- }
698
-
699
- private void setPreviousBundleId(@Nullable String bundleId) {
700
- preferences.setPreviousBundleId(bundleId);
694
+ setNextCapacitorServerPath(defaultWebAssetDir);
701
695
  }
702
696
 
703
697
  private void startRollbackTimer() {
@@ -9,6 +9,10 @@ public class LiveUpdateConfig {
9
9
  private String appId = null;
10
10
 
11
11
  private boolean autoDeleteBundles = false;
12
+
13
+ @Nullable
14
+ private String defaultChannel = null;
15
+
12
16
  private boolean enabled = true;
13
17
 
14
18
  @Nullable
@@ -29,6 +33,11 @@ public class LiveUpdateConfig {
29
33
  return autoDeleteBundles;
30
34
  }
31
35
 
36
+ @Nullable
37
+ public String getDefaultChannel() {
38
+ return defaultChannel;
39
+ }
40
+
32
41
  public boolean getEnabled() {
33
42
  return enabled;
34
43
  }
@@ -59,6 +68,10 @@ public class LiveUpdateConfig {
59
68
  this.autoDeleteBundles = autoDeleteBundles;
60
69
  }
61
70
 
71
+ public void setDefaultChannel(@Nullable String defaultChannel) {
72
+ this.defaultChannel = defaultChannel;
73
+ }
74
+
62
75
  public void setEnabled(boolean enabled) {
63
76
  this.enabled = enabled;
64
77
  }
@@ -19,7 +19,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
19
19
  public class LiveUpdatePlugin extends Plugin {
20
20
 
21
21
  public static final String TAG = "LiveUpdate";
22
- public static final String VERSION = "6.2.0-dev.0a2a6a5.1722676620";
22
+ public static final String VERSION = "6.3.0";
23
23
  public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
24
24
  public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
25
25
  public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
@@ -280,20 +280,8 @@ public class LiveUpdatePlugin extends Plugin {
280
280
  @PluginMethod
281
281
  public void ready(PluginCall call) {
282
282
  try {
283
- NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
284
- @Override
285
- public void success(Result result) {
286
- call.resolve(result.toJSObject());
287
- }
288
-
289
- @Override
290
- public void error(Exception exception) {
291
- Logger.error(TAG, exception.getMessage(), exception);
292
- call.reject(exception.getMessage());
293
- }
294
- };
295
-
296
- implementation.ready(callback);
283
+ implementation.ready();
284
+ call.resolve();
297
285
  } catch (Exception exception) {
298
286
  Logger.error(TAG, exception.getMessage(), exception);
299
287
  call.reject(exception.getMessage());
@@ -443,6 +431,8 @@ public class LiveUpdatePlugin extends Plugin {
443
431
  config.setAppId(appId);
444
432
  boolean autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.getAutoDeleteBundles());
445
433
  config.setAutoDeleteBundles(autoDeleteBundles);
434
+ String defaultChannel = getConfig().getString("defaultChannel", config.getDefaultChannel());
435
+ config.setDefaultChannel(defaultChannel);
446
436
  boolean enabled = getConfig().getBoolean("enabled", config.getEnabled());
447
437
  config.setEnabled(enabled);
448
438
  String location = getConfig().getString("location", config.getLocation());
@@ -19,7 +19,6 @@ public class LiveUpdatePreferences {
19
19
  private final String deviceIdKey = "deviceId"; // DO NOT CHANGE
20
20
  private final String customIdKey = "customId"; // DO NOT CHANGE
21
21
  private final String lastVersionCodeKey = "lastVersionCode"; // DO NOT CHANGE
22
- private final String previousBundleIdKey = "previousBundleId"; // DO NOT CHANGE
23
22
 
24
23
  public LiveUpdatePreferences(@NonNull Context context) {
25
24
  this.context = context;
@@ -53,13 +52,6 @@ public class LiveUpdatePreferences {
53
52
  return context.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE).getInt(lastVersionCodeKey, 0);
54
53
  }
55
54
 
56
- @Nullable
57
- public String getPreviousBundleId() {
58
- return context
59
- .getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE)
60
- .getString(previousBundleIdKey, null);
61
- }
62
-
63
55
  public void setChannel(@Nullable String channel) {
64
56
  if (channel == null) {
65
57
  settingsEditor.remove(channelKey);
@@ -91,13 +83,4 @@ public class LiveUpdatePreferences {
91
83
  settingsEditor.putInt(lastVersionCodeKey, lastVersionCode);
92
84
  settingsEditor.apply();
93
85
  }
94
-
95
- public void setPreviousBundleId(@Nullable String bundleId) {
96
- if (bundleId == null) {
97
- settingsEditor.remove(previousBundleIdKey);
98
- } else {
99
- settingsEditor.putString(previousBundleIdKey, bundleId);
100
- }
101
- settingsEditor.apply();
102
- }
103
86
  }
@@ -4,7 +4,6 @@ import androidx.annotation.NonNull;
4
4
  import androidx.annotation.Nullable;
5
5
  import com.getcapacitor.JSArray;
6
6
  import com.getcapacitor.JSObject;
7
- import io.capawesome.capacitorjs.plugins.liveupdate.LiveUpdate;
8
7
  import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
9
8
  import org.json.JSONObject;
10
9
 
@@ -19,7 +18,7 @@ public class GetBundleResult implements Result {
19
18
 
20
19
  public JSObject toJSObject() {
21
20
  JSObject result = new JSObject();
22
- result.put("bundleId", bundleId.equals(LiveUpdate.DEFAULT_WEB_ASSET_DIR) ? JSONObject.NULL : bundleId);
21
+ result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
23
22
  return result;
24
23
  }
25
24
  }
package/dist/docs.json CHANGED
@@ -172,9 +172,9 @@
172
172
  },
173
173
  {
174
174
  "name": "ready",
175
- "signature": "() => Promise<ReadyResult>",
175
+ "signature": "() => Promise<void>",
176
176
  "parameters": [],
177
- "returns": "Promise<ReadyResult>",
177
+ "returns": "Promise<void>",
178
178
  "tags": [
179
179
  {
180
180
  "name": "since",
@@ -182,9 +182,7 @@
182
182
  }
183
183
  ],
184
184
  "docs": "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\nto prevent the app from being reset to the default bundle.\n\nOnly available on Android and iOS.",
185
- "complexTypes": [
186
- "ReadyResult"
187
- ],
185
+ "complexTypes": [],
188
186
  "slug": "ready"
189
187
  },
190
188
  {
@@ -600,56 +598,6 @@
600
598
  }
601
599
  ]
602
600
  },
603
- {
604
- "name": "ReadyResult",
605
- "slug": "readyresult",
606
- "docs": "",
607
- "tags": [
608
- {
609
- "text": "7.0.0",
610
- "name": "since"
611
- }
612
- ],
613
- "methods": [],
614
- "properties": [
615
- {
616
- "name": "previousBundleId",
617
- "tags": [
618
- {
619
- "text": "7.0.0",
620
- "name": "since"
621
- }
622
- ],
623
- "docs": "The identifier of the previous bundle used.\n\nIf `null`, the default bundle was used.",
624
- "complexTypes": [],
625
- "type": "string | null"
626
- },
627
- {
628
- "name": "currentBundleId",
629
- "tags": [
630
- {
631
- "text": "7.0.0",
632
- "name": "since"
633
- }
634
- ],
635
- "docs": "The identifier of the current bundle used.\n\nIf `null`, the default bundle is being used.",
636
- "complexTypes": [],
637
- "type": "string | null"
638
- },
639
- {
640
- "name": "rollback",
641
- "tags": [
642
- {
643
- "text": "7.0.0",
644
- "name": "since"
645
- }
646
- ],
647
- "docs": "Whether or not the app was reset to the default bundle.",
648
- "complexTypes": [],
649
- "type": "boolean"
650
- }
651
- ]
652
- },
653
601
  {
654
602
  "name": "SetBundleOptions",
655
603
  "slug": "setbundleoptions",
@@ -798,6 +746,22 @@
798
746
  "complexTypes": [],
799
747
  "type": "boolean | undefined"
800
748
  },
749
+ {
750
+ "name": "defaultChannel",
751
+ "tags": [
752
+ {
753
+ "text": "6.3.0",
754
+ "name": "since"
755
+ },
756
+ {
757
+ "text": "'production'",
758
+ "name": "example"
759
+ }
760
+ ],
761
+ "docs": "The default channel of the app.",
762
+ "complexTypes": [],
763
+ "type": "string | undefined"
764
+ },
801
765
  {
802
766
  "name": "enabled",
803
767
  "tags": [
@@ -17,6 +17,13 @@ declare module '@capacitor/cli' {
17
17
  * @default false
18
18
  */
19
19
  autoDeleteBundles?: boolean;
20
+ /**
21
+ * The default channel of the app.
22
+ *
23
+ * @since 6.3.0
24
+ * @example 'production'
25
+ */
26
+ defaultChannel?: string;
20
27
  /**
21
28
  * Whether or not the plugin is enabled.
22
29
  *
@@ -142,7 +149,7 @@ export interface LiveUpdatePlugin {
142
149
  *
143
150
  * @since 5.0.0
144
151
  */
145
- ready(): Promise<ReadyResult>;
152
+ ready(): Promise<void>;
146
153
  /**
147
154
  * Reload the app to apply the new bundle.
148
155
  *
@@ -336,33 +343,6 @@ export interface GetCustomIdResult {
336
343
  */
337
344
  customId: string | null;
338
345
  }
339
- /**
340
- * @since 7.0.0
341
- */
342
- export interface ReadyResult {
343
- /**
344
- * The identifier of the previous bundle used.
345
- *
346
- * If `null`, the default bundle was used.
347
- *
348
- * @since 7.0.0
349
- */
350
- previousBundleId: string | null;
351
- /**
352
- * The identifier of the current bundle used.
353
- *
354
- * If `null`, the default bundle is being used.
355
- *
356
- * @since 7.0.0
357
- */
358
- currentBundleId: string | null;
359
- /**
360
- * Whether or not the app was reset to the default bundle.
361
- *
362
- * @since 7.0.0
363
- */
364
- rollback: boolean;
365
- }
366
346
  /**
367
347
  * @since 5.0.0
368
348
  */
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\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 * @since 5.0.0\n * @example '4100e356-e851-47fe-9d3c-b411eb325a99'\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 * Whether or not the plugin is enabled.\n *\n * @since 5.0.0\n * @default true\n */\n enabled?: boolean;\n /**\n * The location of the server to use when using [Capawesome Cloud](https://capawesome.io/cloud).\n *\n * @since 6.2.0\n * @default 'us'\n * @example 'eu'\n * @see https://capawesome.io/cloud/live-updates/advanced/privacy/\n */\n location?: 'us' | 'eu';\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 before resetting to the default bundle.\n *\n * @since 5.0.0\n * @default 10000\n */\n readyTimeout?: number;\n /**\n * Whether or not the app should be reset to the default bundle during an update.\n *\n * @since 5.0.0\n * @default true\n */\n resetOnUpdate?: boolean;\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 * Get the active bundle identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundle(): Promise<GetBundleResult>;\n /**\n * Get all available bundle identifiers.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the custom identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the device identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Get the version code of the app.\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 * 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 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 5.0.0\n */\n setBundle(options: SetBundleOptions): Promise<void>;\n /**\n * Set the channel of the app.\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 app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): 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(): Promise<SyncResult>;\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 unique identifier of the bundle.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the bundle to verify the integrity of the ZIP file.\n *\n * Must be a SHA-256 hash in hexadecimal format.\n *\n * @since 6.1.0\n * @example 'aab8e0a312e807c8eaeb923e2bdccd7731c5508869c62ad8e6e43ee881414c84'\n */\n checksum?: string;\n /**\n * The URL of the bundle to download.\n *\n * The bundle must be a ZIP file containing at least a `index.html` file.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: 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 of the app.\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 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 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 app.\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 of the app.\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 app.\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 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"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\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 * @since 5.0.0\n * @example '4100e356-e851-47fe-9d3c-b411eb325a99'\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 * Whether or not the plugin is enabled.\n *\n * @since 5.0.0\n * @default true\n */\n enabled?: boolean;\n /**\n * The location of the server to use when using [Capawesome Cloud](https://capawesome.io/cloud).\n *\n * @since 6.2.0\n * @default 'us'\n * @example 'eu'\n * @see https://capawesome.io/cloud/live-updates/advanced/privacy/\n */\n location?: 'us' | 'eu';\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 before resetting to the default bundle.\n *\n * @since 5.0.0\n * @default 10000\n */\n readyTimeout?: number;\n /**\n * Whether or not the app should be reset to the default bundle during an update.\n *\n * @since 5.0.0\n * @default true\n */\n resetOnUpdate?: boolean;\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 * Get the active bundle identifier.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundle(): Promise<GetBundleResult>;\n /**\n * Get all available bundle identifiers.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getBundles(): Promise<GetBundlesResult>;\n /**\n * Get the channel of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getChannel(): Promise<GetChannelResult>;\n /**\n * Get the custom identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getCustomId(): Promise<GetCustomIdResult>;\n /**\n * Get the device identifier of the app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n getDeviceId(): Promise<GetDeviceIdResult>;\n /**\n * Get the version code of the app.\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 * 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<void>;\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 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 5.0.0\n */\n setBundle(options: SetBundleOptions): Promise<void>;\n /**\n * Set the channel of the app.\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 app.\n *\n * Only available on Android and iOS.\n *\n * @since 5.0.0\n */\n setCustomId(options: SetCustomIdOptions): 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(): Promise<SyncResult>;\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 unique identifier of the bundle.\n *\n * @since 5.0.0\n * @example '1.0.0'\n */\n bundleId: string;\n /**\n * The checksum of the bundle to verify the integrity of the ZIP file.\n *\n * Must be a SHA-256 hash in hexadecimal format.\n *\n * @since 6.1.0\n * @example 'aab8e0a312e807c8eaeb923e2bdccd7731c5508869c62ad8e6e43ee881414c84'\n */\n checksum?: string;\n /**\n * The URL of the bundle to download.\n *\n * The bundle must be a ZIP file containing at least a `index.html` file.\n *\n * @since 5.0.0\n * @example 'https://example.com/bundle.zip'\n */\n url: 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 of the app.\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 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 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 app.\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 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 of the app.\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 app.\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 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"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { DeleteBundleOptions, DownloadBundleOptions, GetBundleResult, GetBundlesResult, GetChannelResult, GetCustomIdResult, GetDeviceIdResult, GetVersionCodeResult, GetVersionNameResult, LiveUpdatePlugin, ReadyResult, SetBundleOptions, SetChannelOptions, SetCustomIdOptions, SyncResult } from './definitions';
2
+ import type { DeleteBundleOptions, DownloadBundleOptions, GetBundleResult, GetBundlesResult, GetChannelResult, GetCustomIdResult, GetDeviceIdResult, GetVersionCodeResult, GetVersionNameResult, LiveUpdatePlugin, SetBundleOptions, SetChannelOptions, SetCustomIdOptions, SyncResult } from './definitions';
3
3
  export declare class LiveUpdateWeb extends WebPlugin implements LiveUpdatePlugin {
4
4
  deleteBundle(_options: DeleteBundleOptions): Promise<void>;
5
5
  downloadBundle(_options: DownloadBundleOptions): Promise<void>;
@@ -10,7 +10,7 @@ export declare class LiveUpdateWeb extends WebPlugin implements LiveUpdatePlugin
10
10
  getDeviceId(): Promise<GetDeviceIdResult>;
11
11
  getVersionCode(): Promise<GetVersionCodeResult>;
12
12
  getVersionName(): Promise<GetVersionNameResult>;
13
- ready(): Promise<ReadyResult>;
13
+ ready(): Promise<void>;
14
14
  reload(): Promise<void>;
15
15
  reset(): Promise<void>;
16
16
  setBundle(_options: SetBundleOptions): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAoB5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IACnC,KAAK,CAAC,YAAY,CAAC,QAA6B;QACrD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,QAA+B;QACzD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,SAAS;QACpB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW;QACtB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW;QACtB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,QAA0B;QAC/C,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,QAA2B;QACjD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,QAA4B;QACnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEO,uBAAuB;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n DeleteBundleOptions,\n DownloadBundleOptions,\n GetBundleResult,\n GetBundlesResult,\n GetChannelResult,\n GetCustomIdResult,\n GetDeviceIdResult,\n GetVersionCodeResult,\n GetVersionNameResult,\n LiveUpdatePlugin,\n ReadyResult,\n SetBundleOptions,\n SetChannelOptions,\n SetCustomIdOptions,\n SyncResult,\n} from './definitions';\n\nexport class LiveUpdateWeb extends WebPlugin implements LiveUpdatePlugin {\n public async deleteBundle(_options: DeleteBundleOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async downloadBundle(_options: DownloadBundleOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async getBundle(): Promise<GetBundleResult> {\n this.throwUnimplementedError();\n }\n\n public async getBundles(): Promise<GetBundlesResult> {\n this.throwUnimplementedError();\n }\n\n public async getChannel(): Promise<GetChannelResult> {\n this.throwUnimplementedError();\n }\n\n public async getCustomId(): Promise<GetCustomIdResult> {\n this.throwUnimplementedError();\n }\n\n public async getDeviceId(): Promise<GetDeviceIdResult> {\n this.throwUnimplementedError();\n }\n\n public async getVersionCode(): Promise<GetVersionCodeResult> {\n this.throwUnimplementedError();\n }\n\n public async getVersionName(): Promise<GetVersionNameResult> {\n this.throwUnimplementedError();\n }\n\n public async ready(): Promise<ReadyResult> {\n this.throwUnimplementedError();\n }\n\n public async reload(): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async reset(): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async setBundle(_options: SetBundleOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async setChannel(_options: SetChannelOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async setCustomId(_options: SetCustomIdOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async sync(): Promise<SyncResult> {\n this.throwUnimplementedError();\n }\n\n private throwUnimplementedError(): never {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAmB5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IACnC,KAAK,CAAC,YAAY,CAAC,QAA6B;QACrD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,QAA+B;QACzD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,SAAS;QACpB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW;QACtB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW;QACtB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,cAAc;QACzB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,QAA0B;QAC/C,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,QAA2B;QACjD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,QAA4B;QACnD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;IAEO,uBAAuB;QAC7B,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n DeleteBundleOptions,\n DownloadBundleOptions,\n GetBundleResult,\n GetBundlesResult,\n GetChannelResult,\n GetCustomIdResult,\n GetDeviceIdResult,\n GetVersionCodeResult,\n GetVersionNameResult,\n LiveUpdatePlugin,\n SetBundleOptions,\n SetChannelOptions,\n SetCustomIdOptions,\n SyncResult,\n} from './definitions';\n\nexport class LiveUpdateWeb extends WebPlugin implements LiveUpdatePlugin {\n public async deleteBundle(_options: DeleteBundleOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async downloadBundle(_options: DownloadBundleOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async getBundle(): Promise<GetBundleResult> {\n this.throwUnimplementedError();\n }\n\n public async getBundles(): Promise<GetBundlesResult> {\n this.throwUnimplementedError();\n }\n\n public async getChannel(): Promise<GetChannelResult> {\n this.throwUnimplementedError();\n }\n\n public async getCustomId(): Promise<GetCustomIdResult> {\n this.throwUnimplementedError();\n }\n\n public async getDeviceId(): Promise<GetDeviceIdResult> {\n this.throwUnimplementedError();\n }\n\n public async getVersionCode(): Promise<GetVersionCodeResult> {\n this.throwUnimplementedError();\n }\n\n public async getVersionName(): Promise<GetVersionNameResult> {\n this.throwUnimplementedError();\n }\n\n public async ready(): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async reload(): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async reset(): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async setBundle(_options: SetBundleOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async setChannel(_options: SetChannelOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async setCustomId(_options: SetCustomIdOptions): Promise<void> {\n this.throwUnimplementedError();\n }\n\n public async sync(): Promise<SyncResult> {\n this.throwUnimplementedError();\n }\n\n private throwUnimplementedError(): never {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
@@ -10,7 +10,7 @@ import Capacitor
10
10
 
11
11
  public func toJSObject() -> AnyObject {
12
12
  var result = JSObject()
13
- result["bundleId"] = bundleId == LiveUpdate.defaultWebAssetDir ? NSNull() : bundleId
13
+ result["bundleId"] = bundleId == nil ? NSNull() : bundleId
14
14
  return result as AnyObject
15
15
  }
16
16
  }
@@ -7,10 +7,9 @@ import CommonCrypto
7
7
 
8
8
  // swiftlint:disable type_body_length
9
9
  @objc public class LiveUpdate: NSObject {
10
- public static let defaultWebAssetDir = "public" // DO NOT CHANGE (See https://dub.sh/Buvz4yj)
11
-
12
10
  private let cachesDirectoryUrl = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
13
11
  private let config: LiveUpdateConfig
12
+ private let defaultWebAssetDir = "public" // DO NOT CHANGE (See https://dub.sh/Buvz4yj)
14
13
  private let defaultServerPathKey = "serverBasePath" // DO NOT CHANGE (See https://dub.sh/ceDl0zT)
15
14
  private let libraryDirectoryUrl = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!
16
15
  private let plugin: LiveUpdatePlugin
@@ -18,7 +17,6 @@ import CommonCrypto
18
17
  private let preferences: LiveUpdatePreferences
19
18
 
20
19
  private var rollbackDispatchWorkItem: DispatchWorkItem?
21
- private var rollbackPerformed = false
22
20
 
23
21
  init(config: LiveUpdateConfig, plugin: LiveUpdatePlugin) {
24
22
  self.config = config
@@ -76,7 +74,10 @@ import CommonCrypto
76
74
  }
77
75
 
78
76
  @objc public func getBundle(completion: @escaping (Result?, Error?) -> Void) {
79
- let bundleId = getCurrentBundleId()
77
+ var bundleId = getCurrentBundleId()
78
+ if bundleId == defaultWebAssetDir {
79
+ bundleId = nil
80
+ }
80
81
  let result = GetBundleResult(bundleId: bundleId)
81
82
  completion(result, nil)
82
83
  }
@@ -88,7 +89,7 @@ import CommonCrypto
88
89
  }
89
90
 
90
91
  @objc public func getChannel(completion: @escaping (Result?, Error?) -> Void) {
91
- let channel = preferences.getChannel()
92
+ let channel = getChannel()
92
93
  let result = GetChannelResult(channel: channel)
93
94
  completion(result, nil)
94
95
  }
@@ -118,18 +119,12 @@ import CommonCrypto
118
119
  completion(result, nil)
119
120
  }
120
121
 
121
- @objc public func ready(completion: @escaping (Result?, Error?) -> Void) {
122
+ @objc public func ready() {
122
123
  CAPLog.print("[", LiveUpdatePlugin.tag, "] ", "App is ready.")
123
124
  stopRollbackTimer()
124
125
  if config.autoDeleteBundles {
125
126
  deleteUnusedBundles()
126
127
  }
127
- let currentBundleId = getCurrentBundleId()
128
- let previousBundleId = getPreviousBundleId()
129
- let result = ReadyResult(currentBundleId: currentBundleId, previousBundleId: previousBundleId, rollback: rollbackPerformed)
130
- completion(result, nil)
131
- setPreviousBundleId(bundleId: currentBundleId)
132
- rollbackPerformed = false
133
128
  }
134
129
 
135
130
  @objc public func reload() {
@@ -377,7 +372,7 @@ import CommonCrypto
377
372
  parameters["appVersionCode"] = getVersionCode()
378
373
  parameters["appVersionName"] = getVersionName()
379
374
  parameters["bundleId"] = getCurrentBundleId()
380
- parameters["channelName"] = preferences.getChannel()
375
+ parameters["channelName"] = getChannel()
381
376
  parameters["customId"] = preferences.getCustomId()
382
377
  parameters["deviceId"] = getDeviceId()
383
378
  parameters["osVersion"] = UIDevice.current.systemVersion
@@ -404,20 +399,6 @@ import CommonCrypto
404
399
  }
405
400
  }
406
401
 
407
- private func getVersionCode() -> String {
408
- guard let appVersionCode = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
409
- return ""
410
- }
411
- return appVersionCode
412
- }
413
-
414
- private func getVersionName() -> String {
415
- guard let appVersionName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
416
- return ""
417
- }
418
- return appVersionName
419
- }
420
-
421
402
  private func getBundleIds() -> [String] {
422
403
  let url = libraryDirectoryUrl.appendingPathComponent(bundlesDirectory)
423
404
  do {
@@ -432,6 +413,17 @@ import CommonCrypto
432
413
  }
433
414
  }
434
415
 
416
+ private func getChannel() -> String? {
417
+ var channel: String?
418
+ if let _ = config.defaultChannel {
419
+ channel = config.defaultChannel
420
+ }
421
+ if let _ = preferences.getChannel() {
422
+ channel = preferences.getChannel()
423
+ }
424
+ return channel
425
+ }
426
+
435
427
  /// - Returns: The current bundle ID (`public` for the built-in bundle) or `nil` if no view controller was found.
436
428
  private func getCurrentBundleId() -> String? {
437
429
  guard let path = getCurrentCapacitorServerPath() else {
@@ -461,15 +453,25 @@ import CommonCrypto
461
453
 
462
454
  /// - Returns: The absolute path to the next bundle directory.
463
455
  private func getNextCapacitorServerPath() -> String {
464
- let defaultCapacitorServerPath = buildCapacitorServerPathFor(bundleId: LiveUpdate.defaultWebAssetDir)
456
+ let defaultCapacitorServerPath = buildCapacitorServerPathFor(bundleId: defaultWebAssetDir)
465
457
  if let path = KeyValueStore.standard[self.defaultServerPathKey, as: String.self] {
466
458
  return path.isEmpty ? defaultCapacitorServerPath : path
467
459
  }
468
460
  return defaultCapacitorServerPath
469
461
  }
470
462
 
471
- private func getPreviousBundleId() -> String? {
472
- return preferences.getPreviousBundleId()
463
+ private func getVersionCode() -> String {
464
+ guard let appVersionCode = Bundle.main.infoDictionary?["CFBundleVersion"] as? String else {
465
+ return ""
466
+ }
467
+ return appVersionCode
468
+ }
469
+
470
+ private func getVersionName() -> String {
471
+ guard let appVersionName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String else {
472
+ return ""
473
+ }
474
+ return appVersionName
473
475
  }
474
476
 
475
477
  private func hasBundle(bundleId: String) -> Bool {
@@ -478,10 +480,7 @@ import CommonCrypto
478
480
  }
479
481
 
480
482
  private func rollback() {
481
- rollbackPerformed = true
482
- let currentBundleId = getCurrentBundleId()
483
- setPreviousBundleId(bundleId: currentBundleId)
484
- if currentBundleId == LiveUpdate.defaultWebAssetDir {
483
+ if getCurrentBundleId() == defaultWebAssetDir {
485
484
  CAPLog.print("[", LiveUpdatePlugin.tag, "] ", "App is not ready. Default bundle is already in use.")
486
485
  return
487
486
  }
@@ -498,11 +497,28 @@ import CommonCrypto
498
497
  }
499
498
 
500
499
  private func searchIndexHtmlFile(url: URL) -> URL? {
501
- let enumerator = FileManager.default.enumerator(atPath: url.path)
502
- while let element = enumerator?.nextObject() as? String {
503
- if element.hasSuffix("index.html") {
504
- return url.appendingPathComponent(element)
500
+ do {
501
+ let directoryContents = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: [])
502
+ if directoryContents.isEmpty {
503
+ return nil
505
504
  }
505
+ let fileNames = directoryContents.map { $0.lastPathComponent }
506
+ if fileNames.contains("index.html") {
507
+ return url.appendingPathComponent("index.html")
508
+ } else {
509
+ for fileUrl in directoryContents {
510
+ var isDirectory: ObjCBool = false
511
+ if FileManager.default.fileExists(atPath: fileUrl.path, isDirectory: &isDirectory) {
512
+ if isDirectory.boolValue {
513
+ if let indexHtmlFile = searchIndexHtmlFile(url: fileUrl) {
514
+ return indexHtmlFile
515
+ }
516
+ }
517
+ }
518
+ }
519
+ }
520
+ } catch {
521
+ CAPLog.print("[", LiveUpdatePlugin.tag, "] ", "Failed to search index.html file: \(error.localizedDescription)")
506
522
  }
507
523
  return nil
508
524
  }
@@ -515,7 +531,7 @@ import CommonCrypto
515
531
  }
516
532
 
517
533
  private func setCurrentCapacitorServerPathToDefaultWebAssetDir() {
518
- let path = buildCapacitorServerPathFor(bundleId: LiveUpdate.defaultWebAssetDir)
534
+ let path = buildCapacitorServerPathFor(bundleId: defaultWebAssetDir)
519
535
  setCurrentCapacitorServerPath(path: path)
520
536
  }
521
537
 
@@ -535,14 +551,10 @@ import CommonCrypto
535
551
  }
536
552
 
537
553
  private func setNextCapacitorServerPathToDefaultWebAssetDir() {
538
- let path = buildCapacitorServerPathFor(bundleId: LiveUpdate.defaultWebAssetDir)
554
+ let path = buildCapacitorServerPathFor(bundleId: defaultWebAssetDir)
539
555
  setNextCapacitorServerPath(path: path)
540
556
  }
541
557
 
542
- private func setPreviousBundleId(bundleId: String?) {
543
- preferences.setPreviousBundleId(bundleId)
544
- }
545
-
546
558
  private func startRollbackTimer() {
547
559
  stopRollbackTimer()
548
560
  rollbackDispatchWorkItem = DispatchWorkItem { [weak self] in
@@ -1,6 +1,7 @@
1
1
  public struct LiveUpdateConfig {
2
2
  var appId: String?
3
3
  var autoDeleteBundles = false
4
+ var defaultChannel: String?
4
5
  var enabled = true
5
6
  var location: String?
6
7
  var publicKey: String?
@@ -8,7 +8,7 @@ import Capacitor
8
8
  @objc(LiveUpdatePlugin)
9
9
  public class LiveUpdatePlugin: CAPPlugin {
10
10
  public static let tag = "LiveUpdate"
11
- public static let version = "6.2.0-dev.0a2a6a5.1722676620"
11
+ public static let version = "6.3.0"
12
12
  public static let userDefaultsPrefix = "CapawesomeLiveUpdate" // DO NOT CHANGE
13
13
 
14
14
  private var config: LiveUpdateConfig?
@@ -152,16 +152,8 @@ public class LiveUpdatePlugin: CAPPlugin {
152
152
  }
153
153
 
154
154
  @objc func ready(_ call: CAPPluginCall) {
155
- implementation?.ready(completion: { result, error in
156
- if let error = error {
157
- CAPLog.print("[", LiveUpdatePlugin.tag, "] ", error)
158
- call.reject(error.localizedDescription)
159
- return
160
- }
161
- if let result = result?.toJSObject() as? JSObject {
162
- call.resolve(result)
163
- }
164
- })
155
+ implementation?.ready()
156
+ call.resolve()
165
157
  }
166
158
 
167
159
  @objc func reload(_ call: CAPPluginCall) {
@@ -247,6 +239,7 @@ public class LiveUpdatePlugin: CAPPlugin {
247
239
 
248
240
  config.appId = getConfig().getString("appId", config.appId)
249
241
  config.autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.autoDeleteBundles)
242
+ config.defaultChannel = getConfig().getString("defaultChannel", config.defaultChannel)
250
243
  config.enabled = getConfig().getBoolean("enabled", config.enabled)
251
244
  config.location = getConfig().getString("location", config.location)
252
245
  config.publicKey = getConfig().getString("publicKey", config.publicKey)
@@ -4,7 +4,6 @@ public class LiveUpdatePreferences: NSObject {
4
4
  private let channelKey = "channel" // DO NOT CHANGE
5
5
  private let customIdKey = "customId" // DO NOT CHANGE
6
6
  private let lastBundleVersionKey = "lastBundleVersion" // DO NOT CHANGE
7
- private let previousBundleIdKey = "previousBundleIdKey" // DO NOT CHANGE
8
7
 
9
8
  public func getChannel() -> String? {
10
9
  return UserDefaults.standard.string(forKey: applyPrefix(to: channelKey))
@@ -18,10 +17,6 @@ public class LiveUpdatePreferences: NSObject {
18
17
  return UserDefaults.standard.string(forKey: applyPrefix(to: lastBundleVersionKey))
19
18
  }
20
19
 
21
- public func getPreviousBundleId() -> String? {
22
- return UserDefaults.standard.string(forKey: applyPrefix(to: previousBundleIdKey))
23
- }
24
-
25
20
  public func setChannel(_ value: String?) {
26
21
  if let value = value {
27
22
  UserDefaults.standard.set(value, forKey: applyPrefix(to: channelKey))
@@ -41,15 +36,6 @@ public class LiveUpdatePreferences: NSObject {
41
36
  UserDefaults.standard.synchronize()
42
37
  }
43
38
 
44
- public func setPreviousBundleId(_ value: String?) {
45
- if let value = value {
46
- UserDefaults.standard.set(value, forKey: applyPrefix(to: previousBundleIdKey))
47
- } else {
48
- UserDefaults.standard.removeObject(forKey: applyPrefix(to: previousBundleIdKey))
49
- }
50
- UserDefaults.standard.synchronize()
51
- }
52
-
53
39
  private func applyPrefix(to key: String) -> String {
54
40
  return LiveUpdatePlugin.userDefaultsPrefix + "." + key
55
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/capacitor-live-update",
3
- "version": "6.2.0-dev.0a2a6a5.1722676620",
3
+ "version": "6.2.0-dev.4ebc29c.1723183892",
4
4
  "description": "Capacitor plugin to update your app remotely in real-time.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,32 +0,0 @@
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.LiveUpdate;
6
- import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
7
- import org.json.JSONObject;
8
-
9
- public class ReadyResult implements Result {
10
-
11
- @Nullable
12
- private String currentBundleId;
13
-
14
- @Nullable
15
- private String previousBundleId;
16
-
17
- private boolean rollback;
18
-
19
- public ReadyResult(@Nullable String currentBundleId, @Nullable String previousBundleId, boolean rollback) {
20
- this.currentBundleId = currentBundleId;
21
- this.previousBundleId = previousBundleId;
22
- this.rollback = rollback;
23
- }
24
-
25
- public JSObject toJSObject() {
26
- JSObject result = new JSObject();
27
- result.put("currentBundleId", currentBundleId.equals(LiveUpdate.DEFAULT_WEB_ASSET_DIR) ? JSONObject.NULL : currentBundleId);
28
- result.put("previousBundleId", previousBundleId.equals(LiveUpdate.DEFAULT_WEB_ASSET_DIR) ? JSONObject.NULL : previousBundleId);
29
- result.put("rollback", rollback);
30
- return result;
31
- }
32
- }
@@ -1,22 +0,0 @@
1
- import Foundation
2
- import Capacitor
3
-
4
- @objc public class ReadyResult: NSObject, Result {
5
- let currentBundleId: String?
6
- let previousBundleId: String?
7
- let rollback: Bool
8
-
9
- init(currentBundleId: String?, previousBundleId: String?, rollback: Bool) {
10
- self.currentBundleId = currentBundleId
11
- self.previousBundleId = previousBundleId
12
- self.rollback = rollback
13
- }
14
-
15
- public func toJSObject() -> AnyObject {
16
- var result = JSObject()
17
- result["currentBundleId"] = currentBundleId == LiveUpdate.defaultWebAssetDir ? NSNull() : currentBundleId
18
- result["previousBundleId"] = previousBundleId == LiveUpdate.defaultWebAssetDir ? NSNull() : previousBundleId
19
- result["rollback"] = rollback
20
- return result as AnyObject
21
- }
22
- }