@lvce-editor/shared-process 0.4.0 → 0.4.2

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.
@@ -343,7 +343,7 @@
343
343
  },
344
344
  {
345
345
  "key": "Space",
346
- "command": "Explorer.handleClickCurrent",
346
+ "command": "Explorer.handleClickCurrentButKeepFocus",
347
347
  "when": "focus.Explorer"
348
348
  },
349
349
  {
@@ -1,4 +1,4 @@
1
- # Language Basics CSS
1
+ # Language Basics Css
2
2
 
3
3
  ## Contributing
4
4
 
@@ -104,12 +104,19 @@ export const initialLineState = {
104
104
  stack: [],
105
105
  }
106
106
 
107
+ /**
108
+ * @param {any} lineStateA
109
+ * @param {any} lineStateB
110
+ */
107
111
  export const isEqualLineState = (lineStateA, lineStateB) => {
108
112
  return lineStateA.state === lineStateB.state
109
113
  }
110
114
 
115
+ export const hasArrayReturn = true
116
+
111
117
  /**
112
118
  * @param {string} line
119
+ * @param {any} lineState
113
120
  */
114
121
  export const tokenizeLine = (line, lineState) => {
115
122
  let next = null
@@ -349,11 +356,9 @@ export const tokenizeLine = (line, lineState) => {
349
356
  console.log({ state, line })
350
357
  throw new Error('no')
351
358
  }
352
- index += next[0].length
353
- tokens.push({
354
- type: token,
355
- length: next[0].length,
356
- })
359
+ const tokenLength = next[0].length
360
+ index += tokenLength
361
+ tokens.push(token, tokenLength)
357
362
  }
358
363
  return {
359
364
  state,
@@ -1,33 +1,122 @@
1
+ /**
2
+ * @enum number
3
+ */
4
+ export const State = {
5
+ TopLevelContent: 1,
6
+ InsideLineComment: 2,
7
+ }
8
+
9
+ export const StateMap = {
10
+ [State.TopLevelContent]: 'TopLevelContent',
11
+ [State.InsideLineComment]: 'InsideLineComment',
12
+ }
13
+
1
14
  /**
2
15
  * @enum number
3
16
  */
4
17
  export const TokenType = {
5
- Text: 0,
6
- NewLine: 1,
18
+ CssSelector: 1,
19
+ Whitespace: 2,
20
+ None: 57,
21
+ Unknown: 881,
22
+ NewLine: 884,
23
+ Comment: 885,
24
+ Query: 886,
25
+ Text: 887,
7
26
  }
8
27
 
9
28
  export const TokenMap = {
29
+ [TokenType.CssSelector]: 'CssSelector',
30
+ [TokenType.Whitespace]: 'Whitespace',
31
+ [TokenType.None]: 'None',
32
+ [TokenType.Unknown]: 'Unknown',
33
+ [TokenType.NewLine]: 'NewLine',
34
+ [TokenType.Comment]: 'Comment',
35
+ [TokenType.Query]: 'Query',
10
36
  [TokenType.Text]: 'Text',
11
37
  }
12
38
 
39
+ const RE_LINE_COMMENT_START = /^#/
40
+ const RE_WHITESPACE = /^ +/
41
+ const RE_CURLY_OPEN = /^\{/
42
+ const RE_CURLY_CLOSE = /^\}/
43
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-]+\b/
44
+ const RE_COLON = /^:/
45
+ const RE_PROPERTY_VALUE = /^[^;\}]+/
46
+ const RE_SEMICOLON = /^;/
47
+ const RE_COMMA = /^,/
48
+ const RE_ANYTHING = /^.*/
49
+ const RE_NUMERIC = /^(([0-9]+\.?[0-9]*)|(\.[0-9]+))/
50
+ const RE_ANYTHING_UNTIL_CLOSE_BRACE = /^[^\}]+/
51
+ const RE_BLOCK_COMMENT_START = /^\/\*/
52
+ const RE_BLOCK_COMMENT_END = /^\*\//
53
+ const RE_BLOCK_COMMENT_CONTENT = /^.+?(?=\*\/|$)/s
54
+ const RE_ROUND_OPEN = /^\(/
55
+ const RE_ROUND_CLOSE = /^\)/
56
+ const RE_PSEUDO_SELECTOR_CONTENT = /^[^\)]+/
57
+ const RE_SQUARE_OPEN = /^\[/
58
+ const RE_SQUARE_CLOSE = /^\]/
59
+ const RE_ATTRIBUTE_SELECTOR_CONTENT = /^[^\]]+/
60
+ const RE_QUERY = /^@[a-z\-]+/
61
+ const RE_STAR = /^\*/
62
+ const RE_QUERY_NAME = /^[a-z\-]+/
63
+ const RE_QUERY_CONTENT = /^[^\)]+/
64
+ const RE_COMBINATOR = /^[\+\>\~]/
65
+
13
66
  export const initialLineState = {
14
- state: 1,
67
+ state: State.TopLevelContent,
68
+ tokens: [],
69
+ stack: [],
15
70
  }
