@lvce-editor/quick-pick-worker 3.3.0 → 4.0.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.
@@ -546,12 +546,12 @@ const execute = (command, ...args) => {
546
546
  };
547
547
 
548
548
  const Two$1 = '2.0';
549
- const callbacks$1 = Object.create(null);
550
- const get$2 = id => {
551
- return callbacks$1[id];
549
+ const callbacks$2 = Object.create(null);
550
+ const get$3 = id => {
551
+ return callbacks$2[id];
552
552
  };
553
- const remove$1 = id => {
554
- delete callbacks$1[id];
553
+ const remove$2 = id => {
554
+ delete callbacks$2[id];
555
555
  };
556
556
  class JsonRpcError extends Error {
557
557
  constructor(message) {
@@ -696,14 +696,14 @@ const warn$1 = (...args) => {
696
696
  console.warn(...args);
697
697
  };
698
698
  const resolve = (id, response) => {
699
- const fn = get$2(id);
699
+ const fn = get$3(id);
700
700
  if (!fn) {
701
701
  console.log(response);
702
702
  warn$1(`callback ${id} may already be disposed`);
703
703
  return;
704
704
  }
705
705
  fn(response);
706
- remove$1(id);
706
+ remove$2(id);
707
707
  };
708
708
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
709
709
  const getErrorType = prettyError => {
@@ -759,7 +759,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
759
759
  const errorProperty = getErrorProperty(error, prettyError);
760
760
  return create$1$1(id, errorProperty);
761
761
  };
762
- const create$b = (message, result) => {
762
+ const create$c = (message, result) => {
763
763
  return {
764
764
  id: message.id,
765
765
  jsonrpc: Two$1,
@@ -768,7 +768,7 @@ const create$b = (message, result) => {
768
768
  };
769
769
  const getSuccessResponse = (message, result) => {
770
770
  const resultProperty = result ?? null;
771
- return create$b(message, resultProperty);
771
+ return create$c(message, resultProperty);
772
772
  };
773
773
  const getErrorResponseSimple = (id, error) => {
774
774
  return {
@@ -862,7 +862,7 @@ const handleJsonRpcMessage = async (...args) => {
862
862
 
863
863
  const Two = '2.0';
864
864
 
865
- const create$a = (method, params) => {
865
+ const create$b = (method, params) => {
866
866
  return {
867
867
  jsonrpc: Two,
868
868
  method,
@@ -870,7 +870,7 @@ const create$a = (method, params) => {
870
870
  };
871
871
  };
872
872
 
873
- const create$9 = (id, method, params) => {
873
+ const create$a = (id, method, params) => {
874
874
  const message = {
875
875
  id,
876
876
  jsonrpc: Two,
@@ -880,13 +880,13 @@ const create$9 = (id, method, params) => {
880
880
  return message;
881
881
  };
882
882
 
883
- let id = 0;
884
- const create$8 = () => {
885
- return ++id;
883
+ let id$2 = 0;
884
+ const create$9 = () => {
885
+ return ++id$2;
886
886
  };
887
887
 
888
888
  const registerPromise = map => {
889
- const id = create$8();
889
+ const id = create$9();
890
890
  const {
891
891
  promise,
892
892
  resolve
@@ -903,7 +903,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
903
903
  id,
904
904
  promise
905
905
  } = registerPromise(callbacks);
906
- const message = create$9(id, method, params);
906
+ const message = create$a(id, method, params);
907
907
  if (useSendAndTransfer && ipc.sendAndTransfer) {
908
908
  ipc.sendAndTransfer(message);
909
909
  } else {
@@ -939,7 +939,7 @@ const createRpc = ipc => {
939
939
  * @deprecated
940
940
  */
941
941
  send(method, ...params) {
942
- const message = create$a(method, params);
942
+ const message = create$b(method, params);
943
943
  ipc.send(message);
944
944
  }
945
945
  };
@@ -979,7 +979,7 @@ const listen$1 = async (module, options) => {
979
979
  return ipc;
980
980
  };
981
981
 
982
- const create$7 = async ({
982
+ const create$8 = async ({
983
983
  commandMap,
984
984
  isMessagePortOpen = true,
985
985
  messagePort
@@ -997,7 +997,7 @@ const create$7 = async ({
997
997
  return rpc;
998
998
  };
999
999
 
1000
- const create$6 = async ({
1000
+ const create$7 = async ({
1001
1001
  commandMap,
1002
1002
  isMessagePortOpen,
1003
1003
  send
@@ -1007,7 +1007,7 @@ const create$6 = async ({
1007
1007
  port2
1008
1008
  } = new MessageChannel();
1009
1009
  await send(port1);
1010
- return create$7({
1010
+ return create$8({
1011
1011
  commandMap,
1012
1012
  isMessagePortOpen,
1013
1013
  messagePort: port2
@@ -1042,13 +1042,13 @@ const createSharedLazyRpc = factory => {
1042
1042
  };
1043
1043
  };
1044
1044
 
1045
- const create$5 = async ({
1045
+ const create$6 = async ({
1046
1046
  commandMap,
1047
1047
  isMessagePortOpen,
1048
1048
  send
1049
1049
  }) => {
1050
1050
  return createSharedLazyRpc(() => {
1051
- return create$6({
1051
+ return create$7({
1052
1052
  commandMap,
1053
1053
  isMessagePortOpen,
1054
1054
  send
@@ -1056,7 +1056,7 @@ const create$5 = async ({
1056
1056
  });
1057
1057
  };
1058
1058
 
1059
- const create$4 = async ({
1059
+ const create$5 = async ({
1060
1060
  commandMap
1061
1061
  }) => {
1062
1062
  // TODO create a commandMap per rpc instance
@@ -1088,32 +1088,32 @@ const createMockRpc = ({
1088
1088
  };
1089
1089
 
1090
1090
  const rpcs = Object.create(null);
1091
- const set$4 = (id, rpc) => {
1091
+ const set$5 = (id, rpc) => {
1092
1092
  rpcs[id] = rpc;
1093
1093
  };
1094
- const get$1 = id => {
1094
+ const get$2 = id => {
1095
1095
  return rpcs[id];
1096
1096
  };
1097
- const remove = id => {
1097
+ const remove$1 = id => {
1098
1098
  delete rpcs[id];
1099
1099
  };
1100
1100
 
1101
1101
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
1102
- const create$3 = rpcId => {
1102
+ const create$4 = rpcId => {
1103
1103
  return {
1104
1104
  async dispose() {
1105
- const rpc = get$1(rpcId);
1105
+ const rpc = get$2(rpcId);
1106
1106
  await rpc.dispose();
1107
1107
  },
1108
1108
  // @ts-ignore
1109
1109
  invoke(method, ...params) {
1110
- const rpc = get$1(rpcId);
1110
+ const rpc = get$2(rpcId);
1111
1111
  // @ts-ignore
1112
1112
  return rpc.invoke(method, ...params);
1113
1113
  },
1114
1114
  // @ts-ignore
1115
1115
  invokeAndTransfer(method, ...params) {
1116
- const rpc = get$1(rpcId);
1116
+ const rpc = get$2(rpcId);
1117
1117
  // @ts-ignore
1118
1118
  return rpc.invokeAndTransfer(method, ...params);
1119
1119
  },
@@ -1121,16 +1121,16 @@ const create$3 = rpcId => {
1121
1121
  const mockRpc = createMockRpc({
1122
1122
  commandMap
1123
1123
  });
1124
- set$4(rpcId, mockRpc);
1124
+ set$5(rpcId, mockRpc);
1125
1125
  // @ts-ignore
1126
1126
  mockRpc[Symbol.dispose] = () => {
1127
- remove(rpcId);
1127
+ remove$1(rpcId);
1128
1128
  };
1129
1129
  // @ts-ignore
1130
1130
  return mockRpc;
1131
1131
  },
1132
1132
  set(rpc) {
1133
- set$4(rpcId, rpc);
1133
+ set$5(rpcId, rpc);
1134
1134
  }
1135
1135
  };
1136
1136
  };
@@ -1151,52 +1151,52 @@ const SetPatches = 'Viewlet.setPatches';
1151
1151
  const FocusQuickPickInput = 20;
1152
1152
 
1153
1153
  const {
1154
- invoke: invoke$2,
1155
- set: set$3
1156
- } = create$3(EditorWorker);
1154
+ invoke: invoke$3,
1155
+ set: set$4
1156
+ } = create$4(EditorWorker);
1157
1157
  const getLines = async editorUid => {
1158
- const lines = await invoke$2('Editor.getLines2', editorUid);
1158
+ const lines = await invoke$3('Editor.getLines2', editorUid);
1159
1159
  return lines;
1160
1160
  };
1161
1161
 
1162
1162
  const {
1163
- invoke: invoke$1,
1164
- set: set$2
1165
- } = create$3(7013);
1163
+ invoke: invoke$2,
1164
+ set: set$3
1165
+ } = create$4(7013);
1166
1166
 
1167
1167
  const {
1168
- invoke,
1168
+ invoke: invoke$1,
1169
1169
  invokeAndTransfer,
1170
- set: set$1
1171
- } = create$3(RendererWorker);
1170
+ set: set$2
1171
+ } = create$4(RendererWorker);
1172
1172
  const sendMessagePortToEditorWorker = async (port, rpcId) => {
1173
1173
  const command = 'HandleMessagePort.handleMessagePort';
1174
1174
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1175
1175
  };
1176
1176
  const setFocus = key => {
1177
- return invoke('Focus.setFocus', key);
1177
+ return invoke$1('Focus.setFocus', key);
1178
1178
  };
1179
1179
  const getFileIcon = async options => {
1180
- return invoke('IconTheme.getFileIcon', options);
1180
+ return invoke$1('IconTheme.getFileIcon', options);
1181
1181
  };
1182
1182
  const getFolderIcon = async options => {
1183
- return invoke('IconTheme.getFolderIcon', options);
1183
+ return invoke$1('IconTheme.getFolderIcon', options);
1184
1184
  };
1185
1185
  const closeWidget$1 = async widgetId => {
1186
- return invoke('Viewlet.closeWidget', widgetId);
1186
+ return invoke$1('Viewlet.closeWidget', widgetId);
1187
1187
  };
1188
1188
  const sendMessagePortToFileSearchWorker2 = async (port, rpcId = 0) => {
1189
1189
  const command = 'FileSearch.handleMessagePort';
1190
1190
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
1191
1191
  };
1192
1192
  const getActiveEditorId = () => {
1193
- return invoke('GetActiveEditor.getActiveEditorId');
1193
+ return invoke$1('GetActiveEditor.getActiveEditorId');
1194
1194
  };
1195
1195
  const openUri$1 = async (uri, focus, options) => {
1196
- await invoke('Main.openUri', uri, focus, options);
1196
+ await invoke$1('Main.openUri', uri, focus, options);
1197
1197
  };
1198
1198
  const showErrorDialog$1 = async errorInfo => {
1199
- await invoke('ErrorHandling.showErrorDialog', errorInfo);
1199
+ await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
1200
1200
  };
1201
1201
 
1202
1202
  const closeWidget = async id => {
@@ -1204,7 +1204,73 @@ const closeWidget = async id => {
1204
1204
  await closeWidget$1(id);
1205
1205
  };
1206
1206
 
1207
+ let id$1 = 0;
1208
+ const create$3 = () => {
1209
+ return ++id$1;
1210
+ };
1211
+
1212
+ const callbacks$1 = Object.create(null);
1213
+ const registerCallback = () => {
1214
+ const id = create$3();
1215
+ const {
1216
+ promise,
1217
+ resolve
1218
+ } = Promise.withResolvers();
1219
+ callbacks$1[id] = resolve;
1220
+ return {
1221
+ id,
1222
+ promise
1223
+ };
1224
+ };
1225
+ const executeCallback = (id, value) => {
1226
+ const fn = callbacks$1[id];
1227
+ delete callbacks$1[id];
1228
+ fn(value);
1229
+ };
1230
+
1231
+ const ColorTheme$1 = 0;
1232
+ const Commands$1 = 1;
1233
+ const Custom$1 = 2;
1234
+ const File$1 = 3;
1235
+ const GoToColumn$1 = 4;
1236
+ const GoToLine$2 = 5;
1237
+ const Help$2 = 6;
1238
+ const Recent$1 = 7;
1239
+ const Symbol$3 = 8;
1240
+ const View$3 = 9;
1241
+ const WorkspaceSymbol$2 = 10;
1242
+ const EveryThing$1 = 100;
1243
+
1244
+ const getCancelResult$1 = args => {
1245
+ const last = args.at(-1);
1246
+ if (last && typeof last === 'object' &&
1247
+ // @ts-ignore
1248
+ last.mode === 'quickPick') {
1249
+ return undefined;
1250
+ }
1251
+ return {
1252
+ canceled: true,
1253
+ inputValue: ''
1254
+ };
1255
+ };
1207
1256
  const close = async state => {
1257
+ const {
1258
+ args,
1259
+ providerId
1260
+ } = state;
1261
+ if (providerId === Custom$1) {
1262
+ const resolveId = args[2];
1263
+ const options = args.at(-1);
1264
+ const result = getCancelResult$1(args);
1265
+ if (options?.callbackOwner === 'quickPickWorker') {
1266
+ if (typeof resolveId !== 'number') {
1267
+ throw new TypeError('expected resolve id to be a number');
1268
+ }
1269
+ executeCallback(resolveId, result);
1270
+ } else {
1271
+ await invoke$1('QuickPick.executeCallback', resolveId, result);
1272
+ }
1273
+ }
1208
1274
  await closeWidget(state.uid);
1209
1275
  return state;
1210
1276
  };
@@ -1336,13 +1402,47 @@ const create$2 = () => {
1336
1402
 
1337
1403
  const {
1338
1404
  dispose: dispose$1,
1339
- get,
1405
+ get: get$1,
1340
1406
  getCommandIds,
1341
1407
  registerCommands,
1342
- set,
1408
+ set: set$1,
1343
1409
  wrapCommand
1344
1410
  } = create$2();
1345
1411
 
1412
+ const getListHeight$1 = (itemsLength, itemHeight, maxHeight) => {
1413
+ number(itemsLength);
1414
+ number(itemHeight);
1415
+ number(maxHeight);
1416
+ if (itemsLength === 0) {
1417
+ return itemHeight;
1418
+ }
1419
+ const totalHeight = itemsLength * itemHeight;
1420
+ return Math.min(totalHeight, maxHeight);
1421
+ };
1422
+
1423
+ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1424
+ if (size >= contentSize) {
1425
+ return 0;
1426
+ }
1427
+ return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1428
+ };
1429
+
1430
+ const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
1431
+ if (finalDelta <= 0) {
1432
+ return 0;
1433
+ }
1434
+ const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
1435
+ return scrollBarOffset;
1436
+ };
1437
+ const getScrollBarY = getScrollBarOffset;
1438
+ const getDeltaY = (scrollBarY, finalDelta, size, scrollBarSize) => {
1439
+ const scrollBarRange = size - scrollBarSize;
1440
+ if (finalDelta <= 0 || scrollBarRange <= 0) {
1441
+ return 0;
1442
+ }
1443
+ return scrollBarY / scrollBarRange * finalDelta;
1444
+ };
1445
+
1346
1446
  const create$1 = ({
1347
1447
  headerHeight = 0,
1348
1448
  itemHeight,
@@ -1360,17 +1460,40 @@ const create$1 = ({
1360
1460
  minLineY: 0,
1361
1461
  scrollBarActive: false,
1362
1462
  scrollBarHeight: 0,
1463
+ scrollBarPointerId: -1,
1464
+ scrollBarPointerOffsetY: 0,
1363
1465
  touchDifference: 0,
1364
1466
  touchOffsetY: 0,
1365
1467
  touchTimeStamp: 0
1366
1468
  };
1367
1469
  };
1368
- const getListHeight$1 = (height, headerHeight) => {
1470
+ const getListHeight = (height, headerHeight) => {
1369
1471
  if (headerHeight) {
1370
1472
  return height - headerHeight;
1371
1473
  }
1372
1474
  return headerHeight;
1373
1475
  };
1476
+ const clamp = (value, min, max) => {
1477
+ return Math.min(Math.max(value, min), max);
1478
+ };
1479
+ const getScrollBarHeight = state => {
1480
+ const {
1481
+ height,
1482
+ itemHeight,
1483
+ items,
1484
+ minimumSliderSize
1485
+ } = state;
1486
+ const listHeight = getListHeight$1(items.length, itemHeight, height);
1487
+ const contentHeight = items.length * itemHeight;
1488
+ return getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
1489
+ };
1490
+ const getScrollBarTop = (state, scrollBarHeight) => {
1491
+ const scrollBarSize = state.height - state.headerHeight;
1492
+ return getScrollBarY(state.deltaY, state.finalDeltaY, scrollBarSize, scrollBarHeight);
1493
+ };
1494
+ const getRelativePointerY = (state, clientY) => {
1495
+ return clientY - state.top - state.headerHeight;
1496
+ };
1374
1497
  const setDeltaY = (state, deltaY) => {
1375
1498
  object(state);
1376
1499
  number(deltaY);
@@ -1380,7 +1503,7 @@ const setDeltaY = (state, deltaY) => {
1380
1503
  itemHeight,
1381
1504
  items
1382
1505
  } = state;
1383
- const listHeight = getListHeight$1(height, headerHeight);
1506
+ const listHeight = getListHeight(height, headerHeight);
1384
1507
  const itemsLength = items.length;
1385
1508
  const finalDeltaY = itemsLength * itemHeight - listHeight;
1386
1509
  if (deltaY < 0) {
@@ -1408,6 +1531,53 @@ const handleWheel = (state, deltaMode, deltaY) => {
1408
1531
  number(deltaY);
1409
1532
  return setDeltaY(state, state.deltaY + deltaY);
1410
1533
  };
1534
+ const handleScrollBarPointerDown = (state, clientY, pointerId) => {
1535
+ object(state);
1536
+ number(clientY);
1537
+ number(pointerId);
1538
+ const scrollBarHeight = getScrollBarHeight(state);
1539
+ if (scrollBarHeight <= 0) {
1540
+ return state;
1541
+ }
1542
+ const scrollBarTop = getScrollBarTop(state, scrollBarHeight);
1543
+ const relativePointerY = getRelativePointerY(state, clientY);
1544
+ const scrollBarPointerOffsetY = clamp(relativePointerY - scrollBarTop, 0, scrollBarHeight);
1545
+ const newState = {
1546
+ ...state,
1547
+ scrollBarActive: true,
1548
+ scrollBarPointerId: pointerId,
1549
+ scrollBarPointerOffsetY
1550
+ };
1551
+ return handleScrollBarPointerMove(newState, clientY, pointerId);
1552
+ };
1553
+ const handleScrollBarPointerMove = (state, clientY, pointerId) => {
1554
+ object(state);
1555
+ number(clientY);
1556
+ number(pointerId);
1557
+ if (!state.scrollBarActive || state.scrollBarPointerId !== pointerId) {
1558
+ return state;
1559
+ }
1560
+ const scrollBarHeight = getScrollBarHeight(state);
1561
+ const scrollBarSize = state.height - state.headerHeight;
1562
+ const maxScrollBarTop = Math.max(scrollBarSize - scrollBarHeight, 0);
1563
+ const relativePointerY = getRelativePointerY(state, clientY) - state.scrollBarPointerOffsetY;
1564
+ const scrollBarTop = clamp(relativePointerY, 0, maxScrollBarTop);
1565
+ const deltaY = Math.round(getDeltaY(scrollBarTop, state.finalDeltaY, scrollBarSize, scrollBarHeight));
1566
+ return setDeltaY(state, deltaY);
1567
+ };
1568
+ const handleScrollBarPointerUp = (state, pointerId) => {
1569
+ object(state);
1570
+ number(pointerId);
1571
+ if (!state.scrollBarActive || state.scrollBarPointerId !== pointerId) {
1572
+ return state;
1573
+ }
1574
+ return {
1575
+ ...state,
1576
+ scrollBarActive: false,
1577
+ scrollBarPointerId: -1,
1578
+ scrollBarPointerOffsetY: 0
1579
+ };
1580
+ };
1411
1581
 
1412
1582
  const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, workspaceUri, assetDir) => {
1413
1583
  const state = {
@@ -1442,7 +1612,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, w
1442
1612
  platform,
1443
1613
  value: ''
1444
1614
  };
1445
- set(uid, state, state);
1615
+ set$1(uid, state, state);
1446
1616
  };
1447
1617
 
1448
1618
  const RenderItems = 1;
@@ -1492,7 +1662,7 @@ const diff2 = uid => {
1492
1662
  const {
1493
1663
  newState,
1494
1664
  oldState
1495
- } = get(uid);
1665
+ } = get$1(uid);
1496
1666
  return diff(oldState, newState);
1497
1667
  };
1498
1668
 
@@ -1501,7 +1671,7 @@ const dispose = uid => {
1501
1671
  };
1502
1672
 
1503
1673
  const setColorTheme = id => {
1504
- return invoke(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1674
+ return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1505
1675
  };
1506
1676
 
1507
1677
  const focusPick$1 = async pick => {
@@ -1511,19 +1681,6 @@ const focusPick$1 = async pick => {
1511
1681
  await setColorTheme(label);
1512
1682
  };
1513
1683
 
1514
- const ColorTheme$1 = 0;
1515
- const Commands$1 = 1;
1516
- const Custom$1 = 2;
1517
- const File$1 = 3;
1518
- const GoToColumn$1 = 4;
1519
- const GoToLine$2 = 5;
1520
- const Help$2 = 6;
1521
- const Recent$1 = 7;
1522
- const Symbol$3 = 8;
1523
- const View$3 = 9;
1524
- const WorkspaceSymbol$2 = 10;
1525
- const EveryThing$1 = 100;
1526
-
1527
1684
  const noop$1 = async () => {};
1528
1685
  const getFn$1 = id => {
1529
1686
  switch (id) {
@@ -1559,6 +1716,10 @@ const getMissingIconRequests = (dirents, fileIconCache) => {
1559
1716
  return missingRequests;
1560
1717
  };
1561
1718
 
1719
+ const getPath$1 = dirent => {
1720
+ return dirent.path;
1721
+ };
1722
+
1562
1723
  const None$2 = 0;
1563
1724
  const Directory = 3;
1564
1725
  const File = 7;
@@ -1578,6 +1739,15 @@ const requestFileIcons = async requests => {
1578
1739
  return Promise.all(promises);
1579
1740
  };
1580
1741
 
1742
+ const toDirent = pick => {
1743
+ const dirent = {
1744
+ name: pick.label,
1745
+ path: pick.uri,
1746
+ type: pick.direntType
1747
+ };
1748
+ return dirent;
1749
+ };
1750
+
1581
1751
  const updateIconCache = (iconCache, missingRequests, newIcons) => {
1582
1752
  if (missingRequests.length === 0) {
1583
1753
  return iconCache;
@@ -1593,17 +1763,6 @@ const updateIconCache = (iconCache, missingRequests, newIcons) => {
1593
1763
  return newFileIconCache;
1594
1764
  };
1595
1765
 
1596
- const getPath$1 = dirent => {
1597
- return dirent.path;
1598
- };
1599
- const toDirent = pick => {
1600
- const dirent = {
1601
- name: pick.label,
1602
- path: pick.uri,
1603
- type: pick.direntType
1604
- };
1605
- return dirent;
1606
- };
1607
1766
  const getQuickPickFileIcons = async (items, fileIconCache) => {
1608
1767
  const dirents = items.map(toDirent);
1609
1768
  const missingRequests = getMissingIconRequests(dirents, fileIconCache);
@@ -1620,6 +1779,7 @@ const getQuickPickFileIcons = async (items, fileIconCache) => {
1620
1779
  const focusIndex = async (state, index) => {
1621
1780
  const {
1622
1781
  fileIconCache,
1782
+ itemHeight,
1623
1783
  items,
1624
1784
  maxLineY,
1625
1785
  maxVisibleItems,
@@ -1639,6 +1799,7 @@ const focusIndex = async (state, index) => {
1639
1799
  // TODO need to scroll up
1640
1800
  return {
1641
1801
  ...state,
1802
+ deltaY: minLineY * itemHeight,
1642
1803
  fileIconCache: newFileIconCache,
1643
1804
  focusedIndex: index,
1644
1805
  icons,
@@ -1657,6 +1818,7 @@ const focusIndex = async (state, index) => {
1657
1818
  } = await getQuickPickFileIcons(sliced, fileIconCache);
1658
1819
  return {
1659
1820
  ...state,
1821
+ deltaY: minLineY * itemHeight,
1660
1822
  fileIconCache: newFileIconCache,
1661
1823
  focusedIndex: index,
1662
1824
  icons,
@@ -1728,8 +1890,7 @@ const DownArrow = 16;
1728
1890
 
1729
1891
  const getKeyBindings = () => {
1730
1892
  return [{
1731
- args: ['QuickPick'],
1732
- command: 'Viewlet.closeWidget',
1893
+ command: 'QuickPick.close',
1733
1894
  key: Escape,
1734
1895
  when: FocusQuickPickInput
1735
1896
  }, {
@@ -2156,19 +2317,8 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
2156
2317
  return finalDeltaY;
2157
2318
  };
2158
2319
 
2159
- const getListHeight = (itemsLength, itemHeight, maxHeight) => {
2160
- number(itemsLength);
2161
- number(itemHeight);
2162
- number(maxHeight);
2163
- if (itemsLength === 0) {
2164
- return itemHeight;
2165
- }
2166
- const totalHeight = itemsLength * itemHeight;
2167
- return Math.min(totalHeight, maxHeight);
2168
- };
2169
-
2170
2320
  const getColorThemeNames = async (assetDir, platform) => {
2171
- return invoke('ColorTheme.getColorThemeNames', assetDir, platform);
2321
+ return invoke$1('ColorTheme.getColorThemeNames', assetDir, platform);
2172
2322
  };
2173
2323
 
2174
2324
  const toProtoVisibleItem$3 = name => {
@@ -2226,14 +2376,14 @@ const state$1 = {
2226
2376
  const getAll = async () => {
2227
2377
  try {
2228
2378
  // @ts-ignore
2229
- const entries = await invoke('Layout.getAllQuickPickMenuEntries');
2379
+ const entries = await invoke$1('Layout.getAllQuickPickMenuEntries');
2230
2380
  return entries || [];
2231
2381
  } catch {
2232
2382
  // ignore
2233
2383
  }
2234
2384
  return state$1.menuEntries;
2235
2385
  };
2236
- const add = menuEntries => {
2386
+ const add$1 = menuEntries => {
2237
2387
  state$1.menuEntries = [...state$1.menuEntries, ...menuEntries];
2238
2388
  };
2239
2389
 
@@ -2262,7 +2412,7 @@ const getExtensionPicks = async (assetDir, platform) => {
2262
2412
  // Assert.number(platform)
2263
2413
  // TODO ask extension management worker directly
2264
2414
  // TODO don't call this every time, cache the results
2265
- const extensionPicks = await invoke('ExtensionHost.getCommands', assetDir, platform);
2415
+ const extensionPicks = await invoke$1('ExtensionHost.getCommands', assetDir, platform);
2266
2416
  if (!extensionPicks) {
2267
2417
  return [];
2268
2418
  }
@@ -2302,22 +2452,53 @@ const getPicks$b = async (value, args, {
2302
2452
  return converted;
2303
2453
  };
2304
2454
 
2455
+ const state = {
2456
+ args: [],
2457
+ items: Object.create(null)
2458
+ };
2459
+
2460
+ let id = 0;
2461
+ const add = items => {
2462
+ const nextId = ++id;
2463
+ state.items[nextId] = items;
2464
+ return nextId;
2465
+ };
2466
+ const get = id => {
2467
+ return state.items[id] || [];
2468
+ };
2469
+ const remove = id => {
2470
+ delete state.items[id];
2471
+ };
2472
+
2473
+ let rpc;
2474
+ const set = newRpc => {
2475
+ rpc = newRpc;
2476
+ };
2477
+ const invoke = (method, ...args) => {
2478
+ return rpc.invoke(method, ...args);
2479
+ };
2480
+
2305
2481
  const toProtoVisibleItem$1 = item => {
2306
2482
  const {
2307
- label
2483
+ description = '',
2484
+ label,
2485
+ value
2308
2486
  } = item;
2309
2487
  return {
2310
- description: '',
2488
+ description,
2311
2489
  direntType: 0,
2312
2490
  fileIcon: '',
2313
2491
  icon: '',
2314
2492
  label,
2315
2493
  matches: [],
2316
- uri: ''
2494
+ uri: '',
2495
+ value
2317
2496
  };
2318
2497
  };
2319
2498
  const getPicks$a = async (searchValue, args) => {
2320
- const items = args[1] || [];
2499
+ state.args = args;
2500
+ const options = args.at(-1);
2501
+ const items = options?.mode === 'quickInput' ? searchValue === '' && options?.customItemsId ? get(options.customItemsId) : await invoke('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue) : options?.customItemsId ? get(options.customItemsId) : args[1] || [];
2321
2502
  const mapped = items.map(toProtoVisibleItem$1);
2322
2503
  return mapped;
2323
2504
  };
@@ -2325,11 +2506,11 @@ const getPicks$a = async (searchValue, args) => {
2325
2506
  const emptyMatches = [];
2326
2507
 
2327
2508
  const getWorkspacePath = async () => {
2328
- return invoke('Workspace.getPath');
2509
+ return invoke$1('Workspace.getPath');
2329
2510
  };
2330
2511
 
2331
2512
  const searchFile$1 = async (path, value, prepare, assetDir) => {
2332
- const result = await invoke$1('FileSearch.searchFile', path, value, prepare, assetDir);
2513
+ const result = await invoke$2('FileSearch.searchFile', path, value, prepare, assetDir);
2333
2514
  return result;
2334
2515
  };
2335
2516
 
@@ -2614,8 +2795,12 @@ const getPicks$7 = async () => {
2614
2795
  }];
2615
2796
  };
2616
2797
 
2617
- const getRecentlyOpened = () => {
2618
- return invoke(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2798
+ const uniq = array => {
2799
+ return [...new Set(array)];
2800
+ };
2801
+ const getRecentlyOpened = async () => {
2802
+ const recentlyOpened = await invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2803
+ return uniq(recentlyOpened);
2619
2804
  };
2620
2805
 
2621
2806
  const getPath = uri => {
@@ -2694,7 +2879,7 @@ const shouldHide = item => {
2694
2879
  const selectPickBuiltin = async item => {
2695
2880
  const args = item.args || [];
2696
2881
  // TODO ids should be all numbers for efficiency -> also directly can call command
2697
- await invoke(item.id, ...args);
2882
+ await invoke$1(item.id, ...args);
2698
2883
  if (shouldHide(item)) {
2699
2884
  return {
2700
2885
  command: Hide
@@ -2707,13 +2892,16 @@ const selectPickBuiltin = async item => {
2707
2892
  const selectPickExtension = async item => {
2708
2893
  const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
2709
2894
  try {
2710
- await invoke('ExtensionHost.executeCommand', id);
2895
+ await invoke$1('ExtensionHost.executeCommand', id);
2711
2896
  } catch (error) {
2712
2897
  await handleError(error, false);
2713
2898
  await showErrorDialog(error);
2899
+ return {
2900
+ command: Hide
2901
+ };
2714
2902
  }
2715
2903
  return {
2716
- command: Hide
2904
+ command: KeepOpen
2717
2905
  };
2718
2906
  };
2719
2907
  const selectPick$8 = async item => {
@@ -2727,16 +2915,31 @@ const selectPick$8 = async item => {
2727
2915
  return selectPickBuiltin(item);
2728
2916
  };
2729
2917
 
2730
- const state = {
2731
- args: []
2918
+ const getOptions = args => {
2919
+ const last = args.at(-1);
2920
+ if (!last || typeof last !== 'object') {
2921
+ return {};
2922
+ }
2923
+ return last;
2732
2924
  };
2733
-
2734
- const selectPick$7 = async pick => {
2925
+ const selectPick$7 = async (_pick, value) => {
2735
2926
  const {
2736
2927
  args
2737
2928
  } = state;
2929
+ const options = getOptions(args);
2738
2930
  const resolveId = args[2];
2739
- await invoke(`QuickPick.executeCallback`, resolveId, pick);
2931
+ const result = options.mode === 'quickPick' ? _pick.value : {
2932
+ canceled: false,
2933
+ inputValue: value
2934
+ };
2935
+ if (options.callbackOwner === 'quickPickWorker') {
2936
+ if (typeof resolveId !== 'number') {
2937
+ throw new TypeError('expected resolve id to be a number');
2938
+ }
2939
+ executeCallback(resolveId, result);
2940
+ } else {
2941
+ await invoke$1('QuickPick.executeCallback', resolveId, result);
2942
+ }
2740
2943
  return {
2741
2944
  command: Hide
2742
2945
  };
@@ -2760,12 +2963,12 @@ const selectPick$6 = async pick => {
2760
2963
  };
2761
2964
 
2762
2965
  const setCursor = async (rowIndex, columnIndex) => {
2763
- await invoke('Editor.cursorSet', rowIndex, columnIndex);
2966
+ await invoke$1('Editor.cursorSet', rowIndex, columnIndex);
2764
2967
  };
2765
2968
 
2766
2969
  const goToPositionAndFocus = async (rowIndex, columnIndex) => {
2767
2970
  await setCursor(rowIndex, columnIndex);
2768
- await invoke('Editor.handleFocus');
2971
+ await invoke$1('Editor.handleFocus');
2769
2972
  };
2770
2973
 
2771
2974
  const selectPickGoToColumn = async (item, value) => {
@@ -2808,7 +3011,7 @@ const selectPick$4 = async item => {
2808
3011
  };
2809
3012
 
2810
3013
  const openWorkspaceFolder = uri => {
2811
- return invoke(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
3014
+ return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
2812
3015
  };
2813
3016
 
2814
3017
  // TODO selectPick should be independent of show/hide
@@ -2890,6 +3093,11 @@ const getQuickPickSubProviderId = (id, prefix) => {
2890
3093
  }
2891
3094
  };
2892
3095
 
3096
+ const isQuickInput = args => {
3097
+ const options = args.at(-1);
3098
+ return options?.mode === 'quickInput';
3099
+ };
3100
+
2893
3101
  // TODO when user types letters -> no need to query provider again -> just filter existing results
2894
3102
  const setValue = async (state, newValue) => {
2895
3103
  const {
@@ -2913,7 +3121,7 @@ const setValue = async (state, newValue) => {
2913
3121
  assetDir,
2914
3122
  platform
2915
3123
  });
2916
- const filterValue = getFilterValue(providerId, subId, newValue);
3124
+ const filterValue = isQuickInput(args) ? '' : getFilterValue(providerId, subId, newValue);
2917
3125
  const items = filterQuickPickItems(newPicks, filterValue);
2918
3126
  const focusedIndex = items.length === 0 ? -1 : 0;
2919
3127
  const sliced = items.slice(minLineY, maxLineY);
@@ -2921,7 +3129,7 @@ const setValue = async (state, newValue) => {
2921
3129
  icons,
2922
3130
  newFileIconCache
2923
3131
  } = await getQuickPickFileIcons(sliced, fileIconCache);
2924
- const listHeight = getListHeight(items.length, itemHeight, height);
3132
+ const listHeight = getListHeight$1(items.length, itemHeight, height);
2925
3133
  const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
2926
3134
  return {
2927
3135
  ...state,
@@ -2967,7 +3175,27 @@ const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd)
2967
3175
  return handleInput(state, newValue, cursorOffset, User);
2968
3176
  };
2969
3177
 
3178
+ const getCancelResult = args => {
3179
+ const last = args.at(-1);
3180
+ if (last && typeof last === 'object' &&
3181
+ // @ts-ignore
3182
+ last.mode === 'quickPick') {
3183
+ return undefined;
3184
+ }
3185
+ return {
3186
+ canceled: true,
3187
+ inputValue: ''
3188
+ };
3189
+ };
2970
3190
  const handleBlur = async state => {
3191
+ const {
3192
+ args,
3193
+ providerId
3194
+ } = state;
3195
+ if (providerId === Custom$1) {
3196
+ const resolveId = args[2];
3197
+ await invoke$1('QuickPick.executeCallback', resolveId, getCancelResult(args));
3198
+ }
2971
3199
  await closeWidget(state.uid);
2972
3200
  return state;
2973
3201
  };
@@ -2992,6 +3220,17 @@ const getPick = (items, index) => {
2992
3220
  return undefined;
2993
3221
  };
2994
3222
 
3223
+ const createCustomPick = value => {
3224
+ return {
3225
+ description: '',
3226
+ direntType: 0,
3227
+ fileIcon: '',
3228
+ icon: '',
3229
+ label: value,
3230
+ matches: [],
3231
+ uri: ''
3232
+ };
3233
+ };
2995
3234
  const selectIndex = async (state, index, button = /* left */0) => {
2996
3235
  const {
2997
3236
  items,
@@ -3000,12 +3239,12 @@ const selectIndex = async (state, index, button = /* left */0) => {
3000
3239
  value
3001
3240
  } = state;
3002
3241
  const actualIndex = index + minLineY;
3003
- const pick = getPick(items, actualIndex);
3242
+ const prefix = getQuickPickPrefix(value);
3243
+ const subId = getQuickPickSubProviderId(providerId, prefix);
3244
+ const pick = getPick(items, actualIndex) || (subId === Custom$1 ? createCustomPick(value) : undefined);
3004
3245
  if (!pick) {
3005
3246
  return state;
3006
3247
  }
3007
- const prefix = getQuickPickPrefix(value);
3008
- const subId = getQuickPickSubProviderId(providerId, prefix);
3009
3248
  const fn = getSelect(subId);
3010
3249
  const selectPickResult = await fn(pick, value);
3011
3250
  object(selectPickResult);
@@ -3052,11 +3291,12 @@ const handleFocus = async state => {
3052
3291
  const commandMapRef = {};
3053
3292
 
3054
3293
  const handleMessagePort = async port => {
3055
- await create$7({
3294
+ const rpc = await create$8({
3056
3295
  commandMap: commandMapRef,
3057
3296
  isMessagePortOpen: true,
3058
3297
  messagePort: port
3059
3298
  });
3299
+ set(rpc);
3060
3300
  };
3061
3301
 
3062
3302
  const initialize = async () => {
@@ -3104,25 +3344,45 @@ const getQuickPickProviderId = prefix => {
3104
3344
  }
3105
3345
  };
3106
3346
 
3347
+ const callbacks = [];
3348
+ const waitUntilVisible = () => {
3349
+ const {
3350
+ promise,
3351
+ resolve
3352
+ } = Promise.withResolvers();
3353
+ callbacks.push(resolve);
3354
+ return promise;
3355
+ };
3356
+ const notifyVisible = () => {
3357
+ const pendingCallbacks = callbacks.splice(0);
3358
+ for (const callback of pendingCallbacks) {
3359
+ callback();
3360
+ }
3361
+ };
3362
+
3107
3363
  const parseArgs = (subId, args) => {
3108
3364
  if (subId !== Custom$1) {
3109
3365
  return {
3110
3366
  ignoreFocusOut: false,
3111
- initialValue: ''
3367
+ initialValue: '',
3368
+ placeholder: ''
3112
3369
  };
3113
3370
  }
3114
3371
  const last = args.at(-1);
3115
3372
  if (!last || typeof last !== 'object') {
3116
3373
  return {
3117
3374
  ignoreFocusOut: false,
3118
- initialValue: ''
3375
+ initialValue: '',
3376
+ placeholder: ''
3119
3377
  };
3120
3378
  }
3121
3379
  return {
3122
3380
  // @ts-ignore
3123
3381
  ignoreFocusOut: Boolean(last.ignoreFocusOut),
3124
3382
  // @ts-ignore
3125
- initialValue: String(last.initialValue)
3383
+ initialValue: last.initialValue ? String(last.initialValue) : '',
3384
+ // @ts-ignore
3385
+ placeholder: last.placeholder ? String(last.placeholder) : ''
3126
3386
  };
3127
3387
  };
3128
3388
  const loadContent = async state => {
@@ -3154,10 +3414,11 @@ const loadContent = async state => {
3154
3414
  icons,
3155
3415
  newFileIconCache
3156
3416
  } = await getQuickPickFileIcons(sliced, fileIconCache);
3157
- const listHeight = getListHeight(items.length, itemHeight, height);
3417
+ const listHeight = getListHeight$1(items.length, itemHeight, height);
3158
3418
  const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
3159
3419
  const parsedArgs = parseArgs(subId, args);
3160
3420
  const finalValue = parsedArgs.initialValue || value;
3421
+ notifyVisible();
3161
3422
  return {
3162
3423
  ...state,
3163
3424
  args,
@@ -3173,20 +3434,13 @@ const loadContent = async state => {
3173
3434
  maxLineY,
3174
3435
  minLineY,
3175
3436
  picks: newPicks,
3176
- placeholder: '',
3437
+ placeholder: parsedArgs.placeholder,
3177
3438
  providerId: id,
3178
3439
  state: Finished,
3179
3440
  value: finalValue
3180
3441
  };
3181
3442
  };
3182
3443
 
3183
- const callbacks = Object.create(null);
3184
- const executeCallback = id => {
3185
- const fn = callbacks[id];
3186
- delete callbacks[id];
3187
- fn();
3188
- };
3189
-
3190
3444
  const SetCursorOffset = 'setCursorOffset';
3191
3445
  const SetFocusedIndex = 'setFocusedIndex';
3192
3446
  const SetItemsHeight = 'setItemsHeight';
@@ -3535,13 +3789,6 @@ const getVisible$1 = (items, minLineY, maxLineY, icons) => {
3535
3789
  return protoVisibleItems;
3536
3790
  };
3537
3791
 
3538
- const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
3539
- if (size >= contentSize) {
3540
- return 0;
3541
- }
3542
- return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
3543
- };
3544
-
3545
3792
  const emptyHighlightSections = [];
3546
3793
 
3547
3794
  const getHighlightSections = (highlights, label) => {
@@ -3578,13 +3825,14 @@ const getHighlightSections = (highlights, label) => {
3578
3825
  };
3579
3826
 
3580
3827
  const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
3828
+ const visibleFocusedIndex = focusedIndex - minLineY;
3581
3829
  const visibleItems = protoVisibleItems.map((visibleItem, i) => {
3582
3830
  const highlights = visibleItem.matches.slice(1);
3583
3831
  const sections = getHighlightSections(highlights, visibleItem.label);
3584
3832
  return {
3585
3833
  ...visibleItem,
3586
3834
  highlights: sections,
3587
- isActive: i === focusedIndex,
3835
+ isActive: i === visibleFocusedIndex,
3588
3836
  posInSet: minLineY + i + 1,
3589
3837
  setSize
3590
3838
  };
@@ -3592,15 +3840,6 @@ const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
3592
3840
  return visibleItems;
3593
3841
  };
3594
3842
 
3595
- const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
3596
- if (finalDelta <= 0) {
3597
- return 0;
3598
- }
3599
- const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
3600
- return scrollBarOffset;
3601
- };
3602
- const getScrollBarY = getScrollBarOffset;
3603
-
3604
3843
  const createQuickPickViewModel = (oldState, newState) => {
3605
3844
  const {
3606
3845
  cursorOffset,
@@ -3624,7 +3863,7 @@ const createQuickPickViewModel = (oldState, newState) => {
3624
3863
  const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
3625
3864
  const newFocusedIndex = focusedIndex - minLineY;
3626
3865
  const itemCount = items.length;
3627
- const listHeight = getListHeight(itemCount, itemHeight, height);
3866
+ const listHeight = getListHeight$1(itemCount, itemHeight, height);
3628
3867
  const contentHeight = itemCount * itemHeight;
3629
3868
  const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
3630
3869
  const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
@@ -3655,7 +3894,7 @@ const Label = 'Label';
3655
3894
  const List = 'List';
3656
3895
  const ListItems = 'ListItems';
3657
3896
  const MaskIcon = 'MaskIcon';
3658
- const QuickPick$1 = 'QuickPick';
3897
+ const QuickPick$2 = 'QuickPick';
3659
3898
  const QuickPickHeader = 'QuickPickHeader';
3660
3899
  const QuickPickHighlight = 'QuickPickHighlight';
3661
3900
  const QuickPickItem = 'QuickPickItem';
@@ -3679,11 +3918,11 @@ const HandleScrollbarPointerDown = 'handleScrollbarPointerDown';
3679
3918
  const HandleScrollbarPointerMove = 'handleScrollbarPointerMove';
3680
3919
  const HandleScrollbarPointerUp = 'handleScrollbarPointerUp';
3681
3920
 
3682
- const QuickPick = 'QuickPick';
3921
+ const QuickPick$1 = 'QuickPick';
3683
3922
  const QuickPickItems = 'QuickPickItems';
3684
3923
  const QuickPickItemActive = 'QuickPickItemActive';
3685
3924
 
3686
- const getQuickPickInputVirtualDom = () => {
3925
+ const getQuickPickInputVirtualDom = (placeholder = '') => {
3687
3926
  const ariaLabel = typeNameofCommandToRun();
3688
3927
  return {
3689
3928
  ariaAutoComplete: 'list',
@@ -3699,18 +3938,19 @@ const getQuickPickInputVirtualDom = () => {
3699
3938
  onBlur: HandleBlur,
3700
3939
  onFocus: HandleFocus,
3701
3940
  onInput: HandleInput,
3941
+ placeholder,
3702
3942
  role: ComboBox,
3703
3943
  spellcheck: false,
3704
3944
  type: Input
3705
3945
  };
3706
3946
  };
3707
3947
 
3708
- const getQuickPickHeaderVirtualDom = () => {
3948
+ const getQuickPickHeaderVirtualDom = (placeholder = '') => {
3709
3949
  return [{
3710
3950
  childCount: 1,
3711
3951
  className: QuickPickHeader,
3712
3952
  type: Div
3713
- }, getQuickPickInputVirtualDom()];
3953
+ }, getQuickPickInputVirtualDom(placeholder)];
3714
3954
  };
3715
3955
 
3716
3956
  const getFileIconVirtualDom = icon => {
@@ -3832,6 +4072,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
3832
4072
  return [{
3833
4073
  childCount: 1,
3834
4074
  className: mergeClassNames(ScrollBar, ScrollBarSmall),
4075
+ onPointerDown: HandleScrollbarPointerDown,
3835
4076
  type: Div
3836
4077
  }, {
3837
4078
  childCount: 0,
@@ -3859,7 +4100,7 @@ const getRootNodeCount = nodes => {
3859
4100
  }
3860
4101
  return count;
3861
4102
  };
3862
- const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) => {
4103
+ const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop, placeholder = '') => {
3863
4104
  const quickOpen$1 = quickOpen();
3864
4105
  const shouldShowScrollbar = scrollBarHeight > 0;
3865
4106
  const quickPickItemsDom = getQuickPickItemsVirtualDom(visibleItems);
@@ -3867,10 +4108,10 @@ const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) =>
3867
4108
  return [{
3868
4109
  ariaLabel: quickOpen$1,
3869
4110
  childCount: 2,
3870
- className: mergeClassNames(Viewlet, QuickPick$1),
3871
- id: QuickPick,
4111
+ className: mergeClassNames(Viewlet, QuickPick$2),
4112
+ id: QuickPick$1,
3872
4113
  type: Div
3873
- }, ...getQuickPickHeaderVirtualDom(), {
4114
+ }, ...getQuickPickHeaderVirtualDom(placeholder), {
3874
4115
  ariaActivedescendant: QuickPickItemActive,
3875
4116
  childCount: shouldShowScrollbar ? 2 : 1,
3876
4117
  className: mergeClassNames(List, ContainContent),
@@ -3896,7 +4137,7 @@ const renderItemsDom = state => {
3896
4137
  scrollBarTop,
3897
4138
  visibleItems
3898
4139
  } = viewModel;
3899
- return getQuickPickVirtualDom(visibleItems, scrollBarHeight, scrollBarTop);
4140
+ return getQuickPickVirtualDom(visibleItems, scrollBarHeight, scrollBarTop, state.placeholder);
3900
4141
  };
3901
4142
  const renderItems = (_oldState, newState) => {
3902
4143
  const dom = renderItemsDom(newState);
@@ -3954,11 +4195,11 @@ const render2 = (uid, diffResult) => {
3954
4195
  const {
3955
4196
  newState,
3956
4197
  oldState
3957
- } = get(uid);
4198
+ } = get$1(uid);
3958
4199
  if (oldState === newState) {
3959
4200
  return [];
3960
4201
  }
3961
- set(uid, newState, newState);
4202
+ set$1(uid, newState, newState);
3962
4203
  const commands = applyRender(oldState, newState, diffResult);
3963
4204
  return commands;
3964
4205
  };
@@ -4025,26 +4266,62 @@ const selectItem = async (state, label) => {
4025
4266
  };
4026
4267
 
4027
4268
  const showQuickInput = async ({
4269
+ id,
4028
4270
  ignoreFocusOut,
4271
+ initialItems = [],
4029
4272
  initialValue,
4030
4273
  waitUntil
4031
4274
  }) => {
4032
- // TODO ask renderer worker to create quickpick instance, with given options
4275
+ const customItemsId = add(initialItems);
4033
4276
  const picks = [];
4034
- // const id=QuickPickCallbacks.registerCallback()
4035
- await invoke('QuickPick.showCustom', picks, {
4036
- ignoreFocusOut,
4037
- initialValue,
4038
- waitUntil
4039
- });
4040
- return {
4041
- canceled: false,
4042
- inputValue: ''
4043
- };
4277
+ try {
4278
+ const result = await invoke$1('QuickPick.showCustom', picks, {
4279
+ customItemsId,
4280
+ ignoreFocusOut,
4281
+ initialValue,
4282
+ mode: 'quickInput',
4283
+ quickInputId: id,
4284
+ waitUntil
4285
+ });
4286
+ return result ?? {
4287
+ canceled: true,
4288
+ inputValue: ''
4289
+ };
4290
+ } finally {
4291
+ remove(customItemsId);
4292
+ }
4293
+ };
4294
+
4295
+ const QuickPick = 'QuickPick';
4296
+
4297
+ const showQuickPick = async ({
4298
+ items,
4299
+ placeholder = '',
4300
+ waitUntil = 'selected'
4301
+ }) => {
4302
+ const customItemsId = add(items);
4303
+ const {
4304
+ id,
4305
+ promise
4306
+ } = registerCallback();
4307
+ try {
4308
+ await invoke$1('Viewlet.openWidget', QuickPick, 'custom', [], id, {
4309
+ callbackOwner: 'quickPickWorker',
4310
+ customItemsId,
4311
+ mode: 'quickPick',
4312
+ placeholder
4313
+ });
4314
+ if (waitUntil === 'visible') {
4315
+ return undefined;
4316
+ }
4317
+ return await promise;
4318
+ } finally {
4319
+ remove(customItemsId);
4320
+ }
4044
4321
  };
4045
4322
 
4046
4323
  const commandMap = {
4047
- 'QuickPick.addMenuEntries': add,
4324
+ 'QuickPick.addMenuEntries': add$1,
4048
4325
  'QuickPick.close': close,
4049
4326
  'QuickPick.create2': create,
4050
4327
  'QuickPick.diff2': diff2,
@@ -4063,6 +4340,9 @@ const commandMap = {
4063
4340
  'QuickPick.handleFocus': wrapCommand(handleFocus),
4064
4341
  'QuickPick.handleInput': wrapCommand(handleInput),
4065
4342
  'QuickPick.handleMessagePort': handleMessagePort,
4343
+ 'QuickPick.handleScrollBarPointerDown': wrapCommand(handleScrollBarPointerDown),
4344
+ 'QuickPick.handleScrollBarPointerMove': wrapCommand(handleScrollBarPointerMove),
4345
+ 'QuickPick.handleScrollBarPointerUp': wrapCommand(handleScrollBarPointerUp),
4066
4346
  'QuickPick.handleWheel': wrapCommand(handleWheel),
4067
4347
  'QuickPick.initialize': initialize,
4068
4348
  'QuickPick.loadContent': wrapCommand(loadContent),
@@ -4073,34 +4353,36 @@ const commandMap = {
4073
4353
  'QuickPick.selectItem': wrapCommand(selectItem),
4074
4354
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
4075
4355
  'QuickPick.setValue': wrapCommand(setValue),
4076
- 'QuickPick.showQuickInput': showQuickInput
4356
+ 'QuickPick.showQuickInput': showQuickInput,
4357
+ 'QuickPick.showQuickPick': showQuickPick,
4358
+ 'QuickPick.waitUntilVisible': waitUntilVisible
4077
4359
  };
4078
4360
 
4079
4361
  const initializeEditorWorker = async () => {
4080
- const rpc = await create$5({
4362
+ const rpc = await create$6({
4081
4363
  commandMap: {},
4082
4364
  async send(port) {
4083
4365
  await sendMessagePortToEditorWorker(port, 0);
4084
4366
  }
4085
4367
  });
4086
- set$3(rpc);
4368
+ set$4(rpc);
4087
4369
  };
4088
4370
 
4089
4371
  const initializeFileSearchWorker = async () => {
4090
- const rpc = await create$5({
4372
+ const rpc = await create$6({
4091
4373
  commandMap: {},
4092
4374
  async send(port) {
4093
4375
  await sendMessagePortToFileSearchWorker2(port, 0);
4094
4376
  }
4095
4377
  });
4096
- set$2(rpc);
4378
+ set$3(rpc);
4097
4379
  };
4098
4380
 
4099
4381
  const initializeRendererWorker = async () => {
4100
- const rpc = await create$4({
4382
+ const rpc = await create$5({
4101
4383
  commandMap: commandMap
4102
4384
  });
4103
- set$1(rpc);
4385
+ set$2(rpc);
4104
4386
  };
4105
4387
 
4106
4388
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "3.3.0",
3
+ "version": "4.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"