@lvce-editor/shared-process 0.17.2 → 0.17.4

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.
@@ -147,7 +147,7 @@ const RE_REGEX =
147
147
  const RE_VARIABLE_NAME_SPECIAL = /\p{L}/u
148
148
  const RE_VARIABLE_NAME_SPECIAL_2 = /./u
149
149
  const RE_BUILTIN_CLASS =
150
- /^(?:Array|Object|Promise|ArrayBuffer|URL|URLSearchParams|WebSocket|FileSystemHandle|Function|StorageEvent|MessageEvent|MessageChannel|Int32Array|Boolean|String|Error|Set|RegExp|Map|WeakMap|RangeError|Date|Headers|Response|Request|Buffer|MessagePort|FileHandle|X509Certificate|Blob|HTMLElement|HTMLFormElement)\b/
150
+ /^(?:Array|Object|Promise|ArrayBuffer|URL|URLSearchParams|WebSocket|FileSystemHandle|Function|StorageEvent|MessageEvent|MessageChannel|Int32Array|Boolean|String|Error|Set|RegExp|Map|WeakMap|RangeError|Date|Headers|Response|Request|Buffer|MessagePort|FileHandle|X509Certificate|Blob|HTMLElement|HTMLFormElement|Symbol|WeakSet|DataView)\b/
151
151
 
152
152
  const RE_PROPERTY_NAME = /^[a-z]\w*(?=\s*\:)/
153
153
  const RE_PROPERTY_NAME_FUNCTION = /^[a-z]\w*(?=\s*\()/
@@ -499,7 +499,7 @@ export const tokenizeLine = (line, lineState) => {
499
499
  state = State.InsideBacktickString
500
500
  } else if ((next = part.match(RE_BACKSLASH))) {
501
501
  token = TokenType.String
502
- state = State.InsideDoubleQuoteString
502
+ state = State.InsideBacktickString
503
503
  } else if ((next = part.match(RE_DOLLAR))) {
504
504
  token = TokenType.String
505
505
  state = State.InsideBacktickString
@@ -6,8 +6,11 @@
6
6
  "ActivityBarActiveBackground": "#1f2727",
7
7
  "ActivityBarActiveForeground": "rgb(135, 143, 140)",
8
8
 
9
- "BadgeBackground": "#90599b",
10
- "BadgeForeground": "#eeeeee",
9
+ "BadgeBackground": "rgb(160, 63, 155)",
10
+ "BadgeForeground": "#fff",
11
+
12
+ "BadgeSecondaryBackground": "#90599b",
13
+ "BadgeSecondaryForeground": "#eeeeee",
11
14
 
12
15
  "DropDownBackground": "#3c3c3c",
13
16
  "DropDownForeground": "#f0f0f0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,9 +17,10 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.22.10",
20
- "@lvce-editor/extension-host": "0.17.2",
21
- "@lvce-editor/extension-host-helper-process": "0.17.2",
22
- "@lvce-editor/pty-host": "0.17.2",
20
+ "@lvce-editor/extension-host": "0.17.4",
21
+ "@lvce-editor/extension-host-helper-process": "0.17.4",
22
+ "@lvce-editor/pretty-error": "^1.0.0",
23
+ "@lvce-editor/pty-host": "0.17.4",
23
24
  "debug": "^4.3.4",
24
25
  "execa": "^7.2.0",
25
26
  "exit-hook": "^3.2.0",
@@ -34,11 +35,11 @@
34
35
  },
35
36
  "optionalDependencies": {
36
37
  "extract-zip": "^2.0.1",
37
- "vscode-ripgrep-with-github-api-error-fix": "^2.8.0",
38
38
  "open": "^9.1.0",
39
39
  "symlink-dir": "^5.1.1",
40
+ "tail": "^2.2.6",
40
41
  "tmp-promise": "^3.0.3",
41
42
  "trash": "^8.1.1",
42
- "tail": "^2.2.6"
43
+ "vscode-ripgrep-with-github-api-error-fix": "^2.9.0"
43
44
  }
44
45
  }
