@lvce-editor/shared-process 0.16.16 → 0.16.18

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.
@@ -0,0 +1,16 @@
1
+ # Language Basics CSON
2
+
3
+ CSON syntax highlighting for Lvce Editor.
4
+
5
+ ## Contributing
6
+
7
+ ```sh
8
+ git clone git@github.com:lvce-editor/language-basics-cson.git &&
9
+ cd language-basics-cson &&
10
+ npm ci &&
11
+ npm test
12
+ ```
13
+
14
+ ## Gitpod
15
+
16
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/language-basics-cson)
@@ -0,0 +1,13 @@
1
+ {
2
+ "id": "builtin.language-basics-cson",
3
+ "name": "Language Basics CSON",
4
+ "description": "Provides syntax highlighting and bracket matching in CSON files.",
5
+ "languages": [
6
+ {
7
+ "id": "cson",
8
+ "extensions": [".cson"],
9
+ "tokenize": "src/tokenizeCson.js",
10
+ "configuration": "languageConfiguration.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "comments": {
3
+ "blockComment": ["/*", "*/"]
4
+ },
5
+ "brackets": [
6
+ ["{", "}"],
7
+ ["[", "]"],
8
+ ["(", ")"]
9
+ ],
10
+ "autoClosingPairs": [
11
+ { "open": "{", "close": "}", "notIn": ["string", "comment"] },
12
+ { "open": "[", "close": "]", "notIn": ["string", "comment"] },
13
+ { "open": "(", "close": ")", "notIn": ["string", "comment"] },
14
+ { "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
15
+ { "open": "'", "close": "'", "notIn": ["string", "comment"] }
16
+ ],
17
+ "indentationRules": {
18
+ "increaseIndentPattern": "(^.*\\{[^}]*$)",
19
+ "decreaseIndentPattern": "^\\s*\\}"
20
+ }
21
+ }
@@ -0,0 +1,207 @@
1
+ /**
2
+ * @enum number
3
+ */
4
+ export const State = {
5
+ TopLevelContent: 1,
6
+ AfterSelector: 2,
7
+ InsideSelector: 3,
8
+ AfterPropertyName: 4,
9
+ AfterPropertyNameAfterColon: 5,
10
+ InsideBlockComment: 7,
11
+ InsidePseudoSelector: 8,
12
+ InsideAttributeSelector: 9,
13
+ AfterQuery: 10,
14
+ InsideRound: 11,
15
+ AfterQueryWithRules: 12,
16
+ InsideRule: 13,
17
+ AfterFunctionName: 14,
18
+ InsideDoubleQuoteString: 15,
19
+ InsideSingleQuoteString: 16,
20
+ AfterFunctionNameInsideArguments: 17,
21
+ AfterKeywordImport: 18,
22
+ }
23
+
24
+ export const StateMap = {
25
+ [State.TopLevelContent]: 'TopLevelContent',
26
+ [State.AfterSelector]: 'AfterSelector',
27
+ [State.InsideSelector]: 'InsideSelector',
28
+ [State.AfterPropertyName]: 'AfterPropertyName',
29
+ [State.AfterPropertyNameAfterColon]: 'AfterPropertyNameAfterColon',
30
+ }
31
+
32
+ /**
33
+ * @enum number
34
+ */
35
+ export const TokenType = {
36
+ CssSelector: 1,
37
+ Whitespace: 2,
38
+ Punctuation: 3,
39
+ CssPropertyName: 4,
40
+ CssPropertyValue: 5,
41
+ CurlyOpen: 6,
42
+ CurlyClose: 7,
43
+ PropertyColon: 8,
44
+ CssPropertySemicolon: 9,
45
+ Variable: 10,
46
+ None: 57,
47
+ Unknown: 881,
48
+ CssPropertyColon: 882,
49
+ Numeric: 883,
50
+ NewLine: 884,
51
+ Comment: 885,
52
+ Query: 886,
53
+ Text: 887,
54
+ CssSelectorId: 889,
55
+ FuntionName: 890,
56
+ String: 891,
57
+ KeywordImport: 892,
58
+ CssSelectorClass: 893,
59
+ }
60
+
61
+ export const TokenMap = {
62
+ [TokenType.CssSelector]: 'CssSelector',
63
+ [TokenType.Whitespace]: 'Whitespace',
64
+ [TokenType.Punctuation]: 'Punctuation',
65
+ [TokenType.CssPropertyName]: 'CssPropertyName',
66
+ [TokenType.CssPropertyValue]: 'CssPropertyValue',
67
+ [TokenType.CurlyOpen]: 'Punctuation',
68
+ [TokenType.CurlyClose]: 'Punctuation',
69
+ [TokenType.PropertyColon]: 'Punctuation',
70
+ [TokenType.CssPropertySemicolon]: 'Punctuation',
71
+ [TokenType.Variable]: 'VariableName',
72
+ [TokenType.None]: 'None',
73
+ [TokenType.CssPropertyValue]: 'CssPropertyValue',
74
+ [TokenType.Unknown]: 'Unknown',
75
+ [TokenType.CssPropertyColon]: 'Punctuation',
76
+ [TokenType.Numeric]: 'Numeric',
77
+ [TokenType.NewLine]: 'NewLine',
78
+ [TokenType.Comment]: 'Comment',
79
+ [TokenType.Query]: 'CssAtRule',
80
+ [TokenType.Text]: 'Text',
81
+ [TokenType.CssSelectorId]: 'CssSelectorId',
82
+ [TokenType.FuntionName]: 'Function',
83
+ [TokenType.String]: 'String',
84
+ [TokenType.KeywordImport]: 'KeywordImport',
85
+ [TokenType.CssSelectorClass]: 'CssSelectorClass',
86
+ }
87
+
88
+ const RE_SELECTOR = /^[\.a-zA-Z\d\-\:>\+\~\_%\\]+/
89
+ const RE_SELECTOR_ID = /^#[\w\-\_]+/
90
+ const RE_SELECTOR_CLASS = /^\.[\w\-\_]+/
91
+ const RE_WHITESPACE = /^\s+/
92
+ const RE_CURLY_OPEN = /^\{/
93
+ const RE_CURLY_CLOSE = /^\}/
94
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\w]+/
95
+ const RE_COLON = /^:/
96
+ const RE_PROPERTY_VALUE = /^[^;\}]+/
97
+ const RE_PROPERTY_VALUE_SHORT = /^[^;\}\s\)]+/
98
+ const RE_PROPERTY_VALUE_INSIDE_FUNCTION = /^[^\}\s\)]+/
99
+ const RE_SEMICOLON = /^;/
100
+ const RE_COMMA = /^,/
101
+ const RE_ANYTHING = /^.+/s
102
+ const RE_NUMERIC = /^\-?(([0-9]+\.?[0-9]*)|(\.[0-9]+))/
103
+ const RE_ANYTHING_UNTIL_CLOSE_BRACE = /^[^\}]+/
104
+ const RE_BLOCK_COMMENT_START = /^\/\*/
105
+ const RE_BLOCK_COMMENT_END = /^\*\//
106
+ const RE_BLOCK_COMMENT_CONTENT = /^.+?(?=\*\/|$)/s
107
+ const RE_ROUND_OPEN = /^\(/
108
+ const RE_ROUND_CLOSE = /^\)/
109
+ const RE_PSEUDO_SELECTOR_CONTENT = /^[^\)]+/
110
+ const RE_SQUARE_OPEN = /^\[/
111
+ const RE_SQUARE_CLOSE = /^\]/
112
+ const RE_ATTRIBUTE_SELECTOR_CONTENT = /^[^\]]+/
113
+ const RE_QUERY = /^@[a-z\-]+/
114
+ const RE_STAR = /^\*/
115
+ const RE_QUERY_NAME = /^[a-zA-Z\w\-\d\_]+/
116
+ const RE_QUERY_CONTENT = /^[^\)]+/
117
+ const RE_COMBINATOR = /^[\+\>\~]/
118
+ const RE_FUNCTION = /^[a-zA-Z][a-zA-Z\-]+(?=\()/
119
+ const RE_VARIABLE_NAME = /^\-\-[a-zA-Z\w\-\_]+/
120
+ const RE_PERCENT = /^\%/
121
+ const RE_OPERATOR = /^[\-\/\*\+]/
122
+ const RE_DOUBLE_QUOTE = /^"/
123
+ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
124
+ const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^']+/
125
+ const RE_SINGLE_QUOTE = /^'/
126
+ const RE_ANYTHING_BUT_CURLY = /^[^\{\}]+/s
127
+ const RE_LINE_COMMENT = /^#.*/
128
+ const RE_PUNCTUATION = /^[\:\{\}\[\]]/
129
+
130
+ export const initialLineState = {
131
+ state: State.TopLevelContent,
132
+ tokens: [],
133
+ stack: [],
134
+ }
135
+
136
+ /**
137
+ * @param {any} lineStateA
138
+ * @param {any} lineStateB
139
+ */
140
+ export const isEqualLineState = (lineStateA, lineStateB) => {
141
+ return lineStateA.state === lineStateB.state
142
+ }
143
+
144
+ export const hasArrayReturn = true
145
+
146
+ /**
147
+ * @param {string} line
148
+ * @param {any} lineState
149
+ */
150
+ export const tokenizeLine = (line, lineState) => {
151
+ let next = null
152
+ let index = 0
153
+ let tokens = []
154
+ let token = TokenType.None
155
+ let state = lineState.state
156
+ const stack = lineState.stack
157
+ while (index < line.length) {
158
+ const part = line.slice(index)
159
+ switch (state) {
160
+ case State.TopLevelContent:
161
+ if ((next = part.match(RE_WHITESPACE))) {
162
+ token = TokenType.Whitespace
163
+ state = State.TopLevelContent
164
+ } else if ((next = part.match(RE_SINGLE_QUOTE))) {
165
+ token = TokenType.Punctuation
166
+ state = State.InsideSingleQuoteString
167
+ } else if ((next = part.match(RE_LINE_COMMENT))) {
168
+ token = TokenType.Comment
169
+ state = State.TopLevelContent
170
+ } else if ((next = part.match(RE_PUNCTUATION))) {
171
+ token = TokenType.Punctuation
172
+ state = State.TopLevelContent
173
+ } else if ((next = part.match(RE_ANYTHING))) {
174
+ token = TokenType.Text
175
+ state = State.TopLevelContent
176
+ } else {
177
+ throw new Error('no')
178
+ }
179
+ break
180
+ case State.InsideSingleQuoteString:
181
+ if ((next = part.match(RE_SINGLE_QUOTE))) {
182
+ token = TokenType.Punctuation
183
+ state = State.TopLevelContent
184
+ } else if ((next = part.match(RE_STRING_SINGLE_QUOTE_CONTENT))) {
185
+ token = TokenType.String
186
+ state = State.InsideSingleQuoteString
187
+ } else {
188
+ throw new Error('no')
189
+ }
190
+ break
191
+ default:
192
+ console.log({ state, line })
193
+ throw new Error('no')
194
+ }
195
+ const tokenLength = next[0].length
196
+ index += tokenLength
197
+ tokens.push(token, tokenLength)
198
+ }
199
+ if (state === State.AfterPropertyName) {
200
+ state = State.InsideSelector
201
+ }
202
+ return {
203
+ state,
204
+ tokens,
205
+ stack,
206
+ }
207
+ }
@@ -32,7 +32,8 @@
32
32
  ".tour",
33
33
  ".heapsnapshot",
34
34
  ".code-workspace",
35
- ".code-profile"
35
+ ".code-profile",
36
+ ".github-issues"
36
37
  ],
