@lvce-editor/shared-process 0.10.8 → 0.11.0

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 (35) hide show
  1. package/config/defaultKeyBindings.json +12 -22
  2. package/config/defaultSettings.json +4 -2
  3. package/extensions/builtin.language-basics-html/src/tokenizeHtml.js +14 -4
  4. package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +13 -5
  5. package/extensions/builtin.language-basics-json/extension.json +3 -1
  6. package/extensions/builtin.language-basics-json/src/tokenizeJson.js +4 -1
  7. package/extensions/builtin.theme-gruvbox/extension.json +1 -1
  8. package/extensions/builtin.theme-noctis-uva/extension.json +1 -1
  9. package/package.json +4 -4
  10. package/src/parts/ChromeExtension/ChromeExtension.ipc.js +4 -2
  11. package/src/parts/CliLink/CliLink.js +13 -3
  12. package/src/parts/ClipBoard/ClipBoard.ipc.js +4 -2
  13. package/src/parts/Command/Command.js +6 -1
  14. package/src/parts/Developer/Developer.ipc.js +10 -8
  15. package/src/parts/Download/Download.ipc.js +8 -0
  16. package/src/parts/EncodingType/EncodingType.js +1 -0
  17. package/src/parts/ExportStatic/ExportStatic.js +8 -2
  18. package/src/parts/ExtensionInstallFromUrl/ExtensionInstallFromUrl.js +2 -1
  19. package/src/parts/FileSystem/FileSystem.ipc.js +16 -14
  20. package/src/parts/FileSystem/FileSystem.js +17 -5
  21. package/src/parts/Module/Module.js +2 -0
  22. package/src/parts/ModuleId/ModuleId.js +1 -0
  23. package/src/parts/ModuleMap/ModuleMap.js +6 -3
  24. package/src/parts/Native/Native.ipc.js +3 -1
  25. package/src/parts/OutputChannel/OutputChannel.ipc.js +4 -2
  26. package/src/parts/Platform/Platform.ipc.js +20 -17
  27. package/src/parts/Platform/Platform.js +24 -19
  28. package/src/parts/Preferences/Preferences.ipc.js +3 -1
  29. package/src/parts/PtyHostPath/PtyHostPath.js +11 -0
  30. package/src/parts/RecentlyOpened/RecentlyOpened.ipc.js +3 -1
  31. package/src/parts/Search/Search.ipc.js +3 -1
  32. package/src/parts/Search/Search.js +18 -10
  33. package/src/parts/SearchFile/SearchFile.ipc.js +3 -1
  34. package/src/parts/Terminal/Terminal.ipc.js +6 -4
  35. package/src/parts/Terminal/Terminal.js +7 -9
@@ -22,8 +22,8 @@
22
22
  {
23
23
  "key": "Escape",
24
24
  "command": "Viewlet.closeWidget",
25
- "when": "focus.EditorFindWidget",
26
- "args": ["EditorFindWidget"]
25
+ "when": "focus.FindWidget",
26
+ "args": ["FindWidget"]
27
27
  },
28
28
  {
29
29
  "key": "ctrl+ArrowRight",
@@ -329,23 +329,13 @@
329
329
  },
330
330
  {
331
331
  "key": "Escape",
332
- "command": "Explorer.cancelRename",
333
- "when": "focus.ExplorerRename"
332
+ "command": "Explorer.cancelEdit",
333
+ "when": "focus.ExplorerEditBox"
334
334
  },
335
335
  {
336
336
  "key": "Enter",
337
- "command": "Explorer.acceptRename",
338
- "when": "focus.ExplorerRename"
339
- },
340
- {
341
- "key": "Escape",
342
- "command": "Explorer.cancelNewFile",
343
- "when": "focus.ExplorerCreateFile"
344
- },
345
- {
346
- "key": "Enter",
347
- "command": "Explorer.acceptNewFile",
348
- "when": "focus.ExplorerCreateFile"
337
+ "command": "Explorer.acceptEdit",
338
+ "when": "focus.ExplorerEditBox"
349
339
  },
350
340
  {
351
341
  "key": "Delete",
@@ -687,18 +677,18 @@
687
677
  },
688
678
  {
689
679
  "key": "Enter",
690
- "command": "EditorFindWidget.focusNext",
691
- "when": "focus.EditorFindWidget"
680
+ "command": "FindWidget.focusNext",
681
+ "when": "focus.FindWidget"
692
682
  },
693
683
  {
694
684
  "key": "shift+F4",
695
- "command": "EditorFindWidget.focusPrevious",
696
- "when": "focus.EditorFindWidget"
685
+ "command": "FindWidget.focusPrevious",
686
+ "when": "focus.FindWidget"
697
687
  },
698
688
  {
699
689
  "key": "F4",
700
- "command": "EditorFindWidget.focusNext",
701
- "when": "focus.EditorFindWidget"
690
+ "command": "FindWidget.focusNext",
691
+ "when": "focus.FindWidget"
702
692
  },
703
693
  {
704
694
  "key": "ctrl+=",
@@ -6,6 +6,7 @@
6
6
  "editor.fontSize": 15,
7
7
  "editor.fontFamily": "'Fira Code'",
8
8
  "editor.lineHeight": 20,
9
+ "editor.formatOnSave": false,
9
10
 
10
11
  "extensions.autoUpdate": true,
11
12
 
@@ -17,7 +18,7 @@
17
18
  "Thumbs.db": true
18
19
  },
