@lvce-editor/shared-process 0.0.28 → 0.0.29

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.
@@ -305,7 +305,7 @@
305
305
  "label": "Editor: Move Line Up"
306
306
  },
307
307
  {
308
- "id": "file.openFolder",
308
+ "id": "Dialog.openFolder",
309
309
  "label": "File: Open Folder"
310
310
  },
311
311
  {
@@ -313,7 +313,7 @@
313
313
  "label": "File: Open Recent"
314
314
  },
315
315
  {
316
- "id": "help.about",
316
+ "id": "Dialog.showAbout",
317
317
  "label": "Help: About"
318
318
  },
319
319
  {
@@ -133,7 +133,7 @@
133
133
  },
134
134
  {
135
135
  "key": "ctrl+`",
136
- "command": "ViewService.toggleView",
136
+ "command": "Layout.togglePanel",
137
137
  "args": ["Terminal"]
138
138
  },
139
139
  {
@@ -152,31 +152,23 @@
152
152
  },
153
153
  {
154
154
  "key": "ctrl+p",
155
- "command": "QuickPick.openEverythingQuickPick"
155
+ "command": "Viewlet.openWidget",
156
+ "args": ["QuickPick", "file"]
156
157
  },
157
158
  {
158
159
  "key": "ctrl+shift+p",
159
- "command": "QuickPick.openCommandPalette"
160
- },
161
- {
162
- "key": "shift shift",
163
- "command": "QuickPick.openCommandPalette"
164
- },
165
- {
166
- "key": "ctrl ctrl",
167
- "command": "QuickPick.openCommandPalette"
168
- },
169
- {
170
- "key": "alt alt",
171
- "command": "QuickPick.openCommandPalette"
160
+ "command": "Viewlet.openWidget",
161
+ "args": ["QuickPick", "everything"]
172
162
  },
173
163
  {
174
164
  "key": "F1",
175
- "command": "QuickPick.openCommandPalette"
165
+ "command": "Viewlet.openWidget",
166
+ "args": ["QuickPick", "everything"]
176
167
  },
177
168
  {
178
169
  "key": "Escape",
179
- "command": "QuickPick.hide",
170
+ "command": "Viewlet.closeWidget",
171
+ "args": ["QuickPick"],
180
172
  "when": "focus.quickPickInput"
181
173
  },
182
174
  {
@@ -650,5 +642,13 @@
650
642
  "key": "Enter",
651
643
  "command": "Locations.selectCurrent",
652
644
  "when": "focus.locationList"
645
+ },
646
+ {
647
+ "key": "ctrl+0",
648
+ "command": "SideBar.focus"
649
+ },
650
+ {
651
+ "key": "ctrl+1",
652
+ "command": "Main.focus"
653
653
  }
654
654
  ]
@@ -13,5 +13,7 @@
13
13
  "workbench.iconTheme": "vscode-icons",
14
14
  "workbench.activityBar.visible": true,
15
15
  "workbench.sideBar.visible": true,
16
- "workbench.saveStateOnVisibilityChange": false
16
+ "workbench.saveStateOnVisibilityChange": false,
17
+
18
+ "sessionReplay.enabled": true
17
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -13,17 +13,16 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "chokidar": "^3.5.3",
16
- "clipboardy": "^3.0.0",
17
16
  "debug": "^4.3.4",
18
17
  "execa": "^6.1.0",
19
18
  "exit-hook": "^3.0.0",
20
- "got": "^12.3.0",
19
+ "got": "^12.3.1",
21
20
  "is-object": "^1.0.2",
22
21
  "json-parse-even-better-errors": "^2.3.1",
23
22
  "jsonc-parser": "^3.1.0",
24
23
  "lines-and-columns": "^2.0.3",
25
24
  "open": "^8.4.0",
26
- "p-queue": "^7.2.0",
25
+ "p-queue": "^7.3.0",
27
26
  "parse-json": "^6.0.2",
28
27
  "tail": "^2.2.4",
29
28
  "tar-fs": "^2.1.1",
@@ -31,8 +30,8 @@
31
30
  "verror": "^1.10.1",
32
31
  "ws": "^8.8.1",
33
32
  "xdg-basedir": "^5.1.0",
