@lvce-editor/shared-process 0.12.1 → 0.14.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.
Files changed (102) hide show
  1. package/config/defaultKeyBindings.json +30 -0
  2. package/config/defaultSettings.json +6 -0
  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 +7 -1
  6. package/extensions/builtin.language-basics-html/src/tokenizeHtml.js +77 -27
  7. package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +29 -1
  8. package/extensions/builtin.language-basics-json/extension.json +4 -2
  9. package/extensions/builtin.language-basics-json/src/tokenizeJson.js +3 -0
  10. package/extensions/builtin.language-basics-jsx/src/tokenizeJsx.js +18 -5
  11. package/extensions/builtin.language-basics-vue/src/tokenizeVue.js +1 -1
  12. package/extensions/builtin.language-basics-xml/extension.json +3 -1
  13. package/package.json +9 -10
  14. package/src/parts/Assert/Assert.js +1 -6
  15. package/src/parts/AssertionError/AssertionError.js +6 -0
  16. package/src/parts/BulkReplacement/BulkReplacement.ipc.js +7 -0
  17. package/src/parts/BulkReplacement/BulkReplacement.js +20 -0
  18. package/src/parts/BulkReplacementContent/BulkReplacementContent.js +30 -0
  19. package/src/parts/ChildProcessError/ChildProcessError.js +45 -0
  20. package/src/parts/ChromeExtension/ChromeExtension.js +2 -5
  21. package/src/parts/CleanStack/CleanStack.js +90 -2
  22. package/src/parts/CliList/CliList.js +3 -0
  23. package/src/parts/ClipBoard/ClipBoard.js +2 -2
  24. package/src/parts/ClipBoard/ClipBoardGnome.js +1 -2
  25. package/src/parts/ClipBoard/ClipBoardNoop.js +2 -2
  26. package/src/parts/ClipBoard/ClipBoardWindows.js +1 -3
  27. package/src/parts/Command/Command.js +5 -10
  28. package/src/parts/Credentials/Credentials.ipc.js +5 -5
  29. package/src/parts/Credentials/Credentials.js +2 -10
  30. package/src/parts/Desktop/Desktop.js +22 -0
  31. package/src/parts/Download/Download.js +2 -2
  32. package/src/parts/Error/Error.js +1 -1
  33. package/src/parts/ErrorCodes/ErrorCodes.js +2 -1
  34. package/src/parts/ErrorHandling/ErrorHandling.js +8 -14
  35. package/src/parts/ExtensionHost/ExtensionHost.js +1 -2
  36. package/src/parts/ExtensionHost/ExtensionHostKeyBindings.js +0 -12
  37. package/src/parts/ExtensionHostRpc/ExtensionHostRpc.js +1 -1
  38. package/src/parts/ExtensionInstallFromFile/ExtensionInstallFromFile.js +1 -1
  39. package/src/parts/ExtensionInstallFromGitHub/ExtensionInstallFromGitHub.js +1 -1
  40. package/src/parts/ExtensionInstallFromUrl/ExtensionInstallFromUrl.js +1 -1
  41. package/src/parts/ExtensionLink/ExtensionLink.js +0 -19
  42. package/src/parts/ExtensionList/ExtensionList.js +11 -2
  43. package/src/parts/ExtensionManagement/ExtensionManagement.js +6 -58
  44. package/src/parts/ExtensionManagement/ExtensionManagementColorTheme.js +3 -1
  45. package/src/parts/ExtensionManagement/ExtensionManagementIconTheme.js +1 -1
  46. package/src/parts/ExtensionManagement/ExtensionManagementLanguages.js +7 -3
  47. package/src/parts/ExtensionManifestInputType/ExtensionManifestInputType.js +2 -0
  48. package/src/parts/ExtensionManifests/ExtensionManifests.js +3 -0
  49. package/src/parts/ExtensionManifests/ExtensionManifestsFromFolder.js +5 -15
  50. package/src/parts/ExtensionManifests/ExtensionManifestsFromLinkedExtensionsFolder.js +56 -0
  51. package/src/parts/ExtensionUninstall/ExtensionUninstall.js +18 -0
  52. package/src/parts/ExtensionUnlink/ExtensionUnlink.js +1 -1
  53. package/src/parts/Extract/Extract.js +2 -6
  54. package/src/parts/ExtractZip/ExtractZip.js +1 -1
  55. package/src/parts/{Error → FileNotFoundError}/FileNotFoundError.js +9 -2
  56. package/src/parts/FileSystem/FileSystem.js +6 -32
  57. package/src/parts/FirstNodeWorkerEventType/FirstNodeWorkerEventType.js +5 -0
  58. package/src/parts/GetDirentType/GetDirentType.js +27 -0
  59. package/src/parts/GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js +39 -0
  60. package/src/parts/GetFirstNodeWorkerEvent/GetFirstNodeWorkerEvent.js +21 -0
  61. package/src/parts/GetNewLineIndex/GetNewLineIndex.js +9 -0
  62. package/src/parts/GetResponse/GetResponse.js +16 -6
  63. package/src/parts/GetTextSearchRipGrepArgs/GetTextSearchRipGrepArgs.js +14 -0
  64. package/src/parts/InstallExtension/InstallExtension.ipc.js +6 -0
  65. package/src/parts/InstallExtension/InstallExtension.js +33 -0
  66. package/src/parts/IpcParent/IpcParent.js +9 -0
  67. package/src/parts/IpcParentModule/IpcParentModule.js +12 -0
  68. package/src/parts/IpcParentType/IpcParentType.js +2 -0
  69. package/src/parts/IpcParentWithNodeForkedProcess/IpcParentWithNodeForkedProcess.js +49 -0
  70. package/src/parts/IpcParentWithNodeWorker/IpcParentWithNodeWorker.js +36 -0
  71. package/src/parts/IsEnoentErrorWindows/IsEnoentErrorWindows.js +3 -0
  72. package/src/parts/IsIgnoredError/IsIgnoredError.js +14 -0
  73. package/src/parts/Json/Json.js +3 -5
  74. package/src/parts/JsonError/JsonError.js +8 -14
  75. package/src/parts/JsonParsingError/JsonParsingError.js +17 -0
  76. package/src/parts/Jsonc/Jsonc.js +304 -0
  77. package/src/parts/JsoncCharCode/JsoncCharCode.js +23 -0
  78. package/src/parts/JsoncFile/JsoncFile.js +8 -0
  79. package/src/parts/JsoncTokenType/JsoncTokenType.js +11 -0
  80. package/src/parts/LimitString/LimitString.js +3 -1
  81. package/src/parts/MergeStacks/MergeStacks.js +3 -2
  82. package/src/parts/Module/Module.js +4 -0
  83. package/src/parts/ModuleId/ModuleId.js +2 -0
  84. package/src/parts/ModuleMap/ModuleMap.js +4 -0
  85. package/src/parts/Native/Native.js +1 -1
  86. package/src/parts/ParentIpc/ParentIpc.js +2 -1
  87. package/src/parts/Platform/Platform.js +0 -21
  88. package/src/parts/Preferences/Preferences.js +6 -8
  89. package/src/parts/PrettyError/PrettyError.js +16 -7
  90. package/src/parts/PrintPrettyError/PrintPrettyError.js +3 -1
  91. package/src/parts/RecentlyOpened/RecentlyOpened.js +3 -7
  92. package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
  93. package/src/parts/RipGrep/RipGrep.js +1 -1
  94. package/src/parts/SearchFile/SearchFile.js +4 -9
  95. package/src/parts/Socket/Socket.js +2 -7
  96. package/src/parts/Terminal/Terminal.ipc.js +4 -41
  97. package/src/parts/Terminal/Terminal.js +29 -25
  98. package/src/parts/TextSearch/TextSearch.js +102 -108
  99. package/src/parts/ToAbsolutePaths/ToAbsolutePaths.js +9 -0
  100. package/src/parts/ToTextSearchResult/ToTextSearchResult.js +42 -0
  101. package/src/parts/Trash/Trash.js +1 -2
  102. /package/src/parts/{RgPath/RgPath.js → RipGrepPath/RipGrepPath.js} +0 -0
