@lvce-editor/shared-process 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -190,6 +190,9 @@ export const tokenizeLine = (line, lineState) => {
190
190
  } else if ((next = part.match(RE_SELECTOR))) {
191
191
  token = TokenType.CssSelector
192
192
  state = State.AfterSelector
193
+ } else if ((next = part.match(RE_SELECTOR_ID))) {
194
+ token = TokenType.CssSelectorId
195
+ state = State.AfterSelector
193
196
  } else if ((next = part.match(RE_COMMA))) {
194
197
  token = TokenType.Punctuation
195
198
  state = State.AfterSelector
@@ -57,7 +57,7 @@ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
57
57
  const RE_KEYWORD =
58
58
  /^(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)\b/
59
59
 
60
- const RE_VARIABLE_NAME = /^[a-zA-Z\_]+/
60
+ const RE_VARIABLE_NAME = /^[a-zA-Z\_\/\-]+/
61
61
  const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)<>]/
62
62
  const RE_NUMERIC = /^\d+/
63
63
 
@@ -220,6 +220,10 @@
220
220
  {
221
221
  "name": "YamlPropertyValueString",
222
222
  "foreground": "#8CAEC1"
223
+ },
224
+ {
225
+ "name": "CssAtRule",
226
+ "foreground": "#E78484"
223
227
  }
224
228
  ]
225
229
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,12 +20,12 @@
20
20
  "node": ">=16"
21
21
  },
