@lvce-editor/about-view 5.5.0 → 5.7.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 +126 -81
- 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
|
});
|
@@ -389,7 +378,7 @@ const create$4 = (method, params) => {
|
|
389
378
|
};
|
390
379
|
};
|
391
380
|
const callbacks = Object.create(null);
|
392
|
-
const set$
|
381
|
+
const set$3 = (id, fn) => {
|
393
382
|
callbacks[id] = fn;
|
394
383
|
};
|
395
384
|
const get$2 = id => {
|
@@ -399,16 +388,16 @@ 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
|
410
399
|
} = Promise.withResolvers();
|
411
|
-
set$
|
400
|
+
set$3(id, resolve);
|
412
401
|
return {
|
413
402
|
id,
|
414
403
|
promise
|
@@ -481,6 +470,16 @@ const constructError = (message, type, name) => {
|
|
481
470
|
}
|
482
471
|
return new ErrorConstructor(message);
|
483
472
|
};
|
473
|
+
const joinLines$1 = lines => {
|
474
|
+
return lines.join(NewLine$1);
|
475
|
+
};
|
476
|
+
const splitLines = lines => {
|
477
|
+
return lines.split(NewLine$1);
|
478
|
+
};
|
479
|
+
const getCurrentStack = () => {
|
480
|
+
const currentStack = joinLines$1(splitLines(new Error().stack || '').slice(2));
|
481
|
+
return currentStack;
|
482
|
+
};
|
484
483
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
485
484
|
return string.indexOf(NewLine$1, startIndex);
|
486
485
|
};
|
@@ -491,19 +490,16 @@ const getParentStack = error => {
|
|
491
490
|
}
|
492
491
|
return parentStack;
|
493
492
|
};
|
494
|
-
const joinLines$1 = lines => {
|
495
|
-
return lines.join(NewLine$1);
|
496
|
-
};
|
497
493
|
const MethodNotFound = -32601;
|
498
494
|
const Custom = -32001;
|
499
|
-
const splitLines = lines => {
|
500
|
-
return lines.split(NewLine$1);
|
501
|
-
};
|
502
495
|
const restoreJsonRpcError = error => {
|
496
|
+
const currentStack = getCurrentStack();
|
503
497
|
if (error && error instanceof Error) {
|
498
|
+
if (typeof error.stack === 'string') {
|
499
|
+
error.stack = error.stack + NewLine$1 + currentStack;
|
500
|
+
}
|
504
501
|
return error;
|
505
502
|
}
|
506
|
-
const currentStack = joinLines$1(splitLines(new Error().stack || '').slice(1));
|
507
503
|
if (error && error.code && error.code === MethodNotFound) {
|
508
504
|
const restoredError = new JsonRpcError(error.message);
|
509
505
|
const parentStack = getParentStack(error);
|
@@ -584,6 +580,17 @@ const getErrorType = prettyError => {
|
|
584
580
|
}
|
585
581
|
return undefined;
|
586
582
|
};
|
583
|
+
const isAlreadyStack = line => {
|
584
|
+
return line.trim().startsWith('at ');
|
585
|
+
};
|
586
|
+
const getStack = prettyError => {
|
587
|
+
const stackString = prettyError.stack || '';
|
588
|
+
const newLineIndex = stackString.indexOf('\n');
|
589
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
590
|
+
return stackString.slice(newLineIndex + 1);
|
591
|
+
}
|
592
|
+
return stackString;
|
593
|
+
};
|
587
594
|
const getErrorProperty = (error, prettyError) => {
|
588
595
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
589
596
|
return {
|
@@ -596,7 +603,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
596
603
|
code: Custom,
|
597
604
|
message: prettyError.message,
|
598
605
|
data: {
|
599
|
-
stack: prettyError
|
606
|
+
stack: getStack(prettyError),
|
600
607
|
codeFrame: prettyError.codeFrame,
|
601
608
|
type: getErrorType(prettyError),
|
602
609
|
code: prettyError.code,
|
@@ -719,7 +726,7 @@ const send = (transport, method, ...params) => {
|
|
719
726
|
const message = create$4(method, params);
|
720
727
|
transport.send(message);
|
721
728
|
};
|
722
|
-
const invoke$
|
729
|
+
const invoke$1 = (ipc, method, ...params) => {
|
723
730
|
return invokeHelper(ipc, method, params, false);
|
724
731
|
};
|
725
732
|
const invokeAndTransfer = (ipc, method, ...params) => {
|
@@ -752,7 +759,7 @@ const createRpc = ipc => {
|
|
752
759
|
send(ipc, method, ...params);
|
753
760
|
},
|
754
761
|
invoke(method, ...params) {
|
755
|
-
return invoke$
|
762
|
+
return invoke$1(ipc, method, ...params);
|
756
763
|
},
|
757
764
|
invokeAndTransfer(method, ...params) {
|
758
765
|
return invokeAndTransfer(ipc, method, ...params);
|
@@ -793,7 +800,7 @@ const listen$1 = async (module, options) => {
|
|
793
800
|
const ipc = module.wrap(rawIpc);
|
794
801
|
return ipc;
|
795
802
|
};
|
796
|
-
const create$
|
803
|
+
const create$3 = async ({
|
797
804
|
commandMap
|
798
805
|
}) => {
|
799
806
|
// TODO create a commandMap per rpc instance
|
@@ -805,10 +812,10 @@ const create$2 = async ({
|
|
805
812
|
};
|
806
813
|
const WebWorkerRpcClient = {
|
807
814
|
__proto__: null,
|
808
|
-
create: create$
|
815
|
+
create: create$3
|
809
816
|
};
|
810
817
|
|
811
|
-
const create$
|
818
|
+
const create$2 = () => {
|
812
819
|
const states = Object.create(null);
|
813
820
|
return {
|
814
821
|
get(uid) {
|
@@ -869,19 +876,19 @@ const create$1 = () => {
|
|
869
876
|
|
870
877
|
const {
|
871
878
|
get: get$1,
|
872
|
-
set: set$
|
879
|
+
set: set$1,
|
873
880
|
dispose: dispose$1,
|
874
881
|
wrapCommand
|
875
|
-
} = create$
|
882
|
+
} = create$2();
|
876
883
|
|
877
|
-
const create = uid => {
|
884
|
+
const create$1 = uid => {
|
878
885
|
const state = {
|
879
886
|
uid,
|
880
887
|
focusId: 0,
|
881
888
|
lines: [],
|
882
889
|
productName: ''
|
883
890
|
};
|
884
|
-
set$
|
891
|
+
set$1(uid, state, state);
|
885
892
|
};
|
886
893
|
|
887
894
|
const RenderFocus = 2;
|
@@ -976,7 +983,7 @@ const focusPrevious = state => {
|
|
976
983
|
};
|
977
984
|
};
|
978
985
|
|
979
|
-
const commandIds = ['dispose', '
|
986
|
+
const commandIds = ['dispose', 'focusNext', 'focusPrevious', 'handleClickButton', 'handleClickClose', 'handleClickCopy', 'handleClickOk', 'handleFocusIn'];
|
980
987
|
|
981
988
|
const getCommandIds = () => {
|
982
989
|
return commandIds;
|
@@ -1006,25 +1013,43 @@ const getKeyBindings = () => {
|
|
1006
1013
|
};
|
1007
1014
|
|
1008
1015
|
const rpcs = Object.create(null);
|
1009
|
-
const set$
|
1016
|
+
const set$b = (id, rpc) => {
|
1010
1017
|
rpcs[id] = rpc;
|
1011
1018
|
};
|
1012
1019
|
const get = id => {
|
1013
1020
|
return rpcs[id];
|
1014
1021
|
};
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
return
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1022
|
+
|
1023
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
1024
|
+
|
1025
|
+
const create = rpcId => {
|
1026
|
+
return {
|
1027
|
+
// @ts-ignore
|
1028
|
+
invoke(method, ...params) {
|
1029
|
+
const rpc = get(rpcId);
|
1030
|
+
// @ts-ignore
|
1031
|
+
return rpc.invoke(method, ...params);
|
1032
|
+
},
|
1033
|
+
// @ts-ignore
|
1034
|
+
invokeAndTransfer(method, ...params) {
|
1035
|
+
const rpc = get(rpcId);
|
1036
|
+
// @ts-ignore
|
1037
|
+
return rpc.invokeAndTransfer(method, ...params);
|
1038
|
+
},
|
1039
|
+
set(rpc) {
|
1040
|
+
set$b(rpcId, rpc);
|
1041
|
+
}
|
1042
|
+
};
|
1023
1043
|
};
|
1044
|
+
const RendererWorker$1 = 1;
|
1045
|
+
const {
|
1046
|
+
invoke: invoke$2,
|
1047
|
+
set: set$2
|
1048
|
+
} = create(RendererWorker$1);
|
1024
1049
|
const RendererWorker = {
|
1025
1050
|
__proto__: null,
|
1026
|
-
invoke: invoke$
|
1027
|
-
set: set$
|
1051
|
+
invoke: invoke$2,
|
1052
|
+
set: set$2
|
1028
1053
|
};
|
1029
1054
|
|
1030
1055
|
const {
|
@@ -1032,8 +1057,16 @@ const {
|
|
1032
1057
|
set
|
1033
1058
|
} = RendererWorker;
|
1034
1059
|
|
1060
|
+
const closeWidget = async id => {
|
1061
|
+
await invoke('Viewlet.closeWidget', id);
|
1062
|
+
};
|
1063
|
+
|
1064
|
+
const close = async () => {
|
1065
|
+
await closeWidget('About');
|
1066
|
+
};
|
1067
|
+
|
1035
1068
|
const handleClickClose = async state => {
|
1036
|
-
await
|
1069
|
+
await close();
|
1037
1070
|
return state;
|
1038
1071
|
};
|
1039
1072
|
|
@@ -1047,24 +1080,42 @@ const joinLines = lines => {
|
|
1047
1080
|
return lines.join(NewLine);
|
1048
1081
|
};
|
1049
1082
|
|
1083
|
+
const copy$1 = async lines => {
|
1084
|
+
const message = joinLines(lines);
|
1085
|
+
await writeText(message);
|
1086
|
+
};
|
1087
|
+
|
1050
1088
|
const handleClickCopy = async state => {
|
1051
1089
|
const {
|
1052
1090
|
lines
|
1053
1091
|
} = state;
|
1054
|
-
|
1055
|
-
await
|
1092
|
+
await copy$1(lines);
|
1093
|
+
await close();
|
1056
1094
|
return state;
|
1057
1095
|
};
|
1058
1096
|
|
1059
|
-
const closeWidget = async id => {
|
1060
|
-
await invoke('Viewlet.closeWidget', id);
|
1061
|
-
};
|
1062
|
-
|
1063
1097
|
const handleClickOk = async state => {
|
1064
|
-
await
|
1098
|
+
await close();
|
1065
1099
|
return state;
|
1066
1100
|
};
|
1067
1101
|
|
1102
|
+
const Ok$1 = 'Ok';
|
1103
|
+
const Copy$1 = 'Copy';
|
1104
|
+
const Close = 'Close';
|
1105
|
+
|
1106
|
+
const handleClickButton = async (state, name) => {
|
1107
|
+
switch (name) {
|
1108
|
+
case Copy$1:
|
1109
|
+
return handleClickCopy(state);
|
1110
|
+
case Ok$1:
|
1111
|
+
return handleClickOk(state);
|
1112
|
+
case Close:
|
1113
|
+
return handleClickClose(state);
|
1114
|
+
default:
|
1115
|
+
throw new Error(`unexpected button`);
|
1116
|
+
}
|
1117
|
+
};
|
1118
|
+
|
1068
1119
|
const handleFocusIn = async state => {
|
1069
1120
|
// TODO remove side effect
|
1070
1121
|
await invoke('Focus.setFocus', FocusAbout);
|
@@ -1430,19 +1481,19 @@ const loadContent2 = uid => {
|
|
1430
1481
|
lines,
|
1431
1482
|
focusId: Ok$2
|
1432
1483
|
};
|
1433
|
-
set$
|
1484
|
+
set$1(uid, oldState, newState);
|
1434
1485
|
};
|
1435
1486
|
|
1436
|
-
const Ok
|
1437
|
-
const Copy
|
1487
|
+
const Ok = 'Ok';
|
1488
|
+
const Copy = 'Copy';
|
1438
1489
|
const Info$1 = 'Info';
|
1439
1490
|
const CloseDialog = 'Close Dialog';
|
1440
1491
|
|
1441
1492
|
const ok = () => {
|
1442
|
-
return i18nString(Ok
|
1493
|
+
return i18nString(Ok);
|
1443
1494
|
};
|
1444
1495
|
const copy = () => {
|
1445
|
-
return i18nString(Copy
|
1496
|
+
return i18nString(Copy);
|
1446
1497
|
};
|
1447
1498
|
const info = () => {
|
1448
1499
|
return i18nString(Info$1);
|
@@ -1489,11 +1540,10 @@ const DialogIcon$1 = 'DialogIcon';
|
|
1489
1540
|
const DialogInfoIcon = 'DialogInfoIcon';
|
1490
1541
|
const MaskIconInfo = 'MaskIconInfo';
|
1491
1542
|
|
1492
|
-
const HandleClickClose =
|
1493
|
-
const
|
1494
|
-
const
|
1495
|
-
const
|
1496
|
-
const HandleFocusIn = 'handleFocusIn';
|
1543
|
+
const HandleClickClose = 1;
|
1544
|
+
const HandleClickButton = 4;
|
1545
|
+
const HandleContextMenu = 5;
|
1546
|
+
const HandleFocusIn = 6;
|
1497
1547
|
|
1498
1548
|
const Button$1 = 1;
|
1499
1549
|
const Div = 4;
|
@@ -1536,21 +1586,21 @@ const True = 'true';
|
|
1536
1586
|
const Button = 'button';
|
1537
1587
|
const Dialog = 'dialog';
|
1538
1588
|
|
1539
|
-
const getPrimaryButtonVirtualDom = (message,
|
1589
|
+
const getPrimaryButtonVirtualDom = (message, name) => {
|
1540
1590
|
return [{
|
1541
1591
|
type: Button$1,
|
1542
1592
|
className: mergeClassNames(Button$2, ButtonPrimary),
|
1543
|
-
onClick,
|
1593
|
+
onClick: HandleClickButton,
|
1544
1594
|
childCount: 1,
|
1545
1595
|
name
|
1546
1596
|
}, text(message)];
|
1547
1597
|
};
|
1548
1598
|
|
1549
|
-
const getSecondaryButtonVirtualDom = (message,
|
1599
|
+
const getSecondaryButtonVirtualDom = (message, name) => {
|
1550
1600
|
return [{
|
1551
1601
|
type: Button$1,
|
1552
1602
|
className: mergeClassNames(Button$2, ButtonSecondary),
|
1553
|
-
onClick,
|
1603
|
+
onClick: HandleClickButton,
|
1554
1604
|
childCount: 1,
|
1555
1605
|
name
|
1556
1606
|
}, text(message)];
|
@@ -1559,9 +1609,6 @@ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
|
|
1559
1609
|
const DialogIcon = 'DialogIcon';
|
1560
1610
|
const DialogHeading = 'DialogHeading';
|
1561
1611
|
|
1562
|
-
const Ok = 'Ok';
|
1563
|
-
const Copy = 'Copy';
|
1564
|
-
|
1565
1612
|
const joinBySpace = (...items) => {
|
1566
1613
|
return items.join(' ');
|
1567
1614
|
};
|
@@ -1616,7 +1663,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
|
|
1616
1663
|
type: Div,
|
1617
1664
|
className: DialogButtonsRow,
|
1618
1665
|
childCount: 2
|
1619
|
-
}, ...getSecondaryButtonVirtualDom(okMessage,
|
1666
|
+
}, ...getSecondaryButtonVirtualDom(okMessage, Ok$1), ...getPrimaryButtonVirtualDom(copyMessage, Copy$1)];
|
1620
1667
|
return dom;
|
1621
1668
|
};
|
1622
1669
|
|
@@ -1639,9 +1686,9 @@ const renderDialog = (oldState, newState) => {
|
|
1639
1686
|
const getFocusSelector = focusId => {
|
1640
1687
|
switch (focusId) {
|
1641
1688
|
case Copy$2:
|
1642
|
-
return Copy;
|
1689
|
+
return Copy$1;
|
1643
1690
|
case Ok$2:
|
1644
|
-
return Ok;
|
1691
|
+
return Ok$1;
|
1645
1692
|
default:
|
1646
1693
|
return '';
|
1647
1694
|
}
|
@@ -1683,21 +1730,18 @@ const doRender = (uid, diffResult) => {
|
|
1683
1730
|
oldState,
|
1684
1731
|
newState
|
1685
1732
|
} = get$1(uid);
|
1686
|
-
set$
|
1733
|
+
set$1(uid, newState, newState);
|
1687
1734
|
const commands = applyRender(oldState, newState, diffResult);
|
1688
1735
|
return commands;
|
1689
1736
|
};
|
1690
1737
|
|
1691
1738
|
const renderEventListeners = () => {
|
1692
1739
|
return [{
|
1693
|
-
name:
|
1694
|
-
params: ['
|
1740
|
+
name: HandleClickButton,
|
1741
|
+
params: ['handleClickButton', 'event.target.name']
|
1695
1742
|
}, {
|
1696
1743
|
name: HandleClickClose,
|
1697
|
-
params: ['handleClickClose']
|
1698
|
-
}, {
|
1699
|
-
name: HandleClickCopy,
|
1700
|
-
params: ['handleClickCopy']
|
1744
|
+
params: ['handleClickClose'] // TODO
|
1701
1745
|
}, {
|
1702
1746
|
name: HandleFocusIn,
|
1703
1747
|
params: ['handleFocusIn']
|
@@ -1780,13 +1824,14 @@ const showAbout = async platform => {
|
|
1780
1824
|
};
|
1781
1825
|
|
1782
1826
|
const commandMap = {
|
1783
|
-
'About.create': create,
|
1827
|
+
'About.create': create$1,
|
1784
1828
|
'About.diff2': diff2,
|
1785
1829
|
'About.dispose': dispose,
|
1786
1830
|
'About.focusNext': wrapCommand(focusNext),
|
1787
1831
|
'About.focusPrevious': wrapCommand(focusPrevious),
|
1788
1832
|
'About.getCommandIds': getCommandIds,
|
1789
1833
|
'About.getKeyBindings': getKeyBindings,
|
1834
|
+
'About.handleClickButton': wrapCommand(handleClickButton),
|
1790
1835
|
'About.handleClickClose': wrapCommand(handleClickClose),
|
1791
1836
|
'About.handleClickCopy': wrapCommand(handleClickCopy),
|
1792
1837
|
'About.handleClickOk': wrapCommand(handleClickOk),
|