@marko/language-tools 2.5.55 → 2.5.57

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/index.js CHANGED
@@ -2682,11 +2682,11 @@ scope: ${scopeExpr}
2682
2682
  case 10 /* AttrNamed */: {
2683
2683
  const isDefault = isEmptyRange2(attr.name);
2684
2684
  const value = attr.value;
2685
- const modifierIndex = !isDefault && (!value || value.type === 13 /* AttrValue */) && this.#getNamedAttrModifierIndex(attr);
2685
+ const modifier = !value || value.type === 13 /* AttrValue */ ? this.#getNamedAttrModifier(attr) : void 0;
2686
2686
  const defaultMapPosition = isDefault ? attr.name : void 0;
2687
2687
  let name = isDefault ? ATTR_UNAMED2 : attr.name;
2688
- if (modifierIndex !== false) {
2689
- name = { start: attr.name.start, end: modifierIndex };
2688
+ if (modifier) {
2689
+ name = { start: attr.name.start, end: modifier.start - 1 };
2690
2690
  }
2691
2691
  if (value) {
2692
2692
  switch (value.type) {
@@ -2701,13 +2701,14 @@ scope: ${scopeExpr}
2701
2701
  if (boundRange) {
2702
2702
  if (!boundRange.member) {
2703
2703
  const valueLiteral = this.#read(boundRange.value);
2704
- this.#extractor.copy(boundRange.value).copy(boundRange.types).write(`
2704
+ this.#extractor.copy(boundRange.value).write(" ").copy(boundRange.types).write(`
2705
2705
  )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write(
2706
2706
  `Change"(
2707
2707
  // @ts-ignore
2708
- _${valueLiteral}) {
2708
+ _${valueLiteral}
2709
+ ) {
2709
2710
  ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`) : ""}`
2710
- ).copy(boundRange.value).write(`= _${valueLiteral};
2711
+ ).copy(boundRange.value).write("= ").copy(modifier).write(`(_${valueLiteral});
2711
2712
  }`);
2712
2713
  } else if (boundRange.member.computed) {
2713
2714
  this.#extractor.copy(boundRange.value).copy({
@@ -2717,14 +2718,26 @@ ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`)
2717
2718
  start: boundRange.member.end,
2718
2719
  end: boundRange.member.end + 1
2719
2720
  }).copy(boundRange.types).write(`
2720
- )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n').copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`])");
2721
+ )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n');
2722
+ if (modifier) {
2723
+ this.#extractor.copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`] && ((\n// @ts-ignore\n_\n)=>{\n").copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`](").copy(modifier).write("(_));\n})");
2724
+ } else {
2725
+ this.#extractor.copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`]");
2726
+ }
2727
+ this.#extractor.write(")");
2721
2728
  } else {
2722
2729
  const memberRange = {
2723
2730
  start: boundRange.value.start,
2724
2731
  end: boundRange.member.end
2725
2732
  };
2726
2733
  this.#extractor.copy(memberRange).copy(boundRange.types).write(`
2727
- )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n').copy(memberRange).write("Change)");
2734
+ )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n');
2735
+ if (modifier) {
2736
+ this.#extractor.copy(memberRange).write("Change && ((\n// @ts-ignore\n_\n)=>{\n").copy(memberRange).write("Change(").copy(modifier).write("(_));\n})");
2737
+ } else {
2738
+ this.#extractor.copy(memberRange).write("Change");
2739
+ }
2740
+ this.#extractor.write(")");
2728
2741
  }
2729
2742
  } else {
2730
2743
  this.#copyWithMutationsReplaced(value.value);
@@ -2773,7 +2786,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`)
2773
2786
  this.#extractor.copy(attr.args);
2774
2787
  }
2775
2788
  } else {
2776
- this.#extractor.write('"').copy(defaultMapPosition).copy(name).write(`": ${modifierIndex === false ? "true" : '""'}`);
2789
+ this.#extractor.write('"').copy(defaultMapPosition).copy(name).write(`": ${modifier ? '""' : "true"}`);
2777
2790
  }
2778
2791
  break;
2779
2792
  }
