@lvce-editor/problems-view 1.26.3 → 1.26.5

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.
@@ -244,6 +244,21 @@ const terminate = () => {
244
244
  globalThis.close();
245
245
  };
246
246
 
247
+ const Item = 0;
248
+ const Expanded = 1;
249
+ const Collapsed = 2;
250
+
251
+ const collapseAll$1 = state => {
252
+ const {
253
+ problems
254
+ } = state;
255
+ const collapsedUris = problems.filter(problem => problem.listItemType !== Item).map(problem => problem.uri);
256
+ return {
257
+ ...state,
258
+ collapsedUris: [...new Set(collapsedUris)]
259
+ };
260
+ };
261
+
247
262
  const normalizeLine = line => {
248
263
  if (line.startsWith('Error: ')) {
249
264
  return line.slice('Error: '.length);
@@ -300,6 +315,61 @@ class VError extends Error {
300
315
  }
301
316
  }
302
317
 
318
+ class AssertionError extends Error {
319
+ constructor(message) {
320
+ super(message);
321
+ this.name = 'AssertionError';
322
+ }
323
+ }
324
+ const Object$1 = 1;
325
+ const Number$1 = 2;
326
+ const Array$1 = 3;
327
+ const String$1 = 4;
328
+ const Boolean$1 = 5;
329
+ const Function = 6;
330
+ const Null = 7;
331
+ const Unknown = 8;
332
+ const getType = value => {
333
+ switch (typeof value) {
334
+ case 'number':
335
+ return Number$1;
336
+ case 'function':
337
+ return Function;
338
+ case 'string':
339
+ return String$1;
340
+ case 'object':
341
+ if (value === null) {
342
+ return Null;
343
+ }
344
+ if (Array.isArray(value)) {
345
+ return Array$1;
346
+ }
347
+ return Object$1;
348
+ case 'boolean':
349
+ return Boolean$1;
350
+ default:
351
+ return Unknown;
352
+ }
353
+ };
354
+ const number = value => {
355
+ const type = getType(value);
356
+ if (type !== Number$1) {
357
+ throw new AssertionError('expected value to be of type number');
358
+ }
359
+ };
360
+ const array = value => {
361
+ const type = getType(value);
362
+ if (type !== Array$1) {
363
+ throw new AssertionError('expected value to be of type array');
364
+ }
365
+ };
366
+ const string = value => {
367
+ const type = getType(value);
368
+ if (type !== String$1) {
369
+ throw new AssertionError('expected value to be of type string');
370
+ }
371
+ };
372
+
303
373
  const isMessagePort = value => {
304
374
  return value && value instanceof MessagePort;
305
375
  };
@@ -1211,6 +1281,34 @@ const listen$1 = async (module, options) => {
1211
1281
  return ipc;
1212
1282
  };
1213
1283
 
1284
+ const createSharedLazyRpc = factory => {
1285
+ let rpcPromise;
1286
+ const getOrCreate = () => {
1287
+ if (!rpcPromise) {
1288
+ rpcPromise = factory();
1289
+ }
1290
+ return rpcPromise;
1291
+ };
1292
+ return {
1293
+ async dispose() {
1294
+ const rpc = await getOrCreate();
1295
+ await rpc.dispose();
1296
+ },
1297
+ async invoke(method, ...params) {
1298
+ const rpc = await getOrCreate();
1299
+ return rpc.invoke(method, ...params);
1300
+ },
1301
+ async invokeAndTransfer(method, ...params) {
1302
+ const rpc = await getOrCreate();
1303
+ return rpc.invokeAndTransfer(method, ...params);
1304
+ },
1305
+ async send(method, ...params) {
1306
+ const rpc = await getOrCreate();
1307
+ rpc.send(method, ...params);
1308
+ }
1309
+ };
1310
+ };
1311
+
1214
1312
  const create$5 = async ({
1215
1313
  commandMap,
1216
1314
  isMessagePortOpen = true,
@@ -1246,34 +1344,6 @@ const create$4 = async ({
1246
1344
  });
1247
1345
  };
1248
1346
 
1249
- const createSharedLazyRpc = factory => {
1250
- let rpcPromise;
1251
- const getOrCreate = () => {
1252
- if (!rpcPromise) {
1253
- rpcPromise = factory();
1254
- }
1255
- return rpcPromise;
1256
- };
1257
- return {
1258
- async dispose() {
1259
- const rpc = await getOrCreate();
1260
- await rpc.dispose();
1261
- },
1262
- async invoke(method, ...params) {
1263
- const rpc = await getOrCreate();
1264
- return rpc.invoke(method, ...params);
1265
- },
1266
- async invokeAndTransfer(method, ...params) {
1267
- const rpc = await getOrCreate();
1268
- return rpc.invokeAndTransfer(method, ...params);
1269
- },
1270
- async send(method, ...params) {
1271
- const rpc = await getOrCreate();
1272
- rpc.send(method, ...params);
1273
- }
1274
- };
1275
- };
1276
-
1277
1347
  const create$3 = async ({
1278
1348
  commandMap,
1279
1349
  isMessagePortOpen,
@@ -1541,9 +1611,11 @@ const VirtualDomElements = {
1541
1611
  Video
1542
1612
  };
1543
1613
 
1614
+ const ClientX = 'event.clientX';
1544
1615
  const ClientY = 'event.clientY';
1545
1616
  const DeltaMode = 'event.deltaMode';
1546
1617
  const DeltaY = 'event.deltaY';
1618
+ const TargetName = 'event.target.name';
1547
1619
 
1548
1620
  const Space = 9;
1549
1621
  const PageUp = 10;
@@ -1586,61 +1658,6 @@ const EditorWorker = {
1586
1658
  set: set$3
1587
1659
  };
1588
1660
 
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
1661
  const {
1645
1662
  invoke,
1646
1663
  invokeAndTransfer,
@@ -1808,10 +1825,6 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1808
1825
  return Math.min(Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize), size);
1809
1826
  };
1810
1827
 
1811
- const Item = 0;
1812
- const Expanded = 1;
1813
- const Collapsed = 2;
1814
-
1815
1828
  const getListItemType = (listItemType, isCollapsed) => {
1816
1829
  if (listItemType === Item) {
1817
1830
  return Item;
@@ -2227,6 +2240,18 @@ const toProblems = (diagnostics, workspaceUri = '') => {
2227
2240
  return problems;
2228
2241
  };
2229
2242
 
2243
+ const getDiagnosticKey = diagnostic => JSON.stringify([diagnostic.uri, diagnostic.rowIndex, diagnostic.columnIndex, diagnostic.message, diagnostic.source, diagnostic.type, diagnostic.code]);
2244
+ const getUniqueDiagnostics = diagnostics => {
2245
+ const keys = new Set();
2246
+ return diagnostics.filter(diagnostic => {
2247
+ const key = getDiagnosticKey(diagnostic);
2248
+ if (keys.has(key)) {
2249
+ return false;
2250
+ }
2251
+ keys.add(key);
2252
+ return true;
2253
+ });
2254
+ };
2230
2255
  const getProblems = async (workspaceUri, activeUri) => {
2231
2256
  if (!activeUri) {
2232
2257
  return {
@@ -2235,10 +2260,8 @@ const getProblems = async (workspaceUri, activeUri) => {
2235
2260
  };
2236
2261
  }
2237
2262
  try {
2238
- const diagnostics = await getProblems$1();
2239
- const activeDiagnostics = diagnostics.filter(diagnostic => diagnostic.uri === activeUri);
2240
- // @ts-ignore
2241
- const problems = toProblems(activeDiagnostics, workspaceUri);
2263
+ const diagnostics = getUniqueDiagnostics(await getProblems$1());
2264
+ const problems = toProblems(diagnostics, workspaceUri);
2242
2265
  return {
2243
2266
  error: '',
2244
2267
  problems
@@ -2389,10 +2412,6 @@ const handleClickAt = (state, eventX, eventY) => {
2389
2412
  };
2390
2413
  };
2391
2414
 
2392
- const handleClickButton = async (state, name) => {
2393
- return state;
2394
- };
2395
-
2396
2415
  const show2 = async (uid, menuId, x, y, args) => {
2397
2416
  await showContextMenu2(uid, menuId, x, y, args);
2398
2417
  };
@@ -2407,6 +2426,35 @@ const handleClickMoreFilters = async (state, eventX, eventY) => {
2407
2426
  return state;
2408
2427
  };
2409
2428
 
2429
+ const viewAsList = state => {
2430
+ return {
2431
+ ...state,
2432
+ viewMode: List
2433
+ };
2434
+ };
2435
+
2436
+ const viewAsTable = state => {
2437
+ return {
2438
+ ...state,
2439
+ viewMode: Table
2440
+ };
2441
+ };
2442
+
2443
+ const handleClickButton = async (state, name, eventX = 0, eventY = 0) => {
2444
+ switch (name) {
2445
+ case 'collapseAll':
2446
+ return collapseAll$1(state);
2447
+ case 'more filters':
2448
+ return handleClickMoreFilters(state, eventX, eventY);
2449
+ case 'viewAsList':
2450
+ return viewAsList(state);
2451
+ case 'viewAsTable':
2452
+ return viewAsTable(state);
2453
+ default:
2454
+ return state;
2455
+ }
2456
+ };
2457
+
2410
2458
  const handleContextMenu = async (state, eventX, eventY) => {
2411
2459
  const {
2412
2460
  uid
@@ -2738,8 +2786,15 @@ const renderCss = (oldState, newState) => {
2738
2786
 
2739
2787
  const Filter$2 = 'filter';
2740
2788
 
2789
+ const getFilterInputName = (inputSource, filterValue) => {
2790
+ if (inputSource === Script && filterValue) {
2791
+ return `${Filter$2}-${encodeURIComponent(filterValue)}`;
2792
+ }
2793
+ return Filter$2;
2794
+ };
2795
+
2741
2796
  const renderFilterValue = (oldState, newState) => {
2742
- return ['Viewlet.setValueByName', Filter$2, newState.filterValue];
2797
+ return ['Viewlet.setValueByName', getFilterInputName(newState.inputSource, newState.filterValue), newState.filterValue];
2743
2798
  };
2744
2799
 
2745
2800
  const Button = 1;
@@ -2791,6 +2846,10 @@ const HandleWheel = 7;
2791
2846
  const HandleScrollBarMove = 8;
2792
2847
  const HandleScrollBarPointerCaptureLost = 9;
2793
2848
  const HandleScrollBarPointerDown = 10;
2849
+ const HandleCollapseAll = 11;
2850
+ const HandleViewAsList = 12;
2851
+ const HandleViewAsTable = 13;
2852
+ const HandleClickButton = 14;
2794
2853
 
2795
2854
  const getIconVirtualDom = (icon, type = Div) => {
2796
2855
  return {
@@ -2801,6 +2860,20 @@ const getIconVirtualDom = (icon, type = Div) => {
2801
2860
  };
2802
2861
  };
2803
2862
 
2863
+ const getOnClick = command => {
2864
+ switch (command) {
2865
+ case 'collapseAll':
2866
+ return HandleCollapseAll;
2867
+ case 'more filters':
2868
+ return HandleClickMoreFilters;
2869
+ case 'viewAsList':
2870
+ return HandleViewAsList;
2871
+ case 'viewAsTable':
2872
+ return HandleViewAsTable;
2873
+ default:
2874
+ return HandleClickButton;
2875
+ }
2876
+ };
2804
2877
  const getActionButtonVirtualDom = action => {
2805
2878
  const {
2806
2879
  command,
@@ -2810,7 +2883,8 @@ const getActionButtonVirtualDom = action => {
2810
2883
  return [{
2811
2884
  childCount: 1,
2812
2885
  className: IconButton,
2813
- 'data-command': command,
2886
+ name: command,
2887
+ onClick: getOnClick(command),
2814
2888
  title: id,
2815
2889
  type: Button$1
2816
2890
  }, getIconVirtualDom(icon)];
@@ -2828,7 +2902,7 @@ const getFilterBadgeDom = badgeText => {
2828
2902
  return [filterBadgeNode, text(badgeText)];
2829
2903
  };
2830
2904
 
2831
- const getInputBoxVirtualDom = (name, onInput, placeholder) => {
2905
+ const getInputBoxVirtualDom = (name, onInput, placeholder, value) => {
2832
2906
  return {
2833
2907
  ariaLabel: placeholder,
2834
2908
  autocapitalize: 'off',
@@ -2839,7 +2913,10 @@ const getInputBoxVirtualDom = (name, onInput, placeholder) => {
2839
2913
  onInput,
2840
2914
  placeholder,
2841
2915
  spellcheck: false,
2842
- type: Input
2916
+ type: Input,
2917
+ ...(value && {
2918
+ value
2919
+ })
2843
2920
  };
2844
2921
  };
2845
2922
 
@@ -2862,10 +2939,11 @@ const getProblemsFilterVirtualDom = action => {
2862
2939
  childCount: getChildCount(action.badgeText),
2863
2940
  className: Filter$1,
2864
2941
  type: Div
2865
- }, getInputBoxVirtualDom(Filter$2, action.command, action.placeholder || ''), ...getFilterBadgeDom(action.badgeText), ...getActionButtonVirtualDom({
2942
+ }, getInputBoxVirtualDom(action.name || Filter$2, action.command, action.placeholder || '', action.value), ...getFilterBadgeDom(action.badgeText), ...getActionButtonVirtualDom({
2866
2943
  command: 'more filters',
2867
2944
  icon: Filter,
2868
- id: 'more filters'})];
2945
+ id: 'more filters' // TODO use i18n string
2946
+ })];
2869
2947
  };
2870
2948
 
2871
2949
  const messageNode$2 = {
@@ -3186,7 +3264,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarActive) => {
3186
3264
 
3187
3265
  const Focusable = 0;
3188
3266
 
3189
- const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, isSmall, message, scrollBarHeight = 0, scrollBarActive = false, problemCount = problems.length) => {
3267
+ const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, inputSource, isSmall, message, scrollBarHeight = 0, scrollBarActive = false, problemCount = problems.length) => {
3190
3268
  const baseDom = {
3191
3269
  childCount: isSmall ? 2 : 1,
3192
3270
  className: mergeClassNames(Viewlet, Problems),
@@ -3201,7 +3279,10 @@ const getProblemsVirtualDom = (activeUri, viewMode, problems, filterValue, isSma
3201
3279
  const filterDom = isSmall ? getProblemsFilterVirtualDom({
3202
3280
  badgeText: '',
3203
3281
  command: HandleFilterInput,
3204
- placeholder: filter()}) : [];
3282
+ name: getFilterInputName(inputSource, filterValue),
3283
+ placeholder: filter(),
3284
+ value: filterValue
3285
+ }) : [];
3205
3286
  const itemsDom = getProblemsVirtualDom$1(viewMode, problems, filterValue, message, problemCount);
3206
3287
  const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarActive);
3207
3288
  const contentClassName = viewMode === Table ? mergeClassNames(ProblemsContent, ProblemsContentTable) : ProblemsContent;
@@ -3219,6 +3300,7 @@ const renderItems = (oldState, newState) => {
3219
3300
  collapsedUris,
3220
3301
  filterValue,
3221
3302
  focusedIndex,
3303
+ inputSource,
3222
3304
  maxLineY,
3223
3305
  message,
3224
3306
  minLineY,
@@ -3232,7 +3314,7 @@ const renderItems = (oldState, newState) => {
3232
3314
  const problemCount = getVisibleProblemCount(problems, collapsedUris, filterValue, viewMode);
3233
3315
  const visible = getVisibleProblems(problems, collapsedUris, focusedIndex, filterValue, minLineY, maxLineY, viewMode);
3234
3316
  const isSmall = width <= smallWidthBreakPoint;
3235
- const dom = getProblemsVirtualDom(activeUri, viewMode, visible, filterValue, isSmall, message, scrollBarHeight, scrollBarActive, problemCount);
3317
+ const dom = getProblemsVirtualDom(activeUri, viewMode, visible, filterValue, inputSource, isSmall, message, scrollBarHeight, scrollBarActive, problemCount);
3236
3318
  return ['Viewlet.setDom2', dom];
3237
3319
  };
3238
3320
 
@@ -3308,6 +3390,7 @@ const getActions = state => {
3308
3390
  badgeText: visibleCount === problemsCount ? '' : showingOf(visibleCount, problemsCount),
3309
3391
  command: HandleFilterInput,
3310
3392
  id: 'Filter',
3393
+ name: getFilterInputName(inputSource, filterValue),
3311
3394
  placeholder: filter(),
3312
3395
  type: ProblemsFilter,
3313
3396
  value: inputSource === Script ? filterValue : ''
@@ -3365,7 +3448,19 @@ const renderEventListeners = () => {
3365
3448
  params: ['handleClickAt', 'event.clientX', 'event.clientY']
3366
3449
  }, {
3367
3450
  name: HandleClickMoreFilters,
3368
- params: ['handleClickMoreFilters']
3451
+ params: ['handleClickMoreFilters', ClientX, ClientY]
3452
+ }, {
3453
+ name: HandleClickButton,
3454
+ params: ['handleClickButton', TargetName, ClientX, ClientY]
3455
+ }, {
3456
+ name: HandleCollapseAll,
3457
+ params: ['collapseAll']
3458
+ }, {
3459
+ name: HandleViewAsList,
3460
+ params: ['viewAsList']
3461
+ }, {
3462
+ name: HandleViewAsTable,
3463
+ params: ['viewAsTable']
3369
3464
  }, {
3370
3465
  name: HandleWheel,
3371
3466
  params: ['handleWheel', DeltaMode, DeltaY],
@@ -3404,21 +3499,8 @@ const saveState = state => {
3404
3499
  };
3405
3500
  };
3406
3501
 
3407
- const viewAsList = state => {
3408
- return {
3409
- ...state,
3410
- viewMode: List
3411
- };
3412
- };
3413
-
3414
- const viewAsTable = state => {
3415
- return {
3416
- ...state,
3417
- viewMode: Table
3418
- };
3419
- };
3420
-
3421
3502
  const commandMap = {
3503
+ 'Problems.collapseAll': wrapCommand(collapseAll$1),
3422
3504
  'Problems.copyMessage': wrapCommand(copyMessage),
3423
3505
  'Problems.create': create,
3424
3506
  'Problems.diff2': diff2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/problems-view",
3
- "version": "1.26.3",
3
+ "version": "1.26.5",
4
4
  "description": "Problems View Worker",
5
5
  "repository": {
6
6
  "type": "git",