@rootnative/loupe 0.0.0-alpha.3 → 0.0.0-alpha.4

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/CHANGELOG.md CHANGED
@@ -4,6 +4,46 @@ All notable changes to `@rootnative/loupe` are in this file. The format follows
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.0.0-alpha.4] - 2026-11-30
8
+
9
+ loupe drives the iOS simulator on a Mac. Each command works there but `pinch` and `drag --shot`, and the Expo helpers open your app in Expo Go there too.
10
+
11
+ ### Added
12
+
13
+ - **`screenshot` works on an iOS simulator.** The first call for a simulator starts loupe's test runner on it with `xcodebuild`, which takes from 10 seconds to more than 5 minutes on a busy Mac. loupe waits up to 10 minutes for it. The runner stays after the command, so the next call is fast. It stops by itself after 10 minutes with no call, and when the simulator stops. The image is upright in each orientation, and the JSON has the size of the screen in pt. On a simulator, `screenshot` needs `app`: the bundle id of the app in front, or `com.apple.springboard` for the home screen. loupe reads the orientation of the screen from that app, so the image is upright also when the app keeps its own orientation on a turned simulator. loupe takes the screenshot only while that app is in front.
14
+ - **`rotate` works on an iOS simulator**, with `app`. loupe turns the simulator, and waits until the app in front has turned. An app that keeps its own orientation gives `orientation_locked`, and loupe turns the simulator back. The home screen of an iPhone stays in portrait, so it gives `orientation_locked` in landscape.
15
+ - **`ui` works on an iOS simulator**, with `app`. It gives the windows of the app, with frames in pt: an alert and the share sheet are in them. A static text has its words in `text`, and the testID of a view is its `id`. Buttons, cells, switches and fields are `clickable`, but a touchable view with no role isn't: the iOS tree doesn't tell. The probe's report is in `probe`, as on Android.
16
+ - **`insets` works on an iOS simulator**, with `app`, and reads the safe area only from the app's probe: iOS gives loupe no system numbers. With no probe, or a probe with no SafeAreaProvider above it, it gives `unsupported`.
17
+ - **`wait` works on an iOS simulator**, with `app`: `--text`, `--label` and `--id` read the iOS tree, and `--still` compares the whole screen (the clock in the status bar ticks once a minute, which costs one more screenshot).
18
+ - **`tap` works on an iOS simulator**, with `app`: at a point in pt, or on the element with a text, label or id, with `--wait-text` and `--wait-still`. XCUITest makes the touch on the simulator, so it never moves the pointer of your Mac or reaches another window, and `tap` returns after the app has taken it.
19
+ - **`double-tap` and `hold` work on an iOS simulator**, with `app`, as `tap` does. XCUITest makes the double-tap with the system's time between the taps, so `gap` is left out on iOS.
20
+ - **`swipe` and `drag` work on an iOS simulator**, with `app`. XCUITest moves at one speed, so loupe gives it the speed that takes `duration`, and presses for 50 ms at least before a move. `drag --shot` gives `unsupported` on iOS for now: XCUITest runs the whole drag as one call. On iOS a list can still fling after `--hold-end`.
21
+ - **`type` and `key` work on an iOS simulator**, with `app`. `type` takes any text there, into the field that has the keyboard focus; with none, it gives `element_not_found`. `key` presses the keys that an iPhone has: home, enter, tab, space and delete. The others, `back` among them, give `unsupported` with the reason.
22
+ - **`open-url`, `background` and `foreground` work on an iOS simulator**, with `app`. `open-url` opens the link with `simctl openurl`, waits until that app is in front, and answers the "Open in …?" of iOS with Open, only when it names that app; the JSON gives the question as `alert`. `background` sends the app away with the home button. `foreground`, and `background --for`, bring it back as it was, as the app switcher does (`way: "activate"`).
23
+ - **`theme` works on an iOS simulator**: with no theme it reads the appearance (`simctl ui … appearance`), and with `app` it sets light or dark, reads it back, and waits until the app's probe shows it, as on Android.
24
+ - **`dismiss` works on an iOS simulator**, with `app`. It closes, from the top, an alert of iOS over the app (layer `system-alert`, for example the "Open in …?" of a link or a permission), an alert of the app, and the share sheet, each with a tap (`tap-button`, or `tap-outside` above a sheet with no Close button). It taps only a button that cancels: Cancel, Close, Not Now, Don’t Allow, or the only button; an alert with none, and the keyboard, end the call as `next`, with the reason in `warnings`.
25
+ - **`scroll-to` works on an iOS simulator**, with `app`. An iOS list keeps the speed of a touch through a hold and flings at the lift, so on iOS each drag is slow (800 ms), and loupe reads until the list keeps still before it looks for the element.
26
+ - **`check` works on an iOS simulator**, with `app`, with each rule. `touch-target` asks 44 × 44 pt there, as Apple does, and the messages give pt. `inset` runs only with the probe: with none, the check says `safeAreaSource: "none"`, and `inset` gives a warning and no findings. The rules leave out Expo Go's gear and the scroll bars of the iOS tree. XCUITest gives the whole frame of an element, also past the screen edge, so `overflow` measures only the part on the screen. The iOS tree doesn't say which way a scroll view scrolls, so loupe takes one whose content goes past its left or right side as horizontal, as a carousel.
27
+ - **`measure` works on an iOS simulator**, with `app`: the colour runs of a row or a column of the upright screenshot, and where an element sits. The safe area comes from the probe; with none, `safeAreaSource` is `none`, the safe area is the whole screen, and a warning says so.
28
+ - **`sweep` works on an iOS simulator**, with `app`: each link in each orientation and theme, checked, with its screenshot and the contact sheets, and with `--scroll` and `--reload-every`. With `--direction`, for your app in Expo Go (`app host.exp.Exponent`), it sets each direction in app.json as on Android. At the end it puts the device orientation, the appearance and the direction back.
29
+ - **`expo-open`, `expo-reload` and `expo-rtl` work on an iOS simulator.** The simulator reaches Metro on your Mac with no port forward. loupe answers the "Open in “Expo Go”?" of iOS with Open, closes Expo Go's developer menu, and waits until the app shows, as on Android. After a stop, Expo Go on iOS can keep "Opening project..." or a blank screen until the link comes again, so loupe opens it again after 20 s. After `expo-reload` and `expo-rtl` of an app with the probe, loupe waits for the probe. An app with no probe whose screen never keeps still gives `not_idle`. `expo-reload` stops Expo Go with `simctl terminate`. On iOS the JSON has no `launchState`. With no Expo Go on the simulator, they give `no_handler`: press "i" in `npx expo start`, and the Expo CLI installs it.
30
+ - **`background` and `foreground` on iOS read the home screen first.** XCUITest can still say for many seconds that an app runs in front after it left, so while the home screen shows, loupe takes no app as in front. When the app is still in front 3 s after the home press, `background` presses home once more.
31
+ - `pinch` stays on Android emulators. On an iOS simulator it gives `unsupported` with the reason: XCUITest pinches an element around its own centre, so it can't take the point, the span, the angle and the turn of a loupe pinch.
32
+ - `rotate` takes `app` on Android too. With it, loupe rotates only while that app is in front.
33
+ - The runner listens on 127.0.0.1 only, and takes only requests with a token that loupe makes at each start. loupe keeps the port and the token, and the log of `xcodebuild`, in `~/Library/Caches/loupe`.
34
+
35
+ ### Changed
36
+
37
+ - In the JSON of `double-tap`, `gap` is optional, and in the JSON of `drag`, `moveTime` is optional: iOS leaves them out.
38
+ - In the JSON of `insets`, `systemBars`, `cutout` and `cutoutRects` are optional: iOS leaves them out. Android gives them as before.
39
+ - In the JSON of `check` and of `measure`, `safeAreaSource` can be `none`: an iOS screen with no probe.
40
+ - `CommandContext` has `spawnDetached`, which starts a tool that stays after the command. `createContext()` sets it. A context that you build by hand needs it.
41
+
42
+ ### Fixed
43
+
44
+ - `background --for` waits the whole time before it brings the app back. A timer could end 1 ms early, and `away` was then 1 ms short of `for`.
45
+ - On a busy Mac, `simctl list` can take more than 30 seconds right after a simulator boots. loupe stopped it then, so `devices` gave a warning in place of the simulators, and `device` didn't find a simulator. loupe now gives it 2 minutes.
46
+
7
47
  ## [0.0.0-alpha.3] - 2026-11-28
