@difizen/libro-lsp 0.1.2
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.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/es/adapters/adapter.d.ts +255 -0
- package/es/adapters/adapter.d.ts.map +1 -0
- package/es/adapters/adapter.js +647 -0
- package/es/adapters/notebook-adapter.d.ts +150 -0
- package/es/adapters/notebook-adapter.d.ts.map +1 -0
- package/es/adapters/notebook-adapter.js +588 -0
- package/es/adapters/status-message.d.ts +48 -0
- package/es/adapters/status-message.d.ts.map +1 -0
- package/es/adapters/status-message.js +110 -0
- package/es/connection-manager.d.ts +199 -0
- package/es/connection-manager.d.ts.map +1 -0
- package/es/connection-manager.js +685 -0
- package/es/connection.d.ts +149 -0
- package/es/connection.d.ts.map +1 -0
- package/es/connection.js +591 -0
- package/es/extractors/index.d.ts +4 -0
- package/es/extractors/index.d.ts.map +1 -0
- package/es/extractors/index.js +6 -0
- package/es/extractors/manager.d.ts +31 -0
- package/es/extractors/manager.d.ts.map +1 -0
- package/es/extractors/manager.js +90 -0
- package/es/extractors/text-extractor.d.ts +56 -0
- package/es/extractors/text-extractor.d.ts.map +1 -0
- package/es/extractors/text-extractor.js +72 -0
- package/es/extractors/types.d.ts +68 -0
- package/es/extractors/types.d.ts.map +1 -0
- package/es/extractors/types.js +1 -0
- package/es/feature.d.ts +29 -0
- package/es/feature.d.ts.map +1 -0
- package/es/feature.js +85 -0
- package/es/index.d.ts +19 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +21 -0
- package/es/lsp-app-contribution.d.ts +19 -0
- package/es/lsp-app-contribution.d.ts.map +1 -0
- package/es/lsp-app-contribution.js +155 -0
- package/es/lsp-protocol.d.ts +10 -0
- package/es/lsp-protocol.d.ts.map +1 -0
- package/es/lsp-protocol.js +1 -0
- package/es/lsp.d.ts +136 -0
- package/es/lsp.d.ts.map +1 -0
- package/es/lsp.js +141 -0
- package/es/manager.d.ts +142 -0
- package/es/manager.d.ts.map +1 -0
- package/es/manager.js +423 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +21 -0
- package/es/plugin.d.ts +56 -0
- package/es/plugin.d.ts.map +1 -0
- package/es/plugin.js +0 -0
- package/es/positioning.d.ts +66 -0
- package/es/positioning.d.ts.map +1 -0
- package/es/positioning.js +96 -0
- package/es/schema.d.ts +240 -0
- package/es/schema.d.ts.map +1 -0
- package/es/schema.js +0 -0
- package/es/tokens.d.ts +677 -0
- package/es/tokens.d.ts.map +1 -0
- package/es/tokens.js +183 -0
- package/es/utils.d.ts +33 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +168 -0
- package/es/virtual/document.d.ts +546 -0
- package/es/virtual/document.d.ts.map +1 -0
- package/es/virtual/document.js +1263 -0
- package/es/ws-connection/server-capability-registration.d.ts +19 -0
- package/es/ws-connection/server-capability-registration.d.ts.map +1 -0
- package/es/ws-connection/server-capability-registration.js +51 -0
- package/es/ws-connection/types.d.ts +76 -0
- package/es/ws-connection/types.d.ts.map +1 -0
- package/es/ws-connection/types.js +1 -0
- package/es/ws-connection/ws-connection.d.ts +105 -0
- package/es/ws-connection/ws-connection.d.ts.map +1 -0
- package/es/ws-connection/ws-connection.js +301 -0
- package/package.json +67 -0
- package/src/adapters/adapter.ts +611 -0
- package/src/adapters/notebook-adapter.ts +463 -0
- package/src/adapters/status-message.ts +93 -0
- package/src/connection-manager.ts +626 -0
- package/src/connection.ts +570 -0
- package/src/extractors/index.ts +6 -0
- package/src/extractors/manager.ts +82 -0
- package/src/extractors/text-extractor.ts +94 -0
- package/src/extractors/types.ts +78 -0
- package/src/feature.ts +60 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +21 -0
- package/src/lsp-app-contribution.ts +83 -0
- package/src/lsp-protocol.ts +10 -0
- package/src/lsp.ts +160 -0
- package/src/manager.ts +358 -0
- package/src/module.ts +32 -0
- package/src/plugin.ts +62 -0
- package/src/positioning.ts +121 -0
- package/src/schema.ts +249 -0
- package/src/tokens.ts +843 -0
- package/src/utils.ts +109 -0
- package/src/virtual/document.ts +1250 -0
- package/src/ws-connection/server-capability-registration.ts +77 -0
- package/src/ws-connection/types.ts +102 -0
- package/src/ws-connection/ws-connection.ts +320 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Registration, ServerCapabilities, Unregistration } from 'vscode-languageserver-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Register the capabilities with the server capabilities provider
|
|
4
|
+
*
|
|
5
|
+
* @param serverCapabilities - server capabilities provider.
|
|
6
|
+
* @param registration - capabilities to be registered.
|
|
7
|
+
* @return - the new server capabilities provider
|
|
8
|
+
*/
|
|
9
|
+
declare function registerServerCapability(serverCapabilities: ServerCapabilities, registration: Registration): ServerCapabilities | null;
|
|
10
|
+
/**
|
|
11
|
+
* Unregister the capabilities with the server capabilities provider
|
|
12
|
+
*
|
|
13
|
+
* @param serverCapabilities - server capabilities provider.
|
|
14
|
+
* @param registration - capabilities to be unregistered.
|
|
15
|
+
* @return - the new server capabilities provider
|
|
16
|
+
*/
|
|
17
|
+
declare function unregisterServerCapability(serverCapabilities: ServerCapabilities, unregistration: Unregistration): ServerCapabilities;
|
|
18
|
+
export { registerServerCapability, unregisterServerCapability };
|
|
19
|
+
//# sourceMappingURL=server-capability-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-capability-registration.d.ts","sourceRoot":"","sources":["../../src/ws-connection/server-capability-registration.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACf,MAAM,gCAAgC,CAAC;AAMxC;;;;;;GAMG;AACH,iBAAS,wBAAwB,CAC/B,kBAAkB,EAAE,kBAAkB,EACtC,YAAY,EAAE,YAAY,GACzB,kBAAkB,GAAG,IAAI,CAqB3B;AAED;;;;;;GAMG;AACH,iBAAS,0BAA0B,CACjC,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,cAAc,GAC7B,kBAAkB,CAUpB;AAED,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Disclaimer/acknowledgement: Fragments are based on https://github.com/wylieconlon/lsp-editor-adapter,
|
|
7
|
+
// which is copyright of wylieconlon and contributors and ISC licenced.
|
|
8
|
+
// ISC licence is, quote, "functionally equivalent to the simplified BSD and MIT licenses,
|
|
9
|
+
// but without language deemed unnecessary following the Berne Convention." (Wikipedia).
|
|
10
|
+
// Introduced modifications are BSD licenced, copyright JupyterLab development team.
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Register the capabilities with the server capabilities provider
|
|
14
|
+
*
|
|
15
|
+
* @param serverCapabilities - server capabilities provider.
|
|
16
|
+
* @param registration - capabilities to be registered.
|
|
17
|
+
* @return - the new server capabilities provider
|
|
18
|
+
*/
|
|
19
|
+
function registerServerCapability(serverCapabilities, registration) {
|
|
20
|
+
var serverCapabilitiesCopy = JSON.parse(JSON.stringify(serverCapabilities));
|
|
21
|
+
var method = registration.method,
|
|
22
|
+
registerOptions = registration.registerOptions;
|
|
23
|
+
var providerName = method.substring(13) + 'Provider';
|
|
24
|
+
if (providerName) {
|
|
25
|
+
if (!registerOptions) {
|
|
26
|
+
serverCapabilitiesCopy[providerName] = true;
|
|
27
|
+
} else {
|
|
28
|
+
serverCapabilitiesCopy[providerName] = JSON.parse(JSON.stringify(registerOptions));
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
console.warn('Could not register server capability.', registration);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return serverCapabilitiesCopy;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Unregister the capabilities with the server capabilities provider
|
|
39
|
+
*
|
|
40
|
+
* @param serverCapabilities - server capabilities provider.
|
|
41
|
+
* @param registration - capabilities to be unregistered.
|
|
42
|
+
* @return - the new server capabilities provider
|
|
43
|
+
*/
|
|
44
|
+
function unregisterServerCapability(serverCapabilities, unregistration) {
|
|
45
|
+
var serverCapabilitiesCopy = JSON.parse(JSON.stringify(serverCapabilities));
|
|
46
|
+
var method = unregistration.method;
|
|
47
|
+
var providerName = method.substring(13) + 'Provider';
|
|
48
|
+
delete serverCapabilitiesCopy[providerName];
|
|
49
|
+
return serverCapabilitiesCopy;
|
|
50
|
+
}
|
|
51
|
+
export { registerServerCapability, unregisterServerCapability };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type * as lsp from 'vscode-languageserver-protocol';
|
|
2
|
+
export interface IDocumentInfo {
|
|
3
|
+
/**
|
|
4
|
+
* URI of the virtual document.
|
|
5
|
+
*/
|
|
6
|
+
uri: string;
|
|
7
|
+
/**
|
|
8
|
+
* Version of the virtual document.
|
|
9
|
+
*/
|
|
10
|
+
version: number;
|
|
11
|
+
/**
|
|
12
|
+
* Text content of the document.
|
|
13
|
+
*/
|
|
14
|
+
text: string;
|
|
15
|
+
/**
|
|
16
|
+
* Language id of the document.
|
|
17
|
+
*/
|
|
18
|
+
languageId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ILspConnection {
|
|
21
|
+
/**
|
|
22
|
+
* Is the language server is connected?
|
|
23
|
+
*/
|
|
24
|
+
isConnected: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Is the language server is initialized?
|
|
27
|
+
*/
|
|
28
|
+
isInitialized: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Is the language server is connected and initialized?
|
|
31
|
+
*/
|
|
32
|
+
isReady: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Initialize a connection over a web socket that speaks the LSP protocol
|
|
35
|
+
*/
|
|
36
|
+
connect(socket: WebSocket): void;
|
|
37
|
+
/**
|
|
38
|
+
* Close the connection
|
|
39
|
+
*/
|
|
40
|
+
close(): void;
|
|
41
|
+
/**
|
|
42
|
+
* The initialize request tells the server which options the client supports
|
|
43
|
+
*/
|
|
44
|
+
sendInitialize(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Inform the server that the document was opened
|
|
47
|
+
*/
|
|
48
|
+
sendOpen(documentInfo: IDocumentInfo): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sends the full text of the document to the server
|
|
51
|
+
*/
|
|
52
|
+
sendChange(documentInfo: IDocumentInfo): void;
|
|
53
|
+
/**
|
|
54
|
+
* Send save notification to the server.
|
|
55
|
+
*/
|
|
56
|
+
sendSaved(documentInfo: IDocumentInfo): void;
|
|
57
|
+
/**
|
|
58
|
+
* Send configuration change to the server.
|
|
59
|
+
*/
|
|
60
|
+
sendConfigurationChange(settings: lsp.DidChangeConfigurationParams): void;
|
|
61
|
+
}
|
|
62
|
+
export interface ILspOptions {
|
|
63
|
+
/**
|
|
64
|
+
* LSP handler endpoint.
|
|
65
|
+
*/
|
|
66
|
+
serverUri: string;
|
|
67
|
+
/**
|
|
68
|
+
* Language Id.
|
|
69
|
+
*/
|
|
70
|
+
languageId: string;
|
|
71
|
+
/**
|
|
72
|
+
* The root URI set by server.
|
|
73
|
+
*/
|
|
74
|
+
rootUri: string;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ws-connection/types.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,GAAG,MAAM,gCAAgC,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAGd;;OAEG;IACH,cAAc,IAAI,IAAI,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAE5C;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAE9C;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACH,uBAAuB,CAAC,QAAQ,EAAE,GAAG,CAAC,4BAA4B,GAAG,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Disposable, Event } from '@difizen/mana-app';
|
|
2
|
+
import { Emitter } from '@difizen/mana-app';
|
|
3
|
+
import type * as protocol from 'vscode-languageserver-protocol';
|
|
4
|
+
import type { MessageConnection } from 'vscode-ws-jsonrpc';
|
|
5
|
+
import type { IDocumentInfo, ILspConnection, ILspOptions } from './types.js';
|
|
6
|
+
export declare class LspWsConnection implements ILspConnection, Disposable {
|
|
7
|
+
constructor(options: ILspOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Is the language server is connected?
|
|
10
|
+
*/
|
|
11
|
+
get isConnected(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Is the language server is initialized?
|
|
14
|
+
*/
|
|
15
|
+
get isInitialized(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Is the language server is connected and initialized?
|
|
18
|
+
*/
|
|
19
|
+
get isReady(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* A signal emitted when the connection is disposed.
|
|
22
|
+
*/
|
|
23
|
+
get onDisposed(): Event<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if the connection is disposed
|
|
26
|
+
*/
|
|
27
|
+
get isDisposed(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Initialize a connection over a web socket that speaks the LSP protocol
|
|
30
|
+
*/
|
|
31
|
+
connect(socket: WebSocket): void;
|
|
32
|
+
/**
|
|
33
|
+
* Close the connection
|
|
34
|
+
*/
|
|
35
|
+
close(): void;
|
|
36
|
+
/**
|
|
37
|
+
* The initialize request telling the server which options the client supports
|
|
38
|
+
*/
|
|
39
|
+
sendInitialize(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Inform the server that the document was opened
|
|
42
|
+
*/
|
|
43
|
+
sendOpen(documentInfo: IDocumentInfo): void;
|
|
44
|
+
/**
|
|
45
|
+
* Sends the full text of the document to the server
|
|
46
|
+
*/
|
|
47
|
+
sendChange(documentInfo: IDocumentInfo): void;
|
|
48
|
+
/**
|
|
49
|
+
* Send save notification to the server.
|
|
50
|
+
*/
|
|
51
|
+
sendSaved(documentInfo: IDocumentInfo): void;
|
|
52
|
+
/**
|
|
53
|
+
* Send configuration change to the server.
|
|
54
|
+
*/
|
|
55
|
+
sendConfigurationChange(settings: protocol.DidChangeConfigurationParams): void;
|
|
56
|
+
/**
|
|
57
|
+
* Dispose the connection.
|
|
58
|
+
*/
|
|
59
|
+
dispose(): void;
|
|
60
|
+
/**
|
|
61
|
+
* The internal websocket connection to the LSP handler
|
|
62
|
+
*/
|
|
63
|
+
protected socket: WebSocket;
|
|
64
|
+
/**
|
|
65
|
+
* The json-rpc wrapper over the internal websocket connection.
|
|
66
|
+
*/
|
|
67
|
+
protected connection: MessageConnection;
|
|
68
|
+
/**
|
|
69
|
+
* Map to track opened virtual documents..
|
|
70
|
+
*/
|
|
71
|
+
protected openedUris: Map<string, boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Server capabilities provider.
|
|
74
|
+
*/
|
|
75
|
+
protected serverCapabilities: protocol.ServerCapabilities;
|
|
76
|
+
/**
|
|
77
|
+
* The connection is connected?
|
|
78
|
+
*/
|
|
79
|
+
protected _isConnected: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The connection is initialized?
|
|
82
|
+
*/
|
|
83
|
+
protected _isInitialized: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Array of LSP callback disposables, it is used to
|
|
86
|
+
* clear the callbacks when the connection is disposed.
|
|
87
|
+
*/
|
|
88
|
+
protected _disposables: protocol.Disposable[];
|
|
89
|
+
/**
|
|
90
|
+
* Callback called when the server is initialized.
|
|
91
|
+
*/
|
|
92
|
+
protected onServerInitialized(params: protocol.InitializeResult): void;
|
|
93
|
+
/**
|
|
94
|
+
* Initialization parameters to be sent to the language server.
|
|
95
|
+
* Subclasses should override this when adding more features.
|
|
96
|
+
*/
|
|
97
|
+
protected initializeParams(): protocol.InitializeParams;
|
|
98
|
+
/**
|
|
99
|
+
* URI of the LSP handler enpoint.
|
|
100
|
+
*/
|
|
101
|
+
protected _rootUri: string;
|
|
102
|
+
protected _disposed: Emitter<void>;
|
|
103
|
+
protected _isDisposed: boolean;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=ws-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-connection.d.ts","sourceRoot":"","sources":["../../src/ws-connection/ws-connection.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAO3D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE7E,qBAAa,eAAgB,YAAW,cAAc,EAAE,UAAU;gBACpD,OAAO,EAAE,WAAW;IAIhC;;OAEG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;OAEG;IACH,IAAI,OAAO,YAEV;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,KAAK,CAAC,IAAI,CAAC,CAE5B;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI;IAsDhC;;OAEG;IACH,KAAK;IAQL;;OAEG;IACH,cAAc;IAuBd;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa;IAgBpC;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,aAAa;IAqBtC;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,aAAa;IAiBrC;;OAEG;IACH,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,4BAA4B;IAUvE;;OAEG;IACH,OAAO,IAAI,IAAI;IAWf;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;IAE5B;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,iBAAiB,CAAC;IAExC;;OAEG;IACH,SAAS,CAAC,UAAU,uBAA8B;IAElD;;OAEG;IACH,SAAS,CAAC,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IAE1D;;OAEG;IACH,SAAS,CAAC,YAAY,UAAS;IAE/B;;OAEG;IACH,SAAS,CAAC,cAAc,UAAS;IAEjC;;;OAGG;IACH,SAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAM;IAEnD;;OAEG;IACH,SAAS,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,GAAG,IAAI;IAWtE;;;OAGG;IACH,SAAS,CAAC,gBAAgB,IAAI,QAAQ,CAAC,gBAAgB;IASvD;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE3B,SAAS,CAAC,SAAS,gBAAuB;IAE1C,SAAS,CAAC,WAAW,UAAS;CAC/B"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (c) Jupyter Development Team.
|
|
9
|
+
* Distributed under the terms of the Modified BSD License.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// Disclaimer/acknowledgement: Fragments are based on https://github.com/wylieconlon/lsp-editor-adapter,
|
|
13
|
+
// which is copyright of wylieconlon and contributors and ISC licenced.
|
|
14
|
+
// ISC licence is, quote, "functionally equivalent to the simplified BSD and MIT licenses,
|
|
15
|
+
// but without language deemed unnecessary following the Berne Convention." (Wikipedia).
|
|
16
|
+
// Introduced modifications are BSD licenced, copyright JupyterLab development team.
|
|
17
|
+
|
|
18
|
+
import { Emitter } from '@difizen/mana-app';
|
|
19
|
+
|
|
20
|
+
//TODO: vscode-ws-jsonrpc has new version
|
|
21
|
+
|
|
22
|
+
import { ConsoleLogger, listen } from 'vscode-ws-jsonrpc';
|
|
23
|
+
import { registerServerCapability, unregisterServerCapability } from "./server-capability-registration.js";
|
|
24
|
+
export var LspWsConnection = /*#__PURE__*/function () {
|
|
25
|
+
function LspWsConnection(options) {
|
|
26
|
+
_classCallCheck(this, LspWsConnection);
|
|
27
|
+
/**
|
|
28
|
+
* Map to track opened virtual documents..
|
|
29
|
+
*/
|
|
30
|
+
this.openedUris = new Map();
|
|
31
|
+
/**
|
|
32
|
+
* The connection is connected?
|
|
33
|
+
*/
|
|
34
|
+
this._isConnected = false;
|
|
35
|
+
/**
|
|
36
|
+
* The connection is initialized?
|
|
37
|
+
*/
|
|
38
|
+
this._isInitialized = false;
|
|
39
|
+
/**
|
|
40
|
+
* Array of LSP callback disposables, it is used to
|
|
41
|
+
* clear the callbacks when the connection is disposed.
|
|
42
|
+
*/
|
|
43
|
+
this._disposables = [];
|
|
44
|
+
this._disposed = new Emitter();
|
|
45
|
+
this._isDisposed = false;
|
|
46
|
+
this._rootUri = options.rootUri;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Is the language server is connected?
|
|
51
|
+
*/
|
|
52
|
+
_createClass(LspWsConnection, [{
|
|
53
|
+
key: "isConnected",
|
|
54
|
+
get: function get() {
|
|
55
|
+
return this._isConnected;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Is the language server is initialized?
|
|
60
|
+
*/
|
|
61
|
+
}, {
|
|
62
|
+
key: "isInitialized",
|
|
63
|
+
get: function get() {
|
|
64
|
+
return this._isInitialized;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Is the language server is connected and initialized?
|
|
69
|
+
*/
|
|
70
|
+
}, {
|
|
71
|
+
key: "isReady",
|
|
72
|
+
get: function get() {
|
|
73
|
+
return this._isConnected && this._isInitialized;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A signal emitted when the connection is disposed.
|
|
78
|
+
*/
|
|
79
|
+
}, {
|
|
80
|
+
key: "onDisposed",
|
|
81
|
+
get: function get() {
|
|
82
|
+
return this._disposed.event;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Check if the connection is disposed
|
|
87
|
+
*/
|
|
88
|
+
}, {
|
|
89
|
+
key: "isDisposed",
|
|
90
|
+
get: function get() {
|
|
91
|
+
return this._isDisposed;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Initialize a connection over a web socket that speaks the LSP protocol
|
|
96
|
+
*/
|
|
97
|
+
}, {
|
|
98
|
+
key: "connect",
|
|
99
|
+
value: function connect(socket) {
|
|
100
|
+
var _this = this;
|
|
101
|
+
this.socket = socket;
|
|
102
|
+
listen({
|
|
103
|
+
webSocket: this.socket,
|
|
104
|
+
logger: new ConsoleLogger(),
|
|
105
|
+
onConnection: function onConnection(connection) {
|
|
106
|
+
connection.listen();
|
|
107
|
+
_this._isConnected = true;
|
|
108
|
+
_this.connection = connection;
|
|
109
|
+
_this.sendInitialize();
|
|
110
|
+
var registerCapabilityDisposable = _this.connection.onRequest('client/registerCapability', function (params) {
|
|
111
|
+
params.registrations.forEach(function (capabilityRegistration) {
|
|
112
|
+
try {
|
|
113
|
+
_this.serverCapabilities = registerServerCapability(_this.serverCapabilities, capabilityRegistration);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error(err);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
_this._disposables.push(registerCapabilityDisposable);
|
|
120
|
+
var unregisterCapabilityDisposable = _this.connection.onRequest('client/unregisterCapability', function (params) {
|
|
121
|
+
params.unregisterations.forEach(function (capabilityUnregistration) {
|
|
122
|
+
_this.serverCapabilities = unregisterServerCapability(_this.serverCapabilities, capabilityUnregistration);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
_this._disposables.push(unregisterCapabilityDisposable);
|
|
126
|
+
var disposable = _this.connection.onClose(function () {
|
|
127
|
+
_this._isConnected = false;
|
|
128
|
+
});
|
|
129
|
+
_this._disposables.push(disposable);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Close the connection
|
|
136
|
+
*/
|
|
137
|
+
}, {
|
|
138
|
+
key: "close",
|
|
139
|
+
value: function close() {
|
|
140
|
+
if (this.connection) {
|
|
141
|
+
this.connection.dispose();
|
|
142
|
+
}
|
|
143
|
+
this.openedUris.clear();
|
|
144
|
+
this.socket.close();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The initialize request telling the server which options the client supports
|
|
149
|
+
*/
|
|
150
|
+
}, {
|
|
151
|
+
key: "sendInitialize",
|
|
152
|
+
value: function sendInitialize() {
|
|
153
|
+
var _this2 = this;
|
|
154
|
+
if (!this._isConnected) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this.openedUris.clear();
|
|
158
|
+
var message = this.initializeParams();
|
|
159
|
+
this.connection.sendRequest('initialize', message).then(function (params) {
|
|
160
|
+
_this2.onServerInitialized(params);
|
|
161
|
+
return;
|
|
162
|
+
}, function (e) {
|
|
163
|
+
console.warn('LSP websocket connection initialization failure', e);
|
|
164
|
+
}).catch(console.error);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Inform the server that the document was opened
|
|
169
|
+
*/
|
|
170
|
+
}, {
|
|
171
|
+
key: "sendOpen",
|
|
172
|
+
value: function sendOpen(documentInfo) {
|
|
173
|
+
var textDocumentMessage = {
|
|
174
|
+
textDocument: {
|
|
175
|
+
uri: documentInfo.uri,
|
|
176
|
+
languageId: documentInfo.languageId,
|
|
177
|
+
text: documentInfo.text,
|
|
178
|
+
version: documentInfo.version
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
this.connection.sendNotification('textDocument/didOpen', textDocumentMessage).catch(console.error);
|
|
182
|
+
this.openedUris.set(documentInfo.uri, true);
|
|
183
|
+
this.sendChange(documentInfo);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Sends the full text of the document to the server
|
|
188
|
+
*/
|
|
189
|
+
}, {
|
|
190
|
+
key: "sendChange",
|
|
191
|
+
value: function sendChange(documentInfo) {
|
|
192
|
+
if (!this.isReady) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (!this.openedUris.get(documentInfo.uri)) {
|
|
196
|
+
this.sendOpen(documentInfo);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var textDocumentChange = {
|
|
200
|
+
textDocument: {
|
|
201
|
+
uri: documentInfo.uri,
|
|
202
|
+
version: documentInfo.version
|
|
203
|
+
},
|
|
204
|
+
contentChanges: [{
|
|
205
|
+
text: documentInfo.text
|
|
206
|
+
}]
|
|
207
|
+
};
|
|
208
|
+
this.connection.sendNotification('textDocument/didChange', textDocumentChange).catch(console.error);
|
|
209
|
+
documentInfo.version++;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Send save notification to the server.
|
|
214
|
+
*/
|
|
215
|
+
}, {
|
|
216
|
+
key: "sendSaved",
|
|
217
|
+
value: function sendSaved(documentInfo) {
|
|
218
|
+
if (!this.isReady) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
var textDocumentChange = {
|
|
222
|
+
textDocument: {
|
|
223
|
+
uri: documentInfo.uri,
|
|
224
|
+
version: documentInfo.version
|
|
225
|
+
},
|
|
226
|
+
text: documentInfo.text
|
|
227
|
+
};
|
|
228
|
+
this.connection.sendNotification('textDocument/didSave', textDocumentChange).catch(console.error);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Send configuration change to the server.
|
|
233
|
+
*/
|
|
234
|
+
}, {
|
|
235
|
+
key: "sendConfigurationChange",
|
|
236
|
+
value: function sendConfigurationChange(settings) {
|
|
237
|
+
if (!this.isReady) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
this.connection.sendNotification('workspace/didChangeConfiguration', settings).catch(console.error);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Dispose the connection.
|
|
245
|
+
*/
|
|
246
|
+
}, {
|
|
247
|
+
key: "dispose",
|
|
248
|
+
value: function dispose() {
|
|
249
|
+
if (this._isDisposed) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this._isDisposed = true;
|
|
253
|
+
this._disposables.forEach(function (disposable) {
|
|
254
|
+
disposable.dispose();
|
|
255
|
+
});
|
|
256
|
+
this._disposed.fire();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The internal websocket connection to the LSP handler
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The json-rpc wrapper over the internal websocket connection.
|
|
265
|
+
*/
|
|
266
|
+
}, {
|
|
267
|
+
key: "onServerInitialized",
|
|
268
|
+
value:
|
|
269
|
+
/**
|
|
270
|
+
* Callback called when the server is initialized.
|
|
271
|
+
*/
|
|
272
|
+
function onServerInitialized(params) {
|
|
273
|
+
this._isInitialized = true;
|
|
274
|
+
this.serverCapabilities = params.capabilities;
|
|
275
|
+
this.connection.sendNotification('initialized', {}).catch(console.error);
|
|
276
|
+
this.connection.sendNotification('workspace/didChangeConfiguration', {
|
|
277
|
+
settings: {}
|
|
278
|
+
}).catch(console.error);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Initialization parameters to be sent to the language server.
|
|
283
|
+
* Subclasses should override this when adding more features.
|
|
284
|
+
*/
|
|
285
|
+
}, {
|
|
286
|
+
key: "initializeParams",
|
|
287
|
+
value: function initializeParams() {
|
|
288
|
+
return {
|
|
289
|
+
capabilities: {},
|
|
290
|
+
processId: null,
|
|
291
|
+
rootUri: this._rootUri,
|
|
292
|
+
workspaceFolders: null
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* URI of the LSP handler enpoint.
|
|
298
|
+
*/
|
|
299
|
+
}]);
|
|
300
|
+
return LspWsConnection;
|
|
301
|
+
}();
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@difizen/libro-lsp",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"libro",
|
|
7
|
+
"notebook"
|
|
8
|
+
],
|
|
9
|
+
"repository": "git@github.com:difizen/libro.git",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"typings": "./es/index.d.ts",
|
|
15
|
+
"default": "./es/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./mock": {
|
|
18
|
+
"typings": "./es/mock/index.d.ts",
|
|
19
|
+
"default": "./es/mock/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./es/mock": {
|
|
22
|
+
"typings": "./es/mock/index.d.ts",
|
|
23
|
+
"default": "./es/mock/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"main": "es/index.js",
|
|
28
|
+
"module": "es/index.js",
|
|
29
|
+
"typings": "es/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"es",
|
|
32
|
+
"src"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@difizen/libro-core": "^0.1.2",
|
|
36
|
+
"@difizen/libro-kernel": "^0.1.2",
|
|
37
|
+
"@difizen/libro-common": "^0.1.2",
|
|
38
|
+
"@difizen/libro-code-editor": "^0.1.2",
|
|
39
|
+
"@difizen/mana-app": "latest",
|
|
40
|
+
"lodash.mergewith": "^4.6.2",
|
|
41
|
+
"uuid": "^9.0.0",
|
|
42
|
+
"vscode-jsonrpc": "^6.0.0",
|
|
43
|
+
"vscode-languageserver-protocol": "^3.17.0",
|
|
44
|
+
"vscode-ws-jsonrpc": "~1.0.2"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": "^18.2.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/lodash.mergewith": "^4.6.9",
|
|
51
|
+
"@types/react": "^18.2.25",
|
|
52
|
+
"@types/uuid": "^9.0.2"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"setup": "father build",
|
|
56
|
+
"build": "father build",
|
|
57
|
+
"test": ": Note: lint task is delegated to test:* scripts",
|
|
58
|
+
"test:vitest": "vitest run",
|
|
59
|
+
"test:jest": "jest",
|
|
60
|
+
"coverage": ": Note: lint task is delegated to coverage:* scripts",
|
|
61
|
+
"coverage:vitest": "vitest run --coverage",
|
|
62
|
+
"coverage:jest": "jest --coverage",
|
|
63
|
+
"lint": ": Note: lint task is delegated to lint:* scripts",
|
|
64
|
+
"lint:eslint": "eslint src",
|
|
65
|
+
"lint:tsc": "tsc --noEmit"
|
|
66
|
+
}
|
|
67
|
+
}
|