@parcel/lsp 2.12.1-dev.3209 → 2.12.1-dev.3229

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 +87 -87
  2. package/package.json +4 -4
package/lib/LspServer.js CHANGED
@@ -1,13 +1,13 @@
1
- var $hJKAc$path = require("path");
2
- var $hJKAc$fs = require("fs");
3
- var $hJKAc$os = require("os");
4
- var $hJKAc$vscodelanguageservernode = require("vscode-languageserver/node");
5
- var $hJKAc$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
- var $hJKAc$assert = require("assert");
7
- var $hJKAc$url = require("url");
8
- var $hJKAc$commonpathprefix = require("common-path-prefix");
9
- var $hJKAc$parcelwatcher = require("@parcel/watcher");
10
- var $hJKAc$parcellspprotocol = require("@parcel/lsp-protocol");
1
+ var $fn0BF$path = require("path");
2
+ var $fn0BF$fs = require("fs");
3
+ var $fn0BF$os = require("os");
4
+ var $fn0BF$vscodelanguageservernode = require("vscode-languageserver/node");
5
+ var $fn0BF$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
+ var $fn0BF$assert = require("assert");
7
+ var $fn0BF$url = require("url");
8
+ var $fn0BF$commonpathprefix = require("common-path-prefix");
9
+ var $fn0BF$parcelwatcher = require("@parcel/watcher");
10
+ var $fn0BF$parcellspprotocol = require("@parcel/lsp-protocol");
11
11
 
12
12
 
13
13
 
@@ -19,30 +19,30 @@ var $hJKAc$parcellspprotocol = require("@parcel/lsp-protocol");
19
19
 
20
20
 
21
21
 
22
- const $4a486f71d356e583$var$connection = (0, $hJKAc$vscodelanguageservernode.createConnection)((0, $hJKAc$vscodelanguageservernode.ProposedFeatures).all);
23
- const $4a486f71d356e583$var$WORKSPACE_ROOT = process.cwd();
24
- const $4a486f71d356e583$var$LSP_SENTINEL_FILENAME = "lsp-server";
22
+ const $ef04e29befc9f442$var$connection = (0, $fn0BF$vscodelanguageservernode.createConnection)((0, $fn0BF$vscodelanguageservernode.ProposedFeatures).all);
23
+ const $ef04e29befc9f442$var$WORKSPACE_ROOT = process.cwd();
24
+ const $ef04e29befc9f442$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 $4a486f71d356e583$var$hasConfigurationCapability = false;
28
- let $4a486f71d356e583$var$hasWorkspaceFolderCapability = false;
27
+ let $ef04e29befc9f442$var$hasConfigurationCapability = false;
28
+ let $ef04e29befc9f442$var$hasWorkspaceFolderCapability = false;
29
29
  // let hasDiagnosticRelatedInformationCapability = false;
