@g9tm/app-diagnostic-lynx 0.2.1 → 0.2.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.
@@ -23,6 +23,7 @@ with the command that proved it and the date. Nothing here is claimed from a Nod
23
23
  | Voice | two notes (permission granted beforehand) | two `.m4a` of ~79 KB |
24
24
  | Window screenshot | the gesture's shot | a 363 KB JPEG of the window, the map included |
25
25
  | `sendRange` on the host's client | a whole tester report through a local fake gateway over HTTPS (self-signed, trusted only by the host's dev-host trust) | 10 PUTs of 64 KB read natively; a dropped answer → retry → 416 → resumed at the gateway's offset; the hash matched at finalize. The host hook `httpClient` is what made the TLS trust apply |
26
+ | N-AD-03 — a pinch on the map with the gesture armed (DOOGEE, 2026-11-13, a tester report) | 8 real two-finger pinches on the map in the «any screen» mode | 7.0.24 HELD the first finger and replayed late: at the 350 ms limit MapLibre never began its scale, so the pinch failed now and then. The hold now never applies over an excluded surface, in any mode (`TouchCore`: `!downExcluded`); after it 8/8 pinches zoomed and MapLibre's `scale-begin` is in the app log |
26
27
 
27
28
  ## Pending
28
29
 
@@ -30,4 +31,3 @@ with the command that proved it and the date. Nothing here is claimed from a Nod
30
31
  | --- | --- | --- |
31
32
  | **N-AD-01b** The same on a phone (the gesture with real fingers, the microphone with a real voice) | An emulator injects touches into the decor view and records silence | A Didban session on a lab phone (P7.7) |
32
33
  | **N-AD-02** iOS (`ios/src`) | Not written yet in this package: the app's `AGMedia.mm` / `AGFiles.mm` move here with neutral names | A build on the Mac through a Didban session (the Mac is reserved for Didban) |
33
- | **N-AD-03** The gesture's pinch replay on a real map (MapLibre) | A replay a slop late must still zoom | Emulator with two-finger input, then a phone |
package/README.md CHANGED
@@ -10,7 +10,7 @@ device, with no product name anywhere.
10
10
  | `startVoice` / `stopVoice` | a spoken note as AAC `.m4a`; the microphone permission is asked at the first note |
11
11
  | `screenshot` | the window as the user sees it, a map's surface included, as JPEG |
12
12
  | `sendRange` | one HTTP request whose body is a byte range of a file, read natively (the resumable report upload) |
13
- | `watchTouches` | the tester gesture: multi-finger taps and first touches as the global event `g9:diagnostic-touch`; with `consume`, a two-finger touch is held away from the views and replayed when it is a pinch or a pan (E-20) |
13
+ | `watchTouches` | the tester gesture: multi-finger taps (with the fingers' midpoint `cx`, `cy`) and first touches as the global event `g9:diagnostic-touch`; with `touches`, also a `seq` trace of every touch that could have been a tap (why it was or was not one); with `consume`, a two-finger touch is held away from the views and replayed when it is a pinch or a pan (E-20). A finger «moved» only when it left its own landing point |
14
14
 
15
15
  The contract (methods, envelopes, error codes, the event) is `types/g9-app-diagnostic-module.d.ts`; `npm run codegen`-style
16
16
  regeneration is `lynx-autolink-codegen` then `node scripts/android-bridge-types.mjs --fix`.
@@ -100,7 +100,10 @@ internal object TouchWatcher {
100
100
  val w = root.width.toFloat()
101
101
  val h = root.height.toFloat()
102
102
  if (w <= 0f || h <= 0f) return
103
- val json = JSONObject().put("type", e.type).put("fingers", e.fingers).put("x", (e.x / w).toDouble()).put("y", (e.y / h).toDouble()).put("excluded", e.excluded)
103
+ val json =
104
+ JSONObject().put("type", e.type).put("fingers", e.fingers).put("x", (e.x / w).toDouble()).put("y", (e.y / h).toDouble())
105
+ .put("cx", (e.cx / w).toDouble()).put("cy", (e.cy / h).toDouble()).put("excluded", e.excluded)
106
+ e.info?.let { json.put("info", JSONObject(it)) }
104
107
  G9AppDiagnosticHost.emit(EVENT, json.toString())
105
108
  }
106
109
  }
