@lvce-editor/shared-process 0.125.7 → 0.125.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.125.7",
3
+ "version": "0.125.9",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -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', 'b2bafb8', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '674cc9c', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -10,6 +10,7 @@ export const Commands = {
10
10
  dispose: LanguageServer.dispose,
11
11
  disposeAll: LanguageServer.disposeAll,
12
12
  documentSymbols: LanguageServer.documentSymbols,
13
+ feature: LanguageServer.feature,
13
14
  format: LanguageServer.format,
14
15
  references: LanguageServer.references,
15
16
  }
@@ -19,7 +19,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
19
19
 
20
20
 
21
21
 
22
-
22
+
23
23
 
24
24
 
25
25
 
@@ -94,14 +94,23 @@ export const complete = async ({ argv, extensionId, id, offset, rootUri, textDoc
94
94
  return connection.complete(normalizedDocument, offset)
95
95
  }
96
96
 
97
- export const codeAction = async ({ argv, extensionId, id, offset, rootUri, textDocument, uri } ) => {
97
+ export const codeAction = async ({
98
+ argv,
99
+ extensionId,
100
+ id,
101
+ offset,
102
+ only,
103
+ rootUri,
104
+ textDocument,
105
+ uri,
106
+ } ) => {
98
107
  const normalizedDocument = {
99
108
  ...textDocument,
100
109
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
101
110
  }
102
111
  const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
103
112
  const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
104
- return connection.codeAction(normalizedDocument, offset)
113
+ return connection.codeAction(normalizedDocument, offset, only)
105
114
  }
106
115
 
107
116
  export const diagnostic = async ({ argv, extensionId, id, rootUri, textDocument, uri } ) => {
@@ -154,6 +163,26 @@ export const references = async ({ argv, extensionId, id, offset, rootUri, textD
154
163
  return connection.references(normalizedDocument, offset)
155
164
  }
156
165
 
166
+ export const feature = async ({
167
+ argv,
168
+ extensionId,
169
+ id,
170
+ method,
171
+ newName,
172
+ offset,
173
+ rootUri,
174
+ textDocument,
175
+ uri,
176
+ }
177
+
178
+
179
+ ) => {
180
+ const normalizedDocument = { ...textDocument, uri: normalizeLanguageServerDocumentUri(textDocument.uri) }
181
+ const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
182
+ const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
183
+ return connection.feature(normalizedDocument, method, offset, newName)
184
+ }
185
+
157
186
  export const dispose = (extensionId) => {
158
187
  for (const [id, state] of connections) {
159
188
  if (state.extensionId === extensionId) {
@@ -3,6 +3,7 @@ import { basename, extname } from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
4
  import { LanguageServerMessageParser } from '../LanguageServerMessageParser/LanguageServerMessageParser.js'
5
5
  import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDocumentUri/NormalizeLanguageServerDocumentUri.js'
6
+ import { typeScriptLanguageServerPath } from '../TypeScriptLanguageServerPath/TypeScriptLanguageServerPath.js'
6
7
 
7
8
 
8
9
 
@@ -28,6 +29,11 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
28
29
 
29
30
 
30
31
 
32
+
33
+
34
+
35
+
36
+
31
37
 
32
38
 
33
39
 
@@ -63,7 +69,7 @@ export const getSpawnOptions = (
63
69
  uri,
64
70
  argv,
65
71
  ) => {
66
- const executablePath = fileURLToPath(uri)
72
+ const executablePath = uri === 'lvce-language-server:typescript' ? typeScriptLanguageServerPath : fileURLToPath(uri)
67
73
  const extension = extname(executablePath).toLowerCase()
68
74
  if (extension === '.js' || extension === '.mjs' || extension === '.cjs') {
69
75
  return {
@@ -168,6 +174,7 @@ export class LanguageServerConnection {
168
174
  nextRequestId = 1
169
175
  running = true
170
176
  stderr = ''
177
+ capabilities = {}
171
178
  supportsCodeActions = false
172
179
  supportsDocumentFormatting = false
173
180
  supportsDocumentSymbols = false
@@ -211,7 +218,7 @@ export class LanguageServerConnection {
211
218
  this.rejectPendingRequests(new Error('Language server was disposed'))
212
219
  }
213
220
 
214
- async codeAction(textDocument, offset) {
221
+ async codeAction(textDocument, offset, only) {
215
222
  await this.ready
216
223
  if (!this.supportsCodeActions) {
217
224
  return []
@@ -220,6 +227,7 @@ export class LanguageServerConnection {
220
227
  const position = getPosition(textDocument.text, offset)
221
228
  const result = await this.sendRequest('textDocument/codeAction', {
222
229
  context: {
230
+ ...(only && { only: [only] }),
223
231
  diagnostics: diagnostics.filter((diagnostic) => containsPosition(diagnostic, position)),
224
232
  },
225
233
  range: {
@@ -324,6 +332,37 @@ export class LanguageServerConnection {
324
332
  return Array.isArray(result) ? result : []
325
333
  }
326
334
 
335
+ async feature(textDocument, method, offset, newName) {
336
+ await this.ready
337
+ const capabilityByMethod = {
338
+ hover: 'hoverProvider',
339
+ implementation: 'implementationProvider',
340
+ prepareRename: 'renameProvider',
341
+ rename: 'renameProvider',
342
+ signatureHelp: 'signatureHelpProvider',
343
+ typeDefinition: 'typeDefinitionProvider',
344
+ }
345
+ const capability = capabilityByMethod[method]
346
+ if (!capability) {
347
+ throw new Error(`Unsupported language server feature: ${method}`)
348
+ }
349
+ if (!this.capabilities[capability]) {
350
+ return undefined
351
+ }
352
+ if (method === 'prepareRename') {
353
+ const provider = this.capabilities.renameProvider
354
+ if (!provider || typeof provider !== 'object' || !('prepareProvider' in provider) || !provider.prepareProvider) {
355
+ return undefined
356
+ }
357
+ }
358
+ this.syncDocument(textDocument)
359
+ return this.sendRequest(`textDocument/${method}`, {
360
+ ...(method === 'rename' && { newName }),
361
+ position: getPosition(textDocument.text, offset),
362
+ textDocument: { uri: textDocument.uri },
363
+ })
364
+ }
365
+
327
366
  async references(textDocument, offset) {
328
367
  await this.ready
329
368
  if (!this.supportsReferences) {
@@ -366,12 +405,15 @@ export class LanguageServerConnection {
366
405
  dynamicRegistration: false,
367
406
  hierarchicalDocumentSymbolSupport: true,
368
407
  },
408
+ hover: { contentFormat: ['markdown', 'plaintext'] },
369
409
  publishDiagnostics: {
370
410
  relatedInformation: true,
371
411
  },
372
412
  references: {
373
413
  dynamicRegistration: false,
374
414
  },
415
+ rename: { prepareSupport: true },
416
+ signatureHelp: { signatureInformation: { documentationFormat: ['plaintext'] } },
375
417
  synchronization: {
376
418
  didSave: true,
377
419
  dynamicRegistration: false,
@@ -397,6 +439,7 @@ export class LanguageServerConnection {
397
439
  },
398
440
  ],
399
441
  }))
442
+ this.capabilities = result?.capabilities || {}
400
443
  this.supportsCodeActions = Boolean(result?.capabilities?.codeActionProvider)
401
444
  this.supportsDocumentFormatting = Boolean(result?.capabilities?.documentFormattingProvider)
402
445
  this.supportsDocumentSymbols = Boolean(result?.capabilities?.documentSymbolProvider)
@@ -56,11 +56,11 @@ export const getSetupName = () => {
56
56
  return 'Lvce-Setup'
57
57
  }
58
58
 
59
- export const version = '0.125.7'
59
+ export const version = '0.125.9'
60
60
 
61
- export const commit = 'b2bafb8'
61
+ export const commit = '674cc9c'
62
62
 
63
- export const date = '2026-10-22T12:34:06.000Z'
63
+ export const date = '2026-10-22T15:08:35.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', 'b2bafb8', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', '674cc9c', 'packages', 'preload', 'dist', 'index.js')
6
6
  }
@@ -0,0 +1,10 @@
1
+ import { join } from 'node:path'
2
+ import * as Root from '../Root/Root.js'
3
+
4
+ export const typeScriptLanguageServerPath = join(
5
+ Root.root,
6
+ 'language-servers',
7
+ 'typescript',
8
+ 'lib',
9
+ process.platform === 'win32' ? 'tsc.exe' : 'tsc',
10
+ )