@lvce-editor/shared-process 0.4.3 → 0.5.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.
@@ -7,13 +7,15 @@
7
7
 
8
8
  "extensions.autoUpdate": true,
9
9
 
10
+ "sessionReplay.enabled": true,
11
+
10
12
  "serviceWorker.enabled": false,
11
13
 
14
+ "window.titleBarStyle": "custom",
15
+
12
16
  "workbench.colorTheme": "slime",
13
17
  "workbench.iconTheme": "vscode-icons",
14
18
  "workbench.activityBar.visible": true,
15
19
  "workbench.sideBar.visible": true,
16
- "workbench.saveStateOnVisibilityChange": false,
17
-
18
- "sessionReplay.enabled": true
20
+ "workbench.saveStateOnVisibilityChange": false
19
21
  }
@@ -4,6 +4,8 @@
4
4
  export const State = {
5
5
  TopLevelContent: 1,
6
6
  InsideLineComment: 2,
7
+ AfterPropertyName: 3,
8
+ AfterPropertyNameAfterEqualSign: 4,
7
9
  }
8
10
 
9
11
  export const StateMap = {
@@ -23,24 +25,36 @@ export const TokenType = {
23
25
  Comment: 885,
24
26
  Query: 886,
25
27
  Text: 887,
28
+ LanguageConstant: 11,
29
+ Numeric: 15,
30
+ PropertyName: 12,
31
+ PropertyValueString: 14,
32
+ Punctuation: 13,
33
+ String: 188,
26
34
  }
27
35
 
28
36
  export const TokenMap = {
29
- [TokenType.CssSelector]: 'CssSelector',
30
- [TokenType.Whitespace]: 'Whitespace',
31
- [TokenType.None]: 'None',
32
- [TokenType.Unknown]: 'Unknown',
33
- [TokenType.NewLine]: 'NewLine',
34
37
  [TokenType.Comment]: 'Comment',
38
+ [TokenType.LanguageConstant]: 'LanguageConstant',
39
+ [TokenType.NewLine]: 'NewLine',
40
+ [TokenType.None]: 'None',
41
+ [TokenType.Numeric]: 'Numeric',
42
+ [TokenType.PropertyName]: 'JsonPropertyName',
35
43
  [TokenType.Query]: 'Query',
36
44
  [TokenType.Text]: 'Text',
45
+ [TokenType.Unknown]: 'Unknown',
46
+ [TokenType.Whitespace]: 'Whitespace',
47
+ [TokenType.Punctuation]: 'Punctuation',
48
+ [TokenType.PropertyValueString]: 'String',
49
+ [TokenType.String]: 'String',
37
50
  }
38
51
 
52
+ const RE_LANGUAGE_CONSTANT = /^(?:true|false)/
39
53
  const RE_LINE_COMMENT_START = /^#/
40
54
  const RE_WHITESPACE = /^ +/
41
55
  const RE_CURLY_OPEN = /^\{/
42
56
  const RE_CURLY_CLOSE = /^\}/
43
- const RE_PROPERTY_NAME = /^[a-zA-Z\-]+\b/
57
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*\=)/
44
58
  const RE_COLON = /^:/
45
59
  const RE_PROPERTY_VALUE = /^[^;\}]+/
46
60
  const RE_SEMICOLON = /^;/
@@ -62,6 +76,7 @@ const RE_STAR = /^\*/
62
76
  const RE_QUERY_NAME = /^[a-z\-]+/
63
77
  const RE_QUERY_CONTENT = /^[^\)]+/
64
78
  const RE_COMBINATOR = /^[\+\>\~]/
79
+ const RE_EQUAL_SIGN = /^\=/
65
80
 
