react-native-windows 0.82.0-preview.1 → 0.82.0-preview.11

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 (63) hide show
  1. package/Libraries/Animated/nodes/AnimatedValue.js +0 -8
  2. package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
  3. package/Libraries/BatchedBridge/MessageQueue.js +1 -0
  4. package/Libraries/Components/Switch/Switch.js +1 -1
  5. package/Libraries/Components/Switch/Switch.windows.js +1 -1
  6. package/Libraries/Core/ReactNativeVersion.js +2 -2
  7. package/Libraries/Core/Timers/JSTimers.js +1 -0
  8. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  9. package/Libraries/Core/Timers/immediateShim.js +1 -0
  10. package/Libraries/Core/setUpPerformance.js +3 -5
  11. package/Libraries/Interaction/PanResponder.js +6 -51
  12. package/Microsoft.ReactNative/ComponentView.idl +2 -0
  13. package/Microsoft.ReactNative/Composition.Input.idl +7 -0
  14. package/Microsoft.ReactNative/CompositionComponentView.idl +3 -0
  15. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +18 -0
  16. package/Microsoft.ReactNative/Fabric/ComponentView.h +9 -0
  17. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +12 -0
  18. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +15 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +75 -0
  20. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -0
  21. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +84 -17
  22. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +4 -0
  23. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +56 -82
  24. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +7 -4
  25. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +82 -14
  26. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +11 -4
  27. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +33 -0
  28. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +17 -0
  29. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +59 -31
  30. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +3 -0
  31. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +42 -15
  32. package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +12 -0
  33. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  34. package/PropertySheets/Warnings.props +1 -2
  35. package/PropertySheets/WinUI.props +1 -1
  36. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/BaseParagraphProps.cpp +174 -0
  37. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/BaseParagraphProps.h +69 -0
  38. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +5 -11
  39. package/Scripts/rnw-dependencies.ps1 +15 -1
  40. package/Shared/Shared.vcxitems +1 -0
  41. package/Shared/Shared.vcxitems.filters +1 -3
  42. package/codegen/NativePerformanceSpec.g.h +41 -35
  43. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +55 -49
  44. package/codegen/rnwcoreJSI-generated.cpp +434 -422
  45. package/codegen/rnwcoreJSI.h +18 -0
  46. package/index.js +6 -0
  47. package/index.windows.js +6 -0
  48. package/package.json +15 -14
  49. package/src/private/featureflags/ReactNativeFeatureFlags.js +6 -1
  50. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -1
  51. package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
  52. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -0
  53. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
  54. package/src/private/webapis/performance/EventTiming.js +34 -15
  55. package/src/private/webapis/performance/LongTasks.js +35 -2
  56. package/src/private/webapis/performance/Performance.js +49 -13
  57. package/src/private/webapis/performance/PerformanceEntry.js +21 -8
  58. package/src/private/webapis/performance/PerformanceObserver.js +30 -1
  59. package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
  60. package/src/private/webapis/performance/ResourceTiming.js +29 -18
  61. package/src/private/webapis/performance/UserTiming.js +33 -28
  62. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
  63. package/src/private/webapis/performance/specs/NativePerformance.js +2 -0
@@ -65,6 +65,7 @@ public:
65
65
  virtual bool enableVirtualViewDebugFeatures(jsi::Runtime &rt) = 0;
66
66
  virtual bool enableVirtualViewRenderState(jsi::Runtime &rt) = 0;
67
67
  virtual bool enableVirtualViewWindowFocusDetection(jsi::Runtime &rt) = 0;
68
+ virtual bool enableWebPerformanceAPIsByDefault(jsi::Runtime &rt) = 0;
68
69
  virtual bool fixMappingOfEventPrioritiesBetweenFabricAndReact(jsi::Runtime &rt) = 0;
69
70
  virtual bool fuseboxEnabledRelease(jsi::Runtime &rt) = 0;
70
71
  virtual bool fuseboxNetworkInspectionEnabled(jsi::Runtime &rt) = 0;
@@ -480,6 +481,14 @@ private:
480
481
  return bridging::callFromJs<bool>(
481
482
  rt, &T::enableVirtualViewWindowFocusDetection, jsInvoker_, instance_);
482
483
  }
