@lvce-editor/problems-view 1.29.1 → 1.30.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.
@@ -2177,51 +2177,12 @@ const getMenuIds = () => {
2177
2177
  return [ProblemsFilter$1];
2178
2178
  };
2179
2179
 
2180
- const getMissingRequests = (problems, fileIconCache) => {
2181
- const missingRequests = [];
2182
- const pendingUris = new Set();
2183
- for (const problem of problems) {
2184
- const {
2185
- fileName,
2186
- uri
2187
- } = problem;
2188
- if (!uri || uri in fileIconCache || pendingUris.has(uri)) {
2189
- continue;
2190
- }
2191
- pendingUris.add(uri);
2192
- missingRequests.push({
2193
- name: fileName,
2194
- uri
2195
- });
2196
- }
2197
- return missingRequests;
2198
- };
2199
- const requestFileIcon = name => {
2200
- if (!name) {
2201
- return Promise.resolve('');
2202
- }
2203
- return getFileIcon({
2204
- name
2205
- });
2206
- };
2207
- const getFileIcons = async (problems, fileIconCache) => {
2208
- const missingRequests = getMissingRequests(problems, fileIconCache);
2209
- if (missingRequests.length === 0) {
2210
- return fileIconCache;
2211
- }
2212
- const icons = await Promise.all(missingRequests.map(request => requestFileIcon(request.name)));
2213
- const newFileIconCache = {
2214
- ...fileIconCache
2215
- };
2216
- for (let i = 0; i < missingRequests.length; i++) {
2217
- newFileIconCache[missingRequests[i].uri] = icons[i];
2218
- }
2219
- return newFileIconCache;
2220
- };
2221
-
2222
2180
  const {
2223
2181
  getProblems: getProblems$1,
2224
2182
  getUri} = EditorWorker;
2183
+ const getDiagnostics = editorId => {
2184
+ return invoke$1('Editor.getDiagnostics', editorId);
2185
+ };
2225
2186
 
2226
2187
  const leadingSlashesRegex = /^\/+/;
2227
2188
  const trailingSlashRegex = /\/$/;
@@ -2364,6 +2325,72 @@ const getProblems = async (workspaceUri, activeUri) => {
2364
2325
  }
2365
2326
  };
2366
2327
 
2328
+ const countByType = (diagnostics, type) => {
2329
+ return diagnostics.filter(diagnostic => diagnostic.type === type).length;
2330
+ };
2331
+ const getProblemsSummary = async () => {
2332
+ const editorId = await getActiveEditorId();
2333
+ if (editorId === -1) {
2334
+ return {
2335
+ errorCount: 0,
2336
+ hasEditor: false,
2337
+ problemCount: 0,
2338
+ warningCount: 0
2339
+ };
2340
+ }
2341
+ const [allDiagnostics, activeDiagnostics] = await Promise.all([getProblems$1(), getDiagnostics(editorId)]);
2342
+ const uniqueDiagnostics = getUniqueDiagnostics(allDiagnostics);
2343
+ const uniqueActiveDiagnostics = getUniqueDiagnostics(activeDiagnostics);
2344
+ return {
2345
+ errorCount: countByType(uniqueActiveDiagnostics, Error$1),
2346
+ hasEditor: true,
2347
+ problemCount: uniqueDiagnostics.length,
2348
+ warningCount: countByType(uniqueActiveDiagnostics, Warning)
2349
+ };
2350
+ };
2351
+
2352
+ const getMissingRequests = (problems, fileIconCache) => {
2353
+ const missingRequests = [];
2354
+ const pendingUris = new Set();
2355
+ for (const problem of problems) {
2356
+ const {
2357
+ fileName,
2358
+ uri
2359
+ } = problem;
2360
+ if (!uri || uri in fileIconCache || pendingUris.has(uri)) {
2361
+ continue;
2362
+ }
2363
+ pendingUris.add(uri);
2364
+ missingRequests.push({
2365
+ name: fileName,
2366
+ uri
2367
+ });
2368
+ }
2369
+ return missingRequests;
2370
+ };
2371
+ const requestFileIcon = name => {
2372
+ if (!name) {
2373
+ return Promise.resolve('');
2374
+ }
2375
+ return getFileIcon({
2376
+ name
2377
+ });
2378
+ };
2379
+ const getFileIcons = async (problems, fileIconCache) => {
2380
+ const missingRequests = getMissingRequests(problems, fileIconCache);
2381
+ if (missingRequests.length === 0) {
2382
+ return fileIconCache;
2383
+ }
2384
+ const icons = await Promise.all(missingRequests.map(request => requestFileIcon(request.name)));
2385
+ const newFileIconCache = {
2386
+ ...fileIconCache
2387
+ };
2388
+ for (let i = 0; i < missingRequests.length; i++) {
2389
+ newFileIconCache[missingRequests[i].uri] = icons[i];
2390
+ }
2391
+ return newFileIconCache;
2392
+ };
2393
+
2367
2394
  const refreshProblems = async (state, activeUri) => {
2368
2395
  const {
2369
2396
  fileIconCache,
@@ -3705,6 +3732,7 @@ const commandMap = {
3705
3732
  'Problems.getKeyBindings': getKeyBindings,
3706
3733
  'Problems.getMenuEntries2': wrapGetter(getMenuEntries2),
3707
3734
  'Problems.getMenuIds': getMenuIds,
3735
+ 'Problems.getProblemsSummary': getProblemsSummary,
3708
3736
  'Problems.handleActiveEditorChange': wrapCommand(handleActiveEditorChange),
3709
3737
  'Problems.handleArrowLeft': wrapCommand(handleArrowLeft),
3710
3738
  'Problems.handleArrowRight': wrapCommand(handleArrowRight),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.29.1",
3
+ "version": "1.30.0",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",