@capacitor/ios 4.0.0-alpha.2 → 4.0.0-beta.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 +69 -0
- package/Capacitor/Capacitor/AppUUID.swift +53 -0
- package/Capacitor/Capacitor/CAPBridgeViewController.swift +6 -2
- package/Capacitor/Capacitor/Router.swift +29 -0
- package/Capacitor/Capacitor/UIColor.swift +2 -2
- package/Capacitor/Capacitor/WebViewAssetHandler.swift +46 -22
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
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
|
+
# [4.0.0-beta.0](https://github.com/ionic-team/capacitor/compare/3.6.0...4.0.0-beta.0) (2022-06-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ios:** make removeAllListeners return a promise ([#5526](https://github.com/ionic-team/capacitor/issues/5526)) ([815f71b](https://github.com/ionic-team/capacitor/commit/815f71b6b62f6c4d5f66e6a36c190bb00a96fdcc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **ios:** add getConfig to CAPPlugin ([#5495](https://github.com/ionic-team/capacitor/issues/5495)) ([224a9d0](https://github.com/ionic-team/capacitor/commit/224a9d075629d9c9da9ddc658eb282617fc46d09))
|
|
17
|
+
* **ios:** Add preferredContentMode configuration option ([#5583](https://github.com/ionic-team/capacitor/issues/5583)) ([5b6dfa3](https://github.com/ionic-team/capacitor/commit/5b6dfa3fe29c85632546b299f03cc04a77cf7475))
|
|
18
|
+
* **ios:** Support of range requests on WebViewAssetHandler ([#5659](https://github.com/ionic-team/capacitor/issues/5659)) ([348c08d](https://github.com/ionic-team/capacitor/commit/348c08d511e9d57a1b2ecedc3290c65fa9ba3924))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# [3.6.0](https://github.com/ionic-team/capacitor/compare/3.5.1...3.6.0) (2022-06-17)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* **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))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* **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))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
6
40
|
# [4.0.0-alpha.2](https://github.com/ionic-team/capacitor/compare/3.4.1...4.0.0-alpha.2) (2022-05-12)
|
|
7
41
|
|
|
8
42
|
|
|
@@ -20,6 +54,26 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
20
54
|
|
|
21
55
|
|
|
22
56
|
|
|
57
|
+
|
|
58
|
+
## [3.5.1](https://github.com/ionic-team/capacitor/compare/3.5.0...3.5.1) (2022-05-04)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @capacitor/ios
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# [3.5.0](https://github.com/ionic-team/capacitor/compare/3.4.3...3.5.0) (2022-04-22)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Features
|
|
70
|
+
|
|
71
|
+
* **ios:** Add overrideable routing for CAPBridgeViewController subclasses ([#5546](https://github.com/ionic-team/capacitor/issues/5546)) ([8875d5e](https://github.com/ionic-team/capacitor/commit/8875d5e2721e8a8ee763ce70cb672db383f36efa))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
23
77
|
# [4.0.0-alpha.1](https://github.com/ionic-team/capacitor/compare/3.4.1...4.0.0-alpha.1) (2022-03-25)
|
|
24
78
|
|
|
25
79
|
|
|
@@ -31,6 +85,21 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
31
85
|
|
|
32
86
|
|
|
33
87
|
|
|
88
|
+
## [3.4.3](https://github.com/ionic-team/capacitor/compare/3.4.2...3.4.3) (2022-03-04)
|
|
89
|
+
|
|
90
|
+
**Note:** Version bump only for package @capacitor/ios
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## [3.4.2](https://github.com/ionic-team/capacitor/compare/3.4.1...3.4.2) (2022-03-03)
|
|
97
|
+
|
|
98
|
+
**Note:** Version bump only for package @capacitor/ios
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
34
103
|
## [3.4.1](https://github.com/ionic-team/capacitor/compare/3.4.0...3.4.1) (2022-02-09)
|
|
35
104
|
|
|
36
105
|
|
|
@@ -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
|
+
}
|
|
@@ -42,7 +42,7 @@ import Cordova
|
|
|
42
42
|
setScreenOrientationDefaults()
|
|
43
43
|
|
|
44
44
|
// get the web view
|
|
45
|
-
let assetHandler = WebViewAssetHandler()
|
|
45
|
+
let assetHandler = WebViewAssetHandler(router: router())
|
|
46
46
|
assetHandler.setAssetPath(configuration.appLocation.path)
|
|
47
47
|
let delegationHandler = WebViewDelegationHandler()
|
|
48
48
|
prepareWebView(with: configuration, assetHandler: assetHandler, delegationHandler: delegationHandler)
|
|
@@ -89,7 +89,11 @@ import Cordova
|
|
|
89
89
|
}
|
|
90
90
|
return descriptor
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
|
|
93
|
+
open func router() -> Router {
|
|
94
|
+
return _Router()
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
/**
|
|
94
98
|
The WKWebViewConfiguration to use for the webview.
|
|
95
99
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Router.swift
|
|
3
|
+
// Capacitor
|
|
4
|
+
//
|
|
5
|
+
// Created by Steven Sherry on 3/29/22.
|
|
6
|
+
// Copyright © 2022 Drifty Co. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
|
|
11
|
+
public protocol Router {
|
|
12
|
+
func route(for path: String) -> String
|
|
13
|
+
var basePath: String { get set }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// swiftlint:disable:next type_name
|
|
17
|
+
internal struct _Router: Router {
|
|
18
|
+
var basePath: String = ""
|
|
19
|
+
func route(for path: String) -> String {
|
|
20
|
+
let pathUrl = URL(fileURLWithPath: path)
|
|
21
|
+
|
|
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"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return basePath + path
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -26,14 +26,14 @@ public extension CapacitorExtensionTypeWrapper where T: UIColor {
|
|
|
26
26
|
with: ""
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
var argb:
|
|
29
|
+
var argb: UInt64 = 0
|
|
30
30
|
|
|
31
31
|
var red: CGFloat = 0.0
|
|
32
32
|
var green: CGFloat = 0.0
|
|
33
33
|
var blue: CGFloat = 0.0
|
|
34
34
|
var alpha: CGFloat = 1.0
|
|
35
35
|
|
|
36
|
-
guard Scanner(string: hexString).
|
|
36
|
+
guard Scanner(string: hexString).scanHexInt64(&argb) else { return nil }
|
|
37
37
|
|
|
38
38
|
if hexString.count == 6 {
|
|
39
39
|
red = CGFloat((argb & 0xFF0000) >> 16) / 255.0
|
|
@@ -3,49 +3,73 @@ import MobileCoreServices
|
|
|
3
3
|
|
|
4
4
|
@objc(CAPWebViewAssetHandler)
|
|
5
5
|
internal class WebViewAssetHandler: NSObject, WKURLSchemeHandler {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
private var router: Router
|
|
7
|
+
|
|
8
|
+
init(router: Router) {
|
|
9
|
+
self.router = router
|
|
10
|
+
super.init()
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
func setAssetPath(_ assetPath: String) {
|
|
10
|
-
|
|
14
|
+
router.basePath = assetPath
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
func webView(_ webView: WKWebView, start urlSchemeTask: WKURLSchemeTask) {
|
|
14
|
-
|
|
18
|
+
let startPath: String
|
|
15
19
|
let url = urlSchemeTask.request.url!
|
|
16
20
|
let stringToLoad = url.path
|
|
17
|
-
|
|
21
|
+
|
|
18
22
|
if stringToLoad.starts(with: CapacitorBridge.fileStartIdentifier) {
|
|
19
23
|
startPath = stringToLoad.replacingOccurrences(of: CapacitorBridge.fileStartIdentifier, with: "")
|
|
20
|
-
} else if stringToLoad.isEmpty || url.pathExtension.isEmpty {
|
|
21
|
-
startPath.append("/index.html")
|
|
22
24
|
} else {
|
|
23
|
-
startPath.
|
|
25
|
+
startPath = router.route(for: stringToLoad)
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
let localUrl = URL.init(string: url.absoluteString)!
|
|
26
29
|
let fileUrl = URL.init(fileURLWithPath: startPath)
|
|
27
30
|
|
|
28
31
|
do {
|
|
29
32
|
var data = Data()
|
|
30
|
-
if !stringToLoad.contains("cordova.js") {
|
|
31
|
-
if isMediaExtension(pathExtension: url.pathExtension) {
|
|
32
|
-
data = try Data(contentsOf: fileUrl, options: Data.ReadingOptions.mappedIfSafe)
|
|
33
|
-
} else {
|
|
34
|
-
data = try Data(contentsOf: fileUrl)
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
33
|
let mimeType = mimeTypeForExtension(pathExtension: url.pathExtension)
|
|
38
|
-
|
|
39
|
-
let headers = [
|
|
34
|
+
var headers = [
|
|
40
35
|
"Content-Type": mimeType,
|
|
41
36
|
"Cache-Control": "no-cache"
|
|
42
37
|
]
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
if let rangeString = urlSchemeTask.request.value(forHTTPHeaderField: "Range"),
|
|
39
|
+
let totalSize = try fileUrl.resourceValues(forKeys: [.fileSizeKey]).fileSize,
|
|
40
|
+
isMediaExtension(pathExtension: url.pathExtension) {
|
|
41
|
+
let fileHandle = try FileHandle(forReadingFrom: fileUrl)
|
|
42
|
+
let parts = rangeString.components(separatedBy: "=")
|
|
43
|
+
let streamParts = parts[1].components(separatedBy: "-")
|
|
44
|
+
let fromRange = Int(streamParts[0]) ?? 0
|
|
45
|
+
var toRange = totalSize - 1
|
|
46
|
+
if streamParts.count > 1 {
|
|
47
|
+
toRange = Int(streamParts[1]) ?? toRange
|
|
48
|
+
}
|
|
49
|
+
let rangeLength = toRange - fromRange + 1
|
|
50
|
+
try fileHandle.seek(toOffset: UInt64(fromRange))
|
|
51
|
+
data = fileHandle.readData(ofLength: rangeLength)
|
|
52
|
+
headers["Accept-Ranges"] = "bytes"
|
|
53
|
+
headers["Content-Range"] = "bytes \(fromRange)-\(toRange)/\(totalSize)"
|
|
54
|
+
headers["Content-Length"] = String(data.count)
|
|
55
|
+
let response = HTTPURLResponse(url: localUrl, statusCode: 206, httpVersion: nil, headerFields: headers)
|
|
56
|
+
urlSchemeTask.didReceive(response!)
|
|
57
|
+
try fileHandle.close()
|
|
47
58
|
} else {
|
|
48
|
-
|
|
59
|
+
if !stringToLoad.contains("cordova.js") {
|
|
60
|
+
if isMediaExtension(pathExtension: url.pathExtension) {
|
|
61
|
+
data = try Data(contentsOf: fileUrl, options: Data.ReadingOptions.mappedIfSafe)
|
|
62
|
+
} else {
|
|
63
|
+
data = try Data(contentsOf: fileUrl)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let urlResponse = URLResponse(url: localUrl, mimeType: mimeType, expectedContentLength: data.count, textEncodingName: nil)
|
|
67
|
+
let httpResponse = HTTPURLResponse(url: localUrl, statusCode: 200, httpVersion: nil, headerFields: headers)
|
|
68
|
+
if isMediaExtension(pathExtension: url.pathExtension) {
|
|
69
|
+
urlSchemeTask.didReceive(urlResponse)
|
|
70
|
+
} else {
|
|
71
|
+
urlSchemeTask.didReceive(httpResponse!)
|
|
72
|
+
}
|
|
49
73
|
}
|
|
50
74
|
urlSchemeTask.didReceive(data)
|
|
51
75
|
} catch let error as NSError {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/ios",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.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.
|
|
27
|
+
"@capacitor/core": "^3.6.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "d9e553f76fac74df6ab0f2bf5c3da18e51b2282b"
|
|
33
33
|
}
|