@kerebron/extension-yjs 0.4.5 → 0.4.6

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 (270) hide show
  1. package/README.md +50 -128
  2. package/esm/{extension-yjs/src/ExtensionYjs.d.ts → ExtensionYjs.d.ts} +2 -3
  3. package/esm/ExtensionYjs.d.ts.map +1 -0
  4. package/esm/{extension-yjs/src/ExtensionYjs.js → ExtensionYjs.js} +1 -2
  5. package/esm/convertUtils.d.ts.map +1 -0
  6. package/esm/keys.d.ts.map +1 -0
  7. package/esm/lib.d.ts.map +1 -0
  8. package/esm/{extension-yjs/src/userColors.d.ts → userColors.d.ts} +0 -1
  9. package/esm/userColors.d.ts.map +1 -0
  10. package/esm/{extension-yjs/src/userColors.js → userColors.js} +0 -1
  11. package/esm/utils.d.ts.map +1 -0
  12. package/esm/{extension-yjs/src/yPositionPlugin.d.ts → yPositionPlugin.d.ts} +1 -1
  13. package/esm/yPositionPlugin.d.ts.map +1 -0
  14. package/esm/{extension-yjs/src/yPositionPlugin.js → yPositionPlugin.js} +1 -1
  15. package/esm/ySyncPlugin.d.ts.map +1 -0
  16. package/esm/{extension-yjs/src/ySyncPlugin.js → ySyncPlugin.js} +1 -1
  17. package/esm/yUndoPlugin.d.ts.map +1 -0
  18. package/package.json +8 -10
  19. package/assets/collaboration-status.css +0 -172
  20. package/esm/_dnt.polyfills.d.ts +0 -101
  21. package/esm/_dnt.polyfills.d.ts.map +0 -1
  22. package/esm/_dnt.polyfills.js +0 -127
  23. package/esm/_dnt.shims.d.ts +0 -2
  24. package/esm/_dnt.shims.d.ts.map +0 -1
  25. package/esm/_dnt.shims.js +0 -57
  26. package/esm/editor/src/CoreEditor.d.ts +0 -40
  27. package/esm/editor/src/CoreEditor.d.ts.map +0 -1
  28. package/esm/editor/src/CoreEditor.js +0 -252
  29. package/esm/editor/src/DummyEditorView.d.ts +0 -60
  30. package/esm/editor/src/DummyEditorView.d.ts.map +0 -1
  31. package/esm/editor/src/DummyEditorView.js +0 -277
  32. package/esm/editor/src/Extension.d.ts +0 -31
  33. package/esm/editor/src/Extension.d.ts.map +0 -1
  34. package/esm/editor/src/Extension.js +0 -53
  35. package/esm/editor/src/ExtensionManager.d.ts +0 -32
  36. package/esm/editor/src/ExtensionManager.d.ts.map +0 -1
  37. package/esm/editor/src/ExtensionManager.js +0 -260
  38. package/esm/editor/src/Mark.d.ts +0 -23
  39. package/esm/editor/src/Mark.d.ts.map +0 -1
  40. package/esm/editor/src/Mark.js +0 -51
  41. package/esm/editor/src/Node.d.ts +0 -32
  42. package/esm/editor/src/Node.d.ts.map +0 -1
  43. package/esm/editor/src/Node.js +0 -60
  44. package/esm/editor/src/commands/CommandManager.d.ts +0 -23
  45. package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
  46. package/esm/editor/src/commands/CommandManager.js +0 -118
  47. package/esm/editor/src/commands/baseCommandFactories.d.ts +0 -3
  48. package/esm/editor/src/commands/baseCommandFactories.d.ts.map +0 -1
  49. package/esm/editor/src/commands/baseCommandFactories.js +0 -836
  50. package/esm/editor/src/commands/createChainableState.d.ts +0 -3
  51. package/esm/editor/src/commands/createChainableState.d.ts.map +0 -1
  52. package/esm/editor/src/commands/createChainableState.js +0 -29
  53. package/esm/editor/src/commands/keyCommandFactories.d.ts +0 -3
  54. package/esm/editor/src/commands/keyCommandFactories.d.ts.map +0 -1
  55. package/esm/editor/src/commands/keyCommandFactories.js +0 -10
  56. package/esm/editor/src/commands/mod.d.ts +0 -7
  57. package/esm/editor/src/commands/mod.d.ts.map +0 -1
  58. package/esm/editor/src/commands/mod.js +0 -76
  59. package/esm/editor/src/commands/replaceCommandFactories.d.ts +0 -3
  60. package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +0 -1
  61. package/esm/editor/src/commands/replaceCommandFactories.js +0 -94
  62. package/esm/editor/src/commands/types.d.ts +0 -18
  63. package/esm/editor/src/commands/types.d.ts.map +0 -1
  64. package/esm/editor/src/commands/types.js +0 -1
  65. package/esm/editor/src/mod.d.ts +0 -9
  66. package/esm/editor/src/mod.d.ts.map +0 -1
  67. package/esm/editor/src/mod.js +0 -8
  68. package/esm/editor/src/nodeToTreeString.d.ts +0 -10
  69. package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
  70. package/esm/editor/src/nodeToTreeString.js +0 -74
  71. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +0 -6
  72. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +0 -1
  73. package/esm/editor/src/plugins/TrackSelecionPlugin.js +0 -24
  74. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +0 -23
  75. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +0 -1
  76. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +0 -163
  77. package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
  78. package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
  79. package/esm/editor/src/plugins/keymap/keymap.js +0 -125
  80. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
  81. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
  82. package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
  83. package/esm/editor/src/types.d.ts +0 -52
  84. package/esm/editor/src/types.d.ts.map +0 -1
  85. package/esm/editor/src/types.js +0 -1
  86. package/esm/editor/src/ui.d.ts +0 -15
  87. package/esm/editor/src/ui.d.ts.map +0 -1
  88. package/esm/editor/src/ui.js +0 -16
  89. package/esm/editor/src/utilities/SmartOutput.d.ts +0 -41
  90. package/esm/editor/src/utilities/SmartOutput.d.ts.map +0 -1
  91. package/esm/editor/src/utilities/SmartOutput.js +0 -228
  92. package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -9
  93. package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
  94. package/esm/editor/src/utilities/createNodeFromContent.js +0 -32
  95. package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -9
  96. package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
  97. package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
  98. package/esm/editor/src/utilities/getShadowRoot.d.ts +0 -2
  99. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +0 -1
  100. package/esm/editor/src/utilities/getShadowRoot.js +0 -16
  101. package/esm/editor/src/utilities/mod.d.ts +0 -6
  102. package/esm/editor/src/utilities/mod.d.ts.map +0 -1
  103. package/esm/editor/src/utilities/mod.js +0 -5
  104. package/esm/editor/src/utilities/toRawTextResult.d.ts +0 -3
  105. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +0 -1
  106. package/esm/editor/src/utilities/toRawTextResult.js +0 -21
  107. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +0 -8
  108. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +0 -1
  109. package/esm/extension-autocomplete/src/AutocompletePlugin.js +0 -232
  110. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +0 -17
  111. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +0 -1
  112. package/esm/extension-autocomplete/src/DefaultRenderer.js +0 -137
  113. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +0 -26
  114. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +0 -1
  115. package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +0 -30
  116. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +0 -11
  117. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +0 -1
  118. package/esm/extension-autocomplete/src/createDefaultMatcher.js +0 -58
  119. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +0 -4
  120. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +0 -1
  121. package/esm/extension-autocomplete/src/createRegexMatcher.js +0 -50
  122. package/esm/extension-autocomplete/src/mod.d.ts +0 -3
  123. package/esm/extension-autocomplete/src/mod.d.ts.map +0 -1
  124. package/esm/extension-autocomplete/src/mod.js +0 -2
  125. package/esm/extension-autocomplete/src/types.d.ts +0 -60
  126. package/esm/extension-autocomplete/src/types.d.ts.map +0 -1
  127. package/esm/extension-autocomplete/src/types.js +0 -1
  128. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +0 -15
  129. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +0 -1
  130. package/esm/extension-basic-editor/src/ExtensionHtml.js +0 -108
  131. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +0 -24
  132. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +0 -1
  133. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +0 -35
  134. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +0 -25
  135. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +0 -1
  136. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +0 -96
  137. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +0 -32
  138. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +0 -1
  139. package/esm/extension-lsp/src/DiagnosticPlugin.js +0 -131
  140. package/esm/extension-lsp/src/ExtensionLsp.d.ts +0 -25
  141. package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +0 -1
  142. package/esm/extension-lsp/src/ExtensionLsp.js +0 -126
  143. package/esm/extension-lsp/src/LSPClient.d.ts +0 -56
  144. package/esm/extension-lsp/src/LSPClient.d.ts.map +0 -1
  145. package/esm/extension-lsp/src/LSPClient.js +0 -449
  146. package/esm/extension-lsp/src/LspStatus.d.ts +0 -34
  147. package/esm/extension-lsp/src/LspStatus.d.ts.map +0 -1
  148. package/esm/extension-lsp/src/LspStatus.js +0 -127
  149. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +0 -8
  150. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +0 -1
  151. package/esm/extension-lsp/src/computeIncrementalChanges.js +0 -82
  152. package/esm/extension-lsp/src/createLspAutocomplete.d.ts +0 -23
  153. package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +0 -1
  154. package/esm/extension-lsp/src/createLspAutocomplete.js +0 -68
  155. package/esm/extension-lsp/src/workspace.d.ts +0 -62
  156. package/esm/extension-lsp/src/workspace.d.ts.map +0 -1
  157. package/esm/extension-lsp/src/workspace.js +0 -168
  158. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +0 -36
  159. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +0 -1
  160. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +0 -240
  161. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +0 -26
  162. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +0 -1
  163. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +0 -115
  164. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +0 -22
  165. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +0 -1
  166. package/esm/extension-markdown/src/ExtensionMarkdown.js +0 -48
  167. package/esm/extension-markdown/src/MarkdownParser.d.ts +0 -61
  168. package/esm/extension-markdown/src/MarkdownParser.d.ts.map +0 -1
  169. package/esm/extension-markdown/src/MarkdownParser.js +0 -249
  170. package/esm/extension-markdown/src/MarkdownSerializer.d.ts +0 -42
  171. package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +0 -1
  172. package/esm/extension-markdown/src/MarkdownSerializer.js +0 -325
  173. package/esm/extension-markdown/src/PositionMapper.d.ts +0 -15
  174. package/esm/extension-markdown/src/PositionMapper.d.ts.map +0 -1
  175. package/esm/extension-markdown/src/PositionMapper.js +0 -100
  176. package/esm/extension-markdown/src/TokenSource.d.ts +0 -11
  177. package/esm/extension-markdown/src/TokenSource.d.ts.map +0 -1
  178. package/esm/extension-markdown/src/TokenSource.js +0 -39
  179. package/esm/extension-markdown/src/mdToPmConverter.d.ts +0 -5
  180. package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +0 -1
  181. package/esm/extension-markdown/src/mdToPmConverter.js +0 -111
  182. package/esm/extension-markdown/src/pmToMdConverter.d.ts +0 -16
  183. package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +0 -1
  184. package/esm/extension-markdown/src/pmToMdConverter.js +0 -433
  185. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +0 -4
  186. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +0 -1
  187. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +0 -151
  188. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +0 -3
  189. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +0 -1
  190. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +0 -34
  191. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +0 -6
  192. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +0 -1
  193. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +0 -380
  194. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +0 -3
  195. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +0 -1
  196. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +0 -323
  197. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +0 -9
  198. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +0 -1
  199. package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +0 -308
  200. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +0 -5
  201. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +0 -1
  202. package/esm/extension-markdown/src/treeSitterTokenizer.js +0 -769
  203. package/esm/extension-markdown/src/types.d.ts +0 -28
  204. package/esm/extension-markdown/src/types.d.ts.map +0 -1
  205. package/esm/extension-markdown/src/types.js +0 -131
  206. package/esm/extension-markdown/src/utils.d.ts +0 -8
  207. package/esm/extension-markdown/src/utils.d.ts.map +0 -1
  208. package/esm/extension-markdown/src/utils.js +0 -86
  209. package/esm/extension-menu/src/CustomMenuPlugin.d.ts +0 -65
  210. package/esm/extension-menu/src/CustomMenuPlugin.d.ts.map +0 -1
  211. package/esm/extension-menu/src/CustomMenuPlugin.js +0 -1186
  212. package/esm/extension-menu/src/ExtensionCustomMenu.d.ts +0 -14
  213. package/esm/extension-menu/src/ExtensionCustomMenu.d.ts.map +0 -1
  214. package/esm/extension-menu/src/ExtensionCustomMenu.js +0 -57
  215. package/esm/extension-menu/src/buildMenu.d.ts +0 -5
  216. package/esm/extension-menu/src/buildMenu.d.ts.map +0 -1
  217. package/esm/extension-menu/src/buildMenu.js +0 -331
  218. package/esm/extension-menu/src/icons.d.ts +0 -15
  219. package/esm/extension-menu/src/icons.d.ts.map +0 -1
  220. package/esm/extension-menu/src/icons.js +0 -123
  221. package/esm/extension-menu/src/menu.d.ts +0 -81
  222. package/esm/extension-menu/src/menu.d.ts.map +0 -1
  223. package/esm/extension-menu/src/menu.js +0 -350
  224. package/esm/extension-menu/src/mod.d.ts +0 -3
  225. package/esm/extension-menu/src/mod.d.ts.map +0 -1
  226. package/esm/extension-menu/src/mod.js +0 -2
  227. package/esm/extension-menu/src/prompt.d.ts +0 -36
  228. package/esm/extension-menu/src/prompt.d.ts.map +0 -1
  229. package/esm/extension-menu/src/prompt.js +0 -158
  230. package/esm/extension-yjs/src/CollaborationStatus.d.ts +0 -60
  231. package/esm/extension-yjs/src/CollaborationStatus.d.ts.map +0 -1
  232. package/esm/extension-yjs/src/CollaborationStatus.js +0 -287
  233. package/esm/extension-yjs/src/ExtensionYjs.d.ts.map +0 -1
  234. package/esm/extension-yjs/src/convertUtils.d.ts.map +0 -1
  235. package/esm/extension-yjs/src/keys.d.ts.map +0 -1
  236. package/esm/extension-yjs/src/lib.d.ts.map +0 -1
  237. package/esm/extension-yjs/src/userColors.d.ts.map +0 -1
  238. package/esm/extension-yjs/src/utils.d.ts.map +0 -1
  239. package/esm/extension-yjs/src/yPositionPlugin.d.ts.map +0 -1
  240. package/esm/extension-yjs/src/ySyncPlugin.d.ts.map +0 -1
  241. package/esm/extension-yjs/src/yUndoPlugin.d.ts.map +0 -1
  242. package/esm/tree-sitter-shim/src/main.d.ts +0 -15
  243. package/esm/tree-sitter-shim/src/main.d.ts.map +0 -1
  244. package/esm/tree-sitter-shim/src/main.js +0 -25
  245. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +0 -6
  246. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +0 -1
  247. package/esm/tree-sitter-shim/src/tree_sitter/node.js +0 -1
  248. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +0 -7
  249. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +0 -1
  250. package/esm/tree-sitter-shim/src/tree_sitter/parser.js +0 -5
  251. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +0 -6
  252. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +0 -1
  253. package/esm/tree-sitter-shim/src/tree_sitter/tree.js +0 -1
  254. package/esm/wasm/src/mod.d.ts +0 -12
  255. package/esm/wasm/src/mod.d.ts.map +0 -1
  256. package/esm/wasm/src/mod.js +0 -48
  257. package/esm/wasm/wasm.d.ts +0 -138
  258. package/esm/wasm/wasm.d.ts.map +0 -1
  259. package/esm/wasm/wasm.js +0 -120
  260. /package/esm/{extension-yjs/src/convertUtils.d.ts → convertUtils.d.ts} +0 -0
  261. /package/esm/{extension-yjs/src/convertUtils.js → convertUtils.js} +0 -0
  262. /package/esm/{extension-yjs/src/keys.d.ts → keys.d.ts} +0 -0
  263. /package/esm/{extension-yjs/src/keys.js → keys.js} +0 -0
  264. /package/esm/{extension-yjs/src/lib.d.ts → lib.d.ts} +0 -0
  265. /package/esm/{extension-yjs/src/lib.js → lib.js} +0 -0
  266. /package/esm/{extension-yjs/src/utils.d.ts → utils.d.ts} +0 -0
  267. /package/esm/{extension-yjs/src/utils.js → utils.js} +0 -0
  268. /package/esm/{extension-yjs/src/ySyncPlugin.d.ts → ySyncPlugin.d.ts} +0 -0
  269. /package/esm/{extension-yjs/src/yUndoPlugin.d.ts → yUndoPlugin.d.ts} +0 -0
  270. /package/esm/{extension-yjs/src/yUndoPlugin.js → yUndoPlugin.js} +0 -0
