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,39 @@
/**
* 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<<13269e5dcf93e0b31428517812e3bb88>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-transform-plugins/src/utils/createInlinePlatformChecks.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {Scope} from '@babel/traverse';
import type * as $$IMPORT_TYPEOF_1$$ from '@babel/types';
import type {CallExpression, MemberExpression} from '@babel/types';
type Types = typeof $$IMPORT_TYPEOF_1$$;
type PlatformChecks = {
isPlatformNode: (
node: MemberExpression,
scope: Scope,
isWrappedModule: boolean,
) => boolean;
isPlatformSelectNode: (
node: CallExpression,
scope: Scope,
isWrappedModule: boolean,
) => boolean;
};
declare function createInlinePlatformChecks(
t: Types,
requireName?: string,
): PlatformChecks;
export default createInlinePlatformChecks;

View File

@@ -0,0 +1,148 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = createInlinePlatformChecks;
const importMap = new Map([["ReactNative", "react-native"]]);
function createInlinePlatformChecks(t, requireName = "require") {
const {
isIdentifier,
isStringLiteral,
isNumericLiteral,
isMemberExpression,
isCallExpression,
} = t;
const isPlatformNode = (node, scope, isWrappedModule) =>
isPlatformOS(node, scope, isWrappedModule) ||
isReactPlatformOS(node, scope, isWrappedModule);
const isPlatformSelectNode = (node, scope, isWrappedModule) =>
isPlatformSelect(node, scope, isWrappedModule) ||
isReactPlatformSelect(node, scope, isWrappedModule);
const isPlatformOS = (node, scope, isWrappedModule) =>
isIdentifier(node.property, {
name: "OS",
}) &&
isImportOrGlobal(
node.object,
scope,
[
{
name: "Platform",
},
],
isWrappedModule,
);
const isReactPlatformOS = (node, scope, isWrappedModule) =>
isIdentifier(node.property, {
name: "OS",
}) &&
isMemberExpression(node.object) &&
isIdentifier(node.object.property, {
name: "Platform",
}) &&
isImportOrGlobal(
node.object.object,
scope,
[
{
name: "React",
},
{
name: "ReactNative",
},
],
isWrappedModule,
);
const isPlatformSelect = (node, scope, isWrappedModule) =>
isMemberExpression(node.callee) &&
isIdentifier(node.callee.property, {
name: "select",
}) &&
isImportOrGlobal(
node.callee.object,
scope,
[
{
name: "Platform",
},
],
isWrappedModule,
);
const isReactPlatformSelect = (node, scope, isWrappedModule) =>
isMemberExpression(node.callee) &&
isIdentifier(node.callee.property, {
name: "select",
}) &&
isMemberExpression(node.callee.object) &&
isIdentifier(node.callee.object.property, {
name: "Platform",
}) &&
isImportOrGlobal(
node.callee.object.object,
scope,
[
{
name: "React",
},
{
name: "ReactNative",
},
],
isWrappedModule,
);
const isRequireCall = (node, dependencyId, scope) =>
isCallExpression(node) &&
isIdentifier(node.callee, {
name: requireName,
}) &&
checkRequireArgs(node.arguments, dependencyId);
const isImport = (node, scope, patterns) =>
patterns.some((pattern) => {
const importName = importMap.get(pattern.name) || pattern.name;
return isRequireCall(node, importName, scope);
});
const isImportOrGlobal = (node, scope, patterns, isWrappedModule) => {
const identifier = patterns.find((pattern) => isIdentifier(node, pattern));
if (
!!identifier &&
isToplevelBinding(scope.getBinding(identifier.name), isWrappedModule)
) {
return true;
}
if (isImport(node, scope, patterns)) {
return true;
}
if (isIdentifier(node)) {
const binding = scope.getBinding(node.name);
if (
binding != null &&
isToplevelBinding(binding, isWrappedModule) &&
binding.path.isVariableDeclarator()
) {
const init = binding.path.node.init;
if (init != null && isImport(init, scope, patterns)) {
return true;
}
}
}
return false;
};
const checkRequireArgs = (args, dependencyId) => {
const pattern = t.stringLiteral(dependencyId);
return (
isStringLiteral(args[0], pattern) ||
(isMemberExpression(args[0]) &&
isNumericLiteral(args[0].property) &&
isStringLiteral(args[1], pattern))
);
};
const isToplevelBinding = (binding, isWrappedModule) =>
!binding ||
!binding.scope.parent ||
(isWrappedModule && !binding.scope.parent.parent);
return {
isPlatformNode,
isPlatformSelectNode,
};
}

View File

@@ -0,0 +1,200 @@
/**
* 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
* @format
* @oncall react_native
*/
import type {Scope} from '@babel/traverse';
import type {CallExpression, MemberExpression} from '@babel/types';
// Type only import. No runtime dependency
// eslint-disable-next-line import/no-extraneous-dependencies
import typeof * as Types from '@babel/types';
const importMap = new Map([['ReactNative', 'react-native']]);
type PlatformChecks = {
isPlatformNode: (
node: MemberExpression,
scope: Scope,
isWrappedModule: boolean,
) => boolean,
isPlatformSelectNode: (
node: CallExpression,
scope: Scope,
isWrappedModule: boolean,
) => boolean,
};
export default function createInlinePlatformChecks(
t: Types,
requireName: string = 'require',
): PlatformChecks {
const {
isIdentifier,
isStringLiteral,
isNumericLiteral,
isMemberExpression,
isCallExpression,
} = t;
const isPlatformNode = (
node: MemberExpression,
scope: Scope,
isWrappedModule: boolean,
): boolean =>
isPlatformOS(node, scope, isWrappedModule) ||
isReactPlatformOS(node, scope, isWrappedModule);
const isPlatformSelectNode = (
node: CallExpression,
scope: Scope,
isWrappedModule: boolean,
): boolean =>
isPlatformSelect(node, scope, isWrappedModule) ||
isReactPlatformSelect(node, scope, isWrappedModule);
const isPlatformOS = (
node: MemberExpression,
scope: Scope,
isWrappedModule: boolean,
): boolean =>
isIdentifier(node.property, {name: 'OS'}) &&
isImportOrGlobal(node.object, scope, [{name: 'Platform'}], isWrappedModule);
const isReactPlatformOS = (
node: MemberExpression,
scope: Scope,
isWrappedModule: boolean,
): boolean =>
isIdentifier(node.property, {name: 'OS'}) &&
isMemberExpression(node.object) &&
isIdentifier(node.object.property, {name: 'Platform'}) &&
isImportOrGlobal(
// $FlowFixMe[incompatible-type]
node.object.object,
scope,
[{name: 'React'}, {name: 'ReactNative'}],
isWrappedModule,
);
const isPlatformSelect = (
node: CallExpression,
scope: Scope,
isWrappedModule: boolean,
): boolean =>
isMemberExpression(node.callee) &&
isIdentifier(node.callee.property, {name: 'select'}) &&
isImportOrGlobal(
// $FlowFixMe[incompatible-type]
node.callee.object,
scope,
[{name: 'Platform'}],
isWrappedModule,
);
const isReactPlatformSelect = (
node: CallExpression,
scope: Scope,
isWrappedModule: boolean,
): boolean =>
isMemberExpression(node.callee) &&
isIdentifier(node.callee.property, {name: 'select'}) &&
isMemberExpression(node.callee.object) &&
isIdentifier(node.callee.object.property, {name: 'Platform'}) &&
isImportOrGlobal(
// $FlowFixMe[incompatible-type]
// $FlowFixMe[incompatible-use]
node.callee.object.object,
scope,
[{name: 'React'}, {name: 'ReactNative'}],
isWrappedModule,
);
const isRequireCall = (
node: BabelNodeExpression,
dependencyId: string,
scope: Scope,
): boolean =>
isCallExpression(node) &&
isIdentifier(node.callee, {name: requireName}) &&
checkRequireArgs(node.arguments, dependencyId);
const isImport = (
node: BabelNodeExpression,
scope: Scope,
patterns: Array<{name: string}>,
): boolean =>
patterns.some((pattern: {name: string}) => {
const importName = importMap.get(pattern.name) || pattern.name;
return isRequireCall(node, importName, scope);
});
const isImportOrGlobal = (
node: BabelNodeExpression,
scope: Scope,
patterns: Array<{name: string}>,
isWrappedModule: boolean,
): boolean => {
const identifier = patterns.find((pattern: {name: string}) =>
isIdentifier(node, pattern),
);
if (
!!identifier &&
isToplevelBinding(scope.getBinding(identifier.name), isWrappedModule)
) {
return true;
}
if (isImport(node, scope, patterns)) {
return true;
}
if (isIdentifier(node)) {
const binding = scope.getBinding(node.name);
if (
binding != null &&
isToplevelBinding(binding, isWrappedModule) &&
binding.path.isVariableDeclarator()
) {
const init = binding.path.node.init;
// $FlowFixMe[incompatible-type] Flow doesn't narrow binding.path.node through isVariableDeclarator()
if (init != null && isImport(init, scope, patterns)) {
return true;
}
}
}
return false;
};
const checkRequireArgs = (
args: Array<
| BabelNodeExpression
| BabelNodeSpreadElement
| BabelNodeArgumentPlaceholder,
>,
dependencyId: string,
): boolean => {
const pattern = t.stringLiteral(dependencyId);
return (
isStringLiteral(args[0], pattern) ||
(isMemberExpression(args[0]) &&
isNumericLiteral(args[0].property) &&
isStringLiteral(args[1], pattern))
);
};
const isToplevelBinding = (
binding: void | $FlowFixMe,
isWrappedModule: boolean,
): boolean =>
!binding ||
!binding.scope.parent ||
(isWrappedModule && !binding.scope.parent.parent);
return {
isPlatformNode,
isPlatformSelectNode,
};
}