@lvce-editor/problems-view 1.25.1 → 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.
@@ -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 slashIndex = uri.lastIndexOf('/');
1675
- return uri.slice(0, slashIndex).slice(workspaceUri.length);
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) => {
@@ -2066,15 +2202,16 @@ const getActionButtonVirtualDom = action => {
2066
2202
  }, getIconVirtualDom(icon)];
2067
2203
  };
2068
2204
 
2205
+ const filterBadgeNode = {
2206
+ childCount: 1,
2207
+ className: FilterBadge,
2208
+ type: Div
2209
+ };
2069
2210
  const getFilterBadgeDom = badgeText => {
2070
2211
  if (!badgeText) {
2071
2212
  return [];
2072
2213
  }
2073
- return [{
2074
- childCount: 1,
2075
- className: FilterBadge,
2076
- type: Div
2077
- }, text(badgeText)];
2214
+ return [filterBadgeNode, text(badgeText)];
2078
2215
  };
2079
2216
 
2080
2217
  const getInputBoxVirtualDom = (name, onInput, placeholder) => {
@@ -2115,20 +2252,23 @@ const getProblemsFilterVirtualDom = action => {
2115
2252
  id: 'more filters'})];
2116
2253
  };
2117
2254
 
2255
+ const messageNode$2 = {
2256
+ childCount: 3,
2257
+ className: Message,
2258
+ type: Div
2259
+ };
2260
+ const spanNode = {
2261
+ childCount: 1,
2262
+ type: Span
2263
+ };
2264
+ const clearFilterNode = {
2265
+ childCount: 1,
2266
+ className: MessageAction,
2267
+ onClick: HandleClearFilterClick,
2268
+ type: A
2269
+ };
2118
2270
  const getNoResultsWithFilterVirtualDom = () => {
2119
- return [{
2120
- childCount: 3,
2121
- className: Message,
2122
- type: Div
2123
- }, {
2124
- childCount: 1,
2125
- type: Span
2126
- }, text(noResultsFoundWithProvidedFilterCriteria()), {
2127
- childCount: 1,
2128
- className: MessageAction,
2129
- onClick: HandleClearFilterClick,
2130
- type: A
2131
- }, text(clearFilter()), text('.')];
2271
+ return [messageNode$2, spanNode, text(noResultsFoundWithProvidedFilterCriteria()), clearFilterNode, text(clearFilter()), text('.')];
2132
2272
  };
2133
2273
 
