@lvce-editor/problems-view 1.26.1 → 1.26.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.
@@ -300,61 +300,6 @@ class VError extends Error {
300
300
  }
301
301
  }
302
302
 
303
- class AssertionError extends Error {
304
- constructor(message) {
305
- super(message);
306
- this.name = 'AssertionError';
307
- }
308
- }
309
- const Object$1 = 1;
310
- const Number$1 = 2;
311
- const Array$1 = 3;
312
- const String$1 = 4;
313
- const Boolean$1 = 5;
314
- const Function = 6;
315
- const Null = 7;
316
- const Unknown = 8;
317
- const getType = value => {
318
- switch (typeof value) {
319
- case 'number':
320
- return Number$1;
321
- case 'function':
322
- return Function;
323
- case 'string':
324
- return String$1;
325
- case 'object':
326
- if (value === null) {
327
- return Null;
328
- }
329
- if (Array.isArray(value)) {
330
- return Array$1;
331
- }
332
- return Object$1;
333
- case 'boolean':
334
- return Boolean$1;
335
- default:
336
- return Unknown;
337
- }
338
- };
339
- const number = value => {
340
- const type = getType(value);
341
- if (type !== Number$1) {
342
- throw new AssertionError('expected value to be of type number');
343
- }
344
- };
345
- const array = value => {
346
- const type = getType(value);
347
- if (type !== Array$1) {
348
- throw new AssertionError('expected value to be of type array');
349
- }
350
- };
351
- const string = value => {
352
- const type = getType(value);
353
- if (type !== String$1) {
354
- throw new AssertionError('expected value to be of type string');
355
- }
356
- };
357
-
358
303
  const isMessagePort = value => {
359
304
  return value && value instanceof MessagePort;
360
305
  };
@@ -1616,7 +1561,7 @@ const Checked = 2;
1616
1561
  const Unchecked = 3;
1617
1562
 
1618
1563
  const EditorWorker$1 = 99;
1619
- const RendererWorker$1 = 1;
1564
+ const RendererWorker = 1;
1620
1565
 
1621
1566
  const SetCss = 'Viewlet.setCss';
1622
1567
 
@@ -1641,11 +1586,66 @@ const EditorWorker = {
1641
1586
  set: set$3
1642
1587
  };
1643
1588
 
1589
+ class AssertionError extends Error {
1590
+ constructor(message) {
1591
+ super(message);
1592
+ this.name = 'AssertionError';
1593
+ }
1594
+ }
1595
+ const Object$1 = 1;
1596
+ const Number$1 = 2;
1597
+ const Array$1 = 3;
1598
+ const String$1 = 4;
1599
+ const Boolean$1 = 5;
1600
+ const Function = 6;
1601
+ const Null = 7;
1602
+ const Unknown = 8;
1603
+ const getType = value => {
1604
+ switch (typeof value) {
1605
+ case 'number':
1606
+ return Number$1;
1607
+ case 'function':
1608
+ return Function;
1609
+ case 'string':
1610
+ return String$1;
1611
+ case 'object':
1612
+ if (value === null) {
1613
+ return Null;
1614
+ }
1615
+ if (Array.isArray(value)) {
1616
+ return Array$1;
1617
+ }
1618
+ return Object$1;
1619
+ case 'boolean':
1620
+ return Boolean$1;
1621
+ default:
1622
+ return Unknown;
1623
+ }
1624
+ };
1625
+ const number = value => {
1626
+ const type = getType(value);
1627
+ if (type !== Number$1) {
1628
+ throw new AssertionError('expected value to be of type number');
1629
+ }
1630
+ };
1631
+ const array = value => {
1632
+ const type = getType(value);
1633
+ if (type !== Array$1) {
1634
+ throw new AssertionError('expected value to be of type array');
1635
+ }
1636
+ };
1637
+ const string = value => {
1638
+ const type = getType(value);
1639
+ if (type !== String$1) {
1640
+ throw new AssertionError('expected value to be of type string');
1641
+ }
1642
+ };
1643
+
1644
1644
  const {
1645
1645
  invoke,
1646
1646
  invokeAndTransfer,
1647
1647
  set: set$2
1648
- } = create$1(RendererWorker$1);
1648
+ } = create$1(RendererWorker);
1649
1649
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1650
1650
  number(uid);