8
48
 
9
49
  The first step to iOS: on a Mac, `devices` lists the iOS simulators, and `device` takes one. loupe doesn't drive a simulator yet.
@@ -56,7 +96,8 @@ loupe drives an Android emulator or device, measures each screen of your app in
56
96
  - **The device:** `devices`, `open-url`, `rotate`, `theme`, `background`, `foreground`, and `dismiss`. `dismiss` closes a system sheet, a dialog, the keyboard, or an overlay of your app.
57
97
  - **The probe:** when your app renders `<LoupeProbe />` from `@rootnative/loupe-probe`, `insets` and the rules use the app's own safe area.
58
98
 
59
- [unreleased]: https://github.com/rootnative/loupe/compare/loupe@0.0.0-alpha.3...HEAD
99
+ [unreleased]: https://github.com/rootnative/loupe/compare/loupe@0.0.0-alpha.4...HEAD
100
+ [0.0.0-alpha.4]: https://github.com/rootnative/loupe/releases/tag/loupe@0.0.0-alpha.4
60
101
  [0.0.0-alpha.3]: https://github.com/rootnative/loupe/releases/tag/loupe@0.0.0-alpha.3
61
102
  [0.0.0-alpha.2]: https://github.com/rootnative/loupe/releases/tag/loupe@0.0.0-alpha.2