37
38
  "fileNames": [
38
39
  "composer.lock",
@@ -298,6 +298,10 @@ export const tokenizeLine = (line, lineState) => {
298
298
  } else if ((next = part.match(RE_LINE_COMMENT))) {
299
299
  token = TokenType.Comment
300
300
  state = State.AfterPropertyValue
301
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
302
+ token = TokenType.Comment
303
+ state = State.InsideBlockComment
304
+ stack.push(State.AfterPropertyValue)
301
305
  } else if ((next = part.match(RE_ANYTHING))) {
302
306
  token = TokenType.Text
303
307
  state = State.AfterCurlyOpen
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.16.16",
3
+ "version": "0.16.18",
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.22.5",
20
- "@lvce-editor/extension-host": "0.16.16",
21
- "@lvce-editor/extension-host-helper-process": "0.16.16",
22
- "@lvce-editor/pty-host": "0.16.16",
20
+ "@lvce-editor/extension-host": "0.16.18",
21
+ "@lvce-editor/extension-host-helper-process": "0.16.18",
22
+ "@lvce-editor/pty-host": "0.16.18",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -1,6 +1,10 @@
1
+ import * as IsElectron from '../IsElectron/IsElectron.js'
1
2
  import * as Path from '../Path/Path.js'
2
3
  import * as Root from '../Root/Root.js'
3
4
 
4
5
  export const getElectronRebuildPath = () => {
6
+ if (IsElectron.isElectron()) {
7
+ return Path.join(Root.root, 'packages', 'main-process', 'node_modules', '.bin', 'electron-rebuild.cmd')
8
+ }
5
9
  return Path.join(Root.root, 'packages', 'main-process', 'node_modules', '.bin', 'electron-rebuild')
6
10
  }
@@ -5,8 +5,10 @@ export const getFirstNodeChildProcessEvent = async (childProcess) => {
5
5
  let stderr = ''
6
6
  let stdout = ''
7
7
  const cleanup = (value) => {
8
- childProcess.stderr.off('data', handleStdErrData)
9
- childProcess.stdout.off('data', handleStdoutData)
8
+ if (childProcess.stdout && childProcess.stderr) {
9
+ childProcess.stderr.off('data', handleStdErrData)
10
+ childProcess.stdout.off('data', handleStdoutData)
11
+ }
10
12
  childProcess.off('message', handleMessage)
11
13
  childProcess.off('exit', handleExit)
12
14
  childProcess.off('error', handleError)
@@ -27,8 +29,10 @@ export const getFirstNodeChildProcessEvent = async (childProcess) => {
27
29
  const handleError = (event) => {
28
30
  cleanup({ type: FirstNodeWorkerEventType.Error, event, stdout, stderr })
29
31
  }
30
- childProcess.stderr.on('data', handleStdErrData)
31
- childProcess.stdout.on('data', handleStdoutData)
32
+ if (childProcess.stdout && childProcess.stderr) {
33
+ childProcess.stderr.on('data', handleStdErrData)
34
+ childProcess.stdout.on('data', handleStdoutData)
35
+ }
32
36
  childProcess.on('message', handleMessage)
33
37
  childProcess.on('exit', handleExit)
34
38
  childProcess.on('error', handleError)
@@ -0,0 +1,5 @@
1
+ import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
2
+
3
+ export const isDlOpenError = (error) => {
4
+ return error && error instanceof Error && 'code' in error && error.code === ErrorCodes.ERR_DLOPEN_FAILED
5
+ }
@@ -1,12 +1,12 @@
1
+ import * as IsDlOpenError from '../IsDlOpenError/IsDlOpenError.js'
1
2
  import { VError } from '../VError/VError.js'
2
- import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
3
3
 
4
4
  export const loadWindowProcessTree = async () => {
5
5
  try {
6
6
  // @ts-ignore
7
7
  return await import('@vscode/windows-process-tree')
8
8
  } catch (error) {
9
- if (error && error instanceof Error && 'code' in error && error.code === ErrorCodes.ERR_DLOPEN_FAILED) {
9
+ if (IsDlOpenError.isDlOpenError(error)) {
10
10
  throw new VError(
11
11
  `Failed to load windows process tree: The native module "@vscode/windows-process-tree" is not compatible with this node version and must be compiled against a matching electron version using electron-rebuild`
12
12
  )
@@ -169,11 +169,11 @@ export const getSetupName = () => {
169
169
  return 'Lvce-Setup'
170
170
  }
171
171
 
172
- export const version = '0.16.16'
172
+ export const version = '0.16.18'
173
173
 
174
- export const commit = 'd2454d3'
174
+ export const commit = 'd5caee6'
175
175
 
176
- export const date = '2023-07-19T15:35:04.000Z'
176
+ export const date = '2023-07-20T14:53:13.000Z'
177
177
 
178
178
  export const getVersion = () => {
179
179
  return version
@@ -1,5 +1,7 @@
1
1
  import { spawn } from 'node:child_process'
2
+ import * as FirstNodeWorkerEventType from '../FirstNodeWorkerEventType/FirstNodeWorkerEventType.js'
2
3
  import * as GetElectronRebuildPath from '../GetElectronRebuildPath/GetElectronRebuildPath.js'
4
+ import * as GetFirstNodeChildProcessEvent from '../GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js'
3
5
  import * as IsElectron from '../IsElectron/IsElectron.js'
4
6
  import * as Path from '../Path/Path.js'
5
7
  import * as Root from '../Root/Root.js'
@@ -18,7 +20,10 @@ const rebuildNodePtyElectron = async (cwd) => {
18
20
  cwd,
19
21
  stdio: 'inherit',
20
22
  })
21
- // TODO wait for child process to be finished
23
+ const { type, event } = await GetFirstNodeChildProcessEvent.getFirstNodeChildProcessEvent(childProcess)
24
+ if (type === FirstNodeWorkerEventType.Error) {
25
+ throw new Error(`Failed to rebuild native module: ${event}`)
26
+ }
22
27
  }
23
28
 
24
29
  /**
@@ -29,6 +34,10 @@ const rebuildNodePtyNode = async (cwd) => {
29
34
  cwd,
30
35
  stdio: 'inherit',
31
36
  })
37
+ const { type, event } = await GetFirstNodeChildProcessEvent.getFirstNodeChildProcessEvent(childProcess)
38
+ if (type === FirstNodeWorkerEventType.Error) {
39
+ throw new Error(`Failed to rebuild native module: ${event}`)
40
+ }
32
41
  }
33
42
 
34
43
  const getFn = () => {