16
71
 
72
+ export const hasArrayReturn = true
73
+
74
+ /**
75
+ * @param {string} line
76
+ * @param {any} lineState
77
+ */
17
78
  export const tokenizeLine = (line, lineState) => {
18
- if (line.length === 0) {
19
- return {
20
- state: 1,
21
- tokens: [],
79
+ let next = null
80
+ let index = 0
81
+ let tokens = []
82
+ let token = TokenType.None
83
+ let state = lineState.state
84
+ while (index < line.length) {
85
+ const part = line.slice(index)
86
+ switch (state) {
87
+ case State.TopLevelContent:
88
+ if ((next = part.match(RE_LINE_COMMENT_START))) {
89
+ token = TokenType.Comment
90
+ state = State.InsideLineComment
91
+ } else if ((next = part.match(RE_WHITESPACE))) {
92
+ token = TokenType.Whitespace
93
+ state = State.TopLevelContent
94
+ } else if ((next = part.match(RE_ANYTHING))) {
95
+ token = TokenType.Text
96
+ state = State.TopLevelContent
97
+ } else {
98
+ part //?
99
+ throw new Error('no')
100
+ }
101
+ break
102
+ case State.InsideLineComment:
103
+ if ((next = part.match(RE_ANYTHING))) {
104
+ token = TokenType.Comment
105
+ state = State.TopLevelContent
106
+ } else {
107
+ throw new Error('no')
108
+ }
109
+ break
110
+ default:
111
+ console.log({ state, line })
112
+ throw new Error('no')
22
113
  }
114
+ const tokenLength = next[0].length
115
+ index += tokenLength
116
+ tokens.push(token, tokenLength)
23
117
  }
24
118
  return {
25
- state: 1,
26
- tokens: [
27
- {
28
- type: TokenType.Text,
29
- length: line.length,
30
- },
31
- ],
119
+ state,
120
+ tokens,
32
121
  }
33
122
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "builtin.language-basics-docker",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "name": "Language Basics Docker",
5
5
  "description": "Provides syntax highlighting and bracket matching in Dockerfile files.",
6
6
  "languages": [
@@ -44,6 +44,8 @@ const RE_ANYTHING = /^.*/
44
44
  const RE_KEYWORD =
45
45
  /^(?:ADD|ARG|CMD|COPY|ENTRYPOINT|ENV|EXPOSE|FROM|HEALTHCHECK|LABEL|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR)\b/
46
46
 
47
+ export const hasArrayReturnValue = true
48
+
47
49
  /**
48
50
  * @param {string} line
49
51
  * @param {any} lineState
@@ -0,0 +1,14 @@
1
+ # Language Basics Gitattributes
2
+
3
+ ## Contributing
4
+
5
+ ```sh
6
+ git clone git@github.com:lvce-editor/language-basics-gitattributes.git &&
7
+ cd language-basics-gitattributes &&
8
+ npm ci &&
9
+ npm test
10
+ ```
11
+
12
+ ## Gitpod
13
+
14
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/language-basics-gitattributes)
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "builtin.language-basics-gitattributes",
3
+ "name": "Language Basics Gitattributes",
4
+ "description": "Provides syntax highlighting and bracket matching in gitattributes files.",
5
+ "languages": [
6
+ {
7
+ "id": "gitattributes",
8
+ "extensions": [".gitattributes"],
9
+ "tokenize": "src/tokenizeGitAttributes.js"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @enum number
3
+ */
4
+ export const State = {
5
+ TopLevelContent: 1,
6
+ InsideLineComment: 2,
7
+ AfterPropertyName: 3,
8
+ }
9
+
10
+ /**
11
+ * @enum number
12
+ */
13
+ export const TokenType = {
14
+ Comment: 885,
15
+ LanguageConstant: 11,
16
+ NewLine: 884,
17
+ None: 57,
18
+ Numeric: 15,
19
+ PropertyName: 12,
20
+ PropertyValueString: 14,
21
+ Punctuation: 13,
22
+ Query: 886,
23
+ Text: 887,
24
+ Unknown: 881,
25
+ Whitespace: 2,
26
+ }
27
+
28
+ export const TokenMap = {
29
+ [TokenType.Text]: 'Text',
30
+ [TokenType.Comment]: 'Comment',
31
+ }
32
+
33
+ const RE_LINE_COMMENT_START = /^#/
34
+ const RE_WHITESPACE = /^ +/
35
+ const RE_CURLY_OPEN = /^\{/
36
+ const RE_CURLY_CLOSE = /^\}/
37
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:)/
38
+ const RE_PROPERTY_VALUE = /^[^;\}]+/
39
+ const RE_SEMICOLON = /^;/
40
+ const RE_COMMA = /^,/
41
+ const RE_ANYTHING = /^.*/
42
+ const RE_ANYTHING_BUT_COMMENT = /^[^#]+/
43
+ const RE_NUMERIC = /^(([0-9]+\.?[0-9]*)|(\.[0-9]+))/
44
+ const RE_ANYTHING_UNTIL_CLOSE_BRACE = /^[^\}]+/
45
+ const RE_BLOCK_COMMENT_START = /^\/\*/
46
+ const RE_BLOCK_COMMENT_END = /^\*\//
47
+ const RE_BLOCK_COMMENT_CONTENT = /^.+?(?=\*\/|$)/s
48
+ const RE_ROUND_OPEN = /^\(/
49
+ const RE_ROUND_CLOSE = /^\)/
50
+ const RE_PSEUDO_SELECTOR_CONTENT = /^[^\)]+/
51
+ const RE_SQUARE_OPEN = /^\[/
52
+ const RE_SQUARE_CLOSE = /^\]/
53
+ const RE_ATTRIBUTE_SELECTOR_CONTENT = /^[^\]]+/
54
+ const RE_QUERY = /^@[a-z\-]+/
55
+ const RE_STAR = /^\*/
56
+ const RE_QUERY_NAME = /^[a-z\-]+/
57
+ const RE_QUERY_CONTENT = /^[^\)]+/
58
+ const RE_COMBINATOR = /^[\+\>\~]/
59
+ const RE_LANGUAGE_CONSTANT = /^(?:true|false)/
60
+ const RE_COLON = /^:/
61
+ const RE_DASH = /^\-/
62
+ const RE_WORDS = /^[\w\s]*\w/
63
+
64
+ export const initialLineState = {
65
+ state: 1,
66
+ tokens: [],
67
+ }
68
+
69
+ export const hasArrayReturn = true
70
+
71
+ /**
72
+ * @param {string} line
73
+ * @param {any} lineState
74
+ */
75
+ export const tokenizeLine = (line, lineState) => {
76
+ let next = null
77
+ let index = 0
78
+ let tokens = []
79
+ let token = TokenType.None
80
+ let state = lineState.state
81
+ while (index < line.length) {
82
+ const part = line.slice(index)
83
+ switch (state) {
84
+ case State.TopLevelContent:
85
+ if ((next = part.match(RE_LINE_COMMENT_START))) {
86
+ token = TokenType.Comment
87
+ state = State.InsideLineComment
88
+ } else if ((next = part.match(RE_WHITESPACE))) {
89
+ token = TokenType.Whitespace
90
+ state = State.TopLevelContent
91
+ } else if ((next = part.match(RE_ANYTHING))) {
92
+ token = TokenType.Text
93
+ state = State.TopLevelContent
94
+ } else {
95
+ throw new Error('no')
96
+ }
97
+ break
98
+ case State.InsideLineComment:
99
+ if ((next = part.match(RE_ANYTHING))) {
100
+ token = TokenType.Comment
101
+ state = State.TopLevelContent
102
+ } else {
103
+ throw new Error('no')
104
+ }
105
+ break
106
+ case State.AfterPropertyName:
107
+ if ((next = part.match(RE_COLON))) {
108
+ token = TokenType.Punctuation
109
+ state = State.AfterPropertyNameAfterColon
110
+ } else if ((next = part.match(RE_WHITESPACE))) {
111
+ token = TokenType.Whitespace
112
+ state = State.AfterPropertyName
113
+ } else {
114
+ throw new Error('no')
115
+ }
116
+ break
117
+ default:
118
+ console.log({ state, line })
119
+ throw new Error('no')
120
+ }
121
+ const tokenLength = next[0].length
122
+ index += tokenLength
123
+ tokens.push(token, tokenLength)
124
+ }
125
+ if (state === State.AfterPropertyNameAfterColon) {
126
+ state = State.TopLevelContent
127
+ }
128
+ return {
129
+ state,
130
+ tokens,
131
+ }
132
+ }
@@ -98,6 +98,8 @@ export const isLineStateEqual = (lineStateA, lineStateB) => {
98
98
  return lineStateA.state === lineStateB.state
99
99
  }
