@rootnative/loupe-probe 0.0.0-alpha.0 → 0.0.0-alpha.2

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 ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@rootnative/loupe-probe` are in this file. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow modified semver: a breaking change bumps the middle digit (`0.1.0`), and fixes and additions bump the last digit (`0.0.2`).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.0.0-alpha.2] - 2026-11-25
8
+
9
+ No change since 0.0.0-alpha.1.
10
+
11
+ ## [0.0.0-alpha.1] - 2026-11-24
12
+
13
+ ### Added
14
+
15
+ - **`<LoupeProbe />`**. Render it once, inside your `SafeAreaProvider`. In development it gives loupe the safe-area insets, the window size, the scale, the layout direction, the colour scheme, and the `route` that you pass. It renders nothing in a release build.
16
+ - Peer dependencies: `react` 18 or later, `react-native` 0.73 or later, and `react-native-safe-area-context` 4 or later.
17
+
18
+ [unreleased]: https://github.com/rootnative/loupe/compare/loupe@0.0.0-alpha.2...HEAD
19
+ [0.0.0-alpha.2]: https://github.com/rootnative/loupe/releases/tag/loupe@0.0.0-alpha.2
20
+ [0.0.0-alpha.1]: https://github.com/rootnative/loupe/releases/tag/loupe@0.0.0-alpha.1
package/README.md CHANGED
@@ -1,10 +1,76 @@
1
1
  # @rootnative/loupe-probe
2
2
 
3
- The in-app helper of loupe by Root Native. It reports the safe-area insets,
4
- the window size and the layout direction of your app to loupe, in
5
- development only.
3
+ The in-app helper of [loupe](https://github.com/rootnative/loupe#readme).
6
4
 
7
- This version, `0.0.0-alpha.0`, is empty. It has no code. Use a later
8
- version.
5
+ Some facts about a screen are known only inside your app: the safe-area
6
+ insets of the current orientation, the window size, and the layout direction.
7
+ The probe reports them to loupe, in development only.
9
8
 
10
- Source and docs: https://github.com/rootnative/loupe
9
+ > The probe is in alpha, as loupe is. A new version can change its report.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install --save-dev @rootnative/loupe-probe
15
+ ```
16
+
17
+ The probe needs `react`, `react-native` and `react-native-safe-area-context`
18
+ in your app.
19
+
20
+ ## Use
21
+
22
+ Render `<LoupeProbe />` once, near the root of your app, inside your
23
+ `SafeAreaProvider`:
24
+
25
+ ```tsx
26
+ import { LoupeProbe } from '@rootnative/loupe-probe'
27
+ import { SafeAreaProvider } from 'react-native-safe-area-context'
28
+
29
+ export default function App() {
30
+ return (
31
+ <SafeAreaProvider>
32
+ <Navigation />
33
+ <LoupeProbe />
34
+ </SafeAreaProvider>
35
+ )
36
+ }
37
+ ```
38
+
39
+ Pass the current route, so that loupe can show it in a report:
40
+
41
+ ```tsx
42
+ <LoupeProbe route={pathname} />
43
+ ```
44
+
45
+ Keep the probe on the screen: not in a scroll view, and not in a screen that
46
+ is hidden. loupe reads it only while it is on the screen.
47
+
48
+ ## What it reports
49
+
50
+ The probe renders one view of 1 × 1 point at the top-left corner of its
51
+ parent. The view draws nothing and takes no touch. Its accessibility label
52
+ holds `loupe:` and a short JSON report:
53
+
54
+ | Field | What it is |
55
+ | --- | --- |
56
+ | `insets` | The safe-area insets of the current orientation, from the nearest `SafeAreaProvider`. Left out when there is no provider. |
57
+ | `window` | The window size. |
58
+ | `scale` | Pixels per point (pt on iOS, dp on Android). |
59
+ | `direction` | `ltr` or `rtl`. |
60
+ | `colorScheme` | `light` or `dark`. Left out when the system gives none. |
61
+ | `route` | The `route` prop, when you pass one. |
62
+
63
+ loupe finds the label in the accessibility tree that it reads already, so
64
+ the probe needs no network and no port. The label holds these fields and
65
+ nothing else from your app. Don't put private data in the route.
66
+
67
+ Screen readers skip the view: TalkBack and VoiceOver don't read it.
68
+
69
+ ## Release builds
70
+
71
+ `LoupeProbe` renders nothing unless `__DEV__` is true, so a release build
72
+ shows no probe.
73
+
74
+ ## License
75
+
76
+ MIT
@@ -0,0 +1,49 @@
1
+ import * as react from 'react';
2
+
3
+ interface LoupeProbeProps {
4
+ /** The current route, for example the path that your router gives. */
5
+ route?: string;
6
+ }
7
+ /**
8
+ * Reports the safe-area insets, the window, the layout direction and the
9
+ * colour scheme of the app to loupe. Render it once, near the root, inside
10
+ * your `SafeAreaProvider`. It renders nothing unless `__DEV__` is true.
11
+ */
12
+ declare function LoupeProbe(props: LoupeProbeProps): react.JSX.Element | null;
13
+
14
+ /**
15
+ * The app reports its state in the accessibility label of one hidden view:
16
+ * this prefix, then the report as JSON. loupe finds the label in the UI tree
17
+ * it already reads, so the report needs no network and no port.
18
+ */
19
+ declare const PROBE_PREFIX = "loupe:";
20
+ /** Goes up when a field changes its meaning, so loupe can refuse an old app. */
21
+ declare const PROBE_FORMAT = 1;
22
+ interface ProbeInsets {
23
+ top: number;
24
+ right: number;
25
+ bottom: number;
26
+ left: number;
27
+ }
28
+ /** Sizes are in pt on iOS and in dp on Android. */
29
+ interface ProbeReport {
30
+ /**
31
+ * The safe-area insets of the current orientation. Left out when the probe
32
+ * has no `SafeAreaProvider` above it.
33
+ */
34
+ insets?: ProbeInsets;
35
+ window: {
36
+ width: number;
37
+ height: number;
38
+ };
39
+ /** Pixels per pt or dp. */
40
+ scale: number;
41
+ direction: 'ltr' | 'rtl';
42
+ /** Left out when the system gives no colour scheme. */
43
+ colorScheme?: 'light' | 'dark';
44
+ /** The current route, when the app passes it. */
45
+ route?: string;
46
+ }
47
+ declare function encodeProbeReport(report: ProbeReport): string;
48
+
49
+ export { LoupeProbe, type LoupeProbeProps, PROBE_FORMAT, PROBE_PREFIX, type ProbeInsets, type ProbeReport, encodeProbeReport };
package/dist/index.js ADDED
@@ -0,0 +1,78 @@
1
+ // src/probe.tsx
2
+ import { useContext } from "react";
3
+ import {
4
+ I18nManager,
5
+ StyleSheet,
6
+ useColorScheme,
7
+ useWindowDimensions,
8
+ View
9
+ } from "react-native";
10
+ import { SafeAreaInsetsContext } from "react-native-safe-area-context";
11
+
12
+ // src/report.ts
13
+ var PROBE_PREFIX = "loupe:";
14
+ var PROBE_FORMAT = 1;
15
+ function encodeProbeReport(report) {
16
+ const { insets, window, scale, direction, colorScheme, route } = report;
17
+ return PROBE_PREFIX + JSON.stringify({
18
+ v: PROBE_FORMAT,
19
+ insets: insets && {
20
+ top: insets.top,
21
+ right: insets.right,
22
+ bottom: insets.bottom,
23
+ left: insets.left
24
+ },
25
+ window: { width: window.width, height: window.height },
26
+ scale,
27
+ direction,
28
+ colorScheme,
29
+ route
30
+ });
31
+ }
32
+
33
+ // src/probe.tsx
34
+ import { jsx } from "react/jsx-runtime";
35
+ function LoupeProbe(props) {
36
+ return __DEV__ ? /* @__PURE__ */ jsx(Probe, { ...props }) : null;
37
+ }
38
+ function Probe({ route }) {
39
+ const insets = useContext(SafeAreaInsetsContext);
40
+ const { width, height, scale } = useWindowDimensions();
41
+ const colorScheme = useColorScheme();
42
+ const label = encodeProbeReport({
43
+ insets: insets ?? void 0,
44
+ window: { width, height },
45
+ scale,
46
+ direction: I18nManager.isRTL ? "rtl" : "ltr",
47
+ colorScheme: colorScheme === "light" || colorScheme === "dark" ? colorScheme : void 0,
48
+ route
49
+ });
50
+ return /* @__PURE__ */ jsx(
51
+ View,
52
+ {
53
+ accessibilityLabel: label,
54
+ importantForAccessibility: "no",
55
+ collapsable: false,
56
+ style: styles.probe
57
+ }
58
+ );
59
+ }
60
+ var styles = StyleSheet.create({
61
+ // uiautomator leaves a node out of its dump when the user can't see it: an
62
+ // empty frame, alpha 0, or a hidden parent. So the view is 1 × 1, and it
63
+ // draws nothing because it has no background.
64
+ probe: {
65
+ position: "absolute",
66
+ top: 0,
67
+ left: 0,
68
+ width: 1,
69
+ height: 1,
70
+ pointerEvents: "none"
71
+ }
72
+ });
73
+ export {
74
+ LoupeProbe,
75
+ PROBE_FORMAT,
76
+ PROBE_PREFIX,
77
+ encodeProbeReport
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootnative/loupe-probe",
3
- "version": "0.0.0-alpha.0",
3
+ "version": "0.0.0-alpha.2",
4
4
  "description": "The in-app helper of loupe by Root Native: it reports the safe-area insets, the window size and the layout direction of your app to loupe, in development only.",
5
5
  "license": "MIT",
6
6
  "author": "Root Native",
@@ -23,10 +23,49 @@
23
23
  "testing",
24
24
  "ai-agents"
25
25
  ],
