react-native 0.82.0-rc.0 → 0.82.0-rc.3

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 (94) hide show
  1. package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
  2. package/Libraries/BatchedBridge/MessageQueue.js +1 -0
  3. package/Libraries/Core/ReactNativeVersion.js +1 -1
  4. package/Libraries/Core/Timers/JSTimers.js +1 -0
  5. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  6. package/Libraries/Core/Timers/immediateShim.js +1 -0
  7. package/Libraries/Core/setUpPerformance.js +3 -5
  8. package/React/Base/RCTVersion.m +1 -1
  9. package/React/CoreModules/RCTAlertController.mm +6 -1
  10. package/React/FBReactNativeSpec/FBReactNativeSpecJSI-generated.cpp +12 -0
  11. package/React/FBReactNativeSpec/FBReactNativeSpecJSI.h +18 -0
  12. package/ReactAndroid/build.gradle.kts +7 -0
  13. package/ReactAndroid/gradle.properties +2 -1
  14. package/ReactAndroid/hermes-engine/build.gradle.kts +28 -7
  15. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +7 -1
  16. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +11 -1
  17. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +3 -1
  18. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +3 -1
  19. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +12 -1
  20. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Canary_Android.kt +3 -1
  21. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +3 -1
  22. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  23. package/ReactAndroid/src/main/jni/CMakeLists.txt +5 -0
  24. package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +15 -1
  25. package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +4 -1
  26. package/ReactAndroid/src/main/jni/react/hermes/reactexecutor/CMakeLists.txt +4 -0
  27. package/ReactAndroid/src/main/jni/react/runtime/hermes/jni/CMakeLists.txt +4 -0
  28. package/ReactAndroid/src/main/jni/react/runtime/jni/CMakeLists.txt +4 -0
  29. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  30. package/ReactCommon/hermes/executor/CMakeLists.txt +4 -0
  31. package/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +8 -5
  32. package/ReactCommon/hermes/inspector-modern/CMakeLists.txt +4 -0
  33. package/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.cpp +2 -2
  34. package/ReactCommon/hermes/inspector-modern/chrome/ConnectionDemux.h +2 -2
  35. package/ReactCommon/hermes/inspector-modern/chrome/Registration.cpp +2 -2
  36. package/ReactCommon/hermes/inspector-modern/chrome/Registration.h +2 -2
  37. package/ReactCommon/jsinspector-modern/React-jsinspector.podspec +2 -0
  38. package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +5 -1
  39. package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +6 -1
  40. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +44 -26
  41. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +4 -2
  42. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +5 -1
  43. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +10 -1
  44. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSCanary.h +5 -1
  45. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +2 -1
  46. package/ReactCommon/react/nativemodule/defaults/CMakeLists.txt +1 -0
  47. package/ReactCommon/react/nativemodule/defaults/DefaultTurboModules.cpp +8 -0
  48. package/ReactCommon/react/nativemodule/defaults/React-defaultsnativemodule.podspec +1 -0
  49. package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +6 -1
  50. package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +3 -1
  51. package/ReactCommon/react/nativemodule/webperformance/CMakeLists.txt +1 -1
  52. package/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp +9 -9
  53. package/ReactCommon/react/nativemodule/webperformance/NativePerformance.h +3 -0
  54. package/ReactCommon/react/nativemodule/webperformance/React-webperformancenativemodule.podspec +58 -0
  55. package/ReactCommon/react/runtime/CMakeLists.txt +4 -0
  56. package/ReactCommon/react/runtime/hermes/CMakeLists.txt +4 -0
  57. package/ReactCommon/react/runtime/hermes/HermesInstance.cpp +7 -3
  58. package/ReactCommon/react/timing/primitives.h +12 -0
  59. package/flow/bom.js.flow +158 -1
  60. package/package.json +9 -8
  61. package/scripts/cocoapods/autolinking.rb +6 -0
  62. package/scripts/cocoapods/codegen_utils.rb +1 -1
  63. package/scripts/cocoapods/jsengine.rb +2 -1
  64. package/scripts/cocoapods/utils.rb +8 -2
  65. package/scripts/codegen/generate-artifacts-executor/index.js +5 -6
  66. package/scripts/codegen/generate-artifacts-executor/utils.js +41 -10
  67. package/scripts/react_native_pods.rb +1 -0
  68. package/scripts/replace-rncore-version.js +4 -2
  69. package/sdks/hermes-engine/hermes-engine.podspec +35 -12
  70. package/sdks/hermes-engine/hermes-utils.rb +41 -10
  71. package/sdks/hermes-engine/utils/build-apple-framework.sh +7 -1
  72. package/sdks/hermes-engine/utils/build-hermes-xcode.sh +8 -1
  73. package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +1 -1
  74. package/sdks/hermes-engine/utils/replace_hermes_version.js +4 -2
  75. package/sdks/hermes-engine/version.properties +1 -0
  76. package/sdks/hermesc/osx-bin/hermes +0 -0
  77. package/sdks/hermesc/osx-bin/hermesc +0 -0
  78. package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
  79. package/settings.gradle.kts +9 -0
  80. package/src/private/featureflags/ReactNativeFeatureFlags.js +6 -1
  81. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -1
  82. package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
  83. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
  84. package/src/private/webapis/performance/EventTiming.js +34 -15
  85. package/src/private/webapis/performance/LongTasks.js +35 -2
  86. package/src/private/webapis/performance/Performance.js +49 -13
  87. package/src/private/webapis/performance/PerformanceEntry.js +21 -8
  88. package/src/private/webapis/performance/PerformanceObserver.js +30 -1
  89. package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
  90. package/src/private/webapis/performance/ResourceTiming.js +29 -18
  91. package/src/private/webapis/performance/UserTiming.js +33 -28
  92. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
  93. package/src/private/webapis/performance/specs/NativePerformance.js +2 -0
  94. package/third-party-podspecs/replace_dependencies_version.js +4 -2
