@parcel/lsp 2.9.4-nightly.3003 → 2.9.4-nightly.3008

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/lib/LspServer.js CHANGED
@@ -1,13 +1,13 @@
1
- var $7uaT0$path = require("path");
2
- var $7uaT0$fs = require("fs");
3
- var $7uaT0$os = require("os");
4
- var $7uaT0$vscodelanguageservernode = require("vscode-languageserver/node");
5
- var $7uaT0$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
- var $7uaT0$assert = require("assert");
7
- var $7uaT0$url = require("url");
8
- var $7uaT0$commonpathprefix = require("common-path-prefix");
9
- var $7uaT0$parcelwatcher = require("@parcel/watcher");
10
- var $7uaT0$parcellspprotocol = require("@parcel/lsp-protocol");
1
+ var $eMcyD$path = require("path");
2
+ var $eMcyD$fs = require("fs");
3
+ var $eMcyD$os = require("os");
4
+ var $eMcyD$vscodelanguageservernode = require("vscode-languageserver/node");
5
+ var $eMcyD$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
+ var $eMcyD$assert = require("assert");
7
+ var $eMcyD$url = require("url");
8
+ var $eMcyD$commonpathprefix = require("common-path-prefix");
9
+ var $eMcyD$parcelwatcher = require("@parcel/watcher");
10
+ var $eMcyD$parcellspprotocol = require("@parcel/lsp-protocol");
11
11
 
12
12
 
13
13
 
@@ -19,29 +19,29 @@ var $7uaT0$parcellspprotocol = require("@parcel/lsp-protocol");
19
19
 
20
20
 
21
21
 
22
- const $6897e3d3c327789d$var$connection = (0, $7uaT0$vscodelanguageservernode.createConnection)((0, $7uaT0$vscodelanguageservernode.ProposedFeatures).all);
22
+ const $5a69790e53b882fa$var$connection = (0, $eMcyD$vscodelanguageservernode.createConnection)((0, $eMcyD$vscodelanguageservernode.ProposedFeatures).all);
23
23
  // Create a simple text document manager.
24
24
  // const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
25
- let $6897e3d3c327789d$var$hasConfigurationCapability = false;
26
- let $6897e3d3c327789d$var$hasWorkspaceFolderCapability = false;
25
+ let $5a69790e53b882fa$var$hasConfigurationCapability = false;
26
+ let $5a69790e53b882fa$var$hasWorkspaceFolderCapability = false;
27
27
  // let hasDiagnosticRelatedInformationCapability = false;
