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

23
node_modules/metro/src/commands/build.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* 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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<10c41709fa9779dd0e12ef411eaef8eb>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro/src/commands/build.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {CommandModule} from 'yargs';
declare const $$EXPORT_DEFAULT_DECLARATION$$: () => CommandModule;
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

135
node_modules/metro/src/commands/build.js generated vendored Normal file
View File

@@ -0,0 +1,135 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _cliUtils = require("../cli-utils");
var _parseKeyValueParamArray = _interopRequireDefault(
require("../cli/parseKeyValueParamArray"),
);
var _TerminalReporter = _interopRequireDefault(
require("../lib/TerminalReporter"),
);
var _metroConfig = require("metro-config");
var _metroCore = require("metro-core");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
const term = new _metroCore.Terminal(process.stdout);
const updateReporter = new _TerminalReporter.default(term);
var _default = () => ({
command: "build <entry>",
desc: "Generates a JavaScript bundle containing the specified entrypoint and its descendants",
builder: (yargs) => {
yargs.option("project-roots", {
alias: "P",
type: "string",
array: true,
});
yargs.option("out", {
alias: "O",
type: "string",
demandOption: true,
});
yargs.option("platform", {
alias: "p",
type: "string",
});
yargs.option("output-type", {
alias: "t",
type: "string",
});
yargs.option("max-workers", {
alias: "j",
type: "number",
});
yargs.option("minify", {
alias: "z",
type: "boolean",
});
yargs.option("dev", {
alias: "g",
type: "boolean",
});
yargs.option("source-map", {
type: "boolean",
});
yargs.option("source-map-url", {
type: "string",
});
yargs.option("legacy-bundler", {
type: "boolean",
});
yargs.option("config", {
alias: "c",
type: "string",
});
yargs.option("transform-option", {
type: "string",
array: true,
alias: "transformer-option",
coerce: _parseKeyValueParamArray.default,
describe:
"Custom transform options of the form key=value. URL-encoded. May be specified multiple times.",
});
yargs.option("resolver-option", {
type: "string",
array: true,
coerce: _parseKeyValueParamArray.default,
describe:
"Custom resolver options of the form key=value. URL-encoded. May be specified multiple times.",
});
yargs.option("reset-cache", {
type: "boolean",
});
},
handler: (0, _cliUtils.makeAsyncCommand)(async (argv) => {
const config = await (0, _metroConfig.loadConfig)(argv);
const options = {
entry: argv.entry,
dev: argv.dev,
out: argv.out,
minify: argv.minify,
platform: argv.platform,
sourceMap: argv.sourceMap,
sourceMapUrl: argv.sourceMapUrl,
customResolverOptions: argv.resolverOption,
customTransformOptions: argv.transformOption,
};
const MetroApi = require("../index");
await MetroApi.runBuild(config, {
...options,
onBegin: () => {
updateReporter.update({
buildID: "$",
type: "bundle_build_started",
bundleDetails: {
bundleType: "Bundle",
customResolverOptions: options.customResolverOptions ?? {},
customTransformOptions: options.customTransformOptions ?? {},
dev: !!options.dev,
entryFile: options.entry,
minify: !!options.minify,
platform: options.platform,
},
});
},
onProgress: (transformedFileCount, totalFileCount) => {
updateReporter.update({
buildID: "$",
type: "bundle_transform_progressed",
transformedFileCount,
totalFileCount,
});
},
onComplete: () => {
updateReporter.update({
buildID: "$",
type: "bundle_build_done",
});
},
});
}),
});
exports.default = _default;

151
node_modules/metro/src/commands/build.js.flow generated vendored Normal file
View File

