@lvce-editor/shared-process 0.20.14 → 0.21.0
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 +5 -5
- package/src/parts/AppWindow/AppWindow.js +46 -0
- package/src/parts/AppWindowStates/AppWindowStates.js +62 -0
- package/src/parts/Authority/Authority.js +1 -0
- package/src/parts/ColorTheme/ColorTheme.js +21 -0
- package/src/parts/DefaultUrl/DefaultUrl.js +4 -0
- package/src/parts/ElectronWindow/ElectronWindow.js +6 -1
- 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/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/Module/Module.js +6 -0
- package/src/parts/ModuleId/ModuleId.js +3 -0
- package/src/parts/ModuleMap/ModuleMap.js +8 -0
- package/src/parts/Platform/Platform.js +5 -3
- package/src/parts/Screen/Screen.ipc.js +9 -0
- package/src/parts/Screen/Screen.js +13 -0
- 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.0",
|
|
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.0",
|
|
22
|
+
"@lvce-editor/extension-host-helper-process": "0.21.0",
|
|
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.0",
|
|
27
27
|
"@lvce-editor/verror": "^1.1.2",
|
|
28
28
|
"debug": "^4.3.4",
|
|
29
29
|
"execa": "^8.0.1",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"p-queue": "^8.0.0",
|
|
35
35
|
"parse-json": "^8.1.0",
|
|
36
36
|
"tar-fs": "^3.0.4",
|
|
37
|
-
"ws": "^8.
|
|
37
|
+
"ws": "^8.15.0",
|
|
38
38
|
"xdg-basedir": "^5.1.0"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as DefaultUrl from '../DefaultUrl/DefaultUrl.js'
|
|
2
|
+
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
3
|
+
import * as Platform from '../Platform/Platform.js'
|
|
4
|
+
import * as Preferences from '../Preferences/Preferences.js'
|
|
5
|
+
import * as Screen from '../Screen/Screen.js'
|
|
6
|
+
|
|
7
|
+
const getWindowOptions = (preferencs, screenWidth, screenHeight) => {
|
|
8
|
+
const titleBarPreference = preferencs['window.titleBarStyle']
|
|
9
|
+
const frame = titleBarPreference !== 'custom'
|
|
10
|
+
const titleBarStyle = titleBarPreference === 'custom' ? 'hidden' : undefined
|
|
11
|
+
const zoomLevelPreference = preferencs['window.zoomLevel']
|
|
12
|
+
const zoomLevel = zoomLevelPreference
|
|
13
|
+
const windowControlsOverlayPreference = Platform.isWindows && preferencs['window.controlsOverlay.enabled']
|
|
14
|
+
|
|
15
|
+
const titleBarOverlay = windowControlsOverlayPreference
|
|
16
|
+
? {
|
|
17
|
+
color: '#1e2324',
|
|
18
|
+
symbolColor: '#74b1be',
|
|
19
|
+
height: 29,
|
|
20
|
+
}
|
|
21
|
+
: undefined
|
|
22
|
+
return {
|
|
23
|
+
y: 0,
|
|
24
|
+
x: screenWidth - 800,
|
|
25
|
+
width: 800,
|
|
26
|
+
height: screenHeight,
|
|
27
|
+
menu: true,
|
|
28
|
+
background: '#1e2324',
|
|
29
|
+
titleBarStyle,
|
|
30
|
+
frame,
|
|
31
|
+
zoomLevel,
|
|
32
|
+
titleBarOverlay,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const createAppWindow = async (preferences, parsedArgs, workingDirectory, url = DefaultUrl.defaultUrl) => {
|
|
37
|
+
const screenWidth = await Screen.getWidth()
|
|
38
|
+
const screenHeight = await Screen.getHeight()
|
|
39
|
+
const windowOptions = getWindowOptions(preferences, screenWidth, screenHeight)
|
|
40
|
+
return ParentIpc.invoke('AppWindow.createAppWindow2', windowOptions, parsedArgs, workingDirectory, url)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const openNew = async (url) => {
|
|
44
|
+
const preferences = await Preferences.getAll()
|
|
45
|
+
return createAppWindow(preferences, [], '', url)
|
|
46
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const state = {
|
|
2
|
+
/**
|
|
3
|
+
* @type {any[]}
|
|
4
|
+
*/
|
|
5
|
+
windowStates: [],
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const findByWindowId = (windowId) => {
|
|
9
|
+
const { windowStates } = state
|
|
10
|
+
for (const windowState of windowStates) {
|
|
11
|
+
if (windowState.windowId === windowId) {
|
|
12
|
+
return windowState
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return undefined
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const findByWebContentsId = (webContentsId) => {
|
|
19
|
+
const { windowStates } = state
|
|
20
|
+
for (const windowState of windowStates) {
|
|
21
|
+
if (windowState.webContentsId === webContentsId) {
|
|
22
|
+
return windowState
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const findIndexById = (id) => {
|
|
29
|
+
const { windowStates } = state
|
|
30
|
+
for (let i = 0; i < windowStates.length; i++) {
|
|
31
|
+
const windowState = windowStates[i]
|
|
32
|
+
if (windowState.windowId === id) {
|
|
33
|
+
return i
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return -1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const remove = (windowId) => {
|
|
40
|
+
const index = findIndexById(windowId)
|
|
41
|
+
if (index === -1) {
|
|
42
|
+
throw new Error(`expected window ${windowId} to be in windows array`)
|
|
43
|
+
}
|
|
44
|
+
state.windowStates.splice(index, 1)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const getAll = () => {
|
|
48
|
+
return state.windowStates
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const add = (config) => {
|
|
52
|
+
state.windowStates.push(config)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const findByPort = (port) => {
|
|
56
|
+
for (const config of state.windowStates) {
|
|
57
|
+
if (config.port === port) {
|
|
58
|
+
return config
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return undefined
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const Authority = '-'
|
|
@@ -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,8 +1,9 @@
|
|
|
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) => {
|
|
@@ -50,3 +51,7 @@ export const zoomReset = (windowId) => {
|
|
|
50
51
|
export const focus = (windowId) => {
|
|
51
52
|
return ParentIpc.invoke('ElectronWindow.focus', windowId)
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
export const handleClose = (windowId) => {
|
|
56
|
+
// TODO
|
|
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('ElectronApp.quit')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -124,6 +124,12 @@ export const load = (moduleId) => {
|
|
|
124
124
|
return import('../Workspace/Workspace.ipc.js')
|
|
125
125
|
case ModuleId.ElectronNet:
|
|
126
126
|
return import('../ElectronNet/ElectronNet.ipc.js')
|
|
127
|
+
case ModuleId.Screen:
|
|
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')
|
|
127
133
|
default:
|
|
128
134
|
throw new Error(`module ${moduleId} not found`)
|
|
129
135
|
}
|
|
@@ -277,6 +277,14 @@ export const getModuleId = (commandId) => {
|
|
|
277
277
|
return ModuleId.Workspace
|
|
278
278
|
case 'ElectronNet.getJson':
|
|
279
279
|
return ModuleId.ElectronNet
|
|
280
|
+
case 'Screen.getWidth':
|
|
281
|
+
case 'Screen.getHeight':
|
|
282
|
+
case 'Screen.getBounds':
|
|
283
|
+
return ModuleId.Screen
|
|
284
|
+
case 'HandleElectronReady.handleElectronReady':
|
|
285
|
+
return ModuleId.HandleElectronReady
|
|
286
|
+
case 'HandleWindowAllClosed.handleWindowAllClosed':
|
|
287
|
+
return ModuleId.HandleWindowAllClosed
|
|
280
288
|
default:
|
|
281
289
|
throw new CommandNotFoundError(commandId)
|
|
282
290
|
}
|
|
@@ -13,6 +13,8 @@ export const isMacOs = platform === 'darwin'
|
|
|
13
13
|
|
|
14
14
|
export const isDeb = false
|
|
15
15
|
|
|
16
|
+
export const scheme = 'lvce-oss'
|
|
17
|
+
|
|
16
18
|
export const getPathSeparator = () => {
|
|
17
19
|
return sep
|
|
18
20
|
}
|
|
@@ -51,11 +53,11 @@ export const getSetupName = () => {
|
|
|
51
53
|
return 'Lvce-Setup'
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
export const version = '0.
|
|
56
|
+
export const version = '0.21.0'
|
|
55
57
|
|
|
56
|
-
export const commit = '
|
|
58
|
+
export const commit = 'f639638'
|
|
57
59
|
|
|
58
|
-
export const date = '2023-12-
|
|
60
|
+
export const date = '2023-12-12T05:33:21.000Z'
|
|
59
61
|
|
|
60
62
|
export const getVersion = () => {
|
|
61
63
|
return version
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
|
+
|
|
3
|
+
export const getWidth = () => {
|
|
4
|
+
return ParentIpc.invoke('ElectronScreen.getWidth')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const getHeight = () => {
|
|
8
|
+
return ParentIpc.invoke('ElectronScreen.getHeight')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getBounds = () => {
|
|
12
|
+
return ParentIpc.invoke('ElectronScreen.getBounds')
|
|
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
|
-
}
|