@capgo/capacitor-updater 4.29.0 → 4.34.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 CHANGED
@@ -147,6 +147,7 @@ Capacitor Updator works by unzipping a compiled app bundle to the native device
147
147
  * [`getDeviceId()`](#getdeviceid)
148
148
  * [`getPluginVersion()`](#getpluginversion)
149
149
  * [`isAutoUpdateEnabled()`](#isautoupdateenabled)
150
+ * [`removeAllListeners()`](#removealllisteners)
150
151
  * [Interfaces](#interfaces)
151
152
  * [Type Aliases](#type-aliases)
152
153
 
@@ -596,6 +597,19 @@ Get the state of auto update config. This will return `false` in manual mode.
596
597
  --------------------
597
598
 
598
599
 
600
+ ### removeAllListeners()
601
+
602
+ ```typescript
603
+ removeAllListeners() => Promise<void>
604
+ ```
605
+
606
+ Remove all listeners for this plugin.
607
+
608
+ **Since:** 1.0.0
609
+
610
+ --------------------
611
+
612
+
599
613
  ### Interfaces
600
614
 
601
615
 
@@ -172,6 +172,13 @@ public class CapacitorUpdater {
172
172
 
173
173
  ZipEntry entry;
174
174
  while ((entry = zis.getNextEntry()) != null) {
175
+ if (entry.getName().contains("\\")) {
176
+ Log.e(
177
+ TAG,
178
+ "unzip: Windows path is not supported, please use unix path as require by zip RFC: " +
179
+ entry.getName()
180
+ );
181
+ }
175
182
  final File file = new File(targetDirectory, entry.getName());
176
183
  final String canonicalPath = file.getCanonicalPath();
177
184
  final String canonicalDir = targetDirectory.getCanonicalPath();
@@ -647,6 +654,7 @@ public class CapacitorUpdater {
647
654
  this.sendStats("set", newBundle.getVersionName());
648
655
  return true;
649
656
  }
657
+ this.setBundleStatus(id, BundleStatus.ERROR);
650
658
  this.sendStats("set_fail", newBundle.getVersionName());
651
659
  return false;
652
660
  }
@@ -55,7 +55,7 @@ public class CapacitorUpdaterPlugin
55
55
  private static final String channelUrlDefault =
56
56
  "https://api.capgo.app/channel_self";
57
57
 
58
- private final String PLUGIN_VERSION = "4.29.0";
58
+ private final String PLUGIN_VERSION = "4.34.0";
59
59
  private static final String DELAY_CONDITION_PREFERENCES = "";
60
60
 
61
61
  private SharedPreferences.Editor editor;
package/dist/docs.json CHANGED
@@ -758,6 +758,21 @@
758
758
  "docs": "Get the state of auto update config. This will return `false` in manual mode.",
759
759
  "complexTypes": [],
760
760
  "slug": "isautoupdateenabled"
761
+ },
762
+ {
763
+ "name": "removeAllListeners",
764
+ "signature": "() => Promise<void>",
765
+ "parameters": [],
766
+ "returns": "Promise<void>",
767
+ "tags": [
768
+ {
769
+ "name": "since",
770
+ "text": "1.0.0"
771
+ }
772
+ ],
773
+ "docs": "Remove all listeners for this plugin.",
774
+ "complexTypes": [],
775
+ "slug": "removealllisteners"
761
776
  }
762
777
  ],
763
778
  "properties": []
@@ -452,4 +452,10 @@ export interface CapacitorUpdaterPlugin {
452
452
  isAutoUpdateEnabled(): Promise<{
453
453
  enabled: boolean;
454
454
  }>;
455
+ /**
456
+ * Remove all listeners for this plugin.
457
+ *
458
+ * @since 1.0.0
459
+ */
460
+ removeAllListeners(): Promise<void>;
455
461
  }
@@ -340,7 +340,7 @@ extension CustomError: LocalizedError {
340
340
  }
341
341
 
342
342
  private func decryptFile(filePath: URL, sessionKey: String) throws {
343
- if (self.privateKey ?? "").isEmpty || (sessionKey ?? "").isEmpty {
343
+ if self.privateKey.isEmpty || sessionKey.isEmpty {
344
344
  print("\(self.TAG) Cannot found privateKey or sessionKey")
345
345
  return
346
346
  }
@@ -443,7 +443,7 @@ extension CustomError: LocalizedError {
443
443
  private func setCurrentBundle(bundle: String) {
444
444
  UserDefaults.standard.set(bundle, forKey: self.CAP_SERVER_PATH)
445
445
  UserDefaults.standard.synchronize()
446
- print("\(self.TAG) Current bundle set to: \((bundle ?? "").isEmpty ? BundleInfo.ID_BUILTIN : bundle)")
446
+ print("\(self.TAG) Current bundle set to: \((bundle ).isEmpty ? BundleInfo.ID_BUILTIN : bundle)")
447
447
  }
448
448
 
449
449
  public func download(url: URL, version: String, sessionKey: String) throws -> BundleInfo {
@@ -583,6 +583,7 @@ extension CustomError: LocalizedError {
583
583
  self.sendStats(action: "set", versionName: newBundle.getVersionName())
584
584
  return true
585
585
  }
586
+ self.setBundleStatus(id: id, status: BundleStatus.ERROR)
586
587
  self.sendStats(action: "set_fail", versionName: newBundle.getVersionName())
587
588
  return false
588
589
  }
@@ -631,7 +632,7 @@ extension CustomError: LocalizedError {
631
632
 
632
633
  func setChannel(channel: String) -> SetChannel {
633
634
  let setChannel: SetChannel = SetChannel()
634
- if (self.channelUrl ?? "").isEmpty {
635
+ if (self.channelUrl ).isEmpty {
635
636
  print("\(self.TAG) Channel URL is not set")
636
637
  setChannel.message = "Channel URL is not set"
637
638
  setChannel.error = "missing_config"
@@ -656,7 +657,7 @@ extension CustomError: LocalizedError {
656
657
  setChannel.message = message
657
658
  }
658
659
  case let .failure(error):
659
- print("\(self.TAG) Error set Channel", response.value, error)
660
+ print("\(self.TAG) Error set Channel", response.value!, error)
660
661
  setChannel.message = "Error set Channel \(String(describing: response.value))"
661
662
  setChannel.error = "response_error"
662
663
  }
@@ -668,7 +669,7 @@ extension CustomError: LocalizedError {
668
669
 
669
670
  func getChannel() -> GetChannel {
670
671
  let getChannel: GetChannel = GetChannel()
671
- if (self.channelUrl ?? "").isEmpty {
672
+ if (self.channelUrl ).isEmpty {
672
673
  print("\(self.TAG) Channel URL is not set")
673
674
  getChannel.message = "Channel URL is not set"
674
675
  getChannel.error = "missing_config"
@@ -708,7 +709,7 @@ extension CustomError: LocalizedError {
708
709
  }
709
710
 
710
711
  func sendStats(action: String, versionName: String) {
711
- if (self.statsUrl ?? "").isEmpty {
712
+ if (self.statsUrl ).isEmpty {
712
713
  return
713
714
  }
714
715
  var parameters: InfoObject = self.createInfoObject()
@@ -720,7 +721,7 @@ extension CustomError: LocalizedError {
720
721
  case .success:
721
722
  print("\(self.TAG) Stats send for \(action), version \(versionName)")
722
723
  case let .failure(error):
723
- print("\(self.TAG) Error sending stats: ", response.value, error)
724
+ print("\(self.TAG) Error sending stats: ", response.value!, error)
724
725
  }
725
726
  }
726
727
  }
@@ -803,7 +804,7 @@ extension CustomError: LocalizedError {
803
804
  guard let bundlePath: String = UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) else {
804
805
  return BundleInfo.ID_BUILTIN
805
806
  }
806
- if (bundlePath ?? "").isEmpty {
807
+ if (bundlePath ).isEmpty {
807
808
  return BundleInfo.ID_BUILTIN
808
809
  }
809
810
  let bundleID: String = bundlePath.components(separatedBy: "/").last ?? bundlePath
@@ -23,4 +23,5 @@ CAP_PLUGIN(CapacitorUpdaterPlugin, "CapacitorUpdater",
23
23
  CAP_PLUGIN_METHOD(getPluginVersion, CAPPluginReturnPromise);
24
24
  CAP_PLUGIN_METHOD(next, CAPPluginReturnPromise);
25
25
  CAP_PLUGIN_METHOD(isAutoUpdateEnabled, CAPPluginReturnPromise);
26
+ CAP_PLUGIN_METHOD(removeAllListeners, CAPPluginReturnPromise);
26
27
  )
@@ -15,7 +15,7 @@ import Version
15
15
  @objc(CapacitorUpdaterPlugin)
16
16
  public class CapacitorUpdaterPlugin: CAPPlugin {
17
17
  private var implementation = CapacitorUpdater()
18
- private let PLUGIN_VERSION: String = "4.29.0"
18
+ private let PLUGIN_VERSION: String = "4.34.0"
19
19
  static let updateUrlDefault = "https://api.capgo.app/updates"
20
20
  static let statsUrlDefault = "https://api.capgo.app/stats"
21
21
  static let channelUrlDefault = "https://api.capgo.app/channel_self"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.29.0",
3
+ "version": "4.34.0",
4
4
  "packageManager": "pnpm@8.1.0",
5
5
  "license": "MPL-2.0",
6
6
  "description": "Live update for capacitor apps",