@lvce-editor/shared-process 0.16.22 → 0.17.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.
@@ -56,6 +56,7 @@ export const TokenType = {
56
56
  String: 891,
57
57
  KeywordImport: 892,
58
58
  CssSelectorClass: 893,
59
+ CssPseudoSelector: 894,
59
60
  }
60
61
 
61
62
  export const TokenMap = {
@@ -83,18 +84,20 @@ export const TokenMap = {
83
84
  [TokenType.String]: 'String',
84
85
  [TokenType.KeywordImport]: 'KeywordImport',
85
86
  [TokenType.CssSelectorClass]: 'CssSelectorClass',
87
+ [TokenType.CssPseudoSelector]: 'CssPseudoSelector',
86
88
  }
87
89
 
88
- const RE_SELECTOR = /^[\.a-zA-Z\d\-\:>\+\~\_%\\]+/
89
- const RE_SELECTOR_ID = /^#[\w\-\_]+/
90
- const RE_SELECTOR_CLASS = /^\.[\w\-\_]+/
90
+ const RE_SELECTOR_ELEMENT = /^[a-zA-Z\d\->+~_%\\\p{L}]+/u
91
+ const RE_SELECTOR_ID = /^#[\w\-\_\\]+/
92
+ const RE_PSEUDO_SELECTOR = /^:[\p{L}\-]+/u
93
+ const RE_SELECTOR_CLASS = /^\.[\w\-_\p{L}\p{Emoji_Presentation}]+/u
91
94
  const RE_WHITESPACE = /^\s+/
92
95
  const RE_CURLY_OPEN = /^\{/
93
96
  const RE_CURLY_CLOSE = /^\}/
94
97
  const RE_PROPERTY_NAME = /^[a-zA-Z\-\w]+/
95
98
  const RE_COLON = /^:/
96
- const RE_PROPERTY_VALUE = /^[^;\}\/]+/
97
- const RE_PROPERTY_VALUE_SHORT = /^[^;\}\s\)\/]+/
99
+ const RE_PROPERTY_VALUE = /^[^;\}\/\(]+/
100
+ const RE_PROPERTY_VALUE_SHORT = /^[^;\}\s\)\/\*\(]+/
98
101
  const RE_PROPERTY_VALUE_INSIDE_FUNCTION = /^[^\}\s\)]+/
99
102
  const RE_SEMICOLON = /^;/
100
103
  const RE_COMMA = /^,/
@@ -110,7 +113,7 @@ const RE_PSEUDO_SELECTOR_CONTENT = /^[^\)]+/
110
113
  const RE_SQUARE_OPEN = /^\[/
111
114
  const RE_SQUARE_CLOSE = /^\]/
112
115
  const RE_ATTRIBUTE_SELECTOR_CONTENT = /^[^\]]+/
113
- const RE_QUERY = /^@[a-z\-]+/
116
+ const RE_QUERY = /^@[a-zA-Z\w\-\d\_]+/
114
117
  const RE_STAR = /^\*/
115
118
  const RE_QUERY_NAME = /^[a-zA-Z\w\-\d\_]+/
116
119
  const RE_QUERY_CONTENT = /^[^\)]+/