62
103
  [0.0.0-alpha.1]: https://github.com/rootnative/loupe/releases/tag/loupe@0.0.0-alpha.1
package/README.md CHANGED
@@ -2,20 +2,31 @@
2
2
 
3
3
  Layout checks for iOS and Android, built for AI agents.
4
4
 
5
- loupe drives an emulator or a device, opens each screen of your app, and
6
- gives your agent exact numbers: element frames, safe areas, cutouts, and
7
- edges, in dp. Your agent can then say "pass" or "fail" with evidence, not
8
- with a guess from a screenshot.
5
+ loupe drives a simulator, an emulator or a device, opens each screen of
6
+ your app, and gives your agent exact numbers: element frames, safe areas,
7
+ cutouts, and edges, in dp (pt on iOS). Your agent can then say "pass" or
8
+ "fail" with evidence, not with a guess from a screenshot.
9
+
10
+ > loupe is in alpha. On an iOS simulator, each command works but `pinch`
11
+ > and `drag --shot`, which give `unsupported`. Each command on a simulator
12
+ > that reads or touches the screen needs `--app`: the bundle id of the app
13
+ > in front, or `com.apple.springboard` for the home screen. A new version
14
+ > can change the commands, their options, and their JSON.
15
+
16
+
17
+
18
+
19
+
9
20
 
10
- > loupe is in alpha, and it drives Android only for now. A new version can
11
- > change the commands, their options, and their JSON.
12
21
 
13
22
  ## What you need
14
23
 
15
24
  - Node.js 20.19 or later.
16
- - `adb` from the Android SDK platform tools, on your `PATH` or in
17
- `$ANDROID_HOME/platform-tools`.
18
- - An emulator or a device with Android 11 (API level 30) or later.
25
+ - For Android: `adb` from the Android SDK platform tools, on your `PATH` or
26
+ in `$ANDROID_HOME/platform-tools`, and an emulator or a device with
27
+ Android 11 (API level 30) or later.
28
+ - For iOS: a Mac with Xcode 16.4 or later, and a simulator with iOS 18.5 or
29
+ later. loupe doesn't drive an iPhone yet.
19
30
 
20
31
  ## Use it with an agent
21
32
 
@@ -128,10 +139,10 @@ the end.
128
139
 
129
140
  | Rule | Fails when |
130
141
  | --- | --- |
131
- | `inset` | An element with text, a label, or a touch sits under a system bar or the cutout, or outside the safe area. |
142
+ | `inset` | An element with text, a label, or a touch sits under a system bar or the cutout, or outside the safe area. On iOS it runs only with the probe. |
132
143
  | `overflow` | An element at a screen edge is shorter than the elements like it in its row or column: the edge cuts it. |
133
144
  | `centred` | A text with an element on each side is more than 4 dp from the centre of its container. |
