@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.mjs
CHANGED
|
@@ -16,15 +16,17 @@ import {
|
|
|
16
16
|
|
|
17
17
|
// src/utils/project.ts
|
|
18
18
|
import path from "path";
|
|
19
|
+
import { createRequire } from "module";
|
|
19
20
|
import * as defaultCompiler from "@marko/compiler";
|
|
20
21
|
import * as defaultTranslator from "@marko/translator-default";
|
|
21
|
-
import resolveFrom from "resolve-from";
|
|
22
22
|
var ignoreErrors = (_err) => {
|
|
23
23
|
};
|
|
24
24
|
var projectsByDir = /* @__PURE__ */ new Map();
|
|
25
25
|
var projectsByCompiler = /* @__PURE__ */ new Map();
|
|
26
26
|
var defaultProject = {
|
|
27
27
|
cache: /* @__PURE__ */ new Map(),
|
|
28
|
+
compiler: defaultCompiler,
|
|
29
|
+
translator: defaultTranslator,
|
|
28
30
|
getLookup(dir) {
|
|
29
31
|
const key = `taglib:${dir}`;
|
|
30
32
|
let lookup = defaultProject.cache.get(key);
|
|
@@ -39,9 +41,7 @@ var defaultProject = {
|
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
return lookup;
|
|
42
|
-
}
|
|
43
|
-
compiler: defaultCompiler,
|
|
44
|
-
translator: defaultTranslator
|
|
44
|
+
}
|
|
45
45
|
};
|
|
46
46
|
defaultCompiler.configure({ translator: defaultTranslator });
|
|
47
47
|
function getMarkoProject(dir) {
|
|
@@ -65,19 +65,17 @@ function clearMarkoProjectCaches() {
|
|
|
65
65
|
}
|
|
66
66
|
function loadProject(dir) {
|
|
67
67
|
try {
|
|
68
|
-
const
|
|
68
|
+
const require2 = createRequire(dir);
|
|
69
|
+
const compilerConfigPath = require2.resolve("@marko/compiler/config");
|
|
69
70
|
const cachedProject = projectsByCompiler.get(compilerConfigPath);
|
|
70
71
|
if (cachedProject)
|
|
71
72
|
return cachedProject;
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
__require(resolveFrom(
|
|
75
|
-
dir,
|
|
76
|
-
interopDefault(__require(compilerConfigPath)).translator
|
|
77
|
-
))
|
|
78
|
-
];
|
|
73
|
+
const compiler = require2(path.join(compilerConfigPath, ".."));
|
|
74
|
+
const translator = require2(interopDefault(require2(compilerConfigPath)).translator);
|
|
79
75
|
const project = {
|
|
80
76
|
cache: /* @__PURE__ */ new Map(),
|
|
77
|
+
compiler,
|
|
78
|
+
translator,
|
|
81
79
|
getLookup(dir2) {
|
|
82
80
|
const key = `taglib:${dir2}`;
|
|
83
81
|
let lookup = project.cache.get(key);
|
|
@@ -90,9 +88,7 @@ function loadProject(dir) {
|
|
|
90
88
|
project.cache.set(key, lookup);
|
|
91
89
|
}
|
|
92
90
|
return lookup;
|
|
93
|
-
}
|
|
94
|
-
compiler,
|
|
95
|
-
translator
|
|
91
|
+
}
|
|
96
92
|
};
|
|
97
93
|
projectsByCompiler.set(compilerConfigPath, project);
|
|
98
94
|
return project;
|
|
@@ -1373,7 +1369,7 @@ var markoExt = ".marko";
|
|
|
1373
1369
|
var markoExtReg = /\.marko$/;
|
|
1374
1370
|
var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
|
|
1375
1371
|
var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
|
|
1376
|
-
function patch(ts2, scriptLang, cache, host) {
|
|
1372
|
+
function patch(ts2, scriptLang, cache, host, ps) {
|
|
1377
1373
|
var _a, _b, _c;
|
|
1378
1374
|
const rootDir = host.getCurrentDirectory();
|
|
1379
1375
|
const projectTypeLibs = getProjectTypeLibs(
|
|
@@ -1424,6 +1420,14 @@ function patch(ts2, scriptLang, cache, host) {
|
|
|
1424
1420
|
} catch {
|
|
1425
1421
|
cached = { snapshot: ts2.ScriptSnapshot.fromString("") };
|
|
1426
1422
|
}
|
|
1423
|
+
ps == null ? void 0 : ps.getOrCreateScriptInfoForNormalizedPath(
|
|
1424
|
+
filename,
|
|
1425
|
+
false,
|
|
1426
|
+
void 0,
|
|
1427
|
+
ts2.ScriptKind.Deferred,
|
|
1428
|
+
false,
|
|
1429
|
+
host
|
|
1430
|
+
);
|
|
1427
1431
|
cache.set(filename, cached);
|
|
1428
1432
|
}
|
|
1429
1433
|
return cached.snapshot;
|