@parcel/lsp 2.9.0 → 2.9.1

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.
Files changed (2) hide show
  1. package/lib/LspServer.js +72 -72
  2. package/package.json +4 -4
package/lib/LspServer.js CHANGED
@@ -1,13 +1,13 @@
1
- var $jCml6$path = require("path");
2
- var $jCml6$fs = require("fs");
3
- var $jCml6$os = require("os");
4
- var $jCml6$vscodelanguageservernode = require("vscode-languageserver/node");
5
- var $jCml6$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
- var $jCml6$assert = require("assert");
7
- var $jCml6$url = require("url");
8
- var $jCml6$commonpathprefix = require("common-path-prefix");
9
- var $jCml6$parcelwatcher = require("@parcel/watcher");
10
- var $jCml6$parcellspprotocol = require("@parcel/lsp-protocol");
1
+ var $jaVVh$path = require("path");
2
+ var $jaVVh$fs = require("fs");
3
+ var $jaVVh$os = require("os");
4
+ var $jaVVh$vscodelanguageservernode = require("vscode-languageserver/node");
5
+ var $jaVVh$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
+ var $jaVVh$assert = require("assert");
7
+ var $jaVVh$url = require("url");
8
+ var $jaVVh$commonpathprefix = require("common-path-prefix");
9
+ var $jaVVh$parcelwatcher = require("@parcel/watcher");
10
+ var $jaVVh$parcellspprotocol = require("@parcel/lsp-protocol");
11
11
 
12
12
 
13
13
 
@@ -19,29 +19,29 @@ var $jCml6$parcellspprotocol = require("@parcel/lsp-protocol");
19
19
 
20
20
 
21
21
 
22
- const $7a2a8bcac4752bd6$var$connection = (0, $jCml6$vscodelanguageservernode.createConnection)((0, $jCml6$vscodelanguageservernode.ProposedFeatures).all);
22
+ const $0b1d2d458fcf7340$var$connection = (0, $jaVVh$vscodelanguageservernode.createConnection)((0, $jaVVh$vscodelanguageservernode.ProposedFeatures).all);
23
23
  // Create a simple text document manager.
24
24
  // const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
25
- let $7a2a8bcac4752bd6$var$hasConfigurationCapability = false;
26
- let $7a2a8bcac4752bd6$var$hasWorkspaceFolderCapability = false;
25
+ let $0b1d2d458fcf7340$var$hasConfigurationCapability = false;
26
+ let $0b1d2d458fcf7340$var$hasWorkspaceFolderCapability = false;
27
27
  // let hasDiagnosticRelatedInformationCapability = false;
