From 16b80a5f6a17f6ec0a6aa7e8a00cd780478da87f Mon Sep 17 00:00:00 2001 From: Edmond Chui <1967998+EdmondChuiHW@users.noreply.github.com> Date: Tue, 12 Mar 2024 00:45:08 +0000 Subject: [PATCH] move --- config/gni/devtools_grd_files.gni | 4 +--- front_end/core/host/BUILD.gn | 1 + .../Impl.ts => core/host/RNPerfMetrics.ts} | 18 +++++++++++++++-- front_end/core/host/host.ts | 3 +++ front_end/entrypoints/rn_inspector/BUILD.gn | 1 - .../entrypoints/rn_inspector/rn_inspector.ts | 5 ++--- .../rn_inspector/rn_perf_metrics/BUILD.gn | 20 ------------------- .../rn_perf_metrics/RNPerfMetricsEvent.d.ts | 6 ------ .../rn_inspector/rn_perf_metrics/Utils.ts | 16 --------------- .../rn_perf_metrics/rn_perf_metrics.ts | 12 ----------- 10 files changed, 23 insertions(+), 63 deletions(-) rename front_end/{entrypoints/rn_inspector/rn_perf_metrics/Impl.ts => core/host/RNPerfMetrics.ts} (75%) delete mode 100644 front_end/entrypoints/rn_inspector/rn_perf_metrics/BUILD.gn delete mode 100644 front_end/entrypoints/rn_inspector/rn_perf_metrics/RNPerfMetricsEvent.d.ts delete mode 100644 front_end/entrypoints/rn_inspector/rn_perf_metrics/Utils.ts delete mode 100644 front_end/entrypoints/rn_inspector/rn_perf_metrics/rn_perf_metrics.ts diff --git a/config/gni/devtools_grd_files.gni b/config/gni/devtools_grd_files.gni index 109484f1780..19d4084b012 100644 --- a/config/gni/devtools_grd_files.gni +++ b/config/gni/devtools_grd_files.gni @@ -701,6 +701,7 @@ grd_files_debug_sources = [ "front_end/core/host/InspectorFrontendHost.js", "front_end/core/host/InspectorFrontendHostAPI.js", "front_end/core/host/Platform.js", + "front_end/core/host/RNPerfMetrics.js", "front_end/core/host/ResourceLoader.js", "front_end/core/host/UserMetrics.js", "front_end/core/i18n/DevToolsLocale.js", @@ -829,9 +830,6 @@ grd_files_debug_sources = [ "front_end/entrypoints/node_app/NodeConnectionsPanel.js", "front_end/entrypoints/node_app/NodeMain.js", "front_end/entrypoints/node_app/nodeConnectionsPanel.css.js", - "front_end/entrypoints/rn_inspector/rn_perf_metrics/Impl.js", - "front_end/entrypoints/rn_inspector/rn_perf_metrics/Utils.js", - "front_end/entrypoints/rn_inspector/rn_perf_metrics/rn_perf_metrics.js", "front_end/entrypoints/wasmparser_worker/WasmParserWorker.js", "front_end/entrypoints/worker_app/WorkerMain.js", "front_end/generated/ARIAProperties.js", diff --git a/front_end/core/host/BUILD.gn b/front_end/core/host/BUILD.gn index 0d9f614f4ab..1ac8bda8149 100644 --- a/front_end/core/host/BUILD.gn +++ b/front_end/core/host/BUILD.gn @@ -10,6 +10,7 @@ devtools_module("host") { "InspectorFrontendHost.ts", "InspectorFrontendHostAPI.ts", "Platform.ts", + "RNPerfMetrics.ts", "ResourceLoader.ts", "UserMetrics.ts", ] diff --git a/front_end/entrypoints/rn_inspector/rn_perf_metrics/Impl.ts b/front_end/core/host/RNPerfMetrics.ts similarity index 75% rename from front_end/entrypoints/rn_inspector/rn_perf_metrics/Impl.ts rename to front_end/core/host/RNPerfMetrics.ts index d4c6c53f76b..acf63b4e040 100644 --- a/front_end/entrypoints/rn_inspector/rn_perf_metrics/Impl.ts +++ b/front_end/core/host/RNPerfMetrics.ts @@ -1,10 +1,12 @@ +// Copyright 2024 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // Copyright (c) Meta Platforms, Inc. and affiliates. // Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import {type ReactNativeChromeDevToolsEvent} from './RNPerfMetricsEvent.js'; - export type RNReliabilityEventListener = (event: ReactNativeChromeDevToolsEvent) => void; type UnsunscribeFn = () => void; @@ -60,3 +62,15 @@ class RNPerfMetricsImpl implements RNPerfMetrics { } } } + +export function registerGlobalPerfMetricsListener(): void { + if (globalThis.enableReactNativePerfMetrics !== true) { + return; + } + + getInstance().addEventListener(event => { + window.postMessage({event, tag: 'react-native-chrome-devtools-perf-metrics'}, window.location.origin); + }); +} + +export type ReactNativeChromeDevToolsEvent = {}; diff --git a/front_end/core/host/host.ts b/front_end/core/host/host.ts index d7823b710d2..b1e6c207e7e 100644 --- a/front_end/core/host/host.ts +++ b/front_end/core/host/host.ts @@ -6,6 +6,7 @@ import * as InspectorFrontendHost from './InspectorFrontendHost.js'; import * as InspectorFrontendHostAPI from './InspectorFrontendHostAPI.js'; import * as Platform from './Platform.js'; import * as ResourceLoader from './ResourceLoader.js'; +import * as RNPerfMetrics from './RNPerfMetrics.js'; import * as UserMetrics from './UserMetrics.js'; export { @@ -13,7 +14,9 @@ export { InspectorFrontendHostAPI, Platform, ResourceLoader, + RNPerfMetrics, UserMetrics, }; export const userMetrics = new UserMetrics.UserMetrics(); +export const rnPerfMetrics = RNPerfMetrics.getInstance(); diff --git a/front_end/entrypoints/rn_inspector/BUILD.gn b/front_end/entrypoints/rn_inspector/BUILD.gn index c4cf7e38a54..8b2ec72c46b 100644 --- a/front_end/entrypoints/rn_inspector/BUILD.gn +++ b/front_end/entrypoints/rn_inspector/BUILD.gn @@ -35,7 +35,6 @@ devtools_entrypoint("entrypoint") { "../../panels/webauthn:meta", "../main:bundle", "../shell", - "rn_perf_metrics:rn_perf_metrics", ] visibility = [ "../../:*" ] diff --git a/front_end/entrypoints/rn_inspector/rn_inspector.ts b/front_end/entrypoints/rn_inspector/rn_inspector.ts index 165065ad927..184ae0fb594 100644 --- a/front_end/entrypoints/rn_inspector/rn_inspector.ts +++ b/front_end/entrypoints/rn_inspector/rn_inspector.ts @@ -14,12 +14,11 @@ import '../../panels/network/network-meta.js'; import '../../panels/js_profiler/js_profiler-meta.js'; import '../../panels/rn_welcome/rn_welcome-meta.js'; +import * as Host from '../../core/host/host.js'; import * as Root from '../../core/root/root.js'; import * as Main from '../main/main.js'; -import * as RNPerfMetrics from './rn_perf_metrics/rn_perf_metrics.js'; - -RNPerfMetrics.Utils.registerGlobalPerfMetricsListener(); +Host.RNPerfMetrics.registerGlobalPerfMetricsListener(); // Legacy JavaScript Profiler - we support this until Hermes can support the // modern Performance panel. diff --git a/front_end/entrypoints/rn_inspector/rn_perf_metrics/BUILD.gn b/front_end/entrypoints/rn_inspector/rn_perf_metrics/BUILD.gn deleted file mode 100644 index 137ceea50a0..00000000000 --- a/front_end/entrypoints/rn_inspector/rn_perf_metrics/BUILD.gn +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# Copyright 2021 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("../../../../scripts/build/ninja/devtools_module.gni") -import("../../visibility.gni") - -devtools_module("rn_perf_metrics") { - sources = [ - "Impl.ts", - "RNPerfMetricsEvent.d.ts", - "rn_perf_metrics.ts", - "Utils.ts", - ] - - visibility = [ "../:*" ] - - visibility += devtools_entrypoints_visibility -} diff --git a/front_end/entrypoints/rn_inspector/rn_perf_metrics/RNPerfMetricsEvent.d.ts b/front_end/entrypoints/rn_inspector/rn_perf_metrics/RNPerfMetricsEvent.d.ts deleted file mode 100644 index 907ff6f1529..00000000000 --- a/front_end/entrypoints/rn_inspector/rn_perf_metrics/RNPerfMetricsEvent.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Meta Platforms, Inc. and affiliates. -// Copyright 2020 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -export type ReactNativeChromeDevToolsEvent = {}; diff --git a/front_end/entrypoints/rn_inspector/rn_perf_metrics/Utils.ts b/front_end/entrypoints/rn_inspector/rn_perf_metrics/Utils.ts deleted file mode 100644 index 79a0a1503cd..00000000000 --- a/front_end/entrypoints/rn_inspector/rn_perf_metrics/Utils.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Meta Platforms, Inc. and affiliates. -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import * as RNPerfMetricsImpl from './Impl.js'; - -export function registerGlobalPerfMetricsListener(): void { - if (globalThis.enableReactNativePerfMetrics !== true) { - return; - } - - RNPerfMetricsImpl.getInstance().addEventListener(event => { - window.postMessage({event, tag: 'react-native-chrome-devtools-perf-metrics'}, window.location.origin); - }); -} diff --git a/front_end/entrypoints/rn_inspector/rn_perf_metrics/rn_perf_metrics.ts b/front_end/entrypoints/rn_inspector/rn_perf_metrics/rn_perf_metrics.ts deleted file mode 100644 index 0db06bd4aeb..00000000000 --- a/front_end/entrypoints/rn_inspector/rn_perf_metrics/rn_perf_metrics.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Meta Platforms, Inc. and affiliates. -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import * as Impl from './Impl.js'; -import * as Utils from './Utils.js'; - -export { - Impl, - Utils, -};