Skip to content

Commit b95f818

Browse files
committed
Fix build and lint after chromium/7827 sync
Resolving the chromium/7827 merge surfaced compile/lint breakages that aren't textual conflicts — they come from the TypeScript 6.0 upgrade and upstream API changes/removals. This commit makes the synced tree build (gn + tsc) and lint cleanly. Kept separate from the merge commit for reviewability. **Experiments**: Upstream moved `ExperimentName` into `core/root/ExperimentNames.ts`. Re-export it from `Runtime.ts` so existing `Root.Runtime.ExperimentName.*` references keep resolving, add the React Native experiment values to `ExperimentNames.ts`, register them for tests in the new `RuntimeHelpers.ts`, and switch RN `isEnabled/setEnabled` call sites from `RNExperimentName` to `ExperimentName` (the core API is strictly typed). **rehydrated_devtools_app**: Upstream removed this entrypoint in favour of `trace_app`, but the RN debugger opens `rehydrated_devtools_app.html` by name. Restored the entrypoint (alongside `trace_app`) and its BUILD.gn visibility/deps; the rehydrating connection accepts both via `isTraceApp() || getPathName().includes('rehydrated_devtools_app')`. **Upstream API migrations in RN files**: `UI.XLink`/`<x-link>` (removed) → `<devtools-link>` from `ui/kit`; `UIUtils.createInlineButton` (removed) inlined; `i18n.getFormatLocalizedString` → `ui/i18n`; `SimpleView`/`VBox` options-object constructors; `Trace.Handlers.Types.ParsedTrace` → `Trace.TraceModel.ParsedTrace` (handler data now under `.data`); CSS `*.css.js` imports are branded strings (drop `.cssText`); `getRegisteredViewExtensions` is now a `ViewManager` instance method. **TypeScript 6.0 / build**: Export the `RNPerfMetrics` class (TS4094 on the re-exported singleton); convert the `check-license-header` eslint rule to ESM; add missing BUILD.gn deps (`ui/components/adorners`, `ui/components/icon_button`, `ui/kit`) and a dropped `Root` import in NetworkLogView; convert lantern metric test `it()` callbacks to `function()` so `this` is the Mocha context. **Dependencies / lint**: Drop the fork's `nanoid`/`serialize-javascript`/`ws` dependency overrides (superseded by upstream's newer tree); exempt RN components from upstream's new `no-lit-render-outside-of-view` / `no-imperative-dom-api` / `no-adopted-style-sheets` rules pending a proper view-function migration.
1 parent 9e41975 commit b95f818

34 files changed

Lines changed: 188 additions & 77 deletions

eslint.config.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,30 @@ export default defineConfig([
855855
'@devtools/no-lit-render-outside-of-view': 'off',
856856
},
857857
},
858+
{
859+
// [RN] React Native-specific components predate upstream's view-function lint
860+
// rules and use direct Lit render / imperative DOM / adoptedStyleSheets patterns.
861+
// Keep them exempt until they are migrated. Keep in sync with META_CODE_PATHS in
862+
// scripts/eslint_rules/lib/check-license-header.js.
863+
name: 'React Native-specific files',
864+
files: [
865+
'front_end/core/rn_experiments/**/*.ts',
866+
'front_end/entrypoints/rn_fusebox/**/*.ts',
867+
'front_end/models/react_native/**/*.ts',
868+
'front_end/panels/react_devtools/**/*.ts',
869+
'front_end/panels/rn_welcome/**/*.ts',
870+
'front_end/panels/network/components/NetworkEventCoverageInfobar.ts',
871+
'front_end/panels/timeline/ReactNativeTimelineLandingPage.ts',
872+
'front_end/panels/timeline/components/RNPerfIssueTypes.ts',
873+
'front_end/panels/timeline/components/SidebarRNPerfIssueItem.ts',
874+
'front_end/panels/timeline/components/SidebarRNPerfSignalsTab.ts',
875+
],
876+
rules: {
877+
'@devtools/no-lit-render-outside-of-view': 'off',
878+
'@devtools/no-imperative-dom-api': 'off',
879+
'@devtools/no-adopted-style-sheets': 'off',
880+
},
881+
},
858882
{
859883
name: 'Keep models/trace isolated',
860884
files: ['front_end/models/trace/**/*.ts'],

front_end/core/host/RNPerfMetrics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export function getInstance(): RNPerfMetrics {
2020

2121
type PanelLocation = 'main'|'drawer';
2222
type UnsubscribeFn = () => void;
23-
class RNPerfMetrics {
23+
// Exported so the type of the `rnPerfMetrics` singleton re-exported from host.ts
24+
// is nameable (required by TypeScript 6.0's stricter declaration emit, TS4094).
25+
export class RNPerfMetrics {
2426
readonly #consoleErrorMethod = 'error';
2527
#listeners = new Set<RNReliabilityEventListener>();
2628
#launchId: string|null = null;

front_end/core/rn_experiments/experimentsImpl.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,12 @@ class RNExperimentsSupport {
144144

145145
copyInto(other: Root.Runtime.ExperimentsSupport, titlePrefix = ''): void {
146146
for (const [name, spec] of this.#experiments) {
147+
// RNExperimentName mirrors the React Native entries in Root.Runtime.ExperimentName
148+
// (see ExperimentNames.ts); cast to satisfy the core experiments API.
149+
const coreName = name as unknown as Root.Runtime.ExperimentName;
147150
other.register(
148-
name,
151+
coreName,
149152
titlePrefix + spec.title,
150-
spec.unstable,
151153
spec.docLink,
152154
spec.feedbackLink,
153155
);
@@ -156,7 +158,7 @@ class RNExperimentsSupport {
156158
isReactNativeEntryPoint: state.isReactNativeEntryPoint,
157159
})
158160
) {
159-
other.enableExperimentsByDefault([name]);
161+
other.enableExperimentsByDefault([coreName]);
160162
}
161163
}
162164
for (const name of this.#defaultEnabledCoreExperiments) {

front_end/core/sdk/RehydratingConnection.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ describeWithEnvironment('RehydratingConnection emittance', function() {
213213
const reveal = sinon.stub(Common.Revealer.RevealerRegistry.prototype, 'reveal').resolves();
214214
const messageLog: Array<string|Message> = [];
215215

216-
const conn = new SDK.RehydratingConnection.RehydratingConnectionTransport((e: string) => {
217-
throw new Error(`Connection lost: ${e}`);
216+
const conn = new SDK.RehydratingConnection.RehydratingConnectionTransport(connectionLostDetails => {
217+
throw new Error(`Connection lost: ${connectionLostDetails?.reason}`);
218218
});
219219

220220
// Impractical to invoke the real devtools frontend, so we fake the 3 CDP handlers that

front_end/entrypoints/main/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ devtools_entrypoint("meta") {
102102
visibility = [
103103
"../../panels/greendev/*",
104104
"../greendev_floaty/*",
105+
"../rehydrated_devtools_app:*",
106+
"../rn_fusebox:*",
105107
"../shell/*",
106108
"../trace_app:*",
107109
]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2024 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
import("../../../scripts/build/ninja/devtools_entrypoint.gni")
5+
import("../visibility.gni")
6+
7+
devtools_entrypoint("entrypoint") {
8+
entrypoint = "rehydrated_devtools_app.ts"
9+
10+
deps = [
11+
"../../Images:optimize_images",
12+
"../../core/sdk:meta",
13+
"../../entrypoints/inspector_main:meta",
14+
"../../entrypoints/main:meta",
15+
"../../models/logs:meta",
16+
"../../models/persistence:meta",
17+
"../../panels/browser_debugger:meta",
18+
"../../panels/mobile_throttling:meta",
19+
"../../panels/protocol_monitor:meta",
20+
"../../panels/sensors:meta",
21+
"../../panels/settings:meta",
22+
"../../panels/sources:meta",
23+
"../../panels/timeline:meta",
24+
"../../ui/legacy/components/perf_ui:meta",
25+
"../../ui/legacy/components/quick_open:meta",
26+
"../../ui/legacy/components/source_frame:meta",
27+
"../main:bundle",
28+
]
29+
30+
visibility = [ "../../:*" ]
31+
32+
visibility += devtools_entrypoints_visibility
33+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
// Copyright 2024 The Chromium Authors. All rights reserved.
3+
// Use of this source code is governed by a BSD-style license that can be
4+
// found in the LICENSE file.
5+
import '../main/main-meta.js';
6+
import '../inspector_main/inspector_main-meta.js';
7+
import '../../core/sdk/sdk-meta.js';
8+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
9+
// @ts-ignore: tsc 6.0 does not support side-effect imports without a type definition.
10+
// We cannot use `@ts-expect-error` here because the import is correctly resolved
11+
// when bundling the application (which doesn't error) and only errors in unbundled builds.
12+
import '../../Images/Images.js';
13+
import '../../models/logs/logs-meta.js';
14+
import '../../models/persistence/persistence-meta.js';
15+
import '../../panels/browser_debugger/browser_debugger-meta.js';
16+
// panels/timeline depends on mobile_throttling for settings UI
17+
import '../../panels/mobile_throttling/mobile_throttling-meta.js';
18+
import '../../panels/protocol_monitor/protocol_monitor-meta.js';
19+
import '../../panels/settings/settings-meta.js';
20+
import '../../panels/sources/sources-meta.js';
21+
// sdk/emulation depends on panels/sensors: crbug.com/1376652
22+
import '../../panels/sensors/sensors-meta.js';
23+
import '../../panels/timeline/timeline-meta.js';
24+
import '../../ui/legacy/components/perf_ui/perf_ui-meta.js';
25+
import '../../ui/legacy/components/quick_open/quick_open-meta.js';
26+
import '../../ui/legacy/components/source_frame/source_frame-meta.js';
27+
28+
import * as Main from '../main/main.js';
29+
30+
new Main.MainImpl.MainImpl();

front_end/entrypoints/rn_fusebox/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ devtools_module("rn_fusebox") {
2020
"../../core/i18n:bundle",
2121
"../../core/root:bundle",
2222
"../../core/sdk:bundle",
23+
"../../ui/kit:bundle",
2324
"../../ui/legacy:bundle",
2425
]
2526
}

front_end/entrypoints/rn_fusebox/FuseboxFeatureObserver.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Use of this source code is governed by a BSD-style license that can be
44
// found in the LICENSE file.
55

6+
import '../../ui/kit/kit.js';
7+
68
import type * as Common from '../../core/common/common.js';
79
import * as i18n from '../../core/i18n/i18n.js';
810
import * as Root from '../../core/root/root.js';
@@ -115,7 +117,7 @@ export class FuseboxFeatureObserver implements
115117
const drawerLocationPromise = viewManager.resolveLocation(UI.ViewManager.ViewLocationValues.DRAWER_VIEW);
116118
void Promise.all([panelLocationPromise, drawerLocationPromise])
117119
.then(([panelLocation, drawerLocation]) => {
118-
UI.ViewManager.getRegisteredViewExtensions().forEach(view => {
120+
viewManager.getRegisteredViewExtensions().forEach(view => {
119121
if (view.location() === UI.ViewManager.ViewLocationValues.DRAWER_VIEW) {
120122
drawerLocation?.removeView(view);
121123
} else {
@@ -143,8 +145,8 @@ export class FuseboxFeatureObserver implements
143145
}
144146

145147
async #ensureTimelineFramesEnabled(): Promise<void> {
146-
if (!Root.Runtime.experiments.isEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES)) {
147-
Root.Runtime.experiments.setEnabled(Root.Runtime.RNExperimentName.ENABLE_TIMELINE_FRAMES, true);
148+
if (!Root.Runtime.experiments.isEnabled(Root.Runtime.ExperimentName.ENABLE_TIMELINE_FRAMES)) {
149+
Root.Runtime.experiments.setEnabled(Root.Runtime.ExperimentName.ENABLE_TIMELINE_FRAMES, true);
148150
UI.InspectorView?.InspectorView?.instance()?.displayReloadRequiredWarning(
149151
i18nString(UIStrings.reloadRequiredForTimelineFramesMessage));
150152
}
@@ -206,7 +208,7 @@ export class FuseboxFeatureObserver implements
206208
<div class="alert-title">${titleText}</div>
207209
<div class="alert-detail">
208210
${i18nString(UIStrings.multiHostFeatureDisabledDetail)}
209-
See <x-link href="https://github.com/react-native-community/discussions-and-proposals/discussions/954" class="devtools-link" jslog=${VisualLogging.link().track({click: true, keydown:'Enter|Space'}).context('multi-host-learn-more')}>discussions/954</x-link>.
211+
See <devtools-link href="https://github.com/react-native-community/discussions-and-proposals/discussions/954" class="devtools-link" jslog=${VisualLogging.link().track({click: true, keydown:'Enter|Space'}).context('multi-host-learn-more')}>discussions/954</devtools-link>.
210212
</div>
211213
</div>
212214
`, alertBar, {host: this});

front_end/models/trace/lantern/core/NetworkAnalyzer.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ describeWithEnvironment('NetworkAnalyzer', () => {
158158
assert.deepEqual(result, expected);
159159
});
160160

161-
it('should work on a real trace', async () => {
161+
it('should work on a real trace', async function() {
162162
const requests = await createRequests(this, trace);
163163
const result = NetworkAnalyzer.estimateIfConnectionWasReused(requests);
164164
const distinctConnections = Array.from(result.values()).filter(item => !item).length;
@@ -267,15 +267,15 @@ describeWithEnvironment('NetworkAnalyzer', () => {
267267
assert.deepEqual(result.get('https://example.com'), expected);
268268
});
269269

270-
it('should work on a real trace', async () => {
270+
it('should work on a real trace', async function() {
271271
const requests = await createRequests(this, trace);
272272
const result = NetworkAnalyzer.estimateRTTByOrigin(requests);
273273
assertCloseEnough(result.get('https://www.paulirish.com')?.min ?? 0, 10);
274274
assertCloseEnough(result.get('https://www.googletagmanager.com')?.min ?? 0, 17);
275275
assertCloseEnough(result.get('https://www.google-analytics.com')?.min ?? 0, 10);
276276
});
277277

278-
it('should approximate well with either method', async () => {
278+
it('should approximate well with either method', async function() {
279279
const requests = await createRequests(this, trace);
280280
const result = NetworkAnalyzer.estimateRTTByOrigin(requests).get(NetworkAnalyzer.summary);
281281
const resultApprox = NetworkAnalyzer
@@ -318,15 +318,15 @@ describeWithEnvironment('NetworkAnalyzer', () => {
318318
assert.deepEqual(result.get('https://example.com'), expected);
319319
});
320320

321-
it('should work on a real trace', async () => {
321+
it('should work on a real trace', async function() {
322322
const requests = await createRequests(this, trace);
323323
const result = NetworkAnalyzer.estimateServerResponseTimeByOrigin(requests);
324324
assertCloseEnough(result.get('https://www.paulirish.com')?.avg ?? 0, 35);
325325
assertCloseEnough(result.get('https://www.googletagmanager.com')?.avg ?? 0, 8);
326326
assertCloseEnough(result.get('https://www.google-analytics.com')?.avg ?? 0, 8);
327327
});
328328

329-
it('should approximate well with either method', async () => {
329+
it('should approximate well with either method', async function() {
330330
const requests = await createRequests(this, trace);
331331
const result = NetworkAnalyzer.estimateServerResponseTimeByOrigin(requests).get(
332332
NetworkAnalyzer.summary,
@@ -443,7 +443,7 @@ describeWithEnvironment('NetworkAnalyzer', () => {
443443
});
444444

445445
describe('#computeRTTAndServerResponseTime', function() {
446-
it('should work', async () => {
446+
it('should work', async function() {
447447
const requests = await createRequests(this, trace);
448448
const result = NetworkAnalyzer.computeRTTAndServerResponseTime(requests);
449449

@@ -490,14 +490,14 @@ describeWithEnvironment('NetworkAnalyzer', () => {
490490
});
491491

492492
describe('#findMainDocument', function() {
493-
it('should find the main document', async () => {
493+
it('should find the main document', async function() {
494494
const requests = await createRequests(this, trace);
495495
const mainDocument = NetworkAnalyzer.findResourceForUrl(requests, 'https://www.paulirish.com/');
496496
assert.isOk(mainDocument);
497497
assert.strictEqual(mainDocument.url, 'https://www.paulirish.com/');
498498
});
499499

500-
it('should find the main document if the URL includes a fragment', async () => {
500+
it('should find the main document if the URL includes a fragment', async function() {
501501
const requests = await createRequests(this, trace);
502502
const mainDocument = NetworkAnalyzer.findResourceForUrl(requests, 'https://www.paulirish.com/#info');
503503
assert.isOk(mainDocument);
@@ -509,7 +509,7 @@ describeWithEnvironment('NetworkAnalyzer', () => {
509509
expectConsoleLogs({
510510
error: ['Error: missing metric scores for specified navigation'],
511511
});
512-
it('should resolve to the same document when no redirect', async () => {
512+
it('should resolve to the same document when no redirect', async function() {
513513
const requests = await createRequests(this, trace);
514514
const mainDocument = NetworkAnalyzer.findResourceForUrl(requests, 'https://www.paulirish.com/');
515515
assert.isOk(mainDocument);
@@ -518,7 +518,7 @@ describeWithEnvironment('NetworkAnalyzer', () => {
518518
assert.strictEqual(finalDocument.url, 'https://www.paulirish.com/');
519519
});
520520

521-
it('should resolve to the final document with redirects', async () => {
521+
it('should resolve to the final document with redirects', async function() {
522522
const requests = await createRequests(this, traceWithRedirect);
523523
const mainDocument = NetworkAnalyzer.findResourceForUrl(requests, 'http://www.vkontakte.ru/');
524524
assert.isOk(mainDocument);

0 commit comments

Comments
 (0)