26
+ "type": "module",
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ "./package.json": "./package.json",
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ }
35
+ },
26
36
  "files": [
37
+ "dist",
27
38
  "README.md",
39
+ "CHANGELOG.md",
28
40
  "LICENSE"
29
41
  ],
42
+ "sideEffects": false,
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "prepack": "turbo run build --filter=@rootnative/loupe-probe",
46
+ "dev": "tsup --watch",
47
+ "typecheck": "tsc --noEmit",
48
+ "test": "vitest run",
49
+ "lint": "eslint . --max-warnings 0",
50
+ "clean": "node -e \"for (const p of ['dist', '.turbo']) require('node:fs').rmSync(p, { recursive: true, force: true })\""
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^22.20.2",
54
+ "@types/react": "19.3.0",
55
+ "@types/react-dom": "19.3.0",
56
+ "react": "19.3.0",
57
+ "react-dom": "19.3.0",
58
+ "react-native": "0.88.1",
59
+ "react-native-safe-area-context": "5.11.1",
60
+ "tsup": "^8.5.1",
61
+ "typescript": "^5.9.3",
62
+ "vitest": "^3.2.4"
63
+ },
64
+ "peerDependencies": {
65
+ "react": ">=18",
66
+ "react-native": ">=0.73",
67
+ "react-native-safe-area-context": ">=4"
68
+ },
30
69
  "publishConfig": {
31
70
  "access": "public"
32
71
  }