@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.
@@ -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 volume = Float(min(max((options["volume"] as? NSNumber)?.doubleValue ?? 1, 0), 1))
317
- let fadeIn = max(0, (options["fadeIn"] as? NSNumber)?.doubleValue ?? 0) / 1000
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? { (value[key] as? NSNumber).map { CGFloat(truncating: $0) } }
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"] as? NSNumber).map { CGFloat(truncating: $0) } ?? 17
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
- Text(status).accessibilityIdentifier("craft-driver-status")
11
- .task { await openUniversalLinkIfRequested() }
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