@lvce-editor/shared-process 0.100.14 → 0.100.15
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 -2
- package/src/parts/BuiltinExtensionsPath/BuiltinExtensionsPath.js +1 -1
- package/src/parts/LanguageServer/LanguageServer.ipc.js +1 -0
- package/src/parts/LanguageServer/LanguageServer.js +12 -0
- package/src/parts/LanguageServerConnection/LanguageServerConnection.js +59 -0
- package/src/parts/ModuleMap/ModuleMap.js +1 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/PreloadUrl/PreloadUrl.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.15",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "1.9.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.100.
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.100.15",
|
|
22
22
|
"@lvce-editor/ipc": "16.11.0",
|
|
23
23
|
"@lvce-editor/json-rpc": "8.6.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "1.5.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', 'fe8b07e', 'extensions')
|
|
7
7
|
return builtinExtensionsPath
|
|
8
8
|
}
|
|
@@ -3,6 +3,7 @@ import * as LanguageServer from './LanguageServer.js'
|
|
|
3
3
|
export const name = 'LanguageServer'
|
|
4
4
|
|
|
5
5
|
export const Commands = {
|
|
6
|
+
codeAction: LanguageServer.codeAction,
|
|
6
7
|
complete: LanguageServer.complete,
|
|
7
8
|
definition: LanguageServer.definition,
|
|
8
9
|
diagnostic: LanguageServer.diagnostic,
|
|
@@ -19,6 +19,8 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
|
|
@@ -88,6 +90,16 @@ export const complete = async ({ argv, extensionId, id, offset, rootUri, textDoc
|
|
|
88
90
|
return connection.complete(normalizedDocument, offset)
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
export const codeAction = async ({ argv, extensionId, id, offset, rootUri, textDocument, uri } ) => {
|
|
94
|
+
const normalizedDocument = {
|
|
95
|
+
...textDocument,
|
|
96
|
+
uri: normalizeLanguageServerDocumentUri(textDocument.uri),
|
|
97
|
+
}
|
|
98
|
+
const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
|
|
99
|
+
const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
|
|
100
|
+
return connection.codeAction(normalizedDocument, offset)
|
|
101
|
+
}
|
|
102
|
+
|
|
91
103
|
export const diagnostic = async ({ argv, extensionId, id, rootUri, textDocument, uri } ) => {
|
|
92
104
|
const normalizedDocument = {
|
|
93
105
|
...textDocument,
|
|
@@ -32,6 +32,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
|
@@ -91,6 +92,40 @@ const getPosition = (text, offset) => {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
const comparePositions = (first, second) => {
|
|
106
|
+
return first.line - second.line || first.character - second.character
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const isPosition = (value) => {
|
|
110
|
+
return (
|
|
111
|
+
Boolean(value) && typeof value === 'object' && typeof (value).character === 'number' && typeof (value).line === 'number'
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const containsPosition = (value, position) => {
|
|
116
|
+
if (!value || typeof value !== 'object') {
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
const range = (value).range
|
|
120
|
+
return Boolean(
|
|
121
|
+
range &&
|
|
122
|
+
isPosition(range.start) &&
|
|
123
|
+
isPosition(range.end) &&
|
|
124
|
+
comparePositions(range.start, position) <= 0 &&
|
|
125
|
+
comparePositions(position, range.end) <= 0,
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
94
129
|
const getWorkspaceName = (rootUri) => {
|
|
95
130
|
try {
|
|
96
131
|
return basename(fileURLToPath(rootUri)) || 'workspace'
|
|
@@ -132,6 +167,7 @@ export class LanguageServerConnection {
|
|
|
132
167
|
nextRequestId = 1
|
|
133
168
|
running = true
|
|
134
169
|
stderr = ''
|
|
170
|
+
supportsCodeActions = false
|
|
135
171
|
supportsDocumentFormatting = false
|
|
136
172
|
supportsPullDiagnostics = false
|
|
137
173
|
|
|
@@ -172,6 +208,28 @@ export class LanguageServerConnection {
|
|
|
172
208
|
this.rejectPendingRequests(new Error('Language server was disposed'))
|
|
173
209
|
}
|
|
174
210
|
|
|
211
|
+
async codeAction(textDocument, offset) {
|
|
212
|
+
await this.ready
|
|
213
|
+
if (!this.supportsCodeActions) {
|
|
214
|
+
return []
|
|
215
|
+
}
|
|
216
|
+
const diagnostics = await this.diagnostic(textDocument)
|
|
217
|
+
const position = getPosition(textDocument.text, offset)
|
|
218
|
+
const result = await this.sendRequest('textDocument/codeAction', {
|
|
219
|
+
context: {
|
|
220
|
+
diagnostics: diagnostics.filter((diagnostic) => containsPosition(diagnostic, position)),
|
|
221
|
+
},
|
|
222
|
+
range: {
|
|
223
|
+
end: position,
|
|
224
|
+
start: position,
|
|
225
|
+
},
|
|
226
|
+
textDocument: {
|
|
227
|
+
uri: textDocument.uri,
|
|
228
|
+
},
|
|
229
|
+
})
|
|
230
|
+
return Array.isArray(result) ? result : []
|
|
231
|
+
}
|
|
232
|
+
|
|
175
233
|
async complete(textDocument, offset) {
|
|
176
234
|
await this.ready
|
|
177
235
|
this.configureMarkdown(textDocument.languageId)
|
|
@@ -339,6 +397,7 @@ export class LanguageServerConnection {
|
|
|
339
397
|
},
|
|
340
398
|
],
|
|
341
399
|
}))
|
|
400
|
+
this.supportsCodeActions = Boolean(result?.capabilities?.codeActionProvider)
|
|
342
401
|
this.supportsDocumentFormatting = Boolean(result?.capabilities?.documentFormattingProvider)
|
|
343
402
|
this.supportsPullDiagnostics = Boolean(result?.capabilities?.diagnosticProvider)
|
|
344
403
|
this.sendNotification('initialized', {})
|
|
@@ -211,6 +211,7 @@ export const getModuleId = (commandId) => {
|
|
|
211
211
|
return ModuleId.InstallExtension
|
|
212
212
|
case 'IsAutoUpdateSupported.isAutoUpdateSupported':
|
|
213
213
|
return ModuleId.IsAutoUpdateSupported
|
|
214
|
+
case 'LanguageServer.codeAction':
|
|
214
215
|
case 'LanguageServer.complete':
|
|
215
216
|
case 'LanguageServer.definition':
|
|
216
217
|
case 'LanguageServer.diagnostic':
|
|
@@ -61,11 +61,11 @@ export const getSetupName = () => {
|
|
|
61
61
|
return 'Lvce-Setup'
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const version = '0.100.
|
|
64
|
+
export const version = '0.100.15'
|
|
65
65
|
|
|
66
|
-
export const commit = '
|
|
66
|
+
export const commit = 'fe8b07e'
|
|
67
67
|
|
|
68
|
-
export const date = '2026-08-
|
|
68
|
+
export const date = '2026-08-11T10:24:26.000Z'
|
|
69
69
|
|
|
70
70
|
export const getVersion = () => {
|
|
71
71
|
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', 'fe8b07e', 'packages', 'preload', 'dist', 'index.js')
|
|
6
6
|
}
|