metro-source-map 0.83.1 → 0.83.3
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 +3 -3
- 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 +51 -25
- package/src/generateFunctionMap.js.flow +23 -22
- package/src/source-map.d.ts +130 -36
- package/src/source-map.js +77 -25
- package/src/source-map.js.flow +39 -14
- /package/src/Consumer/{types.flow.js → types.js} +0 -0
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _AbstractConsumer = _interopRequireDefault(require("./AbstractConsumer"));
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
var _normalizeSourcePath = _interopRequireDefault(
|
|
10
|
+
require("./normalizeSourcePath"),
|
|
11
|
+
);
|
|
12
|
+
var _search = require("./search");
|
|
13
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
14
|
+
var _ob = require("ob1");
|
|
15
|
+
var _vlq = require("vlq");
|
|
16
|
+
function _interopRequireDefault(e) {
|
|
17
|
+
return e && e.__esModule ? e : { default: e };
|
|
18
|
+
}
|
|
19
|
+
class MappingsConsumer extends _AbstractConsumer.default {
|
|
17
20
|
constructor(sourceMap) {
|
|
18
21
|
super(sourceMap);
|
|
19
22
|
this._sourceMap = sourceMap;
|
|
@@ -24,19 +27,17 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
24
27
|
const { line, column } = generatedPosition;
|
|
25
28
|
if (line == null || column == null) {
|
|
26
29
|
return {
|
|
27
|
-
...EMPTY_POSITION,
|
|
30
|
+
..._constants.EMPTY_POSITION,
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
if (generatedPosition.bias != null) {
|
|
31
|
-
|
|
32
|
-
generatedPosition.bias === GREATEST_LOWER_BOUND,
|
|
33
|
-
`Unimplemented lookup bias: ${lookupBiasToString(
|
|
34
|
-
generatedPosition.bias
|
|
35
|
-
)}`
|
|
34
|
+
(0, _invariant.default)(
|
|
35
|
+
generatedPosition.bias === _constants.GREATEST_LOWER_BOUND,
|
|
36
|
+
`Unimplemented lookup bias: ${(0, _constants.lookupBiasToString)(generatedPosition.bias)}`,
|
|
36
37
|
);
|
|
37
38
|
}
|
|
38
39
|
const mappings = this._decodeAndCacheMappings();
|
|
39
|
-
const index = greatestLowerBound(
|
|
40
|
+
const index = (0, _search.greatestLowerBound)(
|
|
40
41
|
mappings,
|
|
41
42
|
{
|
|
42
43
|
line,
|
|
@@ -44,10 +45,14 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
44
45
|
},
|
|
45
46
|
(position, mapping) => {
|
|
46
47
|
if (position.line === mapping.generatedLine) {
|
|
47
|
-
return
|
|
48
|
+
return (0, _ob.get0)(
|
|
49
|
+
(0, _ob.sub)(position.column, mapping.generatedColumn),
|
|
50
|
+
);
|
|
48
51
|
}
|
|
49
|
-
return
|
|
50
|
-
|
|
52
|
+
return (0, _ob.get0)(
|
|
53
|
+
(0, _ob.sub)(position.line, mapping.generatedLine),
|
|
54
|
+
);
|
|
55
|
+
},
|
|
51
56
|
);
|
|
52
57
|
if (
|
|
53
58
|
index != null &&
|
|
@@ -62,16 +67,16 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
62
67
|
};
|
|
63
68
|
}
|
|
64
69
|
return {
|
|
65
|
-
...EMPTY_POSITION,
|
|
70
|
+
..._constants.EMPTY_POSITION,
|
|
66
71
|
};
|
|
67
72
|
}
|
|
68
73
|
*_decodeMappings() {
|
|
69
|
-
let generatedLine = FIRST_LINE;
|
|
70
|
-
let generatedColumn = FIRST_COLUMN;
|
|
71
|
-
let originalLine = FIRST_LINE;
|
|
72
|
-
let originalColumn = FIRST_COLUMN;
|
|
73
|
-
let nameIndex = add0(0);
|
|
74
|
-
let sourceIndex = add0(0);
|
|
74
|
+
let generatedLine = _constants.FIRST_LINE;
|
|
75
|
+
let generatedColumn = _constants.FIRST_COLUMN;
|
|
76
|
+
let originalLine = _constants.FIRST_LINE;
|
|
77
|
+
let originalColumn = _constants.FIRST_COLUMN;
|
|
78
|
+
let nameIndex = (0, _ob.add0)(0);
|
|
79
|
+
let sourceIndex = (0, _ob.add0)(0);
|
|
75
80
|
const normalizedSources = this._normalizeAndCacheSources();
|
|
76
81
|
const { mappings: mappingsRaw, names } = this._sourceMap;
|
|
77
82
|
let next;
|
|
@@ -79,8 +84,8 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
79
84
|
for (let i = 0; i < mappingsRaw.length; i = next) {
|
|
80
85
|
switch (mappingsRaw[i]) {
|
|
81
86
|
case ";":
|
|
82
|
-
generatedLine = inc(generatedLine);
|
|
83
|
-
generatedColumn = FIRST_COLUMN;
|
|
87
|
+
generatedLine = (0, _ob.inc)(generatedLine);
|
|
88
|
+
generatedColumn = _constants.FIRST_COLUMN;
|
|
84
89
|
case ",":
|
|
85
90
|
next = i + 1;
|
|
86
91
|
continue;
|
|
@@ -97,10 +102,13 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
97
102
|
if (vlqCache.has(mappingRaw)) {
|
|
98
103
|
decodedVlqValues = vlqCache.get(mappingRaw);
|
|
99
104
|
} else {
|
|
100
|
-
decodedVlqValues =
|
|
105
|
+
decodedVlqValues = (0, _vlq.decode)(mappingRaw);
|
|
101
106
|
vlqCache.set(mappingRaw, decodedVlqValues);
|
|
102
107
|
}
|
|
103
|
-
|
|
108
|
+
(0, _invariant.default)(
|
|
109
|
+
Array.isArray(decodedVlqValues),
|
|
110
|
+
"Decoding VLQ tuple failed",
|
|
111
|
+
);
|
|
104
112
|
const [
|
|
105
113
|
generatedColumnDelta,
|
|
106
114
|
sourceIndexDelta,
|
|
@@ -108,9 +116,12 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
108
116
|
originalColumnDelta,
|
|
109
117
|
nameIndexDelta,
|
|
110
118
|
] = decodedVlqValues;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
(0, _vlq.decode)(mappingRaw);
|
|
120
|
+
(0, _invariant.default)(
|
|
121
|
+
generatedColumnDelta != null,
|
|
122
|
+
"Invalid generated column delta",
|
|
123
|
+
);
|
|
124
|
+
generatedColumn = (0, _ob.add)(generatedColumn, generatedColumnDelta);
|
|
114
125
|
const mapping = {
|
|
115
126
|
generatedLine,
|
|
116
127
|
generatedColumn,
|
|
@@ -120,17 +131,23 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
120
131
|
originalColumn: null,
|
|
121
132
|
};
|
|
122
133
|
if (sourceIndexDelta != null) {
|
|
123
|
-
sourceIndex = add(sourceIndex, sourceIndexDelta);
|
|
124
|
-
mapping.source = normalizedSources[get0(sourceIndex)];
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
sourceIndex = (0, _ob.add)(sourceIndex, sourceIndexDelta);
|
|
135
|
+
mapping.source = normalizedSources[(0, _ob.get0)(sourceIndex)];
|
|
136
|
+
(0, _invariant.default)(
|
|
137
|
+
originalLineDelta != null,
|
|
138
|
+
"Invalid original line delta",
|
|
139
|
+
);
|
|
140
|
+
(0, _invariant.default)(
|
|
141
|
+
originalColumnDelta != null,
|
|
142
|
+
"Invalid original column delta",
|
|
143
|
+
);
|
|
144
|
+
originalLine = (0, _ob.add)(originalLine, originalLineDelta);
|
|
145
|
+
originalColumn = (0, _ob.add)(originalColumn, originalColumnDelta);
|
|
129
146
|
mapping.originalLine = originalLine;
|
|
130
147
|
mapping.originalColumn = originalColumn;
|
|
131
148
|
if (nameIndexDelta != null) {
|
|
132
|
-
nameIndex = add(nameIndex, nameIndexDelta);
|
|
133
|
-
mapping.name = names[get0(nameIndex)];
|
|
149
|
+
nameIndex = (0, _ob.add)(nameIndex, nameIndexDelta);
|
|
150
|
+
mapping.name = names[(0, _ob.get0)(nameIndex)];
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
153
|
yield mapping;
|
|
@@ -139,7 +156,7 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
139
156
|
_normalizeAndCacheSources() {
|
|
140
157
|
if (!this._normalizedSources) {
|
|
141
158
|
this._normalizedSources = this._sourceMap.sources.map((source) =>
|
|
142
|
-
|
|
159
|
+
(0, _normalizeSourcePath.default)(source, this._sourceMap),
|
|
143
160
|
);
|
|
144
161
|
}
|
|
145
162
|
return this._normalizedSources;
|
|
@@ -155,12 +172,12 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
155
172
|
}
|
|
156
173
|
_indexOfSource(source) {
|
|
157
174
|
const idx = this._normalizeAndCacheSources().indexOf(
|
|
158
|
-
|
|
175
|
+
(0, _normalizeSourcePath.default)(source, this._sourceMap),
|
|
159
176
|
);
|
|
160
177
|
if (idx === -1) {
|
|
161
178
|
return null;
|
|
162
179
|
}
|
|
163
|
-
return add0(idx);
|
|
180
|
+
return (0, _ob.add0)(idx);
|
|
164
181
|
}
|
|
165
182
|
sourceContentFor(source, nullOnMissing) {
|
|
166
183
|
const { sourcesContent } = this._sourceMap;
|
|
@@ -171,7 +188,7 @@ class MappingsConsumer extends AbstractConsumer {
|
|
|
171
188
|
if (idx == null) {
|
|
172
189
|
return null;
|
|
173
190
|
}
|
|
174
|
-
return sourcesContent[get0(idx)] ?? null;
|
|
191
|
+
return sourcesContent[(0, _ob.get0)(idx)] ?? null;
|
|
175
192
|
}
|
|
176
193
|
}
|
|
177
|
-
|
|
194
|
+
exports.default = MappingsConsumer;
|
|
@@ -9,36 +9,37 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {BasicSourceMap} from '../source-map';
|
|
15
13
|
import type {
|
|
16
14
|
GeneratedPositionLookup,
|
|
17
15
|
IConsumer,
|
|
18
16
|
Mapping,
|
|
19
17
|
SourcePosition,
|
|
20
|
-
} from './types
|
|
18
|
+
} from './types';
|
|
21
19
|
import type {Number0} from 'ob1';
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
import AbstractConsumer from './AbstractConsumer';
|
|
22
|
+
import {
|
|
25
23
|
EMPTY_POSITION,
|
|
26
24
|
FIRST_COLUMN,
|
|
27
25
|
FIRST_LINE,
|
|
28
26
|
GREATEST_LOWER_BOUND,
|
|
29
27
|
lookupBiasToString,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
} from './constants';
|
|
29
|
+
import normalizeSourcePath from './normalizeSourcePath';
|
|
30
|
+
import {greatestLowerBound} from './search';
|
|
31
|
+
import invariant from 'invariant';
|
|
32
|
+
import {add, add0, get0, inc, sub} from 'ob1';
|
|
33
|
+
import {decode as decodeVlq} from 'vlq';
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
36
|
* A source map consumer that supports "basic" source maps (that have a
|
|
39
37
|
* `mappings` field and no sections).
|
|
40
38
|
*/
|
|
41
|
-
class MappingsConsumer
|
|
39
|
+
export default class MappingsConsumer
|
|
40
|
+
extends AbstractConsumer
|
|
41
|
+
implements IConsumer
|
|
42
|
+
{
|
|
42
43
|
_sourceMap: BasicSourceMap;
|
|
43
44
|
_decodedMappings: ?$ReadOnlyArray<Mapping>;
|
|
44
45
|
_normalizedSources: ?$ReadOnlyArray<string>;
|
|
@@ -61,7 +62,7 @@ class MappingsConsumer extends AbstractConsumer implements IConsumer {
|
|
|
61
62
|
invariant(
|
|
62
63
|
generatedPosition.bias === GREATEST_LOWER_BOUND,
|
|
63
64
|
`Unimplemented lookup bias: ${lookupBiasToString(
|
|
64
|
-
// $FlowFixMe[incompatible-
|
|
65
|
+
// $FlowFixMe[incompatible-type]
|
|
65
66
|
generatedPosition.bias,
|
|
66
67
|
)}`,
|
|
67
68
|
);
|
|
@@ -216,5 +217,3 @@ class MappingsConsumer extends AbstractConsumer implements IConsumer {
|
|
|
216
217
|
return sourcesContent[get0(idx)] ?? null;
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
|
-
|
|
220
|
-
module.exports = MappingsConsumer;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 {IndexMap} from '../source-map';
|
|
12
|
+
import type {
|
|
13
|
+
GeneratedOffset,
|
|
14
|
+
GeneratedPositionLookup,
|
|
15
|
+
IConsumer,
|
|
16
|
+
Mapping,
|
|
17
|
+
SourcePosition,
|
|
18
|
+
} from './types';
|
|
19
|
+
|
|
20
|
+
import AbstractConsumer from './AbstractConsumer';
|
|
21
|
+
/**
|
|
22
|
+
* A source map consumer that supports "indexed" source maps (that have a
|
|
23
|
+
* `sections` field and no top-level mappings).
|
|
24
|
+
*/
|
|
25
|
+
declare class SectionsConsumer extends AbstractConsumer implements IConsumer {
|
|
26
|
+
_consumers: ReadonlyArray<[GeneratedOffset, IConsumer]>;
|
|
27
|
+
constructor(sourceMap: IndexMap);
|
|
28
|
+
originalPositionFor(
|
|
29
|
+
generatedPosition: GeneratedPositionLookup,
|
|
30
|
+
): SourcePosition;
|
|
31
|
+
generatedMappings(): Iterable<Mapping>;
|
|
32
|
+
_consumerForPosition(
|
|
33
|
+
generatedPosition: GeneratedPositionLookup,
|
|
34
|
+
): null | undefined | [GeneratedOffset, IConsumer];
|
|
35
|
+
sourceContentFor(
|
|
36
|
+
source: string,
|
|
37
|
+
nullOnMissing: true,
|
|
38
|
+
): null | undefined | string;
|
|
39
|
+
}
|
|
40
|
+
export default SectionsConsumer;
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _AbstractConsumer = _interopRequireDefault(require("./AbstractConsumer"));
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
var _createConsumer = _interopRequireDefault(require("./createConsumer"));
|
|
10
|
+
var _positionMath = require("./positionMath");
|
|
11
|
+
var _search = require("./search");
|
|
12
|
+
var _ob = require("ob1");
|
|
13
|
+
function _interopRequireDefault(e) {
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
15
|
+
}
|
|
16
|
+
class SectionsConsumer extends _AbstractConsumer.default {
|
|
10
17
|
constructor(sourceMap) {
|
|
11
18
|
super(sourceMap);
|
|
12
19
|
this._consumers = sourceMap.sections.map((section, index) => {
|
|
13
20
|
const generatedOffset = {
|
|
14
|
-
lines: add0(section.offset.line),
|
|
15
|
-
columns: add0(section.offset.column),
|
|
21
|
+
lines: (0, _ob.add0)(section.offset.line),
|
|
22
|
+
columns: (0, _ob.add0)(section.offset.column),
|
|
16
23
|
};
|
|
17
|
-
const consumer =
|
|
24
|
+
const consumer = (0, _createConsumer.default)(section.map);
|
|
18
25
|
return [generatedOffset, consumer];
|
|
19
26
|
});
|
|
20
27
|
}
|
|
@@ -23,11 +30,14 @@ class SectionsConsumer extends AbstractConsumer {
|
|
|
23
30
|
this._consumerForPosition(generatedPosition) || [];
|
|
24
31
|
if (!consumer) {
|
|
25
32
|
return {
|
|
26
|
-
...EMPTY_POSITION,
|
|
33
|
+
..._constants.EMPTY_POSITION,
|
|
27
34
|
};
|
|
28
35
|
}
|
|
29
36
|
return consumer.originalPositionFor(
|
|
30
|
-
|
|
37
|
+
(0, _positionMath.subtractOffsetFromPosition)(
|
|
38
|
+
generatedPosition,
|
|
39
|
+
generatedOffset,
|
|
40
|
+
),
|
|
31
41
|
);
|
|
32
42
|
}
|
|
33
43
|
*generatedMappings() {
|
|
@@ -36,11 +46,12 @@ class SectionsConsumer extends AbstractConsumer {
|
|
|
36
46
|
for (const mapping of consumer.generatedMappings()) {
|
|
37
47
|
if (
|
|
38
48
|
first &&
|
|
39
|
-
(get1(mapping.generatedLine) > 1 ||
|
|
49
|
+
((0, _ob.get1)(mapping.generatedLine) > 1 ||
|
|
50
|
+
(0, _ob.get0)(mapping.generatedColumn) > 0)
|
|
40
51
|
) {
|
|
41
52
|
yield {
|
|
42
|
-
generatedLine: FIRST_LINE,
|
|
43
|
-
generatedColumn: FIRST_COLUMN,
|
|
53
|
+
generatedLine: _constants.FIRST_LINE,
|
|
54
|
+
generatedColumn: _constants.FIRST_COLUMN,
|
|
44
55
|
source: null,
|
|
45
56
|
name: null,
|
|
46
57
|
originalLine: null,
|
|
@@ -50,10 +61,13 @@ class SectionsConsumer extends AbstractConsumer {
|
|
|
50
61
|
first = false;
|
|
51
62
|
yield {
|
|
52
63
|
...mapping,
|
|
53
|
-
generatedLine:
|
|
54
|
-
|
|
64
|
+
generatedLine: (0, _ob.add)(
|
|
65
|
+
mapping.generatedLine,
|
|
66
|
+
generatedOffset.lines,
|
|
67
|
+
),
|
|
68
|
+
generatedColumn: (0, _ob.add)(
|
|
55
69
|
mapping.generatedColumn,
|
|
56
|
-
generatedOffset.columns
|
|
70
|
+
generatedOffset.columns,
|
|
57
71
|
),
|
|
58
72
|
};
|
|
59
73
|
}
|
|
@@ -64,17 +78,17 @@ class SectionsConsumer extends AbstractConsumer {
|
|
|
64
78
|
if (line == null || column == null) {
|
|
65
79
|
return null;
|
|
66
80
|
}
|
|
67
|
-
const index = greatestLowerBound(
|
|
81
|
+
const index = (0, _search.greatestLowerBound)(
|
|
68
82
|
this._consumers,
|
|
69
83
|
generatedPosition,
|
|
70
84
|
(position, [offset]) => {
|
|
71
|
-
const line0 = sub1(line);
|
|
85
|
+
const line0 = (0, _ob.sub1)(line);
|
|
72
86
|
const column0 = column;
|
|
73
87
|
if (line0 === offset.lines) {
|
|
74
|
-
return get0(sub(column0, offset.columns));
|
|
88
|
+
return (0, _ob.get0)((0, _ob.sub)(column0, offset.columns));
|
|
75
89
|
}
|
|
76
|
-
return get0(sub(line0, offset.lines));
|
|
77
|
-
}
|
|
90
|
+
return (0, _ob.get0)((0, _ob.sub)(line0, offset.lines));
|
|
91
|
+
},
|
|
78
92
|
);
|
|
79
93
|
return index != null ? this._consumers[index] : null;
|
|
80
94
|
}
|
|
@@ -88,4 +102,4 @@ class SectionsConsumer extends AbstractConsumer {
|
|
|
88
102
|
return null;
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
|
-
|
|
105
|
+
exports.default = SectionsConsumer;
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {IndexMap} from '../source-map';
|
|
15
13
|
import type {
|
|
16
14
|
GeneratedOffset,
|
|
@@ -18,20 +16,23 @@ import type {
|
|
|
18
16
|
IConsumer,
|
|
19
17
|
Mapping,
|
|
20
18
|
SourcePosition,
|
|
21
|
-
} from './types
|
|
19
|
+
} from './types';
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
import AbstractConsumer from './AbstractConsumer';
|
|
22
|
+
import {EMPTY_POSITION, FIRST_COLUMN, FIRST_LINE} from './constants';
|
|
23
|
+
import createConsumer from './createConsumer';
|
|
24
|
+
import {subtractOffsetFromPosition} from './positionMath';
|
|
25
|
+
import {greatestLowerBound} from './search';
|
|
26
|
+
import {add, add0, get0, get1, sub, sub1} from 'ob1';
|
|
29
27
|
|
|
30
28
|
/**
|
|
31
29
|
* A source map consumer that supports "indexed" source maps (that have a
|
|
32
30
|
* `sections` field and no top-level mappings).
|
|
33
31
|
*/
|
|
34
|
-
class SectionsConsumer
|
|
32
|
+
export default class SectionsConsumer
|
|
33
|
+
extends AbstractConsumer
|
|
34
|
+
implements IConsumer
|
|
35
|
+
{
|
|
35
36
|
_consumers: $ReadOnlyArray<[GeneratedOffset, IConsumer]>;
|
|
36
37
|
|
|
37
38
|
constructor(sourceMap: IndexMap) {
|
|
@@ -121,5 +122,3 @@ class SectionsConsumer extends AbstractConsumer implements IConsumer {
|
|
|
121
122
|
return null;
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
-
module.exports = SectionsConsumer;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 {Number0, Number1} from 'ob1';
|
|
12
|
+
|
|
13
|
+
declare const FIRST_COLUMN: Number0;
|
|
14
|
+
declare const FIRST_LINE: Number1;
|
|
15
|
+
export declare type IterationOrder = symbol & {__IterationOrder__: string};
|
|
16
|
+
declare const GENERATED_ORDER: IterationOrder;
|
|
17
|
+
declare const ORIGINAL_ORDER: IterationOrder;
|
|
18
|
+
export declare type LookupBias = symbol & {__LookupBias__: string};
|
|
19
|
+
declare const GREATEST_LOWER_BOUND: LookupBias;
|
|
20
|
+
declare const LEAST_UPPER_BOUND: LookupBias;
|
|
21
|
+
declare const EMPTY_POSITION: Readonly<{
|
|
22
|
+
source: null;
|
|
23
|
+
name: null;
|
|
24
|
+
line: null;
|
|
25
|
+
column: null;
|
|
26
|
+
}>;
|
|
27
|
+
declare function iterationOrderToString(x: IterationOrder): string;
|
|
28
|
+
declare function lookupBiasToString(x: LookupBias): string;
|
|
29
|
+
export {
|
|
30
|
+
FIRST_COLUMN,
|
|
31
|
+
FIRST_LINE,
|
|
32
|
+
GENERATED_ORDER,
|
|
33
|
+
ORIGINAL_ORDER,
|
|
34
|
+
GREATEST_LOWER_BOUND,
|
|
35
|
+
LEAST_UPPER_BOUND,
|
|
36
|
+
EMPTY_POSITION,
|
|
37
|
+
iterationOrderToString,
|
|
38
|
+
lookupBiasToString,
|
|
39
|
+
};
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.ORIGINAL_ORDER =
|
|
7
|
+
exports.LEAST_UPPER_BOUND =
|
|
8
|
+
exports.GREATEST_LOWER_BOUND =
|
|
9
|
+
exports.GENERATED_ORDER =
|
|
10
|
+
exports.FIRST_LINE =
|
|
11
|
+
exports.FIRST_COLUMN =
|
|
12
|
+
exports.EMPTY_POSITION =
|
|
13
|
+
void 0;
|
|
14
|
+
exports.iterationOrderToString = iterationOrderToString;
|
|
15
|
+
exports.lookupBiasToString = lookupBiasToString;
|
|
16
|
+
var _ob = require("ob1");
|
|
17
|
+
const FIRST_COLUMN = (exports.FIRST_COLUMN = (0, _ob.add0)(0));
|
|
18
|
+
const FIRST_LINE = (exports.FIRST_LINE = (0, _ob.add1)(0));
|
|
19
|
+
const GENERATED_ORDER = (exports.GENERATED_ORDER = "GENERATED_ORDER");
|
|
20
|
+
const ORIGINAL_ORDER = (exports.ORIGINAL_ORDER = "ORIGINAL_ORDER");
|
|
21
|
+
const GREATEST_LOWER_BOUND = (exports.GREATEST_LOWER_BOUND =
|
|
22
|
+
"GREATEST_LOWER_BOUND");
|
|
23
|
+
const LEAST_UPPER_BOUND = (exports.LEAST_UPPER_BOUND = "LEAST_UPPER_BOUND");
|
|
24
|
+
const EMPTY_POSITION = (exports.EMPTY_POSITION = Object.freeze({
|
|
11
25
|
source: null,
|
|
12
26
|
name: null,
|
|
13
27
|
line: null,
|
|
14
28
|
column: null,
|
|
15
|
-
});
|
|
29
|
+
}));
|
|
16
30
|
function iterationOrderToString(x) {
|
|
17
31
|
return x;
|
|
18
32
|
}
|
|
19
33
|
function lookupBiasToString(x) {
|
|
20
34
|
return x;
|
|
21
35
|
}
|
|
22
|
-
module.exports = {
|
|
23
|
-
FIRST_COLUMN,
|
|
24
|
-
FIRST_LINE,
|
|
25
|
-
GENERATED_ORDER,
|
|
26
|
-
ORIGINAL_ORDER,
|
|
27
|
-
GREATEST_LOWER_BOUND,
|
|
28
|
-
LEAST_UPPER_BOUND,
|
|
29
|
-
EMPTY_POSITION,
|
|
30
|
-
iterationOrderToString,
|
|
31
|
-
lookupBiasToString,
|
|
32
|
-
};
|
|
@@ -9,11 +9,9 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
12
|
import type {Number0, Number1} from 'ob1';
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
import {add0, add1} from 'ob1';
|
|
17
15
|
|
|
18
16
|
const FIRST_COLUMN: Number0 = add0(0);
|
|
19
17
|
const FIRST_LINE: Number1 = add1(0);
|
|
@@ -26,7 +24,12 @@ export opaque type LookupBias = 'GREATEST_LOWER_BOUND' | 'LEAST_UPPER_BOUND';
|
|
|
26
24
|
const GREATEST_LOWER_BOUND: LookupBias = 'GREATEST_LOWER_BOUND';
|
|
27
25
|
const LEAST_UPPER_BOUND: LookupBias = 'LEAST_UPPER_BOUND';
|
|
28
26
|
|
|
29
|
-
const EMPTY_POSITION
|
|
27
|
+
const EMPTY_POSITION: $ReadOnly<{
|
|
28
|
+
source: null,
|
|
29
|
+
name: null,
|
|
30
|
+
line: null,
|
|
31
|
+
column: null,
|
|
32
|
+
}> = Object.freeze({
|
|
30
33
|
source: null,
|
|
31
34
|
name: null,
|
|
32
35
|
line: null,
|
|
@@ -41,7 +44,7 @@ function lookupBiasToString(x: LookupBias): string {
|
|
|
41
44
|
return x;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
export {
|
|
45
48
|
FIRST_COLUMN,
|
|
46
49
|
FIRST_LINE,
|
|
47
50
|
GENERATED_ORDER,
|
|
@@ -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
|
+
import type {MixedSourceMap} from '../source-map';
|
|
12
|
+
import type {IConsumer} from './types';
|
|
13
|
+
|
|
14
|
+
declare function createConsumer(sourceMap: MixedSourceMap): IConsumer;
|
|
15
|
+
export default createConsumer;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
exports.default = createConsumer;
|
|
7
|
+
var _MappingsConsumer = _interopRequireDefault(require("./MappingsConsumer"));
|
|
8
|
+
var _SectionsConsumer = _interopRequireDefault(require("./SectionsConsumer"));
|
|
9
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
10
|
+
function _interopRequireDefault(e) {
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
12
|
+
}
|
|
4
13
|
function createConsumer(sourceMap) {
|
|
5
|
-
|
|
14
|
+
(0, _invariant.default)(
|
|
6
15
|
sourceMap.version === "3" || sourceMap.version === 3,
|
|
7
|
-
`Unrecognized source map format version: ${sourceMap.version}
|
|
16
|
+
`Unrecognized source map format version: ${sourceMap.version}`,
|
|
8
17
|
);
|
|
9
|
-
const MappingsConsumer = require("./MappingsConsumer");
|
|
10
|
-
const SectionsConsumer = require("./SectionsConsumer");
|
|
11
18
|
if (sourceMap.mappings === undefined) {
|
|
12
|
-
return new
|
|
19
|
+
return new _SectionsConsumer.default(sourceMap);
|
|
13
20
|
}
|
|
14
|
-
return new
|
|
21
|
+
return new _MappingsConsumer.default(sourceMap);
|
|
15
22
|
}
|
|
16
|
-
module.exports = createConsumer;
|