@@ -780,5 +780,35 @@
780
780
  "key": "ctrl+j",
781
781
  "command": "Viewlet.openWidget",
782
782
  "args": ["ColorPicker"]
783
+ },
784
+ {
785
+ "key": "ArrowDown",
786
+ "command": "Search.focusNext",
787
+ "when": "focus.SearchResults"
788
+ },
789
+ {
790
+ "key": "ArrowUp",
791
+ "command": "Search.focusPrevious",
792
+ "when": "focus.SearchResults"
793
+ },
794
+ {
795
+ "key": "Delete",
796
+ "command": "Search.dismissItem",
797
+ "when": "focus.SearchResults"
798
+ },
799
+ {
800
+ "key": "Home",
801
+ "command": "Search.focusFirst",
802
+ "when": "focus.SearchResults"
803
+ },
804
+ {
805
+ "key": "End",
806
+ "command": "Search.focusLast",
807
+ "when": "focus.SearchResults"
808
+ },
809
+ {
810
+ "key": "ctrl+c",
811
+ "command": "Search.copy",
812
+ "when": "focus.SearchResults"
783
813
  }
784
814
  ]
@@ -10,6 +10,10 @@
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,
13
17
 
14
18
  "extensions.autoUpdate": true,
15
19
 
@@ -29,6 +33,8 @@
29
33
 
