@craft-native/ios 0.0.147 → 0.0.149

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@craft-native/ios",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "homepage": "https://github.com/craft-native/craft/tree/main/packages/ios#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8438,7 +8438,7 @@ final class CraftZigRuntime: NSObject {
8438
8438
  enum CraftWebServices {
8439
8439
  private static var waiting: [String: (Result<Any, CraftNativeActionError>) -> Void] = [:]
8440
8440
  /// Coordinator events a native screen hears too.
8441
- static let forwardedEvents: Set<String> = ["craftLocationUpdate", "craftLocationError"]
8441
+ static let forwardedEvents: Set<String> = ["craftLocationUpdate", "craftLocationError", "craftMusicChange"]
8442
8442
  static let event = Notification.Name("craftWebServicesEvent")
8443
8443
 
8444
8444
  static var isAvailable: Bool { CraftSwiftShim.coordinator != nil }
@@ -59,6 +59,8 @@ enum CraftNativeActions {
59
59
  // GPS and the route recording are the web view's coordinator's
60
60
  // (CraftWebServices), so a native-only app, which has none, has none.
61
61
  if config.enableGeolocation && config.renderer != "native" { values.append("geolocation") }
62
+ // The Music app's song and transport are the coordinator's too.
63
+ if config.enableAppleMusic && config.renderer != "native" { values.append("music") }
62
64
  return values
63
65
  }
64
66
 
@@ -270,6 +272,24 @@ enum CraftNativeActions {
270
272
  }
271
273
  CraftWebServices.perform(action: action, body: args.first as? [String: Any] ?? [:]) { complete(requestToken, $0, completion) }
272
274
  return
275
+ case ("Music", _):
276
+ // The page's own Music app bridge (CraftMusic.swift), in the web
277
+ // view's coordinator: one observer, whose changes reach the page
278
+ // and every native screen as `craftMusicChange`.
279
+ guard config.enableAppleMusic else {
280
+ complete(requestToken, failure("CAPABILITY_DISABLED", "Apple Music is disabled"), completion)
281
+ return
282
+ }
283
+ let actions = [
284
+ "getAuthorizationStatus": "musicGetAuthorization", "requestAuthorization": "musicRequestAuthorization",
285
+ "getNowPlaying": "musicGetNowPlaying", "control": "musicControl", "observe": "musicObserve",
286
+ ]
287
+ guard let action = actions[method] else {
288
+ complete(requestToken, failure("UNKNOWN_ACTION", "Unsupported Music method"), completion)
289
+ return
290
+ }
291
+ CraftWebServices.perform(action: action, body: args.first as? [String: Any] ?? [:]) { complete(requestToken, $0, completion) }
292
+ return
273
293
  case ("Linking", "openURL"), ("Linking", "canOpenURL"):
274
294
  // Another app or the system: `webcal:` subscriptions, `mailto:`,
275
295
  // `tel:`, the App Store, this app's page in Settings
@@ -3274,6 +3274,12 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
3274
3274
  if navigationController?.topViewController === self {
3275
3275
  navigationController?.popViewController(animated: true)
3276
3276
  }
3277
+ case "NAVIGATE_POP_TO_ROOT":
3278
+ // Back to the first screen of this screen's stack in one move: a
3279
+ // finished task (a saved workout) closes the way it was reached.
3280
+ if navigationController?.topViewController === self {
3281
+ navigationController?.popToRootViewController(animated: true)
3282
+ }
3277
3283
  case "API_REQUEST":
3278
3284
  guard let id = message["id"] as? String else { return }
3279
3285
  let args = payload["args"] as? [Any] ?? []