134
- | `touch-target` | An element that you can press is smaller than 48 × 48 dp. From 40 dp, loupe gives a warning: a `hitSlop` can make it whole. |
145
+ | `touch-target` | An element that you can press is smaller than 48 × 48 dp (44 × 44 pt on iOS). From 40 dp, loupe gives a warning: a `hitSlop` can make it whole. |
135
146
  | `mirrored` | In RTL, an element sits where LTR puts it. Save the other direction with `ui --out <file>`, then run `check --mirror-of <file>`. |
136
147
 
137
148
  Each finding gives the element and its numbers in dp.
@@ -141,31 +152,31 @@ Each finding gives the element and its numbers in dp.
141
152
  | Command | What it does |
142
153
  | --- | --- |
143
154
  | `devices` | List the Android emulators and devices, the AVDs that don't run, and on a Mac the iOS simulators. |
144
- | `open-url` | Open a link (a deep link or a web page), and wait until it opens. |
145
- | `check` | Check the screen for layout defects with the rules above. |
146
- | `sweep` | Open each link in each orientation and theme, check each screen, and write a report, the screenshots, and a contact sheet of each variant. |
147
- | `screenshot` | Save the screen as a PNG file, upright in each orientation. |
148
- | `ui` | Read the accessibility tree of the screen, with frames in dp. |
149
- | `insets` | Read the safe-area insets and the cutout of the current orientation. |
150
- | `measure` | Measure the colour runs along a row or a column, or where an element sits on the screen and in the safe area. |
151
- | `wait` | Wait until the screen keeps still, or until an element is on the screen. |
152
- | `rotate` | Turn the screen, and wait until it has turned. |
153
- | `theme` | Set the system theme to light or dark, and wait until the app shows it. With no theme, read it. |
154
- | `tap` | Tap one point, or the element with a text, label, or id. |
155
- | `double-tap` | Tap one point or element twice. |
156
- | `hold` | Touch one point or element and hold it: a long press. |
157
- | `swipe` | Move one touch in a straight line from one point to another. |
158
- | `drag` | Touch, hold, move, hold, and lift, with a screenshot while the touch is down. |
159
- | `pinch` | Pinch or spread two fingers around a point or an element, and turn them. On an emulator only. |
160
- | `scroll-to` | Scroll until the element with a text, label, or id is in view, and give its frame. |
161
- | `type` | Type text into the field that has the focus. |
162
- | `key` | Press one key, for example `back`, `home`, or `enter`. |
163
- | `dismiss` | Close the top layer over the app: the keyboard, a dialog, a menu or a sheet of the app, a system sheet, or the notification shade. |
164
- | `background` | Send the app in front to the background. With `--for`, bring it back after that time. |
165
- | `foreground` | Bring an app back to the front, as a person does from Recents. |
166
- | `expo-open` | Open the app in Expo Go at a route, close Expo Go's onboarding sheet and developer menu, and wait until the app shows. |
167
- | `expo-reload` | Stop Expo Go and open the app again, so its JavaScript starts again. Keep the route when the app has the probe. |
168
- | `expo-rtl` | Turn RTL on or off in the app.json of the app, and open the app again in that direction. `off` puts app.json back as it was. |
155
+ | `open-url` | Open a link (a deep link or a web page), and wait until it opens. On an iOS simulator, with `--app`: loupe waits until that app is in front, and answers iOS's "Open in …?" for it. |
156
+ | `check` | Check the screen for layout defects with the rules above. It works on an iOS simulator too, with `--app`; there the `inset` rule needs the probe. |
157
+ | `sweep` | Open each link in each orientation and theme, check each screen, and write a report, the screenshots, and a contact sheet of each variant. It works on an iOS simulator too, with `--app`. |
158
+ | `screenshot` | Save the screen as a PNG file, upright in each orientation. It works on an iOS simulator too, with `--app`. |
159
+ | `ui` | Read the accessibility tree of the screen, with frames in dp (pt on iOS). It works on an iOS simulator too, with `--app`. |
160
+ | `insets` | Read the safe-area insets and the cutout of the current orientation. On an iOS simulator, with `--app`, it reads the safe area from the probe only. |
161
+ | `measure` | Measure the colour runs along a row or a column, or where an element sits on the screen and in the safe area. It works on an iOS simulator too, with `--app`; there the safe area needs the probe. |
162
+ | `wait` | Wait until the screen keeps still, or until an element is on the screen. It works on an iOS simulator too, with `--app`. |
163
+ | `rotate` | Turn the screen, and wait until it has turned. It works on an iOS simulator too, with `--app`. |
164
+ | `theme` | Set the system theme to light or dark, and wait until the app shows it. With no theme, read it. It works on an iOS simulator too: reading needs nothing, setting needs `--app`. |
165
+ | `tap` | Tap one point, or the element with a text, label, or id. It works on an iOS simulator too, with `--app`. |
166
+ | `double-tap` | Tap one point or element twice. It works on an iOS simulator too, with `--app`. |
167
+ | `hold` | Touch one point or element and hold it: a long press. It works on an iOS simulator too, with `--app`. |
168
+ | `swipe` | Move one touch in a straight line from one point to another. It works on an iOS simulator too, with `--app`. |
169
+ | `drag` | Touch, hold, move, hold, and lift, with a screenshot while the touch is down. It works on an iOS simulator too, with `--app`, but with no screenshot. |
170
+ | `pinch` | Pinch or spread two fingers around a point or an element, and turn them. On an Android emulator only: a real device and an iOS simulator give `unsupported`. |
171
+ | `scroll-to` | Scroll until the element with a text, label, or id is in view, and give its frame. It works on an iOS simulator too, with `--app`. |
172
+ | `type` | Type text into the field that has the focus. It works on an iOS simulator too, with `--app`, and takes any text there. |
173
+ | `key` | Press one key, for example `back`, `home`, or `enter`. On an iOS simulator, with `--app`: only home, enter, tab, space and delete. |
174
+ | `dismiss` | Close the top layer over the app: the keyboard, a dialog, a menu or a sheet of the app, a system sheet, or the notification shade. On an iOS simulator, with `--app`: an alert of iOS or of the app, and the share sheet; not the keyboard, which iOS can't hide with a key. |
175
+ | `background` | Send the app in front to the background. With `--for`, bring it back after that time. It works on an iOS simulator too, with `--app`. |
176
+ | `foreground` | Bring an app back to the front, as a person does from Recents. On an iOS simulator, XCUITest brings the app back as it was. |
177
+ | `expo-open` | Open the app in Expo Go at a route, close Expo Go's onboarding sheet and developer menu, and wait until the app shows. It works on an iOS simulator too, and answers the "Open in “Expo Go”?" of iOS. |
178
+ | `expo-reload` | Stop Expo Go and open the app again, so its JavaScript starts again. Keep the route when the app has the probe. It works on an iOS simulator too. |
179
+ | `expo-rtl` | Turn RTL on or off in the app.json of the app, and open the app again in that direction. `off` puts app.json back as it was. It works on an iOS simulator too. |
169
180
  | `expo-warm` | Ask Metro (`npx expo start`) for the app and its bundle, so that the first open in Expo Go is fast. Give the SHA-256 of the bundle. |