30
34
  "serviceWorker.enabled": false,
31
35
 
36
+ "simpleBrowser.suggestions": false,
37
+
32
38
  "window.titleBarStyle": "native",
33
39
  "window.zoomLevel": 0.5,
34
40
  "window.controlsOverlay.enabled": true,
@@ -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')
@@ -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,10 +287,15 @@ 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
270
299
  } else if ((next = part.match(RE_TAG_TEXT))) {
271
300
  token = TokenType.Text
272
301
  state = State.TopLevelContent
@@ -279,6 +308,12 @@ export const tokenizeLine = (line, lineState) => {
279
308
  if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
280
309
  token = TokenType.PunctuationTag
281
310
  state = State.TopLevelContent
311
+ const embeddedLanguageId = getEmbeddedLangageId(tag)
312
+ if (embeddedLanguageId) {
313
+ state = getEmbeddedContentState(tag)
314
+ embeddedLanguage = embeddedLanguageId
315
+ embeddedLanguageStart = index + next[0].length
316
+ }
282
317
  } else if ((next = part.match(RE_EQUAL_SIGN))) {
283
318
  token = TokenType.Punctuation
284
319
  state = State.AfterAttributeEqualSign
@@ -291,6 +326,9 @@ export const tokenizeLine = (line, lineState) => {
291
326
  } else if ((next = part.match(RE_TAG_TEXT))) {
292
327
  token = TokenType.Text
293
328
  state = State.InsideOpeningTag
329
+ } else if ((next = part.match(RE_WHITESPACE_THEN_EQUAL_SIGN))) {
330
+ token = TokenType.Whitespace
331
+ state = State.AfterAttributeName
294
332
  } else if ((next = part.match(RE_WHITESPACE))) {
295
333
  token = TokenType.Whitespace
296
334
  state = State.InsideOpeningTagAndHasSeenWhitespace
@@ -313,6 +351,9 @@ export const tokenizeLine = (line, lineState) => {
313
351
  } else if ((next = part.match(RE_ATTRIBUTE_VALUE_UNQUOTED))) {
314
352
  token = TokenType.String
315
353
  state = State.InsideOpeningTag
354
+ } else if ((next = part.match(RE_WHITESPACE))) {
355
+ token = TokenType.Whitespace
356
+ state = State.AfterAttributeEqualSign
316
357
  } else {
317
358
  part
318
359
  throw new Error('no')
@@ -374,10 +415,19 @@ export const tokenizeLine = (line, lineState) => {
374
415
  }
375
416
  break
376
417
  case State.InsideStyleContent:
377
- if ((next = part.match(RE_STYLE_CONTENT_END))) {
418
+ if (
419
+ (next =
420
+ part.match(RE_STYLE_CONTENT_END) ||
421
+ part.match(RE_STYLE_CONTENT_END_2))
422
+ ) {
378
423
  token = TokenType.TagName
379
424
  state = State.AfterClosingTagName
380
- tokens.push(TokenType.PunctuationTag, 2, TokenType.TagName, 6)
425
+ tokens.push(
426
+ TokenType.PunctuationTag,
427
+ 2,
428
+ TokenType.TagName,
429
+ next[0].length - 1
430
+ )
381
431
  embeddedLanguageEnd = index
382
432
  index += next[0].length
383
433
  embeddedLanguage = ''
@@ -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
@@ -22,6 +22,7 @@ const State = {
22
22
  InsideBacktickString: 17,
23
23
  AfterPropertyDot: 18,
24
24
  InsideTag: 19,
25
+ AfterSemicolon: 20,
25
26
  }
26
27
 
27
28
  /**
@@ -124,13 +125,13 @@ const RE_STRING_DOUBLE_QUOTE_CONTENT = /^[^"\\]+/
124
125
  const RE_STRING_BACKTICK_QUOTE_CONTENT = /^[^`\\\$]+/
125
126
  const RE_STRING_ESCAPE = /^\\./
126
127
  const RE_SHEBANG = /^#!.*/
127
- const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\(|\=\s*function|\=\s*\())/
128
+ const RE_FUNCTION_CALL_NAME = /^[\w]+(?=\s*(\`|\(|\=\s*function|\=\s*\())/
128
129
  const RE_DECORATOR = /^@\w+/
129
130
  const RE_BACKSLASH = /^\\/
130
131
  const RE_DOLLAR_CURLY_OPEN = /^\$\{/
131
132
  const RE_DOLLAR = /^\$/
132
133
  const RE_ANYTHING = /^.+/u
133
- const RE_ANGLE_BRACKET_OPEN_TAG = /^<(?![\s!<=])/
134
+ const RE_ANGLE_BRACKET_OPEN_TAG = /^<(?![\s!<=\d])/
134
135
  const RE_ANGLE_BRACKET_CLOSE_TAG = /^<\/(?![\s!])/
135
136
  const RE_TAGNAME = /^[!\w\:\.]+/
136
137
  const RE_ANGLE_BRACKET_CLOSE = /^>/
@@ -155,6 +156,8 @@ const RE_EMPTY_FRAGMENT = /^<\s*\>/
155
156
  const RE_VAR_CONST_LET_EXPORT =
156
157
  /^\s*(?=(?:if|class|export|var|const|let)(?:\s+|$))/
157
158
 
159
+ const RE_EXPRESSION = /;\w+$/
160
+
158
161
  export const initialLineState = {
159
162
  state: State.TopLevelContent,
160
163
  /**
@@ -260,8 +263,13 @@ export const tokenizeLine = (line, lineState) => {
260
263
  token = TokenType.Numeric
261
264
  state = State.TopLevelContent
262
265
  } else if ((next = part.match(RE_ANGLE_BRACKET_OPEN_TAG))) {
263
- token = TokenType.PunctuationTag
264
- state = State.AfterOpeningAngleBracket
266
+ if (RE_EXPRESSION.test(line.slice(0, index))) {
267
+ next = part.match(RE_ANGLE_BRACKET_OPEN)
268
+ token = TokenType.Punctuation
269
+ } else {
270
+ token = TokenType.PunctuationTag
271
+ state = State.AfterOpeningAngleBracket
272
+ }
265
273
  } else if ((next = part.match(RE_CURLY_CLOSE))) {
266
274
  token = TokenType.Punctuation
267
275
  state = stack.pop() || State.TopLevelContent
@@ -275,7 +283,11 @@ export const tokenizeLine = (line, lineState) => {
275
283
  state = State.AfterPropertyDot
276
284
  } else if (next[0] === '}') {
277
285
  state = stack.pop() || State.TopLevelContent
278
- } else {
286
+ }
287
+ // else if (next[0] === ';') {
288
+ // state = State.AfterSemicolon
289
+ // }
290
+ else {
279
291
  state = State.TopLevelContent
280
292
  }
281
293
  } else if ((next = part.match(RE_SLASH))) {
@@ -570,6 +582,7 @@ export const tokenizeLine = (line, lineState) => {
570
582
  state = State.InsideTag
571
583
  } else {
572
584
  part
585
+ line
573
586
  throw new Error('no')
574
587
  }
575
588
  break
@@ -58,7 +58,7 @@ const RE_ANGLE_BRACKET_ONLY = /^</
58
58
  const RE_ANGLE_BRACKET_OPEN = /^</
59
59
  const RE_ANGLE_BRACKET_OPEN_TAG = /^<(?![\s!])/
60
60
  const RE_ANY_TEXT = /^[^\n]+/
61
- const RE_ATTRIBUTE_NAME = /^[a-zA-Z\d\-\:]+/
61
+ const RE_ATTRIBUTE_NAME = /^[\@a-zA-Z\d\-\:\.]+/
62
62
  const RE_BLOCK_COMMENT_CONTENT_1 = /^.+?(?=-->)/s
63
63
  const RE_BLOCK_COMMENT_CONTENT_2 = /^.+$/s
64
64
  const RE_BLOCK_COMMENT_END = /^-->/
@@ -70,7 +70,9 @@
70
70
  ".xsd",
71
71
  ".xul",
72
72
  ".tmtheme",
73
- ".mm"
73
+ ".mm",
74
+ ".tmDragCommand",
75
+ ".tmCommand"
74
76
  ],
75
77
  "fileNames": [".project", "resources.grd"],
76
78
  "tokenize": "src/tokenizeXml.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.12.1",
3
+ "version": "0.14.0",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,25 +17,24 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.18.6",
20
- "@lvce-editor/extension-host": "0.12.1",
21
- "@lvce-editor/extension-host-helper-process": "0.12.1",
22
- "@lvce-editor/pty-host": "0.12.1",
20
+ "@lvce-editor/extension-host": "0.14.0",
21
+ "@lvce-editor/extension-host-helper-process": "0.14.0",
22
+ "@lvce-editor/pty-host": "0.14.0",
23
23
  "debug": "^4.3.4",
24
- "execa": "^6.1.0",
24
+ "execa": "^7.0.0",
25
25
  "exit-hook": "^3.2.0",
26
- "got": "^12.5.3",
26
+ "got": "^12.6.0",
27
27
  "is-object": "^1.0.2",
28
28
  "lines-and-columns": "^2.0.3",
29
- "open": "^8.4.1",
29
+ "open": "^8.4.2",
30
30
  "p-queue": "^7.3.4",
31
31
  "parse-json": "^6.0.2",
32
32
  "symlink-dir": "^5.1.1",
33
33
  "tail": "^2.2.6",
34
34
  "tar-fs": "^2.1.1",
35
35
  "tmp-promise": "^3.0.3",
36
- "trash": "^8.1.0",
37
- "verror": "^1.10.1",
38
- "ws": "^8.12.0",
36
+ "trash": "^8.1.1",
37
+ "ws": "^8.12.1",
39
38
  "xdg-basedir": "^5.1.0"
40
39
  },
41
40
  "optionalDependencies": {
@@ -1,9 +1,4 @@
1
- class AssertionError extends Error {
2
- constructor(message) {
3
- super(message)
4
- this.name = 'AssertionError'
5
- }
6
- }
1
+ import { AssertionError } from '../AssertionError/AssertionError.js'
7
2
 
8
3
  const getType = (value) => {
9
4
  switch (typeof value) {
@@ -0,0 +1,6 @@
1
+ export class AssertionError extends Error {
2
+ constructor(message) {
3
+ super(message)
4
+ this.name = 'AssertionError'
5
+ }
6
+ }
@@ -0,0 +1,7 @@
1
+ import * as BulkReplacement from './BulkReplacement.js'
2
+
3
+ export const name = 'BulkReplacement'
4
+
5
+ export const Commands = {
6
+ applyBulkReplacement: BulkReplacement.applyBulkReplacement,
7
+ }
@@ -0,0 +1,20 @@
1
+ import * as FileSystem from '../FileSystem/FileSystem.js'
2
+ import * as BulkReplacementContent from '../BulkReplacementContent/BulkReplacementContent.js'
3
+
4
+ const applyEdit = async (path, ranges, replacement) => {
5
+ const content = await FileSystem.readFile(path)
6
+ const newContent = BulkReplacementContent.getNewContent(content, ranges, replacement)
7
+ await FileSystem.writeFile(path, newContent)
8
+ }
9
+
10
+ export const applyBulkReplacement = async (files, ranges, replacement) => {
11
+ let rangeIndex = 0
12
+ for (const file of files) {
13
+ const rangeLength = ranges[rangeIndex]
14
+ const rangeStartIndex = rangeIndex + 1
15
+ const rangeEndIndex = rangeStartIndex + rangeLength
16
+ const fileRanges = ranges.slice(rangeStartIndex, rangeEndIndex)
17
+ await applyEdit(file, fileRanges, replacement)
18
+ rangeIndex = rangeEndIndex
19
+ }
20
+ }
@@ -0,0 +1,30 @@
1
+ import * as GetNewLineIndex from '../GetNewLineIndex/GetNewLineIndex.js'
2
+
3
+ export const getNewContent = (content, ranges, replacement) => {
4
+ if (ranges.length === 0) {
5
+ return content
6
+ }
7
+ let rowIndex = 0
8
+ let newLineIndex = -1
9
+ let copiedContentIndex = 0
10
+ let newContent = ''
11
+ let previousNewLineIndex = -1
12
+ for (let i = 0; i < ranges.length; i += 4) {
13
+ while (rowIndex < ranges[i]) {
14
+ previousNewLineIndex = newLineIndex
15
+ newLineIndex = GetNewLineIndex.getNewLineIndex(content, newLineIndex + 1)
16
+ rowIndex++
17
+ }
18
+ const startRowIndex = ranges[i]
19
+ const startColumnIndex = ranges[i + 1]
20
+ const endRowIndex = ranges[i + 2]
21
+ const endColumnIndex = ranges[i + 3]
22
+ if (copiedContentIndex <= newLineIndex) {
23
+ newContent += content.slice(copiedContentIndex, newLineIndex + 1)
24
+ copiedContentIndex = newLineIndex + 1
25
+ }
26
+ newContent += replacement
27
+ copiedContentIndex += endColumnIndex - startColumnIndex
28
+ }
29
+ return newContent
30
+ }
@@ -0,0 +1,45 @@
1
+ import * as SplitLines from '../SplitLines/SplitLines.js'
2
+
3
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/
4
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/
5
+
6
+ const RE_MASSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/
7
+ const RE_MASSAGE_CODE_BLOCK_END = /^\s* at/
8
+
9
+ const isUnhelpfulNativeModuleError = (stderr) => {
10
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr)
11
+ }
12
+
13
+ const isMessageCodeBlockStartIndex = (line) => {
14
+ return RE_MASSAGE_CODE_BLOCK_START.test(line)
15
+ }
16
+
17
+ const isMessageCodeBlockEndIndex = (line) => {
18
+ return RE_MASSAGE_CODE_BLOCK_END.test(line)
19
+ }
20
+
21
+ const getMessageCodeBlock = (stderr) => {
22
+ const lines = SplitLines.splitLines(stderr)
23
+ const startIndex = lines.findIndex(isMessageCodeBlockStartIndex)
24
+ const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex)
25
+ const relevantLines = lines.slice(startIndex, endIndex)
26
+ const relevantMessage = relevantLines.join(' ').slice('Error: '.length)
27
+ return relevantMessage
28
+ }
29
+
30
+ const getNativeModuleErrorMessage = (stderr) => {
31
+ const message = getMessageCodeBlock(stderr)
32
+ return `incompatible native node module: ${message}`
33
+ }
34
+
35
+ export class ChildProcessError extends Error {
36
+ constructor(stderr) {
37
+ if (isUnhelpfulNativeModuleError(stderr)) {
38
+ const message = getNativeModuleErrorMessage(stderr)
39
+ super(message)
40
+ } else {
41
+ super('child process error')
42
+ }
43
+ this.name = 'ChildProcessError'
44
+ }
45
+ }