@lvce-editor/shared-process 0.89.3 → 0.90.1

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.
@@ -35,12 +35,10 @@
35
35
 
36
36
  "sessionReplay.enabled": false,
37
37
 
38
- "serviceWorker.enabled": false,
39
-
40
38
  "simpleBrowser.suggestions": false,
41
39
 
42
40
  "terminal.backend": "real",
43
- "terminal.renderer": "termterm",
41
+ "terminal.renderer": "xterm",
44
42
  "terminal.separateConnection": false,
45
43
 
46
44
  "window.titleBarStyle": "custom",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.89.3",
3
+ "version": "0.90.1",
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.9.0",
22
- "@lvce-editor/extension-host-helper-process": "0.89.3",
22
+ "@lvce-editor/extension-host-helper-process": "0.90.1",
23
23
  "@lvce-editor/ipc": "16.3.0",
24
24
  "@lvce-editor/json-rpc": "8.2.0",
25
25
  "@lvce-editor/jsonc-parser": "1.5.0",
@@ -28,6 +28,7 @@
28
28
  "@lvce-editor/rpc-registry": "9.35.0",
29
29
  "@lvce-editor/verror": "1.7.0",
30
30
  "is-object": "^1.0.2",
31
+ "markdown-it": "^14.3.0",
31
32
  "xdg-basedir": "^5.1.0"
32
33
  },
33
34
  "optionalDependencies": {
@@ -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', 'f1db6cb', 'extensions')
6
+ const builtinExtensionsPath = join(staticServerPath, '..', '..', 'static', 'd347596', 'extensions')
7
7
  return builtinExtensionsPath
8
8
  }
@@ -2,6 +2,10 @@ import { spawn, } from 'node:child_process'
2
2
  import { basename } from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
4
  import { LanguageServerMessageParser } from '../LanguageServerMessageParser/LanguageServerMessageParser.js'
5
+ import {
6
+ executeMarkdownLanguageServerRequest,
7
+ isMarkdownLanguageServerRequest,
8
+ } from '../MarkdownLanguageServerRequest/MarkdownLanguageServerRequest.js'
5
9
 
6
10
 
7
11
 
