@lvce-editor/about-view 4.16.0 → 5.0.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.
@@ -389,13 +389,13 @@ const create$4 = (method, params) => {
389
389
  };
390
390
  };
391
391
  const callbacks = Object.create(null);
392
- const set$1 = (id, fn) => {
392
+ const set$2 = (id, fn) => {
393
393
  callbacks[id] = fn;
394
394
  };
395
- const get$1 = id => {
395
+ const get$2 = id => {
396
396
  return callbacks[id];
397
397
  };
398
- const remove = id => {
398
+ const remove$1 = id => {
399
399
  delete callbacks[id];
400
400
  };
401
401
  let id = 0;
@@ -408,7 +408,7 @@ const registerPromise = () => {
408
408
  resolve,
409
409
  promise
410
410
  } = Promise.withResolvers();
411
- set$1(id, resolve);
411
+ set$2(id, resolve);
412
412
  return {
413
413
  id,
414
414
  promise
@@ -565,14 +565,14 @@ const warn = (...args) => {
565
565
  console.warn(...args);
566
566
  };
567
567
  const resolve = (id, response) => {
568
- const fn = get$1(id);
568
+ const fn = get$2(id);
569
569
  if (!fn) {
570
570
  console.log(response);
571
571
  warn(`callback ${id} may already be disposed`);
572
572
  return;
573
573
  }
574
574
  fn(response);
575
- remove(id);
575
+ remove$1(id);
576
576
  };
577
577
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
578
578
  const getErrorType = prettyError => {
@@ -604,7 +604,7 @@ const getErrorProperty = (error, prettyError) => {
604
604
  }
605
605
  };
606
606
  };
607
- const create$1 = (message, error) => {
607
+ const create$1$1 = (message, error) => {
608
608
  return {
609
609
  jsonrpc: Two,
610
610
  id: message.id,
@@ -615,7 +615,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
615
615
  const prettyError = preparePrettyError(error);
616
616
  logError(error, prettyError);
617
617
  const errorProperty = getErrorProperty(error, prettyError);
618
- return create$1(message, errorProperty);
618
+ return create$1$1(message, errorProperty);
619
619
  };
620
620
  const create$5 = (message, result) => {
621
621
  return {
@@ -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 = async ({
793
+ const create$1 = async ({
794
794
  commandMap
795
795
  }) => {
796
796
  // TODO create a commandMap per rpc instance
@@ -802,7 +802,31 @@ const create = async ({
802
802
  };
803
803
  const WebWorkerRpcClient = {
804
804
  __proto__: null,
805
- create
805
+ create: create$1
806
+ };
807
+
808
+ const states = Object.create(null);
809
+ const get$1 = uid => {
810
+ return states[uid];
811
+ };
812
+ const remove = uid => {
813
+ delete states[uid];
814
+ };
815
+ const set$1 = (uid, oldState, newState) => {
816
+ states[uid] = {
817
+ oldState,
818
+ newState
819
+ };
820
+ };
821
+
822
+ const create = uid => {
823
+ const state = {
824
+ uid,
825
+ focusId: 0,
826
+ lines: [],
827
+ productName: ''
828
+ };
829
+ set$1(uid, state, state);
806
830
  };
807
831
 
808
832
  const RenderFocus = 2;
@@ -832,6 +856,19 @@ const diff = (oldState, newState) => {
832
856
  return diffResult;
833
857
  };
834
858
 
859
+ const diff2 = uid => {
860
+ const {
861
+ oldState,
862
+ newState
863
+ } = get$1(uid);
864
+ const diffResult = diff(oldState, newState);
865
+ return diffResult;
866
+ };
867
+
868
+ const dispose = uid => {
869
+ remove(uid);
870
+ };
871
+
835
872
  const None = 0;
836
873
  const Ok$2 = 1;
837
874
  const Copy$2 = 2;
@@ -878,6 +915,84 @@ const focusPrevious = state => {
878
915
  };
879
916
  };
880
917
 
918
+ const commandIds = ['handleClickClose', 'handleClickOk', 'handleClickCopy', 'handleFocusIn', 'focusNext', 'focusPrevious'];
919
+ const getCommandIds = () => {
920
+ return commandIds;
921
+ };
922
+
923
+ const Tab = 2;
924
+ const Escape = 8;
925
+
926
+ const Shift = 1 << 10 >>> 0;
927
+
928
+ const FocusAbout = 4;
929
+
930
+ const getKeyBindings = () => {
931
+ return [{
932
+ key: Escape,
933
+ command: 'About.handleClickClose',
934
+ when: FocusAbout
935
+ }, {
936
+ key: Tab,
937
+ command: 'About.focusNext',
938
+ when: FocusAbout
939
+ }, {
940
+ key: Tab | Shift,
941
+ command: 'About.focusPrevious',
942
+ when: FocusAbout
943
+ }];
944
+ };
945
+
946
+ const RendererWorker = 1;
947
+
948
+ const rpcs = Object.create(null);
949
+ const set = (id, rpc) => {
950
+ rpcs[id] = rpc;
951
+ };
952
+ const get = id => {
953
+ return rpcs[id];
954
+ };
955
+
956
+ const invoke = (method, ...params) => {
957
+ const rpc = get(RendererWorker);
958
+ // @ts-ignore
959
+ return rpc.invoke(method, ...params);
960
+ };
961
+
962
+ const handleClickClose = async state => {
963
+ await invoke('Viewlet.closeWidget', 'About');
964
+ return state;
965
+ };
966
+
967
+ const writeText = async text => {
968
+ await invoke('ClipBoard.writeText', /* text */text);
969
+ };
970
+
971
+ const NewLine = '\n';
972
+
973
+ const joinLines = lines => {
974
+ return lines.join(NewLine);
975
+ };
976
+
977
+ const handleClickCopy = async state => {
978
+ const {
979
+ lines
980
+ } = state;
981
+ const message = joinLines(lines);
982
+ await writeText(message);
983
+ return state;
984
+ };
985
+
986
+ const handleClickOk = async state => {
987
+ await invoke('Viewlet.closeWidget', 'About');
988
+ return state;
989
+ };
990
+
991
+ const handleFocusIn = async state => {
992
+ await invoke('Focus.setFocus', FocusAbout);
993
+ return state;
994
+ };
995
+
881
996
  const OneSecondAgo = '1 second ago';
882
997
  const SomeSecondsAgo = '{PH1} seconds ago';
883
998
  const OneMinuteAgo = '1 minute ago';
@@ -1162,26 +1277,8 @@ const formatAboutDate = (isoDate, now) => {
1162
1277
  return `${isoDate} (${ago})`;
1163
1278
  };
1164
1279
 
1165
- const NewLine = '\n';
1166
-
1167
- const joinLines = lines => {
1168
- return lines.join(NewLine);
1169
- };
1170
-
1171
- const RendererWorker = 1;
1172
-
1173
- const rpcs = Object.create(null);
1174
- const set = (id, rpc) => {
1175
- rpcs[id] = rpc;
1176
- };
1177
- const get = id => {
1178
- return rpcs[id];
1179
- };
1180
-
1181
- const invoke = (method, ...params) => {
1182
- const rpc = get(RendererWorker);
1183
- // @ts-ignore
1184
- return rpc.invoke(method, ...params);
1280
+ const getBrowser = () => {
1281
+ return `${navigator.userAgent}`;
1185
1282
  };
1186
1283
 
1187
1284
  const version = '0.0.0-dev';
@@ -1225,18 +1322,6 @@ const Process = {
1225
1322
  version
1226
1323
  };
1227
1324
 
1228
- const getDetailString = async () => {
1229
- const [electronVersion, nodeVersion, chromeVersion, version, commit, v8Version, date] = await Promise.all([getElectronVersion(), getNodeVersion(), getChromeVersion(), getVersion(), getCommit(), getV8Version(), getDate()]);
1230
- const now = Date.now();
1231
- const formattedDate = formatAboutDate(date, now);
1232
- const lines = [`Version: ${version}`, `Commit: ${commit}`, `Date: ${formattedDate}`, `Electron: ${electronVersion}`, `Chromium: ${chromeVersion}`, `Node: ${nodeVersion}`, `V8: ${v8Version}`];
1233
- return joinLines(lines);
1234
- };
1235
-
1236
- const getBrowser = () => {
1237
- return `${navigator.userAgent}`;
1238
- };
1239
-
1240
1325
  const getDetailStringWeb = () => {
1241
1326
  const {
1242
1327
  date,
@@ -1250,6 +1335,57 @@ const getDetailStringWeb = () => {
1250
1335
  return lines;
1251
1336
  };
1252
1337
 
1338
+ const loadContent2 = uid => {
1339
+ const lines = getDetailStringWeb();
1340
+ const {
1341
+ oldState
1342
+ } = get$1(uid);
1343
+ const newState = {
1344
+ ...oldState,
1345
+ productName: productNameLong$1,
1346
+ lines,
1347
+ focusId: Ok$2
1348
+ };
1349
+ set$1(uid, oldState, newState);
1350
+ };
1351
+
1352
+ const Ok$1 = 'Ok';
1353
+ const Copy$1 = 'Copy';
1354
+ const Info$1 = 'Info';
1355
+ const CloseDialog = 'Close Dialog';
1356
+
1357
+ const ok = () => {
1358
+ return i18nString(Ok$1);
1359
+ };
1360
+ const copy = () => {
1361
+ return i18nString(Copy$1);
1362
+ };
1363
+ const info = () => {
1364
+ return i18nString(Info$1);
1365
+ };
1366
+ const closeDialog = () => {
1367
+ return i18nString(CloseDialog);
1368
+ };
1369
+
1370
+ const createViewModel = state => {
1371
+ const okMessage = ok();
1372
+ const copyMessage = copy();
1373
+ const closeMessage = closeDialog();
1374
+ const infoMessage = info();
1375
+ const {
1376
+ productName,
1377
+ lines
1378
+ } = state;
1379
+ return {
1380
+ productName,
1381
+ lines,
1382
+ closeMessage,
1383
+ okMessage,
1384
+ copyMessage,
1385
+ infoMessage
1386
+ };
1387
+ };
1388
+
1253
1389
  const Button$2 = 'Button';
1254
1390
  const ButtonPrimary = 'ButtonPrimary';
1255
1391
  const ButtonSecondary = 'ButtonSecondary';
@@ -1344,8 +1480,8 @@ const getSecondaryButtonVirtualDom = (message, onClick, name) => {
1344
1480
  const DialogIcon = 'DialogIcon';
1345
1481
  const DialogHeading = 'DialogHeading';
1346
1482
 
1347
- const Ok$1 = 'Ok';
1348
- const Copy$1 = 'Copy';
1483
+ const Ok = 'Ok';
1484
+ const Copy = 'Copy';
1349
1485
 
1350
1486
  const Focusable = -1;
1351
1487
 
@@ -1397,7 +1533,7 @@ const getDialogVirtualDom = (content, closeMessage, infoMessage, okMessage, copy
1397
1533
  type: Div,
1398
1534
  className: DialogButtonsRow,
1399
1535
  childCount: 2
1400
- }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok$1), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy$1)];
1536
+ }, ...getSecondaryButtonVirtualDom(okMessage, HandleClickOk, Ok), ...getPrimaryButtonVirtualDom(copyMessage, HandleClickCopy, Copy)];
1401
1537
  return dom;
1402
1538
  };
1403
1539
 
@@ -1411,109 +1547,6 @@ const getAboutVirtualDom = (productName, lines, closeMessage, okMessage, copyMes
1411
1547
  }, ...getDialogVirtualDom(content, closeMessage, infoMessage, okMessage, copyMessage, productName)];
1412
1548
  };
1413
1549
 
1414
- const commandIds = ['handleClickClose', 'handleClickOk', 'handleClickCopy', 'handleFocusIn', 'focusNext', 'focusPrevious'];
1415
- const getCommandIds = () => {
1416
- return commandIds;
1417
- };
1418
-
1419
- const Tab = 2;
1420
- const Escape = 8;
1421
-
1422
- const Shift = 1 << 10 >>> 0;
1423
-
1424
- const FocusAbout = 4;
1425
-
1426
- const getKeyBindings = () => {
1427
- return [{
1428
- key: Escape,
1429
- command: 'About.handleClickClose',
1430
- when: FocusAbout
1431
- }, {
1432
- key: Tab,
1433
- command: 'About.focusNext',
1434
- when: FocusAbout
1435
- }, {
1436
- key: Tab | Shift,
1437
- command: 'About.focusPrevious',
1438
- when: FocusAbout
1439
- }];
1440
- };
1441
-
1442
- const handleClickClose = async state => {
1443
- await invoke('Viewlet.closeWidget', 'About');
1444
- return state;
1445
- };
1446
-
1447
- const writeText = async text => {
1448
- await invoke('ClipBoard.writeText', /* text */text);
1449
- };
1450
-
1451
- const handleClickCopy = async state => {
1452
- const {
1453
- lines
1454
- } = state;
1455
- const message = joinLines(lines);
1456
- await writeText(message);
1457
- return state;
1458
- };
1459
-
1460
- const handleClickOk = async state => {
1461
- await invoke('Viewlet.closeWidget', 'About');
1462
- return state;
1463
- };
1464
-
1465
- const handleFocusIn = async state => {
1466
- await invoke('Focus.setFocus', FocusAbout);
1467
- return state;
1468
- };
1469
-
1470
- const loadContent = state => {
1471
- const lines = getDetailStringWeb();
1472
- return {
1473
- ...state,
1474
- productName: productNameLong$1,
1475
- lines,
1476
- focusId: Ok$2
1477
- };
1478
- };
1479
-
1480
- const Ok = 'Ok';
1481
- const Copy = 'Copy';
1482
- const Info$1 = 'Info';
1483
- const CloseDialog = 'Close Dialog';
1484
-
1485
- const ok = () => {
1486
- return i18nString(Ok);
1487
- };
1488
- const copy = () => {
1489
- return i18nString(Copy);
1490
- };
1491
- const info = () => {
1492
- return i18nString(Info$1);
1493
- };
1494
- const closeDialog = () => {
1495
- return i18nString(CloseDialog);
1496
- };
1497
-
1498
- const createViewModel = state => {
1499
- const okMessage = ok();
1500
- const copyMessage = copy();
1501
- const closeMessage = closeDialog();
1502
- const infoMessage = info();
1503
- const {
1504
- productName,
1505
- lines
1506
- } = state;
1507
- return {
1508
- productName,
1509
- lines,
1510
- closeMessage,
1511
- okMessage,
1512
- copyMessage,
1513
- infoMessage
1514
- };
1515
- };
1516
-
1517
1550
  const renderDialog = (oldState, newState) => {
1518
1551
  const viewModel = createViewModel(newState);
1519
1552
  const dom = getAboutVirtualDom(viewModel.productName, viewModel.lines, viewModel.closeMessage, viewModel.okMessage, viewModel.copyMessage, viewModel.infoMessage);
@@ -1523,9 +1556,9 @@ const renderDialog = (oldState, newState) => {
1523
1556
  const getFocusSelector = focusId => {
1524
1557
  switch (focusId) {
1525
1558
  case Copy$2:
1526
- return Copy$1;
1559
+ return Copy;
1527
1560
  case Ok$2:
1528
- return Ok$1;
1561
+ return Ok;
1529
1562
  default:
1530
1563
  return '';
1531
1564
  }
@@ -1556,9 +1589,14 @@ const applyRender = (oldState, newState, diffResult) => {
1556
1589
  return commands;
1557
1590
  };
1558
1591
 
1559
- const doRender = (oldState, newState) => {
1560
- const diffResult = diff(oldState, newState);
1561
- return applyRender(oldState, newState, diffResult);
1592
+ const doRender = (uid, diffResult) => {
1593
+ const {
1594
+ oldState,
1595
+ newState
1596
+ } = get$1(uid);
1597
+ const commands = applyRender(oldState, newState, diffResult);
1598
+ set$1(uid, newState, newState);
1599
+ return commands;
1562
1600
  };
1563
1601
 
1564
1602
  const renderEventListeners = () => {
@@ -1611,6 +1649,14 @@ const showMessageBox = async options => {
1611
1649
 
1612
1650
  const Info = 'info';
1613
1651
 
1652
+ const getDetailString = async () => {
1653
+ const [electronVersion, nodeVersion, chromeVersion, version, commit, v8Version, date] = await Promise.all([getElectronVersion(), getNodeVersion(), getChromeVersion(), getVersion(), getCommit(), getV8Version(), getDate()]);
1654
+ const now = Date.now();
1655
+ const formattedDate = formatAboutDate(date, now);
1656
+ const lines = [`Version: ${version}`, `Commit: ${commit}`, `Date: ${formattedDate}`, `Electron: ${electronVersion}`, `Chromium: ${chromeVersion}`, `Node: ${nodeVersion}`, `V8: ${v8Version}`];
1657
+ return joinLines(lines);
1658
+ };
1659
+
1614
1660
  const showAboutElectron = async () => {
1615
1661
  const windowId = await getWindowId();
1616
1662
  const detail = await getDetailString();
@@ -1645,20 +1691,19 @@ const showAbout = async platform => {
1645
1691
  };
1646
1692
 
1647
1693
  const commandMap = {
1648
- 'About.diff': diff,
1694
+ 'About.create': create,
1695
+ 'About.diff2': diff2,
1696
+ 'About.dispose': dispose,
1649
1697
  'About.focusNext': focusNext,
1650
1698
  'About.focusPrevious': focusPrevious,
1651
1699
  'About.getCommandIds': getCommandIds,
1652
- 'About.getDetailString': getDetailString,
1653
- 'About.getDetailStringWeb': getDetailStringWeb,
1654
1700
  'About.getKeyBindings': getKeyBindings,
1655
- 'About.getVirtualDom': getAboutVirtualDom,
1656
1701
  'About.handleClickClose': handleClickClose,
1657
1702
  'About.handleClickCopy': handleClickCopy,
1658
1703
  'About.handleClickOk': handleClickOk,
1659
1704
  'About.handleFocusIn': handleFocusIn,
1660
- 'About.loadContent': loadContent,
1661
- 'About.render': doRender,
1705
+ 'About.loadContent2': loadContent2,
1706
+ 'About.render2': doRender,
1662
1707
  'About.renderEventListeners': renderEventListeners,
1663
1708
  'About.showAbout': showAbout,
1664
1709
  'About.showAboutElectron': showAboutElectron
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/about-view",
3
- "version": "4.16.0",
3
+ "version": "5.0.0",
4
4
  "description": "About View Worker",
5
5
  "keywords": [
6
6
  "about-view"