@difizen/libro-lsp 0.1.2 → 0.1.4

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 (47) hide show
  1. package/es/adapters/adapter.d.ts.map +1 -1
  2. package/es/adapters/adapter.js +4 -3
  3. package/es/adapters/notebook-adapter.d.ts +10 -4
  4. package/es/adapters/notebook-adapter.d.ts.map +1 -1
  5. package/es/adapters/notebook-adapter.js +20 -8
  6. package/es/connection-manager.d.ts +37 -34
  7. package/es/connection-manager.d.ts.map +1 -1
  8. package/es/connection-manager.js +186 -186
  9. package/es/connection.d.ts +8 -16
  10. package/es/connection.d.ts.map +1 -1
  11. package/es/connection.js +26 -12
  12. package/es/index.d.ts +1 -0
  13. package/es/index.d.ts.map +1 -1
  14. package/es/index.js +1 -0
  15. package/es/lsp-app-contribution.d.ts +2 -0
  16. package/es/lsp-app-contribution.d.ts.map +1 -1
  17. package/es/lsp-app-contribution.js +11 -4
  18. package/es/lsp-protocol.d.ts +15 -0
  19. package/es/lsp-protocol.d.ts.map +1 -1
  20. package/es/lsp-protocol.js +9 -1
  21. package/es/module.d.ts.map +1 -1
  22. package/es/module.js +54 -2
  23. package/es/monitor.d.ts +20 -0
  24. package/es/monitor.d.ts.map +1 -0
  25. package/es/monitor.js +25 -0
  26. package/es/tokens.d.ts +4 -1
  27. package/es/tokens.d.ts.map +1 -1
  28. package/es/tokens.js +2 -1
  29. package/es/virtual/document.d.ts +14 -4
  30. package/es/virtual/document.d.ts.map +1 -1
  31. package/es/virtual/document.js +48 -24
  32. package/es/ws-connection/ws-connection.d.ts +2 -1
  33. package/es/ws-connection/ws-connection.d.ts.map +1 -1
  34. package/es/ws-connection/ws-connection.js +4 -3
  35. package/package.json +5 -5
  36. package/src/adapters/adapter.ts +2 -1
  37. package/src/adapters/notebook-adapter.ts +17 -7
  38. package/src/connection-manager.ts +120 -146
  39. package/src/connection.ts +16 -27
  40. package/src/index.ts +1 -0
  41. package/src/lsp-app-contribution.ts +4 -2
  42. package/src/lsp-protocol.ts +26 -0
  43. package/src/module.ts +61 -0
  44. package/src/monitor.ts +28 -0
  45. package/src/tokens.ts +5 -1
  46. package/src/virtual/document.ts +32 -8
  47. package/src/ws-connection/ws-connection.ts +4 -2
@@ -15,7 +15,8 @@ import { Emitter, inject, singleton } from '@difizen/mana-app';
15
15
  import type * as protocol from 'vscode-languageserver-protocol';
16
16
 
17
17
  import type { WidgetLSPAdapter } from './adapters/adapter.js';
18
- import { LSPConnection } from './connection.js';
18
+ import type { LSPConnection } from './connection.js';
19
+ import { LSPConnectionFactory } from './connection.js';
19
20
  import type { ClientCapabilities } from './lsp.js';
20
21
  import type { AskServersToSendTraceNotifications } from './plugin.js';
