@craft-native/ios 0.0.247 → 0.0.248
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 +1 -0
- package/dist/cli.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +54 -53
- package/package.json +1 -1
- package/templates/CraftApp.swift +37 -2
- package/templates/CraftHealth.swift +217 -0
- package/templates/CraftHeartRate.swift +6 -3
- package/templates/CraftHybrid.swift +18 -19
- package/templates/CraftLiveActivities.swift +1 -1
- package/templates/CraftNativeActions.swift +87 -8
- package/templates/CraftNativeFiles.swift +15 -3
- package/templates/CraftNativeFlatList.swift +18 -1
- package/templates/CraftNativeMutation.swift +36 -0
- package/templates/CraftNativeScreen.swift +813 -65
- package/templates/CraftNativeServices.swift +4 -2
- package/templates/CraftNativeUI.swift +10 -2
- package/templates/testing/DriverTests.swift.template +1 -0
- package/templates/testing/HostApp.swift +9 -2
|
@@ -313,8 +313,10 @@ final class CraftNativeSounds {
|
|
|
313
313
|
func play(id: String, url: URL, options: [String: Any], answer: @escaping (Result<Any, CraftNativeActionError>) -> Void) {
|
|
314
314
|
stop(id: id, fadeOut: 0)
|
|
315
315
|
let loop = options["loop"] as? Bool ?? false
|
|
316
|
-
let
|
|
317
|
-
let
|
|
316
|
+
let volumeValue = craftNativeNumber(options["volume"]).map { $0.doubleValue }.flatMap { $0.isFinite ? $0 : nil } ?? 1
|
|
317
|
+
let fadeInValue = craftNativeNumber(options["fadeIn"]).map { $0.doubleValue }.flatMap { $0.isFinite ? $0 : nil } ?? 0
|
|
318
|
+
let volume = Float(min(max(volumeValue, 0), 1))
|
|
319
|
+
let fadeIn = max(0, fadeInValue) / 1000
|
|
318
320
|
Self.claimSession(respectSilentSwitch: options["respectSilentSwitch"] as? Bool ?? true)
|
|
319
321
|
let item = AVPlayerItem(url: url)
|
|
320
322
|
let player = AVQueuePlayer()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import AuthenticationServices
|
|
2
|
+
import CoreFoundation
|
|
2
3
|
import SafariServices
|
|
3
4
|
import UIKit
|
|
4
5
|
import WebKit
|
|
@@ -54,7 +55,12 @@ enum CraftPresenter {
|
|
|
54
55
|
/// view's points, as a rect. Nil when it is not one.
|
|
55
56
|
static func rect(_ value: Any?) -> CGRect? {
|
|
56
57
|
guard let value = value as? [String: Any] else { return nil }
|
|
57
|
-
func number(_ key: String) -> CGFloat? {
|
|
58
|
+
func number(_ key: String) -> CGFloat? {
|
|
59
|
+
guard let number = value[key] as? NSNumber,
|
|
60
|
+
CFGetTypeID(number) != CFBooleanGetTypeID() else { return nil }
|
|
61
|
+
let value = CGFloat(truncating: number)
|
|
62
|
+
return value.isFinite ? value : nil
|
|
63
|
+
}
|
|
58
64
|
guard let x = number("x"), let y = number("y") else { return nil }
|
|
59
65
|
return CGRect(x: x, y: y, width: max(0, number("width") ?? 0), height: max(0, number("height") ?? 0))
|
|
60
66
|
}
|
|
@@ -464,7 +470,9 @@ extension CraftSignInWithApple: ASAuthorizationControllerDelegate, ASAuthorizati
|
|
|
464
470
|
/// show the same glyph the system's own controls use.
|
|
465
471
|
enum CraftSymbols {
|
|
466
472
|
static func image(named name: String, options: [String: Any]) -> String? {
|
|
467
|
-
let pointSize = (options["pointSize"]
|
|
473
|
+
let pointSize = craftNativeNumber(options["pointSize"])
|
|
474
|
+
.map { CGFloat(truncating: $0) }
|
|
475
|
+
.flatMap { $0.isFinite ? $0 : nil } ?? 17
|
|
468
476
|
let weight: UIImage.SymbolWeight
|
|
469
477
|
switch options["weight"] as? String {
|
|
470
478
|
case "ultraLight": weight = .ultraLight
|
|
@@ -276,6 +276,7 @@ final class DriverTests: XCTestCase {
|
|
|
276
276
|
let host = XCUIApplication(bundleIdentifier: "{{BUNDLE_PREFIX}}.host")
|
|
277
277
|
host.launchArguments = ["--craft-universal-link", url.absoluteString]
|
|
278
278
|
host.launch()
|
|
279
|
+
host.buttons["craft-driver-open-universal-link"].tap()
|
|
279
280
|
let opened = app.wait(for: .runningForeground, timeout: 75)
|
|
280
281
|
if !opened {
|
|
281
282
|
post("/save?name=universal-link-host.txt", Data(host.debugDescription.utf8))
|
|
@@ -7,8 +7,15 @@ struct HostApp: App {
|
|
|
7
7
|
|
|
8
8
|
var body: some Scene {
|
|
9
9
|
WindowGroup {
|
|
10
|
-
|
|
11
|
-
.
|
|
10
|
+
VStack {
|
|
11
|
+
Text(status).accessibilityIdentifier("craft-driver-status")
|
|
12
|
+
// XCTest must finish acquiring the host's launch assertion
|
|
13
|
+
// before a handoff can move another application foreground.
|
|
14
|
+
Button("Open Universal Link") {
|
|
15
|
+
Task { await openUniversalLinkIfRequested() }
|
|
16
|
+
}
|
|
17
|
+
.accessibilityIdentifier("craft-driver-open-universal-link")
|
|
18
|
+
}
|
|
12
19
|
}
|
|
13
20
|
}
|
|
14
21
|
|