@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.
@@ -1,270 +1,270 @@
1
- package com.g9tm.appdiagnostic.core
2
-
3
- /**
4
- * The tester gesture's decisions, free of Android types so the JVM suite drives them (../../jvm): the TWIN of
5
- * G9AppDiagnostic.Maui TesterGestureService (OnTouch + InterceptDispatch, 2026-10-24) and of the Lynx app's own observer.
6
- *
7
- * OBSERVE. A completed multi-finger tap — all fingers down and up within [MAX_TAP_MS] (350 ms for two, 500 for three), no
8
- * finger moved past the slop — is reported; JS pairs two of them into the gesture (@g9tm/app-diagnostic tester/gesture.ts).
9
- * With [touches], every first finger down is reported too (a recording's timeline). A pinch or a pan moves, so it never
10
- * counts.
11
- *
12
- * CONSUME (E-20). Observed only, the gesture's first finger also pressed whatever was under it (a button, a list row, a
13
- * tree on the map), and the report began over a screen the gesture had just changed (QA, 2026-10-24). With [consume], a
14
- * SECOND finger that lands within [SECOND_FINGER_WINDOW_MS] of the first, unmoved, makes the views get a CANCEL (a pressed
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
- * 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
- * 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) 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».
30
- */
31
- class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
32
- companion object {
33
- const val DOWN = 0
34
- const val UP = 1
35
- const val MOVE = 2
36
- const val CANCEL = 3
37
- const val POINTER_DOWN = 5
38
- const val POINTER_UP = 6
39
-
40
- const val MAX_TAP_MS = 350L
41
- const val MAX_THREE_FINGER_TAP_MS = 500L
42
- const val SECOND_FINGER_WINDOW_MS = 250L
43
-
44
- fun maxTapMsFor(fingers: Int): Long = if (fingers >= 3) MAX_THREE_FINGER_TAP_MS else MAX_TAP_MS
45
- }
46
-
47
- /** One pointer of an event, in window pixels. */
48
- data class Pointer(val id: Int, val x: Float, val y: Float)
49
-
50
- /** One event: its masked action (the MotionEvent constants) and every pointer down in it. */
51
- data class Sample(val action: Int, val pointers: List<Pointer>)
52
-
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
- )
67
-
68
- enum class Verdict {
69
- /** The views get the event as it is. */
70
- PASS,
71
-
72
- /** Held here: the views do not get it. */
73
- CONSUME,
74
-
75
- /** The views get a CANCEL of this event, then nothing (the hold begins). */
76
- CANCEL_THEN_CONSUME,
77
-
78
- /** The views get a fresh DOWN + POINTER_DOWNs at the fingers' current places, then this event (the hold ends). */
79
- REPLAY,
80
- }
81
-
82
- data class Result(val verdict: Verdict, val emits: List<Emit>)
83
-
84
- private enum class Phase { IDLE, HOLDING, RELEASED, PASSING }
85
-
86
- @Volatile var taps = false
87
- @Volatile var touches = false
88
- @Volatile var consume = false
89
- @Volatile var excludeSurfaces = false
90
-
91
- /** Whether a window point is on a surface the host excludes (the map's view). Asked only on a first finger down. */
92
- var isExcluded: (Float, Float) -> Boolean = { _, _ -> false }
93
-
94
- private var downAt = 0L
95
- private var maxPointers = 0
96
- private var moved = false
97
- private var downX = 0f
98
- private var downY = 0f
99
- private var downExcluded = false
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
-
111
- private var phase = Phase.IDLE
112
- private val held = HashMap<Int, Pair<Float, Float>>()
113
-
114
- val watching: Boolean
115
- get() = taps || touches
116
-
117
- /** Every event of the window, in order. Never throws. */
118
- fun onEvent(s: Sample): Result {
119
- if (!watching) {
120
- phase = Phase.IDLE
121
- return Result(Verdict.PASS, emptyList())
122
- }
123
- val emits = ArrayList<Emit>(1)
124
- observe(s, emits)
125
- val verdict = if (taps && consume) intercept(s) else Verdict.PASS
126
- return Result(verdict, emits)
127
- }
128
-
129
- private fun observe(s: Sample, emits: MutableList<Emit>) {
130
- val first = s.pointers.firstOrNull()
131
- when (s.action) {
132
- DOWN -> {
133
- downAt = clock()
134
- maxPointers = 1
135
- moved = false
136
- downX = first?.x ?: 0f
137
- downY = first?.y ?: 0f
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
148
- if (touches) emits += Emit("down", 1, downX, downY, false)
149
- }
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
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)
175
- maxPointers = 0
176
- }
177
- CANCEL -> {
178
- if (touches) trace(emits, clock() - downAt, tap = false, cancelled = true)
179
- maxPointers = 0
180
- moved = true
181
- }
182
- }
183
- }
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
-
212
- private fun intercept(s: Sample): Verdict =
213
- when (s.action) {
214
- DOWN -> {
215
- phase = Phase.IDLE
216
- held.clear()
217
- Verdict.PASS
218
- }
219
- POINTER_DOWN ->
220
- when {
221
- phase == Phase.HOLDING -> {
222
- remember(s)
223
- Verdict.CONSUME
224
- }
225
- phase != Phase.IDLE -> Verdict.PASS
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 -> {
232
- remember(s)
233
- phase = Phase.HOLDING
234
- everHeld = true
235
- Verdict.CANCEL_THEN_CONSUME
236
- }
237
- else -> {
238
- phase = Phase.PASSING
239
- Verdict.PASS
240
- }
241
- }
242
- MOVE ->
243
- if (phase != Phase.HOLDING) {
244
- Verdict.PASS
245
- } else if (anyMoved(s) || clock() - downAt > maxTapMsFor(s.pointers.size)) {
246
- phase = Phase.RELEASED
247
- Verdict.REPLAY
248
- } else {
249
- Verdict.CONSUME
250
- }
251
- POINTER_UP -> if (phase == Phase.HOLDING) Verdict.CONSUME else Verdict.PASS
252
- UP, CANCEL -> {
253
- val wasHeld = phase == Phase.HOLDING
254
- phase = Phase.IDLE
255
- held.clear()
256
- if (wasHeld) Verdict.CONSUME else Verdict.PASS
257
- }
258
- else -> if (phase == Phase.HOLDING) Verdict.CONSUME else Verdict.PASS
259
- }
260
-
261
- private fun remember(s: Sample) {
262
- for (p in s.pointers) held.putIfAbsent(p.id, p.x to p.y)
263
- }
264
-
265
- private fun anyMoved(s: Sample): Boolean =
266
- s.pointers.any { p ->
267
- val start = held[p.id] ?: return@any false
268
- Math.abs(p.x - start.first) > slopPx || Math.abs(p.y - start.second) > slopPx
269
- }
270
- }
1
+ package com.g9tm.appdiagnostic.core
2
+
3
+ /**
4
+ * The tester gesture's decisions, free of Android types so the JVM suite drives them (../../jvm): the TWIN of
5
+ * G9AppDiagnostic.Maui TesterGestureService (OnTouch + InterceptDispatch, 2026-10-24) and of the Lynx app's own observer.
6
+ *
7
+ * OBSERVE. A completed multi-finger tap — all fingers down and up within [MAX_TAP_MS] (350 ms for two, 500 for three), no
8
+ * finger moved past the slop — is reported; JS pairs two of them into the gesture (@g9tm/app-diagnostic tester/gesture.ts).
9
+ * With [touches], every first finger down is reported too (a recording's timeline). A pinch or a pan moves, so it never
10
+ * counts.
11
+ *
12
+ * CONSUME (E-20). Observed only, the gesture's first finger also pressed whatever was under it (a button, a list row, a
13
+ * tree on the map), and the report began over a screen the gesture had just changed (QA, 2026-10-24). With [consume], a
14
+ * SECOND finger that lands within [SECOND_FINGER_WINDOW_MS] of the first, unmoved, makes the views get a CANCEL (a pressed
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
+ * 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
+ * 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) 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».
30
+ */
31
+ class TouchCore(private val slopPx: Float, private val clock: () -> Long) {
32
+ companion object {
33
+ const val DOWN = 0
34
+ const val UP = 1
35
+ const val MOVE = 2
36
+ const val CANCEL = 3
37
+ const val POINTER_DOWN = 5
38
+ const val POINTER_UP = 6
39
+
40
+ const val MAX_TAP_MS = 350L
41
+ const val MAX_THREE_FINGER_TAP_MS = 500L
42
+ const val SECOND_FINGER_WINDOW_MS = 250L
43
+
44
+ fun maxTapMsFor(fingers: Int): Long = if (fingers >= 3) MAX_THREE_FINGER_TAP_MS else MAX_TAP_MS
45
+ }
46
+
47
+ /** One pointer of an event, in window pixels. */
48
+ data class Pointer(val id: Int, val x: Float, val y: Float)
49
+
50
+ /** One event: its masked action (the MotionEvent constants) and every pointer down in it. */
51
+ data class Sample(val action: Int, val pointers: List<Pointer>)
52
+
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
+ )
67
+
68
+ enum class Verdict {
69
+ /** The views get the event as it is. */
70
+ PASS,
71
+
72
+ /** Held here: the views do not get it. */
73
+ CONSUME,
74
+
75
+ /** The views get a CANCEL of this event, then nothing (the hold begins). */
76
+ CANCEL_THEN_CONSUME,
77
+
78
+ /** The views get a fresh DOWN + POINTER_DOWNs at the fingers' current places, then this event (the hold ends). */
79
+ REPLAY,
80
+ }
81
+
82
+ data class Result(val verdict: Verdict, val emits: List<Emit>)
83
+
84
+ private enum class Phase { IDLE, HOLDING, RELEASED, PASSING }
85
+
86
+ @Volatile var taps = false
87
+ @Volatile var touches = false
88
+ @Volatile var consume = false
89
+ @Volatile var excludeSurfaces = false
90
+
91
+ /** Whether a window point is on a surface the host excludes (the map's view). Asked only on a first finger down. */
92
+ var isExcluded: (Float, Float) -> Boolean = { _, _ -> false }
93
+
94
+ private var downAt = 0L
95
+ private var maxPointers = 0
96
+ private var moved = false
97
+ private var downX = 0f
98
+ private var downY = 0f
99
+ private var downExcluded = false
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
+
111
+ private var phase = Phase.IDLE
112
+ private val held = HashMap<Int, Pair<Float, Float>>()
113
+
114
+ val watching: Boolean
115
+ get() = taps || touches
116
+
117
+ /** Every event of the window, in order. Never throws. */
118
+ fun onEvent(s: Sample): Result {
119
+ if (!watching) {
120
+ phase = Phase.IDLE
121
+ return Result(Verdict.PASS, emptyList())
122
+ }
123
+ val emits = ArrayList<Emit>(1)
124
+ observe(s, emits)
125
+ val verdict = if (taps && consume) intercept(s) else Verdict.PASS
126
+ return Result(verdict, emits)
127
+ }
128
+
129
+ private fun observe(s: Sample, emits: MutableList<Emit>) {
130
+ val first = s.pointers.firstOrNull()
131
+ when (s.action) {
132
+ DOWN -> {
133
+ downAt = clock()
134
+ maxPointers = 1
135
+ moved = false
136
+ downX = first?.x ?: 0f
137
+ downY = first?.y ?: 0f
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
148
+ if (touches) emits += Emit("down", 1, downX, downY, false)
149
+ }
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
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)
175
+ maxPointers = 0
176
+ }
177
+ CANCEL -> {
178
+ if (touches) trace(emits, clock() - downAt, tap = false, cancelled = true)
179
+ maxPointers = 0
180
+ moved = true
181
+ }
182
+ }
183
+ }
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
+
212
+ private fun intercept(s: Sample): Verdict =
213
+ when (s.action) {
214
+ DOWN -> {
215
+ phase = Phase.IDLE
216
+ held.clear()
217
+ Verdict.PASS
218
+ }
219
+ POINTER_DOWN ->
220
+ when {
221
+ phase == Phase.HOLDING -> {
222
+ remember(s)
223
+ Verdict.CONSUME
224
+ }
225
+ phase != Phase.IDLE -> Verdict.PASS
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 -> {
232
+ remember(s)
233
+ phase = Phase.HOLDING
234
+ everHeld = true
235
+ Verdict.CANCEL_THEN_CONSUME
236
+ }
237
+ else -> {
238
+ phase = Phase.PASSING
239
+ Verdict.PASS
240
+ }
241
+ }
242
+ MOVE ->
243
+ if (phase != Phase.HOLDING) {
244
+ Verdict.PASS
245
+ } else if (anyMoved(s) || clock() - downAt > maxTapMsFor(s.pointers.size)) {
246
+ phase = Phase.RELEASED
247
+ Verdict.REPLAY
248
+ } else {
249
+ Verdict.CONSUME
250
+ }
251
+ POINTER_UP -> if (phase == Phase.HOLDING) Verdict.CONSUME else Verdict.PASS
252
+ UP, CANCEL -> {
253
+ val wasHeld = phase == Phase.HOLDING
254
+ phase = Phase.IDLE
255
+ held.clear()
256
+ if (wasHeld) Verdict.CONSUME else Verdict.PASS
257
+ }
258
+ else -> if (phase == Phase.HOLDING) Verdict.CONSUME else Verdict.PASS
259
+ }
260
+
261
+ private fun remember(s: Sample) {
262
+ for (p in s.pointers) held.putIfAbsent(p.id, p.x to p.y)
263
+ }
264
+
265
+ private fun anyMoved(s: Sample): Boolean =
266
+ s.pointers.any { p ->
267
+ val start = held[p.id] ?: return@any false
268
+ Math.abs(p.x - start.first) > slopPx || Math.abs(p.y - start.second) > slopPx
269
+ }
270
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@g9tm/app-diagnostic-lynx",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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",