serve-sim 0.1.50-beta.151.1 → 0.1.50-beta.152.1
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/Sources/SimNative/DuoHIDBridge.swift +9 -3
- package/Sources/SimNative/HIDInjector.swift +2 -0
- package/Sources/SimNative/sim-module.swift +6 -0
- package/dist/middleware.js +48 -48
- package/dist/native/serve-sim-native.node +0 -0
- package/dist/serve-sim.js +72 -72
- package/package.json +2 -1
- package/src/device-session.ts +4 -3
- package/src/launchable-helper.ts +112 -0
- package/src/native.ts +49 -9
|
@@ -6,7 +6,9 @@ import SimNativeSupport
|
|
|
6
6
|
/// replies acknowledge dispatch, so a failed command never switches capture.
|
|
7
7
|
final class DuoHIDBridge {
|
|
8
8
|
private let udid: String
|
|
9
|
-
|
|
9
|
+
/// Settable so JS can swap in a launchable copy once the device is known
|
|
10
|
+
/// to be a Duo (resolving it costs a `codesign` probe).
|
|
11
|
+
var executable: String
|
|
10
12
|
private var process: Process?
|
|
11
13
|
private var input: FileHandle?
|
|
12
14
|
private var output: FileHandle?
|
|
@@ -51,8 +53,12 @@ final class DuoHIDBridge {
|
|
|
51
53
|
while Date() < deadline && reply.count < 64 {
|
|
52
54
|
var descriptor = pollfd(fd: output.fileDescriptor, events: Int16(POLLIN), revents: 0)
|
|
53
55
|
let remaining = max(1, Int32(deadline.timeIntervalSinceNow * 1000))
|
|
54
|
-
guard poll(&descriptor, 1, remaining) > 0
|
|
55
|
-
|
|
56
|
+
guard poll(&descriptor, 1, remaining) > 0 else { break }
|
|
57
|
+
guard let byte = try output.read(upToCount: 1), !byte.isEmpty else {
|
|
58
|
+
// Its own stderr (inherited above) says why, e.g. dyld refusing to start it.
|
|
59
|
+
fputs("[hid] Duo guest helper exited without replying to \"\(command)\": \(executable)\n", stderr)
|
|
60
|
+
break
|
|
61
|
+
}
|
|
56
62
|
if byte[0] == 10 { return String(data: reply, encoding: .utf8) == "OK" }
|
|
57
63
|
reply.append(byte)
|
|
58
64
|
}
|
|
@@ -550,6 +550,8 @@ actor HIDInjector {
|
|
|
550
550
|
|
|
551
551
|
func isFoldable() -> Bool { duoBridge != nil }
|
|
552
552
|
|
|
553
|
+
func setDuoHelper(_ path: String) { duoBridge?.executable = path }
|
|
554
|
+
|
|
553
555
|
func close() { duoBridge = nil }
|
|
554
556
|
|
|
555
557
|
private func updateTouchTarget(width: Int, height: Int) {
|
|
@@ -91,6 +91,12 @@ private func u32(_ v: Int) -> UInt32 {
|
|
|
91
91
|
return await injector.isFoldable()
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/// Replace the guest helper the Duo bridge launches. No-op for other devices.
|
|
95
|
+
@NodeMethod func setDuoHelper(_ path: String) async throws {
|
|
96
|
+
try await setupTask.value
|
|
97
|
+
await injector.setDuoHelper(path)
|
|
98
|
+
}
|
|
99
|
+
|
|
94
100
|
@NodeMethod func close() async {
|
|
95
101
|
_ = try? await setupTask.value
|
|
96
102
|
await injector.close()
|