first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

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 { DebuggerShellPreparationResult } from "../";
/**
* Default `BrowserLauncher` implementation which opens URLs on the host
* machine.
*/
declare const DefaultBrowserLauncher: {
/**
* Attempt to open the debugger frontend in a Google Chrome or Microsoft Edge
* app window.
*/
launchDebuggerAppWindow: (url: string) => Promise<void>;
unstable_showFuseboxShell(url: string, windowKey: string): Promise<void>;
unstable_prepareFuseboxShell(): Promise<DebuggerShellPreparationResult>;
};
declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof DefaultBrowserLauncher;
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

View File

@@ -0,0 +1,62 @@
"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 DefaultBrowserLauncher = {
launchDebuggerAppWindow: async (url) => {
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 unstable_showFuseboxShell(url, windowKey) {
return await unstable_spawnDebuggerShellWithArgs(
["--frontendUrl=" + url, "--windowKey=" + windowKey],
{
mode: "detached",
flavor: process.env.RNDT_DEV === "1" ? "dev" : "prebuilt",
},
);
},
async unstable_prepareFuseboxShell() {
return await unstable_prepareDebuggerShell(
process.env.RNDT_DEV === "1" ? "dev" : "prebuilt",
);
},
};
var _default = (exports.default = DefaultBrowserLauncher);

View File

@@ -0,0 +1,27 @@
/**
* 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 "../";
/**
* Default `BrowserLauncher` implementation which opens URLs on the host
* machine.
*/
declare const DefaultBrowserLauncher: {
/**
* Attempt to open the debugger frontend in a Google Chrome or Microsoft Edge
* app window.
*/
launchDebuggerAppWindow: (url: string) => Promise<void>,
unstable_showFuseboxShell(url: string, windowKey: string): Promise<void>,
unstable_prepareFuseboxShell(): Promise<DebuggerShellPreparationResult>,
};
declare export default typeof DefaultBrowserLauncher;

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,29 @@
/**
* 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";
/**
* Get the DevTools frontend URL to debug a given React Native CDP target.
*/
declare function getDevToolsFrontendUrl(
experiments: Experiments,
webSocketDebuggerUrl: string,
devServerUrl: string,
options?: Readonly<{
relative?: boolean;
launchId?: string;
telemetryInfo?: string;
/** Whether to use the modern `rn_fusebox.html` entry point. */
useFuseboxEntryPoint?: boolean;
appId?: string;
panel?: string;
}>,
): string;
export default getDevToolsFrontendUrl;

View File

@@ -0,0 +1,58 @@
"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) +
"/debugger-frontend/" +
(options?.useFuseboxEntryPoint === true
? "rn_fusebox.html"
: "rn_inspector.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 = new URL(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,29 @@
/**
* 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";
/**
* Get the DevTools frontend URL to debug a given React Native CDP target.
*/
declare export default function getDevToolsFrontendUrl(
experiments: Experiments,
webSocketDebuggerUrl: string,
devServerUrl: string,
options?: $ReadOnly<{
relative?: boolean,
launchId?: string,
telemetryInfo?: string,
/** Whether to use the modern `rn_fusebox.html` entry point. */
useFuseboxEntryPoint?: boolean,
appId?: string,
panel?: string,
}>,
): string;