craft-native 0.0.214 → 0.0.215
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/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/src/index.js +4 -1
- package/dist/ios/src/testing.d.ts +5 -0
- package/dist/ios/templates/testing/DriverTests.swift.template +16 -0
- package/dist/ios/templates/testing/HostApp.swift +31 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3424,7 +3424,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3424
3424
|
`);
|
|
3425
3425
|
}
|
|
3426
3426
|
// package.json
|
|
3427
|
-
var version = "0.0.
|
|
3427
|
+
var version = "0.0.215";
|
|
3428
3428
|
|
|
3429
3429
|
// bin/cli.ts
|
|
3430
3430
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/ios/src/index.js
CHANGED
|
@@ -156,8 +156,11 @@ function serializeSimulatorSteps(steps) {
|
|
|
156
156
|
}
|
|
157
157
|
} else if ("name" in step)
|
|
158
158
|
arg = token(step.name);
|
|
159
|
-
else if ("url" in step)
|
|
159
|
+
else if ("url" in step) {
|
|
160
|
+
if (step.command === "universallink" && new URL(step.url).protocol !== "https:")
|
|
161
|
+
throw new Error("Universal Links require an HTTPS URL");
|
|
160
162
|
arg = step.url;
|
|
163
|
+
}
|
|
161
164
|
if (/[\r\n]/.test(arg))
|
|
162
165
|
throw new Error("Simulator arguments cannot contain newlines");
|
|
163
166
|
return `${step.command}${arg ? ` ${arg}` : ""}`;
|
|
@@ -60,6 +60,11 @@ export type SimulatorStep = {
|
|
|
60
60
|
command: 'openurl';
|
|
61
61
|
url: string;
|
|
62
62
|
}
|
|
63
|
+
/** Use Apple's universalLinksOnly API, allowing association downloads up to 60 seconds. */
|
|
64
|
+
| {
|
|
65
|
+
command: 'universallink';
|
|
66
|
+
url: string;
|
|
67
|
+
}
|
|
63
68
|
/** Runs `step` only when the element with this identifier is there (a screen shown the first time). */
|
|
64
69
|
| {
|
|
65
70
|
command: 'ifid';
|
|
@@ -14,6 +14,7 @@ import XCTest
|
|
|
14
14
|
/// delay <ms> every proxied request waits this long (0 = off)
|
|
15
15
|
/// exec <hook> runs the switch's HOOKS/<hook>.sh on the Mac (restart the API, …)
|
|
16
16
|
/// openurl <url> opens a link through the system, answering "Open in the app?"
|
|
17
|
+
/// universallink <https-url> waits up to 60s for an OS-verified link; never opens a browser
|
|
17
18
|
/// shot <name> screenshot → shots/<name>.png
|
|
18
19
|
/// tree <name> accessibility tree → shots/<name>.txt
|
|
19
20
|
/// tap <text> first hittable element whose label contains text
|
|
@@ -253,6 +254,21 @@ final class DriverTests: XCTestCase {
|
|
|
253
254
|
answerOpenPrompt()
|
|
254
255
|
note("openurl \(arg)")
|
|
255
256
|
}
|
|
257
|
+
case "universallink":
|
|
258
|
+
guard let url = URL(string: arg), url.scheme == "https" else {
|
|
259
|
+
check(false, "universallink requires an HTTPS URL")
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
let host = XCUIApplication(bundleIdentifier: "{{BUNDLE_PREFIX}}.host")
|
|
263
|
+
host.launchArguments = ["--craft-universal-link", url.absoluteString]
|
|
264
|
+
host.launch()
|
|
265
|
+
let opened = app.wait(for: .runningForeground, timeout: 75)
|
|
266
|
+
if !opened {
|
|
267
|
+
post("/save?name=universal-link-host.txt", Data(host.debugDescription.utf8))
|
|
268
|
+
post("/save?name=universal-link-app.txt", Data(app.debugDescription.utf8))
|
|
269
|
+
}
|
|
270
|
+
check(opened, "universallink \(arg) opened the target app")
|
|
271
|
+
host.terminate()
|
|
256
272
|
case "shot":
|
|
257
273
|
let shot = XCUIScreen.main.screenshot()
|
|
258
274
|
post("/save?name=\(arg).png", shot.pngRepresentation)
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
|
+
import UIKit
|
|
2
3
|
|
|
3
4
|
@main
|
|
4
5
|
struct HostApp: App {
|
|
5
|
-
|
|
6
|
+
@State private var status = "Craft simulator driver"
|
|
7
|
+
|
|
8
|
+
var body: some Scene {
|
|
9
|
+
WindowGroup {
|
|
10
|
+
Text(status).accessibilityIdentifier("craft-driver-status")
|
|
11
|
+
.task { await openUniversalLinkIfRequested() }
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@MainActor
|
|
16
|
+
private func openUniversalLinkIfRequested() async {
|
|
17
|
+
let arguments = ProcessInfo.processInfo.arguments
|
|
18
|
+
guard let index = arguments.firstIndex(of: "--craft-universal-link"),
|
|
19
|
+
arguments.indices.contains(index + 1),
|
|
20
|
+
let url = URL(string: arguments[index + 1]), url.scheme == "https" else { return }
|
|
21
|
+
// Installation returns before iOS finishes downloading the AASA from
|
|
22
|
+
// Apple's CDN. Ask the public API until the OS accepts the association;
|
|
23
|
+
// universalLinksOnly prevents a failed attempt from opening Safari.
|
|
24
|
+
let deadline = Date().addingTimeInterval(60)
|
|
25
|
+
while Date() < deadline && !Task.isCancelled {
|
|
26
|
+
let opened = await UIApplication.shared.open(url, options: [.universalLinksOnly: true])
|
|
27
|
+
if opened {
|
|
28
|
+
status = "Universal Link accepted"
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
status = "Waiting for Universal Link association"
|
|
32
|
+
try? await Task.sleep(nanoseconds: 1_000_000_000)
|
|
33
|
+
}
|
|
34
|
+
status = "Universal Link was not accepted within 60 seconds"
|
|
35
|
+
}
|
|
6
36
|
}
|