@marko/language-tools 2.0.0 → 2.0.1

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 CHANGED
@@ -2887,7 +2887,8 @@ __export(project_exports, {
2887
2887
  getConfig: () => getConfig,
2888
2888
  getScriptLang: () => getScriptLang,
2889
2889
  getTagLookup: () => getTagLookup,
2890
- getTypeLibs: () => getTypeLibs
2890
+ getTypeLibs: () => getTypeLibs,
2891
+ setDefaultTypePaths: () => setDefaultTypePaths
2891
2892
  });
2892
2893
  var import_path2 = __toESM(require("path"));
2893
2894
  var import_module = require("module");
@@ -2895,6 +2896,7 @@ var defaultCompiler = __toESM(require("@marko/compiler"));
2895
2896
  var defaultConfig = __toESM(require("@marko/compiler/config"));
2896
2897
  var defaultTranslator = __toESM(require("@marko/translator-default"));
2897
2898
  var import_strip_json_comments = __toESM(require("strip-json-comments"));
2899
+ var defaultTypeLibs = {};
2898
2900
  var ignoreErrors = (_err) => {
2899
2901
  };
2900
2902
  var metaByDir = /* @__PURE__ */ new Map();
@@ -2951,8 +2953,8 @@ function getTypeLibs(rootDir, ts, host) {
2951
2953
  resolveTypeCompilerOptions,
2952
2954
  host
2953
2955
  );
2954
- const internalTypesFile = resolvedInternalTypes == null ? void 0 : resolvedInternalTypes.resolvedFileName;
2955
- const markoTypesFile = resolvedMarkoTypes == null ? void 0 : resolvedMarkoTypes.resolvedFileName;
2956
+ const internalTypesFile = (resolvedInternalTypes == null ? void 0 : resolvedInternalTypes.resolvedFileName) || defaultTypeLibs.internalTypesFile;
2957
+ const markoTypesFile = (resolvedMarkoTypes == null ? void 0 : resolvedMarkoTypes.resolvedFileName) || defaultTypeLibs.markoTypesFile;
2956
2958
  const markoRunTypesFile = resolvedMarkoRunTypes == null ? void 0 : resolvedMarkoRunTypes.resolvedFileName;