@@ -15,7 +15,18 @@ package com.g9tm.appdiagnostic.core
15
15
  * button un-presses; a click is on UP) and the stream is HELD. Lifted as a tap: the views saw only a cancelled touch. Moved
16
16
  * past the slop or held longer than a tap: a pinch or a pan — the held stream is REPLAYED (a fresh DOWN and POINTER_DOWNs
17
17
  * where the fingers are now) and the rest flows through, so pinch-zoom still works, a slop late. A second finger that comes
18
- * late passes untouched. Over an excluded surface (the map, in its mode) nothing is held: that surface stays native.
18
+ * late passes untouched. Over an excluded surface (the map) nothing is held, in any mode: that surface stays native.
19
+ *
20
+ * EVERY FINGER AGAINST ITS OWN LANDING POINT (2026-11-15). A tap «moved» when any finger left ITS OWN landing point by
21
+ * more than the slop. Until then only `pointers[0]` was compared, with the FIRST finger's landing point: when the first
22
+ * finger lifted first, index 0 became the second finger — a finger's width away — and the next MOVE dropped the tap (a
23
+ * two-finger double tap failed about every other time on a DOOGEE). A tap reports the fingers' midpoint at the most
24
+ * fingers (`cx`, `cy`) beside the first finger (`x`, `y`): which finger lands first changes from tap to tap, the midpoint
25
+ * does not.
26
+ *
27
+ * THE TRACE. With [touches] on, every touch that could have been a tap (two fingers or more, or a short one-finger
28
+ * touch) ends with one `seq` report: its fingers, time, how far a finger moved, whether it was held and why it was or was
29
+ * not a tap — the field record of a gesture that «does not work».
19
30
  */
20
31
  class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