34
- "@lvce-editor/pty-host": "0.0.28",
35
- "@lvce-editor/extension-host": "0.0.28"
33
+ "@lvce-editor/pty-host": "0.0.29",
34
+ "@lvce-editor/extension-host": "0.0.29"
36
35
  },
37
36
  "optionalDependencies": {
38
37
  "electron-clipboard-ex": "^1.3.3",
@@ -1,7 +1,6 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as ClipBoard from './ClipBoard.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register('ClipBoard.readFiles', ClipBoard.readFiles)
6
- Command.register('ClipBoard.writeFiles', ClipBoard.writeFiles)
3
+ export const Commands = {
4
+ 'ClipBoard.readFiles': ClipBoard.readFiles,
5
+ 'ClipBoard.writeFiles': ClipBoard.writeFiles,
7
6
  }
@@ -59,11 +59,26 @@ const loadModule = (moduleId) => {
59
59
  }
60
60
  }
61
61
 
62
+ const initializeModule = (module) => {
63
+ if (typeof module.__initialize__ !== 'function') {
64
+ if (module.Commands) {
65
+ for (const [key, value] of Object.entries(module.Commands)) {
66
+ register(key, value)
67
+ }
68
+ return
69
+ }
70
+ throw new Error(
71
+ `module ${module.name} is missing an initialize function and commands`
72
+ )
73
+ }
74
+ return module.__initialize__()
75
+ }
76
+
62
77
  const getOrLoadModule = (moduleId) => {
63
78
  if (!pendingModules[moduleId]) {
64
79
  const importPromise = loadModule(moduleId)
65
80
  pendingModules[moduleId] = importPromise
66
- .then((module) => module.__initialize__())
81
+ .then(initializeModule)
67
82
  .catch((error) => {
68
83
  console.error(error)
69
84
  })
@@ -1,10 +1,9 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Credentials from './Credentials.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register(801, Credentials.getPassword)
6
- Command.register(802, Credentials.setPassword)
7
- Command.register(803, Credentials.deletePassword)
8
- Command.register(804, Credentials.findPassword)
9
- Command.register(805, Credentials.findCredentials)
3
+ export const Commands = {
4
+ 801: Credentials.getPassword,
5
+ 802: Credentials.setPassword,
6
+ 803: Credentials.deletePassword,
7
+ 804: Credentials.findPassword,
8
+ 805: Credentials.findCredentials,
10
9
  }
@@ -1,14 +1,13 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Developer from './Developer.js'
3
2
 
4
3
  // prettier-ignore
5
- export const __initialize__ = () => {
6
- Command.register('Developer.sharedProcessStartupPerformance', Developer.sharedProcessStartupPerformance)
7
- Command.register('Developer.sharedProcessMemoryUsage', Developer.sharedProcessMemoryUsage)
8
- Command.register('Developer.allocateMemory', Developer.allocateMemory)
9
- Command.register('Developer.crashSharedProcess', Developer.crashSharedProcess)
10
- Command.register('Developer.createHeapSnapshot', Developer.createHeapSnapshot)
11
- Command.register('Developer.createProfile', Developer.createProfile)
12
- Command.register('Developer.getNodeStartupTiming', Developer.getNodeStartupTiming)
13
- Command.register('Developer.getNodeStartupTime', Developer.getNodeStartupTiming)
4
+ export const Commands = {
5
+ 'Developer.sharedProcessStartupPerformance': Developer.sharedProcessStartupPerformance,
6
+ 'Developer.sharedProcessMemoryUsage': Developer.sharedProcessMemoryUsage,
7
+ 'Developer.allocateMemory': Developer.allocateMemory,
8
+ 'Developer.crashSharedProcess': Developer.crashSharedProcess,
9
+ 'Developer.createHeapSnapshot': Developer.createHeapSnapshot,
10
+ 'Developer.createProfile': Developer.createProfile,
11
+ 'Developer.getNodeStartupTiming': Developer.getNodeStartupTiming,
12
+ 'Developer.getNodeStartupTime': Developer.getNodeStartupTiming,
14
13
  }
@@ -1,19 +1,18 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Electron from './Electron.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register('Electron.toggleDevtools', Electron.toggleDevtools)
6
- Command.register('Electron.windowMinimize', Electron.windowMinimize)
7
- Command.register('Electron.windowMaximize', Electron.windowMaximize)
8
- Command.register('Electron.windowUnmaximize', Electron.windowUnmaximize)
9
- Command.register('Electron.windowClose', Electron.windowClose)
10
- Command.register('Electron.about', Electron.about)
11
- Command.register('Electron.showOpenDialog', Electron.showOpenDialog)
12
- Command.register('Electron.windowReload', Electron.windowReload)
13
- Command.register('Electron.getPerformanceEntries', Electron.getPerformanceEntries)
14
- Command.register('Electron.crashMainProcess', Electron.crashMainProcess)
15
- Command.register('Electron.showMessageBox', Electron.showMessageBox)
16
- Command.register('Electron.windowOpenNew', Electron.windowOpenNew)
17
- Command.register('Electron.exit', Electron.exit)
18
- Command.register('Electron.openProcessExplorer', Electron.openProcessExplorer)
3
+ export const Commands = {
4
+ 'Electron.toggleDevtools': Electron.toggleDevtools,
5
+ 'Electron.windowMinimize': Electron.windowMinimize,
6
+ 'Electron.windowMaximize': Electron.windowMaximize,
7
+ 'Electron.windowUnmaximize': Electron.windowUnmaximize,
8
+ 'Electron.windowClose': Electron.windowClose,
9
+ 'Electron.about': Electron.about,
10
+ 'Electron.showOpenDialog': Electron.showOpenDialog,
11
+ 'Electron.windowReload': Electron.windowReload,
12
+ 'Electron.getPerformanceEntries': Electron.getPerformanceEntries,
13
+ 'Electron.crashMainProcess': Electron.crashMainProcess,
14
+ 'Electron.showMessageBox': Electron.showMessageBox,
15
+ 'Electron.windowOpenNew': Electron.windowOpenNew,
16
+ 'Electron.exit': Electron.exit,
17
+ 'Electron.openProcessExplorer': Electron.openProcessExplorer,
19
18
  }
@@ -5,6 +5,18 @@ export const state = {
5
5
  send(message) {
6
6
  ParentIpc.electronSend(message)
7
7
  },
8
+ async invoke(method, ...params) {
9
+ return new Promise((resolve, reject) => {
10
+ // TODO use one map instead of two
11
+ const callbackId = Callback.register(resolve, reject)
12
+ state.send({
13
+ jsonrpc: '2.0',
14
+ method,
15
+ params,
16
+ id: callbackId,
17
+ })
18
+ })
19
+ },
8
20
  }
9
21
 
10
22
  const send = (method, ...params) => {
@@ -16,84 +28,81 @@ const send = (method, ...params) => {
16
28
  }
17
29
 
18
30
  const invoke = async (method, ...params) => {
19
- return new Promise((resolve, reject) => {
20
- // TODO use one map instead of two
21
- const callbackId = Callback.register(resolve, reject)
22
- state.send({
23
- jsonrpc: '2.0',
24
- method,
25
- params,
26
- id: callbackId,
27
- })
28
- })
31
+ return state.invoke(method, ...params)
29
32
  }
30
33
 
31
- export const toggleDevtools = () => {
32
- send(/* Window.toggleDevtools */ 6523)
34
+ export const toggleDevtools = async () => {
35
+ await invoke(/* Window.toggleDevtools */ 'Window.toggleDevtools')
33
36
  }
34
37
 
35
- export const windowMinimize = () => {
36
- send(/* Window.minimize */ 6521)
38
+ export const windowMinimize = async () => {
39
+ await invoke(/* Window.minimize */ 'Window.minimize')
37
40
  }
38
41
 
39
- export const windowMaximize = () => {
40
- send(/* Window.maximize */ 6522)
42
+ export const windowMaximize = async () => {
43
+ await invoke(/* Window.maximize */ 'Window.maximize')
41
44
  }
42
45
 
43
- export const windowUnmaximize = () => {
44
- send(/* Window.unmaximize */ 6524)
46
+ export const windowUnmaximize = async () => {
47
+ await invoke(/* Window.unmaximize */ 'Window.unmaximize')
45
48
  }
46
49
 
47
- export const windowClose = () => {
48
- send(/* Window.close */ 6525)
50
+ export const windowClose = async () => {
51
+ await invoke(/* Window.close */ 'Window.close')
49
52
  }
50
53
 
51
- export const windowReload = () => {
52
- send(/* Window.reload */ 6526)
54
+ export const windowReload = async () => {
55
+ await invoke(/* Window.reload */ 'Window.reload')
53
56
  }
54
57
 
55
58
  // TODO move these into separate files like done extension host
56
59
 
57
- export const windowOpenNew = () => {
58
- send(/* AppWindow.openNew */ 8527)
60
+ export const windowOpenNew = async () => {
61
+ await invoke(/* AppWindow.openNew */ 'AppWindow.openNew')
59
62
  }
60
63
 
61
- export const about = () => {
62
- send(/* About.open */ 20001)
64
+ export const about = async () => {
65
+ await invoke(/* About.open */ 'About.open')
63
66
  }
64
67
 
65
68
  export const showOpenDialog = async () => {
66
- const result = await invoke(/* Dialog.showOpenDialog */ 20100)
69
+ const result = await invoke(
70
+ /* Dialog.showOpenDialog */ 'Dialog.showOpenDialog'
71
+ )
67
72
  return result
68
73
  }
69
74
 
70
75
  export const showMessageBox = async (message, buttons) => {
71
76
  const result = await invoke(
72
- /* Dialog.showMessageBox */ 20101,
77
+ /* Dialog.showMessageBox */ 'Dialog.showMessageBox',
73
78
  message,
74
79
  buttons
75
80
  )
76
81
  return result
77
82
  }
78
83
 
79
- export const crashMainProcess = () => {
80
- send(/* Developer.crashMainProcess */ 7723)
84
+ export const crashMainProcess = async () => {
85
+ await invoke(/* Developer.crashMainProcess */ 'Developer.crashMainProcess')
81
86
  }
82
87
 
83
88
  export const getPerformanceEntries = async () => {
84
- const result = await invoke(/* Developer.getPerformanceEntries */ 7722)
89
+ const result = await invoke(
90
+ /* Developer.getPerformanceEntries */ 'Developer.getPerformanceEntries'
91
+ )
85
92
  return result
86
93
  }
87
94
 
88
95
  export const beep = async () => {
89
96
  // TODO when is remote should send to renderer worker
90
- await invoke(/* Beep.beep */ 50000)
97
+ await invoke(/* Beep.beep */ 'Beep.beep')
91
98
  }
92
99
 
93
100
  export const exit = async () => {
94
- await invoke(/* App.exit */ 2211)
101
+ await invoke(/* App.exit */ 'App.exit')
95
102
  }
96
103
 
97
104
  export const openProcessExplorer = async () => {
98
- await invoke(/* ProcessExplorer.openProcessExplorer */ 8822)
105
+ await invoke(
106
+ /* ProcessExplorer.openProcessExplorer */ 'ProcessExplorer.openProcessExplorer'
107
+ )
99
108
  }
@@ -4,18 +4,19 @@ import * as ExtensionHostCommand from './ExtensionHostCommand.js'
4
4
  import * as ExtensionHostKeyBindings from './ExtensionHostKeyBindings.js'
5
5
 
6
6
  // prettier-ignore
7
- export const __initialize__ = () => {
8
- Command.register('ExtensionHost.getCommands', ExtensionHostCommand.getCommandsIpc)
9
- Command.register('ExtensionHostKeyBindings.getKeyBindings', ExtensionHostKeyBindings.getKeyBindings)
10
- Command.register('ExtensionHost.start', ExtensionHost.start)
11
- Command.register('ExtensionHost.dispose', ExtensionHost.dispose)
12
- Command.register('ExtensionHost.send', ExtensionHost.send)
7
+ export const Commands = {
13
8
 
14
- Command.register('ExtensionHostExtension.activate', ExtensionHost.forward)
15
- Command.register('ExtensionHostExtension.disable', ExtensionHost.forward)
16
- Command.register('ExtensionHostSemanticTokens.executeSemanticTokenProvider', ExtensionHost.forward)
17
- Command.register('ExtensionHostTextDocument.setLanguageId', ExtensionHost.forward)
18
- Command.register('ExtensionHostTextDocument.syncIncremental', ExtensionHost.forward)
19
- Command.register('ExtensionHostTextDocument.syncFull', ExtensionHost.forward)
20
- Command.register('ExtensionHostCompletion.execute', ExtensionHost.forward)
9
+ 'ExtensionHost.getCommands': ExtensionHostCommand.getCommandsIpc,
10
+ 'ExtensionHostKeyBindings.getKeyBindings': ExtensionHostKeyBindings.getKeyBindings,
11
+ 'ExtensionHost.start': ExtensionHost.start,
12
+ 'ExtensionHost.dispose': ExtensionHost.dispose,
13
+ 'ExtensionHost.send': ExtensionHost.send,
14
+
15
+ 'ExtensionHostExtension.activate': ExtensionHost.forward,
16
+ 'ExtensionHostExtension.disable': ExtensionHost.forward,
17
+ 'ExtensionHostSemanticTokens.executeSemanticTokenProvider': ExtensionHost.forward,
18
+ 'ExtensionHostTextDocument.setLanguageId': ExtensionHost.forward,
19
+ 'ExtensionHostTextDocument.syncIncremental': ExtensionHost.forward,
20
+ 'ExtensionHostTextDocument.syncFull': ExtensionHost.forward,
21
+ 'ExtensionHostCompletion.execute': ExtensionHost.forward,
21
22
  }
@@ -1,22 +1,19 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as ExtensionHostIconTheme from '../ExtensionManagement/ExtensionManagementIconTheme.js'
2
+ import * as ExtensionManagement from './ExtensionManagement.js'
3
3
  import * as ExtensionHostColorTheme from './ExtensionManagementColorTheme.js'
4
4
  import * as ExtensionHostLanguages from './ExtensionManagementLanguages.js'
5
- import * as ExtensionManagement from './ExtensionManagement.js'
6
5
 
7
6
  // prettier-ignore
8
- export const __initialize__ = () => {
9
- Command.register('ExtensionManagement.install', ExtensionManagement.install)
10
- Command.register('ExtensionManagement.uninstall', ExtensionManagement.uninstall)
11
- Command.register('ExtensionManagement.enable', ExtensionManagement.enable)
12
- Command.register('ExtensionManagement.disable', ExtensionManagement.disable)
13
- Command.register('ExtensionManagement.getAllExtensions', ExtensionManagement.getAllExtensions)
14
- Command.register('ExtensionManagement.getExtensions', ExtensionManagement.getExtensions)
15
-
16
- Command.register('ExtensionHost.getColorThemeJson', ExtensionHostColorTheme.getColorThemeJson)
17
- Command.register('ExtensionHost.getColorThemeNames', ExtensionHostColorTheme.getColorThemeNames)
18
-
19
- Command.register('ExtensionHost.getLanguages', ExtensionHostLanguages.getLanguages)
20
- Command.register('ExtensionHost.getLanguageConfiguration', ExtensionHostLanguages.getLanguageConfiguration)
21
- Command.register('ExtensionHost.getIconThemeJson', ExtensionHostIconTheme.getIconTheme)
7
+ export const Commands = {
8
+ 'ExtensionManagement.install': ExtensionManagement.install,
9
+ 'ExtensionManagement.uninstall': ExtensionManagement.uninstall,
10
+ 'ExtensionManagement.enable': ExtensionManagement.enable,
11
+ 'ExtensionManagement.disable': ExtensionManagement.disable,
12
+ 'ExtensionManagement.getAllExtensions': ExtensionManagement.getAllExtensions,
13
+ 'ExtensionManagement.getExtensions': ExtensionManagement.getExtensions,
14
+ 'ExtensionHost.getColorThemeJson': ExtensionHostColorTheme.getColorThemeJson,
15
+ 'ExtensionHost.getColorThemeNames': ExtensionHostColorTheme.getColorThemeNames,
16
+ 'ExtensionHost.getLanguages': ExtensionHostLanguages.getLanguages,
17
+ 'ExtensionHost.getLanguageConfiguration': ExtensionHostLanguages.getLanguageConfiguration,
18
+ 'ExtensionHost.getIconThemeJson': ExtensionHostIconTheme.getIconTheme,
22
19
  }
@@ -1,4 +1,3 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as FileSystem from './FileSystem.js'
3
2
 
4
3
  // TODO ugly code here -> should be inside FileSystem.js
@@ -6,7 +5,6 @@ const fileSystemWatch = (socket, id, path) => {
6
5
  // const watcher = FileSystem.watch(path, {
7
6
  // onAll(...args) {
8
7
  // socket.send(JSON.stringify([/* callback */ id, /* event */ args]))
9
-
10
8
  // }
11
9
  // }
12
10
  // )
@@ -16,17 +14,18 @@ const fileSystemWatch = (socket, id, path) => {
16
14
  }
17
15
 
18
16
  // TODO separate ipc from code like in renderer worker
19
- export const __initialize__ = () => {
20
- Command.register('FileSystem.readFile', FileSystem.readFile)
21
- Command.register('FileSystem.writeFile', FileSystem.writeFile)
22
- Command.register('FileSystem.readDirWithFileTypes', FileSystem.readDirWithFileTypes)
23
- Command.register('FileSystem.remove', FileSystem.remove)
24
- Command.register('FileSystem.mkdir', FileSystem.mkdir)
25
- // Command.register(106, fileSystemWatch) // TODO
26
- Command.register('FileSystem.createFile', FileSystem.createFile)
27
- Command.register('FileSystem.createFolder', FileSystem.createFolder)
28
- Command.register('FileSystem.rename', FileSystem.rename)
29
- Command.register('FileSystem.ensureFile', FileSystem.ensureFile)
30
- Command.register('FileSystem.copy', FileSystem.copy)
31
- Command.register('FileSystem.getPathSeparator', FileSystem.getPathSeparator)
17
+ export const Commands = {
18
+ 'FileSystem.copy': FileSystem.copy,
19
+ 'FileSystem.createFile': FileSystem.createFile,
20
+ 'FileSystem.createFolder': FileSystem.createFolder,
21
+ 'FileSystem.ensureFile': FileSystem.ensureFile,
22
+ 'FileSystem.getPathSeparator': FileSystem.getPathSeparator,
23
+ 'FileSystem.getRealPath': FileSystem.getRealPath,
24
+ 'FileSystem.mkdir': FileSystem.mkdir,
25
+ 'FileSystem.readDirWithFileTypes': FileSystem.readDirWithFileTypes,
26
+ 'FileSystem.readFile': FileSystem.readFile,
27
+ 'FileSystem.remove': FileSystem.remove,
28
+ 'FileSystem.rename': FileSystem.rename,
29
+ 'FileSystem.stat': FileSystem.stat,
30
+ 'FileSystem.writeFile': FileSystem.writeFile,
32
31
  }
@@ -147,6 +147,9 @@ export const exists = async (path) => {
147
147
  }
148
148
  }
149
149
 
150
+ /**
151
+ * @param {import('fs').Dirent|import('fs').StatsBase} dirent
152
+ */
150
153
  const getType = (dirent) => {
151
154
  if (dirent.isFile()) {
152
155
  return 'file'
@@ -154,9 +157,24 @@ const getType = (dirent) => {
154
157
  if (dirent.isDirectory()) {
155
158
  return 'directory'
156
159
  }
160
+ if (dirent.isSymbolicLink()) {
161
+ return 'symlink'
162
+ }
163
+ if (dirent.isSocket()) {
164
+ return 'socket'
165
+ }
166
+ if (dirent.isBlockDevice()) {
167
+ return 'block-device'
168
+ }
169
+ if (dirent.isCharacterDevice()) {
170
+ return 'character-device'
171
+ }
157
172
  return 'unknown'
158
173
  }
159
174
 
175
+ /**
176
+ * @param {import('fs').Dirent} dirent
177
+ */
160
178
  const toPrettyDirent = (dirent) => {
161
179
  return {
162
180
  name: dirent.name,
@@ -224,6 +242,31 @@ export const getPathSeparator = () => {
224
242
  return Platform.getPathSeparator()
225
243
  }
226
244
 
245
+ export const getRealPath = async (path) => {
246
+ try {
247
+ return await fs.realpath(path)
248
+ } catch (error) {
249
+ // @ts-ignore
250
+ if (error && error instanceof globalThis.Error && error.code === 'ENOENT') {
251
+ let content
252
+ try {
253
+ content = await fs.readlink(path)
254
+ } catch {
255
+ throw new VError(error, `Failed to resolve real path for ${path}`)
256
+ }
257
+ throw new VError(`Broken symbolic link: File not found ${content}`)
258
+ }
259
+ throw new VError(error, `Failed to resolve real path for ${path}`)
260
+ }
261
+ }
262
+
263
+ export const stat = async (path) => {
264
+ const stats = await fs.stat(path)
265
+ const type = getType(stats)
266
+ return type
267
+ }
268
+
269
+ // getRealPath('/home/simon/Documents/levivilet/lvce-editor/node_modules/.bin/abc') //?
227
270
  // export const unwatch = (id) => {
228
271
  // state.watchers[id].close()
229
272
  // delete state.watchers[id]
@@ -1,6 +1,5 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Native from './Native.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register('Native.openFolder', Native.openFolder)
3
+ export const Commands = {
4
+ 'Native.openFolder': Native.openFolder,
6
5
  }
@@ -3,11 +3,11 @@ import * as Command from '../Command/Command.js'
3
3
  import * as OutputChannel from './OutputChannel.js'
4
4
 
5
5
  export const state = {
6
- outputChannels: Object.create(null)
6
+ outputChannels: Object.create(null),
7
7
  }
8
8
 
9
9
  const open = (socket, id, path) => {
10
- console.log({path})
10
+ console.log({ path })
11
11
  Assert.object(socket)
12
12
  // Assert.string(id)
13
13
  Assert.string(path)
@@ -20,22 +20,19 @@ const open = (socket, id, path) => {
20
20
  }
21
21
  const onData = (data) => {
22
22
  console.log('send data', data)
23
- socket.send(
24
- {
25
- jsonrpc: '2.0',
26
- method: 2133,
27
- params: ['Output', 'handleData', data],
28
- }
29
- )
23
+ socket.send({
24
+ jsonrpc: '2.0',
25
+ method: 2133,
26
+ params: ['Output', 'handleData', data],
27
+ })
30
28
  }
31
29
  const onError = (error) => {
32
30
  console.info(`[shared process] output channel error: ${error}`)
33
- socket.send(
34
- {
35
- jsonrpc: '2.0',
36
- method: 2133,
37
- params: ['Output', 'handleError', error],
38
- })
31
+ socket.send({
32
+ jsonrpc: '2.0',
33
+ method: 2133,
34
+ params: ['Output', 'handleError', error],
35
+ })
39
36
  }
40
37
  state.outputChannels[id] = OutputChannel.open(path, onData, onError)
41
38
  }
@@ -45,7 +42,7 @@ const close = (socket, id) => {
45
42
  delete state.outputChannels[id]
46
43
  }
47
44
 
48
- export const __initialize__ = () => {
49
- Command.register('OutputChannel.open', open)
50
- Command.register('OutputChannel.close', close)
45
+ export const Commands = {
46
+ 'OutputChannel.open': open,
47
+ 'OutputChannel.close': close,
51
48
  }
@@ -1,21 +1,19 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Platform from '../Platform/Platform.js'
3
2
 
4
3
  // prettier-ignore
5
- export const __initialize__ = () => {
6
- Command.register('Platform.getConfigDir', Platform.getConfigDir)
7
- Command.register('Platform.getAppDir', Platform.getAppDir)
8
- Command.register('Platform.getHomeDir', Platform.getHomeDir)
9
- Command.register('Platform.getDataDir', Platform.getDataDir)
10
- Command.register('Platform.getExtensionsPath', Platform.getExtensionsPath)
11
- Command.register('Platform.getBuiltinExtensionsPath', Platform.getBuiltinExtensionsPath)
12
- Command.register('Platform.getDisabledExtensionsPath', Platform.getDisabledExtensionsPath)
13
- Command.register('Platform.getCachedExtensionsPath', Platform.getCachedExtensionsPath)
14
- Command.register('Platform.getMarketplaceUrl', Platform.getMarketplaceUrl)
15
- Command.register('Platform.getLogsDir', Platform.getLogsDir)
16
- Command.register('Platform.getUserSettingsPath', Platform.getUserSettingsPath)
17
- Command.register('Platform.getRecentlyOpenedPath', Platform.getRecentlyOpenedPath)
18
- Command.register('Platform.getCacheDir', Platform.getCacheDir)
19
- Command.register('Platform.getCacheDir', Platform.getCacheDir)
20
- Command.register('Platform.setEnvironmentVariables', Platform.setEnvironmentVariables)
4
+ export const Commands = {
5
+ 'Platform.getConfigDir': Platform.getConfigDir,
6
+ 'Platform.getAppDir': Platform.getAppDir,
7
+ 'Platform.getHomeDir': Platform.getHomeDir,
8
+ 'Platform.getDataDir': Platform.getDataDir,
9
+ 'Platform.getExtensionsPath': Platform.getExtensionsPath,
10
+ 'Platform.getBuiltinExtensionsPath': Platform.getBuiltinExtensionsPath,
11
+ 'Platform.getDisabledExtensionsPath': Platform.getDisabledExtensionsPath,
12
+ 'Platform.getCachedExtensionsPath': Platform.getCachedExtensionsPath,
13
+ 'Platform.getMarketplaceUrl': Platform.getMarketplaceUrl,
14
+ 'Platform.getLogsDir': Platform.getLogsDir,
15
+ 'Platform.getUserSettingsPath': Platform.getUserSettingsPath,
16
+ 'Platform.getRecentlyOpenedPath': Platform.getRecentlyOpenedPath,
17
+ 'Platform.getCacheDir': Platform.getCacheDir,
18
+ 'Platform.setEnvironmentVariables': Platform.setEnvironmentVariables,
21
19
  }
@@ -1,6 +1,5 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Preferences from '../Preferences/Preferences.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register("Preferences.getAll", Preferences.getAll)
3
+ export const Commands = {
4
+ 'Preferences.getAll': Preferences.getAll,
6
5
  }
@@ -1,7 +1,6 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Process from './Process.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register(555, Process.crash)
6
- Command.register(556, Process.crashAsync)
3
+ export const Commands = {
4
+ 555: Process.crash,
5
+ 556: Process.crashAsync,
7
6
  }
@@ -1,6 +1,5 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Search from './Search.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register('Search.search', Search.search)
3
+ export const Commands = {
4
+ 'Search.search': Search.search,
6
5
  }
@@ -1,6 +1,5 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as SearchFile from './SearchFile.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register('SearchFile.searchFile', SearchFile.searchFile)
3
+ export const Commands = {
4
+ 'SearchFile.searchFile': SearchFile.searchFile,
6
5
  }
@@ -5,7 +5,7 @@ import * as Terminal from './Terminal.js'
5
5
  const create = (socket, id, cwd) => {
6
6
  Assert.object(socket)
7
7
  if (!socket) {
8
- console.log({socket, id, cwd})
8
+ console.log({ socket, id, cwd })
9
9
  console.warn('socket not available')
10
10
  return
11
11
  }
@@ -25,7 +25,7 @@ const create = (socket, id, cwd) => {
25
25
  }
26
26
 
27
27
  const write = (id, input) => {
28
- console.log({ id, input})
28
+ console.log({ id, input })
29
29
  Terminal.write(id, input)
30
30
  }
31
31
 
@@ -37,9 +37,9 @@ const dispose = (socket, id) => {
37
37
  Terminal.dispose(id)
38
38
  }
39
39
 
40
- export const __initialize__ = () => {
41
- Command.register('Terminal.create', create)
42
- Command.register('Terminal.dispose', dispose)
43
- Command.register('Terminal.write', write)
44
- Command.register('Terminal.resize', resize)
40
+ export const Commands = {
41
+ 'Terminal.create': create,
42
+ 'Terminal.dispose': dispose,
43
+ 'Terminal.write': write,
44
+ 'Terminal.resize': resize,
45
45
  }
@@ -1,6 +1,5 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as TextDocument from './TextDocument.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register(4820, TextDocument.applyEdit)
3
+ export const Commands = {
4
+ 4820: TextDocument.applyEdit,
6
5
  }
@@ -1,6 +1,5 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as WebSocketServer from './WebSocketServer.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register(5621, WebSocketServer.handleUpgrade)
3
+ export const Commands = {
4
+ 5621: WebSocketServer.handleUpgrade,
6
5
  }
@@ -1,7 +1,6 @@
1
- import * as Command from '../Command/Command.js'
2
1
  import * as Workspace from './Workspace.js'
3
2
 
4
- export const __initialize__ = () => {
5
- Command.register('Workspace.resolveRoot', Workspace.resolveRoot)
6
- Command.register('Workspace.getHomeDir', Workspace.getHomeDir)
3
+ export const Commands = {
4
+ 'Workspace.resolveRoot': Workspace.resolveRoot,
5
+ 'Workspace.getHomeDir': Workspace.getHomeDir,
7
6
  }