@@ -1,449 +0,0 @@
1
- import { MessageType, TextDocumentSyncKind, } from 'vscode-languageserver-protocol';
2
- import { DefaultWorkspace, } from './workspace.js';
3
- const defaultNotificationHandlers = {
4
- 'window/logMessage': (client, params) => {
5
- if (params.type == MessageType.Error) {
6
- console.error('[lsp] ' + params.message);
7
- }
8
- else if (params.type == MessageType.Warning) {
9
- console.warn('[lsp] ' + params.message);
10
- }
11
- else if (params.type == MessageType.Info) {
12
- console.info('[lsp] ' + params.message);
13
- }
14
- else if (params.type == MessageType.Log) {
15
- console.log('[lsp] ' + params.message);
16
- }
17
- },
18
- 'window/showMessage': (client, params) => {
19
- if (params.type > MessageType.Info)
20
- return;
21
- for (const f of client.workspace.files) {
22
- const ui = f.getUi();
23
- if (!ui)
24
- continue;
25
- ui.showMessage(params.message);
26
- }
27
- },
28
- };
29
- class Request {
30
- constructor(id, params, timeout) {
31
- Object.defineProperty(this, "id", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: id
36
- });
37
- Object.defineProperty(this, "params", {
38
- enumerable: true,
39
- configurable: true,
40
- writable: true,
41
- value: params
42
- });
43
- Object.defineProperty(this, "timeout", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: timeout
48
- });
49
- Object.defineProperty(this, "promise", {
50
- enumerable: true,
51
- configurable: true,
52
- writable: true,
53
- value: void 0
54
- });
55
- this.promise = new Promise((resolve, reject) => {
56
- this.resolve = resolve;
57
- this.reject = reject;
58
- });
59
- }
60
- }
61
- const clientCapabilities = {
62
- general: {
63
- markdown: {
64
- parser: 'marked',
65
- },
66
- },
67
- textDocument: {
68
- publishDiagnostics: { versionSupport: true },
69
- completion: {
70
- completionItem: {
71
- snippetSupport: true,
72
- documentationFormat: ['plaintext', 'markdown'],
73
- insertReplaceSupport: false,
74
- },
75
- completionList: {
76
- itemDefaults: ['commitCharacters', 'editRange', 'insertTextFormat'],
77
- },
78
- completionItemKind: { valueSet: [] },
79
- contextSupport: true,
80
- },
81
- hover: {
82
- contentFormat: ['markdown', 'plaintext'],
83
- },
84
- // formatting: {},
85
- // rename: {},
86
- signatureHelp: {
87
- contextSupport: true,
88
- signatureInformation: {
89
- documentationFormat: ['markdown', 'plaintext'],
90
- parameterInformation: { labelOffsetSupport: true },
91
- activeParameterSupport: true,
92
- },
93
- },
94
- definition: {},
95
- declaration: {},
96
- implementation: {},
97
- typeDefinition: {},
98
- references: {},
99
- diagnostic: {},
100
- },
101
- window: {
102
- showMessage: {},
103
- },
104
- };
105
- export class LSPError extends Error {
106
- constructor() {
107
- super(...arguments);
108
- Object.defineProperty(this, "isTimeout", {
109
- enumerable: true,
110
- configurable: true,
111
- writable: true,
112
- value: false
113
- });
114
- Object.defineProperty(this, "isLSP", {
115
- enumerable: true,
116
- configurable: true,
117
- writable: true,
118
- value: true
119
- });
120
- }
121
- static createTimeout() {
122
- const err = new LSPError('Request timed out');
123
- err.isTimeout = true;
124
- return err;
125
- }
126
- }
127
- export class LSPClient extends EventTarget {
128
- constructor(transport, config = {}) {
129
- super();
130
- Object.defineProperty(this, "transport", {
131
- enumerable: true,
132
- configurable: true,
133
- writable: true,
134
- value: transport
135
- });
136
- Object.defineProperty(this, "config", {
137
- enumerable: true,
138
- configurable: true,
139
- writable: true,
140
- value: config
141
- });
142
- Object.defineProperty(this, "sources", {
143
- enumerable: true,
144
- configurable: true,
145
- writable: true,
146
- value: {}
147
- });
148
- Object.defineProperty(this, "workspace", {
149
- enumerable: true,
150
- configurable: true,
151
- writable: true,
152
- value: void 0
153
- });
154
- Object.defineProperty(this, "nextReqID", {
155
- enumerable: true,
156
- configurable: true,
157
- writable: true,
158
- value: 0
159
- });
160
- Object.defineProperty(this, "requests", {
161
- enumerable: true,
162
- configurable: true,
163
- writable: true,
164
- value: []
165
- });
166
- Object.defineProperty(this, "serverCapabilities", {
167
- enumerable: true,
168
- configurable: true,
169
- writable: true,
170
- value: null
171
- });
172
- Object.defineProperty(this, "supportSync", {
173
- enumerable: true,
174
- configurable: true,
175
- writable: true,
176
- value: TextDocumentSyncKind.None
177
- });
178
- Object.defineProperty(this, "timeout", {
179
- enumerable: true,
180
- configurable: true,
181
- writable: true,
182
- value: void 0
183
- });
184
- Object.defineProperty(this, "initializing", {
185
- enumerable: true,
186
- configurable: true,
187
- writable: true,
188
- value: void 0
189
- });
190
- Object.defineProperty(this, "receiveListener", {
191
- enumerable: true,
192
- configurable: true,
193
- writable: true,
194
- value: void 0
195
- });
196
- Object.defineProperty(this, "active", {
197
- enumerable: true,
198
- configurable: true,
199
- writable: true,
200
- value: false
201
- });
202
- this.timeout = config.timeout ?? 3000;
203
- this.receiveListener = (event) => this.receiveMessage(event);
204
- transport.addEventListener('message', this.receiveListener);
205
- transport.addEventListener('initialized', () => {
206
- try {
207
- console.info('LSP initialized');
208
- this.onInitialized();
209
- }
210
- catch (err) {
211
- if (err.isLSP) {
212
- console.error('Timeout as client.onConnected()', err.message, this.onInitialized);
213
- }
214
- else {
215
- throw err;
216
- }
217
- }
218
- });
219
- transport.addEventListener('open', () => {
220
- this.startInitializing();
221
- });
222
- transport.addEventListener('close', (event) => {
223
- this.active = false;
224
- this.serverCapabilities = null;
225
- this.dispatchEvent(new CloseEvent('close'));
226
- });
227
- this.workspace = config.workspace
228
- ? config.workspace(this)
229
- : new DefaultWorkspace(this);
230
- }
231
- startInitializing() {
232
- if (this.initializing) {
233
- return;
234
- }
235
- this.initializing = setInterval(async () => {
236
- const capabilities = clientCapabilities;
237
- try {
238
- const resp = await this.requestInner('initialize', {
239
- processId: null,
240
- clientInfo: { name: '@kerebron/lsp-client' },
241
- rootUri: this.config.rootUri || null,
242
- capabilities,
243
- }).promise;
244
- this.stopInitializing();
245
- this.serverCapabilities = resp.capabilities;
246
- const sync = this.serverCapabilities.textDocumentSync;
247
- this.supportSync = TextDocumentSyncKind.None;
248
- if (sync) {
249
- this.supportSync = typeof sync == 'number'
250
- ? sync
251
- : sync.change ?? TextDocumentSyncKind.None;
252
- }
253
- // deno-lint-ignore no-empty
254
- }
255
- catch (ignoreConnectErrors) { }
256
- }, this.timeout);
257
- }
258
- stopInitializing() {
259
- if (this.initializing) {
260
- clearInterval(this.initializing);
261
- this.initializing = undefined;
262
- }
263
- }
264
- async restart() {
265
- this.active = true;
266
- if (!this.transport.isConnected()) {
267
- this.transport.connect();
268
- }
269
- else {
270
- this.startInitializing();
271
- }
272
- }
273
- onInitialized() {
274
- this.transport.send(JSON.stringify({ jsonrpc: '2.0', method: 'initialized', params: {} }));
275
- this.workspace.connected();
276
- }
277
- connect(uri, source) {
278
- if (this.sources[uri] && this.sources[uri] !== source) {
279
- throw new Error(`Source for ${uri} already connected`);
280
- }
281
- this.sources[uri] = source;
282
- this.active = true;
283
- if (!this.transport.isConnected()) {
284
- this.transport.connect();
285
- }
286
- }
287
- disconnect(uri) {
288
- delete this.sources[uri];
289
- this.workspace.closeFile(uri);
290
- if (Object.keys(this.sources).length === 0) {
291
- this.active = false;
292
- this.serverCapabilities = null;
293
- this.transport.removeEventListener('data', this.receiveListener);
294
- this.workspace.disconnected();
295
- this.dispatchEvent(new CloseEvent('close'));
296
- }
297
- }
298
- /// Send a `textDocument/didOpen` notification to the server.
299
- async didOpen(file) {
300
- if (!this.transport.isInitialized()) {
301
- return false;
302
- }
303
- await this.notification('textDocument/didOpen', {
304
- textDocument: {
305
- uri: file.uri,
306
- languageId: file.languageId,
307
- text: file.content,
308
- version: file.version,
309
- },
310
- });
311
- return true;
312
- }
313
- /// Send a `textDocument/didClose` notification to the server.
314
- didClose(uri) {
315
- if (!this.transport.isInitialized()) {
316
- return;
317
- }
318
- this.notification('textDocument/didClose', {
319
- textDocument: { uri },
320
- });
321
- }
322
- receiveMessage(event) {
323
- const msg = event.data;
324
- const value = JSON.parse(msg);
325
- if ('id' in value && !('method' in value)) {
326
- const index = this.requests.findIndex((r) => r.id == value.id);
327
- if (index < 0) {
328
- console.warn(`[lsp] Received a response for non-existent request ${value.id}`);
329
- }
330
- else {
331
- const req = this.requests[index];
332
- clearTimeout(req.timeout);
333
- this.requests.splice(index, 1);
334
- if (value.error)
335
- req.reject(value.error);
336
- else
337
- req.resolve(value.result);
338
- }
339
- }
340
- else if (!('id' in value)) {
341
- const event = new CustomEvent(value.method, {
342
- detail: { params: value.params },
343
- });
344
- if (this.dispatchEvent(event)) {
345
- if (this.config.unhandledNotification) {
346
- this.config.unhandledNotification(this, value.method, value.params);
347
- }
348
- else {
349
- if (defaultNotificationHandlers[value.method]) {
350
- defaultNotificationHandlers[value.method](this, value.params);
351
- }
352
- }
353
- }
354
- }
355
- else {
356
- const resp = {
357
- jsonrpc: '2.0',
358
- id: value.id,
359
- error: {
360
- code: -32601, /* MethodNotFound */
361
- message: 'Method not implemented',
362
- },
363
- };
364
- this.transport.send(JSON.stringify(resp));
365
- }
366
- }
367
- async request(method, params) {
368
- if (!this.transport.isConnected()) {
369
- if (this.active) {
370
- this.transport.connect();
371
- }
372
- throw new LSPError('Not connected');
373
- }
374
- const retVal = await this.requestInner(method, params)
375
- .promise;
376
- return retVal;
377
- }
378
- requestInner(method, params, mapped = false) {
379
- if (!this.transport) {
380
- throw new Error('No transport');
381
- }
382
- if (!this.transport.isConnected()) {
383
- if (this.active) {
384
- this.transport.connect();
385
- }
386
- throw new Error('Transport not connected');
387
- }
388
- const id = ++this.nextReqID, data = {
389
- jsonrpc: '2.0',
390
- id,
391
- method,
392
- params: params,
393
- };
394
- const req = new Request(id, params, setTimeout(() => this.timeoutRequest(req, method, id, params), this.timeout));
395
- try {
396
- if (!this.transport) {
397
- throw new LSPError('No transport');
398
- }
399
- this.transport.send(JSON.stringify(data));
400
- this.requests.push(req);
401
- }
402
- catch (e) {
403
- console.error(e);
404
- clearTimeout(req.timeout);
405
- req.reject(e);
406
- }
407
- return req;
408
- }
409
- async notification(method, params) {
410
- if (!this.transport)
411
- return false;
412
- if (!this.transport.isConnected()) {
413
- if (this.active) {
414
- this.transport.connect();
415
- }
416
- return false;
417
- }
418
- if (!this.transport.isInitialized()) {
419
- return false;
420
- }
421
- const data = {
422
- jsonrpc: '2.0',
423
- method,
424
- params: params,
425
- };
426
- this.transport.send(JSON.stringify(data));
427
- return true;
428
- }
429
- cancelRequest(params) {
430
- const found = this.requests.find((r) => r.params === params);
431
- if (found) {
432
- this.notification('$/cancelRequest', found.id);
433
- }
434
- }
435
- hasCapability(name) {
436
- return this.serverCapabilities ? !!this.serverCapabilities[name] : null;
437
- }
438
- sync() {
439
- this.workspace.syncFiles();
440
- }
441
- timeoutRequest(req, method, id, params) {
442
- console.error('this.timeoutRequest', this.timeout, method, id, params);
443
- const index = this.requests.indexOf(req);
444
- if (index > -1) {
445
- req.reject(LSPError.createTimeout());
446
- this.requests.splice(index, 1);
447
- }
448
- }
449
- }
@@ -1,34 +0,0 @@
1
- import { EditorState } from 'prosemirror-state';
2
- import { EditorView } from 'prosemirror-view';
3
- import type { MenuElement } from '../../extension-menu/src/mod.js';
4
- import type { ExtensionLsp } from './ExtensionLsp.js';
5
- export type LspConnectionStatus = 'connected' | 'connecting' | 'disconnected';
6
- export interface LspStatusOptions {
7
- /** The LSP extension instance to monitor */
8
- lspExtension: ExtensionLsp;
9
- /** Optional label to show (e.g., 'LSP' or language name) */
10
- label?: string;
11
- }
12
- /**
13
- * A menu element that displays LSP connection status.
14
- * Shows a status indicator dot with an optional label.
15
- */
16
- export declare class LspStatusElement implements MenuElement {
17
- private lspExtension;
18
- private label;
19
- private dom;
20
- private statusDot;
21
- private labelEl;
22
- private status;
23
- private statusCheckInterval;
24
- constructor(options: LspStatusOptions);
25
- render(_view: EditorView): {
26
- dom: HTMLElement;
27
- update: (state: EditorState) => boolean;
28
- };
29
- private getClient;
30
- private updateStatusFromClient;
31
- private setStatus;
32
- destroy(): void;
33
- }
34
- //# sourceMappingURL=LspStatus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LspStatus.d.ts","sourceRoot":"","sources":["../../../src/extension-lsp/src/LspStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,YAAY,GAAG,cAAc,CAAC;AAE9E,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,YAAY,EAAE,YAAY,CAAC;IAC3B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,WAAW;IAClD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,MAAM,CAAuC;IACrD,OAAO,CAAC,mBAAmB,CAA+C;gBAE9D,OAAO,EAAE,gBAAgB;IAKrC,MAAM,CACJ,KAAK,EAAE,UAAU,GAChB;QAAE,GAAG,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAA;KAAE;IAyChE,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,SAAS;IAoBjB,OAAO;CAMR"}
@@ -1,127 +0,0 @@
1
- const CSS_PREFIX = 'kb-lsp-status';
2
- /**
3
- * A menu element that displays LSP connection status.
4
- * Shows a status indicator dot with an optional label.
5
- */
6
- export class LspStatusElement {
7
- constructor(options) {
8
- Object.defineProperty(this, "lspExtension", {
9
- enumerable: true,
10
- configurable: true,
11
- writable: true,
12
- value: void 0
13
- });
14
- Object.defineProperty(this, "label", {
15
- enumerable: true,
16
- configurable: true,
17
- writable: true,
18
- value: void 0
19
- });
20
- Object.defineProperty(this, "dom", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: null
25
- });
26
- Object.defineProperty(this, "statusDot", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: null
31
- });
32
- Object.defineProperty(this, "labelEl", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: null
37
- });
38
- Object.defineProperty(this, "status", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: 'disconnected'
43
- });
44
- Object.defineProperty(this, "statusCheckInterval", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: null
49
- });
50
- this.lspExtension = options.lspExtension;
51
- this.label = options.label ?? 'LSP';
52
- }
53
- render(_view) {
54
- // Create main container
55
- this.dom = document.createElement('div');
56
- this.dom.className = CSS_PREFIX;
57
- this.dom.setAttribute('role', 'status');
58
- this.dom.setAttribute('aria-live', 'polite');
59
- // Create status indicator
60
- const indicator = document.createElement('div');
61
- indicator.className = `${CSS_PREFIX}__indicator`;
62
- // Status dot
63
- this.statusDot = document.createElement('span');
64
- this.statusDot.className =
65
- `${CSS_PREFIX}__dot ${CSS_PREFIX}__dot--disconnected`;
66
- indicator.appendChild(this.statusDot);
67
- // Label
68
- this.labelEl = document.createElement('span');
69
- this.labelEl.className = `${CSS_PREFIX}__label`;
70
- this.labelEl.textContent = this.label;
71
- indicator.appendChild(this.labelEl);
72
- this.dom.appendChild(indicator);
73
- // Set initial status based on client state
74
- this.updateStatusFromClient();
75
- // Poll for status changes since the client is created lazily
76
- this.statusCheckInterval = setInterval(() => {
77
- this.updateStatusFromClient();
78
- }, 1000);
79
- const update = (_state) => {
80
- // Always visible
81
- return true;
82
- };
83
- return { dom: this.dom, update };
84
- }
85
- getClient() {
86
- const mainLang = this.lspExtension.mainLang || 'markdown';
87
- return this.lspExtension.getClient(mainLang);
88
- }
89
- updateStatusFromClient() {
90
- const client = this.getClient();
91
- // Check if the client has server capabilities (meaning it's connected and initialized)
92
- if (client?.serverCapabilities) {
93
- this.setStatus('connected');
94
- }
95
- else if (client?.active) {
96
- this.setStatus('connecting');
97
- }
98
- else {
99
- this.setStatus('disconnected');
100
- }
101
- }
102
- setStatus(status) {
103
- if (this.status === status)
104
- return; // No change
105
- this.status = status;
106
- if (this.statusDot) {
107
- this.statusDot.className =
108
- `${CSS_PREFIX}__dot ${CSS_PREFIX}__dot--${status}`;
109
- }
110
- if (this.dom) {
111
- this.dom.setAttribute('data-status', status);
112
- const statusLabels = {
113
- connected: 'LSP Connected',
114
- connecting: 'LSP Connecting...',
115
- disconnected: 'LSP Disconnected',
116
- };
117
- this.dom.title = statusLabels[status];
118
- this.dom.setAttribute('aria-label', statusLabels[status]);
119
- }
120
- }
121
- destroy() {
122
- if (this.statusCheckInterval) {
123
- clearInterval(this.statusCheckInterval);
124
- this.statusCheckInterval = null;
125
- }
126
- }
127
- }
@@ -1,8 +0,0 @@
1
- import * as lsp from 'vscode-languageserver-protocol';
2
- /**
3
- * Compares two strings and computes the minimal set of text changes
4
- * using a diff-based approach (simple line-by-line + character diff for simplicity).
5
- * Returns an array of TextEdit-like changes that transform `previous` into `current`.
6
- */
7
- export declare function computeIncrementalChanges(previous: string, current: string): lsp.TextDocumentContentChangeEvent[];
8
- //# sourceMappingURL=computeIncrementalChanges.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computeIncrementalChanges.d.ts","sourceRoot":"","sources":["../../../src/extension-lsp/src/computeIncrementalChanges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,gCAAgC,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,GAAG,CAAC,8BAA8B,EAAE,CA0FtC"}