@marko/language-server 1.0.7 → 1.0.9

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.mjs CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  TextDocumentSyncKind,
14
14
  createConnection
15
15
  } from "vscode-languageserver/node";
16
- import { Project as Project4 } from "@marko/language-tools";
16
+ import { Project as Project5 } from "@marko/language-tools";
17
17
 
18
18
  // src/utils/file.ts
19
19
  import path from "path";
@@ -1177,7 +1177,7 @@ import { URI as URI6 } from "vscode-uri";
1177
1177
  import * as prettier2 from "prettier";
1178
1178
  import {
1179
1179
  NodeType as NodeType9,
1180
- Project as Project3,
1180
+ Project as Project4,
1181
1181
  ScriptLang,
1182
1182
  extractScript
1183
1183
  } from "@marko/language-tools";
@@ -1186,11 +1186,16 @@ import {
1186
1186
  import path6 from "path";
1187
1187
  import {
1188
1188
  Processors,
1189
+ Project as Project3,
1189
1190
  getExt,
1190
1191
  isDefinitionFile
1191
1192
  } from "@marko/language-tools";
1192
1193
  var fsPathReg = /^(?:[./\\]|[A-Z]:)/i;
1193
1194
  var modulePartsReg = /^((?:@(?:[^/]+)\/)?(?:[^/]+))(.*)$/;
1195
+ Project3.setDefaultTypePaths({
1196
+ internalTypesFile: path6.join(__dirname, "marko.internal.d.ts"),
1197
+ markoTypesFile: path6.join(__dirname, "marko.runtime.d.ts")
1198
+ });
1194
1199
  function patch(ts2, configFile, extractCache2, resolutionCache, host, ps) {
1195
1200
  var _a, _b, _c;
1196
1201
  const processors = Processors.create({
@@ -1202,6 +1207,17 @@ function patch(ts2, configFile, extractCache2, resolutionCache, host, ps) {
1202
1207
  var _a2;
1203
1208
  return (_a2 = processor.getRootNames) == null ? void 0 : _a2.call(processor);
1204
1209
  }).flat().filter(Boolean);
1210
+ const trackFile = ps ? (fileName) => {
1211
+ ps.getOrCreateScriptInfoForNormalizedPath(
1212
+ fileName,
1213
+ true,
1214
+ void 0,
1215
+ ts2.ScriptKind.Deferred,
1216
+ false,
1217
+ host
1218
+ );
1219
+ } : () => {
1220
+ };
1205
1221
  const getScriptFileNames = host.getScriptFileNames.bind(host);
1206
1222
  host.getScriptFileNames = () => [
1207
1223
  ...new Set(rootNames.concat(getScriptFileNames()))
@@ -1228,14 +1244,7 @@ function patch(ts2, configFile, extractCache2, resolutionCache, host, ps) {
1228
1244
  } catch {
1229
1245
  cached = { snapshot: ts2.ScriptSnapshot.fromString("") };
1230
1246
  }
1231
- ps == null ? void 0 : ps.getOrCreateScriptInfoForNormalizedPath(
1232
- fileName,
1233
- false,
1234
- void 0,
1235
- ts2.ScriptKind.Deferred,
1236
- false,
1237
- host
1238
- );
1247
+ trackFile(fileName);
1239
1248
  extractCache2.set(fileName, cached);
1240
1249
  }
1241
1250
  return cached.snapshot;
@@ -1269,7 +1278,8 @@ function patch(ts2, configFile, extractCache2, resolutionCache, host, ps) {
1269
1278
  let normalModuleLiterals = moduleLiterals;
1270
1279
  let resolvedModules;
1271
1280
  for (let i = 0; i < moduleLiterals.length; i++) {
1272
- const moduleName = moduleLiterals[i].text;
1281
+ const moduleLiteral = moduleLiterals[i];
1282
+ const moduleName = moduleLiteral.text;
1273
1283
  const processor = moduleName[0] !== "*" ? getProcessor(moduleName) : void 0;
1274
1284
  if (processor) {
1275
1285
  let resolvedFileName;
@@ -1327,6 +1337,7 @@ function patch(ts2, configFile, extractCache2, resolutionCache, host, ps) {
1327
1337
  });
1328
1338
  } else if (resolvedModules) {
1329
1339
  resolvedModules.push(void 0);
1340
+ normalModuleLiterals.push(moduleLiteral);
1330
1341
  }
1331
1342
  }
1332
1343
  const normalResolvedModules = normalModuleLiterals.length ? resolveModuleNameLiterals(
@@ -1409,7 +1420,7 @@ var ScriptService = {
1409
1420
  return;
1410
1421
  const tsProject = getTSProject(filename);
1411
1422
  const extracted = processScript(doc, tsProject);
1412
- const lang = Project3.getScriptLang(
1423
+ const lang = Project4.getScriptLang(
1413
1424
  filename,
1414
1425
  tsProject.markoScriptLang,
1415
1426
  ts,
@@ -1793,8 +1804,8 @@ function processScript(doc, tsProject) {
1793
1804
  ts,
1794
1805
  parsed,
1795
1806
  lookup,
1796
- scriptLang: Project3.getScriptLang(filename, markoScriptLang, ts, host),
1797
- runtimeTypesCode: (_a = Project3.getTypeLibs(tsProject.rootDir, ts, host)) == null ? void 0 : _a.markoTypesCode
1807
+ scriptLang: Project4.getScriptLang(filename, markoScriptLang, ts, host),
1808
+ runtimeTypesCode: (_a = Project4.getTypeLibs(tsProject.rootDir, ts, host)) == null ? void 0 : _a.markoTypesCode
1798
1809
  });
1799
1810
  });
1800
1811
  }
@@ -1866,7 +1877,7 @@ function getTSProject(docFsPath) {
1866
1877
  }
1867
1878
  }
1868
1879
  const rootDir = configFile && path7.dirname(configFile) || process.cwd();
1869
- const cache = Project3.getCache(configFile && rootDir);
1880
+ const cache = Project4.getCache(configFile && rootDir);
1870
1881
  let projectCache = cache.get(getTSProject);
1871
1882
  let cached;
1872
1883
  if (projectCache) {
@@ -3046,7 +3057,7 @@ for (const command in service.commands) {
3046
3057
  }
3047
3058
  function validateDocs() {
3048
3059
  queueDiagnostic();
3049
- Project4.clearCaches();
3060
+ Project5.clearCaches();
3050
3061
  }
3051
3062
  function queueDiagnostic() {
3052
3063
  clearTimeout(diagnosticTimeout);