@@ -85,6 +85,10 @@ def hermes_commit_envvar_defined()
85
85
  return ENV.has_key?('HERMES_COMMIT')
86
86
  end
87
87
 
88
+ def hermes_v1_enabled()
89
+ return ENV['RCT_HERMES_V1_ENABLED'] == "1"
90
+ end
91
+
88
92
  def force_build_from_tag(react_native_path)
89
93
  return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && File.exist?(hermestag_file(react_native_path))
90
94
  end
@@ -170,13 +174,19 @@ end
170
174
 
171
175
  def podspec_source_build_from_github_tag(react_native_path)
172
176
  tag = File.read(hermestag_file(react_native_path)).strip
173
- hermes_log("Using tag difined in sdks/.hermesversion: #{tag}")
177
+
178
+ if hermes_v1_enabled()
179
+ hermes_log("Using tag defined in sdks/.hermesv1version: #{tag}")
180
+ else
181
+ hermes_log("Using tag defined in sdks/.hermesversion: #{tag}")
182
+ end
174
183
  return {:git => HERMES_GITHUB_URL, :tag => tag}
175
184
  end
176
185
 
177
186
  def podspec_source_build_from_github_main()
178
- hermes_log("Using the latest commit from main.")
179
- return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} main | cut -f 1`.strip}
187
+ branch = hermes_v1_enabled() ? "250829098.0.0-stable" : "main"
188
+ hermes_log("Using the latest commit from #{branch}.")
189
+ return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} #{branch} | cut -f 1`.strip}
180
190
  end
181
191
 
182
192
  def podspec_source_download_prebuild_release_tarball(react_native_path, version)
@@ -200,7 +210,11 @@ def artifacts_dir()
200
210
  end
201
211
 
202
212
  def hermestag_file(react_native_path)
203
- return File.join(react_native_path, "sdks", ".hermesversion")
213
+ if hermes_v1_enabled()
214
+ return File.join(react_native_path, "sdks", ".hermesv1version")
215
+ else
216
+ return File.join(react_native_path, "sdks", ".hermesversion")
217
+ end
204
218
  end
205
219
 
206
220
  def release_tarball_url(version, build_type)
@@ -210,10 +224,18 @@ def release_tarball_url(version, build_type)
210
224
  ENV['ENTERPRISE_REPOSITORY'] != nil && ENV['ENTERPRISE_REPOSITORY'] != "" ?
211
225
  ENV['ENTERPRISE_REPOSITORY'] :
212
226
  "https://repo1.maven.org/maven2"