22
22
  "dependencies": {
23
- "@lvce-editor/extension-host": "0.11.0",
24
- "@lvce-editor/pty-host": "0.11.0",
23
+ "@lvce-editor/extension-host": "0.11.1",
24
+ "@lvce-editor/pty-host": "0.11.1",
25
25
  "debug": "^4.3.4",
26
26
  "execa": "^6.1.0",
27
27
  "exit-hook": "^3.1.2",
28
- "got": "^12.5.2",
28
+ "got": "^12.5.3",
29
29
  "is-object": "^1.0.2",
30
30
  "lines-and-columns": "^2.0.3",
31
31
  "open": "^8.4.0",
@@ -42,7 +42,7 @@
42
42
  "optionalDependencies": {
43
43
  "electron-clipboard-ex": "^1.3.3",
44
44
  "keytar": "^7.9.0",
45
- "vscode-ripgrep-with-github-api-error-fix": "^2.5.0",
45
+ "vscode-ripgrep-with-github-api-error-fix": "^2.6.0",
46
46
  "extract-zip": "^2.0.1"
47
47
  },
48
48
  "devDependencies": {
@@ -1,12 +1,12 @@
1
1
  import * as ExtensionLink from '../ExtensionLink/ExtensionLink.js'
2
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
2
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
3
3
 
4
4
  export const handleCliArgs = async (argv) => {
5
5
  try {
6
6
  const path = argv.length > 1 ? argv[1] : process.cwd()
7
7
  await ExtensionLink.link(path)
8
8
  } catch (error) {
9
- if (error && error.code === FileSystemErrorCodes.E_MANIFEST_NOT_FOUND) {
9
+ if (error && error.code === ErrorCodes.E_MANIFEST_NOT_FOUND) {
10
10
  console.error(error.message)
11
11
  process.exitCode = 128
12
12
  return
@@ -1,13 +1,11 @@
1
- export const File = 'file'
2
-
3
- export const Direcory = 'directory'
4
-
5
- export const Symlink = 'symlink'
6
-
7
- export const Socket = 'socket'
8
-
9
- export const BlockDevice = 'block-device'
10
-
11
- export const CharacterDevice = 'character-device'
12
-
13
- export const Unknown = 'unknown'
1
+ export const BlockDevice = 1
2
+ export const CharacterDevice = 2
3
+ export const Directory = 3
4
+ export const DirectoryExpanded = 4
5
+ export const DirectoryExpanding = 5
6
+ export const File = 6
7
+ export const Socket = 7
8
+ export const Symlink = 8
9
+ export const SymLinkFile = 9
10
+ export const SymLinkFolder = 10
11
+ export const Unknown = 11
@@ -1,10 +1,10 @@
1
1
  import VError from 'verror'
2
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
2
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
3
3
 
4
4
  export class FileNotFoundError extends VError {
5
5
  constructor(path) {
6
6
  super(`File not found '${path}'`)
7
7
  this.name = 'FileNotFoundError'
8
- this.code = FileSystemErrorCodes.ENOENT
8
+ this.code = ErrorCodes.ENOENT
9
9
  }
10
10
  }
@@ -0,0 +1,51 @@
1
+ import * as ChildProcess from '../ChildProcess/ChildProcess.js'
2
+ import * as Platform from '../Platform/Platform.js'
3
+
4
+ export const create = () => {
5
+ const extensionHostHelperProcessPath =
6
+ Platform.getExtensionHostHelperProcessPath()
7
+ const childProcess = ChildProcess.fork(
8
+ extensionHostHelperProcessPath,
9
+ ['--ipc-type=websocket', '--max-old-space-size=60', '--enable-source-maps'],
10
+ {}
11
+ )
12
+ return {
13
+ on(event, listener) {
14
+ switch (event) {
15
+ case 'message':
16
+ childProcess.on('message', listener)
17
+ break
18
+ case 'error':
19
+ childProcess.on('error', listener)
20
+ break
21
+ case 'exit':
22
+ childProcess.on('exit', listener)
23
+ break
24
+ default:
25
+ throw new Error(`unsupported event type ${event}`)
26
+ }
27
+ },
28
+ off(event, listener) {
29
+ switch (event) {
30
+ case 'message':
31
+ childProcess.off('message', listener)
32
+ break
33
+ case 'error':
34
+ childProcess.off('error', listener)
35
+ break
36
+ case 'exit':
37
+ childProcess.off('exit', listener)
38
+ break
39
+ default:
40
+ throw new Error(`unsupported event type ${event}`)
41
+ }
42
+ },
43
+ send(message) {
44
+ childProcess.send(message)
45
+ },
46
+ dispose() {
47
+ childProcess.kill()
48
+ },
49
+ _process: childProcess,
50
+ }
51
+ }
@@ -2,7 +2,7 @@ import VError from 'verror'
2
2
  import * as ExtensionManifest from '../ExtensionManifest/ExtensionManifest.js'
3
3
  import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
4
4
  import * as FileSystem from '../FileSystem/FileSystem.js'
5
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
5
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
6
6
  import * as Path from '../Path/Path.js'
7
7
  import * as Platform from '../Platform/Platform.js'
8
8
  import * as SymLink from '../SymLink/SymLink.js'
@@ -35,7 +35,7 @@ export const link = async (path) => {
35
35
  const to = Path.join(linkedExtensionsPath, manifest.id)
36
36
  await SymLink.createSymLink(path, to)
37
37
  } catch (error) {
38
- if (error && error.code === FileSystemErrorCodes.EEXIST) {
38
+ if (error && error.code === ErrorCodes.EEXIST) {
39
39
  return linkFallBack(path)
40
40
  }
41
41
  throw new VError(error, `Failed to link extension`)
@@ -3,7 +3,7 @@ import VError from 'verror'
3
3
  import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
4
4
  import * as ReadJson from '../JsonFile/JsonFile.js'
5
5
  import * as Path from '../Path/Path.js'
6
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
6
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
7
7
 
8
8
  const RE_EXTENSION_FRAGMENT = /.+(\/|\\)(.+)$/
9
9
 
@@ -35,9 +35,9 @@ export const get = async (path) => {
35
35
  error,
36
36
  `Failed to load extension manifest for ${id}`
37
37
  )
38
- if (error.code === FileSystemErrorCodes.ENOENT) {
38
+ if (error.code === ErrorCodes.ENOENT) {
39
39
  // @ts-ignore
40
- enhancedError.code = FileSystemErrorCodes.E_MANIFEST_NOT_FOUND
40
+ enhancedError.code = ErrorCodes.E_MANIFEST_NOT_FOUND
41
41
  } else {
42
42
  // @ts-ignore
43
43
  enhancedError.code = error.code
@@ -2,7 +2,7 @@ import VError from 'verror'
2
2
  import * as ExtensionManifest from '../ExtensionManifest/ExtensionManifest.js'
3
3
  import * as FileSystem from '../FileSystem/FileSystem.js'
4
4
  import * as Path from '../Path/Path.js'
5
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
5
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
6
6
 
7
7
  const toAbsolutePaths = (path, dirents) => {
8
8
  const absolutePaths = []
@@ -26,7 +26,7 @@ export const getExtensionManifests = async (path) => {
26
26
  } catch (error) {
27
27
  // TODO how to make typescript happy?
28
28
  // @ts-ignore
29
- if (error.code === FileSystemErrorCodes.ENOENT) {
29
+ if (error.code === ErrorCodes.ENOENT) {
30
30
  return []
31
31
  }
32
32
  throw new VError(error, 'Failed to get extension manifests')
@@ -4,7 +4,7 @@ import * as os from 'node:os'
4
4
  import VError from 'verror'
5
5
  import * as DirentType from '../DirentType/DirentType.js'
6
6
  import { FileNotFoundError } from '../Error/FileNotFoundError.js'
7
- import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
7
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
8
8
  import * as Path from '../Path/Path.js'
9
9
  import * as Platform from '../Platform/Platform.js'
10
10
  import * as Trash from '../Trash/Trash.js'
@@ -52,7 +52,7 @@ export const readFile = async (path, encoding = EncodingType.Utf8) => {
52
52
  // console.timeEnd(`read ${path}`)
53
53
  return content
54
54
  } catch (error) {
55
- if (error && error.code === FileSystemErrorCodes.ENOENT) {
55
+ if (error && error.code === ErrorCodes.ENOENT) {
56
56
  throw new FileNotFoundError(path)
57
57
  }
58
58
  throw new VError(error, `Failed to read file "${path}"`)
@@ -75,7 +75,7 @@ export const writeFile = async (
75
75
  // Queue.add(`writeFile/${path}`, () =>
76
76
  await fs.writeFile(path, content, encoding)
77
77
  } catch (error) {
78
- if (error && error.code === FileSystemErrorCodes.ENOENT) {
78
+ if (error && error.code === ErrorCodes.ENOENT) {
79
79
  throw new FileNotFoundError(path)
80
80
  }
81
81
  throw new VError(error, `Failed to write to file "${path}"`)
@@ -152,7 +152,7 @@ const getType = (dirent) => {
152
152
  return DirentType.File
153
153
  }
154
154
  if (dirent.isDirectory()) {
155
- return DirentType.Direcory
155
+ return DirentType.Directory
156
156
  }
157
157
  if (dirent.isSymbolicLink()) {
158
158
  return DirentType.Symlink
@@ -194,7 +194,7 @@ export const readDir = async (path) => {
194
194
  const dirents = await fs.readdir(path)
195
195
  return dirents
196
196
  } catch (error) {
197
- if (error && error.code === FileSystemErrorCodes.ENOENT) {
197
+ if (error && error.code === ErrorCodes.ENOENT) {
198
198
  throw new FileNotFoundError(path)
199
199
  }
200
200
  throw new VError(error, `Failed to read directory "${path}"`)
@@ -222,7 +222,7 @@ export const rename = async (oldPath, newPath) => {
222
222
  try {
223
223
  await fs.rename(oldPath, newPath)
224
224
  } catch (error) {
225
- if (error && error.code === FileSystemErrorCodes.EXDEV) {
225
+ if (error && error.code === ErrorCodes.EXDEV) {
226
226
  return fallbackRename(oldPath, newPath)
227
227
  }
228
228
  throw new VError(error, `Failed to rename "${oldPath}" to "${newPath}"`)
@@ -258,7 +258,7 @@ export const getRealPath = async (path) => {
258
258
  error &&
259
259
  error instanceof globalThis.Error &&
260
260
  // @ts-ignore
261
- error.code === FileSystemErrorCodes.ENOENT
261
+ error.code === ErrorCodes.ENOENT
262
262
  ) {
263
263
  let content
264
264
  try {
@@ -8,6 +8,7 @@ import { requiresSocket } from '../RequiresSocket/RequiresSocket.js'
8
8
  import * as Platform from '../Platform/Platform.js'
9
9
  import * as ExtensionHostIpc from '../ExtensionHostIpc/ExtensionHostIpc.js'
10
10
  import * as ExtensionHostRpc from '../ExtensionHostRpc/ExtensionHostRpc.js'
11
+ import * as ExtensionHostHelperProcessIpc from '../ExtensionHostHelperProcessIpc/ExtensionHostHelperProcessIpc.js'
11
12
  // TODO add tests for this
12
13
 
13
14
  // TODO handle structure: one shared process multiple extension hosts
@@ -61,6 +62,11 @@ const handleWebSocketExtensionHost = async (message, handle) => {
61
62
  // console.log(rpc)
62
63
  }
63
64
 
65
+ const handleWebSocketExtensionHostHelperProcess = (message, handle) => {
66
+ const ipc = ExtensionHostHelperProcessIpc.create()
67
+ ipc._process.send(message, handle)
68
+ }
69
+
64
70
  const handleWebSocket = (message, handle) => {
65
71
  const headers = message.headers
66
72
  if (!headers) {
@@ -75,6 +81,8 @@ const handleWebSocket = (message, handle) => {
75
81
  return handleWebSocketSharedProcess(message, handle)
76
82
  case 'lvce.extension-host':
77
83
  return handleWebSocketExtensionHost(message, handle)
84
+ case 'lvce.extension-host-helper-process':
85
+ return handleWebSocketExtensionHostHelperProcess(message, handle)
78
86
  default:
79
87
  throw new VError(`unsupported sec-websocket-procotol ${protocol}`)
80
88
  }
@@ -209,7 +217,6 @@ const electronInitialize = (initializeMessage) => {
209
217
  },
210
218
  })
211
219
  }
212
-
213
220
  }
214
221
  } else {
215
222
  Command.execute(message.method, fakeSocket, ...message.params)
@@ -101,6 +101,16 @@ export const getExtensionHostPath = () => {
101
101
  return extensionHostPath
102
102
  }
103
103
 
104
+ export const getExtensionHostHelperProcessPath = () => {
105
+ return Path.join(
106
+ Root.root,
107
+ 'packages',
108
+ 'extension-host-helper-process',
109
+ 'src',
110
+ 'extensionHostHelperProcessMain.js'
111
+ )
112
+ }
113
+
104
114
  export const getRecentlyOpenedPath = () => {
105
115
  return Path.join(cacheDir, 'recently-opened.json')
106
116
  }