@@ -218,53 +218,58 @@ struct StrKeyHash {
218
218
// https://www.w3.org/TR/event-timing/#sec-events-exposed
219
219
// Not all of these are currently supported by RN, but we map them anyway for
220
220
// future-proofing.
221
- static const std::unordered_map<StrKey, const char *, StrKeyHash>
222
- SUPPORTED_EVENTS = {
223
- {" topAuxClick" , " auxclick" },
224
- {" topClick" , " click" },
225
- {" topContextMenu" , " contextmenu" },
226
- {" topDblClick" , " dblclick" },
227
- {" topMouseDown" , " mousedown" },
228
- {" topMouseEnter" , " mouseenter" },
229
- {" topMouseLeave" , " mouseleave" },
230
- {" topMouseOut" , " mouseout" },
231
- {" topMouseOver" , " mouseover" },
232
- {" topMouseUp" , " mouseup" },
233
- {" topPointerOver" , " pointerover" },
234
- {" topPointerEnter" , " pointerenter" },
235
- {" topPointerDown" , " pointerdown" },
236
- {" topPointerUp" , " pointerup" },
237
- {" topPointerCancel" , " pointercancel" },
238
- {" topPointerOut" , " pointerout" },
239
- {" topPointerLeave" , " pointerleave" },
240
- {" topGotPointerCapture" , " gotpointercapture" },
241
- {" topLostPointerCapture" , " lostpointercapture" },
242
- {" topTouchStart" , " touchstart" },
243
- {" topTouchEnd" , " touchend" },
244
- {" topTouchCancel" , " touchcancel" },
245
- {" topKeyDown" , " keydown" },
246
- {" topKeyPress" , " keypress" },
247
- {" topKeyUp" , " keyup" },
248
- {" topBeforeInput" , " beforeinput" },
249
- {" topInput" , " input" },
250
- {" topCompositionStart" , " compositionstart" },
251
- {" topCompositionUpdate" , " compositionupdate" },
252
- {" topCompositionEnd" , " compositionend" },
253
- {" topDragStart" , " dragstart" },
254
- {" topDragEnd" , " dragend" },
255
- {" topDragEnter" , " dragenter" },
256
- {" topDragLeave" , " dragleave" },
257
- {" topDragOver" , " dragover" },
258
- {" topDrop" , " drop" },
259
- };
221
+ using SupportedEventTypeRegistry =
222
+ std::unordered_map<StrKey, const char *, StrKeyHash>;
223
+
224
+ static const SupportedEventTypeRegistry &getSupportedEvents () {
225
+ static SupportedEventTypeRegistry SUPPORTED_EVENTS = {
226
+ {" topAuxClick" , " auxclick" },
227
+ {" topClick" , " click" },
228
+ {" topContextMenu" , " contextmenu" },
229
+ {" topDblClick" , " dblclick" },
230
+ {" topMouseDown" , " mousedown" },
231
+ {" topMouseEnter" , " mouseenter" },
232
+ {" topMouseLeave" , " mouseleave" },
233
+ {" topMouseOut" , " mouseout" },
234
+ {" topMouseOver" , " mouseover" },
235
+ {" topMouseUp" , " mouseup" },
236
+ {" topPointerOver" , " pointerover" },
237
+ {" topPointerEnter" , " pointerenter" },
238
+ {" topPointerDown" , " pointerdown" },
239
+ {" topPointerUp" , " pointerup" },
240
+ {" topPointerCancel" , " pointercancel" },
241
+ {" topPointerOut" , " pointerout" },
242
+ {" topPointerLeave" , " pointerleave" },
243
+ {" topGotPointerCapture" , " gotpointercapture" },
244
+ {" topLostPointerCapture" , " lostpointercapture" },
245
+ {" topTouchStart" , " touchstart" },
246
+ {" topTouchEnd" , " touchend" },
247
+ {" topTouchCancel" , " touchcancel" },
248
+ {" topKeyDown" , " keydown" },
249
+ {" topKeyPress" , " keypress" },
250
+ {" topKeyUp" , " keyup" },
251
+ {" topBeforeInput" , " beforeinput" },
252
+ {" topInput" , " input" },
253
+ {" topCompositionStart" , " compositionstart" },
254
+ {" topCompositionUpdate" , " compositionupdate" },
255
+ {" topCompositionEnd" , " compositionend" },
256
+ {" topDragStart" , " dragstart" },
257
+ {" topDragEnd" , " dragend" },
258
+ {" topDragEnter" , " dragenter" },
259
+ {" topDragLeave" , " dragleave" },
260
+ {" topDragOver" , " dragover" },
261
+ {" topDrop" , " drop" },
262
+ };
263
+ return SUPPORTED_EVENTS;
264
+ }
260
265
261
266
EventTag PerformanceEntryReporter::onEventStart (const char *name) {
262
267
if (!isReportingEvents ()) {
263
268
return 0 ;
264
269
}
265
-
266
- auto it = SUPPORTED_EVENTS .find (name);
267
- if (it == SUPPORTED_EVENTS .end ()) {
270
+ const auto &supportedEvents = getSupportedEvents ();
271
+ auto it = supportedEvents .find (name);
272
+ if (it == supportedEvents .end ()) {
268
273
return 0 ;
269
274
}
270
275
0 commit comments