484
+ bool enableWebPerformanceAPIsByDefault(jsi::Runtime &rt) override {
485
+ static_assert(
486
+ bridging::getParameterCount(&T::enableWebPerformanceAPIsByDefault) == 1,
487
+ "Expected enableWebPerformanceAPIsByDefault(...) to have 1 parameters");
488
+
489
+ return bridging::callFromJs<bool>(
490
+ rt, &T::enableWebPerformanceAPIsByDefault, jsInvoker_, instance_);
491
+ }
483
492
  bool fixMappingOfEventPrioritiesBetweenFabricAndReact(jsi::Runtime &rt) override {
484
493
  static_assert(
485
494
  bridging::getParameterCount(&T::fixMappingOfEventPrioritiesBetweenFabricAndReact) == 1,
@@ -9031,6 +9040,7 @@ protected:
9031
9040
 
9032
9041
  public:
9033
9042
  virtual double now(jsi::Runtime &rt) = 0;
9043
+ virtual double timeOrigin(jsi::Runtime &rt) = 0;
9034
9044
  virtual void reportMark(jsi::Runtime &rt, jsi::String name, double startTime, jsi::Value entry) = 0;
9035
9045
  virtual void reportMeasure(jsi::Runtime &rt, jsi::String name, double startTime, double duration, jsi::Value entry) = 0;
9036
9046
  virtual std::optional<double> getMarkTime(jsi::Runtime &rt, jsi::String name) = 0;
@@ -9087,6 +9097,14 @@ private:
9087
9097
  return bridging::callFromJs<double>(
9088
9098
  rt, &T::now, jsInvoker_, instance_);
9089
9099
  }
9100
+ double timeOrigin(jsi::Runtime &rt) override {
9101
+ static_assert(
9102
+ bridging::getParameterCount(&T::timeOrigin) == 1,
9103
+ "Expected timeOrigin(...) to have 1 parameters");
9104
+
9105
+ return bridging::callFromJs<double>(
9106
+ rt, &T::timeOrigin, jsInvoker_, instance_);
9107
+ }
9090
9108
  void reportMark(jsi::Runtime &rt, jsi::String name, double startTime, jsi::Value entry) override {
9091
9109
  static_assert(
9092
9110
  bridging::getParameterCount(&T::reportMark) == 4,
package/index.js CHANGED
@@ -224,6 +224,12 @@ module.exports = {
224
224
  * @deprecated
225
225
  */
226
226
  get InteractionManager() {
227
+ warnOnce(
228
+ 'interaction-manager-deprecated',
229
+ 'InteractionManager has been deprecated and will be removed in a ' +
230
+ 'future release. Please refactor long tasks into smaller ones, and ' +
231
+ " use 'requestIdleCallback' instead.",
232
+ );
227
233
  return require('./Libraries/Interaction/InteractionManager').default;
228
234
  },
229
235
  get Keyboard() {
package/index.windows.js CHANGED
@@ -224,6 +224,12 @@ module.exports = {
224
224
  * @deprecated
225
225
  */
226
226
  get InteractionManager() {
227
+ warnOnce(
228
+ 'interaction-manager-deprecated',
229
+ 'InteractionManager has been deprecated and will be removed in a ' +
230
+ 'future release. Please refactor long tasks into smaller ones, and ' +
231
+ " use 'requestIdleCallback' instead.",
232
+ );
227
233
  return require('./Libraries/Interaction/InteractionManager').default;
228
234
  },
229
235
  get Keyboard() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.82.0-preview.1",
3
+ "version": "0.82.0-preview.11",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,16 +26,16 @@
26
26
  "@react-native-community/cli": "20.0.0",
27
27
  "@react-native-community/cli-platform-android": "20.0.0",
28
28
  "@react-native-community/cli-platform-ios": "20.0.0",
29
- "@react-native-windows/cli": "0.82.0-preview.1",
29
+ "@react-native-windows/cli": "0.82.0-preview.3",
30
30
  "@react-native/assets": "1.0.0",
31
- "@react-native/assets-registry": "0.82.0-rc.0",
32
- "@react-native/codegen": "0.82.0-rc.0",
33
- "@react-native/community-cli-plugin": "0.82.0-rc.0",
34
- "@react-native/gradle-plugin": "0.82.0-rc.0",
35
- "@react-native/js-polyfills": "0.82.0-rc.0",
36
- "@react-native/new-app-screen": "0.82.0-nightly-20250902-9731e8ebc",
37
- "@react-native/normalize-colors": "0.82.0-rc.0",
38
- "@react-native/virtualized-lists": "0.82.0-rc.0",
31
+ "@react-native/assets-registry": "0.82.1",
32
+ "@react-native/codegen": "0.82.1",
33
+ "@react-native/community-cli-plugin": "0.82.1",
34
+ "@react-native/gradle-plugin": "0.82.1",
35
+ "@react-native/js-polyfills": "0.82.1",
36
+ "@react-native/new-app-screen": "0.82.0-rc.0",
37
+ "@react-native/normalize-colors": "0.82.1",
38
+ "@react-native/virtualized-lists": "0.82.1",
39
39
  "abort-controller": "^3.0.0",
40
40
  "anser": "^1.4.9",
41
41
  "ansi-regex": "^5.0.0",
@@ -47,6 +47,7 @@
47
47
  "event-target-shim": "^5.0.1",
48
48
  "flow-enums-runtime": "^0.0.6",
49
49
  "glob": "^7.1.1",
50
+ "hermes-compiler": "0.0.0",
50
51
  "invariant": "^2.2.4",
51
52
  "jest-environment-node": "^29.7.0",
52
53
  "memoize-one": "^5.0.0",
@@ -68,8 +69,8 @@
68
69
  "yargs": "^17.6.2"
69
70
  },
70
71
  "devDependencies": {
71
- "@react-native-windows/codegen": "0.82.0-preview.1",
72
- "@react-native/metro-config": "0.82.0-rc.0",
72
+ "@react-native-windows/codegen": "0.82.0-preview.2",
73
+ "@react-native/metro-config": "0.82.1",
73
74
  "@rnw-scripts/babel-react-native-config": "0.0.0",
74
75
  "@rnw-scripts/eslint-config": "1.2.38",
75
76
  "@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.1.42",
@@ -84,7 +85,7 @@
84
85
  "just-scripts": "^1.3.3",
85
86
  "prettier": "2.8.8",
86
87
  "react": "19.1.1",
87
- "react-native": "0.82.0-rc.0",
88
+ "react-native": "0.82.1",
88
89
  "react-native-platform-override": "0.82.0-preview.1",
89
90
  "react-refresh": "^0.14.0",
90
91
  "typescript": "5.0.4"
@@ -92,7 +93,7 @@
92
93
  "peerDependencies": {
93
94
  "@types/react": "^19.1.1",
94
95
  "react": "^19.1.1",
95
- "react-native": "0.82.0-rc.0"
96
+ "react-native": "^0.82.0"
96
97
  },
97
98
  "beachball": {
98
99
  "defaultNpmTag": "preview",
@@ -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<<85a053d6a79240a7b4e181d3054ecfd3>>
7
+ * @generated SignedSource<<5ba27aa5af4c69dedd733ca5ccb09fe3>>
8
8
  * @flow strict
9
9
  * @noformat
10
10
  */
@@ -93,6 +93,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
93
93
  enableVirtualViewDebugFeatures: Getter<boolean>,
94
94
  enableVirtualViewRenderState: Getter<boolean>,
95
95
  enableVirtualViewWindowFocusDetection: Getter<boolean>,
96
+ enableWebPerformanceAPIsByDefault: Getter<boolean>,
96
97
  fixMappingOfEventPrioritiesBetweenFabricAndReact: Getter<boolean>,
97
98
  fuseboxEnabledRelease: Getter<boolean>,
98
99
  fuseboxNetworkInspectionEnabled: Getter<boolean>,
@@ -370,6 +371,10 @@ export const enableVirtualViewRenderState: Getter<boolean> = createNativeFlagGet
370
371
  * Enables window focus detection for prioritizing VirtualView events.
371
372
  */
372
373
  export const enableVirtualViewWindowFocusDetection: Getter<boolean> = createNativeFlagGetter('enableVirtualViewWindowFocusDetection', false);
374
+ /**
375
+ * Enable Web Performance APIs (Performance Timeline, User Timings, etc.) by default.
376
+ */
377
+ export const enableWebPerformanceAPIsByDefault: Getter<boolean> = createNativeFlagGetter('enableWebPerformanceAPIsByDefault', false);
373
378
  /**
374
379
  * Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
375
380
  */
@@ -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<<da22f4c43e3bdcd999e3dd1dd5896c63>>
7
+ * @generated SignedSource<<9feb9fa0298078e66d362b41d21db655>>
8
8
  * @flow strict
9
9
  * @noformat
10
10
  */
@@ -69,6 +69,7 @@ export interface Spec extends TurboModule {
69
69
  +enableVirtualViewDebugFeatures?: () => boolean;
70
70
  +enableVirtualViewRenderState?: () => boolean;
71
71
  +enableVirtualViewWindowFocusDetection?: () => boolean;
72
+ +enableWebPerformanceAPIsByDefault?: () => boolean;
72
73
  +fixMappingOfEventPrioritiesBetweenFabricAndReact?: () => boolean;
73
74
  +fuseboxEnabledRelease?: () => boolean;
74
75
  +fuseboxNetworkInspectionEnabled?: () => boolean;
@@ -12,29 +12,49 @@ import {polyfillGlobal} from '../../../Libraries/Utilities/PolyfillFunctions';
12
12
 
13
13
  let initialized = false;
14
14
 
15
- export default function setUpPerformanceObserver() {
15
+ export default function setUpPerformanceModern() {
16
16
  if (initialized) {
17
17
  return;
18
18
  }
19
19
 
20
20
  initialized = true;
21
21
 
22
+ const Performance = require('../webapis/performance/Performance').default;
23
+
24
+ // We don't use `polyfillGlobal` to define this lazily because the
25
+ // `performance` object is always accessed.
26
+ // $FlowExpectedError[cannot-write]
27
+ global.performance = new Performance();
28
+
22
29
  polyfillGlobal(
23
- 'PerformanceObserver',
30
+ 'EventCounts',
31
+ () => require('../webapis/performance/EventTiming').EventCounts_public,
32
+ );
33
+
34
+ polyfillGlobal(
35
+ 'Performance',
36
+ () => require('../webapis/performance/Performance').Performance_public,
37
+ );
38
+
39
+ polyfillGlobal(
40
+ 'PerformanceEntry',
24
41
  () =>
25
- require('../webapis/performance/PerformanceObserver').PerformanceObserver,
42
+ require('../webapis/performance/PerformanceEntry')
43
+ .PerformanceEntry_public,
26
44
  );
27
45
 
28
46
  polyfillGlobal(
29
- 'PerformanceObserverEntryList',
47
+ 'PerformanceEventTiming',
30
48
  () =>
31
- require('../webapis/performance/PerformanceObserver')
32
- .PerformanceObserverEntryList,
49
+ require('../webapis/performance/EventTiming')
50
+ .PerformanceEventTiming_public,
33
51
  );
34
52
 
35
53
  polyfillGlobal(
36
- 'PerformanceEntry',
37
- () => require('../webapis/performance/PerformanceEntry').PerformanceEntry,
54
+ 'PerformanceLongTaskTiming',
55
+ () =>
56
+ require('../webapis/performance/LongTasks')
57
+ .PerformanceLongTaskTiming_public,
38
58
  );
39
59
 
40
60
  polyfillGlobal(
@@ -44,28 +64,33 @@ export default function setUpPerformanceObserver() {
44
64
 
45
65
  polyfillGlobal(
46
66
  'PerformanceMeasure',
47
- () => require('../webapis/performance/UserTiming').PerformanceMeasure,
67
+ () =>
68
+ require('../webapis/performance/UserTiming').PerformanceMeasure_public,
48
69
  );
49
70
 
50
71
  polyfillGlobal(
51
- 'PerformanceEventTiming',
52
- () => require('../webapis/performance/EventTiming').PerformanceEventTiming,
72
+ 'PerformanceObserver',
73
+ () =>
74
+ require('../webapis/performance/PerformanceObserver').PerformanceObserver,
53
75
  );
54
76
 
55
77
  polyfillGlobal(
56
- 'PerformanceResourceTiming',
78
+ 'PerformanceObserverEntryList',
57
79
  () =>
58
- require('../webapis/performance/ResourceTiming')
59
- .PerformanceResourceTiming,
80
+ require('../webapis/performance/PerformanceObserver')
81
+ .PerformanceObserverEntryList_public,
60
82
  );
61
83
 
62
84
  polyfillGlobal(
63
- 'TaskAttributionTiming',
64
- () => require('../webapis/performance/LongTasks').TaskAttributionTiming,
85
+ 'PerformanceResourceTiming',
86
+ () =>
87
+ require('../webapis/performance/ResourceTiming')
88
+ .PerformanceResourceTiming_public,
65
89
  );
66
90
 
67
91
  polyfillGlobal(
68
- 'PerformanceLongTaskTiming',
69
- () => require('../webapis/performance/LongTasks').PerformanceLongTaskTiming,
92
+ 'TaskAttributionTiming',
93
+ () =>
94
+ require('../webapis/performance/LongTasks').TaskAttributionTiming_public,
70
95
  );
71
96
  }
@@ -55,6 +55,7 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
55
55
  supportedCommands: ['setValue'],
56
56
  });
57
57
 
58
+ // [windows #15582] removed interfaceOnly: true to generate the native component implementation
58
59
  export default (codegenNativeComponent<SwitchNativeProps>('Switch', {
59
60
  paperComponentName: 'RCTSwitch',
60
61
  excludedPlatforms: ['android'],
@@ -6,6 +6,7 @@
6
6
  *
7
7
  * @flow strict
8
8
  * @format
9
+ * @deprecated
9
10
  */
10
11
 
11
12
  import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport';
@@ -9,9 +9,9 @@
9
9
  */
10
10
 
11
11
  // flowlint unsafe-getters-setters:off
12
-
13
12
  import type {
14
13
  DOMHighResTimeStamp,
14
+ PerformanceEntryInit,
15
15
  PerformanceEntryJSON,
16
16
  } from './PerformanceEntry';
17
17
 
@@ -29,25 +29,20 @@ export type PerformanceEventTimingJSON = {
29
29
  ...
30
30
  };
31
31
 
32
+ export interface PerformanceEventTimingInit extends PerformanceEntryInit {
33
+ +processingStart?: DOMHighResTimeStamp;
34
+ +processingEnd?: DOMHighResTimeStamp;
35
+ +interactionId?: number;
36
+ }
37
+
32
38
  export class PerformanceEventTiming extends PerformanceEntry {
33
39
  #processingStart: DOMHighResTimeStamp;
34
40
  #processingEnd: DOMHighResTimeStamp;
35
41
  #interactionId: number;
36
42
 
37
- constructor(init: {
38
- name: string,
39
- startTime?: DOMHighResTimeStamp,
40
- duration?: DOMHighResTimeStamp,
41
- processingStart?: DOMHighResTimeStamp,
42
- processingEnd?: DOMHighResTimeStamp,
43
- interactionId?: number,
44
- }) {
45
- super({
46
- name: init.name,
47
- entryType: 'event',
48
- startTime: init.startTime ?? 0,
49
- duration: init.duration ?? 0,
50
- });
43
+ constructor(init: PerformanceEventTimingInit) {
44
+ super('event', init);
45
+
51
46
  this.#processingStart = init.processingStart ?? 0;
52
47
  this.#processingEnd = init.processingEnd ?? 0;
53
48
  this.#interactionId = init.interactionId ?? 0;
@@ -75,6 +70,18 @@ export class PerformanceEventTiming extends PerformanceEntry {
75
70
  }
76
71
  }
77
72
 
73
+ export const PerformanceEventTiming_public: typeof PerformanceEventTiming =
74
+ /* eslint-disable no-shadow */
75
+ // $FlowExpectedError[incompatible-type]
76
+ function PerformanceEventTiming() {
77
+ throw new TypeError(
78
+ "Failed to construct 'PerformanceEventTiming': Illegal constructor",
79
+ );
80
+ };
81
+
82
+ // $FlowExpectedError[prop-missing]
83
+ PerformanceEventTiming_public.prototype = PerformanceEventTiming.prototype;
84
+
78
85
  type EventCountsForEachCallbackType =
79
86
  | (() => void)
80
87
  | ((value: number) => void)
@@ -139,3 +146,15 @@ export class EventCounts {
139
146
  return getCachedEventCounts().values();
140
147
  }
141
148
  }
149
+
150
+ export const EventCounts_public: typeof EventCounts =
151
+ /* eslint-disable no-shadow */
152
+ // $FlowExpectedError[incompatible-type]
153
+ function EventCounts() {
154
+ throw new TypeError(
155
+ "Failed to construct 'EventCounts': Illegal constructor",
156
+ );
157
+ };
158
+
159
+ // $FlowExpectedError[prop-missing]
160
+ EventCounts_public.prototype = EventCounts.prototype;
@@ -9,8 +9,10 @@
9
9
  */
10
10
 
11
11
  // flowlint unsafe-getters-setters:off
12
-
13
- import type {PerformanceEntryJSON} from './PerformanceEntry';
12
+ import type {
13
+ PerformanceEntryInit,
14
+ PerformanceEntryJSON,
15
+ } from './PerformanceEntry';
14
16
 
15
17
  import {PerformanceEntry} from './PerformanceEntry';
16
18
 
@@ -22,10 +24,28 @@ export type PerformanceLongTaskTimingJSON = {
22
24
 
23
25
  export class TaskAttributionTiming extends PerformanceEntry {}
24
26
 
27
+ export const TaskAttributionTiming_public: typeof TaskAttributionTiming =
28
+ /* eslint-disable no-shadow */
29
+ // $FlowExpectedError[incompatible-type]
30
+ function TaskAttributionTiming() {
31
+ throw new TypeError(
32
+ "Failed to construct 'TaskAttributionTiming': Illegal constructor",
33
+ );
34
+ };
35
+
36
+ // $FlowExpectedError[prop-missing]
37
+ TaskAttributionTiming_public.prototype = TaskAttributionTiming.prototype;
38
+
25
39
  const EMPTY_ATTRIBUTION: $ReadOnlyArray<TaskAttributionTiming> =
26
40
  Object.preventExtensions([]);
27
41
 
42
+ export interface PerformanceLongTaskTimingInit extends PerformanceEntryInit {}
43
+
28
44
  export class PerformanceLongTaskTiming extends PerformanceEntry {
45
+ constructor(init: PerformanceEntryInit) {
46
+ super('longtask', init);
47
+ }
48
+
29
49
  get attribution(): $ReadOnlyArray<TaskAttributionTiming> {
30
50
  return EMPTY_ATTRIBUTION;
31
51
  }
@@ -37,3 +57,16 @@ export class PerformanceLongTaskTiming extends PerformanceEntry {
37
57
  };
38
58
  }
39
59
  }
60
+
61
+ export const PerformanceLongTaskTiming_public: typeof PerformanceLongTaskTiming =
62
+ /* eslint-disable no-shadow */
63
+ // $FlowExpectedError[incompatible-type]
64
+ function PerformanceLongTaskTiming() {
65
+ throw new TypeError(
66
+ "Failed to construct 'PerformanceLongTaskTiming': Illegal constructor",
67
+ );
68
+ };
69
+
70
+ // $FlowExpectedError[prop-missing]
71
+ PerformanceLongTaskTiming_public.prototype =
72
+ PerformanceLongTaskTiming.prototype;
@@ -63,13 +63,15 @@ const cachedReportMeasure = NativePerformance.reportMeasure;
63
63
  const cachedGetMarkTime = NativePerformance.getMarkTime;
64
64
  const cachedNativeClearMarks = NativePerformance.clearMarks;
65
65
  const cachedNativeClearMeasures = NativePerformance.clearMeasures;
66
+ let cachedTimeOrigin: ?DOMHighResTimeStamp;
66
67
 
67
- const MARK_OPTIONS_REUSABLE_OBJECT: {...PerformanceMarkOptions} = {
68
+ const MARK_OPTIONS_REUSABLE_OBJECT: PerformanceMarkOptions = {
68
69
  startTime: 0,
69
70
  detail: undefined,
70
71
  };
71
72
 
72
- const MEASURE_OPTIONS_REUSABLE_OBJECT: {...PerformanceMeasureInit} = {
73
+ const MEASURE_OPTIONS_REUSABLE_OBJECT: PerformanceMeasureInit = {
74
+ name: '',
73
75
  startTime: 0,
74
76
  duration: 0,
75
77
  detail: undefined,
@@ -92,7 +94,11 @@ const getMarkTimeForMeasure = (markName: string): number => {
92
94
  * https://www.w3.org/TR/user-timing/#extensions-performance-interface
93
95
  */
94
96
  export default class Performance {
95
- eventCounts: EventCounts = new EventCounts();
97
+ #eventCounts: EventCounts = new EventCounts();
98
+
99
+ get eventCounts(): EventCounts {
100
+ return this.#eventCounts;
101
+ }
96
102
 
97
103
  // Get the current JS memory information.
98
104
  get memory(): MemoryInfo {
@@ -122,22 +128,36 @@ export default class Performance {
122
128
  get rnStartupTiming(): ReactNativeStartupTiming {
123
129
  const {
124
130
  startTime,
125
- endTime,
126
131
  initializeRuntimeStart,
127
- initializeRuntimeEnd,
128
132
  executeJavaScriptBundleEntryPointStart,
129
- executeJavaScriptBundleEntryPointEnd,
133
+ endTime,
130
134
  } = NativePerformance.getReactNativeStartupTiming();
131
135
  return new ReactNativeStartupTiming({
132
136
  startTime,
133
- endTime,
134
137
  initializeRuntimeStart,
135
- initializeRuntimeEnd,
136
138
  executeJavaScriptBundleEntryPointStart,
137
- executeJavaScriptBundleEntryPointEnd,
139
+ endTime,
138
140
  });
139
141
  }
140
142
 
143
+ /**
144
+ * Returns the high resolution timestamp that is used as the baseline for
145
+ * performance-related timestamps.
146
+ * https://developer.mozilla.org/en-US/docs/Web/API/Performance/timeOrigin
147
+ */
148
+ get timeOrigin(): DOMHighResTimeStamp {
149
+ if (cachedTimeOrigin == null) {
150
+ if (NativePerformance.timeOrigin) {
151
+ cachedTimeOrigin = NativePerformance?.timeOrigin();
152
+ } else {
153
+ // Very naive polyfill.
154
+ cachedTimeOrigin = Date.now() - getCurrentTimeStamp();
155
+ }
156
+ }
157
+
158
+ return cachedTimeOrigin;
159
+ }
160
+
141
161
  mark(
142
162
  markName: string,
143
163
  markOptions?: PerformanceMarkOptions,
@@ -189,7 +209,9 @@ export default class Performance {
189
209
  resolvedDetail = structuredClone(detail);
190
210
  }
191
211
 
212
+ // $FlowExpectedError[cannot-write]
192
213
  MARK_OPTIONS_REUSABLE_OBJECT.startTime = resolvedStartTime;
214
+ // $FlowExpectedError[cannot-write]
193
215
  MARK_OPTIONS_REUSABLE_OBJECT.detail = resolvedDetail;
194
216
 
195
217
  const entry = new PerformanceMark(
@@ -367,14 +389,16 @@ export default class Performance {
367
389
  }
368
390
  }
369
391
 
392
+ // $FlowExpectedError[cannot-write]
393
+ MEASURE_OPTIONS_REUSABLE_OBJECT.name = resolvedMeasureName;
394
+ // $FlowExpectedError[cannot-write]
370
395
  MEASURE_OPTIONS_REUSABLE_OBJECT.startTime = resolvedStartTime;
396
+ // $FlowExpectedError[cannot-write]
371
397
  MEASURE_OPTIONS_REUSABLE_OBJECT.duration = resolvedDuration;
398
+ // $FlowExpectedError[cannot-write]
372
399
  MEASURE_OPTIONS_REUSABLE_OBJECT.detail = resolvedDetail;
373
400
 
374
- const entry = new PerformanceMeasure(
375
- resolvedMeasureName,
376
- MEASURE_OPTIONS_REUSABLE_OBJECT,
377
- );
401
+ const entry = new PerformanceMeasure(MEASURE_OPTIONS_REUSABLE_OBJECT);
378
402
 
379
403
  cachedReportMeasure(
380
404
  resolvedMeasureName,
@@ -438,4 +462,16 @@ export default class Performance {
438
462
  }
439
463
  }
440
464
 
465
+ export const Performance_public: typeof Performance =
466
+ /* eslint-disable no-shadow */
467
+ // $FlowExpectedError[incompatible-type]
468
+ function Performance() {
469
+ throw new TypeError(
470
+ "Failed to construct 'Performance': Illegal constructor",
471
+ );
472
+ };
473
+
474
+ // $FlowExpectedError[prop-missing]
475
+ Performance_public.prototype = Performance.prototype;
476
+
441
477
  setPlatformObject(Performance);
@@ -28,24 +28,25 @@ export type PerformanceEntryJSON = {
28
28
  ...
29
29
  };
30
30
 
31
+ export interface PerformanceEntryInit {
32
+ +name: string;
33
+ +startTime: DOMHighResTimeStamp;
34
+ +duration: DOMHighResTimeStamp;
35
+ }
36
+
31
37
  export class PerformanceEntry {
32
38
  // We don't use private fields because they're significantly slower to
33
39
  // initialize on construction and to access.
34
40
  // We also need these to be protected so they can be initialized in subclasses
35
41
  // where we avoid calling `super()` for performance reasons.
36
- __name: string;
37
42
  __entryType: PerformanceEntryType;
43
+ __name: string;
38
44
  __startTime: DOMHighResTimeStamp;
39
45
  __duration: DOMHighResTimeStamp;
40
46
 
41
- constructor(init: {
42
- name: string,
43
- entryType: PerformanceEntryType,
44
- startTime: DOMHighResTimeStamp,
45
- duration: DOMHighResTimeStamp,
46
- }) {
47
+ constructor(entryType: PerformanceEntryType, init: PerformanceEntryInit) {
48
+ this.__entryType = entryType;
47
49
  this.__name = init.name;
48
- this.__entryType = init.entryType;
49
50
  this.__startTime = init.startTime;
50
51
  this.__duration = init.duration;
51
52
  }
@@ -76,6 +77,18 @@ export class PerformanceEntry {
76
77
  }
77
78
  }
78
79
 
80
+ export const PerformanceEntry_public: typeof PerformanceEntry =
81
+ /* eslint-disable no-shadow */
82
+ // $FlowExpectedError[incompatible-type]
83
+ function PerformanceEntry() {
84
+ throw new TypeError(
85
+ "Failed to construct 'PerformanceEntry': Illegal constructor",
86
+ );
87
+ };
88
+
89
+ // $FlowExpectedError[prop-missing]
90
+ PerformanceEntry_public.prototype = PerformanceEntry.prototype;
91
+
79
92
  setPlatformObject(PerformanceEntry);
80
93
 
81
94
  export type PerformanceEntryList = $ReadOnlyArray<PerformanceEntry>;
@@ -57,6 +57,19 @@ export class PerformanceObserverEntryList {
57
57
  }
58
58
  }
59
59
 
60
+ export const PerformanceObserverEntryList_public: typeof PerformanceObserverEntryList =
61
+ /* eslint-disable no-shadow */
62
+ // $FlowExpectedError[incompatible-type]
63
+ function PerformanceObserverEntryList() {
64
+ throw new TypeError(
65
+ "Failed to construct 'PerformanceObserverEntryList': Illegal constructor",
66
+ );
67
+ };
68
+
69
+ // $FlowExpectedError[prop-missing]
70
+ PerformanceObserverEntryList_public.prototype =
71
+ PerformanceObserverEntryList.prototype;
72
+
60
73
  export type PerformanceObserverCallbackOptions = {
61
74
  droppedEntriesCount: number,
62
75
  };
@@ -145,6 +158,22 @@ export class PerformanceObserver {
145
158
  NativePerformance.disconnect(this.#nativeObserverHandle);
146
159
  }
147
160
 
161
+ takeRecords(): PerformanceEntryList {
162
+ let entries: PerformanceEntryList = [];
163
+
164
+ if (this.#nativeObserverHandle != null) {
165
+ const rawEntries = NativePerformance.takeRecords(
166
+ this.#nativeObserverHandle,
167
+ true,
168
+ );
169
+ if (rawEntries && rawEntries.length > 0) {
170
+ entries = rawEntries.map(rawToPerformanceEntry);
171
+ }
172
+ }
173
+
174
+ return entries;
175
+ }
176
+
148
177
  #createNativeObserver(): OpaqueNativeObserverHandle | null {
149
178
  this.#calledAtLeastOnce = false;
150
179
 
@@ -154,7 +183,7 @@ export class PerformanceObserver {
154
183
  observerHandle,
155
184
  true, // sort records
156
185
  );
157
- if (!rawEntries) {
186
+ if (!rawEntries || rawEntries.length === 0) {
158
187
  return;
159
188
  }
160
189