metro-source-map 0.74.1 → 0.75.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro-source-map",
3
- "version": "0.74.1",
3
+ "version": "0.75.1",
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.74.1",
18
+ "metro-symbolicate": "0.75.1",
19
19
  "nullthrows": "^1.1.1",
20
- "ob1": "0.74.1",
20
+ "ob1": "0.75.1",
21
21
  "source-map": "^0.5.6",
22
22
  "vlq": "^1.0.0"
23
23
  },
@@ -26,5 +26,8 @@
26
26
  "@babel/core": "^7.20.0",
27
27
  "@babel/parser": "^7.20.0",
28
28
  "uglify-es": "^3.1.9"
29
+ },
30
+ "engines": {
31
+ "node": ">=14.17.0"
29
32
  }
30
33
  }
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
- generated: {
105
- line: map.generatedLine,
106
- column: map.generatedColumn,
107
- },
108
- original: {
109
- line: map.originalLine,
110
- column: map.originalColumn,
111
- },
112
- source: map.source,
113
- name: map.name,
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,
@@ -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(map => {
209
- rawMappings.push({
210
- generated: {
211
- line: map.generatedLine,
212
- column: map.generatedColumn,
213
- },
214
- original: {
215
- line: map.originalLine,
216
- column: map.originalColumn,
217
- },
218
- source: map.source,
219
- name: map.name,
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
- const sourceMap: SourceMapping = (mapping: any);
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
- const sourceMap: SourceMappingWithName = (mapping: any);
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,