21
32
  companion object {
@@ -39,8 +50,20 @@ class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
39
50
  /** One event: its masked action (the MotionEvent constants) and every pointer down in it. */
40
51
  data class Sample(val action: Int, val pointers: List<Pointer>)
41
52
 
42
- /** What the watcher tells JS. */
43
- data class Emit(val type: String, val fingers: Int, val x: Float, val y: Float, val excluded: Boolean)
53
+ /**
54
+ * What the watcher tells JS. [x], [y]: the first finger; [cx], [cy]: the fingers' midpoint at the most fingers (a tap);
55
+ * [info]: a `seq` report's fields.
56
+ */
57
+ data class Emit(
58
+ val type: String,
59
+ val fingers: Int,
60
+ val x: Float,
61
+ val y: Float,
62
+ val excluded: Boolean,
63
+ val cx: Float = x,
64
+ val cy: Float = y,
65
+ val info: Map<String, Any>? = null,
66
+ )
44
67
 
45
68
  enum class Verdict {
46
69
  /** The views get the event as it is. */
@@ -75,6 +98,16 @@ class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
75
98
  private var downY = 0f
76
99
  private var downExcluded = false
77
100
 
101
+ // This touch's record: every finger's own landing point, the midpoint at the most fingers, and the trace's facts.
102
+ private val starts = HashMap<Int, Pair<Float, Float>>()
103
+ private var midX = 0f
104
+ private var midY = 0f
105
+ private var maxMovePx = 0f
106
+ private var secondAtMs = -1L
107
+ private var firstUpAtMs = -1L
108
+ private var firstOnlyMoved = false
109
+ private var everHeld = false
110
+
78
111
  private var phase = Phase.IDLE
79
112
  private val held = HashMap<Int, Pair<Float, Float>>()
80
113
 
@@ -103,23 +136,79 @@ class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
103
136
  downX = first?.x ?: 0f
104
137
  downY = first?.y ?: 0f
105
138
  downExcluded = runCatching { isExcluded(downX, downY) }.getOrDefault(false)
139
+ starts.clear()
140
+ for (p in s.pointers) starts[p.id] = p.x to p.y
141
+ midX = downX
142
+ midY = downY
143
+ maxMovePx = 0f
144
+ secondAtMs = -1L
145
+ firstUpAtMs = -1L
146
+ firstOnlyMoved = false
147
+ everHeld = false
106
148
  if (touches) emits += Emit("down", 1, downX, downY, false)
107
149
  }
108
- POINTER_DOWN -> maxPointers = maxOf(maxPointers, s.pointers.size)
109
- MOVE -> if (!moved && first != null && (Math.abs(first.x - downX) > slopPx || Math.abs(first.y - downY) > slopPx)) moved = true
110
- UP -> {
111
- if (taps && !moved && maxPointers >= 2 && clock() - downAt <= maxTapMsFor(maxPointers)) {
112
- emits += Emit("tap", maxPointers, downX, downY, downExcluded)
150
+ POINTER_DOWN -> {
151
+ for (p in s.pointers) starts.putIfAbsent(p.id, p.x to p.y)
152
+ if (secondAtMs < 0 && s.pointers.size >= 2) secondAtMs = clock() - downAt
153
+ if (s.pointers.size > maxPointers) {
154
+ maxPointers = s.pointers.size
155
+ midX = s.pointers.map { it.x }.average().toFloat()
156
+ midY = s.pointers.map { it.y }.average().toFloat()
157
+ }
158
+ }
159
+ MOVE -> {
160
+ for (p in s.pointers) {
161
+ val start = starts[p.id] ?: continue
162
+ val d = maxOf(Math.abs(p.x - start.first), Math.abs(p.y - start.second))
163
+ if (d > maxMovePx) maxMovePx = d
164
+ if (d > slopPx) moved = true
113
165
  }
166
+ // The rule before 2026-11-15 (index 0 against the first finger's landing point), kept for the trace only.
167
+ if (!firstOnlyMoved && first != null && (Math.abs(first.x - downX) > slopPx || Math.abs(first.y - downY) > slopPx)) firstOnlyMoved = true
168
+ }
169
+ POINTER_UP -> if (firstUpAtMs < 0) firstUpAtMs = clock() - downAt
170
+ UP -> {
171
+ val ms = clock() - downAt
172
+ val tap = taps && !moved && maxPointers >= 2 && ms <= maxTapMsFor(maxPointers)
173
+ if (tap) emits += Emit("tap", maxPointers, downX, downY, downExcluded, midX, midY)
174
+ if (touches) trace(emits, ms, tap, cancelled = false)
114
175
  maxPointers = 0
115
176
  }
116
177
  CANCEL -> {
178
+ if (touches) trace(emits, clock() - downAt, tap = false, cancelled = true)
117
179
  maxPointers = 0
118
180
  moved = true
119
181
  }
120
182
  }
121
183
  }
122
184
 
185
+ /** The `seq` report of a touch that could have been a tap (two fingers or more, or a short one-finger touch). */
186
+ private fun trace(emits: MutableList<Emit>, ms: Long, tap: Boolean, cancelled: Boolean) {
187
+ if (maxPointers < 2 && (ms > 600 || moved)) return
188
+ val why =
189
+ when {
190
+ tap -> "tap"
191
+ cancelled -> "cancelled"
192
+ maxPointers < 2 -> "one-finger"
193
+ moved -> "moved"
194
+ ms > maxTapMsFor(maxPointers) -> "too-long"
195
+ !taps -> "not-watching"
196
+ else -> "other"
197
+ }
198
+ val info =
199
+ mapOf(
200
+ "ms" to ms,
201
+ "secondMs" to secondAtMs,
202
+ "firstUpMs" to firstUpAtMs,
203
+ "movePx" to Math.round(maxMovePx),
204
+ "slopPx" to Math.round(slopPx),
205
+ "held" to everHeld,
206
+ "oldRuleMoved" to firstOnlyMoved,
207
+ "why" to why,
208
+ )
209
+ emits += Emit("seq", maxPointers, downX, downY, downExcluded, midX, midY, info)
210
+ }
211
+
123
212
  private fun intercept(s: Sample): Verdict =
124
213
  when (s.action) {
125
214
  DOWN -> {
@@ -134,9 +223,15 @@ class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
134
223
  Verdict.CONSUME
135
224
  }
136
225
  phase != Phase.IDLE -> Verdict.PASS
137
- s.pointers.size == 2 && !moved && clock() - downAt <= SECOND_FINGER_WINDOW_MS && !(excludeSurfaces && downExcluded) -> {
226
+ // Never over an excluded surface, in ANY mode (two tester reports — «two-finger zoom
227
+ // comes and goes» with tester mode on): a held pinch reached the map only as a REPLAY — late (110–360 ms), its
228
+ // first moves swallowed — and when the hold ran to its 350 ms limit MapLibre never began the scale (device trace,
229
+ // 2026-11-13). Over the map the gesture is only OBSERVED: the two-finger double tap still opens the tester (in
230
+ // the modes that count it there); the map also takes it as its own two-finger tap.
231
+ s.pointers.size == 2 && !moved && clock() - downAt <= SECOND_FINGER_WINDOW_MS && !downExcluded -> {
138
232
  remember(s)
139
233
  phase = Phase.HOLDING
234
+ everHeld = true
140
235
  Verdict.CANCEL_THEN_CONSUME
141
236
  }
142
237
  else -> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/app-diagnostic-lynx",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Lynx native half of @g9tm/app-diagnostic: the app's own window as an MP4, a spoken note, the window screenshot, a file range sent natively, and the tester gesture (observed or consumed). No product names: the host configures everything.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -32,7 +32,7 @@
32
32
  "check:android-module": "node scripts/run-gradle.mjs -p android-check build"
33
33
  },
34
34
  "peerDependencies": {
35
- "@g9tm/app-diagnostic": "^0.2.1"
35
+ "@g9tm/app-diagnostic": "^0.2.2"
36
36
  },
37
37
  "license": "MIT",
38
38
  "engines": { "node": ">=22.6" }
package/src/index.ts CHANGED
@@ -50,14 +50,23 @@ export interface DiagnosticRecording {
50
50
  readonly capped?: boolean;
51
51
  }
52
52
 
53
- /** One touch the watcher reports (x, y: fractions of the window). */
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
+ */
54
57
  export interface DiagnosticTouchEvent {
55
- readonly type: 'tap' | 'down';
58
+ readonly type: 'tap' | 'down' | 'seq';
56
59
  readonly fingers: number;
60
+ /** The first finger. */
57
61
  readonly x: number;
58
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;
59
66
  /** On a surface the host excludes (its map). */
60
67
  readonly excluded: boolean;
68
+ /** A `seq` trace's facts (ms, secondMs, firstUpMs, movePx, slopPx, held, why, …). */
69
+ readonly info?: Readonly<Record<string, unknown>>;
61
70
  }
62
71
 
63
72
  /** One remote touch: points in dp from the window's top-left. */
@@ -145,8 +154,17 @@ export function onDiagnosticTouch(events: GlobalEvents, listener: (event: Diagno
145
154
  const raw = args[0];
146
155
  try {
147
156
  const e = (typeof raw === 'string' ? JSON.parse(raw) : raw) as Partial<DiagnosticTouchEvent>;
148
- if ((e.type === 'tap' || e.type === 'down') && typeof e.fingers === 'number' && typeof e.x === 'number' && typeof e.y === 'number') {
149
- listener({ type: e.type, fingers: e.fingers, x: e.x, y: e.y, excluded: e.excluded === true });
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
+ });
150
168
  }
151
169
  } catch {
152
170
  // not ours
@@ -14,7 +14,10 @@
14
14
  //
15
15
  // Events (global, JSON text): `g9:diagnostic-touch` — {type: 'tap', fingers, x, y, excluded} for a completed multi-finger
16
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).
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.
18
21
 
19
22
  /** @lynxmodule */
20
23
  export declare class G9AppDiagnosticModule {