66
81
  export const initialLineState = {
67
82
  state: State.TopLevelContent,
@@ -69,6 +84,8 @@ export const initialLineState = {
69
84
  stack: [],
70
85
  }
71
86
 
87
+ export const hasArrayReturn = true
88
+
72
89
  /**
73
90
  * @param {string} line
74
91
  * @param {any} lineState
@@ -89,6 +106,10 @@ export const tokenizeLine = (line, lineState) => {
89
106
  } else if ((next = part.match(RE_WHITESPACE))) {
90
107
  token = TokenType.Whitespace
91
108
  state = State.TopLevelContent
109
+ } else if ((next = part.match(RE_PROPERTY_NAME))) {
110
+ part
111
+ token = TokenType.PropertyName
112
+ state = State.AfterPropertyName
92
113
  } else if ((next = part.match(RE_ANYTHING))) {
93
114
  token = TokenType.Text
94
115
  state = State.TopLevelContent
@@ -105,15 +126,45 @@ export const tokenizeLine = (line, lineState) => {
105
126
  throw new Error('no')
106
127
  }
107
128
  break
129
+ case State.AfterPropertyName:
130
+ if ((next = part.match(RE_EQUAL_SIGN))) {
131
+ token = TokenType.Punctuation
132
+ state = State.AfterPropertyNameAfterEqualSign
133
+ } else if ((next = part.match(RE_WHITESPACE))) {
134
+ token = TokenType.Whitespace
135
+ state = State.AfterPropertyName
136
+ } else {
137
+ part
138
+ throw new Error('no')
139
+ }
140
+ break
141
+ case State.AfterPropertyNameAfterEqualSign:
142
+ if ((next = part.match(RE_WHITESPACE))) {
143
+ token = TokenType.Whitespace
144
+ state = State.AfterPropertyNameAfterEqualSign
145
+ } else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
146
+ token = TokenType.LanguageConstant
147
+ state = State.TopLevelContent
148
+ } else if ((next = part.match(RE_NUMERIC))) {
149
+ token = TokenType.Numeric
150
+ state = State.TopLevelContent
151
+ } else if ((next = part.match(RE_LINE_COMMENT_START))) {
152
+ token = TokenType.Comment
153
+ state = State.InsideLineComment
154
+ } else if ((next = part.match(RE_ANYTHING))) {
155
+ token = TokenType.PropertyValueString
156
+ state = State.TopLevelContent
157
+ } else {
158
+ throw new Error('no')
159
+ }
160
+ break
108
161
  default:
109
162
  console.log({ state, line })
110
163
  throw new Error('no')
111
164
  }
112
- index += next[0].length
113
- tokens.push({
114
- type: token,
115
- length: next[0].length,
116
- })
165
+ const tokenLength = next[0].length
166
+ index += tokenLength
167
+ tokens.push(token, tokenLength)
117
168
  }
118
169
  return {
119
170
  state,
@@ -5,6 +5,7 @@ export const State = {
5
5
  TopLevelContent: 1,
6
6
  InsideLineComment: 2,
7
7
  AfterPropertyName: 3,
8
+ AfterPropertyNameAfterEqualSign: 4,
8
9
  }
9
10
 
10
11
  /**
@@ -28,13 +29,17 @@ export const TokenType = {
28
29
  export const TokenMap = {
29
30
  [TokenType.Text]: 'Text',
30
31
  [TokenType.Comment]: 'Comment',
32
+ [TokenType.PropertyName]: 'PropertyName',
33
+ [TokenType.Whitespace]: 'Whitespace',
34
+ [TokenType.Punctuation]: 'Punctuation',
35
+ [TokenType.PropertyValueString]: 'String',
31
36
  }
32
37
 
33
38
  const RE_LINE_COMMENT_START = /^#/
34
39
  const RE_WHITESPACE = /^ +/
35
40
  const RE_CURLY_OPEN = /^\{/
36
41
  const RE_CURLY_CLOSE = /^\}/
37
- const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:)/
42
+ const RE_PROPERTY_NAME = /^[\w\-\_]+\b(?=\=)/
38
43
  const RE_PROPERTY_VALUE = /^[^;\}]+/
39
44
  const RE_SEMICOLON = /^;/
40
45
  const RE_COMMA = /^,/
@@ -59,7 +64,8 @@ const RE_COMBINATOR = /^[\+\>\~]/
59
64
  const RE_LANGUAGE_CONSTANT = /^(?:true|false)/
60
65
  const RE_COLON = /^:/
61
66
  const RE_DASH = /^\-/
62
- const RE_WORDS = /^[\w\s]*\w/
67
+ const RE_EQUAL_SIGN = /^\=/
68
+ const RE_WORD = /^[\w\*\.\/]+/
63
69
 
64
70
  export const initialLineState = {
65
71
  state: 1,
@@ -88,6 +94,12 @@ export const tokenizeLine = (line, lineState) => {
88
94
  } else if ((next = part.match(RE_WHITESPACE))) {
89
95
  token = TokenType.Whitespace
90
96
  state = State.TopLevelContent
97
+ } else if ((next = part.match(RE_PROPERTY_NAME))) {
98
+ token = TokenType.PropertyName
99
+ state = State.AfterPropertyName
100
+ } else if ((next = part.match(RE_WORD))) {
101
+ token = TokenType.Text
102
+ state = State.TopLevelContent
91
103
  } else if ((next = part.match(RE_ANYTHING))) {
92
104
  token = TokenType.Text
93
105
  state = State.TopLevelContent
@@ -104,9 +116,9 @@ export const tokenizeLine = (line, lineState) => {
104
116
  }
105
117
  break
106
118
  case State.AfterPropertyName:
107
- if ((next = part.match(RE_COLON))) {
119
+ if ((next = part.match(RE_EQUAL_SIGN))) {
108
120
  token = TokenType.Punctuation
109
- state = State.AfterPropertyNameAfterColon
121
+ state = State.AfterPropertyNameAfterEqualSign
110
122
  } else if ((next = part.match(RE_WHITESPACE))) {
111
123
  token = TokenType.Whitespace
112
124
  state = State.AfterPropertyName
@@ -114,6 +126,21 @@ export const tokenizeLine = (line, lineState) => {
114
126
  throw new Error('no')
115
127
  }
116
128
  break
129
+ case State.AfterPropertyNameAfterEqualSign:
130
+ if ((next = part.match(RE_LINE_COMMENT_START))) {
131
+ token = TokenType.Comment
132
+ state = State.InsideLineComment
133
+ } else if ((next = part.match(RE_WORD))) {
134
+ token = TokenType.PropertyValueString
135
+ state = State.TopLevelContent
136
+ } else if ((next = part.match(RE_WHITESPACE))) {
137
+ token = TokenType.Whitespace
138
+ state = State.AfterPropertyNameAfterEqualSign
139
+ } else {
140
+ part
141
+ throw new Error('no')
142
+ }
143
+ break
117
144
  default:
118
145
  console.log({ state, line })
119
146
  throw new Error('no')
@@ -122,7 +149,7 @@ export const tokenizeLine = (line, lineState) => {
122
149
  index += tokenLength
123
150
  tokens.push(token, tokenLength)
124
151
  }
125
- if (state === State.AfterPropertyNameAfterColon) {
152
+ if (state === State.InsideLineComment) {
126
153
  state = State.TopLevelContent
127
154
  }
128
155
  return {
@@ -5,7 +5,7 @@
5
5
  "languages": [
6
6
  {
7
7
  "id": "javascript",
8
- "extensions": [".js"],
8
+ "extensions": [".js", ".es6", ".mjs", ".cjs", ".pac"],
9
9
  "tokenize": "src/tokenizeJavaScript.js",
10
10
  "configuration": "./languageConfiguration.json"
11
11
  }
@@ -120,6 +120,14 @@ export const initialLineState = {
120
120
  state: State.TopLevelContent,
121
121
  }
122
122
 
123
+ export const hasArrayReturn = true
124
+
125
+ /**
126
+ *
127
+ * @param {string} line
128
+ * @param {*} lineState
129
+ * @returns
130
+ */
123
131
  export const tokenizeLine = (line, lineState) => {
124
132
  let next = null
125
133
  let index = 0
@@ -280,16 +288,12 @@ export const tokenizeLine = (line, lineState) => {
280
288
  state
281
289
  throw new Error('no')
282
290
  }
283
- index += next[0].length
284
- tokens.push({
285
- type: token,
286
- length: next[0].length,
287
- })
291
+ const tokenLength = next[0].length
292
+ index += tokenLength
293
+ tokens.push(token, tokenLength)
288
294
  }
289
295
  return {
290
296
  state,
291
297
  tokens,
292
298
  }
293
299
  }