@@ -162,6 +162,7 @@ export const getModuleId = (commandId) => {
162
162
  case 'Platform.getUserKeyBindingsPath':
163
163
  case 'Platform.getVersion':
164
164
  case 'Platform.setEnvironmentVariables':
165
+ case 'Platform.getProductNameLong':
165
166
  return ModuleId.Platform
166
167
  case 'Preferences.getAll':
167
168
  return ModuleId.Preferences
@@ -25,4 +25,5 @@ export const Commands = {
25
25
  getUserSettingsPath: Platform.getUserSettingsPath,
26
26
  getVersion: Platform.getVersion,
27
27
  setEnvironmentVariables: Platform.setEnvironmentVariables,
28
+ getProductNameLong: Platform.getProductNameLong,
28
29
  }
@@ -169,11 +169,11 @@ export const getSetupName = () => {
169
169
  return 'Lvce-Setup'
170
170
  }
171
171
 
172
- export const version = '0.17.2'
172
+ export const version = '0.17.4'
173
173
 
174
- export const commit = 'e83e740'
174
+ export const commit = '7260a79'
175
175
 
176
- export const date = '2023-08-12T10:04:22.000Z'
176
+ export const date = '2023-08-15T20:41:15.000Z'
177
177
 
178
178
  export const getVersion = () => {
179
179
  return version
@@ -186,3 +186,9 @@ export const getCommit = () => {
186
186
  export const getDate = () => {
187
187
  return date
188
188
  }
189
+
190
+ export const productNameLong = 'Lvce Editor - OSS'
191
+
192
+ export const getProductNameLong = () => {
193
+ return productNameLong
194
+ }
@@ -1,107 +1,7 @@
1
1
  import { codeFrameColumns } from '@babel/code-frame'
2
2
  import { LinesAndColumns } from 'lines-and-columns'
3
- import { readFileSync } from 'node:fs'
4
- import * as CleanStack from '../CleanStack/CleanStack.js'
5
- import * as EncodingType from '../EncodingType/EncodingType.js'
6
- import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
7
- import * as GetActualPath from '../GetActualPath/GetActualPath.js'
8
- import * as JoinLines from '../JoinLines/JoinLines.js'
9
3
  import * as Json from '../Json/Json.js'
10
- import * as SplitLines from '../SplitLines/SplitLines.js'
11
- import * as Logger from '../Logger/Logger.js'
12
-
13
- const RE_MODULE_NOT_FOUND_STACK = /Cannot find package '([^']+)' imported from (.+)$/
14
-
15
- const prepareModuleNotFoundError = (error) => {
16
- const { message } = error
17
- const match = message.match(RE_MODULE_NOT_FOUND_STACK)
18
- if (!match) {
19
- return {
20
- message,
21
- stack: error.stack,
22
- codeFrame: '',
23
- }
24
- }
25
- const notFoundModule = match[1]
26
- const importedFrom = match[2]
27
- const rawLines = readFileSync(importedFrom, EncodingType.Utf8)
28
- let line = 0
29
- let column = 0
30
- const splittedLines = SplitLines.splitLines(rawLines)
31
- for (let i = 0; i < splittedLines.length; i++) {
32
- const splittedLine = splittedLines[i]
33
- const index = splittedLine.indexOf(notFoundModule)
34
- if (index !== -1) {
35
- line = i + 1
36
- column = index
37
- break
38
- }
39
- }
40
- const location = {
41
- start: {
42
- line,
43
- column,
44
- },
45
- }
46
- const codeFrame = codeFrameColumns(rawLines, location)
47
- const stackLines = SplitLines.splitLines(error.stack)
48
- const newStackLines = [stackLines[0], ` at ${importedFrom}:${line}:${column}`, ...stackLines.slice(1)]
49
- const newStack = JoinLines.joinLines(newStackLines)
50
- return {
51
- message,
52
- stack: newStack,
53
- codeFrame,
54
- }
55
- }
56
-
57
- export const prepare = (error) => {
58
- try {
59
- if (error && error.code === ErrorCodes.ERR_MODULE_NOT_FOUND) {
60
- return prepareModuleNotFoundError(error)
61
- }
62
- const { message } = error
63
- if (error && error.cause) {
64
- const cause = error.cause()
65
- if (cause) {
66
- error = cause
67
- }
68
- }
69
- const lines = CleanStack.cleanStack(error.stack)
70
- const file = lines[0]
71
- let codeFrame = ''
72
- if (error.codeFrame) {
73
- codeFrame = error.codeFrame
74
- } else if (file) {
75
- let match = file.match(/\((.*):(\d+):(\d+)\)$/)
76
- if (!match) {
77
- match = file.match(/at (.*):(\d+):(\d+)$/)
78
- }
79
- if (match) {
80
- const [_, path, line, column] = match
81
- const actualPath = GetActualPath.getActualPath(path)
82
- const rawLines = readFileSync(actualPath, EncodingType.Utf8)
83
- const location = {
84
- start: {
85
- line: Number.parseInt(line),
86
- column: Number.parseInt(column),
87
- },
88
- }
89
- codeFrame = codeFrameColumns(rawLines, location)
90
- }
91
- }
92
- const relevantStack = JoinLines.joinLines(lines)
93
- return {
94
- message,
95
- stack: relevantStack,
96
- codeFrame,
97
- type: error.constructor.name,
98
- code: error.code,
99
- }
100
- } catch (otherError) {
101
- Logger.warn(`ErrorHandling Error: ${otherError}`)
102
- return error
103
- }
104
- }
4
+ export { prepare } from '@lvce-editor/pretty-error'
105
5
 
106
6
  const fixBackslashes = (string) => {
107
7
  return string.replaceAll('\\\\', '\\')
@@ -1,97 +0,0 @@
1
- import * as SplitLines from '../SplitLines/SplitLines.js'
2
-
3
- const RE_AT = /^\s+at/
4
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/
5
- const RE_OBJECT_AS = /^\s*at (async )?Object\.\w+ \[as ([\w\.]+)\]/
6
- const RE_GET_RESPONSE = /^\s*at async getResponse/
7
- const RE_WEBSOCKET_HANDLE_MESSAGE = /^\s*at async WebSocket.handleMessage/
8
- const RE_EXECUTE_COMMAND_ASYNC = /^\s*at executeCommandAsync/
9
- const RE_HANDLE_OTHER_MESSAGES_FROM_MESSAGE_PORT = /^\s*at async MessagePort\.handleOtherMessagesFromMessagePort/
10
- const RE_ASSERT = /^\s*at .*\/Assert\.js/
11
-
12
- const isInternalLine = (line) => {
13
- return line.includes('node:') || RE_AT_PROMISE_INDEX.test(line) || line.includes('node_modules/ws')
14
- }
15
-
16
- const isRelevantLine = (line) => {
17
- return !isInternalLine(line)
18
- }
19
-
20
- const isApplicationUsefulLine = (line, index) => {
21
- if (index === 0) {
22
- if (RE_ASSERT.test(line)) {
23
- return false
24
- }
25
- return true
26
- }
27
- if (RE_GET_RESPONSE.test(line)) {
28
- return false
29
- }
30
- if (RE_WEBSOCKET_HANDLE_MESSAGE.test(line)) {
31
- return false
32
- }
33
- if (RE_EXECUTE_COMMAND_ASYNC.test(line)) {
34
- return false
35
- }
36
- if (RE_HANDLE_OTHER_MESSAGES_FROM_MESSAGE_PORT.test(line)) {
37
- return false
38
- }
39
- return true
40
- }
41
-
42
- const isNormalStackLine = (line) => {
43
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line)
44
- }
45
-
46
- const cleanLine = (line) => {
47
- if (line.startsWith(' at exports.')) {
48
- return ' at ' + line.slice(' at exports.'.length)
49
- }
50
- if (line.startsWith(' at async exports.')) {
51
- return ' at async ' + line.slice(' at async exports.'.length)
52
- }
53
- if (line.startsWith(' at async Module.')) {
54
- return ' at async ' + line.slice(' at async Module.'.length)
55
- }
56
- if (line.startsWith(' at Module.')) {
57
- return ' at ' + line.slice(' at Module.'.length)
58
- }
59
- const objectMatch = line.match(RE_OBJECT_AS)
60
- if (objectMatch) {
61
- const rest = line.slice(objectMatch[0].length)
62
- if (objectMatch[1]) {
63
- return ' at ' + objectMatch[1] + objectMatch[2] + rest
64
- }
65
- return ' at ' + objectMatch[2] + rest
66
- }
67
- return line
68
- }
69
-
70
- const getDetails = (lines) => {
71
- const index = lines.findIndex(isNormalStackLine)
72
- return {
73
- custom: lines.slice(0, index),
74
- actualStack: lines.slice(index).map(cleanLine),
75
- }
76
- }
77
-
78
- const RE_PATH_1 = /^\/(.*)(\d+)$/
79
-
80
- const mergeCustom = (custom, relevantStack) => {
81
- if (custom.length === 0) {
82
- return relevantStack
83
- }
84
- const firstLine = custom[0]
85
- if (RE_PATH_1.test(firstLine)) {
86
- return [` at ${firstLine}`, ...relevantStack]
87
- }
88
- return relevantStack
89
- }
90
-
91
- export const cleanStack = (stack) => {
92
- const lines = SplitLines.splitLines(stack)
93
- const { custom, actualStack } = getDetails(lines)
94
- const relevantStack = actualStack.filter(isRelevantLine).filter(isApplicationUsefulLine)
95
- const merged = mergeCustom(custom, relevantStack)
96
- return merged
97
- }