craft-native 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/dist/android/templates/MainActivityNative.kt.template +7 -0
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/templates/CraftApp.swift +1 -1
- package/dist/ios/templates/CraftNativeActions.swift +20 -0
- package/dist/ios/templates/CraftNativeScreen.swift +6 -0
- package/package.json +1 -1
|
@@ -1882,6 +1882,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
1882
1882
|
openScreen(route, payload.optJSONObject("params") ?: JSONObject())
|
|
1883
1883
|
}
|
|
1884
1884
|
"NAVIGATE_BACK" -> if (screens.lastOrNull() === screen) back()
|
|
1885
|
+
"NAVIGATE_POP_TO_ROOT" -> if (screens.lastOrNull() === screen) popToRoot()
|
|
1885
1886
|
"API_REQUEST" -> answerAPI(screen, message, payload)
|
|
1886
1887
|
"API_CANCEL" -> {
|
|
1887
1888
|
val id = payload.optString("requestId")
|
|
@@ -3197,6 +3198,12 @@ class MainActivity : AppCompatActivity() {
|
|
|
3197
3198
|
}
|
|
3198
3199
|
}
|
|
3199
3200
|
|
|
3201
|
+
/** Back to the first screen in one move. */
|
|
3202
|
+
private fun popToRoot() {
|
|
3203
|
+
while (screens.size > 1) closeScreen(screens.removeAt(screens.lastIndex))
|
|
3204
|
+
show(screens.last())
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3200
3207
|
private fun back() {
|
|
3201
3208
|
if (screens.size > 1) {
|
|
3202
3209
|
closeScreen(screens.removeAt(screens.lastIndex))
|
package/dist/cli.js
CHANGED
|
@@ -3303,7 +3303,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3303
3303
|
`);
|
|
3304
3304
|
}
|
|
3305
3305
|
// package.json
|
|
3306
|
-
var version = "0.0.
|
|
3306
|
+
var version = "0.0.149";
|
|
3307
3307
|
|
|
3308
3308
|
// bin/cli.ts
|
|
3309
3309
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -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] ?? []
|