@lvce-editor/shared-process 0.13.0 → 0.14.1

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.
Files changed (112) hide show
  1. package/config/defaultKeyBindings.json +1 -784
  2. package/config/defaultSettings.json +8 -1
  3. package/extensions/builtin.language-basics-css/extension.json +2 -1
  4. package/extensions/builtin.language-basics-css/languageConfiguration.json +21 -0
  5. package/extensions/builtin.language-basics-css/src/tokenizeCss.js +10 -1
  6. package/extensions/builtin.language-basics-dotenv/extension.json +5 -1
  7. package/extensions/builtin.language-basics-go/src/tokenizeGo.js +79 -10
  8. package/extensions/builtin.language-basics-html/languageConfiguration.json +66 -0
  9. package/extensions/builtin.language-basics-html/src/tokenizeHtml.js +89 -27
  10. package/extensions/builtin.language-basics-java/src/tokenizeJava.js +6 -5
  11. package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +29 -1
  12. package/extensions/builtin.language-basics-json/extension.json +4 -2
  13. package/extensions/builtin.language-basics-json/src/tokenizeJson.js +3 -0
  14. package/extensions/builtin.language-basics-jsx/src/tokenizeJsx.js +18 -5
  15. package/extensions/builtin.language-basics-typescript/src/tokenizeTypeScript.js +26 -0
  16. package/extensions/builtin.language-basics-vue/src/tokenizeVue.js +1 -1
  17. package/extensions/builtin.language-basics-xml/extension.json +3 -1
  18. package/extensions/builtin.theme-atom-one-dark/color-theme.json +2 -2
  19. package/extensions/builtin.theme-ayu/color-theme.json +6 -2
  20. package/extensions/builtin.theme-cobalt2/color-theme.json +5 -2
  21. package/extensions/builtin.theme-slime/color-theme.json +2 -2
  22. package/package.json +10 -11
  23. package/src/parts/Assert/Assert.js +1 -6
  24. package/src/parts/AssertionError/AssertionError.js +6 -0
  25. package/src/parts/BulkReplacement/BulkReplacement.ipc.js +7 -0
  26. package/src/parts/BulkReplacement/BulkReplacement.js +20 -0
  27. package/src/parts/BulkReplacementContent/BulkReplacementContent.js +30 -0
  28. package/src/parts/ChildProcessError/ChildProcessError.js +45 -0
  29. package/src/parts/ChromeExtension/ChromeExtension.js +2 -5
  30. package/src/parts/CleanStack/CleanStack.js +90 -2
  31. package/src/parts/CliList/CliList.js +3 -0
  32. package/src/parts/ClipBoard/ClipBoard.js +2 -2
  33. package/src/parts/ClipBoard/ClipBoardGnome.js +1 -2
  34. package/src/parts/ClipBoard/ClipBoardNoop.js +2 -2
  35. package/src/parts/ClipBoard/ClipBoardWindows.js +1 -3
  36. package/src/parts/Command/Command.js +5 -10
  37. package/src/parts/Credentials/Credentials.ipc.js +5 -5
  38. package/src/parts/Credentials/Credentials.js +2 -10
  39. package/src/parts/Desktop/Desktop.js +22 -0
  40. package/src/parts/Download/Download.js +2 -2
  41. package/src/parts/Error/Error.js +1 -1
  42. package/src/parts/ErrorCodes/ErrorCodes.js +2 -1
  43. package/src/parts/ErrorHandling/ErrorHandling.js +8 -14
  44. package/src/parts/ExportStatic/ExportStatic.js +8 -3
  45. package/src/parts/ExtensionHost/ExtensionHost.js +1 -2
  46. package/src/parts/ExtensionHost/ExtensionHostKeyBindings.js +0 -12
  47. package/src/parts/ExtensionHostRpc/ExtensionHostRpc.js +1 -1
  48. package/src/parts/ExtensionInstallFromFile/ExtensionInstallFromFile.js +1 -1
  49. package/src/parts/ExtensionInstallFromGitHub/ExtensionInstallFromGitHub.js +1 -1
  50. package/src/parts/ExtensionInstallFromUrl/ExtensionInstallFromUrl.js +1 -1
  51. package/src/parts/ExtensionLink/ExtensionLink.js +0 -19
  52. package/src/parts/ExtensionList/ExtensionList.js +11 -2
  53. package/src/parts/ExtensionManagement/ExtensionManagement.js +6 -58
  54. package/src/parts/ExtensionManagement/ExtensionManagementColorTheme.js +3 -1
  55. package/src/parts/ExtensionManagement/ExtensionManagementIconTheme.js +1 -1
  56. package/src/parts/ExtensionManagement/ExtensionManagementLanguages.js +7 -3
  57. package/src/parts/ExtensionManifestInputType/ExtensionManifestInputType.js +2 -0
  58. package/src/parts/ExtensionManifests/ExtensionManifests.js +3 -0
  59. package/src/parts/ExtensionManifests/ExtensionManifestsFromFolder.js +5 -15
  60. package/src/parts/ExtensionManifests/ExtensionManifestsFromLinkedExtensionsFolder.js +56 -0
  61. package/src/parts/ExtensionUninstall/ExtensionUninstall.js +18 -0
  62. package/src/parts/ExtensionUnlink/ExtensionUnlink.js +1 -1
  63. package/src/parts/Extract/Extract.js +2 -6
  64. package/src/parts/ExtractZip/ExtractZip.js +1 -1
  65. package/src/parts/{Error → FileNotFoundError}/FileNotFoundError.js +9 -2
  66. package/src/parts/FileSystem/FileSystem.js +6 -32
  67. package/src/parts/FirstNodeWorkerEventType/FirstNodeWorkerEventType.js +5 -0
  68. package/src/parts/GetDirentType/GetDirentType.js +27 -0
  69. package/src/parts/GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js +39 -0
  70. package/src/parts/GetFirstNodeWorkerEvent/GetFirstNodeWorkerEvent.js +21 -0
  71. package/src/parts/GetNewLineIndex/GetNewLineIndex.js +9 -0
  72. package/src/parts/GetResponse/GetResponse.js +16 -6
  73. package/src/parts/GetTextSearchRipGrepArgs/GetTextSearchRipGrepArgs.js +14 -0
  74. package/src/parts/InstallExtension/InstallExtension.ipc.js +6 -0
  75. package/src/parts/InstallExtension/InstallExtension.js +33 -0
  76. package/src/parts/IpcParent/IpcParent.js +9 -0
  77. package/src/parts/IpcParentModule/IpcParentModule.js +12 -0
  78. package/src/parts/IpcParentType/IpcParentType.js +2 -0
  79. package/src/parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js +49 -0
  80. package/src/parts/IpcParentWithNodeWorker/IpcParentWithNodeWorker.js +36 -0
  81. package/src/parts/IsEnoentErrorWindows/IsEnoentErrorWindows.js +3 -0
  82. package/src/parts/IsIgnoredError/IsIgnoredError.js +14 -0
  83. package/src/parts/Json/Json.js +3 -5
  84. package/src/parts/JsonError/JsonError.js +8 -14
  85. package/src/parts/JsonParsingError/JsonParsingError.js +17 -0
  86. package/src/parts/Jsonc/Jsonc.js +304 -0
  87. package/src/parts/JsoncCharCode/JsoncCharCode.js +23 -0
  88. package/src/parts/JsoncFile/JsoncFile.js +8 -0
  89. package/src/parts/JsoncTokenType/JsoncTokenType.js +11 -0
  90. package/src/parts/LimitString/LimitString.js +3 -1
  91. package/src/parts/MergeStacks/MergeStacks.js +3 -2
  92. package/src/parts/Module/Module.js +4 -0
  93. package/src/parts/ModuleId/ModuleId.js +2 -0
  94. package/src/parts/ModuleMap/ModuleMap.js +4 -0
  95. package/src/parts/Native/Native.js +1 -1
  96. package/src/parts/ParentIpc/ParentIpc.js +2 -1
  97. package/src/parts/Platform/Platform.js +0 -21
  98. package/src/parts/Preferences/Preferences.js +6 -8
  99. package/src/parts/PrettyError/PrettyError.js +16 -7
  100. package/src/parts/PrintPrettyError/PrintPrettyError.js +3 -1
  101. package/src/parts/RecentlyOpened/RecentlyOpened.js +3 -7
  102. package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
  103. package/src/parts/RipGrep/RipGrep.js +1 -1
  104. package/src/parts/SearchFile/SearchFile.js +4 -9
  105. package/src/parts/Socket/Socket.js +2 -7
  106. package/src/parts/Terminal/Terminal.ipc.js +4 -41
  107. package/src/parts/Terminal/Terminal.js +29 -25
  108. package/src/parts/TextSearch/TextSearch.js +102 -108
  109. package/src/parts/ToAbsolutePaths/ToAbsolutePaths.js +9 -0
  110. package/src/parts/ToTextSearchResult/ToTextSearchResult.js +42 -0
  111. package/src/parts/Trash/Trash.js +1 -2
  112. /package/src/parts/{RgPath/RgPath.js → RipGrepPath/RipGrepPath.js} +0 -0
