@lvce-editor/about-view 5.4.0 → 5.6.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 +109 -55
- package/package.json +1 -1
package/dist/aboutWorkerMain.js
CHANGED
@@ -303,22 +303,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
303
303
|
const wrap$f = global => {
|
304
304
|
return new IpcChildWithModuleWorker(global);
|
305
305
|
};
|
306
|
-
const withResolvers = () => {
|
307
|
-
let _resolve;
|
308
|
-
const promise = new Promise(resolve => {
|
309
|
-
_resolve = resolve;
|
310
|
-
});
|
311
|
-
return {
|
312
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
313
|
-
resolve: _resolve,
|
314
|
-
promise
|
315
|
-
};
|
316
|
-
};
|
317
306
|
const waitForFirstMessage = async port => {
|
318
307
|
const {
|
319
308
|
resolve,
|
320
309
|
promise
|
321
|
-
} = withResolvers();
|
310
|
+
} = Promise.withResolvers();
|
322
311
|
port.addEventListener('message', resolve, {
|
323
312
|
once: true
|
324
313
|
});
|
@@ -399,11 +388,11 @@ const remove = id => {
|
|
399
388
|
delete callbacks[id];
|
400
389
|
};
|
401
390
|
let id = 0;
|
402
|
-
const create$3 = () => {
|
391
|
+
const create$3$1 = () => {
|
403
392
|
return ++id;
|
404
393
|
};
|
405
394
|
const registerPromise = () => {
|
406
|
-
const id = create$3();
|
395
|
+
const id = create$3$1();
|
407
396
|
const {
|
408
397
|
resolve,
|
409
398
|
promise
|
@@ -793,7 +782,7 @@ const listen$1 = async (module, options) => {
|
|
793
782
|
const ipc = module.wrap(rawIpc);
|
794
783
|
return ipc;
|
795
784
|
};
|
796
|
-
const create$
|
785
|
+
const create$3 = async ({
|
797
786
|
commandMap
|
798
787
|
}) => {
|
799
788
|
// TODO create a commandMap per rpc instance
|
@@ -805,10 +794,10 @@ const create$2 = async ({
|
|
805
794
|
};
|
806
795
|
const WebWorkerRpcClient = {
|
807
796
|
__proto__: null,
|
808
|
-
create: create$
|
797
|
+
create: create$3
|
809
798
|
};
|
810
799
|
|
811
|
-
const create$
|
800
|
+
const create$2 = () => {
|
812
801
|
const states = Object.create(null);
|
813
802
|
return {
|
814
803
|
get(uid) {
|
@@ -849,6 +838,20 @@ const create$1 = () => {
|
|
849
838
|
};
|
850
839
|
};
|
851
840
|
return wrapped;
|
841
|
+
},
|
842
|
+
diff(uid, modules, numbers) {
|
843
|
+
const {
|
844
|
+
oldState,
|
845
|
+
newState
|
846
|
+
} = states[uid];
|
847
|
+
const diffResult = [];
|
848
|
+
for (let i = 0; i < modules.length; i++) {
|
849
|
+
const fn = modules[i];
|
850
|
+
if (!fn(oldState, newState)) {
|
851
|
+
diffResult.push(numbers[i]);
|
852
|
+
}
|
853
|
+
}
|
854
|
+
return diffResult;
|
852
855
|
}
|
853
856
|
};
|
854
857
|
};
|
@@ -858,9 +861,9 @@ const {
|
|
858
861
|
set: set$1,
|
859
862
|
dispose: dispose$1,
|
860
863
|
wrapCommand
|
861
|
-
} = create$
|
864
|
+
} = create$2();
|
862
865
|
|
863
|
-
const create = uid => {
|
866
|
+
const create$1 = uid => {
|
864
867
|
const state = {
|
865
868
|
uid,
|
866
869
|
focusId: 0,
|
@@ -962,7 +965,7 @@ const focusPrevious = state => {
|
|
962
965
|
};
|
963
966
|
};
|
964
967
|
|
965
|
-
const commandIds = ['dispose', '
|
968
|
+
const commandIds = ['dispose', 'focusNext', 'focusPrevious', 'handleClickButton', 'handleClickClose', 'handleClickCopy', 'handleClickOk', 'handleFocusIn'];
|
966
969
|
|
967
970
|
const getCommandIds = () => {
|
968
971
|
return commandIds;
|
@@ -991,24 +994,61 @@ const getKeyBindings = () => {
|
|
991
994
|
}];
|
992
995
|
};
|
993
996
|
|
994
|
-
const RendererWorker = 1;
|
995
|
-
|
996
997
|
const rpcs = Object.create(null);
|
997
|
-
const set = (id, rpc) => {
|
998
|
+
const set$6 = (id, rpc) => {
|
998
999
|
rpcs[id] = rpc;
|
999
1000
|
};
|
1000
1001
|
const get = id => {
|
1001
1002
|
return rpcs[id];
|
1002
1003
|
};
|
1004
|
+
const RendererWorker$1 = 1;
|
1003
1005
|
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
return
|
1006
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
1007
|
+
|
1008
|
+
const create = rpcId => {
|
1009
|
+
return {
|
1010
|
+
// @ts-ignore
|
1011
|
+
invoke(method, ...params) {
|
1012
|
+
const rpc = get(RendererWorker$1);
|
1013
|
+
// @ts-ignore
|
1014
|
+
return rpc.invoke(method, ...params);
|
1015
|
+
},
|
1016
|
+
// @ts-ignore
|
1017
|
+
invokeAndTransfer(method, ...params) {
|
1018
|
+
const rpc = get(RendererWorker$1);
|
1019
|
+
// @ts-ignore
|
1020
|
+
return rpc.invoke(method, ...params);
|
1021
|
+
},
|
1022
|
+
set(rpc) {
|
1023
|
+
set$6(rpcId, rpc);
|
1024
|
+
}
|
1025
|
+
};
|
1026
|
+
};
|
1027
|
+
const {
|
1028
|
+
invoke: invoke$3,
|
1029
|
+
set: set$3
|
1030
|
+
} = create(RendererWorker$1);
|
1031
|
+
const RendererWorker = {
|
1032
|
+
__proto__: null,
|
1033
|
+
invoke: invoke$3,
|
1034
|
+
set: set$3
|
1035
|
+
};
|
1036
|
+
|
1037
|
+
const {
|
1038
|
+
invoke,
|
1039
|
+
set
|
1040
|
+
} = RendererWorker;
|
1041
|
+
|
1042
|
+
const closeWidget = async id => {
|
1043
|
+
await invoke('Viewlet.closeWidget', id);
|
1044
|
+
};
|
1045
|
+
|
1046
|
+
const close = async () => {
|
1047
|
+
await closeWidget('About');
|
1008
1048
|
};
|
1009
1049
|
|
1010
1050
|
const handleClickClose = async state => {
|
1011
|
-
await
|
1051
|
+
await close();
|
1012
1052
|
return state;
|
1013
1053
|
};
|
1014
1054
|
|
@@ -1022,24 +1062,42 @@ const joinLines = lines => {
|
|
1022
1062
|
return lines.join(NewLine);
|
1023
1063
|
};
|
1024
1064
|
|
1065
|
+
const copy$1 = async lines => {
|
1066
|
+
const message = joinLines(lines);
|
1067
|
+
await writeText(message);
|
1068
|
+
};
|
1069
|
+
|
1025
1070
|
const handleClickCopy = async state => {
|
1026
1071
|
const {
|
1027
1072
|
lines
|
1028
1073
|
} = state;
|
1029
|
-
|
1030
|
-
await
|
1074
|
+
await copy$1(lines);
|
1075
|
+
await close();
|
1031
1076
|
return state;
|
1032
1077
|
};
|
1033
1078
|
|
1034
|
-
const closeWidget = async id => {
|
1035
|
-
await invoke('Viewlet.closeWidget', id);
|
1036
|
-
};
|
1037
|
-
|
1038
1079
|
const handleClickOk = async state => {
|
1039
|
-
await
|
1080
|
+
await close();
|
1040
1081
|
return state;
|
1041
1082
|
};
|
1042
1083
|
|
1084
|
+
const Ok$1 = 'Ok';
|
1085
|
+
const Copy$1 = 'Copy';
|
1086
|
+
const Close = 'Close';
|
1087
|
+
|
1088
|
+
const handleClickButton = async (state, name) => {
|
1089
|
+
switch (name) {
|
1090
|
+
case Copy$1:
|
1091
|
+
return handleClickCopy(state);
|
1092
|
+
case Ok$1:
|
1093
|
+
return handleClickOk(state);
|
1094
|
+
case Close:
|
1095
|
+
return handleClickClose(state);
|
1096
|
+
default:
|
1097
|
+
throw new Error(`unexpected button`);
|
1098
|
+
}
|
1099
|
+
};
|
1100
|
+
|
1043
1101
|
const handleFocusIn = async state => {
|
1044
1102
|
// TODO remove side effect
|
1045
1103
|
await invoke('Focus.setFocus', FocusAbout);
|
@@ -1408,16 +1466,16 @@ const loadContent2 = uid => {
|
|
1408
1466
|
set$1(uid, oldState, newState);
|
1409
1467
|
};
|
1410
1468
|
|
1411
|
-
const Ok
|
1412
|
-
const Copy
|
1469
|
+
const Ok = 'Ok';
|
1470
|
+
const Copy = 'Copy';
|
1413
1471
|
const Info$1 = 'Info';
|
1414
1472
|
const CloseDialog = 'Close Dialog';
|
1415
1473
|
|
1416
1474
|
const ok = () => {
|
1417
|
-
return i18nString(Ok
|
1475
|
+
return i18nString(Ok);
|
1418
1476
|
};
|
1419
1477
|
const copy = () => {
|
1420
|
-
return i18nString(Copy
|
1478
|
+
return i18nString(Copy);
|
1421
1479
|
};
|
1422
1480
|
const info = () => {
|
1423
1481
|
return i18nString(Info$1);
|
@@ -1467,6 +1525,7 @@ const MaskIconInfo = 'MaskIconInfo';
|
|
1467
1525
|
const HandleClickClose = 'handleClickClose';
|
1468
1526
|
const HandleClickCopy = 'handleClickCopy';
|
1469
1527
|
const HandleClickOk = 'handleClickOk';
|
1528
|
+
const HandleClickButton = 'handleClickButton';
|
1470
1529
|
const HandleContextMenu = 'handleContextMenu';
|
1471
1530
|
const HandleFocusIn = 'handleFocusIn';
|
1472
1531
|
|
@@ -1515,7 +1574,7 @@ const getPrimaryButtonVirtualDom = (message, onClick, name) => {
|
|
1515
1574
|
return [{
|
1516
1575
|
type: Button$1,
|
1517
1576
|
className: mergeClassNames(Button$2, ButtonPrimary),
|
1518
|
-
onClick,
|
1577
|
+
onClick: HandleClickButton,
|
1519
1578
|
childCount: 1,
|
1520
1579
|
name
|
1521
1580
|
}, text(message)];
|
@@ -1525,7 +1584,7 @@ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
|
|
1525
1584
|
return [{
|
1526
1585
|
type: Button$1,
|
1527
1586
|
className: mergeClassNames(Button$2, ButtonSecondary),
|
1528
|
-
onClick,
|
1587
|
+
onClick: HandleClickButton,
|
1529
1588
|
childCount: 1,
|
1530
1589
|
name
|
1531
1590
|
}, text(message)];
|
@@ -1534,9 +1593,6 @@ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
|
|
1534
1593
|
const DialogIcon = 'DialogIcon';
|
1535
1594
|
const DialogHeading = 'DialogHeading';
|
1536
1595
|
|
1537
|
-
const Ok = 'Ok';
|
1538
|
-
const Copy = 'Copy';
|
1539
|
-
|
1540
1596
|
const joinBySpace = (...items) => {
|
1541
1597
|
return items.join(' ');
|
1542
1598
|
};
|
@@ -1591,7 +1647,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
|
|
1591
1647
|
type: Div,
|
1592
1648
|
className: DialogButtonsRow,
|
1593
1649
|
childCount: 2
|
1594
|
-
}, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy)];
|
1650
|
+
}, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok$1), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy$1)];
|
1595
1651
|
return dom;
|
1596
1652
|
};
|
1597
1653
|
|
@@ -1614,9 +1670,9 @@ const renderDialog = (oldState, newState) => {
|
|
1614
1670
|
const getFocusSelector = focusId => {
|
1615
1671
|
switch (focusId) {
|
1616
1672
|
case Copy$2:
|
1617
|
-
return Copy;
|
1673
|
+
return Copy$1;
|
1618
1674
|
case Ok$2:
|
1619
|
-
return Ok;
|
1675
|
+
return Ok$1;
|
1620
1676
|
default:
|
1621
1677
|
return '';
|
1622
1678
|
}
|
@@ -1665,14 +1721,11 @@ const doRender = (uid, diffResult) => {
|
|
1665
1721
|
|
1666
1722
|
const renderEventListeners = () => {
|
1667
1723
|
return [{
|
1668
|
-
name:
|
1669
|
-
params: ['
|
1724
|
+
name: HandleClickButton,
|
1725
|
+
params: ['handleClickButton', 'event.target.name']
|
1670
1726
|
}, {
|
1671
1727
|
name: HandleClickClose,
|
1672
|
-
params: ['handleClickClose']
|
1673
|
-
}, {
|
1674
|
-
name: HandleClickCopy,
|
1675
|
-
params: ['handleClickCopy']
|
1728
|
+
params: ['handleClickClose'] // TODO
|
1676
1729
|
}, {
|
1677
1730
|
name: HandleFocusIn,
|
1678
1731
|
params: ['handleFocusIn']
|
@@ -1755,13 +1808,14 @@ const showAbout = async platform => {
|
|
1755
1808
|
};
|
1756
1809
|
|
1757
1810
|
const commandMap = {
|
1758
|
-
'About.create': create,
|
1811
|
+
'About.create': create$1,
|
1759
1812
|
'About.diff2': diff2,
|
1760
1813
|
'About.dispose': dispose,
|
1761
1814
|
'About.focusNext': wrapCommand(focusNext),
|
1762
1815
|
'About.focusPrevious': wrapCommand(focusPrevious),
|
1763
1816
|
'About.getCommandIds': getCommandIds,
|
1764
1817
|
'About.getKeyBindings': getKeyBindings,
|
1818
|
+
'About.handleClickButton': wrapCommand(handleClickButton),
|
1765
1819
|
'About.handleClickClose': wrapCommand(handleClickClose),
|
1766
1820
|
'About.handleClickCopy': wrapCommand(handleClickCopy),
|
1767
1821
|
'About.handleClickOk': wrapCommand(handleClickOk),
|
@@ -1777,7 +1831,7 @@ const listen = async () => {
|
|
1777
1831
|
const rpc = await WebWorkerRpcClient.create({
|
1778
1832
|
commandMap: commandMap
|
1779
1833
|
});
|
1780
|
-
set(
|
1834
|
+
set(rpc);
|
1781
1835
|
};
|
1782
1836
|
|
1783
1837
|
const main = async () => {
|