@kerebron/extension-lsp 0.4.8 → 0.4.9

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.
@@ -2,6 +2,9 @@ import { Plugin, PluginKey } from 'prosemirror-state';
2
2
  import { Decoration, DecorationSet } from 'prosemirror-view';
3
3
  const DiagnosticPluginKey = new PluginKey('lsp-diagnostic');
4
4
  export class DiagnosticPlugin extends Plugin {
5
+ diagListener;
6
+ listenerDisconnect;
7
+ listenerChange;
5
8
  constructor(config, extension) {
6
9
  super({
7
10
  key: DiagnosticPluginKey,
@@ -60,24 +63,6 @@ export class DiagnosticPlugin extends Plugin {
60
63
  },
61
64
  },
62
65
  });
63
- Object.defineProperty(this, "diagListener", {
64
- enumerable: true,
65
- configurable: true,
66
- writable: true,
67
- value: void 0
68
- });
69
- Object.defineProperty(this, "listenerDisconnect", {
70
- enumerable: true,
71
- configurable: true,
72
- writable: true,
73
- value: void 0
74
- });
75
- Object.defineProperty(this, "listenerChange", {
76
- enumerable: true,
77
- configurable: true,
78
- writable: true,
79
- value: void 0
80
- });
81
66
  let lastDiag = 0;
82
67
  const editor = extension.getEditor();
83
68
  const uri = editor.config.uri;
@@ -5,56 +5,17 @@ import { AutocompletePlugin } from '@kerebron/extension-autocomplete/Autocomplet
5
5
  import { DiagnosticPlugin } from './DiagnosticPlugin.js';
6
6
  import { createLspAutocomplete } from './createLspAutocomplete.js';
7
7
  export class ExtensionLsp extends Extension {
8
+ config;
9
+ name = 'lsp';
10
+ clients = {};
11
+ uri;
12
+ extensionMarkdown;
13
+ extensionAutocomplete;
14
+ mainLang = 'markdown';
15
+ source;
8
16
  constructor(config) {
9
17
  super(config);
10
- Object.defineProperty(this, "config", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: config
15
- });
16
- Object.defineProperty(this, "name", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: 'lsp'
21
- });
22
- Object.defineProperty(this, "clients", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: {}
27
- });
28
- Object.defineProperty(this, "uri", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: void 0
33
- });
34
- Object.defineProperty(this, "extensionMarkdown", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- Object.defineProperty(this, "extensionAutocomplete", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: void 0
45
- });
46
- Object.defineProperty(this, "mainLang", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: 'markdown'
51
- });
52
- Object.defineProperty(this, "source", {
53
- enumerable: true,
54
- configurable: true,
55
- writable: true,
56
- value: void 0
57
- });
18
+ this.config = config;
58
19
  }
59
20
  getProseMirrorPlugins() {
60
21
  const plugins = [];
package/esm/LSPClient.js CHANGED
@@ -27,31 +27,14 @@ const defaultNotificationHandlers = {
27
27
  },
28
28
  };
29
29
  class Request {
30
+ id;
31
+ params;
32
+ timeout;
33
+ promise;
30
34
  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
- });
35
+ this.id = id;
36
+ this.params = params;
37
+ this.timeout = timeout;
55
38
  this.promise = new Promise((resolve, reject) => {
56
39
  this.resolve = resolve;
57
40
  this.reject = reject;
@@ -103,21 +86,8 @@ const clientCapabilities = {
103
86
  },
104
87
  };
105
88
  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
- }
89
+ isTimeout = false;
90
+ isLSP = true;
121
91
  static createTimeout() {
122
92
  const err = new LSPError('Request timed out');
123
93
  err.isTimeout = true;
@@ -125,80 +95,22 @@ export class LSPError extends Error {
125
95
  }
126
96
  }
127
97
  export class LSPClient extends EventTarget {
98
+ transport;
99
+ config;
100
+ sources = {};
101
+ workspace;
102
+ nextReqID = 0;
103
+ requests = [];
104
+ serverCapabilities = null;
105
+ supportSync = TextDocumentSyncKind.None;
106
+ timeout;
107
+ initializing;
108
+ receiveListener;
109
+ active = false;
128
110
  constructor(transport, config = {}) {
129
111
  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
- });
112
+ this.transport = transport;
113
+ this.config = config;
202
114
  this.timeout = config.timeout ?? 3000;
203
115
  this.receiveListener = (event) => this.receiveMessage(event);
204
116
  transport.addEventListener('message', this.receiveListener);
@@ -5,50 +5,16 @@ function shouldReconnectOnCode(code) {
5
5
  return reconnectCodes.includes(code);
6
6
  }
