@lvce-editor/about-view 2.3.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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);
@@ -800,15 +800,15 @@ const WebWorkerRpcClient = {
800
800
  };
801
801
 
802
802
  const None = 0;
803
- const Ok = 1;
804
- const Copy = 2;
803
+ const Ok$1 = 1;
804
+ const Copy$1 = 2;
805
805
 
806
806
  const getNextFocus = focusId => {
807
807
  switch (focusId) {
808
- case Ok:
809
- return Copy;
810
- case Copy:
811
- return Ok;
808
+ case Ok$1:
809
+ return Copy$1;
810
+ case Copy$1:
811
+ return Ok$1;
812
812
  default:
813
813
  return None;
814
814
  }
@@ -826,10 +826,10 @@ const focusNext = state => {
826
826
 
827
827
  const getPreviousFocus = focusId => {
828
828
  switch (focusId) {
829
- case Ok:
830
- return Copy;
831
- case Copy:
832
- return Ok;
829
+ case Ok$1:
830
+ return Copy$1;
831
+ case Copy$1:
832
+ return Ok$1;
833
833
  default:
834
834
  return None;
835
835
  }
@@ -846,13 +846,12 @@ const focusPrevious = state => {
846
846
  };
847
847
 
848
848
  const emptyObject = {};
849
- const RE_PLACEHOLDER = /{(PH\d+)}/g;
849
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
850
850
  const i18nString = (key, placeholders = emptyObject) => {
851
851
  if (placeholders === emptyObject) {
852
852
  return key;
853
853
  }
854
854
  const replacer = (match, rest) => {
855
- // @ts-ignore
856
855
  return placeholders[rest];
857
856
  };
858
857
  return key.replaceAll(RE_PLACEHOLDER, replacer);
@@ -1165,7 +1164,7 @@ const getV8Version = () => {
1165
1164
  const getDate = () => {
1166
1165
  return date;
1167
1166
  };
1168
- const productNameLong = 'Lvce Editor - OSS';
1167
+ const productNameLong$1 = 'Lvce Editor - OSS';
1169
1168
 
1170
1169
  const getDetailString = async () => {
1171
1170
  const [electronVersion, nodeVersion, chromeVersion, version, commit, v8Version, date] = await Promise.all([getElectronVersion(), getNodeVersion(), getChromeVersion(), getVersion(), getCommit(), getV8Version(), getDate()]);
@@ -1260,26 +1259,31 @@ const mergeClassNames = (...classNames) => {
1260
1259
  return joinBySpace(...classNames.filter(Boolean));
1261
1260
  };
1262
1261
 
1263
- const getPrimaryButtonVirtualDom = (message, onClick) => {
1262
+ const getPrimaryButtonVirtualDom = (message, onClick, name) => {
1264
1263
  return [{
1265
1264
  type: Button$1,
1266
1265
  className: mergeClassNames(Button$2, ButtonPrimary),
1267
1266
  onClick,
1268
- childCount: 1
1267
+ childCount: 1,
1268
+ name
1269
1269
  }, text(message)];
1270
1270
  };
1271
- const getSecondaryButtonVirtualDom = (message, onClick) => {
1271
+ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
1272
1272
  return [{
1273
1273
  type: Button$1,
1274
1274
  className: mergeClassNames(Button$2, ButtonSecondary),
1275
1275
  onClick,
1276
- childCount: 1
1276
+ childCount: 1,
1277
+ name
1277
1278
  }, text(message)];
1278
1279
  };
1279
1280
 
1280
1281
  const DialogIcon = 'DialogIcon';
1281
1282
  const DialogHeading = 'DialogHeading';
1282
1283
 
1284
+ const Ok = 'Ok';
1285
+ const Copy = 'Copy';
1286
+
1283
1287
  const Focusable = -1;
1284
1288
 
1285
1289
  const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copyMessage, productName) => {
@@ -1330,7 +1334,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
1330
1334
  type: Div,
1331
1335
  className: DialogButtonsRow,
1332
1336
  childCount: 2
1333
- }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy)];
1337
+ }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy)];
1334
1338
  return dom;
1335
1339
  };
1336
1340
 
@@ -1371,9 +1375,9 @@ const loadContent = state => {
1371
1375
  const lines = getDetailStringWeb();
1372
1376
  return {
1373
1377
  ...state,
1374
- productName: productNameLong,
1378
+ productName: productNameLong$1,
1375
1379
  lines,
1376
- focusId: Ok
1380
+ focusId: Ok$1
1377
1381
  };
1378
1382
  };
1379
1383
 
@@ -1406,10 +1410,10 @@ const closeDialog = () => {
1406
1410
 
1407
1411
  const getFocusSelector = focusId => {
1408
1412
  switch (focusId) {
1409
- case Copy:
1410
- return '.ButtonPrimary';
1411
- case Ok:
1412
- return '.ButtonSecondary';
1413
+ case Copy$1:
1414
+ return Copy;
1415
+ case Ok$1:
1416
+ return Ok;
1413
1417
  default:
1414
1418
  return '';
1415
1419
  }
@@ -1433,8 +1437,8 @@ const renderFocus = {
1433
1437
  return oldState.focusId === newState.focusId;
1434
1438
  },
1435
1439
  apply(oldState, newState) {
1436
- const selector = getFocusSelector(newState.focusId);
1437
- return ['setFocused', selector];
1440
+ const name = getFocusSelector(newState.focusId);
1441
+ return ['Viewlet.focusElementByName', name];
1438
1442
  }
1439
1443
  };
1440
1444
  const render = [renderDialog, renderFocus];
@@ -1468,6 +1472,63 @@ const renderEventListers = () => {
1468
1472
  }];
1469
1473
  };
1470
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
+
1471
1532
  const commandMap = {
1472
1533
  'About.focusNext': focusNext,
1473
1534
  'About.focusPrevious': focusPrevious,
@@ -1477,13 +1538,15 @@ const commandMap = {
1477
1538
  'About.getVirtualDom': getAboutVirtualDom,
1478
1539
  'About.loadContent': loadContent,
1479
1540
  'About.render': doRender,
1480
- 'About.renderEventListeners': renderEventListers
1541
+ 'About.renderEventListeners': renderEventListers,
1542
+ 'About.showAboutElectron': showAboutElectron
1481
1543
  };
1482
1544
 
1483
1545
  const listen = async () => {
1484
- await WebWorkerRpcClient.create({
1546
+ const rpc = await WebWorkerRpcClient.create({
1485
1547
  commandMap: commandMap
1486
1548
  });
1549
+ setRpc(rpc);
1487
1550
  };
1488
1551
 
1489
1552
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "",
5
5
  "main": "dist/aboutWorkerMain.js",
6
6
  "type": "module",