30
- let $4a486f71d356e583$var$hasDiagnosticsRefreshSupport = false;
31
- $4a486f71d356e583$var$connection.onInitialize((params)=>{
30
+ let $ef04e29befc9f442$var$hasDiagnosticsRefreshSupport = false;
31
+ $ef04e29befc9f442$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
- $4a486f71d356e583$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
36
- $4a486f71d356e583$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
35
+ $ef04e29befc9f442$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
36
+ $ef04e29befc9f442$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
- $4a486f71d356e583$var$hasDiagnosticsRefreshSupport = Boolean(capabilities.workspace?.diagnostics?.refreshSupport);
42
+ $ef04e29befc9f442$var$hasDiagnosticsRefreshSupport = Boolean(capabilities.workspace?.diagnostics?.refreshSupport);
43
43
  const result = {
44
44
  capabilities: {
45
- textDocumentSync: (0, $hJKAc$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
45
+ textDocumentSync: (0, $fn0BF$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 @@ $4a486f71d356e583$var$connection.onInitialize((params)=>{
50
50
  }
51
51
  }
52
52
  };
53
- if ($4a486f71d356e583$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
53
+ if ($ef04e29befc9f442$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
54
54
  workspaceFolders: {
55
55
  supported: true
56
56
  }
57
57
  };
58
58
  return result;
59
59
  });
60
- $4a486f71d356e583$var$connection.onInitialized(()=>{
61
- if ($4a486f71d356e583$var$hasConfigurationCapability) // Register for all configuration changes.
62
- $4a486f71d356e583$var$connection.client.register((0, $hJKAc$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
63
- if ($4a486f71d356e583$var$hasWorkspaceFolderCapability) $4a486f71d356e583$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
64
- $4a486f71d356e583$var$connection.console.log("Workspace folder change event received.");
60
+ $ef04e29befc9f442$var$connection.onInitialized(()=>{
61
+ if ($ef04e29befc9f442$var$hasConfigurationCapability) // Register for all configuration changes.
62
+ $ef04e29befc9f442$var$connection.client.register((0, $fn0BF$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
63
+ if ($ef04e29befc9f442$var$hasWorkspaceFolderCapability) $ef04e29befc9f442$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
64
+ $ef04e29befc9f442$var$connection.console.log('Workspace folder change event received.');
65
65
  });
66
66
  });
67
67
  // Proxy
68
- $4a486f71d356e583$var$connection.onRequest((0, $hJKAc$parcellspprotocol.RequestImporters), async (params)=>{
69
- let client = $4a486f71d356e583$var$findClient(params);
68
+ $ef04e29befc9f442$var$connection.onRequest((0, $fn0BF$parcellspprotocol.RequestImporters), async (params)=>{
69
+ let client = $ef04e29befc9f442$var$findClient(params);
70
70
  if (client) {
71
- let result = await client.connection.sendRequest((0, $hJKAc$parcellspprotocol.RequestImporters), params);
71
+ let result = await client.connection.sendRequest((0, $fn0BF$parcellspprotocol.RequestImporters), params);
72
72
  return result;
73
73
  }
74
74
  return null;
75
75
  });
76
- $4a486f71d356e583$var$connection.onRequest((0, $hJKAc$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
77
- let client = $4a486f71d356e583$var$findClient(params.textDocument.uri);
76
+ $ef04e29befc9f442$var$connection.onRequest((0, $fn0BF$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
77
+ let client = $ef04e29befc9f442$var$findClient(params.textDocument.uri);
78
78
  let result;
79
79
  if (client) {
80
80
  // console.log(
@@ -83,24 +83,24 @@ $4a486f71d356e583$var$connection.onRequest((0, $hJKAc$vscodelanguageservernode.D
83
83
  // params.previousResultId === client.lastBuild,
84
84
  // );
85
85
  if (params.previousResultId === client.lastBuild) return {
86
- kind: (0, $hJKAc$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
86
+ kind: (0, $fn0BF$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
87
87
  resultId: client.lastBuild
88
88
  };
89
- result = await client.connection.sendRequest((0, $hJKAc$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
89
+ result = await client.connection.sendRequest((0, $fn0BF$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
90
90
  if (result) client.uris.add(params.textDocument.uri);
91
91
  }
92
92
  return {
93
- kind: (0, $hJKAc$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
93
+ kind: (0, $fn0BF$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
94
94
  resultId: client?.lastBuild,
95
95
  items: result ?? []
96
96
  };
97
97
  });
98
- $4a486f71d356e583$var$connection.listen();
99
- class $4a486f71d356e583$var$ProgressReporter {
98
+ $ef04e29befc9f442$var$connection.listen();
99
+ class $ef04e29befc9f442$var$ProgressReporter {
100
100
  begin() {
101
101
  this.progressReporterPromise = (async ()=>{
102
- let reporter = await $4a486f71d356e583$var$connection.window.createWorkDoneProgress();
103
- reporter.begin("Parcel");
102
+ let reporter = await $ef04e29befc9f442$var$connection.window.createWorkDoneProgress();
103
+ reporter.begin('Parcel');
104
104
  return reporter;
105
105
  })();
106
106
  this.progressReporterPromise.then((reporter)=>{
@@ -109,7 +109,7 @@ class $4a486f71d356e583$var$ProgressReporter {
109
109
  }
110
110
  async done() {
111
111
  if (this.progressReporterPromise == null) this.begin();
112
- $hJKAc$assert(this.progressReporterPromise != null);
112
+ $fn0BF$assert(this.progressReporterPromise != null);
113
113
  (await this.progressReporterPromise).done();
114
114
  this.progressReporterPromise = null;
115
115
  }
@@ -123,108 +123,108 @@ class $4a486f71d356e583$var$ProgressReporter {
123
123
  }
124
124
  }
125
125
  }
126
- function $4a486f71d356e583$var$sendDiagnosticsRefresh() {
127
- if ($4a486f71d356e583$var$hasDiagnosticsRefreshSupport) $4a486f71d356e583$var$connection.sendRequest((0, $hJKAc$vscodelanguageservernode.DiagnosticRefreshRequest).type);
126
+ function $ef04e29befc9f442$var$sendDiagnosticsRefresh() {
127
+ if ($ef04e29befc9f442$var$hasDiagnosticsRefreshSupport) $ef04e29befc9f442$var$connection.sendRequest((0, $fn0BF$vscodelanguageservernode.DiagnosticRefreshRequest).type);
128
128
  }
129
- let $4a486f71d356e583$var$progressReporter = new $4a486f71d356e583$var$ProgressReporter();
130
- let $4a486f71d356e583$var$clients = new Map();
131
- function $4a486f71d356e583$var$findClient(document) {
132
- let filepath = $hJKAc$url.fileURLToPath(document);
129
+ let $ef04e29befc9f442$var$progressReporter = new $ef04e29befc9f442$var$ProgressReporter();
130
+ let $ef04e29befc9f442$var$clients = new Map();
131
+ function $ef04e29befc9f442$var$findClient(document) {
132
+ let filepath = $fn0BF$url.fileURLToPath(document);
133
133
  let longestPrefix = 0;
134
134
  let bestClient;
135
- for (let [, client] of $4a486f71d356e583$var$clients){
136
- let prefix = $hJKAc$commonpathprefix([
135
+ for (let [, client] of $ef04e29befc9f442$var$clients){
136
+ let prefix = $fn0BF$commonpathprefix([
137
137
  client.projectRoot,
138
138
  filepath
139
139
  ]).length;
140
140
  if (longestPrefix < prefix) {
141
141
  longestPrefix = prefix;
142
142
  bestClient = client;
143
- } else if (longestPrefix === prefix) console.warn("Ambiguous client for " + filepath);
143
+ } else if (longestPrefix === prefix) console.warn('Ambiguous client for ' + filepath);
144
144
  }
145
145
  return bestClient;
146
146
  }
147
- function $4a486f71d356e583$var$loadMetafile(filepath) {
148
- const file = $hJKAc$fs.readFileSync(filepath, "utf-8");
147
+ function $ef04e29befc9f442$var$loadMetafile(filepath) {
148
+ const file = $fn0BF$fs.readFileSync(filepath, 'utf-8');
149
149
  return JSON.parse(file);
150
150
  }
151
- function $4a486f71d356e583$var$createClient(metafilepath, metafile) {
151
+ function $ef04e29befc9f442$var$createClient(metafilepath, metafile) {
152
152
  let socketfilepath = metafilepath.slice(0, -5);
153
- let [reader, writer] = (0, $hJKAc$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
154
- let client = (0, $hJKAc$vscodejsonrpcnode.createMessageConnection)(reader, writer);
153
+ let [reader, writer] = (0, $fn0BF$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
154
+ let client = (0, $fn0BF$vscodejsonrpcnode.createMessageConnection)(reader, writer);
155
155
  client.listen();
156
156
  let uris = new Set();
157
157
  let result = {
158
158
  connection: client,
159
159
  uris: uris,
160
160
  projectRoot: metafile.projectRoot,
161
- lastBuild: "0"
161
+ lastBuild: '0'
162
162
  };
163
- client.onNotification((0, $hJKAc$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
163
+ client.onNotification((0, $fn0BF$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
164
164
  // console.log('got NotificationBuildStatus', state, message);
165
- if (state === "start") {
166
- $4a486f71d356e583$var$progressReporter.begin();
167
- for (let uri of uris)$4a486f71d356e583$var$connection.sendDiagnostics({
165
+ if (state === 'start') {
166
+ $ef04e29befc9f442$var$progressReporter.begin();
167
+ for (let uri of uris)$ef04e29befc9f442$var$connection.sendDiagnostics({
168
168
  uri: uri,
169
169
  diagnostics: []
170
170
  });
171
- } else if (state === "progress" && message != null) $4a486f71d356e583$var$progressReporter.report(message);
172
- else if (state === "end") {
171
+ } else if (state === 'progress' && message != null) $ef04e29befc9f442$var$progressReporter.report(message);
172
+ else if (state === 'end') {
173
173
  result.lastBuild = String(Date.now());
174
- $4a486f71d356e583$var$sendDiagnosticsRefresh();
175
- $4a486f71d356e583$var$progressReporter.done();
176
- $4a486f71d356e583$var$connection.sendNotification((0, $hJKAc$parcellspprotocol.NotificationBuild));
174
+ $ef04e29befc9f442$var$sendDiagnosticsRefresh();
175
+ $ef04e29befc9f442$var$progressReporter.done();
176
+ $ef04e29befc9f442$var$connection.sendNotification((0, $fn0BF$parcellspprotocol.NotificationBuild));
177
177
  }
178
178
  });
179
- client.onNotification((0, $hJKAc$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
179
+ client.onNotification((0, $fn0BF$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
180
180
  // console.log('got NotificationWorkspaceDiagnostics', diagnostics);
181
181
  for (let d of diagnostics){
182
182
  uris.add(d.uri);
183
- $4a486f71d356e583$var$connection.sendDiagnostics(d);
183
+ $ef04e29befc9f442$var$connection.sendDiagnostics(d);
184
184
  }
185
185
  });
186
186
  client.onClose(()=>{
187
- $4a486f71d356e583$var$clients.delete(JSON.stringify(metafile));
188
- $4a486f71d356e583$var$sendDiagnosticsRefresh();
187
+ $ef04e29befc9f442$var$clients.delete(JSON.stringify(metafile));
188
+ $ef04e29befc9f442$var$sendDiagnosticsRefresh();
189
189
  return Promise.all([
190
190
  ...uris
191
- ].map((uri)=>$4a486f71d356e583$var$connection.sendDiagnostics({
191
+ ].map((uri)=>$ef04e29befc9f442$var$connection.sendDiagnostics({
192
192
  uri: uri,
193
193
  diagnostics: []
194
194
  })));
195
195
  });
196
- $4a486f71d356e583$var$sendDiagnosticsRefresh();
197
- $4a486f71d356e583$var$clients.set(JSON.stringify(metafile), result);
196
+ $ef04e29befc9f442$var$sendDiagnosticsRefresh();
197
+ $ef04e29befc9f442$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 $4a486f71d356e583$var$BASEDIR = $hJKAc$path.join($hJKAc$fs.realpathSync($hJKAc$os.tmpdir()), "parcel-lsp");
201
- $hJKAc$fs.mkdirSync($4a486f71d356e583$var$BASEDIR, {
200
+ const $ef04e29befc9f442$var$BASEDIR = $fn0BF$path.join($fn0BF$fs.realpathSync($fn0BF$os.tmpdir()), 'parcel-lsp');
201
+ $fn0BF$fs.mkdirSync($ef04e29befc9f442$var$BASEDIR, {
202
202
  recursive: true
203
203
  });
204
- $hJKAc$fs.writeFileSync($hJKAc$path.join($4a486f71d356e583$var$BASEDIR, $4a486f71d356e583$var$LSP_SENTINEL_FILENAME), "");
204
+ $fn0BF$fs.writeFileSync($fn0BF$path.join($ef04e29befc9f442$var$BASEDIR, $ef04e29befc9f442$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 $hJKAc$fs.readdirSync($4a486f71d356e583$var$BASEDIR)){
208
- if (!filename.endsWith(".json")) continue;
209
- let filepath = $hJKAc$path.join($4a486f71d356e583$var$BASEDIR, filename);
210
- const contents = $4a486f71d356e583$var$loadMetafile(filepath);
207
+ for (let filename of $fn0BF$fs.readdirSync($ef04e29befc9f442$var$BASEDIR)){
208
+ if (!filename.endsWith('.json')) continue;
209
+ let filepath = $fn0BF$path.join($ef04e29befc9f442$var$BASEDIR, filename);
210
+ const contents = $ef04e29befc9f442$var$loadMetafile(filepath);
211
211
  const { projectRoot: projectRoot } = contents;
212
- if ($4a486f71d356e583$var$WORKSPACE_ROOT === projectRoot) $4a486f71d356e583$var$createClient(filepath, contents);
212
+ if ($ef04e29befc9f442$var$WORKSPACE_ROOT === projectRoot) $ef04e29befc9f442$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
- $hJKAc$parcelwatcher.subscribe($4a486f71d356e583$var$BASEDIR, async (err, events)=>{
216
+ $fn0BF$parcelwatcher.subscribe($ef04e29befc9f442$var$BASEDIR, async (err, events)=>{
217
217
  if (err) throw err;
218
218
  for (let event of events){
219
- if (event.type === "create" && event.path.endsWith(".json")) {
220
- const contents = $4a486f71d356e583$var$loadMetafile(event.path);
219
+ if (event.type === 'create' && event.path.endsWith('.json')) {
220
+ const contents = $ef04e29befc9f442$var$loadMetafile(event.path);
221
221
  const { projectRoot: projectRoot } = contents;
222
- if ($4a486f71d356e583$var$WORKSPACE_ROOT === projectRoot) $4a486f71d356e583$var$createClient(event.path, contents);
223
- } else if (event.type === "delete" && event.path.endsWith(".json")) {
224
- let existing = $4a486f71d356e583$var$clients.get(event.path);
225
- console.log("existing", event.path, existing);
222
+ if ($ef04e29befc9f442$var$WORKSPACE_ROOT === projectRoot) $ef04e29befc9f442$var$createClient(event.path, contents);
223
+ } else if (event.type === 'delete' && event.path.endsWith('.json')) {
224
+ let existing = $ef04e29befc9f442$var$clients.get(event.path);
225
+ console.log('existing', event.path, existing);
226
226
  if (existing) {
227
- $4a486f71d356e583$var$clients.delete(event.path);
227
+ $ef04e29befc9f442$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.3209+ee048fa0b",
3
+ "version": "2.12.1-dev.3229+795716bf4",
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.1584+ee048fa0b"
25
+ "parcel": "^2.0.0-dev.1601+795716bf4"
26
26
  },
27
27
  "dependencies": {
28
- "@parcel/lsp-protocol": "2.12.1-dev.3209+ee048fa0b",
28
+ "@parcel/lsp-protocol": "2.12.1-dev.3229+795716bf4",
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": "ee048fa0b95364a320c040d012673766869f4c87"
47
+ "gitHead": "795716bf4650f012262eade20f8dc1cfd1f02580"
48
48
  }