213
- namespace = "com/facebook/react"
214
- # Sample url from Maven:
215
- # https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.0/react-native-artifacts-0.71.0-hermes-ios-debug.tar.gz
216
- return "#{maven_repo_url}/#{namespace}/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
227
+
228
+ if hermes_v1_enabled()
229
+ namespace = "com/facebook/hermes"
230
+ # Sample url from Maven:
231
+ # https://repo1.maven.org/maven2/com/facebook/hermes/hermes-ios/0.14.0/hermes-ios-0.14.0-debug.tar.gz
232
+ return "#{maven_repo_url}/#{namespace}/hermes-ios/#{version}/hermes-ios-#{version}-#{build_type.to_s}.tar.gz"
233
+ else
234
+ namespace = "com/facebook/react"
235
+ # Sample url from Maven:
236
+ # https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.0/react-native-artifacts-0.71.0-hermes-ios-debug.tar.gz
237
+ return "#{maven_repo_url}/#{namespace}/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
238
+ end
217
239
  end
218
240
 
219
241
  def download_stable_hermes(react_native_path, version, configuration)
@@ -235,9 +257,18 @@ def download_hermes_tarball(react_native_path, tarball_url, version, configurati
235
257
  end
236
258
 
237
259
  def nightly_tarball_url(version)
260
+ # TODO: T231755027 update coordinates and versioning
238
261
  artifact_coordinate = "react-native-artifacts"
239
262
  artifact_name = "hermes-ios-debug.tar.gz"
240
- xml_url = "https://central.sonatype.com/repository/maven-snapshots/com/facebook/react/#{artifact_coordinate}/#{version}-SNAPSHOT/maven-metadata.xml"
263
+ namespace = "com/facebook/react"
264
+
265
+ if hermes_v1_enabled()
266
+ artifact_coordinate = "hermes-ios"
267
+ artifact_name = "hermes-ios-debug.tar.gz"
268
+ namespace = "com/facebook/hermes"
269
+ end
270
+
271
+ xml_url = "https://central.sonatype.com/repository/maven-snapshots/#{namespace}/#{artifact_coordinate}/#{version}-SNAPSHOT/maven-metadata.xml"
241
272
 
242
273
  response = Net::HTTP.get_response(URI(xml_url))
243
274
  if response.is_a?(Net::HTTPSuccess)
@@ -245,7 +276,7 @@ def nightly_tarball_url(version)
245
276
  timestamp = xml.elements['metadata/versioning/snapshot/timestamp'].text
246
277
  build_number = xml.elements['metadata/versioning/snapshot/buildNumber'].text
247
278
  full_version = "#{version}-#{timestamp}-#{build_number}"
248
- final_url = "https://central.sonatype.com/repository/maven-snapshots/com/facebook/react/#{artifact_coordinate}/#{version}-SNAPSHOT/#{artifact_coordinate}-#{full_version}-#{artifact_name}"
279
+ final_url = "https://central.sonatype.com/repository/maven-snapshots/#{namespace}/#{artifact_coordinate}/#{version}-SNAPSHOT/#{artifact_coordinate}-#{full_version}-#{artifact_name}"
249
280
 
250
281
  return final_url
251
282
  else
@@ -88,6 +88,11 @@ function configure_apple_framework {
88
88
  xcode_15_flags="LINKER:-ld_classic"
89
89
  fi
90
90
 
91
+ boost_context_flag=""
92
+ if [[ $1 == "catalyst" ]]; then
93
+ boost_context_flag="-DHERMES_ALLOW_BOOST_CONTEXT=0"
94
+ fi
95
+
91
96
  pushd "$HERMES_PATH" > /dev/null || exit 1
92
97
  cmake -S . -B "build_$1" \
93
98
  -DHERMES_EXTRA_LINKER_FLAGS="$xcode_15_flags" \
@@ -107,7 +112,8 @@ function configure_apple_framework {
107
112
  -DIMPORT_HOST_COMPILERS:PATH="$IMPORT_HOST_COMPILERS_PATH" \
108
113
  -DJSI_DIR="$JSI_PATH" \
109
114
  -DHERMES_RELEASE_VERSION="for RN $(get_release_version)" \
110
- -DCMAKE_BUILD_TYPE="$cmake_build_type"
115
+ -DCMAKE_BUILD_TYPE="$cmake_build_type" \
116
+ $boost_context_flag
111
117
  popd > /dev/null || exit 1
112
118
  }
113
119
 
@@ -59,6 +59,11 @@ if [[ $xcode_major_version -ge 15 ]]; then
59
59
  xcode_15_flags="LINKER:-ld_classic"
60
60
  fi
61
61
 
62
+ boost_context_flag=""
63
+ if [[ $PLATFORM_NAME == "catalyst" ]]; then
64
+ boost_context_flag="-DHERMES_ALLOW_BOOST_CONTEXT=0"
65
+ fi
66
+
62
67
  architectures=$( echo "$ARCHS" | tr " " ";" )
63
68
 
64
69
  echo "Configure Apple framework"
@@ -83,7 +88,8 @@ echo "Configure Apple framework"
83
88
  -DIMPORT_HOST_COMPILERS:PATH="${hermesc_path}" \
84
89
  -DJSI_DIR="$jsi_path" \
85
90
  -DHERMES_RELEASE_VERSION="for RN $release_version" \
86
- -DCMAKE_BUILD_TYPE="$cmake_build_type"
91
+ -DCMAKE_BUILD_TYPE="$cmake_build_type" \
92
+ $boost_context_flag
87
93
 
88
94
  echo "Build Apple framework"
89
95
 
@@ -96,6 +102,7 @@ echo "Copy Apple framework to destroot/Library/Frameworks"
96
102
 
97
103
  platform_copy_destination=$(get_platform_copy_destination $PLATFORM_NAME)
98
104
 
105
+ mkdir -p "${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/${platform_copy_destination}"
99
106
  cp -pfR \
100
107
  "${PODS_ROOT}/hermes-engine/build/${PLATFORM_NAME}/lib/hermesvm.framework" \
101
108
  "${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/${platform_copy_destination}"
@@ -18,7 +18,7 @@ SDKROOT=$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
18
18
  env -i \
19
19
  PATH="$PATH" \
20
20
  SDKROOT="$SDKROOT" \
21
- "$CMAKE_BINARY" -S "${PODS_ROOT}/hermes-engine" -B "$hermesc_dir_path" -DJSI_DIR="$jsi_path"
21
+ "$CMAKE_BINARY" -S "${PODS_ROOT}/hermes-engine" -B "$hermesc_dir_path" -DJSI_DIR="$jsi_path" -DCMAKE_BUILD_TYPE=Release
22
22
 
23
23
  env -i \
24
24
  PATH="$PATH" \
@@ -10,7 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const {execSync} = require('child_process');
13
+ const {spawnSync} = require('child_process');
14
14
  const fs = require('fs');
15
15
  const yargs = require('yargs');
16
16
 
@@ -62,7 +62,9 @@ function replaceHermesConfiguration(configuration, version, podsRoot) {
62
62
  fs.mkdirSync(finalLocation, {recursive: true});
63
63
 
64
64
  console.log('Extracting the tarball');
65
- execSync(`tar -xf ${tarballURLPath} -C ${finalLocation}`);
65
+ spawnSync('tar', ['-xf', tarballURLPath, '-C', finalLocation], {
66
+ stdio: 'inherit',
67
+ });
66
68
  }
67
69
 
68
70
  function updateLastBuildConfiguration(configuration) {
@@ -0,0 +1 @@
1
+ HERMES_V1_VERSION_NAME=250829098.0.0
Binary file
Binary file
Binary file
@@ -29,3 +29,12 @@ include(":packages:react-native:ReactAndroid:hermes-engine")
29
29
 
30
30
  project(":packages:react-native:ReactAndroid:hermes-engine").projectDir =
31
31
  file("ReactAndroid/hermes-engine/")
32
+
33
+ // Since Gradle 9.0, all the projects in the path must have an existing folder.
34
+ // As we build :packages:react-native:ReactAndroid, we need to declare the folders
35
+ // for :packages and :packages:react-native as well as otherwise the build from
36
+ // source will fail with a missing folder exception.
37
+
38
+ project(":packages").projectDir = file("/tmp")
39
+
40
+ project(":packages:react-native").projectDir = file("/tmp")
@@ -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
  }
@@ -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>;