@lvce-editor/problems-view 1.2.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 = {
@@ -1259,19 +1261,137 @@ const handleArrowRight = state => {
1259
1261
  };
1260
1262
  };
1261
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
+
1262
1277
  const initialize = async () => {
1263
1278
  // TODO create connection to editor worker
1264
1279
  };
1265
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
+
1266
1386
  const Chevron = 'Chevron';
1267
1387
  const FileIcon = 'FileIcon';
1268
- const Filter$3 = 'Filter';
1388
+ const Filter$2 = 'Filter';
1269
1389
  const Highlight = 'Highlight';
1270
1390
  const IconButton = 'IconButton';
1271
1391
  const InputBox = 'InputBox';
1272
1392
  const Label = 'Label';
1273
1393
  const LabelDetail = 'LabelDetail';
1274
- const Message$1 = 'Message';
1394
+ const Message = 'Message';
1275
1395
  const MessageAction = 'MessageAction';
1276
1396
  const Problem = 'Problem';
1277
1397
  const ProblemAt = 'ProblemAt';
@@ -1320,16 +1440,16 @@ const getActionButtonVirtualDom = action => {
1320
1440
  }, getIconVirtualDom(icon)];
1321
1441
  };
1322
1442
 
1323
- const Filter$2 = 'filter';
1443
+ const Filter$1 = 'filter';
1324
1444
 
1325
- const Filter$1 = 'Filter';
1445
+ const Filter = 'Filter';
1326
1446
 
1327
1447
  const getProblemsFilterVirtualDom = action => {
1328
1448
  // TODO avoid mutation
1329
1449
  const dom = [];
1330
1450
  dom.push({
1331
1451
  type: VirtualDomElements.Div,
1332
- className: Filter$3,
1452
+ className: Filter$2,
1333
1453
  childCount: 1
1334
1454
  }, {
1335
1455
  type: VirtualDomElements.Input,
@@ -1339,14 +1459,14 @@ const getProblemsFilterVirtualDom = action => {
1339
1459
  autocorrect: 'off',
1340
1460
  placeholder: action.placeholder,
1341
1461
  onInput: action.command,
1342
- name: Filter$2,
1462
+ name: Filter$1,
1343
1463
  value: action.value
1344
1464
  });
1345
1465
  // @ts-ignore
1346
1466
  dom[0].childCount++;
1347
1467
  dom.push(...getActionButtonVirtualDom({
1348
1468
  id: 'more filters',
1349
- icon: Filter$1,
1469
+ icon: Filter,
1350
1470
  command: 'more filters'
1351
1471
  }));
1352
1472
  return dom;
@@ -1421,59 +1541,6 @@ const getTreeItemIndent = depth => {
1421
1541
  return `${depth * defaultIndent}rem`;
1422
1542
  };
1423
1543
 
1424
- const emptyObject = {};
1425
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1426
- const i18nString = (key, placeholders = emptyObject) => {
1427
- if (placeholders === emptyObject) {
1428
- return key;
1429
- }
1430
- const replacer = (match, rest) => {
1431
- return placeholders[rest];
1432
- };
1433
- return key.replaceAll(RE_PLACEHOLDER, replacer);
1434
- };
1435
-
1436
- const ClearFilters = 'Clear Filters';
1437
- const Code = 'Code';
1438
- const File = 'File';
1439
- const Filter = 'Filter';
1440
- const LineColumn = '[Ln {PH1}, Col {PH2}]';
1441
- const Message = 'Message';
1442
- const NoProblemsDetected = 'No problems have been detected in the workspace.';
1443
- const NoResultsFoundWithProvidedFilterCriteria = 'No results found with provided filter criteria.';
1444
- const Source = 'Source';
1445
-
1446
- const noProblemsDetected = () => {
1447
- return i18nString(NoProblemsDetected);
1448
- };
1449
- const atLineColumn = (line, column) => {
1450
- return i18nString(LineColumn, {
1451
- PH1: line,
1452
- PH2: column
1453
- });
1454
- };
1455
- const clearFilter = () => {
1456
- return i18nString(ClearFilters);
1457
- };
1458
- const code = () => {
1459
- return i18nString(Code);
1460
- };
1461
- const message = () => {
1462
- return i18nString(Message);
1463
- };
1464
- const file = () => {
1465
- return i18nString(File);
1466
- };
1467
- const filter = () => {
1468
- return i18nString(Filter);
1469
- };
1470
- const source = () => {
1471
- return i18nString(Source);
1472
- };
1473
- const noResultsFoundWithProvidedFilterCriteria = () => {
1474
- return i18nString(NoResultsFoundWithProvidedFilterCriteria);
1475
- };
1476
-
1477
1544
  const getProblemVirtualDom = problem => {
1478
1545
  const {
1479
1546
  message,
@@ -1573,7 +1640,7 @@ const getProblemsNoProblemsFoundVirtualDom = filterValue => {
1573
1640
  const dom = [];
1574
1641
  dom.push({
1575
1642
  type: VirtualDomElements.Div,
1576
- className: Message$1,
1643
+ className: Message,
1577
1644
  childCount: 1
1578
1645
  });
1579
1646
  if (filterValue) {
@@ -1838,6 +1905,18 @@ const render2 = (uid, diffResult) => {
1838
1905
  return commands;
1839
1906
  };
1840
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
+
1841
1920
  const resize = (state, dimensions) => {
1842
1921
  return {
1843
1922
  ...state,
@@ -1858,8 +1937,23 @@ const saveState = state => {
1858
1937
  };
1859
1938
  };
1860
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
+
1861
1954
  const commandMap = {
1862
1955
  'Problems.copyMessage': copyMessage,
1956
+ 'Problems.renderEventListeners': renderEventListeners,
1863
1957
  'Problems.create': create,
1864
1958
  'Problems.diff2': diff2,
1865
1959
  'Problems.focusIndex': focusIndex,
@@ -1867,10 +1961,16 @@ const commandMap = {
1867
1961
  'Problems.handleArrowLeft': wrapCommand(handleArrowLeft),
1868
1962
  'Problems.handleArrowRight': wrapCommand(handleArrowRight),
1869
1963
  'Problems.initialize': initialize,
1964
+ 'Problems.loadContent': wrapCommand(loadContent),
1870
1965
  'Problems.render2': render2,
1966
+ 'Problems.renderActions': renderActions,
1871
1967
  'Problems.resize': resize,
1872
1968
  'Problems.saveState': saveState,
1873
- 'Problems.terminate': terminate
1969
+ 'Problems.terminate': terminate,
1970
+ 'Problems.handleIconThemeChange': handleIconThemeChange,
1971
+ 'Problems.handleContextMenu': handleContextMenu,
1972
+ 'Problems.viewAsTable': viewAsTable,
1973
+ 'Problems.viewAsList': viewAsList
1874
1974
  };
1875
1975
 
1876
1976
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",