@lvce-editor/shared-process 0.23.0 → 0.23.2
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/ElectronBrowserView/ElectronBrowserView.js +17 -6
- package/src/parts/ElectronBrowserViewFunctions/ElectronBrowserViewFunctions.js +11 -18
- package/src/parts/ElectronBrowserViewIpcState/ElectronBrowserViewIpcState.js +19 -0
- package/src/parts/ElectronBrowserViewState/ElectronBrowserViewState.js +15 -0
- package/src/parts/ElectronWebContents/ElectronWebContents.ipc.js +14 -0
- package/src/parts/ElectronWebContents/ElectronWebContents.js +73 -0
- package/src/parts/ElectronWindow/ElectronWindow.ipc.js +3 -2
- package/src/parts/ElectronWindow/ElectronWindow.js +9 -0
- package/src/parts/Module/Module.js +2 -0
- package/src/parts/ModuleId/ModuleId.js +1 -0
- package/src/parts/ModuleMap/ModuleMap.js +11 -2
- package/src/parts/Platform/Platform.js +3 -3
- package/src/parts/RequiresSocket/RequiresSocket.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lvce-editor/assert": "^1.2.0",
|
|
21
|
-
"@lvce-editor/extension-host-helper-process": "0.23.
|
|
21
|
+
"@lvce-editor/extension-host-helper-process": "0.23.2",
|
|
22
22
|
"@lvce-editor/ipc": "^2.1.0",
|
|
23
23
|
"@lvce-editor/json-rpc": "^1.0.0",
|
|
24
24
|
"@lvce-editor/jsonc-parser": "^1.1.0",
|
|
25
|
-
"@lvce-editor/pretty-error": "^1.
|
|
26
|
-
"@lvce-editor/pty-host": "0.23.
|
|
25
|
+
"@lvce-editor/pretty-error": "^1.5.0",
|
|
26
|
+
"@lvce-editor/pty-host": "0.23.2",
|
|
27
27
|
"@lvce-editor/verror": "^1.1.2",
|
|
28
28
|
"@lvce-editor/web-socket-server": "^1.1.0",
|
|
29
29
|
"debug": "^4.3.4",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"got": "^13.0.0",
|
|
33
33
|
"is-object": "^1.0.2",
|
|
34
34
|
"p-queue": "^8.0.1",
|
|
35
|
-
"tar-fs": "^3.0.
|
|
35
|
+
"tar-fs": "^3.0.5",
|
|
36
36
|
"xdg-basedir": "^5.1.0"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import * as ElectronBrowserViewIpcState from '../ElectronBrowserViewIpcState/ElectronBrowserViewIpcState.js'
|
|
2
|
+
import * as ElectronBrowserViewState from '../ElectronBrowserViewState/ElectronBrowserViewState.js'
|
|
3
|
+
import * as ElectronWebContents from '../ElectronWebContents/ElectronWebContents.js'
|
|
1
4
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
5
|
|
|
3
|
-
export const createBrowserView = (restoreId, fallthroughKeyBindings) => {
|
|
4
|
-
|
|
6
|
+
export const createBrowserView = async (ipc, restoreId, fallthroughKeyBindings) => {
|
|
7
|
+
const webContentsId = await ParentIpc.invoke('ElectronBrowserView.createBrowserView2', restoreId)
|
|
8
|
+
ElectronBrowserViewIpcState.add(webContentsId, ipc)
|
|
9
|
+
// TODO get window id from renderer worker
|
|
10
|
+
await ParentIpc.invoke('ElectronBrowserView.attachEventListeners', webContentsId)
|
|
11
|
+
await ParentIpc.invoke('ElectronBrowserViewFunctions.setBackgroundColor', webContentsId, 'white')
|
|
12
|
+
return webContentsId
|
|
5
13
|
}
|
|
6
14
|
|
|
7
|
-
export const disposeBrowserView = (id) => {
|
|
8
|
-
|
|
15
|
+
export const disposeBrowserView = async (id) => {
|
|
16
|
+
ElectronBrowserViewState.remove(id)
|
|
17
|
+
await ParentIpc.invoke('ElectronBrowserView.disposeBrowserView', id)
|
|
18
|
+
await ElectronWebContents.dispose(id)
|
|
9
19
|
}
|
|
10
20
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
21
|
+
export const handleBrowserViewCreated = (id) => {
|
|
22
|
+
console.log('created', id)
|
|
23
|
+
ElectronBrowserViewState.add(id)
|
|
13
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
2
|
+
import * as ElectronWebContents from '../ElectronWebContents/ElectronWebContents.js'
|
|
2
3
|
|
|
3
4
|
export const resizeBrowserView = (id, x, y, width, height) => {
|
|
4
5
|
return ParentIpc.invoke('ElectronBrowserViewFunctions.resizeBrowserView', id, x, y, width, height)
|
|
@@ -8,25 +9,19 @@ export const setIframeSrc = async (id, iframeSrc) => {
|
|
|
8
9
|
return ParentIpc.invoke('ElectronBrowserViewFunctions.setIframeSrc', id, iframeSrc)
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
return ParentIpc.invoke('
|
|
12
|
+
const callFunction = (id, functionName) => {
|
|
13
|
+
return ParentIpc.invoke('ElectronWebContents.callFunction', id, functionName)
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const
|
|
16
|
-
return ParentIpc.invoke('ElectronBrowserViewFunctions.openDevtools', id)
|
|
17
|
-
}
|
|
16
|
+
export const focus = ElectronWebContents.focus
|
|
18
17
|
|
|
19
|
-
export const
|
|
20
|
-
return ParentIpc.invoke('ElectronBrowserViewFunctions.reload', id)
|
|
21
|
-
}
|
|
18
|
+
export const openDevtools = ElectronWebContents.openDevtools
|
|
22
19
|
|
|
23
|
-
export const
|
|
24
|
-
return ParentIpc.invoke('ElectronBrowserViewFunctions.forward', id)
|
|
25
|
-
}
|
|
20
|
+
export const reload = ElectronWebContents.reload
|
|
26
21
|
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
export const forward = ElectronWebContents.forward
|
|
23
|
+
|
|
24
|
+
export const backward = ElectronWebContents.backward
|
|
30
25
|
|
|
31
26
|
export const cancelNavigation = (id) => {
|
|
32
27
|
return ParentIpc.invoke('ElectronBrowserViewFunctions.cancelNavigation', id)
|
|
@@ -40,9 +35,7 @@ export const hide = (id) => {
|
|
|
40
35
|
return ParentIpc.invoke('ElectronBrowserViewFunctions.hide', id)
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
export const inspectElement =
|
|
44
|
-
return ParentIpc.invoke('ElectronBrowserViewFunctions.inspectElement', id, x, y)
|
|
45
|
-
}
|
|
38
|
+
export const inspectElement = ElectronWebContents.inspectElement
|
|
46
39
|
|
|
47
40
|
export const copyImageAt = (id, x, y) => {
|
|
48
41
|
return ParentIpc.invoke('ElectronBrowserViewFunctions.copyImageAt', id, x, y)
|
|
@@ -53,5 +46,5 @@ export const setFallthroughKeyBindings = (fallthroughKeyBindings) => {
|
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
export const getStats = (id) => {
|
|
56
|
-
return ParentIpc.invoke('
|
|
49
|
+
return ParentIpc.invoke('ElectronWebContents.getStats', id)
|
|
57
50
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const state = {
|
|
2
|
+
ipcMap: Object.create(null),
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const add = (id, ipc) => {
|
|
6
|
+
state.ipcMap[id] = ipc
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const get = (id) => {
|
|
10
|
+
return state.ipcMap[id]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const remove = (id) => {
|
|
14
|
+
delete state.ipcMap[id]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getAll = () => {
|
|
18
|
+
return Object.values(state.ipcMap)
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const state = {
|
|
2
|
+
browserViews: Object.create(null),
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const add = (id) => {
|
|
6
|
+
state.browserViews[id] = id
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const remove = (id) => {
|
|
10
|
+
delete state.browserViews[id]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const getAll = () => {
|
|
14
|
+
return Object.values(state.browserViews)
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as ElectronWebContents from './ElectronWebContents.js'
|
|
2
|
+
|
|
3
|
+
export const name = 'ElectronWebContents'
|
|
4
|
+
|
|
5
|
+
export const Commands = {
|
|
6
|
+
dispose: ElectronWebContents.dispose,
|
|
7
|
+
handleKeyBinding: ElectronWebContents.handleKeyBinding,
|
|
8
|
+
handleWindowOpen: ElectronWebContents.handleWindowOpen,
|
|
9
|
+
handleWillNavigate: ElectronWebContents.handleWillNavigate,
|
|
10
|
+
handleDidNavigate: ElectronWebContents.handleDidNavigate,
|
|
11
|
+
handleContextMenu: ElectronWebContents.handleContextMenu,
|
|
12
|
+
handleTitleUpdated: ElectronWebContents.handleTitleUpdated,
|
|
13
|
+
handleBrowserViewDestroyed: ElectronWebContents.handleBrowserViewDestroyed, // TODO rename to webcontents
|
|
14
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as ElectronBrowserViewIpcState from '../ElectronBrowserViewIpcState/ElectronBrowserViewIpcState.js'
|
|
2
|
+
import * as ElectronBrowserViewState from '../ElectronBrowserViewState/ElectronBrowserViewState.js'
|
|
3
|
+
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
4
|
+
|
|
5
|
+
export const dispose = async (id) => {
|
|
6
|
+
await ParentIpc.invoke('ElectronWebContents.dispose', id)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const callFunction = (webContentsId, method, ...params) => {
|
|
10
|
+
return ParentIpc.invoke(`ElectronWebContents.callFunction`, webContentsId, method, ...params)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const focus = (webContentsId) => {
|
|
14
|
+
return callFunction(webContentsId, 'focus')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const openDevtools = (webContentsId) => {
|
|
18
|
+
return callFunction(webContentsId, 'openDevTools')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const reload = (webContentsId) => {
|
|
22
|
+
return callFunction(webContentsId, 'reload')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const forward = (webContentsId) => {
|
|
26
|
+
return callFunction(webContentsId, 'goForward')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const backward = (webContentsId) => {
|
|
30
|
+
return callFunction(webContentsId, 'goBack')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const inspectElement = (webContentsId, x, y) => {
|
|
34
|
+
return callFunction(webContentsId, `inspectElement`, x, y)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const handleWindowOpen = (webContentsId, url) => {
|
|
38
|
+
// TODO
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const forwardEvent = (method, webContentsId, ...params) => {
|
|
42
|
+
const ipc = ElectronBrowserViewIpcState.get(webContentsId)
|
|
43
|
+
if (!ipc) {
|
|
44
|
+
console.log('no ipc', { webContentsId })
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
ipc.send({
|
|
48
|
+
jsonrpc: '2.0',
|
|
49
|
+
method: `SimpleBrowser.${method}`,
|
|
50
|
+
params,
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const handleWillNavigate = (...args) => {
|
|
55
|
+
return forwardEvent('handleWillNavigate', ...args)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const handleDidNavigate = (...args) => {
|
|
59
|
+
return forwardEvent('handleDidNavigate', ...args)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const handleContextMenu = (...args) => {
|
|
63
|
+
return forwardEvent('handleContextMenu', ...args)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const handleTitleUpdated = (...args) => {
|
|
67
|
+
return forwardEvent('handleTitleUpdated', ...args)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const handleBrowserViewDestroyed = (id) => {
|
|
71
|
+
ElectronBrowserViewState.remove(id)
|
|
72
|
+
ElectronBrowserViewIpcState.remove(id)
|
|
73
|
+
}
|
|
@@ -4,14 +4,15 @@ export const name = 'ElectronWindow'
|
|
|
4
4
|
|
|
5
5
|
export const Commands = {
|
|
6
6
|
close: ElectronWindow.close,
|
|
7
|
+
focus: ElectronWindow.focus,
|
|
8
|
+
getZoom: ElectronWindow.getZoom,
|
|
7
9
|
maximize: ElectronWindow.maximize,
|
|
8
10
|
minimize: ElectronWindow.minimize,
|
|
11
|
+
openNew: ElectronWindow.openNew,
|
|
9
12
|
reload: ElectronWindow.reload,
|
|
10
13
|
toggleDevtools: ElectronWindow.toggleDevtools,
|
|
11
14
|
unmaximize: ElectronWindow.unmaximize,
|
|
12
15
|
zoomIn: ElectronWindow.zoomIn,
|
|
13
16
|
zoomOut: ElectronWindow.zoomOut,
|
|
14
17
|
zoomReset: ElectronWindow.zoomReset,
|
|
15
|
-
openNew: ElectronWindow.openNew,
|
|
16
|
-
focus: ElectronWindow.focus,
|
|
17
18
|
}
|
|
@@ -92,6 +92,11 @@ export const zoomReset = (windowId) => {
|
|
|
92
92
|
return setZoom(windowId, getDefaultZoomLevel(), getMinZoomLevel(), getMaxZoomLevel())
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
export const getZoom = (windowId) => {
|
|
96
|
+
// TODO zoom level should be stored in shared process
|
|
97
|
+
return ParentIpc.invoke('ElectronWindow.getZoom', windowId)
|
|
98
|
+
}
|
|
99
|
+
|
|
95
100
|
export const focus = (windowId) => {
|
|
96
101
|
return ParentIpc.invoke('ElectronWindow.executeWebContentsFunction', windowId, 'focus')
|
|
97
102
|
}
|
|
@@ -99,3 +104,7 @@ export const focus = (windowId) => {
|
|
|
99
104
|
export const handleClose = (windowId) => {
|
|
100
105
|
// TODO
|
|
101
106
|
}
|
|
107
|
+
|
|
108
|
+
export const getFocusedWindowId = () => {
|
|
109
|
+
return ParentIpc.invoke('ElectronWindow.getFocusedWindowId')
|
|
110
|
+
}
|
|
@@ -140,6 +140,8 @@ export const load = (moduleId) => {
|
|
|
140
140
|
return import('../HandleRemoteRequest/HandleRemoteRequest.ipc.js')
|
|
141
141
|
case ModuleId.HandleMessagePortForExtensionHostHelperProcess:
|
|
142
142
|
return import('../HandleMessagePortForExtensionHostHelperProcess/HandleMessagePortForExtensionHostHelperProcess.ipc.js')
|
|
143
|
+
case ModuleId.ElectronWebContents:
|
|
144
|
+
return import('../ElectronWebContents/ElectronWebContents.ipc.js')
|
|
143
145
|
default:
|
|
144
146
|
throw new Error(`module ${moduleId} not found`)
|
|
145
147
|
}
|
|
@@ -261,16 +261,17 @@ export const getModuleId = (commandId) => {
|
|
|
261
261
|
case 'WebSocketServer.handleUpgrade':
|
|
262
262
|
return ModuleId.WebSocketServer
|
|
263
263
|
case 'ElectronWindow.close':
|
|
264
|
+
case 'ElectronWindow.focus':
|
|
265
|
+
case 'ElectronWindow.getZoom':
|
|
264
266
|
case 'ElectronWindow.maximize':
|
|
265
267
|
case 'ElectronWindow.minimize':
|
|
268
|
+
case 'ElectronWindow.openNew':
|
|
266
269
|
case 'ElectronWindow.reload':
|
|
267
270
|
case 'ElectronWindow.toggleDevtools':
|
|
268
271
|
case 'ElectronWindow.unmaximize':
|
|
269
272
|
case 'ElectronWindow.zoomIn':
|
|
270
273
|
case 'ElectronWindow.zoomOut':
|
|
271
274
|
case 'ElectronWindow.zoomReset':
|
|
272
|
-
case 'ElectronWindow.focus':
|
|
273
|
-
case 'ElectronWindow.openNew':
|
|
274
275
|
return ModuleId.Window
|
|
275
276
|
case 'Workspace.getHomeDir':
|
|
276
277
|
case 'Workspace.resolveRoot':
|
|
@@ -295,6 +296,14 @@ export const getModuleId = (commandId) => {
|
|
|
295
296
|
return ModuleId.HandleRemoteRequest
|
|
296
297
|
case 'HandleMessagePortForExtensionHostHelperProcess.handleMessagePortForExtensionHostHelperProcess':
|
|
297
298
|
return ModuleId.HandleMessagePortForExtensionHostHelperProcess
|
|
299
|
+
case 'ElectronWebContents.dispose':
|
|
300
|
+
case 'ElectronWebContents.handleKeyBinding':
|
|
301
|
+
case 'ElectronWebContents.handleWindowOpen':
|
|
302
|
+
case 'ElectronWebContents.handleWillNavigate':
|
|
303
|
+
case 'ElectronWebContents.handleDidNavigate':
|
|
304
|
+
case 'ElectronWebContents.handleContextMenu':
|
|
305
|
+
case 'ElectronWebContents.handlePageTitleUpdated':
|
|
306
|
+
return ModuleId.ElectronWebContents
|
|
298
307
|
default:
|
|
299
308
|
throw new CommandNotFoundError(commandId)
|
|
300
309
|
}
|
|
@@ -61,11 +61,11 @@ export const getSetupName = () => {
|
|
|
61
61
|
return 'Lvce-Setup'
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export const version = '0.23.
|
|
64
|
+
export const version = '0.23.2'
|
|
65
65
|
|
|
66
|
-
export const commit = '
|
|
66
|
+
export const commit = '40414a1'
|
|
67
67
|
|
|
68
|
-
export const date = '2024-02-
|
|
68
|
+
export const date = '2024-02-12T18:48:06.000Z'
|
|
69
69
|
|
|
70
70
|
export const getVersion = () => {
|
|
71
71
|
return version
|
|
@@ -11,6 +11,7 @@ const METHODS_THAT_REQUIRE_SOCKET = new Set([
|
|
|
11
11
|
'ElectronApplicationMenu.setItems',
|
|
12
12
|
'GetWindowId.getWindowId',
|
|
13
13
|
'HandleMessagePortForExtensionHostHelperProcess.handleMessagePortForExtensionHostHelperProcess',
|
|
14
|
+
'ElectronBrowserView.createBrowserView',
|
|
14
15
|
])
|
|
15
16
|
|
|
16
17
|
export const requiresSocket = (method) => {
|