@lvce-editor/about-view 4.6.0 → 4.8.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.
@@ -805,6 +805,42 @@ const WebWorkerRpcClient = {
805
805
  create
806
806
  };
807
807
 
808
+ const RenderFocus = 2;
809
+ const RenderAbout = 3;
810
+
811
+ const diffType$1 = RenderAbout;
812
+ const isEqual$1 = (oldState, newState) => {
813
+ return oldState.productName === newState.productName && oldState.lines === newState.lines;
814
+ };
815
+
816
+ const DiffAbout = {
817
+ __proto__: null,
818
+ diffType: diffType$1,
819
+ isEqual: isEqual$1
820
+ };
821
+
822
+ const diffType = RenderFocus;
823
+ const isEqual = (oldState, newState) => {
824
+ return oldState.focusId === newState.focusId;
825
+ };
826
+
827
+ const DiffFocus = {
828
+ __proto__: null,
829
+ diffType,
830
+ isEqual
831
+ };
832
+
833
+ const modules = [DiffAbout, DiffFocus];
834
+ const diff = (oldState, newState) => {
835
+ const diffResult = [];
836
+ for (const module of modules) {
837
+ if (!module.isEqual(oldState, newState)) {
838
+ diffResult.push(module.diffType);
839
+ }
840
+ }
841
+ return diffResult;
842
+ };
843
+
808
844
  const None = 0;
809
845
  const Ok$2 = 1;
810
846
  const Copy$2 = 2;
@@ -1388,6 +1424,11 @@ const getAboutVirtualDom = (productName, lines, closeMessage, okMessage, copyMes
1388
1424
  }, ...getDialogVirtualDom(content, closeMessage, infoMessage, okMessage, copyMessage, productName)];
1389
1425
  };
1390
1426
 
1427
+ const commandIds = ['handleClickClose', 'handleClickOk', 'handleClickCopy', 'handleFocusIn', 'focusNext', 'focusPrevious'];
1428
+ const getCommandIds = () => {
1429
+ return commandIds;
1430
+ };
1431
+
1391
1432
  const Tab = 2;
1392
1433
  const Escape = 8;
1393
1434
 
@@ -1434,6 +1475,11 @@ const handleClickOk = async state => {
1434
1475
  return state;
1435
1476
  };
1436
1477
 
1478
+ const handleFocusIn = async state => {
1479
+ await invoke('Focus.setFocus', FocusAbout);
1480
+ return state;
1481
+ };
1482
+
1437
1483
  const loadContent = state => {
1438
1484
  const lines = getDetailStringWeb();
1439
1485
  return {
@@ -1473,39 +1519,43 @@ const getFocusSelector = focusId => {
1473
1519
  }
1474
1520
  };
1475
1521
 
1476
- const renderDialog = {
1477
- isEqual(oldState, newState) {
1478
- return oldState.productName === newState.productName && oldState.lines === newState.lines;
1479
- },
1480
- apply(oldState, newState) {
1481
- const okMessage = ok();
1482
- const copyMessage = copy();
1483
- const closeMessage = closeDialog();
1484
- const infoMessage = info();
1485
- const dom = getAboutVirtualDom(newState.productName, newState.lines, closeMessage, okMessage, copyMessage, infoMessage);
1486
- return ['Viewlet.setDom2', dom];
1487
- }
1522
+ const renderDialog = (oldState, newState) => {
1523
+ const okMessage = ok();
1524
+ const copyMessage = copy();
1525
+ const closeMessage = closeDialog();
1526
+ const infoMessage = info();
1527
+ const dom = getAboutVirtualDom(newState.productName, newState.lines, closeMessage, okMessage, copyMessage, infoMessage);
1528
+ return ['Viewlet.setDom2', dom];
1529
+ };
1530
+ const renderFocus = (oldState, newState) => {
1531
+ const name = getFocusSelector(newState.focusId);
1532
+ return ['Viewlet.focusElementByName', name];
1488
1533
  };
1489
- const renderFocus = {
1490
- isEqual(oldState, newState) {
1491
- return oldState.focusId === newState.focusId;
1492
- },
1493
- apply(oldState, newState) {
1494
- const name = getFocusSelector(newState.focusId);
1495
- return ['Viewlet.focusElementByName', name];
1534
+ const getRenderer = diffType => {
1535
+ switch (diffType) {
1536
+ case RenderAbout:
1537
+ return renderDialog;
1538
+ case RenderFocus:
1539
+ return renderFocus;
1540
+ default:
1541
+ throw new Error('unknown renderer');
1496
1542
  }
1497
1543
  };
1498
- const render = [renderDialog, renderFocus];
1499
- const doRender = (oldState, newState) => {
1544
+
1545
+ const applyRender = (oldState, newState, diffResult) => {
1500
1546
  const commands = [];
1501
- for (const fn of render) {
1502
- if (!fn.isEqual(oldState, newState)) {
1503
- commands.push(fn.apply(oldState, newState));
1504
- }
1547
+ for (const item of diffResult) {
1548
+ const fn = getRenderer(item);
1549
+ commands.push(fn(oldState, newState));
1505
1550
  }
1506
1551
  return commands;
1507
1552
  };
1508
1553
 
1554
+ const doRender = (oldState, newState) => {
1555
+ const diffResult = diff(oldState, newState);
1556
+ return applyRender(oldState, newState, diffResult);
1557
+ };
1558
+
1509
1559
  const renderEventListeners = () => {
1510
1560
  return [{
1511
1561
  name: HandleClickOk,
@@ -1568,8 +1618,10 @@ const showAboutElectron = async () => {
1568
1618
  };
1569
1619
 
1570
1620
  const commandMap = {
1621
+ 'About.diff': diff,
1571
1622
  'About.focusNext': focusNext,
1572
1623
  'About.focusPrevious': focusPrevious,
1624
+ 'About.getCommandIds': getCommandIds,
1573
1625
  'About.getDetailString': getDetailString,
1574
1626
  'About.getDetailStringWeb': getDetailStringWeb,
1575
1627
  'About.getKeyBindings': getKeyBindings,
@@ -1577,6 +1629,7 @@ const commandMap = {
1577
1629
  'About.handleClickClose': handleClickClose,
1578
1630
  'About.handleClickCopy': handleClickCopy,
1579
1631
  'About.handleClickOk': handleClickOk,
1632
+ 'About.handleFocusIn': handleFocusIn,
1580
1633
  'About.loadContent': loadContent,
1581
1634
  'About.render': doRender,
1582
1635
  'About.renderEventListeners': renderEventListeners,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "4.6.0",
3
+ "version": "4.8.0",
4
4
  "description": "About View Worker",
5
5
  "keywords": [
6
6
  "about-view"