21
22
  import type {
@@ -42,6 +43,8 @@ import type { VirtualDocument } from './virtual/document.js';
42
43
  */
43
44
  @singleton({ token: ILSPDocumentConnectionManager })
44
45
  export class DocumentConnectionManager implements ILSPDocumentConnectionManager {
46
+ @inject(LSPConnectionFactory)
47
+ protected readonly lspConnectionFactory: LSPConnectionFactory;
45
48
  constructor(
46
49
  @inject(ILanguageServerManagerFactory)
47
50
  languageServerManagerFactory: ILanguageServerManagerFactory,
@@ -51,7 +54,58 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
51
54
  this.adapters = new Map();
52
55
  this._ignoredLanguages = new Set();
53
56
  this.languageServerManager = languageServerManagerFactory({});
54
- Private.setLanguageServerManager(this.languageServerManager);
57
+ }
58
+
59
+ private _connections: Map<TLanguageServerId, LSPConnection> = new Map();
60
+
61
+ protected disconnectServer(languageServerId: TLanguageServerId): void {
62
+ const connection = this._connections.get(languageServerId);
63
+ if (connection) {
64
+ connection.close();
65
+ this._connections.delete(languageServerId);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Return (or create and initialize) the WebSocket associated with the language
71
+ */
72
+ protected async connection(
73
+ language: string,
74
+ languageServerId: TLanguageServerId,
75
+ uris: IURIs,
76
+ onCreate: (connection: LSPConnection) => void,
77
+ capabilities: ClientCapabilities,
78
+ ): Promise<LSPConnection> {
79
+ let connection = this._connections.get(languageServerId);
80
+ if (!connection) {
81
+ const socket = new WebSocket(uris.socket);
82
+
83
+ const connection = this.lspConnectionFactory({
84
+ languageId: language,
85
+ serverUri: uris.server,
86
+ rootUri: uris.base,
87
+ serverIdentifier: languageServerId,
88
+ capabilities: capabilities,
89
+ });
90
+
91
+ this._connections.set(languageServerId, connection);
92
+ connection.connect(socket);
93
+ onCreate(connection);
94
+ }
95
+
96
+ connection = this._connections.get(languageServerId)!;
97
+
98
+ return connection;
99
+ }
100
+
101
+ protected updateServerConfiguration(
102
+ languageServerId: TLanguageServerId,
103
+ settings: protocol.DidChangeConfigurationParams,
104
+ ): void {
105
+ const connection = this._connections.get(languageServerId);
106
+ if (connection) {
107
+ connection.sendConfigurationChange(settings);
108
+ }
55
109
  }
56
110
 
57
111
  /**
@@ -121,7 +175,50 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
121
175
  * Promise resolved when the language server manager is ready.
122
176
  */
123
177
  get ready(): Promise<void> {
124
- return Private.getLanguageServerManager().ready;
178
+ return this.languageServerManager.ready;
179
+ }
180
+
181
+ /**
182
+ * Generate the URI of a virtual document from input
183
+ *
184
+ * @param virtualDocument - the virtual document
185
+ * @param language - language of the document
186
+ */
187
+ solveUris(virtualDocument: VirtualDocument, language: string): IURIs | undefined {
188
+ const wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
189
+ const rootUri = PageConfig.getOption('rootUri');
190
+ const virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri');
191
+
192
+ const baseUri = virtualDocument.hasLspSupportedFile ? rootUri : virtualDocumentsUri;
193
+
194
+ // for now take the best match only
195
+ const matchingServers = this.languageServerManager.getMatchingServers({
196
+ language,
197
+ });
198
+ const languageServerId = matchingServers.length === 0 ? null : matchingServers[0];
199
+
200
+ if (languageServerId === null) {
201
+ return;
202
+ }
203
+
204
+ // workaround url-parse bug(s) (see https://github.com/jupyter-lsp/jupyterlab-lsp/issues/595)
205
+ let documentUri = URL.join(baseUri, virtualDocument.uri);
206
+ if (!documentUri.startsWith('file:///') && documentUri.startsWith('file://')) {
207
+ documentUri = documentUri.replace('file://', 'file:///');
208
+ if (
209
+ documentUri.startsWith('file:///users/') &&
210
+ baseUri.startsWith('file:///Users/')
211
+ ) {
212
+ documentUri = documentUri.replace('file:///users/', 'file:///Users/');
213
+ }
214
+ }
215
+
216
+ return {
217
+ base: baseUri,
218
+ document: documentUri,
219
+ server: URL.join('ws://jupyter-lsp', language),
220
+ socket: URL.join(wsBase, 'lsp', 'ws', languageServerId),
221
+ };
125
222
  }
126
223
 
127
224
  /**
@@ -222,7 +319,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
222
319
  settings: parsedSettings,
223
320
  };
224
321
 
225
- Private.updateServerConfiguration(languageServerId, serverSettings);
322
+ this.updateServerConfiguration(languageServerId, serverSettings);
226
323
  }
227
324
  }
228
325
 
@@ -320,7 +417,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
320
417
  * language.
321
418
  */
322
419
  disconnect(languageId: TLanguageServerId): void {
323
- Private.disconnect(languageId);
420
+ this.disconnect(languageId);
324
421
  }
325
422
 
326
423
  /**
@@ -415,7 +512,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
415
512
 
416
513
  this.connectDocumentSignals(virtualDocument);
417
514
 
418
- const uris = DocumentConnectionManager.solveUris(virtualDocument, language);
515
+ const uris = this.solveUris(virtualDocument, language);
419
516
  const matchingServers = this.languageServerManager.getMatchingServers({
420
517
  language,
421
518
  });
@@ -429,7 +526,7 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
429
526
  if (!uris) {
430
527
  return;
431
528
  }
432
- const connection = await Private.connection(
529
+ const connection = await this.connection(
433
530
  language,
434
531
  languageServerId!,
435
532
  uris,
@@ -476,151 +573,28 @@ export class DocumentConnectionManager implements ILSPDocumentConnectionManager
476
573
  */
477
574
  protected _ignoredLanguages: Set<string>;
478
575
  }
479
-
480
- export namespace DocumentConnectionManager {
481
- export interface IOptions {
482
- /**
483
- * The language server manager instance.
484
- */
485
- languageServerManager: ILanguageServerManager;
486
- }
487
-
576
+ export interface IURIs {
488
577
  /**
489
- * Generate the URI of a virtual document from input
578
+ * The root URI set by server.
490
579
  *
491
- * @param virtualDocument - the virtual document
492
- * @param language - language of the document
493
580
  */
494
- export function solveUris(
495
- virtualDocument: VirtualDocument,
496
- language: string,
497
- ): IURIs | undefined {
498
- const wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
499
- const rootUri = PageConfig.getOption('rootUri');
500
- const virtualDocumentsUri = PageConfig.getOption('virtualDocumentsUri');
501
-
502
- const baseUri = virtualDocument.hasLspSupportedFile ? rootUri : virtualDocumentsUri;
503
-
504
- // for now take the best match only
505
- const matchingServers = Private.getLanguageServerManager().getMatchingServers({
506
- language,
507
- });
508
- const languageServerId = matchingServers.length === 0 ? null : matchingServers[0];
509
-
510
- if (languageServerId === null) {
511
- return;
512
- }
513
-
514
- // workaround url-parse bug(s) (see https://github.com/jupyter-lsp/jupyterlab-lsp/issues/595)
515
- let documentUri = URL.join(baseUri, virtualDocument.uri);
516
- if (!documentUri.startsWith('file:///') && documentUri.startsWith('file://')) {
517
- documentUri = documentUri.replace('file://', 'file:///');
518
- if (
519
- documentUri.startsWith('file:///users/') &&
520
- baseUri.startsWith('file:///Users/')
521
- ) {
522
- documentUri = documentUri.replace('file:///users/', 'file:///Users/');
523
- }
524
- }
525
-
526
- return {
527
- base: baseUri,
528
- document: documentUri,
529
- server: URL.join('ws://jupyter-lsp', language),
530
- socket: URL.join(wsBase, 'lsp', 'ws', languageServerId),
531
- };
532
- }
533
-
534
- export interface IURIs {
535
- /**
536
- * The root URI set by server.
537
- *
538
- */
539
- base: string;
540
-
541
- /**
542
- * The URI to the virtual document.
543
- *
544
- */
545
- document: string;
546
-
547
- /**
548
- * Address of websocket endpoint for LSP services.
549
- *
550
- */
551
- server: string;
552
-
553
- /**
554
- * Address of websocket endpoint for the language server.
555
- *
556
- */
557
- socket: string;
558
- }
559
- }
560
-
561
- /**
562
- * Namespace primarily for language-keyed cache of LSPConnections
563
- */
564
- namespace Private {
565
- const _connections: Map<TLanguageServerId, LSPConnection> = new Map();
566
- let _languageServerManager: ILanguageServerManager;
567
-
568
- export function getLanguageServerManager(): ILanguageServerManager {
569
- return _languageServerManager;
570
- }
571
- export function setLanguageServerManager(
572
- languageServerManager: ILanguageServerManager,
573
- ): void {
574
- _languageServerManager = languageServerManager;
575
- }
576
-
577
- export function disconnect(languageServerId: TLanguageServerId): void {
578
- const connection = _connections.get(languageServerId);
579
- if (connection) {
580
- connection.close();
581
- _connections.delete(languageServerId);
582
- }
583
- }
581
+ base: string;
584
582
 
585
583
  /**
586
- * Return (or create and initialize) the WebSocket associated with the language
584
+ * The URI to the virtual document.
585
+ *
587
586
  */
588
- export async function connection(
589
- language: string,
590
- languageServerId: TLanguageServerId,
591
- uris: DocumentConnectionManager.IURIs,
592
- onCreate: (connection: LSPConnection) => void,
593
- capabilities: ClientCapabilities,
594
- ): Promise<LSPConnection> {
595
- let connection = _connections.get(languageServerId);
596
- if (!connection) {
597
- const socket = new WebSocket(uris.socket);
587
+ document: string;
598
588
 
599
- const connection = new LSPConnection({
600
- languageId: language,
601
- serverUri: uris.server,
602
- rootUri: uris.base,
603
- serverIdentifier: languageServerId,
604
- capabilities: capabilities,
605
- });
606
-
607
- _connections.set(languageServerId, connection);
608
- connection.connect(socket);
609
- onCreate(connection);
610
- }
611
-
612
- connection = _connections.get(languageServerId)!;
613
-
614
- return connection;
615
- }
589
+ /**
590
+ * Address of websocket endpoint for LSP services.
591
+ *
592
+ */
593
+ server: string;
616
594
 
617
- export function updateServerConfiguration(
618
- languageServerId: TLanguageServerId,
619
- settings: protocol.DidChangeConfigurationParams,
620
- ): void {
621
- const connection = _connections.get(languageServerId);
622
- if (connection) {
623
- connection.sendConfigurationChange(settings);
624
- }
625
- }
595
+ /**
596
+ * Address of websocket endpoint for the language server.
597
+ *
598
+ */
599
+ socket: string;
626
600
  }
package/src/connection.ts CHANGED
@@ -8,10 +8,14 @@
8
8
 
9
9
  import type { Event } from '@difizen/mana-app';
10
10
  import { Emitter } from '@difizen/mana-app';
11
+ import { inject, transient } from '@difizen/mana-app';
11
12
  import type * as lsp from 'vscode-languageserver-protocol';
12
13
  import type { MessageConnection } from 'vscode-ws-jsonrpc';
13
14
 
14
- import { Method } from './tokens.js';
15
+ import type { AnyMethodType, IMessageLog } from './lsp-protocol.js';
16
+ import { MessageKind } from './lsp-protocol.js';
17
+ import { LSPMonitor } from './monitor.js';
18
+ import { Method, ILSPOptions } from './tokens.js';
15
19
  import type {
16
20
  ClientNotifications,
17
21
  ClientRequests,
@@ -20,7 +24,6 @@ import type {
20
24
  IClientResult,
21
25
  IDocumentInfo,
22
26
  ILSPConnection,
23
- ILSPOptions,
24
27
  IServerRequestHandler,
25
28
  IServerRequestParams,
26
29
  IServerResult,
@@ -148,17 +151,6 @@ export const Provider: Record<string, keyof lsp.ServerCapabilities> = {
148
151
  WORKSPACE: 'workspace',
149
152
  };
150
153
 
151
- type AnyMethodType =
152
- | typeof Method.ServerNotification
153
- | typeof Method.ClientNotification
154
- | typeof Method.ClientRequest
155
- | typeof Method.ServerRequest;
156
- type AnyMethod =
157
- | Method.ServerNotification
158
- | Method.ClientNotification
159
- | Method.ClientRequest
160
- | Method.ServerRequest;
161
-
162
154
  /**
163
155
  * Create a map between the request method and its handler
164
156
  */
@@ -173,22 +165,13 @@ function createMethodMap<T, H, U extends keyof T = keyof T>(
173
165
  return result as T;
174
166
  }
175
167
 
176
- enum MessageKind {
177
- clientNotifiedServer,
178
- serverNotifiedClient,
179
- serverRequested,
180
- clientRequested,
181
- resultForClient,
182
- responseForServer,
183
- }
184
-
185
- interface IMessageLog<T extends AnyMethod = AnyMethod> {
186
- method: T;
187
- message: any;
188
- }
168
+ export const LSPConnectionFactory = Symbol('LSPConnectionFactory');
169
+ export type LSPConnectionFactory = (options: ILSPOptions) => LSPConnection;
189
170
 
171
+ @transient()
190
172
  export class LSPConnection extends LspWsConnection implements ILSPConnection {
191
- constructor(options: ILSPOptions) {
173
+ @inject(LSPMonitor) lspmonitor: LSPMonitor;
174
+ constructor(@inject(ILSPOptions) options: ILSPOptions) {
192
175
  super(options);
193
176
  this._options = options;
194
177
  this.logAllCommunication = false;
@@ -285,6 +268,12 @@ export class LSPConnection extends LspWsConnection implements ILSPConnection {
285
268
  // eslint-disable-next-line no-console
286
269
  console.log(kind, message);
287
270
  }
271
+ this.lspmonitor.log({
272
+ serverIdentifier: this.serverIdentifier ?? '',
273
+ serverLanguage: this.serverLanguage ?? '',
274
+ kind,
275
+ message,
276
+ });
288
277
  }
289
278
 
290
279
  /**
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  export * from './module.js';
9
+ export * from './monitor.js';
9
10
  export * from './adapters/adapter.js';
10
11
  export * from './connection-manager.js';
11
12
  export * from './extractors/index.js';
@@ -4,7 +4,7 @@ import { ServerManager } from '@difizen/libro-kernel';
4
4
  import { ApplicationContribution } from '@difizen/mana-app';
5
5
  import { inject, singleton } from '@difizen/mana-app';
6
6
 
7
- import { NotebookAdapter } from './adapters/notebook-adapter.js';
7
+ import { NotebookAdapterFactory } from './adapters/notebook-adapter.js';
8
8
  import {
9
9
  ILSPCodeExtractorsManager,
10
10
  ILSPDocumentConnectionManager,
@@ -20,6 +20,7 @@ export class LSPAppContribution implements ApplicationContribution {
20
20
  connectionManager: ILSPDocumentConnectionManager;
21
21
  @inject(ILSPFeatureManager) featureManager: ILSPFeatureManager;
22
22
  @inject(ILSPCodeExtractorsManager) codeExtractorManager: ILSPCodeExtractorsManager;
23
+ @inject(NotebookAdapterFactory) notebookAdapterFactory: NotebookAdapterFactory;
23
24
 
24
25
  onStart() {
25
26
  /**
@@ -72,7 +73,8 @@ export class LSPAppContribution implements ApplicationContribution {
72
73
  await notebook.initialized;
73
74
  await this.serverManager.ready;
74
75
 
75
- const adapter = new NotebookAdapter(notebook, {
76
+ const adapter = this.notebookAdapterFactory({
77
+ editorWidget: notebook,
76
78
  connectionManager: this.connectionManager,
77
79
  featureManager: this.featureManager,
78
80
  foreignCodeExtractorsManager: this.codeExtractorManager,
@@ -1,5 +1,6 @@
1
1
  import type { LSPConnection } from './connection.js';
2
2
  import type { Document } from './tokens.js';
3
+ import type { Method } from './tokens.js';
3
4
  import type { VirtualDocument } from './virtual/document.js';
4
5
 
5
6
  export type LSPProviderResult = {
@@ -8,3 +9,28 @@ export type LSPProviderResult = {
8
9
  editor: Document.IEditor;
9
10
  };
10
11
  export type LSPProvider = () => Promise<LSPProviderResult>;
12
+
13
+ export type AnyMethodType =
14
+ | typeof Method.ServerNotification
15
+ | typeof Method.ClientNotification
16
+ | typeof Method.ClientRequest
17
+ | typeof Method.ServerRequest;
18
+ export type AnyMethod =
19
+ | Method.ServerNotification
20
+ | Method.ClientNotification
21
+ | Method.ClientRequest
22
+ | Method.ServerRequest;
23
+
24
+ export enum MessageKind {
25
+ clientNotifiedServer = 'clientNotifiedServer',
26
+ serverNotifiedClient = 'serverNotifiedClient',
27
+ serverRequested = 'serverRequested',
28
+ clientRequested = 'clientRequested',
29
+ resultForClient = 'resultForClient',
30
+ responseForServer = 'responseForServer',
31
+ }
32
+
33
+ export interface IMessageLog<T extends AnyMethod = AnyMethod> {
34
+ method: T;
35
+ message: any;
36
+ }
package/src/module.ts CHANGED
@@ -1,15 +1,31 @@
1
1
  import { LibroServerModule } from '@difizen/libro-kernel';
2
2
  import { ManaModule } from '@difizen/mana-app';
3
3
 
4
+ import {
5
+ NotebookAdapter,
6
+ NotebookAdapterFactory,
7
+ NotebookAdapterOptions,
8
+ } from './adapters/notebook-adapter.js';
4
9
  import { DocumentConnectionManager } from './connection-manager.js';
10
+ import { LSPConnection, LSPConnectionFactory } from './connection.js';
5
11
  import { CodeExtractorsManager } from './extractors/index.js';
6
12
  import { FeatureManager } from './feature.js';
7
13
  import { LSPAppContribution } from './lsp-app-contribution.js';
8
14
  import { LanguageServerManager } from './manager.js';
15
+ import { LSPMonitor } from './monitor.js';
9
16
  import {
10
17
  ILanguageServerManagerFactory,
11
18
  ILanguageServerManagerOptions,
19
+ ILSPOptions,
12
20
  } from './tokens.js';
21
+ import {
22
+ IVirtualDocumentOptions,
23
+ VirtualDocument,
24
+ VirtualDocumentFactory,
25
+ VirtualDocumentInfo,
26
+ VirtualDocumentInfoFactory,
27
+ VirtualDocumentInfoOptions,
28
+ } from './virtual/document.js';
13
29
 
14
30
  export const LibroLSPModule = ManaModule.create()
15
31
  .register(
@@ -28,5 +44,50 @@ export const LibroLSPModule = ManaModule.create()
28
44
  };
29
45
  },
30
46
  },
47
+ VirtualDocumentInfo,
48
+ {
49
+ token: VirtualDocumentInfoFactory,
50
+ useFactory: (ctx) => {
51
+ return (option: VirtualDocumentInfoOptions) => {
52
+ const child = ctx.container.createChild();
53
+ child.register({ token: VirtualDocumentInfoOptions, useValue: option });
54
+ return child.get(VirtualDocumentInfo);
55
+ };
56
+ },
57
+ },
58
+ VirtualDocument,
59
+ {
60
+ token: VirtualDocumentFactory,
61
+ useFactory: (ctx) => {
62
+ return (option: IVirtualDocumentOptions) => {
63
+ const child = ctx.container.createChild();
64
+ child.register({ token: IVirtualDocumentOptions, useValue: option });
65
+ return child.get(VirtualDocument);
66
+ };
67
+ },
68
+ },
69
+ NotebookAdapter,
70
+ {
71
+ token: NotebookAdapterFactory,
72
+ useFactory: (ctx) => {
73
+ return (option: NotebookAdapterOptions) => {
74
+ const child = ctx.container.createChild();
75
+ child.register({ token: NotebookAdapterOptions, useValue: option });
76
+ return child.get(NotebookAdapter);
77
+ };
78
+ },
79
+ },
80
+ LSPConnection,
81
+ {
82
+ token: LSPConnectionFactory,
83
+ useFactory: (ctx) => {
84
+ return (option: ILSPOptions) => {
85
+ const child = ctx.container.createChild();
86
+ child.register({ token: ILSPOptions, useValue: option });
87
+ return child.get(LSPConnection);
88
+ };
89
+ },
90
+ },
91
+ LSPMonitor,
31
92
  )
32
93
  .dependOn(LibroServerModule);
package/src/monitor.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { Emitter } from '@difizen/mana-app';
2
+ import { singleton } from '@difizen/mana-app';
3
+
4
+ import type { IMessageLog, MessageKind } from './lsp-protocol.js';
5
+
6
+ export interface LogMessage {
7
+ /**
8
+ * Identifier of the language server
9
+ */
10
+ serverIdentifier: string;
11
+
12
+ /**
13
+ * Language of the language server
14
+ */
15
+ serverLanguage: string;
16
+ kind: MessageKind;
17
+ message: IMessageLog;
18
+ }
19
+
20
+ @singleton()
21
+ export class LSPMonitor {
22
+ protected onMessageEmitter = new Emitter<LogMessage>();
23
+ onMessage = this.onMessageEmitter.event;
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ log(message: LogMessage) {
26
+ this.onMessageEmitter.fire(message);
27
+ }
28
+ }
package/src/tokens.ts CHANGED
@@ -11,6 +11,7 @@ import type * as rpc from 'vscode-jsonrpc';
11
11
  import type * as lsp from 'vscode-languageserver-protocol';
12
12
 
13
13
  import type { WidgetLSPAdapter } from './adapters/adapter.js';
14
+ import type { IURIs } from './connection-manager.js';
14
15
  import type { IForeignCodeExtractor } from './extractors/types.js';
15
16
  import type {
16
17
  AnyCompletion,
@@ -464,6 +465,8 @@ export interface ILSPDocumentConnectionManager {
464
465
  * @param adapter - the adapter need to be registered
465
466
  */
466
467
  registerAdapter(path: string, adapter: WidgetLSPAdapter<NotebookView>): void;
468
+
469
+ solveUris(virtualDocument: VirtualDocument, language: string): IURIs | undefined;
467
470
  }
468
471
 
469
472
  /**
@@ -535,6 +538,7 @@ export interface ILSPCodeExtractorsManager {
535
538
  ): void;
536
539
  }
537
540
 
541
+ export const ILSPOptions = Symbol('ILSPOptions');
538
542
  /**
539
543
  * Argument for creating a connection to the LSP proxy server.
540
544
  */
@@ -752,7 +756,7 @@ export type ServerRequests<
752
756
  /**
753
757
  * @alpha
754
758
  *
755
- * Interface describing he connection to the language server.
759
+ * Interface describing the connection to the language server.
756
760
  */
757
761
  export interface ILSPConnection extends ILspConnection {
758
762
  /**