@@ -0,0 +1,151 @@
/**
* 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
* @oncall react_native
*/
import type {RunBuildOptions} from '../index';
import type {CustomTransformOptions} from 'metro-babel-transformer';
import type {CustomResolverOptions} from 'metro-resolver';
import type {CommandModule} from 'yargs';
import typeof Yargs from 'yargs';
import {makeAsyncCommand} from '../cli-utils';
import parseKeyValueParamArray from '../cli/parseKeyValueParamArray';
import TerminalReporter from '../lib/TerminalReporter';
import {loadConfig} from 'metro-config';
import {Terminal} from 'metro-core';
const term = new Terminal(process.stdout);
const updateReporter = new TerminalReporter(term);
type Args = Readonly<{
_: unknown,
$0: unknown,
config?: string,
dev?: boolean,
entry: string,
legacyBundler?: boolean,
maxWorkers?: number,
minify?: boolean,
out: string,
outputType?: string,
platform?: string,
projectRoots?: ReadonlyArray<string>,
resetCache?: boolean,
sourceMap?: boolean,
sourceMapUrl?: string,
transformOption: CustomTransformOptions,
resolverOption: CustomResolverOptions,
...
}>;
export default (): CommandModule => ({
command: 'build <entry>',
desc: 'Generates a JavaScript bundle containing the specified entrypoint and its descendants',
builder: (yargs: Yargs): void => {
yargs.option('project-roots', {
alias: 'P',
type: 'string',
array: true,
});
yargs.option('out', {alias: 'O', type: 'string', demandOption: true});
yargs.option('platform', {alias: 'p', type: 'string'});
yargs.option('output-type', {alias: 't', type: 'string'});
yargs.option('max-workers', {alias: 'j', type: 'number'});
yargs.option('minify', {alias: 'z', type: 'boolean'});
yargs.option('dev', {alias: 'g', type: 'boolean'});
yargs.option('source-map', {type: 'boolean'});
yargs.option('source-map-url', {type: 'string'});
yargs.option('legacy-bundler', {type: 'boolean'});
yargs.option('config', {alias: 'c', type: 'string'});
yargs.option('transform-option', {
type: 'string',
array: true,
alias: 'transformer-option',
coerce: parseKeyValueParamArray as $FlowFixMe,
describe:
'Custom transform options of the form key=value. URL-encoded. May be specified multiple times.',
});
yargs.option('resolver-option', {
type: 'string',
array: true,
coerce: parseKeyValueParamArray as $FlowFixMe,
describe:
'Custom resolver options of the form key=value. URL-encoded. May be specified multiple times.',
});
// Deprecated
yargs.option('reset-cache', {type: 'boolean'});
},
handler: makeAsyncCommand(async (argv: Args) => {
// $FlowFixMe[incompatible-type] argv has extra props.
const config = await loadConfig(argv);
const options: RunBuildOptions = {
entry: argv.entry,
dev: argv.dev,
out: argv.out,
minify: argv.minify,
platform: argv.platform,
sourceMap: argv.sourceMap,
sourceMapUrl: argv.sourceMapUrl,
customResolverOptions: argv.resolverOption,
customTransformOptions: argv.transformOption,
};
// Inline require() to avoid circular dependency with ../index
// eslint-disable-next-line import/no-commonjs
const MetroApi = require('../index');
await MetroApi.runBuild(config, {
...options,
onBegin: (): void => {
updateReporter.update({
buildID: '$',
type: 'bundle_build_started',
bundleDetails: {
bundleType: 'Bundle',
customResolverOptions: options.customResolverOptions ?? {},
customTransformOptions: options.customTransformOptions ?? {},
dev: !!options.dev,
entryFile: options.entry,
minify: !!options.minify,
platform: options.platform,
},
});
},
onProgress: (
transformedFileCount: number,
totalFileCount: number,
): void => {
updateReporter.update({
buildID: '$',
type: 'bundle_transform_progressed',
transformedFileCount,
totalFileCount,
});
},
onComplete: (): void => {
updateReporter.update({
buildID: '$',
type: 'bundle_build_done',
});
},
});
}),
});

23
node_modules/metro/src/commands/dependencies.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* 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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<a73d915901dde7a679972b78a1e08a3e>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro/src/commands/dependencies.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {CommandModule} from 'yargs';
declare const $$EXPORT_DEFAULT_DECLARATION$$: () => CommandModule;
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

