@lvce-editor/quick-pick-worker 4.25.0 → 4.26.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.
@@ -553,7 +553,7 @@ const execute = (command, ...args) => {
553
553
 
554
554
  const Two$1 = '2.0';
555
555
  const callbacks$2 = Object.create(null);
556
- const get$3 = id => {
556
+ const get$4 = id => {
557
557
  return callbacks$2[id];
558
558
  };
559
559
  const remove$2 = id => {
@@ -774,7 +774,7 @@ const warn$1 = (...args) => {
774
774
  console.warn(...args);
775
775
  };
776
776
  const resolve = (id, response) => {
777
- const fn = get$3(id);
777
+ const fn = get$4(id);
778
778
  if (!fn) {
779
779
  console.log(response);
780
780
  warn$1(`callback ${id} may already be disposed`);
@@ -1039,6 +1039,9 @@ const logError = () => {
1039
1039
  // handled by renderer worker
1040
1040
  };
1041
1041
  const handleMessage = event => {
1042
+ if (event.data === 'ready') {
1043
+ return Promise.resolve();
1044
+ }
1042
1045
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
1043
1046
  const actualExecute = event?.target?.execute || execute;
1044
1047
  return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
@@ -1171,10 +1174,10 @@ const createMockRpc = ({
1171
1174
  };
1172
1175
 
1173
1176
  const rpcs = Object.create(null);
1174
- const set$8 = (id, rpc) => {
1177
+ const set$a = (id, rpc) => {
1175
1178
  rpcs[id] = rpc;
1176
1179
  };
1177
- const get$2 = id => {
1180
+ const get$3 = id => {
1178
1181
  return rpcs[id];
1179
1182
  };
1180
1183
  const remove$1 = id => {
@@ -1185,18 +1188,18 @@ const remove$1 = id => {
1185
1188
  const create$4 = rpcId => {
1186
1189
  return {
1187
1190
  async dispose() {
1188
- const rpc = get$2(rpcId);
1191
+ const rpc = get$3(rpcId);
1189
1192
  await rpc.dispose();
1190
1193
  },
1191
1194
  // @ts-ignore
1192
1195
  invoke(method, ...params) {
1193
- const rpc = get$2(rpcId);
1196
+ const rpc = get$3(rpcId);
1194
1197
  // @ts-ignore
1195
1198
  return rpc.invoke(method, ...params);
1196
1199
  },
1197
1200
  // @ts-ignore
1198
1201
  invokeAndTransfer(method, ...params) {
1199
- const rpc = get$2(rpcId);
1202
+ const rpc = get$3(rpcId);
1200
1203
  // @ts-ignore
1201
1204
  return rpc.invokeAndTransfer(method, ...params);
1202
1205
  },
@@ -1204,7 +1207,7 @@ const create$4 = rpcId => {
1204
1207
  const mockRpc = createMockRpc({
1205
1208
  commandMap
1206
1209
  });
1207
- set$8(rpcId, mockRpc);
1210
+ set$a(rpcId, mockRpc);
1208
1211
  // @ts-ignore
1209
1212
  mockRpc[Symbol.dispose] = () => {
1210
1213
  remove$1(rpcId);
@@ -1213,180 +1216,19 @@ const create$4 = rpcId => {
1213
1216
  return mockRpc;
1214
1217
  },
1215
1218
  set(rpc) {
1216
- set$8(rpcId, rpc);
1219
+ set$a(rpcId, rpc);
1217
1220
  }
1218
1221
  };
1219
1222
  };
1220
1223
 
1221
- const Audio = 0;
1222
1224
  const Button = 1;
1223
- const Col = 2;
1224
- const ColGroup = 3;
1225
1225
  const Div = 4;
1226
- const H1 = 5;
1227
1226
  const Input = 6;
1228
- const Kbd = 7;
1229
1227
  const Span = 8;
1230
- const Table = 9;
1231
- const TBody = 10;
1232
- const Td = 11;
1233
1228
  const Text = 12;
1234
- const Th = 13;
1235
- const THead = 14;
1236
- const Tr = 15;
1237
- const I = 16;
1238
1229
  const Img = 17;
1239
- const Root = 0;
1240
- const Ins = 20;
1241
- const Del = 21;
1242
- const H2 = 22;
1243
- const H3 = 23;
1244
- const H4 = 24;
1245
- const H5 = 25;
1246
- const H6 = 26;
1247
- const Article = 27;
1248
- const Aside = 28;
1249
- const Footer = 29;
1250
- const Header = 30;
1251
- const Nav = 40;
1252
- const Section = 41;
1253
- const Search = 42;
1254
- const Dd = 43;
1255
- const Dl = 44;
1256
- const Figcaption = 45;
1257
- const Figure = 46;
1258
- const Hr = 47;
1259
- const Li = 48;
1260
- const Ol = 49;
1261
- const P = 50;
1262
- const Pre = 51;
1263
- const A = 53;
1264
- const Abbr = 54;
1265
- const Br = 55;
1266
- const Cite = 56;
1267
- const Data = 57;
1268
- const Time = 58;
1269
- const Tfoot = 59;
1270
- const Ul = 60;
1271
- const Video = 61;
1272
- const TextArea = 62;
1273
- const Select = 63;
1274
- const Option$1 = 64;
1275
- const Code = 65;
1276
- const Label$1 = 66;
1277
- const Dt = 67;
1278
- const Iframe = 68;
1279
- const Main = 69;
1280
- const Strong = 70;
1281
- const Em = 71;
1282
- const Style = 72;
1283
- const Html = 73;
1284
- const Head = 74;
1285
- const Title = 75;
1286
- const Meta = 76;
1287
- const Canvas = 77;
1288
- const Form = 78;
1289
- const BlockQuote = 79;
1290
- const Quote = 80;
1291
- const Circle = 81;
1292
- const Defs = 82;
1293
- const Ellipse = 83;
1294
- const G = 84;
1295
- const Line = 85;
1296
- const Path = 86;
1297
- const Polygon = 87;
1298
- const Polyline = 88;
1299
- const Rect = 89;
1300
- const Svg = 90;
1301
- const Use = 91;
1302
1230
  const Reference = 100;
1303
1231
 
1304
- const VirtualDomElements = {
1305
- __proto__: null,
1306
- A,
1307
- Abbr,
1308
- Article,
1309
- Aside,
1310
- Audio,
1311
- BlockQuote,
1312
- Br,
1313
- Button,
1314
- Canvas,
1315
- Circle,
1316
- Cite,
1317
- Code,
1318
- Col,
1319
- ColGroup,
1320
- Data,
1321
- Dd,
1322
- Defs,
1323
- Del,
1324
- Div,
1325
- Dl,
1326
- Dt,
1327
- Ellipse,
1328
- Em,
1329
- Figcaption,
1330
- Figure,
1331
- Footer,
1332
- Form,
1333
- G,
1334
- H1,
1335
- H2,
1336
- H3,
1337
- H4,
1338
- H5,
1339
- H6,
1340
- Head,
1341
- Header,
1342
- Hr,
1343
- Html,
1344
- I,
1345
- Iframe,
1346
- Img,
1347
- Input,
1348
- Ins,
1349
- Kbd,
1350
- Label: Label$1,
1351
- Li,
1352
- Line,
1353
- Main,
1354
- Meta,
1355
- Nav,
1356
- Ol,
1357
- Option: Option$1,
1358
- P,
1359
- Path,
1360
- Polygon,
1361
- Polyline,
1362
- Pre,
1363
- Quote,
1364
- Rect,
1365
- Reference,
1366
- Root,
1367
- Search,
1368
- Section,
1369
- Select,
1370
- Span,
1371
- Strong,
1372
- Style,
1373
- Svg,
1374
- TBody,
1375
- THead,
1376
- Table,
1377
- Td,
1378
- Text,
1379
- TextArea,
1380
- Tfoot,
1381
- Th,
1382
- Time,
1383
- Title,
1384
- Tr,
1385
- Ul,
1386
- Use,
1387
- Video
1388
- };
1389
-
1390
1232
  const EditorWorker = 99;
1391
1233
  const ExtensionManagementWorker = 9006;
1392
1234
  const RendererProcess = 1670;
@@ -1400,66 +1242,66 @@ const SetPatches = 'Viewlet.setPatches';
1400
1242
  const FocusQuickPickInput = 20;
1401
1243
 
1402
1244
  const {
1403
- invoke: invoke$7,
1404
- set: set$7
1245
+ invoke: invoke$8,
1246
+ set: set$9
1405
1247
  } = create$4(EditorWorker);
1406
1248
  const getLines = async editorUid => {
1407
- const lines = await invoke$7('Editor.getLines2', editorUid);
1249
+ const lines = await invoke$8('Editor.getLines2', editorUid);
1408
1250
  return lines;
1409
1251
  };
1410
1252
 
1411
1253
  const {
1412
- invoke: invoke$6,
1413
- set: set$6
1254
+ invoke: invoke$7,
1255
+ set: set$8
1414
1256
  } = create$4(ExtensionManagementWorker);
1415
1257
  const getLanguages = (platform, assetDir) => {
1416
- return invoke$6('Extensions.getLanguages', platform, assetDir);
1258
+ return invoke$7('Extensions.getLanguages', platform, assetDir);
1417
1259
  };
1418
1260
 
1419
1261
  const {
1420
- invoke: invoke$5,
1421
- set: set$5
1262
+ invoke: invoke$6,
1263
+ set: set$7
1422
1264
  } = create$4(7013);
1423
1265
 
1424
1266
  const {
1425
- invoke: invoke$4,
1426
- set: set$4
1267
+ invoke: invoke$5,
1268
+ set: set$6
1427
1269
  } = create$4(RendererProcess);
1428
1270
 
1429
1271
  const {
1430
- invoke: invoke$3,
1272
+ invoke: invoke$4,
1431
1273
  invokeAndTransfer,
1432
- set: set$3
1274
+ set: set$5
1433
1275
  } = create$4(RendererWorker);
1434
1276
  const sendMessagePortToEditorWorker = async (port, rpcId) => {
1435
1277
  const command = 'HandleMessagePort.handleMessagePort';
1436
1278
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1437
1279
  };
1438
1280
  const setFocus = key => {
1439
- return invoke$3('Focus.setFocus', key);
1281
+ return invoke$4('Focus.setFocus', key);
1440
1282
  };
1441
1283
  const getFileIcon = async options => {
1442
- return invoke$3('IconTheme.getFileIcon', options);
1284
+ return invoke$4('IconTheme.getFileIcon', options);
1443
1285
  };
1444
1286
  const getFolderIcon = async options => {
1445
- return invoke$3('IconTheme.getFolderIcon', options);
1287
+ return invoke$4('IconTheme.getFolderIcon', options);
1446
1288
  };
1447
1289
  const closeWidget$1 = async widgetId => {
1448
- return invoke$3('Viewlet.closeWidget', widgetId);
1290
+ return invoke$4('Viewlet.closeWidget', widgetId);
1449
1291
  };
1450
1292
  const sendMessagePortToFileSearchWorker2 = async (port, rpcId = 0) => {
1451
1293
  const command = 'FileSearch.handleMessagePort';
1452
1294
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
1453
1295
  };
1454
1296
  const getActiveEditorId = () => {
1455
- return invoke$3('GetActiveEditor.getActiveEditorId');
1297
+ return invoke$4('GetActiveEditor.getActiveEditorId');
1456
1298
  };
1457
1299
  const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1458
1300
  const command = 'Extensions.handleMessagePort';
1459
1301
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1460
1302
  };
1461
1303
  const showErrorDialog$1 = async errorInfo => {
1462
- await invoke$3('ErrorHandling.showErrorDialog', errorInfo);
1304
+ await invoke$4('ErrorHandling.showErrorDialog', errorInfo);
1463
1305
  };
1464
1306
 
1465
1307
  const closeWidget = async id => {
@@ -1467,11 +1309,11 @@ const closeWidget = async id => {
1467
1309
  await closeWidget$1(id);
1468
1310
  };
1469
1311
 
1470
- const state$4 = {
1312
+ const state$5 = {
1471
1313
  value: 0
1472
1314
  };
1473
1315
  const create$3 = () => {
1474
- return ++state$4.value;
1316
+ return ++state$5.value;
1475
1317
  };
1476
1318
 
1477
1319
  const callbacks$1 = Object.create(null);
@@ -1537,7 +1379,7 @@ const close = async state => {
1537
1379
  }
1538
1380
  executeCallback(resolveId, result);
1539
1381
  } else {
1540
- await invoke$3('QuickPick.executeCallback', resolveId, result);
1382
+ await invoke$4('QuickPick.executeCallback', resolveId, result);
1541
1383
  }
1542
1384
  }
1543
1385
  }
@@ -1814,10 +1656,10 @@ const create$2 = () => {
1814
1656
 
1815
1657
  const {
1816
1658
  dispose: dispose$1,
1817
- get: get$1,
1659
+ get: get$2,
1818
1660
  getCommandIds,
1819
1661
  registerCommands,
1820
- set: set$2,
1662
+ set: set$4,
1821
1663
  wrapAsyncCommand,
1822
1664
  wrapCommand
1823
1665
  } = create$2();
@@ -2114,7 +1956,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, _
2114
1956
  platform,
2115
1957
  value: ''
2116
1958
  };
2117
- set$2(uid, state, state);
1959
+ set$4(uid, state, state);
2118
1960
  };
2119
1961
 
2120
1962
  const isEqual$4 = (oldState, newState) => {
@@ -2165,7 +2007,7 @@ const diff2 = uid => {
2165
2007
  const {
2166
2008
  newState,
2167
2009
  oldState
2168
- } = get$1(uid);
2010
+ } = get$2(uid);
2169
2011
  return diff(oldState, newState);
2170
2012
  };
2171
2013
 
@@ -2174,7 +2016,7 @@ const dispose = uid => {
2174
2016
  };
2175
2017
 
2176
2018
  const setColorTheme = id => {
2177
- return invoke$3(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
2019
+ return invoke$4(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
2178
2020
  };
2179
2021
 
2180
2022
  const focusPick$1 = async pick => {
@@ -2790,7 +2632,7 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
2790
2632
  };
2791
2633
 
2792
2634
  const getColorThemeNames = async (assetDir, platform) => {
2793
- return invoke$3('ColorTheme.getColorThemeNames', assetDir, platform);
2635
+ return invoke$4('ColorTheme.getColorThemeNames', assetDir, platform);
2794
2636
  };
2795
2637
 
2796
2638
  const toProtoVisibleItem$4 = name => {
@@ -2868,21 +2710,21 @@ const warn = (...args) => {
2868
2710
  console.warn(...args);
2869
2711
  };
2870
2712
 
2871
- const state$3 = {
2713
+ const state$4 = {
2872
2714
  menuEntries: []
2873
2715
  };
2874
2716
  const getAll = async () => {
2875
2717
  try {
2876
2718
  // @ts-ignore
2877
- const entries = await invoke$3('Layout.getAllQuickPickMenuEntries');
2719
+ const entries = await invoke$4('Layout.getAllQuickPickMenuEntries');
2878
2720
  return entries || [];
2879
2721
  } catch {
2880
2722
  // ignore
2881
2723
  }
2882
- return state$3.menuEntries;
2724
+ return state$4.menuEntries;
2883
2725
  };
2884
2726
  const add$1 = menuEntries => {
2885
- state$3.menuEntries = [...state$3.menuEntries, ...menuEntries];
2727
+ state$4.menuEntries = [...state$4.menuEntries, ...menuEntries];
2886
2728
  };
2887
2729
 
2888
2730
  const changeLanguageModePick = {
@@ -2909,7 +2751,7 @@ const getExtensionPicks = async (assetDir, platform, applicationId) => {
2909
2751
  // Assert.number(platform)
2910
2752
  // TODO ask extension management worker directly
2911
2753
  // TODO don't call this every time, cache the results
2912
- const extensionPicks = applicationId === undefined ? await invoke$3('ExtensionHost.getCommands', assetDir, platform) : await invoke$3('Application.execute', applicationId, 'ExtensionHost.getCommands', assetDir, platform);
2754
+ const extensionPicks = applicationId === undefined ? await invoke$4('ExtensionHost.getCommands', assetDir, platform) : await invoke$4('Application.execute', applicationId, 'ExtensionHost.getCommands', assetDir, platform);
2913
2755
  if (!extensionPicks) {
2914
2756
  return [];
2915
2757
  }
@@ -2954,7 +2796,7 @@ const getPicks$e = async (value, args, {
2954
2796
  return converted;
2955
2797
  };
2956
2798
 
2957
- const state$2 = {
2799
+ const state$3 = {
2958
2800
  args: [],
2959
2801
  items: Object.create(null)
2960
2802
  };
@@ -2964,24 +2806,24 @@ const idState = {
2964
2806
  };
2965
2807
  const add = items => {
2966
2808
  const nextId = ++idState.value;
2967
- state$2.items[nextId] = items;
2809
+ state$3.items[nextId] = items;
2968
2810
  return nextId;
2969
2811
  };
2970
- const get = id => {
2971
- return state$2.items[id] || [];
2812
+ const get$1 = id => {
2813
+ return state$3.items[id] || [];
2972
2814
  };
2973
2815
  const remove = id => {
2974
- delete state$2.items[id];
2816
+ delete state$3.items[id];
2975
2817
  };
2976
2818
 
2977
- const state$1 = {
2819
+ const state$2 = {
2978
2820
  rpc: undefined
2979
2821
  };
2980
- const set$1 = newRpc => {
2981
- state$1.rpc = newRpc;
2822
+ const set$3 = newRpc => {
2823
+ state$2.rpc = newRpc;
2982
2824
  };
2983
- const invoke$2 = (method, ...args) => {
2984
- return state$1.rpc.invoke(method, ...args);
2825
+ const invoke$3 = (method, ...args) => {
2826
+ return state$2.rpc.invoke(method, ...args);
2985
2827
  };
2986
2828
 
2987
2829
  const isTextInput = args => {
@@ -3012,16 +2854,16 @@ const toProtoVisibleItem$2 = item => {
3012
2854
  };
3013
2855
  };
3014
2856
  const getPicks$d = async (searchValue, args) => {
3015
- state$2.args = args;
2857
+ state$3.args = args;
3016
2858
  if (isTextInput(args)) {
3017
2859
  return [];
3018
2860
  }
3019
2861
  const options = args.at(-1);
3020
2862
  let items;
3021
2863
  if (options?.mode === 'quickInput') {
3022
- items = searchValue === '' && options?.customItemsId ? get(options.customItemsId) : await invoke$2('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue);
2864
+ items = searchValue === '' && options?.customItemsId ? get$1(options.customItemsId) : await invoke$3('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue);
3023
2865
  } else {
3024
- items = options?.customItemsId ? get(options.customItemsId) : args[1] || [];
2866
+ items = options?.customItemsId ? get$1(options.customItemsId) : args[1] || [];
3025
2867
  }
3026
2868
  const mapped = items.map(toProtoVisibleItem$2);
3027
2869
  return mapped;
@@ -3044,11 +2886,64 @@ const getPicks$c = async () => {
3044
2886
  const emptyMatches = [];
3045
2887
 
3046
2888
  const getWorkspacePath = async () => {
3047
- return invoke$3('Workspace.getPath');
2889
+ return invoke$4('Workspace.getPath');
2890
+ };
2891
+
2892
+ const state$1 = {};
2893
+ const set$2 = value => {
2894
+ state$1.rpc = value;
2895
+ };
2896
+ const invoke$2 = (method, ...args) => {
2897
+ if (!state$1.rpc) {
2898
+ throw new Error('Cache worker is not initialized');
2899
+ }
2900
+ return state$1.rpc.invoke(method, ...args);
3048
2901
  };
3049
2902
 
3050
- const searchFile$1 = async (path, value, prepare, assetDir) => {
3051
- const result = await invoke$5('FileSearch.searchFile', path, value, prepare, assetDir);
2903
+ const cacheName = 'quick-pick-files-v1';
2904
+ const cacheUrl = workspace => {
2905
+ const url = new URL('https://quick-pick-cache.invalid/cache/v1');
2906
+ url.searchParams.set('folder', workspace);
2907
+ return url.href;
2908
+ };
2909
+ const isEntry = value => {
2910
+ if (!value || typeof value !== 'object') {
2911
+ return false;
2912
+ }
2913
+ const entry = value;
2914
+ return typeof entry.hash === 'string' && /^[\da-f]{64}$/.test(entry.hash) && Array.isArray(entry.results) && entry.results.every(result => typeof result === 'string');
2915
+ };
2916
+ const get = async workspace => {
2917
+ try {
2918
+ const cached = await invoke$2('Cache.getCacheStorageItem', cacheUrl(workspace), cacheName);
2919
+ if (!cached) {
2920
+ return undefined;
2921
+ }
2922
+ const expires = Date.parse(cached.headers.expires || '');
2923
+ if (!Number.isFinite(expires) || expires <= Date.now()) {
2924
+ return undefined;
2925
+ }
2926
+ const entry = JSON.parse(new TextDecoder().decode(cached.body));
2927
+ return isEntry(entry) ? entry : undefined;
2928
+ } catch {
2929
+ return undefined;
2930
+ }
2931
+ };
2932
+ const set$1 = async (workspace, entry) => {
2933
+ const expires = new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toUTCString();
2934
+ const headers = {
2935
+ 'cache-control': 'private, max-age=7776000',
2936
+ expires
2937
+ };
2938
+ try {
2939
+ await invoke$2('Cache.setCacheStorageItem', cacheUrl(workspace), JSON.stringify(entry), cacheName, headers);
2940
+ } catch {
2941
+ // Caching is optional; a storage failure must not break file search.
2942
+ }
2943
+ };
2944
+
2945
+ const searchFile = async (path, value, prepare, assetDir, ifNonMatch) => {
2946
+ const result = ifNonMatch === undefined ? await invoke$6('FileSearch.searchFile', path, value, prepare, assetDir) : await invoke$6('FileSearch.searchFile', path, value, prepare, assetDir, ifNonMatch);
3052
2947
  return result;
3053
2948
  };
3054
2949
 
@@ -3067,11 +2962,7 @@ const pathDirName = path => {
3067
2962
  return path.slice(0, index);
3068
2963
  };
3069
2964
 
3070
- const searchFile = async (path, value) => {
3071
- const prepare = true;
3072
- const files = await searchFile$1(/* path */path, /* searchTerm */value, prepare, '');
3073
- return files;
3074
- };
2965
+ const isFileList = value => Array.isArray(value);
3075
2966
  const hasUriScheme = path => /^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path);
3076
2967
  const isAbsolutePath = path => path.startsWith('/') || /^[a-z]:[\\/]/i.test(path);
3077
2968
  const trimTrailingSeparators = path => {
@@ -3122,7 +3013,28 @@ const getPicks$b = async searchValue => {
3122
3013
  if (!workspace) {
3123
3014
  return [];
3124
3015
  }
3125
- const files = await searchFile(workspace, searchValue);
3016
+ let cacheEnabled = false;
3017
+ try {
3018
+ cacheEnabled = (await invoke$4('Preferences.get', 'quickPick.cache')) !== false;
3019
+ } catch {
3020
+ // If preferences are unavailable, preserve the existing uncached search behavior.
3021
+ }
3022
+ const cached = cacheEnabled ? await get(workspace) : undefined;
3023
+ const response = await searchFile(workspace, searchValue, true, '', cacheEnabled ? cached?.hash ?? null : undefined);
3024
+ let files;
3025
+ if (isFileList(response)) {
3026
+ files = response;
3027
+ } else if (response.matchesCache && cached) {
3028
+ files = cached.results;
3029
+ } else {
3030
+ files = response.results;
3031
+ if (cacheEnabled && !isFileList(response)) {
3032
+ await set$1(workspace, {
3033
+ hash: response.hash,
3034
+ results: files
3035
+ });
3036
+ }
3037
+ }
3126
3038
  const picks = files.map(path => convertToPick(resolveFileUri(workspace, path)));
3127
3039
  return picks;
3128
3040
  };
@@ -3468,7 +3380,7 @@ const uniq = array => {
3468
3380
  });
3469
3381
  };
3470
3382
  const getRecentlyOpened = async () => {
3471
- const recentlyOpened = await invoke$3(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
3383
+ const recentlyOpened = await invoke$4(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
3472
3384
  return uniq(recentlyOpened);
3473
3385
  };
3474
3386
 
@@ -3544,7 +3456,7 @@ const getPicks$6 = async () => {
3544
3456
  const recentlyOpened = await getRecentlyOpened();
3545
3457
  let homeDir;
3546
3458
  try {
3547
- homeDir = await invoke$3('Workspace.getHomeDir');
3459
+ homeDir = await invoke$4('Workspace.getHomeDir');
3548
3460
  } catch {
3549
3461
  // Ignore unavailable workspace RPCs and keep the full path.
3550
3462
  }
@@ -3603,7 +3515,7 @@ const selectPickBuiltin = async item => {
3603
3515
  }
3604
3516
  const args = item.args || [];
3605
3517
  // TODO ids should be all numbers for efficiency -> also directly can call command
3606
- await invoke$3(item.id, ...args);
3518
+ await invoke$4(item.id, ...args);
3607
3519
  if (shouldHide(item)) {
3608
3520
  return {
3609
3521
  command: Hide
@@ -3617,9 +3529,9 @@ const selectPickExtension = async (item, applicationId) => {
3617
3529
  const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
3618
3530
  try {
3619
3531
  if (applicationId === undefined) {
3620
- await invoke$3('ExtensionHost.executeCommand', id);
3532
+ await invoke$4('ExtensionHost.executeCommand', id);
3621
3533
  } else {
3622
- await invoke$3('Application.execute', applicationId, 'ExtensionHost.executeCommand', id);
3534
+ await invoke$4('Application.execute', applicationId, 'ExtensionHost.executeCommand', id);
3623
3535
  }
3624
3536
  } catch (error) {
3625
3537
  await handleError(error, false);
@@ -3653,7 +3565,7 @@ const getOptions = args => {
3653
3565
  const selectPick$a = async (_pick, value) => {
3654
3566
  const {
3655
3567
  args
3656
- } = state$2;
3568
+ } = state$3;
3657
3569
  const options = getOptions(args);
3658
3570
  if (options.executeItemCommand && _pick.command) {
3659
3571
  return {
@@ -3678,7 +3590,7 @@ const selectPick$a = async (_pick, value) => {
3678
3590
  }
3679
3591
  executeCallback(resolveId, result);
3680
3592
  } else {
3681
- await invoke$3('QuickPick.executeCallback', resolveId, result);
3593
+ await invoke$4('QuickPick.executeCallback', resolveId, result);
3682
3594
  }
3683
3595
  return {
3684
3596
  command: Hide
@@ -3687,14 +3599,14 @@ const selectPick$a = async (_pick, value) => {
3687
3599
 
3688
3600
  const selectPick$9 = async pick => {
3689
3601
  const editorId = await getActiveEditorId();
3690
- await invoke$3('Viewlet.executeViewletCommand', editorId, 'setEndOfLine', pick.value);
3602
+ await invoke$4('Viewlet.executeViewletCommand', editorId, 'setEndOfLine', pick.value);
3691
3603
  return {
3692
3604
  command: Hide
3693
3605
  };
3694
3606
  };
3695
3607
 
3696
3608
  const openUri = async uri => {
3697
- await invoke$3('Main.openUri', uri);
3609
+ await invoke$4('Main.openUri', uri);
3698
3610
  };
3699
3611
 
3700
3612
  const toFileUri = path => {
@@ -3714,12 +3626,12 @@ const selectPick$8 = async pick => {
3714
3626
  };
3715
3627
 
3716
3628
  const setCursor = async (rowIndex, columnIndex) => {
3717
- await invoke$3('Editor.cursorSet', rowIndex, columnIndex);
3629
+ await invoke$4('Editor.cursorSet', rowIndex, columnIndex);
3718
3630
  };
3719
3631
 
3720
3632
  const goToPositionAndFocus = async (rowIndex, columnIndex) => {
3721
3633
  await setCursor(rowIndex, columnIndex);
3722
- await invoke$3('Editor.handleFocus');
3634
+ await invoke$4('Editor.handleFocus');
3723
3635
  };
3724
3636
 
3725
3637
  const selectPickGoToColumn = async (item, value) => {
@@ -3762,7 +3674,7 @@ const selectPick$6 = async item => {
3762
3674
 
3763
3675
  const selectPick$5 = async pick => {
3764
3676
  const editorId = await getActiveEditorId();
3765
- await invoke$3('Viewlet.executeViewletCommand', editorId, 'setIndentation', pick.value);
3677
+ await invoke$4('Viewlet.executeViewletCommand', editorId, 'setIndentation', pick.value);
3766
3678
  return {
3767
3679
  command: Hide
3768
3680
  };
@@ -3771,7 +3683,7 @@ const selectPick$5 = async pick => {
3771
3683
  const selectPick$4 = async pick => {
3772
3684
  const editorId = await getActiveEditorId();
3773
3685
  const value = pick.value;
3774
- await invoke$3('Viewlet.executeViewletCommand', editorId, 'setLanguageId', value.languageId, value.tokenizePath, true);
3686
+ await invoke$4('Viewlet.executeViewletCommand', editorId, 'setLanguageId', value.languageId, value.tokenizePath, true);
3775
3687
  return {
3776
3688
  command: Hide
3777
3689
  };
@@ -3779,7 +3691,7 @@ const selectPick$4 = async pick => {
3779
3691
 
3780
3692
  const openWorkspaceFolder = uri => {
3781
3693
  const command = uri.includes('://') ? 'Workspace.setUri' : 'Workspace.setPath';
3782
- return invoke$3(command, uri);
3694
+ return invoke$4(command, uri);
3783
3695
  };
3784
3696
 
3785
3697
  // TODO selectPick should be independent of show/hide
@@ -4034,7 +3946,7 @@ const handleBlur = async state => {
4034
3946
  const options = args.at(-1);
4035
3947
  if (!options?.executeItemCommand) {
4036
3948
  const resolveId = args[2];
4037
- await invoke$3('QuickPick.executeCallback', resolveId, getCancelResult(args));
3949
+ await invoke$4('QuickPick.executeCallback', resolveId, getCancelResult(args));
4038
3950
  }
4039
3951
  }
4040
3952
  await closeWidget(state.uid);
@@ -4174,7 +4086,7 @@ const getLoadedState = async state => {
4174
4086
  let colorTheme = '';
4175
4087
  if (subId === ColorTheme$1) {
4176
4088
  try {
4177
- colorTheme = await invoke$3('ColorTheme.getColorTheme');
4089
+ colorTheme = await invoke$4('ColorTheme.getColorTheme');
4178
4090
  } catch {
4179
4091
  // The worker can be released before the renderer endpoint.
4180
4092
  }
@@ -4322,7 +4234,7 @@ const selectIndex = async (state, index, button = /* left */0) => {
4322
4234
  await closeWidget(state.uid);
4323
4235
  }
4324
4236
  if (selectPickResult.itemCommand) {
4325
- await invoke$3(selectPickResult.itemCommand, ...(selectPickResult.itemCommandArgs || []));
4237
+ await invoke$4(selectPickResult.itemCommand, ...(selectPickResult.itemCommandArgs || []));
4326
4238
  }
4327
4239
  return state;
4328
4240
  case OpenColorTheme:
@@ -4359,7 +4271,7 @@ const handleClickAt = async (state, x, y, uri) => {
4359
4271
  if (state.providerId !== Recent$1 || state.items.every(item => item.uri !== uri)) {
4360
4272
  return state;
4361
4273
  }
4362
- await invoke$3('RecentlyOpened.removeRecentlyOpened', uri);
4274
+ await invoke$4('RecentlyOpened.removeRecentlyOpened', uri);
4363
4275
  const next = await loadContent({
4364
4276
  ...state,
4365
4277
  value: ''
@@ -4390,7 +4302,7 @@ const handleMessagePort = async port => {
4390
4302
  isMessagePortOpen: true,
4391
4303
  messagePort: port
4392
4304
  });
4393
- set$1(rpc);
4305
+ set$3(rpc);
4394
4306
  };
4395
4307
 
4396
4308
  const state = {
@@ -4403,10 +4315,10 @@ const isConnected = () => {
4403
4315
  return connected;
4404
4316
  };
4405
4317
  const invoke$1 = (method, ...params) => {
4406
- return invoke$4(method, ...params);
4318
+ return invoke$5(method, ...params);
4407
4319
  };
4408
4320
  const set = rpc => {
4409
- set$4(rpc);
4321
+ set$6(rpc);
4410
4322
  state.connected = true;
4411
4323
  };
4412
4324
 
@@ -4417,7 +4329,7 @@ const handleRendererProcessMessagePort = async (port, viewletCommandMap, setAsRe
4417
4329
  throw new TypeError(`Viewlet command not found: ${command}`);
4418
4330
  }
4419
4331
  await fn(uid, ...args);
4420
- await invoke$3('Viewlet.requestRender', uid);
4332
+ await invoke$4('Viewlet.requestRender', uid);
4421
4333
  };
4422
4334
  const rpc = await create$8({
4423
4335
  commandMap: {
@@ -4443,7 +4355,7 @@ const initialize = async () => {
4443
4355
  };
4444
4356
 
4445
4357
  const invoke = async (applicationId, method, ...args) => {
4446
- return applicationId === undefined ? invoke$3(method, ...args) : invoke$3('Application.execute', applicationId, method, ...args);
4358
+ return applicationId === undefined ? invoke$4(method, ...args) : invoke$4('Application.execute', applicationId, method, ...args);
4447
4359
  };
4448
4360
 
4449
4361
  const QuickPick$2 = 'QuickPick';
@@ -4536,8 +4448,6 @@ const text = data => {
4536
4448
  };
4537
4449
  };
4538
4450
 
4539
- new Set(Object.values(VirtualDomElements));
4540
-
4541
4451
  const SetText = 1;
4542
4452
  const Replace = 2;
4543
4453
  const SetAttribute = 3;
@@ -4548,6 +4458,7 @@ const NavigateParent = 8;
4548
4458
  const RemoveChild = 9;
4549
4459
  const NavigateSibling = 10;
4550
4460
  const SetReferenceNodeUid = 11;
4461
+ const MultiNavigation = 18;
4551
4462
 
4552
4463
  const isKey = key => {
4553
4464
  return key !== 'type' && key !== 'childCount';
@@ -4608,6 +4519,55 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
4608
4519
  };
4609
4520
  };
4610
4521
 
4522
+ const isNavigationPatch = patch => {
4523
+ switch (patch.type) {
4524
+ case NavigateChild:
4525
+ case NavigateParent:
4526
+ case NavigateSibling:
4527
+ return true;
4528
+ default:
4529
+ return false;
4530
+ }
4531
+ };
4532
+ const getNavigationIndex = patch => {
4533
+ switch (patch.type) {
4534
+ case NavigateChild:
4535
+ case NavigateSibling:
4536
+ return patch.index;
4537
+ default:
4538
+ return 0;
4539
+ }
4540
+ };
4541
+ const appendNavigationPatch = (patches, type, index) => {
4542
+ const previousPatch = patches.at(-1);
4543
+ if (!previousPatch) {
4544
+ patches.push(type === NavigateParent ? {
4545
+ type
4546
+ } : {
4547
+ index,
4548
+ type
4549
+ });
4550
+ return;
4551
+ }
4552
+ if (previousPatch.type === MultiNavigation) {
4553
+ previousPatch.navigations.push(type, index);
4554
+ return;
4555
+ }
4556
+ if (isNavigationPatch(previousPatch)) {
4557
+ patches[patches.length - 1] = {
4558
+ navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
4559
+ type: MultiNavigation
4560
+ };
4561
+ return;
4562
+ }
4563
+ patches.push(type === NavigateParent ? {
4564
+ type
4565
+ } : {
4566
+ index,
4567
+ type
4568
+ });
4569
+ };
4570
+
4611
4571
  const compareNodes = (oldNode, newNode) => {
4612
4572
  // Check if node type changed - return null to signal incompatible nodes
4613
4573
  // (caller should handle this with a Replace operation)
@@ -4672,25 +4632,17 @@ const treeToArray = node => {
4672
4632
 
4673
4633
  const navigateToChild = (patches, currentChildIndex, index) => {
4674
4634
  if (currentChildIndex === -1) {
4675
- patches.push({
4676
- type: NavigateChild,
4677
- index
4678
- });
4635
+ appendNavigationPatch(patches, NavigateChild, index);
4679
4636
  return index;
4680
4637
  }
4681
4638
  if (currentChildIndex !== index) {
4682
- patches.push({
4683
- type: NavigateSibling,
4684
- index
4685
- });
4639
+ appendNavigationPatch(patches, NavigateSibling, index);
4686
4640
  }
4687
4641
  return index;
4688
4642
  };
4689
4643
  const navigateToParent = (patches, currentChildIndex) => {
4690
4644
  if (currentChildIndex >= 0) {
4691
- patches.push({
4692
- type: NavigateParent
4693
- });
4645
+ appendNavigationPatch(patches, NavigateParent, 0);
4694
4646
  }
4695
4647
  return -1;
4696
4648
  };
@@ -4706,6 +4658,29 @@ const replaceTree = (newNode, patches) => {
4706
4658
  nodes: treeToArray(newNode)
4707
4659
  });
4708
4660
  };
4661
+ const appendPatch = (patches, patch) => {
4662
+ switch (patch.type) {
4663
+ case MultiNavigation:
4664
+ for (let i = 0; i < patch.navigations.length; i += 2) {
4665
+ appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
4666
+ }
4667
+ return;
4668
+ case NavigateChild:
4669
+ case NavigateSibling:
4670
+ appendNavigationPatch(patches, patch.type, patch.index);
4671
+ return;
4672
+ case NavigateParent:
4673
+ appendNavigationPatch(patches, patch.type, 0);
4674
+ return;
4675
+ default:
4676
+ patches.push(patch);
4677
+ }
4678
+ };
4679
+ const appendPatches = (patches, newPatches) => {
4680
+ for (const patch of newPatches) {
4681
+ appendPatch(patches, patch);
4682
+ }
4683
+ };
4709
4684
  const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
4710
4685
  const nodePatches = compareNodes(oldNode.node, newNode.node);
4711
4686
  if (nodePatches === null) {
@@ -4714,16 +4689,16 @@ const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index)
4714
4689
  return nextChildIndex;
4715
4690
  }
4716
4691
  const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
4717
- if (nodePatches.length === 0 && !hasChildrenToCompare) {
4692
+ const childPatches = [];
4693
+ if (hasChildrenToCompare) {
4694
+ diffChildren(oldNode.children, newNode.children, childPatches);
4695
+ }
4696
+ if (nodePatches.length === 0 && childPatches.length === 0) {
4718
4697
  return currentChildIndex;
4719
4698
  }
4720
4699
  const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
4721
- if (nodePatches.length > 0) {
4722
- patches.push(...nodePatches);
4723
- }
4724
- if (hasChildrenToCompare) {
4725
- diffChildren(oldNode.children, newNode.children, patches);
4726
- }
4700
+ patches.push(...nodePatches);
4701
+ appendPatches(patches, childPatches);
4727
4702
  return nextChildIndex;
4728
4703
  };
4729
4704
  const diffRootNode = (oldNode, newNode, patches) => {
@@ -4779,7 +4754,7 @@ const diffTrees = (oldTree, newTree, patches, path) => {
4779
4754
  const removeTrailingNavigationPatches = patches => {
4780
4755
  while (patches.length > 0) {
4781
4756
  const patch = patches.at(-1);
4782
- if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
4757
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
4783
4758
  break;
4784
4759
  }
4785
4760
  patches.pop();
@@ -5284,11 +5259,11 @@ const render2 = (uid, diffResult) => {
5284
5259
  const {
5285
5260
  newState,
5286
5261
  oldState
5287
- } = get$1(uid);
5262
+ } = get$2(uid);
5288
5263
  if (oldState === newState) {
5289
5264
  return [];
5290
5265
  }
5291
- set$2(uid, newState, newState);
5266
+ set$4(uid, newState, newState);
5292
5267
  const commands = applyRender(oldState, newState, diffResult);
5293
5268
  if (!isConnected()) {
5294
5269
  return commands;
@@ -5485,6 +5460,16 @@ const commandMap = {
5485
5460
  'QuickPick.waitUntilVisible': waitUntilVisible
5486
5461
  };
5487
5462
 
5463
+ const initializeCacheWorker = async () => {
5464
+ const rpc = await create$6({
5465
+ commandMap: {},
5466
+ async send(port) {
5467
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToCacheWorker', port);
5468
+ }
5469
+ });
5470
+ set$2(rpc);
5471
+ };
5472
+
5488
5473
  const initializeEditorWorker = async () => {
5489
5474
  const rpc = await create$6({
5490
5475
  commandMap: {},
@@ -5492,7 +5477,7 @@ const initializeEditorWorker = async () => {
5492
5477
  await sendMessagePortToEditorWorker(port, 0);
5493
5478
  }
5494
5479
  });
5495
- set$7(rpc);
5480
+ set$9(rpc);
5496
5481
  };
5497
5482
 
5498
5483
  const initializeExtensionManagementWorker = async () => {
@@ -5502,7 +5487,7 @@ const initializeExtensionManagementWorker = async () => {
5502
5487
  await sendMessagePortToExtensionManagementWorker(port, 0);
5503
5488
  }
5504
5489
  });
5505
- set$6(rpc);
5490
+ set$8(rpc);
5506
5491
  };
5507
5492
 
5508
5493
  const initializeFileSearchWorker = async () => {
@@ -5512,20 +5497,20 @@ const initializeFileSearchWorker = async () => {
5512
5497
  await sendMessagePortToFileSearchWorker2(port, 0);
5513
5498
  }
5514
5499
  });
5515
- set$5(rpc);
5500
+ set$7(rpc);
5516
5501
  };
5517
5502
 
5518
5503
  const initializeRendererWorker = async () => {
5519
5504
  const rpc = await create$5({
5520
5505
  commandMap: commandMap
5521
5506
  });
5522
- set$3(rpc);
5507
+ set$5(rpc);
5523
5508
  };
5524
5509
 
5525
5510
  const listen = async () => {
5526
5511
  Object.assign(commandMapRef, commandMap);
5527
5512
  registerCommands(commandMap);
5528
- await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeExtensionManagementWorker(), initializeFileSearchWorker()]);
5513
+ await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeExtensionManagementWorker(), initializeFileSearchWorker(), initializeCacheWorker()]);
5529
5514
  };
5530
5515
 
5531
5516
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.25.0",
3
+ "version": "4.26.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"