@difizen/libro-lsp 0.1.3 → 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
@@ -3,23 +3,24 @@
3
3
  // Distributed under the terms of the Modified BSD License.
4
4
 
5
5
  import type {
6
- IRange,
7
6
  IPosition as CodeEditorPosition,
7
+ IRange,
8
8
  } from '@difizen/libro-code-editor';
9
- import { Emitter } from '@difizen/mana-app';
10
9
  import type { Disposable, Event } from '@difizen/mana-app';
10
+ import { Emitter } from '@difizen/mana-app';
11
+ import { inject, transient } from '@difizen/mana-app';
11
12
 
12
- import { DocumentConnectionManager } from '../connection-manager.js';
13
13
  import type { IForeignCodeExtractor } from '../extractors/types.js';
14
14
  import type { LanguageIdentifier } from '../lsp.js';
15
15
  import type {
16
- Position,
17
16
  IEditorPosition,
18
17
  IRootPosition,
19
18
  ISourcePosition,
20
19
  IVirtualPosition,
20
+ Position,
21
21
  } from '../positioning.js';
22
22
  import type { Document, ILSPCodeExtractorsManager } from '../tokens.js';
23
+ import { ILSPDocumentConnectionManager } from '../tokens.js';
23
24
  import { DefaultMap, untilReady } from '../utils.js';
24
25
  import type { IDocumentInfo } from '../ws-connection/types.js';
25
26
 
@@ -97,16 +98,26 @@ export function isWithinRange(position: CodeEditorPosition, range: IRange): bool
97
98
  );
98
99
  }
99
100
 
101
+ export const VirtualDocumentInfoFactory = Symbol('VirtualDocumentInfoFactory');
102
+ export type VirtualDocumentInfoFactory = (
103
+ document: VirtualDocument,
104
+ ) => VirtualDocumentInfo;
105
+ export const VirtualDocumentInfoOptions = Symbol('VirtualDocumentInfoOptions');
106
+ export type VirtualDocumentInfoOptions = VirtualDocument;
107
+
100
108
  /**
101
109
  * A virtual implementation of IDocumentInfo
102
110
  */
111
+ @transient()
103
112
  export class VirtualDocumentInfo implements IDocumentInfo {
113
+ @inject(ILSPDocumentConnectionManager)
114
+ connectionManager: ILSPDocumentConnectionManager;
104
115
  /**
105
116
  * Creates an instance of VirtualDocumentInfo.
106
117
  * @param document - the virtual document need to
107
118
  * be wrapped.
108
119
  */
109
- constructor(document: VirtualDocument) {
120
+ constructor(@inject(VirtualDocumentInfoOptions) document: VirtualDocument) {
110
121
  this._document = document;
111
122
  }
112
123
 
@@ -128,7 +139,7 @@ export class VirtualDocumentInfo implements IDocumentInfo {
128
139
  * value before using it.
129
140
  */
130
141
  get uri(): string {
131
- const uris = DocumentConnectionManager.solveUris(this._document, this.languageId);
142
+ const uris = this.connectionManager.solveUris(this._document, this.languageId);
132
143
  if (!uris) {
133
144
  return '';
134
145
  }
@@ -192,6 +203,12 @@ export interface IVirtualDocumentOptions {
192
203
  parent?: VirtualDocument;
193
204
  }
194
205
 
206
+ export const VirtualDocumentFactory = Symbol('VirtualDocumentFactory');
207
+ export type VirtualDocumentFactory = (
208
+ options: IVirtualDocumentOptions,
209
+ ) => VirtualDocument;
210
+ export const IVirtualDocumentOptions = Symbol('IVirtualDocumentOptions');
211
+
195
212
  /**
196
213
  *
197
214
  * A notebook can hold one or more virtual documents; there is always one,
@@ -213,8 +230,13 @@ export interface IVirtualDocumentOptions {
213
230
  * No dependency on editor implementation (such as CodeMirrorEditor)
214
231
  * is allowed for VirtualEditor.
215
232
  */
233
+ @transient()
216
234
  export class VirtualDocument implements Disposable {
217
- constructor(options: IVirtualDocumentOptions) {
235
+ @inject(VirtualDocumentFactory) protected readonly factory: VirtualDocumentFactory;
236
+ constructor(
237
+ @inject(IVirtualDocumentOptions) options: IVirtualDocumentOptions,
238
+ @inject(VirtualDocumentInfoFactory) docInfofactory: VirtualDocumentInfoFactory,
239
+ ) {
218
240
  this.options = options;
219
241
  this.path = this.options.path;
220
242
  this.fileExtension = options.fileExtension;
@@ -234,6 +256,8 @@ export class VirtualDocument implements Disposable {
234
256
  this._remainingLifetime = 6;
235
257
 
236
258
  this.unusedDocuments = new Set();
259
+ this.documentInfo = docInfofactory(this);
260
+
237
261
  this.documentInfo = new VirtualDocumentInfo(this);
238
262
  this.updateManager = new UpdateManager(this);
239
263
  this.updateManager.updateBegan(this._updateBeganSlot, this);
@@ -959,7 +983,7 @@ export class VirtualDocument implements Disposable {
959
983
  standalone: boolean,
960
984
  fileExtension: string,
961
985
  ): VirtualDocument {
962
- const document = new VirtualDocument({
986
+ const document = this.factory({
963
987
  ...this.options,
964
988
  parent: this,
965
989
  standalone: standalone,
@@ -10,7 +10,7 @@
10
10
  // Introduced modifications are BSD licenced, copyright JupyterLab development team.
11
11
 
12
12
  import type { Disposable, Event } from '@difizen/mana-app';
13
- import { Emitter } from '@difizen/mana-app';
13
+ import { Emitter, transient } from '@difizen/mana-app';
14
14
  import type * as protocol from 'vscode-languageserver-protocol';
15
15
  //TODO: vscode-ws-jsonrpc has new version
16
16
  import type { MessageConnection } from 'vscode-ws-jsonrpc';
@@ -20,8 +20,10 @@ import {
20
20
  registerServerCapability,
21
21
  unregisterServerCapability,
22
22
  } from './server-capability-registration.js';
23
- import type { IDocumentInfo, ILspConnection, ILspOptions } from './types.js';
23
+ import type { ILspOptions } from './types.js';
24
+ import type { IDocumentInfo, ILspConnection } from './types.js';
24
25
 
26
+ @transient()
25
27
  export class LspWsConnection implements ILspConnection, Disposable {
26
28
  constructor(options: ILspOptions) {
27
29
  this._rootUri = options.rootUri;