@lvce-editor/about-view 5.0.0 → 5.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.
- package/dist/aboutWorkerMain.js +96 -41
- package/package.json +1 -1
package/dist/aboutWorkerMain.js
CHANGED
@@ -395,7 +395,7 @@ const set$2 = (id, fn) => {
|
|
395
395
|
const get$2 = id => {
|
396
396
|
return callbacks[id];
|
397
397
|
};
|
398
|
-
const remove
|
398
|
+
const remove = id => {
|
399
399
|
delete callbacks[id];
|
400
400
|
};
|
401
401
|
let id = 0;
|
@@ -414,7 +414,7 @@ const registerPromise = () => {
|
|
414
414
|
promise
|
415
415
|
};
|
416
416
|
};
|
417
|
-
const create$2 = (method, params) => {
|
417
|
+
const create$2$1 = (method, params) => {
|
418
418
|
const {
|
419
419
|
id,
|
420
420
|
promise
|
@@ -572,7 +572,7 @@ const resolve = (id, response) => {
|
|
572
572
|
return;
|
573
573
|
}
|
574
574
|
fn(response);
|
575
|
-
remove
|
575
|
+
remove(id);
|
576
576
|
};
|
577
577
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
578
578
|
const getErrorType = prettyError => {
|
@@ -706,7 +706,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
706
706
|
const {
|
707
707
|
message,
|
708
708
|
promise
|
709
|
-
} = create$2(method, params);
|
709
|
+
} = create$2$1(method, params);
|
710
710
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
711
711
|
ipc.sendAndTransfer(message);
|
712
712
|
} else {
|
@@ -790,7 +790,7 @@ const listen$1 = async (module, options) => {
|
|
790
790
|
const ipc = module.wrap(rawIpc);
|
791
791
|
return ipc;
|
792
792
|
};
|
793
|
-
const create$
|
793
|
+
const create$2 = async ({
|
794
794
|
commandMap
|
795
795
|
}) => {
|
796
796
|
// TODO create a commandMap per rpc instance
|
@@ -802,23 +802,42 @@ const create$1 = async ({
|
|
802
802
|
};
|
803
803
|
const WebWorkerRpcClient = {
|
804
804
|
__proto__: null,
|
805
|
-
create: create$
|
805
|
+
create: create$2
|
806
806
|
};
|
807
807
|
|
808
|
-
const
|
809
|
-
const
|
810
|
-
return
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
808
|
+
const create$1 = () => {
|
809
|
+
const states = Object.create(null);
|
810
|
+
return {
|
811
|
+
get(uid) {
|
812
|
+
return states[uid];
|
813
|
+
},
|
814
|
+
set(uid, oldState, newState) {
|
815
|
+
states[uid] = {
|
816
|
+
oldState,
|
817
|
+
newState
|
818
|
+
};
|
819
|
+
},
|
820
|
+
dispose(uid) {
|
821
|
+
delete states[uid];
|
822
|
+
},
|
823
|
+
getKeys() {
|
824
|
+
return Object.keys(states).map(key => {
|
825
|
+
return Number.parseInt(key);
|
826
|
+
});
|
827
|
+
},
|
828
|
+
clear() {
|
829
|
+
for (const key of Object.keys(states)) {
|
830
|
+
delete states[key];
|
831
|
+
}
|
832
|
+
}
|
819
833
|
};
|
820
834
|
};
|
821
835
|
|
836
|
+
const {
|
837
|
+
get: get$1,
|
838
|
+
set: set$1,
|
839
|
+
dispose: dispose$1} = create$1();
|
840
|
+
|
822
841
|
const create = uid => {
|
823
842
|
const state = {
|
824
843
|
uid,
|
@@ -830,20 +849,26 @@ const create = uid => {
|
|
830
849
|
};
|
831
850
|
|
832
851
|
const RenderFocus = 2;
|
852
|
+
const RenderFocusContext = 4;
|
833
853
|
const RenderAbout = 3;
|
834
854
|
|
835
|
-
const diffType$
|
836
|
-
const isEqual$
|
855
|
+
const diffType$2 = RenderAbout;
|
856
|
+
const isEqual$2 = (oldState, newState) => {
|
837
857
|
return oldState.productName === newState.productName && JSON.stringify(oldState.lines) === JSON.stringify(newState.lines);
|
838
858
|
};
|
839
859
|
|
840
|
-
const diffType = RenderFocus;
|
860
|
+
const diffType$1 = RenderFocus;
|
861
|
+
const isEqual$1 = (oldState, newState) => {
|
862
|
+
return oldState.focusId === newState.focusId;
|
863
|
+
};
|
864
|
+
|
865
|
+
const diffType = RenderFocusContext;
|
841
866
|
const isEqual = (oldState, newState) => {
|
842
867
|
return oldState.focusId === newState.focusId;
|
843
868
|
};
|
844
869
|
|
845
|
-
const modules = [isEqual$1, isEqual];
|
846
|
-
const numbers = [diffType$1, diffType];
|
870
|
+
const modules = [isEqual$2, isEqual$1, isEqual];
|
871
|
+
const numbers = [diffType$2, diffType$1, diffType];
|
847
872
|
|
848
873
|
const diff = (oldState, newState) => {
|
849
874
|
const diffResult = [];
|
@@ -866,7 +891,7 @@ const diff2 = uid => {
|
|
866
891
|
};
|
867
892
|
|
868
893
|
const dispose = uid => {
|
869
|
-
|
894
|
+
dispose$1(uid);
|
870
895
|
};
|
871
896
|
|
872
897
|
const None = 0;
|
@@ -983,14 +1008,25 @@ const handleClickCopy = async state => {
|
|
983
1008
|
return state;
|
984
1009
|
};
|
985
1010
|
|
1011
|
+
const closeWidget = async id => {
|
1012
|
+
await invoke('Viewlet.closeWidget', id);
|
1013
|
+
};
|
1014
|
+
|
986
1015
|
const handleClickOk = async state => {
|
987
|
-
await
|
1016
|
+
await closeWidget('About');
|
988
1017
|
return state;
|
989
1018
|
};
|
990
1019
|
|
991
1020
|
const handleFocusIn = async state => {
|
1021
|
+
// TODO remove side effect
|
992
1022
|
await invoke('Focus.setFocus', FocusAbout);
|
993
|
-
|
1023
|
+
if (state.focusId) {
|
1024
|
+
return state;
|
1025
|
+
}
|
1026
|
+
return {
|
1027
|
+
...state,
|
1028
|
+
focusId: Ok$2
|
1029
|
+
};
|
994
1030
|
};
|
995
1031
|
|
996
1032
|
const OneSecondAgo = '1 second ago';
|
@@ -1413,9 +1449,12 @@ const HandleFocusIn = 'handleFocusIn';
|
|
1413
1449
|
|
1414
1450
|
const Button$1 = 1;
|
1415
1451
|
const Div = 4;
|
1416
|
-
const Text = 12;
|
1417
1452
|
const Br = 55;
|
1418
1453
|
|
1454
|
+
const mergeClassNames = (...classNames) => {
|
1455
|
+
return classNames.filter(Boolean).join(' ');
|
1456
|
+
};
|
1457
|
+
const Text = 12;
|
1419
1458
|
const text = data => {
|
1420
1459
|
return {
|
1421
1460
|
type: Text,
|
@@ -1449,14 +1488,6 @@ const True = 'true';
|
|
1449
1488
|
const Button = 'button';
|
1450
1489
|
const Dialog = 'dialog';
|
1451
1490
|
|
1452
|
-
const joinBySpace = (...items) => {
|
1453
|
-
return items.join(' ');
|
1454
|
-
};
|
1455
|
-
|
1456
|
-
const mergeClassNames = (...classNames) => {
|
1457
|
-
return joinBySpace(...classNames.filter(Boolean));
|
1458
|
-
};
|
1459
|
-
|
1460
1491
|
const getPrimaryButtonVirtualDom = (message, onClick, name) => {
|
1461
1492
|
return [{
|
1462
1493
|
type: Button$1,
|
@@ -1483,6 +1514,10 @@ const DialogHeading = 'DialogHeading';
|
|
1483
1514
|
const Ok = 'Ok';
|
1484
1515
|
const Copy = 'Copy';
|
1485
1516
|
|
1517
|
+
const joinBySpace = (...items) => {
|
1518
|
+
return items.join(' ');
|
1519
|
+
};
|
1520
|
+
|
1486
1521
|
const Focusable = -1;
|
1487
1522
|
|
1488
1523
|
const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copyMessage, productName) => {
|
@@ -1569,12 +1604,18 @@ const renderFocus = (oldState, newState) => {
|
|
1569
1604
|
return ['Viewlet.focusElementByName', name];
|
1570
1605
|
};
|
1571
1606
|
|
1607
|
+
const renderFocusContext = (oldState, newState) => {
|
1608
|
+
return ['Viewlet.setFocusContext', FocusAbout];
|
1609
|
+
};
|
1610
|
+
|
1572
1611
|
const getRenderer = diffType => {
|
1573
1612
|
switch (diffType) {
|
1574
1613
|
case RenderAbout:
|
1575
1614
|
return renderDialog;
|
1576
1615
|
case RenderFocus:
|
1577
1616
|
return renderFocus;
|
1617
|
+
case RenderFocusContext:
|
1618
|
+
return renderFocusContext;
|
1578
1619
|
default:
|
1579
1620
|
throw new Error('unknown renderer');
|
1580
1621
|
}
|
@@ -1594,8 +1635,8 @@ const doRender = (uid, diffResult) => {
|
|
1594
1635
|
oldState,
|
1595
1636
|
newState
|
1596
1637
|
} = get$1(uid);
|
1597
|
-
const commands = applyRender(oldState, newState, diffResult);
|
1598
1638
|
set$1(uid, newState, newState);
|
1639
|
+
const commands = applyRender(oldState, newState, diffResult);
|
1599
1640
|
return commands;
|
1600
1641
|
};
|
1601
1642
|
|
@@ -1690,18 +1731,32 @@ const showAbout = async platform => {
|
|
1690
1731
|
await fn();
|
1691
1732
|
};
|
1692
1733
|
|
1734
|
+
const wrapCommand = fn => {
|
1735
|
+
const wrapped = async (uid, ...args) => {
|
1736
|
+
const {
|
1737
|
+
newState
|
1738
|
+
} = get$1(uid);
|
1739
|
+
const newerState = await fn(newState, ...args);
|
1740
|
+
if (newState === newerState) {
|
1741
|
+
return;
|
1742
|
+
}
|
1743
|
+
set$1(uid, newState, newerState);
|
1744
|
+
};
|
1745
|
+
return wrapped;
|
1746
|
+
};
|
1747
|
+
|
1693
1748
|
const commandMap = {
|
1694
1749
|
'About.create': create,
|
1695
1750
|
'About.diff2': diff2,
|
1696
1751
|
'About.dispose': dispose,
|
1697
|
-
'About.focusNext': focusNext,
|
1698
|
-
'About.focusPrevious': focusPrevious,
|
1752
|
+
'About.focusNext': wrapCommand(focusNext),
|
1753
|
+
'About.focusPrevious': wrapCommand(focusPrevious),
|
1699
1754
|
'About.getCommandIds': getCommandIds,
|
1700
1755
|
'About.getKeyBindings': getKeyBindings,
|
1701
|
-
'About.handleClickClose': handleClickClose,
|
1702
|
-
'About.handleClickCopy': handleClickCopy,
|
1703
|
-
'About.handleClickOk': handleClickOk,
|
1704
|
-
'About.handleFocusIn': handleFocusIn,
|
1756
|
+
'About.handleClickClose': wrapCommand(handleClickClose),
|
1757
|
+
'About.handleClickCopy': wrapCommand(handleClickCopy),
|
1758
|
+
'About.handleClickOk': wrapCommand(handleClickOk),
|
1759
|
+
'About.handleFocusIn': wrapCommand(handleFocusIn),
|
1705
1760
|
'About.loadContent2': loadContent2,
|
1706
1761
|
'About.render2': doRender,
|
1707
1762
|
'About.renderEventListeners': renderEventListeners,
|