@lvce-editor/shared-process 0.20.15 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.20.15",
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.20.15",
22
- "@lvce-editor/extension-host-helper-process": "0.20.15",
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.20.15",
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",
@@ -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 = async (preferencs, screenWidth, screenHeight) => {
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('Appwindow.createAppWindow2', windowOptions, parsedArgs, workingDirectory, url)
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,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 ParentIpc.invoke('AppWindow.openNew')
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
- export const open = () => {
4
- return ParentIpc.invoke('ElectronWindowProcessExplorer.open')
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,7 @@
1
+ import * as HandleElectronReady from './HandleElectronReady.js'
2
+
3
+ export const name = 'HandleElectronReady'
4
+
5
+ export const Commands = {
6
+ handleElectronReady: HandleElectronReady.handleElectronReady,
7
+ }
@@ -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,7 @@
1
+ import * as HandleWindowAllClosed from './HandleWindowAllClosed.js'
2
+
3
+ export const name = 'HandleWindowAllClosed'
4
+
5
+ export const Commands = {
6
+ handleWindowAllClosed: HandleWindowAllClosed.handleWindowAllClosed,
7
+ }
@@ -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
+ }
@@ -1,5 +1,3 @@
1
- import * as IsElectron from '../IsElectron/IsElectron.js'
2
-
3
1
  export const listen = () => {
4
2
  // @ts-ignore
5
3
  const parentPort = process.parentPort
@@ -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
  }
@@ -62,3 +62,5 @@ export const ElectronContentTracing = 55
62
62
  export const Os = 56
63
63
  export const ElectronNet = 57
64
64
  export const Screen = 58
65
+ export const HandleElectronReady = 59
66
+ export const HandleWindowAllClosed = 60
@@ -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.20.15'
56
+ export const version = '0.21.0'
57
57
 
58
- export const commit = '7202220'
58
+ export const commit = 'f639638'
59
59
 
60
- export const date = '2023-12-10T20:01:56.000Z'
60
+ export const date = '2023-12-12T05:33:21.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('Screen.getWidth')
4
+ return ParentIpc.invoke('ElectronScreen.getWidth')
5
5
  }
6
6
 
7
7
  export const getHeight = () => {
8
- return ParentIpc.invoke('Screen.getHeight')
8
+ return ParentIpc.invoke('ElectronScreen.getHeight')
9
9
  }
10
10
 
11
11
  export const getBounds = () => {
12
- return ParentIpc.invoke('Screen.getBounds')
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
- }
@@ -1,6 +0,0 @@
1
- import * as JsonRpcSuccessResponse from '../JsonRpcSuccessResponse/JsonSuccessResponse.js'
2
-
3
- export const getSuccessResponse = (message, result) => {
4
- const resultProperty = result ?? null
5
- return JsonRpcSuccessResponse.create(message, resultProperty)
6
- }