metro-source-map 0.83.3 → 0.83.5
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 +8 -8
- package/src/BundleBuilder.js.flow +2 -2
- package/src/Consumer/AbstractConsumer.js.flow +2 -2
- package/src/Consumer/DelegatingConsumer.js.flow +2 -2
- package/src/Consumer/MappingsConsumer.js.flow +4 -4
- package/src/Consumer/SectionsConsumer.js.flow +1 -1
- package/src/Consumer/constants.js.flow +1 -1
- package/src/Consumer/createConsumer.js.flow +1 -1
- package/src/Consumer/search.js.flow +1 -1
- package/src/Consumer/types.js.flow +3 -3
- package/src/Generator.js.flow +3 -3
- package/src/composeSourceMaps.js.flow +2 -2
- package/src/encode.js.flow +1 -1
- package/src/generateFunctionMap.js +27 -25
- package/src/generateFunctionMap.js.flow +4 -9
- package/src/source-map.js.flow +12 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-source-map",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.5",
|
|
4
4
|
"description": "🚇 Source map generator for Metro.",
|
|
5
5
|
"main": "src/source-map.js",
|
|
6
6
|
"exports": {
|
|
@@ -10,28 +10,28 @@
|
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git
|
|
13
|
+
"url": "git+https://github.com/facebook/metro.git",
|
|
14
|
+
"directory": "packages/metro-source-map"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
17
|
"prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src",
|
|
17
18
|
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@babel/traverse": "^7.
|
|
21
|
-
"@babel/
|
|
22
|
-
"@babel/types": "^7.25.2",
|
|
21
|
+
"@babel/traverse": "^7.29.0",
|
|
22
|
+
"@babel/types": "^7.29.0",
|
|
23
23
|
"flow-enums-runtime": "^0.0.6",
|
|
24
24
|
"invariant": "^2.2.4",
|
|
25
|
-
"metro-symbolicate": "0.83.
|
|
25
|
+
"metro-symbolicate": "0.83.5",
|
|
26
26
|
"nullthrows": "^1.1.1",
|
|
27
|
-
"ob1": "0.83.
|
|
27
|
+
"ob1": "0.83.5",
|
|
28
28
|
"source-map": "^0.5.6",
|
|
29
29
|
"vlq": "^1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@babel/core": "^7.25.2",
|
|
34
|
-
"@babel/parser": "^7.
|
|
34
|
+
"@babel/parser": "^7.29.0",
|
|
35
35
|
"terser": "^5.15.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
@@ -13,8 +13,8 @@ import type {IndexMap, IndexMapSection, MixedSourceMap} from './source-map';
|
|
|
13
13
|
|
|
14
14
|
const EMPTY_MAP = {
|
|
15
15
|
version: 3,
|
|
16
|
-
sources:
|
|
17
|
-
names:
|
|
16
|
+
sources: [] as Array<string>,
|
|
17
|
+
names: [] as Array<string>,
|
|
18
18
|
mappings: 'A',
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -39,8 +39,8 @@ export default class AbstractConsumer implements IConsumer {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
eachMapping(
|
|
42
|
-
callback: (mapping: Mapping) =>
|
|
43
|
-
context?:
|
|
42
|
+
callback: (mapping: Mapping) => unknown,
|
|
43
|
+
context?: unknown = null,
|
|
44
44
|
order?: IterationOrder = GENERATED_ORDER,
|
|
45
45
|
): void {
|
|
46
46
|
invariant(
|
|
@@ -57,8 +57,8 @@ export default class DelegatingConsumer implements IConsumer {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
eachMapping(
|
|
60
|
-
callback: (mapping: Mapping) =>
|
|
61
|
-
context?:
|
|
60
|
+
callback: (mapping: Mapping) => unknown,
|
|
61
|
+
context?: unknown,
|
|
62
62
|
order?: IterationOrder,
|
|
63
63
|
): void {
|
|
64
64
|
return this._rootConsumer.eachMapping(callback, context, order);
|
|
@@ -41,8 +41,8 @@ export default class MappingsConsumer
|
|
|
41
41
|
implements IConsumer
|
|
42
42
|
{
|
|
43
43
|
_sourceMap: BasicSourceMap;
|
|
44
|
-
_decodedMappings:
|
|
45
|
-
_normalizedSources:
|
|
44
|
+
_decodedMappings: ?ReadonlyArray<Mapping>;
|
|
45
|
+
_normalizedSources: ?ReadonlyArray<string>;
|
|
46
46
|
|
|
47
47
|
constructor(sourceMap: BasicSourceMap) {
|
|
48
48
|
super(sourceMap);
|
|
@@ -175,7 +175,7 @@ export default class MappingsConsumer
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
_normalizeAndCacheSources():
|
|
178
|
+
_normalizeAndCacheSources(): ReadonlyArray<string> {
|
|
179
179
|
if (!this._normalizedSources) {
|
|
180
180
|
this._normalizedSources = this._sourceMap.sources.map(source =>
|
|
181
181
|
normalizeSourcePath(source, this._sourceMap),
|
|
@@ -184,7 +184,7 @@ export default class MappingsConsumer
|
|
|
184
184
|
return this._normalizedSources;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
_decodeAndCacheMappings():
|
|
187
|
+
_decodeAndCacheMappings(): ReadonlyArray<Mapping> {
|
|
188
188
|
if (!this._decodedMappings) {
|
|
189
189
|
this._decodedMappings = [...this._decodeMappings()];
|
|
190
190
|
}
|
|
@@ -33,7 +33,7 @@ export default class SectionsConsumer
|
|
|
33
33
|
extends AbstractConsumer
|
|
34
34
|
implements IConsumer
|
|
35
35
|
{
|
|
36
|
-
_consumers:
|
|
36
|
+
_consumers: ReadonlyArray<[GeneratedOffset, IConsumer]>;
|
|
37
37
|
|
|
38
38
|
constructor(sourceMap: IndexMap) {
|
|
39
39
|
super(sourceMap);
|
|
@@ -24,7 +24,7 @@ export opaque type LookupBias = 'GREATEST_LOWER_BOUND' | 'LEAST_UPPER_BOUND';
|
|
|
24
24
|
const GREATEST_LOWER_BOUND: LookupBias = 'GREATEST_LOWER_BOUND';
|
|
25
25
|
const LEAST_UPPER_BOUND: LookupBias = 'LEAST_UPPER_BOUND';
|
|
26
26
|
|
|
27
|
-
const EMPTY_POSITION:
|
|
27
|
+
const EMPTY_POSITION: Readonly<{
|
|
28
28
|
source: null,
|
|
29
29
|
name: null,
|
|
30
30
|
line: null,
|
|
@@ -18,7 +18,7 @@ import invariant from 'invariant';
|
|
|
18
18
|
|
|
19
19
|
export default function createConsumer(sourceMap: MixedSourceMap): IConsumer {
|
|
20
20
|
invariant(
|
|
21
|
-
(sourceMap.version
|
|
21
|
+
(sourceMap.version as unknown) === '3' || sourceMap.version === 3,
|
|
22
22
|
`Unrecognized source map format version: ${sourceMap.version}`,
|
|
23
23
|
);
|
|
24
24
|
|
|
@@ -33,7 +33,7 @@ export type GeneratedPositionLookup = {
|
|
|
33
33
|
...
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
export type Mapping =
|
|
36
|
+
export type Mapping = Readonly<{
|
|
37
37
|
source: ?string,
|
|
38
38
|
generatedLine: Number1,
|
|
39
39
|
generatedColumn: Number0,
|
|
@@ -51,8 +51,8 @@ export interface IConsumer {
|
|
|
51
51
|
generatedMappings(): Iterable<Mapping>;
|
|
52
52
|
|
|
53
53
|
eachMapping(
|
|
54
|
-
callback: (mapping: Mapping) =>
|
|
55
|
-
context?:
|
|
54
|
+
callback: (mapping: Mapping) => unknown,
|
|
55
|
+
context?: unknown,
|
|
56
56
|
order?: IterationOrder,
|
|
57
57
|
): void;
|
|
58
58
|
|
package/src/Generator.js.flow
CHANGED
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
|
|
18
18
|
import B64Builder from './B64Builder';
|
|
19
19
|
|
|
20
|
-
type FileFlags =
|
|
20
|
+
type FileFlags = Readonly<{
|
|
21
21
|
addToIgnoreList?: boolean,
|
|
22
22
|
}>;
|
|
23
23
|
|
|
@@ -199,7 +199,7 @@ export default class Generator {
|
|
|
199
199
|
}
|
|
200
200
|
: {};
|
|
201
201
|
|
|
202
|
-
return
|
|
202
|
+
return {
|
|
203
203
|
version: 3,
|
|
204
204
|
file,
|
|
205
205
|
sources: this.sources.slice(),
|
|
@@ -208,7 +208,7 @@ export default class Generator {
|
|
|
208
208
|
...ignoreList,
|
|
209
209
|
names: this.names.items(),
|
|
210
210
|
mappings: this.builder.toString(),
|
|
211
|
-
}
|
|
211
|
+
} as BasicSourceMap;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
@@ -21,7 +21,7 @@ Consumer;
|
|
|
21
21
|
|
|
22
22
|
// Originally based on https://github.com/jakobwesthoff/source-map-merger
|
|
23
23
|
export default function composeSourceMaps(
|
|
24
|
-
maps:
|
|
24
|
+
maps: ReadonlyArray<MixedSourceMap>,
|
|
25
25
|
): MixedSourceMap {
|
|
26
26
|
// NOTE: require() here to break dependency cycle
|
|
27
27
|
const SourceMetadataMapConsumer =
|
|
@@ -93,7 +93,7 @@ export default function composeSourceMaps(
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function findOriginalPosition(
|
|
96
|
-
consumers:
|
|
96
|
+
consumers: ReadonlyArray<IConsumer>,
|
|
97
97
|
generatedLine: Number1,
|
|
98
98
|
generatedColumn: Number0,
|
|
99
99
|
): {
|
package/src/encode.js.flow
CHANGED
|
@@ -7,36 +7,38 @@ exports.functionMapBabelPlugin = functionMapBabelPlugin;
|
|
|
7
7
|
exports.generateFunctionMap = generateFunctionMap;
|
|
8
8
|
exports.generateFunctionMappingsArray = generateFunctionMappingsArray;
|
|
9
9
|
var _B64Builder = _interopRequireDefault(require("./B64Builder"));
|
|
10
|
-
var
|
|
11
|
-
require("@babel/traverse--for-generate-function-map"),
|
|
12
|
-
);
|
|
10
|
+
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
13
11
|
var _types = _interopRequireWildcard(require("@babel/types"));
|
|
14
12
|
var t = _types;
|
|
15
13
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
16
14
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
17
15
|
var _path = _interopRequireDefault(require("path"));
|
|
18
|
-
function
|
|
19
|
-
if ("function"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var n = { __proto__: null },
|
|
33
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
34
|
-
for (var u in e)
|
|
35
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
36
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
37
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
16
|
+
function _interopRequireWildcard(e, t) {
|
|
17
|
+
if ("function" == typeof WeakMap)
|
|
18
|
+
var r = new WeakMap(),
|
|
19
|
+
n = new WeakMap();
|
|
20
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
21
|
+
if (!t && e && e.__esModule) return e;
|
|
22
|
+
var o,
|
|
23
|
+
i,
|
|
24
|
+
f = { __proto__: null, default: e };
|
|
25
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
26
|
+
return f;
|
|
27
|
+
if ((o = t ? n : r)) {
|
|
28
|
+
if (o.has(e)) return o.get(e);
|
|
29
|
+
o.set(e, f);
|
|
38
30
|
}
|
|
39
|
-
|
|
31
|
+
for (const t in e)
|
|
32
|
+
"default" !== t &&
|
|
33
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
34
|
+
((i =
|
|
35
|
+
(o = Object.defineProperty) &&
|
|
36
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
37
|
+
(i.get || i.set)
|
|
38
|
+
? o(f, t, i)
|
|
39
|
+
: (f[t] = e[t]));
|
|
40
|
+
return f;
|
|
41
|
+
})(e, t);
|
|
40
42
|
}
|
|
41
43
|
function _interopRequireDefault(e) {
|
|
42
44
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -147,7 +149,7 @@ function getFunctionMapVisitor(context, pushMapping) {
|
|
|
147
149
|
}
|
|
148
150
|
function forEachMapping(ast, context, pushMapping) {
|
|
149
151
|
const visitor = getFunctionMapVisitor(context, pushMapping);
|
|
150
|
-
(0,
|
|
152
|
+
(0, _traverse.default)(ast, {
|
|
151
153
|
noScope: true,
|
|
152
154
|
Function: visitor,
|
|
153
155
|
Program: visitor,
|
|
@@ -16,8 +16,7 @@ import type {Node as BabelNode} from '@babel/types';
|
|
|
16
16
|
import type {MetroBabelFileMetadata} from 'metro-babel-transformer';
|
|
17
17
|
|
|
18
18
|
import B64Builder from './B64Builder';
|
|
19
|
-
|
|
20
|
-
import traverseForGenerateFunctionMap from '@babel/traverse--for-generate-function-map';
|
|
19
|
+
import traverse from '@babel/traverse';
|
|
21
20
|
import * as t from '@babel/types';
|
|
22
21
|
import {
|
|
23
22
|
isAssignmentExpression,
|
|
@@ -98,7 +97,7 @@ function generateFunctionMap(
|
|
|
98
97
|
function generateFunctionMappingsArray(
|
|
99
98
|
ast: BabelNode,
|
|
100
99
|
context?: Context,
|
|
101
|
-
):
|
|
100
|
+
): ReadonlyArray<RangeMapping> {
|
|
102
101
|
const mappings = [];
|
|
103
102
|
forEachMapping(ast, context, mapping => {
|
|
104
103
|
mappings.push(mapping);
|
|
@@ -218,11 +217,7 @@ function forEachMapping(
|
|
|
218
217
|
) {
|
|
219
218
|
const visitor = getFunctionMapVisitor(context, pushMapping);
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
// values missing the `hub` property needed by Babel transformation, so we
|
|
223
|
-
// use a separate copy of traverse to populate a separate cache to not pollute
|
|
224
|
-
// the main @babel/traverse cache. See: https://github.com/facebook/metro/pull/1340
|
|
225
|
-
traverseForGenerateFunctionMap(ast, {
|
|
220
|
+
traverse(ast, {
|
|
226
221
|
// Our visitor doesn't care about scope
|
|
227
222
|
noScope: true,
|
|
228
223
|
|
|
@@ -416,7 +411,7 @@ function getNameFromId(id: BabelNode): ?string {
|
|
|
416
411
|
return parts.join('.');
|
|
417
412
|
}
|
|
418
413
|
|
|
419
|
-
function getNamePartsFromId(id: BabelNode):
|
|
414
|
+
function getNamePartsFromId(id: BabelNode): ReadonlyArray<string> {
|
|
420
415
|
if (!id) {
|
|
421
416
|
return [];
|
|
422
417
|
}
|
package/src/source-map.js.flow
CHANGED
|
@@ -35,18 +35,18 @@ export type MetroSourceMapSegmentTuple =
|
|
|
35
35
|
| SourceMapping
|
|
36
36
|
| GeneratedCodeMapping;
|
|
37
37
|
|
|
38
|
-
export type HermesFunctionOffsets = {[number]:
|
|
38
|
+
export type HermesFunctionOffsets = {[number]: ReadonlyArray<number>, ...};
|
|
39
39
|
|
|
40
|
-
export type FBSourcesArray =
|
|
40
|
+
export type FBSourcesArray = ReadonlyArray<?FBSourceMetadata>;
|
|
41
41
|
export type FBSourceMetadata = [?FBSourceFunctionMap];
|
|
42
42
|
export type FBSourceFunctionMap = {
|
|
43
|
-
+names:
|
|
43
|
+
+names: ReadonlyArray<string>,
|
|
44
44
|
+mappings: string,
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
export type BabelSourceMapSegment =
|
|
48
|
-
generated:
|
|
49
|
-
original?:
|
|
47
|
+
export type BabelSourceMapSegment = Readonly<{
|
|
48
|
+
generated: Readonly<{column: number, line: number, ...}>,
|
|
49
|
+
original?: Readonly<{column: number, line: number, ...}>,
|
|
50
50
|
source?: ?string,
|
|
51
51
|
name?: ?string,
|
|
52
52
|
...
|
|
@@ -108,8 +108,8 @@ type SourceMapConsumerMapping = {
|
|
|
108
108
|
function fromRawMappingsImpl(
|
|
109
109
|
isBlocking: boolean,
|
|
110
110
|
onDone: Generator => void,
|
|
111
|
-
modules:
|
|
112
|
-
+map:
|
|
111
|
+
modules: ReadonlyArray<{
|
|
112
|
+
+map: ?ReadonlyArray<MetroSourceMapSegmentTuple>,
|
|
113
113
|
+functionMap: ?FBSourceFunctionMap,
|
|
114
114
|
+path: string,
|
|
115
115
|
+source: string,
|
|
@@ -179,8 +179,8 @@ function fromRawMappingsImpl(
|
|
|
179
179
|
* the resulting bundle, e.g. by some prefix code.
|
|
180
180
|
*/
|
|
181
181
|
function fromRawMappings(
|
|
182
|
-
modules:
|
|
183
|
-
+map:
|
|
182
|
+
modules: ReadonlyArray<{
|
|
183
|
+
+map: ?ReadonlyArray<MetroSourceMapSegmentTuple>,
|
|
184
184
|
+functionMap: ?FBSourceFunctionMap,
|
|
185
185
|
+path: string,
|
|
186
186
|
+source: string,
|
|
@@ -206,8 +206,8 @@ function fromRawMappings(
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
async function fromRawMappingsNonBlocking(
|
|
209
|
-
modules:
|
|
210
|
-
+map:
|
|
209
|
+
modules: ReadonlyArray<{
|
|
210
|
+
+map: ?ReadonlyArray<MetroSourceMapSegmentTuple>,
|
|
211
211
|
+functionMap: ?FBSourceFunctionMap,
|
|
212
212
|
+path: string,
|
|
213
213
|
+source: string,
|