@lvce-editor/shared-process 0.11.9 → 0.11.10

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.
Files changed (42) hide show
  1. package/config/defaultKeyBindings.json +25 -0
  2. package/config/defaultSettings.json +2 -7
  3. package/extensions/builtin.language-basics-coffeescript/src/tokenizeCoffeeScript.js +232 -3
  4. package/extensions/builtin.language-basics-cpp/src/tokenizeCpp.js +14 -0
  5. package/extensions/builtin.language-basics-css/src/tokenizeCss.js +8 -0
  6. package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +52 -4
  7. package/extensions/builtin.language-basics-python/src/tokenizePython.js +1 -1
  8. package/extensions/builtin.language-basics-ruby/README.md +14 -0
  9. package/extensions/builtin.language-basics-ruby/extension.json +48 -0
  10. package/extensions/builtin.language-basics-ruby/src/tokenizeRuby.js +241 -0
  11. package/extensions/builtin.language-basics-scss/README.md +14 -0
  12. package/extensions/builtin.language-basics-scss/extension.json +12 -0
  13. package/extensions/builtin.language-basics-scss/src/tokenizeScss.js +28 -0
  14. package/extensions/builtin.language-basics-shellscript/extension.json +2 -1
  15. package/extensions/builtin.language-basics-shellscript/src/tokenizeShellScript.js +75 -23
  16. package/extensions/builtin.language-basics-toml/src/tokenizeToml.js +87 -13
  17. package/extensions/builtin.language-basics-xml/extension.json +2 -1
  18. package/extensions/builtin.language-basics-xml/src/tokenizeXml.js +7 -0
  19. package/extensions/builtin.language-basics-yaml/src/tokenizeYaml.js +8 -1
  20. package/extensions/builtin.theme-cobalt2/color-theme.json +4 -0
  21. package/extensions/builtin.theme-gruvbox/color-theme.json +4 -0
  22. package/extensions/builtin.theme-palenight/color-theme.json +4 -0
  23. package/extensions/builtin.theme-slime/color-theme.json +9 -1
  24. package/package.json +5 -5
  25. package/src/parts/Cli/Cli.js +2 -2
  26. package/src/parts/CliInstall/CliInstall.js +21 -6
  27. package/src/parts/CliList/CliList.js +3 -2
  28. package/src/parts/CliUnlink/CliUnlink.js +1 -1
  29. package/src/parts/DownloadAndExtract/DownloadAndExtract.js +18 -8
  30. package/src/parts/ErrorHandling/ErrorHandling.js +4 -9
  31. package/src/parts/ExportStatic/ExportStatic.js +57 -330
  32. package/src/parts/ExtensionHost/ExtensionHost.js +4 -7
  33. package/src/parts/ExtensionInstallFromGitHub/ExtensionInstallFromGitHub.js +1 -4
  34. package/src/parts/ExtensionManagement/ExtensionManagementColorTheme.js +3 -4
  35. package/src/parts/FileSystem/FileSystem.js +5 -15
  36. package/src/parts/GetResponse/GetResponse.js +10 -14
  37. package/src/parts/JsonRpc/JsonRpc.js +3 -6
  38. package/src/parts/JsonRpcErrorCode/JsonRpcErrorCode.js +2 -0
  39. package/src/parts/JsonRpcVersion/JsonRpcVersion.js +1 -0
  40. package/src/parts/OutputChannel/OutputChannel.ipc.js +3 -2
  41. package/src/parts/Terminal/Terminal.js +5 -4
  42. package/src/sharedProcessMain.js +2 -5
