Repository navigation
Commit fddd5ec
committed
[General] Align
## Description
The JS `PointerType` enum is `TOUCH, STYLUS, MOUSE, KEY, OTHER`, but the
native constants stopped at `OTHER = 3` — the value JS reads as `KEY`.
Native pointer types travel to JS as plain ints with no translation layer
(`gestureHandlerCommon.ts` types them as `PointerType`), so every native
"other pointer" surfaced as `PointerType.KEY`, and `PointerType.OTHER` was
unreachable from native. It is reachable on Android through
`TOOL_TYPE_ERASER` / `TOOL_TYPE_UNKNOWN`, and on Apple through tvOS
focus-driven hover and any touch that is neither direct, pencil, nor
indirect pointer.
Declares `KEY` on both platforms so `OTHER` lands on 4. Native never emits
`KEY` — it is produced only by the web `KeyboardEventManager`.
With the values consistent, `ButtonEvent.pointerType` is narrowed from
`number` to `PointerType`. It only mirrored the codegen spec's `Int32`; the
spec keeps its own self-contained copy, so codegen is unaffected. Numeric
enums and `number` are mutually assignable, so this breaks no consumer —
which is also why the `buttonEventTest` drift guard still passes. That guard
can no longer tell a deliberate refinement of this field from real spec
drift, but it still catches added, removed and retyped fields.
## Test plan
- Android: `:react-native-gesture-handler:compileDebugKotlin` and
`:app:assembleDebug` in `apps/basic-example/android` both succeed
- Apple: enum values pinned by a compiled assertion (`Touch` 0 … `Key` 3,
`OtherPointer` 4); no `switch` over the enum exists, so no `-Wswitch` fallout
- `yarn ts-check` clean (both passes), `yarn test` 115/115, `yarn lint:js`
0 errors
- The iOS app build was not run — `pod install` fails on this machine for
reasons unrelated to the change (rvm `libruby.2.7.dylib` mismatch)pointerType across native and JS1 parent e58c43a commit fddd5ec
3 files changed
Lines changed: 4 additions & 2 deletions
File tree
- packages/react-native-gesture-handler
- android/src/main/java/com/swmansion/gesturehandler/core
- apple
- src/v3/types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
1090 | | - | |
| 1090 | + | |
| 1091 | + | |
1091 | 1092 | | |
1092 | 1093 | | |
1093 | 1094 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments