@office-iss/react-native-win32 0.0.0-canary.270 → 0.0.0-canary.271

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.
Files changed (96) hide show
  1. package/CHANGELOG.json +16 -1
  2. package/CHANGELOG.md +12 -4
  3. package/Libraries/Animated/animations/Animation.js +63 -24
  4. package/Libraries/Animated/animations/DecayAnimation.js +26 -38
  5. package/Libraries/Animated/animations/SpringAnimation.js +33 -39
  6. package/Libraries/Animated/animations/TimingAnimation.js +34 -42
  7. package/Libraries/Animated/createAnimatedComponent.js +46 -32
  8. package/Libraries/Animated/nodes/AnimatedProps.js +16 -10
  9. package/Libraries/Animated/nodes/AnimatedStyle.js +4 -0
  10. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
  11. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +61 -3
  12. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +61 -3
  13. package/Libraries/Components/Button.js +6 -4
  14. package/Libraries/Components/Button.win32.js +9 -4
  15. package/Libraries/Components/ScrollView/ScrollView.js +5 -5
  16. package/Libraries/Components/Switch/Switch.js +8 -6
  17. package/Libraries/Components/TextInput/TextInput.d.ts +4 -4
  18. package/Libraries/Components/TextInput/TextInput.flow.js +7 -10
  19. package/Libraries/Components/TextInput/TextInput.js +7 -7
  20. package/Libraries/Components/TextInput/TextInput.win32.js +7 -7
  21. package/Libraries/Components/TextInput/TextInputState.js +11 -13
  22. package/Libraries/Components/TextInput/TextInputState.win32.js +13 -16
  23. package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
  24. package/Libraries/Components/View/ViewNativeComponent.js +3 -10
  25. package/Libraries/Core/ReactNativeVersion.js +1 -1
  26. package/Libraries/Core/setUpBatchedBridge.js +1 -10
  27. package/Libraries/Core/setUpReactDevTools.js +3 -3
  28. package/Libraries/Core/setUpSegmentFetcher.js +1 -0
  29. package/Libraries/Core/setUpTimers.js +8 -8
  30. package/Libraries/Image/ImageBackground.js +2 -5
  31. package/Libraries/Image/ImageProps.js +1 -1
  32. package/Libraries/Image/ImageViewNativeComponent.js +2 -2
  33. package/Libraries/Inspector/ReactDevToolsOverlay.js +0 -1
  34. package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +3 -5
  35. package/Libraries/JSInspector/NetworkAgent.js +1 -1
  36. package/Libraries/Lists/FlatList.d.ts +1 -2
  37. package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +2 -2
  38. package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
  39. package/Libraries/LogBox/Data/LogBoxData.js +1 -1
  40. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +1 -1
  41. package/Libraries/LogBox/UI/LogBoxMessage.js +2 -2
  42. package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
  43. package/Libraries/NativeComponent/BaseViewConfig.ios.js +1 -0
  44. package/Libraries/NativeComponent/BaseViewConfig.win32.js +1 -0
  45. package/Libraries/Network/XMLHttpRequest.js +26 -1
  46. package/Libraries/Pressability/HoverState.js +2 -0
  47. package/Libraries/Pressability/HoverState.win32.js +2 -0
  48. package/Libraries/Pressability/Pressability.js +2 -3
  49. package/Libraries/Pressability/Pressability.win32.js +2 -3
  50. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -3
  51. package/Libraries/ReactNative/RendererImplementation.js +4 -3
  52. package/Libraries/Renderer/shims/ReactNativeTypes.js +13 -18
  53. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -0
  54. package/Libraries/StyleSheet/StyleSheetTypes.js +13 -0
  55. package/Libraries/StyleSheet/processTransform.js +3 -34
  56. package/Libraries/Text/Text.js +251 -249
  57. package/Libraries/Text/Text.win32.js +285 -295
  58. package/Libraries/Types/CoreEventTypes.d.ts +3 -10
  59. package/Libraries/Types/CoreEventTypes.js +4 -6
  60. package/Libraries/Types/CoreEventTypes.win32.js +4 -6
  61. package/Libraries/Utilities/Platform.flow.js +2 -2
  62. package/Libraries/Utilities/Platform.flow.win32.js +2 -2
  63. package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +5 -4
  64. package/index.js +5 -2
  65. package/index.win32.js +5 -2
  66. package/jest/setup.js +30 -0
  67. package/overrides.json +18 -17
  68. package/package.json +13 -13
  69. package/src/private/animated/NativeAnimatedHelper.js +2 -4
  70. package/src/private/animated/NativeAnimatedHelper.win32.js +2 -3
  71. package/src/private/components/HScrollViewNativeComponents.js +4 -5
  72. package/src/private/{fusebox → debugging}/setUpFuseboxReactDevToolsDispatcher.js +6 -0
  73. package/src/private/featureflags/ReactNativeFeatureFlags.js +14 -23
  74. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -5
  75. package/src/private/specs/modules/NativeAccessibilityInfo.js +3 -0
  76. package/src/private/specs/modules/NativeAccessibilityInfoWin32.js +3 -0
  77. package/src/private/specs/modules/NativeAccessibilityManager.js +4 -0
  78. package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -3
  79. package/src/private/webapis/performance/EventTiming.js +13 -8
  80. package/src/private/webapis/performance/Performance.js +30 -40
  81. package/src/private/webapis/performance/PerformanceEntry.js +2 -5
  82. package/src/private/webapis/performance/PerformanceObserver.js +20 -32
  83. package/src/private/webapis/performance/RawPerformanceEntry.js +1 -1
  84. package/src/private/webapis/performance/UserTiming.js +6 -2
  85. package/src/private/webapis/performance/Utilities.js +0 -7
  86. package/src/private/webapis/performance/specs/NativePerformance.js +53 -0
  87. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +247 -0
  88. package/src-win/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
  89. package/types/public/ReactNativeTypes.d.ts +4 -4
  90. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +0 -69
  91. package/src/private/webapis/performance/specs/__mocks__/NativePerformance.js +0 -69
  92. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +0 -154
  93. /package/src/private/{fusebox → debugging}/FuseboxSessionObserver.js +0 -0
  94. /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.android.js +0 -0
  95. /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.ios.js +0 -0
  96. /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.win32.js +0 -0
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @generated SignedSource<<cd4a2a047e3a6fdb4205efb518906462>>
7
+ * @generated SignedSource<<e6477fcd9bf64a5c84496dfb55ae3700>>
8
8
  * @flow strict