@@ -18,16 +18,8 @@ export const copy = async (source, target) => {
18
18
  try {
19
19
  await fs.cp(source, target, { recursive: true })
20
20
  } catch (error) {
21
- if (
22
- error &&
23
- error.message &&
24
- error.message.startsWith(
25
- 'Invalid src or dest: cp returned EINVAL (src and dest cannot be the same)'
26
- )
27
- ) {
28
- throw new VError(
29
- `Failed to copy "${source}" to "${target}": src and dest cannot be the same`
30
- )
21
+ if (error && error.message && error.message.startsWith('Invalid src or dest: cp returned EINVAL (src and dest cannot be the same)')) {
22
+ throw new VError(`Failed to copy "${source}" to "${target}": src and dest cannot be the same`)
31
23
  }
32
24
  throw new VError(error, `Failed to copy "${source}" to "${target}"`)
33
25
  }
@@ -65,11 +57,7 @@ export const readFile = async (path, encoding = EncodingType.Utf8) => {
65
57
  * @param {string} content
66
58
  * @param {BufferEncoding} encoding
67
59
  */
68
- export const writeFile = async (
69
- path,
70
- content,
71
- encoding = EncodingType.Utf8
72
- ) => {
60
+ export const writeFile = async (path, content, encoding = EncodingType.Utf8) => {
73
61
  try {
74
62
  // queue would be more correct for concurrent writes but also slower
75
63
  // Queue.add(`writeFile/${path}`, () =>
@@ -166,6 +154,7 @@ const getType = (dirent) => {
166
154
  if (dirent.isCharacterDevice()) {
167
155
  return DirentType.CharacterDevice
168
156
  }
157
+ console.log({ dirent })
169
158
  return DirentType.Unknown
170
159
  }
171
160
 
@@ -182,6 +171,7 @@ const toPrettyDirent = (dirent) => {
182
171
  export const readDirWithFileTypes = async (path) => {
183
172
  try {
184
173
  const dirents = await fs.readdir(path, { withFileTypes: true })
174
+ console.log({ dirents: dirents.filter((x) => getType(x) === DirentType.Unknown) })
185
175
  const prettyDirents = dirents.map(toPrettyDirent)
186
176
  return prettyDirents
187
177
  } catch (error) {
@@ -1,6 +1,7 @@
1
1
  import * as Command from '../Command/Command.js'
2
2
  import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
3
- import * as JsonRpc from '../JsonRpc/JsonRpc.js'
3
+ import * as JsonRpcErrorCode from '../JsonRpcErrorCode/JsonRpcErrorCode.js'
4
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js'
4
5
  import * as PrettyError from '../PrettyError/PrettyError.js'
5
6
  import { requiresSocket } from '../RequiresSocket/RequiresSocket.js'
6
7
 
@@ -11,22 +12,17 @@ export const getResponse = async (message, handle) => {
11
12
  : await Command.execute(message.method, ...message.params)
12
13
 
13
14
  return {
14
- jsonrpc: JsonRpc.Version,
15
+ jsonrpc: JsonRpcVersion.Two,
15
16
  id: message.id,
16
17
  result: result ?? null,
17
18
  }
18
19
  } catch (error) {
19
- if (
20
- error &&
21
- error instanceof Error &&
22
- error.message &&
23
- error.message.startsWith('method not found')
24
- ) {
20
+ if (error && error instanceof Error && error.message && error.message.startsWith('method not found')) {
25
21
  return {
26
- jsonrpc: JsonRpc.Version,
22
+ jsonrpc: JsonRpcVersion.Two,
27
23
  id: message.id,
28
24
  error: {
29
- code: JsonRpc.ErrorMethodNotFound,
25
+ code: JsonRpcErrorCode.MethodNotFound,
30
26
  message: error.message,
31
27
  data: error.stack,
32
28
  },
@@ -35,10 +31,10 @@ export const getResponse = async (message, handle) => {
35
31
  // @ts-ignore
36
32
  if (error && error instanceof Error && error.code === ErrorCodes.ENOENT) {
37
33
  return {
38
- jsonrpc: JsonRpc.Version,
34
+ jsonrpc: JsonRpcVersion.Two,
39
35
  id: message.id,
40
36
  error: {
41
- code: -32001,
37
+ code: JsonRpcErrorCode.Custom,
42
38
  message: `${error}`,
43
39
  },
44
40
  }
@@ -46,10 +42,10 @@ export const getResponse = async (message, handle) => {
46
42
  const prettyError = PrettyError.prepare(error)
47
43
  PrettyError.print(prettyError, `[shared-process] `)
48
44
  return {
49
- jsonrpc: JsonRpc.Version,
45
+ jsonrpc: JsonRpcVersion.Two,
50
46
  id: message.id,
51
47
  error: {
52
- code: -32001,
48
+ code: JsonRpcErrorCode.Custom,
53
49
  message: prettyError.message,
54
50
  data: {
55
51
  stack: prettyError.stack,
@@ -1,12 +1,9 @@
1
1
  import * as Callback from '../Callback/Callback.js'
2
-
3
- export const Version = '2.0'
4
-
5
- export const ErrorMethodNotFound = -32601
2
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js'
6
3
 
7
4
  export const send = (transport, method, ...params) => {
8
5
  transport.send({
9
- jsonrpc: '2.0',
6
+ jsonrpc: JsonRpcVersion.Two,
10
7
  method,
11
8
  params,
12
9
  })
@@ -17,7 +14,7 @@ export const invoke = (ipc, method, ...params) => {
17
14
  // TODO use one map instead of two
18
15
  const callbackId = Callback.register(resolve, reject)
19
16
  ipc.send({
20
- jsonrpc: '2.0',
17
+ jsonrpc: JsonRpcVersion.Two,
21
18
  method,
22
19
  params,
23
20
  id: callbackId,
@@ -0,0 +1,2 @@
1
+ export const MethodNotFound = -32601
2
+ export const Custom = -32001
@@ -0,0 +1 @@
1
+ export const Two = '2.0'
@@ -1,6 +1,7 @@
1
1
  import * as Assert from '../Assert/Assert.js'
2
2
  import * as Command from '../Command/Command.js'
3
3
  import * as OutputChannel from './OutputChannel.js'
4
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js'
4
5
 
5
6
  export const state = {
6
7
  outputChannels: Object.create(null),
@@ -21,7 +22,7 @@ const open = (socket, id, path) => {
21
22
  const onData = (data) => {
22
23
  console.log('send data', data)
23
24
  socket.send({
24
- jsonrpc: '2.0',
25
+ jsonrpc: JsonRpcVersion.Two,
25
26
  method: 2133,
26
27
  params: ['Output', 'handleData', data],
27
28
  })
@@ -29,7 +30,7 @@ const open = (socket, id, path) => {
29
30
  const onError = (error) => {
30
31
  console.info(`[shared process] output channel error: ${error}`)
31
32
  socket.send({
32
- jsonrpc: '2.0',
33
+ jsonrpc: JsonRpcVersion.Two,
33
34
  method: 2133,
34
35
  params: ['Output', 'handleError', error],
35
36
  })
@@ -3,6 +3,7 @@ import { ChildProcess, fork } from 'node:child_process'
3
3
  import * as Assert from '../Assert/Assert.js'
4
4
  import * as Debug from '../Debug/Debug.js'
5
5
  import * as PtyHostPath from '../PtyHostPath/PtyHostPath.js'
6
+ import * as JsonRpcVersion from '../JsonRpcVersion/JsonRpcVersion.js'
6
7
 
7
8
  export const state = {
8
9
  /**
@@ -75,7 +76,7 @@ export const create = async (socket, id, cwd) => {
75
76
  const handleMessage = (message) => {
76
77
  const data = message.params[1]
77
78
  socket.send({
78
- jsonrpc: '2.0',
79
+ jsonrpc: JsonRpcVersion.Two,
79
80
  method: 'Viewlet.send',
80
81
  params: ['Terminal', 'handleData', data],
81
82
  })
@@ -102,7 +103,7 @@ export const create = async (socket, id, cwd) => {
102
103
  break
103
104
  }
104
105
  state.send({
105
- jsonrpc: '2.0',
106
+ jsonrpc: JsonRpcVersion.Two,
106
107
  method: 'Terminal.create',
107
108
  params: [id, cwd],
108
109
  })
@@ -128,7 +129,7 @@ export const write = (id, data) => {
128
129
  return
129
130
  }
130
131
  state.send({
131
- jsonrpc: '2.0',
132
+ jsonrpc: JsonRpcVersion.Two,
132
133
  method: 'Terminal.write',
133
134
  params: [id, data],
134
135
  })
@@ -140,7 +141,7 @@ export const resize = (state, columns, rows) => {
140
141
 
141
142
  export const dispose = (id) => {
142
143
  state.send({
143
- jsonrpc: '2.0',
144
+ jsonrpc: JsonRpcVersion.Two,
144
145
  method: 'Terminal.dispose',
145
146
  params: [id],
146
147
  })
@@ -27,7 +27,7 @@ const main = async () => {
27
27
  const argv0 = argv[0]
28
28
  if (knownCliArgs.includes(argv0)) {
29
29
  const module = await import('./parts/Cli/Cli.js')
30
- await module.handleCliArgs(argv, console, process)
30
+ await module.handleCliArgs(argv)
31
31
  return
32
32
  }
33
33
 
@@ -36,10 +36,7 @@ const main = async () => {
36
36
  process.on('disconnect', handleDisconnect)
37
37
  process.on('SIGTERM', handleSigTerm)
38
38
 
39
- process.on(
40
- 'uncaughtExceptionMonitor',
41
- ErrorHandling.handleUncaughtExceptionMonitor
42
- )
39
+ process.on('uncaughtExceptionMonitor', ErrorHandling.handleUncaughtExceptionMonitor)
43
40
  ParentIpc.listen()
44
41
 
45
42
  // ExtensionHost.start() // TODO start on demand, e.g. not when extensions should be disabled