@lvce-editor/about-view 5.5.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.
@@ -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$4 = (id, fn) => {
381
+ const set$2 = (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$4(id, resolve);
400
+ set$2(id, resolve);
412
401
  return {
413
402
  id,
414
403
  promise
@@ -719,7 +708,7 @@ const send = (transport, method, ...params) => {
719
708
  const message = create$4(method, params);
720
709
  transport.send(message);
721
710
  };
722
- const invoke$2 = (ipc, method, ...params) => {
711
+ const invoke$1 = (ipc, method, ...params) => {
723
712
  return invokeHelper(ipc, method, params, false);
724
713
  };
725
714
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -752,7 +741,7 @@ const createRpc = ipc => {
752
741
  send(ipc, method, ...params);
753
742
  },
754
743
  invoke(method, ...params) {
755
- return invoke$2(ipc, method, ...params);
744
+ return invoke$1(ipc, method, ...params);
756
745
  },
757
746
  invokeAndTransfer(method, ...params) {
758
747
  return invokeAndTransfer(ipc, method, ...params);
@@ -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$2 = async ({
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$2
797
+ create: create$3
809
798
  };
810
799
 
811
- const create$1 = () => {
800
+ const create$2 = () => {
812
801
  const states = Object.create(null);
813
802
  return {
814
803
  get(uid) {
@@ -869,19 +858,19 @@ const create$1 = () => {
869
858
 
870
859
  const {
871
860
  get: get$1,
872
- set: set$3,
861
+ set: set$1,
873
862
  dispose: dispose$1,
874
863
  wrapCommand
875
- } = create$1();
864
+ } = create$2();
876
865
 
877
- const create = uid => {
866
+ const create$1 = uid => {
878
867
  const state = {
879
868
  uid,
880
869
  focusId: 0,
881
870
  lines: [],
882
871
  productName: ''
883
872
  };
884
- set$3(uid, state, state);
873
+ set$1(uid, state, state);
885
874
  };
886
875
 
887
876
  const RenderFocus = 2;
@@ -976,7 +965,7 @@ const focusPrevious = state => {
976
965
  };
977
966
  };
978
967
 
979
- const commandIds = ['dispose', 'handleClickClose', 'handleClickOk', 'handleClickCopy', 'handleFocusIn', 'focusNext', 'focusPrevious'];
968
+ const commandIds = ['dispose', 'focusNext', 'focusPrevious', 'handleClickButton', 'handleClickClose', 'handleClickCopy', 'handleClickOk', 'handleFocusIn'];
980
969
 
981
970
  const getCommandIds = () => {
982
971
  return commandIds;
@@ -1006,25 +995,43 @@ const getKeyBindings = () => {
1006
995
  };
1007
996
 
1008
997
  const rpcs = Object.create(null);
1009
- const set$2 = (id, rpc) => {
998
+ const set$6 = (id, rpc) => {
1010
999
  rpcs[id] = rpc;
1011
1000
  };
1012
1001
  const get = id => {
1013
1002
  return rpcs[id];
1014
1003
  };
1015
1004
  const RendererWorker$1 = 1;
1016
- const invoke$1 = (method, ...params) => {
1017
- const rpc = get(RendererWorker$1);
1018
- // @ts-ignore
1019
- return rpc.invoke(method, ...params);
1020
- };
1021
- const set$1 = rpc => {
1022
- set$2(RendererWorker$1, rpc);
1005
+
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
+ };
1023
1026
  };
1027
+ const {
1028
+ invoke: invoke$3,
1029
+ set: set$3
1030
+ } = create(RendererWorker$1);
1024
1031
  const RendererWorker = {
1025
1032
  __proto__: null,
1026
- invoke: invoke$1,
1027
- set: set$1
1033
+ invoke: invoke$3,
1034
+ set: set$3
1028
1035
  };
1029
1036
 
1030
1037
  const {
@@ -1032,8 +1039,16 @@ const {
1032
1039
  set
1033
1040
  } = RendererWorker;
1034
1041
 
1042
+ const closeWidget = async id => {
1043
+ await invoke('Viewlet.closeWidget', id);
1044
+ };
1045
+
1046
+ const close = async () => {
1047
+ await closeWidget('About');
1048
+ };
1049
+
1035
1050
  const handleClickClose = async state => {
1036
- await invoke('Viewlet.closeWidget', 'About');
1051
+ await close();
1037
1052
  return state;
1038
1053
  };
1039
1054
 
@@ -1047,24 +1062,42 @@ const joinLines = lines => {
1047
1062
  return lines.join(NewLine);
1048
1063
  };
1049
1064
 
1065
+ const copy$1 = async lines => {
1066
+ const message = joinLines(lines);
1067
+ await writeText(message);
1068
+ };
1069
+
1050
1070
  const handleClickCopy = async state => {
1051
1071
  const {
1052
1072
  lines
1053
1073
  } = state;
1054
- const message = joinLines(lines);
1055
- await writeText(message);
1074
+ await copy$1(lines);
1075
+ await close();
1056
1076
  return state;
1057
1077
  };
1058
1078
 
1059
- const closeWidget = async id => {
1060
- await invoke('Viewlet.closeWidget', id);
1061
- };
1062
-
1063
1079
  const handleClickOk = async state => {
1064
- await closeWidget('About');
1080
+ await close();
1065
1081
  return state;
1066
1082
  };
1067
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
+
1068
1101
  const handleFocusIn = async state => {
1069
1102
  // TODO remove side effect
1070
1103
  await invoke('Focus.setFocus', FocusAbout);
@@ -1430,19 +1463,19 @@ const loadContent2 = uid => {
1430
1463
  lines,
1431
1464
  focusId: Ok$2
1432
1465
  };
1433
- set$3(uid, oldState, newState);
1466
+ set$1(uid, oldState, newState);
1434
1467
  };
1435
1468
 
1436
- const Ok$1 = 'Ok';
1437
- const Copy$1 = 'Copy';
1469
+ const Ok = 'Ok';
1470
+ const Copy = 'Copy';
1438
1471
  const Info$1 = 'Info';
1439
1472
  const CloseDialog = 'Close Dialog';
1440
1473
 
1441
1474
  const ok = () => {
1442
- return i18nString(Ok$1);
1475
+ return i18nString(Ok);
1443
1476
  };
1444
1477
  const copy = () => {
1445
- return i18nString(Copy$1);
1478
+ return i18nString(Copy);
1446
1479
  };
1447
1480
  const info = () => {
1448
1481
  return i18nString(Info$1);
@@ -1492,6 +1525,7 @@ const MaskIconInfo = 'MaskIconInfo';
1492
1525
  const HandleClickClose = 'handleClickClose';
1493
1526
  const HandleClickCopy = 'handleClickCopy';
1494
1527
  const HandleClickOk = 'handleClickOk';
1528
+ const HandleClickButton = 'handleClickButton';
1495
1529
  const HandleContextMenu = 'handleContextMenu';
1496
1530
  const HandleFocusIn = 'handleFocusIn';
1497
1531
 
@@ -1540,7 +1574,7 @@ const getPrimaryButtonVirtualDom = (message, onClick, name) => {
1540
1574
  return [{
1541
1575
  type: Button$1,
1542
1576
  className: mergeClassNames(Button$2, ButtonPrimary),
1543
- onClick,
1577
+ onClick: HandleClickButton,
1544
1578
  childCount: 1,
1545
1579
  name
1546
1580
  }, text(message)];
@@ -1550,7 +1584,7 @@ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
1550
1584
  return [{
1551
1585
  type: Button$1,
1552
1586
  className: mergeClassNames(Button$2, ButtonSecondary),
1553
- onClick,
1587
+ onClick: HandleClickButton,
1554
1588
  childCount: 1,
1555
1589
  name
1556
1590
  }, text(message)];
@@ -1559,9 +1593,6 @@ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
1559
1593
  const DialogIcon = 'DialogIcon';
1560
1594
  const DialogHeading = 'DialogHeading';
1561
1595
 
1562
- const Ok = 'Ok';
1563
- const Copy = 'Copy';
1564
-
1565
1596
  const joinBySpace = (...items) => {
1566
1597
  return items.join(' ');
1567
1598
  };
@@ -1616,7 +1647,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
1616
1647
  type: Div,
1617
1648
  className: DialogButtonsRow,
1618
1649
  childCount: 2
1619
- }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy)];
1650
+ }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok$1), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy$1)];
1620
1651
  return dom;
1621
1652
  };
1622
1653
 
@@ -1639,9 +1670,9 @@ const renderDialog = (oldState, newState) => {
1639
1670
  const getFocusSelector = focusId => {
1640
1671
  switch (focusId) {
1641
1672
  case Copy$2:
1642
- return Copy;
1673
+ return Copy$1;
1643
1674
  case Ok$2:
1644
- return Ok;
1675
+ return Ok$1;
1645
1676
  default:
1646
1677
  return '';
1647
1678
  }
@@ -1683,21 +1714,18 @@ const doRender = (uid, diffResult) => {
1683
1714
  oldState,
1684
1715
  newState
1685
1716
  } = get$1(uid);
1686
- set$3(uid, newState, newState);
1717
+ set$1(uid, newState, newState);
1687
1718
  const commands = applyRender(oldState, newState, diffResult);
1688
1719
  return commands;
1689
1720
  };
1690
1721
 
1691
1722
  const renderEventListeners = () => {
1692
1723
  return [{
1693
- name: HandleClickOk,
1694
- params: ['handleClickOk']
1724
+ name: HandleClickButton,
1725
+ params: ['handleClickButton', 'event.target.name']
1695
1726
  }, {
1696
1727
  name: HandleClickClose,
1697
- params: ['handleClickClose']
1698
- }, {
1699
- name: HandleClickCopy,
1700
- params: ['handleClickCopy']
1728
+ params: ['handleClickClose'] // TODO
1701
1729
  }, {
1702
1730
  name: HandleFocusIn,
1703
1731
  params: ['handleFocusIn']
@@ -1780,13 +1808,14 @@ const showAbout = async platform => {
1780
1808
  };
1781
1809
 
1782
1810
  const commandMap = {
1783
- 'About.create': create,
1811
+ 'About.create': create$1,
1784
1812
  'About.diff2': diff2,
1785
1813
  'About.dispose': dispose,
1786
1814
  'About.focusNext': wrapCommand(focusNext),
1787
1815
  'About.focusPrevious': wrapCommand(focusPrevious),
1788
1816
  'About.getCommandIds': getCommandIds,
1789
1817
  'About.getKeyBindings': getKeyBindings,
1818
+ 'About.handleClickButton': wrapCommand(handleClickButton),
1790
1819
  'About.handleClickClose': wrapCommand(handleClickClose),
1791
1820
  'About.handleClickCopy': wrapCommand(handleClickCopy),
1792
1821
  'About.handleClickOk': wrapCommand(handleClickOk),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "5.5.0",
3
+ "version": "5.6.0",
4
4
  "description": "About View Worker",
5
5
  "keywords": [
6
6
  "about-view"