102
node_modules/metro/src/commands/dependencies.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _cliUtils = require("../cli-utils");
var _Server = _interopRequireDefault(require("../Server"));
var _fs = _interopRequireDefault(require("fs"));
var _metroConfig = require("metro-config");
var _path = _interopRequireDefault(require("path"));
var _util = require("util");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
async function dependencies(args, config) {
const rootModuleAbsolutePath = args.entryFile;
if (!_fs.default.existsSync(rootModuleAbsolutePath)) {
return Promise.reject(
new Error(`File ${rootModuleAbsolutePath} does not exist`),
);
}
config.cacheStores = [];
const relativePath = _path.default.relative(
config.server.unstable_serverRoot ?? config.projectRoot,
rootModuleAbsolutePath,
);
const options = {
platform: args.platform,
entryFile: relativePath,
dev: args.dev,
minify: false,
generateSourceMaps: !args.dev,
};
const outStream =
args.output != null
? _fs.default.createWriteStream(args.output)
: process.stdout;
const server = new _Server.default(config);
try {
const deps = await server.getOrderedDependencyPaths(options);
deps.forEach((modulePath) => {
const isInsideProjectRoots =
config.watchFolders.filter((root) => modulePath.startsWith(root))
.length > 0;
if (isInsideProjectRoots) {
outStream.write(modulePath + "\n");
}
});
} finally {
await server.end();
}
return args.output != null
? (0, _util.promisify)(outStream.end).bind(outStream)()
: Promise.resolve();
}
var _default = () => ({
command: "get-dependencies [entryFile]",
desc: "List all dependencies that will be bundled for a given entry point",
builder: (yargs) => {
yargs.option("entry-file", {
type: "string",
demandOption: true,
describe: "Absolute path to the root JS file",
});
yargs.option("output", {
type: "string",
describe:
"File name where to store the output, ex. /tmp/dependencies.txt",
});
yargs.option("platform", {
type: "string",
describe: "The platform extension used for selecting modules",
});
yargs.option("transformer", {
type: "string",
describe: "Specify a custom transformer to be used",
});
yargs.option("max-workers", {
type: "number",
describe:
"Specifies the maximum number of workers the worker-pool " +
"will spawn for transforming files. This defaults to the number of the " +
"cores available on your machine.",
});
yargs.option("dev", {
type: "boolean",
default: true,
describe: "If false, skip all dev-only code path",
});
yargs.option("verbose", {
type: "boolean",
default: false,
description: "Enables logging",
});
},
handler: (0, _cliUtils.makeAsyncCommand)(async (argv) => {
const config = await (0, _metroConfig.loadConfig)(argv);
await dependencies(argv, config);
}),
});
exports.default = _default;

133
node_modules/metro/src/commands/dependencies.js.flow generated vendored Normal file
View File

