@lvce-editor/shared-process 0.128.6 → 0.128.7
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/package.json +2 -1
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/ElectronWindow/ElectronWindow.ipc.js +1 -0
- package/src/parts/ElectronWindow/ElectronWindow.js +8 -0
- package/src/parts/GetAppWindowOptions/GetAppWindowOptions.js +23 -11
- package/src/parts/GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js +2 -1
- package/src/parts/LanguageServer/LanguageServer.ipc.js +1 -0
- package/src/parts/LanguageServer/LanguageServer.js +42 -20
- package/src/parts/LanguageServerConnection/LanguageServerConnection.js +58 -6
- package/src/parts/LanguageServerFileWatcher/LanguageServerFileWatcher.js +183 -0
- package/src/parts/ModuleMap/ModuleMap.js +2 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PreloadUrl/PreloadUrl.js +1 -1
- package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.128.
|
|
3
|
+
"version": "0.128.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@lvce-editor/process-explorer": "3.37.6",
|
|
27
27
|
"@lvce-editor/rpc-registry": "9.67.1",
|
|
28
28
|
"@lvce-editor/verror": "1.7.0",
|
|
29
|
+
"chokidar": "^5.0.0",
|
|
29
30
|
"is-object": "^1.0.2",
|
|
30
31
|
"rollup": "^4.68.8",
|
|
31
32
|
"xdg-basedir": "^5.1.0"
|
|
@@ -3,6 +3,6 @@ import { fileURLToPath } from 'url'
|
|
|
3
3
|
|
|
4
4
|
export const getBuiltinExtensionsPath = () => {
|
|
5
5
|
const staticServerPath = fileURLToPath(import.meta.resolve('@lvce-editor/static-server'))
|
|
6
|
-
const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '
|
|
6
|
+
const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '9b81870', 'extensions')
|
|
7
7
|
return builtinExtensionsPath
|
|
8
8
|
}
|
|
@@ -13,6 +13,7 @@ export const Commands = {
|
|
|
13
13
|
openNewWithEditorInput: ElectronWindow.openNewWithEditorInput,
|
|
14
14
|
openNewWithUri: ElectronWindow.openNewWithUri,
|
|
15
15
|
reload: ElectronWindow.reload,
|
|
16
|
+
setAppearance: ElectronWindow.setAppearance,
|
|
16
17
|
setBrowserFullWidthGestureEnabled: ElectronWindow.setBrowserFullWidthGestureEnabled,
|
|
17
18
|
show: ElectronWindow.show,
|
|
18
19
|
takeEditorTransfer: ElectronWindow.takeEditorTransfer,
|
|
@@ -136,4 +136,12 @@ export const setBrowserFullWidthGestureEnabled = (windowId, enabled) => {
|
|
|
136
136
|
)
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
export const setAppearance = (windowId, appearance) => {
|
|
140
|
+
Assert.number(windowId)
|
|
141
|
+
if (appearance !== null) {
|
|
142
|
+
Assert.string(appearance)
|
|
143
|
+
}
|
|
144
|
+
return ParentIpc.invoke('ElectronWindow.setAppearance', windowId, appearance)
|
|
145
|
+
}
|
|
146
|
+
|
|
139
147
|
export { openNewWithEditorInput, takeEditorTransfer, completeEditorTransfer } from '../EditorTransfer/EditorTransfer.js'
|
|
@@ -5,6 +5,15 @@ import * as Platform from '../Platform/Platform.js'
|
|
|
5
5
|
const fallbackBackground = '#1e2324'
|
|
6
6
|
const fallbackSymbolColor = '#74b1be'
|
|
7
7
|
|
|
8
|
+
// Board uses a light surface independently of the workbench color theme.
|
|
9
|
+
const boardBackground = '#ffffff'
|
|
10
|
+
const appearanceByName = {
|
|
11
|
+
board: {
|
|
12
|
+
backgroundColor: boardBackground,
|
|
13
|
+
titleBarOverlay: { color: boardBackground, symbolColor: '#202124' },
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
const getColor = (colors, keys, fallback) => {
|
|
9
18
|
for (const key of keys) {
|
|
10
19
|
if (colors[key]) {
|
|
@@ -53,15 +62,18 @@ export const getAppWindowOptions = async ({ preferences, preloadUrl, screenHeigh
|
|
|
53
62
|
}
|
|
54
63
|
: undefined
|
|
55
64
|
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
return {
|
|
66
|
+
...GetBrowserWindowOptions.getBrowserWindowOptions({
|
|
67
|
+
background,
|
|
68
|
+
frame,
|
|
69
|
+
height: screenHeight,
|
|
70
|
+
preloadUrl,
|
|
71
|
+
titleBarOverlay,
|
|
72
|
+
titleBarStyle,
|
|
73
|
+
width: 800,
|
|
74
|
+
x: screenWidth - 800,
|
|
75
|
+
y: 0,
|
|
76
|
+
}),
|
|
77
|
+
appearanceByName,
|
|
78
|
+
}
|
|
67
79
|
}
|
package/src/parts/GetElectronFileResponseAbsolutePath/GetElectronFileResponseAbsolutePath.js
CHANGED
|
@@ -3,6 +3,7 @@ import { tmpdir } from 'node:os'
|
|
|
3
3
|
import { join } from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
import * as Path from '../Path/Path.js'
|
|
6
|
+
import { removeQueryParameters } from '../RemoveQueryParameters/RemoveQueryParameters.js'
|
|
6
7
|
import * as Root from '../Root/Root.js'
|
|
7
8
|
import * as StaticPath from '../StaticPath/StaticPath.js'
|
|
8
9
|
|
|
@@ -57,7 +58,7 @@ const getRemoteAbsolutePath = (pathName) => {
|
|
|
57
58
|
|
|
58
59
|
// TODO clean up this code
|
|
59
60
|
export const getElectronFileResponseAbsolutePath = (pathName) => {
|
|
60
|
-
if (appRoutePattern.test(pathName)) {
|
|
61
|
+
if (appRoutePattern.test(removeQueryParameters(pathName))) {
|
|
61
62
|
const staticPath = StaticPath.getStaticPath()
|
|
62
63
|
return Path.join(staticPath, 'index.html')
|
|
63
64
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { dirname } from 'node:path'
|
|
2
2
|
import { pathToFileURL } from 'node:url'
|
|
3
|
+
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
3
4
|
import { LanguageServerConnection } from '../LanguageServerConnection/LanguageServerConnection.js'
|
|
4
5
|
import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDocumentUri/NormalizeLanguageServerDocumentUri.js'
|
|
5
6
|
|
|
@@ -53,6 +54,33 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
|
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
const connections = new Map ()
|
|
57
|
+
const diagnosticObservers = new Set ()
|
|
58
|
+
|
|
59
|
+
export const observeDiagnostics = (ipc) => {
|
|
60
|
+
if (diagnosticObservers.has(ipc)) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
diagnosticObservers.add(ipc)
|
|
64
|
+
const onClose = () => {
|
|
65
|
+
diagnosticObservers.delete(ipc)
|
|
66
|
+
if (ipc.removeEventListener) {
|
|
67
|
+
ipc.removeEventListener('close', onClose)
|
|
68
|
+
} else {
|
|
69
|
+
ipc.off('close', onClose)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (ipc.addEventListener) {
|
|
73
|
+
ipc.addEventListener('close', onClose)
|
|
74
|
+
} else {
|
|
75
|
+
ipc.on('close', onClose)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const refreshDiagnostics = (rootUri) => {
|
|
80
|
+
for (const ipc of diagnosticObservers) {
|
|
81
|
+
JsonRpc.send(ipc, 'GetActiveEditor.refreshLanguageServerDiagnostics', rootUri)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
56
84
|
|
|
57
85
|
const getRootUri = (documentUri) => {
|
|
58
86
|
if (documentUri.startsWith('file:')) {
|
|
@@ -68,14 +96,16 @@ const hasSameOptions = (state, uri, argv) => {
|
|
|
68
96
|
return state.uri === uri && state.argv.length === argv.length && state.argv.every((argument, index) => argument === argv[index])
|
|
69
97
|
}
|
|
70
98
|
|
|
71
|
-
const getConnection = (id, extensionId, uri, argv,
|
|
72
|
-
const
|
|
99
|
+
const getConnection = (id, extensionId, uri, argv, workspace) => {
|
|
100
|
+
const rootUri = normalizeLanguageServerDocumentUri(workspace)
|
|
101
|
+
const key = `${id}:${rootUri}`
|
|
102
|
+
const existing = connections.get(key)
|
|
73
103
|
if (existing && existing.extensionId === extensionId && existing.connection.isRunning() && hasSameOptions(existing, uri, argv)) {
|
|
74
104
|
return existing.connection
|
|
75
105
|
}
|
|
76
106
|
existing?.connection.dispose()
|
|
77
|
-
const connection = new LanguageServerConnection({ argv, rootUri, uri })
|
|
78
|
-
connections.set(
|
|
107
|
+
const connection = new LanguageServerConnection({ argv, refreshDiagnostics: () => refreshDiagnostics(workspace), rootUri, uri })
|
|
108
|
+
connections.set(key, {
|
|
79
109
|
argv: [...argv],
|
|
80
110
|
connection,
|
|
81
111
|
extensionId,
|
|
@@ -89,8 +119,7 @@ export const complete = async ({ argv, extensionId, id, offset, rootUri, textDoc
|
|
|
89
119
|
...textDocument,
|
|
90
120
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
91
121
|
}
|
|
92
|
-
const
|
|
93
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
122
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
94
123
|
return connection.complete(normalizedDocument, offset)
|
|
95
124
|
}
|
|
96
125
|
|
|
@@ -108,8 +137,7 @@ export const codeAction = async ({
|
|
|
108
137
|
...textDocument,
|
|
109
138
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
110
139
|
}
|
|
111
|
-
const
|
|
112
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
140
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
113
141
|
return connection.codeAction(normalizedDocument, offset, only)
|
|
114
142
|
}
|
|
115
143
|
|
|
@@ -118,8 +146,7 @@ export const diagnostic = async ({ argv, extensionId, id, rootUri, textDocument,
|
|
|
118
146
|
...textDocument,
|
|
119
147
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
120
148
|
}
|
|
121
|
-
const
|
|
122
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
149
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
123
150
|
return connection.diagnostic(normalizedDocument)
|
|
124
151
|
}
|
|
125
152
|
|
|
@@ -128,8 +155,7 @@ export const definition = async ({ argv, extensionId, id, offset, rootUri, textD
|
|
|
128
155
|
...textDocument,
|
|
129
156
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
130
157
|
}
|
|
131
|
-
const
|
|
132
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
158
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
133
159
|
return connection.definition(normalizedDocument, offset)
|
|
134
160
|
}
|
|
135
161
|
|
|
@@ -138,8 +164,7 @@ export const documentSymbols = async ({ argv, extensionId, id, rootUri, textDocu
|
|
|
138
164
|
...textDocument,
|
|
139
165
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
140
166
|
}
|
|
141
|
-
const
|
|
142
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
167
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
143
168
|
return connection.documentSymbols(normalizedDocument)
|
|
144
169
|
}
|
|
145
170
|
|
|
@@ -148,8 +173,7 @@ export const format = async ({ argv, extensionId, id, rootUri, textDocument, uri
|
|
|
148
173
|
...textDocument,
|
|
149
174
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
150
175
|
}
|
|
151
|
-
const
|
|
152
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
176
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
153
177
|
return connection.format(normalizedDocument)
|
|
154
178
|
}
|
|
155
179
|
|
|
@@ -158,8 +182,7 @@ export const references = async ({ argv, extensionId, id, offset, rootUri, textD
|
|
|
158
182
|
...textDocument,
|
|
159
183
|
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
160
184
|
}
|
|
161
|
-
const
|
|
162
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
185
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
163
186
|
return connection.references(normalizedDocument, offset)
|
|
164
187
|
}
|
|
165
188
|
|
|
@@ -178,8 +201,7 @@ export const feature = async ({
|
|
|
178
201
|
|
|
179
202
|
) => {
|
|
180
203
|
const normalizedDocument = { ...textDocument, uri: normalizeLanguageServerDocumentUri(textDocument.uri) }
|
|
181
|
-
const
|
|
182
|
-
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
204
|
+
const connection = getConnection(id, extensionId, uri, argv, rootUri || getRootUri(normalizedDocument.uri))
|
|
183
205
|
return connection.feature(normalizedDocument, method, offset, newName)
|
|
184
206
|
}
|
|
185
207
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn, } from 'node:child_process'
|
|
2
2
|
import { basename, extname } from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { LanguageServerFileWatcher } from '../LanguageServerFileWatcher/LanguageServerFileWatcher.js'
|
|
4
5
|
import { LanguageServerMessageParser } from '../LanguageServerMessageParser/LanguageServerMessageParser.js'
|
|
5
6
|
import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDocumentUri/NormalizeLanguageServerDocumentUri.js'
|
|
6
7
|
import { typeScriptLanguageServerPath } from '../TypeScriptLanguageServerPath/TypeScriptLanguageServerPath.js'
|
|
@@ -61,6 +62,7 @@ import { typeScriptLanguageServerPath } from '../TypeScriptLanguageServerPath/Ty
|
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
|
|
65
|
+
|
|
64
66
|
|
|
65
67
|
|
|
66
68
|
|
|
@@ -131,14 +133,17 @@ const containsPosition = (value, position) => {
|
|
|
131
133
|
)
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
const
|
|
136
|
+
const getWorkspacePath = (rootUri) => {
|
|
135
137
|
try {
|
|
136
|
-
return
|
|
138
|
+
return fileURLToPath(rootUri)
|
|
137
139
|
} catch {
|
|
138
|
-
|
|
140
|
+
// A language server can use roots that the local filesystem cannot watch.
|
|
141
|
+
return undefined
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
|
|
145
|
+
const getWorkspaceName = (rootUri) => basename(getWorkspacePath(rootUri) ?? '') || 'workspace'
|
|
146
|
+
|
|
142
147
|
const createDeferred = () => {
|
|
143
148
|
let resolve = () => {}
|
|
144
149
|
const promise = new Promise ((resolvePromise) => {
|
|
@@ -170,6 +175,9 @@ export class LanguageServerConnection {
|
|
|
170
175
|
publishedDiagnostics = new Map ()
|
|
171
176
|
ready
|
|
172
177
|
rootUri
|
|
178
|
+
fileWatcher
|
|
179
|
+
isBundledTypeScript
|
|
180
|
+
refreshDiagnostics
|
|
173
181
|
initializationProgressWasStarted = false
|
|
174
182
|
nextRequestId = 1
|
|
175
183
|
running = true
|
|
@@ -181,13 +189,24 @@ export class LanguageServerConnection {
|
|
|
181
189
|
supportsPullDiagnostics = false
|
|
182
190
|
supportsReferences = false
|
|
183
191
|
|
|
184
|
-
constructor({ argv, rootUri, uri } ) {
|
|
192
|
+
constructor({ argv, refreshDiagnostics, rootUri, uri } ) {
|
|
185
193
|
this.rootUri = rootUri
|
|
194
|
+
this.isBundledTypeScript = uri === 'lvce-language-server:typescript'
|
|
195
|
+
this.refreshDiagnostics = refreshDiagnostics
|
|
196
|
+
const workspacePath = getWorkspacePath(rootUri)
|
|
197
|
+
if (workspacePath) {
|
|
198
|
+
this.fileWatcher = new LanguageServerFileWatcher(workspacePath, (changes) => {
|
|
199
|
+
this.sendNotification('workspace/didChangeWatchedFiles', { changes })
|
|
200
|
+
})
|
|
201
|
+
}
|
|
186
202
|
const { args, command, env } = getSpawnOptions(uri, argv)
|
|
187
203
|
this.child = spawn(command, [...args], {
|
|
188
204
|
env,
|
|
189
205
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
190
206
|
})
|
|
207
|
+
this.child.stdin.on('error', () => {
|
|
208
|
+
this.dispose()
|
|
209
|
+
})
|
|
191
210
|
this.child.stdout.on('data', (chunk) => {
|
|
192
211
|
this.handleData(chunk)
|
|
193
212
|
})
|
|
@@ -214,6 +233,7 @@ export class LanguageServerConnection {
|
|
|
214
233
|
return
|
|
215
234
|
}
|
|
216
235
|
this.running = false
|
|
236
|
+
this.fileWatcher?.dispose()
|
|
217
237
|
this.child.kill()
|
|
218
238
|
this.rejectPendingRequests(new Error('Language server was disposed'))
|
|
219
239
|
}
|
|
@@ -265,12 +285,20 @@ export class LanguageServerConnection {
|
|
|
265
285
|
async diagnostic(textDocument) {
|
|
266
286
|
await this.ready
|
|
267
287
|
if (this.supportsPullDiagnostics) {
|
|
288
|
+
// The bundled server can return its first diagnostics before registering
|
|
289
|
+
// file watches. Capture any intervening edits for that registration.
|
|
290
|
+
if (this.isBundledTypeScript) {
|
|
291
|
+
await this.fileWatcher?.prepare()
|
|
292
|
+
}
|
|
268
293
|
this.syncDocument(textDocument)
|
|
269
294
|
const result = await this.sendRequest('textDocument/diagnostic', {
|
|
270
295
|
textDocument: {
|
|
271
296
|
uri: textDocument.uri,
|
|
272
297
|
},
|
|
273
298
|
})
|
|
299
|
+
// The server can return diagnostics while the initial watch is scanning.
|
|
300
|
+
// Changes made in response to those diagnostics need an active watch.
|
|
301
|
+
await this.fileWatcher?.waitUntilReady()
|
|
274
302
|
if (result && typeof result === 'object' && Array.isArray((result).items)) {
|
|
275
303
|
return (result).items
|
|
276
304
|
}
|
|
@@ -424,6 +452,8 @@ export class LanguageServerConnection {
|
|
|
424
452
|
},
|
|
425
453
|
workspace: {
|
|
426
454
|
configuration: true,
|
|
455
|
+
...(this.fileWatcher && { didChangeWatchedFiles: { dynamicRegistration: true, relativePatternSupport: true } }),
|
|
456
|
+
...(this.refreshDiagnostics && { diagnostics: { refreshSupport: true } }),
|
|
427
457
|
workspaceFolders: true,
|
|
428
458
|
},
|
|
429
459
|
},
|
|
@@ -516,6 +546,9 @@ export class LanguageServerConnection {
|
|
|
516
546
|
}
|
|
517
547
|
|
|
518
548
|
handleMessage(message) {
|
|
549
|
+
if (!this.running) {
|
|
550
|
+
return
|
|
551
|
+
}
|
|
519
552
|
if (message.method === 'textDocument/publishDiagnostics') {
|
|
520
553
|
this.handlePublishedDiagnostics(message.params)
|
|
521
554
|
return
|
|
@@ -525,7 +558,7 @@ export class LanguageServerConnection {
|
|
|
525
558
|
return
|
|
526
559
|
}
|
|
527
560
|
if (message.method && message.id !== undefined && message.id !== null) {
|
|
528
|
-
this.handleServerRequest(message)
|
|
561
|
+
void this.handleServerRequest(message)
|
|
529
562
|
return
|
|
530
563
|
}
|
|
531
564
|
if (message.id === undefined || message.id === null) {
|
|
@@ -573,7 +606,7 @@ export class LanguageServerConnection {
|
|
|
573
606
|
this.initializationProgressEnded.resolve()
|
|
574
607
|
}
|
|
575
608
|
|
|
576
|
-
handleServerRequest(message)
|
|
609
|
+
async handleServerRequest(message) {
|
|
577
610
|
try {
|
|
578
611
|
let result = null
|
|
579
612
|
if (message.method === 'workspace/configuration') {
|
|
@@ -582,6 +615,21 @@ export class LanguageServerConnection {
|
|
|
582
615
|
} else if (message.method === 'window/workDoneProgress/create') {
|
|
583
616
|
this.initializationProgressWasStarted = true
|
|
584
617
|
this.initializationProgressStarted.resolve()
|
|
618
|
+
} else if (message.method === 'client/registerCapability') {
|
|
619
|
+
await Promise.all((message.params?.registrations ?? []).map(async (registration) => {
|
|
620
|
+
if (registration.method === 'workspace/didChangeWatchedFiles') {
|
|
621
|
+
await this.fileWatcher?.register(registration.id, registration.registerOptions.watchers)
|
|
622
|
+
}
|
|
623
|
+
}))
|
|
624
|
+
} else if (message.method === 'client/unregisterCapability') {
|
|
625
|
+
// The field is spelled this way in the LSP specification.
|
|
626
|
+
for (const registration of message.params?.unregisterations ?? []) {
|
|
627
|
+
if (registration.method === 'workspace/didChangeWatchedFiles') {
|
|
628
|
+
this.fileWatcher?.unregister(registration.id)
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
} else if (message.method === 'workspace/diagnostic/refresh') {
|
|
632
|
+
this.refreshDiagnostics?.()
|
|
585
633
|
} else if (message.method === 'workspace/workspaceFolders') {
|
|
586
634
|
result = [
|
|
587
635
|
{
|
|
@@ -615,6 +663,7 @@ export class LanguageServerConnection {
|
|
|
615
663
|
return
|
|
616
664
|
}
|
|
617
665
|
this.running = false
|
|
666
|
+
this.fileWatcher?.dispose()
|
|
618
667
|
this.rejectPendingRequests(error)
|
|
619
668
|
}
|
|
620
669
|
|
|
@@ -692,6 +741,9 @@ export class LanguageServerConnection {
|
|
|
692
741
|
}
|
|
693
742
|
|
|
694
743
|
sendMessage(message) {
|
|
744
|
+
if (!this.running) {
|
|
745
|
+
return
|
|
746
|
+
}
|
|
695
747
|
const content = JSON.stringify(message)
|
|
696
748
|
const header = `Content-Length: ${Buffer.byteLength(content)}\r\n\r\n`
|
|
697
749
|
this.child.stdin.write(header + content)
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { basename, isAbsolute, matchesGlob, resolve } from 'node:path'
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const eventTypes = { add: [1, 1], change: [2, 2], unlink: [4, 3] }
|
|
25
|
+
|
|
26
|
+
const toGlobPath = (path) => (process.platform === 'win32' ? path.replaceAll('\\', '/').toLowerCase() : path)
|
|
27
|
+
|
|
28
|
+
const parseWatcher = (workspace, { globPattern, kind = 7 } ) => {
|
|
29
|
+
const glob =
|
|
30
|
+
typeof globPattern === 'string'
|
|
31
|
+
? globPattern
|
|
32
|
+
: resolve(fileURLToPath(typeof globPattern.baseUri === 'string' ? globPattern.baseUri : globPattern.baseUri.uri), globPattern.pattern)
|
|
33
|
+
return { glob: toGlobPath(isAbsolute(glob) ? glob : resolve(workspace, glob)), kind }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export class LanguageServerFileWatcher {
|
|
37
|
+
patterns = new Map ()
|
|
38
|
+
workspace
|
|
39
|
+
sendChanges
|
|
40
|
+
subscription
|
|
41
|
+
changes = []
|
|
42
|
+
pendingEvents
|
|
43
|
+
flushTimer
|
|
44
|
+
|
|
45
|
+
constructor(workspacePath, sendChanges) {
|
|
46
|
+
this.workspace = workspacePath
|
|
47
|
+
this.sendChanges = sendChanges
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async register(id, watchers) {
|
|
51
|
+
const patterns = watchers.map((watcher) => parseWatcher(this.workspace, watcher))
|
|
52
|
+
this.patterns.set(id, patterns)
|
|
53
|
+
const pendingEvents = this.pendingEvents
|
|
54
|
+
this.pendingEvents = undefined
|
|
55
|
+
for (const { event, file } of pendingEvents ?? []) {
|
|
56
|
+
this.handleEvent(event, file)
|
|
57
|
+
}
|
|
58
|
+
const subscription = this.start()
|
|
59
|
+
try {
|
|
60
|
+
await subscription.ready
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (this.subscription === subscription) {
|
|
63
|
+
this.subscription = undefined
|
|
64
|
+
}
|
|
65
|
+
if (this.patterns.get(id) === patterns) {
|
|
66
|
+
this.unregister(id)
|
|
67
|
+
}
|
|
68
|
+
throw error
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async prepare() {
|
|
73
|
+
if (!this.subscription) {
|
|
74
|
+
this.pendingEvents = []
|
|
75
|
+
}
|
|
76
|
+
const subscription = this.start()
|
|
77
|
+
try {
|
|
78
|
+
await subscription.ready
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (this.subscription === subscription) {
|
|
81
|
+
this.dispose()
|
|
82
|
+
console.warn(`[language-server] File watcher for ${this.workspace} failed: ${String(error)}`)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async waitUntilReady() {
|
|
88
|
+
try {
|
|
89
|
+
await this.subscription?.ready
|
|
90
|
+
} catch {
|
|
91
|
+
// The registration request reports the watcher failure.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
unregister(id) {
|
|
96
|
+
this.patterns.delete(id)
|
|
97
|
+
if (this.patterns.size === 0) {
|
|
98
|
+
this.dispose()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
dispose() {
|
|
103
|
+
this.patterns.clear()
|
|
104
|
+
const subscription = this.subscription
|
|
105
|
+
this.subscription = undefined
|
|
106
|
+
clearTimeout(this.flushTimer)
|
|
107
|
+
this.flushTimer = undefined
|
|
108
|
+
this.changes.length = 0
|
|
109
|
+
this.pendingEvents = undefined
|
|
110
|
+
subscription?.controller.abort()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
start() {
|
|
114
|
+
// Keep one workspace watch per connection. Language servers can request
|
|
115
|
+
// broad patterns outside the project (for example, in its parent directory).
|
|
116
|
+
if (!this.subscription) {
|
|
117
|
+
const controller = new AbortController()
|
|
118
|
+
this.subscription = { controller, ready: this.subscribe(controller.signal) }
|
|
119
|
+
}
|
|
120
|
+
return this.subscription
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async subscribe(signal) {
|
|
124
|
+
const { watch } = await import('chokidar')
|
|
125
|
+
signal.throwIfAborted()
|
|
126
|
+
const watcher = watch(this.workspace, {
|
|
127
|
+
followSymlinks: false,
|
|
128
|
+
ignored: (path) => path !== this.workspace && basename(path) === '.git',
|
|
129
|
+
ignoreInitial: true,
|
|
130
|
+
})
|
|
131
|
+
// TypeScript consumes file notifications. A directory creation can arrive
|
|
132
|
+
// before its installed declarations are visible to TypeScript.
|
|
133
|
+
watcher.on('all', (event, path) => {
|
|
134
|
+
if (!signal.aborted && (event === 'add' || event === 'change' || event === 'unlink')) {
|
|
135
|
+
this.handleEvent(event, path)
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
await new Promise ((resolve, reject) => {
|
|
139
|
+
let ready = false
|
|
140
|
+
const close = () => {
|
|
141
|
+
void watcher.close().catch((error) => console.warn(`[language-server] File watcher shutdown failed: ${String(error)}`))
|
|
142
|
+
}
|
|
143
|
+
signal.addEventListener('abort', () => {
|
|
144
|
+
close()
|
|
145
|
+
reject(signal.reason)
|
|
146
|
+
}, { once: true })
|
|
147
|
+
watcher.once('ready', () => {
|
|
148
|
+
ready = true
|
|
149
|
+
resolve()
|
|
150
|
+
})
|
|
151
|
+
watcher.on('error', (error) => {
|
|
152
|
+
if (ready) {
|
|
153
|
+
console.warn(`[language-server] File watcher for ${this.workspace} failed: ${String(error)}`)
|
|
154
|
+
} else {
|
|
155
|
+
close()
|
|
156
|
+
reject(error)
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
handleEvent(event, file) {
|
|
163
|
+
if (this.pendingEvents) {
|
|
164
|
+
this.pendingEvents.push({ event, file })
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
const [kind, type] = eventTypes[event]
|
|
168
|
+
const path = toGlobPath(file)
|
|
169
|
+
const matches = [...this.patterns.values()].some((patterns) =>
|
|
170
|
+
patterns.some((pattern) => (pattern.kind & kind) !== 0 && matchesGlob(path, pattern.glob)),
|
|
171
|
+
)
|
|
172
|
+
if (!matches) {
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
const uri = pathToFileURL(file).href
|
|
176
|
+
this.changes.push({ type, uri })
|
|
177
|
+
this.flushTimer ??= setTimeout(() => {
|
|
178
|
+
this.flushTimer = undefined
|
|
179
|
+
const changes = this.changes.splice(0)
|
|
180
|
+
this.sendChanges(changes)
|
|
181
|
+
}, 50)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -92,6 +92,7 @@ export const getModuleId = (commandId) => {
|
|
|
92
92
|
case 'ElectronWindow.openNewWithEditorInput':
|
|
93
93
|
case 'ElectronWindow.openNewWithUri':
|
|
94
94
|
case 'ElectronWindow.reload':
|
|
95
|
+
case 'ElectronWindow.setAppearance':
|
|
95
96
|
case 'ElectronWindow.setBrowserFullWidthGestureEnabled':
|
|
96
97
|
case 'ElectronWindow.show':
|
|
97
98
|
case 'ElectronWindow.takeEditorTransfer':
|
|
@@ -227,6 +228,7 @@ export const getModuleId = (commandId) => {
|
|
|
227
228
|
case 'LanguageServer.disposeAll':
|
|
228
229
|
case 'LanguageServer.documentSymbols':
|
|
229
230
|
case 'LanguageServer.format':
|
|
231
|
+
case 'LanguageServer.observeDiagnostics':
|
|
230
232
|
case 'LanguageServer.references':
|
|
231
233
|
return ModuleId.LanguageServer
|
|
232
234
|
case 'ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage':
|
|
@@ -56,11 +56,11 @@ export const getSetupName = () => {
|
|
|
56
56
|
return 'Lvce-Setup'
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
export const version = '0.128.
|
|
59
|
+
export const version = '0.128.7'
|
|
60
60
|
|
|
61
|
-
export const commit = '
|
|
61
|
+
export const commit = '9b81870'
|
|
62
62
|
|
|
63
|
-
export const date = '2026-11-
|
|
63
|
+
export const date = '2026-11-25T10:42:38.000Z'
|
|
64
64
|
|
|
65
65
|
export const getVersion = () => {
|
|
66
66
|
return version
|
|
@@ -2,5 +2,5 @@ import { join } from 'node:path'
|
|
|
2
2
|
import * as Root from '../Root/Root.js'
|
|
3
3
|
|
|
4
4
|
export const getPreloadUrl = () => {
|
|
5
|
-
return join(Root.root, 'static', '
|
|
5
|
+
return join(Root.root, 'static', '9b81870', 'packages', 'preload', 'dist', 'index.js')
|
|
6
6
|
}
|
|
@@ -13,6 +13,7 @@ const METHODS_THAT_REQUIRE_SOCKET = new Set([
|
|
|
13
13
|
'HandleMessagePortForExtensionNodeProcess.handleMessagePortForExtensionNodeProcess',
|
|
14
14
|
'ElectronBrowserView.createBrowserView',
|
|
15
15
|
'ElectronWebContentsView.createWebContentsView',
|
|
16
|
+
'LanguageServer.observeDiagnostics',
|
|
16
17
|
'FileWatcher.dispose',
|
|
17
18
|
'FileWatcher.watch',
|
|
18
19
|
'FileWatcher.watchFile2',
|