@lvce-editor/embeds-process 2.2.0 → 3.0.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/bin/embedsProcess.js +3 -0
- package/dist/embedsProcessMain.js +1619 -0
- package/package.json +17 -50
- package/src/embedsProcessMain.js +0 -3
- package/src/parts/ApplyIncomingIpcResponse/ApplyIncomingIpcResponse.js +0 -11
- package/src/parts/Assert/Assert.js +0 -1
- package/src/parts/Callback/Callback.js +0 -1
- package/src/parts/Command/Command.js +0 -9
- package/src/parts/CommandMap/CommandMap.js +0 -27
- package/src/parts/CommandState/CommandState.js +0 -21
- package/src/parts/ElectronWebContents/ElectronWebContents.js +0 -77
- package/src/parts/ElectronWebContentsView/ElectronWebContentsView.js +0 -68
- package/src/parts/ElectronWebContentsViewIpcState/ElectronWebContentsViewIpcState.js +0 -17
- package/src/parts/ElectronWebContentsViewState/ElectronWebContentsViewState.js +0 -13
- package/src/parts/HandleElectronMessagePort/HandleElectronMessagePort.js +0 -8
- package/src/parts/HandleIncomingIpc/HandleIncomingIpc.js +0 -15
- package/src/parts/HandleIncomingIpcMessagePort/HandleIncomingIpcMessagePort.js +0 -8
- package/src/parts/HandleIpc/HandleIpc.js +0 -5
- package/src/parts/HandleIpcClosed/HandleIpcClosed.js +0 -23
- package/src/parts/HandleIpcEmbedsWorker/HandleIpcEmbedsWorker.js +0 -20
- package/src/parts/HandleIpcMainProcess/HandleIpcMainProcess.js +0 -20
- package/src/parts/HandleIpcModule/HandleIpcModule.js +0 -19
- package/src/parts/HandleIpcSharedProcess/HandleIpcSharedProcess.js +0 -21
- package/src/parts/HandleMessage/HandleMessage.js +0 -19
- package/src/parts/IpcChild/IpcChild.js +0 -15
- package/src/parts/IpcChildModule/IpcChildModule.js +0 -25
- package/src/parts/IpcChildType/IpcChildType.js +0 -20
- package/src/parts/IpcId/IpcId.js +0 -9
- package/src/parts/JsonRpc/JsonRpc.js +0 -1
- package/src/parts/Listen/Listen.js +0 -10
- package/src/parts/Main/Main.js +0 -8
- package/src/parts/MainProcessIpc/MainProcessIpc.js +0 -20
- package/src/parts/ParentIpc/ParentIpc.js +0 -20
- package/src/parts/SharedProcessIpc/SharedProcessIpc.js +0 -20
package/package.json
CHANGED
|
@@ -1,58 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/embeds-process",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Embeds Process",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Lvce Editor"
|
|
7
|
+
],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lvce-editor/embeds-process.git"
|
|
9
11
|
},
|
|
10
|
-
"keywords": [],
|
|
11
|
-
"author": "",
|
|
12
12
|
"license": "MIT",
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"no-unused-vars": "off",
|
|
19
|
-
"unicorn/numeric-separators-style": "off",
|
|
20
|
-
"no-extra-semi": "off",
|
|
21
|
-
"arrow-body-style": "off",
|
|
22
|
-
"padded-blocks": "off",
|
|
23
|
-
"capitalized-comments": "off",
|
|
24
|
-
"padding-line-between-statements": "off",
|
|
25
|
-
"arrow-parens": "off",
|
|
26
|
-
"no-warning-comments": "off",
|
|
27
|
-
"array-bracket-spacing": "off",
|
|
28
|
-
"comma-spacing": "off",
|
|
29
|
-
"unicorn/no-array-callback-reference": "off",
|
|
30
|
-
"comma-dangle": "off",
|
|
31
|
-
"operator-linebreak": "off",
|
|
32
|
-
"no-case-declarations": "off",
|
|
33
|
-
"no-undef": "off",
|
|
34
|
-
"object-curly-spacing": "off",
|
|
35
|
-
"object-shorthand": "off",
|
|
36
|
-
"complexity": "off",
|
|
37
|
-
"no-labels": "off",
|
|
38
|
-
"no-multi-assign": "off",
|
|
39
|
-
"max-params": "off",
|
|
40
|
-
"no-bitwise": "off",
|
|
41
|
-
"unicorn/prefer-math-trunc": "off",
|
|
42
|
-
"no-await-in-loop": "off",
|
|
43
|
-
"unicorn/prefer-add-event-listener": "off",
|
|
44
|
-
"no-unused-expressions": "off",
|
|
45
|
-
"unicorn/better-regex": "off",
|
|
46
|
-
"unicorn/no-array-push-push": "off",
|
|
47
|
-
"unicorn/prevent-abbreviations": "off"
|
|
48
|
-
},
|
|
49
|
-
"ignores": [
|
|
50
|
-
"distmin"
|
|
51
|
-
]
|
|
13
|
+
"author": "Lvce Editor",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/embedsProcessMain.js",
|
|
16
|
+
"bin": {
|
|
17
|
+
"embeds-process": "bin/embedsProcess.js"
|
|
52
18
|
},
|
|
53
19
|
"dependencies": {
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
20
|
+
"execa": "^9.5.3"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22"
|
|
57
24
|
}
|
|
58
25
|
}
|
package/src/embedsProcessMain.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
2
|
-
|
|
3
|
-
export const applyIncomingIpcResponse = async (target, response, ipcId) => {
|
|
4
|
-
switch (response.type) {
|
|
5
|
-
case 'handle':
|
|
6
|
-
HandleIpc.handleIpc(target)
|
|
7
|
-
break
|
|
8
|
-
default:
|
|
9
|
-
throw new Error('unexpected response')
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lvce-editor/assert'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { resolve } from '@lvce-editor/json-rpc'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as ElectronWebContents from '../ElectronWebContents/ElectronWebContents.js'
|
|
2
|
-
import * as ElectronWebContentsView from '../ElectronWebContentsView/ElectronWebContentsView.js'
|
|
3
|
-
import * as HandleElectronMessagePort from '../HandleElectronMessagePort/HandleElectronMessagePort.js'
|
|
4
|
-
|
|
5
|
-
export const commandMap = {
|
|
6
|
-
'ElectronWebContentsView.backward': ElectronWebContents.backward,
|
|
7
|
-
'ElectronWebContentsView.createWebContentsView': ElectronWebContentsView.createWebContentsView,
|
|
8
|
-
'ElectronWebContentsView.disposeWebContentsView': ElectronWebContentsView.disposeWebContentsView,
|
|
9
|
-
'ElectronWebContentsView.focus': ElectronWebContents.focus,
|
|
10
|
-
'ElectronWebContentsView.forward': ElectronWebContents.forward,
|
|
11
|
-
'ElectronWebContentsView.getStats': ElectronWebContentsView.getStats,
|
|
12
|
-
'ElectronWebContentsView.inspectElement': ElectronWebContents.inspectElement,
|
|
13
|
-
'ElectronWebContentsView.openDevtools': ElectronWebContents.openDevtools,
|
|
14
|
-
'ElectronWebContentsView.reload': ElectronWebContents.reload,
|
|
15
|
-
'ElectronWebContentsView.resizeBrowserView': ElectronWebContentsView.resizeWebContentsView,
|
|
16
|
-
'ElectronWebContentsView.setIframeSrc': ElectronWebContentsView.setIframeSrc,
|
|
17
|
-
'ElectronWebContentsView.setIframeSrcFallback': ElectronWebContentsView.setIframeSrcFallback,
|
|
18
|
-
'ElectronWebContentsView.setFallthroughKeyBindings': ElectronWebContentsView.setFallthroughKeyBindings,
|
|
19
|
-
'ElectronWebContentsView.handleKeyBinding': ElectronWebContentsView.handleKeyBinding,
|
|
20
|
-
'ElectronWebContentsView.show': ElectronWebContentsView.show,
|
|
21
|
-
'ElectronWebContents.handleDidNavigate': ElectronWebContentsView.handleDidNavigate,
|
|
22
|
-
'ElectronWebContents.handleTitleUpdated': ElectronWebContentsView.handleTitleUpdated,
|
|
23
|
-
'ElectronWebContents.handleBrowserViewDestroyed': ElectronWebContentsView.handleBrowserViewDestroyed,
|
|
24
|
-
'ElectronWebContents.handleWillNavigate': ElectronWebContentsView.handleWillNavigate,
|
|
25
|
-
'ElectronWebContents.handleContextMenu': ElectronWebContentsView.handleContextMenu,
|
|
26
|
-
'HandleElectronMessagePort.handleElectronMessagePort': HandleElectronMessagePort.handleElectronMessagePort,
|
|
27
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const commands = Object.create(null)
|
|
2
|
-
|
|
3
|
-
export const registerCommand = (key, fn) => {
|
|
4
|
-
commands[key] = fn
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const registerCommands = (commandMap) => {
|
|
8
|
-
for (const [key, value] of Object.entries(commandMap)) {
|
|
9
|
-
registerCommand(key, value)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const getCommand = (key) => {
|
|
14
|
-
return commands[key]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const reset = () => {
|
|
18
|
-
for (const key of Object.keys(commands)) {
|
|
19
|
-
delete commands[key]
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import * as ElectronWebContentsViewIpcState from '../ElectronWebContentsViewIpcState/ElectronWebContentsViewIpcState.js'
|
|
2
|
-
import * as ElectronWebContentsViewState from '../ElectronWebContentsViewState/ElectronWebContentsViewState.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 = ElectronWebContentsViewIpcState.get(webContentsId)
|
|
43
|
-
if (!ipc) {
|
|
44
|
-
console.log(`[shared-process] no ipc for webcontents ${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 handleKeyBinding = (...args) => {
|
|
71
|
-
forwardEvent('handleKeyBinding', ...args)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export const handleWebContentsViewDestroyed = (id) => {
|
|
75
|
-
ElectronWebContentsViewState.remove(id)
|
|
76
|
-
ElectronWebContentsViewIpcState.remove(id)
|
|
77
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as ElectronWebContents from '../ElectronWebContents/ElectronWebContents.js'
|
|
3
|
-
import * as ElectronWebContentsViewIpcState from '../ElectronWebContentsViewIpcState/ElectronWebContentsViewIpcState.js'
|
|
4
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
5
|
-
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
6
|
-
|
|
7
|
-
export const createWebContentsView = async (ipc, restoreId, fallthroughKeyBindings) => {
|
|
8
|
-
Assert.number(restoreId)
|
|
9
|
-
const webContentsId = await ParentIpc.invoke('ElectronWebContentsView.createWebContentsView', restoreId)
|
|
10
|
-
ElectronWebContentsViewIpcState.add(webContentsId, ipc)
|
|
11
|
-
// TODO get window id from renderer worker
|
|
12
|
-
await ParentIpc.invoke('ElectronWebContentsView.attachEventListeners', webContentsId)
|
|
13
|
-
await ParentIpc.invoke('ElectronWebContentsViewFunctions.setBackgroundColor', webContentsId, 'white')
|
|
14
|
-
return webContentsId
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const disposeWebContentsView = async (id) => {
|
|
18
|
-
await ParentIpc.invoke('ElectronWebContentsView.disposeWebContentsView', id)
|
|
19
|
-
await ElectronWebContents.dispose(id)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const resizeWebContentsView = async (id, ...args) => {
|
|
23
|
-
return ParentIpc.invoke('ElectronWebContentsViewFunctions.resizeBrowserView', id, ...args)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const setIframeSrc = async (id, ...args) => {
|
|
27
|
-
return ParentIpc.invoke('ElectronWebContentsViewFunctions.setIframeSrc', id, ...args)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const setIframeSrcFallback = async (id, ...args) => {
|
|
31
|
-
return ParentIpc.invoke('ElectronWebContentsViewFunctions.setIframeSrcFallback', id, ...args)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const setFallthroughKeyBindings = async (id, ...args) => {
|
|
35
|
-
return ParentIpc.invoke('ElectronWebContentsViewFunctions.setFallthroughKeyBindings', id, ...args)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const getStats = async (id, ...args) => {
|
|
39
|
-
return ParentIpc.invoke('ElectronWebContentsViewFunctions.getStats', id, ...args)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const show = async (id, ...args) => {
|
|
43
|
-
return ParentIpc.invoke('ElectronWebContentsViewFunctions.show', id, ...args)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const forwardIpcEvent =
|
|
47
|
-
(key) =>
|
|
48
|
-
(id, ...args) => {
|
|
49
|
-
const ipc = ElectronWebContentsViewIpcState.get(id)
|
|
50
|
-
if (!ipc) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
JsonRpc.send(ipc, key, id, ...args)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const handleDidNavigate = forwardIpcEvent('ElectronWebContentsView.handleDidNavigate')
|
|
57
|
-
|
|
58
|
-
export const handleTitleUpdated = forwardIpcEvent('ElectronWebContentsView.handleTitleUpdated')
|
|
59
|
-
|
|
60
|
-
export const handleWillNavigate = forwardIpcEvent('ElectronWebContentsView.handleWillNavigate')
|
|
61
|
-
|
|
62
|
-
export const handleContextMenu = forwardIpcEvent('ElectronWebContentsView.handleContextMenu')
|
|
63
|
-
|
|
64
|
-
export const handleKeyBinding = forwardIpcEvent('ElectronWebContentsView.handleKeyBinding')
|
|
65
|
-
|
|
66
|
-
export const handleBrowserViewDestroyed = (id, ...args) => {
|
|
67
|
-
// TODO send to embeds worker?
|
|
68
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const ipcMap = Object.create(null)
|
|
2
|
-
|
|
3
|
-
export const add = (id, ipc) => {
|
|
4
|
-
ipcMap[id] = ipc
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const get = (id) => {
|
|
8
|
-
return ipcMap[id]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const remove = (id) => {
|
|
12
|
-
delete ipcMap[id]
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const getAll = () => {
|
|
16
|
-
return Object.entries(ipcMap)
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const webContentViews = Object.create(null)
|
|
2
|
-
|
|
3
|
-
export const add = (id) => {
|
|
4
|
-
webContentViews[id] = id
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const remove = (id) => {
|
|
8
|
-
delete webContentViews[id]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const getAll = () => {
|
|
12
|
-
return Object.values(webContentViews)
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIncomingIpc from '../HandleIncomingIpc/HandleIncomingIpc.js'
|
|
3
|
-
|
|
4
|
-
export const handleElectronMessagePort = async (messagePort, ipcId) => {
|
|
5
|
-
Assert.object(messagePort)
|
|
6
|
-
Assert.number(ipcId)
|
|
7
|
-
return HandleIncomingIpc.handleIncomingIpc(ipcId, messagePort, {})
|
|
8
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as ApplyIncomingIpcResponse from '../ApplyIncomingIpcResponse/ApplyIncomingIpcResponse.js'
|
|
2
|
-
import * as Assert from '../Assert/Assert.js'
|
|
3
|
-
import * as HandleIncomingIpcMessagePort from '../HandleIncomingIpcMessagePort/HandleIncomingIpcMessagePort.js'
|
|
4
|
-
import * as HandleIpcModule from '../HandleIpcModule/HandleIpcModule.js'
|
|
5
|
-
|
|
6
|
-
const getIpcAndResponse = (module, handle, message) => {
|
|
7
|
-
return HandleIncomingIpcMessagePort.handleIncomingIpcMessagePort(module, handle, message)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const handleIncomingIpc = async (ipcId, handle, message) => {
|
|
11
|
-
Assert.number(ipcId)
|
|
12
|
-
const module = HandleIpcModule.getModule(ipcId)
|
|
13
|
-
const { target, response } = await getIpcAndResponse(module, handle, message)
|
|
14
|
-
await ApplyIncomingIpcResponse.applyIncomingIpcResponse(target, response, ipcId)
|
|
15
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as ElectronWebContentsView from '../ElectronWebContentsView/ElectronWebContentsView.js'
|
|
2
|
-
import * as ElectronWebContentsViewIpcState from '../ElectronWebContentsViewIpcState/ElectronWebContentsViewIpcState.js'
|
|
3
|
-
|
|
4
|
-
const getIdsToDispose = (ipc) => {
|
|
5
|
-
const entries = ElectronWebContentsViewIpcState.getAll()
|
|
6
|
-
const toDispose = []
|
|
7
|
-
|
|
8
|
-
for (const [id, value] of entries) {
|
|
9
|
-
if (value === ipc) {
|
|
10
|
-
toDispose.push(parseInt(id))
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return toDispose
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const handleIpcClosed = async (event) => {
|
|
17
|
-
const idsToDispose = getIdsToDispose(event.target)
|
|
18
|
-
for (const id of idsToDispose) {
|
|
19
|
-
ElectronWebContentsViewIpcState.remove(id)
|
|
20
|
-
await ElectronWebContentsView.disposeWebContentsView(id)
|
|
21
|
-
}
|
|
22
|
-
// SharedProcessIpc.send('HandleMessagePortForEmbedsProcess.handleEmbedsProcessIpcClosed')
|
|
23
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIpcClosed from '../HandleIpcClosed/HandleIpcClosed.js'
|
|
3
|
-
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
4
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
5
|
-
|
|
6
|
-
export const targetMessagePort = async (messagePort, message) => {
|
|
7
|
-
Assert.object(messagePort)
|
|
8
|
-
const ipc = await IpcChild.listen({
|
|
9
|
-
method: IpcChildType.ElectronMessagePort,
|
|
10
|
-
messagePort,
|
|
11
|
-
})
|
|
12
|
-
ipc.addEventListener('close', HandleIpcClosed.handleIpcClosed)
|
|
13
|
-
return ipc
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const upgradeMessagePort = () => {
|
|
17
|
-
return {
|
|
18
|
-
type: 'handle',
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
|
-
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
5
|
-
|
|
6
|
-
export const targetMessagePort = async (messagePort, message) => {
|
|
7
|
-
Assert.object(messagePort)
|
|
8
|
-
const ipc = await IpcChild.listen({
|
|
9
|
-
method: IpcChildType.ElectronMessagePort,
|
|
10
|
-
messagePort,
|
|
11
|
-
})
|
|
12
|
-
ParentIpc.state.ipc = ipc
|
|
13
|
-
return ipc
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const upgradeMessagePort = () => {
|
|
17
|
-
return {
|
|
18
|
-
type: 'handle',
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as HandleIpcEmbedsWorker from '../HandleIpcEmbedsWorker/HandleIpcEmbedsWorker.js'
|
|
3
|
-
import * as HandleIpcMainProcess from '../HandleIpcMainProcess/HandleIpcMainProcess.js'
|
|
4
|
-
import * as HandleIpcSharedProcess from '../HandleIpcSharedProcess/HandleIpcSharedProcess.js'
|
|
5
|
-
import * as IpcId from '../IpcId/IpcId.js'
|
|
6
|
-
|
|
7
|
-
export const getModule = (ipcId) => {
|
|
8
|
-
Assert.number(ipcId)
|
|
9
|
-
switch (ipcId) {
|
|
10
|
-
case IpcId.SharedProcess:
|
|
11
|
-
return HandleIpcSharedProcess
|
|
12
|
-
case IpcId.EmbedsWorker:
|
|
13
|
-
return HandleIpcEmbedsWorker
|
|
14
|
-
case IpcId.MainProcess:
|
|
15
|
-
return HandleIpcMainProcess
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(`Embeds process encountered unexpected incoming ipc ${ipcId}`)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as Assert from '../Assert/Assert.js'
|
|
2
|
-
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
|
-
import * as SharedProcessIpc from '../SharedProcessIpc/SharedProcessIpc.js'
|
|
5
|
-
|
|
6
|
-
export const targetMessagePort = async (messagePort, message) => {
|
|
7
|
-
Assert.object(messagePort)
|
|
8
|
-
// TODO don't listen directly, return type 'listen' and type 'set' with parameters
|
|
9
|
-
const ipc = await IpcChild.listen({
|
|
10
|
-
method: IpcChildType.ElectronMessagePort,
|
|
11
|
-
messagePort,
|
|
12
|
-
})
|
|
13
|
-
SharedProcessIpc.state.ipc = ipc
|
|
14
|
-
return ipc
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const upgradeMessagePort = () => {
|
|
18
|
-
return {
|
|
19
|
-
type: 'handle',
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as Callback from '../Callback/Callback.js'
|
|
2
|
-
import * as Command from '../Command/Command.js'
|
|
3
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
4
|
-
|
|
5
|
-
const prepare = (error) => {
|
|
6
|
-
return error
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const requiresSocket = (method) => {
|
|
10
|
-
return false
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const logError = (error, prettyError) => {
|
|
14
|
-
// handled by shared process
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const handleMessage = (event) => {
|
|
18
|
-
return JsonRpc.handleJsonRpcMessage(event.target, event.data, Command.execute, Callback.resolve, prepare, logError, requiresSocket)
|
|
19
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as IpcChildModule from '../IpcChildModule/IpcChildModule.js'
|
|
2
|
-
|
|
3
|
-
export const listen = async ({ method, ...params }) => {
|
|
4
|
-
const module = await IpcChildModule.getModule(method)
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
const rawIpc = await module.listen(params)
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
if (module.signal) {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
module.signal(rawIpc)
|
|
11
|
-
}
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
const ipc = module.wrap(rawIpc)
|
|
14
|
-
return ipc
|
|
15
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IpcChildWithElectronMessagePort,
|
|
3
|
-
IpcChildWithElectronUtilityProcess,
|
|
4
|
-
IpcChildWithNodeForkedProcess,
|
|
5
|
-
IpcChildWithNodeWorker,
|
|
6
|
-
IpcChildWithWebSocket,
|
|
7
|
-
} from '@lvce-editor/ipc'
|
|
8
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
9
|
-
|
|
10
|
-
export const getModule = (method) => {
|
|
11
|
-
switch (method) {
|
|
12
|
-
case IpcChildType.NodeForkedProcess:
|
|
13
|
-
return IpcChildWithNodeForkedProcess
|
|
14
|
-
case IpcChildType.NodeWorker:
|
|
15
|
-
return IpcChildWithNodeWorker
|
|
16
|
-
case IpcChildType.ElectronUtilityProcess:
|
|
17
|
-
return IpcChildWithElectronUtilityProcess
|
|
18
|
-
case IpcChildType.ElectronMessagePort:
|
|
19
|
-
return IpcChildWithElectronMessagePort
|
|
20
|
-
case IpcChildType.WebSocket:
|
|
21
|
-
return IpcChildWithWebSocket
|
|
22
|
-
default:
|
|
23
|
-
throw new Error('unexpected ipc type')
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const NodeWorker = 1
|
|
2
|
-
export const NodeForkedProcess = 2
|
|
3
|
-
export const ElectronUtilityProcess = 3
|
|
4
|
-
export const ElectronMessagePort = 4
|
|
5
|
-
export const NodeMessagePort = 5
|
|
6
|
-
export const WebSocket = 6
|
|
7
|
-
|
|
8
|
-
export const Auto = () => {
|
|
9
|
-
const { argv } = process
|
|
10
|
-
if (argv.includes('--ipc-type=node-worker')) {
|
|
11
|
-
return NodeWorker
|
|
12
|
-
}
|
|
13
|
-
if (argv.includes('--ipc-type=node-forked-process')) {
|
|
14
|
-
return NodeForkedProcess
|
|
15
|
-
}
|
|
16
|
-
if (argv.includes('--ipc-type=electron-utility-process')) {
|
|
17
|
-
return ElectronUtilityProcess
|
|
18
|
-
}
|
|
19
|
-
throw new Error(`[shared-process] unknown ipc type`)
|
|
20
|
-
}
|
package/src/parts/IpcId/IpcId.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const EmbedsProcess = 2
|
|
2
|
-
export const EmbedsWorker = 77
|
|
3
|
-
export const ExtensionHostHelperProcess = 3
|
|
4
|
-
export const MainProcess = -5
|
|
5
|
-
export const ProcessExplorer = 11
|
|
6
|
-
export const SearchProcess = 13
|
|
7
|
-
export const SharedProcess = 1
|
|
8
|
-
export const TerminalProcess = 7
|
|
9
|
-
export const Unknown = 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@lvce-editor/json-rpc'
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as HandleIpc from '../HandleIpc/HandleIpc.js'
|
|
2
|
-
import * as IpcChild from '../IpcChild/IpcChild.js'
|
|
3
|
-
import * as IpcChildType from '../IpcChildType/IpcChildType.js'
|
|
4
|
-
import * as ParentIpc from '../ParentIpc/ParentIpc.js'
|
|
5
|
-
|
|
6
|
-
export const listen = async () => {
|
|
7
|
-
const ipc = await IpcChild.listen({ method: IpcChildType.Auto() })
|
|
8
|
-
HandleIpc.handleIpc(ipc)
|
|
9
|
-
ParentIpc.state.ipc = ipc
|
|
10
|
-
}
|
package/src/parts/Main/Main.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as CommandMap from '../CommandMap/CommandMap.js'
|
|
2
|
-
import * as CommandState from '../CommandState/CommandState.js'
|
|
3
|
-
import * as Listen from '../Listen/Listen.js'
|
|
4
|
-
|
|
5
|
-
export const main = async () => {
|
|
6
|
-
CommandState.registerCommands(CommandMap.commandMap)
|
|
7
|
-
await Listen.listen()
|
|
8
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
2
|
-
|
|
3
|
-
export const state = {
|
|
4
|
-
/**
|
|
5
|
-
* @type {any}
|
|
6
|
-
*/
|
|
7
|
-
ipc: undefined,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const invoke = (method, ...params) => {
|
|
11
|
-
return JsonRpc.invoke(state.ipc, method, ...params)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const send = (method, ...params) => {
|
|
15
|
-
return JsonRpc.send(state.ipc, method, ...params)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const invokeAndTransfer = (method, transfer, ...params) => {
|
|
19
|
-
return JsonRpc.invokeAndTransfer(state.ipc, transfer, method, ...params)
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as JsonRpc from '../JsonRpc/JsonRpc.js'
|
|
2
|
-
|
|
3
|
-
export const state = {
|
|
4
|
-
/**
|
|
5
|
-
* @type {any}
|
|
6
|
-
*/
|
|
7
|
-
ipc: undefined,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const invoke = (method, ...params) => {
|
|
11
|
-
return JsonRpc.invoke(state.ipc, method, ...params)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const send = (method, ...params) => {
|
|
15
|
-
return JsonRpc.send(state.ipc, method, ...params)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const invokeAndTransfer = (method, transfer, ...params) => {
|
|
19
|
-
return JsonRpc.invokeAndTransfer(state.ipc, transfer, method, ...params)
|
|
20
|
-
}
|