@volar/source-map 0.33.6 → 0.34.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/out/index.js +23 -23
- package/package.json +2 -2
package/out/index.js
CHANGED
|
@@ -45,13 +45,13 @@ class SourceMapBase {
|
|
|
45
45
|
this.mappings = _mappings ?? [];
|
|
46
46
|
}
|
|
47
47
|
getSourceRange(start, end, filter) {
|
|
48
|
-
for (const
|
|
49
|
-
return
|
|
48
|
+
for (const mapped of this.getRanges(start, end ?? start, false, filter)) {
|
|
49
|
+
return mapped;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
getMappedRange(start, end, filter) {
|
|
53
|
-
for (const
|
|
54
|
-
return
|
|
53
|
+
for (const mapped of this.getRanges(start, end ?? start, true, filter)) {
|
|
54
|
+
return mapped;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
getSourceRanges(start, end, filter) {
|
|
@@ -64,31 +64,31 @@ class SourceMapBase {
|
|
|
64
64
|
for (const mapping of this.mappings) {
|
|
65
65
|
if (filter && !filter(mapping.data))
|
|
66
66
|
continue;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
yield
|
|
67
|
+
const mapped = this.getRange(startOffset, endOffset, sourceToTarget, mapping.mode, mapping.sourceRange, mapping.mappedRange, mapping.data);
|
|
68
|
+
if (mapped) {
|
|
69
|
+
yield getMapped(mapped);
|
|
70
70
|
}
|
|
71
71
|
else if (mapping.additional) {
|
|
72
72
|
for (const other of mapping.additional) {
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
yield
|
|
73
|
+
const mapped = this.getRange(startOffset, endOffset, sourceToTarget, other.mode, other.sourceRange, other.mappedRange, mapping.data);
|
|
74
|
+
if (mapped) {
|
|
75
|
+
yield getMapped(mapped);
|
|
76
76
|
break; // only return first match additional range
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
81
|
+
function getMapped(mapped) {
|
|
82
|
+
return mapped;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
getRange(start, end, sourceToTarget, mode, sourceRange, targetRange, data) {
|
|
86
|
-
const
|
|
87
|
-
const
|
|
86
|
+
const mappedToRange = sourceToTarget ? targetRange : sourceRange;
|
|
87
|
+
const mappedFromRange = sourceToTarget ? sourceRange : targetRange;
|
|
88
88
|
if (mode === Mode.Totally) {
|
|
89
|
-
if (start ===
|
|
90
|
-
const _start =
|
|
91
|
-
const _end =
|
|
89
|
+
if (start === mappedFromRange.start && end === mappedFromRange.end) {
|
|
90
|
+
const _start = mappedToRange.start;
|
|
91
|
+
const _end = mappedToRange.end;
|
|
92
92
|
return [{
|
|
93
93
|
start: Math.min(_start, _end),
|
|
94
94
|
end: Math.max(_start, _end),
|
|
@@ -96,9 +96,9 @@ class SourceMapBase {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
else if (mode === Mode.Offset) {
|
|
99
|
-
if (start >=
|
|
100
|
-
const _start =
|
|
101
|
-
const _end =
|
|
99
|
+
if (start >= mappedFromRange.start && end <= mappedFromRange.end) {
|
|
100
|
+
const _start = mappedToRange.start + start - mappedFromRange.start;
|
|
101
|
+
const _end = mappedToRange.end + end - mappedFromRange.end;
|
|
102
102
|
return [{
|
|
103
103
|
start: Math.min(_start, _end),
|
|
104
104
|
end: Math.max(_start, _end),
|
|
@@ -106,9 +106,9 @@ class SourceMapBase {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
else if (mode === Mode.Expand) {
|
|
109
|
-
if (start >=
|
|
110
|
-
const _start =
|
|
111
|
-
const _end =
|
|
109
|
+
if (start >= mappedFromRange.start && end <= mappedFromRange.end) {
|
|
110
|
+
const _start = mappedToRange.start;
|
|
111
|
+
const _end = mappedToRange.end;
|
|
112
112
|
return [{
|
|
113
113
|
start: Math.min(_start, _end),
|
|
114
114
|
end: Math.max(_start, _end),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/source-map",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"url": "https://github.com/johnsoncodehk/volar.git",
|
|
13
13
|
"directory": "packages/source-map"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "1a70119c77eca70c56d5a99da0322c087a6cb33b"
|
|
16
16
|
}
|