@atlaspack/lsp 2.14.2-unified-e330ff3d9.0 → 2.14.2-unified-f165f7d09.0

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
@@ -5,9 +5,9 @@ var $cBkJy$vscodelanguageservernode = require("vscode-languageserver/node");
5
5
  var $cBkJy$vscodejsonrpcnode = require("vscode-jsonrpc/node");
6
6
  var $cBkJy$assert = require("assert");
7
7
  var $cBkJy$url = require("url");
8
- var $cBkJy$commonpathprefix = require("common-path-prefix");
9
8
  var $cBkJy$parcelwatcher = require("@parcel/watcher");
10
9
  var $cBkJy$atlaspacklspprotocol = require("@atlaspack/lsp-protocol");
10
+ var $cBkJy$commonpathprefix = require("common-path-prefix");
11
11
 
12
12
 
13
13
 
@@ -61,7 +61,7 @@ $7ef283f05e7b48bf$var$connection.onInitialized(()=>{
61
61
  if ($7ef283f05e7b48bf$var$hasConfigurationCapability) // Register for all configuration changes.
62
62
  $7ef283f05e7b48bf$var$connection.client.register((0, $cBkJy$vscodelanguageservernode.DidChangeConfigurationNotification).type, undefined);
63
63
  if ($7ef283f05e7b48bf$var$hasWorkspaceFolderCapability) // eslint-disable-next-line @typescript-eslint/no-unused-vars
64
- $7ef283f05e7b48bf$var$connection.workspace.onDidChangeWorkspaceFolders(()=>{
64
+ $7ef283f05e7b48bf$var$connection.workspace.onDidChangeWorkspaceFolders((_event)=>{
65
65
  $7ef283f05e7b48bf$var$connection.console.log('Workspace folder change event received.');
66
66
  });
67
67
  });
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMiC,mCAAa9B,CAAAA,GAAAA,gDAAAA,EAAiBU,CAAAA,GAAAA,gDAAAA,EAAiBqB,GAAG;AACxD,MAAMC,uCAAiBJ,QAAQK,GAAG;AAClC,MAAMC,8CAAwB;AAC9B,yCAAA;AACA,kFAAA;AAEA,IAAIC,mDAA6B;AACjC,IAAIC,qD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W;AAAI;AAEtCxI,wBAAiBD,iBAAUoI,+BAAS/F,8CAAwB;AAE5D,0EAAA;AACA,4DAAA;AACA,KAAK,MAAMsG,YAAY1I,sBAAemI,+BAAU;IAC9C,IAAI,CAACO,SAASE,QAAQ,CAAC,UAAU;IACjC,MAAMzC,WAAWpG,iBAAUoI,+BAASO;IACpC,MAAMG,WAAWnC,mCAAaP;IAC9B,MAAM,eAACvE,WAAAA,EAAY,GAAGiH;IAEtB,IAAI3G,yCAAmBN,aACrBmF,mCAAaZ,UAAU0C;AAE3B;AAEA,8EAAA;AACA,yEAAA;AACA,yCAAA;AACAxH,+BAAkB8G,+BAAS,OAAOY,KAAKC;IACrC,IAAID,KACF,MAAMA;IAGR,KAAK,MAAME,SAASD,OAAQ;QAC1B,IAAIC,MAAMtF,IAAI,KAAK,YAAYsF,MAAMlJ,IAAI,CAAC6I,QAAQ,CAAC,UAAU;YAC3D,MAAMC,WAAWnC,mCAAauC,MAAMlJ,IAAI;YACxC,MAAM,eAAC6B,WAAAA,EAAY,GAAGiH;YAEtB,IAAI3G,yCAAmBN,aACrBmF,mCAAakC,MAAMlJ,IAAI,EAAE8I;QAE7B,OAAO,IAAII,MAAMtF,IAAI,KAAK,YAAYsF,MAAMlJ,IAAI,CAAC6I,QAAQ,CAAC,UAAU;YAClE,MAAMM,WAAWlD,8BAAQmD,GAAG,CAACF,MAAMlJ,IAAI;YACvC,sCAAA;YACA+D,QAAQC,GAAG,CAAC,YAAYkF,MAAMlJ,IAAI,EAAEmJ;YACpC,IAAIA,UAAU;gBACZlD,8BAAQ+B,MAAM,CAACkB,MAAMlJ,IAAI;gBACzBmJ,SAASlH,UAAU,CAACoH,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/utils/atlaspack-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 '@atlaspack/lsp-protocol';\n\ntype Metafile = {\n projectRoot: string;\n pid: typeof process['pid'];\n argv: typeof process['argv'];\n};\n\nconst connection = createConnection(ProposedFeatures.all);\nconst WORKSPACE_ROOT = process.cwd();\nconst LSP_SENTINEL_FILENAME = 'lsp-server';\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 const client = findClient(params);\n if (client) {\n const result = await client.connection.sendRequest(\n RequestImporters,\n params,\n );\n return result;\n }\n return null;\n});\n\nconnection.onRequest(\n DocumentDiagnosticRequest.type,\n async (\n params: DocumentDiagnosticParams,\n ): Promise<DocumentDiagnosticReport> => {\n const 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 // eslint-disable-next-line prefer-const\n let reporter = await connection.window.createWorkDoneProgress();\n reporter.begin('Atlaspack');\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 const 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\nconst progressReporter = new ProgressReporter();\nconst clients: Map<string, Client> = new Map();\n\nfunction findClient(document: DocumentUri): Client | undefined {\n const filepath = url.fileURLToPath(document);\n\n let longestPrefix = 0;\n let bestClient;\n for (const [, client] of clients) {\n const prefix = commonPathPrefix([client.projectRoot, filepath]).length;\n if (longestPrefix < prefix) {\n longestPrefix = prefix;\n bestClient = client;\n } else if (longestPrefix === prefix) {\n // eslint-disable-next-line no-console\n console.warn('Ambiguous client for ' + filepath);\n }\n }\n return bestClient;\n}\n\nfunction loadMetafile(filepath: string) {\n const file = fs.readFileSync(filepath, 'utf-8');\n return JSON.parse(file);\n}\n\nfunction createClient(metafilepath: string, metafile: Metafile) {\n const socketfilepath = metafilepath.slice(0, -5);\n const [reader, writer] = createServerPipeTransport(socketfilepath);\n const client = createMessageConnection(reader, writer);\n client.listen();\n\n const uris = new Set<DocumentUri>();\n\n const 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 (const 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 (const d of diagnostics) {\n uris.add(d.uri);\n connection.sendDiagnostics(d);\n }\n });\n\n client.onClose(() => {\n clients.delete(JSON.stringify(metafile));\n sendDiagnosticsRefresh();\n return Promise.all(\n [...uris].map((uri) =>\n connection.sendDiagnostics({uri, diagnostics: []}),\n ),\n );\n });\n\n sendDiagnosticsRefresh();\n clients.set(JSON.stringify(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\nfs.writeFileSync(path.join(BASEDIR, LSP_SENTINEL_FILENAME), '');\n\n// Search for currently running Atlaspack processes in the parcel-lsp dir.\n// Create an IPC client connection for each running process.\nfor (const filename of fs.readdirSync(BASEDIR)) {\n if (!filename.endsWith('.json')) continue;\n const filepath = path.join(BASEDIR, filename);\n const contents = loadMetafile(filepath);\n const {projectRoot} = contents;\n\n if (WORKSPACE_ROOT === projectRoot) {\n createClient(filepath, contents);\n }\n}\n\n// Watch for new Atlaspack processes in the parcel-lsp dir, and disconnect the\n// client for each corresponding connection when a Atlaspack process ends\n// eslint-disable-next-line require-await\nwatcher.subscribe(BASEDIR, async (err, events) => {\n if (err) {\n throw err;\n }\n\n for (const event of events) {\n if (event.type === 'create' && event.path.endsWith('.json')) {\n const contents = loadMetafile(event.path);\n const {projectRoot} = contents;\n\n if (WORKSPACE_ROOT === projectRoot) {\n createClient(event.path, contents);\n }\n } else if (event.type === 'delete' && event.path.endsWith('.json')) {\n const existing = clients.get(event.path);\n // eslint-disable-next-line no-console\n console.log('existing', event.path, existing);\n if (existing) {\n clients.delete(event.path);\n existing.connection.end();\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","Metafile","projectRoot","pid","process","argv","connection","all","WORKSPACE_ROOT","cwd","LSP_SENTINEL_FILENAME","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","Set","progressReporter","clients","Map","document","filepath","fileURLToPath","longestPrefix","bestClient","prefix","length","warn","loadMetafile","file","readFileSync","JSON","parse","createClient","metafilepath","metafile","socketfilepath","slice","reader","writer","onNotification","state","sendDiagnostics","String","Date","now","sendNotification","d","onClose","delete","stringify","map","set","BASEDIR","join","realpathSync","tmpdir","mkdirSync","recursive","writeFileSync","filename","readdirSync","endsWith","contents","subscribe","err","events","event","existing","get","end"],"version":3,"file":"LspServer.js.map","sourceRoot":"../../../../"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAMkC,mCAAa/B,CAAAA,GAAAA,gDAAAA,EAAiBU,CAAAA,GAAAA,gDAAAA,EAAiBsB,GAAG;AACxD,MAAMC,uCAAiBJ,QAAQK,GAAG;AAClC,MAAMC,8CAAwB;AAC9B,yCAAA;AACA,kFAAA;AAEA,I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ACxDD,oBAAaqI,+BAAS;IAACK,WAAW;AAAI;AAEtC1I,wBAAiBD,iBAAUsI,+BAAShG,8CAAwB;AAE5D,0EAAA;AACA,4DAAA;AACA,KAAK,MAAMuG,YAAY5I,sBAAeqI,+BAAU;IAC9C,IAAI,CAACO,SAASE,QAAQ,CAAC,UAAU;IACjC,MAAMzC,WAAWtG,iBAAUsI,+BAASO;IACpC,MAAMG,WAAWnC,mCAAaP;IAC9B,MAAM,eAACxE,WAAAA,EAAY,GAAGkH;IAEtB,IAAI5G,yCAAmBN,aACrBoF,mCAAaZ,UAAU0C;AAE3B;AAEA,8EAAA;AACA,yEAAA;AACA,yCAAA;AACA3H,+BAAkBiH,+BAAS,OAAOY,KAAKC;IACrC,IAAID,KACF,MAAMA;IAGR,KAAK,MAAME,SAASD,OAAQ;QAC1B,IAAIC,MAAMvF,IAAI,KAAK,YAAYuF,MAAMpJ,IAAI,CAAC+I,QAAQ,CAAC,UAAU;YAC3D,MAAMC,WAAWnC,mCAAauC,MAAMpJ,IAAI;YACxC,MAAM,eAAC8B,WAAAA,EAAY,GAAGkH;YAEtB,IAAI5G,yCAAmBN,aACrBoF,mCAAakC,MAAMpJ,IAAI,EAAEgJ;QAE7B,OAAO,IAAII,MAAMvF,IAAI,KAAK,YAAYuF,MAAMpJ,IAAI,CAAC+I,QAAQ,CAAC,UAAU;YAClE,MAAMM,WAAWlD,8BAAQmD,GAAG,CAACF,MAAMpJ,IAAI;YACvC,sCAAA;YACAiE,QAAQC,GAAG,CAAC,YAAYkF,MAAMpJ,IAAI,EAAEqJ;YACpC,IAAIA,UAAU;gBACZlD,8BAAQ+B,MAAM,CAACkB,MAAMpJ,IAAI;gBACzBqJ,SAASnH,UAAU,CAACqH,GAAG;YACzB;QACF;IACF;AACF","sources":["packages/utils/atlaspack-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';\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 '@atlaspack/lsp-protocol';\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst commonPathPrefix = require('common-path-prefix');\n\ntype Metafile = {\n projectRoot: string;\n pid: typeof process['pid'];\n argv: typeof process['argv'];\n};\n\nconst connection = createConnection(ProposedFeatures.all);\nconst WORKSPACE_ROOT = process.cwd();\nconst LSP_SENTINEL_FILENAME = 'lsp-server';\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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 const client = findClient(params);\n if (client) {\n const result = await client.connection.sendRequest(\n RequestImporters,\n params,\n );\n return result;\n }\n return null;\n});\n\nconnection.onRequest(\n DocumentDiagnosticRequest.type,\n async (\n params: DocumentDiagnosticParams,\n ): Promise<DocumentDiagnosticReport> => {\n const 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 // eslint-disable-next-line prefer-const\n let reporter = await connection.window.createWorkDoneProgress();\n reporter.begin('Atlaspack');\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 const 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\nconst progressReporter = new ProgressReporter();\nconst clients: Map<string, Client> = new Map();\n\nfunction findClient(document: DocumentUri): Client | undefined {\n const filepath = url.fileURLToPath(document);\n\n let longestPrefix = 0;\n let bestClient;\n for (const [, client] of clients) {\n const prefix = commonPathPrefix([client.projectRoot, filepath]).length;\n if (longestPrefix < prefix) {\n longestPrefix = prefix;\n bestClient = client;\n } else if (longestPrefix === prefix) {\n // eslint-disable-next-line no-console\n console.warn('Ambiguous client for ' + filepath);\n }\n }\n return bestClient;\n}\n\nfunction loadMetafile(filepath: string) {\n const file = fs.readFileSync(filepath, 'utf-8');\n return JSON.parse(file);\n}\n\nfunction createClient(metafilepath: string, metafile: Metafile) {\n const socketfilepath = metafilepath.slice(0, -5);\n const [reader, writer] = createServerPipeTransport(socketfilepath);\n const client = createMessageConnection(reader, writer);\n client.listen();\n\n const uris = new Set<DocumentUri>();\n\n const 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 (const 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 (const d of diagnostics) {\n uris.add(d.uri);\n connection.sendDiagnostics(d);\n }\n });\n\n client.onClose(() => {\n clients.delete(JSON.stringify(metafile));\n sendDiagnosticsRefresh();\n return Promise.all(\n [...uris].map((uri) =>\n connection.sendDiagnostics({uri, diagnostics: []}),\n ),\n );\n });\n\n sendDiagnosticsRefresh();\n clients.set(JSON.stringify(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\nfs.writeFileSync(path.join(BASEDIR, LSP_SENTINEL_FILENAME), '');\n\n// Search for currently running Atlaspack processes in the parcel-lsp dir.\n// Create an IPC client connection for each running process.\nfor (const filename of fs.readdirSync(BASEDIR)) {\n if (!filename.endsWith('.json')) continue;\n const filepath = path.join(BASEDIR, filename);\n const contents = loadMetafile(filepath);\n const {projectRoot} = contents;\n\n if (WORKSPACE_ROOT === projectRoot) {\n createClient(filepath, contents);\n }\n}\n\n// Watch for new Atlaspack processes in the parcel-lsp dir, and disconnect the\n// client for each corresponding connection when a Atlaspack process ends\n// eslint-disable-next-line require-await\nwatcher.subscribe(BASEDIR, async (err, events) => {\n if (err) {\n throw err;\n }\n\n for (const event of events) {\n if (event.type === 'create' && event.path.endsWith('.json')) {\n const contents = loadMetafile(event.path);\n const {projectRoot} = contents;\n\n if (WORKSPACE_ROOT === projectRoot) {\n createClient(event.path, contents);\n }\n } else if (event.type === 'delete' && event.path.endsWith('.json')) {\n const existing = clients.get(event.path);\n // eslint-disable-next-line no-console\n console.log('existing', event.path, existing);\n if (existing) {\n clients.delete(event.path);\n existing.connection.end();\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","watcher","NotificationBuild","NotificationBuildStatus","NotificationWorkspaceDiagnostics","RequestDocumentDiagnostics","RequestImporters","commonPathPrefix","require","Metafile","projectRoot","pid","process","argv","connection","all","WORKSPACE_ROOT","cwd","LSP_SENTINEL_FILENAME","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","_event","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","Set","progressReporter","clients","Map","document","filepath","fileURLToPath","longestPrefix","bestClient","prefix","length","warn","loadMetafile","file","readFileSync","JSON","parse","createClient","metafilepath","metafile","socketfilepath","slice","reader","writer","onNotification","state","sendDiagnostics","String","Date","now","sendNotification","d","onClose","delete","stringify","map","set","BASEDIR","join","realpathSync","tmpdir","mkdirSync","recursive","writeFileSync","filename","readdirSync","endsWith","contents","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": "@atlaspack/lsp",
3
- "version": "2.14.2-unified-e330ff3d9.0",
3
+ "version": "2.14.2-unified-f165f7d09.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,7 +20,7 @@
20
20
  "node": ">= 16.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@atlaspack/lsp-protocol": "2.14.2-unified-e330ff3d9.0",
23
+ "@atlaspack/lsp-protocol": "2.14.2-unified-f165f7d09.0",
24
24
  "@parcel/watcher": "^2.0.7",
25
25
  "common-path-prefix": "^3.0.0",
26
26
  "nullthrows": "^1.1.1",
@@ -40,5 +40,5 @@
40
40
  "types": false
41
41
  },
42
42
  "type": "commonjs",
43
- "gitHead": "e330ff3d90fbf336f87439a65e312d698433990b"
43
+ "gitHead": "f165f7d09a7970afa669133971ceb2702726c23d"
44
44
  }
package/src/LspServer.ts CHANGED
@@ -24,8 +24,6 @@ import {
24
24
  } from 'vscode-jsonrpc/node';
25
25
  import * as invariant from 'assert';
26
26
  import * as url from 'url';
27
- import commonPathPrefix = require('common-path-prefix');
28
-
29
27
  // import {TextDocument} from 'vscode-languageserver-textdocument';
30
28
  import * as watcher from '@parcel/watcher';
31
29
  import {
@@ -36,6 +34,9 @@ import {
36
34
  RequestImporters,
37
35
  } from '@atlaspack/lsp-protocol';
38
36
 
37
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
38
+ const commonPathPrefix = require('common-path-prefix');
39
+
39
40
  type Metafile = {
40
41
  projectRoot: string;
41
42
  pid: typeof process['pid'];