@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,116 @@
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.JsOrTsComponentInfoProvider = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const utils_1 = require("../../utils");
9
+ const utils_2 = require("./features/utils");
10
+ class JsOrTsComponentInfoProvider {
11
+ constructor(typeChecker, classType, useSvelte5PlusPropsParameter = false) {
12
+ this.typeChecker = typeChecker;
13
+ this.classType = classType;
14
+ this.useSvelte5PlusPropsParameter = useSvelte5PlusPropsParameter;
15
+ }
16
+ getEvents() {
17
+ const eventType = this.getType(this.useSvelte5PlusPropsParameter ? '$$events' : '$$events_def');
18
+ if (!eventType) {
19
+ return [];
20
+ }
21
+ return this.mapPropertiesOfType(eventType);
22
+ }
23
+ getSlotLets(slot = 'default') {
24
+ const slotType = this.getType(this.useSvelte5PlusPropsParameter ? '$$slots' : '$$slot_def');
25
+ if (!slotType) {
26
+ return [];
27
+ }
28
+ const slotLets = slotType.getProperties().find((prop) => prop.name === slot);
29
+ if (!slotLets?.valueDeclaration) {
30
+ return [];
31
+ }
32
+ const slotLetsType = this.typeChecker.getTypeOfSymbolAtLocation(slotLets, slotLets.valueDeclaration);
33
+ return this.mapPropertiesOfType(slotLetsType);
34
+ }
35
+ getProps() {
36
+ if (!this.useSvelte5PlusPropsParameter) {
37
+ const props = this.getType('$$prop_def');
38
+ if (!props) {
39
+ return [];
40
+ }
41
+ return this.mapPropertiesOfType(props);
42
+ }
43
+ return this.mapPropertiesOfType(this.classType).filter((prop) => !prop.name.startsWith('$$'));
44
+ }
45
+ getType(classProperty) {
46
+ const symbol = this.classType.getProperty(classProperty);
47
+ if (!symbol?.valueDeclaration) {
48
+ return null;
49
+ }
50
+ return this.typeChecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
51
+ }
52
+ mapPropertiesOfType(type) {
53
+ return type
54
+ .getProperties()
55
+ .map((prop) => {
56
+ // type would still be correct when there're multiple declarations
57
+ const declaration = prop.valueDeclaration ??
58
+ prop.declarations?.[0] ??
59
+ // very complex types are hidden on this thing for some reason
60
+ prop?.links?.mappedType?.declaration;
61
+ if (!declaration) {
62
+ return;
63
+ }
64
+ return {
65
+ name: prop.name,
66
+ type: this.typeChecker.typeToString(this.typeChecker.getTypeOfSymbolAtLocation(prop, declaration)),
67
+ doc: typescript_1.default.displayPartsToString(prop.getDocumentationComment(this.typeChecker))
68
+ };
69
+ })
70
+ .filter(utils_1.isNotNullOrUndefined);
71
+ }
72
+ /**
73
+ * The result of this shouldn't be cached as it could lead to memory leaks. The type checker
74
+ * could become old and then multiple versions of it could exist.
75
+ */
76
+ static create(lang, def, isSvelte5Plus) {
77
+ const program = lang.getProgram();
78
+ const sourceFile = program?.getSourceFile(def.fileName);
79
+ if (!program || !sourceFile) {
80
+ return null;
81
+ }
82
+ const defIdentifier = (0, utils_2.findContainingNode)(sourceFile, def.textSpan, typescript_1.default.isIdentifier);
83
+ if (!defIdentifier) {
84
+ return null;
85
+ }
86
+ const typeChecker = program.getTypeChecker();
87
+ const componentSymbol = typeChecker.getSymbolAtLocation(defIdentifier);
88
+ if (!componentSymbol) {
89
+ return null;
90
+ }
91
+ const type = typeChecker.getTypeOfSymbolAtLocation(componentSymbol, defIdentifier);
92
+ if (type.isClass()) {
93
+ return new JsOrTsComponentInfoProvider(typeChecker, type);
94
+ }
95
+ const constructorSignatures = type.getConstructSignatures();
96
+ if (constructorSignatures.length === 1) {
97
+ return new JsOrTsComponentInfoProvider(typeChecker, constructorSignatures[0].getReturnType());
98
+ }
99
+ if (!isSvelte5Plus) {
100
+ return null;
101
+ }
102
+ const signatures = type.getCallSignatures();
103
+ if (signatures.length !== 1) {
104
+ return null;
105
+ }
106
+ const propsParameter = signatures[0].parameters[1];
107
+ if (!propsParameter) {
108
+ return null;
109
+ }
110
+ const propsParameterType = typeChecker.getTypeOfSymbol(propsParameter);
111
+ return new JsOrTsComponentInfoProvider(typeChecker, propsParameterType,
112
+ /** useSvelte5PlusPropsParameter */ true);
113
+ }
114
+ }
115
+ exports.JsOrTsComponentInfoProvider = JsOrTsComponentInfoProvider;
116
+ //# sourceMappingURL=ComponentInfoProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentInfoProvider.js","sourceRoot":"","sources":["../../../../src/plugins/typescript/ComponentInfoProvider.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAC5B,uCAAmD;AACnD,4CAAsD;AAUtD,MAAa,2BAA2B;IACpC,YACqB,WAA2B,EAC3B,SAAkB,EAClB,+BAAwC,KAAK;QAF7C,gBAAW,GAAX,WAAW,CAAgB;QAC3B,cAAS,GAAT,SAAS,CAAS;QAClB,iCAA4B,GAA5B,4BAA4B,CAAiB;IAC/D,CAAC;IAEJ,SAAS;QACL,MAAM,SAAS,GAAG,IAAI,CAAC,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AC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,kBAAkB,GAAG,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAEvE,OAAO,IAAI,2BAA2B,CAClC,WAAW,EACX,kBAAkB;QAClB,mCAAmC,CAAC,IAAI,CAC3C,CAAC;IACN,CAAC;CACJ;AAvJD,kEAuJC"}
@@ -0,0 +1,10 @@
1
+ import { TraceMap } from '@jridgewell/trace-mapping';
2
+ import { Position } from 'vscode-languageserver';
3
+ import { SourceMapDocumentMapper } from '../../lib/documents';
4
+ export declare class ConsumerDocumentMapper extends SourceMapDocumentMapper {
5
+ private nrPrependesLines;
6
+ constructor(traceMap: TraceMap, sourceUri: string, nrPrependesLines: number);
7
+ getOriginalPosition(generatedPosition: Position): Position;
8
+ getGeneratedPosition(originalPosition: Position): Position;
9
+ isInGenerated(): boolean;
10
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsumerDocumentMapper = void 0;
4
+ const vscode_languageserver_1 = require("vscode-languageserver");
5
+ const documents_1 = require("../../lib/documents");
6
+ class ConsumerDocumentMapper extends documents_1.SourceMapDocumentMapper {
7
+ constructor(traceMap, sourceUri, nrPrependesLines) {
8
+ super(traceMap, sourceUri);
9
+ this.nrPrependesLines = nrPrependesLines;
10
+ }
11
+ getOriginalPosition(generatedPosition) {
12
+ return super.getOriginalPosition(vscode_languageserver_1.Position.create(generatedPosition.line - this.nrPrependesLines, generatedPosition.character));
13
+ }
14
+ getGeneratedPosition(originalPosition) {
15
+ const result = super.getGeneratedPosition(originalPosition);
16
+ result.line += this.nrPrependesLines;
17
+ return result;
18
+ }
19
+ isInGenerated() {
20
+ // always return true and map outliers case by case
21
+ return true;
22
+ }
23
+ }
24
+ exports.ConsumerDocumentMapper = ConsumerDocumentMapper;
25
+ //# sourceMappingURL=DocumentMapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentMapper.js","sourceRoot":"","sources":["../../../../src/plugins/typescript/DocumentMapper.ts"],"names":[],"mappings":";;;AACA,iEAAiD;AACjD,mDAA8D;AAE9D,MAAa,sBAAuB,SAAQ,mCAAuB;IAC/D,YACI,QAAkB,EAClB,SAAiB,EACT,gBAAwB;QAEhC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAFnB,qBAAgB,GAAhB,gBAAgB,CAAQ;IAGpC,CAAC;IAED,mBAAmB,CAAC,iBAA2B;QAC3C,OAAO,KAAK,CAAC,mBAAmB,CAC5B,gCAAQ,CAAC,MAAM,CACX,iBAAiB,CAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,EAC9C,iBAAiB,CAAC,SAAS,CAC9B,CACJ,CAAC;IACN,CAAC;IAED,oBAAoB,CAAC,gBAA0B;QAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;QAC5D,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,gBAAgB,CAAC;QACrC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,aAAa;QACT,mDAAmD;QACnD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5BD,wDA4BC"}
@@ -0,0 +1,173 @@
1
+ import { EncodedSourceMap } from "@jridgewell/trace-mapping";
2
+ import { TemplateNode } from "svelte/types/compiler/interfaces";
3
+ import { IExportedNames } from "svelte2tsx";
4
+ import ts from "typescript";
5
+ import { Position, Range, TextDocumentContentChangeEvent } from "vscode-languageserver";
6
+ import { Document, DocumentMapper, IdentityMapper, TagInformation, FilePosition } from "../../lib/documents";
7
+ import { SvelteNode, SvelteNodeWalker } from "./svelte-ast-utils";
8
+ import { MacroforgeAugmentationConfig, MacroDiagnostic } from "./macroforgeAugmenter";
9
+ /**
10
+ * An error which occurred while trying to parse/preprocess the svelte file contents.
11
+ */
12
+ export interface ParserError {
13
+ message: string;
14
+ range: Range;
15
+ code: number;
16
+ }
17
+ /**
18
+ * Initial version of snapshots.
19
+ */
20
+ export declare const INITIAL_VERSION = 0;
21
+ /**
22
+ * A document snapshot suitable for the ts language service and the plugin.
23
+ * Can be a real ts/js file or a virtual ts/js file which is generated from a Svelte file.
24
+ */
25
+ export interface DocumentSnapshot extends ts.IScriptSnapshot, DocumentMapper {
26
+ version: number;
27
+ filePath: string;
28
+ scriptKind: ts.ScriptKind;
29
+ scriptInfo: TagInformation | null;
30
+ macroDiagnostics: MacroDiagnostic[];
31
+ positionAt(offset: number): Position;
32
+ offsetAt(position: Position): number;
33
+ /**
34
+ * Convenience function for getText(0, getLength())
35
+ */
36
+ getFullText(): string;
37
+ isOpenedInClient(): boolean;
38
+ }
39
+ /**
40
+ * Options that apply to svelte files.
41
+ */
42
+ export interface SvelteSnapshotOptions {
43
+ parse: typeof import("svelte/compiler").parse | undefined;
44
+ version: string | undefined;
45
+ transformOnTemplateError: boolean;
46
+ typingsNamespace: string;
47
+ }
48
+ export declare namespace DocumentSnapshot {
49
+ /**
50
+ * Returns a svelte snapshot from a svelte document.
51
+ * @param document the svelte document
52
+ * @param options options that apply to the svelte document
53
+ */
54
+ function fromDocument(document: Document, options: SvelteSnapshotOptions, macroforgeConfig?: MacroforgeAugmentationConfig): SvelteDocumentSnapshot;
55
+ /**
56
+ * Returns a svelte or ts/js snapshot from a file path, depending on the file contents.
57
+ * @param filePath path to the js/ts/svelte file
58
+ * @param createDocument function that is used to create a document in case it's a Svelte file
59
+ * @param options options that apply in case it's a svelte file
60
+ */
61
+ function fromFilePath(filePath: string, createDocument: (filePath: string, text: string) => Document, options: SvelteSnapshotOptions, tsSystem: ts.System, macroforgeConfig?: MacroforgeAugmentationConfig): SvelteDocumentSnapshot | JSOrTSDocumentSnapshot;
62
+ /**
63
+ * Returns a ts/js snapshot from a file path.
64
+ * @param filePath path to the js/ts file
65
+ * @param options options that apply in case it's a svelte file
66
+ */
67
+ function fromNonSvelteFilePath(filePath: string, tsSystem: ts.System, macroforgeConfig?: MacroforgeAugmentationConfig): JSOrTSDocumentSnapshot;
68
+ /**
69
+ * Returns a svelte snapshot from a file path.
70
+ * @param filePath path to the svelte file
71
+ * @param createDocument function that is used to create a document
72
+ * @param options options that apply in case it's a svelte file
73
+ */
74
+ function fromSvelteFilePath(filePath: string, createDocument: (filePath: string, text: string) => Document, options: SvelteSnapshotOptions, tsSystem: ts.System, macroforgeConfig?: MacroforgeAugmentationConfig): SvelteDocumentSnapshot;
75
+ }
76
+ /**
77
+ * A svelte document snapshot suitable for the TS language service and the plugin.
78
+ * It contains the generated code (Svelte->TS/JS) so the TS language service can understand it.
79
+ */
80
+ export declare class SvelteDocumentSnapshot implements DocumentSnapshot {
81
+ readonly parent: Document;
82
+ readonly parserError: ParserError | null;
83
+ readonly scriptKind: ts.ScriptKind;
84
+ readonly svelteVersion: string | undefined;
85
+ private text;
86
+ private readonly nrPrependedLines;
87
+ private readonly exportedNames;
88
+ private readonly tsxMap?;
89
+ private readonly htmlAst?;
90
+ private readonly macroforgeConfig?;
91
+ private mapper?;
92
+ private lineOffsets?;
93
+ private url;
94
+ version: number;
95
+ isSvelte5Plus: boolean;
96
+ constructor(parent: Document, parserError: ParserError | null, scriptKind: ts.ScriptKind, svelteVersion: string | undefined, text: string, nrPrependedLines: number, exportedNames: IExportedNames, tsxMap?: EncodedSourceMap | undefined, htmlAst?: TemplateNode | undefined, macroforgeConfig?: MacroforgeAugmentationConfig | undefined);
97
+ get filePath(): string;
98
+ macroDiagnostics: MacroDiagnostic[];
99
+ private applyMacroforgeAugmentation;
100
+ get scriptInfo(): TagInformation | null;
101
+ get moduleScriptInfo(): TagInformation | null;
102
+ getOriginalText(range?: Range): string;
103
+ getText(start: number, end: number): string;
104
+ getLength(): number;
105
+ getFullText(): string;
106
+ getChangeRange(): undefined;
107
+ positionAt(offset: number): Position;
108
+ offsetAt(position: Position): number;
109
+ getLineContainingOffset(offset: number): string;
110
+ hasProp(name: string): boolean;
111
+ svelteNodeAt(positionOrOffset: number | Position): SvelteNode | null;
112
+ walkSvelteAst(walker: SvelteNodeWalker): void;
113
+ getOriginalPosition(pos: Position): Position;
114
+ getGeneratedPosition(pos: Position): Position;
115
+ isInGenerated(pos: Position): boolean;
116
+ getURL(): string;
117
+ isOpenedInClient(): boolean;
118
+ private getLineOffsets;
119
+ private getMapper;
120
+ private initMapper;
121
+ }
122
+ /**
123
+ * A js/ts document snapshot suitable for the ts language service and the plugin.
124
+ * Since no mapping has to be done here, it also implements the mapper interface.
125
+ * If it's a SvelteKit file (e.g. +page.ts), types will be auto-added if not explicitly typed.
126
+ */
127
+ export declare class JSOrTSDocumentSnapshot extends IdentityMapper implements DocumentSnapshot {
128
+ version: number;
129
+ readonly filePath: string;
130
+ private text;
131
+ private readonly macroforgeConfig?;
132
+ scriptKind: ts.ScriptKind;
133
+ scriptInfo: null;
134
+ originalText: string;
135
+ kitFile: boolean;
136
+ private lineOffsets?;
137
+ private internalLineOffsets?;
138
+ private addedCode;
139
+ private paramsPath;
140
+ private serverHooksPath;
141
+ private clientHooksPath;
142
+ private universalHooksPath;
143
+ private openedByClient;
144
+ isOpenedInClient(): boolean;
145
+ constructor(version: number, filePath: string, text: string, macroforgeConfig?: MacroforgeAugmentationConfig | undefined);
146
+ getText(start: number, end: number): string;
147
+ getLength(): number;
148
+ getFullText(): string;
149
+ getChangeRange(): undefined;
150
+ positionAt(offset: number): Position;
151
+ offsetAt(position: Position): number;
152
+ getGeneratedPosition(originalPosition: Position): Position;
153
+ getOriginalPosition(generatedPosition: Position): Position;
154
+ update(changes: TextDocumentContentChangeEvent[]): void;
155
+ protected getLineOffsets(): number[];
156
+ private originalOffsetAt;
157
+ private originalPositionAt;
158
+ private getOriginalLineOffsets;
159
+ private adjustText;
160
+ macroDiagnostics: MacroDiagnostic[];
161
+ private applyMacroforgeAugmentation;
162
+ private createSource;
163
+ }
164
+ export declare class DtsDocumentSnapshot extends JSOrTSDocumentSnapshot implements DocumentMapper {
165
+ private tsSys;
166
+ private traceMap;
167
+ private mapperInitialized;
168
+ constructor(version: number, filePath: string, text: string, tsSys: ts.System, macroforgeConfig?: MacroforgeAugmentationConfig);
169
+ getOriginalFilePosition(generatedPosition: Position): FilePosition;
170
+ private initMapper;
171
+ private initMapperByRawSourceMap;
172
+ private logFailedToResolveSourceMap;
173
+ }