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

37
node_modules/metro/src/Server/MultipartResponse.d.ts generated vendored Normal file
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.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<355f5514464c4989f90a211782db41e7>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro/src/Server/MultipartResponse.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {IncomingMessage, ServerResponse} from 'http';
type Data = string | Buffer | Uint8Array;
type Headers = {[$$Key$$: string]: string | number};
declare class MultipartResponse {
static wrapIfSupported(
req: IncomingMessage,
res: ServerResponse,
): MultipartResponse | ServerResponse;
static serializeHeaders(headers: Headers): string;
res: ServerResponse;
headers: Headers;
constructor(res: ServerResponse);
writeChunk(headers: Headers | null, data?: Data, isLast?: boolean): void;
writeHead(status: number, headers?: Headers): void;
setHeader(name: string, value: string | number): void;
end(data?: Data): void;
once(name: string, fn: () => unknown): this;
}
export default MultipartResponse;

71
node_modules/metro/src/Server/MultipartResponse.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _accepts = _interopRequireDefault(require("accepts"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
const CRLF = "\r\n";
const BOUNDARY = "3beqjf3apnqeu3h5jqorms4i";
class MultipartResponse {
static wrapIfSupported(req, res) {
if ((0, _accepts.default)(req).types().includes("multipart/mixed")) {
return new MultipartResponse(res);
}
return res;
}
static serializeHeaders(headers) {
return Object.keys(headers)
.map((key) => `${key}: ${headers[key]}`)
.join(CRLF);
}
constructor(res) {
this.res = res;
this.headers = {};
res.writeHead(200, {
"Content-Type": `multipart/mixed; boundary="${BOUNDARY}"`,
});
res.write(
"If you are seeing this, your client does not support multipart response",
);
}
writeChunk(headers, data, isLast = false) {
if (this.res.finished) {
return;
}
this.res.write(`${CRLF}--${BOUNDARY}${CRLF}`);
if (headers) {
this.res.write(MultipartResponse.serializeHeaders(headers) + CRLF + CRLF);
}
if (data != null) {
this.res.write(data);
}
if (isLast) {
this.res.write(`${CRLF}--${BOUNDARY}--${CRLF}`);
}
}
writeHead(status, headers) {
this.setHeader("X-Http-Status", status);
if (!headers) {
return;
}
for (const key in headers) {
this.setHeader(key, headers[key]);
}
}
setHeader(name, value) {
this.headers[name] = value;
}
end(data) {
this.writeChunk(this.headers, data, true);
this.res.end();
}
once(name, fn) {
this.res.once(name, fn);
return this;
}
}
exports.default = MultipartResponse;

101
node_modules/metro/src/Server/MultipartResponse.js.flow generated vendored Normal file
View File

@@ -0,0 +1,101 @@
/**
* 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 {IncomingMessage, ServerResponse} from 'http';
import accepts from 'accepts';
const CRLF = '\r\n';
const BOUNDARY = '3beqjf3apnqeu3h5jqorms4i';
type Data = string | Buffer | Uint8Array;
type Headers = {[string]: string | number};
export default class MultipartResponse {
static wrapIfSupported(
req: IncomingMessage,
res: ServerResponse,
): MultipartResponse | ServerResponse {
if (accepts(req).types().includes('multipart/mixed')) {
return new MultipartResponse(res);
}
return res;
}
static serializeHeaders(headers: Headers): string {
return Object.keys(headers)
.map(key => `${key}: ${headers[key]}`)
.join(CRLF);
}
res: ServerResponse;
headers: Headers;
constructor(res: ServerResponse) {
this.res = res;
this.headers = {};
res.writeHead(200, {
'Content-Type': `multipart/mixed; boundary="${BOUNDARY}"`,
});
res.write(
'If you are seeing this, your client does not support multipart response',
);
}
writeChunk(
headers: Headers | null,
data?: Data,
isLast?: boolean = false,
): void {
if (this.res.finished) {
return;
}
this.res.write(`${CRLF}--${BOUNDARY}${CRLF}`);
if (headers) {
this.res.write(MultipartResponse.serializeHeaders(headers) + CRLF + CRLF);
}
if (data != null) {
this.res.write(data);
}
if (isLast) {
this.res.write(`${CRLF}--${BOUNDARY}--${CRLF}`);
}
}
writeHead(status: number, headers?: Headers): void {
// We can't actually change the response HTTP status code
// because the headers have already been sent
this.setHeader('X-Http-Status', status);
if (!headers) {
return;
}
for (const key in headers) {
this.setHeader(key, headers[key]);
}
}
setHeader(name: string, value: string | number): void {
this.headers[name] = value;
}
end(data?: Data): void {
this.writeChunk(this.headers, data, true);
this.res.end();
}
once(name: string, fn: () => unknown): this {
this.res.once(name, fn);
return this;
}
}

38
node_modules/metro/src/Server/symbolicate.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
/**
* 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<<74bba01977b0b5887c4bb38eb8fc78ea>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro/src/Server/symbolicate.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
import type {ConfigT} from 'metro-config';
export type StackFrameInput = {
readonly file: null | undefined | string;
readonly lineNumber: null | undefined | number;
readonly column: null | undefined | number;
readonly methodName: null | undefined | string;
};
export type IntermediateStackFrame = Omit<
StackFrameInput,
keyof {collapse?: boolean}
> & {collapse?: boolean};
export type StackFrameOutput = Readonly<IntermediateStackFrame>;
declare function symbolicate(
stack: ReadonlyArray<StackFrameInput>,
maps: Iterable<[string, ExplodedSourceMap]>,
config: ConfigT,
extraData: unknown,
): Promise<ReadonlyArray<StackFrameOutput>>;
export default symbolicate;

138
node_modules/metro/src/Server/symbolicate.js generated vendored Normal file
View File

@@ -0,0 +1,138 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = symbolicate;
var _search = require("metro-source-map/private/Consumer/search");
var _Symbolication = require("metro-symbolicate/private/Symbolication");
function createFunctionNameGetter(module) {
const consumer = new _Symbolication.SourceMetadataMapConsumer(
{
version: 3,
mappings: "",
sources: ["dummy"],
names: [],
x_facebook_sources: [[module.functionMap]],
},
(name) => name,
);
return ({ line1Based, column0Based }) =>
consumer.functionNameFor({
line: line1Based,
column: column0Based,
source: "dummy",
});
}
async function symbolicate(stack, maps, config, extraData) {
const mapsByUrl = new Map();
for (const [url, map] of maps) {
mapsByUrl.set(url, map);
}
const functionNameGetters = new Map();
function findModule(frame) {
const map = mapsByUrl.get(frame.file);
if (!map || frame.lineNumber == null) {
return null;
}
const moduleIndex = (0, _search.greatestLowerBound)(
map,
frame.lineNumber,
(target, candidate) => target - candidate.firstLine1Based,
);
if (moduleIndex == null) {
return null;
}
return map[moduleIndex];
}
function findOriginalPos(frame, module) {
if (
module.map == null ||
frame.lineNumber == null ||
frame.column == null
) {
return null;
}
const generatedPosInModule = {
line1Based: frame.lineNumber - module.firstLine1Based + 1,
column0Based: frame.column,
};
const mappingIndex = (0, _search.greatestLowerBound)(
module.map,
generatedPosInModule,
(target, candidate) => {
if (target.line1Based === candidate[0]) {
return target.column0Based - candidate[1];
}
return target.line1Based - candidate[0];
},
);
if (mappingIndex == null) {
return null;
}
const mapping = module.map[mappingIndex];
if (mapping[0] !== generatedPosInModule.line1Based || mapping.length < 4) {
return null;
}
return {
line1Based: mapping[2],
column0Based: mapping[3],
};
}
function findFunctionName(originalPos, module) {
if (module.functionMap) {
let getFunctionName = functionNameGetters.get(module);
if (!getFunctionName) {
getFunctionName = createFunctionNameGetter(module);
functionNameGetters.set(module, getFunctionName);
}
return getFunctionName(originalPos);
}
return null;
}
function symbolicateFrame(frame) {
const module = findModule(frame);
if (!module) {
return {
...frame,
};
}
if (!Array.isArray(module.map)) {
throw new Error(
`Unexpected module with serialized source map found: ${module.path}`,
);
}
const originalPos = findOriginalPos(frame, module);
if (!originalPos) {
return {
...frame,
};
}
const methodName =
findFunctionName(originalPos, module) ?? frame.methodName;
return {
...frame,
methodName,
file: module.path,
lineNumber: originalPos.line1Based,
column: originalPos.column0Based,
};
}
async function customizeFrame(frame) {
const customizations =
(await config.symbolicator.customizeFrame(frame)) || {};
return {
...frame,
...customizations,
};
}
async function customizeStack(symbolicatedStack) {
return await config.symbolicator.customizeStack(
symbolicatedStack,
extraData,
);
}
return Promise.all(stack.map(symbolicateFrame).map(customizeFrame)).then(
customizeStack,
);
}

218
node_modules/metro/src/Server/symbolicate.js.flow generated vendored Normal file
View File

@@ -0,0 +1,218 @@
/**
* 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 {
FBSourceFunctionMap,
MetroSourceMapSegmentTuple,
} from '../../../metro-source-map/src/source-map';
import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
import type {ConfigT} from 'metro-config';
import {greatestLowerBound} from 'metro-source-map/private/Consumer/search';
import {SourceMetadataMapConsumer} from 'metro-symbolicate/private/Symbolication';
export type StackFrameInput = {
+file: ?string,
+lineNumber: ?number,
+column: ?number,
+methodName: ?string,
...
};
export type IntermediateStackFrame = {
...StackFrameInput,
collapse?: boolean,
...
};
export type StackFrameOutput = Readonly<IntermediateStackFrame>;
type ExplodedSourceMapModule = ExplodedSourceMap[number];
type Position = {+line1Based: number, column0Based: number};
function createFunctionNameGetter(
module: ExplodedSourceMapModule,
): Position => ?string {
const consumer = new SourceMetadataMapConsumer(
{
version: 3,
mappings: '',
sources: ['dummy'],
names: [],
x_facebook_sources: [[module.functionMap]],
},
name => name /* no normalization needed */,
);
return ({line1Based, column0Based}) =>
consumer.functionNameFor({
line: line1Based,
column: column0Based,
source: 'dummy',
});
}
export default async function symbolicate(
stack: ReadonlyArray<StackFrameInput>,
maps: Iterable<[string, ExplodedSourceMap]>,
config: ConfigT,
extraData: unknown,
): Promise<ReadonlyArray<StackFrameOutput>> {
const mapsByUrl = new Map<?string, ExplodedSourceMap>();
for (const [url, map] of maps) {
mapsByUrl.set(url, map);
}
const functionNameGetters = new Map<
{
+firstLine1Based: number,
+functionMap: ?FBSourceFunctionMap,
+map: Array<MetroSourceMapSegmentTuple>,
+path: string,
},
(Position) => ?string,
>();
function findModule(frame: StackFrameInput): ?ExplodedSourceMapModule {
const map = mapsByUrl.get(frame.file);
if (!map || frame.lineNumber == null) {
return null;
}
const moduleIndex = greatestLowerBound(
map,
frame.lineNumber,
(target, candidate) => target - candidate.firstLine1Based,
);
if (moduleIndex == null) {
return null;
}
return map[moduleIndex];
}
function findOriginalPos(
frame: StackFrameInput,
module: ExplodedSourceMapModule,
): ?Position {
if (
module.map == null ||
frame.lineNumber == null ||
frame.column == null
) {
return null;
}
const generatedPosInModule = {
line1Based: frame.lineNumber - module.firstLine1Based + 1,
column0Based: frame.column,
};
const mappingIndex = greatestLowerBound(
module.map,
generatedPosInModule,
(target, candidate) => {
if (target.line1Based === candidate[0]) {
return target.column0Based - candidate[1];
}
return target.line1Based - candidate[0];
},
);
if (mappingIndex == null) {
return null;
}
const mapping = module.map[mappingIndex];
if (
mapping[0] !== generatedPosInModule.line1Based ||
mapping.length < 4 /* no source line/column info */
) {
return null;
}
return {
// $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
line1Based: mapping[2],
// $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
column0Based: mapping[3],
};
}
function findFunctionName(
originalPos: Position,
module: {
+firstLine1Based: number,
+functionMap: ?FBSourceFunctionMap,
+map: Array<MetroSourceMapSegmentTuple>,
+path: string,
},
): ?string {
if (module.functionMap) {
let getFunctionName = functionNameGetters.get(module);
if (!getFunctionName) {
getFunctionName = createFunctionNameGetter(module);
functionNameGetters.set(module, getFunctionName);
}
return getFunctionName(originalPos);
}
return null;
}
function symbolicateFrame(frame: StackFrameInput): IntermediateStackFrame {
const module = findModule(frame);
if (!module) {
return {...frame};
}
if (!Array.isArray(module.map)) {
throw new Error(
`Unexpected module with serialized source map found: ${module.path}`,
);
}
const originalPos = findOriginalPos(frame, module);
if (!originalPos) {
return {...frame};
}
const methodName =
findFunctionName(originalPos, module) ?? frame.methodName;
return {
...frame,
methodName,
file: module.path,
lineNumber: originalPos.line1Based,
column: originalPos.column0Based,
};
}
/**
* `customizeFrame` allows for custom modifications of the symbolicated frame in a stack.
* It can be used to collapse stack frames that are not relevant to users, pointing them
* to more relevant product code instead.
*
* An example usecase is a library throwing an error while sanitizing inputs from product code.
* In some cases, it's more useful to point the developer looking at the error towards the product code directly.
*/
async function customizeFrame(
frame: IntermediateStackFrame,
): Promise<IntermediateStackFrame> {
const customizations =
(await config.symbolicator.customizeFrame(frame)) || {};
return {...frame, ...customizations};
}
/**
* `customizeStack` allows for custom modifications of a symbolicated stack.
* Where `customizeFrame` operates on individual frames, this hook can process the entire stack in context.
*
* Note: `customizeStack` has access to an `extraData` object which can be used to attach metadata
* to the error coming in, to be used by the customizeStack hook.
*/
async function customizeStack(
symbolicatedStack: Array<IntermediateStackFrame>,
): Promise<Array<IntermediateStackFrame>> {
return await config.symbolicator.customizeStack(
symbolicatedStack,
extraData,
);
}
return Promise.all(stack.map(symbolicateFrame).map(customizeFrame)).then(
customizeStack,
);
}