@atlaspack/lsp 2.14.2-canary.52 → 2.14.2-canary.520

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