FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

View File

@@ -0,0 +1,26 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
import type { DebuggerShellPreparationResult } from "../types/DevToolLauncher";
/**
* Default `DevToolLauncher` implementation which handles opening apps on the
* local machine.
*/
declare const DefaultToolLauncher: {
launchDebuggerAppWindow: (url: string) => Promise<void>;
launchDebuggerShell(url: string, windowKey: string): Promise<void>;
prepareDebuggerShell(
prebuiltBinaryPath?: null | undefined | string,
): Promise<DebuggerShellPreparationResult>;
};
declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof DefaultToolLauncher;
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
const {
unstable_prepareDebuggerShell,
unstable_spawnDebuggerShellWithArgs,
} = require("@react-native/debugger-shell");
const { spawn } = require("child_process");
const ChromeLauncher = require("chrome-launcher");
const { Launcher: EdgeLauncher } = require("chromium-edge-launcher");
const open = require("open");
const DefaultToolLauncher = {
launchDebuggerAppWindow: async (url) => {
if (process.env.NODE_ENV === "test") {
assertMockedInTests();
}
let chromePath;
try {
chromePath = ChromeLauncher.getChromePath();
} catch (e) {
chromePath = EdgeLauncher.getFirstInstallation();
}
if (chromePath == null) {
await open(url);
return;
}
const chromeFlags = [`--app=${url}`, "--window-size=1200,600"];
return new Promise((resolve, reject) => {
const childProcess = spawn(chromePath, chromeFlags, {
detached: true,
stdio: "ignore",
});
childProcess.on("data", () => {
resolve();
});
childProcess.on("close", (code) => {
if (code !== 0) {
reject(
new Error(
`Failed to launch debugger app window: ${chromePath} exited with code ${code}`,
),
);
}
});
});
},
async launchDebuggerShell(url, windowKey) {
if (process.env.NODE_ENV === "test") {
assertMockedInTests();
}
return await unstable_spawnDebuggerShellWithArgs([
"--frontendUrl=" + url,
"--windowKey=" + windowKey,
]);
},
async prepareDebuggerShell(prebuiltBinaryPath) {
if (process.env.NODE_ENV === "test") {
assertMockedInTests();
}
return await unstable_prepareDebuggerShell();
},
};
function assertMockedInTests() {
if (process.env.NODE_ENV === "test") {
throw new Error(
"DefaultToolLauncher must be mocked or overridden in tests. " +
"Add jest.mock('../utils/DefaultAppLauncher') to test setup.",
);
}
}
var _default = (exports.default = DefaultToolLauncher);

View File

@@ -0,0 +1,25 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type { DebuggerShellPreparationResult } from "../types/DevToolLauncher";
/**
* Default `DevToolLauncher` implementation which handles opening apps on the
* local machine.
*/
declare const DefaultToolLauncher: {
launchDebuggerAppWindow: (url: string) => Promise<void>,
launchDebuggerShell(url: string, windowKey: string): Promise<void>,
prepareDebuggerShell(
prebuiltBinaryPath?: ?string,
): Promise<DebuggerShellPreparationResult>,
};
declare export default typeof DefaultToolLauncher;

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
declare function getBaseUrlFromRequest(
req: http$IncomingMessage<tls$TLSSocket> | http$IncomingMessage<net$Socket>,
): null | undefined | URL;
export default getBaseUrlFromRequest;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = getBaseUrlFromRequest;
function getBaseUrlFromRequest(req) {
const hostHeader = req.headers.host;
if (hostHeader == null) {
return null;
}
const scheme = req.socket.encrypted === true ? "https" : "http";
const url = `${scheme}://${req.headers.host}`;
try {
return new URL(url);
} catch {
return null;
}
}

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
// Determine the base URL (scheme and host) used by a client to reach this
// server.
//
// TODO: Support X-Forwarded-Host, etc. for trusted proxies
declare export default function getBaseUrlFromRequest(
req: http$IncomingMessage<tls$TLSSocket> | http$IncomingMessage<net$Socket>,
): ?URL;

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
*/
import type { Experiments } from "../types/Experiments";
import type { ReadonlyURL } from "../types/ReadonlyURL";
/**
* Get the DevTools frontend URL to debug a given React Native CDP target.
*/
declare function getDevToolsFrontendUrl(
experiments: Experiments,
webSocketDebuggerUrl: string,
devServerUrl: ReadonlyURL,
options?: Readonly<{
relative?: boolean;
launchId?: string;
telemetryInfo?: string;
appId?: string;
panel?: string;
}>,
): string;
export default getDevToolsFrontendUrl;

View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = getDevToolsFrontendUrl;
function getDevToolsFrontendUrl(
experiments,
webSocketDebuggerUrl,
devServerUrl,
options,
) {
const wsParam = getWsParam({
webSocketDebuggerUrl,
devServerUrl,
});
const appUrl =
(options?.relative === true ? "" : devServerUrl.origin) +
"/debugger-frontend/rn_fusebox.html";
const searchParams = new URLSearchParams([
[wsParam.key, wsParam.value],
["sources.hide_add_folder", "true"],
]);
if (experiments.enableNetworkInspector) {
searchParams.append("unstable_enableNetworkPanel", "true");
}
if (options?.launchId != null && options.launchId !== "") {
searchParams.append("launchId", options.launchId);
}
if (options?.appId != null && options.appId !== "") {
searchParams.append("appId", options.appId);
}
if (options?.telemetryInfo != null && options.telemetryInfo !== "") {
searchParams.append("telemetryInfo", options.telemetryInfo);
}
if (options?.panel != null && options.panel !== "") {
searchParams.append("panel", options.panel);
}
return appUrl + "?" + searchParams.toString();
}
function getWsParam({ webSocketDebuggerUrl, devServerUrl }) {
const wsUrl = new URL(webSocketDebuggerUrl);
const serverHost = devServerUrl.host;
let value;
if (wsUrl.host === serverHost) {
value = wsUrl.pathname + wsUrl.search + wsUrl.hash;
} else {
value = wsUrl.host + wsUrl.pathname + wsUrl.search + wsUrl.hash;
}
const key = wsUrl.protocol.slice(0, -1);
return {
key,
value,
};
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type { Experiments } from "../types/Experiments";
import type { ReadonlyURL } from "../types/ReadonlyURL";
/**
* Get the DevTools frontend URL to debug a given React Native CDP target.
*/
declare export default function getDevToolsFrontendUrl(
experiments: Experiments,
webSocketDebuggerUrl: string,
devServerUrl: ReadonlyURL,
options?: Readonly<{
relative?: boolean,
launchId?: string,
telemetryInfo?: string,
appId?: string,
panel?: string,
}>,
): string;