@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.
@@ -2447,6 +2447,10 @@ const DIAGNOSTIC_CODES = {
2447
2447
  * it renders nothing.
2448
2448
  */
2449
2449
  CODE_BLOCK_EXPRESSION_ONLY: "TSRX2035",
2450
+ /** A `break` that would leave an `@try`, `@pending`, `@catch` or `@empty` body, or a nested `@{ … }` block. */
2451
+ DIRECTIVE_BODY_BREAK: "TSRX2036",
2452
+ /** A `continue` that would leave an `@try`, `@pending`, `@catch`, `@empty` or `@switch` case body, or a nested `@{ … }` block. */
2453
+ DIRECTIVE_BODY_CONTINUE: "TSRX2037",
2450
2454
  /** `<style apply>` carries no expression value. */
2451
2455
  STYLE_APPLY_VALUE: "TSRX3001",
2452
2456
  /** An `apply` entry is not an identifier, member, or array of those, or does not resolve to a style block. */
@@ -2475,6 +2479,8 @@ const DIAGNOSTIC_CODES = {
2475
2479
  CSS_SYNTAX: "TSRX3013",
2476
2480
  /** A `<style>` block in a child expression container (`{<style>…</style>}`), which renders its class map. */
2477
2481
  STYLE_IN_EXPRESSION_CONTAINER: "TSRX3014",
2482
+ /** An `&` with no rule around it in the output, which would match the page's root element. */
2483
+ CSS_NESTING_SELECTOR_PLACEMENT: "TSRX3015",
2478
2484
  /** A recognized `import.meta.env.platform.*` flag is used without a selected platform. */
2479
2485
  PLATFORM_REQUIRED: "TSRX4001",
2480
2486
  /** A name that starts with the prefix the compiler reserves for its own identifiers. */
@@ -3151,6 +3157,14 @@ function features_from_mapping_data(data) {
3151
3157
  * the span exactly show the authored name.
3152
3158
  * - Anything else → `Atom`.
3153
3159
  *
3160
+ * Mappings over the same ranges in both files are one candidate. A container
3161
+ * mapped for diagnostics only can cover exactly the text of the token inside
3162
+ * it (`item` in a Vue `{item.label}`, a Solid `key i`), and the token keeps
3163
+ * its hover and navigation whichever comes first: a mapping without features
3164
+ * never takes the place of one with features. Of two with features, the first
3165
+ * is kept, so the spans that coalesce stay the same. The candidate is
3166
+ * position-only when one of its mappings is and none has a feature bit.
3167
+ *
3154
3168
  * The transform emits container spans (statements, control-flow bodies) that
3155
3169
  * enclose token spans. TypeScript requires generated spans to be disjoint, so
3156
3170
  * candidates are ranked Verbatim first, then shorter before longer, and a
@@ -3179,6 +3193,13 @@ function to_span_mappings(mappings, generated_text, original_text, options = {})
3179
3193
  const language_features = options.languageFeatures !== false;
3180
3194
  /** @type {Candidate[]} */
3181
3195
  const candidates = [];
3196
+ /**
3197
+ * Candidates by their generated and original ranges. Kept apart, two
3198
+ * candidates over the same ranges would tie in the ranking below, and the
3199
+ * first in the transform's order would win even without features.
3200
+ * @type {Map<string, Candidate>}
3201
+ */
3202
+ const by_ranges = /* @__PURE__ */ new Map();
3182
3203
  for (const mapping of mappings) {
3183
3204
  const count = Math.min(mapping.sourceOffsets.length, mapping.generatedOffsets.length);
3184
3205
  for (let index = 0; index < count; index++) {
@@ -3198,15 +3219,27 @@ function to_span_mappings(mappings, generated_text, original_text, options = {})
3198
3219
  else if (is_whole_identifier(generated_text, generated_start, generated_end) && is_whole_token(original_text, original_start, original_end)) kind = SpanMapKind.Alias;
3199
3220
  else if (is_partial_identifier(original_text, original_start, original_end)) continue;
3200
3221
  else kind = SpanMapKind.Atom;
3201
- candidates.push({
3222
+ const features = language_features ? features_from_mapping_data(mapping.data) : SpanMapFeature.None;
3223
+ const position_only = is_position_only(mapping.data);
3224
+ const key = `${generated_start},${generated_end},${original_start},${original_end}`;
3225
+ const same = by_ranges.get(key);
3226
+ if (same) {
3227
+ if (same.features === SpanMapFeature.None) same.features = features;
3228
+ same.positionOnly = (same.positionOnly || position_only) && same.features === SpanMapFeature.None;
3229
+ continue;
3230
+ }
3231
+ /** @type {Candidate} */
3232
+ const candidate = {
3202
3233
  generatedStart: generated_start,
3203
3234
  generatedEnd: generated_end,
3204
3235
  originalStart: original_start,
3205
3236
  originalEnd: original_end,
3206
3237
  kind,
3207
- features: language_features ? features_from_mapping_data(mapping.data) : SpanMapFeature.None,
3208
- positionOnly: is_position_only(mapping.data)
3209
- });
3238
+ features,
3239
+ positionOnly: position_only
3240
+ };
3241
+ by_ranges.set(key, candidate);
3242
+ candidates.push(candidate);
3210
3243
  }
3211
3244
  }
3212
3245
  candidates.sort((left, right) => Number(left.kind !== SpanMapKind.Verbatim) - Number(right.kind !== SpanMapKind.Verbatim) || left.generatedEnd - left.generatedStart - (right.generatedEnd - right.generatedStart) || left.generatedStart - right.generatedStart || left.originalStart - right.originalStart);
@@ -3986,4 +4019,4 @@ function nearest_package_manifest(entry) {
3986
4019
 
3987
4020
  //#endregion
3988
4021
  export { validate_options as i, require$1 as n, to_diagnostic as r, create_tsrx_content_mapper as t };
3989
- //# sourceMappingURL=mapper-SyX-87Od.js.map
4022
+ //# sourceMappingURL=mapper-CsFz-OPS.js.map