@marko/language-tools 2.1.1 → 2.1.3
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 +64 -28
- package/dist/index.mjs +64 -28
- package/dist/util/project.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2928,12 +2928,14 @@ __export(project_exports, {
|
|
|
2928
2928
|
getScriptLang: () => getScriptLang,
|
|
2929
2929
|
getTagLookup: () => getTagLookup,
|
|
2930
2930
|
getTypeLibs: () => getTypeLibs,
|
|
2931
|
+
setDefaultCompilerMeta: () => setDefaultCompilerMeta,
|
|
2931
2932
|
setDefaultTypePaths: () => setDefaultTypePaths
|
|
2932
2933
|
});
|
|
2933
2934
|
var import_path2 = __toESM(require("path"));
|
|
2934
2935
|
var import_module = require("module");
|
|
2935
2936
|
var import_strip_json_comments = __toESM(require("strip-json-comments"));
|
|
2936
2937
|
var defaultTypeLibs = {};
|
|
2938
|
+
var defaultMeta;
|
|
2937
2939
|
var ignoreErrors = (_err) => {
|
|
2938
2940
|
};
|
|
2939
2941
|
var metaByDir = /* @__PURE__ */ new Map();
|
|
@@ -3039,6 +3041,9 @@ function getScriptLang(fileName, defaultScriptLang, ts, host) {
|
|
|
3039
3041
|
return scriptLang;
|
|
3040
3042
|
}
|
|
3041
3043
|
function clearCaches() {
|
|
3044
|
+
if (defaultMeta) {
|
|
3045
|
+
clearCacheForMeta(defaultMeta);
|
|
3046
|
+
}
|
|
3042
3047
|
for (const project of metaByCompiler.values()) {
|
|
3043
3048
|
clearCacheForMeta(project);
|
|
3044
3049
|
}
|
|
@@ -3046,36 +3051,67 @@ function clearCaches() {
|
|
|
3046
3051
|
function setDefaultTypePaths(defaults) {
|
|
3047
3052
|
Object.assign(defaultTypeLibs, defaults);
|
|
3048
3053
|
}
|
|
3049
|
-
function
|
|
3054
|
+
function setDefaultCompilerMeta(compiler, config) {
|
|
3055
|
+
const { translator } = config;
|
|
3056
|
+
if (typeof translator !== "object") {
|
|
3057
|
+
throw new Error("Translator must be fully resolved and loaded.");
|
|
3058
|
+
}
|
|
3059
|
+
defaultMeta = {
|
|
3060
|
+
compiler,
|
|
3061
|
+
config: {
|
|
3062
|
+
...config,
|
|
3063
|
+
cache: /* @__PURE__ */ new Map(),
|
|
3064
|
+
translator
|
|
3065
|
+
}
|
|
3066
|
+
};
|
|
3067
|
+
compiler.configure(defaultMeta.config);
|
|
3068
|
+
}
|
|
3069
|
+
function getMeta(dir) {
|
|
3070
|
+
if (!dir) {
|
|
3071
|
+
if (!defaultMeta) {
|
|
3072
|
+
throw new Error(
|
|
3073
|
+
"@marko/compiler must be installed or compiler registered."
|
|
3074
|
+
);
|
|
3075
|
+
}
|
|
3076
|
+
return defaultMeta;
|
|
3077
|
+
}
|
|
3078
|
+
if (defaultMeta) {
|
|
3079
|
+
try {
|
|
3080
|
+
return loadMeta(dir);
|
|
3081
|
+
} catch {
|
|
3082
|
+
metaByDir.set(dir, defaultMeta);
|
|
3083
|
+
return defaultMeta;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
return loadMeta(dir);
|
|
3087
|
+
}
|
|
3088
|
+
function loadMeta(dir) {
|
|
3050
3089
|
let cached = metaByDir.get(dir);
|
|
3051
3090
|
if (!cached) {
|
|
3052
|
-
|
|
3091
|
+
let require2 = (0, import_module.createRequire)(dir);
|
|
3092
|
+
let configPath;
|
|
3053
3093
|
try {
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
}
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
} catch (err) {
|
|
3076
|
-
if (fallback)
|
|
3077
|
-
throw err;
|
|
3078
|
-
cached = getMeta();
|
|
3094
|
+
configPath = require2.resolve("@marko/compiler/config");
|
|
3095
|
+
} catch {
|
|
3096
|
+
require2 = (0, import_module.createRequire)(
|
|
3097
|
+
import_path2.default.dirname(require2.resolve("marko/package.json"))
|
|
3098
|
+
);
|
|
3099
|
+
configPath = require2.resolve("@marko/compiler/config");
|
|
3100
|
+
}
|
|
3101
|
+
cached = metaByCompiler.get(configPath);
|
|
3102
|
+
if (!cached) {
|
|
3103
|
+
const compiler = require2(import_path2.default.dirname(configPath));
|
|
3104
|
+
const config = interopDefault(require2(configPath));
|
|
3105
|
+
cached = {
|
|
3106
|
+
compiler,
|
|
3107
|
+
config: {
|
|
3108
|
+
...config,
|
|
3109
|
+
cache: /* @__PURE__ */ new Map(),
|
|
3110
|
+
translator: require2(config.translator)
|
|
3111
|
+
}
|
|
3112
|
+
};
|
|
3113
|
+
compiler.configure(cached.config);
|
|
3114
|
+
metaByCompiler.set(configPath, cached);
|
|
3079
3115
|
}
|
|
3080
3116
|
metaByDir.set(dir, cached);
|
|
3081
3117
|
}
|
|
@@ -3092,7 +3128,7 @@ function getTagLookupForProject(meta, dir) {
|
|
|
3092
3128
|
ignoreErrors
|
|
3093
3129
|
);
|
|
3094
3130
|
} catch {
|
|
3095
|
-
if (
|
|
3131
|
+
if (meta !== defaultMeta) {
|
|
3096
3132
|
lookup = getTagLookupForProject(getMeta(), dir);
|
|
3097
3133
|
}
|
|
3098
3134
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2896,12 +2896,14 @@ __export(project_exports, {
|
|
|
2896
2896
|
getScriptLang: () => getScriptLang,
|
|
2897
2897
|
getTagLookup: () => getTagLookup,
|
|
2898
2898
|
getTypeLibs: () => getTypeLibs,
|
|
2899
|
+
setDefaultCompilerMeta: () => setDefaultCompilerMeta,
|
|
2899
2900
|
setDefaultTypePaths: () => setDefaultTypePaths
|
|
2900
2901
|
});
|
|
2901
2902
|
import path2 from "path";
|
|
2902
2903
|
import { createRequire } from "module";
|
|
2903
2904
|
import stripJSONComments from "strip-json-comments";
|
|
2904
2905
|
var defaultTypeLibs = {};
|
|
2906
|
+
var defaultMeta;
|
|
2905
2907
|
var ignoreErrors = (_err) => {
|
|
2906
2908
|
};
|
|
2907
2909
|
var metaByDir = /* @__PURE__ */ new Map();
|
|
@@ -3007,6 +3009,9 @@ function getScriptLang(fileName, defaultScriptLang, ts, host) {
|
|
|
3007
3009
|
return scriptLang;
|
|
3008
3010
|
}
|
|
3009
3011
|
function clearCaches() {
|
|
3012
|
+
if (defaultMeta) {
|
|
3013
|
+
clearCacheForMeta(defaultMeta);
|
|
3014
|
+
}
|
|
3010
3015
|
for (const project of metaByCompiler.values()) {
|
|
3011
3016
|
clearCacheForMeta(project);
|
|
3012
3017
|
}
|
|
@@ -3014,36 +3019,67 @@ function clearCaches() {
|
|
|
3014
3019
|
function setDefaultTypePaths(defaults) {
|
|
3015
3020
|
Object.assign(defaultTypeLibs, defaults);
|
|
3016
3021
|
}
|
|
3017
|
-
function
|
|
3022
|
+
function setDefaultCompilerMeta(compiler, config) {
|
|
3023
|
+
const { translator } = config;
|
|
3024
|
+
if (typeof translator !== "object") {
|
|
3025
|
+
throw new Error("Translator must be fully resolved and loaded.");
|
|
3026
|
+
}
|
|
3027
|
+
defaultMeta = {
|
|
3028
|
+
compiler,
|
|
3029
|
+
config: {
|
|
3030
|
+
...config,
|
|
3031
|
+
cache: /* @__PURE__ */ new Map(),
|
|
3032
|
+
translator
|
|
3033
|
+
}
|
|
3034
|
+
};
|
|
3035
|
+
compiler.configure(defaultMeta.config);
|
|
3036
|
+
}
|
|
3037
|
+
function getMeta(dir) {
|
|
3038
|
+
if (!dir) {
|
|
3039
|
+
if (!defaultMeta) {
|
|
3040
|
+
throw new Error(
|
|
3041
|
+
"@marko/compiler must be installed or compiler registered."
|
|
3042
|
+
);
|
|
3043
|
+
}
|
|
3044
|
+
return defaultMeta;
|
|
3045
|
+
}
|
|
3046
|
+
if (defaultMeta) {
|
|
3047
|
+
try {
|
|
3048
|
+
return loadMeta(dir);
|
|
3049
|
+
} catch {
|
|
3050
|
+
metaByDir.set(dir, defaultMeta);
|
|
3051
|
+
return defaultMeta;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
return loadMeta(dir);
|
|
3055
|
+
}
|
|
3056
|
+
function loadMeta(dir) {
|
|
3018
3057
|
let cached = metaByDir.get(dir);
|
|
3019
3058
|
if (!cached) {
|
|
3020
|
-
|
|
3059
|
+
let require2 = createRequire(dir);
|
|
3060
|
+
let configPath;
|
|
3021
3061
|
try {
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
}
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
} catch (err) {
|
|
3044
|
-
if (fallback)
|
|
3045
|
-
throw err;
|
|
3046
|
-
cached = getMeta();
|
|
3062
|
+
configPath = require2.resolve("@marko/compiler/config");
|
|
3063
|
+
} catch {
|
|
3064
|
+
require2 = createRequire(
|
|
3065
|
+
path2.dirname(require2.resolve("marko/package.json"))
|
|
3066
|
+
);
|
|
3067
|
+
configPath = require2.resolve("@marko/compiler/config");
|
|
3068
|
+
}
|
|
3069
|
+
cached = metaByCompiler.get(configPath);
|
|
3070
|
+
if (!cached) {
|
|
3071
|
+
const compiler = require2(path2.dirname(configPath));
|
|
3072
|
+
const config = interopDefault(require2(configPath));
|
|
3073
|
+
cached = {
|
|
3074
|
+
compiler,
|
|
3075
|
+
config: {
|
|
3076
|
+
...config,
|
|
3077
|
+
cache: /* @__PURE__ */ new Map(),
|
|
3078
|
+
translator: require2(config.translator)
|
|
3079
|
+
}
|
|
3080
|
+
};
|
|
3081
|
+
compiler.configure(cached.config);
|
|
3082
|
+
metaByCompiler.set(configPath, cached);
|
|
3047
3083
|
}
|
|
3048
3084
|
metaByDir.set(dir, cached);
|
|
3049
3085
|
}
|
|
@@ -3060,7 +3096,7 @@ function getTagLookupForProject(meta, dir) {
|
|
|
3060
3096
|
ignoreErrors
|
|
3061
3097
|
);
|
|
3062
3098
|
} catch {
|
|
3063
|
-
if (
|
|
3099
|
+
if (meta !== defaultMeta) {
|
|
3064
3100
|
lookup = getTagLookupForProject(getMeta(), dir);
|
|
3065
3101
|
}
|
|
3066
3102
|
}
|
package/dist/util/project.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type { TaglibLookup } from "@marko/babel-utils";
|
|
|
4
4
|
import type * as Compiler from "@marko/compiler";
|
|
5
5
|
import { ScriptLang } from "../extractors/script";
|
|
6
6
|
export interface Meta {
|
|
7
|
-
fallback: boolean;
|
|
8
7
|
compiler: typeof Compiler;
|
|
9
8
|
config: Omit<Compiler.Config, "cache" | "translator"> & {
|
|
10
9
|
cache: Map<any, any>;
|
|
@@ -78,4 +77,5 @@ export declare function getTypeLibs(rootDir: string, ts: typeof TS, host: TS.Mod
|
|
|
78
77
|
export declare function getScriptLang(fileName: string, defaultScriptLang: ScriptLang, ts: typeof TS, host: TS.ModuleResolutionHost): ScriptLang;
|
|
79
78
|
export declare function clearCaches(): void;
|
|
80
79
|
export declare function setDefaultTypePaths(defaults: typeof defaultTypeLibs): void;
|
|
80
|
+
export declare function setDefaultCompilerMeta(compiler: typeof Compiler, config: Compiler.Config): void;
|
|
81
81
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.3",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@marko/compiler": "^5.28.4"
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@babel/code-frame": "^7.22.5",
|
|
17
17
|
"@marko/compiler": "^5.31.1",
|
|
18
|
-
"@marko/translator-default": "^5.29.
|
|
18
|
+
"@marko/translator-default": "^5.29.2",
|
|
19
19
|
"@types/babel__code-frame": "^7.0.3",
|
|
20
20
|
"@types/babel__helper-validator-identifier": "^7.15.0",
|
|
21
21
|
"@typescript/vfs": "^1.4.0",
|
|
22
|
-
"marko": "^5.29.
|
|
22
|
+
"marko": "^5.29.2",
|
|
23
23
|
"mitata": "^0.1.6",
|
|
24
24
|
"tsx": "^3.12.7"
|
|
25
25
|
},
|