28
- let $6897e3d3c327789d$var$hasDiagnosticsRefreshSupport = false;
29
- $6897e3d3c327789d$var$connection.onInitialize((params)=>{
28
+ let $5a69790e53b882fa$var$hasDiagnosticsRefreshSupport = false;
29
+ $5a69790e53b882fa$var$connection.onInitialize((params)=>{
30
30
  var _capabilities_workspace_diagnostics, _capabilities_workspace;
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
- $6897e3d3c327789d$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
35
- $6897e3d3c327789d$var$hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
34
+ $5a69790e53b882fa$var$hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
35
+ $5a69790e53b882fa$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
- $6897e3d3c327789d$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
+ $5a69790e53b882fa$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, $7uaT0$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
44
+ textDocumentSync: (0, $eMcyD$vscodelanguageservernode.TextDocumentSyncKind).Incremental,
45
45
  // Tell the client that this server supports code completion.
46
46
  diagnosticProvider: {
47
47
  workspaceDiagnostics: false,
@@ -49,32 +49,31 @@ $6897e3d3c327789d$var$connection.onInitialize((params)=>{
49
49
  }
50
50
  }
51
51
  };
52
- if ($6897e3d3c327789d$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
52
+ if ($5a69790e53b882fa$var$hasWorkspaceFolderCapability) result.capabilities.workspace = {
53
53
  workspaceFolders: {
54
54
  supported: true
55
55
  }
56
56
  };
57
57
  return result;
58
58
  });
59
- $6897e3d3c327789d$var$connection.onInitialized(()=>{
60
- if ($6897e3d3c327789d$var$hasConfigurationCapability) // Register for all configuration changes.
61
- $6897e3d3c327789d$var$connection.client.register((0, $7uaT0$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
62
- if ($6897e3d3c327789d$var$hasWorkspaceFolderCapability) $6897e3d3c327789d$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
63
- $6897e3d3c327789d$var$connection.console.log("Workspace folder change event received.");
59
+ $5a69790e53b882fa$var$connection.onInitialized(()=>{
60
+ if ($5a69790e53b882fa$var$hasConfigurationCapability) // Register for all configuration changes.
61
+ $5a69790e53b882fa$var$connection.client.register((0, $eMcyD$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
62
+ if ($5a69790e53b882fa$var$hasWorkspaceFolderCapability) $5a69790e53b882fa$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
63
+ $5a69790e53b882fa$var$connection.console.log("Workspace folder change event received.");
64
64
  });
65
65
  });
66
66
  // Proxy
67
- $6897e3d3c327789d$var$connection.onRequest((0, $7uaT0$parcellspprotocol.RequestImporters), async (params)=>{
68
- let client = $6897e3d3c327789d$var$findClient(params);
67
+ $5a69790e53b882fa$var$connection.onRequest((0, $eMcyD$parcellspprotocol.RequestImporters), async (params)=>{
68
+ let client = $5a69790e53b882fa$var$findClient(params);
69
69
  if (client) {
70
- let result = await client.connection.sendRequest((0, $7uaT0$parcellspprotocol.RequestImporters), params);
70
+ let result = await client.connection.sendRequest((0, $eMcyD$parcellspprotocol.RequestImporters), params);
71
71
  return result;
72
72
  }
73
73
  return null;
74
74
  });
75
- $6897e3d3c327789d$var$connection.onRequest((0, $7uaT0$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
76
- var _client;
77
- let client = $6897e3d3c327789d$var$findClient(params.textDocument.uri);
75
+ $5a69790e53b882fa$var$connection.onRequest((0, $eMcyD$vscodelanguageservernode.DocumentDiagnosticRequest).type, async (params)=>{
76
+ let client = $5a69790e53b882fa$var$findClient(params.textDocument.uri);
78
77
  let result;
79
78
  if (client) {
80
79
  // console.log(
@@ -83,23 +82,23 @@ $6897e3d3c327789d$var$connection.onRequest((0, $7uaT0$vscodelanguageservernode.D
83
82
  // params.previousResultId === client.lastBuild,
84
83
  // );
85
84
  if (params.previousResultId === client.lastBuild) return {
86
- kind: (0, $7uaT0$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
85
+ kind: (0, $eMcyD$vscodelanguageservernode.DocumentDiagnosticReportKind).Unchanged,
87
86
  resultId: client.lastBuild
88
87
  };
89
- result = await client.connection.sendRequest((0, $7uaT0$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
88
+ result = await client.connection.sendRequest((0, $eMcyD$parcellspprotocol.RequestDocumentDiagnostics), params.textDocument.uri);
90
89
  if (result) client.uris.add(params.textDocument.uri);
91
90
  }
92
91
  return {
93
- kind: (0, $7uaT0$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
94
- resultId: (_client = client) === null || _client === void 0 ? void 0 : _client.lastBuild,
92
+ kind: (0, $eMcyD$vscodelanguageservernode.DocumentDiagnosticReportKind).Full,
93
+ resultId: client === null || client === void 0 ? void 0 : client.lastBuild,
95
94
  items: result !== null && result !== void 0 ? result : []
96
95
  };
97
96
  });
98
- $6897e3d3c327789d$var$connection.listen();
99
- class $6897e3d3c327789d$var$ProgressReporter {
97
+ $5a69790e53b882fa$var$connection.listen();
98
+ class $5a69790e53b882fa$var$ProgressReporter {
100
99
  begin() {
101
100
  this.progressReporterPromise = (async ()=>{
102
- let reporter = await $6897e3d3c327789d$var$connection.window.createWorkDoneProgress();
101
+ let reporter = await $5a69790e53b882fa$var$connection.window.createWorkDoneProgress();
103
102
  reporter.begin("Parcel");
104
103
  return reporter;
105
104
  })();
@@ -109,7 +108,7 @@ class $6897e3d3c327789d$var$ProgressReporter {
109
108
  }
110
109
  async done() {
111
110
  if (this.progressReporterPromise == null) this.begin();
112
- $7uaT0$assert(this.progressReporterPromise != null);
111
+ $eMcyD$assert(this.progressReporterPromise != null);
113
112
  (await this.progressReporterPromise).done();
114
113
  this.progressReporterPromise = null;
115
114
  }
@@ -123,17 +122,17 @@ class $6897e3d3c327789d$var$ProgressReporter {
123
122
  }
124
123
  }
125
124
  }
126
- function $6897e3d3c327789d$var$sendDiagnosticsRefresh() {
127
- if ($6897e3d3c327789d$var$hasDiagnosticsRefreshSupport) $6897e3d3c327789d$var$connection.sendRequest((0, $7uaT0$vscodelanguageservernode.DiagnosticRefreshRequest).type);
125
+ function $5a69790e53b882fa$var$sendDiagnosticsRefresh() {
126
+ if ($5a69790e53b882fa$var$hasDiagnosticsRefreshSupport) $5a69790e53b882fa$var$connection.sendRequest((0, $eMcyD$vscodelanguageservernode.DiagnosticRefreshRequest).type);
128
127
  }
129
- let $6897e3d3c327789d$var$progressReporter = new $6897e3d3c327789d$var$ProgressReporter();
130
- let $6897e3d3c327789d$var$clients = new Map();
131
- function $6897e3d3c327789d$var$findClient(document) {
132
- let filepath = $7uaT0$url.fileURLToPath(document);
128
+ let $5a69790e53b882fa$var$progressReporter = new $5a69790e53b882fa$var$ProgressReporter();
129
+ let $5a69790e53b882fa$var$clients = new Map();
130
+ function $5a69790e53b882fa$var$findClient(document) {
131
+ let filepath = $eMcyD$url.fileURLToPath(document);
133
132
  let longestPrefix = 0;
134
133
  let bestClient;
135
- for (let [, client] of $6897e3d3c327789d$var$clients){
136
- let prefix = $7uaT0$commonpathprefix([
134
+ for (let [, client] of $5a69790e53b882fa$var$clients){
135
+ let prefix = $eMcyD$commonpathprefix([
137
136
  client.projectRoot,
138
137
  filepath
139
138
  ]).length;
@@ -144,11 +143,11 @@ function $6897e3d3c327789d$var$findClient(document) {
144
143
  }
145
144
  return bestClient;
146
145
  }
147
- function $6897e3d3c327789d$var$createClient(metafilepath) {
148
- let metafile = JSON.parse($7uaT0$fs.readFileSync(metafilepath, "utf8"));
146
+ function $5a69790e53b882fa$var$createClient(metafilepath) {
147
+ let metafile = JSON.parse($eMcyD$fs.readFileSync(metafilepath, "utf8"));
149
148
  let socketfilepath = metafilepath.slice(0, -5);
150
- let [reader, writer] = (0, $7uaT0$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
151
- let client = (0, $7uaT0$vscodejsonrpcnode.createMessageConnection)(reader, writer);
149
+ let [reader, writer] = (0, $eMcyD$vscodejsonrpcnode.createServerPipeTransport)(socketfilepath);
150
+ let client = (0, $eMcyD$vscodejsonrpcnode.createMessageConnection)(reader, writer);
152
151
  client.listen();
153
152
  let uris = new Set();
154
153
  let result = {
@@ -157,66 +156,66 @@ function $6897e3d3c327789d$var$createClient(metafilepath) {
157
156
  projectRoot: metafile.projectRoot,
158
157
  lastBuild: "0"
159
158
  };
160
- client.onNotification((0, $7uaT0$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
159
+ client.onNotification((0, $eMcyD$parcellspprotocol.NotificationBuildStatus), (state, message)=>{
161
160
  // console.log('got NotificationBuildStatus', state, message);
162
161
  if (state === "start") {
163
- $6897e3d3c327789d$var$progressReporter.begin();
164
- for (let uri of uris)$6897e3d3c327789d$var$connection.sendDiagnostics({
162
+ $5a69790e53b882fa$var$progressReporter.begin();
163
+ for (let uri of uris)$5a69790e53b882fa$var$connection.sendDiagnostics({
165
164
  uri: uri,
166
165
  diagnostics: []
167
166
  });
168
- } else if (state === "progress" && message != null) $6897e3d3c327789d$var$progressReporter.report(message);
167
+ } else if (state === "progress" && message != null) $5a69790e53b882fa$var$progressReporter.report(message);
169
168
  else if (state === "end") {
170
169
  result.lastBuild = String(Date.now());
171
- $6897e3d3c327789d$var$sendDiagnosticsRefresh();
172
- $6897e3d3c327789d$var$progressReporter.done();
173
- $6897e3d3c327789d$var$connection.sendNotification((0, $7uaT0$parcellspprotocol.NotificationBuild));
170
+ $5a69790e53b882fa$var$sendDiagnosticsRefresh();
171
+ $5a69790e53b882fa$var$progressReporter.done();
172
+ $5a69790e53b882fa$var$connection.sendNotification((0, $eMcyD$parcellspprotocol.NotificationBuild));
174
173
  }
175
174
  });
176
- client.onNotification((0, $7uaT0$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
175
+ client.onNotification((0, $eMcyD$parcellspprotocol.NotificationWorkspaceDiagnostics), (diagnostics)=>{
177
176
  // console.log('got NotificationWorkspaceDiagnostics', diagnostics);
178
177
  for (let d of diagnostics){
179
178
  uris.add(d.uri);
180
- $6897e3d3c327789d$var$connection.sendDiagnostics(d);
179
+ $5a69790e53b882fa$var$connection.sendDiagnostics(d);
181
180
  }
182
181
  });
183
182
  client.onClose(()=>{
184
- $6897e3d3c327789d$var$clients.delete(metafile);
185
- $6897e3d3c327789d$var$sendDiagnosticsRefresh();
183
+ $5a69790e53b882fa$var$clients.delete(metafile);
184
+ $5a69790e53b882fa$var$sendDiagnosticsRefresh();
186
185
  return Promise.all([
187
186
  ...uris
188
- ].map((uri)=>$6897e3d3c327789d$var$connection.sendDiagnostics({
187
+ ].map((uri)=>$5a69790e53b882fa$var$connection.sendDiagnostics({
189
188
  uri: uri,
190
189
  diagnostics: []
191
190
  })));
192
191
  });
193
- $6897e3d3c327789d$var$sendDiagnosticsRefresh();
194
- $6897e3d3c327789d$var$clients.set(metafile, result);
192
+ $5a69790e53b882fa$var$sendDiagnosticsRefresh();
193
+ $5a69790e53b882fa$var$clients.set(metafile, result);
195
194
  }
196
195
  // Take realpath because to have consistent cache keys on macOS (/var -> /private/var)
197
- const $6897e3d3c327789d$var$BASEDIR = $7uaT0$path.join($7uaT0$fs.realpathSync($7uaT0$os.tmpdir()), "parcel-lsp");
198
- $7uaT0$fs.mkdirSync($6897e3d3c327789d$var$BASEDIR, {
196
+ const $5a69790e53b882fa$var$BASEDIR = $eMcyD$path.join($eMcyD$fs.realpathSync($eMcyD$os.tmpdir()), "parcel-lsp");
197
+ $eMcyD$fs.mkdirSync($5a69790e53b882fa$var$BASEDIR, {
199
198
  recursive: true
200
199
  });
201
200
  // Search for currently running Parcel processes in the parcel-lsp dir.
202
201
  // Create an IPC client connection for each running process.
203
- for (let filename of $7uaT0$fs.readdirSync($6897e3d3c327789d$var$BASEDIR)){
202
+ for (let filename of $eMcyD$fs.readdirSync($5a69790e53b882fa$var$BASEDIR)){
204
203
  if (!filename.endsWith(".json")) continue;
205
- let filepath = $7uaT0$path.join($6897e3d3c327789d$var$BASEDIR, filename);
206
- $6897e3d3c327789d$var$createClient(filepath);
204
+ let filepath = $eMcyD$path.join($5a69790e53b882fa$var$BASEDIR, filename);
205
+ $5a69790e53b882fa$var$createClient(filepath);
207
206
  // console.log('connected initial', filepath);
208
207
  }
209
208
  // Watch for new Parcel processes in the parcel-lsp dir, and disconnect the
210
209
  // client for each corresponding connection when a Parcel process ends
211
- $7uaT0$parcelwatcher.subscribe($6897e3d3c327789d$var$BASEDIR, async (err, events)=>{
210
+ $eMcyD$parcelwatcher.subscribe($5a69790e53b882fa$var$BASEDIR, async (err, events)=>{
212
211
  if (err) throw err;
213
212
  for (let event of events){
214
- if (event.type === "create" && event.path.endsWith(".json")) $6897e3d3c327789d$var$createClient(event.path);
213
+ if (event.type === "create" && event.path.endsWith(".json")) $5a69790e53b882fa$var$createClient(event.path);
215
214
  else if (event.type === "delete" && event.path.endsWith(".json")) {
216
- let existing = $6897e3d3c327789d$var$clients.get(event.path);
215
+ let existing = $5a69790e53b882fa$var$clients.get(event.path);
217
216
  // console.log('existing', event.path, existing);
218
217
  if (existing) {
219
- $6897e3d3c327789d$var$clients.delete(event.path);
218
+ $5a69790e53b882fa$var$clients.delete(event.path);
220
219
  existing.connection.end();
221
220
  // console.log('disconnected watched', event.path);
222
221
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM4B,mCAAazB,CAAAA,GAAAA,gDAAAA,EAAiBU,CAAAA,GAAAA,gDAAAA,EAAiBgB,GAAG;AAExD,yCAAA;AACA,kFAAA;AAEA,IAAIC,mDAA6B;AACjC,IAAIC,qDAA+B;AACnC,yDAAA;AACA,IAAIC,qDAA+B;AAEnCJ,iCAAWK,YAAY,CAAC,CAACC;QAiBrBC,qCAAAA;IAhBF,MAAMA,eAAeD,OAAOC,YAAY;IAExC,iEAAA;IACA,8CAAA;IACAL,mDAA6B,CAAC,CAC5BK,CAAAA,aAAaC,SAAS,IAAI,CAAC,CAACD,aAAaC,SAAS,CAACC,aAAa,AAAbA;IAErDN,qDAA+B,CAAC,CAC9BI,CAAAA,aAAaC,SAAS,IAAI,CAAC,CAACD,aAAaC,SAAS,CAACE,gBAAgB,AAAhBA;IAErD,kDAAA;IACA,iCAAA;IACA,oDAAA;IACA,oEAAA;IACA,KAAA;IACAN,qDAA+BO,SAC7BJ,0BAAAA,aAAaC,SAAS,cAAtBD,+CAAAA,sCAAAA,wBAAwBK,WAAW,cAAnCL,0DAAAA,oCAAqCM,cACvC;IAEA,MAAMC,SAA2B;QAC/BP,cAAc;YACZQ,kBAAkB7B,CAAAA,GAAAA,oDAAAA,EAAqB8B,WAAW;YAClD,6DAAA;YACAC,oBAAoB;gBAClBC,sBAAsB;gBACtBC,uBAAuB;YACzB;QACF;IACF;IAEA,IAAIhB,oDACFW,OAAOP,YAAY,CAACC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p/src/LspServer.ts"],"sourcesContent":["import * as path from 'path';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport {\n createConnection,\n DiagnosticRefreshRequest,\n DidChangeConfigurationNotification,\n DocumentDiagnosticParams,\n DocumentDiagnosticReport,\n DocumentDiagnosticReportKind,\n DocumentDiagnosticRequest,\n DocumentUri,\n InitializeParams,\n InitializeResult,\n ProposedFeatures,\n TextDocumentSyncKind,\n WorkDoneProgressServerReporter,\n} from 'vscode-languageserver/node';\n\nimport {\n createServerPipeTransport,\n createMessageConnection,\n MessageConnection,\n} from 'vscode-jsonrpc/node';\nimport * as invariant from 'assert';\nimport * as url from 'url';\nimport commonPathPrefix = require('common-path-prefix');\n\n// import {TextDocument} from 'vscode-languageserver-textdocument';\nimport * as watcher from '@parcel/watcher';\nimport {\n NotificationBuild,\n NotificationBuildStatus,\n NotificationWorkspaceDiagnostics,\n RequestDocumentDiagnostics,\n RequestImporters,\n} from '@parcel/lsp-protocol';\n\nconst connection = createConnection(ProposedFeatures.all);\n\n// Create a simple text document manager.\n// const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);\n\nlet hasConfigurationCapability = false;\nlet hasWorkspaceFolderCapability = false;\n// let hasDiagnosticRelatedInformationCapability = false;\nlet hasDiagnosticsRefreshSupport = false;\n\nconnection.onInitialize((params: InitializeParams) => {\n const capabilities = params.capabilities;\n\n // Does the client support the `workspace/configuration` request?\n // If not, we fall back using global settings.\n hasConfigurationCapability = !!(\n capabilities.workspace && !!capabilities.workspace.configuration\n );\n hasWorkspaceFolderCapability = !!(\n capabilities.workspace && !!capabilities.workspace.workspaceFolders\n );\n // hasDiagnosticRelatedInformationCapability = !!(\n // capabilities.textDocument &&\n // capabilities.textDocument.publishDiagnostics &&\n // capabilities.textDocument.publishDiagnostics.relatedInformation\n // );\n hasDiagnosticsRefreshSupport = Boolean(\n capabilities.workspace?.diagnostics?.refreshSupport,\n );\n\n const result: InitializeResult = {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n // Tell the client that this server supports code completion.\n diagnosticProvider: {\n workspaceDiagnostics: false,\n interFileDependencies: true,\n },\n },\n };\n\n if (hasWorkspaceFolderCapability) {\n result.capabilities.workspace = {\n workspaceFolders: {\n supported: true,\n },\n };\n }\n return result;\n});\n\nconnection.onInitialized(() => {\n if (hasConfigurationCapability) {\n // Register for all configuration changes.\n connection.client.register(\n DidChangeConfigurationNotification.type,\n undefined,\n );\n }\n if (hasWorkspaceFolderCapability) {\n connection.workspace.onDidChangeWorkspaceFolders(_event => {\n connection.console.log('Workspace folder change event received.');\n });\n }\n});\n\n// Proxy\nconnection.onRequest(RequestImporters, async params => {\n let client = findClient(params);\n if (client) {\n let result = await client.connection.sendRequest(RequestImporters, params);\n return result;\n }\n return null;\n});\n\nconnection.onRequest(\n DocumentDiagnosticRequest.type,\n async (\n params: DocumentDiagnosticParams,\n ): Promise<DocumentDiagnosticReport> => {\n let client = findClient(params.textDocument.uri);\n let result;\n if (client) {\n // console.log(\n // 'DocumentDiagnosticRequest',\n // params.textDocument.uri,\n // params.previousResultId === client.lastBuild,\n // );\n\n if (params.previousResultId === client.lastBuild) {\n return {\n kind: DocumentDiagnosticReportKind.Unchanged,\n resultId: client.lastBuild,\n };\n }\n\n result = await client.connection.sendRequest(\n RequestDocumentDiagnostics,\n params.textDocument.uri,\n );\n\n if (result) {\n client.uris.add(params.textDocument.uri);\n }\n }\n\n return {\n kind: DocumentDiagnosticReportKind.Full,\n resultId: client?.lastBuild,\n items: result ?? [],\n };\n },\n);\n\nconnection.listen();\n\nclass ProgressReporter {\n progressReporterPromise?: Promise<WorkDoneProgressServerReporter> | null;\n lastMessage?: string;\n begin() {\n this.progressReporterPromise = (async () => {\n let reporter = await connection.window.createWorkDoneProgress();\n reporter.begin('Parcel');\n return reporter;\n })();\n this.progressReporterPromise.then(reporter => {\n if (this.lastMessage != null) {\n reporter.report(this.lastMessage);\n }\n });\n }\n async done() {\n if (this.progressReporterPromise == null) {\n this.begin();\n }\n invariant(this.progressReporterPromise != null);\n (await this.progressReporterPromise).done();\n this.progressReporterPromise = null;\n }\n async report(message: string) {\n if (this.progressReporterPromise == null) {\n this.lastMessage = message;\n this.begin();\n } else {\n let r = await this.progressReporterPromise;\n r.report(message);\n }\n }\n}\n\nfunction sendDiagnosticsRefresh() {\n if (hasDiagnosticsRefreshSupport) {\n connection.sendRequest(DiagnosticRefreshRequest.type);\n }\n}\n\ntype Client = {\n connection: MessageConnection;\n projectRoot: string;\n uris: Set<DocumentUri>;\n lastBuild: string;\n};\n\nlet progressReporter = new ProgressReporter();\nlet clients: Map<string, Client> = new Map();\n\nfunction findClient(document: DocumentUri): Client | undefined {\n let filepath = url.fileURLToPath(document);\n\n let longestPrefix = 0;\n let bestClient;\n for (let [, client] of clients) {\n let prefix = commonPathPrefix([client.projectRoot, filepath]).length;\n if (longestPrefix < prefix) {\n longestPrefix = prefix;\n bestClient = client;\n } else if (longestPrefix === prefix) {\n console.warn('Ambiguous client for ' + filepath);\n }\n }\n return bestClient;\n}\n\nfunction createClient(metafilepath: string) {\n let metafile = JSON.parse(fs.readFileSync(metafilepath, 'utf8'));\n\n let socketfilepath = metafilepath.slice(0, -5);\n let [reader, writer] = createServerPipeTransport(socketfilepath);\n let client = createMessageConnection(reader, writer);\n client.listen();\n\n let uris = new Set<DocumentUri>();\n\n let result = {\n connection: client,\n uris,\n projectRoot: metafile.projectRoot,\n lastBuild: '0',\n };\n\n client.onNotification(NotificationBuildStatus, (state, message) => {\n // console.log('got NotificationBuildStatus', state, message);\n if (state === 'start') {\n progressReporter.begin();\n for (let uri of uris) {\n connection.sendDiagnostics({uri, diagnostics: []});\n }\n } else if (state === 'progress' && message != null) {\n progressReporter.report(message);\n } else if (state === 'end') {\n result.lastBuild = String(Date.now());\n sendDiagnosticsRefresh();\n progressReporter.done();\n connection.sendNotification(NotificationBuild);\n }\n });\n\n client.onNotification(NotificationWorkspaceDiagnostics, diagnostics => {\n // console.log('got NotificationWorkspaceDiagnostics', diagnostics);\n for (let d of diagnostics) {\n uris.add(d.uri);\n connection.sendDiagnostics(d);\n }\n });\n\n client.onClose(() => {\n clients.delete(metafile);\n sendDiagnosticsRefresh();\n return Promise.all(\n [...uris].map(uri => connection.sendDiagnostics({uri, diagnostics: []})),\n );\n });\n\n sendDiagnosticsRefresh();\n clients.set(metafile, result);\n}\n\n// Take realpath because to have consistent cache keys on macOS (/var -> /private/var)\nconst BASEDIR = path.join(fs.realpathSync(os.tmpdir()), 'parcel-lsp');\nfs.mkdirSync(BASEDIR, {recursive: true});\n// Search for currently running Parcel processes in the parcel-lsp dir.\n// Create an IPC client connection for each running process.\nfor (let filename of fs.readdirSync(BASEDIR)) {\n if (!filename.endsWith('.json')) continue;\n let filepath = path.join(BASEDIR, filename);\n createClient(filepath);\n // console.log('connected initial', filepath);\n}\n\n// Watch for new Parcel processes in the parcel-lsp dir, and disconnect the\n// client for each corresponding connection when a Parcel process ends\nwatcher.subscribe(BASEDIR, async (err, events) => {\n if (err) {\n throw err;\n }\n\n for (let event of events) {\n if (event.type === 'create' && event.path.endsWith('.json')) {\n createClient(event.path);\n // console.log('connected watched', event.path);\n } else if (event.type === 'delete' && event.path.endsWith('.json')) {\n let existing = clients.get(event.path);\n // console.log('existing', event.path, existing);\n if (existing) {\n clients.delete(event.path);\n existing.connection.end();\n // console.log('disconnected watched', event.path);\n }\n }\n }\n});\n"],"names":["path","fs","os","createConnection","DiagnosticRefreshRequest","DidChangeConfigurationNotification","DocumentDiagnosticParams","DocumentDiagnosticReport","DocumentDiagnosticReportKind","DocumentDiagnosticRequest","DocumentUri","InitializeParams","InitializeResult","ProposedFeatures","TextDocumentSyncKind","WorkDoneProgressServerReporter","createServerPipeTransport","createMessageConnection","MessageConnection","invariant","url","commonPathPrefix","watcher","NotificationBuild","NotificationBuildStatus","NotificationWorkspaceDiagnostics","RequestDocumentDiagnostics","RequestImporters","connection","all","hasConfigurationCapability","hasWorkspaceFolderCapability","hasDiagnosticsRefreshSupport","onInitialize","params","capabilities","workspace","configuration","workspaceFolders","Boolean","diagnostics","refreshSupport","result","textDocumentSync","Incremental","diagnosticProvider","workspaceDiagnostics","interFileDependencies","supported","onInitialized","client","register","type","undefined","onDidChangeWorkspaceFolders","console","log","onRequest","findClient","sendRequest","Promise","textDocument","uri","previousResultId","lastBuild","kind","Unchanged","resultId","uris","add","Full","items","listen","ProgressReporter","begin","progressReporterPromise","reporter","window","createWorkDoneProgress","then","lastMessage","report","done","message","r","sendDiagnosticsRefresh","Client","projectRoot","Set","progressReporter","clients","Map","document","filepath","fileURLToPath","longestPrefix","bestClient","prefix","length","warn","createClient","metafilepath","metafile","JSON","parse","readFileSync","socketfilepath","slice","reader","writer","onNotification","state","sendDiagnostics","String","Date","now","sendNotification","d","onClose","delete","map","set","BASEDIR","join","realpathSync","tmpdir","mkdirSync","recursive","filename","readdirSync","endsWith","subscribe","err","events","event","existing","get","end"],"version":3,"file":"LspServer.js.map","sourceRoot":"../../../../"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM4B,mCAAazB,CAAAA,GAAAA,gDAAAA,EAAiBU,CAAAA,GAAAA,gDAAAA,EAAiBgB,GAAG;AAExD,yCAAA;AACA,kFAAA;AAEA,IAAIC,mDAA6B;AACjC,IAAIC,qDAA+B;AACnC,yDAAA;AACA,IAAIC,qDAA+B;AAEnCJ,iCAAWK,YAAY,CAAC,CAACC;QAiBrBC,qCAAAA;IAhBF,MAAMA,eAAeD,OAAOC,YAAY;IAExC,iEAAA;IACA,8CAAA;IACAL,mDAA6B,CAAC,CAC5BK,CAAAA,aAAaC,SAAS,IAAI,CAAC,CAACD,aAAaC,SAAS,CAACC,aAAa,AAAbA;IAErDN,qDAA+B,CAAC,CAC9BI,CAAAA,aAAaC,SAAS,IAAI,CAAC,CAACD,aAAaC,SAAS,CAACE,gBAAgB,AAAhBA;IAErD,kDAAA;IACA,iCAAA;IACA,oDAAA;IACA,oEAAA;IACA,KAAA;IACAN,qDAA+BO,SAC7BJ,0BA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AK,YAAYkF,MAAMtI,IAAI,CAACkI,QAAQ,CAAC,UAAU;YAClE,IAAIK,WAAW7C,8BAAQ8C,GAAG,CAACF,MAAMtI,IAAI;YACrC,iDAAA;YACA,IAAIuI,UAAU;gBACZ7C,8BAAQ6B,MAAM,CAACe,MAAMtI,IAAI;gBACzBuI,SAAS3G,UAAU,CAAC6G,GAAG;YACvB,mDAAA;YACF;QACF;IACF;AACF","sources":["packages/utils/parcel-lsp/src/LspServer.ts"],"sourcesContent":["import * as path from 'path';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport {\n createConnection,\n DiagnosticRefreshRequest,\n DidChangeConfigurationNotification,\n DocumentDiagnosticParams,\n DocumentDiagnosticReport,\n DocumentDiagnosticReportKind,\n DocumentDiagnosticRequest,\n DocumentUri,\n InitializeParams,\n InitializeResult,\n ProposedFeatures,\n TextDocumentSyncKind,\n WorkDoneProgressServerReporter,\n} from 'vscode-languageserver/node';\n\nimport {\n createServerPipeTransport,\n createMessageConnection,\n MessageConnection,\n} from 'vscode-jsonrpc/node';\nimport * as invariant from 'assert';\nimport * as url from 'url';\nimport commonPathPrefix = require('common-path-prefix');\n\n// import {TextDocument} from 'vscode-languageserver-textdocument';\nimport * as watcher from '@parcel/watcher';\nimport {\n NotificationBuild,\n NotificationBuildStatus,\n NotificationWorkspaceDiagnostics,\n RequestDocumentDiagnostics,\n RequestImporters,\n} from '@parcel/lsp-protocol';\n\nconst connection = createConnection(ProposedFeatures.all);\n\n// Create a simple text document manager.\n// const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);\n\nlet hasConfigurationCapability = false;\nlet hasWorkspaceFolderCapability = false;\n// let hasDiagnosticRelatedInformationCapability = false;\nlet hasDiagnosticsRefreshSupport = false;\n\nconnection.onInitialize((params: InitializeParams) => {\n const capabilities = params.capabilities;\n\n // Does the client support the `workspace/configuration` request?\n // If not, we fall back using global settings.\n hasConfigurationCapability = !!(\n capabilities.workspace && !!capabilities.workspace.configuration\n );\n hasWorkspaceFolderCapability = !!(\n capabilities.workspace && !!capabilities.workspace.workspaceFolders\n );\n // hasDiagnosticRelatedInformationCapability = !!(\n // capabilities.textDocument &&\n // capabilities.textDocument.publishDiagnostics &&\n // capabilities.textDocument.publishDiagnostics.relatedInformation\n // );\n hasDiagnosticsRefreshSupport = Boolean(\n capabilities.workspace?.diagnostics?.refreshSupport,\n );\n\n const result: InitializeResult = {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n // Tell the client that this server supports code completion.\n diagnosticProvider: {\n workspaceDiagnostics: false,\n interFileDependencies: true,\n },\n },\n };\n\n if (hasWorkspaceFolderCapability) {\n result.capabilities.workspace = {\n workspaceFolders: {\n supported: true,\n },\n };\n }\n return result;\n});\n\nconnection.onInitialized(() => {\n if (hasConfigurationCapability) {\n // Register for all configuration changes.\n connection.client.register(\n DidChangeConfigurationNotification.type,\n undefined,\n );\n }\n if (hasWorkspaceFolderCapability) {\n connection.workspace.onDidChangeWorkspaceFolders(_event => {\n connection.console.log('Workspace folder change event received.');\n });\n }\n});\n\n// Proxy\nconnection.onRequest(RequestImporters, async params => {\n let client = findClient(params);\n if (client) {\n let result = await client.connection.sendRequest(RequestImporters, params);\n return result;\n }\n return null;\n});\n\nconnection.onRequest(\n DocumentDiagnosticRequest.type,\n async (\n params: DocumentDiagnosticParams,\n ): Promise<DocumentDiagnosticReport> => {\n let client = findClient(params.textDocument.uri);\n let result;\n if (client) {\n // console.log(\n // 'DocumentDiagnosticRequest',\n // params.textDocument.uri,\n // params.previousResultId === client.lastBuild,\n // );\n\n if (params.previousResultId === client.lastBuild) {\n return {\n kind: DocumentDiagnosticReportKind.Unchanged,\n resultId: client.lastBuild,\n };\n }\n\n result = await client.connection.sendRequest(\n RequestDocumentDiagnostics,\n params.textDocument.uri,\n );\n\n if (result) {\n client.uris.add(params.textDocument.uri);\n }\n }\n\n return {\n kind: DocumentDiagnosticReportKind.Full,\n resultId: client?.lastBuild,\n items: result ?? [],\n };\n },\n);\n\nconnection.listen();\n\nclass ProgressReporter {\n progressReporterPromise?: Promise<WorkDoneProgressServerReporter> | null;\n lastMessage?: string;\n begin() {\n this.progressReporterPromise = (async () => {\n let reporter = await connection.window.createWorkDoneProgress();\n reporter.begin('Parcel');\n return reporter;\n })();\n this.progressReporterPromise.then(reporter => {\n if (this.lastMessage != null) {\n reporter.report(this.lastMessage);\n }\n });\n }\n async done() {\n if (this.progressReporterPromise == null) {\n this.begin();\n }\n invariant(this.progressReporterPromise != null);\n (await this.progressReporterPromise).done();\n this.progressReporterPromise = null;\n }\n async report(message: string) {\n if (this.progressReporterPromise == null) {\n this.lastMessage = message;\n this.begin();\n } else {\n let r = await this.progressReporterPromise;\n r.report(message);\n }\n }\n}\n\nfunction sendDiagnosticsRefresh() {\n if (hasDiagnosticsRefreshSupport) {\n connection.sendRequest(DiagnosticRefreshRequest.type);\n }\n}\n\ntype Client = {\n connection: MessageConnection;\n projectRoot: string;\n uris: Set<DocumentUri>;\n lastBuild: string;\n};\n\nlet progressReporter = new ProgressReporter();\nlet clients: Map<string, Client> = new Map();\n\nfunction findClient(document: DocumentUri): Client | undefined {\n let filepath = url.fileURLToPath(document);\n\n let longestPrefix = 0;\n let bestClient;\n for (let [, client] of clients) {\n let prefix = commonPathPrefix([client.projectRoot, filepath]).length;\n if (longestPrefix < prefix) {\n longestPrefix = prefix;\n bestClient = client;\n } else if (longestPrefix === prefix) {\n console.warn('Ambiguous client for ' + filepath);\n }\n }\n return bestClient;\n}\n\nfunction createClient(metafilepath: string) {\n let metafile = JSON.parse(fs.readFileSync(metafilepath, 'utf8'));\n\n let socketfilepath = metafilepath.slice(0, -5);\n let [reader, writer] = createServerPipeTransport(socketfilepath);\n let client = createMessageConnection(reader, writer);\n client.listen();\n\n let uris = new Set<DocumentUri>();\n\n let result = {\n connection: client,\n uris,\n projectRoot: metafile.projectRoot,\n lastBuild: '0',\n };\n\n client.onNotification(NotificationBuildStatus, (state, message) => {\n // console.log('got NotificationBuildStatus', state, message);\n if (state === 'start') {\n progressReporter.begin();\n for (let uri of uris) {\n connection.sendDiagnostics({uri, diagnostics: []});\n }\n } else if (state === 'progress' && message != null) {\n progressReporter.report(message);\n } else if (state === 'end') {\n result.lastBuild = String(Date.now());\n sendDiagnosticsRefresh();\n progressReporter.done();\n connection.sendNotification(NotificationBuild);\n }\n });\n\n client.onNotification(NotificationWorkspaceDiagnostics, diagnostics => {\n // console.log('got NotificationWorkspaceDiagnostics', diagnostics);\n for (let d of diagnostics) {\n uris.add(d.uri);\n connection.sendDiagnostics(d);\n }\n });\n\n client.onClose(() => {\n clients.delete(metafile);\n sendDiagnosticsRefresh();\n return Promise.all(\n [...uris].map(uri => connection.sendDiagnostics({uri, diagnostics: []})),\n );\n });\n\n sendDiagnosticsRefresh();\n clients.set(metafile, result);\n}\n\n// Take realpath because to have consistent cache keys on macOS (/var -> /private/var)\nconst BASEDIR = path.join(fs.realpathSync(os.tmpdir()), 'parcel-lsp');\nfs.mkdirSync(BASEDIR, {recursive: true});\n// Search for currently running Parcel processes in the parcel-lsp dir.\n// Create an IPC client connection for each running process.\nfor (let filename of fs.readdirSync(BASEDIR)) {\n if (!filename.endsWith('.json')) continue;\n let filepath = path.join(BASEDIR, filename);\n createClient(filepath);\n // console.log('connected initial', filepath);\n}\n\n// Watch for new Parcel processes in the parcel-lsp dir, and disconnect the\n// client for each corresponding connection when a Parcel process ends\nwatcher.subscribe(BASEDIR, async (err, events) => {\n if (err) {\n throw err;\n }\n\n for (let event of events) {\n if (event.type === 'create' && event.path.endsWith('.json')) {\n createClient(event.path);\n // console.log('connected watched', event.path);\n } else if (event.type === 'delete' && event.path.endsWith('.json')) {\n let existing = clients.get(event.path);\n // console.log('existing', event.path, existing);\n if (existing) {\n clients.delete(event.path);\n existing.connection.end();\n // console.log('disconnected watched', event.path);\n }\n }\n }\n});\n"],"names":["path","fs","os","createConnection","DiagnosticRefreshRequest","DidChangeConfigurationNotification","DocumentDiagnosticParams","DocumentDiagnosticReport","DocumentDiagnosticReportKind","DocumentDiagnosticRequest","DocumentUri","InitializeParams","InitializeResult","ProposedFeatures","TextDocumentSyncKind","WorkDoneProgressServerReporter","createServerPipeTransport","createMessageConnection","MessageConnection","invariant","url","commonPathPrefix","watcher","NotificationBuild","NotificationBuildStatus","NotificationWorkspaceDiagnostics","RequestDocumentDiagnostics","RequestImporters","connection","all","hasConfigurationCapability","hasWorkspaceFolderCapability","hasDiagnosticsRefreshSupport","onInitialize","params","capabilities","workspace","configuration","workspaceFolders","Boolean","diagnostics","refreshSupport","result","textDocumentSync","Incremental","diagnosticProvider","workspaceDiagnostics","interFileDependencies","supported","onInitialized","client","register","type","undefined","onDidChangeWorkspaceFolders","console","log","onRequest","findClient","sendRequest","Promise","textDocument","uri","previousResultId","lastBuild","kind","Unchanged","resultId","uris","add","Full","items","listen","ProgressReporter","begin","progressReporterPromise","reporter","window","createWorkDoneProgress","then","lastMessage","report","done","message","r","sendDiagnosticsRefresh","Client","projectRoot","Set","progressReporter","clients","Map","document","filepath","fileURLToPath","longestPrefix","bestClient","prefix","length","warn","createClient","metafilepath","metafile","JSON","parse","readFileSync","socketfilepath","slice","reader","writer","onNotification","state","sendDiagnostics","String","Date","now","sendNotification","d","onClose","delete","map","set","BASEDIR","join","realpathSync","tmpdir","mkdirSync","recursive","filename","readdirSync","endsWith","subscribe","err","events","event","existing","get","end"],"version":3,"file":"LspServer.js.map","sourceRoot":"../../../../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/lsp",
3
- "version": "2.9.4-nightly.3003+801de2c60",
3
+ "version": "2.9.4-nightly.3008+4499a71ba",
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.1378+801de2c60"
25
+ "parcel": "2.0.0-nightly.1383+4499a71ba"
26
26
  },
27
27
  "dependencies": {
28
- "@parcel/lsp-protocol": "2.9.4-nightly.3003+801de2c60",
28
+ "@parcel/lsp-protocol": "2.9.4-nightly.3008+4499a71ba",
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": "801de2c60ae0c37df6d798ee3a93f45afe9909c7"
47
+ "gitHead": "4499a71ba8ba8797117a07244f1c8848f2d5dedb"
48
48
  }