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,44 @@
/**
* 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<<22565876862bd94effefabfc09cf8933>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/AbstractConsumer.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {
GeneratedPositionLookup,
IConsumer,
IterationOrder,
Mapping,
SourcePosition,
} from './types';
declare class AbstractConsumer implements IConsumer {
_sourceMap: {readonly file?: string};
constructor(sourceMap: {readonly file?: string});
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition;
generatedMappings(): Iterable<Mapping>;
eachMapping(
callback: (mapping: Mapping) => unknown,
context?: unknown,
order?: IterationOrder,
): void;
get file(): null | undefined | string;
sourceContentFor(
source: string,
nullOnMissing: true,
): null | undefined | string;
}
export default AbstractConsumer;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _constants = require("./constants");
var _invariant = _interopRequireDefault(require("invariant"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
class AbstractConsumer {
constructor(sourceMap) {
this._sourceMap = sourceMap;
}
originalPositionFor(generatedPosition) {
(0, _invariant.default)(false, "Not implemented");
}
generatedMappings() {
(0, _invariant.default)(false, "Not implemented");
}
eachMapping(callback, context = null, order = _constants.GENERATED_ORDER) {
(0, _invariant.default)(
order === _constants.GENERATED_ORDER,
`Iteration order not implemented: ${(0, _constants.iterationOrderToString)(order)}`,
);
for (const mapping of this.generatedMappings()) {
callback.call(context, mapping);
}
}
get file() {
return this._sourceMap.file;
}
sourceContentFor(source, nullOnMissing) {
(0, _invariant.default)(false, "Not implemented");
}
}
exports.default = AbstractConsumer;

View File

@@ -0,0 +1,63 @@
/**
* 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 {
GeneratedPositionLookup,
IConsumer,
IterationOrder,
Mapping,
SourcePosition,
} from './types';
import {GENERATED_ORDER, iterationOrderToString} from './constants';
import invariant from 'invariant';
// Implementation details shared between MappingsConsumer and SectionsConsumer
export default class AbstractConsumer implements IConsumer {
_sourceMap: {+file?: string, ...};
constructor(sourceMap: {+file?: string, ...}) {
this._sourceMap = sourceMap;
}
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition {
invariant(false, 'Not implemented');
}
generatedMappings(): Iterable<Mapping> {
invariant(false, 'Not implemented');
}
eachMapping(
callback: (mapping: Mapping) => unknown,
context?: unknown = null,
order?: IterationOrder = GENERATED_ORDER,
): void {
invariant(
order === GENERATED_ORDER,
`Iteration order not implemented: ${iterationOrderToString(order)}`,
);
for (const mapping of this.generatedMappings()) {
callback.call(context, mapping);
}
}
// flowlint-next-line unsafe-getters-setters:off
get file(): ?string {
return this._sourceMap.file;
}
sourceContentFor(source: string, nullOnMissing: true): ?string {
invariant(false, 'Not implemented');
}
}

View File

@@ -0,0 +1,54 @@
/**
* 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<<25b3906d78ba99d86fb91390016332ff>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/DelegatingConsumer.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {MixedSourceMap} from '../source-map';
import type {LookupBias} from './constants.js';
import type {
GeneratedPositionLookup,
IConsumer,
IterationOrder,
Mapping,
SourcePosition,
} from './types';
/**
* A source map consumer that supports both "basic" and "indexed" source maps.
* Uses `MappingsConsumer` and `SectionsConsumer` under the hood (via
* `createConsumer`).
*/
declare class DelegatingConsumer implements IConsumer {
static readonly GENERATED_ORDER: IterationOrder;
static readonly ORIGINAL_ORDER: IterationOrder;
static readonly GREATEST_LOWER_BOUND: LookupBias;
static readonly LEAST_UPPER_BOUND: LookupBias;
_rootConsumer: IConsumer;
constructor(sourceMap: MixedSourceMap);
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition;
generatedMappings(): Iterable<Mapping>;
eachMapping(
callback: (mapping: Mapping) => unknown,
context?: unknown,
order?: IterationOrder,
): void;
get file(): null | undefined | string;
sourceContentFor(
source: string,
nullOnMissing: true,
): null | undefined | string;
}
export default DelegatingConsumer;

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _constants = require("./constants");
var _createConsumer = _interopRequireDefault(require("./createConsumer"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
class DelegatingConsumer {
static GENERATED_ORDER = _constants.GENERATED_ORDER;
static ORIGINAL_ORDER = _constants.ORIGINAL_ORDER;
static GREATEST_LOWER_BOUND = _constants.GREATEST_LOWER_BOUND;
static LEAST_UPPER_BOUND = _constants.LEAST_UPPER_BOUND;
constructor(sourceMap) {
this._rootConsumer = (0, _createConsumer.default)(sourceMap);
return this._rootConsumer;
}
originalPositionFor(generatedPosition) {
return this._rootConsumer.originalPositionFor(generatedPosition);
}
generatedMappings() {
return this._rootConsumer.generatedMappings();
}
eachMapping(callback, context, order) {
return this._rootConsumer.eachMapping(callback, context, order);
}
get file() {
return this._rootConsumer.file;
}
sourceContentFor(source, nullOnMissing) {
return this._rootConsumer.sourceContentFor(source, nullOnMissing);
}
}
exports.default = DelegatingConsumer;

View File

@@ -0,0 +1,75 @@
/**
* 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 {MixedSourceMap} from '../source-map';
import type {LookupBias} from './constants.js';
import type {
GeneratedPositionLookup,
IConsumer,
IterationOrder,
Mapping,
SourcePosition,
} from './types';
import {
GENERATED_ORDER,
GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND,
ORIGINAL_ORDER,
} from './constants';
import createConsumer from './createConsumer';
/**
* A source map consumer that supports both "basic" and "indexed" source maps.
* Uses `MappingsConsumer` and `SectionsConsumer` under the hood (via
* `createConsumer`).
*/
export default class DelegatingConsumer implements IConsumer {
static +GENERATED_ORDER: IterationOrder = GENERATED_ORDER;
static +ORIGINAL_ORDER: IterationOrder = ORIGINAL_ORDER;
static +GREATEST_LOWER_BOUND: LookupBias = GREATEST_LOWER_BOUND;
static +LEAST_UPPER_BOUND: LookupBias = LEAST_UPPER_BOUND;
_rootConsumer: IConsumer;
// $FlowFixMe[incompatible-type]
constructor(sourceMap: MixedSourceMap): IConsumer {
this._rootConsumer = createConsumer(sourceMap);
return this._rootConsumer;
}
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition {
return this._rootConsumer.originalPositionFor(generatedPosition);
}
generatedMappings(): Iterable<Mapping> {
return this._rootConsumer.generatedMappings();
}
eachMapping(
callback: (mapping: Mapping) => unknown,
context?: unknown,
order?: IterationOrder,
): void {
return this._rootConsumer.eachMapping(callback, context, order);
}
// flowlint-next-line unsafe-getters-setters:off
get file(): ?string {
return this._rootConsumer.file;
}
sourceContentFor(source: string, nullOnMissing: true): ?string {
return this._rootConsumer.sourceContentFor(source, nullOnMissing);
}
}

View File

@@ -0,0 +1,50 @@
/**
* 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<<e2a6c983e649fe98c57dec4cc2e0aa65>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/MappingsConsumer.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {BasicSourceMap} from '../source-map';
import type {
GeneratedPositionLookup,
IConsumer,
Mapping,
SourcePosition,
} from './types';
import type {Number0} from 'ob1';
import AbstractConsumer from './AbstractConsumer';
/**
* A source map consumer that supports "basic" source maps (that have a
* `mappings` field and no sections).
*/
declare class MappingsConsumer extends AbstractConsumer implements IConsumer {
_sourceMap: BasicSourceMap;
_decodedMappings: null | undefined | ReadonlyArray<Mapping>;
_normalizedSources: null | undefined | ReadonlyArray<string>;
constructor(sourceMap: BasicSourceMap);
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition;
_decodeMappings(): Generator<Mapping, void, void>;
_normalizeAndCacheSources(): ReadonlyArray<string>;
_decodeAndCacheMappings(): ReadonlyArray<Mapping>;
generatedMappings(): Iterable<Mapping>;
_indexOfSource(source: string): null | undefined | Number0;
sourceContentFor(
source: string,
nullOnMissing: true,
): null | undefined | string;
}
export default MappingsConsumer;

View File

@@ -0,0 +1,194 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _AbstractConsumer = _interopRequireDefault(require("./AbstractConsumer"));
var _constants = require("./constants");
var _normalizeSourcePath = _interopRequireDefault(
require("./normalizeSourcePath"),
);
var _search = require("./search");
var _invariant = _interopRequireDefault(require("invariant"));
var _ob = require("ob1");
var _vlq = require("vlq");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
class MappingsConsumer extends _AbstractConsumer.default {
constructor(sourceMap) {
super(sourceMap);
this._sourceMap = sourceMap;
this._decodedMappings = null;
this._normalizedSources = null;
}
originalPositionFor(generatedPosition) {
const { line, column } = generatedPosition;
if (line == null || column == null) {
return {
..._constants.EMPTY_POSITION,
};
}
if (generatedPosition.bias != null) {
(0, _invariant.default)(
generatedPosition.bias === _constants.GREATEST_LOWER_BOUND,
`Unimplemented lookup bias: ${(0, _constants.lookupBiasToString)(generatedPosition.bias)}`,
);
}
const mappings = this._decodeAndCacheMappings();
const index = (0, _search.greatestLowerBound)(
mappings,
{
line,
column,
},
(position, mapping) => {
if (position.line === mapping.generatedLine) {
return (0, _ob.get0)(
(0, _ob.sub)(position.column, mapping.generatedColumn),
);
}
return (0, _ob.get0)(
(0, _ob.sub)(position.line, mapping.generatedLine),
);
},
);
if (
index != null &&
mappings[index].generatedLine === generatedPosition.line
) {
const mapping = mappings[index];
return {
source: mapping.source,
name: mapping.name,
line: mapping.originalLine,
column: mapping.originalColumn,
};
}
return {
..._constants.EMPTY_POSITION,
};
}
*_decodeMappings() {
let generatedLine = _constants.FIRST_LINE;
let generatedColumn = _constants.FIRST_COLUMN;
let originalLine = _constants.FIRST_LINE;
let originalColumn = _constants.FIRST_COLUMN;
let nameIndex = (0, _ob.add0)(0);
let sourceIndex = (0, _ob.add0)(0);
const normalizedSources = this._normalizeAndCacheSources();
const { mappings: mappingsRaw, names } = this._sourceMap;
let next;
const vlqCache = new Map();
for (let i = 0; i < mappingsRaw.length; i = next) {
switch (mappingsRaw[i]) {
case ";":
generatedLine = (0, _ob.inc)(generatedLine);
generatedColumn = _constants.FIRST_COLUMN;
case ",":
next = i + 1;
continue;
}
findNext: for (next = i + 1; next < mappingsRaw.length; ++next) {
switch (mappingsRaw[next]) {
case ";":
case ",":
break findNext;
}
}
const mappingRaw = mappingsRaw.slice(i, next);
let decodedVlqValues;
if (vlqCache.has(mappingRaw)) {
decodedVlqValues = vlqCache.get(mappingRaw);
} else {
decodedVlqValues = (0, _vlq.decode)(mappingRaw);
vlqCache.set(mappingRaw, decodedVlqValues);
}
(0, _invariant.default)(
Array.isArray(decodedVlqValues),
"Decoding VLQ tuple failed",
);
const [
generatedColumnDelta,
sourceIndexDelta,
originalLineDelta,
originalColumnDelta,
nameIndexDelta,
] = decodedVlqValues;
(0, _vlq.decode)(mappingRaw);
(0, _invariant.default)(
generatedColumnDelta != null,
"Invalid generated column delta",
);
generatedColumn = (0, _ob.add)(generatedColumn, generatedColumnDelta);
const mapping = {
generatedLine,
generatedColumn,
source: null,
name: null,
originalLine: null,
originalColumn: null,
};
if (sourceIndexDelta != null) {
sourceIndex = (0, _ob.add)(sourceIndex, sourceIndexDelta);
mapping.source = normalizedSources[(0, _ob.get0)(sourceIndex)];
(0, _invariant.default)(
originalLineDelta != null,
"Invalid original line delta",
);
(0, _invariant.default)(
originalColumnDelta != null,
"Invalid original column delta",
);
originalLine = (0, _ob.add)(originalLine, originalLineDelta);
originalColumn = (0, _ob.add)(originalColumn, originalColumnDelta);
mapping.originalLine = originalLine;
mapping.originalColumn = originalColumn;
if (nameIndexDelta != null) {
nameIndex = (0, _ob.add)(nameIndex, nameIndexDelta);
mapping.name = names[(0, _ob.get0)(nameIndex)];
}
}
yield mapping;
}
}
_normalizeAndCacheSources() {
if (!this._normalizedSources) {
this._normalizedSources = this._sourceMap.sources.map((source) =>
(0, _normalizeSourcePath.default)(source, this._sourceMap),
);
}
return this._normalizedSources;
}
_decodeAndCacheMappings() {
if (!this._decodedMappings) {
this._decodedMappings = [...this._decodeMappings()];
}
return this._decodedMappings;
}
generatedMappings() {
return this._decodeAndCacheMappings();
}
_indexOfSource(source) {
const idx = this._normalizeAndCacheSources().indexOf(
(0, _normalizeSourcePath.default)(source, this._sourceMap),
);
if (idx === -1) {
return null;
}
return (0, _ob.add0)(idx);
}
sourceContentFor(source, nullOnMissing) {
const { sourcesContent } = this._sourceMap;
if (!sourcesContent) {
return null;
}
const idx = this._indexOfSource(source);
if (idx == null) {
return null;
}
return sourcesContent[(0, _ob.get0)(idx)] ?? null;
}
}
exports.default = MappingsConsumer;

View File

@@ -0,0 +1,219 @@
/**
* 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
* @format
* @oncall react_native
*/
import type {BasicSourceMap} from '../source-map';
import type {
GeneratedPositionLookup,
IConsumer,
Mapping,
SourcePosition,
} from './types';
import type {Number0} from 'ob1';
import AbstractConsumer from './AbstractConsumer';
import {
EMPTY_POSITION,
FIRST_COLUMN,
FIRST_LINE,
GREATEST_LOWER_BOUND,
lookupBiasToString,
} from './constants';
import normalizeSourcePath from './normalizeSourcePath';
import {greatestLowerBound} from './search';
import invariant from 'invariant';
import {add, add0, get0, inc, sub} from 'ob1';
import {decode as decodeVlq} from 'vlq';
/**
* A source map consumer that supports "basic" source maps (that have a
* `mappings` field and no sections).
*/
export default class MappingsConsumer
extends AbstractConsumer
implements IConsumer
{
_sourceMap: BasicSourceMap;
_decodedMappings: ?ReadonlyArray<Mapping>;
_normalizedSources: ?ReadonlyArray<string>;
constructor(sourceMap: BasicSourceMap) {
super(sourceMap);
this._sourceMap = sourceMap;
this._decodedMappings = null;
this._normalizedSources = null;
}
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition {
const {line, column} = generatedPosition;
if (line == null || column == null) {
return {...EMPTY_POSITION};
}
if (generatedPosition.bias != null) {
invariant(
generatedPosition.bias === GREATEST_LOWER_BOUND,
`Unimplemented lookup bias: ${lookupBiasToString(
// $FlowFixMe[incompatible-type]
generatedPosition.bias,
)}`,
);
}
const mappings = this._decodeAndCacheMappings();
const index = greatestLowerBound(
mappings,
{line, column},
(position, mapping) => {
if (position.line === mapping.generatedLine) {
return get0(sub(position.column, mapping.generatedColumn));
}
return get0(sub(position.line, mapping.generatedLine));
},
);
if (
index != null &&
mappings[index].generatedLine === generatedPosition.line
) {
const mapping = mappings[index];
return {
source: mapping.source,
name: mapping.name,
line: mapping.originalLine,
column: mapping.originalColumn,
};
}
return {...EMPTY_POSITION};
}
*_decodeMappings(): Generator<Mapping, void, void> {
let generatedLine = FIRST_LINE;
let generatedColumn = FIRST_COLUMN;
let originalLine = FIRST_LINE;
let originalColumn = FIRST_COLUMN;
let nameIndex = add0(0);
let sourceIndex = add0(0);
const normalizedSources = this._normalizeAndCacheSources();
const {mappings: mappingsRaw, names} = this._sourceMap;
let next;
const vlqCache = new Map<string, any>();
for (let i = 0; i < mappingsRaw.length; i = next) {
switch (mappingsRaw[i]) {
case ';':
generatedLine = inc(generatedLine);
generatedColumn = FIRST_COLUMN;
/* falls through */
case ',':
next = i + 1;
continue;
}
findNext: for (next = i + 1; next < mappingsRaw.length; ++next) {
switch (mappingsRaw[next]) {
case ';':
/* falls through */
case ',':
break findNext;
}
}
const mappingRaw = mappingsRaw.slice(i, next);
let decodedVlqValues;
if (vlqCache.has(mappingRaw)) {
decodedVlqValues = vlqCache.get(mappingRaw);
} else {
decodedVlqValues = decodeVlq(mappingRaw);
vlqCache.set(mappingRaw, decodedVlqValues);
}
invariant(Array.isArray(decodedVlqValues), 'Decoding VLQ tuple failed');
const [
generatedColumnDelta,
sourceIndexDelta,
originalLineDelta,
originalColumnDelta,
nameIndexDelta,
] = decodedVlqValues;
decodeVlq(mappingRaw);
invariant(generatedColumnDelta != null, 'Invalid generated column delta');
generatedColumn = add(generatedColumn, generatedColumnDelta);
const mapping: {...Mapping, ...} = {
generatedLine,
generatedColumn,
source: null,
name: null,
originalLine: null,
originalColumn: null,
};
if (sourceIndexDelta != null) {
sourceIndex = add(sourceIndex, sourceIndexDelta);
mapping.source = normalizedSources[get0(sourceIndex)];
invariant(originalLineDelta != null, 'Invalid original line delta');
invariant(originalColumnDelta != null, 'Invalid original column delta');
originalLine = add(originalLine, originalLineDelta);
originalColumn = add(originalColumn, originalColumnDelta);
mapping.originalLine = originalLine;
mapping.originalColumn = originalColumn;
if (nameIndexDelta != null) {
nameIndex = add(nameIndex, nameIndexDelta);
mapping.name = names[get0(nameIndex)];
}
}
yield mapping;
}
}
_normalizeAndCacheSources(): ReadonlyArray<string> {
if (!this._normalizedSources) {
this._normalizedSources = this._sourceMap.sources.map(source =>
normalizeSourcePath(source, this._sourceMap),
);
}
return this._normalizedSources;
}
_decodeAndCacheMappings(): ReadonlyArray<Mapping> {
if (!this._decodedMappings) {
this._decodedMappings = [...this._decodeMappings()];
}
return this._decodedMappings;
}
generatedMappings(): Iterable<Mapping> {
return this._decodeAndCacheMappings();
}
_indexOfSource(source: string): ?Number0 {
const idx = this._normalizeAndCacheSources().indexOf(
normalizeSourcePath(source, this._sourceMap),
);
if (idx === -1) {
return null;
}
return add0(idx);
}
sourceContentFor(source: string, nullOnMissing: true): ?string {
const {sourcesContent} = this._sourceMap;
if (!sourcesContent) {
return null;
}
const idx = this._indexOfSource(source);
if (idx == null) {
return null;
}
return sourcesContent[get0(idx)] ?? null;
}
}

View File

@@ -0,0 +1,47 @@
/**
* 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<<19e73dfc942bfc06b0a44f0488b16947>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/SectionsConsumer.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {IndexMap} from '../source-map';
import type {
GeneratedOffset,
GeneratedPositionLookup,
IConsumer,
Mapping,
SourcePosition,
} from './types';
import AbstractConsumer from './AbstractConsumer';
/**
* A source map consumer that supports "indexed" source maps (that have a
* `sections` field and no top-level mappings).
*/
declare class SectionsConsumer extends AbstractConsumer implements IConsumer {
_consumers: ReadonlyArray<[GeneratedOffset, IConsumer]>;
constructor(sourceMap: IndexMap);
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition;
generatedMappings(): Iterable<Mapping>;
_consumerForPosition(
generatedPosition: GeneratedPositionLookup,
): null | undefined | [GeneratedOffset, IConsumer];
sourceContentFor(
source: string,
nullOnMissing: true,
): null | undefined | string;
}
export default SectionsConsumer;

View File

@@ -0,0 +1,105 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _AbstractConsumer = _interopRequireDefault(require("./AbstractConsumer"));
var _constants = require("./constants");
var _createConsumer = _interopRequireDefault(require("./createConsumer"));
var _positionMath = require("./positionMath");
var _search = require("./search");
var _ob = require("ob1");
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
class SectionsConsumer extends _AbstractConsumer.default {
constructor(sourceMap) {
super(sourceMap);
this._consumers = sourceMap.sections.map((section, index) => {
const generatedOffset = {
lines: (0, _ob.add0)(section.offset.line),
columns: (0, _ob.add0)(section.offset.column),
};
const consumer = (0, _createConsumer.default)(section.map);
return [generatedOffset, consumer];
});
}
originalPositionFor(generatedPosition) {
const [generatedOffset, consumer] =
this._consumerForPosition(generatedPosition) || [];
if (!consumer) {
return {
..._constants.EMPTY_POSITION,
};
}
return consumer.originalPositionFor(
(0, _positionMath.subtractOffsetFromPosition)(
generatedPosition,
generatedOffset,
),
);
}
*generatedMappings() {
for (const [generatedOffset, consumer] of this._consumers) {
let first = true;
for (const mapping of consumer.generatedMappings()) {
if (
first &&
((0, _ob.get1)(mapping.generatedLine) > 1 ||
(0, _ob.get0)(mapping.generatedColumn) > 0)
) {
yield {
generatedLine: _constants.FIRST_LINE,
generatedColumn: _constants.FIRST_COLUMN,
source: null,
name: null,
originalLine: null,
originalColumn: null,
};
}
first = false;
yield {
...mapping,
generatedLine: (0, _ob.add)(
mapping.generatedLine,
generatedOffset.lines,
),
generatedColumn: (0, _ob.add)(
mapping.generatedColumn,
generatedOffset.columns,
),
};
}
}
}
_consumerForPosition(generatedPosition) {
const { line, column } = generatedPosition;
if (line == null || column == null) {
return null;
}
const index = (0, _search.greatestLowerBound)(
this._consumers,
generatedPosition,
(position, [offset]) => {
const line0 = (0, _ob.sub1)(line);
const column0 = column;
if (line0 === offset.lines) {
return (0, _ob.get0)((0, _ob.sub)(column0, offset.columns));
}
return (0, _ob.get0)((0, _ob.sub)(line0, offset.lines));
},
);
return index != null ? this._consumers[index] : null;
}
sourceContentFor(source, nullOnMissing) {
for (const [_, consumer] of this._consumers) {
const content = consumer.sourceContentFor(source, nullOnMissing);
if (content != null) {
return content;
}
}
return null;
}
}
exports.default = SectionsConsumer;

View File

@@ -0,0 +1,124 @@
/**
* 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 {IndexMap} from '../source-map';
import type {
GeneratedOffset,
GeneratedPositionLookup,
IConsumer,
Mapping,
SourcePosition,
} from './types';
import AbstractConsumer from './AbstractConsumer';
import {EMPTY_POSITION, FIRST_COLUMN, FIRST_LINE} from './constants';
import createConsumer from './createConsumer';
import {subtractOffsetFromPosition} from './positionMath';
import {greatestLowerBound} from './search';
import {add, add0, get0, get1, sub, sub1} from 'ob1';
/**
* A source map consumer that supports "indexed" source maps (that have a
* `sections` field and no top-level mappings).
*/
export default class SectionsConsumer
extends AbstractConsumer
implements IConsumer
{
_consumers: ReadonlyArray<[GeneratedOffset, IConsumer]>;
constructor(sourceMap: IndexMap) {
super(sourceMap);
this._consumers = sourceMap.sections.map((section, index) => {
const generatedOffset = {
lines: add0(section.offset.line),
columns: add0(section.offset.column),
};
const consumer = createConsumer(section.map);
return [generatedOffset, consumer];
});
}
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition {
const [generatedOffset, consumer] =
this._consumerForPosition(generatedPosition) || [];
if (!consumer) {
return {...EMPTY_POSITION};
}
return consumer.originalPositionFor(
subtractOffsetFromPosition(generatedPosition, generatedOffset),
);
}
*generatedMappings(): Iterable<Mapping> {
for (const [generatedOffset, consumer] of this._consumers) {
let first = true;
for (const mapping of consumer.generatedMappings()) {
if (
first &&
(get1(mapping.generatedLine) > 1 || get0(mapping.generatedColumn) > 0)
) {
yield {
generatedLine: FIRST_LINE,
generatedColumn: FIRST_COLUMN,
source: null,
name: null,
originalLine: null,
originalColumn: null,
};
}
first = false;
yield {
...mapping,
generatedLine: add(mapping.generatedLine, generatedOffset.lines),
generatedColumn: add(
mapping.generatedColumn,
generatedOffset.columns,
),
};
}
}
}
_consumerForPosition(
generatedPosition: GeneratedPositionLookup,
): ?[GeneratedOffset, IConsumer] {
const {line, column} = generatedPosition;
if (line == null || column == null) {
return null;
}
const index = greatestLowerBound(
this._consumers,
generatedPosition,
(position, [offset]) => {
const line0 = sub1(line);
const column0 = column;
if (line0 === offset.lines) {
return get0(sub(column0, offset.columns));
}
return get0(sub(line0, offset.lines));
},
);
return index != null ? this._consumers[index] : null;
}
sourceContentFor(source: string, nullOnMissing: true): ?string {
for (const [_, consumer] of this._consumers) {
const content = consumer.sourceContentFor(source, nullOnMissing);
if (content != null) {
return content;
}
}
return null;
}
}

View File

@@ -0,0 +1,46 @@
/**
* 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<<bcbe0a1f886534ee2f99a12da9c16270>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/constants.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {Number0, Number1} from 'ob1';
declare const FIRST_COLUMN: Number0;
declare const FIRST_LINE: Number1;
export declare type IterationOrder = symbol & {__IterationOrder__: string};
declare const GENERATED_ORDER: IterationOrder;
declare const ORIGINAL_ORDER: IterationOrder;
export declare type LookupBias = symbol & {__LookupBias__: string};
declare const GREATEST_LOWER_BOUND: LookupBias;
declare const LEAST_UPPER_BOUND: LookupBias;
declare const EMPTY_POSITION: Readonly<{
source: null;
name: null;
line: null;
column: null;
}>;
declare function iterationOrderToString(x: IterationOrder): string;
declare function lookupBiasToString(x: LookupBias): string;
export {
FIRST_COLUMN,
FIRST_LINE,
GENERATED_ORDER,
ORIGINAL_ORDER,
GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND,
EMPTY_POSITION,
iterationOrderToString,
lookupBiasToString,
};

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.ORIGINAL_ORDER =
exports.LEAST_UPPER_BOUND =
exports.GREATEST_LOWER_BOUND =
exports.GENERATED_ORDER =
exports.FIRST_LINE =
exports.FIRST_COLUMN =
exports.EMPTY_POSITION =
void 0;
exports.iterationOrderToString = iterationOrderToString;
exports.lookupBiasToString = lookupBiasToString;
var _ob = require("ob1");
const FIRST_COLUMN = (exports.FIRST_COLUMN = (0, _ob.add0)(0));
const FIRST_LINE = (exports.FIRST_LINE = (0, _ob.add1)(0));
const GENERATED_ORDER = (exports.GENERATED_ORDER = "GENERATED_ORDER");
const ORIGINAL_ORDER = (exports.ORIGINAL_ORDER = "ORIGINAL_ORDER");
const GREATEST_LOWER_BOUND = (exports.GREATEST_LOWER_BOUND =
"GREATEST_LOWER_BOUND");
const LEAST_UPPER_BOUND = (exports.LEAST_UPPER_BOUND = "LEAST_UPPER_BOUND");
const EMPTY_POSITION = (exports.EMPTY_POSITION = Object.freeze({
source: null,
name: null,
line: null,
column: null,
}));
function iterationOrderToString(x) {
return x;
}
function lookupBiasToString(x) {
return x;
}

View File

@@ -0,0 +1,57 @@
/**
* 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 {Number0, Number1} from 'ob1';
import {add0, add1} from 'ob1';
const FIRST_COLUMN: Number0 = add0(0);
const FIRST_LINE: Number1 = add1(0);
export opaque type IterationOrder = 'GENERATED_ORDER' | 'ORIGINAL_ORDER';
const GENERATED_ORDER: IterationOrder = 'GENERATED_ORDER';
const ORIGINAL_ORDER: IterationOrder = 'ORIGINAL_ORDER';
export opaque type LookupBias = 'GREATEST_LOWER_BOUND' | 'LEAST_UPPER_BOUND';
const GREATEST_LOWER_BOUND: LookupBias = 'GREATEST_LOWER_BOUND';
const LEAST_UPPER_BOUND: LookupBias = 'LEAST_UPPER_BOUND';
const EMPTY_POSITION: Readonly<{
source: null,
name: null,
line: null,
column: null,
}> = Object.freeze({
source: null,
name: null,
line: null,
column: null,
});
function iterationOrderToString(x: IterationOrder): string {
return x;
}
function lookupBiasToString(x: LookupBias): string {
return x;
}
export {
FIRST_COLUMN,
FIRST_LINE,
GENERATED_ORDER,
ORIGINAL_ORDER,
GREATEST_LOWER_BOUND,
LEAST_UPPER_BOUND,
EMPTY_POSITION,
iterationOrderToString,
lookupBiasToString,
};

View File

@@ -0,0 +1,22 @@
/**
* 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<<3628df6a457f3d3d7c15f9e248338e4e>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/createConsumer.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {MixedSourceMap} from '../source-map';
import type {IConsumer} from './types';
declare function createConsumer(sourceMap: MixedSourceMap): IConsumer;
export default createConsumer;

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = createConsumer;
var _MappingsConsumer = _interopRequireDefault(require("./MappingsConsumer"));
var _SectionsConsumer = _interopRequireDefault(require("./SectionsConsumer"));
var _invariant = _interopRequireDefault(require("invariant"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
function createConsumer(sourceMap) {
(0, _invariant.default)(
sourceMap.version === "3" || sourceMap.version === 3,
`Unrecognized source map format version: ${sourceMap.version}`,
);
if (sourceMap.mappings === undefined) {
return new _SectionsConsumer.default(sourceMap);
}
return new _MappingsConsumer.default(sourceMap);
}

View File

@@ -0,0 +1,30 @@
/**
* 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 {MixedSourceMap} from '../source-map';
import type {IConsumer} from './types';
import MappingsConsumer from './MappingsConsumer';
import SectionsConsumer from './SectionsConsumer';
import invariant from 'invariant';
export default function createConsumer(sourceMap: MixedSourceMap): IConsumer {
invariant(
(sourceMap.version as unknown) === '3' || sourceMap.version === 3,
`Unrecognized source map format version: ${sourceMap.version}`,
);
// eslint-disable-next-line lint/strictly-null
if (sourceMap.mappings === undefined) {
return new SectionsConsumer(sourceMap);
}
return new MappingsConsumer(sourceMap);
}

23
node_modules/metro-source-map/src/Consumer/index.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<<62d8c1b54e47245bd0ef831be2b7049d>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/index.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import DelegatingConsumer from './DelegatingConsumer';
declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof DelegatingConsumer;
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

13
node_modules/metro-source-map/src/Consumer/index.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _DelegatingConsumer = _interopRequireDefault(
require("./DelegatingConsumer"),
);
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
var _default = (exports.default = _DelegatingConsumer.default);

View File

@@ -0,0 +1,15 @@
/**
* 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
*/
// Implements an API-compatible subset of source-map's `SourceMapConsumer`.
import DelegatingConsumer from './DelegatingConsumer';
export default DelegatingConsumer;

View File

@@ -0,0 +1,22 @@
/**
* 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<<f0cb08627027adbc9cc7b4b9c8caa208>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/normalizeSourcePath.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
declare function normalizeSourcePath(
sourceInput: string,
map: {readonly sourceRoot?: null | undefined | string},
): string;
export default normalizeSourcePath;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = normalizeSourcePath;
var _util = _interopRequireDefault(require("source-map/lib/util"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
function normalizeSourcePath(sourceInput, map) {
const { sourceRoot } = map;
let source = sourceInput;
source = String(source);
source = _util.default.normalize(source);
source =
sourceRoot != null &&
_util.default.isAbsolute(sourceRoot) &&
_util.default.isAbsolute(source)
? _util.default.relative(sourceRoot, source)
: source;
return source;
}

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.
*
* @flow strict-local
* @format
* @oncall react_native
*/
// flowlint-next-line untyped-import:off
import util from 'source-map/lib/util';
// Extracted from source-map@0.5.6's SourceMapConsumer
export default function normalizeSourcePath(
sourceInput: string,
map: {+sourceRoot?: ?string, ...},
): string {
const {sourceRoot} = map;
let source = sourceInput;
source = String(source);
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
source = util.normalize(source);
// Always ensure that absolute sources are internally stored relative to
// the source root, if the source root is absolute. Not doing this would
// be particularly problematic when the source root is a prefix of the
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
source =
sourceRoot != null && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
? util.relative(sourceRoot, source)
: source;
return source;
}

View File

@@ -0,0 +1,32 @@
/**
* 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<<6db8c7c1cbb86a47de92e1b9565dd624>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/positionMath.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {GeneratedOffset} from './types';
import type {Number0, Number1} from 'ob1';
export declare function shiftPositionByOffset<
T extends {
readonly line: null | undefined | Number1;
readonly column: null | undefined | Number0;
},
>(pos: T, offset: GeneratedOffset): T;
export declare function subtractOffsetFromPosition<
T extends {
readonly line: null | undefined | Number1;
readonly column: null | undefined | Number0;
},
>(pos: T, offset: GeneratedOffset): T;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.shiftPositionByOffset = shiftPositionByOffset;
exports.subtractOffsetFromPosition = subtractOffsetFromPosition;
var _ob = require("ob1");
function shiftPositionByOffset(pos, offset) {
return {
...pos,
line: pos.line != null ? (0, _ob.add)(pos.line, offset.lines) : null,
column:
pos.column != null ? (0, _ob.add)(pos.column, offset.columns) : null,
};
}
function subtractOffsetFromPosition(pos, offset) {
if (pos.line === (0, _ob.add1)(offset.lines)) {
return shiftPositionByOffset(pos, {
lines: (0, _ob.neg)(offset.lines),
columns: (0, _ob.neg)(offset.columns),
});
}
return shiftPositionByOffset(pos, {
lines: (0, _ob.neg)(offset.lines),
columns: (0, _ob.add0)(0),
});
}

View File

@@ -0,0 +1,48 @@
/**
* 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 {GeneratedOffset} from './types';
import type {Number0, Number1} from 'ob1';
import {add, add0, add1, neg} from 'ob1';
export function shiftPositionByOffset<
T extends {
+line: ?Number1,
+column: ?Number0,
...
},
>(pos: T, offset: GeneratedOffset): T {
return {
...pos,
line: pos.line != null ? add(pos.line, offset.lines) : null,
column: pos.column != null ? add(pos.column, offset.columns) : null,
};
}
export function subtractOffsetFromPosition<
T extends {
+line: ?Number1,
+column: ?Number0,
...
},
>(pos: T, offset: GeneratedOffset): T {
if (pos.line === add1(offset.lines)) {
return shiftPositionByOffset(pos, {
lines: neg(offset.lines),
columns: neg(offset.columns),
});
}
return shiftPositionByOffset(pos, {
lines: neg(offset.lines),
columns: add0(0),
});
}

22
node_modules/metro-source-map/src/Consumer/search.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* 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<<c44d93a454a950171d9456512714303b>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/search.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
export declare function greatestLowerBound<T, U>(
elements: ReadonlyArray<T>,
target: U,
comparator: ($$PARAM_0$$: U, $$PARAM_1$$: T) => number,
): null | undefined | number;

24
node_modules/metro-source-map/src/Consumer/search.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.greatestLowerBound = greatestLowerBound;
function greatestLowerBound(elements, target, comparator) {
let first = 0;
let it = 0;
let count = elements.length;
let step;
while (count > 0) {
it = first;
step = Math.floor(count / 2);
it = it + step;
if (comparator(target, elements[it]) >= 0) {
first = ++it;
count = count - (step + 1);
} else {
count = step;
}
}
return first ? first - 1 : null;
}

View File

@@ -0,0 +1,33 @@
/**
* 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
*/
export function greatestLowerBound<T, U>(
elements: ReadonlyArray<T>,
target: U,
comparator: (U, T) => number,
): ?number {
let first = 0;
let it = 0;
let count = elements.length;
let step;
while (count > 0) {
it = first;
step = Math.floor(count / 2);
it = it + step;
if (comparator(target, elements[it]) >= 0) {
first = ++it;
count = count - (step + 1);
} else {
count = step;
}
}
return first ? first - 1 : null;
}

64
node_modules/metro-source-map/src/Consumer/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,64 @@
/**
* 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<<5fbef54d757c6130889a1889f7d71255>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-source-map/src/Consumer/types.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
import type {IterationOrder, LookupBias} from './constants';
import type {Number0, Number1} from 'ob1';
export type {IterationOrder, LookupBias};
export type GeneratedOffset = {
readonly lines: Number0;
readonly columns: Number0;
};
export type SourcePosition = {
source: null | undefined | string;
line: null | undefined | Number1;
column: null | undefined | Number0;
name: null | undefined | string;
};
export type GeneratedPosition = {
readonly line: Number1;
readonly column: Number0;
};
export type GeneratedPositionLookup = {
readonly line: null | undefined | Number1;
readonly column: null | undefined | Number0;
readonly bias?: LookupBias;
};
export type Mapping = Readonly<{
source: null | undefined | string;
generatedLine: Number1;
generatedColumn: Number0;
originalLine: null | undefined | Number1;
originalColumn: null | undefined | Number0;
name: null | undefined | string;
}>;
export interface IConsumer {
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition;
generatedMappings(): Iterable<Mapping>;
eachMapping(
callback: (mapping: Mapping) => unknown,
context?: unknown,
order?: IterationOrder,
): void;
get file(): null | undefined | string;
sourceContentFor(
source: string,
nullOnMissing: true,
): null | undefined | string;
}

1
node_modules/metro-source-map/src/Consumer/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";

View File

@@ -0,0 +1,67 @@
/**
* 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 {IterationOrder, LookupBias} from './constants';
import type {Number0, Number1} from 'ob1';
export type {IterationOrder, LookupBias};
export type GeneratedOffset = {+lines: Number0, +columns: Number0};
export type SourcePosition = {
source: ?string,
line: ?Number1,
column: ?Number0,
name: ?string,
...
};
export type GeneratedPosition = {
+line: Number1,
+column: Number0,
...
};
export type GeneratedPositionLookup = {
+line: ?Number1,
+column: ?Number0,
+bias?: LookupBias,
...
};
export type Mapping = Readonly<{
source: ?string,
generatedLine: Number1,
generatedColumn: Number0,
originalLine: ?Number1,
originalColumn: ?Number0,
name: ?string,
...
}>;
export interface IConsumer {
originalPositionFor(
generatedPosition: GeneratedPositionLookup,
): SourcePosition;
generatedMappings(): Iterable<Mapping>;
eachMapping(
callback: (mapping: Mapping) => unknown,
context?: unknown,
order?: IterationOrder,
): void;
// flowlint-next-line unsafe-getters-setters:off
get file(): ?string;
sourceContentFor(
source: string,
/* nullOnMissing = false behaves inconsistently upstream, so we don't support it */
nullOnMissing: true,
): ?string;
}