2134
2274
  const getBadgeVirtualDom = (className, count) => {
@@ -2194,11 +2334,26 @@ const getProblemSourceDetail = (source, code) => {
2194
2334
  return message;
2195
2335
  };
2196
2336
 
2197
- const defaultIndent = 1;
2198
- const getTreeItemIndent = depth => {
2199
- return `${depth * defaultIndent}rem`;
2337
+ const labelNode = {
2338
+ childCount: 1,
2339
+ className: Label,
2340
+ type: Span
2341
+ };
2342
+ const labelDetailNode = {
2343
+ childCount: 1,
2344
+ className: LabelDetail,
2345
+ type: Div
2346
+ };
2347
+ const highlightNode = {
2348
+ childCount: 1,
2349
+ className: Highlight,
2350
+ type: Div
2351
+ };
2352
+ const problemAtNode = {
2353
+ childCount: 2,
2354
+ className: ProblemAt,
2355
+ type: Span
2200
2356
  };
2201
-
2202
2357
  const getProblemVirtualDom = problem => {
2203
2358
  const {
2204
2359
  code,
@@ -2220,8 +2375,10 @@ const getProblemVirtualDom = problem => {
2220
2375
  type
2221
2376
  } = problem;
2222
2377
  let className = Problem;
2378
+ const indent = getProblemIndent(listItemType);
2379
+ className = mergeClassNames(className, `Indent-${indent}`);
2223
2380
  if (isActive) {
2224
- className += ' ' + ProblemSelected;
2381
+ className = mergeClassNames(className, ProblemSelected);
2225
2382
  }
2226
2383
  if (listItemType === Expanded || listItemType === Collapsed) {
2227
2384
  return [{
@@ -2232,18 +2389,9 @@ const getProblemVirtualDom = problem => {
2232
2389
  ariaSetSize: setSize,
2233
2390
  childCount: 5,
2234
2391
  className,
2235
- paddingLeft: getTreeItemIndent(1),
2236
2392
  role: TreeItem,
2237
2393
  type: Div
2238
- }, listItemType === Collapsed ? getChevronRightVirtualDom() : getChevronDownVirtualDom(), getFileIconVirtualDom(icon), {
2239
- childCount: 1,
2240
- className: Label,
2241
- type: Span
2242
- }, text(fileName), {
2243
- childCount: 1,
2244
- className: LabelDetail,
2245
- type: Div
2246
- }, text(relativePath), ...getBadgeVirtualDom(ProblemBadge, problem.count)];
2394
+ }, listItemType === Collapsed ? getChevronRightVirtualDom() : getChevronDownVirtualDom(), getFileIconVirtualDom(icon), labelNode, text(fileName), labelDetailNode, text(relativePath), ...getBadgeVirtualDom(ProblemBadge, problem.count)];
2247
2395
  }
2248
2396
  const lineColumn = atLineColumn(rowIndex, columnIndex);
2249
2397
  const label = {
@@ -2261,7 +2409,6 @@ const getProblemVirtualDom = problem => {
2261
2409
  ariaSetSize: setSize,
2262
2410
  childCount: 3,
2263
2411
  className,
2264
- paddingLeft: getTreeItemIndent(2),
2265
2412
  role: TreeItem,
2266
2413
  type: Div
2267
2414
  }, getProblemsIconVirtualDom(type), label];
@@ -2270,19 +2417,11 @@ const getProblemVirtualDom = problem => {
2270
2417
  const middle = message.slice(messageMatchIndex, messageMatchIndex + filterValueLength);
2271
2418
  const after = message.slice(messageMatchIndex + filterValueLength);
2272
2419
  label.childCount += 2;
2273
- dom.push(text(before), {
2274
- childCount: 1,
2275
- className: Highlight,
2276
- type: Div
2277
- }, text(middle), text(after));
2420
+ dom.push(text(before), highlightNode, text(middle), text(after));
2278
2421
  } else {
2279
2422
  dom.push(text(message));
2280
2423
  }
2281
- dom.push({
2282
- childCount: 2,
2283
- className: ProblemAt,
2284
- type: Span
2285
- }, text(getProblemSourceDetail(source, code)), text(lineColumn));
2424
+ dom.push(problemAtNode, text(getProblemSourceDetail(source, code)), text(lineColumn));
2286
2425
  return dom;
2287
2426
  };
2288
2427
 
@@ -2298,14 +2437,20 @@ const getProblemsListVirtualDom = problems => {
2298
2437
  return dom;
2299
2438
  };
2300
2439
 
2440
+ const messageNode$1 = {
2441
+ childCount: 1,
2442
+ className: Message,
2443
+ type: Div
2444
+ };
2301
2445
  const getProblemsNoProblemsFoundVirtualDom = () => {
2302
- return [{
2303
- childCount: 1,
2304
- className: Message,
2305
- type: Div
2306
- }, text(noProblemsDetected())];
2446
+ return [messageNode$1, text(noProblemsDetected())];
2307
2447
  };
2308
2448
 
2449
+ const rowItemNode$1 = {
2450
+ childCount: 1,
2451
+ className: ProblemsTableRowItem,
2452
+ type: Div
2453
+ };
2309
2454
  const getClassName = isEven => {
2310
2455
  if (isEven) {
2311
2456
  return ProblemsTableRow;
@@ -2330,27 +2475,7 @@ const getProblemsTableRowVirtualDom = problem => {
2330
2475
  childCount: 5,
2331
2476
  className: getClassName(isEven),
2332
2477
  type: Div
2333
- }, {
2334
- childCount: 1,
2335
- className: ProblemsTableRowItem,
2336
- type: Div
2337
- }, getProblemsIconVirtualDom(type), {
2338
- childCount: 1,
2339
- className: ProblemsTableRowItem,
2340
- type: Div
2341
- }, text(getProblemSourceDetail(source, code)), {
2342
- childCount: 1,
2343
- className: ProblemsTableRowItem,
2344
- type: Div
2345
- }, text(message), {
2346
- childCount: 1,
2347
- className: ProblemsTableRowItem,
2348
- type: Div
2349
- }, text(uri), {
2350
- childCount: 1,
2351
- className: ProblemsTableRowItem,
2352
- type: Div
2353
- }, text(source)];
2478
+ }, rowItemNode$1, getProblemsIconVirtualDom(type), rowItemNode$1, text(getProblemSourceDetail(source, code)), rowItemNode$1, text(message), rowItemNode$1, text(uri), rowItemNode$1, text(source)];
2354
2479
  return dom;
2355
2480
  };
