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

26
node_modules/metro-resolver/src/utils/isAssetFile.d.ts generated vendored Normal file
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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<ef11437df6220e26b38eae0d8fb2c3d1>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-resolver/src/utils/isAssetFile.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
/**
* Determine if a file path should be considered an asset file based on the
* given `assetExts`.
*/
declare function isAssetFile(
filePath: string,
assetExts: ReadonlySet<string>,
): boolean;
export default isAssetFile;

22
node_modules/metro-resolver/src/utils/isAssetFile.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = isAssetFile;
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
function isAssetFile(filePath, assetExts) {
const baseName = _path.default.basename(filePath);
for (let i = baseName.length - 1; i >= 0; i--) {
if (baseName[i] === ".") {
const ext = baseName.slice(i + 1);
if (assetExts.has(ext)) {
return true;
}
}
}
return false;
}

View File

@@ -0,0 +1,35 @@
/**
* 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 path from 'path';
/**
* Determine if a file path should be considered an asset file based on the
* given `assetExts`.
*/
export default function isAssetFile(
filePath: string,
assetExts: ReadonlySet<string>,
): boolean {
const baseName = path.basename(filePath);
for (let i = baseName.length - 1; i >= 0; i--) {
if (baseName[i] === '.') {
const ext = baseName.slice(i + 1);
if (assetExts.has(ext)) {
return true;
}
}
}
return false;
}

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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<bf08da4ef625a52c96e6ab5e4b6b088a>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-resolver/src/utils/isSubpathDefinedInExportsLike.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
/**
* Identifies whether the given subpath is defined in the given "exports"-like
* mapping. Does not reduce exports conditions (therefore does not identify
* whether the subpath is mapped to a value).
*/
import type {NormalizedExportsLikeMap} from '../types';
export declare function isSubpathDefinedInExportsLike(
exportsLikeMap: NormalizedExportsLikeMap,
subpath: string,
): boolean;

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.isSubpathDefinedInExportsLike = isSubpathDefinedInExportsLike;
var _matchSubpathPattern = require("./matchSubpathPattern");
function isSubpathDefinedInExportsLike(exportsLikeMap, subpath) {
if (exportsLikeMap.has(subpath)) {
return true;
}
for (const key of exportsLikeMap.keys()) {
if (
key.split("*").length === 2 &&
(0, _matchSubpathPattern.matchSubpathPattern)(key, subpath) != null
) {
return true;
}
}
return false;
}

View File

@@ -0,0 +1,40 @@
/**
* 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
*/
/**
* Identifies whether the given subpath is defined in the given "exports"-like
* mapping. Does not reduce exports conditions (therefore does not identify
* whether the subpath is mapped to a value).
*/
import type {NormalizedExportsLikeMap} from '../types';
import {matchSubpathPattern} from './matchSubpathPattern';
export function isSubpathDefinedInExportsLike(
exportsLikeMap: NormalizedExportsLikeMap,
subpath: string,
): boolean {
if (exportsLikeMap.has(subpath)) {
return true;
}
// Attempt to match after expanding any subpath pattern keys
for (const key of exportsLikeMap.keys()) {
if (
key.split('*').length === 2 &&
matchSubpathPattern(key, subpath) != null
) {
return true;
}
}
return false;
}

View File

@@ -0,0 +1,31 @@
/**
* 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<<2de88d23d3cf26217cd8ae8ada6c79b7>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-resolver/src/utils/matchSubpathFromExportsLike.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {NormalizedExportsLikeMap, ResolutionContext} from '../types';
/**
* Get the mapped replacement for the given subpath.
*
* Implements modern package resolution behaviour based on the [Package Entry
* Points spec](https://nodejs.org/docs/latest-v19.x/api/packages.html#package-entry-points).
*/
export declare function matchSubpathFromExportsLike(
context: ResolutionContext,
subpath: string,
exportsLikeMap: NormalizedExportsLikeMap,
platform: string | null,
createConfigError: (reason: string) => Error,
): Readonly<{target: string | null; patternMatch: string | null}>;

View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.matchSubpathFromExportsLike = matchSubpathFromExportsLike;
var _matchSubpathPattern = require("./matchSubpathPattern");
var _reduceExportsLikeMap = require("./reduceExportsLikeMap");
function matchSubpathFromExportsLike(
context,
subpath,
exportsLikeMap,
platform,
createConfigError,
) {
const conditionNames = new Set([
"default",
context.isESMImport === true ? "import" : "require",
...context.unstable_conditionNames,
...(platform != null
? (context.unstable_conditionsByPlatform[platform] ?? [])
: []),
]);
const exportsLikeMapAfterConditions = (0,
_reduceExportsLikeMap.reduceExportsLikeMap)(
exportsLikeMap,
conditionNames,
createConfigError,
);
let target = exportsLikeMapAfterConditions.get(subpath);
let patternMatch = null;
if (target == null) {
const expansionKeys = [...exportsLikeMapAfterConditions.keys()]
.map((key) => ({
key,
baseLength: key.indexOf("*"),
}))
.filter((data) => data.baseLength !== -1)
.sort((a, b) => {
if (a.baseLength === b.baseLength) {
return b.key.length - a.key.length;
}
return b.baseLength - a.baseLength;
});
for (const { key } of expansionKeys) {
const value = exportsLikeMapAfterConditions.get(key);
patternMatch = (0, _matchSubpathPattern.matchSubpathPattern)(
key,
subpath,
);
if (patternMatch != null) {
target = value;
break;
}
}
}
return {
target: target ?? null,
patternMatch,
};
}

