@tsrx/content-mapper 0.1.4 → 0.1.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/dist/mapper.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as validate_options, n as require, r as to_diagnostic, t as create_tsrx_content_mapper } from "./mapper-
|
|
1
|
+
import { i as validate_options, n as require, r as to_diagnostic, t as create_tsrx_content_mapper } from "./mapper-CsFz-OPS.js";
|
|
2
2
|
|
|
3
3
|
export { create_tsrx_content_mapper, require, to_diagnostic, validate_options };
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as create_tsrx_content_mapper } from "./mapper-
|
|
2
|
+
import { t as create_tsrx_content_mapper } from "./mapper-CsFz-OPS.js";
|
|
3
3
|
import { redirect_console_to_stderr, run_mapper_server } from "./rpc.js";
|
|
4
4
|
|
|
5
5
|
//#region src/server.js
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/content-mapper",
|
|
3
3
|
"description": "TypeScript 7 content mapper for .tsrx files",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Dominic Gannaway",
|
|
7
7
|
"type": "module",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"tsdown": "^0.23.0",
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
52
|
"vue": "3.6.0-rc.14",
|
|
53
|
-
"@tsrx/
|
|
54
|
-
"@tsrx/
|
|
55
|
-
"@tsrx/
|
|
56
|
-
"@tsrx/
|
|
57
|
-
"@tsrx/
|
|
58
|
-
"@tsrx/
|
|
53
|
+
"@tsrx/solid": "0.4.12",
|
|
54
|
+
"@tsrx/typescript-plugin": "0.7.12",
|
|
55
|
+
"@tsrx/core": "0.8.0",
|
|
56
|
+
"@tsrx/preact": "0.4.12",
|
|
57
|
+
"@tsrx/vue": "0.4.12",
|
|
58
|
+
"@tsrx/react": "0.5.12"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
package/src/span-mappings.js
CHANGED
|
@@ -98,6 +98,14 @@ export function features_from_mapping_data(data) {
|
|
|
98
98
|
* the span exactly show the authored name.
|
|
99
99
|
* - Anything else → `Atom`.
|
|
100
100
|
*
|
|
101
|
+
* Mappings over the same ranges in both files are one candidate. A container
|
|
102
|
+
* mapped for diagnostics only can cover exactly the text of the token inside
|
|
103
|
+
* it (`item` in a Vue `{item.label}`, a Solid `key i`), and the token keeps
|
|
104
|
+
* its hover and navigation whichever comes first: a mapping without features
|
|
105
|
+
* never takes the place of one with features. Of two with features, the first
|
|
106
|
+
* is kept, so the spans that coalesce stay the same. The candidate is
|
|
107
|
+
* position-only when one of its mappings is and none has a feature bit.
|
|
108
|
+
*
|
|
101
109
|
* The transform emits container spans (statements, control-flow bodies) that
|
|
102
110
|
* enclose token spans. TypeScript requires generated spans to be disjoint, so
|
|
103
111
|
* candidates are ranked Verbatim first, then shorter before longer, and a
|
|
@@ -126,6 +134,13 @@ export function to_span_mappings(mappings, generated_text, original_text, option
|
|
|
126
134
|
const language_features = options.languageFeatures !== false;
|
|
127
135
|
/** @type {Candidate[]} */
|
|
128
136
|
const candidates = [];
|
|
137
|
+
/**
|
|
138
|
+
* Candidates by their generated and original ranges. Kept apart, two
|
|
139
|
+
* candidates over the same ranges would tie in the ranking below, and the
|
|
140
|
+
* first in the transform's order would win even without features.
|
|
141
|
+
* @type {Map<string, Candidate>}
|
|
142
|
+
*/
|
|
143
|
+
const by_ranges = new Map();
|
|
129
144
|
|
|
130
145
|
for (const mapping of mappings) {
|
|
131
146
|
const count = Math.min(mapping.sourceOffsets.length, mapping.generatedOffsets.length);
|
|
@@ -173,17 +188,30 @@ export function to_span_mappings(mappings, generated_text, original_text, option
|
|
|
173
188
|
} else {
|
|
174
189
|
kind = SpanMapKind.Atom;
|
|
175
190
|
}
|
|
176
|
-
|
|
191
|
+
const features = language_features
|
|
192
|
+
? features_from_mapping_data(mapping.data)
|
|
193
|
+
: SpanMapFeature.None;
|
|
194
|
+
const position_only = is_position_only(mapping.data);
|
|
195
|
+
const key = `${generated_start},${generated_end},${original_start},${original_end}`;
|
|
196
|
+
const same = by_ranges.get(key);
|
|
197
|
+
if (same) {
|
|
198
|
+
if (same.features === SpanMapFeature.None) same.features = features;
|
|
199
|
+
same.positionOnly =
|
|
200
|
+
(same.positionOnly || position_only) && same.features === SpanMapFeature.None;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
/** @type {Candidate} */
|
|
204
|
+
const candidate = {
|
|
177
205
|
generatedStart: generated_start,
|
|
178
206
|
generatedEnd: generated_end,
|
|
179
207
|
originalStart: original_start,
|
|
180
208
|
originalEnd: original_end,
|
|
181
209
|
kind,
|
|
182
|
-
features
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
210
|
+
features,
|
|
211
|
+
positionOnly: position_only,
|
|
212
|
+
};
|
|
213
|
+
by_ranges.set(key, candidate);
|
|
214
|
+
candidates.push(candidate);
|
|
187
215
|
}
|
|
188
216
|
}
|
|
189
217
|
|