170
181
  | `version` | Print the loupe version and the host it runs on. |
171
182
 
@@ -173,7 +184,8 @@ Each finding gives the element and its numbers in dp.
173
184
 
174
185
  With [`@rootnative/loupe-probe`](https://github.com/rootnative/loupe/tree/main/packages/probe#readme)
175
186
  in your app, `insets` and the rules use the app's own safe area. Without it,
176
- loupe takes the safe area from Android.
187
+ loupe takes the safe area from Android. On an iOS simulator, `insets` reads
188
+ only the probe.
177
189
 
178
190
  ## Privacy
179
191
 
package/dist/bin.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  registry,
7
7
  runCommand,
8
8
  version
9
- } from "./chunk-7ALG5744.js";
9
+ } from "./chunk-ROE4FVE2.js";
10
10
 
11
11
  // src/cli/flags.ts
12
12
  import { parseArgs } from "util";
@@ -230,7 +230,7 @@ async function mcp(args, io, registry2, context) {
230
230
  io.err('Run "loupe mcp --help" for its use.');
231
231
  return EXIT_USAGE;
232
232
  }
233
- const { serveMcp } = await import("./server-3J6ZMCJG.js");
233
+ const { serveMcp } = await import("./server-VPDLHMTP.js");
234
234
  await serveMcp({
235
235
  registry: registry2,
236
236
  context,