@lvce-editor/about-view 2.4.0 → 2.5.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.
@@ -6,17 +6,17 @@ const create$4 = (method, params) => {
6
6
  params
7
7
  };
8
8
  };
9
- const state = {
9
+ const state$1 = {
10
10
  callbacks: Object.create(null)
11
11
  };
12
12
  const set = (id, fn) => {
13
- state.callbacks[id] = fn;
13
+ state$1.callbacks[id] = fn;
14
14
  };
15
15
  const get = id => {
16
- return state.callbacks[id];
16
+ return state$1.callbacks[id];
17
17
  };
18
18
  const remove = id => {
19
- delete state.callbacks[id];
19
+ delete state$1.callbacks[id];
20
20
  };
21
21
  let id = 0;
22
22
  const create$3 = () => {
@@ -339,7 +339,7 @@ const send = (transport, method, ...params) => {
339
339
  const message = create$4(method, params);
340
340
  transport.send(message);
341
341
  };
342
- const invoke = (ipc, method, ...params) => {
342
+ const invoke$1 = (ipc, method, ...params) => {
343
343
  return invokeHelper(ipc, method, params, false);
344
344
  };
345
345
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -753,7 +753,7 @@ const createRpc = ipc => {
753
753
  send(ipc, method, ...params);
754
754
  },
755
755
  invoke(method, ...params) {
756
- return invoke(ipc, method, ...params);
756
+ return invoke$1(ipc, method, ...params);
757
757
  },
758
758
  invokeAndTransfer(method, ...params) {
759
759
  return invokeAndTransfer(ipc, method, ...params);
@@ -1164,7 +1164,7 @@ const getV8Version = () => {
1164
1164
  const getDate = () => {
1165
1165
  return date;
1166
1166
  };
1167
- const productNameLong = 'Lvce Editor - OSS';
1167
+ const productNameLong$1 = 'Lvce Editor - OSS';
1168
1168
 
1169
1169
  const getDetailString = async () => {
1170
1170
  const [electronVersion, nodeVersion, chromeVersion, version, commit, v8Version, date] = await Promise.all([getElectronVersion(), getNodeVersion(), getChromeVersion(), getVersion(), getCommit(), getV8Version(), getDate()]);
@@ -1375,7 +1375,7 @@ const loadContent = state => {
1375
1375
  const lines = getDetailStringWeb();
1376
1376
  return {
1377
1377
  ...state,
1378
- productName: productNameLong,
1378
+ productName: productNameLong$1,
1379
1379
  lines,
1380
1380
  focusId: Ok$1
1381
1381
  };
@@ -1472,6 +1472,63 @@ const renderEventListers = () => {
1472
1472
  }];
1473
1473
  };
1474
1474
 
1475
+ const state = {
1476
+ rpc: undefined
1477
+ };
1478
+ const invoke = (method, ...params) => {
1479
+ const rpc = state.rpc;
1480
+ // @ts-ignore
1481
+ return rpc.invoke(method, ...params);
1482
+ };
1483
+ const setRpc = rpc => {
1484
+ state.rpc = rpc;
1485
+ };
1486
+
1487
+ const writeText = async text => {
1488
+ await invoke('ClipBoard.writeText', /* text */text);
1489
+ };
1490
+
1491
+ const getWindowId = async () => {
1492
+ return invoke('GetWindowId.getWindowId');
1493
+ };
1494
+
1495
+ const productNameLong = 'Lvce Editor - OSS';
1496
+ const getProductNameLong = () => {
1497
+ return productNameLong;
1498
+ };
1499
+
1500
+ const showMessageBox = async options => {
1501
+ const productName = getProductNameLong();
1502
+ const windowId = await getWindowId();
1503
+ const finalOptions = {
1504
+ ...options,
1505
+ productName,
1506
+ windowId
1507
+ };
1508
+ return invoke('ElectronDialog.showMessageBox', finalOptions);
1509
+ };
1510
+
1511
+ const Info = 'info';
1512
+
1513
+ const showAboutElectron = async () => {
1514
+ const windowId = await getWindowId();
1515
+ const detail = await getDetailString();
1516
+ const productNameLong = getProductNameLong();
1517
+ const options = {
1518
+ windowId,
1519
+ message: productNameLong,
1520
+ buttons: [copy(), ok()],
1521
+ type: Info,
1522
+ detail
1523
+ };
1524
+ const index = await showMessageBox(options);
1525
+ switch (index) {
1526
+ case 0:
1527
+ await writeText(detail);
1528
+ break;
1529
+ }
1530
+ };
1531
+
1475
1532
  const commandMap = {
1476
1533
  'About.focusNext': focusNext,
1477
1534
  'About.focusPrevious': focusPrevious,
@@ -1481,13 +1538,15 @@ const commandMap = {
1481
1538
  'About.getVirtualDom': getAboutVirtualDom,
1482
1539
  'About.loadContent': loadContent,
1483
1540
  'About.render': doRender,
1484
- 'About.renderEventListeners': renderEventListers
1541
+ 'About.renderEventListeners': renderEventListers,
1542
+ 'About.showAboutElectron': showAboutElectron
1485
1543
  };
1486
1544
 
1487
1545
  const listen = async () => {
1488
- await WebWorkerRpcClient.create({
1546
+ const rpc = await WebWorkerRpcClient.create({
1489
1547
  commandMap: commandMap
1490
1548
  });
1549
+ setRpc(rpc);
1491
1550
  };
1492
1551
 
1493
1552
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "",
5
5
  "main": "dist/aboutWorkerMain.js",
6
6
  "type": "module",