View File

@@ -0,0 +1,85 @@
/**
* 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 {NormalizedExportsLikeMap, ResolutionContext} from '../types';
import {matchSubpathPattern} from './matchSubpathPattern';
import {reduceExportsLikeMap} from './reduceExportsLikeMap';
/**
* Get the mapped replacement for the given subpath.
*
* Implements modern package resolution behaviour based on the [Package Entry
* Points spec](https://nodejs.org/docs/latest-v19.x/api/packages.html#package-entry-points).
*/
export function matchSubpathFromExportsLike(
context: ResolutionContext,
/**
* The package-relative subpath (beginning with '.') to match against either
* an exact subpath key or subpath pattern key in "exports".
*/
subpath: string,
exportsLikeMap: NormalizedExportsLikeMap,
platform: string | null,
createConfigError: (reason: string) => Error,
): Readonly<{
target: string | null,
patternMatch: string | null,
}> {
const conditionNames = new Set([
'default',
context.isESMImport === true ? 'import' : 'require',
...context.unstable_conditionNames,
...(platform != null
? (context.unstable_conditionsByPlatform[platform] ?? [])
: []),
]);
const exportsLikeMapAfterConditions = reduceExportsLikeMap(
exportsLikeMap,
conditionNames,
createConfigError,
);
let target = exportsLikeMapAfterConditions.get(subpath);
let patternMatch = null;
// Attempt to match after expanding any subpath pattern keys
if (target == null) {
// Gather keys which are subpath patterns in descending order of specificity
// For ordering, see `PATTERN_KEY_COMPARE` in:
// https://nodejs.org/api/esm.html#resolution-algorithm-specification
const expansionKeys = [...exportsLikeMapAfterConditions.keys()]
.map(key => ({key, baseLength: key.indexOf('*')}))
.filter(data => data.baseLength !== -1)
.sort((a, b) => {
if (a.baseLength === b.baseLength) {
// If wildcards are in equal positions, the longer key is more
// specific
return b.key.length - a.key.length;
}
return b.baseLength - a.baseLength;
});
for (const {key} of expansionKeys) {
const value = exportsLikeMapAfterConditions.get(key);
patternMatch = matchSubpathPattern(key, subpath);
if (patternMatch != null) {
target = value;
break;
}
}
}
return {target: target ?? null, patternMatch};
}

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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<40375a98e9c03360973e0cf65b702ced>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-resolver/src/utils/matchSubpathPattern.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
/**
* If a subpath pattern expands to the passed subpath, return the subpath match
* (value to substitute for '*'). Otherwise, return `null`.
*
* See https://nodejs.org/docs/latest-v19.x/api/packages.html#subpath-patterns.
*/
export declare function matchSubpathPattern(
subpathPattern: string,
subpath: string,
): string | null;

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.matchSubpathPattern = matchSubpathPattern;
function matchSubpathPattern(subpathPattern, subpath) {
const [patternBase, patternTrailer] = subpathPattern.split("*");
if (
subpath.startsWith(patternBase) &&
(patternTrailer.length === 0 ||
(subpath.endsWith(patternTrailer) &&
subpath.length >= subpathPattern.length))
) {
return subpath.substring(
patternBase.length,
subpath.length - patternTrailer.length,
);
}
return null;
}

View File