2356
2481
 
@@ -2363,59 +2488,53 @@ const getProblemsTableBodyVirtualDom = problems => {
2363
2488
  return dom;
2364
2489
  };
2365
2490
 
2491
+ const tableHeaderNode = {
2492
+ childCount: 1,
2493
+ className: ProblemsTableHeader,
2494
+ type: Div
2495
+ };
2496
+ const tableRowNode = {
2497
+ childCount: 5,
2498
+ className: ProblemsTableRow,
2499
+ type: Div
2500
+ };
2501
+ const emptyRowItemNode = {
2502
+ childCount: 0,
2503
+ className: ProblemsTableRowItem,
2504
+ type: Div
2505
+ };
2506
+ const rowItemNode = {
2507
+ childCount: 1,
2508
+ className: ProblemsTableRowItem,
2509
+ type: Div
2510
+ };
2366
2511
  const getProblemsTableHeaderVirtualDom = () => {
2367
2512
  const textCode = code();
2368
2513
  const textSource = source();
2369
2514
  const textMessage = message();
2370
2515
  const textFile = file();
2371
- const dom = [{
2372
- childCount: 1,
2373
- className: ProblemsTableHeader,
2374
- type: Div
2375
- }, {
2376
- childCount: 5,
2377
- className: ProblemsTableRow,
2378
- type: Div
2379
- }, {
2380
- childCount: 0,
2381
- className: ProblemsTableRowItem,
2382
- type: Div
2383
- }, {
2384
- childCount: 1,
2385
- className: ProblemsTableRowItem,
2386
- type: Div
2387
- }, text(textCode), {
2388
- childCount: 1,
2389
- className: ProblemsTableRowItem,
2390
- type: Div
2391
- }, text(textMessage), {
2392
- childCount: 1,
2393
- className: ProblemsTableRowItem,
2394
- type: Div
2395
- }, text(textFile), {
2396
- childCount: 1,
2397
- className: ProblemsTableRowItem,
2398
- type: Div
2399
- }, text(textSource)];
2516
+ const dom = [tableHeaderNode, tableRowNode, emptyRowItemNode, rowItemNode, text(textCode), rowItemNode, text(textMessage), rowItemNode, text(textFile), rowItemNode, text(textSource)];
2400
2517
  return dom;
2401
2518
  };
2402
2519
 
2520
+ const tableNode = {
2521
+ childCount: 2,
2522
+ className: ProblemsTable,
2523
+ type: Div
2524
+ };
2403
2525
  const getProblemsTableVirtualDom = problems => {
2404
- const dom = [{
2405
- childCount: 2,
2406
- className: ProblemsTable,
2407
- type: Div
2408
- }, ...getProblemsTableHeaderVirtualDom(), ...getProblemsTableBodyVirtualDom(problems)];
2526
+ const dom = [tableNode, ...getProblemsTableHeaderVirtualDom(), ...getProblemsTableBodyVirtualDom(problems)];
2409
2527
  return dom;
2410
2528
  };
2411
2529
 
