@capacitor/ios 3.5.1 → 3.6.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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.6.0](https://github.com/ionic-team/capacitor/compare/3.5.1...3.6.0) (2022-06-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ios:** Use `URL(fileURLWithPath:)` instead of `URL(string:)` ([#5603](https://github.com/ionic-team/capacitor/issues/5603)) ([5fac1b2](https://github.com/ionic-team/capacitor/commit/5fac1b2da5aa5882087716cb2aa862d89173f4a1))
12
+
13
+
14
+ ### Features
15
+
16
+ * **iOS, Android:** add AppUUID Lib for plugins ([#5690](https://github.com/ionic-team/capacitor/issues/5690)) ([05e76cf](https://github.com/ionic-team/capacitor/commit/05e76cf526a44e07fa75f9482fa2223a13918638))
17
+
18
+
19
+
20
+
21
+
6
22
  ## [3.5.1](https://github.com/ionic-team/capacitor/compare/3.5.0...3.5.1) (2022-05-04)
7
23
 
8
24
  **Note:** Version bump only for package @capacitor/ios
@@ -0,0 +1,53 @@
1
+ import CommonCrypto
2
+ import Foundation
3
+
4
+ private func hexString(_ iterator: Array<UInt8>.Iterator) -> String {
5
+ return iterator.map { String(format: "%02x", $0) }.joined()
6
+ }
7
+
8
+ extension Data {
9
+ public var sha256: String {
10
+ var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
11
+ self.withUnsafeBytes { bytes in
12
+ _ = CC_SHA256(bytes.baseAddress, CC_LONG(self.count), &digest)
13
+ }
14
+ return hexString(digest.makeIterator())
15
+ }
16
+ }
17
+
18
+ public class AppUUID {
19
+ private static let key: String = "CapacitorAppUUID"
20
+
21
+ public static func getAppUUID() -> String {
22
+ assertAppUUID()
23
+ return readUUID()
24
+ }
25
+
26
+ public static func regenerateAppUUID() {
27
+ let uuid = generateUUID()
28
+ writeUUID(uuid)
29
+ }
30
+
31
+ private static func assertAppUUID() {
32
+ let uuid = readUUID()
33
+ if uuid == "" {
34
+ regenerateAppUUID()
35
+ }
36
+ }
37
+
38
+ private static func generateUUID() -> String {
39
+ let uuid: String = UUID.init().uuidString
40
+ return uuid.data(using: .utf8)!.sha256
41
+ }
42
+
43
+ private static func readUUID() -> String {
44
+ let defaults = UserDefaults.standard
45
+ return defaults.string(forKey: key) ?? ""
46
+ }
47
+
48
+ private static func writeUUID(_ uuid: String) {
49
+ let defaults = UserDefaults.standard
50
+ defaults.set(uuid, forKey: key)
51
+ }
52
+
53
+ }
@@ -10,18 +10,20 @@ import Foundation
10
10
 
11
11
  public protocol Router {
12
12
  func route(for path: String) -> String
13
+ var basePath: String { get set }
13
14
  }
14
15
 
15
16
  // swiftlint:disable:next type_name
16
17
  internal struct _Router: Router {
18
+ var basePath: String = ""
17
19
  func route(for path: String) -> String {
18
- let pathUrl = URL(string: path)
20
+ let pathUrl = URL(fileURLWithPath: path)
19
21
 
20
- // if the pathUrl is null, then it is an invalid url (meaning it is empty or just plain invalid) then we want to route to /index.html
21
- if pathUrl?.pathExtension.isEmpty ?? true {
22
- return "/index.html"
22
+ // If there's no path extension it also means the path is empty or a SPA route
23
+ if pathUrl.pathExtension.isEmpty {
24
+ return basePath + "/index.html"
23
25
  }
24
26
 
25
- return path
27
+ return basePath + path
26
28
  }
27
29
  }
@@ -3,8 +3,7 @@ import MobileCoreServices
3
3
 
4
4
  @objc(CAPWebViewAssetHandler)
5
5
  internal class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
6
- private let router: Router
7
- private var basePath: String = ""
6
+ private var router: Router
8
7
 
9
8
  init(router: Router) {
10
9
  self.router = router
@@ -12,19 +11,18 @@ internal class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
12
11
  }
13
12
 
14
13
  func setAssetPath(_ assetPath: String) {
15
- self.basePath = assetPath
14
+ router.basePath = assetPath
16
15
  }
17
16
 
18
17
  func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
19
- var startPath = self.basePath
18
+ let startPath: String
20
19
  let url = urlSchemeTask.request.url!
21
20
  let stringToLoad = url.path
22
21
 
23
- let resolvedRoute = router.route(for: stringToLoad)
24
22
  if stringToLoad.starts(with: CapacitorBridge.fileStartIdentifier) {
25
23
  startPath = stringToLoad.replacingOccurrences(of: CapacitorBridge.fileStartIdentifier, with: "")
26
24
  } else {
27
- startPath.append(resolvedRoute)
25
+ startPath = router.route(for: stringToLoad)
28
26
  }
29
27
 
30
28
  let localUrl = URL.init(string: url.absoluteString)!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/ios",
3
- "version": "3.5.1",
3
+ "version": "3.6.0",
4
4
  "description": "Capacitor: Cross-platform apps with JavaScript and the web",
5
5
  "homepage": "https://capacitorjs.com",
6
6
  "author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
@@ -24,10 +24,10 @@
24
24
  "xc:build:CapacitorCordova": "cd CapacitorCordova && xcodebuild && cd .."
25
25
  },
26
26
  "peerDependencies": {
27
- "@capacitor/core": "^3.5.0"
27
+ "@capacitor/core": "^3.6.0"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "009064dbf01cbc5900bbc16053b6d7535ad4c2b4"
32
+ "gitHead": "1e06a199a44bb5321f0fb48b5fbca961cc1dbb50"
33
33
  }