@lvce-editor/problems-view 1.25.2 → 1.25.3
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.
- package/dist/problemsViewWorkerMain.js +144 -85
- package/package.json +1 -1
|
@@ -1280,6 +1280,8 @@ const Unchecked = 3;
|
|
|
1280
1280
|
const EditorWorker$1 = 99;
|
|
1281
1281
|
const RendererWorker$1 = 1;
|
|
1282
1282
|
|
|
1283
|
+
const SetCss = 'Viewlet.setCss';
|
|
1284
|
+
|
|
1283
1285
|
const {
|
|
1284
1286
|
invoke: invoke$1,
|
|
1285
1287
|
set: set$3
|
|
@@ -1401,6 +1403,10 @@ const create = (id, uri, x, y, width, height, workspaceUri) => {
|
|
|
1401
1403
|
set(id, state, state);
|
|
1402
1404
|
};
|
|
1403
1405
|
|
|
1406
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1407
|
+
return oldState.collapsedUris === newState.collapsedUris && oldState.filterValue === newState.filterValue && oldState.problems === newState.problems;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1404
1410
|
const isEqual$1 = (oldState, newState) => {
|
|
1405
1411
|
return newState.inputSource === User || oldState.filterValue === newState.filterValue;
|
|
1406
1412
|
};
|
|
@@ -1411,9 +1417,10 @@ const isEqual = (oldState, newState) => {
|
|
|
1411
1417
|
|
|
1412
1418
|
const RenderItems = 1;
|
|
1413
1419
|
const RenderFilterValue = 2;
|
|
1420
|
+
const RenderCss = 4;
|
|
1414
1421
|
|
|
1415
|
-
const modules = [isEqual, isEqual$1];
|
|
1416
|
-
const numbers = [RenderItems, RenderFilterValue];
|
|
1422
|
+
const modules = [isEqual, isEqual$1, isEqual$2];
|
|
1423
|
+
const numbers = [RenderItems, RenderFilterValue, RenderCss];
|
|
1417
1424
|
|
|
1418
1425
|
const diff = (oldState, newState) => {
|
|
1419
1426
|
const diffResult = [];
|
|
@@ -1670,9 +1677,22 @@ const toProblem = (diagnostic, index) => {
|
|
|
1670
1677
|
uri
|
|
1671
1678
|
};
|
|
1672
1679
|
};
|
|
1680
|
+
const normalizeFileUri = uri => {
|
|
1681
|
+
const normalizedUri = uri.startsWith('file://') ? uri.slice('file://'.length) : uri;
|
|
1682
|
+
return /^\/[a-z]:\//i.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
|
|
1683
|
+
};
|
|
1673
1684
|
const getRelativeParentUri = (uri, workspaceUri) => {
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1685
|
+
const normalizedUri = normalizeFileUri(uri);
|
|
1686
|
+
const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(/\/$/, '');
|
|
1687
|
+
const slashIndex = normalizedUri.lastIndexOf('/');
|
|
1688
|
+
const parentUri = normalizedUri.slice(0, slashIndex);
|
|
1689
|
+
if (parentUri === normalizedWorkspaceUri) {
|
|
1690
|
+
return '';
|
|
1691
|
+
}
|
|
1692
|
+
if (normalizedWorkspaceUri && parentUri.startsWith(`${normalizedWorkspaceUri}/`)) {
|
|
1693
|
+
return parentUri.slice(normalizedWorkspaceUri.length + 1);
|
|
1694
|
+
}
|
|
1695
|
+
return parentUri.replace(/^\/+/, '');
|
|
1676
1696
|
};
|
|
1677
1697
|
const getFileName = uri => {
|
|
1678
1698
|
const slashIndex = uri.lastIndexOf('/');
|
|
@@ -1997,6 +2017,122 @@ const loadContent = async (state, savedState) => {
|
|
|
1997
2017
|
};
|
|
1998
2018
|
};
|
|
1999
2019
|
|
|
2020
|
+
const getIndentRule = indent => {
|
|
2021
|
+
return `.Indent-${indent} {
|
|
2022
|
+
padding-left: ${indent};
|
|
2023
|
+
}`;
|
|
2024
|
+
};
|
|
2025
|
+
|
|
2026
|
+
const defaultIndent = 1;
|
|
2027
|
+
const getTreeItemIndent = depth => {
|
|
2028
|
+
return `${depth * defaultIndent}rem`;
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2031
|
+
const getProblemIndent = listItemType => {
|
|
2032
|
+
const isGroup = listItemType === Expanded || listItemType === Collapsed;
|
|
2033
|
+
const depth = isGroup ? 1 : 2;
|
|
2034
|
+
return getTreeItemIndent(depth);
|
|
2035
|
+
};
|
|
2036
|
+
|
|
2037
|
+
const getUniqueIndents = problems => {
|
|
2038
|
+
const uniqueIndents = [];
|
|
2039
|
+
for (const problem of problems) {
|
|
2040
|
+
const indent = getProblemIndent(problem.listItemType);
|
|
2041
|
+
if (!uniqueIndents.includes(indent)) {
|
|
2042
|
+
uniqueIndents.push(indent);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
return uniqueIndents;
|
|
2046
|
+
};
|
|
2047
|
+
|
|
2048
|
+
const matchesFilterValue = (string, filterValueLower) => {
|
|
2049
|
+
if (filterValueLower) {
|
|
2050
|
+
return string.toLowerCase().indexOf(filterValueLower);
|
|
2051
|
+
}
|
|
2052
|
+
return 0;
|
|
2053
|
+
};
|
|
2054
|
+
|
|
2055
|
+
const getListItemType = (listItemType, isCollapsed) => {
|
|
2056
|
+
if (listItemType === Item) {
|
|
2057
|
+
return Item;
|
|
2058
|
+
}
|
|
2059
|
+
if (isCollapsed) {
|
|
2060
|
+
return Collapsed;
|
|
2061
|
+
}
|
|
2062
|
+
return Expanded;
|
|
2063
|
+
};
|
|
2064
|
+
const filterProblems = (problems, collapsedUris, filterValue) => {
|
|
2065
|
+
const filterValueLower = filterValue.toLowerCase();
|
|
2066
|
+
const filtered = [];
|
|
2067
|
+
for (const problem of problems) {
|
|
2068
|
+
const uriMatchIndex = matchesFilterValue(problem.uri, filterValueLower);
|
|
2069
|
+
const sourceMatchIndex = matchesFilterValue(problem.source, filterValueLower);
|
|
2070
|
+
const messageMatchIndex = matchesFilterValue(problem.message, filterValueLower);
|
|
2071
|
+
if (uriMatchIndex === -1 && sourceMatchIndex === -1 && messageMatchIndex === -1) {
|
|
2072
|
+
continue;
|
|
2073
|
+
}
|
|
2074
|
+
const isCollapsed = collapsedUris.includes(problem.uri);
|
|
2075
|
+
if (isCollapsed && problem.listItemType === Item) {
|
|
2076
|
+
continue;
|
|
2077
|
+
}
|
|
2078
|
+
filtered.push({
|
|
2079
|
+
...problem,
|
|
2080
|
+
isCollapsed,
|
|
2081
|
+
listItemType: getListItemType(problem.listItemType, isCollapsed),
|
|
2082
|
+
messageMatchIndex,
|
|
2083
|
+
sourceMatchIndex,
|
|
2084
|
+
uriMatchIndex
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
return filtered;
|
|
2088
|
+
};
|
|
2089
|
+
|
|
2090
|
+
const getFileNameIcon = file => {
|
|
2091
|
+
return '';
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
const getIcon = uri => {
|
|
2095
|
+
if (!uri) {
|
|
2096
|
+
return '';
|
|
2097
|
+
}
|
|
2098
|
+
return getFileNameIcon();
|
|
2099
|
+
};
|
|
2100
|
+
|
|
2101
|
+
const getVisibleProblems = (problems, collapsedUris, focusedIndex, filterValue) => {
|
|
2102
|
+
array(problems);
|
|
2103
|
+
array(collapsedUris);
|
|
2104
|
+
number(focusedIndex);
|
|
2105
|
+
string(filterValue);
|
|
2106
|
+
const visibleItems = [];
|
|
2107
|
+
const filterValueLength = filterValue.length;
|
|
2108
|
+
const filtered = filterProblems(problems, collapsedUris, filterValue);
|
|
2109
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
2110
|
+
const problem = filtered[i];
|
|
2111
|
+
visibleItems.push({
|
|
2112
|
+
...problem,
|
|
2113
|
+
filterValueLength,
|
|
2114
|
+
icon: getIcon(problem.uri),
|
|
2115
|
+
isActive: i === focusedIndex,
|
|
2116
|
+
isEven: i % 2 === 0
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
return visibleItems;
|
|
2120
|
+
};
|
|
2121
|
+
|
|
2122
|
+
const renderCss = (oldState, newState) => {
|
|
2123
|
+
const {
|
|
2124
|
+
collapsedUris,
|
|
2125
|
+
filterValue,
|
|
2126
|
+
focusedIndex,
|
|
2127
|
+
problems,
|
|
2128
|
+
uid
|
|
2129
|
+
} = newState;
|
|
2130
|
+
const visibleProblems = getVisibleProblems(problems, collapsedUris, focusedIndex, filterValue);
|
|
2131
|
+
const uniqueIndents = getUniqueIndents(visibleProblems);
|
|
2132
|
+
const css = uniqueIndents.map(getIndentRule).join('\n');
|
|
2133
|
+
return [SetCss, uid, css];
|
|
2134
|
+
};
|
|
2135
|
+
|
|
2000
2136
|
const Filter$2 = 'filter';
|
|
2001
2137
|
|
|
2002
2138
|
const renderFilterValue = (oldState, newState) => {
|
|
@@ -2198,11 +2334,6 @@ const getProblemSourceDetail = (source, code) => {
|
|
|
2198
2334
|
return message;
|
|
2199
2335
|
};
|
|
2200
2336
|
|
|
2201
|
-
const defaultIndent = 1;
|
|
2202
|
-
const getTreeItemIndent = depth => {
|
|
2203
|
-
return `${depth * defaultIndent}rem`;
|
|
2204
|
-
};
|
|
2205
|
-
|
|
2206
2337
|
const labelNode = {
|
|
2207
2338
|
childCount: 1,
|
|
2208
2339
|
className: Label,
|
|
@@ -2244,6 +2375,8 @@ const getProblemVirtualDom = problem => {
|
|
|
2244
2375
|
type
|
|
2245
2376
|
} = problem;
|
|
2246
2377
|
let className = Problem;
|
|
2378
|
+
const indent = getProblemIndent(listItemType);
|
|
2379
|
+
className = mergeClassNames(className, `Indent-${indent}`);
|
|
2247
2380
|
if (isActive) {
|
|
2248
2381
|
className = mergeClassNames(className, ProblemSelected);
|
|
2249
2382
|
}
|
|
@@ -2256,7 +2389,6 @@ const getProblemVirtualDom = problem => {
|
|
|
2256
2389
|
ariaSetSize: setSize,
|
|
2257
2390
|
childCount: 5,
|
|
2258
2391
|
className,
|
|
2259
|
-
paddingLeft: getTreeItemIndent(1),
|
|
2260
2392
|
role: TreeItem,
|
|
2261
2393
|
type: Div
|
|
2262
2394
|
}, listItemType === Collapsed ? getChevronRightVirtualDom() : getChevronDownVirtualDom(), getFileIconVirtualDom(icon), labelNode, text(fileName), labelDetailNode, text(relativePath), ...getBadgeVirtualDom(ProblemBadge, problem.count)];
|
|
@@ -2277,7 +2409,6 @@ const getProblemVirtualDom = problem => {
|
|
|
2277
2409
|
ariaSetSize: setSize,
|
|
2278
2410
|
childCount: 3,
|
|
2279
2411
|
className,
|
|
2280
|
-
paddingLeft: getTreeItemIndent(2),
|
|
2281
2412
|
role: TreeItem,
|
|
2282
2413
|
type: Div
|
|
2283
2414
|
}, getProblemsIconVirtualDom(type), label];
|
|
@@ -2438,80 +2569,6 @@ const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, isSma
|
|
|
2438
2569
|
return [baseDom, ...filterDom, ...itemsDom];
|
|
2439
2570
|
};
|
|
2440
2571
|
|
|
2441
|
-
const matchesFilterValue = (string, filterValueLower) => {
|
|
2442
|
-
if (filterValueLower) {
|
|
2443
|
-
return string.toLowerCase().indexOf(filterValueLower);
|
|
2444
|
-
}
|
|
2445
|
-
return 0;
|
|
2446
|
-
};
|
|
2447
|
-
|
|
2448
|
-
const getListItemType = (listItemType, isCollapsed) => {
|
|
2449
|
-
if (listItemType === Item) {
|
|
2450
|
-
return Item;
|
|
2451
|
-
}
|
|
2452
|
-
if (isCollapsed) {
|
|
2453
|
-
return Collapsed;
|
|
2454
|
-
}
|
|
2455
|
-
return Expanded;
|
|
2456
|
-
};
|
|
2457
|
-
const filterProblems = (problems, collapsedUris, filterValue) => {
|
|
2458
|
-
const filterValueLower = filterValue.toLowerCase();
|
|
2459
|
-
const filtered = [];
|
|
2460
|
-
for (const problem of problems) {
|
|
2461
|
-
const uriMatchIndex = matchesFilterValue(problem.uri, filterValueLower);
|
|
2462
|
-
const sourceMatchIndex = matchesFilterValue(problem.source, filterValueLower);
|
|
2463
|
-
const messageMatchIndex = matchesFilterValue(problem.message, filterValueLower);
|
|
2464
|
-
if (uriMatchIndex === -1 && sourceMatchIndex === -1 && messageMatchIndex === -1) {
|
|
2465
|
-
continue;
|
|
2466
|
-
}
|
|
2467
|
-
const isCollapsed = collapsedUris.includes(problem.uri);
|
|
2468
|
-
if (isCollapsed && problem.listItemType === Item) {
|
|
2469
|
-
continue;
|
|
2470
|
-
}
|
|
2471
|
-
filtered.push({
|
|
2472
|
-
...problem,
|
|
2473
|
-
isCollapsed,
|
|
2474
|
-
listItemType: getListItemType(problem.listItemType, isCollapsed),
|
|
2475
|
-
messageMatchIndex,
|
|
2476
|
-
sourceMatchIndex,
|
|
2477
|
-
uriMatchIndex
|
|
2478
|
-
});
|
|
2479
|
-
}
|
|
2480
|
-
return filtered;
|
|
2481
|
-
};
|
|
2482
|
-
|
|
2483
|
-
const getFileNameIcon = file => {
|
|
2484
|
-
return '';
|
|
2485
|
-
};
|
|
2486
|
-
|
|
2487
|
-
const getIcon = uri => {
|
|
2488
|
-
if (!uri) {
|
|
2489
|
-
return '';
|
|
2490
|
-
}
|
|
2491
|
-
return getFileNameIcon();
|
|
2492
|
-
};
|
|
2493
|
-
|
|
2494
|
-
const getVisibleProblems = (problems, collapsedUris, focusedIndex, filterValue) => {
|
|
2495
|
-
array(problems);
|
|
2496
|
-
array(collapsedUris);
|
|
2497
|
-
number(focusedIndex);
|
|
2498
|
-
string(filterValue);
|
|
2499
|
-
const visibleItems = [];
|
|
2500
|
-
const filterValueLength = filterValue.length;
|
|
2501
|
-
const filtered = filterProblems(problems, collapsedUris, filterValue);
|
|
2502
|
-
for (let i = 0; i < filtered.length; i++) {
|
|
2503
|
-
const problem = filtered[i];
|
|
2504
|
-
visibleItems.push({
|
|
2505
|
-
...problem,
|
|
2506
|
-
filterValueLength,
|
|
2507
|
-
icon: getIcon(problem.uri),
|
|
2508
|
-
isActive: i === focusedIndex,
|
|
2509
|
-
isEven: i % 2 === 0
|
|
2510
|
-
});
|
|
2511
|
-
}
|
|
2512
|
-
return visibleItems;
|
|
2513
|
-
};
|
|
2514
|
-
|
|
2515
2572
|
const renderItems = (oldState, newState) => {
|
|
2516
2573
|
const {
|
|
2517
2574
|
activeUri,
|
|
@@ -2532,6 +2589,8 @@ const renderItems = (oldState, newState) => {
|
|
|
2532
2589
|
|
|
2533
2590
|
const getRenderer = diffType => {
|
|
2534
2591
|
switch (diffType) {
|
|
2592
|
+
case RenderCss:
|
|
2593
|
+
return renderCss;
|
|
2535
2594
|
case RenderFilterValue:
|
|
2536
2595
|
return renderFilterValue;
|
|
2537
2596
|
case RenderItems:
|