@lvce-editor/problems-view 1.26.2 → 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
  };
@@ -1641,6 +1586,61 @@ 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,
@@ -1808,13 +1808,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1808
1808
  return Math.min(Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize), size);
1809
1809
  };
1810
1810
 
1811
- const matchesFilterValue = (string, filterValueLower) => {
1812
- if (filterValueLower) {
1813
- return string.toLowerCase().indexOf(filterValueLower);
1814
- }
1815
- return 0;
1816
- };
1817
-
1818
1811
  const Item = 0;
1819
1812
  const Expanded = 1;
1820
1813
  const Collapsed = 2;
@@ -1828,8 +1821,17 @@ const getListItemType = (listItemType, isCollapsed) => {
1828
1821
  }
1829
1822
  return Expanded;
1830
1823
  };
1824
+
1825
+ const matchesFilterValue = (string, filterValueLower) => {
1826
+ if (filterValueLower) {
1827
+ return string.toLowerCase().indexOf(filterValueLower);
1828
+ }
1829
+ return 0;
1830
+ };
1831
+
1831
1832
  const filterProblems = (problems, collapsedUris, filterValue) => {
1832
1833
  const filterValueLower = filterValue.toLowerCase();
1834
+ const collapsedUriSet = new Set(collapsedUris);
1833
1835
  const filtered = [];
1834
1836
  for (const problem of problems) {
1835
1837
  const uriMatchIndex = matchesFilterValue(problem.uri, filterValueLower);
@@ -1838,7 +1840,7 @@ const filterProblems = (problems, collapsedUris, filterValue) => {
1838
1840
  if (uriMatchIndex === -1 && sourceMatchIndex === -1 && messageMatchIndex === -1) {
1839
1841
  continue;
1840
1842
  }
1841
- const isCollapsed = collapsedUris.includes(problem.uri);
1843
+ const isCollapsed = collapsedUriSet.has(problem.uri);
1842
1844
  if (isCollapsed && problem.listItemType === Item) {
1843
1845
  continue;
1844
1846
  }
@@ -2118,6 +2120,9 @@ const {
2118
2120
  getProblems: getProblems$1,
2119
2121
  getUri} = EditorWorker;
2120
2122
 
2123
+ const leadingSlashesRegex = /^\/+/;
2124
+ const trailingSlashRegex = /\/$/;
2125
+ const windowsDrivePathRegex = /^\/[a-z]:\//i;
2121
2126
  const toProblem = (diagnostic, index) => {
2122
2127
  const {
2123
2128
  code,
@@ -2147,11 +2152,11 @@ const toProblem = (diagnostic, index) => {
2147
2152
  };
2148
2153
  const normalizeFileUri = uri => {
2149
2154
  const normalizedUri = uri.startsWith('file://') ? uri.slice('file://'.length) : uri;
2150
- return /^\/[a-z]:\//i.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
2155
+ return windowsDrivePathRegex.test(normalizedUri) ? normalizedUri.slice(1) : normalizedUri;
2151
2156
  };
2152
2157
  const getRelativeParentUri = (uri, workspaceUri) => {
2153
2158
  const normalizedUri = normalizeFileUri(uri);
2154
- const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(/\/$/, '');
2159
+ const normalizedWorkspaceUri = normalizeFileUri(workspaceUri).replace(trailingSlashRegex, '');
2155
2160
  const slashIndex = normalizedUri.lastIndexOf('/');
2156
2161
  const parentUri = normalizedUri.slice(0, slashIndex);
2157
2162
  if (parentUri === normalizedWorkspaceUri) {
@@ -2160,7 +2165,7 @@ const getRelativeParentUri = (uri, workspaceUri) => {
2160
2165
  if (normalizedWorkspaceUri && parentUri.startsWith(`${normalizedWorkspaceUri}/`)) {
2161
2166
  return parentUri.slice(normalizedWorkspaceUri.length + 1);
2162
2167
  }
2163
- return parentUri.replace(/^\/+/, '');
2168
+ return parentUri.replace(leadingSlashesRegex, '');
2164
2169
  };
2165
2170
  const getFileName = uri => {
2166
2171
  const slashIndex = uri.lastIndexOf('/');
@@ -2289,7 +2294,7 @@ const getArrowLeftNewFocusedIndex = (problems, collapsedUris, focusedIndex) => {
2289
2294
  if (problem.listItemType !== Item) {
2290
2295
  return {
2291
2296
  index: i,
2292
- newCollapsedUris: [...collapsedUris, problem.uri]
2297
+ newCollapsedUris: collapsedUris.includes(problem.uri) ? collapsedUris : [...collapsedUris, problem.uri]
2293
2298
  };
2294
2299
  }
2295
2300
  }
@@ -2315,17 +2320,9 @@ const handleArrowLeft = state => {
2315
2320
  };
2316
2321
  };
2317
2322
 
2318
- const removeElement = (array, element) => {
2319
- const index = array.indexOf(element);
2320
- if (index === -1) {
2321
- return array;
2322
- }
2323
- return [...array.slice(0, index), ...array.slice(index + 1)];
2324
- };
2325
-
2326
2323
  const getArrowRightNewFocusedIndex = (problems, collapsedUris, focusedIndex) => {
2327
2324
  const problem = problems[focusedIndex];
2328
- const newCollapsedUris = removeElement(collapsedUris, problem.uri);
2325
+ const newCollapsedUris = collapsedUris.includes(problem.uri) ? collapsedUris.filter(uri => uri !== problem.uri) : collapsedUris;
2329
2326
  return {
2330
2327
  index: focusedIndex,
2331
2328
  newCollapsedUris
@@ -2553,27 +2550,32 @@ const getActiveUri = async () => {
2553
2550
  return getUri(editorId);
2554
2551
  };
2555
2552
 
2556
- const getSavedViewMode = savedState => {
2557
- if (savedState && typeof savedState.viewMode === 'number') {
2558
- 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)];
2559
2561
  }
2560
- return List;
2562
+ return [];
2561
2563
  };
2564
+
2562
2565
  const getSavedFilterValue = savedState => {
2563
2566
  if (savedState && typeof savedState.filterValue === 'string') {
2564
2567
  return savedState.filterValue;
2565
2568
  }
2566
2569
  return '';
2567
2570
  };
2568
- const isString = value => {
2569
- return typeof value === 'string';
2570
- };
2571
- const getSavedCollapsedUris = savedState => {
2572
- if (savedState && savedState.collapsedUris && Array.isArray(savedState.collapsedUris) && savedState.collapsedUris.every(isString)) {
2573
- return savedState.collapsedUris;
2571
+
2572
+ const getSavedViewMode = savedState => {
2573
+ if (savedState && typeof savedState.viewMode === 'number') {
2574
+ return savedState.viewMode;
2574
2575
  }
2575
- return [];
2576
+ return List;
2576
2577
  };
2578
+
2577
2579
  const loadContent = async (state, savedState) => {
2578
2580
  const {
2579
2581
  workspaceUri
@@ -2828,8 +2830,10 @@ const getFilterBadgeDom = badgeText => {
2828
2830
 
2829
2831
  const getInputBoxVirtualDom = (name, onInput, placeholder) => {
2830
2832
  return {
2833
+ ariaLabel: placeholder,
2831
2834
  autocapitalize: 'off',
2832
2835
  autocorrect: 'off',
2836
+ childCount: 0,
2833
2837
  className: InputBox,
2834
2838
  name,
2835
2839
  onInput,
@@ -2908,6 +2912,7 @@ const getChevronRightVirtualDom = (extraClassName = '') => {
2908
2912
 
2909
2913
  const getFileIconVirtualDom = icon => {
2910
2914
  return {
2915
+ alt: '',
2911
2916
  childCount: 0,
2912
2917
  className: FileIcon,
2913
2918
  role: None$1,
@@ -3026,7 +3031,7 @@ const getProblemVirtualDom = problem => {
3026
3031
  role: TreeItem,
3027
3032
  type: Div
3028
3033
  }, getProblemsIconVirtualDom(type), label];
3029
- if (filterValueLength) {
3034
+ if (filterValueLength && messageMatchIndex >= 0) {
3030
3035
  const before = message.slice(0, messageMatchIndex);
3031
3036
  const middle = message.slice(messageMatchIndex, messageMatchIndex + filterValueLength);
3032
3037
  const after = message.slice(messageMatchIndex + filterValueLength);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.26.2",
3
+ "version": "1.26.3",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",