@parcel/lsp 2.12.1-nightly.3137 → 2.12.1-nightly.3141

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