@lvce-editor/shared-process 0.20.15 → 0.21.1
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 +4 -4
- package/src/parts/AppWindow/AppWindow.js +2 -2
- package/src/parts/ColorTheme/ColorTheme.js +21 -0
- package/src/parts/ElectronContextMenu/ElectronContextMenu.js +6 -2
- package/src/parts/ElectronSafeStorage/ElectronSafeStorage.js +6 -3
- package/src/parts/ElectronWindow/ElectronWindow.js +13 -8
- package/src/parts/ElectronWindowProcessExplorer/ElectronWindowProcessExplorer.js +31 -2
- package/src/parts/GetProcessExplorerUrl/GetProcessExplorerUrl.js +11 -0
- package/src/parts/HandleElectronReady/HandleElectronReady.ipc.js +7 -0
- package/src/parts/HandleElectronReady/HandleElectronReady.js +10 -0
- package/src/parts/HandleUncaughtExceptionMonitor/HandleUncaughtExceptionMonitor.js +5 -0
- package/src/parts/HandleWindowAllClosed/HandleWindowAllClosed.ipc.js +7 -0
- package/src/parts/HandleWindowAllClosed/HandleWindowAllClosed.js +11 -0
- package/src/parts/IpcChildWithElectronUtilityProcess/IpcChildWithElectronUtilityProcess.js +0 -2
- package/src/parts/Main/Main.js +2 -3
- package/src/parts/Module/Module.js +4 -0
- package/src/parts/ModuleId/ModuleId.js +2 -0
- package/src/parts/ModuleMap/ModuleMap.js +4 -0
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/Screen/Screen.js +3 -3
- package/src/parts/GetResponse/GetResponse.js +0 -14
- package/src/parts/GetSuccessResponse/GetSuccessResponse.js +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/code-frame": "^7.23.5",
|
|
21
|
-
"@lvce-editor/extension-host": "0.
|
|
22
|
-
"@lvce-editor/extension-host-helper-process": "0.
|
|
21
|
+
"@lvce-editor/extension-host": "0.21.1",
|
|
22
|
+
"@lvce-editor/extension-host-helper-process": "0.21.1",
|
|
23
23
|
"@lvce-editor/json-rpc": "^0.4.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "^1.1.0",
|
|
25
25
|
"@lvce-editor/pretty-error": "^1.2.2",
|
|
26
|
-
"@lvce-editor/pty-host": "0.
|
|
26
|
+
"@lvce-editor/pty-host": "0.21.1",
|
|
27
27
|
"@lvce-editor/verror": "^1.1.2",
|
|
28
28
|
"debug": "^4.3.4",
|
|
29
29
|
"execa": "^8.0.1",
|
|
@@ -4,7 +4,7 @@ import * as Platform from '../Platform/Platform.js'
|
|
|
4
4
|
import * as Preferences from '../Preferences/Preferences.js'
|
|
5
5
|
import * as Screen from '../Screen/Screen.js'
|
|
6
6
|
|
|
7
|
-
const getWindowOptions =
|
|
7
|
+
const getWindowOptions = (preferencs, screenWidth, screenHeight) => {
|
|
8
8
|
const titleBarPreference = preferencs['window.titleBarStyle']
|
|
9
9
|
const frame = titleBarPreference !== 'custom'
|
|
10
10
|
const titleBarStyle = titleBarPreference === 'custom' ? 'hidden' : undefined
|
|
@@ -37,7 +37,7 @@ export const createAppWindow = async (preferences, parsedArgs, workingDirectory,
|
|
|
37
37
|
const screenWidth = await Screen.getWidth()
|
|
38
38
|
const screenHeight = await Screen.getHeight()
|
|
39
39
|
const windowOptions = getWindowOptions(preferences, screenWidth, screenHeight)
|
|
40
|
-
return ParentIpc.invoke('
|
|
40
|
+
return ParentIpc.invoke('AppWindow.createAppWindow2', windowOptions, parsedArgs, workingDirectory, url)
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export const openNew = async (url) => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as JoinLines from '../JoinLines/JoinLines.js'
|
|
2
|
+
|
|
3
|
+
export const getColorThemeJson = async () => {
|
|
4
|
+
return {
|
|
5
|
+
MainBackground: '#1e2324',
|
|
6
|
+
TreeItemForeground: ` rgb(188, 190, 190)`,
|
|
7
|
+
FocusOutline: `#3d5252`,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const toInnerLine = ([key, value]) => {
|
|
12
|
+
return ` --${key}: ${value};`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const toCss = (colorThemeJson) => {
|
|
16
|
+
const innerLines = Object.entries(colorThemeJson).map(toInnerLine)
|
|
17
|
+
const css = `:root {
|
|
18
|
+
${JoinLines.joinLines(innerLines)}
|
|
19
|
+
}`
|
|
20
|
+
return css
|
|
21
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import * as Assert from '../Assert/Assert.js'
|
|
1
2
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
3
|
|
|
3
|
-
export const openContextMenu = (menuItems, x, y
|
|
4
|
-
|
|
4
|
+
export const openContextMenu = (menuItems, x, y) => {
|
|
5
|
+
Assert.array(menuItems)
|
|
6
|
+
Assert.number(x)
|
|
7
|
+
Assert.number(y)
|
|
8
|
+
return ParentIpc.invoke('ElectronContextMenu.openContextMenu', menuItems, x, y)
|
|
5
9
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import * as EncodingType from '../EncodingType/EncodingType.js'
|
|
1
2
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
3
|
|
|
3
4
|
export const isEncryptionAvailable = () => {
|
|
4
5
|
return ParentIpc.invoke('ElectronSafeStorage.isEncryptionAvailable')
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export const encryptString = (plainText) => {
|
|
8
|
-
|
|
8
|
+
export const encryptString = async (plainText) => {
|
|
9
|
+
const buffer = await ParentIpc.invoke('ElectronSafeStorage.encrypt', plainText)
|
|
10
|
+
return buffer.toString(EncodingType.Base64)
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export const decryptString = (encrypted) => {
|
|
12
|
-
|
|
14
|
+
const buffer = Buffer.from(encrypted, EncodingType.Base64)
|
|
15
|
+
return ParentIpc.invoke('ElectronSafeStorage.decrypt', buffer)
|
|
13
16
|
}
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import * as Assert from '../Assert/Assert.js'
|
|
2
2
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
3
|
+
import * as AppWindow from '../AppWindow/AppWindow.js'
|
|
3
4
|
|
|
4
5
|
export const openNew = () => {
|
|
5
|
-
return
|
|
6
|
+
return AppWindow.openNew()
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export const minimize = (windowId) => {
|
|
9
10
|
Assert.number(windowId)
|
|
10
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
11
|
+
return ParentIpc.invoke('ElectronWindow.executeWindowFunction', windowId, 'minimize')
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const toggleDevtools = (windowId) => {
|
|
14
15
|
Assert.number(windowId)
|
|
15
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
16
|
+
return ParentIpc.invoke('ElectronWindow.executeWebContentsFunction', windowId, 'toggleDevTools')
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export const maximize = (windowId) => {
|
|
19
20
|
Assert.number(windowId)
|
|
20
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
21
|
+
return ParentIpc.invoke('ElectronWindow.executeWindowFunction', windowId, 'maximize')
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export const unmaximize = (windowId) => {
|
|
24
25
|
Assert.number(windowId)
|
|
25
|
-
return ParentIpc.invoke('ElectronWindow.unmaximize')
|
|
26
|
+
return ParentIpc.invoke('ElectronWindow.executeWindowFunction', windowId, 'unmaximize')
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export const close = (windowId) => {
|
|
29
30
|
Assert.number(windowId)
|
|
30
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
31
|
+
return ParentIpc.invoke('ElectronWindow.executeWindowFunction', windowId, 'close')
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export const reload = (windowId) => {
|
|
34
35
|
Assert.number(windowId)
|
|
35
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
36
|
+
return ParentIpc.invoke('ElectronWindow.executeWindowFunction', windowId, 'reload')
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export const zoomIn = (windowId) => {
|
|
@@ -48,5 +49,9 @@ export const zoomReset = (windowId) => {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export const focus = (windowId) => {
|
|
51
|
-
return ParentIpc.invoke('ElectronWindow.
|
|
52
|
+
return ParentIpc.invoke('ElectronWindow.executeWebContentsFunction', windowId, 'focus')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const handleClose = (windowId) => {
|
|
56
|
+
// TODO
|
|
52
57
|
}
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import * as ColorTheme from '../ColorTheme/ColorTheme.js'
|
|
5
|
+
import * as GetProcessExplorerUrl from '../GetProcessExplorerUrl/GetProcessExplorerUrl.js'
|
|
1
6
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
const getOptions = async (colorThemeJson) => {
|
|
9
|
+
const backgroundColor = colorThemeJson.MainBackground
|
|
10
|
+
const preload = GetProcessExplorerUrl.getProcessExplorerPreloadUrl()
|
|
11
|
+
const options = {
|
|
12
|
+
width: 800,
|
|
13
|
+
height: 500,
|
|
14
|
+
backgroundColor,
|
|
15
|
+
webPreferences: {
|
|
16
|
+
preload,
|
|
17
|
+
sandbox: true,
|
|
18
|
+
additionalArguments: ['--lvce-window-kind=process-explorer'],
|
|
19
|
+
spellcheck: false,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
return options
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const open = async () => {
|
|
26
|
+
const colorThemeJson = await ColorTheme.getColorThemeJson()
|
|
27
|
+
const options = await getOptions(colorThemeJson)
|
|
28
|
+
// TODO get actual process explorer theme css from somewhere
|
|
29
|
+
const processExplorerThemeCss = ColorTheme.toCss(colorThemeJson)
|
|
30
|
+
const processExporerThemeCssPath = join(tmpdir(), 'process-explorer-theme.css')
|
|
31
|
+
await writeFile(processExporerThemeCssPath, processExplorerThemeCss)
|
|
32
|
+
const url = GetProcessExplorerUrl.getProcessExplorerUrl()
|
|
33
|
+
return ParentIpc.invoke('ElectronWindowProcessExplorer.open2', options, url)
|
|
5
34
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Path from '../Path/Path.js'
|
|
2
|
+
import * as Platform from '../Platform/Platform.js'
|
|
3
|
+
import * as Root from '../Root/Root.js'
|
|
4
|
+
|
|
5
|
+
export const getProcessExplorerUrl = () => {
|
|
6
|
+
return `${Platform.scheme}://-/packages/main-process/pages/process-explorer/process-explorer.html`
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const getProcessExplorerPreloadUrl = () => {
|
|
10
|
+
return Path.join(Root.root, 'packages', 'main-process', 'pages', 'process-explorer', 'process-explorer-preload.js')
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as AppWindow from '../AppWindow/AppWindow.js'
|
|
2
|
+
import * as Assert from '../Assert/Assert.js'
|
|
3
|
+
import * as Preferences from '../Preferences/Preferences.js'
|
|
4
|
+
|
|
5
|
+
export const handleElectronReady = async (parsedArgs, workingDirectory) => {
|
|
6
|
+
Assert.object(parsedArgs)
|
|
7
|
+
Assert.string(workingDirectory)
|
|
8
|
+
const preferences = await Preferences.getAll()
|
|
9
|
+
await AppWindow.createAppWindow(preferences, parsedArgs, workingDirectory)
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Debug from '../Debug/Debug.js'
|
|
2
|
+
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
3
|
+
import * as Platform from '../Platform/Platform.js'
|
|
4
|
+
|
|
5
|
+
export const handleWindowAllClosed = async () => {
|
|
6
|
+
Debug.debug('[info] all windows closed')
|
|
7
|
+
if (!Platform.isMacOs) {
|
|
8
|
+
Debug.debug('[info] quitting')
|
|
9
|
+
await ParentIpc.invoke('Exit.exit')
|
|
10
|
+
}
|
|
11
|
+
}
|
package/src/parts/Main/Main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { setPriority } from 'node:os'
|
|
2
1
|
import * as Command from '../Command/Command.js'
|
|
2
|
+
import * as HandleUncaughtExceptionMonitor from '../HandleUncaughtExceptionMonitor/HandleUncaughtExceptionMonitor.js'
|
|
3
3
|
import * as Module from '../Module/Module.js'
|
|
4
4
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
5
5
|
import * as ProcessListeners from '../ProcessListeners/ProcessListeners.js'
|
|
@@ -9,7 +9,6 @@ export const main = async () => {
|
|
|
9
9
|
Command.setLoad(Module.load)
|
|
10
10
|
process.on('disconnect', ProcessListeners.handleDisconnect)
|
|
11
11
|
process.on(Signal.SIGTERM, ProcessListeners.handleSigTerm)
|
|
12
|
-
process.on('uncaughtExceptionMonitor',
|
|
12
|
+
process.on('uncaughtExceptionMonitor', HandleUncaughtExceptionMonitor.handleUncaughtExceptionMonitor)
|
|
13
13
|
await ParentIpc.listen()
|
|
14
|
-
setPriority(process.pid, 19)
|
|
15
14
|
}
|
|
@@ -126,6 +126,10 @@ export const load = (moduleId) => {
|
|
|
126
126
|
return import('../ElectronNet/ElectronNet.ipc.js')
|
|
127
127
|
case ModuleId.Screen:
|
|
128
128
|
return import('../Screen/Screen.ipc.js')
|
|
129
|
+
case ModuleId.HandleElectronReady:
|
|
130
|
+
return import('../HandleElectronReady/HandleElectronReady.ipc.js')
|
|
131
|
+
case ModuleId.HandleWindowAllClosed:
|
|
132
|
+
return import('../HandleWindowAllClosed/HandleWindowAllClosed.ipc.js')
|
|
129
133
|
default:
|
|
130
134
|
throw new Error(`module ${moduleId} not found`)
|
|
131
135
|
}
|
|
@@ -281,6 +281,10 @@ export const getModuleId = (commandId) => {
|
|
|
281
281
|
case 'Screen.getHeight':
|
|
282
282
|
case 'Screen.getBounds':
|
|
283
283
|
return ModuleId.Screen
|
|
284
|
+
case 'HandleElectronReady.handleElectronReady':
|
|
285
|
+
return ModuleId.HandleElectronReady
|
|
286
|
+
case 'HandleWindowAllClosed.handleWindowAllClosed':
|
|
287
|
+
return ModuleId.HandleWindowAllClosed
|
|
284
288
|
default:
|
|
285
289
|
throw new CommandNotFoundError(commandId)
|
|
286
290
|
}
|
|
@@ -53,11 +53,11 @@ export const getSetupName = () => {
|
|
|
53
53
|
return 'Lvce-Setup'
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export const version = '0.
|
|
56
|
+
export const version = '0.21.1'
|
|
57
57
|
|
|
58
|
-
export const commit = '
|
|
58
|
+
export const commit = '1aea3f8'
|
|
59
59
|
|
|
60
|
-
export const date = '2023-12-
|
|
60
|
+
export const date = '2023-12-12T20:15:17.000Z'
|
|
61
61
|
|
|
62
62
|
export const getVersion = () => {
|
|
63
63
|
return version
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
2
|
|
|
3
3
|
export const getWidth = () => {
|
|
4
|
-
return ParentIpc.invoke('
|
|
4
|
+
return ParentIpc.invoke('ElectronScreen.getWidth')
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const getHeight = () => {
|
|
8
|
-
return ParentIpc.invoke('
|
|
8
|
+
return ParentIpc.invoke('ElectronScreen.getHeight')
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const getBounds = () => {
|
|
12
|
-
return ParentIpc.invoke('
|
|
12
|
+
return ParentIpc.invoke('ElectronScreen.getBounds')
|
|
13
13
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as GetErrorResponse from '../GetErrorResponse/GetErrorResponse.js'
|
|
2
|
-
import * as GetSuccessResponse from '../GetSuccessResponse/GetSuccessResponse.js'
|
|
3
|
-
import * as RequiresSocket from '../RequiresSocket/RequiresSocket.js'
|
|
4
|
-
|
|
5
|
-
export const getResponse = async (message, ipc, execute, preparePrettyError, logError) => {
|
|
6
|
-
try {
|
|
7
|
-
const result = RequiresSocket.requiresSocket(message.method)
|
|
8
|
-
? await execute(message.method, ipc, ...message.params)
|
|
9
|
-
: await execute(message.method, ...message.params)
|
|
10
|
-
return GetSuccessResponse.getSuccessResponse(message, result)
|
|
11
|
-
} catch (error) {
|
|
12
|
-
return GetErrorResponse.getErrorResponse(message, error, ipc, preparePrettyError, logError)
|
|
13
|
-
}
|
|
14
|
-
}
|