metro-source-map 0.83.0 → 0.83.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/B64Builder.d.ts +47 -0
- package/src/B64Builder.js +10 -3
- package/src/B64Builder.js.flow +2 -6
- package/src/BundleBuilder.d.ts +43 -0
- package/src/BundleBuilder.js +6 -4
- package/src/BundleBuilder.js.flow +2 -6
- package/src/Consumer/AbstractConsumer.d.ts +37 -0
- package/src/Consumer/AbstractConsumer.js +17 -10
- package/src/Consumer/AbstractConsumer.js.flow +4 -8
- package/src/Consumer/DelegatingConsumer.d.ts +47 -0
- package/src/Consumer/DelegatingConsumer.js +15 -13
- package/src/Consumer/DelegatingConsumer.js.flow +6 -9
- package/src/Consumer/MappingsConsumer.d.ts +43 -0
- package/src/Consumer/MappingsConsumer.js +68 -51
- package/src/Consumer/MappingsConsumer.js.flow +14 -15
- package/src/Consumer/SectionsConsumer.d.ts +40 -0
- package/src/Consumer/SectionsConsumer.js +38 -24
- package/src/Consumer/SectionsConsumer.js.flow +11 -12
- package/src/Consumer/constants.d.ts +39 -0
- package/src/Consumer/constants.js +23 -20
- package/src/Consumer/constants.js.flow +8 -5
- package/src/Consumer/createConsumer.d.ts +15 -0
- package/src/Consumer/createConsumer.js +14 -8
- package/src/Consumer/createConsumer.js.flow +5 -9
- package/src/Consumer/index.d.ts +16 -0
- package/src/Consumer/index.js +11 -2
- package/src/Consumer/index.js.flow +2 -4
- package/src/Consumer/normalizeSourcePath.d.ts +15 -0
- package/src/Consumer/normalizeSourcePath.js +13 -5
- package/src/Consumer/normalizeSourcePath.js.flow +2 -6
- package/src/Consumer/positionMath.d.ts +25 -0
- package/src/Consumer/positionMath.js +14 -12
- package/src/Consumer/positionMath.js.flow +4 -8
- package/src/Consumer/search.d.ts +15 -0
- package/src/Consumer/search.js +4 -3
- package/src/Consumer/search.js.flow +1 -5
- package/src/Consumer/types.d.ts +57 -0
- package/src/Consumer/{types.flow.js.flow → types.js.flow} +0 -2
- package/src/Generator.d.ts +107 -0
- package/src/Generator.js +16 -13
- package/src/Generator.js.flow +2 -6
- package/src/composeSourceMaps.d.ts +16 -0
- package/src/composeSourceMaps.js +19 -11
- package/src/composeSourceMaps.js.flow +11 -11
- package/src/encode.d.ts +66 -0
- package/src/encode.js +4 -1
- package/src/encode.js.flow +9 -5
- package/src/generateFunctionMap.d.ts +45 -0
- package/src/generateFunctionMap.js +52 -30
- package/src/generateFunctionMap.js.flow +21 -22
- package/src/source-map.d.ts +130 -36
- package/src/source-map.js +77 -25
- package/src/source-map.js.flow +42 -17
- /package/src/Consumer/{types.flow.js → types.js} +0 -0
|
@@ -9,20 +9,18 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {MixedSourceMap} from '../source-map';
|
|
15
|
-
import type {IConsumer} from './types
|
|
13
|
+
import type {IConsumer} from './types';
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
import MappingsConsumer from './MappingsConsumer';
|
|
16
|
+
import SectionsConsumer from './SectionsConsumer';
|
|
17
|
+
import invariant from 'invariant';
|
|
18
18
|
|
|
19
|
-
function createConsumer(sourceMap: MixedSourceMap): IConsumer {
|
|
19
|
+
export default function createConsumer(sourceMap: MixedSourceMap): IConsumer {
|
|
20
20
|
invariant(
|
|
21
21
|
(sourceMap.version: mixed) === '3' || sourceMap.version === 3,
|
|
22
22
|
`Unrecognized source map format version: ${sourceMap.version}`,
|
|
23
23
|
);
|
|
24
|
-
const MappingsConsumer = require('./MappingsConsumer');
|
|
25
|
-
const SectionsConsumer = require('./SectionsConsumer');
|
|
26
24
|
|
|
27
25
|
// eslint-disable-next-line lint/strictly-null
|
|
28
26
|
if (sourceMap.mappings === undefined) {
|
|
@@ -30,5 +28,3 @@ function createConsumer(sourceMap: MixedSourceMap): IConsumer {
|
|
|
30
28
|
}
|
|
31
29
|
return new MappingsConsumer(sourceMap);
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
module.exports = createConsumer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import DelegatingConsumer from './DelegatingConsumer';
|
|
12
|
+
|
|
13
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof DelegatingConsumer;
|
|
14
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
15
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
16
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
package/src/Consumer/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _DelegatingConsumer = _interopRequireDefault(
|
|
8
|
+
require("./DelegatingConsumer"),
|
|
9
|
+
);
|
|
10
|
+
function _interopRequireDefault(e) {
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
12
|
+
}
|
|
13
|
+
var _default = (exports.default = _DelegatingConsumer.default);
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
// Implements an API-compatible subset of source-map's `SourceMapConsumer`.
|
|
15
|
-
|
|
13
|
+
import DelegatingConsumer from './DelegatingConsumer';
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
export default DelegatingConsumer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare function normalizeSourcePath(
|
|
12
|
+
sourceInput: string,
|
|
13
|
+
map: {readonly sourceRoot?: null | undefined | string},
|
|
14
|
+
): string;
|
|
15
|
+
export default normalizeSourcePath;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = normalizeSourcePath;
|
|
7
|
+
var _util = _interopRequireDefault(require("source-map/lib/util"));
|
|
8
|
+
function _interopRequireDefault(e) {
|
|
9
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
|
+
}
|
|
4
11
|
function normalizeSourcePath(sourceInput, map) {
|
|
5
12
|
const { sourceRoot } = map;
|
|
6
13
|
let source = sourceInput;
|
|
7
14
|
source = String(source);
|
|
8
|
-
source =
|
|
15
|
+
source = _util.default.normalize(source);
|
|
9
16
|
source =
|
|
10
|
-
sourceRoot != null &&
|
|
11
|
-
|
|
17
|
+
sourceRoot != null &&
|
|
18
|
+
_util.default.isAbsolute(sourceRoot) &&
|
|
19
|
+
_util.default.isAbsolute(source)
|
|
20
|
+
? _util.default.relative(sourceRoot, source)
|
|
12
21
|
: source;
|
|
13
22
|
return source;
|
|
14
23
|
}
|
|
15
|
-
module.exports = normalizeSourcePath;
|
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
// flowlint-next-line untyped-import:off
|
|
15
|
-
|
|
13
|
+
import util from 'source-map/lib/util';
|
|
16
14
|
|
|
17
15
|
// Extracted from source-map@0.5.6's SourceMapConsumer
|
|
18
|
-
function normalizeSourcePath(
|
|
16
|
+
export default function normalizeSourcePath(
|
|
19
17
|
sourceInput: string,
|
|
20
18
|
map: {+sourceRoot?: ?string, ...},
|
|
21
19
|
): string {
|
|
@@ -38,5 +36,3 @@ function normalizeSourcePath(
|
|
|
38
36
|
|
|
39
37
|
return source;
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
module.exports = normalizeSourcePath;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {GeneratedOffset} from './types';
|
|
12
|
+
import type {Number0, Number1} from 'ob1';
|
|
13
|
+
|
|
14
|
+
export declare function shiftPositionByOffset<
|
|
15
|
+
T extends {
|
|
16
|
+
readonly line: null | undefined | Number1;
|
|
17
|
+
readonly column: null | undefined | Number0;
|
|
18
|
+
},
|
|
19
|
+
>(pos: T, offset: GeneratedOffset): T;
|
|
20
|
+
export declare function subtractOffsetFromPosition<
|
|
21
|
+
T extends {
|
|
22
|
+
readonly line: null | undefined | Number1;
|
|
23
|
+
readonly column: null | undefined | Number0;
|
|
24
|
+
},
|
|
25
|
+
>(pos: T, offset: GeneratedOffset): T;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.shiftPositionByOffset = shiftPositionByOffset;
|
|
7
|
+
exports.subtractOffsetFromPosition = subtractOffsetFromPosition;
|
|
8
|
+
var _ob = require("ob1");
|
|
4
9
|
function shiftPositionByOffset(pos, offset) {
|
|
5
10
|
return {
|
|
6
11
|
...pos,
|
|
7
|
-
line: pos.line != null ? add(pos.line, offset.lines) : null,
|
|
8
|
-
column:
|
|
12
|
+
line: pos.line != null ? (0, _ob.add)(pos.line, offset.lines) : null,
|
|
13
|
+
column:
|
|
14
|
+
pos.column != null ? (0, _ob.add)(pos.column, offset.columns) : null,
|
|
9
15
|
};
|
|
10
16
|
}
|
|
11
17
|
function subtractOffsetFromPosition(pos, offset) {
|
|
12
|
-
if (pos.line === add1(offset.lines)) {
|
|
18
|
+
if (pos.line === (0, _ob.add1)(offset.lines)) {
|
|
13
19
|
return shiftPositionByOffset(pos, {
|
|
14
|
-
lines: neg(offset.lines),
|
|
15
|
-
columns: neg(offset.columns),
|
|
20
|
+
lines: (0, _ob.neg)(offset.lines),
|
|
21
|
+
columns: (0, _ob.neg)(offset.columns),
|
|
16
22
|
});
|
|
17
23
|
}
|
|
18
24
|
return shiftPositionByOffset(pos, {
|
|
19
|
-
lines: neg(offset.lines),
|
|
20
|
-
columns: add0(0),
|
|
25
|
+
lines: (0, _ob.neg)(offset.lines),
|
|
26
|
+
columns: (0, _ob.add0)(0),
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
|
-
module.exports = {
|
|
24
|
-
shiftPositionByOffset,
|
|
25
|
-
subtractOffsetFromPosition,
|
|
26
|
-
};
|
|
@@ -9,14 +9,12 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type {GeneratedOffset} from './types.flow';
|
|
12
|
+
import type {GeneratedOffset} from './types';
|
|
15
13
|
import type {Number0, Number1} from 'ob1';
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
import {add, add0, add1, neg} from 'ob1';
|
|
18
16
|
|
|
19
|
-
function shiftPositionByOffset<
|
|
17
|
+
export function shiftPositionByOffset<
|
|
20
18
|
T: {
|
|
21
19
|
+line: ?Number1,
|
|
22
20
|
+column: ?Number0,
|
|
@@ -30,7 +28,7 @@ function shiftPositionByOffset<
|
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
function subtractOffsetFromPosition<
|
|
31
|
+
export function subtractOffsetFromPosition<
|
|
34
32
|
T: {
|
|
35
33
|
+line: ?Number1,
|
|
36
34
|
+column: ?Number0,
|
|
@@ -48,5 +46,3 @@ function subtractOffsetFromPosition<
|
|
|
48
46
|
columns: add0(0),
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
module.exports = {shiftPositionByOffset, subtractOffsetFromPosition};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export declare function greatestLowerBound<T, U>(
|
|
12
|
+
elements: ReadonlyArray<T>,
|
|
13
|
+
target: U,
|
|
14
|
+
comparator: ($$PARAM_0$$: U, $$PARAM_1$$: T) => number,
|
|
15
|
+
): null | undefined | number;
|
package/src/Consumer/search.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.greatestLowerBound = greatestLowerBound;
|
|
3
7
|
function greatestLowerBound(elements, target, comparator) {
|
|
4
8
|
let first = 0;
|
|
5
9
|
let it = 0;
|
|
@@ -18,6 +22,3 @@ function greatestLowerBound(elements, target, comparator) {
|
|
|
18
22
|
}
|
|
19
23
|
return first ? first - 1 : null;
|
|
20
24
|
}
|
|
21
|
-
module.exports = {
|
|
22
|
-
greatestLowerBound,
|
|
23
|
-
};
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function greatestLowerBound<T, U>(
|
|
12
|
+
export function greatestLowerBound<T, U>(
|
|
15
13
|
elements: $ReadOnlyArray<T>,
|
|
16
14
|
target: U,
|
|
17
15
|
comparator: (U, T) => number,
|
|
@@ -33,5 +31,3 @@ function greatestLowerBound<T, U>(
|
|
|
33
31
|
}
|
|
34
32
|
return first ? first - 1 : null;
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
module.exports = {greatestLowerBound};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {IterationOrder, LookupBias} from './constants';
|
|
12
|
+
import type {Number0, Number1} from 'ob1';
|
|
13
|
+
|
|
14
|
+
export type {IterationOrder, LookupBias};
|
|
15
|
+
export type GeneratedOffset = {
|
|
16
|
+
readonly lines: Number0;
|
|
17
|
+
readonly columns: Number0;
|
|
18
|
+
};
|
|
19
|
+
export type SourcePosition = {
|
|
20
|
+
source: null | undefined | string;
|
|
21
|
+
line: null | undefined | Number1;
|
|
22
|
+
column: null | undefined | Number0;
|
|
23
|
+
name: null | undefined | string;
|
|
24
|
+
};
|
|
25
|
+
export type GeneratedPosition = {
|
|
26
|
+
readonly line: Number1;
|
|
27
|
+
readonly column: Number0;
|
|
28
|
+
};
|
|
29
|
+
export type GeneratedPositionLookup = {
|
|
30
|
+
readonly line: null | undefined | Number1;
|
|
31
|
+
readonly column: null | undefined | Number0;
|
|
32
|
+
readonly bias?: LookupBias;
|
|
33
|
+
};
|
|
34
|
+
export type Mapping = Readonly<{
|
|
35
|
+
source: null | undefined | string;
|
|
36
|
+
generatedLine: Number1;
|
|
37
|
+
generatedColumn: Number0;
|
|
38
|
+
originalLine: null | undefined | Number1;
|
|
39
|
+
originalColumn: null | undefined | Number0;
|
|
40
|
+
name: null | undefined | string;
|
|
41
|
+
}>;
|
|
42
|
+
export interface IConsumer {
|
|
43
|
+
originalPositionFor(
|
|
44
|
+
generatedPosition: GeneratedPositionLookup,
|
|
45
|
+
): SourcePosition;
|
|
46
|
+
generatedMappings(): Iterable<Mapping>;
|
|
47
|
+
eachMapping(
|
|
48
|
+
callback: (mapping: Mapping) => unknown,
|
|
49
|
+
context?: unknown,
|
|
50
|
+
order?: IterationOrder,
|
|
51
|
+
): void;
|
|
52
|
+
get file(): null | undefined | string;
|
|
53
|
+
sourceContentFor(
|
|
54
|
+
source: string,
|
|
55
|
+
nullOnMissing: true,
|
|
56
|
+
): null | undefined | string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
BasicSourceMap,
|
|
13
|
+
FBSourceFunctionMap,
|
|
14
|
+
FBSourceMetadata,
|
|
15
|
+
} from './source-map';
|
|
16
|
+
|
|
17
|
+
import B64Builder from './B64Builder';
|
|
18
|
+
|
|
19
|
+
type FileFlags = Readonly<{addToIgnoreList?: boolean}>;
|
|
20
|
+
/**
|
|
21
|
+
* Generates a source map from raw mappings.
|
|
22
|
+
*
|
|
23
|
+
* Raw mappings are a set of 2, 4, or five elements:
|
|
24
|
+
*
|
|
25
|
+
* - line and column number in the generated source
|
|
26
|
+
* - line and column number in the original source
|
|
27
|
+
* - symbol name in the original source
|
|
28
|
+
*
|
|
29
|
+
* Mappings have to be passed in the order appearance in the generated source.
|
|
30
|
+
*/
|
|
31
|
+
declare class Generator {
|
|
32
|
+
builder: B64Builder;
|
|
33
|
+
last: {
|
|
34
|
+
generatedColumn: number;
|
|
35
|
+
generatedLine: number;
|
|
36
|
+
name: number;
|
|
37
|
+
source: number;
|
|
38
|
+
sourceColumn: number;
|
|
39
|
+
sourceLine: number;
|
|
40
|
+
};
|
|
41
|
+
names: IndexedSet;
|
|
42
|
+
source: number;
|
|
43
|
+
sources: Array<string>;
|
|
44
|
+
sourcesContent: Array<null | undefined | string>;
|
|
45
|
+
x_facebook_sources: Array<null | undefined | FBSourceMetadata>;
|
|
46
|
+
x_google_ignoreList: Array<number>;
|
|
47
|
+
constructor();
|
|
48
|
+
/**
|
|
49
|
+
* Mark the beginning of a new source file.
|
|
50
|
+
*/
|
|
51
|
+
startFile(
|
|
52
|
+
file: string,
|
|
53
|
+
code: string,
|
|
54
|
+
functionMap: null | undefined | FBSourceFunctionMap,
|
|
55
|
+
flags?: FileFlags,
|
|
56
|
+
): void;
|
|
57
|
+
/**
|
|
58
|
+
* Mark the end of the current source file
|
|
59
|
+
*/
|
|
60
|
+
endFile(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Adds a mapping for generated code without a corresponding source location.
|
|
63
|
+
*/
|
|
64
|
+
addSimpleMapping(generatedLine: number, generatedColumn: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Adds a mapping for generated code with a corresponding source location.
|
|
67
|
+
*/
|
|
68
|
+
addSourceMapping(
|
|
69
|
+
generatedLine: number,
|
|
70
|
+
generatedColumn: number,
|
|
71
|
+
sourceLine: number,
|
|
72
|
+
sourceColumn: number,
|
|
73
|
+
): void;
|
|
74
|
+
/**
|
|
75
|
+
* Adds a mapping for code with a corresponding source location + symbol name.
|
|
76
|
+
*/
|
|
77
|
+
addNamedSourceMapping(
|
|
78
|
+
generatedLine: number,
|
|
79
|
+
generatedColumn: number,
|
|
80
|
+
sourceLine: number,
|
|
81
|
+
sourceColumn: number,
|
|
82
|
+
name: string,
|
|
83
|
+
): void;
|
|
84
|
+
/**
|
|
85
|
+
* Return the source map as object.
|
|
86
|
+
*/
|
|
87
|
+
toMap(file?: string, options?: {excludeSource?: boolean}): BasicSourceMap;
|
|
88
|
+
/**
|
|
89
|
+
* Return the source map as string.
|
|
90
|
+
*
|
|
91
|
+
* This is ~2.5x faster than calling `JSON.stringify(generator.toMap())`
|
|
92
|
+
*/
|
|
93
|
+
toString(file?: string, options?: {excludeSource?: boolean}): string;
|
|
94
|
+
/**
|
|
95
|
+
* Determine whether we need to write the `x_facebook_sources` field.
|
|
96
|
+
* If the metadata is all `null`s, we can omit the field entirely.
|
|
97
|
+
*/
|
|
98
|
+
hasSourcesMetadata(): boolean;
|
|
99
|
+
}
|
|
100
|
+
export default Generator;
|
|
101
|
+
declare class IndexedSet {
|
|
102
|
+
map: Map<string, number>;
|
|
103
|
+
nextIndex: number;
|
|
104
|
+
constructor();
|
|
105
|
+
indexFor(x: string): number;
|
|
106
|
+
items(): Array<string>;
|
|
107
|
+
}
|
package/src/Generator.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _B64Builder = _interopRequireDefault(require("./B64Builder"));
|
|
8
|
+
function _interopRequireDefault(e) {
|
|
9
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
|
+
}
|
|
4
11
|
class Generator {
|
|
5
12
|
constructor() {
|
|
6
|
-
this.builder = new
|
|
13
|
+
this.builder = new _B64Builder.default();
|
|
7
14
|
this.last = {
|
|
8
15
|
generatedColumn: 0,
|
|
9
16
|
generatedLine: 1,
|
|
@@ -70,13 +77,13 @@ class Generator {
|
|
|
70
77
|
generatedColumn,
|
|
71
78
|
sourceLine,
|
|
72
79
|
sourceColumn,
|
|
73
|
-
name
|
|
80
|
+
name,
|
|
74
81
|
) {
|
|
75
82
|
this.addSourceMapping(
|
|
76
83
|
generatedLine,
|
|
77
84
|
generatedColumn,
|
|
78
85
|
sourceLine,
|
|
79
|
-
sourceColumn
|
|
86
|
+
sourceColumn,
|
|
80
87
|
);
|
|
81
88
|
const last = this.last;
|
|
82
89
|
const nameIndex = this.names.indexFor(name);
|
|
@@ -93,7 +100,7 @@ class Generator {
|
|
|
93
100
|
const sourcesMetadata = this.hasSourcesMetadata()
|
|
94
101
|
? {
|
|
95
102
|
x_facebook_sources: JSON.parse(
|
|
96
|
-
JSON.stringify(this.x_facebook_sources)
|
|
103
|
+
JSON.stringify(this.x_facebook_sources),
|
|
97
104
|
),
|
|
98
105
|
}
|
|
99
106
|
: {};
|
|
@@ -122,17 +129,13 @@ class Generator {
|
|
|
122
129
|
}
|
|
123
130
|
let sourcesMetadata;
|
|
124
131
|
if (this.hasSourcesMetadata()) {
|
|
125
|
-
sourcesMetadata = `"x_facebook_sources":${JSON.stringify(
|
|
126
|
-
this.x_facebook_sources
|
|
127
|
-
)},`;
|
|
132
|
+
sourcesMetadata = `"x_facebook_sources":${JSON.stringify(this.x_facebook_sources)},`;
|
|
128
133
|
} else {
|
|
129
134
|
sourcesMetadata = "";
|
|
130
135
|
}
|
|
131
136
|
let ignoreList;
|
|
132
137
|
if (this.x_google_ignoreList.length) {
|
|
133
|
-
ignoreList = `"x_google_ignoreList":${JSON.stringify(
|
|
134
|
-
this.x_google_ignoreList
|
|
135
|
-
)},`;
|
|
138
|
+
ignoreList = `"x_google_ignoreList":${JSON.stringify(this.x_google_ignoreList)},`;
|
|
136
139
|
} else {
|
|
137
140
|
ignoreList = "";
|
|
138
141
|
}
|
|
@@ -151,10 +154,11 @@ class Generator {
|
|
|
151
154
|
}
|
|
152
155
|
hasSourcesMetadata() {
|
|
153
156
|
return this.x_facebook_sources.some(
|
|
154
|
-
(metadata) => metadata != null && metadata.some((value) => value != null)
|
|
157
|
+
(metadata) => metadata != null && metadata.some((value) => value != null),
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
160
|
}
|
|
161
|
+
exports.default = Generator;
|
|
158
162
|
class IndexedSet {
|
|
159
163
|
constructor() {
|
|
160
164
|
this.map = new Map();
|
|
@@ -172,4 +176,3 @@ class IndexedSet {
|
|
|
172
176
|
return Array.from(this.map.keys());
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
|
-
module.exports = Generator;
|
package/src/Generator.js.flow
CHANGED
|
@@ -9,15 +9,13 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {
|
|
15
13
|
BasicSourceMap,
|
|
16
14
|
FBSourceFunctionMap,
|
|
17
15
|
FBSourceMetadata,
|
|
18
16
|
} from './source-map';
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
import B64Builder from './B64Builder';
|
|
21
19
|
|
|
22
20
|
type FileFlags = $ReadOnly<{
|
|
23
21
|
addToIgnoreList?: boolean,
|
|
@@ -34,7 +32,7 @@ type FileFlags = $ReadOnly<{
|
|
|
34
32
|
*
|
|
35
33
|
* Mappings have to be passed in the order appearance in the generated source.
|
|
36
34
|
*/
|
|
37
|
-
class Generator {
|
|
35
|
+
export default class Generator {
|
|
38
36
|
builder: B64Builder;
|
|
39
37
|
last: {
|
|
40
38
|
generatedColumn: number,
|
|
@@ -291,5 +289,3 @@ class IndexedSet {
|
|
|
291
289
|
return Array.from(this.map.keys());
|
|
292
290
|
}
|
|
293
291
|
}
|
|
294
|
-
|
|
295
|
-
module.exports = Generator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {MixedSourceMap} from './source-map';
|
|
12
|
+
|
|
13
|
+
declare function composeSourceMaps(
|
|
14
|
+
maps: ReadonlyArray<MixedSourceMap>,
|
|
15
|
+
): MixedSourceMap;
|
|
16
|
+
export default composeSourceMaps;
|
package/src/composeSourceMaps.js
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = composeSourceMaps;
|
|
7
|
+
var _Consumer = _interopRequireDefault(require("./Consumer"));
|
|
8
|
+
var _sourceMap = require("source-map");
|
|
9
|
+
function _interopRequireDefault(e) {
|
|
10
|
+
return e && e.__esModule ? e : { default: e };
|
|
11
|
+
}
|
|
12
|
+
_Consumer.default;
|
|
6
13
|
function composeSourceMaps(maps) {
|
|
7
|
-
const SourceMetadataMapConsumer =
|
|
8
|
-
|
|
14
|
+
const SourceMetadataMapConsumer =
|
|
15
|
+
require("metro-symbolicate/private/SourceMetadataMapConsumer").default;
|
|
16
|
+
const GoogleIgnoreListConsumer =
|
|
17
|
+
require("metro-symbolicate/private/GoogleIgnoreListConsumer").default;
|
|
9
18
|
if (maps.length < 1) {
|
|
10
19
|
throw new Error("composeSourceMaps: Expected at least one map");
|
|
11
20
|
}
|
|
12
21
|
const firstMap = maps[0];
|
|
13
22
|
const consumers = maps
|
|
14
23
|
.map(function (map) {
|
|
15
|
-
return new
|
|
24
|
+
return new _Consumer.default(map);
|
|
16
25
|
})
|
|
17
26
|
.reverse();
|
|
18
|
-
const generator = new SourceMapGenerator({
|
|
27
|
+
const generator = new _sourceMap.SourceMapGenerator({
|
|
19
28
|
file: consumers[0].file,
|
|
20
29
|
});
|
|
21
30
|
consumers[0].eachMapping((mapping) => {
|
|
22
31
|
const original = findOriginalPosition(
|
|
23
32
|
consumers,
|
|
24
33
|
mapping.generatedLine,
|
|
25
|
-
mapping.generatedColumn
|
|
34
|
+
mapping.generatedColumn,
|
|
26
35
|
);
|
|
27
36
|
generator.addMapping({
|
|
28
37
|
generated: {
|
|
@@ -42,14 +51,14 @@ function composeSourceMaps(maps) {
|
|
|
42
51
|
});
|
|
43
52
|
const composedMap = generator.toJSON();
|
|
44
53
|
composedMap.sourcesContent = composedMap.sources.map((source) =>
|
|
45
|
-
consumers[consumers.length - 1].sourceContentFor(source, true)
|
|
54
|
+
consumers[consumers.length - 1].sourceContentFor(source, true),
|
|
46
55
|
);
|
|
47
56
|
if (composedMap.sourcesContent.every((content) => content == null)) {
|
|
48
57
|
delete composedMap.sourcesContent;
|
|
49
58
|
}
|
|
50
59
|
const metadataConsumer = new SourceMetadataMapConsumer(firstMap);
|
|
51
60
|
composedMap.x_facebook_sources = metadataConsumer.toArray(
|
|
52
|
-
composedMap.sources
|
|
61
|
+
composedMap.sources,
|
|
53
62
|
);
|
|
54
63
|
const function_offsets = maps[maps.length - 1].x_hermes_function_offsets;
|
|
55
64
|
if (function_offsets) {
|
|
@@ -97,4 +106,3 @@ function findOriginalPosition(consumers, generatedLine, generatedColumn) {
|
|
|
97
106
|
}
|
|
98
107
|
return original;
|
|
99
108
|
}
|
|
100
|
-
module.exports = composeSourceMaps;
|