@marko/language-server 1.0.3 → 1.0.5
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 +20 -16
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +20 -16
- package/dist/index.mjs.map +3 -3
- package/dist/ts-plugin/host.d.ts +2 -1
- package/dist/utils/project.d.ts +1 -1
- package/package.json +9 -10
package/dist/index.js
CHANGED
|
@@ -28,15 +28,17 @@ var import_node = require("vscode-languageserver/node");
|
|
|
28
28
|
|
|
29
29
|
// src/utils/project.ts
|
|
30
30
|
var import_path = __toESM(require("path"));
|
|
31
|
+
var import_module = require("module");
|
|
31
32
|
var defaultCompiler = __toESM(require("@marko/compiler"));
|
|
32
33
|
var defaultTranslator = __toESM(require("@marko/translator-default"));
|
|
33
|
-
var import_resolve_from = __toESM(require("resolve-from"));
|
|
34
34
|
var ignoreErrors = (_err) => {
|
|
35
35
|
};
|
|
36
36
|
var projectsByDir = /* @__PURE__ */ new Map();
|
|
37
37
|
var projectsByCompiler = /* @__PURE__ */ new Map();
|
|
38
38
|
var defaultProject = {
|
|
39
39
|
cache: /* @__PURE__ */ new Map(),
|
|
40
|
+
compiler: defaultCompiler,
|
|
41
|
+
translator: defaultTranslator,
|
|
40
42
|
getLookup(dir) {
|
|
41
43
|
const key = `taglib:${dir}`;
|
|
42
44
|
let lookup = defaultProject.cache.get(key);
|
|
@@ -51,9 +53,7 @@ var defaultProject = {
|
|
|
51
53
|
);
|
|
52
54
|
}
|
|
53
55
|
return lookup;
|
|
54
|
-
}
|
|
55
|
-
compiler: defaultCompiler,
|
|
56
|
-
translator: defaultTranslator
|
|
56
|
+
}
|
|
57
57
|
};
|
|
58
58
|
defaultCompiler.configure({ translator: defaultTranslator });
|
|
59
59
|
function getMarkoProject(dir) {
|
|
@@ -77,19 +77,17 @@ function clearMarkoProjectCaches() {
|
|
|
77
77
|
}
|
|
78
78
|
function loadProject(dir) {
|
|
79
79
|
try {
|
|
80
|
-
const
|
|
80
|
+
const require2 = (0, import_module.createRequire)(dir);
|
|
81
|
+
const compilerConfigPath = require2.resolve("@marko/compiler/config");
|
|
81
82
|
const cachedProject = projectsByCompiler.get(compilerConfigPath);
|
|
82
83
|
if (cachedProject)
|
|
83
84
|
return cachedProject;
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
require((0, import_resolve_from.default)(
|
|
87
|
-
dir,
|
|
88
|
-
interopDefault(require(compilerConfigPath)).translator
|
|
89
|
-
))
|
|
90
|
-
];
|
|
85
|
+
const compiler = require2(import_path.default.join(compilerConfigPath, ".."));
|
|
86
|
+
const translator = require2(interopDefault(require2(compilerConfigPath)).translator);
|
|
91
87
|
const project = {
|
|
92
88
|
cache: /* @__PURE__ */ new Map(),
|
|
89
|
+
compiler,
|
|
90
|
+
translator,
|
|
93
91
|
getLookup(dir2) {
|
|
94
92
|
const key = `taglib:${dir2}`;
|
|
95
93
|
let lookup = project.cache.get(key);
|
|
@@ -102,9 +100,7 @@ function loadProject(dir) {
|
|
|
102
100
|
project.cache.set(key, lookup);
|
|
103
101
|
}
|
|
104
102
|
return lookup;
|
|
105
|
-
}
|
|
106
|
-
compiler,
|
|
107
|
-
translator
|
|
103
|
+
}
|
|
108
104
|
};
|
|
109
105
|
projectsByCompiler.set(compilerConfigPath, project);
|
|
110
106
|
return project;
|
|
@@ -1349,7 +1345,7 @@ var markoExt = ".marko";
|
|
|
1349
1345
|
var markoExtReg = /\.marko$/;
|
|
1350
1346
|
var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
1351
1347
|
var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
|
|
1352
|
-
function patch(ts2, scriptLang, cache, host) {
|
|
1348
|
+
function patch(ts2, scriptLang, cache, host, ps) {
|
|
1353
1349
|
var _a, _b, _c;
|
|
1354
1350
|
const rootDir = host.getCurrentDirectory();
|
|
1355
1351
|
const projectTypeLibs = getProjectTypeLibs(
|
|
@@ -1400,6 +1396,14 @@ function patch(ts2, scriptLang, cache, host) {
|
|
|
1400
1396
|
} catch {
|
|
1401
1397
|
cached = { snapshot: ts2.ScriptSnapshot.fromString("") };
|
|
1402
1398
|
}
|
|
1399
|
+
ps == null ? void 0 : ps.getOrCreateScriptInfoForNormalizedPath(
|
|
1400
|
+
filename,
|
|
1401
|
+
false,
|
|
1402
|
+
void 0,
|
|
1403
|
+
ts2.ScriptKind.Deferred,
|
|
1404
|
+
false,
|
|
1405
|
+
host
|
|
1406
|
+
);
|
|
1403
1407
|
cache.set(filename, cached);
|
|
1404
1408
|
}
|
|
1405
1409
|
return cached.snapshot;
|