@lvce-editor/shared-process 0.15.15 → 0.15.17

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 (49) hide show
  1. package/config/builtinCommands.json +4 -0
  2. package/config/defaultSettings.json +2 -0
  3. package/extensions/builtin.language-basics-python/extension.json +1 -1
  4. package/extensions/builtin.language-basics-xml/extension.json +2 -1
  5. package/extensions/builtin.language-basics-xml/src/tokenizeXml.js +1 -1
  6. package/extensions/builtin.theme-atom-one-dark/color-theme.json +4 -0
  7. package/package.json +4 -4
  8. package/src/parts/ChildProcessError/ChildProcessError.js +4 -1
  9. package/src/parts/ElectronInitialize/ElectronInitialize.ipc.js +8 -0
  10. package/src/parts/ElectronInitialize/ElectronInitialize.js +40 -0
  11. package/src/parts/ErrorCodes/ErrorCodes.js +2 -0
  12. package/src/parts/ExportStatic/ExportStatic.js +5 -0
  13. package/src/parts/FirstWebSocketEventType/FirstWebSocketEventType.js +2 -0
  14. package/src/parts/GetErrorResponse/GetErrorResponse.js +1 -0
  15. package/src/parts/GetHelpfulChildProcessError/GetHelpfulChildProcessError.js +13 -3
  16. package/src/parts/HandleIpc/HandleIpc.js +30 -0
  17. package/src/parts/HandleWebSocket/HandleWebSocket.ipc.js +7 -0
  18. package/src/parts/HandleWebSocket/HandleWebSocket.js +25 -0
  19. package/src/parts/HandleWebSocketForExtensionHost/HandleWebSocketForExtensionHost.js +15 -0
  20. package/src/parts/HandleWebSocketForExtensionHostHelperProcess/HandleWebSocketForExtensionHostHelperProcess.js +6 -0
  21. package/src/parts/HandleWebSocketForSharedProcess/HandleWebSocketForSharedProcess.js +16 -0
  22. package/src/parts/HandleWebSocketForTerminalProcess/HandleWebSocketForTerminalProcess.js +22 -0
  23. package/src/parts/HandleWebSocketForUnknown/HandleWebSocketForUnknown.js +10 -0
  24. package/src/parts/HandleWebSocketModule/HandleWebSocketModule.js +20 -0
  25. package/src/parts/IpcChild/IpcChild.js +3 -1
  26. package/src/parts/IpcChildModule/IpcChildModule.js +2 -0
  27. package/src/parts/IpcChildType/IpcChildType.js +4 -0
  28. package/src/parts/IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js +27 -0
  29. package/src/parts/IpcChildWithNodeForkedProcess/IpcChildWithNodeForkedProcess.js +4 -0
  30. package/src/parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js +7 -3
  31. package/src/parts/IsElectron/IsElectron.js +3 -0
  32. package/src/parts/JsonRpc/JsonRpc.js +16 -0
  33. package/src/parts/Module/Module.js +6 -0
  34. package/src/parts/ModuleId/ModuleId.js +3 -0
  35. package/src/parts/ModuleMap/ModuleMap.js +6 -0
  36. package/src/parts/ParentIpc/ParentIpc.js +10 -188
  37. package/src/parts/PrettyError/PrettyError.js +1 -0
  38. package/src/parts/ProtocolType/ProtocolType.js +2 -1
  39. package/src/parts/PtyHost/PtyHost.js +81 -0
  40. package/src/parts/RebuildNodePty/RebuildNodePty.ipc.js +7 -0
  41. package/src/parts/RebuildNodePty/RebuildNodePty.js +48 -0
  42. package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
  43. package/src/parts/Terminal/Terminal.js +36 -127
  44. package/src/parts/WebSocketServer/WebSocketServer.js +6 -25
  45. package/src/sharedProcessMain.js +1 -1
  46. package/extensions/builtin.language-basics-json5/README.md +0 -16
  47. package/extensions/builtin.language-basics-json5/extension.json +0 -12
  48. package/extensions/builtin.language-basics-json5/src/tokenizeJson5.js +0 -321
  49. /package/src/parts/{GetWindowsNsisDOwnloadUrl → GetWindowsNsisDownloadUrl}/GetWindowsNsisDownloadUrl.js +0 -0
@@ -226,6 +226,10 @@
226
226
  "id": "Developer.toggleDeveloperTools",
227
227
  "label": "Developer: Toggle Developer Tools"
228
228
  },
229
+ {
230
+ "id": "RebuildNodePty.rebuildNodePty",
231
+ "label": "Developer: Rebuild Node Pty"
232
+ },
229
233
  {
230
234
  "id": "Window.reload",
231
235
  "label": "Window: Reload",
@@ -38,6 +38,8 @@
38
38
 
39
39
  "simpleBrowser.suggestions": false,
40
40
 
41
+ "terminal.separateConnection": false,
42
+
41
43
  "window.titleBarStyle": "native",
42
44
  "window.zoomLevel": 0,
43
45
  "window.controlsOverlay.enabled": true,
@@ -6,7 +6,7 @@
6
6
  {
7
7
  "id": "python",
8
8
  "extensions": [".py"],
9
- "fileNames": ["SCsub"],
9
+ "fileNames": ["SCsub", "SConstruct"],
10
10
  "configuration": "./languageConfiguration.json",
11
11
  "tokenize": "src/tokenizePython.js",
12
12
  "firstLine": "^#!\\s*/?.*\\bpython[0-9.-]*\\b"
@@ -72,7 +72,8 @@
72
72
  ".tmtheme",
73
73
  ".mm",
74
74
  ".tmDragCommand",
75
- ".tmCommand"
75
+ ".tmCommand",
76
+ ".natvis"
76
77
  ],
77
78
  "fileNames": [".project", "resources.grd"],
78
79
  "tokenize": "src/tokenizeXml.js"
@@ -81,7 +81,7 @@ const RE_SLASH = /^\//
81
81
  const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
82
82
  const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^']+/
83
83
  const RE_TAG_TEXT = /^[^\s>]+/
84
- const RE_TAGNAME = /^[!\w\-]+/
84
+ const RE_TAGNAME = /^[!\w\-\:]+/
85
85
  const RE_TEXT = /^[^<>\n]+/
86
86
  const RE_WHITESPACE = /^\s+/
87
87
  const RE_WORD = /^[^\s]+/
@@ -96,6 +96,10 @@
96
96
  "name": "CssSelectorId",
97
97
  "foreground": "#61AFEF"
98
98
  },
99
+ {
100
+ "name": "CssAtRule",
101
+ "foreground": "#C678DD"
102
+ },
99
103
  {
100
104
  "name": "CssPropertyName",
101
105
  "foreground": "#ABB2BF"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.15.15",
3
+ "version": "0.15.17",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.21.4",
20
- "@lvce-editor/extension-host": "0.15.15",
21
- "@lvce-editor/extension-host-helper-process": "0.15.15",
22
- "@lvce-editor/pty-host": "0.15.15",
20
+ "@lvce-editor/extension-host": "0.15.17",
21
+ "@lvce-editor/extension-host-helper-process": "0.15.17",
22
+ "@lvce-editor/pty-host": "0.15.17",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -2,8 +2,11 @@ import * as GetHelpfulChildProcessError from '../GetHelpfulChildProcessError/Get
2
2
 
3
3
  export class ChildProcessError extends Error {
4
4
  constructor(stderr) {
5
- const message = GetHelpfulChildProcessError.getHelpfulChildProcessError('', stderr)
5
+ const { message, code } = GetHelpfulChildProcessError.getHelpfulChildProcessError('', stderr)
6
6
  super(message)
7
7
  this.name = 'ChildProcessError'
8
+ if (code) {
9
+ this.code = code
10
+ }
8
11
  }
9
12
  }
@@ -0,0 +1,8 @@
1
+ import * as ElectronInitialize from './ElectronInitialize.js'
2
+
3
+ export const name = 'ElectronInitialize'
4
+
5
+ // prettier-ignore
6
+ export const Commands = {
7
+ electronInitialize: ElectronInitialize.electronInitialize,
8
+ }
@@ -0,0 +1,40 @@
1
+ import * as Callback from '../Callback/Callback.js'
2
+ import * as Command from '../Command/Command.js'
3
+ import * as GetResponse from '../GetResponse/GetResponse.js'
4
+
5
+ export const electronInitialize = (port, folder) => {
6
+ // TODO handle error
7
+ const fakeSocket = {
8
+ send: port.postMessage.bind(port),
9
+ on(event, listener) {
10
+ switch (event) {
11
+ case 'close':
12
+ port.on('close', listener)
13
+ break
14
+ case 'message':
15
+ port.on('message', listener)
16
+ break
17
+ default:
18
+ console.warn('socket event not implemented', event, listener)
19
+ break
20
+ }
21
+ },
22
+ }
23
+ const handleOtherMessagesFromMessagePort = async (message) => {
24
+ // console.log('got port message', message)
25
+ if (message.result) {
26
+ Callback.resolve(message.id, message.result)
27
+ } else if (message.method) {
28
+ if (message.id) {
29
+ const response = await GetResponse.getResponse(message, fakeSocket)
30
+ port.postMessage(response)
31
+ } else {
32
+ console.warn(`[shared process] sending messages without id is deprecated: ${message.method}`)
33
+ Command.execute(message.method, fakeSocket, ...message.params)
34
+ }
35
+ } else {
36
+ console.warn('unknown message', message)
37
+ }
38
+ }
39
+ port.on('message', handleOtherMessagesFromMessagePort)
40
+ }
@@ -1,7 +1,9 @@
1
1
  export const E_COLOR_THEME_NOT_FOUND = 'E_COLOR_THEME_NOT_FOUND'
2
2
  export const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND'
3
3
  export const E_ICON_THEME_NOT_FOUND = 'E_ICON_THEME_NOT_FOUND'
4
+ export const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE'
4
5
  export const E_MANIFEST_NOT_FOUND = 'E_MANIFEST_NOT_FOUND'
6
+ export const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON'
5
7
  export const EACCES = 'EACCES'
6
8
  export const ECONNRESET = 'ECONNRESET'
7
9
  export const EEXIST = 'EEXIST'
@@ -127,6 +127,11 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
127
127
  return \`\${assetDir}/themes/\${colorThemeId}.json\`
128
128
  }`
129
129
  )
