@lvce-editor/shared-process 0.95.1 → 0.95.2

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.
@@ -11,7 +11,7 @@
11
11
  "editor.fontLigatures": true,
12
12
  "editor.links": true,
13
13
  "editor.tabSize": 2,
14
- "editor.hover": false,
14
+ "editor.hover": true,
15
15
 
16
16
  "editor.autoClosingBrackets": true,
17
17
  "editor.autoClosingQuotes": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.95.1",
3
+ "version": "0.95.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "1.7.0",
21
21
  "@lvce-editor/auth-process": "1.12.0",
22
- "@lvce-editor/extension-host-helper-process": "0.95.1",
22
+ "@lvce-editor/extension-host-helper-process": "0.95.2",
23
23
  "@lvce-editor/ipc": "16.6.0",
24
24
  "@lvce-editor/json-rpc": "8.5.0",
25
25
  "@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', '2572a83', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', '0a72652', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -13,6 +13,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
13
13
 
14
14
 
15
15
 
16
+
16
17
 
17
18
 
18
19
 
@@ -20,6 +21,7 @@ import { normalizeLanguageServerDocumentUri } from '../NormalizeLanguageServerDo
20
21
 
21
22
 
22
23
 
24
+
23
25
 
24
26
 
25
27
 
@@ -61,23 +63,23 @@ const getConnection = (id, uri, argv, rootUri) => {
61
63
  return connection
62
64
  }
63
65
 