@@ -162,7 +165,7 @@ export const tokenizeLine = (line, lineState) => {
162
165
  if ((next = part.match(RE_SELECTOR_CLASS))) {
163
166
  token = TokenType.CssSelectorClass
164
167
  state = State.AfterSelector
165
- } else if ((next = part.match(RE_SELECTOR))) {
168
+ } else if ((next = part.match(RE_SELECTOR_ELEMENT))) {
166
169
  token = TokenType.CssSelector
167
170
  state = State.AfterSelector
168
171
  } else if ((next = part.match(RE_SELECTOR_ID))) {
@@ -171,6 +174,9 @@ export const tokenizeLine = (line, lineState) => {
171
174
  } else if ((next = part.match(RE_WHITESPACE))) {
172
175
  token = TokenType.Whitespace
173
176
  state = State.TopLevelContent
177
+ } else if ((next = part.match(RE_PSEUDO_SELECTOR))) {
178
+ token = TokenType.CssPseudoSelector
179
+ state = State.AfterSelector
174
180
  } else if ((next = part.match(RE_CURLY_OPEN))) {
175
181
  token = TokenType.CurlyOpen
176
182
  state = State.InsideSelector
@@ -181,7 +187,7 @@ export const tokenizeLine = (line, lineState) => {
181
187
  token = TokenType.Punctuation
182
188
  state = State.InsideAttributeSelector
183
189
  } else if ((next = part.match(RE_QUERY))) {
184
- switch (next[0]) {
190
+ switch (next[0].toLocaleLowerCase()) {
185
191
  case '@font-face':
186
192
  case '@-ms-viewport':
187
193
  case '@-o-viewport':
@@ -226,7 +232,7 @@ export const tokenizeLine = (line, lineState) => {
226
232
  } else if ((next = part.match(RE_SELECTOR_CLASS))) {
227
233
  token = TokenType.CssSelectorClass
228
234
  state = State.AfterSelector
229
- } else if ((next = part.match(RE_SELECTOR))) {
235
+ } else if ((next = part.match(RE_SELECTOR_ELEMENT))) {
230
236
  token = TokenType.CssSelector
231
237
  state = State.AfterSelector
232
238
  } else if ((next = part.match(RE_SELECTOR_ID))) {
@@ -247,9 +253,19 @@ export const tokenizeLine = (line, lineState) => {
247
253
  } else if ((next = part.match(RE_VERTICAL_LINE))) {
248
254
  token = TokenType.Punctuation
249
255
  state = State.AfterSelector
256
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
257
+ stack.push(state)
258
+ token = TokenType.Comment
259
+ state = State.InsideBlockComment
250
260
  } else if ((next = part.match(RE_SLASH))) {
251
261
  token = TokenType.Punctuation
252
262
  state = State.AfterSelector
263
+ } else if ((next = part.match(RE_SEMICOLON))) {
264
+ token = TokenType.Punctuation
265
+ state = stack.pop() || State.TopLevelContent
266
+ } else if ((next = part.match(RE_PSEUDO_SELECTOR))) {
267
+ token = TokenType.CssPseudoSelector
268
+ state = State.AfterSelector
253
269
  } else if ((next = part.match(RE_ANYTHING_BUT_CURLY))) {
254
270
  token = TokenType.Unknown
255
271
  state = State.AfterSelector
@@ -293,6 +309,12 @@ export const tokenizeLine = (line, lineState) => {
293
309
  stack.push(state)
294
310
  token = TokenType.Comment
295
311
  state = State.InsideBlockComment
312
+ } else if ((next = part.match(RE_SEMICOLON))) {
313
+ token = TokenType.Punctuation
314
+ state = stack.pop() || State.TopLevelContent
315
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_CLOSE_BRACE))) {
316
+ token = TokenType.Text
317
+ state = stack.pop() || State.TopLevelContent
296
318
  } else {
297
319
  part
298
320
  throw new Error('no')
@@ -305,6 +327,10 @@ export const tokenizeLine = (line, lineState) => {
305
327
  } else if ((next = part.match(RE_CURLY_OPEN))) {
306
328
  token = TokenType.Punctuation
307
329
  state = State.InsideSelector
330
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
331
+ stack.push(state)
332
+ token = TokenType.Comment
333
+ state = State.InsideBlockComment
308
334
  } else {
309
335
  throw new Error('no')
310
336
  }
@@ -341,6 +367,9 @@ export const tokenizeLine = (line, lineState) => {
341
367
  } else if ((next = part.match(RE_QUERY))) {
342
368
  token = TokenType.Query
343
369
  state = State.AfterQuery
370
+ } else if ((next = part.match(RE_SEMICOLON))) {
371
+ token = TokenType.Punctuation
372
+ state = State.InsideSelector
344
373
  } else if ((next = part.match(RE_ANYTHING_UNTIL_CLOSE_BRACE))) {
345
374
  token = TokenType.Unknown
346
375
  state = State.InsideSelector
@@ -416,6 +445,9 @@ export const tokenizeLine = (line, lineState) => {
416
445
  } else if ((next = part.match(RE_SLASH))) {
417
446
  token = TokenType.Punctuation
418
447
  state = State.AfterPropertyNameAfterColon
448
+ } else if ((next = part.match(RE_ROUND_OPEN))) {
449
+ token = TokenType.Punctuation
450
+ state = State.AfterFunctionNameInsideArguments
419
451
  } else {
420
452
  part
421
453
  throw new Error('no')
@@ -496,9 +528,16 @@ export const tokenizeLine = (line, lineState) => {
496
528
  } else if ((next = part.match(RE_CURLY_CLOSE))) {
497
529
  token = TokenType.Punctuation
498
530
  state = State.TopLevelContent
531
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
532
+ stack.push(state)
533
+ token = TokenType.Comment
534
+ state = State.InsideBlockComment
499
535
  } else if ((next = part.match(RE_SLASH))) {
500
536
  token = TokenType.Punctuation
501
537
  state = State.AfterFunctionName
538
+ } else if ((next = part.match(RE_STAR))) {
539
+ token = TokenType.Punctuation
540
+ state = State.AfterFunctionName
502
541
  } else {
503
542
  part
504
543
  throw new Error('no')
@@ -572,7 +611,12 @@ export const tokenizeLine = (line, lineState) => {
572
611
  } else if ((next = part.match(RE_DOUBLE_QUOTE))) {
573
612
  token = TokenType.Punctuation
574
613
  state = State.InsideDoubleQuoteString
614
+ } else if ((next = part.match(RE_FUNCTION))) {
615
+ stack.push(state)
616
+ token = TokenType.FuntionName
617
+ state = State.AfterFunctionName
575
618
  } else {
619
+ part
576
620
  throw new Error('no')
577
621
  }
578
622
  break
@@ -598,6 +642,9 @@ export const tokenizeLine = (line, lineState) => {
598
642
  if (state === State.AfterPropertyName) {
599
643
  state = State.InsideSelector
600
644
  }
645
+ if (state === State.AfterKeywordImport) {
646
+ state = State.TopLevelContent
647
+ }
601
648
  return {
602
649
  state,
603
650
  tokens,
@@ -15,7 +15,9 @@
15
15
  ".env.development",
16
16
  ".env.production",
17
17
  ".env.dev",
18
- ".env.sample"
18
+ ".env.sample",
19
+ ".env.dist",
20
+ ".env.test"
19
21
  ],
20
22
  "configuration": "./languageConfiguration.json",
21
23
  "tokenize": "src/tokenizeDotenv.js"
@@ -29,7 +29,9 @@ export const TokenType = {
29
29
  KeywordThis: 12,
30
30
  Class: 13,
31
31
  Comment: 14,
32
+ Text: 117,
32
33
  FunctionName: 885,
34
+ KeywordImport: 215,
33
35
  }
34
36
 
35
37
  export const TokenMap = {
@@ -49,6 +51,8 @@ export const TokenMap = {
49
51
  [TokenType.Class]: 'Class',
50
52
  [TokenType.Comment]: 'Comment',
51
53
  [TokenType.FunctionName]: 'Function',
54
+ [TokenType.Text]: 'Text',
55
+ [TokenType.KeywordImport]: 'KeywordImport',
52
56
  }
53
57
 
54
58
  export const initialLineState = {
@@ -77,6 +81,7 @@ const RE_CURLY_OPEN = /^\{/
77
81
  const RE_ANYTHING_UNTIL_END = /^.+/s
78
82
  const RE_SLASH = /^\//
79
83
  const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\())/
84
+ const RE_ANYTHING = /^.+/u
80
85
 
81
86
  export const hasArrayReturn = true
82
87
 
@@ -128,6 +133,8 @@ export const tokenizeLine = (line, lineState) => {
128
133
  case 'extends':
129
134
  token = TokenType.Keyword
130
135
  state = State.AfterKeywordBeforeClass
136
+ case 'import':
137
+ token = TokenType.KeywordImport
131
138
  break
132
139
  default:
133
140
  token = TokenType.Keyword
@@ -166,6 +173,9 @@ export const tokenizeLine = (line, lineState) => {
166
173
  } else if ((next = part.match(RE_ATTRIBUTE))) {
167
174
  token = TokenType.Attribute
168
175
  state = State.TopLevelContent
176
+ } else if ((next = part.match(RE_ANYTHING))) {
177
+ token = TokenType.Text
178
+ state = State.TopLevelContent
169
179
  } else {
170
180
  part //?
171
181
  throw new Error('no')
@@ -22,6 +22,7 @@ const State = {
22
22
  InsideBacktickString: 17,
23
23
  AfterPropertyDot: 18,
24
24
  AfterKeywordClass: 19,
25
+ AfterKeywordVariableDeclaration: 20,
25
26
  }
26
27
 
27
28
  /**
@@ -55,6 +56,7 @@ export const TokenType = {
55
56
  KeywordOperator: 887,
56
57
  KeywordFunction: 889,
57
58
  Class: 890,
59
+ KeywordVoid: 891,
58
60
  }
59
61
 
60
62
  export const TokenMap = {
@@ -84,6 +86,7 @@ export const TokenMap = {
84
86
  [TokenType.KeywordThis]: 'KeywordThis',
85
87
  [TokenType.KeywordOperator]: 'KeywordOperator',
86
88
  [TokenType.KeywordFunction]: 'KeywordFunction',
89
+ [TokenType.KeywordVoid]: 'KeywordVoid',
87
90
  [TokenType.Class]: 'Class',
88
91
  }
89
92
 
@@ -129,7 +132,7 @@ const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`\\\$]+/
129
132
  const RE_STRING_ESCAPE = /^\\./
130
133
  const RE_SHEBANG = /^#!.*/
131
134
  const RE_FUNCTION_CALL_NAME =
132
- /^[\w]+(?=\s*(\(|\=\s*(?:async\s*)?function|\=\s*(?:async\s*)?\())/
135
+ /^[\w\$]+(?=\s*(\(|\=\s*(?:async\s*)?function|\=\s*(?:async\s*)?\())/
133
136
 
134
137
  const RE_DECORATOR = /^@\w+/
135
138
  const RE_BACKSLASH = /^\\/
@@ -144,7 +147,10 @@ const RE_REGEX =
144
147
  const RE_VARIABLE_NAME_SPECIAL = /\p{L}/u
145
148
  const RE_VARIABLE_NAME_SPECIAL_2 = /./u
146
149
  const RE_BUILTIN_CLASS =
147
- /^(?:Array|Object|Promise|ArrayBuffer|URL|URLSearchParams|WebSocket|FileSystemHandle|Function|StorageEvent|MessageEvent|MessageChannel|Int32Array|Boolean|String|Error|Set|RegExp|Map|WeakMap|RangeError|Date|Headers|Response|Request|Buffer|MessagePort|FileHandle|X509Certificate|Blob|HTMLElement)\b/
150
+ /^(?:Array|Object|Promise|ArrayBuffer|URL|URLSearchParams|WebSocket|FileSystemHandle|Function|StorageEvent|MessageEvent|MessageChannel|Int32Array|Boolean|String|Error|Set|RegExp|Map|WeakMap|RangeError|Date|Headers|Response|Request|Buffer|MessagePort|FileHandle|X509Certificate|Blob|HTMLElement|HTMLFormElement)\b/
151
+
152
+ const RE_PROPERTY_NAME = /^[a-z]\w*(?=\s*\:)/
153
+ const RE_PROPERTY_NAME_FUNCTION = /^[a-z]\w*(?=\s*\()/
148
154
 
149
155
  export const initialLineState = {
150
156
  state: State.TopLevelContent,
@@ -176,6 +182,71 @@ export const tokenizeLine = (line, lineState) => {
176
182
  if ((next = part.match(RE_WHITESPACE))) {
177
183
  token = TokenType.Whitespace
178
184
  state = State.TopLevelContent
185
+ } else if ((next = part.match(RE_PROPERTY_NAME_FUNCTION))) {
186
+ switch (next[0]) {
187
+ case 'function':
188
+ token = TokenType.KeywordFunction
189
+ state = State.TopLevelContent
190
+ break
191
+ case 'async':
192
+ token = TokenType.KeywordModifier
193
+ state = State.TopLevelContent
194
+ break
195
+ case 'await':
196
+ token = TokenType.KeywordModifier
197
+ state = State.TopLevelContent
198
+ break
199
+ case 'as':
200
+ case 'switch':
201
+ case 'default':
202
+ case 'case':
203
+ case 'else':
204
+ case 'if':
205
+ case 'break':
206
+ case 'throw':
207
+ case 'for':
208
+ case 'try':
209
+ case 'catch':
210
+ case 'finally':
211
+ case 'continue':
212
+ case 'while':
213
+ token = TokenType.KeywordControl
214
+ state = State.TopLevelContent
215
+ break
216
+ case 'return':
217
+ token = TokenType.KeywordReturn
218
+ state = State.TopLevelContent
219
+ break
220
+ case 'new':
221
+ token = TokenType.KeywordNew
222
+ state = State.TopLevelContent
223
+ break
224
+ case 'this':
225
+ token = TokenType.KeywordThis
226
+ state = State.TopLevelContent
227
+ break
228
+ case 'import':
229
+ case 'export':
230
+ case 'from':
231
+ token = TokenType.KeywordImport
232
+ state = State.TopLevelContent
233
+ break
234
+ case 'constructor':
235
+ case 'super':
236
+ token = TokenType.Keyword
237
+ state = State.TopLevelContent
238
+ break
239
+ default:
240
+ token = TokenType.FunctionName
241
+ state = State.TopLevelContent
242
+ break
243
+ }
244
+ } else if ((next = part.match(RE_PROPERTY_NAME))) {
245
+ token = TokenType.VariableName
246
+ state = State.TopLevelContent
247
+ if (part === 'default:') {
248
+ token = TokenType.KeywordControl
249
+ }
179
250
  } else if ((next = part.match(RE_KEYWORD))) {
180
251
  switch (next[0]) {
181
252
  case 'true':
@@ -257,6 +328,16 @@ export const tokenizeLine = (line, lineState) => {
257
328
  token = TokenType.Keyword
258
329
  state = State.AfterKeywordClass
259
330
  break
331
+ case 'var':
332
+ case 'let':
333
+ case 'const':
334
+ token = TokenType.Keyword
335
+ state = State.AfterKeywordVariableDeclaration
336
+ break
337
+ case 'void':
338
+ token = TokenType.KeywordVoid
339
+ state = State.TopLevelContent
340
+ break
260
341
  default:
261
342
  token = TokenType.Keyword
262
343
  state = State.TopLevelContent
@@ -478,6 +559,39 @@ export const tokenizeLine = (line, lineState) => {
478
559
  throw new Error('no')
479
560
  }
480
561
  break
562
+ case State.AfterKeywordVariableDeclaration:
563
+ if ((next = part.match(RE_WHITESPACE))) {
564
+ token = TokenType.Whitespace
565
+ state = State.AfterKeywordVariableDeclaration
566
+ } else if ((next = part.match(RE_FUNCTION_CALL_NAME))) {
567
+ token = TokenType.FunctionName
568
+ state = State.TopLevelContent
569
+ } else if ((next = part.match(RE_VARIABLE_NAME))) {
570
+ token = TokenType.VariableName
571
+ state = State.TopLevelContent
572
+ } else if ((next = part.match(RE_CURLY_OPEN))) {
573
+ token = TokenType.Punctuation
574
+ state = State.TopLevelContent
575
+ } else if ((next = part.match(RE_LINE_COMMENT))) {
576
+ token = TokenType.Comment
577
+ state = State.AfterKeywordVariableDeclaration
578
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
579
+ stack.push(state)
580
+ token = TokenType.Comment
581
+ state = State.InsideBlockComment
582
+ } else if ((next = part.match(RE_PUNCTUATION))) {
583
+ token = TokenType.Punctuation
584
+ state = State.TopLevelContent
585
+ } else if ((next = part.match(RE_VARIABLE_NAME_SPECIAL))) {
586
+ token = TokenType.VariableName
587
+ state = State.TopLevelContent
588
+ } else if ((next = part.match(RE_VARIABLE_NAME_SPECIAL_2))) {
589
+ token = TokenType.VariableName
590
+ state = State.TopLevelContent
591
+ } else {
592
+ throw new Error(`no`)
593
+ }
594
+ break
481
595
  default:
482
596
  state
483
597
  throw new Error('no')
@@ -51,7 +51,8 @@
51
51
  ".nycrc",
52
52
  "manifest.webapp",
53
53
  ".alexrc",
54
- ".yarn-integrity"
54
+ ".yarn-integrity",
55
+ ".tsbuildinfo"
55
56
  ],
56
57
  "tokenize": "src/tokenizeJson.js"
57
58
  }
@@ -6,7 +6,7 @@ const State = {
6
6
  TopLevelContent: 1,
7
7
  InsideSingleQuoteString: 2,
8
8
  InsideDoubleQuoteString: 3,
9
- AfterKeywordDeclaration: 4,
9
+ AfterKeywordVariableDeclaration: 4,
10
10
  BeforeValue: 5,
11
11
  AfterKeywordTypeDeclaration: 8,
12
12
  BeforeType: 9,
@@ -120,7 +120,7 @@ export const initialLineState = {
120
120
 
121
121
  const RE_LINE_COMMENT = /^\/\/[^\n]*/
122
122
  const RE_KEYWORD =
123
- /^(?:yield|with|while|void|var|undefined|typeof|type|true|try|throw|this|static|switch|super|readonly|return|public|protected|private|package|null|new|let|interface|instanceof|in|import|implements|if|function|for|finally|from|false|extends|export|enum|else|do|delete|default|debugger|declare|continue|const|constructor|class|catch|case|break|await|async|abstract)\b/
123
+ /^(?:yield|with|while|void|var|undefined|typeof|type|true|try|throw|this|static|switch|super|readonly|return|public|protected|private|package|null|new|let|interface|instanceof|in|import|implements|if|function|for|finally|from|false|extends|export|enum|else|do|delete|default|debugger|declare|continue|const|constructor|class|catch|case|break|await|async|accessor|abstract)\b/
124
124
 
125
125
  const RE_WHITESPACE = /^\s+/
126
126
  const RE_VARIABLE_NAME = /^[\#\$a-zA-Z\_][\$a-zA-Z\_\d]*/
@@ -155,7 +155,7 @@ const RE_ANYTHING_UNTIL_END = /^.+/s
155
155
  const RE_CURLY_OPEN = /^\{/
156
156
  const RE_CURLY_CLOSE = /^\}/
157
157
  const RE_KEYWORD_CLASS_PROPERTY_MODIFIER =
158
- /^(?:override|public|protected|private|readonly)\b/
158
+ /^(?:override|public|protected|private|readonly|accessor)\b/
159
159
 
160
160
  const RE_VERTICAL_LINE = /^\|/
161
161
  const RE_ROUND_OPEN = /^\(/
@@ -178,6 +178,7 @@ const RE_ANGLE_CLOSE = /^>/
178
178
  const RE_OPERATOR = /^[!\*\?\.\:\|\%\&\^@]/
179
179
  const RE_METHOD_NAME = /^[\w\d]+(?=\s*(\(|\:\s*function|\:\s*\())/
180
180
  const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\(|\=\s*function|\=\s*\())/
181
+
181
182
  const RE_NUMERIC_2 =
182
183
  /^(?:(?:[0-9][0-9_]*(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)|(?:[0-9][0-9_]*(\.)[eE][+-]?[0-9][0-9_]*(n)?\b)|(?:(\.)[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)|(?:[0-9][0-9_]*[eE][+-]?[0-9][0-9_]*(n)?\b)|(?:[0-9][0-9_]*(\.)[0-9][0-9_]*(n)?\b)|(?:[0-9][0-9_]*(\.)[0-9][0-9_]*(n)?\b)|(?:[0-9][0-9_]*(\.)(n)?\B)|(?:(\.)[0-9][0-9_]*(n)?\b)|(?:[0-9][0-9_]*(n)?\b(?!\.))|(?:0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\b)|(?:0(?:b|B)[01][01_]*(n)?\b)|(?:0(?:o|O)?[0-7][0-7_]*(n)?\b))/ // 1.1E+3
183
184
  const RE_NUMERIC_HEX = /0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*(n)?\b/
@@ -195,7 +196,7 @@ const RE_KEYWORD_READONLY = /^readonly\b/
195
196
  const RE_SHEBANG = /^\#\!\/.*/
196
197
  const RE_SPREAD = /^\.\.\./
197
198
  const RE_BUILTIN_CLASS =
198
- /^(?:Array|Object|Promise|ArrayBuffer|URL|URLSearchParams|WebSocket|FileSystemHandle|Function|StorageEvent|MessageEvent|MessageChannel|Int32Array|Boolean|String|Error|Set|RegExp|Map|WeakMap|RangeError|Date|Headers|Response|Request|Buffer|MessagePort|FileHandle|X509Certificate|Blob)\b/
199
+ /^(?:Array|Object|Promise|ArrayBuffer|URL|URLSearchParams|WebSocket|FileSystemHandle|Function|StorageEvent|MessageEvent|MessageChannel|Int32Array|Boolean|String|Error|Set|RegExp|Map|WeakMap|RangeError|Date|Headers|Response|Request|Buffer|MessagePort|FileHandle|X509Certificate|Blob|HTMLElement|MutationRecord|HTMLVideoElement)\b/
199
200
 
200
201
  const RE_KEYWORD_NEW = /^new\b/
201
202
  const RE_KEYWORD_IMPLEMENTS = /^implements\b/
@@ -279,7 +280,7 @@ export const tokenizeLine = (line, lineState) => {
279
280
  case 'const':
280
281
  case 'var':
281
282
  token = TokenType.Keyword
282
- state = State.AfterKeywordDeclaration
283
+ state = State.AfterKeywordVariableDeclaration
283
284
  break
284
285
  case 'type':
285
286
  token = TokenType.Keyword
@@ -340,6 +341,9 @@ export const tokenizeLine = (line, lineState) => {
340
341
  } else if ((next = part.match(RE_BUILTIN_CLASS))) {
341
342
  token = TokenType.Class
342
343
  state = State.TopLevelContent
344
+ } else if ((next = part.match(RE_FUNCTION_CALL_NAME))) {
345
+ token = TokenType.Function
346
+ state = State.TopLevelContent
343
347
  } else if ((next = part.match(RE_VARIABLE_NAME))) {
344
348
  token = TokenType.VariableName
345
349
  state = State.TopLevelContent
@@ -418,10 +422,10 @@ export const tokenizeLine = (line, lineState) => {
418
422
  throw new Error('no')
419
423
  }
420
424
  break
421
- case State.AfterKeywordDeclaration:
425
+ case State.AfterKeywordVariableDeclaration:
422
426
  if ((next = part.match(RE_WHITESPACE))) {
423
427
  token = TokenType.Whitespace
424
- state = State.AfterKeywordDeclaration
428
+ state = State.AfterKeywordVariableDeclaration
425
429
  } else if ((next = part.match(RE_COLON))) {
426
430
  token = TokenType.Punctuation
427
431
  state = State.BeforeType
@@ -434,9 +438,12 @@ export const tokenizeLine = (line, lineState) => {
434
438
  } else if ((next = part.match(RE_KEYWORD_OF))) {
435
439
  token = TokenType.KeywordOperator
436
440
  state = State.TopLevelContent
441
+ } else if ((next = part.match(RE_FUNCTION_CALL_NAME))) {
442
+ token = TokenType.FunctionName
443
+ state = State.AfterKeywordVariableDeclaration
437
444
  } else if ((next = part.match(RE_VARIABLE_NAME))) {
438
445
  token = TokenType.VariableName
439
- state = State.AfterKeywordDeclaration
446
+ state = State.AfterKeywordVariableDeclaration
440
447
  } else if ((next = part.match(RE_EQUAL))) {
441
448
  token = TokenType.Punctuation
442
449
  state = State.TopLevelContent
@@ -451,10 +458,10 @@ export const tokenizeLine = (line, lineState) => {
451
458
  state = State.TopLevelContent
452
459
  } else if ((next = part.match(RE_COMMA))) {
453
460
  token = TokenType.Punctuation
454
- state = State.AfterKeywordDeclaration
461
+ state = State.AfterKeywordVariableDeclaration
455
462
  } else if ((next = part.match(RE_PUNCTUATION))) {
456
463
  token = TokenType.Punctuation
457
- state = State.AfterKeywordDeclaration
464
+ state = State.AfterKeywordVariableDeclaration
458
465
  } else if ((next = part.match(RE_QUOTE_DOUBLE))) {
459
466
  token = TokenType.Punctuation
460
467
  state = State.InsideDoubleQuoteString
@@ -693,7 +700,7 @@ export const tokenizeLine = (line, lineState) => {
693
700
  state = State.AfterType
694
701
  } else if ((next = part.match(RE_EQUAL))) {
695
702
  token = TokenType.Punctuation
696
- state = State.TopLevelContent
703
+ state = stack.pop() || State.TopLevelContent
697
704
  } else if ((next = part.match(RE_QUESTION_MARK_COLON))) {
698
705
  token = TokenType.Punctuation
699
706
  state = State.BeforeType
@@ -742,6 +749,10 @@ export const tokenizeLine = (line, lineState) => {
742
749
  } else if ((next = part.match(RE_AMPERSAND))) {
743
750
  token = TokenType.Punctuation
744
751
  state = State.BeforeType
752
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
753
+ stack.push(state)
754
+ token = TokenType.Comment
755
+ state = State.InsideBlockComment
745
756
  } else if ((next = part.match(RE_ANYTHING_BUT_SEMICOLON_UNTIL_END))) {
746
757
  token = TokenType.Text
747
758
  state = State.AfterType
@@ -811,7 +822,7 @@ export const tokenizeLine = (line, lineState) => {
811
822
  case 'const':
812
823
  case 'var':
813
824
  token = TokenType.Keyword
814
- state = State.AfterKeywordDeclaration
825
+ state = State.AfterKeywordVariableDeclaration
815
826
  break
816
827
  case 'type':
817
828
  token = TokenType.Keyword
@@ -1077,6 +1088,10 @@ export const tokenizeLine = (line, lineState) => {
1077
1088
  } else if ((next = part.match(RE_EQUAL))) {
1078
1089
  token = TokenType.Punctuation
1079
1090
  state = State.TopLevelContent
1091
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
1092
+ stack.push(state)
1093
+ token = TokenType.Comment
1094
+ state = State.InsideBlockComment
1080
1095
  } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1081
1096
  token = TokenType.Text
1082
1097
  state = State.TopLevelContent
@@ -1105,7 +1120,6 @@ export const tokenizeLine = (line, lineState) => {
1105
1120
  token = TokenType.Punctuation
1106
1121
  state = State.BeforeType
1107
1122
  } else if ((next = part.match(RE_CURLY_CLOSE))) {
1108
- stack
1109
1123
  token = TokenType.Punctuation
1110
1124
  state = stack.pop() || State.TopLevelContent
1111
1125
  } else if ((next = part.match(RE_SEMICOLON))) {
@@ -1146,6 +1160,10 @@ export const tokenizeLine = (line, lineState) => {
1146
1160
  stack.push(state)
1147
1161
  token = TokenType.Punctuation
1148
1162
  state = State.InsideDoubleQuoteString
1163
+ } else if ((next = part.match(RE_ROUND_OPEN))) {
1164
+ stack.push(State.AfterMethodParameters)
1165
+ token = TokenType.Punctuation
1166
+ state = State.InsideMethodParameters
1149
1167
  } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1150
1168
  token = TokenType.Text
1151
1169
  state = State.TopLevelContent
@@ -1174,7 +1192,7 @@ export const tokenizeLine = (line, lineState) => {
1174
1192
  state = State.InsideObjectDestructuringAfterValue
1175
1193
  } else if ((next = part.match(RE_CURLY_CLOSE))) {
1176
1194
  token = TokenType.Punctuation
1177
- state = State.AfterKeywordDeclaration
1195
+ state = State.AfterKeywordVariableDeclaration
1178
1196
  } else if ((next = part.match(RE_COLON))) {
1179
1197
  token = TokenType.Punctuation
1180
1198
  state = State.InsideObjectDestructuringAfterValue
@@ -1201,6 +1219,10 @@ export const tokenizeLine = (line, lineState) => {
1201
1219
  } else if ((next = part.match(RE_VARIABLE_NAME))) {
1202
1220
  token = TokenType.Type
1203
1221
  state = State.AfterInterfaceName
1222
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
1223
+ stack.push(state)
1224
+ token = TokenType.Comment
1225
+ state = State.InsideBlockComment
1204
1226
  } else {
1205
1227
  throw new Error('no')
1206
1228
  }
@@ -1254,6 +1276,9 @@ export const tokenizeLine = (line, lineState) => {
1254
1276
  token = TokenType.Punctuation
1255
1277
  state = State.InsideSingleQuoteString
1256
1278
  stack.push(State.InsideTypeObject)
1279
+ } else if ((next = part.match(RE_LINE_COMMENT))) {
1280
+ token = TokenType.Comment
1281
+ state = State.InsideTypeObject
1257
1282
  } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1258
1283
  token = TokenType.Text
1259
1284
  state = State.TopLevelContent
@@ -1353,6 +1378,8 @@ export const tokenizeLine = (line, lineState) => {
1353
1378
  state = State.AfterMethodParameters
1354
1379
  } else if ((next = part.match(RE_ARROW))) {
1355
1380
  token = TokenType.Punctuation
1381
+ // TODO depending on whether this is a type function
1382
+ // this can be either a type or a value
1356
1383
  state = State.BeforeType
1357
1384
  } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1358
1385
  token = TokenType.Punctuation
@@ -1442,7 +1469,7 @@ export const tokenizeLine = (line, lineState) => {
1442
1469
  } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
1443
1470
  stack.push(state)
1444
1471
  token = TokenType.Comment
1445
- state = State.AfterInterfaceName
1472
+ state = State.InsideBlockComment
1446
1473
  } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1447
1474
  token = TokenType.Text
1448
1475
  state = stack.pop() || State.TopLevelContent
@@ -1534,6 +1561,10 @@ export const tokenizeLine = (line, lineState) => {
1534
1561
  } else if ((next = part.match(RE_DOT))) {
1535
1562
  token = TokenType.Punctuation
1536
1563
  state = State.AfterPropertyDot
1564
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
1565
+ stack.push(state)
1566
+ token = TokenType.Comment
1567
+ state = State.InsideBlockComment
1537
1568
  } else {
1538
1569
  throw new Error('no')
1539
1570
  }
@@ -73,7 +73,9 @@
73
73
  ".mm",
74
74
  ".tmDragCommand",
75
75
  ".tmCommand",
76
- ".natvis"
76
+ ".natvis",
77
+ ".xcscheme",
78
+ ".xcsettings"
77
79
  ],
78
80
  "fileNames": [".project", "resources.grd"],
79
81
  "tokenize": "src/tokenizeXml.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.16.22",
3
+ "version": "0.17.0",
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.22",
21
- "@lvce-editor/extension-host-helper-process": "0.16.22",
22
- "@lvce-editor/pty-host": "0.16.22",
20
+ "@lvce-editor/extension-host": "0.17.0",
21
+ "@lvce-editor/extension-host-helper-process": "0.17.0",
22
+ "@lvce-editor/pty-host": "0.17.0",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -34,6 +34,9 @@ export const link = async (path) => {
34
34
  const to = Path.join(linkedExtensionsPath, manifest.id)
35
35
  await SymLink.createSymLink(path, to)
36
36
  } catch (error) {
37
+ if (error && error.code === ErrorCodes.E_MANIFEST_NOT_FOUND) {
38
+ throw new VError(`Failed to link extension: Extension manifest not found '${error.path}'`)
39
+ }
37
40
  if (error && error.code === ErrorCodes.EEXIST) {
38
41
  return linkFallBack(path)
39
42
  }
@@ -1,25 +1,16 @@
1
1
  import isObject from 'is-object'
2
2
  import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
3
3
  import * as ExtensionManifestStatus from '../ExtensionManifestStatus/ExtensionManifestStatus.js'
4
+ import * as InferExtensionId from '../InferExtensionId/InferExtensionId.js'
5
+ import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js'
4
6
  import * as ReadJson from '../JsonFile/JsonFile.js'
5
7
  import * as Path from '../Path/Path.js'
6
- import * as IsEnoentError from '../IsEnoentError/IsEnoentError.js'
7
8
  import { VError } from '../VError/VError.js'
8
9
 
9
- const RE_EXTENSION_FRAGMENT = /.+(\/|\\)(.+)$/
10
-
11
- const inferExtensionId = (absolutePath) => {
12
- const match = absolutePath.match(RE_EXTENSION_FRAGMENT)
13
- if (match) {
14
- return match[2]
15
- }
16
- return ''
17
- }
18
-
19
10
  // TODO json parsing and error handling should happen in renderer process
20
11
  export const get = async (path) => {
12
+ const absolutePath = Path.join(path, 'extension.json')
21
13
  try {
22
- const absolutePath = Path.join(path, 'extension.json')
23
14
  const json = await ReadJson.readJson(absolutePath)
24
15
  if (!isObject(json)) {
25
16
  // TODO should include stack of extension json file here
@@ -31,7 +22,7 @@ export const get = async (path) => {
31
22
  status: ExtensionManifestStatus.Resolved,
32
23
  }
33
24
  } catch (error) {
34
- const id = inferExtensionId(path)
25
+ const id = InferExtensionId.inferExtensionId(path)
35
26
  const enhancedError = new VError(error, `Failed to load extension manifest for ${id}`)
36
27
  if (IsEnoentError.isEnoentError(error)) {
37
28
  try {
@@ -48,6 +39,8 @@ export const get = async (path) => {
48
39
  }
49
40
  } catch {}
50
41
  // @ts-ignore
42
+ enhancedError.path = absolutePath
43
+ // @ts-ignore
51
44
  enhancedError.code = ErrorCodes.E_MANIFEST_NOT_FOUND
52
45
  } else {
53
46
  // @ts-ignore
@@ -0,0 +1,9 @@
1
+ const RE_EXTENSION_FRAGMENT = /.+(\/|\\)(.+)$/
2
+
3
+ export const inferExtensionId = (absolutePath) => {
4
+ const match = absolutePath.match(RE_EXTENSION_FRAGMENT)
5
+ if (match) {
6
+ return match[2]
7
+ }
8
+ return ''
9
+ }
@@ -169,11 +169,11 @@ export const getSetupName = () => {
169
169
  return 'Lvce-Setup'
170
170
  }
171
171
 
172
- export const version = '0.16.22'
172
+ export const version = '0.17.0'
173
173
 
174
- export const commit = '84da26e'
174
+ export const commit = '4a17b31'
175
175
 
176
- export const date = '2023-07-30T16:05:29.000Z'
176
+ export const date = '2023-08-05T17:17:49.000Z'
177
177
 
178
178
  export const getVersion = () => {
179
179
  return version