@lvce-editor/shared-process 0.15.18 → 0.15.20
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.
- package/extensions/builtin.language-basics-dart/src/tokenizeDart.js +2 -1
- package/extensions/builtin.language-basics-html/src/tokenizeHtml.js +77 -3
- package/extensions/builtin.language-basics-javascript/src/tokenizeJavaScript.js +3 -0
- package/index.js +2 -2
- package/package.json +9 -9
- package/src/parts/Character/Character.js +11 -0
- package/src/parts/Configuration/Configuration.js +4 -7
- package/src/parts/ErrorHandling/ErrorHandling.js +2 -1
- package/src/parts/ExportStatic/ExportStatic.js +18 -20
- package/src/parts/FileSystem/FileSystem.js +12 -0
- package/src/parts/GetNewLineIndex/GetNewLineIndex.js +3 -1
- package/src/parts/GetTerminalSpawnOptions/GetTerminalSpawnOptions.ipc.js +7 -0
- package/src/parts/GetTerminalSpawnOptions/GetTerminalSpawnOptions.js +14 -0
- package/src/parts/JoinLines/JoinLines.js +3 -1
- package/src/parts/Json/Json.js +2 -1
- package/src/parts/JsonError/JsonError.js +3 -1
- package/src/parts/Module/Module.js +2 -0
- package/src/parts/ModuleId/ModuleId.js +1 -0
- package/src/parts/ModuleMap/ModuleMap.js +2 -0
- package/src/parts/PrettyError/PrettyError.js +42 -36
- package/src/parts/SplitLines/SplitLines.js +3 -1
- package/src/parts/Terminal/Terminal.js +2 -2
- package/src/parts/Trash/Trash.js +1 -1
- package/src/sharedProcessMain.js +0 -11
|
@@ -43,9 +43,10 @@ export const hasArrayReturn = true
|
|
|
43
43
|
|
|
44
44
|
const RE_KEYWORD =
|
|
45
45
|
/^(?:abstract|as|assert|async|await|break|case|catch|class|const|continue|covariant|default|deferred|do|dynamic|else|enum|export|extends|extension|external|factory|false|final|finally|for|Function|get|hide|if|implements|import|in|interface|is|late|library|mixin|new|null|on|operator|part|required|rethrow|return|set|show|static|super|switch|sync|this|throw|true|try|typedef|var|void|while|with|yield)\b/
|
|
46
|
+
|
|
46
47
|
const RE_WHITESPACE = /^\s+/
|
|
47
48
|
const RE_VARIABLE_NAME = /^[a-zA-Z]+/
|
|
48
|
-
const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)
|
|
49
|
+
const RE_PUNCTUATION = /^[:,;\{\}\[\]\.=\(\)>+<]/
|
|
49
50
|
const RE_QUOTE_SINGLE = /^'/
|
|
50
51
|
const RE_QUOTE_DOUBLE = /^"/
|
|
51
52
|
const RE_STRING_SINGLE_QUOTE_CONTENT = /^[^']+/
|
|
@@ -89,6 +89,7 @@ const RE_SCRIPT_CONTENT_END = /^<\/script/
|
|
|
89
89
|
const RE_STYLE_CONTENT = /^..*?(?=(?:<\/(?:style|head))|$)/s
|
|
90
90
|
const RE_STYLE_CONTENT_END = /^<\/style/
|
|
91
91
|
const RE_STYLE_CONTENT_END_2 = /^<\/head/
|
|
92
|
+
const RE_TYPE = /^[^\s\>]+/
|
|
92
93
|
|
|
93
94
|
export const initialLineState = {
|
|
94
95
|
state: State.TopLevelContent,
|
|
@@ -98,6 +99,8 @@ export const initialLineState = {
|
|
|
98
99
|
embeddedLanguageStart: 0,
|
|
99
100
|
embeddedLanguageEnd: 0,
|
|
100
101
|
embeddedState: undefined,
|
|
102
|
+
specialTag: false,
|
|
103
|
+
type: '',
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
/**
|
|
@@ -150,6 +153,54 @@ const getEmbeddedContentState = (tag) => {
|
|
|
150
153
|
}
|
|
151
154
|
}
|
|
152
155
|
|
|
156
|
+
/**
|
|
157
|
+
* @param {string} value
|
|
158
|
+
*/
|
|
159
|
+
const unquote = (value) => {
|
|
160
|
+
for (const quote of ["'", '"']) {
|
|
161
|
+
if (value.startsWith(quote) && value.endsWith(quote)) {
|
|
162
|
+
return value.slice(1, -1)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return value
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
*
|
|
170
|
+
* @param {string} value
|
|
171
|
+
*/
|
|
172
|
+
const getType = (value) => {
|
|
173
|
+
const unquotedValue = unquote(value)
|
|
174
|
+
switch (unquotedValue) {
|
|
175
|
+
case 'text/javascript':
|
|
176
|
+
case 'text/x-javascript':
|
|
177
|
+
case 'text/jscript':
|
|
178
|
+
case 'text/livescript':
|
|
179
|
+
case 'text/babel':
|
|
180
|
+
case 'text/ecmascript':
|
|
181
|
+
case 'text/x-ecmascript':
|
|
182
|
+
case 'application/x-javascript':
|
|
183
|
+
case 'application/javascript':
|
|
184
|
+
case 'application/x-ecmascript':
|
|
185
|
+
case 'application/ecmascript':
|
|
186
|
+
case 'module':
|
|
187
|
+
return 'javascript'
|
|
188
|
+
case 'text/x-handlebars':
|
|
189
|
+
case 'text/x-handlebars-template':
|
|
190
|
+
case 'text/handlebars-template':
|
|
191
|
+
case 'text/template':
|
|
192
|
+
case 'text/x-template':
|
|
193
|
+
case 'text/ng-template':
|
|
194
|
+
case 'text/x-ng-template':
|
|
195
|
+
return 'html'
|
|
196
|
+
case 'application/json':
|
|
197
|
+
case 'application/ld+json':
|
|
198
|
+
return 'json'
|
|
199
|
+
default:
|
|
200
|
+
return ''
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
153
204
|
/**
|
|
154
205
|
*
|
|
155
206
|
* @param {string} line
|
|
@@ -166,6 +217,9 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
166
217
|
let embeddedLanguage = lineState.embeddedLanguage
|
|
167
218
|
let embeddedLanguageStart = lineState.embeddedLanguageStart
|
|
168
219
|
let embeddedLanguageEnd = lineState.embeddedLanguageEnd
|
|
220
|
+
let specialTag = lineState.specialTag
|
|
221
|
+
let attributeName = ''
|
|
222
|
+
let type = ''
|
|
169
223
|
while (index < line.length) {
|
|
170
224
|
const part = line.slice(index)
|
|
171
225
|
switch (state) {
|
|
@@ -198,6 +252,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
198
252
|
token = TokenType.TagName
|
|
199
253
|
state = State.InsideOpeningTag
|
|
200
254
|
tag = next[0]
|
|
255
|
+
specialTag = tag === 'script' || tag === 'style'
|
|
201
256
|
} else if ((next = part.match(RE_SLASH))) {
|
|
202
257
|
token = TokenType.PunctuationTag
|
|
203
258
|
state = State.AfterClosingTagAngleBrackets
|
|
@@ -219,12 +274,15 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
219
274
|
if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
|
|
220
275
|
token = TokenType.PunctuationTag
|
|
221
276
|
state = State.TopLevelContent
|
|
222
|
-
const embeddedLanguageId = getEmbeddedLangageId(tag)
|
|
277
|
+
const embeddedLanguageId = type || getEmbeddedLangageId(tag)
|
|
223
278
|
if (embeddedLanguageId) {
|
|
224
279
|
state = getEmbeddedContentState(tag)
|
|
225
280
|
embeddedLanguage = embeddedLanguageId
|
|
226
281
|
embeddedLanguageStart = index + next[0].length
|
|
227
282
|
}
|
|
283
|
+
specialTag = false
|
|
284
|
+
type = ''
|
|
285
|
+
attributeName = ''
|
|
228
286
|
} else if ((next = part.match(RE_EXCLAMATION_MARK))) {
|
|
229
287
|
token = TokenType.PunctuationTag
|
|
230
288
|
state = State.InsideOpeningTag
|
|
@@ -281,18 +339,22 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
281
339
|
if ((next = part.match(RE_ATTRIBUTE_NAME))) {
|
|
282
340
|
token = TokenType.AttributeName
|
|
283
341
|
state = State.AfterAttributeName
|
|
342
|
+
attributeName = next[0]
|
|
284
343
|
} else if ((next = part.match(RE_SELF_CLOSING))) {
|
|
285
344
|
token = TokenType.PunctuationTag
|
|
286
345
|
state = State.TopLevelContent
|
|
287
346
|
} else if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
|
|
288
347
|
token = TokenType.PunctuationTag
|
|
289
348
|
state = State.TopLevelContent
|
|
290
|
-
const embeddedLanguageId = getEmbeddedLangageId(tag)
|
|
349
|
+
const embeddedLanguageId = type || getEmbeddedLangageId(tag)
|
|
291
350
|
if (embeddedLanguageId) {
|
|
292
351
|
state = getEmbeddedContentState(tag)
|
|
293
352
|
embeddedLanguage = embeddedLanguageId
|
|
294
353
|
embeddedLanguageStart = index + next[0].length
|
|
295
354
|
}
|
|
355
|
+
specialTag = false
|
|
356
|
+
type = ''
|
|
357
|
+
attributeName = ''
|
|
296
358
|
} else if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
297
359
|
token = TokenType.Punctuation
|
|
298
360
|
state = State.InsideDoubleQuoteString
|
|
@@ -314,12 +376,15 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
314
376
|
if ((next = part.match(RE_ANGLE_BRACKET_CLOSE))) {
|
|
315
377
|
token = TokenType.PunctuationTag
|
|
316
378
|
state = State.TopLevelContent
|
|
317
|
-
const embeddedLanguageId = getEmbeddedLangageId(tag)
|
|
379
|
+
const embeddedLanguageId = type || getEmbeddedLangageId(tag)
|
|
318
380
|
if (embeddedLanguageId) {
|
|
319
381
|
state = getEmbeddedContentState(tag)
|
|
320
382
|
embeddedLanguage = embeddedLanguageId
|
|
321
383
|
embeddedLanguageStart = index + next[0].length
|
|
322
384
|
}
|
|
385
|
+
specialTag = false
|
|
386
|
+
type = ''
|
|
387
|
+
attributeName = ''
|
|
323
388
|
} else if ((next = part.match(RE_EQUAL_SIGN))) {
|
|
324
389
|
token = TokenType.Punctuation
|
|
325
390
|
state = State.AfterAttributeEqualSign
|
|
@@ -345,6 +410,13 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
345
410
|
}
|
|
346
411
|
break
|
|
347
412
|
case State.AfterAttributeEqualSign:
|
|
413
|
+
if (specialTag && attributeName === 'type') {
|
|
414
|
+
const valueMatch = part.match(RE_TYPE)
|
|
415
|
+
if (valueMatch) {
|
|
416
|
+
const value = valueMatch[0]
|
|
417
|
+
type = getType(value)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
348
420
|
if ((next = part.match(RE_DOUBLE_QUOTE))) {
|
|
349
421
|
token = TokenType.PunctuationString
|
|
350
422
|
state = State.InsideDoubleQuoteString
|
|
@@ -473,5 +545,7 @@ export const tokenizeLine = (line, lineState) => {
|
|
|
473
545
|
embeddedLanguage,
|
|
474
546
|
embeddedLanguageStart,
|
|
475
547
|
embeddedLanguageEnd,
|
|
548
|
+
specialTag,
|
|
549
|
+
type,
|
|
476
550
|
}
|
|
477
551
|
}
|
|
@@ -89,6 +89,7 @@ export const TokenMap = {
|
|
|
89
89
|
|
|
90
90
|
const RE_KEYWORD =
|
|
91
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/
|
|
92
|
+
|
|
92
93
|
const RE_CURLY_OPEN = /^\{/
|
|
93
94
|
const RE_CURLY_CLOSE = /^\}/
|
|
94
95
|
const RE_SQUARE_OPEN = /^\[/
|
|
@@ -97,6 +98,7 @@ const RE_COMMA = /^,/
|
|
|
97
98
|
const RE_COLON = /^:/
|
|
98
99
|
const RE_NUMERIC =
|
|
99
100
|
/^((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b/
|
|
101
|
+
|
|
100
102
|
const RE_NUMERIC_OCTAL = /0(?:o|O)?[0-7][0-7_]*(n)?\b/
|
|
101
103
|
const RE_LINE_COMMENT_START = /^\/\//
|
|
102
104
|
const RE_LINE_COMMENT_CONTENT = /^[^\n]+/
|
|
@@ -128,6 +130,7 @@ const RE_STRING_ESCAPE = /^\\./
|
|
|
128
130
|
const RE_SHEBANG = /^#!.*/
|
|
129
131
|
const RE_FUNCTION_CALL_NAME =
|
|
130
132
|
/^[\w]+(?=\s*(\(|\=\s*(?:async\s*)?function|\=\s*(?:async\s*)?\())/
|
|
133
|
+
|
|
131
134
|
const RE_DECORATOR = /^@\w+/
|
|
132
135
|
const RE_BACKSLASH = /^\\/
|
|
133
136
|
const RE_DOLLAR_CURLY_OPEN = /^\$\{/
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dirname, join } from 'node:path'
|
|
1
|
+
import { dirname, isAbsolute, join } from 'node:path'
|
|
2
2
|
import { fileURLToPath } from 'node:url'
|
|
3
3
|
|
|
4
4
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
@@ -10,7 +10,7 @@ export const exportStatic = async ({ extensionPath = process.cwd(), testPath = '
|
|
|
10
10
|
throw new Error(`root argument is required`)
|
|
11
11
|
}
|
|
12
12
|
const fn = await import('./src/parts/ExportStatic/ExportStatic.js')
|
|
13
|
-
if (extensionPath !== root) {
|
|
13
|
+
if (extensionPath !== root && !isAbsolute(extensionPath)) {
|
|
14
14
|
extensionPath = join(root, extensionPath)
|
|
15
15
|
}
|
|
16
16
|
const pathPrefix = process.env.PATH_PREFIX || ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.20",
|
|
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.21.4",
|
|
20
|
-
"@lvce-editor/extension-host": "0.15.
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.15.
|
|
22
|
-
"@lvce-editor/pty-host": "0.15.
|
|
20
|
+
"@lvce-editor/extension-host": "0.15.20",
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.15.20",
|
|
22
|
+
"@lvce-editor/pty-host": "0.15.20",
|
|
23
23
|
"debug": "^4.3.4",
|
|
24
24
|
"execa": "^7.1.1",
|
|
25
25
|
"exit-hook": "^3.2.0",
|
|
@@ -28,11 +28,7 @@
|
|
|
28
28
|
"lines-and-columns": "^2.0.3",
|
|
29
29
|
"p-queue": "^7.3.4",
|
|
30
30
|
"parse-json": "^7.0.0",
|
|
31
|
-
"symlink-dir": "^5.1.1",
|
|
32
|
-
"tail": "^2.2.6",
|
|
33
31
|
"tar-fs": "^2.1.1",
|
|
34
|
-
"tmp-promise": "^3.0.3",
|
|
35
|
-
"trash": "^8.1.1",
|
|
36
32
|
"ws": "^8.13.0",
|
|
37
33
|
"xdg-basedir": "^5.1.0"
|
|
38
34
|
},
|
|
@@ -40,6 +36,10 @@
|
|
|
40
36
|
"extract-zip": "^2.0.1",
|
|
41
37
|
"keytar": "^7.9.0",
|
|
42
38
|
"vscode-ripgrep-with-github-api-error-fix": "^2.8.0",
|
|
43
|
-
"open": "^9.1.0"
|
|
39
|
+
"open": "^9.1.0",
|
|
40
|
+
"symlink-dir": "^5.1.1",
|
|
41
|
+
"tmp-promise": "^3.0.3",
|
|
42
|
+
"trash": "^8.1.1",
|
|
43
|
+
"tail": "^2.2.6"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const Backslash = '\\'
|
|
2
|
+
export const Dash = '-'
|
|
3
|
+
export const Dot = '.'
|
|
4
|
+
export const EmptyString = ''
|
|
5
|
+
export const NewLine = '\n'
|
|
6
|
+
export const OpenAngleBracket = '<'
|
|
7
|
+
export const Slash = '/'
|
|
8
|
+
export const Space = ' '
|
|
9
|
+
export const Tab = '\t'
|
|
10
|
+
export const Underline = '_'
|
|
11
|
+
export const T = 't'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as Character from '../Character/Character.js'
|
|
2
2
|
import { writeFile } from '../FileSystem/FileSystem.js'
|
|
3
|
-
import * as
|
|
3
|
+
import * as JsonFile from '../JsonFile/JsonFile.js'
|
|
4
4
|
|
|
5
5
|
let settings
|
|
6
6
|
let settingsPromise
|
|
@@ -9,7 +9,7 @@ const readSettings = async () => {
|
|
|
9
9
|
// TODO allow jsonc
|
|
10
10
|
if (!settings) {
|
|
11
11
|
if (!settingsPromise) {
|
|
12
|
-
settingsPromise =
|
|
12
|
+
settingsPromise = JsonFile.readJson('/tmp/settings.json')
|
|
13
13
|
}
|
|
14
14
|
await settingsPromise
|
|
15
15
|
}
|
|
@@ -18,10 +18,7 @@ const readSettings = async () => {
|
|
|
18
18
|
|
|
19
19
|
const writeSettings = async () => {
|
|
20
20
|
// TODO jsonc
|
|
21
|
-
await writeFile(
|
|
22
|
-
'/tmp/settings.json',
|
|
23
|
-
JSON.stringify(settings, null, 2) + '\n'
|
|
24
|
-
)
|
|
21
|
+
await writeFile('/tmp/settings.json', JSON.stringify(settings, null, 2) + Character.NewLine)
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
export const get = async (key) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Character from '../Character/Character.js'
|
|
1
2
|
import * as ExitCode from '../ExitCode/ExitCode.js'
|
|
2
3
|
import * as GetNewLineIndex from '../GetNewLineIndex/GetNewLineIndex.js'
|
|
3
4
|
import * as IsIgnoredError from '../IsIgnoredError/IsIgnoredError.js'
|
|
@@ -62,6 +63,6 @@ export const handleUncaughtExceptionMonitor = (error, origin) => {
|
|
|
62
63
|
return
|
|
63
64
|
}
|
|
64
65
|
const prettyError = PrettyError.prepare(error)
|
|
65
|
-
Logger.error(prettyError.codeFrame +
|
|
66
|
+
Logger.error(prettyError.codeFrame + Character.NewLine + prettyError.stack + Character.NewLine)
|
|
66
67
|
Process.setExitCode(ExitCode.Error)
|
|
67
68
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { isAbsolute, join } from 'path'
|
|
1
2
|
import * as FileSystem from '../FileSystem/FileSystem.js'
|
|
2
3
|
import * as JsonFile from '../JsonFile/JsonFile.js'
|
|
3
4
|
import * as Path from '../Path/Path.js'
|
|
5
|
+
import { existsSync } from 'fs'
|
|
4
6
|
|
|
5
7
|
// TODO
|
|
6
8
|
// - implement this for syntax highlighting projects
|
|
@@ -80,7 +82,7 @@ const isCommitHash = (dirent) => {
|
|
|
80
82
|
* @param {string} root
|
|
81
83
|
*/
|
|
82
84
|
const clean = async (root) => {
|
|
83
|
-
await FileSystem.
|
|
85
|
+
await FileSystem.forceRemove(Path.join(root, 'dist'))
|
|
84
86
|
await FileSystem.mkdir(Path.join(root, 'dist'))
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -119,13 +121,8 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
|
|
|
119
121
|
)
|
|
120
122
|
await replace(
|
|
121
123
|
Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
|
|
122
|
-
`
|
|
123
|
-
|
|
124
|
-
};`,
|
|
125
|
-
`const getColorThemeUrlWeb = (colorThemeId) => {
|
|
126
|
-
const assetDir = getAssetDir()
|
|
127
|
-
return \`\${assetDir}/themes/\${colorThemeId}.json\`
|
|
128
|
-
}`
|
|
124
|
+
`return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``,
|
|
125
|
+
`return \`\${assetDir}/themes/\${colorThemeId}.json\``
|
|
129
126
|
)
|
|
130
127
|
await replace(
|
|
131
128
|
Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'),
|
|
@@ -134,13 +131,8 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
|
|
|
134
131
|
)
|
|
135
132
|
await replace(
|
|
136
133
|
Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
|
|
137
|
-
`
|
|
138
|
-
|
|
139
|
-
}`,
|
|
140
|
-
`getIconThemeUrl = (iconThemeId) => {
|
|
141
|
-
const assetDir = getAssetDir()
|
|
142
|
-
return \`\${assetDir}/icon-themes/\${iconThemeId}.json\`
|
|
143
|
-
}`
|
|
134
|
+
`return \`\${assetDir}/extensions/builtin.\${iconThemeId}/icon-theme.json\``,
|
|
135
|
+
`return \`\${assetDir}/icon-themes/\${iconThemeId}.json\``
|
|
144
136
|
)
|
|
145
137
|
await replace(
|
|
146
138
|
Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'),
|
|
@@ -318,7 +310,7 @@ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commi
|
|
|
318
310
|
return
|
|
319
311
|
}
|
|
320
312
|
const extensionId = extensionJson.id
|
|
321
|
-
await FileSystem.
|
|
313
|
+
await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
|
|
322
314
|
await FileSystem.mkdir(Path.join(root, 'dist', commitHash, 'extensions', extensionId))
|
|
323
315
|
await FileSystem.copyFile(Path.join(root, 'README.md'), Path.join(root, 'dist', commitHash, 'extensions', extensionId, 'README.md'))
|
|
324
316
|
for (const file of ['src', 'data', 'extension.json']) {
|
|
@@ -340,7 +332,7 @@ const addExtensionLanguages = async ({ root, extensionPath, extensionJson, commi
|
|
|
340
332
|
const mergedLanguages = mergeLanguages(builtinLanguages, extensionLanguages)
|
|
341
333
|
await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'languages.json'), mergedLanguages)
|
|
342
334
|
if (await FileSystem.exists(Path.join(extensionPath, 'test', 'cases'))) {
|
|
343
|
-
await FileSystem.
|
|
335
|
+
await FileSystem.forceRemove(Path.join(root, 'dist', commitHash, 'playground'))
|
|
344
336
|
await FileSystem.copy(Path.join(extensionPath, 'test', 'cases'), Path.join(root, 'dist', commitHash, 'playground'))
|
|
345
337
|
const testFiles = await FileSystem.readDir(Path.join(extensionPath, 'test', 'cases'))
|
|
346
338
|
const fileMap = testFiles.map(toPlaygroundFile)
|
|
@@ -436,12 +428,12 @@ const getTestFiles = (testFilesRaw) => {
|
|
|
436
428
|
}
|
|
437
429
|
|
|
438
430
|
const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
|
|
439
|
-
|
|
440
|
-
|
|
431
|
+
const testRoot = isAbsolute(testPath) ? testPath : join(root, testPath)
|
|
432
|
+
await FileSystem.copy(`${testRoot}/src`, `${root}/dist/${commitHash}/packages/extension-host-worker-tests/src`)
|
|
433
|
+
const testFilesRaw = await FileSystem.readDir(`${testRoot}/src`)
|
|
441
434
|
const testFiles = getTestFiles(testFilesRaw)
|
|
442
435
|
await FileSystem.mkdir(`${root}/dist/${commitHash}/tests`)
|
|
443
436
|
await FileSystem.mkdir(`${root}/dist/tests`)
|
|
444
|
-
console.log({ testFiles })
|
|
445
437
|
for (const testFile of testFiles) {
|
|
446
438
|
await FileSystem.copyFile(`${root}/dist/index.html`, `${root}/dist/tests/${testFile}.html`)
|
|
447
439
|
}
|
|
@@ -454,6 +446,12 @@ const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
|
|
|
454
446
|
* @param {{root:string, pathPrefix:string , extensionPath:string, testPath:string }} param0
|
|
455
447
|
*/
|
|
456
448
|
export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath }) => {
|
|
449
|
+
if (!existsSync(root)) {
|
|
450
|
+
throw new Error(`root path does not exist: ${root}`)
|
|
451
|
+
}
|
|
452
|
+
if (!existsSync(extensionPath)) {
|
|
453
|
+
throw new Error(`extension path does not exist: ${extensionPath}`)
|
|
454
|
+
}
|
|
457
455
|
if (pathPrefix === 'auto') {
|
|
458
456
|
const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'))
|
|
459
457
|
const { id } = extensionJson
|
|
@@ -123,6 +123,18 @@ export const remove = async (path) => {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
export const forceRemove = async (path) => {
|
|
127
|
+
if (!isOkayToRemove(path)) {
|
|
128
|
+
console.warn('not removing path')
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
await fs.rm(path, { force: true, recursive: true })
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw new VError(error, `Failed to remove "${path}"`)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
126
138
|
export const exists = async (path) => {
|
|
127
139
|
try {
|
|
128
140
|
await fs.access(path)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as Character from '../Character/Character.js'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
*
|
|
3
5
|
* @param {string} string
|
|
@@ -5,5 +7,5 @@
|
|
|
5
7
|
* @returns
|
|
6
8
|
*/
|
|
7
9
|
export const getNewLineIndex = (string, startIndex = undefined) => {
|
|
8
|
-
return string.indexOf(
|
|
10
|
+
return string.indexOf(Character.NewLine, startIndex)
|
|
9
11
|
}
|
package/src/parts/Json/Json.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// parsing error handling based on https://github.com/sindresorhus/parse-json/blob/main/index.js
|
|
2
2
|
|
|
3
3
|
import { JsonParsingError } from '../JsonParsingError/JsonParsingError.js'
|
|
4
|
+
import * as Character from '../Character/Character.js'
|
|
4
5
|
|
|
5
6
|
export const parse = async (string, filePath) => {
|
|
6
7
|
try {
|
|
@@ -13,5 +14,5 @@ export const parse = async (string, filePath) => {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const stringify = (value) => {
|
|
16
|
-
return JSON.stringify(value, null, 2) +
|
|
17
|
+
return JSON.stringify(value, null, 2) + Character.NewLine
|
|
17
18
|
}
|
|
@@ -9,8 +9,10 @@ const emptyError = {
|
|
|
9
9
|
codeFrame: '',
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
const RE_POSITION = /in JSON at position (\d+)/
|
|
13
|
+
|
|
12
14
|
export const getErrorPropsFromError = (error, string, filePath) => {
|
|
13
|
-
const indexMatch = error.message.match(
|
|
15
|
+
const indexMatch = error.message.match(RE_POSITION)
|
|
14
16
|
if (indexMatch && indexMatch.length > 0) {
|
|
15
17
|
const lines = new LinesAndColumns(string)
|
|
16
18
|
const index = Number(indexMatch[1])
|
|
@@ -66,6 +66,8 @@ export const load = (moduleId) => {
|
|
|
66
66
|
return import('../HandleElectronMessagePort/HandleElectronMessagePort.ipc.js')
|
|
67
67
|
case ModuleId.HandleNodeMessagePort:
|
|
68
68
|
return import('../HandleNodeMessagePort/HandleNodeMessagePort.ipc.js')
|
|
69
|
+
case ModuleId.GetTerminalSpawnOptions:
|
|
70
|
+
return import('../GetTerminalSpawnOptions/GetTerminalSpawnOptions.ipc.js')
|
|
69
71
|
default:
|
|
70
72
|
throw new Error(`module ${moduleId} not found`)
|
|
71
73
|
}
|
|
@@ -173,6 +173,8 @@ export const getModuleId = (commandId) => {
|
|
|
173
173
|
return ModuleId.HandleNodeMessagePort
|
|
174
174
|
case 'HandleElectronMessagePort.handleElectronMessagePort':
|
|
175
175
|
return ModuleId.HandleElectronMessagePort
|
|
176
|
+
case 'GetTerminalSpawnOptions.getTerminalSpawnOptions':
|
|
177
|
+
return ModuleId.GetTerminalSpawnOptions
|
|
176
178
|
default:
|
|
177
179
|
throw new CommandNotFoundError(commandId)
|
|
178
180
|
}
|
|
@@ -8,6 +8,7 @@ import * as GetActualPath from '../GetActualPath/GetActualPath.js'
|
|
|
8
8
|
import * as JoinLines from '../JoinLines/JoinLines.js'
|
|
9
9
|
import * as Json from '../Json/Json.js'
|
|
10
10
|
import * as SplitLines from '../SplitLines/SplitLines.js'
|
|
11
|
+
import * as Logger from '../Logger/Logger.js'
|
|
11
12
|
|
|
12
13
|
const RE_MODULE_NOT_FOUND_STACK = /Cannot find package '([^']+)' imported from (.+)$/
|
|
13
14
|
|
|
@@ -54,46 +55,51 @@ const prepareModuleNotFoundError = (error) => {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export const prepare = (error) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const { message } = error
|
|
61
|
-
if (error && error.cause) {
|
|
62
|
-
const cause = error.cause()
|
|
63
|
-
if (cause) {
|
|
64
|
-
error = cause
|
|
58
|
+
try {
|
|
59
|
+
if (error && error.code === ErrorCodes.ERR_MODULE_NOT_FOUND) {
|
|
60
|
+
return prepareModuleNotFoundError(error)
|
|
65
61
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} else if (file) {
|
|
73
|
-
let match = file.match(/\((.*):(\d+):(\d+)\)$/)
|
|
74
|
-
if (!match) {
|
|
75
|
-
match = file.match(/at (.*):(\d+):(\d+)$/)
|
|
62
|
+
const { message } = error
|
|
63
|
+
if (error && error.cause) {
|
|
64
|
+
const cause = error.cause()
|
|
65
|
+
if (cause) {
|
|
66
|
+
error = cause
|
|
67
|
+
}
|
|
76
68
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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)
|
|
86
90
|
}
|
|
87
|
-
codeFrame = codeFrameColumns(rawLines, location)
|
|
88
91
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
|
|
@@ -28,7 +28,7 @@ const createTerminal = (ptyHost, socket) => {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const create = async (socket, id, cwd) => {
|
|
31
|
+
export const create = async (socket, id, cwd, command, args) => {
|
|
32
32
|
try {
|
|
33
33
|
Assert.object(socket)
|
|
34
34
|
Assert.number(id)
|
|
@@ -41,7 +41,7 @@ export const create = async (socket, id, cwd) => {
|
|
|
41
41
|
ptyHost.send({
|
|
42
42
|
jsonrpc: JsonRpcVersion.Two,
|
|
43
43
|
method: 'Terminal.create',
|
|
44
|
-
params: [id, cwd],
|
|
44
|
+
params: [id, cwd, command, args],
|
|
45
45
|
})
|
|
46
46
|
} catch (error) {
|
|
47
47
|
throw new VError(error, `Failed to create terminal`)
|
package/src/parts/Trash/Trash.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { default as _trash } from 'trash'
|
|
2
1
|
import { VError } from '../VError/VError.js'
|
|
3
2
|
|
|
4
3
|
export const trash = async (path) => {
|
|
5
4
|
try {
|
|
5
|
+
const { default: _trash } = await import('trash')
|
|
6
6
|
await _trash(path)
|
|
7
7
|
} catch (error) {
|
|
8
8
|
throw new VError(error, 'Failed to move item to trash')
|
package/src/sharedProcessMain.js
CHANGED
|
@@ -31,22 +31,11 @@ const main = async () => {
|
|
|
31
31
|
await module.handleCliArgs(argv)
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
console.log('[shared process] started')
|
|
36
34
|
// process.on('beforeExit', handleBeforeExit)
|
|
37
35
|
process.on('disconnect', handleDisconnect)
|
|
38
36
|
process.on(Signal.SIGTERM, handleSigTerm)
|
|
39
|
-
|
|
40
37
|
process.on('uncaughtExceptionMonitor', ErrorHandling.handleUncaughtExceptionMonitor)
|
|
41
38
|
await ParentIpc.listen()
|
|
42
|
-
|
|
43
|
-
// ExtensionHost.start() // TODO start on demand, e.g. not when extensions should be disabled
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
main()
|
|
47
|
-
|
|
48
|
-
// TODO when browser reloads or opens in new tab how does the window know which folder to open?
|
|
49
|
-
|
|
50
|
-
// setTimeout(() => {
|
|
51
|
-
// throw new Error('oops')
|
|
52
|
-
// }, 210)
|