Commit 29ad9e8
authored
refactor: don't use private reanimated API (#1209)
## 📜 Description
Added a support for Expo snack.
## 💡 Motivation and Context
In this PR I re-worked the approach how I attach worklet handlers to
`KeyboardControllerView`. Prior to
#538
we simply broadcasted events for stored worklet handlers inside a global
object. But this approach had downsides, such as slow flow of execution,
so I re-worked it in
#538
and instantly introduced issues like:
#551
and
#555
While I managed somehow to fix it, the new approach wasn't ideal:
- we still used internal API that was relying on FS structure;
- this is highly internal API that can be changed anytime and will not
assure that lib works across all reanimated versions;
- in Expo Go I see strange errors, but I tend to think they are derived
from the same issue - my code can not lookup a module and we get a crash
🤷♂️
I kept the idea to re-work this piece of code and in this PR I'm doing
it. I can not use public API only, but the new approach is actually
smarter. The new idea is that we **still** use `registerEvent`
Should fix errors like:
<img width="600" height="1266" alt="image"
src="https://github.com/user-attachments/assets/272de55e-91a5-443a-b252-32e5a0f1a50c"
/>
Actually correct solution for:
#555
In future I'll be able to add interactive code samples into
documentation, so people can run demos straight in the browser.
## 📢 Changelog
<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->
### JS
- remove `event-handler` files;
- remove `event-mapping` file;
- use `useEvent`/`useHandler` hook for `useKeyboardHandler` and
`useFocusedInputHandler` hooks;
- use `registerForEvents`/`unregisterFromEvents` methods from
`WorkletEventHandler` (instance returned by `useEvent` hook);
> I also had to use `never` types, or cast to my types using `as unknown
as`, since I anyway access reanimated internals. But it's safer to use
internals in this way, than before 🤞
## 🤔 How Has This Been Tested?
Tested manually on:
- iPhone 16 Pro (new arch, iOS 26.0);
- e2e tests;
## 📸 Screenshots (if appropriate):
<img width="1721" height="878" alt="image"
src="https://github.com/user-attachments/assets/30c8dc65-a7f2-4682-838f-aab4c22189fc"
/>
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed1 parent 14471f9 commit 29ad9e8
File tree
8 files changed
+110
-101
lines changed- src
- hooks
8 files changed
+110
-101
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
23 | 21 | | |
24 | 22 | | |
25 | | - | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
| |||
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 130 | + | |
| 131 | + | |
141 | 132 | | |
142 | 133 | | |
143 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 4 | + | |
9 | 5 | | |
10 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
| |||
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
110 | | - | |
| 116 | + | |
111 | 117 | | |
112 | 118 | | |
113 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
114 | 151 | | |
115 | | - | |
| 152 | + | |
116 | 153 | | |
117 | 154 | | |
118 | 155 | | |
| |||
149 | 186 | | |
150 | 187 | | |
151 | 188 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 189 | + | |
156 | 190 | | |
157 | 191 | | |
158 | 192 | | |
| |||
224 | 258 | | |
225 | 259 | | |
226 | 260 | | |
227 | | - | |
| 261 | + | |
228 | 262 | | |
229 | 263 | | |
230 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
231 | 285 | | |
232 | | - | |
| 286 | + | |
233 | 287 | | |
234 | 288 | | |
235 | 289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
10 | 21 | | |
11 | 22 | | |
12 | 23 | | |
13 | | - | |
14 | 24 | | |
15 | 25 | | |
16 | 26 | | |
| |||
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 34 | + | |
28 | 35 | | |
29 | 36 | | |
30 | | - | |
31 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
| |||
38 | 46 | | |
39 | 47 | | |
40 | 48 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
61 | 56 | | |
62 | 57 | | |
63 | 58 | | |
| |||
68 | 63 | | |
69 | 64 | | |
70 | 65 | | |
71 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
0 commit comments