@@ -0,0 +1,133 @@
/**
* 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
* @oncall react_native
*/
import type {ConfigT} from 'metro-config';
import type {CommandModule} from 'yargs';
import typeof Yargs from 'yargs';
import {makeAsyncCommand} from '../cli-utils';
import Server from '../Server';
import fs from 'fs';
import {loadConfig} from 'metro-config';
import path from 'path';
import {promisify} from 'util';
type Args = Readonly<{
_: unknown,
$0: unknown,
entryFile: string,
output?: string,
platform?: string,
transformer?: string,
maxWorkers?: number,
dev: boolean,
verbose: boolean,
...
}>;
async function dependencies(args: Args, config: ConfigT) {
const rootModuleAbsolutePath = args.entryFile;
if (!fs.existsSync(rootModuleAbsolutePath)) {
return Promise.reject(
new Error(`File ${rootModuleAbsolutePath} does not exist`),
);
}
// $FlowFixMe[cannot-write]
config.cacheStores = [];
const relativePath = path.relative(
config.server.unstable_serverRoot ?? config.projectRoot,
rootModuleAbsolutePath,
);
const options = {
platform: args.platform,
entryFile: relativePath,
dev: args.dev,
minify: false,
generateSourceMaps: !args.dev,
};
const outStream =
args.output != null ? fs.createWriteStream(args.output) : process.stdout;
const server = new Server(config);
try {
const deps = await server.getOrderedDependencyPaths(options);
deps.forEach(modulePath => {
// Temporary hack to disable listing dependencies not under this directory.
// Long term, we need either
// (a) JS code to not depend on anything outside this directory, or
// (b) Come up with a way to declare this dependency in Buck.
const isInsideProjectRoots =
config.watchFolders.filter(root => modulePath.startsWith(root)).length >
0;
if (isInsideProjectRoots) {
outStream.write(modulePath + '\n');
}
});
} finally {
await server.end();
}
return args.output != null
? // $FlowFixMe[method-unbinding]
promisify(outStream.end).bind(outStream)()
: Promise.resolve();
}
export default (): CommandModule => ({
command: 'get-dependencies [entryFile]',
desc: 'List all dependencies that will be bundled for a given entry point',
builder: (yargs: Yargs) => {
yargs.option('entry-file', {
type: 'string',
demandOption: true,
describe: 'Absolute path to the root JS file',
});
yargs.option('output', {
type: 'string',
describe:
'File name where to store the output, ex. /tmp/dependencies.txt',
});
yargs.option('platform', {
type: 'string',
describe: 'The platform extension used for selecting modules',
});
yargs.option('transformer', {
type: 'string',
describe: 'Specify a custom transformer to be used',
});
yargs.option('max-workers', {
type: 'number',
describe:
'Specifies the maximum number of workers the worker-pool ' +
'will spawn for transforming files. This defaults to the number of the ' +
'cores available on your machine.',
});
yargs.option('dev', {
type: 'boolean',
default: true,
describe: 'If false, skip all dev-only code path',
});
yargs.option('verbose', {
type: 'boolean',
default: false,
description: 'Enables logging',
});
},
handler: makeAsyncCommand(async (argv: Args) => {
// $FlowFixMe[incompatible-type] argv has extra props.
const config = await loadConfig(argv);
await dependencies(argv, config);
}),
});

23
node_modules/metro/src/commands/serve.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* 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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<367f11c0b6933f8c8c58718c7dd41e78>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro/src/commands/serve.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {CommandModule} from 'yargs';
declare const $$EXPORT_DEFAULT_DECLARATION$$: () => CommandModule;
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

107
node_modules/metro/src/commands/serve.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _cliUtils = require("../cli-utils");
var _metroConfig = require("metro-config");
var _util = require("util");
var _default = () => ({
command: "serve",
aliases: ["start"],
desc: "Starts Metro on the given port, building bundles on the fly",
builder: (yargs) => {
yargs.option("project-roots", {
alias: "P",
type: "string",
array: true,
});
yargs.option("host", {
alias: "h",
type: "string",
default: "localhost",
});
yargs.option("port", {
alias: "p",
type: "number",
default: 8081,
});
yargs.option("max-workers", {
alias: "j",
type: "number",
});
yargs.option("secure", {
type: "boolean",
describe: "(deprecated)",
});
yargs.option("secure-key", {
type: "string",
describe: "(deprecated)",
});
yargs.option("secure-cert", {
type: "string",
describe: "(deprecated)",
});
yargs.option("secure-server-options", {
alias: "s",
type: "string",
describe: "Use dot notation for object path",
});
yargs.option("hmr-enabled", {
alias: "hmr",
type: "boolean",
});
yargs.option("config", {
alias: "c",
type: "string",
});
yargs.option("reset-cache", {
type: "boolean",
});
yargs.example(
"secure-server-options",
'-s.cert="$(cat path/to/cert)" -s.key="$(cat path/to/key")',
);
},
handler: (0, _cliUtils.makeAsyncCommand)(async (argv) => {
let server = null;
let restarting = false;
async function restart() {
if (restarting) {
return;
} else {
restarting = true;
}
if (server) {
console.log("Configuration changed. Restarting the server...");
await (0, _util.promisify)(server.close).call(server);
}
const config = await (0, _metroConfig.loadConfig)(argv);
const MetroApi = require("../index");
const {
_,
$0: _0,
config: _config,
hmrEnabled: _hmrEnabled,
maxWorkers: _maxWorkers,
port: _port,
projectRoots: _projectRoots,
resetCache: _resetCache,
...runServerOptions
} = argv;
({ httpServer: server } = await MetroApi.runServer(
config,
runServerOptions,
));
restarting = false;
}
const foundConfig = await (0, _metroConfig.resolveConfig)(argv.config);
if (foundConfig) {
await (0, _cliUtils.watchFile)(foundConfig.filepath, restart);
} else {
await restart();
}
}),
});
exports.default = _default;

