metro-source-map 0.75.0 → 0.76.0
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 +5 -5
- package/src/Consumer/MappingsConsumer.js +1 -5
- package/src/Generator.js +0 -3
- package/src/Generator.js.flow +0 -3
- package/src/generateFunctionMap.js +3 -23
- package/src/source-map.js +26 -12
- package/src/source-map.js.flow +42 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-source-map",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.76.0",
|
|
4
4
|
"description": "🚇 Source map generator for Metro.",
|
|
5
5
|
"main": "src/source-map.js",
|
|
6
6
|
"repository": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"@babel/traverse": "^7.20.0",
|
|
16
16
|
"@babel/types": "^7.20.0",
|
|
17
17
|
"invariant": "^2.2.4",
|
|
18
|
-
"metro-symbolicate": "0.
|
|
18
|
+
"metro-symbolicate": "0.76.0",
|
|
19
19
|
"nullthrows": "^1.1.1",
|
|
20
|
-
"ob1": "0.
|
|
20
|
+
"ob1": "0.76.0",
|
|
21
21
|
"source-map": "^0.5.6",
|
|
22
22
|
"vlq": "^1.0.0"
|
|
23
23
|
},
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/core": "^7.20.0",
|
|
27
27
|
"@babel/parser": "^7.20.0",
|
|
28
|
-
"
|
|
28
|
+
"terser": "^5.15.0"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
31
|
+
"node": ">=16"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -182,7 +182,6 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
182
182
|
return add0(idx);
|
|
183
183
|
}
|
|
184
184
|
sourceContentFor(source, nullOnMissing) {
|
|
185
|
-
var _sourcesContent$get;
|
|
186
185
|
const { sourcesContent } = this._sourceMap;
|
|
187
186
|
if (!sourcesContent) {
|
|
188
187
|
return null;
|
|
@@ -191,10 +190,7 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
191
190
|
if (idx == null) {
|
|
192
191
|
return null;
|
|
193
192
|
}
|
|
194
|
-
return
|
|
195
|
-
_sourcesContent$get !== void 0
|
|
196
|
-
? _sourcesContent$get
|
|
197
|
-
: null;
|
|
193
|
+
return sourcesContent[get0(idx)] ?? null;
|
|
198
194
|
}
|
|
199
195
|
}
|
|
200
196
|
module.exports = MappingsConsumer;
|
package/src/Generator.js
CHANGED
|
@@ -147,9 +147,6 @@ class Generator {
|
|
|
147
147
|
sources: this.sources.slice(),
|
|
148
148
|
// $FlowFixMe[exponential-spread]
|
|
149
149
|
...content,
|
|
150
|
-
/* $FlowFixMe(>=0.111.0 site=react_native_fb) This comment suppresses an
|
|
151
|
-
* error found when Flow v0.111 was deployed. To see the error, delete
|
|
152
|
-
* this comment and run Flow. */
|
|
153
150
|
...sourcesMetadata,
|
|
154
151
|
names: this.names.items(),
|
|
155
152
|
mappings: this.builder.toString(),
|
package/src/Generator.js.flow
CHANGED
|
@@ -181,9 +181,6 @@ class Generator {
|
|
|
181
181
|
sources: this.sources.slice(),
|
|
182
182
|
// $FlowFixMe[exponential-spread]
|
|
183
183
|
...content,
|
|
184
|
-
/* $FlowFixMe(>=0.111.0 site=react_native_fb) This comment suppresses an
|
|
185
|
-
* error found when Flow v0.111 was deployed. To see the error, delete
|
|
186
|
-
* this comment and run Flow. */
|
|
187
184
|
...sourcesMetadata,
|
|
188
185
|
names: this.names.items(),
|
|
189
186
|
mappings: this.builder.toString(),
|
|
@@ -171,14 +171,7 @@ function getNameForPath(path) {
|
|
|
171
171
|
// foo = function () {};
|
|
172
172
|
id = parent.left;
|
|
173
173
|
} else if ((0, _types.isJSXExpressionContainer)(parent)) {
|
|
174
|
-
|
|
175
|
-
const grandParentNode =
|
|
176
|
-
parentPath === null || parentPath === void 0
|
|
177
|
-
? void 0
|
|
178
|
-
: (_parentPath$parentPat = parentPath.parentPath) === null ||
|
|
179
|
-
_parentPath$parentPat === void 0
|
|
180
|
-
? void 0
|
|
181
|
-
: _parentPath$parentPat.node;
|
|
174
|
+
const grandParentNode = parentPath?.parentPath?.node;
|
|
182
175
|
if ((0, _types.isJSXElement)(grandParentNode)) {
|
|
183
176
|
// <foo>{function () {}}</foo>
|
|
184
177
|
const openingElement = grandParentNode.openingElement;
|
|
@@ -188,18 +181,8 @@ function getNameForPath(path) {
|
|
|
188
181
|
t.jsxIdentifier("children")
|
|
189
182
|
);
|
|
190
183
|
} else if ((0, _types.isJSXAttribute)(grandParentNode)) {
|
|
191
|
-
var _parentPath$parentPat2, _parentPath$parentPat3;
|
|
192
184
|
// <foo bar={function () {}} />
|
|
193
|
-
const openingElement =
|
|
194
|
-
parentPath === null || parentPath === void 0
|
|
195
|
-
? void 0
|
|
196
|
-
: (_parentPath$parentPat2 = parentPath.parentPath) === null ||
|
|
197
|
-
_parentPath$parentPat2 === void 0
|
|
198
|
-
? void 0
|
|
199
|
-
: (_parentPath$parentPat3 = _parentPath$parentPat2.parentPath) ===
|
|
200
|
-
null || _parentPath$parentPat3 === void 0
|
|
201
|
-
? void 0
|
|
202
|
-
: _parentPath$parentPat3.node;
|
|
185
|
+
const openingElement = parentPath?.parentPath?.parentPath?.node;
|
|
203
186
|
const prop = grandParentNode;
|
|
204
187
|
id = t.jsxMemberExpression(
|
|
205
188
|
// $FlowFixMe Flow error uncovered by typing Babel more strictly
|
|
@@ -322,10 +305,7 @@ function getNamePartsFromId(id) {
|
|
|
322
305
|
} else if ((0, _types.isNullLiteral)(id)) {
|
|
323
306
|
name = "null";
|
|
324
307
|
} else if ((0, _types.isRegExpLiteral)(id)) {
|
|
325
|
-
|
|
326
|
-
name = `_${id.pattern}_${
|
|
327
|
-
(_id$flags = id.flags) !== null && _id$flags !== void 0 ? _id$flags : ""
|
|
328
|
-
}`;
|
|
308
|
+
name = `_${id.pattern}_${id.flags ?? ""}`;
|
|
329
309
|
} else if ((0, _types.isTemplateLiteral)(id)) {
|
|
330
310
|
name = id.quasis.map((quasi) => quasi.value.raw).join("");
|
|
331
311
|
} else if ((0, _types.isLiteral)(id) && id.value != null) {
|
package/src/source-map.js
CHANGED
|
@@ -18,6 +18,7 @@ const Consumer = require("./Consumer");
|
|
|
18
18
|
const normalizeSourcePath = require("./Consumer/normalizeSourcePath");
|
|
19
19
|
const { generateFunctionMap } = require("./generateFunctionMap");
|
|
20
20
|
const Generator = require("./Generator");
|
|
21
|
+
// $FlowFixMe[untyped-import] - source-map
|
|
21
22
|
const SourceMap = require("source-map");
|
|
22
23
|
function fromRawMappingsImpl(isBlocking, onDone, modules, offsetLines) {
|
|
23
24
|
const modulesToProcess = modules.slice();
|
|
@@ -100,18 +101,29 @@ async function fromRawMappingsNonBlocking(modules, offsetLines = 0) {
|
|
|
100
101
|
function toBabelSegments(sourceMap) {
|
|
101
102
|
const rawMappings = [];
|
|
102
103
|
new SourceMap.SourceMapConsumer(sourceMap).eachMapping((map) => {
|
|
103
|
-
rawMappings.push(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
rawMappings.push(
|
|
105
|
+
map.originalLine == null || map.originalColumn == null
|
|
106
|
+
? {
|
|
107
|
+
generated: {
|
|
108
|
+
line: map.generatedLine,
|
|
109
|
+
column: map.generatedColumn,
|
|
110
|
+
},
|
|
111
|
+
source: map.source,
|
|
112
|
+
name: map.name,
|
|
113
|
+
}
|
|
114
|
+
: {
|
|
115
|
+
generated: {
|
|
116
|
+
line: map.generatedLine,
|
|
117
|
+
column: map.generatedColumn,
|
|
118
|
+
},
|
|
119
|
+
original: {
|
|
120
|
+
line: map.originalLine,
|
|
121
|
+
column: map.originalColumn,
|
|
122
|
+
},
|
|
123
|
+
source: map.source,
|
|
124
|
+
name: map.name,
|
|
125
|
+
}
|
|
126
|
+
);
|
|
115
127
|
});
|
|
116
128
|
return rawMappings;
|
|
117
129
|
}
|
|
@@ -141,9 +153,11 @@ function addMapping(generator, mapping, carryOver) {
|
|
|
141
153
|
if (n === 2) {
|
|
142
154
|
generator.addSimpleMapping(line, column);
|
|
143
155
|
} else if (n === 4) {
|
|
156
|
+
// $FlowIssue[invalid-tuple-arity] Arity is ensured by conidition on length
|
|
144
157
|
const sourceMap = mapping;
|
|
145
158
|
generator.addSourceMapping(line, column, sourceMap[2], sourceMap[3]);
|
|
146
159
|
} else if (n === 5) {
|
|
160
|
+
// $FlowIssue[invalid-tuple-arity] Arity is ensured by conidition on length
|
|
147
161
|
const sourceMap = mapping;
|
|
148
162
|
generator.addNamedSourceMapping(
|
|
149
163
|
line,
|
package/src/source-map.js.flow
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
@@ -21,6 +21,7 @@ const Consumer = require('./Consumer');
|
|
|
21
21
|
const normalizeSourcePath = require('./Consumer/normalizeSourcePath');
|
|
22
22
|
const {generateFunctionMap} = require('./generateFunctionMap');
|
|
23
23
|
const Generator = require('./Generator');
|
|
24
|
+
// $FlowFixMe[untyped-import] - source-map
|
|
24
25
|
const SourceMap = require('source-map');
|
|
25
26
|
|
|
26
27
|
export type {IConsumer};
|
|
@@ -85,6 +86,15 @@ export type IndexMap = {
|
|
|
85
86
|
|
|
86
87
|
export type MixedSourceMap = IndexMap | BasicSourceMap;
|
|
87
88
|
|
|
89
|
+
type SourceMapConsumerMapping = {
|
|
90
|
+
generatedLine: number,
|
|
91
|
+
generatedColumn: number,
|
|
92
|
+
originalLine: ?number,
|
|
93
|
+
originalColumn: ?number,
|
|
94
|
+
source: ?string,
|
|
95
|
+
name: ?string,
|
|
96
|
+
};
|
|
97
|
+
|
|
88
98
|
function fromRawMappingsImpl(
|
|
89
99
|
isBlocking: boolean,
|
|
90
100
|
onDone: Generator => void,
|
|
@@ -205,20 +215,33 @@ function toBabelSegments(
|
|
|
205
215
|
): Array<BabelSourceMapSegment> {
|
|
206
216
|
const rawMappings: Array<BabelSourceMapSegment> = [];
|
|
207
217
|
|
|
208
|
-
new SourceMap.SourceMapConsumer(sourceMap).eachMapping(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
new SourceMap.SourceMapConsumer(sourceMap).eachMapping(
|
|
219
|
+
(map: SourceMapConsumerMapping) => {
|
|
220
|
+
rawMappings.push(
|
|
221
|
+
map.originalLine == null || map.originalColumn == null
|
|
222
|
+
? {
|
|
223
|
+
generated: {
|
|
224
|
+
line: map.generatedLine,
|
|
225
|
+
column: map.generatedColumn,
|
|
226
|
+
},
|
|
227
|
+
source: map.source,
|
|
228
|
+
name: map.name,
|
|
229
|
+
}
|
|
230
|
+
: {
|
|
231
|
+
generated: {
|
|
232
|
+
line: map.generatedLine,
|
|
233
|
+
column: map.generatedColumn,
|
|
234
|
+
},
|
|
235
|
+
original: {
|
|
236
|
+
line: map.originalLine,
|
|
237
|
+
column: map.originalColumn,
|
|
238
|
+
},
|
|
239
|
+
source: map.source,
|
|
240
|
+
name: map.name,
|
|
241
|
+
},
|
|
242
|
+
);
|
|
243
|
+
},
|
|
244
|
+
);
|
|
222
245
|
|
|
223
246
|
return rawMappings;
|
|
224
247
|
}
|
|
@@ -274,11 +297,13 @@ function addMapping(
|
|
|
274
297
|
if (n === 2) {
|
|
275
298
|
generator.addSimpleMapping(line, column);
|
|
276
299
|
} else if (n === 4) {
|
|
277
|
-
|
|
300
|
+
// $FlowIssue[invalid-tuple-arity] Arity is ensured by conidition on length
|
|
301
|
+
const sourceMap: SourceMapping = mapping;
|
|
278
302
|
|
|
279
303
|
generator.addSourceMapping(line, column, sourceMap[2], sourceMap[3]);
|
|
280
304
|
} else if (n === 5) {
|
|
281
|
-
|
|
305
|
+
// $FlowIssue[invalid-tuple-arity] Arity is ensured by conidition on length
|
|
306
|
+
const sourceMap: SourceMappingWithName = mapping;
|
|
282
307
|
|
|
283
308
|
generator.addNamedSourceMapping(
|
|
284
309
|
line,
|