@marko/language-tools 2.0.6 → 2.0.7
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 +27 -5
- package/dist/index.mjs +27 -5
- package/dist/util/project.d.ts +2 -0
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -2000,7 +2000,7 @@ constructor(_?: Return) {}
|
|
|
2000
2000
|
}
|
|
2001
2001
|
this.#writeComments(child);
|
|
2002
2002
|
this.#extractor.write("if (").copy(
|
|
2003
|
-
((_a = child.args) == null ? void 0 : _a.value) || this.#getAttrValue(child, ATTR_UNAMED2) || "undefined"
|
|
2003
|
+
this.#getRangeWithoutTrailingComma((_a = child.args) == null ? void 0 : _a.value) || this.#getAttrValue(child, ATTR_UNAMED2) || "undefined"
|
|
2004
2004
|
).write(") {\n");
|
|
2005
2005
|
if (child.body) {
|
|
2006
2006
|
const localBindings = getHoistSources(child);
|
|
@@ -2081,7 +2081,9 @@ constructor(_?: Return) {}
|
|
|
2081
2081
|
}
|
|
2082
2082
|
case "while": {
|
|
2083
2083
|
this.#writeComments(child);
|
|
2084
|
-
this.#extractor.write("while (\n").copy(
|
|
2084
|
+
this.#extractor.write("while (\n").copy(
|
|
2085
|
+
this.#getRangeWithoutTrailingComma((_b = child.args) == null ? void 0 : _b.value) || "undefined"
|
|
2086
|
+
).write("\n) {\n");
|
|
2085
2087
|
const body = this.#processBody(child);
|
|
2086
2088
|
if (body == null ? void 0 : body.renderBody) {
|
|
2087
2089
|
this.#writeChildren(child, body.renderBody);
|
|
@@ -2436,7 +2438,7 @@ const attrTags = ${varShared(
|
|
|
2436
2438
|
const alternates = IF_TAG_ALTERNATES.get(tag);
|
|
2437
2439
|
this.#writeComments(tag);
|
|
2438
2440
|
this.#extractor.write("((\n").copy(
|
|
2439
|
-
((_a = tag.args) == null ? void 0 : _a.value) || this.#getAttrValue(tag, ATTR_UNAMED2) || "undefined"
|
|
2441
|
+
this.#getRangeWithoutTrailingComma((_a = tag.args) == null ? void 0 : _a.value) || this.#getAttrValue(tag, ATTR_UNAMED2) || "undefined"
|
|
2440
2442
|
).write("\n) ? ");
|
|
2441
2443
|
this.#writeDynamicAttrTagBody(tag);
|
|
2442
2444
|
let needsAlternate = true;
|
|
@@ -2475,7 +2477,9 @@ const attrTags = ${varShared(
|
|
|
2475
2477
|
case "while": {
|
|
2476
2478
|
this.#writeComments(tag);
|
|
2477
2479
|
this.#extractor.write(`${varShared("mergeAttrTags")}((
|
|
2478
|
-
`).copy(
|
|
2480
|
+
`).copy(
|
|
2481
|
+
this.#getRangeWithoutTrailingComma((_c = tag.args) == null ? void 0 : _c.value) || "undefined"
|
|
2482
|
+
).write("\n) ? [");
|
|
2479
2483
|
this.#writeDynamicAttrTagBody(tag);
|
|
2480
2484
|
this.#extractor.write("] : [])");
|
|
2481
2485
|
break;
|
|
@@ -2663,7 +2667,9 @@ const attrTags = ${varShared(
|
|
|
2663
2667
|
switch (nextChild.nameText) {
|
|
2664
2668
|
case "else-if": {
|
|
2665
2669
|
const alternate = {
|
|
2666
|
-
condition:
|
|
2670
|
+
condition: this.#getRangeWithoutTrailingComma(
|
|
2671
|
+
(_a = nextChild.args) == null ? void 0 : _a.value
|
|
2672
|
+
) || this.#getAttrValue(nextChild, ATTR_UNAMED2),
|
|
2667
2673
|
node: nextChild
|
|
2668
2674
|
};
|
|
2669
2675
|
hasDynamicAttrTags ||= nextChild.hasAttrTags;
|
|
@@ -2763,6 +2769,22 @@ const attrTags = ${varShared(
|
|
|
2763
2769
|
}
|
|
2764
2770
|
}
|
|
2765
2771
|
}
|
|
2772
|
+
#getRangeWithoutTrailingComma(range) {
|
|
2773
|
+
if (!range)
|
|
2774
|
+
return void 0;
|
|
2775
|
+
const { start } = range;
|
|
2776
|
+
let end = range.end - 1;
|
|
2777
|
+
while (end >= start) {
|
|
2778
|
+
if (isWhitespaceCode(this.#code.charCodeAt(end))) {
|
|
2779
|
+
end--;
|
|
2780
|
+
} else if (this.#code.charAt(end) === ",") {
|
|
2781
|
+
return { start, end };
|
|
2782
|
+
} else {
|
|
2783
|
+
break;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
return range;
|
|
2787
|
+
}
|
|
2766
2788
|
#isEmptyText(text) {
|
|
2767
2789
|
let pos = text.start;
|
|
2768
2790
|
while (pos < text.end) {
|
package/dist/index.mjs
CHANGED
|
@@ -1969,7 +1969,7 @@ constructor(_?: Return) {}
|
|
|
1969
1969
|
}
|
|
1970
1970
|
this.#writeComments(child);
|
|
1971
1971
|
this.#extractor.write("if (").copy(
|
|
1972
|
-
((_a = child.args) == null ? void 0 : _a.value) || this.#getAttrValue(child, ATTR_UNAMED2) || "undefined"
|
|
1972
|
+
this.#getRangeWithoutTrailingComma((_a = child.args) == null ? void 0 : _a.value) || this.#getAttrValue(child, ATTR_UNAMED2) || "undefined"
|
|
1973
1973
|
).write(") {\n");
|
|
1974
1974
|
if (child.body) {
|
|
1975
1975
|
const localBindings = getHoistSources(child);
|
|
@@ -2050,7 +2050,9 @@ constructor(_?: Return) {}
|
|
|
2050
2050
|
}
|
|
2051
2051
|
case "while": {
|
|
2052
2052
|
this.#writeComments(child);
|
|
2053
|
-
this.#extractor.write("while (\n").copy(
|
|
2053
|
+
this.#extractor.write("while (\n").copy(
|
|
2054
|
+
this.#getRangeWithoutTrailingComma((_b = child.args) == null ? void 0 : _b.value) || "undefined"
|
|
2055
|
+
).write("\n) {\n");
|
|
2054
2056
|
const body = this.#processBody(child);
|
|
2055
2057
|
if (body == null ? void 0 : body.renderBody) {
|
|
2056
2058
|
this.#writeChildren(child, body.renderBody);
|
|
@@ -2405,7 +2407,7 @@ const attrTags = ${varShared(
|
|
|
2405
2407
|
const alternates = IF_TAG_ALTERNATES.get(tag);
|
|
2406
2408
|
this.#writeComments(tag);
|
|
2407
2409
|
this.#extractor.write("((\n").copy(
|
|
2408
|
-
((_a = tag.args) == null ? void 0 : _a.value) || this.#getAttrValue(tag, ATTR_UNAMED2) || "undefined"
|
|
2410
|
+
this.#getRangeWithoutTrailingComma((_a = tag.args) == null ? void 0 : _a.value) || this.#getAttrValue(tag, ATTR_UNAMED2) || "undefined"
|
|
2409
2411
|
).write("\n) ? ");
|
|
2410
2412
|
this.#writeDynamicAttrTagBody(tag);
|
|
2411
2413
|
let needsAlternate = true;
|
|
@@ -2444,7 +2446,9 @@ const attrTags = ${varShared(
|
|
|
2444
2446
|
case "while": {
|
|
2445
2447
|
this.#writeComments(tag);
|
|
2446
2448
|
this.#extractor.write(`${varShared("mergeAttrTags")}((
|
|
2447
|
-
`).copy(
|
|
2449
|
+
`).copy(
|
|
2450
|
+
this.#getRangeWithoutTrailingComma((_c = tag.args) == null ? void 0 : _c.value) || "undefined"
|
|
2451
|
+
).write("\n) ? [");
|
|
2448
2452
|
this.#writeDynamicAttrTagBody(tag);
|
|
2449
2453
|
this.#extractor.write("] : [])");
|
|
2450
2454
|
break;
|
|
@@ -2632,7 +2636,9 @@ const attrTags = ${varShared(
|
|
|
2632
2636
|
switch (nextChild.nameText) {
|
|
2633
2637
|
case "else-if": {
|
|
2634
2638
|
const alternate = {
|
|
2635
|
-
condition:
|
|
2639
|
+
condition: this.#getRangeWithoutTrailingComma(
|
|
2640
|
+
(_a = nextChild.args) == null ? void 0 : _a.value
|
|
2641
|
+
) || this.#getAttrValue(nextChild, ATTR_UNAMED2),
|
|
2636
2642
|
node: nextChild
|
|
2637
2643
|
};
|
|
2638
2644
|
hasDynamicAttrTags ||= nextChild.hasAttrTags;
|
|
@@ -2732,6 +2738,22 @@ const attrTags = ${varShared(
|
|
|
2732
2738
|
}
|
|
2733
2739
|
}
|
|
2734
2740
|
}
|
|
2741
|
+
#getRangeWithoutTrailingComma(range) {
|
|
2742
|
+
if (!range)
|
|
2743
|
+
return void 0;
|
|
2744
|
+
const { start } = range;
|
|
2745
|
+
let end = range.end - 1;
|
|
2746
|
+
while (end >= start) {
|
|
2747
|
+
if (isWhitespaceCode(this.#code.charCodeAt(end))) {
|
|
2748
|
+
end--;
|
|
2749
|
+
} else if (this.#code.charAt(end) === ",") {
|
|
2750
|
+
return { start, end };
|
|
2751
|
+
} else {
|
|
2752
|
+
break;
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
return range;
|
|
2756
|
+
}
|
|
2735
2757
|
#isEmptyText(text) {
|
|
2736
2758
|
let pos = text.start;
|
|
2737
2759
|
while (pos < text.end) {
|
package/dist/util/project.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export declare function getCompiler(dir?: string): typeof defaultCompiler;
|
|
|
25
25
|
export declare function getCache(dir?: string): Map<any, any>;
|
|
26
26
|
export declare function getConfig(dir?: string): Omit<{
|
|
27
27
|
output?: "source" | "html" | "dom" | "hydrate" | "migrate" | undefined;
|
|
28
|
+
errorRecovery?: boolean | undefined;
|
|
29
|
+
applyFixes?: Map<number, unknown> | undefined;
|
|
28
30
|
stripTypes?: boolean | undefined;
|
|
29
31
|
runtimeId?: string | null | undefined;
|
|
30
32
|
ast?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.7",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@babel/helper-validator-identifier": "^7.
|
|
8
|
-
"@babel/parser": "^7.
|
|
9
|
-
"@marko/compiler": "5.
|
|
10
|
-
"@marko/translator-default": "5.
|
|
11
|
-
"htmljs-parser": "^5.
|
|
7
|
+
"@babel/helper-validator-identifier": "^7.22.5",
|
|
8
|
+
"@babel/parser": "^7.22.5",
|
|
9
|
+
"@marko/compiler": "5.28.4",
|
|
10
|
+
"@marko/translator-default": "5.26.4",
|
|
11
|
+
"htmljs-parser": "^5.5.0",
|
|
12
12
|
"relative-import-path": "^1.0.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@babel/code-frame": "^7.
|
|
16
|
-
"@marko/compiler": "^5.
|
|
15
|
+
"@babel/code-frame": "^7.22.5",
|
|
16
|
+
"@marko/compiler": "^5.28.3",
|
|
17
17
|
"@types/babel__code-frame": "^7.0.3",
|
|
18
18
|
"@types/babel__helper-validator-identifier": "^7.15.0",
|
|
19
19
|
"@typescript/vfs": "^1.4.0",
|
|
20
|
-
"marko": "^5.
|
|
20
|
+
"marko": "^5.26.4",
|
|
21
21
|
"mitata": "^0.1.6",
|
|
22
22
|
"tsx": "^3.12.7"
|
|
23
23
|
},
|