@lvce-editor/shared-process 0.100.13 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.100.13",
3
+ "version": "0.100.15",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,28 +18,28 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "1.9.0",
21
- "@lvce-editor/extension-host-helper-process": "0.100.13",
22
- "@lvce-editor/ipc": "16.10.0",
21
+ "@lvce-editor/extension-host-helper-process": "0.100.15",
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",
25
25
  "@lvce-editor/pretty-error": "2.0.0",
26
26
  "@lvce-editor/process-explorer": "3.14.0",
27
- "@lvce-editor/rpc-registry": "9.48.0",
27
+ "@lvce-editor/rpc-registry": "9.51.0",
28
28
  "@lvce-editor/verror": "1.7.0",
29
29
  "is-object": "^1.0.2",
30
30
  "markdown-it": "^15.0.0",
31
31
  "xdg-basedir": "^5.1.0"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@lvce-editor/embeds-process": "4.15.0",
34
+ "@lvce-editor/embeds-process": "4.16.0",
35
35
  "@lvce-editor/file-system-process": "5.14.0",
36
- "@lvce-editor/file-watcher-process": "4.12.0",
36
+ "@lvce-editor/file-watcher-process": "4.13.0",
37
37
  "@lvce-editor/network-process": "5.2.0",
38
38
  "@lvce-editor/preload": "1.5.0",
39
39
  "@lvce-editor/preview-process": "11.0.0",
40
40
  "@lvce-editor/pty-host": "8.7.0",
41
- "@lvce-editor/search-process": "15.7.0",
42
- "@lvce-editor/typescript-compile-process": "5.8.0",
41
+ "@lvce-editor/search-process": "15.8.0",
42
+ "@lvce-editor/typescript-compile-process": "5.9.0",
43
43
  "open": "^11.0.0",
44
44
  "tail": "^2.2.6",
45
45
  "tmp-promise": "^3.0.3",
@@ -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', '9713834', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'fe8b07e', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -3,8 +3,10 @@ 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,
10
+ dispose: LanguageServer.dispose,
9
11
  format: LanguageServer.format,
10
12
  }
@@ -11,6 +11,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
11
11
 
12
12
 
13
13
 
14
+
14
15
 
15
16
 
16
17
 
@@ -18,8 +19,11 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
18
19
 
19
20
 
20
21
 
22
+
23
+
21
24
 
22
25
 
26
+
23
27
 
24
28
 
25
29
 
@@ -30,6 +34,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
30
34
 
31
35
 
32
36
 
37
+
33
38
 
34
39
 
35
40
 
@@ -39,6 +44,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
39
44
 
40
45
 
41
46
 
47
+
42
48
 
43
49
 
44
50
 
@@ -58,9 +64,9 @@ const hasSameOptions = (state, uri, argv) => {
58
64
  return state.uri === uri && state.argv.length === argv.length && state.argv.every((argument, index) => argument === argv[index])
59
65
  }
60
66
 
61
- const getConnection = (id, uri, argv, rootUri) => {
67
+ const getConnection = (id, extensionId, uri, argv, rootUri) => {
62
68
  const existing = connections.get(id)
63
- if (existing && existing.connection.isRunning() && hasSameOptions(existing, uri, argv)) {
69
+ if (existing && existing.extensionId === extensionId && existing.connection.isRunning() && hasSameOptions(existing, uri, argv)) {
64
70
  return existing.connection
65
71
  }
66
72
  existing?.connection.dispose()
@@ -68,51 +74,71 @@ const getConnection = (id, uri, argv, rootUri) => {
68
74
  connections.set(id, {
69
75
  argv: [...argv],
70
76
  connection,
77
+ extensionId,
71
78
  uri,
72
79
  })
73
80
  return connection
74
81
  }
75
82
 
76
- export const complete = async ({ argv, id, offset, rootUri, textDocument, uri } ) => {
83
+ export const complete = async ({ argv, extensionId, id, offset, rootUri, textDocument, uri } ) => {
77
84
  const normalizedDocument = {
78
85
  ...textDocument,
79
86
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
80
87
  }
81
88
  const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
82
- const connection = getConnection(`${id}:${normalizedRootUri}`, uri, argv, normalizedRootUri)
89
+ const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
83
90
  return connection.complete(normalizedDocument, offset)
84
91
  }
85
92
 
86
- export const diagnostic = async ({ argv, id, rootUri, textDocument, uri } ) => {
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
+
103
+ export const diagnostic = async ({ argv, extensionId, id, rootUri, textDocument, uri } ) => {
87
104
  const normalizedDocument = {
88
105
  ...textDocument,
89
106
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
90
107
  }
91
108
  const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
92
- const connection = getConnection(`${id}:${normalizedRootUri}`, uri, argv, normalizedRootUri)
109
+ const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
93
110
  return connection.diagnostic(normalizedDocument)
94
111
  }
95
112
 
96
- export const definition = async ({ argv, id, offset, rootUri, textDocument, uri } ) => {
113
+ export const definition = async ({ argv, extensionId, id, offset, rootUri, textDocument, uri } ) => {
97
114
  const normalizedDocument = {
98
115
  ...textDocument,
99
116
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
100
117
  }
101
118
  const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
102
- const connection = getConnection(`${id}:${normalizedRootUri}`, uri, argv, normalizedRootUri)
119
+ const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
103
120
  return connection.definition(normalizedDocument, offset)
104
121
  }
105
122
 
106
- export const format = async ({ argv, id, rootUri, textDocument, uri } ) => {
123
+ export const format = async ({ argv, extensionId, id, rootUri, textDocument, uri } ) => {
107
124
  const normalizedDocument = {
108
125
  ...textDocument,
109
126
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
110
127
  }
111
128
  const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
112
- const connection = getConnection(`${id}:${normalizedRootUri}`, uri, argv, normalizedRootUri)
129
+ const connection = getConnection(`${id}:${normalizedRootUri}`, extensionId, uri, argv, normalizedRootUri)
113
130
  return connection.format(normalizedDocument)
114
131
  }
115
132
 
133
+ export const dispose = (extensionId) => {
134
+ for (const [id, state] of connections) {
135
+ if (state.extensionId === extensionId) {
136
+ state.connection.dispose()
137
+ connections.delete(id)
138
+ }
139
+ }
140
+ }
141
+
116
142
  export const disposeAll = () => {
117
143
  for (const state of connections.values()) {
118
144
  state.connection.dispose()
@@ -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,9 +211,11 @@ 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':
218
+ case 'LanguageServer.dispose':
217
219
  case 'LanguageServer.format':
218
220
  return ModuleId.LanguageServer
219
221
  case 'ListProcessesWithMemoryUsage.listProcessesWithMemoryUsage':
@@ -61,11 +61,11 @@ export const getSetupName = () => {
61
61
  return 'Lvce-Setup'
62
62
  }
63
63
 
64
- export const version = '0.100.13'
64
+ export const version = '0.100.15'
65
65
 
66
- export const commit = '9713834'
66
+ export const commit = 'fe8b07e'
67
67
 
68
- export const date = '2026-08-11T00:17:11.000Z'
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', '9713834', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', 'fe8b07e', 'packages', 'preload', 'dist', 'index.js')
6
6
  }