130
+ await replace(
131
+ Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'),
132
+ `/${commitHash}`,
133
+ `${pathPrefix}/${commitHash}`
134
+ )
130
135
  await replace(
131
136
  Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
132
137
  `getIconThemeUrl = (iconThemeId) => {
@@ -0,0 +1,2 @@
1
+ export const Open = 1
2
+ export const Close = 2
@@ -49,6 +49,7 @@ export const getErrorResponse = (message, error) => {
49
49
  stack: prettyError.stack,
50
50
  codeFrame: prettyError.codeFrame,
51
51
  type: prettyError.type,
52
+ code: prettyError.code,
52
53
  },
53
54
  },
54
55
  }
@@ -1,4 +1,5 @@
1
1
  import * as SplitLines from '../SplitLines/SplitLines.js'
2
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
2
3
 
3
4
  const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/
4
5
  const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/
@@ -29,7 +30,10 @@ const getMessageCodeBlock = (stderr) => {
29
30
 
30
31
  const getNativeModuleErrorMessage = (stderr) => {
31
32
  const message = getMessageCodeBlock(stderr)
32
- return `incompatible native node module: ${message}`
33
+ return {
34
+ message: `Incompatible native node module: ${message}`,
35
+ code: ErrorCodes.E_INCOMPATIBLE_NATIVE_MODULE,
36
+ }
33
37
  }
34
38
 
35
39
  const isModulesSyntaxError = (stderr) => {
@@ -40,7 +44,10 @@ const isModulesSyntaxError = (stderr) => {
40
44
  }
41
45
 
42
46
  const getModuleSyntaxError = (stderr) => {
43
- return `ES Modules are not supported in electron`
47
+ return {
48
+ message: `ES Modules are not supported in electron`,
49
+ code: ErrorCodes.E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
50
+ }
44
51
  }
45
52
 
46
53
  export const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -50,5 +57,8 @@ export const getHelpfulChildProcessError = (stdout, stderr) => {
50
57
  if (isModulesSyntaxError(stderr)) {
51
58
  return getModuleSyntaxError(stderr)
52
59
  }
53
- return 'child process error'
60
+ return {
61
+ message: `child process error: ${stderr}`,
62
+ code: '',
63
+ }
54
64
  }
@@ -0,0 +1,30 @@
1
+ import * as Callback from '../Callback/Callback.js'
2
+ import * as Command from '../Command/Command.js'
3
+ import * as GetResponse from '../GetResponse/GetResponse.js'
4
+
5
+ const handleJsonRpcResult = (message) => {
6
+ Callback.resolve(message.id, message.result)
7
+ }
8
+
9
+ export const handleIpc = (ipc) => {
10
+ const handleJsonRpcMessage = async (message, handle) => {
11
+ if (message.method) {
12
+ const response = await GetResponse.getResponse(message, handle)
13
+ ipc.send(response)
14
+ } else {
15
+ // TODO handle error
16
+ Command.execute(message.method, ...message.params)
17
+ }
18
+ }
19
+
20
+ const handleMessageFromParentProcess = async (message, handle) => {
21
+ if (message.result) {
22
+ return handleJsonRpcResult(message)
23
+ }
24
+ if (message.method) {
25
+ return handleJsonRpcMessage(message, handle)
26
+ }
27
+ console.warn('unknown message', message)
28
+ }
29
+ ipc.on('message', handleMessageFromParentProcess)
30
+ }
@@ -0,0 +1,7 @@
1
+ import * as HandleWebSocket from './HandleWebSocket.js'
2
+
3
+ export const name = 'HandleWebSocket'
4
+
5
+ export const Commands = {
6
+ handleWebSocket: HandleWebSocket.handleWebSocket,
7
+ }
@@ -0,0 +1,25 @@
1
+ import * as Assert from '../Assert/Assert.js'
2
+ import * as HandleWebSocketModule from '../HandleWebSocketModule/HandleWebSocketModule.js'
3
+ import { VError } from '../VError/VError.js'
4
+
5
+ export const handleWebSocket = async (handle, message) => {
6
+ Assert.object(message)
7
+ Assert.object(handle)
8
+ const headers = message.headers
9
+ if (!headers) {
10
+ throw new VError('missing websocket headers')
11
+ }
12
+ const protocol = headers['sec-websocket-protocol']
13
+ if (!protocol) {
14
+ throw new VError('missing sec websocket protocol header')
15
+ }
16
+ try {
17
+ const module = await HandleWebSocketModule.load(protocol)
18
+ await module.handleWebSocket(message, handle, protocol)
19
+ } catch (error) {
20
+ try {
21
+ handle.destroy()
22
+ } catch {}
23
+ throw new VError(error, `Failed to connect to websocket`)
24
+ }
25
+ }
@@ -0,0 +1,15 @@
1
+ import * as ExtensionHostIpc from '../ExtensionHostIpc/ExtensionHostIpc.js'
2
+ import * as ExtensionHostRpc from '../ExtensionHostRpc/ExtensionHostRpc.js'
3
+
4
+ // TODO lazyload modules for spawning extension host, they are only needed later
5
+ export const handleWebSocket = async (message, handle) => {
6
+ // console.log('[shared-process] received extension host websocket', message)
7
+ const ipc = await ExtensionHostIpc.create()
8
+ console.info('[sharedprocess] creating extension ipc')
9
+ const rpc = await ExtensionHostRpc.create(ipc, handle)
10
+ console.info('[sharedprocess] created extension host rpc')
11
+ ipc._process.send(message, handle)
12
+ // rpc.send(message)
13
+ // console.log('spawned extension host')
14
+ // console.log(rpc)
15
+ }
@@ -0,0 +1,6 @@
1
+ import * as ExtensionHostHelperProcessIpc from '../ExtensionHostHelperProcessIpc/ExtensionHostHelperProcessIpc.js'
2
+
3
+ export const handleWebSocket = async (message, handle) => {
4
+ const ipc = await ExtensionHostHelperProcessIpc.create()
5
+ ipc._process.send(message, handle)
6
+ }
@@ -0,0 +1,16 @@
1
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
2
+ import * as Socket from '../Socket/Socket.js'
3
+ import * as WebSocketServer from '../WebSocketServer/WebSocketServer.js'
4
+
5
+ const handleSocketError = (error) => {
6
+ if (error && error.code === ErrorCodes.ECONNRESET) {
7
+ return
8
+ }
9
+ console.info('[info shared process: handle error]', error)
10
+ }
11
+
12
+ export const handleWebSocket = async (message, handle) => {
13
+ handle.on('error', handleSocketError)
14
+ const webSocket = await WebSocketServer.handleUpgrade(message, handle)
15
+ Socket.set(webSocket)
16
+ }
@@ -0,0 +1,22 @@
1
+ import * as PtyHost from '../PtyHost/PtyHost.js'
2
+
3
+ export const handleWebSocket = async (message, handle) => {
4
+ const instance = await PtyHost.getOrCreate()
5
+ instance.sendAndTransfer(
6
+ {
7
+ jsonrpc: '2.0',
8
+ method: 'HandleWebSocket.handleWebSocket',
9
+ params: [message],
10
+ },
11
+ handle
12
+ )
13
+ // console.log({ instance })
14
+ // const ipc = await PtyHost.getOrCreate()
15
+ // console.info('[sharedprocess] creating extension ipc')
16
+ // const rpc = await ExtensionHostRpc.create(ipc, handle)
17
+ // console.info('[sharedprocess] created extension host rpc')
18
+ // ipc._process.send(message, handle)
19
+ // rpc.send(message)
20
+ // console.log('spawned extension host')
21
+ // console.log(rpc)
22
+ }
@@ -0,0 +1,10 @@
1
+ import * as Logger from '../Logger/Logger.js'
2
+
3
+ export const handleWebSocket = (message, handle, protocol) => {
4
+ Logger.warn(`[shared-process] unsupported sec-websocket-procotol ${protocol}`)
5
+ try {
6
+ handle.destroy()
7
+ } catch {
8
+ // ignore
9
+ }
10
+ }
@@ -0,0 +1,20 @@
1
+ import * as ProtocolType from '../ProtocolType/ProtocolType.js'
2
+ import { VError } from '../VError/VError.js'
3
+
4
+ export const load = (protocol) => {
5
+ if (!protocol) {
6
+ throw new VError('missing sec websocket protocol header')
7
+ }
8
+ switch (protocol) {
9
+ case ProtocolType.SharedProcess:
10
+ return import('../HandleWebSocketForSharedProcess/HandleWebSocketForSharedProcess.js')
11
+ case ProtocolType.ExtensionHost:
12
+ return import('../HandleWebSocketForExtensionHost/HandleWebSocketForExtensionHost.js')
13
+ case ProtocolType.ExtensionHostHelperProcess:
14
+ return import('../HandleWebSocketForExtensionHostHelperProcess/HandleWebSocketForExtensionHostHelperProcess.js')
15
+ case ProtocolType.TerminalProcess:
16
+ return import('../HandleWebSocketForTerminalProcess/HandleWebSocketForTerminalProcess.js')
17
+ default:
18
+ return import('../HandleWebSocketForUnknown/HandleWebSocketForUnknown.js')
19
+ }
20
+ }
@@ -2,5 +2,7 @@ import * as IpcChildModule from '../IpcChildModule/IpcChildModule.js'
2
2
 
3
3
  export const listen = async ({ method }) => {
4
4
  const module = await IpcChildModule.getModule(method)
5
- return module.listen()
5
+ const rawIpc = await module.listen()
6
+ const ipc = module.wrap(rawIpc)
7
+ return ipc
6
8
  }
@@ -6,6 +6,8 @@ export const getModule = (method) => {
6
6
  return import('../IpcChildWithNodeForkedProcess/IpcChildWithNodeForkedProcess.js')
7
7
  case IpcChildType.NodeWorker:
8
8
  return import('../IpcChildWithNodeWorker/IpcChildWithNodeWorker.js')
9
+ case IpcChildType.ElectronUtilityProcess:
10
+ return import('../IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js')
9
11
  default:
10
12
  throw new Error('unexpected ipc type')
11
13
  }
@@ -1,5 +1,6 @@
1
1
  export const NodeWorker = 1
2
2
  export const NodeForkedProcess = 2
3
+ export const ElectronUtilityProcess = 3
3
4
 
4
5
  export const Auto = () => {
5
6
  const { argv } = process
@@ -9,5 +10,8 @@ export const Auto = () => {
9
10
  if (argv.includes('--ipc-type=node-forked-process')) {
10
11
  return NodeForkedProcess
11
12
  }
13
+ if (argv.includes('--ipc-type=electron-utility-process')) {
14
+ return ElectronUtilityProcess
15
+ }
12
16
  throw new Error(`[shared-process] unknown ipc type`)
13
17
  }
@@ -0,0 +1,27 @@
1
+ export const listen = () => {
2
+ // @ts-ignore
3
+ const parentPort = process.parentPort
4
+ if (!parentPort) {
5
+ throw new Error('parent port must be defined')
6
+ }
7
+ parentPort.postMessage('ready')
8
+ return parentPort
9
+ }
10
+
11
+ export const wrap = (parentPort) => {
12
+ return {
13
+ parentPort,
14
+ on(event, listener) {
15
+ this.parentPort.on(event, listener)
16
+ },
17
+ off(event, listener) {
18
+ this.parentPort.off(event, listener)
19
+ },
20
+ send(message) {
21
+ this.parentPort.postMessage(message)
22
+ },
23
+ dispose() {
24
+ this.parentPort.close()
25
+ },
26
+ }
27
+ }
@@ -1,4 +1,8 @@
1
1
  export const listen = async () => {
2
+ if (!process.send) {
3
+ throw new Error('process.send must be defined')
4
+ }
5
+ process.send('ready')
2
6
  return process
3
7
  }
4
8
 
@@ -8,7 +8,8 @@ import { VError } from '../VError/VError.js'
8
8
  export const create = async ({ path, argv = [], env, execArgv = [], stdio = 'inherit', name = 'child process' }) => {
9
9
  try {
10
10
  Assert.string(path)
11
- const childProcess = fork(path, argv, {
11
+ const actualArgv = ['--ipc-type=node-forked-process', ...argv]
12
+ const childProcess = fork(path, actualArgv, {
12
13
  env,
13
14
  execArgv,
14
15
  stdio: 'pipe',
@@ -36,11 +37,14 @@ export const wrap = (childProcess) => {
36
37
  on(event, listener) {
37
38
  this.childProcess.on(event, listener)
38
39
  },
40
+ off(event, listener) {
41
+ this.childProcess.off(event, listener)
42
+ },
39
43
  send(message) {
40
44
  this.childProcess.send(message)
41
45
  },
42
- sendAndTransfer(message, transfer) {
43
- throw new Error('transfer is not supported')
46
+ sendAndTransfer(message, handle) {
47
+ this.childProcess.send(message, handle)
44
48
  },
45
49
  dispose() {
46
50
  this.childProcess.kill()
@@ -0,0 +1,3 @@
1
+ export const isElectron = () => {
2
+ return Boolean(process.env.ELECTRON_RUN_AS_NODE)
3
+ }
@@ -21,3 +21,19 @@ export const invoke = (ipc, method, ...params) => {
21
21
  })
22
22
  })
23
23
  }
24
+
25
+ export const invokeAndTransfer = (ipc, handle, method, ...params) => {
26
+ return new Promise((resolve, reject) => {
27
+ // TODO use one map instead of two
28
+ const callbackId = Callback.register(resolve, reject)
29
+ ipc.sendAndTransfer(
30
+ {
31
+ jsonrpc: JsonRpcVersion.Two,
32
+ method,
33
+ params,
34
+ id: callbackId,
35
+ },
36
+ handle
37
+ )
38
+ })
39
+ }
@@ -20,6 +20,8 @@ export const load = (moduleId) => {
20
20
  return import('../Download/Download.ipc.js')
21
21
  case ModuleId.ExtensionHost:
22
22
  return import('../ExtensionHost/ExtensionHost.ipc.js')
23
+ case ModuleId.ElectronInitialize:
24
+ return import('../ElectronInitialize/ElectronInitialize.ipc.js')
23
25
  case ModuleId.ExtensionManagement:
24
26
  return import('../ExtensionManagement/ExtensionManagement.ipc.js')
25
27
  case ModuleId.FileSystem:
@@ -52,6 +54,10 @@ export const load = (moduleId) => {
52
54
  return import('../WebSocketServer/WebSocketServer.ipc.js')
53
55
  case ModuleId.Workspace:
54
56
  return import('../Workspace/Workspace.ipc.js')
57
+ case ModuleId.RebuildNodePty:
58
+ return import('../RebuildNodePty/RebuildNodePty.ipc.js')
59
+ case ModuleId.HandleWebSocket:
60
+ return import('../HandleWebSocket/HandleWebSocket.ipc.js')
55
61
  default:
56
62
  throw new Error(`module ${moduleId} not found`)
57
63
  }
@@ -23,3 +23,6 @@ export const AutoUpdater = 22
23
23
  export const IsAutoUpdateSupported = 23
24
24
  export const AutoUpdaterAppImage = 24
25
25
  export const AutoUpdaterWindowsNsis = 25
26
+ export const RebuildNodePty = 26
27
+ export const ElectronInitialize = 27
28
+ export const HandleWebSocket = 28
@@ -31,6 +31,8 @@ export const getModuleId = (commandId) => {
31
31
  return ModuleId.Developer
32
32
  case 'Download.download':
33
33
  return ModuleId.Download
34
+ case 'ElectronInitialize.electronInitialize':
35
+ return ModuleId.ElectronInitialize
34
36
  case 'ExtensionHost.dispose':
35
37
  case 'ExtensionHost.enableExtension':
36
38
  case 'ExtensionHost.executeCommand':
@@ -108,6 +110,8 @@ export const getModuleId = (commandId) => {
108
110
  case 'GitLsFiles.gitLsFilesHash':
109
111
  case 'GitLsFiles.resolveGit':
110
112
  return ModuleId.GitLsFiles
113
+ case 'HandleWebSocket.handleWebSocket':
114
+ return ModuleId.HandleWebSocket
111
115
  case 'InstallExtension.installExtension':
112
116
  return ModuleId.InstallExtension
113
117
  case 'IsAutoUpdateSupported.isAutoUpdateSupported':
@@ -155,6 +159,8 @@ export const getModuleId = (commandId) => {
155
159
  case 'Workspace.getHomeDir':
156
160
  case 'Workspace.resolveRoot':
157
161
  return ModuleId.Workspace
162
+ case 'RebuildNodePty.rebuildNodePty':
163
+ return ModuleId.RebuildNodePty
158
164
  default:
159
165
  throw new CommandNotFoundError(commandId)
160
166
  }