@@ -10,6 +10,11 @@
10
10
  "editor.letterSpacing": 0.5,
11
11
  "editor.fontLigatures": true,
12
12
  "editor.links": true,
13
+ "editor.tabSize": 2,
14
+
15
+ "editor.autoClosingBrackets": true,
16
+ "editor.autoClosingQuotes": true,
17
+ "editor.quickSuggestions": false,
13
18
 
14
19
  "extensions.autoUpdate": true,
15
20
 
@@ -29,8 +34,10 @@
29
34
 
30
35
  "serviceWorker.enabled": false,
31
36
 
37
+ "simpleBrowser.suggestions": false,
38
+
32
39
  "window.titleBarStyle": "native",
33
- "window.zoomLevel": 0.5,
40
+ "window.zoomLevel": 0,
34
41
  "window.controlsOverlay.enabled": true,
35
42
 
36
43
  "workbench.colorTheme": "slime",
@@ -6,7 +6,8 @@
6
6
  {
7
7
  "id": "css",
8
8
  "extensions": [".css"],
9
- "tokenize": "src/tokenizeCss.js"
9
+ "tokenize": "src/tokenizeCss.js",
10
+ "configuration": "languageConfiguration.json"
10
11
  }
11
12
  ]
12
13
  }
@@ -0,0 +1,21 @@
1
+ {
2
+ "comments": {
3
+ "blockComment": ["/*", "*/"]
4
+ },
5
+ "brackets": [
6
+ ["{", "}"],
7
+ ["[", "]"],
8
+ ["(", ")"]
9
+ ],
10
+ "autoClosingPairs": [
11
+ { "open": "{", "close": "}", "notIn": ["string", "comment"] },
12
+ { "open": "[", "close": "]", "notIn": ["string", "comment"] },
13
+ { "open": "(", "close": ")", "notIn": ["string", "comment"] },
14
+ { "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
15
+ { "open": "'", "close": "'", "notIn": ["string", "comment"] }
16
+ ],
17
+ "indentationRules": {
18
+ "increaseIndentPattern": "(^.*\\{[^}]*$)",
19
+ "decreaseIndentPattern": "^\\s*\\}"
20
+ }
21
+ }
@@ -306,6 +306,9 @@ export const tokenizeLine = (line, lineState) => {
306
306
  token = TokenType.Comment
307
307
  state = State.InsideBlockComment
308
308
  stack.push(State.InsideSelector)
309
+ } else if ((next = part.match(RE_STAR))) {
310
+ token = TokenType.Punctuation
311
+ state = State.InsideSelector
309
312
  } else if ((next = part.match(RE_ANYTHING_UNTIL_CLOSE_BRACE))) {
310
313
  token = TokenType.Unknown
311
314
  state = State.InsideSelector
@@ -465,7 +468,7 @@ export const tokenizeLine = (line, lineState) => {
465
468
  state = State.AfterFunctionName
466
469
  } else if ((next = part.match(RE_ROUND_CLOSE))) {
467
470
  token = TokenType.Punctuation
468
- state = State.AfterFunctionNameInsideArguments
471
+ state = stack.pop() || State.InsideSelector
469
472
  } else if ((next = part.match(RE_SEMICOLON))) {
470
473
  token = TokenType.Punctuation
471
474
  state = State.InsideSelector
@@ -492,6 +495,9 @@ export const tokenizeLine = (line, lineState) => {
492
495
  } else if ((next = part.match(RE_PROPERTY_VALUE_INSIDE_FUNCTION))) {
493
496
  token = TokenType.CssPropertyValue
494
497
  state = State.AfterFunctionName
498
+ } else if ((next = part.match(RE_CURLY_CLOSE))) {
499
+ token = TokenType.Punctuation
500
+ state = stack.pop() || State.TopLevelContent
495
501
  } else {
496
502
  part
497
503
  throw new Error('no')
@@ -541,6 +547,9 @@ export const tokenizeLine = (line, lineState) => {
541
547
  index += tokenLength
542
548
  tokens.push(token, tokenLength)
543
549
  }
550
+ if (state === State.AfterPropertyName) {
551
+ state = State.InsideSelector
552
+ }
544
553
  return {
545
554
  state,
546
555
  tokens,
@@ -11,7 +11,11 @@
11
11
  ".env.local",
12
12
  ".env.example",
13
13
  ".env.development.example",
14
- ".env.production.example"
14
+ ".env.production.example",
15
+ ".env.development",
16
+ ".env.production",
17
+ ".env.dev",
18
+ ".env.sample"
15
19
  ],
16
20
  "configuration": "./languageConfiguration.json",
17
21
  "tokenize": "src/tokenizeDotenv.js"
@@ -30,6 +30,8 @@ export const TokenType = {
30
30
  NewLine: 771,
31
31
  Keyword: 951,
32
32
  VariableName: 952,
33
+ LanguageConstant: 953,
34
+ KeywordControl: 954,
33
35
  }
34
36
 
35
37
  export const TokenMap = {
@@ -51,14 +53,14 @@ export const TokenMap = {
51
53
  [TokenType.NewLine]: 'NewLine',
52
54
  [TokenType.Keyword]: 'Keyword',
53
55
  [TokenType.VariableName]: 'VariableName',
56
+ [TokenType.LanguageConstant]: 'LanguageConstant',
57
+ [TokenType.KeywordControl]: 'KeywordControl',
54
58
  }
55
59
 
56
60
  const RE_WHITESPACE = /^\s+/
57
61
  const RE_WHITESPACE_SINGLE_LINE = /^( |\t)+/
58
62
  const RE_WHITESPACE_NEWLINE = /^\n/
59
63
  const RE_CONSTANT = /^(true|false|null)/
60
- const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\n]+/
61
- const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^'\n]+/
62
64
  const RE_DOUBLE_QUOTE = /^"/
63
65
  const RE_CURLY_OPEN = /^\{/
64
66
  const RE_CURLY_CLOSE = /^\}/
@@ -82,7 +84,7 @@ const RE_ROUND_CLOSE = /^\)/
82
84
  const RE_DOT = /^\./
83
85
  const RE_EQUAL_SIGN = /^=/
84
86
  const RE_SINGLE_QUOTE = /^'/
85
- const RE_PUNCTUATION = /^[\(\)=\+\-><\.,\/\*\^\[\]\{\}\|:]/
87
+ const RE_PUNCTUATION = /^[\(\)=\+\-><\.,\/\*\^\[\]\{\}\|:\;\%]/
86
88
  const RE_ANYTHING_UNTIL_END = /^.+/s
87
89
  const RE_START_OF_FUNCTION = /^( )*\(/
88
90
  const RE_COLON_COLON = /^::/
@@ -92,17 +94,39 @@ const RE_SQUARE_OPEN_SQUARE_OPEN = /^\[\[/
92
94
  const RE_SQUARE_CLOSE_SQUARE_CLOSE = /^\]\]/
93
95
  const RE_STRING_MULTILINE_CONTENT = /^.+?(?=\]\]|$)/s
94
96
  const RE_KEYWORD =
95
- /^(?:var|type|switch|struct|select|return|range|package|map|interface|import|if|goto|go|func|default|continue|const|chan|case|break)\b/
97
+ /^(?:var|type|true|switch|struct|select|return|range|package|map|interface|import|if|goto|go|for|func|false|default|continue|const|chan|case|break)\b/
96
98
  const RE_TEXT = /^.+/s
99
+ const RE_QUOTE_SINGLE = /^'/
100
+ const RE_QUOTE_DOUBLE = /^"/
101
+ const RE_QUOTE_BACKTICK = /^`/
102
+ const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^'\\]+/
103
+ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\\]+/
104
+ const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`\\\$]+/
105
+ const RE_STRING_ESCAPE = /^\\./
106
+ const RE_BACKSLASH = /^\\/
97
107
 
98
108
  export const initialLineState = {
99
109
  state: State.TopLevelContent,
100
110
  }
101
111
 
112
+ export const hasArrayReturn = true
113
+
114
+ /**
115
+ *
116
+ * @param {*} lineStateA
117
+ * @param {*} lineStateB
118
+ * @returns
119
+ */
102
120
  export const isLineStateEqual = (lineStateA, lineStateB) => {
103
121
  return lineStateA.state === lineStateB.state
104
122
  }
105
123
 
124
+ /**
125
+ *
126
+ * @param {string} line
127
+ * @param {*} lineState
128
+ * @returns
129
+ */
106
130
  export const tokenizeLine = (line, lineState) => {
107
131
  let next = null
108
132
  let index = 0
@@ -117,17 +141,47 @@ export const tokenizeLine = (line, lineState) => {
117
141
  token = TokenType.Whitespace
118
142
  state = State.TopLevelContent
119
143
  } else if ((next = part.match(RE_KEYWORD))) {
120
- token = TokenType.Keyword
144
+ switch (next[0]) {
145
+ case 'true':
146
+ case 'false':
147
+ token = TokenType.LanguageConstant
148
+ break
149
+ case 'as':
150
+ case 'switch':
151
+ case 'default':
152
+ case 'case':
153
+ case 'else':
154
+ case 'if':
155
+ case 'break':
156
+ case 'throw':
157
+ case 'for':
158
+ case 'try':
159
+ case 'catch':
160
+ case 'finally':
161
+ case 'continue':
162
+ case 'while':
163
+ token = TokenType.KeywordControl
164
+ break
165
+ default:
166
+ token = TokenType.Keyword
167
+ break
168
+ }
121
169
  state = State.TopLevelContent
122
170
  } else if ((next = part.match(RE_VARIABLE_NAME))) {
123
171
  token = TokenType.VariableName
124
172
  state = State.TopLevelContent
173
+ } else if ((next = part.match(RE_NUMERIC))) {
174
+ token = TokenType.Numeric
175
+ state = State.TopLevelContent
125
176
  } else if ((next = part.match(RE_LINE_COMMENT))) {
126
177
  token = TokenType.Comment
127
178
  state = State.InsideLineComment
128
179
  } else if ((next = part.match(RE_PUNCTUATION))) {
129
180
  token = TokenType.Punctuation
130
181
  state = State.TopLevelContent
182
+ } else if ((next = part.match(RE_QUOTE_DOUBLE))) {
183
+ token = TokenType.Punctuation
184
+ state = State.InsideDoubleQuoteString
131
185
  } else if ((next = part.match(RE_TEXT))) {
132
186
  token = TokenType.Text
133
187
  state = State.TopLevelContent
@@ -136,6 +190,23 @@ export const tokenizeLine = (line, lineState) => {
136
190
  throw new Error('no')
137
191
  }
138
192
  break
193
+ case State.InsideDoubleQuoteString:
194
+ if ((next = part.match(RE_QUOTE_DOUBLE))) {
195
+ token = TokenType.Punctuation
196
+ state = State.TopLevelContent
197
+ } else if ((next = part.match(RE_STRING_DOUBLE_QUOTE_CONTENT))) {
198
+ token = TokenType.String
199
+ state = State.InsideDoubleQuoteString
200
+ } else if ((next = part.match(RE_STRING_ESCAPE))) {
201
+ token = TokenType.String
202
+ state = State.InsideDoubleQuoteString
203
+ } else if ((next = part.match(RE_BACKSLASH))) {
204
+ token = TokenType.String
205
+ state = State.InsideDoubleQuoteString
206
+ } else {
207
+ throw new Error('no')
208
+ }
209
+ break
139
210
  case State.InsideLineComment:
140
211
  if ((next = part.match(RE_TEXT))) {
141
212
  token = TokenType.Comment
@@ -148,11 +219,9 @@ export const tokenizeLine = (line, lineState) => {
148
219
  state
149
220
  throw new Error('no')
150
221
  }
151
- index += next[0].length
152
- tokens.push({
153
- type: token,
154
- length: next[0].length,
155
- })
222
+ const tokenLength = next[0].length
223
+ index += tokenLength
224
+ tokens.push(token, tokenLength)
156
225
  }
157
226
  return {
158
227
  state,
@@ -0,0 +1,66 @@
1
+ {
2
+ "comments": {
3
+ "blockComment": ["<!--", "-->"]
4
+ },
5
+ "brackets": [
6
+ ["<!--", "-->"],
7
+ ["<", ">"],
8
+ ["{", "}"],
9
+ ["(", ")"]
10
+ ],
11
+ "autoClosingPairs": [
12
+ { "open": "{", "close": "}" },
13
+ { "open": "[", "close": "]" },
14
+ { "open": "(", "close": ")" },
15
+ { "open": "'", "close": "'" },
16
+ { "open": "\"", "close": "\"" },
17
+ { "open": "<!--", "close": "-->", "notIn": ["comment", "string"] }
18
+ ],
19
+ "surroundingPairs": [
20
+ { "open": "'", "close": "'" },
21
+ { "open": "\"", "close": "\"" },
22
+ { "open": "{", "close": "}" },
23
+ { "open": "[", "close": "]" },
24
+ { "open": "(", "close": ")" },
25
+ { "open": "<", "close": ">" }
26
+ ],
27
+ "colorizedBracketPairs": [
28
+ ["{", "}"],
29
+ ["(", ")"]
30
+ ],
31
+ "folding": {
32
+ "markers": {
33
+ "start": "^\\s*<!--\\s*#region\\b.*-->",
34
+ "end": "^\\s*<!--\\s*#endregion\\b.*-->"
35
+ }
36
+ },
37
+ "wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\$\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\s]+)",
38
+ "onEnterRules": [
39
+ {
40
+ "beforeText": {
41
+ "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!\\/)>)[^<]*$",
42
+ "flags": "i"
43
+ },
44
+ "afterText": {
45
+ "pattern": "^<\\/([_:\\w][_:\\w-.\\d]*)\\s*>",
46
+ "flags": "i"
47
+ },
48
+ "action": {
49
+ "indent": "indentOutdent"
50
+ }
51
+ },
52
+ {
53
+ "beforeText": {
54
+ "pattern": "<(?!(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr))(\\w[\\w\\d]*)([^/>]*(?!\\/)>)[^<]*$",
55
+ "flags": "i"
56
+ },
57
+ "action": {
58
+ "indent": "indent"
59
+ }
60
+ }
61
+ ],
62
+ "indentationRules": {
63
+ "increaseIndentPattern": "<(?!\\?|(?:area|base|br|col|frame|hr|html|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\\b|[^>]*\\/>)([-_\\.A-Za-z0-9]+)(?=\\s|>)\\b[^>]*>(?!.*<\\/\\1>)|<!--(?!.*-->)|\\{[^}\"']*$",
64
+ "decreaseIndentPattern": "^\\s*(<\\/(?!html)[-_\\.A-Za-z0-9]+\\b[^>]*>|-->|\\})"
65
+ }
66
+ }
@@ -17,6 +17,7 @@ const State = {
17
17
  InsideSingleQuoteString: 13,
18
18
  InsideScriptContent: 14,
19
19
  InsideStyleContent: 15,
20
+ InsideStartTagBeforeAngleBracket: 16,
20
21
  }
21
22
 
22
23
  export const StateMap = {}
@@ -58,7 +59,6 @@ export const TokenMap = {
58
59
  }
59
60
 
60
61
  const RE_ANGLE_BRACKET_CLOSE = /^>/
61
- const RE_ANGLE_BRACKET_ONLY = /^</
62
62
  const RE_ANGLE_BRACKET_OPEN = /^</
63
63
  const RE_ANGLE_BRACKET_OPEN_TAG = /^<(?![\s!\%])/
64
64
  const RE_ANY_TEXT = /^[^\n]+/
@@ -71,13 +71,8 @@ const RE_DOCTYPE = /^<!(?=\w)/
71
71
  const RE_DASH_DASH = /^\-\-/
72
72
  const RE_DOUBLE_QUOTE = /^"/
73
73
  const RE_EQUAL_SIGN = /^=/
74
+ const RE_WHITESPACE_THEN_EQUAL_SIGN = /^\s+(?==)/
74
75
  const RE_EXCLAMATION_MARK = /^!/
75
- const RE_INVALID_INSIDE_ClOSING_TAG = /^[^a-zA-Z>]/
76
- const RE_INVALID_INSIDE_OPENING_TAG = /^[^a-zA-Z>]/
77
- const RE_NEWLINE = /^\n/
78
- const RE_NEWLINE_WHITESPACE = /^\n\s*/
79
- const RE_NOT_TAGNAME = /^[^a-zA-Z\d]+/
80
- const RE_PUNCTUATION = /^[<;'".,]/
81
76
  const RE_PUNCTUATION_SELF_CLOSING = /^\/>/
82
77
  const RE_SELF_CLOSING = /^\/>/
83
78
  const RE_SINGLE_QUOTE = /^'/
@@ -85,15 +80,15 @@ const RE_SLASH = /^\//
85
80
  const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"]+/
86
81
  const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^']+/
87
82
  const RE_TAG_TEXT = /^[^\s>]+/
88
- const RE_TAGNAME = /^[!\w\:]+/
83
+ const RE_TAGNAME = /^[!\w\:][!\w\:\d\-]*/
89
84
  const RE_TEXT = /^[^<>\n]+/
90
85
  const RE_WHITESPACE = /^\s+/
91
- const RE_WORD = /^[^\s]+/
92
86
  const RE_ATTRIBUTE_VALUE_UNQUOTED = /^[^<>\s]+/
93
87
  const RE_SCRIPT_CONTENT = /^..*?(?=(?:<\/script)|$)/s
94
88
  const RE_SCRIPT_CONTENT_END = /^<\/script/
95
- const RE_STYLE_CONTENT = /^..*?(?=(?:<\/style)|$)/s
89
+ const RE_STYLE_CONTENT = /^..*?(?=(?:<\/(?:style|head))|$)/s
96
90
  const RE_STYLE_CONTENT_END = /^<\/style/
91
+ const RE_STYLE_CONTENT_END_2 = /^<\/head/
97
92
 
98
93
  export const initialLineState = {
99
94
  state: State.TopLevelContent,
@@ -125,6 +120,36 @@ const getEmbeddedStyleLanguageId = () => {
125
120
  return 'css'
126
121
  }
127
122
 
123
+ /**
124
+ * @param {string} tag
125
+ */
126
+ const getEmbeddedLangageId = (tag) => {
127
+ switch (tag) {
128
+ case 'script':
129
+ return getEmbeddedScriptLanguageId()
130
+ case 'style':
131
+ return getEmbeddedStyleLanguageId()
132
+ default:
133
+ return ''
134
+ }
135
+ }
136
+
137
+ /**
138
+ *
139
+ * @param {string} tag
140
+ * @returns
141
+ */
142
+ const getEmbeddedContentState = (tag) => {
143
+ switch (tag) {
144
+ case 'script':
145
+ return State.InsideScriptContent
146
+ case 'style':
147
+ return State.InsideStyleContent
148
+ default:
149
+ return State.TopLevelContent
150
+ }
151
+ }
152
+
128
153
  /**
129
154
  *
130
155
  * @param {string} line
@@ -194,18 +219,11 @@ export const tokenizeLine = (line, lineState) => {
194
219
  if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
195
220
  token = TokenType.PunctuationTag
196
221
  state = State.TopLevelContent
197
- switch (tag) {
198
- case 'script':
199
- state = State.InsideScriptContent
200
- embeddedLanguage = getEmbeddedScriptLanguageId()
201
- embeddedLanguageStart = index + next[0].length
202
- break
203
- case 'style':
204
- state = State.InsideStyleContent
205
- embeddedLanguage = getEmbeddedStyleLanguageId()
206
- embeddedLanguageStart = index + next[0].length
207
- default:
208
- break
222
+ const embeddedLanguageId = getEmbeddedLangageId(tag)
223
+ if (embeddedLanguageId) {
224
+ state = getEmbeddedContentState(tag)
225
+ embeddedLanguage = embeddedLanguageId
226
+ embeddedLanguageStart = index + next[0].length
209
227
  }
210
228
  } else if ((next = part.match(RE_EXCLAMATION_MARK))) {
211
229
  token = TokenType.PunctuationTag
@@ -249,6 +267,12 @@ export const tokenizeLine = (line, lineState) => {
249
267
  } else if ((next = part.match(RE_TEXT))) {
250
268
  token = TokenType.Text
251
269
  state = State.TopLevelContent
270
+ } else if ((next = part.match(RE_WHITESPACE))) {
271
+ token = TokenType.Whitespace
272
+ state = State.AfterClosingTagName
273
+ } else if ((next = part.match(RE_ANGLE_BRACKET_OPEN_TAG))) {
274
+ token = TokenType.PunctuationTag
275
+ state = State.AfterOpeningAngleBracket
252
276
  } else {
253
277
  throw new Error('no')
254
278
  }
@@ -263,13 +287,24 @@ export const tokenizeLine = (line, lineState) => {
263
287
  } else if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
264
288
  token = TokenType.PunctuationTag
265
289
  state = State.TopLevelContent
266
- if (tag === 'script') {
267
- state = State.InsideScriptContent
268
- embeddedLanguage = 'javascript'
290
+ const embeddedLanguageId = getEmbeddedLangageId(tag)
291
+ if (embeddedLanguageId) {
292
+ state = getEmbeddedContentState(tag)
293
+ embeddedLanguage = embeddedLanguageId
294
+ embeddedLanguageStart = index + next[0].length
269
295
  }
296
+ } else if ((next = part.match(RE_DOUBLE_QUOTE))) {
297
+ token = TokenType.Punctuation
298
+ state = State.InsideDoubleQuoteString
299
+ } else if ((next = part.match(RE_ANGLE_BRACKET_OPEN_TAG))) {
300
+ token = TokenType.PunctuationTag
301
+ state = State.AfterOpeningAngleBracket
270
302
  } else if ((next = part.match(RE_TAG_TEXT))) {
271
303
  token = TokenType.Text
272
304
  state = State.TopLevelContent
305
+ } else if ((next = part.match(RE_WHITESPACE))) {
306
+ token = TokenType.Whitespace
307
+ state = State.InsideOpeningTagAndHasSeenWhitespace
273
308
  } else {
274
309
  part //?
275
310
  throw new Error('no')
@@ -279,6 +314,12 @@ export const tokenizeLine = (line, lineState) => {
279
314
  if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
280
315
  token = TokenType.PunctuationTag
281
316
  state = State.TopLevelContent
317
+ const embeddedLanguageId = getEmbeddedLangageId(tag)
318
+ if (embeddedLanguageId) {
319
+ state = getEmbeddedContentState(tag)
320
+ embeddedLanguage = embeddedLanguageId
321
+ embeddedLanguageStart = index + next[0].length
322
+ }
282
323
  } else if ((next = part.match(RE_EQUAL_SIGN))) {
283
324
  token = TokenType.Punctuation
284
325
  state = State.AfterAttributeEqualSign
@@ -291,6 +332,9 @@ export const tokenizeLine = (line, lineState) => {
291
332
  } else if ((next = part.match(RE_TAG_TEXT))) {
292
333
  token = TokenType.Text
293
334
  state = State.InsideOpeningTag
335
+ } else if ((next = part.match(RE_WHITESPACE_THEN_EQUAL_SIGN))) {
336
+ token = TokenType.Whitespace
337
+ state = State.AfterAttributeName
294
338
  } else if ((next = part.match(RE_WHITESPACE))) {
295
339
  token = TokenType.Whitespace
296
340
  state = State.InsideOpeningTagAndHasSeenWhitespace
@@ -313,6 +357,9 @@ export const tokenizeLine = (line, lineState) => {
313
357
  } else if ((next = part.match(RE_ATTRIBUTE_VALUE_UNQUOTED))) {
314
358
  token = TokenType.String
315
359
  state = State.InsideOpeningTag
360
+ } else if ((next = part.match(RE_WHITESPACE))) {
361
+ token = TokenType.Whitespace
362
+ state = State.AfterAttributeEqualSign
316
363
  } else {
317
364
  part
318
365
  throw new Error('no')
@@ -374,10 +421,19 @@ export const tokenizeLine = (line, lineState) => {
374
421
  }
375
422
  break
376
423
  case State.InsideStyleContent:
377
- if ((next = part.match(RE_STYLE_CONTENT_END))) {
424
+ if (
425
+ (next =
426
+ part.match(RE_STYLE_CONTENT_END) ||
427
+ part.match(RE_STYLE_CONTENT_END_2))
428
+ ) {
378
429
  token = TokenType.TagName
379
430
  state = State.AfterClosingTagName
380
- tokens.push(TokenType.PunctuationTag, 2, TokenType.TagName, 6)
431
+ tokens.push(
432
+ TokenType.PunctuationTag,
433
+ 2,
434
+ TokenType.TagName,
435
+ next[0].length - 1
436
+ )
381
437
  embeddedLanguageEnd = index
382
438
  index += next[0].length
383
439
  embeddedLanguage = ''
@@ -404,6 +460,12 @@ export const tokenizeLine = (line, lineState) => {
404
460
  if (state === State.AfterClosingTagAngleBrackets) {
405
461
  state = State.TopLevelContent
406
462
  }
463
+ if (state === State.InsideOpeningTag) {
464
+ state = State.InsideOpeningTagAndHasSeenWhitespace
465
+ }
466
+ if (state === State.AfterAttributeEqualSign) {
467
+ state = State.InsideOpeningTag
468
+ }
407
469
  return {
408
470
  state,
409
471
  tokens,
@@ -53,6 +53,8 @@ const RE_TRIPLE_DOUBLE_QUOTE = /^"""/
53
53
  const RE_STRING_TRIPLE_CONTENT = /^.+?(?="""|$)/s
54
54
  const RE_ATTRIBUTE = /^@\w+/
55
55
 
56
+ export const hasArrayReturn = true
57
+
56
58
  /**
57
59
  * @param {string} line
58
60
  * @param {any} lineState
@@ -122,11 +124,10 @@ export const tokenizeLine = (line, lineState) => {
122
124
  state
123
125
  throw new Error('no')
124
126
  }
125
- index += next[0].length
126
- tokens.push({
127
- type: token,
128
- length: next[0].length,
129
- })
127
+ const currentTokenText = next[0]
128
+ const currentTokenLength = currentTokenText.length
129
+ index += currentTokenLength
130
+ tokens.push(token, currentTokenLength)
130
131
  }
131
132
  return {
132
133
  state,
@@ -21,6 +21,7 @@ const State = {
21
21
  InsideDoubleQuoteString: 16,
22
22
  InsideBacktickString: 17,
23
23
  AfterPropertyDot: 18,
24
+ AfterKeywordClass: 19,
24
25
  }
25
26
 
26
27
  /**
@@ -53,6 +54,7 @@ export const TokenType = {
53
54
  KeywordThis: 886,
54
55
  KeywordOperator: 887,
55
56
  KeywordFunction: 889,
57
+ Class: 890,
56
58
  }
57
59
 
58
60
  export const TokenMap = {
@@ -82,6 +84,7 @@ export const TokenMap = {
82
84
  [TokenType.KeywordThis]: 'KeywordThis',
83
85
  [TokenType.KeywordOperator]: 'KeywordOperator',
84
86
  [TokenType.KeywordFunction]: 'KeywordFunction',
87
+ [TokenType.Class]: 'Class',
85
88
  }
86
89
 
87
90
  const RE_KEYWORD =
@@ -123,7 +126,8 @@ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\\]+/
123
126
  const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`\\\$]+/
124
127
  const RE_STRING_ESCAPE = /^\\./
125
128
  const RE_SHEBANG = /^#!.*/
126
- const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\(|\=\s*function|\=\s*\())/
129
+ const RE_FUNCTION_CALL_NAME =
130
+ /^[\w]+(?=\s*(\(|\=\s*(?:async\s*)?function|\=\s*(?:async\s*)?\())/
127
131
  const RE_DECORATOR = /^@\w+/
128
132
  const RE_BACKSLASH = /^\\/
129
133
  const RE_DOLLAR_CURLY_OPEN = /^\$\{/
@@ -224,6 +228,10 @@ export const tokenizeLine = (line, lineState) => {
224
228
  case 'of':
225
229
  token = TokenType.KeywordOperator
226
230
  break
231
+ case 'class':
232
+ token = TokenType.Keyword
233
+ state = State.AfterKeywordClass
234
+ break
227
235
  default:
228
236
  token = TokenType.Keyword
229
237
  break
@@ -416,6 +424,26 @@ export const tokenizeLine = (line, lineState) => {
416
424
  throw new Error('no')
417
425
  }
418
426
  break
427
+ case State.AfterKeywordClass:
428
+ if ((next = part.match(RE_WHITESPACE))) {
429
+ token = TokenType.Whitespace
430
+ state = State.AfterKeywordClass
431
+ } else if ((next = part.match(RE_VARIABLE_NAME))) {
432
+ token = TokenType.Class
433
+ state = State.TopLevelContent
434
+ } else if ((next = part.match(RE_LINE_COMMENT))) {
435
+ token = TokenType.Comment
436
+ state = State.TopLevelContent
437
+ } else if ((next = part.match(RE_BLOCK_COMMENT_START))) {
438
+ token = TokenType.Comment
439
+ state = State.InsideBlockComment
440
+ } else if ((next = part.match(RE_CURLY_OPEN))) {
441
+ token = TokenType.Punctuation
442
+ state = State.TopLevelContent
443
+ } else {
444
+ throw new Error('no')
445
+ }
446
+ break
419
447
  default:
420
448
  state
421
449
  throw new Error('no')
@@ -31,7 +31,8 @@
31
31
  ".code-snippets",
32
32
  ".tour",
33
33
  ".heapsnapshot",
34
- ".code-workspace"
34
+ ".code-workspace",
35
+ ".code-profile"
35
36
  ],
36
37
  "fileNames": [
37
38
  "composer.lock",
@@ -48,7 +49,8 @@
48
49
  ".gdntsa",
49
50
  ".nycrc",
50
51
  "manifest.webapp",
51
- ".alexrc"
52
+ ".alexrc",
53
+ ".yarn-integrity"
52
54
  ],
53
55
  "tokenize": "src/tokenizeJson.js"
54
56
  }
@@ -295,6 +295,9 @@ export const tokenizeLine = (line, lineState) => {
295
295
  } else if ((next = part.match(RE_COMMA))) {
296
296
  token = TokenType.Punctuation
297
297
  state = State.AfterCurlyOpen
298
+ } else if ((next = part.match(RE_LINE_COMMENT))) {
299
+ token = TokenType.Comment
300
+ state = State.AfterPropertyValue
298
301
  } else if ((next = part.match(RE_ANYTHING))) {
299
302
  token = TokenType.Text
300
303
  state = State.AfterCurlyOpen