@@ -3351,13 +3364,12 @@ ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`)
3351
3364
  return `${varShared("readScopes")}({ ${hoistVars.join(SEP_COMMA_SPACE)} })`;
3352
3365
  }
3353
3366
  }
3354
- #getNamedAttrModifierIndex(attr) {
3355
- const start = attr.name.start + 1;
3356
- const end = attr.name.end - 1;
3357
- for (let i = end; i-- > start; ) {
3358
- if (this.#code.charAt(i) === ":") return i;
3367
+ #getNamedAttrModifier(attr) {
3368
+ const start = attr.name.start;
3369
+ const end = attr.name.end;
3370
+ for (let i = end - 1; i-- > start; ) {
3371
+ if (this.#code.charAt(i) === ":") return { start: i + 1, end };
3359
3372
  }
3360
- return false;
3361
3373
  }
3362
3374
  #getAttrTagName(tag) {
3363
3375
  var _a;
package/dist/index.mjs CHANGED
@@ -2645,11 +2645,11 @@ scope: ${scopeExpr}
2645
2645
  case 10 /* AttrNamed */: {
2646
2646
  const isDefault = isEmptyRange2(attr.name);
2647
2647
  const value = attr.value;
2648
- const modifierIndex = !isDefault && (!value || value.type === 13 /* AttrValue */) && this.#getNamedAttrModifierIndex(attr);
2648
+ const modifier = !value || value.type === 13 /* AttrValue */ ? this.#getNamedAttrModifier(attr) : void 0;
2649
2649
  const defaultMapPosition = isDefault ? attr.name : void 0;
2650
2650
  let name = isDefault ? ATTR_UNAMED2 : attr.name;
2651
- if (modifierIndex !== false) {
2652
- name = { start: attr.name.start, end: modifierIndex };
2651
+ if (modifier) {
2652
+ name = { start: attr.name.start, end: modifier.start - 1 };
2653
2653
  }
2654
2654
  if (value) {
2655
2655
  switch (value.type) {
@@ -2664,13 +2664,14 @@ scope: ${scopeExpr}
2664
2664
  if (boundRange) {
2665
2665
  if (!boundRange.member) {
2666
2666
  const valueLiteral = this.#read(boundRange.value);
2667
- this.#extractor.copy(boundRange.value).copy(boundRange.types).write(`
2667
+ this.#extractor.copy(boundRange.value).write(" ").copy(boundRange.types).write(`
2668
2668
  )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write(
2669
2669
  `Change"(
2670
2670
  // @ts-ignore
2671
- _${valueLiteral}) {
2671
+ _${valueLiteral}
2672
+ ) {
2672
2673
  ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`) : ""}`
2673
- ).copy(boundRange.value).write(`= _${valueLiteral};
2674
+ ).copy(boundRange.value).write("= ").copy(modifier).write(`(_${valueLiteral});
2674
2675
  }`);
2675
2676
  } else if (boundRange.member.computed) {
2676
2677
  this.#extractor.copy(boundRange.value).copy({
@@ -2680,14 +2681,26 @@ ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`)
2680
2681
  start: boundRange.member.end,
2681
2682
  end: boundRange.member.end + 1
2682
2683
  }).copy(boundRange.types).write(`
2683
- )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n').copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`])");
2684
+ )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n');
2685
+ if (modifier) {
2686
+ this.#extractor.copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`] && ((\n// @ts-ignore\n_\n)=>{\n").copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`](").copy(modifier).write("(_));\n})");
2687
+ } else {
2688
+ this.#extractor.copy(boundRange.value).write("[`${\n").copy(boundRange.member).write("\n}Change`]");
2689
+ }
2690
+ this.#extractor.write(")");
2684
2691
  } else {
2685
2692
  const memberRange = {
2686
2693
  start: boundRange.value.start,
2687
2694
  end: boundRange.member.end
2688
2695
  };
2689
2696
  this.#extractor.copy(memberRange).copy(boundRange.types).write(`
2690
- )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n').copy(memberRange).write("Change)");
2697
+ )${SEP_COMMA_NEW_LINE}"`).copy(defaultMapPosition).copy(name).write('Change": (\n');
2698
+ if (modifier) {
2699
+ this.#extractor.copy(memberRange).write("Change && ((\n// @ts-ignore\n_\n)=>{\n").copy(memberRange).write("Change(").copy(modifier).write("(_));\n})");
2700
+ } else {
2701
+ this.#extractor.copy(memberRange).write("Change");
2702
+ }
2703
+ this.#extractor.write(")");
2691
2704
  }
2692
2705
  } else {
2693
2706
  this.#copyWithMutationsReplaced(value.value);
@@ -2736,7 +2749,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`)
2736
2749
  this.#extractor.copy(attr.args);
2737
2750
  }
2738
2751
  } else {
2739
- this.#extractor.write('"').copy(defaultMapPosition).copy(name).write(`": ${modifierIndex === false ? "true" : '""'}`);
2752
+ this.#extractor.write('"').copy(defaultMapPosition).copy(name).write(`": ${modifier ? '""' : "true"}`);
2740
2753
  }
2741
2754
  break;
2742
2755
  }
@@ -3314,13 +3327,12 @@ ${isMutatedVar(tag.parent, valueLiteral) ? varLocal(`change__${valueLiteral}.`)
3314
3327
  return `${varShared("readScopes")}({ ${hoistVars.join(SEP_COMMA_SPACE)} })`;
3315
3328
  }
3316
3329
  }
3317
- #getNamedAttrModifierIndex(attr) {
3318
- const start = attr.name.start + 1;
3319
- const end = attr.name.end - 1;
3320
- for (let i = end; i-- > start; ) {
3321
- if (this.#code.charAt(i) === ":") return i;
3330
+ #getNamedAttrModifier(attr) {
3331
+ const start = attr.name.start;
3332
+ const end = attr.name.end;
3333
+ for (let i = end - 1; i-- > start; ) {
3334
+ if (this.#code.charAt(i) === ":") return { start: i + 1, end };
3322
3335
  }
3323
- return false;
3324
3336
  }
3325
3337
  #getAttrTagName(tag) {
3326
3338
  var _a;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.5.55",
4
+ "version": "2.5.57",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "dependencies": {
7
- "@marko/compiler": "^5.39.53",
7
+ "@marko/compiler": "^5.39.61",
8
8
  "@luxass/strip-json-comments": "^1.4.0",
9
- "htmljs-parser": "^5.7.4",
9
+ "htmljs-parser": "^5.10.2",
10
10
  "relative-import-path": "^1.0.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/babel__code-frame": "^7.27.0",
14
- "@typescript/vfs": "^1.6.2",
15
- "marko": "^5.38.21",
14
+ "@typescript/vfs": "^1.6.4",
15
+ "marko": "^5.38.31",
16
16
  "mitata": "^1.0.34",
17
17
  "tsx": "^4.21.0"
18
18
  },