@lvce-editor/problems-view 1.1.0 → 1.3.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.
@@ -1013,6 +1013,7 @@ const copyMessage = async state => {
1013
1013
  };
1014
1014
 
1015
1015
  const User = 1;
1016
+ const Script = 2;
1016
1017
 
1017
1018
  const {
1018
1019
  get,
@@ -1022,6 +1023,7 @@ const {
1022
1023
 
1023
1024
  const None$1 = 0;
1024
1025
  const Table = 1;
1026
+ const List = 2;
1025
1027
 
1026
1028
  const create = (id, uri, x, y, width, height, args, parentUid) => {
1027
1029
  const state = {
@@ -1077,6 +1079,13 @@ const diff2 = uid => {
1077
1079
  return diffResult;
1078
1080
  };
1079
1081
 
1082
+ const focusIndex = (state, index) => {
1083
+ return {
1084
+ ...state,
1085
+ focusedIndex: index
1086
+ };
1087
+ };
1088
+
1080
1089
  const None = 'none';
1081
1090
  const Tree$1 = 'tree';
1082
1091
  const TreeItem$1 = 'treeitem';
@@ -1252,19 +1261,137 @@ const handleArrowRight = state => {
1252
1261
  };
1253
1262
  };
1254
1263
 
1264
+ const handleContextMenu = async (state, eventX, eventY) => {
1265
+ // @ts-ignore
1266
+ // await ContextMenu.show(eventX, eventY, MenuEntryId.Problems)
1267
+ return state;
1268
+ };
1269
+
1270
+ const handleIconThemeChange = state => {
1271
+ return {
1272
+ ...state,
1273
+ problems: [...state.problems]
1274
+ };
1275
+ };
1276
+
1255
1277
  const initialize = async () => {
1256
1278
  // TODO create connection to editor worker
1257
1279
  };
1258
1280
 
1281
+ const getProblems = async state => {
1282
+ // TODO ask editor worker for problems
1283
+ return [];
1284
+ };
1285
+
1286
+ const emptyObject = {};
1287
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1288
+ const i18nString = (key, placeholders = emptyObject) => {
1289
+ if (placeholders === emptyObject) {
1290
+ return key;
1291
+ }
1292
+ const replacer = (match, rest) => {
1293
+ return placeholders[rest];
1294
+ };
1295
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
1296
+ };
1297
+
1298
+ const ClearFilters = 'Clear Filters';
1299
+ const Code = 'Code';
1300
+ const File = 'File';
1301
+ const Filter$3 = 'Filter';
1302
+ const LineColumn = '[Ln {PH1}, Col {PH2}]';
1303
+ const Message$1 = 'Message';
1304
+ const NoProblemsDetected = 'No problems have been detected in the workspace.';
1305
+ const NoResultsFoundWithProvidedFilterCriteria = 'No results found with provided filter criteria.';
1306
+ const ProblemsDetected = 'Some problems have been detected in the workspace.';
1307
+ const Source = 'Source';
1308
+
1309
+ const noProblemsDetected = () => {
1310
+ return i18nString(NoProblemsDetected);
1311
+ };
1312
+ const getMessage = problemsCount => {
1313
+ if (problemsCount === 0) {
1314
+ return i18nString(NoProblemsDetected);
1315
+ }
1316
+ return i18nString(ProblemsDetected);
1317
+ };
1318
+ const atLineColumn = (line, column) => {
1319
+ return i18nString(LineColumn, {
1320
+ PH1: line,
1321
+ PH2: column
1322
+ });
1323
+ };
1324
+ const clearFilter = () => {
1325
+ return i18nString(ClearFilters);
1326
+ };
1327
+ const code = () => {
1328
+ return i18nString(Code);
1329
+ };
1330
+ const message = () => {
1331
+ return i18nString(Message$1);
1332
+ };
1333
+ const file = () => {
1334
+ return i18nString(File);
1335
+ };
1336
+ const filter = () => {
1337
+ return i18nString(Filter$3);
1338
+ };
1339
+ const source = () => {
1340
+ return i18nString(Source);
1341
+ };
1342
+ const noResultsFoundWithProvidedFilterCriteria = () => {
1343
+ return i18nString(NoResultsFoundWithProvidedFilterCriteria);
1344
+ };
1345
+
1346
+ const getSavedViewMode = savedState => {
1347
+ if (savedState && typeof savedState.viewMode === 'number') {
1348
+ return savedState.viewMode;
1349
+ }
1350
+ return List;
1351
+ };
1352
+ const getSavedFilterValue = savedState => {
1353
+ if (savedState && typeof savedState.filterValue === 'string') {
1354
+ return savedState.filterValue;
1355
+ }
1356
+ return '';
1357
+ };
1358
+ const isString = value => {
1359
+ return typeof value === 'string';
1360
+ };
1361
+ const getSavedCollapsedUris = savedState => {
1362
+ if (savedState && savedState.collapsedUris && Array.isArray(savedState.collapsedUris) && savedState.collapsedUris.every(isString)) {
1363
+ return savedState.collapsedUris;
1364
+ }
1365
+ return [];
1366
+ };
1367
+ const loadContent = async (state, savedState) => {
1368
+ const problems = await getProblems();
1369
+ const message = getMessage(problems.length);
1370
+ const viewMode = getSavedViewMode(savedState);
1371
+ const filterValue = getSavedFilterValue(savedState);
1372
+ const collapsedUris = getSavedCollapsedUris(savedState);
1373
+ return {
1374
+ ...state,
1375
+ problems,
1376
+ message,
1377
+ viewMode,
1378
+ filterValue,
1379
+ inputSource: Script,
1380
+ filteredProblems: problems,
1381
+ listItems: [],
1382
+ collapsedUris
1383
+ };
1384
+ };
1385
+
1259
1386
  const Chevron = 'Chevron';
1260
1387
  const FileIcon = 'FileIcon';
1261
- const Filter$3 = 'Filter';
1388
+ const Filter$2 = 'Filter';
1262
1389
  const Highlight = 'Highlight';
1263
1390
  const IconButton = 'IconButton';
1264
1391
  const InputBox = 'InputBox';
1265
1392
  const Label = 'Label';
1266
1393
  const LabelDetail = 'LabelDetail';
1267
- const Message$1 = 'Message';
1394
+ const Message = 'Message';
1268
1395
  const MessageAction = 'MessageAction';
1269
1396
  const Problem = 'Problem';
1270
1397
  const ProblemAt = 'ProblemAt';
@@ -1313,16 +1440,16 @@ const getActionButtonVirtualDom = action => {
1313
1440
  }, getIconVirtualDom(icon)];
1314
1441
  };
1315
1442
 
1316
- const Filter$2 = 'filter';
1443
+ const Filter$1 = 'filter';
1317
1444
 
1318
- const Filter$1 = 'Filter';
1445
+ const Filter = 'Filter';
1319
1446
 
1320
1447
  const getProblemsFilterVirtualDom = action => {
1321
1448
  // TODO avoid mutation
1322
1449
  const dom = [];
1323
1450
  dom.push({
1324
1451
  type: VirtualDomElements.Div,
1325
- className: Filter$3,
1452
+ className: Filter$2,
1326
1453
  childCount: 1
1327
1454
  }, {
1328
1455
  type: VirtualDomElements.Input,
@@ -1332,14 +1459,14 @@ const getProblemsFilterVirtualDom = action => {
1332
1459
  autocorrect: 'off',
1333
1460
  placeholder: action.placeholder,
1334
1461
  onInput: action.command,
1335
- name: Filter$2,
1462
+ name: Filter$1,
1336
1463
  value: action.value
1337
1464
  });
1338
1465
  // @ts-ignore
1339
1466
  dom[0].childCount++;
1340
1467
  dom.push(...getActionButtonVirtualDom({
1341
1468
  id: 'more filters',
1342
- icon: Filter$1,
1469
+ icon: Filter,
1343
1470
  command: 'more filters'
1344
1471
  }));
1345
1472
  return dom;
@@ -1414,59 +1541,6 @@ const getTreeItemIndent = depth => {
1414
1541
  return `${depth * defaultIndent}rem`;
1415
1542
  };
1416
1543
 
1417
- const emptyObject = {};
1418
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1419
- const i18nString = (key, placeholders = emptyObject) => {
1420
- if (placeholders === emptyObject) {
1421
- return key;
1422
- }
1423
- const replacer = (match, rest) => {
1424
- return placeholders[rest];
1425
- };
1426
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1427
- };
1428
-
1429
- const ClearFilters = 'Clear Filters';
1430
- const Code = 'Code';
1431
- const File = 'File';
1432
- const Filter = 'Filter';
1433
- const LineColumn = '[Ln {PH1}, Col {PH2}]';
1434
- const Message = 'Message';
1435
- const NoProblemsDetected = 'No problems have been detected in the workspace.';
1436
- const NoResultsFoundWithProvidedFilterCriteria = 'No results found with provided filter criteria.';
1437
- const Source = 'Source';
1438
-
1439
- const noProblemsDetected = () => {
1440
- return i18nString(NoProblemsDetected);
1441
- };
1442
- const atLineColumn = (line, column) => {
1443
- return i18nString(LineColumn, {
1444
- PH1: line,
1445
- PH2: column
1446
- });
1447
- };
1448
- const clearFilter = () => {
1449
- return i18nString(ClearFilters);
1450
- };
1451
- const code = () => {
1452
- return i18nString(Code);
1453
- };
1454
- const message = () => {
1455
- return i18nString(Message);
1456
- };
1457
- const file = () => {
1458
- return i18nString(File);
1459
- };
1460
- const filter = () => {
1461
- return i18nString(Filter);
1462
- };
1463
- const source = () => {
1464
- return i18nString(Source);
1465
- };
1466
- const noResultsFoundWithProvidedFilterCriteria = () => {
1467
- return i18nString(NoResultsFoundWithProvidedFilterCriteria);
1468
- };
1469
-
1470
1544
  const getProblemVirtualDom = problem => {
1471
1545
  const {
1472
1546
  message,
@@ -1566,7 +1640,7 @@ const getProblemsNoProblemsFoundVirtualDom = filterValue => {
1566
1640
  const dom = [];
1567
1641
  dom.push({
1568
1642
  type: VirtualDomElements.Div,
1569
- className: Message$1,
1643
+ className: Message,
1570
1644
  childCount: 1
1571
1645
  });
1572
1646
  if (filterValue) {
@@ -1831,6 +1905,25 @@ const render2 = (uid, diffResult) => {
1831
1905
  return commands;
1832
1906
  };
1833
1907
 
1908
+ const renderActions = () => {
1909
+ return [{
1910
+ type: VirtualDomElements.Div,
1911
+ childCount: 1
1912
+ }, text('not implemented')];
1913
+ };
1914
+
1915
+ const renderEventListeners = () => {
1916
+ // TODO
1917
+ return [];
1918
+ };
1919
+
1920
+ const resize = (state, dimensions) => {
1921
+ return {
1922
+ ...state,
1923
+ ...dimensions
1924
+ };
1925
+ };
1926
+
1834
1927
  const saveState = state => {
1835
1928
  const {
1836
1929
  viewMode,
@@ -1844,17 +1937,40 @@ const saveState = state => {
1844
1937
  };
1845
1938
  };
1846
1939
 
1940
+ const viewAsList = state => {
1941
+ return {
1942
+ ...state,
1943
+ viewMode: List
1944
+ };
1945
+ };
1946
+
1947
+ const viewAsTable = state => {
1948
+ return {
1949
+ ...state,
1950
+ viewMode: Table
1951
+ };
1952
+ };
1953
+
1847
1954
  const commandMap = {
1955
+ 'Problems.copyMessage': copyMessage,
1956
+ 'Problems.renderEventListeners': renderEventListeners,
1848
1957
  'Problems.create': create,
1849
1958
  'Problems.diff2': diff2,
1959
+ 'Problems.focusIndex': focusIndex,
1850
1960
  'Problems.getKeyBindings': getKeyBindings,
1851
1961
  'Problems.handleArrowLeft': wrapCommand(handleArrowLeft),
1852
1962
  'Problems.handleArrowRight': wrapCommand(handleArrowRight),
1853
1963
  'Problems.initialize': initialize,
1964
+ 'Problems.loadContent': wrapCommand(loadContent),
1854
1965
  'Problems.render2': render2,
1966
+ 'Problems.renderActions': renderActions,
1967
+ 'Problems.resize': resize,
1855
1968
  'Problems.saveState': saveState,
1856
1969
  'Problems.terminate': terminate,
1857
- 'Problems.copyMessage': copyMessage
1970
+ 'Problems.handleIconThemeChange': handleIconThemeChange,
1971
+ 'Problems.handleContextMenu': handleContextMenu,
1972
+ 'Problems.viewAsTable': viewAsTable,
1973
+ 'Problems.viewAsList': viewAsList
1858
1974
  };
1859
1975
 
1860
1976
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",