7
7
  export class LspWebSocketTransport extends EventTarget {
8
+ uri;
9
+ socket;
10
+ reconnectAttempts = 0;
11
+ maxAttempts = 10;
12
+ baseDelay = 1000;
13
+ isConnecting = false;
14
+ initialized = false;
8
15
  constructor(uri) {
9
16
  super();
10
- Object.defineProperty(this, "uri", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: uri
15
- });
16
- Object.defineProperty(this, "socket", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- Object.defineProperty(this, "reconnectAttempts", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: 0
27
- });
28
- Object.defineProperty(this, "maxAttempts", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: 10
33
- });
34
- Object.defineProperty(this, "baseDelay", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: 1000
39
- });
40
- Object.defineProperty(this, "isConnecting", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: false
45
- });
46
- Object.defineProperty(this, "initialized", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: false
51
- });
17
+ this.uri = uri;
52
18
  }
53
19
  isConnected() {
54
20
  return this.socket?.readyState === WebSocket.OPEN;
package/esm/workspace.js CHANGED
@@ -1,19 +1,10 @@
1
1
  import { TextDocumentSyncKind } from 'vscode-languageserver-protocol';
2
2
  import { computeIncrementalChanges } from './computeIncrementalChanges.js';
3
3
  export class Workspace {
4
+ client;
5
+ isConnected = false;
4
6
  constructor(client) {
5
- Object.defineProperty(this, "client", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: client
10
- });
11
- Object.defineProperty(this, "isConnected", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: false
16
- });
7
+ this.client = client;
17
8
  }
18
9
  getFile(uri) {
19
10
  return this.files.find((f) => f.uri == uri) || null;
@@ -39,70 +30,28 @@ export class Workspace {
39
30
  }
40
31
  }
41
32
  class DefaultWorkspaceFile {
33
+ uri;
34
+ languageId;
35
+ version;
36
+ content;
37
+ mapper;
38
+ source;
39
+ syncedContent = '';
42
40
  constructor(uri, languageId, version, content, mapper, source) {
43
- Object.defineProperty(this, "uri", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: uri
48
- });
49
- Object.defineProperty(this, "languageId", {
50
- enumerable: true,
51
- configurable: true,
52
- writable: true,
53
- value: languageId
54
- });
55
- Object.defineProperty(this, "version", {
56
- enumerable: true,
57
- configurable: true,
58
- writable: true,
59
- value: version
60
- });
61
- Object.defineProperty(this, "content", {
62
- enumerable: true,
63
- configurable: true,
64
- writable: true,
65
- value: content
66
- });
67
- Object.defineProperty(this, "mapper", {
68
- enumerable: true,
69
- configurable: true,
70
- writable: true,
71
- value: mapper
72
- });
73
- Object.defineProperty(this, "source", {
74
- enumerable: true,
75
- configurable: true,
76
- writable: true,
77
- value: source
78
- });
79
- Object.defineProperty(this, "syncedContent", {
80
- enumerable: true,
81
- configurable: true,
82
- writable: true,
83
- value: ''
84
- });
41
+ this.uri = uri;
42
+ this.languageId = languageId;
43
+ this.version = version;
44
+ this.content = content;
45
+ this.mapper = mapper;
46
+ this.source = source;
85
47
  }
86
48
  getUi() {
87
49
  return this.source.ui;
88
50
  }
89
51
  }
90
52
  export class DefaultWorkspace extends Workspace {
91
- constructor() {
92
- super(...arguments);
93
- Object.defineProperty(this, "files", {
94
- enumerable: true,
95
- configurable: true,
96
- writable: true,
97
- value: []
98
- });
99
- Object.defineProperty(this, "fileVersions", {
100
- enumerable: true,
101
- configurable: true,
102
- writable: true,
103
- value: Object.create(null)
104
- });
105
- }
53
+ files = [];
54
+ fileVersions = Object.create(null);
106
55
  nextFileVersion(uri) {
107
56
  return this.fileVersions[uri] = (this.fileVersions[uri] ?? -1) + 1;
108
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/extension-lsp",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "license": "MIT",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "scripts": {},
18
18
  "dependencies": {
19
- "@kerebron/editor": "0.4.8",
20
- "@kerebron/extension-autocomplete": "0.4.8",
21
- "@kerebron/extension-markdown": "0.4.8",
19
+ "@kerebron/editor": "0.4.9",
20
+ "@kerebron/extension-autocomplete": "0.4.9",
21
+ "@kerebron/extension-markdown": "0.4.9",
22
22
  "prosemirror-state": "1.4.3",
23
23
  "prosemirror-view": "1.40.0",
24
24
  "vscode-languageserver-protocol": "3.17.5"