2957
2959
  if (!internalTypesFile || !markoTypesFile) {
2958
2960
  throw new Error("Could not resolve marko type files.");
@@ -2977,7 +2979,11 @@ function getScriptLang(fileName, defaultScriptLang, ts, host) {
2977
2979
  const cache = config.cache.get(getScriptLang);
2978
2980
  let scriptLang = cache == null ? void 0 : cache.get(dir);
2979
2981
  if (!scriptLang) {
2980
- const configPath = ts.findConfigFile(dir, host.fileExists, "marko.json");
2982
+ const configPath = ts.findConfigFile(
2983
+ dir,
2984
+ host.fileExists.bind(host),
2985
+ "marko.json"
2986
+ );
2981
2987
  if (configPath) {
2982
2988
  try {
2983
2989
  const configSource = host.readFile(configPath);
@@ -3010,6 +3016,9 @@ function clearCaches() {
3010
3016
  clearCacheForMeta(project);
3011
3017
  }
3012
3018
  }
3019
+ function setDefaultTypePaths(defaults) {
3020
+ Object.assign(defaultTypeLibs, defaults);
3021
+ }
3013
3022
  function getMeta(dir) {
3014
3023
  if (!dir)
3015
3024
  return defaultMeta;
package/dist/index.mjs CHANGED
@@ -2856,7 +2856,8 @@ __export(project_exports, {
2856
2856
  getConfig: () => getConfig,
2857
2857
  getScriptLang: () => getScriptLang,
2858
2858
  getTagLookup: () => getTagLookup,
2859
- getTypeLibs: () => getTypeLibs
2859
+ getTypeLibs: () => getTypeLibs,
2860
+ setDefaultTypePaths: () => setDefaultTypePaths
2860
2861
  });
2861
2862
  import path2 from "path";
2862
2863
  import { createRequire } from "module";
@@ -2864,6 +2865,7 @@ import * as defaultCompiler from "@marko/compiler";
2864
2865
  import * as defaultConfig from "@marko/compiler/config";
2865
2866
  import * as defaultTranslator from "@marko/translator-default";
2866
2867
  import stripJSONComments from "strip-json-comments";
2868
+ var defaultTypeLibs = {};
2867
2869
  var ignoreErrors = (_err) => {
2868
2870
  };
2869
2871
  var metaByDir = /* @__PURE__ */ new Map();
@@ -2920,8 +2922,8 @@ function getTypeLibs(rootDir, ts, host) {
2920
2922
  resolveTypeCompilerOptions,
2921
2923
  host
2922
2924
  );
2923
- const internalTypesFile = resolvedInternalTypes == null ? void 0 : resolvedInternalTypes.resolvedFileName;
2924
- const markoTypesFile = resolvedMarkoTypes == null ? void 0 : resolvedMarkoTypes.resolvedFileName;
2925
+ const internalTypesFile = (resolvedInternalTypes == null ? void 0 : resolvedInternalTypes.resolvedFileName) || defaultTypeLibs.internalTypesFile;
2926
+ const markoTypesFile = (resolvedMarkoTypes == null ? void 0 : resolvedMarkoTypes.resolvedFileName) || defaultTypeLibs.markoTypesFile;
2925
2927
  const markoRunTypesFile = resolvedMarkoRunTypes == null ? void 0 : resolvedMarkoRunTypes.resolvedFileName;
2926
2928
  if (!internalTypesFile || !markoTypesFile) {
2927
2929
  throw new Error("Could not resolve marko type files.");
@@ -2946,7 +2948,11 @@ function getScriptLang(fileName, defaultScriptLang, ts, host) {
2946
2948
  const cache = config.cache.get(getScriptLang);
2947
2949
  let scriptLang = cache == null ? void 0 : cache.get(dir);
2948
2950
  if (!scriptLang) {
2949
- const configPath = ts.findConfigFile(dir, host.fileExists, "marko.json");
2951
+ const configPath = ts.findConfigFile(
2952
+ dir,
2953
+ host.fileExists.bind(host),
2954
+ "marko.json"
2955
+ );
2950
2956
  if (configPath) {
2951
2957
  try {
2952
2958
  const configSource = host.readFile(configPath);
@@ -2979,6 +2985,9 @@ function clearCaches() {
2979
2985
  clearCacheForMeta(project);
2980
2986
  }
2981
2987
  }
2988
+ function setDefaultTypePaths(defaults) {
2989
+ Object.assign(defaultTypeLibs, defaults);
2990
+ }
2982
2991
  function getMeta(dir) {
2983
2992
  if (!dir)
2984
2993
  return defaultMeta;
@@ -13,6 +13,14 @@ export interface Meta {
13
13
  };
14
14
  };
15
15
  }
16
+ interface TypeLibs {
17
+ internalTypesFile: string | undefined;
18
+ markoRunTypesFile: string | undefined;
19
+ markoRunGeneratedTypesFile: string | undefined;
20
+ markoTypesFile: string | undefined;
21
+ markoTypesCode: string | undefined;
22
+ }
23
+ declare const defaultTypeLibs: Partial<TypeLibs>;
16
24
  export declare function getCompiler(dir?: string): typeof defaultCompiler;
17
25
  export declare function getCache(dir?: string): Map<any, any>;
18
26
  export declare function getConfig(dir?: string): Omit<{
@@ -66,3 +74,5 @@ export declare function getTypeLibs(rootDir: string, ts: typeof TS, host: TS.Mod
66
74
  };
67
75
  export declare function getScriptLang(fileName: string, defaultScriptLang: ScriptLang, ts: typeof TS, host: TS.ModuleResolutionHost): ScriptLang;
68
76
  export declare function clearCaches(): void;
77
+ export declare function setDefaultTypePaths(defaults: typeof defaultTypeLibs): void;
78
+ export {};
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.0.0",
4
+ "version": "2.0.1",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "dependencies": {
7
7
  "@babel/helper-validator-identifier": "^7.19.1",
8
- "@babel/parser": "^7.21.3",
8
+ "@babel/parser": "^7.21.4",
9
9
  "@marko/compiler": "5.27.4",
10
10
  "@marko/translator-default": "5.25.4",
11
11
  "htmljs-parser": "^5.4.3",
12
12
  "relative-import-path": "^1.0.0"
13
13
  },
14
14
  "devDependencies": {
15
- "@babel/code-frame": "^7.18.6",
15
+ "@babel/code-frame": "^7.21.4",
16
16
  "@marko/compiler": "^5.27.4",
17
17
  "@types/babel__code-frame": "^7.0.3",
18
18
  "@types/babel__helper-validator-identifier": "^7.15.0",