1651
1651
  number(menuId);
@@ -1664,23 +1664,18 @@ const getActiveEditorId$1 = () => {
1664
1664
  return invoke('GetActiveEditor.getActiveEditorId');
1665
1665
  };
1666
1666
 
1667
- const RendererWorker = {
1668
- __proto__: null,
1669
- getActiveEditorId: getActiveEditorId$1,
1670
- invoke,
1671
- invokeAndTransfer,
1672
- sendMessagePortToEditorWorker: sendMessagePortToEditorWorker$1,
1673
- set: set$2,
1674
- showContextMenu2,
1675
- writeClipBoardText: writeClipBoardText$1
1667
+ const getActiveEditorId = () => {
1668
+ return getActiveEditorId$1();
1669
+ };
1670
+ const sendMessagePortToEditorWorker = (port, rpcId) => {
1671
+ return sendMessagePortToEditorWorker$1(port, rpcId);
1672
+ };
1673
+ const set$1 = rpc => {
1674
+ set$2(rpc);
1675
+ };
1676
+ const writeClipBoardText = text => {
1677
+ return writeClipBoardText$1(text);
1676
1678
  };
1677
-
1678
- const {
1679
- getActiveEditorId,
1680
- sendMessagePortToEditorWorker,
1681
- set: set$1,
1682
- writeClipBoardText
1683
- } = RendererWorker;
1684
1679
 
1685
1680
  const writeText = async text => {
1686
1681
  await writeClipBoardText(text);
@@ -1813,13 +1808,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1813
1808
  return Math.min(Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize), size);
1814
1809
  };
1815
1810
 
1816
- const matchesFilterValue = (string, filterValueLower) => {
1817
- if (filterValueLower) {
1818
- return string.toLowerCase().indexOf(filterValueLower);
1819
- }
1820
- return 0;
1821
- };
1822
-
1823
1811
  const Item = 0;
1824
1812
  const Expanded = 1;
1825
1813
  const Collapsed = 2;
@@ -1833,8 +1821,17 @@ const getListItemType = (listItemType, isCollapsed) => {
1833
1821
  }
1834
1822
  return Expanded;
1835
1823
  };