100
100
 
101
+ export const hasArrayReturn = true
102
+
101
103
  /**
102
104
  *
103
105
  * @param {string} line
@@ -287,11 +289,9 @@ export const tokenizeLine = (line, lineState) => {
287
289
  state
288
290
  throw new Error('no')
289
291
  }
290
- index += next[0].length
291
- tokens.push({
292
- type: token,
293
- length: next[0].length,
294
- })
292
+ const tokenLength = next[0].length
293
+ index += tokenLength
294
+ tokens.push(token, tokenLength)
295
295
  }
296
296
  return {
297
297
  state,
@@ -6,6 +6,7 @@ export const State = {
6
6
  InsideLineComment: 2,
7
7
  AfterPropertyName: 3,
8
8
  AfterPropertyNameAfterColon: 4,
9
+ AfterDash: 5,
9
10
  }
10
11
 
11
12
  export const StateMap = {
@@ -45,14 +46,14 @@ export const TokenMap = {
45
46
  [TokenType.Unknown]: 'Unknown',
46
47
  [TokenType.Whitespace]: 'Whitespace',
47
48
  [TokenType.Punctuation]: 'Punctuation',
48
- [TokenType.PropertyValueString]: 'PropertyValueString',
49
+ [TokenType.PropertyValueString]: 'String',
49
50
  }
50
51
 
51
52
  const RE_LINE_COMMENT_START = /^#/
52
53
  const RE_WHITESPACE = /^ +/
53
54
  const RE_CURLY_OPEN = /^\{/
54
55
  const RE_CURLY_CLOSE = /^\}/
55
- const RE_PROPERTY_NAME = /^[a-zA-Z\-]+(?=\s*:)/
56
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:)/
56
57
  const RE_PROPERTY_VALUE = /^[^;\}]+/
57
58
  const RE_SEMICOLON = /^;/
58
59
  const RE_COMMA = /^,/
@@ -75,6 +76,7 @@ const RE_QUERY_CONTENT = /^[^\)]+/
75
76
  const RE_COMBINATOR = /^[\+\>\~]/
76
77
  const RE_LANGUAGE_CONSTANT = /^(?:true|false)/
77
78
  const RE_COLON = /^:/
79
+ const RE_DASH = /^\-/
78
80
 
79
81
  export const initialLineState = {
80
82
  state: State.TopLevelContent,
@@ -82,6 +84,8 @@ export const initialLineState = {
82
84
  stack: [],
83
85
  }
84
86
 
87
+ export const hasArrayReturn = true
88
+
85
89
  /**
86
90
  * @param {string} line
87
91
  * @param {any} lineState
@@ -105,6 +109,9 @@ export const tokenizeLine = (line, lineState) => {
105
109
  } else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
106
110
  token = TokenType.LanguageConstant
107
111
  state = State.TopLevelContent
112
+ } else if ((next = part.match(RE_DASH))) {
113
+ token = TokenType.Punctuation
114
+ state = State.AfterDash
108
115
  } else if ((next = part.match(RE_PROPERTY_NAME))) {
109
116
  token = TokenType.PropertyName
110
117
  state = State.AfterPropertyName
@@ -155,20 +162,39 @@ export const tokenizeLine = (line, lineState) => {
155
162
  throw new Error('no')
156
163
  }
157
164
  break
165
+ case State.AfterDash:
166
+ if ((next = part.match(RE_WHITESPACE))) {
167
+ token = TokenType.Whitespace
168
+ state = State.AfterDash
169
+ } else if ((next = part.match(RE_PROPERTY_NAME))) {
170
+ token = TokenType.PropertyName
171
+ state = State.AfterPropertyName
172
+ } else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
173
+ token = TokenType.LanguageConstant
174
+ state = State.TopLevelContent
175
+ } else if ((next = part.match(RE_NUMERIC))) {
176
+ token = TokenType.Numeric
177
+ state = State.TopLevelContent
178
+ } else if ((next = part.match(RE_ANYTHING))) {
179
+ token = TokenType.PropertyValueString
180
+ state = State.TopLevelContent
181
+ } else {
182
+ throw new Error('no')
183
+ }
184
+ break
158
185
  default:
159
186
  console.log({ state, line })
160
187
  throw new Error('no')
161
188
  }
162
- index += next[0].length
163
- tokens.push({
164
- type: token,
165
- length: next[0].length,
166
- })
189
+ const length = next[0].length
190
+ index += length
191
+ tokens.push(token, length)
192
+ }
193
+ if (state === State.AfterPropertyNameAfterColon) {
194
+ state = State.TopLevelContent
167
195
  }
168
196
  return {
169
197
  state,
170
198
  tokens,
171
199
  }
172
200
  }
173
-
174
- tokenizeLine(`x: 11`, initialLineState) //?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -38,8 +38,8 @@
38
38
  "verror": "^1.10.1",
39
39
  "ws": "^8.8.1",
40
40
  "xdg-basedir": "^5.1.0",
41
- "@lvce-editor/pty-host": "0.4.0",
42
- "@lvce-editor/extension-host": "0.4.0"
41
+ "@lvce-editor/pty-host": "0.4.2",
42
+ "@lvce-editor/extension-host": "0.4.2"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "electron-clipboard-ex": "^1.3.3",