ReviewOS

also looking at this

craft-native/craft

feat(ios): haptic, whose reason expired when ios_config landed

#130
Closed glennmichael123 wants to merge feat/ios-haptic-reason-expired into test/ios-reply-shape-conformance
3 files +236 -78
packages/zig/src/ios_dispatch.zigmodified+12-6
Changes to packages/zig/src/ios_dispatch.zig
@@ -382,8 +382,10 @@ comptime {
382382///
383383/// `.status = .unavailable` in a module's manifest means the handler is
384384/// reachable and refuses, deliberately, because Zig cannot do the thing
385/// correctly — `haptic` cannot see `config.enableHaptics`, and the rest say
386/// why in their own `reason`.
385/// correctly; each one says why in its own `reason`. `haptic` was the example
386/// this comment used to give, and is now the example of a reason expiring:
387/// `ios_config.zig` made `config.enableHaptics` readable and the refusal
388/// outlived it.
387389///
388390/// In the Zig-hosted app that refusal is the honest end of the line: `route`
389391/// tries `handOffToHost` next, and the shim is what actually serves it. The
@@ -391,8 +393,9 @@ comptime {
391393/// deliberately does not consult `handOffToHost`, because there the host *is*
392394/// the caller. So claiming one of these would not be a refusal instead of an
393395/// answer, it would be a refusal instead of the *host's working answer*: an app
394/// that has haptics today would stop buzzing the moment the runtime was linked,
395/// and the page would get a rejection where it used to get silence-and-a-buzz.
396/// that had haptics would have stopped buzzing the moment the runtime was
397/// linked, and the page would have got a rejection where it used to get
398/// silence-and-a-buzz.
396399///
397400/// `test/ios_conformance_test.zig` already treats falling through as better
398401/// than `.unavailable`. This is that rule, applied to the one path that had no
@@ -904,7 +907,6 @@ test "an action declared unavailable is left to the host, not claimed" {
904907 // the difference, linking the runtime replaced the working answer with a
905908 // rejection. `false` here is what sends the call back to Swift's switch.
906909 const declared_unavailable = [_][]const u8{
907 "haptic",
908910 "getNetworkStatus",
909911 "lockOrientation",
910912 "unlockOrientation",
@@ -929,7 +931,7 @@ test "the fall-through is read from the manifests, not from a list kept beside t
929931 }
930932 }
931933 }
932 try testing.expectEqual(@as(usize, 4), declared);
934 try testing.expectEqual(@as(usize, 3), declared);
933935}
934936
935937test "a live action is still claimed, unavailable is not a blanket hand-back" {
@@ -937,6 +939,10 @@ test "a live action is still claimed, unavailable is not a blanket hand-back" {
937939 // `.live`, so the seam must keep claiming it. A fall-through that widened
938940 // to whole modules would silently un-migrate everything beside a refusal.
939941 try testing.expect(!hostServesItself("vibrate"));
942 // `haptic` was the fourth entry above until `ios_config.zig` made the gate
943 // it could not read readable. It is served here now, so handing it back
944 // would hand back a working action.
945 try testing.expect(!hostServesItself("haptic"));
940946 try testing.expect(!hostServesItself("setKeepAwake"));
941947 try testing.expect(!hostServesItself("getDeviceInfo"));
942948 try testing.expect(!hostServesItself("noSuchAction"));