1824
+
1825
+ const matchesFilterValue = (string, filterValueLower) => {
1826
+ if (filterValueLower) {
1827
+ return string.toLowerCase().indexOf(filterValueLower);
1828
+ }
1829
+ return 0;
1830
+ };
1831
+
1836
1832
  const filterProblems = (problems, collapsedUris, filterValue) => {
1837
1833
  const filterValueLower = filterValue.toLowerCase();
1834
+ const collapsedUriSet = new Set(collapsedUris);
1838
1835
  const filtered = [];
1839
1836
  for (const problem of problems) {
1840
1837
  const uriMatchIndex = matchesFilterValue(problem.uri, filterValueLower);
@@ -1843,7 +1840,7 @@ const filterProblems = (problems, collapsedUris, filterValue) => {
1843
1840
  if (uriMatchIndex === -1 && sourceMatchIndex === -1 && messageMatchIndex === -1) {
1844
1841
  continue;
1845
1842
  }
1846
- const isCollapsed = collapsedUris.includes(problem.uri);
1843
+ const isCollapsed = collapsedUriSet.has(problem.uri);
1847
1844
  if (isCollapsed && problem.listItemType === Item) {
1848
1845
  continue;
1849
1846
  }
@@ -2123,6 +2120,9 @@ const {
2123
2120
  getProblems: getProblems$1,
2124
2121
  getUri} = EditorWorker;
2125
2122
 
2123
+ const leadingSlashesRegex = /^\/+/;
2124
+ const trailingSlashRegex = /\/$/;
2125
+ const windowsDrivePathRegex = /^\/[a-z]:\//i;
2126
2126
  const toProblem = (diagnostic, index) => {
2127
2127
  const {
2128
2128
  code,
@@ -2152,11 +2152,11 @@ const toProblem = (diagnostic, index) => {
2152
2152
  };
2153
2153
  const normalizeFileUri = uri => {
2154
2154
  const normalizedUri = uri.startsWith('file://') ? uri.slice('file://'.length) : uri;
2155
- return /^\/[a-z]:\//i.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
2155
+ return windowsDrivePathRegex.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
2156
2156
  };
2157
2157
  const getRelativeParentUri = (uri, workspaceUri) => {
2158
2158
  const normalizedUri = normalizeFileUri(uri);
2159
- const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(/\/$/, '');
2159
+ const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(trailingSlashRegex, '');
2160
2160
  const slashIndex = normalizedUri.lastIndexOf('/');
2161
2161
  const parentUri = normalizedUri.slice(0, slashIndex);
2162
2162
  if (parentUri === normalizedWorkspaceUri) {
@@ -2165,7 +2165,7 @@ const getRelativeParentUri = (uri, workspaceUri) => {
2165
2165
  if (normalizedWorkspaceUri && parentUri.startsWith(`${normalizedWorkspaceUri}/`)) {
2166
2166
  return parentUri.slice(normalizedWorkspaceUri.length + 1);
2167
2167
  }
2168
- return parentUri.replace(/^\/+/, '');
2168
+ return parentUri.replace(leadingSlashesRegex, '');
2169
2169
  };
2170
2170
  const getFileName = uri => {
2171
2171
  const slashIndex = uri.lastIndexOf('/');
@@ -2251,14 +2251,10 @@ const getProblems = async (workspaceUri, activeUri) => {
2251
2251
  }
2252
2252
  };
2253
2253
 
2254
- const handleActiveEditorChange = async (state, activeUri) => {
2254
+ const refreshProblems = async (state, activeUri) => {
2255
2255
  const {
2256
- activeUri: oldActiveUri,
2257
2256
  workspaceUri
2258
2257
  } = state;
2259
- if (activeUri === oldActiveUri) {
2260
- return state;
2261
- }
2262
2258
  const {
2263
2259
  error,
2264
2260
  problems
@@ -2273,6 +2269,24 @@ const handleActiveEditorChange = async (state, activeUri) => {
2273
2269
  problems
2274
2270
  };
2275
2271
  };
2272
+ const handleActiveEditorChange = async (state, activeUri) => {
2273
+ const {
2274
+ activeUri: oldActiveUri
2275
+ } = state;
2276
+ if (activeUri === oldActiveUri) {
2277
+ return state;
2278
+ }
2279
+ return refreshProblems(state, activeUri);
2280
+ };
2281
+ const handleDiagnosticsChange = async (state, uri) => {
2282
+ const {
2283
+ activeUri
2284
+ } = state;
2285
+ if (uri !== activeUri) {
2286
+ return state;
2287
+ }
2288
+ return refreshProblems(state, uri);
2289
+ };
2276
2290
 
2277
2291
  const getArrowLeftNewFocusedIndex = (problems, collapsedUris, focusedIndex) => {
2278
2292
  for (let i = focusedIndex; i >= 0; i--) {
@@ -2280,7 +2294,7 @@ const getArrowLeftNewFocusedIndex = (problems, collapsedUris, focusedIndex) => {
2280
2294
  if (problem.listItemType !== Item) {
2281
2295
  return {
2282
2296
  index: i,
2283
- newCollapsedUris: [...collapsedUris, problem.uri]
2297
+ newCollapsedUris: collapsedUris.includes(problem.uri) ? collapsedUris : [...collapsedUris, problem.uri]
2284
2298
  };
2285
2299
  }
2286
2300
  }
@@ -2306,17 +2320,9 @@ const handleArrowLeft = state => {
2306
2320
  };
2307
2321
  };
2308
2322
 
2309
- const removeElement = (array, element) => {
2310
- const index = array.indexOf(element);
2311
- if (index === -1) {
2312
- return array;
2313
- }
2314
- return [...array.slice(0, index), ...array.slice(index + 1)];
2315
- };
2316
-
2317
2323
  const getArrowRightNewFocusedIndex = (problems, collapsedUris, focusedIndex) => {
2318
2324
  const problem = problems[focusedIndex];
2319
- const newCollapsedUris = removeElement(collapsedUris, problem.uri);
2325
+ const newCollapsedUris = collapsedUris.includes(problem.uri) ? collapsedUris.filter(uri => uri !== problem.uri) : collapsedUris;
2320
2326
  return {
2321
2327
  index: focusedIndex,
2322
2328
  newCollapsedUris
@@ -2544,27 +2550,32 @@ const getActiveUri = async () => {
2544
2550
  return getUri(editorId);
2545
2551
  };
2546
2552
 
2547
- const getSavedViewMode = savedState => {
2548
- if (savedState && typeof savedState.viewMode === 'number') {
2549
- return savedState.viewMode;
2553
+ const isString = value => {
2554
+ return typeof value === 'string';
2555
+ };
2556
+
2557
+ const getSavedCollapsedUris = savedState => {
2558
+ const collapsedUris = savedState?.collapsedUris;
2559
+ if (Array.isArray(collapsedUris) && collapsedUris.every(isString)) {
2560
+ return [...new Set(collapsedUris)];
2550
2561
  }
2551
- return List;
2562
+ return [];
2552
2563
  };
2564
+
2553
2565
  const getSavedFilterValue = savedState => {
2554
2566
  if (savedState && typeof savedState.filterValue === 'string') {
2555
2567
  return savedState.filterValue;
2556
2568
  }
2557
2569
  return '';
2558
2570
  };
2559
- const isString = value => {
2560
- return typeof value === 'string';
2561
- };
2562
- const getSavedCollapsedUris = savedState => {
2563
- if (savedState && savedState.collapsedUris && Array.isArray(savedState.collapsedUris) && savedState.collapsedUris.every(isString)) {
2564
- return savedState.collapsedUris;
2571
+
2572
+ const getSavedViewMode = savedState => {
2573
+ if (savedState && typeof savedState.viewMode === 'number') {
2574
+ return savedState.viewMode;
2565
2575
  }
2566
- return [];
2576
+ return List;
2567
2577
  };
2578
+
2568
2579
  const loadContent = async (state, savedState) => {
2569
2580
  const {
2570
2581
  workspaceUri
@@ -2819,8 +2830,10 @@ const getFilterBadgeDom = badgeText => {
2819
2830
 
2820
2831
  const getInputBoxVirtualDom = (name, onInput, placeholder) => {
2821
2832
  return {
2833
+ ariaLabel: placeholder,
2822
2834
  autocapitalize: 'off',
2823
2835
  autocorrect: 'off',
2836
+ childCount: 0,
2824
2837
  className: InputBox,
2825
2838
  name,
2826
2839
  onInput,
@@ -2899,6 +2912,7 @@ const getChevronRightVirtualDom = (extraClassName = '') => {
2899
2912
 
2900
2913
  const getFileIconVirtualDom = icon => {
2901
2914
  return {
2915
+ alt: '',
2902
2916
  childCount: 0,
2903
2917
  className: FileIcon,
2904
2918
  role: None$1,
@@ -3017,7 +3031,7 @@ const getProblemVirtualDom = problem => {
3017
3031
  role: TreeItem,
3018
3032
  type: Div
3019
3033
  }, getProblemsIconVirtualDom(type), label];
3020
- if (filterValueLength) {
3034
+ if (filterValueLength && messageMatchIndex >= 0) {
3021
3035
  const before = message.slice(0, messageMatchIndex);
3022
3036
  const middle = message.slice(messageMatchIndex, messageMatchIndex + filterValueLength);
3023
3037
  const after = message.slice(messageMatchIndex + filterValueLength);
@@ -3421,6 +3435,7 @@ const commandMap = {
3421
3435
  'Problems.handleClickButton': wrapCommand(handleClickButton),
3422
3436
  'Problems.handleClickMoreFilters': wrapCommand(handleClickMoreFilters),
3423
3437
  'Problems.handleContextMenu': wrapCommand(handleContextMenu),
3438
+ 'Problems.handleDiagnosticsChange': wrapCommand(handleDiagnosticsChange),
3424
3439
  'Problems.handleFilterInput': wrapCommand(handleFilterInput),
3425
3440
  'Problems.handleIconThemeChange': wrapCommand(handleIconThemeChange),
3426
3441
  'Problems.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.26.1",
3
+ "version": "1.26.3",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",