@rnperf/sdk 0.0.0-stage → 0.1.0

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/index.js ADDED
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startPerfMonitor = startPerfMonitor;
4
+ exports.stopPerfMonitor = stopPerfMonitor;
5
+ exports.setScreen = setScreen;
6
+ exports.mark = mark;
7
+ exports.measure = measure;
8
+ exports.reportTTI = reportTTI;
9
+ exports.trackInteraction = trackInteraction;
10
+ exports.perfLog = perfLog;
11
+ exports.isPerfMonitorConnected = isPerfMonitorConnected;
12
+ exports.createNavigationTracker = createNavigationTracker;
13
+ const probes_js_1 = require("./probes.js");
14
+ const rn_js_1 = require("./rn.js");
15
+ const native_js_1 = require("./native.js");
16
+ const renders_js_1 = require("./renders.js");
17
+ const transport_js_1 = require("./transport.js");
18
+ const DEFAULT_PORT = 8139;
19
+ class PerfMonitor {
20
+ transport;
21
+ fps = new probes_js_1.FpsProbe();
22
+ stalls = new probes_js_1.StallProbe();
23
+ bridge = new probes_js_1.BridgeProbe();
24
+ renders = new renders_js_1.RenderTracker();
25
+ nativeFrames = new native_js_1.NativeFrameProbe();
26
+ timer = null;
27
+ reporting = false;
28
+ startedAt = 0;
29
+ currentScreen;
30
+ marks = new Map();
31
+ ttiReported = new Set();
32
+ running = false;
33
+ start(options = {}) {
34
+ if (this.running)
35
+ return;
36
+ const dev = Boolean(global.__DEV__);
37
+ if (!dev && !options.enableInRelease) {
38
+ // Profiling costs real CPU. Opting in to it in production must be explicit.
39
+ return;
40
+ }
41
+ const host = options.host === 'auto' || !options.host ? (0, rn_js_1.inferHost)() : options.host;
42
+ if (!host) {
43
+ warn('could not infer the daemon host from the Metro bundle URL — pass `host` explicitly.');
44
+ return;
45
+ }
46
+ this.running = true;
47
+ this.startedAt = (0, probes_js_1.now)();
48
+ const platform = rn_js_1.Platform.OS === 'android' ? 'android' : 'ios';
49
+ this.transport = new transport_js_1.Transport(host, options.port ?? DEFAULT_PORT, {
50
+ app: {
51
+ bundleId: options.bundleId ?? (0, rn_js_1.inferBundleId)(),
52
+ name: options.appName,
53
+ version: options.appVersion,
54
+ },
55
+ platform,
56
+ deviceName: rn_js_1.Platform.constants?.Model ?? rn_js_1.Platform.constants?.Brand,
57
+ runtime: {
58
+ rnVersion: rn_js_1.Platform.constants?.reactNativeVersion
59
+ ? formatVersion(rn_js_1.Platform.constants.reactNativeVersion)
60
+ : undefined,
61
+ hermes: (0, probes_js_1.isHermes)(),
62
+ dev,
63
+ },
64
+ }, options.onStatus);
65
+ this.transport.connect();
66
+ this.fps.start();
67
+ this.stalls.start();
68
+ if (options.trackBridge !== false)
69
+ this.bridge.start();
70
+ if (options.trackUiFrames !== false) {
71
+ if (this.nativeFrames.attach()) {
72
+ this.nativeFrames.start();
73
+ }
74
+ else {
75
+ warn((0, native_js_1.explainMissingNativeModule)());
76
+ }
77
+ }
78
+ if (options.trackRenders !== false && !this.renders.install()) {
79
+ warn('component render tracking is unavailable — React had not initialised when the monitor started. Call startPerfMonitor() after importing your root component.');
80
+ }
81
+ const intervalMs = options.intervalMs ?? 1000;
82
+ this.timer = setInterval(() => void this.report(), intervalMs);
83
+ this.installErrorHook();
84
+ }
85
+ async report() {
86
+ if (!this.transport)
87
+ return;
88
+ // Reading the native window is a bridge round trip. If the JS thread is
89
+ // blocked it may still be outstanding when the next tick fires; skipping
90
+ // is correct, because the native side keeps accumulating either way and
91
+ // the following read simply covers a longer window.
92
+ if (this.reporting)
93
+ return;
94
+ this.reporting = true;
95
+ try {
96
+ await this.collectAndSend();
97
+ }
98
+ finally {
99
+ this.reporting = false;
100
+ }
101
+ }
102
+ async collectAndSend() {
103
+ if (!this.transport)
104
+ return;
105
+ const t = Date.now();
106
+ const sample = { t, dt: Math.round((0, probes_js_1.now)() - this.startedAt) };
107
+ const fps = this.fps.read();
108
+ if (fps !== undefined)
109
+ sample.jsFps = Math.round(fps * 10) / 10;
110
+ const { jsStallMaxMs, jsStallCount } = this.stalls.read();
111
+ if (jsStallCount > 0) {
112
+ sample.jsStallMaxMs = Math.round(jsStallMaxMs);
113
+ sample.jsStallCount = jsStallCount;
114
+ }
115
+ Object.assign(sample, (0, probes_js_1.readJsHeap)());
116
+ const bridgeCalls = this.bridge.read();
117
+ if (bridgeCalls !== undefined)
118
+ sample.bridgeCalls = bridgeCalls;
119
+ const renders = this.renders.read();
120
+ if (renders)
121
+ sample.renders = renders;
122
+ if (this.currentScreen)
123
+ sample.screen = this.currentScreen;
124
+ if (this.nativeFrames.available) {
125
+ const frames = await this.nativeFrames.read();
126
+ if (frames.uiFps !== undefined)
127
+ sample.uiFps = round1(frames.uiFps);
128
+ if (frames.refreshHz !== undefined)
129
+ sample.uiRefreshHz = frames.refreshHz;
130
+ if (frames.frameP50Ms !== undefined)
131
+ sample.frameP50Ms = round2(frames.frameP50Ms);
132
+ if (frames.frameP95Ms !== undefined)
133
+ sample.frameP95Ms = round2(frames.frameP95Ms);
134
+ if (frames.frameP99Ms !== undefined)
135
+ sample.frameP99Ms = round2(frames.frameP99Ms);
136
+ if (frames.jankPercent !== undefined)
137
+ sample.jankPercent = round1(frames.jankPercent);
138
+ if (frames.framesRendered !== undefined)
139
+ sample.framesRendered = frames.framesRendered;
140
+ // Without a cable the daemon cannot read memory at all, so for a device
141
+ // on Wi-Fi these are the only memory figures available for the run.
142
+ if (frames.memoryMB !== undefined)
143
+ sample.rssMB = round1(frames.memoryMB);
144
+ if (frames.javaHeapMB !== undefined)
145
+ sample.javaHeapMB = round1(frames.javaHeapMB);
146
+ if (frames.nativeHeapMB !== undefined)
147
+ sample.nativeHeapMB = round1(frames.nativeHeapMB);
148
+ }
149
+ // The transport may have been torn down while awaiting the bridge.
150
+ this.transport?.sendSample(sample);
151
+ }
152
+ installErrorHook() {
153
+ try {
154
+ const handler = global.ErrorUtils?.getGlobalHandler?.();
155
+ global.ErrorUtils?.setGlobalHandler?.((error, isFatal) => {
156
+ this.transport?.sendEvent({
157
+ type: 'crash',
158
+ t: Date.now(),
159
+ message: `${isFatal ? 'Fatal: ' : ''}${error?.message ?? String(error)}`,
160
+ stack: error?.stack,
161
+ });
162
+ handler?.(error, isFatal);
163
+ });
164
+ }
165
+ catch { /* leave the app's own handler alone */ }
166
+ }
167
+ /* ------------------------------------------------------------ public */
168
+ setScreen(name) {
169
+ if (this.currentScreen === name)
170
+ return;
171
+ this.currentScreen = name;
172
+ this.transport?.sendEvent({ type: 'screen', t: Date.now(), name });
173
+ }
174
+ mark(name, detail) {
175
+ this.marks.set(name, (0, probes_js_1.now)());
176
+ this.transport?.sendEvent({ type: 'mark', t: Date.now(), name, detail });
177
+ }
178
+ measure(name, startMark, detail) {
179
+ const start = this.marks.get(startMark ?? name);
180
+ if (start === undefined)
181
+ return undefined;
182
+ const durationMs = (0, probes_js_1.now)() - start;
183
+ this.transport?.sendEvent({
184
+ type: 'measure', t: Date.now(), name, durationMs: Math.round(durationMs * 100) / 100, detail,
185
+ });
186
+ return durationMs;
187
+ }
188
+ /** Report time-to-interactive for a screen. Ignored after the first call per screen. */
189
+ reportTTI(screen, durationMs) {
190
+ const key = screen ?? '__app__';
191
+ if (this.ttiReported.has(key))
192
+ return;
193
+ this.ttiReported.add(key);
194
+ this.transport?.sendEvent({
195
+ type: 'tti',
196
+ t: Date.now(),
197
+ durationMs: Math.round(durationMs ?? (0, probes_js_1.now)() - this.startedAt),
198
+ screen,
199
+ });
200
+ }
201
+ trackInteraction(name, durationMs) {
202
+ this.transport?.sendEvent({ type: 'interaction', t: Date.now(), name, durationMs: Math.round(durationMs) });
203
+ }
204
+ log(level, message, tag) {
205
+ this.transport?.sendEvent({ type: 'log', t: Date.now(), level, message, tag });
206
+ }
207
+ stop() {
208
+ if (!this.running)
209
+ return;
210
+ this.running = false;
211
+ if (this.timer)
212
+ clearInterval(this.timer);
213
+ this.timer = null;
214
+ this.fps.stop();
215
+ this.stalls.stop();
216
+ this.bridge.stop();
217
+ this.nativeFrames.stop();
218
+ this.renders.uninstall();
219
+ this.transport?.close();
220
+ this.transport = undefined;
221
+ }
222
+ get isConnected() {
223
+ return Boolean(this.transport?.connected);
224
+ }
225
+ }
226
+ const monitor = new PerfMonitor();
227
+ /**
228
+ * Start streaming performance data to the rnperf daemon.
229
+ *
230
+ * Call it once, as early as possible but **after** React has loaded, so the
231
+ * render tracker can attach to React's commit hook:
232
+ *
233
+ * ```ts
234
+ * import { startPerfMonitor } from '@rnperf/sdk';
235
+ * import App from './App';
236
+ *
237
+ * startPerfMonitor(); // host is derived from the Metro URL
238
+ * ```
239
+ *
240
+ * In a release build it is a no-op unless `enableInRelease` is set.
241
+ */
242
+ function startPerfMonitor(options) {
243
+ monitor.start(options);
244
+ }
245
+ function stopPerfMonitor() {
246
+ monitor.stop();
247
+ }
248
+ /** Tell the monitor which screen is active, so findings can name it. */
249
+ function setScreen(name) {
250
+ monitor.setScreen(name);
251
+ }
252
+ function mark(name, detail) {
253
+ monitor.mark(name, detail);
254
+ }
255
+ /** Duration since `mark(startMark ?? name)`, also reported to the daemon. */
256
+ function measure(name, startMark, detail) {
257
+ return monitor.measure(name, startMark, detail);
258
+ }
259
+ function reportTTI(screen, durationMs) {
260
+ monitor.reportTTI(screen, durationMs);
261
+ }
262
+ function trackInteraction(name, durationMs) {
263
+ monitor.trackInteraction(name, durationMs);
264
+ }
265
+ function perfLog(level, message, tag) {
266
+ monitor.log(level, message, tag);
267
+ }
268
+ function isPerfMonitorConnected() {
269
+ return monitor.isConnected;
270
+ }
271
+ /**
272
+ * Drop-in for React Navigation: pass to `<NavigationContainer onStateChange>`
273
+ * (or call from your own router) to segment metrics by screen.
274
+ *
275
+ * ```tsx
276
+ * <NavigationContainer onStateChange={() => setScreen(navigationRef.getCurrentRoute()?.name ?? '')}>
277
+ * ```
278
+ */
279
+ function createNavigationTracker(getCurrentRouteName) {
280
+ let previous;
281
+ let enteredAt = (0, probes_js_1.now)();
282
+ return () => {
283
+ const name = getCurrentRouteName();
284
+ if (!name || name === previous)
285
+ return;
286
+ if (previous)
287
+ monitor.trackInteraction(`navigate:${previous}→${name}`, (0, probes_js_1.now)() - enteredAt);
288
+ previous = name;
289
+ enteredAt = (0, probes_js_1.now)();
290
+ monitor.setScreen(name);
291
+ };
292
+ }
293
+ /* --------------------------------------------------------------- helpers */
294
+ function formatVersion(v) {
295
+ return `${v.major ?? 0}.${v.minor ?? 0}.${v.patch ?? 0}`;
296
+ }
297
+ const round1 = (n) => Math.round(n * 10) / 10;
298
+ const round2 = (n) => Math.round(n * 100) / 100;
299
+ function warn(message) {
300
+ if (global.__DEV__)
301
+ console.warn(`[rnperf] ${message}`);
302
+ }
303
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAqPA,4CAEC;AAED,0CAEC;AAGD,8BAEC;AAED,oBAEC;AAGD,0BAEC;AAED,8BAEC;AAED,4CAEC;AAED,0BAEC;AAED,wDAEC;AAUD,0DAWC;AA9SD,2CAA2F;AAC3F,mCAA6D;AAC7D,2CAA2E;AAC3E,6CAA6C;AAC7C,iDAA2C;AAO3C,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,MAAM,WAAW;IACP,SAAS,CAAa;IACb,GAAG,GAAG,IAAI,oBAAQ,EAAE,CAAC;IACrB,MAAM,GAAG,IAAI,sBAAU,EAAE,CAAC;IAC1B,MAAM,GAAG,IAAI,uBAAW,EAAE,CAAC;IAC3B,OAAO,GAAG,IAAI,0BAAa,EAAE,CAAC;IAC9B,YAAY,GAAG,IAAI,4BAAgB,EAAE,CAAC;IAC/C,KAAK,GAA0C,IAAI,CAAC;IACpD,SAAS,GAAG,KAAK,CAAC;IAClB,SAAS,GAAG,CAAC,CAAC;IACd,aAAa,CAAU;IACvB,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACh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AAO,CAAC,gBAAgB,CAAC,YAAY,QAAQ,IAAI,IAAI,EAAE,EAAE,IAAA,eAAG,GAAE,GAAG,SAAS,CAAC,CAAC;QAC1F,QAAQ,GAAG,IAAI,CAAC;QAChB,SAAS,GAAG,IAAA,eAAG,GAAE,CAAC;QAClB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AAED,6EAA6E;AAE7E,SAAS,aAAa,CAAC,CAAqD;IAC1E,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;AAC9D,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AAEhE,SAAS,IAAI,CAAC,OAAe;IAC3B,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,44 @@
1
+ /** One window of UI-thread frame data, drained from the native module. */
2
+ export interface NativeFrameMetrics {
3
+ uiFps?: number;
4
+ frameP50Ms?: number;
5
+ frameP95Ms?: number;
6
+ frameP99Ms?: number;
7
+ jankPercent?: number;
8
+ framesRendered?: number;
9
+ /** The display's maximum refresh rate — 120 on ProMotion hardware. */
10
+ refreshHz?: number;
11
+ /** iOS: physical footprint in MB — what Xcode shows, and what jetsam judges. */
12
+ memoryMB?: number;
13
+ /** Android: Java heap in use. */
14
+ javaHeapMB?: number;
15
+ /** Android: native heap allocated. */
16
+ nativeHeapMB?: number;
17
+ }
18
+ /**
19
+ * Bridge to the optional `RNPerfFrameMonitor` native module.
20
+ *
21
+ * Everything degrades to "no UI-thread data" rather than throwing: the module
22
+ * is absent in Expo Go, in a build where pods were not reinstalled, and on
23
+ * Android (where the daemon reads frame timings from `adb` instead).
24
+ */
25
+ export declare class NativeFrameProbe {
26
+ private module?;
27
+ private started;
28
+ private inFlight;
29
+ private failures;
30
+ /** Attaches to the native module. Returns false when it is unavailable. */
31
+ attach(): boolean;
32
+ start(): void;
33
+ /**
34
+ * Reads and resets the native window. Returns `{}` when a read is already
35
+ * outstanding, which happens when the JS thread is blocked — precisely when
36
+ * piling up more bridge calls would make things worse.
37
+ */
38
+ read(): Promise<NativeFrameMetrics>;
39
+ stop(): void;
40
+ get available(): boolean;
41
+ }
42
+ /** Why UI-thread frame data is unavailable, phrased for a dev-time warning. */
43
+ export declare function explainMissingNativeModule(): string;
44
+ //# sourceMappingURL=native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAIA,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAQD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAK;IAErB,2EAA2E;IAC3E,MAAM,IAAI,OAAO;IAWjB,KAAK,IAAI,IAAI;IAUb;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAkBzC,IAAI,IAAI,IAAI;IAWZ,IAAI,SAAS,IAAI,OAAO,CAEvB;CACF;AAED,+EAA+E;AAC/E,wBAAgB,0BAA0B,IAAI,MAAM,CAUnD"}
package/dist/native.js ADDED
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeFrameProbe = void 0;
4
+ exports.explainMissingNativeModule = explainMissingNativeModule;
5
+ const rn_js_1 = require("./rn.js");
6
+ /**
7
+ * Bridge to the optional `RNPerfFrameMonitor` native module.
8
+ *
9
+ * Everything degrades to "no UI-thread data" rather than throwing: the module
10
+ * is absent in Expo Go, in a build where pods were not reinstalled, and on
11
+ * Android (where the daemon reads frame timings from `adb` instead).
12
+ */
13
+ class NativeFrameProbe {
14
+ module;
15
+ started = false;
16
+ inFlight = false;
17
+ failures = 0;
18
+ /** Attaches to the native module. Returns false when it is unavailable. */
19
+ attach() {
20
+ try {
21
+ const candidate = rn_js_1.NativeModules.RNPerfFrameMonitor;
22
+ if (!candidate || typeof candidate.getMetrics !== 'function')
23
+ return false;
24
+ this.module = candidate;
25
+ return true;
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ start() {
32
+ if (!this.module || this.started)
33
+ return;
34
+ try {
35
+ this.module.start();
36
+ this.started = true;
37
+ }
38
+ catch {
39
+ this.module = undefined;
40
+ }
41
+ }
42
+ /**
43
+ * Reads and resets the native window. Returns `{}` when a read is already
44
+ * outstanding, which happens when the JS thread is blocked — precisely when
45
+ * piling up more bridge calls would make things worse.
46
+ */
47
+ async read() {
48
+ if (!this.module || !this.started || this.inFlight)
49
+ return {};
50
+ this.inFlight = true;
51
+ try {
52
+ const metrics = await this.module.getMetrics();
53
+ this.failures = 0;
54
+ return metrics ?? {};
55
+ }
56
+ catch {
57
+ // Three consecutive failures means something is structurally wrong;
58
+ // stop paying for a bridge call every second to rediscover that.
59
+ this.failures += 1;
60
+ if (this.failures >= 3)
61
+ this.stop();
62
+ return {};
63
+ }
64
+ finally {
65
+ this.inFlight = false;
66
+ }
67
+ }
68
+ stop() {
69
+ if (!this.module)
70
+ return;
71
+ try {
72
+ if (this.started)
73
+ this.module.stop();
74
+ }
75
+ catch {
76
+ // The module is going away regardless.
77
+ }
78
+ this.started = false;
79
+ this.module = undefined;
80
+ }
81
+ get available() {
82
+ return Boolean(this.module);
83
+ }
84
+ }
85
+ exports.NativeFrameProbe = NativeFrameProbe;
86
+ /** Why UI-thread frame data is unavailable, phrased for a dev-time warning. */
87
+ function explainMissingNativeModule() {
88
+ const platform = rn_js_1.Platform.OS;
89
+ if ((0, rn_js_1.isExpoRuntime)()) {
90
+ return 'UI-thread FPS needs the rnperf native module, which Expo Go cannot load. Run `npx expo prebuild` and use a development build.';
91
+ }
92
+ if (platform === 'android') {
93
+ return 'UI-thread FPS needs the rnperf native module. Rebuild the app (`npx react-native run-android`) so autolinking picks it up. Until then, connect the device over adb and the daemon will read frame timings itself.';
94
+ }
95
+ return 'UI-thread FPS needs the rnperf native module. Run `cd ios && pod install`, then rebuild the app.';
96
+ }
97
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":";;;AAuGA,gEAUC;AAjHD,mCAAiE;AA4BjE;;;;;;GAMG;AACH,MAAa,gBAAgB;IACnB,MAAM,CAAgB;IACtB,OAAO,GAAG,KAAK,CAAC;IAChB,QAAQ,GAAG,KAAK,CAAC;IACjB,QAAQ,GAAG,CAAC,CAAC;IAErB,2EAA2E;IAC3E,MAAM;QACJ,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,qBAAa,CAAC,kBAA8C,CAAC;YAC/E,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zB,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,OAAO;gBAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,uCAAuC;QACzC,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF;AAjED,4CAiEC;AAED,+EAA+E;AAC/E,SAAgB,0BAA0B;IACxC,MAAM,QAAQ,GAAG,gBAAQ,CAAC,EAAE,CAAC;IAE7B,IAAI,IAAA,qBAAa,GAAE,EAAE,CAAC;QACpB,OAAO,+HAA+H,CAAC;IACzI,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,mNAAmN,CAAC;IAC7N,CAAC;IACD,OAAO,kGAAkG,CAAC;AAC5G,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Runtime probes. Every one of these degrades to "no data" rather than
3
+ * throwing: the SDK runs inside someone else's app and must never be the
4
+ * reason it crashes.
5
+ */
6
+ /**
7
+ * Counts animation frames the JS thread actually serviced. React Native drives
8
+ * `requestAnimationFrame` from the JS thread, so a shortfall here is a direct
9
+ * measure of JS thread saturation — the thing that makes touch handling feel
10
+ * sticky even when the UI thread is fine.
11
+ */
12
+ export declare class FpsProbe {
13
+ private frames;
14
+ private windowStart;
15
+ private running;
16
+ private rafId;
17
+ start(): void;
18
+ /** Frames per second since the last read, then resets the window. */
19
+ read(): number | undefined;
20
+ stop(): void;
21
+ }
22
+ /**
23
+ * Measures how late a fixed-period timer actually fires. Drift is time the JS
24
+ * thread spent inside one synchronous block, which is what users experience as
25
+ * a freeze. FPS alone cannot distinguish "steadily slow" from "fine, then a
26
+ * 400ms lockup" — this can.
27
+ */
28
+ export declare class StallProbe {
29
+ private timer;
30
+ private expected;
31
+ private maxStall;
32
+ private stallCount;
33
+ private readonly periodMs;
34
+ private readonly thresholdMs;
35
+ constructor(periodMs?: number, thresholdMs?: number);
36
+ start(): void;
37
+ read(): {
38
+ jsStallMaxMs: number;
39
+ jsStallCount: number;
40
+ };
41
+ stop(): void;
42
+ }
43
+ /** Hermes exposes allocator stats; JSC and V8 expose `performance.memory`. */
44
+ export declare function readJsHeap(): {
45
+ jsHeapMB?: number;
46
+ jsHeapTotalMB?: number;
47
+ };
48
+ export declare function isHermes(): boolean;
49
+ /**
50
+ * Counts calls crossing the legacy bridge by installing MessageQueue's spy
51
+ * hook on the live bridge instance. Under the new architecture most calls are
52
+ * synchronous JSI and never appear here, so a zero reading means "nothing on
53
+ * the bridge", not "nothing happening".
54
+ */
55
+ export declare class BridgeProbe {
56
+ private calls;
57
+ private installed;
58
+ start(): boolean;
59
+ read(): number | undefined;
60
+ stop(): void;
61
+ }
62
+ export declare function now(): number;
63
+ /**
64
+ * Metro resolves `require` at build time, so these deep imports have to go
65
+ * through an indirect lookup to stay optional — the SDK must not hard-fail in
66
+ * an app that has tree-shaken or renamed an internal module.
67
+ */
68
+ //# sourceMappingURL=probes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../src/probes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAuB;IAEpC,KAAK,IAAI,IAAI;IAab,qEAAqE;IACrE,IAAI,IAAI,MAAM,GAAG,SAAS;IAW1B,IAAI,IAAI,IAAI;CAOb;AAID;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ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