28
- let $7a2a8bcac4752bd6$var$hasDiagnosticsRefreshSupport = false;
29
- $7a2a8bcac4752bd6$var$connection.onInitialize((params)=>{
28
+ let $0b1d2d458fcf7340$var$hasDiagnosticsRefreshSupport = false;
29
+ $0b1d2d458fcf7340$var$connection.onInitialize((params)=>{
30
30
  var _capabilities_workspace, _capabilities_workspace_diagnostics;
31
31
  const capabilities = params.capabilities;
32
32
  // Does the client support the `workspace/configuration` request?
33
33
  // If not, we fall back using global settings.
34
- $7a2a8bcac4752bd6$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
35
- $7a2a8bcac4752bd6$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
34
+ $0b1d2d458fcf7340$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
35
+ $0b1d2d458fcf7340$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
36
36
  // hasDiagnosticRelatedInformationCapability = !!(
37
37
  // capabilities.textDocument &&
38
38
  // capabilities.textDocument.publishDiagnostics &&
39
39
  // capabilities.textDocument.publishDiagnostics.relatedInformation
40
40
  // );
41
- $7a2a8bcac4752bd6$var$hasDiagnosticsRefreshSupport = Boolean((_capabilities_workspace = capabilities.workspace) === null || _capabilities_workspace === void 0 ? void 0 : (_capabilities_workspace_diagnostics = _capabilities_workspace.diagnostics) === null || _capabilities_workspace_diagnostics === void 0 ? void 0 : _capabilities_workspace_diagnostics.refreshSupport);
41
+ $0b1d2d458fcf7340$var$hasDiagnosticsRefreshSupport = Boolean((_capabilities_workspace = capabilities.workspace) === null || _capabilities_workspace === void 0 ? void 0 : (_capabilities_workspace_diagnostics = _capabilities_workspace.diagnostics) === null || _capabilities_workspace_diagnostics === void 0 ? void 0 : _capabilities_workspace_diagnostics.refreshSupport);
42
42
  const result = {
43
43
  capabilities: {
44
- textDocumentSync: (0, $jCml6$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
44
+ textDocumentSync: (0, $jaVVh$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
45
45
  // Tell the client that this server supports code completion.
46
46
  diagnosticProvider: {
47
47
  workspaceDiagnostics: false,
@@ -49,31 +49,31 @@ $7a2a8bcac4752bd6$var$connection.onInitialize((params)=>{
49
49
  }
50
50
  }
51
51
  };
52
- if ($7a2a8bcac4752bd6$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
52
+ if ($0b1d2d458fcf7340$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
53
53
  workspaceFolders: {
54
54
  supported: true
55
55
  }
56
56
  };
57
57
  return result;
58
58
  });
59
- $7a2a8bcac4752bd6$var$connection.onInitialized(()=>{
60
- if ($7a2a8bcac4752bd6$var$hasConfigurationCapability) // Register for all configuration changes.
61
- $7a2a8bcac4752bd6$var$connection.client.register((0, $jCml6$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
62
- if ($7a2a8bcac4752bd6$var$hasWorkspaceFolderCapability) $7a2a8bcac4752bd6$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
63
- $7a2a8bcac4752bd6$var$connection.console.log("Workspace folder change event received.");
59
+ $0b1d2d458fcf7340$var$connection.onInitialized(()=>{
60
+ if ($0b1d2d458fcf7340$var$hasConfigurationCapability) // Register for all configuration changes.
61
+ $0b1d2d458fcf7340$var$connection.client.register((0, $jaVVh$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
62
+ if ($0b1d2d458fcf7340$var$hasWorkspaceFolderCapability) $0b1d2d458fcf7340$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
63
+ $0b1d2d458fcf7340$var$connection.console.log("Workspace folder change event received.");
64
64
  });
65
65
  });
66
66
  // Proxy
67
- $7a2a8bcac4752bd6$var$connection.onRequest((0, $jCml6$parcellspprotocol.RequestImporters), async (params)=>{
68
- let client = $7a2a8bcac4752bd6$var$findClient(params);
67
+ $0b1d2d458fcf7340$var$connection.onRequest((0, $jaVVh$parcellspprotocol.RequestImporters), async (params)=>{
68
+ let client = $0b1d2d458fcf7340$var$findClient(params);
69
69
  if (client) {
70
- let result = await client.connection.sendRequest((0, $jCml6$parcellspprotocol.RequestImporters), params);
70
+ let result = await client.connection.sendRequest((0, $jaVVh$parcellspprotocol.RequestImporters), params);
71
71
  return result;
72
72
  }
73
73
  return null;
74
74
  });
75
- $7a2a8bcac4752bd6$var$connection.onRequest((0, $jCml6$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
76
- let client = $7a2a8bcac4752bd6$var$findClient(params.textDocument.uri);
75
+ $0b1d2d458fcf7340$var$connection.onRequest((0, $jaVVh$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
76
+ let client = $0b1d2d458fcf7340$var$findClient(params.textDocument.uri);
77
77
  let result;
78
78
  if (client) {
79
79
  // console.log(
@@ -82,23 +82,23 @@ $7a2a8bcac4752bd6$var$connection.onRequest((0, $jCml6$vscodelanguageservernode.D
82
82
  // params.previousResultId === client.lastBuild,
83
83
  // );
84
84
  if (params.previousResultId === client.lastBuild) return {
85
- kind: (0, $jCml6$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
85
+ kind: (0, $jaVVh$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
86
86
  resultId: client.lastBuild
87
87
  };
88
- result = await client.connection.sendRequest((0, $jCml6$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
88
+ result = await client.connection.sendRequest((0, $jaVVh$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
89
89
  if (result) client.uris.add(params.textDocument.uri);
90
90
  }
91
91
  return {
92
- kind: (0, $jCml6$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
92
+ kind: (0, $jaVVh$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
93
93
  resultId: client === null || client === void 0 ? void 0 : client.lastBuild,
94
94
  items: result !== null && result !== void 0 ? result : []
95
95
  };
96
96
  });
97
- $7a2a8bcac4752bd6$var$connection.listen();
98
- class $7a2a8bcac4752bd6$var$ProgressReporter {
97
+ $0b1d2d458fcf7340$var$connection.listen();
98
+ class $0b1d2d458fcf7340$var$ProgressReporter {
99
99
  begin() {
100
100
  this.progressReporterPromise = (async ()=>{
101
- let reporter = await $7a2a8bcac4752bd6$var$connection.window.createWorkDoneProgress();
101
+ let reporter = await $0b1d2d458fcf7340$var$connection.window.createWorkDoneProgress();
102
102
  reporter.begin("Parcel");
103
103
  return reporter;
104
104
  })();
@@ -108,7 +108,7 @@ class $7a2a8bcac4752bd6$var$ProgressReporter {
108
108
  }
109
109
  async done() {
110
110
  if (this.progressReporterPromise == null) this.begin();
111
- $jCml6$assert(this.progressReporterPromise != null);
111
+ $jaVVh$assert(this.progressReporterPromise != null);
112
112
  (await this.progressReporterPromise).done();
113
113
  this.progressReporterPromise = null;
114
114
  }
@@ -122,17 +122,17 @@ class $7a2a8bcac4752bd6$var$ProgressReporter {
122
122
  }
123
123
  }
124
124
  }
125
- function $7a2a8bcac4752bd6$var$sendDiagnosticsRefresh() {
126
- if ($7a2a8bcac4752bd6$var$hasDiagnosticsRefreshSupport) $7a2a8bcac4752bd6$var$connection.sendRequest((0, $jCml6$vscodelanguageservernode.DiagnosticRefreshRequest).type);
125
+ function $0b1d2d458fcf7340$var$sendDiagnosticsRefresh() {
126
+ if ($0b1d2d458fcf7340$var$hasDiagnosticsRefreshSupport) $0b1d2d458fcf7340$var$connection.sendRequest((0, $jaVVh$vscodelanguageservernode.DiagnosticRefreshRequest).type);
127
127
  }
128
- let $7a2a8bcac4752bd6$var$progressReporter = new $7a2a8bcac4752bd6$var$ProgressReporter();
129
- let $7a2a8bcac4752bd6$var$clients = new Map();
130
- function $7a2a8bcac4752bd6$var$findClient(document) {
131
- let filepath = $jCml6$url.fileURLToPath(document);
128
+ let $0b1d2d458fcf7340$var$progressReporter = new $0b1d2d458fcf7340$var$ProgressReporter();
129
+ let $0b1d2d458fcf7340$var$clients = new Map();
130
+ function $0b1d2d458fcf7340$var$findClient(document) {
131
+ let filepath = $jaVVh$url.fileURLToPath(document);
132
132
  let longestPrefix = 0;
133
133
  let bestClient;
134
- for (let [, client] of $7a2a8bcac4752bd6$var$clients){
135
- let prefix = $jCml6$commonpathprefix([
134
+ for (let [, client] of $0b1d2d458fcf7340$var$clients){
135
+ let prefix = $jaVVh$commonpathprefix([
136
136
  client.projectRoot,
137
137
  filepath
138
138
  ]).length;
@@ -143,11 +143,11 @@ function $7a2a8bcac4752bd6$var$findClient(document) {
143
143
  }
144
144
  return bestClient;
145
145
  }
146
- function $7a2a8bcac4752bd6$var$createClient(metafilepath) {
147
- let metafile = JSON.parse($jCml6$fs.readFileSync(metafilepath, "utf8"));
146
+ function $0b1d2d458fcf7340$var$createClient(metafilepath) {
147
+ let metafile = JSON.parse($jaVVh$fs.readFileSync(metafilepath, "utf8"));
148
148
  let socketfilepath = metafilepath.slice(0, -5);
149
- let [reader, writer] = (0, $jCml6$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
150
- let client = (0, $jCml6$vscodejsonrpcnode.createMessageConnection)(reader, writer);
149
+ let [reader, writer] = (0, $jaVVh$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
150
+ let client = (0, $jaVVh$vscodejsonrpcnode.createMessageConnection)(reader, writer);
151
151
  client.listen();
152
152
  let uris = new Set();
153
153
  let result = {
@@ -156,66 +156,66 @@ function $7a2a8bcac4752bd6$var$createClient(metafilepath) {
156
156
  projectRoot: metafile.projectRoot,
157
157
  lastBuild: "0"
158
158
  };
159
- client.onNotification((0, $jCml6$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
159
+ client.onNotification((0, $jaVVh$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
160
160
  // console.log('got NotificationBuildStatus', state, message);
161
161
  if (state === "start") {
162
- $7a2a8bcac4752bd6$var$progressReporter.begin();
163
- for (let uri of uris)$7a2a8bcac4752bd6$var$connection.sendDiagnostics({
162
+ $0b1d2d458fcf7340$var$progressReporter.begin();
163
+ for (let uri of uris)$0b1d2d458fcf7340$var$connection.sendDiagnostics({
164
164
  uri: uri,
165
165
  diagnostics: []
166
166
  });
167
- } else if (state === "progress" && message != null) $7a2a8bcac4752bd6$var$progressReporter.report(message);
167
+ } else if (state === "progress" && message != null) $0b1d2d458fcf7340$var$progressReporter.report(message);
168
168
  else if (state === "end") {
169
169
  result.lastBuild = String(Date.now());
170
- $7a2a8bcac4752bd6$var$sendDiagnosticsRefresh();
171
- $7a2a8bcac4752bd6$var$progressReporter.done();
172
- $7a2a8bcac4752bd6$var$connection.sendNotification((0, $jCml6$parcellspprotocol.NotificationBuild));
170
+ $0b1d2d458fcf7340$var$sendDiagnosticsRefresh();
171
+ $0b1d2d458fcf7340$var$progressReporter.done();
172
+ $0b1d2d458fcf7340$var$connection.sendNotification((0, $jaVVh$parcellspprotocol.NotificationBuild));
173
173
  }
174
174
  });
175
- client.onNotification((0, $jCml6$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
175
+ client.onNotification((0, $jaVVh$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
176
176
  // console.log('got NotificationWorkspaceDiagnostics', diagnostics);
177
177
  for (let d of diagnostics){
178
178
  uris.add(d.uri);
179
- $7a2a8bcac4752bd6$var$connection.sendDiagnostics(d);
179
+ $0b1d2d458fcf7340$var$connection.sendDiagnostics(d);
180
180
  }
181
181
  });
182
182
  client.onClose(()=>{
183
- $7a2a8bcac4752bd6$var$clients.delete(metafile);
184
- $7a2a8bcac4752bd6$var$sendDiagnosticsRefresh();
183
+ $0b1d2d458fcf7340$var$clients.delete(metafile);
184
+ $0b1d2d458fcf7340$var$sendDiagnosticsRefresh();
185
185
  return Promise.all([
186
186
  ...uris
187
- ].map((uri)=>$7a2a8bcac4752bd6$var$connection.sendDiagnostics({
187
+ ].map((uri)=>$0b1d2d458fcf7340$var$connection.sendDiagnostics({
188
188
  uri: uri,
189
189
  diagnostics: []
190
190
  })));
191
191
  });
192
- $7a2a8bcac4752bd6$var$sendDiagnosticsRefresh();
193
- $7a2a8bcac4752bd6$var$clients.set(metafile, result);
192
+ $0b1d2d458fcf7340$var$sendDiagnosticsRefresh();
193
+ $0b1d2d458fcf7340$var$clients.set(metafile, result);
194
194
  }
195
195
  // Take realpath because to have consistent cache keys on macOS (/var -> /private/var)
196
- const $7a2a8bcac4752bd6$var$BASEDIR = $jCml6$path.join($jCml6$fs.realpathSync($jCml6$os.tmpdir()), "parcel-lsp");
197
- $jCml6$fs.mkdirSync($7a2a8bcac4752bd6$var$BASEDIR, {
196
+ const $0b1d2d458fcf7340$var$BASEDIR = $jaVVh$path.join($jaVVh$fs.realpathSync($jaVVh$os.tmpdir()), "parcel-lsp");
197
+ $jaVVh$fs.mkdirSync($0b1d2d458fcf7340$var$BASEDIR, {
198
198
  recursive: true
199
199
  });
200
200
  // Search for currently running Parcel processes in the parcel-lsp dir.
201
201
  // Create an IPC client connection for each running process.
202
- for (let filename of $jCml6$fs.readdirSync($7a2a8bcac4752bd6$var$BASEDIR)){
202
+ for (let filename of $jaVVh$fs.readdirSync($0b1d2d458fcf7340$var$BASEDIR)){
203
203
  if (!filename.endsWith(".json")) continue;
204
- let filepath = $jCml6$path.join($7a2a8bcac4752bd6$var$BASEDIR, filename);
205
- $7a2a8bcac4752bd6$var$createClient(filepath);
204
+ let filepath = $jaVVh$path.join($0b1d2d458fcf7340$var$BASEDIR, filename);
205
+ $0b1d2d458fcf7340$var$createClient(filepath);
206
206
  // console.log('connected initial', filepath);
207
207
  }
208
208
  // Watch for new Parcel processes in the parcel-lsp dir, and disconnect the
209
209
  // client for each corresponding connection when a Parcel process ends
210
- $jCml6$parcelwatcher.subscribe($7a2a8bcac4752bd6$var$BASEDIR, async (err, events)=>{
210
+ $jaVVh$parcelwatcher.subscribe($0b1d2d458fcf7340$var$BASEDIR, async (err, events)=>{
211
211
  if (err) throw err;
212
212
  for (let event of events){
213
- if (event.type === "create" && event.path.endsWith(".json")) $7a2a8bcac4752bd6$var$createClient(event.path);
213
+ if (event.type === "create" && event.path.endsWith(".json")) $0b1d2d458fcf7340$var$createClient(event.path);
214
214
  else if (event.type === "delete" && event.path.endsWith(".json")) {
215
- let existing = $7a2a8bcac4752bd6$var$clients.get(event.path);
215
+ let existing = $0b1d2d458fcf7340$var$clients.get(event.path);
216
216
  // console.log('existing', event.path, existing);
217
217
  if (existing) {
218
- $7a2a8bcac4752bd6$var$clients.delete(event.path);
218
+ $0b1d2d458fcf7340$var$clients.delete(event.path);
219
219
  existing.connection.end();
220
220
  // console.log('disconnected watched', event.path);
221
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/lsp",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "engines": {
24
24
  "node": ">= 12.0.0",
25
- "parcel": "^2.9.0"
25
+ "parcel": "^2.9.1"
26
26
  },
27
27
  "dependencies": {
28
- "@parcel/lsp-protocol": "2.9.0",
28
+ "@parcel/lsp-protocol": "2.9.1",
29
29
  "@parcel/watcher": "^2.0.7",
30
30
  "common-path-prefix": "^3.0.0",
31
31
  "nullthrows": "^1.1.1",
@@ -44,5 +44,5 @@
44
44
  "targets": {
45
45
  "types": false
46
46
  },
47
- "gitHead": "dd9435be8afed35c5ffc161cf4b586fd6c78fc1f"
47
+ "gitHead": "5c5dc302b559f0b0d8c57b4d638aac521c879b70"
48
48
  }