64
- export const complete = async ({ argv, id, offset, textDocument, uri } ) => {
66
+ export const complete = async ({ argv, id, offset, rootUri, textDocument, uri } ) => {
65
67
  const normalizedDocument = {
66
68
  ...textDocument,
67
69
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
68
70
  }
69
- const rootUri = getRootUri(normalizedDocument.uri)
70
- const connection = getConnection(`${id}:${rootUri}`, uri, argv, rootUri)
71
+ const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
72
+ const connection = getConnection(`${id}:${normalizedRootUri}`, uri, argv, normalizedRootUri)
71
73
  return connection.complete(normalizedDocument, offset)
72
74
  }
73
75
 
74
- export const diagnostic = async ({ argv, id, textDocument, uri } ) => {
76
+ export const diagnostic = async ({ argv, id, rootUri, textDocument, uri } ) => {
75
77
  const normalizedDocument = {
76
78
  ...textDocument,
77
79
  uri: normalizeLanguageServerDocumentUri(textDocument.uri),
78
80
  }
79
- const rootUri = getRootUri(normalizedDocument.uri)
80
- const connection = getConnection(`${id}:${rootUri}`, uri, argv, rootUri)
81
+ const normalizedRootUri = rootUri ? normalizeLanguageServerDocumentUri(rootUri) : getRootUri(normalizedDocument.uri)
82
+ const connection = getConnection(`${id}:${normalizedRootUri}`, uri, argv, normalizedRootUri)
81
83
  return connection.diagnostic(normalizedDocument)
82
84
  }
83
85
 
@@ -23,6 +23,22 @@ import {
23
23
 
24
24
 
25
25
 
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
26
42
 
27
43
 
28
44
 
@@ -74,17 +90,38 @@ const getWorkspaceName = (rootUri) => {
74
90
  }
75
91
  }
76
92
 
93
+ const createDeferred = () => {
94
+ let resolve = () => {}
95
+ const promise = new Promise ((resolvePromise) => {
96
+ resolve = resolvePromise
97
+ })
98
+ return { promise, resolve }
99
+ }
100
+
101
+ const wait = (duration) => {
102
+ return new Promise((resolve) => {
103
+ setTimeout(resolve, duration)
104
+ })
105
+ }
106
+
77
107
  export class LanguageServerConnection {
78
108
  child
109
+ configurationHandled = createDeferred()
110
+ diagnosticWaiters = new Map ()
79
111
  documents = new Map ()
112
+ initializationProgressEnded = createDeferred()
113
+ initializationProgressStarted = createDeferred()
80
114
  parser = new LanguageServerMessageParser()
81
115
  pendingRequests = new Map ()
116
+ publishedDiagnostics = new Map ()
82
117
  ready
83
118
  rootUri
119
+ initializationProgressWasStarted = false
84
120
  markdownConfigured = false
85
121
  nextRequestId = 1
86
122
  running = true
87
123
  stderr = ''
124
+ supportsPullDiagnostics = false
88
125
 
89
126
  constructor({ argv, rootUri, uri } ) {
90
127
  this.rootUri = rootUri
@@ -147,16 +184,29 @@ export class LanguageServerConnection {
147
184
  async diagnostic(textDocument) {
148
185
  await this.ready
149
186
  this.configureMarkdown(textDocument.languageId)
150
- this.syncDocument(textDocument)
151
- const result = await this.sendRequest('textDocument/diagnostic', {
152
- textDocument: {
153
- uri: textDocument.uri,
154
- },
155
- })
156
- if (result && typeof result === 'object' && Array.isArray((result).items)) {
157
- return (result).items
187
+ if (this.supportsPullDiagnostics) {
188
+ this.syncDocument(textDocument)
189
+ const result = await this.sendRequest('textDocument/diagnostic', {
190
+ textDocument: {
191
+ uri: textDocument.uri,
192
+ },
193
+ })
194
+ if (result && typeof result === 'object' && Array.isArray((result).items)) {
195
+ return (result).items
196
+ }
197
+ return []
158
198
  }
159
- return []
199
+ const previous = this.documents.get(textDocument.uri)
200
+ const documentChanged = !previous || previous.languageId !== textDocument.languageId || previous.text !== textDocument.text
201
+ const cached = this.publishedDiagnostics.get(textDocument.uri)
202
+ if (!documentChanged && cached) {
203
+ return cached
204
+ }
205
+ const diagnostics = this.waitForPublishedDiagnostics(textDocument.uri)
206
+ if (documentChanged) {
207
+ this.syncDocument(textDocument)
208
+ }
209
+ return diagnostics
160
210
  }
161
211
 
162
212
  configureMarkdown(languageId) {
@@ -206,7 +256,7 @@ export class LanguageServerConnection {
206
256
  }
207
257
 
208
258
  async initialize() {
209
- await this.sendRequest('initialize', {
259
+ const result = (await this.sendRequest('initialize', {
210
260
  capabilities: {
211
261
  textDocument: {
212
262
  completion: {
@@ -218,11 +268,17 @@ export class LanguageServerConnection {
218
268
  dynamicRegistration: false,
219
269
  relatedDocumentSupport: false,
220
270
  },
271
+ publishDiagnostics: {
272
+ relatedInformation: true,
273
+ },
221
274
  synchronization: {
222
275
  didSave: true,
223
276
  dynamicRegistration: false,
224
277
  },
225
278
  },
279
+ window: {
280
+ workDoneProgress: true,
281
+ },
226
282
  workspace: {
227
283
  configuration: true,
228
284
  workspaceFolders: true,
@@ -239,8 +295,15 @@ export class LanguageServerConnection {
239
295
  uri: this.rootUri,
240
296
  },
241
297
  ],
242
- })
298
+ }))
299
+ this.supportsPullDiagnostics = Boolean(result?.capabilities?.diagnosticProvider)
243
300
  this.sendNotification('initialized', {})
301
+ await Promise.race([this.initializationProgressStarted.promise, wait(100)])
302
+ if (this.initializationProgressWasStarted) {
303
+ await Promise.race([this.initializationProgressEnded.promise, wait(30_000)])
304
+ }
305
+ await Promise.race([this.configurationHandled.promise, wait(100)])
306
+ await wait(0)
244
307
  }
245
308
 
246
309
  syncDocument(textDocument) {
@@ -303,6 +366,14 @@ export class LanguageServerConnection {
303
366
  }
304
367
 
305
368
  handleMessage(message) {
369
+ if (message.method === 'textDocument/publishDiagnostics') {
370
+ this.handlePublishedDiagnostics(message.params)
371
+ return
372
+ }
373
+ if (message.method === '$/progress') {
374
+ this.handleProgress(message.params)
375
+ return
376
+ }
306
377
  if (message.method && message.id !== undefined && message.id !== null) {
307
378
  void this.handleServerRequest(message)
308
379
  return
@@ -322,12 +393,45 @@ export class LanguageServerConnection {
322
393
  pending.resolve(message.result)
323
394
  }
324
395
 
396
+ handlePublishedDiagnostics(params) {
397
+ if (!params || typeof params !== 'object') {
398
+ return
399
+ }
400
+ const { diagnostics, uri } = params
401
+ if (typeof uri !== 'string' || !Array.isArray(diagnostics)) {
402
+ return
403
+ }
404
+ this.publishedDiagnostics.set(uri, diagnostics)
405
+ const waiters = this.diagnosticWaiters.get(uri)
406
+ if (!waiters) {
407
+ return
408
+ }
409
+ this.diagnosticWaiters.delete(uri)
410
+ for (const waiter of waiters) {
411
+ waiter.resolve(diagnostics)
412
+ }
413
+ }
414
+
415
+ handleProgress(params) {
416
+ if (!params || typeof params !== 'object') {
417
+ return
418
+ }
419
+ const { value } = params
420
+ if (!value || typeof value !== 'object' || (value).kind !== 'end') {
421
+ return
422
+ }
423
+ this.initializationProgressEnded.resolve()
424
+ }
425
+
325
426
  async handleServerRequest(message) {
326
427
  try {
327
428
  let result = null
328
429
  if (message.method === 'workspace/configuration') {
329
430
  const itemCount = Array.isArray(message.params?.items) ? message.params.items.length : 0
330
431
  result = Array.from({ length: itemCount }).fill(null)
432
+ } else if (message.method === 'window/workDoneProgress/create') {
433
+ this.initializationProgressWasStarted = true
434
+ this.initializationProgressStarted.resolve()
331
435
  } else if (message.method === 'workspace/workspaceFolders') {
332
436
  result = [
333
437
  {
@@ -346,6 +450,9 @@ export class LanguageServerConnection {
346
450
  jsonrpc: '2.0',
347
451
  result,
348
452
  })
453
+ if (message.method === 'workspace/configuration') {
454
+ this.configurationHandled.resolve()
455
+ }
349
456
  } catch (error) {
350
457
  this.sendMessage({
351
458
  error: {
@@ -371,6 +478,12 @@ export class LanguageServerConnection {
371
478
  pending.reject(error)
372
479
  }
373
480
  this.pendingRequests.clear()
481
+ for (const waiters of this.diagnosticWaiters.values()) {
482
+ for (const waiter of waiters) {
483
+ waiter.reject(error)
484
+ }
485
+ }
486
+ this.diagnosticWaiters.clear()
374
487
  }
375
488
 
376
489
  sendNotification(method, params) {
@@ -398,6 +511,14 @@ export class LanguageServerConnection {
398
511
  return promise
399
512
  }
400
513
 
514
+ waitForPublishedDiagnostics(uri) {
515
+ return new Promise ((resolve, reject) => {
516
+ const waiters = this.diagnosticWaiters.get(uri) || new Set()
517
+ waiters.add({ reject, resolve })
518
+ this.diagnosticWaiters.set(uri, waiters)
519
+ })
520
+ }
521
+
401
522
  sendMessage(message) {
402
523
  const content = JSON.stringify(message)
403
524
  const header = `Content-Length: ${Buffer.byteLength(content)}\r\n\r\n`
@@ -61,11 +61,11 @@ export const getSetupName = () => {
61
61
  return 'Lvce-Setup'
62
62
  }
63
63
 
64
- export const version = '0.95.1'
64
+ export const version = '0.95.2'
65
65
 
66
- export const commit = '2572a83'
66
+ export const commit = '0a72652'
67
67
 
68
- export const date = '2026-07-29T14:03:33.000Z'
68
+ export const date = '2026-07-29T18:04:24.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', '2572a83', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', '0a72652', 'packages', 'preload', 'dist', 'index.js')
6
6
  }