9
9
  */
10
10
 
@@ -27,10 +27,8 @@ export interface Spec extends TurboModule {
27
27
  +allowRecursiveCommitsWithSynchronousMountOnAndroid?: () => boolean;
28
28
  +batchRenderingUpdatesInEventLoop?: () => boolean;
29
29
  +completeReactInstanceCreationOnBgThreadOnAndroid?: () => boolean;
30
- +destroyFabricSurfacesInReactInstanceManager?: () => boolean;
31
30
  +enableAlignItemsBaselineOnFabricIOS?: () => boolean;
32
31
  +enableAndroidLineHeightCentering?: () => boolean;
33
- +enableBackgroundStyleApplicator?: () => boolean;
34
32
  +enableBridgelessArchitecture?: () => boolean;
35
33
  +enableCleanTextInputYogaNode?: () => boolean;
36
34
  +enableDeletionOfUnmountedViews?: () => boolean;
@@ -41,6 +39,7 @@ export interface Spec extends TurboModule {
41
39
  +enableFabricRendererExclusively?: () => boolean;
42
40
  +enableGranularShadowTreeStateReconciliation?: () => boolean;
43
41
  +enableIOSViewClipToPaddingBox?: () => boolean;
42
+ +enableLayoutAnimationsOnAndroid?: () => boolean;
44
43
  +enableLayoutAnimationsOnIOS?: () => boolean;
45
44
  +enableLongTaskAPI?: () => boolean;
46
45
  +enableMicrotasks?: () => boolean;
@@ -68,11 +67,9 @@ export interface Spec extends TurboModule {
68
67
  +useImmediateExecutorInAndroidBridgeless?: () => boolean;
69
68
  +useModernRuntimeScheduler?: () => boolean;
70
69
  +useNativeViewConfigsInBridgelessMode?: () => boolean;
71
- +useNewReactImageViewBackgroundDrawing?: () => boolean;
72
70
  +useOptimisedViewPreallocationOnAndroid?: () => boolean;
73
71
  +useOptimizedEventBatchingOnAndroid?: () => boolean;
74
72
  +useRuntimeShadowNodeReferenceUpdate?: () => boolean;
75
- +useRuntimeShadowNodeReferenceUpdateOnLayout?: () => boolean;
76
73
  +useTurboModuleInterop?: () => boolean;
77
74
  +useTurboModules?: () => boolean;
78
75
  }
@@ -16,6 +16,9 @@ export interface Spec extends TurboModule {
16
16
  +isReduceMotionEnabled: (
17
17
  onSuccess: (isReduceMotionEnabled: boolean) => void,
18
18
  ) => void;
19
+ +isHighTextContrastEnabled?: (
20
+ onSuccess: (isHighTextContrastEnabled: boolean) => void,
21
+ ) => void;
19
22
  +isTouchExplorationEnabled: (
20
23
  onSuccess: (isScreenReaderEnabled: boolean) => void,
21
24
  ) => void;
@@ -16,6 +16,9 @@ export interface Spec extends TurboModule {
16
16
  +isReduceMotionEnabled: (
17
17
  onSuccess: (isReduceMotionEnabled: boolean) => void,
18
18
  ) => void;
19
+ +isHighTextContrastEnabled?: (
20
+ onSuccess: (isHighTextContrastEnabled: boolean) => void,
21
+ ) => void;
19
22
  +isTouchExplorationEnabled: (
20
23
  onSuccess: (isScreenReaderEnabled: boolean) => void,
21
24
  ) => void;
@@ -29,6 +29,10 @@ export interface Spec extends TurboModule {
29
29
  onSuccess: (isReduceMotionEnabled: boolean) => void,
30
30
  onError: (error: Object) => void,
31
31
  ) => void;
32
+ +getCurrentDarkerSystemColorsState?: (
33
+ onSuccess: (isDarkerSystemColorsEnabled: boolean) => void,
34
+ onError: (error: Object) => void,
35
+ ) => void;
32
36
  +getCurrentPrefersCrossFadeTransitionsState?: (
33
37
  onSuccess: (prefersCrossFadeTransitions: boolean) => void,
34
38
  onError: (error: Object) => void,
@@ -11,7 +11,7 @@
11
11
  // flowlint unsafe-getters-setters:off
12
12
 
13
13
  import type {
14
- HostComponent,
14
+ HostInstance,
15
15
  INativeMethods,
16
16
  InternalInstanceHandle,
17
17
  MeasureInWindowOnSuccessCallback,
@@ -19,7 +19,6 @@ import type {
19
19
  MeasureOnSuccessCallback,
20
20
  ViewConfig,
21
21
  } from '../../../../../Libraries/Renderer/shims/ReactNativeTypes';
22
- import type {ElementRef} from 'react';
23
22
 
24
23
  import TextInputState from '../../../../../Libraries/Components/TextInput/TextInputState';
25
24
  import {getFabricUIManager} from '../../../../../Libraries/ReactNative/FabricUIManager';
@@ -143,7 +142,7 @@ export default class ReactNativeElement
143
142
  }
144
143
 
145
144
  measureLayout(
146
- relativeToNativeNode: number | ElementRef<HostComponent<mixed>>,
145
+ relativeToNativeNode: number | HostInstance,
147
146
  onSuccess: MeasureLayoutOnSuccessCallback,
148
147
  onFail?: () => void /* currently unused */,
149
148
  ) {
@@ -16,8 +16,8 @@ import type {
16
16
  } from './PerformanceEntry';
17
17
 
18
18
  import {PerformanceEntry} from './PerformanceEntry';
19
- import {warnNoNativePerformanceObserver} from './Utilities';
20
- import NativePerformanceObserver from './specs/NativePerformanceObserver';
19
+ import {warnNoNativePerformance} from './Utilities';
20
+ import NativePerformance from './specs/NativePerformance';
21
21
 
22
22
  export type PerformanceEventTimingJSON = {
23
23
  ...PerformanceEntryJSON,
@@ -85,14 +85,18 @@ function getCachedEventCounts(): Map<string, number> {
85
85
  if (cachedEventCounts) {
86
86
  return cachedEventCounts;
87
87
  }
88
- if (!NativePerformanceObserver) {
89
- warnNoNativePerformanceObserver();
90
- return new Map();
88
+
89
+ if (!NativePerformance || !NativePerformance?.getEventCounts) {
90
+ warnNoNativePerformance();
91
+ cachedEventCounts = new Map();
92
+ return cachedEventCounts;
91
93
  }
92
94
 
93
- cachedEventCounts = new Map<string, number>(
94
- NativePerformanceObserver.getEventCounts(),
95
+ const eventCounts = new Map<string, number>(
96
+ NativePerformance.getEventCounts?.() ?? [],
95
97
  );
98
+ cachedEventCounts = eventCounts;
99
+
96
100
  // $FlowFixMe[incompatible-call]
97
101
  global.queueMicrotask(() => {
98
102
  // To be consistent with the calls to the API from the same task,
@@ -101,7 +105,8 @@ function getCachedEventCounts(): Map<string, number> {
101
105
  // after the current task is guaranteed to have finished.
102
106
  cachedEventCounts = null;
103
107
  });
104
- return cachedEventCounts ?? new Map();
108
+
109
+ return eventCounts;
105
110
  }
106
111
 
107
112
  /**
@@ -13,22 +13,18 @@
13
13
  import type {
14
14
  DOMHighResTimeStamp,
15
15
  PerformanceEntryType,
16
+ PerformanceEntryList,
16
17
  } from './PerformanceEntry';
17
- import type {PerformanceEntryList} from './PerformanceObserver';
18
18
  import type {DetailType, PerformanceMarkOptions} from './UserTiming';
19
19
 
20
20
  import {EventCounts} from './EventTiming';
21
21
  import MemoryInfo from './MemoryInfo';
22
- import {ALWAYS_LOGGED_ENTRY_TYPES} from './PerformanceEntry';
23
- import {warnNoNativePerformanceObserver} from './Utilities';
24
22
  import {
25
23
  performanceEntryTypeToRaw,
26
24
  rawToPerformanceEntry,
27
25
  } from './RawPerformanceEntry';
28
- import {RawPerformanceEntryTypeValues} from './RawPerformanceEntry';
29
26
  import ReactNativeStartupTiming from './ReactNativeStartupTiming';
30
27
  import NativePerformance from './specs/NativePerformance';
31
- import NativePerformanceObserver from './specs/NativePerformanceObserver';
32
28
  import {PerformanceMark, PerformanceMeasure} from './UserTiming';
33
29
  import {warnNoNativePerformance} from './Utilities';
34
30
 
@@ -47,6 +43,9 @@ export type PerformanceMeasureOptions = {
47
43
  end?: DOMHighResTimeStamp,
48
44
  };
49
45
 
46
+ const ENTRY_TYPES_AVAILABLE_FROM_TIMELINE: $ReadOnlyArray<PerformanceEntryType> =
47
+ ['mark', 'measure'];
48
+
50
49
  /**
51
50
  * Partial implementation of the Performance interface for RN,
52
51
  * corresponding to the standard in
@@ -122,15 +121,12 @@ export default class Performance {
122
121
  }
123
122
 
124
123
  clearMarks(markName?: string): void {
125
- if (!NativePerformanceObserver?.clearEntries) {
126
- warnNoNativePerformanceObserver();
124
+ if (!NativePerformance?.clearMarks) {
125
+ warnNoNativePerformance();
127
126
  return;
128
127
  }
129
128
 
130
- NativePerformanceObserver.clearEntries(
131
- RawPerformanceEntryTypeValues.MARK,
132
- markName,
133
- );
129
+ NativePerformance.clearMarks(markName);
134
130
  }
135
131
 
136
132
  measure(
@@ -209,15 +205,12 @@ export default class Performance {
209
205
  }
210
206
 
211
207
  clearMeasures(measureName?: string): void {
212
- if (!NativePerformanceObserver?.clearEntries) {
213
- warnNoNativePerformanceObserver();
208
+ if (!NativePerformance?.clearMeasures) {
209
+ warnNoNativePerformance();
214
210
  return;
215
211
  }
216
212
 
217
- NativePerformanceObserver?.clearEntries(
218
- RawPerformanceEntryTypeValues.MEASURE,
219
- measureName,
220
- );
213
+ NativePerformance?.clearMeasures(measureName);
221
214
  }
222
215
 
223
216
  /**
@@ -234,28 +227,28 @@ export default class Performance {
234
227
  * https://www.w3.org/TR/performance-timeline/#extensions-to-the-performance-interface
235
228
  */
236
229
  getEntries(): PerformanceEntryList {
237
- if (!NativePerformanceObserver?.getEntries) {
238
- warnNoNativePerformanceObserver();
230
+ if (!NativePerformance?.getEntries) {
231
+ warnNoNativePerformance();
239
232
  return [];
240
233
  }
241
- return NativePerformanceObserver.getEntries().map(rawToPerformanceEntry);
234
+ return NativePerformance.getEntries().map(rawToPerformanceEntry);
242
235
  }
243
236
 
244
237
  getEntriesByType(entryType: PerformanceEntryType): PerformanceEntryList {
245
- if (!ALWAYS_LOGGED_ENTRY_TYPES.includes(entryType)) {
246
- console.warn(
247
- `Performance.getEntriesByType: Only valid for ${JSON.stringify(
248
- ALWAYS_LOGGED_ENTRY_TYPES,
249
- )} entry types, got ${entryType}`,
250
- );
238
+ if (
239
+ entryType != null &&
240
+ !ENTRY_TYPES_AVAILABLE_FROM_TIMELINE.includes(entryType)
241
+ ) {
242
+ console.warn('Deprecated API for given entry type.');
251
243
  return [];
252
244
  }
253
245
 
254
- if (!NativePerformanceObserver?.getEntries) {
255
- warnNoNativePerformanceObserver();
246
+ if (!NativePerformance?.getEntriesByType) {
247
+ warnNoNativePerformance();
256
248
  return [];
257
249
  }
258
- return NativePerformanceObserver.getEntries(
250
+
251
+ return NativePerformance.getEntriesByType(
259
252
  performanceEntryTypeToRaw(entryType),
260
253
  ).map(rawToPerformanceEntry);
261
254
  }
@@ -265,24 +258,21 @@ export default class Performance {
265
258
  entryType?: PerformanceEntryType,
266
259
  ): PerformanceEntryList {
267
260
  if (
268
- entryType !== undefined &&
269
- !ALWAYS_LOGGED_ENTRY_TYPES.includes(entryType)
261
+ entryType != null &&
262
+ !ENTRY_TYPES_AVAILABLE_FROM_TIMELINE.includes(entryType)
270
263
  ) {
271
- console.warn(
272
- `Performance.getEntriesByName: Only valid for ${JSON.stringify(
273
- ALWAYS_LOGGED_ENTRY_TYPES,
274
- )} entry types, got ${entryType}`,
275
- );
264
+ console.warn('Deprecated API for given entry type.');
276
265
  return [];
277
266
  }
278
267
 
279
- if (!NativePerformanceObserver?.getEntries) {
280
- warnNoNativePerformanceObserver();
268
+ if (!NativePerformance?.getEntriesByName) {
269
+ warnNoNativePerformance();
281
270
  return [];
282
271
  }
283
- return NativePerformanceObserver.getEntries(
284
- entryType != null ? performanceEntryTypeToRaw(entryType) : undefined,
272
+
273
+ return NativePerformance.getEntriesByName(
285
274
  entryName,
275
+ entryType != null ? performanceEntryTypeToRaw(entryType) : undefined,
286
276
  ).map(rawToPerformanceEntry);
287
277
  }
288
278
  }
@@ -21,11 +21,6 @@ export type PerformanceEntryJSON = {
21
21
  ...
22
22
  };
23
23
 
24
- export const ALWAYS_LOGGED_ENTRY_TYPES: $ReadOnlyArray<PerformanceEntryType> = [
25
- 'mark',
26
- 'measure',
27
- ];
28
-
29
24
  export class PerformanceEntry {
30
25
  #name: string;
31
26
  #entryType: PerformanceEntryType;
@@ -69,3 +64,5 @@ export class PerformanceEntry {
69
64
  };
70
65
  }
71
66
  }
67
+
68
+ export type PerformanceEntryList = $ReadOnlyArray<PerformanceEntry>;
@@ -11,20 +11,18 @@
11
11
  import type {
12
12
  DOMHighResTimeStamp,
13
13
  PerformanceEntryType,
14
+ PerformanceEntryList,
14
15
  } from './PerformanceEntry';
15
16
 
16
17
  import {PerformanceEventTiming} from './EventTiming';
17
- import {PerformanceEntry} from './PerformanceEntry';
18
18
  import {
19
19
  performanceEntryTypeToRaw,
20
20
  rawToPerformanceEntry,
21
21
  rawToPerformanceEntryType,
22
22
  } from './RawPerformanceEntry';
23
- import NativePerformanceObserver from './specs/NativePerformanceObserver';
24
- import type {OpaqueNativeObserverHandle} from './specs/NativePerformanceObserver';
25
- import {warnNoNativePerformanceObserver} from './Utilities';
26
-
27
- export type PerformanceEntryList = $ReadOnlyArray<PerformanceEntry>;
23
+ import NativePerformance from './specs/NativePerformance';
24
+ import type {OpaqueNativeObserverHandle} from './specs/NativePerformance';
25
+ import {warnNoNativePerformance} from './Utilities';
28
26
 
29
27
  export {PerformanceEntry} from './PerformanceEntry';
30
28
 
@@ -76,15 +74,15 @@ export type PerformanceObserverInit = {
76
74
  };
77
75
 
78
76
  function getSupportedPerformanceEntryTypes(): $ReadOnlyArray<PerformanceEntryType> {
79
- if (!NativePerformanceObserver) {
77
+ if (!NativePerformance) {
80
78
  return Object.freeze([]);
81
79
  }
82
- if (!NativePerformanceObserver.getSupportedPerformanceEntryTypes) {
80
+ if (!NativePerformance.getSupportedPerformanceEntryTypes) {
83
81
  // fallback if getSupportedPerformanceEntryTypes is not defined on native side
84
82
  return Object.freeze(['mark', 'measure', 'event']);
85
83
  }
86
84
  return Object.freeze(
87
- NativePerformanceObserver.getSupportedPerformanceEntryTypes().map(
85
+ NativePerformance.getSupportedPerformanceEntryTypes().map(
88
86
  rawToPerformanceEntryType,
89
87
  ),
90
88
  );
@@ -121,11 +119,8 @@ export class PerformanceObserver {
121
119
  }
122
120
 
123
121
  observe(options: PerformanceObserverInit): void {
124
- if (
125
- !NativePerformanceObserver ||
126
- NativePerformanceObserver.observe == null
127
- ) {
128
- warnNoNativePerformanceObserver();
122
+ if (!NativePerformance || NativePerformance.observe == null) {
123
+ warnNoNativePerformance();
129
124
  return;
130
125
  }
131
126
 
@@ -137,12 +132,12 @@ export class PerformanceObserver {
137
132
 
138
133
  if (options.entryTypes) {
139
134
  this.#type = 'multiple';
140
- NativePerformanceObserver.observe?.(this.#nativeObserverHandle, {
135
+ NativePerformance.observe?.(this.#nativeObserverHandle, {
141
136
  entryTypes: options.entryTypes.map(performanceEntryTypeToRaw),
142
137
  });
143
138
  } else if (options.type) {
144
139
  this.#type = 'single';
145
- NativePerformanceObserver.observe?.(this.#nativeObserverHandle, {
140
+ NativePerformance.observe?.(this.#nativeObserverHandle, {
146
141
  type: performanceEntryTypeToRaw(options.type),
147
142
  buffered: options.buffered,
148
143
  durationThreshold: options.durationThreshold,
@@ -151,35 +146,28 @@ export class PerformanceObserver {
151
146
  }
152
147
 
153
148
  disconnect(): void {
154
- if (!NativePerformanceObserver) {
155
- warnNoNativePerformanceObserver();
149
+ if (!NativePerformance) {
150
+ warnNoNativePerformance();
156
151
  return;
157
152
  }
158
153
 
159
- if (
160
- this.#nativeObserverHandle == null ||
161
- !NativePerformanceObserver.disconnect
162
- ) {
154
+ if (this.#nativeObserverHandle == null || !NativePerformance.disconnect) {
163
155
  return;
164
156
  }
165
157
 
166
- NativePerformanceObserver.disconnect(this.#nativeObserverHandle);
158
+ NativePerformance.disconnect(this.#nativeObserverHandle);
167
159
  }
168
160
 
169
161
  #createNativeObserver(): OpaqueNativeObserverHandle {
170
- if (
171
- !NativePerformanceObserver ||
172
- !NativePerformanceObserver.createObserver
173
- ) {
174
- warnNoNativePerformanceObserver();
162
+ if (!NativePerformance || !NativePerformance.createObserver) {
163
+ warnNoNativePerformance();
175
164
  return;
176
165
  }
177
166
 
178
167
  this.#calledAtLeastOnce = false;
179
168
 
180
- return NativePerformanceObserver.createObserver(() => {
181
- // $FlowNotNull
182
- const rawEntries = NativePerformanceObserver.takeRecords?.(
169
+ return NativePerformance.createObserver(() => {
170
+ const rawEntries = NativePerformance.takeRecords?.(
183
171
  this.#nativeObserverHandle,
184
172
  true, // sort records
185
173
  );
@@ -193,7 +181,7 @@ export class PerformanceObserver {
193
181
  let droppedEntriesCount = 0;
194
182
  if (!this.#calledAtLeastOnce) {
195
183
  droppedEntriesCount =
196
- NativePerformanceObserver.getDroppedEntriesCount?.(
184
+ NativePerformance.getDroppedEntriesCount?.(
197
185
  this.#nativeObserverHandle,
198
186
  ) ?? 0;
199
187
  this.#calledAtLeastOnce = true;
@@ -12,7 +12,7 @@ import type {PerformanceEntryType} from './PerformanceEntry';
12
12
  import type {
13
13
  RawPerformanceEntry,
14
14
  RawPerformanceEntryType,
15
- } from './specs/NativePerformanceObserver';
15
+ } from './specs/NativePerformance';
16
16
 
17
17
  import {PerformanceEventTiming} from './EventTiming';
18
18
  import {PerformanceLongTaskTiming} from './LongTasks';
@@ -30,7 +30,7 @@ export type PerformanceMeasureInit = {
30
30
  };
31
31
 
32
32
  export class PerformanceMark extends PerformanceEntry {
33
- detail: DetailType;
33
+ #detail: DetailType;
34
34
 
35
35
  constructor(markName: string, markOptions?: PerformanceMarkOptions) {
36
36
  super({
@@ -41,9 +41,13 @@ export class PerformanceMark extends PerformanceEntry {
41
41
  });
42
42
 
43
43
  if (markOptions) {
44
- this.detail = markOptions.detail;
44
+ this.#detail = markOptions.detail;
45
45
  }
46
46
  }
47
+
48
+ get detail(): DetailType {
49
+ return this.#detail;
50
+ }
47
51
  }
48
52
 
49
53
  export class PerformanceMeasure extends PerformanceEntry {
@@ -16,10 +16,3 @@ export function warnNoNativePerformance() {
16
16
  'Missing native implementation of Performance',
17
17
  );
18
18
  }
19
-
20
- export function warnNoNativePerformanceObserver() {
21
- warnOnce(
22
- 'missing-native-performance-observer',
23
- 'Missing native implementation of PerformanceObserver',
24
- );
25
- }
@@ -16,6 +16,31 @@ export type NativeMemoryInfo = {[key: string]: ?number};
16
16
 
17
17
  export type ReactNativeStartupTiming = {[key: string]: ?number};
18
18
 
19
+ export type RawPerformanceEntryType = number;
20
+
21
+ export type RawPerformanceEntry = {
22
+ name: string,
23
+ entryType: RawPerformanceEntryType,
24
+ startTime: number,
25
+ duration: number,
26
+
27
+ // For "event" entries only:
28
+ processingStart?: number,
29
+ processingEnd?: number,
30
+ interactionId?: number,
31
+ };
32
+
33
+ export type OpaqueNativeObserverHandle = mixed;
34
+
35
+ export type NativeBatchedObserverCallback = () => void;
36
+
37
+ export type PerformanceObserverInit = {
38
+ entryTypes?: $ReadOnlyArray<number>,
39
+ type?: number,
40
+ buffered?: boolean,
41
+ durationThreshold?: number,
42
+ };
43
+
19
44
  export interface Spec extends TurboModule {
20
45
  +now?: () => number;
21
46
  +mark: (name: string, startTime: number) => void;
@@ -27,8 +52,36 @@ export interface Spec extends TurboModule {
27
52
  startMark?: string,
28
53
  endMark?: string,
29
54
  ) => void;
55
+ +clearMarks?: (entryName?: string) => void;
56
+ +clearMeasures?: (entryName?: string) => void;
57
+ +getEntries?: () => $ReadOnlyArray<RawPerformanceEntry>;
58
+ +getEntriesByName?: (
59
+ entryName: string,
60
+ entryType?: ?RawPerformanceEntryType,
61
+ ) => $ReadOnlyArray<RawPerformanceEntry>;
62
+ +getEntriesByType?: (
63
+ entryType: RawPerformanceEntryType,
64
+ ) => $ReadOnlyArray<RawPerformanceEntry>;
65
+ +getEventCounts?: () => $ReadOnlyArray<[string, number]>;
30
66
  +getSimpleMemoryInfo: () => NativeMemoryInfo;
31
67
  +getReactNativeStartupTiming: () => ReactNativeStartupTiming;
68
+
69
+ +createObserver?: (
70
+ callback: NativeBatchedObserverCallback,
71
+ ) => OpaqueNativeObserverHandle;
72
+ +getDroppedEntriesCount?: (observer: OpaqueNativeObserverHandle) => number;
73
+
74
+ +observe?: (
75
+ observer: OpaqueNativeObserverHandle,
76
+ options: PerformanceObserverInit,
77
+ ) => void;
78
+ +disconnect?: (observer: OpaqueNativeObserverHandle) => void;
79
+ +takeRecords?: (
80
+ observer: OpaqueNativeObserverHandle,
81
+ sort: boolean,
82
+ ) => $ReadOnlyArray<RawPerformanceEntry>;
83
+
84
+ +getSupportedPerformanceEntryTypes?: () => $ReadOnlyArray<RawPerformanceEntryType>;
32
85
  }
33
86
 
34
87
  export default (TurboModuleRegistry.get<Spec>('NativePerformanceCxx'): ?Spec);