@lvce-editor/status-bar-worker 3.19.0 → 3.20.1

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.
@@ -119,11 +119,11 @@ const terminate = () => {
119
119
  };
120
120
 
121
121
  const {
122
- get: get$4,
122
+ get: get$5,
123
123
  getCommandIds,
124
124
  getKeys,
125
125
  registerCommands,
126
- set: set$6,
126
+ set: set$7,
127
127
  wrapCommand,
128
128
  wrapGetter
129
129
  } = create$8();
@@ -139,7 +139,7 @@ const create$7 = (uid, uri, x, y, width, height, platform, assetDir) => {
139
139
  uid,
140
140
  warningCount: 0
141
141
  };
142
- set$6(uid, state, state);
142
+ set$7(uid, state, state);
143
143
  };
144
144
 
145
145
  const isEqual = (oldState, newState) => {
@@ -167,7 +167,7 @@ const diff2 = uid => {
167
167
  const {
168
168
  newState,
169
169
  oldState
170
- } = get$4(uid);
170
+ } = get$5(uid);
171
171
  const result = diff(oldState, newState);
172
172
  return result;
173
173
  };
@@ -721,7 +721,7 @@ const execute = (command, ...args) => {
721
721
 
722
722
  const Two$1 = '2.0';
723
723
  const callbacks = Object.create(null);
724
- const get$3 = id => {
724
+ const get$4 = id => {
725
725
  return callbacks[id];
726
726
  };
727
727
  const remove$1 = id => {
@@ -911,7 +911,7 @@ const warn = (...args) => {
911
911
  console.warn(...args);
912
912
  };
913
913
  const resolve = (id, response) => {
914
- const fn = get$3(id);
914
+ const fn = get$4(id);
915
915
  if (!fn) {
916
916
  console.log(response);
917
917
  warn(`callback ${id} may already be disposed`);
@@ -1244,10 +1244,10 @@ const createMockRpc = ({
1244
1244
  };
1245
1245
 
1246
1246
  const rpcs = Object.create(null);
1247
- const set$5 = (id, rpc) => {
1247
+ const set$6 = (id, rpc) => {
1248
1248
  rpcs[id] = rpc;
1249
1249
  };
1250
- const get$2 = id => {
1250
+ const get$3 = id => {
1251
1251
  return rpcs[id];
1252
1252
  };
1253
1253
  const remove = id => {
@@ -1258,18 +1258,18 @@ const remove = id => {
1258
1258
  const create = rpcId => {
1259
1259
  return {
1260
1260
  async dispose() {
1261
- const rpc = get$2(rpcId);
1261
+ const rpc = get$3(rpcId);
1262
1262
  await rpc.dispose();
1263
1263
  },
1264
1264
  // @ts-ignore
1265
1265
  invoke(method, ...params) {
1266
- const rpc = get$2(rpcId);
1266
+ const rpc = get$3(rpcId);
1267
1267
  // @ts-ignore
1268
1268
  return rpc.invoke(method, ...params);
1269
1269
  },
1270
1270
  // @ts-ignore
1271
1271
  invokeAndTransfer(method, ...params) {
1272
- const rpc = get$2(rpcId);
1272
+ const rpc = get$3(rpcId);
1273
1273
  // @ts-ignore
1274
1274
  return rpc.invokeAndTransfer(method, ...params);
1275
1275
  },
@@ -1277,7 +1277,7 @@ const create = rpcId => {
1277
1277
  const mockRpc = createMockRpc({
1278
1278
  commandMap
1279
1279
  });
1280
- set$5(rpcId, mockRpc);
1280
+ set$6(rpcId, mockRpc);
1281
1281
  // @ts-ignore
1282
1282
  mockRpc[Symbol.dispose] = () => {
1283
1283
  remove(rpcId);
@@ -1286,7 +1286,7 @@ const create = rpcId => {
1286
1286
  return mockRpc;
1287
1287
  },
1288
1288
  set(rpc) {
1289
- set$5(rpcId, rpc);
1289
+ set$6(rpcId, rpc);
1290
1290
  }
1291
1291
  };
1292
1292
  };
@@ -1296,10 +1296,174 @@ const Status = 'status';
1296
1296
 
1297
1297
  const MaskIcon = 'MaskIcon';
1298
1298
 
1299
+ const Audio = 0;
1299
1300
  const Button$1 = 1;
1301
+ const Col = 2;
1302
+ const ColGroup = 3;
1300
1303
  const Div = 4;
1304
+ const H1 = 5;
1305
+ const Input = 6;
1306
+ const Kbd = 7;
1301
1307
  const Span = 8;
1308
+ const Table = 9;
1309
+ const TBody = 10;
1310
+ const Td = 11;
1302
1311
  const Text = 12;
1312
+ const Th = 13;
1313
+ const THead = 14;
1314
+ const Tr = 15;
1315
+ const I = 16;
1316
+ const Img = 17;
1317
+ const Root = 0;
1318
+ const Ins = 20;
1319
+ const Del = 21;
1320
+ const H2 = 22;
1321
+ const H3 = 23;
1322
+ const H4 = 24;
1323
+ const H5 = 25;
1324
+ const H6 = 26;
1325
+ const Article = 27;
1326
+ const Aside = 28;
1327
+ const Footer = 29;
1328
+ const Header = 30;
1329
+ const Nav = 40;
1330
+ const Section = 41;
1331
+ const Search = 42;
1332
+ const Dd = 43;
1333
+ const Dl = 44;
1334
+ const Figcaption = 45;
1335
+ const Figure = 46;
1336
+ const Hr = 47;
1337
+ const Li = 48;
1338
+ const Ol = 49;
1339
+ const P = 50;
1340
+ const Pre = 51;
1341
+ const A = 53;
1342
+ const Abbr = 54;
1343
+ const Br = 55;
1344
+ const Cite = 56;
1345
+ const Data = 57;
1346
+ const Time = 58;
1347
+ const Tfoot = 59;
1348
+ const Ul = 60;
1349
+ const Video = 61;
1350
+ const TextArea = 62;
1351
+ const Select = 63;
1352
+ const Option = 64;
1353
+ const Code = 65;
1354
+ const Label = 66;
1355
+ const Dt = 67;
1356
+ const Iframe = 68;
1357
+ const Main = 69;
1358
+ const Strong = 70;
1359
+ const Em = 71;
1360
+ const Style = 72;
1361
+ const Html = 73;
1362
+ const Head = 74;
1363
+ const Title = 75;
1364
+ const Meta = 76;
1365
+ const Canvas = 77;
1366
+ const Form = 78;
1367
+ const BlockQuote = 79;
1368
+ const Quote = 80;
1369
+ const Circle = 81;
1370
+ const Defs = 82;
1371
+ const Ellipse = 83;
1372
+ const G = 84;
1373
+ const Line = 85;
1374
+ const Path = 86;
1375
+ const Polygon = 87;
1376
+ const Polyline = 88;
1377
+ const Rect = 89;
1378
+ const Svg = 90;
1379
+ const Use = 91;
1380
+ const Reference = 100;
1381
+
1382
+ const VirtualDomElements = {
1383
+ __proto__: null,
1384
+ A,
1385
+ Abbr,
1386
+ Article,
1387
+ Aside,
1388
+ Audio,
1389
+ BlockQuote,
1390
+ Br,
1391
+ Button: Button$1,
1392
+ Canvas,
1393
+ Circle,
1394
+ Cite,
1395
+ Code,
1396
+ Col,
1397
+ ColGroup,
1398
+ Data,
1399
+ Dd,
1400
+ Defs,
1401
+ Del,
1402
+ Div,
1403
+ Dl,
1404
+ Dt,
1405
+ Ellipse,
1406
+ Em,
1407
+ Figcaption,
1408
+ Figure,
1409
+ Footer,
1410
+ Form,
1411
+ G,
1412
+ H1,
1413
+ H2,
1414
+ H3,
1415
+ H4,
1416
+ H5,
1417
+ H6,
1418
+ Head,
1419
+ Header,
1420
+ Hr,
1421
+ Html,
1422
+ I,
1423
+ Iframe,
1424
+ Img,
1425
+ Input,
1426
+ Ins,
1427
+ Kbd,
1428
+ Label,
1429
+ Li,
1430
+ Line,
1431
+ Main,
1432
+ Meta,
1433
+ Nav,
1434
+ Ol,
1435
+ Option,
1436
+ P,
1437
+ Path,
1438
+ Polygon,
1439
+ Polyline,
1440
+ Pre,
1441
+ Quote,
1442
+ Rect,
1443
+ Reference,
1444
+ Root,
1445
+ Search,
1446
+ Section,
1447
+ Select,
1448
+ Span,
1449
+ Strong,
1450
+ Style,
1451
+ Svg,
1452
+ TBody,
1453
+ THead,
1454
+ Table,
1455
+ Td,
1456
+ Text,
1457
+ TextArea,
1458
+ Tfoot,
1459
+ Th,
1460
+ Time,
1461
+ Title,
1462
+ Tr,
1463
+ Ul,
1464
+ Use,
1465
+ Video
1466
+ };
1303
1467
 
1304
1468
  const Button = 'event.button';
1305
1469
  const ClientX = 'event.clientX';
@@ -1315,17 +1479,17 @@ const SetFocusContext = 'Viewlet.setFocusContext';
1315
1479
 
1316
1480
  const {
1317
1481
  invoke: invoke$3,
1318
- set: set$4
1482
+ set: set$5
1319
1483
  } = create(ExtensionManagementWorker);
1320
1484
 
1321
1485
  const {
1322
1486
  invoke: invoke$2,
1323
- set: set$3
1487
+ set: set$4
1324
1488
  } = create(RendererProcess);
1325
1489
 
1326
1490
  const {
1327
1491
  invoke: invoke$1,
1328
- set: set$2
1492
+ set: set$3
1329
1493
  } = create(RendererWorker);
1330
1494
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1331
1495
  number(uid);
@@ -1357,8 +1521,18 @@ const handleClickProblems = async () => {
1357
1521
  await invoke$1('Panel.toggleView', 'Problems');
1358
1522
  };
1359
1523
 
1524
+ const EditorEncoding = 'EditorEncoding';
1525
+ const EditorIndentation = 'EditorIndentation';
1526
+ const EditorLanguage = 'EditorLanguage';
1527
+ const EditorPosition = 'EditorPosition';
1360
1528
  const Notifications = 'Notifications';
1361
1529
  const Problems = 'Problems';
1530
+ const isEditorStatus = name => {
1531
+ return [EditorEncoding, EditorIndentation, EditorLanguage, EditorPosition].includes(name);
1532
+ };
1533
+ const isRight = name => {
1534
+ return name === Notifications || isEditorStatus(name);
1535
+ };
1362
1536
 
1363
1537
  const handleClick = async (state, name) => {
1364
1538
  if (!name) {
@@ -1376,7 +1550,7 @@ const handleClick = async (state, name) => {
1376
1550
  await handleClickNotification();
1377
1551
  } else if (item.name === Problems) {
1378
1552
  await handleClickProblems();
1379
- } else {
1553
+ } else if (!isEditorStatus(item.name)) {
1380
1554
  await handleClickExtensionStatusBarItem(name);
1381
1555
  }
1382
1556
  // TODO
@@ -1397,6 +1571,31 @@ const handleContextMenu = async (state, button, x, y) => {
1397
1571
  return state;
1398
1572
  };
1399
1573
 
1574
+ const textItem = (name, text, ariaLabel, tooltip) => ({
1575
+ ariaLabel,
1576
+ command: '',
1577
+ elements: [{
1578
+ type: 'text',
1579
+ value: text
1580
+ }],
1581
+ name,
1582
+ tooltip
1583
+ });
1584
+ const getEditorStatusBarItems = status => {
1585
+ if (!status) {
1586
+ return [];
1587
+ }
1588
+ const {
1589
+ column,
1590
+ encoding,
1591
+ languageId,
1592
+ line,
1593
+ tabSize
1594
+ } = status;
1595
+ const encodingLabel = encoding === 'utf8' ? ['UTF', '8'].join('-') : encoding;
1596
+ return [textItem(EditorPosition, `Ln ${line}, Col ${column}`, `Line ${line}, Column ${column}`, 'Go to Line/Column'), textItem(EditorIndentation, `Spaces: ${tabSize}`, `Spaces: ${tabSize}`, 'Select Indentation'), textItem(EditorEncoding, encodingLabel, `Encoding: ${encodingLabel}`, 'Select Encoding'), textItem(EditorLanguage, languageId, `Language: ${languageId}`, 'Select Language Mode')];
1597
+ };
1598
+
1400
1599
  const getAriaLabel = count => {
1401
1600
  if (count === 0) {
1402
1601
  return 'No Notifications';
@@ -1472,11 +1671,12 @@ const getProblemsStatusBarItem = (errorCount, warningCount, enabled) => {
1472
1671
  };
1473
1672
 
1474
1673
  const getBuiltinStatusBarItems = async (errorCount, warningCount, {
1674
+ editorStatus,
1475
1675
  notificationCount = 0,
1476
1676
  notificationsEnabled = true,
1477
1677
  problemsEnabled = true
1478
1678
  } = {}) => {
1479
- return [...getNotificationsStatusBarItem(notificationsEnabled, notificationCount), ...getProblemsStatusBarItem(errorCount, warningCount, problemsEnabled)];
1679
+ return [...getEditorStatusBarItems(editorStatus), ...getNotificationsStatusBarItem(notificationsEnabled, notificationCount), ...getProblemsStatusBarItem(errorCount, warningCount, problemsEnabled)];
1480
1680
  };
1481
1681
 
1482
1682
  const getExtensionStatusBarItems = async (assetDir, platform) => {
@@ -1556,6 +1756,7 @@ const getStatusBarItems = async ({
1556
1756
  assetDir,
1557
1757
  builtinNotificationsEnabled = true,
1558
1758
  builtinProblemsEnabled = true,
1759
+ editorStatus,
1559
1760
  errorCount,
1560
1761
  platform,
1561
1762
  showItems,
@@ -1568,6 +1769,7 @@ const getStatusBarItems = async ({
1568
1769
  const notificationCount = await getNotificationCount();
1569
1770
  const uiStatusBarItems = toUiStatusBarItems(extensionStatusBarItems);
1570
1771
  const extraItems = await getBuiltinStatusBarItems(errorCount, warningCount, {
1772
+ editorStatus,
1571
1773
  notificationCount,
1572
1774
  notificationsEnabled: builtinNotificationsEnabled,
1573
1775
  problemsEnabled: builtinProblemsEnabled
@@ -1614,6 +1816,8 @@ const text = data => {
1614
1816
  };
1615
1817
  };
1616
1818
 
1819
+ new Set(Object.values(VirtualDomElements));
1820
+
1617
1821
  const HandleContextMenu = 2;
1618
1822
  const HandleClick = 11;
1619
1823
 
@@ -1754,8 +1958,8 @@ const isConnected = () => {
1754
1958
  const invoke = (method, ...params) => {
1755
1959
  return invoke$2(method, ...params);
1756
1960
  };
1757
- const set$1 = rpc => {
1758
- set$3(rpc);
1961
+ const set$2 = rpc => {
1962
+ set$4(rpc);
1759
1963
  state.connected = true;
1760
1964
  };
1761
1965
 
@@ -1769,8 +1973,8 @@ const render2 = (uid, diffResult) => {
1769
1973
  const {
1770
1974
  newState,
1771
1975
  oldState
1772
- } = get$4(uid);
1773
- set$6(uid, newState, newState);
1976
+ } = get$5(uid);
1977
+ set$7(uid, newState, newState);
1774
1978
  const commands = applyRender(oldState, newState, diffResult);
1775
1979
  if (!isConnected()) {
1776
1980
  return commands;
@@ -1784,7 +1988,7 @@ const renderOutOfBand = async uid => {
1784
1988
  }
1785
1989
  const {
1786
1990
  newState
1787
- } = get$4(uid);
1991
+ } = get$5(uid);
1788
1992
  if (newState.initial) {
1789
1993
  return;
1790
1994
  }
@@ -1804,12 +2008,12 @@ const handleExtensionManagementChange = async () => {
1804
2008
  const {
1805
2009
  newState,
1806
2010
  oldState
1807
- } = get$4(uid);
2011
+ } = get$5(uid);
1808
2012
  const newerState = await handleItemsChanged(newState);
1809
2013
  if (newState === newerState || oldState === newerState) {
1810
2014
  continue;
1811
2015
  }
1812
- set$6(uid, oldState, {
2016
+ set$7(uid, oldState, {
1813
2017
  ...newState,
1814
2018
  ...newerState
1815
2019
  });
@@ -1836,25 +2040,25 @@ const handleNotificationCountChanged = (state, count) => {
1836
2040
  };
1837
2041
 
1838
2042
  let latestCount;
1839
- const get$1 = () => {
2043
+ const get$2 = () => {
1840
2044
  return latestCount;
1841
2045
  };
1842
- const set = count => {
2046
+ const set$1 = count => {
1843
2047
  latestCount = count;
1844
2048
  };
1845
2049
 
1846
2050
  const handleNotificationCountChangedAll = async count => {
1847
- set(count);
2051
+ set$1(count);
1848
2052
  for (const uid of getKeys()) {
1849
2053
  const {
1850
2054
  newState,
1851
2055
  oldState
1852
- } = get$4(uid);
2056
+ } = get$5(uid);
1853
2057
  const newerState = handleNotificationCountChanged(newState, count);
1854
2058
  if (newState === newerState || oldState === newerState) {
1855
2059
  continue;
1856
2060
  }
1857
- set$6(uid, oldState, newerState);
2061
+ set$7(uid, oldState, newerState);
1858
2062
  await renderOutOfBand(uid);
1859
2063
  }
1860
2064
  };
@@ -1869,7 +2073,60 @@ const handleExtensionManagementMessagePort = async port => {
1869
2073
  commandMap: commandMap$1,
1870
2074
  messagePort: port
1871
2075
  });
1872
- set$4(rpc);
2076
+ set$5(rpc);
2077
+ };
2078
+
2079
+ let editorStatus;
2080
+ const get$1 = () => editorStatus;
2081
+ const set = value => {
2082
+ editorStatus = value;
2083
+ };
2084
+
2085
+ const equals = (oldStatus, newStatus) => {
2086
+ if (!oldStatus || !newStatus) {
2087
+ return oldStatus === newStatus;
2088
+ }
2089
+ return oldStatus.column === newStatus.column && oldStatus.encoding === newStatus.encoding && oldStatus.languageId === newStatus.languageId && oldStatus.line === newStatus.line && oldStatus.tabSize === newStatus.tabSize;
2090
+ };
2091
+ const updateItems = (items, status) => {
2092
+ const remainingItems = items.filter(item => !isEditorStatus(item.name));
2093
+ const editorItems = getEditorStatusBarItems(status);
2094
+ if (editorItems.length === 0) {
2095
+ return remainingItems;
2096
+ }
2097
+ const notificationIndex = remainingItems.findIndex(item => item.name === Notifications);
2098
+ const insertIndex = notificationIndex === -1 ? remainingItems.length : notificationIndex;
2099
+ return [...remainingItems.slice(0, insertIndex), ...editorItems, ...remainingItems.slice(insertIndex)];
2100
+ };
2101
+ const handleEditorStatusChanged = (state, editorStatus) => {
2102
+ const {
2103
+ editorStatus: oldEditorStatus,
2104
+ statusBarItemsRight
2105
+ } = state;
2106
+ if (equals(oldEditorStatus, editorStatus)) {
2107
+ return state;
2108
+ }
2109
+ return {
2110
+ ...state,
2111
+ editorStatus,
2112
+ statusBarItemsRight: updateItems(statusBarItemsRight, editorStatus)
2113
+ };
2114
+ };
2115
+
2116
+ const handleEditorStatusChangedAll = async editorStatus => {
2117
+ set(editorStatus);
2118
+ for (const uid of getKeys()) {
2119
+ const {
2120
+ newState,
2121
+ oldState
2122
+ } = get$5(uid);
2123
+ const newerState = handleEditorStatusChanged(newState, editorStatus);
2124
+ if (newState === newerState || oldState === newerState) {
2125
+ continue;
2126
+ }
2127
+ set$7(uid, oldState, newerState);
2128
+ await renderOutOfBand(uid);
2129
+ }
1873
2130
  };
1874
2131
 
1875
2132
  const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
@@ -1883,12 +2140,13 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
1883
2140
  };
1884
2141
  const rpc = await create$2({
1885
2142
  commandMap: {
2143
+ 'StatusBar.handleEditorStatusChanged': handleEditorStatusChangedAll,
1886
2144
  'Viewlet.executeViewletCommand': executeViewletCommand
1887
2145
  },
1888
2146
  messagePort: port
1889
2147
  });
1890
2148
  if (setAsRendererProcess) {
1891
- set$1(rpc);
2149
+ set$2(rpc);
1892
2150
  }
1893
2151
  };
1894
2152
 
@@ -1984,6 +2242,7 @@ const loadContent = async state => {
1984
2242
  platform,
1985
2243
  warningCount
1986
2244
  } = state;
2245
+ const editorStatus = get$1();
1987
2246
  const {
1988
2247
  builtinNotificationsEnabled,
1989
2248
  builtinProblemsEnabled,
@@ -1993,6 +2252,7 @@ const loadContent = async state => {
1993
2252
  assetDir,
1994
2253
  builtinNotificationsEnabled: builtinNotificationsEnabled,
1995
2254
  builtinProblemsEnabled: builtinProblemsEnabled,
2255
+ editorStatus,
1996
2256
  errorCount,
1997
2257
  platform,
1998
2258
  showItems: itemsVisible,
@@ -2000,13 +2260,14 @@ const loadContent = async state => {
2000
2260
  });
2001
2261
  const loadedState = {
2002
2262
  ...state,
2263
+ editorStatus,
2003
2264
  errorCount: 0,
2004
2265
  initial: false,
2005
- statusBarItemsLeft: statusBarItems.filter(item => item.name !== Notifications),
2006
- statusBarItemsRight: statusBarItems.filter(item => item.name === Notifications),
2266
+ statusBarItemsLeft: statusBarItems.filter(item => !isRight(item.name)),
2267
+ statusBarItemsRight: statusBarItems.filter(item => isRight(item.name)),
2007
2268
  warningCount: 0
2008
2269
  };
2009
- const latestNotificationCount = get$1();
2270
+ const latestNotificationCount = get$2();
2010
2271
  if (latestNotificationCount === undefined) {
2011
2272
  return loadedState;
2012
2273
  }
@@ -2072,7 +2333,7 @@ const initializeRenderWorker = async () => {
2072
2333
  const rpc = await create$1({
2073
2334
  commandMap: commandMap
2074
2335
  });
2075
- set$2(rpc);
2336
+ set$3(rpc);
2076
2337
  };
2077
2338
 
2078
2339
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.19.0",
3
+ "version": "3.20.1",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",