@atlaspack/reporter-lsp 2.14.21-typescript-bc4459c37.0 → 2.14.21
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 +8 -0
- package/lib/LspReporter.js +1 -28
- package/lib/ipc.js +1 -3
- package/lib/utils.js +6 -4
- package/package.json +8 -13
- package/src/{LspReporter.ts → LspReporter.js} +18 -38
- package/src/ipc.js +55 -0
- package/src/{utils.ts → utils.js} +15 -11
- package/LICENSE +0 -201
- package/lib/LspReporter.d.ts +0 -3
- package/lib/ipc.d.ts +0 -4
- package/lib/utils.d.ts +0 -38
- package/src/ipc.ts +0 -77
- package/tsconfig.json +0 -4
package/CHANGELOG.md
CHANGED
package/lib/LspReporter.js
CHANGED
|
@@ -79,10 +79,6 @@ var _utils2 = require("./utils");
|
|
|
79
79
|
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); }
|
|
80
80
|
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; }
|
|
81
81
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
82
|
-
// @ts-expect-error TS7016
|
|
83
|
-
|
|
84
|
-
// @ts-expect-error TS7016
|
|
85
|
-
|
|
86
82
|
const lookupPid = (0, _util().promisify)(ps().lookup);
|
|
87
83
|
const ignoreFail = func => {
|
|
88
84
|
try {
|
|
@@ -99,15 +95,12 @@ const getWorkspaceDiagnostics = () => [...workspaceDiagnostics].map(([uri, diagn
|
|
|
99
95
|
uri,
|
|
100
96
|
diagnostics
|
|
101
97
|
}));
|
|
102
|
-
|
|
103
|
-
// @ts-expect-error TS7034
|
|
104
98
|
let server;
|
|
105
99
|
let connections = [];
|
|
106
100
|
let bundleGraphDeferrable = (0, _utils().makeDeferredWithPromise)();
|
|
107
101
|
let bundleGraph = bundleGraphDeferrable.promise;
|
|
108
102
|
let watchStarted = false;
|
|
109
103
|
let lspStarted = false;
|
|
110
|
-
// @ts-expect-error TS7034
|
|
111
104
|
let watchStartPromise;
|
|
112
105
|
const LSP_SENTINEL_FILENAME = 'lsp-server';
|
|
113
106
|
const LSP_SENTINEL_FILE = _path().default.join(BASEDIR, LSP_SENTINEL_FILENAME);
|
|
@@ -119,8 +112,6 @@ async function watchLspActive() {
|
|
|
119
112
|
} catch {
|
|
120
113
|
//
|
|
121
114
|
}
|
|
122
|
-
|
|
123
|
-
// @ts-expect-error TS2769
|
|
124
115
|
return _fs().default.watch(BASEDIR, (eventType, filename) => {
|
|
125
116
|
switch (eventType) {
|
|
126
117
|
case 'rename':
|
|
@@ -136,8 +127,6 @@ async function watchLspActive() {
|
|
|
136
127
|
}
|
|
137
128
|
});
|
|
138
129
|
}
|
|
139
|
-
|
|
140
|
-
// @ts-expect-error TS2552
|
|
141
130
|
async function doWatchStart(options) {
|
|
142
131
|
await _fs().default.promises.mkdir(BASEDIR, {
|
|
143
132
|
recursive: true
|
|
@@ -165,15 +154,11 @@ async function doWatchStart(options) {
|
|
|
165
154
|
connection.onRequest(_lspProtocol().RequestDocumentDiagnostics, async uri => {
|
|
166
155
|
let graph = await bundleGraph;
|
|
167
156
|
if (!graph) return;
|
|
168
|
-
|
|
169
|
-
// @ts-expect-error TS2345
|
|
170
157
|
return getDiagnosticsUnusedExports(graph, uri);
|
|
171
158
|
});
|
|
172
159
|
connection.onRequest(_lspProtocol().RequestImporters, async params => {
|
|
173
160
|
let graph = await bundleGraph;
|
|
174
161
|
if (!graph) return null;
|
|
175
|
-
|
|
176
|
-
// @ts-expect-error TS2345
|
|
177
162
|
return getImporters(graph, params);
|
|
178
163
|
});
|
|
179
164
|
sendDiagnostics();
|
|
@@ -194,7 +179,6 @@ var _default = exports.default = new (_plugin().Reporter)({
|
|
|
194
179
|
watchStarted = true;
|
|
195
180
|
}
|
|
196
181
|
if (watchStarted && lspStarted) {
|
|
197
|
-
// @ts-expect-error TS7005
|
|
198
182
|
if (!watchStartPromise) {
|
|
199
183
|
watchStartPromise = doWatchStart(options);
|
|
200
184
|
}
|
|
@@ -227,9 +211,7 @@ var _default = exports.default = new (_plugin().Reporter)({
|
|
|
227
211
|
break;
|
|
228
212
|
}
|
|
229
213
|
case 'log':
|
|
230
|
-
if (
|
|
231
|
-
// @ts-expect-error TS2339
|
|
232
|
-
event.diagnostics != null && (event.level === 'error' || event.level === 'warn' || event.level === 'info' || event.level === 'verbose')) {
|
|
214
|
+
if (event.diagnostics != null && (event.level === 'error' || event.level === 'warn' || event.level === 'info' || event.level === 'verbose')) {
|
|
233
215
|
updateDiagnostics(event.diagnostics, event.level, options.projectRoot);
|
|
234
216
|
}
|
|
235
217
|
break;
|
|
@@ -243,7 +225,6 @@ var _default = exports.default = new (_plugin().Reporter)({
|
|
|
243
225
|
}
|
|
244
226
|
case 'watchEnd':
|
|
245
227
|
connections.forEach(c => c.end());
|
|
246
|
-
// @ts-expect-error TS7005
|
|
247
228
|
await server.close();
|
|
248
229
|
ignoreFail(() => _fs().default.unlinkSync(META_FILE));
|
|
249
230
|
break;
|
|
@@ -280,8 +261,6 @@ function updateDiagnostics(parcelDiagnostics, parcelSeverity, projectRoot) {
|
|
|
280
261
|
if (firstFrameHighlight == null) {
|
|
281
262
|
continue;
|
|
282
263
|
}
|
|
283
|
-
|
|
284
|
-
// @ts-expect-error TS2304
|
|
285
264
|
const relatedInformation = [];
|
|
286
265
|
for (const codeFrame of codeFrames) {
|
|
287
266
|
for (const highlight of codeFrame.codeHighlights) {
|
|
@@ -335,7 +314,6 @@ function getDiagnosticsUnusedExports(bundleGraph, document) {
|
|
|
335
314
|
}
|
|
336
315
|
});
|
|
337
316
|
if (asset) {
|
|
338
|
-
// @ts-expect-error TS2304
|
|
339
317
|
const generateDiagnostic = (loc, type) => ({
|
|
340
318
|
range: {
|
|
341
319
|
start: {
|
|
@@ -352,11 +330,8 @@ function getDiagnosticsUnusedExports(bundleGraph, document) {
|
|
|
352
330
|
message: `Unused ${type}.`,
|
|
353
331
|
tags: [_utils2.DiagnosticTag.Unnecessary]
|
|
354
332
|
});
|
|
355
|
-
|
|
356
|
-
// @ts-expect-error TS2345
|
|
357
333
|
let usedSymbols = bundleGraph.getUsedSymbols(asset);
|
|
358
334
|
if (usedSymbols) {
|
|
359
|
-
// @ts-expect-error TS2339
|
|
360
335
|
for (let [exported, symbol] of asset.symbols) {
|
|
361
336
|
if (!usedSymbols.has(exported)) {
|
|
362
337
|
if (symbol.loc) {
|
|
@@ -383,7 +358,6 @@ function getDiagnosticsUnusedExports(bundleGraph, document) {
|
|
|
383
358
|
// }
|
|
384
359
|
}
|
|
385
360
|
|
|
386
|
-
// @ts-expect-error TS2339
|
|
387
361
|
for (let dep of asset.getDependencies()) {
|
|
388
362
|
let usedSymbols = bundleGraph.getUsedSymbols(dep);
|
|
389
363
|
if (usedSymbols) {
|
|
@@ -447,7 +421,6 @@ function getImporters(bundleGraph, document) {
|
|
|
447
421
|
}
|
|
448
422
|
});
|
|
449
423
|
if (asset) {
|
|
450
|
-
// @ts-expect-error TS2345
|
|
451
424
|
let incoming = bundleGraph.getIncomingDependencies(asset);
|
|
452
425
|
return incoming.filter(dep => dep.sourcePath != null).map(dep => `file://${(0, _nullthrows().default)(dep.sourcePath)}`);
|
|
453
426
|
}
|
package/lib/ipc.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -14,8 +14,6 @@ function _path() {
|
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
// @ts-expect-error TS2724
|
|
18
|
-
|
|
19
17
|
function parcelSeverityToLspSeverity(parcelSeverity) {
|
|
20
18
|
switch (parcelSeverity) {
|
|
21
19
|
case 'error':
|
|
@@ -63,31 +61,35 @@ const DiagnosticTag = exports.DiagnosticTag = {
|
|
|
63
61
|
* Clients are allowed to render diagnostics with this tag faded out instead of having
|
|
64
62
|
* an error squiggle.
|
|
65
63
|
*/
|
|
66
|
-
//
|
|
64
|
+
// $FlowFixMe
|
|
67
65
|
Unnecessary: 1,
|
|
68
66
|
/**
|
|
69
67
|
* Deprecated or obsolete code.
|
|
70
68
|
*
|
|
71
69
|
* Clients are allowed to rendered diagnostics with this tag strike through.
|
|
72
70
|
*/
|
|
73
|
-
//
|
|
71
|
+
// $FlowFixMe
|
|
74
72
|
Deprecated: 2
|
|
75
73
|
};
|
|
76
74
|
const DiagnosticSeverity = exports.DiagnosticSeverity = {
|
|
77
75
|
/**
|
|
78
76
|
* Reports an error.
|
|
79
77
|
*/
|
|
78
|
+
// $FlowFixMe
|
|
80
79
|
Error: 1,
|
|
81
80
|
/**
|
|
82
81
|
* Reports a warning.
|
|
83
82
|
*/
|
|
83
|
+
// $FlowFixMe
|
|
84
84
|
Warning: 2,
|
|
85
85
|
/**
|
|
86
86
|
* Reports an information.
|
|
87
87
|
*/
|
|
88
|
+
// $FlowFixMe
|
|
88
89
|
Information: 3,
|
|
89
90
|
/**
|
|
90
91
|
* Reports a hint.
|
|
91
92
|
*/
|
|
93
|
+
// $FlowFixMe
|
|
92
94
|
Hint: 4
|
|
93
95
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/reporter-lsp",
|
|
3
|
-
"version": "2.14.21
|
|
3
|
+
"version": "2.14.21",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,24 +9,19 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "
|
|
13
|
-
"source": "
|
|
14
|
-
"types": "./lib/LspReporter.d.ts",
|
|
12
|
+
"main": "lib/LspReporter.js",
|
|
13
|
+
"source": "src/LspReporter.js",
|
|
15
14
|
"engines": {
|
|
16
15
|
"node": ">= 16.0.0"
|
|
17
16
|
},
|
|
18
17
|
"dependencies": {
|
|
19
|
-
"@atlaspack/lsp-protocol": "2.14.
|
|
20
|
-
"@atlaspack/plugin": "2.14.21
|
|
21
|
-
"@atlaspack/utils": "2.17.3
|
|
18
|
+
"@atlaspack/lsp-protocol": "2.14.1",
|
|
19
|
+
"@atlaspack/plugin": "2.14.21",
|
|
20
|
+
"@atlaspack/utils": "2.17.3",
|
|
22
21
|
"node-ipc": "^9.1.4",
|
|
23
22
|
"nullthrows": "^1.1.1",
|
|
24
23
|
"ps-node": "^0.1.6",
|
|
25
24
|
"vscode-jsonrpc": "^8.0.2"
|
|
26
25
|
},
|
|
27
|
-
"type": "commonjs"
|
|
28
|
-
|
|
29
|
-
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
|
30
|
-
},
|
|
31
|
-
"gitHead": "bc4459c37a38ef1f74772126637e1d8841d1fcb0"
|
|
32
|
-
}
|
|
26
|
+
"type": "commonjs"
|
|
27
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
1
3
|
import type {Diagnostic as ParcelDiagnostic} from '@atlaspack/diagnostic';
|
|
2
4
|
import type {BundleGraph, FilePath, PackagedBundle} from '@atlaspack/types';
|
|
3
|
-
// @ts-expect-error TS7016
|
|
4
5
|
import type {Program, Query} from 'ps-node';
|
|
5
6
|
import type {Diagnostic, DocumentUri} from 'vscode-languageserver';
|
|
6
7
|
import type {MessageConnection} from 'vscode-jsonrpc/node';
|
|
@@ -17,14 +18,12 @@ import os from 'os';
|
|
|
17
18
|
import url from 'url';
|
|
18
19
|
import fs from 'fs';
|
|
19
20
|
import nullthrows from 'nullthrows';
|
|
20
|
-
// @ts-expect-error TS7016
|
|
21
21
|
import * as ps from 'ps-node';
|
|
22
22
|
import {promisify} from 'util';
|
|
23
23
|
|
|
24
24
|
import {createServer} from './ipc';
|
|
25
25
|
import {
|
|
26
|
-
|
|
27
|
-
PublishDiagnostic,
|
|
26
|
+
type PublishDiagnostic,
|
|
28
27
|
NotificationBuildStatus,
|
|
29
28
|
NotificationWorkspaceDiagnostics,
|
|
30
29
|
RequestDocumentDiagnostics,
|
|
@@ -39,12 +38,12 @@ import {
|
|
|
39
38
|
} from './utils';
|
|
40
39
|
import type {FSWatcher} from 'fs';
|
|
41
40
|
|
|
42
|
-
const lookupPid: (
|
|
41
|
+
const lookupPid: (Query) => Program[] = promisify(ps.lookup);
|
|
43
42
|
|
|
44
|
-
const ignoreFail = (func
|
|
43
|
+
const ignoreFail = (func) => {
|
|
45
44
|
try {
|
|
46
45
|
func();
|
|
47
|
-
} catch (e
|
|
46
|
+
} catch (e) {
|
|
48
47
|
/**/
|
|
49
48
|
}
|
|
50
49
|
};
|
|
@@ -55,28 +54,22 @@ const META_FILE = path.join(BASEDIR, `parcel-${process.pid}.json`);
|
|
|
55
54
|
|
|
56
55
|
let workspaceDiagnostics: DefaultMap<
|
|
57
56
|
string,
|
|
58
|
-
Array<Diagnostic
|
|
57
|
+
Array<Diagnostic>,
|
|
59
58
|
> = new DefaultMap(() => []);
|
|
60
59
|
|
|
61
60
|
const getWorkspaceDiagnostics = (): Array<PublishDiagnostic> =>
|
|
62
|
-
[...workspaceDiagnostics].map(([uri, diagnostics]
|
|
63
|
-
uri,
|
|
64
|
-
diagnostics,
|
|
65
|
-
}));
|
|
61
|
+
[...workspaceDiagnostics].map(([uri, diagnostics]) => ({uri, diagnostics}));
|
|
66
62
|
|
|
67
|
-
// @ts-expect-error TS7034
|
|
68
63
|
let server;
|
|
69
64
|
let connections: Array<MessageConnection> = [];
|
|
70
65
|
|
|
71
|
-
let bundleGraphDeferrable =
|
|
72
|
-
BundleGraph<PackagedBundle
|
|
73
|
-
|
|
74
|
-
let bundleGraph: Promise<BundleGraph<PackagedBundle> | null | undefined> =
|
|
66
|
+
let bundleGraphDeferrable =
|
|
67
|
+
makeDeferredWithPromise<?BundleGraph<PackagedBundle>>();
|
|
68
|
+
let bundleGraph: Promise<?BundleGraph<PackagedBundle>> =
|
|
75
69
|
bundleGraphDeferrable.promise;
|
|
76
70
|
|
|
77
71
|
let watchStarted = false;
|
|
78
72
|
let lspStarted = false;
|
|
79
|
-
// @ts-expect-error TS7034
|
|
80
73
|
let watchStartPromise;
|
|
81
74
|
|
|
82
75
|
const LSP_SENTINEL_FILENAME = 'lsp-server';
|
|
@@ -91,7 +84,6 @@ async function watchLspActive(): Promise<FSWatcher> {
|
|
|
91
84
|
//
|
|
92
85
|
}
|
|
93
86
|
|
|
94
|
-
// @ts-expect-error TS2769
|
|
95
87
|
return fs.watch(BASEDIR, (eventType: string, filename: string) => {
|
|
96
88
|
switch (eventType) {
|
|
97
89
|
case 'rename':
|
|
@@ -108,8 +100,7 @@ async function watchLspActive(): Promise<FSWatcher> {
|
|
|
108
100
|
});
|
|
109
101
|
}
|
|
110
102
|
|
|
111
|
-
|
|
112
|
-
async function doWatchStart(options: PluginOptions) {
|
|
103
|
+
async function doWatchStart(options) {
|
|
113
104
|
await fs.promises.mkdir(BASEDIR, {recursive: true});
|
|
114
105
|
|
|
115
106
|
// For each existing file, check if the pid matches a running process.
|
|
@@ -135,7 +126,6 @@ async function doWatchStart(options: PluginOptions) {
|
|
|
135
126
|
let graph = await bundleGraph;
|
|
136
127
|
if (!graph) return;
|
|
137
128
|
|
|
138
|
-
// @ts-expect-error TS2345
|
|
139
129
|
return getDiagnosticsUnusedExports(graph, uri);
|
|
140
130
|
});
|
|
141
131
|
|
|
@@ -143,7 +133,6 @@ async function doWatchStart(options: PluginOptions) {
|
|
|
143
133
|
let graph = await bundleGraph;
|
|
144
134
|
if (!graph) return null;
|
|
145
135
|
|
|
146
|
-
// @ts-expect-error TS2345
|
|
147
136
|
return getImporters(graph, params);
|
|
148
137
|
});
|
|
149
138
|
|
|
@@ -161,14 +150,13 @@ async function doWatchStart(options: PluginOptions) {
|
|
|
161
150
|
|
|
162
151
|
watchLspActive();
|
|
163
152
|
|
|
164
|
-
export default new Reporter({
|
|
153
|
+
export default (new Reporter({
|
|
165
154
|
async report({event, options}) {
|
|
166
155
|
if (event.type === 'watchStart') {
|
|
167
156
|
watchStarted = true;
|
|
168
157
|
}
|
|
169
158
|
|
|
170
159
|
if (watchStarted && lspStarted) {
|
|
171
|
-
// @ts-expect-error TS7005
|
|
172
160
|
if (!watchStartPromise) {
|
|
173
161
|
watchStartPromise = doWatchStart(options);
|
|
174
162
|
}
|
|
@@ -201,7 +189,6 @@ export default new Reporter({
|
|
|
201
189
|
}
|
|
202
190
|
case 'log':
|
|
203
191
|
if (
|
|
204
|
-
// @ts-expect-error TS2339
|
|
205
192
|
event.diagnostics != null &&
|
|
206
193
|
(event.level === 'error' ||
|
|
207
194
|
event.level === 'warn' ||
|
|
@@ -224,17 +211,16 @@ export default new Reporter({
|
|
|
224
211
|
}
|
|
225
212
|
case 'watchEnd':
|
|
226
213
|
connections.forEach((c) => c.end());
|
|
227
|
-
// @ts-expect-error TS7005
|
|
228
214
|
await server.close();
|
|
229
215
|
ignoreFail(() => fs.unlinkSync(META_FILE));
|
|
230
216
|
break;
|
|
231
217
|
}
|
|
232
218
|
},
|
|
233
|
-
})
|
|
219
|
+
}): Reporter);
|
|
234
220
|
|
|
235
221
|
function updateBuildState(
|
|
236
222
|
state: 'start' | 'progress' | 'end',
|
|
237
|
-
message
|
|
223
|
+
message: string | void,
|
|
238
224
|
) {
|
|
239
225
|
connections.forEach((c) =>
|
|
240
226
|
c.sendNotification(NotificationBuildStatus, state, message),
|
|
@@ -280,8 +266,7 @@ function updateDiagnostics(
|
|
|
280
266
|
continue;
|
|
281
267
|
}
|
|
282
268
|
|
|
283
|
-
|
|
284
|
-
const relatedInformation: Array<DiagnosticRelatedInformation> = [];
|
|
269
|
+
const relatedInformation = [];
|
|
285
270
|
for (const codeFrame of codeFrames) {
|
|
286
271
|
for (const highlight of codeFrame.codeHighlights) {
|
|
287
272
|
const filePath = codeFrame.filePath;
|
|
@@ -338,7 +323,7 @@ function getDiagnosticsUnusedExports(
|
|
|
338
323
|
document: string,
|
|
339
324
|
): Array<Diagnostic> {
|
|
340
325
|
let filename = url.fileURLToPath(document);
|
|
341
|
-
let diagnostics
|
|
326
|
+
let diagnostics = [];
|
|
342
327
|
|
|
343
328
|
let asset = bundleGraph.traverse((node, context, actions) => {
|
|
344
329
|
if (node.type === 'asset' && node.value.filePath === filename) {
|
|
@@ -348,8 +333,7 @@ function getDiagnosticsUnusedExports(
|
|
|
348
333
|
});
|
|
349
334
|
|
|
350
335
|
if (asset) {
|
|
351
|
-
|
|
352
|
-
const generateDiagnostic = (loc: SourceLocation, type: string) => ({
|
|
336
|
+
const generateDiagnostic = (loc, type) => ({
|
|
353
337
|
range: {
|
|
354
338
|
start: {
|
|
355
339
|
line: loc.start.line - 1,
|
|
@@ -366,10 +350,8 @@ function getDiagnosticsUnusedExports(
|
|
|
366
350
|
tags: [DiagnosticTag.Unnecessary],
|
|
367
351
|
});
|
|
368
352
|
|
|
369
|
-
// @ts-expect-error TS2345
|
|
370
353
|
let usedSymbols = bundleGraph.getUsedSymbols(asset);
|
|
371
354
|
if (usedSymbols) {
|
|
372
|
-
// @ts-expect-error TS2339
|
|
373
355
|
for (let [exported, symbol] of asset.symbols) {
|
|
374
356
|
if (!usedSymbols.has(exported)) {
|
|
375
357
|
if (symbol.loc) {
|
|
@@ -396,7 +378,6 @@ function getDiagnosticsUnusedExports(
|
|
|
396
378
|
// }
|
|
397
379
|
}
|
|
398
380
|
|
|
399
|
-
// @ts-expect-error TS2339
|
|
400
381
|
for (let dep of asset.getDependencies()) {
|
|
401
382
|
let usedSymbols = bundleGraph.getUsedSymbols(dep);
|
|
402
383
|
if (usedSymbols) {
|
|
@@ -465,7 +446,6 @@ function getImporters(
|
|
|
465
446
|
});
|
|
466
447
|
|
|
467
448
|
if (asset) {
|
|
468
|
-
// @ts-expect-error TS2345
|
|
469
449
|
let incoming = bundleGraph.getIncomingDependencies(asset);
|
|
470
450
|
return incoming
|
|
471
451
|
.filter((dep) => dep.sourcePath != null)
|
package/src/ipc.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import * as net from 'net';
|
|
3
|
+
import type {
|
|
4
|
+
MessageReader,
|
|
5
|
+
MessageWriter,
|
|
6
|
+
MessageConnection,
|
|
7
|
+
} from 'vscode-jsonrpc/node';
|
|
8
|
+
import {
|
|
9
|
+
createMessageConnection,
|
|
10
|
+
SocketMessageReader,
|
|
11
|
+
SocketMessageWriter,
|
|
12
|
+
} from 'vscode-jsonrpc/node';
|
|
13
|
+
|
|
14
|
+
function createClientPipeTransport(
|
|
15
|
+
pipeName: string,
|
|
16
|
+
onConnected: (reader: MessageReader, writer: MessageWriter) => void,
|
|
17
|
+
): Promise<{|close: () => Promise<void>|}> {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
let server: net.Server = net.createServer((socket: net.Socket) => {
|
|
20
|
+
onConnected(
|
|
21
|
+
new SocketMessageReader(socket),
|
|
22
|
+
new SocketMessageWriter(socket),
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
server.on('error', reject);
|
|
26
|
+
server.listen(pipeName, () => {
|
|
27
|
+
server.removeListener('error', reject);
|
|
28
|
+
resolve({
|
|
29
|
+
close() {
|
|
30
|
+
return new Promise((res, rej) => {
|
|
31
|
+
server.close((e) => {
|
|
32
|
+
if (e) rej(e);
|
|
33
|
+
else res();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function createServer(
|
|
43
|
+
filename: string,
|
|
44
|
+
setup: (connection: MessageConnection) => void,
|
|
45
|
+
): Promise<{|close: () => Promise<void>|}> {
|
|
46
|
+
return createClientPipeTransport(
|
|
47
|
+
filename,
|
|
48
|
+
(reader: MessageReader, writer: MessageWriter) => {
|
|
49
|
+
let connection = createMessageConnection(reader, writer);
|
|
50
|
+
connection.listen();
|
|
51
|
+
|
|
52
|
+
setup(connection);
|
|
53
|
+
},
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
// @flow
|
|
1
2
|
import type {DiagnosticLogEvent, FilePath} from '@atlaspack/types';
|
|
2
|
-
// @ts-expect-error TS2724
|
|
3
3
|
import type {ODiagnosticSeverity} from 'vscode-languageserver';
|
|
4
4
|
|
|
5
5
|
import path from 'path';
|
|
@@ -61,31 +61,35 @@ export const DiagnosticTag = {
|
|
|
61
61
|
* Clients are allowed to render diagnostics with this tag faded out instead of having
|
|
62
62
|
* an error squiggle.
|
|
63
63
|
*/
|
|
64
|
-
//
|
|
65
|
-
Unnecessary: 1
|
|
64
|
+
// $FlowFixMe
|
|
65
|
+
Unnecessary: (1: ODiagnosticTag),
|
|
66
66
|
/**
|
|
67
67
|
* Deprecated or obsolete code.
|
|
68
68
|
*
|
|
69
69
|
* Clients are allowed to rendered diagnostics with this tag strike through.
|
|
70
70
|
*/
|
|
71
|
-
//
|
|
72
|
-
Deprecated: 2
|
|
73
|
-
}
|
|
71
|
+
// $FlowFixMe
|
|
72
|
+
Deprecated: (2: ODiagnosticTag),
|
|
73
|
+
};
|
|
74
74
|
export const DiagnosticSeverity = {
|
|
75
75
|
/**
|
|
76
76
|
* Reports an error.
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
// $FlowFixMe
|
|
79
|
+
Error: (1: ODiagnosticSeverity),
|
|
79
80
|
/**
|
|
80
81
|
* Reports a warning.
|
|
81
82
|
*/
|
|
82
|
-
|
|
83
|
+
// $FlowFixMe
|
|
84
|
+
Warning: (2: ODiagnosticSeverity),
|
|
83
85
|
/**
|
|
84
86
|
* Reports an information.
|
|
85
87
|
*/
|
|
86
|
-
|
|
88
|
+
// $FlowFixMe
|
|
89
|
+
Information: (3: ODiagnosticSeverity),
|
|
87
90
|
/**
|
|
88
91
|
* Reports a hint.
|
|
89
92
|
*/
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
// $FlowFixMe
|
|
94
|
+
Hint: (4: ODiagnosticSeverity),
|
|
95
|
+
};
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright (c) 2024 Atlassian US., Inc.
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
package/lib/LspReporter.d.ts
DELETED
package/lib/ipc.d.ts
DELETED
package/lib/utils.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { DiagnosticLogEvent, FilePath } from '@atlaspack/types';
|
|
2
|
-
import type { ODiagnosticSeverity } from 'vscode-languageserver';
|
|
3
|
-
export type ParcelSeverity = DiagnosticLogEvent['level'];
|
|
4
|
-
export declare function parcelSeverityToLspSeverity(parcelSeverity: ParcelSeverity): ODiagnosticSeverity;
|
|
5
|
-
export declare function normalizeFilePath(filePath: FilePath, projectRoot: FilePath): FilePath;
|
|
6
|
-
export declare const DiagnosticTag: {
|
|
7
|
-
/**
|
|
8
|
-
* Unused or unnecessary code.
|
|
9
|
-
*
|
|
10
|
-
* Clients are allowed to render diagnostics with this tag faded out instead of having
|
|
11
|
-
* an error squiggle.
|
|
12
|
-
*/
|
|
13
|
-
readonly Unnecessary: ODiagnosticTag;
|
|
14
|
-
/**
|
|
15
|
-
* Deprecated or obsolete code.
|
|
16
|
-
*
|
|
17
|
-
* Clients are allowed to rendered diagnostics with this tag strike through.
|
|
18
|
-
*/
|
|
19
|
-
readonly Deprecated: ODiagnosticTag;
|
|
20
|
-
};
|
|
21
|
-
export declare const DiagnosticSeverity: {
|
|
22
|
-
/**
|
|
23
|
-
* Reports an error.
|
|
24
|
-
*/
|
|
25
|
-
readonly Error: ODiagnosticSeverity;
|
|
26
|
-
/**
|
|
27
|
-
* Reports a warning.
|
|
28
|
-
*/
|
|
29
|
-
readonly Warning: ODiagnosticSeverity;
|
|
30
|
-
/**
|
|
31
|
-
* Reports an information.
|
|
32
|
-
*/
|
|
33
|
-
readonly Information: ODiagnosticSeverity;
|
|
34
|
-
/**
|
|
35
|
-
* Reports a hint.
|
|
36
|
-
*/
|
|
37
|
-
readonly Hint: ODiagnosticSeverity;
|
|
38
|
-
};
|
package/src/ipc.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as net from 'net';
|
|
2
|
-
import type {
|
|
3
|
-
MessageReader,
|
|
4
|
-
MessageWriter,
|
|
5
|
-
MessageConnection,
|
|
6
|
-
} from 'vscode-jsonrpc/node';
|
|
7
|
-
import {
|
|
8
|
-
createMessageConnection,
|
|
9
|
-
SocketMessageReader,
|
|
10
|
-
SocketMessageWriter,
|
|
11
|
-
} from 'vscode-jsonrpc/node';
|
|
12
|
-
|
|
13
|
-
function createClientPipeTransport(
|
|
14
|
-
pipeName: string,
|
|
15
|
-
onConnected: (reader: MessageReader, writer: MessageWriter) => void,
|
|
16
|
-
): Promise<{
|
|
17
|
-
close: () => Promise<void>;
|
|
18
|
-
}> {
|
|
19
|
-
return new Promise(
|
|
20
|
-
(
|
|
21
|
-
resolve: (
|
|
22
|
-
result:
|
|
23
|
-
| Promise<{
|
|
24
|
-
close(): Promise<void>;
|
|
25
|
-
}>
|
|
26
|
-
| {
|
|
27
|
-
close(): Promise<void>;
|
|
28
|
-
},
|
|
29
|
-
) => void,
|
|
30
|
-
reject: (error?: any) => void,
|
|
31
|
-
) => {
|
|
32
|
-
let server: net.Server = net.createServer((socket: net.Socket) => {
|
|
33
|
-
onConnected(
|
|
34
|
-
new SocketMessageReader(socket),
|
|
35
|
-
new SocketMessageWriter(socket),
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
server.on('error', reject);
|
|
39
|
-
server.listen(pipeName, () => {
|
|
40
|
-
server.removeListener('error', reject);
|
|
41
|
-
resolve({
|
|
42
|
-
close() {
|
|
43
|
-
return new Promise(
|
|
44
|
-
(
|
|
45
|
-
res: (result: Promise<undefined> | undefined) => void,
|
|
46
|
-
rej: (error?: any) => void,
|
|
47
|
-
) => {
|
|
48
|
-
server.close((e) => {
|
|
49
|
-
if (e) rej(e);
|
|
50
|
-
// @ts-expect-error TS2794
|
|
51
|
-
else res();
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function createServer(
|
|
63
|
-
filename: string,
|
|
64
|
-
setup: (connection: MessageConnection) => void,
|
|
65
|
-
): Promise<{
|
|
66
|
-
close: () => Promise<void>;
|
|
67
|
-
}> {
|
|
68
|
-
return createClientPipeTransport(
|
|
69
|
-
filename,
|
|
70
|
-
(reader: MessageReader, writer: MessageWriter) => {
|
|
71
|
-
let connection = createMessageConnection(reader, writer);
|
|
72
|
-
connection.listen();
|
|
73
|
-
|
|
74
|
-
setup(connection);
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
}
|
package/tsconfig.json
DELETED