@lvce-editor/shared-process 0.21.7 → 0.21.9
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/package.json +8 -10
- package/src/parts/GetElectronFileResponseContent/GetElectronFileResponseContent.js +1 -1
- package/src/parts/GetMimeType/GetMimeType.js +1 -0
- package/src/parts/GetTypeScriptPath/GetTypeScriptPath.js +11 -3
- package/src/parts/Json/Json.js +6 -4
- package/src/parts/MimeType/MimeType.js +1 -1
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/TranspileTypeScript/TranspileTypeScript.js +1 -5
- package/src/parts/JsonError/JsonError.js +0 -66
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.9",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
"node": ">=18"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@babel/code-frame": "^7.23.5",
|
|
21
20
|
"@lvce-editor/assert": "^1.0.1",
|
|
22
|
-
"@lvce-editor/extension-host": "0.21.
|
|
23
|
-
"@lvce-editor/extension-host-helper-process": "0.21.
|
|
24
|
-
"@lvce-editor/json-rpc": "^0.
|
|
21
|
+
"@lvce-editor/extension-host": "0.21.9",
|
|
22
|
+
"@lvce-editor/extension-host-helper-process": "0.21.9",
|
|
23
|
+
"@lvce-editor/json-rpc": "^1.0.0",
|
|
25
24
|
"@lvce-editor/jsonc-parser": "^1.1.0",
|
|
26
25
|
"@lvce-editor/pretty-error": "^1.3.0",
|
|
27
|
-
"@lvce-editor/pty-host": "0.21.
|
|
26
|
+
"@lvce-editor/pty-host": "0.21.9",
|
|
28
27
|
"@lvce-editor/verror": "^1.1.2",
|
|
29
28
|
"debug": "^4.3.4",
|
|
30
29
|
"execa": "^8.0.1",
|
|
@@ -35,14 +34,13 @@
|
|
|
35
34
|
"p-queue": "^8.0.1",
|
|
36
35
|
"parse-json": "^8.1.0",
|
|
37
36
|
"tar-fs": "^3.0.4",
|
|
38
|
-
"ws": "^8.
|
|
37
|
+
"ws": "^8.16.0",
|
|
39
38
|
"xdg-basedir": "^5.1.0"
|
|
40
39
|
},
|
|
41
40
|
"optionalDependencies": {
|
|
42
|
-
"@lvce-editor/ripgrep": "^1.0.
|
|
41
|
+
"@lvce-editor/ripgrep": "^1.0.2",
|
|
43
42
|
"extract-zip": "^2.0.1",
|
|
44
|
-
"open": "^10.0.
|
|
45
|
-
"symlink-dir": "^5.2.0",
|
|
43
|
+
"open": "^10.0.2",
|
|
46
44
|
"tail": "^2.2.6",
|
|
47
45
|
"tmp-promise": "^3.0.3",
|
|
48
46
|
"trash": "^8.1.1"
|
|
@@ -17,7 +17,7 @@ export const getElectronFileResponseContent = async (absolutePath, url) => {
|
|
|
17
17
|
let content = await readFile(absolutePath)
|
|
18
18
|
if (IsTypeScriptPath.isTypeScriptPath(url)) {
|
|
19
19
|
const preferences = await getPreferences()
|
|
20
|
-
if (preferences['typescript.transpile']) {
|
|
20
|
+
if (preferences['typescript.transpile'] || process.env['TRANSPILE_TYPESCRIPT']) {
|
|
21
21
|
const newContent = await TranspileTypeScript.transpileTypeScript(content.toString())
|
|
22
22
|
content = newContent.outputText
|
|
23
23
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { join } from 'path'
|
|
2
|
-
import * as
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import * as PlatformPaths from '../PlatformPaths/PlatformPaths.js'
|
|
3
3
|
|
|
4
4
|
export const getTypeScriptPath = () => {
|
|
5
|
-
return join(
|
|
5
|
+
return join(
|
|
6
|
+
PlatformPaths.getBuiltinExtensionsPath(),
|
|
7
|
+
'builtin.language-features-typescript',
|
|
8
|
+
'node',
|
|
9
|
+
'node_modules',
|
|
10
|
+
'typescript',
|
|
11
|
+
'lib',
|
|
12
|
+
'typescript.js',
|
|
13
|
+
)
|
|
6
14
|
}
|
package/src/parts/Json/Json.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// parsing error handling based on https://github.com/sindresorhus/parse-json/blob/main/index.js
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { VError } from '../VError/VError.js'
|
|
4
4
|
import * as Character from '../Character/Character.js'
|
|
5
|
+
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
5
6
|
|
|
6
7
|
export const parse = async (string, filePath) => {
|
|
7
8
|
try {
|
|
8
9
|
return JSON.parse(string)
|
|
9
10
|
} catch (error) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const betterError = new VError(error, `Failed to parse json at ${filePath}`)
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
betterError.code = ErrorCodes.E_JSON_PARSE
|
|
14
|
+
throw betterError
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const ApplicationFontWoff = 'application/font-woff'
|
|
2
|
-
export const ApplicationJson = '
|
|
2
|
+
export const ApplicationJson = 'application/json'
|
|
3
3
|
export const AudioMidi = 'audio/midi'
|
|
4
4
|
export const AudioMpeg = 'audio/mpeg'
|
|
5
5
|
export const AudioOgg = 'audio/ogg'
|
|
@@ -61,11 +61,11 @@ export const getSetupName = () => {
|
|
|
61
61
|
return 'Lvce-Setup'
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const version = '0.21.
|
|
64
|
+
export const version = '0.21.9'
|
|
65
65
|
|
|
66
|
-
export const commit = '
|
|
66
|
+
export const commit = '215edd2'
|
|
67
67
|
|
|
68
|
-
export const date = '2023-12-
|
|
68
|
+
export const date = '2023-12-28T22:11:19.000Z'
|
|
69
69
|
|
|
70
70
|
export const getVersion = () => {
|
|
71
71
|
return version
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { VError } from '@lvce-editor/verror'
|
|
2
|
-
import * as GetTypeScriptPath from '../GetTypeScriptPath/GetTypeScriptPath.js'
|
|
3
2
|
import * as Assert from '../Assert/Assert.js'
|
|
3
|
+
import * as GetTypeScriptPath from '../GetTypeScriptPath/GetTypeScriptPath.js'
|
|
4
4
|
import * as LoadTypeScript from '../LoadTypeScript/LoadTypeScript.js'
|
|
5
5
|
|
|
6
6
|
export const transpileTypeScript = async (code) => {
|
|
7
7
|
try {
|
|
8
8
|
Assert.string(code)
|
|
9
9
|
const typescriptPath = GetTypeScriptPath.getTypeScriptPath()
|
|
10
|
-
console.log({ typescriptPath })
|
|
11
10
|
const typescript = await LoadTypeScript.loadTypeScript(typescriptPath)
|
|
12
|
-
console.log({ k: Object.keys(typescript) })
|
|
13
11
|
const newContent = await typescript.transpileModule(code, {
|
|
14
12
|
compilerOptions: {
|
|
15
13
|
target: 'esnext',
|
|
16
14
|
},
|
|
17
15
|
})
|
|
18
|
-
console.log({ newContent })
|
|
19
16
|
return newContent
|
|
20
17
|
} catch (error) {
|
|
21
|
-
console.log({ error })
|
|
22
18
|
throw new VError(error, `Failed to transpile typescript`)
|
|
23
19
|
}
|
|
24
20
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { codeFrameColumns } from '@babel/code-frame'
|
|
2
|
-
import { LinesAndColumns } from 'lines-and-columns'
|
|
3
|
-
|
|
4
|
-
// parsing error handling based on https://github.com/sindresorhus/parse-json/blob/main/index.js
|
|
5
|
-
|
|
6
|
-
const emptyError = {
|
|
7
|
-
message: '',
|
|
8
|
-
stack: '',
|
|
9
|
-
codeFrame: '',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const RE_POSITION = /in JSON at position (\d+)/
|
|
13
|
-
|
|
14
|
-
export const getErrorPropsFromError = (error, string, filePath) => {
|
|
15
|
-
const indexMatch = error.message.match(RE_POSITION)
|
|
16
|
-
if (indexMatch && indexMatch.length > 0) {
|
|
17
|
-
const lines = new LinesAndColumns(string)
|
|
18
|
-
const index = Number(indexMatch[1])
|
|
19
|
-
const location = lines.locationForIndex(index)
|
|
20
|
-
if (location) {
|
|
21
|
-
const line = location.line + 1
|
|
22
|
-
const column = location.column + 1
|
|
23
|
-
const codeFrame = codeFrameColumns(string, { start: { line, column } }, { highlightCode: false })
|
|
24
|
-
return {
|
|
25
|
-
codeFrame,
|
|
26
|
-
message: 'Json Parsing Error',
|
|
27
|
-
stack: ` at ${filePath}:${line}:${column}`,
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (string.length === 0) {
|
|
32
|
-
return {
|
|
33
|
-
codeFrame: ``,
|
|
34
|
-
message: 'Json Parsing Error: Cannot parse empty string',
|
|
35
|
-
stack: ` at ${filePath}`,
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (error.message === 'Unexpected end of JSON input') {
|
|
40
|
-
const lines = new LinesAndColumns(string)
|
|
41
|
-
const index = string.length - 1
|
|
42
|
-
const location = lines.locationForIndex(index)
|
|
43
|
-
if (location) {
|
|
44
|
-
const codeFrame = codeFrameColumns(string, { start: { line: location.line + 1, column: location.column + 1 } }, { highlightCode: false })
|
|
45
|
-
return {
|
|
46
|
-
codeFrame,
|
|
47
|
-
message: 'Json Parsing Error',
|
|
48
|
-
stack: ` at ${filePath}`,
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
codeFrame: ``,
|
|
54
|
-
message: 'Json Parsing Error',
|
|
55
|
-
stack: ` at ${filePath}`,
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const getErrorProps = (string, filePath) => {
|
|
60
|
-
try {
|
|
61
|
-
JSON.parse(string)
|
|
62
|
-
return emptyError
|
|
63
|
-
} catch (error) {
|
|
64
|
-
return getErrorPropsFromError(error, string, filePath)
|
|
65
|
-
}
|
|
66
|
-
}
|