@marko/language-tools 2.4.8 → 2.5.1
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 +39 -11
- package/dist/index.mjs +39 -11
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -883,9 +883,9 @@ function getAttributeValueType(value) {
|
|
|
883
883
|
}
|
|
884
884
|
if (
|
|
885
885
|
// double quote string
|
|
886
|
-
/^"(?:[^"\\]
|
|
887
|
-
/^'(?:[^'\\]
|
|
888
|
-
/^`(?:[^`\\$]
|
|
886
|
+
/^"(?:[^"\\]|\\.)*"$/.test(value) || // single quote string
|
|
887
|
+
/^'(?:[^'\\]|\\.)*'$/.test(value) || // template literal without any interpolations
|
|
888
|
+
/^`(?:[^`\\$]|\\.|\$(?!\{))*`$/.test(value)
|
|
889
889
|
) {
|
|
890
890
|
return 2 /* QuotedString */;
|
|
891
891
|
} else if (
|
|
@@ -1185,7 +1185,22 @@ function crawlProgramScope(parsed, scriptParser) {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
|
-
|
|
1188
|
+
if (child.nameText === "script" && child.body) {
|
|
1189
|
+
checkForMutations(
|
|
1190
|
+
parentScope,
|
|
1191
|
+
scriptParser.expressionAt(
|
|
1192
|
+
child.body[0].start - "()=>{\n".length,
|
|
1193
|
+
`()=>{
|
|
1194
|
+
${read({
|
|
1195
|
+
start: child.body[0].start,
|
|
1196
|
+
end: child.body[child.body.length - 1].end
|
|
1197
|
+
})}
|
|
1198
|
+
}`
|
|
1199
|
+
)
|
|
1200
|
+
);
|
|
1201
|
+
} else {
|
|
1202
|
+
visit(child.body, bodyScope);
|
|
1203
|
+
}
|
|
1189
1204
|
Scopes.set(child.body, bodyScope);
|
|
1190
1205
|
}
|
|
1191
1206
|
if (child.attrs) {
|
|
@@ -1676,7 +1691,7 @@ function isTemplateTag(ts, tag) {
|
|
|
1676
1691
|
|
|
1677
1692
|
// src/extractors/script/util/runtime-overrides.ts
|
|
1678
1693
|
var RuntimeOverloads = /* @__PURE__ */ new Map();
|
|
1679
|
-
var commentsReg = /\/\*(?:[^*]
|
|
1694
|
+
var commentsReg = /\/\*(?:[^*]|\*[^/])*\*\//gm;
|
|
1680
1695
|
var replaceTokensReg = /\babstract\s+(\w+)|Marko\.(TemplateInput(?:<[^>]+>)?|Component)/gm;
|
|
1681
1696
|
var overrideBlockReg = /\/\*[*\s]*@marko-overload-start[*\s]*\*\/([\s\S]+)\/\*[*\s]*@marko-overload-end[*\s]*\*\//g;
|
|
1682
1697
|
function getRuntimeOverrides(runtimeTypes, generics, applyGenerics) {
|
|
@@ -1794,7 +1809,7 @@ var ATTR_UNAMED2 = "value";
|
|
|
1794
1809
|
var REG_EXT = /(?<=[/\\][^/\\]+)\.[^.]+$/;
|
|
1795
1810
|
var REG_BLOCK = /\s*{/y;
|
|
1796
1811
|
var REG_NEW_LINE = /^|(\r?\n)/g;
|
|
1797
|
-
var REG_ATTR_ARG_LITERAL = /(?<=\s*)(["'])((?:[^"'\\]
|
|
1812
|
+
var REG_ATTR_ARG_LITERAL = /(?<=\s*)(["'])((?:[^"'\\]|\\.|(?!\1))*)\1\s*([,)])/my;
|
|
1798
1813
|
var REG_TAG_IMPORT = /(?<=(['"]))<([^'">]+)>(?=\1)/;
|
|
1799
1814
|
var REG_INPUT_TYPE = /\s*(interface|type)\s+Input\b/y;
|
|
1800
1815
|
var REG_OBJECT_PROPERTY = /^[_$a-z][_$a-z0-9]*$/i;
|
|
@@ -2658,9 +2673,12 @@ const attrTags = ${varShared(
|
|
|
2658
2673
|
if (this.#writeAttrs(tag)) {
|
|
2659
2674
|
hasInput = true;
|
|
2660
2675
|
}
|
|
2661
|
-
const
|
|
2676
|
+
const isScript = tag.nameText === "script";
|
|
2677
|
+
const body = !isScript ? this.#processBody(tag) : void 0;
|
|
2662
2678
|
let hasRenderBody = false;
|
|
2663
|
-
if (
|
|
2679
|
+
if (isScript) {
|
|
2680
|
+
hasRenderBody = !!tag.body;
|
|
2681
|
+
} else if (body) {
|
|
2664
2682
|
hasInput = true;
|
|
2665
2683
|
this.#writeAttrTags(body, false, nestedTagType);
|
|
2666
2684
|
hasRenderBody = body.renderBody !== void 0;
|
|
@@ -2681,15 +2699,25 @@ const attrTags = ${varShared(
|
|
|
2681
2699
|
this.#extractor.write(`(() => {
|
|
2682
2700
|
`);
|
|
2683
2701
|
}
|
|
2684
|
-
|
|
2685
|
-
|
|
2702
|
+
let didReturn = false;
|
|
2703
|
+
if (isScript) {
|
|
2704
|
+
if (tag.body) {
|
|
2705
|
+
this.#copyWithMutationsReplaced({
|
|
2706
|
+
start: tag.body[0].start,
|
|
2707
|
+
end: tag.body[tag.body.length - 1].end
|
|
2708
|
+
});
|
|
2709
|
+
didReturn = this.#writeChildren(tag, []);
|
|
2710
|
+
}
|
|
2711
|
+
} else if (body == null ? void 0 : body.renderBody) {
|
|
2712
|
+
didReturn = this.#writeChildren(tag, body.renderBody);
|
|
2713
|
+
}
|
|
2686
2714
|
if (!tag.params) {
|
|
2687
2715
|
this.#extractor.write(`return () => {
|
|
2688
2716
|
`);
|
|
2689
2717
|
}
|
|
2690
2718
|
this.#writeReturn(
|
|
2691
2719
|
didReturn ? `${varLocal("return")}.return` : void 0,
|
|
2692
|
-
|
|
2720
|
+
getHoistSources(tag)
|
|
2693
2721
|
);
|
|
2694
2722
|
if (tag.params) {
|
|
2695
2723
|
this.#extractor.write("})");
|
package/dist/index.mjs
CHANGED
|
@@ -844,9 +844,9 @@ function getAttributeValueType(value) {
|
|
|
844
844
|
}
|
|
845
845
|
if (
|
|
846
846
|
// double quote string
|
|
847
|
-
/^"(?:[^"\\]
|
|
848
|
-
/^'(?:[^'\\]
|
|
849
|
-
/^`(?:[^`\\$]
|
|
847
|
+
/^"(?:[^"\\]|\\.)*"$/.test(value) || // single quote string
|
|
848
|
+
/^'(?:[^'\\]|\\.)*'$/.test(value) || // template literal without any interpolations
|
|
849
|
+
/^`(?:[^`\\$]|\\.|\$(?!\{))*`$/.test(value)
|
|
850
850
|
) {
|
|
851
851
|
return 2 /* QuotedString */;
|
|
852
852
|
} else if (
|
|
@@ -1146,7 +1146,22 @@ function crawlProgramScope(parsed, scriptParser) {
|
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
1148
|
}
|
|
1149
|
-
|
|
1149
|
+
if (child.nameText === "script" && child.body) {
|
|
1150
|
+
checkForMutations(
|
|
1151
|
+
parentScope,
|
|
1152
|
+
scriptParser.expressionAt(
|
|
1153
|
+
child.body[0].start - "()=>{\n".length,
|
|
1154
|
+
`()=>{
|
|
1155
|
+
${read({
|
|
1156
|
+
start: child.body[0].start,
|
|
1157
|
+
end: child.body[child.body.length - 1].end
|
|
1158
|
+
})}
|
|
1159
|
+
}`
|
|
1160
|
+
)
|
|
1161
|
+
);
|
|
1162
|
+
} else {
|
|
1163
|
+
visit(child.body, bodyScope);
|
|
1164
|
+
}
|
|
1150
1165
|
Scopes.set(child.body, bodyScope);
|
|
1151
1166
|
}
|
|
1152
1167
|
if (child.attrs) {
|
|
@@ -1637,7 +1652,7 @@ function isTemplateTag(ts, tag) {
|
|
|
1637
1652
|
|
|
1638
1653
|
// src/extractors/script/util/runtime-overrides.ts
|
|
1639
1654
|
var RuntimeOverloads = /* @__PURE__ */ new Map();
|
|
1640
|
-
var commentsReg = /\/\*(?:[^*]
|
|
1655
|
+
var commentsReg = /\/\*(?:[^*]|\*[^/])*\*\//gm;
|
|
1641
1656
|
var replaceTokensReg = /\babstract\s+(\w+)|Marko\.(TemplateInput(?:<[^>]+>)?|Component)/gm;
|
|
1642
1657
|
var overrideBlockReg = /\/\*[*\s]*@marko-overload-start[*\s]*\*\/([\s\S]+)\/\*[*\s]*@marko-overload-end[*\s]*\*\//g;
|
|
1643
1658
|
function getRuntimeOverrides(runtimeTypes, generics, applyGenerics) {
|
|
@@ -1758,7 +1773,7 @@ var ATTR_UNAMED2 = "value";
|
|
|
1758
1773
|
var REG_EXT = /(?<=[/\\][^/\\]+)\.[^.]+$/;
|
|
1759
1774
|
var REG_BLOCK = /\s*{/y;
|
|
1760
1775
|
var REG_NEW_LINE = /^|(\r?\n)/g;
|
|
1761
|
-
var REG_ATTR_ARG_LITERAL = /(?<=\s*)(["'])((?:[^"'\\]
|
|
1776
|
+
var REG_ATTR_ARG_LITERAL = /(?<=\s*)(["'])((?:[^"'\\]|\\.|(?!\1))*)\1\s*([,)])/my;
|
|
1762
1777
|
var REG_TAG_IMPORT = /(?<=(['"]))<([^'">]+)>(?=\1)/;
|
|
1763
1778
|
var REG_INPUT_TYPE = /\s*(interface|type)\s+Input\b/y;
|
|
1764
1779
|
var REG_OBJECT_PROPERTY = /^[_$a-z][_$a-z0-9]*$/i;
|
|
@@ -2622,9 +2637,12 @@ const attrTags = ${varShared(
|
|
|
2622
2637
|
if (this.#writeAttrs(tag)) {
|
|
2623
2638
|
hasInput = true;
|
|
2624
2639
|
}
|
|
2625
|
-
const
|
|
2640
|
+
const isScript = tag.nameText === "script";
|
|
2641
|
+
const body = !isScript ? this.#processBody(tag) : void 0;
|
|
2626
2642
|
let hasRenderBody = false;
|
|
2627
|
-
if (
|
|
2643
|
+
if (isScript) {
|
|
2644
|
+
hasRenderBody = !!tag.body;
|
|
2645
|
+
} else if (body) {
|
|
2628
2646
|
hasInput = true;
|
|
2629
2647
|
this.#writeAttrTags(body, false, nestedTagType);
|
|
2630
2648
|
hasRenderBody = body.renderBody !== void 0;
|
|
@@ -2645,15 +2663,25 @@ const attrTags = ${varShared(
|
|
|
2645
2663
|
this.#extractor.write(`(() => {
|
|
2646
2664
|
`);
|
|
2647
2665
|
}
|
|
2648
|
-
|
|
2649
|
-
|
|
2666
|
+
let didReturn = false;
|
|
2667
|
+
if (isScript) {
|
|
2668
|
+
if (tag.body) {
|
|
2669
|
+
this.#copyWithMutationsReplaced({
|
|
2670
|
+
start: tag.body[0].start,
|
|
2671
|
+
end: tag.body[tag.body.length - 1].end
|
|
2672
|
+
});
|
|
2673
|
+
didReturn = this.#writeChildren(tag, []);
|
|
2674
|
+
}
|
|
2675
|
+
} else if (body == null ? void 0 : body.renderBody) {
|
|
2676
|
+
didReturn = this.#writeChildren(tag, body.renderBody);
|
|
2677
|
+
}
|
|
2650
2678
|
if (!tag.params) {
|
|
2651
2679
|
this.#extractor.write(`return () => {
|
|
2652
2680
|
`);
|
|
2653
2681
|
}
|
|
2654
2682
|
this.#writeReturn(
|
|
2655
2683
|
didReturn ? `${varLocal("return")}.return` : void 0,
|
|
2656
|
-
|
|
2684
|
+
getHoistSources(tag)
|
|
2657
2685
|
);
|
|
2658
2686
|
if (tag.params) {
|
|
2659
2687
|
this.#extractor.write("})");
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.1",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@marko/compiler": "^5.28.4"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@babel/parser": "^7.26.
|
|
10
|
+
"@babel/parser": "^7.26.3",
|
|
11
11
|
"@luxass/strip-json-comments": "^1.3.2",
|
|
12
12
|
"htmljs-parser": "^5.5.3",
|
|
13
13
|
"relative-import-path": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@babel/code-frame": "^7.26.2",
|
|
17
|
-
"@marko/compiler": "^5.38.
|
|
18
|
-
"@marko/translator-default": "^6.1.
|
|
17
|
+
"@marko/compiler": "^5.38.3",
|
|
18
|
+
"@marko/translator-default": "^6.1.2",
|
|
19
19
|
"@types/babel__code-frame": "^7.0.6",
|
|
20
20
|
"@typescript/vfs": "^1.6.0",
|
|
21
|
-
"marko": "^5.36.
|
|
22
|
-
"mitata": "^1.0.
|
|
21
|
+
"marko": "^5.36.3",
|
|
22
|
+
"mitata": "^1.0.20",
|
|
23
23
|
"tsx": "^4.19.2"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|