2530
+ const messageNode = {
2531
+ childCount: 1,
2532
+ className: Message,
2533
+ type: Div
2534
+ };
2412
2535
  const getProblemsVirtualDom$1 = (viewMode, problems, filterValue, message) => {
2413
2536
  if (problems.length === 0 && message) {
2414
- return [{
2415
- childCount: 1,
2416
- className: Message,
2417
- type: Div
2418
- }, text(message)];
2537
+ return [messageNode, text(message)];
2419
2538
  }
2420
2539
  if (problems.length === 0 && filterValue) {
2421
2540
  return getNoResultsWithFilterVirtualDom();
@@ -2435,7 +2554,7 @@ const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, isSma
2435
2554
  const baseDom = {
2436
2555
  childCount: isSmall ? 2 : 1,
2437
2556
  className: mergeClassNames(Viewlet, Problems),
2438
- dataActiveUri: activeUri,
2557
+ 'data-activeUri': activeUri,
2439
2558
  onBlur: HandleBlur,
2440
2559
  onContextMenu: HandleContextMenu,
2441
2560
  onPointerDown: HandlePointerDown,
@@ -2450,80 +2569,6 @@ const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, isSma
2450
2569
  return [baseDom, ...filterDom, ...itemsDom];
2451
2570
  };
2452
2571
 
2453
- const matchesFilterValue = (string, filterValueLower) => {
2454
- if (filterValueLower) {
2455
- return string.toLowerCase().indexOf(filterValueLower);
2456
- }
2457
- return 0;
2458
- };
2459
-
2460
- const getListItemType = (listItemType, isCollapsed) => {
2461
- if (listItemType === Item) {
2462
- return Item;
2463
- }
2464
- if (isCollapsed) {
2465
- return Collapsed;
2466
- }
2467
- return Expanded;
2468
- };
2469
- const filterProblems = (problems, collapsedUris, filterValue) => {
2470
- const filterValueLower = filterValue.toLowerCase();
2471
- const filtered = [];
2472
- for (const problem of problems) {
2473
- const uriMatchIndex = matchesFilterValue(problem.uri, filterValueLower);
2474
- const sourceMatchIndex = matchesFilterValue(problem.source, filterValueLower);
2475
- const messageMatchIndex = matchesFilterValue(problem.message, filterValueLower);
2476
- if (uriMatchIndex === -1 && sourceMatchIndex === -1 && messageMatchIndex === -1) {
2477
- continue;
2478
- }
2479
- const isCollapsed = collapsedUris.includes(problem.uri);
2480
- if (isCollapsed && problem.listItemType === Item) {
2481
- continue;
2482
- }
2483
- filtered.push({
2484
- ...problem,
2485
- isCollapsed,
2486
- listItemType: getListItemType(problem.listItemType, isCollapsed),
2487
- messageMatchIndex,
2488
- sourceMatchIndex,
2489
- uriMatchIndex
2490
- });
2491
- }
2492
- return filtered;
2493
- };
2494
-
2495
- const getFileNameIcon = file => {
2496
- return '';
2497
- };
2498
-
2499
- const getIcon = uri => {
2500
- if (!uri) {
2501
- return '';
2502
- }
2503
- return getFileNameIcon();
2504
- };
2505
-
2506
- const getVisibleProblems = (problems, collapsedUris, focusedIndex, filterValue) => {
2507
- array(problems);
2508
- array(collapsedUris);
2509
- number(focusedIndex);
2510
- string(filterValue);
2511
- const visibleItems = [];
2512
- const filterValueLength = filterValue.length;
2513
- const filtered = filterProblems(problems, collapsedUris, filterValue);
2514
- for (let i = 0; i < filtered.length; i++) {
2515
- const problem = filtered[i];
2516
- visibleItems.push({
2517
- ...problem,
2518
- filterValueLength,
2519
- icon: getIcon(problem.uri),
2520
- isActive: i === focusedIndex,
2521
- isEven: i % 2 === 0
2522
- });
2523
- }
2524
- return visibleItems;
2525
- };
2526
-
2527
2572
  const renderItems = (oldState, newState) => {
2528
2573
  const {
2529
2574
  activeUri,
@@ -2544,6 +2589,8 @@ const renderItems = (oldState, newState) => {
2544
2589
 
2545
2590
  const getRenderer = diffType => {
2546
2591
  switch (diffType) {
2592
+ case RenderCss:
2593
+ return renderCss;
2547
2594
  case RenderFilterValue:
2548
2595
  return renderFilterValue;
2549
2596
  case RenderItems:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.25.1",
3
+ "version": "1.25.3",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",