294
-
295
- tokenizeLine(`\`\``, initialLineState) //?
@@ -27,7 +27,8 @@
27
27
  ".hintrc",
28
28
  ".babelrc",
29
29
  ".prettierrc",
30
- ".sublime-project"
30
+ ".sublime-project",
31
+ ".code-snippets"
31
32
  ],
32
33
  "filenames": ["composer.lock", ".watchmanconfig"],
33
34
  "tokenize": "src/tokenizeJson.js"
@@ -99,8 +99,11 @@ export const initialLineState = {
99
99
  stack: [],
100
100
  }
101
101
 
102
+ export const hasArrayReturn = true
103
+
102
104
  /**
103
105
  * @param {string} line
106
+ * @param {any} lineState
104
107
  */
105
108
  export const tokenizeLine = (line, lineState) => {
106
109
  let next
@@ -110,6 +113,7 @@ export const tokenizeLine = (line, lineState) => {
110
113
  let __r = 0
111
114
  const tokens = []
112
115
  const stack = lineState.stack
116
+ state
113
117
  while (index < line.length) {
114
118
  if (__r++ > 100_000_000_000) {
115
119
  throw new Error('endless loop')
@@ -159,6 +163,7 @@ export const tokenizeLine = (line, lineState) => {
159
163
  }
160
164
  break
161
165
  case State.AfterCurlyOpen:
166
+ part
162
167
  if ((next = part.match(RE_WHITESPACE))) {
163
168
  token = TokenType.Whitespace
164
169
  state = State.AfterCurlyOpen
@@ -187,6 +192,7 @@ export const tokenizeLine = (line, lineState) => {
187
192
  } else if ((next = part.match(RE_DOUBLE_QUOTE))) {
188
193
  token = TokenType.Punctuation
189
194
  state = stack.pop()
195
+ state
190
196
  } else if ((next = part.match(RE_ESCAPED_QUOTE))) {
191
197
  token = TokenType.JsonPropertyName
192
198
  state = State.InsidePropertyNameString
@@ -220,6 +226,9 @@ export const tokenizeLine = (line, lineState) => {
220
226
  if ((next = part.match(RE_COLON))) {
221
227
  token = TokenType.Punctuation
222
228
  state = State.AfterPropertyNameAfterColon
229
+ } else if ((next = part.match(RE_WHITESPACE))) {
230
+ token = TokenType.Whitespace
231
+ state = State.AfterPropertyName
223
232
  } else if ((next = part.match(RE_ANYTHING))) {
224
233
  token = TokenType.Text
225
234
  state = State.AfterCurlyOpen
@@ -228,11 +237,11 @@ export const tokenizeLine = (line, lineState) => {
228
237
  }
229
238
  break
230
239
  case State.AfterPropertyNameAfterColon:
240
+ part
231
241
  if ((next = part.match(RE_WHITESPACE))) {
232
242
  token = TokenType.Whitespace
233
243
  state = State.AfterPropertyNameAfterColon
234
244
  } else if ((next = part.match(RE_DOUBLE_QUOTE))) {
235
- line.slice(0, index) //?
236
245
  token = TokenType.Punctuation
237
246
  state = State.InsideString
238
247
  stack.push(State.AfterPropertyValue)
@@ -292,10 +301,7 @@ export const tokenizeLine = (line, lineState) => {
292
301
  const currentTokenText = next[0]
293
302
  const currentTokenLength = currentTokenText.length
294
303
  index += currentTokenLength
295
- tokens.push({
296
- type: token,
297
- length: currentTokenLength,
298
- })
304
+ tokens.push(token, currentTokenLength)
299
305
  }
300
306
  if (state === State.InsideLineComment) {
301
307
  state = State.TopLevelContent
@@ -306,22 +312,3 @@ export const tokenizeLine = (line, lineState) => {
306
312
  tokens,
307
313
  }
308
314
  }
309
-
310
- // const result = tokenizeLine(` "a": "b",`, {
311
- // state: State.AfterCurlyOpen,
312
- // }) //?
313
-
314
- const result = tokenizeLine(
315
- `"extends: "eslint:recommended",
316
- `,
317
- {
318
- state: State.AfterCurlyOpen,
319
- stack: [],
320
- }
321
- ) //?
322
-
323
- result.tokens.map((t) => TokenMap[t.type]) //?
324
-
325
- // tokenizeLine(`{
326
- // "a": "b"
327
- // }`) //?
@@ -4,6 +4,7 @@
4
4
  export const State = {
5
5
  TopLevelContent: 1,
6
6
  InsideString: 2,
7
+ InsideLineComment: 3,
7
8
  }
8
9
 
9
10
  export const StateMap = {
@@ -22,6 +23,8 @@ export const TokenType = {
22
23
  Numeric: 6,
23
24
  Punctuation: 7,
24
25
  VariableName: 8,
26
+ Comment: 885,
27
+ Text: 9,
25
28
  }
26
29
 
27
30
  export const TokenMap = {
@@ -33,8 +36,11 @@ export const TokenMap = {
33
36
  [TokenType.Numeric]: 'Numeric',
34
37
  [TokenType.Punctuation]: 'Punctuation',
35
38
  [TokenType.VariableName]: 'VariableName',
39
+ [TokenType.Comment]: 'Comment',
40
+ [TokenType.Text]: 'Text',
36
41
  }
37
42
 
43
+ const RE_LINE_COMMENT_START = /^#/
38
44
  const RE_SELECTOR = /^[\.a-zA-Z\d\-\:>]+/
39
45
  const RE_WHITESPACE = /^ +/
40
46
  const RE_CURLY_OPEN = /^\{/
@@ -44,14 +50,14 @@ const RE_COLON = /^:/
44
50
  const RE_PROPERTY_VALUE = /^[^;\}]+/
45
51
  const RE_SEMICOLON = /^;/
46
52
  const RE_COMMA = /^,/
47
- const RE_ANYTHING = /^.*/
53
+ const RE_ANYTHING = /^.*/s
48
54
  const RE_ANYTHING_UNTIL_CLOSE_BRACE = /^[^\}]+/
49
55
  const RE_QUOTE_DOUBLE = /^"/
50
56
  const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
51
57
  const RE_KEYWORD =
52
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/
53
59
 
54
- const RE_VARIABLE_NAME = /^[a-zA-Z]+/
60
+ const RE_VARIABLE_NAME = /^[a-zA-Z\_]+/
55
61
  const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)<>]/
56
62
  const RE_NUMERIC = /^\d+/
57
63
 
@@ -60,12 +66,21 @@ export const initialLineState = {
60
66
  tokens: [],
61
67
  }
62
68
 
69
+ /**
70
+ *
71
+ * @param {any} lineStateA
72
+ * @param {any} lineStateB
73
+ * @returns
74
+ */
63
75
  export const isEqualLineState = (lineStateA, lineStateB) => {
64
76
  return lineStateA.state === lineStateB.state
65
77
  }
66
78
 
79
+ export const hasArrayReturn = true
80
+
67
81
  /**
68
82
  * @param {string} line
83
+ * @param {any} lineState
69
84
  */
70
85
  export const tokenizeLine = (line, lineState) => {
71
86
  let next = null
@@ -95,6 +110,12 @@ export const tokenizeLine = (line, lineState) => {
95
110
  } else if ((next = part.match(RE_QUOTE_DOUBLE))) {
96
111
  token = TokenType.PunctuationString
97
112
  state = State.InsideString
113
+ } else if ((next = part.match(RE_LINE_COMMENT_START))) {
114
+ token = TokenType.Comment
115
+ state = State.InsideLineComment
116
+ } else if ((next = part.match(RE_ANYTHING))) {
117
+ token = TokenType.Text
118
+ state = State.TopLevelContent
98
119
  } else {
99
120
  part //?
100
121
  throw new Error('no')
@@ -111,14 +132,23 @@ export const tokenizeLine = (line, lineState) => {
111
132
  throw new Error('no')
112
133
  }
113
134
  break
135
+ case State.InsideLineComment:
136
+ if ((next = part.match(RE_ANYTHING))) {
137
+ token = TokenType.Comment
138
+ state = State.TopLevelContent
139
+ } else {
140
+ throw new Error('no')
141
+ }
142
+ break
114
143
  default:
115
144
  throw new Error('no')
116
145
  }
117
- index += next[0].length
118
- tokens.push({
119
- type: token,
120
- length: next[0].length,
121
- })
146
+ const tokenLength = next[0].length
147
+ index += tokenLength
148
+ tokens.push(token, tokenLength)
149
+ }
150
+ if (state === State.InsideLineComment) {
151
+ state = State.TopLevelContent
122
152
  }
123
153
  return {
124
154
  state,
@@ -7,6 +7,11 @@ export const State = {
7
7
  AfterPropertyName: 3,
8
8
  AfterPropertyNameAfterColon: 4,
9
9
  AfterDash: 5,
10
+ AfterPropertyNameAfterColonAfterNewLine: 6,
11
+ AfterPipe: 7,
12
+ InsideMultiLineString: 8,
13
+ InsideMultiLineStringAfterWhitespace: 9,
14
+ AfterPropertyValue: 10,
10
15
  }
11
16
 
12
17
  export const StateMap = {
@@ -31,6 +36,7 @@ export const TokenType = {
31
36
  Text: 887,
32
37
  Unknown: 881,
33
38
  Whitespace: 2,
39
+ String: 188,
34
40
  }
35
41
 
36
42
  export const TokenMap = {
@@ -47,18 +53,20 @@ export const TokenMap = {
47
53
  [TokenType.Whitespace]: 'Whitespace',
48
54
  [TokenType.Punctuation]: 'Punctuation',
49
55
  [TokenType.PropertyValueString]: 'String',
56
+ [TokenType.String]: 'String',
50
57
  }
51
58
 
52
59
  const RE_LINE_COMMENT_START = /^#/
53
60
  const RE_WHITESPACE = /^ +/
54
61
  const RE_CURLY_OPEN = /^\{/
55
62
  const RE_CURLY_CLOSE = /^\}/
56
- const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:)/
57
- const RE_PROPERTY_VALUE = /^[^;\}]+/
63
+ const RE_PROPERTY_NAME = /^[a-zA-Z\-\_\d\s]+\b(?=\s*:(\s+|$))/
64
+ const RE_PROPERTY_VALUE_1 = /^.+(?=\s+#)/s
58
65
  const RE_SEMICOLON = /^;/
59
66
  const RE_COMMA = /^,/
60
67
  const RE_ANYTHING = /^.*/
61
- const RE_NUMERIC = /^(([0-9]+\.?[0-9]*)|(\.[0-9]+))/
68
+ const RE_ANYTHING_BUT_COMMENT = /^[^#]+/
69
+ const RE_NUMERIC = /^(([0-9]+\.?[0-9]*)|(\.[0-9]+))\b/
62
70
  const RE_ANYTHING_UNTIL_CLOSE_BRACE = /^[^\}]+/
63
71
  const RE_BLOCK_COMMENT_START = /^\/\*/
64
72
  const RE_BLOCK_COMMENT_END = /^\*\//
@@ -74,18 +82,35 @@ const RE_STAR = /^\*/
74
82
  const RE_QUERY_NAME = /^[a-z\-]+/
75
83
  const RE_QUERY_CONTENT = /^[^\)]+/
76
84
  const RE_COMBINATOR = /^[\+\>\~]/
77
- const RE_LANGUAGE_CONSTANT = /^(?:true|false)/
85
+ const RE_LANGUAGE_CONSTANT = /^(?:true|false|null)(?!#)/
78
86
  const RE_COLON = /^:/
79
87
  const RE_DASH = /^\-/
88
+ const RE_WORDS = /^[\w\s]*\w/
89
+ const RE_MULTI_LINE_STRING_START = /^(?:\||>)/
90
+ const RE_KEY_PRE = /^\s*(\-\s*)?/
80
91
 
81
92
  export const initialLineState = {
82
93
  state: State.TopLevelContent,
83
94
  tokens: [],
84
- stack: [],
95
+ indent: '',
96
+ keyOffset: 0,
85
97
  }
86
98
 
87
99
  export const hasArrayReturn = true
88
100
 
101
+ /**
102
+ *
103
+ * @param {string} line
104
+ * @returns {number}
105
+ */
106
+ const getKeyOffset = (line) => {
107
+ const whiteSpaceMatch = line.match(RE_KEY_PRE)
108
+ if (whiteSpaceMatch) {
109
+ return whiteSpaceMatch[0].length
110
+ }
111
+ return 0
112
+ }
113
+
89
114
  /**
90
115
  * @param {string} line
91
116
  * @param {any} lineState
@@ -96,6 +121,7 @@ export const tokenizeLine = (line, lineState) => {
96
121
  let tokens = []
97
122
  let token = TokenType.None
98
123
  let state = lineState.state
124
+ let keyOffset = lineState.keyOffset
99
125
  while (index < line.length) {
100
126
  const part = line.slice(index)
101
127
  switch (state) {
@@ -118,6 +144,9 @@ export const tokenizeLine = (line, lineState) => {
118
144
  } else if ((next = part.match(RE_NUMERIC))) {
119
145
  token = TokenType.Numeric
120
146
  state = State.TopLevelContent
147
+ } else if ((next = part.match(RE_WORDS))) {
148
+ token = TokenType.Text
149
+ state = State.TopLevelContent
121
150
  } else if ((next = part.match(RE_ANYTHING))) {
122
151
  token = TokenType.Text
123
152
  state = State.TopLevelContent
@@ -155,6 +184,16 @@ export const tokenizeLine = (line, lineState) => {
155
184
  } else if ((next = part.match(RE_NUMERIC))) {
156
185
  token = TokenType.Numeric
157
186
  state = State.TopLevelContent
187
+ } else if ((next = part.match(RE_LINE_COMMENT_START))) {
188
+ token = TokenType.Comment
189
+ state = State.InsideLineComment
190
+ } else if ((next = part.match(RE_MULTI_LINE_STRING_START))) {
191
+ part
192
+ token = TokenType.Punctuation
193
+ state = State.AfterPipe
194
+ } else if ((next = part.match(RE_PROPERTY_VALUE_1))) {
195
+ token = TokenType.PropertyValueString
196
+ state = State.AfterPropertyValue
158
197
  } else if ((next = part.match(RE_ANYTHING))) {
159
198
  token = TokenType.PropertyValueString
160
199
  state = State.TopLevelContent
@@ -162,6 +201,26 @@ export const tokenizeLine = (line, lineState) => {
162
201
  throw new Error('no')
163
202
  }
164
203
  break
204
+ case State.AfterPropertyValue:
205
+ if ((next = part.match(RE_WHITESPACE))) {
206
+ token = TokenType.Whitespace
207
+ state = State.AfterPropertyValue
208
+ } else if ((next = part.match(RE_LINE_COMMENT_START))) {
209
+ token = TokenType.Comment
210
+ state = State.InsideLineComment
211
+ } else {
212
+ part
213
+ throw new Error('no')
214
+ }
215
+ break
216
+ case State.AfterPipe:
217
+ if ((next = part.match(RE_WHITESPACE))) {
218
+ token = TokenType.Whitespace
219
+ state = State.AfterPipe
220
+ } else {
221
+ throw new Error('no')
222
+ }
223
+ break
165
224
  case State.AfterDash:
166
225
  if ((next = part.match(RE_WHITESPACE))) {
167
226
  token = TokenType.Whitespace
@@ -182,19 +241,81 @@ export const tokenizeLine = (line, lineState) => {
182
241
  throw new Error('no')
183
242
  }
184
243
  break
244
+ case State.AfterPropertyNameAfterColonAfterNewLine:
245
+ if ((next = part.match(RE_WHITESPACE))) {
246
+ token = TokenType.Whitespace
247
+ state = State.AfterPropertyNameAfterColonAfterNewLine
248
+ } else if ((next = part.match(RE_DASH))) {
249
+ token = TokenType.Punctuation
250
+ state = State.AfterDash
251
+ } else if ((next = part.match(RE_PROPERTY_NAME))) {
252
+ token = TokenType.PropertyName
253
+ state = State.AfterPropertyName
254
+ } else if ((next = part.match(RE_NUMERIC))) {
255
+ token = TokenType.Numeric
256
+ state = State.TopLevelContent
257
+ } else if ((next = part.match(RE_LANGUAGE_CONSTANT))) {
258
+ token = TokenType.LanguageConstant
259
+ state = State.TopLevelContent
260
+ } else if ((next = part.match(RE_WORDS))) {
261
+ token = TokenType.PropertyValueString
262
+ state = State.TopLevelContent
263
+ } else if ((next = part.match(RE_LINE_COMMENT_START))) {
264
+ token = TokenType.Comment
265
+ state = State.InsideLineComment
266
+ } else {
267
+ part
268
+ throw new Error('no')
269
+ }
270
+ break
271
+ case State.InsideMultiLineString:
272
+ if ((next = part.match(RE_WHITESPACE))) {
273
+ token = TokenType.Whitespace
274
+ if (next[0].length > keyOffset) {
275
+ state = State.InsideMultiLineStringAfterWhitespace
276
+ } else {
277
+ state = State.TopLevelContent
278
+ }
279
+ } else if ((next = part.match(RE_PROPERTY_NAME))) {
280
+ token = TokenType.PropertyName
281
+ state = State.AfterPropertyName
282
+ } else if ((next = part.match(RE_ANYTHING))) {
283
+ token = TokenType.Text
284
+ state = State.TopLevelContent
285
+ } else {
286
+ throw new Error('no')
287
+ }
288
+ break
289
+ case State.InsideMultiLineStringAfterWhitespace:
290
+ if ((next = part.match(RE_ANYTHING))) {
291
+ token = TokenType.String
292
+ state = State.InsideMultiLineString
293
+ } else {
294
+ throw new Error('no')
295
+ }
296
+ break
185
297
  default:
186
298
  console.log({ state, line })
187
299
  throw new Error('no')
188
300
  }
189
- const length = next[0].length
190
- index += length
191
- tokens.push(token, length)
301
+ const tokenLength = next[0].length
302
+ index += tokenLength
303
+ tokens.push(token, tokenLength)
192
304
  }
193
- if (state === State.AfterPropertyNameAfterColon) {
194
- state = State.TopLevelContent
305
+ switch (state) {
306
+ case State.AfterPropertyNameAfterColon:
307
+ state = State.AfterPropertyNameAfterColonAfterNewLine
308
+ break
309
+ case State.AfterPipe:
310
+ keyOffset = getKeyOffset(line)
311
+ state = State.InsideMultiLineString
312
+ break
313
+ default:
314
+ break
195
315
  }
196
316
  return {
197
317
  state,
198
318
  tokens,
319
+ keyOffset,
199
320
  }
200
321
  }
@@ -667,6 +667,7 @@
667
667
  "_f_markdownlint_ignore": "/icons/file_type_markdownlint_ignore.svg",
668
668
  "_f_marko": "/icons/file_type_marko.svg",
669
669
  "_f_markojs": "/icons/file_type_markojs.svg",
670
+ "_f_master-co": "/icons/file_type_master-co.svg",
670
671
  "_f_matlab": "/icons/file_type_matlab.svg",
671
672
  "_f_maven": "/icons/file_type_maven.svg",
672
673
  "_f_maxscript": "/icons/file_type_maxscript.svg",
@@ -994,6 +995,7 @@
994
995
  "_f_webpack": "/icons/file_type_webpack.svg",
995
996
  "_f_wenyan": "/icons/file_type_wenyan.svg",
996
997
  "_f_wercker": "/icons/file_type_wercker.svg",
998
+ "_f_wgsl": "/icons/file_type_wgsl.svg",
997
999
  "_f_wikitext": "/icons/file_type_wikitext.svg",
998
1000
  "_f_windi": "/icons/file_type_windi.svg",
999
1001
  "_f_wolfram": "/icons/file_type_wolfram.svg",
@@ -1195,6 +1197,7 @@
1195
1197
  ".eslintrc": "_f_eslint",
1196
1198
  ".eslintignore": "_f_eslint",
1197
1199
  ".eslintcache": "_f_eslint",
1200
+ "eslint.config.js": "_f_eslint",
1198
1201
  ".eslintrc.js": "_f_eslint",
1199
1202
  ".eslintrc.mjs": "_f_eslint",
1200
1203
  ".eslintrc.cjs": "_f_eslint",
@@ -1377,6 +1380,7 @@
1377
1380
  "license-apache.md": "_f_license",
1378
1381
  "license-apache.txt": "_f_license",
1379
1382
  ".licrc": "_f_licensebat",
1383
+ ".lighthouserc.cjs": "_f_lighthouse",
1380
1384
  ".lighthouserc.js": "_f_lighthouse",
1381
1385
  ".lighthouserc.json": "_f_lighthouse",
1382
1386
  ".lighthouserc.yaml": "_f_lighthouse",
@@ -1407,6 +1411,14 @@
1407
1411
  ".markdownlint-cli2.yaml": "_f_markdownlint",
1408
1412
  ".markdownlint-cli2.cjs": "_f_markdownlint",
1409
1413
  ".markdownlintignore": "_f_markdownlint_ignore",
1414
+ "master.js": "_f_master-co",
1415
+ "master.ts": "_f_master-co",
1416
+ "master.mjs": "_f_master-co",
1417
+ "master.json": "_f_master-co",
1418
+ "master.css.js": "_f_master-co",
1419
+ "master.css.ts": "_f_master-co",
1420
+ "master.css.mjs": "_f_master-co",
1421
+ "master.css.json": "_f_master-co",
1410
1422
  "maven.config": "_f_maven",
1411
1423
  "pom.xml": "_f_maven",
1412
1424
  "extensions.xml": "_f_maven",
@@ -1437,6 +1449,7 @@
1437
1449
  "ng-tailwind.js": "_f_ng_tailwind",
1438
1450
  "nginx.conf": "_f_nginx",
1439
1451
  "build.ninja": "_f_ninja",
1452
+ "flake.lock": "_f_nix",
1440
1453
  ".node-version": "_f_node",
1441
1454
  ".nvmrc": "_f_node",
1442
1455
  "nodemon.json": "_f_nodemon",
@@ -3520,6 +3533,7 @@
3520
3533
  "wasm": "_f_wasm",
3521
3534
  "wat": "_f_wasm",
3522
3535
  "wenyan": "_f_wenyan",
3536
+ "wgsl": "_f_wgsl",
3523
3537
  "wikitext": "_f_wikitext",
3524
3538
  "wolfram": "_f_wolfram",
3525
3539
  "wurstlang": "_f_wurst",
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32"><defs><linearGradient id="a" x1="0.5" y1="-1.054" x2="0.5" y2="1.002" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#c8861c"/><stop offset="0.323" stop-color="#e6a345"/><stop offset="1" stop-color="#f6db9b"/></linearGradient><linearGradient id="b" x1="21.397" y1="-1.054" x2="21.397" y2="1.002" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#c78a28"/><stop offset="0.323" stop-color="#e6a345"/><stop offset="1" stop-color="#f6db9b"/></linearGradient><linearGradient id="c" x1="0.156" y1="-0.44" x2="0.754" y2="1.009" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#fcdd98"/><stop offset="0.232" stop-color="#fada94"/><stop offset="0.407" stop-color="#f6d48b"/><stop offset="0.564" stop-color="#efc87b"/><stop offset="0.709" stop-color="#e6b864"/><stop offset="0.847" stop-color="#d9a346"/><stop offset="0.975" stop-color="#c98922"/><stop offset="1" stop-color="#e6a345"/></linearGradient><clipPath id="e"><rect width="32" height="32"/></clipPath></defs><g id="d" clip-path="url(#e)"><g transform="translate(1.999 8.399)"><path d="M581.955,173.456c-.732-1.3-1.349-1.489-1.949-1.489-.882,0-1.495.815-1.887,1.539l-1.564,3.212.426.7a5.836,5.836,0,0,0,7.852,2.464l.407-.212Z" transform="translate(-557.239 -165.337)" fill="url(#a)"/><path d="M519.451,173.456c.732-1.3,1.348-1.489,1.95-1.489.882,0,1.494.815,1.886,1.539l1.564,3.212-.426.7a5.836,5.836,0,0,1-7.852,2.464l-.407-.212Z" transform="translate(-516.166 -165.337)" fill="url(#b)"/><path d="M546.924,152.989a3.231,3.231,0,0,0-5.725-.035l-1.686,3.23-1.687-3.23a3.231,3.231,0,0,0-5.725.035l-2.194,4.245c1.042-1.182,2.5-.486,3.137.717l2.366,4.356,1.21,2.315a3.208,3.208,0,0,0,1.378,1.4,3.349,3.349,0,0,0,3.026,0,3.209,3.209,0,0,0,1.378-1.4l1.21-2.315,2.366-4.356c.636-1.2,2.1-1.9,3.137-.717Z" transform="translate(-525.512 -151.239)" fill="url(#c)"/></g></g></svg>
@@ -0,0 +1,86 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ id="Logo"
4
+ viewBox="0 0 768 600"
5
+ width="32"
6
+ height="32"
7
+ version="1.1"
8
+ sodipodi:docname="file_type_wgsl.svg"
9
+ inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ xmlns:svg="http://www.w3.org/2000/svg">
14
+ <sodipodi:namedview
15
+ id="namedview63"
16
+ pagecolor="#ffffff"
17
+ bordercolor="#666666"
18
+ borderopacity="1.0"
19
+ inkscape:pageshadow="2"
20
+ inkscape:pageopacity="0.0"
21
+ inkscape:pagecheckerboard="0"
22
+ showgrid="false"
23
+ inkscape:zoom="25.588427"
24
+ inkscape:cx="8.871198"
25
+ inkscape:cy="17.664236"
26
+ inkscape:window-width="2520"
27
+ inkscape:window-height="1365"
28
+ inkscape:window-x="15"
29
+ inkscape:window-y="50"
30
+ inkscape:window-maximized="1"
31
+ inkscape:current-layer="Logo" />
32
+ <defs
33
+ id="defs55">
34
+ <style
35
+ id="style53">
36
+ .cls-1 {
37
+ fill: #005a9c;
38
+ }
39
+
40
+ .cls-1, .cls-2, .cls-3, .cls-4, .cls-5, .cls-6 {
41
+ fill-rule: evenodd;
42
+ }
43
+
44
+ .cls-2 {
45
+ fill: #0066b0;
46
+ }
47
+
48
+ .cls-3 {
49
+ fill: #0076cc;
50
+ }
51
+
52
+ .cls-4 {
53
+ fill: #0086e8;
54
+ }
55
+
56
+ .cls-5 {
57
+ fill: #0093ff;
58
+ }
59
+ </style>
60
+ </defs>
61
+ <path
62
+ id="Triangle_1"
63
+ data-name="Triangle 1"
64
+ class="cls-1"
65
+ d="M 293.6275,508.5 52.8725,91.5 h 481.51 z" />
66
+ <path
67
+ id="Triangle_2"
68
+ data-name="Triangle 2"
69
+ class="cls-2"
70
+ d="m 534.6275,91.5 -120.5,208 h 241 z" />
71
+ <path
72
+ id="Triangle_3"
73
+ data-name="Triangle 3"
74
+ class="cls-3"
75
+ d="m 534.6275,507.5 -120.5,-208 h 241 z" />
76
+ <path
77
+ id="Triangle_4"
78
+ data-name="Triangle 4"
79
+ class="cls-4"
80
+ d="m 654.6275,300.5 -60.5,-104 h 121 z" />
81
+ <path
82
+ id="Triangle_5"
83
+ data-name="Triangle 5"
84
+ class="cls-5"
85
+ d="m 654.6275,92.5 -60.5,104 h 121 z" />
86
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "debug": "^4.3.4",
25
25
  "execa": "^6.1.0",
26
26
  "exit-hook": "^3.1.0",
27
- "got": "^12.4.1",
27
+ "got": "^12.5.0",
28
28
  "is-object": "^1.0.2",
29
29
  "json-parse-even-better-errors": "^2.3.1",
30
30
  "jsonc-parser": "^3.2.0",
@@ -38,13 +38,13 @@
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.3",
42
- "@lvce-editor/extension-host": "0.4.3"
41
+ "@lvce-editor/pty-host": "0.5.0",
42
+ "@lvce-editor/extension-host": "0.5.0"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "electron-clipboard-ex": "^1.3.3",
46
46
  "keytar": "^7.9.0",
47
- "vscode-ripgrep-with-github-api-error-fix": "^2.4.1"
47
+ "vscode-ripgrep-with-github-api-error-fix": "^2.5.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/debug": "^4.1.7",
@@ -0,0 +1,8 @@
1
+ import VError from 'verror'
2
+
3
+ export class FileNotFoundError extends VError {
4
+ constructor(path) {
5
+ super(`File not found '${path}'`)
6
+ this.name = 'FileNotFoundError'
7
+ }
8
+ }
@@ -7,6 +7,7 @@ import * as Path from '../Path/Path.js'
7
7
  import * as Platform from '../Platform/Platform.js'
8
8
  import * as Trash from '../Trash/Trash.js'
9
9
  import * as FileSystemErrorCodes from '../FileSystemErrorCodes/FileSystemErrorCodes.js'
10
+ import { FileNotFoundError } from '../Error/FileNotFoundError.js'
10
11
 
11
12
  export const state = {
12
13
  watcherMap: Object.create(null),
@@ -44,20 +45,26 @@ export const readFile = async (path) => {
44
45
  return content
45
46
  } catch (error) {
46
47
  if (error && error.code === FileSystemErrorCodes.ENOENT) {
47
- throw new VError(`File not found '${path}'`)
48
+ throw new FileNotFoundError(path)
48
49
  }
49
50
  throw new VError(error, `Failed to read file "${path}"`)
50
51
  }
51
52
  }
52
53
 
53
- export const writeFile = async (path, content) => {
54
+ /**
55
+ *
56
+ * @param {string} path
57
+ * @param {string} content
58
+ * @param {BufferEncoding} encoding
59
+ */
60
+ export const writeFile = async (path, content, encoding = 'utf8') => {
54
61
  try {
55
62
  // queue would be more correct for concurrent writes but also slower
56
63
  // Queue.add(`writeFile/${path}`, () =>
57
- await fs.writeFile(path, content)
64
+ await fs.writeFile(path, content, encoding)
58
65
  } catch (error) {
59
66
  if (error && error.code === FileSystemErrorCodes.ENOENT) {
60
- throw new VError(`File not found '${path}'`)
67
+ throw new FileNotFoundError(path)
61
68
  }
62
69
  throw new VError(error, `Failed to write to file "${path}"`)
63
70
  }
@@ -210,7 +217,12 @@ export const getRealPath = async (path) => {
210
217
  return await fs.realpath(path)
211
218
  } catch (error) {
212
219
  // @ts-ignore
213
- if (error && error instanceof globalThis.Error && error.code === 'ENOENT') {
220
+ if (
221
+ error &&
222
+ error instanceof globalThis.Error &&
223
+ // @ts-ignore
224
+ error.code === FileSystemErrorCodes.ENOENT
225
+ ) {
214
226
  let content
215
227
  try {
216
228
  content = await fs.readlink(path)
@@ -1,5 +1,7 @@
1
+ import { dirname } from 'path'
1
2
  import VError from 'verror'
2
3
  import * as Assert from '../Assert/Assert.js'
4
+ import { FileNotFoundError } from '../Error/FileNotFoundError.js'
3
5
  import * as FileSystem from '../FileSystem/FileSystem.js'
4
6
  import * as Json from '../Json/Json.js'
5
7
  import * as Platform from '../Platform/Platform.js'
@@ -40,13 +42,26 @@ const getRecentlyOpened = async (recentlyOpenedPath) => {
40
42
 
41
43
  const setRecentlyOpened = async (recentlyOpenedPath, newRecentlyOpened) => {
42
44
  const stringified = Json.stringify(newRecentlyOpened)
43
- await FileSystem.writeFile(recentlyOpenedPath, stringified)
45
+ try {
46
+ await FileSystem.writeFile(recentlyOpenedPath, stringified)
47
+ } catch (error) {
48
+ if (error && error instanceof FileNotFoundError) {
49
+ await FileSystem.mkdir(dirname(recentlyOpenedPath))
50
+ await FileSystem.writeFile(recentlyOpenedPath, stringified)
51
+ return
52
+ }
53
+ throw error
54
+ }
44
55
  }
45
56
 
46
57
  export const addPath = async (path) => {
47
- Assert.string(path)
48
- const recentlyOpenedPath = Platform.getRecentlyOpenedPath()
49
- const parsed = await getRecentlyOpened(recentlyOpenedPath)
50
- const newRecentlyOpened = addToArrayUnique(parsed, path)
51
- await setRecentlyOpened(recentlyOpenedPath, newRecentlyOpened)
58
+ try {
59
+ Assert.string(path)
60
+ const recentlyOpenedPath = Platform.getRecentlyOpenedPath()
61
+ const parsed = await getRecentlyOpened(recentlyOpenedPath)
62
+ const newRecentlyOpened = addToArrayUnique(parsed, path)
63
+ await setRecentlyOpened(recentlyOpenedPath, newRecentlyOpened)
64
+ } catch (error) {
65
+ throw new VError(error, `Failed to add path to recently opened`)
66
+ }
52
67
  }