130
node_modules/metro/src/commands/serve.js.flow generated vendored Normal file
View File

@@ -0,0 +1,130 @@
/**
* 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
* @oncall react_native
*/
import type {ServerOptions as HttpsServerOptions} from 'https';
import type {CommandModule} from 'yargs';
import typeof Yargs from 'yargs';
import {makeAsyncCommand, watchFile} from '../cli-utils';
import {loadConfig, resolveConfig} from 'metro-config';
import {promisify} from 'util';
type Args = Readonly<{
_: unknown,
$0: unknown,
projectRoots?: ReadonlyArray<string>,
host: string,
port: number,
maxWorkers?: number,
secure?: boolean,
secureKey?: string,
secureCert?: string,
secureServerOptions?: HttpsServerOptions,
hmrEnabled?: boolean,
config?: string,
resetCache?: boolean,
...
}>;
export default (): CommandModule => ({
command: 'serve',
aliases: ['start'],
desc: 'Starts Metro on the given port, building bundles on the fly',
builder: (yargs: Yargs): void => {
yargs.option('project-roots', {
alias: 'P',
type: 'string',
array: true,
});
yargs.option('host', {alias: 'h', type: 'string', default: 'localhost'});
yargs.option('port', {alias: 'p', type: 'number', default: 8081});
yargs.option('max-workers', {alias: 'j', type: 'number'});
yargs.option('secure', {type: 'boolean', describe: '(deprecated)'});
yargs.option('secure-key', {type: 'string', describe: '(deprecated)'});
yargs.option('secure-cert', {type: 'string', describe: '(deprecated)'});
yargs.option('secure-server-options', {
alias: 's',
type: 'string',
describe: 'Use dot notation for object path',
});
yargs.option('hmr-enabled', {alias: 'hmr', type: 'boolean'});
yargs.option('config', {alias: 'c', type: 'string'});
// Deprecated
yargs.option('reset-cache', {type: 'boolean'});
// Examples
yargs.example(
'secure-server-options',
'-s.cert="$(cat path/to/cert)" -s.key="$(cat path/to/key")',
);
},
handler: makeAsyncCommand(async (argv: Args) => {
let server = null;
let restarting = false;
async function restart(): Promise<void> {
if (restarting) {
return;
} else {
restarting = true;
}
if (server) {
// eslint-disable-next-line no-console
console.log('Configuration changed. Restarting the server...');
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
await promisify(server.close).call(server);
}
// $FlowFixMe[incompatible-type] argv has extra props.
const config = await loadConfig(argv);
// Inline require() to avoid circular dependency with ../index
// eslint-disable-next-line import/no-commonjs
const MetroApi = require('../index');
const {
_,
$0: _0,
config: _config,
hmrEnabled: _hmrEnabled,
maxWorkers: _maxWorkers,
port: _port,
projectRoots: _projectRoots,
resetCache: _resetCache,
...runServerOptions
} = argv;
({httpServer: server} = await MetroApi.runServer(
config,
// $FlowFixMe[incompatible-exact] argv has extra props.
runServerOptions,
));
restarting = false;
}
const foundConfig = await resolveConfig(argv.config);
if (foundConfig) {
await watchFile(foundConfig.filepath, restart);
} else {
await restart();
}
}),
});