@g9tm/app-diagnostic-lynx 0.3.0 → 0.3.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/src/index.ts CHANGED
@@ -1,175 +1,175 @@
1
- // @g9tm/app-diagnostic-lynx — the native half of @g9tm/app-diagnostic on Lynx: the `G9AppDiagnosticModule` native module
2
- // (Android android/, iOS ios/, Autolink) turned into promises, and the core's platform interfaces built on it. Runs on
3
- // Lynx's background thread: ES2019, no timers of its own. The module's envelopes and error codes:
4
- // types/g9-app-diagnostic-module.d.ts.
5
- import type { DiagnosticSendRange, RangeRequest, RangeResponse, Unsubscribe } from '@g9tm/app-diagnostic';
6
- import { type G9AppDiagnosticModuleSpec, requireG9AppDiagnosticModule } from '../generated/G9AppDiagnosticModule.ts';
7
-
8
- /** The module's shape, for a host that calls it through its own bridge layer (its own error type). */
9
- export type { G9AppDiagnosticModuleSpec };
10
-
11
- /** Error codes of the module contract. Public API: add, never rename or repurpose. */
12
- export const DiagnosticNativeErrorCode = {
13
- Busy: 'busy',
14
- Permission: 'permission',
15
- Unavailable: 'unavailable',
16
- Invalid: 'invalid',
17
- NotFound: 'not-found',
18
- Network: 'network',
19
- Timeout: 'timeout',
20
- Io: 'io',
21
- } as const;
22
-
23
- /** A native error with the contract's code. */
24
- export class DiagnosticNativeError extends Error {
25
- readonly code: string;
26
-
27
- constructor(code: string, message: string) {
28
- super(message);
29
- this.name = 'DiagnosticNativeError';
30
- this.code = code;
31
- }
32
- }
33
-
34
- export interface DiagnosticNativeCapabilities {
35
- readonly version: string;
36
- readonly platform: 'android' | 'ios' | string;
37
- readonly screen: boolean;
38
- readonly voice: boolean;
39
- /** The gesture can be held away from the views (E-20). */
40
- readonly consume: boolean;
41
- }
42
-
43
- export interface DiagnosticRecording {
44
- readonly path: string;
45
- readonly bytes: number;
46
- readonly durationMs: number;
47
- readonly width?: number;
48
- readonly height?: number;
49
- /** The 10-minute cap ended it. */
50
- readonly capped?: boolean;
51
- }
52
-
53
- /**
54
- * One touch the watcher reports (fractions of the window). `tap`: a completed multi-finger tap; `down`: a first finger
55
- * down; `seq` (only while `touches` is on): the trace of a touch that could have been a tap — why it was or was not one.
56
- */
57
- export interface DiagnosticTouchEvent {
58
- readonly type: 'tap' | 'down' | 'seq';
59
- readonly fingers: number;
60
- /** The first finger. */
61
- readonly x: number;
62
- readonly y: number;
63
- /** The fingers' midpoint at the most fingers (a tap, a trace); the first finger otherwise. */
64
- readonly cx: number;
65
- readonly cy: number;
66
- /** On a surface the host excludes (its map). */
67
- readonly excluded: boolean;
68
- /** A `seq` trace's facts (ms, secondMs, firstUpMs, movePx, slopPx, held, why, …). */
69
- readonly info?: Readonly<Record<string, unknown>>;
70
- }
71
-
72
- /** One remote touch: points in dp from the window's top-left. */
73
- export interface DiagnosticTouch {
74
- readonly kind: 'tap' | 'longPress' | 'drag';
75
- readonly x: number;
76
- readonly y: number;
77
- readonly toX?: number;
78
- readonly toY?: number;
79
- readonly durationMs?: number;
80
- }
81
-
82
- export interface DiagnosticWatchOptions {
83
- /** Report completed multi-finger taps (the gesture). */
84
- readonly taps: boolean;
85
- /** Report every first finger down (a recording's timeline). */
86
- readonly touches: boolean;
87
- /** Hold a two-finger touch away from the views so the gesture never also presses what is under it. */
88
- readonly consume: boolean;
89
- /** Never hold over an excluded surface (the «except the map» mode). */
90
- readonly excludeSurfaces: boolean;
91
- }
92
-
93
- /** The global events a Lynx page receives (`lynx.getJSModule('GlobalEventEmitter')`), or a test's stand-in. */
94
- export interface GlobalEvents {
95
- addListener(name: string, listener: (...args: unknown[]) => void): void;
96
- removeListener(name: string, listener: (...args: unknown[]) => void): void;
97
- }
98
-
99
- export const TOUCH_EVENT = 'g9:diagnostic-touch';
100
-
101
- type Reply = Record<string, unknown>;
102
-
103
- function unwrap<T>(reply: Reply): T {
104
- if (reply && reply.ok === true) return reply.value as T;
105
- const error = (reply?.error ?? {}) as { code?: unknown; message?: unknown };
106
- throw new DiagnosticNativeError(typeof error.code === 'string' ? error.code : DiagnosticNativeErrorCode.Io, typeof error.message === 'string' ? error.message : 'native call failed');
107
- }
108
-
109
- function call<T>(invoke: (callback: (reply: Reply) => void) => void): Promise<T> {
110
- return new Promise<T>((resolve, reject) => {
111
- try {
112
- invoke((reply) => {
113
- try {
114
- resolve(unwrap<T>(reply));
115
- } catch (error) {
116
- reject(error);
117
- }
118
- });
119
- } catch (error) {
120
- reject(new DiagnosticNativeError(DiagnosticNativeErrorCode.Unavailable, String((error as Error)?.message ?? error)));
121
- }
122
- });
123
- }
124
-
125
- /** The module as promises. `module` defaults to the registered native module (tests pass a fake with the same shape). */
126
- export function createDiagnosticNative(module: G9AppDiagnosticModuleSpec = requireG9AppDiagnosticModule()) {
127
- return {
128
- capabilities: () => call<DiagnosticNativeCapabilities>((cb) => module.capabilities(cb)),
129
- state: () => call<{ readonly screen: boolean; readonly voice: boolean }>((cb) => module.state(cb)),
130
- startScreen: (dir: string, maxFps = 10) => call<null>((cb) => module.startScreen(dir, maxFps, cb)).then(() => undefined),
131
- stopScreen: () => call<DiagnosticRecording | null>((cb) => module.stopScreen(cb)),
132
- startVoice: (dir: string) => call<null>((cb) => module.startVoice(dir, cb)).then(() => undefined),
133
- stopVoice: () => call<DiagnosticRecording | null>((cb) => module.stopVoice(cb)),
134
- watchTouches: (o: DiagnosticWatchOptions) => call<null>((cb) => module.watchTouches(o.taps, o.touches, o.consume, o.excludeSurfaces, cb)).then(() => undefined),
135
- screenshot: (dir: string, maxEdge: number, quality: number) =>
136
- call<{ readonly path: string; readonly width: number; readonly height: number; readonly bytes: number }>((cb) => module.screenshot(dir, maxEdge, quality, cb)),
137
- sendRange: (request: RangeRequest) => call<RangeResponse>((cb) => module.sendRange(JSON.stringify(request), cb)),
138
- /** A real touch for the operator's remote control (E-13): dp from the window's top-left; check the user's consent first. */
139
- touch: (t: DiagnosticTouch) =>
140
- call<{ readonly handled: boolean }>((cb) => module.touch(t.kind, t.x, t.y, t.toX ?? t.x, t.toY ?? t.y, t.durationMs ?? (t.kind === 'longPress' ? 800 : t.kind === 'drag' ? 300 : 50), cb)),
141
- };
142
- }
143
-
144
- export type DiagnosticNative = ReturnType<typeof createDiagnosticNative>;
145
-
146
- /** The core's `DiagnosticSendRange` (the tester report's resumable PUT) on the native module. */
147
- export function nativeSendRange(native: Pick<DiagnosticNative, 'sendRange'>): DiagnosticSendRange {
148
- return (request) => native.sendRange(request);
149
- }
150
-
151
- /** The watcher's events, parsed; a malformed one is dropped. */
152
- export function onDiagnosticTouch(events: GlobalEvents, listener: (event: DiagnosticTouchEvent) => void): Unsubscribe {
153
- const handler = (...args: unknown[]) => {
154
- const raw = args[0];
155
- try {
156
- const e = (typeof raw === 'string' ? JSON.parse(raw) : raw) as Partial<DiagnosticTouchEvent>;
157
- if ((e.type === 'tap' || e.type === 'down' || e.type === 'seq') && typeof e.fingers === 'number' && typeof e.x === 'number' && typeof e.y === 'number') {
158
- listener({
159
- type: e.type,
160
- fingers: e.fingers,
161
- x: e.x,
162
- y: e.y,
163
- cx: typeof e.cx === 'number' ? e.cx : e.x,
164
- cy: typeof e.cy === 'number' ? e.cy : e.y,
165
- excluded: e.excluded === true,
166
- ...(e.info && typeof e.info === 'object' ? { info: e.info } : {}),
167
- });
168
- }
169
- } catch {
170
- // not ours
171
- }
172
- };
173
- events.addListener(TOUCH_EVENT, handler);
174
- return () => events.removeListener(TOUCH_EVENT, handler);
175
- }
1
+ // @g9tm/app-diagnostic-lynx — the native half of @g9tm/app-diagnostic on Lynx: the `G9AppDiagnosticModule` native module
2
+ // (Android android/, iOS ios/, Autolink) turned into promises, and the core's platform interfaces built on it. Runs on
3
+ // Lynx's background thread: ES2019, no timers of its own. The module's envelopes and error codes:
4
+ // types/g9-app-diagnostic-module.d.ts.
5
+ import type { DiagnosticSendRange, RangeRequest, RangeResponse, Unsubscribe } from '@g9tm/app-diagnostic';
6
+ import { type G9AppDiagnosticModuleSpec, requireG9AppDiagnosticModule } from '../generated/G9AppDiagnosticModule.ts';
7
+
8
+ /** The module's shape, for a host that calls it through its own bridge layer (its own error type). */
9
+ export type { G9AppDiagnosticModuleSpec };
10
+
11
+ /** Error codes of the module contract. Public API: add, never rename or repurpose. */
12
+ export const DiagnosticNativeErrorCode = {
13
+ Busy: 'busy',
14
+ Permission: 'permission',
15
+ Unavailable: 'unavailable',
16
+ Invalid: 'invalid',
17
+ NotFound: 'not-found',
18
+ Network: 'network',
19
+ Timeout: 'timeout',
20
+ Io: 'io',
21
+ } as const;
22
+
23
+ /** A native error with the contract's code. */
24
+ export class DiagnosticNativeError extends Error {
25
+ readonly code: string;
26
+
27
+ constructor(code: string, message: string) {
28
+ super(message);
29
+ this.name = 'DiagnosticNativeError';
30
+ this.code = code;
31
+ }
32
+ }
33
+
34
+ export interface DiagnosticNativeCapabilities {
35
+ readonly version: string;
36
+ readonly platform: 'android' | 'ios' | string;
37
+ readonly screen: boolean;
38
+ readonly voice: boolean;
39
+ /** The gesture can be held away from the views (E-20). */
40
+ readonly consume: boolean;
41
+ }
42
+
43
+ export interface DiagnosticRecording {
44
+ readonly path: string;
45
+ readonly bytes: number;
46
+ readonly durationMs: number;
47
+ readonly width?: number;
48
+ readonly height?: number;
49
+ /** The 10-minute cap ended it. */
50
+ readonly capped?: boolean;
51
+ }
52
+
53
+ /**
54
+ * One touch the watcher reports (fractions of the window). `tap`: a completed multi-finger tap; `down`: a first finger
55
+ * down; `seq` (only while `touches` is on): the trace of a touch that could have been a tap — why it was or was not one.
56
+ */
57
+ export interface DiagnosticTouchEvent {
58
+ readonly type: 'tap' | 'down' | 'seq';
59
+ readonly fingers: number;
60
+ /** The first finger. */
61
+ readonly x: number;
62
+ readonly y: number;
63
+ /** The fingers' midpoint at the most fingers (a tap, a trace); the first finger otherwise. */
64
+ readonly cx: number;
65
+ readonly cy: number;
66
+ /** On a surface the host excludes (its map). */
67
+ readonly excluded: boolean;
68
+ /** A `seq` trace's facts (ms, secondMs, firstUpMs, movePx, slopPx, held, why, …). */
69
+ readonly info?: Readonly<Record<string, unknown>>;
70
+ }
71
+
72
+ /** One remote touch: points in dp from the window's top-left. */
73
+ export interface DiagnosticTouch {
74
+ readonly kind: 'tap' | 'longPress' | 'drag';
75
+ readonly x: number;
76
+ readonly y: number;
77
+ readonly toX?: number;
78
+ readonly toY?: number;
79
+ readonly durationMs?: number;
80
+ }
81
+
82
+ export interface DiagnosticWatchOptions {
83
+ /** Report completed multi-finger taps (the gesture). */
84
+ readonly taps: boolean;
85
+ /** Report every first finger down (a recording's timeline). */
86
+ readonly touches: boolean;
87
+ /** Hold a two-finger touch away from the views so the gesture never also presses what is under it. */
88
+ readonly consume: boolean;
89
+ /** Never hold over an excluded surface (the «except the map» mode). */
90
+ readonly excludeSurfaces: boolean;
91
+ }
92
+
93
+ /** The global events a Lynx page receives (`lynx.getJSModule('GlobalEventEmitter')`), or a test's stand-in. */
94
+ export interface GlobalEvents {
95
+ addListener(name: string, listener: (...args: unknown[]) => void): void;
96
+ removeListener(name: string, listener: (...args: unknown[]) => void): void;
97
+ }
98
+
99
+ export const TOUCH_EVENT = 'g9:diagnostic-touch';
100
+
101
+ type Reply = Record<string, unknown>;
102
+
103
+ function unwrap<T>(reply: Reply): T {
104
+ if (reply && reply.ok === true) return reply.value as T;
105
+ const error = (reply?.error ?? {}) as { code?: unknown; message?: unknown };
106
+ throw new DiagnosticNativeError(typeof error.code === 'string' ? error.code : DiagnosticNativeErrorCode.Io, typeof error.message === 'string' ? error.message : 'native call failed');
107
+ }
108
+
109
+ function call<T>(invoke: (callback: (reply: Reply) => void) => void): Promise<T> {
110
+ return new Promise<T>((resolve, reject) => {
111
+ try {
112
+ invoke((reply) => {
113
+ try {
114
+ resolve(unwrap<T>(reply));
115
+ } catch (error) {
116
+ reject(error);
117
+ }
118
+ });
119
+ } catch (error) {
120
+ reject(new DiagnosticNativeError(DiagnosticNativeErrorCode.Unavailable, String((error as Error)?.message ?? error)));
121
+ }
122
+ });
123
+ }
124
+
125
+ /** The module as promises. `module` defaults to the registered native module (tests pass a fake with the same shape). */
126
+ export function createDiagnosticNative(module: G9AppDiagnosticModuleSpec = requireG9AppDiagnosticModule()) {
127
+ return {
128
+ capabilities: () => call<DiagnosticNativeCapabilities>((cb) => module.capabilities(cb)),
129
+ state: () => call<{ readonly screen: boolean; readonly voice: boolean }>((cb) => module.state(cb)),
130
+ startScreen: (dir: string, maxFps = 10) => call<null>((cb) => module.startScreen(dir, maxFps, cb)).then(() => undefined),
131
+ stopScreen: () => call<DiagnosticRecording | null>((cb) => module.stopScreen(cb)),
132
+ startVoice: (dir: string) => call<null>((cb) => module.startVoice(dir, cb)).then(() => undefined),
133
+ stopVoice: () => call<DiagnosticRecording | null>((cb) => module.stopVoice(cb)),
134
+ watchTouches: (o: DiagnosticWatchOptions) => call<null>((cb) => module.watchTouches(o.taps, o.touches, o.consume, o.excludeSurfaces, cb)).then(() => undefined),
135
+ screenshot: (dir: string, maxEdge: number, quality: number) =>
136
+ call<{ readonly path: string; readonly width: number; readonly height: number; readonly bytes: number }>((cb) => module.screenshot(dir, maxEdge, quality, cb)),
137
+ sendRange: (request: RangeRequest) => call<RangeResponse>((cb) => module.sendRange(JSON.stringify(request), cb)),
138
+ /** A real touch for the operator's remote control (E-13): dp from the window's top-left; check the user's consent first. */
139
+ touch: (t: DiagnosticTouch) =>
140
+ call<{ readonly handled: boolean }>((cb) => module.touch(t.kind, t.x, t.y, t.toX ?? t.x, t.toY ?? t.y, t.durationMs ?? (t.kind === 'longPress' ? 800 : t.kind === 'drag' ? 300 : 50), cb)),
141
+ };
142
+ }
143
+
144
+ export type DiagnosticNative = ReturnType<typeof createDiagnosticNative>;
145
+
146
+ /** The core's `DiagnosticSendRange` (the tester report's resumable PUT) on the native module. */
147
+ export function nativeSendRange(native: Pick<DiagnosticNative, 'sendRange'>): DiagnosticSendRange {
148
+ return (request) => native.sendRange(request);
149
+ }
150
+
151
+ /** The watcher's events, parsed; a malformed one is dropped. */
152
+ export function onDiagnosticTouch(events: GlobalEvents, listener: (event: DiagnosticTouchEvent) => void): Unsubscribe {
153
+ const handler = (...args: unknown[]) => {
154
+ const raw = args[0];
155
+ try {
156
+ const e = (typeof raw === 'string' ? JSON.parse(raw) : raw) as Partial<DiagnosticTouchEvent>;
157
+ if ((e.type === 'tap' || e.type === 'down' || e.type === 'seq') && typeof e.fingers === 'number' && typeof e.x === 'number' && typeof e.y === 'number') {
158
+ listener({
159
+ type: e.type,
160
+ fingers: e.fingers,
161
+ x: e.x,
162
+ y: e.y,
163
+ cx: typeof e.cx === 'number' ? e.cx : e.x,
164
+ cy: typeof e.cy === 'number' ? e.cy : e.y,
165
+ excluded: e.excluded === true,
166
+ ...(e.info && typeof e.info === 'object' ? { info: e.info } : {}),
167
+ });
168
+ }
169
+ } catch {
170
+ // not ours
171
+ }
172
+ };
173
+ events.addListener(TOUCH_EVENT, handler);
174
+ return () => events.removeListener(TOUCH_EVENT, handler);
175
+ }
@@ -1,60 +1,60 @@
1
- // The native module of @g9tm/app-diagnostic-lynx. The Android/iOS specs and the JS accessor (generated/) follow this
2
- // declaration. Every reply is an envelope `{ ok: true, value } | { ok: false, error: { code, message } }` so the error
3
- // fields survive the bridge.
4
- //
5
- // Error codes (public API — add, never rename or repurpose):
6
- // busy a recorder of that kind is already running
7
- // permission the microphone permission was refused
8
- // unavailable no encoder / microphone / laid-out window
9
- // invalid a folder or file outside the folders the host allows, or a malformed request
10
- // not-found the file to send does not exist
11
- // network the range request failed in transport (any HTTP status is a value, not an error)
12
- // timeout the range request ran past its time limit
13
- // io the platform refused (a capture that failed, no space)
14
- //
15
- // Events (global, JSON text): `g9:diagnostic-touch` — {type: 'tap', fingers, x, y, excluded} for a completed multi-finger
16
- // tap, {type: 'down', fingers: 1, x, y, excluded: false} for a first finger down (only while `touches` is on). x, y are
17
- // fractions of the window; `excluded` = the first finger landed on a surface the host excludes (a map). A tap also
18
- // carries `cx`, `cy`: the fingers' midpoint at the most fingers. While `touches` is on, every touch that could have been a
19
- // tap ends with {type: 'seq', fingers, x, y, cx, cy, excluded, info: {ms, secondMs, firstUpMs, movePx, slopPx, held,
20
- // oldRuleMoved, why}} — why: tap | moved | too-long | one-finger | cancelled | not-watching.
21
-
22
- /** @lynxmodule */
23
- export declare class G9AppDiagnosticModule {
24
- /** `{ version, platform: 'android' | 'ios', screen, voice, consume }`: what this device can record, whether a gesture can be consumed. */
25
- capabilities(callback: (reply: Record<string, unknown>) => void): void;
26
- /** `{ screen, voice }`: which recorder runs now (a recorder outlives a reload of the app's script). */
27
- state(callback: (reply: Record<string, unknown>) => void): void;
28
- /**
29
- * Records the app's OWN window into `<dir>/screen-<ms>.mp4` (H.264, long edge ≤ 960 px, no system consent) at an adaptive
30
- * rate starting at `maxFps` (4-20). Stops itself at 10 minutes and keeps the file for `stopScreen`. Value: null.
31
- */
32
- startScreen(dir: string, maxFps: number, callback: (reply: Record<string, unknown>) => void): void;
33
- /** `{ path, bytes, durationMs, width, height, capped }`, or null when nothing usable was recorded. */
34
- stopScreen(callback: (reply: Record<string, unknown>) => void): void;
35
- /** Records the microphone into `<dir>/voice-<ms>.m4a` (AAC, mono, 44.1 kHz); asks the permission first. Value: null. */
36
- startVoice(dir: string, callback: (reply: Record<string, unknown>) => void): void;
37
- /** `{ path, bytes, durationMs }`, or null. */
38
- stopVoice(callback: (reply: Record<string, unknown>) => void): void;
39
- /**
40
- * The tester gesture's watcher: `taps` reports completed multi-finger taps, `touches` every first finger down, `consume`
41
- * holds a two-finger touch away from the views (cancelled, replayed when it turns out to be a pinch or pan) so the
42
- * gesture never also presses what is under it; `excludeSurfaces` keeps the excluded surfaces native (never held). All
43
- * false = nothing is watched. Value: null.
44
- */
45
- watchTouches(taps: boolean, touches: boolean, consume: boolean, excludeSurfaces: boolean, callback: (reply: Record<string, unknown>) => void): void;
46
- /** The window as the user sees it (the map included), JPEG at `quality` (10-100), long edge ≤ `maxEdge`, into `dir`: `{ path, width, height, bytes }`. */
47
- screenshot(dir: string, maxEdge: number, quality: number, callback: (reply: Record<string, unknown>) => void): void;
48
- /**
49
- * One HTTP request whose body is a byte range of a file, read natively: `{url, method, path, offset, length, contentType,
50
- * headers, timeoutMs}` as JSON. Every HTTP status resolves `{ status, body, headers }`; only a transport failure rejects.
51
- */
52
- sendRange(requestJson: string, callback: (reply: Record<string, unknown>) => void): void;
53
- /**
54
- * A REAL touch for the operator's remote control (the live channel's remote input, E-13; the caller checks the user's
55
- * consent first): `kind` 'tap' | 'longPress' | 'drag', points in dp from the window's top-left, dispatched into the
56
- * window's decor view with real time between DOWN, MOVEs and UP — whatever is on top gets it as it gets a finger.
57
- * `{ handled }`.
58
- */
59
- touch(kind: string, x: number, y: number, toX: number, toY: number, durationMs: number, callback: (reply: Record<string, unknown>) => void): void;
60
- }
1
+ // The native module of @g9tm/app-diagnostic-lynx. The Android/iOS specs and the JS accessor (generated/) follow this
2
+ // declaration. Every reply is an envelope `{ ok: true, value } | { ok: false, error: { code, message } }` so the error
3
+ // fields survive the bridge.
4
+ //
5
+ // Error codes (public API — add, never rename or repurpose):
6
+ // busy a recorder of that kind is already running
7
+ // permission the microphone permission was refused
8
+ // unavailable no encoder / microphone / laid-out window
9
+ // invalid a folder or file outside the folders the host allows, or a malformed request
10
+ // not-found the file to send does not exist
11
+ // network the range request failed in transport (any HTTP status is a value, not an error)
12
+ // timeout the range request ran past its time limit
13
+ // io the platform refused (a capture that failed, no space)
14
+ //
15
+ // Events (global, JSON text): `g9:diagnostic-touch` — {type: 'tap', fingers, x, y, excluded} for a completed multi-finger
16
+ // tap, {type: 'down', fingers: 1, x, y, excluded: false} for a first finger down (only while `touches` is on). x, y are
17
+ // fractions of the window; `excluded` = the first finger landed on a surface the host excludes (a map). A tap also
18
+ // carries `cx`, `cy`: the fingers' midpoint at the most fingers. While `touches` is on, every touch that could have been a
19
+ // tap ends with {type: 'seq', fingers, x, y, cx, cy, excluded, info: {ms, secondMs, firstUpMs, movePx, slopPx, held,
20
+ // oldRuleMoved, why}} — why: tap | moved | too-long | one-finger | cancelled | not-watching.
21
+
22
+ /** @lynxmodule */
23
+ export declare class G9AppDiagnosticModule {
24
+ /** `{ version, platform: 'android' | 'ios', screen, voice, consume }`: what this device can record, whether a gesture can be consumed. */
25
+ capabilities(callback: (reply: Record<string, unknown>) => void): void;
26
+ /** `{ screen, voice }`: which recorder runs now (a recorder outlives a reload of the app's script). */
27
+ state(callback: (reply: Record<string, unknown>) => void): void;
28
+ /**
29
+ * Records the app's OWN window into `<dir>/screen-<ms>.mp4` (H.264, long edge ≤ 960 px, no system consent) at an adaptive
30
+ * rate starting at `maxFps` (4-20). Stops itself at 10 minutes and keeps the file for `stopScreen`. Value: null.
31
+ */
32
+ startScreen(dir: string, maxFps: number, callback: (reply: Record<string, unknown>) => void): void;
33
+ /** `{ path, bytes, durationMs, width, height, capped }`, or null when nothing usable was recorded. */
34
+ stopScreen(callback: (reply: Record<string, unknown>) => void): void;
35
+ /** Records the microphone into `<dir>/voice-<ms>.m4a` (AAC, mono, 44.1 kHz); asks the permission first. Value: null. */
36
+ startVoice(dir: string, callback: (reply: Record<string, unknown>) => void): void;
37
+ /** `{ path, bytes, durationMs }`, or null. */
38
+ stopVoice(callback: (reply: Record<string, unknown>) => void): void;
39
+ /**
40
+ * The tester gesture's watcher: `taps` reports completed multi-finger taps, `touches` every first finger down, `consume`
41
+ * holds a two-finger touch away from the views (cancelled, replayed when it turns out to be a pinch or pan) so the
42
+ * gesture never also presses what is under it; `excludeSurfaces` keeps the excluded surfaces native (never held). All
43
+ * false = nothing is watched. Value: null.
44
+ */
45
+ watchTouches(taps: boolean, touches: boolean, consume: boolean, excludeSurfaces: boolean, callback: (reply: Record<string, unknown>) => void): void;
46
+ /** The window as the user sees it (the map included), JPEG at `quality` (10-100), long edge ≤ `maxEdge`, into `dir`: `{ path, width, height, bytes }`. */
47
+ screenshot(dir: string, maxEdge: number, quality: number, callback: (reply: Record<string, unknown>) => void): void;
48
+ /**
49
+ * One HTTP request whose body is a byte range of a file, read natively: `{url, method, path, offset, length, contentType,
50
+ * headers, timeoutMs}` as JSON. Every HTTP status resolves `{ status, body, headers }`; only a transport failure rejects.
51
+ */
52
+ sendRange(requestJson: string, callback: (reply: Record<string, unknown>) => void): void;
53
+ /**
54
+ * A REAL touch for the operator's remote control (the live channel's remote input, E-13; the caller checks the user's
55
+ * consent first): `kind` 'tap' | 'longPress' | 'drag', points in dp from the window's top-left, dispatched into the
56
+ * window's decor view with real time between DOWN, MOVEs and UP — whatever is on top gets it as it gets a finger.
57
+ * `{ handled }`.
58
+ */
59
+ touch(kind: string, x: number, y: number, toX: number, toY: number, durationMs: number, callback: (reply: Record<string, unknown>) => void): void;
60
+ }