@parcel/lsp 2.12.1-dev.3198 → 2.12.1-dev.3200

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