@@ -0,0 +1,37 @@
/**
* 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
*/
/**
* If a subpath pattern expands to the passed subpath, return the subpath match
* (value to substitute for '*'). Otherwise, return `null`.
*
* See https://nodejs.org/docs/latest-v19.x/api/packages.html#subpath-patterns.
*/
export function matchSubpathPattern(
subpathPattern: string,
subpath: string,
): string | null {
const [patternBase, patternTrailer] = subpathPattern.split('*');
if (
subpath.startsWith(patternBase) &&
(patternTrailer.length === 0 ||
(subpath.endsWith(patternTrailer) &&
subpath.length >= subpathPattern.length))
) {
return subpath.substring(
patternBase.length,
subpath.length - patternTrailer.length,
);
}
return null;
}

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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<0bb41edd0d0c6f257cb95ca9b7b00aa9>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-resolver/src/utils/reduceExportsLikeMap.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
/**
* Reduce an "exports"-like mapping to a flat subpath mapping after resolving
* conditional exports.
*/
import type {FlattenedExportMap, NormalizedExportsLikeMap} from '../types';
export declare function reduceExportsLikeMap(
exportsLikeMap: NormalizedExportsLikeMap,
conditionNames: ReadonlySet<string>,
createConfigError: (reason: string) => Error,
): FlattenedExportMap;

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.reduceExportsLikeMap = reduceExportsLikeMap;
function reduceExportsLikeMap(
exportsLikeMap,
conditionNames,
createConfigError,
) {
const result = new Map();
for (const [subpath, value] of exportsLikeMap) {
const subpathValue = reduceConditionalExport(value, conditionNames);
if (subpathValue !== "no-match") {
result.set(subpath, subpathValue);
}
}
for (const value of result.values()) {
if (value != null && !value.startsWith("./")) {
throw createConfigError(
'One or more mappings for subpaths defined in "exports" are invalid. ' +
'All values must begin with "./".',
);
}
}
return result;
}
function reduceConditionalExport(subpathValue, conditionNames) {
let reducedValue = subpathValue;
while (reducedValue != null && typeof reducedValue !== "string") {
let match;
if ("default" in reducedValue) {
match = "no-match";
} else {
match = null;
}
for (const conditionName in reducedValue) {
if (conditionNames.has(conditionName)) {
match = reducedValue[conditionName];
break;
}
}
reducedValue = match;
}
return reducedValue;
}

View File

@@ -0,0 +1,90 @@
/**
* 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
*/
/**
* Reduce an "exports"-like mapping to a flat subpath mapping after resolving
* conditional exports.
*/
import type {
ExportsLikeMap,
FlattenedExportMap,
NormalizedExportsLikeMap,
} from '../types';
export function reduceExportsLikeMap(
exportsLikeMap: NormalizedExportsLikeMap,
conditionNames: ReadonlySet<string>,
createConfigError: (reason: string) => Error,
): FlattenedExportMap {
const result = new Map<string, string | null>();
for (const [subpath, value] of exportsLikeMap) {
const subpathValue = reduceConditionalExport(value, conditionNames);
// If a subpath has no resolution for the passed `conditionNames`, do not
// include it in the result. (This includes only explicit `null` values,
// which may conditionally hide higher-specificity subpath patterns.)
if (subpathValue !== 'no-match') {
result.set(subpath, subpathValue);
}
}
for (const value of result.values()) {
if (value != null && !value.startsWith('./')) {
throw createConfigError(
'One or more mappings for subpaths defined in "exports" are invalid. ' +
'All values must begin with "./".',
);
}
}
return result;
}
/**
* Reduce an "exports"-like subpath value after asserting the passed
* `conditionNames` in any nested conditions.
*
* Returns `'no-match'` in the case that none of the asserted `conditionNames`
* are matched.
*
* See https://nodejs.org/docs/latest-v19.x/api/packages.html#conditional-exports.
*/
function reduceConditionalExport(
subpathValue: Values<ExportsLikeMap>,
conditionNames: ReadonlySet<string>,
): string | null | 'no-match' {
let reducedValue = subpathValue;
while (reducedValue != null && typeof reducedValue !== 'string') {
let match: typeof subpathValue | 'no-match';
// when conditions are present and default is not specified
// the default condition is implicitly set to null, to allow
// for restricting access to unexported internals of a package.
if ('default' in reducedValue) {
match = 'no-match';
} else {
match = null;
}
for (const conditionName in reducedValue) {
if (conditionNames.has(conditionName)) {
match = reducedValue[conditionName];
break;
}
}
reducedValue = match;
}
return reducedValue;
}

23
node_modules/metro-resolver/src/utils/toPosixPath.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<<091df9100cc8f841af449036a548f6aa>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-resolver/src/utils/toPosixPath.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
/**
* Replace path separators in the passed string to coerce to a POSIX path. This
* is a no-op on POSIX systems.
*/
declare function toPosixPath(relativePathOrSpecifier: string): string;
export default toPosixPath;

23
node_modules/metro-resolver/src/utils/toPosixPath.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = toPosixPath;
var _path = _interopRequireDefault(require("path"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
const MATCH_NON_POSIX_PATH_SEPS = new RegExp(
"\\" + _path.default.win32.sep,
"g",
);
function toPosixPath(relativePathOrSpecifier) {
if (_path.default.sep === _path.default.posix.sep) {
return relativePathOrSpecifier;
}
return relativePathOrSpecifier.replace(
MATCH_NON_POSIX_PATH_SEPS,
_path.default.posix.sep,
);
}

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
* @format
* @oncall react_native
*/
import path from 'path';
const MATCH_NON_POSIX_PATH_SEPS = new RegExp('\\' + path.win32.sep, 'g');
/**
* Replace path separators in the passed string to coerce to a POSIX path. This
* is a no-op on POSIX systems.
*/
export default function toPosixPath(relativePathOrSpecifier: string): string {
if (path.sep === path.posix.sep) {
return relativePathOrSpecifier;
}
return relativePathOrSpecifier.replace(
MATCH_NON_POSIX_PATH_SEPS,
path.posix.sep,
);
}