@macroforge/svelte-language-server 0.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.
Files changed (256) hide show
  1. package/README.md +331 -0
  2. package/bin/server.js +5 -0
  3. package/dist/src/importPackage.d.ts +16 -0
  4. package/dist/src/importPackage.js +76 -0
  5. package/dist/src/importPackage.js.map +1 -0
  6. package/dist/src/index.d.ts +3 -0
  7. package/dist/src/index.js +23 -0
  8. package/dist/src/index.js.map +1 -0
  9. package/dist/src/lib/DiagnosticsManager.d.ts +20 -0
  10. package/dist/src/lib/DiagnosticsManager.js +71 -0
  11. package/dist/src/lib/DiagnosticsManager.js.map +1 -0
  12. package/dist/src/lib/FallbackWatcher.d.ts +15 -0
  13. package/dist/src/lib/FallbackWatcher.js +66 -0
  14. package/dist/src/lib/FallbackWatcher.js.map +1 -0
  15. package/dist/src/lib/documentHighlight/wordHighlight.d.ts +3 -0
  16. package/dist/src/lib/documentHighlight/wordHighlight.js +62 -0
  17. package/dist/src/lib/documentHighlight/wordHighlight.js.map +1 -0
  18. package/dist/src/lib/documents/Document.d.ts +63 -0
  19. package/dist/src/lib/documents/Document.js +138 -0
  20. package/dist/src/lib/documents/Document.js.map +1 -0
  21. package/dist/src/lib/documents/DocumentBase.d.ts +65 -0
  22. package/dist/src/lib/documents/DocumentBase.js +69 -0
  23. package/dist/src/lib/documents/DocumentBase.js.map +1 -0
  24. package/dist/src/lib/documents/DocumentManager.d.ts +28 -0
  25. package/dist/src/lib/documents/DocumentManager.js +122 -0
  26. package/dist/src/lib/documents/DocumentManager.js.map +1 -0
  27. package/dist/src/lib/documents/DocumentMapper.d.ts +88 -0
  28. package/dist/src/lib/documents/DocumentMapper.js +258 -0
  29. package/dist/src/lib/documents/DocumentMapper.js.map +1 -0
  30. package/dist/src/lib/documents/configLoader.d.ts +80 -0
  31. package/dist/src/lib/documents/configLoader.js +265 -0
  32. package/dist/src/lib/documents/configLoader.js.map +1 -0
  33. package/dist/src/lib/documents/fileCollection.d.ts +41 -0
  34. package/dist/src/lib/documents/fileCollection.js +87 -0
  35. package/dist/src/lib/documents/fileCollection.js.map +1 -0
  36. package/dist/src/lib/documents/index.d.ts +5 -0
  37. package/dist/src/lib/documents/index.js +22 -0
  38. package/dist/src/lib/documents/index.js.map +1 -0
  39. package/dist/src/lib/documents/parseHtml.d.ts +13 -0
  40. package/dist/src/lib/documents/parseHtml.js +160 -0
  41. package/dist/src/lib/documents/parseHtml.js.map +1 -0
  42. package/dist/src/lib/documents/utils.d.ts +105 -0
  43. package/dist/src/lib/documents/utils.js +410 -0
  44. package/dist/src/lib/documents/utils.js.map +1 -0
  45. package/dist/src/lib/foldingRange/indentFolding.d.ts +26 -0
  46. package/dist/src/lib/foldingRange/indentFolding.js +142 -0
  47. package/dist/src/lib/foldingRange/indentFolding.js.map +1 -0
  48. package/dist/src/lib/semanticToken/semanticTokenLegend.d.ts +33 -0
  49. package/dist/src/lib/semanticToken/semanticTokenLegend.js +37 -0
  50. package/dist/src/lib/semanticToken/semanticTokenLegend.js.map +1 -0
  51. package/dist/src/logger.d.ts +9 -0
  52. package/dist/src/logger.js +28 -0
  53. package/dist/src/logger.js.map +1 -0
  54. package/dist/src/ls-config.d.ts +326 -0
  55. package/dist/src/ls-config.js +386 -0
  56. package/dist/src/ls-config.js.map +1 -0
  57. package/dist/src/plugins/PluginHost.d.ts +68 -0
  58. package/dist/src/plugins/PluginHost.js +447 -0
  59. package/dist/src/plugins/PluginHost.js.map +1 -0
  60. package/dist/src/plugins/css/CSSDocument.d.ts +46 -0
  61. package/dist/src/plugins/css/CSSDocument.js +78 -0
  62. package/dist/src/plugins/css/CSSDocument.js.map +1 -0
  63. package/dist/src/plugins/css/CSSPlugin.d.ts +35 -0
  64. package/dist/src/plugins/css/CSSPlugin.js +407 -0
  65. package/dist/src/plugins/css/CSSPlugin.js.map +1 -0
  66. package/dist/src/plugins/css/FileSystemProvider.d.ts +10 -0
  67. package/dist/src/plugins/css/FileSystemProvider.js +75 -0
  68. package/dist/src/plugins/css/FileSystemProvider.js.map +1 -0
  69. package/dist/src/plugins/css/StyleAttributeDocument.d.ts +41 -0
  70. package/dist/src/plugins/css/StyleAttributeDocument.js +65 -0
  71. package/dist/src/plugins/css/StyleAttributeDocument.js.map +1 -0
  72. package/dist/src/plugins/css/features/getIdClassCompletion.d.ts +19 -0
  73. package/dist/src/plugins/css/features/getIdClassCompletion.js +56 -0
  74. package/dist/src/plugins/css/features/getIdClassCompletion.js.map +1 -0
  75. package/dist/src/plugins/css/features/svelte-selectors.d.ts +2 -0
  76. package/dist/src/plugins/css/features/svelte-selectors.js +18 -0
  77. package/dist/src/plugins/css/features/svelte-selectors.js.map +1 -0
  78. package/dist/src/plugins/css/global-vars.d.ts +16 -0
  79. package/dist/src/plugins/css/global-vars.js +82 -0
  80. package/dist/src/plugins/css/global-vars.js.map +1 -0
  81. package/dist/src/plugins/css/service.d.ts +5 -0
  82. package/dist/src/plugins/css/service.js +66 -0
  83. package/dist/src/plugins/css/service.js.map +1 -0
  84. package/dist/src/plugins/documentContext.d.ts +3 -0
  85. package/dist/src/plugins/documentContext.js +36 -0
  86. package/dist/src/plugins/documentContext.js.map +1 -0
  87. package/dist/src/plugins/html/HTMLPlugin.d.ts +36 -0
  88. package/dist/src/plugins/html/HTMLPlugin.js +363 -0
  89. package/dist/src/plugins/html/HTMLPlugin.js.map +1 -0
  90. package/dist/src/plugins/html/dataProvider.d.ts +1 -0
  91. package/dist/src/plugins/html/dataProvider.js +481 -0
  92. package/dist/src/plugins/html/dataProvider.js.map +1 -0
  93. package/dist/src/plugins/index.d.ts +7 -0
  94. package/dist/src/plugins/index.js +24 -0
  95. package/dist/src/plugins/index.js.map +1 -0
  96. package/dist/src/plugins/interfaces.d.ts +132 -0
  97. package/dist/src/plugins/interfaces.js +3 -0
  98. package/dist/src/plugins/interfaces.js.map +1 -0
  99. package/dist/src/plugins/svelte/SvelteDocument.d.ts +98 -0
  100. package/dist/src/plugins/svelte/SvelteDocument.js +318 -0
  101. package/dist/src/plugins/svelte/SvelteDocument.js.map +1 -0
  102. package/dist/src/plugins/svelte/SveltePlugin.d.ts +24 -0
  103. package/dist/src/plugins/svelte/SveltePlugin.js +306 -0
  104. package/dist/src/plugins/svelte/SveltePlugin.js.map +1 -0
  105. package/dist/src/plugins/svelte/features/SvelteTags.d.ts +28 -0
  106. package/dist/src/plugins/svelte/features/SvelteTags.js +136 -0
  107. package/dist/src/plugins/svelte/features/SvelteTags.js.map +1 -0
  108. package/dist/src/plugins/svelte/features/getCodeActions/getQuickfixes.d.ts +11 -0
  109. package/dist/src/plugins/svelte/features/getCodeActions/getQuickfixes.js +140 -0
  110. package/dist/src/plugins/svelte/features/getCodeActions/getQuickfixes.js.map +1 -0
  111. package/dist/src/plugins/svelte/features/getCodeActions/getRefactorings.d.ts +9 -0
  112. package/dist/src/plugins/svelte/features/getCodeActions/getRefactorings.js +140 -0
  113. package/dist/src/plugins/svelte/features/getCodeActions/getRefactorings.js.map +1 -0
  114. package/dist/src/plugins/svelte/features/getCodeActions/index.d.ts +4 -0
  115. package/dist/src/plugins/svelte/features/getCodeActions/index.js +19 -0
  116. package/dist/src/plugins/svelte/features/getCodeActions/index.js.map +1 -0
  117. package/dist/src/plugins/svelte/features/getCompletions.d.ts +4 -0
  118. package/dist/src/plugins/svelte/features/getCompletions.js +184 -0
  119. package/dist/src/plugins/svelte/features/getCompletions.js.map +1 -0
  120. package/dist/src/plugins/svelte/features/getDiagnostics.d.ts +9 -0
  121. package/dist/src/plugins/svelte/features/getDiagnostics.js +284 -0
  122. package/dist/src/plugins/svelte/features/getDiagnostics.js.map +1 -0
  123. package/dist/src/plugins/svelte/features/getHoverInfo.d.ts +7 -0
  124. package/dist/src/plugins/svelte/features/getHoverInfo.js +93 -0
  125. package/dist/src/plugins/svelte/features/getHoverInfo.js.map +1 -0
  126. package/dist/src/plugins/svelte/features/getModifierData.d.ts +7 -0
  127. package/dist/src/plugins/svelte/features/getModifierData.js +56 -0
  128. package/dist/src/plugins/svelte/features/getModifierData.js.map +1 -0
  129. package/dist/src/plugins/svelte/features/getSelectionRanges.d.ts +3 -0
  130. package/dist/src/plugins/svelte/features/getSelectionRanges.js +46 -0
  131. package/dist/src/plugins/svelte/features/getSelectionRanges.js.map +1 -0
  132. package/dist/src/plugins/svelte/features/utils.d.ts +5 -0
  133. package/dist/src/plugins/svelte/features/utils.js +18 -0
  134. package/dist/src/plugins/svelte/features/utils.js.map +1 -0
  135. package/dist/src/plugins/typescript/ComponentInfoProvider.d.ts +27 -0
  136. package/dist/src/plugins/typescript/ComponentInfoProvider.js +116 -0
  137. package/dist/src/plugins/typescript/ComponentInfoProvider.js.map +1 -0
  138. package/dist/src/plugins/typescript/DocumentMapper.d.ts +10 -0
  139. package/dist/src/plugins/typescript/DocumentMapper.js +25 -0
  140. package/dist/src/plugins/typescript/DocumentMapper.js.map +1 -0
  141. package/dist/src/plugins/typescript/DocumentSnapshot.d.ts +173 -0
  142. package/dist/src/plugins/typescript/DocumentSnapshot.js +623 -0
  143. package/dist/src/plugins/typescript/DocumentSnapshot.js.map +1 -0
  144. package/dist/src/plugins/typescript/LSAndTSDocResolver.d.ts +100 -0
  145. package/dist/src/plugins/typescript/LSAndTSDocResolver.js +301 -0
  146. package/dist/src/plugins/typescript/LSAndTSDocResolver.js.map +1 -0
  147. package/dist/src/plugins/typescript/SnapshotManager.d.ts +59 -0
  148. package/dist/src/plugins/typescript/SnapshotManager.js +238 -0
  149. package/dist/src/plugins/typescript/SnapshotManager.js.map +1 -0
  150. package/dist/src/plugins/typescript/TypeScriptPlugin.d.ts +65 -0
  151. package/dist/src/plugins/typescript/TypeScriptPlugin.js +332 -0
  152. package/dist/src/plugins/typescript/TypeScriptPlugin.js.map +1 -0
  153. package/dist/src/plugins/typescript/features/CallHierarchyProvider.d.ts +24 -0
  154. package/dist/src/plugins/typescript/features/CallHierarchyProvider.js +325 -0
  155. package/dist/src/plugins/typescript/features/CallHierarchyProvider.js.map +1 -0
  156. package/dist/src/plugins/typescript/features/CodeActionsProvider.d.ts +72 -0
  157. package/dist/src/plugins/typescript/features/CodeActionsProvider.js +1030 -0
  158. package/dist/src/plugins/typescript/features/CodeActionsProvider.js.map +1 -0
  159. package/dist/src/plugins/typescript/features/CodeLensProvider.d.ts +28 -0
  160. package/dist/src/plugins/typescript/features/CodeLensProvider.js +205 -0
  161. package/dist/src/plugins/typescript/features/CodeLensProvider.js.map +1 -0
  162. package/dist/src/plugins/typescript/features/CompletionProvider.d.ts +57 -0
  163. package/dist/src/plugins/typescript/features/CompletionProvider.js +791 -0
  164. package/dist/src/plugins/typescript/features/CompletionProvider.js.map +1 -0
  165. package/dist/src/plugins/typescript/features/DiagnosticsProvider.d.ts +36 -0
  166. package/dist/src/plugins/typescript/features/DiagnosticsProvider.js +497 -0
  167. package/dist/src/plugins/typescript/features/DiagnosticsProvider.js.map +1 -0
  168. package/dist/src/plugins/typescript/features/DocumentHighlightProvider.d.ts +17 -0
  169. package/dist/src/plugins/typescript/features/DocumentHighlightProvider.js +211 -0
  170. package/dist/src/plugins/typescript/features/DocumentHighlightProvider.js.map +1 -0
  171. package/dist/src/plugins/typescript/features/FindComponentReferencesProvider.d.ts +9 -0
  172. package/dist/src/plugins/typescript/features/FindComponentReferencesProvider.js +66 -0
  173. package/dist/src/plugins/typescript/features/FindComponentReferencesProvider.js.map +1 -0
  174. package/dist/src/plugins/typescript/features/FindFileReferencesProvider.d.ts +9 -0
  175. package/dist/src/plugins/typescript/features/FindFileReferencesProvider.js +38 -0
  176. package/dist/src/plugins/typescript/features/FindFileReferencesProvider.js.map +1 -0
  177. package/dist/src/plugins/typescript/features/FindReferencesProvider.d.ts +20 -0
  178. package/dist/src/plugins/typescript/features/FindReferencesProvider.js +149 -0
  179. package/dist/src/plugins/typescript/features/FindReferencesProvider.js.map +1 -0
  180. package/dist/src/plugins/typescript/features/FoldingRangeProvider.d.ts +28 -0
  181. package/dist/src/plugins/typescript/features/FoldingRangeProvider.js +247 -0
  182. package/dist/src/plugins/typescript/features/FoldingRangeProvider.js.map +1 -0
  183. package/dist/src/plugins/typescript/features/HoverProvider.d.ts +11 -0
  184. package/dist/src/plugins/typescript/features/HoverProvider.js +75 -0
  185. package/dist/src/plugins/typescript/features/HoverProvider.js.map +1 -0
  186. package/dist/src/plugins/typescript/features/ImplementationProvider.d.ts +9 -0
  187. package/dist/src/plugins/typescript/features/ImplementationProvider.js +47 -0
  188. package/dist/src/plugins/typescript/features/ImplementationProvider.js.map +1 -0
  189. package/dist/src/plugins/typescript/features/InlayHintProvider.d.ts +22 -0
  190. package/dist/src/plugins/typescript/features/InlayHintProvider.js +225 -0
  191. package/dist/src/plugins/typescript/features/InlayHintProvider.js.map +1 -0
  192. package/dist/src/plugins/typescript/features/RenameProvider.d.ts +53 -0
  193. package/dist/src/plugins/typescript/features/RenameProvider.js +423 -0
  194. package/dist/src/plugins/typescript/features/RenameProvider.js.map +1 -0
  195. package/dist/src/plugins/typescript/features/SelectionRangeProvider.d.ts +18 -0
  196. package/dist/src/plugins/typescript/features/SelectionRangeProvider.js +62 -0
  197. package/dist/src/plugins/typescript/features/SelectionRangeProvider.js.map +1 -0
  198. package/dist/src/plugins/typescript/features/SemanticTokensProvider.d.ts +15 -0
  199. package/dist/src/plugins/typescript/features/SemanticTokensProvider.js +116 -0
  200. package/dist/src/plugins/typescript/features/SemanticTokensProvider.js.map +1 -0
  201. package/dist/src/plugins/typescript/features/SignatureHelpProvider.d.ts +22 -0
  202. package/dist/src/plugins/typescript/features/SignatureHelpProvider.js +110 -0
  203. package/dist/src/plugins/typescript/features/SignatureHelpProvider.js.map +1 -0
  204. package/dist/src/plugins/typescript/features/TypeDefinitionProvider.d.ts +9 -0
  205. package/dist/src/plugins/typescript/features/TypeDefinitionProvider.js +35 -0
  206. package/dist/src/plugins/typescript/features/TypeDefinitionProvider.js.map +1 -0
  207. package/dist/src/plugins/typescript/features/UpdateImportsProvider.d.ts +11 -0
  208. package/dist/src/plugins/typescript/features/UpdateImportsProvider.js +109 -0
  209. package/dist/src/plugins/typescript/features/UpdateImportsProvider.js.map +1 -0
  210. package/dist/src/plugins/typescript/features/WorkspaceSymbolProvider.d.ts +25 -0
  211. package/dist/src/plugins/typescript/features/WorkspaceSymbolProvider.js +176 -0
  212. package/dist/src/plugins/typescript/features/WorkspaceSymbolProvider.js.map +1 -0
  213. package/dist/src/plugins/typescript/features/getDirectiveCommentCompletions.d.ts +13 -0
  214. package/dist/src/plugins/typescript/features/getDirectiveCommentCompletions.js +58 -0
  215. package/dist/src/plugins/typescript/features/getDirectiveCommentCompletions.js.map +1 -0
  216. package/dist/src/plugins/typescript/features/getJsDocTemplateCompletion.d.ts +4 -0
  217. package/dist/src/plugins/typescript/features/getJsDocTemplateCompletion.js +57 -0
  218. package/dist/src/plugins/typescript/features/getJsDocTemplateCompletion.js.map +1 -0
  219. package/dist/src/plugins/typescript/features/utils.d.ts +81 -0
  220. package/dist/src/plugins/typescript/features/utils.js +331 -0
  221. package/dist/src/plugins/typescript/features/utils.js.map +1 -0
  222. package/dist/src/plugins/typescript/macroforgeAugmenter.d.ts +23 -0
  223. package/dist/src/plugins/typescript/macroforgeAugmenter.js +41 -0
  224. package/dist/src/plugins/typescript/macroforgeAugmenter.js.map +1 -0
  225. package/dist/src/plugins/typescript/module-loader.d.ts +28 -0
  226. package/dist/src/plugins/typescript/module-loader.js +254 -0
  227. package/dist/src/plugins/typescript/module-loader.js.map +1 -0
  228. package/dist/src/plugins/typescript/previewer.d.ts +7 -0
  229. package/dist/src/plugins/typescript/previewer.js +120 -0
  230. package/dist/src/plugins/typescript/previewer.js.map +1 -0
  231. package/dist/src/plugins/typescript/service.d.ts +105 -0
  232. package/dist/src/plugins/typescript/service.js +1073 -0
  233. package/dist/src/plugins/typescript/service.js.map +1 -0
  234. package/dist/src/plugins/typescript/serviceCache.d.ts +90 -0
  235. package/dist/src/plugins/typescript/serviceCache.js +50 -0
  236. package/dist/src/plugins/typescript/serviceCache.js.map +1 -0
  237. package/dist/src/plugins/typescript/svelte-ast-utils.d.ts +77 -0
  238. package/dist/src/plugins/typescript/svelte-ast-utils.js +100 -0
  239. package/dist/src/plugins/typescript/svelte-ast-utils.js.map +1 -0
  240. package/dist/src/plugins/typescript/svelte-sys.d.ts +9 -0
  241. package/dist/src/plugins/typescript/svelte-sys.js +79 -0
  242. package/dist/src/plugins/typescript/svelte-sys.js.map +1 -0
  243. package/dist/src/plugins/typescript/utils.d.ts +48 -0
  244. package/dist/src/plugins/typescript/utils.js +334 -0
  245. package/dist/src/plugins/typescript/utils.js.map +1 -0
  246. package/dist/src/server.d.ts +19 -0
  247. package/dist/src/server.js +434 -0
  248. package/dist/src/server.js.map +1 -0
  249. package/dist/src/svelte-check.d.ts +65 -0
  250. package/dist/src/svelte-check.js +288 -0
  251. package/dist/src/svelte-check.js.map +1 -0
  252. package/dist/src/utils.d.ts +111 -0
  253. package/dist/src/utils.js +337 -0
  254. package/dist/src/utils.js.map +1 -0
  255. package/dist/tsconfig.tsbuildinfo +1 -0
  256. package/package.json +79 -0
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SvelteCheck = void 0;
7
+ const path_1 = require("path");
8
+ const typescript_1 = __importDefault(require("typescript"));
9
+ const vscode_languageserver_1 = require("vscode-languageserver");
10
+ const documents_1 = require("./lib/documents");
11
+ const logger_1 = require("./logger");
12
+ const ls_config_1 = require("./ls-config");
13
+ const plugins_1 = require("./plugins");
14
+ const FileSystemProvider_1 = require("./plugins/css/FileSystemProvider");
15
+ const service_1 = require("./plugins/css/service");
16
+ const utils_1 = require("./plugins/typescript/features/utils");
17
+ const utils_2 = require("./plugins/typescript/utils");
18
+ const utils_3 = require("./utils");
19
+ const lodash_1 = require("lodash");
20
+ /**
21
+ * Small wrapper around PluginHost's Diagnostic Capabilities
22
+ * for svelte-check, without the overhead of the lsp.
23
+ */
24
+ class SvelteCheck {
25
+ constructor(workspacePath, options = {}) {
26
+ this.options = options;
27
+ this.docManager = new documents_1.DocumentManager((textDocument) => new documents_1.Document(textDocument.uri, textDocument.text));
28
+ this.configManager = new ls_config_1.LSConfigManager();
29
+ this.pluginHost = new plugins_1.PluginHost(this.docManager);
30
+ logger_1.Logger.setLogErrorsOnly(true);
31
+ this.initialize(workspacePath, options);
32
+ }
33
+ async initialize(workspacePath, options) {
34
+ if (options.tsconfig && !(0, path_1.isAbsolute)(options.tsconfig)) {
35
+ throw new Error('tsconfigPath needs to be absolute, got ' + options.tsconfig);
36
+ }
37
+ this.configManager.update({
38
+ svelte: {
39
+ compilerWarnings: options.compilerWarnings
40
+ }
41
+ });
42
+ // No HTMLPlugin, it does not provide diagnostics
43
+ if (shouldRegister('svelte')) {
44
+ this.pluginHost.register(new plugins_1.SveltePlugin(this.configManager));
45
+ }
46
+ if (shouldRegister('css')) {
47
+ const services = (0, service_1.createLanguageServices)({
48
+ fileSystemProvider: new FileSystemProvider_1.FileSystemProvider()
49
+ });
50
+ const workspaceFolders = [
51
+ {
52
+ name: '',
53
+ uri: (0, utils_3.pathToUrl)(workspacePath)
54
+ }
55
+ ];
56
+ this.pluginHost.register(new plugins_1.CSSPlugin(this.docManager, this.configManager, workspaceFolders, services));
57
+ }
58
+ if (shouldRegister('js') || options.tsconfig) {
59
+ const workspaceUris = [(0, utils_3.pathToUrl)(workspacePath)];
60
+ this.lsAndTSDocResolver = new plugins_1.LSAndTSDocResolver(this.docManager, workspaceUris, this.configManager, {
61
+ tsconfigPath: options.tsconfig,
62
+ isSvelteCheck: true,
63
+ onProjectReloaded: options.onProjectReload,
64
+ watch: options.watch,
65
+ onFileSnapshotCreated: options.onFileSnapshotCreated
66
+ });
67
+ this.pluginHost.register(new plugins_1.TypeScriptPlugin(this.configManager, this.lsAndTSDocResolver, workspaceUris, this.docManager));
68
+ }
69
+ function shouldRegister(source) {
70
+ return !options.diagnosticSources || options.diagnosticSources.includes(source);
71
+ }
72
+ }
73
+ /**
74
+ * Creates/updates given document
75
+ *
76
+ * @param doc Text and Uri of the document
77
+ * @param isNew Whether or not this is the creation of the document
78
+ */
79
+ async upsertDocument(doc, isNew) {
80
+ const filePath = (0, utils_3.urlToPath)(doc.uri) || '';
81
+ if (this.options.tsconfig) {
82
+ const lsContainer = await this.getLSContainer(this.options.tsconfig);
83
+ if (!lsContainer.fileBelongsToProject(filePath, isNew)) {
84
+ return;
85
+ }
86
+ }
87
+ if (doc.uri.endsWith('.ts') ||
88
+ doc.uri.endsWith('.js') ||
89
+ doc.uri.endsWith('.tsx') ||
90
+ doc.uri.endsWith('.jsx') ||
91
+ doc.uri.endsWith('.mjs') ||
92
+ doc.uri.endsWith('.cjs') ||
93
+ doc.uri.endsWith('.mts') ||
94
+ doc.uri.endsWith('.cts')) {
95
+ this.pluginHost.updateTsOrJsFile(filePath, [
96
+ {
97
+ range: vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(0, 0), vscode_languageserver_1.Position.create(Number.MAX_VALUE, Number.MAX_VALUE)),
98
+ text: doc.text
99
+ }
100
+ ]);
101
+ }
102
+ else {
103
+ this.docManager.openClientDocument({
104
+ text: doc.text,
105
+ uri: doc.uri
106
+ });
107
+ }
108
+ }
109
+ /**
110
+ * Removes/closes document
111
+ *
112
+ * @param uri Uri of the document
113
+ */
114
+ async removeDocument(uri) {
115
+ if (!this.docManager.get(uri)) {
116
+ return;
117
+ }
118
+ this.docManager.closeDocument(uri);
119
+ this.docManager.releaseDocument(uri);
120
+ if (this.options.tsconfig) {
121
+ const lsContainer = await this.getLSContainer(this.options.tsconfig);
122
+ lsContainer.deleteSnapshot((0, utils_3.urlToPath)(uri) || '');
123
+ }
124
+ }
125
+ /**
126
+ * Gets the diagnostics for all currently open files.
127
+ */
128
+ async getDiagnostics() {
129
+ if (this.options.tsconfig) {
130
+ return this.getDiagnosticsForTsconfig(this.options.tsconfig);
131
+ }
132
+ return await Promise.all(this.docManager.getAllOpenedByClient().map(async (doc) => {
133
+ const uri = doc[1].uri;
134
+ return await this.getDiagnosticsForFile(uri);
135
+ }));
136
+ }
137
+ async getDiagnosticsForTsconfig(tsconfigPath) {
138
+ const lsContainer = await this.getLSContainer(tsconfigPath);
139
+ const map = (diagnostic, range) => {
140
+ const file = diagnostic.file;
141
+ range ??= file
142
+ ? (0, utils_2.convertRange)({ positionAt: file.getLineAndCharacterOfPosition.bind(file) }, diagnostic)
143
+ : { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
144
+ return {
145
+ range: range,
146
+ severity: (0, utils_2.mapSeverity)(diagnostic.category),
147
+ source: diagnostic.source,
148
+ message: typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
149
+ code: diagnostic.code,
150
+ tags: (0, utils_2.getDiagnosticTag)(diagnostic)
151
+ };
152
+ };
153
+ if (lsContainer.configErrors.some((error) => error.category === typescript_1.default.DiagnosticCategory.Error)) {
154
+ return reportConfigError();
155
+ }
156
+ const lang = lsContainer.getService();
157
+ if (lsContainer.configErrors.some((error) => error.category === typescript_1.default.DiagnosticCategory.Error)) {
158
+ return reportConfigError();
159
+ }
160
+ const files = lang.getProgram()?.getSourceFiles() || [];
161
+ const options = lang.getProgram()?.getCompilerOptions() || {};
162
+ const diagnostics = await Promise.all(files.map((file) => {
163
+ const uri = (0, utils_3.pathToUrl)(file.fileName);
164
+ const doc = this.docManager.get(uri);
165
+ if (doc) {
166
+ this.docManager.markAsOpenedInClient(uri);
167
+ return this.getDiagnosticsForFile(uri);
168
+ }
169
+ else {
170
+ // This check is done inside TS mostly, too, but for some diagnostics like suggestions it
171
+ // doesn't apply to all code paths. That's why we do it here, too.
172
+ const skipDiagnosticsForFile = (options.skipLibCheck && file.isDeclarationFile) ||
173
+ (options.skipDefaultLibCheck && file.hasNoDefaultLib) ||
174
+ lsContainer.isShimFiles(file.fileName) ||
175
+ // ignore JS files in node_modules
176
+ /\/node_modules\/.+\.(c|m)?js$/.test(file.fileName);
177
+ const snapshot = lsContainer.snapshotManager.get(file.fileName);
178
+ const isKitFile = snapshot?.kitFile ?? false;
179
+ const diagnostics = [];
180
+ if (!skipDiagnosticsForFile) {
181
+ const diagnosticSources = [
182
+ 'getSyntacticDiagnostics',
183
+ 'getSuggestionDiagnostics',
184
+ 'getSemanticDiagnostics'
185
+ ];
186
+ for (const diagnosticSource of diagnosticSources) {
187
+ for (let diagnostic of lang[diagnosticSource](file.fileName)) {
188
+ if (!diagnostic.start || !diagnostic.length || !isKitFile) {
189
+ diagnostics.push(map(diagnostic));
190
+ continue;
191
+ }
192
+ let range = undefined;
193
+ const inGenerated = (0, utils_1.isInGeneratedCode)(file.text, diagnostic.start, diagnostic.start + diagnostic.length);
194
+ if (inGenerated && snapshot) {
195
+ const pos = snapshot.getOriginalPosition(snapshot.positionAt(diagnostic.start));
196
+ range = {
197
+ start: pos,
198
+ end: {
199
+ line: pos.line,
200
+ // adjust length so it doesn't spill over to the next line
201
+ character: pos.character + 1
202
+ }
203
+ };
204
+ // If not one of the specific error messages then filter out
205
+ if (diagnostic.code === 2307) {
206
+ diagnostic = {
207
+ ...diagnostic,
208
+ messageText: typeof diagnostic.messageText === 'string' &&
209
+ diagnostic.messageText.includes('./$types')
210
+ ? diagnostic.messageText +
211
+ ` (this likely means that SvelteKit's type generation didn't run yet - try running it by executing 'npm run dev' or 'npm run build')`
212
+ : diagnostic.messageText
213
+ };
214
+ }
215
+ else if (diagnostic.code === 2694) {
216
+ diagnostic = {
217
+ ...diagnostic,
218
+ messageText: typeof diagnostic.messageText === 'string' &&
219
+ diagnostic.messageText.includes('/$types')
220
+ ? diagnostic.messageText +
221
+ ` (this likely means that SvelteKit's generated types are out of date - try rerunning it by executing 'npm run dev' or 'npm run build')`
222
+ : diagnostic.messageText
223
+ };
224
+ }
225
+ else if (diagnostic.code !==
226
+ 2355 /* A function whose declared type is neither 'void' nor 'any' must return a value */) {
227
+ continue;
228
+ }
229
+ }
230
+ diagnostics.push(map(diagnostic, range));
231
+ }
232
+ }
233
+ }
234
+ return {
235
+ filePath: file.fileName,
236
+ text: snapshot?.originalText ?? file.text,
237
+ diagnostics
238
+ };
239
+ }
240
+ }));
241
+ if (lsContainer.configErrors.length) {
242
+ diagnostics.push(...reportConfigError());
243
+ }
244
+ return diagnostics;
245
+ function reportConfigError() {
246
+ const grouped = (0, lodash_1.groupBy)(lsContainer.configErrors, (error) => error.file?.fileName ?? tsconfigPath);
247
+ return Object.entries(grouped).map(([filePath, errors]) => ({
248
+ filePath,
249
+ text: '',
250
+ diagnostics: errors.map((diagnostic) => map(diagnostic))
251
+ }));
252
+ }
253
+ }
254
+ async getDiagnosticsForFile(uri) {
255
+ const diagnostics = await this.pluginHost.getDiagnostics({ uri });
256
+ return {
257
+ filePath: (0, utils_3.urlToPath)(uri) || '',
258
+ text: this.docManager.get(uri)?.getText() || '',
259
+ diagnostics
260
+ };
261
+ }
262
+ getLSContainer(tsconfigPath) {
263
+ if (!this.lsAndTSDocResolver) {
264
+ throw new Error('Cannot run with tsconfig path without LS/TSdoc resolver');
265
+ }
266
+ return this.lsAndTSDocResolver.getTSService(tsconfigPath);
267
+ }
268
+ /**
269
+ * Gets the watch directories based on the tsconfig include patterns.
270
+ * Returns null if no tsconfig is specified.
271
+ */
272
+ async getWatchDirectories() {
273
+ if (!this.options.tsconfig) {
274
+ return null;
275
+ }
276
+ const lsContainer = await this.getLSContainer(this.options.tsconfig);
277
+ const projectConfig = lsContainer.getProjectConfig();
278
+ if (!projectConfig.wildcardDirectories) {
279
+ return null;
280
+ }
281
+ return Object.entries(projectConfig.wildcardDirectories).map(([dir, flags]) => ({
282
+ path: dir,
283
+ recursive: !!(flags & typescript_1.default.WatchDirectoryFlags.Recursive)
284
+ }));
285
+ }
286
+ }
287
+ exports.SvelteCheck = SvelteCheck;
288
+ //# sourceMappingURL=svelte-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svelte-check.js","sourceRoot":"","sources":["../../src/svelte-check.ts"],"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C;YAC5E,IAAI,EAAE,GAAG;YACT,SAAS,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,oBAAE,CAAC,mBAAmB,CAAC,SAAS,CAAC;SAC1D,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAnVD,kCAmVC"}
@@ -0,0 +1,111 @@
1
+ import { Node } from 'vscode-html-languageservice';
2
+ import { Position, Range } from 'vscode-languageserver';
3
+ type Predicate<T> = (x: T) => boolean;
4
+ export declare function not<T>(predicate: Predicate<T>): (x: T) => boolean;
5
+ export declare function or<T>(...predicates: Array<Predicate<T>>): (x: T) => boolean;
6
+ export declare function and<T>(...predicates: Array<Predicate<T>>): (x: T) => boolean;
7
+ export declare function unique<T>(array: T[]): T[];
8
+ export declare function clamp(num: number, min: number, max: number): number;
9
+ export declare function urlToPath(stringUrl: string): string | null;
10
+ export declare function pathToUrl(path: string): string;
11
+ /**
12
+ * Some paths (on windows) start with a upper case driver letter, some don't.
13
+ * This is normalized here.
14
+ */
15
+ export declare function normalizePath(path: string): string;
16
+ /**
17
+ * URIs coming from the client could be encoded in a different
18
+ * way than expected / than the internal services create them.
19
+ * This normalizes them to be the same as the internally generated ones.
20
+ */
21
+ export declare function normalizeUri(uri: string): string;
22
+ /**
23
+ * Given a path like foo/bar or foo/bar.svelte , returns its last path
24
+ * (bar or bar.svelte in this example).
25
+ */
26
+ export declare function getLastPartOfPath(path: string): string;
27
+ export declare function flatten<T>(arr: Array<T | T[]>): T[];
28
+ /**
29
+ * Map or keep original (passthrough) if the mapper returns undefined.
30
+ */
31
+ export declare function passMap<T>(array: T[], mapper: (x: T) => void | T[]): (T | T[])[];
32
+ export declare function isInRange(range: Range, positionToTest: Position): boolean;
33
+ export declare function isZeroLengthRange(range: Range): boolean;
34
+ export declare function isRangeStartAfterEnd(range: Range): boolean;
35
+ export declare function swapRangeStartEndIfNecessary(range: Range): Range;
36
+ export declare function moveRangeStartToEndIfNecessary(range: Range): Range;
37
+ export declare function isBeforeOrEqualToPosition(position: Position, positionToTest: Position): boolean;
38
+ export declare function isPositionEqual(position1: Position, position2: Position): boolean;
39
+ export declare function isNotNullOrUndefined<T>(val: T | undefined | null): val is T;
40
+ /**
41
+ * Debounces a function but cancels previous invocation only if
42
+ * a second function determines it should.
43
+ *
44
+ * @param fn The function with it's argument
45
+ * @param determineIfSame The function which determines if the previous invocation should be canceld or not
46
+ * @param miliseconds Number of miliseconds to debounce
47
+ */
48
+ export declare function debounceSameArg<T>(fn: (arg: T) => void, shouldCancelPrevious: (newArg: T, prevArg?: T) => boolean, miliseconds: number): (arg: T) => void;
49
+ /**
50
+ * Debounces a function but also waits at minimum the specified number of miliseconds until
51
+ * the next invocation. This avoids needless calls when a synchronous call (like diagnostics)
52
+ * took too long and the whole timeout of the next call was eaten up already.
53
+ *
54
+ * @param fn The function
55
+ * @param miliseconds Number of miliseconds to debounce/throttle
56
+ */
57
+ export declare function debounceThrottle(fn: () => void, miliseconds: number): () => void;
58
+ /**
59
+ * Like str.lastIndexOf, but for regular expressions. Note that you need to provide the g-flag to your RegExp!
60
+ */
61
+ export declare function regexLastIndexOf(text: string, regex: RegExp, endPos?: number): number;
62
+ /**
63
+ * Like str.indexOf, but for regular expressions.
64
+ */
65
+ export declare function regexIndexOf(text: string, regex: RegExp, startPos?: number): number;
66
+ /**
67
+ * Get all matches of a regexp.
68
+ */
69
+ export declare function getRegExpMatches(regex: RegExp, str: string): RegExpExecArray[];
70
+ /**
71
+ * Function to modify each line of a text, preserving the line break style (`\n` or `\r\n`)
72
+ */
73
+ export declare function modifyLines(text: string, replacementFn: (line: string, lineIdx: number) => string): string;
74
+ export declare function isSamePosition(position: Position, another: Position): boolean;
75
+ /**
76
+ * Like array.filter, but asynchronous
77
+ */
78
+ export declare function filterAsync<T>(array: T[], predicate: (t: T, idx: number) => Promise<boolean>): Promise<T[]>;
79
+ export declare function getIndent(text: string): string;
80
+ /**
81
+ *
82
+ * The html language service is case insensitive, and would provide
83
+ * hover/ completion info for Svelte components like `Option` which have
84
+ * the same name like a html tag.
85
+ *
86
+ * Also, svelte directives like action and event modifier only work
87
+ * with element not component
88
+ */
89
+ export declare function possiblyComponent(node: Node): boolean;
90
+ export declare function possiblyComponent(tagName: string): boolean;
91
+ /**
92
+ * If the object if it has entries, else undefined
93
+ */
94
+ export declare function returnObjectIfHasKeys<T>(obj: T | undefined): T | undefined;
95
+ /**
96
+ * adopted from https://github.com/microsoft/TypeScript/blob/8192d550496d884263e292488e325ae96893dc78/src/compiler/core.ts#L1769-L1807
97
+ * see the comment there about why we can't just use String.prototype.toLowerCase() here
98
+ */
99
+ export declare function toFileNameLowerCase(x: string): string;
100
+ export type GetCanonicalFileName = (fileName: string) => string;
101
+ /**
102
+ * adopted from https://github.com/microsoft/TypeScript/blob/8192d550496d884263e292488e325ae96893dc78/src/compiler/core.ts#L2312
103
+ */
104
+ export declare function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName;
105
+ export declare function memoize<T>(callback: () => T): () => T;
106
+ export declare function removeLineWithString(str: string, keyword: string): string;
107
+ /**
108
+ * Traverses a string and returns the index of the end character, taking into account quotes, curlies and generic tags.
109
+ */
110
+ export declare function traverseTypeString(str: string, start: number, endChar: string): number;
111
+ export {};