@lvce-editor/extension-search-view 4.6.0 → 4.8.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.
@@ -1117,6 +1117,33 @@ const terminate = () => {
1117
1117
  globalThis.close();
1118
1118
  };
1119
1119
 
1120
+ const None$3 = 'none';
1121
+
1122
+ const Button$2 = 1;
1123
+ const Div = 4;
1124
+ const Input$1 = 6;
1125
+ const Text = 12;
1126
+ const Img = 17;
1127
+
1128
+ const Button$1 = 'event.button';
1129
+ const ClientX = 'event.clientX';
1130
+ const ClientY = 'event.clientY';
1131
+ const DeltaMode = 'event.deltaMode';
1132
+ const DeltaY = 'event.deltaY';
1133
+ const TargetValue = 'event.target.value';
1134
+
1135
+ const Script$1 = 2;
1136
+
1137
+ const LeftClick = 0;
1138
+
1139
+ const DebugWorker = 55;
1140
+ const ExtensionHostWorker = 44;
1141
+ const RendererWorker$1 = 1;
1142
+
1143
+ const None$2 = 0;
1144
+ const Input = 1;
1145
+ const List$2 = 2;
1146
+
1120
1147
  const handleError = async (error, notify = true, prefix = '') => {
1121
1148
  // @ts-ignore
1122
1149
  console.error(error);
@@ -1208,10 +1235,6 @@ const viewsAndMoreActions = () => {
1208
1235
  return i18nString(ViewsAndMoreActions);
1209
1236
  };
1210
1237
 
1211
- const None$3 = 0;
1212
- const Input$1 = 1;
1213
- const List$2 = 2;
1214
-
1215
1238
  const getFinalDeltaY = (height, itemHeight, itemsLength) => {
1216
1239
  const contentHeight = itemsLength * itemHeight;
1217
1240
  const finalDeltaY = Math.max(contentHeight - height, 0);
@@ -1258,9 +1281,22 @@ const Disabled = '@disabled';
1258
1281
  const Builtin = '@builtin';
1259
1282
  const Sort = '@sort';
1260
1283
  const Id = '@id';
1284
+ const Category = '@category';
1261
1285
  const Outdated = '@outdated';
1262
1286
 
1263
1287
  const RE_PARAM = /@\w+/g;
1288
+ const deserializeCategory = value => {
1289
+ if (value.startsWith(':"') && value.endsWith('"')) {
1290
+ return value.slice(2, -1);
1291
+ }
1292
+ if (value.startsWith('"') && value.endsWith('"')) {
1293
+ return value.slice(1, -1);
1294
+ }
1295
+ if (value.startsWith(':')) {
1296
+ return value.slice(1);
1297
+ }
1298
+ return value.trim();
1299
+ };
1264
1300
 
1265
1301
  // TODO test sorting and filtering
1266
1302
  const parseValue = value => {
@@ -1271,6 +1307,7 @@ const parseValue = value => {
1271
1307
  let sort = '';
1272
1308
  let id = '';
1273
1309
  let outdated = false;
1310
+ let category = '';
1274
1311
  // TODO this is not very functional code (assignment)
1275
1312
  const replaced = value.replaceAll(RE_PARAM, (match, by, order) => {
1276
1313
  if (match.startsWith(Installed)) {
@@ -1293,6 +1330,10 @@ const parseValue = value => {
1293
1330
  // TODO improve parsing
1294
1331
  id = value.replace('@id:', '');
1295
1332
  }
1333
+ if (match.startsWith(Category)) {
1334
+ const raw = value.replace('@category', '');
1335
+ category = deserializeCategory(raw);
1336
+ }
1296
1337
  if (match.startsWith(Outdated)) {
1297
1338
  outdated = true;
1298
1339
  }
@@ -1308,7 +1349,8 @@ const parseValue = value => {
1308
1349
  installed,
1309
1350
  id,
1310
1351
  sort,
1311
- isLocal
1352
+ isLocal,
1353
+ category
1312
1354
  };
1313
1355
  };
1314
1356
 
@@ -1320,10 +1362,18 @@ const matchesId = (extension, query) => {
1320
1362
  const extensionIdLower = extension.id.toLowerCase();
1321
1363
  return extensionIdLower.includes(query);
1322
1364
  };
1365
+ const matchesCategory = (extension, category) => {
1366
+ return extension && typeof extension === 'object' && 'categories' in extension && Array.isArray(extension.categories) && extension.categories.some(item => {
1367
+ return item.toLowerCase() === category;
1368
+ });
1369
+ };
1323
1370
  const matchesParsedValue = (extension, parsedValue) => {
1324
1371
  if (parsedValue.id && extension.id) {
1325
1372
  return parsedValue.id === extension.id;
1326
1373
  }
1374
+ if (parsedValue.category && matchesCategory(extension, parsedValue.category)) {
1375
+ return true;
1376
+ }
1327
1377
  if (extension.name) {
1328
1378
  return matchesName(extension, parsedValue.query);
1329
1379
  }
@@ -1387,7 +1437,7 @@ const handleInput = async (state, value, inputSource = User) => {
1387
1437
  allExtensions,
1388
1438
  deltaY: 0,
1389
1439
  finalDeltaY: 0,
1390
- focus: Input$1,
1440
+ focus: Input,
1391
1441
  items,
1392
1442
  maxLineY: 0,
1393
1443
  message: noExtensionsFound(),
@@ -1436,34 +1486,16 @@ const handleInput = async (state, value, inputSource = User) => {
1436
1486
  };
1437
1487
 
1438
1488
  const clearSearchResults = state => {
1439
- return handleInput(state, '');
1489
+ return handleInput({
1490
+ ...state,
1491
+ focus: Input
1492
+ }, '', Script$1);
1440
1493
  };
1441
1494
 
1442
1495
  const closeSuggest = state => {
1443
1496
  return state;
1444
1497
  };
1445
1498
 
1446
- const None$2 = 'none';
1447
-
1448
- const Button$2 = 1;
1449
- const Div = 4;
1450
- const Input = 6;
1451
- const Text = 12;
1452
- const Img = 17;
1453
-
1454
- const Button$1 = 'event.button';
1455
- const ClientX = 'event.clientX';
1456
- const ClientY = 'event.clientY';
1457
- const DeltaMode = 'event.deltaMode';
1458
- const DeltaY = 'event.deltaY';
1459
- const TargetValue = 'event.target.value';
1460
-
1461
- const LeftClick = 0;
1462
-
1463
- const DebugWorker = 55;
1464
- const ExtensionHostWorker = 44;
1465
- const RendererWorker$1 = 1;
1466
-
1467
1499
  const rpcs = Object.create(null);
1468
1500
  const set$5 = (id, rpc) => {
1469
1501
  rpcs[id] = rpc;
@@ -1970,7 +2002,8 @@ const {
1970
2002
  wrapCommand,
1971
2003
  getCommandIds,
1972
2004
  registerCommands,
1973
- wrapGetter
2005
+ wrapGetter,
2006
+ diff
1974
2007
  } = create$2();
1975
2008
 
1976
2009
  const create = (id, uri, x, y, width, height, platform, assetDir) => {
@@ -2036,18 +2069,7 @@ const modules = [isEqual$1, isEqual$2, isEqual, isEqual$2];
2036
2069
  const numbers = [RenderItems, RenderFocus, RenderSearchValue, RenderFocusContext];
2037
2070
 
2038
2071
  const diff2 = uid => {
2039
- const {
2040
- oldState,
2041
- newState
2042
- } = get(uid);
2043
- const diffResult = [];
2044
- for (let i = 0; i < modules.length; i++) {
2045
- const fn = modules[i];
2046
- if (!fn(oldState, newState)) {
2047
- diffResult.push(numbers[i]);
2048
- }
2049
- }
2050
- return diffResult;
2072
+ return diff(uid, modules, numbers);
2051
2073
  };
2052
2074
 
2053
2075
  const dispose = uid => {
@@ -2333,7 +2355,7 @@ const getMenuEntries = () => {
2333
2355
  const handleBlur = state => {
2334
2356
  return {
2335
2357
  ...state,
2336
- focus: None$3
2358
+ focus: None$2
2337
2359
  };
2338
2360
  };
2339
2361
 
@@ -2658,7 +2680,10 @@ const HandleTouchStart = 14;
2658
2680
  const HandleWheel = 15;
2659
2681
 
2660
2682
  const getInputActions = newState => {
2661
- const clearEnabled = newState.searchValue.length > 0;
2683
+ const {
2684
+ searchValue
2685
+ } = newState;
2686
+ const clearEnabled = searchValue.length > 0;
2662
2687
  const actions = [{
2663
2688
  onClick: HandleClearSearchResults,
2664
2689
  icon: `MaskIcon${ClearAll}`,
@@ -2774,7 +2799,9 @@ const normalizeExtension$1 = (extension, platform, assetDir) => {
2774
2799
  description: getDescription(extension),
2775
2800
  uri: '',
2776
2801
  publisher: getPublisher(extension),
2777
- icon: getIcon(extension, platform, assetDir)
2802
+ icon: getIcon(extension, platform, assetDir),
2803
+ // @ts-ignore // TODO
2804
+ categories: extension.categories
2778
2805
  };
2779
2806
  };
2780
2807
 
@@ -2830,7 +2857,7 @@ const loadContent = async (state, savedState) => {
2830
2857
  inputSource: Script,
2831
2858
  inputActions,
2832
2859
  deltaY
2833
- }, searchValue);
2860
+ }, searchValue, Script);
2834
2861
  return updatedState;
2835
2862
  };
2836
2863
 
@@ -2842,7 +2869,7 @@ const Extensions$1 = 'extensions';
2842
2869
 
2843
2870
  const getSelector = focus => {
2844
2871
  switch (focus) {
2845
- case Input$1:
2872
+ case Input:
2846
2873
  return `[name="${Extensions$1}"]`;
2847
2874
  case List$2:
2848
2875
  return '.ListItems';
@@ -2866,7 +2893,7 @@ const renderFocusContext = newState => {
2866
2893
  const {
2867
2894
  uid
2868
2895
  } = newState;
2869
- if (newState.focus === Input$1) {
2896
+ if (newState.focus === Input) {
2870
2897
  return ['Viewlet.setFocusContext', uid, FocusExtensionsInput];
2871
2898
  }
2872
2899
  if (newState.focus === List$2) {
@@ -2944,7 +2971,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2944
2971
  role: None,
2945
2972
  childCount: 2
2946
2973
  }, {
2947
- type: Input,
2974
+ type: Input$1,
2948
2975
  inputType: 'search',
2949
2976
  className: MultilineInputBox,
2950
2977
  spellcheck: false,
@@ -3187,7 +3214,7 @@ const getExtensionsViewVirtualDom = state => {
3187
3214
  childCount: 2,
3188
3215
  ariaLive: 'polite',
3189
3216
  ariaBusy: false,
3190
- role: None$2
3217
+ role: None$3
3191
3218
  }, ...getExtensionHeaderVirtualDom(placeholder, inputActions), ...getContentVirtualDom(visibleExtensions, message, scrollBarHeight, scrollBarY)];
3192
3219
  };
3193
3220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "4.6.0",
3
+ "version": "4.8.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",