@lvce-editor/embeds-process 3.4.0 → 4.1.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.
@@ -15,30 +15,48 @@ const getAll = () => {
15
15
  };
16
16
 
17
17
  const rpcs = Object.create(null);
18
- const set$5 = (id, rpc) => {
18
+ const set$7 = (id, rpc) => {
19
19
  rpcs[id] = rpc;
20
20
  };
21
21
  const get$1 = id => {
22
22
  return rpcs[id];
23
23
  };
24
+
25
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
26
+
27
+ const create$6 = rpcId => {
28
+ return {
29
+ // @ts-ignore
30
+ invoke(method, ...params) {
31
+ const rpc = get$1(rpcId);
32
+ // @ts-ignore
33
+ return rpc.invoke(method, ...params);
34
+ },
35
+ // @ts-ignore
36
+ invokeAndTransfer(method, ...params) {
37
+ const rpc = get$1(rpcId);
38
+ // @ts-ignore
39
+ return rpc.invokeAndTransfer(method, ...params);
40
+ },
41
+ set(rpc) {
42
+ set$7(rpcId, rpc);
43
+ }
44
+ };
45
+ };
24
46
  const MainProcess$1 = -5;
25
47
  const SharedProcess$1 = 1;
26
- const invoke$3 = (method, ...params) => {
27
- const rpc = get$1(MainProcess$1);
28
- // @ts-ignore
29
- return rpc.invoke(method, ...params);
30
- };
31
- const set$3 = rpc => {
32
- set$5(MainProcess$1, rpc);
33
- };
48
+ const {
49
+ invoke: invoke$3,
50
+ set: set$3
51
+ } = create$6(MainProcess$1);
34
52
  const MainProcess$2 = {
35
53
  __proto__: null,
36
54
  invoke: invoke$3,
37
55
  set: set$3
38
56
  };
39
- const set$4 = rpc => {
40
- set$5(SharedProcess$1, rpc);
41
- };
57
+ const {
58
+ set: set$4
59
+ } = create$6(SharedProcess$1);
42
60
  const SharedProcess$2 = {
43
61
  __proto__: null,
44
62
  set: set$4
@@ -1460,7 +1478,9 @@ const targetMessagePort$2 = async (messagePort, message) => {
1460
1478
  commandMap: commandMapRef
1461
1479
  });
1462
1480
  // @ts-ignore
1463
- const ipc = rpc.ipc;
1481
+ const {
1482
+ ipc
1483
+ } = rpc;
1464
1484
  ipc.addEventListener('close', handleIpcClosed);
1465
1485
  return rpc;
1466
1486
  };
@@ -1525,16 +1545,20 @@ const HandleIpcSharedProcess = {
1525
1545
  const EmbedsWorker = 77;
1526
1546
  const MainProcess = -5;
1527
1547
  const SharedProcess = 1;
1548
+ const EmbedsWorkerAlt = 208;
1528
1549
 
1529
1550
  const getModule = ipcId => {
1530
1551
  number(ipcId);
1531
1552
  switch (ipcId) {
1532
1553
  case SharedProcess:
1533
1554
  return HandleIpcSharedProcess;
1555
+ // deprecated
1534
1556
  case EmbedsWorker:
1557
+ case EmbedsWorkerAlt:
1535
1558
  return HandleIpcEmbedsWorker;
1536
1559
  case MainProcess:
1537
1560
  return HandleIpcMainProcess;
1561
+ // deprecated
1538
1562
  default:
1539
1563
  throw new Error(`Embeds process encountered unexpected incoming ipc ${ipcId}`);
1540
1564
  }
@@ -1559,6 +1583,23 @@ const handleElectronMessagePort = async (messagePort, ipcId) => {
1559
1583
  return handleIncomingIpc(ipcId, messagePort, {});
1560
1584
  };
1561
1585
 
1586
+ const createMainProcessRpc = async port => {
1587
+ try {
1588
+ const rpc = await ElectronMessagePortRpcClient.create({
1589
+ commandMap: {},
1590
+ messagePort: port
1591
+ });
1592
+ return rpc;
1593
+ } catch (error) {
1594
+ throw new VError(error, `Failed to create main process rpc`);
1595
+ }
1596
+ };
1597
+
1598
+ const initialize = async port => {
1599
+ const rpc = await createMainProcessRpc(port);
1600
+ set$2(rpc);
1601
+ };
1602
+
1562
1603
  const commandMap = {
1563
1604
  'ElectronWebContents.handleBrowserViewDestroyed': handleBrowserViewDestroyed,
1564
1605
  'ElectronWebContents.handleContextMenu': handleContextMenu,
@@ -1583,7 +1624,8 @@ const commandMap = {
1583
1624
  'ElectronWebContentsView.setIframeSrc': setIframeSrc,
1584
1625
  'ElectronWebContentsView.setIframeSrcFallback': setIframeSrcFallback,
1585
1626
  'ElectronWebContentsView.show': show,
1586
- 'HandleElectronMessagePort.handleElectronMessagePort': handleElectronMessagePort
1627
+ 'HandleElectronMessagePort.handleElectronMessagePort': handleElectronMessagePort,
1628
+ 'Initialize.initialize': initialize
1587
1629
  };
1588
1630
 
1589
1631
  const listen = async argv => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/embeds-process",
3
- "version": "3.4.0",
3
+ "version": "4.1.0",
4
4
  "description": "Embeds Process",
5
5
  "keywords": [
6
6
  "Lvce Editor"