@lvce-editor/shared-process 0.16.13 → 0.16.15

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.
@@ -88,7 +88,7 @@ export const TokenMap = {
88
88
  }
89
89
 
90
90
  const RE_KEYWORD =
91
- /^(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|if|implements|import|in|Infinity|instanceof|interface|let|new|null|of|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|undefined|var|void|while|with|yield)\b/
91
+ /^(?:as|assert|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|if|implements|import|in|Infinity|instanceof|interface|let|new|null|of|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|undefined|var|void|while|with|yield)\b/
92
92
 
93
93
  const RE_CURLY_OPEN = /^\{/
94
94
  const RE_CURLY_CLOSE = /^\}/
@@ -203,6 +203,13 @@ export const tokenizeLine = (line, lineState) => {
203
203
  case 'while':
204
204
  token = TokenType.KeywordControl
205
205
  break
206
+ case 'assert':
207
+ if (line.includes('import')) {
208
+ token = TokenType.KeywordControl
209
+ } else {
210
+ token = TokenType.FunctionName
211
+ }
212
+ break
206
213
  case 'async':
207
214
  case 'await':
208
215
  token = TokenType.KeywordModifier
@@ -70,6 +70,7 @@ export const TokenType = {
70
70
  Function: 20,
71
71
  FunctionName: 21,
72
72
  KeywordOperator: 22,
73
+ Text: 23,
73
74
  }
74
75
 
75
76
  export const TokenMap = {
@@ -98,6 +99,7 @@ export const TokenMap = {
98
99
  [TokenType.Function]: 'Function',
99
100
  [TokenType.FunctionName]: 'Function',
100
101
  [TokenType.KeywordOperator]: 'KeywordOperator',
102
+ [TokenType.Text]: 'Text',
101
103
  }
102
104
 
103
105
  export const initialLineState = {
@@ -111,14 +113,15 @@ export const initialLineState = {
111
113
  const RE_LINE_COMMENT = /^\/\/[^\n]*/
112
114
  const RE_KEYWORD =
113
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/
116
+
114
117
  const RE_WHITESPACE = /^\s+/
115
118
  const RE_VARIABLE_NAME = /^[\#\$a-zA-Z\_][\$a-zA-Z\_\d]*/
116
- const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)>\+\-]/
119
+ const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)>\+\-\*]/
117
120
  const RE_QUOTE_SINGLE = /^'/
118
121
  const RE_QUOTE_DOUBLE = /^"/
119
122
  const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^\\']+/
120
123
  const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^\\"]+/
121
- const RE_NUMERIC = /^\d+/
124
+ const RE_NUMERIC = /^(?:-)?\d+/
122
125
  const RE_COLON = /^\:/
123
126
  const RE_COLON_OPTIONAL = /^\??\:/
124
127
  const RE_TYPE_PRIMITIVE = /^(?:string|boolean|number|bigint|symbol|void|any)\b/
@@ -143,6 +146,7 @@ const RE_CURLY_OPEN = /^\{/
143
146
  const RE_CURLY_CLOSE = /^\}/
144
147
  const RE_KEYWORD_CLASS_PROPERTY_MODIFIER =
145
148
  /^(?:override|public|protected|private|readonly)\b/
149
+
146
150
  const RE_VERTICAL_LINE = /^\|/
147
151
  const RE_ROUND_OPEN = /^\(/
148
152
  const RE_ROUND_CLOSE = /^\)/
@@ -177,6 +181,7 @@ const RE_KEYWORD_OF = /^of\b/
177
181
  const RE_KEYWORD_EXTENDS = /^extends\b/
178
182
  const RE_KEYWORD_READONLY = /^readonly\b/
179
183
  const RE_SHEBANG = /^\#\!\/.*/
184
+ const RE_SPREAD = /^\.\.\./
180
185
 
181
186
  export const hasArrayReturn = true
182
187
  /**
@@ -429,6 +434,15 @@ export const tokenizeLine = (line, lineState) => {
429
434
  } else if ((next = part.match(RE_EQUAL))) {
430
435
  token = TokenType.Punctuation
431
436
  state = State.BeforeType
437
+ } else if ((next = part.match(RE_COLON))) {
438
+ token = TokenType.Punctuation
439
+ state = State.AfterKeywordTypeDeclaration
440
+ } else if ((next = part.match(RE_SEMICOLON))) {
441
+ token = TokenType.Punctuation
442
+ state = stack.pop() || State.TopLevelContent
443
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
444
+ token = TokenType.Text
445
+ state = stack.pop() || State.TopLevelContent
432
446
  } else {
433
447
  part
434
448
  throw new Error('no')
@@ -475,6 +489,28 @@ export const tokenizeLine = (line, lineState) => {
475
489
  } else if ((next = part.match(RE_VERTICAL_LINE))) {
476
490
  token = TokenType.Punctuation
477
491
  state = State.BeforeType
492
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
493
+ stack.push(state)
494
+ token = TokenType.Comment
495
+ state = State.InsideBlockComment
496
+ } else if ((next = part.match(RE_LINE_COMMENT))) {
497
+ token = TokenType.Comment
498
+ state = State.BeforeType
499
+ } else if ((next = part.match(RE_NUMERIC))) {
500
+ token = TokenType.Numeric
501
+ state = State.AfterType
502
+ } else if ((next = part.match(RE_NUMERIC_2))) {
503
+ token = TokenType.Numeric
504
+ state = State.AfterType
505
+ } else if ((next = part.match(RE_SQUARE_OPEN))) {
506
+ token = TokenType.Punctuation
507
+ state = State.BeforeType
508
+ } else if ((next = part.match(RE_CURLY_CLOSE))) {
509
+ token = TokenType.Punctuation
510
+ state = stack.pop() || State.TopLevelContent
511
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
512
+ token = TokenType.Text
513
+ state = State.TopLevelContent
478
514
  } else {
479
515
  part
480
516
  throw new Error('no')
@@ -490,6 +526,15 @@ export const tokenizeLine = (line, lineState) => {
490
526
  } else if ((next = part.match(RE_WHITESPACE))) {
491
527
  token = TokenType.Whitespace
492
528
  state = State.InsideTypeExpression
529
+ } else if ((next = part.match(RE_PUNCTUATION))) {
530
+ token = TokenType.Punctuation
531
+ state = State.InsideTypeExpression
532
+ } else if ((next = part.match(RE_SQUARE_OPEN))) {
533
+ token = TokenType.Punctuation
534
+ state = State.InsideTypeExpression
535
+ } else if ((next = part.match(RE_SQUARE_CLOSE))) {
536
+ token = TokenType.Punctuation
537
+ state = State.InsideTypeExpression
493
538
  } else {
494
539
  throw new Error('no')
495
540
  }
@@ -513,6 +558,24 @@ export const tokenizeLine = (line, lineState) => {
513
558
  } else if ((next = part.match(RE_CURLY_CLOSE))) {
514
559
  token = TokenType.Punctuation
515
560
  state = stack.pop() || State.TopLevelContent
561
+ } else if ((next = part.match(RE_KEYWORD))) {
562
+ token = TokenType.Keyword
563
+ state = State.TopLevelContent
564
+ } else if ((next = part.match(RE_PUNCTUATION))) {
565
+ token = TokenType.Punctuation
566
+ state = State.InsideTypeExpression
567
+ } else if ((next = part.match(RE_SQUARE_OPEN))) {
568
+ token = TokenType.Punctuation
569
+ state = State.InsideTypeExpression
570
+ } else if ((next = part.match(RE_SQUARE_CLOSE))) {
571
+ token = TokenType.Punctuation
572
+ state = State.InsideTypeExpression
573
+ } else if ((next = part.match(RE_VERTICAL_LINE))) {
574
+ token = TokenType.Punctuation
575
+ state = State.InsideTypeExpression
576
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
577
+ token = TokenType.Text
578
+ state = State.TopLevelContent
516
579
  } else {
517
580
  part
518
581
  throw new Error('no')
@@ -534,6 +597,12 @@ export const tokenizeLine = (line, lineState) => {
534
597
  } else if ((next = part.match(RE_CURLY_OPEN))) {
535
598
  token = TokenType.Punctuation
536
599
  state = State.TopLevelContent
600
+ } else if ((next = part.match(RE_QUOTE_SINGLE))) {
601
+ token = TokenType.Punctuation
602
+ state = State.InsideSingleQuoteString
603
+ } else if ((next = part.match(RE_PUNCTUATION))) {
604
+ token = TokenType.Punctuation
605
+ state = State.TopLevelContent
537
606
  } else {
538
607
  tokens
539
608
  part
@@ -589,6 +658,13 @@ export const tokenizeLine = (line, lineState) => {
589
658
  } else if ((next = part.match(RE_CURLY_OPEN))) {
590
659
  token = TokenType.Punctuation
591
660
  state = State.InsideTypeObject
661
+ } else if ((next = part.match(RE_QUOTE_SINGLE))) {
662
+ stack.push(state)
663
+ token = TokenType.Punctuation
664
+ state = State.InsideSingleQuoteString
665
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
666
+ token = TokenType.Text
667
+ state = State.TopLevelContent
592
668
  } else {
593
669
  // stack.push(State.AfterType)
594
670
  part
@@ -843,6 +919,19 @@ export const tokenizeLine = (line, lineState) => {
843
919
  } else if ((next = part.match(RE_SQUARE_CLOSE))) {
844
920
  token = TokenType.Punctuation
845
921
  state = State.InsideTypeObject
922
+ } else if ((next = part.match(RE_PUNCTUATION))) {
923
+ token = TokenType.Punctuation
924
+ state = State.InsideTypeObject
925
+ } else if ((next = part.match(RE_QUESTION_MARK))) {
926
+ token = TokenType.Punctuation
927
+ state = State.InsideTypeObject
928
+ } else if ((next = part.match(RE_QUOTE_SINGLE))) {
929
+ token = TokenType.Punctuation
930
+ state = State.InsideSingleQuoteString
931
+ stack.push(State.InsideTypeObject)
932
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
933
+ token = TokenType.Text
934
+ state = State.TopLevelContent
846
935
  } else {
847
936
  part
848
937
  throw new Error('no')
@@ -859,6 +948,9 @@ export const tokenizeLine = (line, lineState) => {
859
948
  } else if ((next = part.match(RE_WHITESPACE))) {
860
949
  token = TokenType.Whitespace
861
950
  state = State.AfterMethodName
951
+ } else if ((next = part.match(RE_SPREAD))) {
952
+ token = TokenType.Punctuation
953
+ state = State.AfterMethodName
862
954
  } else {
863
955
  throw new Error('no')
864
956
  }
@@ -867,6 +959,9 @@ export const tokenizeLine = (line, lineState) => {
867
959
  if ((next = part.match(RE_VARIABLE_NAME))) {
868
960
  token = TokenType.VariableName
869
961
  state = State.InsideMethodParametersAfterVariableName
962
+ } else if ((next = part.match(RE_WHITESPACE))) {
963
+ token = TokenType.Whitespace
964
+ state = State.InsideMethodParameters
870
965
  } else if ((next = part.match(RE_ROUND_CLOSE))) {
871
966
  token = TokenType.Punctuation
872
967
  state = State.AfterMethodParameters
@@ -876,6 +971,29 @@ export const tokenizeLine = (line, lineState) => {
876
971
  } else if ((next = part.match(RE_COLON))) {
877
972
  token = TokenType.Punctuation
878
973
  state = State.BeforeType
974
+ } else if ((next = part.match(RE_COMMA))) {
975
+ token = TokenType.Punctuation
976
+ state = State.InsideMethodParameters
977
+ } else if ((next = part.match(RE_VERTICAL_LINE))) {
978
+ stack.push(state)
979
+ token = TokenType.Punctuation
980
+ state = State.BeforeType
981
+ } else if ((next = part.match(RE_SPREAD))) {
982
+ token = TokenType.Punctuation
983
+ state = State.InsideMethodParameters
984
+ } else if ((next = part.match(RE_SQUARE_OPEN))) {
985
+ token = TokenType.Punctuation
986
+ state = State.InsideMethodParameters
987
+ } else if ((next = part.match(RE_SQUARE_CLOSE))) {
988
+ token = TokenType.Punctuation
989
+ state = State.InsideMethodParameters
990
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
991
+ stack.push(state)
992
+ token = TokenType.Comment
993
+ state = State.InsideBlockComment
994
+ } else if ((next = part.match(RE_PUNCTUATION))) {
995
+ token = TokenType.Punctuation
996
+ state = State.InsideMethodParameters
879
997
  } else {
880
998
  part
881
999
  throw new Error('no')
@@ -886,6 +1004,13 @@ export const tokenizeLine = (line, lineState) => {
886
1004
  token = TokenType.Punctuation
887
1005
  state = State.BeforeType
888
1006
  stack.push(State.InsideMethodParameters)
1007
+ } else if ((next = part.match(RE_QUESTION_MARK_COLON))) {
1008
+ token = TokenType.Punctuation
1009
+ state = State.BeforeType
1010
+ stack.push(State.InsideMethodParameters)
1011
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1012
+ token = TokenType.Text
1013
+ state = State.InsideMethodParametersAfterVariableName
889
1014
  } else {
890
1015
  throw new Error('no')
891
1016
  }
@@ -901,6 +1026,9 @@ export const tokenizeLine = (line, lineState) => {
901
1026
  } else if ((next = part.match(RE_ARROW))) {
902
1027
  token = TokenType.Punctuation
903
1028
  state = State.BeforeType
1029
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1030
+ token = TokenType.Punctuation
1031
+ state = State.TopLevelContent
904
1032
  } else {
905
1033
  throw new Error('no')
906
1034
  }
@@ -924,6 +1052,9 @@ export const tokenizeLine = (line, lineState) => {
924
1052
  } else if ((next = part.match(RE_PUNCTUATION))) {
925
1053
  token = TokenType.Punctuation
926
1054
  state = State.TopLevelContent
1055
+ } else if ((next = part.match(RE_ANYTHING_UNTIL_END))) {
1056
+ token = TokenType.Text
1057
+ state = State.TopLevelContent
927
1058
  } else {
928
1059
  throw new Error('no')
929
1060
  }
@@ -955,6 +1086,35 @@ export const tokenizeLine = (line, lineState) => {
955
1086
  } else if ((next = part.match(RE_VARIABLE_NAME))) {
956
1087
  token = TokenType.Type
957
1088
  state = State.AfterInterfaceName
1089
+ } else if ((next = part.match(RE_ANGLE_OPEN))) {
1090
+ stack.push(State.AfterInterfaceName)
1091
+ token = TokenType.Punctuation
1092
+ state = State.BeforeType
1093
+ } else if ((next = part.match(RE_QUESTION_MARK_COLON))) {
1094
+ token = TokenType.Punctuation
1095
+ state = State.AfterInterfaceName
1096
+ } else if ((next = part.match(RE_ANGLE_CLOSE))) {
1097
+ token = TokenType.Punctuation
1098
+ state = State.AfterInterfaceName
1099
+ } else if ((next = part.match(RE_EQUAL))) {
1100
+ token = TokenType.Punctuation
1101
+ state = State.TopLevelContent
1102
+ } else if ((next = part.match(RE_DOT))) {
1103
+ token = TokenType.Punctuation
1104
+ state = State.AfterPropertyDot
1105
+ } else if ((next = part.match(RE_VERTICAL_LINE))) {
1106
+ token = TokenType.Punctuation
1107
+ state = State.BeforeType
1108
+ } else if ((next = part.match(RE_COLON))) {
1109
+ token = TokenType.Punctuation
1110
+ state = State.BeforeType
1111
+ } else if ((next = part.match(RE_COMMA))) {
1112
+ token = TokenType.Punctuation
1113
+ state = State.TopLevelContent
1114
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
1115
+ stack.push(state)
1116
+ token = TokenType.Comment
1117
+ state = State.AfterInterfaceName
958
1118
  } else {
959
1119
  part
960
1120
  throw new Error('no')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.16.13",
3
+ "version": "0.16.15",
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.13",
21
- "@lvce-editor/extension-host-helper-process": "0.16.13",
22
- "@lvce-editor/pty-host": "0.16.13",
20
+ "@lvce-editor/extension-host": "0.16.15",
21
+ "@lvce-editor/extension-host-helper-process": "0.16.15",
22
+ "@lvce-editor/pty-host": "0.16.15",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -10,8 +10,6 @@ export const Commands = {
10
10
  crashSharedProcess: Crash.crashSharedProcess,
11
11
  createHeapSnapshot: HeapSnapshot.createHeapSnapshot,
12
12
  createProfile: CpuProfile.createProfile,
13
- getNodeStartupTime: Developer.getNodeStartupTiming,
14
- getNodeStartupTiming: Developer.getNodeStartupTiming,
15
13
  sharedProcessMemoryUsage: Developer.sharedProcessMemoryUsage,
16
14
  sharedProcessStartupPerformance: Developer.sharedProcessStartupPerformance,
17
15
  }
@@ -25,36 +25,6 @@ export const sharedProcessStartupPerformance = () => {
25
25
  // performance.eventLoopUtilization
26
26
  }
27
27
 
28
- export const getNodeStartupTiming = () => {
29
- const {
30
- name,
31
- entryType,
32
- startTime,
33
- duration,
34
- // @ts-ignore
35
- nodeStart,
36
- v8Start,
37
- bootstrapComplete,
38
- environment,
39
- loopStart,
40
- loopExit,
41
- idleTime,
42
- } = performance.nodeTiming
43
- return {
44
- name,
45
- entryType,
46
- startTime,
47
- duration,
48
- nodeStart,
49
- v8Start,
50
- bootstrapComplete,
51
- environment,
52
- loopStart,
53
- loopExit,
54
- idleTime,
55
- }
56
- }
57
-
58
28
  export const sharedProcessMemoryUsage = () => {
59
29
  // TODO also print out number of watched files
60
30
  return Process.memoryUsage()
@@ -74,6 +74,8 @@ export const load = (moduleId) => {
74
74
  return import('../WebSocketServer/WebSocketServer.ipc.js')
75
75
  case ModuleId.Workspace:
76
76
  return import('../Workspace/Workspace.ipc.js')
77
+ case ModuleId.Performance:
78
+ return import('../Performance/Performance.ipc.js')
77
79
  default:
78
80
  throw new Error(`module ${moduleId} not found`)
79
81
  }
@@ -34,3 +34,4 @@ export const GetTerminalSpawnOptions = 33
34
34
  export const HandleCliArgs = 34
35
35
  export const ListProcessesWithMemoryUsage = 35
36
36
  export const IncrementalTextSearch = 36
37
+ export const Performance = 37
@@ -26,11 +26,11 @@ export const getModuleId = (commandId) => {
26
26
  case 'Developer.crashSharedProcess':
27
27
  case 'Developer.createHeapSnapshot':
28
28
  case 'Developer.createProfile':
29
- case 'Developer.getNodeStartupTime':
30
- case 'Developer.getNodeStartupTiming':
31
29
  case 'Developer.sharedProcessMemoryUsage':
32
30
  case 'Developer.sharedProcessStartupPerformance':
33
31
  return ModuleId.Developer
32
+ case 'Performance.getNodeStartupTiming':
33
+ return ModuleId.Performance
34
34
  case 'Download.download':
35
35
  return ModuleId.Download
36
36
  case 'ElectronInitialize.electronInitialize':
@@ -0,0 +1,7 @@
1
+ import * as Performance from './Performance.js'
2
+
3
+ export const name = 'Performance'
4
+
5
+ export const Commands = {
6
+ getNodeStartupTiming: Performance.getNodeStartupTiming,
7
+ }
@@ -0,0 +1,29 @@
1
+ export const getNodeStartupTiming = () => {
2
+ const {
3
+ name,
4
+ entryType,
5
+ startTime,
6
+ duration,
7
+ // @ts-ignore
8
+ nodeStart,
9
+ v8Start,
10
+ bootstrapComplete,
11
+ environment,
12
+ loopStart,
13
+ loopExit,
14
+ idleTime,
15
+ } = performance.nodeTiming
16
+ return {
17
+ name,
18
+ entryType,
19
+ startTime,
20
+ duration,
21
+ nodeStart,
22
+ v8Start,
23
+ bootstrapComplete,
24
+ environment,
25
+ loopStart,
26
+ loopExit,
27
+ idleTime,
28
+ }
29
+ }
@@ -169,11 +169,11 @@ export const getSetupName = () => {
169
169
  return 'Lvce-Setup'
170
170
  }
171
171
 
172
- export const version = '0.16.13'
172
+ export const version = '0.16.15'
173
173
 
174
- export const commit = 'ee10956'
174
+ export const commit = '7321f00'
175
175
 
176
- export const date = '2023-07-11T15:00:17.000Z'
176
+ export const date = '2023-07-18T15:56:24.000Z'
177
177
 
178
178
  export const getVersion = () => {
179
179
  return version