@statorjs/language-server 0.1.7 → 0.1.9
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/server.cjs +99 -2
- package/package.json +2 -2
package/dist/server.cjs
CHANGED
|
@@ -45546,11 +45546,108 @@ function buildServerTsx(regions) {
|
|
|
45546
45546
|
`;
|
|
45547
45547
|
}
|
|
45548
45548
|
code += " return (<>";
|
|
45549
|
-
|
|
45550
|
-
code += tpl;
|
|
45549
|
+
code = appendTemplateTsx(code, mappings, tpl, tplOffset);
|
|
45551
45550
|
code += "</>);\n}\n";
|
|
45552
45551
|
return { lang: "tsx", code, mappings };
|
|
45553
45552
|
}
|
|
45553
|
+
var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
45554
|
+
"area",
|
|
45555
|
+
"base",
|
|
45556
|
+
"br",
|
|
45557
|
+
"col",
|
|
45558
|
+
"embed",
|
|
45559
|
+
"hr",
|
|
45560
|
+
"img",
|
|
45561
|
+
"input",
|
|
45562
|
+
"link",
|
|
45563
|
+
"meta",
|
|
45564
|
+
"source",
|
|
45565
|
+
"track",
|
|
45566
|
+
"wbr"
|
|
45567
|
+
]);
|
|
45568
|
+
function appendTemplateTsx(code, mappings, tpl, tplOffset) {
|
|
45569
|
+
let out = code;
|
|
45570
|
+
let i = 0;
|
|
45571
|
+
let runStart = 0;
|
|
45572
|
+
const flush = (end) => {
|
|
45573
|
+
if (end > runStart) {
|
|
45574
|
+
push(mappings, tplOffset + runStart, out.length, end - runStart);
|
|
45575
|
+
out += tpl.slice(runStart, end);
|
|
45576
|
+
}
|
|
45577
|
+
};
|
|
45578
|
+
while (i < tpl.length) {
|
|
45579
|
+
if (tpl.startsWith("<!--", i)) {
|
|
45580
|
+
flush(i);
|
|
45581
|
+
const end = tpl.indexOf("-->", i);
|
|
45582
|
+
i = end === -1 ? tpl.length : end + 3;
|
|
45583
|
+
runStart = i;
|
|
45584
|
+
continue;
|
|
45585
|
+
}
|
|
45586
|
+
if (/^<script\b/i.test(tpl.slice(i, i + 8))) {
|
|
45587
|
+
flush(i);
|
|
45588
|
+
const end = tpl.toLowerCase().indexOf("</script>", i);
|
|
45589
|
+
out += "<script />";
|
|
45590
|
+
i = end === -1 ? tpl.length : end + "</script>".length;
|
|
45591
|
+
runStart = i;
|
|
45592
|
+
continue;
|
|
45593
|
+
}
|
|
45594
|
+
if (tpl[i] === "{") {
|
|
45595
|
+
i = expressionEnd(tpl, i);
|
|
45596
|
+
continue;
|
|
45597
|
+
}
|
|
45598
|
+
if (tpl[i] === "<" && /[a-zA-Z]/.test(tpl[i + 1] ?? "")) {
|
|
45599
|
+
const tag = /^[a-zA-Z][\w-]*/.exec(tpl.slice(i + 1))[0];
|
|
45600
|
+
let j = i + 1 + tag.length;
|
|
45601
|
+
while (j < tpl.length) {
|
|
45602
|
+
const ch = tpl[j];
|
|
45603
|
+
if (ch === '"' || ch === "'") {
|
|
45604
|
+
const q = tpl.indexOf(ch, j + 1);
|
|
45605
|
+
j = q === -1 ? tpl.length : q + 1;
|
|
45606
|
+
continue;
|
|
45607
|
+
}
|
|
45608
|
+
if (ch === "{") {
|
|
45609
|
+
j = expressionEnd(tpl, j);
|
|
45610
|
+
continue;
|
|
45611
|
+
}
|
|
45612
|
+
if (ch === ">") break;
|
|
45613
|
+
j++;
|
|
45614
|
+
}
|
|
45615
|
+
if (VOID_TAGS.has(tag.toLowerCase()) && j < tpl.length) {
|
|
45616
|
+
let k = j - 1;
|
|
45617
|
+
while (k > i && /\s/.test(tpl[k])) k--;
|
|
45618
|
+
if (tpl[k] !== "/") {
|
|
45619
|
+
flush(j);
|
|
45620
|
+
out += " /";
|
|
45621
|
+
runStart = j;
|
|
45622
|
+
}
|
|
45623
|
+
}
|
|
45624
|
+
i = j + 1;
|
|
45625
|
+
continue;
|
|
45626
|
+
}
|
|
45627
|
+
i++;
|
|
45628
|
+
}
|
|
45629
|
+
flush(tpl.length);
|
|
45630
|
+
return out;
|
|
45631
|
+
}
|
|
45632
|
+
function expressionEnd(tpl, start) {
|
|
45633
|
+
let depth = 0;
|
|
45634
|
+
let quote = null;
|
|
45635
|
+
for (let i = start; i < tpl.length; i++) {
|
|
45636
|
+
const ch = tpl[i];
|
|
45637
|
+
if (quote !== null) {
|
|
45638
|
+
if (ch === "\\") i++;
|
|
45639
|
+
else if (ch === quote) quote = null;
|
|
45640
|
+
continue;
|
|
45641
|
+
}
|
|
45642
|
+
if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
45643
|
+
else if (ch === "{") depth++;
|
|
45644
|
+
else if (ch === "}") {
|
|
45645
|
+
depth--;
|
|
45646
|
+
if (depth === 0) return i + 1;
|
|
45647
|
+
}
|
|
45648
|
+
}
|
|
45649
|
+
return tpl.length;
|
|
45650
|
+
}
|
|
45554
45651
|
function splitFrontmatter(fm, fmOffset2) {
|
|
45555
45652
|
const hoisted = [];
|
|
45556
45653
|
const body = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statorjs/language-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Volar-based language server for .stator files.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"volar-service-typescript": "0.0.71",
|
|
34
34
|
"vscode-css-languageservice": "^6.3.0",
|
|
35
35
|
"vscode-uri": "^3.0.8",
|
|
36
|
-
"@statorjs/stator": "1.
|
|
36
|
+
"@statorjs/stator": "1.5.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"typescript": "^5.6.0"
|