@marko/language-server 1.0.5 → 1.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 +188 -368
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +180 -359
- package/dist/index.mjs.map +4 -4
- package/dist/ts-plugin/host.d.ts +4 -4
- package/dist/utils/file.d.ts +0 -2
- package/package.json +8 -7
- package/dist/utils/get-component-filename.d.ts +0 -1
- package/dist/utils/get-runtime-types.d.ts +0 -10
- package/dist/utils/get-script-lang.d.ts +0 -4
- package/dist/utils/project.d.ts +0 -11
package/dist/index.js
CHANGED
|
@@ -25,95 +25,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
// src/index.ts
|
|
26
26
|
var import_util2 = require("util");
|
|
27
27
|
var import_node = require("vscode-languageserver/node");
|
|
28
|
-
|
|
29
|
-
// src/utils/project.ts
|
|
30
|
-
var import_path = __toESM(require("path"));
|
|
31
|
-
var import_module = require("module");
|
|
32
|
-
var defaultCompiler = __toESM(require("@marko/compiler"));
|
|
33
|
-
var defaultTranslator = __toESM(require("@marko/translator-default"));
|
|
34
|
-
var ignoreErrors = (_err) => {
|
|
35
|
-
};
|
|
36
|
-
var projectsByDir = /* @__PURE__ */ new Map();
|
|
37
|
-
var projectsByCompiler = /* @__PURE__ */ new Map();
|
|
38
|
-
var defaultProject = {
|
|
39
|
-
cache: /* @__PURE__ */ new Map(),
|
|
40
|
-
compiler: defaultCompiler,
|
|
41
|
-
translator: defaultTranslator,
|
|
42
|
-
getLookup(dir) {
|
|
43
|
-
const key = `taglib:${dir}`;
|
|
44
|
-
let lookup = defaultProject.cache.get(key);
|
|
45
|
-
if (!lookup) {
|
|
46
|
-
defaultProject.cache.set(
|
|
47
|
-
key,
|
|
48
|
-
lookup = defaultCompiler.taglib.buildLookup(
|
|
49
|
-
dir,
|
|
50
|
-
defaultTranslator,
|
|
51
|
-
ignoreErrors
|
|
52
|
-
)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return lookup;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
defaultCompiler.configure({ translator: defaultTranslator });
|
|
59
|
-
function getMarkoProject(dir) {
|
|
60
|
-
if (!dir)
|
|
61
|
-
return defaultProject;
|
|
62
|
-
let project = projectsByDir.get(dir);
|
|
63
|
-
if (!project) {
|
|
64
|
-
project = loadProject(dir);
|
|
65
|
-
projectsByDir.set(dir, project);
|
|
66
|
-
}
|
|
67
|
-
return project;
|
|
68
|
-
}
|
|
69
|
-
function getMarkoProjects() {
|
|
70
|
-
return projectsByCompiler.values();
|
|
71
|
-
}
|
|
72
|
-
function clearMarkoProjectCaches() {
|
|
73
|
-
for (const project of getMarkoProjects()) {
|
|
74
|
-
project.cache.clear();
|
|
75
|
-
project.compiler.taglib.clearCaches();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function loadProject(dir) {
|
|
79
|
-
try {
|
|
80
|
-
const require2 = (0, import_module.createRequire)(dir);
|
|
81
|
-
const compilerConfigPath = require2.resolve("@marko/compiler/config");
|
|
82
|
-
const cachedProject = projectsByCompiler.get(compilerConfigPath);
|
|
83
|
-
if (cachedProject)
|
|
84
|
-
return cachedProject;
|
|
85
|
-
const compiler = require2(import_path.default.join(compilerConfigPath, ".."));
|
|
86
|
-
const translator = require2(interopDefault(require2(compilerConfigPath)).translator);
|
|
87
|
-
const project = {
|
|
88
|
-
cache: /* @__PURE__ */ new Map(),
|
|
89
|
-
compiler,
|
|
90
|
-
translator,
|
|
91
|
-
getLookup(dir2) {
|
|
92
|
-
const key = `taglib:${dir2}`;
|
|
93
|
-
let lookup = project.cache.get(key);
|
|
94
|
-
if (lookup === void 0) {
|
|
95
|
-
try {
|
|
96
|
-
lookup = compiler.taglib.buildLookup(dir2, translator, ignoreErrors);
|
|
97
|
-
} catch {
|
|
98
|
-
lookup = defaultProject.getLookup(dir2);
|
|
99
|
-
}
|
|
100
|
-
project.cache.set(key, lookup);
|
|
101
|
-
}
|
|
102
|
-
return lookup;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
projectsByCompiler.set(compilerConfigPath, project);
|
|
106
|
-
return project;
|
|
107
|
-
} catch {
|
|
108
|
-
return defaultProject;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function interopDefault(mod) {
|
|
112
|
-
return mod.default || mod;
|
|
113
|
-
}
|
|
28
|
+
var import_language_tools16 = require("@marko/language-tools");
|
|
114
29
|
|
|
115
30
|
// src/utils/file.ts
|
|
116
|
-
var
|
|
31
|
+
var import_path = __toESM(require("path"));
|
|
117
32
|
var import_language_tools = require("@marko/language-tools");
|
|
118
33
|
var import_vscode_uri = require("vscode-uri");
|
|
119
34
|
var processorCaches = /* @__PURE__ */ new WeakMap();
|
|
@@ -123,19 +38,17 @@ function getFSPath(doc) {
|
|
|
123
38
|
function getMarkoFile(doc) {
|
|
124
39
|
const { uri } = doc;
|
|
125
40
|
const { fsPath: filename, scheme } = import_vscode_uri.URI.parse(uri);
|
|
126
|
-
const dirname = filename &&
|
|
127
|
-
const
|
|
128
|
-
const cache = project.cache;
|
|
41
|
+
const dirname = filename && import_path.default.dirname(filename);
|
|
42
|
+
const cache = import_language_tools.Project.getCache(dirname);
|
|
129
43
|
let file = cache.get(doc);
|
|
130
44
|
if (!file) {
|
|
131
45
|
const { version } = doc;
|
|
132
46
|
const code = doc.getText();
|
|
133
47
|
const parsed = (0, import_language_tools.parse)(code, filename);
|
|
134
|
-
const lookup =
|
|
48
|
+
const lookup = import_language_tools.Project.getTagLookup(dirname);
|
|
135
49
|
cache.set(
|
|
136
50
|
doc,
|
|
137
51
|
file = {
|
|
138
|
-
project,
|
|
139
52
|
uri,
|
|
140
53
|
scheme,
|
|
141
54
|
version,
|
|
@@ -151,9 +64,8 @@ function getMarkoFile(doc) {
|
|
|
151
64
|
}
|
|
152
65
|
function clearMarkoCacheForFile(doc) {
|
|
153
66
|
const { fsPath: filename } = import_vscode_uri.URI.parse(doc.uri);
|
|
154
|
-
const dirname = filename &&
|
|
155
|
-
const
|
|
156
|
-
const cache = project.cache;
|
|
67
|
+
const dirname = filename && import_path.default.dirname(filename);
|
|
68
|
+
const cache = import_language_tools.Project.getCache(dirname);
|
|
157
69
|
cache.delete(doc);
|
|
158
70
|
}
|
|
159
71
|
function processDoc(doc, process2) {
|
|
@@ -481,7 +393,7 @@ function isExternalModule(file) {
|
|
|
481
393
|
}
|
|
482
394
|
|
|
483
395
|
// src/service/marko/complete/AttrValue.ts
|
|
484
|
-
var
|
|
396
|
+
var import_path2 = __toESM(require("path"));
|
|
485
397
|
var import_vscode_languageserver3 = require("vscode-languageserver");
|
|
486
398
|
|
|
487
399
|
// src/service/marko/util/is-document-link-attr.ts
|
|
@@ -591,7 +503,7 @@ async function AttrValue({
|
|
|
591
503
|
const resolved = resolveUrl(req, uri);
|
|
592
504
|
if (resolved) {
|
|
593
505
|
const result = [];
|
|
594
|
-
const curFile = req === "." ?
|
|
506
|
+
const curFile = req === "." ? import_path2.default.basename(uri) : void 0;
|
|
595
507
|
const replaceRange = parsed.locationAt({
|
|
596
508
|
start: start + segmentStart + 1,
|
|
597
509
|
end: start + rawValue.length
|
|
@@ -624,7 +536,7 @@ async function AttrValue({
|
|
|
624
536
|
var import_vscode_languageserver5 = require("vscode-languageserver");
|
|
625
537
|
|
|
626
538
|
// src/service/marko/util/get-tag-name-completion.ts
|
|
627
|
-
var
|
|
539
|
+
var import_path3 = __toESM(require("path"));
|
|
628
540
|
var import_vscode_languageserver4 = require("vscode-languageserver");
|
|
629
541
|
var import_vscode_uri3 = require("vscode-uri");
|
|
630
542
|
var deprecated = [import_vscode_languageserver4.CompletionItemTag.Deprecated];
|
|
@@ -647,7 +559,7 @@ function getTagNameCompletion({
|
|
|
647
559
|
kind: import_vscode_languageserver4.MarkupKind.Markdown,
|
|
648
560
|
value: tag.html ? `Built in [<${tag.name}>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/${tag.name}) HTML tag.` : isCoreTag ? `Core Marko <${tag.name}> tag.` : nodeModuleName ? `Custom Marko tag discovered from the ["${nodeModuleName}"](${fileURIForTag}) npm package.` : `Custom Marko tag discovered from:
|
|
649
561
|
|
|
650
|
-
[${importer ?
|
|
562
|
+
[${importer ? import_path3.default.relative(importer, fileForTag) : fileForTag}](${fileURIForTag})`
|
|
651
563
|
};
|
|
652
564
|
if (tag.description) {
|
|
653
565
|
documentation.value += `
|
|
@@ -833,32 +745,32 @@ var doComplete = async (doc, params) => {
|
|
|
833
745
|
};
|
|
834
746
|
|
|
835
747
|
// src/service/marko/validate.ts
|
|
836
|
-
var
|
|
748
|
+
var import_path4 = __toESM(require("path"));
|
|
749
|
+
var import_language_tools6 = require("@marko/language-tools");
|
|
837
750
|
var import_vscode_languageserver7 = require("vscode-languageserver");
|
|
838
751
|
var markoErrorRegExp = /^(.+?)\.marko(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
839
752
|
var doValidate = (doc) => {
|
|
840
753
|
const filename = getFSPath(doc);
|
|
841
754
|
const diagnostics = [];
|
|
842
|
-
const { compiler, translator, cache } = getMarkoProject(
|
|
843
|
-
filename && import_path5.default.dirname(filename)
|
|
844
|
-
);
|
|
845
755
|
try {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
756
|
+
import_language_tools6.Project.getCompiler(filename && import_path4.default.dirname(filename)).compileSync(
|
|
757
|
+
doc.getText(),
|
|
758
|
+
filename || "untitled.marko",
|
|
759
|
+
{
|
|
760
|
+
code: false,
|
|
761
|
+
output: "source",
|
|
762
|
+
sourceMaps: false,
|
|
763
|
+
babelConfig: {
|
|
764
|
+
caller: {
|
|
765
|
+
name: "@marko/language-server",
|
|
766
|
+
supportsStaticESM: true,
|
|
767
|
+
supportsDynamicImport: true,
|
|
768
|
+
supportsTopLevelAwait: true,
|
|
769
|
+
supportsExportNamespaceFrom: true
|
|
770
|
+
}
|
|
859
771
|
}
|
|
860
772
|
}
|
|
861
|
-
|
|
773
|
+
);
|
|
862
774
|
} catch (e) {
|
|
863
775
|
let match;
|
|
864
776
|
while (match = markoErrorRegExp.exec(e.message)) {
|
|
@@ -881,7 +793,7 @@ var doValidate = (doc) => {
|
|
|
881
793
|
};
|
|
882
794
|
|
|
883
795
|
// src/service/marko/hover/index.ts
|
|
884
|
-
var
|
|
796
|
+
var import_language_tools7 = require("@marko/language-tools");
|
|
885
797
|
|
|
886
798
|
// src/utils/constants.ts
|
|
887
799
|
var START_POSITION = {
|
|
@@ -925,7 +837,7 @@ var doHover = async (doc, params) => {
|
|
|
925
837
|
const file = getMarkoFile(doc);
|
|
926
838
|
const offset = doc.offsetAt(params.position);
|
|
927
839
|
const node = file.parsed.nodeAt(offset);
|
|
928
|
-
return await ((_a = handlers2[
|
|
840
|
+
return await ((_a = handlers2[import_language_tools7.NodeType[node.type]]) == null ? void 0 : _a.call(handlers2, {
|
|
929
841
|
file,
|
|
930
842
|
params,
|
|
931
843
|
offset,
|
|
@@ -934,12 +846,12 @@ var doHover = async (doc, params) => {
|
|
|
934
846
|
};
|
|
935
847
|
|
|
936
848
|
// src/service/marko/definition/index.ts
|
|
937
|
-
var
|
|
849
|
+
var import_language_tools10 = require("@marko/language-tools");
|
|
938
850
|
|
|
939
851
|
// src/service/marko/definition/AttrName.ts
|
|
940
852
|
var import_fs2 = __toESM(require("fs"));
|
|
941
853
|
var import_vscode_uri4 = require("vscode-uri");
|
|
942
|
-
var
|
|
854
|
+
var import_language_tools8 = require("@marko/language-tools");
|
|
943
855
|
|
|
944
856
|
// src/utils/regexp-builder.ts
|
|
945
857
|
function RegExpBuilder(strings, ...expressions) {
|
|
@@ -988,8 +900,8 @@ function AttrName2({
|
|
|
988
900
|
tagDefSource
|
|
989
901
|
);
|
|
990
902
|
if (match && match.index) {
|
|
991
|
-
range = (0,
|
|
992
|
-
(0,
|
|
903
|
+
range = (0, import_language_tools8.getLocation)(
|
|
904
|
+
(0, import_language_tools8.getLines)(tagDefSource),
|
|
993
905
|
match.index,
|
|
994
906
|
match.index + match[0].length
|
|
995
907
|
);
|
|
@@ -1007,9 +919,9 @@ function AttrName2({
|
|
|
1007
919
|
|
|
1008
920
|
// src/service/marko/definition/OpenTagName.ts
|
|
1009
921
|
var import_fs3 = __toESM(require("fs"));
|
|
1010
|
-
var
|
|
922
|
+
var import_path5 = __toESM(require("path"));
|
|
1011
923
|
var import_vscode_uri5 = require("vscode-uri");
|
|
1012
|
-
var
|
|
924
|
+
var import_language_tools9 = require("@marko/language-tools");
|
|
1013
925
|
function OpenTagName3({
|
|
1014
926
|
node,
|
|
1015
927
|
file: { parsed, lookup }
|
|
@@ -1017,9 +929,9 @@ function OpenTagName3({
|
|
|
1017
929
|
const tag = node.parent;
|
|
1018
930
|
let tagDef;
|
|
1019
931
|
let range = START_LOCATION;
|
|
1020
|
-
if (tag.type ===
|
|
932
|
+
if (tag.type === import_language_tools9.NodeType.AttrTag) {
|
|
1021
933
|
let parentTag = tag.owner;
|
|
1022
|
-
while ((parentTag == null ? void 0 : parentTag.type) ===
|
|
934
|
+
while ((parentTag == null ? void 0 : parentTag.type) === import_language_tools9.NodeType.AttrTag)
|
|
1023
935
|
parentTag = parentTag.owner;
|
|
1024
936
|
tagDef = parentTag && parentTag.nameText ? lookup.getTag(parentTag.nameText) : void 0;
|
|
1025
937
|
} else {
|
|
@@ -1029,7 +941,7 @@ function OpenTagName3({
|
|
|
1029
941
|
return;
|
|
1030
942
|
}
|
|
1031
943
|
const tagEntryFile = tagDef.template || tagDef.renderer || tagDef.filePath;
|
|
1032
|
-
if (!
|
|
944
|
+
if (!import_path5.default.isAbsolute(tagEntryFile)) {
|
|
1033
945
|
return;
|
|
1034
946
|
}
|
|
1035
947
|
if (/\/marko(?:-tag)?\.json$/.test(tagEntryFile)) {
|
|
@@ -1038,8 +950,8 @@ function OpenTagName3({
|
|
|
1038
950
|
tagDefSource
|
|
1039
951
|
);
|
|
1040
952
|
if (match && match.index) {
|
|
1041
|
-
range = (0,
|
|
1042
|
-
(0,
|
|
953
|
+
range = (0, import_language_tools9.getLocation)(
|
|
954
|
+
(0, import_language_tools9.getLines)(tagDefSource),
|
|
1043
955
|
match.index,
|
|
1044
956
|
match.index + match[0].length
|
|
1045
957
|
);
|
|
@@ -1065,7 +977,7 @@ var findDefinition = async (doc, params) => {
|
|
|
1065
977
|
const file = getMarkoFile(doc);
|
|
1066
978
|
const offset = doc.offsetAt(params.position);
|
|
1067
979
|
const node = file.parsed.nodeAt(offset);
|
|
1068
|
-
return await ((_a = handlers3[
|
|
980
|
+
return await ((_a = handlers3[import_language_tools10.NodeType[node.type]]) == null ? void 0 : _a.call(handlers3, {
|
|
1069
981
|
file,
|
|
1070
982
|
params,
|
|
1071
983
|
offset,
|
|
@@ -1074,7 +986,7 @@ var findDefinition = async (doc, params) => {
|
|
|
1074
986
|
};
|
|
1075
987
|
|
|
1076
988
|
// src/service/marko/document-links.ts
|
|
1077
|
-
var
|
|
989
|
+
var import_language_tools11 = require("@marko/language-tools");
|
|
1078
990
|
var importTagReg2 = /(['"])<((?:[^\1\\>]+|\\.)*)>?\1/g;
|
|
1079
991
|
var findDocumentLinks = async (doc) => {
|
|
1080
992
|
return processDoc(doc, extractDocumentLinks);
|
|
@@ -1093,14 +1005,14 @@ function extractDocumentLinks({
|
|
|
1093
1005
|
const { program, read } = parsed;
|
|
1094
1006
|
const visit = (node) => {
|
|
1095
1007
|
switch (node.type) {
|
|
1096
|
-
case
|
|
1008
|
+
case import_language_tools11.NodeType.AttrTag:
|
|
1097
1009
|
if (node.body) {
|
|
1098
1010
|
for (const child of node.body) {
|
|
1099
1011
|
visit(child);
|
|
1100
1012
|
}
|
|
1101
1013
|
}
|
|
1102
1014
|
break;
|
|
1103
|
-
case
|
|
1015
|
+
case import_language_tools11.NodeType.Tag:
|
|
1104
1016
|
if (node.attrs && node.nameText) {
|
|
1105
1017
|
for (const attr of node.attrs) {
|
|
1106
1018
|
if (isDocumentLinkAttr(code, node, attr)) {
|
|
@@ -1126,7 +1038,7 @@ function extractDocumentLinks({
|
|
|
1126
1038
|
}
|
|
1127
1039
|
};
|
|
1128
1040
|
for (const node of program.static) {
|
|
1129
|
-
if (node.type ===
|
|
1041
|
+
if (node.type === import_language_tools11.NodeType.Import) {
|
|
1130
1042
|
importTagReg2.lastIndex = 0;
|
|
1131
1043
|
const value = parsed.read(node);
|
|
1132
1044
|
const match = importTagReg2.exec(value);
|
|
@@ -1154,7 +1066,7 @@ function extractDocumentLinks({
|
|
|
1154
1066
|
|
|
1155
1067
|
// src/service/marko/document-symbols.ts
|
|
1156
1068
|
var import_vscode_languageserver8 = require("vscode-languageserver");
|
|
1157
|
-
var
|
|
1069
|
+
var import_language_tools12 = require("@marko/language-tools");
|
|
1158
1070
|
var findDocumentSymbols = async (doc) => processDoc(doc, extractDocumentSymbols);
|
|
1159
1071
|
function extractDocumentSymbols({
|
|
1160
1072
|
uri,
|
|
@@ -1170,10 +1082,10 @@ function extractDocumentSymbols({
|
|
|
1170
1082
|
const visit = (node) => {
|
|
1171
1083
|
var _a, _b;
|
|
1172
1084
|
switch (node.type) {
|
|
1173
|
-
case
|
|
1174
|
-
case
|
|
1085
|
+
case import_language_tools12.NodeType.Tag:
|
|
1086
|
+
case import_language_tools12.NodeType.AttrTag:
|
|
1175
1087
|
symbols.push({
|
|
1176
|
-
name: (node.type ===
|
|
1088
|
+
name: (node.type === import_language_tools12.NodeType.AttrTag ? (_a = node.nameText) == null ? void 0 : _a.slice(node.nameText.indexOf("@")) : node.nameText) || "<${...}>",
|
|
1177
1089
|
kind: node.nameText && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html) && import_vscode_languageserver8.SymbolKind.Property || import_vscode_languageserver8.SymbolKind.Class,
|
|
1178
1090
|
location: {
|
|
1179
1091
|
uri,
|
|
@@ -1241,7 +1153,7 @@ var marko_default = {
|
|
|
1241
1153
|
};
|
|
1242
1154
|
|
|
1243
1155
|
// src/service/script/index.ts
|
|
1244
|
-
var
|
|
1156
|
+
var import_path7 = __toESM(require("path"));
|
|
1245
1157
|
var import_relative_import_path = require("relative-import-path");
|
|
1246
1158
|
var import_tsserverlibrary = __toESM(require("typescript/lib/tsserverlibrary"));
|
|
1247
1159
|
var import_vscode_languageserver10 = require("vscode-languageserver");
|
|
@@ -1250,209 +1162,105 @@ var prettier2 = __toESM(require("prettier"));
|
|
|
1250
1162
|
var import_language_tools14 = require("@marko/language-tools");
|
|
1251
1163
|
|
|
1252
1164
|
// src/ts-plugin/host.ts
|
|
1253
|
-
var
|
|
1165
|
+
var import_path6 = __toESM(require("path"));
|
|
1254
1166
|
var import_language_tools13 = require("@marko/language-tools");
|
|
1255
|
-
|
|
1256
|
-
// src/utils/get-runtime-types.ts
|
|
1257
|
-
var import_path7 = __toESM(require("path"));
|
|
1258
|
-
var internalTypesFile = import_path7.default.join(__dirname, "marko.internal.d.ts");
|
|
1259
|
-
var defaultMarkoTypesFile = import_path7.default.join(__dirname, "marko.runtime.d.ts");
|
|
1260
|
-
function getProjectTypeLibs(rootDir, project, ts2, host) {
|
|
1261
|
-
let cached = project.cache.get(getProjectTypeLibs);
|
|
1262
|
-
if (cached === void 0) {
|
|
1263
|
-
const markoRunGeneratedTypesFile = import_path7.default.join(
|
|
1264
|
-
rootDir,
|
|
1265
|
-
".marko-run/routes.d.ts"
|
|
1266
|
-
);
|
|
1267
|
-
const resolveFromFile = import_path7.default.join(host.getCurrentDirectory(), "_.d.ts");
|
|
1268
|
-
const compilerOptions = host.getCompilationSettings();
|
|
1269
|
-
const { resolvedTypeReferenceDirective: resolvedMarkoTypes } = ts2.resolveTypeReferenceDirective(
|
|
1270
|
-
project.translator.runtimeTypes || "marko",
|
|
1271
|
-
resolveFromFile,
|
|
1272
|
-
compilerOptions,
|
|
1273
|
-
host
|
|
1274
|
-
);
|
|
1275
|
-
const { resolvedTypeReferenceDirective: resolvedMarkoRunTypes } = ts2.resolveTypeReferenceDirective(
|
|
1276
|
-
"@marko/run",
|
|
1277
|
-
resolveFromFile,
|
|
1278
|
-
compilerOptions,
|
|
1279
|
-
host
|
|
1280
|
-
);
|
|
1281
|
-
const markoTypesFile = (resolvedMarkoTypes == null ? void 0 : resolvedMarkoTypes.resolvedFileName) || defaultMarkoTypesFile;
|
|
1282
|
-
const markoRunTypesFile = resolvedMarkoRunTypes == null ? void 0 : resolvedMarkoRunTypes.resolvedFileName;
|
|
1283
|
-
cached = {
|
|
1284
|
-
internalTypesFile,
|
|
1285
|
-
markoTypesFile,
|
|
1286
|
-
markoTypesCode: host.readFile(markoTypesFile, "utf-8") || "",
|
|
1287
|
-
markoRunTypesFile,
|
|
1288
|
-
markoRunGeneratedTypesFile: host.fileExists(markoRunGeneratedTypesFile) ? markoRunGeneratedTypesFile : void 0
|
|
1289
|
-
};
|
|
1290
|
-
project.cache.set(getProjectTypeLibs, cached);
|
|
1291
|
-
}
|
|
1292
|
-
return cached;
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
// src/utils/get-script-lang.ts
|
|
1296
|
-
var import_language_tools12 = require("@marko/language-tools");
|
|
1297
|
-
function getScriptLang(filename, ts2, host, projectScriptLang) {
|
|
1298
|
-
const configPath = ts2.findConfigFile(
|
|
1299
|
-
filename,
|
|
1300
|
-
host.fileExists.bind(host),
|
|
1301
|
-
"marko.json"
|
|
1302
|
-
);
|
|
1303
|
-
if (configPath) {
|
|
1304
|
-
try {
|
|
1305
|
-
const markoConfig = JSON.parse(
|
|
1306
|
-
host.readFile(configPath, "utf-8") || "{}"
|
|
1307
|
-
);
|
|
1308
|
-
const scriptLang = markoConfig["script-lang"] || markoConfig.scriptLang;
|
|
1309
|
-
if (scriptLang !== void 0) {
|
|
1310
|
-
return scriptLang === import_language_tools12.ScriptLang.ts ? import_language_tools12.ScriptLang.ts : import_language_tools12.ScriptLang.js;
|
|
1311
|
-
}
|
|
1312
|
-
} catch {
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return /[/\\]node_modules[/\\]/.test(filename) ? import_language_tools12.ScriptLang.js : projectScriptLang;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
// src/utils/get-component-filename.ts
|
|
1319
|
-
var import_fs4 = __toESM(require("fs"));
|
|
1320
|
-
var import_path8 = __toESM(require("path"));
|
|
1321
|
-
function getComponentFilename(from) {
|
|
1322
|
-
const dir = import_path8.default.dirname(from);
|
|
1323
|
-
const nameNoExt = import_path8.default.basename(from, ".marko");
|
|
1324
|
-
const isEntry = nameNoExt === "index";
|
|
1325
|
-
const componentFull = `${nameNoExt}.component.`;
|
|
1326
|
-
const componentBrowserFull = `${nameNoExt}.component-browser.`;
|
|
1327
|
-
const componentPartial = isEntry ? "component." : void 0;
|
|
1328
|
-
const componentBrowserPartial = isEntry ? "component-browser." : void 0;
|
|
1329
|
-
for (const entry of tryReaddirSync(dir)) {
|
|
1330
|
-
if (entry !== from && (isEntry && entry.startsWith(componentBrowserPartial) || entry.startsWith(componentPartial)) || entry.startsWith(componentBrowserFull) || entry.startsWith(componentFull)) {
|
|
1331
|
-
return import_path8.default.join(dir, entry);
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
function tryReaddirSync(dir) {
|
|
1336
|
-
try {
|
|
1337
|
-
return import_fs4.default.readdirSync(dir);
|
|
1338
|
-
} catch {
|
|
1339
|
-
return [];
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
// src/ts-plugin/host.ts
|
|
1344
|
-
var markoExt = ".marko";
|
|
1345
|
-
var markoExtReg = /\.marko$/;
|
|
1346
|
-
var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
1347
1167
|
var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
|
|
1348
|
-
|
|
1168
|
+
var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
1169
|
+
function patch(ts2, configFile, extractCache2, resolutionCache, host, ps) {
|
|
1349
1170
|
var _a, _b, _c;
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
projectTypeLibs.markoTypesFile
|
|
1360
|
-
];
|
|
1361
|
-
if (projectTypeLibs.markoRunTypesFile) {
|
|
1362
|
-
projectTypeLibsFiles.push(projectTypeLibs.markoRunTypesFile);
|
|
1363
|
-
}
|
|
1364
|
-
if (projectTypeLibs.markoRunGeneratedTypesFile) {
|
|
1365
|
-
projectTypeLibsFiles.push(projectTypeLibs.markoRunGeneratedTypesFile);
|
|
1366
|
-
}
|
|
1367
|
-
const isMarkoTSFile = (fileName) => getScriptLang(fileName, ts2, host, scriptLang) === import_language_tools13.ScriptLang.ts;
|
|
1171
|
+
const processors = import_language_tools13.Processors.create({
|
|
1172
|
+
ts: ts2,
|
|
1173
|
+
host,
|
|
1174
|
+
configFile
|
|
1175
|
+
});
|
|
1176
|
+
const rootNames = Object.values(processors).map((processor) => {
|
|
1177
|
+
var _a2;
|
|
1178
|
+
return (_a2 = processor.getRootNames) == null ? void 0 : _a2.call(processor);
|
|
1179
|
+
}).flat().filter(Boolean);
|
|
1368
1180
|
const getScriptFileNames = host.getScriptFileNames.bind(host);
|
|
1369
1181
|
host.getScriptFileNames = () => [
|
|
1370
|
-
...new Set(
|
|
1182
|
+
...new Set(rootNames.concat(getScriptFileNames()))
|
|
1371
1183
|
];
|
|
1372
1184
|
const getScriptKind = (_a = host.getScriptKind) == null ? void 0 : _a.bind(host);
|
|
1373
1185
|
if (getScriptKind) {
|
|
1374
1186
|
host.getScriptKind = (fileName) => {
|
|
1375
|
-
|
|
1187
|
+
const processor = getProcessor(fileName);
|
|
1188
|
+
if (processor)
|
|
1189
|
+
return processor.getScriptKind(fileName);
|
|
1190
|
+
return getScriptKind(fileName);
|
|
1376
1191
|
};
|
|
1377
1192
|
}
|
|
1378
1193
|
const getScriptSnapshot = host.getScriptSnapshot.bind(host);
|
|
1379
|
-
host.getScriptSnapshot = (
|
|
1380
|
-
|
|
1381
|
-
|
|
1194
|
+
host.getScriptSnapshot = (fileName) => {
|
|
1195
|
+
const processor = getProcessor(fileName);
|
|
1196
|
+
if (processor) {
|
|
1197
|
+
let cached = extractCache2.get(fileName);
|
|
1382
1198
|
if (!cached) {
|
|
1383
|
-
const code = host.readFile(
|
|
1384
|
-
const dir = import_path9.default.dirname(filename);
|
|
1199
|
+
const code = host.readFile(fileName, "utf-8") || "";
|
|
1385
1200
|
try {
|
|
1386
|
-
|
|
1387
|
-
cached = (0, import_language_tools13.extractScript)({
|
|
1388
|
-
ts: ts2,
|
|
1389
|
-
parsed: (0, import_language_tools13.parse)(code, filename),
|
|
1390
|
-
lookup: markoProject.getLookup(dir),
|
|
1391
|
-
scriptLang: getScriptLang(filename, ts2, host, scriptLang),
|
|
1392
|
-
runtimeTypesCode: projectTypeLibs.markoTypesCode,
|
|
1393
|
-
componentFilename: getComponentFilename(filename)
|
|
1394
|
-
});
|
|
1201
|
+
cached = processor.extract(fileName, code);
|
|
1395
1202
|
cached.snapshot = ts2.ScriptSnapshot.fromString(cached.toString());
|
|
1396
1203
|
} catch {
|
|
1397
1204
|
cached = { snapshot: ts2.ScriptSnapshot.fromString("") };
|
|
1398
1205
|
}
|
|
1399
1206
|
ps == null ? void 0 : ps.getOrCreateScriptInfoForNormalizedPath(
|
|
1400
|
-
|
|
1207
|
+
fileName,
|
|
1401
1208
|
false,
|
|
1402
1209
|
void 0,
|
|
1403
1210
|
ts2.ScriptKind.Deferred,
|
|
1404
1211
|
false,
|
|
1405
1212
|
host
|
|
1406
1213
|
);
|
|
1407
|
-
|
|
1214
|
+
extractCache2.set(fileName, cached);
|
|
1408
1215
|
}
|
|
1409
1216
|
return cached.snapshot;
|
|
1410
1217
|
}
|
|
1411
|
-
return getScriptSnapshot(
|
|
1218
|
+
return getScriptSnapshot(fileName);
|
|
1412
1219
|
};
|
|
1413
1220
|
if (host.getProjectVersion) {
|
|
1414
1221
|
const getScriptVersion = host.getScriptVersion.bind(host);
|
|
1415
|
-
host.getScriptVersion = (
|
|
1416
|
-
|
|
1222
|
+
host.getScriptVersion = (fileName) => {
|
|
1223
|
+
const processor = getProcessor(fileName);
|
|
1224
|
+
if (processor)
|
|
1417
1225
|
return host.getProjectVersion();
|
|
1418
|
-
|
|
1419
|
-
return getScriptVersion(filename);
|
|
1226
|
+
return getScriptVersion(fileName);
|
|
1420
1227
|
};
|
|
1421
1228
|
}
|
|
1422
1229
|
const readDirectory2 = (_b = host.readDirectory) == null ? void 0 : _b.bind(host);
|
|
1423
1230
|
if (readDirectory2) {
|
|
1424
|
-
host.readDirectory = (
|
|
1231
|
+
host.readDirectory = (path8, extensions, exclude, include, depth) => {
|
|
1425
1232
|
return readDirectory2(
|
|
1426
|
-
|
|
1427
|
-
extensions == null ? void 0 : extensions.concat(
|
|
1233
|
+
path8,
|
|
1234
|
+
extensions == null ? void 0 : extensions.concat(import_language_tools13.Processors.extensions),
|
|
1428
1235
|
exclude,
|
|
1429
1236
|
include,
|
|
1430
1237
|
depth
|
|
1431
1238
|
);
|
|
1432
1239
|
};
|
|
1433
1240
|
}
|
|
1434
|
-
const
|
|
1435
|
-
if (
|
|
1436
|
-
host.
|
|
1437
|
-
let
|
|
1241
|
+
const resolveModuleNameLiterals = (_c = host.resolveModuleNameLiterals) == null ? void 0 : _c.bind(host);
|
|
1242
|
+
if (resolveModuleNameLiterals) {
|
|
1243
|
+
host.resolveModuleNameLiterals = (moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) => {
|
|
1244
|
+
let normalModuleLiterals = moduleLiterals;
|
|
1438
1245
|
let resolvedModules;
|
|
1439
|
-
for (let i = 0; i <
|
|
1440
|
-
const moduleName =
|
|
1441
|
-
const
|
|
1442
|
-
if (
|
|
1246
|
+
for (let i = 0; i < moduleLiterals.length; i++) {
|
|
1247
|
+
const moduleName = moduleLiterals[i].text;
|
|
1248
|
+
const processor = moduleName[0] !== "*" ? getProcessor(moduleName) : void 0;
|
|
1249
|
+
if (processor) {
|
|
1443
1250
|
let resolvedFileName;
|
|
1444
1251
|
if (fsPathReg.test(moduleName)) {
|
|
1445
|
-
resolvedFileName =
|
|
1252
|
+
resolvedFileName = import_path6.default.resolve(containingFile, "..", moduleName);
|
|
1446
1253
|
} else {
|
|
1447
1254
|
const [, nodeModuleName, relativeModulePath] = modulePartsReg.exec(moduleName);
|
|
1448
|
-
const { resolvedModule } = ts2.
|
|
1255
|
+
const { resolvedModule } = ts2.bundlerModuleNameResolver(
|
|
1449
1256
|
`${nodeModuleName}/package.json`,
|
|
1450
1257
|
containingFile,
|
|
1451
1258
|
options,
|
|
1452
|
-
host
|
|
1259
|
+
host,
|
|
1260
|
+
resolutionCache
|
|
1453
1261
|
);
|
|
1454
1262
|
if (resolvedModule) {
|
|
1455
|
-
resolvedFileName =
|
|
1263
|
+
resolvedFileName = import_path6.default.join(
|
|
1456
1264
|
resolvedModule.resolvedFileName,
|
|
1457
1265
|
"..",
|
|
1458
1266
|
relativeModulePath
|
|
@@ -1461,47 +1269,54 @@ function patch(ts2, scriptLang, cache, host, ps) {
|
|
|
1461
1269
|
}
|
|
1462
1270
|
if (!resolvedModules) {
|
|
1463
1271
|
resolvedModules = [];
|
|
1464
|
-
|
|
1272
|
+
normalModuleLiterals = [];
|
|
1465
1273
|
for (let j = 0; j < i; j++) {
|
|
1466
1274
|
resolvedModules.push(void 0);
|
|
1467
|
-
|
|
1275
|
+
normalModuleLiterals.push(moduleLiterals[j]);
|
|
1468
1276
|
}
|
|
1469
1277
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1278
|
+
if (resolvedFileName) {
|
|
1279
|
+
if ((0, import_language_tools13.isDefinitionFile)(resolvedFileName)) {
|
|
1280
|
+
if (!host.fileExists(resolvedFileName)) {
|
|
1281
|
+
resolvedFileName = void 0;
|
|
1282
|
+
}
|
|
1283
|
+
} else {
|
|
1284
|
+
const ext = (0, import_language_tools13.getExt)(resolvedFileName);
|
|
1285
|
+
const definitionFile = `${resolvedFileName.slice(
|
|
1286
|
+
0,
|
|
1287
|
+
-ext.length
|
|
1288
|
+
)}.d${ext}`;
|
|
1289
|
+
if (host.fileExists(definitionFile)) {
|
|
1290
|
+
resolvedFileName = definitionFile;
|
|
1291
|
+
} else if (!host.fileExists(resolvedFileName)) {
|
|
1292
|
+
resolvedFileName = void 0;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
resolvedModules.push({
|
|
1297
|
+
resolvedModule: resolvedFileName ? {
|
|
1472
1298
|
resolvedFileName,
|
|
1473
|
-
extension:
|
|
1299
|
+
extension: processor.getScriptExtension(resolvedFileName),
|
|
1474
1300
|
isExternalLibraryImport: false
|
|
1475
|
-
} :
|
|
1476
|
-
);
|
|
1301
|
+
} : void 0
|
|
1302
|
+
});
|
|
1477
1303
|
} else if (resolvedModules) {
|
|
1478
1304
|
resolvedModules.push(void 0);
|
|
1479
1305
|
}
|
|
1480
1306
|
}
|
|
1481
|
-
const normalResolvedModules =
|
|
1482
|
-
|
|
1307
|
+
const normalResolvedModules = normalModuleLiterals.length ? resolveModuleNameLiterals(
|
|
1308
|
+
normalModuleLiterals,
|
|
1483
1309
|
containingFile,
|
|
1484
|
-
reusedNames,
|
|
1485
1310
|
redirectedReference,
|
|
1486
1311
|
options,
|
|
1487
|
-
|
|
1312
|
+
containingSourceFile,
|
|
1313
|
+
reusedNames
|
|
1488
1314
|
) : void 0;
|
|
1489
1315
|
if (resolvedModules) {
|
|
1490
1316
|
if (normalResolvedModules) {
|
|
1491
1317
|
for (let i = 0, j = 0; i < resolvedModules.length; i++) {
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
resolvedModules[i] = normalResolvedModules[j++];
|
|
1495
|
-
break;
|
|
1496
|
-
case null:
|
|
1497
|
-
resolvedModules[i] = void 0;
|
|
1498
|
-
break;
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
} else {
|
|
1502
|
-
for (let i = resolvedModules.length; i--; ) {
|
|
1503
|
-
if (resolvedModules[i] === null) {
|
|
1504
|
-
resolvedModules[i] = void 0;
|
|
1318
|
+
if (!resolvedModules[i]) {
|
|
1319
|
+
resolvedModules[i] = normalResolvedModules[j++];
|
|
1505
1320
|
}
|
|
1506
1321
|
}
|
|
1507
1322
|
}
|
|
@@ -1512,6 +1327,10 @@ function patch(ts2, scriptLang, cache, host, ps) {
|
|
|
1512
1327
|
};
|
|
1513
1328
|
}
|
|
1514
1329
|
return host;
|
|
1330
|
+
function getProcessor(fileName) {
|
|
1331
|
+
const ext = (0, import_language_tools13.getExt)(fileName);
|
|
1332
|
+
return ext ? processors[ext] : void 0;
|
|
1333
|
+
}
|
|
1515
1334
|
}
|
|
1516
1335
|
|
|
1517
1336
|
// src/service/script/index.ts
|
|
@@ -1527,12 +1346,13 @@ var colorModifierReg = /\bcolor\b/;
|
|
|
1527
1346
|
var localInternalsPrefix = "__marko_internal_";
|
|
1528
1347
|
var requiredTSCompilerOptions = {
|
|
1529
1348
|
module: import_tsserverlibrary.default.ModuleKind.ESNext,
|
|
1530
|
-
moduleResolution: import_tsserverlibrary.default.ModuleResolutionKind.
|
|
1349
|
+
moduleResolution: import_tsserverlibrary.default.ModuleResolutionKind.Bundler,
|
|
1531
1350
|
noEmit: true,
|
|
1532
1351
|
allowJs: true,
|
|
1533
1352
|
composite: false,
|
|
1534
1353
|
declaration: false,
|
|
1535
1354
|
skipLibCheck: true,
|
|
1355
|
+
importHelpers: false,
|
|
1536
1356
|
isolatedModules: true,
|
|
1537
1357
|
resolveJsonModule: true,
|
|
1538
1358
|
skipDefaultLibCheck: true,
|
|
@@ -1562,13 +1382,13 @@ var ScriptService = {
|
|
|
1562
1382
|
const filename = getFSPath(doc);
|
|
1563
1383
|
if (!filename)
|
|
1564
1384
|
return;
|
|
1565
|
-
const
|
|
1566
|
-
const extracted = processScript(doc,
|
|
1567
|
-
const lang = getScriptLang(
|
|
1385
|
+
const tsProject = getTSProject(filename);
|
|
1386
|
+
const extracted = processScript(doc, tsProject);
|
|
1387
|
+
const lang = import_language_tools14.Project.getScriptLang(
|
|
1568
1388
|
filename,
|
|
1389
|
+
tsProject.markoScriptLang,
|
|
1569
1390
|
import_tsserverlibrary.default,
|
|
1570
|
-
|
|
1571
|
-
project.markoScriptLang
|
|
1391
|
+
tsProject.host
|
|
1572
1392
|
);
|
|
1573
1393
|
const generated = extracted.toString();
|
|
1574
1394
|
const content = (() => {
|
|
@@ -1637,7 +1457,7 @@ var ScriptService = {
|
|
|
1637
1457
|
let source = completion.source;
|
|
1638
1458
|
if (source && completion.hasAction) {
|
|
1639
1459
|
if (source[0] === ".") {
|
|
1640
|
-
source =
|
|
1460
|
+
source = import_path7.default.resolve(fileName, "..", source);
|
|
1641
1461
|
}
|
|
1642
1462
|
detail = (0, import_relative_import_path.relativeImportPath)(fileName, source);
|
|
1643
1463
|
sortText = `\uFFFF${sortText}`;
|
|
@@ -1941,26 +1761,17 @@ ${documentation}`;
|
|
|
1941
1761
|
}
|
|
1942
1762
|
};
|
|
1943
1763
|
function processScript(doc, tsProject) {
|
|
1944
|
-
return processDoc(
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
tsProject.rootDir,
|
|
1956
|
-
markoProject,
|
|
1957
|
-
import_tsserverlibrary.default,
|
|
1958
|
-
host
|
|
1959
|
-
)) == null ? void 0 : _a.markoTypesCode,
|
|
1960
|
-
componentFilename: getComponentFilename(filename)
|
|
1961
|
-
});
|
|
1962
|
-
}
|
|
1963
|
-
);
|
|
1764
|
+
return processDoc(doc, ({ filename, parsed, lookup }) => {
|
|
1765
|
+
var _a;
|
|
1766
|
+
const { host, markoScriptLang } = tsProject;
|
|
1767
|
+
return (0, import_language_tools14.extractScript)({
|
|
1768
|
+
ts: import_tsserverlibrary.default,
|
|
1769
|
+
parsed,
|
|
1770
|
+
lookup,
|
|
1771
|
+
scriptLang: import_language_tools14.Project.getScriptLang(filename, markoScriptLang, import_tsserverlibrary.default, host),
|
|
1772
|
+
runtimeTypesCode: (_a = import_language_tools14.Project.getTypeLibs(tsProject.rootDir, import_tsserverlibrary.default, host)) == null ? void 0 : _a.markoTypesCode
|
|
1773
|
+
});
|
|
1774
|
+
});
|
|
1964
1775
|
}
|
|
1965
1776
|
function getInsertModuleStatementOffset(parsed) {
|
|
1966
1777
|
const { program } = parsed;
|
|
@@ -2011,27 +1822,27 @@ function docLocationAtTextSpan(doc, { start, length }) {
|
|
|
2011
1822
|
}
|
|
2012
1823
|
function getTSProject(docFsPath) {
|
|
2013
1824
|
var _a;
|
|
2014
|
-
let
|
|
1825
|
+
let configFile;
|
|
2015
1826
|
let markoScriptLang = import_language_tools14.ScriptLang.js;
|
|
2016
1827
|
if (docFsPath) {
|
|
2017
|
-
|
|
1828
|
+
configFile = import_tsserverlibrary.default.findConfigFile(
|
|
2018
1829
|
docFsPath,
|
|
2019
1830
|
import_tsserverlibrary.default.sys.fileExists,
|
|
2020
1831
|
"tsconfig.json"
|
|
2021
1832
|
);
|
|
2022
|
-
if (
|
|
1833
|
+
if (configFile) {
|
|
2023
1834
|
markoScriptLang = import_language_tools14.ScriptLang.ts;
|
|
2024
1835
|
} else {
|
|
2025
|
-
|
|
1836
|
+
configFile = import_tsserverlibrary.default.findConfigFile(
|
|
2026
1837
|
docFsPath,
|
|
2027
1838
|
import_tsserverlibrary.default.sys.fileExists,
|
|
2028
1839
|
"jsconfig.json"
|
|
2029
1840
|
);
|
|
2030
1841
|
}
|
|
2031
1842
|
}
|
|
2032
|
-
const rootDir =
|
|
2033
|
-
const
|
|
2034
|
-
let projectCache =
|
|
1843
|
+
const rootDir = configFile && import_path7.default.dirname(configFile) || process.cwd();
|
|
1844
|
+
const cache = import_language_tools14.Project.getCache(configFile && rootDir);
|
|
1845
|
+
let projectCache = cache.get(getTSProject);
|
|
2035
1846
|
let cached;
|
|
2036
1847
|
if (projectCache) {
|
|
2037
1848
|
cached = projectCache.get(rootDir);
|
|
@@ -2039,14 +1850,14 @@ function getTSProject(docFsPath) {
|
|
|
2039
1850
|
return cached;
|
|
2040
1851
|
} else {
|
|
2041
1852
|
projectCache = /* @__PURE__ */ new Map();
|
|
2042
|
-
|
|
1853
|
+
cache.set(getTSProject, projectCache);
|
|
2043
1854
|
}
|
|
2044
1855
|
const { fileNames, options, projectReferences } = import_tsserverlibrary.default.parseJsonConfigFileContent(
|
|
2045
|
-
|
|
1856
|
+
configFile && import_tsserverlibrary.default.readConfigFile(configFile, import_tsserverlibrary.default.sys.readFile).config || defaultTSConfig,
|
|
2046
1857
|
import_tsserverlibrary.default.sys,
|
|
2047
1858
|
rootDir,
|
|
2048
1859
|
requiredTSCompilerOptions,
|
|
2049
|
-
|
|
1860
|
+
configFile,
|
|
2050
1861
|
void 0,
|
|
2051
1862
|
extraTSCompilerExtensions
|
|
2052
1863
|
);
|
|
@@ -2054,15 +1865,21 @@ function getTSProject(docFsPath) {
|
|
|
2054
1865
|
const potentialGlobalFiles = new Set(
|
|
2055
1866
|
fileNames.filter((file) => /\.[cm]?ts$/.test(file))
|
|
2056
1867
|
);
|
|
2057
|
-
const tsPkgFile =
|
|
2058
|
-
const defaultLibFile =
|
|
2059
|
-
tsPkgFile ?
|
|
1868
|
+
const tsPkgFile = configFile && ((_a = import_tsserverlibrary.default.resolveModuleName("typescript/package.json", configFile, options, import_tsserverlibrary.default.sys).resolvedModule) == null ? void 0 : _a.resolvedFileName);
|
|
1869
|
+
const defaultLibFile = import_path7.default.join(
|
|
1870
|
+
tsPkgFile ? import_path7.default.join(tsPkgFile, "../lib") : __dirname,
|
|
2060
1871
|
import_tsserverlibrary.default.getDefaultLibFileName(options)
|
|
2061
1872
|
);
|
|
1873
|
+
const resolutionCache = import_tsserverlibrary.default.createModuleResolutionCache(
|
|
1874
|
+
rootDir,
|
|
1875
|
+
getCanonicalFileName,
|
|
1876
|
+
options
|
|
1877
|
+
);
|
|
2062
1878
|
const host = patch(
|
|
2063
1879
|
import_tsserverlibrary.default,
|
|
2064
|
-
|
|
1880
|
+
configFile,
|
|
2065
1881
|
extractCache,
|
|
1882
|
+
resolutionCache,
|
|
2066
1883
|
{
|
|
2067
1884
|
getNewLine() {
|
|
2068
1885
|
return import_tsserverlibrary.default.sys.newLine;
|
|
@@ -2085,9 +1902,16 @@ function getTSProject(docFsPath) {
|
|
|
2085
1902
|
getProjectReferences() {
|
|
2086
1903
|
return projectReferences;
|
|
2087
1904
|
},
|
|
2088
|
-
|
|
2089
|
-
return
|
|
2090
|
-
return import_tsserverlibrary.default.
|
|
1905
|
+
resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options2, _containingSourceFile, _reusedNames) {
|
|
1906
|
+
return moduleLiterals.map((moduleLiteral) => {
|
|
1907
|
+
return import_tsserverlibrary.default.bundlerModuleNameResolver(
|
|
1908
|
+
moduleLiteral.text,
|
|
1909
|
+
containingFile,
|
|
1910
|
+
options2,
|
|
1911
|
+
host,
|
|
1912
|
+
resolutionCache,
|
|
1913
|
+
redirectedReference
|
|
1914
|
+
);
|
|
2091
1915
|
});
|
|
2092
1916
|
},
|
|
2093
1917
|
readDirectory: import_tsserverlibrary.default.sys.readDirectory,
|
|
@@ -2110,7 +1934,7 @@ function getTSProject(docFsPath) {
|
|
|
2110
1934
|
return `${((_a2 = get(filenameToURI(filename))) == null ? void 0 : _a2.version) ?? -1}`;
|
|
2111
1935
|
},
|
|
2112
1936
|
getScriptKind(filename) {
|
|
2113
|
-
switch (
|
|
1937
|
+
switch (import_path7.default.extname(filename)) {
|
|
2114
1938
|
case import_tsserverlibrary.default.Extension.Js:
|
|
2115
1939
|
case import_tsserverlibrary.default.Extension.Cjs:
|
|
2116
1940
|
case import_tsserverlibrary.default.Extension.Mjs:
|
|
@@ -2146,14 +1970,7 @@ function getTSProject(docFsPath) {
|
|
|
2146
1970
|
host,
|
|
2147
1971
|
rootDir: options.rootDir,
|
|
2148
1972
|
service: import_tsserverlibrary.default.createLanguageService(host),
|
|
2149
|
-
|
|
2150
|
-
markoScriptLang,
|
|
2151
|
-
markoProjectTypeLibs: getProjectTypeLibs(
|
|
2152
|
-
options.rootDir,
|
|
2153
|
-
markoProject,
|
|
2154
|
-
import_tsserverlibrary.default,
|
|
2155
|
-
host
|
|
2156
|
-
)
|
|
1973
|
+
markoScriptLang
|
|
2157
1974
|
};
|
|
2158
1975
|
projectCache.set(rootDir, tsProject);
|
|
2159
1976
|
return tsProject;
|
|
@@ -2311,6 +2128,9 @@ function getTSTriggerChar(char) {
|
|
|
2311
2128
|
if (char && tsTriggerChars.has(char))
|
|
2312
2129
|
return char;
|
|
2313
2130
|
}
|
|
2131
|
+
function getCanonicalFileName(fileName) {
|
|
2132
|
+
return import_tsserverlibrary.default.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
|
2133
|
+
}
|
|
2314
2134
|
|
|
2315
2135
|
// src/service/style/index.ts
|
|
2316
2136
|
var import_vscode_css_languageservice2 = require("vscode-css-languageservice");
|
|
@@ -3195,7 +3015,7 @@ for (const command in service.commands) {
|
|
|
3195
3015
|
}
|
|
3196
3016
|
function validateDocs() {
|
|
3197
3017
|
queueDiagnostic();
|
|
3198
|
-
|
|
3018
|
+
import_language_tools16.Project.clearCaches();
|
|
3199
3019
|
}
|
|
3200
3020
|
function queueDiagnostic() {
|
|
3201
3021
|
clearTimeout(diagnosticTimeout);
|