@lvce-editor/problems-view 1.26.5 → 1.26.6

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.
@@ -1674,6 +1674,9 @@ const sendMessagePortToEditorWorker$1 = async (port, rpcId) => {
1674
1674
  const command = 'HandleMessagePort.handleMessagePort';
1675
1675
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1676
1676
  };
1677
+ const getFileIcon = async options => {
1678
+ return invoke('IconTheme.getFileIcon', options);
1679
+ };
1677
1680
  const writeClipBoardText$1 = async text => {
1678
1681
  await invoke('ClipBoard.writeText', /* text */text);
1679
1682
  };
@@ -1729,6 +1732,7 @@ const create = (id, uri, x, y, width, height, workspaceUri) => {
1729
1732
  activeUri: '',
1730
1733
  collapsedUris: [],
1731
1734
  deltaY: 0,
1735
+ fileIconCache: {},
1732
1736
  filteredProblems: [],
1733
1737
  filterValue: '',
1734
1738
  finalDeltaY: 0,
@@ -1779,7 +1783,7 @@ const haveSameCollapsedUris = (oldState, newState) => {
1779
1783
  return oldCollapsedUris.length === newCollapsedUris.length && oldCollapsedUris.every((uri, index) => uri === newCollapsedUris[index]);
1780
1784
  };
1781
1785
  const isEqual = (oldState, newState) => {
1782
- return oldState.activeUri === newState.activeUri && haveSameCollapsedUris(oldState, newState) && oldState.focusedIndex === newState.focusedIndex && oldState.height === newState.height && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.problems === newState.problems && oldState.filterValue === newState.filterValue && oldState.message === newState.message && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.width === newState.width && oldState.viewMode === newState.viewMode;
1786
+ return oldState.activeUri === newState.activeUri && haveSameCollapsedUris(oldState, newState) && oldState.fileIconCache === newState.fileIconCache && oldState.focusedIndex === newState.focusedIndex && oldState.height === newState.height && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.problems === newState.problems && oldState.filterValue === newState.filterValue && oldState.message === newState.message && oldState.scrollBarActive === newState.scrollBarActive && oldState.scrollBarHeight === newState.scrollBarHeight && oldState.width === newState.width && oldState.viewMode === newState.viewMode;
1783
1787
  };
1784
1788
 
1785
1789
  const RenderItems = 1;
@@ -2129,6 +2133,48 @@ const getMenuIds = () => {
2129
2133
  return [ProblemsFilter$1];
2130
2134
  };
2131
2135
 
2136
+ const getMissingRequests = (problems, fileIconCache) => {
2137
+ const missingRequests = [];
2138
+ const pendingUris = new Set();
2139
+ for (const problem of problems) {
2140
+ const {
2141
+ fileName,
2142
+ uri
2143
+ } = problem;
2144
+ if (!uri || uri in fileIconCache || pendingUris.has(uri)) {
2145
+ continue;
2146
+ }
2147
+ pendingUris.add(uri);
2148
+ missingRequests.push({
2149
+ name: fileName,
2150
+ uri
2151
+ });
2152
+ }
2153
+ return missingRequests;
2154
+ };
2155
+ const requestFileIcon = name => {
2156
+ if (!name) {
2157
+ return Promise.resolve('');
2158
+ }
2159
+ return getFileIcon({
2160
+ name
2161
+ });
2162
+ };
2163
+ const getFileIcons = async (problems, fileIconCache) => {
2164
+ const missingRequests = getMissingRequests(problems, fileIconCache);
2165
+ if (missingRequests.length === 0) {
2166
+ return fileIconCache;
2167
+ }
2168
+ const icons = await Promise.all(missingRequests.map(request => requestFileIcon(request.name)));
2169
+ const newFileIconCache = {
2170
+ ...fileIconCache
2171
+ };
2172
+ for (let i = 0; i < missingRequests.length; i++) {
2173
+ newFileIconCache[missingRequests[i].uri] = icons[i];
2174
+ }
2175
+ return newFileIconCache;
2176
+ };
2177
+
2132
2178
  const {
2133
2179
  getProblems: getProblems$1,
2134
2180
  getUri} = EditorWorker;
@@ -2276,15 +2322,18 @@ const getProblems = async (workspaceUri, activeUri) => {
2276
2322
 
2277
2323
  const refreshProblems = async (state, activeUri) => {
2278
2324
  const {
2325
+ fileIconCache,
2279
2326
  workspaceUri
2280
2327
  } = state;
2281
2328
  const {
2282
2329
  error,
2283
2330
  problems
2284
2331
  } = await getProblems(workspaceUri, activeUri);
2332
+ const newFileIconCache = await getFileIcons(problems, fileIconCache);
2285
2333
  return {
2286
2334
  ...state,
2287
2335
  activeUri,
2336
+ fileIconCache: newFileIconCache,
2288
2337
  filteredProblems: problems,
2289
2338
  inputSource: Script,
2290
2339
  listItems: [],
@@ -2473,13 +2522,14 @@ const handleFilterInput = (state, value, inputSource = Script) => {
2473
2522
  };
2474
2523
  };
2475
2524
 
2476
- const handleIconThemeChange = state => {
2525
+ const handleIconThemeChange = async state => {
2477
2526
  const {
2478
2527
  problems
2479
2528
  } = state;
2529
+ const fileIconCache = await getFileIcons(problems, {});
2480
2530
  return {
2481
2531
  ...state,
2482
- problems: [...problems]
2532
+ fileIconCache
2483
2533
  };
2484
2534
  };
2485
2535
 
@@ -2626,6 +2676,7 @@ const getSavedViewMode = savedState => {
2626
2676
 
2627
2677
  const loadContent = async (state, savedState) => {
2628
2678
  const {
2679
+ fileIconCache: oldFileIconCache,
2629
2680
  workspaceUri
2630
2681
  } = state;
2631
2682
  const activeUri = await getActiveUri();
@@ -2643,6 +2694,7 @@ const loadContent = async (state, savedState) => {
2643
2694
  };
2644
2695
  }
2645
2696
  const message = getMessage(problems.length);
2697
+ const fileIconCache = await getFileIcons(problems, oldFileIconCache);
2646
2698
  const viewMode = getSavedViewMode(savedState);
2647
2699
  const filterValue = getSavedFilterValue(savedState);
2648
2700
  const collapsedUris = getSavedCollapsedUris(savedState);
@@ -2650,6 +2702,7 @@ const loadContent = async (state, savedState) => {
2650
2702
  ...state,
2651
2703
  activeUri,
2652
2704
  collapsedUris,
2705
+ fileIconCache,
2653
2706
  filteredProblems: problems,
2654
2707
  filterValue,
2655
2708
  inputSource: Script,
@@ -2688,18 +2741,14 @@ const getUniqueIndents = problems => {
2688
2741
  return uniqueIndents;
2689
2742
  };
2690
2743
 
2691
- const getFileNameIcon = file => {
2692
- return '';
2693
- };
2694
-
2695
- const getIcon = uri => {
2744
+ const getIcon = (uri, fileIconCache) => {
2696
2745
  if (!uri) {
2697
2746
  return '';
2698
2747
  }
2699
- return getFileNameIcon();
2748
+ return fileIconCache[uri] || '';
2700
2749
  };
2701
2750
 
2702
- const getVisibleProblems = (problems, collapsedUris, focusedIndex, filterValue, minLineY = 0, maxLineY = Infinity, viewMode = List) => {
2751
+ const getVisibleProblems = (problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY = 0, maxLineY = Infinity, viewMode = List) => {
2703
2752
  array(problems);
2704
2753
  array(collapsedUris);
2705
2754
  number(focusedIndex);
@@ -2714,7 +2763,7 @@ const getVisibleProblems = (problems, collapsedUris, focusedIndex, filterValue,
2714
2763
  visibleItems.push({
2715
2764
  ...problem,
2716
2765
  filterValueLength,
2717
- icon: getIcon(problem.uri),
2766
+ icon: getIcon(problem.uri, fileIconCache),
2718
2767
  isActive: i === focusedIndex,
2719
2768
  isEven: i % 2 === 0
2720
2769
  });
@@ -2726,6 +2775,7 @@ const renderCss = (oldState, newState) => {
2726
2775
  const {
2727
2776
  collapsedUris,
2728
2777
  deltaY,
2778
+ fileIconCache,
2729
2779
  filterValue,
2730
2780
  finalDeltaY,
2731
2781
  focusedIndex,
@@ -2740,7 +2790,7 @@ const renderCss = (oldState, newState) => {
2740
2790
  viewMode,
2741
2791
  width
2742
2792
  } = newState;
2743
- const visibleProblems = getVisibleProblems(problems, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
2793
+ const visibleProblems = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
2744
2794
  const uniqueIndents = getUniqueIndents(visibleProblems);
2745
2795
  const listHeight = getListHeight(height, width, smallWidthBreakPoint, viewMode);
2746
2796
  const scrollBarTop = getScrollBarTop(listHeight, finalDeltaY, deltaY, scrollBarHeight);
@@ -3298,6 +3348,7 @@ const renderItems = (oldState, newState) => {
3298
3348
  const {
3299
3349
  activeUri,
3300
3350
  collapsedUris,
3351
+ fileIconCache,
3301
3352
  filterValue,
3302
3353
  focusedIndex,
3303
3354
  inputSource,
@@ -3312,7 +3363,7 @@ const renderItems = (oldState, newState) => {
3312
3363
  width
3313
3364
  } = newState;
3314
3365
  const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode);
3315
- const visible = getVisibleProblems(problems, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
3366
+ const visible = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
3316
3367
  const isSmall = width <= smallWidthBreakPoint;
3317
3368
  const dom = getProblemsVirtualDom(activeUri, viewMode, visible, filterValue, inputSource, isSmall, message, scrollBarHeight, scrollBarActive, problemCount);
3318
3369
  return ['Viewlet.setDom2', dom];
@@ -3373,6 +3424,7 @@ const getActionsVirtualDom = actions => {
3373
3424
  const getActions = state => {
3374
3425
  const {
3375
3426
  collapsedUris,
3427
+ fileIconCache,
3376
3428
  filterValue,
3377
3429
  focusedIndex,
3378
3430
  inputSource,
@@ -3381,7 +3433,7 @@ const getActions = state => {
3381
3433
  viewMode,
3382
3434
  width
3383
3435
  } = state;
3384
- const visibleCount = getVisibleProblems(problems, collapsedUris, focusedIndex, filterValue, 0, Infinity, viewMode).length;
3436
+ const visibleCount = getVisibleProblems(problems, fileIconCache, collapsedUris, focusedIndex, filterValue, 0, Infinity, viewMode).length;
3385
3437
  const problemsCount = problems.length;
3386
3438
  const isSmall = width <= smallWidthBreakPoint;
3387
3439
  const actions = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.26.5",
3
+ "version": "1.26.6",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",