19
20
 
20
- "sessionReplay.enabled": true,
21
+ "sessionReplay.enabled": false,
21
22
 
22
23
  "serviceWorker.enabled": false,
23
24
 
@@ -38,6 +39,7 @@
38
39
  "ctrl+p",
39
40
  "ctrl+shift+p",
40
41
  "ctrl+b",
41
- "ctrl+m"
42
+ "ctrl+m",
43
+ "ctrl+Tab"
42
44
  ]
43
45
  }
@@ -84,7 +84,7 @@ const RE_TAGNAME = /^[!\w]+/
84
84
  const RE_TEXT = /^[^<>\n]+/
85
85
  const RE_WHITESPACE = /^\s+/
86
86
  const RE_WORD = /^[^\s]+/
87
- const RE_ATTRIBUTE_VALUE_UNQUOTED=/^[^<>]+/
87
+ const RE_ATTRIBUTE_VALUE_UNQUOTED = /^[^<>]+/
88
88
 
89
89
  export const initialLineState = {
90
90
  state: State.TopLevelContent,
@@ -145,6 +145,9 @@ export const tokenizeLine = (line, lineState) => {
145
145
  } else if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
146
146
  token = TokenType.PunctuationTag
147
147
  state = State.TopLevelContent
148
+ } else if ((next = part.match(RE_ANGLE_BRACKET_OPEN))) {
149
+ token = TokenType.PunctuationTag
150
+ state = State.AfterOpeningAngleBracket
148
151
  } else if ((next = part.match(RE_ANY_TEXT))) {
149
152
  token = TokenType.Text
150
153
  state = State.TopLevelContent
@@ -178,6 +181,9 @@ export const tokenizeLine = (line, lineState) => {
178
181
  if ((next = part.match(RE_TAGNAME))) {
179
182
  token = TokenType.TagName
180
183
  state = State.AfterClosingTagName
184
+ } else if ((next = part.match(RE_WHITESPACE))) {
185
+ token = TokenType.Whitespace
186
+ state = State.TopLevelContent
181
187
  } else if ((next = part.match(RE_ANY_TEXT))) {
182
188
  token = TokenType.Text
183
189
  state = State.TopLevelContent
@@ -250,9 +256,9 @@ export const tokenizeLine = (line, lineState) => {
250
256
  } else if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
251
257
  token = TokenType.PunctuationTag
252
258
  state = State.TopLevelContent
253
- }else if((next=part.match(RE_ATTRIBUTE_VALUE_UNQUOTED))){
254
- token=TokenType.String
255
- state=State.InsideOpeningTag
259
+ } else if ((next = part.match(RE_ATTRIBUTE_VALUE_UNQUOTED))) {
260
+ token = TokenType.String
261
+ state = State.InsideOpeningTag
256
262
  } else {
257
263
  part
258
264
  throw new Error('no')
@@ -299,10 +305,14 @@ export const tokenizeLine = (line, lineState) => {
299
305
  state
300
306
  throw new Error('no')
301
307
  }
308
+
302
309
  const tokenLength = next[0].length
303
310
  index += tokenLength
304
311
  tokens.push(token, tokenLength)
305
312
  }
313
+ if (state === State.AfterClosingTagAngleBrackets) {
314
+ state = State.TopLevelContent
315
+ }
306
316
  return {
307
317
  state,
308
318
  tokens,
@@ -49,6 +49,7 @@ export const TokenType = {
49
49
  KeywordReturn: 883,
50
50
  KeywordNew: 884,
51
51
  FunctionName: 885,
52
+ KeywordThis: 886,
52
53
  }
53
54
 
54
55
  export const TokenMap = {
@@ -75,6 +76,7 @@ export const TokenMap = {
75
76
  [TokenType.KeywordReturn]: 'KeywordReturn',
76
77
  [TokenType.KeywordNew]: 'KeywordNew',
77
78
  [TokenType.FunctionName]: 'Function',
79
+ [TokenType.KeywordThis]: 'KeywordThis',
78
80
  }
79
81
 
80
82
  const RE_KEYWORD =
@@ -113,7 +115,7 @@ const RE_QUOTE_DOUBLE = /^"/
113
115
  const RE_QUOTE_BACKTICK = /^`/
114
116
  const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^'\\]+/
115
117
  const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\\]+/
116
- const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`]+/
118
+ const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`\\]+/
117
119
  const RE_STRING_ESCAPE = /^\\./
118
120
  const RE_SHEBANG = /^#!.*/
119
121
  const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\(|\=\s*function|\=\s*\())/
@@ -179,6 +181,9 @@ export const tokenizeLine = (line, lineState) => {
179
181
  case 'new':
180
182
  token = TokenType.KeywordNew
181
183
  break
184
+ case 'this':
185
+ token = TokenType.KeywordThis
186
+ break
182
187
  default:
183
188
  token = TokenType.Keyword
184
189
  break
@@ -251,12 +256,12 @@ export const tokenizeLine = (line, lineState) => {
251
256
  }
252
257
  break
253
258
  case State.InsideBlockComment:
254
- if ((next = part.match(RE_BLOCK_COMMENT_CONTENT))) {
255
- token = TokenType.Comment
256
- state = State.InsideBlockComment
257
- } else if ((next = part.match(RE_BLOCK_COMMENT_END))) {
259
+ if ((next = part.match(RE_BLOCK_COMMENT_END))) {
258
260
  token = TokenType.Comment
259
261
  state = State.TopLevelContent
262
+ } else if ((next = part.match(RE_BLOCK_COMMENT_CONTENT))) {
263
+ token = TokenType.Comment
264
+ state = State.InsideBlockComment
260
265
  } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
261
266
  token = TokenType.Comment
262
267
  state = State.InsideBlockComment
@@ -299,6 +304,9 @@ export const tokenizeLine = (line, lineState) => {
299
304
  } else if ((next = part.match(RE_STRING_BACKTICK_QUOTE_CONTENT))) {
300
305
  token = TokenType.String
301
306
  state = State.InsideBacktickString
307
+ } else if ((next = part.match(RE_STRING_ESCAPE))) {
308
+ token = TokenType.String
309
+ state = State.InsideBacktickString
302
310
  } else {
303
311
  throw new Error('no')
304
312
  }
@@ -41,7 +41,9 @@
41
41
  ".stylelintrc",
42
42
  ".parcelrc",
43
43
  ".publishrc",
44
- ".whitesource"
44
+ ".whitesource",
45
+ ".mention-bot",
46
+ "pdfjs.config"
45
47
  ],
46
48
  "tokenize": "src/tokenizeJson.js"
47
49
  }
@@ -255,7 +255,7 @@ export const tokenizeLine = (line, lineState) => {
255
255
  state = State.AfterPropertyValue
256
256
  } else if ((next = part.match(RE_TEXT))) {
257
257
  token = TokenType.Text
258
- state = State.TopLevelContent
258
+ state = State.AfterCurlyOpen
259
259
  } else if ((next = part.match(RE_CURLY_OPEN))) {
260
260
  token = TokenType.Punctuation
261
261
  state = State.AfterCurlyOpen
@@ -311,6 +311,9 @@ export const tokenizeLine = (line, lineState) => {
311
311
  if (state === State.InsideLineComment) {
312
312
  state = State.TopLevelContent
313
313
  }
314
+ if (state === State.AfterPropertyValue) {
315
+ state = State.AfterCurlyOpen
316
+ }
314
317
  return {
315
318
  state,
316
319
  stack,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "builtin.theme-gruvbox",
3
- "name": "Gruvbox",
3
+ "name": "Gruvbox Theme",
4
4
  "description": "Theme based on gruvbox-material-vscode theme by sainnhe",
5
5
  "colorThemes": [
6
6
  {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "builtin.theme-noctis-uva",
3
- "name": "Theme Noctis Uva",
3
+ "name": "Noctis Uva Theme",
4
4
  "description": "",
5
5
  "colorThemes": [
6
6
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.10.8",
3
+ "version": "0.11.0",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,8 +20,8 @@
20
20
  "node": ">=16"
21
21
  },
22
22
  "dependencies": {
23
- "@lvce-editor/extension-host": "0.10.8",
24
- "@lvce-editor/pty-host": "0.10.8",
23
+ "@lvce-editor/extension-host": "0.11.0",
24
+ "@lvce-editor/pty-host": "0.11.0",
25
25
  "debug": "^4.3.4",
26
26
  "execa": "^6.1.0",
27
27
  "exit-hook": "^3.1.2",
@@ -36,7 +36,7 @@
36
36
  "tmp-promise": "^3.0.3",
37
37
  "trash": "^8.1.0",
38
38
  "verror": "^1.10.1",
39
- "ws": "^8.9.0",
39
+ "ws": "^8.11.0",
40
40
  "xdg-basedir": "^5.1.0"
41
41
  },
42
42
  "optionalDependencies": {
@@ -1,6 +1,8 @@
1
1
  import * as ChromeExtension from './ChromeExtension.js'
2
2
 
3
+ export const name = 'ChromeExtension'
4
+
3
5
  export const Commands = {
4
- 'ChromeExtension.install': ChromeExtension.install,
5
- 'ChromeExtension.uninstall': ChromeExtension.uninstall,
6
+ install: ChromeExtension.install,
7
+ uninstall: ChromeExtension.uninstall,
6
8
  }
@@ -1,6 +1,16 @@
1
1
  import * as ExtensionLink from '../ExtensionLink/ExtensionLink.js'
2
+ import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
2
3
 
3
- export const handleCliArgs = async (argv, console) => {
4
- const path = argv.length > 1 ? argv[1] : process.cwd()
5
- await ExtensionLink.link(path)
4
+ export const handleCliArgs = async (argv) => {
5
+ try {
6
+ const path = argv.length > 1 ? argv[1] : process.cwd()
7
+ await ExtensionLink.link(path)
8
+ } catch (error) {
9
+ if (error && error.code === FileSystemErrorCodes.E_MANIFEST_NOT_FOUND) {
10
+ console.error(error.message)
11
+ process.exitCode = 128
12
+ return
13
+ }
14
+ throw error
15
+ }
6
16
  }
@@ -1,6 +1,8 @@
1
1
  import * as ClipBoard from './ClipBoard.js'
2
2
 
3
+ export const name = 'ClipBoard'
4
+
3
5
  export const Commands = {
4
- 'ClipBoard.readFiles': ClipBoard.readFiles,
5
- 'ClipBoard.writeFiles': ClipBoard.writeFiles,
6
+ readFiles: ClipBoard.readFiles,
7
+ writeFiles: ClipBoard.writeFiles,
6
8
  }
@@ -8,7 +8,12 @@ const pendingModules = Object.create(null)
8
8
  const initializeModule = (module) => {
9
9
  if (module.Commands) {
10
10
  for (const [key, value] of Object.entries(module.Commands)) {
11
- register(key, value)
11
+ if (module.name) {
12
+ const actualKey = `${module.name}.${key}`
13
+ register(actualKey, value)
14
+ } else {
15
+ register(key, value)
16
+ }
12
17
  }
13
18
  return
14
19
  }
@@ -1,13 +1,15 @@
1
1
  import * as Developer from './Developer.js'
2
2
 
3
+ export const name = 'Developer'
4
+
3
5
  // prettier-ignore
4
6
  export const Commands = {
5
- 'Developer.allocateMemory': Developer.allocateMemory,
6
- 'Developer.crashSharedProcess': Developer.crashSharedProcess,
7
- 'Developer.createHeapSnapshot': Developer.createHeapSnapshot,
8
- 'Developer.createProfile': Developer.createProfile,
9
- 'Developer.getNodeStartupTime': Developer.getNodeStartupTiming,
10
- 'Developer.getNodeStartupTiming': Developer.getNodeStartupTiming,
11
- 'Developer.sharedProcessMemoryUsage': Developer.sharedProcessMemoryUsage,
12
- 'Developer.sharedProcessStartupPerformance': Developer.sharedProcessStartupPerformance,
7
+ allocateMemory: Developer.allocateMemory,
8
+ crashSharedProcess: Developer.crashSharedProcess,
9
+ createHeapSnapshot: Developer.createHeapSnapshot,
10
+ createProfile: Developer.createProfile,
11
+ getNodeStartupTime: Developer.getNodeStartupTiming,
12
+ getNodeStartupTiming: Developer.getNodeStartupTiming,
13
+ sharedProcessMemoryUsage: Developer.sharedProcessMemoryUsage,
14
+ sharedProcessStartupPerformance: Developer.sharedProcessStartupPerformance,
13
15
  }
@@ -0,0 +1,8 @@
1
+ import * as Download from './Download.js'
2
+
3
+ export const name = 'Download'
4
+
5
+ // prettier-ignore
6
+ export const Commands = {
7
+ download: Download.download,
8
+ }
@@ -0,0 +1 @@
1
+ export const Utf8 = 'utf8'
@@ -358,9 +358,15 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
358
358
  `/${commitHash}`,
359
359
  `${pathPrefix}/${commitHash}`
360
360
  )
361
-
362
361
  await replace(
363
- Path.join(root, 'dist', commitHash, 'css', 'App.css'),
362
+ Path.join(
363
+ root,
364
+ 'dist',
365
+ commitHash,
366
+ 'css',
367
+ 'parts',
368
+ 'ViewletTitleBarButtons.css'
369
+ ),
364
370
  `/${commitHash}`,
365
371
  `${pathPrefix}/${commitHash}`
366
372
  )
@@ -5,6 +5,7 @@ import * as Download from '../Download/Download.js'
5
5
  import * as Extract from '../Extract/Extract.js'
6
6
  import * as Platform from '../Platform/Platform.js'
7
7
  import * as TmpFile from '../TmpFile/TmpFile.js'
8
+ import * as EncodingType from '../EncodingType/EncodingType.js'
8
9
 
9
10
  export const install = async ({ url }) => {
10
11
  try {
@@ -17,7 +18,7 @@ export const install = async ({ url }) => {
17
18
  const tmpDir = await TmpFile.getTmpDir()
18
19
  await Extract.extractTarBr(tmpFile, tmpDir)
19
20
  const manifestPath = join(tmpDir, 'extension.json')
20
- const manifestContent = await readFile(manifestPath, 'utf8')
21
+ const manifestContent = await readFile(manifestPath, EncodingType.Utf8)
21
22
  const manifestJson = JSON.parse(manifestContent)
22
23
  const id = manifestJson.id
23
24
  if (!id) {
@@ -13,20 +13,22 @@ const fileSystemWatch = (socket, id, path) => {
13
13
  // })
14
14
  }
15
15
 
16
+ export const name = 'FileSystem'
17
+
16
18
  // TODO separate ipc from code like in renderer worker
17
19
  export const Commands = {
18
- 'FileSystem.chmod': FileSystem.chmod,
19
- 'FileSystem.copy': FileSystem.copy,
20
- 'FileSystem.createFile': FileSystem.createFile,
21
- 'FileSystem.createFolder': FileSystem.createFolder,
22
- 'FileSystem.ensureFile': FileSystem.ensureFile,
23
- 'FileSystem.getPathSeparator': FileSystem.getPathSeparator,
24
- 'FileSystem.getRealPath': FileSystem.getRealPath,
25
- 'FileSystem.mkdir': FileSystem.mkdir,
26
- 'FileSystem.readDirWithFileTypes': FileSystem.readDirWithFileTypes,
27
- 'FileSystem.readFile': FileSystem.readFile,
28
- 'FileSystem.remove': FileSystem.remove,
29
- 'FileSystem.rename': FileSystem.rename,
30
- 'FileSystem.stat': FileSystem.stat,
31
- 'FileSystem.writeFile': FileSystem.writeFile,
20
+ chmod: FileSystem.chmod,
21
+ copy: FileSystem.copy,
22
+ createFile: FileSystem.createFile,
23
+ createFolder: FileSystem.createFolder,
24
+ ensureFile: FileSystem.ensureFile,
25
+ getPathSeparator: FileSystem.getPathSeparator,
26
+ getRealPath: FileSystem.getRealPath,
27
+ mkdir: FileSystem.mkdir,
28
+ readDirWithFileTypes: FileSystem.readDirWithFileTypes,
29
+ readFile: FileSystem.readFile,
30
+ remove: FileSystem.remove,
31
+ rename: FileSystem.rename,
32
+ stat: FileSystem.stat,
33
+ writeFile: FileSystem.writeFile,
32
34
  }
@@ -3,11 +3,12 @@ import * as fs from 'node:fs/promises'
3
3
  import * as os from 'node:os'
4
4
  import VError from 'verror'
5
5
  import * as DirentType from '../DirentType/DirentType.js'
6
+ import { FileNotFoundError } from '../Error/FileNotFoundError.js'
7
+ import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
6
8
  import * as Path from '../Path/Path.js'
7
9
  import * as Platform from '../Platform/Platform.js'
8
10
  import * as Trash from '../Trash/Trash.js'
9
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
10
- import { FileNotFoundError } from '../Error/FileNotFoundError.js'
11
+ import * as EncodingType from '../EncodingType/EncodingType.js'
11
12
 
12
13
  export const state = {
13
14
  watcherMap: Object.create(null),
@@ -33,12 +34,19 @@ export const copy = async (source, target) => {
33
34
  }
34
35
 
35
36
  // TODO extensions should only be accessed once on startup
36
- export const readFile = async (path) => {
37
+
38
+ /**
39
+ *
40
+ * @param {string} path
41
+ * @param {BufferEncoding} encoding
42
+ * @returns
43
+ */
44
+ export const readFile = async (path, encoding = EncodingType.Utf8) => {
37
45
  // console.info('[shared-process] read file', path)
38
46
  try {
39
47
  // const start = performance.now()
40
48
  // console.time(`read ${path}`)
41
- const content = await fs.readFile(path, 'utf8')
49
+ const content = await fs.readFile(path, encoding)
42
50
  // const end = performance.now()
43
51
  // console.log('read', path, 'took', (end - start).toFixed(2), 'ms')
44
52
  // console.timeEnd(`read ${path}`)
@@ -57,7 +65,11 @@ export const readFile = async (path) => {
57
65
  * @param {string} content
58
66
  * @param {BufferEncoding} encoding
59
67
  */
60
- export const writeFile = async (path, content, encoding = 'utf8') => {
68
+ export const writeFile = async (
69
+ path,
70
+ content,
71
+ encoding = EncodingType.Utf8
72
+ ) => {
61
73
  try {
62
74
  // queue would be more correct for concurrent writes but also slower
63
75
  // Queue.add(`writeFile/${path}`, () =>
@@ -8,6 +8,8 @@ export const load = (moduleId) => {
8
8
  return import('../ClipBoard/ClipBoard.ipc.js')
9
9
  case ModuleId.Developer:
10
10
  return import('../Developer/Developer.ipc.js')
11
+ case ModuleId.Download:
12
+ return import('../Download/Download.ipc.js')
11
13
  case ModuleId.ExtensionHost:
12
14
  return import('../ExtensionHost/ExtensionHost.ipc.js')
13
15
  case ModuleId.ExtensionManagement:
@@ -15,3 +15,4 @@ export const TextDocument = 14
15
15
  export const WebSocketServer = 15
16
16
  export const Workspace = 16
17
17
  export const ChromeExtension = 17
18
+ export const Download = 18
@@ -17,7 +17,8 @@ export const getModuleId = (commandId) => {
17
17
  case 'Developer.sharedProcessMemoryUsage':
18
18
  case 'Developer.sharedProcessStartupPerformance':
19
19
  return ModuleId.Developer
20
- case 'EXtensionHostRename.executePrepareRename':
20
+ case 'Download.download':
21
+ return ModuleId.Download
21
22
  case 'ExtensionHost.dispose':
22
23
  case 'ExtensionHost.enableExtension':
23
24
  case 'ExtensionHost.executeCommand':
@@ -52,14 +53,15 @@ export const getModuleId = (commandId) => {
52
53
  case 'ExtensionHostOutput.getOutputChannels':
53
54
  case 'ExtensionHostQuickPick.handleQuickPickResult':
54
55
  case 'ExtensionHostReferences.executeReferenceProvider':
56
+ case 'EXtensionHostRename.executePrepareRename':
55
57
  case 'ExtensionHostRename.executeRename':
56
58
  case 'ExtensionHostSemanticTokens.executeSemanticTokenProvider':
57
59
  case 'ExtensionHostSourceControl.acceptInput':
58
- case 'ExtensionHostTextDocument':
59
60
  case 'ExtensionHostTextDocument.setLanguageId':
60
61
  case 'ExtensionHostTextDocument.syncFull':
61
62
  case 'ExtensionHostTextDocument.syncIncremental':
62
63
  case 'ExtensionHostTextDocument.syncInitial':
64
+ case 'ExtensionHostTextDocument':
63
65
  case 'ExtensionHostWorkspace.setWorkspacePath':
64
66
  return ModuleId.ExtensionHost
65
67
  case 'ExtensionHost.getColorThemeJson':
@@ -97,11 +99,12 @@ export const getModuleId = (commandId) => {
97
99
  return ModuleId.OutputChannel
98
100
  case 'Platform.getAppDir':
99
101
  case 'Platform.getBuiltinExtensionsPath':
100
- case 'Platform.getCacheDir':
101
102
  case 'Platform.getCachedExtensionsPath':
103
+ case 'Platform.getCacheDir':
102
104
  case 'Platform.getConfigDir':
103
105
  case 'Platform.getDataDir':
104
106
  case 'Platform.getDisabledExtensionsPath':
107
+ case 'Platform.getDownloadDir':
105
108
  case 'Platform.getExtensionsPath':
106
109
  case 'Platform.getHomeDir':
107
110
  case 'Platform.getLogsDir':
@@ -1,5 +1,7 @@
1
1
  import * as Native from './Native.js'
2
2
 
3
+ export const name = 'Native'
4
+
3
5
  export const Commands = {
4
- 'Native.openFolder': Native.openFolder,
6
+ openFolder: Native.openFolder,
5
7
  }
@@ -42,7 +42,9 @@ const close = (socket, id) => {
42
42
  delete state.outputChannels[id]
43
43
  }
44
44
 
45
+ export const name = 'OutputChannel'
46
+
45
47
  export const Commands = {
46
- 'OutputChannel.close': close,
47
- 'OutputChannel.open': open,
48
+ close: close,
49
+ open: open,
48
50
  }
@@ -1,22 +1,25 @@
1
1
  import * as Platform from '../Platform/Platform.js'
2
2
 
3
+ export const name = 'Platform'
4
+
3
5
  // prettier-ignore
4
6
  export const Commands = {
5
- 'Platform.getAppDir': Platform.getAppDir,
6
- 'Platform.getBuiltinExtensionsPath': Platform.getBuiltinExtensionsPath,
7
- 'Platform.getCacheDir': Platform.getCacheDir,
8
- 'Platform.getCachedExtensionsPath': Platform.getCachedExtensionsPath,
9
- 'Platform.getConfigDir': Platform.getConfigDir,
10
- 'Platform.getDataDir': Platform.getDataDir,
11
- 'Platform.getDisabledExtensionsPath': Platform.getDisabledExtensionsPath,
12
- 'Platform.getExtensionsPath': Platform.getExtensionsPath,
13
- 'Platform.getHomeDir': Platform.getHomeDir,
14
- 'Platform.getLogsDir': Platform.getLogsDir,
15
- 'Platform.getMarketplaceUrl': Platform.getMarketplaceUrl,
16
- 'Platform.getNodePath': Platform.getNodePath,
17
- 'Platform.getRecentlyOpenedPath': Platform.getRecentlyOpenedPath,
18
- 'Platform.getTestPath': Platform.getTestPath,
19
- 'Platform.getTmpDir': Platform.getTmpDir,
20
- 'Platform.getUserSettingsPath': Platform.getUserSettingsPath,
21
- 'Platform.setEnvironmentVariables': Platform.setEnvironmentVariables,
7
+ getAppDir: Platform.getAppDir,
8
+ getBuiltinExtensionsPath: Platform.getBuiltinExtensionsPath,
9
+ getCachedExtensionsPath: Platform.getCachedExtensionsPath,
10
+ getCacheDir: Platform.getCacheDir,
11
+ getConfigDir: Platform.getConfigDir,
12
+ getDataDir: Platform.getDataDir,
13
+ getDisabledExtensionsPath: Platform.getDisabledExtensionsPath,
14
+ getDownloadDir: Platform.getDownloadDir,
15
+ getExtensionsPath: Platform.getExtensionsPath,
16
+ getHomeDir: Platform.getHomeDir,
17
+ getLogsDir: Platform.getLogsDir,
18
+ getMarketplaceUrl: Platform.getMarketplaceUrl,
19
+ getNodePath: Platform.getNodePath,
20
+ getRecentlyOpenedPath: Platform.getRecentlyOpenedPath,
21
+ getTestPath: Platform.getTestPath,
22
+ getTmpDir: Platform.getTmpDir,
23
+ getUserSettingsPath: Platform.getUserSettingsPath,
24
+ setEnvironmentVariables: Platform.setEnvironmentVariables,
22
25
  }
@@ -1,16 +1,18 @@
1
1
  import { extensionHostPath } from '@lvce-editor/extension-host'
2
2
  import { homedir, tmpdir } from 'node:os'
3
- import { resolve, sep } from 'node:path'
3
+ import { join, resolve, sep } from 'node:path'
4
4
  import { pathToFileURL } from 'node:url'
5
5
  import { xdgCache, xdgConfig, xdgData, xdgState } from 'xdg-basedir'
6
6
  import * as Path from '../Path/Path.js'
7
7
  import * as Root from '../Root/Root.js'
8
8
 
9
+ const { env, platform } = process
10
+
9
11
  export const applicationName = 'lvce-oss'
10
12
 
11
- export const isWindows = process.platform === 'win32'
13
+ export const isWindows = platform === 'win32'
12
14
 
13
- export const isMacOs = process.platform === 'darwin'
15
+ export const isMacOs = platform === 'darwin'
14
16
 
15
17
  export const dataDir = Path.join(xdgData || tmpdir(), applicationName)
16
18
 
@@ -52,28 +54,28 @@ export const getChromeExtensionsPath = () => {
52
54
 
53
55
  export const getMarketplaceUrl = () => {
54
56
  return (
55
- process.env.LVCE_MARKETPLACE_URL ||
56
- 'https://marketplace.22e924c84de072d4b25b.com'
57
+ env.LVCE_MARKETPLACE_URL || 'https://marketplace.22e924c84de072d4b25b.com'
57
58
  )
58
59
  }
59
60
 
60
61
  export const getDesktop = () => {
62
+ const { ORIGINAL_XDG_CURRENT_DESKTOP, XDG_CURRENT_DESKTOP } = env
61
63
  if (
62
- process.env.ORIGINAL_XDG_CURRENT_DESKTOP &&
63
- process.env.ORIGINAL_XDG_CURRENT_DESKTOP !== 'undefined'
64
+ ORIGINAL_XDG_CURRENT_DESKTOP &&
65
+ ORIGINAL_XDG_CURRENT_DESKTOP !== 'undefined'
64
66
  ) {
65
- if (process.env.ORIGINAL_XDG_CURRENT_DESKTOP === 'ubuntu:GNOME') {
67
+ if (ORIGINAL_XDG_CURRENT_DESKTOP === 'ubuntu:GNOME') {
66
68
  return 'gnome'
67
69
  }
68
- return process.env.ORIGINAL_XDG_CURRENT_DESKTOP
70
+ return ORIGINAL_XDG_CURRENT_DESKTOP
69
71
  }
70
- if (process.env.XDG_CURRENT_DESKTOP) {
71
- if (process.env.XDG_CURRENT_DESKTOP === 'ubuntu:GNOME') {
72
+ if (XDG_CURRENT_DESKTOP) {
73
+ if (XDG_CURRENT_DESKTOP === 'ubuntu:GNOME') {
72
74
  return 'gnome'
73
75
  }
74
- return process.env.XDG_CURRENT_DESKTOP
76
+ return XDG_CURRENT_DESKTOP
75
77
  }
76
- if (process.platform === 'win32') {
78
+ if (isWindows) {
77
79
  return 'windows'
78
80
  }
79
81
  return ''
@@ -108,17 +110,15 @@ export const getDefaultSettingsPath = () => {
108
110
  }
109
111
  export const setEnvironmentVariables = (variables) => {
110
112
  for (const [key, value] of Object.entries(variables)) {
111
- process.env[key] = value
113
+ env[key] = value
112
114
  }
113
115
  }
114
116
 
115
117
  export const getTestPath = () => {
116
- if (process.env.TEST_PATH) {
118
+ if (env.TEST_PATH) {
117
119
  const testPath =
118
120
  '/remote' +
119
- pathToFileURL(Path.join(process.cwd(), process.env.TEST_PATH))
120
- .toString()
121
- .slice(7)
121
+ pathToFileURL(Path.join(process.cwd(), env.TEST_PATH)).toString().slice(7)
122
122
  return testPath
123
123
  }
124
124
  return '/packages/extension-host-worker-tests'
@@ -133,7 +133,7 @@ export const getTmpDir = () => {
133
133
  }
134
134
 
135
135
  export const getOnlyExtensionPath = () => {
136
- const onlyExtensionPath = process.env.ONLY_EXTENSION
136
+ const onlyExtensionPath = env.ONLY_EXTENSION
137
137
  if (onlyExtensionPath) {
138
138
  return resolve(onlyExtensionPath)
139
139
  }
@@ -159,3 +159,8 @@ export const getDataDir = () => {
159
159
  export const getHomeDir = () => {
160
160
  return homeDir
161
161
  }
162
+
163
+ export const getDownloadDir = () => {
164
+ const { XDG_DOWNLOAD_DIR } = env
165
+ return XDG_DOWNLOAD_DIR || join(homeDir, 'Downloads')
166
+ }
@@ -1,5 +1,7 @@
1
1
  import * as Preferences from '../Preferences/Preferences.js'
2
2
 
3
+ export const name = 'Preferences'
4
+
3
5
  export const Commands = {
4
- 'Preferences.getAll': Preferences.getAll,
6
+ getAll: Preferences.getAll,
5
7
  }
@@ -0,0 +1,11 @@
1
+ import * as Root from '../Root/Root.js'
2
+ import * as Path from '../Path/Path.js'
3
+
4
+ export const getPtyHostPath = async () => {
5
+ try {
6
+ const { ptyHostPath } = await import('@lvce-editor/pty-host')
7
+ return ptyHostPath
8
+ } catch {
9
+ return Path.join(Root.root, 'packages', 'pty-host', 'src', 'ptyHostMain.js')
10
+ }
11
+ }
@@ -1,5 +1,7 @@
1
1
  import * as RecentlyOpened from './RecentlyOpened.js'
2
2
 
3
+ export const name = 'RecentlyOpened'
4
+
3
5
  export const Commands = {
4
- 'RecentlyOpened.addPath': RecentlyOpened.addPath,
6
+ addPath: RecentlyOpened.addPath,
5
7
  }
@@ -1,5 +1,7 @@
1
1
  import * as Search from './Search.js'
2
2
 
3
+ export const name = 'Search'
4
+
3
5
  export const Commands = {
4
- 'Search.search': Search.search,
6
+ search: Search.search,
5
7
  }
@@ -4,10 +4,13 @@ import * as Platform from '../Platform/Platform.js'
4
4
 
5
5
  const MAX_SEARCH_RESULTS = 300
6
6
 
7
- const toSearchResult = (parsedLine) => ({
8
- preview: parsedLine.data.lines.text,
9
- absoluteOffset: parsedLine.data.absolute_offset,
10
- })
7
+ const toSearchResult = (parsedLine) => {
8
+ return {
9
+ preview: parsedLine.data.lines.text,
10
+ absoluteOffset: parsedLine.data.absolute_offset,
11
+ lineNumber: parsedLine.data.line_number - 1,
12
+ }
13
+ }
11
14
 
12
15
  // TODO update vscode-ripgrep when https://github.com/mhinz/vim-grepper/issues/244, https://github.com/BurntSushi/ripgrep/issues/1892 is fixed
13
16
 
@@ -59,7 +62,8 @@ export const search = async (searchDir, searchString) => {
59
62
  let stats = {}
60
63
  let numberOfResults = 0
61
64
  // TODO use pipeline / transform stream maybe
62
- childProcess.stdout.on('data', (chunk) => {
65
+
66
+ const handleData = (chunk) => {
63
67
  buffer += chunk
64
68
  const lines = buffer.split('\n')
65
69
  // @ts-ignore
@@ -88,20 +92,24 @@ export const search = async (searchDir, searchString) => {
88
92
  if (numberOfResults > MAX_SEARCH_RESULTS) {
89
93
  childProcess.kill()
90
94
  }
91
- })
92
- childProcess.once('close', () => {
95
+ }
96
+
97
+ const handleClose = () => {
93
98
  resolve({
94
99
  results: Object.entries(allSearchResults),
95
100
  stats,
96
101
  })
97
- })
98
- childProcess.once('error', (error) => {
102
+ }
103
+ const handleError = (error) => {
99
104
  // TODO check type of error
100
105
  console.error(error)
101
106
  resolve({
102
107
  results: [],
103
108
  stats,
104
109
  })
105
- })
110
+ }
111
+ childProcess.stdout.on('data', handleData)
112
+ childProcess.once('close', handleClose)
113
+ childProcess.once('error', handleError)
106
114
  })
107
115
  }
@@ -1,5 +1,7 @@
1
1
  import * as SearchFile from './SearchFile.js'
2
2
 
3
+ export const name = 'SearchFile'
4
+
3
5
  export const Commands = {
4
- 'SearchFile.searchFile': SearchFile.searchFile,
6
+ searchFile: SearchFile.searchFile,
5
7
  }
@@ -37,9 +37,11 @@ const dispose = (socket, id) => {
37
37
  Terminal.dispose(id)
38
38
  }
39
39
 
40
+ export const name = 'Terminal'
41
+
40
42
  export const Commands = {
41
- 'Terminal.create': create,
42
- 'Terminal.dispose': dispose,
43
- 'Terminal.resize': resize,
44
- 'Terminal.write': write,
43
+ create: create,
44
+ dispose: dispose,
45
+ resize: resize,
46
+ write: write,
45
47
  }
@@ -1,10 +1,8 @@
1
- import { ChildProcess, fork } from 'node:child_process'
2
1
  import exitHook from 'exit-hook'
3
- import { ptyHostPath } from '@lvce-editor/pty-host'
4
- import * as Debug from '../Debug/Debug.js'
5
- import * as Path from '../Path/Path.js'
6
- import * as Root from '../Root/Root.js'
2
+ import { ChildProcess, fork } from 'node:child_process'
7
3
  import * as Assert from '../Assert/Assert.js'
4
+ import * as Debug from '../Debug/Debug.js'
5
+ import * as PtyHostPath from '../PtyHostPath/PtyHostPath.js'
8
6
 
9
7
  export const state = {
10
8
  /**
@@ -45,8 +43,9 @@ const handleProcessExit = () => {
45
43
  cleanUpAll()
46
44
  }
47
45
 
48
- const createPtyHost = () => {
46
+ const createPtyHost = async () => {
49
47
  exitHook(handleProcessExit)
48
+ const ptyHostPath = await PtyHostPath.getPtyHostPath()
50
49
  const ptyHost = fork(ptyHostPath, { stdio: 'inherit' })
51
50
  return ptyHost
52
51
  }
@@ -60,17 +59,16 @@ const createPtyHost = () => {
60
59
  // })
61
60
  // }
62
61
 
63
- export const create = (socket, id, cwd) => {
62
+ export const create = async (socket, id, cwd) => {
64
63
  Assert.object(socket)
65
64
  Assert.number(id)
66
65
  Assert.string(cwd)
67
66
 
68
- console.log('create terminal')
69
67
  Debug.debug('creating pty host')
70
68
  switch (state.ptyHostState) {
71
69
  case /* None */ 0: {
72
70
  state.ptyHostState = /* Creating */ 1
73
- const ptyHost = createPtyHost()
71
+ const ptyHost = await createPtyHost()
74
72
  const handleFirstMessage = () => {
75
73
  Debug.debug('pty host ready')
76
74
  state.ptyHostState = /* Ready */ 2