@@ -62,6 +66,7 @@ export class LanguageServerConnection {
62
66
  pendingRequests = new Map ()
63
67
  ready
64
68
  rootUri
69
+ markdownConfigured = false
65
70
  nextRequestId = 1
66
71
  running = true
67
72
  stderr = ''
@@ -103,6 +108,7 @@ export class LanguageServerConnection {
103
108
 
104
109
  async complete(textDocument, offset) {
105
110
  await this.ready
111
+ this.configureMarkdown(textDocument.languageId)
106
112
  this.syncDocument(textDocument)
107
113
  const result = await this.sendRequest('textDocument/completion', {
108
114
  context: {
@@ -122,6 +128,35 @@ export class LanguageServerConnection {
122
128
  return []
123
129
  }
124
130
 
131
+ configureMarkdown(languageId) {
132
+ if (languageId !== 'markdown' || this.markdownConfigured) {
133
+ return
134
+ }
135
+ this.markdownConfigured = true
136
+ this.sendNotification('workspace/didChangeConfiguration', {
137
+ settings: {
138
+ markdown: {
139
+ occurrencesHighlight: {
140
+ enabled: true,
141
+ },
142
+ preferredMdPathExtensionStyle: 'auto',
143
+ server: {
144
+ log: 'off',
145
+ },
146
+ suggest: {
147
+ paths: {
148
+ enabled: true,
149
+ includeWorkspaceHeaderCompletions: 'never',
150
+ },
151
+ },
152
+ validate: {
153
+ enabled: false,
154
+ },
155
+ },
156
+ },
157
+ })
158
+ }
159
+
125
160
  async initialize() {
126
161
  await this.sendRequest('initialize', {
127
162
  capabilities: {
@@ -217,7 +252,7 @@ export class LanguageServerConnection {
217
252
 
218
253
  handleMessage(message) {
219
254
  if (message.method && message.id !== undefined && message.id !== null) {
220
- this.handleServerRequest(message)
255
+ void this.handleServerRequest(message)
221
256
  return
222
257
  }
223
258
  if (message.id === undefined || message.id === null) {
@@ -235,24 +270,40 @@ export class LanguageServerConnection {
235
270
  pending.resolve(message.result)
236
271
  }
237
272
 
238
- handleServerRequest(message) {
239
- let result = null
240
- if (message.method === 'workspace/configuration') {
241
- const itemCount = Array.isArray(message.params?.items) ? message.params.items.length : 0
242
- result = Array.from({ length: itemCount }).fill(null)
243
- } else if (message.method === 'workspace/workspaceFolders') {
244
- result = [
245
- {
246
- name: getWorkspaceName(this.rootUri),
247
- uri: this.rootUri,
273
+ async handleServerRequest(message) {
274
+ try {
275
+ let result = null
276
+ if (message.method === 'workspace/configuration') {
277
+ const itemCount = Array.isArray(message.params?.items) ? message.params.items.length : 0
278
+ result = Array.from({ length: itemCount }).fill(null)
279
+ } else if (message.method === 'workspace/workspaceFolders') {
280
+ result = [
281
+ {
282
+ name: getWorkspaceName(this.rootUri),
283
+ uri: this.rootUri,
284
+ },
285
+ ]
286
+ } else if (isMarkdownLanguageServerRequest(message.method || '')) {
287
+ result = await executeMarkdownLanguageServerRequest(message.method || '', message.params || {}, {
288
+ documents: this.documents,
289
+ rootUri: this.rootUri,
290
+ })
291
+ }
292
+ this.sendMessage({
293
+ id: message.id,
294
+ jsonrpc: '2.0',
295
+ result,
296
+ })
297
+ } catch (error) {
298
+ this.sendMessage({
299
+ error: {
300
+ code: -32_603,
301
+ message: error instanceof Error ? error.message : String(error),
248
302
  },
249
- ]
303
+ id: message.id,
304
+ jsonrpc: '2.0',
305
+ })
250
306
  }
251
- this.sendMessage({
252
- id: message.id,
253
- jsonrpc: '2.0',
254
- result,
255
- })
256
307
  }
257
308
 
258
309
  handleExit(error) {
@@ -0,0 +1,116 @@
1
+ import MarkdownIt from 'markdown-it'
2
+ import { readFile, readdir, stat } from 'node:fs/promises'
3
+ import { isAbsolute, relative, resolve, sep } from 'node:path'
4
+ import { fileURLToPath, pathToFileURL } from 'node:url'
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ const markdownFileExtensions = new Set(['.markdown', '.md', '.mdown', '.mdtext', '.mdtxt', '.mdwn', '.mkd', '.mkdn'])
21
+ const ignoredDirectories = new Set(['.git', 'node_modules'])
22
+ const markdownIt = new MarkdownIt({ html: true })
23
+
24
+ export const isMarkdownLanguageServerRequest = (method) => {
25
+ return (
26
+ method === 'markdown/parse' ||
27
+ method === 'markdown/fs/readFile' ||
28
+ method === 'markdown/fs/readDirectory' ||
29
+ method === 'markdown/fs/stat' ||
30
+ method === 'markdown/findMarkdownFilesInWorkspace'
31
+ )
32
+ }
33
+
34
+ const getWorkspacePath = (uri, rootUri) => {
35
+ const rootPath = resolve(fileURLToPath(rootUri))
36
+ const targetPath = resolve(fileURLToPath(uri))
37
+ const relativePath = relative(rootPath, targetPath)
38
+ if (relativePath === '..' || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath)) {
39
+ throw new Error(`Language server file request is outside the workspace`)
40
+ }
41
+ return targetPath
42
+ }
43
+
44
+ const getMarkdownText = async (params, context) => {
45
+ if (typeof params.text === 'string') {
46
+ return params.text
47
+ }
48
+ if (!params.uri) {
49
+ throw new Error(`Markdown parse request is missing a uri`)
50
+ }
51
+ const document = context.documents.get(params.uri)
52
+ if (document) {
53
+ return document.text
54
+ }
55
+ const path = getWorkspacePath(params.uri, context.rootUri)
56
+ return readFile(path, 'utf8')
57
+ }
58
+
59
+ const findMarkdownFiles = async (rootPath) => {
60
+ const result = []
61
+ const visit = async (directory) => {
62
+ const entries = await readdir(directory, { withFileTypes: true })
63
+ await Promise.all(
64
+ entries.map(async (entry) => {
65
+ const path = resolve(directory, entry.name)
66
+ if (entry.isDirectory()) {
67
+ if (ignoredDirectories.has(entry.name)) {
68
+ return
69
+ }
70
+ await visit(path)
71
+ return
72
+ }
73
+ const extensionIndex = entry.name.lastIndexOf('.')
74
+ const extension = extensionIndex === -1 ? '' : entry.name.slice(extensionIndex).toLowerCase()
75
+ if (markdownFileExtensions.has(extension)) {
76
+ result.push(pathToFileURL(path).href)
77
+ }
78
+ }),
79
+ )
80
+ }
81
+ await visit(rootPath)
82
+ return result.sort()
83
+ }
84
+
85
+ export const executeMarkdownLanguageServerRequest = async (
86
+ method,
87
+ params,
88
+ context,
89
+ ) => {
90
+ if (method === 'markdown/parse') {
91
+ return markdownIt.parse(await getMarkdownText(params, context), {})
92
+ }
93
+ if (method === 'markdown/findMarkdownFilesInWorkspace') {
94
+ return findMarkdownFiles(getWorkspacePath(context.rootUri, context.rootUri))
95
+ }
96
+ if (!params.uri) {
97
+ throw new Error(`Markdown file request is missing a uri`)
98
+ }
99
+ const path = getWorkspacePath(params.uri, context.rootUri)
100
+ if (method === 'markdown/fs/readFile') {
101
+ return [...(await readFile(path))]
102
+ }
103
+ if (method === 'markdown/fs/readDirectory') {
104
+ const entries = await readdir(path, { withFileTypes: true })
105
+ return entries.map((entry) => [entry.name, { isDirectory: entry.isDirectory() }])
106
+ }
107
+ if (method === 'markdown/fs/stat') {
108
+ try {
109
+ const fileStat = await stat(path)
110
+ return { isDirectory: fileStat.isDirectory() }
111
+ } catch {
112
+ return undefined
113
+ }
114
+ }
115
+ throw new Error(`Unsupported Markdown language server request: ${method}`)
116
+ }
@@ -61,11 +61,11 @@ export const getSetupName = () => {
61
61
  return 'Lvce-Setup'
62
62
  }
63
63
 
64
- export const version = '0.89.3'
64
+ export const version = '0.90.1'
65
65
 
66
- export const commit = 'f1db6cb'
66
+ export const commit = 'd347596'
67
67
 
68
- export const date = '2026-07-14T11:58:48.000Z'
68
+ export const date = '2026-07-14T15:50:53.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', 'f1db6cb', 'packages', 'preload', 'dist', 'index.js')
5
+ return join(Root.root, 'static', 'd347596', 'packages', 'preload', 'dist', 'index.js')
6
6
  }