@atlaspack/lsp 2.14.2-canary.48 → 2.14.2-canary.481
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/CHANGELOG.md +27 -0
- package/lib/LspServer.js +300 -206
- package/lib/types/LspServer.d.ts +1 -0
- package/package.json +8 -7
- package/src/LspServer.ts +39 -24
- package/tsconfig.json +8 -10
- package/tsconfig.tsbuildinfo +1 -0
- package/lib/LspServer.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @atlaspack/lsp
|
|
2
2
|
|
|
3
|
+
## 2.14.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
|
|
10
|
+
- @atlaspack/lsp-protocol@2.14.4
|
|
11
|
+
|
|
12
|
+
## 2.14.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
|
|
19
|
+
- @atlaspack/lsp-protocol@2.14.3
|
|
20
|
+
|
|
21
|
+
## 2.14.2
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
28
|
+
- @atlaspack/lsp-protocol@2.14.2
|
|
29
|
+
|
|
3
30
|
## 2.14.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/lib/LspServer.js
CHANGED
|
@@ -1,235 +1,329 @@
|
|
|
1
|
-
|
|
2
|
-
var $cBkJy$fs = require("fs");
|
|
3
|
-
var $cBkJy$os = require("os");
|
|
4
|
-
var $cBkJy$vscodelanguageservernode = require("vscode-languageserver/node");
|
|
5
|
-
var $cBkJy$vscodejsonrpcnode = require("vscode-jsonrpc/node");
|
|
6
|
-
var $cBkJy$assert = require("assert");
|
|
7
|
-
var $cBkJy$url = require("url");
|
|
8
|
-
var $cBkJy$commonpathprefix = require("common-path-prefix");
|
|
9
|
-
var $cBkJy$parcelwatcher = require("@parcel/watcher");
|
|
10
|
-
var $cBkJy$atlaspacklspprotocol = require("@atlaspack/lsp-protocol");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
20
2
|
|
|
3
|
+
function path() {
|
|
4
|
+
const data = _interopRequireWildcard(require("path"));
|
|
5
|
+
path = function () {
|
|
6
|
+
return data;
|
|
7
|
+
};
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
function fs() {
|
|
11
|
+
const data = _interopRequireWildcard(require("fs"));
|
|
12
|
+
fs = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function os() {
|
|
18
|
+
const data = _interopRequireWildcard(require("os"));
|
|
19
|
+
os = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function _node() {
|
|
25
|
+
const data = require("vscode-languageserver/node");
|
|
26
|
+
_node = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _node2() {
|
|
32
|
+
const data = require("vscode-jsonrpc/node");
|
|
33
|
+
_node2 = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function invariant() {
|
|
39
|
+
const data = _interopRequireWildcard(require("assert"));
|
|
40
|
+
invariant = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
function url() {
|
|
46
|
+
const data = _interopRequireWildcard(require("url"));
|
|
47
|
+
url = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
function watcher() {
|
|
53
|
+
const data = _interopRequireWildcard(require("@parcel/watcher"));
|
|
54
|
+
watcher = function () {
|
|
55
|
+
return data;
|
|
56
|
+
};
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
function _lspProtocol() {
|
|
60
|
+
const data = require("@atlaspack/lsp-protocol");
|
|
61
|
+
_lspProtocol = function () {
|
|
62
|
+
return data;
|
|
63
|
+
};
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
67
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
68
|
+
// import {TextDocument} from 'vscode-languageserver-textdocument';
|
|
21
69
|
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
71
|
+
const commonPathPrefix = require('common-path-prefix');
|
|
72
|
+
const connection = (0, _node().createConnection)(_node().ProposedFeatures.all);
|
|
73
|
+
const WORKSPACE_ROOT = process.cwd();
|
|
74
|
+
const LSP_SENTINEL_FILENAME = 'lsp-server';
|
|
25
75
|
// Create a simple text document manager.
|
|
26
76
|
// const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
|
|
27
|
-
|
|
28
|
-
let
|
|
77
|
+
|
|
78
|
+
let hasConfigurationCapability = false;
|
|
79
|
+
let hasWorkspaceFolderCapability = false;
|
|
29
80
|
// let hasDiagnosticRelatedInformationCapability = false;
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
81
|
+
let hasDiagnosticsRefreshSupport = false;
|
|
82
|
+
connection.onInitialize(params => {
|
|
83
|
+
var _capabilities$workspa;
|
|
84
|
+
const capabilities = params.capabilities;
|
|
85
|
+
|
|
86
|
+
// Does the client support the `workspace/configuration` request?
|
|
87
|
+
// If not, we fall back using global settings.
|
|
88
|
+
hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
|
|
89
|
+
hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
|
|
90
|
+
// hasDiagnosticRelatedInformationCapability = !!(
|
|
91
|
+
// capabilities.textDocument &&
|
|
92
|
+
// capabilities.textDocument.publishDiagnostics &&
|
|
93
|
+
// capabilities.textDocument.publishDiagnostics.relatedInformation
|
|
94
|
+
// );
|
|
95
|
+
hasDiagnosticsRefreshSupport = Boolean((_capabilities$workspa = capabilities.workspace) === null || _capabilities$workspa === void 0 || (_capabilities$workspa = _capabilities$workspa.diagnostics) === null || _capabilities$workspa === void 0 ? void 0 : _capabilities$workspa.refreshSupport);
|
|
96
|
+
const result = {
|
|
97
|
+
capabilities: {
|
|
98
|
+
textDocumentSync: _node().TextDocumentSyncKind.Incremental,
|
|
99
|
+
// Tell the client that this server supports code completion.
|
|
100
|
+
diagnosticProvider: {
|
|
101
|
+
workspaceDiagnostics: false,
|
|
102
|
+
interFileDependencies: true
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (hasWorkspaceFolderCapability) {
|
|
107
|
+
result.capabilities.workspace = {
|
|
108
|
+
workspaceFolders: {
|
|
109
|
+
supported: true
|
|
110
|
+
}
|
|
57
111
|
};
|
|
58
|
-
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
59
114
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
115
|
+
connection.onInitialized(() => {
|
|
116
|
+
if (hasConfigurationCapability) {
|
|
117
|
+
// Register for all configuration changes.
|
|
118
|
+
connection.client.register(_node().DidChangeConfigurationNotification.type, undefined);
|
|
119
|
+
}
|
|
120
|
+
if (hasWorkspaceFolderCapability) {
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
122
|
+
connection.workspace.onDidChangeWorkspaceFolders(_event => {
|
|
123
|
+
connection.console.log('Workspace folder change event received.');
|
|
65
124
|
});
|
|
125
|
+
}
|
|
66
126
|
});
|
|
127
|
+
|
|
67
128
|
// Proxy
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
129
|
+
connection.onRequest(_lspProtocol().RequestImporters, async params => {
|
|
130
|
+
// @ts-expect-error TS2345
|
|
131
|
+
const client = findClient(params);
|
|
132
|
+
if (client) {
|
|
133
|
+
const result = await client.connection.sendRequest(_lspProtocol().RequestImporters, params);
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
75
137
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
138
|
+
connection.onRequest(_node().DocumentDiagnosticRequest.type, async params => {
|
|
139
|
+
const client = findClient(params.textDocument.uri);
|
|
140
|
+
let result;
|
|
141
|
+
if (client) {
|
|
142
|
+
// console.log(
|
|
143
|
+
// 'DocumentDiagnosticRequest',
|
|
144
|
+
// params.textDocument.uri,
|
|
145
|
+
// params.previousResultId === client.lastBuild,
|
|
146
|
+
// );
|
|
147
|
+
|
|
148
|
+
if (params.previousResultId === client.lastBuild) {
|
|
149
|
+
return {
|
|
150
|
+
kind: _node().DocumentDiagnosticReportKind.Unchanged,
|
|
151
|
+
resultId: client.lastBuild
|
|
152
|
+
};
|
|
91
153
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
items: result ?? []
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
$7ef283f05e7b48bf$var$connection.listen();
|
|
99
|
-
class $7ef283f05e7b48bf$var$ProgressReporter {
|
|
100
|
-
begin() {
|
|
101
|
-
this.progressReporterPromise = (async ()=>{
|
|
102
|
-
let reporter = await $7ef283f05e7b48bf$var$connection.window.createWorkDoneProgress();
|
|
103
|
-
reporter.begin('Atlaspack');
|
|
104
|
-
return reporter;
|
|
105
|
-
})();
|
|
106
|
-
this.progressReporterPromise.then((reporter)=>{
|
|
107
|
-
if (this.lastMessage != null) reporter.report(this.lastMessage);
|
|
108
|
-
});
|
|
154
|
+
result = await client.connection.sendRequest(_lspProtocol().RequestDocumentDiagnostics, params.textDocument.uri);
|
|
155
|
+
if (result) {
|
|
156
|
+
client.uris.add(params.textDocument.uri);
|
|
109
157
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
kind: _node().DocumentDiagnosticReportKind.Full,
|
|
161
|
+
resultId: client === null || client === void 0 ? void 0 : client.lastBuild,
|
|
162
|
+
// @ts-expect-error TS2740
|
|
163
|
+
items: result ?? []
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
connection.listen();
|
|
167
|
+
class ProgressReporter {
|
|
168
|
+
begin() {
|
|
169
|
+
this.progressReporterPromise = (async () => {
|
|
170
|
+
// eslint-disable-next-line prefer-const
|
|
171
|
+
let reporter = await connection.window.createWorkDoneProgress();
|
|
172
|
+
reporter.begin('Atlaspack');
|
|
173
|
+
return reporter;
|
|
174
|
+
})();
|
|
175
|
+
this.progressReporterPromise.then(reporter => {
|
|
176
|
+
if (this.lastMessage != null) {
|
|
177
|
+
reporter.report(this.lastMessage);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async done() {
|
|
182
|
+
if (this.progressReporterPromise == null) {
|
|
183
|
+
this.begin();
|
|
115
184
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
185
|
+
// @ts-expect-error TS2349
|
|
186
|
+
invariant()(this.progressReporterPromise != null);
|
|
187
|
+
// @ts-expect-error TS2533
|
|
188
|
+
(await this.progressReporterPromise).done();
|
|
189
|
+
this.progressReporterPromise = null;
|
|
190
|
+
}
|
|
191
|
+
async report(message) {
|
|
192
|
+
if (this.progressReporterPromise == null) {
|
|
193
|
+
this.lastMessage = message;
|
|
194
|
+
this.begin();
|
|
195
|
+
} else {
|
|
196
|
+
const r = await this.progressReporterPromise;
|
|
197
|
+
r.report(message);
|
|
124
198
|
}
|
|
199
|
+
}
|
|
125
200
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
201
|
+
function sendDiagnosticsRefresh() {
|
|
202
|
+
if (hasDiagnosticsRefreshSupport) {
|
|
203
|
+
connection.sendRequest(_node().DiagnosticRefreshRequest.type);
|
|
204
|
+
}
|
|
128
205
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
} else if (longestPrefix === prefix) console.warn('Ambiguous client for ' + filepath);
|
|
206
|
+
const progressReporter = new ProgressReporter();
|
|
207
|
+
const clients = new Map();
|
|
208
|
+
function findClient(document) {
|
|
209
|
+
const filepath = url().fileURLToPath(document);
|
|
210
|
+
let longestPrefix = 0;
|
|
211
|
+
let bestClient;
|
|
212
|
+
for (const [, client] of clients) {
|
|
213
|
+
const prefix = commonPathPrefix([client.projectRoot, filepath]).length;
|
|
214
|
+
if (longestPrefix < prefix) {
|
|
215
|
+
longestPrefix = prefix;
|
|
216
|
+
bestClient = client;
|
|
217
|
+
} else if (longestPrefix === prefix) {
|
|
218
|
+
// eslint-disable-next-line no-console
|
|
219
|
+
console.warn('Ambiguous client for ' + filepath);
|
|
144
220
|
}
|
|
145
|
-
|
|
221
|
+
}
|
|
222
|
+
return bestClient;
|
|
146
223
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
149
|
-
|
|
224
|
+
function loadMetafile(filepath) {
|
|
225
|
+
const file = fs().readFileSync(filepath, 'utf-8');
|
|
226
|
+
return JSON.parse(file);
|
|
150
227
|
}
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
228
|
+
function createClient(metafilepath, metafile) {
|
|
229
|
+
const socketfilepath = metafilepath.slice(0, -5);
|
|
230
|
+
const [reader, writer] = (0, _node2().createServerPipeTransport)(socketfilepath);
|
|
231
|
+
const client = (0, _node2().createMessageConnection)(reader, writer);
|
|
232
|
+
client.listen();
|
|
233
|
+
const uris = new Set();
|
|
234
|
+
const result = {
|
|
235
|
+
connection: client,
|
|
236
|
+
uris,
|
|
237
|
+
projectRoot: metafile.projectRoot,
|
|
238
|
+
lastBuild: '0'
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// @ts-expect-error TS7006
|
|
242
|
+
client.onNotification(_lspProtocol().NotificationBuildStatus, (state, message) => {
|
|
243
|
+
// console.log('got NotificationBuildStatus', state, message);
|
|
244
|
+
if (state === 'start') {
|
|
245
|
+
progressReporter.begin();
|
|
246
|
+
for (const uri of uris) {
|
|
247
|
+
connection.sendDiagnostics({
|
|
248
|
+
uri,
|
|
249
|
+
diagnostics: []
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
} else if (state === 'progress' && message != null) {
|
|
253
|
+
progressReporter.report(message);
|
|
254
|
+
} else if (state === 'end') {
|
|
255
|
+
result.lastBuild = String(Date.now());
|
|
256
|
+
sendDiagnosticsRefresh();
|
|
257
|
+
progressReporter.done();
|
|
258
|
+
connection.sendNotification(_lspProtocol().NotificationBuild);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// @ts-expect-error TS7006
|
|
263
|
+
client.onNotification(_lspProtocol().NotificationWorkspaceDiagnostics, diagnostics => {
|
|
264
|
+
// console.log('got NotificationWorkspaceDiagnostics', diagnostics);
|
|
265
|
+
for (const d of diagnostics) {
|
|
266
|
+
uris.add(d.uri);
|
|
267
|
+
connection.sendDiagnostics(d);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
client.onClose(() => {
|
|
271
|
+
clients.delete(JSON.stringify(metafile));
|
|
272
|
+
sendDiagnosticsRefresh();
|
|
273
|
+
return Promise.all([...uris].map(uri => connection.sendDiagnostics({
|
|
274
|
+
uri,
|
|
275
|
+
diagnostics: []
|
|
276
|
+
})));
|
|
277
|
+
});
|
|
278
|
+
sendDiagnosticsRefresh();
|
|
279
|
+
clients.set(JSON.stringify(metafile), result);
|
|
198
280
|
}
|
|
281
|
+
|
|
199
282
|
// Take realpath because to have consistent cache keys on macOS (/var -> /private/var)
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
283
|
+
const BASEDIR = path().join(fs().realpathSync(os().tmpdir()), 'parcel-lsp');
|
|
284
|
+
fs().mkdirSync(BASEDIR, {
|
|
285
|
+
recursive: true
|
|
203
286
|
});
|
|
204
|
-
|
|
287
|
+
fs().writeFileSync(path().join(BASEDIR, LSP_SENTINEL_FILENAME), '');
|
|
288
|
+
|
|
205
289
|
// Search for currently running Atlaspack processes in the parcel-lsp dir.
|
|
206
290
|
// Create an IPC client connection for each running process.
|
|
207
|
-
for (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
291
|
+
for (const filename of fs().readdirSync(BASEDIR)) {
|
|
292
|
+
if (!filename.endsWith('.json')) continue;
|
|
293
|
+
const filepath = path().join(BASEDIR, filename);
|
|
294
|
+
const contents = loadMetafile(filepath);
|
|
295
|
+
const {
|
|
296
|
+
projectRoot
|
|
297
|
+
} = contents;
|
|
298
|
+
if (WORKSPACE_ROOT === projectRoot) {
|
|
299
|
+
createClient(filepath, contents);
|
|
300
|
+
}
|
|
213
301
|
}
|
|
302
|
+
|
|
214
303
|
// Watch for new Atlaspack processes in the parcel-lsp dir, and disconnect the
|
|
215
304
|
// client for each corresponding connection when a Atlaspack process ends
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
305
|
+
// eslint-disable-next-line require-await
|
|
306
|
+
watcher().subscribe(BASEDIR, async (err, events) => {
|
|
307
|
+
if (err) {
|
|
308
|
+
throw err;
|
|
309
|
+
}
|
|
310
|
+
for (const event of events) {
|
|
311
|
+
if (event.type === 'create' && event.path.endsWith('.json')) {
|
|
312
|
+
const contents = loadMetafile(event.path);
|
|
313
|
+
const {
|
|
314
|
+
projectRoot
|
|
315
|
+
} = contents;
|
|
316
|
+
if (WORKSPACE_ROOT === projectRoot) {
|
|
317
|
+
createClient(event.path, contents);
|
|
318
|
+
}
|
|
319
|
+
} else if (event.type === 'delete' && event.path.endsWith('.json')) {
|
|
320
|
+
const existing = clients.get(event.path);
|
|
321
|
+
// eslint-disable-next-line no-console
|
|
322
|
+
console.log('existing', event.path, existing);
|
|
323
|
+
if (existing) {
|
|
324
|
+
clients.delete(event.path);
|
|
325
|
+
existing.connection.end();
|
|
326
|
+
}
|
|
231
327
|
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
//# sourceMappingURL=LspServer.js.map
|
|
328
|
+
}
|
|
329
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/lsp",
|
|
3
|
-
"version": "2.14.2-canary.
|
|
3
|
+
"version": "2.14.2-canary.481+a958853ae",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,17 +10,18 @@
|
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
12
|
"main": "./lib/LspServer.js",
|
|
13
|
-
"source": "src/LspServer.ts",
|
|
14
|
-
"types": "
|
|
13
|
+
"source": "./src/LspServer.ts",
|
|
14
|
+
"types": "./lib/types/LspServer.d.ts",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"watch": "tsc -watch -p ./",
|
|
17
|
-
"lint": "eslint src --ext ts"
|
|
17
|
+
"lint": "eslint src --ext ts",
|
|
18
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
18
19
|
},
|
|
19
20
|
"engines": {
|
|
20
21
|
"node": ">= 16.0.0"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@atlaspack/lsp-protocol": "2.14.1-canary.
|
|
24
|
+
"@atlaspack/lsp-protocol": "2.14.1-canary.514+a958853ae",
|
|
24
25
|
"@parcel/watcher": "^2.0.7",
|
|
25
26
|
"common-path-prefix": "^3.0.0",
|
|
26
27
|
"nullthrows": "^1.1.1",
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
"types": false
|
|
41
42
|
},
|
|
42
43
|
"type": "commonjs",
|
|
43
|
-
"gitHead": "
|
|
44
|
-
}
|
|
44
|
+
"gitHead": "a958853ae3de2812bfd032357e9fa7cab6a1ddb6"
|
|
45
|
+
}
|