@lvce-editor/shared-process 0.18.11 → 0.18.12
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 +18 -5
- package/src/parts/AutoUpdater/AutoUpdater.js +2 -1
- package/src/parts/ChildProcessError/ChildProcessError.js +11 -2
- package/src/parts/Env/Env.js +2 -0
- package/src/parts/GetHelpfulChildProcessError/GetHelpfulChildProcessError.js +34 -3
- package/src/parts/IsAppImage/IsAppImage.js +5 -0
- package/src/parts/Main/Main.js +15 -0
- package/src/parts/MergeStacks/MergeStacks.js +20 -0
- package/src/parts/NormalizeErrorLine/NormalizeErrorLine.js +9 -0
- package/src/parts/Platform/Platform.js +3 -7
- package/src/parts/RebuildForElectron/RebuildForElectron.js +10 -11
- package/src/parts/RebuildForNode/RebuildForNode.js +9 -10
- package/src/sharedProcessMain.js +2 -16
package/package.json
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.12",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Lvce Editor"
|
|
8
|
+
],
|
|
9
|
+
"author": "Lvce Editor",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/lvce-editor/lvce-editor.git",
|
|
14
|
+
"directory": "packages/shared-process"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
},
|
|
6
19
|
"dependencies": {
|
|
7
20
|
"@babel/code-frame": "^7.22.13",
|
|
8
|
-
"@lvce-editor/extension-host": "0.18.
|
|
9
|
-
"@lvce-editor/extension-host-helper-process": "0.18.
|
|
21
|
+
"@lvce-editor/extension-host": "0.18.12",
|
|
22
|
+
"@lvce-editor/extension-host-helper-process": "0.18.12",
|
|
10
23
|
"@lvce-editor/jsonc-parser": "^1.1.0",
|
|
11
|
-
"@lvce-editor/pretty-error": "^1.2.
|
|
12
|
-
"@lvce-editor/pty-host": "0.18.
|
|
24
|
+
"@lvce-editor/pretty-error": "^1.2.1",
|
|
25
|
+
"@lvce-editor/pty-host": "0.18.12",
|
|
13
26
|
"@lvce-editor/verror": "^1.1.1",
|
|
14
27
|
"debug": "^4.3.4",
|
|
15
28
|
"execa": "^8.0.1",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as AutoUpdateType from '../AutoUpdateType/AutoUpdateType.js'
|
|
2
2
|
import * as CompareVersion from '../CompareVersion/CompareVersion.js'
|
|
3
3
|
import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
|
|
4
|
+
import * as IsAppImage from '../IsAppImage/IsAppImage.js'
|
|
4
5
|
import * as Platform from '../Platform/Platform.js'
|
|
5
6
|
import { VError } from '../VError/VError.js'
|
|
6
7
|
|
|
@@ -12,7 +13,7 @@ export const getAutoUpdateType = async () => {
|
|
|
12
13
|
if (Platform.isWindows) {
|
|
13
14
|
return AutoUpdateType.WindowsNsis
|
|
14
15
|
}
|
|
15
|
-
if (
|
|
16
|
+
if (IsAppImage.isAppImage()) {
|
|
16
17
|
return AutoUpdateType.AppImage
|
|
17
18
|
}
|
|
18
19
|
return AutoUpdateType.None
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import * as GetHelpfulChildProcessError from '../GetHelpfulChildProcessError/GetHelpfulChildProcessError.js'
|
|
2
|
+
import * as JoinLines from '../JoinLines/JoinLines.js'
|
|
3
|
+
import * as SplitLines from '../SplitLines/SplitLines.js'
|
|
2
4
|
|
|
3
5
|
export class ChildProcessError extends Error {
|
|
4
6
|
constructor(stderr) {
|
|
5
|
-
const { message, code } = GetHelpfulChildProcessError.getHelpfulChildProcessError('', stderr)
|
|
6
|
-
super(message)
|
|
7
|
+
const { message, code, stack } = GetHelpfulChildProcessError.getHelpfulChildProcessError('', stderr)
|
|
8
|
+
super(message || 'child process error')
|
|
7
9
|
this.name = 'ChildProcessError'
|
|
8
10
|
if (code) {
|
|
9
11
|
this.code = code
|
|
10
12
|
}
|
|
13
|
+
if (stack) {
|
|
14
|
+
const lines = SplitLines.splitLines(this.stack)
|
|
15
|
+
const [firstLine, ...stackLines] = lines
|
|
16
|
+
const newStackLines = [firstLine, ...stack, ...stackLines]
|
|
17
|
+
const newStack = JoinLines.joinLines(newStackLines)
|
|
18
|
+
this.stack = newStack
|
|
19
|
+
}
|
|
11
20
|
}
|
|
12
21
|
}
|
package/src/parts/Env/Env.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as SplitLines from '../SplitLines/SplitLines.js'
|
|
2
1
|
import * as ErrorCodes from '../ErrorCodes/ErrorCodes.js'
|
|
2
|
+
import * as SplitLines from '../SplitLines/SplitLines.js'
|
|
3
|
+
import * as JoinLines from '../JoinLines/JoinLines.js'
|
|
3
4
|
|
|
4
5
|
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/
|
|
5
6
|
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/
|
|
@@ -7,6 +8,9 @@ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js versi
|
|
|
7
8
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/
|
|
8
9
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/
|
|
9
10
|
|
|
11
|
+
const RE_AT = /^\s+at/
|
|
12
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/
|
|
13
|
+
|
|
10
14
|
const isUnhelpfulNativeModuleError = (stderr) => {
|
|
11
15
|
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr)
|
|
12
16
|
}
|
|
@@ -62,7 +66,7 @@ const isModuleNotFoundMessage = (line) => {
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
const getModuleNotFoundError = (stderr) => {
|
|
65
|
-
const lines =
|
|
69
|
+
const lines = SplitLines.splitLines(stderr)
|
|
66
70
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage)
|
|
67
71
|
const message = lines[messageIndex]
|
|
68
72
|
return {
|
|
@@ -71,6 +75,30 @@ const getModuleNotFoundError = (stderr) => {
|
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
const isNormalStackLine = (line) => {
|
|
79
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const getDetails = (lines) => {
|
|
83
|
+
const index = lines.findIndex(isNormalStackLine)
|
|
84
|
+
if (index === -1) {
|
|
85
|
+
return {
|
|
86
|
+
actualMessage: JoinLines.joinLines(lines),
|
|
87
|
+
rest: [],
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let lastIndex = index - 1
|
|
91
|
+
while (++lastIndex < lines.length) {
|
|
92
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
actualMessage: lines[index - 1],
|
|
98
|
+
rest: lines.slice(index, lastIndex),
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
74
102
|
export const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
75
103
|
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
76
104
|
return getNativeModuleErrorMessage(stderr)
|
|
@@ -81,8 +109,11 @@ export const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
81
109
|
if (isModuleNotFoundError(stderr)) {
|
|
82
110
|
return getModuleNotFoundError(stderr)
|
|
83
111
|
}
|
|
112
|
+
const lines = SplitLines.splitLines(stderr)
|
|
113
|
+
const { actualMessage, rest } = getDetails(lines)
|
|
84
114
|
return {
|
|
85
|
-
message:
|
|
115
|
+
message: `${actualMessage}`,
|
|
86
116
|
code: '',
|
|
117
|
+
stack: rest,
|
|
87
118
|
}
|
|
88
119
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { setPriority } from 'node:os'
|
|
2
|
+
import * as Command from '../Command/Command.js'
|
|
3
|
+
import * as Module from '../Module/Module.js'
|
|
4
|
+
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
5
|
+
import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js'
|
|
6
|
+
import * as Signal from '../Signal/Signal.js'
|
|
7
|
+
|
|
8
|
+
export const main = async () => {
|
|
9
|
+
Command.setLoad(Module.load)
|
|
10
|
+
process.on('disconnect', ProcessListeners.handleDisconnect)
|
|
11
|
+
process.on(Signal.SIGTERM, ProcessListeners.handleSigTerm)
|
|
12
|
+
process.on('uncaughtExceptionMonitor', ProcessListeners.handleUncaughtExceptionMonitor)
|
|
13
|
+
await ParentIpc.listen()
|
|
14
|
+
setPriority(process.pid, 19)
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as GetNewLineIndex from '../GetNewLineIndex/GetNewLineIndex.js'
|
|
2
|
+
import * as NormalizeErrorLine from '../NormalizeErrorLine/NormalizeErrorLine.js'
|
|
3
|
+
|
|
4
|
+
export const mergeStacks = (parent, child) => {
|
|
5
|
+
if (!child) {
|
|
6
|
+
return parent
|
|
7
|
+
}
|
|
8
|
+
const parentNewLineIndex = GetNewLineIndex.getNewLineIndex(parent)
|
|
9
|
+
const childNewLineIndex = GetNewLineIndex.getNewLineIndex(child)
|
|
10
|
+
if (childNewLineIndex === -1) {
|
|
11
|
+
return parent
|
|
12
|
+
}
|
|
13
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex)
|
|
14
|
+
const childRest = child.slice(childNewLineIndex)
|
|
15
|
+
const childFirstLine = NormalizeErrorLine.normalizeLine(child.slice(0, childNewLineIndex))
|
|
16
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
17
|
+
return parentFirstLine + childRest
|
|
18
|
+
}
|
|
19
|
+
return child
|
|
20
|
+
}
|
|
@@ -13,10 +13,6 @@ export const isMacOs = platform === 'darwin'
|
|
|
13
13
|
|
|
14
14
|
export const isDeb = false
|
|
15
15
|
|
|
16
|
-
export const isAppImage = () => {
|
|
17
|
-
return Boolean(env.APPIMAGE)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
export const getPathSeparator = () => {
|
|
21
17
|
return sep
|
|
22
18
|
}
|
|
@@ -55,11 +51,11 @@ export const getSetupName = () => {
|
|
|
55
51
|
return 'Lvce-Setup'
|
|
56
52
|
}
|
|
57
53
|
|
|
58
|
-
export const version = '0.18.
|
|
54
|
+
export const version = '0.18.12'
|
|
59
55
|
|
|
60
|
-
export const commit = '
|
|
56
|
+
export const commit = '1045890'
|
|
61
57
|
|
|
62
|
-
export const date = '2023-10-
|
|
58
|
+
export const date = '2023-10-11T17:06:03.000Z'
|
|
63
59
|
|
|
64
60
|
export const getVersion = () => {
|
|
65
61
|
return version
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
1
|
+
import { VError } from '@lvce-editor/verror'
|
|
2
|
+
import * as Exec from '../Exec/Exec.js'
|
|
3
3
|
import * as GetElectronRebuildPath from '../GetElectronRebuildPath/GetElectronRebuildPath.js'
|
|
4
|
-
import * as GetFirstNodeChildProcessEvent from '../GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @param {string} cwd
|
|
8
7
|
*/
|
|
9
8
|
export const rebuild = async (cwd) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
throw new
|
|
9
|
+
try {
|
|
10
|
+
const electronRebuildPath = GetElectronRebuildPath.getElectronRebuildPath()
|
|
11
|
+
await Exec.exec(electronRebuildPath, [], {
|
|
12
|
+
cwd,
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
})
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw new VError(error, `Failed to rebuild native module`)
|
|
18
17
|
}
|
|
19
18
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import * as GetFirstNodeChildProcessEvent from '../GetFirstNodeChildProcessEvent/GetFirstNodeChildProcessEvent.js'
|
|
1
|
+
import { VError } from '@lvce-editor/verror'
|
|
2
|
+
import * as Exec from '../Exec/Exec.js'
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @param {string} cwd
|
|
7
6
|
*/
|
|
8
7
|
export const rebuild = async (cwd) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new
|
|
8
|
+
try {
|
|
9
|
+
await Exec.exec('npm', ['rebuild'], {
|
|
10
|
+
cwd,
|
|
11
|
+
stdio: 'inherit',
|
|
12
|
+
})
|
|
13
|
+
} catch (error) {
|
|
14
|
+
throw new VError(error, `Failed to rebuild native module`)
|
|
16
15
|
}
|
|
17
16
|
}
|
package/src/sharedProcessMain.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as Command from './parts/Command/Command.js'
|
|
3
|
-
import * as Module from './parts/Module/Module.js'
|
|
4
|
-
import * as ParentIpc from './parts/ParentIpc/ParentIpc.js'
|
|
5
|
-
import * as ProcessListeners from './parts/ProcessListeners/ProcessListeners.js'
|
|
6
|
-
import * as Signal from './parts/Signal/Signal.js'
|
|
1
|
+
import * as Main from './parts/Main/Main.js'
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
Command.setLoad(Module.load)
|
|
10
|
-
process.on('disconnect', ProcessListeners.handleDisconnect)
|
|
11
|
-
process.on(Signal.SIGTERM, ProcessListeners.handleSigTerm)
|
|
12
|
-
process.on('uncaughtExceptionMonitor', ProcessListeners.handleUncaughtExceptionMonitor)
|
|
13
|
-
await ParentIpc.listen()
|
|
14
|
-
setPriority(process.pid, 19)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
main()
|
|
3
|
+
Main.main()
|