@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 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
- var $cBkJy$path = require("path");
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
- const $7ef283f05e7b48bf$var$connection = (0, $cBkJy$vscodelanguageservernode.createConnection)((0, $cBkJy$vscodelanguageservernode.ProposedFeatures).all);
23
- const $7ef283f05e7b48bf$var$WORKSPACE_ROOT = process.cwd();
24
- const $7ef283f05e7b48bf$var$LSP_SENTINEL_FILENAME = 'lsp-server';
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
- let $7ef283f05e7b48bf$var$hasConfigurationCapability = false;
28
- let $7ef283f05e7b48bf$var$hasWorkspaceFolderCapability = false;
77
+
78
+ let hasConfigurationCapability = false;
79
+ let hasWorkspaceFolderCapability = false;
29
80
  // let hasDiagnosticRelatedInformationCapability = false;
30
- let $7ef283f05e7b48bf$var$hasDiagnosticsRefreshSupport = false;
31
- $7ef283f05e7b48bf$var$connection.onInitialize((params)=>{
32
- const capabilities = params.capabilities;
33
- // Does the client support the `workspace/configuration` request?
34
- // If not, we fall back using global settings.
35
- $7ef283f05e7b48bf$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
36
- $7ef283f05e7b48bf$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
37
- // hasDiagnosticRelatedInformationCapability = !!(
38
- // capabilities.textDocument &&
39
- // capabilities.textDocument.publishDiagnostics &&
40
- // capabilities.textDocument.publishDiagnostics.relatedInformation
41
- // );
42
- $7ef283f05e7b48bf$var$hasDiagnosticsRefreshSupport = Boolean(capabilities.workspace?.diagnostics?.refreshSupport);
43
- const result = {
44
- capabilities: {
45
- textDocumentSync: (0, $cBkJy$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
46
- // Tell the client that this server supports code completion.
47
- diagnosticProvider: {
48
- workspaceDiagnostics: false,
49
- interFileDependencies: true
50
- }
51
- }
52
- };
53
- if ($7ef283f05e7b48bf$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
54
- workspaceFolders: {
55
- supported: true
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
- return result;
112
+ }
113
+ return result;
59
114
  });
60
- $7ef283f05e7b48bf$var$connection.onInitialized(()=>{
61
- if ($7ef283f05e7b48bf$var$hasConfigurationCapability) // Register for all configuration changes.
62
- $7ef283f05e7b48bf$var$connection.client.register((0, $cBkJy$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
63
- if ($7ef283f05e7b48bf$var$hasWorkspaceFolderCapability) $7ef283f05e7b48bf$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
64
- $7ef283f05e7b48bf$var$connection.console.log('Workspace folder change event received.');
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
- $7ef283f05e7b48bf$var$connection.onRequest((0, $cBkJy$atlaspacklspprotocol.RequestImporters), async (params)=>{
69
- let client = $7ef283f05e7b48bf$var$findClient(params);
70
- if (client) {
71
- let result = await client.connection.sendRequest((0, $cBkJy$atlaspacklspprotocol.RequestImporters), params);
72
- return result;
73
- }
74
- return null;
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
- $7ef283f05e7b48bf$var$connection.onRequest((0, $cBkJy$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
77
- let client = $7ef283f05e7b48bf$var$findClient(params.textDocument.uri);
78
- let result;
79
- if (client) {
80
- // console.log(
81
- // 'DocumentDiagnosticRequest',
82
- // params.textDocument.uri,
83
- // params.previousResultId === client.lastBuild,
84
- // );
85
- if (params.previousResultId === client.lastBuild) return {
86
- kind: (0, $cBkJy$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
87
- resultId: client.lastBuild
88
- };
89
- result = await client.connection.sendRequest((0, $cBkJy$atlaspacklspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
90
- if (result) client.uris.add(params.textDocument.uri);
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
- return {
93
- kind: (0, $cBkJy$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
94
- resultId: client?.lastBuild,
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
- async done() {
111
- if (this.progressReporterPromise == null) this.begin();
112
- $cBkJy$assert(this.progressReporterPromise != null);
113
- (await this.progressReporterPromise).done();
114
- this.progressReporterPromise = null;
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
- async report(message) {
117
- if (this.progressReporterPromise == null) {
118
- this.lastMessage = message;
119
- this.begin();
120
- } else {
121
- let r = await this.progressReporterPromise;
122
- r.report(message);
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 $7ef283f05e7b48bf$var$sendDiagnosticsRefresh() {
127
- if ($7ef283f05e7b48bf$var$hasDiagnosticsRefreshSupport) $7ef283f05e7b48bf$var$connection.sendRequest((0, $cBkJy$vscodelanguageservernode.DiagnosticRefreshRequest).type);
201
+ function sendDiagnosticsRefresh() {
202
+ if (hasDiagnosticsRefreshSupport) {
203
+ connection.sendRequest(_node().DiagnosticRefreshRequest.type);
204
+ }
128
205
  }
129
- let $7ef283f05e7b48bf$var$progressReporter = new $7ef283f05e7b48bf$var$ProgressReporter();
130
- let $7ef283f05e7b48bf$var$clients = new Map();
131
- function $7ef283f05e7b48bf$var$findClient(document) {
132
- let filepath = $cBkJy$url.fileURLToPath(document);
133
- let longestPrefix = 0;
134
- let bestClient;
135
- for (let [, client] of $7ef283f05e7b48bf$var$clients){
136
- let prefix = $cBkJy$commonpathprefix([
137
- client.projectRoot,
138
- filepath
139
- ]).length;
140
- if (longestPrefix < prefix) {
141
- longestPrefix = prefix;
142
- bestClient = client;
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
- return bestClient;
221
+ }
222
+ return bestClient;
146
223
  }
147
- function $7ef283f05e7b48bf$var$loadMetafile(filepath) {
148
- const file = $cBkJy$fs.readFileSync(filepath, 'utf-8');
149
- return JSON.parse(file);
224
+ function loadMetafile(filepath) {
225
+ const file = fs().readFileSync(filepath, 'utf-8');
226
+ return JSON.parse(file);
150
227
  }
151
- function $7ef283f05e7b48bf$var$createClient(metafilepath, metafile) {
152
- let socketfilepath = metafilepath.slice(0, -5);
153
- let [reader, writer] = (0, $cBkJy$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
154
- let client = (0, $cBkJy$vscodejsonrpcnode.createMessageConnection)(reader, writer);
155
- client.listen();
156
- let uris = new Set();
157
- let result = {
158
- connection: client,
159
- uris: uris,
160
- projectRoot: metafile.projectRoot,
161
- lastBuild: '0'
162
- };
163
- client.onNotification((0, $cBkJy$atlaspacklspprotocol.NotificationBuildStatus), (state, message)=>{
164
- // console.log('got NotificationBuildStatus', state, message);
165
- if (state === 'start') {
166
- $7ef283f05e7b48bf$var$progressReporter.begin();
167
- for (let uri of uris)$7ef283f05e7b48bf$var$connection.sendDiagnostics({
168
- uri: uri,
169
- diagnostics: []
170
- });
171
- } else if (state === 'progress' && message != null) $7ef283f05e7b48bf$var$progressReporter.report(message);
172
- else if (state === 'end') {
173
- result.lastBuild = String(Date.now());
174
- $7ef283f05e7b48bf$var$sendDiagnosticsRefresh();
175
- $7ef283f05e7b48bf$var$progressReporter.done();
176
- $7ef283f05e7b48bf$var$connection.sendNotification((0, $cBkJy$atlaspacklspprotocol.NotificationBuild));
177
- }
178
- });
179
- client.onNotification((0, $cBkJy$atlaspacklspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
180
- // console.log('got NotificationWorkspaceDiagnostics', diagnostics);
181
- for (let d of diagnostics){
182
- uris.add(d.uri);
183
- $7ef283f05e7b48bf$var$connection.sendDiagnostics(d);
184
- }
185
- });
186
- client.onClose(()=>{
187
- $7ef283f05e7b48bf$var$clients.delete(JSON.stringify(metafile));
188
- $7ef283f05e7b48bf$var$sendDiagnosticsRefresh();
189
- return Promise.all([
190
- ...uris
191
- ].map((uri)=>$7ef283f05e7b48bf$var$connection.sendDiagnostics({
192
- uri: uri,
193
- diagnostics: []
194
- })));
195
- });
196
- $7ef283f05e7b48bf$var$sendDiagnosticsRefresh();
197
- $7ef283f05e7b48bf$var$clients.set(JSON.stringify(metafile), result);
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 $7ef283f05e7b48bf$var$BASEDIR = $cBkJy$path.join($cBkJy$fs.realpathSync($cBkJy$os.tmpdir()), 'parcel-lsp');
201
- $cBkJy$fs.mkdirSync($7ef283f05e7b48bf$var$BASEDIR, {
202
- recursive: true
283
+ const BASEDIR = path().join(fs().realpathSync(os().tmpdir()), 'parcel-lsp');
284
+ fs().mkdirSync(BASEDIR, {
285
+ recursive: true
203
286
  });
204
- $cBkJy$fs.writeFileSync($cBkJy$path.join($7ef283f05e7b48bf$var$BASEDIR, $7ef283f05e7b48bf$var$LSP_SENTINEL_FILENAME), '');
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 (let filename of $cBkJy$fs.readdirSync($7ef283f05e7b48bf$var$BASEDIR)){
208
- if (!filename.endsWith('.json')) continue;
209
- let filepath = $cBkJy$path.join($7ef283f05e7b48bf$var$BASEDIR, filename);
210
- const contents = $7ef283f05e7b48bf$var$loadMetafile(filepath);
211
- const { projectRoot: projectRoot } = contents;
212
- if ($7ef283f05e7b48bf$var$WORKSPACE_ROOT === projectRoot) $7ef283f05e7b48bf$var$createClient(filepath, contents);
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
- $cBkJy$parcelwatcher.subscribe($7ef283f05e7b48bf$var$BASEDIR, async (err, events)=>{
217
- if (err) throw err;
218
- for (let event of events){
219
- if (event.type === 'create' && event.path.endsWith('.json')) {
220
- const contents = $7ef283f05e7b48bf$var$loadMetafile(event.path);
221
- const { projectRoot: projectRoot } = contents;
222
- if ($7ef283f05e7b48bf$var$WORKSPACE_ROOT === projectRoot) $7ef283f05e7b48bf$var$createClient(event.path, contents);
223
- } else if (event.type === 'delete' && event.path.endsWith('.json')) {
224
- let existing = $7ef283f05e7b48bf$var$clients.get(event.path);
225
- console.log('existing', event.path, existing);
226
- if (existing) {
227
- $7ef283f05e7b48bf$var$clients.delete(event.path);
228
- existing.connection.end();
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.48+e0f533757",
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": "src/LspServer.ts",
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.81+e0f533757",
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": "e0f533757bd1019dbd108a04952c87da15286e09"
44
- }
44
+ "gitHead": "a958853ae3de2812bfd032357e9fa7cab6a1ddb6"
45
+ }