@lvce-editor/shared-process 0.16.15 → 0.16.16
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.
|
@@ -38,7 +38,11 @@ const State = {
|
|
|
38
38
|
AfterInterfaceName: 35,
|
|
39
39
|
AfterKeywordImport: 36,
|
|
40
40
|
AfterKeywordFunction: 37,
|
|
41
|
-
|
|
41
|
+
InsideGeneric: 38,
|
|
42
|
+
AfterTypeAfterNewLine: 39,
|
|
43
|
+
AfterKeywordInstanceOf: 40,
|
|
44
|
+
AfterKeywordNew: 41,
|
|
45
|
+
AfterKeywordTypeOf: 42,
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -71,6 +75,8 @@ export const TokenType = {
|
|
|
71
75
|
FunctionName: 21,
|
|
72
76
|
KeywordOperator: 22,
|
|
73
77
|
Text: 23,
|
|
78
|
+
KeywordThis: 24,
|
|
79
|
+
KeywordAwait: 25,
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
export const TokenMap = {
|
|
@@ -100,6 +106,8 @@ export const TokenMap = {
|
|
|
100
106
|
[TokenType.FunctionName]: 'Function',
|
|
101
107
|
[TokenType.KeywordOperator]: 'KeywordOperator',
|
|
102
108
|
[TokenType.Text]: 'Text',
|
|
109
|
+
[TokenType.KeywordThis]: 'KeywordThis',
|
|
110
|
+
[TokenType.KeywordAwait]: 'KeywordAwait',
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
export const initialLineState = {
|
|
@@ -112,7 +120,7 @@ export const initialLineState = {
|
|
|
112
120
|
|
|
113
121
|
const RE_LINE_COMMENT = /^\/\/[^\n]*/
|
|
114
122
|
const RE_KEYWORD =
|
|
115
|
-
/^(?:yield|with|while|void|var|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|abstract)\b/
|
|
116
124
|
|
|
117
125
|
const RE_WHITESPACE = /^\s+/
|
|
118
126
|
const RE_VARIABLE_NAME = /^[\#\$a-zA-Z\_][\$a-zA-Z\_\d]*/
|
|
@@ -124,7 +132,9 @@ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^\\"]+/
|
|
|
124
132
|
const RE_NUMERIC = /^(?:-)?\d+/
|
|
125
133
|
const RE_COLON = /^\:/
|
|
126
134
|
const RE_COLON_OPTIONAL = /^\??\:/
|
|
127
|
-
const RE_TYPE_PRIMITIVE =
|
|
135
|
+
const RE_TYPE_PRIMITIVE =
|
|
136
|
+
/^(?:string|boolean|number|bigint|symbol|void|any|null|undefined|object|true|false|unknown)\b/
|
|
137
|
+
|
|
128
138
|
const RE_EQUAL = /^=/
|
|
129
139
|
const RE_SEMICOLON = /^;/
|
|
130
140
|
const RE_KEYWORD_CONST = /^(?:const)/
|
|
@@ -140,7 +150,7 @@ const RE_BLOCK_COMMENT_END = /^\*\//
|
|
|
140
150
|
const RE_SLASH = /^\//
|
|
141
151
|
// copied from https://github.com/PrismJS/prism/blob/master/components/prism-javascript.js#L57
|
|
142
152
|
const RE_REGEX =
|
|
143
|
-
/((
|
|
153
|
+
/((?:^|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/
|
|
144
154
|
const RE_ANYTHING_UNTIL_END = /^.+/s
|
|
145
155
|
const RE_CURLY_OPEN = /^\{/
|
|
146
156
|
const RE_CURLY_CLOSE = /^\}/
|
|
@@ -151,6 +161,7 @@ const RE_VERTICAL_LINE = /^\|/
|
|
|
151
161
|
const RE_ROUND_OPEN = /^\(/
|
|
152
162
|
const RE_ROUND_CLOSE = /^\)/
|
|
153
163
|
const RE_QUESTION_MARK_COLON = /^\?\:/
|
|
164
|
+
const RE_EXLAMATION_MARK_COLON = /^\!\:/
|
|
154
165
|
const RE_ARROW = /^\=\>/
|
|
155
166
|
const RE_AMPERSAND = /^\&/
|
|
156
167
|
const RE_COMMA = /^\,/
|
|
@@ -178,10 +189,18 @@ const RE_STRING_ESCAPE = /^\\./
|
|
|
178
189
|
const RE_KEYWORD_TYPE = /^type\b/
|
|
179
190
|
const RE_KEYWORD_IN = /^in\b/
|
|
180
191
|
const RE_KEYWORD_OF = /^of\b/
|
|
192
|
+
const RE_KEYWORD_CONSTRUCTOR = /^constructor\b/
|
|
181
193
|
const RE_KEYWORD_EXTENDS = /^extends\b/
|
|
182
194
|
const RE_KEYWORD_READONLY = /^readonly\b/
|
|
183
195
|
const RE_SHEBANG = /^\#\!\/.*/
|
|
184
196
|
const RE_SPREAD = /^\.\.\./
|
|
197
|
+
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
|
+
|
|
200
|
+
const RE_KEYWORD_NEW = /^new\b/
|
|
201
|
+
const RE_KEYWORD_IMPLEMENTS = /^implements\b/
|
|
202
|
+
const RE_KEYWORD_TYPE_OF = /^typeof\b/
|
|
203
|
+
const RE_ANYTHING_BUT_SEMICOLON_UNTIL_END = /^[^;]+/s
|
|
185
204
|
|
|
186
205
|
export const hasArrayReturn = true
|
|
187
206
|
/**
|
|
@@ -209,6 +228,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
209
228
|
case 'true':
|
|
210
229
|
case 'false':
|
|
211
230
|
case 'null':
|
|
231
|
+
case 'undefined':
|
|
212
232
|
token = TokenType.LanguageConstant
|
|
213
233
|
state = State.TopLevelContent
|
|
214
234
|
break
|
|
@@ -222,33 +242,38 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
222
242
|
state = State.TopLevelContent
|
|
223
243
|
break
|
|
224
244
|
case 'as':
|
|
225
|
-
case '
|
|
226
|
-
case 'default':
|
|
245
|
+
case 'break':
|
|
227
246
|
case 'case':
|
|
247
|
+
case 'catch':
|
|
248
|
+
case 'continue':
|
|
249
|
+
case 'default':
|
|
250
|
+
case 'do':
|
|
228
251
|
case 'else':
|
|
252
|
+
case 'finally':
|
|
253
|
+
case 'for':
|
|
229
254
|
case 'if':
|
|
230
|
-
case '
|
|
255
|
+
case 'switch':
|
|
231
256
|
case 'throw':
|
|
232
|
-
case 'while':
|
|
233
257
|
case 'try':
|
|
234
|
-
case '
|
|
235
|
-
case 'finally':
|
|
236
|
-
case 'for':
|
|
258
|
+
case 'while':
|
|
237
259
|
token = TokenType.KeywordControl
|
|
238
260
|
state = State.TopLevelContent
|
|
239
261
|
break
|
|
240
262
|
case 'async':
|
|
241
|
-
case 'await':
|
|
242
263
|
token = TokenType.KeywordModifier
|
|
243
264
|
state = State.TopLevelContent
|
|
244
265
|
break
|
|
266
|
+
case 'await':
|
|
267
|
+
token = TokenType.KeywordAwait
|
|
268
|
+
state = State.TopLevelContent
|
|
269
|
+
break
|
|
245
270
|
case 'return':
|
|
246
271
|
token = TokenType.KeywordReturn
|
|
247
272
|
state = State.TopLevelContent
|
|
248
273
|
break
|
|
249
274
|
case 'new':
|
|
250
275
|
token = TokenType.KeywordNew
|
|
251
|
-
state = State.
|
|
276
|
+
state = State.AfterKeywordNew
|
|
252
277
|
break
|
|
253
278
|
case 'let':
|
|
254
279
|
case 'const':
|
|
@@ -278,20 +303,32 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
278
303
|
case 'public':
|
|
279
304
|
case 'override':
|
|
280
305
|
case 'abstract':
|
|
306
|
+
case 'static':
|
|
281
307
|
token = TokenType.KeywordModifier
|
|
282
308
|
state = State.TopLevelContent
|
|
283
309
|
break
|
|
284
310
|
case 'in':
|
|
285
311
|
case 'of':
|
|
286
312
|
case 'typeof':
|
|
287
|
-
case 'instanceof':
|
|
288
313
|
token = TokenType.KeywordOperator
|
|
289
314
|
state = State.TopLevelContent
|
|
290
315
|
break
|
|
316
|
+
case 'instanceof':
|
|
317
|
+
token = TokenType.KeywordOperator
|
|
318
|
+
state = State.AfterKeywordInstanceOf
|
|
319
|
+
break
|
|
291
320
|
case 'function':
|
|
292
321
|
token = TokenType.Keyword
|
|
293
322
|
state = State.AfterKeywordFunction
|
|
294
323
|
break
|
|
324
|
+
case 'this':
|
|
325
|
+
token = TokenType.KeywordThis
|
|
326
|
+
state = State.TopLevelContent
|
|
327
|
+
break
|
|
328
|
+
case 'class':
|
|
329
|
+
token = TokenType.Keyword
|
|
330
|
+
state = State.AfterKeywordClass
|
|
331
|
+
break
|
|
295
332
|
default:
|
|
296
333
|
token = TokenType.Keyword
|
|
297
334
|
state = State.TopLevelContent
|
|
@@ -300,6 +337,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
300
337
|
} else if (index === 0 && (next = part.match(RE_SHEBANG))) {
|
|
301
338
|
token = TokenType.Comment
|
|
302
339
|
state = State.TopLevelContent
|
|
340
|
+
} else if ((next = part.match(RE_BUILTIN_CLASS))) {
|
|
341
|
+
token = TokenType.Class
|
|
342
|
+
state = State.TopLevelContent
|
|
303
343
|
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
304
344
|
token = TokenType.VariableName
|
|
305
345
|
state = State.TopLevelContent
|
|
@@ -307,12 +347,12 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
307
347
|
if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
308
348
|
token = TokenType.Comment
|
|
309
349
|
state = State.InsideBlockComment
|
|
310
|
-
} else if ((next = part.match(RE_REGEX))) {
|
|
311
|
-
token = TokenType.Regex
|
|
312
|
-
state = State.TopLevelContent
|
|
313
350
|
} else if ((next = part.match(RE_LINE_COMMENT_START))) {
|
|
314
351
|
token = TokenType.Comment
|
|
315
352
|
state = State.InsideLineComment
|
|
353
|
+
} else if ((next = part.match(RE_REGEX))) {
|
|
354
|
+
token = TokenType.Regex
|
|
355
|
+
state = State.TopLevelContent
|
|
316
356
|
} else if ((next = part.match(RE_PUNCTUATION))) {
|
|
317
357
|
token = TokenType.Punctuation
|
|
318
358
|
state = State.TopLevelContent
|
|
@@ -353,7 +393,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
353
393
|
case State.InsideSingleQuoteString:
|
|
354
394
|
if ((next = part.match(RE_QUOTE_SINGLE))) {
|
|
355
395
|
token = TokenType.Punctuation
|
|
356
|
-
state = State.TopLevelContent
|
|
396
|
+
state = stack.pop() || State.TopLevelContent
|
|
357
397
|
} else if ((next = part.match(RE_STRING_SINGLE_QUOTE_CONTENT))) {
|
|
358
398
|
token = TokenType.String
|
|
359
399
|
state = State.InsideSingleQuoteString
|
|
@@ -367,7 +407,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
367
407
|
case State.InsideDoubleQuoteString:
|
|
368
408
|
if ((next = part.match(RE_QUOTE_DOUBLE))) {
|
|
369
409
|
token = TokenType.Punctuation
|
|
370
|
-
state = State.TopLevelContent
|
|
410
|
+
state = stack.pop() || State.TopLevelContent
|
|
371
411
|
} else if ((next = part.match(RE_STRING_DOUBLE_QUOTE_CONTENT))) {
|
|
372
412
|
token = TokenType.String
|
|
373
413
|
state = State.InsideDoubleQuoteString
|
|
@@ -418,6 +458,13 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
418
458
|
} else if ((next = part.match(RE_QUOTE_DOUBLE))) {
|
|
419
459
|
token = TokenType.Punctuation
|
|
420
460
|
state = State.InsideDoubleQuoteString
|
|
461
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
462
|
+
stack.push(state)
|
|
463
|
+
token = TokenType.Comment
|
|
464
|
+
state = State.InsideBlockComment
|
|
465
|
+
} else if ((next = part.match(RE_EXCLAMATION_MARK))) {
|
|
466
|
+
token = TokenType.Punctuation
|
|
467
|
+
state = State.AfterVariableName
|
|
421
468
|
} else {
|
|
422
469
|
line
|
|
423
470
|
part
|
|
@@ -453,11 +500,23 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
453
500
|
token = TokenType.Whitespace
|
|
454
501
|
state = State.BeforeType
|
|
455
502
|
} else if ((next = part.match(RE_TYPE_PRIMITIVE))) {
|
|
456
|
-
part
|
|
457
503
|
token = TokenType.TypePrimitive
|
|
458
504
|
state = stack.pop() || State.AfterType
|
|
505
|
+
} else if ((next = part.match(RE_BUILTIN_CLASS))) {
|
|
506
|
+
token = TokenType.Class
|
|
507
|
+
state = stack.pop() || State.AfterType
|
|
508
|
+
} else if ((next = part.match(RE_KEYWORD_TYPE_OF))) {
|
|
509
|
+
stack.push(state)
|
|
510
|
+
token = TokenType.KeywordOperator
|
|
511
|
+
state = State.AfterKeywordTypeOf
|
|
512
|
+
} else if ((next = part.match(RE_KEYWORD_READONLY))) {
|
|
513
|
+
token = TokenType.KeywordModifier
|
|
514
|
+
state = State.BeforeType
|
|
515
|
+
} else if ((next = part.match(RE_KEYWORD_EXTENDS))) {
|
|
516
|
+
token = TokenType.KeywordOperator
|
|
517
|
+
state = State.BeforeType
|
|
518
|
+
stack.push(state)
|
|
459
519
|
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
460
|
-
part
|
|
461
520
|
token = TokenType.Type
|
|
462
521
|
state = State.AfterType
|
|
463
522
|
} else if ((next = part.match(RE_SEMICOLON))) {
|
|
@@ -483,9 +542,13 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
483
542
|
token = TokenType.Punctuation
|
|
484
543
|
state = State.InsideTypeObject
|
|
485
544
|
} else if ((next = part.match(RE_QUOTE_SINGLE))) {
|
|
545
|
+
stack.push(State.AfterType)
|
|
486
546
|
token = TokenType.Punctuation
|
|
487
547
|
state = State.InsideSingleQuoteString
|
|
488
|
-
|
|
548
|
+
} else if ((next = part.match(RE_QUOTE_DOUBLE))) {
|
|
549
|
+
stack.push(State.AfterType)
|
|
550
|
+
token = TokenType.Punctuation
|
|
551
|
+
state = State.InsideDoubleQuoteString
|
|
489
552
|
} else if ((next = part.match(RE_VERTICAL_LINE))) {
|
|
490
553
|
token = TokenType.Punctuation
|
|
491
554
|
state = State.BeforeType
|
|
@@ -508,6 +571,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
508
571
|
} else if ((next = part.match(RE_CURLY_CLOSE))) {
|
|
509
572
|
token = TokenType.Punctuation
|
|
510
573
|
state = stack.pop() || State.TopLevelContent
|
|
574
|
+
} else if ((next = part.match(RE_QUESTION_MARK))) {
|
|
575
|
+
token = TokenType.Punctuation
|
|
576
|
+
state = State.BeforeType
|
|
511
577
|
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
512
578
|
token = TokenType.Text
|
|
513
579
|
state = State.TopLevelContent
|
|
@@ -573,6 +639,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
573
639
|
} else if ((next = part.match(RE_VERTICAL_LINE))) {
|
|
574
640
|
token = TokenType.Punctuation
|
|
575
641
|
state = State.InsideTypeExpression
|
|
642
|
+
} else if ((next = part.match(RE_LINE_COMMENT))) {
|
|
643
|
+
token = TokenType.Comment
|
|
644
|
+
state = State.AfterTypeExpression
|
|
576
645
|
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
577
646
|
token = TokenType.Text
|
|
578
647
|
state = State.TopLevelContent
|
|
@@ -585,6 +654,12 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
585
654
|
if ((next = part.match(RE_COLON))) {
|
|
586
655
|
token = TokenType.Punctuation
|
|
587
656
|
state = State.BeforeType
|
|
657
|
+
} else if ((next = part.match(RE_QUESTION_MARK_COLON))) {
|
|
658
|
+
token = TokenType.Punctuation
|
|
659
|
+
state = State.BeforeType
|
|
660
|
+
} else if ((next = part.match(RE_EXLAMATION_MARK_COLON))) {
|
|
661
|
+
token = TokenType.Punctuation
|
|
662
|
+
state = State.BeforeType
|
|
588
663
|
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
589
664
|
token = TokenType.Whitespace
|
|
590
665
|
state = State.AfterVariableName
|
|
@@ -620,7 +695,6 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
620
695
|
token = TokenType.Punctuation
|
|
621
696
|
state = State.TopLevelContent
|
|
622
697
|
} else if ((next = part.match(RE_QUESTION_MARK_COLON))) {
|
|
623
|
-
next
|
|
624
698
|
token = TokenType.Punctuation
|
|
625
699
|
state = State.BeforeType
|
|
626
700
|
} else if ((next = part.match(RE_COLON))) {
|
|
@@ -662,6 +736,15 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
662
736
|
stack.push(state)
|
|
663
737
|
token = TokenType.Punctuation
|
|
664
738
|
state = State.InsideSingleQuoteString
|
|
739
|
+
} else if ((next = part.match(RE_LINE_COMMENT))) {
|
|
740
|
+
token = TokenType.Comment
|
|
741
|
+
state = State.AfterType
|
|
742
|
+
} else if ((next = part.match(RE_AMPERSAND))) {
|
|
743
|
+
token = TokenType.Punctuation
|
|
744
|
+
state = State.BeforeType
|
|
745
|
+
} else if ((next = part.match(RE_ANYTHING_BUT_SEMICOLON_UNTIL_END))) {
|
|
746
|
+
token = TokenType.Text
|
|
747
|
+
state = State.AfterType
|
|
665
748
|
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
666
749
|
token = TokenType.Text
|
|
667
750
|
state = State.TopLevelContent
|
|
@@ -671,6 +754,162 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
671
754
|
throw new Error('no')
|
|
672
755
|
}
|
|
673
756
|
break
|
|
757
|
+
case State.AfterTypeAfterNewLine:
|
|
758
|
+
if ((next = part.match(RE_KEYWORD))) {
|
|
759
|
+
switch (next[0]) {
|
|
760
|
+
case 'true':
|
|
761
|
+
case 'false':
|
|
762
|
+
case 'null':
|
|
763
|
+
case 'undefined':
|
|
764
|
+
token = TokenType.LanguageConstant
|
|
765
|
+
state = State.TopLevelContent
|
|
766
|
+
break
|
|
767
|
+
case 'import':
|
|
768
|
+
token = TokenType.KeywordImport
|
|
769
|
+
state = State.AfterKeywordImport
|
|
770
|
+
break
|
|
771
|
+
case 'export':
|
|
772
|
+
case 'from':
|
|
773
|
+
token = TokenType.KeywordImport
|
|
774
|
+
state = State.TopLevelContent
|
|
775
|
+
break
|
|
776
|
+
case 'as':
|
|
777
|
+
case 'break':
|
|
778
|
+
case 'case':
|
|
779
|
+
case 'catch':
|
|
780
|
+
case 'continue':
|
|
781
|
+
case 'default':
|
|
782
|
+
case 'do':
|
|
783
|
+
case 'else':
|
|
784
|
+
case 'finally':
|
|
785
|
+
case 'for':
|
|
786
|
+
case 'if':
|
|
787
|
+
case 'switch':
|
|
788
|
+
case 'throw':
|
|
789
|
+
case 'try':
|
|
790
|
+
case 'while':
|
|
791
|
+
token = TokenType.KeywordControl
|
|
792
|
+
state = State.TopLevelContent
|
|
793
|
+
break
|
|
794
|
+
case 'async':
|
|
795
|
+
token = TokenType.KeywordModifier
|
|
796
|
+
state = State.TopLevelContent
|
|
797
|
+
break
|
|
798
|
+
case 'await':
|
|
799
|
+
token = TokenType.KeywordAwait
|
|
800
|
+
state = State.TopLevelContent
|
|
801
|
+
break
|
|
802
|
+
case 'return':
|
|
803
|
+
token = TokenType.KeywordReturn
|
|
804
|
+
state = State.TopLevelContent
|
|
805
|
+
break
|
|
806
|
+
case 'new':
|
|
807
|
+
token = TokenType.KeywordNew
|
|
808
|
+
state = State.TopLevelContent
|
|
809
|
+
break
|
|
810
|
+
case 'let':
|
|
811
|
+
case 'const':
|
|
812
|
+
case 'var':
|
|
813
|
+
token = TokenType.Keyword
|
|
814
|
+
state = State.AfterKeywordDeclaration
|
|
815
|
+
break
|
|
816
|
+
case 'type':
|
|
817
|
+
token = TokenType.Keyword
|
|
818
|
+
state = State.AfterKeywordTypeDeclaration
|
|
819
|
+
break
|
|
820
|
+
case 'declare':
|
|
821
|
+
token = TokenType.KeywordDeclare
|
|
822
|
+
state = State.AfterKeywordDeclare
|
|
823
|
+
break
|
|
824
|
+
case 'void':
|
|
825
|
+
token = TokenType.KeywordVoid
|
|
826
|
+
state = State.TopLevelContent
|
|
827
|
+
break
|
|
828
|
+
case 'interface':
|
|
829
|
+
token = TokenType.Keyword
|
|
830
|
+
state = State.AfterKeywordInterface
|
|
831
|
+
break
|
|
832
|
+
case 'private':
|
|
833
|
+
case 'protected':
|
|
834
|
+
case 'readonly':
|
|
835
|
+
case 'public':
|
|
836
|
+
case 'override':
|
|
837
|
+
case 'abstract':
|
|
838
|
+
token = TokenType.KeywordModifier
|
|
839
|
+
state = State.TopLevelContent
|
|
840
|
+
break
|
|
841
|
+
case 'in':
|
|
842
|
+
case 'of':
|
|
843
|
+
case 'typeof':
|
|
844
|
+
case 'instanceof':
|
|
845
|
+
token = TokenType.KeywordOperator
|
|
846
|
+
state = State.TopLevelContent
|
|
847
|
+
break
|
|
848
|
+
case 'instanceof':
|
|
849
|
+
token = TokenType.KeywordOperator
|
|
850
|
+
state = State.AfterKeywordInstanceOf
|
|
851
|
+
break
|
|
852
|
+
case 'function':
|
|
853
|
+
token = TokenType.Keyword
|
|
854
|
+
state = State.AfterKeywordFunction
|
|
855
|
+
break
|
|
856
|
+
case 'this':
|
|
857
|
+
token = TokenType.KeywordThis
|
|
858
|
+
state = State.TopLevelContent
|
|
859
|
+
break
|
|
860
|
+
case 'class':
|
|
861
|
+
token = TokenType.Keyword
|
|
862
|
+
state = State.AfterKeywordClass
|
|
863
|
+
break
|
|
864
|
+
default:
|
|
865
|
+
token = TokenType.Keyword
|
|
866
|
+
state = State.TopLevelContent
|
|
867
|
+
break
|
|
868
|
+
}
|
|
869
|
+
} else if ((next = part.match(RE_ROUND_OPEN))) {
|
|
870
|
+
token = TokenType.Punctuation
|
|
871
|
+
state = stack.pop() || State.TopLevelContent
|
|
872
|
+
} else if ((next = part.match(RE_SEMICOLON))) {
|
|
873
|
+
token = TokenType.Punctuation
|
|
874
|
+
state = stack.pop() || State.TopLevelContent
|
|
875
|
+
} else if ((next = part.match(RE_WHITESPACE))) {
|
|
876
|
+
token = TokenType.Whitespace
|
|
877
|
+
state = State.AfterTypeAfterNewLine
|
|
878
|
+
} else if ((next = part.match(RE_EQUAL))) {
|
|
879
|
+
token = TokenType.Punctuation
|
|
880
|
+
state = State.BeforeType
|
|
881
|
+
} else if ((next = part.match(RE_VERTICAL_LINE))) {
|
|
882
|
+
token = TokenType.Punctuation
|
|
883
|
+
state = State.BeforeType
|
|
884
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
885
|
+
token = TokenType.VariableName
|
|
886
|
+
state = State.TopLevelContent
|
|
887
|
+
} else if ((next = part.match(RE_ROUND_CLOSE))) {
|
|
888
|
+
token = TokenType.Punctuation
|
|
889
|
+
state = stack.pop() || State.TopLevelContent
|
|
890
|
+
} else if ((next = part.match(RE_CURLY_CLOSE))) {
|
|
891
|
+
token = TokenType.Punctuation
|
|
892
|
+
state = stack.pop() || State.TopLevelContent
|
|
893
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
894
|
+
stack.push(state)
|
|
895
|
+
token = TokenType.Comment
|
|
896
|
+
state = State.InsideBlockComment
|
|
897
|
+
} else if ((next = part.match(RE_LINE_COMMENT))) {
|
|
898
|
+
token = TokenType.Comment
|
|
899
|
+
state = State.AfterTypeAfterNewLine
|
|
900
|
+
} else if ((next = part.match(RE_AMPERSAND))) {
|
|
901
|
+
token = TokenType.Punctuation
|
|
902
|
+
state = State.BeforeType
|
|
903
|
+
} else if ((next = part.match(RE_OPERATOR))) {
|
|
904
|
+
token = TokenType.Punctuation
|
|
905
|
+
state = State.TopLevelContent
|
|
906
|
+
} else if ((next = part.match(RE_ANYTHING_BUT_SEMICOLON_UNTIL_END))) {
|
|
907
|
+
token = TokenType.Text
|
|
908
|
+
state = State.AfterType
|
|
909
|
+
} else {
|
|
910
|
+
throw new Error('no')
|
|
911
|
+
}
|
|
912
|
+
break
|
|
674
913
|
case State.AfterKeywordDeclare:
|
|
675
914
|
if ((next = part.match(RE_WHITESPACE))) {
|
|
676
915
|
token = TokenType.Whitespace
|
|
@@ -759,12 +998,12 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
759
998
|
}
|
|
760
999
|
break
|
|
761
1000
|
case State.InsideBlockComment:
|
|
762
|
-
if ((next = part.match(
|
|
763
|
-
token = TokenType.Comment
|
|
764
|
-
state = State.InsideBlockComment
|
|
765
|
-
} else if ((next = part.match(RE_BLOCK_COMMENT_END))) {
|
|
1001
|
+
if ((next = part.match(RE_BLOCK_COMMENT_END))) {
|
|
766
1002
|
token = TokenType.Comment
|
|
767
1003
|
state = stack.pop() || State.TopLevelContent
|
|
1004
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_CONTENT))) {
|
|
1005
|
+
token = TokenType.Comment
|
|
1006
|
+
state = State.InsideBlockComment
|
|
768
1007
|
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
769
1008
|
token = TokenType.Comment
|
|
770
1009
|
state = State.InsideBlockComment
|
|
@@ -784,9 +1023,16 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
784
1023
|
if ((next = part.match(RE_WHITESPACE))) {
|
|
785
1024
|
token = TokenType.Whitespace
|
|
786
1025
|
state = State.AfterKeywordClass
|
|
1026
|
+
} else if ((next = part.match(RE_KEYWORD_EXTENDS))) {
|
|
1027
|
+
token = TokenType.KeywordModifier
|
|
1028
|
+
state = State.AfterKeywordClass
|
|
787
1029
|
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
788
1030
|
token = TokenType.Class
|
|
789
1031
|
state = State.AfterKeywordClassAfterClassName
|
|
1032
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
1033
|
+
stack.push(state)
|
|
1034
|
+
token = TokenType.Comment
|
|
1035
|
+
state = State.InsideBlockComment
|
|
790
1036
|
} else {
|
|
791
1037
|
part
|
|
792
1038
|
throw new Error('no')
|
|
@@ -799,6 +1045,41 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
799
1045
|
} else if ((next = part.match(RE_CURLY_OPEN))) {
|
|
800
1046
|
token = TokenType.Punctuation
|
|
801
1047
|
state = State.InsideClass
|
|
1048
|
+
} else if ((next = part.match(RE_KEYWORD_EXTENDS))) {
|
|
1049
|
+
token = TokenType.KeywordModifier
|
|
1050
|
+
state = State.AfterKeywordClass
|
|
1051
|
+
} else if ((next = part.match(RE_KEYWORD_IMPLEMENTS))) {
|
|
1052
|
+
token = TokenType.Keyword
|
|
1053
|
+
state = State.AfterKeywordClass
|
|
1054
|
+
} else if ((next = part.match(RE_DOT))) {
|
|
1055
|
+
token = TokenType.Punctuation
|
|
1056
|
+
state = State.AfterPropertyDot
|
|
1057
|
+
} else if ((next = part.match(RE_COMMA))) {
|
|
1058
|
+
token = TokenType.Punctuation
|
|
1059
|
+
state = State.AfterKeywordClass
|
|
1060
|
+
} else if ((next = part.match(RE_ROUND_OPEN))) {
|
|
1061
|
+
token = TokenType.Punctuation
|
|
1062
|
+
state = State.AfterKeywordClassAfterClassName
|
|
1063
|
+
} else if ((next = part.match(RE_ROUND_CLOSE))) {
|
|
1064
|
+
token = TokenType.Punctuation
|
|
1065
|
+
state = State.AfterKeywordClassAfterClassName
|
|
1066
|
+
} else if ((next = part.match(RE_QUOTE_DOUBLE))) {
|
|
1067
|
+
stack.push(state)
|
|
1068
|
+
token = TokenType.Punctuation
|
|
1069
|
+
state = State.InsideDoubleQuoteString
|
|
1070
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
1071
|
+
token = TokenType.Class
|
|
1072
|
+
state = State.AfterKeywordClassAfterClassName
|
|
1073
|
+
} else if ((next = part.match(RE_ANGLE_OPEN))) {
|
|
1074
|
+
stack.push(state)
|
|
1075
|
+
token = TokenType.Punctuation
|
|
1076
|
+
state = State.BeforeType
|
|
1077
|
+
} else if ((next = part.match(RE_EQUAL))) {
|
|
1078
|
+
token = TokenType.Punctuation
|
|
1079
|
+
state = State.TopLevelContent
|
|
1080
|
+
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
1081
|
+
token = TokenType.Text
|
|
1082
|
+
state = State.TopLevelContent
|
|
802
1083
|
} else {
|
|
803
1084
|
throw new Error('no')
|
|
804
1085
|
}
|
|
@@ -810,6 +1091,12 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
810
1091
|
} else if ((next = part.match(RE_KEYWORD_CLASS_PROPERTY_MODIFIER))) {
|
|
811
1092
|
token = TokenType.StorageModifier
|
|
812
1093
|
state = State.InsideClass
|
|
1094
|
+
} else if ((next = part.match(RE_KEYWORD_CONSTRUCTOR))) {
|
|
1095
|
+
token = TokenType.Keyword
|
|
1096
|
+
state = State.AfterVariableName
|
|
1097
|
+
} else if ((next = part.match(RE_FUNCTION_CALL_NAME))) {
|
|
1098
|
+
token = TokenType.FunctionName
|
|
1099
|
+
state = State.AfterVariableName
|
|
813
1100
|
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
814
1101
|
token = TokenType.VariableName
|
|
815
1102
|
state = State.InsideClass
|
|
@@ -824,6 +1111,44 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
824
1111
|
} else if ((next = part.match(RE_SEMICOLON))) {
|
|
825
1112
|
token = TokenType.Punctuation
|
|
826
1113
|
state = State.InsideClass
|
|
1114
|
+
} else if ((next = part.match(RE_EQUAL))) {
|
|
1115
|
+
token = TokenType.Punctuation
|
|
1116
|
+
state = State.TopLevelContent
|
|
1117
|
+
} else if ((next = part.match(RE_SQUARE_OPEN))) {
|
|
1118
|
+
token = TokenType.Punctuation
|
|
1119
|
+
state = State.InsideClass
|
|
1120
|
+
} else if ((next = part.match(RE_SQUARE_CLOSE))) {
|
|
1121
|
+
token = TokenType.Punctuation
|
|
1122
|
+
state = State.InsideClass
|
|
1123
|
+
} else if ((next = part.match(RE_QUOTE_SINGLE))) {
|
|
1124
|
+
stack.push(state)
|
|
1125
|
+
token = TokenType.Punctuation
|
|
1126
|
+
state = State.InsideSingleQuoteString
|
|
1127
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
1128
|
+
stack.push(state)
|
|
1129
|
+
token = TokenType.Comment
|
|
1130
|
+
state = State.InsideBlockComment
|
|
1131
|
+
} else if ((next = part.match(RE_VERTICAL_LINE))) {
|
|
1132
|
+
token = TokenType.Punctuation
|
|
1133
|
+
state = State.InsideClass
|
|
1134
|
+
} else if ((next = part.match(RE_ANGLE_OPEN))) {
|
|
1135
|
+
token = TokenType.Punctuation
|
|
1136
|
+
state = State.TopLevelContent
|
|
1137
|
+
} else if ((next = part.match(RE_QUESTION_MARK_COLON))) {
|
|
1138
|
+
stack.push(state)
|
|
1139
|
+
token = TokenType.Punctuation
|
|
1140
|
+
state = State.BeforeType
|
|
1141
|
+
} else if ((next = part.match(RE_EXLAMATION_MARK_COLON))) {
|
|
1142
|
+
stack.push(state)
|
|
1143
|
+
token = TokenType.Punctuation
|
|
1144
|
+
state = State.BeforeType
|
|
1145
|
+
} else if ((next = part.match(RE_QUOTE_DOUBLE))) {
|
|
1146
|
+
stack.push(state)
|
|
1147
|
+
token = TokenType.Punctuation
|
|
1148
|
+
state = State.InsideDoubleQuoteString
|
|
1149
|
+
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
1150
|
+
token = TokenType.Text
|
|
1151
|
+
state = State.TopLevelContent
|
|
827
1152
|
} else {
|
|
828
1153
|
part
|
|
829
1154
|
throw new Error('no')
|
|
@@ -994,6 +1319,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
994
1319
|
} else if ((next = part.match(RE_PUNCTUATION))) {
|
|
995
1320
|
token = TokenType.Punctuation
|
|
996
1321
|
state = State.InsideMethodParameters
|
|
1322
|
+
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
1323
|
+
token = TokenType.Text
|
|
1324
|
+
state = stack.pop() || State.TopLevelContent
|
|
997
1325
|
} else {
|
|
998
1326
|
part
|
|
999
1327
|
throw new Error('no')
|
|
@@ -1115,6 +1443,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
1115
1443
|
stack.push(state)
|
|
1116
1444
|
token = TokenType.Comment
|
|
1117
1445
|
state = State.AfterInterfaceName
|
|
1446
|
+
} else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
|
|
1447
|
+
token = TokenType.Text
|
|
1448
|
+
state = stack.pop() || State.TopLevelContent
|
|
1118
1449
|
} else {
|
|
1119
1450
|
part
|
|
1120
1451
|
throw new Error('no')
|
|
@@ -1162,6 +1493,58 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
1162
1493
|
} else if ((next = part.match(RE_PUNCTUATION))) {
|
|
1163
1494
|
token = TokenType.Punctuation
|
|
1164
1495
|
state = State.TopLevelContent
|
|
1496
|
+
} else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
|
|
1497
|
+
stack.push(state)
|
|
1498
|
+
token = TokenType.Comment
|
|
1499
|
+
state = State.InsideBlockComment
|
|
1500
|
+
} else {
|
|
1501
|
+
throw new Error('no')
|
|
1502
|
+
}
|
|
1503
|
+
break
|
|
1504
|
+
case State.AfterKeywordInstanceOf:
|
|
1505
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
1506
|
+
token = TokenType.Whitespace
|
|
1507
|
+
state = State.AfterKeywordInstanceOf
|
|
1508
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
1509
|
+
token = TokenType.Class
|
|
1510
|
+
state = State.TopLevelContent
|
|
1511
|
+
} else if ((next = part.match(RE_ROUND_OPEN))) {
|
|
1512
|
+
token = TokenType.Punctuation
|
|
1513
|
+
state = State.TopLevelContent
|
|
1514
|
+
} else {
|
|
1515
|
+
throw new Error('no')
|
|
1516
|
+
}
|
|
1517
|
+
break
|
|
1518
|
+
case State.AfterKeywordNew:
|
|
1519
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
1520
|
+
token = TokenType.Whitespace
|
|
1521
|
+
state = State.AfterKeywordNew
|
|
1522
|
+
} else if ((next = part.match(RE_KEYWORD_NEW))) {
|
|
1523
|
+
token = TokenType.KeywordNew
|
|
1524
|
+
state = State.AfterKeywordNew
|
|
1525
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
1526
|
+
token = TokenType.Class
|
|
1527
|
+
state = State.TopLevelContent
|
|
1528
|
+
} else if ((next = part.match(RE_ROUND_OPEN))) {
|
|
1529
|
+
token = TokenType.Punctuation
|
|
1530
|
+
state = State.TopLevelContent
|
|
1531
|
+
} else if ((next = part.match(RE_COLON))) {
|
|
1532
|
+
token = TokenType.Punctuation
|
|
1533
|
+
state = State.TopLevelContent
|
|
1534
|
+
} else if ((next = part.match(RE_DOT))) {
|
|
1535
|
+
token = TokenType.Punctuation
|
|
1536
|
+
state = State.AfterPropertyDot
|
|
1537
|
+
} else {
|
|
1538
|
+
throw new Error('no')
|
|
1539
|
+
}
|
|
1540
|
+
break
|
|
1541
|
+
case State.AfterKeywordTypeOf:
|
|
1542
|
+
if ((next = part.match(RE_WHITESPACE))) {
|
|
1543
|
+
token = TokenType.Whitespace
|
|
1544
|
+
state = State.AfterKeywordTypeOf
|
|
1545
|
+
} else if ((next = part.match(RE_VARIABLE_NAME))) {
|
|
1546
|
+
token = TokenType.VariableName
|
|
1547
|
+
state = stack.pop() || State.TopLevelContent
|
|
1165
1548
|
} else {
|
|
1166
1549
|
throw new Error('no')
|
|
1167
1550
|
}
|
|
@@ -1178,7 +1561,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
1178
1561
|
state = State.InsideClass
|
|
1179
1562
|
stack.pop()
|
|
1180
1563
|
} else if (state === State.AfterType) {
|
|
1181
|
-
state =
|
|
1564
|
+
state = State.AfterTypeAfterNewLine
|
|
1182
1565
|
}
|
|
1183
1566
|
return {
|
|
1184
1567
|
state,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.16",
|
|
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.
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.16.
|
|
22
|
-
"@lvce-editor/pty-host": "0.16.
|
|
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",
|
|
23
23
|
"debug": "^4.3.4",
|
|
24
24
|
"execa": "^7.1.1",
|
|
25
25
|
"exit-hook": "^3.2.0",
|
|
@@ -227,9 +227,6 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
|
|
|
227
227
|
await replace(Path.join(root, 'dist', 'manifest.json'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
|
|
228
228
|
await replace(Path.join(root, 'dist', 'manifest.json'), `"start_url": "/"`, `"start_url": "${pathPrefix}"`)
|
|
229
229
|
await replace(Path.join(root, 'dist', commitHash, 'css', 'App.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
|
|
230
|
-
await replace(Path.join(root, 'dist', commitHash, 'css', 'parts', 'EditorTabs.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
|
|
231
|
-
await replace(Path.join(root, 'dist', commitHash, 'css', 'parts', 'ViewletTitleBarButtons.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
|
|
232
|
-
await replace(Path.join(root, 'dist', commitHash, 'css', 'parts', 'ViewletTitleBarIcon.css'), `/${commitHash}`, `${pathPrefix}/${commitHash}`)
|
|
233
230
|
}
|
|
234
231
|
}
|
|
235
232
|
|
|
@@ -169,11 +169,11 @@ export const getSetupName = () => {
|
|
|
169
169
|
return 'Lvce-Setup'
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
export const version = '0.16.
|
|
172
|
+
export const version = '0.16.16'
|
|
173
173
|
|
|
174
|
-
export const commit = '
|
|
174
|
+
export const commit = 'd2454d3'
|
|
175
175
|
|
|
176
|
-
export const date = '2023-07-
|
|
176
|
+
export const date = '2023-07-19T15:35:04.000Z'
|
|
177
177
|
|
|
178
178
|
export const getVersion = () => {
|
|
179
179
|
return version
|